agent-yes 1.237.0 → 1.238.0-beta.570.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{SUPPORTED_CLIS-C0RwjYrz.js → SUPPORTED_CLIS-BNmF8R13.js} +3 -3
- package/dist/{SUPPORTED_CLIS-CDrJz9Xo.js → SUPPORTED_CLIS-CL_aDyc-.js} +2 -2
- package/dist/{agentShare-Cl_J3dfx.js → agentShare-DpmG7r_b.js} +2 -2
- package/dist/{callback-D0_AeyN1.js → callback-Bj7Mef_Y.js} +3 -3
- package/dist/{callback-CFbkvqTh.js → callback-DBNd0LVA.js} +2 -2
- package/dist/cli.js +4 -4
- package/dist/index.js +2 -2
- package/dist/{notifyDaemon-D_8TRVHt.js → notifyDaemon-CGgMpWK3.js} +2 -2
- package/dist/{rustBinary-Bb9qJZ5w.js → rustBinary-CwBgqXIl.js} +2 -2
- package/dist/{schedule-B8Erb3y6.js → schedule-4kGSyhxx.js} +4 -4
- package/dist/{serve-QejbNTr-.js → serve-nBi1Qrz7.js} +234 -37
- package/dist/{setup-Dzi5Cc3g.js → setup-C-FQZTeR.js} +2 -2
- package/dist/{subcommands-ymJWO2iv.js → subcommands-CU0jP5lx.js} +1 -1
- package/dist/{subcommands-DFr-5FOL.js → subcommands-DHVf6p7P.js} +20 -10
- package/dist/{terminal-vNeFNLT8.js → terminal-DdYFqm3s.js} +2 -2
- package/dist/{ts-Dd1FK7sR.js → ts-CV60LDBN.js} +2 -2
- package/dist/{versionChecker-XfEBINhH.js → versionChecker-DtCBEDW3.js} +2 -2
- package/dist/widget-igzAbsEd.js +172 -0
- package/dist/widget.js +162 -0
- package/dist/widgets.js +2 -1
- package/dist/{ws-Dun8gGiV.js → ws-Bue4UzPC.js} +2 -2
- package/package.json +7 -3
- package/ts/serve.ts +254 -19
- package/ts/subcommands.ts +12 -0
- package/ts/termToken.spec.ts +25 -3
- package/ts/termToken.ts +35 -8
- package/ts/widget.ts +207 -0
- package/ts/widgets.ts +2 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "./logger-CDIsZ-Pp.js";
|
|
2
|
-
import "./versionChecker-
|
|
3
|
-
import "./ts-
|
|
2
|
+
import "./versionChecker-DtCBEDW3.js";
|
|
3
|
+
import "./ts-CV60LDBN.js";
|
|
4
4
|
import "./todoAutomation-Buo457VO.js";
|
|
5
5
|
import "./JsonlStore-CPGIR0Wy.js";
|
|
6
6
|
import "./globalPidIndex-D9DOSd-c.js";
|
|
7
7
|
import "./pidStore-6EZd5DUv.js";
|
|
8
8
|
import "./messageLog-C-YIzhRj.js";
|
|
9
|
-
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-
|
|
9
|
+
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-CL_aDyc-.js";
|
|
10
10
|
|
|
11
11
|
export { SUPPORTED_CLIS };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as CLIS_CONFIG } from "./ts-
|
|
1
|
+
import { t as CLIS_CONFIG } from "./ts-CV60LDBN.js";
|
|
2
2
|
|
|
3
3
|
//#region ts/SUPPORTED_CLIS.ts
|
|
4
4
|
const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
|
|
5
5
|
|
|
6
6
|
//#endregion
|
|
7
7
|
export { SUPPORTED_CLIS as t };
|
|
8
|
-
//# sourceMappingURL=SUPPORTED_CLIS-
|
|
8
|
+
//# sourceMappingURL=SUPPORTED_CLIS-CL_aDyc-.js.map
|
|
@@ -3,7 +3,7 @@ import "./globalPidIndex-D9DOSd-c.js";
|
|
|
3
3
|
import "./messageLog-C-YIzhRj.js";
|
|
4
4
|
import "./e2e-CEIdJGZ7.js";
|
|
5
5
|
import "./configShared-9wVlbPyC.js";
|
|
6
|
-
import { N as resolveOne } from "./subcommands-
|
|
6
|
+
import { N as resolveOne } from "./subcommands-DHVf6p7P.js";
|
|
7
7
|
import "./webrtcLink-VQhWmKOw.js";
|
|
8
8
|
import "./remotes-Bem6WIyU.js";
|
|
9
9
|
import { a as startShare } from "./share-B9u8-I3y.js";
|
|
@@ -229,4 +229,4 @@ function transformEvent(rawEvent, agentId, forwarded) {
|
|
|
229
229
|
|
|
230
230
|
//#endregion
|
|
231
231
|
export { createScopedShare, listShares, revokeAllShares, revokeShare };
|
|
232
|
-
//# sourceMappingURL=agentShare-
|
|
232
|
+
//# sourceMappingURL=agentShare-DpmG7r_b.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as agentYesHome } from "./agentYesHome-CtmsY6I-.js";
|
|
2
|
-
import { N as resolveOne } from "./subcommands-
|
|
2
|
+
import { N as resolveOne } from "./subcommands-DHVf6p7P.js";
|
|
3
3
|
import { a as mintCapability, o as parseExpires } from "./callbackCore-DAYcemCC.js";
|
|
4
4
|
import { randomBytes } from "node:crypto";
|
|
5
5
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
@@ -72,7 +72,7 @@ async function resolveBase(flag) {
|
|
|
72
72
|
if (flag) return flag;
|
|
73
73
|
if (process.env.AGENT_YES_CALLBACK_BASE) return process.env.AGENT_YES_CALLBACK_BASE;
|
|
74
74
|
try {
|
|
75
|
-
const { resolveLocalServeUrl } = await import("./serve-
|
|
75
|
+
const { resolveLocalServeUrl } = await import("./serve-nBi1Qrz7.js");
|
|
76
76
|
const url = await resolveLocalServeUrl();
|
|
77
77
|
if (url) return url;
|
|
78
78
|
} catch {}
|
|
@@ -187,4 +187,4 @@ async function cmdCallback(rest) {
|
|
|
187
187
|
|
|
188
188
|
//#endregion
|
|
189
189
|
export { loadOrCreateCallbackSecret as i, isCallbackRevoked as n, loadCallbackSecretReadOnly as r, cmdCallback as t };
|
|
190
|
-
//# sourceMappingURL=callback-
|
|
190
|
+
//# sourceMappingURL=callback-Bj7Mef_Y.js.map
|
|
@@ -3,10 +3,10 @@ import "./globalPidIndex-D9DOSd-c.js";
|
|
|
3
3
|
import "./messageLog-C-YIzhRj.js";
|
|
4
4
|
import "./e2e-CEIdJGZ7.js";
|
|
5
5
|
import "./configShared-9wVlbPyC.js";
|
|
6
|
-
import "./subcommands-
|
|
6
|
+
import "./subcommands-DHVf6p7P.js";
|
|
7
7
|
import "./webrtcLink-VQhWmKOw.js";
|
|
8
8
|
import "./remotes-Bem6WIyU.js";
|
|
9
9
|
import "./callbackCore-DAYcemCC.js";
|
|
10
|
-
import { i as loadOrCreateCallbackSecret, n as isCallbackRevoked, r as loadCallbackSecretReadOnly, t as cmdCallback } from "./callback-
|
|
10
|
+
import { i as loadOrCreateCallbackSecret, n as isCallbackRevoked, r as loadCallbackSecretReadOnly, t as cmdCallback } from "./callback-Bj7Mef_Y.js";
|
|
11
11
|
|
|
12
12
|
export { cmdCallback };
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { t as invokedCliName } from "./invokedCli-uqM2YYA7.js";
|
|
3
3
|
import { n as logger } from "./logger-CDIsZ-Pp.js";
|
|
4
|
-
import { i as versionString, n as displayVersion, t as checkAndAutoUpdate } from "./versionChecker-
|
|
5
|
-
import { n as getRustBinary } from "./rustBinary-
|
|
4
|
+
import { i as versionString, n as displayVersion, t as checkAndAutoUpdate } from "./versionChecker-DtCBEDW3.js";
|
|
5
|
+
import { n as getRustBinary } from "./rustBinary-CwBgqXIl.js";
|
|
6
6
|
import { argv } from "process";
|
|
7
7
|
import { spawn } from "child_process";
|
|
8
8
|
import ms from "ms";
|
|
@@ -285,7 +285,7 @@ function buildRustArgs(argv, cliFromScript, supportedClis) {
|
|
|
285
285
|
const rawArg = process.argv[2];
|
|
286
286
|
const managerCommands = !invokedCliName(process.argv);
|
|
287
287
|
const isHelpFlag = rawArg === "-h" || rawArg === "--help";
|
|
288
|
-
const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-
|
|
288
|
+
const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-CU0jP5lx.js");
|
|
289
289
|
if (isHelpFlag && process.argv.length === 3) {
|
|
290
290
|
await cmdHelp(managerCommands);
|
|
291
291
|
process.exit(0);
|
|
@@ -339,7 +339,7 @@ if (config.useRust) {
|
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
if (rustBinary) {
|
|
342
|
-
const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-
|
|
342
|
+
const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-BNmF8R13.js");
|
|
343
343
|
const rustArgs = buildRustArgs(process.argv, config.cli, SUPPORTED_CLIS);
|
|
344
344
|
if (config.verbose) {
|
|
345
345
|
console.log(`[rust] Using binary: ${rustBinary}`);
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./logger-CDIsZ-Pp.js";
|
|
2
|
-
import "./versionChecker-
|
|
3
|
-
import { a as hasTodoStore, c as AgentContext, i as answerAsk, n as agentYes, o as listAsks, r as config, s as listAsksForProject, t as CLIS_CONFIG } from "./ts-
|
|
2
|
+
import "./versionChecker-DtCBEDW3.js";
|
|
3
|
+
import { a as hasTodoStore, c as AgentContext, i as answerAsk, n as agentYes, o as listAsks, r as config, s as listAsksForProject, t as CLIS_CONFIG } from "./ts-CV60LDBN.js";
|
|
4
4
|
import { _ as isKnownKind, a as renderTree, b as statesOf, c as monitorHint, d as openStore, f as DONE_STATE, g as initialState, h as canTransition, i as renderDigest, l as CycleError, m as ORPHANED_STATE, o as unblockedTasks, p as LIFECYCLES, r as openBlockers, s as describeBlock, t as reconcileTodos, u as TodoStore, v as nextStates, x as removeControlCharacters, y as requiredGate } from "./todoAutomation-Buo457VO.js";
|
|
5
5
|
import "./JsonlStore-CPGIR0Wy.js";
|
|
6
6
|
import "./globalPidIndex-D9DOSd-c.js";
|
|
@@ -3,7 +3,7 @@ import "./globalPidIndex-D9DOSd-c.js";
|
|
|
3
3
|
import "./messageLog-C-YIzhRj.js";
|
|
4
4
|
import "./e2e-CEIdJGZ7.js";
|
|
5
5
|
import "./configShared-9wVlbPyC.js";
|
|
6
|
-
import { $ as daemonLockDir, A as renderLogTailLines, G as appendEvent, K as gcInboxes, Q as shouldStealLock, S as listRecords, X as liveWatchers, Y as listInboxParents, Z as readInbox, _ as isPidAlive, c as deriveLiveState, et as daemonLockOwnerPath, q as hostId, tt as notifyDir } from "./subcommands-
|
|
6
|
+
import { $ as daemonLockDir, A as renderLogTailLines, G as appendEvent, K as gcInboxes, Q as shouldStealLock, S as listRecords, X as liveWatchers, Y as listInboxParents, Z as readInbox, _ as isPidAlive, c as deriveLiveState, et as daemonLockOwnerPath, q as hostId, tt as notifyDir } from "./subcommands-DHVf6p7P.js";
|
|
7
7
|
import "./webrtcLink-VQhWmKOw.js";
|
|
8
8
|
import "./remotes-Bem6WIyU.js";
|
|
9
9
|
import { mkdir, readFile, rename, rm, stat, writeFile } from "fs/promises";
|
|
@@ -589,4 +589,4 @@ async function ensureDaemon() {
|
|
|
589
589
|
|
|
590
590
|
//#endregion
|
|
591
591
|
export { daemonStatus, ensureDaemon, requestDaemonStop, runDaemon };
|
|
592
|
-
//# sourceMappingURL=notifyDaemon-
|
|
592
|
+
//# sourceMappingURL=notifyDaemon-CGgMpWK3.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as getInstalledPackage } from "./versionChecker-
|
|
1
|
+
import { r as getInstalledPackage } from "./versionChecker-DtCBEDW3.js";
|
|
2
2
|
import { execFileSync } from "child_process";
|
|
3
3
|
import { existsSync, mkdirSync, unlinkSync } from "fs";
|
|
4
4
|
import { chmod, copyFile } from "fs/promises";
|
|
@@ -225,4 +225,4 @@ async function getRustBinary(options = {}) {
|
|
|
225
225
|
|
|
226
226
|
//#endregion
|
|
227
227
|
export { getRustBinary as n, findSpawnHiddenLauncher as t };
|
|
228
|
-
//# sourceMappingURL=rustBinary-
|
|
228
|
+
//# sourceMappingURL=rustBinary-CwBgqXIl.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "./logger-CDIsZ-Pp.js";
|
|
2
|
-
import "./versionChecker-
|
|
3
|
-
import "./ts-
|
|
2
|
+
import "./versionChecker-DtCBEDW3.js";
|
|
3
|
+
import "./ts-CV60LDBN.js";
|
|
4
4
|
import "./todoAutomation-Buo457VO.js";
|
|
5
5
|
import "./JsonlStore-CPGIR0Wy.js";
|
|
6
6
|
import "./globalPidIndex-D9DOSd-c.js";
|
|
7
7
|
import "./pidStore-6EZd5DUv.js";
|
|
8
8
|
import "./messageLog-C-YIzhRj.js";
|
|
9
|
-
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-
|
|
9
|
+
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-CL_aDyc-.js";
|
|
10
10
|
import { d as resolveSpawnCwd } from "./workspaceConfig-B7HaQ-MI.js";
|
|
11
11
|
import { n as liveEnv, t as ensureNodeRuntime } from "./nodeRuntime-Bf88NPqj.js";
|
|
12
12
|
import { createHash } from "node:crypto";
|
|
@@ -153,4 +153,4 @@ async function cmdSchedule(rest) {
|
|
|
153
153
|
|
|
154
154
|
//#endregion
|
|
155
155
|
export { cmdSchedule };
|
|
156
|
-
//# sourceMappingURL=schedule-
|
|
156
|
+
//# sourceMappingURL=schedule-4kGSyhxx.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./logger-CDIsZ-Pp.js";
|
|
2
|
-
import { r as getInstalledPackage } from "./versionChecker-
|
|
3
|
-
import { t as findSpawnHiddenLauncher } from "./rustBinary-
|
|
4
|
-
import { i as answerAsk, l as CLAUDE_SESSION_PIN_ENV, o as listAsks } from "./ts-
|
|
2
|
+
import { r as getInstalledPackage } from "./versionChecker-DtCBEDW3.js";
|
|
3
|
+
import { t as findSpawnHiddenLauncher } from "./rustBinary-CwBgqXIl.js";
|
|
4
|
+
import { i as answerAsk, l as CLAUDE_SESSION_PIN_ENV, o as listAsks } from "./ts-CV60LDBN.js";
|
|
5
5
|
import { t as agentYesHome$1 } from "./agentYesHome-CtmsY6I-.js";
|
|
6
6
|
import { x as removeControlCharacters } from "./todoAutomation-Buo457VO.js";
|
|
7
7
|
import "./JsonlStore-CPGIR0Wy.js";
|
|
@@ -11,12 +11,12 @@ import { r as recordInbox } from "./messageLog-C-YIzhRj.js";
|
|
|
11
11
|
import { t as pgidForWrapper } from "./reaper-DP49VCKx.js";
|
|
12
12
|
import "./e2e-CEIdJGZ7.js";
|
|
13
13
|
import "./configShared-9wVlbPyC.js";
|
|
14
|
-
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-
|
|
15
|
-
import { A as renderLogTailLines, D as readPtysize, E as readNotes, J as isTransientLockMkdirError, M as renderRawLogLines, N as resolveOne, O as recentMessageEdges, R as snapshotStatus, S as listRecords, W as writeToIpc, b as isUserTyping, f as extractNeedsInput, j as renderRawLog, k as recentReadEdges, l as deriveLiveStatus, nt as TYPING_BADGE, o as controlCodeFromName, p as extractTaskCounts, u as extractBadges } from "./subcommands-
|
|
14
|
+
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-CL_aDyc-.js";
|
|
15
|
+
import { A as renderLogTailLines, D as readPtysize, E as readNotes, J as isTransientLockMkdirError, M as renderRawLogLines, N as resolveOne, O as recentMessageEdges, R as snapshotStatus, S as listRecords, W as writeToIpc, b as isUserTyping, f as extractNeedsInput, j as renderRawLog, k as recentReadEdges, l as deriveLiveStatus, nt as TYPING_BADGE, o as controlCodeFromName, p as extractTaskCounts, u as extractBadges } from "./subcommands-DHVf6p7P.js";
|
|
16
16
|
import "./webrtcLink-VQhWmKOw.js";
|
|
17
17
|
import "./remotes-Bem6WIyU.js";
|
|
18
18
|
import { i as frameVisitorMessage, s as verifyCapability, t as MAX_CALLBACK_MSG_BYTES } from "./callbackCore-DAYcemCC.js";
|
|
19
|
-
import { n as isCallbackRevoked, r as loadCallbackSecretReadOnly } from "./callback-
|
|
19
|
+
import { n as isCallbackRevoked, r as loadCallbackSecretReadOnly } from "./callback-Bj7Mef_Y.js";
|
|
20
20
|
import { a as getSpawnHook, c as hasProvisionHook, d as resolveSpawnCwd, i as getProvisionRoot, l as hasSpawnHook, r as getProvisionHook, u as isProvisionAllowed } from "./workspaceConfig-B7HaQ-MI.js";
|
|
21
21
|
import { n as liveEnv, t as ensureNodeRuntime } from "./nodeRuntime-Bf88NPqj.js";
|
|
22
22
|
import { r as spawnRejectionReason } from "./spawnGate-Bo_LFgt9.js";
|
|
@@ -31,6 +31,17 @@ import { createHash, createHmac, randomBytes, timingSafeEqual } from "crypto";
|
|
|
31
31
|
|
|
32
32
|
//#region ts/termToken.ts
|
|
33
33
|
const PREFIX = "ayt1";
|
|
34
|
+
const CAPS_READONLY = ["tail", "size"];
|
|
35
|
+
const CAPS_INTERACTIVE = [
|
|
36
|
+
"tail",
|
|
37
|
+
"size",
|
|
38
|
+
"send",
|
|
39
|
+
"resize"
|
|
40
|
+
];
|
|
41
|
+
/** Derive caps for a legacy `{w}` token (pre-caps format): w=1 ⇒ interactive. */
|
|
42
|
+
function legacyCaps(w) {
|
|
43
|
+
return w === 1 ? [...CAPS_INTERACTIVE] : [...CAPS_READONLY];
|
|
44
|
+
}
|
|
34
45
|
/** Dedicated HMAC key derived from the master token (so the token isn't signed with the raw master). */
|
|
35
46
|
function keyFor(masterToken) {
|
|
36
47
|
return createHash("sha256").update("ay/term/token/v1\n" + masterToken).digest();
|
|
@@ -39,11 +50,17 @@ function keyFor(masterToken) {
|
|
|
39
50
|
function isTermToken(tok) {
|
|
40
51
|
return typeof tok === "string" && tok.startsWith(PREFIX + ".");
|
|
41
52
|
}
|
|
42
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Mint a scoped token bound to `scope.pid` (the subject), signed with the master
|
|
55
|
+
* token. `caps` is authoritative; if omitted it derives from `canSend` (terminal
|
|
56
|
+
* back-compat). Emits the caps-format payload `{s, c, x}` (verified alongside the
|
|
57
|
+
* legacy `{p, w, x}`).
|
|
58
|
+
*/
|
|
43
59
|
function mintTermToken(masterToken, scope) {
|
|
60
|
+
const caps = scope.caps ?? (scope.canSend ? [...CAPS_INTERACTIVE] : [...CAPS_READONLY]);
|
|
44
61
|
const body = `${PREFIX}.${Buffer.from(JSON.stringify({
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
s: scope.pid,
|
|
63
|
+
c: caps,
|
|
47
64
|
x: Math.floor(scope.exp)
|
|
48
65
|
})).toString("base64url")}`;
|
|
49
66
|
return `${body}.${createHmac("sha256", keyFor(masterToken)).update(body).digest().toString("base64url")}`;
|
|
@@ -72,11 +89,14 @@ function verifyTermToken(masterToken, tok, nowSec = Math.floor(Date.now() / 1e3)
|
|
|
72
89
|
} catch {
|
|
73
90
|
return null;
|
|
74
91
|
}
|
|
75
|
-
|
|
92
|
+
const sub = typeof obj.s === "string" && obj.s ? obj.s : obj.p;
|
|
93
|
+
if (typeof sub !== "string" || !sub) return null;
|
|
76
94
|
if (typeof obj.x !== "number" || !Number.isFinite(obj.x) || obj.x <= nowSec) return null;
|
|
95
|
+
const caps = Array.isArray(obj.c) ? obj.c.filter((x) => typeof x === "string") : legacyCaps(obj.w);
|
|
77
96
|
return {
|
|
78
|
-
pid:
|
|
79
|
-
canSend:
|
|
97
|
+
pid: sub,
|
|
98
|
+
canSend: caps.includes("send"),
|
|
99
|
+
caps,
|
|
80
100
|
exp: obj.x
|
|
81
101
|
};
|
|
82
102
|
}
|
|
@@ -473,7 +493,7 @@ function authorizeRequest(req, expectedToken) {
|
|
|
473
493
|
return null;
|
|
474
494
|
}
|
|
475
495
|
function isTermCorsPath(p) {
|
|
476
|
-
return /^\/api\/(tail|size)\/.+$/.test(p) || p === "/api/send";
|
|
496
|
+
return /^\/api\/(tail|size)\/.+$/.test(p) || p === "/api/send" || /^\/api\/resize\/.+$/.test(p) || p.startsWith("/api/widget/");
|
|
477
497
|
}
|
|
478
498
|
function withTermCors(req, res) {
|
|
479
499
|
if (!res) return res;
|
|
@@ -511,17 +531,13 @@ async function scopedKeywordOk(keyword, scope) {
|
|
|
511
531
|
*/
|
|
512
532
|
async function scopedGate(scope, method, p) {
|
|
513
533
|
const forbid = (m) => new Response(m, { status: 403 });
|
|
534
|
+
const needs = (cap) => scope.caps.includes(cap) ? null : forbid(`scoped token lacks '${cap}'`);
|
|
514
535
|
const m = /^\/api\/(?:tail|size)\/(.+)$/.exec(p);
|
|
515
|
-
if (method === "GET" && m) return await scopedKeywordOk(decodeURIComponent(m[1]), scope) ? null : forbid("scoped token: not bound to this agent");
|
|
516
|
-
if (method === "POST" && p === "/api/send")
|
|
517
|
-
if (!scope.canSend) return forbid("scoped token is read-only");
|
|
518
|
-
return null;
|
|
519
|
-
}
|
|
536
|
+
if (method === "GET" && m) return needs("tail") ?? (await scopedKeywordOk(decodeURIComponent(m[1]), scope) ? null : forbid("scoped token: not bound to this agent"));
|
|
537
|
+
if (method === "POST" && p === "/api/send") return needs("send");
|
|
520
538
|
const rz = /^\/api\/resize\/(.+)$/.exec(p);
|
|
521
|
-
if (method === "POST" && rz)
|
|
522
|
-
|
|
523
|
-
return await scopedKeywordOk(decodeURIComponent(rz[1]), scope) ? null : forbid("scoped token: not bound to this agent");
|
|
524
|
-
}
|
|
539
|
+
if (method === "POST" && rz) return needs("resize") ?? (await scopedKeywordOk(decodeURIComponent(rz[1]), scope) ? null : forbid("scoped token: not bound to this agent"));
|
|
540
|
+
if (p.startsWith("/api/widget/")) return needs("read");
|
|
525
541
|
return forbid("scoped token: route not permitted");
|
|
526
542
|
}
|
|
527
543
|
/**
|
|
@@ -529,23 +545,57 @@ async function scopedGate(scope, method, p) {
|
|
|
529
545
|
* master token file, resolve the keyword to a concrete pid, and sign. Used by
|
|
530
546
|
* `ay term mint`. Throws if there's no serve token or the agent can't be resolved.
|
|
531
547
|
*/
|
|
532
|
-
|
|
548
|
+
const TERMINAL_CAPS = new Set([
|
|
549
|
+
"tail",
|
|
550
|
+
"size",
|
|
551
|
+
"send",
|
|
552
|
+
"resize"
|
|
553
|
+
]);
|
|
554
|
+
async function mintScopedTermToken(target, opts) {
|
|
533
555
|
const master = await loadTokenReadOnly();
|
|
534
556
|
if (!master) throw new Error("no serve token at ~/.agent-yes/.serve-token — run `ay serve` once on this host to create it");
|
|
535
|
-
const
|
|
536
|
-
|
|
557
|
+
const caps = opts.caps ?? (opts.canSend ? [
|
|
558
|
+
"tail",
|
|
559
|
+
"size",
|
|
560
|
+
"send",
|
|
561
|
+
"resize"
|
|
562
|
+
] : ["tail", "size"]);
|
|
563
|
+
let sub = target;
|
|
564
|
+
if (target !== "*" && caps.some((c) => TERMINAL_CAPS.has(c))) {
|
|
565
|
+
const rec = await resolveOne(target, defaultOpts({ all: true }));
|
|
566
|
+
sub = String(rec.pid);
|
|
567
|
+
}
|
|
537
568
|
const exp = Math.floor(Date.now() / 1e3) + Math.max(1, Math.floor(opts.ttlSec));
|
|
538
569
|
return {
|
|
539
570
|
token: mintTermToken(master, {
|
|
540
|
-
pid,
|
|
541
|
-
|
|
571
|
+
pid: sub,
|
|
572
|
+
caps,
|
|
542
573
|
exp
|
|
543
574
|
}),
|
|
544
|
-
|
|
575
|
+
sub,
|
|
576
|
+
pid: sub,
|
|
545
577
|
exp,
|
|
546
|
-
|
|
578
|
+
caps
|
|
547
579
|
};
|
|
548
580
|
}
|
|
581
|
+
const widgetViewers = /* @__PURE__ */ new Map();
|
|
582
|
+
const widgetPushers = /* @__PURE__ */ new Map();
|
|
583
|
+
const widgetWaiters = /* @__PURE__ */ new Map();
|
|
584
|
+
let widgetCmdSeq = 0;
|
|
585
|
+
const WIDGET_TTL_MS = 3e4;
|
|
586
|
+
function widgetNewId() {
|
|
587
|
+
return "v_" + randomBytes(4).toString("hex");
|
|
588
|
+
}
|
|
589
|
+
function widgetLive() {
|
|
590
|
+
const now = Date.now();
|
|
591
|
+
for (const [id, v] of widgetViewers) if (now - v.lastSeen >= WIDGET_TTL_MS) widgetViewers.delete(id);
|
|
592
|
+
return [...widgetViewers.values()];
|
|
593
|
+
}
|
|
594
|
+
/** Resolve a `<viewer>` selector: exact id, then id-prefix / url / title substring. */
|
|
595
|
+
function widgetResolve(sel) {
|
|
596
|
+
if (widgetViewers.has(sel) && Date.now() - widgetViewers.get(sel).lastSeen < WIDGET_TTL_MS) return sel;
|
|
597
|
+
return widgetLive().find((v) => v.id.startsWith(sel) || v.url.includes(sel) || v.title.includes(sel))?.id ?? null;
|
|
598
|
+
}
|
|
549
599
|
const defaultOpts = (overrides = {}) => ({
|
|
550
600
|
all: false,
|
|
551
601
|
active: false,
|
|
@@ -971,6 +1021,23 @@ async function resolveLocalServeUrl() {
|
|
|
971
1021
|
const port = portFromArgs(daemonArgs);
|
|
972
1022
|
return port ? `http://127.0.0.1:${port}` : null;
|
|
973
1023
|
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Best-effort HTTP base URL of the LOCAL running daemon, for CLI→daemon calls
|
|
1026
|
+
* (`ay widget`). More robust than resolveLocalServeUrl for UNMANAGED daemons: it
|
|
1027
|
+
* also reads the portless proxy backend port (~/.portless/routes.json) and the
|
|
1028
|
+
* PORT env, so a daemon started outside oxmgr (e.g. a portless wrapper that injects
|
|
1029
|
+
* PORT) is still found without the caller having to pass --base. Null if nothing
|
|
1030
|
+
* local is discoverable.
|
|
1031
|
+
*/
|
|
1032
|
+
async function resolveDaemonHttpBase() {
|
|
1033
|
+
const managed = await resolveLocalServeUrl();
|
|
1034
|
+
if (managed) return managed;
|
|
1035
|
+
const pport = await portlessAppPort();
|
|
1036
|
+
if (pport) return `http://127.0.0.1:${pport}`;
|
|
1037
|
+
const envPort = process.env.AGENT_YES_SERVE_PORT || process.env.PORT;
|
|
1038
|
+
if (envPort && /^\d+$/.test(envPort)) return `http://127.0.0.1:${envPort}`;
|
|
1039
|
+
return null;
|
|
1040
|
+
}
|
|
974
1041
|
async function warnStrayServeProcesses() {
|
|
975
1042
|
const stray = await listStrayServeProcesses();
|
|
976
1043
|
if (stray.length === 0) return;
|
|
@@ -2179,7 +2246,7 @@ Options:
|
|
|
2179
2246
|
}
|
|
2180
2247
|
});
|
|
2181
2248
|
if (req.method === "GET" && p === "/api/ws") {
|
|
2182
|
-
const ws = await import("./ws-
|
|
2249
|
+
const ws = await import("./ws-Bue4UzPC.js");
|
|
2183
2250
|
try {
|
|
2184
2251
|
await ws.loadProvision();
|
|
2185
2252
|
} catch (e) {
|
|
@@ -2199,7 +2266,7 @@ Options:
|
|
|
2199
2266
|
if (req.method === "GET" && p === "/api/ws/status") {
|
|
2200
2267
|
const dirRaw = url.searchParams.get("path");
|
|
2201
2268
|
if (!dirRaw) return new Response("missing ?path=<workspace dir>", { status: 400 });
|
|
2202
|
-
const ws = await import("./ws-
|
|
2269
|
+
const ws = await import("./ws-Bue4UzPC.js");
|
|
2203
2270
|
let prov;
|
|
2204
2271
|
try {
|
|
2205
2272
|
prov = await ws.loadProvision();
|
|
@@ -2273,6 +2340,136 @@ Options:
|
|
|
2273
2340
|
return new Response(e.message, { status: 404 });
|
|
2274
2341
|
}
|
|
2275
2342
|
}
|
|
2343
|
+
const scopedSub = authResult.kind === "scoped" ? authResult.scope.pid : null;
|
|
2344
|
+
const boundOk = (vid) => !scopedSub || scopedSub === "*" || scopedSub === vid;
|
|
2345
|
+
if (req.method === "POST" && p === "/api/widget/register") {
|
|
2346
|
+
let b;
|
|
2347
|
+
try {
|
|
2348
|
+
b = await req.json();
|
|
2349
|
+
} catch {
|
|
2350
|
+
return new Response("invalid JSON body", { status: 400 });
|
|
2351
|
+
}
|
|
2352
|
+
const id = scopedSub && scopedSub !== "*" ? scopedSub : typeof b.id === "string" && b.id ? b.id : widgetNewId();
|
|
2353
|
+
widgetViewers.set(id, {
|
|
2354
|
+
id,
|
|
2355
|
+
url: String(b.url ?? ""),
|
|
2356
|
+
title: String(b.title ?? ""),
|
|
2357
|
+
caps: Array.isArray(b.caps) ? b.caps.filter((c) => typeof c === "string") : [],
|
|
2358
|
+
lastSeen: Date.now()
|
|
2359
|
+
});
|
|
2360
|
+
return Response.json({ viewerId: id });
|
|
2361
|
+
}
|
|
2362
|
+
if (req.method === "GET" && p === "/api/widget/list") {
|
|
2363
|
+
const now = Date.now();
|
|
2364
|
+
return Response.json(widgetLive().map((v) => ({
|
|
2365
|
+
id: v.id,
|
|
2366
|
+
url: v.url,
|
|
2367
|
+
title: v.title,
|
|
2368
|
+
caps: v.caps,
|
|
2369
|
+
age: Math.round((now - v.lastSeen) / 1e3)
|
|
2370
|
+
})));
|
|
2371
|
+
}
|
|
2372
|
+
const pollM = /^\/api\/widget\/poll\/(.+)$/.exec(p);
|
|
2373
|
+
if (req.method === "GET" && pollM) {
|
|
2374
|
+
const vid = decodeURIComponent(pollM[1]);
|
|
2375
|
+
if (!boundOk(vid)) return new Response("token not bound to this viewer", { status: 403 });
|
|
2376
|
+
const enc = new TextEncoder();
|
|
2377
|
+
let hb = null;
|
|
2378
|
+
const stream = new ReadableStream({
|
|
2379
|
+
start(controller) {
|
|
2380
|
+
const push = (obj) => {
|
|
2381
|
+
try {
|
|
2382
|
+
controller.enqueue(enc.encode(`data: ${JSON.stringify(obj)}\n\n`));
|
|
2383
|
+
} catch {}
|
|
2384
|
+
};
|
|
2385
|
+
widgetPushers.set(vid, push);
|
|
2386
|
+
const touch = () => {
|
|
2387
|
+
const v = widgetViewers.get(vid);
|
|
2388
|
+
if (v) v.lastSeen = Date.now();
|
|
2389
|
+
};
|
|
2390
|
+
touch();
|
|
2391
|
+
hb = setInterval(() => {
|
|
2392
|
+
try {
|
|
2393
|
+
controller.enqueue(enc.encode(": ping\n\n"));
|
|
2394
|
+
touch();
|
|
2395
|
+
} catch {}
|
|
2396
|
+
}, 15e3);
|
|
2397
|
+
const cleanup = () => {
|
|
2398
|
+
if (hb) clearInterval(hb);
|
|
2399
|
+
if (widgetPushers.get(vid) === push) widgetPushers.delete(vid);
|
|
2400
|
+
};
|
|
2401
|
+
req.signal.addEventListener("abort", cleanup);
|
|
2402
|
+
},
|
|
2403
|
+
cancel() {
|
|
2404
|
+
if (hb) clearInterval(hb);
|
|
2405
|
+
}
|
|
2406
|
+
});
|
|
2407
|
+
return new Response(stream, { headers: {
|
|
2408
|
+
"Content-Type": "text/event-stream",
|
|
2409
|
+
"Cache-Control": "no-cache",
|
|
2410
|
+
Connection: "keep-alive"
|
|
2411
|
+
} });
|
|
2412
|
+
}
|
|
2413
|
+
if (req.method === "POST" && p === "/api/widget/result") {
|
|
2414
|
+
let b;
|
|
2415
|
+
try {
|
|
2416
|
+
b = await req.json();
|
|
2417
|
+
} catch {
|
|
2418
|
+
return new Response("invalid JSON body", { status: 400 });
|
|
2419
|
+
}
|
|
2420
|
+
const resolve = b.cmdId ? widgetWaiters.get(b.cmdId) : void 0;
|
|
2421
|
+
if (resolve) {
|
|
2422
|
+
widgetWaiters.delete(b.cmdId);
|
|
2423
|
+
resolve({
|
|
2424
|
+
ok: b.ok === true,
|
|
2425
|
+
data: b.data,
|
|
2426
|
+
error: b.error
|
|
2427
|
+
});
|
|
2428
|
+
}
|
|
2429
|
+
return Response.json({ ok: true });
|
|
2430
|
+
}
|
|
2431
|
+
if (req.method === "POST" && p === "/api/widget/read") {
|
|
2432
|
+
let b;
|
|
2433
|
+
try {
|
|
2434
|
+
b = await req.json();
|
|
2435
|
+
} catch {
|
|
2436
|
+
return new Response("invalid JSON body", { status: 400 });
|
|
2437
|
+
}
|
|
2438
|
+
if (!b.viewer || !b.kind) return new Response("missing viewer/kind", { status: 400 });
|
|
2439
|
+
if (authResult.kind === "scoped" && b.kind === "screenshot" && !authResult.scope.caps.includes("screenshot")) return new Response("scoped token lacks 'screenshot'", { status: 403 });
|
|
2440
|
+
const vid = widgetResolve(b.viewer);
|
|
2441
|
+
if (!vid) return new Response(`no online viewer matching "${b.viewer}"`, { status: 404 });
|
|
2442
|
+
if (!boundOk(vid)) return new Response("token not bound to this viewer", { status: 403 });
|
|
2443
|
+
const push = widgetPushers.get(vid);
|
|
2444
|
+
if (!push) return new Response("viewer offline", { status: 409 });
|
|
2445
|
+
const cmdId = `c${++widgetCmdSeq}_${Date.now()}`;
|
|
2446
|
+
const result = await new Promise((resolve) => {
|
|
2447
|
+
const timer = setTimeout(() => {
|
|
2448
|
+
widgetWaiters.delete(cmdId);
|
|
2449
|
+
resolve({
|
|
2450
|
+
ok: false,
|
|
2451
|
+
error: "timeout"
|
|
2452
|
+
});
|
|
2453
|
+
}, 1e4);
|
|
2454
|
+
widgetWaiters.set(cmdId, (r) => {
|
|
2455
|
+
clearTimeout(timer);
|
|
2456
|
+
resolve(r);
|
|
2457
|
+
});
|
|
2458
|
+
push({
|
|
2459
|
+
cmdId,
|
|
2460
|
+
kind: b.kind,
|
|
2461
|
+
args: b.args ?? {}
|
|
2462
|
+
});
|
|
2463
|
+
});
|
|
2464
|
+
const v = widgetViewers.get(vid);
|
|
2465
|
+
return Response.json({
|
|
2466
|
+
viewer: vid,
|
|
2467
|
+
url: v?.url ?? "",
|
|
2468
|
+
ts: Math.floor(Date.now() / 1e3),
|
|
2469
|
+
kind: b.kind,
|
|
2470
|
+
...result.ok ? { data: result.data } : { error: result.error ?? "failed" }
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2276
2473
|
const tailM = /^\/api\/tail\/(.+)$/.exec(p);
|
|
2277
2474
|
if (req.method === "GET" && tailM) {
|
|
2278
2475
|
const keyword = decodeURIComponent(tailM[1]);
|
|
@@ -2791,7 +2988,7 @@ Options:
|
|
|
2791
2988
|
const perm = body.perm ?? "r";
|
|
2792
2989
|
if (perm !== "r" && perm !== "rw") return new Response(`invalid perm ${perm} (want r or rw)`, { status: 400 });
|
|
2793
2990
|
try {
|
|
2794
|
-
const { createScopedShare } = await import("./agentShare-
|
|
2991
|
+
const { createScopedShare } = await import("./agentShare-DpmG7r_b.js");
|
|
2795
2992
|
const share = await createScopedShare({
|
|
2796
2993
|
agent: body.agent,
|
|
2797
2994
|
perm,
|
|
@@ -2806,12 +3003,12 @@ Options:
|
|
|
2806
3003
|
}
|
|
2807
3004
|
}
|
|
2808
3005
|
if (req.method === "GET" && p === "/api/shares") {
|
|
2809
|
-
const { listShares } = await import("./agentShare-
|
|
3006
|
+
const { listShares } = await import("./agentShare-DpmG7r_b.js");
|
|
2810
3007
|
return Response.json(listShares());
|
|
2811
3008
|
}
|
|
2812
3009
|
const revokeM = /^\/api\/share\/([^/]+)$/.exec(p);
|
|
2813
3010
|
if (req.method === "DELETE" && revokeM) {
|
|
2814
|
-
const { revokeShare } = await import("./agentShare-
|
|
3011
|
+
const { revokeShare } = await import("./agentShare-DpmG7r_b.js");
|
|
2815
3012
|
const ok = revokeShare(decodeURIComponent(revokeM[1]));
|
|
2816
3013
|
return new Response(ok ? "revoked" : "no such share", { status: ok ? 200 : 404 });
|
|
2817
3014
|
}
|
|
@@ -3113,7 +3310,7 @@ Options:
|
|
|
3113
3310
|
const shutdown = (resolve) => {
|
|
3114
3311
|
if (heartbeat) clearInterval(heartbeat);
|
|
3115
3312
|
closeShare?.();
|
|
3116
|
-
import("./agentShare-
|
|
3313
|
+
import("./agentShare-DpmG7r_b.js").then((m) => m.revokeAllShares()).catch(() => {});
|
|
3117
3314
|
server?.stop();
|
|
3118
3315
|
Promise.resolve(releaseHostLock?.()).catch(() => {}).then(resolve);
|
|
3119
3316
|
};
|
|
@@ -3125,5 +3322,5 @@ Options:
|
|
|
3125
3322
|
}
|
|
3126
3323
|
|
|
3127
3324
|
//#endregion
|
|
3128
|
-
export { cmdServe, mintScopedTermToken, resolveLocalServeUrl };
|
|
3129
|
-
//# sourceMappingURL=serve-
|
|
3325
|
+
export { cmdServe, loadTokenReadOnly, mintScopedTermToken, resolveDaemonHttpBase, resolveLocalServeUrl };
|
|
3326
|
+
//# sourceMappingURL=serve-nBi1Qrz7.js.map
|
|
@@ -32,7 +32,7 @@ async function cmdSetup(rest) {
|
|
|
32
32
|
if (!existsSync(abs)) process.stderr.write(` note: that directory doesn't exist yet — create it, or agents spawned there will fail\n`);
|
|
33
33
|
if (noShare) return 0;
|
|
34
34
|
process.stdout.write(`\nsharing this machine to agent-yes.com…\n`);
|
|
35
|
-
const { cmdServe } = await import("./serve-
|
|
35
|
+
const { cmdServe } = await import("./serve-nBi1Qrz7.js");
|
|
36
36
|
return cmdServe([
|
|
37
37
|
"install",
|
|
38
38
|
"--share",
|
|
@@ -42,4 +42,4 @@ async function cmdSetup(rest) {
|
|
|
42
42
|
|
|
43
43
|
//#endregion
|
|
44
44
|
export { cmdSetup };
|
|
45
|
-
//# sourceMappingURL=setup-
|
|
45
|
+
//# sourceMappingURL=setup-C-FQZTeR.js.map
|
|
@@ -3,7 +3,7 @@ import "./globalPidIndex-D9DOSd-c.js";
|
|
|
3
3
|
import "./messageLog-C-YIzhRj.js";
|
|
4
4
|
import "./e2e-CEIdJGZ7.js";
|
|
5
5
|
import "./configShared-9wVlbPyC.js";
|
|
6
|
-
import { A as renderLogTailLines, B as stopTipForCli, C as matchKeyword, D as readPtysize, E as readNotes, F as resolveResumeArgs, H as waitForLogQuiet, I as restartHintLines, L as runSubcommand, M as renderRawLogLines, N as resolveOne, O as recentMessageEdges, P as resolveReadWindow, R as snapshotStatus, S as listRecords, T as readAgentPtysize, U as writeKeysPaced, V as submitAndConfirm, W as writeToIpc, _ as isPidAlive, a as cmdHelp, b as isUserTyping, c as deriveLiveState, d as extractMenu, f as extractNeedsInput, g as isExitRequest, h as isAgentStuck, i as backoffWhileTyping, j as renderRawLog, k as recentReadEdges, l as deriveLiveStatus, m as finalizedLines, n as READ_PAGE_DEFAULT, o as controlCodeFromName, p as extractTaskCounts, r as TYPING_WINDOW_MS, s as cursorAbs, t as GRACEFUL_EXIT_COMMANDS, u as extractBadges, v as isSlashCommand, w as menuSelectKeys, x as lastStdinAt, y as isSubcommand, z as stdinActivityPath } from "./subcommands-
|
|
6
|
+
import { A as renderLogTailLines, B as stopTipForCli, C as matchKeyword, D as readPtysize, E as readNotes, F as resolveResumeArgs, H as waitForLogQuiet, I as restartHintLines, L as runSubcommand, M as renderRawLogLines, N as resolveOne, O as recentMessageEdges, P as resolveReadWindow, R as snapshotStatus, S as listRecords, T as readAgentPtysize, U as writeKeysPaced, V as submitAndConfirm, W as writeToIpc, _ as isPidAlive, a as cmdHelp, b as isUserTyping, c as deriveLiveState, d as extractMenu, f as extractNeedsInput, g as isExitRequest, h as isAgentStuck, i as backoffWhileTyping, j as renderRawLog, k as recentReadEdges, l as deriveLiveStatus, m as finalizedLines, n as READ_PAGE_DEFAULT, o as controlCodeFromName, p as extractTaskCounts, r as TYPING_WINDOW_MS, s as cursorAbs, t as GRACEFUL_EXIT_COMMANDS, u as extractBadges, v as isSlashCommand, w as menuSelectKeys, x as lastStdinAt, y as isSubcommand, z as stdinActivityPath } from "./subcommands-DHVf6p7P.js";
|
|
7
7
|
import "./webrtcLink-VQhWmKOw.js";
|
|
8
8
|
import "./remotes-Bem6WIyU.js";
|
|
9
9
|
|