validateToolReferences
SUPPORT · function · 运行时值
Validate tool references against the complete registered set.
Checking against every registered tool (not only the ones available in the current request) keeps the declaration honest: a module may reference a tool that this request filters out, but never one that does not exist.
导入
ts
import { validateToolReferences } from '@jangts/agent-core/support';js
import { validateToolReferences } from '@jangts/agent-core/support';其他公开入口:@jangts/agent-core/support。
定义
调用
ts
validateToolReferences(names: Iterable<string>, references: readonly CapabilityToolReferences[]): voidValidate tool references against the complete registered set.
Checking against every registered tool (not only the ones available in the current request) keeps the declaration honest: a module may reference a tool that this request filters out, but never one that does not exist.
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
names | Iterable<string> | 必需 | — |
references | readonly CapabilityToolReferences[] | 必需 | — |
返回: void。
使用示例
- 能力组合与声明式安装:集中列出模块、工具引用和注册顺序;通用循环只消费这份实际清单。
直接复用现有模块声明
入门 · Node.js
ts
import { Support } from '@jangts/agent-core';
const modules = [{ id: 'service', description: '服务查询能力', tools: [{ id: 'get_status' }] }];
const catalog = Support.defineCapabilityCatalog(modules);
console.log(catalog.ids(), catalog.findToolOwner('get_status')?.id);js
import { Support } from '@jangts/agent-core';
const modules = [{ id: 'service', description: '服务查询能力', tools: [{ id: 'get_status' }] }];
const catalog = Support.defineCapabilityCatalog(modules);
console.log(catalog.ids(), catalog.findToolOwner('get_status')?.id);增加工具引用和有序安装
配置 · Node.js
ts
import { Support } from '@jangts/agent-core';
const modules = [{ id: 'service', description: '服务查询', tools: [{ id: 'get_status' }],
references: [{ id: 'status-skill', requiredToolIds: ['get_status'], optionalToolIds: [] }] }];
const moduleCatalog = Support.defineCapabilityCatalog(modules, { toolReferences: module => module.references });
const registration = Support.defineRegistrationCatalog<{ installed: string[] }>([
{ id: 'service', register: app => { app.installed.push(moduleCatalog.require('service').id); } },
{ id: 'status-view', when: app => app.installed.includes('service'), register: app => { app.installed.push('status-view'); } },
]);
const app = { installed: [] as string[] };
registration.install(app);
console.log(app.installed);js
import { Support } from '@jangts/agent-core';
const modules = [{ id: 'service', description: '服务查询', tools: [{ id: 'get_status' }],
references: [{ id: 'status-skill', requiredToolIds: ['get_status'], optionalToolIds: [] }] }];
const moduleCatalog = Support.defineCapabilityCatalog(modules, { toolReferences: module => module.references });
const registration = Support.defineRegistrationCatalog([
{ id: 'service', register: app => { app.installed.push(moduleCatalog.require('service').id); } },
{ id: 'status-view', when: app => app.installed.includes('service'), register: app => { app.installed.push('status-view'); } },
]);
const app = { installed: [] };
registration.install(app);
console.log(app.installed);