Skip to content
中文

Tool module composition and declarative installation ​

List modules, tool references, and registration order in one place; the generic loop consumes only that actual list.

defineCapabilityCatalog verifies unique identities for modules and tools and builds the tools and findToolOwner projections; requiredToolIds and optionalToolIds must both point to already registered tools, and optional only indicates a usage relationship, not permission to write a wrong reference. It does not create new Core execution stages.

defineRegistrationCatalog compiles static installation items into a read-only catalog, and install(app) evaluates when in order and calls register. Later items can observe state installed by earlier ones. Predicates and registration are both synchronous; enabled is not a substitute for the three distinct decisions of deployment configuration, this request's permissions, and execution authorization.

defineAssociatedCatalog verifies owner-to-tool references at assembly time: a string may only name an independently registered tool, inline declarations may fill defaults, and duplicate tool IDs or unknown owners are rejected. It creates no parallel intent identity and executes no tools.

A Catalog get may return undefined, while require throws when nothing is found; ids/definitions/values/entries are different views of the same collection, not parallel lists.

Progressive examples for the same business case ​

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

Policies & implementations ​

API reference, usage examples and developer guides.