Files
openclaw/src/chat/tool-content.ts
Tak Hoffman cc5c691f00 feat(ui): render assistant directives and add embed tag (#64104)
* Add embed rendering for Control UI assistant output

* Add changelog entry for embed rendering

* Harden canvas path resolution and stage isolation

* Secure assistant media route and preserve UI avatar override

* Fix chat media and history regressions

* Harden embed iframe URL handling

* Fix embed follow-up review regressions

* Restore offloaded chat attachment persistence

* Harden hook and media routing

* Fix embed review follow-ups

* feat(ui): add configurable embed sandbox mode

* fix(gateway): harden assistant media and auth rotation

* fix(gateway): restore websocket pairing handshake flows

* fix(gateway): restore ws hello policy details

* Restore dropped control UI shell wiring

* Fix control UI reconnect cleanup regressions

* fix(gateway): restore media root and auth getter compatibility

* feat(ui): rename public canvas tag to embed

* fix(ui): address remaining media and gateway review issues

* fix(ui): address remaining embed and attachment review findings

* fix(ui): restore stop control and tool card inputs

* fix(ui): address history and attachment review findings

* fix(ui): restore prompt contribution wiring

* fix(ui): address latest history and directive reviews

* fix(ui): forward password auth for assistant media

* fix(ui): suppress silent transcript tokens with media

* feat(ui): add granular embed sandbox modes

* fix(ui): preserve relative media directives in history

* docs(ui): document embed sandbox modes

* fix(gateway): restrict canvas history hoisting to tool entries

* fix(gateway): tighten embed follow-up review fixes

* fix(ci): repair merged branch type drift

* fix(prompt): restore stable runtime prompt rendering

* fix(ui): harden local attachment preview checks

* fix(prompt): restore channel-aware approval guidance

* fix(gateway): enforce auth rotation and media cleanup

* feat(ui): gate external embed urls behind config

* fix(ci): repair rebased branch drift

* fix(ci): resolve remaining branch check failures
2026-04-11 07:32:53 -05:00

36 lines
1.2 KiB
TypeScript

export type ToolContentBlock = Record<string, unknown>;
export function normalizeToolContentType(value: unknown): string {
return typeof value === "string" ? value.toLowerCase() : "";
}
export function isToolCallContentType(value: unknown): boolean {
const type = normalizeToolContentType(value);
return type === "toolcall" || type === "tool_call" || type === "tooluse" || type === "tool_use";
}
export function isToolResultContentType(value: unknown): boolean {
const type = normalizeToolContentType(value);
return type === "toolresult" || type === "tool_result";
}
export function isToolCallBlock(block: ToolContentBlock): boolean {
return isToolCallContentType(block.type);
}
export function isToolResultBlock(block: ToolContentBlock): boolean {
return isToolResultContentType(block.type);
}
export function resolveToolBlockArgs(block: ToolContentBlock): unknown {
return block.args ?? block.arguments ?? block.input;
}
export function resolveToolUseId(block: ToolContentBlock): string | undefined {
const id =
(typeof block.id === "string" && block.id.trim()) ||
(typeof block.tool_use_id === "string" && block.tool_use_id.trim()) ||
(typeof block.toolUseId === "string" && block.toolUseId.trim());
return id || undefined;
}