Skip to content
English

IntentRegistry ​

KIT · class · 运行时值

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.

导入 ​

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

其他公开入口:@jangts/agent-core、@jangts/agent-core/types、@jangts/agent-core/kits/domains、@jangts/agent-core/kits。

定义 ​

ts
class IntentRegistry<Definition>

泛型参数 ​

类型参数约束默认类型
DefinitionIntentToolRegistrationIntentToolRegistration

构造函数 ​

ts
new IntentRegistry<Definition extends IntentToolRegistration = IntentToolRegistration>(policy?: IntentPolicy<Definition>): IntentRegistry<Definition>
参数类型传递说明
policyIntentPolicy<Definition>可省略—
policy 的字段
字段类型必需说明
idPatternRegExp | undefined可省略只读。Pattern every Tool id must match.
scopeModesreadonly string[] | undefined可省略只读。Allowed scopePolicy values; undefined accepts any value.
targetModesreadonly string[] | undefined可省略只读。Allowed targetPolicy values; undefined accepts any value.
contextTiersreadonly string[] | undefined可省略只读。Allowed contextTier values; undefined accepts any value.
actionsreadonly string[] | undefined可省略只读。Allowed planIntent values; undefined accepts any value.
delegatesreadonly string[] | undefined可省略只读。Allowed delegate ids; undefined accepts any non-empty delegate.
handoffValuesreadonly unknown[] | undefined可省略只读。Allowed preparedHandoff values; undefined accepts any value.
assertDefinition((definition: Definition) => void) | undefined可省略只读。Extra App assertion, called after the built-in checks; must return void synchronously.
tagsreadonly string[] | undefined可省略只读。Diagnostic tags attached to registration rejections.
errors{ readonly sealed?: BreakReason; readonly invalid?: BreakReason; readonly duplicate?: (goal: string) => Error | string; } | undefined可省略只读。见类型定义及调用场景。

返回: IntentRegistry<Definition>。

实例属性 ​

字段类型必需说明
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"]>>; }>[]必需只读。Registered goals in registration order.

成员目录 ​

成员用途
create静态。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.

成员详情 ​

create ​

静态成员。

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.

类型参数约束默认类型
DefinitionIntentToolRegistration—
参数类型传递说明
definitionsIterable<Definition>必需—
policyIntentPolicy<Definition>可省略—
policy 的字段
字段类型必需说明
idPatternRegExp | undefined可省略只读。Pattern every Tool id must match.
scopeModesreadonly string[] | undefined可省略只读。Allowed scopePolicy values; undefined accepts any value.
targetModesreadonly string[] | undefined可省略只读。Allowed targetPolicy values; undefined accepts any value.
contextTiersreadonly string[] | undefined可省略只读。Allowed contextTier values; undefined accepts any value.
actionsreadonly string[] | undefined可省略只读。Allowed planIntent values; undefined accepts any value.
delegatesreadonly string[] | undefined可省略只读。Allowed delegate ids; undefined accepts any non-empty delegate.
handoffValuesreadonly unknown[] | undefined可省略只读。Allowed preparedHandoff values; undefined accepts any value.
assertDefinition((definition: Definition) => void) | undefined可省略只读。Extra App assertion, called after the built-in checks; must return void synchronously.
tagsreadonly string[] | undefined可省略只读。Diagnostic tags attached to registration rejections.
errors{ readonly sealed?: BreakReason; readonly invalid?: BreakReason; readonly duplicate?: (goal: string) => Error | string; } | undefined可省略只读。见类型定义及调用场景。

返回: IntentRegistry<Definition>。

register ​

实例方法。

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.

参数类型传递说明
inputDefinition必需—

返回: IntentRegistry<Definition>。

registerAll ​

实例方法。

Register every domain Tool in iteration order.

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

Register every domain Tool in iteration order.

参数类型传递说明
definitionsIterable<Definition>必需—

返回: IntentRegistry<Definition>。

get ​

实例方法。

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.

参数类型传递说明
goalstring必需—

返回: 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。

返回值的可选结构: 选择其中一种结构,各分支的字段要求分别列出。

分支 1

undefined

分支 2
字段类型必需说明
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"]必需Unique 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"]必需Non-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"] | undefined可省略只读。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"] | undefined可省略只读。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"] | undefined可省略App-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"] | undefined可省略App-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"] | undefined可省略App-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"] | undefined可省略App-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"] | undefined可省略App-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"]必需只读。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"]必需Converts 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"]必需Allowed 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"] | undefined可省略Additional actions the intent may use; must be unique.

has ​

实例方法。

Whether a Tool id is registered.

ts
has(goal: string): boolean

Whether a Tool id is registered.

参数类型传递说明
goalstring必需—

返回: boolean。

ids ​

实例方法。

Registered Tool ids in registration order.

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

Registered Tool ids in registration order.

无调用参数。

返回: readonly IntentId<Definition>[]。

values ​

实例方法。

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.

无调用参数。

返回: 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 ​

实例方法。

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.

参数类型传递说明
contextunknown必需—

返回: ModelToolRegistry。

resolve ​

实例方法。

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.

参数类型传递说明
selectionModelSelection必需—
contextReadonly<{ stageId: string; }>必需—
selection 的字段
字段类型必需说明
inputRecord<string, unknown>必需只读。Arguments exactly as produced by the model, before schema parsing.
call{ id: string; name: string; argumentChars: number; } | undefined可省略只读。Native function call that carried the selection, when the provider used one.
toolIdstring必需只读。Capability the selection resolved to.
context 的字段
字段类型必需说明
stageIdstring必需见类型定义及调用场景。

返回: unknown。

select ​

实例方法。

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.

参数类型传递说明
idsreadonly string[]必需—
context[] | [unknown]剩余参数—

返回: ModelToolRegistry。

entries ​

实例方法。

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.

无调用参数。

返回: 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 ​

实例方法。

Registered domain Tool for id.

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

Registered domain Tool for id.

参数类型传递说明
idstring必需—

返回: 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"]>>; }>。

返回值结构
字段类型必需说明
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"]必需Unique 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"]必需Non-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"] | undefined可省略只读。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"] | undefined可省略只读。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"] | undefined可省略App-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"] | undefined可省略App-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"] | undefined可省略App-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"] | undefined可省略App-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"] | undefined可省略App-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"]必需只读。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"]必需Converts 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"]必需Allowed 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"] | undefined可省略Additional actions the intent may use; must be unique.

allows ​

实例方法。

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.

参数类型传递说明
goalstring必需—
delegatestring必需—

返回: boolean。

describe ​

实例方法。

Copy the selected goals out of the registry.

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

Copy the selected goals out of the registry.

参数类型传递说明
goalsreadonly string[]可省略—

返回: IntentDescription<Definition>[]。

seal ​

实例方法。

Finalize the registry; no registration is accepted afterwards.

ts
seal(): IntentRegistry<Definition>

Finalize the registry; no registration is accepted afterwards.

无调用参数。

返回: IntentRegistry<Definition>。

使用示例 ​

先登记一个接口说明 Tool ​

入门 · 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);

增加约束和范围关联,查询入口保持一致 ​

配置 · 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'));

相关策略源码 ​

相关定义 ​

接口参考、使用示例与开发指南。