Skip to content
中文

createIntentRegistry ​

KIT · function · Runtime value

Create and seal a complete catalog; use the constructor for incremental installation.

Import ​

ts
import { createIntentRegistry } from '@jangts/agent-core/kits/domains';
js
import { createIntentRegistry } from '@jangts/agent-core/kits/domains';

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

Definition ​

Type parameters ​

Type parameterConstraintDefault type
DefinitionIntentToolRegistration—

Call ​

ts
createIntentRegistry<Definition extends IntentToolRegistration>(definitions: Iterable<Definition>, policy?: IntentPolicy<Definition>): IntentRegistry<Definition>

Create and seal a complete catalog; use the constructor for incremental installation.

Type parameterConstraintDefault type
DefinitionIntentToolRegistration—
ParameterTypePassingDescription
definitionsIterable<Definition>Required—
policyIntentPolicy<Definition>Optional—
Fields of policy
FieldTypeRequiredDescription
idPatternRegExp | undefinedOptionalRead-only. Pattern every Tool id must match.
scopeModesreadonly string[] | undefinedOptionalRead-only. Allowed scopePolicy values; undefined accepts any value.
targetModesreadonly string[] | undefinedOptionalRead-only. Allowed targetPolicy values; undefined accepts any value.
contextTiersreadonly string[] | undefinedOptionalRead-only. Allowed contextTier values; undefined accepts any value.
actionsreadonly string[] | undefinedOptionalRead-only. Allowed planIntent values; undefined accepts any value.
delegatesreadonly string[] | undefinedOptionalRead-only. Allowed delegate ids; undefined accepts any non-empty delegate.
handoffValuesreadonly unknown[] | undefinedOptionalRead-only. Allowed preparedHandoff values; undefined accepts any value.
assertDefinition((definition: Definition) => void) | undefinedOptionalRead-only. Extra App assertion, called after the built-in checks; must return void synchronously.
tagsreadonly string[] | undefinedOptionalRead-only. Diagnostic tags attached to registration rejections.
errors{ readonly sealed?: BreakReason; readonly invalid?: BreakReason; readonly duplicate?: (goal: string) => Error | string; } | undefinedOptionalRead-only. See the type definition and usage context.

Returns: IntentRegistry<Definition>.

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.