RegisteredIntent
KIT · type · Type contract
Frozen registration view: list fields are frozen copies, helper methods are dropped.
Import
ts
import type { RegisteredIntent } from '@jangts/agent-core/kits/domains';js
/** @typedef {import('@jangts/agent-core/kits/domains').RegisteredIntent} RegisteredIntent */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: RegisteredIntent<Definition>
Type expression
ts
type RegisteredIntent<Definition extends IntentToolRegistration> = Readonly<
Omit<
RegistrationProjection<Definition, IntentTool>,
'delegates' | 'auxiliaryActions' | 'inputSchema' | 'resolve'
> &
ModelTool<any, any> &
RegisteredIntentLists<Definition> & {
id: Definition['id'];
delegates: Readonly<NonNullable<Definition['delegates']>>;
}
>;Type parameters
| Type parameter | Constraint | Default type |
|---|---|---|
Definition | IntentToolRegistration | — |
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
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"] | Required | 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"] | Required | 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 | Optional | Read-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"] | undefined | Optional | Read-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"] | undefined | Optional | 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 | Optional | 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 | Optional | 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 | Optional | 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 | Optional | 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"] | Required | Read-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"] | Required | 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"] | Required | 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 | Optional | Additional actions the intent may use; must be unique. |
Member index
| Member | Purpose |
|---|---|
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. |
Member details
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.
ts
RegisteredIntent.resolve(input: any, context: Readonly<{ stageId: string; }>): anyConverts validated arguments into the value handed back to the caller.
Runs inside the model call, so it must return synchronously; throwing rejects the selection.
| Parameter | Type | Passing | Description |
|---|---|---|---|
input | any | Required | — |
context | Readonly<{ stageId: string; }> | Required | — |
Fields of context
| Field | Type | Required | Description |
|---|---|---|---|
stageId | string | Required | See the type definition and usage context. |
Returns: any.
Examples
- Domain Tools: tool declarations and scope relationships: One list provides the available tools, allowed delegates, scope aliases, sources, and tool relationships.
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'));