happy-imou-cloud 2.0.4 → 2.0.5

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 (23) hide show
  1. package/dist/{BaseReasoningProcessor-DEEfNi5Y.cjs → BaseReasoningProcessor-DPVZIJ4n.cjs} +2 -2
  2. package/dist/{BaseReasoningProcessor-Di1yEMMv.mjs → BaseReasoningProcessor-bFVTvf3Q.mjs} +2 -2
  3. package/dist/{api-CyJG1mr6.cjs → api-DaqnNHfl.cjs} +4 -2
  4. package/dist/{api-CIHTNilH.mjs → api-DoHt-HyL.mjs} +4 -2
  5. package/dist/{command-CPlJKXDn.cjs → command-D9-hmqVq.cjs} +3 -3
  6. package/dist/{command-BERqmFB0.mjs → command-Dl9SrMnv.mjs} +3 -3
  7. package/dist/{index-vNYxNqVZ.mjs → index-C5wR2qKT.mjs} +141 -47
  8. package/dist/{index-1zlH6s7a.cjs → index-Dc92gnxM.cjs} +143 -49
  9. package/dist/index.cjs +3 -3
  10. package/dist/index.mjs +3 -3
  11. package/dist/lib.cjs +1 -1
  12. package/dist/lib.mjs +1 -1
  13. package/dist/{persistence-BeFVx6kI.cjs → persistence-D6Y0604_.cjs} +1 -1
  14. package/dist/{persistence-sLEqV8vk.mjs → persistence-QqeBvUxX.mjs} +1 -1
  15. package/dist/{registerKillSessionHandler-CCxqGFjZ.cjs → registerKillSessionHandler-C6yXr8ky.cjs} +2 -2
  16. package/dist/{registerKillSessionHandler-uVHqIC4h.mjs → registerKillSessionHandler-CC9zGBPE.mjs} +2 -2
  17. package/dist/{runClaude-Dl9nIRIg.mjs → runClaude-CZ8gxaJL.mjs} +4 -4
  18. package/dist/{runClaude-Dz-PCSvb.cjs → runClaude-gHKFB1UG.cjs} +5 -5
  19. package/dist/{runCodex-BtZplK1R.cjs → runCodex-CdjzG1N7.cjs} +53 -17
  20. package/dist/{runCodex-DgKKw3IU.mjs → runCodex-DT7g4MPm.mjs} +53 -17
  21. package/dist/{runGemini-CM1v3I24.mjs → runGemini-CmY5386l.mjs} +51 -19
  22. package/dist/{runGemini-DUyH311Z.cjs → runGemini-DxjvRmOc.cjs} +51 -19
  23. package/package.json +2 -1
@@ -2,8 +2,8 @@
2
2
 
3
3
  var os = require('node:os');
4
4
  var node_path = require('node:path');
5
- var api = require('./api-CyJG1mr6.cjs');
6
- var index = require('./index-1zlH6s7a.cjs');
5
+ var api = require('./api-DaqnNHfl.cjs');
6
+ var index = require('./index-Dc92gnxM.cjs');
7
7
  var node_events = require('node:events');
8
8
  var node_crypto = require('node:crypto');
9
9
 
@@ -1,7 +1,7 @@
1
1
  import os from 'node:os';
2
2
  import { resolve } from 'node:path';
3
- import { c as configuration, p as packageJson, s as startOfflineReconnection, l as logger } from './api-CIHTNilH.mjs';
4
- import { p as projectPath } from './index-vNYxNqVZ.mjs';
3
+ import { c as configuration, p as packageJson, s as startOfflineReconnection, l as logger } from './api-DoHt-HyL.mjs';
4
+ import { p as projectPath } from './index-C5wR2qKT.mjs';
5
5
  import { EventEmitter } from 'node:events';
6
6
  import { randomUUID } from 'node:crypto';
7
7
 
@@ -19,7 +19,7 @@ var path = require('path');
19
19
  var expoServerSdk = require('expo-server-sdk');
20
20
 
21
21
  var name = "happy-imou-cloud";
22
- var version = "2.0.4";
22
+ var version = "2.0.5";
23
23
  var description = "hicloud - Imou 企业定制版。关键是 happy!移动端远程 AI 编程工具,支持 Claude Code、Codex 和 Gemini CLI";
24
24
  var author = "long.zhu";
25
25
  var license = "MIT";
@@ -118,6 +118,7 @@ var dependencies = {
118
118
  "expo-server-sdk": "^3.15.0",
119
119
  fastify: "^5.6.2",
120
120
  "fastify-type-provider-zod": "4.0.2",
121
+ "happy-protocol": "0.1.0",
121
122
  "http-proxy": "^1.18.1",
122
123
  "http-proxy-middleware": "^3.0.5",
123
124
  ink: "^6.5.1",
@@ -432,7 +433,7 @@ async function listDaemonLogFiles(limit = 50) {
432
433
  return { file, path: fullPath, modified: stats.mtime };
433
434
  }).sort((a, b) => b.modified.getTime() - a.modified.getTime());
434
435
  try {
435
- const { readDaemonState } = await Promise.resolve().then(function () { return require('./persistence-BeFVx6kI.cjs'); });
436
+ const { readDaemonState } = await Promise.resolve().then(function () { return require('./persistence-D6Y0604_.cjs'); });
436
437
  const state = await readDaemonState();
437
438
  if (!state) {
438
439
  return logs;
@@ -1755,6 +1756,7 @@ class ApiSessionClient extends node_events.EventEmitter {
1755
1756
  case "message":
1756
1757
  case "tool-call":
1757
1758
  case "tool-call-result":
1759
+ case "terminal-output":
1758
1760
  case "permission-request":
1759
1761
  case "task_started":
1760
1762
  case "task_complete":
@@ -17,7 +17,7 @@ import { resolve, join as join$1 } from 'path';
17
17
  import { Expo } from 'expo-server-sdk';
18
18
 
19
19
  var name = "happy-imou-cloud";
20
- var version = "2.0.4";
20
+ var version = "2.0.5";
21
21
  var description = "hicloud - Imou 企业定制版。关键是 happy!移动端远程 AI 编程工具,支持 Claude Code、Codex 和 Gemini CLI";
22
22
  var author = "long.zhu";
23
23
  var license = "MIT";
@@ -116,6 +116,7 @@ var dependencies = {
116
116
  "expo-server-sdk": "^3.15.0",
117
117
  fastify: "^5.6.2",
118
118
  "fastify-type-provider-zod": "4.0.2",
119
+ "happy-protocol": "0.1.0",
119
120
  "http-proxy": "^1.18.1",
120
121
  "http-proxy-middleware": "^3.0.5",
121
122
  ink: "^6.5.1",
@@ -430,7 +431,7 @@ async function listDaemonLogFiles(limit = 50) {
430
431
  return { file, path: fullPath, modified: stats.mtime };
431
432
  }).sort((a, b) => b.modified.getTime() - a.modified.getTime());
432
433
  try {
433
- const { readDaemonState } = await import('./persistence-sLEqV8vk.mjs');
434
+ const { readDaemonState } = await import('./persistence-QqeBvUxX.mjs');
434
435
  const state = await readDaemonState();
435
436
  if (!state) {
436
437
  return logs;
@@ -1753,6 +1754,7 @@ class ApiSessionClient extends EventEmitter {
1753
1754
  case "message":
1754
1755
  case "tool-call":
1755
1756
  case "tool-call-result":
1757
+ case "terminal-output":
1756
1758
  case "permission-request":
1757
1759
  case "task_started":
1758
1760
  case "task_complete":
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-1zlH6s7a.cjs');
3
+ var index = require('./index-Dc92gnxM.cjs');
4
4
  require('chalk');
5
- require('./api-CyJG1mr6.cjs');
5
+ require('./api-DaqnNHfl.cjs');
6
6
  require('axios');
7
7
  require('fs');
8
8
  require('node:fs');
@@ -19,7 +19,7 @@ require('fs/promises');
19
19
  require('crypto');
20
20
  require('path');
21
21
  require('expo-server-sdk');
22
- require('./persistence-BeFVx6kI.cjs');
22
+ require('./persistence-D6Y0604_.cjs');
23
23
  require('node:fs/promises');
24
24
  require('os');
25
25
  require('tmp');
@@ -1,6 +1,6 @@
1
- import { c as createDefaultRuntimeShell } from './index-vNYxNqVZ.mjs';
1
+ import { c as createDefaultRuntimeShell } from './index-C5wR2qKT.mjs';
2
2
  import 'chalk';
3
- import './api-CIHTNilH.mjs';
3
+ import './api-DoHt-HyL.mjs';
4
4
  import 'axios';
5
5
  import 'fs';
6
6
  import 'node:fs';
@@ -17,7 +17,7 @@ import 'fs/promises';
17
17
  import 'crypto';
18
18
  import 'path';
19
19
  import 'expo-server-sdk';
20
- import './persistence-sLEqV8vk.mjs';
20
+ import './persistence-QqeBvUxX.mjs';
21
21
  import 'node:fs/promises';
22
22
  import 'os';
23
23
  import 'tmp';
@@ -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, h as buildAuthenticatedHeaders, S as SigningBootstrapRequiredError, j as SIGNING_BOOTSTRAP_REQUIRED_MESSAGE, k as encodeBase64Url, f as delay, m as buildClientHeaders, n as decodeBase64, H as HAPPY_CLOUD_DAEMON_PORT, p as packageJson, A as ApiClient, o as getLatestDaemonLog } from './api-CIHTNilH.mjs';
3
- import { writeCredentialsLegacy, writeCredentialsDataKey, readCredentials, readSettings, updateSettings, readDaemonState, clearDaemonState, acquireDaemonLock, writeDaemonState, releaseDaemonLock, validateProfileForAgent, getProfileEnvironmentVariables, clearCredentials, clearMachineId } from './persistence-sLEqV8vk.mjs';
2
+ import { l as logger, e as encodeBase64, c as configuration, h as buildAuthenticatedHeaders, S as SigningBootstrapRequiredError, j as SIGNING_BOOTSTRAP_REQUIRED_MESSAGE, k as encodeBase64Url, f as delay, m as buildClientHeaders, n as decodeBase64, H as HAPPY_CLOUD_DAEMON_PORT, p as packageJson, A as ApiClient, o as getLatestDaemonLog } from './api-DoHt-HyL.mjs';
3
+ import { writeCredentialsLegacy, writeCredentialsDataKey, readCredentials, readSettings, updateSettings, readDaemonState, clearDaemonState, acquireDaemonLock, writeDaemonState, releaseDaemonLock, validateProfileForAgent, getProfileEnvironmentVariables, clearCredentials, clearMachineId } from './persistence-QqeBvUxX.mjs';
4
4
  import { z } from 'zod';
5
5
  import fs from 'fs/promises';
6
6
  import os, { homedir } from 'os';
@@ -5042,15 +5042,17 @@ async function withRetry(operation, options) {
5042
5042
  return await operation();
5043
5043
  } catch (error) {
5044
5044
  lastError = normalizeAcpError(error);
5045
- if (attempt < options.maxAttempts) {
5046
- const delayMs = Math.min(
5047
- options.baseDelayMs * Math.pow(2, attempt - 1),
5048
- options.maxDelayMs
5049
- );
5050
- logger.debug(`[AcpBackend] ${options.operationName} failed (attempt ${attempt}/${options.maxAttempts}): ${lastError.message}. Retrying in ${delayMs}ms...`);
5051
- options.onRetry?.(attempt, lastError);
5052
- await delay(delayMs);
5045
+ const retryable = options.shouldRetry?.(lastError) ?? true;
5046
+ if (!retryable || attempt >= options.maxAttempts) {
5047
+ throw lastError;
5053
5048
  }
5049
+ const delayMs = Math.min(
5050
+ options.baseDelayMs * Math.pow(2, attempt - 1),
5051
+ options.maxDelayMs
5052
+ );
5053
+ logger.debug(`[AcpBackend] ${options.operationName} failed (attempt ${attempt}/${options.maxAttempts}): ${lastError.message}. Retrying in ${delayMs}ms...`);
5054
+ options.onRetry?.(attempt, lastError);
5055
+ await delay(delayMs);
5054
5056
  }
5055
5057
  }
5056
5058
  throw lastError;
@@ -5103,6 +5105,77 @@ function enrichAcpError(error, stderrExcerpt) {
5103
5105
  }
5104
5106
  return normalized;
5105
5107
  }
5108
+ class AcpProcessStartupError extends Error {
5109
+ constructor(message, exitCode, signal) {
5110
+ super(message);
5111
+ this.exitCode = exitCode;
5112
+ this.signal = signal;
5113
+ this.name = "AcpProcessStartupError";
5114
+ }
5115
+ }
5116
+ function createProcessStartupError(agentName, operationName, code, signal) {
5117
+ if (code !== null) {
5118
+ return new AcpProcessStartupError(
5119
+ `${agentName} exited with code ${code} during ${operationName}`,
5120
+ code,
5121
+ signal
5122
+ );
5123
+ }
5124
+ if (signal) {
5125
+ return new AcpProcessStartupError(
5126
+ `${agentName} exited due to signal ${signal} during ${operationName}`,
5127
+ code,
5128
+ signal
5129
+ );
5130
+ }
5131
+ return new AcpProcessStartupError(
5132
+ `${agentName} exited unexpectedly during ${operationName}`,
5133
+ code,
5134
+ signal
5135
+ );
5136
+ }
5137
+ async function raceWithProcessExit(childProcess, operation, options) {
5138
+ if (childProcess.exitCode !== null) {
5139
+ throw createProcessStartupError(
5140
+ options.agentName,
5141
+ options.operationName,
5142
+ childProcess.exitCode,
5143
+ childProcess.signalCode ?? null
5144
+ );
5145
+ }
5146
+ return await new Promise((resolve, reject) => {
5147
+ let settled = false;
5148
+ const cleanup = () => {
5149
+ childProcess.off("error", handleError);
5150
+ childProcess.off("exit", handleExit);
5151
+ };
5152
+ const settleResolve = (value) => {
5153
+ if (settled) {
5154
+ return;
5155
+ }
5156
+ settled = true;
5157
+ cleanup();
5158
+ resolve(value);
5159
+ };
5160
+ const settleReject = (error) => {
5161
+ if (settled) {
5162
+ return;
5163
+ }
5164
+ settled = true;
5165
+ cleanup();
5166
+ reject(normalizeAcpError(error));
5167
+ };
5168
+ const handleError = (error) => {
5169
+ settleReject(error);
5170
+ };
5171
+ const handleExit = (code, signal) => {
5172
+ settleReject(createProcessStartupError(options.agentName, options.operationName, code, signal));
5173
+ };
5174
+ childProcess.once("error", handleError);
5175
+ childProcess.once("exit", handleExit);
5176
+ operation.then(settleResolve, settleReject);
5177
+ });
5178
+ }
5106
5179
  class AcpBackend {
5107
5180
  constructor(options) {
5108
5181
  this.options = options;
@@ -5503,20 +5576,27 @@ class AcpBackend {
5503
5576
  async () => {
5504
5577
  let timeoutHandle = null;
5505
5578
  try {
5506
- const result = await Promise.race([
5507
- this.connection.initialize(initRequest).then((res) => {
5508
- if (timeoutHandle) {
5509
- clearTimeout(timeoutHandle);
5510
- timeoutHandle = null;
5511
- }
5512
- return res;
5513
- }),
5514
- new Promise((_, reject) => {
5515
- timeoutHandle = setTimeout(() => {
5516
- reject(new Error(`Initialize timeout after ${initTimeout}ms - ${this.transport.agentName} did not respond`));
5517
- }, initTimeout);
5518
- })
5519
- ]);
5579
+ const result = await raceWithProcessExit(
5580
+ this.process,
5581
+ Promise.race([
5582
+ this.connection.initialize(initRequest).then((res) => {
5583
+ if (timeoutHandle) {
5584
+ clearTimeout(timeoutHandle);
5585
+ timeoutHandle = null;
5586
+ }
5587
+ return res;
5588
+ }),
5589
+ new Promise((_, reject) => {
5590
+ timeoutHandle = setTimeout(() => {
5591
+ reject(new Error(`Initialize timeout after ${initTimeout}ms - ${this.transport.agentName} did not respond`));
5592
+ }, initTimeout);
5593
+ })
5594
+ ]),
5595
+ {
5596
+ agentName: this.transport.agentName,
5597
+ operationName: "initialize"
5598
+ }
5599
+ );
5520
5600
  return result;
5521
5601
  } finally {
5522
5602
  if (timeoutHandle) {
@@ -5528,7 +5608,8 @@ class AcpBackend {
5528
5608
  operationName: "Initialize",
5529
5609
  maxAttempts: RETRY_CONFIG.maxAttempts,
5530
5610
  baseDelayMs: RETRY_CONFIG.baseDelayMs,
5531
- maxDelayMs: RETRY_CONFIG.maxDelayMs
5611
+ maxDelayMs: RETRY_CONFIG.maxDelayMs,
5612
+ shouldRetry: (error) => !(error instanceof AcpProcessStartupError)
5532
5613
  }
5533
5614
  );
5534
5615
  logger.debug(`[AcpBackend] Initialize completed`);
@@ -5547,20 +5628,27 @@ class AcpBackend {
5547
5628
  async () => {
5548
5629
  let timeoutHandle = null;
5549
5630
  try {
5550
- const result = await Promise.race([
5551
- this.connection.newSession(newSessionRequest).then((res) => {
5552
- if (timeoutHandle) {
5553
- clearTimeout(timeoutHandle);
5554
- timeoutHandle = null;
5555
- }
5556
- return res;
5557
- }),
5558
- new Promise((_, reject) => {
5559
- timeoutHandle = setTimeout(() => {
5560
- reject(new Error(`New session timeout after ${initTimeout}ms - ${this.transport.agentName} did not respond`));
5561
- }, initTimeout);
5562
- })
5563
- ]);
5631
+ const result = await raceWithProcessExit(
5632
+ this.process,
5633
+ Promise.race([
5634
+ this.connection.newSession(newSessionRequest).then((res) => {
5635
+ if (timeoutHandle) {
5636
+ clearTimeout(timeoutHandle);
5637
+ timeoutHandle = null;
5638
+ }
5639
+ return res;
5640
+ }),
5641
+ new Promise((_, reject) => {
5642
+ timeoutHandle = setTimeout(() => {
5643
+ reject(new Error(`New session timeout after ${initTimeout}ms - ${this.transport.agentName} did not respond`));
5644
+ }, initTimeout);
5645
+ })
5646
+ ]),
5647
+ {
5648
+ agentName: this.transport.agentName,
5649
+ operationName: "new session"
5650
+ }
5651
+ );
5564
5652
  return result;
5565
5653
  } finally {
5566
5654
  if (timeoutHandle) {
@@ -5572,7 +5660,8 @@ class AcpBackend {
5572
5660
  operationName: "NewSession",
5573
5661
  maxAttempts: RETRY_CONFIG.maxAttempts,
5574
5662
  baseDelayMs: RETRY_CONFIG.baseDelayMs,
5575
- maxDelayMs: RETRY_CONFIG.maxDelayMs
5663
+ maxDelayMs: RETRY_CONFIG.maxDelayMs,
5664
+ shouldRetry: (error) => !(error instanceof AcpProcessStartupError)
5576
5665
  }
5577
5666
  );
5578
5667
  this.acpSessionId = sessionResponse.sessionId;
@@ -6103,6 +6192,7 @@ function registerGeminiAgent() {
6103
6192
  logger.debug("[Gemini] Registered with agent registry");
6104
6193
  }
6105
6194
 
6195
+ const DEFAULT_CODEX_ACP_NPX_PACKAGE = "@zed-industries/codex-acp@0.9.5";
6106
6196
  function readFirstEnv(...names) {
6107
6197
  for (const name of names) {
6108
6198
  const raw = process.env[name];
@@ -6157,6 +6247,10 @@ function readCodexAcpNpxMode() {
6157
6247
  }
6158
6248
  return "auto";
6159
6249
  }
6250
+ function readCodexAcpNpxPackage() {
6251
+ const configured = readFirstEnv("HAPPY_CODEX_ACP_PACKAGE", "HAPPIER_CODEX_ACP_PACKAGE");
6252
+ return configured || DEFAULT_CODEX_ACP_NPX_PACKAGE;
6253
+ }
6160
6254
  function isBinOnPath(baseName) {
6161
6255
  return resolveCommandOnPath(baseName) !== null;
6162
6256
  }
@@ -6222,7 +6316,7 @@ function resolveCodexAcpSpawn(options = {}) {
6222
6316
  }
6223
6317
  return {
6224
6318
  command: resolveNpxCommand(),
6225
- args: ["--prefer-offline", "-y", "@zed-industries/codex-acp", ...directArgs]
6319
+ args: ["--prefer-offline", "-y", readCodexAcpNpxPackage(), ...directArgs]
6226
6320
  };
6227
6321
  }
6228
6322
  function validateCodexAcpSpawn(options = {}) {
@@ -6509,12 +6603,12 @@ async function ensureUnifiedDaemonStarted() {
6509
6603
  async function executeUnifiedProvider(opts) {
6510
6604
  const credentials = await ensureUnifiedRuntimePrerequisites(opts.credentials);
6511
6605
  if (opts.provider === "claude") {
6512
- const { runClaude } = await import('./runClaude-Dl9nIRIg.mjs');
6606
+ const { runClaude } = await import('./runClaude-CZ8gxaJL.mjs');
6513
6607
  await runClaude(credentials, opts.claudeOptions ?? {});
6514
6608
  return;
6515
6609
  }
6516
6610
  if (opts.provider === "codex") {
6517
- const { runCodex } = await import('./runCodex-DgKKw3IU.mjs');
6611
+ const { runCodex } = await import('./runCodex-DT7g4MPm.mjs');
6518
6612
  await runCodex({
6519
6613
  credentials,
6520
6614
  startedBy: opts.startedBy,
@@ -6524,7 +6618,7 @@ async function executeUnifiedProvider(opts) {
6524
6618
  return;
6525
6619
  }
6526
6620
  if (opts.provider === "gemini") {
6527
- const { runGemini } = await import('./runGemini-CM1v3I24.mjs');
6621
+ const { runGemini } = await import('./runGemini-CmY5386l.mjs');
6528
6622
  await runGemini({
6529
6623
  credentials,
6530
6624
  startedBy: opts.startedBy
@@ -6566,7 +6660,7 @@ function shouldRunMainClaudeFlow(opts) {
6566
6660
  return;
6567
6661
  } else if (subcommand === "runtime") {
6568
6662
  if (args[1] === "providers") {
6569
- const { renderRuntimeProviders } = await import('./command-BERqmFB0.mjs');
6663
+ const { renderRuntimeProviders } = await import('./command-Dl9SrMnv.mjs');
6570
6664
  console.log(renderRuntimeProviders());
6571
6665
  return;
6572
6666
  }
@@ -6744,8 +6838,8 @@ function shouldRunMainClaudeFlow(opts) {
6744
6838
  const projectId = args[3];
6745
6839
  try {
6746
6840
  const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
6747
- const { readCredentials: readCredentials2 } = await import('./persistence-sLEqV8vk.mjs');
6748
- const { ApiClient: ApiClient2 } = await import('./api-CIHTNilH.mjs').then(function (n) { return n.q; });
6841
+ const { readCredentials: readCredentials2 } = await import('./persistence-QqeBvUxX.mjs');
6842
+ const { ApiClient: ApiClient2 } = await import('./api-DoHt-HyL.mjs').then(function (n) { return n.q; });
6749
6843
  let userEmail = void 0;
6750
6844
  try {
6751
6845
  const credentials = await readCredentials2();