PreviewTool
SUPPORT · interface · 类型合同
A model tool with an explicit, presentation-only streaming preview contract.
导入
ts
import type { PreviewTool } from '@jangts/agent-core/support';js
/** @typedef {import('@jangts/agent-core/support').PreviewTool} PreviewTool */其他公开入口:@jangts/agent-core/support、@jangts/agent-core/support/model。
定义
ts
interface PreviewTool<Input, Selection, Context>继承或实现: ModelTool< Input, Selection, Context >。
泛型参数
| 类型参数 | 约束 | 默认类型 |
|---|---|---|
Input | — | unknown |
Selection | — | Input |
Context | — | any |
字段结构
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
preview | true | Omit<ReplyPreviewRule, "stageId" | "toolId"> | undefined | 可省略 | 只读。见类型定义及调用场景。 |
id | string | 必需 | 只读。Unique id within its registry; never blank. |
description | string | 必需 | 只读。Model-visible description explaining when the capability applies. |
inputSchema | SchemaAdapter<Input> | 必需 | 只读。Schema describing the arguments; must be an object schema. |
active | ToolCondition<Context> | undefined | 可省略 | 只读。Omitted means active. Authorization remains a separate execution boundary. |
asIntent | AsIntent<Context> | undefined | 可省略 | 只读。Omitted means this tool is not advertised by withIntent(). |
resolve | (input: Input, context: Readonly<{ stageId: string; }>) => Selection | 必需 | 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. |
成员目录
| 成员 | 用途 |
|---|---|
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. |
成员详情
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
PreviewTool.resolve(input: Input, context: Readonly<{ stageId: string; }>): SelectionConverts validated arguments into the value handed back to the caller.
Runs inside the model call, so it must return synchronously; throwing rejects the selection.
| 参数 | 类型 | 传递 | 说明 |
|---|---|---|---|
input | Input | 必需 | — |
context | Readonly<{ stageId: string; }> | 必需 | — |
context 的字段
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
stageId | string | 必需 | 见类型定义及调用场景。 |
返回: Selection。
等待后的值: Awaited<Selection>。
类型使用
使用该类型时,可按上方泛型参数选择类型;有默认类型的参数可以省略。