glimmervoid 0.52.2-next.697 → 0.52.2-next.699
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 +15 -10
- package/dist/chunks/{adapters-BbOhEt3K.js → adapters-BQVgsufG.js} +1 -1
- package/dist/chunks/{adapters-KsgiBN7g.js → adapters-BwrJAzEk.js} +2 -2
- package/dist/chunks/agent-api-cli-CAVmc6oB.js +1 -0
- package/dist/chunks/{agent-api-cli-oEczDo6J.js → agent-api-cli-CtQRT4Db.js} +1 -1
- package/dist/chunks/{agent-api-core-Bx7YtsJX.js → agent-api-core-Ddnr3HgI.js} +45 -1
- package/dist/chunks/{config-DMO8GHVh.js → config-BL8YQ3Ak.js} +1 -1
- package/dist/chunks/config-store-CEM4SJvM.js +1 -0
- package/dist/chunks/{config-store-BZU0pwDi.js → config-store-aB3AE95Q.js} +1 -1
- package/dist/chunks/{main-BJFZUB8b.js → main-D6DExe_h.js} +9 -104
- package/dist/chunks/{pr-flows-external-BRtHbSYM.js → pack-agent-DlW4j1b6.js} +267 -170
- package/dist/chunks/pack-bridge-CQ2Jlear.js +153 -0
- package/dist/chunks/packs-cli-DCKa39sG.js +502 -0
- package/dist/chunks/packs-cli-DV__4MB_.js +1 -0
- package/dist/chunks/{pair-cli-COUf3oqu.js → pair-cli-Dud8jpuO.js} +2 -2
- package/dist/chunks/{pr-flows-cli-CXEWmN7B.js → pr-flows-cli-Clw5RPyH.js} +7 -16
- package/dist/chunks/pr-flows-external-DfN4780W.js +147 -0
- package/dist/chunks/{remote-config-DGikQcIX.js → remote-config-dHj-Qfux.js} +1 -1
- package/dist/chunks/{settings-cli-C1MpfiMd.js → settings-cli-9Z0TOaxK.js} +4 -4
- package/dist/chunks/{settings-readout-core-CmSf-Xx7.js → settings-readout-core-c06UYQ-8.js} +1 -1
- package/dist/chunks/{ssh-sign-cli-CzTz9BiL.js → ssh-sign-cli-CtLGtrUf.js} +1 -1
- package/dist/client/assets/{action-status-DP6ioCmx.js → action-status-Bbo7Fyia.js} +1 -1
- package/dist/client/assets/action-status-Bbo7Fyia.js.br +0 -0
- package/dist/client/assets/{arena-panel-Bq_N5X1d.js → arena-panel-DjLi_oT2.js} +2 -2
- package/dist/client/assets/arena-panel-DjLi_oT2.js.br +0 -0
- package/dist/client/assets/{benchmark-panel-ryHZdeXk.js → benchmark-panel-BGIM23C6.js} +1 -1
- package/dist/client/assets/benchmark-panel-BGIM23C6.js.br +0 -0
- package/dist/client/assets/{boards-view-gTzMZiol.js → boards-view-DVlW49Sr.js} +1 -1
- package/dist/client/assets/boards-view-DVlW49Sr.js.br +0 -0
- package/dist/client/assets/button-CeEmJCQe.js +1 -0
- package/dist/client/assets/button-CeEmJCQe.js.br +0 -0
- package/dist/client/assets/{card-actions-zCz9tHtX.js → card-actions-D5VASOyl.js} +1 -1
- package/dist/client/assets/{card-registry-BDFzrxQP.js → card-registry-CxPu9XGn.js} +1 -1
- package/dist/client/assets/card-registry-CxPu9XGn.js.br +0 -0
- package/dist/client/assets/{community-panel-BO1QiePf.js → community-panel-BTKm5Lhg.js} +1 -1
- package/dist/client/assets/community-panel-BTKm5Lhg.js.br +0 -0
- package/dist/client/assets/{control-ws-UoNejDTB.js → control-ws-DxQoY1aG.js} +1 -1
- package/dist/client/assets/control-ws-DxQoY1aG.js.br +0 -0
- package/dist/client/assets/{dialogs-dHL1tDYy.js → dialogs-B2pJJnBE.js} +1 -1
- package/dist/client/assets/dialogs-B2pJJnBE.js.br +0 -0
- package/dist/client/assets/{doc-editor-ui-chyeOfet.js → doc-editor-ui-Bbxos6dN.js} +1 -1
- package/dist/client/assets/doc-editor-ui-Bbxos6dN.js.br +0 -0
- package/dist/client/assets/{feature-hint-DPfwv8Qe.js → feature-hint-DQt3iscN.js} +1 -1
- package/dist/client/assets/feature-hint-DQt3iscN.js.br +0 -0
- package/dist/client/assets/{first-run-checklist-w-110hem.js → first-run-checklist-BTtzaAxJ.js} +1 -1
- package/dist/client/assets/first-run-checklist-BTtzaAxJ.js.br +0 -0
- package/dist/client/assets/{hooks-panel-DuVgf_lN.js → hooks-panel-ezwWnzzh.js} +1 -1
- package/dist/client/assets/hooks-panel-ezwWnzzh.js.br +0 -0
- package/dist/client/assets/index-MrcTP834.js +75 -0
- package/dist/client/assets/index-MrcTP834.js.br +0 -0
- package/dist/client/assets/{issues-panel-qlnHYLBW.js → issues-panel-tctX4Q02.js} +1 -1
- package/dist/client/assets/issues-panel-tctX4Q02.js.br +0 -0
- package/dist/client/assets/{lane-read-token-step-oXeNfMHE.js → lane-read-token-step-DkaiOW-4.js} +1 -1
- package/dist/client/assets/lane-read-token-step-DkaiOW-4.js.br +0 -0
- package/dist/client/assets/{menu-ER74fqs1.js → menu-ByAf-D4t.js} +1 -1
- package/dist/client/assets/menu-ByAf-D4t.js.br +0 -0
- package/dist/client/assets/{modal-T0t68alc.js → modal-Cccq9QKp.js} +1 -1
- package/dist/client/assets/modal-Cccq9QKp.js.br +0 -0
- package/dist/client/assets/{my-prs-panel-DghSKpbk.js → my-prs-panel-DoxJN1p6.js} +1 -1
- package/dist/client/assets/my-prs-panel-DoxJN1p6.js.br +0 -0
- package/dist/client/assets/{nyan-cat-trmJWrVl.js → nyan-cat-DYqFVEIO.js} +1 -1
- package/dist/client/assets/nyan-cat-DYqFVEIO.js.br +0 -0
- package/dist/client/assets/{phone-shell-BdcE4Ih2.js → phone-shell-D2vARBmz.js} +1 -1
- package/dist/client/assets/phone-shell-D2vARBmz.js.br +0 -0
- package/dist/client/assets/{plan-face-Ctp6Q2w0.js → plan-face-3E2usY8A.js} +1 -1
- package/dist/client/assets/plan-face-3E2usY8A.js.br +0 -0
- package/dist/client/assets/{plan-render-DeOz3r6C.js → plan-render-DolHJmvM.js} +1 -1
- package/dist/client/assets/plan-render-DolHJmvM.js.br +0 -0
- package/dist/client/assets/{pr-queue-columns--vCEWzQx.js → pr-queue-columns-DrjGb4RH.js} +1 -1
- package/dist/client/assets/pr-queue-columns-DrjGb4RH.js.br +0 -0
- package/dist/client/assets/{pr-status-icon-Bt7cQdYv.js → pr-status-icon-DxYoCfBP.js} +1 -1
- package/dist/client/assets/pr-status-icon-DxYoCfBP.js.br +0 -0
- package/dist/client/assets/{radar-panel-D0wJY_nu.js → radar-panel-iLONRxIB.js} +1 -1
- package/dist/client/assets/radar-panel-iLONRxIB.js.br +0 -0
- package/dist/client/assets/{repo-roots-adder-BtWcg5vC.js → repo-roots-adder-B7o85a0g.js} +1 -1
- package/dist/client/assets/repo-roots-adder-B7o85a0g.js.br +0 -0
- package/dist/client/assets/{resume-dialog-DQDyaeEE.js → resume-dialog-Dee6nJCh.js} +1 -1
- package/dist/client/assets/resume-dialog-Dee6nJCh.js.br +0 -0
- package/dist/client/assets/{review-queue-panel-BcWmyEjv.js → review-queue-panel-smdp-hn3.js} +1 -1
- package/dist/client/assets/review-queue-panel-smdp-hn3.js.br +0 -0
- package/dist/client/assets/{session-actions-O2gdJm4Y.js → session-actions-Bup-o08b.js} +2 -2
- package/dist/client/assets/session-actions-Bup-o08b.js.br +0 -0
- package/dist/client/assets/{session-row-OLB0sL3R.js → session-row-A_MI5_sD.js} +1 -1
- package/dist/client/assets/session-row-A_MI5_sD.js.br +0 -0
- package/dist/client/assets/{session-tick-CICZHafe.js → session-tick-lPppK7OC.js} +1 -1
- package/dist/client/assets/session-tick-lPppK7OC.js.br +0 -0
- package/dist/client/assets/{settings-panel-CVhn_sVH.js → settings-panel-BnyIiop4.js} +2 -2
- package/dist/client/assets/settings-panel-BnyIiop4.js.br +0 -0
- package/dist/client/assets/{setup-step-CaBKPldA.js → setup-step-B0XzLQJc.js} +1 -1
- package/dist/client/assets/setup-step-B0XzLQJc.js.br +0 -0
- package/dist/client/assets/{shown-face-B0wjZKZT.js → shown-face-DZEzOG7B.js} +1 -1
- package/dist/client/assets/shown-face-DZEzOG7B.js.br +0 -0
- package/dist/client/assets/{trace-panel-D2XB5RxU.js → trace-panel-rD_JORVh.js} +1 -1
- package/dist/client/assets/trace-panel-rD_JORVh.js.br +0 -0
- package/dist/client/assets/{usage-panel-B1dQfY6p.js → usage-panel-B6oMuE3s.js} +1 -1
- package/dist/client/assets/usage-panel-B6oMuE3s.js.br +0 -0
- package/dist/client/assets/{your-day-tip-Brj1r-sQ.js → your-day-tip-CnENMCMS.js} +1 -1
- package/dist/client/assets/your-day-tip-CnENMCMS.js.br +0 -0
- package/dist/client/index.html +12 -12
- package/dist/client/index.html.br +0 -0
- package/dist/examples/packs/plan-usage/icon.svg +1 -0
- package/dist/examples/packs/plan-usage/pack.json +11 -0
- package/dist/examples/packs/plan-usage/panel/bridge.js +23 -0
- package/dist/examples/packs/plan-usage/panel/index.html +15 -0
- package/dist/examples/packs/plan-usage/panel/panel.css +15 -0
- package/dist/examples/packs/plan-usage/panel/panel.js +56 -0
- package/dist/schema/pack.v1.json +43 -21
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/agent-api-cli-D93znXwp.js +0 -1
- package/dist/chunks/config-store-DT65GJMG.js +0 -1
- package/dist/chunks/pack-bridge-DifQHfqf.js +0 -152
- package/dist/client/assets/action-status-DP6ioCmx.js.br +0 -0
- package/dist/client/assets/arena-panel-Bq_N5X1d.js.br +0 -0
- package/dist/client/assets/benchmark-panel-ryHZdeXk.js.br +0 -0
- package/dist/client/assets/boards-view-gTzMZiol.js.br +0 -0
- package/dist/client/assets/button-CBoNTVJe.js +0 -1
- package/dist/client/assets/button-CBoNTVJe.js.br +0 -0
- package/dist/client/assets/card-registry-BDFzrxQP.js.br +0 -0
- package/dist/client/assets/community-panel-BO1QiePf.js.br +0 -0
- package/dist/client/assets/control-ws-UoNejDTB.js.br +0 -0
- package/dist/client/assets/dialogs-dHL1tDYy.js.br +0 -0
- package/dist/client/assets/doc-editor-ui-chyeOfet.js.br +0 -0
- package/dist/client/assets/feature-hint-DPfwv8Qe.js.br +0 -0
- package/dist/client/assets/first-run-checklist-w-110hem.js.br +0 -0
- package/dist/client/assets/hooks-panel-DuVgf_lN.js.br +0 -0
- package/dist/client/assets/index-o7oGy8XE.js +0 -75
- package/dist/client/assets/index-o7oGy8XE.js.br +0 -0
- package/dist/client/assets/issues-panel-qlnHYLBW.js.br +0 -0
- package/dist/client/assets/lane-read-token-step-oXeNfMHE.js.br +0 -0
- package/dist/client/assets/menu-ER74fqs1.js.br +0 -0
- package/dist/client/assets/modal-T0t68alc.js.br +0 -0
- package/dist/client/assets/my-prs-panel-DghSKpbk.js.br +0 -0
- package/dist/client/assets/nyan-cat-trmJWrVl.js.br +0 -0
- package/dist/client/assets/phone-shell-BdcE4Ih2.js.br +0 -0
- package/dist/client/assets/plan-face-Ctp6Q2w0.js.br +0 -0
- package/dist/client/assets/plan-render-DeOz3r6C.js.br +0 -0
- package/dist/client/assets/pr-queue-columns--vCEWzQx.js.br +0 -0
- package/dist/client/assets/pr-status-icon-Bt7cQdYv.js.br +0 -0
- package/dist/client/assets/radar-panel-D0wJY_nu.js.br +0 -0
- package/dist/client/assets/repo-roots-adder-BtWcg5vC.js.br +0 -0
- package/dist/client/assets/resume-dialog-DQDyaeEE.js.br +0 -0
- package/dist/client/assets/review-queue-panel-BcWmyEjv.js.br +0 -0
- package/dist/client/assets/session-actions-O2gdJm4Y.js.br +0 -0
- package/dist/client/assets/session-row-OLB0sL3R.js.br +0 -0
- package/dist/client/assets/session-tick-CICZHafe.js.br +0 -0
- package/dist/client/assets/settings-panel-CVhn_sVH.js.br +0 -0
- package/dist/client/assets/setup-step-CaBKPldA.js.br +0 -0
- package/dist/client/assets/shown-face-B0wjZKZT.js.br +0 -0
- package/dist/client/assets/trace-panel-D2XB5RxU.js.br +0 -0
- package/dist/client/assets/usage-panel-B1dQfY6p.js.br +0 -0
- package/dist/client/assets/your-day-tip-Brj1r-sQ.js.br +0 -4
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Jn as STATES } from "./session-BrX33men.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region shared/contracts/theme-palette.ts
|
|
4
|
+
var HexColor = z.string().regex(/^#[0-9a-fA-F]{6}$/, { error: (issue) => `a color is #rrggbb, not ${JSON.stringify(issue.input)}` });
|
|
5
|
+
var ThemeStates = z.strictObject({
|
|
6
|
+
running: HexColor,
|
|
7
|
+
waiting: HexColor,
|
|
8
|
+
failed: HexColor,
|
|
9
|
+
monitoring: HexColor,
|
|
10
|
+
done: HexColor,
|
|
11
|
+
initializing: HexColor,
|
|
12
|
+
idle: HexColor,
|
|
13
|
+
starting: HexColor,
|
|
14
|
+
complete: HexColor
|
|
15
|
+
});
|
|
16
|
+
var THEME_STATE_NAMES = ThemeStates.keyof().options;
|
|
17
|
+
function colorFor(role) {
|
|
18
|
+
return HexColor.describe(role);
|
|
19
|
+
}
|
|
20
|
+
var ThemePalette = z.strictObject({
|
|
21
|
+
label: z.string().trim().min(1).max(40).describe("The name shown in the Theme picker"),
|
|
22
|
+
mode: z.enum(["dark", "light"]).describe("Whether the theme is dark or light, which picks the terminal palette its ANSI colors are tuned for"),
|
|
23
|
+
accentAnsiSlot: z.enum([
|
|
24
|
+
"blue",
|
|
25
|
+
"magenta",
|
|
26
|
+
"none"
|
|
27
|
+
]).describe("The terminal ANSI color the accent replaces, with a lighter mix of it as that color's bright variant; none leaves terminal colors alone"),
|
|
28
|
+
chrome: z.strictObject({
|
|
29
|
+
"bg": colorFor("Page background"),
|
|
30
|
+
"bg-card": colorFor("Cards, panes and the terminal background"),
|
|
31
|
+
"bg-header": colorFor("Headers and toolbars"),
|
|
32
|
+
"bg-surface": colorFor("Raised controls: chips, inputs, menus and hover fills"),
|
|
33
|
+
"border": colorFor("Default borders"),
|
|
34
|
+
"border-dim": colorFor("Faint dividers inside a card or list"),
|
|
35
|
+
"border-hover": colorFor("Borders of a hovered or focused control"),
|
|
36
|
+
"text": colorFor("Body text"),
|
|
37
|
+
"text-dim": colorFor("Secondary text such as hints and empty states"),
|
|
38
|
+
"text-head": colorFor("Headings and emphasized text"),
|
|
39
|
+
"text-muted": colorFor("Labels and metadata, between text and text-dim"),
|
|
40
|
+
"accent": colorFor("Links, focus rings, selection and primary actions"),
|
|
41
|
+
"accent-dim": colorFor("A quieter accent for selected borders")
|
|
42
|
+
}).describe("Dashboard colors; each key becomes the CSS custom property --<key>"),
|
|
43
|
+
states: ThemeStates.describe("One color per session state, shown as --state-<state> on cards, dots and badges")
|
|
44
|
+
});
|
|
45
|
+
var PackBridgeTopic = z.enum([
|
|
46
|
+
"sessions",
|
|
47
|
+
"focus",
|
|
48
|
+
"theme",
|
|
49
|
+
"my-prs",
|
|
50
|
+
"usage",
|
|
51
|
+
"attention",
|
|
52
|
+
"team-reviews"
|
|
53
|
+
]);
|
|
54
|
+
var BridgeVersion = z.literal(1);
|
|
55
|
+
var BridgePlanWindow = z.strictObject({
|
|
56
|
+
pct: z.number().nullable().describe("Percent of the window used, 0 to 100; 100 or more means the limit is reached; null when the agent did not report it"),
|
|
57
|
+
resetsAtMs: z.number().nullable().describe("When the window resets, as Unix epoch milliseconds; null when the agent did not report it")
|
|
58
|
+
}).nullable().describe("null when the agent reported nothing for this window");
|
|
59
|
+
var BridgePullRequest = z.strictObject({
|
|
60
|
+
key: z.string(),
|
|
61
|
+
title: z.string(),
|
|
62
|
+
url: z.string(),
|
|
63
|
+
author: z.string()
|
|
64
|
+
});
|
|
65
|
+
var PACK_BRIDGE_TOPIC_DATA = {
|
|
66
|
+
sessions: z.strictObject({ sessions: z.array(z.strictObject({
|
|
67
|
+
id: z.string(),
|
|
68
|
+
name: z.string(),
|
|
69
|
+
agent: z.string().nullable(),
|
|
70
|
+
state: z.string().describe(`One of ${Object.values(STATES).join(", ")}; the theme color for a state is --state-<state in lowercase>, and DORMANT has none`),
|
|
71
|
+
stateSinceMs: z.number().describe("When the session entered its state, as Unix epoch milliseconds"),
|
|
72
|
+
taskTitle: z.string().nullable()
|
|
73
|
+
})) }),
|
|
74
|
+
focus: z.strictObject({
|
|
75
|
+
sessionId: z.string().nullable(),
|
|
76
|
+
view: z.string(),
|
|
77
|
+
isStreamerMode: z.boolean().describe("The operator is screen sharing: session names and task titles arrive masked and pull request titles and authors arrive empty")
|
|
78
|
+
}),
|
|
79
|
+
theme: z.strictObject({
|
|
80
|
+
id: z.string().nullable().describe("The active theme's id; a pack theme's id is <pack name>/<theme id>"),
|
|
81
|
+
colors: z.record(z.string(), z.string()).describe("CSS custom properties to set on the root element, keyed with their leading --: one per theme chrome key (--bg, --bg-card, --bg-header, --bg-surface, --border, --border-dim, --border-hover, --text, --text-dim, --text-head, --text-muted, --accent, --accent-dim) and per session state (--state-<state>, a hex color, and --state-<state>-bg, a translucent color-mix tint of it)")
|
|
82
|
+
}),
|
|
83
|
+
"my-prs": z.strictObject({ prs: z.array(z.strictObject({
|
|
84
|
+
key: z.string(),
|
|
85
|
+
repo: z.string(),
|
|
86
|
+
number: z.number(),
|
|
87
|
+
title: z.string(),
|
|
88
|
+
url: z.string(),
|
|
89
|
+
isDraft: z.boolean(),
|
|
90
|
+
state: z.enum([
|
|
91
|
+
"OPEN",
|
|
92
|
+
"MERGED",
|
|
93
|
+
"CLOSED"
|
|
94
|
+
]),
|
|
95
|
+
checks: z.enum([
|
|
96
|
+
"SUCCESS",
|
|
97
|
+
"FAILURE",
|
|
98
|
+
"PENDING",
|
|
99
|
+
"ERROR",
|
|
100
|
+
"EXPECTED"
|
|
101
|
+
]).nullable(),
|
|
102
|
+
reviewDecision: z.enum([
|
|
103
|
+
"APPROVED",
|
|
104
|
+
"CHANGES_REQUESTED",
|
|
105
|
+
"REVIEW_REQUIRED"
|
|
106
|
+
]).nullable(),
|
|
107
|
+
unresolvedThreads: z.number()
|
|
108
|
+
})) }),
|
|
109
|
+
usage: z.strictObject({ planLimits: z.array(z.strictObject({
|
|
110
|
+
vendor: z.enum([
|
|
111
|
+
"claude",
|
|
112
|
+
"codex",
|
|
113
|
+
"kimi"
|
|
114
|
+
]),
|
|
115
|
+
fiveHour: BridgePlanWindow,
|
|
116
|
+
sevenDay: BridgePlanWindow
|
|
117
|
+
})).describe("One entry per agent that has reported plan limits; an agent that has not is absent") }),
|
|
118
|
+
attention: z.strictObject({
|
|
119
|
+
waiting: z.number(),
|
|
120
|
+
finished: z.number(),
|
|
121
|
+
failed: z.number()
|
|
122
|
+
}),
|
|
123
|
+
"team-reviews": z.strictObject({
|
|
124
|
+
ready: z.array(BridgePullRequest),
|
|
125
|
+
needsAttention: z.array(BridgePullRequest),
|
|
126
|
+
inReviewCount: z.number(),
|
|
127
|
+
queuedCount: z.number()
|
|
128
|
+
})
|
|
129
|
+
};
|
|
130
|
+
var PanelToHost = z.discriminatedUnion("kind", [z.strictObject({
|
|
131
|
+
v: BridgeVersion,
|
|
132
|
+
kind: z.literal("subscribe"),
|
|
133
|
+
topics: z.array(PackBridgeTopic).min(1).describe("The topics to receive; only those also listed in the panel's reads in pack.json are granted, and a later subscribe replaces the earlier one")
|
|
134
|
+
})]);
|
|
135
|
+
var HostTopicMessages = PackBridgeTopic.options.map((topic) => z.strictObject({
|
|
136
|
+
v: BridgeVersion,
|
|
137
|
+
kind: z.literal("topic"),
|
|
138
|
+
topic: z.literal(topic),
|
|
139
|
+
data: PACK_BRIDGE_TOPIC_DATA[topic]
|
|
140
|
+
}).describe("Sent right after hello and again whenever the data changes, checked once a second"));
|
|
141
|
+
var HostToPanel = z.union([z.strictObject({
|
|
142
|
+
v: BridgeVersion,
|
|
143
|
+
kind: z.literal("hello"),
|
|
144
|
+
granted: z.array(PackBridgeTopic).describe("The subscribed topics that are also in reads; a topic missing here never arrives")
|
|
145
|
+
}), ...HostTopicMessages]);
|
|
146
|
+
function packBridgeJsonSchemaText() {
|
|
147
|
+
return `${JSON.stringify({
|
|
148
|
+
panelToHost: z.toJSONSchema(PanelToHost),
|
|
149
|
+
hostToPanel: z.toJSONSchema(HostToPanel)
|
|
150
|
+
}, null, 2)}\n`;
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
export { ThemePalette as i, packBridgeJsonSchemaText as n, THEME_STATE_NAMES as r, PackBridgeTopic as t };
|
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import { r as errorMessage } from "./text-DoirglWV.js";
|
|
2
|
+
import { a as examplePacksDir } from "./runtime-paths-DfoHzN15.js";
|
|
3
|
+
import { n as glimmervoidHomeDir } from "./config-path-core-DUWk0Lui.js";
|
|
4
|
+
import { Jn as STATES, n as AGENT_REPLY_SCHEMAS } from "./session-BrX33men.js";
|
|
5
|
+
import { n as packBridgeJsonSchemaText, r as THEME_STATE_NAMES, t as PackBridgeTopic } from "./pack-bridge-CQ2Jlear.js";
|
|
6
|
+
import { Y as decideHostAllowed, _ as packFileHeaders, a as packCheckHasProblem, d as readPackDir, i as checkPack, m as packJsonSchemaText, o as packReportText, t as packGuideText, u as readApprovedPackFingerprints } from "./pack-agent-DlW4j1b6.js";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
import http from "node:http";
|
|
10
|
+
//#region shared/theme-colors-core.ts
|
|
11
|
+
var STRONG_TINT_STATES = /* @__PURE__ */ new Set(["waiting", "monitoring"]);
|
|
12
|
+
function stateColors(states) {
|
|
13
|
+
return Object.fromEntries(THEME_STATE_NAMES.flatMap((stateName) => {
|
|
14
|
+
const tintPercent = STRONG_TINT_STATES.has(stateName) ? 8 : 6;
|
|
15
|
+
return [[`--state-${stateName}`, states[stateName]], [`--state-${stateName}-bg`, `color-mix(in oklab, var(--state-${stateName}) ${tintPercent}%, transparent)`]];
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
function themeCssColors(palette) {
|
|
19
|
+
return {
|
|
20
|
+
...Object.fromEntries(Object.entries(palette.chrome).map(([token, color]) => [`--${token}`, color])),
|
|
21
|
+
...stateColors(palette.states)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region server/packs/core/pack-preview-core.ts
|
|
26
|
+
var HOUR_MS = 36e5;
|
|
27
|
+
var SAMPLE_PALETTE = {
|
|
28
|
+
label: "Sample dark",
|
|
29
|
+
mode: "dark",
|
|
30
|
+
accentAnsiSlot: "blue",
|
|
31
|
+
chrome: {
|
|
32
|
+
"bg": "#0d1117",
|
|
33
|
+
"bg-card": "#11161d",
|
|
34
|
+
"bg-header": "#0f141a",
|
|
35
|
+
"bg-surface": "#18202a",
|
|
36
|
+
"border": "#263040",
|
|
37
|
+
"border-dim": "#1b232e",
|
|
38
|
+
"border-hover": "#3a4a5e",
|
|
39
|
+
"text": "#c9d4df",
|
|
40
|
+
"text-dim": "#7d8a97",
|
|
41
|
+
"text-head": "#eef3f8",
|
|
42
|
+
"text-muted": "#94a1ae",
|
|
43
|
+
"accent": "#4f9cf9",
|
|
44
|
+
"accent-dim": "#2f6db8"
|
|
45
|
+
},
|
|
46
|
+
states: {
|
|
47
|
+
running: "#3fb950",
|
|
48
|
+
waiting: "#d29922",
|
|
49
|
+
failed: "#f85149",
|
|
50
|
+
monitoring: "#58a6ff",
|
|
51
|
+
done: "#8b949e",
|
|
52
|
+
initializing: "#6e7681",
|
|
53
|
+
idle: "#e3b341",
|
|
54
|
+
starting: "#a371f7",
|
|
55
|
+
complete: "#2ea043"
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var SAMPLE_PULL_REQUEST = {
|
|
59
|
+
key: "acme/app#42",
|
|
60
|
+
title: "Speed up the deck import",
|
|
61
|
+
url: "https://github.com/acme/app/pull/42",
|
|
62
|
+
author: "sample-author"
|
|
63
|
+
};
|
|
64
|
+
function previewSampleTopics(nowMs) {
|
|
65
|
+
return {
|
|
66
|
+
sessions: { sessions: [
|
|
67
|
+
{
|
|
68
|
+
id: "sample-1",
|
|
69
|
+
name: "deck import",
|
|
70
|
+
agent: "claude-code",
|
|
71
|
+
state: STATES.RUNNING,
|
|
72
|
+
stateSinceMs: nowMs - 24e4,
|
|
73
|
+
taskTitle: "Speed up the deck import"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "sample-2",
|
|
77
|
+
name: "login bug",
|
|
78
|
+
agent: "codex",
|
|
79
|
+
state: STATES.WAITING,
|
|
80
|
+
stateSinceMs: nowMs - 9e4,
|
|
81
|
+
taskTitle: "Fix the login redirect"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: "sample-3",
|
|
85
|
+
name: "docs pass",
|
|
86
|
+
agent: "kimi",
|
|
87
|
+
state: STATES.FAILED,
|
|
88
|
+
stateSinceMs: nowMs - 12e5,
|
|
89
|
+
taskTitle: null
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: "sample-4",
|
|
93
|
+
name: "search index",
|
|
94
|
+
agent: "claude-code",
|
|
95
|
+
state: STATES.RUNNING,
|
|
96
|
+
stateSinceMs: nowMs - 27e5,
|
|
97
|
+
taskTitle: "Rebuild the search index"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: "sample-5",
|
|
101
|
+
name: "release notes",
|
|
102
|
+
agent: "codex",
|
|
103
|
+
state: STATES.COMPLETE,
|
|
104
|
+
stateSinceMs: nowMs - 3 * HOUR_MS,
|
|
105
|
+
taskTitle: "Draft the release notes"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: "sample-6",
|
|
109
|
+
name: "scratch",
|
|
110
|
+
agent: null,
|
|
111
|
+
state: STATES.IDLE,
|
|
112
|
+
stateSinceMs: nowMs - 26 * HOUR_MS,
|
|
113
|
+
taskTitle: null
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: "sample-7",
|
|
117
|
+
name: "new session",
|
|
118
|
+
agent: "kimi",
|
|
119
|
+
state: STATES.STARTING,
|
|
120
|
+
stateSinceMs: nowMs - 5e3,
|
|
121
|
+
taskTitle: null
|
|
122
|
+
}
|
|
123
|
+
] },
|
|
124
|
+
focus: {
|
|
125
|
+
sessionId: "sample-1",
|
|
126
|
+
view: "focus",
|
|
127
|
+
isStreamerMode: false
|
|
128
|
+
},
|
|
129
|
+
"my-prs": { prs: [
|
|
130
|
+
{
|
|
131
|
+
key: "acme/app#42",
|
|
132
|
+
repo: "acme/app",
|
|
133
|
+
number: 42,
|
|
134
|
+
title: "Speed up the deck import",
|
|
135
|
+
url: "https://github.com/acme/app/pull/42",
|
|
136
|
+
isDraft: false,
|
|
137
|
+
state: "OPEN",
|
|
138
|
+
checks: "SUCCESS",
|
|
139
|
+
reviewDecision: "APPROVED",
|
|
140
|
+
unresolvedThreads: 0
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
key: "acme/app#43",
|
|
144
|
+
repo: "acme/app",
|
|
145
|
+
number: 43,
|
|
146
|
+
title: "Fix the login redirect",
|
|
147
|
+
url: "https://github.com/acme/app/pull/43",
|
|
148
|
+
isDraft: true,
|
|
149
|
+
state: "OPEN",
|
|
150
|
+
checks: "FAILURE",
|
|
151
|
+
reviewDecision: null,
|
|
152
|
+
unresolvedThreads: 2
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
key: "acme/api#7",
|
|
156
|
+
repo: "acme/api",
|
|
157
|
+
number: 7,
|
|
158
|
+
title: "Rebuild the search index",
|
|
159
|
+
url: "https://github.com/acme/api/pull/7",
|
|
160
|
+
isDraft: false,
|
|
161
|
+
state: "OPEN",
|
|
162
|
+
checks: "PENDING",
|
|
163
|
+
reviewDecision: "CHANGES_REQUESTED",
|
|
164
|
+
unresolvedThreads: 1
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
key: "acme/api#8",
|
|
168
|
+
repo: "acme/api",
|
|
169
|
+
number: 8,
|
|
170
|
+
title: "Draft the release notes",
|
|
171
|
+
url: "https://github.com/acme/api/pull/8",
|
|
172
|
+
isDraft: false,
|
|
173
|
+
state: "OPEN",
|
|
174
|
+
checks: null,
|
|
175
|
+
reviewDecision: "REVIEW_REQUIRED",
|
|
176
|
+
unresolvedThreads: 0
|
|
177
|
+
}
|
|
178
|
+
] },
|
|
179
|
+
usage: { planLimits: [
|
|
180
|
+
{
|
|
181
|
+
vendor: "claude",
|
|
182
|
+
fiveHour: {
|
|
183
|
+
pct: 42,
|
|
184
|
+
resetsAtMs: nowMs + 2 * HOUR_MS
|
|
185
|
+
},
|
|
186
|
+
sevenDay: {
|
|
187
|
+
pct: 91,
|
|
188
|
+
resetsAtMs: nowMs + 72 * HOUR_MS
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
vendor: "codex",
|
|
193
|
+
fiveHour: {
|
|
194
|
+
pct: 100,
|
|
195
|
+
resetsAtMs: nowMs + HOUR_MS / 3
|
|
196
|
+
},
|
|
197
|
+
sevenDay: null
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
vendor: "kimi",
|
|
201
|
+
fiveHour: {
|
|
202
|
+
pct: null,
|
|
203
|
+
resetsAtMs: nowMs + 4 * HOUR_MS
|
|
204
|
+
},
|
|
205
|
+
sevenDay: {
|
|
206
|
+
pct: 5,
|
|
207
|
+
resetsAtMs: null
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
] },
|
|
211
|
+
attention: {
|
|
212
|
+
waiting: 1,
|
|
213
|
+
finished: 1,
|
|
214
|
+
failed: 1
|
|
215
|
+
},
|
|
216
|
+
"team-reviews": {
|
|
217
|
+
ready: [SAMPLE_PULL_REQUEST],
|
|
218
|
+
needsAttention: [],
|
|
219
|
+
inReviewCount: 1,
|
|
220
|
+
queuedCount: 3
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function previewThemes(pack) {
|
|
225
|
+
return [...pack?.ui?.ok ? pack.ui.value.themes.map(({ id, ...palette }) => ({
|
|
226
|
+
id: `${pack.header.name}/${id}`,
|
|
227
|
+
label: palette.label,
|
|
228
|
+
colors: themeCssColors(palette)
|
|
229
|
+
})) : [], {
|
|
230
|
+
id: "sample-dark",
|
|
231
|
+
label: SAMPLE_PALETTE.label,
|
|
232
|
+
colors: themeCssColors(SAMPLE_PALETTE)
|
|
233
|
+
}];
|
|
234
|
+
}
|
|
235
|
+
function previewPanels(pack) {
|
|
236
|
+
if (!pack?.ui?.ok) return [];
|
|
237
|
+
return pack.ui.value.panels.map((panel) => ({
|
|
238
|
+
id: panel.id,
|
|
239
|
+
label: panel.label,
|
|
240
|
+
url: `/files/${panel.entry.split("/").map(encodeURIComponent).join("/")}`,
|
|
241
|
+
reads: panel.reads
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
244
|
+
var HOST_SCRIPT = `
|
|
245
|
+
const frame = document.getElementById('frame');
|
|
246
|
+
const panelSelect = document.getElementById('panel');
|
|
247
|
+
const themeSelect = document.getElementById('theme');
|
|
248
|
+
const status = document.getElementById('status');
|
|
249
|
+
const swatches = document.getElementById('swatches');
|
|
250
|
+
document.getElementById('report').textContent = preview.report;
|
|
251
|
+
let grantedTopics = [];
|
|
252
|
+
function addOptions(select, items) {
|
|
253
|
+
for (const item of items) select.append(new Option(item.label, item.id));
|
|
254
|
+
}
|
|
255
|
+
addOptions(panelSelect, preview.panels);
|
|
256
|
+
panelSelect.parentElement.hidden = preview.panels.length === 0;
|
|
257
|
+
addOptions(themeSelect, preview.themes);
|
|
258
|
+
function currentPanel() {
|
|
259
|
+
return preview.panels.find((panel) => panel.id === panelSelect.value);
|
|
260
|
+
}
|
|
261
|
+
function topicData(topic) {
|
|
262
|
+
if (topic !== 'theme') return preview.topics[topic];
|
|
263
|
+
const theme = preview.themes.find((candidate) => candidate.id === themeSelect.value);
|
|
264
|
+
return { id: theme.id, colors: theme.colors };
|
|
265
|
+
}
|
|
266
|
+
function post(message) {
|
|
267
|
+
frame.contentWindow?.postMessage(message, '*');
|
|
268
|
+
}
|
|
269
|
+
function postTopic(topic) {
|
|
270
|
+
post({ v: 1, kind: 'topic', topic, data: topicData(topic) });
|
|
271
|
+
}
|
|
272
|
+
function renderSwatches() {
|
|
273
|
+
const theme = preview.themes.find((candidate) => candidate.id === themeSelect.value);
|
|
274
|
+
for (const [property, value] of Object.entries(theme.colors)) swatches.style.setProperty(property, value);
|
|
275
|
+
swatches.replaceChildren(...Object.entries(theme.colors).map(([property, value]) => {
|
|
276
|
+
const swatch = document.createElement('div');
|
|
277
|
+
swatch.className = 'swatch';
|
|
278
|
+
swatch.style.setProperty('--swatch', 'var(' + property + ')');
|
|
279
|
+
swatch.textContent = property + ' ' + value;
|
|
280
|
+
return swatch;
|
|
281
|
+
}));
|
|
282
|
+
}
|
|
283
|
+
function openPanel() {
|
|
284
|
+
grantedTopics = [];
|
|
285
|
+
const panel = currentPanel();
|
|
286
|
+
frame.hidden = !panel;
|
|
287
|
+
swatches.hidden = Boolean(panel);
|
|
288
|
+
status.textContent = panel ? 'Waiting for the panel to subscribe.' : 'No panel to show, so here are the colors of the picked theme.';
|
|
289
|
+
if (panel) frame.src = panel.url;
|
|
290
|
+
if (!panel) renderSwatches();
|
|
291
|
+
}
|
|
292
|
+
window.addEventListener('message', (event) => {
|
|
293
|
+
const panel = currentPanel();
|
|
294
|
+
if (!panel || event.source !== frame.contentWindow) return;
|
|
295
|
+
const request = event.data;
|
|
296
|
+
const isSubscribe = request && typeof request === 'object' && Object.keys(request).sort().join() === 'kind,topics,v'
|
|
297
|
+
&& request.v === preview.bridgeVersion && request.kind === 'subscribe' && Array.isArray(request.topics) && request.topics.length > 0
|
|
298
|
+
&& request.topics.every((topic) => preview.knownTopics.includes(topic));
|
|
299
|
+
if (!isSubscribe) {
|
|
300
|
+
status.textContent = 'Glimmervoid ignores this message, so the panel would get no data: ' + JSON.stringify(request) + '. A subscribe is exactly { v: ' + preview.bridgeVersion + ', kind: "subscribe", topics } with at least one of ' + preview.knownTopics.join(', ');
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
grantedTopics = request.topics.filter((topic) => panel.reads.includes(topic));
|
|
304
|
+
const refused = request.topics.filter((topic) => !grantedTopics.includes(topic));
|
|
305
|
+
status.textContent = 'Granted: ' + (grantedTopics.join(', ') || 'nothing') + (refused.length > 0 ? '. Not in reads, so never sent: ' + refused.join(', ') : '');
|
|
306
|
+
post({ v: 1, kind: 'hello', granted: grantedTopics });
|
|
307
|
+
for (const topic of grantedTopics) postTopic(topic);
|
|
308
|
+
});
|
|
309
|
+
panelSelect.addEventListener('change', openPanel);
|
|
310
|
+
themeSelect.addEventListener('change', () => {
|
|
311
|
+
if (grantedTopics.includes('theme')) postTopic('theme');
|
|
312
|
+
if (!currentPanel()) renderSwatches();
|
|
313
|
+
});
|
|
314
|
+
openPanel();
|
|
315
|
+
`;
|
|
316
|
+
function scriptJson(value) {
|
|
317
|
+
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
318
|
+
}
|
|
319
|
+
function previewHostPage({ title, report, pack, nowMs }) {
|
|
320
|
+
const preview = {
|
|
321
|
+
report,
|
|
322
|
+
panels: previewPanels(pack),
|
|
323
|
+
themes: previewThemes(pack),
|
|
324
|
+
topics: previewSampleTopics(nowMs),
|
|
325
|
+
knownTopics: PackBridgeTopic.options,
|
|
326
|
+
bridgeVersion: 1
|
|
327
|
+
};
|
|
328
|
+
return `<!DOCTYPE html>
|
|
329
|
+
<html lang="en"><head><meta charset="utf-8"><title>${title.replace(/[<&]/g, "")}</title>
|
|
330
|
+
<style>
|
|
331
|
+
body { margin: 0; height: 100vh; display: flex; flex-direction: column; font: 13px system-ui, sans-serif; background: #15181c; color: #d5dbe1; }
|
|
332
|
+
header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 8px 12px; border-bottom: 1px solid #2a3038; }
|
|
333
|
+
pre { margin: 0; padding: 8px 12px; max-height: 30vh; overflow: auto; white-space: pre-wrap; border-bottom: 1px solid #2a3038; }
|
|
334
|
+
#status { color: #9aa5b1; }
|
|
335
|
+
iframe { flex: 1; width: 100%; border: 0; }
|
|
336
|
+
iframe[hidden] { display: none; }
|
|
337
|
+
#swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; padding: 12px; overflow: auto; }
|
|
338
|
+
#swatches[hidden] { display: none; }
|
|
339
|
+
.swatch { padding: 10px; border-radius: 6px; background: var(--swatch); color: #fff; text-shadow: 0 1px 2px #000; font: 12px ui-monospace, monospace; }
|
|
340
|
+
</style></head>
|
|
341
|
+
<body>
|
|
342
|
+
<header><strong>Pack preview</strong><label>Panel <select id="panel"></select></label><label>Theme <select id="theme"></select></label><span id="status"></span><span>Sample data, not your dashboard. Reload after editing the pack.</span></header>
|
|
343
|
+
<pre id="report"></pre>
|
|
344
|
+
<iframe id="frame" title="Panel" sandbox="allow-scripts allow-forms"></iframe>
|
|
345
|
+
<div id="swatches" hidden></div>
|
|
346
|
+
<script>const preview = ${scriptJson(preview)};${HOST_SCRIPT}<\/script>
|
|
347
|
+
</body></html>
|
|
348
|
+
`;
|
|
349
|
+
}
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region server/packs/packs-cli.ts
|
|
352
|
+
var PREVIEW_HOST = "127.0.0.1";
|
|
353
|
+
var FILES_PREFIX = "/files/";
|
|
354
|
+
async function runPackCheckCli({ packDir, isJson, env, homeDir }) {
|
|
355
|
+
const approvedFingerprints = readApprovedPackFingerprints(homeDir);
|
|
356
|
+
const report = await checkPack(packDir, env, (fingerprint) => approvedFingerprints.has(fingerprint));
|
|
357
|
+
process.stdout.write(`${isJson ? JSON.stringify(report, null, 2) : packReportText(report)}\n`);
|
|
358
|
+
return packCheckHasProblem(report) ? 1 : 0;
|
|
359
|
+
}
|
|
360
|
+
var SCHEMA_TEXT_BY_NAME = {
|
|
361
|
+
pack: packJsonSchemaText,
|
|
362
|
+
bridge: packBridgeJsonSchemaText
|
|
363
|
+
};
|
|
364
|
+
async function runGuide(homeDir, schemaName) {
|
|
365
|
+
if (schemaName === null) {
|
|
366
|
+
process.stdout.write(`${await packGuideText({
|
|
367
|
+
homeDir,
|
|
368
|
+
examplePacksDir
|
|
369
|
+
}, ["The JSON Schemas, with what each field means: glimmervoid packs guide --schema pack (pack.json) and glimmervoid packs guide --schema bridge (panel bridge messages)."])}\n`);
|
|
370
|
+
return 0;
|
|
371
|
+
}
|
|
372
|
+
const schemaText = SCHEMA_TEXT_BY_NAME[schemaName];
|
|
373
|
+
if (!schemaText) {
|
|
374
|
+
process.stderr.write(`glimmervoid packs guide: --schema is pack or bridge, not ${schemaName}\n`);
|
|
375
|
+
return 1;
|
|
376
|
+
}
|
|
377
|
+
process.stdout.write(schemaText());
|
|
378
|
+
return 0;
|
|
379
|
+
}
|
|
380
|
+
async function runList() {
|
|
381
|
+
if (!process.env["GLIMMERVOID_AGENT_URL"]) {
|
|
382
|
+
process.stderr.write("glimmervoid packs list reads the running Glimmervoid, so it works inside a Glimmervoid session; the operator sees the same list in Settings, Packs\n");
|
|
383
|
+
return 1;
|
|
384
|
+
}
|
|
385
|
+
const { askAgentApi } = await import("./agent-api-cli-CAVmc6oB.js");
|
|
386
|
+
const reply = AGENT_REPLY_SCHEMAS.packs.safeParse(await askAgentApi("packs", { command: "list" }));
|
|
387
|
+
if (!reply.success) {
|
|
388
|
+
process.stderr.write("glimmervoid packs list: Glimmervoid did not answer with a pack list\n");
|
|
389
|
+
return 1;
|
|
390
|
+
}
|
|
391
|
+
if (!reply.data.ok) {
|
|
392
|
+
process.stderr.write(`glimmervoid packs list: ${reply.data.error}\n`);
|
|
393
|
+
return 1;
|
|
394
|
+
}
|
|
395
|
+
process.stdout.write(`${reply.data.text}\n`);
|
|
396
|
+
return 0;
|
|
397
|
+
}
|
|
398
|
+
function decodedFilePath(urlPath) {
|
|
399
|
+
try {
|
|
400
|
+
return urlPath.slice(7).split("/").map(decodeURIComponent).join("/");
|
|
401
|
+
} catch {
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
async function previewResponse(packDir, requestUrl, env, homeDir) {
|
|
406
|
+
const urlPath = new URL(requestUrl, `http://${PREVIEW_HOST}`).pathname;
|
|
407
|
+
const read = await readPackDir(packDir, env);
|
|
408
|
+
const pack = read.ok ? read.pack : null;
|
|
409
|
+
if (urlPath.startsWith(FILES_PREFIX)) {
|
|
410
|
+
const filePath = decodedFilePath(urlPath);
|
|
411
|
+
const bytes = filePath === null ? void 0 : pack?.filesByPath.get(filePath);
|
|
412
|
+
if (filePath === null || bytes === void 0) return {
|
|
413
|
+
status: 404,
|
|
414
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" },
|
|
415
|
+
body: "Not a file in the pack"
|
|
416
|
+
};
|
|
417
|
+
return {
|
|
418
|
+
status: 200,
|
|
419
|
+
headers: {
|
|
420
|
+
...packFileHeaders(filePath),
|
|
421
|
+
"Cache-Control": "no-store"
|
|
422
|
+
},
|
|
423
|
+
body: bytes
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
if (urlPath !== "/") return {
|
|
427
|
+
status: 404,
|
|
428
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" },
|
|
429
|
+
body: "Not found"
|
|
430
|
+
};
|
|
431
|
+
const approvedFingerprints = readApprovedPackFingerprints(homeDir);
|
|
432
|
+
const report = await checkPack(packDir, env, (fingerprint) => approvedFingerprints.has(fingerprint));
|
|
433
|
+
return {
|
|
434
|
+
status: 200,
|
|
435
|
+
headers: {
|
|
436
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
437
|
+
"Cache-Control": "no-store"
|
|
438
|
+
},
|
|
439
|
+
body: previewHostPage({
|
|
440
|
+
title: `Pack preview: ${report.name ?? path.basename(packDir)}`,
|
|
441
|
+
report: packReportText(report),
|
|
442
|
+
pack,
|
|
443
|
+
nowMs: Date.now()
|
|
444
|
+
})
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
async function runPreview(packDir, portText, env, homeDir) {
|
|
448
|
+
const port = portText === null ? 0 : Number(portText);
|
|
449
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535) {
|
|
450
|
+
process.stderr.write(`glimmervoid packs preview: --port must be a port number, not ${portText}\n`);
|
|
451
|
+
return 1;
|
|
452
|
+
}
|
|
453
|
+
const server = http.createServer((request, response) => {
|
|
454
|
+
if (!decideHostAllowed(request.headers.host)) {
|
|
455
|
+
response.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" }).end("Host not allowed");
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
previewResponse(packDir, request.url ?? "/", env, homeDir).then(({ status, headers, body }) => response.writeHead(status, headers).end(body), (error) => response.writeHead(500, { "Content-Type": "text/plain; charset=utf-8" }).end(errorMessage(error)));
|
|
459
|
+
});
|
|
460
|
+
const listening = await new Promise((resolve) => {
|
|
461
|
+
server.once("error", (error) => resolve({
|
|
462
|
+
ok: false,
|
|
463
|
+
error: errorMessage(error)
|
|
464
|
+
}));
|
|
465
|
+
server.listen(port, PREVIEW_HOST, () => {
|
|
466
|
+
const address = server.address();
|
|
467
|
+
resolve({
|
|
468
|
+
ok: true,
|
|
469
|
+
port: typeof address === "object" && address !== null ? address.port : port
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
if (!listening.ok) {
|
|
474
|
+
process.stderr.write(`glimmervoid packs preview: could not listen on ${PREVIEW_HOST}:${port}: ${listening.error}\n`);
|
|
475
|
+
return 1;
|
|
476
|
+
}
|
|
477
|
+
process.stdout.write(`Previewing ${packDir} at http://${PREVIEW_HOST}:${listening.port}/ with sample data; each page load re-reads the pack. Stop with Ctrl-C.\n`);
|
|
478
|
+
await new Promise((resolve) => {
|
|
479
|
+
process.once("SIGINT", () => server.close(() => resolve()));
|
|
480
|
+
process.once("SIGTERM", () => server.close(() => resolve()));
|
|
481
|
+
});
|
|
482
|
+
return 0;
|
|
483
|
+
}
|
|
484
|
+
async function runPacksCli(parsed) {
|
|
485
|
+
const env = process.env;
|
|
486
|
+
const homeDir = glimmervoidHomeDir(os.homedir(), env);
|
|
487
|
+
const [packFolder] = parsed.positionals;
|
|
488
|
+
const subcommand = parsed.commandPath[1];
|
|
489
|
+
if (subcommand === "guide") return runGuide(homeDir, typeof parsed.values.schema === "string" ? parsed.values.schema : null);
|
|
490
|
+
if (subcommand === "list") return runList();
|
|
491
|
+
if (packFolder === void 0) return 1;
|
|
492
|
+
const packDir = path.resolve(packFolder);
|
|
493
|
+
if (subcommand === "check") return runPackCheckCli({
|
|
494
|
+
packDir,
|
|
495
|
+
isJson: parsed.values.json === true,
|
|
496
|
+
env,
|
|
497
|
+
homeDir
|
|
498
|
+
});
|
|
499
|
+
return runPreview(packDir, typeof parsed.values.port === "string" ? parsed.values.port : null, env, homeDir);
|
|
500
|
+
}
|
|
501
|
+
//#endregion
|
|
502
|
+
export { runPacksCli as n, runPackCheckCli as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as runPacksCli } from "./packs-cli-DCKa39sG.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as errorMessage } from "./text-DoirglWV.js";
|
|
2
|
-
import { c as resolveConfigPath } from "./config-store-
|
|
3
|
-
import { c as defaultPairingsPath, i as REVOCATION_PROPAGATION_SECONDS, l as defaultSeenPath, n as normalizeRemoteConfig, o as createPairingsStore, s as createSeenStore } from "./remote-config-
|
|
2
|
+
import { c as resolveConfigPath } from "./config-store-aB3AE95Q.js";
|
|
3
|
+
import { c as defaultPairingsPath, i as REVOCATION_PROPAGATION_SECONDS, l as defaultSeenPath, n as normalizeRemoteConfig, o as createPairingsStore, s as createSeenStore } from "./remote-config-dHj-Qfux.js";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
//#region server/text-format.ts
|
|
6
6
|
function trimIso(iso) {
|