agent-yes 1.98.0 → 1.100.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/dist/SUPPORTED_CLIS-C-cenkTG.js +8 -0
- package/dist/{SUPPORTED_CLIS-C0a9K6I5.js → SUPPORTED_CLIS-DIHMEdRx.js} +2 -2
- package/dist/cli.js +3 -3
- package/dist/index.js +2 -2
- package/dist/{serve-DPY37v0u.js → serve-C4fZSjh9.js} +22 -14
- package/dist/{share-D-r6y3xD.js → share-BsCeIfQM.js} +19 -2
- package/dist/{subcommands-D4Muugfr.js → subcommands-BKY3nQV4.js} +2 -2
- package/dist/{subcommands-fCkYXyTe.js → subcommands-dnjUZ9nY.js} +1 -1
- package/dist/{ts-BuFWTNL9.js → ts-CUn393DD.js} +2 -2
- package/dist/{versionChecker-CpNUvHBx.js → versionChecker-BWdncsn6.js} +2 -2
- package/lab/ui/index.html +221 -98
- package/lab/ui/room-client.js +328 -239
- package/package.json +1 -1
- package/ts/serve.ts +38 -10
- package/ts/share.ts +29 -1
- package/dist/SUPPORTED_CLIS-BtLklR5y.js +0 -8
package/package.json
CHANGED
package/ts/serve.ts
CHANGED
|
@@ -83,8 +83,11 @@ async function cmdServeDaemon(sub: string, args: string[]): Promise<number> {
|
|
|
83
83
|
|
|
84
84
|
if (sub === "install") {
|
|
85
85
|
const token = await loadOrCreateToken(undefined);
|
|
86
|
-
// Build the ay serve command with forwarded args (port, host, --webrtc, etc.)
|
|
87
|
-
|
|
86
|
+
// Build the ay serve command with forwarded args (port, host, --webrtc, etc.).
|
|
87
|
+
// Absolute paths: oxmgr's daemon environment may not have ~/.bun/bin in
|
|
88
|
+
// PATH, so a bare `ay` (or its `#!/usr/bin/env bun` shebang) fails to spawn.
|
|
89
|
+
const ayBin = Bun.which("ay");
|
|
90
|
+
const serveCmd = [...(ayBin ? [process.execPath, ayBin] : ["ay"]), "serve", ...args].join(" ");
|
|
88
91
|
const proc = Bun.spawn(
|
|
89
92
|
[oxmgrBin, "start", serveCmd, "--name", DAEMON_NAME, "--restart", "always"],
|
|
90
93
|
{ stdio: ["ignore", "inherit", "inherit"] },
|
|
@@ -93,15 +96,23 @@ async function cmdServeDaemon(sub: string, args: string[]): Promise<number> {
|
|
|
93
96
|
if (code === 0) {
|
|
94
97
|
const portM = /--port[=\s](\d+)/.exec(args.join(" "));
|
|
95
98
|
const port = portM ? Number(portM[1]) : DEFAULT_PORT;
|
|
99
|
+
// Mirror cmdServe's mode resolution: webrtc-only daemons open no HTTP port.
|
|
100
|
+
const webrtcish = args.some((a) => a.startsWith("--webrtc") || a.startsWith("--share"));
|
|
101
|
+
const httpish =
|
|
102
|
+
args.some((a) => a.startsWith("--http") || a.startsWith("--share")) ||
|
|
103
|
+
!args.some((a) => a.startsWith("--webrtc"));
|
|
96
104
|
process.stdout.write(`\ninstalled '${DAEMON_NAME}' as a daemon via oxmgr\n`);
|
|
97
105
|
process.stdout.write(`token: ${token}\n\n`);
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
if (httpish) {
|
|
107
|
+
process.stdout.write(` ay ls ${token}@<host>:${port}\n`);
|
|
108
|
+
process.stdout.write(` ay remote add <alias> http://${token}@<host>:${port}\n`);
|
|
109
|
+
}
|
|
100
110
|
process.stdout.write(` ay serve logs # view server logs\n`);
|
|
101
111
|
process.stdout.write(` ay serve uninstall # remove daemon\n`);
|
|
102
|
-
if (
|
|
112
|
+
if (webrtcish) {
|
|
103
113
|
process.stdout.write(
|
|
104
|
-
`\nthe WebRTC share link is printed by the daemon — see: ay serve logs\n
|
|
114
|
+
`\nthe WebRTC share link is printed by the daemon — see: ay serve logs\n` +
|
|
115
|
+
`(the room persists in ~/.agent-yes/.share-room, so the link survives restarts)\n`,
|
|
105
116
|
);
|
|
106
117
|
}
|
|
107
118
|
}
|
|
@@ -140,11 +151,15 @@ export async function cmdServe(rest: string[]): Promise<number> {
|
|
|
140
151
|
` --webrtc [URL] Share over WebRTC (bare flag mints a room+link on\n` +
|
|
141
152
|
` agent-yes.com, or pass webrtc://room:token@host).\n` +
|
|
142
153
|
` Alone it needs NO port — combine with --http for both.\n` +
|
|
154
|
+
` The minted room persists in ~/.agent-yes/.share-room\n` +
|
|
155
|
+
` (stable link across restarts; delete the file to rotate).\n` +
|
|
143
156
|
` --share [URL] Legacy alias for --http --webrtc\n\n` +
|
|
144
157
|
`Options:\n` +
|
|
145
158
|
` --port N Port to listen on (default: ${DEFAULT_PORT})\n` +
|
|
146
159
|
` --host HOST Interface to bind (default: 127.0.0.1; use 0.0.0.0 to expose)\n` +
|
|
147
160
|
` --token TOKEN Auth token (auto-generated and saved if omitted)\n` +
|
|
161
|
+
` -d, --daemon Install these flags as a background daemon via oxmgr\n` +
|
|
162
|
+
` (same as: ay serve install <flags>)\n` +
|
|
148
163
|
` --allow-spawn Deprecated no-op — the console can always spawn agents\n` +
|
|
149
164
|
` --tls-cert FILE TLS certificate PEM\n` +
|
|
150
165
|
` --tls-key FILE TLS private key PEM\n\n` +
|
|
@@ -205,6 +220,14 @@ export async function cmdServe(rest: string[]): Promise<number> {
|
|
|
205
220
|
.exitProcess(false);
|
|
206
221
|
|
|
207
222
|
const argv = await y.parseAsync();
|
|
223
|
+
|
|
224
|
+
// --daemon/-d: install these exact flags as the oxmgr daemon instead of
|
|
225
|
+
// serving in the foreground (sugar for `ay serve install <flags>`).
|
|
226
|
+
if (argv.daemon) {
|
|
227
|
+
const fwd = rest.filter((a) => a !== "--daemon" && a !== "-d");
|
|
228
|
+
return cmdServeDaemon("install", fwd);
|
|
229
|
+
}
|
|
230
|
+
|
|
208
231
|
const port = (argv.port as number) ?? DEFAULT_PORT;
|
|
209
232
|
const host = (argv.host as string) ?? "127.0.0.1";
|
|
210
233
|
const tokenFlag = typeof argv.token === "string" ? argv.token : undefined;
|
|
@@ -651,17 +674,22 @@ export async function cmdServe(rest: string[]): Promise<number> {
|
|
|
651
674
|
// webrtc:// value joins an explicit one.
|
|
652
675
|
if (wantWebrtc) {
|
|
653
676
|
const webrtcVal = (argv.webrtc ?? argv.share) as string | undefined;
|
|
654
|
-
const
|
|
677
|
+
const explicitUrl =
|
|
655
678
|
typeof webrtcVal === "string" && webrtcVal.startsWith("webrtc://") ? webrtcVal : undefined;
|
|
656
679
|
try {
|
|
657
|
-
const { startShare } = await import("./share.ts");
|
|
680
|
+
const { startShare, loadOrCreateShareRoom } = await import("./share.ts");
|
|
681
|
+
// No explicit webrtc:// URL → reuse the persisted room (minted once and
|
|
682
|
+
// saved like the serve token), so the link is stable across restarts.
|
|
658
683
|
const { link } = await startShare({
|
|
659
|
-
url:
|
|
684
|
+
url: explicitUrl ?? (await loadOrCreateShareRoom()),
|
|
660
685
|
localFetch: apiFetch,
|
|
661
686
|
apiToken: token,
|
|
662
687
|
});
|
|
663
688
|
process.stdout.write(
|
|
664
|
-
`${wantHttp ? "\n" : ""}shared over WebRTC — open this link (the token is eaten from the URL on open):\n ${link}\n
|
|
689
|
+
`${wantHttp ? "\n" : ""}shared over WebRTC — open this link (the token is eaten from the URL on open):\n ${link}\n` +
|
|
690
|
+
(explicitUrl
|
|
691
|
+
? "\n"
|
|
692
|
+
: ` (persistent room — same link across restarts; delete ~/.agent-yes/.share-room to rotate)\n\n`),
|
|
665
693
|
);
|
|
666
694
|
} catch (e) {
|
|
667
695
|
process.stderr.write(`ay serve --webrtc failed: ${(e as Error).message}\n`);
|
package/ts/share.ts
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
// lab/ui/cf/worker.ts for the signaling protocol and lab/ui/index.html for the
|
|
6
6
|
// browser side.
|
|
7
7
|
import { randomBytes } from "crypto";
|
|
8
|
+
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
9
|
+
import { homedir } from "os";
|
|
10
|
+
import path from "path";
|
|
8
11
|
|
|
9
12
|
const SUB = "ay-signal-1";
|
|
10
13
|
const ICE = [{ urls: "stun:stun.l.google.com:19302" }];
|
|
@@ -12,7 +15,8 @@ const MAX_CHUNK = 15_000; // keep DataChannel messages under the SCTP limit
|
|
|
12
15
|
const DEFAULT_SIGHOST = "s.agent-yes.com";
|
|
13
16
|
|
|
14
17
|
export interface ShareOpts {
|
|
15
|
-
/** webrtc://room:token@host, or undefined to mint a fresh
|
|
18
|
+
/** webrtc://room:token@host, or undefined to mint a fresh (unpersisted)
|
|
19
|
+
* room+token — callers wanting a stable room use loadOrCreateShareRoom() */
|
|
16
20
|
url?: string;
|
|
17
21
|
/** signaling host when minting (default s.agent-yes.com) */
|
|
18
22
|
sighost?: string;
|
|
@@ -22,6 +26,30 @@ export interface ShareOpts {
|
|
|
22
26
|
apiToken: string;
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
// The room+token persist like the serve token, so the share link (and any
|
|
30
|
+
// browser that saved the room) survives restarts — important for daemons,
|
|
31
|
+
// which would otherwise mint a new link on every restart. Delete the file to
|
|
32
|
+
// rotate the room.
|
|
33
|
+
function shareRoomPath(): string {
|
|
34
|
+
const home = process.env.AGENT_YES_HOME ?? path.join(homedir(), ".agent-yes");
|
|
35
|
+
return path.join(home, ".share-room");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function loadOrCreateShareRoom(sighost = DEFAULT_SIGHOST): Promise<string> {
|
|
39
|
+
try {
|
|
40
|
+
const url = (await readFile(shareRoomPath(), "utf-8")).trim();
|
|
41
|
+
if (url.startsWith("webrtc://")) return url;
|
|
42
|
+
} catch {
|
|
43
|
+
/* not yet minted */
|
|
44
|
+
}
|
|
45
|
+
const room = "r" + randomBytes(3).toString("hex");
|
|
46
|
+
const token = randomBytes(32).toString("hex");
|
|
47
|
+
const url = `webrtc://${room}:${token}@${sighost}`;
|
|
48
|
+
await mkdir(path.dirname(shareRoomPath()), { recursive: true });
|
|
49
|
+
await writeFile(shareRoomPath(), url, { mode: 0o600 });
|
|
50
|
+
return url;
|
|
51
|
+
}
|
|
52
|
+
|
|
25
53
|
function parseShareUrl(s: string): { room: string; token: string; host: string } {
|
|
26
54
|
const m = /^webrtc:\/\/([^:@/]+):([^@/]+)@(.+)$/.exec(s);
|
|
27
55
|
if (!m) throw new Error(`bad --share url: ${s} (want webrtc://room:token@host)`);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import "./ts-BuFWTNL9.js";
|
|
2
|
-
import "./logger-B9h0djqx.js";
|
|
3
|
-
import "./versionChecker-CpNUvHBx.js";
|
|
4
|
-
import "./pidStore-DBjlqzo8.js";
|
|
5
|
-
import "./globalPidIndex-yVd3mbsV.js";
|
|
6
|
-
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-C0a9K6I5.js";
|
|
7
|
-
|
|
8
|
-
export { SUPPORTED_CLIS };
|