Skip to content
中文

PreviewTool ​

SUPPORT · interface · Type contract

A model tool with an explicit, presentation-only streaming preview contract.

Import ​

ts
import type { PreviewTool } from '@jangts/agent-core/support';
js
/** @typedef {import('@jangts/agent-core/support').PreviewTool} PreviewTool */

Other public entry points:@jangts/agent-core/support, @jangts/agent-core/support/model.

Definition ​

ts
interface PreviewTool<Input, Selection, Context>

Extends or implements: ModelTool< Input, Selection, Context >.

Type parameters ​

Type parameterConstraintDefault type
Input—unknown
Selection—Input
Context—any

Field structure ​

FieldTypeRequiredDescription
previewtrue | Omit<ReplyPreviewRule, "stageId" | "toolId"> | undefinedOptionalRead-only. See the type definition and usage context.
idstringRequiredRead-only. Unique id within its registry; never blank.
descriptionstringRequiredRead-only. Model-visible description explaining when the capability applies.
inputSchemaSchemaAdapter<Input>RequiredRead-only. Schema describing the arguments; must be an object schema.
activeToolCondition<Context> | undefinedOptionalRead-only. Omitted means active. Authorization remains a separate execution boundary.
asIntentAsIntent<Context> | undefinedOptionalRead-only. Omitted means this tool is not advertised by withIntent().
resolve(input: Input, context: Readonly<{ stageId: string; }>) => SelectionRequiredConverts 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 index ​

MemberPurpose
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.

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
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.

ParameterTypePassingDescription
inputInputRequired—
contextReadonly<{ stageId: string; }>Required—
Fields of context
FieldTypeRequiredDescription
stageIdstringRequiredSee the type definition and usage context.

Returns: Selection.

Awaited value: Awaited<Selection>.

Using the type ​

When using this type, choose type arguments from the table above; parameters with defaults may be omitted.

API reference, usage examples and developer guides.