Skip to content
中文

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
FieldTypeRequiredDescription
idstring | undefinedOptionalRead-only. Unique id within its registry; never blank.
descriptionstring | undefinedOptionalRead-only. Model-visible description explaining when the capability applies.
inputSchemaSchemaAdapter<any> | undefinedOptionalRead-only. Schema describing the arguments; must be an object schema.
activeToolCondition<any> | undefinedOptionalRead-only. Omitted means active. Authorization remains a separate execution boundary.
asIntentAsIntent<any> | undefinedOptionalRead-only. Omitted means this tool is not advertised by withIntent().
resolve((input: any, context: Readonly<{ stageId: string; }>) => unknown) | undefinedOptionalRead-only. See the type definition and usage context.

Examples ​

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);

API reference, usage examples and developer guides.