happy-imou-cloud 2.0.21 → 2.0.23

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 (29) hide show
  1. package/dist/{BaseReasoningProcessor-0nj-PMFc.cjs → BaseReasoningProcessor-BzbDRBqp.cjs} +3 -3
  2. package/dist/{BaseReasoningProcessor-DnVC7liC.mjs → BaseReasoningProcessor-DH3BCCTf.mjs} +3 -3
  3. package/dist/ProviderSelectionHandler-CbkbtIRC.mjs +673 -0
  4. package/dist/ProviderSelectionHandler-meVvz9NZ.cjs +680 -0
  5. package/dist/{api-MGlKcEf3.cjs → api-C4bF6GEA.cjs} +35 -3
  6. package/dist/{api-DJe9WP9M.mjs → api-DX7Vg4Hz.mjs} +35 -4
  7. package/dist/{command-DAlFmWmr.cjs → command-CF6Wi_v2.cjs} +3 -3
  8. package/dist/{command-CfyFnMv2.mjs → command-DicPZ-Up.mjs} +3 -3
  9. package/dist/{index-CgVjDJpt.cjs → index-BybqdOf2.cjs} +63 -15
  10. package/dist/{index-CHXCgpwi.mjs → index-CEJmASSW.mjs} +60 -12
  11. package/dist/index.cjs +3 -3
  12. package/dist/index.mjs +3 -3
  13. package/dist/lib.cjs +1 -1
  14. package/dist/lib.d.cts +108 -105
  15. package/dist/lib.d.mts +108 -105
  16. package/dist/lib.mjs +1 -1
  17. package/dist/{persistence-DLFUNI9q.cjs → persistence-CdqBfAwo.cjs} +1 -1
  18. package/dist/{persistence-CkP90vEt.mjs → persistence-xypxp7ei.mjs} +1 -1
  19. package/dist/{registerKillSessionHandler-Cs_INk4A.cjs → registerKillSessionHandler-BK3fZIch.cjs} +14 -364
  20. package/dist/{registerKillSessionHandler-DsHTZDsU.mjs → registerKillSessionHandler-BNN-_qNu.mjs} +15 -362
  21. package/dist/{runClaude-DAQAEmHe.mjs → runClaude-B-ex_tr3.mjs} +8 -6
  22. package/dist/{runClaude-BGSgcyUp.cjs → runClaude-CT3jCZjH.cjs} +11 -9
  23. package/dist/{runCodex-B2UpSn82.mjs → runCodex-DhbvUtJC.mjs} +9 -7
  24. package/dist/{runCodex-earICaxw.cjs → runCodex-DodH9jhh.cjs} +12 -10
  25. package/dist/{runGemini-BBUmH1Qh.mjs → runGemini-BsFR5Pd3.mjs} +12 -74
  26. package/dist/{runGemini-D5RAIaR0.cjs → runGemini-CeHCZ1l4.cjs} +12 -74
  27. package/package.json +1 -1
  28. package/dist/ProviderSelectionHandler-Bafuy28L.cjs +0 -265
  29. package/dist/ProviderSelectionHandler-R-2r7ItM.mjs +0 -261
@@ -18,7 +18,7 @@ var node_child_process = require('node:child_process');
18
18
  var expoServerSdk = require('expo-server-sdk');
19
19
 
20
20
  var name = "happy-imou-cloud";
21
- var version = "2.0.21";
21
+ var version = "2.0.23";
22
22
  var description = "hicloud - Imou 企业定制版。关键是 happy!移动端远程 AI 编程工具,支持 Claude Code、Codex 和 Gemini CLI";
23
23
  var author = "long.zhu";
24
24
  var license = "MIT";
@@ -432,7 +432,7 @@ async function listDaemonLogFiles(limit = 50) {
432
432
  return { file, path: fullPath, modified: stats.mtime };
433
433
  }).sort((a, b) => b.modified.getTime() - a.modified.getTime());
434
434
  try {
435
- const { readDaemonState } = await Promise.resolve().then(function () { return require('./persistence-DLFUNI9q.cjs'); });
435
+ const { readDaemonState } = await Promise.resolve().then(function () { return require('./persistence-CdqBfAwo.cjs'); });
436
436
  const state = await readDaemonState();
437
437
  if (!state) {
438
438
  return logs;
@@ -568,6 +568,7 @@ function decrypt(key, variant, data) {
568
568
 
569
569
  const HAPPY_ORG_REPEAT_THRESHOLD = 3;
570
570
  const HAPPY_ORG_TURN_REPORT_TAG = "HAPPY_TURN_REPORT";
571
+ const HAPPY_ORG_SUMMARY_MAX_LENGTH = 120;
571
572
  const HappyOrgInterventionTypeSchema = z.z.enum([
572
573
  "none",
573
574
  "review_needed",
@@ -575,6 +576,7 @@ const HappyOrgInterventionTypeSchema = z.z.enum([
575
576
  "decision_needed"
576
577
  ]);
577
578
  const HappyOrgTurnStatusSchema = z.z.enum([
579
+ "turn_update",
578
580
  "task_complete",
579
581
  "turn_aborted"
580
582
  ]);
@@ -596,6 +598,7 @@ const HappyOrgMessageMetaSchema = z.z.object({
596
598
  control: HappyOrgTaskControlSchema.optional()
597
599
  });
598
600
  z.z.object({
601
+ turnStatus: HappyOrgTurnStatusSchema.optional().nullable(),
599
602
  summary: z.z.string().optional().nullable(),
600
603
  interventionType: HappyOrgInterventionTypeSchema.optional().nullable(),
601
604
  blockerCode: z.z.string().optional().nullable(),
@@ -616,7 +619,13 @@ const HappyOrgRepeatEntrySchema = z.z.object({
616
619
  lastSeenAt: z.z.number().int().nonnegative()
617
620
  });
618
621
  const HappyOrgRuntimeStateSchema = z.z.object({
619
- status: z.z.enum(["active", "terminated"]),
622
+ status: z.z.enum([
623
+ "active",
624
+ "waiting_review",
625
+ "waiting_decision",
626
+ "waiting_close",
627
+ "terminated"
628
+ ]),
620
629
  reason: z.z.string().optional().nullable(),
621
630
  terminatedAt: z.z.number().int().nonnegative().optional(),
622
631
  reopenedAt: z.z.number().int().nonnegative().optional()
@@ -2811,6 +2820,28 @@ class ApiUserObserverClient extends node_events.EventEmitter {
2811
2820
  offUpdate(callback) {
2812
2821
  this.off("update", callback);
2813
2822
  }
2823
+ syncSessionRuntimeIndex(sessionId, sessionIndex, opts = {}) {
2824
+ if (!this.socket.connected) {
2825
+ logger.debug("[API USER OBSERVER] Skipping session runtime index sync because socket is disconnected", {
2826
+ sessionId
2827
+ });
2828
+ return false;
2829
+ }
2830
+ const now = Date.now();
2831
+ this.socket.emit("session-alive", {
2832
+ sid: sessionId,
2833
+ time: now,
2834
+ thinking: false,
2835
+ sessionIndex
2836
+ });
2837
+ if (opts.markInactive) {
2838
+ this.socket.emit("session-end", {
2839
+ sid: sessionId,
2840
+ time: now
2841
+ });
2842
+ }
2843
+ return true;
2844
+ }
2814
2845
  async close() {
2815
2846
  this.clearReconnectAfterServerDisconnectTimer();
2816
2847
  this.protocolV3Descriptor = null;
@@ -3620,6 +3651,7 @@ exports.ApiSessionClient = ApiSessionClient;
3620
3651
  exports.AsyncLock = AsyncLock;
3621
3652
  exports.HAPPY_CLOUD_DAEMON_PORT = HAPPY_CLOUD_DAEMON_PORT;
3622
3653
  exports.HAPPY_ORG_REPEAT_THRESHOLD = HAPPY_ORG_REPEAT_THRESHOLD;
3654
+ exports.HAPPY_ORG_SUMMARY_MAX_LENGTH = HAPPY_ORG_SUMMARY_MAX_LENGTH;
3623
3655
  exports.HAPPY_ORG_TURN_REPORT_TAG = HAPPY_ORG_TURN_REPORT_TAG;
3624
3656
  exports.HeadTailPreviewBuffer = HeadTailPreviewBuffer;
3625
3657
  exports.SIGNING_BOOTSTRAP_REQUIRED_MESSAGE = SIGNING_BOOTSTRAP_REQUIRED_MESSAGE;
@@ -16,7 +16,7 @@ import { spawn } from 'node:child_process';
16
16
  import { Expo } from 'expo-server-sdk';
17
17
 
18
18
  var name = "happy-imou-cloud";
19
- var version = "2.0.21";
19
+ var version = "2.0.23";
20
20
  var description = "hicloud - Imou 企业定制版。关键是 happy!移动端远程 AI 编程工具,支持 Claude Code、Codex 和 Gemini CLI";
21
21
  var author = "long.zhu";
22
22
  var license = "MIT";
@@ -430,7 +430,7 @@ async function listDaemonLogFiles(limit = 50) {
430
430
  return { file, path: fullPath, modified: stats.mtime };
431
431
  }).sort((a, b) => b.modified.getTime() - a.modified.getTime());
432
432
  try {
433
- const { readDaemonState } = await import('./persistence-CkP90vEt.mjs');
433
+ const { readDaemonState } = await import('./persistence-xypxp7ei.mjs');
434
434
  const state = await readDaemonState();
435
435
  if (!state) {
436
436
  return logs;
@@ -566,6 +566,7 @@ function decrypt(key, variant, data) {
566
566
 
567
567
  const HAPPY_ORG_REPEAT_THRESHOLD = 3;
568
568
  const HAPPY_ORG_TURN_REPORT_TAG = "HAPPY_TURN_REPORT";
569
+ const HAPPY_ORG_SUMMARY_MAX_LENGTH = 120;
569
570
  const HappyOrgInterventionTypeSchema = z.enum([
570
571
  "none",
571
572
  "review_needed",
@@ -573,6 +574,7 @@ const HappyOrgInterventionTypeSchema = z.enum([
573
574
  "decision_needed"
574
575
  ]);
575
576
  const HappyOrgTurnStatusSchema = z.enum([
577
+ "turn_update",
576
578
  "task_complete",
577
579
  "turn_aborted"
578
580
  ]);
@@ -594,6 +596,7 @@ const HappyOrgMessageMetaSchema = z.object({
594
596
  control: HappyOrgTaskControlSchema.optional()
595
597
  });
596
598
  z.object({
599
+ turnStatus: HappyOrgTurnStatusSchema.optional().nullable(),
597
600
  summary: z.string().optional().nullable(),
598
601
  interventionType: HappyOrgInterventionTypeSchema.optional().nullable(),
599
602
  blockerCode: z.string().optional().nullable(),
@@ -614,7 +617,13 @@ const HappyOrgRepeatEntrySchema = z.object({
614
617
  lastSeenAt: z.number().int().nonnegative()
615
618
  });
616
619
  const HappyOrgRuntimeStateSchema = z.object({
617
- status: z.enum(["active", "terminated"]),
620
+ status: z.enum([
621
+ "active",
622
+ "waiting_review",
623
+ "waiting_decision",
624
+ "waiting_close",
625
+ "terminated"
626
+ ]),
618
627
  reason: z.string().optional().nullable(),
619
628
  terminatedAt: z.number().int().nonnegative().optional(),
620
629
  reopenedAt: z.number().int().nonnegative().optional()
@@ -2809,6 +2818,28 @@ class ApiUserObserverClient extends EventEmitter {
2809
2818
  offUpdate(callback) {
2810
2819
  this.off("update", callback);
2811
2820
  }
2821
+ syncSessionRuntimeIndex(sessionId, sessionIndex, opts = {}) {
2822
+ if (!this.socket.connected) {
2823
+ logger.debug("[API USER OBSERVER] Skipping session runtime index sync because socket is disconnected", {
2824
+ sessionId
2825
+ });
2826
+ return false;
2827
+ }
2828
+ const now = Date.now();
2829
+ this.socket.emit("session-alive", {
2830
+ sid: sessionId,
2831
+ time: now,
2832
+ thinking: false,
2833
+ sessionIndex
2834
+ });
2835
+ if (opts.markInactive) {
2836
+ this.socket.emit("session-end", {
2837
+ sid: sessionId,
2838
+ time: now
2839
+ });
2840
+ }
2841
+ return true;
2842
+ }
2812
2843
  async close() {
2813
2844
  this.clearReconnectAfterServerDisconnectTimer();
2814
2845
  this.protocolV3Descriptor = null;
@@ -3613,4 +3644,4 @@ var api = /*#__PURE__*/Object.freeze({
3613
3644
  ApiClient: ApiClient
3614
3645
  });
3615
3646
 
3616
- export { ApiClient as A, HAPPY_ORG_TURN_REPORT_TAG as H, SigningBootstrapRequiredError as S, ApiSessionClient as a, connectionState as b, configuration as c, HAPPY_ORG_REPEAT_THRESHOLD as d, encodeBase64 as e, backoff as f, delay as g, AsyncLock as h, isAuthenticationRequiredError as i, buildAuthenticatedHeaders as j, SIGNING_BOOTSTRAP_REQUIRED_MESSAGE as k, logger as l, encodeBase64Url as m, buildClientHeaders as n, decodeBase64 as o, packageJson as p, HAPPY_CLOUD_DAEMON_PORT as q, HeadTailPreviewBuffer as r, startOfflineReconnection as s, getLatestDaemonLog as t, api as u };
3647
+ export { ApiClient as A, HAPPY_ORG_REPEAT_THRESHOLD as H, SigningBootstrapRequiredError as S, ApiSessionClient as a, HAPPY_ORG_TURN_REPORT_TAG as b, configuration as c, HAPPY_ORG_SUMMARY_MAX_LENGTH as d, encodeBase64 as e, connectionState as f, backoff as g, delay as h, isAuthenticationRequiredError as i, AsyncLock as j, buildAuthenticatedHeaders as k, logger as l, SIGNING_BOOTSTRAP_REQUIRED_MESSAGE as m, encodeBase64Url as n, buildClientHeaders as o, packageJson as p, decodeBase64 as q, HAPPY_CLOUD_DAEMON_PORT as r, startOfflineReconnection as s, HeadTailPreviewBuffer as t, getLatestDaemonLog as u, api as v };
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-CgVjDJpt.cjs');
3
+ var index = require('./index-BybqdOf2.cjs');
4
4
  require('chalk');
5
- require('./api-MGlKcEf3.cjs');
5
+ require('./api-C4bF6GEA.cjs');
6
6
  require('axios');
7
7
  require('fs');
8
8
  require('node:fs');
@@ -18,7 +18,7 @@ require('crypto');
18
18
  require('path');
19
19
  require('node:child_process');
20
20
  require('expo-server-sdk');
21
- require('./persistence-DLFUNI9q.cjs');
21
+ require('./persistence-CdqBfAwo.cjs');
22
22
  require('node:fs/promises');
23
23
  require('os');
24
24
  require('tmp');
@@ -1,6 +1,6 @@
1
- import { c as createDefaultRuntimeShell } from './index-CHXCgpwi.mjs';
1
+ import { c as createDefaultRuntimeShell } from './index-CEJmASSW.mjs';
2
2
  import 'chalk';
3
- import './api-DJe9WP9M.mjs';
3
+ import './api-DX7Vg4Hz.mjs';
4
4
  import 'axios';
5
5
  import 'fs';
6
6
  import 'node:fs';
@@ -16,7 +16,7 @@ import 'crypto';
16
16
  import 'path';
17
17
  import 'node:child_process';
18
18
  import 'expo-server-sdk';
19
- import './persistence-CkP90vEt.mjs';
19
+ import './persistence-xypxp7ei.mjs';
20
20
  import 'node:fs/promises';
21
21
  import 'os';
22
22
  import 'tmp';
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var chalk = require('chalk');
4
- var api = require('./api-MGlKcEf3.cjs');
5
- var persistence = require('./persistence-DLFUNI9q.cjs');
4
+ var api = require('./api-C4bF6GEA.cjs');
5
+ var persistence = require('./persistence-CdqBfAwo.cjs');
6
6
  var z = require('zod');
7
7
  var fs$2 = require('fs/promises');
8
8
  var os$1 = require('os');
@@ -72,7 +72,7 @@ async function openBrowser(url) {
72
72
  }
73
73
  }
74
74
 
75
- 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-CgVjDJpt.cjs', document.baseURI).href)));
75
+ 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-BybqdOf2.cjs', document.baseURI).href)));
76
76
  const QRCode = require$1("qrcode-terminal/vendor/QRCode");
77
77
  const QRErrorCorrectLevel = require$1("qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel");
78
78
  const pendingTempFiles = /* @__PURE__ */ new Set();
@@ -695,7 +695,7 @@ function setupCleanupHandlers() {
695
695
  });
696
696
  }
697
697
 
698
- const __dirname$2 = path$1.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CgVjDJpt.cjs', document.baseURI).href))));
698
+ const __dirname$2 = path$1.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-BybqdOf2.cjs', document.baseURI).href))));
699
699
  function projectPath() {
700
700
  const path = path$1.resolve(__dirname$2, "..");
701
701
  return path;
@@ -2541,16 +2541,36 @@ function createTrackedSessionFromRemoteIndexEntry(entry) {
2541
2541
  pid: entry.sessionIndex?.hostPid ?? 0
2542
2542
  };
2543
2543
  }
2544
+ async function archiveStaleRemoteSession(userScopedObserver, session) {
2545
+ if (!userScopedObserver || !session.sessionIndex) {
2546
+ api.logger.debug(
2547
+ `[REMOTE SESSION INDEX] Stale remote session ${session.id} cannot be archived because user-scoped observer is unavailable`
2548
+ );
2549
+ return false;
2550
+ }
2551
+ const archived = userScopedObserver.syncSessionRuntimeIndex(session.id, {
2552
+ ...session.sessionIndex,
2553
+ lifecycleState: "archived"
2554
+ }, {
2555
+ markInactive: true
2556
+ });
2557
+ if (archived) {
2558
+ api.logger.debug(`[REMOTE SESSION INDEX] Archived stale remote session ${session.id}`);
2559
+ }
2560
+ return archived;
2561
+ }
2544
2562
  async function recoverTrackedSessionsFromRemoteIndex({
2545
2563
  api: api$1,
2546
2564
  machineId,
2547
2565
  trackedSessionPids,
2548
2566
  trackSession,
2567
+ userScopedObserver,
2549
2568
  lookupHappyProcessByPid = findHappyProcessByPid
2550
2569
  }) {
2551
2570
  const sessions = await api$1.listSessionsIndex();
2552
2571
  const alreadyTracked = new Set(trackedSessionPids);
2553
2572
  let recoveredCount = 0;
2573
+ let archivedStaleCount = 0;
2554
2574
  let skippedStaleCount = 0;
2555
2575
  for (const session of sessions) {
2556
2576
  const sessionIndex = session.sessionIndex;
@@ -2579,7 +2599,12 @@ async function recoverTrackedSessionsFromRemoteIndex({
2579
2599
  }
2580
2600
  const sessionPidIsAlive = lookupResult !== null && !NON_SESSION_PROCESS_TYPES$1.has(lookupResult.type);
2581
2601
  if (!sessionPidIsAlive) {
2582
- skippedStaleCount++;
2602
+ const archived = await archiveStaleRemoteSession(userScopedObserver, session);
2603
+ if (archived) {
2604
+ archivedStaleCount++;
2605
+ } else {
2606
+ skippedStaleCount++;
2607
+ }
2583
2608
  continue;
2584
2609
  }
2585
2610
  trackSession(pid, createTrackedSessionFromRemoteIndexEntry(session));
@@ -2589,6 +2614,7 @@ async function recoverTrackedSessionsFromRemoteIndex({
2589
2614
  }
2590
2615
  return {
2591
2616
  recoveredCount,
2617
+ archivedStaleCount,
2592
2618
  skippedStaleCount
2593
2619
  };
2594
2620
  }
@@ -3315,11 +3341,12 @@ async function startDaemon() {
3315
3341
  trackedSessionPids: pidToTrackedSession.keys(),
3316
3342
  trackSession: (pid, trackedSession) => {
3317
3343
  pidToTrackedSession.set(pid, trackedSession);
3318
- }
3344
+ },
3345
+ userScopedObserver
3319
3346
  });
3320
- if (recoveryResult.recoveredCount > 0 || recoveryResult.skippedStaleCount > 0) {
3347
+ if (recoveryResult.recoveredCount > 0 || recoveryResult.archivedStaleCount > 0 || recoveryResult.skippedStaleCount > 0) {
3321
3348
  api.logger.debug(
3322
- `[DAEMON RUN] Remote session index recovery ${label} completed: recovered=${recoveryResult.recoveredCount}, skippedStale=${recoveryResult.skippedStaleCount}`
3349
+ `[DAEMON RUN] Remote session index recovery ${label} completed: recovered=${recoveryResult.recoveredCount}, archivedStale=${recoveryResult.archivedStaleCount}, skippedStale=${recoveryResult.skippedStaleCount}`
3323
3350
  );
3324
3351
  }
3325
3352
  };
@@ -5131,6 +5158,21 @@ class GeminiTransport {
5131
5158
  }
5132
5159
  const geminiTransport = new GeminiTransport();
5133
5160
 
5161
+ const DEFAULT_CODEX_EXECUTE_TIMEOUT_MS = 15 * 6e4;
5162
+ function readPositiveIntegerEnv$1(name) {
5163
+ const raw = typeof process.env[name] === "string" ? process.env[name].trim() : "";
5164
+ if (!raw) {
5165
+ return null;
5166
+ }
5167
+ const value = Number(raw);
5168
+ if (!Number.isFinite(value) || !Number.isInteger(value) || value <= 0) {
5169
+ return null;
5170
+ }
5171
+ return value;
5172
+ }
5173
+ function resolveCodexExecuteTimeoutMs() {
5174
+ return readPositiveIntegerEnv$1("HAPPY_CODEX_EXECUTE_TIMEOUT_MS") ?? readPositiveIntegerEnv$1("HAPPIER_CODEX_EXECUTE_TIMEOUT_MS") ?? DEFAULT_CODEX_EXECUTE_TIMEOUT_MS;
5175
+ }
5134
5176
  class CodexTransport extends DefaultTransport {
5135
5177
  constructor() {
5136
5178
  super("codex");
@@ -5141,6 +5183,12 @@ class CodexTransport extends DefaultTransport {
5141
5183
  getIdleTimeout() {
5142
5184
  return 800;
5143
5185
  }
5186
+ getToolCallTimeout(toolCallId, toolKind) {
5187
+ if (toolKind === "execute") {
5188
+ return resolveCodexExecuteTimeoutMs();
5189
+ }
5190
+ return super.getToolCallTimeout(toolCallId, toolKind);
5191
+ }
5144
5192
  }
5145
5193
  new CodexTransport();
5146
5194
 
@@ -7745,7 +7793,7 @@ class AbortError extends Error {
7745
7793
  }
7746
7794
  }
7747
7795
 
7748
- 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-CgVjDJpt.cjs', document.baseURI).href)));
7796
+ 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-BybqdOf2.cjs', document.baseURI).href)));
7749
7797
  const __dirname$1 = path.join(__filename$1, "..");
7750
7798
  function getGlobalClaudeVersion() {
7751
7799
  try {
@@ -8996,11 +9044,11 @@ var launch = /*#__PURE__*/Object.freeze({
8996
9044
 
8997
9045
  const unifiedProviderExecutors = {
8998
9046
  claude: async (opts) => {
8999
- const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-BGSgcyUp.cjs'); });
9047
+ const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-CT3jCZjH.cjs'); });
9000
9048
  await runClaude(opts.credentials, opts.claudeOptions ?? {});
9001
9049
  },
9002
9050
  codex: async (opts) => {
9003
- const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-earICaxw.cjs'); });
9051
+ const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-DodH9jhh.cjs'); });
9004
9052
  await runCodex({
9005
9053
  credentials: opts.credentials,
9006
9054
  startedBy: opts.startedBy,
@@ -9009,7 +9057,7 @@ const unifiedProviderExecutors = {
9009
9057
  });
9010
9058
  },
9011
9059
  gemini: async (opts) => {
9012
- const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-D5RAIaR0.cjs'); });
9060
+ const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-CeHCZ1l4.cjs'); });
9013
9061
  await runGemini({
9014
9062
  credentials: opts.credentials,
9015
9063
  startedBy: opts.startedBy
@@ -9085,7 +9133,7 @@ function shouldRunMainClaudeFlow(opts) {
9085
9133
  return;
9086
9134
  } else if (subcommand === "runtime") {
9087
9135
  if (args[1] === "providers") {
9088
- const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-DAlFmWmr.cjs'); });
9136
+ const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-CF6Wi_v2.cjs'); });
9089
9137
  console.log(renderRuntimeProviders());
9090
9138
  return;
9091
9139
  }
@@ -9263,8 +9311,8 @@ function shouldRunMainClaudeFlow(opts) {
9263
9311
  const projectId = args[3];
9264
9312
  try {
9265
9313
  const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
9266
- const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./persistence-DLFUNI9q.cjs'); });
9267
- const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-MGlKcEf3.cjs'); }).then(function (n) { return n.api; });
9314
+ const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./persistence-CdqBfAwo.cjs'); });
9315
+ const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-C4bF6GEA.cjs'); }).then(function (n) { return n.api; });
9268
9316
  let userEmail = void 0;
9269
9317
  try {
9270
9318
  const credentials = await readCredentials2();
@@ -1,6 +1,6 @@
1
1
  import{createRequire as _pkgrollCR}from"node:module";const require=_pkgrollCR(import.meta.url);import chalk from 'chalk';
2
- import { l as logger, e as encodeBase64, c as configuration, j as buildAuthenticatedHeaders, S as SigningBootstrapRequiredError, k as SIGNING_BOOTSTRAP_REQUIRED_MESSAGE, m as encodeBase64Url, g as delay, n as buildClientHeaders, o as decodeBase64, q as HAPPY_CLOUD_DAEMON_PORT, p as packageJson, A as ApiClient, r as HeadTailPreviewBuffer, t as getLatestDaemonLog } from './api-DJe9WP9M.mjs';
3
- import { writeCredentialsLegacy, writeCredentialsDataKey, readCredentials, readSettings, updateSettings, readDaemonState, clearDaemonState, acquireDaemonLock, writeDaemonState, releaseDaemonLock, validateProfileForAgent, getProfileEnvironmentVariables, clearCredentials, clearMachineId } from './persistence-CkP90vEt.mjs';
2
+ import { l as logger, e as encodeBase64, c as configuration, k as buildAuthenticatedHeaders, S as SigningBootstrapRequiredError, m as SIGNING_BOOTSTRAP_REQUIRED_MESSAGE, n as encodeBase64Url, h as delay, o as buildClientHeaders, q as decodeBase64, r as HAPPY_CLOUD_DAEMON_PORT, p as packageJson, A as ApiClient, t as HeadTailPreviewBuffer, u as getLatestDaemonLog } from './api-DX7Vg4Hz.mjs';
3
+ import { writeCredentialsLegacy, writeCredentialsDataKey, readCredentials, readSettings, updateSettings, readDaemonState, clearDaemonState, acquireDaemonLock, writeDaemonState, releaseDaemonLock, validateProfileForAgent, getProfileEnvironmentVariables, clearCredentials, clearMachineId } from './persistence-xypxp7ei.mjs';
4
4
  import { z } from 'zod';
5
5
  import fs, { writeFile as writeFile$1, rename, unlink as unlink$1 } from 'fs/promises';
6
6
  import os, { homedir } from 'os';
@@ -2519,16 +2519,36 @@ function createTrackedSessionFromRemoteIndexEntry(entry) {
2519
2519
  pid: entry.sessionIndex?.hostPid ?? 0
2520
2520
  };
2521
2521
  }
2522
+ async function archiveStaleRemoteSession(userScopedObserver, session) {
2523
+ if (!userScopedObserver || !session.sessionIndex) {
2524
+ logger.debug(
2525
+ `[REMOTE SESSION INDEX] Stale remote session ${session.id} cannot be archived because user-scoped observer is unavailable`
2526
+ );
2527
+ return false;
2528
+ }
2529
+ const archived = userScopedObserver.syncSessionRuntimeIndex(session.id, {
2530
+ ...session.sessionIndex,
2531
+ lifecycleState: "archived"
2532
+ }, {
2533
+ markInactive: true
2534
+ });
2535
+ if (archived) {
2536
+ logger.debug(`[REMOTE SESSION INDEX] Archived stale remote session ${session.id}`);
2537
+ }
2538
+ return archived;
2539
+ }
2522
2540
  async function recoverTrackedSessionsFromRemoteIndex({
2523
2541
  api,
2524
2542
  machineId,
2525
2543
  trackedSessionPids,
2526
2544
  trackSession,
2545
+ userScopedObserver,
2527
2546
  lookupHappyProcessByPid = findHappyProcessByPid
2528
2547
  }) {
2529
2548
  const sessions = await api.listSessionsIndex();
2530
2549
  const alreadyTracked = new Set(trackedSessionPids);
2531
2550
  let recoveredCount = 0;
2551
+ let archivedStaleCount = 0;
2532
2552
  let skippedStaleCount = 0;
2533
2553
  for (const session of sessions) {
2534
2554
  const sessionIndex = session.sessionIndex;
@@ -2557,7 +2577,12 @@ async function recoverTrackedSessionsFromRemoteIndex({
2557
2577
  }
2558
2578
  const sessionPidIsAlive = lookupResult !== null && !NON_SESSION_PROCESS_TYPES$1.has(lookupResult.type);
2559
2579
  if (!sessionPidIsAlive) {
2560
- skippedStaleCount++;
2580
+ const archived = await archiveStaleRemoteSession(userScopedObserver, session);
2581
+ if (archived) {
2582
+ archivedStaleCount++;
2583
+ } else {
2584
+ skippedStaleCount++;
2585
+ }
2561
2586
  continue;
2562
2587
  }
2563
2588
  trackSession(pid, createTrackedSessionFromRemoteIndexEntry(session));
@@ -2567,6 +2592,7 @@ async function recoverTrackedSessionsFromRemoteIndex({
2567
2592
  }
2568
2593
  return {
2569
2594
  recoveredCount,
2595
+ archivedStaleCount,
2570
2596
  skippedStaleCount
2571
2597
  };
2572
2598
  }
@@ -3293,11 +3319,12 @@ async function startDaemon() {
3293
3319
  trackedSessionPids: pidToTrackedSession.keys(),
3294
3320
  trackSession: (pid, trackedSession) => {
3295
3321
  pidToTrackedSession.set(pid, trackedSession);
3296
- }
3322
+ },
3323
+ userScopedObserver
3297
3324
  });
3298
- if (recoveryResult.recoveredCount > 0 || recoveryResult.skippedStaleCount > 0) {
3325
+ if (recoveryResult.recoveredCount > 0 || recoveryResult.archivedStaleCount > 0 || recoveryResult.skippedStaleCount > 0) {
3299
3326
  logger.debug(
3300
- `[DAEMON RUN] Remote session index recovery ${label} completed: recovered=${recoveryResult.recoveredCount}, skippedStale=${recoveryResult.skippedStaleCount}`
3327
+ `[DAEMON RUN] Remote session index recovery ${label} completed: recovered=${recoveryResult.recoveredCount}, archivedStale=${recoveryResult.archivedStaleCount}, skippedStale=${recoveryResult.skippedStaleCount}`
3301
3328
  );
3302
3329
  }
3303
3330
  };
@@ -5109,6 +5136,21 @@ class GeminiTransport {
5109
5136
  }
5110
5137
  const geminiTransport = new GeminiTransport();
5111
5138
 
5139
+ const DEFAULT_CODEX_EXECUTE_TIMEOUT_MS = 15 * 6e4;
5140
+ function readPositiveIntegerEnv$1(name) {
5141
+ const raw = typeof process.env[name] === "string" ? process.env[name].trim() : "";
5142
+ if (!raw) {
5143
+ return null;
5144
+ }
5145
+ const value = Number(raw);
5146
+ if (!Number.isFinite(value) || !Number.isInteger(value) || value <= 0) {
5147
+ return null;
5148
+ }
5149
+ return value;
5150
+ }
5151
+ function resolveCodexExecuteTimeoutMs() {
5152
+ return readPositiveIntegerEnv$1("HAPPY_CODEX_EXECUTE_TIMEOUT_MS") ?? readPositiveIntegerEnv$1("HAPPIER_CODEX_EXECUTE_TIMEOUT_MS") ?? DEFAULT_CODEX_EXECUTE_TIMEOUT_MS;
5153
+ }
5112
5154
  class CodexTransport extends DefaultTransport {
5113
5155
  constructor() {
5114
5156
  super("codex");
@@ -5119,6 +5161,12 @@ class CodexTransport extends DefaultTransport {
5119
5161
  getIdleTimeout() {
5120
5162
  return 800;
5121
5163
  }
5164
+ getToolCallTimeout(toolCallId, toolKind) {
5165
+ if (toolKind === "execute") {
5166
+ return resolveCodexExecuteTimeoutMs();
5167
+ }
5168
+ return super.getToolCallTimeout(toolCallId, toolKind);
5169
+ }
5122
5170
  }
5123
5171
  new CodexTransport();
5124
5172
 
@@ -8974,11 +9022,11 @@ var launch = /*#__PURE__*/Object.freeze({
8974
9022
 
8975
9023
  const unifiedProviderExecutors = {
8976
9024
  claude: async (opts) => {
8977
- const { runClaude } = await import('./runClaude-DAQAEmHe.mjs');
9025
+ const { runClaude } = await import('./runClaude-B-ex_tr3.mjs');
8978
9026
  await runClaude(opts.credentials, opts.claudeOptions ?? {});
8979
9027
  },
8980
9028
  codex: async (opts) => {
8981
- const { runCodex } = await import('./runCodex-B2UpSn82.mjs');
9029
+ const { runCodex } = await import('./runCodex-DhbvUtJC.mjs');
8982
9030
  await runCodex({
8983
9031
  credentials: opts.credentials,
8984
9032
  startedBy: opts.startedBy,
@@ -8987,7 +9035,7 @@ const unifiedProviderExecutors = {
8987
9035
  });
8988
9036
  },
8989
9037
  gemini: async (opts) => {
8990
- const { runGemini } = await import('./runGemini-BBUmH1Qh.mjs');
9038
+ const { runGemini } = await import('./runGemini-BsFR5Pd3.mjs');
8991
9039
  await runGemini({
8992
9040
  credentials: opts.credentials,
8993
9041
  startedBy: opts.startedBy
@@ -9063,7 +9111,7 @@ function shouldRunMainClaudeFlow(opts) {
9063
9111
  return;
9064
9112
  } else if (subcommand === "runtime") {
9065
9113
  if (args[1] === "providers") {
9066
- const { renderRuntimeProviders } = await import('./command-CfyFnMv2.mjs');
9114
+ const { renderRuntimeProviders } = await import('./command-DicPZ-Up.mjs');
9067
9115
  console.log(renderRuntimeProviders());
9068
9116
  return;
9069
9117
  }
@@ -9241,8 +9289,8 @@ function shouldRunMainClaudeFlow(opts) {
9241
9289
  const projectId = args[3];
9242
9290
  try {
9243
9291
  const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
9244
- const { readCredentials: readCredentials2 } = await import('./persistence-CkP90vEt.mjs');
9245
- const { ApiClient: ApiClient2 } = await import('./api-DJe9WP9M.mjs').then(function (n) { return n.u; });
9292
+ const { readCredentials: readCredentials2 } = await import('./persistence-xypxp7ei.mjs');
9293
+ const { ApiClient: ApiClient2 } = await import('./api-DX7Vg4Hz.mjs').then(function (n) { return n.v; });
9246
9294
  let userEmail = void 0;
9247
9295
  try {
9248
9296
  const credentials = await readCredentials2();
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  require('chalk');
4
- require('./api-MGlKcEf3.cjs');
5
- require('./persistence-DLFUNI9q.cjs');
4
+ require('./api-C4bF6GEA.cjs');
5
+ require('./persistence-CdqBfAwo.cjs');
6
6
  require('zod');
7
- require('./index-CgVjDJpt.cjs');
7
+ require('./index-BybqdOf2.cjs');
8
8
  require('node:child_process');
9
9
  require('node:fs');
10
10
  require('cross-spawn');
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import 'chalk';
2
- import './api-DJe9WP9M.mjs';
3
- import './persistence-CkP90vEt.mjs';
2
+ import './api-DX7Vg4Hz.mjs';
3
+ import './persistence-xypxp7ei.mjs';
4
4
  import 'zod';
5
- import './index-CHXCgpwi.mjs';
5
+ import './index-CEJmASSW.mjs';
6
6
  import 'node:child_process';
7
7
  import 'node:fs';
8
8
  import 'cross-spawn';
package/dist/lib.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var api = require('./api-MGlKcEf3.cjs');
3
+ var api = require('./api-C4bF6GEA.cjs');
4
4
  var types = require('./types-DVk3crez.cjs');
5
5
  require('axios');
6
6
  require('chalk');