happy-imou-cloud 2.0.22 → 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 (32) hide show
  1. package/bin/happy-cloud.mjs +1 -1
  2. package/dist/{BaseReasoningProcessor-CJVv1aNR.cjs → BaseReasoningProcessor-BzbDRBqp.cjs} +3 -3
  3. package/dist/{BaseReasoningProcessor-mIqqngd3.mjs → BaseReasoningProcessor-DH3BCCTf.mjs} +3 -3
  4. package/dist/{ProviderSelectionHandler-BjLyIfSR.mjs → ProviderSelectionHandler-CbkbtIRC.mjs} +2 -2
  5. package/dist/{ProviderSelectionHandler-e4zL4Y5_.cjs → ProviderSelectionHandler-meVvz9NZ.cjs} +2 -2
  6. package/dist/{api-DP-RQUao.cjs → api-C4bF6GEA.cjs} +24 -2
  7. package/dist/{api-DrijKeDb.mjs → api-DX7Vg4Hz.mjs} +24 -2
  8. package/dist/{command-BZphfJrt.cjs → command-CF6Wi_v2.cjs} +3 -3
  9. package/dist/{command--vV6BSsL.mjs → command-DicPZ-Up.mjs} +3 -3
  10. package/dist/{index-CqCEZDFi.cjs → index-BybqdOf2.cjs} +63 -15
  11. package/dist/{index-BIki80pQ.mjs → index-CEJmASSW.mjs} +60 -12
  12. package/dist/index.cjs +3 -3
  13. package/dist/index.mjs +3 -3
  14. package/dist/lib.cjs +1 -1
  15. package/dist/lib.d.cts +95 -92
  16. package/dist/lib.d.mts +95 -92
  17. package/dist/lib.mjs +1 -1
  18. package/dist/{persistence-yVTbf_Ng.cjs → persistence-CdqBfAwo.cjs} +1 -1
  19. package/dist/{persistence-C3NBdZdz.mjs → persistence-xypxp7ei.mjs} +1 -1
  20. package/dist/{registerKillSessionHandler-QmBN446A.cjs → registerKillSessionHandler-BK3fZIch.cjs} +14 -11
  21. package/dist/{registerKillSessionHandler-CHEj7UjN.mjs → registerKillSessionHandler-BNN-_qNu.mjs} +14 -11
  22. package/dist/{runClaude-D0DD_Ya5.mjs → runClaude-B-ex_tr3.mjs} +8 -6
  23. package/dist/{runClaude-BuI6OOEv.cjs → runClaude-CT3jCZjH.cjs} +8 -6
  24. package/dist/{runCodex-BzZ0jODI.mjs → runCodex-DhbvUtJC.mjs} +9 -7
  25. package/dist/{runCodex-1jTTmCvq.cjs → runCodex-DodH9jhh.cjs} +9 -7
  26. package/dist/{runGemini-Bx2SYAyG.mjs → runGemini-BsFR5Pd3.mjs} +8 -6
  27. package/dist/{runGemini-1gJRE8oT.cjs → runGemini-CeHCZ1l4.cjs} +8 -6
  28. package/package.json +1 -1
  29. package/scripts/build.mjs +66 -66
  30. package/scripts/devtools/README.md +9 -9
  31. package/scripts/e2e/fake-codex-acp-agent.mjs +139 -139
  32. package/scripts/e2e/local-server-session-roundtrip.mjs +1063 -1063
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import { execFileSync } from 'child_process';
4
4
  import { fileURLToPath } from 'url';
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-CqCEZDFi.cjs');
4
- var api = require('./api-DP-RQUao.cjs');
5
- var registerKillSessionHandler = require('./registerKillSessionHandler-QmBN446A.cjs');
3
+ var index = require('./index-BybqdOf2.cjs');
4
+ var api = require('./api-C4bF6GEA.cjs');
5
+ var registerKillSessionHandler = require('./registerKillSessionHandler-BK3fZIch.cjs');
6
6
  var node_events = require('node:events');
7
7
  var node_crypto = require('node:crypto');
8
8
 
@@ -1,6 +1,6 @@
1
- import { p as publishSessionRegistration } from './index-BIki80pQ.mjs';
2
- import { s as startOfflineReconnection, c as configuration, i as isAuthenticationRequiredError, l as logger } from './api-DrijKeDb.mjs';
3
- import { c as createSessionMetadata } from './registerKillSessionHandler-CHEj7UjN.mjs';
1
+ import { p as publishSessionRegistration } from './index-CEJmASSW.mjs';
2
+ import { s as startOfflineReconnection, c as configuration, i as isAuthenticationRequiredError, l as logger } from './api-DX7Vg4Hz.mjs';
3
+ import { c as createSessionMetadata } from './registerKillSessionHandler-BNN-_qNu.mjs';
4
4
  import { EventEmitter } from 'node:events';
5
5
  import { randomUUID } from 'node:crypto';
6
6
 
@@ -1,5 +1,5 @@
1
- import { H as HAPPY_ORG_REPEAT_THRESHOLD, b as HAPPY_ORG_TURN_REPORT_TAG, d as HAPPY_ORG_SUMMARY_MAX_LENGTH, l as logger } from './api-DrijKeDb.mjs';
2
- import { g as getPendingInteractionTimeoutMs, I as INTERACTION_SUPERSEDED_ERROR, a as INTERACTION_TIMED_OUT_ERROR } from './registerKillSessionHandler-CHEj7UjN.mjs';
1
+ import { H as HAPPY_ORG_REPEAT_THRESHOLD, b as HAPPY_ORG_TURN_REPORT_TAG, d as HAPPY_ORG_SUMMARY_MAX_LENGTH, l as logger } from './api-DX7Vg4Hz.mjs';
2
+ import { g as getPendingInteractionTimeoutMs, I as INTERACTION_SUPERSEDED_ERROR, a as INTERACTION_TIMED_OUT_ERROR } from './registerKillSessionHandler-BNN-_qNu.mjs';
3
3
 
4
4
  async function runModeLoop(opts) {
5
5
  let currentMode = opts.startingMode;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var api = require('./api-DP-RQUao.cjs');
4
- var registerKillSessionHandler = require('./registerKillSessionHandler-QmBN446A.cjs');
3
+ var api = require('./api-C4bF6GEA.cjs');
4
+ var registerKillSessionHandler = require('./registerKillSessionHandler-BK3fZIch.cjs');
5
5
 
6
6
  async function runModeLoop(opts) {
7
7
  let currentMode = opts.startingMode;
@@ -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.22";
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-yVTbf_Ng.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;
@@ -2820,6 +2820,28 @@ class ApiUserObserverClient extends node_events.EventEmitter {
2820
2820
  offUpdate(callback) {
2821
2821
  this.off("update", callback);
2822
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
+ }
2823
2845
  async close() {
2824
2846
  this.clearReconnectAfterServerDisconnectTimer();
2825
2847
  this.protocolV3Descriptor = null;
@@ -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.22";
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-C3NBdZdz.mjs');
433
+ const { readDaemonState } = await import('./persistence-xypxp7ei.mjs');
434
434
  const state = await readDaemonState();
435
435
  if (!state) {
436
436
  return logs;
@@ -2818,6 +2818,28 @@ class ApiUserObserverClient extends EventEmitter {
2818
2818
  offUpdate(callback) {
2819
2819
  this.off("update", callback);
2820
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
+ }
2821
2843
  async close() {
2822
2844
  this.clearReconnectAfterServerDisconnectTimer();
2823
2845
  this.protocolV3Descriptor = null;
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-CqCEZDFi.cjs');
3
+ var index = require('./index-BybqdOf2.cjs');
4
4
  require('chalk');
5
- require('./api-DP-RQUao.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-yVTbf_Ng.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-BIki80pQ.mjs';
1
+ import { c as createDefaultRuntimeShell } from './index-CEJmASSW.mjs';
2
2
  import 'chalk';
3
- import './api-DrijKeDb.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-C3NBdZdz.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-DP-RQUao.cjs');
5
- var persistence = require('./persistence-yVTbf_Ng.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-CqCEZDFi.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-CqCEZDFi.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-CqCEZDFi.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-BuI6OOEv.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-1jTTmCvq.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-1gJRE8oT.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-BZphfJrt.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-yVTbf_Ng.cjs'); });
9267
- const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-DP-RQUao.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, 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-DrijKeDb.mjs';
3
- import { writeCredentialsLegacy, writeCredentialsDataKey, readCredentials, readSettings, updateSettings, readDaemonState, clearDaemonState, acquireDaemonLock, writeDaemonState, releaseDaemonLock, validateProfileForAgent, getProfileEnvironmentVariables, clearCredentials, clearMachineId } from './persistence-C3NBdZdz.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-D0DD_Ya5.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-BzZ0jODI.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-Bx2SYAyG.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--vV6BSsL.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-C3NBdZdz.mjs');
9245
- const { ApiClient: ApiClient2 } = await import('./api-DrijKeDb.mjs').then(function (n) { return n.v; });
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-DP-RQUao.cjs');
5
- require('./persistence-yVTbf_Ng.cjs');
4
+ require('./api-C4bF6GEA.cjs');
5
+ require('./persistence-CdqBfAwo.cjs');
6
6
  require('zod');
7
- require('./index-CqCEZDFi.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-DrijKeDb.mjs';
3
- import './persistence-C3NBdZdz.mjs';
2
+ import './api-DX7Vg4Hz.mjs';
3
+ import './persistence-xypxp7ei.mjs';
4
4
  import 'zod';
5
- import './index-BIki80pQ.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-DP-RQUao.cjs');
3
+ var api = require('./api-C4bF6GEA.cjs');
4
4
  var types = require('./types-DVk3crez.cjs');
5
5
  require('axios');
6
6
  require('chalk');