MCPcopy Create free account
hub / github.com/oboard/claude-code-rev / getToolBlock

Function getToolBlock

src/services/api/openaiCompatibleClient.ts:535–554  ·  view source on GitHub ↗
(toolIndex: number, id?: string, name?: string)

Source from the content-addressed store, hash-verified

533 }
534
535 const getToolBlock = (toolIndex: number, id?: string, name?: string) => {
536 const existing = openBlocks.find(
537 block => block.kind === 'tool_use' && block.sourceIndex === toolIndex,
538 )
539 if (existing && existing.kind === 'tool_use') {
540 if (name) existing.name = name
541 if (id) existing.id = id
542 return existing
543 }
544 const created: OpenBlock = {
545 kind: 'tool_use',
546 index: nextIndex++,
547 sourceIndex: toolIndex,
548 id: id ?? `toolu_${Math.random().toString(36).slice(2, 10)}`,
549 name: name ?? '',
550 closed: false,
551 }
552 openBlocks.push(created)
553 return created
554 }
555
556 const closeOpenBlocks = function* () {
557 for (const block of [...openBlocks].sort((a, b) => a.index - b.index)) {

Callers 1

createOpenAIEventStreamFunction · 0.85

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected