glimmervoid 0.52.2-next.719 → 0.52.2-next.721
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/bin/glimmervoid.js +16 -16
- package/dist/chunks/{adapters-QeHAvLKT.js → adapters-C4VBHYHo.js} +6 -6
- package/dist/chunks/{adapters-Dvb7KXnO.js → adapters-C7CEI0fq.js} +1 -1
- package/dist/chunks/{agent-api-cli-CZPOzaRb.js → agent-api-cli-B571XTNc.js} +3 -3
- package/dist/chunks/agent-api-cli-DdnM_H4H.js +1 -0
- package/dist/chunks/{agent-api-core-B3qq8oek.js → agent-api-core-CvNwRgNZ.js} +3 -9
- package/dist/chunks/{agent-setup-cli-Dbwb7jtf.js → agent-setup-cli-DxlHDthm.js} +1 -1
- package/dist/chunks/{config-BdItI6F3.js → config-ClF7i8C6.js} +2 -2
- package/dist/chunks/{config-store-CHFS_vNw.js → config-store-201cn0A1.js} +4 -4
- package/dist/chunks/config-store-BrDX0ssT.js +1 -0
- package/dist/chunks/{grok-B_9N78_d.js → grok-kT9nCRev.js} +1 -1
- package/dist/chunks/kimi-CSCbrloe.js +1 -0
- package/dist/chunks/{kimi-YAqn6G1W.js → kimi-DJOALMiY.js} +2 -2
- package/dist/chunks/{main-BHMjdBfS.js → main-HIBk_nyb.js} +52 -30
- package/dist/chunks/pack-agent-BkxnZGft.js +432 -0
- package/dist/chunks/{pack-bridge-BgB2p-Hg.js → pack-bridge-CMzPKvPZ.js} +1 -1
- package/dist/chunks/{pack-agent-BY3gEwjx.js → pack-files-CKm6gcGR.js} +110 -573
- package/dist/chunks/{packs-cli-CjAfzj-I.js → packs-cli-ByiipDas.js} +6 -5
- package/dist/chunks/{pair-cli-BG4FUb5y.js → pair-cli-CDhWmGKV.js} +2 -2
- package/dist/chunks/{pr-flows-cli-D8Njf3EF.js → pr-flows-cli-QUMg7_Oz.js} +63 -37
- package/dist/chunks/{pr-flows-external-CaziHHty.js → pr-flows-external-QJdRYWnW.js} +10 -21
- package/dist/chunks/{remote-config-Dm7-_lHb.js → remote-config-eN6GelcO.js} +1 -1
- package/dist/chunks/{session-DC6dGYjf.js → session-C_EdlPyW.js} +35 -22
- package/dist/chunks/{settings-cli-C39NaAB1.js → settings-cli-D9dmhoSG.js} +5 -5
- package/dist/chunks/{settings-readout-core-CtligFID.js → settings-readout-core-87Ajew__.js} +2 -2
- package/dist/chunks/{spawn-env-aigWM-7F.js → spawn-env-_fjRJ34f.js} +3 -2
- package/dist/chunks/{ssh-sign-cli-DmT55jSe.js → ssh-sign-cli-Lh9uTM9h.js} +2 -2
- package/dist/chunks/{whiteboard-svg-core-tSYpbhy7.js → whiteboard-svg-core-D6_Clunv.js} +1 -1
- package/dist/client/assets/{action-status-CsphqLIp.js → action-status-57cP9fbP.js} +1 -1
- package/dist/client/assets/action-status-57cP9fbP.js.br +0 -0
- package/dist/client/assets/{arena-panel-Dwp8y2NZ.js → arena-panel-DBK3FOgW.js} +2 -2
- package/dist/client/assets/arena-panel-DBK3FOgW.js.br +0 -0
- package/dist/client/assets/{benchmark-panel-CYRs6njt.js → benchmark-panel-DzF5soM-.js} +1 -1
- package/dist/client/assets/benchmark-panel-DzF5soM-.js.br +0 -0
- package/dist/client/assets/{boards-view-BNqEed2T.js → boards-view-BD_SWx3l.js} +1 -1
- package/dist/client/assets/boards-view-BD_SWx3l.js.br +0 -0
- package/dist/client/assets/button-CVmKU9qL.js +1 -0
- package/dist/client/assets/button-CVmKU9qL.js.br +0 -0
- package/dist/client/assets/{card-actions-BF783lHX.js → card-actions-BNX4cQ22.js} +1 -1
- package/dist/client/assets/{card-registry-D_kyKNFR.js → card-registry-B2RFZmB2.js} +1 -1
- package/dist/client/assets/card-registry-B2RFZmB2.js.br +0 -0
- package/dist/client/assets/{community-panel-DS3UkApo.js → community-panel-BvMkWjmy.js} +1 -1
- package/dist/client/assets/community-panel-BvMkWjmy.js.br +0 -0
- package/dist/client/assets/{control-ws-BFTcI_Sk.js → control-ws-BpCKssAD.js} +1 -1
- package/dist/client/assets/control-ws-BpCKssAD.js.br +0 -0
- package/dist/client/assets/{dialogs-Cx0QONjF.js → dialogs-BA9rPYGx.js} +1 -1
- package/dist/client/assets/dialogs-BA9rPYGx.js.br +0 -0
- package/dist/client/assets/{doc-editor-ui-CQ-SsVYm.js → doc-editor-ui-njV-48Mt.js} +1 -1
- package/dist/client/assets/doc-editor-ui-njV-48Mt.js.br +0 -0
- package/dist/client/assets/{feature-hint-Bo_OZ6CQ.js → feature-hint-DT1NDTe-.js} +1 -1
- package/dist/client/assets/feature-hint-DT1NDTe-.js.br +0 -0
- package/dist/client/assets/{first-run-checklist-CZMpSceK.js → first-run-checklist-Dt8GFysX.js} +1 -1
- package/dist/client/assets/first-run-checklist-Dt8GFysX.js.br +0 -0
- package/dist/client/assets/{hooks-panel-D_WWcD6R.js → hooks-panel-B1SRjYyy.js} +1 -1
- package/dist/client/assets/hooks-panel-B1SRjYyy.js.br +0 -0
- package/dist/client/assets/{index-DuWDE9I2.js → index-D4HOaloI.js} +5 -5
- package/dist/client/assets/index-D4HOaloI.js.br +0 -0
- package/dist/client/assets/{issues-panel-D1qL_x0F.js → issues-panel-Cgckhdt0.js} +1 -1
- package/dist/client/assets/issues-panel-Cgckhdt0.js.br +0 -0
- package/dist/client/assets/{lane-read-token-step-bzSufW14.js → lane-read-token-step-DuSAEY-V.js} +1 -1
- package/dist/client/assets/lane-read-token-step-DuSAEY-V.js.br +0 -0
- package/dist/client/assets/{menu-YgFIqpxB.js → menu-CgH4aQPE.js} +1 -1
- package/dist/client/assets/menu-CgH4aQPE.js.br +0 -0
- package/dist/client/assets/{modal-CmB-mwt3.js → modal-DKFrxnH8.js} +1 -1
- package/dist/client/assets/modal-DKFrxnH8.js.br +0 -0
- package/dist/client/assets/{my-prs-panel-C_GmBrXA.js → my-prs-panel-D98hfuOw.js} +1 -1
- package/dist/client/assets/my-prs-panel-D98hfuOw.js.br +0 -0
- package/dist/client/assets/{nyan-cat-nQzxNUPN.js → nyan-cat-C1hMNKIf.js} +1 -1
- package/dist/client/assets/nyan-cat-C1hMNKIf.js.br +0 -0
- package/dist/client/assets/{phone-shell-qUdIewhB.js → phone-shell-DSKoMk_-.js} +1 -1
- package/dist/client/assets/phone-shell-DSKoMk_-.js.br +0 -0
- package/dist/client/assets/{plan-face-BD13Z8Nm.js → plan-face-DaeKVB_n.js} +1 -1
- package/dist/client/assets/plan-face-DaeKVB_n.js.br +0 -0
- package/dist/client/assets/{plan-render-BrxIi33z.js → plan-render-7BMe1GQQ.js} +1 -1
- package/dist/client/assets/plan-render-7BMe1GQQ.js.br +0 -0
- package/dist/client/assets/{pr-queue-columns-B5uPcvV4.js → pr-queue-columns-B9V9mLXw.js} +1 -1
- package/dist/client/assets/pr-queue-columns-B9V9mLXw.js.br +0 -0
- package/dist/client/assets/{pr-status-icon-C-44DKID.js → pr-status-icon-Bx6wInOj.js} +1 -1
- package/dist/client/assets/pr-status-icon-Bx6wInOj.js.br +0 -0
- package/dist/client/assets/{radar-panel-BWqCzwjR.js → radar-panel-F_mlKslB.js} +1 -1
- package/dist/client/assets/radar-panel-F_mlKslB.js.br +0 -0
- package/dist/client/assets/{repo-roots-adder-ByJ8XDCb.js → repo-roots-adder-DQQmm200.js} +1 -1
- package/dist/client/assets/repo-roots-adder-DQQmm200.js.br +0 -0
- package/dist/client/assets/{resume-dialog-q81xS4Fg.js → resume-dialog-CF4AwHD4.js} +1 -1
- package/dist/client/assets/resume-dialog-CF4AwHD4.js.br +0 -0
- package/dist/client/assets/{review-queue-panel-BBIesmKx.js → review-queue-panel-D-vbTvIc.js} +1 -1
- package/dist/client/assets/review-queue-panel-D-vbTvIc.js.br +0 -0
- package/dist/client/assets/{session-actions-D-XfZCX_.js → session-actions-Oqr5gh-y.js} +2 -2
- package/dist/client/assets/session-actions-Oqr5gh-y.js.br +0 -0
- package/dist/client/assets/{session-row-MJx4kfgA.js → session-row-BNMG0b7h.js} +1 -1
- package/dist/client/assets/session-row-BNMG0b7h.js.br +0 -0
- package/dist/client/assets/{session-tick-Cu958tSf.js → session-tick-CHJ0mY2-.js} +1 -1
- package/dist/client/assets/session-tick-CHJ0mY2-.js.br +0 -0
- package/dist/client/assets/{settings-panel-DVDMeuHO.js → settings-panel-BG7RfpWI.js} +2 -2
- package/dist/client/assets/settings-panel-BG7RfpWI.js.br +0 -0
- package/dist/client/assets/{setup-step-qMoYS0vS.js → setup-step-B8uQtgL-.js} +1 -1
- package/dist/client/assets/setup-step-B8uQtgL-.js.br +0 -0
- package/dist/client/assets/{trace-panel-CPRamHl5.js → trace-panel-DXuMaFQf.js} +1 -1
- package/dist/client/assets/trace-panel-DXuMaFQf.js.br +0 -0
- package/dist/client/assets/{usage-panel-DBHS_Yxm.js → usage-panel-DTeMQgAs.js} +1 -1
- package/dist/client/assets/usage-panel-DTeMQgAs.js.br +0 -0
- package/dist/client/assets/{your-day-tip-BRzwTD3I.js → your-day-tip-npG2dZYF.js} +1 -1
- package/dist/client/assets/your-day-tip-npG2dZYF.js.br +0 -0
- package/dist/client/index.html +12 -12
- package/dist/client/index.html.br +0 -0
- package/dist/schema/pack.v1.json +23 -11
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/agent-api-cli-CqfBqnBN.js +0 -1
- package/dist/chunks/config-store-CoLRNzto.js +0 -1
- package/dist/chunks/kimi-_j4Imdso.js +0 -1
- package/dist/chunks/packs-cli-DE8O3Xt5.js +0 -1
- package/dist/client/assets/action-status-CsphqLIp.js.br +0 -0
- package/dist/client/assets/arena-panel-Dwp8y2NZ.js.br +0 -0
- package/dist/client/assets/benchmark-panel-CYRs6njt.js.br +0 -0
- package/dist/client/assets/boards-view-BNqEed2T.js.br +0 -0
- package/dist/client/assets/button-oL7ZznmQ.js +0 -1
- package/dist/client/assets/button-oL7ZznmQ.js.br +0 -0
- package/dist/client/assets/card-registry-D_kyKNFR.js.br +0 -0
- package/dist/client/assets/community-panel-DS3UkApo.js.br +0 -0
- package/dist/client/assets/control-ws-BFTcI_Sk.js.br +0 -0
- package/dist/client/assets/dialogs-Cx0QONjF.js.br +0 -0
- package/dist/client/assets/doc-editor-ui-CQ-SsVYm.js.br +0 -0
- package/dist/client/assets/feature-hint-Bo_OZ6CQ.js.br +0 -0
- package/dist/client/assets/first-run-checklist-CZMpSceK.js.br +0 -0
- package/dist/client/assets/hooks-panel-D_WWcD6R.js.br +0 -0
- package/dist/client/assets/index-DuWDE9I2.js.br +0 -0
- package/dist/client/assets/issues-panel-D1qL_x0F.js.br +0 -0
- package/dist/client/assets/lane-read-token-step-bzSufW14.js.br +0 -0
- package/dist/client/assets/menu-YgFIqpxB.js.br +0 -0
- package/dist/client/assets/modal-CmB-mwt3.js.br +0 -0
- package/dist/client/assets/my-prs-panel-C_GmBrXA.js.br +0 -0
- package/dist/client/assets/nyan-cat-nQzxNUPN.js.br +0 -0
- package/dist/client/assets/phone-shell-qUdIewhB.js.br +0 -0
- package/dist/client/assets/plan-face-BD13Z8Nm.js.br +0 -0
- package/dist/client/assets/plan-render-BrxIi33z.js.br +0 -0
- package/dist/client/assets/pr-queue-columns-B5uPcvV4.js.br +0 -4
- package/dist/client/assets/pr-status-icon-C-44DKID.js.br +0 -0
- package/dist/client/assets/radar-panel-BWqCzwjR.js.br +0 -0
- package/dist/client/assets/repo-roots-adder-ByJ8XDCb.js.br +0 -0
- package/dist/client/assets/resume-dialog-q81xS4Fg.js.br +0 -0
- package/dist/client/assets/review-queue-panel-BBIesmKx.js.br +0 -0
- package/dist/client/assets/session-actions-D-XfZCX_.js.br +0 -0
- package/dist/client/assets/session-row-MJx4kfgA.js.br +0 -0
- package/dist/client/assets/session-tick-Cu958tSf.js.br +0 -0
- package/dist/client/assets/settings-panel-DVDMeuHO.js.br +0 -0
- package/dist/client/assets/setup-step-qMoYS0vS.js.br +0 -0
- package/dist/client/assets/trace-panel-CPRamHl5.js.br +0 -0
- package/dist/client/assets/usage-panel-DBHS_Yxm.js.br +0 -0
- package/dist/client/assets/your-day-tip-BRzwTD3I.js.br +0 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { fn as PR_FLOW_PLACEHOLDERS_BY_KIND } from "./session-C_EdlPyW.js";
|
|
2
|
+
import { n as packBridgeJsonSchemaText } from "./pack-bridge-CMzPKvPZ.js";
|
|
3
|
+
import { t as parseJsonOrNull } from "./json-core-If8h-Qgy.js";
|
|
4
|
+
import { D as prFlowsPacksOf, F as unknownPlaceholderMessage, c as PackHeader, m as expandPlaceholders, n as declaredPanels, o as readPackDir, s as PACK_FILE_NAME, t as PACKS_DIR_NAME, u as packJsonSchemaText, x as packRuleErrors, y as packApproval } from "./pack-files-CKm6gcGR.js";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
//#region server/core/host-policy.ts
|
|
8
|
+
var LOOPBACK_HOST_RE = /^(?:localhost|127(?:\.\d{1,3}){3}|\[::1\]|\[::ffff:127(?:\.\d{1,3}){3}\])$/;
|
|
9
|
+
function hostOnly(value) {
|
|
10
|
+
const trimmed = String(value == null ? "" : value).trim().toLowerCase();
|
|
11
|
+
if (trimmed === "") return "";
|
|
12
|
+
if (trimmed.startsWith("[")) {
|
|
13
|
+
const close = trimmed.indexOf("]");
|
|
14
|
+
if (close === -1) return "";
|
|
15
|
+
return trimmed.slice(0, close + 1);
|
|
16
|
+
}
|
|
17
|
+
const colon = trimmed.lastIndexOf(":");
|
|
18
|
+
if (colon === -1) return trimmed;
|
|
19
|
+
return trimmed.slice(0, colon);
|
|
20
|
+
}
|
|
21
|
+
function hostMatches(allowed, candidate) {
|
|
22
|
+
if (allowed === "") return false;
|
|
23
|
+
if (allowed === candidate) return true;
|
|
24
|
+
if (!allowed.startsWith("*.")) return false;
|
|
25
|
+
const suffix = allowed.slice(1);
|
|
26
|
+
return candidate.endsWith(suffix) && candidate.length > suffix.length;
|
|
27
|
+
}
|
|
28
|
+
function decideHostAllowed(hostHeader, allowedHosts = []) {
|
|
29
|
+
if (hostHeader == null || hostHeader === "") return true;
|
|
30
|
+
const host = hostOnly(hostHeader);
|
|
31
|
+
if (host === "") return false;
|
|
32
|
+
if (LOOPBACK_HOST_RE.test(host)) return true;
|
|
33
|
+
return (Array.isArray(allowedHosts) ? allowedHosts : [allowedHosts]).some((entry) => hostMatches(hostOnly(entry), host));
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region server/packs/core/pack-core.ts
|
|
37
|
+
function packNeeds(pack) {
|
|
38
|
+
return [...pack.header.requires.env.map((name) => `env ${name}`), ...pack.header.requires.programs.map((program) => `program ${program}`)];
|
|
39
|
+
}
|
|
40
|
+
function packThemes(pack) {
|
|
41
|
+
return pack.ui?.ok ? pack.ui.value.themes : [];
|
|
42
|
+
}
|
|
43
|
+
function approvedPackThemes(packs) {
|
|
44
|
+
return packs.flatMap((pack) => packThemes(pack).map(({ id, ...palette }) => ({
|
|
45
|
+
id: `${pack.header.name}/${id}`,
|
|
46
|
+
palette
|
|
47
|
+
})));
|
|
48
|
+
}
|
|
49
|
+
function packPanels(pack) {
|
|
50
|
+
return pack.ui?.ok ? pack.ui.value.panels : [];
|
|
51
|
+
}
|
|
52
|
+
function packFileUrl(pack, accessKey, filePath) {
|
|
53
|
+
return `/packs/${encodeURIComponent(pack.header.name)}/${accessKey}/files/${filePath.split("/").map(encodeURIComponent).join("/")}`;
|
|
54
|
+
}
|
|
55
|
+
function approvedPackPanels(packs, accessKeyOf) {
|
|
56
|
+
return packs.flatMap((pack) => packPanels(pack).map((panel) => ({
|
|
57
|
+
viewId: `pack:${pack.header.name}/${panel.id}`,
|
|
58
|
+
label: panel.label,
|
|
59
|
+
entryUrl: packFileUrl(pack, accessKeyOf(pack), panel.entry),
|
|
60
|
+
iconUrl: panel.icon ? packFileUrl(pack, accessKeyOf(pack), panel.icon) : null,
|
|
61
|
+
reads: panel.reads
|
|
62
|
+
})));
|
|
63
|
+
}
|
|
64
|
+
var PACK_FILE_MIME_BY_EXTENSION = {
|
|
65
|
+
".html": "text/html; charset=utf-8",
|
|
66
|
+
".js": "text/javascript; charset=utf-8",
|
|
67
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
68
|
+
".css": "text/css; charset=utf-8",
|
|
69
|
+
".json": "application/json; charset=utf-8",
|
|
70
|
+
".svg": "image/svg+xml",
|
|
71
|
+
".png": "image/png",
|
|
72
|
+
".jpg": "image/jpeg",
|
|
73
|
+
".jpeg": "image/jpeg",
|
|
74
|
+
".gif": "image/gif",
|
|
75
|
+
".webp": "image/webp",
|
|
76
|
+
".woff2": "font/woff2",
|
|
77
|
+
".txt": "text/plain; charset=utf-8"
|
|
78
|
+
};
|
|
79
|
+
var PACK_PANEL_CONTENT_POLICY = [
|
|
80
|
+
"sandbox allow-scripts allow-forms",
|
|
81
|
+
"default-src 'self' data: blob:",
|
|
82
|
+
"script-src 'self' 'unsafe-inline'",
|
|
83
|
+
"style-src 'self' 'unsafe-inline'",
|
|
84
|
+
"connect-src 'none'",
|
|
85
|
+
"form-action 'none'",
|
|
86
|
+
"frame-src 'none'",
|
|
87
|
+
"base-uri 'none'"
|
|
88
|
+
].join("; ");
|
|
89
|
+
function packFileMime(filePath) {
|
|
90
|
+
return PACK_FILE_MIME_BY_EXTENSION[path.posix.extname(filePath).toLowerCase()] ?? "application/octet-stream";
|
|
91
|
+
}
|
|
92
|
+
var OPAQUE_ORIGIN = "null";
|
|
93
|
+
function packFileHeaders(filePath, requestOrigin) {
|
|
94
|
+
const headers = {
|
|
95
|
+
"Content-Security-Policy": PACK_PANEL_CONTENT_POLICY,
|
|
96
|
+
"X-Content-Type-Options": "nosniff",
|
|
97
|
+
"Referrer-Policy": "no-referrer",
|
|
98
|
+
"Content-Type": packFileMime(filePath),
|
|
99
|
+
Vary: "Origin"
|
|
100
|
+
};
|
|
101
|
+
return requestOrigin === OPAQUE_ORIGIN ? {
|
|
102
|
+
...headers,
|
|
103
|
+
"Access-Control-Allow-Origin": OPAQUE_ORIGIN
|
|
104
|
+
} : headers;
|
|
105
|
+
}
|
|
106
|
+
function uiSectionErrors(pack) {
|
|
107
|
+
return pack.ui && !pack.ui.ok ? pack.ui.errors : [];
|
|
108
|
+
}
|
|
109
|
+
function validPackRow(pack, approvedFingerprints) {
|
|
110
|
+
const { prFlowsPacks, warnings: prFlowsErrors } = prFlowsPacksOf([pack]);
|
|
111
|
+
const sectionErrors = [...prFlowsErrors, ...uiSectionErrors(pack)];
|
|
112
|
+
const [prFlowsPack] = prFlowsPacks;
|
|
113
|
+
return {
|
|
114
|
+
name: pack.header.name,
|
|
115
|
+
version: pack.header.version,
|
|
116
|
+
description: pack.header.description ?? null,
|
|
117
|
+
dir: pack.dir,
|
|
118
|
+
state: approvedFingerprints.has(pack.fingerprint) ? "approved" : "pending",
|
|
119
|
+
fingerprint: pack.fingerprint,
|
|
120
|
+
files: [...pack.filesByPath.keys()].sort(),
|
|
121
|
+
needs: packNeeds(pack),
|
|
122
|
+
missingRequires: pack.missingRequires,
|
|
123
|
+
prFlows: prFlowsPack ? packApproval(prFlowsPack) : null,
|
|
124
|
+
themes: packThemes(pack).map((theme) => ({
|
|
125
|
+
id: theme.id,
|
|
126
|
+
label: theme.label,
|
|
127
|
+
mode: theme.mode
|
|
128
|
+
})),
|
|
129
|
+
panels: packPanels(pack).map((panel) => ({
|
|
130
|
+
id: panel.id,
|
|
131
|
+
label: panel.label,
|
|
132
|
+
reads: panel.reads
|
|
133
|
+
})),
|
|
134
|
+
errors: sectionErrors
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function packRow(packDir, read, approvedFingerprints) {
|
|
138
|
+
if (read.ok) return validPackRow(read.pack, approvedFingerprints);
|
|
139
|
+
return {
|
|
140
|
+
name: path.basename(packDir),
|
|
141
|
+
version: null,
|
|
142
|
+
description: null,
|
|
143
|
+
dir: packDir,
|
|
144
|
+
state: "invalid",
|
|
145
|
+
fingerprint: null,
|
|
146
|
+
files: [],
|
|
147
|
+
needs: [],
|
|
148
|
+
missingRequires: [],
|
|
149
|
+
prFlows: null,
|
|
150
|
+
themes: [],
|
|
151
|
+
panels: [],
|
|
152
|
+
errors: read.errors
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function pendingPackNote(row) {
|
|
156
|
+
return `The pack '${row.name}' waits for your approval in Settings, Packs`;
|
|
157
|
+
}
|
|
158
|
+
var MAX_REFERENCE_LENGTH = 512;
|
|
159
|
+
var HTML_REFERENCE_PATTERN = new RegExp(`\\b(src|href|poster|srcset|imagesrcset)\\s*=\\s*${`(?:"([^"]{0,${MAX_REFERENCE_LENGTH}})"|'([^']{0,${MAX_REFERENCE_LENGTH}})'|([^\\s"'>]{1,${MAX_REFERENCE_LENGTH}}))`}`, "gi");
|
|
160
|
+
var CSS_REFERENCE_PATTERN = new RegExp(`url\\(\\s*["']?([^"')]{0,${MAX_REFERENCE_LENGTH}})["']?\\s*\\)|@import\\s+["']([^"']{1,${MAX_REFERENCE_LENGTH}})["']`, "gi");
|
|
161
|
+
var INERT_REFERENCE_PATTERN = /^(?:#|data:|blob:|javascript:|about:|mailto:)/i;
|
|
162
|
+
var REMOTE_REFERENCE_PATTERN = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
163
|
+
function withoutDelimited(text, opener, closer) {
|
|
164
|
+
const keptParts = [];
|
|
165
|
+
let cursor = 0;
|
|
166
|
+
while (cursor < text.length) {
|
|
167
|
+
const openAt = text.indexOf(opener, cursor);
|
|
168
|
+
if (openAt === -1) return [...keptParts, text.slice(cursor)].join("");
|
|
169
|
+
keptParts.push(text.slice(cursor, openAt));
|
|
170
|
+
const closeAt = text.indexOf(closer, openAt + opener.length);
|
|
171
|
+
if (closeAt === -1) return keptParts.join("");
|
|
172
|
+
cursor = closeAt + closer.length;
|
|
173
|
+
}
|
|
174
|
+
return keptParts.join("");
|
|
175
|
+
}
|
|
176
|
+
function attributeUrls(attributeName, value) {
|
|
177
|
+
if (!attributeName.toLowerCase().endsWith("srcset")) return [value];
|
|
178
|
+
return value.split(",").map((candidate) => candidate.trim().split(/\s+/)[0] ?? "");
|
|
179
|
+
}
|
|
180
|
+
var JS_IMPORT_PATTERN = new RegExp(`\\b(?:import|export)\\b[^;'"]{0,${MAX_REFERENCE_LENGTH}}?\\bfrom\\s{0,64}["']([^"']{1,${MAX_REFERENCE_LENGTH}})["']|\\bimport\\s{0,64}\\(?\\s{0,64}["']([^"']{1,${MAX_REFERENCE_LENGTH}})["']`, "g");
|
|
181
|
+
var LINE_COMMENT_PATTERN = /^[ \t]*\/\/.*$/gm;
|
|
182
|
+
var RELATIVE_IMPORT_PATTERN = /^\.{1,2}\//;
|
|
183
|
+
function isScriptFile(filePath) {
|
|
184
|
+
return filePath.endsWith(".js") || filePath.endsWith(".mjs");
|
|
185
|
+
}
|
|
186
|
+
function jsImportsIn(text) {
|
|
187
|
+
return [...withoutDelimited(text, "/*", "*/").replace(LINE_COMMENT_PATTERN, "").matchAll(JS_IMPORT_PATTERN)].map((match) => ({
|
|
188
|
+
url: match[1] ?? match[2] ?? "",
|
|
189
|
+
isImport: true
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
function linkReferences(urls) {
|
|
193
|
+
return urls.map((url) => ({
|
|
194
|
+
url,
|
|
195
|
+
isImport: false
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
function inlineScriptsIn(html) {
|
|
199
|
+
const scriptBodies = [];
|
|
200
|
+
const lowerHtml = html.toLowerCase();
|
|
201
|
+
let cursor = 0;
|
|
202
|
+
while (cursor < html.length) {
|
|
203
|
+
const openAt = lowerHtml.indexOf("<script", cursor);
|
|
204
|
+
const bodyStart = openAt === -1 ? -1 : lowerHtml.indexOf(">", openAt);
|
|
205
|
+
const closeAt = bodyStart === -1 ? -1 : lowerHtml.indexOf("<\/script", bodyStart);
|
|
206
|
+
if (closeAt === -1) return scriptBodies;
|
|
207
|
+
scriptBodies.push(html.slice(bodyStart + 1, closeAt));
|
|
208
|
+
cursor = closeAt;
|
|
209
|
+
}
|
|
210
|
+
return scriptBodies;
|
|
211
|
+
}
|
|
212
|
+
function rawReferencesIn(filePath, text) {
|
|
213
|
+
if (isScriptFile(filePath)) return jsImportsIn(text);
|
|
214
|
+
const withoutComments = withoutDelimited(withoutDelimited(text, "<!--", "-->"), "/*", "*/");
|
|
215
|
+
const cssReferences = linkReferences([...withoutComments.matchAll(CSS_REFERENCE_PATTERN)].map((match) => match[1] ?? match[2] ?? ""));
|
|
216
|
+
if (!filePath.endsWith(".html")) return cssReferences;
|
|
217
|
+
return [
|
|
218
|
+
...linkReferences([...withoutComments.matchAll(HTML_REFERENCE_PATTERN)].flatMap((match) => attributeUrls(match[1] ?? "", match[2] ?? match[3] ?? match[4] ?? ""))),
|
|
219
|
+
...inlineScriptsIn(withoutComments).flatMap(jsImportsIn),
|
|
220
|
+
...cssReferences
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
function referencesIn(filePath, text) {
|
|
224
|
+
return rawReferencesIn(filePath, text).map((reference) => ({
|
|
225
|
+
...reference,
|
|
226
|
+
url: reference.url.trim()
|
|
227
|
+
})).filter((reference) => reference.url !== "" && !INERT_REFERENCE_PATTERN.test(reference.url));
|
|
228
|
+
}
|
|
229
|
+
function decodedPath(reference) {
|
|
230
|
+
try {
|
|
231
|
+
return decodeURIComponent(reference);
|
|
232
|
+
} catch {
|
|
233
|
+
return reference;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function referenceError(filePath, { url: reference, isImport }, filesByPath) {
|
|
237
|
+
if (REMOTE_REFERENCE_PATTERN.test(reference)) return `${filePath} loads ${reference}, but a panel has no network; put that file in the pack`;
|
|
238
|
+
if (reference.startsWith("/")) return `${filePath} refers to ${reference}, an absolute path that leaves the pack; use a path relative to ${filePath}`;
|
|
239
|
+
if (isImport && !RELATIVE_IMPORT_PATTERN.test(reference)) return `${filePath} imports ${reference}, but a panel has no package resolver; import a file in the pack by a path starting with ./ or ../`;
|
|
240
|
+
const referencedPath = referencedPackPath(filePath, reference);
|
|
241
|
+
if (referencedPath.startsWith("../")) return `${filePath} refers to ${reference}, which is outside the pack`;
|
|
242
|
+
return filesByPath.has(referencedPath) ? null : `${filePath} refers to ${reference}, which is not a file in the pack`;
|
|
243
|
+
}
|
|
244
|
+
function referencedPackPath(filePath, reference) {
|
|
245
|
+
return path.posix.normalize(path.posix.join(path.posix.dirname(filePath), decodedPath(reference.replace(/[?#].*$/, ""))));
|
|
246
|
+
}
|
|
247
|
+
function panelReferenceErrors(filesByPath) {
|
|
248
|
+
return [...filesByPath].filter(([filePath]) => filePath.endsWith(".html") || filePath.endsWith(".css") || isScriptFile(filePath)).flatMap(([filePath, bytes]) => referencesIn(filePath, bytes.toString("utf8")).map((reference) => referenceError(filePath, reference, filesByPath)).filter((error) => error !== null));
|
|
249
|
+
}
|
|
250
|
+
var SUBSCRIBED_TOPICS_PATTERN = /subscribe\(\s*\[([^\]]{0,500})\]|kind\s*:\s*['"]subscribe['"][^}]{0,500}?topics\s*:\s*\[([^\]]{0,500})\]/g;
|
|
251
|
+
function filesLoadedFrom(entry, filesByPath) {
|
|
252
|
+
const loadedPaths = /* @__PURE__ */ new Set();
|
|
253
|
+
const pendingPaths = [entry];
|
|
254
|
+
while (pendingPaths.length > 0) {
|
|
255
|
+
const filePath = pendingPaths.pop() ?? "";
|
|
256
|
+
const bytes = filesByPath.get(filePath);
|
|
257
|
+
if (loadedPaths.has(filePath) || bytes === void 0) continue;
|
|
258
|
+
loadedPaths.add(filePath);
|
|
259
|
+
if (!filePath.endsWith(".html") && !isScriptFile(filePath)) continue;
|
|
260
|
+
pendingPaths.push(...referencesIn(filePath, bytes.toString("utf8")).filter(({ url }) => !REMOTE_REFERENCE_PATTERN.test(url) && !url.startsWith("/")).map(({ url }) => referencedPackPath(filePath, url)));
|
|
261
|
+
}
|
|
262
|
+
return [...loadedPaths].filter((filePath) => filePath.endsWith(".html") || isScriptFile(filePath));
|
|
263
|
+
}
|
|
264
|
+
function subscribedTopicsIn(text) {
|
|
265
|
+
return [...text.matchAll(SUBSCRIBED_TOPICS_PATTERN)].flatMap((match) => [...(match[1] ?? match[2] ?? "").matchAll(/['"]([^'"]+)['"]/g)].map((topic) => topic[1] ?? ""));
|
|
266
|
+
}
|
|
267
|
+
function undeclaredSubscriptionErrors(filesByPath, panels) {
|
|
268
|
+
return panels.flatMap((panel) => filesLoadedFrom(panel.entry, filesByPath).flatMap((filePath) => [...new Set(subscribedTopicsIn(filesByPath.get(filePath)?.toString("utf8") ?? ""))].filter((topic) => !panel.reads.includes(topic)).map((topic) => `${filePath} subscribes to '${topic}', which panel ${panel.id} does not list under reads, so it never arrives there; add it to that panel's reads or drop it`)));
|
|
269
|
+
}
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region server/packs/pack-check.ts
|
|
272
|
+
function pageErrors(filesByPath, header) {
|
|
273
|
+
return [...panelReferenceErrors(filesByPath), ...undeclaredSubscriptionErrors(filesByPath, header ? declaredPanels(header.ui) : [])];
|
|
274
|
+
}
|
|
275
|
+
async function checkPack(packDir, env, isApprovedFingerprint) {
|
|
276
|
+
const read = await readPackDir(packDir, env);
|
|
277
|
+
if (!read.ok) {
|
|
278
|
+
const name = read.header ? `${read.header.name} v${read.header.version}` : null;
|
|
279
|
+
return {
|
|
280
|
+
packDir: path.resolve(packDir),
|
|
281
|
+
name,
|
|
282
|
+
isApproved: false,
|
|
283
|
+
errors: [...read.errors, ...pageErrors(read.filesByPath ?? /* @__PURE__ */ new Map(), read.header)],
|
|
284
|
+
missingRequires: [],
|
|
285
|
+
entries: [],
|
|
286
|
+
rules: [],
|
|
287
|
+
panels: [],
|
|
288
|
+
themes: []
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
const { pack } = read;
|
|
292
|
+
const { prFlowsPacks, warnings: prFlowsErrors } = prFlowsPacksOf([pack]);
|
|
293
|
+
const ui = pack.ui?.ok ? pack.ui.value : {
|
|
294
|
+
panels: [],
|
|
295
|
+
themes: []
|
|
296
|
+
};
|
|
297
|
+
const report = {
|
|
298
|
+
packDir: pack.dir,
|
|
299
|
+
name: `${pack.header.name} v${pack.header.version}`,
|
|
300
|
+
isApproved: isApprovedFingerprint(pack.fingerprint),
|
|
301
|
+
errors: [
|
|
302
|
+
...prFlowsErrors,
|
|
303
|
+
...uiSectionErrors(pack),
|
|
304
|
+
...pageErrors(pack.filesByPath, pack.header)
|
|
305
|
+
],
|
|
306
|
+
missingRequires: pack.missingRequires,
|
|
307
|
+
entries: [],
|
|
308
|
+
rules: [],
|
|
309
|
+
panels: ui.panels.map((panel) => `${panel.id} (${panel.label}) opens ${panel.entry}${panel.reads.length === 0 ? ", reads nothing" : `, reads ${panel.reads.join(", ")}`}`),
|
|
310
|
+
themes: ui.themes.map((theme) => `${theme.id} (${theme.label}, ${theme.mode})`)
|
|
311
|
+
};
|
|
312
|
+
const [prFlowsPack] = prFlowsPacks;
|
|
313
|
+
if (!prFlowsPack) return report;
|
|
314
|
+
const approval = packApproval(prFlowsPack);
|
|
315
|
+
const entries = (approval.pack?.commands ?? []).map((command) => {
|
|
316
|
+
const names = PR_FLOW_PLACEHOLDERS_BY_KIND[command.kind];
|
|
317
|
+
const expanded = expandPlaceholders(command.command, Object.fromEntries(names.map((placeholderName) => [placeholderName, `{${placeholderName}}`])));
|
|
318
|
+
const error = expanded.ok ? null : unknownPlaceholderMessage(command.kind, expanded.unknown);
|
|
319
|
+
return {
|
|
320
|
+
kind: command.kind,
|
|
321
|
+
id: command.id,
|
|
322
|
+
label: command.label,
|
|
323
|
+
argv: command.command,
|
|
324
|
+
repos: command.repos ?? null,
|
|
325
|
+
error
|
|
326
|
+
};
|
|
327
|
+
});
|
|
328
|
+
return {
|
|
329
|
+
...report,
|
|
330
|
+
errors: [...report.errors, ...packRuleErrors(prFlowsPack.section, pack.header.name)],
|
|
331
|
+
entries,
|
|
332
|
+
rules: approval.pack?.rules ?? []
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function packCheckHasProblem(report) {
|
|
336
|
+
return report.errors.length > 0 || report.entries.some((entry) => entry.error !== null);
|
|
337
|
+
}
|
|
338
|
+
function reportHeading(report) {
|
|
339
|
+
const checked = report.name === null ? `Checked the pack at ${report.packDir}` : `Checked pack ${report.name} at ${report.packDir}`;
|
|
340
|
+
if (packCheckHasProblem(report)) return `${checked}: fix the problems below, then check it again`;
|
|
341
|
+
return `${checked}: no problems; ${report.isApproved ? "it is approved" : "once installed, it waits for the operator to approve it in Settings, Packs"}`;
|
|
342
|
+
}
|
|
343
|
+
function entryReach(entry) {
|
|
344
|
+
if (entry.kind === "action") return ", on the repositories of the rules that name it";
|
|
345
|
+
if (entry.repos === null) return ", on every repository";
|
|
346
|
+
return `, limited to ${entry.repos.join(", ")}`;
|
|
347
|
+
}
|
|
348
|
+
function entryLine(entry) {
|
|
349
|
+
const heading = `${entry.kind} ${entry.id} (${entry.label}): `;
|
|
350
|
+
if (entry.error !== null) return `${heading}invalid, ${entry.error}`;
|
|
351
|
+
return `${heading}valid${entryReach(entry)}\n would run ${JSON.stringify(entry.argv)}`;
|
|
352
|
+
}
|
|
353
|
+
function packReportText(report) {
|
|
354
|
+
return [
|
|
355
|
+
reportHeading(report),
|
|
356
|
+
...report.panels.map((panel) => `panel ${panel}`),
|
|
357
|
+
...report.themes.map((theme) => `theme ${theme}`),
|
|
358
|
+
...report.entries.map(entryLine),
|
|
359
|
+
...report.rules.map((rule) => `rule ${rule}`),
|
|
360
|
+
...report.errors.map((error) => `error: ${error}`),
|
|
361
|
+
...report.missingRequires.map((missing) => `missing on this machine: ${missing}, so the pack stays off here until it has it; not a problem in the pack`)
|
|
362
|
+
].join("\n");
|
|
363
|
+
}
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region server/packs/pack-agent.ts
|
|
366
|
+
async function exampleLines(examplePacksDir) {
|
|
367
|
+
const entries = await fs.promises.readdir(examplePacksDir, { withFileTypes: true }).catch(() => []);
|
|
368
|
+
const lines = await Promise.all(entries.filter((entry) => entry.isDirectory()).map(async (entry) => {
|
|
369
|
+
const manifestText = await fs.promises.readFile(path.join(examplePacksDir, entry.name, PACK_FILE_NAME), "utf8").catch(() => "");
|
|
370
|
+
const header = PackHeader.safeParse(parseJsonOrNull(manifestText));
|
|
371
|
+
return `- ${path.join(examplePacksDir, entry.name)}${header.success && header.data.description ? `: ${header.data.description}` : ""}`;
|
|
372
|
+
}));
|
|
373
|
+
return lines.length === 0 ? ["(this install ships no example packs)"] : lines.sort();
|
|
374
|
+
}
|
|
375
|
+
async function packGuideText({ homeDir, examplePacksDir }, schemaLines) {
|
|
376
|
+
return [
|
|
377
|
+
"Glimmervoid packs",
|
|
378
|
+
"",
|
|
379
|
+
`A pack is a folder holding a ${PACK_FILE_NAME} and the files it names, at most 1 MiB in all and without symlinks. Install one by placing its folder under ${path.join(homeDir, PACKS_DIR_NAME)}, or by listing its path under "packs" in Glimmervoid's config.json.`,
|
|
380
|
+
"Nothing in a pack runs or shows until the operator approves it in Settings, Packs, and any change to any file in it asks again. Never approve a pack for the operator; check it, then tell them it waits for approval.",
|
|
381
|
+
"",
|
|
382
|
+
"Sections of pack.json, each checked on its own:",
|
|
383
|
+
"- prFlows: commands My PRs runs on pull requests (prActions, sources, actions, rules).",
|
|
384
|
+
"- ui.themes: color themes for the Theme picker; every chrome and state color is a #rrggbb hex.",
|
|
385
|
+
"- ui.panels: HTML pages shown as dashboard tabs. A panel runs sandboxed in an opaque origin: no network, no cookies, no storage, no popups or navigation (a link in a panel opens nothing), no access to the dashboard page. Put every script, style, image and font in the pack and refer to it by a relative path; ES module scripts with relative imports, fonts, inline <script> and <style> all work. localStorage, sessionStorage and cookies throw a SecurityError, so a panel keeps its state in memory and loses it on reload. Every panel file is served with this Content-Security-Policy:",
|
|
386
|
+
` ${PACK_PANEL_CONTENT_POLICY}`,
|
|
387
|
+
"",
|
|
388
|
+
"Panel bridge: list the topics a panel needs under its reads in pack.json; the operator sees them before approving. The panel posts {\"v\":1,\"kind\":\"subscribe\",\"topics\":[...]} to window.parent and gets {\"v\":1,\"kind\":\"hello\",\"granted\":[...]}: the subscribed topics that are also in reads, so a topic left out of reads never arrives. Then a {\"v\":1,\"kind\":\"topic\",\"topic\":...,\"data\":...} message comes for each granted topic, right away and again whenever it changes. Accept messages only when event.source === window.parent. The descriptions in the bridge JSON Schema below give each field's units and meaning.",
|
|
389
|
+
"Each example panel ships the same bridge.js; copy it beside your panel and load it before your own script. It defines window.glimmervoid.subscribe(topics, onTopic) (it calls onTopic(\"hello\", granted) once, then onTopic(topic, data) per topic message), applyTheme(themeData) (pass it the theme topic data; it sets every color as a CSS custom property on the root, such as var(--bg) or var(--state-running)) and element(tag, className, text).",
|
|
390
|
+
"",
|
|
391
|
+
"Examples to copy and adapt:",
|
|
392
|
+
...await exampleLines(examplePacksDir),
|
|
393
|
+
"",
|
|
394
|
+
"Workflow: write the pack in any folder, run glimmervoid packs check <folder> (exits 1 and lists every problem, including files a page loads that are missing or remote), then glimmervoid packs preview <folder> to open its panels in a browser with sample data and its themes, without installing or approving anything. Then install it and tell the operator it waits for approval. The packs tool with action check runs the same check.",
|
|
395
|
+
"",
|
|
396
|
+
...schemaLines
|
|
397
|
+
].join("\n");
|
|
398
|
+
}
|
|
399
|
+
function rowLines(row) {
|
|
400
|
+
return [
|
|
401
|
+
`${row.name}${row.version === null ? "" : ` v${row.version}`}: ${row.state} at ${row.dir}`,
|
|
402
|
+
...row.panels.map((panel) => ` panel ${panel.id} (${panel.label})${panel.reads.length === 0 ? "" : `, reads ${panel.reads.join(", ")}`}`),
|
|
403
|
+
...row.themes.map((theme) => ` theme ${theme.id} (${theme.label}, ${theme.mode})`),
|
|
404
|
+
...row.missingRequires.map((missing) => ` missing on this machine: ${missing}`),
|
|
405
|
+
...row.errors.map((error) => ` error: ${error}`)
|
|
406
|
+
];
|
|
407
|
+
}
|
|
408
|
+
async function readPacksForAgent(request, deps) {
|
|
409
|
+
if (request.command === "guide") return {
|
|
410
|
+
text: await packGuideText(deps, [
|
|
411
|
+
`${PACK_FILE_NAME} JSON Schema:`,
|
|
412
|
+
packJsonSchemaText(),
|
|
413
|
+
"Panel bridge messages JSON Schema:",
|
|
414
|
+
packBridgeJsonSchemaText()
|
|
415
|
+
]),
|
|
416
|
+
hasProblem: false
|
|
417
|
+
};
|
|
418
|
+
if (request.command === "list") {
|
|
419
|
+
const rows = deps.packRows();
|
|
420
|
+
return {
|
|
421
|
+
text: rows.length === 0 ? `No packs are installed; ${path.join(deps.homeDir, PACKS_DIR_NAME)} holds none and config.json lists none.` : rows.flatMap(rowLines).join("\n"),
|
|
422
|
+
hasProblem: rows.some((row) => row.errors.length > 0)
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
const report = await checkPack(request.path ?? "", deps.env, deps.isApproved);
|
|
426
|
+
return {
|
|
427
|
+
text: packReportText(report),
|
|
428
|
+
hasProblem: packCheckHasProblem(report)
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
//#endregion
|
|
432
|
+
export { packReportText as a, packFileHeaders as c, decideHostAllowed as d, packCheckHasProblem as i, packRow as l, readPacksForAgent as n, approvedPackPanels as o, checkPack as r, approvedPackThemes as s, packGuideText as t, pendingPackNote as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { er as STATES } from "./session-C_EdlPyW.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region shared/contracts/theme-palette.ts
|
|
4
4
|
var HexColor = z.string().regex(/^#[0-9a-fA-F]{6}$/, { error: (issue) => issue.input === void 0 ? "missing; a theme sets every color as #rrggbb" : `a color is #rrggbb, not ${JSON.stringify(issue.input)}` });
|