@hansenexus/hud 0.4.0 → 0.5.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 +603 -9
- package/dist/a11y-B5DUaiCs.js +246 -0
- package/dist/a11y-panel-p_t4eD7p.js +207 -0
- package/dist/{capabilities-CjulXFQX.js → access-C7zlaqj6.js} +1 -90
- package/dist/{access-CNvJOwKM.d.ts → access-D_ewAEJG.d.ts} +11 -4
- package/dist/access-panel-CEfTr9ZI.js +123 -0
- package/dist/adapter-BYoxPYTI.d.ts +33 -0
- package/dist/adapter-hcwmJtNx.js +65 -0
- package/dist/auto/runtime.d.ts +65 -0
- package/dist/auto/runtime.js +50 -0
- package/dist/auto.d.ts +15 -0
- package/dist/auto.js +33 -0
- package/dist/capabilities-rDSKjXpq.js +110 -0
- package/dist/capture-CwrIwLqi.js +300 -0
- package/dist/capture-buffer-Bbbo6omF.d.ts +35 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +275 -0
- package/dist/data-panel-DhxAmP91.js +817 -0
- package/dist/data-store-ChF1td_P.js +164 -0
- package/dist/define-hud-CHPedaQ5.d.ts +50 -0
- package/dist/design-D0kGgPoP.js +87 -0
- package/dist/detect-BxHZ0pxW.d.ts +25 -0
- package/dist/detect-CHZiSeZs.js +63 -0
- package/dist/dispatch-panel-B-xr_Giy.js +279 -0
- package/dist/{env-vEjyJfPW.d.ts → env-CApnbI0r.d.ts} +2 -0
- package/dist/{env-DfxpPfs9.js → env-CaiFPIhF.js} +3 -0
- package/dist/file-xdSaQ2uR.js +103 -0
- package/dist/flags-DVtaJ8pQ.d.ts +58 -0
- package/dist/flags.d.ts +2 -0
- package/dist/flags.js +82 -0
- package/dist/force-state-panel-_otVYh9i.js +97 -0
- package/dist/generate-C8lQl3Eh.js +53 -0
- package/dist/handler-BpVhxEmU.js +106 -0
- package/dist/{handler-WmE4Lu7l.d.ts → handler-DtYVCZY6.d.ts} +1 -1
- package/dist/index-BAV_1W8a.d.ts +43 -0
- package/dist/index-BJ26pse9.d.ts +70 -0
- package/dist/index-BnQ0dTZf.d.ts +19 -0
- package/dist/index-CwfX-W87.d.ts +72 -0
- package/dist/index-DcH9V3cU.d.ts +48 -0
- package/dist/index-DqOyNf1u.d.ts +65 -0
- package/dist/index-DstI_ike.d.ts +66 -0
- package/dist/index-Dxz4fn4j.d.ts +42 -0
- package/dist/index-Hhh7OXzU.d.ts +129 -0
- package/dist/index-ReFbhQ9p.d.ts +25 -0
- package/dist/index-RgXfMBuW.d.ts +48 -0
- package/dist/{index-BYsdS-7d.d.ts → index-gCZBO53s.d.ts} +21 -3
- package/dist/index.d.ts +5 -5
- package/dist/index.js +710 -69
- package/dist/inspect-C9Ft8fqn.js +142 -0
- package/dist/inspect-root-BkaupBMp.js +429 -0
- package/dist/meta-Bv0sEao3.js +6 -0
- package/dist/meta-C_G7MB5w.d.ts +49 -0
- package/dist/mocks-CA-wM2SB.d.ts +109 -0
- package/dist/mocks-ESiRqk9o.js +150 -0
- package/dist/msw-browser-wjaYgkB7.d.ts +31 -0
- package/dist/next/config.d.ts +52 -0
- package/dist/next/config.js +78 -0
- package/dist/next.d.ts +14 -4
- package/dist/next.js +5 -3
- package/dist/observe-CdDnDBRP.js +89 -0
- package/dist/observe-panel-Cgp1M8oT.js +347 -0
- package/dist/ops-panel-CEqDe_UT.js +234 -0
- package/dist/{payload-CLKDVZWl.d.ts → payload-MUQ9ciER.d.ts} +25 -1
- package/dist/plugins/a11y.d.ts +2 -0
- package/dist/plugins/a11y.js +2 -0
- package/dist/plugins/access/server.d.ts +5 -5
- package/dist/plugins/access/server.js +4 -3
- package/dist/plugins/access.d.ts +5 -5
- package/dist/plugins/access.js +16 -215
- package/dist/plugins/agent/server.d.ts +3 -38
- package/dist/plugins/agent/server.js +47 -21
- package/dist/plugins/agent.d.ts +4 -4
- package/dist/plugins/agent.js +6 -348
- package/dist/plugins/capture/server.d.ts +92 -0
- package/dist/plugins/capture/server.js +248 -0
- package/dist/plugins/capture.d.ts +24 -0
- package/dist/plugins/capture.js +70 -0
- package/dist/plugins/data/msw-browser.d.ts +2 -0
- package/dist/plugins/data/msw-browser.js +39 -0
- package/dist/plugins/data/msw-node.d.ts +36 -0
- package/dist/plugins/data/msw-node.js +68 -0
- package/dist/plugins/data/server.d.ts +257 -0
- package/dist/plugins/data/server.js +717 -0
- package/dist/plugins/data.d.ts +6 -0
- package/dist/plugins/data.js +51 -0
- package/dist/plugins/design/server.d.ts +54 -0
- package/dist/plugins/design/server.js +198 -0
- package/dist/plugins/design.d.ts +4 -124
- package/dist/plugins/design.js +4 -619
- package/dist/plugins/inspect/convex.d.ts +2 -0
- package/dist/plugins/inspect/convex.js +486 -0
- package/dist/plugins/inspect/react-query.d.ts +2 -0
- package/dist/plugins/inspect/react-query.js +225 -0
- package/dist/plugins/inspect/sockets.d.ts +51 -0
- package/dist/plugins/inspect/sockets.js +397 -0
- package/dist/plugins/inspect/swr.d.ts +2 -0
- package/dist/plugins/inspect/swr.js +218 -0
- package/dist/plugins/inspect.d.ts +4 -0
- package/dist/plugins/inspect.js +3 -0
- package/dist/plugins/observe.d.ts +4 -64
- package/dist/plugins/observe.js +1 -616
- package/dist/plugins/ops/server.d.ts +1 -1
- package/dist/plugins/ops/server.js +2 -1
- package/dist/plugins/ops.d.ts +2 -1
- package/dist/plugins/ops.js +15 -336
- package/dist/plugins/routes/server.d.ts +88 -0
- package/dist/plugins/routes/server.js +62 -0
- package/dist/plugins/routes.d.ts +3 -0
- package/dist/plugins/routes.js +216 -0
- package/dist/plugins/seo.d.ts +2 -0
- package/dist/plugins/seo.js +2 -0
- package/dist/plugins/vitals.d.ts +2 -25
- package/dist/plugins/vitals.js +3 -2
- package/dist/{plugins-CQ_0w1ot.d.ts → plugins-BZvDqGx5.d.ts} +33 -3
- package/dist/poll-CjKsWZi8.js +89 -0
- package/dist/requests-BwD6MKEq.js +282 -0
- package/dist/requests-CJrUf465.d.ts +50 -0
- package/dist/review.js +2 -2
- package/dist/same-origin-BGet22CC.js +21 -0
- package/dist/scan-DzJNXqOk.js +165 -0
- package/dist/seo-Dq9q_QkO.js +551 -0
- package/dist/seo-panel-CfiY-TnT.js +124 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -105
- package/dist/sessions-panel-COvhPAzv.js +98 -0
- package/dist/{shortcut-U6ftVY06.js → shortcut-s_mjGeU8.js} +1 -44
- package/dist/{types-QJUajwWq.js → state-CjjZPjPJ.js} +13 -8
- package/dist/store/convex.d.ts +33 -0
- package/dist/store/convex.js +52 -0
- package/dist/{vitals-panel-Dvc5dnR-.js → store-CQqIIKTc.js} +1 -29
- package/dist/store-Ync9eb1G.js +67 -0
- package/dist/store.d.ts +76 -0
- package/dist/store.js +188 -0
- package/dist/{styles--slk86ZQ.js → styles-BA8ueHoV.js} +13 -3
- package/dist/styles-DKU_P8MH.js +139 -0
- package/dist/styles-DPpDPmzi.js +68 -0
- package/dist/tokens-panel-CbMQfasZ.js +142 -0
- package/dist/types-B-ulf2Jp.js +8 -0
- package/dist/types-BIgGf-0C.d.ts +25 -0
- package/dist/types-BIkI-qN8.js +30 -0
- package/dist/{types-DADBRiGk.d.ts → types-Cxh4twqc.d.ts} +1 -1
- package/dist/types-DIdPfjtV.js +6 -0
- package/dist/types-DaJcsEjO.d.ts +44 -0
- package/dist/types-Dn68psVz.d.ts +118 -0
- package/dist/types-szkr2QOF.d.ts +39 -0
- package/dist/unlock-store-4V3vR4Eg.js +96 -0
- package/dist/variant-groups-TIfO3NIj.js +137 -0
- package/dist/variant-groups-aAIrcNK5.d.ts +36 -0
- package/dist/variants-panel-BDoSkwBJ.js +457 -0
- package/dist/variants-types-CcRf119M.d.ts +63 -0
- package/dist/variants.d.ts +43 -0
- package/dist/variants.js +83 -0
- package/dist/vitals-panel-BCmMUntW.js +30 -0
- package/dist/vite.d.ts +37 -0
- package/dist/vite.js +134 -0
- package/package.json +65 -5
- package/dist/define-hud-BBzsSl8b.d.ts +0 -36
package/dist/plugins/access.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { c as HudPluginProps, r as HudCapability } from "../plugins-
|
|
2
|
-
import "../
|
|
3
|
-
|
|
4
|
-
//#region src/plugins/access/access-panel.d.ts
|
|
1
|
+
import { c as HudPluginProps, r as HudCapability } from "../plugins-BZvDqGx5.js";
|
|
2
|
+
import { c as CAPABILITY_MATRIX, d as hasCapability, i as resolveHudAccess, l as CapabilityMatrixOverride, n as HudAccess, p as isProductionDenied, r as hudRequiresUnlock, s as ACCESS_UNLOCK_CAPABILITY, u as HUD_CAPABILITIES } from "../access-D_ewAEJG.js";
|
|
3
|
+
//#region src/plugins/access/access-pill.d.ts
|
|
5
4
|
declare function AccessPill(): import("react").JSX.Element;
|
|
6
5
|
//#endregion
|
|
7
6
|
//#region src/plugins/access/unlock-store.d.ts
|
|
@@ -31,6 +30,7 @@ export declare function access(options?: AccessOptions): {
|
|
|
31
30
|
readonly title: "Access";
|
|
32
31
|
readonly capability: "access.unlock";
|
|
33
32
|
readonly pill: typeof AccessPill;
|
|
33
|
+
readonly pillPriority: 30;
|
|
34
34
|
readonly panel: ({ ctx }: HudPluginProps) => import("react").JSX.Element;
|
|
35
35
|
readonly access: {
|
|
36
36
|
readonly can: (env: string, capability: HudCapability) => boolean;
|
|
@@ -38,4 +38,4 @@ export declare function access(options?: AccessOptions): {
|
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
//#endregion
|
|
41
|
-
export { ACCESS_UNLOCK_CAPABILITY, CAPABILITY_MATRIX, type CapabilityMatrixOverride, HUD_CAPABILITIES, type HudAccess, type UnlockStatus, hasCapability, hudRequiresUnlock, resolveHudAccess };
|
|
41
|
+
export { ACCESS_UNLOCK_CAPABILITY, CAPABILITY_MATRIX, type CapabilityMatrixOverride, HUD_CAPABILITIES, type HudAccess, type UnlockStatus, hasCapability, hudRequiresUnlock, isProductionDenied, resolveHudAccess };
|
package/dist/plugins/access.js
CHANGED
|
@@ -1,121 +1,10 @@
|
|
|
1
|
-
import { i as definePlugin
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { i as definePlugin } from "../plugins-DVy_vaYr.js";
|
|
2
|
+
import { n as hudRequiresUnlock, o as resolveHudAccess } from "../access-C7zlaqj6.js";
|
|
3
|
+
import { c as toHudEnv, i as hasCapability, n as CAPABILITY_MATRIX, o as isProductionDenied, r as HUD_CAPABILITIES, s as resolveMatrix, t as ACCESS_UNLOCK_CAPABILITY } from "../capabilities-rDSKjXpq.js";
|
|
4
|
+
import { n as useUnlockState, r as useUnlocked } from "../unlock-store-4V3vR4Eg.js";
|
|
5
|
+
import { lazy } from "react";
|
|
4
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
//#region src/plugins/access/
|
|
6
|
-
/**
|
|
7
|
-
* Unlock state of the page's HUD. The browser never sees the password or the
|
|
8
|
-
* token: the cookie is httpOnly and only the server can judge it, so this
|
|
9
|
-
* store asks the unlock route rather than reading anything locally.
|
|
10
|
-
*/
|
|
11
|
-
let state = {
|
|
12
|
-
env: "development",
|
|
13
|
-
status: "checking",
|
|
14
|
-
error: null
|
|
15
|
-
};
|
|
16
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
17
|
-
function set(patch) {
|
|
18
|
-
state = {
|
|
19
|
-
...state,
|
|
20
|
-
...patch
|
|
21
|
-
};
|
|
22
|
-
for (const listener of listeners) listener();
|
|
23
|
-
}
|
|
24
|
-
function subscribe(listener) {
|
|
25
|
-
listeners.add(listener);
|
|
26
|
-
return () => listeners.delete(listener);
|
|
27
|
-
}
|
|
28
|
-
const getState = () => state;
|
|
29
|
-
function useUnlockState() {
|
|
30
|
-
return useSyncExternalStore(subscribe, getState, getState);
|
|
31
|
-
}
|
|
32
|
-
function errorOf(body) {
|
|
33
|
-
if (body && typeof body === "object" && "error" in body && typeof body.error === "string") return body.error;
|
|
34
|
-
}
|
|
35
|
-
/** Asks `<apiBase>/access/unlock` whether this browser is unlocked. Any failure keeps it shut. */
|
|
36
|
-
async function refreshUnlockStatus(apiBase) {
|
|
37
|
-
try {
|
|
38
|
-
const res = await fetch(`${apiBase.replace(/\/+$/, "")}/access/unlock`, {
|
|
39
|
-
cache: "no-store",
|
|
40
|
-
headers: { accept: "application/json" }
|
|
41
|
-
});
|
|
42
|
-
const body = await res.json().catch(() => ({}));
|
|
43
|
-
if (!res.ok || !body || typeof body !== "object") {
|
|
44
|
-
set({ status: "locked" });
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const { configured, unlocked } = body;
|
|
48
|
-
set({ status: configured === false ? "unconfigured" : unlocked === true ? "unlocked" : "locked" });
|
|
49
|
-
} catch {
|
|
50
|
-
set({ status: "locked" });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/** Trades the password for the unlock cookie through the plugin's own route. */
|
|
54
|
-
async function submitPassword(api, password) {
|
|
55
|
-
set({ error: null });
|
|
56
|
-
try {
|
|
57
|
-
if ((await api("/unlock", {
|
|
58
|
-
method: "POST",
|
|
59
|
-
headers: { "content-type": "application/json" },
|
|
60
|
-
body: JSON.stringify({ password })
|
|
61
|
-
}))?.unlocked === true) {
|
|
62
|
-
set({ status: "unlocked" });
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
set({ error: "unlock refused" });
|
|
66
|
-
} catch (cause) {
|
|
67
|
-
set({ error: cause instanceof HudApiError ? errorOf(cause.body) ?? `unlock refused (${cause.status})` : "unlock failed" });
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* `HudAccessControl.useUnlocked`: development is open, a disabled or unknown
|
|
73
|
-
* tier never unlocks, every deployed tier asks the server once per mount.
|
|
74
|
-
*/
|
|
75
|
-
function useUnlocked(envName, apiBase) {
|
|
76
|
-
const env = toHudEnv(envName);
|
|
77
|
-
const access = resolveHudAccess(env);
|
|
78
|
-
const { status } = useUnlockState();
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
const required = hudRequiresUnlock(access);
|
|
81
|
-
set({
|
|
82
|
-
env,
|
|
83
|
-
status: access === "open" ? "unlocked" : required ? "checking" : "locked"
|
|
84
|
-
});
|
|
85
|
-
if (required) refreshUnlockStatus(apiBase);
|
|
86
|
-
}, [
|
|
87
|
-
env,
|
|
88
|
-
access,
|
|
89
|
-
apiBase
|
|
90
|
-
]);
|
|
91
|
-
if (access === "open") return true;
|
|
92
|
-
if (access === "denied") return false;
|
|
93
|
-
return status === "unlocked";
|
|
94
|
-
}
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/plugins/access/access-panel.tsx
|
|
97
|
-
const ACCESS_TEXT = {
|
|
98
|
-
open: "open, no password",
|
|
99
|
-
password: "password",
|
|
100
|
-
flag: "password, observe-only",
|
|
101
|
-
denied: "disabled"
|
|
102
|
-
};
|
|
103
|
-
const field = {
|
|
104
|
-
flex: 1,
|
|
105
|
-
minWidth: 0,
|
|
106
|
-
padding: "3px 6px",
|
|
107
|
-
font: "inherit",
|
|
108
|
-
fontFamily: "var(--hud-mono)",
|
|
109
|
-
color: "var(--hud-fg)",
|
|
110
|
-
background: "var(--hud-bg-subtle)",
|
|
111
|
-
border: "1px solid var(--hud-border)",
|
|
112
|
-
borderRadius: 4
|
|
113
|
-
};
|
|
114
|
-
const button = {
|
|
115
|
-
padding: "3px 10px",
|
|
116
|
-
border: "1px solid var(--hud-border)",
|
|
117
|
-
borderRadius: 4
|
|
118
|
-
};
|
|
7
|
+
//#region src/plugins/access/access-pill.tsx
|
|
119
8
|
function AccessPill() {
|
|
120
9
|
const { env, status } = useUnlockState();
|
|
121
10
|
const access = resolveHudAccess(env);
|
|
@@ -125,104 +14,9 @@ function AccessPill() {
|
|
|
125
14
|
"data-rating": unlocked ? "good" : "poor"
|
|
126
15
|
}), access === "open" ? "Open" : unlocked ? "Unlocked" : "Locked"] });
|
|
127
16
|
}
|
|
128
|
-
/** The panel a locked deployed HUD shows instead of every other plugin. */
|
|
129
|
-
function createAccessPanel(matrix) {
|
|
130
|
-
return function AccessPanel({ ctx }) {
|
|
131
|
-
const { env, status, error } = useUnlockState();
|
|
132
|
-
const [password, setPassword] = useState("");
|
|
133
|
-
const [submitting, setSubmitting] = useState(false);
|
|
134
|
-
const access = resolveHudAccess(env);
|
|
135
|
-
const ttlHours = hudUnlockTtlMs(access) / 36e5;
|
|
136
|
-
async function onSubmit(event) {
|
|
137
|
-
event.preventDefault();
|
|
138
|
-
if (!password || submitting) return;
|
|
139
|
-
setSubmitting(true);
|
|
140
|
-
const ok = await submitPassword(ctx.api, password);
|
|
141
|
-
setSubmitting(false);
|
|
142
|
-
if (ok) setPassword("");
|
|
143
|
-
}
|
|
144
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
145
|
-
style: {
|
|
146
|
-
display: "grid",
|
|
147
|
-
gap: 8
|
|
148
|
-
},
|
|
149
|
-
children: [
|
|
150
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
151
|
-
/* @__PURE__ */ jsx("strong", { children: env }),
|
|
152
|
-
" ",
|
|
153
|
-
/* @__PURE__ */ jsxs("span", {
|
|
154
|
-
className: "empty",
|
|
155
|
-
children: ["· ", ACCESS_TEXT[access]]
|
|
156
|
-
})
|
|
157
|
-
] }),
|
|
158
|
-
status === "unconfigured" && /* @__PURE__ */ jsx("p", {
|
|
159
|
-
className: "empty",
|
|
160
|
-
style: { margin: 0 },
|
|
161
|
-
children: "No unlock password is configured on this deployment's server, so the HUD cannot be unlocked here."
|
|
162
|
-
}),
|
|
163
|
-
status !== "unconfigured" && access !== "open" && status !== "unlocked" && /* @__PURE__ */ jsxs("form", {
|
|
164
|
-
style: {
|
|
165
|
-
display: "flex",
|
|
166
|
-
gap: 6
|
|
167
|
-
},
|
|
168
|
-
onSubmit,
|
|
169
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
170
|
-
type: "password",
|
|
171
|
-
autoComplete: "off",
|
|
172
|
-
value: password,
|
|
173
|
-
onChange: (event) => setPassword(event.target.value),
|
|
174
|
-
placeholder: "hud password",
|
|
175
|
-
"aria-label": "hud password",
|
|
176
|
-
style: field
|
|
177
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
178
|
-
type: "submit",
|
|
179
|
-
style: button,
|
|
180
|
-
disabled: !password || submitting,
|
|
181
|
-
children: submitting ? "Checking…" : "Unlock"
|
|
182
|
-
})]
|
|
183
|
-
}),
|
|
184
|
-
error && /* @__PURE__ */ jsx("p", {
|
|
185
|
-
role: "alert",
|
|
186
|
-
style: {
|
|
187
|
-
margin: 0,
|
|
188
|
-
color: "var(--hud-poor)"
|
|
189
|
-
},
|
|
190
|
-
children: error
|
|
191
|
-
}),
|
|
192
|
-
access !== "open" && status === "unlocked" && /* @__PURE__ */ jsxs("p", {
|
|
193
|
-
className: "empty",
|
|
194
|
-
style: { margin: 0 },
|
|
195
|
-
children: [
|
|
196
|
-
"Unlocked for up to ",
|
|
197
|
-
ttlHours,
|
|
198
|
-
" h."
|
|
199
|
-
]
|
|
200
|
-
}),
|
|
201
|
-
access !== "open" && status !== "unlocked" && ttlHours > 0 && /* @__PURE__ */ jsxs("p", {
|
|
202
|
-
className: "empty",
|
|
203
|
-
style: { margin: 0 },
|
|
204
|
-
children: [
|
|
205
|
-
"An unlock lasts ",
|
|
206
|
-
ttlHours,
|
|
207
|
-
" h."
|
|
208
|
-
]
|
|
209
|
-
}),
|
|
210
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
|
|
211
|
-
className: "empty",
|
|
212
|
-
children: "Capabilities"
|
|
213
|
-
}), /* @__PURE__ */ jsx("code", {
|
|
214
|
-
style: {
|
|
215
|
-
fontFamily: "var(--hud-mono)",
|
|
216
|
-
whiteSpace: "pre-wrap"
|
|
217
|
-
},
|
|
218
|
-
children: env === "development" ? "all" : matrix[env].join("\n") || "none"
|
|
219
|
-
})] })
|
|
220
|
-
]
|
|
221
|
-
});
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
17
|
//#endregion
|
|
225
18
|
//#region src/plugins/access/index.tsx
|
|
19
|
+
const Panel = lazy(() => import("../access-panel-CEfTr9ZI.js"));
|
|
226
20
|
/**
|
|
227
21
|
* Opt-in for deployed tiers. Without it `defineHud` renders nothing outside
|
|
228
22
|
* development. With it the HUD follows the env ladder: a tier's capability
|
|
@@ -234,12 +28,19 @@ function createAccessPanel(matrix) {
|
|
|
234
28
|
*/
|
|
235
29
|
function access(options = {}) {
|
|
236
30
|
const matrix = resolveMatrix(options.matrix);
|
|
31
|
+
function AccessPanel({ ctx }) {
|
|
32
|
+
return /* @__PURE__ */ jsx(Panel, {
|
|
33
|
+
ctx,
|
|
34
|
+
matrix
|
|
35
|
+
});
|
|
36
|
+
}
|
|
237
37
|
return definePlugin({
|
|
238
38
|
id: "access",
|
|
239
39
|
title: "Access",
|
|
240
40
|
capability: ACCESS_UNLOCK_CAPABILITY,
|
|
241
41
|
pill: AccessPill,
|
|
242
|
-
|
|
42
|
+
pillPriority: 30,
|
|
43
|
+
panel: AccessPanel,
|
|
243
44
|
access: {
|
|
244
45
|
can: (env, capability) => capability === "access.unlock" || hasCapability(toHudEnv(env), capability, matrix),
|
|
245
46
|
useUnlocked
|
|
@@ -247,4 +48,4 @@ function access(options = {}) {
|
|
|
247
48
|
});
|
|
248
49
|
}
|
|
249
50
|
//#endregion
|
|
250
|
-
export { ACCESS_UNLOCK_CAPABILITY, CAPABILITY_MATRIX, HUD_CAPABILITIES, access, hasCapability, hudRequiresUnlock, resolveHudAccess };
|
|
51
|
+
export { ACCESS_UNLOCK_CAPABILITY, CAPABILITY_MATRIX, HUD_CAPABILITIES, access, hasCapability, hudRequiresUnlock, isProductionDenied, resolveHudAccess };
|
|
@@ -1,42 +1,7 @@
|
|
|
1
|
-
import { r as GrabPayload, t as ComponentHint } from "../../payload-
|
|
2
|
-
import { a as DispatchTargetInfo, i as DispatchReceipt, n as AgentSessionStatus, o as SessionsResponse, r as DispatchBody, t as AgentSession } from "../../types-
|
|
1
|
+
import { r as GrabPayload, t as ComponentHint } from "../../payload-MUQ9ciER.js";
|
|
2
|
+
import { a as DispatchTargetInfo, i as DispatchReceipt, n as AgentSessionStatus, o as SessionsResponse, r as DispatchBody, t as AgentSession } from "../../types-Cxh4twqc.js";
|
|
3
|
+
import { n as DispatchProvider, r as ProviderStatus, t as DispatchOrder } from "../../types-szkr2QOF.js";
|
|
3
4
|
import { ChildProcess, SpawnOptions } from "node:child_process";
|
|
4
|
-
//#region src/plugins/agent/providers/types.d.ts
|
|
5
|
-
/** What a provider receives: the raw request plus the prompt built from it. */
|
|
6
|
-
interface DispatchOrder {
|
|
7
|
-
note: string;
|
|
8
|
-
payload: GrabPayload | null;
|
|
9
|
-
hints: ComponentHint[];
|
|
10
|
-
/** `dispatchPrompt(...)` of the above; what an agent should be told. */
|
|
11
|
-
prompt: string;
|
|
12
|
-
}
|
|
13
|
-
type ProviderStatus = {
|
|
14
|
-
available: true;
|
|
15
|
-
} | {
|
|
16
|
-
available: false;
|
|
17
|
-
reason: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* The `dispatch` provider seam. One implementation per backend: `hermes()`
|
|
21
|
-
* and `claudeCode()` ship with the plugin; anything with the same shape works.
|
|
22
|
-
* Runs server side only.
|
|
23
|
-
*/
|
|
24
|
-
interface DispatchProvider {
|
|
25
|
-
/** Unique among the providers passed in; the client selects a target by it. */
|
|
26
|
-
id: string;
|
|
27
|
-
label: string;
|
|
28
|
-
description?: string;
|
|
29
|
-
/** Default: available. */
|
|
30
|
-
status?: () => ProviderStatus | Promise<ProviderStatus>;
|
|
31
|
-
/** Starts work and returns as soon as it is accepted, not when it finishes. */
|
|
32
|
-
dispatch: (order: DispatchOrder) => Promise<{
|
|
33
|
-
runId: string;
|
|
34
|
-
detail?: string;
|
|
35
|
-
}>;
|
|
36
|
-
/** Runs and sessions this backend knows about, for the Sessions panel. */
|
|
37
|
-
sessions?: () => Promise<AgentSession[]>;
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
5
|
//#region src/plugins/agent/prompt.d.ts
|
|
41
6
|
interface PromptInput {
|
|
42
7
|
note: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { i as definePlugin } from "../../plugins-DVy_vaYr.js";
|
|
2
|
+
import { t as refuseCrossSite } from "../../same-origin-BGet22CC.js";
|
|
2
3
|
//#region src/plugins/agent/prompt.ts
|
|
3
4
|
/** The task text every provider receives: grab context first, then the instruction. */
|
|
4
5
|
function dispatchPrompt({ note, payload, hints = [] }) {
|
|
@@ -21,7 +22,13 @@ function dispatchPrompt({ note, payload, hints = [] }) {
|
|
|
21
22
|
}
|
|
22
23
|
if (hints.length > 0) lines.push(`Component manifest matches (best effort, verify): ${hints.map((h) => h.path).join(", ")}`);
|
|
23
24
|
if (!component?.source && hints.length === 0) lines.push("No source hint: locate the component from the route and selector.");
|
|
24
|
-
lines.push(`Viewport: ${payload.viewport.width}×${payload.viewport.height}
|
|
25
|
+
lines.push(`Viewport: ${payload.viewport.width}×${payload.viewport.height}`);
|
|
26
|
+
const shot = payload.screenshot;
|
|
27
|
+
if (shot?.status === "ready") {
|
|
28
|
+
const what = shot.scope === "element" ? "the grabbed element" : "the viewport (element not found headless)";
|
|
29
|
+
lines.push(`Screenshot: PNG ${shot.width}×${shot.height} of ${what}, attached to this dispatch.`);
|
|
30
|
+
} else if (shot?.status === "unavailable") lines.push(`Screenshot: none (${shot.reason}).`);
|
|
31
|
+
lines.push(`Instruction: ${instruction}`, "", "Task: locate the element's source, apply the instruction, and run the project's checks.");
|
|
25
32
|
return lines.join("\n");
|
|
26
33
|
}
|
|
27
34
|
//#endregion
|
|
@@ -146,10 +153,17 @@ function claudeCode({ cwd: cwdOption, command = "claude", args = defaultArgs, la
|
|
|
146
153
|
await api.fsp.mkdir(logDir, { recursive: true });
|
|
147
154
|
const id = `run-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
|
|
148
155
|
const log = path.join(logDir, `${id}.log`);
|
|
156
|
+
let prompt = order.prompt;
|
|
157
|
+
const shot = order.payload?.screenshot;
|
|
158
|
+
if (shot?.status === "ready") {
|
|
159
|
+
const image = path.join(logDir, `${id}.png`);
|
|
160
|
+
await api.fsp.writeFile(image, Buffer.from(shot.base64, "base64"), { mode: 384 });
|
|
161
|
+
prompt += `\nScreenshot file (PNG of the grabbed element): ${image}`;
|
|
162
|
+
}
|
|
149
163
|
const fd = fs.openSync(log, "a", 384);
|
|
150
164
|
let child;
|
|
151
165
|
try {
|
|
152
|
-
child = spawn(command, args(
|
|
166
|
+
child = spawn(command, args(prompt), {
|
|
153
167
|
cwd: cwdOf(api),
|
|
154
168
|
detached: true,
|
|
155
169
|
stdio: [
|
|
@@ -271,27 +285,30 @@ function hermes({ baseUrl, token, instructions, label = "Hermes", timeoutMs = 1e
|
|
|
271
285
|
function message(error) {
|
|
272
286
|
return error instanceof Error ? error.message : String(error);
|
|
273
287
|
}
|
|
274
|
-
/**
|
|
275
|
-
* A dispatch spawns an agent, so a page on another origin must not be able to
|
|
276
|
-
* trigger one through the developer's browser. A JSON content type forces a
|
|
277
|
-
* CORS preflight that this route never answers, and `Sec-Fetch-Site` rejects
|
|
278
|
-
* cross-site requests outright where the browser sends it.
|
|
279
|
-
*/
|
|
280
|
-
function refuseCrossSite(request) {
|
|
281
|
-
const site = request.headers.get("sec-fetch-site");
|
|
282
|
-
if (site && site !== "same-origin" && site !== "none") return Response.json({
|
|
283
|
-
ok: false,
|
|
284
|
-
error: "cross-site request refused"
|
|
285
|
-
}, { status: 403 });
|
|
286
|
-
if (!request.headers.get("content-type")?.toLowerCase().startsWith("application/json")) return Response.json({
|
|
287
|
-
ok: false,
|
|
288
|
-
error: "expected application/json"
|
|
289
|
-
}, { status: 415 });
|
|
290
|
-
return null;
|
|
291
|
-
}
|
|
292
288
|
function isRecord(value) {
|
|
293
289
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
294
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* The grab's screenshot as the `capture` plugin attached it: a PNG, or the
|
|
293
|
+
* reason there is none. A `pending` one (the panel waits for it, but a raw
|
|
294
|
+
* client may not) is dropped.
|
|
295
|
+
*/
|
|
296
|
+
function parseScreenshot(value) {
|
|
297
|
+
if (!isRecord(value)) return void 0;
|
|
298
|
+
if (value.status === "ready" && value.mime === "image/png" && typeof value.base64 === "string" && /^[A-Za-z0-9+/]*={0,2}$/.test(value.base64) && typeof value.width === "number" && typeof value.height === "number" && (value.scope === "element" || value.scope === "viewport")) return {
|
|
299
|
+
status: "ready",
|
|
300
|
+
mime: "image/png",
|
|
301
|
+
base64: value.base64,
|
|
302
|
+
width: value.width,
|
|
303
|
+
height: value.height,
|
|
304
|
+
scope: value.scope
|
|
305
|
+
};
|
|
306
|
+
if (value.status === "unavailable" && typeof value.reason === "string") return {
|
|
307
|
+
status: "unavailable",
|
|
308
|
+
reason: value.reason,
|
|
309
|
+
...typeof value.hint === "string" ? { hint: value.hint } : {}
|
|
310
|
+
};
|
|
311
|
+
}
|
|
295
312
|
/** Shape check, not a schema: enough that the prompt builder cannot throw on it. */
|
|
296
313
|
function parseBody(value) {
|
|
297
314
|
if (!isRecord(value) || typeof value.target !== "string") return null;
|
|
@@ -300,10 +317,19 @@ function parseBody(value) {
|
|
|
300
317
|
const validPayload = isRecord(payload) && typeof payload.app === "string" && typeof payload.route === "string" && isRecord(payload.anchor) && typeof payload.anchor.label === "string" && typeof payload.anchor.selector === "string" && isRecord(payload.viewport) && typeof payload.viewport.width === "number" && typeof payload.viewport.height === "number" && (payload.component == null || isRecord(payload.component) && typeof payload.component.name === "string" && Array.isArray(payload.component.owners));
|
|
301
318
|
if (payload != null && !validPayload) return null;
|
|
302
319
|
const hints = Array.isArray(value.hints) ? value.hints.filter((h) => isRecord(h) && typeof h.name === "string" && typeof h.path === "string") : [];
|
|
320
|
+
let grab = null;
|
|
321
|
+
if (validPayload) {
|
|
322
|
+
const { screenshot: raw, ...rest } = payload;
|
|
323
|
+
const screenshot = parseScreenshot(raw);
|
|
324
|
+
grab = {
|
|
325
|
+
...rest,
|
|
326
|
+
...screenshot ? { screenshot } : {}
|
|
327
|
+
};
|
|
328
|
+
}
|
|
303
329
|
return {
|
|
304
330
|
target: value.target,
|
|
305
331
|
note,
|
|
306
|
-
payload:
|
|
332
|
+
payload: grab,
|
|
307
333
|
hints
|
|
308
334
|
};
|
|
309
335
|
}
|
package/dist/plugins/agent.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as GrabPayload, t as ComponentHint } from "../payload-
|
|
2
|
-
import { c as HudPluginProps, s as HudPluginContext } from "../plugins-
|
|
3
|
-
import "../index-
|
|
4
|
-
import { a as DispatchTargetInfo, i as DispatchReceipt, n as AgentSessionStatus, o as SessionsResponse, r as DispatchBody, t as AgentSession } from "../types-
|
|
1
|
+
import { r as GrabPayload, t as ComponentHint } from "../payload-MUQ9ciER.js";
|
|
2
|
+
import { c as HudPluginProps, s as HudPluginContext } from "../plugins-BZvDqGx5.js";
|
|
3
|
+
import "../index-gCZBO53s.js";
|
|
4
|
+
import { a as DispatchTargetInfo, i as DispatchReceipt, n as AgentSessionStatus, o as SessionsResponse, r as DispatchBody, t as AgentSession } from "../types-Cxh4twqc.js";
|
|
5
5
|
//#region src/plugins/agent/index.d.ts
|
|
6
6
|
export interface AgentDispatchOptions {
|
|
7
7
|
/**
|