MCPcopy Index your code
hub / github.com/tiann/hapi / waitForMessagesAndGetAsString

Method waitForMessagesAndGetAsString

cli/src/utils/MessageQueue2.ts:317–336  ·  view source on GitHub ↗

* Wait for messages and return all messages with the same mode as a single string * Returns { message: string, mode: T } or null if aborted/closed

(abortSignal?: AbortSignal)

Source from the content-addressed store, hash-verified

315 * Returns { message: string, mode: T } or null if aborted/closed
316 */
317 async waitForMessagesAndGetAsString(abortSignal?: AbortSignal): Promise<{ message: string, mode: T, isolate: boolean, hash: string } | null> {
318 // If we have messages, return them immediately
319 if (this.queue.length > 0) {
320 return this.collectBatch();
321 }
322
323 // If closed or already aborted, return null
324 if (this.closed || abortSignal?.aborted) {
325 return null;
326 }
327
328 // Wait for messages to arrive
329 const hasMessages = await this.waitForMessages(abortSignal);
330
331 if (!hasMessages) {
332 return null;
333 }
334
335 return this.collectBatch();
336 }
337
338 /**
339 * Collect a batch of messages with the same mode, respecting isolation requirements

Callers 10

runAgentSessionFunction · 0.95
runMainLoopMethod · 0.80
runMainLoopMethod · 0.80
runMainLoopMethod · 0.80
runMainLoopMethod · 0.80
runMainLoopMethod · 0.80
runMainLoopMethod · 0.80
runMainLoopMethod · 0.80

Calls 2

collectBatchMethod · 0.95
waitForMessagesMethod · 0.95

Tested by

no test coverage detected