Files
openclaw/src/tools/execution.ts
2026-06-04 03:45:53 -04:00

27 lines
841 B
TypeScript

// Defines tool execution references used by the runtime dispatcher.
import type { ToolExecutorRef } from "./types.js";
/**
* Formatting helpers for tool executor references.
*
* Executor refs are closed discriminated unions; the formatted string is for
* diagnostics/logging and must not become a parser contract.
*/
/** Render an executor ref as a compact diagnostic label. */
export function formatToolExecutorRef(ref: ToolExecutorRef): string {
switch (ref.kind) {
case "core":
return `core:${ref.executorId}`;
case "plugin":
return `plugin:${ref.pluginId}:${ref.toolName}`;
case "channel":
return `channel:${ref.channelId}:${ref.actionId}`;
case "mcp":
return `mcp:${ref.serverId}:${ref.toolName}`;
default: {
const exhaustive: never = ref;
return exhaustive;
}
}
}