agent-yes 1.307.0 → 1.308.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 +53 -0
- package/dist/{JsonlStore-CB_0sfdT.js → JsonlStore-fEAVg5aY.js} +1 -1
- package/dist/SUPPORTED_CLIS-Ce_7n97m.js +12 -0
- package/dist/{SUPPORTED_CLIS-qL9_2DZ8.js → SUPPORTED_CLIS-DFpjQ2Ke.js} +2 -2
- package/dist/agent-yes.config-ByXwI-t3.js +47 -0
- package/dist/agentPermissions-CgM1bl6m.js +62 -0
- package/dist/{agentShare-C2oXrGvf.js → agentShare-Dz_T6b5v.js} +14 -14
- package/dist/{askCli-D4czi-_j.js → askCli-BjQOqpvv.js} +6 -6
- package/dist/{browser-BW90gl2w.js → browser-BzjhscIR.js} +5 -5
- package/dist/{browser-BAFPmEvN.js → browser-CU933aYj.js} +1 -1
- package/dist/{callback-ie8yyKma.js → callback-CAWItwdn.js} +5 -5
- package/dist/callback-oTjpUn2G.js +17 -0
- package/dist/{callbackCore-Deve5pv3.js → callbackCore-DoPrLOFY.js} +1 -1
- package/dist/{callbackCore-BZ_10zyc.js → callbackCore-TE7HjQm9.js} +1 -1
- package/dist/{channels-jIa5fNjY.js → channels-BGSdyeQs.js} +2 -2
- package/dist/{channels-Y36S0ccW.js → channels-bw-b9z0l.js} +6 -6
- package/dist/channels.js +5 -5
- package/dist/claude-DLN2dvVD.js +180 -0
- package/dist/cli.js +60 -15
- package/dist/{cmdDsh-DZ8bLsH7.js → cmdDsh-h7V2ThH5.js} +1 -1
- package/dist/{cmdKill-DUyZ7Dch.js → cmdKill-b5I7H8wx.js} +5 -5
- package/dist/{cmdPs-CfR5qCiO.js → cmdPs-RZU-tTd4.js} +14 -14
- package/dist/{agent-yes.config-CRfpdp3A.js → configLoader-CLSX_LND.js} +4 -42
- package/dist/configLoader-D9O9zwKR.js +5 -0
- package/dist/{configShared-De4bR5hH.js → configShared-B9gyn11R.js} +1 -1
- package/dist/{cwdConflictWarn-ml6Qs3Qu.js → cwdConflictWarn-BQ8vH915.js} +2 -2
- package/dist/{cwdPassthroughHint-CzWh0hrw.js → cwdPassthroughHint-h4dQQCLO.js} +1 -1
- package/dist/detach-B_n7xRl2.js +58 -0
- package/dist/{e2e-BdLf8DvY.js → e2e-C34A1uYu.js} +1 -1
- package/dist/{expose-Bhsn5yUz.js → expose-BKxcKYt-.js} +1 -1
- package/dist/{forceKill-BDqxx4uQ.js → forceKill-BAqKNR_f.js} +2 -2
- package/dist/{forkNested-DHuYbpaf.js → forkNested-CVSWfZT6.js} +3 -3
- package/dist/{globalPidIndex-DmDCB_X7.js → globalPidIndex-B5c_g_yJ.js} +1 -1
- package/dist/{globalPidIndex-C6p_AY4D.js → globalPidIndex-D9fxq9Ad.js} +10 -2
- package/dist/{hist-DY16wm7g.js → hist-OSUKO8sb.js} +1 -1
- package/dist/{html2canvas-pro.esm-Dp-JZojz.js → html2canvas-pro.esm-BW1GOcB-.js} +1 -1
- package/dist/{identity-D3hr59eC.js → identity-BVHHqtvP.js} +1 -1
- package/dist/{identity-puvd7hVQ.js → identity-CtwRW1nD.js} +1 -1
- package/dist/index.js +8 -8
- package/dist/{initMsg-GPU52N-j.js → initMsg-C1tgHfYP.js} +1 -1
- package/dist/{initMsg-BEVDWYnv.js → initMsg-CkrZjsX-.js} +1 -1
- package/dist/launch-BlKMU2ZA.js +74 -0
- package/dist/launch-CMran68t.js +3 -0
- package/dist/{messageLog-CEqe4Hk1.js → messageLog-BrXNxItW.js} +1 -1
- package/dist/{needsInput-hRiWFjGy.js → needsInput-B3aPVSqs.js} +1 -1
- package/dist/{nodeRuntime-DGMQRTGT.js → nodeRuntime-B1nCglgu.js} +1 -1
- package/dist/{notifyDaemon-DcAbvP43.js → notifyDaemon-Dh4cLfBU.js} +13 -13
- package/dist/{notifyStore-C4pH_-zJ.js → notifyStore-B7DLD83Q.js} +1 -1
- package/dist/{notifyStore-DIfkfKB2.js → notifyStore-CNdHlJyW.js} +1 -1
- package/dist/{openBrowser-CQAOIrD6.js → openBrowser-CwhGNBhv.js} +1 -1
- package/dist/oxmgrService-C0nYf9CD.js +3 -0
- package/dist/{oxmgrService-DlYHmqyI.js → oxmgrService-CBlFJ_-C.js} +2 -2
- package/dist/{parentLink-UiM6WoKm.js → parentLink-C2gocHk9.js} +2 -2
- package/dist/{parentLink-B7_kEM1v.js → parentLink-EVI_0cLu.js} +2 -2
- package/dist/{parentPingLoop-BYT4XgfN.js → parentPingLoop-B9QDw20l.js} +7 -7
- package/dist/peer-BSZQbKB7.js +4 -0
- package/dist/{peer-L-prov9t.js → peer-DI_xxui8.js} +3 -3
- package/dist/pidStore-BRU1Q0uN.js +6 -0
- package/dist/{pidStore-DUXifdBr.js → pidStore-DXEbQrh-.js} +3 -3
- package/dist/{procStats-DwTxj3rs.js → procStats-CkzFrwx7.js} +1 -1
- package/dist/{reaper-DsZhX5FH.js → reaper-A_eEjMxS.js} +1 -1
- package/dist/{reaper-C2cuougX.js → reaper-BTfq0-5j.js} +1 -1
- package/dist/{remotes-CAZymHd7.js → remotes-B0vw-dsd.js} +3 -3
- package/dist/{remotes-W6NhMDfP.js → remotes-TKXkCV76.js} +3 -3
- package/dist/roomReplyAlias-0xfUQlda.js +6 -0
- package/dist/{roomReplyAlias-B1EJft2d.js → roomReplyAlias-CkfEtW2v.js} +3 -3
- package/dist/runner-B1vocYOj.js +371 -0
- package/dist/{runningLock-DMznYh45.js → runningLock-DaVbNt4d.js} +1 -1
- package/dist/{rustBinary-BjsZbiv5.js → rustBinary-B603fLUa.js} +2 -2
- package/dist/{rustBinary-CXQGcJEm.js → rustBinary-CTEd2FnZ.js} +2 -2
- package/dist/{schedule-zacFV53l.js → schedule-DncJhp1d.js} +15 -15
- package/dist/{schedules-BvwTGXU2.js → schedules-D6hZ7VpJ.js} +1 -1
- package/dist/{schedulesCli-Donh0LS2.js → schedulesCli-DSBZwREE.js} +3 -3
- package/dist/{senderAncestry-KhAUPCQs.js → senderAncestry-Brb-cYni.js} +1 -1
- package/dist/{senderAncestry-CVHeKk1Y.js → senderAncestry-DqbNIecg.js} +1 -1
- package/dist/{serve-C38WYmzz.js → serve-BJEDb5Az.js} +52 -51
- package/dist/{serveRust-76_apYb8.js → serveRust-B50JWdfK.js} +3 -3
- package/dist/{setup-CeAisuhv.js → setup-CxQJtnmp.js} +4 -4
- package/dist/{share-_TPYAGWC.js → share-CPtJgXt2.js} +2 -2
- package/dist/{share-CbFetL5H.js → share-zVt71n2g.js} +2 -2
- package/dist/{shareCmd-foO5MbJp.js → shareCmd-96G551OE.js} +10 -10
- package/dist/{spawnGate-nUrmf4dd.js → spawnGate-BkkT7GF2.js} +3 -3
- package/dist/spawnGate-Ky21E51l.js +5 -0
- package/dist/{store-xmBpqPUq.js → store-MjCqeJDI.js} +1 -1
- package/dist/{subcommands-DE31Tfv_.js → subcommands-BJezWaHi.js} +455 -124
- package/dist/{subcommands-DLQEC24N.js → subcommands-DbdxjvFI.js} +12 -12
- package/dist/{systemPathLink-DI9WdoqQ.js → systemPathLink-BQE53HED.js} +1 -1
- package/dist/{terminal-CBbp6PfB.js → terminal-CLjXOXI7.js} +2 -2
- package/dist/terminal.js +1 -1
- package/dist/{todoAutomation-CKlrxuZv.js → todoAutomation-KgmnTAsD.js} +2 -2
- package/dist/{todoCli-BllShFnc.js → todoCli-ammnk6Wv.js} +6 -6
- package/dist/{todoIdentity-DeDp7LKl.js → todoIdentity-DzjduXlF.js} +2 -2
- package/dist/{todoStore-msRCEUi1.js → todoStore-Dre3Yhwt.js} +2 -2
- package/dist/{tray-RIjHSw7z.js → tray-C4sCiT8B.js} +2 -2
- package/dist/{trayApp-C9SZOPpw.js → trayApp-CZwRPF62.js} +2 -2
- package/dist/trayApp-UWX_Bfay.js +5 -0
- package/dist/{ts-CO1H1P2R.js → ts-J77_edCv.js} +20 -79
- package/dist/{versionChecker-CG--tQsV.js → versionChecker-DcrK7m4z.js} +2 -2
- package/dist/{webrtcLink-WxS1nTIs.js → webrtcLink-CGCXjlQJ.js} +2 -2
- package/dist/{webrtcLink-DcvacEci.js → webrtcLink-D4pMhyvY.js} +2 -2
- package/dist/{webrtcRemote-B4pwES4i.js → webrtcRemote-DdCC3aZC.js} +3 -3
- package/dist/{widget-CI7BtN94.js → widget-DU-iJOPF.js} +3 -3
- package/dist/widget.js +1 -1
- package/dist/widgets.js +5 -5
- package/dist/{workspaceConfig-DjEklzxf.js → workspaceConfig-BmK6COFt.js} +1 -1
- package/dist/{ws-DLJSBws6.js → ws-AZ6QSr2M.js} +3 -3
- package/dist/ws-CNd9TMOE.js +16 -0
- package/package.json +1 -1
- package/ts/cli.ts +40 -1
- package/ts/globalPidIndex.ts +19 -2
- package/ts/parseCliArgs.spec.ts +10 -0
- package/ts/parseCliArgs.ts +22 -0
- package/ts/subcommands.spec.ts +2 -2
- package/ts/subcommands.ts +186 -13
- package/dist/SUPPORTED_CLIS-BOGmmIrH.js +0 -12
- package/dist/callback-CNL-PGwh.js +0 -17
- package/dist/oxmgrService-o9L3I6FX.js +0 -3
- package/dist/peer-3F7owPWt.js +0 -4
- package/dist/pidStore-B89BOF_T.js +0 -6
- package/dist/roomReplyAlias-BeGVkAlc.js +0 -6
- package/dist/spawnGate-DhPgMs0Y.js +0 -5
- package/dist/trayApp-BSOmax2E.js +0 -5
- package/dist/ws-W5nWHjDt.js +0 -16
|
@@ -1,26 +1,242 @@
|
|
|
1
1
|
import { t as invokedCliName } from "./invokedCli-zdFbz1ST.js";
|
|
2
2
|
import { t as agentYesHome } from "./agentYesHome-JmJC28YX.js";
|
|
3
|
-
import { c as updateGlobalPidStatus, o as readGlobalPids, r as getGlobalPidIndexPath } from "./globalPidIndex-
|
|
4
|
-
import { t as PidStore } from "./pidStore-
|
|
5
|
-
import { a as recordOutbox, i as recordMessage, n as readMailbox, o as senderLabel, t as partyMatches } from "./messageLog-
|
|
6
|
-
import { t as loadSharedCliDefaults } from "./configShared-
|
|
7
|
-
import { n as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { n as
|
|
12
|
-
import {
|
|
13
|
-
import { o as
|
|
3
|
+
import { c as updateGlobalPidStatus, o as readGlobalPids, r as getGlobalPidIndexPath } from "./globalPidIndex-D9fxq9Ad.js";
|
|
4
|
+
import { t as PidStore } from "./pidStore-DXEbQrh-.js";
|
|
5
|
+
import { a as recordOutbox, i as recordMessage, n as readMailbox, o as senderLabel, t as partyMatches } from "./messageLog-BrXNxItW.js";
|
|
6
|
+
import { t as loadSharedCliDefaults } from "./configShared-B9gyn11R.js";
|
|
7
|
+
import { n as userMessage } from "./claude-DLN2dvVD.js";
|
|
8
|
+
import { n as localHost, r as localUser, t as formatIdentity } from "./identity-CtwRW1nD.js";
|
|
9
|
+
import { i as isWebrtcSpec } from "./webrtcLink-D4pMhyvY.js";
|
|
10
|
+
import { l as readRemotes, u as resolveRemoteSpec } from "./remotes-B0vw-dsd.js";
|
|
11
|
+
import { n as hostedRoomMember, r as roomAliasPlaceholder } from "./roomReplyAlias-CkfEtW2v.js";
|
|
12
|
+
import { n as isWorkingScreen, r as parseMenu, t as classifyNeedsInput } from "./needsInput-B3aPVSqs.js";
|
|
13
|
+
import { S as postmortemStartedAt, _ as filterSinceSeq, a as getCursor, b as maxSeq, f as readInbox, o as heartbeatWatcher, p as setCursor, r as clearWatcher, s as hostId, v as filterSinceTs, y as filterUnread } from "./notifyStore-CNdHlJyW.js";
|
|
14
|
+
import { o as pidOwnershipVerdict, r as findAgentAncestor, s as readAncestryTable, t as ageMatchesRegistration } from "./senderAncestry-DqbNIecg.js";
|
|
15
|
+
import path from "node:path";
|
|
14
16
|
import ms from "ms";
|
|
15
17
|
import yargs from "yargs";
|
|
16
18
|
import { closeSync, constants, mkdirSync, openSync, readFileSync, realpathSync, renameSync, writeFileSync } from "fs";
|
|
17
19
|
import { appendFile, mkdir, open, readFile, readdir, rename, rm, stat, writeFile } from "fs/promises";
|
|
18
20
|
import { homedir } from "os";
|
|
19
|
-
import path from "path";
|
|
21
|
+
import path$1 from "path";
|
|
22
|
+
import { randomUUID } from "node:crypto";
|
|
20
23
|
import { lock } from "proper-lockfile";
|
|
21
24
|
import { execFileSync, spawn } from "node:child_process";
|
|
22
|
-
import {
|
|
25
|
+
import { open as open$1, readFile as readFile$1, rename as rename$1, unlink as unlink$1, writeFile as writeFile$1 } from "node:fs/promises";
|
|
26
|
+
import { createHash as createHash$1, randomBytes as randomBytes$1 } from "crypto";
|
|
23
27
|
|
|
28
|
+
//#region ts/stream/cost.ts
|
|
29
|
+
const integer = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
30
|
+
async function anchorAt(file, offset) {
|
|
31
|
+
const length = Math.min(128, offset);
|
|
32
|
+
const buffer = Buffer.alloc(length);
|
|
33
|
+
const { bytesRead } = await file.read(buffer, 0, length, offset - length);
|
|
34
|
+
return buffer.subarray(0, bytesRead).toString("base64");
|
|
35
|
+
}
|
|
36
|
+
function costOf(line) {
|
|
37
|
+
try {
|
|
38
|
+
const event = JSON.parse(line.toString("utf8"));
|
|
39
|
+
if (event?.type === "turn_end" && typeof event.costUsd === "number" && Number.isFinite(event.costUsd)) return event.costUsd;
|
|
40
|
+
} catch {}
|
|
41
|
+
}
|
|
42
|
+
/** A rebuildable byte checkpoint; the cost itself is always read from its event witness. */
|
|
43
|
+
async function readCumulativeCost(fileName, startedAt) {
|
|
44
|
+
const file = await open$1(fileName, "r").catch(() => null);
|
|
45
|
+
if (!file) return void 0;
|
|
46
|
+
const indexFile = fileName + ".cost-index.json";
|
|
47
|
+
try {
|
|
48
|
+
const info = await file.stat();
|
|
49
|
+
let cached = await readFile$1(indexFile, "utf8").then((text) => JSON.parse(text)).catch(() => null);
|
|
50
|
+
let cursor = 0, cost, witness = null;
|
|
51
|
+
if (cached?.version === 1 && cached.dev === info.dev && cached.ino === info.ino && cached.startedAt === startedAt && integer(cached.offset) && cached.offset <= info.size && cached.anchor === await anchorAt(file, cached.offset)) {
|
|
52
|
+
const candidate = cached.witness;
|
|
53
|
+
if (candidate === null) cursor = cached.offset;
|
|
54
|
+
else if (candidate && integer(candidate.start) && integer(candidate.length) && candidate.length <= 1024 * 1024 && candidate.start + candidate.length <= cached.offset) {
|
|
55
|
+
const buffer = Buffer.alloc(candidate.length);
|
|
56
|
+
const { bytesRead } = await file.read(buffer, 0, buffer.length, candidate.start);
|
|
57
|
+
cost = costOf(buffer.subarray(0, bytesRead));
|
|
58
|
+
if (cost !== void 0) {
|
|
59
|
+
cursor = cached.offset;
|
|
60
|
+
witness = candidate;
|
|
61
|
+
} else cached = null;
|
|
62
|
+
} else cached = null;
|
|
63
|
+
} else cached = null;
|
|
64
|
+
const initialCursor = cursor;
|
|
65
|
+
let readOffset = cursor;
|
|
66
|
+
let parts = [], partBytes = 0;
|
|
67
|
+
const buffer = Buffer.alloc(64 * 1024);
|
|
68
|
+
while (readOffset < info.size) {
|
|
69
|
+
const { bytesRead } = await file.read(buffer, 0, Math.min(buffer.length, info.size - readOffset), readOffset);
|
|
70
|
+
if (!bytesRead) break;
|
|
71
|
+
let start = 0;
|
|
72
|
+
for (let end = buffer.indexOf(10, start); end !== -1 && end < bytesRead; end = buffer.indexOf(10, start)) {
|
|
73
|
+
const tail = buffer.subarray(start, end);
|
|
74
|
+
const line = parts.length ? Buffer.concat([...parts, tail], partBytes + tail.length) : tail;
|
|
75
|
+
const value = costOf(line);
|
|
76
|
+
if (value !== void 0) {
|
|
77
|
+
cost = value;
|
|
78
|
+
witness = {
|
|
79
|
+
start: cursor,
|
|
80
|
+
length: line.length
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
cursor = readOffset + end + 1;
|
|
84
|
+
parts = [];
|
|
85
|
+
partBytes = 0;
|
|
86
|
+
start = end + 1;
|
|
87
|
+
}
|
|
88
|
+
if (start < bytesRead) {
|
|
89
|
+
const part = Buffer.from(buffer.subarray(start, bytesRead));
|
|
90
|
+
parts.push(part);
|
|
91
|
+
partBytes += part.length;
|
|
92
|
+
}
|
|
93
|
+
readOffset += bytesRead;
|
|
94
|
+
}
|
|
95
|
+
if (!cached || cursor !== initialCursor) {
|
|
96
|
+
const index = {
|
|
97
|
+
version: 1,
|
|
98
|
+
dev: info.dev,
|
|
99
|
+
ino: info.ino,
|
|
100
|
+
startedAt,
|
|
101
|
+
offset: cursor,
|
|
102
|
+
anchor: await anchorAt(file, cursor),
|
|
103
|
+
witness
|
|
104
|
+
};
|
|
105
|
+
const temporary = `${indexFile}.${randomUUID()}.tmp`;
|
|
106
|
+
try {
|
|
107
|
+
await writeFile$1(temporary, JSON.stringify(index), {
|
|
108
|
+
mode: 384,
|
|
109
|
+
flag: "wx"
|
|
110
|
+
});
|
|
111
|
+
await rename$1(temporary, indexFile);
|
|
112
|
+
} catch {} finally {
|
|
113
|
+
await unlink$1(temporary).catch(() => {});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return cost;
|
|
117
|
+
} finally {
|
|
118
|
+
await file.close();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region ts/stream/state.ts
|
|
124
|
+
function eventFile(record) {
|
|
125
|
+
return record.log_file?.replace(/\.(?:raw\.)?log$/, ".events.jsonl") ?? path.join(record.cwd, ".agent-yes", `${record.pid}.events.jsonl`);
|
|
126
|
+
}
|
|
127
|
+
/** Ignore partial append records. Bound status reads independently of session length. */
|
|
128
|
+
async function readEvents(file, maxBytes = 256 * 1024) {
|
|
129
|
+
const handle = await open$1(file, "r").catch(() => null);
|
|
130
|
+
if (!handle) return [];
|
|
131
|
+
try {
|
|
132
|
+
const size = (await handle.stat()).size;
|
|
133
|
+
const offset = Math.max(0, size - maxBytes);
|
|
134
|
+
const buffer = Buffer.alloc(size - offset);
|
|
135
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, offset);
|
|
136
|
+
let text = buffer.subarray(0, bytesRead).toString("utf8");
|
|
137
|
+
if (offset) text = text.slice(text.indexOf("\n") + 1);
|
|
138
|
+
const lines = text.split("\n");
|
|
139
|
+
lines.pop();
|
|
140
|
+
const events = [];
|
|
141
|
+
for (const line of lines) try {
|
|
142
|
+
const event = JSON.parse(line);
|
|
143
|
+
if (event && typeof event.type === "string") events.push(event);
|
|
144
|
+
} catch {}
|
|
145
|
+
return events;
|
|
146
|
+
} finally {
|
|
147
|
+
await handle.close();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function streamSnapshot(events) {
|
|
151
|
+
let state = "active";
|
|
152
|
+
let question = null;
|
|
153
|
+
let costUsd;
|
|
154
|
+
for (const event of events) switch (event.type) {
|
|
155
|
+
case "turn_start":
|
|
156
|
+
case "text":
|
|
157
|
+
case "tool_call":
|
|
158
|
+
case "tool_result":
|
|
159
|
+
state = "active";
|
|
160
|
+
question = null;
|
|
161
|
+
break;
|
|
162
|
+
case "needs_input":
|
|
163
|
+
state = "needs_input";
|
|
164
|
+
question = event.question;
|
|
165
|
+
break;
|
|
166
|
+
case "needs_permission":
|
|
167
|
+
state = "needs_input";
|
|
168
|
+
question = `${event.tool}: ${JSON.stringify(event.input)}`;
|
|
169
|
+
break;
|
|
170
|
+
case "turn_end":
|
|
171
|
+
state = "idle";
|
|
172
|
+
question = null;
|
|
173
|
+
if (event.costUsd !== void 0) costUsd = event.costUsd;
|
|
174
|
+
break;
|
|
175
|
+
case "error":
|
|
176
|
+
state = "stuck";
|
|
177
|
+
question = event.message;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
state,
|
|
182
|
+
question,
|
|
183
|
+
costUsd
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
async function readStreamSnapshot(record) {
|
|
187
|
+
const file = eventFile(record);
|
|
188
|
+
const [events, costUsd] = await Promise.all([readEvents(file), readCumulativeCost(file, record.started_at)]);
|
|
189
|
+
return {
|
|
190
|
+
...streamSnapshot(events),
|
|
191
|
+
costUsd
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region ts/stream/send.ts
|
|
197
|
+
/** Never retry a submitted message: a receipt timeout has an uncertain outcome. */
|
|
198
|
+
async function sendStream(record, text, options) {
|
|
199
|
+
const id = randomUUID();
|
|
200
|
+
const handle = await open$1(eventFile(record), "r");
|
|
201
|
+
try {
|
|
202
|
+
let offset = (await handle.stat()).size;
|
|
203
|
+
let pending = "";
|
|
204
|
+
const interruptId = randomUUID();
|
|
205
|
+
const payload = (options.interrupt ? JSON.stringify({
|
|
206
|
+
type: "control_request",
|
|
207
|
+
request_id: interruptId,
|
|
208
|
+
request: { subtype: "interrupt" }
|
|
209
|
+
}) + "\n" : "") + userMessage(text, id);
|
|
210
|
+
if (Buffer.byteLength(payload) > 1024 * 1024) throw new Error("ay send: stream message exceeds 1 MiB");
|
|
211
|
+
await options.write(payload);
|
|
212
|
+
const deadline = Date.now() + (options.timeoutMs ?? 3e4);
|
|
213
|
+
while (Date.now() < deadline) {
|
|
214
|
+
const size = (await handle.stat()).size;
|
|
215
|
+
if (size < offset) throw new Error("ay send: stream event log was truncated; delivery is unknown, do not resend automatically");
|
|
216
|
+
if (size > offset) {
|
|
217
|
+
const buffer = Buffer.alloc(Math.min(size - offset, 256 * 1024));
|
|
218
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, offset);
|
|
219
|
+
offset += bytesRead;
|
|
220
|
+
pending += buffer.subarray(0, bytesRead).toString("utf8");
|
|
221
|
+
let end;
|
|
222
|
+
while ((end = pending.indexOf("\n")) !== -1) {
|
|
223
|
+
const line = pending.slice(0, end);
|
|
224
|
+
pending = pending.slice(end + 1);
|
|
225
|
+
try {
|
|
226
|
+
const event = JSON.parse(line);
|
|
227
|
+
if (event.type === "user" && event.id === id) return id;
|
|
228
|
+
} catch {}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
232
|
+
}
|
|
233
|
+
throw new Error(`ay send: no replay receipt for ${id}; delivery is unknown, do not resend automatically`);
|
|
234
|
+
} finally {
|
|
235
|
+
await handle.close();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
//#endregion
|
|
24
240
|
//#region ts/interruptSend.ts
|
|
25
241
|
/** Permission prompts take precedence over lingering busy chrome. */
|
|
26
242
|
function interruptScreenState(cli, lines, cfg) {
|
|
@@ -521,11 +737,11 @@ function untilExitCode(outcome) {
|
|
|
521
737
|
*/
|
|
522
738
|
/** Directory holding the per-pid result files. */
|
|
523
739
|
function resultsDir() {
|
|
524
|
-
return path.join(agentYesHome(), "results");
|
|
740
|
+
return path$1.join(agentYesHome(), "results");
|
|
525
741
|
}
|
|
526
742
|
/** Absolute path of one agent's result envelope. */
|
|
527
743
|
function resultPath(pid) {
|
|
528
|
-
return path.join(resultsDir(), `${pid}.json`);
|
|
744
|
+
return path$1.join(resultsDir(), `${pid}.json`);
|
|
529
745
|
}
|
|
530
746
|
/**
|
|
531
747
|
* Coerce raw write-side input into an envelope payload. If it parses as JSON we
|
|
@@ -644,7 +860,7 @@ function shouldFramePaste(opts) {
|
|
|
644
860
|
/** Rows younger than this are served as-is without kicking a refresh. */
|
|
645
861
|
const REMOTE_CACHE_FRESH_MS = 3e4;
|
|
646
862
|
function remoteCachePath(alias) {
|
|
647
|
-
return path.join(agentYesHome(), "remotes", `${encodeURIComponent(alias)}.cache.json`);
|
|
863
|
+
return path$1.join(agentYesHome(), "remotes", `${encodeURIComponent(alias)}.cache.json`);
|
|
648
864
|
}
|
|
649
865
|
/** The persisted snapshot, or null for missing/corrupt — a cold cache, never an error. */
|
|
650
866
|
async function readRemoteSnapshot(alias) {
|
|
@@ -674,7 +890,7 @@ async function readRemoteSnapshot(alias) {
|
|
|
674
890
|
/** tmp + rename, like the health file: a concurrent reader never sees a torn file. */
|
|
675
891
|
async function writeRemoteSnapshot(snap) {
|
|
676
892
|
const dest = remoteCachePath(snap.alias);
|
|
677
|
-
await mkdir(path.dirname(dest), { recursive: true });
|
|
893
|
+
await mkdir(path$1.dirname(dest), { recursive: true });
|
|
678
894
|
const tmp = `${dest}.${process.pid}.tmp`;
|
|
679
895
|
await writeFile(tmp, JSON.stringify(snap));
|
|
680
896
|
await rename(tmp, dest);
|
|
@@ -837,8 +1053,8 @@ function noteRemoteResult(health, ok, now) {
|
|
|
837
1053
|
* costs one slow `ay ls` and nothing else.
|
|
838
1054
|
*/
|
|
839
1055
|
function healthPath() {
|
|
840
|
-
const dir = process.env.AGENT_YES_HOME ?? path.join(homedir(), ".agent-yes");
|
|
841
|
-
return path.join(dir, "remote-health.json");
|
|
1056
|
+
const dir = process.env.AGENT_YES_HOME ?? path$1.join(homedir(), ".agent-yes");
|
|
1057
|
+
return path$1.join(dir, "remote-health.json");
|
|
842
1058
|
}
|
|
843
1059
|
/** Read the per-alias health map. Any error yields {} — probe rather than skip. */
|
|
844
1060
|
async function readRemoteHealth() {
|
|
@@ -873,7 +1089,7 @@ async function readRemoteHealth() {
|
|
|
873
1089
|
*/
|
|
874
1090
|
async function writeRemoteHealth(health) {
|
|
875
1091
|
const dest = healthPath();
|
|
876
|
-
await mkdir(path.dirname(dest), { recursive: true });
|
|
1092
|
+
await mkdir(path$1.dirname(dest), { recursive: true });
|
|
877
1093
|
const tmp = `${dest}.${process.pid}.tmp`;
|
|
878
1094
|
await writeFile(tmp, JSON.stringify(health, null, 2));
|
|
879
1095
|
await rename(tmp, dest);
|
|
@@ -960,7 +1176,7 @@ const heldByThisProcess = /* @__PURE__ */ new Set();
|
|
|
960
1176
|
* changes shape between runtimes.
|
|
961
1177
|
*/
|
|
962
1178
|
function ipcLockTarget(pid) {
|
|
963
|
-
return path.join(agentYesHome(), "locks", `ipc-${pid}`);
|
|
1179
|
+
return path$1.join(agentYesHome(), "locks", `ipc-${pid}`);
|
|
964
1180
|
}
|
|
965
1181
|
/**
|
|
966
1182
|
* Run `fn` with exclusive access to `pid`'s stdin across processes.
|
|
@@ -974,7 +1190,7 @@ async function withIpcLock(pid, fn, onFallback) {
|
|
|
974
1190
|
let release;
|
|
975
1191
|
const target = ipcLockTarget(pid);
|
|
976
1192
|
try {
|
|
977
|
-
await mkdir(path.dirname(target), { recursive: true });
|
|
1193
|
+
await mkdir(path$1.dirname(target), { recursive: true });
|
|
978
1194
|
release = await lock(target, {
|
|
979
1195
|
lockfilePath: `${target}.lock`,
|
|
980
1196
|
realpath: false,
|
|
@@ -1001,11 +1217,11 @@ async function withIpcLock(pid, fn, onFallback) {
|
|
|
1001
1217
|
//#endregion
|
|
1002
1218
|
//#region ts/workDir.ts
|
|
1003
1219
|
function isWithin(child, parent) {
|
|
1004
|
-
const rel = path.relative(parent, child);
|
|
1005
|
-
return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
1220
|
+
const rel = path$1.relative(parent, child);
|
|
1221
|
+
return rel === "" || !rel.startsWith("..") && !path$1.isAbsolute(rel);
|
|
1006
1222
|
}
|
|
1007
1223
|
function workdirSamplePath(pid) {
|
|
1008
|
-
return path.join(agentYesHome(), "workdir", `${pid}.json`);
|
|
1224
|
+
return path$1.join(agentYesHome(), "workdir", `${pid}.json`);
|
|
1009
1225
|
}
|
|
1010
1226
|
/**
|
|
1011
1227
|
* The wrapper's latest sample for this agent, or null. A sample whose
|
|
@@ -1256,7 +1472,7 @@ function rowsFromXterm(term, n, fromContent = false) {
|
|
|
1256
1472
|
/** How long a parked message waits for the composer before it is given up. */
|
|
1257
1473
|
const PENDING_MAX_AGE_MS = 1440 * 60 * 1e3;
|
|
1258
1474
|
function pendingDir(pid) {
|
|
1259
|
-
return path.join(agentYesHome(), "pending", String(pid));
|
|
1475
|
+
return path$1.join(agentYesHome(), "pending", String(pid));
|
|
1260
1476
|
}
|
|
1261
1477
|
async function listPending(pid) {
|
|
1262
1478
|
return (await readdir(pendingDir(pid)).catch(() => [])).filter((n) => n.endsWith(".json")).sort();
|
|
@@ -1267,18 +1483,18 @@ async function enqueuePending(p) {
|
|
|
1267
1483
|
recursive: true,
|
|
1268
1484
|
mode: 448
|
|
1269
1485
|
});
|
|
1270
|
-
const id = `${String(p.queuedAt).padStart(15, "0")}-${randomBytes(4).toString("hex")}`;
|
|
1486
|
+
const id = `${String(p.queuedAt).padStart(15, "0")}-${randomBytes$1(4).toString("hex")}`;
|
|
1271
1487
|
const full = {
|
|
1272
1488
|
...p,
|
|
1273
1489
|
id
|
|
1274
1490
|
};
|
|
1275
|
-
const tmp = path.join(dir, `.${id}.tmp`);
|
|
1491
|
+
const tmp = path$1.join(dir, `.${id}.tmp`);
|
|
1276
1492
|
await writeFile(tmp, JSON.stringify(full), { mode: 384 });
|
|
1277
|
-
await rename(tmp, path.join(dir, `${id}.json`));
|
|
1493
|
+
await rename(tmp, path$1.join(dir, `${id}.json`));
|
|
1278
1494
|
return full;
|
|
1279
1495
|
}
|
|
1280
1496
|
async function readPending(pid, name) {
|
|
1281
|
-
const raw = await readFile(path.join(pendingDir(pid), name), "utf-8").catch(() => null);
|
|
1497
|
+
const raw = await readFile(path$1.join(pendingDir(pid), name), "utf-8").catch(() => null);
|
|
1282
1498
|
if (raw === null) return null;
|
|
1283
1499
|
try {
|
|
1284
1500
|
return JSON.parse(raw);
|
|
@@ -1294,7 +1510,7 @@ async function readPending(pid, name) {
|
|
|
1294
1510
|
*/
|
|
1295
1511
|
async function claimPending(pid, name) {
|
|
1296
1512
|
try {
|
|
1297
|
-
await rm(path.join(pendingDir(pid), name));
|
|
1513
|
+
await rm(path$1.join(pendingDir(pid), name));
|
|
1298
1514
|
return true;
|
|
1299
1515
|
} catch {
|
|
1300
1516
|
return false;
|
|
@@ -1302,18 +1518,18 @@ async function claimPending(pid, name) {
|
|
|
1302
1518
|
}
|
|
1303
1519
|
/** Move a message the drainer gave up on out of the queue, keeping it on disk. */
|
|
1304
1520
|
async function retirePending(pid, name, why) {
|
|
1305
|
-
const dir = path.join(pendingDir(pid), "undelivered");
|
|
1521
|
+
const dir = path$1.join(pendingDir(pid), "undelivered");
|
|
1306
1522
|
await mkdir(dir, {
|
|
1307
1523
|
recursive: true,
|
|
1308
1524
|
mode: 448
|
|
1309
1525
|
}).catch(() => {});
|
|
1310
|
-
await rename(path.join(pendingDir(pid), name), path.join(dir, name)).catch(() => {});
|
|
1311
|
-
await writeFile(path.join(dir, `${name}.why`), `${why}\n`, { mode: 384 }).catch(() => {});
|
|
1526
|
+
await rename(path$1.join(pendingDir(pid), name), path$1.join(dir, name)).catch(() => {});
|
|
1527
|
+
await writeFile(path$1.join(dir, `${name}.why`), `${why}\n`, { mode: 384 }).catch(() => {});
|
|
1312
1528
|
}
|
|
1313
1529
|
/** An identical body from the same sender within this window is a resend. */
|
|
1314
1530
|
const DUPLICATE_WINDOW_MS = 6e4;
|
|
1315
1531
|
function recentSendsPath(pid) {
|
|
1316
|
-
return path.join(agentYesHome(), "pending", `${pid}.recent.jsonl`);
|
|
1532
|
+
return path$1.join(agentYesHome(), "pending", `${pid}.recent.jsonl`);
|
|
1317
1533
|
}
|
|
1318
1534
|
/** Who sent it, for dedupe purposes: an agent's stable id (or pid). A person at
|
|
1319
1535
|
* a shell (no agent) is never deduped — typing "continue" twice is deliberate. */
|
|
@@ -1323,7 +1539,7 @@ function senderKey(from) {
|
|
|
1323
1539
|
return typeof from.pid === "number" ? `p:${from.pid}` : null;
|
|
1324
1540
|
}
|
|
1325
1541
|
function bodyHash(body) {
|
|
1326
|
-
return createHash("sha256").update(body).digest("hex");
|
|
1542
|
+
return createHash$1("sha256").update(body).digest("hex");
|
|
1327
1543
|
}
|
|
1328
1544
|
async function readRecent(pid) {
|
|
1329
1545
|
const raw = await readFile(recentSendsPath(pid), "utf-8").catch(() => "");
|
|
@@ -1351,11 +1567,11 @@ async function noteRecentSend(pid, sender, body, outcome, now = Date.now()) {
|
|
|
1351
1567
|
outcome
|
|
1352
1568
|
});
|
|
1353
1569
|
const file = recentSendsPath(pid);
|
|
1354
|
-
await mkdir(path.dirname(file), {
|
|
1570
|
+
await mkdir(path$1.dirname(file), {
|
|
1355
1571
|
recursive: true,
|
|
1356
1572
|
mode: 448
|
|
1357
1573
|
});
|
|
1358
|
-
const tmp = `${file}.${randomBytes(4).toString("hex")}.tmp`;
|
|
1574
|
+
const tmp = `${file}.${randomBytes$1(4).toString("hex")}.tmp`;
|
|
1359
1575
|
await writeFile(tmp, kept.map((r) => JSON.stringify(r)).join("\n") + "\n", { mode: 384 });
|
|
1360
1576
|
await rename(tmp, file);
|
|
1361
1577
|
}
|
|
@@ -1383,8 +1599,8 @@ function queuedReceipt(kind, detail) {
|
|
|
1383
1599
|
* to the normal agent-spawning flow.
|
|
1384
1600
|
*/
|
|
1385
1601
|
function notesPath() {
|
|
1386
|
-
const dir = process.env.AGENT_YES_HOME ?? path.join(homedir(), ".agent-yes");
|
|
1387
|
-
return path.join(dir, "notes.jsonl");
|
|
1602
|
+
const dir = process.env.AGENT_YES_HOME ?? path$1.join(homedir(), ".agent-yes");
|
|
1603
|
+
return path$1.join(dir, "notes.jsonl");
|
|
1388
1604
|
}
|
|
1389
1605
|
async function readNotes() {
|
|
1390
1606
|
let raw;
|
|
@@ -1407,7 +1623,7 @@ async function readNotes() {
|
|
|
1407
1623
|
}
|
|
1408
1624
|
async function writeNote(pid, note) {
|
|
1409
1625
|
const p = notesPath();
|
|
1410
|
-
await mkdir(path.dirname(p), { recursive: true });
|
|
1626
|
+
await mkdir(path$1.dirname(p), { recursive: true });
|
|
1411
1627
|
await appendFile(p, JSON.stringify({
|
|
1412
1628
|
pid,
|
|
1413
1629
|
note,
|
|
@@ -1427,8 +1643,8 @@ const READ_WINDOW_MS = 6e4;
|
|
|
1427
1643
|
const IPC_WRITE_TIMEOUT_MS = 1e4;
|
|
1428
1644
|
const READS_KEY_SEP = "\0";
|
|
1429
1645
|
function readsPath() {
|
|
1430
|
-
const dir = process.env.AGENT_YES_HOME ?? path.join(homedir(), ".agent-yes");
|
|
1431
|
-
return path.join(dir, "reads.jsonl");
|
|
1646
|
+
const dir = process.env.AGENT_YES_HOME ?? path$1.join(homedir(), ".agent-yes");
|
|
1647
|
+
return path$1.join(dir, "reads.jsonl");
|
|
1432
1648
|
}
|
|
1433
1649
|
async function readReads() {
|
|
1434
1650
|
let raw;
|
|
@@ -1451,7 +1667,7 @@ async function readReads() {
|
|
|
1451
1667
|
async function recordRead(by, target) {
|
|
1452
1668
|
const p = readsPath();
|
|
1453
1669
|
try {
|
|
1454
|
-
await mkdir(path.dirname(p), { recursive: true });
|
|
1670
|
+
await mkdir(path$1.dirname(p), { recursive: true });
|
|
1455
1671
|
await appendFile(p, JSON.stringify({
|
|
1456
1672
|
by,
|
|
1457
1673
|
target,
|
|
@@ -1636,13 +1852,13 @@ async function computeSenderVia() {
|
|
|
1636
1852
|
};
|
|
1637
1853
|
const here = real(process.cwd());
|
|
1638
1854
|
const claimedRoot = declared.cwd ? real(declared.cwd) : "";
|
|
1639
|
-
const insideClaimedTree = Boolean(claimedRoot) && (here === claimedRoot || here.startsWith(claimedRoot + path.sep));
|
|
1855
|
+
const insideClaimedTree = Boolean(claimedRoot) && (here === claimedRoot || here.startsWith(claimedRoot + path$1.sep));
|
|
1640
1856
|
const sameRepo = () => {
|
|
1641
1857
|
if (!claimedRoot) return false;
|
|
1642
1858
|
const a = gitCommonDir(here);
|
|
1643
1859
|
const b = gitCommonDir(claimedRoot);
|
|
1644
1860
|
if (a === null || b === null) return false;
|
|
1645
|
-
return a === b || a.startsWith(b + path.sep) || b.startsWith(a + path.sep);
|
|
1861
|
+
return a === b || a.startsWith(b + path$1.sep) || b.startsWith(a + path$1.sep);
|
|
1646
1862
|
};
|
|
1647
1863
|
if (!insideClaimedTree && !sameRepo()) return {
|
|
1648
1864
|
agent: declared,
|
|
@@ -1736,7 +1952,7 @@ async function cmdWhoami(rest) {
|
|
|
1736
1952
|
* shipped still show up in `ay ls`. Merging is done in `mergeRecords`.
|
|
1737
1953
|
*/
|
|
1738
1954
|
async function readLocalTsPids(cwd) {
|
|
1739
|
-
const jsonlPath = path.join(cwd, ".agent-yes", "pid-records.jsonl");
|
|
1955
|
+
const jsonlPath = path$1.join(cwd, ".agent-yes", "pid-records.jsonl");
|
|
1740
1956
|
let raw;
|
|
1741
1957
|
try {
|
|
1742
1958
|
raw = await readFile(jsonlPath, "utf-8");
|
|
@@ -2070,7 +2286,7 @@ async function runSubcommand(argv) {
|
|
|
2070
2286
|
switch (sub) {
|
|
2071
2287
|
case "ls":
|
|
2072
2288
|
case "list": return await cmdLs(rest);
|
|
2073
|
-
case "ps": return await (await import("./cmdPs-
|
|
2289
|
+
case "ps": return await (await import("./cmdPs-RZU-tTd4.js")).cmdPs(rest);
|
|
2074
2290
|
case "status": return await cmdStatus(rest);
|
|
2075
2291
|
case "whoami": return await cmdWhoami(rest);
|
|
2076
2292
|
case "result": return await cmdResult(rest);
|
|
@@ -2081,7 +2297,7 @@ async function runSubcommand(argv) {
|
|
|
2081
2297
|
case "tail": return await cmdRead(rest, { mode: "tail" });
|
|
2082
2298
|
case "head": return await cmdRead(rest, { mode: "head" });
|
|
2083
2299
|
case "hist":
|
|
2084
|
-
case "history": return await (await import("./hist-
|
|
2300
|
+
case "history": return await (await import("./hist-OSUKO8sb.js")).cmdHist(rest);
|
|
2085
2301
|
case "send": return await cmdSend(rest);
|
|
2086
2302
|
case "send-drain": return await cmdSendDrain(rest);
|
|
2087
2303
|
case "submit": return await cmdSubmit(rest);
|
|
@@ -2094,11 +2310,11 @@ async function runSubcommand(argv) {
|
|
|
2094
2310
|
case "stop": return await cmdStop(rest);
|
|
2095
2311
|
case "exit": return await cmdExit(rest);
|
|
2096
2312
|
case "restart": return await cmdRestart(rest);
|
|
2097
|
-
case "kill": return await (await import("./cmdKill-
|
|
2313
|
+
case "kill": return await (await import("./cmdKill-b5I7H8wx.js")).cmdKill(rest);
|
|
2098
2314
|
case "note": return await cmdNote(rest);
|
|
2099
2315
|
case "ask":
|
|
2100
2316
|
case "answer": {
|
|
2101
|
-
const { runAskSubcommand, runAnswerSubcommand } = await import("./askCli-
|
|
2317
|
+
const { runAskSubcommand, runAnswerSubcommand } = await import("./askCli-BjQOqpvv.js");
|
|
2102
2318
|
const deps = {
|
|
2103
2319
|
resolveAgent: (keyword) => resolveOne(keyword, {
|
|
2104
2320
|
all: true,
|
|
@@ -2112,85 +2328,85 @@ async function runSubcommand(argv) {
|
|
|
2112
2328
|
return sub === "ask" ? await runAskSubcommand(rest, deps) : await runAnswerSubcommand(rest, deps);
|
|
2113
2329
|
}
|
|
2114
2330
|
case "todo": {
|
|
2115
|
-
const { runTodoSubcommand } = await import("./todoCli-
|
|
2331
|
+
const { runTodoSubcommand } = await import("./todoCli-ammnk6Wv.js");
|
|
2116
2332
|
return runTodoSubcommand(rest);
|
|
2117
2333
|
}
|
|
2118
2334
|
case "ch":
|
|
2119
2335
|
case "channels": {
|
|
2120
|
-
const { cmdCh } = await import("./channels-
|
|
2336
|
+
const { cmdCh } = await import("./channels-bw-b9z0l.js");
|
|
2121
2337
|
return cmdCh(rest);
|
|
2122
2338
|
}
|
|
2123
2339
|
case "term": {
|
|
2124
|
-
const { cmdTerm } = await import("./terminal-
|
|
2340
|
+
const { cmdTerm } = await import("./terminal-CLjXOXI7.js");
|
|
2125
2341
|
return cmdTerm(rest);
|
|
2126
2342
|
}
|
|
2127
2343
|
case "widget": {
|
|
2128
|
-
const { cmdWidget } = await import("./widget-
|
|
2344
|
+
const { cmdWidget } = await import("./widget-DU-iJOPF.js");
|
|
2129
2345
|
return cmdWidget(rest);
|
|
2130
2346
|
}
|
|
2131
2347
|
case "mint": {
|
|
2132
|
-
const { cmdMint } = await import("./widget-
|
|
2348
|
+
const { cmdMint } = await import("./widget-DU-iJOPF.js");
|
|
2133
2349
|
return cmdMint(rest);
|
|
2134
2350
|
}
|
|
2135
2351
|
case "serve": {
|
|
2136
|
-
const { cmdServe } = await import("./serve-
|
|
2352
|
+
const { cmdServe } = await import("./serve-BJEDb5Az.js");
|
|
2137
2353
|
return cmdServe(rest);
|
|
2138
2354
|
}
|
|
2139
2355
|
case "tray": {
|
|
2140
|
-
const { cmdTray } = await import("./trayApp-
|
|
2356
|
+
const { cmdTray } = await import("./trayApp-UWX_Bfay.js");
|
|
2141
2357
|
return cmdTray(rest);
|
|
2142
2358
|
}
|
|
2143
2359
|
case "setup": {
|
|
2144
|
-
const { cmdSetup } = await import("./setup-
|
|
2360
|
+
const { cmdSetup } = await import("./setup-CxQJtnmp.js");
|
|
2145
2361
|
return cmdSetup(rest);
|
|
2146
2362
|
}
|
|
2147
2363
|
case "ws": {
|
|
2148
|
-
const { cmdWs } = await import("./ws-
|
|
2364
|
+
const { cmdWs } = await import("./ws-CNd9TMOE.js");
|
|
2149
2365
|
return cmdWs(rest);
|
|
2150
2366
|
}
|
|
2151
2367
|
case "schedules":
|
|
2152
2368
|
case "sched": {
|
|
2153
|
-
const { cmdSchedules } = await import("./schedulesCli-
|
|
2369
|
+
const { cmdSchedules } = await import("./schedulesCli-DSBZwREE.js");
|
|
2154
2370
|
return cmdSchedules(rest);
|
|
2155
2371
|
}
|
|
2156
2372
|
case "cron": {
|
|
2157
|
-
const { cmdCron } = await import("./schedulesCli-
|
|
2373
|
+
const { cmdCron } = await import("./schedulesCli-DSBZwREE.js");
|
|
2158
2374
|
return cmdCron(rest);
|
|
2159
2375
|
}
|
|
2160
2376
|
case "schedule": {
|
|
2161
|
-
const { cmdSchedule } = await import("./schedule-
|
|
2377
|
+
const { cmdSchedule } = await import("./schedule-DncJhp1d.js");
|
|
2162
2378
|
return cmdSchedule(rest);
|
|
2163
2379
|
}
|
|
2164
2380
|
case "remote": {
|
|
2165
|
-
const { cmdRemote } = await import("./remotes-
|
|
2381
|
+
const { cmdRemote } = await import("./remotes-TKXkCV76.js");
|
|
2166
2382
|
return cmdRemote(rest);
|
|
2167
2383
|
}
|
|
2168
2384
|
case "share": {
|
|
2169
|
-
const { cmdShare } = await import("./shareCmd-
|
|
2385
|
+
const { cmdShare } = await import("./shareCmd-96G551OE.js");
|
|
2170
2386
|
return cmdShare(rest);
|
|
2171
2387
|
}
|
|
2172
2388
|
case "connect": {
|
|
2173
|
-
const { cmdConnect } = await import("./remotes-
|
|
2389
|
+
const { cmdConnect } = await import("./remotes-TKXkCV76.js");
|
|
2174
2390
|
return cmdConnect(rest);
|
|
2175
2391
|
}
|
|
2176
2392
|
case "expose": {
|
|
2177
|
-
const { cmdExpose } = await import("./expose-
|
|
2393
|
+
const { cmdExpose } = await import("./expose-BKxcKYt-.js");
|
|
2178
2394
|
return cmdExpose(rest);
|
|
2179
2395
|
}
|
|
2180
2396
|
case "callback": {
|
|
2181
|
-
const { cmdCallback } = await import("./callback-
|
|
2397
|
+
const { cmdCallback } = await import("./callback-oTjpUn2G.js");
|
|
2182
2398
|
return cmdCallback(rest);
|
|
2183
2399
|
}
|
|
2184
2400
|
case "reap":
|
|
2185
|
-
await (await import("./reaper-
|
|
2401
|
+
await (await import("./reaper-A_eEjMxS.js")).sweep();
|
|
2186
2402
|
return 0;
|
|
2187
2403
|
case "dsh-legacy": {
|
|
2188
|
-
const { cmdDsh } = await import("./cmdDsh-
|
|
2404
|
+
const { cmdDsh } = await import("./cmdDsh-h7V2ThH5.js");
|
|
2189
2405
|
return await cmdDsh(rest);
|
|
2190
2406
|
}
|
|
2191
2407
|
case "gc": {
|
|
2192
|
-
const { gcOldBinaryDirs } = await import("./rustBinary-
|
|
2193
|
-
const { gcLogs } = await import("./globalPidIndex-
|
|
2408
|
+
const { gcOldBinaryDirs } = await import("./rustBinary-B603fLUa.js");
|
|
2409
|
+
const { gcLogs } = await import("./globalPidIndex-B5c_g_yJ.js");
|
|
2194
2410
|
const bins = gcOldBinaryDirs();
|
|
2195
2411
|
const logs = await gcLogs();
|
|
2196
2412
|
if (bins.removed.length === 0) process.stdout.write("no old agent-yes binary cache dirs to remove\n");
|
|
@@ -2257,7 +2473,7 @@ async function cmdHelp(managerCommands = true) {
|
|
|
2257
2473
|
const killAliasNote = managerCommands ? `` : ` (\`ay kill\` only — \`cy kill …\` is a prompt)\n`;
|
|
2258
2474
|
const self = process.env.AGENT_YES_PID ? await resolveSender() : null;
|
|
2259
2475
|
const agentSection = self ? await buildAgentContextSection(self) : "";
|
|
2260
|
-
process.stdout.write(agentSection + "ay - agent-yes CLI\n\nManagement:\n ay ls [keyword] list running agents (remotes from cache, refreshed\n [--waitFor=all|local|<alias>] in the background; --waitFor blocks for fresh rows)\n ay ps [keyword] per-agent CPU/RSS, rolled up over each\n agent's whole process tree, + box vitals\n ay tail [-f] [-n N] <keyword> last N lines (96), -f to follow\n ay tail <keyword> --until TEXT block until TEXT is printed, then exit 0\n [--timeout 10m] [-q] [--regex] (1 = agent exited without it, 2 = no match,\n [--fail-on TEXT] [--count N] 3 = --fail-on hit first)\n ay read <keyword> [page opts] paginate: --last/--head N, --range A:B,\n --before-line L [--limit N]\n" + readAliasNote + " ay cat <keyword> full log\n ay head <keyword> first N lines\n ay hist [-n 6] [--all] [--json] past agent conversations (claude/codex\n transcripts, incl. exited sessions);\n this cwd unless --all\n ay send <keyword> <msg> send a message (keyword '.' = agent in this cwd)\n ay msgs [keyword] [--in|--out] inter-agent message log (sent + received)\n ay ch mk|join|send|read|tail <topic> local-first E2E channels: AI ↔ humans on a topic (ay ch help)\n ay term embed <pid> <script> to embed a live read-only agent terminal in a page (ay term help)\n ay widget ls | read selection|dom read an opted-in page widget's context (selection/DOM) (ay widget help)\n ay mint <target> --caps ... mint a scoped, short-TTL capability token (embeddable in a page)\n ay key <keyword> <key...> send raw keystrokes (down/up/enter/esc/…) — drives menus\n ay submit <keyword> press Enter on text left in its input box\n ay select <keyword> <N> pick option N of a needs_input selection menu\n ay attach <keyword> interactive attach (detach: Ctrl-\\)\n ay stop <keyword> graceful shutdown (/exit for claude/codex)\n ay exit <keyword> [reason] graceful shutdown, recording who/why (= 'ay send <kw> exit')\n ay restart <keyword> [--fresh] stop (if live) + relaunch resuming the session; --fresh replays the prompt\n ay kill <pid> [--dry-run] SIGKILL an agent + its process group, like the console's\n Kill (exact pid from ay ls; never the calling shell)\n" + killAliasNote + " ay status <keyword> agent status snapshot\n ay notify watch --unread get notified when sub-agents finish/stuck/crash (writes to inbox)\n ay whoami [--json] (inside an agent) your own registry identity + reply address\n ay result <keyword> [--wait] pull an agent's structured result envelope\n ay result set '<json>' (inside an agent) deposit your result envelope\n ay reap kill process groups leaked by dead agents\n ay gc reclaim old-version binary cache dirs + stale session logs\n ay dsh-legacy [args...] launch the DeepSeek Harness terminal client (dsh-tui)\n" + wsLines + "\nRemote:\n" + setupLine + " ay share [local|lan|tailscale|webrtc] share this machine: one URL for web console + CLI\n ay connect <share-url> [alias] save another machine's share URL as a remote\n" + shareAliasNote + " ay schedule <when> <cli> -- <msg> run an agent on a schedule (HH:MM or cron)\n ay serve [--port N] start HTTP API server (prints token)\n ay serve status show serve daemon/server status\n ay remote add <alias> http://<token>@<host>:<port>\n ay remote ls / rm <alias> manage saved remotes\n ay expose <port> share localhost:<port> at https://<id>.agent-yes.com (private link)\n ay callback --expires 7d mint an embeddable message-me widget for one agent\n ay ls <token>@<host>:<port> connect inline (no alias needed)\n ay send <token>@<host>:<port>:<kw> <msg>\n\nRun an agent (naming a CLI is what launches one — bare 'ay' shows this help):\n ay <claude|codex|...> [options] -- [prompt]\n ay claude -- \"fix the bug in auth.ts\"\n ay --detach claude -- \"…\" start it in the background and return at once\n (e.g. over ssh); prints its pid + how to drive it\n cy [options] -- [prompt] shortcut for 'ay claude' (bare 'cy' starts claude)\n ay claude --help full agent-runner options\n\nLabs (examples at https://github.com/snomiao/agent-yes/tree/main/lab):\n local-role-play/ designer + builder on one machine\n http-remote/ ay serve remote access demo\n p2p-pairing/ libp2p P2P (needs: cargo build --features swarm)\n");
|
|
2476
|
+
process.stdout.write(agentSection + "ay - agent-yes CLI\n\nManagement:\n ay ls [keyword] list running agents (remotes from cache, refreshed\n [--waitFor=all|local|<alias>] in the background; --waitFor blocks for fresh rows)\n ay ps [keyword] per-agent CPU/RSS, rolled up over each\n agent's whole process tree, + box vitals\n ay tail [-f] [-n N] <keyword> last N lines (96), -f to follow\n ay tail <keyword> --until TEXT block until TEXT is printed, then exit 0\n [--timeout 10m] [-q] [--regex] (1 = agent exited without it, 2 = no match,\n [--fail-on TEXT] [--count N] 3 = --fail-on hit first)\n ay read <keyword> [page opts] paginate: --last/--head N, --range A:B,\n --before-line L [--limit N]\n" + readAliasNote + " ay cat <keyword> full log\n ay head <keyword> first N lines\n ay hist [-n 6] [--all] [--json] past agent conversations (claude/codex\n transcripts, incl. exited sessions);\n this cwd unless --all\n ay send <keyword> <msg> send a message (keyword '.' = agent in this cwd)\n ay msgs [keyword] [--in|--out] inter-agent message log (sent + received)\n ay ch mk|join|send|read|tail <topic> local-first E2E channels: AI ↔ humans on a topic (ay ch help)\n ay term embed <pid> <script> to embed a live read-only agent terminal in a page (ay term help)\n ay widget ls | read selection|dom read an opted-in page widget's context (selection/DOM) (ay widget help)\n ay mint <target> --caps ... mint a scoped, short-TTL capability token (embeddable in a page)\n ay key <keyword> <key...> send raw keystrokes (down/up/enter/esc/…) — drives menus\n ay submit <keyword> press Enter on text left in its input box\n ay select <keyword> <N> pick option N of a needs_input selection menu\n ay attach <keyword> interactive attach (detach: Ctrl-\\)\n ay stop <keyword> graceful shutdown (/exit for claude/codex)\n ay exit <keyword> [reason] graceful shutdown, recording who/why (= 'ay send <kw> exit')\n ay restart <keyword> [--fresh] stop (if live) + relaunch resuming the session; --fresh replays the prompt\n ay kill <pid> [--dry-run] SIGKILL an agent + its process group, like the console's\n Kill (exact pid from ay ls; never the calling shell)\n" + killAliasNote + " ay status <keyword> agent status snapshot\n ay notify watch --unread get notified when sub-agents finish/stuck/crash (writes to inbox)\n ay whoami [--json] (inside an agent) your own registry identity + reply address\n ay result <keyword> [--wait] pull an agent's structured result envelope\n ay result set '<json>' (inside an agent) deposit your result envelope\n ay reap kill process groups leaked by dead agents\n ay gc reclaim old-version binary cache dirs + stale session logs\n ay dsh-legacy [args...] launch the DeepSeek Harness terminal client (dsh-tui)\n" + wsLines + "\nRemote:\n" + setupLine + " ay share [local|lan|tailscale|webrtc] share this machine: one URL for web console + CLI\n ay connect <share-url> [alias] save another machine's share URL as a remote\n" + shareAliasNote + " ay schedule <when> <cli> -- <msg> run an agent on a schedule (HH:MM or cron)\n ay serve [--port N] start HTTP API server (prints token)\n ay serve status show serve daemon/server status\n ay remote add <alias> http://<token>@<host>:<port>\n ay remote ls / rm <alias> manage saved remotes\n ay expose <port> share localhost:<port> at https://<id>.agent-yes.com (private link)\n ay callback --expires 7d mint an embeddable message-me widget for one agent\n ay ls <token>@<host>:<port> connect inline (no alias needed)\n ay send <token>@<host>:<port>:<kw> <msg>\n\nRun an agent (naming a CLI is what launches one — bare 'ay' shows this help):\n ay <claude|codex|...> [options] -- [prompt]\n ay claude -- \"fix the bug in auth.ts\"\n ay --stream claude \"task\" use the Claude stream JSON protocol\n ay --detach claude -- \"…\" start it in the background and return at once\n (e.g. over ssh); prints its pid + how to drive it\n cy [options] -- [prompt] shortcut for 'ay claude' (bare 'cy' starts claude)\n ay claude --help full agent-runner options\n\nLabs (examples at https://github.com/snomiao/agent-yes/tree/main/lab):\n local-role-play/ designer + builder on one machine\n http-remote/ ay serve remote access demo\n p2p-pairing/ libp2p P2P (needs: cargo build --features swarm)\n");
|
|
2261
2477
|
return 0;
|
|
2262
2478
|
}
|
|
2263
2479
|
/** Looks like an agent_id (12 hex, or a longer injected one) rather than a word. */
|
|
@@ -2273,8 +2489,8 @@ function matchKeyword(record, keyword) {
|
|
|
2273
2489
|
}
|
|
2274
2490
|
if (isAgentIdShaped(keyword)) return !!(record.agent_id && record.agent_id.toLowerCase().startsWith(kw));
|
|
2275
2491
|
if (kw === "." || kw === "./") {
|
|
2276
|
-
const here = path.resolve(process.cwd());
|
|
2277
|
-
return path.resolve(record.cwd) === here || !!record.workdir && path.resolve(record.workdir) === here;
|
|
2492
|
+
const here = path$1.resolve(process.cwd());
|
|
2493
|
+
return path$1.resolve(record.cwd) === here || !!record.workdir && path$1.resolve(record.workdir) === here;
|
|
2278
2494
|
}
|
|
2279
2495
|
if (record.cwd.toLowerCase().includes(kw)) return true;
|
|
2280
2496
|
if (record.workdir && record.workdir.toLowerCase().includes(kw)) return true;
|
|
@@ -2721,7 +2937,7 @@ async function runRemoteSend(remote, msg, code, raw = false) {
|
|
|
2721
2937
|
let wire = msg;
|
|
2722
2938
|
let nonce;
|
|
2723
2939
|
if (sender.agent && msg && msg !== "-" && !isSlashCommand(msg) && !raw) {
|
|
2724
|
-
nonce = randomBytes(4).toString("hex");
|
|
2940
|
+
nonce = randomBytes$1(4).toString("hex");
|
|
2725
2941
|
const { prefix, suffix } = buildEnvelope({
|
|
2726
2942
|
nonce,
|
|
2727
2943
|
cli: sender.agent.cli,
|
|
@@ -2834,7 +3050,7 @@ async function fetchRemoteRecordsRaw(url, token, opts, onReachable) {
|
|
|
2834
3050
|
let base = url;
|
|
2835
3051
|
let bearer = token;
|
|
2836
3052
|
if (isWebrtcSpec(url)) {
|
|
2837
|
-
const { startWebrtcBridge } = await import("./webrtcRemote-
|
|
3053
|
+
const { startWebrtcBridge } = await import("./webrtcRemote-DdCC3aZC.js");
|
|
2838
3054
|
bridge = await startWebrtcBridge(url);
|
|
2839
3055
|
base = bridge.baseUrl;
|
|
2840
3056
|
bearer = bridge.token;
|
|
@@ -2917,10 +3133,10 @@ async function cmdLsRefresh(rest) {
|
|
|
2917
3133
|
await Promise.all(aliases.map(async (alias) => {
|
|
2918
3134
|
const cfg = remotes.get(alias);
|
|
2919
3135
|
if (!cfg) return;
|
|
2920
|
-
const lock = path.join(agentYesHome(), "remotes", `${encodeURIComponent(alias)}.refresh.lock`);
|
|
3136
|
+
const lock = path$1.join(agentYesHome(), "remotes", `${encodeURIComponent(alias)}.refresh.lock`);
|
|
2921
3137
|
const owner = Number((await readFile(lock, "utf-8").catch(() => "")).trim());
|
|
2922
3138
|
if (owner > 0 && owner !== process.pid && pidAlive(owner)) return;
|
|
2923
|
-
await mkdir(path.dirname(lock), { recursive: true }).catch(() => {});
|
|
3139
|
+
await mkdir(path$1.dirname(lock), { recursive: true }).catch(() => {});
|
|
2924
3140
|
await writeFile(lock, String(process.pid)).catch(() => {});
|
|
2925
3141
|
try {
|
|
2926
3142
|
const { ok } = await refreshRemoteSnapshot(alias, cfg, opts, now);
|
|
@@ -3138,6 +3354,7 @@ async function runAllRemotesLs(opts) {
|
|
|
3138
3354
|
*/
|
|
3139
3355
|
async function deriveLiveStatus(r) {
|
|
3140
3356
|
if (r.status === "exited" || !isPidAlive(r.pid)) return "exited";
|
|
3357
|
+
if (r.mode === "stream") return (await readStreamSnapshot(r)).state === "idle" ? "idle" : "active";
|
|
3141
3358
|
if (!r.log_file) return "active";
|
|
3142
3359
|
const mtime = await stat(r.log_file).then((s) => s.mtimeMs).catch(() => null);
|
|
3143
3360
|
return mtime !== null && Date.now() - mtime > IDLE_THRESHOLD_MS ? "idle" : "active";
|
|
@@ -3273,6 +3490,17 @@ async function deriveLiveState(r) {
|
|
|
3273
3490
|
state: "stopped",
|
|
3274
3491
|
question: null
|
|
3275
3492
|
};
|
|
3493
|
+
if (r.mode === "stream") {
|
|
3494
|
+
if (reachabilityProbeApplies(r, base) && await confirmStdinUnreachable(r)) return {
|
|
3495
|
+
state: "unreachable",
|
|
3496
|
+
question: null
|
|
3497
|
+
};
|
|
3498
|
+
const { state, question } = await readStreamSnapshot(r);
|
|
3499
|
+
return {
|
|
3500
|
+
state,
|
|
3501
|
+
question
|
|
3502
|
+
};
|
|
3503
|
+
}
|
|
3276
3504
|
if (reachabilityProbeApplies(r, base) && await confirmStdinUnreachable(r)) return {
|
|
3277
3505
|
state: "unreachable",
|
|
3278
3506
|
question: null
|
|
@@ -3493,7 +3721,7 @@ async function cmdLs(rest) {
|
|
|
3493
3721
|
active: argv.active,
|
|
3494
3722
|
json: argv.json,
|
|
3495
3723
|
latest: argv.latest,
|
|
3496
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
3724
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
3497
3725
|
};
|
|
3498
3726
|
if (argv.watch) {
|
|
3499
3727
|
const fallbackMs = Math.max(500, (Number.isFinite(argv.interval) ? argv.interval : 2) * 1e3);
|
|
@@ -3501,8 +3729,8 @@ async function cmdLs(rest) {
|
|
|
3501
3729
|
const tailers = /* @__PURE__ */ new Map();
|
|
3502
3730
|
const indexFiles = new Set([
|
|
3503
3731
|
getGlobalPidIndexPath(),
|
|
3504
|
-
path.join(process.cwd(), ".agent-yes", "pid-records.jsonl"),
|
|
3505
|
-
...opts.cwdScope ? [path.join(opts.cwdScope, ".agent-yes", "pid-records.jsonl")] : []
|
|
3732
|
+
path$1.join(process.cwd(), ".agent-yes", "pid-records.jsonl"),
|
|
3733
|
+
...opts.cwdScope ? [path$1.join(opts.cwdScope, ".agent-yes", "pid-records.jsonl")] : []
|
|
3506
3734
|
]);
|
|
3507
3735
|
let timer;
|
|
3508
3736
|
let fallback;
|
|
@@ -3562,7 +3790,7 @@ async function cmdLs(rest) {
|
|
|
3562
3790
|
};
|
|
3563
3791
|
const snapshot = async (checkIdentity = false) => {
|
|
3564
3792
|
const recs = await listRecords(keyword, opts);
|
|
3565
|
-
const targets = new Set([...indexFiles, ...recs.map((record) => record.log_file).filter((file) => !!file)]);
|
|
3793
|
+
const targets = new Set([...indexFiles, ...recs.map((record) => record.mode === "stream" ? eventFile(record) : record.log_file).filter((file) => !!file)]);
|
|
3566
3794
|
for (const [file, follower] of tailers) if (!targets.has(file)) {
|
|
3567
3795
|
tailers.delete(file);
|
|
3568
3796
|
follower.child.kill("SIGTERM");
|
|
@@ -3622,7 +3850,8 @@ async function cmdLs(rest) {
|
|
|
3622
3850
|
if (opts.json) {
|
|
3623
3851
|
const enriched = await Promise.all(records.map(async (r) => ({
|
|
3624
3852
|
...r,
|
|
3625
|
-
...await deriveLiveState(r)
|
|
3853
|
+
...await deriveLiveState(r),
|
|
3854
|
+
...r.mode === "stream" ? { cost_usd: (await readStreamSnapshot(r)).costUsd ?? null } : {}
|
|
3626
3855
|
})));
|
|
3627
3856
|
await writeStdoutFlushed(JSON.stringify(enriched, null, 2) + "\n");
|
|
3628
3857
|
return 0;
|
|
@@ -3636,14 +3865,17 @@ async function cmdLs(rest) {
|
|
|
3636
3865
|
const lastActive = new Map(await Promise.all(records.map(async (r) => [r.pid, await deriveLastActiveAt(r)])));
|
|
3637
3866
|
const ageOf = (r) => humanizeAge(now - (lastActive.get(r.pid) ?? r.started_at));
|
|
3638
3867
|
const rawCwds = records.map((r) => cwdLabel(r));
|
|
3868
|
+
const costs = new Map(await Promise.all(records.map(async (r) => [r.pid, r.mode === "stream" ? (await readStreamSnapshot(r)).costUsd : void 0])));
|
|
3869
|
+
const costOf = (r) => costs.get(r.pid) === void 0 ? "-" : `$${costs.get(r.pid).toFixed(4)}`;
|
|
3639
3870
|
const widths = {
|
|
3871
|
+
cost: Math.max(4, ...records.map((r) => costOf(r).length)),
|
|
3640
3872
|
pid: Math.max(3, ...records.map((r) => String(r.pid).length)),
|
|
3641
3873
|
cli: Math.max(3, ...records.map((r) => r.cli.length)),
|
|
3642
3874
|
status: Math.max(6, ...records.map((r) => r.status.length)),
|
|
3643
3875
|
age: Math.max(3, ...records.map((r) => ageOf(r).length)),
|
|
3644
3876
|
cwd: Math.max(3, ...rawCwds.map((c) => c.length))
|
|
3645
3877
|
};
|
|
3646
|
-
const fixedWidth = widths.pid + widths.cli + widths.status + widths.age + widths.cwd +
|
|
3878
|
+
const fixedWidth = widths.pid + widths.cli + widths.status + widths.age + widths.cwd + widths.cost + 12;
|
|
3647
3879
|
const promptBudget = Math.max(20, termWidth - fixedWidth - 1);
|
|
3648
3880
|
const forestRows = flattenForest(buildAgentForest(records));
|
|
3649
3881
|
const notes = await readNotes();
|
|
@@ -3683,6 +3915,7 @@ async function cmdLs(rest) {
|
|
|
3683
3915
|
cli: r.cli,
|
|
3684
3916
|
status: displayStatus,
|
|
3685
3917
|
age: ageOf(r),
|
|
3918
|
+
cost: costOf(r),
|
|
3686
3919
|
cwd: cwdLabel(r),
|
|
3687
3920
|
label,
|
|
3688
3921
|
hasNote,
|
|
@@ -3694,6 +3927,7 @@ async function cmdLs(rest) {
|
|
|
3694
3927
|
"CLI".padEnd(widths.cli),
|
|
3695
3928
|
"STATUS".padEnd(widths.status),
|
|
3696
3929
|
"AGE".padEnd(widths.age),
|
|
3930
|
+
"COST".padEnd(widths.cost),
|
|
3697
3931
|
"CWD".padEnd(widths.cwd),
|
|
3698
3932
|
"NOTE/PROMPT"
|
|
3699
3933
|
].join(" ") + "\n";
|
|
@@ -3703,6 +3937,7 @@ async function cmdLs(rest) {
|
|
|
3703
3937
|
r.cli.padEnd(widths.cli),
|
|
3704
3938
|
r.status.padEnd(widths.status),
|
|
3705
3939
|
r.age.padEnd(widths.age),
|
|
3940
|
+
r.cost.padEnd(widths.cost),
|
|
3706
3941
|
r.cwd.padEnd(widths.cwd),
|
|
3707
3942
|
r.label
|
|
3708
3943
|
].join(" ") + "\n");
|
|
@@ -3856,7 +4091,7 @@ async function cmdRead(rest, { mode }) {
|
|
|
3856
4091
|
active: false,
|
|
3857
4092
|
json: false,
|
|
3858
4093
|
latest: argv.latest,
|
|
3859
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
4094
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
3860
4095
|
};
|
|
3861
4096
|
const keyword = argv._[0] !== void 0 ? String(argv._[0]) : void 0;
|
|
3862
4097
|
if (keyword) {
|
|
@@ -3897,7 +4132,7 @@ async function cmdRead(rest, { mode }) {
|
|
|
3897
4132
|
const noteLabel = (await readNotes()).get(record.pid);
|
|
3898
4133
|
const header = noteLabel ? `[pid ${record.pid} ${shortenPath(record.cwd)} * ${noteLabel}]` : `[pid ${record.pid} ${shortenPath(record.cwd)}]`;
|
|
3899
4134
|
if (follow) {
|
|
3900
|
-
const rendered = await renderRawLog(buf, {
|
|
4135
|
+
const rendered = record.mode === "stream" ? n ? Buffer.from(buf).toString("utf8").trimEnd().split("\n").slice(-n).join("\n") : Buffer.from(buf).toString("utf8") : await renderRawLog(buf, {
|
|
3901
4136
|
mode,
|
|
3902
4137
|
n,
|
|
3903
4138
|
cols: size?.cols,
|
|
@@ -3916,6 +4151,16 @@ async function cmdRead(rest, { mode }) {
|
|
|
3916
4151
|
if (tally.feedAll(lines)) return reportUntil("match", tally.last, Boolean(argv.quiet));
|
|
3917
4152
|
}
|
|
3918
4153
|
setInterval(() => void recordRead(reader.key, record.pid), 3e4).unref?.();
|
|
4154
|
+
if (record.mode === "stream") return followTranscriptLocal(logPath, stats.size, tally ? {
|
|
4155
|
+
tally,
|
|
4156
|
+
failTally,
|
|
4157
|
+
pattern: until,
|
|
4158
|
+
failPattern: failOn,
|
|
4159
|
+
quiet: Boolean(argv.quiet),
|
|
4160
|
+
timeoutMs: untilTimeoutMs,
|
|
4161
|
+
matchBacklog: Boolean(argv["match-backlog"]),
|
|
4162
|
+
pid: record.pid
|
|
4163
|
+
} : void 0);
|
|
3919
4164
|
return plain ? followPlainLocal(logPath, buf, stats.size, tally ? {
|
|
3920
4165
|
tally,
|
|
3921
4166
|
failTally,
|
|
@@ -3930,7 +4175,7 @@ async function cmdRead(rest, { mode }) {
|
|
|
3930
4175
|
rows: size?.rows
|
|
3931
4176
|
}) : followRawLocal(logPath, buf, stats.size);
|
|
3932
4177
|
}
|
|
3933
|
-
const allLines = await renderRawLogLines(buf, {
|
|
4178
|
+
const allLines = record.mode === "stream" ? Buffer.from(buf).toString("utf8").trimEnd().split("\n") : await renderRawLogLines(buf, {
|
|
3934
4179
|
cols: size?.cols,
|
|
3935
4180
|
rows: size?.rows
|
|
3936
4181
|
});
|
|
@@ -4049,6 +4294,53 @@ async function watchAppend(logPath, startOffset, onChunk, onStop, signal) {
|
|
|
4049
4294
|
});
|
|
4050
4295
|
return offset;
|
|
4051
4296
|
}
|
|
4297
|
+
/** Follow the already-readable stream transcript without terminal wrapping. */
|
|
4298
|
+
async function followTranscriptLocal(logPath, startOffset, until) {
|
|
4299
|
+
const { StringDecoder } = await import("node:string_decoder");
|
|
4300
|
+
const decoder = new StringDecoder("utf8");
|
|
4301
|
+
const ac = new AbortController();
|
|
4302
|
+
const judge = until ? makeJudge(until.tally, until.failTally) : null;
|
|
4303
|
+
let pending = "";
|
|
4304
|
+
let outcome = "stopped";
|
|
4305
|
+
const feed = (chunk) => {
|
|
4306
|
+
const text = decoder.write(Buffer.from(chunk));
|
|
4307
|
+
if (!until?.quiet) process.stdout.write(text);
|
|
4308
|
+
pending += text;
|
|
4309
|
+
let end;
|
|
4310
|
+
while ((end = pending.indexOf("\n")) !== -1) {
|
|
4311
|
+
const line = pending.slice(0, end);
|
|
4312
|
+
pending = pending.slice(end + 1);
|
|
4313
|
+
if (judge && !judge.settled && judge.test(line)) {
|
|
4314
|
+
outcome = judge.outcome ?? "match";
|
|
4315
|
+
ac.abort();
|
|
4316
|
+
}
|
|
4317
|
+
}
|
|
4318
|
+
};
|
|
4319
|
+
process.stderr.write(until ? untilBanner(until) : "following transcript... (Ctrl-C / SIGTERM to stop)\n");
|
|
4320
|
+
const timer = until?.timeoutMs != null ? setTimeout(() => {
|
|
4321
|
+
outcome = "timeout";
|
|
4322
|
+
ac.abort();
|
|
4323
|
+
}, until.timeoutMs) : void 0;
|
|
4324
|
+
const liveness = until ? setInterval(() => {
|
|
4325
|
+
if (!isPidAlive(until.pid)) {
|
|
4326
|
+
outcome = "exited";
|
|
4327
|
+
ac.abort();
|
|
4328
|
+
}
|
|
4329
|
+
}, 250) : void 0;
|
|
4330
|
+
try {
|
|
4331
|
+
const offset = await watchAppend(logPath, startOffset, feed, () => {}, ac.signal);
|
|
4332
|
+
const remaining = await readFile(logPath).catch(() => Buffer.alloc(0));
|
|
4333
|
+
if (remaining.length > offset) feed(remaining.subarray(offset));
|
|
4334
|
+
if (pending && judge && !judge.settled && judge.test(pending)) outcome = judge.outcome ?? "match";
|
|
4335
|
+
return until ? reportUntil(outcome, judge?.matched ?? null, until.quiet, until.failPattern, {
|
|
4336
|
+
hits: until.tally.hits,
|
|
4337
|
+
needed: until.tally.needed
|
|
4338
|
+
}) : 0;
|
|
4339
|
+
} finally {
|
|
4340
|
+
if (timer) clearTimeout(timer);
|
|
4341
|
+
if (liveness) clearInterval(liveness);
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4052
4344
|
/**
|
|
4053
4345
|
* Default (interactive) follow: append each new byte range with ANSI/control
|
|
4054
4346
|
* sequences stripped. Mirrors the historical behaviour, plus prompt signal /
|
|
@@ -4322,9 +4614,9 @@ function reportUntil(outcome, matched, quiet, failPattern, progress) {
|
|
|
4322
4614
|
* yet written).
|
|
4323
4615
|
*/
|
|
4324
4616
|
async function readPtysize(pid) {
|
|
4325
|
-
const dir = process.env.AGENT_YES_HOME ?? path.join(homedir(), ".agent-yes");
|
|
4617
|
+
const dir = process.env.AGENT_YES_HOME ?? path$1.join(homedir(), ".agent-yes");
|
|
4326
4618
|
try {
|
|
4327
|
-
const [c = 0, r = 0] = (await readFile(path.join(dir, "ptysize", String(pid)), "utf-8")).trim().split(/\s+/).map(Number);
|
|
4619
|
+
const [c = 0, r = 0] = (await readFile(path$1.join(dir, "ptysize", String(pid)), "utf-8")).trim().split(/\s+/).map(Number);
|
|
4328
4620
|
if (c > 0 && r > 0) return {
|
|
4329
4621
|
cols: c,
|
|
4330
4622
|
rows: r
|
|
@@ -4612,7 +4904,7 @@ const renderDiskUsed = /* @__PURE__ */ new Map();
|
|
|
4612
4904
|
const RENDER_DISK_MAX = 1024;
|
|
4613
4905
|
function enableRenderDiskCache() {
|
|
4614
4906
|
renderDiskEnabled = true;
|
|
4615
|
-
renderDiskPath = path.join(agentYesHome(), "cache", "ls-render.json");
|
|
4907
|
+
renderDiskPath = path$1.join(agentYesHome(), "cache", "ls-render.json");
|
|
4616
4908
|
}
|
|
4617
4909
|
function renderDiskGet(key) {
|
|
4618
4910
|
if (!renderDiskEnabled) return void 0;
|
|
@@ -4635,7 +4927,7 @@ function saveRenderDisk() {
|
|
|
4635
4927
|
if (!renderDiskPath) return;
|
|
4636
4928
|
try {
|
|
4637
4929
|
const file = renderDiskPath;
|
|
4638
|
-
mkdirSync(path.dirname(file), {
|
|
4930
|
+
mkdirSync(path$1.dirname(file), {
|
|
4639
4931
|
recursive: true,
|
|
4640
4932
|
mode: 448
|
|
4641
4933
|
});
|
|
@@ -4895,7 +5187,7 @@ async function extractBadges(logPath) {
|
|
|
4895
5187
|
}
|
|
4896
5188
|
const TYPING_WINDOW_MS = 3e3;
|
|
4897
5189
|
function stdinActivityPath(pid) {
|
|
4898
|
-
return path.resolve(agentYesHome(), "activity", `${pid}.stdin`);
|
|
5190
|
+
return path$1.resolve(agentYesHome(), "activity", `${pid}.stdin`);
|
|
4899
5191
|
}
|
|
4900
5192
|
async function lastStdinAt(pid) {
|
|
4901
5193
|
const raw = await readFile(stdinActivityPath(pid), "utf-8").catch(() => null);
|
|
@@ -5308,7 +5600,7 @@ async function interruptPermissionPrompt(record) {
|
|
|
5308
5600
|
const DRAIN_POLL_BASE_MS = 500;
|
|
5309
5601
|
const DRAIN_POLL_CAP_MS = 5e3;
|
|
5310
5602
|
function drainerLockPath(pid) {
|
|
5311
|
-
return path.join(agentYesHome(), "pending", `${pid}.drainer`);
|
|
5603
|
+
return path$1.join(agentYesHome(), "pending", `${pid}.drainer`);
|
|
5312
5604
|
}
|
|
5313
5605
|
/** The pid of a live drainer for `pid`'s queue, or null. */
|
|
5314
5606
|
async function liveDrainer(pid) {
|
|
@@ -5374,7 +5666,7 @@ async function cmdSendDrain(rest) {
|
|
|
5374
5666
|
const pid = Number(rest[0]);
|
|
5375
5667
|
if (!Number.isInteger(pid) || pid <= 0) throw new Error("usage: ay send-drain <pid>");
|
|
5376
5668
|
const lockFile = drainerLockPath(pid);
|
|
5377
|
-
await mkdir(path.dirname(lockFile), { recursive: true });
|
|
5669
|
+
await mkdir(path$1.dirname(lockFile), { recursive: true });
|
|
5378
5670
|
const other = await liveDrainer(pid);
|
|
5379
5671
|
if (other && other !== process.pid) return 0;
|
|
5380
5672
|
await writeFile(lockFile, `${process.pid}\n`);
|
|
@@ -5503,7 +5795,7 @@ async function cmdSend(rest) {
|
|
|
5503
5795
|
active: false,
|
|
5504
5796
|
json: false,
|
|
5505
5797
|
latest: argv.latest,
|
|
5506
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
5798
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
5507
5799
|
};
|
|
5508
5800
|
const keyword = argv._[0] !== void 0 ? String(argv._[0]) : void 0;
|
|
5509
5801
|
const rawMessage = argv._.slice(1).map(String).join(" ");
|
|
@@ -5518,12 +5810,13 @@ async function cmdSend(rest) {
|
|
|
5518
5810
|
const trailing = controlCodeFromName(codeName);
|
|
5519
5811
|
const record = await resolveOne(keyword, opts);
|
|
5520
5812
|
if (!/^\d+$/.test(keyword)) process.stderr.write(`ay send → pid ${record.pid} ${record.cli} @ ${shortenPath(record.cwd)}\n`);
|
|
5521
|
-
if (rawMessage !== "-") {
|
|
5813
|
+
if (rawMessage !== "-" && record.mode !== "stream") {
|
|
5522
5814
|
const rawFlag = Boolean(argv.raw) || process.env.AGENT_YES_SEND_RAW === "1";
|
|
5523
5815
|
const err = sendPayloadCapError(rawMessage.length, await envelopeCostFor(rawMessage, rawFlag));
|
|
5524
5816
|
if (err) throw new Error(err);
|
|
5525
5817
|
}
|
|
5526
5818
|
const fifoPath = record.fifo_file;
|
|
5819
|
+
if (!fifoPath && record.mode === "stream") throw new Error("ay send: this native stream invocation has no replay-confirmed input; relaunch with --input-format stream-json --replay-user-messages");
|
|
5527
5820
|
if (!fifoPath) {
|
|
5528
5821
|
process.stderr.write(`ay send: pid ${record.pid}: no fifo_file recorded — this agent didn't register a stdin FIFO (an older agent, or one not started with --stdpush), so there is no channel to deliver on. If it is still running, restarting it (ay restart ${record.pid}) registers one; if the row is stale, ay stop ${record.pid} retires it.\n`);
|
|
5529
5822
|
return SEND_EXIT_UNREACHABLE;
|
|
@@ -5540,13 +5833,13 @@ async function cmdSend(rest) {
|
|
|
5540
5833
|
if (body.trim() === "") throw new Error("ay send: refusing to send an empty message (stdin was empty).");
|
|
5541
5834
|
} else body = rawMessage;
|
|
5542
5835
|
{
|
|
5543
|
-
const err = sendPayloadCapError(body.length, 0);
|
|
5836
|
+
const err = record.mode === "stream" ? null : sendPayloadCapError(body.length, 0);
|
|
5544
5837
|
if (err) throw new Error(err);
|
|
5545
5838
|
}
|
|
5546
5839
|
const force = Boolean(argv.force) || process.env.AGENT_YES_FORCE_SEND === "1";
|
|
5547
5840
|
const raw = Boolean(argv.raw) || process.env.AGENT_YES_SEND_RAW === "1";
|
|
5548
5841
|
const sender = await enforceSendGuards(record, force);
|
|
5549
|
-
if (isExitRequest(body)) {
|
|
5842
|
+
if (record.mode !== "stream" && isExitRequest(body)) {
|
|
5550
5843
|
const reason = sender.agent ? `requested by ${sender.agent.cli} #${sender.agent.pid} @ ${shortenPath(sender.agent.cwd)}` : `requested via 'ay send ${keyword} exit'`;
|
|
5551
5844
|
const { strategy } = await gracefulExitAgent(record, reason);
|
|
5552
5845
|
process.stdout.write(`pid ${record.pid} (${record.cli}): exit requested — sent ${strategy} (${reason})\n`);
|
|
@@ -5556,8 +5849,8 @@ async function cmdSend(rest) {
|
|
|
5556
5849
|
let prefix = "";
|
|
5557
5850
|
let suffix = "";
|
|
5558
5851
|
let nonce;
|
|
5559
|
-
if (sender.agent && !isSlashCommand(body) && !raw) {
|
|
5560
|
-
nonce = randomBytes(4).toString("hex");
|
|
5852
|
+
if (record.mode !== "stream" && sender.agent && !isSlashCommand(body) && !raw) {
|
|
5853
|
+
nonce = randomBytes$1(4).toString("hex");
|
|
5561
5854
|
const identity = formatIdentity({
|
|
5562
5855
|
cwd: sender.agent.cwd,
|
|
5563
5856
|
pid: sender.agent.pid
|
|
@@ -5571,6 +5864,41 @@ async function cmdSend(rest) {
|
|
|
5571
5864
|
}));
|
|
5572
5865
|
if (/^\s*<ay-msg\s/.test(body)) process.stderr.write("warning: body already starts with an <ay-msg …> header — ay send adds the envelope automatically, so the recipient will see a DOUBLE wrapper. Send the bare body instead (or pass --raw if you really mean to deliver a pre-built envelope verbatim; forwarding a quoted message inside a plain body is fine).\n");
|
|
5573
5866
|
}
|
|
5867
|
+
if (record.mode === "stream") {
|
|
5868
|
+
if (codeName !== "enter") throw new Error("ay send: --code is not supported for stream sessions; use --interrupt");
|
|
5869
|
+
if (argv.noWait || process.env.AGENT_YES_SEND_NO_WAIT === "1") throw new Error("ay send: stream sessions require a replay receipt; omit --no-wait");
|
|
5870
|
+
const receipt = await sendStream(record, body, {
|
|
5871
|
+
interrupt: Boolean(argv.interrupt),
|
|
5872
|
+
write: (payload) => withIpcLock(record.pid, () => writeToIpc(fifoPath, payload), (reason) => {
|
|
5873
|
+
throw new Error(`ay send: cannot lock stream input (${reason}); nothing sent`);
|
|
5874
|
+
})
|
|
5875
|
+
});
|
|
5876
|
+
await recordMessage({
|
|
5877
|
+
at: Date.now(),
|
|
5878
|
+
nonce,
|
|
5879
|
+
origin: sender.agent ? void 0 : "shell",
|
|
5880
|
+
from_via: sender.via,
|
|
5881
|
+
sender_observed: observedSender(),
|
|
5882
|
+
from: sender.agent ? {
|
|
5883
|
+
pid: sender.agent.pid,
|
|
5884
|
+
cli: sender.agent.cli,
|
|
5885
|
+
cwd: sender.agent.cwd,
|
|
5886
|
+
agent_id: sender.agent.agent_id
|
|
5887
|
+
} : null,
|
|
5888
|
+
to: {
|
|
5889
|
+
pid: record.pid,
|
|
5890
|
+
cli: record.cli,
|
|
5891
|
+
cwd: record.cwd,
|
|
5892
|
+
agent_id: record.agent_id
|
|
5893
|
+
},
|
|
5894
|
+
body,
|
|
5895
|
+
confirmed: true,
|
|
5896
|
+
submission: "submitted",
|
|
5897
|
+
wrapped: Boolean(nonce)
|
|
5898
|
+
});
|
|
5899
|
+
process.stdout.write(`sent to pid ${record.pid} (${record.cli}); replay receipt ${receipt}\n`);
|
|
5900
|
+
return 0;
|
|
5901
|
+
}
|
|
5574
5902
|
const framePaste$1 = shouldFramePaste({
|
|
5575
5903
|
supported: Boolean((await cliDefaults())[record.cli]?.bracketedPaste),
|
|
5576
5904
|
body,
|
|
@@ -5784,7 +6112,7 @@ async function cmdMsgs(rest) {
|
|
|
5784
6112
|
active: false,
|
|
5785
6113
|
json: false,
|
|
5786
6114
|
latest: argv.latest,
|
|
5787
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
6115
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
5788
6116
|
});
|
|
5789
6117
|
ownerCwd = record.cwd;
|
|
5790
6118
|
ownerAgentId = record.agent_id;
|
|
@@ -5901,7 +6229,7 @@ async function cmdSubmit(rest) {
|
|
|
5901
6229
|
active: false,
|
|
5902
6230
|
json: false,
|
|
5903
6231
|
latest: argv.latest,
|
|
5904
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
6232
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
5905
6233
|
});
|
|
5906
6234
|
const sender = await enforceSendGuards(record, Boolean(argv.force) || process.env.AGENT_YES_FORCE_SEND === "1");
|
|
5907
6235
|
const before = await readComposerState(record);
|
|
@@ -5954,7 +6282,7 @@ async function cmdKey(rest) {
|
|
|
5954
6282
|
active: false,
|
|
5955
6283
|
json: false,
|
|
5956
6284
|
latest: argv.latest,
|
|
5957
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
6285
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
5958
6286
|
});
|
|
5959
6287
|
const sender = await enforceSendGuards(record, Boolean(argv.force) || process.env.AGENT_YES_FORCE_SEND === "1");
|
|
5960
6288
|
await withIpcLock(record.pid, () => writeKeysPaced(record.fifo_file, byteSeqs, Math.max(0, argv.pace)), (why) => process.stderr.write(`warning: ay key/select writing pid ${record.pid} without the input lock (${why})\n`));
|
|
@@ -5999,7 +6327,7 @@ async function cmdSelect(rest) {
|
|
|
5999
6327
|
active: false,
|
|
6000
6328
|
json: false,
|
|
6001
6329
|
latest: argv.latest,
|
|
6002
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
6330
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
6003
6331
|
});
|
|
6004
6332
|
if (!record.log_file) throw new Error(`pid ${record.pid}: no log_file recorded — can't read the menu to select from.`);
|
|
6005
6333
|
const sender = await enforceSendGuards(record, Boolean(argv.force) || process.env.AGENT_YES_FORCE_SEND === "1");
|
|
@@ -6144,7 +6472,7 @@ async function cmdStop(rest) {
|
|
|
6144
6472
|
active: false,
|
|
6145
6473
|
json: false,
|
|
6146
6474
|
latest: argv.latest,
|
|
6147
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
6475
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
6148
6476
|
};
|
|
6149
6477
|
const keyword = argv._[0] !== void 0 ? String(argv._[0]) : void 0;
|
|
6150
6478
|
if (!keyword) throw new Error("usage: ay stop <keyword> [--method=auto|graceful|double-ctrl-c]");
|
|
@@ -6254,7 +6582,7 @@ async function cmdExit(rest) {
|
|
|
6254
6582
|
active: false,
|
|
6255
6583
|
json: false,
|
|
6256
6584
|
latest: argv.latest,
|
|
6257
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
6585
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
6258
6586
|
};
|
|
6259
6587
|
const keyword = argv._[0] !== void 0 ? String(argv._[0]) : void 0;
|
|
6260
6588
|
if (!keyword) throw new Error("usage: ay exit <keyword> [reason]");
|
|
@@ -6297,7 +6625,7 @@ async function cmdAttach(rest) {
|
|
|
6297
6625
|
active: false,
|
|
6298
6626
|
json: false,
|
|
6299
6627
|
latest: argv.latest,
|
|
6300
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
6628
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
6301
6629
|
};
|
|
6302
6630
|
const keyword = argv._[0] !== void 0 ? String(argv._[0]) : void 0;
|
|
6303
6631
|
if (!keyword) throw new Error("usage: ay attach <keyword> [--escape ctrl-\\]");
|
|
@@ -6337,11 +6665,11 @@ async function cmdAttach(rest) {
|
|
|
6337
6665
|
process.stdout.write(replay);
|
|
6338
6666
|
if (!replay.endsWith("\n")) process.stdout.write("\n");
|
|
6339
6667
|
}
|
|
6340
|
-
const ayHome = process.env.AGENT_YES_HOME ?? path.join(homedir(), ".agent-yes");
|
|
6341
|
-
const winsizeDir = path.join(ayHome, "winsize");
|
|
6668
|
+
const ayHome = process.env.AGENT_YES_HOME ?? path$1.join(homedir(), ".agent-yes");
|
|
6669
|
+
const winsizeDir = path$1.join(ayHome, "winsize");
|
|
6342
6670
|
await mkdir(winsizeDir, { recursive: true });
|
|
6343
|
-
const winsizePath = path.join(winsizeDir, String(record.pid));
|
|
6344
|
-
const { resolveDaemonHttpBase, loadTokenReadOnly } = await import("./serve-
|
|
6671
|
+
const winsizePath = path$1.join(winsizeDir, String(record.pid));
|
|
6672
|
+
const { resolveDaemonHttpBase, loadTokenReadOnly } = await import("./serve-BJEDb5Az.js");
|
|
6345
6673
|
const daemonBase = await resolveDaemonHttpBase().catch(() => null);
|
|
6346
6674
|
const daemonToken = daemonBase ? await loadTokenReadOnly().catch(() => null) ?? "" : "";
|
|
6347
6675
|
const capViewer = `attach:${process.pid}`;
|
|
@@ -6615,7 +6943,7 @@ async function cmdRestart(rest) {
|
|
|
6615
6943
|
active: false,
|
|
6616
6944
|
json: false,
|
|
6617
6945
|
latest: argv.latest,
|
|
6618
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
6946
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
6619
6947
|
};
|
|
6620
6948
|
const record = await resolveOne(argv._[0] !== void 0 ? String(argv._[0]) : void 0, opts);
|
|
6621
6949
|
const fresh = Boolean(argv.fresh);
|
|
@@ -6691,24 +7019,27 @@ async function cmdNote(rest) {
|
|
|
6691
7019
|
async function snapshotStatus(record) {
|
|
6692
7020
|
const alive = record.status !== "exited" && isPidAlive(record.pid);
|
|
6693
7021
|
let state;
|
|
7022
|
+
let question = null;
|
|
6694
7023
|
let logMtimeMs = null;
|
|
6695
7024
|
if (!alive) state = "stopped";
|
|
6696
|
-
else if (record.
|
|
7025
|
+
else if (record.mode === "stream") {
|
|
7026
|
+
({state, question} = await deriveLiveState(record));
|
|
7027
|
+
logMtimeMs = await stat(eventFile(record)).then((info) => info.mtimeMs).catch(() => null);
|
|
7028
|
+
} else if (record.log_file) {
|
|
6697
7029
|
logMtimeMs = await stat(record.log_file).then((s) => s.mtimeMs).catch(() => null);
|
|
6698
7030
|
state = logMtimeMs !== null && Date.now() - logMtimeMs > IDLE_THRESHOLD_MS ? "idle" : "active";
|
|
6699
7031
|
} else state = "active";
|
|
6700
7032
|
const baseState = state === "idle" ? "idle" : "active";
|
|
6701
|
-
const activity = state !== "stopped" && record.log_file ? await extractActivity(record.log_file) : null;
|
|
6702
|
-
|
|
6703
|
-
if (state !== "stopped" && record.log_file) {
|
|
7033
|
+
const activity = state !== "stopped" && record.mode !== "stream" && record.log_file ? await extractActivity(record.log_file) : null;
|
|
7034
|
+
if (record.mode !== "stream" && state !== "stopped" && record.log_file) {
|
|
6704
7035
|
const ni = await extractNeedsInput(record.log_file, record.cli);
|
|
6705
7036
|
if (ni) {
|
|
6706
7037
|
state = "needs_input";
|
|
6707
7038
|
question = ni.question;
|
|
6708
7039
|
} else if (state === "idle" && await isAgentStuck(record, logMtimeMs)) state = "stuck";
|
|
6709
7040
|
}
|
|
6710
|
-
if (alive && record.unresponsive) state = "stuck";
|
|
6711
|
-
if (alive && reachabilityProbeApplies(record, baseState) && await confirmStdinUnreachable(record)) {
|
|
7041
|
+
if (alive && record.mode !== "stream" && record.unresponsive) state = "stuck";
|
|
7042
|
+
if (alive && record.mode !== "stream" && reachabilityProbeApplies(record, baseState) && await confirmStdinUnreachable(record)) {
|
|
6712
7043
|
state = "unreachable";
|
|
6713
7044
|
question = null;
|
|
6714
7045
|
}
|
|
@@ -6765,7 +7096,7 @@ async function cmdStatus(rest) {
|
|
|
6765
7096
|
active: false,
|
|
6766
7097
|
json: false,
|
|
6767
7098
|
latest: argv.latest,
|
|
6768
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
7099
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
6769
7100
|
};
|
|
6770
7101
|
const keyword = argv._[0] !== void 0 ? String(argv._[0]) : void 0;
|
|
6771
7102
|
if (!keyword) throw new Error("usage: ay status <keyword> [--watch | --wait | --wait-idle] [--timeout=Ns] [--cwd=DIR] [--latest]");
|
|
@@ -6908,7 +7239,7 @@ async function cmdResult(rest) {
|
|
|
6908
7239
|
active: false,
|
|
6909
7240
|
json: false,
|
|
6910
7241
|
latest: argv.latest,
|
|
6911
|
-
cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
|
|
7242
|
+
cwdScope: typeof argv.cwd === "string" ? path$1.resolve(argv.cwd) : null
|
|
6912
7243
|
});
|
|
6913
7244
|
const intervalMs = Math.max(500, (Number.isFinite(argv.interval) ? argv.interval : 2) * 1e3);
|
|
6914
7245
|
const timeoutMs = typeof argv.timeout === "string" && argv.timeout.length > 0 ? ms(argv.timeout) ?? NaN : null;
|
|
@@ -7090,7 +7421,7 @@ async function cmdNotify(rest) {
|
|
|
7090
7421
|
}
|
|
7091
7422
|
const ensure = async () => {
|
|
7092
7423
|
if (!argv["ensure-daemon"]) return;
|
|
7093
|
-
const { ensureDaemon } = await import("./notifyDaemon-
|
|
7424
|
+
const { ensureDaemon } = await import("./notifyDaemon-Dh4cLfBU.js");
|
|
7094
7425
|
await ensureDaemon().catch(() => null);
|
|
7095
7426
|
};
|
|
7096
7427
|
await heartbeatWatcher(parent, selfStartedAt);
|
|
@@ -7164,7 +7495,7 @@ async function cmdNotifyCursor(args) {
|
|
|
7164
7495
|
}
|
|
7165
7496
|
async function cmdNotifyd(rest) {
|
|
7166
7497
|
const sub = rest[0] ?? "status";
|
|
7167
|
-
const daemon = await import("./notifyDaemon-
|
|
7498
|
+
const daemon = await import("./notifyDaemon-Dh4cLfBU.js");
|
|
7168
7499
|
switch (sub) {
|
|
7169
7500
|
case "run": return daemon.runDaemon();
|
|
7170
7501
|
case "once": return daemon.runDaemon({ once: true });
|
|
@@ -7191,4 +7522,4 @@ async function cmdNotifyd(rest) {
|
|
|
7191
7522
|
|
|
7192
7523
|
//#endregion
|
|
7193
7524
|
export { readNotes as $, inspectSubmission as A, isUnknownManagerToken as B, envelopeAttribution as C, withIpcLock as Ct, extractNeedsInput as D, buildAgentForest as Dt, extractMenu as E, TYPING_BADGE as Et, isExitRequest as F, listRecords as G, isUserTyping as H, isPidAlive as I, ownedCollapsedPaste as J, matchKeyword as K, isSlashCommand as L, isAgentIdShaped as M, isAgentStuck as N, extractTaskCounts as O, flattenForest as Ot, isBareManagerInvocation as P, readLogForRender as Q, isSubcommand as R, enableRenderDiskCache as S, resolveWorkDir as St, extractBadges as T, shouldFramePaste as Tt, lastReadAt as U, isUnreachableWriteErrno as V, lastStdinAt as W, readAgentPtysize as X, probeStdinReachable as Y, readComposerState as Z, cursorAbs as _, submitStableDraft as _t, READ_PAGE_DEFAULT as a, renderRawLogLines as at, deriveLiveStatus as b, writeKeysPaced as bt, SEND_EXIT_QUEUED as c, resolveResumeArgs as ct, backoffWhileTyping as d, saveRenderDisk as dt, readPtysize as et, buildEnvelope as f, sendPayloadCapError as ft, controlCodeFromName as g, submitAndConfirm as gt, confirmStdinUnreachable as h, stopTipForCli as ht, MAX_RENDER_BYTES as i, renderRawLog as it, interruptSendTarget as j, finalizedLines as k, SEND_EXIT_UNREACHABLE as l, restartHintLines as lt, cmdHelp as m, stdinActivityPath as mt, DRAFT_STABLE_WAITS_MS as n, recentReadEdges as nt, READ_WINDOW_MS as o, resolveOne as ot, cliDefaults as p, snapshotStatus as pt, menuSelectKeys as q, GRACEFUL_EXIT_COMMANDS as r, renderLogTailLines as rt, SEND_BODY_MAX_CHARS as s, resolveReadWindow as st, COMPOSER_WINDOWS as t, recentMessageEdges as tt, TYPING_WINDOW_MS as u, runSubcommand as ut, cwdLabel as v, suggestAgents as vt, envelopeCostFor as w, framePaste as wt, drainerLauncher as x, writeToIpc as xt, deriveLiveState as y, waitForLogQuiet as yt, isSubmitCode as z };
|
|
7194
|
-
//# sourceMappingURL=subcommands-
|
|
7525
|
+
//# sourceMappingURL=subcommands-BJezWaHi.js.map
|