validateToolReferences
SUPPORT · function · Runtime value
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.
Import
ts
import { validateToolReferences } from '@jangts/agent-core/support';js
import { validateToolReferences } from '@jangts/agent-core/support';Other public entry points:@jangts/agent-core/support.
Definition
Call
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.
| Parameter | Type | Passing | Description |
|---|---|---|---|
names | Iterable<string> | Required | — |
references | readonly CapabilityToolReferences[] | Required | — |
Returns: void.
Examples
- Tool module composition and declarative installation: List modules, tool references, and registration order in one place; the generic loop consumes only that actual list.
Reuse existing module declarations directly
Beginner · 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);Add tool references and ordered installation
Configuration · 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);