happy-imou-cloud 2.1.46 → 2.1.48
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-Bsnew7fc.cjs → BaseReasoningProcessor-CKtDfihV.cjs} +2 -2
- package/dist/{BaseReasoningProcessor-Mrdbmfl3.mjs → BaseReasoningProcessor-CM3JbXUC.mjs} +2 -2
- package/dist/{ProviderSelectionHandler-gaUVvyCU.cjs → ProviderSelectionHandler-BHKIBw4t.cjs} +2 -2
- package/dist/{ProviderSelectionHandler-BymmO261.mjs → ProviderSelectionHandler-vgZ2egD_.mjs} +2 -2
- package/dist/{api-DTSpLLTK.mjs → api-CSjP-Z3Y.mjs} +3 -3
- package/dist/{api-Bekjk9d5.cjs → api-eaGKJjMt.cjs} +3 -3
- package/dist/{command-umgXYSY2.mjs → command-BzPI4N1n.mjs} +2 -3
- package/dist/{command-BwhJX0G5.cjs → command-DDoz1Eky.cjs} +2 -3
- package/dist/{index-CUVIZLuf.mjs → index-BzsBo3_Z.mjs} +364 -49
- package/dist/{index-DkaYNlRO.cjs → index-C8X1VlHZ.cjs} +338 -42
- package/dist/index.cjs +2 -3
- package/dist/index.mjs +2 -3
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +2 -0
- package/dist/lib.d.mts +2 -0
- package/dist/lib.mjs +1 -1
- package/dist/{registerKillSessionHandler-hQE08yMO.mjs → registerKillSessionHandler-BHu-3hZQ.mjs} +2 -2
- package/dist/{registerKillSessionHandler-BYWJJDre.cjs → registerKillSessionHandler-CLCYBgZX.cjs} +2 -2
- package/dist/{runClaude-jpo2aFey.cjs → runClaude-BkUbXE2F.cjs} +4 -5
- package/dist/{runClaude-CFeIMCY2.mjs → runClaude-D3CBLW5o.mjs} +4 -5
- package/dist/{runCodex-CrxyWcga.cjs → runCodex-CdgrZK7P.cjs} +29 -9
- package/dist/{runCodex-ByjUfTyr.mjs → runCodex-DqzdgDwZ.mjs} +29 -9
- package/dist/{runGemini-BhIz1N_b.cjs → runGemini-BE05R24D.cjs} +4 -5
- package/dist/{runGemini-CihCRgcR.mjs → runGemini-UZuiKe59.mjs} +4 -5
- package/package.json +1 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chalk = require('chalk');
|
|
4
|
-
var persistence = require('./api-
|
|
4
|
+
var persistence = require('./api-eaGKJjMt.cjs');
|
|
5
5
|
var z = require('zod');
|
|
6
6
|
var fs$2 = require('fs/promises');
|
|
7
7
|
var os$1 = require('os');
|
|
8
|
-
var tmp = require('tmp');
|
|
9
8
|
var node_crypto = require('node:crypto');
|
|
10
9
|
var tweetnacl = require('tweetnacl');
|
|
11
10
|
var axios = require('axios');
|
|
@@ -37,25 +36,6 @@ var node_url = require('node:url');
|
|
|
37
36
|
require('node:events');
|
|
38
37
|
|
|
39
38
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
40
|
-
function _interopNamespaceDefault(e) {
|
|
41
|
-
var n = Object.create(null);
|
|
42
|
-
if (e) {
|
|
43
|
-
Object.keys(e).forEach(function (k) {
|
|
44
|
-
if (k !== 'default') {
|
|
45
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
46
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
get: function () { return e[k]; }
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
n.default = e;
|
|
54
|
-
return Object.freeze(n);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
var tmp__namespace = /*#__PURE__*/_interopNamespaceDefault(tmp);
|
|
58
|
-
|
|
59
39
|
async function openBrowser(url) {
|
|
60
40
|
try {
|
|
61
41
|
if (!process.stdout.isTTY || process.env.CI || process.env.HEADLESS) {
|
|
@@ -72,7 +52,7 @@ async function openBrowser(url) {
|
|
|
72
52
|
}
|
|
73
53
|
}
|
|
74
54
|
|
|
75
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-
|
|
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-C8X1VlHZ.cjs', document.baseURI).href)));
|
|
76
56
|
const QRCode = require$1("qrcode-terminal/vendor/QRCode");
|
|
77
57
|
const QRErrorCorrectLevel = require$1("qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel");
|
|
78
58
|
const pendingTempFiles = /* @__PURE__ */ new Set();
|
|
@@ -637,7 +617,7 @@ function setupCleanupHandlers() {
|
|
|
637
617
|
});
|
|
638
618
|
}
|
|
639
619
|
|
|
640
|
-
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-C8X1VlHZ.cjs', document.baseURI).href))));
|
|
641
621
|
function projectPath() {
|
|
642
622
|
const path = path$1.resolve(__dirname$2, "..");
|
|
643
623
|
return path;
|
|
@@ -1589,7 +1569,8 @@ function startDaemonControlServer({
|
|
|
1589
1569
|
body: z.z.object({
|
|
1590
1570
|
directory: z.z.string(),
|
|
1591
1571
|
sessionId: z.z.string().optional(),
|
|
1592
|
-
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()
|
|
1593
1574
|
}),
|
|
1594
1575
|
response: {
|
|
1595
1576
|
200: z.z.object({
|
|
@@ -1610,9 +1591,9 @@ function startDaemonControlServer({
|
|
|
1610
1591
|
}
|
|
1611
1592
|
}
|
|
1612
1593
|
}, async (request, reply) => {
|
|
1613
|
-
const { directory, sessionId, agent } = request.body;
|
|
1614
|
-
persistence.logger.debug(`[CONTROL SERVER] Spawn session request: dir=${directory}, sessionId=${sessionId || "new"}, agent=${agent || "claude"}`);
|
|
1615
|
-
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 });
|
|
1616
1597
|
switch (result.type) {
|
|
1617
1598
|
case "success":
|
|
1618
1599
|
if (!result.sessionId) {
|
|
@@ -2356,20 +2337,33 @@ function resolveDaemonSpawnAgent(agent) {
|
|
|
2356
2337
|
throw new Error(`Unsupported agent type: '${agent}'. Please update your CLI to the latest version.`);
|
|
2357
2338
|
}
|
|
2358
2339
|
}
|
|
2359
|
-
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";
|
|
2360
2344
|
const args = [
|
|
2361
2345
|
resolveDaemonSpawnAgent(agent),
|
|
2362
2346
|
"--happy-starting-mode",
|
|
2363
|
-
|
|
2347
|
+
startingMode,
|
|
2364
2348
|
"--started-by",
|
|
2365
|
-
|
|
2349
|
+
startedBy
|
|
2366
2350
|
];
|
|
2367
|
-
const providerSessionId = typeof resume?.providerSessionId === "string" ? resume.providerSessionId.trim() : "";
|
|
2351
|
+
const providerSessionId = typeof options.resume?.providerSessionId === "string" ? options.resume.providerSessionId.trim() : "";
|
|
2368
2352
|
if (providerSessionId.length > 0) {
|
|
2369
2353
|
args.push("--resume", providerSessionId);
|
|
2370
2354
|
}
|
|
2371
2355
|
return args;
|
|
2372
2356
|
}
|
|
2357
|
+
function buildTerminalWindowSpawnArgs(agent, resume) {
|
|
2358
|
+
return buildDaemonSpawnArgs(agent, {
|
|
2359
|
+
resume,
|
|
2360
|
+
startingMode: "local",
|
|
2361
|
+
startedBy: "terminal"
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2364
|
+
function isLegacyResumeOptions(value) {
|
|
2365
|
+
return Boolean(value && "providerSessionId" in value);
|
|
2366
|
+
}
|
|
2373
2367
|
|
|
2374
2368
|
const SPAWN_SESSION_ERROR_CODES = {
|
|
2375
2369
|
INVALID_REQUEST: "INVALID_REQUEST",
|
|
@@ -2432,6 +2426,157 @@ function buildDaemonChildEnv(baseEnv, extraEnv) {
|
|
|
2432
2426
|
return childEnv;
|
|
2433
2427
|
}
|
|
2434
2428
|
|
|
2429
|
+
function quotePosix(value) {
|
|
2430
|
+
return `'${value.replace(/'/g, `'"'"'`)}'`;
|
|
2431
|
+
}
|
|
2432
|
+
function quoteAppleScriptString(value) {
|
|
2433
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
2434
|
+
}
|
|
2435
|
+
function quoteWindowsCmd(value) {
|
|
2436
|
+
return `"${value.replace(/(["^&|<>()%])/g, "^$1")}"`;
|
|
2437
|
+
}
|
|
2438
|
+
function buildRuntimeInvocation(args, platform, entrypointOverride) {
|
|
2439
|
+
const projectRoot = projectPath();
|
|
2440
|
+
const entrypoint = entrypointOverride || path.join(projectRoot, "dist", "index.mjs");
|
|
2441
|
+
const runtime = isBun() ? "bun" : "node";
|
|
2442
|
+
const runtimeArgs = ["--no-warnings", "--no-deprecation", entrypoint, ...args];
|
|
2443
|
+
const commandParts = [runtime, ...runtimeArgs];
|
|
2444
|
+
if (platform === "win32") {
|
|
2445
|
+
return commandParts.map(quoteWindowsCmd).join(" ");
|
|
2446
|
+
}
|
|
2447
|
+
return commandParts.map(quotePosix).join(" ");
|
|
2448
|
+
}
|
|
2449
|
+
function buildUserFacingPreview(args) {
|
|
2450
|
+
const agent = args[0];
|
|
2451
|
+
if (agent === "claude" || agent === "codex" || agent === "gemini") {
|
|
2452
|
+
return `hicloud ${agent}`;
|
|
2453
|
+
}
|
|
2454
|
+
return `hicloud ${args.join(" ")}`.trim();
|
|
2455
|
+
}
|
|
2456
|
+
function buildPathWithProjectBin(env, platform) {
|
|
2457
|
+
const binPath = path.join(projectPath(), "node_modules", ".bin");
|
|
2458
|
+
const pathDelimiter = platform === "win32" ? ";" : path.delimiter;
|
|
2459
|
+
const currentPath = env?.PATH || env?.Path || process.env.PATH || "";
|
|
2460
|
+
return currentPath ? `${binPath}${pathDelimiter}${currentPath}` : binPath;
|
|
2461
|
+
}
|
|
2462
|
+
function isValidEnvironmentVariableName(name) {
|
|
2463
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);
|
|
2464
|
+
}
|
|
2465
|
+
function escapeWindowsBatchSetValue(value) {
|
|
2466
|
+
return value.replace(/\r?\n/g, "").replace(/%/g, "%%");
|
|
2467
|
+
}
|
|
2468
|
+
function collectLaunchEnv(env, platform) {
|
|
2469
|
+
const result = {};
|
|
2470
|
+
for (const [key, value] of Object.entries(env || {})) {
|
|
2471
|
+
if (typeof value === "string" && isValidEnvironmentVariableName(key)) {
|
|
2472
|
+
result[key] = value;
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
result.PATH = buildPathWithProjectBin(env, platform);
|
|
2476
|
+
return result;
|
|
2477
|
+
}
|
|
2478
|
+
function buildTerminalLaunchScriptContent(options) {
|
|
2479
|
+
const platform = options.platform || process.platform;
|
|
2480
|
+
const launchEnv = collectLaunchEnv(options.env, platform);
|
|
2481
|
+
const preview = buildUserFacingPreview(options.args);
|
|
2482
|
+
const runtimeInvocation = buildRuntimeInvocation(options.args, platform, options.entrypoint);
|
|
2483
|
+
if (platform === "win32") {
|
|
2484
|
+
const envLines2 = Object.entries(launchEnv).map(([key, value]) => `set "${key}=${escapeWindowsBatchSetValue(value)}"`).join("\r\n");
|
|
2485
|
+
return [
|
|
2486
|
+
"@echo off",
|
|
2487
|
+
"setlocal",
|
|
2488
|
+
envLines2,
|
|
2489
|
+
`cd /d ${quoteWindowsCmd(options.cwd)}`,
|
|
2490
|
+
`echo $ ${preview}`,
|
|
2491
|
+
runtimeInvocation,
|
|
2492
|
+
"echo.",
|
|
2493
|
+
"echo Happy session command exited. You can close this window.",
|
|
2494
|
+
'del "%~f0" >nul 2>nul',
|
|
2495
|
+
"endlocal",
|
|
2496
|
+
""
|
|
2497
|
+
].join("\r\n");
|
|
2498
|
+
}
|
|
2499
|
+
const envLines = Object.entries(launchEnv).map(([key, value]) => `export ${key}=${quotePosix(value)}`).join("\n");
|
|
2500
|
+
return [
|
|
2501
|
+
"#!/usr/bin/env bash",
|
|
2502
|
+
"set +e",
|
|
2503
|
+
'rm -f "$0" >/dev/null 2>&1 || true',
|
|
2504
|
+
envLines,
|
|
2505
|
+
`cd ${quotePosix(options.cwd)} || exit $?`,
|
|
2506
|
+
`echo ${quotePosix(`$ ${preview}`)}`,
|
|
2507
|
+
runtimeInvocation,
|
|
2508
|
+
"status=$?",
|
|
2509
|
+
"echo",
|
|
2510
|
+
'echo "Happy session command exited with status ${status}. You can close this window."',
|
|
2511
|
+
'exec "${SHELL:-bash}" -l',
|
|
2512
|
+
""
|
|
2513
|
+
].join("\n");
|
|
2514
|
+
}
|
|
2515
|
+
function createTerminalLaunchScript(options) {
|
|
2516
|
+
if (options.scriptPath) {
|
|
2517
|
+
return options.scriptPath;
|
|
2518
|
+
}
|
|
2519
|
+
const platform = options.platform || process.platform;
|
|
2520
|
+
const scriptDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "happy-terminal-launch-"));
|
|
2521
|
+
const scriptPath = path.join(scriptDirectory, platform === "win32" ? "launch.cmd" : "launch.sh");
|
|
2522
|
+
fs.writeFileSync(scriptPath, buildTerminalLaunchScriptContent({ ...options, platform }), { encoding: "utf8", mode: 448 });
|
|
2523
|
+
if (platform !== "win32") {
|
|
2524
|
+
fs.chmodSync(scriptPath, 448);
|
|
2525
|
+
}
|
|
2526
|
+
return scriptPath;
|
|
2527
|
+
}
|
|
2528
|
+
function buildTerminalWindowLaunchCommand(options) {
|
|
2529
|
+
const platform = options.platform || process.platform;
|
|
2530
|
+
const scriptPath = createTerminalLaunchScript({ ...options, platform });
|
|
2531
|
+
const preview = buildUserFacingPreview(options.args);
|
|
2532
|
+
if (platform === "win32") {
|
|
2533
|
+
return {
|
|
2534
|
+
command: "cmd.exe",
|
|
2535
|
+
args: ["/d", "/s", "/c", `start "" cmd.exe /d /s /k ${quoteWindowsCmd(scriptPath)}`],
|
|
2536
|
+
options: {
|
|
2537
|
+
cwd: options.cwd,
|
|
2538
|
+
detached: true,
|
|
2539
|
+
stdio: "ignore",
|
|
2540
|
+
env: options.env,
|
|
2541
|
+
windowsHide: false
|
|
2542
|
+
},
|
|
2543
|
+
preview,
|
|
2544
|
+
scriptPath
|
|
2545
|
+
};
|
|
2546
|
+
}
|
|
2547
|
+
if (platform === "darwin") {
|
|
2548
|
+
const appleScript = `tell application "Terminal" to do script ${quoteAppleScriptString(`bash ${quotePosix(scriptPath)}`)}`;
|
|
2549
|
+
return {
|
|
2550
|
+
command: "osascript",
|
|
2551
|
+
args: ["-e", appleScript],
|
|
2552
|
+
options: {
|
|
2553
|
+
cwd: options.cwd,
|
|
2554
|
+
detached: true,
|
|
2555
|
+
stdio: "ignore",
|
|
2556
|
+
env: options.env
|
|
2557
|
+
},
|
|
2558
|
+
preview,
|
|
2559
|
+
scriptPath
|
|
2560
|
+
};
|
|
2561
|
+
}
|
|
2562
|
+
return {
|
|
2563
|
+
command: "x-terminal-emulator",
|
|
2564
|
+
args: ["-e", "bash", scriptPath],
|
|
2565
|
+
options: {
|
|
2566
|
+
cwd: options.cwd,
|
|
2567
|
+
detached: true,
|
|
2568
|
+
stdio: "ignore",
|
|
2569
|
+
env: options.env
|
|
2570
|
+
},
|
|
2571
|
+
preview,
|
|
2572
|
+
scriptPath
|
|
2573
|
+
};
|
|
2574
|
+
}
|
|
2575
|
+
function spawnHappyCLIInTerminalWindow(options) {
|
|
2576
|
+
const launchCommand = buildTerminalWindowLaunchCommand(options);
|
|
2577
|
+
return node_child_process.spawn(launchCommand.command, launchCommand.args, launchCommand.options);
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2435
2580
|
const DIFFERENT_DAEMON_RUNNING_MESSAGE = "A different daemon was started without killing us. We should kill ourselves.";
|
|
2436
2581
|
function pruneStaleTrackedSessions({
|
|
2437
2582
|
trackedSessionPids,
|
|
@@ -3431,6 +3576,50 @@ function resolveTrackedHappySessionId(opts) {
|
|
|
3431
3576
|
return opts.precreatedSessionId ?? opts.requestedSessionId;
|
|
3432
3577
|
}
|
|
3433
3578
|
|
|
3579
|
+
const CODEX_HOME_CONFIG_FILES = [
|
|
3580
|
+
"config.toml",
|
|
3581
|
+
"cap_sid",
|
|
3582
|
+
"version.json",
|
|
3583
|
+
"MEMORY.md"
|
|
3584
|
+
];
|
|
3585
|
+
const CODEX_HOME_CONFIG_DIRS = [
|
|
3586
|
+
"rules",
|
|
3587
|
+
"skills"
|
|
3588
|
+
];
|
|
3589
|
+
function copyCodexHomeEntry$1(sourcePath, destPath) {
|
|
3590
|
+
if (!fs.existsSync(sourcePath)) {
|
|
3591
|
+
return;
|
|
3592
|
+
}
|
|
3593
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
3594
|
+
fs.cpSync(sourcePath, destPath, {
|
|
3595
|
+
recursive: true,
|
|
3596
|
+
force: true,
|
|
3597
|
+
dereference: false,
|
|
3598
|
+
verbatimSymlinks: true
|
|
3599
|
+
});
|
|
3600
|
+
}
|
|
3601
|
+
function createDaemonCodexAuthHome(options) {
|
|
3602
|
+
const sourceHomeDir = options.sourceHomeDir ?? path.join(os.homedir(), ".codex");
|
|
3603
|
+
const targetHomeDir = options.tempDir;
|
|
3604
|
+
fs.mkdirSync(targetHomeDir, { recursive: true });
|
|
3605
|
+
for (const fileName of CODEX_HOME_CONFIG_FILES) {
|
|
3606
|
+
try {
|
|
3607
|
+
copyCodexHomeEntry$1(path.join(sourceHomeDir, fileName), path.join(targetHomeDir, fileName));
|
|
3608
|
+
} catch (error) {
|
|
3609
|
+
persistence.logger.debug(`[codex] Failed to copy source CODEX_HOME file ${fileName} into daemon auth home`, error);
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
for (const dirName of CODEX_HOME_CONFIG_DIRS) {
|
|
3613
|
+
try {
|
|
3614
|
+
copyCodexHomeEntry$1(path.join(sourceHomeDir, dirName), path.join(targetHomeDir, dirName));
|
|
3615
|
+
} catch (error) {
|
|
3616
|
+
persistence.logger.debug(`[codex] Failed to copy source CODEX_HOME directory ${dirName} into daemon auth home`, error);
|
|
3617
|
+
}
|
|
3618
|
+
}
|
|
3619
|
+
fs.writeFileSync(path.join(targetHomeDir, "auth.json"), options.authJson, "utf8");
|
|
3620
|
+
return targetHomeDir;
|
|
3621
|
+
}
|
|
3622
|
+
|
|
3434
3623
|
const DEFAULT_SESSION_WEBHOOK_TIMEOUT_MS = 45e3;
|
|
3435
3624
|
const DEFAULT_TRACKED_SESSION_SWEEP_INTERVAL_MS = 5e3;
|
|
3436
3625
|
function resolveSessionWebhookTimeoutMs() {
|
|
@@ -3545,6 +3734,28 @@ async function startDaemon() {
|
|
|
3545
3734
|
let api = null;
|
|
3546
3735
|
const pidToTrackedSession = /* @__PURE__ */ new Map();
|
|
3547
3736
|
const pidToAwaiter = /* @__PURE__ */ new Map();
|
|
3737
|
+
const terminalLaunchAwaiters = /* @__PURE__ */ new Map();
|
|
3738
|
+
const normalizePathForSessionMatch = (value) => (value || "").trim().replace(/[\\/]+$/, "");
|
|
3739
|
+
const resolveTerminalLaunchAwaiter = (sessionId, sessionMetadata) => {
|
|
3740
|
+
const reportedDirectory = normalizePathForSessionMatch(sessionMetadata.path);
|
|
3741
|
+
const reportedFlavor = resolveRecoverySpawnAgent(sessionMetadata.flavor);
|
|
3742
|
+
const now = Date.now();
|
|
3743
|
+
for (const [awaiterId, awaiter] of terminalLaunchAwaiters.entries()) {
|
|
3744
|
+
if (awaiter.startedAt - 5e3 > now) {
|
|
3745
|
+
continue;
|
|
3746
|
+
}
|
|
3747
|
+
const directoryMatches = normalizePathForSessionMatch(awaiter.directory) === reportedDirectory;
|
|
3748
|
+
const agentMatches = !awaiter.agent || !reportedFlavor || awaiter.agent === reportedFlavor;
|
|
3749
|
+
if (!directoryMatches || !agentMatches) {
|
|
3750
|
+
continue;
|
|
3751
|
+
}
|
|
3752
|
+
terminalLaunchAwaiters.delete(awaiterId);
|
|
3753
|
+
awaiter.resolve({ type: "success", sessionId });
|
|
3754
|
+
persistence.logger.debug(`[DAEMON RUN] Resolved terminal window session awaiter ${awaiterId} for session ${sessionId}`);
|
|
3755
|
+
return true;
|
|
3756
|
+
}
|
|
3757
|
+
return false;
|
|
3758
|
+
};
|
|
3548
3759
|
const getCurrentChildren = () => Array.from(pidToTrackedSession.values());
|
|
3549
3760
|
let userScopedObserver = null;
|
|
3550
3761
|
const removeTrackedSession = (pid, archiveReason) => {
|
|
@@ -3593,6 +3804,7 @@ async function startDaemon() {
|
|
|
3593
3804
|
};
|
|
3594
3805
|
pidToTrackedSession.set(pid, trackedSession);
|
|
3595
3806
|
persistence.logger.debug(`[DAEMON RUN] Registered externally-started session ${sessionId}`);
|
|
3807
|
+
resolveTerminalLaunchAwaiter(sessionId, sessionMetadata);
|
|
3596
3808
|
}
|
|
3597
3809
|
};
|
|
3598
3810
|
const spawnSession = async (options) => {
|
|
@@ -3641,9 +3853,11 @@ async function startDaemon() {
|
|
|
3641
3853
|
const authEnv = {};
|
|
3642
3854
|
if (options.token) {
|
|
3643
3855
|
if (options.agent === "codex") {
|
|
3644
|
-
const codexHomeDir =
|
|
3645
|
-
|
|
3646
|
-
|
|
3856
|
+
const codexHomeDir = await fs$2.mkdtemp(path$1.join(os$1.tmpdir(), "happy-codex-daemon-home-"));
|
|
3857
|
+
authEnv.CODEX_HOME = createDaemonCodexAuthHome({
|
|
3858
|
+
authJson: options.token,
|
|
3859
|
+
tempDir: codexHomeDir
|
|
3860
|
+
});
|
|
3647
3861
|
} else {
|
|
3648
3862
|
authEnv.CLAUDE_CODE_OAUTH_TOKEN = options.token;
|
|
3649
3863
|
}
|
|
@@ -3700,6 +3914,84 @@ async function startDaemon() {
|
|
|
3700
3914
|
errorMessage: spawnError.errorMessage
|
|
3701
3915
|
};
|
|
3702
3916
|
}
|
|
3917
|
+
if (options.launchMode === "terminalWindow" || options.launchMode === "localTerminal") {
|
|
3918
|
+
persistence.logger.debug(`[DAEMON RUN] Using visible terminal window spawning`);
|
|
3919
|
+
let args;
|
|
3920
|
+
try {
|
|
3921
|
+
args = buildTerminalWindowSpawnArgs(options.agent, options.resume);
|
|
3922
|
+
} catch (error) {
|
|
3923
|
+
const spawnError = createSpawnSessionError(
|
|
3924
|
+
SPAWN_SESSION_ERROR_CODES.INVALID_REQUEST,
|
|
3925
|
+
error instanceof Error ? error.message : String(error)
|
|
3926
|
+
);
|
|
3927
|
+
return {
|
|
3928
|
+
type: spawnError.type,
|
|
3929
|
+
errorMessage: spawnError.errorMessage
|
|
3930
|
+
};
|
|
3931
|
+
}
|
|
3932
|
+
const terminalEnv = buildDaemonChildEnv(process.env, extraEnv);
|
|
3933
|
+
const terminalProcess = spawnHappyCLIInTerminalWindow({
|
|
3934
|
+
cwd: directory,
|
|
3935
|
+
args,
|
|
3936
|
+
env: terminalEnv
|
|
3937
|
+
});
|
|
3938
|
+
if (!terminalProcess.pid) {
|
|
3939
|
+
persistence.logger.debug("[DAEMON RUN] Failed to spawn terminal window - no PID returned");
|
|
3940
|
+
const spawnError = createSpawnSessionError(
|
|
3941
|
+
SPAWN_SESSION_ERROR_CODES.SPAWN_NO_PID,
|
|
3942
|
+
"Failed to spawn terminal window - no PID returned"
|
|
3943
|
+
);
|
|
3944
|
+
return {
|
|
3945
|
+
type: spawnError.type,
|
|
3946
|
+
errorMessage: spawnError.errorMessage
|
|
3947
|
+
};
|
|
3948
|
+
}
|
|
3949
|
+
persistence.logger.debug(`[DAEMON RUN] Spawned terminal window process with PID ${terminalProcess.pid}`);
|
|
3950
|
+
const trackedSession = {
|
|
3951
|
+
startedBy: "daemon terminal window",
|
|
3952
|
+
happySessionId: options.sessionId,
|
|
3953
|
+
sessionIndex: null,
|
|
3954
|
+
skipDetachedManagedSessionArchive: true,
|
|
3955
|
+
pid: terminalProcess.pid,
|
|
3956
|
+
childProcess: terminalProcess,
|
|
3957
|
+
directoryCreated,
|
|
3958
|
+
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.`
|
|
3959
|
+
};
|
|
3960
|
+
pidToTrackedSession.set(terminalProcess.pid, trackedSession);
|
|
3961
|
+
terminalProcess.on("exit", (code, signal) => {
|
|
3962
|
+
persistence.logger.debug(`[DAEMON RUN] Terminal launcher PID ${terminalProcess.pid} exited with code ${code}, signal ${signal}`);
|
|
3963
|
+
});
|
|
3964
|
+
terminalProcess.on("error", (error) => {
|
|
3965
|
+
persistence.logger.debug(`[DAEMON RUN] Terminal launcher process error:`, error);
|
|
3966
|
+
});
|
|
3967
|
+
terminalProcess.unref();
|
|
3968
|
+
const terminalAwaiterId = node_crypto.randomUUID();
|
|
3969
|
+
const launchStartedAt = Date.now();
|
|
3970
|
+
persistence.logger.debug(`[DAEMON RUN] Waiting for terminal window session webhook ${terminalAwaiterId}`);
|
|
3971
|
+
return new Promise((resolve) => {
|
|
3972
|
+
const timeout = setTimeout(() => {
|
|
3973
|
+
terminalLaunchAwaiters.delete(terminalAwaiterId);
|
|
3974
|
+
persistence.logger.debug(`[DAEMON RUN] Terminal window session webhook timeout for PID ${terminalProcess.pid}`);
|
|
3975
|
+
const spawnError = createSpawnSessionError(
|
|
3976
|
+
SPAWN_SESSION_ERROR_CODES.SESSION_WEBHOOK_TIMEOUT,
|
|
3977
|
+
`Terminal window session webhook timeout for PID ${terminalProcess.pid}`
|
|
3978
|
+
);
|
|
3979
|
+
resolve({
|
|
3980
|
+
type: spawnError.type,
|
|
3981
|
+
errorMessage: spawnError.errorMessage
|
|
3982
|
+
});
|
|
3983
|
+
}, sessionWebhookTimeoutMs);
|
|
3984
|
+
terminalLaunchAwaiters.set(terminalAwaiterId, {
|
|
3985
|
+
directory,
|
|
3986
|
+
agent: options.agent,
|
|
3987
|
+
startedAt: launchStartedAt,
|
|
3988
|
+
resolve: (result) => {
|
|
3989
|
+
clearTimeout(timeout);
|
|
3990
|
+
resolve(result);
|
|
3991
|
+
}
|
|
3992
|
+
});
|
|
3993
|
+
});
|
|
3994
|
+
}
|
|
3703
3995
|
let tmuxSessionName = extraEnv.TMUX_SESSION_NAME;
|
|
3704
3996
|
const tmuxRequested = tmuxSessionName !== void 0;
|
|
3705
3997
|
const tmuxAvailable = tmuxRequested ? await isTmuxAvailable() : false;
|
|
@@ -9374,10 +9666,14 @@ Recent stderr: ${recentStderrSummaryLine}` : `Signal: ${signal}`;
|
|
|
9374
9666
|
async () => {
|
|
9375
9667
|
let timeoutHandle = null;
|
|
9376
9668
|
try {
|
|
9669
|
+
const resumeSession = this.connection.resumeSession ?? this.connection.unstable_resumeSession;
|
|
9377
9670
|
const result = await raceWithProcessExit(
|
|
9378
9671
|
this.process,
|
|
9379
9672
|
() => Promise.race([
|
|
9380
|
-
(sessionOperation === "resume" ?
|
|
9673
|
+
(sessionOperation === "resume" ? resumeSession ? resumeSession(sessionRequest).then((response) => ({
|
|
9674
|
+
...response,
|
|
9675
|
+
sessionId: requestedResumeSessionId
|
|
9676
|
+
})) : 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) => {
|
|
9381
9677
|
if (timeoutHandle) {
|
|
9382
9678
|
clearTimeout(timeoutHandle);
|
|
9383
9679
|
timeoutHandle = null;
|
|
@@ -10873,7 +11169,7 @@ class AbortError extends Error {
|
|
|
10873
11169
|
}
|
|
10874
11170
|
}
|
|
10875
11171
|
|
|
10876
|
-
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-
|
|
11172
|
+
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-C8X1VlHZ.cjs', document.baseURI).href)));
|
|
10877
11173
|
const __dirname$1 = path.join(__filename$1, "..");
|
|
10878
11174
|
function getGlobalClaudeVersion() {
|
|
10879
11175
|
try {
|
|
@@ -12198,14 +12494,14 @@ var launch = /*#__PURE__*/Object.freeze({
|
|
|
12198
12494
|
const unifiedProviderExecutors = {
|
|
12199
12495
|
claude: async (opts) => {
|
|
12200
12496
|
const claudeOptions = opts.claudeOptions ?? {};
|
|
12201
|
-
const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-
|
|
12497
|
+
const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-BkUbXE2F.cjs'); });
|
|
12202
12498
|
await runClaude(opts.credentials, {
|
|
12203
12499
|
...claudeOptions,
|
|
12204
12500
|
startingMode: claudeOptions.startingMode ?? (claudeOptions.startedBy === "daemon" ? "remote" : void 0)
|
|
12205
12501
|
});
|
|
12206
12502
|
},
|
|
12207
12503
|
codex: async (opts) => {
|
|
12208
|
-
const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-
|
|
12504
|
+
const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-CdgrZK7P.cjs'); });
|
|
12209
12505
|
await runCodex({
|
|
12210
12506
|
credentials: opts.credentials,
|
|
12211
12507
|
startedBy: opts.startedBy,
|
|
@@ -12214,7 +12510,7 @@ const unifiedProviderExecutors = {
|
|
|
12214
12510
|
});
|
|
12215
12511
|
},
|
|
12216
12512
|
gemini: async (opts) => {
|
|
12217
|
-
const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-
|
|
12513
|
+
const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-BE05R24D.cjs'); });
|
|
12218
12514
|
await runGemini({
|
|
12219
12515
|
credentials: opts.credentials,
|
|
12220
12516
|
startedBy: opts.startedBy
|
|
@@ -12297,7 +12593,7 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
12297
12593
|
return;
|
|
12298
12594
|
} else if (subcommand === "runtime") {
|
|
12299
12595
|
if (args[1] === "providers") {
|
|
12300
|
-
const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-
|
|
12596
|
+
const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-DDoz1Eky.cjs'); });
|
|
12301
12597
|
console.log(renderRuntimeProviders());
|
|
12302
12598
|
return;
|
|
12303
12599
|
}
|
|
@@ -12503,8 +12799,8 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
12503
12799
|
const projectId = args[3];
|
|
12504
12800
|
try {
|
|
12505
12801
|
const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
|
|
12506
|
-
const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./api-
|
|
12507
|
-
const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-
|
|
12802
|
+
const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./api-eaGKJjMt.cjs'); }).then(function (n) { return n.persistence; });
|
|
12803
|
+
const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-eaGKJjMt.cjs'); }).then(function (n) { return n.api; });
|
|
12508
12804
|
let userEmail = void 0;
|
|
12509
12805
|
try {
|
|
12510
12806
|
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-eaGKJjMt.cjs');
|
|
5
5
|
require('zod');
|
|
6
|
-
require('./index-
|
|
6
|
+
require('./index-C8X1VlHZ.cjs');
|
|
7
7
|
require('node:child_process');
|
|
8
8
|
require('node:fs');
|
|
9
9
|
require('cross-spawn');
|
|
@@ -25,7 +25,6 @@ require('axios');
|
|
|
25
25
|
require('socket.io-client');
|
|
26
26
|
require('tweetnacl');
|
|
27
27
|
require('expo-server-sdk');
|
|
28
|
-
require('tmp');
|
|
29
28
|
require('qrcode-terminal');
|
|
30
29
|
require('node:module');
|
|
31
30
|
require('open');
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'chalk';
|
|
2
|
-
import './api-
|
|
2
|
+
import './api-CSjP-Z3Y.mjs';
|
|
3
3
|
import 'zod';
|
|
4
|
-
import './index-
|
|
4
|
+
import './index-BzsBo3_Z.mjs';
|
|
5
5
|
import 'node:child_process';
|
|
6
6
|
import 'node:fs';
|
|
7
7
|
import 'cross-spawn';
|
|
@@ -23,7 +23,6 @@ import 'axios';
|
|
|
23
23
|
import 'socket.io-client';
|
|
24
24
|
import 'tweetnacl';
|
|
25
25
|
import 'expo-server-sdk';
|
|
26
|
-
import 'tmp';
|
|
27
26
|
import 'qrcode-terminal';
|
|
28
27
|
import 'node:module';
|
|
29
28
|
import 'open';
|
package/dist/lib.cjs
CHANGED
package/dist/lib.d.cts
CHANGED
|
@@ -4011,6 +4011,7 @@ declare class ApiSessionClient extends EventEmitter {
|
|
|
4011
4011
|
private normalizeSocketError;
|
|
4012
4012
|
}
|
|
4013
4013
|
|
|
4014
|
+
type SessionLaunchMode = 'background' | 'terminalWindow' | 'localTerminal';
|
|
4014
4015
|
interface SpawnSessionOptions {
|
|
4015
4016
|
machineId?: string;
|
|
4016
4017
|
directory: string;
|
|
@@ -4019,6 +4020,7 @@ interface SpawnSessionOptions {
|
|
|
4019
4020
|
approvedNewDirectoryCreation?: boolean;
|
|
4020
4021
|
agent?: 'claude' | 'codex' | 'gemini';
|
|
4021
4022
|
token?: string;
|
|
4023
|
+
launchMode?: SessionLaunchMode;
|
|
4022
4024
|
environmentVariables?: {
|
|
4023
4025
|
ANTHROPIC_BASE_URL?: string;
|
|
4024
4026
|
ANTHROPIC_AUTH_TOKEN?: string;
|
package/dist/lib.d.mts
CHANGED
|
@@ -4011,6 +4011,7 @@ declare class ApiSessionClient extends EventEmitter {
|
|
|
4011
4011
|
private normalizeSocketError;
|
|
4012
4012
|
}
|
|
4013
4013
|
|
|
4014
|
+
type SessionLaunchMode = 'background' | 'terminalWindow' | 'localTerminal';
|
|
4014
4015
|
interface SpawnSessionOptions {
|
|
4015
4016
|
machineId?: string;
|
|
4016
4017
|
directory: string;
|
|
@@ -4019,6 +4020,7 @@ interface SpawnSessionOptions {
|
|
|
4019
4020
|
approvedNewDirectoryCreation?: boolean;
|
|
4020
4021
|
agent?: 'claude' | 'codex' | 'gemini';
|
|
4021
4022
|
token?: string;
|
|
4023
|
+
launchMode?: SessionLaunchMode;
|
|
4022
4024
|
environmentVariables?: {
|
|
4023
4025
|
ANTHROPIC_BASE_URL?: string;
|
|
4024
4026
|
ANTHROPIC_AUTH_TOKEN?: string;
|
package/dist/lib.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ApiClient, a as ApiSessionClient, c as configuration, l as logger } from './api-
|
|
1
|
+
export { A as ApiClient, a as ApiSessionClient, c as configuration, l as logger } from './api-CSjP-Z3Y.mjs';
|
|
2
2
|
export { R as RawJSONLinesSchema } from './types-CiliQpqS.mjs';
|
|
3
3
|
import 'axios';
|
|
4
4
|
import 'chalk';
|
package/dist/{registerKillSessionHandler-hQE08yMO.mjs → registerKillSessionHandler-BHu-3hZQ.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as initialMachineMetadata, R as RuntimeShell, f as formatDisplayMessage, n as resolveCanonicalToolNameV2, o as isTerminalReferenceOnlyPayload, t as truncateDisplayMessage } from './index-
|
|
2
|
-
import { r as readSettings, H as HeadTailPreviewBuffer, e as HAPPY_ORG_REPLY_ACK_VERSION, f as HAPPY_ORG_TURN_REPORT_TAG, g as HAPPY_ORG_SUMMARY_MAX_LENGTH, j as HAPPY_ORG_REPEAT_THRESHOLD, l as logger, n as normalizePreviewableArtifactTarget } from './api-
|
|
1
|
+
import { m as initialMachineMetadata, R as RuntimeShell, f as formatDisplayMessage, n as resolveCanonicalToolNameV2, o as isTerminalReferenceOnlyPayload, t as truncateDisplayMessage } from './index-BzsBo3_Z.mjs';
|
|
2
|
+
import { r as readSettings, H as HeadTailPreviewBuffer, e as HAPPY_ORG_REPLY_ACK_VERSION, f as HAPPY_ORG_TURN_REPORT_TAG, g as HAPPY_ORG_SUMMARY_MAX_LENGTH, j as HAPPY_ORG_REPEAT_THRESHOLD, l as logger, n as normalizePreviewableArtifactTarget } from './api-CSjP-Z3Y.mjs';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { basename } from 'node:path';
|
|
5
5
|
import 'axios';
|
package/dist/{registerKillSessionHandler-BYWJJDre.cjs → registerKillSessionHandler-CLCYBgZX.cjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var persistence = require('./api-
|
|
3
|
+
var index = require('./index-C8X1VlHZ.cjs');
|
|
4
|
+
var persistence = require('./api-eaGKJjMt.cjs');
|
|
5
5
|
var node_crypto = require('node:crypto');
|
|
6
6
|
var path = require('node:path');
|
|
7
7
|
require('axios');
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var node_crypto = require('node:crypto');
|
|
4
|
-
var persistence = require('./api-
|
|
4
|
+
var persistence = require('./api-eaGKJjMt.cjs');
|
|
5
5
|
require('cross-spawn');
|
|
6
6
|
require('@agentclientprotocol/sdk');
|
|
7
|
-
var index = require('./index-
|
|
7
|
+
var index = require('./index-C8X1VlHZ.cjs');
|
|
8
8
|
require('ps-list');
|
|
9
9
|
require('fs');
|
|
10
10
|
require('path');
|
|
@@ -25,15 +25,14 @@ require('tweetnacl');
|
|
|
25
25
|
require('open');
|
|
26
26
|
var React = require('react');
|
|
27
27
|
var ink = require('ink');
|
|
28
|
-
var ProviderSelectionHandler = require('./ProviderSelectionHandler-
|
|
28
|
+
var ProviderSelectionHandler = require('./ProviderSelectionHandler-BHKIBw4t.cjs');
|
|
29
29
|
var types = require('./types-DVk3crez.cjs');
|
|
30
|
-
var registerKillSessionHandler = require('./registerKillSessionHandler-
|
|
30
|
+
var registerKillSessionHandler = require('./registerKillSessionHandler-CLCYBgZX.cjs');
|
|
31
31
|
require('socket.io-client');
|
|
32
32
|
require('expo-server-sdk');
|
|
33
33
|
var node_util = require('node:util');
|
|
34
34
|
var node_http = require('node:http');
|
|
35
35
|
require('zod');
|
|
36
|
-
require('tmp');
|
|
37
36
|
require('qrcode-terminal');
|
|
38
37
|
require('node:module');
|
|
39
38
|
require('url');
|