@zonease/happy 0.6.42 → 0.6.44

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 (88) hide show
  1. package/dist/{api-CIE4_cWd.cjs → api-Ct7Z1lwF.cjs} +65 -5
  2. package/dist/{api-Ew6xr81i.mjs → api-D3j3YL3m.mjs} +65 -5
  3. package/dist/{auth-G9fZpVJ2.cjs → auth-B9kOli6i.cjs} +2 -2
  4. package/dist/{auth-BzYevJo2.mjs → auth-C2ZyAGMu.mjs} +4 -4
  5. package/dist/{auth-Q2STUNI-.mjs → auth-DPe89SQx.mjs} +2 -2
  6. package/dist/{auth-Dor79zTL.cjs → auth-W1aK_a-P.cjs} +4 -4
  7. package/dist/{browser-qDIIAL7S.cjs → browser-BPEhi6te.cjs} +1 -1
  8. package/dist/{browser-BI7s-V8E.mjs → browser-Byx5gq-W.mjs} +1 -1
  9. package/dist/{claudeLocal-Db2tDC4X.mjs → claudeLocal-BtxBYzs7.mjs} +1 -1
  10. package/dist/{claudeLocal-f4uBLJaM.cjs → claudeLocal-CcarNVE9.cjs} +1 -1
  11. package/dist/{config-CHjDs8AS.mjs → config-DJLOlgjr.mjs} +1 -1
  12. package/dist/{config-CSBlEik9.cjs → config-Djr2JMWO.cjs} +1 -1
  13. package/dist/{connect-O_nA5BOC.mjs → connect-PrUuHNLU.mjs} +4 -4
  14. package/dist/{connect-CJoTliii.cjs → connect-rcgRx9US.cjs} +4 -4
  15. package/dist/{controlClient-DoS9JqQC.mjs → controlClient-DSiES8Un.mjs} +1 -1
  16. package/dist/{controlClient-CEz_p1zc.cjs → controlClient-FDsMeGVn.cjs} +1 -1
  17. package/dist/{cursorApprovalHook-DRAHfTXU.cjs → cursorApprovalHook-CTJiiPO6.cjs} +29 -11
  18. package/dist/{cursorApprovalHook-B0v1kGa7.mjs → cursorApprovalHook-DGYeNaLe.mjs} +29 -11
  19. package/dist/{cursorApprovalServer-DzY8yJlI.cjs → cursorApprovalServer-C_wqI7wm.cjs} +109 -8
  20. package/dist/{cursorApprovalServer-JjPkdjGR.mjs → cursorApprovalServer-fjPBXSAb.mjs} +109 -10
  21. package/dist/{deviceKeys-B4aqjnE6.mjs → deviceKeys-BYHzWSyg.mjs} +2 -2
  22. package/dist/{deviceKeys-DyUn0bEx.cjs → deviceKeys-DPut1U07.cjs} +2 -2
  23. package/dist/{doctor-DRnft_5-.mjs → doctor-BA28TuMy.mjs} +2 -2
  24. package/dist/{doctor-BJSuVRUZ.cjs → doctor-B_W7odmC.cjs} +2 -2
  25. package/dist/{downloadImage-Cijmufpr.cjs → downloadImage-B7MKUI0u.cjs} +1 -372
  26. package/dist/downloadImage-DKWzC11M.mjs +485 -0
  27. package/dist/{enroll-CysDL6ee.mjs → enroll-Bc3Lke1H.mjs} +3 -3
  28. package/dist/{enroll-C2gunHdt.cjs → enroll-Blqx_Kg8.cjs} +3 -3
  29. package/dist/{evidence-DPutCuUr.mjs → evidence-D8nvQ8pQ.mjs} +1 -1
  30. package/dist/{evidence-DsQ-h-_W.cjs → evidence-jfqT04hc.cjs} +1 -1
  31. package/dist/{formatImageMessage-6aV9YFWr.mjs → formatImageMessage-BFWnadBR.mjs} +1 -1
  32. package/dist/{formatImageMessage-BPK_Ivfe.cjs → formatImageMessage-CZeSzoFO.cjs} +1 -1
  33. package/dist/index.cjs +50 -46
  34. package/dist/index.mjs +50 -46
  35. package/dist/{install-DBg0xQ3g.mjs → install-BvuadnKW.mjs} +1 -1
  36. package/dist/{install-BsTA2tZn.mjs → install-ChK8Eb58.mjs} +2 -2
  37. package/dist/{install-Tyhs6rUp.cjs → install-DFmp8KKp.cjs} +1 -1
  38. package/dist/{install-DlOppA-e.cjs → install-nJv8rYWA.cjs} +2 -2
  39. package/dist/lib.cjs +3 -3
  40. package/dist/lib.d.cts +1 -0
  41. package/dist/lib.d.mts +1 -0
  42. package/dist/lib.mjs +3 -3
  43. package/dist/{loadableToolOutput-DPGTtKJM.cjs → loadableToolOutput-CqMfcEh7.cjs} +2 -2
  44. package/dist/{loadableToolOutput-2dMPAp4N.mjs → loadableToolOutput-D6crYom_.mjs} +2 -2
  45. package/dist/{persistence-D9tMm6bj.mjs → persistence-BXtirP1k.mjs} +1 -1
  46. package/dist/{persistence-BcQmjobZ.cjs → persistence-DOgft4tZ.cjs} +1 -1
  47. package/dist/{push-Dxsugkes.mjs → push-188EjPTP.mjs} +6 -6
  48. package/dist/{push-Cnm6JQMD.cjs → push-DykEVhRR.cjs} +6 -6
  49. package/dist/registerKillSessionHandler-6loIZYD9.mjs +407 -0
  50. package/dist/registerKillSessionHandler-ks8iPY9a.cjs +411 -0
  51. package/dist/{run-CiPWWhXt.cjs → run-DSJ7IIWW.cjs} +10 -8
  52. package/dist/{run-BEflQaQ2.mjs → run-Dp4_De-r.mjs} +10 -8
  53. package/dist/{runClaude-BVXsyCHb.cjs → runClaude-C3be35z0.cjs} +26 -26
  54. package/dist/{runClaude-sPkSqHWY.mjs → runClaude-gj4urJvB.mjs} +21 -21
  55. package/dist/{runCodex-C4rHkIyw.mjs → runCodex-DRZidxNB.mjs} +26 -26
  56. package/dist/{runCodex-BAwhdmSA.cjs → runCodex-p_fToj9T.cjs} +28 -28
  57. package/dist/{runCursor-CD5wC3gA.cjs → runCursor-CJlqkSYR.cjs} +210 -34
  58. package/dist/{runCursor-DiHLWMs8.mjs → runCursor-SFd9G7X_.mjs} +210 -34
  59. package/dist/{runGemini-B-93gOqB.mjs → runGemini-BOsfh6dX.mjs} +17 -17
  60. package/dist/{runGemini-Cto-adir.cjs → runGemini-lxvXq70R.cjs} +19 -19
  61. package/dist/{runOneShot-BfIzE9W4.cjs → runOneShot-BExFkHmA.cjs} +2 -2
  62. package/dist/{runOneShot-DGjlYVhR.mjs → runOneShot-CtzlkF1l.mjs} +2 -2
  63. package/dist/{serve-CqL6NWDr.cjs → serve-Bl1Caf6x.cjs} +6 -6
  64. package/dist/{serve-ttlqF5jn.mjs → serve-DfvSXAD2.mjs} +6 -6
  65. package/dist/{session-BZhGpQUJ.cjs → session--R6FqsxL.cjs} +5 -5
  66. package/dist/{session-Co0REU9e.mjs → session-BSzNJiAb.mjs} +5 -5
  67. package/dist/{sessionKeyCache-BwFUGgMs.cjs → sessionKeyCache-CVkksG68.cjs} +1 -1
  68. package/dist/{sessionKeyCache-pXTjpETo.mjs → sessionKeyCache-DYiCIvYC.mjs} +1 -1
  69. package/dist/{sessionList-fG5uAPzU.cjs → sessionList-C1q9fy5j.cjs} +2 -2
  70. package/dist/{sessionList-DaufR-sA.mjs → sessionList-D3pCseut.mjs} +2 -2
  71. package/dist/{sessionSummary-CjZPt6nr.cjs → sessionSummary-CUZxEBEZ.cjs} +3 -3
  72. package/dist/{sessionSummary-Dv6dPABg.mjs → sessionSummary-WpOlgXe1.mjs} +3 -3
  73. package/dist/{setupOfflineReconnection-DW5il97B.mjs → setupOfflineReconnection-BeWF3SGN.mjs} +5 -3
  74. package/dist/{setupOfflineReconnection-B6coH9QN.cjs → setupOfflineReconnection-CixoiWTS.cjs} +7 -5
  75. package/dist/{spawnHappyCLI-DhUeycct.mjs → spawnHappyCLI-Cyc-69jO.mjs} +1 -1
  76. package/dist/{spawnHappyCLI-Cfu7C1uM.cjs → spawnHappyCLI-hRc7u16s.cjs} +1 -1
  77. package/dist/{ssh-C4YTSHXL.cjs → ssh-B_TYtrys.cjs} +5 -5
  78. package/dist/{ssh-8tPIKk-i.mjs → ssh-BsxAgWgG.mjs} +5 -5
  79. package/dist/{task-DFW-PecP.cjs → task-BInh42e3.cjs} +6 -6
  80. package/dist/{task-CH-oidFy.mjs → task-BS4usaxx.mjs} +6 -6
  81. package/dist/{uninstall-CeioRZNI.mjs → uninstall-BKuDaZKB.mjs} +2 -2
  82. package/dist/{uninstall-yTSL3X6Y.cjs → uninstall-DNFGxNLl.cjs} +2 -2
  83. package/dist/{update-Bju28vNP.cjs → update-B9LoI5l8.cjs} +3 -3
  84. package/dist/{update-Derd2hoX.mjs → update-DC300VOW.mjs} +3 -3
  85. package/package.json +1 -1
  86. package/dist/downloadImage-BpVF7A79.mjs +0 -854
  87. package/dist/gitWorktree-C6jLoaMw.cjs +0 -39
  88. package/dist/gitWorktree-CzJDU2BV.mjs +0 -37
@@ -0,0 +1,485 @@
1
+ import { l as logger } from './persistence-BXtirP1k.mjs';
2
+ import { createHash } from 'crypto';
3
+ import axios from 'axios';
4
+
5
+ function parseCompact(message) {
6
+ const trimmed = message.trim();
7
+ if (trimmed === "/compact") {
8
+ return {
9
+ isCompact: true,
10
+ originalMessage: trimmed
11
+ };
12
+ }
13
+ if (trimmed.startsWith("/compact ")) {
14
+ return {
15
+ isCompact: true,
16
+ originalMessage: trimmed
17
+ };
18
+ }
19
+ return {
20
+ isCompact: false,
21
+ originalMessage: message
22
+ };
23
+ }
24
+ function parseClear(message) {
25
+ const trimmed = message.trim();
26
+ return {
27
+ isClear: trimmed === "/clear"
28
+ };
29
+ }
30
+ function parseSpecialCommand(message) {
31
+ const compactResult = parseCompact(message);
32
+ if (compactResult.isCompact) {
33
+ return {
34
+ type: "compact",
35
+ originalMessage: compactResult.originalMessage
36
+ };
37
+ }
38
+ const clearResult = parseClear(message);
39
+ if (clearResult.isClear) {
40
+ return {
41
+ type: "clear"
42
+ };
43
+ }
44
+ return {
45
+ type: null
46
+ };
47
+ }
48
+
49
+ class MessageQueue2 {
50
+ queue = [];
51
+ // Made public for testing
52
+ waiter = null;
53
+ closed = false;
54
+ onMessageHandler = null;
55
+ modeHasher;
56
+ constructor(modeHasher, onMessageHandler = null) {
57
+ this.modeHasher = modeHasher;
58
+ this.onMessageHandler = onMessageHandler;
59
+ logger.debug(`[MessageQueue2] Initialized`);
60
+ }
61
+ /**
62
+ * Set a handler that will be called when a message arrives
63
+ */
64
+ setOnMessage(handler) {
65
+ this.onMessageHandler = handler;
66
+ }
67
+ /**
68
+ * Push a message to the queue with a mode.
69
+ */
70
+ push(message, mode) {
71
+ if (this.closed) {
72
+ throw new Error("Cannot push to closed queue");
73
+ }
74
+ const modeHash = this.modeHasher(mode);
75
+ logger.debug(`[MessageQueue2] push() called with mode hash: ${modeHash}`);
76
+ this.queue.push({
77
+ message,
78
+ mode,
79
+ modeHash,
80
+ isolate: false
81
+ });
82
+ if (this.onMessageHandler) {
83
+ this.onMessageHandler(message, mode);
84
+ }
85
+ if (this.waiter) {
86
+ logger.debug(`[MessageQueue2] Notifying waiter`);
87
+ const waiter = this.waiter;
88
+ this.waiter = null;
89
+ waiter(true);
90
+ }
91
+ logger.debug(`[MessageQueue2] push() completed. Queue size: ${this.queue.length}`);
92
+ }
93
+ /**
94
+ * Push a message immediately without batching delay.
95
+ * Does not clear the queue or enforce isolation.
96
+ */
97
+ pushImmediate(message, mode) {
98
+ if (this.closed) {
99
+ throw new Error("Cannot push to closed queue");
100
+ }
101
+ const modeHash = this.modeHasher(mode);
102
+ logger.debug(`[MessageQueue2] pushImmediate() called with mode hash: ${modeHash}`);
103
+ this.queue.push({
104
+ message,
105
+ mode,
106
+ modeHash,
107
+ isolate: false
108
+ });
109
+ if (this.onMessageHandler) {
110
+ this.onMessageHandler(message, mode);
111
+ }
112
+ if (this.waiter) {
113
+ logger.debug(`[MessageQueue2] Notifying waiter for immediate message`);
114
+ const waiter = this.waiter;
115
+ this.waiter = null;
116
+ waiter(true);
117
+ }
118
+ logger.debug(`[MessageQueue2] pushImmediate() completed. Queue size: ${this.queue.length}`);
119
+ }
120
+ /**
121
+ * Push a message that must be processed in complete isolation.
122
+ * Clears any pending messages and ensures this message is never batched with others.
123
+ * Used for special commands that require dedicated processing.
124
+ */
125
+ pushIsolateAndClear(message, mode) {
126
+ if (this.closed) {
127
+ throw new Error("Cannot push to closed queue");
128
+ }
129
+ const modeHash = this.modeHasher(mode);
130
+ logger.debug(`[MessageQueue2] pushIsolateAndClear() called with mode hash: ${modeHash} - clearing ${this.queue.length} pending messages`);
131
+ this.queue = [];
132
+ this.queue.push({
133
+ message,
134
+ mode,
135
+ modeHash,
136
+ isolate: true
137
+ });
138
+ if (this.onMessageHandler) {
139
+ this.onMessageHandler(message, mode);
140
+ }
141
+ if (this.waiter) {
142
+ logger.debug(`[MessageQueue2] Notifying waiter for isolated message`);
143
+ const waiter = this.waiter;
144
+ this.waiter = null;
145
+ waiter(true);
146
+ }
147
+ logger.debug(`[MessageQueue2] pushIsolateAndClear() completed. Queue size: ${this.queue.length}`);
148
+ }
149
+ /**
150
+ * Push a message to the beginning of the queue with a mode.
151
+ */
152
+ unshift(message, mode) {
153
+ if (this.closed) {
154
+ throw new Error("Cannot unshift to closed queue");
155
+ }
156
+ const modeHash = this.modeHasher(mode);
157
+ logger.debug(`[MessageQueue2] unshift() called with mode hash: ${modeHash}`);
158
+ this.queue.unshift({
159
+ message,
160
+ mode,
161
+ modeHash,
162
+ isolate: false
163
+ });
164
+ if (this.onMessageHandler) {
165
+ this.onMessageHandler(message, mode);
166
+ }
167
+ if (this.waiter) {
168
+ logger.debug(`[MessageQueue2] Notifying waiter`);
169
+ const waiter = this.waiter;
170
+ this.waiter = null;
171
+ waiter(true);
172
+ }
173
+ logger.debug(`[MessageQueue2] unshift() completed. Queue size: ${this.queue.length}`);
174
+ }
175
+ /**
176
+ * Reset the queue - clears all messages and resets to empty state
177
+ */
178
+ reset() {
179
+ logger.debug(`[MessageQueue2] reset() called. Clearing ${this.queue.length} messages`);
180
+ this.queue = [];
181
+ this.closed = false;
182
+ this.waiter = null;
183
+ }
184
+ /**
185
+ * Close the queue - no more messages can be pushed
186
+ */
187
+ close() {
188
+ logger.debug(`[MessageQueue2] close() called`);
189
+ this.closed = true;
190
+ if (this.waiter) {
191
+ const waiter = this.waiter;
192
+ this.waiter = null;
193
+ waiter(false);
194
+ }
195
+ }
196
+ /**
197
+ * Check if the queue is closed
198
+ */
199
+ isClosed() {
200
+ return this.closed;
201
+ }
202
+ /**
203
+ * Get the current queue size
204
+ */
205
+ size() {
206
+ return this.queue.length;
207
+ }
208
+ /**
209
+ * Wait for messages and return all messages with the same mode.
210
+ * For string messages, multiple messages are joined with newlines.
211
+ * For object messages (e.g., mixed content with images), returns them one at a time.
212
+ * Returns { message: M, mode: T } or null if aborted/closed
213
+ */
214
+ async waitForMessagesAndGetAsString(abortSignal) {
215
+ if (this.queue.length > 0) {
216
+ return this.collectBatch();
217
+ }
218
+ if (this.closed || abortSignal?.aborted) {
219
+ return null;
220
+ }
221
+ const hasMessages = await this.waitForMessages(abortSignal);
222
+ if (!hasMessages) {
223
+ return null;
224
+ }
225
+ return this.collectBatch();
226
+ }
227
+ /**
228
+ * Collect a batch of messages with the same mode, respecting isolation requirements.
229
+ * For string messages, joins them with newlines.
230
+ * For object messages (like mixed content with images), returns one at a time.
231
+ */
232
+ collectBatch() {
233
+ if (this.queue.length === 0) {
234
+ return null;
235
+ }
236
+ const firstItem = this.queue[0];
237
+ let mode = firstItem.mode;
238
+ let isolate = firstItem.isolate ?? false;
239
+ const targetModeHash = firstItem.modeHash;
240
+ if (firstItem.isolate) {
241
+ const item = this.queue.shift();
242
+ logger.debug(`[MessageQueue2] Collected isolated message with mode hash: ${targetModeHash}`);
243
+ return {
244
+ message: item.message,
245
+ mode,
246
+ hash: targetModeHash,
247
+ isolate
248
+ };
249
+ }
250
+ if (typeof firstItem.message !== "string") {
251
+ const item = this.queue.shift();
252
+ logger.debug(`[MessageQueue2] Collected single object message with mode hash: ${targetModeHash}`);
253
+ return {
254
+ message: item.message,
255
+ mode,
256
+ hash: targetModeHash,
257
+ isolate
258
+ };
259
+ }
260
+ const sameModeMessages = [];
261
+ while (this.queue.length > 0 && this.queue[0].modeHash === targetModeHash && !this.queue[0].isolate && typeof this.queue[0].message === "string") {
262
+ const item = this.queue.shift();
263
+ sameModeMessages.push(item.message);
264
+ }
265
+ logger.debug(`[MessageQueue2] Collected batch of ${sameModeMessages.length} messages with mode hash: ${targetModeHash}`);
266
+ const combinedMessage = sameModeMessages.join("\n");
267
+ return {
268
+ message: combinedMessage,
269
+ mode,
270
+ hash: targetModeHash,
271
+ isolate
272
+ };
273
+ }
274
+ /**
275
+ * Wait for messages to arrive
276
+ */
277
+ waitForMessages(abortSignal) {
278
+ return new Promise((resolve) => {
279
+ let abortHandler = null;
280
+ if (abortSignal) {
281
+ abortHandler = () => {
282
+ logger.debug("[MessageQueue2] Wait aborted");
283
+ if (this.waiter === waiterFunc) {
284
+ this.waiter = null;
285
+ }
286
+ resolve(false);
287
+ };
288
+ abortSignal.addEventListener("abort", abortHandler);
289
+ }
290
+ const waiterFunc = (hasMessages) => {
291
+ if (abortHandler && abortSignal) {
292
+ abortSignal.removeEventListener("abort", abortHandler);
293
+ }
294
+ resolve(hasMessages);
295
+ };
296
+ if (this.queue.length > 0) {
297
+ if (abortHandler && abortSignal) {
298
+ abortSignal.removeEventListener("abort", abortHandler);
299
+ }
300
+ resolve(true);
301
+ return;
302
+ }
303
+ if (this.closed || abortSignal?.aborted) {
304
+ if (abortHandler && abortSignal) {
305
+ abortSignal.removeEventListener("abort", abortHandler);
306
+ }
307
+ resolve(false);
308
+ return;
309
+ }
310
+ this.waiter = waiterFunc;
311
+ logger.debug("[MessageQueue2] Waiting for messages...");
312
+ });
313
+ }
314
+ }
315
+
316
+ function deterministicStringify(obj, options = {}) {
317
+ const {
318
+ undefinedBehavior = "omit",
319
+ sortArrays = false,
320
+ replacer,
321
+ includeSymbols = false
322
+ } = options;
323
+ const seen = /* @__PURE__ */ new WeakSet();
324
+ function processValue(value, key) {
325
+ if (replacer && key !== void 0) {
326
+ value = replacer(key, value);
327
+ }
328
+ if (value === null) return null;
329
+ if (value === void 0) {
330
+ switch (undefinedBehavior) {
331
+ case "omit":
332
+ return void 0;
333
+ case "null":
334
+ return null;
335
+ case "throw":
336
+ throw new Error(`Undefined value at key: ${key}`);
337
+ }
338
+ }
339
+ if (typeof value === "boolean" || typeof value === "number" || typeof value === "string") {
340
+ return value;
341
+ }
342
+ if (value instanceof Date) {
343
+ return value.toISOString();
344
+ }
345
+ if (value instanceof RegExp) {
346
+ return value.toString();
347
+ }
348
+ if (typeof value === "function") {
349
+ return void 0;
350
+ }
351
+ if (typeof value === "symbol") {
352
+ return includeSymbols ? value.toString() : void 0;
353
+ }
354
+ if (typeof value === "bigint") {
355
+ return value.toString() + "n";
356
+ }
357
+ if (seen.has(value)) {
358
+ throw new Error("Circular reference detected");
359
+ }
360
+ seen.add(value);
361
+ if (Array.isArray(value)) {
362
+ const processed2 = value.map((item, index) => processValue(item, String(index))).filter((item) => item !== void 0);
363
+ if (sortArrays) {
364
+ processed2.sort((a, b) => {
365
+ const aStr = JSON.stringify(processValue(a));
366
+ const bStr = JSON.stringify(processValue(b));
367
+ return aStr.localeCompare(bStr);
368
+ });
369
+ }
370
+ seen.delete(value);
371
+ return processed2;
372
+ }
373
+ if (value.constructor === Object || value.constructor === void 0) {
374
+ const processed2 = {};
375
+ const keys = Object.keys(value).sort();
376
+ for (const k of keys) {
377
+ const processedValue = processValue(value[k], k);
378
+ if (processedValue !== void 0) {
379
+ processed2[k] = processedValue;
380
+ }
381
+ }
382
+ seen.delete(value);
383
+ return processed2;
384
+ }
385
+ try {
386
+ const plain = { ...value };
387
+ seen.delete(value);
388
+ return processValue(plain, key);
389
+ } catch {
390
+ seen.delete(value);
391
+ return String(value);
392
+ }
393
+ }
394
+ const processed = processValue(obj);
395
+ return JSON.stringify(processed);
396
+ }
397
+ function hashObject(obj, options, encoding = "hex") {
398
+ const jsonString = deterministicStringify(obj, options);
399
+ return createHash("sha256").update(jsonString).digest(encoding);
400
+ }
401
+
402
+ class MessageBuffer {
403
+ messages = [];
404
+ listeners = [];
405
+ nextId = 1;
406
+ addMessage(content, type = "assistant") {
407
+ const message = {
408
+ id: `msg-${this.nextId++}`,
409
+ timestamp: /* @__PURE__ */ new Date(),
410
+ content,
411
+ type
412
+ };
413
+ this.messages.push(message);
414
+ this.notifyListeners();
415
+ }
416
+ /**
417
+ * Update the last message of a specific type by appending content to it
418
+ * Useful for streaming responses where deltas should accumulate in one message
419
+ */
420
+ updateLastMessage(contentDelta, type = "assistant") {
421
+ for (let i = this.messages.length - 1; i >= 0; i--) {
422
+ if (this.messages[i].type === type) {
423
+ const oldMessage = this.messages[i];
424
+ const updatedMessage = {
425
+ ...oldMessage,
426
+ content: oldMessage.content + contentDelta
427
+ };
428
+ this.messages[i] = updatedMessage;
429
+ this.notifyListeners();
430
+ return;
431
+ }
432
+ }
433
+ this.addMessage(contentDelta, type);
434
+ }
435
+ /**
436
+ * Remove the last message of a specific type
437
+ * Useful for removing placeholder messages like "Thinking..." when actual response starts
438
+ */
439
+ removeLastMessage(type) {
440
+ for (let i = this.messages.length - 1; i >= 0; i--) {
441
+ if (this.messages[i].type === type) {
442
+ this.messages.splice(i, 1);
443
+ this.notifyListeners();
444
+ return true;
445
+ }
446
+ }
447
+ return false;
448
+ }
449
+ getMessages() {
450
+ return [...this.messages];
451
+ }
452
+ clear() {
453
+ this.messages = [];
454
+ this.nextId = 1;
455
+ this.notifyListeners();
456
+ }
457
+ onUpdate(listener) {
458
+ this.listeners.push(listener);
459
+ return () => {
460
+ const index = this.listeners.indexOf(listener);
461
+ if (index > -1) {
462
+ this.listeners.splice(index, 1);
463
+ }
464
+ };
465
+ }
466
+ notifyListeners() {
467
+ const messages = this.getMessages();
468
+ this.listeners.forEach((listener) => listener(messages));
469
+ }
470
+ }
471
+
472
+ async function downloadImage(url) {
473
+ const response = await axios.get(url, {
474
+ responseType: "arraybuffer"
475
+ });
476
+ const buffer = Buffer.from(response.data);
477
+ const base64 = buffer.toString("base64");
478
+ let mimeType = response.headers["content-type"] || "image/jpeg";
479
+ if (mimeType.includes(";")) {
480
+ mimeType = mimeType.split(";")[0].trim();
481
+ }
482
+ return { base64, mimeType };
483
+ }
484
+
485
+ export { MessageQueue2 as M, MessageBuffer as a, parseSpecialCommand as b, downloadImage as d, hashObject as h, parseClear as p };
@@ -1,8 +1,8 @@
1
1
  import axios from 'axios';
2
2
  import tweetnacl from 'tweetnacl';
3
3
  import { createHmac, randomBytes } from 'node:crypto';
4
- import { r as readCredentials, c as configuration, h as decodeBase64, u as updateSettings, w as writeCredentialsDataKey, o as libsodiumPublicKeyFromSecretKey } from './persistence-D9tMm6bj.mjs';
5
- import { decryptWithEphemeralKey } from './auth-Q2STUNI-.mjs';
4
+ import { r as readCredentials, c as configuration, h as decodeBase64, u as updateSettings, w as writeCredentialsDataKey, o as libsodiumPublicKeyFromSecretKey } from './persistence-BXtirP1k.mjs';
5
+ import { decryptWithEphemeralKey } from './auth-DPe89SQx.mjs';
6
6
  import 'node:fs/promises';
7
7
  import 'node:fs';
8
8
  import 'node:os';
@@ -12,7 +12,7 @@ import 'chalk';
12
12
  import 'fs';
13
13
  import 'qrcode-terminal';
14
14
  import './time-DgsBLJA_.mjs';
15
- import './browser-BI7s-V8E.mjs';
15
+ import './browser-Byx5gq-W.mjs';
16
16
  import 'open';
17
17
  import 'react';
18
18
  import 'ink';
@@ -3,8 +3,8 @@
3
3
  var axios = require('axios');
4
4
  var tweetnacl = require('tweetnacl');
5
5
  var node_crypto = require('node:crypto');
6
- var logger = require('./persistence-BcQmjobZ.cjs');
7
- var auth = require('./auth-G9fZpVJ2.cjs');
6
+ var logger = require('./persistence-DOgft4tZ.cjs');
7
+ var auth = require('./auth-B9kOli6i.cjs');
8
8
  require('node:fs/promises');
9
9
  require('node:fs');
10
10
  require('node:os');
@@ -14,7 +14,7 @@ require('chalk');
14
14
  require('fs');
15
15
  require('qrcode-terminal');
16
16
  require('./time-Bj2HRkKH.cjs');
17
- require('./browser-qDIIAL7S.cjs');
17
+ require('./browser-BPEhi6te.cjs');
18
18
  require('open');
19
19
  require('react');
20
20
  require('ink');
@@ -3,7 +3,7 @@ import { constants } from 'node:fs';
3
3
  import { mkdir, appendFile, access, readFile } from 'node:fs/promises';
4
4
  import { randomUUID } from 'node:crypto';
5
5
  import { basename, dirname, resolve } from 'node:path';
6
- import { c as configuration } from './persistence-D9tMm6bj.mjs';
6
+ import { c as configuration } from './persistence-BXtirP1k.mjs';
7
7
  import { r as renderEvidenceReport, i as inferEvidenceKind } from './workflowReports-Dd8-4-8f.mjs';
8
8
  import { p as parseWorkflowArgs, s as stringFlag, b as booleanFlag, a as printOrWriteOutput } from './workflowCommon-B0d01Y_a.mjs';
9
9
  import 'node:os';
@@ -5,7 +5,7 @@ var fs = require('node:fs');
5
5
  var promises = require('node:fs/promises');
6
6
  var node_crypto = require('node:crypto');
7
7
  var path = require('node:path');
8
- var logger = require('./persistence-BcQmjobZ.cjs');
8
+ var logger = require('./persistence-DOgft4tZ.cjs');
9
9
  var workflowReports = require('./workflowReports-BEWuQesA.cjs');
10
10
  var workflowCommon = require('./workflowCommon-Bl568-rt.cjs');
11
11
  require('node:os');
@@ -1,4 +1,4 @@
1
- import { d as downloadImage } from './downloadImage-BpVF7A79.mjs';
1
+ import { d as downloadImage } from './downloadImage-DKWzC11M.mjs';
2
2
 
3
3
  async function formatMessageForClaude(text, images) {
4
4
  const content = [];
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var downloadImage = require('./downloadImage-Cijmufpr.cjs');
3
+ var downloadImage = require('./downloadImage-B7MKUI0u.cjs');
4
4
 
5
5
  async function formatMessageForClaude(text, images) {
6
6
  const content = [];