MCPcopy
hub / github.com/opactorai/Claudable / extractToolCallId

Function extractToolCallId

components/chat/ChatLog.tsx:199–238  ·  view source on GitHub ↗
(
  metadata?: Record<string, unknown> | null
)

Source from the content-addressed store, hash-verified

197};
198
199const extractToolCallId = (
200 metadata?: Record<string, unknown> | null
201): string | null => {
202 if (!metadata) return null;
203
204 const directCandidates = [
205 metadata.toolCallId,
206 metadata.tool_call_id,
207 metadata.toolCallID,
208 metadata.tool_callID,
209 ];
210
211 for (const candidate of directCandidates) {
212 const value = pickFirstString(candidate);
213 if (value) {
214 return value;
215 }
216 }
217
218 const nested =
219 (metadata.tool_call ?? metadata.toolCall ?? metadata.tool ?? null) as
220 | Record<string, unknown>
221 | undefined;
222 if (nested && typeof nested === 'object') {
223 const nestedCandidates = [
224 nested.id,
225 nested.toolCallId,
226 nested.tool_call_id,
227 nested.tool_callID,
228 ];
229 for (const candidate of nestedCandidates) {
230 const value = pickFirstString(candidate);
231 if (value) {
232 return value;
233 }
234 }
235 }
236
237 return null;
238};
239
240const deriveToolInfoFromMetadata = (
241 metadata?: Record<string, unknown> | null

Callers 1

ChatLogFunction · 0.85

Calls 1

pickFirstStringFunction · 0.70

Tested by

no test coverage detected