@feltdb/core 0.12.0 → 0.12.2

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