@feltdb/core 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/authority-scope.d.ts +2 -0
  2. package/dist/authority-scope.d.ts.map +1 -1
  3. package/dist/authority-scope.js +7 -2
  4. package/dist/cli/commands.js +19 -21
  5. package/dist/cli/development-session.js +16 -0
  6. package/dist/cli/studio-artifact.js +33 -0
  7. package/dist/create/package-versions.js +1 -1
  8. package/dist/create/server-source/crates/feltdb/src/acceptance_tests.rs +8 -1
  9. package/dist/create/server-source/crates/feltdb/src/application.rs +16 -0
  10. package/dist/create/server-source/crates/feltdb/src/bin/feltdb_node.rs +21 -22
  11. package/dist/create/server-source/crates/feltdb/src/lib.rs +451 -33
  12. package/dist/create/server-source/crates/feltdb/src/state_contract.rs +48 -3
  13. package/dist/create/server-source/crates/feltdb/src/state_model.rs +569 -4
  14. package/dist/create/server-source/crates/feltdb/src/state_trigger.rs +1 -0
  15. package/dist/create/server-source/crates/feltdb/src/versioned_object_substrate.rs +708 -0
  16. package/dist/create/server-source/crates/feltdb/src/worker_mesh.rs +1 -0
  17. package/dist/create/server-source/crates/feltdb/src/workload.rs +480 -44
  18. package/dist/create/server-source/crates/feltdb/tests/generalized_version_control_evidence.rs +123 -0
  19. package/dist/create/server-source/crates/feltdb/tests/generalized_version_control_substrate_completion.rs +281 -0
  20. package/dist/create/server-source/crates/feltdb/tests/production_readiness_contract.rs +15 -3
  21. package/dist/create/server-source/crates/feltdb/tests/revision_retention_boundary_evidence.rs +28 -18
  22. package/dist/create/server-source/crates/feltdb/tests/storage_independent_versioned_object_substrate.rs +328 -0
  23. package/dist/create/server-source/crates/feltdb/tests/workload_envelope_contract.rs +20 -3
  24. package/dist/create/server-source/crates/feltdb-server/src/app_state.rs +14 -4
  25. package/dist/create/server-source/crates/feltdb-server/src/backup.rs +0 -4
  26. package/dist/create/server-source/crates/feltdb-server/src/canonical_principals.rs +1093 -0
  27. package/dist/create/server-source/crates/feltdb-server/src/causal.rs +905 -144
  28. package/dist/create/server-source/crates/feltdb-server/src/connections.rs +9 -6
  29. package/dist/create/server-source/crates/feltdb-server/src/control_plane.rs +90 -0
  30. package/dist/create/server-source/crates/feltdb-server/src/lib.rs +1 -0
  31. package/dist/create/server-source/crates/feltdb-server/src/main.rs +443 -77
  32. package/dist/create/server-source/crates/feltdb-server/src/principals.rs +9 -501
  33. package/dist/create/server-source/crates/feltdb-server/src/tenancy.rs +22 -0
  34. package/dist/create/server-source/crates/feltdb-server/tests/principal_tenant_migration.rs +247 -0
  35. package/dist/db.d.ts +14 -7
  36. package/dist/db.d.ts.map +1 -1
  37. package/dist/db.js +50 -26
  38. package/dist/deployment.d.ts +2 -0
  39. package/dist/deployment.d.ts.map +1 -1
  40. package/dist/deployment.js +4 -2
  41. package/dist/embedded-transaction.d.ts.map +1 -1
  42. package/dist/embedded-transaction.js +4 -0
  43. package/dist/error-codes.d.ts +12 -0
  44. package/dist/error-codes.d.ts.map +1 -1
  45. package/dist/error-codes.js +20 -2
  46. package/dist/feltdb.d.ts +4 -0
  47. package/dist/feltdb.d.ts.map +1 -1
  48. package/dist/file-db.d.ts +10 -0
  49. package/dist/file-db.d.ts.map +1 -1
  50. package/dist/file-db.js +18 -0
  51. package/dist/http-db.d.ts +7 -0
  52. package/dist/http-db.d.ts.map +1 -1
  53. package/dist/http-db.js +83 -15
  54. package/dist/index-core.d.ts +1 -0
  55. package/dist/index-core.d.ts.map +1 -1
  56. package/dist/index-core.js +1 -0
  57. package/dist/operation-admission.d.ts +2 -0
  58. package/dist/operation-admission.d.ts.map +1 -1
  59. package/dist/public-contract.d.ts +112 -0
  60. package/dist/public-contract.d.ts.map +1 -0
  61. package/dist/public-contract.js +125 -0
  62. package/dist/studio/app.d.ts +23 -0
  63. package/dist/studio/app.d.ts.map +1 -1
  64. package/dist/studio/components/ContractInspector.d.ts +5 -0
  65. package/dist/studio/components/ContractInspector.d.ts.map +1 -1
  66. package/dist/studio/components/SettingsPanel.d.ts +4 -1
  67. package/dist/studio/components/SettingsPanel.d.ts.map +1 -1
  68. package/dist/studio/components/index.js +4 -4
  69. package/dist/studio/{components-CehkcX_k.js → components-CJFgdKG6.js} +322 -303
  70. package/dist/studio/control-plane/Data.d.ts.map +1 -1
  71. package/dist/studio/control-plane/Instance.d.ts +10 -0
  72. package/dist/studio/control-plane/Instance.d.ts.map +1 -1
  73. package/dist/studio/control-plane/Operations.d.ts +3 -0
  74. package/dist/studio/control-plane/Operations.d.ts.map +1 -1
  75. package/dist/studio/control-plane/State.d.ts.map +1 -1
  76. package/dist/studio/control-plane/index.d.ts +4 -2
  77. package/dist/studio/control-plane/index.d.ts.map +1 -1
  78. package/dist/studio/control-plane/index.js +2 -2
  79. package/dist/studio/control-plane-DP8ljTDO.js +3207 -0
  80. package/dist/studio/index.js +96 -75
  81. package/dist/studio/utils/api.d.ts +1 -1
  82. package/dist/studio/utils/api.d.ts.map +1 -1
  83. package/dist/studio/utils/control-plane-api.d.ts +12 -1
  84. package/dist/studio/utils/control-plane-api.d.ts.map +1 -1
  85. package/dist/studio/utils/control-plane-api.js +1 -1
  86. package/dist/studio/utils/index.js +16 -16
  87. package/dist/studio/utils/service-api.d.ts +8 -0
  88. package/dist/studio/utils/service-api.d.ts.map +1 -1
  89. package/dist/studio/utils/service-api.js +15 -12
  90. package/dist/studio-app/assets/{feltdb_wasm-DksXDnLa.js → feltdb_wasm-CfNb3IoF.js} +1 -1
  91. package/dist/studio-app/assets/feltdb_wasm_bg-D9d3gY-E.wasm +0 -0
  92. package/dist/studio-app/assets/index-SDXdROi1.js +30 -0
  93. package/dist/studio-app/feltdb-studio.json +6 -0
  94. package/dist/studio-app/index.html +1 -1
  95. package/dist/transaction.d.ts +9 -1
  96. package/dist/transaction.d.ts.map +1 -1
  97. package/dist/transaction.js +6 -2
  98. package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
  99. package/dist/workspace/local-development-authority.d.ts +8 -0
  100. package/dist/workspace/local-development-authority.d.ts.map +1 -1
  101. package/dist/workspace/local-development-authority.js +136 -1
  102. package/package.json +2 -2
  103. package/dist/studio/control-plane-D6TT2fCQ.js +0 -3064
  104. package/dist/studio-app/assets/feltdb_wasm_bg-Yy4QRHJT.wasm +0 -0
  105. package/dist/studio-app/assets/index-CjELc-ul.js +0 -30
@@ -1,3064 +0,0 @@
1
- import { StudioServiceApi as e, isSecretField as t, safeDisplayValue as n } from "./utils/service-api.js";
2
- import { CapabilitySet as r, ControlPlaneApi as i, controlPlaneErrorMessage as a, formatStatePath as o } from "./utils/control-plane-api.js";
3
- import s, { createContext as c, useContext as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
4
- import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
5
- //#region src/control-plane/context.tsx
6
- var _ = c(null);
7
- function v({ options: e, children: t }) {
8
- let { baseUrl: n = "", token: a = "", applicationId: o = "", environment: s = "production" } = e, c = d(() => new i({
9
- baseUrl: n,
10
- token: a,
11
- applicationId: o,
12
- environment: s
13
- }), [
14
- n,
15
- a,
16
- o,
17
- s
18
- ]), [l, f] = p(new r(null)), [m, g] = p(!0), [v, y] = p(""), [b, x] = p(0);
19
- u(() => {
20
- let e = !0;
21
- return g(!0), c.capabilities().then((t) => {
22
- e && (f(t), y(""));
23
- }).catch((t) => {
24
- e && (f(new r(null)), y(t instanceof Error ? t.message : "The control plane did not answer."));
25
- }).finally(() => {
26
- e && g(!1);
27
- }), () => {
28
- e = !1;
29
- };
30
- }, [c, b]);
31
- let S = d(() => ({
32
- api: c,
33
- capabilities: l,
34
- loading: m,
35
- error: v,
36
- applicationId: o,
37
- environment: s,
38
- baseUrl: n,
39
- token: a,
40
- reload: () => x((e) => e + 1)
41
- }), [
42
- c,
43
- l,
44
- m,
45
- v,
46
- o,
47
- s,
48
- n,
49
- a
50
- ]);
51
- return /* @__PURE__ */ h(_.Provider, {
52
- value: S,
53
- children: t
54
- });
55
- }
56
- function y() {
57
- let e = l(_);
58
- if (!e) throw Error("useControlPlane requires a ControlPlaneProvider");
59
- return e;
60
- }
61
- function b(e, t, n = {}) {
62
- let { api: r } = y(), i = n.enabled !== !1, [o, s] = p(), [c, l] = p(i), [d, f] = p(""), [m, h] = p(0);
63
- return u(() => {
64
- if (!i) {
65
- l(!1);
66
- return;
67
- }
68
- let t = !0, o = () => {
69
- e(r).then((e) => {
70
- t && (s(e), f(""));
71
- }).catch((e) => {
72
- t && f(a(e, n.subject));
73
- }).finally(() => {
74
- t && l(!1);
75
- });
76
- };
77
- if (l(!0), o(), !n.refreshMs) return () => {
78
- t = !1;
79
- };
80
- let c = window.setInterval(o, n.refreshMs);
81
- return () => {
82
- t = !1, window.clearInterval(c);
83
- };
84
- }, [
85
- r,
86
- i,
87
- m,
88
- ...t
89
- ]), {
90
- value: o,
91
- loading: c,
92
- error: d,
93
- refresh: () => h((e) => e + 1)
94
- };
95
- }
96
- //#endregion
97
- //#region src/control-plane/primitives.tsx
98
- function x({ status: e }) {
99
- return /* @__PURE__ */ h("span", {
100
- className: `cp-pill cp-pill-${e}`,
101
- children: e.replace(/[-_]/g, " ")
102
- });
103
- }
104
- function S({ capability: e, title: t }) {
105
- let { capabilities: n } = y(), r = n.get(e);
106
- return /* @__PURE__ */ g("section", {
107
- className: "cp-unavailable",
108
- role: "note",
109
- children: [
110
- /* @__PURE__ */ h("h3", { children: t || r?.title || "Not available on this instance" }),
111
- /* @__PURE__ */ h("p", { children: n.note(e) }),
112
- /* @__PURE__ */ g("p", {
113
- className: "cp-unavailable-id",
114
- children: [
115
- "Capability ",
116
- /* @__PURE__ */ h("code", { children: e }),
117
- " · declared ",
118
- /* @__PURE__ */ h(x, { status: n.status(e) })
119
- ]
120
- })
121
- ]
122
- });
123
- }
124
- function C({ capability: e, requireFull: t, children: n }) {
125
- let { capabilities: r } = y(), i = r.status(e);
126
- return i === "unsupported" || t && i !== "available" ? /* @__PURE__ */ h(S, { capability: e }) : /* @__PURE__ */ h(m, { children: n });
127
- }
128
- function w({ capability: e }) {
129
- let { capabilities: t } = y();
130
- return t.status(e) === "partial" ? /* @__PURE__ */ h("p", {
131
- className: "cp-notice",
132
- children: t.note(e)
133
- }) : null;
134
- }
135
- function T({ what: e }) {
136
- return /* @__PURE__ */ g("p", {
137
- className: "cp-loading",
138
- children: [
139
- "Loading ",
140
- e,
141
- "…"
142
- ]
143
- });
144
- }
145
- function E({ message: e, onRetry: t }) {
146
- return e ? /* @__PURE__ */ g("p", {
147
- className: "cp-error",
148
- role: "alert",
149
- children: [e, t && /* @__PURE__ */ h("button", {
150
- className: "btn btn-ghost",
151
- onClick: t,
152
- children: "Retry"
153
- })]
154
- }) : null;
155
- }
156
- function D({ children: e }) {
157
- return /* @__PURE__ */ h("p", {
158
- className: "cp-empty",
159
- children: e
160
- });
161
- }
162
- function O({ label: e, value: t, hint: n }) {
163
- let r = t == null ? "—" : typeof t == "number" ? t.toLocaleString() : String(t);
164
- return /* @__PURE__ */ g("div", {
165
- className: "cp-stat",
166
- children: [/* @__PURE__ */ h("small", { children: e }), /* @__PURE__ */ h("strong", {
167
- title: n,
168
- children: r
169
- })]
170
- });
171
- }
172
- function k({ value: e }) {
173
- return /* @__PURE__ */ h("pre", {
174
- className: "cp-json",
175
- children: JSON.stringify(e, null, 2)
176
- });
177
- }
178
- function A({ path: e }) {
179
- return /* @__PURE__ */ h("code", {
180
- className: "cp-path",
181
- children: o(e)
182
- });
183
- }
184
- function j({ ms: e }) {
185
- if (!e) return /* @__PURE__ */ h("span", {
186
- className: "cp-muted",
187
- children: "—"
188
- });
189
- let t = new Date(e);
190
- return /* @__PURE__ */ h("time", {
191
- dateTime: t.toISOString(),
192
- title: t.toISOString(),
193
- children: t.toLocaleString()
194
- });
195
- }
196
- function M({ value: e, length: t = 12 }) {
197
- return e ? /* @__PURE__ */ h("code", {
198
- className: "cp-identity",
199
- title: e,
200
- children: e.length > t ? `${e.slice(0, t)}…` : e
201
- }) : /* @__PURE__ */ h("span", {
202
- className: "cp-muted",
203
- children: "—"
204
- });
205
- }
206
- function N({ tabs: e, active: t, onSelect: n }) {
207
- return /* @__PURE__ */ h("div", {
208
- className: "cp-tabs",
209
- role: "tablist",
210
- children: e.map((e) => /* @__PURE__ */ h("button", {
211
- role: "tab",
212
- "aria-selected": e.id === t,
213
- className: e.id === t ? "active" : "",
214
- onClick: () => n(e.id),
215
- children: e.label
216
- }, e.id))
217
- });
218
- }
219
- function P({ eyebrow: e, title: t, description: n, children: r }) {
220
- return /* @__PURE__ */ g("div", {
221
- className: "cp-page",
222
- children: [/* @__PURE__ */ g("header", { children: [
223
- /* @__PURE__ */ h("span", {
224
- className: "eyebrow",
225
- children: e
226
- }),
227
- /* @__PURE__ */ h("h1", { children: t }),
228
- n && /* @__PURE__ */ h("p", { children: n })
229
- ] }), r]
230
- });
231
- }
232
- //#endregion
233
- //#region src/control-plane/Overview.tsx
234
- function F() {
235
- let { value: e, loading: t, error: n, refresh: r } = b((e) => e.overview(), [], {
236
- refreshMs: 1e4,
237
- subject: "the instance overview"
238
- }), { value: i } = b((e) => e.replication(), [], {
239
- refreshMs: 15e3,
240
- subject: "replication health"
241
- }), { value: a } = b((e) => e.transactions({ limit: 8 }), [], {
242
- refreshMs: 1e4,
243
- subject: "recent commits"
244
- });
245
- if (t && !e) return /* @__PURE__ */ h(P, {
246
- eyebrow: "Instance",
247
- title: "Overview",
248
- children: /* @__PURE__ */ h(T, { what: "the instance" })
249
- });
250
- if (!e) return /* @__PURE__ */ h(P, {
251
- eyebrow: "Instance",
252
- title: "Overview",
253
- children: /* @__PURE__ */ h(E, {
254
- message: n,
255
- onRetry: r
256
- })
257
- });
258
- let o = e.storage?.log_recovery || {}, s = e.storage?.collections || [], c = i?.peers || [], l = a?.transactions?.[0];
259
- return /* @__PURE__ */ h(P, {
260
- eyebrow: "Instance",
261
- title: "Overview",
262
- description: `${e.instance.namespace} · ${e.instance.instance_id}`,
263
- children: /* @__PURE__ */ g(C, {
264
- capability: "overview.instance",
265
- children: [
266
- /* @__PURE__ */ h(E, {
267
- message: n,
268
- onRetry: r
269
- }),
270
- /* @__PURE__ */ g("section", {
271
- className: "cp-stats",
272
- "aria-label": "Instance status",
273
- children: [
274
- /* @__PURE__ */ h(O, {
275
- label: "Engine",
276
- value: e.instance.engine_version
277
- }),
278
- /* @__PURE__ */ h(O, {
279
- label: "Protocol",
280
- value: e.instance.protocol_version
281
- }),
282
- /* @__PURE__ */ h(O, {
283
- label: "Uptime",
284
- value: `${e.instance.uptime_seconds}s`
285
- }),
286
- /* @__PURE__ */ h(O, {
287
- label: "Authentication",
288
- value: e.instance.authentication_enabled ? "Enabled" : "Disabled"
289
- })
290
- ]
291
- }),
292
- /* @__PURE__ */ g("section", {
293
- className: "cp-panels",
294
- children: [
295
- /* @__PURE__ */ g("article", {
296
- className: "studio-card",
297
- children: [
298
- /* @__PURE__ */ h("span", {
299
- className: "card-kind",
300
- children: "Authority"
301
- }),
302
- /* @__PURE__ */ g("div", {
303
- className: "cp-stats",
304
- children: [
305
- /* @__PURE__ */ h(O, {
306
- label: "Authority revision",
307
- value: e.authority.authority_revision,
308
- hint: "Monotonic commit order. One transaction advances it once."
309
- }),
310
- /* @__PURE__ */ h(O, {
311
- label: "State version",
312
- value: e.authority.state_version
313
- }),
314
- /* @__PURE__ */ h(O, {
315
- label: "Lease clock",
316
- value: e.authority.lease_clock_healthy ? "Healthy" : "Degraded"
317
- })
318
- ]
319
- }),
320
- e.authority.advertise_url && /* @__PURE__ */ g("p", {
321
- className: "cp-muted",
322
- children: ["Advertised at ", /* @__PURE__ */ h("code", { children: e.authority.advertise_url })]
323
- })
324
- ]
325
- }),
326
- /* @__PURE__ */ g("article", {
327
- className: "studio-card",
328
- children: [
329
- /* @__PURE__ */ h("span", {
330
- className: "card-kind",
331
- children: "Storage and durability"
332
- }),
333
- /* @__PURE__ */ g("div", {
334
- className: "cp-stats",
335
- children: [
336
- /* @__PURE__ */ h(O, {
337
- label: "Records",
338
- value: e.storage.records
339
- }),
340
- /* @__PURE__ */ h(O, {
341
- label: "State revisions",
342
- value: e.storage.state_revisions
343
- }),
344
- /* @__PURE__ */ h(O, {
345
- label: "Collections",
346
- value: s.length
347
- })
348
- ]
349
- }),
350
- /* @__PURE__ */ h("p", {
351
- className: o.status === "clean" ? "cp-muted" : "cp-notice",
352
- 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.`
353
- })
354
- ]
355
- }),
356
- /* @__PURE__ */ g("article", {
357
- className: "studio-card",
358
- children: [/* @__PURE__ */ h("span", {
359
- className: "card-kind",
360
- children: "Runtime"
361
- }), /* @__PURE__ */ g("div", {
362
- className: "cp-stats",
363
- children: [
364
- /* @__PURE__ */ h(O, {
365
- label: "Autonomous worker",
366
- value: e.runtime.worker_enabled ? "Running" : "Off"
367
- }),
368
- /* @__PURE__ */ h(O, {
369
- label: "Request deadline",
370
- value: `${e.runtime.request_deadline_ms} ms`
371
- }),
372
- /* @__PURE__ */ h(O, {
373
- label: "Admission slots free",
374
- value: e.runtime.admission_permits_available
375
- })
376
- ]
377
- })]
378
- }),
379
- /* @__PURE__ */ g("article", {
380
- className: "studio-card",
381
- children: [/* @__PURE__ */ h("span", {
382
- className: "card-kind",
383
- children: "Replication"
384
- }), /* @__PURE__ */ g("div", {
385
- className: "cp-stats",
386
- children: [
387
- /* @__PURE__ */ h(O, {
388
- label: "Peers",
389
- value: c.length
390
- }),
391
- /* @__PURE__ */ h(O, {
392
- label: "Sync failures",
393
- value: i?.health?.peer_sync_failures
394
- }),
395
- /* @__PURE__ */ h(O, {
396
- label: "Operations sent",
397
- value: i?.health?.operations_sent
398
- })
399
- ]
400
- })]
401
- })
402
- ]
403
- }),
404
- /* @__PURE__ */ g("section", {
405
- className: "studio-card",
406
- children: [
407
- /* @__PURE__ */ h("span", {
408
- className: "card-kind",
409
- children: "Activity"
410
- }),
411
- /* @__PURE__ */ g("div", {
412
- className: "cp-stats",
413
- children: [
414
- /* @__PURE__ */ h(O, {
415
- label: "Requests",
416
- value: e.activity?.requests
417
- }),
418
- /* @__PURE__ */ h(O, {
419
- label: "State reads",
420
- value: e.activity?.state_reads
421
- }),
422
- /* @__PURE__ */ h(O, {
423
- label: "State mutations",
424
- value: e.activity?.state_mutations
425
- }),
426
- /* @__PURE__ */ h(O, {
427
- label: "Requests shed",
428
- value: e.activity?.requests_shed,
429
- hint: "Refused at the door because the server was already at its in-flight limit."
430
- }),
431
- /* @__PURE__ */ h(O, {
432
- label: "Deadlines exceeded",
433
- value: e.activity?.request_deadlines_exceeded
434
- }),
435
- /* @__PURE__ */ h(O, {
436
- label: "Authentication failures",
437
- value: e.activity?.authentication_failures
438
- })
439
- ]
440
- }),
441
- l ? /* @__PURE__ */ g("p", {
442
- className: "cp-muted",
443
- children: [
444
- "Last recorded commit ",
445
- /* @__PURE__ */ h("code", { children: l.transaction_id }),
446
- " by ",
447
- /* @__PURE__ */ h("strong", { children: l.subject || "an unnamed actor" }),
448
- " · ",
449
- /* @__PURE__ */ h(j, { ms: l.unix_ms })
450
- ]
451
- }) : /* @__PURE__ */ h("p", {
452
- className: "cp-muted",
453
- children: "No commit is inside the attribution window yet."
454
- })
455
- ]
456
- }),
457
- /* @__PURE__ */ g("section", {
458
- className: "studio-card",
459
- children: [/* @__PURE__ */ h("span", {
460
- className: "card-kind",
461
- children: "Collections"
462
- }), s.length === 0 ? /* @__PURE__ */ h(D, { children: "This instance holds no application collections yet." }) : /* @__PURE__ */ h("div", {
463
- className: "table-shell",
464
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
465
- /* @__PURE__ */ h("th", { children: "Collection" }),
466
- /* @__PURE__ */ h("th", { children: "Capability" }),
467
- /* @__PURE__ */ h("th", { children: "Records" })
468
- ] }) }), /* @__PURE__ */ h("tbody", { children: s.map((e) => /* @__PURE__ */ g("tr", { children: [
469
- /* @__PURE__ */ h("td", { children: e.collection }),
470
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("code", { children: e.capability }) }),
471
- /* @__PURE__ */ h("td", { children: Number(e.records).toLocaleString() })
472
- ] }, e.capability)) })] })
473
- })]
474
- }),
475
- /* @__PURE__ */ g("details", {
476
- className: "cp-raw",
477
- children: [/* @__PURE__ */ h("summary", { children: "Raw overview document" }), /* @__PURE__ */ h(k, { value: e })]
478
- })
479
- ]
480
- })
481
- });
482
- }
483
- //#endregion
484
- //#region src/control-plane/Data.tsx
485
- function I({ field: e, value: t }) {
486
- let r = n(e, t);
487
- return r == null ? /* @__PURE__ */ h("span", {
488
- className: "data-null",
489
- children: "—"
490
- }) : typeof r == "boolean" ? /* @__PURE__ */ h("span", {
491
- className: `data-boolean ${r}`,
492
- children: r ? "True" : "False"
493
- }) : typeof r == "object" ? /* @__PURE__ */ g("details", { children: [/* @__PURE__ */ h("summary", { children: Array.isArray(r) ? `${r.length} items` : "Object" }), /* @__PURE__ */ h("pre", { children: JSON.stringify(r, null, 2) })] }) : /* @__PURE__ */ h(m, { children: String(r) });
494
- }
495
- function ee({ action: e, fields: n, initial: r, onSubmit: i, onCancel: o }) {
496
- let [s, c] = p(() => {
497
- let t = { id: r?.id === void 0 ? "" : String(r.id) };
498
- for (let n of e.input_fields) {
499
- let e = r?.[n];
500
- t[n] = e == null ? "" : typeof e == "object" ? JSON.stringify(e) : String(e);
501
- }
502
- return t;
503
- }), [l, u] = p(!1), [d, f] = p(""), m = (e) => n.find((t) => t.name === e)?.type || "text", _ = async () => {
504
- u(!0), f("");
505
- try {
506
- let t = {};
507
- s.id.trim() && (t.id = s.id.trim());
508
- for (let n of e.input_fields) {
509
- let e = s[n];
510
- if (e === "") continue;
511
- let r = m(n);
512
- if (r === "boolean") t[n] = e === "true";
513
- else if (/integer|number|decimal/.test(r)) t[n] = Number(e);
514
- else if (/json|object|array|map/.test(r)) try {
515
- t[n] = JSON.parse(e);
516
- } catch {
517
- throw Error(`${n} is declared ${r} and must be valid JSON.`);
518
- }
519
- else t[n] = e;
520
- }
521
- await i(t);
522
- } catch (t) {
523
- f(t instanceof Error && !("code" in t) ? t.message : a(t, e.name));
524
- } finally {
525
- u(!1);
526
- }
527
- };
528
- return /* @__PURE__ */ g("form", {
529
- className: "studio-card cp-action-form",
530
- onSubmit: (e) => {
531
- e.preventDefault(), _();
532
- },
533
- children: [
534
- /* @__PURE__ */ g("span", {
535
- className: "card-kind",
536
- children: [
537
- e.operation,
538
- " · ",
539
- e.name
540
- ]
541
- }),
542
- /* @__PURE__ */ g("label", { children: ["id", /* @__PURE__ */ h("input", {
543
- value: s.id,
544
- onChange: (e) => c((t) => ({
545
- ...t,
546
- id: e.target.value
547
- })),
548
- placeholder: e.operation === "create" ? "optional — FeltDB derives one" : "required"
549
- })] }),
550
- e.operation !== "delete" && e.input_fields.map((e) => /* @__PURE__ */ g("label", { children: [
551
- e,
552
- " ",
553
- /* @__PURE__ */ g("small", { children: [m(e), t(e) ? " · secret" : ""] }),
554
- m(e) === "boolean" ? /* @__PURE__ */ g("select", {
555
- value: s[e],
556
- onChange: (t) => c((n) => ({
557
- ...n,
558
- [e]: t.target.value
559
- })),
560
- children: [
561
- /* @__PURE__ */ h("option", {
562
- value: "",
563
- children: "unset"
564
- }),
565
- /* @__PURE__ */ h("option", {
566
- value: "true",
567
- children: "true"
568
- }),
569
- /* @__PURE__ */ h("option", {
570
- value: "false",
571
- children: "false"
572
- })
573
- ]
574
- }) : /* @__PURE__ */ h("input", {
575
- value: s[e],
576
- onChange: (t) => c((n) => ({
577
- ...n,
578
- [e]: t.target.value
579
- }))
580
- })
581
- ] }, e)),
582
- /* @__PURE__ */ h(E, { message: d }),
583
- /* @__PURE__ */ g("div", {
584
- className: "cp-actions",
585
- children: [/* @__PURE__ */ h("button", {
586
- type: "button",
587
- className: "btn btn-ghost",
588
- onClick: o,
589
- children: "Cancel"
590
- }), /* @__PURE__ */ h("button", {
591
- className: "btn btn-primary",
592
- disabled: l,
593
- children: l ? "Running…" : `Run ${e.name}`
594
- })]
595
- })
596
- ]
597
- });
598
- }
599
- function te({ collection: e, id: t }) {
600
- let { value: n, loading: r, error: i, refresh: a } = b((n) => n.provenance(e, t), [e, t], { subject: "this record’s provenance" });
601
- if (r && !n) return /* @__PURE__ */ h(T, { what: "provenance" });
602
- if (!n) return /* @__PURE__ */ h(E, {
603
- message: i,
604
- onRetry: a
605
- });
606
- let o = n.attribution.actor;
607
- return /* @__PURE__ */ g(m, { children: [
608
- /* @__PURE__ */ g("p", {
609
- className: "cp-attribution",
610
- children: [
611
- o ? /* @__PURE__ */ g(m, { children: ["Last changed by ", /* @__PURE__ */ h("strong", { children: o })] }) : /* @__PURE__ */ h(m, { children: "No actor is recorded for the last change" }),
612
- n.attribution.authority && /* @__PURE__ */ g(m, { children: [" on authority ", /* @__PURE__ */ h("code", { children: n.attribution.authority })] }),
613
- " · ",
614
- /* @__PURE__ */ h(j, { ms: n.updated_ms })
615
- ]
616
- }),
617
- /* @__PURE__ */ g("div", {
618
- className: "cp-stats",
619
- children: [
620
- /* @__PURE__ */ h(O, {
621
- label: "Attribution source",
622
- value: n.attribution.source,
623
- hint: "transaction: an actor's commit named this record. authority: only the writing instance is known."
624
- }),
625
- /* @__PURE__ */ h(O, {
626
- label: "Content hash",
627
- value: n.content_hash ? `${n.content_hash.slice(0, 12)}…` : void 0
628
- }),
629
- /* @__PURE__ */ h(O, {
630
- label: "Commits held",
631
- value: n.transactions.length
632
- }),
633
- /* @__PURE__ */ h(O, {
634
- label: "State revisions",
635
- value: n.revisions.length
636
- })
637
- ]
638
- }),
639
- /* @__PURE__ */ h("h3", { children: "Commits that named this record" }),
640
- /* @__PURE__ */ h(w, { capability: "provenance.transactions" }),
641
- n.transactions.length === 0 ? /* @__PURE__ */ h(D, { children: "No commit inside the attribution window named this record." }) : /* @__PURE__ */ h("div", {
642
- className: "table-shell",
643
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
644
- /* @__PURE__ */ h("th", { children: "When" }),
645
- /* @__PURE__ */ h("th", { children: "Actor" }),
646
- /* @__PURE__ */ h("th", { children: "Transaction" }),
647
- /* @__PURE__ */ h("th", { children: "Records" }),
648
- /* @__PURE__ */ h("th", { children: "Revision" })
649
- ] }) }), /* @__PURE__ */ h("tbody", { children: n.transactions.map((e) => /* @__PURE__ */ g("tr", { children: [
650
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(j, { ms: e.unix_ms }) }),
651
- /* @__PURE__ */ h("td", { children: e.subject || /* @__PURE__ */ h("span", {
652
- className: "cp-muted",
653
- children: "unnamed"
654
- }) }),
655
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(M, {
656
- value: e.transaction_id,
657
- length: 16
658
- }) }),
659
- /* @__PURE__ */ h("td", { children: e.operations }),
660
- /* @__PURE__ */ g("td", { children: [
661
- e.base_revision,
662
- " → ",
663
- e.commit_revision
664
- ] })
665
- ] }, e.transaction_id)) })] })
666
- }),
667
- /* @__PURE__ */ h("h3", { children: "State revisions" }),
668
- n.revisions.length === 0 ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(w, { capability: "data.records.history" }), /* @__PURE__ */ h(D, { children: "This record has no state revisions. Its write path advances the authority revision without minting one." })] }) : /* @__PURE__ */ h("div", {
669
- className: "table-shell",
670
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
671
- /* @__PURE__ */ h("th", { children: "#" }),
672
- /* @__PURE__ */ h("th", { children: "State ID" }),
673
- /* @__PURE__ */ h("th", { children: "Parent" }),
674
- /* @__PURE__ */ h("th", { children: "Authority" }),
675
- /* @__PURE__ */ h("th", { children: "When" })
676
- ] }) }), /* @__PURE__ */ h("tbody", { children: n.revisions.map((e) => /* @__PURE__ */ g("tr", { children: [
677
- /* @__PURE__ */ h("td", { children: e.sequence }),
678
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(M, { value: e.state_id }) }),
679
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(M, { value: e.parent_id }) }),
680
- /* @__PURE__ */ h("td", { children: e.authority }),
681
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(j, { ms: e.timestamp_ms }) })
682
- ] }, e.state_id)) })] })
683
- }),
684
- /* @__PURE__ */ g("details", {
685
- className: "cp-raw",
686
- children: [/* @__PURE__ */ h("summary", { children: "Raw operation record" }), /* @__PURE__ */ h(k, { value: n.operation })]
687
- })
688
- ] });
689
- }
690
- function ne({ schema: e }) {
691
- return /* @__PURE__ */ h("div", {
692
- className: "table-shell",
693
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
694
- /* @__PURE__ */ h("th", { children: "Field" }),
695
- /* @__PURE__ */ h("th", { children: "Type" }),
696
- /* @__PURE__ */ h("th", { children: "Required" }),
697
- /* @__PURE__ */ h("th", { children: "Reference" })
698
- ] }) }), /* @__PURE__ */ h("tbody", { children: e.fields.map((e) => /* @__PURE__ */ g("tr", { children: [
699
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("code", { children: e.name }) }),
700
- /* @__PURE__ */ h("td", { children: e.type }),
701
- /* @__PURE__ */ h("td", { children: e.required ? "required" : "optional" }),
702
- /* @__PURE__ */ h("td", { children: e.reference ? /* @__PURE__ */ g("span", {
703
- className: "reference-value",
704
- children: ["→ ", e.reference]
705
- }) : /* @__PURE__ */ h("span", {
706
- className: "cp-muted",
707
- children: "—"
708
- }) })
709
- ] }, e.name)) })] })
710
- });
711
- }
712
- function re({ collection: e, report: t, onRebuild: n }) {
713
- let { capabilities: r } = y();
714
- if (!t) return /* @__PURE__ */ h(T, { what: "indexes" });
715
- let i = t.declared.filter((t) => t.collection === e), a = t.access_paths.find((t) => t.collection === e);
716
- return /* @__PURE__ */ g(m, { children: [
717
- /* @__PURE__ */ h("h3", { children: "Declared indexes" }),
718
- i.length === 0 ? /* @__PURE__ */ g(D, { children: [
719
- "The application contract declares no index on ",
720
- e,
721
- "."
722
- ] }) : /* @__PURE__ */ h("div", {
723
- className: "table-shell",
724
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
725
- /* @__PURE__ */ h("th", { children: "Index" }),
726
- /* @__PURE__ */ h("th", { children: "Fields" }),
727
- /* @__PURE__ */ h("th", { children: "Unique" }),
728
- /* @__PURE__ */ h("th", { children: "State" }),
729
- /* @__PURE__ */ h("th", {})
730
- ] }) }), /* @__PURE__ */ h("tbody", { children: i.map((e) => /* @__PURE__ */ g("tr", { children: [
731
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("code", { children: e.name }) }),
732
- /* @__PURE__ */ h("td", { children: e.fields.map((e) => /* @__PURE__ */ h("span", {
733
- className: e.backed ? "cp-grant granted" : "cp-grant denied",
734
- children: e.field
735
- }, e.field)) }),
736
- /* @__PURE__ */ h("td", { children: e.unique ? "unique" : "non-unique" }),
737
- /* @__PURE__ */ g("td", { children: [
738
- /* @__PURE__ */ h(x, { status: e.state === "backed" ? "available" : "partial" }),
739
- " ",
740
- e.state
741
- ] }),
742
- /* @__PURE__ */ h("td", { children: r.usable("data.indexes.rebuild") && e.fields.map((e) => /* @__PURE__ */ g("button", {
743
- className: "btn btn-ghost",
744
- onClick: () => n(e.field),
745
- children: ["Rebuild ", e.field]
746
- }, e.field)) })
747
- ] }, e.name)) })] })
748
- }),
749
- /* @__PURE__ */ h("h3", { children: "Access paths" }),
750
- /* @__PURE__ */ h("p", {
751
- className: "cp-muted",
752
- 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."
753
- }),
754
- /* @__PURE__ */ h("div", {
755
- className: "table-shell",
756
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [/* @__PURE__ */ h("th", { children: "Field" }), /* @__PURE__ */ h("th", { children: "Access method" })] }) }), /* @__PURE__ */ h("tbody", { children: (a?.fields || []).map((e) => /* @__PURE__ */ g("tr", { children: [/* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("code", { children: e.field }) }), /* @__PURE__ */ g("td", { children: [
757
- /* @__PURE__ */ h(x, { status: e.access_method === "index" ? "available" : "partial" }),
758
- " ",
759
- e.access_method === "index" ? "index" : "full scan"
760
- ] })] }, e.field)) })] })
761
- })
762
- ] });
763
- }
764
- function L({ focus: t, onFocusHandled: n }) {
765
- let { api: r, applicationId: i, environment: o, capabilities: c, baseUrl: l, token: u } = y(), f = d(() => new e({
766
- baseUrl: l,
767
- token: u,
768
- applicationId: i,
769
- environment: o
770
- }), [
771
- l,
772
- u,
773
- i,
774
- o
775
- ]), [m, _] = p(""), [v, x] = p("browse"), [S, w] = p(""), [O, k] = p("data"), [A, j] = p(""), [M, F] = p(""), [L, R] = p({}), [z, B] = p(), [V, H] = p([]), [U, W] = p(null), [G, K] = p(""), { value: q, error: ie } = b(() => f.schema(), [f], {
776
- enabled: !!i,
777
- subject: "the application schema"
778
- }), { value: J } = b((e) => e.actions(), [], {
779
- enabled: !!i,
780
- subject: "declared actions"
781
- }), { value: Y, refresh: ae } = b((e) => e.indexes(), [], {
782
- enabled: !!i,
783
- subject: "indexes"
784
- });
785
- s.useEffect(() => {
786
- q?.collections.length && _((e) => q.collections.some((t) => t.collection === e) ? e : q.collections[0].collection);
787
- }, [q]), s.useEffect(() => {
788
- t && (_(t.collection), w(t.id), k("provenance"), n?.());
789
- }, [t]);
790
- let { value: X, loading: oe, error: se, refresh: ce } = b(() => f.records(m, z, L), [
791
- f,
792
- m,
793
- z,
794
- JSON.stringify(L)
795
- ], {
796
- enabled: !!(i && m),
797
- subject: m
798
- }), { value: Z, error: le } = b(() => f.record(m, S), [
799
- f,
800
- m,
801
- S
802
- ], {
803
- enabled: !!(i && m && S),
804
- subject: `record ${S}`
805
- });
806
- if (!i) return /* @__PURE__ */ h(P, {
807
- eyebrow: "Data",
808
- title: "Data",
809
- children: /* @__PURE__ */ h(D, { children: "Open Studio from a FeltDB application environment to browse its records." })
810
- });
811
- let Q = q?.collections.find((e) => e.collection === m), ue = J?.collections.find((e) => e.collection === m)?.actions || [], $ = (e) => ue.find((t) => t.operation === e), de = async (e, t) => {
812
- await r.runAction(J.revision_id, e.name, t), W(null), K(`${e.name} committed.`), ce(), e.operation === "delete" && w("");
813
- }, fe = async (e) => {
814
- K("");
815
- try {
816
- await r.rebuildIndex(m, e), K(`Rebuilt the index on ${m}.${e}.`), ae();
817
- } catch (t) {
818
- K(a(t, `${m}.${e}`));
819
- }
820
- };
821
- return /* @__PURE__ */ h(P, {
822
- eyebrow: "Data",
823
- title: "Data",
824
- description: "Records as FeltDB holds them, authorized and redacted by the Service API.",
825
- children: /* @__PURE__ */ g(C, {
826
- capability: "data.collections.list",
827
- children: [
828
- /* @__PURE__ */ h(E, { message: ie }),
829
- G && /* @__PURE__ */ h("p", {
830
- className: "cp-notice",
831
- children: G
832
- }),
833
- /* @__PURE__ */ g("div", {
834
- className: "data-layout",
835
- children: [/* @__PURE__ */ g("aside", {
836
- className: "studio-card",
837
- children: [
838
- /* @__PURE__ */ h("span", {
839
- className: "card-kind",
840
- children: "Collections"
841
- }),
842
- (q?.collections || []).map((e) => {
843
- let t = Y?.declared.filter((t) => t.collection === e.collection).length || 0;
844
- return /* @__PURE__ */ g("button", {
845
- className: e.collection === m ? "active" : "",
846
- onClick: () => {
847
- _(e.collection), w(""), H([]), B(void 0), R({});
848
- },
849
- children: [e.collection, /* @__PURE__ */ g("small", { children: [
850
- e.fields.length,
851
- " fields · ",
852
- t,
853
- " indexes"
854
- ] })]
855
- }, e.collection);
856
- }),
857
- !q?.collections.length && /* @__PURE__ */ h(D, { children: "No collections in this contract." })
858
- ]
859
- }), /* @__PURE__ */ g("section", {
860
- className: "data-browser",
861
- children: [
862
- /* @__PURE__ */ g("header", { children: [/* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("span", {
863
- className: "card-kind",
864
- children: "collection"
865
- }), /* @__PURE__ */ h("h2", { children: m || "Data" })] }), /* @__PURE__ */ g("div", {
866
- className: "cp-actions",
867
- children: [$("create") && c.usable("data.records.create") && /* @__PURE__ */ g("button", {
868
- className: "btn btn-primary",
869
- onClick: () => W({ action: $("create") }),
870
- children: ["New ", m]
871
- }), !$("create") && m && /* @__PURE__ */ g("span", {
872
- className: "cp-muted",
873
- children: [
874
- "No declared create action for ",
875
- m,
876
- ", so nothing can create one."
877
- ]
878
- })]
879
- })] }),
880
- /* @__PURE__ */ h(N, {
881
- active: v,
882
- onSelect: x,
883
- tabs: [
884
- {
885
- id: "browse",
886
- label: "Browse"
887
- },
888
- {
889
- id: "schema",
890
- label: "Schema"
891
- },
892
- {
893
- id: "indexes",
894
- label: "Indexes"
895
- }
896
- ]
897
- }),
898
- v === "schema" && Q && /* @__PURE__ */ h(ne, { schema: Q }),
899
- v === "indexes" && /* @__PURE__ */ h(C, {
900
- capability: "data.indexes.inspect",
901
- children: /* @__PURE__ */ h(re, {
902
- collection: m,
903
- report: Y,
904
- onRebuild: (e) => void fe(e)
905
- })
906
- }),
907
- v === "browse" && /* @__PURE__ */ g(C, {
908
- capability: "data.records.browse",
909
- children: [
910
- Q && /* @__PURE__ */ g("form", {
911
- className: "cp-filter",
912
- onSubmit: (e) => {
913
- e.preventDefault(), H([]), B(void 0), R(A && M ? { [A]: M } : {});
914
- },
915
- children: [
916
- /* @__PURE__ */ g("select", {
917
- "aria-label": "Filter field",
918
- value: A,
919
- onChange: (e) => j(e.target.value),
920
- children: [/* @__PURE__ */ h("option", {
921
- value: "",
922
- children: "Filter field"
923
- }), Q.fields.map((e) => {
924
- let t = Y?.access_paths.find((e) => e.collection === m)?.fields.find((t) => t.field === e.name)?.access_method;
925
- return /* @__PURE__ */ g("option", {
926
- value: e.name,
927
- children: [e.name, t ? ` (${t === "index" ? "indexed" : "scan"})` : ""]
928
- }, e.name);
929
- })]
930
- }),
931
- /* @__PURE__ */ h("input", {
932
- "aria-label": "Filter value",
933
- value: M,
934
- onChange: (e) => F(e.target.value),
935
- placeholder: "Equals…"
936
- }),
937
- /* @__PURE__ */ h("button", {
938
- className: "btn btn-ghost",
939
- children: "Apply"
940
- })
941
- ]
942
- }),
943
- c.status("data.records.sort") === "unsupported" && /* @__PURE__ */ g("p", {
944
- className: "cp-muted",
945
- children: ["Listed in record-key order. ", c.note("data.records.sort")]
946
- }),
947
- /* @__PURE__ */ h(E, {
948
- message: se,
949
- onRetry: ce
950
- }),
951
- oe && !X && /* @__PURE__ */ h(T, { what: m }),
952
- X && Q && (X.records.length === 0 ? /* @__PURE__ */ h(D, { children: "No records match." }) : /* @__PURE__ */ h("div", {
953
- className: "table-shell",
954
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [/* @__PURE__ */ h("th", { children: "id" }), Q.fields.map((e) => /* @__PURE__ */ g("th", { children: [e.name, /* @__PURE__ */ h("small", { children: e.type })] }, e.name))] }) }), /* @__PURE__ */ h("tbody", { children: X.records.map((e) => /* @__PURE__ */ g("tr", {
955
- className: String(e.id) === S ? "selected" : "",
956
- onClick: () => {
957
- w(String(e.id)), k("data");
958
- },
959
- children: [/* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("button", {
960
- className: "record-link",
961
- children: String(e.id)
962
- }) }), Q.fields.map((t) => /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(I, {
963
- field: t,
964
- value: e[t.name]
965
- }) }, t.name))]
966
- }, String(e.id))) })] })
967
- })),
968
- /* @__PURE__ */ g("footer", {
969
- className: "data-pagination",
970
- children: [
971
- /* @__PURE__ */ h("span", { children: X ? `${X.records.length} shown · state version ${X.state_version}` : "" }),
972
- /* @__PURE__ */ h("button", {
973
- className: "btn btn-ghost",
974
- disabled: !V.length,
975
- onClick: () => {
976
- let e = V.at(-1);
977
- H((e) => e.slice(0, -1)), B(e);
978
- },
979
- children: "← Previous"
980
- }),
981
- /* @__PURE__ */ h("button", {
982
- className: "btn btn-ghost",
983
- disabled: !X?.pagination.nextCursor,
984
- onClick: () => {
985
- H((e) => [...e, z]), B(X.pagination.nextCursor);
986
- },
987
- children: "Next →"
988
- })
989
- ]
990
- })
991
- ]
992
- })
993
- ]
994
- })]
995
- }),
996
- U && Q && /* @__PURE__ */ h(ee, {
997
- action: U.action,
998
- fields: Q.fields,
999
- initial: U.initial,
1000
- onCancel: () => W(null),
1001
- onSubmit: (e) => de(U.action, e)
1002
- }),
1003
- S && c.usable("data.records.inspect") && /* @__PURE__ */ g("section", {
1004
- className: "cp-detail studio-card",
1005
- children: [
1006
- /* @__PURE__ */ g("header", {
1007
- className: "cp-detail-header",
1008
- children: [/* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("span", {
1009
- className: "card-kind",
1010
- children: "record"
1011
- }), /* @__PURE__ */ g("h2", { children: [
1012
- m,
1013
- " / ",
1014
- S
1015
- ] })] }), /* @__PURE__ */ g("div", {
1016
- className: "cp-actions",
1017
- children: [
1018
- $("update") && Z && c.usable("data.records.update") && /* @__PURE__ */ h("button", {
1019
- className: "btn btn-ghost",
1020
- onClick: () => W({
1021
- action: $("update"),
1022
- initial: Z.record
1023
- }),
1024
- children: "Edit"
1025
- }),
1026
- $("delete") && c.usable("data.records.delete") && /* @__PURE__ */ h("button", {
1027
- className: "btn btn-ghost",
1028
- onClick: () => W({
1029
- action: $("delete"),
1030
- initial: { id: S }
1031
- }),
1032
- children: "Delete"
1033
- }),
1034
- /* @__PURE__ */ h("button", {
1035
- className: "data-close",
1036
- onClick: () => w(""),
1037
- "aria-label": "Close record",
1038
- children: "×"
1039
- })
1040
- ]
1041
- })]
1042
- }),
1043
- !$("update") && !$("delete") && /* @__PURE__ */ h("p", {
1044
- className: "cp-muted",
1045
- children: "This collection declares no update or delete action, so nothing — Studio, an application, or an agent — can change these records in place."
1046
- }),
1047
- /* @__PURE__ */ h(N, {
1048
- active: O,
1049
- onSelect: k,
1050
- tabs: [{
1051
- id: "data",
1052
- label: "Data"
1053
- }, {
1054
- id: "provenance",
1055
- label: "Provenance"
1056
- }]
1057
- }),
1058
- /* @__PURE__ */ h(E, { message: le }),
1059
- O === "data" && Z && Q && /* @__PURE__ */ g("dl", {
1060
- className: "cp-record",
1061
- children: [
1062
- /* @__PURE__ */ h("dt", { children: "id" }),
1063
- /* @__PURE__ */ h("dd", { children: /* @__PURE__ */ h("code", { children: String(Z.record.id) }) }),
1064
- Q.fields.map((e) => /* @__PURE__ */ g(s.Fragment, { children: [/* @__PURE__ */ g("dt", { children: [e.name, /* @__PURE__ */ g("small", { children: [e.type, e.required ? " · required" : ""] })] }), /* @__PURE__ */ h("dd", { children: /* @__PURE__ */ h(I, {
1065
- field: e,
1066
- value: Z.record[e.name]
1067
- }) })] }, e.name))
1068
- ]
1069
- }),
1070
- O === "provenance" && /* @__PURE__ */ h(C, {
1071
- capability: "provenance.record",
1072
- children: /* @__PURE__ */ h(te, {
1073
- collection: m,
1074
- id: S
1075
- })
1076
- })
1077
- ]
1078
- })
1079
- ]
1080
- })
1081
- });
1082
- }
1083
- //#endregion
1084
- //#region src/control-plane/Schema.tsx
1085
- function R() {
1086
- let { applicationId: t, environment: n, baseUrl: r, token: i } = y(), [a, o] = p("declared"), s = d(() => new e({
1087
- baseUrl: r,
1088
- token: i,
1089
- applicationId: t,
1090
- environment: n
1091
- }), [
1092
- r,
1093
- i,
1094
- t,
1095
- n
1096
- ]), { value: c, loading: l, error: u, refresh: f } = b(() => s.schema(), [s], {
1097
- enabled: !!t,
1098
- subject: "the application schema"
1099
- }), { value: _ } = b(() => s.application(), [s], {
1100
- enabled: !!t,
1101
- subject: "the application"
1102
- }), { value: v } = b((e) => e.indexes(), [], {
1103
- enabled: !!t,
1104
- subject: "indexes"
1105
- }), [S, w] = p({}), [A, j] = p(!1), [M, F] = p("");
1106
- if (!t) return /* @__PURE__ */ h(P, {
1107
- eyebrow: "Contract",
1108
- title: "Schema",
1109
- children: /* @__PURE__ */ h(D, { children: "Open Studio from a FeltDB application environment to inspect its schema." })
1110
- });
1111
- let I = async () => {
1112
- if (c) {
1113
- j(!0), F("");
1114
- try {
1115
- let e = {};
1116
- for (let t of c.collections) {
1117
- let n = await s.records(t.collection, void 0, {}, 50), r = {};
1118
- for (let e of n.records) for (let [t, n] of Object.entries(e)) {
1119
- if (t === "_relationships") continue;
1120
- let e = n === null ? "null" : Array.isArray(n) ? "array" : typeof n;
1121
- (r[t] || (r[t] = /* @__PURE__ */ new Set())).add(e);
1122
- }
1123
- e[t.collection] = {
1124
- sampled: n.records.length,
1125
- fields: r
1126
- };
1127
- }
1128
- w(e);
1129
- } catch (e) {
1130
- F(e instanceof Error ? e.message : "Unable to sample records.");
1131
- } finally {
1132
- j(!1);
1133
- }
1134
- }
1135
- };
1136
- return /* @__PURE__ */ h(P, {
1137
- eyebrow: "Contract",
1138
- title: "Schema",
1139
- description: _ ? `${_.application_name || _.application_id} · contract v${_.version}` : void 0,
1140
- children: /* @__PURE__ */ g(C, {
1141
- capability: "data.schema.inspect",
1142
- children: [
1143
- /* @__PURE__ */ h(E, {
1144
- message: u,
1145
- onRetry: f
1146
- }),
1147
- l && !c && /* @__PURE__ */ h(T, { what: "the schema" }),
1148
- _ && /* @__PURE__ */ g("section", {
1149
- className: "cp-stats",
1150
- children: [
1151
- /* @__PURE__ */ h(O, {
1152
- label: "Contract version",
1153
- value: _.version
1154
- }),
1155
- /* @__PURE__ */ h(O, {
1156
- label: "Contract hash",
1157
- value: _.contract_hash ? `${_.contract_hash.slice(0, 12)}…` : void 0
1158
- }),
1159
- /* @__PURE__ */ h(O, {
1160
- label: "Flow hash",
1161
- value: _.flow_hash ? `${_.flow_hash.slice(0, 12)}…` : "not recorded"
1162
- }),
1163
- /* @__PURE__ */ h(O, {
1164
- label: "Collections",
1165
- value: c?.collections.length
1166
- })
1167
- ]
1168
- }),
1169
- /* @__PURE__ */ h(N, {
1170
- active: a,
1171
- onSelect: o,
1172
- tabs: [{
1173
- id: "declared",
1174
- label: "Declared"
1175
- }, {
1176
- id: "observed",
1177
- label: "Observed"
1178
- }]
1179
- }),
1180
- a === "declared" && (c?.collections || []).map((e) => {
1181
- let t = v?.declared.filter((t) => t.collection === e.collection) || [];
1182
- return /* @__PURE__ */ g("section", {
1183
- className: "studio-card",
1184
- children: [
1185
- /* @__PURE__ */ h("span", {
1186
- className: "card-kind",
1187
- children: "collection"
1188
- }),
1189
- /* @__PURE__ */ h("h3", { children: e.collection }),
1190
- /* @__PURE__ */ h("div", {
1191
- className: "table-shell",
1192
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
1193
- /* @__PURE__ */ h("th", { children: "Field" }),
1194
- /* @__PURE__ */ h("th", { children: "Type" }),
1195
- /* @__PURE__ */ h("th", { children: "Required" }),
1196
- /* @__PURE__ */ h("th", { children: "Reference" }),
1197
- /* @__PURE__ */ h("th", { children: "Indexed" })
1198
- ] }) }), /* @__PURE__ */ h("tbody", { children: e.fields.map((t) => {
1199
- let n = v?.access_paths.find((t) => t.collection === e.collection)?.fields.find((e) => e.field === t.name)?.access_method;
1200
- return /* @__PURE__ */ g("tr", { children: [
1201
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("code", { children: t.name }) }),
1202
- /* @__PURE__ */ h("td", { children: t.type }),
1203
- /* @__PURE__ */ h("td", { children: t.required ? "required" : "optional" }),
1204
- /* @__PURE__ */ h("td", { children: t.reference ? /* @__PURE__ */ g("span", {
1205
- className: "reference-value",
1206
- children: ["→ ", t.reference]
1207
- }) : /* @__PURE__ */ h("span", {
1208
- className: "cp-muted",
1209
- children: "—"
1210
- }) }),
1211
- /* @__PURE__ */ h("td", { children: n ? /* @__PURE__ */ h(x, { status: n === "index" ? "available" : "partial" }) : /* @__PURE__ */ h("span", {
1212
- className: "cp-muted",
1213
- children: "—"
1214
- }) })
1215
- ] }, t.name);
1216
- }) })] })
1217
- }),
1218
- t.length > 0 && /* @__PURE__ */ g("p", {
1219
- className: "cp-muted",
1220
- children: ["Indexes: ", t.map((e) => `${e.name} (${e.fields.map((e) => e.field).join(", ")}${e.unique ? ", unique" : ""}) · ${e.state}`).join(" · ")]
1221
- }),
1222
- e.relationships.length > 0 && /* @__PURE__ */ g("p", {
1223
- className: "cp-muted",
1224
- children: ["Relationships: ", e.relationships.map((e) => `${e.name} → ${e.target_collection} (${e.cardinality})`).join(" · ")]
1225
- })
1226
- ]
1227
- }, e.collection);
1228
- }),
1229
- a === "observed" && /* @__PURE__ */ g(m, { children: [
1230
- /* @__PURE__ */ h("p", {
1231
- className: "cp-muted",
1232
- 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."
1233
- }),
1234
- /* @__PURE__ */ h("div", {
1235
- className: "cp-actions",
1236
- children: /* @__PURE__ */ h("button", {
1237
- className: "btn btn-ghost",
1238
- disabled: A,
1239
- onClick: () => void I(),
1240
- children: A ? "Sampling…" : "Sample records"
1241
- })
1242
- }),
1243
- /* @__PURE__ */ h(E, { message: M }),
1244
- Object.keys(S).length === 0 ? /* @__PURE__ */ h(D, { children: "No sample taken yet." }) : Object.entries(S).map(([e, t]) => {
1245
- let n = new Set((c?.collections.find((t) => t.collection === e)?.fields || []).map((e) => e.name));
1246
- return /* @__PURE__ */ g("section", {
1247
- className: "studio-card",
1248
- children: [
1249
- /* @__PURE__ */ h("span", {
1250
- className: "card-kind",
1251
- children: "observed"
1252
- }),
1253
- /* @__PURE__ */ g("h3", { children: [
1254
- e,
1255
- " ",
1256
- /* @__PURE__ */ g("small", { children: [t.sampled, " records sampled"] })
1257
- ] }),
1258
- Object.keys(t.fields).length === 0 ? /* @__PURE__ */ h(D, { children: "No records to observe." }) : /* @__PURE__ */ h("div", {
1259
- className: "table-shell",
1260
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
1261
- /* @__PURE__ */ h("th", { children: "Field" }),
1262
- /* @__PURE__ */ h("th", { children: "Observed types" }),
1263
- /* @__PURE__ */ h("th", { children: "Declared" })
1264
- ] }) }), /* @__PURE__ */ h("tbody", { children: Object.entries(t.fields).map(([e, t]) => /* @__PURE__ */ g("tr", { children: [
1265
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("code", { children: e }) }),
1266
- /* @__PURE__ */ h("td", { children: [...t].join(", ") }),
1267
- /* @__PURE__ */ h("td", { children: e === "id" || n.has(e) ? "declared" : /* @__PURE__ */ h(x, { status: "partial" }) })
1268
- ] }, e)) })] })
1269
- })
1270
- ]
1271
- }, e);
1272
- })
1273
- ] }),
1274
- a === "declared" && c && /* @__PURE__ */ g("details", {
1275
- className: "cp-raw",
1276
- children: [/* @__PURE__ */ h("summary", { children: "Raw contract schema" }), /* @__PURE__ */ h(k, { value: c })]
1277
- })
1278
- ]
1279
- })
1280
- });
1281
- }
1282
- //#endregion
1283
- //#region src/control-plane/Agents.tsx
1284
- function z({ agent: e, onOpenRecord: t }) {
1285
- let n = e.did.transactions;
1286
- return n.length ? /* @__PURE__ */ h("div", {
1287
- className: "table-shell",
1288
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
1289
- /* @__PURE__ */ h("th", { children: "When" }),
1290
- /* @__PURE__ */ h("th", { children: "Transaction" }),
1291
- /* @__PURE__ */ h("th", { children: "Records" }),
1292
- /* @__PURE__ */ h("th", { children: "Revision" }),
1293
- /* @__PURE__ */ h("th", { children: "Touched" })
1294
- ] }) }), /* @__PURE__ */ h("tbody", { children: n.map((e) => /* @__PURE__ */ g("tr", { children: [
1295
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(j, { ms: e.unix_ms }) }),
1296
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(M, {
1297
- value: e.transaction_id,
1298
- length: 16
1299
- }) }),
1300
- /* @__PURE__ */ h("td", { children: e.operations.toLocaleString() }),
1301
- /* @__PURE__ */ g("td", { children: [
1302
- e.base_revision,
1303
- " → ",
1304
- e.commit_revision
1305
- ] }),
1306
- /* @__PURE__ */ g("td", {
1307
- className: "cp-keys",
1308
- children: [e.keys.map((e) => {
1309
- let n = e.split(":"), r = n.pop(), i = n.pop() || "";
1310
- return /* @__PURE__ */ g("button", {
1311
- className: "reference-value",
1312
- onClick: () => t(i, r),
1313
- children: [
1314
- i,
1315
- "/",
1316
- r
1317
- ]
1318
- }, e);
1319
- }), e.keys.length < e.operations && /* @__PURE__ */ g("span", {
1320
- className: "cp-muted",
1321
- children: [
1322
- " +",
1323
- e.operations - e.keys.length,
1324
- " more"
1325
- ]
1326
- })]
1327
- })
1328
- ] }, e.transaction_id)) })] })
1329
- }) : /* @__PURE__ */ h(D, { 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." });
1330
- }
1331
- function B({ agent: e }) {
1332
- return /* @__PURE__ */ g(m, { children: [
1333
- /* @__PURE__ */ h("p", {
1334
- className: "cp-muted",
1335
- 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."
1336
- }),
1337
- /* @__PURE__ */ h("p", {
1338
- className: "cp-capabilities",
1339
- children: e.access.capabilities.length ? e.access.capabilities.map((e) => /* @__PURE__ */ h("code", { children: e }, e)) : /* @__PURE__ */ h("span", {
1340
- className: "cp-muted",
1341
- children: "No capabilities granted. This agent can do nothing."
1342
- })
1343
- }),
1344
- /* @__PURE__ */ h("div", {
1345
- className: "table-shell",
1346
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
1347
- /* @__PURE__ */ h("th", { children: "Collection" }),
1348
- /* @__PURE__ */ h("th", { children: "Read policy" }),
1349
- /* @__PURE__ */ h("th", { children: "Write actions" })
1350
- ] }) }), /* @__PURE__ */ h("tbody", { children: e.access.collections.map((e) => /* @__PURE__ */ g("tr", { children: [
1351
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("strong", { children: e.collection }) }),
1352
- /* @__PURE__ */ h("td", { children: e.read.policy || /* @__PURE__ */ h("span", {
1353
- className: "cp-muted",
1354
- children: "no declared policy"
1355
- }) }),
1356
- /* @__PURE__ */ h("td", { children: e.write.actions.length === 0 ? /* @__PURE__ */ h("span", {
1357
- className: "cp-muted",
1358
- children: "The contract declares no write action for this collection, so nothing can write it."
1359
- }) : e.write.actions.map((e) => /* @__PURE__ */ g("span", {
1360
- className: e.permitted ? "cp-grant granted" : "cp-grant denied",
1361
- children: [
1362
- e.operation,
1363
- " · ",
1364
- e.name,
1365
- e.required_capabilities.length > 0 && /* @__PURE__ */ g("small", { children: [" needs ", e.required_capabilities.join(", ")] })
1366
- ]
1367
- }, e.name)) })
1368
- ] }, e.collection)) })] })
1369
- })
1370
- ] });
1371
- }
1372
- function V({ agent: e }) {
1373
- let { capabilities: t } = y();
1374
- return /* @__PURE__ */ g(m, { children: [
1375
- /* @__PURE__ */ h("h3", { children: "Sessions" }),
1376
- e.doing.sessions.length === 0 ? /* @__PURE__ */ h(D, { children: "No session has been opened for this agent." }) : /* @__PURE__ */ h("div", {
1377
- className: "table-shell",
1378
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
1379
- /* @__PURE__ */ h("th", { children: "Session" }),
1380
- /* @__PURE__ */ h("th", { children: "Status" }),
1381
- /* @__PURE__ */ h("th", { children: "Worker" }),
1382
- /* @__PURE__ */ h("th", { children: "Started" }),
1383
- /* @__PURE__ */ h("th", { children: "Capabilities" })
1384
- ] }) }), /* @__PURE__ */ h("tbody", { children: e.doing.sessions.map((e) => /* @__PURE__ */ g("tr", { children: [
1385
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(M, {
1386
- value: e.session_id,
1387
- length: 18
1388
- }) }),
1389
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(x, { status: String(e.status) }) }),
1390
- /* @__PURE__ */ h("td", { children: e.worker_id ? /* @__PURE__ */ h(M, { value: e.worker_id }) : /* @__PURE__ */ h("span", {
1391
- className: "cp-muted",
1392
- children: "unassigned"
1393
- }) }),
1394
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(j, { ms: e.started_at ? e.started_at * 1e3 : null }) }),
1395
- /* @__PURE__ */ h("td", { children: e.capabilities.length })
1396
- ] }, e.session_id)) })] })
1397
- }),
1398
- /* @__PURE__ */ h("h3", { children: "Durable work" }),
1399
- t.usable("agents.work") ? /* @__PURE__ */ h(w, { capability: "agents.task_context" }) : /* @__PURE__ */ h(S, { capability: "agents.work" }),
1400
- e.doing.work.length === 0 ? /* @__PURE__ */ h(D, { children: "No durable workload names this agent." }) : /* @__PURE__ */ h("div", {
1401
- className: "table-shell",
1402
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
1403
- /* @__PURE__ */ h("th", { children: "Workload" }),
1404
- /* @__PURE__ */ h("th", { children: "Definition" }),
1405
- /* @__PURE__ */ h("th", { children: "State" }),
1406
- /* @__PURE__ */ h("th", { children: "Attempts" }),
1407
- /* @__PURE__ */ h("th", { children: "Last failure" })
1408
- ] }) }), /* @__PURE__ */ h("tbody", { children: e.doing.work.map((e) => /* @__PURE__ */ g("tr", { children: [
1409
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(M, {
1410
- value: String(e.workload_id),
1411
- length: 18
1412
- }) }),
1413
- /* @__PURE__ */ h("td", { children: String(e.definition_id) }),
1414
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(x, { status: String(e.state) }) }),
1415
- /* @__PURE__ */ h("td", { children: String(e.attempts) }),
1416
- /* @__PURE__ */ h("td", { children: e.last_failure ? String(e.last_failure) : /* @__PURE__ */ h("span", {
1417
- className: "cp-muted",
1418
- children: "—"
1419
- }) })
1420
- ] }, String(e.workload_id))) })] })
1421
- }),
1422
- /* @__PURE__ */ h("h3", { children: "Working with this agent" }),
1423
- /* @__PURE__ */ h(S, {
1424
- capability: "agents.work.review_gate",
1425
- title: "Reviewing an agent's changes before they apply"
1426
- })
1427
- ] });
1428
- }
1429
- function H({ agentId: e, onBack: t, onOpenRecord: n }) {
1430
- let [r, i] = p("access"), { capabilities: a } = y(), { value: o, loading: s, error: c, refresh: l } = b((t) => t.agent(e), [e], {
1431
- refreshMs: 15e3,
1432
- subject: "this agent"
1433
- });
1434
- return s && !o ? /* @__PURE__ */ h(T, { what: "the agent" }) : o ? /* @__PURE__ */ h(C, {
1435
- capability: "agents.identity",
1436
- children: /* @__PURE__ */ g("section", {
1437
- className: "cp-detail studio-card",
1438
- children: [
1439
- /* @__PURE__ */ g("header", {
1440
- className: "cp-detail-header",
1441
- children: [/* @__PURE__ */ g("div", { children: [
1442
- /* @__PURE__ */ h("span", {
1443
- className: "card-kind",
1444
- children: "agent"
1445
- }),
1446
- /* @__PURE__ */ h("h2", { children: o.identity.name }),
1447
- /* @__PURE__ */ g("p", {
1448
- className: "cp-muted",
1449
- children: [
1450
- /* @__PURE__ */ h(M, {
1451
- value: o.identity.agent_id,
1452
- length: 24
1453
- }),
1454
- " · ",
1455
- /* @__PURE__ */ h(x, { status: String(o.identity.status) }),
1456
- " ·",
1457
- " ",
1458
- "registered by ",
1459
- o.identity.created_by,
1460
- " ",
1461
- /* @__PURE__ */ h(j, { ms: o.identity.created_at * 1e3 })
1462
- ]
1463
- }),
1464
- /* @__PURE__ */ g("p", {
1465
- className: "cp-muted",
1466
- children: [
1467
- "Application ",
1468
- /* @__PURE__ */ h("code", { children: o.identity.application_id }),
1469
- " · environment ",
1470
- /* @__PURE__ */ h("code", { children: o.identity.environment }),
1471
- " ·",
1472
- " ",
1473
- "contract ",
1474
- /* @__PURE__ */ h(M, { value: o.identity.application_revision })
1475
- ]
1476
- })
1477
- ] }), /* @__PURE__ */ h("button", {
1478
- className: "btn btn-ghost",
1479
- onClick: t,
1480
- children: "← All agents"
1481
- })]
1482
- }),
1483
- /* @__PURE__ */ g("div", {
1484
- className: "cp-stats",
1485
- children: [
1486
- /* @__PURE__ */ h(O, {
1487
- label: "Recent commits",
1488
- value: o.did.transactions.length
1489
- }),
1490
- /* @__PURE__ */ h(O, {
1491
- label: "Records changed",
1492
- value: o.did.records_changed
1493
- }),
1494
- /* @__PURE__ */ h(O, {
1495
- label: "Sessions",
1496
- value: o.doing.sessions.length
1497
- }),
1498
- /* @__PURE__ */ h(O, {
1499
- label: "Last activity",
1500
- value: o.did.last_activity_ms ? new Date(o.did.last_activity_ms).toLocaleString() : void 0
1501
- })
1502
- ]
1503
- }),
1504
- /* @__PURE__ */ h(N, {
1505
- active: r,
1506
- onSelect: i,
1507
- tabs: [
1508
- {
1509
- id: "access",
1510
- label: "What it can access"
1511
- },
1512
- {
1513
- id: "did",
1514
- label: "What it has done"
1515
- },
1516
- {
1517
- id: "doing",
1518
- label: "What it is doing"
1519
- },
1520
- {
1521
- id: "decisions",
1522
- label: "Authorization"
1523
- }
1524
- ]
1525
- }),
1526
- r === "access" && /* @__PURE__ */ h(B, { agent: o }),
1527
- r === "did" && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(w, { capability: "provenance.transactions" }), /* @__PURE__ */ h(z, {
1528
- agent: o,
1529
- onOpenRecord: n
1530
- })] }),
1531
- r === "doing" && /* @__PURE__ */ h(C, {
1532
- capability: "agents.sessions",
1533
- children: /* @__PURE__ */ h(V, { agent: o })
1534
- }),
1535
- r === "decisions" && (a.usable("agents.authorization_decisions") ? o.authorization_decisions.length === 0 ? /* @__PURE__ */ h(D, { children: "No authorization decision has been recorded for this agent." }) : /* @__PURE__ */ h("div", {
1536
- className: "table-shell",
1537
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
1538
- /* @__PURE__ */ h("th", { children: "When" }),
1539
- /* @__PURE__ */ h("th", { children: "Event" }),
1540
- /* @__PURE__ */ h("th", { children: "Actor" }),
1541
- /* @__PURE__ */ h("th", { children: "Capability" }),
1542
- /* @__PURE__ */ h("th", { children: "Decision" })
1543
- ] }) }), /* @__PURE__ */ h("tbody", { children: o.authorization_decisions.map((e, t) => /* @__PURE__ */ g("tr", { children: [
1544
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(j, { ms: e.at * 1e3 }) }),
1545
- /* @__PURE__ */ h("td", { children: e.event }),
1546
- /* @__PURE__ */ h("td", { children: e.actor }),
1547
- /* @__PURE__ */ h("td", { children: e.capability ? /* @__PURE__ */ h("code", { children: e.capability }) : /* @__PURE__ */ h("span", {
1548
- className: "cp-muted",
1549
- children: "—"
1550
- }) }),
1551
- /* @__PURE__ */ h("td", { children: e.decision === null ? /* @__PURE__ */ h("span", {
1552
- className: "cp-muted",
1553
- children: "—"
1554
- }) : /* @__PURE__ */ h(x, { status: e.decision ? "available" : "unsupported" }) })
1555
- ] }, `${e.event}-${e.at}-${t}`)) })] })
1556
- }) : /* @__PURE__ */ h(S, { capability: "agents.authorization_decisions" }))
1557
- ]
1558
- })
1559
- }) : /* @__PURE__ */ h(E, {
1560
- message: c,
1561
- onRetry: l
1562
- });
1563
- }
1564
- function U({ onConnected: e }) {
1565
- let { api: t, capabilities: n } = y(), [r, i] = p(""), [o, s] = p([]), [c, l] = p(!1), [u, d] = p(""), [f, m] = p(null), _ = [
1566
- "state:read",
1567
- "state:write",
1568
- "events:read",
1569
- "workloads:execute",
1570
- "applications:read"
1571
- ];
1572
- if (!n.usable("agents.register")) return /* @__PURE__ */ h(S, { capability: "agents.register" });
1573
- let v = async () => {
1574
- l(!0), d("");
1575
- try {
1576
- let n = await t.registerAgent(r.trim());
1577
- for (let e of o) await t.grantAgentCapability(n.id, e);
1578
- m({
1579
- id: n.id,
1580
- name: n.name
1581
- }), i(""), s([]), e();
1582
- } catch (e) {
1583
- d(a(e, "agent registration"));
1584
- } finally {
1585
- l(!1);
1586
- }
1587
- };
1588
- return /* @__PURE__ */ g("section", {
1589
- className: "studio-card cp-connect",
1590
- children: [
1591
- /* @__PURE__ */ h("span", {
1592
- className: "card-kind",
1593
- children: "Connect an agent"
1594
- }),
1595
- /* @__PURE__ */ h("p", {
1596
- className: "cp-muted",
1597
- 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."
1598
- }),
1599
- /* @__PURE__ */ g("label", { children: ["Agent name", /* @__PURE__ */ h("input", {
1600
- value: r,
1601
- onChange: (e) => i(e.target.value),
1602
- placeholder: "Customer Operations Agent"
1603
- })] }),
1604
- /* @__PURE__ */ g("fieldset", { children: [/* @__PURE__ */ h("legend", { children: "Capabilities" }), _.map((e) => /* @__PURE__ */ g("label", {
1605
- className: "cp-check",
1606
- children: [/* @__PURE__ */ h("input", {
1607
- type: "checkbox",
1608
- checked: o.includes(e),
1609
- onChange: (t) => s((n) => t.target.checked ? [...n, e] : n.filter((t) => t !== e))
1610
- }), /* @__PURE__ */ h("code", { children: e })]
1611
- }, e))] }),
1612
- /* @__PURE__ */ h(E, { message: u }),
1613
- /* @__PURE__ */ h("div", {
1614
- className: "cp-actions",
1615
- children: /* @__PURE__ */ h("button", {
1616
- className: "btn btn-primary",
1617
- disabled: c || !r.trim(),
1618
- onClick: () => void v(),
1619
- children: c ? "Connecting…" : "Connect agent"
1620
- })
1621
- }),
1622
- f && /* @__PURE__ */ g("div", {
1623
- className: "cp-connected",
1624
- children: [/* @__PURE__ */ g("p", { children: [
1625
- /* @__PURE__ */ h("strong", { children: f.name }),
1626
- " is registered as ",
1627
- /* @__PURE__ */ h("code", { children: f.id }),
1628
- "."
1629
- ] }), /* @__PURE__ */ h("p", {
1630
- className: "cp-muted",
1631
- children: "Give the agent this identity and an API key with the capabilities above. Connection details for the endpoint itself are under Developer."
1632
- })]
1633
- })
1634
- ]
1635
- });
1636
- }
1637
- function W({ onOpenRecord: e }) {
1638
- let { applicationId: t } = y(), [n, r] = p(""), { value: i, loading: a, error: o, refresh: s } = b((e) => e.agents(), [], {
1639
- enabled: !!t,
1640
- refreshMs: 2e4,
1641
- subject: "agents"
1642
- });
1643
- return t ? /* @__PURE__ */ h(P, {
1644
- eyebrow: "Agents",
1645
- title: "Agents",
1646
- 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.",
1647
- children: /* @__PURE__ */ g(C, {
1648
- capability: "agents.list",
1649
- children: [/* @__PURE__ */ h(E, {
1650
- message: o,
1651
- onRetry: s
1652
- }), n ? /* @__PURE__ */ h(H, {
1653
- agentId: n,
1654
- onBack: () => r(""),
1655
- onOpenRecord: e
1656
- }) : /* @__PURE__ */ g(m, { children: [
1657
- a && !i && /* @__PURE__ */ h(T, { what: "agents" }),
1658
- i && (i.agents.length === 0 ? /* @__PURE__ */ h(D, { children: "No agent is registered against this application yet." }) : /* @__PURE__ */ h("div", {
1659
- className: "cp-cards",
1660
- children: i.agents.map((e) => /* @__PURE__ */ g("button", {
1661
- className: "studio-card cp-agent-card",
1662
- onClick: () => r(e.agent_id),
1663
- children: [
1664
- /* @__PURE__ */ h("span", {
1665
- className: "card-kind",
1666
- children: "agent"
1667
- }),
1668
- /* @__PURE__ */ h("h3", { children: e.name }),
1669
- /* @__PURE__ */ g("p", {
1670
- className: "cp-muted",
1671
- children: [
1672
- /* @__PURE__ */ h(M, {
1673
- value: e.agent_id,
1674
- length: 20
1675
- }),
1676
- " · ",
1677
- /* @__PURE__ */ h(x, { status: String(e.status) })
1678
- ]
1679
- }),
1680
- /* @__PURE__ */ g("div", {
1681
- className: "cp-stats",
1682
- children: [
1683
- /* @__PURE__ */ h(O, {
1684
- label: "Sessions running",
1685
- value: e.sessions.running
1686
- }),
1687
- /* @__PURE__ */ h(O, {
1688
- label: "Recent commits",
1689
- value: e.activity.recent_transactions
1690
- }),
1691
- /* @__PURE__ */ h(O, {
1692
- label: "Records changed",
1693
- value: e.activity.records_changed
1694
- })
1695
- ]
1696
- }),
1697
- /* @__PURE__ */ h("p", {
1698
- className: "cp-capabilities",
1699
- children: e.capabilities.length ? e.capabilities.map((e) => /* @__PURE__ */ h("code", { children: e }, e)) : /* @__PURE__ */ h("span", {
1700
- className: "cp-muted",
1701
- children: "no capabilities granted"
1702
- })
1703
- }),
1704
- /* @__PURE__ */ g("p", {
1705
- className: "cp-muted",
1706
- children: ["Last activity ", /* @__PURE__ */ h(j, { ms: e.activity.last_activity_ms })]
1707
- })
1708
- ]
1709
- }, e.agent_id))
1710
- })),
1711
- /* @__PURE__ */ h(U, { onConnected: s })
1712
- ] })]
1713
- })
1714
- }) : /* @__PURE__ */ h(P, {
1715
- eyebrow: "Agents",
1716
- title: "Agents",
1717
- children: /* @__PURE__ */ h(D, { children: "Agents are registered against an application. Open Studio from a FeltDB application environment to see them." })
1718
- });
1719
- }
1720
- //#endregion
1721
- //#region src/control-plane/State.tsx
1722
- function G({ revisions: e, selected: t, onToggle: n }) {
1723
- return /* @__PURE__ */ h("div", {
1724
- className: "table-shell",
1725
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
1726
- /* @__PURE__ */ h("th", {}),
1727
- /* @__PURE__ */ h("th", { children: "#" }),
1728
- /* @__PURE__ */ h("th", { children: "State ID" }),
1729
- /* @__PURE__ */ h("th", { children: "Parent" }),
1730
- /* @__PURE__ */ h("th", { children: "Authority" }),
1731
- /* @__PURE__ */ h("th", { children: "Committed" })
1732
- ] }) }), /* @__PURE__ */ h("tbody", { children: e.map((e) => /* @__PURE__ */ g("tr", {
1733
- className: t.includes(e.state_id) ? "selected" : "",
1734
- children: [
1735
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("input", {
1736
- type: "checkbox",
1737
- "aria-label": `Select revision ${e.state_id}`,
1738
- checked: t.includes(e.state_id),
1739
- onChange: () => n(e.state_id)
1740
- }) }),
1741
- /* @__PURE__ */ h("td", { children: e.sequence }),
1742
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(M, {
1743
- value: e.state_id,
1744
- length: 16
1745
- }) }),
1746
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(M, {
1747
- value: e.parent_id,
1748
- length: 16
1749
- }) }),
1750
- /* @__PURE__ */ h("td", { children: e.authority }),
1751
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(j, { ms: e.timestamp_ms }) })
1752
- ]
1753
- }, e.state_id)) })] })
1754
- });
1755
- }
1756
- function K({ diff: e }) {
1757
- return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ g("p", {
1758
- className: "cp-muted",
1759
- children: [
1760
- e.from.sequence,
1761
- " → ",
1762
- e.to.sequence,
1763
- " · ",
1764
- e.relationship === "parent" ? "one step in this resource’s history" : e.relationship === "same-resource" ? "two points in one resource’s history" : "two different resources"
1765
- ]
1766
- }), e.changes.length === 0 ? /* @__PURE__ */ h(D, { children: "These two revisions hold the same content." }) : /* @__PURE__ */ h("div", {
1767
- className: "table-shell",
1768
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
1769
- /* @__PURE__ */ h("th", { children: "Path" }),
1770
- /* @__PURE__ */ h("th", { children: "Change" }),
1771
- /* @__PURE__ */ h("th", { children: "From" }),
1772
- /* @__PURE__ */ h("th", { children: "To" })
1773
- ] }) }), /* @__PURE__ */ h("tbody", { children: e.changes.map((e) => /* @__PURE__ */ g("tr", { children: [
1774
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(A, { path: e.path }) }),
1775
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(x, { status: e.kind }) }),
1776
- /* @__PURE__ */ h("td", {
1777
- className: "cp-value-old",
1778
- children: e.old_value === void 0 || e.old_value === null ? /* @__PURE__ */ h("span", {
1779
- className: "cp-muted",
1780
- children: "—"
1781
- }) : /* @__PURE__ */ h("code", { children: JSON.stringify(e.old_value) })
1782
- }),
1783
- /* @__PURE__ */ h("td", {
1784
- className: "cp-value-new",
1785
- children: e.new_value === void 0 || e.new_value === null ? /* @__PURE__ */ h("span", {
1786
- className: "cp-muted",
1787
- children: "—"
1788
- }) : /* @__PURE__ */ h("code", { children: JSON.stringify(e.new_value) })
1789
- })
1790
- ] }, o(e.path))) })] })
1791
- })] });
1792
- }
1793
- function q({ classification: e }) {
1794
- return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ g("p", {
1795
- className: "cp-attribution",
1796
- children: [
1797
- "Overall: ",
1798
- /* @__PURE__ */ h(x, { status: e.overall }),
1799
- e.overall === "independent" && " — both branches’ changes can be applied without either overwriting the other.",
1800
- e.overall === "convergent" && " — the branches reached the same result.",
1801
- e.overall === "conflict" && " — at least one path cannot take both branches. Reconciliation needs an explicit decision there."
1802
- ]
1803
- }), /* @__PURE__ */ h("div", {
1804
- className: "table-shell",
1805
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
1806
- /* @__PURE__ */ h("th", { children: "Path" }),
1807
- /* @__PURE__ */ h("th", { children: "Class" }),
1808
- /* @__PURE__ */ h("th", { children: "Base" }),
1809
- /* @__PURE__ */ h("th", { children: "Left" }),
1810
- /* @__PURE__ */ h("th", { children: "Right" })
1811
- ] }) }), /* @__PURE__ */ h("tbody", { children: e.path_conflicts.map((e) => /* @__PURE__ */ g("tr", {
1812
- className: e.classification === "conflict" ? "cp-row-conflict" : "",
1813
- children: [
1814
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(A, { path: e.path }) }),
1815
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(x, { status: e.classification }) }),
1816
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("code", { children: JSON.stringify(e.base_value ?? null) }) }),
1817
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("code", { children: JSON.stringify(e.left_value ?? null) }) }),
1818
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("code", { children: JSON.stringify(e.right_value ?? null) }) })
1819
- ]
1820
- }, o(e.path))) })] })
1821
- })] });
1822
- }
1823
- function ie({ base: e, left: t, right: n, onCommitted: r }) {
1824
- let { api: i } = y(), [s, c] = p("left"), [l, u] = p([]), [d, f] = p(null), [m, _] = p(null), [v, b] = p(""), [x, S] = p(!1), C = () => ({
1825
- base: e,
1826
- left: t,
1827
- right: n,
1828
- parent_choice: s,
1829
- overrides: l.filter((e) => e.value.trim() !== "").map((e) => {
1830
- try {
1831
- return {
1832
- path: e.path,
1833
- value: JSON.parse(e.value)
1834
- };
1835
- } catch {
1836
- return {
1837
- path: e.path,
1838
- value: e.value
1839
- };
1840
- }
1841
- })
1842
- }), w = async () => {
1843
- S(!0), b(""), _(null);
1844
- try {
1845
- let e = await i.reconciliationPlan(C());
1846
- f(e), u((t) => {
1847
- let n = new Set(t.map((e) => o(e.path)));
1848
- return [...t, ...e.unresolved.filter((e) => !n.has(o(e))).map((e) => ({
1849
- path: e,
1850
- value: ""
1851
- }))];
1852
- });
1853
- } catch (e) {
1854
- f(null), b(a(e, "the reconciliation plan"));
1855
- } finally {
1856
- S(!1);
1857
- }
1858
- }, T = async () => {
1859
- S(!0), b("");
1860
- try {
1861
- let e = await i.reconciliationExecute(C());
1862
- _(e.revision), r();
1863
- } catch (e) {
1864
- b(a(e, "the reconciliation"));
1865
- } finally {
1866
- S(!1);
1867
- }
1868
- };
1869
- return /* @__PURE__ */ g("section", {
1870
- className: "cp-reconcile",
1871
- children: [
1872
- /* @__PURE__ */ h("p", {
1873
- className: "cp-muted",
1874
- 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."
1875
- }),
1876
- /* @__PURE__ */ h("div", {
1877
- className: "cp-parent-choice",
1878
- role: "radiogroup",
1879
- "aria-label": "Parent branch",
1880
- children: ["left", "right"].map((e) => /* @__PURE__ */ g("label", {
1881
- className: "cp-check",
1882
- children: [
1883
- /* @__PURE__ */ h("input", {
1884
- type: "radio",
1885
- name: "parent",
1886
- checked: s === e,
1887
- onChange: () => c(e)
1888
- }),
1889
- "Start from ",
1890
- /* @__PURE__ */ h("strong", { children: e }),
1891
- " ",
1892
- /* @__PURE__ */ h(M, { value: e === "left" ? t : n })
1893
- ]
1894
- }, e))
1895
- }),
1896
- l.length > 0 && /* @__PURE__ */ g("div", {
1897
- className: "cp-overrides",
1898
- children: [/* @__PURE__ */ h("h4", { children: "Decided paths" }), l.map((e, t) => /* @__PURE__ */ g("label", { children: [/* @__PURE__ */ h(A, { path: e.path }), /* @__PURE__ */ h("input", {
1899
- value: e.value,
1900
- placeholder: "JSON value",
1901
- onChange: (e) => u((n) => n.map((n, r) => r === t ? {
1902
- ...n,
1903
- value: e.target.value
1904
- } : n))
1905
- })] }, o(e.path)))]
1906
- }),
1907
- /* @__PURE__ */ h(E, { message: v }),
1908
- /* @__PURE__ */ g("div", {
1909
- className: "cp-actions",
1910
- children: [/* @__PURE__ */ h("button", {
1911
- className: "btn btn-ghost",
1912
- disabled: x,
1913
- onClick: () => void w(),
1914
- children: x ? "Working…" : "Preview result"
1915
- }), /* @__PURE__ */ h("button", {
1916
- className: "btn btn-primary",
1917
- disabled: x || !d,
1918
- onClick: () => void T(),
1919
- children: "Commit reconciled revision"
1920
- })]
1921
- }),
1922
- d && /* @__PURE__ */ g("div", {
1923
- className: "studio-card",
1924
- children: [
1925
- /* @__PURE__ */ h("span", {
1926
- className: "card-kind",
1927
- children: "Preview"
1928
- }),
1929
- /* @__PURE__ */ g("div", {
1930
- className: "cp-stats",
1931
- children: [
1932
- /* @__PURE__ */ h(O, {
1933
- label: "Content identity",
1934
- value: `${d.preview.content_id.slice(0, 12)}…`
1935
- }),
1936
- /* @__PURE__ */ h(O, {
1937
- label: "Parent",
1938
- value: `#${d.preview.parent.sequence}`
1939
- }),
1940
- /* @__PURE__ */ h(O, {
1941
- label: "Undecided conflicts",
1942
- value: d.unresolved.length
1943
- })
1944
- ]
1945
- }),
1946
- d.unresolved.length > 0 && /* @__PURE__ */ g("p", {
1947
- className: "cp-notice",
1948
- children: [
1949
- d.unresolved.length,
1950
- " path",
1951
- d.unresolved.length === 1 ? "" : "s",
1952
- " conflict and have no decision:",
1953
- " ",
1954
- d.unresolved.map((e) => o(e)).join(", "),
1955
- ". Committing now takes the chosen branch\\u2019s value there."
1956
- ]
1957
- }),
1958
- /* @__PURE__ */ h(k, { value: d.preview.content })
1959
- ]
1960
- }),
1961
- m && /* @__PURE__ */ g("div", {
1962
- className: "studio-card cp-committed",
1963
- children: [
1964
- /* @__PURE__ */ h("span", {
1965
- className: "card-kind",
1966
- children: "Committed"
1967
- }),
1968
- /* @__PURE__ */ g("p", { children: [
1969
- "Revision ",
1970
- /* @__PURE__ */ h(M, {
1971
- value: String(m.state_id),
1972
- length: 20
1973
- }),
1974
- " at sequence ",
1975
- String(m.sequence),
1976
- ", authored by ",
1977
- /* @__PURE__ */ h("strong", { children: String(m.authority) }),
1978
- ", parent ",
1979
- /* @__PURE__ */ h(M, { value: String(m.parent_id) }),
1980
- "."
1981
- ] }),
1982
- /* @__PURE__ */ g("p", {
1983
- className: "cp-muted",
1984
- children: [
1985
- "Integrity ",
1986
- m.integrity_verified ? "verified" : "NOT verified",
1987
- "."
1988
- ]
1989
- })
1990
- ]
1991
- })
1992
- ]
1993
- });
1994
- }
1995
- function J() {
1996
- let [e, t] = p(""), [n, r] = p(""), [i, o] = p([]), [s, c] = p("history"), [l, u] = p(null), [d, f] = p(null), [_, v] = p(""), [x, S] = p(0), { value: w, loading: O, error: k, refresh: A } = b((t) => t.stateResources({
1997
- prefix: e,
1998
- limit: 200
1999
- }), [e, x], { subject: "state resources" }), { value: j, loading: M, refresh: F } = b((e) => e.stateHistory(n), [n, x], {
2000
- enabled: !!n,
2001
- subject: "this resource’s history"
2002
- }), { api: I, capabilities: ee } = y(), te = (e) => o((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e].slice(-3)), ne = async () => {
2003
- v("");
2004
- try {
2005
- u(await I.stateDiff(i[0], i[1])), c("diff");
2006
- } catch (e) {
2007
- u(null), v(a(e, "the diff"));
2008
- }
2009
- }, re = async () => {
2010
- v("");
2011
- try {
2012
- f(await I.stateConflicts(i[0], i[1], i[2])), c("conflicts");
2013
- } catch (e) {
2014
- f(null), v(a(e, "the conflict classification"));
2015
- }
2016
- };
2017
- return /* @__PURE__ */ h(P, {
2018
- eyebrow: "State",
2019
- title: "State",
2020
- description: "What changed, who changed it, what state it came from, why two states conflict, and what reconciliation would do.",
2021
- children: /* @__PURE__ */ h(C, {
2022
- capability: "state.history",
2023
- children: /* @__PURE__ */ g("div", {
2024
- className: "data-layout",
2025
- children: [/* @__PURE__ */ g("aside", {
2026
- className: "studio-card",
2027
- children: [/* @__PURE__ */ h("span", {
2028
- className: "card-kind",
2029
- children: "Resources"
2030
- }), /* @__PURE__ */ g(C, {
2031
- capability: "state.resources.list",
2032
- children: [
2033
- /* @__PURE__ */ h("input", {
2034
- "aria-label": "Resource prefix",
2035
- value: e,
2036
- onChange: (e) => t(e.target.value),
2037
- placeholder: "Filter by prefix…"
2038
- }),
2039
- O && !w && /* @__PURE__ */ h(T, { what: "resources" }),
2040
- w && (w.resources.length === 0 ? /* @__PURE__ */ g(D, { children: [
2041
- "No resource in this instance has revision history",
2042
- e ? ` under “${e}”` : "",
2043
- "."
2044
- ] }) : w.resources.map((e) => /* @__PURE__ */ g("button", {
2045
- className: e.resource === n ? "active" : "",
2046
- onClick: () => {
2047
- r(e.resource), o([]), u(null), f(null), c("history");
2048
- },
2049
- children: [e.resource, /* @__PURE__ */ g("small", { children: [
2050
- e.revisions,
2051
- " revisions",
2052
- e.head ? ` · head #${e.head.sequence}` : ""
2053
- ] })]
2054
- }, e.resource))),
2055
- /* @__PURE__ */ h(E, {
2056
- message: k,
2057
- onRetry: A
2058
- })
2059
- ]
2060
- })]
2061
- }), /* @__PURE__ */ h("section", {
2062
- className: "data-browser",
2063
- children: n ? /* @__PURE__ */ g(m, { children: [
2064
- /* @__PURE__ */ g("header", { children: [/* @__PURE__ */ g("div", { children: [
2065
- /* @__PURE__ */ h("span", {
2066
- className: "card-kind",
2067
- children: "resource"
2068
- }),
2069
- /* @__PURE__ */ h("h2", { children: n }),
2070
- j && /* @__PURE__ */ g("p", {
2071
- className: "cp-muted",
2072
- children: [
2073
- j.revisions.length,
2074
- " retained revisions · retention ",
2075
- j.retention.keep_last === null ? "keeps everything" : `keeps the last ${j.retention.keep_last}`,
2076
- " · horizon #",
2077
- j.retention.horizon
2078
- ]
2079
- })
2080
- ] }), /* @__PURE__ */ g("div", {
2081
- className: "cp-actions",
2082
- children: [
2083
- /* @__PURE__ */ h("button", {
2084
- className: "btn btn-ghost",
2085
- disabled: i.length !== 2,
2086
- onClick: () => void ne(),
2087
- children: "Diff 2 selected"
2088
- }),
2089
- /* @__PURE__ */ h("button", {
2090
- className: "btn btn-ghost",
2091
- disabled: i.length !== 3,
2092
- onClick: () => void re(),
2093
- children: "Classify 3 selected"
2094
- }),
2095
- /* @__PURE__ */ h("button", {
2096
- className: "btn btn-ghost",
2097
- disabled: i.length !== 3,
2098
- onClick: () => c("reconcile"),
2099
- children: "Reconcile"
2100
- })
2101
- ]
2102
- })] }),
2103
- /* @__PURE__ */ h("p", {
2104
- className: "cp-muted",
2105
- 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."
2106
- }),
2107
- /* @__PURE__ */ h(E, { message: _ }),
2108
- /* @__PURE__ */ h(N, {
2109
- active: s,
2110
- onSelect: c,
2111
- tabs: [
2112
- {
2113
- id: "history",
2114
- label: "History"
2115
- },
2116
- {
2117
- id: "diff",
2118
- label: "Diff"
2119
- },
2120
- {
2121
- id: "conflicts",
2122
- label: "Conflicts"
2123
- },
2124
- {
2125
- id: "reconcile",
2126
- label: "Reconciliation"
2127
- }
2128
- ]
2129
- }),
2130
- s === "history" && ee.status("state.branch.heads") === "unsupported" && /* @__PURE__ */ h("p", {
2131
- className: "cp-muted",
2132
- children: ee.note("state.branch.heads")
2133
- }),
2134
- s === "history" && (M && !j ? /* @__PURE__ */ h(T, { what: "history" }) : j && /* @__PURE__ */ h(G, {
2135
- revisions: j.revisions,
2136
- selected: i,
2137
- onToggle: te
2138
- })),
2139
- s === "diff" && /* @__PURE__ */ h(C, {
2140
- capability: "state.diff.semantic",
2141
- children: l ? /* @__PURE__ */ h(K, { diff: l }) : /* @__PURE__ */ h(D, { children: "Select two revisions and press “Diff 2 selected”." })
2142
- }),
2143
- s === "conflicts" && /* @__PURE__ */ h(C, {
2144
- capability: "state.conflict.classify",
2145
- children: d ? /* @__PURE__ */ h(q, { classification: d }) : /* @__PURE__ */ h(D, { children: "Select three revisions — base, left, right — and press “Classify 3 selected”." })
2146
- }),
2147
- s === "reconcile" && /* @__PURE__ */ h(C, {
2148
- capability: "state.reconciliation.execute",
2149
- children: i.length === 3 ? /* @__PURE__ */ h(C, {
2150
- capability: "state.reconciliation.plan",
2151
- children: /* @__PURE__ */ h(ie, {
2152
- base: i[0],
2153
- left: i[1],
2154
- right: i[2],
2155
- onCommitted: () => {
2156
- S((e) => e + 1), F();
2157
- }
2158
- })
2159
- }) : /* @__PURE__ */ h(D, { children: "Reconciliation needs three revisions: a common ancestor and the two branches to reconcile." })
2160
- })
2161
- ] }) : /* @__PURE__ */ h(D, { children: "Select a resource to see its history." })
2162
- })]
2163
- })
2164
- })
2165
- });
2166
- }
2167
- //#endregion
2168
- //#region src/control-plane/Operations.tsx
2169
- function Y({ transactionId: e, onClose: t }) {
2170
- let { value: n, loading: r, error: i, refresh: a } = b((t) => t.transaction(e), [e], { subject: "this transaction" });
2171
- return /* @__PURE__ */ g("section", {
2172
- className: "cp-detail studio-card",
2173
- children: [
2174
- /* @__PURE__ */ g("header", {
2175
- className: "cp-detail-header",
2176
- children: [/* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("span", {
2177
- className: "card-kind",
2178
- children: "transaction"
2179
- }), /* @__PURE__ */ h("h2", { children: /* @__PURE__ */ h(M, {
2180
- value: e,
2181
- length: 32
2182
- }) })] }), /* @__PURE__ */ h("button", {
2183
- className: "data-close",
2184
- onClick: t,
2185
- "aria-label": "Close transaction",
2186
- children: "×"
2187
- })]
2188
- }),
2189
- r && !n && /* @__PURE__ */ h(T, { what: "the transaction" }),
2190
- /* @__PURE__ */ h(E, {
2191
- message: i,
2192
- onRetry: a
2193
- }),
2194
- n && /* @__PURE__ */ g(m, { children: [
2195
- /* @__PURE__ */ g("div", {
2196
- className: "cp-stats",
2197
- children: [
2198
- /* @__PURE__ */ h(O, {
2199
- label: "Applied",
2200
- value: n.applied ? "Yes" : "No"
2201
- }),
2202
- /* @__PURE__ */ h(O, {
2203
- label: "Attribution held",
2204
- value: n.attribution_available ? "Yes" : "No",
2205
- hint: "Whether this commit is still inside the instance's bounded attribution window."
2206
- }),
2207
- /* @__PURE__ */ h(O, {
2208
- label: "Actor",
2209
- value: n.attribution?.subject ?? void 0
2210
- }),
2211
- /* @__PURE__ */ h(O, {
2212
- label: "Records",
2213
- value: n.attribution?.operations
2214
- })
2215
- ]
2216
- }),
2217
- /* @__PURE__ */ h("p", {
2218
- className: "cp-muted",
2219
- children: n.idempotent_replay
2220
- }),
2221
- n.applied && !n.attribution_available && /* @__PURE__ */ h("p", {
2222
- className: "cp-notice",
2223
- 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."
2224
- })
2225
- ] })
2226
- ]
2227
- });
2228
- }
2229
- function ae({ onOpenRecord: e }) {
2230
- let { capabilities: t } = y(), [n, r] = p(""), [i, a] = p(""), [o, s] = p(""), { value: c, loading: l, error: u, refresh: d } = b((e) => e.transactions({
2231
- subject: i || void 0,
2232
- collection: o || void 0,
2233
- limit: 100
2234
- }), [i, o], {
2235
- refreshMs: 8e3,
2236
- subject: "recent commits"
2237
- });
2238
- return /* @__PURE__ */ g(m, { children: [
2239
- /* @__PURE__ */ g("form", {
2240
- className: "cp-filter",
2241
- onSubmit: (e) => e.preventDefault(),
2242
- children: [
2243
- /* @__PURE__ */ h("input", {
2244
- "aria-label": "Actor",
2245
- value: i,
2246
- onChange: (e) => a(e.target.value),
2247
- placeholder: "Actor (subject)…"
2248
- }),
2249
- /* @__PURE__ */ h("input", {
2250
- "aria-label": "Collection",
2251
- value: o,
2252
- onChange: (e) => s(e.target.value),
2253
- placeholder: "Collection…"
2254
- }),
2255
- /* @__PURE__ */ h("button", {
2256
- className: "btn btn-ghost",
2257
- onClick: d,
2258
- children: "Refresh"
2259
- })
2260
- ]
2261
- }),
2262
- c && /* @__PURE__ */ g("p", {
2263
- className: "cp-muted",
2264
- children: [
2265
- c.window.note,
2266
- " Holding ",
2267
- c.window.held,
2268
- " of ",
2269
- c.window.capacity,
2270
- "."
2271
- ]
2272
- }),
2273
- /* @__PURE__ */ h(E, {
2274
- message: u,
2275
- onRetry: d
2276
- }),
2277
- l && !c && /* @__PURE__ */ h(T, { what: "commits" }),
2278
- c && (c.transactions.length === 0 ? /* @__PURE__ */ h(D, { children: "No commit in the window matches." }) : /* @__PURE__ */ h("div", {
2279
- className: "table-shell",
2280
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
2281
- /* @__PURE__ */ h("th", { children: "When" }),
2282
- /* @__PURE__ */ h("th", { children: "Actor" }),
2283
- /* @__PURE__ */ h("th", { children: "Application" }),
2284
- /* @__PURE__ */ h("th", { children: "Transaction" }),
2285
- /* @__PURE__ */ h("th", { children: "Records" }),
2286
- /* @__PURE__ */ h("th", { children: "Revision" }),
2287
- /* @__PURE__ */ h("th", { children: "Touched" })
2288
- ] }) }), /* @__PURE__ */ h("tbody", { children: c.transactions.map((t) => /* @__PURE__ */ g("tr", { children: [
2289
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(j, { ms: t.unix_ms }) }),
2290
- /* @__PURE__ */ h("td", { children: t.subject ? /* @__PURE__ */ h("strong", { children: t.subject }) : /* @__PURE__ */ h("span", {
2291
- className: "cp-muted",
2292
- children: "unnamed"
2293
- }) }),
2294
- /* @__PURE__ */ h("td", { children: t.application_id ? /* @__PURE__ */ h("code", { children: t.application_id }) : /* @__PURE__ */ h("span", {
2295
- className: "cp-muted",
2296
- children: "—"
2297
- }) }),
2298
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("button", {
2299
- className: "record-link",
2300
- onClick: () => r(t.transaction_id),
2301
- children: /* @__PURE__ */ h(M, {
2302
- value: t.transaction_id,
2303
- length: 16
2304
- })
2305
- }) }),
2306
- /* @__PURE__ */ h("td", { children: t.operations.toLocaleString() }),
2307
- /* @__PURE__ */ g("td", { children: [
2308
- t.base_revision,
2309
- " → ",
2310
- t.commit_revision
2311
- ] }),
2312
- /* @__PURE__ */ g("td", {
2313
- className: "cp-keys",
2314
- children: [t.keys.slice(0, 6).map((t) => {
2315
- let n = t.split(":"), r = n.pop(), i = n.pop() || "";
2316
- return /* @__PURE__ */ g("button", {
2317
- className: "reference-value",
2318
- onClick: () => e(i, r),
2319
- children: [
2320
- i,
2321
- "/",
2322
- r
2323
- ]
2324
- }, t);
2325
- }), t.operations > Math.min(t.keys.length, 6) && /* @__PURE__ */ g("span", {
2326
- className: "cp-muted",
2327
- children: [
2328
- " +",
2329
- t.operations - Math.min(t.keys.length, 6),
2330
- " more"
2331
- ]
2332
- })]
2333
- })
2334
- ] }, t.transaction_id)) })] })
2335
- })),
2336
- t.status("operations.correlation_id") === "unsupported" && /* @__PURE__ */ h("p", {
2337
- className: "cp-muted",
2338
- children: t.note("operations.correlation_id")
2339
- }),
2340
- n && t.usable("operations.transaction_status") && /* @__PURE__ */ h(Y, {
2341
- transactionId: n,
2342
- onClose: () => r("")
2343
- })
2344
- ] });
2345
- }
2346
- function X() {
2347
- let [e, t] = p(""), [n, r] = p(""), { value: i, loading: a, error: o, refresh: s } = b((t) => t.operations({
2348
- collection: e || void 0,
2349
- kind: n || void 0,
2350
- limit: 100
2351
- }), [e, n], {
2352
- refreshMs: 8e3,
2353
- subject: "recent operations"
2354
- });
2355
- return /* @__PURE__ */ g(m, { children: [
2356
- /* @__PURE__ */ g("form", {
2357
- className: "cp-filter",
2358
- onSubmit: (e) => e.preventDefault(),
2359
- children: [
2360
- /* @__PURE__ */ h("input", {
2361
- "aria-label": "Collection",
2362
- value: e,
2363
- onChange: (e) => t(e.target.value),
2364
- placeholder: "Collection…"
2365
- }),
2366
- /* @__PURE__ */ g("select", {
2367
- "aria-label": "Operation type",
2368
- value: n,
2369
- onChange: (e) => r(e.target.value),
2370
- children: [
2371
- /* @__PURE__ */ h("option", {
2372
- value: "",
2373
- children: "Any operation"
2374
- }),
2375
- /* @__PURE__ */ h("option", {
2376
- value: "insert",
2377
- children: "insert"
2378
- }),
2379
- /* @__PURE__ */ h("option", {
2380
- value: "update",
2381
- children: "update"
2382
- }),
2383
- /* @__PURE__ */ h("option", {
2384
- value: "delete",
2385
- children: "delete"
2386
- })
2387
- ]
2388
- }),
2389
- /* @__PURE__ */ h("button", {
2390
- className: "btn btn-ghost",
2391
- onClick: s,
2392
- children: "Refresh"
2393
- })
2394
- ]
2395
- }),
2396
- i && /* @__PURE__ */ h("p", {
2397
- className: "cp-muted",
2398
- children: i.retained.note
2399
- }),
2400
- /* @__PURE__ */ h(E, {
2401
- message: o,
2402
- onRetry: s
2403
- }),
2404
- a && !i && /* @__PURE__ */ h(T, { what: "operations" }),
2405
- i && (i.operations.length === 0 ? /* @__PURE__ */ h(D, { children: "No operation in the retained log matches." }) : /* @__PURE__ */ h("div", {
2406
- className: "table-shell",
2407
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
2408
- /* @__PURE__ */ h("th", { children: "When" }),
2409
- /* @__PURE__ */ h("th", { children: "Type" }),
2410
- /* @__PURE__ */ h("th", { children: "Collection" }),
2411
- /* @__PURE__ */ h("th", { children: "Key" }),
2412
- /* @__PURE__ */ h("th", { children: "Authority" }),
2413
- /* @__PURE__ */ h("th", { children: "Sequence" }),
2414
- /* @__PURE__ */ h("th", { children: "Revision" })
2415
- ] }) }), /* @__PURE__ */ h("tbody", { children: i.operations.map((e) => /* @__PURE__ */ g("tr", { children: [
2416
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(j, { ms: e.timestamp_ms }) }),
2417
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(x, { status: e.type }) }),
2418
- /* @__PURE__ */ h("td", { children: e.collection }),
2419
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("code", { children: e.key }) }),
2420
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(M, { value: e.instance_id }) }),
2421
- /* @__PURE__ */ h("td", { children: e.sequence }),
2422
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(M, { value: e.state_id }) })
2423
- ] }, `${e.instance_id}-${e.operation_id}-${e.sequence}`)) })] })
2424
- }))
2425
- ] });
2426
- }
2427
- function oe() {
2428
- let { baseUrl: e, capabilities: t } = y(), [n, r] = p([]), [i, a] = p(!1), [o, s] = p(""), [c, l] = p(""), d = f(null);
2429
- u(() => {
2430
- if (!t.usable("operations.events")) return;
2431
- let n = `${e.replace(/\/$/, "")}/v1/events`, i;
2432
- try {
2433
- i = new EventSource(n);
2434
- } catch {
2435
- s("The browser could not open the event stream.");
2436
- return;
2437
- }
2438
- return d.current = i, i.onopen = () => {
2439
- a(!0), s("");
2440
- }, i.onerror = () => {
2441
- a(!1), s("The event stream is not connected. It requires an endpoint reachable without an Authorization header.");
2442
- }, i.addEventListener("state.changed", (e) => {
2443
- try {
2444
- r((t) => [JSON.parse(e.data), ...t].slice(0, 200));
2445
- } catch {}
2446
- }), () => {
2447
- i.close(), d.current = null, a(!1);
2448
- };
2449
- }, [e, t]);
2450
- let _ = n.filter((e) => !c || JSON.stringify(e).toLowerCase().includes(c.toLowerCase()));
2451
- return /* @__PURE__ */ g(m, { children: [
2452
- /* @__PURE__ */ g("p", {
2453
- className: "cp-muted",
2454
- children: [
2455
- "Live state changes as they commit. ",
2456
- i ? "Connected." : "Not connected.",
2457
- " This is a stream, not a log: it shows what happens while the page is open."
2458
- ]
2459
- }),
2460
- /* @__PURE__ */ h("form", {
2461
- className: "cp-filter",
2462
- onSubmit: (e) => e.preventDefault(),
2463
- children: /* @__PURE__ */ h("input", {
2464
- "aria-label": "Search events",
2465
- value: c,
2466
- onChange: (e) => l(e.target.value),
2467
- placeholder: "Search resource, actor, id…"
2468
- })
2469
- }),
2470
- /* @__PURE__ */ h(E, { message: o }),
2471
- _.length === 0 ? /* @__PURE__ */ h(D, { children: i ? "No change has been observed since this page opened." : "No events." }) : /* @__PURE__ */ h("div", {
2472
- className: "table-shell",
2473
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
2474
- /* @__PURE__ */ h("th", { children: "When" }),
2475
- /* @__PURE__ */ h("th", { children: "Type" }),
2476
- /* @__PURE__ */ h("th", { children: "Resource" }),
2477
- /* @__PURE__ */ h("th", { children: "Id" }),
2478
- /* @__PURE__ */ h("th", { children: "Actor" })
2479
- ] }) }), /* @__PURE__ */ h("tbody", { children: _.map((e) => /* @__PURE__ */ g("tr", { children: [
2480
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(j, { ms: Number(e.timestamp) * 1e3 }) }),
2481
- /* @__PURE__ */ h("td", { children: String(e.type) }),
2482
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h("code", { children: String(e.resource) }) }),
2483
- /* @__PURE__ */ h("td", { children: String(e.resource_id) }),
2484
- /* @__PURE__ */ h("td", { children: String(e.actor) })
2485
- ] }, String(e.event_id))) })] })
2486
- })
2487
- ] });
2488
- }
2489
- function se({ onOpenRecord: e }) {
2490
- let [t, n] = p("transactions");
2491
- return /* @__PURE__ */ g(P, {
2492
- eyebrow: "Operations",
2493
- title: "Operations",
2494
- description: "What was asked for, what the engine did, and what is happening right now.",
2495
- children: [
2496
- /* @__PURE__ */ h(N, {
2497
- active: t,
2498
- onSelect: n,
2499
- tabs: [
2500
- {
2501
- id: "transactions",
2502
- label: "Transactions"
2503
- },
2504
- {
2505
- id: "operations",
2506
- label: "Operations"
2507
- },
2508
- {
2509
- id: "events",
2510
- label: "Events"
2511
- }
2512
- ]
2513
- }),
2514
- t === "transactions" && /* @__PURE__ */ g(C, {
2515
- capability: "provenance.transactions",
2516
- children: [/* @__PURE__ */ h(w, { capability: "operations.rejections" }), /* @__PURE__ */ h(ae, { onOpenRecord: e })]
2517
- }),
2518
- t === "operations" && /* @__PURE__ */ h(C, {
2519
- capability: "operations.recent",
2520
- children: /* @__PURE__ */ h(X, {})
2521
- }),
2522
- t === "events" && /* @__PURE__ */ g(C, {
2523
- capability: "operations.events",
2524
- children: [/* @__PURE__ */ h(oe, {}), /* @__PURE__ */ h(S, {
2525
- capability: "operations.audit_log",
2526
- title: "Searching past events"
2527
- })]
2528
- })
2529
- ]
2530
- });
2531
- }
2532
- //#endregion
2533
- //#region src/control-plane/Instance.tsx
2534
- function ce() {
2535
- let { value: e, loading: t, error: n, refresh: r } = b((e) => e.replication(), [], {
2536
- refreshMs: 1e4,
2537
- subject: "replication"
2538
- });
2539
- if (t && !e) return /* @__PURE__ */ h(P, {
2540
- eyebrow: "Distributed state",
2541
- title: "Replication",
2542
- children: /* @__PURE__ */ h(T, { what: "replication" })
2543
- });
2544
- if (!e) return /* @__PURE__ */ h(P, {
2545
- eyebrow: "Distributed state",
2546
- title: "Replication",
2547
- children: /* @__PURE__ */ h(E, {
2548
- message: n,
2549
- onRetry: r
2550
- })
2551
- });
2552
- let i = e.peers || [], a = e.causal_position || {}, o = e.retained_operation_floors || {};
2553
- return /* @__PURE__ */ h(P, {
2554
- eyebrow: "Distributed state",
2555
- title: "Replication",
2556
- description: "Authorities, causal position, and what replication still owes.",
2557
- children: /* @__PURE__ */ g(C, {
2558
- capability: "replication.health",
2559
- children: [
2560
- /* @__PURE__ */ g("section", {
2561
- className: "cp-stats",
2562
- children: [
2563
- /* @__PURE__ */ h(O, {
2564
- label: "Local authority",
2565
- value: e.local?.instance_id
2566
- }),
2567
- /* @__PURE__ */ h(O, {
2568
- label: "Peers",
2569
- value: i.length
2570
- }),
2571
- /* @__PURE__ */ h(O, {
2572
- label: "Sync successes",
2573
- value: e.health?.peer_sync_successes
2574
- }),
2575
- /* @__PURE__ */ h(O, {
2576
- label: "Sync failures",
2577
- value: e.health?.peer_sync_failures
2578
- }),
2579
- /* @__PURE__ */ h(O, {
2580
- label: "Operations sent",
2581
- value: e.health?.operations_sent
2582
- }),
2583
- /* @__PURE__ */ h(O, {
2584
- label: "Operations received",
2585
- value: e.health?.operations_received
2586
- }),
2587
- /* @__PURE__ */ h(O, {
2588
- label: "Operations compacted",
2589
- value: e.health?.operations_compacted
2590
- })
2591
- ]
2592
- }),
2593
- /* @__PURE__ */ g("section", {
2594
- className: "studio-card",
2595
- children: [
2596
- /* @__PURE__ */ h("span", {
2597
- className: "card-kind",
2598
- children: "Causal position"
2599
- }),
2600
- /* @__PURE__ */ h("p", {
2601
- className: "cp-muted",
2602
- 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."
2603
- }),
2604
- Object.keys(a).length === 0 ? /* @__PURE__ */ h(D, { children: "No origin has produced an operation this instance holds." }) : /* @__PURE__ */ h("div", {
2605
- className: "table-shell",
2606
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
2607
- /* @__PURE__ */ h("th", { children: "Origin" }),
2608
- /* @__PURE__ */ h("th", { children: "Highest held" }),
2609
- /* @__PURE__ */ h("th", { children: "Retained from" })
2610
- ] }) }), /* @__PURE__ */ h("tbody", { children: Object.entries(a).map(([e, t]) => /* @__PURE__ */ g("tr", { children: [
2611
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(M, {
2612
- value: e,
2613
- length: 20
2614
- }) }),
2615
- /* @__PURE__ */ h("td", { children: t }),
2616
- /* @__PURE__ */ h("td", { children: o[e] ?? /* @__PURE__ */ h("span", {
2617
- className: "cp-muted",
2618
- children: "—"
2619
- }) })
2620
- ] }, e)) })] })
2621
- })
2622
- ]
2623
- }),
2624
- /* @__PURE__ */ g("section", {
2625
- className: "studio-card",
2626
- children: [/* @__PURE__ */ h("span", {
2627
- className: "card-kind",
2628
- children: "Peers"
2629
- }), i.length === 0 ? /* @__PURE__ */ h(D, { children: "This instance has no peers. It is a single authority." }) : /* @__PURE__ */ h(k, { value: i })]
2630
- }),
2631
- /* @__PURE__ */ g("details", {
2632
- className: "cp-raw",
2633
- children: [/* @__PURE__ */ h("summary", { children: "Membership" }), /* @__PURE__ */ h(k, { value: e.membership })]
2634
- })
2635
- ]
2636
- })
2637
- });
2638
- }
2639
- function Z() {
2640
- let { value: e, loading: t, error: n, refresh: r } = b((e) => e.applications(), [], {
2641
- refreshMs: 2e4,
2642
- subject: "applications"
2643
- });
2644
- return /* @__PURE__ */ h(P, {
2645
- eyebrow: "Runtimes",
2646
- title: "Applications",
2647
- description: "Applications on this instance and the runtimes serving them.",
2648
- children: /* @__PURE__ */ g(C, {
2649
- capability: "applications.list",
2650
- children: [
2651
- /* @__PURE__ */ h(E, {
2652
- message: n,
2653
- onRetry: r
2654
- }),
2655
- t && !e && /* @__PURE__ */ h(T, { what: "applications" }),
2656
- e && (e.applications.length === 0 ? /* @__PURE__ */ h(D, { children: "No application is visible to you on this instance." }) : /* @__PURE__ */ h("div", {
2657
- className: "cp-cards",
2658
- children: e.applications.map((e) => /* @__PURE__ */ g("article", {
2659
- className: "studio-card",
2660
- children: [
2661
- /* @__PURE__ */ h("span", {
2662
- className: "card-kind",
2663
- children: "application"
2664
- }),
2665
- /* @__PURE__ */ h("h3", { children: String(e.application_name) }),
2666
- /* @__PURE__ */ g("p", {
2667
- className: "cp-muted",
2668
- children: [
2669
- /* @__PURE__ */ h(M, {
2670
- value: String(e.application_id),
2671
- length: 22
2672
- }),
2673
- " · tenant ",
2674
- String(e.tenant_name),
2675
- " ·",
2676
- " ",
2677
- /* @__PURE__ */ h(x, { status: String(e.status) })
2678
- ]
2679
- }),
2680
- /* @__PURE__ */ h("div", {
2681
- className: "table-shell",
2682
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
2683
- /* @__PURE__ */ h("th", { children: "Environment" }),
2684
- /* @__PURE__ */ h("th", { children: "Contract revision" }),
2685
- /* @__PURE__ */ h("th", { children: "Runtime" }),
2686
- /* @__PURE__ */ h("th", { children: "Started" })
2687
- ] }) }), /* @__PURE__ */ h("tbody", { children: (e.environments || []).map((e) => /* @__PURE__ */ g("tr", { children: [
2688
- /* @__PURE__ */ h("td", { children: String(e.environment) }),
2689
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(M, { value: String(e.revision_id) }) }),
2690
- /* @__PURE__ */ h("td", { children: e.runtime ? /* @__PURE__ */ h(x, { status: String(e.runtime.status) }) : /* @__PURE__ */ h("span", {
2691
- className: "cp-muted",
2692
- children: "not running"
2693
- }) }),
2694
- /* @__PURE__ */ h("td", { children: e.runtime ? /* @__PURE__ */ h(j, { ms: Number(e.runtime.started_at) * 1e3 }) : /* @__PURE__ */ h("span", {
2695
- className: "cp-muted",
2696
- children: "—"
2697
- }) })
2698
- ] }, String(e.environment))) })] })
2699
- })
2700
- ]
2701
- }, String(e.application_id)))
2702
- }))
2703
- ]
2704
- })
2705
- });
2706
- }
2707
- function le() {
2708
- let { value: e, loading: t, error: n, refresh: r } = b((e) => e.overview(), [], {
2709
- refreshMs: 5e3,
2710
- subject: "instance activity"
2711
- }), { value: i } = b((e) => e.replication(), [], {
2712
- refreshMs: 1e4,
2713
- subject: "replication health"
2714
- });
2715
- if (t && !e) return /* @__PURE__ */ h(P, {
2716
- eyebrow: "Health",
2717
- title: "Monitoring",
2718
- children: /* @__PURE__ */ h(T, { what: "activity" })
2719
- });
2720
- if (!e) return /* @__PURE__ */ h(P, {
2721
- eyebrow: "Health",
2722
- title: "Monitoring",
2723
- children: /* @__PURE__ */ h(E, {
2724
- message: n,
2725
- onRetry: r
2726
- })
2727
- });
2728
- let a = e.activity || {};
2729
- return /* @__PURE__ */ g(P, {
2730
- eyebrow: "Health",
2731
- title: "Monitoring",
2732
- description: "What this instance counts. Refreshed every five seconds.",
2733
- children: [/* @__PURE__ */ g(C, {
2734
- capability: "monitoring.metrics",
2735
- children: [
2736
- /* @__PURE__ */ g("section", {
2737
- className: "cp-stats",
2738
- children: [
2739
- /* @__PURE__ */ h(O, {
2740
- label: "Requests",
2741
- value: a.requests
2742
- }),
2743
- /* @__PURE__ */ h(O, {
2744
- label: "State reads",
2745
- value: a.state_reads
2746
- }),
2747
- /* @__PURE__ */ h(O, {
2748
- label: "State mutations",
2749
- value: a.state_mutations
2750
- }),
2751
- /* @__PURE__ */ h(O, {
2752
- label: "Event connections",
2753
- value: a.event_connections
2754
- })
2755
- ]
2756
- }),
2757
- /* @__PURE__ */ g("section", {
2758
- className: "cp-stats",
2759
- children: [
2760
- /* @__PURE__ */ h(O, {
2761
- label: "Requests shed",
2762
- value: a.requests_shed,
2763
- hint: "Refused at the door because the in-flight limit was reached."
2764
- }),
2765
- /* @__PURE__ */ h(O, {
2766
- label: "Deadlines exceeded",
2767
- value: a.request_deadlines_exceeded
2768
- }),
2769
- /* @__PURE__ */ h(O, {
2770
- label: "Authentication failures",
2771
- value: a.authentication_failures
2772
- }),
2773
- /* @__PURE__ */ h(O, {
2774
- label: "Admission slots free",
2775
- value: e.runtime?.admission_permits_available
2776
- })
2777
- ]
2778
- }),
2779
- /* @__PURE__ */ g("section", {
2780
- className: "cp-stats",
2781
- children: [
2782
- /* @__PURE__ */ h(O, {
2783
- label: "Records",
2784
- value: e.storage?.records
2785
- }),
2786
- /* @__PURE__ */ h(O, {
2787
- label: "State revisions",
2788
- value: e.storage?.state_revisions
2789
- }),
2790
- /* @__PURE__ */ h(O, {
2791
- label: "Authority revision",
2792
- value: e.authority?.authority_revision
2793
- }),
2794
- /* @__PURE__ */ h(O, {
2795
- label: "Replication backlog sent",
2796
- value: i?.health?.operations_sent
2797
- })
2798
- ]
2799
- }),
2800
- /* @__PURE__ */ g("section", {
2801
- className: "studio-card",
2802
- children: [/* @__PURE__ */ h("span", {
2803
- className: "card-kind",
2804
- children: "Audit writer"
2805
- }), /* @__PURE__ */ h(k, { value: e.storage?.audit })]
2806
- })
2807
- ]
2808
- }), /* @__PURE__ */ h(S, { capability: "monitoring.latency" })]
2809
- });
2810
- }
2811
- function Q() {
2812
- let { capabilities: e } = y(), { value: t, loading: n, error: r, refresh: i } = b((e) => e.overview(), [], { subject: "instance settings" }), { value: a } = b((e) => e.diagnostics(), [], { subject: "instance diagnostics" }), o = e.declaration;
2813
- return /* @__PURE__ */ g(P, {
2814
- eyebrow: "Instance",
2815
- title: "Settings",
2816
- description: "What this instance is configured as, and what it can do.",
2817
- children: [
2818
- /* @__PURE__ */ g(C, {
2819
- capability: "settings.instance",
2820
- children: [
2821
- /* @__PURE__ */ h(E, {
2822
- message: r,
2823
- onRetry: i
2824
- }),
2825
- n && !t && /* @__PURE__ */ h(T, { what: "settings" }),
2826
- t && /* @__PURE__ */ g(m, { children: [
2827
- /* @__PURE__ */ g("section", {
2828
- className: "studio-card",
2829
- children: [/* @__PURE__ */ h("span", {
2830
- className: "card-kind",
2831
- children: "Identity"
2832
- }), /* @__PURE__ */ g("div", {
2833
- className: "cp-stats",
2834
- children: [
2835
- /* @__PURE__ */ h(O, {
2836
- label: "Instance",
2837
- value: t.instance.instance_id
2838
- }),
2839
- /* @__PURE__ */ h(O, {
2840
- label: "Namespace",
2841
- value: t.instance.namespace
2842
- }),
2843
- /* @__PURE__ */ h(O, {
2844
- label: "Engine",
2845
- value: t.instance.engine_version
2846
- }),
2847
- /* @__PURE__ */ h(O, {
2848
- label: "Protocol",
2849
- value: t.instance.protocol_version
2850
- })
2851
- ]
2852
- })]
2853
- }),
2854
- /* @__PURE__ */ g("section", {
2855
- className: "studio-card",
2856
- children: [/* @__PURE__ */ h("span", {
2857
- className: "card-kind",
2858
- children: "Authority and storage"
2859
- }), /* @__PURE__ */ g("div", {
2860
- className: "cp-stats",
2861
- children: [
2862
- /* @__PURE__ */ h(O, {
2863
- label: "Authority revision",
2864
- value: t.authority.authority_revision
2865
- }),
2866
- /* @__PURE__ */ h(O, {
2867
- label: "Lease clock",
2868
- value: t.authority.lease_clock_healthy ? "Healthy" : "Degraded"
2869
- }),
2870
- /* @__PURE__ */ h(O, {
2871
- label: "Log recovery",
2872
- value: t.storage.log_recovery?.status
2873
- }),
2874
- /* @__PURE__ */ h(O, {
2875
- label: "Autonomous worker",
2876
- value: t.runtime.worker_enabled ? "Running" : "Off"
2877
- })
2878
- ]
2879
- })]
2880
- }),
2881
- /* @__PURE__ */ g("section", {
2882
- className: "studio-card",
2883
- children: [/* @__PURE__ */ h("span", {
2884
- className: "card-kind",
2885
- children: "Limits"
2886
- }), /* @__PURE__ */ g("div", {
2887
- className: "cp-stats",
2888
- children: [
2889
- /* @__PURE__ */ h(O, {
2890
- label: "Request deadline",
2891
- value: `${t.runtime.request_deadline_ms} ms`
2892
- }),
2893
- /* @__PURE__ */ h(O, {
2894
- label: "Admission slots free",
2895
- value: t.runtime.admission_permits_available
2896
- }),
2897
- /* @__PURE__ */ h(O, {
2898
- label: "Authentication",
2899
- value: t.instance.authentication_enabled ? "Enabled" : "Disabled"
2900
- })
2901
- ]
2902
- })]
2903
- }),
2904
- a && /* @__PURE__ */ g("details", {
2905
- className: "cp-raw",
2906
- children: [/* @__PURE__ */ h("summary", { children: "Diagnostics" }), /* @__PURE__ */ h(k, { value: a })]
2907
- })
2908
- ] })
2909
- ]
2910
- }),
2911
- /* @__PURE__ */ h(S, {
2912
- capability: "settings.mutate",
2913
- title: "Changing instance configuration"
2914
- }),
2915
- /* @__PURE__ */ g("section", {
2916
- className: "studio-card",
2917
- children: [
2918
- /* @__PURE__ */ h("span", {
2919
- className: "card-kind",
2920
- children: "Capability matrix"
2921
- }),
2922
- /* @__PURE__ */ h("p", {
2923
- className: "cp-muted",
2924
- 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."
2925
- }),
2926
- o ? /* @__PURE__ */ h("div", {
2927
- className: "table-shell",
2928
- children: /* @__PURE__ */ g("table", { children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", { children: [
2929
- /* @__PURE__ */ h("th", { children: "Capability" }),
2930
- /* @__PURE__ */ h("th", { children: "Area" }),
2931
- /* @__PURE__ */ h("th", { children: "Status" }),
2932
- /* @__PURE__ */ h("th", { children: "Surface" }),
2933
- /* @__PURE__ */ h("th", { children: "Note" })
2934
- ] }) }), /* @__PURE__ */ h("tbody", { children: o.capabilities.map((e) => /* @__PURE__ */ g("tr", { children: [
2935
- /* @__PURE__ */ g("td", { children: [
2936
- /* @__PURE__ */ h("strong", { children: e.title }),
2937
- /* @__PURE__ */ h("br", {}),
2938
- /* @__PURE__ */ h("code", { children: e.id })
2939
- ] }),
2940
- /* @__PURE__ */ h("td", { children: e.area }),
2941
- /* @__PURE__ */ h("td", { children: /* @__PURE__ */ h(x, { status: e.status }) }),
2942
- /* @__PURE__ */ h("td", {
2943
- className: "cp-keys",
2944
- children: e.surface.length === 0 ? /* @__PURE__ */ h("span", {
2945
- className: "cp-muted",
2946
- children: "none"
2947
- }) : e.surface.map((e) => /* @__PURE__ */ h("code", { children: e }, e))
2948
- }),
2949
- /* @__PURE__ */ h("td", {
2950
- className: "cp-note",
2951
- children: e.note || /* @__PURE__ */ h("span", {
2952
- className: "cp-muted",
2953
- children: "—"
2954
- })
2955
- })
2956
- ] }, e.id)) })] })
2957
- }) : /* @__PURE__ */ h(D, { children: "The instance did not answer with a capability declaration, so Studio is treating every capability as unavailable." })
2958
- ]
2959
- })
2960
- ]
2961
- });
2962
- }
2963
- function ue() {
2964
- let { value: e, loading: t, error: n, refresh: r } = b((e) => e.developer(), [], { subject: "developer access" });
2965
- if (t && !e) return /* @__PURE__ */ h(P, {
2966
- eyebrow: "Connect",
2967
- title: "Developer",
2968
- children: /* @__PURE__ */ h(T, { what: "connection details" })
2969
- });
2970
- if (!e) return /* @__PURE__ */ h(P, {
2971
- eyebrow: "Connect",
2972
- title: "Developer",
2973
- children: /* @__PURE__ */ h(E, {
2974
- message: n,
2975
- onRetry: r
2976
- })
2977
- });
2978
- let i = e.environment || {};
2979
- return /* @__PURE__ */ h(P, {
2980
- eyebrow: "Connect",
2981
- title: "Developer",
2982
- description: "How an application, an agent, or a person connects to this instance.",
2983
- children: /* @__PURE__ */ g(C, {
2984
- capability: "developer.access",
2985
- children: [
2986
- /* @__PURE__ */ g("section", {
2987
- className: "cp-stats",
2988
- children: [
2989
- /* @__PURE__ */ h(O, {
2990
- label: "Endpoint",
2991
- value: e.endpoint || "not advertised"
2992
- }),
2993
- /* @__PURE__ */ h(O, {
2994
- label: "Namespace",
2995
- value: e.namespace
2996
- }),
2997
- /* @__PURE__ */ h(O, {
2998
- label: "Protocol",
2999
- value: e.protocol_version
3000
- }),
3001
- /* @__PURE__ */ h(O, {
3002
- label: "Authentication",
3003
- value: e.authentication
3004
- })
3005
- ]
3006
- }),
3007
- /* @__PURE__ */ g("section", {
3008
- className: "studio-card",
3009
- children: [
3010
- /* @__PURE__ */ h("span", {
3011
- className: "card-kind",
3012
- children: "SDK"
3013
- }),
3014
- /* @__PURE__ */ h("p", {
3015
- className: "cp-muted",
3016
- children: e.sdk?.install
3017
- }),
3018
- /* @__PURE__ */ h("pre", {
3019
- className: "cp-json",
3020
- children: e.sdk?.snippet
3021
- })
3022
- ]
3023
- }),
3024
- /* @__PURE__ */ g("section", {
3025
- className: "studio-card",
3026
- children: [/* @__PURE__ */ h("span", {
3027
- className: "card-kind",
3028
- children: "CLI"
3029
- }), /* @__PURE__ */ h("pre", {
3030
- className: "cp-json",
3031
- children: e.cli?.snippet
3032
- })]
3033
- }),
3034
- /* @__PURE__ */ g("section", {
3035
- className: "studio-card",
3036
- children: [/* @__PURE__ */ h("span", {
3037
- className: "card-kind",
3038
- children: "Environment"
3039
- }), /* @__PURE__ */ h("pre", {
3040
- className: "cp-json",
3041
- children: Object.entries(i).map(([e, t]) => `${e}=${t || ""}`).join("\n")
3042
- })]
3043
- }),
3044
- /* @__PURE__ */ g("section", {
3045
- className: "studio-card",
3046
- children: [/* @__PURE__ */ h("span", {
3047
- className: "card-kind",
3048
- children: "Interface description"
3049
- }), /* @__PURE__ */ g("p", {
3050
- className: "cp-muted",
3051
- children: [
3052
- "The instance describes its own application interface at ",
3053
- /* @__PURE__ */ h("code", { children: e.openapi }),
3054
- ". An agent that can read it needs nothing else to discover what this application declares and what it may call."
3055
- ]
3056
- })]
3057
- }),
3058
- /* @__PURE__ */ h(S, { capability: "developer.tool_projection" })
3059
- ]
3060
- })
3061
- });
3062
- }
3063
- //#endregion
3064
- export { N as C, y as D, v as E, b as O, x as S, S as T, T as _, Q as a, A as b, W as c, F as d, C as f, k as g, M as h, ce as i, R as l, E as m, ue as n, se as o, D as p, le as r, J as s, Z as t, L as u, P as v, j as w, O as x, w as y };