happy-imou-cloud 2.1.47 → 2.1.49
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/dist/{BaseReasoningProcessor-KXIi0QF_.mjs → BaseReasoningProcessor-CAVeOdyo.mjs} +2 -2
- package/dist/{BaseReasoningProcessor-CBbzF7oj.cjs → BaseReasoningProcessor-Dn9NcoHz.cjs} +2 -2
- package/dist/{ProviderSelectionHandler-CJLlwlAu.cjs → ProviderSelectionHandler-BJJc7qOR.cjs} +2 -2
- package/dist/{ProviderSelectionHandler-DzYObYrV.mjs → ProviderSelectionHandler-DIYidT13.mjs} +2 -2
- package/dist/{api-CVuTajTL.cjs → api-D7nAeZi7.cjs} +3 -3
- package/dist/{api-D3vYIva3.mjs → api-DnqaNvyV.mjs} +3 -3
- package/dist/{command-fcJ-4Yq3.mjs → command-CzfRRhVe.mjs} +2 -2
- package/dist/{command-BZRQuZsh.cjs → command-VcH4hbhi.cjs} +2 -2
- package/dist/{index-Cp1I5I3U.mjs → index-7Z93BoVn.mjs} +378 -33
- package/dist/{index-CyW9A7hx.cjs → index-xa1kwZoj.cjs} +377 -32
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +88 -86
- package/dist/lib.d.mts +88 -86
- package/dist/lib.mjs +1 -1
- package/dist/{registerKillSessionHandler-8C_Wrgor.cjs → registerKillSessionHandler-CfCya6si.cjs} +2 -2
- package/dist/{registerKillSessionHandler-OhhMUuCQ.mjs → registerKillSessionHandler-DLDg2EES.mjs} +2 -2
- package/dist/{runClaude-CfdT_ccS.cjs → runClaude-BBGNmGj6.cjs} +4 -4
- package/dist/{runClaude-BviM1Wl5.mjs → runClaude-zCwRhpOw.mjs} +4 -4
- package/dist/{runCodex-Dx3osc7U.mjs → runCodex-BbgLVjb9.mjs} +80 -11
- package/dist/{runCodex-B-t0yy4k.cjs → runCodex-jUU6U2tZ.cjs} +80 -11
- package/dist/{runGemini-DZ5-uzB9.cjs → runGemini-C0NT8MHK.cjs} +4 -4
- package/dist/{runGemini-CnJ75Q--.mjs → runGemini-DcwNsudA.mjs} +4 -4
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chalk = require('chalk');
|
|
4
|
-
var persistence = require('./api-
|
|
4
|
+
var persistence = require('./api-D7nAeZi7.cjs');
|
|
5
5
|
var z = require('zod');
|
|
6
6
|
var fs$2 = require('fs/promises');
|
|
7
7
|
var os$1 = require('os');
|
|
@@ -52,7 +52,7 @@ async function openBrowser(url) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
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-
|
|
55
|
+
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-xa1kwZoj.cjs', document.baseURI).href)));
|
|
56
56
|
const QRCode = require$1("qrcode-terminal/vendor/QRCode");
|
|
57
57
|
const QRErrorCorrectLevel = require$1("qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel");
|
|
58
58
|
const pendingTempFiles = /* @__PURE__ */ new Set();
|
|
@@ -617,7 +617,7 @@ function setupCleanupHandlers() {
|
|
|
617
617
|
});
|
|
618
618
|
}
|
|
619
619
|
|
|
620
|
-
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-
|
|
620
|
+
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-xa1kwZoj.cjs', document.baseURI).href))));
|
|
621
621
|
function projectPath() {
|
|
622
622
|
const path = path$1.resolve(__dirname$2, "..");
|
|
623
623
|
return path;
|
|
@@ -1569,7 +1569,8 @@ function startDaemonControlServer({
|
|
|
1569
1569
|
body: z.z.object({
|
|
1570
1570
|
directory: z.z.string(),
|
|
1571
1571
|
sessionId: z.z.string().optional(),
|
|
1572
|
-
agent: z.z.enum(["claude", "codex", "gemini"]).optional()
|
|
1572
|
+
agent: z.z.enum(["claude", "codex", "gemini"]).optional(),
|
|
1573
|
+
launchMode: z.z.enum(["background", "terminalWindow", "localTerminal"]).optional()
|
|
1573
1574
|
}),
|
|
1574
1575
|
response: {
|
|
1575
1576
|
200: z.z.object({
|
|
@@ -1590,9 +1591,9 @@ function startDaemonControlServer({
|
|
|
1590
1591
|
}
|
|
1591
1592
|
}
|
|
1592
1593
|
}, async (request, reply) => {
|
|
1593
|
-
const { directory, sessionId, agent } = request.body;
|
|
1594
|
-
persistence.logger.debug(`[CONTROL SERVER] Spawn session request: dir=${directory}, sessionId=${sessionId || "new"}, agent=${agent || "claude"}`);
|
|
1595
|
-
const result = await spawnSession({ directory, sessionId, agent });
|
|
1594
|
+
const { directory, sessionId, agent, launchMode } = request.body;
|
|
1595
|
+
persistence.logger.debug(`[CONTROL SERVER] Spawn session request: dir=${directory}, sessionId=${sessionId || "new"}, agent=${agent || "claude"}, launchMode=${launchMode || "background"}`);
|
|
1596
|
+
const result = await spawnSession({ directory, sessionId, agent, launchMode });
|
|
1596
1597
|
switch (result.type) {
|
|
1597
1598
|
case "success":
|
|
1598
1599
|
if (!result.sessionId) {
|
|
@@ -2336,20 +2337,37 @@ function resolveDaemonSpawnAgent(agent) {
|
|
|
2336
2337
|
throw new Error(`Unsupported agent type: '${agent}'. Please update your CLI to the latest version.`);
|
|
2337
2338
|
}
|
|
2338
2339
|
}
|
|
2339
|
-
function buildDaemonSpawnArgs(agent,
|
|
2340
|
+
function buildDaemonSpawnArgs(agent, optionsOrResume) {
|
|
2341
|
+
const options = isLegacyResumeOptions(optionsOrResume) ? { resume: optionsOrResume } : optionsOrResume ?? {};
|
|
2342
|
+
const startingMode = options.startingMode ?? "remote";
|
|
2343
|
+
const startedBy = options.startedBy ?? "daemon";
|
|
2344
|
+
const resolvedAgent = resolveDaemonSpawnAgent(agent);
|
|
2340
2345
|
const args = [
|
|
2341
|
-
|
|
2346
|
+
resolvedAgent,
|
|
2342
2347
|
"--happy-starting-mode",
|
|
2343
|
-
|
|
2348
|
+
startingMode,
|
|
2344
2349
|
"--started-by",
|
|
2345
|
-
|
|
2350
|
+
startedBy
|
|
2346
2351
|
];
|
|
2347
|
-
const providerSessionId = typeof resume?.providerSessionId === "string" ? resume.providerSessionId.trim() : "";
|
|
2348
|
-
if (providerSessionId.length > 0) {
|
|
2352
|
+
const providerSessionId = typeof options.resume?.providerSessionId === "string" ? options.resume.providerSessionId.trim() : "";
|
|
2353
|
+
if (providerSessionId.length > 0 && supportsProviderResumeArg(resolvedAgent)) {
|
|
2349
2354
|
args.push("--resume", providerSessionId);
|
|
2350
2355
|
}
|
|
2351
2356
|
return args;
|
|
2352
2357
|
}
|
|
2358
|
+
function supportsProviderResumeArg(agent) {
|
|
2359
|
+
return agent === "claude" || agent === "codex";
|
|
2360
|
+
}
|
|
2361
|
+
function buildTerminalWindowSpawnArgs(agent, resume) {
|
|
2362
|
+
return buildDaemonSpawnArgs(agent, {
|
|
2363
|
+
resume,
|
|
2364
|
+
startingMode: "local",
|
|
2365
|
+
startedBy: "terminal"
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
function isLegacyResumeOptions(value) {
|
|
2369
|
+
return Boolean(value && "providerSessionId" in value);
|
|
2370
|
+
}
|
|
2353
2371
|
|
|
2354
2372
|
const SPAWN_SESSION_ERROR_CODES = {
|
|
2355
2373
|
INVALID_REQUEST: "INVALID_REQUEST",
|
|
@@ -2412,6 +2430,157 @@ function buildDaemonChildEnv(baseEnv, extraEnv) {
|
|
|
2412
2430
|
return childEnv;
|
|
2413
2431
|
}
|
|
2414
2432
|
|
|
2433
|
+
function quotePosix(value) {
|
|
2434
|
+
return `'${value.replace(/'/g, `'"'"'`)}'`;
|
|
2435
|
+
}
|
|
2436
|
+
function quoteAppleScriptString(value) {
|
|
2437
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
2438
|
+
}
|
|
2439
|
+
function quoteWindowsCmd(value) {
|
|
2440
|
+
return `"${value.replace(/(["^&|<>()%])/g, "^$1")}"`;
|
|
2441
|
+
}
|
|
2442
|
+
function buildRuntimeInvocation(args, platform, entrypointOverride) {
|
|
2443
|
+
const projectRoot = projectPath();
|
|
2444
|
+
const entrypoint = entrypointOverride || path.join(projectRoot, "dist", "index.mjs");
|
|
2445
|
+
const runtime = isBun() ? "bun" : "node";
|
|
2446
|
+
const runtimeArgs = ["--no-warnings", "--no-deprecation", entrypoint, ...args];
|
|
2447
|
+
const commandParts = [runtime, ...runtimeArgs];
|
|
2448
|
+
if (platform === "win32") {
|
|
2449
|
+
return commandParts.map(quoteWindowsCmd).join(" ");
|
|
2450
|
+
}
|
|
2451
|
+
return commandParts.map(quotePosix).join(" ");
|
|
2452
|
+
}
|
|
2453
|
+
function buildUserFacingPreview(args) {
|
|
2454
|
+
const agent = args[0];
|
|
2455
|
+
if (agent === "claude" || agent === "codex" || agent === "gemini") {
|
|
2456
|
+
return `hicloud ${agent}`;
|
|
2457
|
+
}
|
|
2458
|
+
return `hicloud ${args.join(" ")}`.trim();
|
|
2459
|
+
}
|
|
2460
|
+
function buildPathWithProjectBin(env, platform) {
|
|
2461
|
+
const binPath = path.join(projectPath(), "node_modules", ".bin");
|
|
2462
|
+
const pathDelimiter = platform === "win32" ? ";" : path.delimiter;
|
|
2463
|
+
const currentPath = env?.PATH || env?.Path || process.env.PATH || "";
|
|
2464
|
+
return currentPath ? `${binPath}${pathDelimiter}${currentPath}` : binPath;
|
|
2465
|
+
}
|
|
2466
|
+
function isValidEnvironmentVariableName(name) {
|
|
2467
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);
|
|
2468
|
+
}
|
|
2469
|
+
function escapeWindowsBatchSetValue(value) {
|
|
2470
|
+
return value.replace(/\r?\n/g, "").replace(/%/g, "%%");
|
|
2471
|
+
}
|
|
2472
|
+
function collectLaunchEnv(env, platform) {
|
|
2473
|
+
const result = {};
|
|
2474
|
+
for (const [key, value] of Object.entries(env || {})) {
|
|
2475
|
+
if (typeof value === "string" && isValidEnvironmentVariableName(key)) {
|
|
2476
|
+
result[key] = value;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
result.PATH = buildPathWithProjectBin(env, platform);
|
|
2480
|
+
return result;
|
|
2481
|
+
}
|
|
2482
|
+
function buildTerminalLaunchScriptContent(options) {
|
|
2483
|
+
const platform = options.platform || process.platform;
|
|
2484
|
+
const launchEnv = collectLaunchEnv(options.env, platform);
|
|
2485
|
+
const preview = buildUserFacingPreview(options.args);
|
|
2486
|
+
const runtimeInvocation = buildRuntimeInvocation(options.args, platform, options.entrypoint);
|
|
2487
|
+
if (platform === "win32") {
|
|
2488
|
+
const envLines2 = Object.entries(launchEnv).map(([key, value]) => `set "${key}=${escapeWindowsBatchSetValue(value)}"`).join("\r\n");
|
|
2489
|
+
return [
|
|
2490
|
+
"@echo off",
|
|
2491
|
+
"setlocal",
|
|
2492
|
+
envLines2,
|
|
2493
|
+
`cd /d ${quoteWindowsCmd(options.cwd)}`,
|
|
2494
|
+
`echo $ ${preview}`,
|
|
2495
|
+
runtimeInvocation,
|
|
2496
|
+
"echo.",
|
|
2497
|
+
"echo Happy session command exited. You can close this window.",
|
|
2498
|
+
'del "%~f0" >nul 2>nul',
|
|
2499
|
+
"endlocal",
|
|
2500
|
+
""
|
|
2501
|
+
].join("\r\n");
|
|
2502
|
+
}
|
|
2503
|
+
const envLines = Object.entries(launchEnv).map(([key, value]) => `export ${key}=${quotePosix(value)}`).join("\n");
|
|
2504
|
+
return [
|
|
2505
|
+
"#!/usr/bin/env bash",
|
|
2506
|
+
"set +e",
|
|
2507
|
+
'rm -f "$0" >/dev/null 2>&1 || true',
|
|
2508
|
+
envLines,
|
|
2509
|
+
`cd ${quotePosix(options.cwd)} || exit $?`,
|
|
2510
|
+
`echo ${quotePosix(`$ ${preview}`)}`,
|
|
2511
|
+
runtimeInvocation,
|
|
2512
|
+
"status=$?",
|
|
2513
|
+
"echo",
|
|
2514
|
+
'echo "Happy session command exited with status ${status}. You can close this window."',
|
|
2515
|
+
'exec "${SHELL:-bash}" -l',
|
|
2516
|
+
""
|
|
2517
|
+
].join("\n");
|
|
2518
|
+
}
|
|
2519
|
+
function createTerminalLaunchScript(options) {
|
|
2520
|
+
if (options.scriptPath) {
|
|
2521
|
+
return options.scriptPath;
|
|
2522
|
+
}
|
|
2523
|
+
const platform = options.platform || process.platform;
|
|
2524
|
+
const scriptDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "happy-terminal-launch-"));
|
|
2525
|
+
const scriptPath = path.join(scriptDirectory, platform === "win32" ? "launch.cmd" : "launch.sh");
|
|
2526
|
+
fs.writeFileSync(scriptPath, buildTerminalLaunchScriptContent({ ...options, platform }), { encoding: "utf8", mode: 448 });
|
|
2527
|
+
if (platform !== "win32") {
|
|
2528
|
+
fs.chmodSync(scriptPath, 448);
|
|
2529
|
+
}
|
|
2530
|
+
return scriptPath;
|
|
2531
|
+
}
|
|
2532
|
+
function buildTerminalWindowLaunchCommand(options) {
|
|
2533
|
+
const platform = options.platform || process.platform;
|
|
2534
|
+
const scriptPath = createTerminalLaunchScript({ ...options, platform });
|
|
2535
|
+
const preview = buildUserFacingPreview(options.args);
|
|
2536
|
+
if (platform === "win32") {
|
|
2537
|
+
return {
|
|
2538
|
+
command: "cmd.exe",
|
|
2539
|
+
args: ["/d", "/s", "/c", `start "" cmd.exe /d /s /k ${quoteWindowsCmd(scriptPath)}`],
|
|
2540
|
+
options: {
|
|
2541
|
+
cwd: options.cwd,
|
|
2542
|
+
detached: true,
|
|
2543
|
+
stdio: "ignore",
|
|
2544
|
+
env: options.env,
|
|
2545
|
+
windowsHide: false
|
|
2546
|
+
},
|
|
2547
|
+
preview,
|
|
2548
|
+
scriptPath
|
|
2549
|
+
};
|
|
2550
|
+
}
|
|
2551
|
+
if (platform === "darwin") {
|
|
2552
|
+
const appleScript = `tell application "Terminal" to do script ${quoteAppleScriptString(`bash ${quotePosix(scriptPath)}`)}`;
|
|
2553
|
+
return {
|
|
2554
|
+
command: "osascript",
|
|
2555
|
+
args: ["-e", appleScript],
|
|
2556
|
+
options: {
|
|
2557
|
+
cwd: options.cwd,
|
|
2558
|
+
detached: true,
|
|
2559
|
+
stdio: "ignore",
|
|
2560
|
+
env: options.env
|
|
2561
|
+
},
|
|
2562
|
+
preview,
|
|
2563
|
+
scriptPath
|
|
2564
|
+
};
|
|
2565
|
+
}
|
|
2566
|
+
return {
|
|
2567
|
+
command: "x-terminal-emulator",
|
|
2568
|
+
args: ["-e", "bash", scriptPath],
|
|
2569
|
+
options: {
|
|
2570
|
+
cwd: options.cwd,
|
|
2571
|
+
detached: true,
|
|
2572
|
+
stdio: "ignore",
|
|
2573
|
+
env: options.env
|
|
2574
|
+
},
|
|
2575
|
+
preview,
|
|
2576
|
+
scriptPath
|
|
2577
|
+
};
|
|
2578
|
+
}
|
|
2579
|
+
function spawnHappyCLIInTerminalWindow(options) {
|
|
2580
|
+
const launchCommand = buildTerminalWindowLaunchCommand(options);
|
|
2581
|
+
return node_child_process.spawn(launchCommand.command, launchCommand.args, launchCommand.options);
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2415
2584
|
const DIFFERENT_DAEMON_RUNNING_MESSAGE = "A different daemon was started without killing us. We should kill ourselves.";
|
|
2416
2585
|
function pruneStaleTrackedSessions({
|
|
2417
2586
|
trackedSessionPids,
|
|
@@ -3569,6 +3738,28 @@ async function startDaemon() {
|
|
|
3569
3738
|
let api = null;
|
|
3570
3739
|
const pidToTrackedSession = /* @__PURE__ */ new Map();
|
|
3571
3740
|
const pidToAwaiter = /* @__PURE__ */ new Map();
|
|
3741
|
+
const terminalLaunchAwaiters = /* @__PURE__ */ new Map();
|
|
3742
|
+
const normalizePathForSessionMatch = (value) => (value || "").trim().replace(/[\\/]+$/, "");
|
|
3743
|
+
const resolveTerminalLaunchAwaiter = (sessionId, sessionMetadata) => {
|
|
3744
|
+
const reportedDirectory = normalizePathForSessionMatch(sessionMetadata.path);
|
|
3745
|
+
const reportedFlavor = resolveRecoverySpawnAgent(sessionMetadata.flavor);
|
|
3746
|
+
const now = Date.now();
|
|
3747
|
+
for (const [awaiterId, awaiter] of terminalLaunchAwaiters.entries()) {
|
|
3748
|
+
if (awaiter.startedAt - 5e3 > now) {
|
|
3749
|
+
continue;
|
|
3750
|
+
}
|
|
3751
|
+
const directoryMatches = normalizePathForSessionMatch(awaiter.directory) === reportedDirectory;
|
|
3752
|
+
const agentMatches = !awaiter.agent || !reportedFlavor || awaiter.agent === reportedFlavor;
|
|
3753
|
+
if (!directoryMatches || !agentMatches) {
|
|
3754
|
+
continue;
|
|
3755
|
+
}
|
|
3756
|
+
terminalLaunchAwaiters.delete(awaiterId);
|
|
3757
|
+
awaiter.resolve({ type: "success", sessionId });
|
|
3758
|
+
persistence.logger.debug(`[DAEMON RUN] Resolved terminal window session awaiter ${awaiterId} for session ${sessionId}`);
|
|
3759
|
+
return true;
|
|
3760
|
+
}
|
|
3761
|
+
return false;
|
|
3762
|
+
};
|
|
3572
3763
|
const getCurrentChildren = () => Array.from(pidToTrackedSession.values());
|
|
3573
3764
|
let userScopedObserver = null;
|
|
3574
3765
|
const removeTrackedSession = (pid, archiveReason) => {
|
|
@@ -3617,6 +3808,7 @@ async function startDaemon() {
|
|
|
3617
3808
|
};
|
|
3618
3809
|
pidToTrackedSession.set(pid, trackedSession);
|
|
3619
3810
|
persistence.logger.debug(`[DAEMON RUN] Registered externally-started session ${sessionId}`);
|
|
3811
|
+
resolveTerminalLaunchAwaiter(sessionId, sessionMetadata);
|
|
3620
3812
|
}
|
|
3621
3813
|
};
|
|
3622
3814
|
const spawnSession = async (options) => {
|
|
@@ -3726,6 +3918,84 @@ async function startDaemon() {
|
|
|
3726
3918
|
errorMessage: spawnError.errorMessage
|
|
3727
3919
|
};
|
|
3728
3920
|
}
|
|
3921
|
+
if (options.launchMode === "terminalWindow" || options.launchMode === "localTerminal") {
|
|
3922
|
+
persistence.logger.debug(`[DAEMON RUN] Using visible terminal window spawning`);
|
|
3923
|
+
let args;
|
|
3924
|
+
try {
|
|
3925
|
+
args = buildTerminalWindowSpawnArgs(options.agent, options.resume);
|
|
3926
|
+
} catch (error) {
|
|
3927
|
+
const spawnError = createSpawnSessionError(
|
|
3928
|
+
SPAWN_SESSION_ERROR_CODES.INVALID_REQUEST,
|
|
3929
|
+
error instanceof Error ? error.message : String(error)
|
|
3930
|
+
);
|
|
3931
|
+
return {
|
|
3932
|
+
type: spawnError.type,
|
|
3933
|
+
errorMessage: spawnError.errorMessage
|
|
3934
|
+
};
|
|
3935
|
+
}
|
|
3936
|
+
const terminalEnv = buildDaemonChildEnv(process.env, extraEnv);
|
|
3937
|
+
const terminalProcess = spawnHappyCLIInTerminalWindow({
|
|
3938
|
+
cwd: directory,
|
|
3939
|
+
args,
|
|
3940
|
+
env: terminalEnv
|
|
3941
|
+
});
|
|
3942
|
+
if (!terminalProcess.pid) {
|
|
3943
|
+
persistence.logger.debug("[DAEMON RUN] Failed to spawn terminal window - no PID returned");
|
|
3944
|
+
const spawnError = createSpawnSessionError(
|
|
3945
|
+
SPAWN_SESSION_ERROR_CODES.SPAWN_NO_PID,
|
|
3946
|
+
"Failed to spawn terminal window - no PID returned"
|
|
3947
|
+
);
|
|
3948
|
+
return {
|
|
3949
|
+
type: spawnError.type,
|
|
3950
|
+
errorMessage: spawnError.errorMessage
|
|
3951
|
+
};
|
|
3952
|
+
}
|
|
3953
|
+
persistence.logger.debug(`[DAEMON RUN] Spawned terminal window process with PID ${terminalProcess.pid}`);
|
|
3954
|
+
const trackedSession = {
|
|
3955
|
+
startedBy: "daemon terminal window",
|
|
3956
|
+
happySessionId: options.sessionId,
|
|
3957
|
+
sessionIndex: null,
|
|
3958
|
+
skipDetachedManagedSessionArchive: true,
|
|
3959
|
+
pid: terminalProcess.pid,
|
|
3960
|
+
childProcess: terminalProcess,
|
|
3961
|
+
directoryCreated,
|
|
3962
|
+
message: directoryCreated ? `The path '${directory}' did not exist. We created a new folder and opened a terminal window there.` : `Opened a terminal window in '${directory}' to start the session.`
|
|
3963
|
+
};
|
|
3964
|
+
pidToTrackedSession.set(terminalProcess.pid, trackedSession);
|
|
3965
|
+
terminalProcess.on("exit", (code, signal) => {
|
|
3966
|
+
persistence.logger.debug(`[DAEMON RUN] Terminal launcher PID ${terminalProcess.pid} exited with code ${code}, signal ${signal}`);
|
|
3967
|
+
});
|
|
3968
|
+
terminalProcess.on("error", (error) => {
|
|
3969
|
+
persistence.logger.debug(`[DAEMON RUN] Terminal launcher process error:`, error);
|
|
3970
|
+
});
|
|
3971
|
+
terminalProcess.unref();
|
|
3972
|
+
const terminalAwaiterId = node_crypto.randomUUID();
|
|
3973
|
+
const launchStartedAt = Date.now();
|
|
3974
|
+
persistence.logger.debug(`[DAEMON RUN] Waiting for terminal window session webhook ${terminalAwaiterId}`);
|
|
3975
|
+
return new Promise((resolve) => {
|
|
3976
|
+
const timeout = setTimeout(() => {
|
|
3977
|
+
terminalLaunchAwaiters.delete(terminalAwaiterId);
|
|
3978
|
+
persistence.logger.debug(`[DAEMON RUN] Terminal window session webhook timeout for PID ${terminalProcess.pid}`);
|
|
3979
|
+
const spawnError = createSpawnSessionError(
|
|
3980
|
+
SPAWN_SESSION_ERROR_CODES.SESSION_WEBHOOK_TIMEOUT,
|
|
3981
|
+
`Terminal window session webhook timeout for PID ${terminalProcess.pid}`
|
|
3982
|
+
);
|
|
3983
|
+
resolve({
|
|
3984
|
+
type: spawnError.type,
|
|
3985
|
+
errorMessage: spawnError.errorMessage
|
|
3986
|
+
});
|
|
3987
|
+
}, sessionWebhookTimeoutMs);
|
|
3988
|
+
terminalLaunchAwaiters.set(terminalAwaiterId, {
|
|
3989
|
+
directory,
|
|
3990
|
+
agent: options.agent,
|
|
3991
|
+
startedAt: launchStartedAt,
|
|
3992
|
+
resolve: (result) => {
|
|
3993
|
+
clearTimeout(timeout);
|
|
3994
|
+
resolve(result);
|
|
3995
|
+
}
|
|
3996
|
+
});
|
|
3997
|
+
});
|
|
3998
|
+
}
|
|
3729
3999
|
let tmuxSessionName = extraEnv.TMUX_SESSION_NAME;
|
|
3730
4000
|
const tmuxRequested = tmuxSessionName !== void 0;
|
|
3731
4001
|
const tmuxAvailable = tmuxRequested ? await isTmuxAvailable() : false;
|
|
@@ -8798,6 +9068,69 @@ class AcpBackend {
|
|
|
8798
9068
|
}
|
|
8799
9069
|
return resolvePostPromptNoUpdatesTimeoutMs(this.transport);
|
|
8800
9070
|
}
|
|
9071
|
+
getResponseWaitTimeoutMs(timeoutMs) {
|
|
9072
|
+
if (typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0) {
|
|
9073
|
+
return Math.trunc(timeoutMs);
|
|
9074
|
+
}
|
|
9075
|
+
return readPositiveIntegerEnv("HAPPY_ACP_RESPONSE_WAIT_TIMEOUT_MS") ?? readPositiveIntegerEnv("HAPPIER_ACP_RESPONSE_WAIT_TIMEOUT_MS") ?? resolveAcpResponseWaitTimeoutMs(this.sessionPreferences.timeoutProfile);
|
|
9076
|
+
}
|
|
9077
|
+
createPromptCompletionWatchdog(timeoutMs) {
|
|
9078
|
+
let timeoutHandle = null;
|
|
9079
|
+
let cancelled = false;
|
|
9080
|
+
const promise = new Promise((resolve, reject) => {
|
|
9081
|
+
const schedule = () => {
|
|
9082
|
+
if (cancelled) {
|
|
9083
|
+
return;
|
|
9084
|
+
}
|
|
9085
|
+
if (this.responseCompletionError) {
|
|
9086
|
+
reject(this.responseCompletionError);
|
|
9087
|
+
return;
|
|
9088
|
+
}
|
|
9089
|
+
if (!this.waitingForResponse) {
|
|
9090
|
+
resolve();
|
|
9091
|
+
return;
|
|
9092
|
+
}
|
|
9093
|
+
const lastProgressAt = this.responseLastProgressAt ?? Date.now();
|
|
9094
|
+
const elapsedMs = Math.max(0, Date.now() - lastProgressAt);
|
|
9095
|
+
const remainingMs = Math.max(1, timeoutMs - elapsedMs);
|
|
9096
|
+
timeoutHandle = setTimeout(() => {
|
|
9097
|
+
timeoutHandle = null;
|
|
9098
|
+
if (cancelled) {
|
|
9099
|
+
return;
|
|
9100
|
+
}
|
|
9101
|
+
if (this.responseCompletionError) {
|
|
9102
|
+
reject(this.responseCompletionError);
|
|
9103
|
+
return;
|
|
9104
|
+
}
|
|
9105
|
+
if (!this.waitingForResponse) {
|
|
9106
|
+
resolve();
|
|
9107
|
+
return;
|
|
9108
|
+
}
|
|
9109
|
+
const latestProgressAt = this.responseLastProgressAt ?? Date.now();
|
|
9110
|
+
const latestElapsedMs = Math.max(0, Date.now() - latestProgressAt);
|
|
9111
|
+
if (latestElapsedMs < timeoutMs) {
|
|
9112
|
+
schedule();
|
|
9113
|
+
return;
|
|
9114
|
+
}
|
|
9115
|
+
const timeoutLabel = formatToolCallTimeoutLimit(timeoutMs);
|
|
9116
|
+
const error = new Error(`Timeout waiting for Codex ACP prompt to complete after ${timeoutLabel} without response progress`);
|
|
9117
|
+
this.failPendingResponseWait(error);
|
|
9118
|
+
reject(error);
|
|
9119
|
+
}, remainingMs);
|
|
9120
|
+
};
|
|
9121
|
+
schedule();
|
|
9122
|
+
});
|
|
9123
|
+
return {
|
|
9124
|
+
promise,
|
|
9125
|
+
cancel: () => {
|
|
9126
|
+
cancelled = true;
|
|
9127
|
+
if (timeoutHandle) {
|
|
9128
|
+
clearTimeout(timeoutHandle);
|
|
9129
|
+
timeoutHandle = null;
|
|
9130
|
+
}
|
|
9131
|
+
}
|
|
9132
|
+
};
|
|
9133
|
+
}
|
|
8801
9134
|
clearIdleTimeoutState() {
|
|
8802
9135
|
if (this.idleTimeout) {
|
|
8803
9136
|
clearTimeout(this.idleTimeout);
|
|
@@ -9400,10 +9733,14 @@ Recent stderr: ${recentStderrSummaryLine}` : `Signal: ${signal}`;
|
|
|
9400
9733
|
async () => {
|
|
9401
9734
|
let timeoutHandle = null;
|
|
9402
9735
|
try {
|
|
9736
|
+
const resumeSession = this.connection.resumeSession ?? this.connection.unstable_resumeSession;
|
|
9403
9737
|
const result = await raceWithProcessExit(
|
|
9404
9738
|
this.process,
|
|
9405
9739
|
() => Promise.race([
|
|
9406
|
-
(sessionOperation === "resume" ?
|
|
9740
|
+
(sessionOperation === "resume" ? resumeSession ? resumeSession(sessionRequest).then((response) => ({
|
|
9741
|
+
...response,
|
|
9742
|
+
sessionId: requestedResumeSessionId
|
|
9743
|
+
})) : Promise.reject(new Error("ACP agent advertised session resume, but this SDK connection does not expose resumeSession.")) : sessionOperation === "load" ? this.connection.loadSession(sessionRequest) : this.connection.newSession(sessionRequest)).then((res) => {
|
|
9407
9744
|
if (timeoutHandle) {
|
|
9408
9745
|
clearTimeout(timeoutHandle);
|
|
9409
9746
|
timeoutHandle = null;
|
|
@@ -9645,15 +9982,23 @@ Recent stderr: ${recentStderrSummaryLine}` : `Signal: ${signal}`;
|
|
|
9645
9982
|
prompt: [contentBlock]
|
|
9646
9983
|
};
|
|
9647
9984
|
persistence.logger.debug(`[AcpBackend] Prompt request:`, JSON.stringify(promptRequest, null, 2));
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9985
|
+
const promptWatchdog = this.createPromptCompletionWatchdog(this.getResponseWaitTimeoutMs());
|
|
9986
|
+
try {
|
|
9987
|
+
await raceWithProcessExit(
|
|
9988
|
+
this.process,
|
|
9989
|
+
() => Promise.race([
|
|
9990
|
+
this.connection.prompt(promptRequest),
|
|
9991
|
+
promptWatchdog.promise
|
|
9992
|
+
]),
|
|
9993
|
+
{
|
|
9994
|
+
agentName: this.transport.agentName,
|
|
9995
|
+
operationName: "prompt",
|
|
9996
|
+
getStderrExcerpt: () => this.getRecentStderrExcerpt()
|
|
9997
|
+
}
|
|
9998
|
+
);
|
|
9999
|
+
} finally {
|
|
10000
|
+
promptWatchdog.cancel();
|
|
10001
|
+
}
|
|
9657
10002
|
persistence.logger.debug("[AcpBackend] Prompt request sent to ACP connection");
|
|
9658
10003
|
if (this.waitingForResponse && this.activeToolCalls.size === 0 && this.sawSessionUpdateSincePrompt === false) {
|
|
9659
10004
|
const noUpdatesTimeoutMs = this.getPostPromptNoUpdatesTimeoutMs();
|
|
@@ -9716,7 +10061,7 @@ Recent stderr: ${recentStderrSummaryLine}` : `Signal: ${signal}`;
|
|
|
9716
10061
|
if (!this.waitingForResponse) {
|
|
9717
10062
|
return;
|
|
9718
10063
|
}
|
|
9719
|
-
const effectiveTimeoutMs =
|
|
10064
|
+
const effectiveTimeoutMs = this.getResponseWaitTimeoutMs(timeoutMs);
|
|
9720
10065
|
return new Promise((resolve, reject) => {
|
|
9721
10066
|
this.idleResolver = () => {
|
|
9722
10067
|
this.idleResolver = null;
|
|
@@ -10050,7 +10395,7 @@ function registerGeminiAgent() {
|
|
|
10050
10395
|
persistence.logger.debug("[Gemini] Registered with agent registry");
|
|
10051
10396
|
}
|
|
10052
10397
|
|
|
10053
|
-
const DEFAULT_CODEX_ACP_NPX_PACKAGE = "@zed-industries/codex-acp@0.
|
|
10398
|
+
const DEFAULT_CODEX_ACP_NPX_PACKAGE = "@zed-industries/codex-acp@0.14.0";
|
|
10054
10399
|
function readFirstEnv(...names) {
|
|
10055
10400
|
for (const name of names) {
|
|
10056
10401
|
const raw = process.env[name];
|
|
@@ -10899,7 +11244,7 @@ class AbortError extends Error {
|
|
|
10899
11244
|
}
|
|
10900
11245
|
}
|
|
10901
11246
|
|
|
10902
|
-
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-
|
|
11247
|
+
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-xa1kwZoj.cjs', document.baseURI).href)));
|
|
10903
11248
|
const __dirname$1 = path.join(__filename$1, "..");
|
|
10904
11249
|
function getGlobalClaudeVersion() {
|
|
10905
11250
|
try {
|
|
@@ -12224,14 +12569,14 @@ var launch = /*#__PURE__*/Object.freeze({
|
|
|
12224
12569
|
const unifiedProviderExecutors = {
|
|
12225
12570
|
claude: async (opts) => {
|
|
12226
12571
|
const claudeOptions = opts.claudeOptions ?? {};
|
|
12227
|
-
const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-
|
|
12572
|
+
const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-BBGNmGj6.cjs'); });
|
|
12228
12573
|
await runClaude(opts.credentials, {
|
|
12229
12574
|
...claudeOptions,
|
|
12230
12575
|
startingMode: claudeOptions.startingMode ?? (claudeOptions.startedBy === "daemon" ? "remote" : void 0)
|
|
12231
12576
|
});
|
|
12232
12577
|
},
|
|
12233
12578
|
codex: async (opts) => {
|
|
12234
|
-
const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-
|
|
12579
|
+
const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-jUU6U2tZ.cjs'); });
|
|
12235
12580
|
await runCodex({
|
|
12236
12581
|
credentials: opts.credentials,
|
|
12237
12582
|
startedBy: opts.startedBy,
|
|
@@ -12240,7 +12585,7 @@ const unifiedProviderExecutors = {
|
|
|
12240
12585
|
});
|
|
12241
12586
|
},
|
|
12242
12587
|
gemini: async (opts) => {
|
|
12243
|
-
const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-
|
|
12588
|
+
const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-C0NT8MHK.cjs'); });
|
|
12244
12589
|
await runGemini({
|
|
12245
12590
|
credentials: opts.credentials,
|
|
12246
12591
|
startedBy: opts.startedBy
|
|
@@ -12323,7 +12668,7 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
12323
12668
|
return;
|
|
12324
12669
|
} else if (subcommand === "runtime") {
|
|
12325
12670
|
if (args[1] === "providers") {
|
|
12326
|
-
const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-
|
|
12671
|
+
const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-VcH4hbhi.cjs'); });
|
|
12327
12672
|
console.log(renderRuntimeProviders());
|
|
12328
12673
|
return;
|
|
12329
12674
|
}
|
|
@@ -12529,8 +12874,8 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
12529
12874
|
const projectId = args[3];
|
|
12530
12875
|
try {
|
|
12531
12876
|
const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
|
|
12532
|
-
const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./api-
|
|
12533
|
-
const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-
|
|
12877
|
+
const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./api-D7nAeZi7.cjs'); }).then(function (n) { return n.persistence; });
|
|
12878
|
+
const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-D7nAeZi7.cjs'); }).then(function (n) { return n.api; });
|
|
12534
12879
|
let userEmail = void 0;
|
|
12535
12880
|
try {
|
|
12536
12881
|
const credentials = await readCredentials2();
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('chalk');
|
|
4
|
-
require('./api-
|
|
4
|
+
require('./api-D7nAeZi7.cjs');
|
|
5
5
|
require('zod');
|
|
6
|
-
require('./index-
|
|
6
|
+
require('./index-xa1kwZoj.cjs');
|
|
7
7
|
require('node:child_process');
|
|
8
8
|
require('node:fs');
|
|
9
9
|
require('cross-spawn');
|
package/dist/index.mjs
CHANGED