@feltdb/core 0.7.3 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +25 -0
  2. package/dist/application-development.d.ts +78 -0
  3. package/dist/application-development.d.ts.map +1 -0
  4. package/dist/application-development.js +153 -0
  5. package/dist/application-manifest.d.ts +6 -1
  6. package/dist/application-manifest.d.ts.map +1 -1
  7. package/dist/application-manifest.js +10 -3
  8. package/dist/canonical-application.d.ts +27 -0
  9. package/dist/canonical-application.d.ts.map +1 -0
  10. package/dist/canonical-application.js +46 -0
  11. package/dist/cli/ai-model-config.js +97 -0
  12. package/dist/cli/cli.js +1 -1
  13. package/dist/cli/commands.js +664 -120
  14. package/dist/cli/index.js +1 -1
  15. package/dist/cli/managed-environment.js +6 -0
  16. package/dist/cli/managed-project.js +6 -0
  17. package/dist/cli/proposal-client.js +63 -0
  18. package/dist/cli/publish-engine.js +165 -0
  19. package/dist/cli/source-sync.js +183 -0
  20. package/dist/create/cli.js +11 -2
  21. package/dist/create/create.js +38 -16
  22. package/dist/create/managed-account.js +82 -11
  23. package/dist/create/package-versions.js +1 -1
  24. package/dist/create/server-source/crates/feltdb/src/application.rs +41 -1
  25. package/dist/create/server-source/crates/feltdb/src/authority_failover.rs +84 -6
  26. package/dist/create/server-source/crates/feltdb/src/bin/feltdb_node.rs +126 -38
  27. package/dist/create/server-source/crates/feltdb/src/distributed_transactions.rs +72 -34
  28. package/dist/create/server-source/crates/feltdb/src/lib.rs +20 -2
  29. package/dist/create/server-source/crates/feltdb-server/src/app_state.rs +12 -24
  30. package/dist/create/server-source/crates/feltdb-server/src/application_contract.rs +11 -3
  31. package/dist/create/server-source/crates/feltdb-server/src/authenticated_principal.rs +0 -1
  32. package/dist/create/server-source/crates/feltdb-server/src/certification_harness.rs +23 -22
  33. package/dist/create/server-source/crates/feltdb-server/src/delegation_token.rs +5 -15
  34. package/dist/create/server-source/crates/feltdb-server/src/durable_operations.rs +13 -28
  35. package/dist/create/server-source/crates/feltdb-server/src/identity.rs +111 -3
  36. package/dist/create/server-source/crates/feltdb-server/src/key_management.rs +28 -7
  37. package/dist/create/server-source/crates/feltdb-server/src/lib.rs +5 -5
  38. package/dist/create/server-source/crates/feltdb-server/src/main.rs +1960 -143
  39. package/dist/create/server-source/crates/feltdb-server/src/managed_diagnostics.rs +10 -30
  40. package/dist/create/server-source/crates/feltdb-server/src/membership_policy.rs +12 -4
  41. package/dist/create/server-source/crates/feltdb-server/src/request_telemetry.rs +8 -6
  42. package/dist/create/server-source/crates/feltdb-server/src/snapshot_cursor.rs +10 -14
  43. package/dist/create/server-source/crates/feltdb-server/src/tenancy.rs +195 -13
  44. package/dist/create/server-source/crates/feltdb-server/src/tenant_policies.rs +9 -21
  45. package/dist/create/server-source/crates/feltdb-server/src/transaction_idempotency.rs +5 -3
  46. package/dist/create/server-source/crates/feltdb-server/src/transaction_recovery.rs +9 -8
  47. package/dist/create/server-source/crates/feltdb-server/tests/revision_recovery_integration_test.rs +1 -4
  48. package/dist/create/template/default-project/README.md +57 -0
  49. package/dist/create/template/default-project/agents/activity-assistant.ts +18 -0
  50. package/dist/create/template/default-project/agents/project-assistant.ts +19 -0
  51. package/dist/create/template/default-project/capabilities/activity-summary.ts +14 -0
  52. package/dist/create/template/default-project/capabilities/project-search.ts +16 -0
  53. package/dist/create/template/default-project/capabilities/project-summary.ts +15 -0
  54. package/dist/create/template/default-project/feltdb.flow +174 -0
  55. package/dist/create/template/default-project/src/App.tsx +20 -0
  56. package/dist/create/template/default-project/src/context/AuthContext.tsx +27 -0
  57. package/dist/create/template/default-project/src/feltdb.ts +87 -0
  58. package/dist/create/template/default-project/src/index.tsx +14 -0
  59. package/dist/create/template/default-project/src/pages/Activity.tsx +7 -0
  60. package/dist/create/template/default-project/src/pages/Agents.tsx +15 -0
  61. package/dist/create/template/default-project/src/pages/Dashboard.tsx +17 -0
  62. package/dist/create/template/default-project/src/pages/Invitations.tsx +11 -0
  63. package/dist/create/template/default-project/src/pages/Projects.tsx +11 -0
  64. package/dist/create/template/default-project/src/pages/SignIn.tsx +8 -0
  65. package/dist/create/template/default-project/src/pages/SignUp.tsx +8 -0
  66. package/dist/create/template/default-project/src/styles-application.css +21 -0
  67. package/dist/create/template/default-project/src/styles.css +1 -0
  68. package/dist/create/template/default-project/workflows/agent-assisted-summary.ts +1 -0
  69. package/dist/create/template/default-project/workflows/invitation.ts +30 -0
  70. package/dist/create/template/default-project/workflows/project-created.ts +2 -0
  71. package/dist/db.d.ts +49 -1
  72. package/dist/db.d.ts.map +1 -1
  73. package/dist/db.js +77 -0
  74. package/dist/error-codes.d.ts +20 -1
  75. package/dist/error-codes.d.ts.map +1 -1
  76. package/dist/error-codes.js +25 -0
  77. package/dist/flowspec.d.ts +1 -0
  78. package/dist/flowspec.d.ts.map +1 -1
  79. package/dist/flowspec.js +66 -11
  80. package/dist/http-client.d.ts +135 -14
  81. package/dist/http-client.d.ts.map +1 -1
  82. package/dist/http-client.js +79 -31
  83. package/dist/http-db.d.ts +15 -2
  84. package/dist/http-db.d.ts.map +1 -1
  85. package/dist/http-db.js +113 -5
  86. package/dist/index-core.d.ts +5 -0
  87. package/dist/index-core.d.ts.map +1 -1
  88. package/dist/index-core.js +5 -0
  89. package/dist/module-intent.d.ts +37 -0
  90. package/dist/module-intent.d.ts.map +1 -0
  91. package/dist/module-intent.js +81 -0
  92. package/dist/module.d.ts +76 -0
  93. package/dist/module.d.ts.map +1 -0
  94. package/dist/module.js +61 -0
  95. package/dist/proposal.d.ts +161 -0
  96. package/dist/proposal.d.ts.map +1 -0
  97. package/dist/proposal.js +232 -0
  98. package/dist/studio/app.d.ts +5 -1
  99. package/dist/studio/app.d.ts.map +1 -1
  100. package/dist/studio/components/ApplicationDesigner.d.ts +2 -1
  101. package/dist/studio/components/ApplicationDesigner.d.ts.map +1 -1
  102. package/dist/studio/components/AskFeltDB.d.ts +21 -0
  103. package/dist/studio/components/AskFeltDB.d.ts.map +1 -0
  104. package/dist/studio/components/ContractInspector.d.ts +7 -0
  105. package/dist/studio/components/ContractInspector.d.ts.map +1 -0
  106. package/dist/studio/components/ManagedInstancePanel.d.ts.map +1 -1
  107. package/dist/studio/components/ManagedInstancePanel.js +1 -5
  108. package/dist/studio/components/ModuleExplorer.d.ts +6 -0
  109. package/dist/studio/components/ModuleExplorer.d.ts.map +1 -0
  110. package/dist/studio/components/ProposalBrowser.d.ts +12 -0
  111. package/dist/studio/components/ProposalBrowser.d.ts.map +1 -0
  112. package/dist/studio/components/StateExplorer.d.ts +6 -7
  113. package/dist/studio/components/StateExplorer.d.ts.map +1 -1
  114. package/dist/studio/components/index.d.ts +4 -0
  115. package/dist/studio/components/index.d.ts.map +1 -1
  116. package/dist/studio/components/index.js +4 -4
  117. package/dist/studio/components-CNSNrmA9.js +2787 -0
  118. package/dist/studio/index.js +214 -157
  119. package/dist/studio/studio.css +1 -1
  120. package/dist/studio/utils/index.d.ts +2 -0
  121. package/dist/studio/utils/index.d.ts.map +1 -1
  122. package/dist/studio/utils/index.js +14 -12
  123. package/dist/studio/utils/managed-instance.d.ts +0 -4
  124. package/dist/studio/utils/managed-instance.d.ts.map +1 -1
  125. package/dist/studio/utils/managed-instance.js +0 -4
  126. package/dist/studio/utils/proposal-api.d.ts +53 -0
  127. package/dist/studio/utils/proposal-api.d.ts.map +1 -0
  128. package/dist/studio/utils/proposal-api.js +91 -0
  129. package/dist/studio/utils/service-api.d.ts +81 -0
  130. package/dist/studio/utils/service-api.d.ts.map +1 -0
  131. package/dist/studio/utils/service-api.js +51 -0
  132. package/dist/studio-app/assets/dist-CCOk39Uc.js +1 -0
  133. package/dist/studio-app/assets/{feltdb_wasm-DVKsw75S.js → feltdb_wasm-CSB6KVgw.js} +1 -1
  134. package/dist/studio-app/assets/feltdb_wasm_bg-Dd1fnO9U.wasm +0 -0
  135. package/dist/studio-app/assets/index-Bncji3aN.js +43 -0
  136. package/dist/studio-app/assets/{index-C1GWyazR.css → index-yazaWMUN.css} +1 -1
  137. package/dist/studio-app/assets/lib-B2_7fcn7.js +69 -0
  138. package/dist/studio-app/assets/worker-CARZ5g7K.js +69 -0
  139. package/dist/studio-app/index.html +2 -2
  140. package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
  141. package/dist/workspace/local-development-authority.d.ts +3 -0
  142. package/dist/workspace/local-development-authority.d.ts.map +1 -1
  143. package/dist/workspace/local-development-authority.js +124 -2
  144. package/package.json +1 -1
  145. package/dist/studio/components-Dxuhrv8_.js +0 -1832
  146. package/dist/studio-app/assets/feltdb_wasm_bg-DNyNf0yy.wasm +0 -0
  147. package/dist/studio-app/assets/index-B5tnmvSD.js +0 -28
@@ -1,1832 +0,0 @@
1
- import "./KeyManagementPanel-DZuSeWBK.js";
2
- import "./components/ManagedInstancePanel.js";
3
- import e, { useCallback as t, useEffect as n, useMemo as r, useRef as i, useState as a } from "react";
4
- import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
5
- import { createFeltDB as l, diffFlowSpec as u, emptyFlowSpec as d, formatFlowSpec as f, parseFlowSpec as p, planFlowSpecMigration as m, validateFlowSpec as h } from "@feltdb/core";
6
- //#region src/components/OverviewDashboard.tsx
7
- function g({ stats: e }) {
8
- return e ? /* @__PURE__ */ c("div", {
9
- className: "overview-dashboard",
10
- children: [/* @__PURE__ */ c("div", {
11
- className: "dashboard-header",
12
- children: [/* @__PURE__ */ s("h1", { children: "FeltDB Studio" }), /* @__PURE__ */ s("div", {
13
- className: "namespace-badge",
14
- children: e.namespace
15
- })]
16
- }), /* @__PURE__ */ c("div", {
17
- className: "dashboard-grid",
18
- children: [
19
- /* @__PURE__ */ c("div", {
20
- className: "stat-card",
21
- children: [
22
- /* @__PURE__ */ s("label", { children: "Runtime" }),
23
- /* @__PURE__ */ s("div", {
24
- className: `status-indicator ${e.status}`,
25
- children: "●"
26
- }),
27
- /* @__PURE__ */ s("span", { children: e.status.charAt(0).toUpperCase() + e.status.slice(1) })
28
- ]
29
- }),
30
- /* @__PURE__ */ c("div", {
31
- className: "stat-card",
32
- children: [/* @__PURE__ */ s("label", { children: "Storage" }), /* @__PURE__ */ c("span", { children: [
33
- e.persistence,
34
- " / ",
35
- e.storageBackend
36
- ] })]
37
- }),
38
- /* @__PURE__ */ c("div", {
39
- className: "stat-card",
40
- children: [/* @__PURE__ */ s("label", { children: "Peers" }), /* @__PURE__ */ s("span", {
41
- className: "stat-number",
42
- children: e.peersCount
43
- })]
44
- }),
45
- /* @__PURE__ */ c("div", {
46
- className: "stat-card",
47
- children: [/* @__PURE__ */ s("label", { children: "Objects" }), /* @__PURE__ */ s("span", {
48
- className: "stat-number",
49
- children: e.objectsCount
50
- })]
51
- }),
52
- /* @__PURE__ */ c("div", {
53
- className: "stat-card",
54
- children: [/* @__PURE__ */ s("label", { children: "Operations" }), /* @__PURE__ */ s("span", {
55
- className: "stat-number",
56
- children: e.operationsCount
57
- })]
58
- }),
59
- /* @__PURE__ */ c("div", {
60
- className: "stat-card",
61
- children: [/* @__PURE__ */ s("label", { children: "Capabilities" }), /* @__PURE__ */ s("span", {
62
- className: "stat-number",
63
- children: e.capabilitiesCount
64
- })]
65
- }),
66
- /* @__PURE__ */ c("div", {
67
- className: "stat-card",
68
- children: [/* @__PURE__ */ s("label", { children: "Executions" }), /* @__PURE__ */ s("span", {
69
- className: "stat-number",
70
- children: e.executionsCount
71
- })]
72
- }),
73
- /* @__PURE__ */ c("div", {
74
- className: "stat-card",
75
- children: [/* @__PURE__ */ s("label", { children: "Workflows" }), /* @__PURE__ */ s("span", {
76
- className: "stat-number",
77
- children: e.workflowsCount
78
- })]
79
- }),
80
- /* @__PURE__ */ c("div", {
81
- className: "stat-card",
82
- children: [/* @__PURE__ */ s("label", { children: "Agents" }), /* @__PURE__ */ s("span", {
83
- className: "stat-number",
84
- children: e.agentsCount
85
- })]
86
- }),
87
- /* @__PURE__ */ c("div", {
88
- className: "stat-card",
89
- children: [/* @__PURE__ */ s("label", { children: "Conflicts" }), /* @__PURE__ */ s("span", {
90
- className: "stat-number",
91
- children: e.conflictsCount
92
- })]
93
- })
94
- ]
95
- })]
96
- }) : /* @__PURE__ */ s("div", {
97
- className: "overview-dashboard loading",
98
- children: /* @__PURE__ */ s("p", { children: "Loading runtime information..." })
99
- });
100
- }
101
- //#endregion
102
- //#region src/hooks/index.ts
103
- function _(e, t = "default") {
104
- let [r, i] = a(null);
105
- return n(() => {
106
- if (!e) {
107
- i(null);
108
- return;
109
- }
110
- let n = e.runtime(), r = n.runtime === "browser" ? "browser" : n.runtime === "node" ? "self-hosted" : "remote";
111
- i({
112
- db: e,
113
- connected: !0,
114
- namespace: t,
115
- instanceId: e.instanceId?.() || "unknown",
116
- environment: r
117
- });
118
- }, [e, t]), r;
119
- }
120
- function v(e, t = null, r = "default") {
121
- let [i, o] = a(null);
122
- return n(() => {
123
- if (!e) {
124
- o(null);
125
- return;
126
- }
127
- let n = async () => {
128
- try {
129
- let n = e.runtime(), i = e.health(), a = e.sync?.(), s = t ? await Promise.all(t.collections.map((t) => e.collection(t.name).count())) : [];
130
- o({
131
- namespace: r,
132
- status: i?.status || "healthy",
133
- storageBackend: n.storage,
134
- persistence: n.persistent ? "durable" : "volatile",
135
- peersCount: a?.connected_peers?.length || 0,
136
- objectsCount: s.reduce((e, t) => e + t, 0),
137
- operationsCount: a?.sequence || 0,
138
- capabilitiesCount: t?.capabilities.length || 0,
139
- executionsCount: await e.collection("_flow_executions").count() || await e.collection("Decision").count(),
140
- workflowsCount: t?.workflows.length || 0,
141
- agentsCount: t?.agents.length || 0,
142
- conflictsCount: a?.conflicts_detected || 0
143
- });
144
- } catch (e) {
145
- console.error("Failed to fetch dashboard stats:", e);
146
- }
147
- };
148
- n();
149
- let i = setInterval(n, 5e3);
150
- return () => clearInterval(i);
151
- }, [
152
- e,
153
- t,
154
- r
155
- ]), i;
156
- }
157
- function y(e) {
158
- let [r, i] = a(null), [o, s] = a(!1), [c, l] = a(null), u = t(async () => {
159
- if (e) {
160
- s(!0), l(null);
161
- try {
162
- let t = e.health();
163
- i(t);
164
- } catch (e) {
165
- l(e instanceof Error ? e.message : "Failed to fetch diagnostics");
166
- } finally {
167
- s(!1);
168
- }
169
- }
170
- }, [e]);
171
- return n(() => {
172
- u();
173
- }, [e, u]), {
174
- diagnostics: r,
175
- loading: o,
176
- error: c,
177
- refresh: u
178
- };
179
- }
180
- function b(e, t) {
181
- let [r, i] = a([]), [o, s] = a(!0), [c, l] = a(null);
182
- return n(() => {
183
- if (e) {
184
- s(!0), l(null);
185
- try {
186
- let n = e.collection(t).subscribe((e) => {
187
- i(e), s(!1);
188
- });
189
- return () => n();
190
- } catch (e) {
191
- l(e instanceof Error ? e.message : "Failed to load collection"), s(!1);
192
- }
193
- }
194
- }, [e, t]), {
195
- items: r,
196
- loading: o,
197
- error: c
198
- };
199
- }
200
- function x(e) {
201
- let [t, r] = a([]);
202
- return n(() => {
203
- if (!e) {
204
- r([]);
205
- return;
206
- }
207
- let t = () => {
208
- try {
209
- let t = e.sync?.();
210
- r(t?.connected_peers || []);
211
- } catch (e) {
212
- console.error("Failed to fetch peers:", e);
213
- }
214
- };
215
- t();
216
- let n = setInterval(t, 2e3);
217
- return () => clearInterval(n);
218
- }, [e]), t;
219
- }
220
- function S(e, t) {
221
- let [r, i] = a(null), [o, s] = a(!1), [c, l] = a(null);
222
- return n(() => {
223
- if (!e || !t) {
224
- i(null);
225
- return;
226
- }
227
- s(!0), l(null), (async () => {
228
- try {
229
- let n = e.provenance(t);
230
- i(n);
231
- } catch (e) {
232
- l(e instanceof Error ? e.message : "Failed to fetch provenance");
233
- } finally {
234
- s(!1);
235
- }
236
- })();
237
- }, [e, t]), {
238
- provenance: r,
239
- loading: o,
240
- error: c
241
- };
242
- }
243
- //#endregion
244
- //#region src/components/StateExplorer.tsx
245
- function C({ db: e, definition: t, namespace: n, bridgedItems: r }) {
246
- let { items: i, loading: o, error: l } = b(e, t.name), u = r ?? i, [d, f] = a(null);
247
- return /* @__PURE__ */ c("article", {
248
- className: "state-collection studio-card",
249
- children: [
250
- /* @__PURE__ */ c("header", { children: [/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("span", {
251
- className: "card-kind",
252
- children: "collection"
253
- }), /* @__PURE__ */ s("h2", { children: t.name })] }), /* @__PURE__ */ s("strong", { children: r ? r.length : o ? "…" : i.length })] }),
254
- l && /* @__PURE__ */ s("p", {
255
- className: "runtime-error",
256
- children: l
257
- }),
258
- (!o || r) && !u.length && /* @__PURE__ */ s("div", {
259
- className: "model-empty compact",
260
- children: "No records yet. Mutations will appear here live."
261
- }),
262
- u.map((e, r) => {
263
- let i = String(e.id ?? e.key ?? r);
264
- return /* @__PURE__ */ c("button", {
265
- className: "state-row",
266
- onClick: () => f(d === r ? null : r),
267
- children: [
268
- /* @__PURE__ */ c("span", { children: [/* @__PURE__ */ s("b", { children: i }), /* @__PURE__ */ c("small", { children: [
269
- "flow://",
270
- n,
271
- "/",
272
- t.name,
273
- "/",
274
- i
275
- ] })] }),
276
- /* @__PURE__ */ s("span", { children: d === r ? "−" : "+" }),
277
- d === r && /* @__PURE__ */ s("pre", { children: JSON.stringify(e, null, 2) })
278
- ]
279
- }, i);
280
- })
281
- ]
282
- });
283
- }
284
- function w({ db: e, model: t, namespace: r = "default", applicationUrl: o = "", developmentSession: l }) {
285
- let u = i(null), [d, f] = a(null);
286
- return n(() => {
287
- if (!o) return;
288
- let e = new URL(o).origin, t = () => {
289
- l?.sessionId && u.current?.contentWindow?.postMessage({
290
- type: "feltdb:dev-session",
291
- session: l
292
- }, e), u.current?.contentWindow?.postMessage({
293
- type: "feltdb:studio:read",
294
- requestId: "live"
295
- }, e);
296
- }, n = (n) => {
297
- n.origin === e && (n.data?.type === "feltdb:studio:ready" && t(), n.data?.type === "feltdb:studio:data" && f(n.data.records));
298
- };
299
- window.addEventListener("message", n);
300
- let r = window.setInterval(t, 1500);
301
- return () => {
302
- window.removeEventListener("message", n), window.clearInterval(r);
303
- };
304
- }, [o, l]), /* @__PURE__ */ c("div", {
305
- className: "studio-model-page",
306
- children: [
307
- /* @__PURE__ */ c("header", { children: [
308
- /* @__PURE__ */ s("span", {
309
- className: "eyebrow",
310
- children: "Observe"
311
- }),
312
- /* @__PURE__ */ s("h1", { children: "Data" }),
313
- /* @__PURE__ */ s("p", { children: "Live application records grouped by collection. Select a record to inspect every field." })
314
- ] }),
315
- o && /* @__PURE__ */ s("iframe", {
316
- ref: u,
317
- className: "studio-data-bridge",
318
- src: o,
319
- title: "FeltDB application data bridge",
320
- onLoad: () => {
321
- let e = new URL(o).origin;
322
- l?.sessionId && u.current?.contentWindow?.postMessage({
323
- type: "feltdb:dev-session",
324
- session: l
325
- }, e), u.current?.contentWindow?.postMessage({
326
- type: "feltdb:studio:read",
327
- requestId: "initial"
328
- }, e);
329
- }
330
- }),
331
- /* @__PURE__ */ c("div", {
332
- className: "model-summary",
333
- children: [
334
- /* @__PURE__ */ c("span", { children: [t?.collections.length ?? 0, " collections"] }),
335
- /* @__PURE__ */ c("span", { children: [r, " namespace"] }),
336
- /* @__PURE__ */ s("span", { children: e ? "runtime connected" : "runtime unavailable" })
337
- ]
338
- }),
339
- /* @__PURE__ */ c("div", {
340
- className: "state-grid",
341
- children: [t?.collections.map((t) => /* @__PURE__ */ s(C, {
342
- db: e ?? null,
343
- definition: t,
344
- namespace: r,
345
- bridgedItems: d?.[t.name]
346
- }, t.name)), !t?.collections.length && /* @__PURE__ */ c("div", {
347
- className: "model-empty",
348
- children: [
349
- "No collection model is loaded. Open Studio through ",
350
- /* @__PURE__ */ s("code", { children: "feltdb dev" }),
351
- " to load the active project."
352
- ]
353
- })]
354
- })
355
- ]
356
- });
357
- }
358
- //#endregion
359
- //#region src/components/ReferenceExplorer.tsx
360
- function T(e) {
361
- let t = e.trim().replace(/^flow:\/\//, "").split("/").filter(Boolean);
362
- return e.startsWith("flow://") ? t.length >= 3 ? {
363
- collection: t[t.length - 2],
364
- id: t[t.length - 1]
365
- } : null : t.length >= 2 ? {
366
- collection: t[t.length - 2],
367
- id: t[t.length - 1]
368
- } : null;
369
- }
370
- function E({ db: e, model: t, namespace: n = "default" }) {
371
- let [r, i] = a(""), [o, l] = a(), [u, d] = a("Enter a reference to resolve live state."), f = async () => {
372
- let t = T(r);
373
- if (!t || !e) {
374
- l(void 0), d(e ? "Use Collection/id or flow://namespace/Collection/id." : "Runtime unavailable.");
375
- return;
376
- }
377
- let n = await e.collection(t.collection).get(t.id);
378
- l(n), d(n ? "Materialized locally" : "Reference is valid but is not materialized locally");
379
- };
380
- return /* @__PURE__ */ c("div", {
381
- className: "studio-model-page",
382
- children: [
383
- /* @__PURE__ */ c("header", { children: [
384
- /* @__PURE__ */ s("span", {
385
- className: "eyebrow",
386
- children: "Observe"
387
- }),
388
- /* @__PURE__ */ s("h1", { children: "References" }),
389
- /* @__PURE__ */ s("p", { children: "Resolve stable Flow references directly into their materialized state." })
390
- ] }),
391
- /* @__PURE__ */ c("div", {
392
- className: "reference-query",
393
- children: [/* @__PURE__ */ s("input", {
394
- value: r,
395
- onChange: (e) => i(e.target.value),
396
- onKeyDown: (e) => {
397
- e.key === "Enter" && f();
398
- },
399
- placeholder: `flow://${n}/Collection/id`
400
- }), /* @__PURE__ */ s("button", {
401
- onClick: () => void f(),
402
- children: "Resolve"
403
- })]
404
- }),
405
- /* @__PURE__ */ c("div", {
406
- className: "reference-layout",
407
- children: [/* @__PURE__ */ c("article", {
408
- className: "studio-card",
409
- children: [/* @__PURE__ */ s("span", {
410
- className: "card-kind",
411
- children: "Known collections"
412
- }), t?.collections.map((e) => /* @__PURE__ */ c("button", {
413
- className: "reference-example",
414
- onClick: () => i(`flow://${n}/${e.name}/id`),
415
- children: [e.name, /* @__PURE__ */ c("small", { children: [e.fields.length, " fields"] })]
416
- }, e.name))]
417
- }), /* @__PURE__ */ c("article", {
418
- className: "studio-card reference-result",
419
- children: [
420
- /* @__PURE__ */ s("span", {
421
- className: "card-kind",
422
- children: "Resolution"
423
- }),
424
- /* @__PURE__ */ s("h2", { children: u }),
425
- o !== void 0 && /* @__PURE__ */ s("pre", { children: JSON.stringify(o, null, 2) })
426
- ]
427
- })]
428
- })
429
- ]
430
- });
431
- }
432
- //#endregion
433
- //#region src/components/OperationsExplorer.tsx
434
- function D({ db: e, namespace: t = "default" }) {
435
- let [r, i] = a([]), [o, l] = a("all");
436
- n(() => {
437
- if (!e) return;
438
- let t = !0, n = async () => {
439
- let n = await e.auditEvents();
440
- t && i(n.slice().reverse());
441
- };
442
- n();
443
- let r = setInterval(() => void n(), 1e3);
444
- return () => {
445
- t = !1, clearInterval(r);
446
- };
447
- }, [e]);
448
- let u = r.filter((e) => o === "all" || e.type === o);
449
- return /* @__PURE__ */ c("div", {
450
- className: "studio-model-page",
451
- children: [
452
- /* @__PURE__ */ c("header", { children: [
453
- /* @__PURE__ */ s("span", {
454
- className: "eyebrow",
455
- children: "Observe"
456
- }),
457
- /* @__PURE__ */ s("h1", { children: "Operations" }),
458
- /* @__PURE__ */ s("p", { children: "The runtime's durable local mutation log—not a simulated activity feed." })
459
- ] }),
460
- /* @__PURE__ */ c("div", {
461
- className: "model-summary",
462
- children: [
463
- /* @__PURE__ */ c("span", { children: [r.length, " recorded"] }),
464
- /* @__PURE__ */ c("span", { children: [t, " namespace"] }),
465
- /* @__PURE__ */ c("select", {
466
- value: o,
467
- onChange: (e) => l(e.target.value),
468
- children: [
469
- /* @__PURE__ */ s("option", {
470
- value: "all",
471
- children: "All mutations"
472
- }),
473
- /* @__PURE__ */ s("option", {
474
- value: "put",
475
- children: "Writes"
476
- }),
477
- /* @__PURE__ */ s("option", {
478
- value: "delete",
479
- children: "Deletes"
480
- })
481
- ]
482
- })
483
- ]
484
- }),
485
- /* @__PURE__ */ s("div", {
486
- className: "table-shell",
487
- children: /* @__PURE__ */ c("table", {
488
- className: "operations-table",
489
- children: [/* @__PURE__ */ s("thead", { children: /* @__PURE__ */ c("tr", { children: [
490
- /* @__PURE__ */ s("th", { children: "Sequence" }),
491
- /* @__PURE__ */ s("th", { children: "Mutation" }),
492
- /* @__PURE__ */ s("th", { children: "Collection" }),
493
- /* @__PURE__ */ s("th", { children: "Key" }),
494
- /* @__PURE__ */ s("th", { children: "Timestamp" })
495
- ] }) }), /* @__PURE__ */ c("tbody", { children: [u.map((e) => /* @__PURE__ */ c("tr", { children: [
496
- /* @__PURE__ */ s("td", { children: e.sequence }),
497
- /* @__PURE__ */ s("td", { children: /* @__PURE__ */ s("span", {
498
- className: `event-pill ${e.type}`,
499
- children: e.type
500
- }) }),
501
- /* @__PURE__ */ s("td", { children: e.collection }),
502
- /* @__PURE__ */ s("td", { children: /* @__PURE__ */ s("code", { children: e.key }) }),
503
- /* @__PURE__ */ s("td", { children: new Date(e.timestamp).toLocaleString() })
504
- ] }, `${e.sequence}-${e.key}`)), !u.length && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", {
505
- colSpan: 5,
506
- className: "empty-message",
507
- children: "No matching mutations yet. Create or change application state to populate this stream."
508
- }) })] })]
509
- })
510
- })
511
- ]
512
- });
513
- }
514
- //#endregion
515
- //#region src/components/PeerMap.tsx
516
- function O({ peers: t = [], localInstance: n = "local" }) {
517
- return /* @__PURE__ */ c("div", {
518
- className: "studio-model-page",
519
- children: [
520
- /* @__PURE__ */ c("header", { children: [
521
- /* @__PURE__ */ s("span", {
522
- className: "eyebrow",
523
- children: "Observe"
524
- }),
525
- /* @__PURE__ */ s("h1", { children: "Peers" }),
526
- /* @__PURE__ */ s("p", { children: "The live topology participating in this application's convergence fabric." })
527
- ] }),
528
- /* @__PURE__ */ c("div", {
529
- className: "peer-topology",
530
- children: [/* @__PURE__ */ c("article", {
531
- className: "peer-node local",
532
- children: [
533
- /* @__PURE__ */ s("span", { children: "this instance" }),
534
- /* @__PURE__ */ s("h2", { children: n }),
535
- /* @__PURE__ */ s("small", { children: "online · authoritative local state" })
536
- ]
537
- }), t.map((t) => /* @__PURE__ */ c(e.Fragment, { children: [/* @__PURE__ */ s("i", { className: "peer-link" }), /* @__PURE__ */ c("article", {
538
- className: "peer-node",
539
- children: [
540
- /* @__PURE__ */ s("span", { children: "connected peer" }),
541
- /* @__PURE__ */ s("h2", { children: t }),
542
- /* @__PURE__ */ s("small", { children: "online · exchanging operations" })
543
- ]
544
- })] }, t))]
545
- }),
546
- !t.length && /* @__PURE__ */ s("div", {
547
- className: "model-empty",
548
- children: "This embedded runtime is operating independently. Its state remains durable and can converge when a network peer is attached."
549
- })
550
- ]
551
- });
552
- }
553
- //#endregion
554
- //#region src/components/CapabilityExplorer.tsx
555
- function k({ model: e }) {
556
- let t = e?.capabilities ?? [];
557
- return /* @__PURE__ */ c("div", {
558
- className: "studio-model-page",
559
- children: [
560
- /* @__PURE__ */ c("header", { children: [
561
- /* @__PURE__ */ s("span", {
562
- className: "eyebrow",
563
- children: "Design"
564
- }),
565
- /* @__PURE__ */ s("h1", { children: "Capabilities" }),
566
- /* @__PURE__ */ c("p", { children: [
567
- "Declared authority available to workflows and autonomous agents in ",
568
- e?.app ?? "this application",
569
- "."
570
- ] })
571
- ] }),
572
- /* @__PURE__ */ c("div", {
573
- className: "model-summary",
574
- children: [/* @__PURE__ */ c("span", { children: [t.length, " declared"] }), /* @__PURE__ */ c("span", { children: [new Set(t.flatMap((e) => e.statements)).size, " permission rules"] })]
575
- }),
576
- /* @__PURE__ */ c("div", {
577
- className: "studio-card-grid",
578
- children: [t.map((e) => /* @__PURE__ */ c("article", {
579
- className: "studio-card capability-card",
580
- children: [
581
- /* @__PURE__ */ s("div", {
582
- className: "card-kind",
583
- children: "capability"
584
- }),
585
- /* @__PURE__ */ s("h2", { children: e.name }),
586
- /* @__PURE__ */ s("div", {
587
- className: "statement-list",
588
- children: e.statements.map((e) => {
589
- let [t, ...n] = e.split(" ");
590
- return /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("b", { children: t }), /* @__PURE__ */ s("code", { children: n.join(" ") })] }, e);
591
- })
592
- })
593
- ]
594
- }, e.name)), !t.length && /* @__PURE__ */ s("div", {
595
- className: "model-empty",
596
- children: "No capabilities are declared in the current project model."
597
- })]
598
- })
599
- ]
600
- });
601
- }
602
- //#endregion
603
- //#region src/components/ExecutionViewer.tsx
604
- function A({ db: e, name: t, label: n }) {
605
- let { items: r } = b(e, t);
606
- return r.length ? /* @__PURE__ */ c("section", { children: [/* @__PURE__ */ c("h2", { children: [n, /* @__PURE__ */ s("span", { children: r.length })] }), /* @__PURE__ */ s("div", {
607
- className: "execution-list",
608
- children: r.map((e, r) => /* @__PURE__ */ c("article", {
609
- className: "execution-row",
610
- children: [
611
- /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("b", { children: String(e.name ?? e.workflow ?? e.incident_id ?? e.id ?? n) }), /* @__PURE__ */ s("small", { children: t })] }),
612
- /* @__PURE__ */ s("span", {
613
- className: "event-pill put",
614
- children: String(e.status ?? e.state ?? "materialized")
615
- }),
616
- /* @__PURE__ */ s("pre", { children: JSON.stringify(e, null, 2) })
617
- ]
618
- }, String(e.id ?? r)))
619
- })] }) : null;
620
- }
621
- function j({ db: e, model: t }) {
622
- return /* @__PURE__ */ c("div", {
623
- className: "studio-model-page",
624
- children: [
625
- /* @__PURE__ */ c("header", { children: [
626
- /* @__PURE__ */ s("span", {
627
- className: "eyebrow",
628
- children: "Observe"
629
- }),
630
- /* @__PURE__ */ s("h1", { children: "Executions" }),
631
- /* @__PURE__ */ s("p", { children: "Capability work, workflow runs, assignments, and agent decisions as inspectable state." })
632
- ] }),
633
- /* @__PURE__ */ c("div", {
634
- className: "model-summary",
635
- children: [/* @__PURE__ */ c("span", { children: [t?.workflows.length ?? 0, " workflow definitions"] }), /* @__PURE__ */ c("span", { children: [t?.agents.length ?? 0, " autonomous agents"] })]
636
- }),
637
- /* @__PURE__ */ s(A, {
638
- db: e ?? null,
639
- name: "_flow_executions",
640
- label: "Capability executions"
641
- }),
642
- /* @__PURE__ */ s(A, {
643
- db: e ?? null,
644
- name: "_flow_workflow_runs",
645
- label: "Workflow runs"
646
- }),
647
- /* @__PURE__ */ s(A, {
648
- db: e ?? null,
649
- name: "Assignment",
650
- label: "Materialized assignments"
651
- }),
652
- /* @__PURE__ */ s(A, {
653
- db: e ?? null,
654
- name: "Decision",
655
- label: "Agent decisions"
656
- }),
657
- /* @__PURE__ */ s(A, {
658
- db: e ?? null,
659
- name: "_flow_agent_executions",
660
- label: "Agent executions"
661
- }),
662
- /* @__PURE__ */ c("div", {
663
- className: "model-empty execution-empty",
664
- children: [
665
- "Execution sections appear as soon as their state is committed. Defined workflows: ",
666
- t?.workflows.map((e) => e.name).join(", ") || "none",
667
- "."
668
- ]
669
- })
670
- ]
671
- });
672
- }
673
- //#endregion
674
- //#region src/components/ConflictExplorer.tsx
675
- function M({ db: e, diagnostics: t }) {
676
- let n = (() => {
677
- try {
678
- return e?.sync();
679
- } catch {
680
- return;
681
- }
682
- })(), r = n?.conflicts_detected ?? 0;
683
- return /* @__PURE__ */ c("div", {
684
- className: "studio-model-page",
685
- children: [
686
- /* @__PURE__ */ c("header", { children: [
687
- /* @__PURE__ */ s("span", {
688
- className: "eyebrow",
689
- children: "Observe"
690
- }),
691
- /* @__PURE__ */ s("h1", { children: "Conflicts" }),
692
- /* @__PURE__ */ s("p", { children: "Concurrent mutations detected while replicas converge." })
693
- ] }),
694
- /* @__PURE__ */ c("div", {
695
- className: "metric-grid",
696
- children: [
697
- /* @__PURE__ */ c("article", { children: [/* @__PURE__ */ s("b", { children: r }), /* @__PURE__ */ s("span", { children: "detected" })] }),
698
- /* @__PURE__ */ c("article", { children: [/* @__PURE__ */ s("b", { children: n?.pending_operations ?? 0 }), /* @__PURE__ */ s("span", { children: "pending operations" })] }),
699
- /* @__PURE__ */ c("article", { children: [/* @__PURE__ */ s("b", { children: n?.connected_peers.length ?? 0 }), /* @__PURE__ */ s("span", { children: "connected peers" })] })
700
- ]
701
- }),
702
- /* @__PURE__ */ c("article", {
703
- className: "studio-card",
704
- children: [
705
- /* @__PURE__ */ s("span", {
706
- className: "card-kind",
707
- children: "Convergence"
708
- }),
709
- /* @__PURE__ */ s("h2", { children: r ? "Conflict activity detected" : "No conflicts detected" }),
710
- /* @__PURE__ */ s("p", { children: t?.sync.connected ? "The fabric is connected and applying causal ordering." : "The local replica is independent; conflict detection begins when operations converge with peers." }),
711
- /* @__PURE__ */ s("code", { children: "Causal ordering → deterministic materialization → auditable resolution" })
712
- ]
713
- })
714
- ]
715
- });
716
- }
717
- //#endregion
718
- //#region src/components/WorkflowVisualizer.tsx
719
- function N({ model: t }) {
720
- let n = t?.workflows ?? [], [r, i] = a(), l = n.find((e) => e.name === r) ?? n[0];
721
- return /* @__PURE__ */ c("div", {
722
- className: "studio-model-page",
723
- children: [/* @__PURE__ */ c("header", { children: [
724
- /* @__PURE__ */ s("span", {
725
- className: "eyebrow",
726
- children: "Design"
727
- }),
728
- /* @__PURE__ */ s("h1", { children: "Workflows" }),
729
- /* @__PURE__ */ s("p", { children: "Durable state transitions declared by the application model." })
730
- ] }), /* @__PURE__ */ c("div", {
731
- className: "split-browser",
732
- children: [/* @__PURE__ */ s("aside", { children: n.map((e) => /* @__PURE__ */ c("button", {
733
- className: e.name === l?.name ? "active" : "",
734
- onClick: () => i(e.name),
735
- children: [/* @__PURE__ */ s("strong", { children: e.name }), /* @__PURE__ */ c("span", { children: [e.steps.length, " steps"] })]
736
- }, e.name)) }), /* @__PURE__ */ s("section", { children: l ? /* @__PURE__ */ c(o, { children: [
737
- /* @__PURE__ */ s("div", {
738
- className: "card-kind",
739
- children: "workflow"
740
- }),
741
- /* @__PURE__ */ s("h2", { children: l.name }),
742
- l.parameters.length > 0 && /* @__PURE__ */ c("code", {
743
- className: "signature",
744
- children: [
745
- "(",
746
- l.parameters,
747
- ")"
748
- ]
749
- }),
750
- /* @__PURE__ */ s("div", {
751
- className: "workflow-track",
752
- children: l.steps.map((t, n) => /* @__PURE__ */ c(e.Fragment, { children: [/* @__PURE__ */ c("article", { children: [/* @__PURE__ */ s("span", { children: n + 1 }), /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("strong", { children: t.name }), t.statements.map((e) => /* @__PURE__ */ s("code", { children: e }, e))] })] }), n < l.steps.length - 1 && /* @__PURE__ */ s("i", { children: "→" })] }, t.name))
753
- })
754
- ] }) : /* @__PURE__ */ s("div", {
755
- className: "model-empty",
756
- children: "No workflows are declared."
757
- }) })]
758
- })]
759
- });
760
- }
761
- //#endregion
762
- //#region src/components/AgentExplorer.tsx
763
- function P({ model: e }) {
764
- let t = e?.agents ?? [], [n, r] = a(), i = t.find((e) => e.name === n) ?? t[0];
765
- return /* @__PURE__ */ c("div", {
766
- className: "studio-model-page",
767
- children: [/* @__PURE__ */ c("header", { children: [
768
- /* @__PURE__ */ s("span", {
769
- className: "eyebrow",
770
- children: "Design"
771
- }),
772
- /* @__PURE__ */ s("h1", { children: "Agents" }),
773
- /* @__PURE__ */ s("p", { children: "Autonomous participants whose authority and workflows are part of the model." })
774
- ] }), /* @__PURE__ */ c("div", {
775
- className: "split-browser",
776
- children: [/* @__PURE__ */ s("aside", { children: t.map((e) => /* @__PURE__ */ c("button", {
777
- className: e.name === i?.name ? "active" : "",
778
- onClick: () => r(e.name),
779
- children: [/* @__PURE__ */ s("strong", { children: e.name }), /* @__PURE__ */ c("span", { children: [e.statements.length, " bindings"] })]
780
- }, e.name)) }), /* @__PURE__ */ s("section", { children: i ? /* @__PURE__ */ s(o, { children: /* @__PURE__ */ c("div", {
781
- className: "agent-orbit",
782
- children: [/* @__PURE__ */ c("div", {
783
- className: "agent-core",
784
- children: [/* @__PURE__ */ s("span", { children: "agent" }), /* @__PURE__ */ s("strong", { children: i.name })]
785
- }), i.statements.map((e) => /* @__PURE__ */ c("div", {
786
- className: "agent-binding",
787
- children: [/* @__PURE__ */ s("span", { children: e.split(" ")[0] }), /* @__PURE__ */ s("strong", { children: e.split(" ").slice(1).join(" ") })]
788
- }, e))]
789
- }) }) : /* @__PURE__ */ s("div", {
790
- className: "model-empty",
791
- children: "No agents are declared."
792
- }) })]
793
- })]
794
- });
795
- }
796
- //#endregion
797
- //#region src/components/ProvenanceViewer.tsx
798
- function F({ db: e, namespace: t = "default", reference: r }) {
799
- let [i, l] = a(r ?? ""), [u, d] = a(null), [f, p] = a([]), [m, h] = a("Enter a Flow reference to trace it.");
800
- n(() => {
801
- r && l(r);
802
- }, [r]);
803
- let g = async () => {
804
- if (!(!e || !i)) try {
805
- let t = e.provenance(i);
806
- d(t), h("Causal graph resolved");
807
- } catch {
808
- d(null);
809
- let t = await e.auditEvents(), n = i.split("/"), r = n[n.length - 1] ?? "", a = t.filter((e) => e.key.includes(r));
810
- p(a), h(a.length ? "Local mutation lineage" : "No local lineage found for this reference");
811
- }
812
- };
813
- return /* @__PURE__ */ c("div", {
814
- className: "studio-model-page",
815
- children: [
816
- /* @__PURE__ */ c("header", { children: [
817
- /* @__PURE__ */ s("span", {
818
- className: "eyebrow",
819
- children: "Observe"
820
- }),
821
- /* @__PURE__ */ s("h1", { children: "Provenance" }),
822
- /* @__PURE__ */ s("p", { children: "Follow why state exists—from durable mutations to causal workflow and agent edges." })
823
- ] }),
824
- /* @__PURE__ */ c("div", {
825
- className: "reference-query",
826
- children: [/* @__PURE__ */ s("input", {
827
- value: i,
828
- onChange: (e) => l(e.target.value),
829
- placeholder: `flow://${t}/Collection/id`
830
- }), /* @__PURE__ */ s("button", {
831
- onClick: () => void g(),
832
- children: "Trace"
833
- })]
834
- }),
835
- /* @__PURE__ */ c("article", {
836
- className: "studio-card provenance-result",
837
- children: [
838
- /* @__PURE__ */ s("span", {
839
- className: "card-kind",
840
- children: "Lineage"
841
- }),
842
- /* @__PURE__ */ s("h2", { children: m }),
843
- u && /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ c("div", {
844
- className: "model-summary",
845
- children: [/* @__PURE__ */ c("span", { children: [u.nodes.length, " nodes"] }), /* @__PURE__ */ c("span", { children: [u.edges.length, " edges"] })]
846
- }), /* @__PURE__ */ s("div", {
847
- className: "provenance-nodes",
848
- children: u.nodes.map((e) => /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("b", { children: e.label }), /* @__PURE__ */ s("small", { children: e.type })] }, e.id))
849
- })] }),
850
- !u && f.map((e) => /* @__PURE__ */ c("div", {
851
- className: "provenance-event",
852
- children: [
853
- /* @__PURE__ */ s("span", { children: e.sequence }),
854
- /* @__PURE__ */ c("b", { children: [
855
- e.type,
856
- " ",
857
- e.collection
858
- ] }),
859
- /* @__PURE__ */ s("code", { children: e.key }),
860
- /* @__PURE__ */ s("small", { children: new Date(e.timestamp).toLocaleString() })
861
- ]
862
- }, `${e.sequence}-${e.key}`))
863
- ]
864
- })
865
- ]
866
- });
867
- }
868
- //#endregion
869
- //#region src/components/HealthCenter.tsx
870
- function I({ diagnostics: e, model: t }) {
871
- let n = e ? [
872
- [
873
- "Runtime",
874
- e.runtime.status,
875
- e.runtime.reactive ? "reactive" : "non-reactive"
876
- ],
877
- [
878
- "Storage",
879
- e.storage.status,
880
- `${e.storage.backend} · ${e.storage.persistent ? "persistent" : "volatile"}`
881
- ],
882
- [
883
- "Synchronization",
884
- e.sync.status,
885
- `${e.sync.peers} peers · ${e.sync.pendingOperations} pending`
886
- ],
887
- [
888
- "Fabric",
889
- e.fabric.status,
890
- `${e.fabric.references} references`
891
- ],
892
- [
893
- "Capabilities",
894
- e.capabilities.status,
895
- `${e.capabilities.available}/${e.capabilities.count} available`
896
- ],
897
- [
898
- "Execution",
899
- e.execution.status,
900
- `${e.execution.running} running · ${e.execution.failed} failed`
901
- ],
902
- [
903
- "Workflows",
904
- e.workflow.status,
905
- `${e.workflow.active}/${e.workflow.total} active`
906
- ]
907
- ] : [];
908
- return /* @__PURE__ */ c("div", {
909
- className: "studio-model-page",
910
- children: [
911
- /* @__PURE__ */ c("header", { children: [
912
- /* @__PURE__ */ s("span", {
913
- className: "eyebrow",
914
- children: "Observe"
915
- }),
916
- /* @__PURE__ */ s("h1", { children: "Health" }),
917
- /* @__PURE__ */ s("p", { children: "Runtime diagnostics, not optimistic defaults." })
918
- ] }),
919
- /* @__PURE__ */ s("div", {
920
- className: "health-grid",
921
- children: n.map(([e, t, n]) => /* @__PURE__ */ c("article", {
922
- className: `health-item status-${t}`,
923
- children: [/* @__PURE__ */ s("span", {
924
- className: "status-icon",
925
- children: t === "healthy" ? "✓" : "!"
926
- }), /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("b", { children: e }), /* @__PURE__ */ s("small", { children: n })] })]
927
- }, e))
928
- }),
929
- !e && /* @__PURE__ */ s("div", {
930
- className: "model-empty",
931
- children: "Diagnostics are unavailable until Studio connects to a runtime."
932
- }),
933
- e?.issues.map((e, t) => /* @__PURE__ */ c("div", {
934
- className: `health-issue ${e.severity}`,
935
- children: [
936
- /* @__PURE__ */ s("b", { children: e.component }),
937
- " ",
938
- e.message
939
- ]
940
- }, t)),
941
- /* @__PURE__ */ c("div", {
942
- className: "model-summary",
943
- children: [
944
- /* @__PURE__ */ c("span", { children: [t?.collections.length ?? 0, " collections modeled"] }),
945
- /* @__PURE__ */ c("span", { children: [t?.workflows.length ?? 0, " workflows modeled"] }),
946
- /* @__PURE__ */ c("span", { children: [t?.agents.length ?? 0, " agents modeled"] })
947
- ]
948
- })
949
- ]
950
- });
951
- }
952
- //#endregion
953
- //#region src/components/SettingsPanel.tsx
954
- function L({ db: e, remoteUrl: t = "", token: r = "", onConnect: i }) {
955
- let [o, l] = a(t), [u, d] = a(r), f = e?.runtime();
956
- return n(() => {
957
- l(t), d(r);
958
- }, [t, r]), /* @__PURE__ */ c("div", {
959
- className: "settings-panel",
960
- children: [/* @__PURE__ */ s("h2", { children: "Settings" }), /* @__PURE__ */ c("div", {
961
- className: "settings-content",
962
- children: [
963
- /* @__PURE__ */ s("h3", { children: "Connection" }),
964
- /* @__PURE__ */ c("div", {
965
- className: "connection-info",
966
- children: [
967
- /* @__PURE__ */ c("div", {
968
- className: "info-row",
969
- children: [/* @__PURE__ */ s("label", { children: "Runtime Environment" }), /* @__PURE__ */ s("span", { children: f?.runtime || "unavailable" })]
970
- }),
971
- /* @__PURE__ */ c("div", {
972
- className: "info-row",
973
- children: [/* @__PURE__ */ s("label", { children: "Storage Backend" }), /* @__PURE__ */ s("span", { children: f?.storage || "unavailable" })]
974
- }),
975
- /* @__PURE__ */ c("div", {
976
- className: "info-row",
977
- children: [/* @__PURE__ */ s("label", { children: "Instance ID" }), /* @__PURE__ */ s("span", {
978
- className: "monospace",
979
- children: e?.instanceId?.() || "unavailable"
980
- })]
981
- })
982
- ]
983
- }),
984
- /* @__PURE__ */ c("form", {
985
- className: "connection-form",
986
- onSubmit: (e) => {
987
- e.preventDefault(), i?.(o, u);
988
- },
989
- children: [
990
- /* @__PURE__ */ c("label", { children: ["Server or managed endpoint", /* @__PURE__ */ s("input", {
991
- type: "url",
992
- value: o,
993
- onChange: (e) => l(e.target.value),
994
- placeholder: "https://your-runtime.example.com"
995
- })] }),
996
- /* @__PURE__ */ c("label", { children: ["API token", /* @__PURE__ */ s("input", {
997
- type: "password",
998
- value: u,
999
- onChange: (e) => d(e.target.value),
1000
- placeholder: "fdb_live_…",
1001
- autoComplete: "off"
1002
- })] }),
1003
- /* @__PURE__ */ s("p", { children: "Tokens are kept in this browser session and are never written to the project." }),
1004
- /* @__PURE__ */ s("button", {
1005
- className: "btn btn-primary",
1006
- type: "submit",
1007
- children: "Connect Studio"
1008
- })
1009
- ]
1010
- })
1011
- ]
1012
- })]
1013
- });
1014
- }
1015
- //#endregion
1016
- //#region src/components/GlobalSearch.tsx
1017
- function R({ db: e, model: t, onSearch: r }) {
1018
- let [i, o] = a(""), [l, u] = a([]), d = (e) => {
1019
- o(e), r && r(e);
1020
- };
1021
- return n(() => {
1022
- let n = !0;
1023
- return (async () => {
1024
- let r = i.trim().toLowerCase();
1025
- if (!r) {
1026
- u([]);
1027
- return;
1028
- }
1029
- let a = [
1030
- ...t?.collections.map((e) => ({
1031
- kind: "collection",
1032
- name: e.name,
1033
- detail: `${e.fields.length} fields`
1034
- })) ?? [],
1035
- ...t?.capabilities.map((e) => ({
1036
- kind: "capability",
1037
- name: e.name,
1038
- detail: e.statements.join(" · ")
1039
- })) ?? [],
1040
- ...t?.workflows.map((e) => ({
1041
- kind: "workflow",
1042
- name: e.name,
1043
- detail: `${e.steps.length} steps`
1044
- })) ?? [],
1045
- ...t?.agents.map((e) => ({
1046
- kind: "agent",
1047
- name: e.name,
1048
- detail: e.statements.join(" · ")
1049
- })) ?? []
1050
- ].filter((e) => JSON.stringify(e).toLowerCase().includes(r)), o = e && t ? (await Promise.all(t.collections.map(async (t) => (await e.collection(t.name).all()).filter((e) => JSON.stringify(e).toLowerCase().includes(r)).slice(0, 3).map((e) => ({
1051
- kind: "object",
1052
- name: `${t.name}/${String(e.id ?? "record")}`,
1053
- detail: JSON.stringify(e)
1054
- }))))).flat() : [];
1055
- n && u([...a, ...o].slice(0, 12));
1056
- })(), () => {
1057
- n = !1;
1058
- };
1059
- }, [
1060
- e,
1061
- t,
1062
- i
1063
- ]), /* @__PURE__ */ c("div", {
1064
- className: "global-search",
1065
- children: [/* @__PURE__ */ s("input", {
1066
- type: "text",
1067
- placeholder: "Search: documents/123, flow://, agent/name, etc.",
1068
- value: i,
1069
- onChange: (e) => d(e.target.value),
1070
- className: "search-input global"
1071
- }), i && /* @__PURE__ */ s("div", {
1072
- className: "search-results",
1073
- children: /* @__PURE__ */ c("div", {
1074
- className: "results-group",
1075
- children: [
1076
- /* @__PURE__ */ s("h4", { children: "Model & runtime" }),
1077
- l.map((e, t) => /* @__PURE__ */ c("div", {
1078
- className: "search-result",
1079
- children: [
1080
- /* @__PURE__ */ s("b", { children: e.name }),
1081
- /* @__PURE__ */ s("span", { children: e.kind }),
1082
- /* @__PURE__ */ s("small", { children: e.detail })
1083
- ]
1084
- }, `${e.kind}-${e.name}-${t}`)),
1085
- !l.length && /* @__PURE__ */ s("div", {
1086
- className: "empty-message",
1087
- children: "No matches"
1088
- })
1089
- ]
1090
- })
1091
- })]
1092
- });
1093
- }
1094
- //#endregion
1095
- //#region src/components/ApplicationDesigner.tsx
1096
- var z = f(d("Application"));
1097
- function B({ db: e, namespace: t = "default", projectSpec: o, managedPublish: g, onSpecChange: _ }) {
1098
- let v = `feltdb:studio:draft:${t}`, y = i((() => {
1099
- if (typeof window > "u") return z;
1100
- let e = window.localStorage.getItem(v);
1101
- if (!e) return z;
1102
- try {
1103
- return p(e), e;
1104
- } catch {
1105
- return z;
1106
- }
1107
- })()), b = i(y.current !== z), [x, S] = a(y.current), [C, w] = a(() => p(y.current)), [T, E] = a([]), [D, O] = a([]), [k, A] = a("Draft is valid"), [j, M] = a(0), [N, P] = a(null), [F, I] = a(null), [L, R] = a(!1), [B, V] = a(!1), [H, U] = a(() => ({
1108
- url: g?.url || "",
1109
- namespace: g?.namespace || t,
1110
- token: g?.token || "",
1111
- environment: g?.environment,
1112
- applicationId: g?.applicationId,
1113
- allowDestructive: !1
1114
- })), W = i(null), G = D.length ? D[D.length - 1].source : f(d(C.app)), K = r(() => u(p(G), C), [G, C]), q = r(() => m(p(G), C), [G, C]);
1115
- n(() => {
1116
- if (!e || o) return;
1117
- let t = !1;
1118
- return (async () => {
1119
- try {
1120
- let n = await e.collection("_flow_apps").all(), r = n.find((e) => e.status === "active") ?? n[0];
1121
- if (!r || t) return;
1122
- let i = f(r.spec);
1123
- b.current || (w(r.spec), S(i)), M(r.version ?? 0);
1124
- let a = (await e.collection("_flow_app_versions").all()).filter((e) => e.app === r.app).sort((e, t) => e.version - t.version);
1125
- t || (O(a.map((e) => ({
1126
- version: e.version,
1127
- source: f(e.spec),
1128
- savedAt: e.deployed_at
1129
- }))), A(`Loaded ${r.app} v${r.version}`));
1130
- } catch (e) {
1131
- t || A(`Could not load deployed model: ${e instanceof Error ? e.message : String(e)}`);
1132
- }
1133
- })(), () => {
1134
- t = !0;
1135
- };
1136
- }, [e, o]), n(() => {
1137
- let e = window.setTimeout(() => window.localStorage.setItem(v, x), 200);
1138
- return () => window.clearTimeout(e);
1139
- }, [v, x]);
1140
- let J = (e) => {
1141
- S(e);
1142
- try {
1143
- let t = p(e), n = h(t);
1144
- w(t), _?.(t), E(n), A(n.some((e) => e.severity === "error") ? "Model has validation errors" : "Draft is valid");
1145
- } catch (e) {
1146
- E([{
1147
- severity: "error",
1148
- message: e instanceof Error ? e.message : String(e)
1149
- }]), A("DSL parse failed");
1150
- }
1151
- };
1152
- n(() => {
1153
- if (!o) return;
1154
- let e = f(o);
1155
- S(e), w(o), E(h(o)), A(`Loaded ${o.app} project model`);
1156
- }, [o]);
1157
- let Y = (e) => {
1158
- w(e), J(f(e));
1159
- }, X = () => {
1160
- if (!F) return I({ name: "" });
1161
- let e = F.name.trim();
1162
- if (!/^[A-Z][A-Za-z0-9_]*$/.test(e)) return I({
1163
- ...F,
1164
- error: "Use a capitalized name with no spaces."
1165
- });
1166
- if (C.collections.some((t) => t.name === e)) return I({
1167
- ...F,
1168
- error: "That collection already exists."
1169
- });
1170
- Y({
1171
- ...C,
1172
- collections: [...C.collections, {
1173
- name: e,
1174
- fields: [],
1175
- indexes: []
1176
- }]
1177
- }), I(null);
1178
- }, Z = (e) => P({
1179
- collection: e,
1180
- name: "",
1181
- type: "text",
1182
- reference: "",
1183
- optional: !1
1184
- }), Q = () => {
1185
- if (!N) return;
1186
- let e = N.name.trim(), t = C.collections.find((e) => e.name === N.collection);
1187
- if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)) return P({
1188
- ...N,
1189
- error: "Use a letter-led name with no spaces."
1190
- });
1191
- if (t?.fields.some((t) => t.name === e)) return P({
1192
- ...N,
1193
- error: "That field already exists."
1194
- });
1195
- if ([
1196
- "ref",
1197
- "enum",
1198
- "array",
1199
- "map",
1200
- "vector"
1201
- ].includes(N.type) && !N.reference.trim()) return P({
1202
- ...N,
1203
- error: "Configure this field type."
1204
- });
1205
- let n = N.type === "ref" ? `ref ${N.reference}` : N.type === "enum" ? `enum(${N.reference.split(",").map((e) => e.trim()).filter(Boolean).join(",")})` : N.type === "array" ? `array<${N.reference.trim()}>` : N.type === "map" ? `map<${N.reference.trim()}>` : N.type === "vector" ? `vector<${N.reference.trim()}>` : N.type;
1206
- Y({
1207
- ...C,
1208
- collections: C.collections.map((t) => t.name === N.collection ? {
1209
- ...t,
1210
- fields: [...t.fields, {
1211
- name: e,
1212
- type: n,
1213
- optional: N.optional
1214
- }]
1215
- } : t)
1216
- }), P(null);
1217
- }, $ = () => {
1218
- let e = [...D, {
1219
- version: D.length + 1,
1220
- source: x,
1221
- savedAt: Date.now()
1222
- }];
1223
- O(e), A(`Saved local revision v${e.length}`);
1224
- }, ee = async () => {
1225
- if (!e) return A("Local embedded storage is unavailable");
1226
- if (T.some((e) => e.severity === "error")) return A("Resolve validation errors before deploying");
1227
- if (q.filter((e) => e.safety === "destructive").length && !L) return A("Review and approve destructive local changes before applying");
1228
- try {
1229
- let t = await e.deployFlowSpec(C, j, L), n = [...D, {
1230
- version: t.version,
1231
- source: x,
1232
- savedAt: Date.now()
1233
- }];
1234
- O(n), M(t.version), R(!1), A(`Applied locally as ${t.app} v${t.version}`);
1235
- } catch (e) {
1236
- A(`Local apply failed: ${e instanceof Error ? e.message : String(e)}`);
1237
- }
1238
- }, te = async () => {
1239
- if (!H.url.trim() || !H.token.trim()) return U({
1240
- ...H,
1241
- error: "Cloud URL and API key are required."
1242
- });
1243
- if (T.some((e) => e.severity === "error")) return U({
1244
- ...H,
1245
- error: "Resolve validation errors before publishing."
1246
- });
1247
- U({
1248
- ...H,
1249
- publishing: !0,
1250
- error: void 0
1251
- });
1252
- let e = l({
1253
- namespace: H.namespace.trim() || t,
1254
- server: {
1255
- url: H.url.trim().replace(/\/$/, ""),
1256
- token: H.token
1257
- }
1258
- });
1259
- try {
1260
- let t = await e.collection("_flow_apps").get(C.app), n = m(t?.spec ?? d(C.app), C).filter((e) => e.safety === "destructive");
1261
- if (n.length && !H.allowDestructive) return U({
1262
- ...H,
1263
- publishing: !1,
1264
- destructive: n.map((e) => e.target),
1265
- error: `Review and approve destructive changes: ${n.map((e) => e.target).join(", ")}`
1266
- });
1267
- let r = await e.deployFlowSpec(C, t?.version ?? 0, H.allowDestructive);
1268
- window.sessionStorage.setItem(`feltdb-token:${H.url.trim()}`, H.token), U({
1269
- ...H,
1270
- publishing: !1,
1271
- error: void 0
1272
- }), V(!1), A(`Published ${r.app} v${r.version} to ${H.environment || "cloud"}`);
1273
- } catch (e) {
1274
- U({
1275
- ...H,
1276
- publishing: !1,
1277
- error: e instanceof Error ? e.message : String(e)
1278
- });
1279
- } finally {
1280
- await e.close();
1281
- }
1282
- }, ne = () => {
1283
- let e = URL.createObjectURL(new Blob([x], { type: "text/plain" })), t = document.createElement("a");
1284
- t.href = e, t.download = "feltdb.flow", t.click(), URL.revokeObjectURL(e);
1285
- }, re = async (e) => {
1286
- e && J(await e.text());
1287
- }, ie = [
1288
- ["Data", C.collections.map((e) => e.name)],
1289
- ["Capabilities", C.capabilities.map((e) => e.name)],
1290
- ["Agents", C.agents.map((e) => e.name)],
1291
- ["Workflows", C.workflows.map((e) => e.name)],
1292
- ["Triggers", C.triggers.map((e) => e.event)],
1293
- ["Policies", C.policies.map((e) => e.name)],
1294
- ["Schedules", C.schedules.map((e) => e.name)]
1295
- ];
1296
- return /* @__PURE__ */ c("div", {
1297
- className: "application-designer",
1298
- children: [
1299
- /* @__PURE__ */ c("header", {
1300
- className: "designer-header",
1301
- children: [/* @__PURE__ */ c("div", { children: [
1302
- /* @__PURE__ */ s("span", {
1303
- className: "eyebrow",
1304
- children: "Application fabric"
1305
- }),
1306
- /* @__PURE__ */ s("h1", { children: C.app }),
1307
- /* @__PURE__ */ s("p", { children: "One model for state, intelligence, automation, security, and placement." })
1308
- ] }), /* @__PURE__ */ c("div", {
1309
- className: "designer-actions",
1310
- children: [
1311
- /* @__PURE__ */ s("input", {
1312
- ref: W,
1313
- hidden: !0,
1314
- type: "file",
1315
- accept: ".flow,text/plain",
1316
- onChange: (e) => void re(e.target.files?.[0])
1317
- }),
1318
- /* @__PURE__ */ s("button", {
1319
- className: "btn btn-ghost",
1320
- onClick: () => W.current?.click(),
1321
- children: "Import"
1322
- }),
1323
- /* @__PURE__ */ s("button", {
1324
- className: "btn btn-ghost",
1325
- onClick: ne,
1326
- children: "Export"
1327
- }),
1328
- /* @__PURE__ */ s("button", {
1329
- className: "btn btn-ghost",
1330
- onClick: $,
1331
- children: "Version"
1332
- }),
1333
- /* @__PURE__ */ s("button", {
1334
- className: "btn btn-ghost",
1335
- onClick: () => void ee(),
1336
- children: "Apply locally"
1337
- }),
1338
- /* @__PURE__ */ s("button", {
1339
- className: "btn btn-primary",
1340
- onClick: () => V((e) => !e),
1341
- children: "Publish to cloud"
1342
- })
1343
- ]
1344
- })]
1345
- }),
1346
- q.some((e) => e.safety === "destructive") && /* @__PURE__ */ c("label", {
1347
- className: "local-destructive",
1348
- children: [/* @__PURE__ */ s("input", {
1349
- type: "checkbox",
1350
- checked: L,
1351
- onChange: (e) => R(e.target.checked)
1352
- }), /* @__PURE__ */ c("span", { children: ["Approve destructive local changes: ", q.filter((e) => e.safety === "destructive").map((e) => e.target).join(", ")] })]
1353
- }),
1354
- B && /* @__PURE__ */ c("form", {
1355
- className: "cloud-publisher",
1356
- onSubmit: (e) => {
1357
- e.preventDefault(), te();
1358
- },
1359
- children: [
1360
- /* @__PURE__ */ c("div", {
1361
- className: "cloud-publisher-heading",
1362
- children: [/* @__PURE__ */ c("div", { children: [
1363
- /* @__PURE__ */ s("span", {
1364
- className: "eyebrow",
1365
- children: "Cloud release"
1366
- }),
1367
- /* @__PURE__ */ s("h2", { children: "Publish this application model" }),
1368
- /* @__PURE__ */ s("p", { children: "FeltDB compares the cloud version, plans the migration, and publishes atomically." })
1369
- ] }), /* @__PURE__ */ s("button", {
1370
- type: "button",
1371
- "aria-label": "Close cloud publisher",
1372
- onClick: () => V(!1),
1373
- children: "×"
1374
- })]
1375
- }),
1376
- /* @__PURE__ */ c("div", {
1377
- className: "cloud-fields",
1378
- children: [
1379
- /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "FeltDB Cloud URL" }), /* @__PURE__ */ s("input", {
1380
- type: "url",
1381
- placeholder: "https://your-instance.feltdb.cloud",
1382
- value: H.url,
1383
- onChange: (e) => U({
1384
- ...H,
1385
- url: e.target.value,
1386
- error: void 0,
1387
- destructive: void 0,
1388
- allowDestructive: !1
1389
- })
1390
- })] }),
1391
- /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Namespace" }), /* @__PURE__ */ s("input", {
1392
- value: H.namespace,
1393
- onChange: (e) => U({
1394
- ...H,
1395
- namespace: e.target.value,
1396
- error: void 0,
1397
- destructive: void 0,
1398
- allowDestructive: !1
1399
- })
1400
- })] }),
1401
- /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "API key" }), /* @__PURE__ */ s("input", {
1402
- type: "password",
1403
- autoComplete: "off",
1404
- placeholder: "Loaded securely from this project",
1405
- value: H.token,
1406
- onChange: (e) => U({
1407
- ...H,
1408
- token: e.target.value,
1409
- error: void 0
1410
- })
1411
- })] }),
1412
- H.environment && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Environment" }), /* @__PURE__ */ s("input", {
1413
- value: H.environment,
1414
- readOnly: !0
1415
- })] }),
1416
- H.applicationId && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Application" }), /* @__PURE__ */ s("input", {
1417
- value: H.applicationId,
1418
- readOnly: !0
1419
- })] })
1420
- ]
1421
- }),
1422
- (H.destructive?.length || q.some((e) => e.safety === "destructive")) && /* @__PURE__ */ c("label", {
1423
- className: "cloud-destructive",
1424
- children: [/* @__PURE__ */ s("input", {
1425
- type: "checkbox",
1426
- checked: H.allowDestructive,
1427
- onChange: (e) => U({
1428
- ...H,
1429
- allowDestructive: e.target.checked
1430
- })
1431
- }), /* @__PURE__ */ c("span", { children: ["I reviewed and approve destructive model changes", H.destructive?.length ? `: ${H.destructive.join(", ")}` : "."] })]
1432
- }),
1433
- H.error && /* @__PURE__ */ s("div", {
1434
- className: "cloud-error",
1435
- role: "alert",
1436
- children: H.error
1437
- }),
1438
- /* @__PURE__ */ c("div", {
1439
- className: "cloud-actions",
1440
- children: [/* @__PURE__ */ s("button", {
1441
- type: "button",
1442
- className: "btn btn-ghost",
1443
- onClick: () => V(!1),
1444
- children: "Cancel"
1445
- }), /* @__PURE__ */ s("button", {
1446
- className: "btn btn-primary",
1447
- disabled: H.publishing,
1448
- type: "submit",
1449
- children: H.publishing ? "Publishing…" : "Review and publish"
1450
- })]
1451
- })
1452
- ]
1453
- }),
1454
- /* @__PURE__ */ c("div", {
1455
- className: `designer-status ${T.some((e) => e.severity === "error") ? "error" : ""}`,
1456
- children: [/* @__PURE__ */ s("span", { children: k }), /* @__PURE__ */ c("span", { children: [
1457
- C.collections.length,
1458
- " collections · ",
1459
- C.workflows.length,
1460
- " workflows · ",
1461
- D.length ? `v${D.length}` : "draft"
1462
- ] })]
1463
- }),
1464
- /* @__PURE__ */ c("div", {
1465
- className: "designer-grid",
1466
- children: [
1467
- /* @__PURE__ */ c("aside", {
1468
- className: "model-tree",
1469
- children: [
1470
- /* @__PURE__ */ c("div", {
1471
- className: "panel-title",
1472
- children: [/* @__PURE__ */ s("span", { children: "Application" }), /* @__PURE__ */ s("button", {
1473
- "aria-label": "Add collection",
1474
- onClick: () => I({ name: "" }),
1475
- children: "+"
1476
- })]
1477
- }),
1478
- F && /* @__PURE__ */ c("form", {
1479
- className: "collection-editor",
1480
- onSubmit: (e) => {
1481
- e.preventDefault(), X();
1482
- },
1483
- onKeyDown: (e) => {
1484
- e.key === "Escape" && I(null);
1485
- },
1486
- children: [
1487
- /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "New collection" }), /* @__PURE__ */ s("input", {
1488
- autoFocus: !0,
1489
- placeholder: "e.g. Customer",
1490
- value: F.name,
1491
- onChange: (e) => I({ name: e.target.value })
1492
- })] }),
1493
- F.error && /* @__PURE__ */ s("div", {
1494
- className: "field-error",
1495
- role: "alert",
1496
- children: F.error
1497
- }),
1498
- /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("button", {
1499
- type: "button",
1500
- onClick: () => I(null),
1501
- children: "Cancel"
1502
- }), /* @__PURE__ */ s("button", {
1503
- className: "collection-save",
1504
- type: "submit",
1505
- children: "Add"
1506
- })] })
1507
- ]
1508
- }),
1509
- ie.map(([e, t]) => /* @__PURE__ */ c("section", { children: [/* @__PURE__ */ s("h3", { children: e }), t.length ? t.map((e) => /* @__PURE__ */ s("div", {
1510
- className: "tree-item",
1511
- children: e
1512
- }, e)) : /* @__PURE__ */ s("div", {
1513
- className: "tree-empty",
1514
- children: "None"
1515
- })] }, e))
1516
- ]
1517
- }),
1518
- /* @__PURE__ */ c("section", {
1519
- className: "model-canvas",
1520
- children: [
1521
- /* @__PURE__ */ c("div", {
1522
- className: "panel-title",
1523
- children: [/* @__PURE__ */ s("span", { children: "Application graph" }), /* @__PURE__ */ s("span", {
1524
- className: "graph-legend",
1525
- children: "intent → fabric"
1526
- })]
1527
- }),
1528
- /* @__PURE__ */ c("div", {
1529
- className: "graph-board",
1530
- children: [
1531
- C.collections.map((e) => /* @__PURE__ */ c("article", {
1532
- className: "model-node",
1533
- children: [
1534
- /* @__PURE__ */ s("div", {
1535
- className: "node-kind",
1536
- children: "collection"
1537
- }),
1538
- /* @__PURE__ */ s("h3", { children: e.name }),
1539
- e.fields.map((e) => /* @__PURE__ */ c("div", {
1540
- className: "node-field",
1541
- children: [/* @__PURE__ */ s("span", { children: e.name }), /* @__PURE__ */ c("code", { children: [e.type, e.optional ? "?" : ""] })]
1542
- }, e.name)),
1543
- N?.collection === e.name ? /* @__PURE__ */ c("form", {
1544
- className: "field-editor",
1545
- onSubmit: (e) => {
1546
- e.preventDefault(), Q();
1547
- },
1548
- onKeyDown: (e) => {
1549
- e.key === "Escape" && P(null);
1550
- },
1551
- children: [
1552
- /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Field name" }), /* @__PURE__ */ s("input", {
1553
- autoFocus: !0,
1554
- value: N.name,
1555
- placeholder: "e.g. publishedAt",
1556
- onChange: (e) => P({
1557
- ...N,
1558
- name: e.target.value,
1559
- error: void 0
1560
- })
1561
- })] }),
1562
- /* @__PURE__ */ c("div", {
1563
- className: "field-editor-row",
1564
- children: [
1565
- /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Type" }), /* @__PURE__ */ c("select", {
1566
- value: N.type,
1567
- onChange: (e) => P({
1568
- ...N,
1569
- type: e.target.value,
1570
- error: void 0
1571
- }),
1572
- children: [
1573
- /* @__PURE__ */ s("option", {
1574
- value: "text",
1575
- children: "Text"
1576
- }),
1577
- /* @__PURE__ */ s("option", {
1578
- value: "integer",
1579
- children: "Integer"
1580
- }),
1581
- /* @__PURE__ */ s("option", {
1582
- value: "number",
1583
- children: "Number"
1584
- }),
1585
- /* @__PURE__ */ s("option", {
1586
- value: "decimal",
1587
- children: "Decimal"
1588
- }),
1589
- /* @__PURE__ */ s("option", {
1590
- value: "money",
1591
- children: "Money"
1592
- }),
1593
- /* @__PURE__ */ s("option", {
1594
- value: "bigint",
1595
- children: "Big integer"
1596
- }),
1597
- /* @__PURE__ */ s("option", {
1598
- value: "boolean",
1599
- children: "Boolean"
1600
- }),
1601
- /* @__PURE__ */ s("option", {
1602
- value: "datetime",
1603
- children: "Date & time"
1604
- }),
1605
- /* @__PURE__ */ s("option", {
1606
- value: "date",
1607
- children: "Date"
1608
- }),
1609
- /* @__PURE__ */ s("option", {
1610
- value: "time",
1611
- children: "Time"
1612
- }),
1613
- /* @__PURE__ */ s("option", {
1614
- value: "uuid",
1615
- children: "UUID"
1616
- }),
1617
- /* @__PURE__ */ s("option", {
1618
- value: "email",
1619
- children: "Email"
1620
- }),
1621
- /* @__PURE__ */ s("option", {
1622
- value: "url",
1623
- children: "URL"
1624
- }),
1625
- /* @__PURE__ */ s("option", {
1626
- value: "phone",
1627
- children: "Phone"
1628
- }),
1629
- /* @__PURE__ */ s("option", {
1630
- value: "json",
1631
- children: "JSON"
1632
- }),
1633
- /* @__PURE__ */ s("option", {
1634
- value: "object",
1635
- children: "Object"
1636
- }),
1637
- /* @__PURE__ */ s("option", {
1638
- value: "binary",
1639
- children: "Binary"
1640
- }),
1641
- /* @__PURE__ */ s("option", {
1642
- value: "file",
1643
- children: "File"
1644
- }),
1645
- /* @__PURE__ */ s("option", {
1646
- value: "geo",
1647
- children: "Geo point"
1648
- }),
1649
- /* @__PURE__ */ s("option", {
1650
- value: "enum",
1651
- children: "Enum"
1652
- }),
1653
- /* @__PURE__ */ s("option", {
1654
- value: "array",
1655
- children: "Array"
1656
- }),
1657
- /* @__PURE__ */ s("option", {
1658
- value: "map",
1659
- children: "Typed map"
1660
- }),
1661
- /* @__PURE__ */ s("option", {
1662
- value: "vector",
1663
- children: "Vector"
1664
- }),
1665
- /* @__PURE__ */ s("option", {
1666
- value: "ref",
1667
- children: "Reference"
1668
- })
1669
- ]
1670
- })] }),
1671
- N.type === "ref" && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Collection" }), /* @__PURE__ */ s("select", {
1672
- value: N.reference,
1673
- onChange: (e) => P({
1674
- ...N,
1675
- reference: e.target.value,
1676
- error: void 0
1677
- }),
1678
- children: C.collections.filter((t) => t.name !== e.name).map((e) => /* @__PURE__ */ s("option", {
1679
- value: e.name,
1680
- children: e.name
1681
- }, e.name))
1682
- })] }),
1683
- N.type === "enum" && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Values" }), /* @__PURE__ */ s("input", {
1684
- placeholder: "draft,active,done",
1685
- value: N.reference,
1686
- onChange: (e) => P({
1687
- ...N,
1688
- reference: e.target.value,
1689
- error: void 0
1690
- })
1691
- })] }),
1692
- (N.type === "array" || N.type === "map") && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Item type" }), /* @__PURE__ */ s("input", {
1693
- placeholder: "text, uuid, ref Project…",
1694
- value: N.reference,
1695
- onChange: (e) => P({
1696
- ...N,
1697
- reference: e.target.value,
1698
- error: void 0
1699
- })
1700
- })] }),
1701
- N.type === "vector" && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Dimensions" }), /* @__PURE__ */ s("input", {
1702
- type: "number",
1703
- min: "1",
1704
- placeholder: "1536",
1705
- value: N.reference,
1706
- onChange: (e) => P({
1707
- ...N,
1708
- reference: e.target.value,
1709
- error: void 0
1710
- })
1711
- })] })
1712
- ]
1713
- }),
1714
- /* @__PURE__ */ c("label", {
1715
- className: "field-optional",
1716
- children: [/* @__PURE__ */ s("input", {
1717
- type: "checkbox",
1718
- checked: N.optional,
1719
- onChange: (e) => P({
1720
- ...N,
1721
- optional: e.target.checked
1722
- })
1723
- }), /* @__PURE__ */ s("span", { children: "Optional field" })]
1724
- }),
1725
- N.error && /* @__PURE__ */ s("div", {
1726
- className: "field-error",
1727
- role: "alert",
1728
- children: N.error
1729
- }),
1730
- /* @__PURE__ */ c("div", {
1731
- className: "field-editor-actions",
1732
- children: [/* @__PURE__ */ s("button", {
1733
- type: "button",
1734
- onClick: () => P(null),
1735
- children: "Cancel"
1736
- }), /* @__PURE__ */ s("button", {
1737
- className: "field-save",
1738
- type: "submit",
1739
- children: "Add field"
1740
- })]
1741
- })
1742
- ]
1743
- }) : /* @__PURE__ */ s("button", {
1744
- className: "node-add",
1745
- onClick: () => Z(e.name),
1746
- children: "+ field"
1747
- })
1748
- ]
1749
- }, e.name)),
1750
- C.workflows.map((e) => /* @__PURE__ */ c("article", {
1751
- className: "model-node workflow-node",
1752
- children: [
1753
- /* @__PURE__ */ s("div", {
1754
- className: "node-kind",
1755
- children: "workflow"
1756
- }),
1757
- /* @__PURE__ */ s("h3", { children: e.name }),
1758
- e.steps.map((e) => /* @__PURE__ */ s("div", {
1759
- className: "node-step",
1760
- children: e.name
1761
- }, e.name))
1762
- ]
1763
- }, e.name)),
1764
- C.agents.map((e) => /* @__PURE__ */ c("article", {
1765
- className: "model-node agent-node",
1766
- children: [
1767
- /* @__PURE__ */ s("div", {
1768
- className: "node-kind",
1769
- children: "agent"
1770
- }),
1771
- /* @__PURE__ */ s("h3", { children: e.name }),
1772
- e.statements.map((e) => /* @__PURE__ */ s("div", {
1773
- className: "node-step",
1774
- children: e
1775
- }, e))
1776
- ]
1777
- }, e.name))
1778
- ]
1779
- }),
1780
- /* @__PURE__ */ c("div", {
1781
- className: "change-strip",
1782
- children: [
1783
- /* @__PURE__ */ s("strong", { children: "Model diff" }),
1784
- /* @__PURE__ */ c("span", {
1785
- className: "added",
1786
- children: ["+ ", K.added.join(", ") || "none"]
1787
- }),
1788
- /* @__PURE__ */ c("span", {
1789
- className: "changed",
1790
- children: ["~ ", K.changed.join(", ") || "none"]
1791
- }),
1792
- /* @__PURE__ */ c("span", {
1793
- className: "removed",
1794
- children: ["− ", K.removed.join(", ") || "none"]
1795
- })
1796
- ]
1797
- })
1798
- ]
1799
- }),
1800
- /* @__PURE__ */ c("section", {
1801
- className: "dsl-panel",
1802
- children: [
1803
- /* @__PURE__ */ c("div", {
1804
- className: "panel-title",
1805
- children: [/* @__PURE__ */ s("span", { children: "Flow DSL" }), /* @__PURE__ */ s("span", { children: "feltdb.flow" })]
1806
- }),
1807
- /* @__PURE__ */ s("textarea", {
1808
- "aria-label": "Flow DSL",
1809
- spellCheck: !1,
1810
- value: x,
1811
- onChange: (e) => J(e.target.value)
1812
- }),
1813
- T.length > 0 && /* @__PURE__ */ s("div", {
1814
- className: "diagnostics",
1815
- children: T.map((e, t) => /* @__PURE__ */ c("div", {
1816
- className: e.severity,
1817
- children: [
1818
- e.severity,
1819
- ": ",
1820
- e.message
1821
- ]
1822
- }, t))
1823
- })
1824
- ]
1825
- })
1826
- ]
1827
- })
1828
- ]
1829
- });
1830
- }
1831
- //#endregion
1832
- export { _, F as a, y as b, M as c, O as d, D as f, v as g, b as h, I as i, j as l, w as m, R as n, P as o, E as p, L as r, N as s, B as t, k as u, x as v, g as x, S as y };