happy-imou-cloud 2.1.49 → 2.1.51

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 (55) hide show
  1. package/dist/AcpBackend-CqO3D07V.mjs +2619 -0
  2. package/dist/AcpBackend-XPiTd6ph.cjs +2621 -0
  3. package/dist/{BaseReasoningProcessor-Dn9NcoHz.cjs → BaseReasoningProcessor-BD9tiwep.cjs} +1 -144
  4. package/dist/{BaseReasoningProcessor-CAVeOdyo.mjs → BaseReasoningProcessor-CjlayL2f.mjs} +2 -144
  5. package/dist/ConversationHistory-Bl2doTA-.cjs +780 -0
  6. package/dist/ConversationHistory-CI5bBfuA.mjs +771 -0
  7. package/dist/{ProviderSelectionHandler-BJJc7qOR.cjs → ProviderSelectionHandler-C7GE5QjX.cjs} +6 -6
  8. package/dist/{ProviderSelectionHandler-DIYidT13.mjs → ProviderSelectionHandler-uQ8jzdzr.mjs} +2 -2
  9. package/dist/RuntimeShell-BDt42io_.mjs +252 -0
  10. package/dist/RuntimeShell-D_Te12wq.cjs +258 -0
  11. package/dist/bootstrapManagedProviderSession-Bln-TwyB.cjs +147 -0
  12. package/dist/bootstrapManagedProviderSession-D2Z6YU3n.mjs +145 -0
  13. package/dist/claude-BKNT-2fG.cjs +1080 -0
  14. package/dist/claude-CnN5WCWj.mjs +1073 -0
  15. package/dist/codex-DLGP8WF6.mjs +577 -0
  16. package/dist/codex-Fv2eali8.cjs +582 -0
  17. package/dist/{command-VcH4hbhi.cjs → command-BWPlJyCN.cjs} +16 -8
  18. package/dist/{command-CzfRRhVe.mjs → command-CELwsYoG.mjs} +15 -7
  19. package/dist/config-CFL0Gkqt.cjs +184 -0
  20. package/dist/config-ChSPe7p9.mjs +174 -0
  21. package/dist/createDefaultRuntimeShell-BXu3vCvT.cjs +33 -0
  22. package/dist/createDefaultRuntimeShell-DOg6g3-G.mjs +31 -0
  23. package/dist/cursor-Blq1cHdr.cjs +91 -0
  24. package/dist/cursor-CwPNSy_A.mjs +88 -0
  25. package/dist/future-Dq4Ha1Dn.cjs +24 -0
  26. package/dist/future-xRdLl3vf.mjs +22 -0
  27. package/dist/{index-xa1kwZoj.cjs → index-B_JYgMUS.cjs} +189 -5352
  28. package/dist/{index-7Z93BoVn.mjs → index-CX-F_fuk.mjs} +177 -5331
  29. package/dist/index.cjs +2 -2
  30. package/dist/index.mjs +2 -2
  31. package/dist/installFatalProcessHandlers-0vaw9MAz.mjs +55 -0
  32. package/dist/installFatalProcessHandlers-CyURn5Bp.cjs +57 -0
  33. package/dist/launch-BoCCEd5p.mjs +63 -0
  34. package/dist/launch-wZA5BcvS.cjs +66 -0
  35. package/dist/lib.cjs +2 -3
  36. package/dist/lib.d.cts +20 -17
  37. package/dist/lib.d.mts +20 -17
  38. package/dist/lib.mjs +1 -2
  39. package/dist/resolveCommand-B3BGyBE2.mjs +189 -0
  40. package/dist/resolveCommand-DYMd9PNC.cjs +193 -0
  41. package/dist/{runClaude-zCwRhpOw.mjs → runClaude-Be0myF9k.mjs} +8 -5
  42. package/dist/{runClaude-BBGNmGj6.cjs → runClaude-DZJt5er7.cjs} +46 -43
  43. package/dist/{runCodex-BbgLVjb9.mjs → runCodex-BSnyN4m7.mjs} +226 -117
  44. package/dist/{runCodex-jUU6U2tZ.cjs → runCodex-DTCcGRue.cjs} +269 -160
  45. package/dist/runCursor-Bn1PuwJy.cjs +506 -0
  46. package/dist/runCursor-M6dQ6bGF.mjs +504 -0
  47. package/dist/{runGemini-DcwNsudA.mjs → runGemini-BNm4vYKA.mjs} +279 -5
  48. package/dist/{runGemini-C0NT8MHK.cjs → runGemini-Bn3lFhz6.cjs} +309 -35
  49. package/dist/{registerKillSessionHandler-DLDg2EES.mjs → sessionControl-1bT_7OI6.mjs} +1643 -2405
  50. package/dist/{registerKillSessionHandler-CfCya6si.cjs → sessionControl-flKnQrx0.cjs} +1647 -2417
  51. package/dist/{api-DnqaNvyV.mjs → types-B5vtxa38.mjs} +55 -5
  52. package/dist/{api-D7nAeZi7.cjs → types-CttABk32.cjs} +55 -4
  53. package/package.json +2 -2
  54. package/dist/types-CiliQpqS.mjs +0 -52
  55. package/dist/types-DVk3crez.cjs +0 -54
@@ -1,10 +1,13 @@
1
1
  import { useStdout, useInput, Box, Text, render } from 'ink';
2
2
  import React, { useState, useRef, useEffect, useCallback } from 'react';
3
3
  import { randomUUID } from 'node:crypto';
4
- import { l as logger, b as connectionState, A as ApiClient, h as hashObject, d as AssistantMessageStream } from './api-DnqaNvyV.mjs';
5
- import { B as BasePermissionHandler, C as ConversationHistory$1, r as resolveHappyOrgQueuedTurn, e as ensureManagedProviderMachine, M as MissingMachineIdError, s as syncControlledByUserState, b as MessageQueue2, c as registerKillSessionHandler, d as MessageBuffer, f as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, h as finalizeHappyOrgTurnWithBusinessAck, i as buildTurnResultPushNotification, j as buildReadyPushNotification, l as launchRuntimeHandleWithFactoryResult, k as extractPermissionRequestPushContext, m as buildPermissionPushNotification, n as renderTerminalOutputPreview, p as prepareTerminalOutputForForwarding, o as inferToolResultError, q as forwardAgentMessageToProviderSession, t as createSessionTranscriptInkRenderer } from './registerKillSessionHandler-DLDg2EES.mjs';
6
- import { g as getInitialGeminiModel, r as readGeminiLocalConfig, G as GEMINI_MODEL_ENV, b as closeProviderSession, s as saveGeminiModelToConfig, d as createGeminiBackend, e as stopCaffeinate } from './index-7Z93BoVn.mjs';
7
- import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-CAVeOdyo.mjs';
4
+ import { l as logger, b as connectionState, A as ApiClient, h as hashObject, d as AssistantMessageStream } from './types-B5vtxa38.mjs';
5
+ import { C as ConversationHistory$1, M as MessageBuffer, b as buildTurnResultPushNotification, a as buildReadyPushNotification, l as launchRuntimeHandleWithFactoryResult, e as extractPermissionRequestPushContext, c as buildPermissionPushNotification, d as createSessionTranscriptInkRenderer } from './ConversationHistory-CI5bBfuA.mjs';
6
+ import { B as BasePermissionHandler, c as resolveHappyOrgQueuedTurn, e as ensureManagedProviderMachine, M as MissingMachineIdError, s as syncControlledByUserState, b as MessageQueue2, r as registerKillSessionHandler, d as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, f as finalizeHappyOrgTurnWithBusinessAck, i as renderTerminalOutputPreview, p as prepareTerminalOutputForForwarding, j as inferToolResultError, h as forwardAgentMessageToProviderSession } from './sessionControl-1bT_7OI6.mjs';
7
+ import { f as resolveAcpSessionPreferences, n as scaleAcpTimeoutMs, b as closeProviderSession, s as stopCaffeinate } from './index-CX-F_fuk.mjs';
8
+ import { A as AcpBackend } from './AcpBackend-CqO3D07V.mjs';
9
+ import { r as readGeminiLocalConfig, G as GEMINI_API_KEY_ENV, a as GOOGLE_API_KEY_ENV, d as determineGeminiModel, g as getGeminiModelSource, b as GEMINI_MODEL_ENV, c as getInitialGeminiModel, s as saveGeminiModelToConfig } from './config-ChSPe7p9.mjs';
10
+ import { B as BaseReasoningProcessor } from './BaseReasoningProcessor-CjlayL2f.mjs';
8
11
  import 'cross-spawn';
9
12
  import '@agentclientprotocol/sdk';
10
13
  import 'ps-list';
@@ -13,6 +16,7 @@ import 'node:path';
13
16
  import 'node:os';
14
17
  import 'node:child_process';
15
18
  import 'node:readline';
19
+ import { b as bootstrapManagedProviderSession } from './bootstrapManagedProviderSession-D2Z6YU3n.mjs';
16
20
  import 'tweetnacl';
17
21
  import 'axios';
18
22
  import 'open';
@@ -27,7 +31,7 @@ import 'socket.io-client';
27
31
  import 'fs/promises';
28
32
  import 'crypto';
29
33
  import 'expo-server-sdk';
30
- import './types-CiliQpqS.mjs';
34
+ import './RuntimeShell-BDt42io_.mjs';
31
35
  import 'os';
32
36
  import 'qrcode-terminal';
33
37
  import 'node:module';
@@ -38,6 +42,276 @@ import 'http';
38
42
  import 'util';
39
43
  import 'node:url';
40
44
 
45
+ const GEMINI_TIMEOUTS = {
46
+ /** Gemini CLI can be slow on first start (downloading models, etc.) */
47
+ init: 12e4,
48
+ /** Gemini ACP can swallow an initialize request sent too early after spawn */
49
+ initDelay: 2500,
50
+ /** Standard tool call timeout */
51
+ toolCall: 10 * 6e4,
52
+ /** Investigation tools (codebase_investigator) can run for a long time */
53
+ investigation: 30 * 6e4,
54
+ /** Think tools are usually quick */
55
+ think: 2 * 6e4,
56
+ /** Idle detection after last message chunk */
57
+ idle: 500
58
+ };
59
+ const GEMINI_TOOL_PATTERNS = [
60
+ {
61
+ name: "save_memory",
62
+ patterns: ["save_memory", "save-memory"],
63
+ inputFields: ["memory", "content"]
64
+ },
65
+ {
66
+ name: "think",
67
+ patterns: ["think"],
68
+ inputFields: ["thought", "thinking"]
69
+ }
70
+ ];
71
+ const AVAILABLE_MODELS = [
72
+ "gemini-2.5-pro",
73
+ "gemini-2.5-flash",
74
+ "gemini-2.5-flash-lite"
75
+ ];
76
+ class GeminiTransport {
77
+ agentName = "gemini";
78
+ getTimeoutProfile() {
79
+ return resolveAcpSessionPreferences({ agentName: this.agentName }).timeoutProfile;
80
+ }
81
+ /**
82
+ * Gemini CLI needs 2 minutes for first start (model download, warm-up)
83
+ */
84
+ getInitTimeout() {
85
+ return scaleAcpTimeoutMs(GEMINI_TIMEOUTS.init, "init", this.getTimeoutProfile());
86
+ }
87
+ getInitDelayMs() {
88
+ return GEMINI_TIMEOUTS.initDelay;
89
+ }
90
+ /**
91
+ * Filter Gemini CLI debug output from stdout.
92
+ *
93
+ * Gemini CLI outputs various debug info (experiments, flags, etc.) to stdout
94
+ * that breaks ACP JSON-RPC parsing. We only keep valid JSON lines.
95
+ */
96
+ filterStdoutLine(line) {
97
+ const trimmed = line.trim();
98
+ if (!trimmed) {
99
+ return null;
100
+ }
101
+ if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
102
+ return null;
103
+ }
104
+ try {
105
+ const parsed = JSON.parse(trimmed);
106
+ if (typeof parsed !== "object" || parsed === null) {
107
+ return null;
108
+ }
109
+ return line;
110
+ } catch {
111
+ return null;
112
+ }
113
+ }
114
+ /**
115
+ * Handle Gemini CLI stderr output.
116
+ *
117
+ * Detects:
118
+ * - Rate limit errors (429) - logged but not shown (CLI handles retries)
119
+ * - Model not found (404) - emit error with available models
120
+ * - Other errors during investigation - logged for debugging
121
+ */
122
+ handleStderr(text, context) {
123
+ const trimmed = text.trim();
124
+ if (!trimmed) {
125
+ return { message: null, suppress: true };
126
+ }
127
+ if (trimmed.includes("status 429") || trimmed.includes('code":429') || trimmed.includes("rateLimitExceeded") || trimmed.includes("RESOURCE_EXHAUSTED")) {
128
+ return {
129
+ message: null,
130
+ suppress: false
131
+ // Log for debugging but don't show to user
132
+ };
133
+ }
134
+ if (trimmed.includes("status 404") || trimmed.includes('code":404')) {
135
+ const errorMessage = {
136
+ type: "status",
137
+ status: "error",
138
+ detail: `Model not found. Available models: ${AVAILABLE_MODELS.join(", ")}`
139
+ };
140
+ return { message: errorMessage };
141
+ }
142
+ if (context.hasActiveInvestigation) {
143
+ const hasError = trimmed.includes("timeout") || trimmed.includes("Timeout") || trimmed.includes("failed") || trimmed.includes("Failed") || trimmed.includes("error") || trimmed.includes("Error");
144
+ if (hasError) {
145
+ return { message: null, suppress: false };
146
+ }
147
+ }
148
+ return { message: null };
149
+ }
150
+ /**
151
+ * Gemini-specific tool patterns
152
+ */
153
+ getToolPatterns() {
154
+ return GEMINI_TOOL_PATTERNS;
155
+ }
156
+ /**
157
+ * Check if tool is an investigation tool (needs longer timeout)
158
+ */
159
+ isInvestigationTool(toolCallId, toolKind) {
160
+ const lowerId = toolCallId.toLowerCase();
161
+ return lowerId.includes("codebase_investigator") || lowerId.includes("investigator") || typeof toolKind === "string" && toolKind.includes("investigator");
162
+ }
163
+ /**
164
+ * Get timeout for a tool call
165
+ */
166
+ getToolCallTimeout(toolCallId, toolKind) {
167
+ if (this.isInvestigationTool(toolCallId, toolKind)) {
168
+ return scaleAcpTimeoutMs(GEMINI_TIMEOUTS.investigation, "investigation", this.getTimeoutProfile());
169
+ }
170
+ if (toolKind === "think") {
171
+ return scaleAcpTimeoutMs(GEMINI_TIMEOUTS.think, "think", this.getTimeoutProfile());
172
+ }
173
+ return scaleAcpTimeoutMs(GEMINI_TIMEOUTS.toolCall, "tool", this.getTimeoutProfile());
174
+ }
175
+ /**
176
+ * Get idle detection timeout
177
+ */
178
+ getIdleTimeout() {
179
+ return GEMINI_TIMEOUTS.idle;
180
+ }
181
+ /**
182
+ * Extract tool name from toolCallId using Gemini patterns.
183
+ *
184
+ * Tool IDs often contain the tool name as a prefix (e.g., "save_memory-1765385846663" -> "save_memory")
185
+ */
186
+ extractToolNameFromId(toolCallId) {
187
+ const lowerId = toolCallId.toLowerCase();
188
+ for (const toolPattern of GEMINI_TOOL_PATTERNS) {
189
+ for (const pattern of toolPattern.patterns) {
190
+ if (lowerId.includes(pattern.toLowerCase())) {
191
+ return toolPattern.name;
192
+ }
193
+ }
194
+ }
195
+ return null;
196
+ }
197
+ /**
198
+ * Check if input is effectively empty
199
+ */
200
+ isEmptyInput(input) {
201
+ if (!input) return true;
202
+ if (Array.isArray(input)) return input.length === 0;
203
+ if (typeof input === "object") return Object.keys(input).length === 0;
204
+ return false;
205
+ }
206
+ /**
207
+ * Determine the real tool name from various sources.
208
+ *
209
+ * When Gemini sends "other" or "Unknown tool", tries to determine the real name from:
210
+ * 1. toolCallId patterns (most reliable - tool name often embedded in ID)
211
+ * 2. Input field signatures (specific fields indicate specific tools)
212
+ * 3. Empty input default (some tools like think have empty input)
213
+ *
214
+ * Context-based heuristics were removed as they were fragile and the above
215
+ * methods cover all known cases.
216
+ */
217
+ determineToolName(toolName, toolCallId, input, _context) {
218
+ if (toolName !== "other" && toolName !== "Unknown tool") {
219
+ return toolName;
220
+ }
221
+ const idToolName = this.extractToolNameFromId(toolCallId);
222
+ if (idToolName) {
223
+ return idToolName;
224
+ }
225
+ if (input && typeof input === "object" && !Array.isArray(input)) {
226
+ const inputKeys = Object.keys(input);
227
+ for (const toolPattern of GEMINI_TOOL_PATTERNS) {
228
+ if (toolPattern.inputFields) {
229
+ const hasMatchingField = toolPattern.inputFields.some(
230
+ (field) => inputKeys.some((key) => key.toLowerCase() === field.toLowerCase())
231
+ );
232
+ if (hasMatchingField) {
233
+ return toolPattern.name;
234
+ }
235
+ }
236
+ }
237
+ }
238
+ if (this.isEmptyInput(input) && toolName === "other") {
239
+ const defaultTool = GEMINI_TOOL_PATTERNS.find((p) => p.emptyInputDefault);
240
+ if (defaultTool) {
241
+ return defaultTool.name;
242
+ }
243
+ }
244
+ if (toolName === "other" || toolName === "Unknown tool") {
245
+ const inputKeys = input && typeof input === "object" ? Object.keys(input) : [];
246
+ logger.debug(
247
+ `[GeminiTransport] Unknown tool pattern - toolCallId: "${toolCallId}", toolName: "${toolName}", inputKeys: [${inputKeys.join(", ")}]. Consider adding a new pattern to GEMINI_TOOL_PATTERNS if this tool appears frequently.`
248
+ );
249
+ }
250
+ return toolName;
251
+ }
252
+ }
253
+ const geminiTransport = new GeminiTransport();
254
+
255
+ function createGeminiBackend(options) {
256
+ const localConfig = readGeminiLocalConfig();
257
+ let apiKey = options.cloudToken || localConfig.token || process.env[GEMINI_API_KEY_ENV] || process.env[GOOGLE_API_KEY_ENV] || options.apiKey;
258
+ if (!apiKey) {
259
+ logger.warn(`[Gemini] No API key found. Run 'happy connect gemini' to authenticate via Google OAuth, or set ${GEMINI_API_KEY_ENV} environment variable.`);
260
+ }
261
+ const geminiCommand = "gemini";
262
+ const model = determineGeminiModel(options.model, localConfig);
263
+ const geminiArgs = ["--experimental-acp"];
264
+ let googleCloudProject = null;
265
+ if (localConfig.googleCloudProject) {
266
+ const storedEmail = localConfig.googleCloudProjectEmail;
267
+ const currentEmail = options.currentUserEmail;
268
+ if (!storedEmail || storedEmail === currentEmail) {
269
+ googleCloudProject = localConfig.googleCloudProject;
270
+ logger.debug(`[Gemini] Using Google Cloud Project: ${googleCloudProject}${storedEmail ? ` (for ${storedEmail})` : " (global)"}`);
271
+ } else {
272
+ logger.debug(`[Gemini] Skipping stored Google Cloud Project (stored for ${storedEmail}, current user is ${currentEmail || "unknown"})`);
273
+ }
274
+ }
275
+ const backendOptions = {
276
+ agentName: "gemini",
277
+ cwd: options.cwd,
278
+ command: geminiCommand,
279
+ args: geminiArgs,
280
+ env: {
281
+ ...options.env,
282
+ ...apiKey ? { [GEMINI_API_KEY_ENV]: apiKey, [GOOGLE_API_KEY_ENV]: apiKey } : {},
283
+ // Pass model via env var - gemini CLI reads GEMINI_MODEL automatically
284
+ [GEMINI_MODEL_ENV]: model,
285
+ // Pass Google Cloud Project for Workspace accounts
286
+ ...googleCloudProject ? {
287
+ GOOGLE_CLOUD_PROJECT: googleCloudProject,
288
+ GOOGLE_CLOUD_PROJECT_ID: googleCloudProject
289
+ } : {},
290
+ // Suppress debug output from gemini CLI to avoid stdout pollution
291
+ NODE_ENV: "production",
292
+ DEBUG: ""
293
+ },
294
+ mcpServers: options.mcpServers,
295
+ permissionHandler: options.permissionHandler,
296
+ transportHandler: geminiTransport
297
+ };
298
+ const modelSource = getGeminiModelSource(options.model, localConfig);
299
+ logger.debug("[Gemini] Creating ACP SDK backend with options:", {
300
+ cwd: backendOptions.cwd,
301
+ command: backendOptions.command,
302
+ args: backendOptions.args,
303
+ hasApiKey: !!apiKey,
304
+ model,
305
+ modelSource,
306
+ mcpServerCount: options.mcpServers ? Object.keys(options.mcpServers).length : 0
307
+ });
308
+ return {
309
+ backend: new AcpBackend(backendOptions),
310
+ model,
311
+ modelSource
312
+ };
313
+ }
314
+
41
315
  const GeminiDisplay = ({ messageBuffer, logPath, currentModel, onExit }) => {
42
316
  const [messages, setMessages] = useState([]);
43
317
  const [confirmationMode, setConfirmationMode] = useState(false);