Skip to content
English

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

字段结构 ​

字段类型必需说明
previewtrue | Omit<ReplyPreviewRule, "stageId" | "toolId"> | undefined可省略只读。见类型定义及调用场景。
idstring必需只读。Unique id within its registry; never blank.
descriptionstring必需只读。Model-visible description explaining when the capability applies.
inputSchemaSchemaAdapter<Input>必需只读。Schema describing the arguments; must be an object schema.
activeToolCondition<Context> | undefined可省略只读。Omitted means active. Authorization remains a separate execution boundary.
asIntentAsIntent<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.

成员目录 ​

成员用途
resolveConverts 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; }>): 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.

参数类型传递说明
inputInput必需—
contextReadonly<{ stageId: string; }>必需—
context 的字段
字段类型必需说明
stageIdstring必需见类型定义及调用场景。

返回: Selection。

等待后的值: Awaited<Selection>。

类型使用 ​

使用该类型时,可按上方泛型参数选择类型;有默认类型的参数可以省略。

相关定义 ​

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