claude-yes 1.159.1 → 1.160.1
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/{SUPPORTED_CLIS-BtV-mke0.js → SUPPORTED_CLIS-DQsE1x3p.js} +2 -2
- package/dist/SUPPORTED_CLIS-Miuhk6xh.js +8 -0
- package/dist/cli.js +3 -3
- package/dist/index.js +2 -2
- package/dist/{schedule-DzSUoqqh.js → schedule-PSUIDl7t.js} +4 -4
- package/dist/{serve-CTtO8sIP.js → serve-CmjJUNC3.js} +45 -6
- package/dist/{setup-Bh3eBiQ8.js → setup-19SmDp6U.js} +2 -2
- package/dist/{subcommands-BhGxt0eA.js → subcommands-BLFAm8Ph.js} +17 -8
- package/dist/subcommands-BMx45Ww-.js +9 -0
- package/dist/{ts-CXTowpzb.js → ts-BFkd0Ip5.js} +2 -2
- package/dist/{versionChecker-GyNJfWh9.js → versionChecker-DD_2696r.js} +2 -2
- package/package.json +1 -1
- package/ts/serve.ts +61 -1
- package/ts/subcommands.spec.ts +17 -0
- package/ts/subcommands.ts +29 -9
- package/dist/SUPPORTED_CLIS-CdneNjsn.js +0 -8
- package/dist/subcommands-e07QqFnu.js +0 -9
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as CLIS_CONFIG } from "./ts-
|
|
1
|
+
import { t as CLIS_CONFIG } from "./ts-BFkd0Ip5.js";
|
|
2
2
|
|
|
3
3
|
//#region ts/SUPPORTED_CLIS.ts
|
|
4
4
|
const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
|
|
5
5
|
|
|
6
6
|
//#endregion
|
|
7
7
|
export { SUPPORTED_CLIS as t };
|
|
8
|
-
//# sourceMappingURL=SUPPORTED_CLIS-
|
|
8
|
+
//# sourceMappingURL=SUPPORTED_CLIS-DQsE1x3p.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "./ts-BFkd0Ip5.js";
|
|
2
|
+
import "./logger-CDIsZ-Pp.js";
|
|
3
|
+
import "./versionChecker-DD_2696r.js";
|
|
4
|
+
import "./pidStore-fqXqTKkh.js";
|
|
5
|
+
import "./globalPidIndex-DlmmJlO8.js";
|
|
6
|
+
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-DQsE1x3p.js";
|
|
7
|
+
|
|
8
|
+
export { SUPPORTED_CLIS };
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { t as invokedCliName } from "./invokedCli-uqM2YYA7.js";
|
|
3
3
|
import { n as logger } from "./logger-CDIsZ-Pp.js";
|
|
4
|
-
import { i as versionString, n as displayVersion, r as getInstalledPackage, t as checkAndAutoUpdate } from "./versionChecker-
|
|
4
|
+
import { i as versionString, n as displayVersion, r as getInstalledPackage, t as checkAndAutoUpdate } from "./versionChecker-DD_2696r.js";
|
|
5
5
|
import { argv } from "process";
|
|
6
6
|
import { execFileSync, spawn } from "child_process";
|
|
7
7
|
import ms from "ms";
|
|
@@ -481,7 +481,7 @@ function buildRustArgs(argv, cliFromScript, supportedClis) {
|
|
|
481
481
|
const rawArg = process.argv[2];
|
|
482
482
|
const managerCommands = !invokedCliName(process.argv);
|
|
483
483
|
const isHelpFlag = rawArg === "-h" || rawArg === "--help";
|
|
484
|
-
const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-
|
|
484
|
+
const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-BMx45Ww-.js");
|
|
485
485
|
if (isHelpFlag && process.argv.length === 3) {
|
|
486
486
|
cmdHelp(managerCommands);
|
|
487
487
|
process.exit(0);
|
|
@@ -514,7 +514,7 @@ if (config.useRust) {
|
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
516
|
if (rustBinary) {
|
|
517
|
-
const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-
|
|
517
|
+
const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-Miuhk6xh.js");
|
|
518
518
|
const rustArgs = buildRustArgs(process.argv, config.cli, SUPPORTED_CLIS);
|
|
519
519
|
if (config.verbose) {
|
|
520
520
|
console.log(`[rust] Using binary: ${rustBinary}`);
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-
|
|
1
|
+
import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-BFkd0Ip5.js";
|
|
2
2
|
import "./logger-CDIsZ-Pp.js";
|
|
3
|
-
import "./versionChecker-
|
|
3
|
+
import "./versionChecker-DD_2696r.js";
|
|
4
4
|
import "./pidStore-fqXqTKkh.js";
|
|
5
5
|
import "./globalPidIndex-DlmmJlO8.js";
|
|
6
6
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./ts-
|
|
1
|
+
import "./ts-BFkd0Ip5.js";
|
|
2
2
|
import "./logger-CDIsZ-Pp.js";
|
|
3
|
-
import "./versionChecker-
|
|
3
|
+
import "./versionChecker-DD_2696r.js";
|
|
4
4
|
import "./pidStore-fqXqTKkh.js";
|
|
5
5
|
import "./globalPidIndex-DlmmJlO8.js";
|
|
6
|
-
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-
|
|
6
|
+
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-DQsE1x3p.js";
|
|
7
7
|
import { o as resolveSpawnCwd } from "./workspaceConfig-B0Q9-q2B.js";
|
|
8
8
|
import { createHash } from "node:crypto";
|
|
9
9
|
|
|
@@ -141,4 +141,4 @@ async function cmdSchedule(rest) {
|
|
|
141
141
|
|
|
142
142
|
//#endregion
|
|
143
143
|
export { cmdSchedule };
|
|
144
|
-
//# sourceMappingURL=schedule-
|
|
144
|
+
//# sourceMappingURL=schedule-PSUIDl7t.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import "./ts-
|
|
1
|
+
import "./ts-BFkd0Ip5.js";
|
|
2
2
|
import "./logger-CDIsZ-Pp.js";
|
|
3
|
-
import { r as getInstalledPackage } from "./versionChecker-
|
|
3
|
+
import { r as getInstalledPackage } from "./versionChecker-DD_2696r.js";
|
|
4
4
|
import "./pidStore-fqXqTKkh.js";
|
|
5
5
|
import { a as updateGlobalPidStatus } from "./globalPidIndex-DlmmJlO8.js";
|
|
6
6
|
import { t as pgidForWrapper } from "./reaper-C-eWAxIj.js";
|
|
7
7
|
import "./configShared-CEyhl0WH.js";
|
|
8
|
-
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-
|
|
8
|
+
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-DQsE1x3p.js";
|
|
9
9
|
import "./e2e-Bfw7qL9O.js";
|
|
10
10
|
import "./webrtcLink-CBZkZ-LT.js";
|
|
11
11
|
import "./remotes-DBCvpp3B.js";
|
|
12
12
|
import { a as isProvisionAllowed, i as hasSpawnHook, n as getSpawnHook, o as resolveSpawnCwd, t as getProvisionRoot } from "./workspaceConfig-B0Q9-q2B.js";
|
|
13
|
-
import {
|
|
13
|
+
import { D as writeToIpc, T as snapshotStatus, _ as readPtysize, b as resolveOne, c as extractTaskCounts, g as readNotes, i as controlCodeFromName, m as listRecords, o as deriveLiveStatus, v as renderRawLog } from "./subcommands-BLFAm8Ph.js";
|
|
14
14
|
import yargs from "yargs";
|
|
15
15
|
import { mkdir, open, readFile, stat, unlink, writeFile } from "fs/promises";
|
|
16
16
|
import { homedir, hostname, userInfo } from "os";
|
|
@@ -100,12 +100,51 @@ const SESSION_PIN_ENV = new Set([
|
|
|
100
100
|
"CLAUDE_CODE_ENTRYPOINT",
|
|
101
101
|
"AGENT_YES_PID"
|
|
102
102
|
]);
|
|
103
|
+
let loginShellEnvCache;
|
|
104
|
+
function loginShellEnv() {
|
|
105
|
+
if (loginShellEnvCache !== void 0) return loginShellEnvCache;
|
|
106
|
+
loginShellEnvCache = null;
|
|
107
|
+
if (process.platform === "win32") return loginShellEnvCache;
|
|
108
|
+
try {
|
|
109
|
+
const shell = process.env.SHELL || "/bin/sh";
|
|
110
|
+
const delim = "_AY_SHELL_ENV_DELIM_";
|
|
111
|
+
const out = Bun.spawnSync([
|
|
112
|
+
shell,
|
|
113
|
+
"-ilc",
|
|
114
|
+
`printf %s "${delim}"; env -0; printf %s "${delim}"`
|
|
115
|
+
], {
|
|
116
|
+
stdin: "ignore",
|
|
117
|
+
stderr: "ignore",
|
|
118
|
+
timeout: 5e3,
|
|
119
|
+
env: process.env
|
|
120
|
+
}).stdout?.toString() ?? "";
|
|
121
|
+
const start = out.indexOf(delim);
|
|
122
|
+
const end = out.lastIndexOf(delim);
|
|
123
|
+
if (start === -1 || end <= start) return loginShellEnvCache;
|
|
124
|
+
const dump = out.slice(start + 20, end);
|
|
125
|
+
const env = {};
|
|
126
|
+
for (const pair of dump.split("\0")) {
|
|
127
|
+
if (!pair) continue;
|
|
128
|
+
const eq = pair.indexOf("=");
|
|
129
|
+
if (eq <= 0) continue;
|
|
130
|
+
env[pair.slice(0, eq)] = pair.slice(eq + 1);
|
|
131
|
+
}
|
|
132
|
+
if (env.PATH) loginShellEnvCache = env;
|
|
133
|
+
} catch {}
|
|
134
|
+
return loginShellEnvCache;
|
|
135
|
+
}
|
|
103
136
|
function freshAgentEnv() {
|
|
137
|
+
const login = loginShellEnv();
|
|
104
138
|
const env = {};
|
|
105
|
-
|
|
139
|
+
const base = login ?? process.env;
|
|
140
|
+
for (const [k, v] of Object.entries(base)) {
|
|
106
141
|
if (v === void 0 || SESSION_PIN_ENV.has(k)) continue;
|
|
107
142
|
env[k] = v;
|
|
108
143
|
}
|
|
144
|
+
if (login) for (const [k, v] of Object.entries(process.env)) {
|
|
145
|
+
if (v === void 0 || SESSION_PIN_ENV.has(k) || k in env) continue;
|
|
146
|
+
env[k] = v;
|
|
147
|
+
}
|
|
109
148
|
return env;
|
|
110
149
|
}
|
|
111
150
|
const DAEMON_NAME = "agent-yes";
|
|
@@ -1350,4 +1389,4 @@ Options:
|
|
|
1350
1389
|
|
|
1351
1390
|
//#endregion
|
|
1352
1391
|
export { cmdServe };
|
|
1353
|
-
//# sourceMappingURL=serve-
|
|
1392
|
+
//# sourceMappingURL=serve-CmjJUNC3.js.map
|
|
@@ -32,7 +32,7 @@ async function cmdSetup(rest) {
|
|
|
32
32
|
if (!existsSync(abs)) process.stderr.write(` note: that directory doesn't exist yet — create it, or agents spawned there will fail\n`);
|
|
33
33
|
if (noShare) return 0;
|
|
34
34
|
process.stdout.write(`\nsharing this machine to agent-yes.com…\n`);
|
|
35
|
-
const { cmdServe } = await import("./serve-
|
|
35
|
+
const { cmdServe } = await import("./serve-CmjJUNC3.js");
|
|
36
36
|
return cmdServe([
|
|
37
37
|
"install",
|
|
38
38
|
"--share",
|
|
@@ -42,4 +42,4 @@ async function cmdSetup(rest) {
|
|
|
42
42
|
|
|
43
43
|
//#endregion
|
|
44
44
|
export { cmdSetup };
|
|
45
|
-
//# sourceMappingURL=setup-
|
|
45
|
+
//# sourceMappingURL=setup-19SmDp6U.js.map
|
|
@@ -554,15 +554,15 @@ async function runSubcommand(argv) {
|
|
|
554
554
|
case "restart": return await cmdRestart(rest);
|
|
555
555
|
case "note": return await cmdNote(rest);
|
|
556
556
|
case "serve": {
|
|
557
|
-
const { cmdServe } = await import("./serve-
|
|
557
|
+
const { cmdServe } = await import("./serve-CmjJUNC3.js");
|
|
558
558
|
return cmdServe(rest);
|
|
559
559
|
}
|
|
560
560
|
case "setup": {
|
|
561
|
-
const { cmdSetup } = await import("./setup-
|
|
561
|
+
const { cmdSetup } = await import("./setup-19SmDp6U.js");
|
|
562
562
|
return cmdSetup(rest);
|
|
563
563
|
}
|
|
564
564
|
case "schedule": {
|
|
565
|
-
const { cmdSchedule } = await import("./schedule-
|
|
565
|
+
const { cmdSchedule } = await import("./schedule-PSUIDl7t.js");
|
|
566
566
|
return cmdSchedule(rest);
|
|
567
567
|
}
|
|
568
568
|
case "remote": {
|
|
@@ -2343,6 +2343,14 @@ async function waitForExit(pid, timeoutMs) {
|
|
|
2343
2343
|
}
|
|
2344
2344
|
return !isPidAlive(pid);
|
|
2345
2345
|
}
|
|
2346
|
+
function restartHintLines(cli, cwd, strategy) {
|
|
2347
|
+
return {
|
|
2348
|
+
out: `restarted ${cli} in ${shortenPath(cwd)} via ${strategy}\n`,
|
|
2349
|
+
err: `
|
|
2350
|
+
the resumed agent re-registers under a new pid a moment later — reach it by cwd:
|
|
2351
|
+
ay tail -f ${cwd} # follow the resumed agent\n ay ls # list all agents\n`
|
|
2352
|
+
};
|
|
2353
|
+
}
|
|
2346
2354
|
async function cmdRestart(rest) {
|
|
2347
2355
|
const argv = await yargs(rest).usage("Usage: ay restart <keyword> [--fresh]").option("latest", {
|
|
2348
2356
|
type: "boolean",
|
|
@@ -2385,7 +2393,7 @@ async function cmdRestart(rest) {
|
|
|
2385
2393
|
fresh,
|
|
2386
2394
|
prompt: record.prompt
|
|
2387
2395
|
});
|
|
2388
|
-
|
|
2396
|
+
Bun.spawn([
|
|
2389
2397
|
"agent-yes",
|
|
2390
2398
|
"--cli=" + record.cli,
|
|
2391
2399
|
...resumeArgs
|
|
@@ -2398,8 +2406,9 @@ async function cmdRestart(rest) {
|
|
|
2398
2406
|
"ignore"
|
|
2399
2407
|
]
|
|
2400
2408
|
});
|
|
2401
|
-
|
|
2402
|
-
process.
|
|
2409
|
+
const { out, err } = restartHintLines(record.cli, record.cwd, strategy);
|
|
2410
|
+
process.stdout.write(out);
|
|
2411
|
+
process.stderr.write(err);
|
|
2403
2412
|
return 0;
|
|
2404
2413
|
}
|
|
2405
2414
|
async function cmdNote(rest) {
|
|
@@ -2709,5 +2718,5 @@ async function cmdResultSet(rest) {
|
|
|
2709
2718
|
}
|
|
2710
2719
|
|
|
2711
2720
|
//#endregion
|
|
2712
|
-
export {
|
|
2713
|
-
//# sourceMappingURL=subcommands-
|
|
2721
|
+
export { restartHintLines as C, writeToIpc as D, stopTipForCli as E, resolveResumeArgs as S, snapshotStatus as T, readPtysize as _, cursorAbs as a, resolveOne as b, extractTaskCounts as c, isExitRequest as d, isPidAlive as f, readNotes as g, matchKeyword as h, controlCodeFromName as i, finalizedLines as l, listRecords as m, READ_PAGE_DEFAULT as n, deriveLiveStatus as o, isSubcommand as p, cmdHelp as r, extractNeedsInput as s, GRACEFUL_EXIT_COMMANDS as t, isAgentStuck as u, renderRawLog as v, runSubcommand as w, resolveReadWindow as x, renderRawLogLines as y };
|
|
2722
|
+
//# sourceMappingURL=subcommands-BLFAm8Ph.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "./logger-CDIsZ-Pp.js";
|
|
2
|
+
import "./globalPidIndex-DlmmJlO8.js";
|
|
3
|
+
import "./configShared-CEyhl0WH.js";
|
|
4
|
+
import "./e2e-Bfw7qL9O.js";
|
|
5
|
+
import "./webrtcLink-CBZkZ-LT.js";
|
|
6
|
+
import "./remotes-DBCvpp3B.js";
|
|
7
|
+
import { C as restartHintLines, D as writeToIpc, E as stopTipForCli, S as resolveResumeArgs, T as snapshotStatus, _ as readPtysize, a as cursorAbs, b as resolveOne, c as extractTaskCounts, d as isExitRequest, f as isPidAlive, g as readNotes, h as matchKeyword, i as controlCodeFromName, l as finalizedLines, m as listRecords, n as READ_PAGE_DEFAULT, o as deriveLiveStatus, p as isSubcommand, r as cmdHelp, s as extractNeedsInput, t as GRACEFUL_EXIT_COMMANDS, u as isAgentStuck, v as renderRawLog, w as runSubcommand, x as resolveReadWindow, y as renderRawLogLines } from "./subcommands-BLFAm8Ph.js";
|
|
8
|
+
|
|
9
|
+
export { cmdHelp, isSubcommand, runSubcommand };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as logger, t as addTransport } from "./logger-CDIsZ-Pp.js";
|
|
2
|
-
import { r as getInstalledPackage } from "./versionChecker-
|
|
2
|
+
import { r as getInstalledPackage } from "./versionChecker-DD_2696r.js";
|
|
3
3
|
import { t as agentYesHome } from "./agentYesHome-_eJa3DaX.js";
|
|
4
4
|
import { i as shouldUseLock, r as releaseLock, t as acquireLock } from "./runningLock-V4qvXgAw.js";
|
|
5
5
|
import { t as PidStore } from "./pidStore-fqXqTKkh.js";
|
|
@@ -1802,4 +1802,4 @@ function sleep(ms) {
|
|
|
1802
1802
|
|
|
1803
1803
|
//#endregion
|
|
1804
1804
|
export { removeControlCharacters as a, AgentContext as i, agentYes as n, config as r, CLIS_CONFIG as t };
|
|
1805
|
-
//# sourceMappingURL=ts-
|
|
1805
|
+
//# sourceMappingURL=ts-BFkd0Ip5.js.map
|
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from "url";
|
|
|
7
7
|
|
|
8
8
|
//#region package.json
|
|
9
9
|
var name = "claude-yes";
|
|
10
|
-
var version = "1.
|
|
10
|
+
var version = "1.160.1";
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region ts/versionChecker.ts
|
|
@@ -215,4 +215,4 @@ async function displayVersion() {
|
|
|
215
215
|
|
|
216
216
|
//#endregion
|
|
217
217
|
export { versionString as i, displayVersion as n, getInstalledPackage as r, checkAndAutoUpdate as t };
|
|
218
|
-
//# sourceMappingURL=versionChecker-
|
|
218
|
+
//# sourceMappingURL=versionChecker-DD_2696r.js.map
|
package/package.json
CHANGED
package/ts/serve.ts
CHANGED
|
@@ -152,6 +152,52 @@ const SESSION_PIN_ENV = new Set([
|
|
|
152
152
|
"AGENT_YES_PID",
|
|
153
153
|
]);
|
|
154
154
|
|
|
155
|
+
// The login-shell environment, captured once and cached for the daemon's
|
|
156
|
+
// lifetime. `ay serve` is daemonized by oxmgr/launchd/pm2, which start it with a
|
|
157
|
+
// minimal PATH that never sourced the user's ~/.zshrc / ~/.zprofile — so it lacks
|
|
158
|
+
// ~/.bun/bin, ~/.cargo/bin, Homebrew, nvm shims, etc. A console-spawned agent
|
|
159
|
+
// that inherits that env can't find `bun`/`bunx`/etc. (the user reported "bunx:
|
|
160
|
+
// command not found" when spawning a new agent from the web UI). We recover the
|
|
161
|
+
// real environment by running the user's interactive login shell and dumping its
|
|
162
|
+
// env, exactly as a fresh terminal would have it. Returns null on Windows (no
|
|
163
|
+
// rc-file model — the process env is already the right one) or on any failure, so
|
|
164
|
+
// callers fall back to process.env.
|
|
165
|
+
let loginShellEnvCache: Record<string, string> | null | undefined;
|
|
166
|
+
function loginShellEnv(): Record<string, string> | null {
|
|
167
|
+
if (loginShellEnvCache !== undefined) return loginShellEnvCache;
|
|
168
|
+
loginShellEnvCache = null;
|
|
169
|
+
if (process.platform === "win32") return loginShellEnvCache;
|
|
170
|
+
try {
|
|
171
|
+
const shell = process.env.SHELL || "/bin/sh";
|
|
172
|
+
// Delimiters fence off the env dump from any banner/prompt noise the rc files
|
|
173
|
+
// print to stdout; `env -0` is NUL-separated so values with newlines survive.
|
|
174
|
+
const delim = "_AY_SHELL_ENV_DELIM_";
|
|
175
|
+
const res = Bun.spawnSync([shell, "-ilc", `printf %s "${delim}"; env -0; printf %s "${delim}"`], {
|
|
176
|
+
stdin: "ignore",
|
|
177
|
+
stderr: "ignore",
|
|
178
|
+
timeout: 5_000,
|
|
179
|
+
env: process.env as Record<string, string>,
|
|
180
|
+
});
|
|
181
|
+
const out = res.stdout?.toString() ?? "";
|
|
182
|
+
const start = out.indexOf(delim);
|
|
183
|
+
const end = out.lastIndexOf(delim);
|
|
184
|
+
if (start === -1 || end <= start) return loginShellEnvCache;
|
|
185
|
+
const dump = out.slice(start + delim.length, end);
|
|
186
|
+
const env: Record<string, string> = {};
|
|
187
|
+
for (const pair of dump.split("\0")) {
|
|
188
|
+
if (!pair) continue;
|
|
189
|
+
const eq = pair.indexOf("=");
|
|
190
|
+
if (eq <= 0) continue;
|
|
191
|
+
env[pair.slice(0, eq)] = pair.slice(eq + 1);
|
|
192
|
+
}
|
|
193
|
+
// Require a usable result — a PATH carrying ~/.bun/bin is the whole point.
|
|
194
|
+
if (env.PATH) loginShellEnvCache = env;
|
|
195
|
+
} catch {
|
|
196
|
+
// best-effort; fall back to process.env
|
|
197
|
+
}
|
|
198
|
+
return loginShellEnvCache;
|
|
199
|
+
}
|
|
200
|
+
|
|
155
201
|
// Env for a console-spawned agent, minus only the session-pinning vars above. If
|
|
156
202
|
// `ay serve` was launched from inside Claude Code (or any shell carrying these),
|
|
157
203
|
// it would otherwise leak the parent's SSE port / session id into every spawned
|
|
@@ -159,12 +205,26 @@ const SESSION_PIN_ENV = new Set([
|
|
|
159
205
|
// stale port, surfacing as "fail to connect". Dropping them makes each agent a
|
|
160
206
|
// clean top-level session; all config/provider env (CLAUDE_EFFORT, CLAUDE_CODE_*
|
|
161
207
|
// settings) is preserved.
|
|
208
|
+
//
|
|
209
|
+
// The base is the login-shell env (see loginShellEnv) so the agent behaves like
|
|
210
|
+
// one launched from a fresh terminal — PATH and anything ~/.zshrc exports are
|
|
211
|
+
// present. Daemon-only vars that the login shell doesn't define (e.g. provider
|
|
212
|
+
// keys exported when `ay serve` was launched) are layered back on so nothing the
|
|
213
|
+
// daemon was deliberately given is lost; for keys in both, the login shell wins.
|
|
162
214
|
function freshAgentEnv(): Record<string, string> {
|
|
215
|
+
const login = loginShellEnv();
|
|
163
216
|
const env: Record<string, string> = {};
|
|
164
|
-
|
|
217
|
+
const base = login ?? (process.env as Record<string, string>);
|
|
218
|
+
for (const [k, v] of Object.entries(base)) {
|
|
165
219
|
if (v === undefined || SESSION_PIN_ENV.has(k)) continue;
|
|
166
220
|
env[k] = v;
|
|
167
221
|
}
|
|
222
|
+
if (login) {
|
|
223
|
+
for (const [k, v] of Object.entries(process.env)) {
|
|
224
|
+
if (v === undefined || SESSION_PIN_ENV.has(k) || k in env) continue;
|
|
225
|
+
env[k] = v;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
168
228
|
return env;
|
|
169
229
|
}
|
|
170
230
|
|
package/ts/subcommands.spec.ts
CHANGED
|
@@ -1520,6 +1520,23 @@ describe("subcommands.cmdRestart", () => {
|
|
|
1520
1520
|
// (signal 0 throws only if the pid is gone / not signalable.)
|
|
1521
1521
|
expect(() => process.kill(process.pid, 0)).not.toThrow();
|
|
1522
1522
|
});
|
|
1523
|
+
|
|
1524
|
+
// The post-restart hint must NOT print a pid (the resumed agent's pid races and
|
|
1525
|
+
// resolves to "no agent matched" — the reported "restart not working"). It must
|
|
1526
|
+
// instead key `ay tail` on the cwd, which is the one stable handle at this point.
|
|
1527
|
+
it("restartHintLines keys the watch hint on cwd, never a pid", async () => {
|
|
1528
|
+
const mod = await loadModule();
|
|
1529
|
+
const cwd = "/Users/x/ws/proj/tree/docs";
|
|
1530
|
+
const { out, err } = mod.restartHintLines("claude", cwd, "restoreArgs (--continue)");
|
|
1531
|
+
expect(out).toMatch(/restarted claude in/);
|
|
1532
|
+
expect(out).not.toMatch(/new pid/); // the old, broken phrasing
|
|
1533
|
+
// `ay tail -f <cwd>` — a substring of the agent's absolute cwd, so it resolves
|
|
1534
|
+
// regardless of which pid the resume settles on.
|
|
1535
|
+
expect(err).toMatch(/ay tail -f \/Users\/x\/ws\/proj\/tree\/docs/);
|
|
1536
|
+
expect(err).toMatch(/ay ls/);
|
|
1537
|
+
// No bare numeric pid anywhere in the hint.
|
|
1538
|
+
expect(`${out}${err}`).not.toMatch(/\bpid \d+/);
|
|
1539
|
+
});
|
|
1523
1540
|
});
|
|
1524
1541
|
|
|
1525
1542
|
// ---------------------------------------------------------------------------
|
package/ts/subcommands.ts
CHANGED
|
@@ -2815,6 +2815,29 @@ async function waitForExit(pid: number, timeoutMs: number): Promise<boolean> {
|
|
|
2815
2815
|
return !isPidAlive(pid);
|
|
2816
2816
|
}
|
|
2817
2817
|
|
|
2818
|
+
// Post-restart hint. The resumed agent's pid is NOT knowable synchronously here:
|
|
2819
|
+
// `proc.pid` is the `agent-yes` launcher we just spawned (a wrapper/bin shim
|
|
2820
|
+
// whose pid differs from the registered agent), and the resume itself bootstraps
|
|
2821
|
+
// through a throwaway pid that dies before the real TUI re-registers under yet
|
|
2822
|
+
// another pid seconds later — with a window where nothing is registered at all.
|
|
2823
|
+
// So any pid we print here would race and usually resolve to "no agent matched"
|
|
2824
|
+
// (the reported "restart not working"). The cwd is the one stable handle, and
|
|
2825
|
+
// `ay tail`/`ay ls` already accept a cwd substring, so we key the hint on cwd.
|
|
2826
|
+
export function restartHintLines(
|
|
2827
|
+
cli: string,
|
|
2828
|
+
cwd: string,
|
|
2829
|
+
strategy: string,
|
|
2830
|
+
): { out: string; err: string } {
|
|
2831
|
+
return {
|
|
2832
|
+
out: `restarted ${cli} in ${shortenPath(cwd)} via ${strategy}\n`,
|
|
2833
|
+
err:
|
|
2834
|
+
`\n` +
|
|
2835
|
+
`the resumed agent re-registers under a new pid a moment later — reach it by cwd:\n` +
|
|
2836
|
+
` ay tail -f ${cwd} # follow the resumed agent\n` +
|
|
2837
|
+
` ay ls # list all agents\n`,
|
|
2838
|
+
};
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2818
2841
|
async function cmdRestart(rest: string[]): Promise<number> {
|
|
2819
2842
|
const y = yargs(rest)
|
|
2820
2843
|
.usage("Usage: ay restart <keyword> [--fresh]")
|
|
@@ -2875,20 +2898,17 @@ async function cmdRestart(rest: string[]): Promise<number> {
|
|
|
2875
2898
|
prompt: record.prompt,
|
|
2876
2899
|
});
|
|
2877
2900
|
|
|
2878
|
-
|
|
2901
|
+
// Detached launcher; we deliberately don't track its pid — see restartHintLines
|
|
2902
|
+
// for why the resumed agent's pid isn't reportable synchronously.
|
|
2903
|
+
Bun.spawn(["agent-yes", "--cli=" + record.cli, ...resumeArgs], {
|
|
2879
2904
|
cwd: record.cwd,
|
|
2880
2905
|
detached: true,
|
|
2881
2906
|
stdio: ["ignore", "ignore", "ignore"],
|
|
2882
2907
|
});
|
|
2883
2908
|
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
);
|
|
2887
|
-
process.stderr.write(
|
|
2888
|
-
`\n` +
|
|
2889
|
-
` ay tail ${proc.pid} # watch output\n` +
|
|
2890
|
-
` ay ls # list all agents\n`,
|
|
2891
|
-
);
|
|
2909
|
+
const { out, err } = restartHintLines(record.cli, record.cwd, strategy);
|
|
2910
|
+
process.stdout.write(out);
|
|
2911
|
+
process.stderr.write(err);
|
|
2892
2912
|
return 0;
|
|
2893
2913
|
}
|
|
2894
2914
|
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import "./ts-CXTowpzb.js";
|
|
2
|
-
import "./logger-CDIsZ-Pp.js";
|
|
3
|
-
import "./versionChecker-GyNJfWh9.js";
|
|
4
|
-
import "./pidStore-fqXqTKkh.js";
|
|
5
|
-
import "./globalPidIndex-DlmmJlO8.js";
|
|
6
|
-
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-BtV-mke0.js";
|
|
7
|
-
|
|
8
|
-
export { SUPPORTED_CLIS };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import "./logger-CDIsZ-Pp.js";
|
|
2
|
-
import "./globalPidIndex-DlmmJlO8.js";
|
|
3
|
-
import "./configShared-CEyhl0WH.js";
|
|
4
|
-
import "./e2e-Bfw7qL9O.js";
|
|
5
|
-
import "./webrtcLink-CBZkZ-LT.js";
|
|
6
|
-
import "./remotes-DBCvpp3B.js";
|
|
7
|
-
import { C as runSubcommand, E as writeToIpc, S as resolveResumeArgs, T as stopTipForCli, _ as readPtysize, a as cursorAbs, b as resolveOne, c as extractTaskCounts, d as isExitRequest, f as isPidAlive, g as readNotes, h as matchKeyword, i as controlCodeFromName, l as finalizedLines, m as listRecords, n as READ_PAGE_DEFAULT, o as deriveLiveStatus, p as isSubcommand, r as cmdHelp, s as extractNeedsInput, t as GRACEFUL_EXIT_COMMANDS, u as isAgentStuck, v as renderRawLog, w as snapshotStatus, x as resolveReadWindow, y as renderRawLogLines } from "./subcommands-BhGxt0eA.js";
|
|
8
|
-
|
|
9
|
-
export { cmdHelp, isSubcommand, runSubcommand };
|