@zonease/happy 0.6.41 → 0.6.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/{api-XeHlmApX.cjs → api-B-PlVQY6.cjs} +50 -4
  2. package/dist/{api-K2-jr9ar.mjs → api-BUCtd3cB.mjs} +51 -5
  3. package/dist/{auth-BQvEuSs5.cjs → auth-BqGkUXvq.cjs} +2 -2
  4. package/dist/{auth-CjLkoM3m.mjs → auth-DQH6q_q-.mjs} +4 -4
  5. package/dist/{auth-BbvPcnkY.cjs → auth-OL3nNcDX.cjs} +4 -4
  6. package/dist/{auth-DS8fzlin.mjs → auth-qM2eojWx.mjs} +2 -2
  7. package/dist/{browser-C05SP_Tt.cjs → browser-CY7VNU0C.cjs} +1 -1
  8. package/dist/{browser-C05Ak6RL.mjs → browser-D5RN_Axa.mjs} +1 -1
  9. package/dist/{claudeLocal-DJNRlHIC.mjs → claudeLocal-BXK_vQXS.mjs} +1 -1
  10. package/dist/{claudeLocal-CpDhLCcZ.cjs → claudeLocal-HAXk0deK.cjs} +1 -1
  11. package/dist/{config-DWWtjKQx.mjs → config-2wMjzcHl.mjs} +1 -1
  12. package/dist/{config-B0mns9fF.cjs → config-CaKxWGVe.cjs} +1 -1
  13. package/dist/{connect-DXQC1CJe.mjs → connect-BAunPyp_.mjs} +5 -5
  14. package/dist/{connect-BxCScVNX.cjs → connect-Dt1vY1BC.cjs} +5 -5
  15. package/dist/{controlClient-DgjVRN8D.mjs → controlClient-BzzTNSfl.mjs} +1 -1
  16. package/dist/{controlClient-DgELDZgM.cjs → controlClient-yTkpwcOq.cjs} +1 -1
  17. package/dist/cursorApprovalHook-B2chnVni.cjs +115 -0
  18. package/dist/cursorApprovalHook-BDLPzI5l.mjs +113 -0
  19. package/dist/cursorApprovalServer-Ba1yOUCA.mjs +263 -0
  20. package/dist/cursorApprovalServer-xwxVGL3u.cjs +268 -0
  21. package/dist/{deviceKeys-CejCdWpw.mjs → deviceKeys-CQyFFPtt.mjs} +2 -2
  22. package/dist/{deviceKeys-BpIAWz13.cjs → deviceKeys-CdW-HPnz.cjs} +2 -2
  23. package/dist/{doctor-DznasgP3.cjs → doctor-D4xWXiE7.cjs} +2 -2
  24. package/dist/{doctor-B-LCMVN9.mjs → doctor-DDT2TXHH.mjs} +2 -2
  25. package/dist/downloadImage-3A6zY5AX.cjs +492 -0
  26. package/dist/downloadImage-BqNp0l7y.mjs +485 -0
  27. package/dist/{enroll-HjUqyGnD.mjs → enroll-BlZ0giJI.mjs} +3 -3
  28. package/dist/{enroll-BvfpRUGJ.cjs → enroll-DeYs89Ic.cjs} +3 -3
  29. package/dist/{evidence-CVgTjBrq.cjs → evidence-Bn1JXtdz.cjs} +1 -1
  30. package/dist/{evidence-BEQd1dCh.mjs → evidence-PUnN9yPK.mjs} +1 -1
  31. package/dist/{formatImageMessage-DVs57t3x.mjs → formatImageMessage-BRHeLf0-.mjs} +1 -1
  32. package/dist/{formatImageMessage-CmJTP_hU.cjs → formatImageMessage-bVFGFDJl.cjs} +1 -1
  33. package/dist/{index-CDTNgfUf.cjs → index-BeKrqPYR.cjs} +25 -1
  34. package/dist/{index-CPKdvi7J.mjs → index-DTV7drqs.mjs} +25 -1
  35. package/dist/index.cjs +95 -41
  36. package/dist/index.mjs +95 -41
  37. package/dist/{install-UTz_vYvB.mjs → install-BLPNuSeM.mjs} +2 -2
  38. package/dist/{install-B3mMGISS.mjs → install-BOIcR_Wr.mjs} +1 -1
  39. package/dist/{install-Ck22tYHP.cjs → install-Jrs6YUu8.cjs} +1 -1
  40. package/dist/{install-2Yl_L582.cjs → install-Q-YMwwwg.cjs} +2 -2
  41. package/dist/lib.cjs +4 -4
  42. package/dist/lib.d.cts +4 -2
  43. package/dist/lib.d.mts +4 -2
  44. package/dist/lib.mjs +4 -4
  45. package/dist/{loadableToolOutput-BZYlaqHn.cjs → loadableToolOutput-B3qpMqXT.cjs} +2 -458
  46. package/dist/{loadableToolOutput-4EvraaNY.mjs → loadableToolOutput-DzReWITb.mjs} +3 -456
  47. package/dist/{persistence-DrfN7TzY.cjs → persistence-D7zNFI-d.cjs} +7 -4
  48. package/dist/{persistence-CIUFyOwz.mjs → persistence-DbLMvLvk.mjs} +7 -4
  49. package/dist/{push-CCOXCcM_.cjs → push-RT6Y0Hr3.cjs} +6 -6
  50. package/dist/{push-USXj_pv0.mjs → push-z5wQ4Ki_.mjs} +6 -6
  51. package/dist/{downloadImage-ia5SzlCV.mjs → registerKillSessionHandler-DmfnJ0zq.mjs} +7 -487
  52. package/dist/{downloadImage-B_ygLAXY.cjs → registerKillSessionHandler-MoLdSQxM.cjs} +6 -492
  53. package/dist/{run-Dy6KX6m-.mjs → run-BFnSUK1o.mjs} +14 -9
  54. package/dist/{run-D3CopmEb.cjs → run-C5StYRIB.cjs} +14 -9
  55. package/dist/{runClaude-aHzvx6Ha.cjs → runClaude-ChRp6f5G.cjs} +27 -26
  56. package/dist/{runClaude-CWux2RDq.mjs → runClaude-CjENBdrX.mjs} +22 -21
  57. package/dist/{runCodex-D0ZxSj3O.mjs → runCodex-BzQWlRoj.mjs} +27 -25
  58. package/dist/{runCodex-G-Aq531U.cjs → runCodex-DcQGyotH.cjs} +32 -30
  59. package/dist/runCursor-B73z6MCN.mjs +752 -0
  60. package/dist/runCursor-BlPAxaTy.cjs +754 -0
  61. package/dist/{runGemini-DZC2i6vA.mjs → runGemini-BPv4UzuF.mjs} +18 -16
  62. package/dist/{runGemini-DxGgDAIM.cjs → runGemini-JFqaIC3u.cjs} +23 -21
  63. package/dist/{runOneShot-BgT-JNMA.cjs → runOneShot-2iV11e9L.cjs} +3 -3
  64. package/dist/{runOneShot-cxlk7VKA.mjs → runOneShot-DTukim2A.mjs} +3 -3
  65. package/dist/{serve-Dr3wPrtK.cjs → serve-BDwuAIK4.cjs} +7 -7
  66. package/dist/{serve-CKyvJNs0.mjs → serve-BnlYj5ek.mjs} +7 -7
  67. package/dist/{session-dYzbOo_W.cjs → session-Cp9LEESM.cjs} +5 -5
  68. package/dist/{session-vf2ZjFto.mjs → session-gfeFU8CA.mjs} +5 -5
  69. package/dist/{sessionKeyCache-dDquDzn0.cjs → sessionKeyCache-3Pme04yL.cjs} +1 -1
  70. package/dist/{sessionKeyCache-D2u3JUys.mjs → sessionKeyCache-DtBS_Sb3.mjs} +1 -1
  71. package/dist/{sessionList-C1k2PNg_.mjs → sessionList-B1w4BUdv.mjs} +2 -2
  72. package/dist/{sessionList-DmmtC7uR.cjs → sessionList-BR_5UDZJ.cjs} +2 -2
  73. package/dist/{sessionSummary-DGLoVOxd.cjs → sessionSummary-DLweYgHO.cjs} +3 -3
  74. package/dist/{sessionSummary-5a1QtFVS.mjs → sessionSummary-E-a2bg8W.mjs} +3 -3
  75. package/dist/setupOfflineReconnection-DHwthFtd.mjs +459 -0
  76. package/dist/setupOfflineReconnection-Dkp00dC9.cjs +463 -0
  77. package/dist/{spawnHappyCLI-CarRI4GM.cjs → spawnHappyCLI-C2uY9WV-.cjs} +1 -1
  78. package/dist/{spawnHappyCLI-D3EkTFIn.mjs → spawnHappyCLI-Dt7fbmbk.mjs} +1 -1
  79. package/dist/{ssh-B0hvEYIl.mjs → ssh-C-nEZiGP.mjs} +5 -5
  80. package/dist/{ssh-CBgVwKsB.cjs → ssh-CsnS89Lr.cjs} +5 -5
  81. package/dist/{task-CRo6W-3_.mjs → task-B-8_QGGX.mjs} +6 -6
  82. package/dist/{task-CMunPKCV.cjs → task-lrLb4FCL.cjs} +6 -6
  83. package/dist/{uninstall-BALE2up0.mjs → uninstall-CirMt_WC.mjs} +2 -2
  84. package/dist/{uninstall-BJ3eEGM4.cjs → uninstall-DMjUlEXT.cjs} +2 -2
  85. package/dist/{update-BfjtLrhO.mjs → update-CfXbYshs.mjs} +3 -3
  86. package/dist/{update-Bb3iijy8.cjs → update-mx2p28IP.cjs} +3 -3
  87. package/package.json +1 -1
@@ -1,5 +1,3 @@
1
- import { l as logger, r as readCredentials } from './persistence-CIUFyOwz.mjs';
2
- import { createHash } from 'crypto';
3
1
  import { join, resolve, dirname } from 'node:path';
4
2
  import { p as projectPath } from './projectPath-BTBIMB57.mjs';
5
3
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
@@ -7,18 +5,20 @@ import { createServer } from 'node:http';
7
5
  import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
8
6
  import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
9
7
  import { z } from 'zod';
10
- import { l as listDevices, d as deviceExec } from './deviceKeys-CejCdWpw.mjs';
8
+ import { l as logger, r as readCredentials } from './persistence-DbLMvLvk.mjs';
9
+ import { l as listDevices, d as deviceExec } from './deviceKeys-CQyFFPtt.mjs';
11
10
  import { randomUUID } from 'node:crypto';
12
11
  import { s as shouldEnableOrchestratorTools } from './prompt-BsAZsPbo.mjs';
13
12
  import './mcpToolSchemas-CjeTfrAs.mjs';
14
- import './index-CPKdvi7J.mjs';
13
+ import './index-DTV7drqs.mjs';
15
14
  import { execSync } from 'node:child_process';
16
- import axios from 'axios';
15
+ import 'axios';
17
16
  import 'node:events';
18
17
  import 'socket.io-client';
19
- import './api-K2-jr9ar.mjs';
18
+ import './api-BUCtd3cB.mjs';
20
19
  import 'tweetnacl';
21
20
  import 'ws';
21
+ import 'crypto';
22
22
  import '@stablelib/base64';
23
23
  import 'node:os';
24
24
  import 'node:fs/promises';
@@ -28,403 +28,6 @@ import 'expo-server-sdk';
28
28
  import 'chalk';
29
29
  import './types-BoJh4Qfv.mjs';
30
30
 
31
- function parseCompact(message) {
32
- const trimmed = message.trim();
33
- if (trimmed === "/compact") {
34
- return {
35
- isCompact: true,
36
- originalMessage: trimmed
37
- };
38
- }
39
- if (trimmed.startsWith("/compact ")) {
40
- return {
41
- isCompact: true,
42
- originalMessage: trimmed
43
- };
44
- }
45
- return {
46
- isCompact: false,
47
- originalMessage: message
48
- };
49
- }
50
- function parseClear(message) {
51
- const trimmed = message.trim();
52
- return {
53
- isClear: trimmed === "/clear"
54
- };
55
- }
56
- function parseSpecialCommand(message) {
57
- const compactResult = parseCompact(message);
58
- if (compactResult.isCompact) {
59
- return {
60
- type: "compact",
61
- originalMessage: compactResult.originalMessage
62
- };
63
- }
64
- const clearResult = parseClear(message);
65
- if (clearResult.isClear) {
66
- return {
67
- type: "clear"
68
- };
69
- }
70
- return {
71
- type: null
72
- };
73
- }
74
-
75
- class MessageQueue2 {
76
- queue = [];
77
- // Made public for testing
78
- waiter = null;
79
- closed = false;
80
- onMessageHandler = null;
81
- modeHasher;
82
- constructor(modeHasher, onMessageHandler = null) {
83
- this.modeHasher = modeHasher;
84
- this.onMessageHandler = onMessageHandler;
85
- logger.debug(`[MessageQueue2] Initialized`);
86
- }
87
- /**
88
- * Set a handler that will be called when a message arrives
89
- */
90
- setOnMessage(handler) {
91
- this.onMessageHandler = handler;
92
- }
93
- /**
94
- * Push a message to the queue with a mode.
95
- */
96
- push(message, mode) {
97
- if (this.closed) {
98
- throw new Error("Cannot push to closed queue");
99
- }
100
- const modeHash = this.modeHasher(mode);
101
- logger.debug(`[MessageQueue2] push() called with mode hash: ${modeHash}`);
102
- this.queue.push({
103
- message,
104
- mode,
105
- modeHash,
106
- isolate: false
107
- });
108
- if (this.onMessageHandler) {
109
- this.onMessageHandler(message, mode);
110
- }
111
- if (this.waiter) {
112
- logger.debug(`[MessageQueue2] Notifying waiter`);
113
- const waiter = this.waiter;
114
- this.waiter = null;
115
- waiter(true);
116
- }
117
- logger.debug(`[MessageQueue2] push() completed. Queue size: ${this.queue.length}`);
118
- }
119
- /**
120
- * Push a message immediately without batching delay.
121
- * Does not clear the queue or enforce isolation.
122
- */
123
- pushImmediate(message, mode) {
124
- if (this.closed) {
125
- throw new Error("Cannot push to closed queue");
126
- }
127
- const modeHash = this.modeHasher(mode);
128
- logger.debug(`[MessageQueue2] pushImmediate() called with mode hash: ${modeHash}`);
129
- this.queue.push({
130
- message,
131
- mode,
132
- modeHash,
133
- isolate: false
134
- });
135
- if (this.onMessageHandler) {
136
- this.onMessageHandler(message, mode);
137
- }
138
- if (this.waiter) {
139
- logger.debug(`[MessageQueue2] Notifying waiter for immediate message`);
140
- const waiter = this.waiter;
141
- this.waiter = null;
142
- waiter(true);
143
- }
144
- logger.debug(`[MessageQueue2] pushImmediate() completed. Queue size: ${this.queue.length}`);
145
- }
146
- /**
147
- * Push a message that must be processed in complete isolation.
148
- * Clears any pending messages and ensures this message is never batched with others.
149
- * Used for special commands that require dedicated processing.
150
- */
151
- pushIsolateAndClear(message, mode) {
152
- if (this.closed) {
153
- throw new Error("Cannot push to closed queue");
154
- }
155
- const modeHash = this.modeHasher(mode);
156
- logger.debug(`[MessageQueue2] pushIsolateAndClear() called with mode hash: ${modeHash} - clearing ${this.queue.length} pending messages`);
157
- this.queue = [];
158
- this.queue.push({
159
- message,
160
- mode,
161
- modeHash,
162
- isolate: true
163
- });
164
- if (this.onMessageHandler) {
165
- this.onMessageHandler(message, mode);
166
- }
167
- if (this.waiter) {
168
- logger.debug(`[MessageQueue2] Notifying waiter for isolated message`);
169
- const waiter = this.waiter;
170
- this.waiter = null;
171
- waiter(true);
172
- }
173
- logger.debug(`[MessageQueue2] pushIsolateAndClear() completed. Queue size: ${this.queue.length}`);
174
- }
175
- /**
176
- * Push a message to the beginning of the queue with a mode.
177
- */
178
- unshift(message, mode) {
179
- if (this.closed) {
180
- throw new Error("Cannot unshift to closed queue");
181
- }
182
- const modeHash = this.modeHasher(mode);
183
- logger.debug(`[MessageQueue2] unshift() called with mode hash: ${modeHash}`);
184
- this.queue.unshift({
185
- message,
186
- mode,
187
- modeHash,
188
- isolate: false
189
- });
190
- if (this.onMessageHandler) {
191
- this.onMessageHandler(message, mode);
192
- }
193
- if (this.waiter) {
194
- logger.debug(`[MessageQueue2] Notifying waiter`);
195
- const waiter = this.waiter;
196
- this.waiter = null;
197
- waiter(true);
198
- }
199
- logger.debug(`[MessageQueue2] unshift() completed. Queue size: ${this.queue.length}`);
200
- }
201
- /**
202
- * Reset the queue - clears all messages and resets to empty state
203
- */
204
- reset() {
205
- logger.debug(`[MessageQueue2] reset() called. Clearing ${this.queue.length} messages`);
206
- this.queue = [];
207
- this.closed = false;
208
- this.waiter = null;
209
- }
210
- /**
211
- * Close the queue - no more messages can be pushed
212
- */
213
- close() {
214
- logger.debug(`[MessageQueue2] close() called`);
215
- this.closed = true;
216
- if (this.waiter) {
217
- const waiter = this.waiter;
218
- this.waiter = null;
219
- waiter(false);
220
- }
221
- }
222
- /**
223
- * Check if the queue is closed
224
- */
225
- isClosed() {
226
- return this.closed;
227
- }
228
- /**
229
- * Get the current queue size
230
- */
231
- size() {
232
- return this.queue.length;
233
- }
234
- /**
235
- * Wait for messages and return all messages with the same mode.
236
- * For string messages, multiple messages are joined with newlines.
237
- * For object messages (e.g., mixed content with images), returns them one at a time.
238
- * Returns { message: M, mode: T } or null if aborted/closed
239
- */
240
- async waitForMessagesAndGetAsString(abortSignal) {
241
- if (this.queue.length > 0) {
242
- return this.collectBatch();
243
- }
244
- if (this.closed || abortSignal?.aborted) {
245
- return null;
246
- }
247
- const hasMessages = await this.waitForMessages(abortSignal);
248
- if (!hasMessages) {
249
- return null;
250
- }
251
- return this.collectBatch();
252
- }
253
- /**
254
- * Collect a batch of messages with the same mode, respecting isolation requirements.
255
- * For string messages, joins them with newlines.
256
- * For object messages (like mixed content with images), returns one at a time.
257
- */
258
- collectBatch() {
259
- if (this.queue.length === 0) {
260
- return null;
261
- }
262
- const firstItem = this.queue[0];
263
- let mode = firstItem.mode;
264
- let isolate = firstItem.isolate ?? false;
265
- const targetModeHash = firstItem.modeHash;
266
- if (firstItem.isolate) {
267
- const item = this.queue.shift();
268
- logger.debug(`[MessageQueue2] Collected isolated message with mode hash: ${targetModeHash}`);
269
- return {
270
- message: item.message,
271
- mode,
272
- hash: targetModeHash,
273
- isolate
274
- };
275
- }
276
- if (typeof firstItem.message !== "string") {
277
- const item = this.queue.shift();
278
- logger.debug(`[MessageQueue2] Collected single object message with mode hash: ${targetModeHash}`);
279
- return {
280
- message: item.message,
281
- mode,
282
- hash: targetModeHash,
283
- isolate
284
- };
285
- }
286
- const sameModeMessages = [];
287
- while (this.queue.length > 0 && this.queue[0].modeHash === targetModeHash && !this.queue[0].isolate && typeof this.queue[0].message === "string") {
288
- const item = this.queue.shift();
289
- sameModeMessages.push(item.message);
290
- }
291
- logger.debug(`[MessageQueue2] Collected batch of ${sameModeMessages.length} messages with mode hash: ${targetModeHash}`);
292
- const combinedMessage = sameModeMessages.join("\n");
293
- return {
294
- message: combinedMessage,
295
- mode,
296
- hash: targetModeHash,
297
- isolate
298
- };
299
- }
300
- /**
301
- * Wait for messages to arrive
302
- */
303
- waitForMessages(abortSignal) {
304
- return new Promise((resolve) => {
305
- let abortHandler = null;
306
- if (abortSignal) {
307
- abortHandler = () => {
308
- logger.debug("[MessageQueue2] Wait aborted");
309
- if (this.waiter === waiterFunc) {
310
- this.waiter = null;
311
- }
312
- resolve(false);
313
- };
314
- abortSignal.addEventListener("abort", abortHandler);
315
- }
316
- const waiterFunc = (hasMessages) => {
317
- if (abortHandler && abortSignal) {
318
- abortSignal.removeEventListener("abort", abortHandler);
319
- }
320
- resolve(hasMessages);
321
- };
322
- if (this.queue.length > 0) {
323
- if (abortHandler && abortSignal) {
324
- abortSignal.removeEventListener("abort", abortHandler);
325
- }
326
- resolve(true);
327
- return;
328
- }
329
- if (this.closed || abortSignal?.aborted) {
330
- if (abortHandler && abortSignal) {
331
- abortSignal.removeEventListener("abort", abortHandler);
332
- }
333
- resolve(false);
334
- return;
335
- }
336
- this.waiter = waiterFunc;
337
- logger.debug("[MessageQueue2] Waiting for messages...");
338
- });
339
- }
340
- }
341
-
342
- function deterministicStringify(obj, options = {}) {
343
- const {
344
- undefinedBehavior = "omit",
345
- sortArrays = false,
346
- replacer,
347
- includeSymbols = false
348
- } = options;
349
- const seen = /* @__PURE__ */ new WeakSet();
350
- function processValue(value, key) {
351
- if (replacer && key !== void 0) {
352
- value = replacer(key, value);
353
- }
354
- if (value === null) return null;
355
- if (value === void 0) {
356
- switch (undefinedBehavior) {
357
- case "omit":
358
- return void 0;
359
- case "null":
360
- return null;
361
- case "throw":
362
- throw new Error(`Undefined value at key: ${key}`);
363
- }
364
- }
365
- if (typeof value === "boolean" || typeof value === "number" || typeof value === "string") {
366
- return value;
367
- }
368
- if (value instanceof Date) {
369
- return value.toISOString();
370
- }
371
- if (value instanceof RegExp) {
372
- return value.toString();
373
- }
374
- if (typeof value === "function") {
375
- return void 0;
376
- }
377
- if (typeof value === "symbol") {
378
- return includeSymbols ? value.toString() : void 0;
379
- }
380
- if (typeof value === "bigint") {
381
- return value.toString() + "n";
382
- }
383
- if (seen.has(value)) {
384
- throw new Error("Circular reference detected");
385
- }
386
- seen.add(value);
387
- if (Array.isArray(value)) {
388
- const processed2 = value.map((item, index) => processValue(item, String(index))).filter((item) => item !== void 0);
389
- if (sortArrays) {
390
- processed2.sort((a, b) => {
391
- const aStr = JSON.stringify(processValue(a));
392
- const bStr = JSON.stringify(processValue(b));
393
- return aStr.localeCompare(bStr);
394
- });
395
- }
396
- seen.delete(value);
397
- return processed2;
398
- }
399
- if (value.constructor === Object || value.constructor === void 0) {
400
- const processed2 = {};
401
- const keys = Object.keys(value).sort();
402
- for (const k of keys) {
403
- const processedValue = processValue(value[k], k);
404
- if (processedValue !== void 0) {
405
- processed2[k] = processedValue;
406
- }
407
- }
408
- seen.delete(value);
409
- return processed2;
410
- }
411
- try {
412
- const plain = { ...value };
413
- seen.delete(value);
414
- return processValue(plain, key);
415
- } catch {
416
- seen.delete(value);
417
- return String(value);
418
- }
419
- }
420
- const processed = processValue(obj);
421
- return JSON.stringify(processed);
422
- }
423
- function hashObject(obj, options, encoding = "hex") {
424
- const jsonString = deterministicStringify(obj, options);
425
- return createHash("sha256").update(jsonString).digest(encoding);
426
- }
427
-
428
31
  function createMcpServer(client, options) {
429
32
  const mcp = new McpServer({
430
33
  name: "Happy MCP",
@@ -790,76 +393,6 @@ function detectGitWorktree(cwd) {
790
393
  }
791
394
  }
792
395
 
793
- class MessageBuffer {
794
- messages = [];
795
- listeners = [];
796
- nextId = 1;
797
- addMessage(content, type = "assistant") {
798
- const message = {
799
- id: `msg-${this.nextId++}`,
800
- timestamp: /* @__PURE__ */ new Date(),
801
- content,
802
- type
803
- };
804
- this.messages.push(message);
805
- this.notifyListeners();
806
- }
807
- /**
808
- * Update the last message of a specific type by appending content to it
809
- * Useful for streaming responses where deltas should accumulate in one message
810
- */
811
- updateLastMessage(contentDelta, type = "assistant") {
812
- for (let i = this.messages.length - 1; i >= 0; i--) {
813
- if (this.messages[i].type === type) {
814
- const oldMessage = this.messages[i];
815
- const updatedMessage = {
816
- ...oldMessage,
817
- content: oldMessage.content + contentDelta
818
- };
819
- this.messages[i] = updatedMessage;
820
- this.notifyListeners();
821
- return;
822
- }
823
- }
824
- this.addMessage(contentDelta, type);
825
- }
826
- /**
827
- * Remove the last message of a specific type
828
- * Useful for removing placeholder messages like "Thinking..." when actual response starts
829
- */
830
- removeLastMessage(type) {
831
- for (let i = this.messages.length - 1; i >= 0; i--) {
832
- if (this.messages[i].type === type) {
833
- this.messages.splice(i, 1);
834
- this.notifyListeners();
835
- return true;
836
- }
837
- }
838
- return false;
839
- }
840
- getMessages() {
841
- return [...this.messages];
842
- }
843
- clear() {
844
- this.messages = [];
845
- this.nextId = 1;
846
- this.notifyListeners();
847
- }
848
- onUpdate(listener) {
849
- this.listeners.push(listener);
850
- return () => {
851
- const index = this.listeners.indexOf(listener);
852
- if (index > -1) {
853
- this.listeners.splice(index, 1);
854
- }
855
- };
856
- }
857
- notifyListeners() {
858
- const messages = this.getMessages();
859
- this.listeners.forEach((listener) => listener(messages));
860
- }
861
- }
862
-
863
396
  function registerKillSessionHandler(rpcHandlerManager, killThisHappy) {
864
397
  rpcHandlerManager.registerHandler("killSession", async () => {
865
398
  logger.debug("Kill session request received");
@@ -871,17 +404,4 @@ function registerKillSessionHandler(rpcHandlerManager, killThisHappy) {
871
404
  });
872
405
  }
873
406
 
874
- async function downloadImage(url) {
875
- const response = await axios.get(url, {
876
- responseType: "arraybuffer"
877
- });
878
- const buffer = Buffer.from(response.data);
879
- const base64 = buffer.toString("base64");
880
- let mimeType = response.headers["content-type"] || "image/jpeg";
881
- if (mimeType.includes(";")) {
882
- mimeType = mimeType.split(";")[0].trim();
883
- }
884
- return { base64, mimeType };
885
- }
886
-
887
- export { MessageQueue2 as M, detectGitWorktree as a, MessageBuffer as b, createMcpContext as c, downloadImage as d, parseSpecialCommand as e, hashObject as h, parseClear as p, registerKillSessionHandler as r };
407
+ export { createMcpContext as c, detectGitWorktree as d, registerKillSessionHandler as r };