IntentOptions
CORE · interface · Type contract
Demand-facing hints attached to one Tool; no independent identity is created.
Import
ts
import type { IntentOptions } from '@jangts/agent-core';1
js
/** @typedef {import('@jangts/agent-core').IntentOptions} IntentOptions */1
Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs.
Definition
ts
interface IntentOptions<Context>1
Type parameters
| Type parameter | Constraint | Default type |
|---|---|---|
Context | — | — |
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
description | string | undefined | Optional | Read-only. Optional demand-facing description; otherwise the tool description is reused. |
when | ((context: ToolContext<Context>) => boolean) | undefined | Optional | Read-only. Synchronous participation predicate. |
delegates | readonly string[] | undefined | Optional | Read-only. Allowed continuation delegates, not an execution sequence. |
Examples
- Model tools and transports: typed selection only after full validation: A tool definition provides a Schema and resolver; a transport translates wire output into the unified model selection contract.
- Real tool invocation and in-request runtime: Core registers and executes real tools and returns receipts carrying an invocation; business authorization is owned by the implementation registered by the App.
- Tool best practice: one definition generates the model tool and execution runtime: Register Schema, authorization, execution, and output validation once, and bind the App per request instead of maintaining two tool lists.
- Decorators: complete handlers and existing host methods: Classes construct definitions automatically; methods bind the real host. Outputs still use original define, constructor and bind contracts.
Declare two selectable tools
Beginner · Node.js
ts
import { ModelToolRegistry } from '@jangts/agent-core';
const inputSchema = { jsonSchema: { type: 'object', properties: {}, additionalProperties: false },
parse(value: unknown) {
if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).length) throw new Error('需要空对象');
return {};
} };
const tools = new ModelToolRegistry([
{ id: 'greet', description: '回答问候', inputSchema, resolve: () => 'greet' },
{ id: 'status', description: '查询状态', inputSchema, resolve: () => 'status' },
]).seal();
console.log(tools.resolve({ toolId: 'status', input: {} }, { stageId: 'recognize' }));1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
js
import { ModelToolRegistry } from '@jangts/agent-core';
const inputSchema = { jsonSchema: { type: 'object', properties: {}, additionalProperties: false },
parse(value) {
if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).length)
throw new Error('需要空对象');
return {};
} };
const tools = new ModelToolRegistry([
{ id: 'greet', description: '回答问候', inputSchema, resolve: () => 'greet' },
{ id: 'status', description: '查询状态', inputSchema, resolve: () => 'status' },
]).seal();
console.log(tools.resolve({ toolId: 'status', input: {} }, { stageId: 'recognize' }));1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
Project an allowed subset to only one stage
Configuration · Node.js
ts
import { ModelToolRegistry, Support } from '@jangts/agent-core';
const schema = Support.defineSchema({ jsonSchema: { type: 'object', properties: {} },
parse(value: unknown) { if (!value || typeof value !== 'object' || Array.isArray(value)) throw new TypeError('需要对象'); return {}; } });
const registry = new ModelToolRegistry([
{ id: 'greet', description: '问候', inputSchema: schema, resolve: () => 'greet' },
{ id: 'status', description: '状态', inputSchema: schema, resolve: () => 'status' },
]).seal();
const readOnly = registry.select(['status']);
const transport = Support.createModelTransport({ id: 'recognize', tools: readOnly });
console.log(transport.id, readOnly.ids());1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
js
import { ModelToolRegistry, Support } from '@jangts/agent-core';
const schema = Support.defineSchema({ jsonSchema: { type: 'object', properties: {} },
parse(value) { if (!value || typeof value !== 'object' || Array.isArray(value))
throw new TypeError('需要对象'); return {}; } });
const registry = new ModelToolRegistry([
{ id: 'greet', description: '问候', inputSchema: schema, resolve: () => 'greet' },
{ id: 'status', description: '状态', inputSchema: schema, resolve: () => 'status' },
]).seal();
const readOnly = registry.select(['status']);
const transport = Support.createModelTransport({ id: 'recognize', tools: readOnly });
console.log(transport.id, readOnly.ids());1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Related policy source
- Check order for tool input, execution, output, and late results
- Authorization and model tool projection come from the same definition