@@ -119,25 +119,25 @@ export async function realClaudeMemoryExample() {
119119 const toolResults = [ ]
120120
121121 if ( responseData . content ) {
122- for ( const block of responseData . content ) {
123- if ( block . type === "tool_use" && block . name === "memory" ) {
124- console . log ( "\\n🔧 Processing memory tool call:" )
122+ const memoryToolCalls = responseData . content . filter (
123+ ( block : any ) : block is { type : 'tool_use' ; id : string ; name : 'memory' ; input : { command : MemoryCommand ; path : string } } =>
124+ block . type === "tool_use" && block . name === "memory" ,
125+ )
126+
127+ const results = await Promise . all (
128+ memoryToolCalls . map ( ( block : any ) => {
129+ console . log ( "\n🔧 Processing memory tool call:" )
125130 console . log ( `Command: ${ block . input . command } ` )
126131 console . log ( `Path: ${ block . input . path } ` )
127132
128- // Handle the memory tool call
129- const toolResult = await handleClaudeMemoryToolCall (
130- block ,
131- SUPERMEMORY_API_KEY ,
132- {
133- projectId : "python-scraper-help" ,
134- memoryContainerTag : "claude_memory_debug" ,
135- } ,
136- )
137-
138- toolResults . push ( toolResult )
139- }
140- }
133+ return handleClaudeMemoryToolCall ( block , SUPERMEMORY_API_KEY , {
134+ projectId : "python-scraper-help" ,
135+ memoryContainerTag : "claude_memory_debug" ,
136+ } )
137+ } ) ,
138+ )
139+
140+ toolResults . push ( ...results )
141141 }
142142
143143 // Step 3: Send tool results back to Claude if there were any
@@ -196,16 +196,18 @@ export async function processClaudeResponse(
196196 const toolResults = [ ]
197197
198198 if ( claudeResponseData . content ) {
199- for ( const block of claudeResponseData . content ) {
200- if ( block . type === "tool_use" && block . name === "memory" ) {
201- const toolResult = await handleClaudeMemoryToolCall (
202- block ,
203- supermemoryApiKey ,
204- config ,
205- )
206- toolResults . push ( toolResult )
207- }
208- }
199+ const memoryToolCalls = claudeResponseData . content . filter (
200+ ( block : any ) : block is { type : 'tool_use' ; id : string ; name : 'memory' ; input : { command : MemoryCommand ; path : string } } =>
201+ block . type === "tool_use" && block . name === "memory" ,
202+ )
203+
204+ const results = await Promise . all (
205+ memoryToolCalls . map ( ( block : any ) =>
206+ handleClaudeMemoryToolCall ( block , supermemoryApiKey , config ) ,
207+ ) ,
208+ )
209+
210+ toolResults . push ( ...results )
209211 }
210212
211213 return toolResults
0 commit comments