MCPcopy
hub / github.com/CopilotKit/CopilotKit / drainToolStatuses

Function drainToolStatuses

packages/bot-telegram/src/event-renderer.ts:104–124  ·  view source on GitHub ↗
(
    terminal: (toolName: string) => string,
  )

Source from the content-addressed store, hash-verified

102 * `✅` on finish, `⚠️ … (cancelled)` on error/interrupt).
103 */
104 const drainToolStatuses = async (
105 terminal: (toolName: string) => string,
106 ): Promise<void> => {
107 if (toolStatusIds.size === 0) return;
108 const tasks: Promise<void>[] = [];
109 for (const [toolCallId, messageId] of Array.from(toolStatusIds.entries())) {
110 const captured = capturedToolCalls.find(
111 (c) => c.toolCallId === toolCallId,
112 );
113 const toolName = captured?.toolCallName ?? "tool";
114 tasks.push(
115 args
116 .editAt(messageId, telegramHtml(terminal(toolName)))
117 .catch((err) =>
118 console.error("[telegram-renderer] tool-status drain failed:", err),
119 ),
120 );
121 }
122 toolStatusIds.clear();
123 await Promise.all(tasks);
124 };
125
126 const captureToolCall = (
127 toolCallId: string,

Callers 3

onRunFinishedEventFunction · 0.85
onRunErrorEventFunction · 0.85
markInterruptedFunction · 0.85

Calls 5

telegramHtmlFunction · 0.85
entriesMethod · 0.80
pushMethod · 0.65
errorMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…