mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-23 05:38:09 +00:00
27 lines
841 B
TypeScript
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;
|
|
}
|
|
}
|
|
}
|