agent-yes 1.195.0 → 1.196.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-Ca2ffDRy.js +8 -0
- package/dist/{SUPPORTED_CLIS-Bdj9qDRm.js → SUPPORTED_CLIS-CxLCQtAU.js} +2 -2
- package/dist/{agentShare-M2jaTMlH.js → agentShare-Bi95Xy0S.js} +2 -2
- package/dist/cli.js +4 -4
- package/dist/index.js +2 -2
- package/dist/{notifyDaemon-D5HwUMxH.js → notifyDaemon-BdOeFIVl.js} +2 -2
- package/dist/{rustBinary-B4pfibDJ.js → rustBinary-D_ifX2Vd.js} +2 -2
- package/dist/{schedule-1oS-Yxxa.js → schedule-rvMgc0tA.js} +4 -4
- package/dist/{serve-Ce708ALB.js → serve-D0-LoTfw.js} +10 -10
- package/dist/{setup-fTLT9Bf2.js → setup-BC1VjTOf.js} +2 -2
- package/dist/{subcommands-CV5gqRKq.js → subcommands-Cz8xpc5X.js} +1 -1
- package/dist/{subcommands-CqB9zo8_.js → subcommands-s74ViJcI.js} +6 -6
- package/dist/{ts-DDsICrj-.js → ts-CP17kUI1.js} +2 -2
- package/dist/{versionChecker-B8qEzYDu.js → versionChecker-DTssk7cU.js} +2 -2
- package/lab/ui/index.html +96 -0
- package/lab/ui/room-client.js +544 -388
- package/lab/ui/sw.js +71 -19
- package/package.json +1 -1
- package/dist/SUPPORTED_CLIS-Daig8XHX.js +0 -8
package/lab/ui/sw.js
CHANGED
|
@@ -21,7 +21,7 @@ async function pickClient() {
|
|
|
21
21
|
return all.find((c) => !new URL(c.url).pathname.startsWith(BASE + "p/")) || all[0] || null;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
async function proxyPreview(request, src, port, rest) {
|
|
24
|
+
async function proxyPreview(request, src, port, rest, allowInject) {
|
|
25
25
|
const client = await pickClient();
|
|
26
26
|
if (!client) return new Response("open the agent-yes console to preview", { status: 502 });
|
|
27
27
|
const headers = {};
|
|
@@ -35,23 +35,40 @@ async function proxyPreview(request, src, port, rest) {
|
|
|
35
35
|
let resolved = false;
|
|
36
36
|
mc.port1.onmessage = (ev) => {
|
|
37
37
|
const msg = ev.data;
|
|
38
|
-
if (msg.type
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
else if (m2.type === "end") controller.close();
|
|
45
|
-
else if (m2.type === "error") controller.error(new Error(m2.message));
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
resolved = true;
|
|
50
|
-
resolve(new Response(stream, { status: msg.status, statusText: msg.statusText, headers: msg.headers }));
|
|
51
|
-
} else if (msg.type === "error" && !resolved) {
|
|
52
|
-
resolved = true;
|
|
53
|
-
resolve(new Response("preview tunnel error: " + msg.message, { status: 502 }));
|
|
38
|
+
if (msg.type !== "head") {
|
|
39
|
+
if (msg.type === "error" && !resolved) {
|
|
40
|
+
resolved = true;
|
|
41
|
+
resolve(new Response("preview tunnel error: " + msg.message, { status: 502 }));
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
54
44
|
}
|
|
45
|
+
resolved = true;
|
|
46
|
+
const headers = new Headers(msg.headers);
|
|
47
|
+
const ct = headers.get("content-type") || "";
|
|
48
|
+
// HTML document navigations (the /p/ path itself, not app subresources):
|
|
49
|
+
// buffer, strip CSP, and inject a window.WebSocket shim so the app's own
|
|
50
|
+
// sockets (Vite HMR) also ride the P2P tunnel. Everything else streams.
|
|
51
|
+
if (allowInject && ct.includes("text/html")) {
|
|
52
|
+
const chunks = [];
|
|
53
|
+
mc.port1.onmessage = (e2) => {
|
|
54
|
+
const m2 = e2.data;
|
|
55
|
+
if (m2.type === "body") chunks.push(new Uint8Array(m2.chunk));
|
|
56
|
+
else if (m2.type === "end") resolve(injectBootstrap(chunks, msg, headers, src, Number(port)));
|
|
57
|
+
else if (m2.type === "error") resolve(new Response("preview error: " + m2.message, { status: 502 }));
|
|
58
|
+
};
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const stream = new ReadableStream({
|
|
62
|
+
start(controller) {
|
|
63
|
+
mc.port1.onmessage = (e2) => {
|
|
64
|
+
const m2 = e2.data;
|
|
65
|
+
if (m2.type === "body") controller.enqueue(new Uint8Array(m2.chunk));
|
|
66
|
+
else if (m2.type === "end") controller.close();
|
|
67
|
+
else if (m2.type === "error") controller.error(new Error(m2.message));
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
resolve(new Response(stream, { status: msg.status, statusText: msg.statusText, headers }));
|
|
55
72
|
};
|
|
56
73
|
client.postMessage(
|
|
57
74
|
{ type: "ay-preview-fetch", src, port: Number(port), method: request.method, path: rest, headers, body },
|
|
@@ -60,6 +77,37 @@ async function proxyPreview(request, src, port, rest) {
|
|
|
60
77
|
});
|
|
61
78
|
}
|
|
62
79
|
|
|
80
|
+
// Concatenate the buffered HTML chunks, strip CSP, and inject a bootstrap
|
|
81
|
+
// <script> that replaces window.WebSocket with the parent console's tunneled
|
|
82
|
+
// shim — so a dev server's own sockets (Vite HMR) ride the P2P tunnel too. Runs
|
|
83
|
+
// first (right after <head>) so the override is in place before app scripts.
|
|
84
|
+
function injectBootstrap(chunks, msg, headers, src, port) {
|
|
85
|
+
let total = 0;
|
|
86
|
+
for (const c of chunks) total += c.byteLength;
|
|
87
|
+
const all = new Uint8Array(total);
|
|
88
|
+
let off = 0;
|
|
89
|
+
for (const c of chunks) {
|
|
90
|
+
all.set(c, off);
|
|
91
|
+
off += c.byteLength;
|
|
92
|
+
}
|
|
93
|
+
const raw = new TextDecoder().decode(all);
|
|
94
|
+
const boot =
|
|
95
|
+
"<script>(function(){try{var mk=window.parent&&window.parent.__ayMakeWS;" +
|
|
96
|
+
"if(mk)window.WebSocket=mk(" +
|
|
97
|
+
JSON.stringify(src) +
|
|
98
|
+
"," +
|
|
99
|
+
JSON.stringify(port) +
|
|
100
|
+
");}catch(e){}})();</" +
|
|
101
|
+
"script>";
|
|
102
|
+
const html = /<head[^>]*>/i.test(raw)
|
|
103
|
+
? raw.replace(/<head[^>]*>/i, (m) => m + boot)
|
|
104
|
+
: boot + raw;
|
|
105
|
+
headers.delete("content-security-policy");
|
|
106
|
+
headers.delete("content-security-policy-report-only");
|
|
107
|
+
headers.delete("content-length");
|
|
108
|
+
return new Response(html, { status: msg.status, statusText: msg.statusText, headers });
|
|
109
|
+
}
|
|
110
|
+
|
|
63
111
|
const SHELL = [
|
|
64
112
|
"./",
|
|
65
113
|
"./index.html",
|
|
@@ -98,7 +146,9 @@ self.addEventListener("fetch", (e) => {
|
|
|
98
146
|
const own = PREVIEW.exec(url.pathname);
|
|
99
147
|
if (own) {
|
|
100
148
|
const rest = (own[3] || "/") + url.search;
|
|
101
|
-
|
|
149
|
+
// Navigations to the /p/ root/route may be an HTML doc → allow WS-shim
|
|
150
|
+
// injection; app subresources (below) never inject.
|
|
151
|
+
e.respondWith(proxyPreview(req, decodeURIComponent(own[1]), own[2], rest, true));
|
|
102
152
|
return;
|
|
103
153
|
}
|
|
104
154
|
e.respondWith(maybePreviewFromClient(e, req, url));
|
|
@@ -112,7 +162,9 @@ async function maybePreviewFromClient(e, req, url) {
|
|
|
112
162
|
const client = await self.clients.get(clientId).catch(() => null);
|
|
113
163
|
const cm = client && PREVIEW.exec(new URL(client.url).pathname);
|
|
114
164
|
if (cm) {
|
|
115
|
-
|
|
165
|
+
// Subresources (Vite's /@vite/client, module chunks, etc.) never get the
|
|
166
|
+
// WS shim injected — only the top-level /p/ navigation does.
|
|
167
|
+
return proxyPreview(req, decodeURIComponent(cm[1]), cm[2], url.pathname + url.search, false);
|
|
116
168
|
}
|
|
117
169
|
}
|
|
118
170
|
return shellFetch(req, url);
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import "./ts-DDsICrj-.js";
|
|
2
|
-
import "./logger-CDIsZ-Pp.js";
|
|
3
|
-
import "./versionChecker-B8qEzYDu.js";
|
|
4
|
-
import "./pidStore-BIvsBQ8X.js";
|
|
5
|
-
import "./globalPidIndex-CoNr7tS8.js";
|
|
6
|
-
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-Bdj9qDRm.js";
|
|
7
|
-
|
|
8
|
-
export { SUPPORTED_CLIS };
|