very-happy-cli 0.2.119 → 0.2.121

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 (35) hide show
  1. package/dist/{AcpBackend-DpsLyp2y.mjs → AcpBackend-BxvQ6O4k.mjs} +1 -1
  2. package/dist/{AcpBackend-BpwOAcgu.cjs → AcpBackend-Cdj56ZfU.cjs} +1 -1
  3. package/dist/{AcpSessionManager-Ck6heffK.cjs → AcpSessionManager-DahCU78z.cjs} +51 -11
  4. package/dist/{AcpSessionManager-CM0PcgwO.mjs → AcpSessionManager-DlWlQVhw.mjs} +51 -11
  5. package/dist/{config-CtQJKe8h.cjs → config-DxOhdFEx.cjs} +2 -2
  6. package/dist/{config-DpE-aSHW.mjs → config-osO37dR1.mjs} +2 -2
  7. package/dist/{index-BITXLEZo.mjs → index-BcwAnM9k.mjs} +25 -11
  8. package/dist/{index-CK-yge8m.cjs → index-Bv53Zygv.cjs} +24 -10
  9. package/dist/{index-CRhOD3CQ.cjs → index-DObePs_K.cjs} +176 -54
  10. package/dist/{index-CGpkGfDj.mjs → index-DtZFY8aS.mjs} +2 -2
  11. package/dist/{index-DNXCQz_A.mjs → index-Iz-M3qbz.mjs} +172 -51
  12. package/dist/{index-DY7g3UWq.cjs → index-Vjo1jIJH.cjs} +2 -2
  13. package/dist/index.cjs +2 -2
  14. package/dist/index.mjs +2 -2
  15. package/dist/{installTerminalHooks-Dmr3JUJR.mjs → installTerminalHooks-Bq11vOqF.mjs} +2 -2
  16. package/dist/{installTerminalHooks-BOOg7NNs.cjs → installTerminalHooks-DehsXLmV.cjs} +2 -2
  17. package/dist/lib.cjs +1 -1
  18. package/dist/lib.d.cts +25 -1
  19. package/dist/lib.d.mts +25 -1
  20. package/dist/lib.mjs +1 -1
  21. package/dist/{mcp-D4N7yn98.mjs → mcp-Bx1B3uny.mjs} +2 -2
  22. package/dist/{mcp-CxIk4Mes.cjs → mcp-Cpx9Qlch.cjs} +2 -2
  23. package/dist/{runGemini-Bexbg8pA.mjs → runGemini-CMgudbJs.mjs} +9 -5
  24. package/dist/{runGemini-TbGYRy0V.cjs → runGemini-DI8DipUx.cjs} +9 -5
  25. package/dist/{runOpenClaw-B-TV4EkO.cjs → runOpenClaw-CetdjTl-.cjs} +3 -3
  26. package/dist/{runOpenClaw-BpoIQWbe.mjs → runOpenClaw-DR3fLtVf.mjs} +3 -3
  27. package/dist/{send-U9UJvqNA.cjs → send-Cq0NZCn8.cjs} +2 -2
  28. package/dist/{send-z5SeDtKA.mjs → send-M4b_hD7t.mjs} +2 -2
  29. package/dist/{sessions-DNALvNe8.mjs → sessions-CelkWhqX.mjs} +11 -4
  30. package/dist/{sessions-BAZGALtl.cjs → sessions-DW4lrLOp.cjs} +11 -4
  31. package/dist/{spawn-CsV0SKkw.mjs → spawn-C4fF0q3Z.mjs} +2 -2
  32. package/dist/{spawn-dBxu-RAv.cjs → spawn-D3cwBlWI.cjs} +2 -2
  33. package/dist/{types-Bw_6p8NP.cjs → types-COOYpI8_.cjs} +176 -33
  34. package/dist/{types-DdyNuB7D.mjs → types-P2cJWD0E.mjs} +174 -33
  35. package/package.json +7 -7
@@ -3,7 +3,7 @@
3
3
  var chalk = require('chalk');
4
4
  var os = require('node:os');
5
5
  var node_crypto = require('node:crypto');
6
- var persistence = require('./types-Bw_6p8NP.cjs');
6
+ var persistence = require('./types-COOYpI8_.cjs');
7
7
  var spawn = require('cross-spawn');
8
8
  var path = require('node:path');
9
9
  var node_readline = require('node:readline');
@@ -3406,9 +3406,7 @@ class StreamRelay {
3406
3406
  if (e.type === "content_block_start") {
3407
3407
  const kind = e.content_block?.type === "thinking" ? "thinking" : e.content_block?.type === "text" ? "text" : null;
3408
3408
  if (!kind || !this.currentMid || typeof e.index !== "number") return;
3409
- this.flushPending();
3410
- this.openBlocks.add(e.index);
3411
- this.send({ t: "block-start", mid: this.currentMid, idx: e.index, kind });
3409
+ this.openBlock(this.currentMid, e.index, kind);
3412
3410
  return;
3413
3411
  }
3414
3412
  if (e.type === "content_block_delta") {
@@ -3416,16 +3414,12 @@ class StreamRelay {
3416
3414
  const text = delta?.type === "text_delta" ? delta.text : delta?.type === "thinking_delta" ? delta.thinking : null;
3417
3415
  if (typeof text !== "string" || text.length === 0) return;
3418
3416
  if (!this.currentMid || typeof e.index !== "number") return;
3419
- if (!this.openBlocks.has(e.index)) return;
3420
3417
  this.appendDelta(this.currentMid, e.index, text);
3421
3418
  return;
3422
3419
  }
3423
3420
  if (e.type === "content_block_stop") {
3424
3421
  if (!this.currentMid || typeof e.index !== "number") return;
3425
- if (!this.openBlocks.has(e.index)) return;
3426
- this.flushPending();
3427
- this.openBlocks.delete(e.index);
3428
- this.send({ t: "block-end", mid: this.currentMid, idx: e.index });
3422
+ this.closeBlock(this.currentMid, e.index);
3429
3423
  return;
3430
3424
  }
3431
3425
  if (e.type === "message_delta") {
@@ -3436,7 +3430,29 @@ class StreamRelay {
3436
3430
  return;
3437
3431
  }
3438
3432
  }
3433
+ // ---- Block-level API (see module comment) --------------------------------
3434
+ /** Open a draft block. A different `mid` than the one currently open closes
3435
+ * whatever the previous message left open, exactly like the SDK's
3436
+ * `message_start` does. Re-opening an already open block is a no-op. */
3437
+ openBlock(mid, idx, kind) {
3438
+ this.idleSinceTurnEnd = false;
3439
+ if (this.currentMid !== mid) {
3440
+ this.flushPending();
3441
+ this.closeOpenBlocks();
3442
+ this.currentMid = mid;
3443
+ }
3444
+ if (this.openBlocks.has(idx)) return;
3445
+ this.flushPending();
3446
+ this.openBlocks.add(idx);
3447
+ this.send({ t: "block-start", mid, idx, kind });
3448
+ }
3449
+ /** Append text to an OPEN block; deltas for a block that was never opened
3450
+ * (or belongs to another message) are dropped — the SDK path relies on
3451
+ * this to ignore `input_json_delta` for tool_use blocks. */
3439
3452
  appendDelta(mid, idx, text) {
3453
+ this.idleSinceTurnEnd = false;
3454
+ if (text.length === 0) return;
3455
+ if (this.currentMid !== mid || !this.openBlocks.has(idx)) return;
3440
3456
  if (this.pending && (this.pending.mid !== mid || this.pending.idx !== idx)) {
3441
3457
  this.flushPending();
3442
3458
  }
@@ -3456,6 +3472,22 @@ class StreamRelay {
3456
3472
  }, STREAM_FLUSH_MS);
3457
3473
  }
3458
3474
  }
3475
+ /** Close an open block: pending text goes out first, then `block-end`. */
3476
+ closeBlock(mid, idx) {
3477
+ this.idleSinceTurnEnd = false;
3478
+ if (this.currentMid !== mid || !this.openBlocks.has(idx)) return;
3479
+ this.flushPending();
3480
+ this.openBlocks.delete(idx);
3481
+ this.send({ t: "block-end", mid, idx });
3482
+ }
3483
+ /** Merge quantified progress; flushed on the progress cadence. */
3484
+ setProgress(patch) {
3485
+ this.idleSinceTurnEnd = false;
3486
+ this.progress = { ...this.progress, ...patch };
3487
+ this.progressDirty = true;
3488
+ this.scheduleProgress();
3489
+ }
3490
+ // -------------------------------------------------------------------------
3459
3491
  flushPending() {
3460
3492
  if (this.flushHandle !== null) {
3461
3493
  this.clearTimer(this.flushHandle);
@@ -3478,11 +3510,6 @@ class StreamRelay {
3478
3510
  }
3479
3511
  this.openBlocks.clear();
3480
3512
  }
3481
- setProgress(patch) {
3482
- this.progress = { ...this.progress, ...patch };
3483
- this.progressDirty = true;
3484
- this.scheduleProgress();
3485
- }
3486
3513
  scheduleProgress() {
3487
3514
  if (this.progressHandle !== null) return;
3488
3515
  this.progressHandle = this.setTimer(() => {
@@ -4325,10 +4352,17 @@ class MessageQueue2 {
4325
4352
  waiter = null;
4326
4353
  closed = false;
4327
4354
  onMessageHandler = null;
4355
+ /**
4356
+ * B-332: fired for every item the queue itself destroys before it was ever
4357
+ * handed to the runner. The runner wires this to a queue-cancel tombstone
4358
+ * so the web stops painting a silently-lost message as "queued".
4359
+ */
4360
+ onDiscardHandler = null;
4328
4361
  modeHasher;
4329
- constructor(modeHasher, onMessageHandler = null) {
4362
+ constructor(modeHasher, onMessageHandler = null, onDiscardHandler = null) {
4330
4363
  this.modeHasher = modeHasher;
4331
4364
  this.onMessageHandler = onMessageHandler;
4365
+ this.onDiscardHandler = onDiscardHandler;
4332
4366
  persistence.logger.debug(`[MessageQueue2] Initialized`);
4333
4367
  }
4334
4368
  /**
@@ -4337,6 +4371,19 @@ class MessageQueue2 {
4337
4371
  setOnMessage(handler) {
4338
4372
  this.onMessageHandler = handler;
4339
4373
  }
4374
+ /**
4375
+ * Set a handler that will be called when messages are discarded without ever
4376
+ * being processed (B-332).
4377
+ */
4378
+ setOnDiscard(handler) {
4379
+ this.onDiscardHandler = handler;
4380
+ }
4381
+ /** Report the current items as destroyed for `reason` (caller clears next). */
4382
+ notifyDiscard(reason) {
4383
+ if (this.queue.length === 0) return;
4384
+ const entries = this.queue.map((item) => ({ sourceId: item.sourceId, reason }));
4385
+ this.onDiscardHandler?.(entries);
4386
+ }
4340
4387
  /**
4341
4388
  * Push a message to the queue with a mode and an optional list of
4342
4389
  * attachments that travel with this message.
@@ -4404,6 +4451,7 @@ class MessageQueue2 {
4404
4451
  }
4405
4452
  const modeHash = this.modeHasher(mode);
4406
4453
  persistence.logger.debug(`[MessageQueue2] pushIsolateAndClear() called with mode hash: ${modeHash} - clearing ${this.queue.length} pending messages`);
4454
+ this.notifyDiscard("cleared");
4407
4455
  this.queue = [];
4408
4456
  this.queue.push({
4409
4457
  message,
@@ -4455,6 +4503,7 @@ class MessageQueue2 {
4455
4503
  */
4456
4504
  reset() {
4457
4505
  persistence.logger.debug(`[MessageQueue2] reset() called. Clearing ${this.queue.length} messages`);
4506
+ this.notifyDiscard("aborted");
4458
4507
  this.queue = [];
4459
4508
  this.closed = false;
4460
4509
  this.waiter = null;
@@ -5313,6 +5362,23 @@ async function openBrowser(url) {
5313
5362
  }
5314
5363
  }
5315
5364
 
5365
+ function decideMachineId(input) {
5366
+ const { read, newAuth } = input;
5367
+ if (read.kind === "unreadable") {
5368
+ return {
5369
+ action: "refuse",
5370
+ reason: `settings exist but could not be read (${read.error}); refusing to mint a new machine id \u2014 fix or remove the settings file, or run \`very-happy auth login --force\` to deliberately re-register this machine`
5371
+ };
5372
+ }
5373
+ if (newAuth) return { action: "mint", reason: "new-auth" };
5374
+ if (read.kind === "absent") return { action: "mint", reason: "no-settings-file" };
5375
+ const existing = read.settings.machineId;
5376
+ if (typeof existing === "string" && existing.length > 0) {
5377
+ return { action: "reuse", machineId: existing };
5378
+ }
5379
+ return { action: "mint", reason: "no-machine-id" };
5380
+ }
5381
+
5316
5382
  async function doAuth() {
5317
5383
  console.clear();
5318
5384
  const secret = new Uint8Array(node_crypto.randomBytes(32));
@@ -5486,17 +5552,23 @@ async function authAndSetupMachineIfNeeded() {
5486
5552
  } else {
5487
5553
  persistence.logger.debug("[AUTH] Using existing credentials");
5488
5554
  }
5489
- const settings = await persistence.updateSettings(async (s) => {
5490
- if (newAuth || !s.machineId) {
5491
- return {
5492
- ...s,
5493
- machineId: node_crypto.randomUUID()
5494
- };
5495
- }
5496
- return s;
5555
+ const decision = decideMachineId({
5556
+ read: await persistence.readSettingsOutcome(),
5557
+ newAuth
5497
5558
  });
5498
- persistence.logger.debug(`[AUTH] Machine ID: ${settings.machineId}`);
5499
- return { credentials, machineId: settings.machineId };
5559
+ if (decision.action === "refuse") {
5560
+ throw new Error(`Cannot establish this machine's identity: ${decision.reason}`);
5561
+ }
5562
+ let machineId;
5563
+ if (decision.action === "reuse") {
5564
+ machineId = decision.machineId;
5565
+ } else {
5566
+ machineId = node_crypto.randomUUID();
5567
+ persistence.logger.warn(`[AUTH] Registering a NEW machine id (${decision.reason})`);
5568
+ await persistence.updateSettings(async (s) => ({ ...s, machineId }));
5569
+ }
5570
+ persistence.logger.debug(`[AUTH] Machine ID: ${machineId}`);
5571
+ return { credentials, machineId };
5500
5572
  }
5501
5573
 
5502
5574
  let caffeinateProcess = null;
@@ -7329,7 +7401,7 @@ function parseJsonObject(text) {
7329
7401
  return null;
7330
7402
  }
7331
7403
  }
7332
- function resolveSdkClaudeBinary(platform = process.platform, arch = process.arch, resolver = (s) => node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CRhOD3CQ.cjs', document.baseURI).href))).resolve(s)) {
7404
+ function resolveSdkClaudeBinary(platform = process.platform, arch = process.arch, resolver = (s) => node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-DObePs_K.cjs', document.baseURI).href))).resolve(s)) {
7333
7405
  const platformArch = `${platform}-${arch}`;
7334
7406
  const candidates = [
7335
7407
  `@anthropic-ai/claude-agent-sdk-${platformArch}/claude`,
@@ -9975,6 +10047,27 @@ async function openUserScopedSocket(token, options = {}) {
9975
10047
  };
9976
10048
  }
9977
10049
 
10050
+ const RPC_RATE_LIMIT_ERROR = "RPC rate limit reached";
10051
+ const RPC_ACCOUNT_RATE_LIMIT_ERROR = "RPC account rate limit reached";
10052
+ const RPC_RATE_RETRY_MIN_DELAY_MS = 2e3;
10053
+ const RPC_RATE_RETRY_MAX_DELAY_MS = 6e4;
10054
+ const RPC_RATE_MAX_RETRIES = 2;
10055
+ function isRpcRateLimitAck(ack) {
10056
+ if (!ack || typeof ack !== "object") return false;
10057
+ const a = ack;
10058
+ if (a.ok !== false) return false;
10059
+ if (a.code === "rpc_rate_limited" || a.code === "rpc_account_rate_limited") return true;
10060
+ return a.error === RPC_RATE_LIMIT_ERROR || a.error === RPC_ACCOUNT_RATE_LIMIT_ERROR;
10061
+ }
10062
+ function rpcRateRetryDelayMs(attempt, retryAfterMs, random = Math.random()) {
10063
+ if (typeof retryAfterMs === "number" && Number.isFinite(retryAfterMs) && retryAfterMs > 0) {
10064
+ return Math.min(RPC_RATE_RETRY_MAX_DELAY_MS, Math.round(retryAfterMs * (1 + random * 0.5)));
10065
+ }
10066
+ const exponent = Math.max(0, Math.min(attempt, 32) - 1);
10067
+ const ceiling = Math.min(RPC_RATE_RETRY_MIN_DELAY_MS * 2 ** exponent, RPC_RATE_RETRY_MAX_DELAY_MS);
10068
+ return Math.round(RPC_RATE_RETRY_MIN_DELAY_MS + random * (ceiling - RPC_RATE_RETRY_MIN_DELAY_MS));
10069
+ }
10070
+
9978
10071
  const PERMISSION_OPS_CLIENT = "session-ops";
9979
10072
  const PERMISSION_RPC_TIMEOUT_MS = 3e4;
9980
10073
  const SETTLE_TIMEOUT_MS = 5e3;
@@ -10006,6 +10099,9 @@ function interpretPermissionAck(ack, decryptResult) {
10006
10099
  if (/timed? ?out/i.test(message)) {
10007
10100
  return { status: "timeout", message };
10008
10101
  }
10102
+ if (isRpcRateLimitAck(ack)) {
10103
+ return { status: "rate-limited", message, retryAfterMs: rpcRateRetryDelayMs(1, ack.retryAfterMs, 0) };
10104
+ }
10009
10105
  return { status: "rejected", message };
10010
10106
  }
10011
10107
  let body = null;
@@ -10067,15 +10163,24 @@ async function resolvePermissionRequest(sessionId, requestId, verdict, deps = {}
10067
10163
  const params = persistence.encodeBase64(persistence.encrypt(key, persisted.encryptionVariant, payload));
10068
10164
  const transport = await (deps.openTransport ?? openUserScopedSocket)(token);
10069
10165
  const rpcTimeoutMs = deps.rpcTimeoutMs ?? PERMISSION_RPC_TIMEOUT_MS;
10166
+ const sleep = deps.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
10070
10167
  let ack;
10071
10168
  try {
10072
- ack = await withDeadline(
10073
- transport.rpcCall({ method: `${sessionId}:permission`, params }, rpcTimeoutMs),
10074
- rpcTimeoutMs + RPC_DEADLINE_GRACE_MS,
10075
- `permission RPC did not settle within ${rpcTimeoutMs}ms`
10076
- );
10077
- } catch (error) {
10078
- ack = { ok: false, error: error instanceof Error ? error.message : "RPC call failed" };
10169
+ for (let attempt = 1; ; attempt++) {
10170
+ try {
10171
+ ack = await withDeadline(
10172
+ transport.rpcCall({ method: `${sessionId}:permission`, params }, rpcTimeoutMs),
10173
+ rpcTimeoutMs + RPC_DEADLINE_GRACE_MS,
10174
+ `permission RPC did not settle within ${rpcTimeoutMs}ms`
10175
+ );
10176
+ } catch (error) {
10177
+ ack = { ok: false, error: error instanceof Error ? error.message : "RPC call failed" };
10178
+ }
10179
+ if (!isRpcRateLimitAck(ack) || attempt > RPC_RATE_MAX_RETRIES) break;
10180
+ const waitMs = rpcRateRetryDelayMs(attempt, ack.retryAfterMs, (deps.random ?? Math.random)());
10181
+ deps.onRateLimited?.({ attempt, waitMs, serverError: ack.error ?? "RPC rate limit reached" });
10182
+ await sleep(waitMs);
10183
+ }
10079
10184
  } finally {
10080
10185
  transport.close();
10081
10186
  }
@@ -10083,7 +10188,6 @@ async function resolvePermissionRequest(sessionId, requestId, verdict, deps = {}
10083
10188
  if (outcome.status !== "acknowledged") {
10084
10189
  return { sessionId, requestId, payload, outcome };
10085
10190
  }
10086
- const sleep = deps.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
10087
10191
  const deadline = now() + (deps.settleTimeoutMs ?? SETTLE_TIMEOUT_MS);
10088
10192
  let settled = false;
10089
10193
  for (; ; ) {
@@ -11214,7 +11318,7 @@ function registerSideQuestionHandler(rpc, deps) {
11214
11318
  const retainMs = deps.retainMs ?? SIDE_QUESTION_RETAIN_MS;
11215
11319
  const maxRunMs = deps.maxRunMs ?? SIDE_QUESTION_MAX_RUN_MS;
11216
11320
  const run = deps.run ?? (async (input) => {
11217
- const { query } = await Promise.resolve().then(function () { return require('./index-DY7g3UWq.cjs'); });
11321
+ const { query } = await Promise.resolve().then(function () { return require('./index-Vjo1jIJH.cjs'); });
11218
11322
  return runSideQuestion(query, input);
11219
11323
  });
11220
11324
  const slots = /* @__PURE__ */ new Map();
@@ -11316,7 +11420,7 @@ const MAX_TITLE_CHARS = 60;
11316
11420
  const GENERATION_TIMEOUT_MS = 3e4;
11317
11421
  function resolveClaudeBinary() {
11318
11422
  try {
11319
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CRhOD3CQ.cjs', document.baseURI).href)));
11423
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-DObePs_K.cjs', document.baseURI).href)));
11320
11424
  const utilsPath = path.resolve(path.join(persistence.projectPath(), "scripts", "claude_version_utils.cjs"));
11321
11425
  const { getClaudeCliPath } = require$1(utilsPath);
11322
11426
  const path$1 = getClaudeCliPath();
@@ -11896,6 +12000,7 @@ async function runClaude(credentials, options = {}) {
11896
12000
  if (reconnectSessionId) {
11897
12001
  session.suppressNextArchiveSignal();
11898
12002
  if (!reconnectSeeded) session.skipExistingMessages();
12003
+ void session.cancelUndeliveredQueuedInputs();
11899
12004
  session.updateMetadata((meta) => ({
11900
12005
  ...mergeReconnectMetadata(meta, metadata, Date.now()),
11901
12006
  queueCancellation: true,
@@ -12020,6 +12125,16 @@ async function runClaude(credentials, options = {}) {
12020
12125
  controlledByUser: options.startingMode !== "remote"
12021
12126
  }));
12022
12127
  const messageQueue = new MessageQueue2(claudeModeHash);
12128
+ messageQueue.setOnDiscard((entries) => {
12129
+ const byReason = /* @__PURE__ */ new Map();
12130
+ for (const entry of entries) {
12131
+ if (!entry.sourceId) continue;
12132
+ const list = byReason.get(entry.reason) ?? [];
12133
+ list.push(entry.sourceId);
12134
+ byReason.set(entry.reason, list);
12135
+ }
12136
+ for (const [reason, keys] of byReason) session.sendQueueCancelReason(keys, reason);
12137
+ });
12023
12138
  session.rpcHandlerManager.registerHandler("cancelQueuedMessage", async (params) => ({
12024
12139
  removed: messageQueue.cancelPending(
12025
12140
  typeof params?.localKey === "string" ? params.localKey : void 0,
@@ -13522,9 +13637,9 @@ function resolveLocalSignupBootstrap(configuredMode, configuredInviteCodes, gene
13522
13637
  };
13523
13638
  }
13524
13639
 
13525
- const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CRhOD3CQ.cjs', document.baseURI).href)));
13640
+ const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-DObePs_K.cjs', document.baseURI).href)));
13526
13641
  const __dirname$1 = path.dirname(__filename$1);
13527
- const require_ = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CRhOD3CQ.cjs', document.baseURI).href)));
13642
+ const require_ = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-DObePs_K.cjs', document.baseURI).href)));
13528
13643
  const PRISMA_QUERY_ENGINE_FILES = {
13529
13644
  "arm64-darwin": "libquery_engine-darwin-arm64.dylib.node",
13530
13645
  "x64-darwin": "libquery_engine-darwin.dylib.node",
@@ -15232,10 +15347,10 @@ function isCodexClearText(text) {
15232
15347
  }
15233
15348
  function enqueueCodexUserText(opts) {
15234
15349
  if (isCodexClearText(opts.text)) {
15235
- opts.queue.pushIsolateAndClear(opts.text, opts.mode);
15350
+ opts.queue.pushIsolateAndClear(opts.text, opts.mode, void 0, opts.sourceId);
15236
15351
  return "clear";
15237
15352
  }
15238
- opts.queue.push(opts.text, opts.mode);
15353
+ opts.queue.push(opts.text, opts.mode, void 0, opts.sourceId);
15239
15354
  return "queued";
15240
15355
  }
15241
15356
 
@@ -15420,6 +15535,7 @@ async function runCodex(opts) {
15420
15535
  if (reconnectSessionId) {
15421
15536
  session.suppressNextArchiveSignal();
15422
15537
  if (!reconnectSeeded) session.skipExistingMessages();
15538
+ void session.cancelUndeliveredQueuedInputs();
15423
15539
  session.updateMetadata((meta) => mergeReconnectMetadata(meta, metadata, Date.now()));
15424
15540
  }
15425
15541
  if (response) {
@@ -15442,6 +15558,10 @@ async function runCodex(opts) {
15442
15558
  }
15443
15559
  }
15444
15560
  const messageQueue = new MessageQueue2(hashCodexEnhancedMode);
15561
+ messageQueue.setOnDiscard((entries) => {
15562
+ const keys = entries.map((entry) => entry.sourceId).filter((key) => typeof key === "string");
15563
+ if (keys.length > 0) session.sendQueueCancelReason(keys, entries[0].reason);
15564
+ });
15445
15565
  let currentPermissionMode = initialPermissionMode;
15446
15566
  let currentModel = DEFAULT_CODEX_MODEL;
15447
15567
  let currentEffort = DEFAULT_CODEX_EFFORT;
@@ -15523,7 +15643,8 @@ async function runCodex(opts) {
15523
15643
  const enqueueResult = enqueueCodexUserText({
15524
15644
  text: message.content.text,
15525
15645
  mode: enhancedMode,
15526
- queue: messageQueue
15646
+ queue: messageQueue,
15647
+ sourceId: message.localKey
15527
15648
  });
15528
15649
  if (enqueueResult === "clear") {
15529
15650
  persistence.logger.debug("[Codex] /clear command pushed to isolated queue");
@@ -16148,7 +16269,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
16148
16269
  process.exit(0);
16149
16270
  } else if (subcommand === "install-terminal-hooks") {
16150
16271
  try {
16151
- const { installTerminalHooks, parseTerminalHooksArgs, TERMINAL_HOOKS_HELP } = await Promise.resolve().then(function () { return require('./installTerminalHooks-BOOg7NNs.cjs'); });
16272
+ const { installTerminalHooks, parseTerminalHooksArgs, TERMINAL_HOOKS_HELP } = await Promise.resolve().then(function () { return require('./installTerminalHooks-DehsXLmV.cjs'); });
16152
16273
  const command = parseTerminalHooksArgs(args.slice(1));
16153
16274
  if (command.action === "help") {
16154
16275
  console.log(TERMINAL_HOOKS_HELP);
@@ -16165,7 +16286,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
16165
16286
  }
16166
16287
  } else if (subcommand === "spawn") {
16167
16288
  try {
16168
- const { handleSpawnCommand } = await Promise.resolve().then(function () { return require('./spawn-dBxu-RAv.cjs'); });
16289
+ const { handleSpawnCommand } = await Promise.resolve().then(function () { return require('./spawn-D3cwBlWI.cjs'); });
16169
16290
  await handleSpawnCommand(args.slice(1));
16170
16291
  } catch (error) {
16171
16292
  console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
@@ -16177,7 +16298,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
16177
16298
  return;
16178
16299
  } else if (subcommand === "sessions") {
16179
16300
  try {
16180
- const { handleSessionsCommand } = await Promise.resolve().then(function () { return require('./sessions-BAZGALtl.cjs'); });
16301
+ const { handleSessionsCommand } = await Promise.resolve().then(function () { return require('./sessions-DW4lrLOp.cjs'); });
16181
16302
  await handleSessionsCommand(args.slice(1));
16182
16303
  } catch (error) {
16183
16304
  console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
@@ -16189,7 +16310,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
16189
16310
  return;
16190
16311
  } else if (subcommand === "send") {
16191
16312
  try {
16192
- const { handleSendCommand } = await Promise.resolve().then(function () { return require('./send-U9UJvqNA.cjs'); });
16313
+ const { handleSendCommand } = await Promise.resolve().then(function () { return require('./send-Cq0NZCn8.cjs'); });
16193
16314
  await handleSendCommand(args.slice(1));
16194
16315
  } catch (error) {
16195
16316
  console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
@@ -16295,9 +16416,9 @@ Conversation history is preserved on the server, but in-flight tool calls are in
16295
16416
  if (geminiSubcommand === "project" && args[2] === "set" && args[3]) {
16296
16417
  const projectId = args[3];
16297
16418
  try {
16298
- const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return require('./config-CtQJKe8h.cjs'); });
16299
- const { readCredentialsForConfiguredRelay: readCredentialsForConfiguredRelay2 } = await Promise.resolve().then(function () { return require('./types-Bw_6p8NP.cjs'); }).then(function (n) { return n.persistence; });
16300
- const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./types-Bw_6p8NP.cjs'); }).then(function (n) { return n.api; });
16419
+ const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return require('./config-DxOhdFEx.cjs'); });
16420
+ const { readCredentialsForConfiguredRelay: readCredentialsForConfiguredRelay2 } = await Promise.resolve().then(function () { return require('./types-COOYpI8_.cjs'); }).then(function (n) { return n.persistence; });
16421
+ const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./types-COOYpI8_.cjs'); }).then(function (n) { return n.api; });
16301
16422
  let userEmail = void 0;
16302
16423
  try {
16303
16424
  const credentials = await readCredentialsForConfiguredRelay2();
@@ -16328,7 +16449,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
16328
16449
  }
16329
16450
  if (geminiSubcommand === "project" && args[2] === "get") {
16330
16451
  try {
16331
- const { readGeminiLocalConfig } = await Promise.resolve().then(function () { return require('./config-CtQJKe8h.cjs'); });
16452
+ const { readGeminiLocalConfig } = await Promise.resolve().then(function () { return require('./config-DxOhdFEx.cjs'); });
16332
16453
  const config = readGeminiLocalConfig();
16333
16454
  if (config.googleCloudProject) {
16334
16455
  console.log(`Current Google Cloud Project: ${config.googleCloudProject}`);
@@ -16368,7 +16489,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
16368
16489
  process.exit(0);
16369
16490
  }
16370
16491
  try {
16371
- const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-TbGYRy0V.cjs'); });
16492
+ const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-DI8DipUx.cjs'); });
16372
16493
  let startedBy = void 0;
16373
16494
  for (let i = 1; i < args.length; i++) {
16374
16495
  if (args[i] === "--started-by") {
@@ -16398,7 +16519,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
16398
16519
  }
16399
16520
  };
16400
16521
  try {
16401
- const { runAcp, resolveAcpAgentConfig } = await Promise.resolve().then(function () { return require('./index-CK-yge8m.cjs'); });
16522
+ const { runAcp, resolveAcpAgentConfig } = await Promise.resolve().then(function () { return require('./index-Bv53Zygv.cjs'); });
16402
16523
  const parsed = parsePiRunnerArgs(args.slice(1));
16403
16524
  const resolved = resolveAcpAgentConfig(["pi", ...parsed.passthrough]);
16404
16525
  const { credentials } = await authAndSetupMachineIfNeeded();
@@ -16425,7 +16546,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
16425
16546
  return;
16426
16547
  } else if (subcommand === "acp") {
16427
16548
  try {
16428
- const { runAcp, resolveAcpAgentConfig } = await Promise.resolve().then(function () { return require('./index-CK-yge8m.cjs'); });
16549
+ const { runAcp, resolveAcpAgentConfig } = await Promise.resolve().then(function () { return require('./index-Bv53Zygv.cjs'); });
16429
16550
  let startedBy = void 0;
16430
16551
  let verbose = false;
16431
16552
  const acpArgs = [];
@@ -16465,7 +16586,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
16465
16586
  return;
16466
16587
  } else if (subcommand === "openclaw") {
16467
16588
  try {
16468
- const { runOpenClaw } = await Promise.resolve().then(function () { return require('./runOpenClaw-B-TV4EkO.cjs'); });
16589
+ const { runOpenClaw } = await Promise.resolve().then(function () { return require('./runOpenClaw-CetdjTl-.cjs'); });
16469
16590
  let startedBy = void 0;
16470
16591
  let verbose = false;
16471
16592
  let gatewayUrl;
@@ -16516,7 +16637,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
16516
16637
  return;
16517
16638
  } else if (subcommand === "mcp" && args.length === 1) {
16518
16639
  try {
16519
- const { handleMcpCommand } = await Promise.resolve().then(function () { return require('./mcp-CxIk4Mes.cjs'); });
16640
+ const { handleMcpCommand } = await Promise.resolve().then(function () { return require('./mcp-Cpx9Qlch.cjs'); });
16520
16641
  await handleMcpCommand();
16521
16642
  } catch (error) {
16522
16643
  process.stderr.write(`[very-happy mcp] Fatal: ${error instanceof Error ? error.message : String(error)}
@@ -16890,6 +17011,7 @@ exports.MAX_READ_LIMIT = MAX_READ_LIMIT;
16890
17011
  exports.MessageBuffer = MessageBuffer;
16891
17012
  exports.MessageQueue2 = MessageQueue2;
16892
17013
  exports.SPAWN_AGENTS = SPAWN_AGENTS;
17014
+ exports.StreamRelay = StreamRelay;
16893
17015
  exports.TitleGenerator = TitleGenerator;
16894
17016
  exports.archiveSession = archiveSession;
16895
17017
  exports.checkIfDaemonRunningAndCleanupStaleState = checkIfDaemonRunningAndCleanupStaleState;
@@ -1,9 +1,9 @@
1
- import { q as query } from './index-DNXCQz_A.mjs';
1
+ import { q as query } from './index-Iz-M3qbz.mjs';
2
2
  export { AbortError } from '@anthropic-ai/claude-agent-sdk';
3
3
  import 'chalk';
4
4
  import 'node:os';
5
5
  import 'node:crypto';
6
- import './types-DdyNuB7D.mjs';
6
+ import './types-P2cJWD0E.mjs';
7
7
  import 'axios';
8
8
  import 'node:util';
9
9
  import 'node:fs';