Skip to content
中文

IntentRegistry ​

KIT · class · Runtime value

Goal semantics and allowed values are configuration; the registry owns their common lifecycle.

Registration order is preserved by ids, definitions, values and entries; once seal() is called the set is final and further registration is rejected.

Import ​

ts
import { IntentRegistry } from '@jangts/agent-core/kits/domains';
js
import { IntentRegistry } 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 ​

ts
class IntentRegistry<Definition>

Type parameters ​

Type parameterConstraintDefault type
DefinitionIntentToolRegistrationIntentToolRegistration

Constructor ​

ts
new IntentRegistry<Definition extends IntentToolRegistration = IntentToolRegistration>(policy?: IntentPolicy<Definition>): IntentRegistry<Definition>
ParameterTypePassingDescription
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>.

Instance properties ​

FieldTypeRequiredDescription
definitionsreadonly Readonly<Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; }>[]RequiredRead-only. Registered goals in registration order.

Member index ​

MemberPurpose
createStatic. Create and seal a complete catalog in one call.
registerValidate, freeze and add one domain Tool. Checks run in a fixed order — sealed, identity, context contract, auxiliary actions, handoff, plan, delegates — so the reported violation is stable when several rules fail.
registerAllRegister every domain Tool in iteration order.
getRegistered domain Tool for id, or undefined when it is absent.
hasWhether a Tool id is registered.
idsRegistered Tool ids in registration order.
valuesIterate the registered goals.
withIntentDemand discovery uses tool metadata; domain fields remain attached to these same IDs.
resolveResolve a grouped transport's selected Tool through that Tool's own parser and resolver.
selectExplicit node selection uses the same immutable model projection.
entriesIterate [id, tool] pairs.
requireRegistered domain Tool for id.
allowsWhether the Tool declares this delegate; unknown goals allow nothing.
describeCopy the selected goals out of the registry.
sealFinalize the registry; no registration is accepted afterwards.

Member details ​

create ​

Static member.

Create and seal a complete catalog in one call.

ts
IntentRegistry.create<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>.

register ​

Instance method.

Validate, freeze and add one domain Tool.

Checks run in a fixed order — sealed, identity, context contract, auxiliary actions, handoff, plan, delegates — so the reported violation is stable when several rules fail.

ts
register(input: Definition): IntentRegistry<Definition>

Validate, freeze and add one domain Tool.

Checks run in a fixed order — sealed, identity, context contract, auxiliary actions, handoff, plan, delegates — so the reported violation is stable when several rules fail.

ParameterTypePassingDescription
inputDefinitionRequired—

Returns: IntentRegistry<Definition>.

registerAll ​

Instance method.

Register every domain Tool in iteration order.

ts
registerAll(definitions: Iterable<Definition>): IntentRegistry<Definition>

Register every domain Tool in iteration order.

ParameterTypePassingDescription
definitionsIterable<Definition>Required—

Returns: IntentRegistry<Definition>.

get ​

Instance method.

Registered domain Tool for id, or undefined when it is absent.

ts
get(goal: string): RegisteredIntent<Definition> | undefined

Registered domain Tool for id, or undefined when it is absent.

ParameterTypePassingDescription
goalstringRequired—

Returns: Readonly<Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" \| "inputSchema" \| "delegates" \| "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; }> \| undefined.

Optional shapes of Return value: choose one shape; required fields for each branch are listed separately.

Branch 1

undefined

Branch 2
FieldTypeRequiredDescription
id(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["id"]RequiredUnique Tool id, matched against the policy's idPattern when configured. Unique id within its registry; never blank.
description(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["description"]RequiredNon-blank model-facing description. Model-visible description explaining when the capability applies.
active(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["active"] | undefinedOptionalRead-only. Omitted means active. Authorization remains a separate execution boundary.
asIntent(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["asIntent"] | undefinedOptionalRead-only. Omitted means this tool is not advertised by withIntent().
scopePolicy(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["scopePolicy"] | undefinedOptionalApp-declared scope-mode name; validated against policy.scopeModes when that is set.
targetPolicy(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["targetPolicy"] | undefinedOptionalApp-declared target-mode name; validated against policy.targetModes when that is set.
contextTier(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["contextTier"] | undefinedOptionalApp-declared context tier; validated against policy.contextTiers when that is set.
planIntent(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["planIntent"] | undefinedOptionalApp-declared planning action; validated against policy.actions when that is set.
preparedHandoff(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["preparedHandoff"] | undefinedOptionalApp-declared handoff marker; validated against policy.handoffValues when that is set.
inputSchema(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["inputSchema"]RequiredRead-only. Schema describing the arguments; must be an object schema.
resolve(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["resolve"]RequiredConverts validated arguments into the value handed back to the caller. Runs inside the model call, so it must return synchronously; throwing rejects the selection.
delegates(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["delegates"]RequiredAllowed delegate ids, retained in declaration order without imposing execution order; non-empty and unique.
auxiliaryActions(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["auxiliaryActions"] | undefinedOptionalAdditional actions the intent may use; must be unique.

has ​

Instance method.

Whether a Tool id is registered.

ts
has(goal: string): boolean

Whether a Tool id is registered.

ParameterTypePassingDescription
goalstringRequired—

Returns: boolean.

ids ​

Instance method.

Registered Tool ids in registration order.

ts
ids(): readonly IntentId<Definition>[]

Registered Tool ids in registration order.

No call parameters.

Returns: readonly IntentId<Definition>[].

values ​

Instance method.

Iterate the registered goals.

ts
values(): MapIterator<Readonly<Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; }>>

Iterate the registered goals.

No call parameters.

Returns: MapIterator<Readonly<Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" \| "inputSchema" \| "delegates" \| "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; }>>.

withIntent ​

Instance method.

Demand discovery uses tool metadata; domain fields remain attached to these same IDs.

ts
withIntent(context: unknown): ModelToolRegistry

Demand discovery uses tool metadata; domain fields remain attached to these same IDs.

ParameterTypePassingDescription
contextunknownRequired—

Returns: ModelToolRegistry.

resolve ​

Instance method.

Resolve a grouped transport's selected Tool through that Tool's own parser and resolver.

ts
resolve(selection: import("../../structs/capabilities/model.js").ModelSelection, context: Readonly<{ stageId: string; }>): unknown

Resolve a grouped transport's selected Tool through that Tool's own parser and resolver.

ParameterTypePassingDescription
selectionModelSelectionRequired—
contextReadonly<{ stageId: string; }>Required—
Fields of selection
FieldTypeRequiredDescription
inputRecord<string, unknown>RequiredRead-only. Arguments exactly as produced by the model, before schema parsing.
call{ id: string; name: string; argumentChars: number; } | undefinedOptionalRead-only. Native function call that carried the selection, when the provider used one.
toolIdstringRequiredRead-only. Capability the selection resolved to.
Fields of context
FieldTypeRequiredDescription
stageIdstringRequiredSee the type definition and usage context.

Returns: unknown.

select ​

Instance method.

Explicit node selection uses the same immutable model projection.

ts
select(ids: readonly string[], ...context: [] | [unknown]): ModelToolRegistry

Explicit node selection uses the same immutable model projection.

ParameterTypePassingDescription
idsreadonly string[]Required—
context[] | [unknown]Rest parameter—

Returns: ModelToolRegistry.

entries ​

Instance method.

Iterate [id, tool] pairs.

ts
entries(): MapIterator<[string, Readonly<Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; }>]>

Iterate [id, tool] pairs.

No call parameters.

Returns: MapIterator<[string, Readonly<Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" \| "inputSchema" \| "delegates" \| "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; }>]>.

require ​

Instance method.

Registered domain Tool for id.

ts
require(id: string): RegisteredIntent<Definition>

Registered domain Tool for id.

ParameterTypePassingDescription
idstringRequired—

Returns: Readonly<Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" \| "inputSchema" \| "delegates" \| "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; }>.

Return value structure
FieldTypeRequiredDescription
id(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["id"]RequiredUnique Tool id, matched against the policy's idPattern when configured. Unique id within its registry; never blank.
description(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["description"]RequiredNon-blank model-facing description. Model-visible description explaining when the capability applies.
active(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["active"] | undefinedOptionalRead-only. Omitted means active. Authorization remains a separate execution boundary.
asIntent(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["asIntent"] | undefinedOptionalRead-only. Omitted means this tool is not advertised by withIntent().
scopePolicy(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["scopePolicy"] | undefinedOptionalApp-declared scope-mode name; validated against policy.scopeModes when that is set.
targetPolicy(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["targetPolicy"] | undefinedOptionalApp-declared target-mode name; validated against policy.targetModes when that is set.
contextTier(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["contextTier"] | undefinedOptionalApp-declared context tier; validated against policy.contextTiers when that is set.
planIntent(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["planIntent"] | undefinedOptionalApp-declared planning action; validated against policy.actions when that is set.
preparedHandoff(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["preparedHandoff"] | undefinedOptionalApp-declared handoff marker; validated against policy.handoffValues when that is set.
inputSchema(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["inputSchema"]RequiredRead-only. Schema describing the arguments; must be an object schema.
resolve(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["resolve"]RequiredConverts validated arguments into the value handed back to the caller. Runs inside the model call, so it must return synchronously; throwing rejects the selection.
delegates(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["delegates"]RequiredAllowed delegate ids, retained in declaration order without imposing execution order; non-empty and unique.
auxiliaryActions(Omit<Readonly<IntentTool & RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof IntentTool>>>, "resolve" | "inputSchema" | "delegates" | "auxiliaryActions"> & ModelTool<any, any, any> & RegisteredIntentLists<Definition> & { id: Definition["id"]; delegates: Readonly<NonNullable<Definition["delegates"]>>; })["auxiliaryActions"] | undefinedOptionalAdditional actions the intent may use; must be unique.

allows ​

Instance method.

Whether the Tool declares this delegate; unknown goals allow nothing.

ts
allows(goal: string, delegate: string): boolean

Whether the Tool declares this delegate; unknown goals allow nothing.

ParameterTypePassingDescription
goalstringRequired—
delegatestringRequired—

Returns: boolean.

describe ​

Instance method.

Copy the selected goals out of the registry.

ts
describe(goals?: readonly string[]): IntentDescription<Definition>[]

Copy the selected goals out of the registry.

ParameterTypePassingDescription
goalsreadonly string[]Optional—

Returns: IntentDescription<Definition>[].

seal ​

Instance method.

Finalize the registry; no registration is accepted afterwards.

ts
seal(): IntentRegistry<Definition>

Finalize the registry; no registration is accepted afterwards.

No call parameters.

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.