agent-yes 1.303.1 → 1.304.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/default.config.yaml +5 -5
- package/dist/{JsonlStore-BpYZZTap.js → JsonlStore-CB_0sfdT.js} +5 -4
- package/dist/{SUPPORTED_CLIS-Dq9Lq9WJ.js → SUPPORTED_CLIS-C_1IiOj3.js} +2 -2
- package/dist/SUPPORTED_CLIS-Do3GHAY1.js +12 -0
- package/dist/{agentShare-suB6yPgO.js → agentShare-BvpEm-Fr.js} +10 -9
- package/dist/{askCli-BU3CNCLU.js → askCli-KmMf-3wA.js} +6 -6
- package/dist/{browser-BmxN1Ur9.js → browser-BAFPmEvN.js} +2 -2
- package/dist/{callback-Ctj3_Wxp.js → callback-BiSUhjw7.js} +6 -6
- package/dist/callback-SqLD2mMX.js +17 -0
- package/dist/{callbackCore-DSJWhqAe.js → callbackCore-BZ_10zyc.js} +1 -1
- package/dist/{callbackCore-BesbQ6-Z.js → callbackCore-Deve5pv3.js} +1 -1
- package/dist/{channels-j5nWuzlQ.js → channels-Y36S0ccW.js} +2 -2
- package/dist/cli.js +118 -13
- package/dist/{cmdDsh-2LP0grim.js → cmdDsh-DZ8bLsH7.js} +1 -1
- package/dist/cmdKill-CzSBfWmx.js +116 -0
- package/dist/{cmdPs-wc1j85fi.js → cmdPs-DBt23Qz0.js} +11 -10
- package/dist/{cwdConflictWarn-skQSMwEh.js → cwdConflictWarn-y-epQyOj.js} +21 -5
- package/dist/{cwdPassthroughHint-BUbWMoz0.js → cwdPassthroughHint-CzWh0hrw.js} +1 -1
- package/dist/{expose-Dawq1LxC.js → expose-Bhsn5yUz.js} +2 -2
- package/dist/forceKill-BDqxx4uQ.js +44 -0
- package/dist/{forkNested-CavHyWzA.js → forkNested-3heLs5XC.js} +45 -5
- package/dist/{globalPidIndex-CRB5KtyL.js → globalPidIndex-BsjlId-h.js} +6 -5
- package/dist/{globalPidIndex-BftWlg2V.js → globalPidIndex-uoz8Esqz.js} +2 -2
- package/dist/{hist-Cs0KFSUW.js → hist-DY16wm7g.js} +1 -1
- package/dist/{identity-DA7YI9km.js → identity-C0MxfwI2.js} +1 -1
- package/dist/{identity-Bk-aG_xl.js → identity-Ckav3-Up.js} +1 -1
- package/dist/index.js +7 -7
- package/dist/{initMsg-CcTqFtsp.js → initMsg-BEVDWYnv.js} +1 -1
- package/dist/{initMsg-D9KJnfgC.js → initMsg-GPU52N-j.js} +1 -1
- package/dist/liagent/box-BSIrRRc_.js +2320 -0
- package/dist/liagent/box-DloywR57.d.ts +409 -0
- package/dist/liagent/box.d.ts +3 -0
- package/dist/liagent/box.js +3 -0
- package/dist/liagent/cli.d.ts +1 -0
- package/dist/liagent/cli.js +908 -0
- package/dist/liagent/client.d.ts +28 -0
- package/dist/liagent/client.js +240 -0
- package/dist/liagent/echo-BvzPSI0x.js +86 -0
- package/dist/liagent/echo-W2RcMEny.d.ts +38 -0
- package/dist/liagent/hub.d.ts +405 -0
- package/dist/liagent/hub.js +1831 -0
- package/dist/liagent/index.d.ts +14 -0
- package/dist/liagent/index.js +10 -0
- package/dist/liagent/liagent.js +339 -0
- package/dist/liagent/mic-audio-C3Shud_F.js +754 -0
- package/dist/liagent/mic-audio-DMCWtEI-.d.ts +317 -0
- package/dist/liagent/mic-button-CtZHFBSG.js +651 -0
- package/dist/liagent/mic-button-Y0ioPetQ.d.ts +248 -0
- package/dist/liagent/mic.d.ts +3 -0
- package/dist/liagent/mic.js +4 -0
- package/dist/liagent/progress-CJs08bXb.js +473 -0
- package/dist/liagent/progress-CfE-meHr.d.ts +205 -0
- package/dist/liagent/progress.d.ts +2 -0
- package/dist/liagent/progress.js +3 -0
- package/dist/liagent/protocol.d.ts +324 -0
- package/dist/liagent/protocol.js +504 -0
- package/dist/liagent/speech-rate-DXeJjRTc.js +42 -0
- package/dist/liagent/state-tree-BZCmAknI.js +353 -0
- package/dist/liagent/tree-BrR7NwMf.js +710 -0
- package/dist/liagent/tree-HB9RhX_H.d.ts +295 -0
- package/dist/liagent/tree.d.ts +2 -0
- package/dist/liagent/tree.js +4 -0
- package/dist/liagent/ui-strings-B03le3fh.d.ts +27 -0
- package/dist/liagent/ui-strings-CJIwW5Gf.js +794 -0
- package/dist/liagent/ui.d.ts +394 -0
- package/dist/liagent/ui.js +5 -0
- package/dist/liagent/voice-D7yeS9VM.js +802 -0
- package/dist/liagent/voice-Qo7SCgi8.d.ts +308 -0
- package/dist/liagent/voice.d.ts +3 -0
- package/dist/liagent/voice.js +4 -0
- package/dist/{notifyDaemon-C7GlfJ1E.js → notifyDaemon-DkUB7GV2.js} +10 -9
- package/dist/{openBrowser-1cIo4dJL.js → openBrowser-CQAOIrD6.js} +1 -1
- package/dist/oxmgrService-DlYHmqyI.js +37 -0
- package/dist/oxmgrService-o9L3I6FX.js +3 -0
- package/dist/{parentLink-DoEWVGld.js → parentLink-BcAYcO9L.js} +2 -2
- package/dist/{parentLink-B58V1RVd.js → parentLink-MBUD3oY2.js} +2 -2
- package/dist/{parentPingLoop-C73bbmCE.js → parentPingLoop-DDO592Wh.js} +5 -5
- package/dist/{pidStore-433kvh9D.js → pidStore-C50VPk3E.js} +3 -3
- package/dist/pidStore-COkPjpW8.js +6 -0
- package/dist/{procStats-BvmrBrOs.js → procStats-DwTxj3rs.js} +1 -1
- package/dist/{remotes-MfdV9M8u.js → remotes-BqLoB5GR.js} +2 -2
- package/dist/{remotes-DevcBeLl.js → remotes-BsMGvAay.js} +3 -3
- package/dist/{roomReplyAlias-DFqg_6IU.js → roomReplyAlias-B-v76TA8.js} +3 -3
- package/dist/roomReplyAlias-BzWUBkQy.js +6 -0
- package/dist/{rustBinary-7VK7oLlW.js → rustBinary-BrJ2p8wy.js} +2 -2
- package/dist/{rustBinary-BV4LxMMn.js → rustBinary-vpfpWj1q.js} +2 -2
- package/dist/{schedule-Dp0qkNO1.js → schedule-Bzjhl6-h.js} +15 -44
- package/dist/schedulesCli-CLqieyQZ.js +784 -0
- package/dist/senderAncestry-CVHeKk1Y.js +173 -0
- package/dist/senderAncestry-KhAUPCQs.js +3 -0
- package/dist/{serve-BpOIIOVc.js → serve-XwFYE0cE.js} +67 -69
- package/dist/{serveRust-CbBrcUrg.js → serveRust-BfWkeL6T.js} +31 -4
- package/dist/{setup-DdIBk6Iv.js → setup-D4-s2VZw.js} +5 -5
- package/dist/{share-w5oRbvlj.js → share-CbFetL5H.js} +1 -1
- package/dist/{share-DrS3LYqf.js → share-_TPYAGWC.js} +1 -1
- package/dist/{shareCmd-DDENkBW2.js → shareCmd-DUBsVI3e.js} +10 -10
- package/dist/spawnGate-Dfj9V76w.js +5 -0
- package/dist/{spawnGate-lr3tvA6U.js → spawnGate-Dj_WaS29.js} +3 -3
- package/dist/{subcommands-DxgvDmZX.js → subcommands-B7YZJL8n.js} +471 -307
- package/dist/subcommands-BZPxFgkT.js +15 -0
- package/dist/{systemPathLink-SjUzgSiq.js → systemPathLink-Y3iC7bYV.js} +1 -1
- package/dist/{terminal-C2h7tpe0.js → terminal-13cGj3h6.js} +2 -2
- package/dist/terminal.js +1 -1
- package/dist/{todoAutomation-TTp_Qz9G.js → todoAutomation-CKlrxuZv.js} +2 -2
- package/dist/{todoCli-BWm5nZE0.js → todoCli-CU9vSJSJ.js} +6 -6
- package/dist/{todoIdentity-BvXZKWJI.js → todoIdentity-CzS1e7VL.js} +2 -2
- package/dist/{todoStore-C9RTz0Vs.js → todoStore-msRCEUi1.js} +2 -2
- package/dist/{tray-BeRSozJz.js → tray-CLktEN3G.js} +1 -1
- package/dist/{trayApp-QQjqhDv1.js → trayApp-5_OlvQcz.js} +2 -2
- package/dist/trayApp-DkAPo0m6.js +5 -0
- package/dist/{ts-6LF7f4fx.js → ts-njuddXQz.js} +126 -57
- package/dist/{versionChecker-Bc62HNf6.js → versionChecker-BJycAanp.js} +2 -2
- package/dist/{webrtcLink-va_gAR77.js → webrtcLink-DcvacEci.js} +1 -1
- package/dist/{webrtcLink-SsInrVHU.js → webrtcLink-WxS1nTIs.js} +1 -1
- package/dist/{webrtcRemote-BlGyNZDC.js → webrtcRemote-C3xQyf3u.js} +2 -2
- package/dist/{widget-Crb5zeHL.js → widget-DmRwOlco.js} +3 -3
- package/dist/widgets.js +1 -1
- package/dist/{workspaceConfig-BLWB5Wu9.js → workspaceConfig-DBgsu81B.js} +1 -1
- package/dist/{ws-DIbwNz8Z.js → ws-ByO6JO6m.js} +3 -3
- package/dist/{ws-BRhPG1Vy.js → ws-D0-Jg88z.js} +9 -8
- package/lab/ui/index.html +1 -1
- package/lab/ui/lab/posts/2026-08-11-slack-term-safe-writes.md +1 -1
- package/package.json +73 -8
- package/ts/JsonlStore.ts +10 -3
- package/ts/cli-idle.bun.spec.ts +1 -1
- package/ts/cli-idle.spec.ts +1 -1
- package/ts/cli.ts +35 -0
- package/ts/cmdKill.bun.spec.ts +155 -0
- package/ts/cmdKill.spec.ts +155 -0
- package/ts/cmdKill.ts +183 -0
- package/ts/composerGuard.edges.spec.ts +91 -0
- package/ts/composerGuard.spec.ts +53 -6
- package/ts/composerGuard.ts +42 -13
- package/ts/conptyModeFilter.spec.ts +30 -0
- package/ts/conptyModeFilter.ts +53 -0
- package/ts/copyLiagent.ts +42 -0
- package/ts/cwdConflictWarn.io.spec.ts +50 -0
- package/ts/cwdConflictWarn.spec.ts +34 -1
- package/ts/cwdConflictWarn.ts +43 -5
- package/ts/cwdGuard.spec.ts +110 -0
- package/ts/cwdGuard.ts +118 -0
- package/ts/forceKill.ts +52 -0
- package/ts/forkNested.bun.spec.ts +41 -0
- package/ts/forkNested.spec.ts +41 -0
- package/ts/forkNested.ts +48 -1
- package/ts/globalPidIndex.edges.spec.ts +125 -0
- package/ts/globalPidIndex.ts +6 -2
- package/ts/index.ts +13 -1
- package/ts/interruptSend.bun.spec.ts +99 -0
- package/ts/interruptSend.spec.ts +99 -0
- package/ts/interruptSend.ts +51 -0
- package/ts/lockRegistry.spec.ts +49 -0
- package/ts/lsRenderCache.spec.ts +58 -0
- package/ts/needsInput.edges.spec.ts +23 -0
- package/ts/parseCliArgs.ts +7 -0
- package/ts/pushGatePlan.spec.ts +147 -0
- package/ts/roomReplyAlias.io.spec.ts +81 -0
- package/ts/schedule.ts +5 -1
- package/ts/schedules.bun.spec.ts +397 -0
- package/ts/schedules.spec.ts +397 -0
- package/ts/schedules.ts +517 -0
- package/ts/schedulesCli.ts +386 -0
- package/ts/sendControl.bun.spec.ts +12 -0
- package/ts/senderAncestry.ts +1 -3
- package/ts/serve.ts +22 -33
- package/ts/serveRust.spec.ts +29 -2
- package/ts/serveRust.ts +27 -2
- package/ts/sizeNego.bun.spec.ts +9 -2
- package/ts/sizeNego.spec.ts +9 -2
- package/ts/sizeNego.ts +10 -5
- package/ts/subcommands.spec.ts +348 -9
- package/ts/subcommands.ts +513 -93
- package/ts/suggestAgents.spec.ts +33 -0
- package/ts/terminal/browser.ts +1 -1
- package/ts/todoParse.spec.ts +22 -1
- package/ts/todoParse.ts +19 -0
- package/dist/SUPPORTED_CLIS-ByO5twge.js +0 -12
- package/dist/callback-D7qfh_7p.js +0 -16
- package/dist/pidStore-BRlKRHXY.js +0 -6
- package/dist/roomReplyAlias-DuEkSSDI.js +0 -6
- package/dist/spawnGate-DeQBTX-o.js +0 -5
- package/dist/subcommands-DmiswRy4.js +0 -14
- package/dist/trayApp-C4TAvRvU.js +0 -5
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { o as pidOwnershipVerdict } from "./senderAncestry-CVHeKk1Y.js";
|
|
2
|
+
import yargs from "yargs";
|
|
3
|
+
|
|
4
|
+
//#region ts/cmdKill.ts
|
|
5
|
+
/**
|
|
6
|
+
* Why a kill of `record` must not go ahead, or null. Pure, so each refusal is
|
|
7
|
+
* unit-tested. `selfChain` is the caller and its ancestors; `selfPgid` the
|
|
8
|
+
* caller's process group (null when unknown).
|
|
9
|
+
*/
|
|
10
|
+
function killRefusal(record, targets, selfChain, selfPgid) {
|
|
11
|
+
for (const [pid, what] of [[record.pid, "pid"], [record.wrapper_pid, "wrapper pid"]]) if (pid && selfChain.includes(pid)) return `${what} ${pid} is this shell or one of its ancestors — killing it would kill the caller too. To end your own agent, use: ay exit ${record.pid}`;
|
|
12
|
+
if (targets.pgid && selfPgid && targets.pgid === selfPgid) return `process group ${targets.pgid} is the caller's own group — refusing to kill it`;
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
/** The record's wrapper pid if it now belongs to a process younger than the
|
|
16
|
+
* registration (reused), else null. Same age test as `ay restart`. */
|
|
17
|
+
function reusedWrapperPid(record, table, now = Date.now()) {
|
|
18
|
+
const w = record.wrapper_pid;
|
|
19
|
+
if (!w || w === record.pid) return null;
|
|
20
|
+
return pidOwnershipVerdict(table.get(w)?.ageSecs, record.started_at, now) === "reused" ? w : null;
|
|
21
|
+
}
|
|
22
|
+
async function ownPgid() {
|
|
23
|
+
try {
|
|
24
|
+
const { execFileSync } = await import("node:child_process");
|
|
25
|
+
const out = execFileSync("ps", [
|
|
26
|
+
"-o",
|
|
27
|
+
"pgid=",
|
|
28
|
+
"-p",
|
|
29
|
+
String(process.pid)
|
|
30
|
+
], {
|
|
31
|
+
encoding: "utf8",
|
|
32
|
+
timeout: 5e3
|
|
33
|
+
});
|
|
34
|
+
const n = Number(out.trim());
|
|
35
|
+
return Number.isInteger(n) && n > 1 ? n : null;
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function cmdKill(rest) {
|
|
41
|
+
const argv = await yargs(rest).usage("usage: ay kill <pid> [--dry-run] (the exact pid shown by ay ls)").option("dry-run", {
|
|
42
|
+
alias: "n",
|
|
43
|
+
type: "boolean",
|
|
44
|
+
default: false,
|
|
45
|
+
description: "Print what would be killed, send nothing"
|
|
46
|
+
}).strictOptions().parserConfiguration({ "parse-positional-numbers": false }).help(false).version(false).exitProcess(false).parseAsync();
|
|
47
|
+
const sel = argv._.length === 1 ? String(argv._[0]) : "";
|
|
48
|
+
if (!/^[1-9]\d*$/.test(sel)) {
|
|
49
|
+
process.stderr.write(`ay kill: expected exactly one pid as printed by \`ay ls\`${sel ? ` (got '${sel}')` : ""}.\n No keyword, agent-id or remote matching — for a graceful stop use: ay stop <keyword>\n`);
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
if (process.platform === "win32") {
|
|
53
|
+
process.stderr.write(`ay kill: not supported on Windows (as with the console's Kill)\n`);
|
|
54
|
+
return 1;
|
|
55
|
+
}
|
|
56
|
+
const pid = Number(sel);
|
|
57
|
+
const { readGlobalPids, updateGlobalPidStatus } = await import("./globalPidIndex-uoz8Esqz.js");
|
|
58
|
+
const matches = (await readGlobalPids()).filter((r) => r.pid === pid);
|
|
59
|
+
if (matches.length !== 1) {
|
|
60
|
+
process.stderr.write(matches.length === 0 ? `ay kill: no registered agent has pid ${pid} (see: ay ls --all)\n` : `ay kill: ${matches.length} registry rows claim pid ${pid} — refusing an ambiguous kill\n`);
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
const record = matches[0];
|
|
64
|
+
if (record.status === "exited") {
|
|
65
|
+
process.stderr.write(`ay kill: pid ${pid} is registered as exited — refusing: the number may belong to another process by now\n`);
|
|
66
|
+
return 1;
|
|
67
|
+
}
|
|
68
|
+
const { ancestorPids, pidOwnershipVerdict, readAncestryTable } = await import("./senderAncestry-KhAUPCQs.js");
|
|
69
|
+
const table = await readAncestryTable();
|
|
70
|
+
const selfPgid = await ownPgid();
|
|
71
|
+
if (!table || !selfPgid) {
|
|
72
|
+
process.stderr.write(`ay kill: could not read the process table (ps) — refusing, since it is unknown whether pid ${pid} is still this agent or an ancestor of this shell\n`);
|
|
73
|
+
return 1;
|
|
74
|
+
}
|
|
75
|
+
if (pidOwnershipVerdict(table.get(pid)?.ageSecs, record.started_at) === "reused") {
|
|
76
|
+
process.stderr.write(`ay kill: pid ${pid} is alive but is NOT the agent that registered it (the number was reused) — refusing. Retire the stale row with: ay stop ${pid}\n`);
|
|
77
|
+
return 1;
|
|
78
|
+
}
|
|
79
|
+
const { forceKill, forceKillTargets } = await import("./forceKill-BDqxx4uQ.js");
|
|
80
|
+
const targets = await forceKillTargets(record);
|
|
81
|
+
const reusedWrapper = reusedWrapperPid(record, table);
|
|
82
|
+
if (reusedWrapper) {
|
|
83
|
+
targets.pids = targets.pids.filter((p) => p !== reusedWrapper);
|
|
84
|
+
process.stderr.write(`ay kill: warning: wrapper pid ${reusedWrapper} was reused — not signalling it\n`);
|
|
85
|
+
}
|
|
86
|
+
const refusal = killRefusal(record, targets, [
|
|
87
|
+
process.pid,
|
|
88
|
+
process.ppid,
|
|
89
|
+
...await ancestorPids(process.pid, { readTable: async () => table })
|
|
90
|
+
], selfPgid);
|
|
91
|
+
if (refusal) {
|
|
92
|
+
process.stderr.write(`ay kill: ${refusal}\n`);
|
|
93
|
+
return 1;
|
|
94
|
+
}
|
|
95
|
+
const what = `pid ${pid} (${record.cli}, ${record.cwd})`;
|
|
96
|
+
if (argv["dry-run"]) {
|
|
97
|
+
const list = [...targets.pgid ? [`group ${targets.pgid}`] : [], ...targets.pids];
|
|
98
|
+
process.stdout.write(`would SIGKILL ${list.join(", ")} — ${what}\n`);
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
const { killed, failed } = forceKill(targets);
|
|
102
|
+
if (failed.length) {
|
|
103
|
+
process.stderr.write(`ay kill: could not signal ${failed.join(", ")} — ${what} not marked exited\n`);
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
await updateGlobalPidStatus(pid, {
|
|
107
|
+
status: "exited",
|
|
108
|
+
exit_reason: "force-killed via ay kill"
|
|
109
|
+
}).catch(() => {});
|
|
110
|
+
process.stdout.write(`killed ${what}: ${killed.join(", ") || "nothing left to signal (already gone)"}\n`);
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { cmdKill };
|
|
116
|
+
//# sourceMappingURL=cmdKill-CzSBfWmx.js.map
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import "./logger-CDIsZ-Pp.js";
|
|
2
|
-
import "./JsonlStore-
|
|
3
|
-
import "./globalPidIndex-
|
|
4
|
-
import "./pidStore-
|
|
2
|
+
import "./JsonlStore-CB_0sfdT.js";
|
|
3
|
+
import "./globalPidIndex-BsjlId-h.js";
|
|
4
|
+
import "./pidStore-C50VPk3E.js";
|
|
5
5
|
import "./messageLog-Dq_ka-Bt.js";
|
|
6
6
|
import "./e2e-BdLf8DvY.js";
|
|
7
7
|
import "./configShared-De4bR5hH.js";
|
|
8
|
-
import "./
|
|
9
|
-
import "./
|
|
10
|
-
import "./
|
|
11
|
-
import
|
|
8
|
+
import { Dt as flattenForest, Et as buildAgentForest, G as listRecords, y as deriveLiveState } from "./subcommands-B7YZJL8n.js";
|
|
9
|
+
import "./webrtcLink-DcvacEci.js";
|
|
10
|
+
import "./remotes-BsMGvAay.js";
|
|
11
|
+
import "./roomReplyAlias-B-v76TA8.js";
|
|
12
12
|
import "./notifyStore-DIfkfKB2.js";
|
|
13
|
-
import
|
|
14
|
-
import
|
|
13
|
+
import "./senderAncestry-CVHeKk1Y.js";
|
|
14
|
+
import { i as systemStats, n as sampleTrees, r as snapshotProcs, t as humanBytes } from "./procStats-DwTxj3rs.js";
|
|
15
15
|
import { readFileSync } from "node:fs";
|
|
16
16
|
import path from "node:path";
|
|
17
|
+
import yargs from "yargs";
|
|
17
18
|
import { homedir } from "node:os";
|
|
18
19
|
|
|
19
20
|
//#region ts/cmdPs.ts
|
|
@@ -331,4 +332,4 @@ function readPpidSync(pid) {
|
|
|
331
332
|
|
|
332
333
|
//#endregion
|
|
333
334
|
export { cmdPs };
|
|
334
|
-
//# sourceMappingURL=cmdPs-
|
|
335
|
+
//# sourceMappingURL=cmdPs-DBt23Qz0.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./logger-CDIsZ-Pp.js";
|
|
2
|
-
import { a as readGlobalPids } from "./globalPidIndex-
|
|
2
|
+
import { a as readGlobalPids } from "./globalPidIndex-BsjlId-h.js";
|
|
3
3
|
import path from "path";
|
|
4
4
|
|
|
5
5
|
//#region ts/cwdConflictWarn.ts
|
|
@@ -14,6 +14,19 @@ import path from "path";
|
|
|
14
14
|
* registered in the pid index yet, so every same-cwd match here is a genuine
|
|
15
15
|
* pre-existing peer, never itself.
|
|
16
16
|
*/
|
|
17
|
+
/** The vendor behind a cli name: claude/cy/claude-yes -> claude, codex-* -> codex. */
|
|
18
|
+
function vendorOf(cli) {
|
|
19
|
+
const c = cli.toLowerCase().replace(/-yes$/, "");
|
|
20
|
+
if (c === "cy" || c.startsWith("claude")) return "claude";
|
|
21
|
+
if (c.startsWith("codex")) return "codex";
|
|
22
|
+
return c;
|
|
23
|
+
}
|
|
24
|
+
/** The cli this launch starts: a `<cli>-yes` entry name, else the first non-flag argument. */
|
|
25
|
+
function launchingCli(rawArgv) {
|
|
26
|
+
const bin = path.basename(rawArgv[1] ?? "").replace(/\.(c?js|ts)$/, "");
|
|
27
|
+
if (bin.endsWith("-yes") && bin !== "agent-yes") return bin.replace(/-yes$/, "");
|
|
28
|
+
return rawArgv.slice(2).find((a) => !a.startsWith("-")) ?? null;
|
|
29
|
+
}
|
|
17
30
|
/**
|
|
18
31
|
* POSIX single-quote a shell token so a copy-pasted recovery command survives
|
|
19
32
|
* spaces, quotes, `$`, `;`, `&`, etc. Safe-charset tokens pass through unquoted
|
|
@@ -29,15 +42,18 @@ function shQuote(s) {
|
|
|
29
42
|
* `ay …` command, produce the warning text (or null when there's no conflict).
|
|
30
43
|
* Separated from IO so the message/branching is unit-tested without a live index.
|
|
31
44
|
*/
|
|
32
|
-
function formatCwdConflictWarning(occupants, cwd, origCmd) {
|
|
45
|
+
function formatCwdConflictWarning(occupants, cwd, origCmd, launching = null) {
|
|
33
46
|
if (occupants.length === 0) return null;
|
|
47
|
+
const same = launching ? occupants.filter((r) => vendorOf(r.cli) === vendorOf(launching)) : occupants;
|
|
48
|
+
if (launching && same.length === 0) return `\nℹ ${occupants.slice(0, 3).map((r) => `${r.cli} ${r.pid}`).join(", ")} ${occupants.length > 1 ? "are" : "is"} already running in this directory (${cwd}), from a different vendor than ${launching}.\n That is fine if they are aware of each other (\`ay ls --cwd .\`, \`ay send <pid> "…"\`). Are they? Otherwise\n they share one checkout, builds and ports without knowing it. (AGENT_YES_NO_CWD_WARN=1 silences this)\n\n`;
|
|
49
|
+
occupants = same;
|
|
34
50
|
const wt = `${path.basename(cwd) || "agent"}-work`;
|
|
35
51
|
const list = occupants.slice(0, 3).map((r) => ` ${r.pid} ${r.cli}`).join("\n");
|
|
36
52
|
const more = occupants.length > 3 ? `\n …and ${occupants.length - 3} more` : "";
|
|
37
53
|
const cmd = origCmd.trim() || "ay <cli> …";
|
|
38
54
|
const branch = shQuote(wt);
|
|
39
55
|
const dir = shQuote(`../${wt}`);
|
|
40
|
-
return `\n
|
|
56
|
+
return `\n⚠⚠⚠ STRONGLY NOT RECOMMENDED: ${occupants.length} agent${occupants.length > 1 ? "s are" : " is"} already running in this directory (${cwd}):\n${list}${more}\n Two top-level agents in one working tree share one checkout, one set of builds and\n one set of live services and ports, and neither knows what the other is doing.\n Do one of these instead (cancel with Ctrl-C):\n 1. Parallel work in THIS directory: use in-harness subagents inside the existing\n agent (e.g. Claude's Agent tool), not a second \`ay\`. Subagents are not counted here.\n 2. Parallel work on another branch: start it in its OWN directory (a git worktree)\n and let the main branch harvest that work by git (merge or PR):\n git worktree add -b ${branch} ${dir} && cd ${dir} && ${cmd}\n (set AGENT_YES_NO_CWD_WARN=1 to silence)\n\n`;
|
|
41
57
|
}
|
|
42
58
|
/**
|
|
43
59
|
* IO wrapper: discover live same-cwd peers and print the warning to stderr.
|
|
@@ -51,7 +67,7 @@ async function warnIfCwdOccupied(rawArgv) {
|
|
|
51
67
|
const msg = formatCwdConflictWarning((await readGlobalPids({ liveOnly: true })).filter((r) => path.resolve(r.cwd) === here).map((r) => ({
|
|
52
68
|
pid: r.pid,
|
|
53
69
|
cli: r.cli
|
|
54
|
-
})), here, ["ay", ...rawArgv.slice(2)].map(shQuote).join(" "));
|
|
70
|
+
})), here, ["ay", ...rawArgv.slice(2)].map(shQuote).join(" "), launchingCli(rawArgv));
|
|
55
71
|
if (msg) {
|
|
56
72
|
process.stderr.write(msg);
|
|
57
73
|
if (process.stdout.isTTY) await new Promise((r) => setTimeout(r, 2500));
|
|
@@ -61,4 +77,4 @@ async function warnIfCwdOccupied(rawArgv) {
|
|
|
61
77
|
|
|
62
78
|
//#endregion
|
|
63
79
|
export { warnIfCwdOccupied };
|
|
64
|
-
//# sourceMappingURL=cwdConflictWarn-
|
|
80
|
+
//# sourceMappingURL=cwdConflictWarn-y-epQyOj.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
2
1
|
import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
2
|
import path from "node:path";
|
|
3
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
|
|
6
6
|
//#region node_modules/codehost/src/tunnel/protocol.ts
|
|
@@ -549,4 +549,4 @@ async function cmdExpose(args) {
|
|
|
549
549
|
|
|
550
550
|
//#endregion
|
|
551
551
|
export { cmdExpose, ensureExposure, listExposures, stopExposure };
|
|
552
|
-
//# sourceMappingURL=expose-
|
|
552
|
+
//# sourceMappingURL=expose-Bhsn5yUz.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { t as pgidForWrapper } from "./reaper-C2cuougX.js";
|
|
2
|
+
|
|
3
|
+
//#region ts/forceKill.ts
|
|
4
|
+
/** What forceKill would signal, without signalling it. */
|
|
5
|
+
async function forceKillTargets(record) {
|
|
6
|
+
const g = await pgidForWrapper(record.wrapper_pid ?? 0);
|
|
7
|
+
const pids = [record.pid];
|
|
8
|
+
if (record.wrapper_pid && record.wrapper_pid !== record.pid) pids.push(record.wrapper_pid);
|
|
9
|
+
return {
|
|
10
|
+
pgid: g && g > 1 ? g : null,
|
|
11
|
+
pids: pids.filter((p) => p > 1)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* SIGKILL the targets. Returns labels of what was signalled, and of what could
|
|
16
|
+
* NOT be signalled for a reason other than "already gone" (ESRCH) — e.g. EPERM,
|
|
17
|
+
* a process owned by another user.
|
|
18
|
+
*/
|
|
19
|
+
function forceKill(targets) {
|
|
20
|
+
const killed = [];
|
|
21
|
+
const failed = [];
|
|
22
|
+
const sig = (target, label) => {
|
|
23
|
+
try {
|
|
24
|
+
process.kill(target, "SIGKILL");
|
|
25
|
+
killed.push(label);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
const code = e.code;
|
|
28
|
+
if (code !== "ESRCH") failed.push(`${label} (${code ?? "error"})`);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
if (targets.pgid && targets.pgid > 1) sig(-targets.pgid, `group ${targets.pgid}`);
|
|
32
|
+
for (const pid of targets.pids) {
|
|
33
|
+
if (pid <= 1) continue;
|
|
34
|
+
sig(pid, pid === targets.pids[0] ? `pid ${pid}` : `wrapper ${pid}`);
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
killed,
|
|
38
|
+
failed
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { forceKill, forceKillTargets };
|
|
44
|
+
//# sourceMappingURL=forceKill-BDqxx4uQ.js.map
|
|
@@ -13,13 +13,53 @@ import path from "path";
|
|
|
13
13
|
* into an agent's environment by its wrapper — a human shell never has it) AND
|
|
14
14
|
* stdout is not a TTY (captured/piped, e.g. a tool's Bash). A human piping output
|
|
15
15
|
* (`ay claude | cat`) has no `AGENT_YES_PID`, so they still block as before.
|
|
16
|
-
* `attach` (the `--attach` flag or `AGENT_YES_ATTACH=1`) forces foreground
|
|
16
|
+
* `attach` (the `--attach` flag or `AGENT_YES_ATTACH=1`) forces foreground;
|
|
17
|
+
* `detach` (the `--detach` flag) forces the fork in any context — e.g. a human
|
|
18
|
+
* spawning an agent over `ssh host ay --detach claude -- …`, where the session
|
|
19
|
+
* would otherwise stay open for the agent's whole life.
|
|
17
20
|
*/
|
|
18
21
|
function shouldForkNested(opts) {
|
|
22
|
+
if (opts.detach) return true;
|
|
19
23
|
if (opts.attach) return false;
|
|
20
24
|
if (opts.isTTY) return false;
|
|
21
25
|
return Boolean(opts.ayPid && opts.ayPid.trim());
|
|
22
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Validate where `--detach` was written and return the args with it removed.
|
|
29
|
+
*
|
|
30
|
+
* Accepted in exactly one spelling and place: the bare token `--detach` as the
|
|
31
|
+
* FIRST argument (`ay --detach <cli> …`), once. That keeps the strip
|
|
32
|
+
* parse-free — the Rust runner would otherwise forward the unknown flag to the
|
|
33
|
+
* target CLI. Any OTHER detach-like token before `--` (`--detach=…`,
|
|
34
|
+
* `--detach true`, `--no-detach`, a repeat, or `--detach` after other flags —
|
|
35
|
+
* even after the CLI name) is refused with the one form that works, rather
|
|
36
|
+
* than half-working. After `--` the words are prompt text and are untouched.
|
|
37
|
+
*
|
|
38
|
+
* `rawArgs` is argv without the runtime + script; `parsedDetach` is what yargs
|
|
39
|
+
* concluded.
|
|
40
|
+
*/
|
|
41
|
+
function stripDetachFlag(rawArgs, parsedDetach) {
|
|
42
|
+
const form = "use exactly: ay --detach <cli> [options] -- <prompt>";
|
|
43
|
+
const dash = rawArgs.indexOf("--");
|
|
44
|
+
const end = dash === -1 ? rawArgs.length : dash;
|
|
45
|
+
const hits = [];
|
|
46
|
+
for (let i = 0; i < end; i++) if (/^--(no-)?detach(=|$)/.test(rawArgs[i])) hits.push(i);
|
|
47
|
+
if (hits.length === 0) return parsedDetach ? {
|
|
48
|
+
ok: false,
|
|
49
|
+
error: `unsupported --detach form — ${form}`
|
|
50
|
+
} : {
|
|
51
|
+
ok: true,
|
|
52
|
+
args: rawArgs
|
|
53
|
+
};
|
|
54
|
+
if (!(hits.length === 1 && hits[0] === 0 && rawArgs[0] === "--detach" && !/^(true|false)$/.test(rawArgs[1] ?? ""))) return {
|
|
55
|
+
ok: false,
|
|
56
|
+
error: `unsupported --detach form '${hits.map((i) => rawArgs[i]).join(" ")}' — ${form}`
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
ok: true,
|
|
60
|
+
args: rawArgs.slice(1)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
23
63
|
/** The tutorial printed to the parent agent after a detached spawn, telling it
|
|
24
64
|
* exactly how to drive the agent it just started. */
|
|
25
65
|
function buildSpawnTutorial(cli, pid) {
|
|
@@ -62,7 +102,7 @@ function buildSpawnTutorial(cli, pid) {
|
|
|
62
102
|
* fast instead of waiting out the whole window).
|
|
63
103
|
*/
|
|
64
104
|
async function waitForRegistration(pid, timeoutMs = 5e3, aborted) {
|
|
65
|
-
const { readGlobalPids } = await import("./globalPidIndex-
|
|
105
|
+
const { readGlobalPids } = await import("./globalPidIndex-uoz8Esqz.js");
|
|
66
106
|
const isRegistered = async () => (await readGlobalPids()).some((r) => r.pid === pid && r.status !== "exited");
|
|
67
107
|
const deadline = Date.now() + timeoutMs;
|
|
68
108
|
while (Date.now() < deadline) {
|
|
@@ -110,7 +150,7 @@ async function tailFile(file, max = 400) {
|
|
|
110
150
|
* success, keeping the previous behaviour for anything this can't decide.
|
|
111
151
|
*/
|
|
112
152
|
async function confirmAgentStarted(pid, graceMs = 1500, aborted) {
|
|
113
|
-
const { readGlobalPids } = await import("./globalPidIndex-
|
|
153
|
+
const { readGlobalPids } = await import("./globalPidIndex-uoz8Esqz.js");
|
|
114
154
|
const { stat } = await import("fs/promises");
|
|
115
155
|
const deadline = Date.now() + graceMs;
|
|
116
156
|
while (Date.now() < deadline) {
|
|
@@ -140,5 +180,5 @@ async function confirmAgentStarted(pid, graceMs = 1500, aborted) {
|
|
|
140
180
|
}
|
|
141
181
|
|
|
142
182
|
//#endregion
|
|
143
|
-
export { buildSpawnTutorial, confirmAgentStarted, predictedLogPath, shouldForkNested, waitForRegistration };
|
|
144
|
-
//# sourceMappingURL=forkNested-
|
|
183
|
+
export { buildSpawnTutorial, confirmAgentStarted, predictedLogPath, shouldForkNested, stripDetachFlag, waitForRegistration };
|
|
184
|
+
//# sourceMappingURL=forkNested-3heLs5XC.js.map
|
|
@@ -17,12 +17,13 @@ function resolveGlobalFile() {
|
|
|
17
17
|
return path.join(resolveGlobalDir(), "pids.jsonl");
|
|
18
18
|
}
|
|
19
19
|
async function withLock(file, fn) {
|
|
20
|
-
|
|
21
|
-
await mkdir(dir, { recursive: true });
|
|
20
|
+
await mkdir(path.dirname(file), { recursive: true });
|
|
22
21
|
let release;
|
|
23
22
|
try {
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const lockfilePath = file + ".lock";
|
|
24
|
+
release = await lock(lockfilePath, {
|
|
25
|
+
realpath: false,
|
|
26
|
+
lockfilePath,
|
|
26
27
|
retries: {
|
|
27
28
|
retries: 5,
|
|
28
29
|
minTimeout: 50,
|
|
@@ -315,4 +316,4 @@ async function gcLogs(maxAgeMs = retentionMs()) {
|
|
|
315
316
|
|
|
316
317
|
//#endregion
|
|
317
318
|
export { readGlobalPids as a, pruneOldLogs as i, gcLogs as n, sweepOrphanLogs as o, maybeCompactGlobalPids as r, updateGlobalPidStatus as s, appendGlobalPid as t };
|
|
318
|
-
//# sourceMappingURL=globalPidIndex-
|
|
319
|
+
//# sourceMappingURL=globalPidIndex-BsjlId-h.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "./logger-CDIsZ-Pp.js";
|
|
2
|
-
import { a as readGlobalPids, i as pruneOldLogs, n as gcLogs, o as sweepOrphanLogs, r as maybeCompactGlobalPids, s as updateGlobalPidStatus, t as appendGlobalPid } from "./globalPidIndex-
|
|
2
|
+
import { a as readGlobalPids, i as pruneOldLogs, n as gcLogs, o as sweepOrphanLogs, r as maybeCompactGlobalPids, s as updateGlobalPidStatus, t as appendGlobalPid } from "./globalPidIndex-BsjlId-h.js";
|
|
3
3
|
|
|
4
|
-
export { gcLogs, readGlobalPids };
|
|
4
|
+
export { gcLogs, readGlobalPids, updateGlobalPidStatus };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as safeBranch, i as readGitBranch, n as localHost, o as safeToken, r as localUser, s as tildify, t as formatIdentity } from "./identity-
|
|
1
|
+
import { a as safeBranch, i as readGitBranch, n as localHost, o as safeToken, r as localUser, s as tildify, t as formatIdentity } from "./identity-Ckav3-Up.js";
|
|
2
2
|
|
|
3
3
|
export { formatIdentity };
|
|
@@ -106,4 +106,4 @@ function formatIdentity(parts) {
|
|
|
106
106
|
|
|
107
107
|
//#endregion
|
|
108
108
|
export { safeBranch as a, readGitBranch as i, localHost as n, safeToken as o, localUser as r, tildify as s, formatIdentity as t };
|
|
109
|
-
//# sourceMappingURL=identity-
|
|
109
|
+
//# sourceMappingURL=identity-Ckav3-Up.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "./logger-CDIsZ-Pp.js";
|
|
2
|
-
import "./versionChecker-
|
|
3
|
-
import { a as hasTodoStore, i as answerAsk, l as AgentContext, n as agentYes, o as listAsks, r as config, s as listAsksForProject, t as CLIS_CONFIG } from "./ts-
|
|
4
|
-
import { a as renderTree, c as describeBlock, i as renderDigest, l as monitorHint, o as unblockedTasks, r as openBlockers, t as reconcileTodos, u as removeControlCharacters } from "./todoAutomation-
|
|
5
|
-
import "./JsonlStore-
|
|
6
|
-
import "./globalPidIndex-
|
|
7
|
-
import "./pidStore-
|
|
2
|
+
import "./versionChecker-BJycAanp.js";
|
|
3
|
+
import { a as hasTodoStore, i as answerAsk, l as AgentContext, n as agentYes, o as listAsks, r as config, s as listAsksForProject, t as CLIS_CONFIG } from "./ts-njuddXQz.js";
|
|
4
|
+
import { a as renderTree, c as describeBlock, i as renderDigest, l as monitorHint, o as unblockedTasks, r as openBlockers, t as reconcileTodos, u as removeControlCharacters } from "./todoAutomation-CKlrxuZv.js";
|
|
5
|
+
import "./JsonlStore-CB_0sfdT.js";
|
|
6
|
+
import "./globalPidIndex-BsjlId-h.js";
|
|
7
|
+
import "./pidStore-C50VPk3E.js";
|
|
8
8
|
import "./messageLog-Dq_ka-Bt.js";
|
|
9
|
-
import { a as LIFECYCLES, c as initialState, d as requiredGate, f as statesOf, i as DONE_STATE, l as isKnownKind, n as TodoStore, o as ORPHANED_STATE, r as openStore, s as canTransition, t as CycleError, u as nextStates } from "./todoStore-
|
|
9
|
+
import { a as LIFECYCLES, c as initialState, d as requiredGate, f as statesOf, i as DONE_STATE, l as isKnownKind, n as TodoStore, o as ORPHANED_STATE, r as openStore, s as canTransition, t as CycleError, u as nextStates } from "./todoStore-msRCEUi1.js";
|
|
10
10
|
|
|
11
11
|
export { AgentContext, CLIS_CONFIG, CycleError, DONE_STATE, LIFECYCLES, ORPHANED_STATE, TodoStore, answerAsk, canTransition, config, agentYes as default, describeBlock, hasTodoStore, initialState, isKnownKind, listAsks, listAsksForProject, monitorHint, nextStates, openBlockers, openStore, reconcileTodos, removeControlCharacters, renderDigest, renderTree, requiredGate, statesOf, unblockedTasks };
|