Tài liệu

Tool view

tool-view thay thế hoặc bổ sung cách hiển thị tool call do cùng app khai báo. Gắn nó bằng toolNames không rỗng. Core truyền đúng một prop toolResult và giữ nguyên mount khi state thay đổi.

YAML
contributes:
  ui:
    - id: calendar-result
      kind: nativeModule
      surface: tool-view
      slot: chat.message.inline.below
      toolNames: [readCalendar]
      renderBeforeOutput: true
      module:
        entry: dist/ui/app.js
        export: CalendarResult
TSX
import type { ToolResultSurfaceProps } from '@sota/platform';

type Input = { from: string; to: string };
type Output = { events: Array<{ id: string; title: string }> };

export function CalendarResult({ toolResult }: ToolResultSurfaceProps<Input, Output>) {
  if (toolResult.state === 'input-streaming') return <p>Preparing…</p>;
  if (toolResult.state === 'output-pending') return <p>Waiting for an action…</p>;
  if (toolResult.state === 'output-error') return <p>{toolResult.errorText}</p>;
  if (toolResult.state === 'output-denied') return <p>Permission denied.</p>;
  if (toolResult.state !== 'output-available') return <p>Running…</p>;
  return <p>{toolResult.result?.events.length ?? 0} events</p>;
}
StateContract
input-streamingPartial input dạng unknown; chỉ có khi bật renderBeforeOutput.
input-available, approval statesInput hoàn chỉnh đã validate schema.
output-pendingTool call đang deferred; có thể có deferred.operationId và data opaque của app.
output-availableresult là app result đã bỏ metadata transport; output giữ raw host value.
output-error, output-deniedKhông được giả định có result.

execution chỉ app lane đã tạo tool call. Đây là context chẩn đoán cho payload, không phải yêu cầu load historical artifact của producer.

Mục lục

Esc

Tìm theo tiêu đề và nội dung trong mọi chương.