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.
导入
import { IntentRegistry } from '@jangts/agent-core/kits/domains';import { IntentRegistry } from '@jangts/agent-core/kits/domains';其他公开入口:@jangts/agent-core、@jangts/agent-core/types、@jangts/agent-core/kits/domains、@jangts/agent-core/kits。
定义
class IntentRegistry<Definition>泛型参数
| 类型参数 | 约束 | 默认类型 |
|---|---|---|
Definition | IntentToolRegistration | IntentToolRegistration |
构造函数
new IntentRegistry<Definition extends IntentToolRegistration = IntentToolRegistration>(policy?: IntentPolicy<Definition>): IntentRegistry<Definition>| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
policy | IntentPolicy<Definition> | 可省略 | — |
policy 的字段
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
idPattern | RegExp | undefined | 可省略 | 只读。Pattern every Tool id must match. |
scopeModes | readonly string[] | undefined | 可省略 | 只读。Allowed scopePolicy values; undefined accepts any value. |
targetModes | readonly string[] | undefined | 可省略 | 只读。Allowed targetPolicy values; undefined accepts any value. |
contextTiers | readonly string[] | undefined | 可省略 | 只读。Allowed contextTier values; undefined accepts any value. |
actions | readonly string[] | undefined | 可省略 | 只读。Allowed planIntent values; undefined accepts any value. |
delegates | readonly string[] | undefined | 可省略 | 只读。Allowed delegate ids; undefined accepts any non-empty delegate. |
handoffValues | readonly 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. |
tags | readonly string[] | undefined | 可省略 | 只读。Diagnostic tags attached to registration rejections. |
errors | { readonly sealed?: BreakReason; readonly invalid?: BreakReason; readonly duplicate?: (goal: string) => Error | string; } | undefined | 可省略 | 只读。见类型定义及调用场景。 |
返回: IntentRegistry<Definition>。
实例属性
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
definitions | readonly 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. |
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. |
registerAll | Register every domain Tool in iteration order. |
get | Registered domain Tool for id, or undefined when it is absent. |
has | Whether a Tool id is registered. |
ids | Registered Tool ids in registration order. |
values | Iterate the registered goals. |
withIntent | Demand discovery uses tool metadata; domain fields remain attached to these same IDs. |
resolve | Resolve a grouped transport's selected Tool through that Tool's own parser and resolver. |
select | Explicit node selection uses the same immutable model projection. |
entries | Iterate [id, tool] pairs. |
require | Registered domain Tool for id. |
allows | Whether the Tool declares this delegate; unknown goals allow nothing. |
describe | Copy the selected goals out of the registry. |
seal | Finalize the registry; no registration is accepted afterwards. |
成员详情
create
静态成员。
Create and seal a complete catalog in one call.
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.
| 类型参数 | 约束 | 默认类型 |
|---|---|---|
Definition | IntentToolRegistration | — |
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
definitions | Iterable<Definition> | 必需 | — |
policy | IntentPolicy<Definition> | 可省略 | — |
policy 的字段
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
idPattern | RegExp | undefined | 可省略 | 只读。Pattern every Tool id must match. |
scopeModes | readonly string[] | undefined | 可省略 | 只读。Allowed scopePolicy values; undefined accepts any value. |
targetModes | readonly string[] | undefined | 可省略 | 只读。Allowed targetPolicy values; undefined accepts any value. |
contextTiers | readonly string[] | undefined | 可省略 | 只读。Allowed contextTier values; undefined accepts any value. |
actions | readonly string[] | undefined | 可省略 | 只读。Allowed planIntent values; undefined accepts any value. |
delegates | readonly string[] | undefined | 可省略 | 只读。Allowed delegate ids; undefined accepts any non-empty delegate. |
handoffValues | readonly 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. |
tags | readonly 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.
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.
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
input | Definition | 必需 | — |
返回: IntentRegistry<Definition>。
registerAll
实例方法。
Register every domain Tool in iteration order.
registerAll(definitions: Iterable<Definition>): IntentRegistry<Definition>Register every domain Tool in iteration order.
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
definitions | Iterable<Definition> | 必需 | — |
返回: IntentRegistry<Definition>。
get
实例方法。
Registered domain Tool for id, or undefined when it is absent.
get(goal: string): RegisteredIntent<Definition> | undefinedRegistered domain Tool for id, or undefined when it is absent.
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
goal | 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"]>>; }> \| 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.
has(goal: string): booleanWhether a Tool id is registered.
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
goal | string | 必需 | — |
返回: boolean。
ids
实例方法。
Registered Tool ids in registration order.
ids(): readonly IntentId<Definition>[]Registered Tool ids in registration order.
无调用参数。
返回: readonly IntentId<Definition>[]。
values
实例方法。
Iterate the registered goals.
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.
withIntent(context: unknown): ModelToolRegistryDemand discovery uses tool metadata; domain fields remain attached to these same IDs.
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
context | unknown | 必需 | — |
返回: ModelToolRegistry。
resolve
实例方法。
Resolve a grouped transport's selected Tool through that Tool's own parser and resolver.
resolve(selection: import("../../structs/capabilities/model.js").ModelSelection, context: Readonly<{ stageId: string; }>): unknownResolve a grouped transport's selected Tool through that Tool's own parser and resolver.
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
selection | ModelSelection | 必需 | — |
context | Readonly<{ stageId: string; }> | 必需 | — |
selection 的字段
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
input | Record<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. |
toolId | string | 必需 | 只读。Capability the selection resolved to. |
context 的字段
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
stageId | string | 必需 | 见类型定义及调用场景。 |
返回: unknown。
select
实例方法。
Explicit node selection uses the same immutable model projection.
select(ids: readonly string[], ...context: [] | [unknown]): ModelToolRegistryExplicit node selection uses the same immutable model projection.
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
ids | readonly string[] | 必需 | — |
context | [] | [unknown] | 剩余参数 | — |
返回: ModelToolRegistry。
entries
实例方法。
Iterate [id, tool] pairs.
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.
require(id: string): RegisteredIntent<Definition>Registered domain Tool for id.
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
id | 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"]>>; }>。
返回值结构
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
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.
allows(goal: string, delegate: string): booleanWhether the Tool declares this delegate; unknown goals allow nothing.
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
goal | string | 必需 | — |
delegate | string | 必需 | — |
返回: boolean。
describe
实例方法。
Copy the selected goals out of the registry.
describe(goals?: readonly string[]): IntentDescription<Definition>[]Copy the selected goals out of the registry.
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
goals | readonly string[] | 可省略 | — |
返回: IntentDescription<Definition>[]。
seal
实例方法。
Finalize the registry; no registration is accepted afterwards.
seal(): IntentRegistry<Definition>Finalize the registry; no registration is accepted afterwards.
无调用参数。
返回: IntentRegistry<Definition>。
使用示例
- Domain Tools:Tool 声明与范围关系:同一清单提供可用 Tool、允许 delegate、范围别名、来源和工具关系。
先登记一个接口说明 Tool
入门 · Node.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);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
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'));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'));