happy-imou-cloud 2.0.22 → 2.1.0
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.
- package/bin/happy-cloud.mjs +1 -1
- package/dist/{BaseReasoningProcessor-CJVv1aNR.cjs → BaseReasoningProcessor-C9mH8EVn.cjs} +3 -3
- package/dist/{BaseReasoningProcessor-mIqqngd3.mjs → BaseReasoningProcessor-DQkzwRuf.mjs} +3 -3
- package/dist/ProviderSelectionHandler-5Dedbm8j.cjs +265 -0
- package/dist/ProviderSelectionHandler-BlrrLPlo.mjs +261 -0
- package/dist/{api-DP-RQUao.cjs → api-Bd-MnOS4.cjs} +24 -2
- package/dist/{api-DrijKeDb.mjs → api-w_CUxb9Q.mjs} +25 -3
- package/dist/{command-BZphfJrt.cjs → command-DoDmHNxR.cjs} +3 -3
- package/dist/{command--vV6BSsL.mjs → command-mTWwCqTY.mjs} +3 -3
- package/dist/{index-CqCEZDFi.cjs → index-BQmJ4NAa.cjs} +199 -79
- package/dist/{index-BIki80pQ.mjs → index-GuXV-pxB.mjs} +196 -76
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +3 -3
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +95 -92
- package/dist/lib.d.mts +95 -92
- package/dist/lib.mjs +1 -1
- package/dist/{persistence-yVTbf_Ng.cjs → persistence-BL06LLVz.cjs} +1 -1
- package/dist/{persistence-C3NBdZdz.mjs → persistence-MSy70is3.mjs} +1 -1
- package/dist/{registerKillSessionHandler-CHEj7UjN.mjs → registerKillSessionHandler-CjWfUfc3.mjs} +428 -13
- package/dist/{registerKillSessionHandler-QmBN446A.cjs → registerKillSessionHandler-D9kwxy6B.cjs} +430 -12
- package/dist/{runClaude-BuI6OOEv.cjs → runClaude-D2ZEXue8.cjs} +11 -9
- package/dist/{runClaude-D0DD_Ya5.mjs → runClaude-DpZ95Twb.mjs} +8 -6
- package/dist/{runCodex-BzZ0jODI.mjs → runCodex-CJwaep2R.mjs} +9 -7
- package/dist/{runCodex-1jTTmCvq.cjs → runCodex-Dz_1ho8d.cjs} +12 -10
- package/dist/{runGemini-Bx2SYAyG.mjs → runGemini-BehqjM73.mjs} +192 -71
- package/dist/{runGemini-1gJRE8oT.cjs → runGemini-Dfu6LltX.cjs} +192 -71
- package/package.json +1 -1
- package/scripts/build.mjs +66 -66
- package/scripts/devtools/README.md +9 -9
- package/scripts/e2e/fake-codex-acp-agent.mjs +139 -139
- package/scripts/e2e/local-server-session-roundtrip.mjs +1063 -1063
- package/scripts/release-smoke.mjs +3 -0
- package/dist/ProviderSelectionHandler-BjLyIfSR.mjs +0 -673
- package/dist/ProviderSelectionHandler-e4zL4Y5_.cjs +0 -680
|
@@ -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-
|
|
3
|
-
import { writeCredentialsLegacy, writeCredentialsDataKey, readCredentials, readSettings, updateSettings, readDaemonState, clearDaemonState, acquireDaemonLock, writeDaemonState, releaseDaemonLock, validateProfileForAgent, getProfileEnvironmentVariables, clearCredentials, clearMachineId } from './persistence-
|
|
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-w_CUxb9Q.mjs';
|
|
3
|
+
import { writeCredentialsLegacy, writeCredentialsDataKey, readCredentials, readSettings, updateSettings, readDaemonState, clearDaemonState, acquireDaemonLock, writeDaemonState, releaseDaemonLock, validateProfileForAgent, getProfileEnvironmentVariables, clearCredentials, clearMachineId } from './persistence-MSy70is3.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
|
-
|
|
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
|
};
|
|
@@ -4818,10 +4845,10 @@ function truncateDisplayMessage(value, maxLength) {
|
|
|
4818
4845
|
const DEFAULT_TIMEOUTS = {
|
|
4819
4846
|
/** Default initialization timeout: 60 seconds */
|
|
4820
4847
|
init: 6e4,
|
|
4821
|
-
/** Default tool call timeout:
|
|
4822
|
-
toolCall:
|
|
4823
|
-
/** Think tool timeout:
|
|
4824
|
-
think:
|
|
4848
|
+
/** Default tool call timeout: 10 minutes */
|
|
4849
|
+
toolCall: 10 * 6e4,
|
|
4850
|
+
/** Think tool timeout: 2 minutes */
|
|
4851
|
+
think: 2 * 6e4
|
|
4825
4852
|
};
|
|
4826
4853
|
class DefaultTransport {
|
|
4827
4854
|
agentName;
|
|
@@ -4898,7 +4925,7 @@ class DefaultTransport {
|
|
|
4898
4925
|
return toolName;
|
|
4899
4926
|
}
|
|
4900
4927
|
getPostPromptNoUpdatesTimeoutMs() {
|
|
4901
|
-
return
|
|
4928
|
+
return 2 * 6e4;
|
|
4902
4929
|
}
|
|
4903
4930
|
}
|
|
4904
4931
|
|
|
@@ -4908,11 +4935,11 @@ const GEMINI_TIMEOUTS = {
|
|
|
4908
4935
|
/** Gemini ACP can swallow an initialize request sent too early after spawn */
|
|
4909
4936
|
initDelay: 2500,
|
|
4910
4937
|
/** Standard tool call timeout */
|
|
4911
|
-
toolCall:
|
|
4938
|
+
toolCall: 10 * 6e4,
|
|
4912
4939
|
/** Investigation tools (codebase_investigator) can run for a long time */
|
|
4913
|
-
investigation:
|
|
4940
|
+
investigation: 30 * 6e4,
|
|
4914
4941
|
/** Think tools are usually quick */
|
|
4915
|
-
think:
|
|
4942
|
+
think: 2 * 6e4,
|
|
4916
4943
|
/** Idle detection after last message chunk */
|
|
4917
4944
|
idle: 500
|
|
4918
4945
|
};
|
|
@@ -5109,6 +5136,21 @@ class GeminiTransport {
|
|
|
5109
5136
|
}
|
|
5110
5137
|
const geminiTransport = new GeminiTransport();
|
|
5111
5138
|
|
|
5139
|
+
const DEFAULT_CODEX_EXECUTE_TIMEOUT_MS = 30 * 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
|
|
|
@@ -5149,7 +5197,7 @@ class CursorTransport extends DefaultTransport {
|
|
|
5149
5197
|
const cursorTransport = new CursorTransport();
|
|
5150
5198
|
|
|
5151
5199
|
const DEFAULT_IDLE_TIMEOUT_MS = 500;
|
|
5152
|
-
const DEFAULT_TOOL_CALL_TIMEOUT_MS =
|
|
5200
|
+
const DEFAULT_TOOL_CALL_TIMEOUT_MS = 10 * 6e4;
|
|
5153
5201
|
const DEFAULT_TOOL_CALL_OUTPUT_PREVIEW_HEAD_BYTES = 2e3;
|
|
5154
5202
|
const DEFAULT_TOOL_CALL_OUTPUT_PREVIEW_TAIL_BYTES = 4e3;
|
|
5155
5203
|
function parseArgsFromContent(content) {
|
|
@@ -5409,41 +5457,14 @@ function startToolCall(toolCallId, toolKind, update, ctx, source) {
|
|
|
5409
5457
|
}
|
|
5410
5458
|
const timeoutMs = ctx.transport.getToolCallTimeout?.(toolCallId, toolKindStr) ?? DEFAULT_TOOL_CALL_TIMEOUT_MS;
|
|
5411
5459
|
if (!ctx.toolCallTimeouts.has(toolCallId)) {
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
ctx.clearIdleTimeout();
|
|
5421
|
-
const streamedOutput = renderToolOutput(ctx.toolCallOutputs.get(toolCallId));
|
|
5422
|
-
ctx.toolCallOutputs.delete(toolCallId);
|
|
5423
|
-
ctx.emit({
|
|
5424
|
-
type: "tool-result",
|
|
5425
|
-
toolName: realToolName,
|
|
5426
|
-
result: streamedOutput ? {
|
|
5427
|
-
stdout: streamedOutput,
|
|
5428
|
-
error: timeoutDetail,
|
|
5429
|
-
status: "failed",
|
|
5430
|
-
timedOut: true
|
|
5431
|
-
} : {
|
|
5432
|
-
error: timeoutDetail,
|
|
5433
|
-
status: "failed",
|
|
5434
|
-
timedOut: true
|
|
5435
|
-
},
|
|
5436
|
-
callId: toolCallId
|
|
5437
|
-
});
|
|
5438
|
-
ctx.emit({
|
|
5439
|
-
type: "status",
|
|
5440
|
-
status: "error",
|
|
5441
|
-
detail: timeoutDetail
|
|
5442
|
-
});
|
|
5443
|
-
ctx.failPendingResponseWait(new Error(timeoutDetail));
|
|
5444
|
-
}, timeoutMs);
|
|
5445
|
-
ctx.toolCallTimeouts.set(toolCallId, timeout);
|
|
5446
|
-
logger.debug(`[AcpBackend] \u23F1\uFE0F Set timeout for ${toolCallId}: ${(timeoutMs / 1e3).toFixed(0)}s${isInvestigation ? " (investigation tool)" : ""}`);
|
|
5460
|
+
ctx.armToolCallTimeout({
|
|
5461
|
+
toolCallId,
|
|
5462
|
+
toolKind,
|
|
5463
|
+
toolName: realToolName,
|
|
5464
|
+
timeoutMs,
|
|
5465
|
+
source
|
|
5466
|
+
});
|
|
5467
|
+
logger.debug(`[AcpBackend] \u23F1\uFE0F Set no-progress timeout for ${toolCallId}: ${(timeoutMs / 1e3).toFixed(0)}s${isInvestigation ? " (investigation tool)" : ""}`);
|
|
5447
5468
|
} else {
|
|
5448
5469
|
logger.debug(`[AcpBackend] Timeout already set for ${toolCallId}, skipping`);
|
|
5449
5470
|
}
|
|
@@ -5469,11 +5490,7 @@ function completeToolCall(toolCallId, toolKind, content, ctx) {
|
|
|
5469
5490
|
const toolKindStr = typeof toolKind === "string" ? toolKind : "unknown";
|
|
5470
5491
|
ctx.activeToolCalls.delete(toolCallId);
|
|
5471
5492
|
ctx.toolCallStartTimes.delete(toolCallId);
|
|
5472
|
-
|
|
5473
|
-
if (timeout) {
|
|
5474
|
-
clearTimeout(timeout);
|
|
5475
|
-
ctx.toolCallTimeouts.delete(toolCallId);
|
|
5476
|
-
}
|
|
5493
|
+
ctx.clearToolCallTimeout(toolCallId);
|
|
5477
5494
|
const streamedOutput = renderToolOutput(ctx.toolCallOutputs.get(toolCallId));
|
|
5478
5495
|
ctx.toolCallOutputs.delete(toolCallId);
|
|
5479
5496
|
logger.debug(`[AcpBackend] \u2705 Tool call COMPLETED: ${toolCallId} (${toolKindStr}) - Duration: ${duration}. Active tool calls: ${ctx.activeToolCalls.size}`);
|
|
@@ -5512,10 +5529,8 @@ function failToolCall(toolCallId, status, toolKind, content, ctx) {
|
|
|
5512
5529
|
}
|
|
5513
5530
|
ctx.activeToolCalls.delete(toolCallId);
|
|
5514
5531
|
ctx.toolCallStartTimes.delete(toolCallId);
|
|
5515
|
-
const
|
|
5516
|
-
if (
|
|
5517
|
-
clearTimeout(timeout);
|
|
5518
|
-
ctx.toolCallTimeouts.delete(toolCallId);
|
|
5532
|
+
const clearedTimeout = ctx.clearToolCallTimeout(toolCallId);
|
|
5533
|
+
if (clearedTimeout) {
|
|
5519
5534
|
logger.debug(`[AcpBackend] Cleared timeout for ${toolCallId} (tool call ${status})`);
|
|
5520
5535
|
} else {
|
|
5521
5536
|
logger.debug(`[AcpBackend] No timeout found for ${toolCallId} (tool call ${status}) - timeout may not have been set`);
|
|
@@ -5838,7 +5853,7 @@ const RETRY_CONFIG = {
|
|
|
5838
5853
|
/** Maximum delay between retries in ms */
|
|
5839
5854
|
maxDelayMs: 5e3
|
|
5840
5855
|
};
|
|
5841
|
-
const DEFAULT_POST_PROMPT_NO_UPDATES_TIMEOUT_MS =
|
|
5856
|
+
const DEFAULT_POST_PROMPT_NO_UPDATES_TIMEOUT_MS = 2 * 6e4;
|
|
5842
5857
|
function readPositiveIntegerEnv(name) {
|
|
5843
5858
|
const raw = typeof process.env[name] === "string" ? process.env[name].trim() : "";
|
|
5844
5859
|
if (!raw) {
|
|
@@ -6147,6 +6162,7 @@ class AcpBackend {
|
|
|
6147
6162
|
/** Track active tool calls to prevent duplicate events */
|
|
6148
6163
|
activeToolCalls = /* @__PURE__ */ new Set();
|
|
6149
6164
|
toolCallTimeouts = /* @__PURE__ */ new Map();
|
|
6165
|
+
toolCallTimeoutSpecs = /* @__PURE__ */ new Map();
|
|
6150
6166
|
/** Track tool call start times for performance monitoring */
|
|
6151
6167
|
toolCallStartTimes = /* @__PURE__ */ new Map();
|
|
6152
6168
|
/** Track streamed tool output between ACP updates and final completion */
|
|
@@ -6171,6 +6187,12 @@ class AcpBackend {
|
|
|
6171
6187
|
waitingForResponse = false;
|
|
6172
6188
|
/** First fatal prompt-level error observed for the current turn */
|
|
6173
6189
|
responseCompletionError = null;
|
|
6190
|
+
/** Resettable no-progress timeout while waiting for a turn to finish */
|
|
6191
|
+
responseWaitTimeout = null;
|
|
6192
|
+
/** Current inactivity threshold used by waitForResponseComplete */
|
|
6193
|
+
responseWaitTimeoutMs = null;
|
|
6194
|
+
/** Timestamp of the last meaningful response progress for the current turn */
|
|
6195
|
+
responseLastProgressAt = null;
|
|
6174
6196
|
/** Fallback completion when prompt returns but the agent emits no session updates */
|
|
6175
6197
|
postPromptCompletionIdleTimeout = null;
|
|
6176
6198
|
/** Whether at least one session/update arrived after the current prompt */
|
|
@@ -6204,12 +6226,110 @@ class AcpBackend {
|
|
|
6204
6226
|
this.postPromptCompletionIdleTimeout = null;
|
|
6205
6227
|
}
|
|
6206
6228
|
}
|
|
6229
|
+
clearResponseWaitTimeout() {
|
|
6230
|
+
if (this.responseWaitTimeout) {
|
|
6231
|
+
clearTimeout(this.responseWaitTimeout);
|
|
6232
|
+
this.responseWaitTimeout = null;
|
|
6233
|
+
}
|
|
6234
|
+
}
|
|
6235
|
+
resetResponseWaitTracking() {
|
|
6236
|
+
this.clearResponseWaitTimeout();
|
|
6237
|
+
this.responseWaitTimeoutMs = null;
|
|
6238
|
+
this.responseLastProgressAt = null;
|
|
6239
|
+
}
|
|
6240
|
+
armResponseWaitTimeout(timeoutMs) {
|
|
6241
|
+
this.responseWaitTimeoutMs = timeoutMs;
|
|
6242
|
+
this.clearResponseWaitTimeout();
|
|
6243
|
+
const lastProgressAt = this.responseLastProgressAt ?? Date.now();
|
|
6244
|
+
const elapsedMs = Math.max(0, Date.now() - lastProgressAt);
|
|
6245
|
+
const remainingMs = Math.max(1, timeoutMs - elapsedMs);
|
|
6246
|
+
this.responseWaitTimeout = setTimeout(() => {
|
|
6247
|
+
this.responseWaitTimeout = null;
|
|
6248
|
+
this.responseWaitTimeoutMs = null;
|
|
6249
|
+
this.failPendingResponseWait(new Error("Timeout waiting for response to complete"));
|
|
6250
|
+
}, remainingMs);
|
|
6251
|
+
}
|
|
6252
|
+
scheduleToolCallTimeout(toolCallId) {
|
|
6253
|
+
const spec = this.toolCallTimeoutSpecs.get(toolCallId);
|
|
6254
|
+
if (!spec) {
|
|
6255
|
+
return;
|
|
6256
|
+
}
|
|
6257
|
+
const existing = this.toolCallTimeouts.get(toolCallId);
|
|
6258
|
+
if (existing) {
|
|
6259
|
+
clearTimeout(existing);
|
|
6260
|
+
}
|
|
6261
|
+
const timeout = setTimeout(() => {
|
|
6262
|
+
const duration = formatDuration(this.toolCallStartTimes.get(toolCallId));
|
|
6263
|
+
const timeoutLabel = formatToolCallTimeoutLimit(spec.timeoutMs);
|
|
6264
|
+
const timeoutDetail = `Tool call ${spec.toolName} timed out after ${timeoutLabel}`;
|
|
6265
|
+
logger.debug(`[AcpBackend] \u23F1\uFE0F Tool call TIMEOUT (from ${spec.source}): ${toolCallId} (${spec.toolKind}) after ${timeoutLabel} without progress - Duration: ${duration}, failing current turn`);
|
|
6266
|
+
this.activeToolCalls.delete(toolCallId);
|
|
6267
|
+
this.toolCallStartTimes.delete(toolCallId);
|
|
6268
|
+
this.clearToolCallTimeout(toolCallId);
|
|
6269
|
+
this.clearIdleTimeoutState();
|
|
6270
|
+
const streamedOutput = renderToolOutput(this.toolCallOutputs.get(toolCallId));
|
|
6271
|
+
this.toolCallOutputs.delete(toolCallId);
|
|
6272
|
+
this.emit({
|
|
6273
|
+
type: "tool-result",
|
|
6274
|
+
toolName: spec.toolName,
|
|
6275
|
+
result: streamedOutput ? {
|
|
6276
|
+
stdout: streamedOutput,
|
|
6277
|
+
error: timeoutDetail,
|
|
6278
|
+
status: "failed",
|
|
6279
|
+
timedOut: true
|
|
6280
|
+
} : {
|
|
6281
|
+
error: timeoutDetail,
|
|
6282
|
+
status: "failed",
|
|
6283
|
+
timedOut: true
|
|
6284
|
+
},
|
|
6285
|
+
callId: toolCallId
|
|
6286
|
+
});
|
|
6287
|
+
this.emit({
|
|
6288
|
+
type: "status",
|
|
6289
|
+
status: "error",
|
|
6290
|
+
detail: timeoutDetail
|
|
6291
|
+
});
|
|
6292
|
+
this.failPendingResponseWait(new Error(timeoutDetail));
|
|
6293
|
+
}, spec.timeoutMs);
|
|
6294
|
+
this.toolCallTimeouts.set(toolCallId, timeout);
|
|
6295
|
+
}
|
|
6296
|
+
armToolCallTimeout(spec) {
|
|
6297
|
+
this.toolCallTimeoutSpecs.set(spec.toolCallId, spec);
|
|
6298
|
+
this.scheduleToolCallTimeout(spec.toolCallId);
|
|
6299
|
+
}
|
|
6300
|
+
clearToolCallTimeout(toolCallId) {
|
|
6301
|
+
const timeout = this.toolCallTimeouts.get(toolCallId);
|
|
6302
|
+
const hadTimeout = Boolean(timeout);
|
|
6303
|
+
if (timeout) {
|
|
6304
|
+
clearTimeout(timeout);
|
|
6305
|
+
this.toolCallTimeouts.delete(toolCallId);
|
|
6306
|
+
}
|
|
6307
|
+
this.toolCallTimeoutSpecs.delete(toolCallId);
|
|
6308
|
+
return hadTimeout;
|
|
6309
|
+
}
|
|
6310
|
+
refreshActiveToolCallTimeouts() {
|
|
6311
|
+
for (const toolCallId of this.activeToolCalls) {
|
|
6312
|
+
if (this.toolCallTimeoutSpecs.has(toolCallId)) {
|
|
6313
|
+
this.scheduleToolCallTimeout(toolCallId);
|
|
6314
|
+
}
|
|
6315
|
+
}
|
|
6316
|
+
}
|
|
6317
|
+
markResponseProgress(opts = {}) {
|
|
6318
|
+
this.responseLastProgressAt = Date.now();
|
|
6319
|
+
if (opts.refreshToolTimeouts !== false) {
|
|
6320
|
+
this.refreshActiveToolCallTimeouts();
|
|
6321
|
+
}
|
|
6322
|
+
if (this.waitingForResponse && this.responseWaitTimeoutMs != null) {
|
|
6323
|
+
this.armResponseWaitTimeout(this.responseWaitTimeoutMs);
|
|
6324
|
+
}
|
|
6325
|
+
}
|
|
6207
6326
|
clearToolCallTracking() {
|
|
6208
6327
|
this.activeToolCalls.clear();
|
|
6209
6328
|
for (const timeout of this.toolCallTimeouts.values()) {
|
|
6210
6329
|
clearTimeout(timeout);
|
|
6211
6330
|
}
|
|
6212
6331
|
this.toolCallTimeouts.clear();
|
|
6332
|
+
this.toolCallTimeoutSpecs.clear();
|
|
6213
6333
|
this.toolCallStartTimes.clear();
|
|
6214
6334
|
this.toolCallIdToNameMap.clear();
|
|
6215
6335
|
this.toolCallOutputs.clear();
|
|
@@ -6219,6 +6339,7 @@ class AcpBackend {
|
|
|
6219
6339
|
this.responseCompletionOutcome = null;
|
|
6220
6340
|
this.responseCompletionError = null;
|
|
6221
6341
|
this.sawSessionUpdateSincePrompt = false;
|
|
6342
|
+
this.resetResponseWaitTracking();
|
|
6222
6343
|
this.clearIdleTimeoutState();
|
|
6223
6344
|
this.clearPostPromptCompletionIdleTimeout();
|
|
6224
6345
|
this.clearToolCallTracking();
|
|
@@ -6230,6 +6351,7 @@ class AcpBackend {
|
|
|
6230
6351
|
this.responseCompletionError = error;
|
|
6231
6352
|
this.responseCompletionOutcome = null;
|
|
6232
6353
|
this.waitingForResponse = false;
|
|
6354
|
+
this.resetResponseWaitTracking();
|
|
6233
6355
|
this.clearPostPromptCompletionIdleTimeout();
|
|
6234
6356
|
if (this.idleRejecter) {
|
|
6235
6357
|
this.idleRejecter(error);
|
|
@@ -6239,6 +6361,7 @@ class AcpBackend {
|
|
|
6239
6361
|
}
|
|
6240
6362
|
settleResponseWaiter(outcome) {
|
|
6241
6363
|
const hasActiveWaiter = Boolean(this.idleResolver || this.idleRejecter);
|
|
6364
|
+
this.resetResponseWaitTracking();
|
|
6242
6365
|
if (!this.waitingForResponse && !hasActiveWaiter) {
|
|
6243
6366
|
return;
|
|
6244
6367
|
}
|
|
@@ -6710,6 +6833,8 @@ ${recentStderrExcerpt}`);
|
|
|
6710
6833
|
emit: (msg) => this.emit(msg),
|
|
6711
6834
|
emitIdleStatus: () => this.emitIdleStatus(),
|
|
6712
6835
|
failPendingResponseWait: (error) => this.failPendingResponseWait(error),
|
|
6836
|
+
armToolCallTimeout: (spec) => this.armToolCallTimeout(spec),
|
|
6837
|
+
clearToolCallTimeout: (toolCallId) => this.clearToolCallTimeout(toolCallId),
|
|
6713
6838
|
clearIdleTimeout: () => {
|
|
6714
6839
|
if (this.idleTimeout) {
|
|
6715
6840
|
clearTimeout(this.idleTimeout);
|
|
@@ -6750,6 +6875,7 @@ ${recentStderrExcerpt}`);
|
|
|
6750
6875
|
this.clearPostPromptCompletionIdleTimeout();
|
|
6751
6876
|
for (const update of updates) {
|
|
6752
6877
|
const sessionUpdateType = update.sessionUpdate;
|
|
6878
|
+
this.markResponseProgress();
|
|
6753
6879
|
if (sessionUpdateType !== "agent_message_chunk" && sessionUpdateType !== "tool_call_update") {
|
|
6754
6880
|
logger.debug(`[AcpBackend] Received session update: ${sessionUpdateType}`, JSON.stringify({
|
|
6755
6881
|
sessionUpdate: sessionUpdateType,
|
|
@@ -6813,6 +6939,7 @@ ${recentStderrExcerpt}`);
|
|
|
6813
6939
|
this.resetResponseTrackingForNewPrompt();
|
|
6814
6940
|
this.emit({ type: "status", status: "running" });
|
|
6815
6941
|
this.waitingForResponse = true;
|
|
6942
|
+
this.markResponseProgress({ refreshToolTimeouts: false });
|
|
6816
6943
|
try {
|
|
6817
6944
|
logger.debug(`[AcpBackend] Sending prompt (length: ${prompt.length}): ${prompt.substring(0, 100)}...`);
|
|
6818
6945
|
logger.debug(`[AcpBackend] Full prompt: ${prompt}`);
|
|
@@ -6873,7 +7000,7 @@ ${recentStderrExcerpt}`);
|
|
|
6873
7000
|
* Wait for the response to complete (idle status after all chunks received)
|
|
6874
7001
|
* Call this after sendPrompt to wait for Gemini to finish responding
|
|
6875
7002
|
*/
|
|
6876
|
-
async waitForResponseComplete(timeoutMs =
|
|
7003
|
+
async waitForResponseComplete(timeoutMs = 10 * 6e4) {
|
|
6877
7004
|
if (this.responseCompletionError) {
|
|
6878
7005
|
throw this.responseCompletionError;
|
|
6879
7006
|
}
|
|
@@ -6889,26 +7016,19 @@ ${recentStderrExcerpt}`);
|
|
|
6889
7016
|
return;
|
|
6890
7017
|
}
|
|
6891
7018
|
return new Promise((resolve, reject) => {
|
|
6892
|
-
const timeout = setTimeout(() => {
|
|
6893
|
-
this.idleResolver = null;
|
|
6894
|
-
this.idleRejecter = null;
|
|
6895
|
-
this.waitingForResponse = false;
|
|
6896
|
-
reject(new Error("Timeout waiting for response to complete"));
|
|
6897
|
-
}, timeoutMs);
|
|
6898
7019
|
this.idleResolver = () => {
|
|
6899
|
-
clearTimeout(timeout);
|
|
6900
7020
|
this.idleResolver = null;
|
|
6901
7021
|
this.idleRejecter = null;
|
|
6902
7022
|
this.waitingForResponse = false;
|
|
6903
7023
|
resolve();
|
|
6904
7024
|
};
|
|
6905
7025
|
this.idleRejecter = (error) => {
|
|
6906
|
-
clearTimeout(timeout);
|
|
6907
7026
|
this.idleResolver = null;
|
|
6908
7027
|
this.idleRejecter = null;
|
|
6909
7028
|
this.waitingForResponse = false;
|
|
6910
7029
|
reject(error);
|
|
6911
7030
|
};
|
|
7031
|
+
this.armResponseWaitTimeout(timeoutMs);
|
|
6912
7032
|
});
|
|
6913
7033
|
}
|
|
6914
7034
|
/**
|
|
@@ -8394,7 +8514,7 @@ class ClaudeCodeBackend {
|
|
|
8394
8514
|
logger.debug("[ClaudeRuntimeBackend] Error interrupting Claude query:", error);
|
|
8395
8515
|
}
|
|
8396
8516
|
}
|
|
8397
|
-
async waitForResponseComplete(timeoutMs =
|
|
8517
|
+
async waitForResponseComplete(timeoutMs = 10 * 6e4) {
|
|
8398
8518
|
if (this.responseCompletionOutcome) {
|
|
8399
8519
|
const outcome = this.responseCompletionOutcome;
|
|
8400
8520
|
if (outcome.kind === "rejected") {
|
|
@@ -8974,11 +9094,11 @@ var launch = /*#__PURE__*/Object.freeze({
|
|
|
8974
9094
|
|
|
8975
9095
|
const unifiedProviderExecutors = {
|
|
8976
9096
|
claude: async (opts) => {
|
|
8977
|
-
const { runClaude } = await import('./runClaude-
|
|
9097
|
+
const { runClaude } = await import('./runClaude-DpZ95Twb.mjs');
|
|
8978
9098
|
await runClaude(opts.credentials, opts.claudeOptions ?? {});
|
|
8979
9099
|
},
|
|
8980
9100
|
codex: async (opts) => {
|
|
8981
|
-
const { runCodex } = await import('./runCodex-
|
|
9101
|
+
const { runCodex } = await import('./runCodex-CJwaep2R.mjs');
|
|
8982
9102
|
await runCodex({
|
|
8983
9103
|
credentials: opts.credentials,
|
|
8984
9104
|
startedBy: opts.startedBy,
|
|
@@ -8987,7 +9107,7 @@ const unifiedProviderExecutors = {
|
|
|
8987
9107
|
});
|
|
8988
9108
|
},
|
|
8989
9109
|
gemini: async (opts) => {
|
|
8990
|
-
const { runGemini } = await import('./runGemini-
|
|
9110
|
+
const { runGemini } = await import('./runGemini-BehqjM73.mjs');
|
|
8991
9111
|
await runGemini({
|
|
8992
9112
|
credentials: opts.credentials,
|
|
8993
9113
|
startedBy: opts.startedBy
|
|
@@ -9063,7 +9183,7 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
9063
9183
|
return;
|
|
9064
9184
|
} else if (subcommand === "runtime") {
|
|
9065
9185
|
if (args[1] === "providers") {
|
|
9066
|
-
const { renderRuntimeProviders } = await import('./command
|
|
9186
|
+
const { renderRuntimeProviders } = await import('./command-mTWwCqTY.mjs');
|
|
9067
9187
|
console.log(renderRuntimeProviders());
|
|
9068
9188
|
return;
|
|
9069
9189
|
}
|
|
@@ -9241,8 +9361,8 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
9241
9361
|
const projectId = args[3];
|
|
9242
9362
|
try {
|
|
9243
9363
|
const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
|
|
9244
|
-
const { readCredentials: readCredentials2 } = await import('./persistence-
|
|
9245
|
-
const { ApiClient: ApiClient2 } = await import('./api-
|
|
9364
|
+
const { readCredentials: readCredentials2 } = await import('./persistence-MSy70is3.mjs');
|
|
9365
|
+
const { ApiClient: ApiClient2 } = await import('./api-w_CUxb9Q.mjs').then(function (n) { return n.v; });
|
|
9246
9366
|
let userEmail = void 0;
|
|
9247
9367
|
try {
|
|
9248
9368
|
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-
|
|
5
|
-
require('./persistence-
|
|
4
|
+
require('./api-Bd-MnOS4.cjs');
|
|
5
|
+
require('./persistence-BL06LLVz.cjs');
|
|
6
6
|
require('zod');
|
|
7
|
-
require('./index-
|
|
7
|
+
require('./index-BQmJ4NAa.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-
|
|
3
|
-
import './persistence-
|
|
2
|
+
import './api-w_CUxb9Q.mjs';
|
|
3
|
+
import './persistence-MSy70is3.mjs';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import './index-
|
|
5
|
+
import './index-GuXV-pxB.mjs';
|
|
6
6
|
import 'node:child_process';
|
|
7
7
|
import 'node:fs';
|
|
8
8
|
import 'cross-spawn';
|