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

Method push

cli/src/utils/MessageQueue2.ts:42–72  ·  view source on GitHub ↗

* Push a message to the queue with a mode.

(message: string, mode: T, localId?: string)

Source from the content-addressed store, hash-verified

40 * Push a message to the queue with a mode.
41 */
42 push(message: string, mode: T, localId?: string): void {
43 if (this.closed) {
44 throw new Error('Cannot push to closed queue');
45 }
46
47 const modeHash = this.modeHasher(mode);
48 logger.debug(`[MessageQueue2] push() called with mode hash: ${modeHash}`);
49
50 this.queue.push({
51 message,
52 mode,
53 modeHash,
54 localId,
55 isolate: false
56 });
57
58 // Trigger message handler if set
59 if (this.onMessageHandler) {
60 this.onMessageHandler(message, mode);
61 }
62
63 // Notify waiter if any
64 if (this.waiter) {
65 logger.debug(`[MessageQueue2] Notifying waiter`);
66 const waiter = this.waiter;
67 this.waiter = null;
68 waiter(true);
69 }
70
71 logger.debug(`[MessageQueue2] push() completed. Queue size: ${this.queue.length}`);
72 }
73
74 /**
75 * Push a message immediately without batching delay.

Callers 15

runGeminiFunction · 0.95
createSessionStubFunction · 0.95
runOpencodeFunction · 0.95
createSessionStubFunction · 0.95
createSessionStubFunction · 0.95
runCodexFunction · 0.95
runAgentSessionFunction · 0.95
runClaudeFunction · 0.95
runKimiFunction · 0.95
sendSessionEventFunction · 0.45
runGemini.test.tsFile · 0.45

Calls 1

debugMethod · 0.80

Tested by 15

createSessionStubFunction · 0.76
createSessionStubFunction · 0.76
createSessionStubFunction · 0.76
sendSessionEventFunction · 0.36
createHarnessFunction · 0.36
sendSessionEventFunction · 0.36
respondToPermissionFunction · 0.36
sendHookRequestFunction · 0.36
baseOptionsFunction · 0.36
initializeMethod · 0.36