@feltdb/core 0.11.9 → 0.12.1

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 (56) hide show
  1. package/dist/agent-state.d.ts +489 -0
  2. package/dist/agent-state.d.ts.map +1 -0
  3. package/dist/agent-state.js +993 -0
  4. package/dist/build-identity.json +19 -0
  5. package/dist/cli/index.js +0 -0
  6. package/dist/create/build-identity.json +19 -0
  7. package/dist/create/package-versions.js +1 -1
  8. package/dist/create/server-source/crates/feltdb/src/lib.rs +11 -0
  9. package/dist/create/server-source/crates/feltdb/src/query_performance.rs +4 -1
  10. package/dist/create/server-source/crates/feltdb/src/state_model.rs +854 -155
  11. package/dist/create/server-source/crates/feltdb/tests/generalized_version_control_substrate_completion.rs +31 -13
  12. package/dist/create/server-source/crates/feltdb/tests/state_ref_authority.rs +918 -0
  13. package/dist/create/server-source/crates/feltdb/tests/workload_envelope_contract.rs +15 -2
  14. package/dist/create/server-source/crates/feltdb-server/Cargo.toml +4 -0
  15. package/dist/create/server-source/crates/feltdb-server/benches/query_shape_observer.rs +136 -0
  16. package/dist/create/server-source/crates/feltdb-server/src/app_state.rs +3 -0
  17. package/dist/create/server-source/crates/feltdb-server/src/lib.rs +1 -0
  18. package/dist/create/server-source/crates/feltdb-server/src/main.rs +74 -5
  19. package/dist/create/server-source/crates/feltdb-server/src/query_shape.rs +1137 -0
  20. package/dist/create/server-source/crates/feltdb-server/tests/fixtures/query-shape-trace.expected.json +300 -0
  21. package/dist/create/server-source/crates/feltdb-server/tests/fixtures/query-shape-trace.json +25 -0
  22. package/dist/create/server-source/crates/feltdb-server/tests/query_shape_trace.rs +128 -0
  23. package/dist/create/server-source/crates/feltdb-wasm/test.db +0 -0
  24. package/dist/index-core.d.ts +1 -0
  25. package/dist/index-core.d.ts.map +1 -1
  26. package/dist/index-core.js +1 -0
  27. package/dist/studio/app.d.ts.map +1 -1
  28. package/dist/studio/components/GlobalSearch.d.ts.map +1 -1
  29. package/dist/studio/components/index.js +1 -1
  30. package/dist/studio/{components-BHTKlUgT.js → components-Bivm2lX6.js} +2 -1
  31. package/dist/studio/control-plane/Agents.d.ts.map +1 -1
  32. package/dist/studio/control-plane/Data.d.ts.map +1 -1
  33. package/dist/studio/control-plane/Operations.d.ts.map +1 -1
  34. package/dist/studio/control-plane/Overview.d.ts.map +1 -1
  35. package/dist/studio/control-plane/Schema.d.ts.map +1 -1
  36. package/dist/studio/control-plane/State.d.ts +11 -0
  37. package/dist/studio/control-plane/State.d.ts.map +1 -1
  38. package/dist/studio/control-plane/index.d.ts +1 -1
  39. package/dist/studio/control-plane/index.d.ts.map +1 -1
  40. package/dist/studio/control-plane/index.js +2 -2
  41. package/dist/studio/control-plane/primitives.d.ts +14 -2
  42. package/dist/studio/control-plane/primitives.d.ts.map +1 -1
  43. package/dist/studio/control-plane-CLm69XwX.js +4121 -0
  44. package/dist/studio/index.js +266 -235
  45. package/dist/studio/studio.css +1 -1
  46. package/dist/studio-app/assets/{feltdb_wasm-DGGqm9GK.js → feltdb_wasm-DACcD-zs.js} +1 -1
  47. package/dist/studio-app/assets/feltdb_wasm_bg-BejThWID.wasm +0 -0
  48. package/dist/studio-app/assets/index-CiC8VY-a.css +1 -0
  49. package/dist/studio-app/assets/index-CoZaxnlm.js +30 -0
  50. package/dist/studio-app/index.html +2 -2
  51. package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
  52. package/package.json +2 -2
  53. package/dist/studio/control-plane-DP8ljTDO.js +0 -3207
  54. package/dist/studio-app/assets/feltdb_wasm_bg-BYJo87WY.wasm +0 -0
  55. package/dist/studio-app/assets/index-BrsF-kWL.css +0 -1
  56. package/dist/studio-app/assets/index-qLeZcPW_.js +0 -30
@@ -0,0 +1,4121 @@
1
+ import { StudioServiceApi as e, isSecretField as t, resolveStudioApplicationId as n, safeDisplayValue as r } from "./utils/service-api.js";
2
+ import { CapabilitySet as i, ControlPlaneApi as a, controlPlaneErrorMessage as o, formatStatePath as s } from "./utils/control-plane-api.js";
3
+ import c, { Fragment as l, createContext as u, createElement as d, isValidElement as f, useContext as p, useEffect as m, useId as h, useMemo as g, useRef as _, useState as v } from "react";
4
+ import { useSearchParams as y } from "react-router-dom";
5
+ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
6
+ Object.freeze([
7
+ "positive",
8
+ "progress",
9
+ "attention",
10
+ "critical",
11
+ "neutral",
12
+ "unknown"
13
+ ]);
14
+ var C = Object.freeze({
15
+ positive: "●",
16
+ progress: "◐",
17
+ attention: "▲",
18
+ critical: "✕",
19
+ neutral: "○",
20
+ unknown: "?"
21
+ });
22
+ Object.freeze([
23
+ "submitted",
24
+ "accepted",
25
+ "completed",
26
+ "failed",
27
+ "cancelled",
28
+ "rejected",
29
+ "outcome_unknown"
30
+ ]), Object.freeze({
31
+ submitted: "Sending…",
32
+ accepted: "Started",
33
+ completed: "Done",
34
+ failed: "Failed",
35
+ cancelled: "Cancelled",
36
+ rejected: "Not accepted",
37
+ outcome_unknown: "Result unknown — check current state"
38
+ });
39
+ var w = Object.freeze([
40
+ "verified",
41
+ "verification_failed",
42
+ "not_verified",
43
+ "not_evaluated"
44
+ ]);
45
+ Object.freeze([
46
+ "live",
47
+ "cached",
48
+ "stale",
49
+ "unknown"
50
+ ]), Object.freeze([
51
+ "available",
52
+ "partial",
53
+ "unsupported"
54
+ ]);
55
+ function T(e) {
56
+ let t = String(e).replace(/_/g, " ");
57
+ return t && t[0].toUpperCase() + t.slice(1);
58
+ }
59
+ var E = "positive", D = "progress", O = "attention", k = "critical", A = "neutral", j = "unknown", ee = {
60
+ "compute.environment.actual_state": {
61
+ running: E,
62
+ completed: E,
63
+ pending: D,
64
+ starting: D,
65
+ stopping: D,
66
+ degraded: O,
67
+ failed: k,
68
+ denied: k,
69
+ stopped: A
70
+ },
71
+ "compute.health": {
72
+ healthy: E,
73
+ unhealthy: k,
74
+ unknown: j
75
+ },
76
+ "compute.environment.readiness": {
77
+ ready: E,
78
+ created: D,
79
+ starting: D,
80
+ degraded: O,
81
+ failed: k,
82
+ unavailable: k
83
+ },
84
+ "compute.process.readiness": {
85
+ ready: E,
86
+ starting: D,
87
+ unready: O
88
+ },
89
+ "compute.process.state": {
90
+ ready: E,
91
+ running: E,
92
+ pending: D,
93
+ starting: D,
94
+ stopping: D,
95
+ unready: O,
96
+ failed: k,
97
+ lost: k,
98
+ stopped: A,
99
+ exited: A,
100
+ destroyed: A,
101
+ expired: A,
102
+ unverified: j,
103
+ unreachable: j
104
+ },
105
+ "compute.deployment.status": {
106
+ active: E,
107
+ complete: E,
108
+ pending: D,
109
+ starting: D,
110
+ ready: D,
111
+ network_ready: D,
112
+ switching: D,
113
+ draining: D,
114
+ failed: k,
115
+ rolled_back: k
116
+ },
117
+ "compute.version.status": {
118
+ published: E,
119
+ publishing: D,
120
+ failed: k
121
+ },
122
+ "compute.rollout.status": {
123
+ active: E,
124
+ applying: D,
125
+ failed: k,
126
+ superseded: A
127
+ },
128
+ "compute.job.status": {
129
+ succeeded: E,
130
+ created: D,
131
+ accepted: D,
132
+ queued: D,
133
+ waiting_for_capacity: D,
134
+ reserved: D,
135
+ admitted: D,
136
+ preparing: D,
137
+ running: D,
138
+ failed: k,
139
+ rejected: k,
140
+ timed_out: k,
141
+ cancelled: A
142
+ },
143
+ "compute.computer.observed": {
144
+ running: E,
145
+ starting: D,
146
+ reconciling: D,
147
+ stopping: D,
148
+ failed: k,
149
+ lost: k,
150
+ stopped: A,
151
+ destroyed: A,
152
+ expired: A,
153
+ unverified: j,
154
+ unreachable: j
155
+ },
156
+ "compute.computer.status": {
157
+ running: E,
158
+ pending: D,
159
+ provisioning: D,
160
+ resuming: D,
161
+ stopping: D,
162
+ destroying: D,
163
+ failed: k,
164
+ lost: k,
165
+ stopped: A,
166
+ destroyed: A,
167
+ expired: A,
168
+ unreachable: j
169
+ },
170
+ "feltdb.health.ready_state": {
171
+ healthy: E,
172
+ recovering: D,
173
+ degraded: O,
174
+ unavailable: k
175
+ },
176
+ "feltdb.authority.availability": {
177
+ available: E,
178
+ recovering: D,
179
+ degraded: O,
180
+ closed: A,
181
+ unknown: j
182
+ },
183
+ "feltdb.authority.lease_clock_healthy": {
184
+ true: [E, "Healthy"],
185
+ false: [O, "Degraded"]
186
+ }
187
+ }, te = { "feltdb.revision.integrity_verified": {
188
+ true: "verified",
189
+ false: "verification_failed"
190
+ } }, ne = {
191
+ "compute.response.state": {
192
+ live: "live",
193
+ cached: "cached",
194
+ stale: "stale"
195
+ },
196
+ "feltdb.snapshot.staleness": {
197
+ current: "live",
198
+ stale: "stale",
199
+ unknown: "unknown"
200
+ }
201
+ }, re = (e) => Object.freeze(Object.fromEntries(Object.entries(e).map(([e, t]) => [e, Object.freeze({ ...t })]))), ie = re(ee), ae = re(te);
202
+ re(ne);
203
+ var oe = (e, t) => Object.prototype.hasOwnProperty.call(e, t);
204
+ function se(e, t, n) {
205
+ let r = ie[e];
206
+ if (!r) throw Error(`unknown field: ${e}`);
207
+ let i = String(t), a = oe(r, i) ? r[i] : null, [o, s] = a === null ? [j, null] : Array.isArray(a) ? a : [a, null];
208
+ return {
209
+ field: e,
210
+ value: i,
211
+ tone: o,
212
+ label: n && n.label || s || (a === null ? i : T(i)),
213
+ glyph: C[o],
214
+ mapped: a !== null
215
+ };
216
+ }
217
+ function ce(e, t) {
218
+ let n = ue(t), r = w.includes(e) ? e : "not_evaluated";
219
+ return r === "verified" && n.length === 0 && (r = "not_evaluated"), r === "verified" && n.some((e) => e.status === "failed") && (r = "verification_failed"), {
220
+ state: r,
221
+ checks: n
222
+ };
223
+ }
224
+ function le(e, t, n) {
225
+ let r = ae[e];
226
+ if (!r) throw Error(`unknown field: ${e}`);
227
+ let i = String(t), a = oe(r, i) ? r[i] : "not_evaluated";
228
+ return ce(a, ue(n).map((e) => ({
229
+ ...e,
230
+ status: e.status || (a === "verified" ? "passed" : a === "verification_failed" ? "failed" : void 0)
231
+ })));
232
+ }
233
+ function ue(e) {
234
+ return e ? e.map((e) => typeof e == "string" ? { label: e } : {
235
+ label: String(e.label),
236
+ ...e.status ? { status: e.status } : {}
237
+ }) : [];
238
+ }
239
+ //#endregion
240
+ //#region vendor/stack-ui/core/src/view.js
241
+ var M = (e, t, n, r, i) => ({
242
+ t: e,
243
+ a: t || {},
244
+ c: n === void 0 ? [] : [].concat(n),
245
+ ...r ? { on: r } : {},
246
+ ...i == null ? {} : { k: String(i) }
247
+ }), N = (e) => !!(e && typeof e == "object" && typeof e.t == "string" && e.a && Array.isArray(e.c)), P = (...e) => e.filter(Boolean).join(" "), F = (e) => e != null && e !== "", I = (e) => {
248
+ let t = {};
249
+ for (let [n, r] of Object.entries(e || {})) (/^(data-|aria-)/.test(n) || n === "id" || n === "title") && (t[n] = r);
250
+ return t;
251
+ };
252
+ function de(e) {
253
+ let t = new Date(e);
254
+ return Number.isNaN(t.getTime()) ? String(e) : `${t.toISOString().slice(0, 19).replace("T", " ")} UTC`;
255
+ }
256
+ var fe = (e, t) => {
257
+ let n = new Date(e);
258
+ return Number.isNaN(n.getTime()) ? M("span", { class: t }, String(e)) : M("time", {
259
+ class: t,
260
+ datetime: n.toISOString()
261
+ }, de(e));
262
+ };
263
+ function pe(e) {
264
+ let { field: t, value: n, detail: r, className: i, attrs: a } = e, o = t ? se(t, n, { label: e.label }) : null, s = o ? o.tone : e.tone || "unknown", c = o ? o.label : F(e.label) ? e.label : T(s), l = e.glyph || C[s] || C.unknown;
265
+ return M("span", {
266
+ class: P("stack-status", `stack-status--${s}`, i),
267
+ "data-tone": s,
268
+ ...o ? {
269
+ "data-field": o.field,
270
+ "data-value": o.value
271
+ } : {},
272
+ ...I(a)
273
+ }, [
274
+ M("span", {
275
+ class: "stack-status__glyph",
276
+ "aria-hidden": "true"
277
+ }, l),
278
+ M("span", { class: "stack-status__label" }, c),
279
+ F(r) ? M("span", { class: "stack-status__detail" }, r) : null
280
+ ]);
281
+ }
282
+ var me = {
283
+ verified: "✓",
284
+ verification_failed: "✕",
285
+ not_verified: "!",
286
+ not_evaluated: "–"
287
+ };
288
+ function he(e) {
289
+ let { state: t, checks: n } = ce(e.state, e.checks), r = n.filter((e) => e.status === "failed"), i;
290
+ if (t === "verified") i = n.length === 1 ? `Verified · ${n[0].label}` : `Verified · ${n.length} checks`;
291
+ else if (t === "verification_failed") {
292
+ let e = r.length ? r : n;
293
+ i = e.length === 1 ? `Verification failed · ${e[0].label}` : e.length ? `Verification failed · ${e.length} checks` : "Verification failed";
294
+ } else i = t === "not_verified" ? "Not verified" : "Not evaluated";
295
+ return M("div", {
296
+ class: P("stack-verification", `stack-verification--${t}`, e.className),
297
+ "data-verification": t,
298
+ ...I(e.attrs)
299
+ }, [
300
+ M("span", {
301
+ class: "stack-verification__glyph",
302
+ "aria-hidden": "true"
303
+ }, me[t]),
304
+ M("span", { class: "stack-verification__label" }, i),
305
+ F(e.at) ? [" · ", fe(e.at, "stack-verification__at")] : null,
306
+ F(e.evidenceHref) ? M("a", {
307
+ class: "stack-verification__evidence",
308
+ href: e.evidenceHref
309
+ }, "Evidence") : null,
310
+ n.length > 1 ? M("ul", { class: "stack-verification__checks" }, n.map((e) => M("li", {
311
+ class: "stack-verification__check",
312
+ ...e.status ? { "data-check-status": e.status } : {}
313
+ }, e.status ? `${e.label} — ${e.status}` : e.label))) : null
314
+ ]);
315
+ }
316
+ var ge = {
317
+ live: "Live",
318
+ cached: "Cached",
319
+ stale: "Stale",
320
+ unknown: "Freshness unknown"
321
+ }, _e = {
322
+ live: "●",
323
+ cached: "◷",
324
+ stale: "▲",
325
+ unknown: "?"
326
+ };
327
+ function ve(e) {
328
+ let t = ge[e.freshness] ? e.freshness : "unknown", n = F(e.asOf) && t !== "live";
329
+ return M("span", {
330
+ class: P("stack-freshness", `stack-freshness--${t}`, e.className),
331
+ "data-freshness": t,
332
+ ...I(e.attrs)
333
+ }, [M("span", {
334
+ class: "stack-freshness__glyph",
335
+ "aria-hidden": "true"
336
+ }, _e[t]), M("span", { class: "stack-freshness__label" }, [
337
+ ge[t],
338
+ n ? [" · as of ", fe(e.asOf, "stack-freshness__as-of")] : null,
339
+ F(e.source) ? ` · ${e.source}` : null
340
+ ])]);
341
+ }
342
+ function ye(e) {
343
+ let t = e.status === "partial" ? "partial" : "unsupported", n = F(e.title) ? e.title : t === "partial" ? "Partly available" : "Not available";
344
+ return M("div", {
345
+ class: P("stack-unavailable", `stack-unavailable--${t}`, e.className),
346
+ role: "note",
347
+ "data-capability-status": t,
348
+ ...F(e.capability) ? { "data-capability": e.capability } : {},
349
+ ...I(e.attrs)
350
+ }, [
351
+ M(e.headingLevel ? xe(e.headingLevel) : "p", { class: "stack-unavailable__title" }, n),
352
+ F(e.reason) ? M("p", { class: "stack-unavailable__reason" }, e.reason) : null,
353
+ e.children || null
354
+ ]);
355
+ }
356
+ function be(e) {
357
+ let t = F(e.what) ? e.what : "", n = e.long ? `Still loading${t ? ` ${t}` : ""}…` : `Loading${t ? ` ${t}` : ""}…`;
358
+ return M("div", {
359
+ class: P("stack-loading", e.long ? "stack-loading--long" : null, e.className),
360
+ role: "status",
361
+ "aria-live": "polite",
362
+ ...I(e.attrs)
363
+ }, [M("span", {
364
+ class: "stack-loading__indicator",
365
+ "aria-hidden": "true"
366
+ }), M("span", { class: "stack-loading__label" }, n)]);
367
+ }
368
+ var xe = (e) => `h${Math.min(6, Math.max(1, Number(e) || 2))}`;
369
+ function Se(e) {
370
+ let t = e.variant === "no-match" ? "no-match" : "empty", n = F(e.title) ? e.title : t === "no-match" ? "Nothing matches" : "Nothing here yet";
371
+ return M("div", {
372
+ class: P("stack-empty", `stack-empty--${t}`, e.className),
373
+ ...I(e.attrs)
374
+ }, [
375
+ M(xe(e.headingLevel), { class: "stack-empty__title" }, n),
376
+ F(e.body) ? M("p", { class: "stack-empty__body" }, e.body) : null,
377
+ e.action ? M("div", { class: "stack-empty__action" }, e.action) : null
378
+ ]);
379
+ }
380
+ function L(e) {
381
+ let t = [F(e.code) ? ["Code ", M("code", {}, e.code)] : null, F(e.requestId) ? [
382
+ F(e.code) ? " · " : "",
383
+ "Request ",
384
+ M("code", {}, e.requestId)
385
+ ] : null].filter(Boolean);
386
+ return M("div", {
387
+ class: P("stack-error", e.className),
388
+ role: "alert",
389
+ ...I(e.attrs)
390
+ }, [
391
+ M("p", { class: "stack-error__title" }, F(e.title) ? e.title : "Something went wrong"),
392
+ F(e.message) ? M("p", { class: "stack-error__message" }, e.message) : null,
393
+ t.length ? M("p", { class: "stack-error__meta" }, t) : null,
394
+ e.onRetry || e.actions ? M("div", { class: "stack-error__actions" }, [e.onRetry ? Ee({
395
+ label: e.retryLabel || "Retry",
396
+ onClick: e.onRetry
397
+ }) : null, e.actions || null]) : null
398
+ ]);
399
+ }
400
+ function R(e) {
401
+ return M("dl", {
402
+ class: P("stack-meta", e.className),
403
+ ...I(e.attrs)
404
+ }, (e.items || []).map((e) => {
405
+ let t = !F(e.value) && e.value !== 0 && e.value !== !1;
406
+ return M("div", {
407
+ class: "stack-meta__item",
408
+ ...I(e.attrs)
409
+ }, [
410
+ M("dt", { class: "stack-meta__label" }, e.label),
411
+ M("dd", {
412
+ class: P("stack-meta__value", e.mono ? "stack-meta__value--mono" : null),
413
+ ...t ? { "data-missing": "true" } : {}
414
+ }, t ? "—" : typeof e.value == "boolean" ? String(e.value) : e.value),
415
+ F(e.hint) ? M("dd", { class: "stack-meta__hint" }, e.hint) : null
416
+ ]);
417
+ }));
418
+ }
419
+ function Ce(e) {
420
+ let t = Number(e.length) || 12, n = F(e.id) ? String(e.id) : null, r = n && n.length > t ? `${n.slice(0, t)}…` : n, i = F(e.name) ? M(e.href ? "a" : "span", {
421
+ class: "stack-identity__name",
422
+ ...e.href ? { href: e.href } : {}
423
+ }, e.name) : null;
424
+ return M("span", {
425
+ class: P("stack-identity", e.className),
426
+ ...I(e.attrs)
427
+ }, [
428
+ F(e.kind) ? M("span", { class: "stack-identity__kind" }, e.kind) : null,
429
+ i,
430
+ n ? M("code", {
431
+ class: "stack-identity__id",
432
+ title: n
433
+ }, r === n ? n : [M("span", { "aria-hidden": "true" }, r), M("span", { class: "stack-visually-hidden" }, n)]) : null
434
+ ]);
435
+ }
436
+ function we(e) {
437
+ return M("header", {
438
+ class: P("stack-page-header", e.className),
439
+ ...I(e.attrs)
440
+ }, [
441
+ F(e.eyebrow) ? M("p", { class: "stack-page-header__eyebrow" }, e.eyebrow) : null,
442
+ M("div", { class: "stack-page-header__title-row" }, [
443
+ M(xe(e.headingLevel || 1), { class: "stack-page-header__title" }, e.title),
444
+ e.status ? M("span", { class: "stack-page-header__status" }, e.status) : null,
445
+ e.actions ? M("div", { class: "stack-page-header__actions" }, e.actions) : null
446
+ ]),
447
+ F(e.description) ? M("p", { class: "stack-page-header__description" }, e.description) : null,
448
+ e.meta ? M("div", { class: "stack-page-header__meta" }, e.meta) : null
449
+ ]);
450
+ }
451
+ var z = [
452
+ "primary",
453
+ "secondary",
454
+ "danger",
455
+ "ghost"
456
+ ], Te = [
457
+ "sm",
458
+ "md",
459
+ "lg"
460
+ ];
461
+ function Ee(e) {
462
+ let t = z.includes(e.variant) ? e.variant : "secondary", n = Te.includes(e.size) ? e.size : "md", r = !!(e.disabled || e.busy);
463
+ return M("button", {
464
+ class: P("stack-button", `stack-button--${t}`, `stack-button--${n}`, e.className),
465
+ type: e.type === "submit" ? "submit" : "button",
466
+ ...r ? { disabled: !0 } : {},
467
+ ...e.busy ? { "aria-busy": "true" } : {},
468
+ ...I(e.attrs)
469
+ }, [e.busy ? M("span", {
470
+ class: "stack-button__busy",
471
+ "aria-hidden": "true"
472
+ }) : null, M("span", { class: "stack-button__label" }, e.label)], e.onClick && !r ? { click: e.onClick } : void 0);
473
+ }
474
+ function De(e) {
475
+ let t = (e.items || []).filter((e) => e && F(e.label));
476
+ return M("nav", {
477
+ class: P("stack-breadcrumbs", e.className),
478
+ "aria-label": e.label || "Breadcrumb",
479
+ ...I(e.attrs)
480
+ }, M("ol", { class: "stack-breadcrumbs__list" }, t.map((e, n) => {
481
+ let r = n === t.length - 1;
482
+ return M("li", { class: "stack-breadcrumbs__item" }, [n > 0 ? M("span", {
483
+ class: "stack-breadcrumbs__separator",
484
+ "aria-hidden": "true"
485
+ }, "/") : null, r || !F(e.href) ? M("span", {
486
+ class: "stack-breadcrumbs__current",
487
+ ...r ? { "aria-current": "page" } : {}
488
+ }, e.label) : M("a", {
489
+ class: "stack-breadcrumbs__link",
490
+ href: e.href
491
+ }, e.label)]);
492
+ })));
493
+ }
494
+ function Oe(e) {
495
+ if (![
496
+ "ArrowRight",
497
+ "ArrowLeft",
498
+ "ArrowDown",
499
+ "ArrowUp",
500
+ "Home",
501
+ "End"
502
+ ].includes(e.key)) return;
503
+ let t = e.currentTarget, n = Array.from(t.querySelectorAll("[role=\"tab\"]:not([disabled])"));
504
+ if (!n.length) return;
505
+ let r = n.indexOf(t.ownerDocument.activeElement), i = t.getAttribute("aria-orientation") === "vertical", a = i ? "ArrowDown" : "ArrowRight", o = i ? "ArrowUp" : "ArrowLeft", s;
506
+ if (e.key === "Home") s = 0;
507
+ else if (e.key === "End") s = n.length - 1;
508
+ else if (e.key === a) s = r < 0 ? 0 : (r + 1) % n.length;
509
+ else if (e.key === o) s = r < 0 ? n.length - 1 : (r - 1 + n.length) % n.length;
510
+ else return;
511
+ e.preventDefault(), n[s].focus();
512
+ }
513
+ var ke = (e) => String(e).replace(/[^A-Za-z0-9_-]/g, "-"), Ae = (e) => (t) => {
514
+ let n = t.currentTarget.ownerDocument.getElementById(e);
515
+ n && (t.preventDefault(), n.focus(), typeof n.scrollIntoView == "function" && n.scrollIntoView());
516
+ };
517
+ function je(e) {
518
+ let t = ke(e.idPrefix || "stack-tabs"), n = e.tabs || [], r = n.some((t) => t.id === e.active && !t.disabled) ? e.active : null;
519
+ return M("div", {
520
+ class: P("stack-tabs", e.className),
521
+ role: "tablist",
522
+ ...F(e.label) ? { "aria-label": e.label } : {},
523
+ ...I(e.attrs)
524
+ }, n.map((n, i) => {
525
+ let a = n.id === r, o = a || r === null && i === 0;
526
+ return M("button", {
527
+ class: P("stack-tabs__tab", a ? "stack-tabs__tab--selected" : null, n.className),
528
+ type: "button",
529
+ role: "tab",
530
+ id: `${t}-tab-${ke(n.id)}`,
531
+ "aria-selected": a ? "true" : "false",
532
+ ...F(e.panelId) ? { "aria-controls": e.panelId } : {},
533
+ tabindex: o ? "0" : "-1",
534
+ ...n.disabled ? {
535
+ disabled: !0,
536
+ ...F(n.reason) ? { title: n.reason } : {}
537
+ } : {},
538
+ ...I(n.attrs)
539
+ }, [n.label, F(n.badge) ? M("span", { class: "stack-tabs__badge" }, n.badge) : null], e.onSelect && !n.disabled ? { click: () => e.onSelect(n.id) } : void 0);
540
+ }), { keydown: Oe });
541
+ }
542
+ function Me(e) {
543
+ let t = ke(e.idPrefix || "stack-tabs");
544
+ return M("div", {
545
+ class: P("stack-tabpanel", e.className),
546
+ role: "tabpanel",
547
+ id: e.id,
548
+ ...F(e.active) ? { "aria-labelledby": `${t}-tab-${ke(e.active)}` } : {},
549
+ tabindex: "0",
550
+ ...I(e.attrs)
551
+ }, e.children || null);
552
+ }
553
+ var Ne = {
554
+ ascending: "▲",
555
+ descending: "▼"
556
+ }, Pe = (e) => (t) => {
557
+ t.target === t.currentTarget && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), e());
558
+ };
559
+ function Fe(e) {
560
+ let t = e.columns || [], n = e.rows || [], r = F(e.label) ? e.label : "Table";
561
+ if (e.error) return L({
562
+ title: e.error.title || `${r} could not be read`,
563
+ message: e.error.message,
564
+ code: e.error.code,
565
+ requestId: e.error.requestId,
566
+ onRetry: e.error.onRetry,
567
+ className: P("stack-table-state", e.className),
568
+ attrs: e.attrs
569
+ });
570
+ if (e.loading && !n.length) return be({
571
+ what: e.loadingWhat || r.toLowerCase(),
572
+ className: P("stack-table-state", e.className),
573
+ attrs: e.attrs
574
+ });
575
+ if (!n.length) {
576
+ let t = !!e.noMatch;
577
+ return Se({
578
+ variant: t ? "no-match" : "empty",
579
+ title: t ? e.noMatchTitle || "Nothing matches" : e.emptyTitle || "Nothing here yet",
580
+ body: t ? e.noMatchBody : e.emptyBody,
581
+ action: t ? null : e.emptyAction,
582
+ headingLevel: e.emptyHeadingLevel || 3,
583
+ className: P("stack-table-state", e.className),
584
+ attrs: e.attrs
585
+ });
586
+ }
587
+ let i = e.sort || {}, a = M("thead", {}, M("tr", {}, t.map((t) => {
588
+ let n = i.column === t.id && Ne[i.direction] ? i.direction : null, r = t.sortable && e.onSort ? M("button", {
589
+ class: "stack-table__sort",
590
+ type: "button"
591
+ }, [t.header, M("span", {
592
+ class: "stack-table__sort-indicator",
593
+ "aria-hidden": "true"
594
+ }, n ? Ne[n] : "↕")], { click: () => e.onSort(t.id) }) : t.header;
595
+ return M("th", {
596
+ class: P("stack-table__header", t.align === "end" ? "stack-table__cell--end" : null),
597
+ scope: "col",
598
+ ...t.sortable && e.onSort ? { "aria-sort": n || "none" } : {}
599
+ }, r);
600
+ }))), o = M("tbody", {}, n.map((e) => {
601
+ let n = typeof e.onSelect == "function";
602
+ return M("tr", {
603
+ class: P("stack-table__row", n ? "stack-table__row--selectable" : null, e.selected ? "stack-table__row--selected" : null, e.className),
604
+ ...n ? { tabindex: "0" } : {},
605
+ ...e.selected ? { "aria-current": "true" } : {},
606
+ ...I(e.attrs)
607
+ }, t.map((t) => {
608
+ let n = e.cells ? e.cells[t.id] : void 0, r = n == null;
609
+ return M("td", {
610
+ class: P("stack-table__cell", t.align === "end" ? "stack-table__cell--end" : null),
611
+ ...r ? { "data-missing": "true" } : {}
612
+ }, r ? "—" : n);
613
+ }), n ? {
614
+ click: e.onSelect,
615
+ keydown: Pe(e.onSelect)
616
+ } : void 0, e.key);
617
+ }));
618
+ return M("div", {
619
+ class: P("stack-table", e.className),
620
+ role: "region",
621
+ "aria-label": r,
622
+ tabindex: "0",
623
+ ...e.loading ? { "aria-busy": "true" } : {},
624
+ ...I(e.attrs)
625
+ }, M("table", { class: "stack-table__table" }, [
626
+ M("caption", { class: e.captionVisible ? "stack-table__caption" : "stack-visually-hidden" }, r),
627
+ a,
628
+ o
629
+ ]));
630
+ }
631
+ function Ie(e, t, n) {
632
+ let r = `${t}-${ke(e.id)}`, i = F(e.value) ? String(e.value) : "", a = n ? (t) => n(e.id, t.target.value) : null, o = e.type === "select" ? M("select", {
633
+ class: "stack-filter__control",
634
+ id: r,
635
+ name: e.id
636
+ }, (e.options || []).map((e) => {
637
+ let t = String(typeof e == "object" ? e.value : e);
638
+ return M("option", {
639
+ value: t,
640
+ ...t === i ? { selected: !0 } : {}
641
+ }, typeof e == "object" ? e.label : e);
642
+ }), a ? { change: a } : void 0) : M("input", {
643
+ class: "stack-filter__control",
644
+ id: r,
645
+ name: e.id,
646
+ type: "search",
647
+ value: i,
648
+ ...F(e.placeholder) ? { placeholder: e.placeholder } : {}
649
+ }, [], a ? { input: a } : void 0);
650
+ return M("div", { class: "stack-filter__field" }, [M("label", {
651
+ class: "stack-filter__label",
652
+ for: r
653
+ }, e.label), o]);
654
+ }
655
+ function Le(e) {
656
+ let t = ke(e.idPrefix || "stack-filter"), n = Number(e.applied) || 0;
657
+ return M("form", {
658
+ class: P("stack-filter", e.className),
659
+ role: "search",
660
+ "aria-label": e.label || "Filters",
661
+ ...I(e.attrs)
662
+ }, [M("div", { class: "stack-filter__controls" }, [(e.filters || []).map((n) => Ie(n, t, e.onChange)), M("div", { class: "stack-filter__actions" }, [Ee({
663
+ label: e.applyLabel || "Apply",
664
+ type: "submit",
665
+ variant: "secondary"
666
+ }), n && e.onClear ? Ee({
667
+ label: e.clearLabel || "Clear",
668
+ variant: "ghost",
669
+ onClick: e.onClear
670
+ }) : null])]), M("p", {
671
+ class: "stack-filter__result",
672
+ role: "status",
673
+ "aria-live": "polite"
674
+ }, F(e.result) ? e.result : "")], e.onSubmit ? { submit: (t) => {
675
+ t.preventDefault(), e.onSubmit();
676
+ } } : void 0);
677
+ }
678
+ function Re(e) {
679
+ return M("nav", {
680
+ class: P("stack-pagination", e.className),
681
+ "aria-label": e.label || "Pagination",
682
+ ...I(e.attrs)
683
+ }, [F(e.summary) ? M("p", { class: "stack-pagination__summary" }, e.summary) : null, M("div", { class: "stack-pagination__actions" }, [Ee({
684
+ label: e.previousLabel || "← Previous",
685
+ variant: "ghost",
686
+ disabled: !e.hasPrevious,
687
+ onClick: e.onPrevious,
688
+ attrs: { "data-page": "previous" }
689
+ }), Ee({
690
+ label: e.nextLabel || "Next →",
691
+ variant: "ghost",
692
+ disabled: !e.hasNext,
693
+ onClick: e.onNext,
694
+ attrs: { "data-page": "next" }
695
+ })])]);
696
+ }
697
+ var ze = Object.freeze([
698
+ {
699
+ value: "system",
700
+ label: "System theme"
701
+ },
702
+ {
703
+ value: "light",
704
+ label: "Light theme"
705
+ },
706
+ {
707
+ value: "dark",
708
+ label: "Dark theme"
709
+ }
710
+ ]);
711
+ function Be(e) {
712
+ let t = e.product || {}, n = (t) => e.onNavigate ? { click: (n) => {
713
+ n.defaultPrevented || n.button !== 0 || n.metaKey || n.ctrlKey || n.shiftKey || n.altKey || (n.preventDefault(), e.onNavigate(t));
714
+ } } : void 0, r = ke(e.mainId || "stack-main"), i = [];
715
+ for (let t of e.navigation || []) {
716
+ let e = t.group || "", n = i.find((t) => t.name === e);
717
+ n || i.push(n = {
718
+ name: e,
719
+ items: []
720
+ }), n.items.push(t);
721
+ }
722
+ for (let e of i) e.items.sort((e, t) => (e.order ?? 0) - (t.order ?? 0));
723
+ let a = (e) => M("li", { class: "stack-shell__nav-entry" }, M("a", {
724
+ class: P("stack-shell__nav-item", e.className),
725
+ href: e.href,
726
+ ...e.current ? { "aria-current": "page" } : {},
727
+ ...I(e.attrs)
728
+ }, e.label, n(e.href))), o = e.theme, s = `${r}-theme`, c = e.otherProducts || [];
729
+ return M("div", {
730
+ class: P("stack-shell", e.className),
731
+ ...I(e.attrs)
732
+ }, [
733
+ M("a", {
734
+ class: "stack-shell__skip",
735
+ href: `#${r}`
736
+ }, e.skipLabel || "Skip to content", { click: Ae(r) }),
737
+ M("header", { class: "stack-shell__bar" }, [
738
+ M("a", {
739
+ class: "stack-shell__product",
740
+ href: t.homeHref || "#"
741
+ }, [F(t.mark) ? M("span", {
742
+ class: "stack-shell__mark",
743
+ "aria-hidden": "true"
744
+ }, t.mark) : null, M("span", { class: "stack-shell__product-name" }, t.name || "")], n(t.homeHref || "#")),
745
+ e.context ? M("div", { class: "stack-shell__context" }, e.context) : null,
746
+ e.search ? M("div", { class: "stack-shell__search" }, e.search) : null,
747
+ M("div", { class: "stack-shell__end" }, [o ? M("div", { class: "stack-shell__prefs" }, [M("label", {
748
+ class: "stack-visually-hidden",
749
+ for: s
750
+ }, "Theme"), M("select", {
751
+ class: "stack-shell__theme",
752
+ id: s
753
+ }, ze.map((e) => M("option", {
754
+ value: e.value,
755
+ ...e.value === (o.preference || "system") ? { selected: !0 } : {}
756
+ }, e.label)), o.onChange ? { change: (e) => o.onChange(e.target.value) } : void 0)]) : null, e.account ? M("div", { class: "stack-shell__account" }, e.account) : null])
757
+ ]),
758
+ M("div", { class: "stack-shell__body" }, [M("nav", {
759
+ class: "stack-shell__nav",
760
+ "aria-label": `${t.name || "Product"} navigation`
761
+ }, [
762
+ i.map((e) => M("div", { class: "stack-shell__nav-group" }, [F(e.name) ? M("p", { class: "stack-shell__nav-heading" }, e.name) : null, M("ul", { class: "stack-shell__nav-list" }, e.items.map(a))])),
763
+ F(e.activityHref) ? M("div", { class: "stack-shell__nav-group stack-shell__activity" }, M("ul", { class: "stack-shell__nav-list" }, a({
764
+ label: e.activityLabel || "Activity",
765
+ href: e.activityHref,
766
+ current: e.activityCurrent
767
+ }))) : null,
768
+ c.length ? M("div", { class: "stack-shell__nav-group stack-shell__switcher" }, [M("p", { class: "stack-shell__nav-heading" }, "Other Stack products"), M("ul", { class: "stack-shell__nav-list" }, c.map((e) => M("li", { class: "stack-shell__nav-entry" }, M("a", {
769
+ class: "stack-shell__nav-item",
770
+ href: e.href
771
+ }, e.name))))]) : null
772
+ ]), M("main", {
773
+ class: "stack-shell__main",
774
+ id: r,
775
+ tabindex: "-1",
776
+ ...I(e.mainAttrs)
777
+ }, e.children || null)])
778
+ ]);
779
+ }
780
+ var Ve = Object.freeze({
781
+ Breadcrumbs: De,
782
+ Tabs: je,
783
+ TabPanel: Me,
784
+ DataTable: Fe,
785
+ FilterBar: Le,
786
+ Pagination: Re,
787
+ Shell: Be,
788
+ StatusIndicator: pe,
789
+ VerificationBadge: he,
790
+ FreshnessLabel: ve,
791
+ Unavailable: ye,
792
+ Loading: be,
793
+ EmptyState: Se,
794
+ ErrorPanel: L,
795
+ MetadataList: R,
796
+ ResourceIdentity: Ce,
797
+ PageHeader: we,
798
+ Button: Ee
799
+ }), He = {
800
+ class: "className",
801
+ for: "htmlFor",
802
+ datetime: "dateTime",
803
+ tabindex: "tabIndex"
804
+ }, Ue = {
805
+ click: "onClick",
806
+ change: "onChange",
807
+ input: "onInput",
808
+ submit: "onSubmit",
809
+ keydown: "onKeyDown"
810
+ };
811
+ function We(e, t) {
812
+ if (e == null || e === !1 || e === !0) return null;
813
+ if (typeof e == "string" || typeof e == "number") return e;
814
+ if (Array.isArray(e)) return d(l, t === void 0 ? null : { key: t }, ...e.map((e, t) => We(e, t)));
815
+ if (f(e)) return t === void 0 ? e : d(l, { key: t }, e);
816
+ if (N(e)) {
817
+ let n = e.k === void 0 ? t : e.k, r = n === void 0 ? {} : { key: n };
818
+ for (let [t, n] of Object.entries(e.a)) n != null && n !== !1 && (r[He[t] || t] = n);
819
+ let i = e.t === "input" || e.t === "select" || e.t === "textarea";
820
+ for (let [t, n] of Object.entries(e.on || {})) {
821
+ if (!Ue[t]) throw Error(`toReact: unsupported event ${t}`);
822
+ r[i && (t === "input" || t === "change") ? "onChange" : Ue[t]] = n;
823
+ }
824
+ let a = e.c;
825
+ if (e.t === "select") {
826
+ let e = a.find((e) => N(e) && e.t === "option" && e.a.selected);
827
+ a = a.map((e) => N(e) && e.t === "option" && e.a.selected ? {
828
+ ...e,
829
+ a: {
830
+ ...e.a,
831
+ selected: !1
832
+ }
833
+ } : e), e && (r.value = e.a.value);
834
+ }
835
+ i && "value" in r && !r.onChange && (r.defaultValue = r.value, delete r.value);
836
+ let o = a.map((e, t) => We(e, t));
837
+ return d(e.t, r, ...o);
838
+ }
839
+ throw TypeError("toReact: unsupported child");
840
+ }
841
+ var B = (e) => {
842
+ let t = Ve[e], n = (e) => We(t(e || {}));
843
+ return n.displayName = `Stack${e}`, n;
844
+ }, Ge = B("StatusIndicator"), Ke = B("VerificationBadge");
845
+ B("FreshnessLabel");
846
+ var qe = B("Unavailable"), Je = B("Loading");
847
+ B("EmptyState");
848
+ var Ye = B("ErrorPanel"), Xe = B("MetadataList");
849
+ B("ResourceIdentity");
850
+ var Ze = B("PageHeader");
851
+ B("Button"), B("Breadcrumbs");
852
+ var Qe = B("Tabs"), $e = B("TabPanel"), et = B("DataTable"), tt = B("FilterBar"), nt = B("Pagination"), rt = B("Shell"), it = u(null);
853
+ function at({ options: e, children: t }) {
854
+ let { baseUrl: n = "", token: r = "", applicationId: o = "", environment: s = "production" } = e, c = g(() => new a({
855
+ baseUrl: n,
856
+ token: r,
857
+ applicationId: o,
858
+ environment: s
859
+ }), [
860
+ n,
861
+ r,
862
+ o,
863
+ s
864
+ ]), [l, u] = v(new i(null)), [d, f] = v(!0), [p, h] = v(""), [_, y] = v(0);
865
+ m(() => {
866
+ let e = !0;
867
+ return f(!0), c.capabilities().then((t) => {
868
+ e && (u(t), h(""));
869
+ }).catch((t) => {
870
+ e && (u(new i(null)), h(t instanceof Error ? t.message : "The control plane did not answer."));
871
+ }).finally(() => {
872
+ e && f(!1);
873
+ }), () => {
874
+ e = !1;
875
+ };
876
+ }, [c, _]);
877
+ let b = g(() => ({
878
+ api: c,
879
+ capabilities: l,
880
+ loading: d,
881
+ error: p,
882
+ applicationId: o,
883
+ environment: s,
884
+ baseUrl: n,
885
+ token: r,
886
+ reload: () => y((e) => e + 1)
887
+ }), [
888
+ c,
889
+ l,
890
+ d,
891
+ p,
892
+ o,
893
+ s,
894
+ n,
895
+ r
896
+ ]);
897
+ return /* @__PURE__ */ x(it.Provider, {
898
+ value: b,
899
+ children: t
900
+ });
901
+ }
902
+ function V() {
903
+ let e = p(it);
904
+ if (!e) throw Error("useControlPlane requires a ControlPlaneProvider");
905
+ return e;
906
+ }
907
+ function H(e, t, n = {}) {
908
+ let { api: r } = V(), i = n.enabled !== !1, [a, s] = v(), [c, l] = v(i), [u, d] = v(""), [f, p] = v(0);
909
+ return m(() => {
910
+ if (!i) {
911
+ l(!1);
912
+ return;
913
+ }
914
+ let t = !0, a = () => {
915
+ e(r).then((e) => {
916
+ t && (s(e), d(""));
917
+ }).catch((e) => {
918
+ t && d(o(e, n.subject));
919
+ }).finally(() => {
920
+ t && l(!1);
921
+ });
922
+ };
923
+ if (l(!0), a(), !n.refreshMs) return () => {
924
+ t = !1;
925
+ };
926
+ let c = window.setInterval(a, n.refreshMs);
927
+ return () => {
928
+ t = !1, window.clearInterval(c);
929
+ };
930
+ }, [
931
+ r,
932
+ i,
933
+ f,
934
+ ...t
935
+ ]), {
936
+ value: a,
937
+ loading: c,
938
+ error: u,
939
+ refresh: () => p((e) => e + 1)
940
+ };
941
+ }
942
+ //#endregion
943
+ //#region src/control-plane/primitives.tsx
944
+ function U({ status: e }) {
945
+ return /* @__PURE__ */ x("span", {
946
+ className: `cp-pill cp-pill-${e}`,
947
+ children: e.replace(/[-_]/g, " ")
948
+ });
949
+ }
950
+ function W({ capability: e, title: t }) {
951
+ let { capabilities: n } = V(), r = n.get(e), i = n.status(e);
952
+ return /* @__PURE__ */ x(qe, {
953
+ status: i === "partial" ? "partial" : "unsupported",
954
+ capability: e,
955
+ title: t || r?.title || "Not available on this instance",
956
+ headingLevel: 3,
957
+ reason: n.note(e),
958
+ children: /* @__PURE__ */ S("p", {
959
+ className: "cp-unavailable-id",
960
+ children: [
961
+ "Capability ",
962
+ /* @__PURE__ */ x("code", { children: e }),
963
+ " · declared ",
964
+ /* @__PURE__ */ x(U, { status: i })
965
+ ]
966
+ })
967
+ });
968
+ }
969
+ function G({ capability: e, requireFull: t, children: n }) {
970
+ let { capabilities: r } = V(), i = r.status(e);
971
+ return i === "unsupported" || t && i !== "available" ? /* @__PURE__ */ x(W, { capability: e }) : /* @__PURE__ */ x(b, { children: n });
972
+ }
973
+ function ot({ capability: e }) {
974
+ let { capabilities: t } = V();
975
+ return t.status(e) === "partial" ? /* @__PURE__ */ x("p", {
976
+ className: "cp-notice",
977
+ children: t.note(e)
978
+ }) : null;
979
+ }
980
+ function K({ what: e }) {
981
+ return /* @__PURE__ */ x(Je, { what: e });
982
+ }
983
+ function q({ message: e, onRetry: t }) {
984
+ return e ? /* @__PURE__ */ x(Ye, {
985
+ title: e,
986
+ onRetry: t
987
+ }) : null;
988
+ }
989
+ function J({ children: e }) {
990
+ return /* @__PURE__ */ x("p", {
991
+ className: "cp-empty",
992
+ children: e
993
+ });
994
+ }
995
+ function Y({ label: e, value: t, hint: n }) {
996
+ let r = t == null ? "—" : typeof t == "number" ? t.toLocaleString() : String(t);
997
+ return /* @__PURE__ */ S("div", {
998
+ className: "cp-stat",
999
+ children: [/* @__PURE__ */ x("small", { children: e }), /* @__PURE__ */ x("strong", {
1000
+ title: n,
1001
+ children: r
1002
+ })]
1003
+ });
1004
+ }
1005
+ function X({ value: e }) {
1006
+ return /* @__PURE__ */ x("pre", {
1007
+ className: "cp-json",
1008
+ children: JSON.stringify(e, null, 2)
1009
+ });
1010
+ }
1011
+ function st({ path: e }) {
1012
+ return /* @__PURE__ */ x("code", {
1013
+ className: "cp-path",
1014
+ children: s(e)
1015
+ });
1016
+ }
1017
+ function Z({ ms: e }) {
1018
+ if (!e) return /* @__PURE__ */ x("span", {
1019
+ className: "cp-muted",
1020
+ children: "—"
1021
+ });
1022
+ let t = new Date(e);
1023
+ return /* @__PURE__ */ x("time", {
1024
+ dateTime: t.toISOString(),
1025
+ title: t.toISOString(),
1026
+ children: t.toLocaleString()
1027
+ });
1028
+ }
1029
+ function Q({ value: e, length: t = 12 }) {
1030
+ return e ? /* @__PURE__ */ x("code", {
1031
+ className: "cp-identity",
1032
+ title: e,
1033
+ children: e.length > t ? `${e.slice(0, t)}…` : e
1034
+ }) : /* @__PURE__ */ x("span", {
1035
+ className: "cp-muted",
1036
+ children: "—"
1037
+ });
1038
+ }
1039
+ function ct({ tabs: e, active: t, onSelect: n, label: r, children: i }) {
1040
+ let a = `cp-tabs${h()}`, o = `${a}-panel`;
1041
+ return /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(Qe, {
1042
+ className: "cp-tabs",
1043
+ idPrefix: a,
1044
+ panelId: o,
1045
+ label: r,
1046
+ tabs: e,
1047
+ active: t,
1048
+ onSelect: (e) => n(e)
1049
+ }), /* @__PURE__ */ x($e, {
1050
+ id: o,
1051
+ idPrefix: a,
1052
+ active: t,
1053
+ className: "cp-tabpanel",
1054
+ children: i
1055
+ })] });
1056
+ }
1057
+ function $({ eyebrow: e, title: t, description: n, children: r }) {
1058
+ return /* @__PURE__ */ S("div", {
1059
+ className: "cp-page",
1060
+ children: [/* @__PURE__ */ x(Ze, {
1061
+ eyebrow: e,
1062
+ title: t,
1063
+ description: n
1064
+ }), r]
1065
+ });
1066
+ }
1067
+ //#endregion
1068
+ //#region src/control-plane/Overview.tsx
1069
+ function lt(e) {
1070
+ return e == null ? null : typeof e == "number" ? e.toLocaleString() : String(e);
1071
+ }
1072
+ var ut = (e) => e.map((e) => ({
1073
+ label: e.label,
1074
+ value: lt(e.value),
1075
+ hint: e.hint
1076
+ }));
1077
+ function dt() {
1078
+ let { value: e, loading: t, error: n, refresh: r } = H((e) => e.overview(), [], {
1079
+ refreshMs: 1e4,
1080
+ subject: "the instance overview"
1081
+ }), { value: i } = H((e) => e.replication(), [], {
1082
+ refreshMs: 15e3,
1083
+ subject: "replication health"
1084
+ }), { value: a } = H((e) => e.transactions({ limit: 8 }), [], {
1085
+ refreshMs: 1e4,
1086
+ subject: "recent commits"
1087
+ });
1088
+ if (t && !e) return /* @__PURE__ */ x($, {
1089
+ eyebrow: "Instance",
1090
+ title: "Overview",
1091
+ children: /* @__PURE__ */ x(K, { what: "the instance" })
1092
+ });
1093
+ if (!e) return /* @__PURE__ */ x($, {
1094
+ eyebrow: "Instance",
1095
+ title: "Overview",
1096
+ children: /* @__PURE__ */ x(q, {
1097
+ message: n,
1098
+ onRetry: r
1099
+ })
1100
+ });
1101
+ let o = e.storage?.log_recovery || {}, s = e.storage?.collections, c = (e, t, n) => typeof e == "boolean" ? e ? t : n : void 0, l = i?.peers || [], u = a?.transactions?.[0];
1102
+ return /* @__PURE__ */ x($, {
1103
+ eyebrow: "Instance",
1104
+ title: "Overview",
1105
+ description: `${e.instance.namespace} · ${e.instance.instance_id}`,
1106
+ children: /* @__PURE__ */ S(G, {
1107
+ capability: "overview.instance",
1108
+ children: [
1109
+ /* @__PURE__ */ x(q, {
1110
+ message: n,
1111
+ onRetry: r
1112
+ }),
1113
+ /* @__PURE__ */ x("section", {
1114
+ "aria-label": "Instance status",
1115
+ children: /* @__PURE__ */ x(Xe, { items: ut([
1116
+ {
1117
+ label: "Engine",
1118
+ value: e.instance.engine_version
1119
+ },
1120
+ {
1121
+ label: "Protocol",
1122
+ value: e.instance.protocol_version
1123
+ },
1124
+ {
1125
+ label: "Uptime",
1126
+ value: e.instance.uptime_seconds === void 0 ? void 0 : `${e.instance.uptime_seconds}s`
1127
+ },
1128
+ {
1129
+ label: "Authentication",
1130
+ value: c(e.instance.authentication_enabled, "Enabled", "Disabled")
1131
+ }
1132
+ ]) })
1133
+ }),
1134
+ /* @__PURE__ */ S("section", {
1135
+ className: "cp-panels",
1136
+ children: [
1137
+ /* @__PURE__ */ S("article", {
1138
+ className: "studio-card",
1139
+ children: [
1140
+ /* @__PURE__ */ x("span", {
1141
+ className: "card-kind",
1142
+ children: "Authority"
1143
+ }),
1144
+ /* @__PURE__ */ x(Xe, { items: [...ut([{
1145
+ label: "Authority revision",
1146
+ value: e.authority.authority_revision,
1147
+ hint: "Monotonic commit order. One transaction advances it once."
1148
+ }, {
1149
+ label: "State version",
1150
+ value: e.authority.state_version
1151
+ }]), {
1152
+ label: "Lease clock",
1153
+ value: typeof e.authority.lease_clock_healthy == "boolean" ? /* @__PURE__ */ x(Ge, {
1154
+ field: "feltdb.authority.lease_clock_healthy",
1155
+ value: e.authority.lease_clock_healthy,
1156
+ attrs: { "data-overview": "lease-clock" }
1157
+ }) : null
1158
+ }] }),
1159
+ e.authority.advertise_url && /* @__PURE__ */ S("p", {
1160
+ className: "cp-muted",
1161
+ children: ["Advertised at ", /* @__PURE__ */ x("code", { children: e.authority.advertise_url })]
1162
+ })
1163
+ ]
1164
+ }),
1165
+ /* @__PURE__ */ S("article", {
1166
+ className: "studio-card",
1167
+ children: [
1168
+ /* @__PURE__ */ x("span", {
1169
+ className: "card-kind",
1170
+ children: "Storage and durability"
1171
+ }),
1172
+ /* @__PURE__ */ x(Xe, { items: ut([
1173
+ {
1174
+ label: "Records",
1175
+ value: e.storage.records
1176
+ },
1177
+ {
1178
+ label: "State revisions",
1179
+ value: e.storage.state_revisions
1180
+ },
1181
+ {
1182
+ label: "Collections",
1183
+ value: s?.length
1184
+ }
1185
+ ]) }),
1186
+ /* @__PURE__ */ x("p", {
1187
+ className: o.status === "clean" ? "cp-muted" : "cp-notice",
1188
+ children: o.status === "clean" ? "The durable log opened clean: every byte was a complete record." : `Log recovery discarded an incomplete final append at byte ${o.byte_offset} (${o.discarded_bytes} bytes). The last write before restart did not land.`
1189
+ })
1190
+ ]
1191
+ }),
1192
+ /* @__PURE__ */ S("article", {
1193
+ className: "studio-card",
1194
+ children: [/* @__PURE__ */ x("span", {
1195
+ className: "card-kind",
1196
+ children: "FeltDB runtime"
1197
+ }), /* @__PURE__ */ x(Xe, { items: ut([
1198
+ {
1199
+ label: "Autonomous worker",
1200
+ value: c(e.runtime.worker_enabled, "Running", "Off")
1201
+ },
1202
+ {
1203
+ label: "Request deadline",
1204
+ value: e.runtime.request_deadline_ms === void 0 ? void 0 : `${e.runtime.request_deadline_ms} ms`
1205
+ },
1206
+ {
1207
+ label: "Admission slots free",
1208
+ value: e.runtime.admission_permits_available
1209
+ }
1210
+ ]) })]
1211
+ }),
1212
+ /* @__PURE__ */ S("article", {
1213
+ className: "studio-card",
1214
+ children: [/* @__PURE__ */ x("span", {
1215
+ className: "card-kind",
1216
+ children: "Replication"
1217
+ }), /* @__PURE__ */ x(Xe, { items: ut([
1218
+ {
1219
+ label: "Peers",
1220
+ value: i ? l.length : void 0
1221
+ },
1222
+ {
1223
+ label: "Sync failures",
1224
+ value: i?.health?.peer_sync_failures
1225
+ },
1226
+ {
1227
+ label: "Operations sent",
1228
+ value: i?.health?.operations_sent
1229
+ }
1230
+ ]) })]
1231
+ })
1232
+ ]
1233
+ }),
1234
+ /* @__PURE__ */ S("section", {
1235
+ className: "studio-card",
1236
+ children: [
1237
+ /* @__PURE__ */ x("span", {
1238
+ className: "card-kind",
1239
+ children: "Activity"
1240
+ }),
1241
+ /* @__PURE__ */ x(Xe, { items: ut([
1242
+ {
1243
+ label: "Requests",
1244
+ value: e.activity?.requests
1245
+ },
1246
+ {
1247
+ label: "State reads",
1248
+ value: e.activity?.state_reads
1249
+ },
1250
+ {
1251
+ label: "State mutations",
1252
+ value: e.activity?.state_mutations
1253
+ },
1254
+ {
1255
+ label: "Requests shed",
1256
+ value: e.activity?.requests_shed,
1257
+ hint: "Refused at the door because the server was already at its in-flight limit."
1258
+ },
1259
+ {
1260
+ label: "Deadlines exceeded",
1261
+ value: e.activity?.request_deadlines_exceeded
1262
+ },
1263
+ {
1264
+ label: "Authentication failures",
1265
+ value: e.activity?.authentication_failures
1266
+ }
1267
+ ]) }),
1268
+ u ? /* @__PURE__ */ S("p", {
1269
+ className: "cp-muted",
1270
+ children: [
1271
+ "Last recorded commit ",
1272
+ /* @__PURE__ */ x("code", { children: u.transaction_id }),
1273
+ " by ",
1274
+ /* @__PURE__ */ x("strong", { children: u.subject || "an unnamed actor" }),
1275
+ " · ",
1276
+ /* @__PURE__ */ x(Z, { ms: u.unix_ms })
1277
+ ]
1278
+ }) : /* @__PURE__ */ x("p", {
1279
+ className: "cp-muted",
1280
+ children: "No commit is inside the attribution window yet."
1281
+ })
1282
+ ]
1283
+ }),
1284
+ /* @__PURE__ */ S("section", {
1285
+ className: "studio-card",
1286
+ children: [/* @__PURE__ */ x("span", {
1287
+ className: "card-kind",
1288
+ children: "Collections"
1289
+ }), s ? s.length === 0 ? /* @__PURE__ */ x(J, { children: "This instance holds no application collections yet." }) : /* @__PURE__ */ x(et, {
1290
+ label: "Application collections",
1291
+ columns: [
1292
+ {
1293
+ id: "collection",
1294
+ header: "Collection"
1295
+ },
1296
+ {
1297
+ id: "capability",
1298
+ header: "Capability"
1299
+ },
1300
+ {
1301
+ id: "records",
1302
+ header: "Records",
1303
+ align: "end"
1304
+ }
1305
+ ],
1306
+ rows: s.map((e) => ({
1307
+ key: e.capability,
1308
+ cells: {
1309
+ collection: e.collection,
1310
+ capability: /* @__PURE__ */ x("code", { children: e.capability }),
1311
+ records: Number(e.records).toLocaleString()
1312
+ }
1313
+ }))
1314
+ }) : /* @__PURE__ */ x(J, { children: "This instance did not report its collections." })]
1315
+ }),
1316
+ /* @__PURE__ */ S("details", {
1317
+ className: "cp-raw",
1318
+ children: [/* @__PURE__ */ x("summary", { children: "Raw overview document" }), /* @__PURE__ */ x(X, { value: e })]
1319
+ })
1320
+ ]
1321
+ })
1322
+ });
1323
+ }
1324
+ //#endregion
1325
+ //#region src/control-plane/Data.tsx
1326
+ function ft({ field: e, value: t }) {
1327
+ let n = r(e, t);
1328
+ return n == null ? /* @__PURE__ */ x("span", {
1329
+ className: "data-null",
1330
+ children: "—"
1331
+ }) : typeof n == "boolean" ? /* @__PURE__ */ x("span", {
1332
+ className: `data-boolean ${n}`,
1333
+ children: n ? "True" : "False"
1334
+ }) : typeof n == "object" ? /* @__PURE__ */ S("details", { children: [/* @__PURE__ */ x("summary", { children: Array.isArray(n) ? `${n.length} items` : "Object" }), /* @__PURE__ */ x("pre", { children: JSON.stringify(n, null, 2) })] }) : /* @__PURE__ */ x(b, { children: String(n) });
1335
+ }
1336
+ function pt({ action: e, fields: n, initial: r, onSubmit: i, onCancel: a }) {
1337
+ let [s, c] = v(() => {
1338
+ let t = { id: r?.id === void 0 ? "" : String(r.id) };
1339
+ for (let n of e.input_fields) {
1340
+ let e = r?.[n];
1341
+ t[n] = e == null ? "" : typeof e == "object" ? JSON.stringify(e) : String(e);
1342
+ }
1343
+ return t;
1344
+ }), [l, u] = v(!1), [d, f] = v(""), p = (e) => n.find((t) => t.name === e)?.type || "text", m = async () => {
1345
+ u(!0), f("");
1346
+ try {
1347
+ let t = {};
1348
+ s.id.trim() && (t.id = s.id.trim());
1349
+ for (let n of e.input_fields) {
1350
+ let e = s[n];
1351
+ if (e === "") continue;
1352
+ let r = p(n);
1353
+ if (r === "boolean") t[n] = e === "true";
1354
+ else if (/integer|number|decimal/.test(r)) t[n] = Number(e);
1355
+ else if (/json|object|array|map/.test(r)) try {
1356
+ t[n] = JSON.parse(e);
1357
+ } catch {
1358
+ throw Error(`${n} is declared ${r} and must be valid JSON.`);
1359
+ }
1360
+ else t[n] = e;
1361
+ }
1362
+ await i(t);
1363
+ } catch (t) {
1364
+ f(t instanceof Error && !("code" in t) ? t.message : o(t, e.name));
1365
+ } finally {
1366
+ u(!1);
1367
+ }
1368
+ };
1369
+ return /* @__PURE__ */ S("form", {
1370
+ className: "studio-card cp-action-form",
1371
+ onSubmit: (e) => {
1372
+ e.preventDefault(), m();
1373
+ },
1374
+ children: [
1375
+ /* @__PURE__ */ S("span", {
1376
+ className: "card-kind",
1377
+ children: [
1378
+ e.operation,
1379
+ " · ",
1380
+ e.name
1381
+ ]
1382
+ }),
1383
+ /* @__PURE__ */ S("label", { children: ["id", /* @__PURE__ */ x("input", {
1384
+ value: s.id,
1385
+ onChange: (e) => c((t) => ({
1386
+ ...t,
1387
+ id: e.target.value
1388
+ })),
1389
+ placeholder: e.operation === "create" ? "optional — FeltDB derives one" : "required"
1390
+ })] }),
1391
+ e.operation !== "delete" && e.input_fields.map((e) => /* @__PURE__ */ S("label", { children: [
1392
+ e,
1393
+ " ",
1394
+ /* @__PURE__ */ S("small", { children: [p(e), t(e) ? " · secret" : ""] }),
1395
+ p(e) === "boolean" ? /* @__PURE__ */ S("select", {
1396
+ value: s[e],
1397
+ onChange: (t) => c((n) => ({
1398
+ ...n,
1399
+ [e]: t.target.value
1400
+ })),
1401
+ children: [
1402
+ /* @__PURE__ */ x("option", {
1403
+ value: "",
1404
+ children: "unset"
1405
+ }),
1406
+ /* @__PURE__ */ x("option", {
1407
+ value: "true",
1408
+ children: "true"
1409
+ }),
1410
+ /* @__PURE__ */ x("option", {
1411
+ value: "false",
1412
+ children: "false"
1413
+ })
1414
+ ]
1415
+ }) : /* @__PURE__ */ x("input", {
1416
+ value: s[e],
1417
+ onChange: (t) => c((n) => ({
1418
+ ...n,
1419
+ [e]: t.target.value
1420
+ }))
1421
+ })
1422
+ ] }, e)),
1423
+ /* @__PURE__ */ x(q, { message: d }),
1424
+ /* @__PURE__ */ S("div", {
1425
+ className: "cp-actions",
1426
+ children: [/* @__PURE__ */ x("button", {
1427
+ type: "button",
1428
+ className: "btn btn-ghost",
1429
+ onClick: a,
1430
+ children: "Cancel"
1431
+ }), /* @__PURE__ */ x("button", {
1432
+ className: "btn btn-primary",
1433
+ disabled: l,
1434
+ children: l ? "Running…" : `Run ${e.name}`
1435
+ })]
1436
+ })
1437
+ ]
1438
+ });
1439
+ }
1440
+ function mt({ collection: e, id: t }) {
1441
+ let { value: n, loading: r, error: i, refresh: a } = H((n) => n.provenance(e, t), [e, t], { subject: "this record’s provenance" });
1442
+ if (r && !n) return /* @__PURE__ */ x(K, { what: "provenance" });
1443
+ if (!n) return /* @__PURE__ */ x(q, {
1444
+ message: i,
1445
+ onRetry: a
1446
+ });
1447
+ let o = n.attribution.actor;
1448
+ return /* @__PURE__ */ S(b, { children: [
1449
+ /* @__PURE__ */ S("p", {
1450
+ className: "cp-attribution",
1451
+ children: [
1452
+ o ? /* @__PURE__ */ S(b, { children: ["Last changed by ", /* @__PURE__ */ x("strong", { children: o })] }) : /* @__PURE__ */ x(b, { children: "No actor is recorded for the last change" }),
1453
+ n.attribution.authority && /* @__PURE__ */ S(b, { children: [" on authority ", /* @__PURE__ */ x("code", { children: n.attribution.authority })] }),
1454
+ " · ",
1455
+ /* @__PURE__ */ x(Z, { ms: n.updated_ms })
1456
+ ]
1457
+ }),
1458
+ /* @__PURE__ */ S("div", {
1459
+ className: "cp-stats",
1460
+ children: [
1461
+ /* @__PURE__ */ x(Y, {
1462
+ label: "Attribution source",
1463
+ value: n.attribution.source,
1464
+ hint: "transaction: an actor's commit named this record. authority: only the writing instance is known."
1465
+ }),
1466
+ /* @__PURE__ */ x(Y, {
1467
+ label: "Content hash",
1468
+ value: n.content_hash ? `${n.content_hash.slice(0, 12)}…` : void 0
1469
+ }),
1470
+ /* @__PURE__ */ x(Y, {
1471
+ label: "Commits held",
1472
+ value: n.transactions.length
1473
+ }),
1474
+ /* @__PURE__ */ x(Y, {
1475
+ label: "State revisions",
1476
+ value: n.revisions.length
1477
+ })
1478
+ ]
1479
+ }),
1480
+ /* @__PURE__ */ x("h3", { children: "Commits that named this record" }),
1481
+ /* @__PURE__ */ x(ot, { capability: "provenance.transactions" }),
1482
+ n.transactions.length === 0 ? /* @__PURE__ */ x(J, { children: "No commit inside the attribution window named this record." }) : /* @__PURE__ */ x("div", {
1483
+ className: "table-shell",
1484
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
1485
+ /* @__PURE__ */ x("th", { children: "When" }),
1486
+ /* @__PURE__ */ x("th", { children: "Actor" }),
1487
+ /* @__PURE__ */ x("th", { children: "Transaction" }),
1488
+ /* @__PURE__ */ x("th", { children: "Records" }),
1489
+ /* @__PURE__ */ x("th", { children: "Revision" })
1490
+ ] }) }), /* @__PURE__ */ x("tbody", { children: n.transactions.map((e) => /* @__PURE__ */ S("tr", { children: [
1491
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Z, { ms: e.unix_ms }) }),
1492
+ /* @__PURE__ */ x("td", { children: e.subject || /* @__PURE__ */ x("span", {
1493
+ className: "cp-muted",
1494
+ children: "unnamed"
1495
+ }) }),
1496
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Q, {
1497
+ value: e.transaction_id,
1498
+ length: 16
1499
+ }) }),
1500
+ /* @__PURE__ */ x("td", { children: e.operations }),
1501
+ /* @__PURE__ */ S("td", { children: [
1502
+ e.base_revision,
1503
+ " → ",
1504
+ e.commit_revision
1505
+ ] })
1506
+ ] }, e.transaction_id)) })] })
1507
+ }),
1508
+ /* @__PURE__ */ x("h3", { children: "State revisions" }),
1509
+ n.revisions.length === 0 ? /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(ot, { capability: "data.records.history" }), /* @__PURE__ */ x(J, { children: "This record has no state revisions. Its write path advances the authority revision without minting one." })] }) : /* @__PURE__ */ x("div", {
1510
+ className: "table-shell",
1511
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
1512
+ /* @__PURE__ */ x("th", { children: "#" }),
1513
+ /* @__PURE__ */ x("th", { children: "State ID" }),
1514
+ /* @__PURE__ */ x("th", { children: "Parent" }),
1515
+ /* @__PURE__ */ x("th", { children: "Authority" }),
1516
+ /* @__PURE__ */ x("th", { children: "When" })
1517
+ ] }) }), /* @__PURE__ */ x("tbody", { children: n.revisions.map((e) => /* @__PURE__ */ S("tr", { children: [
1518
+ /* @__PURE__ */ x("td", { children: e.sequence }),
1519
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Q, { value: e.state_id }) }),
1520
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Q, { value: e.parent_id }) }),
1521
+ /* @__PURE__ */ x("td", { children: e.authority }),
1522
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Z, { ms: e.timestamp_ms }) })
1523
+ ] }, e.state_id)) })] })
1524
+ }),
1525
+ /* @__PURE__ */ S("details", {
1526
+ className: "cp-raw",
1527
+ children: [/* @__PURE__ */ x("summary", { children: "Raw operation record" }), /* @__PURE__ */ x(X, { value: n.operation })]
1528
+ })
1529
+ ] });
1530
+ }
1531
+ function ht({ schema: e }) {
1532
+ return /* @__PURE__ */ x("div", {
1533
+ className: "table-shell",
1534
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
1535
+ /* @__PURE__ */ x("th", { children: "Field" }),
1536
+ /* @__PURE__ */ x("th", { children: "Type" }),
1537
+ /* @__PURE__ */ x("th", { children: "Required" }),
1538
+ /* @__PURE__ */ x("th", { children: "Reference" })
1539
+ ] }) }), /* @__PURE__ */ x("tbody", { children: e.fields.map((e) => /* @__PURE__ */ S("tr", { children: [
1540
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("code", { children: e.name }) }),
1541
+ /* @__PURE__ */ x("td", { children: e.type }),
1542
+ /* @__PURE__ */ x("td", { children: e.required ? "required" : "optional" }),
1543
+ /* @__PURE__ */ x("td", { children: e.reference ? /* @__PURE__ */ S("span", {
1544
+ className: "reference-value",
1545
+ children: ["→ ", e.reference]
1546
+ }) : /* @__PURE__ */ x("span", {
1547
+ className: "cp-muted",
1548
+ children: "—"
1549
+ }) })
1550
+ ] }, e.name)) })] })
1551
+ });
1552
+ }
1553
+ function gt({ collection: e, report: t, onRebuild: n }) {
1554
+ let { capabilities: r } = V();
1555
+ if (!t) return /* @__PURE__ */ x(K, { what: "indexes" });
1556
+ let i = t.declared.filter((t) => t.collection === e), a = t.access_paths.find((t) => t.collection === e);
1557
+ return /* @__PURE__ */ S(b, { children: [
1558
+ /* @__PURE__ */ x("h3", { children: "Declared indexes" }),
1559
+ i.length === 0 ? /* @__PURE__ */ S(J, { children: [
1560
+ "The application contract declares no index on ",
1561
+ e,
1562
+ "."
1563
+ ] }) : /* @__PURE__ */ x("div", {
1564
+ className: "table-shell",
1565
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
1566
+ /* @__PURE__ */ x("th", { children: "Index" }),
1567
+ /* @__PURE__ */ x("th", { children: "Fields" }),
1568
+ /* @__PURE__ */ x("th", { children: "Unique" }),
1569
+ /* @__PURE__ */ x("th", { children: "State" }),
1570
+ /* @__PURE__ */ x("th", {})
1571
+ ] }) }), /* @__PURE__ */ x("tbody", { children: i.map((e) => /* @__PURE__ */ S("tr", { children: [
1572
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("code", { children: e.name }) }),
1573
+ /* @__PURE__ */ x("td", { children: e.fields.map((e) => /* @__PURE__ */ x("span", {
1574
+ className: e.backed ? "cp-grant granted" : "cp-grant denied",
1575
+ children: e.field
1576
+ }, e.field)) }),
1577
+ /* @__PURE__ */ x("td", { children: e.unique ? "unique" : "non-unique" }),
1578
+ /* @__PURE__ */ S("td", { children: [
1579
+ /* @__PURE__ */ x(U, { status: e.state === "backed" ? "available" : "partial" }),
1580
+ " ",
1581
+ e.state
1582
+ ] }),
1583
+ /* @__PURE__ */ x("td", { children: r.usable("data.indexes.rebuild") && e.fields.map((e) => /* @__PURE__ */ S("button", {
1584
+ className: "btn btn-ghost",
1585
+ onClick: () => n(e.field),
1586
+ children: ["Rebuild ", e.field]
1587
+ }, e.field)) })
1588
+ ] }, e.name)) })] })
1589
+ }),
1590
+ /* @__PURE__ */ x("h3", { children: "Access paths" }),
1591
+ /* @__PURE__ */ x("p", {
1592
+ className: "cp-muted",
1593
+ children: "How an equality filter on each field would be served. A field served by a scan is still filterable — it is filterable by reading the collection, which is the thing an operator needs to know before running it against a large collection."
1594
+ }),
1595
+ /* @__PURE__ */ x("div", {
1596
+ className: "table-shell",
1597
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [/* @__PURE__ */ x("th", { children: "Field" }), /* @__PURE__ */ x("th", { children: "Access method" })] }) }), /* @__PURE__ */ x("tbody", { children: (a?.fields || []).map((e) => /* @__PURE__ */ S("tr", { children: [/* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("code", { children: e.field }) }), /* @__PURE__ */ S("td", { children: [
1598
+ /* @__PURE__ */ x(U, { status: e.access_method === "index" ? "available" : "partial" }),
1599
+ " ",
1600
+ e.access_method === "index" ? "index" : "full scan"
1601
+ ] })] }, e.field)) })] })
1602
+ })
1603
+ ] });
1604
+ }
1605
+ function _t({ focus: t, onFocusHandled: r }) {
1606
+ let { api: i, applicationId: a, environment: s, capabilities: l, baseUrl: u, token: d } = V(), [f, p] = y(), m = f.get("collection") || "", h = g(() => new e({
1607
+ baseUrl: u,
1608
+ token: d,
1609
+ applicationId: a,
1610
+ environment: s
1611
+ }), [
1612
+ u,
1613
+ d,
1614
+ a,
1615
+ s
1616
+ ]), [_, C] = v(""), [w, T] = v("browse"), [E, D] = v(""), [O, k] = v("data"), [A, j] = v(""), [ee, te] = v(""), [ne, re] = v({}), [ie, ae] = v(), [oe, se] = v([]), [ce, le] = v(null), [ue, M] = v(""), { value: N, loading: P, error: F, refresh: I } = H(() => h.schema(), [h], { subject: "the application schema" }), { value: de } = H((e) => e.actions(), [], { subject: "declared actions" }), { value: fe, refresh: pe } = H((e) => e.indexes(), [], { subject: "indexes" }), me = n(a, N), he = g(() => new e({
1617
+ baseUrl: u,
1618
+ token: d,
1619
+ applicationId: me,
1620
+ environment: s
1621
+ }), [
1622
+ u,
1623
+ d,
1624
+ me,
1625
+ s
1626
+ ]);
1627
+ c.useEffect(() => {
1628
+ N?.collections.length && C((e) => N.collections.some((e) => e.collection === m) ? m : N.collections.some((t) => t.collection === e) ? e : N.collections[0].collection);
1629
+ }, [N, m]), c.useEffect(() => {
1630
+ t && (C(t.collection), D(t.id), k("provenance"), r?.());
1631
+ }, [t]);
1632
+ let ge = JSON.stringify([
1633
+ _,
1634
+ ie ?? null,
1635
+ ne
1636
+ ]), { value: _e, loading: ve, error: ye, refresh: be } = H(() => he.records(_, ie, ne).then((e) => ({
1637
+ ...e,
1638
+ request: ge
1639
+ })), [he, ge], {
1640
+ enabled: !!_,
1641
+ subject: _
1642
+ }), { value: xe, error: Se } = H(() => he.record(_, E), [
1643
+ he,
1644
+ _,
1645
+ E
1646
+ ], {
1647
+ enabled: !!(_ && E),
1648
+ subject: `record ${E}`
1649
+ }), L = N?.collections.find((e) => e.collection === _), R = _e?.request === ge && _e.collection === _ ? _e : void 0, Ce = de?.collections.find((e) => e.collection === _)?.actions || [], we = (e) => {
1650
+ let t = new URLSearchParams(f);
1651
+ t.set("collection", e), p(t), C(e), D(""), se([]), ae(void 0), re({});
1652
+ }, z = (e) => Ce.find((t) => t.operation === e), Te = async (e, t) => {
1653
+ await i.runAction(de.revision_id, e.name, t), le(null), M(`${e.name} committed.`), be(), e.operation === "delete" && D("");
1654
+ }, Ee = async (e) => {
1655
+ M("");
1656
+ try {
1657
+ await i.rebuildIndex(_, e), M(`Rebuilt the index on ${_}.${e}.`), pe();
1658
+ } catch (t) {
1659
+ M(o(t, `${_}.${e}`));
1660
+ }
1661
+ };
1662
+ if (P && !N) return /* @__PURE__ */ x($, {
1663
+ eyebrow: "Data",
1664
+ title: "Data",
1665
+ children: /* @__PURE__ */ x(K, { what: "application data" })
1666
+ });
1667
+ if (!N) {
1668
+ let e = !!(a || u || d);
1669
+ return /* @__PURE__ */ x($, {
1670
+ eyebrow: "Data",
1671
+ title: "Data",
1672
+ children: /* @__PURE__ */ S("section", {
1673
+ className: "studio-card",
1674
+ role: e ? "alert" : "status",
1675
+ children: [
1676
+ /* @__PURE__ */ x("span", {
1677
+ className: "card-kind",
1678
+ children: "Application data"
1679
+ }),
1680
+ /* @__PURE__ */ x("h2", { children: e ? "Data unavailable" : "No application connected" }),
1681
+ /* @__PURE__ */ x("p", { children: e ? "Studio could not read application data from the current FeltDB authority. Check that the development authority is running." : "Connect Studio to a FeltDB application to inspect its data." }),
1682
+ /* @__PURE__ */ x("button", {
1683
+ className: "btn btn-ghost",
1684
+ onClick: I,
1685
+ children: "Retry"
1686
+ })
1687
+ ]
1688
+ })
1689
+ });
1690
+ }
1691
+ return /* @__PURE__ */ x($, {
1692
+ eyebrow: "Data",
1693
+ title: "Data",
1694
+ description: "Records as FeltDB holds them, authorized and redacted by the Service API.",
1695
+ children: /* @__PURE__ */ S(G, {
1696
+ capability: "data.collections.list",
1697
+ children: [
1698
+ /* @__PURE__ */ x(q, { message: F }),
1699
+ ue && /* @__PURE__ */ x("p", {
1700
+ className: "cp-notice",
1701
+ children: ue
1702
+ }),
1703
+ /* @__PURE__ */ S("div", {
1704
+ className: "data-layout",
1705
+ children: [/* @__PURE__ */ S("aside", {
1706
+ className: "studio-card",
1707
+ children: [
1708
+ /* @__PURE__ */ x("span", {
1709
+ className: "card-kind",
1710
+ children: "Collections"
1711
+ }),
1712
+ (N?.collections || []).map((e) => {
1713
+ let t = fe?.declared.filter((t) => t.collection === e.collection).length || 0;
1714
+ return /* @__PURE__ */ S("button", {
1715
+ className: e.collection === _ ? "active" : "",
1716
+ onClick: () => we(e.collection),
1717
+ children: [e.collection, /* @__PURE__ */ S("small", { children: [
1718
+ e.fields.length,
1719
+ " fields · ",
1720
+ t,
1721
+ " indexes"
1722
+ ] })]
1723
+ }, e.collection);
1724
+ }),
1725
+ !N?.collections.length && /* @__PURE__ */ x(J, { children: "No collections in this contract." })
1726
+ ]
1727
+ }), /* @__PURE__ */ S("section", {
1728
+ className: "data-browser",
1729
+ children: [/* @__PURE__ */ S("header", { children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("span", {
1730
+ className: "card-kind",
1731
+ children: "collection"
1732
+ }), /* @__PURE__ */ x("h2", { children: _ || "Data" })] }), /* @__PURE__ */ S("div", {
1733
+ className: "cp-actions",
1734
+ children: [z("create") && l.usable("data.records.create") && /* @__PURE__ */ S("button", {
1735
+ className: "btn btn-primary",
1736
+ onClick: () => le({ action: z("create") }),
1737
+ children: ["New ", _]
1738
+ }), !z("create") && _ && /* @__PURE__ */ S("span", {
1739
+ className: "cp-muted",
1740
+ children: [
1741
+ "No declared create action for ",
1742
+ _,
1743
+ ", so nothing can create one."
1744
+ ]
1745
+ })]
1746
+ })] }), /* @__PURE__ */ S(ct, {
1747
+ label: `${_ || "Collection"} sections`,
1748
+ active: w,
1749
+ onSelect: T,
1750
+ tabs: [
1751
+ {
1752
+ id: "browse",
1753
+ label: "Browse"
1754
+ },
1755
+ {
1756
+ id: "schema",
1757
+ label: "Schema"
1758
+ },
1759
+ {
1760
+ id: "indexes",
1761
+ label: "Indexes"
1762
+ }
1763
+ ],
1764
+ children: [
1765
+ w === "schema" && L && /* @__PURE__ */ x(ht, { schema: L }),
1766
+ w === "indexes" && /* @__PURE__ */ x(G, {
1767
+ capability: "data.indexes.inspect",
1768
+ children: /* @__PURE__ */ x(gt, {
1769
+ collection: _,
1770
+ report: fe,
1771
+ onRebuild: (e) => void Ee(e)
1772
+ })
1773
+ }),
1774
+ w === "browse" && /* @__PURE__ */ S(G, {
1775
+ capability: "data.records.browse",
1776
+ children: [
1777
+ L && /* @__PURE__ */ x(tt, {
1778
+ label: `Filter ${_}`,
1779
+ idPrefix: "data-filter",
1780
+ filters: [{
1781
+ id: "field",
1782
+ label: "Field",
1783
+ type: "select",
1784
+ value: A,
1785
+ options: [{
1786
+ value: "",
1787
+ label: "Choose a field"
1788
+ }, ...L.fields.map((e) => {
1789
+ let t = fe?.access_paths.find((e) => e.collection === _)?.fields.find((t) => t.field === e.name)?.access_method;
1790
+ return {
1791
+ value: e.name,
1792
+ label: `${e.name}${t ? ` (${t === "index" ? "indexed" : "scan"})` : ""}`
1793
+ };
1794
+ })]
1795
+ }, {
1796
+ id: "value",
1797
+ label: "Equals",
1798
+ value: ee,
1799
+ placeholder: "Value"
1800
+ }],
1801
+ onChange: (e, t) => e === "field" ? j(t) : te(t),
1802
+ onSubmit: () => {
1803
+ se([]), ae(void 0), re(A && ee ? { [A]: ee } : {});
1804
+ },
1805
+ applied: Object.keys(ne).length,
1806
+ onClear: () => {
1807
+ se([]), ae(void 0), j(""), te(""), re({});
1808
+ },
1809
+ result: R && Object.keys(ne).length ? `${R.records.length} ${R.records.length === 1 ? "record matches" : "records match"}${R.pagination.nextCursor ? " on this page" : ""}` : ""
1810
+ }),
1811
+ l.status("data.records.sort") === "unsupported" && /* @__PURE__ */ S("p", {
1812
+ className: "cp-muted",
1813
+ children: ["Listed in record-key order. ", l.note("data.records.sort")]
1814
+ }),
1815
+ L && /* @__PURE__ */ x(et, {
1816
+ label: `${_} records`,
1817
+ loading: !ye && (ve || !R),
1818
+ loadingWhat: _,
1819
+ error: ye ? {
1820
+ message: ye,
1821
+ onRetry: be
1822
+ } : null,
1823
+ columns: [{
1824
+ id: "id",
1825
+ header: "id"
1826
+ }, ...L.fields.map((e) => ({
1827
+ id: `field:${e.name}`,
1828
+ header: /* @__PURE__ */ S(b, { children: [e.name, /* @__PURE__ */ x("small", { children: e.type })] })
1829
+ }))],
1830
+ rows: (R?.records || []).map((e) => ({
1831
+ key: String(e.id),
1832
+ selected: String(e.id) === E,
1833
+ onSelect: () => {
1834
+ D(String(e.id)), k("data");
1835
+ },
1836
+ attrs: { "data-record": String(e.id) },
1837
+ cells: {
1838
+ id: /* @__PURE__ */ x("code", { children: String(e.id) }),
1839
+ ...Object.fromEntries(L.fields.map((t) => [`field:${t.name}`, /* @__PURE__ */ x(ft, {
1840
+ field: t,
1841
+ value: e[t.name]
1842
+ })]))
1843
+ }
1844
+ })),
1845
+ noMatch: Object.keys(ne).length > 0,
1846
+ noMatchTitle: "No records match",
1847
+ noMatchBody: "Change or clear the filter.",
1848
+ emptyTitle: "No records yet"
1849
+ }),
1850
+ /* @__PURE__ */ x(nt, {
1851
+ label: `${_} pages`,
1852
+ summary: R ? `${R.records.length} shown · state version ${R.state_version}` : void 0,
1853
+ hasPrevious: oe.length > 0,
1854
+ hasNext: !!R?.pagination.nextCursor,
1855
+ onPrevious: () => {
1856
+ let e = oe.at(-1);
1857
+ se((e) => e.slice(0, -1)), ae(e);
1858
+ },
1859
+ onNext: () => {
1860
+ se((e) => [...e, ie]), ae(R.pagination.nextCursor);
1861
+ }
1862
+ })
1863
+ ]
1864
+ })
1865
+ ]
1866
+ })]
1867
+ })]
1868
+ }),
1869
+ ce && L && /* @__PURE__ */ x(pt, {
1870
+ action: ce.action,
1871
+ fields: L.fields,
1872
+ initial: ce.initial,
1873
+ onCancel: () => le(null),
1874
+ onSubmit: (e) => Te(ce.action, e)
1875
+ }),
1876
+ E && l.usable("data.records.inspect") && /* @__PURE__ */ S("section", {
1877
+ className: "cp-detail studio-card",
1878
+ children: [
1879
+ /* @__PURE__ */ S("header", {
1880
+ className: "cp-detail-header",
1881
+ children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("span", {
1882
+ className: "card-kind",
1883
+ children: "record"
1884
+ }), /* @__PURE__ */ S("h2", { children: [
1885
+ _,
1886
+ " / ",
1887
+ E
1888
+ ] })] }), /* @__PURE__ */ S("div", {
1889
+ className: "cp-actions",
1890
+ children: [
1891
+ z("update") && xe && l.usable("data.records.update") && /* @__PURE__ */ x("button", {
1892
+ className: "btn btn-ghost",
1893
+ onClick: () => le({
1894
+ action: z("update"),
1895
+ initial: xe.record
1896
+ }),
1897
+ children: "Edit"
1898
+ }),
1899
+ z("delete") && l.usable("data.records.delete") && /* @__PURE__ */ x("button", {
1900
+ className: "btn btn-ghost",
1901
+ onClick: () => le({
1902
+ action: z("delete"),
1903
+ initial: { id: E }
1904
+ }),
1905
+ children: "Delete"
1906
+ }),
1907
+ /* @__PURE__ */ x("button", {
1908
+ className: "data-close",
1909
+ onClick: () => D(""),
1910
+ "aria-label": "Close record",
1911
+ children: "×"
1912
+ })
1913
+ ]
1914
+ })]
1915
+ }),
1916
+ !z("update") && !z("delete") && /* @__PURE__ */ x("p", {
1917
+ className: "cp-muted",
1918
+ children: "This collection declares no update or delete action, so nothing — Studio, an application, or an agent — can change these records in place."
1919
+ }),
1920
+ /* @__PURE__ */ S(ct, {
1921
+ label: "Record sections",
1922
+ active: O,
1923
+ onSelect: k,
1924
+ tabs: [{
1925
+ id: "data",
1926
+ label: "Data"
1927
+ }, {
1928
+ id: "provenance",
1929
+ label: "Provenance"
1930
+ }],
1931
+ children: [
1932
+ /* @__PURE__ */ x(q, { message: Se }),
1933
+ O === "data" && xe && L && /* @__PURE__ */ S("dl", {
1934
+ className: "cp-record",
1935
+ children: [
1936
+ /* @__PURE__ */ x("dt", { children: "id" }),
1937
+ /* @__PURE__ */ x("dd", { children: /* @__PURE__ */ x("code", { children: String(xe.record.id) }) }),
1938
+ L.fields.map((e) => /* @__PURE__ */ S(c.Fragment, { children: [/* @__PURE__ */ S("dt", { children: [e.name, /* @__PURE__ */ S("small", { children: [e.type, e.required ? " · required" : ""] })] }), /* @__PURE__ */ x("dd", { children: /* @__PURE__ */ x(ft, {
1939
+ field: e,
1940
+ value: xe.record[e.name]
1941
+ }) })] }, e.name))
1942
+ ]
1943
+ }),
1944
+ O === "provenance" && /* @__PURE__ */ x(G, {
1945
+ capability: "provenance.record",
1946
+ children: /* @__PURE__ */ x(mt, {
1947
+ collection: _,
1948
+ id: E
1949
+ })
1950
+ })
1951
+ ]
1952
+ })
1953
+ ]
1954
+ })
1955
+ ]
1956
+ })
1957
+ });
1958
+ }
1959
+ //#endregion
1960
+ //#region src/control-plane/Schema.tsx
1961
+ function vt() {
1962
+ let { applicationId: t, environment: n, baseUrl: r, token: i } = V(), [a, o] = v("declared"), s = g(() => new e({
1963
+ baseUrl: r,
1964
+ token: i,
1965
+ applicationId: t,
1966
+ environment: n
1967
+ }), [
1968
+ r,
1969
+ i,
1970
+ t,
1971
+ n
1972
+ ]), { value: c, loading: l, error: u, refresh: d } = H(() => s.schema(), [s], {
1973
+ enabled: !!t,
1974
+ subject: "the application schema"
1975
+ }), { value: f } = H(() => s.application(), [s], {
1976
+ enabled: !!t,
1977
+ subject: "the application"
1978
+ }), { value: p } = H((e) => e.indexes(), [], {
1979
+ enabled: !!t,
1980
+ subject: "indexes"
1981
+ }), [m, h] = v({}), [_, y] = v(!1), [C, w] = v("");
1982
+ if (!t) return /* @__PURE__ */ x($, {
1983
+ eyebrow: "Contract",
1984
+ title: "Schema",
1985
+ children: /* @__PURE__ */ x(J, { children: "Open Studio from a FeltDB application environment to inspect its schema." })
1986
+ });
1987
+ let T = async () => {
1988
+ if (c) {
1989
+ y(!0), w("");
1990
+ try {
1991
+ let e = {};
1992
+ for (let t of c.collections) {
1993
+ let n = await s.records(t.collection, void 0, {}, 50), r = {};
1994
+ for (let e of n.records) for (let [t, n] of Object.entries(e)) {
1995
+ if (t === "_relationships") continue;
1996
+ let e = n === null ? "null" : Array.isArray(n) ? "array" : typeof n;
1997
+ (r[t] || (r[t] = /* @__PURE__ */ new Set())).add(e);
1998
+ }
1999
+ e[t.collection] = {
2000
+ sampled: n.records.length,
2001
+ fields: r
2002
+ };
2003
+ }
2004
+ h(e);
2005
+ } catch (e) {
2006
+ w(e instanceof Error ? e.message : "Unable to sample records.");
2007
+ } finally {
2008
+ y(!1);
2009
+ }
2010
+ }
2011
+ };
2012
+ return /* @__PURE__ */ x($, {
2013
+ eyebrow: "Contract",
2014
+ title: "Schema",
2015
+ description: f ? `${f.application_name || f.application_id} · contract v${f.version}` : void 0,
2016
+ children: /* @__PURE__ */ S(G, {
2017
+ capability: "data.schema.inspect",
2018
+ children: [
2019
+ /* @__PURE__ */ x(q, {
2020
+ message: u,
2021
+ onRetry: d
2022
+ }),
2023
+ l && !c && /* @__PURE__ */ x(K, { what: "the schema" }),
2024
+ f && /* @__PURE__ */ S("section", {
2025
+ className: "cp-stats",
2026
+ children: [
2027
+ /* @__PURE__ */ x(Y, {
2028
+ label: "Contract version",
2029
+ value: f.version
2030
+ }),
2031
+ /* @__PURE__ */ x(Y, {
2032
+ label: "Contract hash",
2033
+ value: f.contract_hash ? `${f.contract_hash.slice(0, 12)}…` : void 0
2034
+ }),
2035
+ /* @__PURE__ */ x(Y, {
2036
+ label: "Flow hash",
2037
+ value: f.flow_hash ? `${f.flow_hash.slice(0, 12)}…` : "not recorded"
2038
+ }),
2039
+ /* @__PURE__ */ x(Y, {
2040
+ label: "Collections",
2041
+ value: c?.collections.length
2042
+ })
2043
+ ]
2044
+ }),
2045
+ /* @__PURE__ */ S(ct, {
2046
+ label: "Schema views",
2047
+ active: a,
2048
+ onSelect: o,
2049
+ tabs: [{
2050
+ id: "declared",
2051
+ label: "Declared"
2052
+ }, {
2053
+ id: "observed",
2054
+ label: "Observed"
2055
+ }],
2056
+ children: [
2057
+ a === "declared" && (c?.collections || []).map((e) => {
2058
+ let t = p?.declared.filter((t) => t.collection === e.collection) || [];
2059
+ return /* @__PURE__ */ S("section", {
2060
+ className: "studio-card",
2061
+ children: [
2062
+ /* @__PURE__ */ x("span", {
2063
+ className: "card-kind",
2064
+ children: "collection"
2065
+ }),
2066
+ /* @__PURE__ */ x("h3", { children: e.collection }),
2067
+ /* @__PURE__ */ x("div", {
2068
+ className: "table-shell",
2069
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
2070
+ /* @__PURE__ */ x("th", { children: "Field" }),
2071
+ /* @__PURE__ */ x("th", { children: "Type" }),
2072
+ /* @__PURE__ */ x("th", { children: "Required" }),
2073
+ /* @__PURE__ */ x("th", { children: "Reference" }),
2074
+ /* @__PURE__ */ x("th", { children: "Indexed" })
2075
+ ] }) }), /* @__PURE__ */ x("tbody", { children: e.fields.map((t) => {
2076
+ let n = p?.access_paths.find((t) => t.collection === e.collection)?.fields.find((e) => e.field === t.name)?.access_method;
2077
+ return /* @__PURE__ */ S("tr", { children: [
2078
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("code", { children: t.name }) }),
2079
+ /* @__PURE__ */ x("td", { children: t.type }),
2080
+ /* @__PURE__ */ x("td", { children: t.required ? "required" : "optional" }),
2081
+ /* @__PURE__ */ x("td", { children: t.reference ? /* @__PURE__ */ S("span", {
2082
+ className: "reference-value",
2083
+ children: ["→ ", t.reference]
2084
+ }) : /* @__PURE__ */ x("span", {
2085
+ className: "cp-muted",
2086
+ children: "—"
2087
+ }) }),
2088
+ /* @__PURE__ */ x("td", { children: n ? /* @__PURE__ */ x(U, { status: n === "index" ? "available" : "partial" }) : /* @__PURE__ */ x("span", {
2089
+ className: "cp-muted",
2090
+ children: "—"
2091
+ }) })
2092
+ ] }, t.name);
2093
+ }) })] })
2094
+ }),
2095
+ t.length > 0 && /* @__PURE__ */ S("p", {
2096
+ className: "cp-muted",
2097
+ children: ["Indexes: ", t.map((e) => `${e.name} (${e.fields.map((e) => e.field).join(", ")}${e.unique ? ", unique" : ""}) · ${e.state}`).join(" · ")]
2098
+ }),
2099
+ e.relationships.length > 0 && /* @__PURE__ */ S("p", {
2100
+ className: "cp-muted",
2101
+ children: ["Relationships: ", e.relationships.map((e) => `${e.name} → ${e.target_collection} (${e.cardinality})`).join(" · ")]
2102
+ })
2103
+ ]
2104
+ }, e.collection);
2105
+ }),
2106
+ a === "observed" && /* @__PURE__ */ S(b, { children: [
2107
+ /* @__PURE__ */ x("p", {
2108
+ className: "cp-muted",
2109
+ children: "What the data actually holds, from one page of records per collection. This is a sample of the current data, not the contract and not a survey of the whole collection."
2110
+ }),
2111
+ /* @__PURE__ */ x("div", {
2112
+ className: "cp-actions",
2113
+ children: /* @__PURE__ */ x("button", {
2114
+ className: "btn btn-ghost",
2115
+ disabled: _,
2116
+ onClick: () => void T(),
2117
+ children: _ ? "Sampling…" : "Sample records"
2118
+ })
2119
+ }),
2120
+ /* @__PURE__ */ x(q, { message: C }),
2121
+ Object.keys(m).length === 0 ? /* @__PURE__ */ x(J, { children: "No sample taken yet." }) : Object.entries(m).map(([e, t]) => {
2122
+ let n = new Set((c?.collections.find((t) => t.collection === e)?.fields || []).map((e) => e.name));
2123
+ return /* @__PURE__ */ S("section", {
2124
+ className: "studio-card",
2125
+ children: [
2126
+ /* @__PURE__ */ x("span", {
2127
+ className: "card-kind",
2128
+ children: "observed"
2129
+ }),
2130
+ /* @__PURE__ */ S("h3", { children: [
2131
+ e,
2132
+ " ",
2133
+ /* @__PURE__ */ S("small", { children: [t.sampled, " records sampled"] })
2134
+ ] }),
2135
+ Object.keys(t.fields).length === 0 ? /* @__PURE__ */ x(J, { children: "No records to observe." }) : /* @__PURE__ */ x("div", {
2136
+ className: "table-shell",
2137
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
2138
+ /* @__PURE__ */ x("th", { children: "Field" }),
2139
+ /* @__PURE__ */ x("th", { children: "Observed types" }),
2140
+ /* @__PURE__ */ x("th", { children: "Declared" })
2141
+ ] }) }), /* @__PURE__ */ x("tbody", { children: Object.entries(t.fields).map(([e, t]) => /* @__PURE__ */ S("tr", { children: [
2142
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("code", { children: e }) }),
2143
+ /* @__PURE__ */ x("td", { children: [...t].join(", ") }),
2144
+ /* @__PURE__ */ x("td", { children: e === "id" || n.has(e) ? "declared" : /* @__PURE__ */ x(U, { status: "partial" }) })
2145
+ ] }, e)) })] })
2146
+ })
2147
+ ]
2148
+ }, e);
2149
+ })
2150
+ ] }),
2151
+ a === "declared" && c && /* @__PURE__ */ S("details", {
2152
+ className: "cp-raw",
2153
+ children: [/* @__PURE__ */ x("summary", { children: "Raw contract schema" }), /* @__PURE__ */ x(X, { value: c })]
2154
+ })
2155
+ ]
2156
+ })
2157
+ ]
2158
+ })
2159
+ });
2160
+ }
2161
+ //#endregion
2162
+ //#region src/control-plane/Agents.tsx
2163
+ function yt({ agent: e, onOpenRecord: t }) {
2164
+ let n = e.did.transactions;
2165
+ return n.length ? /* @__PURE__ */ x("div", {
2166
+ className: "table-shell",
2167
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
2168
+ /* @__PURE__ */ x("th", { children: "When" }),
2169
+ /* @__PURE__ */ x("th", { children: "Transaction" }),
2170
+ /* @__PURE__ */ x("th", { children: "Records" }),
2171
+ /* @__PURE__ */ x("th", { children: "Revision" }),
2172
+ /* @__PURE__ */ x("th", { children: "Touched" })
2173
+ ] }) }), /* @__PURE__ */ x("tbody", { children: n.map((e) => /* @__PURE__ */ S("tr", { children: [
2174
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Z, { ms: e.unix_ms }) }),
2175
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Q, {
2176
+ value: e.transaction_id,
2177
+ length: 16
2178
+ }) }),
2179
+ /* @__PURE__ */ x("td", { children: e.operations.toLocaleString() }),
2180
+ /* @__PURE__ */ S("td", { children: [
2181
+ e.base_revision,
2182
+ " → ",
2183
+ e.commit_revision
2184
+ ] }),
2185
+ /* @__PURE__ */ S("td", {
2186
+ className: "cp-keys",
2187
+ children: [e.keys.map((e) => {
2188
+ let n = e.split(":"), r = n.pop(), i = n.pop() || "";
2189
+ return /* @__PURE__ */ S("button", {
2190
+ className: "reference-value",
2191
+ onClick: () => t(i, r),
2192
+ children: [
2193
+ i,
2194
+ "/",
2195
+ r
2196
+ ]
2197
+ }, e);
2198
+ }), e.keys.length < e.operations && /* @__PURE__ */ S("span", {
2199
+ className: "cp-muted",
2200
+ children: [
2201
+ " +",
2202
+ e.operations - e.keys.length,
2203
+ " more"
2204
+ ]
2205
+ })]
2206
+ })
2207
+ ] }, e.transaction_id)) })] })
2208
+ }) : /* @__PURE__ */ x(J, { children: "This agent has made no commit inside the instance's attribution window. That is not proof it has never written — it means nothing it wrote is still in the window." });
2209
+ }
2210
+ function bt({ agent: e }) {
2211
+ return /* @__PURE__ */ S(b, { children: [
2212
+ /* @__PURE__ */ x("p", {
2213
+ className: "cp-muted",
2214
+ children: "Computed from the capabilities this principal holds and the actions the application contract declares — not from what the agent has done or what it is called."
2215
+ }),
2216
+ /* @__PURE__ */ x("p", {
2217
+ className: "cp-capabilities",
2218
+ children: e.access.capabilities.length ? e.access.capabilities.map((e) => /* @__PURE__ */ x("code", { children: e }, e)) : /* @__PURE__ */ x("span", {
2219
+ className: "cp-muted",
2220
+ children: "No capabilities granted. This agent can do nothing."
2221
+ })
2222
+ }),
2223
+ /* @__PURE__ */ x("div", {
2224
+ className: "table-shell",
2225
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
2226
+ /* @__PURE__ */ x("th", { children: "Collection" }),
2227
+ /* @__PURE__ */ x("th", { children: "Read policy" }),
2228
+ /* @__PURE__ */ x("th", { children: "Write actions" })
2229
+ ] }) }), /* @__PURE__ */ x("tbody", { children: e.access.collections.map((e) => /* @__PURE__ */ S("tr", { children: [
2230
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("strong", { children: e.collection }) }),
2231
+ /* @__PURE__ */ x("td", { children: e.read.policy || /* @__PURE__ */ x("span", {
2232
+ className: "cp-muted",
2233
+ children: "no declared policy"
2234
+ }) }),
2235
+ /* @__PURE__ */ x("td", { children: e.write.actions.length === 0 ? /* @__PURE__ */ x("span", {
2236
+ className: "cp-muted",
2237
+ children: "The contract declares no write action for this collection, so nothing can write it."
2238
+ }) : e.write.actions.map((e) => /* @__PURE__ */ S("span", {
2239
+ className: e.permitted ? "cp-grant granted" : "cp-grant denied",
2240
+ children: [
2241
+ e.operation,
2242
+ " · ",
2243
+ e.name,
2244
+ e.required_capabilities.length > 0 && /* @__PURE__ */ S("small", { children: [" needs ", e.required_capabilities.join(", ")] })
2245
+ ]
2246
+ }, e.name)) })
2247
+ ] }, e.collection)) })] })
2248
+ })
2249
+ ] });
2250
+ }
2251
+ function xt({ agent: e }) {
2252
+ let { capabilities: t } = V();
2253
+ return /* @__PURE__ */ S(b, { children: [
2254
+ /* @__PURE__ */ x("h3", { children: "Sessions" }),
2255
+ e.doing.sessions.length === 0 ? /* @__PURE__ */ x(J, { children: "No session has been opened for this agent." }) : /* @__PURE__ */ x("div", {
2256
+ className: "table-shell",
2257
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
2258
+ /* @__PURE__ */ x("th", { children: "Session" }),
2259
+ /* @__PURE__ */ x("th", { children: "Status" }),
2260
+ /* @__PURE__ */ x("th", { children: "Worker" }),
2261
+ /* @__PURE__ */ x("th", { children: "Started" }),
2262
+ /* @__PURE__ */ x("th", { children: "Capabilities" })
2263
+ ] }) }), /* @__PURE__ */ x("tbody", { children: e.doing.sessions.map((e) => /* @__PURE__ */ S("tr", { children: [
2264
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Q, {
2265
+ value: e.session_id,
2266
+ length: 18
2267
+ }) }),
2268
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(U, { status: String(e.status) }) }),
2269
+ /* @__PURE__ */ x("td", { children: e.worker_id ? /* @__PURE__ */ x(Q, { value: e.worker_id }) : /* @__PURE__ */ x("span", {
2270
+ className: "cp-muted",
2271
+ children: "unassigned"
2272
+ }) }),
2273
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Z, { ms: e.started_at ? e.started_at * 1e3 : null }) }),
2274
+ /* @__PURE__ */ x("td", { children: e.capabilities.length })
2275
+ ] }, e.session_id)) })] })
2276
+ }),
2277
+ /* @__PURE__ */ x("h3", { children: "Durable work" }),
2278
+ t.usable("agents.work") ? /* @__PURE__ */ x(ot, { capability: "agents.task_context" }) : /* @__PURE__ */ x(W, { capability: "agents.work" }),
2279
+ e.doing.work.length === 0 ? /* @__PURE__ */ x(J, { children: "No durable workload names this agent." }) : /* @__PURE__ */ x("div", {
2280
+ className: "table-shell",
2281
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
2282
+ /* @__PURE__ */ x("th", { children: "Workload" }),
2283
+ /* @__PURE__ */ x("th", { children: "Definition" }),
2284
+ /* @__PURE__ */ x("th", { children: "State" }),
2285
+ /* @__PURE__ */ x("th", { children: "Attempts" }),
2286
+ /* @__PURE__ */ x("th", { children: "Last failure" })
2287
+ ] }) }), /* @__PURE__ */ x("tbody", { children: e.doing.work.map((e) => /* @__PURE__ */ S("tr", { children: [
2288
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Q, {
2289
+ value: String(e.workload_id),
2290
+ length: 18
2291
+ }) }),
2292
+ /* @__PURE__ */ x("td", { children: String(e.definition_id) }),
2293
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(U, { status: String(e.state) }) }),
2294
+ /* @__PURE__ */ x("td", { children: String(e.attempts) }),
2295
+ /* @__PURE__ */ x("td", { children: e.last_failure ? String(e.last_failure) : /* @__PURE__ */ x("span", {
2296
+ className: "cp-muted",
2297
+ children: "—"
2298
+ }) })
2299
+ ] }, String(e.workload_id))) })] })
2300
+ }),
2301
+ /* @__PURE__ */ x("h3", { children: "Working with this agent" }),
2302
+ /* @__PURE__ */ x(W, {
2303
+ capability: "agents.work.review_gate",
2304
+ title: "Reviewing an agent's changes before they apply"
2305
+ })
2306
+ ] });
2307
+ }
2308
+ function St({ agentId: e, onBack: t, onOpenRecord: n }) {
2309
+ let [r, i] = v("access"), { capabilities: a } = V(), { value: o, loading: s, error: c, refresh: l } = H((t) => t.agent(e), [e], {
2310
+ refreshMs: 15e3,
2311
+ subject: "this agent"
2312
+ });
2313
+ return s && !o ? /* @__PURE__ */ x(K, { what: "the agent" }) : o ? /* @__PURE__ */ x(G, {
2314
+ capability: "agents.identity",
2315
+ children: /* @__PURE__ */ S("section", {
2316
+ className: "cp-detail studio-card",
2317
+ children: [
2318
+ /* @__PURE__ */ S("header", {
2319
+ className: "cp-detail-header",
2320
+ children: [/* @__PURE__ */ S("div", { children: [
2321
+ /* @__PURE__ */ x("span", {
2322
+ className: "card-kind",
2323
+ children: "agent"
2324
+ }),
2325
+ /* @__PURE__ */ x("h2", { children: o.identity.name }),
2326
+ /* @__PURE__ */ S("p", {
2327
+ className: "cp-muted",
2328
+ children: [
2329
+ /* @__PURE__ */ x(Q, {
2330
+ value: o.identity.agent_id,
2331
+ length: 24
2332
+ }),
2333
+ " · ",
2334
+ /* @__PURE__ */ x(U, { status: String(o.identity.status) }),
2335
+ " ·",
2336
+ " ",
2337
+ "registered by ",
2338
+ o.identity.created_by,
2339
+ " ",
2340
+ /* @__PURE__ */ x(Z, { ms: o.identity.created_at * 1e3 })
2341
+ ]
2342
+ }),
2343
+ /* @__PURE__ */ S("p", {
2344
+ className: "cp-muted",
2345
+ children: [
2346
+ "Application ",
2347
+ /* @__PURE__ */ x("code", { children: o.identity.application_id }),
2348
+ " · environment ",
2349
+ /* @__PURE__ */ x("code", { children: o.identity.environment }),
2350
+ " ·",
2351
+ " ",
2352
+ "contract ",
2353
+ /* @__PURE__ */ x(Q, { value: o.identity.application_revision })
2354
+ ]
2355
+ })
2356
+ ] }), /* @__PURE__ */ x("button", {
2357
+ className: "btn btn-ghost",
2358
+ onClick: t,
2359
+ children: "← All agents"
2360
+ })]
2361
+ }),
2362
+ /* @__PURE__ */ S("div", {
2363
+ className: "cp-stats",
2364
+ children: [
2365
+ /* @__PURE__ */ x(Y, {
2366
+ label: "Recent commits",
2367
+ value: o.did.transactions.length
2368
+ }),
2369
+ /* @__PURE__ */ x(Y, {
2370
+ label: "Records changed",
2371
+ value: o.did.records_changed
2372
+ }),
2373
+ /* @__PURE__ */ x(Y, {
2374
+ label: "Sessions",
2375
+ value: o.doing.sessions.length
2376
+ }),
2377
+ /* @__PURE__ */ x(Y, {
2378
+ label: "Last activity",
2379
+ value: o.did.last_activity_ms ? new Date(o.did.last_activity_ms).toLocaleString() : void 0
2380
+ })
2381
+ ]
2382
+ }),
2383
+ /* @__PURE__ */ S(ct, {
2384
+ label: "Agent sections",
2385
+ active: r,
2386
+ onSelect: i,
2387
+ tabs: [
2388
+ {
2389
+ id: "access",
2390
+ label: "What it can access"
2391
+ },
2392
+ {
2393
+ id: "did",
2394
+ label: "What it has done"
2395
+ },
2396
+ {
2397
+ id: "doing",
2398
+ label: "What it is doing"
2399
+ },
2400
+ {
2401
+ id: "decisions",
2402
+ label: "Authorization"
2403
+ }
2404
+ ],
2405
+ children: [
2406
+ r === "access" && /* @__PURE__ */ x(bt, { agent: o }),
2407
+ r === "did" && /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(ot, { capability: "provenance.transactions" }), /* @__PURE__ */ x(yt, {
2408
+ agent: o,
2409
+ onOpenRecord: n
2410
+ })] }),
2411
+ r === "doing" && /* @__PURE__ */ x(G, {
2412
+ capability: "agents.sessions",
2413
+ children: /* @__PURE__ */ x(xt, { agent: o })
2414
+ }),
2415
+ r === "decisions" && (a.usable("agents.authorization_decisions") ? o.authorization_decisions.length === 0 ? /* @__PURE__ */ x(J, { children: "No authorization decision has been recorded for this agent." }) : /* @__PURE__ */ x("div", {
2416
+ className: "table-shell",
2417
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
2418
+ /* @__PURE__ */ x("th", { children: "When" }),
2419
+ /* @__PURE__ */ x("th", { children: "Event" }),
2420
+ /* @__PURE__ */ x("th", { children: "Actor" }),
2421
+ /* @__PURE__ */ x("th", { children: "Capability" }),
2422
+ /* @__PURE__ */ x("th", { children: "Decision" })
2423
+ ] }) }), /* @__PURE__ */ x("tbody", { children: o.authorization_decisions.map((e, t) => /* @__PURE__ */ S("tr", { children: [
2424
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Z, { ms: e.at * 1e3 }) }),
2425
+ /* @__PURE__ */ x("td", { children: e.event }),
2426
+ /* @__PURE__ */ x("td", { children: e.actor }),
2427
+ /* @__PURE__ */ x("td", { children: e.capability ? /* @__PURE__ */ x("code", { children: e.capability }) : /* @__PURE__ */ x("span", {
2428
+ className: "cp-muted",
2429
+ children: "—"
2430
+ }) }),
2431
+ /* @__PURE__ */ x("td", { children: e.decision === null ? /* @__PURE__ */ x("span", {
2432
+ className: "cp-muted",
2433
+ children: "—"
2434
+ }) : /* @__PURE__ */ x(U, { status: e.decision ? "available" : "unsupported" }) })
2435
+ ] }, `${e.event}-${e.at}-${t}`)) })] })
2436
+ }) : /* @__PURE__ */ x(W, { capability: "agents.authorization_decisions" }))
2437
+ ]
2438
+ })
2439
+ ]
2440
+ })
2441
+ }) : /* @__PURE__ */ x(q, {
2442
+ message: c,
2443
+ onRetry: l
2444
+ });
2445
+ }
2446
+ function Ct({ onConnected: e }) {
2447
+ let { api: t, capabilities: n } = V(), [r, i] = v(""), [a, s] = v([]), [c, l] = v(!1), [u, d] = v(""), [f, p] = v(null), m = [
2448
+ "state:read",
2449
+ "state:write",
2450
+ "events:read",
2451
+ "workloads:execute",
2452
+ "applications:read"
2453
+ ];
2454
+ if (!n.usable("agents.register")) return /* @__PURE__ */ x(W, { capability: "agents.register" });
2455
+ let h = async () => {
2456
+ l(!0), d("");
2457
+ try {
2458
+ let n = await t.registerAgent(r.trim());
2459
+ for (let e of a) await t.grantAgentCapability(n.id, e);
2460
+ p({
2461
+ id: n.id,
2462
+ name: n.name
2463
+ }), i(""), s([]), e();
2464
+ } catch (e) {
2465
+ d(o(e, "agent registration"));
2466
+ } finally {
2467
+ l(!1);
2468
+ }
2469
+ };
2470
+ return /* @__PURE__ */ S("section", {
2471
+ className: "studio-card cp-connect",
2472
+ children: [
2473
+ /* @__PURE__ */ x("span", {
2474
+ className: "card-kind",
2475
+ children: "Connect an agent"
2476
+ }),
2477
+ /* @__PURE__ */ x("p", {
2478
+ className: "cp-muted",
2479
+ children: "Registers an agent principal against this application and grants it capabilities. The agent then operates through the application's declared actions — the same interface an application uses — and everything it writes is attributable here."
2480
+ }),
2481
+ /* @__PURE__ */ S("label", { children: ["Agent name", /* @__PURE__ */ x("input", {
2482
+ value: r,
2483
+ onChange: (e) => i(e.target.value),
2484
+ placeholder: "Customer Operations Agent"
2485
+ })] }),
2486
+ /* @__PURE__ */ S("fieldset", { children: [/* @__PURE__ */ x("legend", { children: "Capabilities" }), m.map((e) => /* @__PURE__ */ S("label", {
2487
+ className: "cp-check",
2488
+ children: [/* @__PURE__ */ x("input", {
2489
+ type: "checkbox",
2490
+ checked: a.includes(e),
2491
+ onChange: (t) => s((n) => t.target.checked ? [...n, e] : n.filter((t) => t !== e))
2492
+ }), /* @__PURE__ */ x("code", { children: e })]
2493
+ }, e))] }),
2494
+ /* @__PURE__ */ x(q, { message: u }),
2495
+ /* @__PURE__ */ x("div", {
2496
+ className: "cp-actions",
2497
+ children: /* @__PURE__ */ x("button", {
2498
+ className: "btn btn-primary",
2499
+ disabled: c || !r.trim(),
2500
+ onClick: () => void h(),
2501
+ children: c ? "Connecting…" : "Connect agent"
2502
+ })
2503
+ }),
2504
+ f && /* @__PURE__ */ S("div", {
2505
+ className: "cp-connected",
2506
+ children: [/* @__PURE__ */ S("p", { children: [
2507
+ /* @__PURE__ */ x("strong", { children: f.name }),
2508
+ " is registered as ",
2509
+ /* @__PURE__ */ x("code", { children: f.id }),
2510
+ "."
2511
+ ] }), /* @__PURE__ */ x("p", {
2512
+ className: "cp-muted",
2513
+ children: "Give the agent this identity and an API key with the capabilities above. Connection details for the endpoint itself are under Developer."
2514
+ })]
2515
+ })
2516
+ ]
2517
+ });
2518
+ }
2519
+ function wt({ onOpenRecord: e }) {
2520
+ let { applicationId: t } = V(), [n, r] = v(""), { value: i, loading: a, error: o, refresh: s } = H((e) => e.agents(), [], {
2521
+ enabled: !!t,
2522
+ refreshMs: 2e4,
2523
+ subject: "agents"
2524
+ });
2525
+ return t ? /* @__PURE__ */ x($, {
2526
+ eyebrow: "Agents",
2527
+ title: "Agents",
2528
+ description: "What each agent may do, what it has done, and what it is doing — read from the same durable state every other writer produces.",
2529
+ children: /* @__PURE__ */ S(G, {
2530
+ capability: "agents.list",
2531
+ children: [/* @__PURE__ */ x(q, {
2532
+ message: o,
2533
+ onRetry: s
2534
+ }), n ? /* @__PURE__ */ x(St, {
2535
+ agentId: n,
2536
+ onBack: () => r(""),
2537
+ onOpenRecord: e
2538
+ }) : /* @__PURE__ */ S(b, { children: [
2539
+ a && !i && /* @__PURE__ */ x(K, { what: "agents" }),
2540
+ i && (i.agents.length === 0 ? /* @__PURE__ */ x(J, { children: "No agent is registered against this application yet." }) : /* @__PURE__ */ x("div", {
2541
+ className: "cp-cards",
2542
+ children: i.agents.map((e) => /* @__PURE__ */ S("button", {
2543
+ className: "studio-card cp-agent-card",
2544
+ onClick: () => r(e.agent_id),
2545
+ children: [
2546
+ /* @__PURE__ */ x("span", {
2547
+ className: "card-kind",
2548
+ children: "agent"
2549
+ }),
2550
+ /* @__PURE__ */ x("h3", { children: e.name }),
2551
+ /* @__PURE__ */ S("p", {
2552
+ className: "cp-muted",
2553
+ children: [
2554
+ /* @__PURE__ */ x(Q, {
2555
+ value: e.agent_id,
2556
+ length: 20
2557
+ }),
2558
+ " · ",
2559
+ /* @__PURE__ */ x(U, { status: String(e.status) })
2560
+ ]
2561
+ }),
2562
+ /* @__PURE__ */ S("div", {
2563
+ className: "cp-stats",
2564
+ children: [
2565
+ /* @__PURE__ */ x(Y, {
2566
+ label: "Sessions running",
2567
+ value: e.sessions.running
2568
+ }),
2569
+ /* @__PURE__ */ x(Y, {
2570
+ label: "Recent commits",
2571
+ value: e.activity.recent_transactions
2572
+ }),
2573
+ /* @__PURE__ */ x(Y, {
2574
+ label: "Records changed",
2575
+ value: e.activity.records_changed
2576
+ })
2577
+ ]
2578
+ }),
2579
+ /* @__PURE__ */ x("p", {
2580
+ className: "cp-capabilities",
2581
+ children: e.capabilities.length ? e.capabilities.map((e) => /* @__PURE__ */ x("code", { children: e }, e)) : /* @__PURE__ */ x("span", {
2582
+ className: "cp-muted",
2583
+ children: "no capabilities granted"
2584
+ })
2585
+ }),
2586
+ /* @__PURE__ */ S("p", {
2587
+ className: "cp-muted",
2588
+ children: ["Last activity ", /* @__PURE__ */ x(Z, { ms: e.activity.last_activity_ms })]
2589
+ })
2590
+ ]
2591
+ }, e.agent_id))
2592
+ })),
2593
+ /* @__PURE__ */ x(Ct, { onConnected: s })
2594
+ ] })]
2595
+ })
2596
+ }) : /* @__PURE__ */ x($, {
2597
+ eyebrow: "Agents",
2598
+ title: "Agents",
2599
+ children: /* @__PURE__ */ x(J, { children: "Agents are registered against an application. Open Studio from a FeltDB application environment to see them." })
2600
+ });
2601
+ }
2602
+ //#endregion
2603
+ //#region src/control-plane/State.tsx
2604
+ function Tt() {
2605
+ let { value: e, loading: t, refresh: n } = H((e) => e.overview().then((e) => e.authority_state), [], {
2606
+ refreshMs: 1e4,
2607
+ subject: "the authority state summary"
2608
+ });
2609
+ return t && !e ? /* @__PURE__ */ x("section", {
2610
+ className: "studio-card",
2611
+ children: /* @__PURE__ */ x(K, { what: "state" })
2612
+ }) : e ? /* @__PURE__ */ S("section", {
2613
+ className: "studio-card",
2614
+ "aria-label": "Authority state summary",
2615
+ children: [
2616
+ /* @__PURE__ */ x("span", {
2617
+ className: "card-kind",
2618
+ children: "Authority state"
2619
+ }),
2620
+ /* @__PURE__ */ S("div", {
2621
+ className: "cp-stats",
2622
+ children: [
2623
+ /* @__PURE__ */ x(Y, {
2624
+ label: "Current sequence",
2625
+ value: e.current_sequence
2626
+ }),
2627
+ /* @__PURE__ */ x(Y, {
2628
+ label: "Records",
2629
+ value: e.records
2630
+ }),
2631
+ /* @__PURE__ */ x(Y, {
2632
+ label: "Events",
2633
+ value: e.events
2634
+ }),
2635
+ /* @__PURE__ */ x(Y, {
2636
+ label: "Collections with state",
2637
+ value: e.collections.length
2638
+ })
2639
+ ]
2640
+ }),
2641
+ e.collections.length > 0 && /* @__PURE__ */ x("div", {
2642
+ className: "table-shell",
2643
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [/* @__PURE__ */ x("th", { children: "Collection with state" }), /* @__PURE__ */ x("th", { children: "Records" })] }) }), /* @__PURE__ */ x("tbody", { children: e.collections.map((e) => /* @__PURE__ */ S("tr", { children: [/* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("code", { children: e.collection }) }), /* @__PURE__ */ x("td", { children: e.records.toLocaleString() })] }, e.collection)) })] })
2644
+ })
2645
+ ]
2646
+ }) : /* @__PURE__ */ S("section", {
2647
+ className: "studio-card",
2648
+ role: "alert",
2649
+ children: [
2650
+ /* @__PURE__ */ x("span", {
2651
+ className: "card-kind",
2652
+ children: "Authority state"
2653
+ }),
2654
+ /* @__PURE__ */ x("h2", { children: "State unavailable" }),
2655
+ /* @__PURE__ */ x("p", { children: "Studio could not read the current FeltDB authority state. Check that the development authority is running." }),
2656
+ /* @__PURE__ */ x("button", {
2657
+ className: "btn btn-ghost",
2658
+ onClick: n,
2659
+ children: "Retry"
2660
+ })
2661
+ ]
2662
+ });
2663
+ }
2664
+ function Et({ revisions: e, selected: t, onToggle: n }) {
2665
+ return /* @__PURE__ */ x("div", {
2666
+ className: "table-shell",
2667
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
2668
+ /* @__PURE__ */ x("th", {}),
2669
+ /* @__PURE__ */ x("th", { children: "#" }),
2670
+ /* @__PURE__ */ x("th", { children: "State ID" }),
2671
+ /* @__PURE__ */ x("th", { children: "Parent" }),
2672
+ /* @__PURE__ */ x("th", { children: "Authority" }),
2673
+ /* @__PURE__ */ x("th", { children: "Committed" })
2674
+ ] }) }), /* @__PURE__ */ x("tbody", { children: e.map((e) => /* @__PURE__ */ S("tr", {
2675
+ className: t.includes(e.state_id) ? "selected" : "",
2676
+ children: [
2677
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("input", {
2678
+ type: "checkbox",
2679
+ "aria-label": `Select revision ${e.state_id}`,
2680
+ checked: t.includes(e.state_id),
2681
+ onChange: () => n(e.state_id)
2682
+ }) }),
2683
+ /* @__PURE__ */ x("td", { children: e.sequence }),
2684
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Q, {
2685
+ value: e.state_id,
2686
+ length: 16
2687
+ }) }),
2688
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Q, {
2689
+ value: e.parent_id,
2690
+ length: 16
2691
+ }) }),
2692
+ /* @__PURE__ */ x("td", { children: e.authority }),
2693
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Z, { ms: e.timestamp_ms }) })
2694
+ ]
2695
+ }, e.state_id)) })] })
2696
+ });
2697
+ }
2698
+ function Dt({ diff: e }) {
2699
+ return /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ S("p", {
2700
+ className: "cp-muted",
2701
+ children: [
2702
+ e.from.sequence,
2703
+ " → ",
2704
+ e.to.sequence,
2705
+ " · ",
2706
+ e.relationship === "parent" ? "one step in this resource’s history" : e.relationship === "same-resource" ? "two points in one resource’s history" : "two different resources"
2707
+ ]
2708
+ }), e.changes.length === 0 ? /* @__PURE__ */ x(J, { children: "These two revisions hold the same content." }) : /* @__PURE__ */ x("div", {
2709
+ className: "table-shell",
2710
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
2711
+ /* @__PURE__ */ x("th", { children: "Path" }),
2712
+ /* @__PURE__ */ x("th", { children: "Change" }),
2713
+ /* @__PURE__ */ x("th", { children: "From" }),
2714
+ /* @__PURE__ */ x("th", { children: "To" })
2715
+ ] }) }), /* @__PURE__ */ x("tbody", { children: e.changes.map((e) => /* @__PURE__ */ S("tr", { children: [
2716
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(st, { path: e.path }) }),
2717
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(U, { status: e.kind }) }),
2718
+ /* @__PURE__ */ x("td", {
2719
+ className: "cp-value-old",
2720
+ children: e.old_value === void 0 || e.old_value === null ? /* @__PURE__ */ x("span", {
2721
+ className: "cp-muted",
2722
+ children: "—"
2723
+ }) : /* @__PURE__ */ x("code", { children: JSON.stringify(e.old_value) })
2724
+ }),
2725
+ /* @__PURE__ */ x("td", {
2726
+ className: "cp-value-new",
2727
+ children: e.new_value === void 0 || e.new_value === null ? /* @__PURE__ */ x("span", {
2728
+ className: "cp-muted",
2729
+ children: "—"
2730
+ }) : /* @__PURE__ */ x("code", { children: JSON.stringify(e.new_value) })
2731
+ })
2732
+ ] }, s(e.path))) })] })
2733
+ })] });
2734
+ }
2735
+ function Ot({ classification: e }) {
2736
+ return /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ S("p", {
2737
+ className: "cp-attribution",
2738
+ children: [
2739
+ "Overall: ",
2740
+ /* @__PURE__ */ x(U, { status: e.overall }),
2741
+ e.overall === "independent" && " — both branches’ changes can be applied without either overwriting the other.",
2742
+ e.overall === "convergent" && " — the branches reached the same result.",
2743
+ e.overall === "conflict" && " — at least one path cannot take both branches. Reconciliation needs an explicit decision there."
2744
+ ]
2745
+ }), /* @__PURE__ */ x("div", {
2746
+ className: "table-shell",
2747
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
2748
+ /* @__PURE__ */ x("th", { children: "Path" }),
2749
+ /* @__PURE__ */ x("th", { children: "Class" }),
2750
+ /* @__PURE__ */ x("th", { children: "Base" }),
2751
+ /* @__PURE__ */ x("th", { children: "Left" }),
2752
+ /* @__PURE__ */ x("th", { children: "Right" })
2753
+ ] }) }), /* @__PURE__ */ x("tbody", { children: e.path_conflicts.map((e) => /* @__PURE__ */ S("tr", {
2754
+ className: e.classification === "conflict" ? "cp-row-conflict" : "",
2755
+ children: [
2756
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(st, { path: e.path }) }),
2757
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(U, { status: e.classification }) }),
2758
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("code", { children: JSON.stringify(e.base_value ?? null) }) }),
2759
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("code", { children: JSON.stringify(e.left_value ?? null) }) }),
2760
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("code", { children: JSON.stringify(e.right_value ?? null) }) })
2761
+ ]
2762
+ }, s(e.path))) })] })
2763
+ })] });
2764
+ }
2765
+ var kt = "Content matches revision id";
2766
+ function At({ revision: e }) {
2767
+ let t = le("feltdb.revision.integrity_verified", e.integrity_verified, [kt]);
2768
+ return /* @__PURE__ */ S("div", {
2769
+ className: "studio-card cp-committed",
2770
+ "data-committed-revision": String(e.state_id),
2771
+ children: [
2772
+ /* @__PURE__ */ x("span", {
2773
+ className: "card-kind",
2774
+ children: "Committed"
2775
+ }),
2776
+ /* @__PURE__ */ S("p", { children: [
2777
+ "Revision ",
2778
+ /* @__PURE__ */ x(Q, {
2779
+ value: String(e.state_id),
2780
+ length: 20
2781
+ }),
2782
+ " at sequence ",
2783
+ String(e.sequence),
2784
+ ", authored by ",
2785
+ /* @__PURE__ */ x("strong", { children: String(e.authority) }),
2786
+ ", parent ",
2787
+ /* @__PURE__ */ x(Q, { value: String(e.parent_id) }),
2788
+ "."
2789
+ ] }),
2790
+ /* @__PURE__ */ x(Ke, {
2791
+ state: t.state,
2792
+ checks: t.checks,
2793
+ attrs: { "data-integrity": t.state }
2794
+ })
2795
+ ]
2796
+ });
2797
+ }
2798
+ function jt({ base: e, left: t, right: n, onCommitted: r }) {
2799
+ let { api: i } = V(), [a, c] = v("left"), [l, u] = v([]), [d, f] = v(null), [p, m] = v(null), [h, g] = v(""), [_, y] = v(!1), b = () => ({
2800
+ base: e,
2801
+ left: t,
2802
+ right: n,
2803
+ parent_choice: a,
2804
+ overrides: l.filter((e) => e.value.trim() !== "").map((e) => {
2805
+ try {
2806
+ return {
2807
+ path: e.path,
2808
+ value: JSON.parse(e.value)
2809
+ };
2810
+ } catch {
2811
+ return {
2812
+ path: e.path,
2813
+ value: e.value
2814
+ };
2815
+ }
2816
+ })
2817
+ }), C = async () => {
2818
+ y(!0), g(""), m(null);
2819
+ try {
2820
+ let e = await i.reconciliationPlan(b());
2821
+ f(e), u((t) => {
2822
+ let n = new Set(t.map((e) => s(e.path)));
2823
+ return [...t, ...e.unresolved.filter((e) => !n.has(s(e))).map((e) => ({
2824
+ path: e,
2825
+ value: ""
2826
+ }))];
2827
+ });
2828
+ } catch (e) {
2829
+ f(null), g(o(e, "the reconciliation plan"));
2830
+ } finally {
2831
+ y(!1);
2832
+ }
2833
+ }, w = async () => {
2834
+ y(!0), g("");
2835
+ try {
2836
+ let e = await i.reconciliationExecute(b());
2837
+ m(e.revision), r();
2838
+ } catch (e) {
2839
+ g(o(e, "the reconciliation"));
2840
+ } finally {
2841
+ y(!1);
2842
+ }
2843
+ };
2844
+ return /* @__PURE__ */ S("section", {
2845
+ className: "cp-reconcile",
2846
+ children: [
2847
+ /* @__PURE__ */ x("p", {
2848
+ className: "cp-muted",
2849
+ children: "Reconciliation is an explicit decision, never an automatic merge. Choose which branch the result starts from, decide any path the branches genuinely conflict on, and preview the exact state before committing it. The committed result is a new revision of the resource — it adds to history rather than rewriting it."
2850
+ }),
2851
+ /* @__PURE__ */ x("div", {
2852
+ className: "cp-parent-choice",
2853
+ role: "radiogroup",
2854
+ "aria-label": "Parent branch",
2855
+ children: ["left", "right"].map((e) => /* @__PURE__ */ S("label", {
2856
+ className: "cp-check",
2857
+ children: [
2858
+ /* @__PURE__ */ x("input", {
2859
+ type: "radio",
2860
+ name: "parent",
2861
+ checked: a === e,
2862
+ onChange: () => c(e)
2863
+ }),
2864
+ "Start from ",
2865
+ /* @__PURE__ */ x("strong", { children: e }),
2866
+ " ",
2867
+ /* @__PURE__ */ x(Q, { value: e === "left" ? t : n })
2868
+ ]
2869
+ }, e))
2870
+ }),
2871
+ l.length > 0 && /* @__PURE__ */ S("div", {
2872
+ className: "cp-overrides",
2873
+ children: [/* @__PURE__ */ x("h4", { children: "Decided paths" }), l.map((e, t) => /* @__PURE__ */ S("label", { children: [/* @__PURE__ */ x(st, { path: e.path }), /* @__PURE__ */ x("input", {
2874
+ value: e.value,
2875
+ placeholder: "JSON value",
2876
+ onChange: (e) => u((n) => n.map((n, r) => r === t ? {
2877
+ ...n,
2878
+ value: e.target.value
2879
+ } : n))
2880
+ })] }, s(e.path)))]
2881
+ }),
2882
+ /* @__PURE__ */ x(q, { message: h }),
2883
+ /* @__PURE__ */ S("div", {
2884
+ className: "cp-actions",
2885
+ children: [/* @__PURE__ */ x("button", {
2886
+ className: "btn btn-ghost",
2887
+ disabled: _,
2888
+ onClick: () => void C(),
2889
+ children: _ ? "Working…" : "Preview result"
2890
+ }), /* @__PURE__ */ x("button", {
2891
+ className: "btn btn-primary",
2892
+ disabled: _ || !d,
2893
+ onClick: () => void w(),
2894
+ children: "Commit reconciled revision"
2895
+ })]
2896
+ }),
2897
+ d && /* @__PURE__ */ S("div", {
2898
+ className: "studio-card",
2899
+ children: [
2900
+ /* @__PURE__ */ x("span", {
2901
+ className: "card-kind",
2902
+ children: "Preview"
2903
+ }),
2904
+ /* @__PURE__ */ S("div", {
2905
+ className: "cp-stats",
2906
+ children: [
2907
+ /* @__PURE__ */ x(Y, {
2908
+ label: "Content identity",
2909
+ value: `${d.preview.content_id.slice(0, 12)}…`
2910
+ }),
2911
+ /* @__PURE__ */ x(Y, {
2912
+ label: "Parent",
2913
+ value: `#${d.preview.parent.sequence}`
2914
+ }),
2915
+ /* @__PURE__ */ x(Y, {
2916
+ label: "Undecided conflicts",
2917
+ value: d.unresolved.length
2918
+ })
2919
+ ]
2920
+ }),
2921
+ d.unresolved.length > 0 && /* @__PURE__ */ S("p", {
2922
+ className: "cp-notice",
2923
+ children: [
2924
+ d.unresolved.length,
2925
+ " path",
2926
+ d.unresolved.length === 1 ? "" : "s",
2927
+ " conflict and have no decision:",
2928
+ " ",
2929
+ d.unresolved.map((e) => s(e)).join(", "),
2930
+ ". Committing now takes the chosen branch\\u2019s value there."
2931
+ ]
2932
+ }),
2933
+ /* @__PURE__ */ x(X, { value: d.preview.content })
2934
+ ]
2935
+ }),
2936
+ p && /* @__PURE__ */ x(At, { revision: p })
2937
+ ]
2938
+ });
2939
+ }
2940
+ function Mt() {
2941
+ let [e, t] = v(""), [n, r] = v(""), [i, a] = v([]), [s, c] = v("history"), [l, u] = v(null), [d, f] = v(null), [p, m] = v(""), [h, g] = v(0), { value: _, loading: y, error: C, refresh: w } = H((t) => t.stateResources({
2942
+ prefix: e,
2943
+ limit: 200
2944
+ }), [e, h], { subject: "state resources" }), { value: T, loading: E, refresh: D } = H((e) => e.stateHistory(n), [n, h], {
2945
+ enabled: !!n,
2946
+ subject: "this resource’s history"
2947
+ }), { api: O, capabilities: k } = V(), A = (e) => a((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e].slice(-3)), j = async () => {
2948
+ m("");
2949
+ try {
2950
+ u(await O.stateDiff(i[0], i[1])), c("diff");
2951
+ } catch (e) {
2952
+ u(null), m(o(e, "the diff"));
2953
+ }
2954
+ }, ee = async () => {
2955
+ m("");
2956
+ try {
2957
+ f(await O.stateConflicts(i[0], i[1], i[2])), c("conflicts");
2958
+ } catch (e) {
2959
+ f(null), m(o(e, "the conflict classification"));
2960
+ }
2961
+ };
2962
+ return /* @__PURE__ */ S($, {
2963
+ eyebrow: "State",
2964
+ title: "State",
2965
+ description: "What changed, who changed it, what state it came from, why two states conflict, and what reconciliation would do.",
2966
+ children: [/* @__PURE__ */ x(Tt, {}), /* @__PURE__ */ x(G, {
2967
+ capability: "state.history",
2968
+ children: /* @__PURE__ */ S("div", {
2969
+ className: "data-layout",
2970
+ children: [/* @__PURE__ */ S("aside", {
2971
+ className: "studio-card",
2972
+ children: [/* @__PURE__ */ x("span", {
2973
+ className: "card-kind",
2974
+ children: "Resources"
2975
+ }), /* @__PURE__ */ S(G, {
2976
+ capability: "state.resources.list",
2977
+ children: [
2978
+ /* @__PURE__ */ x("input", {
2979
+ "aria-label": "Resource prefix",
2980
+ value: e,
2981
+ onChange: (e) => t(e.target.value),
2982
+ placeholder: "Filter by prefix…"
2983
+ }),
2984
+ y && !_ && /* @__PURE__ */ x(K, { what: "resources" }),
2985
+ _ && (_.resources.length === 0 ? /* @__PURE__ */ S(J, { children: [
2986
+ "No resource in this instance has revision history",
2987
+ e ? ` under “${e}”` : "",
2988
+ "."
2989
+ ] }) : _.resources.map((e) => /* @__PURE__ */ S("button", {
2990
+ className: e.resource === n ? "active" : "",
2991
+ onClick: () => {
2992
+ r(e.resource), a([]), u(null), f(null), c("history");
2993
+ },
2994
+ children: [e.resource, /* @__PURE__ */ S("small", { children: [
2995
+ e.revisions,
2996
+ " revisions",
2997
+ e.head ? ` · head #${e.head.sequence}` : ""
2998
+ ] })]
2999
+ }, e.resource))),
3000
+ /* @__PURE__ */ x(q, {
3001
+ message: C,
3002
+ onRetry: w
3003
+ })
3004
+ ]
3005
+ })]
3006
+ }), /* @__PURE__ */ x("section", {
3007
+ className: "data-browser",
3008
+ children: n ? /* @__PURE__ */ S(b, { children: [
3009
+ /* @__PURE__ */ S("header", { children: [/* @__PURE__ */ S("div", { children: [
3010
+ /* @__PURE__ */ x("span", {
3011
+ className: "card-kind",
3012
+ children: "resource"
3013
+ }),
3014
+ /* @__PURE__ */ x("h2", { children: n }),
3015
+ T && /* @__PURE__ */ S("p", {
3016
+ className: "cp-muted",
3017
+ children: [
3018
+ T.revisions.length,
3019
+ " retained revisions · retention ",
3020
+ T.retention.keep_last === null ? "keeps everything" : `keeps the last ${T.retention.keep_last}`,
3021
+ " · horizon #",
3022
+ T.retention.horizon
3023
+ ]
3024
+ })
3025
+ ] }), /* @__PURE__ */ S("div", {
3026
+ className: "cp-actions",
3027
+ children: [
3028
+ /* @__PURE__ */ x("button", {
3029
+ className: "btn btn-ghost",
3030
+ disabled: i.length !== 2,
3031
+ onClick: () => void j(),
3032
+ children: "Diff 2 selected"
3033
+ }),
3034
+ /* @__PURE__ */ x("button", {
3035
+ className: "btn btn-ghost",
3036
+ disabled: i.length !== 3,
3037
+ onClick: () => void ee(),
3038
+ children: "Classify 3 selected"
3039
+ }),
3040
+ /* @__PURE__ */ x("button", {
3041
+ className: "btn btn-ghost",
3042
+ disabled: i.length !== 3,
3043
+ onClick: () => c("reconcile"),
3044
+ children: "Reconcile"
3045
+ })
3046
+ ]
3047
+ })] }),
3048
+ /* @__PURE__ */ x("p", {
3049
+ className: "cp-muted",
3050
+ children: "Select two revisions to diff them, or three — base, left, right, in selection order — to classify how two branches interact and to reconcile them."
3051
+ }),
3052
+ /* @__PURE__ */ x(q, { message: p }),
3053
+ /* @__PURE__ */ S(ct, {
3054
+ label: "History views",
3055
+ active: s,
3056
+ onSelect: c,
3057
+ tabs: [
3058
+ {
3059
+ id: "history",
3060
+ label: "History"
3061
+ },
3062
+ {
3063
+ id: "diff",
3064
+ label: "Diff"
3065
+ },
3066
+ {
3067
+ id: "conflicts",
3068
+ label: "Conflicts"
3069
+ },
3070
+ {
3071
+ id: "reconcile",
3072
+ label: "Reconciliation"
3073
+ }
3074
+ ],
3075
+ children: [
3076
+ s === "history" && k.status("state.branch.heads") === "unsupported" && /* @__PURE__ */ x(W, { capability: "state.branch.heads" }),
3077
+ s === "history" && (E && !T ? /* @__PURE__ */ x(K, { what: "history" }) : T && /* @__PURE__ */ x(Et, {
3078
+ revisions: T.revisions,
3079
+ selected: i,
3080
+ onToggle: A
3081
+ })),
3082
+ s === "diff" && /* @__PURE__ */ x(G, {
3083
+ capability: "state.diff.semantic",
3084
+ children: l ? /* @__PURE__ */ x(Dt, { diff: l }) : /* @__PURE__ */ x(J, { children: "Select two revisions and press “Diff 2 selected”." })
3085
+ }),
3086
+ s === "conflicts" && /* @__PURE__ */ x(G, {
3087
+ capability: "state.conflict.classify",
3088
+ children: d ? /* @__PURE__ */ x(Ot, { classification: d }) : /* @__PURE__ */ x(J, { children: "Select three revisions — base, left, right — and press “Classify 3 selected”." })
3089
+ }),
3090
+ s === "reconcile" && /* @__PURE__ */ x(G, {
3091
+ capability: "state.reconciliation.execute",
3092
+ children: i.length === 3 ? /* @__PURE__ */ x(G, {
3093
+ capability: "state.reconciliation.plan",
3094
+ children: /* @__PURE__ */ x(jt, {
3095
+ base: i[0],
3096
+ left: i[1],
3097
+ right: i[2],
3098
+ onCommitted: () => {
3099
+ g((e) => e + 1), D();
3100
+ }
3101
+ })
3102
+ }) : /* @__PURE__ */ x(J, { children: "Reconciliation needs three revisions: a common ancestor and the two branches to reconcile." })
3103
+ })
3104
+ ]
3105
+ })
3106
+ ] }) : /* @__PURE__ */ x(J, { children: "Select a resource to see its history." })
3107
+ })]
3108
+ })
3109
+ })]
3110
+ });
3111
+ }
3112
+ //#endregion
3113
+ //#region src/control-plane/Operations.tsx
3114
+ function Nt(e, t, n) {
3115
+ return e ? "loading" : t ? "connection-failure" : n === "unsupported" ? "unsupported" : "supported";
3116
+ }
3117
+ function Pt() {
3118
+ return /* @__PURE__ */ S("section", {
3119
+ className: "cp-unavailable",
3120
+ role: "note",
3121
+ children: [
3122
+ /* @__PURE__ */ x("h3", { children: "Not available" }),
3123
+ /* @__PURE__ */ x("p", { children: "Transaction observability isn't available from this FeltDB runtime." }),
3124
+ /* @__PURE__ */ x("p", { children: "This does not affect the application's ability to run." })
3125
+ ]
3126
+ });
3127
+ }
3128
+ function Ft({ transactionId: e, onClose: t }) {
3129
+ let { value: n, loading: r, error: i, refresh: a } = H((t) => t.transaction(e), [e], { subject: "this transaction" });
3130
+ return /* @__PURE__ */ S("section", {
3131
+ className: "cp-detail studio-card",
3132
+ children: [
3133
+ /* @__PURE__ */ S("header", {
3134
+ className: "cp-detail-header",
3135
+ children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("span", {
3136
+ className: "card-kind",
3137
+ children: "transaction"
3138
+ }), /* @__PURE__ */ x("h2", { children: /* @__PURE__ */ x(Q, {
3139
+ value: e,
3140
+ length: 32
3141
+ }) })] }), /* @__PURE__ */ x("button", {
3142
+ className: "data-close",
3143
+ onClick: t,
3144
+ "aria-label": "Close transaction",
3145
+ children: "×"
3146
+ })]
3147
+ }),
3148
+ r && !n && /* @__PURE__ */ x(K, { what: "the transaction" }),
3149
+ /* @__PURE__ */ x(q, {
3150
+ message: i,
3151
+ onRetry: a
3152
+ }),
3153
+ n && /* @__PURE__ */ S(b, { children: [
3154
+ /* @__PURE__ */ S("div", {
3155
+ className: "cp-stats",
3156
+ children: [
3157
+ /* @__PURE__ */ x(Y, {
3158
+ label: "Applied",
3159
+ value: n.applied ? "Yes" : "No"
3160
+ }),
3161
+ /* @__PURE__ */ x(Y, {
3162
+ label: "Attribution held",
3163
+ value: n.attribution_available ? "Yes" : "No",
3164
+ hint: "Whether this commit is still inside the instance's bounded attribution window."
3165
+ }),
3166
+ /* @__PURE__ */ x(Y, {
3167
+ label: "Actor",
3168
+ value: n.attribution?.subject ?? void 0
3169
+ }),
3170
+ /* @__PURE__ */ x(Y, {
3171
+ label: "Records",
3172
+ value: n.attribution?.operations
3173
+ })
3174
+ ]
3175
+ }),
3176
+ /* @__PURE__ */ x("p", {
3177
+ className: "cp-muted",
3178
+ children: n.idempotent_replay
3179
+ }),
3180
+ n.applied && !n.attribution_available && /* @__PURE__ */ x("p", {
3181
+ className: "cp-notice",
3182
+ children: "This transaction applied, but it committed longer ago than the attribution window keeps. Who committed it is in the durable transaction log, which no route reads back."
3183
+ })
3184
+ ] })
3185
+ ]
3186
+ });
3187
+ }
3188
+ function It({ onOpenRecord: e }) {
3189
+ let { capabilities: t } = V(), [n, r] = v(""), [i, a] = v({
3190
+ subject: "",
3191
+ collection: ""
3192
+ }), [{ subject: o, collection: s }, c] = v({
3193
+ subject: "",
3194
+ collection: ""
3195
+ }), l = JSON.stringify([o, s]), { value: u, loading: d, error: f, refresh: p } = H((e) => e.transactions({
3196
+ subject: o || void 0,
3197
+ collection: s || void 0,
3198
+ limit: 100
3199
+ }).then((e) => ({
3200
+ ...e,
3201
+ request: l
3202
+ })), [l], {
3203
+ refreshMs: 8e3,
3204
+ subject: "recent commits"
3205
+ }), m = u?.request === l ? u : void 0;
3206
+ return /* @__PURE__ */ S(b, { children: [
3207
+ /* @__PURE__ */ x(tt, {
3208
+ label: "Filter commits",
3209
+ idPrefix: "commit-filter",
3210
+ filters: [{
3211
+ id: "subject",
3212
+ label: "Actor",
3213
+ value: i.subject,
3214
+ placeholder: "Subject"
3215
+ }, {
3216
+ id: "collection",
3217
+ label: "Collection",
3218
+ value: i.collection,
3219
+ placeholder: "Collection"
3220
+ }],
3221
+ onChange: (e, t) => a((n) => ({
3222
+ ...n,
3223
+ [e]: t
3224
+ })),
3225
+ onSubmit: () => c({
3226
+ subject: i.subject.trim(),
3227
+ collection: i.collection.trim()
3228
+ }),
3229
+ applied: +!!o + +!!s,
3230
+ onClear: () => {
3231
+ a({
3232
+ subject: "",
3233
+ collection: ""
3234
+ }), c({
3235
+ subject: "",
3236
+ collection: ""
3237
+ });
3238
+ },
3239
+ result: m && (o || s) ? `${m.transactions.length} ${m.transactions.length === 1 ? "commit matches" : "commits match"}` : ""
3240
+ }),
3241
+ /* @__PURE__ */ x("div", {
3242
+ className: "cp-actions",
3243
+ children: /* @__PURE__ */ x("button", {
3244
+ className: "btn btn-ghost",
3245
+ onClick: p,
3246
+ children: "Refresh"
3247
+ })
3248
+ }),
3249
+ m && /* @__PURE__ */ S("p", {
3250
+ className: "cp-muted",
3251
+ children: [
3252
+ m.window.note,
3253
+ " Holding ",
3254
+ m.window.held,
3255
+ " of ",
3256
+ m.window.capacity,
3257
+ "."
3258
+ ]
3259
+ }),
3260
+ /* @__PURE__ */ x(et, {
3261
+ label: "Recent commits",
3262
+ loading: !f && (d || !m),
3263
+ loadingWhat: "commits",
3264
+ error: f ? {
3265
+ message: f,
3266
+ onRetry: p
3267
+ } : null,
3268
+ columns: [
3269
+ {
3270
+ id: "when",
3271
+ header: "When"
3272
+ },
3273
+ {
3274
+ id: "actor",
3275
+ header: "Actor"
3276
+ },
3277
+ {
3278
+ id: "application",
3279
+ header: "Application"
3280
+ },
3281
+ {
3282
+ id: "transaction",
3283
+ header: "Transaction"
3284
+ },
3285
+ {
3286
+ id: "records",
3287
+ header: "Records",
3288
+ align: "end"
3289
+ },
3290
+ {
3291
+ id: "revision",
3292
+ header: "Revision"
3293
+ },
3294
+ {
3295
+ id: "touched",
3296
+ header: "Touched"
3297
+ }
3298
+ ],
3299
+ rows: (m?.transactions || []).map((t) => ({
3300
+ key: t.transaction_id,
3301
+ selected: t.transaction_id === n,
3302
+ attrs: { "data-transaction": t.transaction_id },
3303
+ cells: {
3304
+ when: /* @__PURE__ */ x(Z, { ms: t.unix_ms }),
3305
+ actor: t.subject ? /* @__PURE__ */ x("strong", { children: t.subject }) : /* @__PURE__ */ x("span", {
3306
+ className: "cp-muted",
3307
+ children: "unnamed"
3308
+ }),
3309
+ application: t.application_id ? /* @__PURE__ */ x("code", { children: t.application_id }) : null,
3310
+ transaction: /* @__PURE__ */ x("button", {
3311
+ className: "record-link",
3312
+ onClick: () => r(t.transaction_id),
3313
+ children: /* @__PURE__ */ x(Q, {
3314
+ value: t.transaction_id,
3315
+ length: 16
3316
+ })
3317
+ }),
3318
+ records: t.operations.toLocaleString(),
3319
+ revision: `${t.base_revision} → ${t.commit_revision}`,
3320
+ touched: /* @__PURE__ */ S("span", {
3321
+ className: "cp-keys",
3322
+ children: [t.keys.slice(0, 6).map((t) => {
3323
+ let n = t.split(":"), r = n.pop(), i = n.pop() || "";
3324
+ return /* @__PURE__ */ S("button", {
3325
+ className: "reference-value",
3326
+ onClick: () => e(i, r),
3327
+ children: [
3328
+ i,
3329
+ "/",
3330
+ r
3331
+ ]
3332
+ }, t);
3333
+ }), t.operations > Math.min(t.keys.length, 6) && /* @__PURE__ */ S("span", {
3334
+ className: "cp-muted",
3335
+ children: [
3336
+ " +",
3337
+ t.operations - Math.min(t.keys.length, 6),
3338
+ " more"
3339
+ ]
3340
+ })]
3341
+ })
3342
+ }
3343
+ })),
3344
+ noMatch: !!(o || s),
3345
+ noMatchTitle: "No commit in the window matches",
3346
+ noMatchBody: "Change or clear the filters.",
3347
+ emptyTitle: "No commits in the attribution window yet"
3348
+ }),
3349
+ t.status("operations.correlation_id") === "unsupported" && /* @__PURE__ */ x("p", {
3350
+ className: "cp-muted",
3351
+ children: t.note("operations.correlation_id")
3352
+ }),
3353
+ n && t.usable("operations.transaction_status") && /* @__PURE__ */ x(Ft, {
3354
+ transactionId: n,
3355
+ onClose: () => r("")
3356
+ })
3357
+ ] });
3358
+ }
3359
+ function Lt() {
3360
+ let [e, t] = v(""), [n, r] = v(""), { value: i, loading: a, error: o, refresh: s } = H((t) => t.operations({
3361
+ collection: e || void 0,
3362
+ kind: n || void 0,
3363
+ limit: 100
3364
+ }), [e, n], {
3365
+ refreshMs: 8e3,
3366
+ subject: "recent operations"
3367
+ });
3368
+ return /* @__PURE__ */ S(b, { children: [
3369
+ /* @__PURE__ */ S("form", {
3370
+ className: "cp-filter",
3371
+ onSubmit: (e) => e.preventDefault(),
3372
+ children: [
3373
+ /* @__PURE__ */ x("input", {
3374
+ "aria-label": "Collection",
3375
+ value: e,
3376
+ onChange: (e) => t(e.target.value),
3377
+ placeholder: "Collection…"
3378
+ }),
3379
+ /* @__PURE__ */ S("select", {
3380
+ "aria-label": "Operation type",
3381
+ value: n,
3382
+ onChange: (e) => r(e.target.value),
3383
+ children: [
3384
+ /* @__PURE__ */ x("option", {
3385
+ value: "",
3386
+ children: "Any operation"
3387
+ }),
3388
+ /* @__PURE__ */ x("option", {
3389
+ value: "insert",
3390
+ children: "insert"
3391
+ }),
3392
+ /* @__PURE__ */ x("option", {
3393
+ value: "update",
3394
+ children: "update"
3395
+ }),
3396
+ /* @__PURE__ */ x("option", {
3397
+ value: "delete",
3398
+ children: "delete"
3399
+ })
3400
+ ]
3401
+ }),
3402
+ /* @__PURE__ */ x("button", {
3403
+ className: "btn btn-ghost",
3404
+ onClick: s,
3405
+ children: "Refresh"
3406
+ })
3407
+ ]
3408
+ }),
3409
+ i && /* @__PURE__ */ x("p", {
3410
+ className: "cp-muted",
3411
+ children: i.retained.note
3412
+ }),
3413
+ /* @__PURE__ */ x(q, {
3414
+ message: o,
3415
+ onRetry: s
3416
+ }),
3417
+ a && !i && /* @__PURE__ */ x(K, { what: "operations" }),
3418
+ i && (i.operations.length === 0 ? /* @__PURE__ */ x(J, { children: "No operation in the retained log matches." }) : /* @__PURE__ */ x("div", {
3419
+ className: "table-shell",
3420
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
3421
+ /* @__PURE__ */ x("th", { children: "When" }),
3422
+ /* @__PURE__ */ x("th", { children: "Type" }),
3423
+ /* @__PURE__ */ x("th", { children: "Collection" }),
3424
+ /* @__PURE__ */ x("th", { children: "Key" }),
3425
+ /* @__PURE__ */ x("th", { children: "Authority" }),
3426
+ /* @__PURE__ */ x("th", { children: "Sequence" }),
3427
+ /* @__PURE__ */ x("th", { children: "Revision" })
3428
+ ] }) }), /* @__PURE__ */ x("tbody", { children: i.operations.map((e) => /* @__PURE__ */ S("tr", { children: [
3429
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Z, { ms: e.timestamp_ms }) }),
3430
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(U, { status: e.type }) }),
3431
+ /* @__PURE__ */ x("td", { children: e.collection }),
3432
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("code", { children: e.key }) }),
3433
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Q, { value: e.instance_id }) }),
3434
+ /* @__PURE__ */ x("td", { children: e.sequence }),
3435
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Q, { value: e.state_id }) })
3436
+ ] }, `${e.instance_id}-${e.operation_id}-${e.sequence}`)) })] })
3437
+ }))
3438
+ ] });
3439
+ }
3440
+ function Rt() {
3441
+ let { baseUrl: e, capabilities: t } = V(), [n, r] = v([]), [i, a] = v(!1), [o, s] = v(""), [c, l] = v(""), u = _(null);
3442
+ m(() => {
3443
+ if (!t.usable("operations.events")) return;
3444
+ let n = `${e.replace(/\/$/, "")}/v1/events`, i;
3445
+ try {
3446
+ i = new EventSource(n);
3447
+ } catch {
3448
+ s("The browser could not open the event stream.");
3449
+ return;
3450
+ }
3451
+ return u.current = i, i.onopen = () => {
3452
+ a(!0), s("");
3453
+ }, i.onerror = () => {
3454
+ a(!1), s("The event stream is not connected. It requires an endpoint reachable without an Authorization header.");
3455
+ }, i.addEventListener("state.changed", (e) => {
3456
+ try {
3457
+ r((t) => [JSON.parse(e.data), ...t].slice(0, 200));
3458
+ } catch {}
3459
+ }), () => {
3460
+ i.close(), u.current = null, a(!1);
3461
+ };
3462
+ }, [e, t]);
3463
+ let d = n.filter((e) => !c || JSON.stringify(e).toLowerCase().includes(c.toLowerCase()));
3464
+ return /* @__PURE__ */ S(b, { children: [
3465
+ /* @__PURE__ */ S("p", {
3466
+ className: "cp-muted",
3467
+ children: [
3468
+ "Live state changes as they commit. ",
3469
+ i ? "Connected." : "Not connected.",
3470
+ " This is a stream, not a log: it shows what happens while the page is open."
3471
+ ]
3472
+ }),
3473
+ /* @__PURE__ */ x("form", {
3474
+ className: "cp-filter",
3475
+ onSubmit: (e) => e.preventDefault(),
3476
+ children: /* @__PURE__ */ x("input", {
3477
+ "aria-label": "Search events",
3478
+ value: c,
3479
+ onChange: (e) => l(e.target.value),
3480
+ placeholder: "Search resource, actor, id…"
3481
+ })
3482
+ }),
3483
+ /* @__PURE__ */ x(q, { message: o }),
3484
+ d.length === 0 ? /* @__PURE__ */ x(J, { children: i ? "No change has been observed since this page opened." : "No events." }) : /* @__PURE__ */ x("div", {
3485
+ className: "table-shell",
3486
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
3487
+ /* @__PURE__ */ x("th", { children: "When" }),
3488
+ /* @__PURE__ */ x("th", { children: "Type" }),
3489
+ /* @__PURE__ */ x("th", { children: "Resource" }),
3490
+ /* @__PURE__ */ x("th", { children: "Id" }),
3491
+ /* @__PURE__ */ x("th", { children: "Actor" })
3492
+ ] }) }), /* @__PURE__ */ x("tbody", { children: d.map((e) => /* @__PURE__ */ S("tr", { children: [
3493
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Z, { ms: Number(e.timestamp) * 1e3 }) }),
3494
+ /* @__PURE__ */ x("td", { children: String(e.type) }),
3495
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x("code", { children: String(e.resource) }) }),
3496
+ /* @__PURE__ */ x("td", { children: String(e.resource_id) }),
3497
+ /* @__PURE__ */ x("td", { children: String(e.actor) })
3498
+ ] }, String(e.event_id))) })] })
3499
+ })
3500
+ ] });
3501
+ }
3502
+ function zt({ onOpenRecord: e }) {
3503
+ let [t, n] = v("transactions"), { capabilities: r, loading: i, error: a, reload: o } = V(), s = Nt(i, a, r.status("provenance.transactions"));
3504
+ return s === "loading" ? /* @__PURE__ */ x($, {
3505
+ eyebrow: "Operations",
3506
+ title: "Operations",
3507
+ children: /* @__PURE__ */ x(K, { what: "runtime capabilities" })
3508
+ }) : s === "connection-failure" ? /* @__PURE__ */ x($, {
3509
+ eyebrow: "Operations",
3510
+ title: "Operations unavailable",
3511
+ description: "Studio could not connect to the FeltDB authority.",
3512
+ children: /* @__PURE__ */ x(q, {
3513
+ message: a,
3514
+ onRetry: o
3515
+ })
3516
+ }) : /* @__PURE__ */ x($, {
3517
+ eyebrow: "Operations",
3518
+ title: "Operations",
3519
+ description: "What was asked for, what the engine did, and what is happening right now.",
3520
+ children: /* @__PURE__ */ S(ct, {
3521
+ label: "Operations views",
3522
+ active: t,
3523
+ onSelect: n,
3524
+ tabs: [
3525
+ {
3526
+ id: "transactions",
3527
+ label: "Transactions"
3528
+ },
3529
+ {
3530
+ id: "operations",
3531
+ label: "Operations"
3532
+ },
3533
+ {
3534
+ id: "events",
3535
+ label: "Events"
3536
+ }
3537
+ ],
3538
+ children: [
3539
+ t === "transactions" && (s === "unsupported" ? /* @__PURE__ */ x(Pt, {}) : /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(ot, { capability: "operations.rejections" }), /* @__PURE__ */ x(It, { onOpenRecord: e })] })),
3540
+ t === "operations" && /* @__PURE__ */ x(G, {
3541
+ capability: "operations.recent",
3542
+ children: /* @__PURE__ */ x(Lt, {})
3543
+ }),
3544
+ t === "events" && /* @__PURE__ */ S(G, {
3545
+ capability: "operations.events",
3546
+ children: [/* @__PURE__ */ x(Rt, {}), /* @__PURE__ */ x(W, {
3547
+ capability: "operations.audit_log",
3548
+ title: "Searching past events"
3549
+ })]
3550
+ })
3551
+ ]
3552
+ })
3553
+ });
3554
+ }
3555
+ //#endregion
3556
+ //#region src/control-plane/Instance.tsx
3557
+ function Bt(e) {
3558
+ return e.capabilityLoading ? "loading" : e.capabilityError ? "discovery-failure" : e.capabilityStatus === "unsupported" ? "unsupported" : e.healthLoading || !e.hasHealth && !e.healthError ? "loading" : e.healthError ? "health-failure" : "supported";
3559
+ }
3560
+ function Vt() {
3561
+ return /* @__PURE__ */ S("section", {
3562
+ className: "cp-unavailable",
3563
+ role: "note",
3564
+ children: [
3565
+ /* @__PURE__ */ x("h3", { children: "Replication health" }),
3566
+ /* @__PURE__ */ x("p", { children: /* @__PURE__ */ x("strong", { children: "Not available from this runtime" }) }),
3567
+ /* @__PURE__ */ x("p", { children: "No replication health data is exposed by this FeltDB runtime." })
3568
+ ]
3569
+ });
3570
+ }
3571
+ function Ht() {
3572
+ let { capabilities: e, loading: t, error: n, reload: r } = V(), i = e.status("replication.health"), { value: a, loading: o, error: s, refresh: c } = H((e) => e.replication(), [], {
3573
+ enabled: !t && !n && i !== "unsupported",
3574
+ refreshMs: 1e4,
3575
+ subject: "replication"
3576
+ }), l = Bt({
3577
+ capabilityLoading: t,
3578
+ capabilityError: n,
3579
+ capabilityStatus: i,
3580
+ healthLoading: o,
3581
+ healthError: s,
3582
+ hasHealth: !!a
3583
+ });
3584
+ if (l === "loading") return /* @__PURE__ */ x($, {
3585
+ eyebrow: "Distributed state",
3586
+ title: "Replication",
3587
+ children: /* @__PURE__ */ x(K, { what: "replication status" })
3588
+ });
3589
+ if (l === "discovery-failure") return /* @__PURE__ */ x($, {
3590
+ eyebrow: "Distributed state",
3591
+ title: "Replication unavailable",
3592
+ description: "Studio could not determine replication status from the connected FeltDB authority.",
3593
+ children: /* @__PURE__ */ x(q, {
3594
+ message: n,
3595
+ onRetry: r
3596
+ })
3597
+ });
3598
+ if (l === "unsupported") return /* @__PURE__ */ x($, {
3599
+ eyebrow: "Distributed state",
3600
+ title: "Replication",
3601
+ children: /* @__PURE__ */ x(Vt, {})
3602
+ });
3603
+ if (l === "health-failure" || !a) return /* @__PURE__ */ x($, {
3604
+ eyebrow: "Distributed state",
3605
+ title: "Replication unavailable",
3606
+ description: "Studio could not determine replication status from the connected FeltDB authority.",
3607
+ children: /* @__PURE__ */ x(q, {
3608
+ message: s,
3609
+ onRetry: c
3610
+ })
3611
+ });
3612
+ let u = a.peers || [], d = a.causal_position || {}, f = a.retained_operation_floors || {};
3613
+ return /* @__PURE__ */ S($, {
3614
+ eyebrow: "Distributed state",
3615
+ title: "Replication",
3616
+ description: "Authorities, causal position, and what replication still owes.",
3617
+ children: [
3618
+ /* @__PURE__ */ S("section", {
3619
+ className: "cp-stats",
3620
+ children: [
3621
+ /* @__PURE__ */ x(Y, {
3622
+ label: "Local authority",
3623
+ value: a.local?.instance_id
3624
+ }),
3625
+ /* @__PURE__ */ x(Y, {
3626
+ label: "Peers",
3627
+ value: u.length
3628
+ }),
3629
+ /* @__PURE__ */ x(Y, {
3630
+ label: "Sync successes",
3631
+ value: a.health?.peer_sync_successes
3632
+ }),
3633
+ /* @__PURE__ */ x(Y, {
3634
+ label: "Sync failures",
3635
+ value: a.health?.peer_sync_failures
3636
+ }),
3637
+ /* @__PURE__ */ x(Y, {
3638
+ label: "Operations sent",
3639
+ value: a.health?.operations_sent
3640
+ }),
3641
+ /* @__PURE__ */ x(Y, {
3642
+ label: "Operations received",
3643
+ value: a.health?.operations_received
3644
+ }),
3645
+ /* @__PURE__ */ x(Y, {
3646
+ label: "Operations compacted",
3647
+ value: a.health?.operations_compacted
3648
+ })
3649
+ ]
3650
+ }),
3651
+ /* @__PURE__ */ S("section", {
3652
+ className: "studio-card",
3653
+ children: [
3654
+ /* @__PURE__ */ x("span", {
3655
+ className: "card-kind",
3656
+ children: "Causal position"
3657
+ }),
3658
+ /* @__PURE__ */ x("p", {
3659
+ className: "cp-muted",
3660
+ children: "The highest operation sequence this instance holds from each origin, and the lowest it still retains. An origin whose floor has risen above a peer's position is a peer that can no longer catch up incrementally."
3661
+ }),
3662
+ Object.keys(d).length === 0 ? /* @__PURE__ */ x(J, { children: "No origin has produced an operation this instance holds." }) : /* @__PURE__ */ x("div", {
3663
+ className: "table-shell",
3664
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
3665
+ /* @__PURE__ */ x("th", { children: "Origin" }),
3666
+ /* @__PURE__ */ x("th", { children: "Highest held" }),
3667
+ /* @__PURE__ */ x("th", { children: "Retained from" })
3668
+ ] }) }), /* @__PURE__ */ x("tbody", { children: Object.entries(d).map(([e, t]) => /* @__PURE__ */ S("tr", { children: [
3669
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Q, {
3670
+ value: e,
3671
+ length: 20
3672
+ }) }),
3673
+ /* @__PURE__ */ x("td", { children: t }),
3674
+ /* @__PURE__ */ x("td", { children: f[e] ?? /* @__PURE__ */ x("span", {
3675
+ className: "cp-muted",
3676
+ children: "—"
3677
+ }) })
3678
+ ] }, e)) })] })
3679
+ })
3680
+ ]
3681
+ }),
3682
+ /* @__PURE__ */ S("section", {
3683
+ className: "studio-card",
3684
+ children: [/* @__PURE__ */ x("span", {
3685
+ className: "card-kind",
3686
+ children: "Peers"
3687
+ }), u.length === 0 ? /* @__PURE__ */ x(J, { children: "This instance has no peers. It is a single authority." }) : /* @__PURE__ */ x(X, { value: u })]
3688
+ }),
3689
+ /* @__PURE__ */ S("details", {
3690
+ className: "cp-raw",
3691
+ children: [/* @__PURE__ */ x("summary", { children: "Membership" }), /* @__PURE__ */ x(X, { value: a.membership })]
3692
+ })
3693
+ ]
3694
+ });
3695
+ }
3696
+ function Ut() {
3697
+ let { value: e, loading: t, error: n, refresh: r } = H((e) => e.applications(), [], {
3698
+ refreshMs: 2e4,
3699
+ subject: "applications"
3700
+ });
3701
+ return /* @__PURE__ */ x($, {
3702
+ eyebrow: "Runtimes",
3703
+ title: "Applications",
3704
+ description: "Applications on this instance and the FeltDB runtimes serving them.",
3705
+ children: /* @__PURE__ */ S(G, {
3706
+ capability: "applications.list",
3707
+ children: [
3708
+ /* @__PURE__ */ x(q, {
3709
+ message: n,
3710
+ onRetry: r
3711
+ }),
3712
+ t && !e && /* @__PURE__ */ x(K, { what: "applications" }),
3713
+ e && (e.applications.length === 0 ? /* @__PURE__ */ x(J, { children: "No application is visible to you on this instance." }) : /* @__PURE__ */ x("div", {
3714
+ className: "cp-cards",
3715
+ children: e.applications.map((e) => /* @__PURE__ */ S("article", {
3716
+ className: "studio-card",
3717
+ children: [
3718
+ /* @__PURE__ */ x("span", {
3719
+ className: "card-kind",
3720
+ children: "application"
3721
+ }),
3722
+ /* @__PURE__ */ x("h3", { children: String(e.application_name) }),
3723
+ /* @__PURE__ */ S("p", {
3724
+ className: "cp-muted",
3725
+ children: [
3726
+ /* @__PURE__ */ x(Q, {
3727
+ value: String(e.application_id),
3728
+ length: 22
3729
+ }),
3730
+ " · tenant ",
3731
+ String(e.tenant_name),
3732
+ " ·",
3733
+ " ",
3734
+ /* @__PURE__ */ x(U, { status: String(e.status) })
3735
+ ]
3736
+ }),
3737
+ /* @__PURE__ */ x("div", {
3738
+ className: "table-shell",
3739
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
3740
+ /* @__PURE__ */ x("th", { children: "Environment" }),
3741
+ /* @__PURE__ */ x("th", { children: "Contract revision" }),
3742
+ /* @__PURE__ */ x("th", { children: "FeltDB runtime" }),
3743
+ /* @__PURE__ */ x("th", { children: "Started" })
3744
+ ] }) }), /* @__PURE__ */ x("tbody", { children: (e.environments || []).map((e) => /* @__PURE__ */ S("tr", { children: [
3745
+ /* @__PURE__ */ x("td", { children: String(e.environment) }),
3746
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(Q, { value: String(e.revision_id) }) }),
3747
+ /* @__PURE__ */ x("td", { children: e.runtime ? /* @__PURE__ */ x(U, { status: String(e.runtime.status) }) : /* @__PURE__ */ x("span", {
3748
+ className: "cp-muted",
3749
+ children: "not running"
3750
+ }) }),
3751
+ /* @__PURE__ */ x("td", { children: e.runtime ? /* @__PURE__ */ x(Z, { ms: Number(e.runtime.started_at) * 1e3 }) : /* @__PURE__ */ x("span", {
3752
+ className: "cp-muted",
3753
+ children: "—"
3754
+ }) })
3755
+ ] }, String(e.environment))) })] })
3756
+ })
3757
+ ]
3758
+ }, String(e.application_id)))
3759
+ }))
3760
+ ]
3761
+ })
3762
+ });
3763
+ }
3764
+ function Wt() {
3765
+ let { value: e, loading: t, error: n, refresh: r } = H((e) => e.overview(), [], {
3766
+ refreshMs: 5e3,
3767
+ subject: "instance activity"
3768
+ }), { value: i } = H((e) => e.replication(), [], {
3769
+ refreshMs: 1e4,
3770
+ subject: "replication health"
3771
+ });
3772
+ if (t && !e) return /* @__PURE__ */ x($, {
3773
+ eyebrow: "Health",
3774
+ title: "Monitoring",
3775
+ children: /* @__PURE__ */ x(K, { what: "activity" })
3776
+ });
3777
+ if (!e) return /* @__PURE__ */ x($, {
3778
+ eyebrow: "Health",
3779
+ title: "Monitoring",
3780
+ children: /* @__PURE__ */ x(q, {
3781
+ message: n,
3782
+ onRetry: r
3783
+ })
3784
+ });
3785
+ let a = e.activity || {};
3786
+ return /* @__PURE__ */ S($, {
3787
+ eyebrow: "Health",
3788
+ title: "Monitoring",
3789
+ description: "What this instance counts. Refreshed every five seconds.",
3790
+ children: [/* @__PURE__ */ S(G, {
3791
+ capability: "monitoring.metrics",
3792
+ children: [
3793
+ /* @__PURE__ */ S("section", {
3794
+ className: "cp-stats",
3795
+ children: [
3796
+ /* @__PURE__ */ x(Y, {
3797
+ label: "Requests",
3798
+ value: a.requests
3799
+ }),
3800
+ /* @__PURE__ */ x(Y, {
3801
+ label: "State reads",
3802
+ value: a.state_reads
3803
+ }),
3804
+ /* @__PURE__ */ x(Y, {
3805
+ label: "State mutations",
3806
+ value: a.state_mutations
3807
+ }),
3808
+ /* @__PURE__ */ x(Y, {
3809
+ label: "Event connections",
3810
+ value: a.event_connections
3811
+ })
3812
+ ]
3813
+ }),
3814
+ /* @__PURE__ */ S("section", {
3815
+ className: "cp-stats",
3816
+ children: [
3817
+ /* @__PURE__ */ x(Y, {
3818
+ label: "Requests shed",
3819
+ value: a.requests_shed,
3820
+ hint: "Refused at the door because the in-flight limit was reached."
3821
+ }),
3822
+ /* @__PURE__ */ x(Y, {
3823
+ label: "Deadlines exceeded",
3824
+ value: a.request_deadlines_exceeded
3825
+ }),
3826
+ /* @__PURE__ */ x(Y, {
3827
+ label: "Authentication failures",
3828
+ value: a.authentication_failures
3829
+ }),
3830
+ /* @__PURE__ */ x(Y, {
3831
+ label: "Admission slots free",
3832
+ value: e.runtime?.admission_permits_available
3833
+ })
3834
+ ]
3835
+ }),
3836
+ /* @__PURE__ */ S("section", {
3837
+ className: "cp-stats",
3838
+ children: [
3839
+ /* @__PURE__ */ x(Y, {
3840
+ label: "Records",
3841
+ value: e.storage?.records
3842
+ }),
3843
+ /* @__PURE__ */ x(Y, {
3844
+ label: "State revisions",
3845
+ value: e.storage?.state_revisions
3846
+ }),
3847
+ /* @__PURE__ */ x(Y, {
3848
+ label: "Authority revision",
3849
+ value: e.authority?.authority_revision
3850
+ }),
3851
+ /* @__PURE__ */ x(Y, {
3852
+ label: "Replication backlog sent",
3853
+ value: i?.health?.operations_sent
3854
+ })
3855
+ ]
3856
+ }),
3857
+ /* @__PURE__ */ S("section", {
3858
+ className: "studio-card",
3859
+ children: [/* @__PURE__ */ x("span", {
3860
+ className: "card-kind",
3861
+ children: "Audit writer"
3862
+ }), /* @__PURE__ */ x(X, { value: e.storage?.audit })]
3863
+ })
3864
+ ]
3865
+ }), /* @__PURE__ */ x(W, { capability: "monitoring.latency" })]
3866
+ });
3867
+ }
3868
+ function Gt() {
3869
+ let { capabilities: e } = V(), { value: t, loading: n, error: r, refresh: i } = H((e) => e.overview(), [], { subject: "instance settings" }), { value: a } = H((e) => e.diagnostics(), [], { subject: "instance diagnostics" }), o = e.declaration;
3870
+ return /* @__PURE__ */ S($, {
3871
+ eyebrow: "Instance",
3872
+ title: "Settings",
3873
+ description: "What this instance is configured as, and what it can do.",
3874
+ children: [
3875
+ /* @__PURE__ */ S(G, {
3876
+ capability: "settings.instance",
3877
+ children: [
3878
+ /* @__PURE__ */ x(q, {
3879
+ message: r,
3880
+ onRetry: i
3881
+ }),
3882
+ n && !t && /* @__PURE__ */ x(K, { what: "settings" }),
3883
+ t && /* @__PURE__ */ S(b, { children: [
3884
+ /* @__PURE__ */ S("section", {
3885
+ className: "studio-card",
3886
+ children: [/* @__PURE__ */ x("span", {
3887
+ className: "card-kind",
3888
+ children: "Identity"
3889
+ }), /* @__PURE__ */ S("div", {
3890
+ className: "cp-stats",
3891
+ children: [
3892
+ /* @__PURE__ */ x(Y, {
3893
+ label: "Instance",
3894
+ value: t.instance.instance_id
3895
+ }),
3896
+ /* @__PURE__ */ x(Y, {
3897
+ label: "Namespace",
3898
+ value: t.instance.namespace
3899
+ }),
3900
+ /* @__PURE__ */ x(Y, {
3901
+ label: "Engine",
3902
+ value: t.instance.engine_version
3903
+ }),
3904
+ /* @__PURE__ */ x(Y, {
3905
+ label: "Protocol",
3906
+ value: t.instance.protocol_version
3907
+ })
3908
+ ]
3909
+ })]
3910
+ }),
3911
+ /* @__PURE__ */ S("section", {
3912
+ className: "studio-card",
3913
+ children: [/* @__PURE__ */ x("span", {
3914
+ className: "card-kind",
3915
+ children: "Authority and storage"
3916
+ }), /* @__PURE__ */ S("div", {
3917
+ className: "cp-stats",
3918
+ children: [
3919
+ /* @__PURE__ */ x(Y, {
3920
+ label: "Authority revision",
3921
+ value: t.authority.authority_revision
3922
+ }),
3923
+ /* @__PURE__ */ x(Y, {
3924
+ label: "Lease clock",
3925
+ value: t.authority.lease_clock_healthy ? "Healthy" : "Degraded"
3926
+ }),
3927
+ /* @__PURE__ */ x(Y, {
3928
+ label: "Log recovery",
3929
+ value: t.storage.log_recovery?.status
3930
+ }),
3931
+ /* @__PURE__ */ x(Y, {
3932
+ label: "Autonomous worker",
3933
+ value: t.runtime.worker_enabled ? "Running" : "Off"
3934
+ })
3935
+ ]
3936
+ })]
3937
+ }),
3938
+ /* @__PURE__ */ S("section", {
3939
+ className: "studio-card",
3940
+ children: [/* @__PURE__ */ x("span", {
3941
+ className: "card-kind",
3942
+ children: "Limits"
3943
+ }), /* @__PURE__ */ S("div", {
3944
+ className: "cp-stats",
3945
+ children: [
3946
+ /* @__PURE__ */ x(Y, {
3947
+ label: "Request deadline",
3948
+ value: `${t.runtime.request_deadline_ms} ms`
3949
+ }),
3950
+ /* @__PURE__ */ x(Y, {
3951
+ label: "Admission slots free",
3952
+ value: t.runtime.admission_permits_available
3953
+ }),
3954
+ /* @__PURE__ */ x(Y, {
3955
+ label: "Authentication",
3956
+ value: t.instance.authentication_enabled ? "Enabled" : "Disabled"
3957
+ })
3958
+ ]
3959
+ })]
3960
+ }),
3961
+ a && /* @__PURE__ */ S("details", {
3962
+ className: "cp-raw",
3963
+ children: [/* @__PURE__ */ x("summary", { children: "Diagnostics" }), /* @__PURE__ */ x(X, { value: a })]
3964
+ })
3965
+ ] })
3966
+ ]
3967
+ }),
3968
+ /* @__PURE__ */ x(W, {
3969
+ capability: "settings.mutate",
3970
+ title: "Changing instance configuration"
3971
+ }),
3972
+ /* @__PURE__ */ S("section", {
3973
+ className: "studio-card",
3974
+ children: [
3975
+ /* @__PURE__ */ x("span", {
3976
+ className: "card-kind",
3977
+ children: "Capability matrix"
3978
+ }),
3979
+ /* @__PURE__ */ x("p", {
3980
+ className: "cp-muted",
3981
+ children: "What this instance declares it can do. Studio renders only what is declared here; anything unsupported appears as unavailable, with the reason below, rather than as a control that cannot work."
3982
+ }),
3983
+ o ? /* @__PURE__ */ x("div", {
3984
+ className: "table-shell",
3985
+ children: /* @__PURE__ */ S("table", { children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", { children: [
3986
+ /* @__PURE__ */ x("th", { children: "Capability" }),
3987
+ /* @__PURE__ */ x("th", { children: "Area" }),
3988
+ /* @__PURE__ */ x("th", { children: "Status" }),
3989
+ /* @__PURE__ */ x("th", { children: "Surface" }),
3990
+ /* @__PURE__ */ x("th", { children: "Note" })
3991
+ ] }) }), /* @__PURE__ */ x("tbody", { children: o.capabilities.map((e) => /* @__PURE__ */ S("tr", { children: [
3992
+ /* @__PURE__ */ S("td", { children: [
3993
+ /* @__PURE__ */ x("strong", { children: e.title }),
3994
+ /* @__PURE__ */ x("br", {}),
3995
+ /* @__PURE__ */ x("code", { children: e.id })
3996
+ ] }),
3997
+ /* @__PURE__ */ x("td", { children: e.area }),
3998
+ /* @__PURE__ */ x("td", { children: /* @__PURE__ */ x(U, { status: e.status }) }),
3999
+ /* @__PURE__ */ x("td", {
4000
+ className: "cp-keys",
4001
+ children: e.surface.length === 0 ? /* @__PURE__ */ x("span", {
4002
+ className: "cp-muted",
4003
+ children: "none"
4004
+ }) : e.surface.map((e) => /* @__PURE__ */ x("code", { children: e }, e))
4005
+ }),
4006
+ /* @__PURE__ */ x("td", {
4007
+ className: "cp-note",
4008
+ children: e.note || /* @__PURE__ */ x("span", {
4009
+ className: "cp-muted",
4010
+ children: "—"
4011
+ })
4012
+ })
4013
+ ] }, e.id)) })] })
4014
+ }) : /* @__PURE__ */ x(J, { children: "The instance did not answer with a capability declaration, so Studio is treating every capability as unavailable." })
4015
+ ]
4016
+ })
4017
+ ]
4018
+ });
4019
+ }
4020
+ function Kt() {
4021
+ let { value: e, loading: t, error: n, refresh: r } = H((e) => e.developer(), [], { subject: "developer access" });
4022
+ if (t && !e) return /* @__PURE__ */ x($, {
4023
+ eyebrow: "Connect",
4024
+ title: "Developer",
4025
+ children: /* @__PURE__ */ x(K, { what: "connection details" })
4026
+ });
4027
+ if (!e) return /* @__PURE__ */ x($, {
4028
+ eyebrow: "Connect",
4029
+ title: "Developer",
4030
+ children: /* @__PURE__ */ x(q, {
4031
+ message: n,
4032
+ onRetry: r
4033
+ })
4034
+ });
4035
+ let i = e.environment || {};
4036
+ return /* @__PURE__ */ x($, {
4037
+ eyebrow: "Connect",
4038
+ title: "Developer",
4039
+ description: "How an application, an agent, or a person connects to this instance.",
4040
+ children: /* @__PURE__ */ S(G, {
4041
+ capability: "developer.access",
4042
+ children: [
4043
+ /* @__PURE__ */ S("section", {
4044
+ className: "cp-stats",
4045
+ children: [
4046
+ /* @__PURE__ */ x(Y, {
4047
+ label: "Endpoint",
4048
+ value: e.endpoint || "not advertised"
4049
+ }),
4050
+ /* @__PURE__ */ x(Y, {
4051
+ label: "Namespace",
4052
+ value: e.namespace
4053
+ }),
4054
+ /* @__PURE__ */ x(Y, {
4055
+ label: "Protocol",
4056
+ value: e.protocol_version
4057
+ }),
4058
+ /* @__PURE__ */ x(Y, {
4059
+ label: "Authentication",
4060
+ value: e.authentication
4061
+ })
4062
+ ]
4063
+ }),
4064
+ /* @__PURE__ */ S("section", {
4065
+ className: "studio-card",
4066
+ children: [
4067
+ /* @__PURE__ */ x("span", {
4068
+ className: "card-kind",
4069
+ children: "SDK"
4070
+ }),
4071
+ /* @__PURE__ */ x("p", {
4072
+ className: "cp-muted",
4073
+ children: e.sdk?.install
4074
+ }),
4075
+ /* @__PURE__ */ x("pre", {
4076
+ className: "cp-json",
4077
+ children: e.sdk?.snippet
4078
+ })
4079
+ ]
4080
+ }),
4081
+ /* @__PURE__ */ S("section", {
4082
+ className: "studio-card",
4083
+ children: [/* @__PURE__ */ x("span", {
4084
+ className: "card-kind",
4085
+ children: "CLI"
4086
+ }), /* @__PURE__ */ x("pre", {
4087
+ className: "cp-json",
4088
+ children: e.cli?.snippet
4089
+ })]
4090
+ }),
4091
+ /* @__PURE__ */ S("section", {
4092
+ className: "studio-card",
4093
+ children: [/* @__PURE__ */ x("span", {
4094
+ className: "card-kind",
4095
+ children: "Environment"
4096
+ }), /* @__PURE__ */ x("pre", {
4097
+ className: "cp-json",
4098
+ children: Object.entries(i).map(([e, t]) => `${e}=${t || ""}`).join("\n")
4099
+ })]
4100
+ }),
4101
+ /* @__PURE__ */ S("section", {
4102
+ className: "studio-card",
4103
+ children: [/* @__PURE__ */ x("span", {
4104
+ className: "card-kind",
4105
+ children: "Interface description"
4106
+ }), /* @__PURE__ */ S("p", {
4107
+ className: "cp-muted",
4108
+ children: [
4109
+ "The instance describes its own application interface at ",
4110
+ /* @__PURE__ */ x("code", { children: e.openapi }),
4111
+ ". An agent that can read it needs nothing else to discover what this application declares and what it may call."
4112
+ ]
4113
+ })]
4114
+ }),
4115
+ /* @__PURE__ */ x(W, { capability: "developer.tool_projection" })
4116
+ ]
4117
+ })
4118
+ });
4119
+ }
4120
+ //#endregion
4121
+ export { Z as A, K as C, Y as D, st as E, rt as F, Ve as I, N as L, at as M, V as N, U as O, H as P, X as S, ot as T, dt as _, Vt as a, q as b, zt as c, At as d, kt as f, _t as g, vt as h, Ht as i, W as j, ct as k, Pt as l, wt as m, Kt as n, Gt as o, Mt as p, Wt as r, Bt as s, Ut as t, Nt as u, G as v, $ as w, Q as x, J as y };