agent-yes 1.306.3 → 1.307.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 +1 -0
- package/dist/{SUPPORTED_CLIS-Dvgot0oL.js → SUPPORTED_CLIS-BOGmmIrH.js} +3 -3
- package/dist/{SUPPORTED_CLIS-XUv7pAhg.js → SUPPORTED_CLIS-qL9_2DZ8.js} +2 -2
- package/dist/{agentShare-DHslHOe9.js → agentShare-C2oXrGvf.js} +4 -4
- package/dist/{callback-BnPh1ipj.js → callback-CNL-PGwh.js} +4 -4
- package/dist/{callback-BbDa82Yw.js → callback-ie8yyKma.js} +3 -3
- package/dist/cli.js +8 -8
- package/dist/{cmdPs-D_9k-_up.js → cmdPs-CfR5qCiO.js} +4 -4
- package/dist/index.js +2 -2
- package/dist/{notifyDaemon-Dsb009Id.js → notifyDaemon-DcAbvP43.js} +4 -4
- package/dist/{parentPingLoop-cXg1hXg0.js → parentPingLoop-BYT4XgfN.js} +2 -2
- package/dist/{remotes-BsMGvAay.js → remotes-CAZymHd7.js} +2 -2
- package/dist/{remotes-BqLoB5GR.js → remotes-W6NhMDfP.js} +1 -1
- package/dist/{roomReplyAlias-B-v76TA8.js → roomReplyAlias-B1EJft2d.js} +2 -2
- package/dist/roomReplyAlias-BeGVkAlc.js +6 -0
- package/dist/{rustBinary-BaadP-ZC.js → rustBinary-BjsZbiv5.js} +2 -2
- package/dist/{rustBinary-0BGlZPM2.js → rustBinary-CXQGcJEm.js} +2 -2
- package/dist/{schedule-CEZ-hTWV.js → schedule-zacFV53l.js} +49 -8
- package/dist/{schedulesCli-CLqieyQZ.js → schedules-BvwTGXU2.js} +2 -339
- package/dist/schedulesCli-Donh0LS2.js +343 -0
- package/dist/{serve-CuqQMmlO.js → serve-C38WYmzz.js} +35 -28
- package/dist/{serveRust-BfWkeL6T.js → serveRust-76_apYb8.js} +1 -1
- package/dist/{setup-D2hLlUYT.js → setup-CeAisuhv.js} +4 -4
- package/dist/{shareCmd-DbMp0rph.js → shareCmd-foO5MbJp.js} +6 -6
- package/dist/{spawnGate-I4p2fbz7.js → spawnGate-DhPgMs0Y.js} +1 -1
- package/dist/{spawnGate-3YSXiRFS.js → spawnGate-nUrmf4dd.js} +2 -2
- package/dist/{subcommands-7SrEP-BA.js → subcommands-DE31Tfv_.js} +24 -24
- package/dist/{subcommands-_Neez7D-.js → subcommands-DLQEC24N.js} +3 -3
- package/dist/{systemPathLink-Y3iC7bYV.js → systemPathLink-DI9WdoqQ.js} +1 -1
- package/dist/{terminal-iUqKIceC.js → terminal-CBbp6PfB.js} +2 -2
- package/dist/{todoCli-uJ3nK9j4.js → todoCli-BllShFnc.js} +1 -1
- package/dist/{tray-CLktEN3G.js → tray-RIjHSw7z.js} +1 -1
- package/dist/trayApp-BSOmax2E.js +5 -0
- package/dist/{trayApp-l9q9To-G.js → trayApp-C9SZOPpw.js} +2 -2
- package/dist/{ts-BLBWiX6i.js → ts-CO1H1P2R.js} +3 -3
- package/dist/{versionChecker-Dt2Aewei.js → versionChecker-CG--tQsV.js} +2 -2
- package/dist/{webrtcRemote-C3xQyf3u.js → webrtcRemote-B4pwES4i.js} +1 -1
- package/dist/{widget-_K5rPsLe.js → widget-CI7BtN94.js} +3 -3
- package/dist/{workspaceConfig-DBgsu81B.js → workspaceConfig-DjEklzxf.js} +1 -1
- package/dist/{ws-BCJF2ZKx.js → ws-DLJSBws6.js} +3 -3
- package/dist/{ws-BaBtzqo_.js → ws-W5nWHjDt.js} +4 -4
- package/lab/ui/console-logic.js +2 -2
- package/lab/ui/device-sync.js +209 -0
- package/lab/ui/device-transfer.js +99 -0
- package/lab/ui/index.html +129 -40
- package/lab/ui/sw.js +2 -0
- package/package.json +3 -1
- package/ts/schedule.ts +51 -1
- package/ts/scheduleSummary.bun.spec.ts +74 -0
- package/ts/serve.ts +11 -0
- package/dist/roomReplyAlias-BzWUBkQy.js +0 -6
- package/dist/trayApp-oEZBU7Cx.js +0 -5
|
@@ -5,12 +5,12 @@ import "./pidStore-DUXifdBr.js";
|
|
|
5
5
|
import "./messageLog-CEqe4Hk1.js";
|
|
6
6
|
import "./e2e-BdLf8DvY.js";
|
|
7
7
|
import "./configShared-De4bR5hH.js";
|
|
8
|
-
import "./subcommands-
|
|
8
|
+
import "./subcommands-DE31Tfv_.js";
|
|
9
9
|
import "./webrtcLink-DcvacEci.js";
|
|
10
|
-
import "./remotes-
|
|
11
|
-
import "./roomReplyAlias-
|
|
10
|
+
import "./remotes-CAZymHd7.js";
|
|
11
|
+
import "./roomReplyAlias-B1EJft2d.js";
|
|
12
12
|
import "./notifyStore-DIfkfKB2.js";
|
|
13
13
|
import "./senderAncestry-CVHeKk1Y.js";
|
|
14
|
-
import { a as isPathInside, c as walkWorkspaces, i as importProvisionModule, l as workspaceStatus, n as cmdWs, o as loadProvision, r as collectWorkspaces, s as resolveOperand, t as WS_JSON_SCHEMA } from "./ws-
|
|
14
|
+
import { a as isPathInside, c as walkWorkspaces, i as importProvisionModule, l as workspaceStatus, n as cmdWs, o as loadProvision, r as collectWorkspaces, s as resolveOperand, t as WS_JSON_SCHEMA } from "./ws-DLJSBws6.js";
|
|
15
15
|
|
|
16
16
|
export { WS_JSON_SCHEMA, cmdWs, collectWorkspaces, isPathInside, loadProvision, walkWorkspaces, workspaceStatus };
|
package/lab/ui/console-logic.js
CHANGED
|
@@ -686,7 +686,7 @@ export function forestOrder(entries) {
|
|
|
686
686
|
// display order. Headers (room/peer) are non-selectable; only 'agent' rows are.
|
|
687
687
|
// A purely local fleet (one room, one unlabelled host) yields only agent rows —
|
|
688
688
|
// identical to forestOrder — so the common case stays a plain agent tree.
|
|
689
|
-
export function layeredRows(entries) {
|
|
689
|
+
export function layeredRows(entries, { showHost = false } = {}) {
|
|
690
690
|
const multiRoom = new Set(entries.map((e) => e._room || "")).size > 1;
|
|
691
691
|
|
|
692
692
|
// Container nodes carry a `kind`/`label` for headers; agent nodes carry an
|
|
@@ -718,7 +718,7 @@ export function layeredRows(entries) {
|
|
|
718
718
|
const agentNodes = agentForestNodes(pe).map(toAgentNode);
|
|
719
719
|
const host = pe[0]?._host || "";
|
|
720
720
|
const label = host && labelCounts.get(host) > 1 ? `${host} (${String(src).slice(-6)})` : host;
|
|
721
|
-
if (multiPeer && label)
|
|
721
|
+
if ((multiPeer || showHost) && label)
|
|
722
722
|
underRoom.push({ kind: "peer", label, room: rid, host, src, children: agentNodes });
|
|
723
723
|
else underRoom.push(...agentNodes); // single/unlabelled peer hidden
|
|
724
724
|
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { exchange } from "./device-transfer.js";
|
|
2
|
+
|
|
3
|
+
const prefix = "ay.peerCopy.";
|
|
4
|
+
const ownerKey = "ay.peerOwner";
|
|
5
|
+
const deviceKey = "ay.peerDevice";
|
|
6
|
+
const text = (v, size) => typeof v === "string" && v.length <= size;
|
|
7
|
+
function valid(s) {
|
|
8
|
+
return (
|
|
9
|
+
s?.version === 1 &&
|
|
10
|
+
/^[0-9a-f-]{36}$/.test(s.device) &&
|
|
11
|
+
Number.isSafeInteger(s.time) &&
|
|
12
|
+
Array.isArray(s.rooms) &&
|
|
13
|
+
s.rooms.length <= 16 &&
|
|
14
|
+
s.rooms.every(
|
|
15
|
+
(r) =>
|
|
16
|
+
r &&
|
|
17
|
+
text(r.name, 160) &&
|
|
18
|
+
r.name &&
|
|
19
|
+
!Object.hasOwn(Object.prototype, r.name) &&
|
|
20
|
+
text(r.token, 4096) &&
|
|
21
|
+
r.token &&
|
|
22
|
+
text(r.host, 300) &&
|
|
23
|
+
(r.host === "codehost" || /^[a-z0-9.-]+(:[0-9]{1,5})?$/i.test(r.host)) &&
|
|
24
|
+
Number.isSafeInteger(r.ts),
|
|
25
|
+
) &&
|
|
26
|
+
Array.isArray(s.agents) &&
|
|
27
|
+
s.agents.length <= 2000 &&
|
|
28
|
+
s.agents.every(
|
|
29
|
+
(a) => a && text(a.room, 160) && Number.isSafeInteger(a.pid) && text(a.status, 64),
|
|
30
|
+
) &&
|
|
31
|
+
Array.isArray(s.schedules) &&
|
|
32
|
+
s.schedules.length <= 512 &&
|
|
33
|
+
s.schedules.every(
|
|
34
|
+
(j) =>
|
|
35
|
+
j &&
|
|
36
|
+
(j.enabled === undefined || typeof j.enabled === "boolean") &&
|
|
37
|
+
text(j.host, 160) &&
|
|
38
|
+
text(j.name, 200) &&
|
|
39
|
+
text(j.cron, 120) &&
|
|
40
|
+
text(j.tz, 100),
|
|
41
|
+
) &&
|
|
42
|
+
Array.isArray(s.unavailable) &&
|
|
43
|
+
s.unavailable.length <= 512 &&
|
|
44
|
+
s.unavailable.every((h) => text(h, 160))
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function mountDeviceSync({ dialog, getLocal, connect }) {
|
|
49
|
+
const status = dialog.querySelector("[role=status]");
|
|
50
|
+
const content = dialog.querySelector(".copies");
|
|
51
|
+
const start = dialog.querySelector(".pair");
|
|
52
|
+
let revision = 0,
|
|
53
|
+
stop;
|
|
54
|
+
const report = (msg) => {
|
|
55
|
+
status.textContent = msg;
|
|
56
|
+
};
|
|
57
|
+
const cancel = () => {
|
|
58
|
+
revision++;
|
|
59
|
+
stop?.();
|
|
60
|
+
stop = undefined;
|
|
61
|
+
start.disabled = false;
|
|
62
|
+
};
|
|
63
|
+
function forget() {
|
|
64
|
+
cancel();
|
|
65
|
+
for (const key of Object.keys(localStorage))
|
|
66
|
+
if (key.startsWith(prefix)) localStorage.removeItem(key);
|
|
67
|
+
localStorage.removeItem(ownerKey);
|
|
68
|
+
content.replaceChildren();
|
|
69
|
+
}
|
|
70
|
+
const session = async () => {
|
|
71
|
+
const res = await fetch("/api/auth/get-session", {
|
|
72
|
+
cache: "no-store",
|
|
73
|
+
signal: AbortSignal.timeout(5000),
|
|
74
|
+
});
|
|
75
|
+
if (!res.ok) throw Error();
|
|
76
|
+
return (await res.json())?.user?.id;
|
|
77
|
+
};
|
|
78
|
+
function render(owner) {
|
|
79
|
+
content.replaceChildren();
|
|
80
|
+
if (!owner || localStorage.getItem(ownerKey) !== owner) return;
|
|
81
|
+
for (const key of Object.keys(localStorage).filter((k) => k.startsWith(prefix + owner + "."))) {
|
|
82
|
+
let copy;
|
|
83
|
+
try {
|
|
84
|
+
copy = JSON.parse(localStorage.getItem(key));
|
|
85
|
+
} catch {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (!valid(copy)) continue;
|
|
89
|
+
const freshRooms = copy.rooms.filter((r) => Date.now() - r.ts <= 90 * 86400000);
|
|
90
|
+
if (freshRooms.length !== copy.rooms.length) {
|
|
91
|
+
copy.rooms = freshRooms;
|
|
92
|
+
localStorage.setItem(key, JSON.stringify(copy));
|
|
93
|
+
}
|
|
94
|
+
const section = document.createElement("section");
|
|
95
|
+
const add = (tag, value) => {
|
|
96
|
+
const el = document.createElement(tag);
|
|
97
|
+
el.textContent = value;
|
|
98
|
+
section.append(el);
|
|
99
|
+
return el;
|
|
100
|
+
};
|
|
101
|
+
add("h3", "Device " + copy.device.slice(0, 8));
|
|
102
|
+
add("p", "Last synced " + new Date(copy.time).toLocaleString());
|
|
103
|
+
for (const r of copy.rooms) {
|
|
104
|
+
const b = add("button", "Connect to " + r.name);
|
|
105
|
+
b.onclick = async () => {
|
|
106
|
+
if (localStorage.getItem(ownerKey) !== owner) return;
|
|
107
|
+
if (await connect(r)) dialog.close();
|
|
108
|
+
else report("A different saved room already uses that name.");
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
for (const a of copy.agents) add("div", a.room + " · PID " + a.pid + " · " + a.status);
|
|
112
|
+
for (const j of copy.schedules)
|
|
113
|
+
add(
|
|
114
|
+
"div",
|
|
115
|
+
j.host +
|
|
116
|
+
" · " +
|
|
117
|
+
j.name +
|
|
118
|
+
" · " +
|
|
119
|
+
j.cron +
|
|
120
|
+
" (" +
|
|
121
|
+
j.tz +
|
|
122
|
+
")" +
|
|
123
|
+
(j.enabled === false ? " · paused" : ""),
|
|
124
|
+
);
|
|
125
|
+
for (const host of copy.unavailable) add("div", host + " · timetable unavailable");
|
|
126
|
+
content.append(section);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
start.onclick = async () => {
|
|
130
|
+
cancel();
|
|
131
|
+
const run = revision;
|
|
132
|
+
start.disabled = true;
|
|
133
|
+
try {
|
|
134
|
+
const owner = await session();
|
|
135
|
+
if (run !== revision) return;
|
|
136
|
+
if (!owner) {
|
|
137
|
+
forget();
|
|
138
|
+
report("Sign in to pair devices.");
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (localStorage.getItem(ownerKey) !== owner) {
|
|
142
|
+
for (const key of Object.keys(localStorage))
|
|
143
|
+
if (key.startsWith(prefix)) localStorage.removeItem(key);
|
|
144
|
+
}
|
|
145
|
+
localStorage.setItem(ownerKey, owner);
|
|
146
|
+
let device = localStorage.getItem(deviceKey);
|
|
147
|
+
if (!device) localStorage.setItem(deviceKey, (device = crypto.randomUUID()));
|
|
148
|
+
report("Waiting for your other device. Choose Sync now there too.");
|
|
149
|
+
const current = async () =>
|
|
150
|
+
(await session()) === owner && revision === run && localStorage.getItem(ownerKey) === owner;
|
|
151
|
+
stop = exchange(
|
|
152
|
+
async () => {
|
|
153
|
+
const snapshot = { ...(await getLocal()), version: 1, time: Date.now(), device };
|
|
154
|
+
if (!valid(snapshot) || !(await current())) throw Error();
|
|
155
|
+
return snapshot;
|
|
156
|
+
},
|
|
157
|
+
async (copy, active) => {
|
|
158
|
+
if (!valid(copy) || copy.device === device || !(await current())) throw Error();
|
|
159
|
+
if (!active()) return false;
|
|
160
|
+
localStorage.setItem(prefix + owner + "." + copy.device, JSON.stringify(copy));
|
|
161
|
+
render(owner);
|
|
162
|
+
return true;
|
|
163
|
+
},
|
|
164
|
+
(msg) => {
|
|
165
|
+
if (run === revision) {
|
|
166
|
+
report(msg);
|
|
167
|
+
start.disabled = false;
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
);
|
|
171
|
+
} catch {
|
|
172
|
+
if (run === revision) {
|
|
173
|
+
report("Sync unavailable. Your local console is ready to use.");
|
|
174
|
+
start.disabled = false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
dialog.querySelector(".forget").onclick = () => {
|
|
179
|
+
forget();
|
|
180
|
+
report("Saved device copies cleared.");
|
|
181
|
+
};
|
|
182
|
+
dialog.querySelector(".close").onclick = () => dialog.close();
|
|
183
|
+
dialog.onclose = cancel;
|
|
184
|
+
window.addEventListener("ay-auth-changed", forget);
|
|
185
|
+
window.addEventListener("storage", (e) => {
|
|
186
|
+
if (e.key === ownerKey || e.key === "ay.peerSignout") {
|
|
187
|
+
cancel();
|
|
188
|
+
render(localStorage.getItem(ownerKey));
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
return async () => {
|
|
192
|
+
report("");
|
|
193
|
+
content.replaceChildren();
|
|
194
|
+
dialog.showModal();
|
|
195
|
+
const run = revision;
|
|
196
|
+
let owner = localStorage.getItem(ownerKey);
|
|
197
|
+
try {
|
|
198
|
+
const signed = await session();
|
|
199
|
+
if (run !== revision) return;
|
|
200
|
+
if (!signed || (owner && signed !== owner)) {
|
|
201
|
+
forget();
|
|
202
|
+
owner = null;
|
|
203
|
+
}
|
|
204
|
+
} catch {
|
|
205
|
+
if (run === revision) report("Offline · showing copies saved on this device.");
|
|
206
|
+
}
|
|
207
|
+
if (dialog.open) render(owner);
|
|
208
|
+
};
|
|
209
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// One opt-in exchange between two browsers. The socket carries only SDP.
|
|
2
|
+
// WebRTC encrypts the data channel between the negotiated endpoints.
|
|
3
|
+
export function exchange(snapshot, receive, report) {
|
|
4
|
+
const ws = new WebSocket(location.origin.replace(/^http/, "ws") + "/api/device-pair");
|
|
5
|
+
const pc = new RTCPeerConnection({ iceServers: [{ urls: "stun:stun.l.google.com:19302" }] });
|
|
6
|
+
let connected = false,
|
|
7
|
+
ended = false,
|
|
8
|
+
received = false,
|
|
9
|
+
acknowledged = false,
|
|
10
|
+
sent = false;
|
|
11
|
+
let candidateTimer,
|
|
12
|
+
descriptionSent = false;
|
|
13
|
+
const timeout = setTimeout(
|
|
14
|
+
() => finish("Pairing timed out. Start again on both devices."),
|
|
15
|
+
85000,
|
|
16
|
+
);
|
|
17
|
+
function finish(message) {
|
|
18
|
+
if (ended) return;
|
|
19
|
+
ended = true;
|
|
20
|
+
clearTimeout(timeout);
|
|
21
|
+
clearTimeout(candidateTimer);
|
|
22
|
+
pc.close();
|
|
23
|
+
ws.close();
|
|
24
|
+
report(message);
|
|
25
|
+
}
|
|
26
|
+
function channel(dc) {
|
|
27
|
+
dc.onopen = async () => {
|
|
28
|
+
connected = true;
|
|
29
|
+
try {
|
|
30
|
+
const data = JSON.stringify(await snapshot());
|
|
31
|
+
if (ended) return;
|
|
32
|
+
if (
|
|
33
|
+
new TextEncoder().encode(data).length > Math.min(pc.sctp?.maxMessageSize || 65536, 65536)
|
|
34
|
+
)
|
|
35
|
+
throw new Error();
|
|
36
|
+
dc.send(data);
|
|
37
|
+
sent = true;
|
|
38
|
+
} catch {
|
|
39
|
+
finish("Could not send this device’s snapshot.");
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
dc.onmessage = async ({ data }) => {
|
|
43
|
+
try {
|
|
44
|
+
if (ended) return;
|
|
45
|
+
if (data === "ack" && sent) acknowledged = true;
|
|
46
|
+
else {
|
|
47
|
+
if (
|
|
48
|
+
received ||
|
|
49
|
+
typeof data !== "string" ||
|
|
50
|
+
data.length > 65536 ||
|
|
51
|
+
new TextEncoder().encode(data).length > 65536
|
|
52
|
+
)
|
|
53
|
+
throw new Error();
|
|
54
|
+
const saved = await receive(JSON.parse(data), () => !ended);
|
|
55
|
+
if (ended || !saved) return;
|
|
56
|
+
received = true;
|
|
57
|
+
dc.send("ack");
|
|
58
|
+
}
|
|
59
|
+
if (received && acknowledged) finish("Both devices saved their copies.");
|
|
60
|
+
} catch {
|
|
61
|
+
finish("Could not save the device snapshot.");
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
dc.onclose = () => finish("Device connection closed.");
|
|
65
|
+
dc.onerror = () => finish("Device connection interrupted.");
|
|
66
|
+
}
|
|
67
|
+
pc.ondatachannel = (e) => channel(e.channel);
|
|
68
|
+
function sendDescription() {
|
|
69
|
+
if (descriptionSent || ended || ws.readyState !== WebSocket.OPEN) return;
|
|
70
|
+
descriptionSent = true;
|
|
71
|
+
clearTimeout(candidateTimer);
|
|
72
|
+
ws.send(JSON.stringify(pc.localDescription));
|
|
73
|
+
}
|
|
74
|
+
pc.onicecandidate = ({ candidate }) => {
|
|
75
|
+
if (!candidate) sendDescription();
|
|
76
|
+
// A blocked STUN server can delay ICE completion even when both peers
|
|
77
|
+
// already have usable local addresses. Give it time to find a public one.
|
|
78
|
+
else if (!candidateTimer) candidateTimer = setTimeout(sendDescription, 6000);
|
|
79
|
+
};
|
|
80
|
+
ws.onmessage = async ({ data }) => {
|
|
81
|
+
try {
|
|
82
|
+
const msg = JSON.parse(data);
|
|
83
|
+
if (msg.type === "start") {
|
|
84
|
+
channel(pc.createDataChannel("device-sync"));
|
|
85
|
+
await pc.setLocalDescription(await pc.createOffer());
|
|
86
|
+
} else {
|
|
87
|
+
await pc.setRemoteDescription(msg);
|
|
88
|
+
if (msg.type === "offer") await pc.setLocalDescription(await pc.createAnswer());
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
finish("Could not connect these devices.");
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
ws.onerror = () => finish("Pairing unavailable. Check your sign-in and connection.");
|
|
95
|
+
ws.onclose = () => {
|
|
96
|
+
if (!connected) finish("Pairing closed. Try again on both devices.");
|
|
97
|
+
};
|
|
98
|
+
return () => finish("Sync stopped.");
|
|
99
|
+
}
|