Skip to content
中文

IntentToolRegistration ​

KIT · type · Type contract

Configuration form; object arguments and a Tool proposal are the registration defaults.

Import ​

ts
import type { IntentToolRegistration } from '@jangts/agent-core/kits/domains';
js
/** @typedef {import('@jangts/agent-core/kits/domains').IntentToolRegistration} IntentToolRegistration */

Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/kits/domains, @jangts/agent-core/kits.

Definition ​

Type: IntentToolRegistration

Type expression
ts
type IntentToolRegistration = Omit<IntentTool, 'inputSchema' | 'resolve'> &
  Partial<Pick<IntentTool, 'inputSchema' | 'resolve'>>;

Field structure ​

FieldTypeRequiredDescription
idstringRequiredUnique Tool id, matched against the policy's idPattern when configured.
descriptionstringRequiredNon-blank model-facing description.
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().
delegatesreadonly string[] | undefinedOptionalAllowed delegate ids, retained in declaration order without imposing execution order; non-empty and unique.
scopePolicystring | undefinedOptionalApp-declared scope-mode name; validated against policy.scopeModes when that is set.
targetPolicystring | undefinedOptionalApp-declared target-mode name; validated against policy.targetModes when that is set.
contextTierstring | undefinedOptionalApp-declared context tier; validated against policy.contextTiers when that is set.
planIntentstring | undefinedOptionalApp-declared planning action; validated against policy.actions when that is set.
auxiliaryActionsreadonly string[] | undefinedOptionalAdditional actions the intent may use; must be unique.
preparedHandoffunknownOptionalApp-declared handoff marker; validated against policy.handoffValues when that is set.
resolve((input: any, context: Readonly<{ stageId: string; }>) => any) | undefinedOptionalConverts validated arguments into the value handed back to the caller. Runs inside the model call, so it must return synchronously; throwing rejects the selection.
inputSchemaSchemaAdapter<any> | undefinedOptionalRead-only. Schema describing the arguments; must be an object schema.

Examples ​

Register one tool that explains an interface ​

Beginner · Node.js

ts
import { IntentRegistry, ScopeRegistry } from '@jangts/agent-core/kits/domains';
const tools = IntentRegistry.create([
  { id: 'explain', description: '根据资料解释 SDK', delegates: ['read', 'reply'], asIntent: true },
]);
console.log(tools.ids(), tools.allows('explain', 'read'));
const scopes = ScopeRegistry.create([
  { id: 'sdk', description: 'SDK 说明资料', category: 'knowledge' },
]);
console.log(scopes.require('sdk').knowledgeTopicIds);
js
import { IntentRegistry, ScopeRegistry } from '@jangts/agent-core/kits/domains';
const tools = IntentRegistry.create([
    { id: 'explain', description: '根据资料解释 SDK', delegates: ['read', 'reply'], asIntent: true },
]);
console.log(tools.ids(), tools.allows('explain', 'read'));
const scopes = ScopeRegistry.create([
    { id: 'sdk', description: 'SDK 说明资料', category: 'knowledge' },
]);
console.log(scopes.require('sdk').knowledgeTopicIds);

Add constraints and scope relationships while keeping the same query entry ​

Configuration · Node.js

ts
import { IntentRegistry, ScopeRegistry } from '@jangts/agent-core/kits/domains';
const tools = new IntentRegistry({ idPattern: /^[a-z-]+$/, delegates: ['read', 'reply'] })
  .registerAll([{ id: 'explain', description: '根据资料解释 SDK', delegates: ['read', 'reply'], asIntent: '用户希望了解 SDK 接口或用法。' }]).seal();
const scopes = ScopeRegistry.create([
  { id: 'sdk', description: 'SDK 说明资料', category: 'knowledge', aliases: ['agent-core'], goalIds: ['explain'], knowledgeTopicIds: ['manual'], toolIds: ['read-source'] },
], { categories: ['knowledge'], requireGoals: true, requireSources: true });
console.log(tools.describe(), scopes.normalize('agent-core'));
console.log(scopes.acceptsTool('agent-core', 'explain'), scopes.topics('sdk'));
js
import { IntentRegistry, ScopeRegistry } from '@jangts/agent-core/kits/domains';
const tools = new IntentRegistry({ idPattern: /^[a-z-]+$/, delegates: ['read', 'reply'] })
    .registerAll([{ id: 'explain', description: '根据资料解释 SDK', delegates: ['read', 'reply'], asIntent: '用户希望了解 SDK 接口或用法。' }]).seal();
const scopes = ScopeRegistry.create([
    { id: 'sdk', description: 'SDK 说明资料', category: 'knowledge', aliases: ['agent-core'], goalIds: ['explain'], knowledgeTopicIds: ['manual'], toolIds: ['read-source'] },
], { categories: ['knowledge'], requireGoals: true, requireSources: true });
console.log(tools.describe(), scopes.normalize('agent-core'));
console.log(scopes.acceptsTool('agent-core', 'explain'), scopes.topics('sdk'));

API reference, usage examples and developer guides.