@hansenexus/hud 0.7.0 → 0.9.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.
Files changed (77) hide show
  1. package/README.md +153 -14
  2. package/dist/{access-Bc709qpl.d.ts → access-CwPCPsv0.d.ts} +1 -1
  3. package/dist/auto/runtime.d.ts +9 -9
  4. package/dist/auto.d.ts +2 -2
  5. package/dist/auto.js +1 -1
  6. package/dist/cli.js +34 -1
  7. package/dist/{define-hud-DTv3njuU.d.ts → define-hud-B0aFXrcK.d.ts} +1 -1
  8. package/dist/{design-BXG1a4we.js → design-BIXY1-Ex.js} +26 -8
  9. package/dist/{force-state-panel-mu-txJnA.js → force-state-panel-D5oDydLs.js} +1 -1
  10. package/dist/{handler-DMzSTqyG.d.ts → handler-BmFhaA2D.d.ts} +1 -1
  11. package/dist/{index-C3wzZS3o.d.ts → index-5B7foZut.d.ts} +2 -2
  12. package/dist/{index-D-hI-DRJ.d.ts → index-B2KCKkN0.d.ts} +1 -1
  13. package/dist/index-B7qaEUgh.d.ts +44 -0
  14. package/dist/{index-CQXiuMZQ.d.ts → index-BGFyuJyN.d.ts} +1 -1
  15. package/dist/{index-Caohnz3B.d.ts → index-BeqWehuh.d.ts} +38 -10
  16. package/dist/{index-BJJoAXJ2.d.ts → index-BqKysxTq.d.ts} +1 -1
  17. package/dist/{index-DLCSLWW4.d.ts → index-D97Fnoie.d.ts} +2 -2
  18. package/dist/{index-BR5OB7DO.d.ts → index-DS0yT0c-.d.ts} +1 -1
  19. package/dist/{index-BNoPbSYD.d.ts → index-DvlCkGB1.d.ts} +1 -1
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +49 -196
  22. package/dist/lanes-panel-Disg54DY.js +395 -0
  23. package/dist/navigation-CX6AXm7H.js +176 -0
  24. package/dist/next/config.cjs +2 -0
  25. package/dist/next/config.d.cts +1 -0
  26. package/dist/next/config.d.ts +1 -0
  27. package/dist/next/config.js +2 -0
  28. package/dist/next.d.ts +4 -1
  29. package/dist/next.js +12 -1
  30. package/dist/obstacles-CCmRFTcZ.js +176 -0
  31. package/dist/plugins/a11y.d.ts +1 -1
  32. package/dist/plugins/access/server.d.ts +3 -3
  33. package/dist/plugins/access.d.ts +2 -2
  34. package/dist/plugins/agent/server.js +1 -1
  35. package/dist/plugins/agent.d.ts +2 -2
  36. package/dist/plugins/capture.d.ts +2 -2
  37. package/dist/plugins/data/server.d.ts +1 -1
  38. package/dist/plugins/data/server.js +1 -1
  39. package/dist/plugins/data.d.ts +1 -1
  40. package/dist/plugins/design/server.d.ts +55 -15
  41. package/dist/plugins/design/server.js +187 -122
  42. package/dist/plugins/design.d.ts +3 -3
  43. package/dist/plugins/design.js +1 -1
  44. package/dist/plugins/inspect.d.ts +1 -1
  45. package/dist/plugins/lanes/server.d.ts +165 -0
  46. package/dist/plugins/lanes/server.js +845 -0
  47. package/dist/plugins/lanes.d.ts +22 -0
  48. package/dist/plugins/lanes.js +30 -0
  49. package/dist/plugins/observe.d.ts +1 -1
  50. package/dist/plugins/ops/server.d.ts +1 -1
  51. package/dist/plugins/ops.d.ts +1 -1
  52. package/dist/plugins/routes/server.d.ts +1 -1
  53. package/dist/plugins/routes.d.ts +3 -3
  54. package/dist/plugins/routes.js +381 -52
  55. package/dist/plugins/seo.d.ts +1 -1
  56. package/dist/plugins/vitals.d.ts +1 -1
  57. package/dist/{plugins-BZT-1LBe.d.ts → plugins-pL2CoWzI.d.ts} +7 -0
  58. package/dist/same-origin-BHuZO1_H.js +36 -0
  59. package/dist/server.d.ts +2 -2
  60. package/dist/store.d.ts +1 -1
  61. package/dist/store.js +1 -1
  62. package/dist/types-BkrkOP3h.js +6 -0
  63. package/dist/types-Dazn3aWZ.d.ts +86 -0
  64. package/dist/{meta-C_G7MB5w.d.ts → types-Dc6JWZR7.d.ts} +6 -6
  65. package/dist/variant-bar-BzZ0ln-C.js +768 -0
  66. package/dist/variant-picks-Byc0hC8a.js +144 -0
  67. package/dist/variants-export-vEtZ-OGC.js +75 -0
  68. package/dist/{variants-panel-B6zWcknV.js → variants-panel-D23v5KIp.js} +71 -54
  69. package/dist/variants-types-BOsZ5fDz.js +65 -0
  70. package/dist/variants-types-VkW7vFZF.d.ts +139 -0
  71. package/dist/variants.d.ts +1 -1
  72. package/dist/variants.js +1 -1
  73. package/dist/vite.d.ts +2 -2
  74. package/package.json +2 -2
  75. package/dist/index-B1vHAY9p.d.ts +0 -20
  76. package/dist/same-origin-BGet22CC.js +0 -21
  77. package/dist/variants-types-CcRf119M.d.ts +0 -63
@@ -1,45 +1,8 @@
1
1
  import { i as definePlugin } from "../../plugins-CcW_K7c2.js";
2
- import { t as refuseCrossSite } from "../../same-origin-BGet22CC.js";
2
+ import { t as refuseCrossSite } from "../../same-origin-BHuZO1_H.js";
3
3
  import { t as HudStoreError } from "../../types-BIkI-qN8.js";
4
- //#region src/plugins/design/variants-types.ts
5
- /** Wire types shared by the Variants panel and `variantsServer()`. */
6
- /** The store collection scores and decisions live in: `.hud/variants.json` with `file()`. */
7
- const VARIANTS_COLLECTION = "variants";
8
- function recordKey(group, id) {
9
- return `${group}:${id}`;
10
- }
11
- function isRecord$1(value) {
12
- return typeof value === "object" && value !== null && !Array.isArray(value);
13
- }
14
- const STATUSES = [
15
- "open",
16
- "decided",
17
- "rejected"
18
- ];
19
- /**
20
- * A store entry as a `VariantRecord`: group and id come from the fields, or
21
- * from a `<group>:<id>` key when the file omits them. Unknown fields are
22
- * dropped, wrong types ignored; null when neither names the variant.
23
- */
24
- function toVariantRecord(id, value) {
25
- if (!isRecord$1(value)) return null;
26
- const separator = id.indexOf(":");
27
- const group = typeof value.group === "string" ? value.group : separator > 0 ? id.slice(0, separator) : "";
28
- const variant = typeof value.id === "string" ? value.id : separator > 0 ? id.slice(separator + 1) : "";
29
- if (!group || !variant) return null;
30
- const record = {
31
- group,
32
- id: variant
33
- };
34
- if (typeof value.label === "string") record.label = value.label;
35
- if (typeof value.status === "string" && STATUSES.includes(value.status)) record.status = value.status;
36
- if (typeof value.score === "number" && Number.isFinite(value.score)) record.score = value.score;
37
- if (typeof value.rationale === "string") record.rationale = value.rationale;
38
- if (typeof value.scoredBy === "string") record.scoredBy = value.scoredBy;
39
- if (typeof value.decidedAt === "string") record.decidedAt = value.decidedAt;
40
- return record;
41
- }
42
- //#endregion
4
+ import { a as toGroupRecord, i as recordKey, n as VARIANTS_COLLECTION, o as toVariantRecord, r as pickedRecord } from "../../variants-types-BOsZ5fDz.js";
5
+ import { n as readVariants, t as formatVariantsMarkdown } from "../../variants-export-vEtZ-OGC.js";
43
6
  //#region src/plugins/design/server.ts
44
7
  const NO_STORE = { "cache-control": "no-store" };
45
8
  function isRecord(value) {
@@ -59,41 +22,162 @@ function failed(error, what) {
59
22
  error: `${what} failed`
60
23
  }, { status: 500 });
61
24
  }
62
- function parseDecide(value) {
63
- if (!isRecord(value) || typeof value.id !== "string" || !value.id) return null;
64
- const body = { id: value.id };
25
+ const ID_MAX = 100;
26
+ const BODY_MAX = 65536;
27
+ const isId = (value) => typeof value === "string" && value.length > 0 && value.length <= ID_MAX;
28
+ function parsePick(value) {
29
+ if (!isRecord(value)) return null;
30
+ const body = {};
31
+ if (value.id === null || isId(value.id)) body.id = value.id;
32
+ else if (value.id !== void 0) return null;
33
+ if (typeof value.note === "string") body.note = value.note.trim();
34
+ else if (value.note !== void 0) return null;
35
+ if (body.note !== void 0 && body.note.length > 4e3) return null;
36
+ if (body.id === void 0 && body.note === void 0) return null;
65
37
  if (typeof value.label === "string") body.label = value.label;
66
- if (Array.isArray(value.variants)) body.variants = value.variants.flatMap((v) => isRecord(v) && typeof v.id === "string" && v.id ? [{
38
+ if (Array.isArray(value.variants)) body.variants = value.variants.flatMap((v) => isRecord(v) && isId(v.id) ? [{
67
39
  id: v.id,
68
40
  label: typeof v.label === "string" ? v.label : v.id
69
41
  }] : []);
70
42
  return body;
71
43
  }
44
+ async function readJson(request) {
45
+ const text = await request.text().catch(() => "");
46
+ if (text.length > BODY_MAX) return null;
47
+ try {
48
+ return JSON.parse(text);
49
+ } catch {
50
+ return null;
51
+ }
52
+ }
53
+ /** A group id the store can key and a `<group>:<id>` record cannot collide with. */
54
+ const isGroup = (group) => isId(group) && !group.includes(":");
55
+ const invalid = (error, status = 400) => Response.json({
56
+ ok: false,
57
+ error
58
+ }, { status });
72
59
  const quote = (v) => v.label === v.id ? `"${v.id}"` : `"${v.id}" (${v.label})`;
73
- /** The cleanup brief Decide hands the dispatch seam. */
74
- function cleanupBrief({ group, label, winner, losers, decidedAt }) {
60
+ /** The cleanup brief "Queue cleanup" hands the dispatch seam. */
61
+ function cleanupBrief({ group, label, winner, losers, decidedAt, note }) {
75
62
  const name = label === group ? `"${group}"` : `"${group}" (${label})`;
76
63
  const remove = losers.length > 0 ? `remove ${losers.map(quote).join(", ")}` : "there are no other variants";
77
64
  return [
78
- `Variant group ${name} was decided on ${decidedAt}: keep ${quote(winner)}, ${remove}.`,
65
+ `Variant group ${name} was decided on ${decidedAt || "an unknown date"}: keep ${quote(winner)}, ${remove}.`,
79
66
  "",
67
+ ...note ? [`Note on the pick: ${note}`, ""] : [],
80
68
  `Task: find <VariantGroup id="${group}"> in the app, inline the winning variant's markup where the group renders, delete the losing variants and the VariantGroup wrapper, remove the group's entries from .hud/variants.json, and run the project's checks.`
81
69
  ].join("\n");
82
70
  }
83
- async function listRecords(store) {
84
- return (await store.list(VARIANTS_COLLECTION)).flatMap((entry) => {
85
- const record = toVariantRecord(entry.id, entry.value);
86
- return record ? [record] : [];
71
+ async function readAll(store) {
72
+ const entries = await store.list(VARIANTS_COLLECTION);
73
+ const stored = {
74
+ records: [],
75
+ groups: []
76
+ };
77
+ for (const { id, value } of entries) {
78
+ const record = toVariantRecord(id, value);
79
+ if (record) stored.records.push(record);
80
+ else {
81
+ const group = toGroupRecord(id, value);
82
+ if (group) stored.groups.push(group);
83
+ }
84
+ }
85
+ return stored;
86
+ }
87
+ /** Writes the pick onto the group's variant records: winner, rejected, or all open again. */
88
+ async function writePick(store, group, id, records, variants, at) {
89
+ const byId = new Map(records.map((r) => [r.id, r]));
90
+ const known = /* @__PURE__ */ new Map();
91
+ for (const r of records) known.set(r.id, r.label ?? r.id);
92
+ for (const v of variants ?? []) known.set(v.id, v.label);
93
+ if (id !== null && !known.has(id)) known.set(id, id);
94
+ for (const [variant, label] of known) {
95
+ const { decidedAt: _previous, ...rest } = byId.get(variant) ?? {
96
+ group,
97
+ id: variant
98
+ };
99
+ const record = {
100
+ ...rest,
101
+ group,
102
+ id: variant,
103
+ label,
104
+ status: "open"
105
+ };
106
+ if (id !== null) record.status = variant === id ? "decided" : "rejected";
107
+ if (variant === id) record.decidedAt = at;
108
+ await store.set(VARIANTS_COLLECTION, recordKey(group, variant), { ...record });
109
+ }
110
+ }
111
+ /** Applies a pick: variant records, then the group's note and log. Reads and writes the store only. */
112
+ async function applyPick(store, group, body) {
113
+ const stored = await readAll(store);
114
+ const records = stored.records.filter((r) => r.group === group);
115
+ const previous = stored.groups.find((g) => g.group === group);
116
+ const current = pickedRecord(records, group);
117
+ const before = {
118
+ pick: current?.id ?? null,
119
+ note: previous?.note ?? ""
120
+ };
121
+ const pick = body.id === void 0 ? before.pick : body.id;
122
+ const note = body.note ?? before.note;
123
+ if (pick === before.pick && note === before.note) {
124
+ const response = {
125
+ ok: true,
126
+ group,
127
+ pick,
128
+ note,
129
+ changed: false
130
+ };
131
+ if (current?.decidedAt) response.decidedAt = current.decidedAt;
132
+ return response;
133
+ }
134
+ const at = (/* @__PURE__ */ new Date()).toISOString();
135
+ if (pick !== before.pick) await writePick(store, group, pick, records, body.variants, at);
136
+ const label = body.label ?? previous?.label;
137
+ await store.set(VARIANTS_COLLECTION, group, {
138
+ ...label === void 0 ? {} : { label },
139
+ note,
140
+ log: [...previous?.log ?? [], {
141
+ at,
142
+ pick,
143
+ note
144
+ }].map((entry) => ({ ...entry }))
87
145
  });
146
+ const response = {
147
+ ok: true,
148
+ group,
149
+ pick,
150
+ note,
151
+ changed: true
152
+ };
153
+ const decidedAt = pick === null ? void 0 : pick === before.pick ? current?.decidedAt : at;
154
+ if (decidedAt) response.decidedAt = decidedAt;
155
+ return response;
88
156
  }
89
157
  /**
90
- * Server half of `variants()`: `GET /` lists every record of the store's
91
- * `variants` collection, `POST /:group/decide` marks a winner (`decidedAt`,
92
- * `status: "decided"`; the others `rejected`) through the storage seam and
93
- * queues a cleanup brief through the dispatch seam. Carries `variants.decide`,
94
- * which only development grants by default.
158
+ * Server half of `variants()`.
159
+ *
160
+ * - `GET /` lists every record of the store's `variants` collection, with the
161
+ * groups' notes and logs.
162
+ * - `POST /:group/pick` records a pick and a note through the storage seam
163
+ * (`status` and `decidedAt` on the variants, note and log on the group).
164
+ * It never touches the dispatch seam.
165
+ * - `POST /:group/cleanup` queues the cleanup brief of a picked group through
166
+ * the dispatch seam; the panel's "Queue cleanup" button is the only caller.
167
+ *
168
+ * Carries `variants.decide`, which only development grants by default.
95
169
  */
96
170
  function variantsServer({ store, dispatch, brief = cleanupBrief }) {
171
+ const queues = /* @__PURE__ */ new Map();
172
+ const serial = (group, run) => {
173
+ const result = (queues.get(group) ?? Promise.resolve()).then(run, run);
174
+ const settled = result.catch(() => {});
175
+ queues.set(group, settled);
176
+ settled.then(() => {
177
+ if (queues.get(group) === settled) queues.delete(group);
178
+ });
179
+ return result;
180
+ };
97
181
  return definePlugin({
98
182
  id: "variants",
99
183
  capability: "variants.decide",
@@ -102,97 +186,78 @@ function variantsServer({ store, dispatch, brief = cleanupBrief }) {
102
186
  try {
103
187
  const body = {
104
188
  ok: true,
105
- records: await listRecords(store)
189
+ ...await readAll(store),
190
+ dispatch: dispatch?.id ?? null
106
191
  };
107
192
  return Response.json(body, { headers: NO_STORE });
108
193
  } catch (error) {
109
194
  return failed(error, "list");
110
195
  }
111
196
  } },
112
- "/:group/decide": { POST: async (request, { params }) => {
197
+ "/:group/pick": { POST: async (request, { params }) => {
113
198
  const refusal = refuseCrossSite(request);
114
199
  if (refusal) return refusal;
115
200
  const group = params.group ?? "";
116
- const body = parseDecide(await request.json().catch(() => null));
117
- if (!group || !body) return Response.json({
118
- ok: false,
119
- error: "invalid decision"
120
- }, { status: 400 });
201
+ const body = parsePick(await readJson(request));
202
+ if (!isGroup(group) || !body) return invalid("invalid pick");
121
203
  try {
122
- const existing = (await listRecords(store)).filter((r) => r.group === group);
123
- const byId = new Map(existing.map((r) => [r.id, r]));
124
- const known = /* @__PURE__ */ new Map();
125
- for (const r of existing) known.set(r.id, r.label ?? r.id);
126
- for (const v of body.variants ?? []) known.set(v.id, v.label);
127
- if (!known.has(body.id)) known.set(body.id, body.id);
128
- const decidedAt = (/* @__PURE__ */ new Date()).toISOString();
129
- for (const [id, label] of known) {
130
- const { decidedAt: _previous, ...rest } = byId.get(id) ?? {
131
- group,
132
- id
133
- };
134
- const record = id === body.id ? {
135
- ...rest,
136
- group,
137
- id,
138
- label,
139
- status: "decided",
140
- decidedAt
141
- } : {
142
- ...rest,
143
- group,
144
- id,
145
- label,
146
- status: "rejected"
147
- };
148
- await store.set(VARIANTS_COLLECTION, recordKey(group, id), { ...record });
149
- }
150
- const winnerLabel = known.get(body.id) ?? body.id;
151
- const decision = {
152
- group,
153
- label: body.label ?? group,
154
- winner: {
155
- id: body.id,
156
- label: winnerLabel
157
- },
158
- losers: [...known].filter(([id]) => id !== body.id).map(([id, label]) => ({
159
- id,
160
- label
161
- })),
162
- decidedAt
163
- };
164
- const response = {
165
- ok: true,
204
+ return Response.json(await serial(group, () => applyPick(store, group, body)), { headers: NO_STORE });
205
+ } catch (error) {
206
+ return failed(error, "pick");
207
+ }
208
+ } },
209
+ "/:group/cleanup": { POST: async (request, { params }) => {
210
+ const refusal = refuseCrossSite(request);
211
+ if (refusal) return refusal;
212
+ const group = params.group ?? "";
213
+ if (!isGroup(group)) return invalid("invalid group");
214
+ if (!dispatch) return invalid("no dispatch provider configured", 409);
215
+ try {
216
+ const stored = await readAll(store);
217
+ const records = stored.records.filter((r) => r.group === group);
218
+ const winner = pickedRecord(records, group);
219
+ if (!winner) return invalid(`nothing is picked in "${group}"`, 409);
220
+ const named = (r) => ({
221
+ id: r.id,
222
+ label: r.label ?? r.id
223
+ });
224
+ const prompt = brief({
166
225
  group,
167
- id: body.id,
168
- decidedAt,
169
- queued: null
170
- };
171
- if (dispatch) try {
226
+ label: stored.groups.find((g) => g.group === group)?.label ?? group,
227
+ winner: named(winner),
228
+ losers: records.filter((r) => r.id !== winner.id).map(named),
229
+ decidedAt: winner.decidedAt ?? "",
230
+ note: stored.groups.find((g) => g.group === group)?.note ?? ""
231
+ });
232
+ try {
172
233
  const status = await dispatch.status?.() ?? { available: true };
173
234
  if (!status.available) throw new Error(status.reason);
174
- const prompt = brief(decision);
175
235
  const run = await dispatch.dispatch({
176
- note: `Clean up variant group "${group}": keep "${body.id}"`,
236
+ note: `Clean up variant group "${group}": keep "${winner.id}"`,
177
237
  payload: null,
178
238
  hints: [],
179
239
  prompt
180
240
  });
181
- response.queued = {
182
- target: dispatch.id,
183
- runId: run.runId
241
+ const response = {
242
+ ok: true,
243
+ group,
244
+ id: winner.id,
245
+ queued: {
246
+ target: dispatch.id,
247
+ runId: run.runId,
248
+ ...run.detail ? { detail: run.detail } : {}
249
+ }
184
250
  };
185
- if (run.detail) response.queued.detail = run.detail;
251
+ return Response.json(response);
186
252
  } catch (error) {
187
- response.queueError = message(error);
253
+ return invalid(`brief not queued: ${message(error)}`, 502);
188
254
  }
189
- return Response.json(response);
190
255
  } catch (error) {
191
- return failed(error, "decide");
256
+ return failed(error, "cleanup");
192
257
  }
193
258
  } }
194
259
  }
195
260
  });
196
261
  }
197
262
  //#endregion
198
- export { VARIANTS_COLLECTION, cleanupBrief, recordKey, toVariantRecord, variantsServer };
263
+ export { VARIANTS_COLLECTION, cleanupBrief, formatVariantsMarkdown, readVariants, recordKey, toGroupRecord, toVariantRecord, variantsServer };
@@ -1,5 +1,5 @@
1
- import { a as HudGenerateResult, c as HudTokenDescriptor, d as HudTokensAdapter, i as HudGenerateRequest, l as HudTokenGroup, n as tokens, o as HudVariantCategory, r as variants, s as HudVariantsAdapter, t as forceState, u as HudTokenScope } from "../index-Caohnz3B.js";
1
+ import { a as HudGenerateRequest, c as HudVariantsAdapter, d as HudTokenGroup, f as HudTokenScope, i as variants, l as HudVariantPage, n as forceState, o as HudGenerateResult, p as HudTokensAdapter, r as tokens, s as HudVariantCategory, t as HudVariantsOptions, u as HudTokenDescriptor } from "../index-BeqWehuh.js";
2
2
  import { a as formatVariantParam, i as VariantOption, n as VARIANT_PARAM, o as parseVariantParam, r as VariantGroupInfo, t as VARIANT_MARKER } from "../variant-groups-aAIrcNK5.js";
3
- import { a as VariantStatus, i as VariantRecord, n as DecideResponse, o as VariantsListResponse, t as DecideBody } from "../variants-types-CcRf119M.js";
3
+ import { a as VariantGroupRecord, c as VariantStatus, l as VariantsListResponse, n as PickBody, o as VariantLogEntry, r as PickResponse, s as VariantRecord, t as CleanupResponse } from "../variants-types-VkW7vFZF.js";
4
4
  import { i as ForcedState, n as FORCE_STATE_MARKER, r as FORCE_STATE_PARAM, t as FORCED_STATES } from "../force-state-CCqoTfVB.js";
5
- export { type DecideBody, type DecideResponse, FORCED_STATES, FORCE_STATE_MARKER, FORCE_STATE_PARAM, type ForcedState, type HudGenerateRequest, type HudGenerateResult, type HudTokenDescriptor, type HudTokenGroup, type HudTokenScope, type HudTokensAdapter, type HudVariantCategory, type HudVariantsAdapter, VARIANT_MARKER, VARIANT_PARAM, type VariantGroupInfo, type VariantOption, type VariantRecord, type VariantStatus, type VariantsListResponse, forceState, formatVariantParam, parseVariantParam, tokens, variants };
5
+ export { type CleanupResponse, FORCED_STATES, FORCE_STATE_MARKER, FORCE_STATE_PARAM, type ForcedState, type HudGenerateRequest, type HudGenerateResult, type HudTokenDescriptor, type HudTokenGroup, type HudTokenScope, type HudTokensAdapter, type HudVariantCategory, type HudVariantPage, type HudVariantsAdapter, HudVariantsOptions, type PickBody, type PickResponse, VARIANT_MARKER, VARIANT_PARAM, type VariantGroupInfo, type VariantGroupRecord, type VariantLogEntry, type VariantOption, type VariantRecord, type VariantStatus, type VariantsListResponse, forceState, formatVariantParam, parseVariantParam, tokens, variants };
@@ -1,4 +1,4 @@
1
1
  import { n as FORCE_STATE_MARKER, r as FORCE_STATE_PARAM, t as FORCED_STATES } from "../force-state-BaqWsmrf.js";
2
- import { n as tokens, r as variants, t as forceState } from "../design-BXG1a4we.js";
2
+ import { n as tokens, r as variants, t as forceState } from "../design-BIXY1-Ex.js";
3
3
  import { n as VARIANT_PARAM, o as parseVariantParam, r as formatVariantParam, t as VARIANT_MARKER } from "../variant-groups-TIfO3NIj.js";
4
4
  export { FORCED_STATES, FORCE_STATE_MARKER, FORCE_STATE_PARAM, VARIANT_MARKER, VARIANT_PARAM, forceState, formatVariantParam, parseVariantParam, tokens, variants };
@@ -1,4 +1,4 @@
1
1
  import { i as requestBuffer, n as RequestPayload, r as RequestTransport, t as InspectRequest } from "../requests-CJrUf465.js";
2
2
  import { t as InspectAdapter } from "../adapter-BYoxPYTI.js";
3
- import { a as replay, c as isSensitiveKey, d as redactUrl, i as InspectFilter, l as redactBody, n as InspectOptions, o as replayBlocker, r as inspect, s as REDACTED, t as INSPECT_CAPABILITY, u as redactHeaders } from "../index-BR5OB7DO.js";
3
+ import { a as replay, c as isSensitiveKey, d as redactUrl, i as InspectFilter, l as redactBody, n as InspectOptions, o as replayBlocker, r as inspect, s as REDACTED, t as INSPECT_CAPABILITY, u as redactHeaders } from "../index-DS0yT0c-.js";
4
4
  export { INSPECT_CAPABILITY, type InspectAdapter, type InspectFilter, InspectOptions, type InspectRequest, REDACTED, type RequestPayload, type RequestTransport, inspect, isSensitiveKey, redactBody, redactHeaders, redactUrl, replay, replayBlocker, requestBuffer };
@@ -0,0 +1,165 @@
1
+ import { ScreenshotServerOptions } from "../capture/server.js";
2
+ import { a as LaneServer, c as ShotBody, i as LaneInfo, l as StartResponse, n as Delivery, o as LaneWorker, s as LanesResponse, t as CommentBody } from "../../types-Dazn3aWZ.js";
3
+ //#region src/plugins/lanes/box.d.ts
4
+ /**
5
+ * The box side of the `lanes` plugin: which lanes exist, which dev servers
6
+ * listen in them, who works in them, and how a comment or screenshot reaches
7
+ * that worker. `nodeBox()` is the real one; the playground and tests pass
8
+ * their own.
9
+ */
10
+ interface LaneBox {
11
+ /** The box's tailnet name (MagicDNS), or null when unknown. */
12
+ host(): Promise<string | null>;
13
+ lanes(): Promise<LaneInfo[]>;
14
+ start(lane: string): Promise<StartResponse>;
15
+ /** Record a message for the lane's worker on the ledger and type it into its terminal. */
16
+ message(lane: string, message: LaneMessage): Promise<Delivery>;
17
+ /** Save a screenshot, hand it to the worker and post it to the lane's PR. */
18
+ shot(lane: string, png: Uint8Array, message: LaneMessage): Promise<Delivery>;
19
+ }
20
+ interface LaneMessage {
21
+ text: string;
22
+ url?: string;
23
+ viewport?: {
24
+ width: number;
25
+ height: number;
26
+ };
27
+ }
28
+ interface ExecResult {
29
+ code: number;
30
+ stdout: string;
31
+ stderr: string;
32
+ }
33
+ /** Runs one command, argv only, never a shell; never throws (a missing binary is code 127). */
34
+ type Exec = (command: string, args: string[], options?: {
35
+ cwd?: string;
36
+ timeoutMs?: number;
37
+ }) => Promise<ExecResult>;
38
+ interface LaunchOrder {
39
+ cwd: string;
40
+ port: number;
41
+ lane: string;
42
+ theme: string;
43
+ log: string;
44
+ command: string[];
45
+ env: Record<string, string>;
46
+ }
47
+ /** `leased`: the server is starting; `held`: the port's lease belongs to someone else. */
48
+ type LaunchResult = {
49
+ status: "leased";
50
+ } | {
51
+ status: "held";
52
+ } | {
53
+ status: "failed";
54
+ error: string;
55
+ };
56
+ interface NodeBoxOptions {
57
+ /** Lane roots, each `<root>/<repo>/<lane>`. Default `~/lanes` and the Orca-era `~/orca/workspaces`. */
58
+ roots?: string[];
59
+ /** The box's tailnet name. Default `HUD_PREVIEW_HOST`, else `tailscale status --json`. */
60
+ host?: string;
61
+ /** Address a started dev server binds to. Default the box's tailnet IPv4 (`tailscale ip -4`). */
62
+ bindAddress?: string;
63
+ /** Ports Start leases from. Default 3100–3999. */
64
+ ports?: [number, number];
65
+ /** The session ledger. Default `~/.claude/sessions`. */
66
+ sessionsDir?: string;
67
+ /** Where screenshots and start logs go. Default `<tmpdir>/hud-lanes`. */
68
+ stateDir?: string;
69
+ /** Branch that holds screenshots linked from PR comments. Default `hud-shots`. */
70
+ shotsBranch?: string;
71
+ /** This dev server's directory, to mark its own lane. Default `process.cwd()`. */
72
+ cwd?: string;
73
+ /** Home directory. Default `os.homedir()`. */
74
+ home?: string;
75
+ /** Test seams. */
76
+ exec?: Exec;
77
+ launch?: (order: LaunchOrder) => Promise<LaunchResult>;
78
+ now?: () => Date;
79
+ }
80
+ interface Pkg {
81
+ scripts?: Record<string, unknown>;
82
+ dependencies?: Record<string, string>;
83
+ devDependencies?: Record<string, string>;
84
+ }
85
+ /** `hud-issue-101-slug` → `{ repo: "hud", issue: 101 }`; a name off the pattern keeps its folder's repo. */
86
+ export declare function parseLaneName(name: string): {
87
+ repo?: string;
88
+ issue?: number;
89
+ };
90
+ interface Listener {
91
+ pid: number;
92
+ port: number;
93
+ loopback: boolean;
94
+ }
95
+ /**
96
+ * `lsof -nP -iTCP -sTCP:LISTEN -Fpcn` → one entry per pid and port. Ports
97
+ * below 1024 or in the ephemeral range, and agent CLI processes, are dropped.
98
+ */
99
+ export declare function parseListeners(out: string): Listener[];
100
+ /** `lsof -a -d cwd -p <pids> -Fpn` → pid → working directory. */
101
+ export declare function parseCwds(out: string): Map<number, string>;
102
+ interface LedgerRecord {
103
+ sid?: unknown;
104
+ lane?: unknown;
105
+ state?: unknown;
106
+ last_seen?: unknown;
107
+ theme?: unknown;
108
+ }
109
+ /** The newest open ledger record working in `lane`. */
110
+ export declare function pickWorker(records: LedgerRecord[], lane: string): {
111
+ sid: string;
112
+ state: string;
113
+ theme?: string;
114
+ } | undefined;
115
+ /** The first terminal handle anywhere in `lane-runtime terminal list`'s JSON (as kommandant's session-mirror reads it). */
116
+ export declare function firstHandle(value: unknown): string | undefined;
117
+ /** Arguments that put a dev script on `port` and `address`, by framework. */
118
+ export declare function devArgs(target: {
119
+ dev: string;
120
+ pkg: Pkg;
121
+ }, port: number, address: string): string[];
122
+ /** `bun run --cwd playground dev`, `cd web && vite`: the folder a root `dev` hands over to. */
123
+ export declare function delegatedDir(dev: string): string | undefined;
124
+ /** `bun run dev`, `pnpm run dev` or `npm run dev --`, by lockfile. */
125
+ export declare function runDev(files: Set<string>, extra: string[]): string[];
126
+ /** What the worker reads in its terminal. One line: a terminal send submits on newline. */
127
+ export declare function messageLine(kind: "comment" | "screenshot", m: LaneMessage, file?: string): string;
128
+ /** The real box: lsof, git, the session ledger, `hn-lease`, `lane-runtime` and `gh`. */
129
+ export declare function nodeBox(options?: NodeBoxOptions): LaneBox;
130
+ //#endregion
131
+ //#region src/plugins/lanes/server.d.ts
132
+ export interface LanesServerOptions {
133
+ /** Where lanes, workers and delivery come from. Default `nodeBox()`, this machine. */
134
+ box?: LaneBox;
135
+ /** Options for the headless render behind the Screenshot button (the `capture` plugin's). */
136
+ capture?: ScreenshotServerOptions;
137
+ }
138
+ /**
139
+ * Server half of `lanes`: `GET /lanes` lists the box's lanes with their dev
140
+ * servers and workers, `POST /start` starts a lane's dev script on a leased
141
+ * port, `POST /comment` hands the worker a message over the ledger, and
142
+ * `POST /screenshot` renders the page at the viewer's width, posts it to the
143
+ * lane's PR and hands it to the worker. Everything is this machine's: mount it
144
+ * only on a dev server that runs on the box the lanes live on.
145
+ */
146
+ export declare function lanes({ box, capture }?: LanesServerOptions): {
147
+ readonly id: "lanes";
148
+ readonly capability: "lanes.preview";
149
+ readonly routes: {
150
+ readonly "/lanes": {
151
+ GET: () => Promise<Response>;
152
+ };
153
+ readonly "/start": {
154
+ readonly POST: (request: Request) => Promise<Response>;
155
+ };
156
+ readonly "/comment": {
157
+ readonly POST: (request: Request) => Promise<Response>;
158
+ };
159
+ readonly "/screenshot": {
160
+ readonly POST: (request: Request) => Promise<Response>;
161
+ };
162
+ };
163
+ };
164
+ //#endregion
165
+ export type { CommentBody, Delivery, Exec, ExecResult, LaneBox, LaneInfo, LaneMessage, LaneServer, LaneWorker, LanesResponse, LaunchOrder, LaunchResult, NodeBoxOptions, ShotBody, StartResponse };