ToolAssociation
SUPPORT · type · Type contract
Explicit tool references or inline overrides of the owner's default model interface.
Import
ts
import type { ToolAssociation } from '@jangts/agent-core/support';js
/** @typedef {import('@jangts/agent-core/support').ToolAssociation} ToolAssociation */Other public entry points:@jangts/agent-core/support.
Definition
Type: ToolAssociation
Type expression
ts
type ToolAssociation = string | Partial<ModelToolRegistration>;Union branch structure
Optional shapes of ToolAssociation: choose one shape; required fields for each branch are listed separately.
Branch 1
string
Branch 2
| Field | Type | Required | Description |
|---|---|---|---|
id | string | undefined | Optional | Read-only. Unique id within its registry; never blank. |
description | string | undefined | Optional | Read-only. Model-visible description explaining when the capability applies. |
inputSchema | SchemaAdapter<any> | undefined | Optional | Read-only. Schema describing the arguments; must be an object schema. |
active | ToolCondition<any> | undefined | Optional | Read-only. Omitted means active. Authorization remains a separate execution boundary. |
asIntent | AsIntent<any> | undefined | Optional | Read-only. Omitted means this tool is not advertised by withIntent(). |
resolve | ((input: any, context: Readonly<{ stageId: string; }>) => unknown) | undefined | Optional | Read-only. See the type definition and usage context. |
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);