@voltro/cli 0.12.0 → 0.14.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 (189) hide show
  1. package/CHANGELOG.md +378 -0
  2. package/dist/{apiBuild-GefjNI5d.js → apiBuild-370ITNRk.js} +3 -3
  3. package/dist/apiBuild-DatWP5hh.js +2 -0
  4. package/dist/bin.js +3 -3
  5. package/dist/{commands-BmNi1RgZ.js → commands-D-teL_TM.js} +3756 -2539
  6. package/dist/dbCommand-B3CeMU3u.js +2 -0
  7. package/dist/{dbCommand-DNrkb58g.js → dbCommand-Dmi-vHfA.js} +72 -57
  8. package/dist/{dev-d0LjACxE.js → dev-CKyW_LAv.js} +1511 -1331
  9. package/dist/dev-CPKbckaN.js +3 -0
  10. package/dist/fileConventions-COg0ZytD.js +9 -0
  11. package/dist/frameworkTableAssembly-DCLhpHsF.js +601 -0
  12. package/dist/frameworkTableAssembly-DYzb2elg.js +2 -0
  13. package/dist/index.js +1 -1
  14. package/dist/{inspectMetrics-uEfIS1vp.js → inspectMetrics-CyVMeofr.js} +962 -943
  15. package/dist/seedRunner-D6eu-u5U.js +229 -0
  16. package/dist/serveCommand-CU3Sw4ZM.js +1127 -0
  17. package/dist/serveEntry.js +3 -3
  18. package/dist/{start-DKcQd52a.js → start-D8ATvTzo.js} +246 -246
  19. package/dist/startEntry.js +2 -2
  20. package/package.json +17 -17
  21. package/templates/AGENTS.core.md +77 -3
  22. package/templates/AGENTS.md +78 -4
  23. package/templates/agent-docs/_index.md +1 -1
  24. package/templates/agent-docs/_manifest.json +2 -2
  25. package/templates/agent-docs/authentication.md +39 -0
  26. package/templates/agent-docs/cli.md +114 -6
  27. package/templates/agent-docs/configuration.md +48 -0
  28. package/templates/agent-docs/data.md +193 -1
  29. package/templates/agent-docs/database/hosting.md +2 -2
  30. package/templates/agent-docs/database/migrations.md +88 -3
  31. package/templates/agent-docs/database/overview.md +11 -0
  32. package/templates/agent-docs/database/seedsdialects.md +53 -1
  33. package/templates/agent-docs/database/transactions.md +31 -0
  34. package/templates/agent-docs/internationalization.md +3 -3
  35. package/templates/agent-docs/introduction.md +133 -2
  36. package/templates/agent-docs/plugins.md +2 -1
  37. package/templates/agent-docs/reference.md +4 -4
  38. package/templates/agent-docs/routing.md +48 -43
  39. package/templates/agent-docs/schema-driven-ui.md +12 -2
  40. package/templates/agent-docs/templates/apibackends.md +1 -8
  41. package/templates/agent-docs/templates/appshells.md +24 -24
  42. package/templates/agent-docs/testing.md +40 -1
  43. package/templates/agent-docs/whats-new.md +51 -131
  44. package/templates/apps/api-ai/database/schema.ts +0 -2
  45. package/templates/apps/api-ai/package.json +7 -7
  46. package/templates/apps/api-auth/package.json +8 -8
  47. package/templates/apps/api-backend/database/schema.ts +0 -3
  48. package/templates/apps/api-backend/package.json +7 -7
  49. package/templates/apps/api-backend-deactivation/database/schema.ts +0 -1
  50. package/templates/apps/api-backend-deactivation/package.json +7 -7
  51. package/templates/apps/api-backend-deactivation/tests/users.deactivate.test.ts +1 -1
  52. package/templates/apps/api-backend-mail/database/schema.ts +0 -3
  53. package/templates/apps/api-backend-mail/package.json +8 -8
  54. package/templates/apps/api-backend-mariadb/database/schema.ts +0 -3
  55. package/templates/apps/api-backend-mariadb/package.json +9 -9
  56. package/templates/apps/api-backend-storage/database/schema.ts +0 -3
  57. package/templates/apps/api-backend-storage/package.json +8 -8
  58. package/templates/apps/api-data-advanced/database/authors.entity.ts +0 -2
  59. package/templates/apps/api-data-advanced/database/books.entity.ts +0 -1
  60. package/templates/apps/api-data-advanced/package.json +8 -8
  61. package/templates/apps/api-data-advanced/tests/queries.test.ts +6 -1
  62. package/templates/apps/api-durable/database/schema.ts +0 -3
  63. package/templates/apps/api-durable/package.json +8 -8
  64. package/templates/apps/api-feature-flags/database/schema.ts +0 -1
  65. package/templates/apps/api-feature-flags/package.json +9 -9
  66. package/templates/apps/api-governance/app.config.ts +0 -1
  67. package/templates/apps/api-governance/database/schema.ts +0 -1
  68. package/templates/apps/api-governance/package.json +8 -8
  69. package/templates/apps/api-kv/database/schema.ts +0 -3
  70. package/templates/apps/api-kv/package.json +8 -8
  71. package/templates/apps/api-kv/tests/sync.test.ts +2 -2
  72. package/templates/apps/api-moderation/database/schema.ts +0 -2
  73. package/templates/apps/api-moderation/package.json +8 -8
  74. package/templates/apps/api-observability/database/schema.ts +0 -1
  75. package/templates/apps/api-observability/package.json +8 -8
  76. package/templates/apps/api-ratelimit/database/schema.ts +0 -1
  77. package/templates/apps/api-ratelimit/package.json +8 -8
  78. package/templates/apps/api-rbac/README.md +53 -14
  79. package/templates/apps/api-rbac/app.config.ts +24 -26
  80. package/templates/apps/api-rbac/authz.ts +76 -0
  81. package/templates/apps/api-rbac/database/schema.ts +22 -7
  82. package/templates/apps/api-rbac/mutations/notes.create.mutation.server.ts +7 -5
  83. package/templates/apps/api-rbac/mutations/notes.create.mutation.ts +15 -8
  84. package/templates/apps/api-rbac/mutations/notes.delete.mutation.server.ts +54 -0
  85. package/templates/apps/api-rbac/mutations/notes.delete.mutation.ts +43 -0
  86. package/templates/apps/api-rbac/mutations/teams.rename.mutation.server.ts +19 -0
  87. package/templates/apps/api-rbac/mutations/teams.rename.mutation.ts +37 -0
  88. package/templates/apps/api-rbac/package.json +8 -8
  89. package/templates/apps/api-rbac/queries/notes.list.query.server.ts +12 -0
  90. package/templates/apps/api-rbac/queries/notes.list.query.ts +26 -0
  91. package/templates/apps/api-rbac/template.json +2 -2
  92. package/templates/apps/api-rbac/tests/authz.test.ts +233 -0
  93. package/templates/apps/api-rest/database/schema.ts +0 -3
  94. package/templates/apps/api-rest/package.json +7 -7
  95. package/templates/apps/api-saas/database/schema.ts +0 -1
  96. package/templates/apps/api-saas/package.json +11 -11
  97. package/templates/apps/api-search/database/schema.ts +0 -1
  98. package/templates/apps/api-search/package.json +8 -8
  99. package/templates/apps/api-versioning/database/schema.ts +0 -1
  100. package/templates/apps/api-versioning/package.json +8 -8
  101. package/templates/apps/api-webhooks/database/schema.ts +0 -1
  102. package/templates/apps/api-webhooks/package.json +9 -8
  103. package/templates/apps/changelog/package.json +6 -6
  104. package/templates/apps/changelog/src/pages/[locale]/{[slug].tsx → [slug].page.tsx} +2 -2
  105. package/templates/apps/changelog/src/pages/[locale]/{index.tsx → index.page.tsx} +2 -2
  106. package/templates/apps/changelog/src/pages/[locale]/mirrors.test.tsx +2 -2
  107. package/templates/apps/changelog/src/pages/{[slug].test.tsx → [slug].page.test.tsx} +1 -1
  108. package/templates/apps/changelog/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
  109. package/templates/apps/edge-functions/package.json +2 -2
  110. package/templates/apps/frontend-admin/package.json +8 -8
  111. package/templates/apps/frontend-admin/src/pages/(marketing)/{index.test.tsx → index.page.test.tsx} +1 -1
  112. package/templates/apps/frontend-admin/src/pages/(marketing)/{login.test.tsx → login.page.test.tsx} +1 -1
  113. package/templates/apps/frontend-admin/src/pages/admin/entity.test.tsx +1 -1
  114. package/templates/apps/frontend-admin/src/pages/admin/{index.test.tsx → index.page.test.tsx} +1 -1
  115. package/templates/apps/frontend-app/package.json +8 -8
  116. package/templates/apps/frontend-app/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
  117. package/templates/apps/frontend-app/src/pages/{schema-ui.test.tsx → schema-ui.page.test.tsx} +1 -1
  118. package/templates/apps/frontend-blank/package.json +7 -7
  119. package/templates/apps/frontend-blank/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
  120. package/templates/apps/frontend-contact/package.json +7 -7
  121. package/templates/apps/frontend-contact/src/pages/[locale]/{index.tsx → index.page.tsx} +2 -2
  122. package/templates/apps/frontend-contact/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
  123. package/templates/apps/frontend-dashboard/package.json +7 -7
  124. package/templates/apps/frontend-dashboard/src/pages/(marketing)/{index.test.tsx → index.page.test.tsx} +1 -1
  125. package/templates/apps/frontend-dashboard/src/pages/(marketing)/{login.test.tsx → login.page.test.tsx} +1 -1
  126. package/templates/apps/frontend-dashboard/src/pages/dashboard/{index.test.tsx → index.page.test.tsx} +1 -1
  127. package/templates/apps/frontend-dashboard/src/pages/dashboard/{settings.test.tsx → settings.page.test.tsx} +1 -1
  128. package/templates/apps/frontend-docs/package.json +7 -7
  129. package/templates/apps/frontend-docs/src/pages/[locale]/docs/{[...slug].tsx → [...slug].page.tsx} +3 -3
  130. package/templates/apps/frontend-docs/src/pages/[locale]/{index.tsx → index.page.tsx} +2 -2
  131. package/templates/apps/frontend-docs/src/pages/[locale]/mirrors.test.tsx +2 -2
  132. package/templates/apps/frontend-docs/src/pages/docs/{[...slug].test.tsx → [...slug].page.test.tsx} +1 -1
  133. package/templates/apps/frontend-docs/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
  134. package/templates/apps/frontend-i18n/package.json +6 -6
  135. package/templates/apps/frontend-i18n/src/pages/[locale]/{about.tsx → about.page.tsx} +2 -2
  136. package/templates/apps/frontend-i18n/src/pages/[locale]/{index.tsx → index.page.tsx} +2 -2
  137. package/templates/apps/frontend-i18n/src/pages/[locale]/mirrors.test.tsx +2 -2
  138. package/templates/apps/frontend-i18n/src/pages/{about.test.tsx → about.page.test.tsx} +1 -1
  139. package/templates/apps/frontend-i18n/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
  140. package/templates/apps/frontend-landing/package.json +7 -7
  141. package/templates/apps/frontend-landing/src/pages/[locale]/{index.tsx → index.page.tsx} +2 -2
  142. package/templates/apps/frontend-landing/src/pages/[locale]/mirrors.test.tsx +1 -1
  143. package/templates/apps/frontend-landing/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
  144. package/templates/apps/frontend-spa/package.json +7 -7
  145. package/templates/apps/frontend-spa/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
  146. package/templates/apps/frontend-ssr/package.json +7 -7
  147. package/templates/apps/frontend-ssr/src/pages/{feed-swr.test.tsx → feed-swr.page.test.tsx} +1 -1
  148. package/templates/apps/frontend-ssr/src/pages/{feed.test.tsx → feed.page.test.tsx} +1 -1
  149. package/templates/apps/frontend-ssr/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
  150. package/templates/apps/frontend-ssr-api/package.json +8 -8
  151. package/templates/apps/frontend-ssr-api/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
  152. package/templates/apps/frontend-static-blog/package.json +6 -6
  153. package/templates/apps/frontend-static-blog/src/pages/[locale]/blog/{[slug].tsx → [slug].page.tsx} +2 -2
  154. package/templates/apps/frontend-static-blog/src/pages/[locale]/{index.tsx → index.page.tsx} +2 -2
  155. package/templates/apps/frontend-static-blog/src/pages/[locale]/mirrors.test.tsx +2 -2
  156. package/templates/apps/frontend-static-blog/src/pages/blog/{[slug].test.tsx → [slug].page.test.tsx} +1 -1
  157. package/templates/apps/frontend-static-blog/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
  158. package/dist/apiBuild-s7swuEU5.js +0 -2
  159. package/dist/dbCommand-Bt6BCG7g.js +0 -2
  160. package/dist/dev-YHbHmeXt.js +0 -3
  161. package/dist/seedRunner-DZmhoqNt.js +0 -821
  162. package/dist/serveCommand-B2-YV9TU.js +0 -1112
  163. package/templates/apps/api-rbac/tests/notes.create.test.ts +0 -80
  164. /package/templates/apps/changelog/src/pages/{[slug].tsx → [slug].page.tsx} +0 -0
  165. /package/templates/apps/changelog/src/pages/{index.tsx → index.page.tsx} +0 -0
  166. /package/templates/apps/frontend-admin/src/pages/(marketing)/{index.tsx → index.page.tsx} +0 -0
  167. /package/templates/apps/frontend-admin/src/pages/(marketing)/{login.tsx → login.page.tsx} +0 -0
  168. /package/templates/apps/frontend-admin/src/pages/admin/{[entity].tsx → [entity].page.tsx} +0 -0
  169. /package/templates/apps/frontend-admin/src/pages/admin/{index.tsx → index.page.tsx} +0 -0
  170. /package/templates/apps/frontend-app/src/pages/{index.tsx → index.page.tsx} +0 -0
  171. /package/templates/apps/frontend-app/src/pages/{schema-ui.tsx → schema-ui.page.tsx} +0 -0
  172. /package/templates/apps/frontend-blank/src/pages/{index.tsx → index.page.tsx} +0 -0
  173. /package/templates/apps/frontend-contact/src/pages/{index.tsx → index.page.tsx} +0 -0
  174. /package/templates/apps/frontend-dashboard/src/pages/(marketing)/{index.tsx → index.page.tsx} +0 -0
  175. /package/templates/apps/frontend-dashboard/src/pages/(marketing)/{login.tsx → login.page.tsx} +0 -0
  176. /package/templates/apps/frontend-dashboard/src/pages/dashboard/{index.tsx → index.page.tsx} +0 -0
  177. /package/templates/apps/frontend-dashboard/src/pages/dashboard/{settings.tsx → settings.page.tsx} +0 -0
  178. /package/templates/apps/frontend-docs/src/pages/docs/{[...slug].tsx → [...slug].page.tsx} +0 -0
  179. /package/templates/apps/frontend-docs/src/pages/{index.tsx → index.page.tsx} +0 -0
  180. /package/templates/apps/frontend-i18n/src/pages/{about.tsx → about.page.tsx} +0 -0
  181. /package/templates/apps/frontend-i18n/src/pages/{index.tsx → index.page.tsx} +0 -0
  182. /package/templates/apps/frontend-landing/src/pages/{index.tsx → index.page.tsx} +0 -0
  183. /package/templates/apps/frontend-spa/src/pages/{index.tsx → index.page.tsx} +0 -0
  184. /package/templates/apps/frontend-ssr/src/pages/{feed-swr.tsx → feed-swr.page.tsx} +0 -0
  185. /package/templates/apps/frontend-ssr/src/pages/{feed.tsx → feed.page.tsx} +0 -0
  186. /package/templates/apps/frontend-ssr/src/pages/{index.tsx → index.page.tsx} +0 -0
  187. /package/templates/apps/frontend-ssr-api/src/pages/{index.tsx → index.page.tsx} +0 -0
  188. /package/templates/apps/frontend-static-blog/src/pages/blog/{[slug].tsx → [slug].page.tsx} +0 -0
  189. /package/templates/apps/frontend-static-blog/src/pages/{index.tsx → index.page.tsx} +0 -0
@@ -0,0 +1,3 @@
1
+ import "./seedRunner-D6eu-u5U.js";
2
+ import { c as e, f as t, s as n } from "./dev-CKyW_LAv.js";
3
+ export { n as loadApiConfig, e as loadDiscovered, t as walk };
@@ -0,0 +1,9 @@
1
+ //#region src/fileConventions.ts
2
+ var e = /\.(query|mutation|action|stream)\.ts$/, t = /\.(query|mutation|action|stream)\.server\.ts$/, n = /\.workflow\.tsx$/, r = /\.workflow\.server\.tsx$/, i = /\.workflow\.tsx?$/, a = /\.trigger\.tsx?$/, o = /\.cron\.tsx?$/, s = /\.webhook\.tsx?$/, c = /\.outbox\.tsx?$/, l = /\.subscribe\.tsx?$/, u = /\.reaction\.tsx?$/, d = /\.aggregate\.tsx?$/, f = /\.startup\.tsx?$/, p = /\.seed\.ts$/, m = /\.relations\.ts$/, h = /\.entity\.ts$|\.schema\.ts$|^schema\.ts$/, g = (e) => i.test(e) && !n.test(e) && !r.test(e), _ = /\.page\.tsx$/, v = /\.island\.tsx?$/, y = /\.component\.tsx$/, b = /\.component\.ui\.tsx$/, x = /\.hook\.tsx?$/, S = /\.internal\.tsx?$/, C = /\.types\.tsx?$/, w = /\.fixture\.tsx?$/, T = /\.tracking\.tsx?$/, E = /\.store\.tsx?$/, D = /\.(test|spec)\.tsx?$/, O = /* @__PURE__ */ new Set([
3
+ "layout.tsx",
4
+ "error.tsx",
5
+ "loading.tsx",
6
+ "not-found.tsx"
7
+ ]);
8
+ //#endregion
9
+ export { a as C, i as D, n as E, r as O, T as S, s as T, p as _, w as a, l as b, v as c, O as d, e as f, h as g, m as h, o as i, g as k, c as l, u as m, y as n, x as o, t as p, b as r, S as s, d as t, _ as u, f as v, C as w, D as x, E as y };
@@ -0,0 +1,601 @@
1
+ import { n as e } from "./appModuleLoader-C9r9mxZt.js";
2
+ import { C as t, D as n, T as r, i, l as a } from "./fileConventions-COg0ZytD.js";
3
+ import { basename as o, join as s } from "node:path";
4
+ import { pathToFileURL as c } from "node:url";
5
+ import { Effect as l } from "effect";
6
+ import { promises as u } from "node:fs";
7
+ import { _voltroConnectionGrantsTable as d, _voltroConnectionsTable as f, _voltroScheduleClaimsTable as p, _voltroScheduleRunsTable as m, _voltroTracesTable as h, _voltroUndoLogTable as ee, _voltroWakeupsTable as g, _voltroWorkflowEventDeliveriesTable as te, _voltroWorkflowEventsTable as ne, outboxAttemptsTable as re, outboxTable as ie, undoCaptureEnabled as ae } from "@voltro/runtime";
8
+ import { SqlClient as _ } from "@effect/sql";
9
+ import { _voltroWorkflowRunEventsTable as oe, _voltroWorkflowRunStepsTable as se, _voltroWorkflowRunsTable as ce, _voltroWorkflowStartContextsTable as le } from "@voltro/workflow";
10
+ import { agentMessagesTable as ue, agentThreadsTable as de, aiBudgetTable as fe, aiUsageTable as pe, isAgentDescriptor as me, isAgentExecutor as v, resolveToolModuleHandlers as y } from "@voltro/ai";
11
+ import { _voltroApiKeysTable as b, _voltroCdcOffsetsTable as x, _voltroIdempotencyTable as S, _voltroKvTable as C, _voltroMigrationPlansTable as w, _voltroMigrationsTable as T, _voltroMssqlCdcOffsetsTable as E, _voltroSeedsTable as D, lt as O } from "@voltro/database";
12
+ import { _voltroWebhookDeliveriesTable as k, _voltroWebhookTargetsTable as A } from "@voltro/plugin-webhooks/mixin";
13
+ import { _voltroStorageBlobsTable as j, _voltroStorageGrantsTable as M, _voltroStorageRefsTable as N, _voltroStorageUsageTable as P } from "@voltro/plugin-storage";
14
+ import { defineAction as F, defineMutation as I, defineQuery as L } from "@voltro/protocol";
15
+ //#region src/frameworkTables.ts
16
+ var R = [
17
+ {
18
+ table: T,
19
+ when: "always"
20
+ },
21
+ {
22
+ table: D,
23
+ when: "always"
24
+ },
25
+ {
26
+ table: w,
27
+ when: "always"
28
+ },
29
+ {
30
+ table: ce,
31
+ when: "workflows"
32
+ },
33
+ {
34
+ table: se,
35
+ when: "workflows"
36
+ },
37
+ {
38
+ table: oe,
39
+ when: "workflows"
40
+ },
41
+ {
42
+ table: le,
43
+ when: "workflows"
44
+ },
45
+ {
46
+ table: ne,
47
+ when: "workflows"
48
+ },
49
+ {
50
+ table: te,
51
+ when: "workflows"
52
+ },
53
+ {
54
+ table: m,
55
+ when: "schedules"
56
+ },
57
+ {
58
+ table: p,
59
+ when: "schedules"
60
+ },
61
+ {
62
+ table: A,
63
+ when: "webhooks"
64
+ },
65
+ {
66
+ table: k,
67
+ when: "webhooks"
68
+ },
69
+ {
70
+ table: h,
71
+ when: "traces"
72
+ },
73
+ {
74
+ table: ee,
75
+ when: "undo"
76
+ },
77
+ {
78
+ table: ie,
79
+ when: "outbox"
80
+ },
81
+ {
82
+ table: re,
83
+ when: "outbox"
84
+ },
85
+ {
86
+ table: f,
87
+ when: "connections"
88
+ },
89
+ {
90
+ table: d,
91
+ when: "connections"
92
+ },
93
+ {
94
+ table: g,
95
+ when: "always"
96
+ },
97
+ {
98
+ table: N,
99
+ when: "always"
100
+ },
101
+ {
102
+ table: M,
103
+ when: "always"
104
+ },
105
+ {
106
+ table: j,
107
+ when: "always"
108
+ },
109
+ {
110
+ table: P,
111
+ when: "always"
112
+ },
113
+ {
114
+ table: S,
115
+ when: "always"
116
+ },
117
+ {
118
+ table: b,
119
+ when: "always"
120
+ },
121
+ {
122
+ table: C,
123
+ when: "always"
124
+ }
125
+ ], z = (e) => {
126
+ let t = R.filter((t) => t.when === "always" || t.when === "workflows" && e.workflows || t.when === "schedules" && e.schedules || t.when === "webhooks" && e.webhooks || t.when === "traces" && e.traces || t.when === "undo" && e.undo === !0 || t.when === "outbox" && e.outbox === !0 || t.when === "connections" && e.connections === !0).map((e) => e.table);
127
+ return e.cdc === !0 && t.push(e.cdcDialect === "mssql" ? E : x), t;
128
+ }, B = (e) => {
129
+ let t = e.startsWith("@") ? e.replace(/^@[^/]+\//, "") : e;
130
+ return (t.startsWith("plugin-") ? t.slice(7) : t).replace(/-([a-zA-Z0-9])/g, (e, t) => t.toUpperCase());
131
+ }, he = (e) => {
132
+ let t = e.startsWith("@") ? e.replace(/^@[^/]+\//, "") : e;
133
+ return (t.startsWith("plugin-") ? t.slice(7) : t).replace(/#/g, "--").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
134
+ }, ge = (e, t) => t.name.includes(".") ? t.name : `${B(e.name)}.${t.name}`, _e = (e, t, n) => {
135
+ switch (e) {
136
+ case "query": return L({
137
+ name: t,
138
+ input: n.input,
139
+ output: n.output,
140
+ ...n.error === void 0 ? {} : { error: n.error },
141
+ ...n.source === void 0 ? {} : { source: n.source }
142
+ });
143
+ case "mutation": return I({
144
+ name: t,
145
+ input: n.input,
146
+ output: n.output,
147
+ ...n.error === void 0 ? {} : { error: n.error }
148
+ });
149
+ case "action": return F({
150
+ name: t,
151
+ input: n.input,
152
+ output: n.output,
153
+ ...n.error === void 0 ? {} : { error: n.error }
154
+ });
155
+ }
156
+ }, ve = (e) => (t, n) => l.suspend(() => {
157
+ let r = { request: {
158
+ subject: n.request.subject,
159
+ traceId: n.request.traceId
160
+ } };
161
+ return e.execute(t, r);
162
+ }), ye = (e) => {
163
+ let t = [];
164
+ for (let n of e) {
165
+ let e = n.routes ?? [];
166
+ for (let r of e) {
167
+ let e = ge(n, r), i = _e(r.kind, e, r);
168
+ t.push({
169
+ kind: r.kind,
170
+ file: `plugin:${n.name}`,
171
+ descriptor: i,
172
+ executor: ve(r),
173
+ plugin: {
174
+ name: n.name,
175
+ version: n.version
176
+ }
177
+ });
178
+ }
179
+ }
180
+ return t;
181
+ }, be = (e, t) => {
182
+ let n = /* @__PURE__ */ new Map();
183
+ for (let e of t) n.set(e, "user-route");
184
+ for (let t of e) {
185
+ let e = t.descriptor.name, r = n.get(e);
186
+ if (r !== void 0) throw Error(`plugin route tag collision: "${e}" declared by plugin "${t.plugin.name}" but already claimed by ${r === "user-route" ? "a user-authored route" : `plugin "${r}"`}`);
187
+ n.set(e, t.plugin.name);
188
+ }
189
+ }, V = "_voltro_plugin_migrations", xe = () => l.gen(function* () {
190
+ yield* (yield* _.SqlClient).unsafe(`
191
+ CREATE TABLE IF NOT EXISTS ${V} (
192
+ id TEXT PRIMARY KEY,
193
+ plugin_name TEXT NOT NULL,
194
+ migration_id TEXT NOT NULL,
195
+ description TEXT,
196
+ applied_at TEXT NOT NULL
197
+ );
198
+ `).pipe(l.orDie);
199
+ }), Se = (e, t) => `${B(e)}__${t}`, Ce = () => l.gen(function* () {
200
+ let e = yield* _.SqlClient, t = yield* e`SELECT id FROM ${e(V)}`.pipe(l.orDie);
201
+ return new Set(t.map((e) => e.id));
202
+ }), we = (e) => l.gen(function* () {
203
+ let t = yield* _.SqlClient, n = (/* @__PURE__ */ new Date()).toISOString();
204
+ yield* t`
205
+ INSERT INTO ${t(V)} (id, plugin_name, migration_id, description, applied_at)
206
+ VALUES (${e.key}, ${e.pluginName}, ${e.migration.id}, ${e.migration.description ?? null}, ${n})
207
+ `.pipe(l.orDie);
208
+ }), Te = (e) => l.gen(function* () {
209
+ let t = e.flatMap((e) => (e.extendSchema?.migrations ?? []).map((t) => ({
210
+ plugin: e,
211
+ migration: t
212
+ })));
213
+ if (t.length === 0) return [];
214
+ yield* xe();
215
+ let n = yield* Ce(), r = [];
216
+ for (let { plugin: e, migration: i } of t) {
217
+ let t = Se(e.name, i.id), a = Date.now();
218
+ if (n.has(t)) {
219
+ r.push({
220
+ pluginName: e.name,
221
+ migrationId: i.id,
222
+ status: "skipped",
223
+ durationMs: 0
224
+ });
225
+ continue;
226
+ }
227
+ let o = yield* _.SqlClient;
228
+ try {
229
+ yield* i.up(o).pipe(l.mapError((e) => e)), yield* we({
230
+ key: t,
231
+ pluginName: e.name,
232
+ migration: i
233
+ }), r.push({
234
+ pluginName: e.name,
235
+ migrationId: i.id,
236
+ status: "applied",
237
+ durationMs: Date.now() - a
238
+ });
239
+ } catch (t) {
240
+ return r.push({
241
+ pluginName: e.name,
242
+ migrationId: i.id,
243
+ status: "failed",
244
+ durationMs: Date.now() - a,
245
+ error: t
246
+ }), yield* l.fail(/* @__PURE__ */ Error(`Plugin migration failed: ${e.name} ${i.id} — ${t instanceof Error ? t.message : String(t)}`));
247
+ }
248
+ }
249
+ return r;
250
+ }), Ee = (e) => e.filter((e) => e.extendSchema && (e.extendSchema.tables?.length ?? 0) + (e.extendSchema.migrations?.length ?? 0) > 0).map((e) => ({
251
+ pluginName: e.name,
252
+ pluginAlias: B(e.name),
253
+ tables: e.extendSchema.tables?.length ?? 0,
254
+ migrations: e.extendSchema.migrations?.length ?? 0
255
+ })), De = (e) => e.flatMap((e) => e.extendSchema?.tables ?? []), H = /(?<!\.server)\.agent\.tsx?$/, Oe = /\.agent\.server\.tsx?$/, U = /\.tool\.tsx?$/, ke = async (t, n) => {
256
+ let r = 0;
257
+ for (let i of t) if (U.test(i)) try {
258
+ let t = await e(i);
259
+ r += y(t);
260
+ } catch (e) {
261
+ n.warn("tool: failed to import — handler not wired", { file: i }, e);
262
+ }
263
+ return r;
264
+ }, Ae = (e) => e.replace(/\.agent\.(tsx?)$/, ".agent.server.$1"), je = async (t, n) => {
265
+ let r = [], i = /* @__PURE__ */ new Set();
266
+ for (let a of t) {
267
+ if (!H.test(a)) continue;
268
+ let t;
269
+ try {
270
+ t = await e(a);
271
+ } catch (e) {
272
+ n.warn("agent: failed to import descriptor", { file: a }, e);
273
+ continue;
274
+ }
275
+ let o = Object.values(t).find(me);
276
+ if (o === void 0) {
277
+ n.warn("agent: no defineAgent() descriptor export found", { file: a });
278
+ continue;
279
+ }
280
+ if (i.has(o.name)) {
281
+ n.warn("agent: duplicate name — skipping", {
282
+ file: a,
283
+ name: o.name
284
+ });
285
+ continue;
286
+ }
287
+ let s = Ae(a), c;
288
+ try {
289
+ c = await e(s);
290
+ } catch (e) {
291
+ n.warn("agent: no executor — expected a `*.agent.server.tsx` default-exporting defineAgentExecutor()", {
292
+ descriptor: a,
293
+ expected: s,
294
+ name: o.name
295
+ }, e);
296
+ continue;
297
+ }
298
+ let l = c.default;
299
+ if (!v(l)) {
300
+ n.warn("agent: executor file must default-export defineAgentExecutor(descriptor, {...})", {
301
+ file: s,
302
+ name: o.name
303
+ });
304
+ continue;
305
+ }
306
+ i.add(o.name), r.push({
307
+ file: a,
308
+ serverFile: s,
309
+ descriptor: o,
310
+ executor: l
311
+ });
312
+ }
313
+ return { agents: r };
314
+ }, W = /\.connection\.tsx?$/, Me = (e) => e.replace(W, ""), Ne = async (t, n) => {
315
+ let r = [], i = /* @__PURE__ */ new Map();
316
+ for (let a of t) {
317
+ let t;
318
+ try {
319
+ t = await e(a);
320
+ } catch (e) {
321
+ n.warn("connections: failed to import", { file: a }, e);
322
+ continue;
323
+ }
324
+ let o = t.default;
325
+ if (o === void 0 || typeof o != "object" || !o) {
326
+ n.warn("connections: missing or non-object default export — expected `defineConnection({...})`", { file: a });
327
+ continue;
328
+ }
329
+ let s = o;
330
+ if (typeof s.id != "string" || s.id.length === 0) {
331
+ n.warn("connections: invalid `id` field", { file: a });
332
+ continue;
333
+ }
334
+ if (s.kind !== "oauth2" && s.kind !== "pat") {
335
+ n.warn("connections: `kind` must be \"oauth2\" or \"pat\"", {
336
+ file: a,
337
+ kind: String(s.kind)
338
+ });
339
+ continue;
340
+ }
341
+ let c = i.get(s.id);
342
+ if (c !== void 0) {
343
+ n.error("connections: DUPLICATE id — only the first is registered", {
344
+ id: s.id,
345
+ registered: c,
346
+ ignored: a
347
+ });
348
+ continue;
349
+ }
350
+ i.set(s.id, a), r.push({
351
+ file: a,
352
+ definition: s
353
+ });
354
+ }
355
+ return r.length > 0 && n.info("discovered connections", {
356
+ connections: r.map((e) => `${e.definition.id} (${e.definition.kind})`),
357
+ files: r.map((e) => Me(o(e.file)))
358
+ }), r;
359
+ }, G = (e) => typeof e.attributes["framework.kind"] == "string" && e.attributes["framework.kind"].startsWith("subscription."), K = (e) => {
360
+ if (e.name.includes("_voltro_traces")) return !0;
361
+ for (let t in e.attributes) {
362
+ let n = e.attributes[t];
363
+ if (typeof n == "string" && n.includes("_voltro_traces")) return !0;
364
+ }
365
+ return !1;
366
+ }, Pe = (e) => typeof e.attributes["framework.kind"] == "string" && e.attributes["framework.kind"].startsWith("subscription"), Fe = 1e3, Ie = 500, Le = 50, q = class {
367
+ capacity;
368
+ buffer = [];
369
+ constructor(e = Fe) {
370
+ this.capacity = e;
371
+ }
372
+ append(e) {
373
+ this.buffer.push(e), this.buffer.length > this.capacity && this.buffer.shift();
374
+ }
375
+ query(e = {}) {
376
+ let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ?? Ie, this.capacity), i = e.traceId, a = e.minDurationMs, o = e.status, s = e.name?.toLowerCase(), c = [];
377
+ for (let e = this.buffer.length - 1; e >= 0 && c.length < r; e--) {
378
+ let r = this.buffer[e];
379
+ r.startMs < t || r.startMs > n || i !== void 0 && r.traceId !== i || a !== void 0 && r.durationMs < a || o !== void 0 && r.status !== o || s !== void 0 && !r.name.toLowerCase().includes(s) || c.push(r);
380
+ }
381
+ return c.reverse();
382
+ }
383
+ queryGrouped(e = {}) {
384
+ let t = e.since ?? 0, n = e.maxTraces ?? Le, r = e.onlyErrors ?? !1, i = /* @__PURE__ */ new Map();
385
+ for (let e of this.buffer) {
386
+ if (e.startMs < t) continue;
387
+ let n = i.get(e.traceId);
388
+ n ? n.push(e) : i.set(e.traceId, [e]);
389
+ }
390
+ let a = [];
391
+ for (let [e, t] of i) {
392
+ t.sort((e, t) => e.startMs - t.startMs);
393
+ let n = t.some((e) => e.status === "error");
394
+ if (r && !n) continue;
395
+ let i = t[0].startMs, o = t.reduce((e, t) => t.endMs > e ? t.endMs : e, i), s = t.filter(G), c = s.length > 0 || t.some(Pe), l = s.reduce((e, t) => e === void 0 || t.startMs > e.startMs ? t : e, void 0);
396
+ a.push({
397
+ traceId: e,
398
+ rootName: t[0].name,
399
+ startMs: i,
400
+ durationMs: o - i,
401
+ spanCount: t.length,
402
+ hasError: n,
403
+ kind: c ? "subscription" : "request",
404
+ ...l === void 0 ? {} : { lastDeliveryMs: l.durationMs },
405
+ ...s.length > 0 ? { deliveryCount: s.length } : {},
406
+ spans: t
407
+ });
408
+ }
409
+ return a.sort((e, t) => t.startMs - e.startMs), a.slice(0, n);
410
+ }
411
+ size() {
412
+ return this.buffer.length;
413
+ }
414
+ capacityHint() {
415
+ return this.capacity;
416
+ }
417
+ clear() {
418
+ this.buffer = [];
419
+ }
420
+ }, J = null, Re = () => (J === null && (J = new q()), J), Y = /* @__PURE__ */ new Set([
421
+ "off",
422
+ "errors",
423
+ "interesting",
424
+ "all"
425
+ ]), X = (e, t, n, r) => {
426
+ let i = Number(e);
427
+ return Number.isFinite(i) ? Math.min(r, Math.max(n, i)) : t;
428
+ }, ze = (e) => e !== void 0 && [
429
+ "1",
430
+ "true",
431
+ "yes",
432
+ "on"
433
+ ].includes(e.toLowerCase()), Be = (e) => {
434
+ let t = Number(e);
435
+ return Number.isFinite(t) && t > 0 ? t : 24;
436
+ }, Z = (e = process.env) => {
437
+ let t = (e.VOLTRO_TRACING_BUFFER ?? "").toLowerCase() === "off", n = X(e.VOLTRO_TRACING_SAMPLE, 1, 0, 1), r = (e.VOLTRO_TRACING_PERSIST ?? "").toLowerCase(), i = e.NODE_ENV === "production" ? "off" : "interesting";
438
+ return {
439
+ mode: Y.has(r) ? r : n <= 0 ? "off" : i,
440
+ sampleRate: n,
441
+ slowMs: X(e.VOLTRO_TRACING_SLOW_MS, 500, 0, 2 ** 53 - 1),
442
+ ttlHours: Be(e.VOLTRO_TRACING_TTL_HOURS),
443
+ persistDelivery: ze(e.VOLTRO_TRACING_PERSIST_DELIVERY),
444
+ bufferDisabled: t
445
+ };
446
+ }, Q = (e = process.env) => {
447
+ let t = Z(e);
448
+ return !t.bufferDisabled && t.mode !== "off";
449
+ }, Ve = (e, t) => {
450
+ if (t >= 1) return !0;
451
+ if (t <= 0) return !1;
452
+ let n = 2166136261;
453
+ for (let t = 0; t < e.length; t++) n ^= e.charCodeAt(t), n = Math.imul(n, 16777619);
454
+ return (n >>> 0) % 1e3 < t * 1e3;
455
+ }, He = (e, t) => {
456
+ if (t.mode === "off" || K(e) || G(e) && !t.persistDelivery) return !1;
457
+ let n = e.status === "error";
458
+ if (t.mode === "errors") return n;
459
+ if (n) return !0;
460
+ if (!Ve(e.traceId, t.sampleRate)) return !1;
461
+ if (t.mode === "all") return !0;
462
+ let r = e.parentSpanId === null || e.parentSpanId === void 0 || e.parentSpanId === "", i = typeof e.durationMs == "number" && e.durationMs >= t.slowMs;
463
+ return r || i;
464
+ }, Ue = (e) => {
465
+ if (e.bufferDisabled) return "durable traces: OFF (VOLTRO_TRACING_BUFFER=off)";
466
+ if (e.mode === "off") return "durable traces: OFF — _voltro_traces not created (prod default; set VOLTRO_TRACING_PERSIST=interesting to enable, or use OTLP)";
467
+ let t = e.mode === "interesting" ? ` (errors + slow≥${e.slowMs}ms + roots)` : e.mode === "errors" ? " (errors only)" : "";
468
+ return `durable traces: mode=${e.mode}${t}` + (e.sampleRate < 1 ? ` · sample=${e.sampleRate}` : "") + (e.persistDelivery ? " · +delivery" : "") + ` · ttl=${e.ttlHours}h`;
469
+ }, We = (e = 30 * 6e4) => {
470
+ let t = /* @__PURE__ */ new Map();
471
+ return (n, r) => {
472
+ let i = t.get(n);
473
+ return i !== void 0 && r - i < e ? !1 : (t.set(n, r), !0);
474
+ };
475
+ }, Ge = (e) => {
476
+ let { store: t, log: n } = e, r = e.policy ?? Z();
477
+ n.info(Ue(r));
478
+ let i = We(), a = [], o = () => {};
479
+ if (r.mode !== "off") {
480
+ let e = [], s = 0;
481
+ o = (t) => {
482
+ He(t, r) && (e.length >= 5e3 && (e.shift(), s += 1, i("flush-drop", Date.now()) && (n.warn(`trace flush queue saturated — dropping durable spans (${s}+ since last warning). Durable inflow exceeds write throughput; reduce it with VOLTRO_TRACING_PERSIST=errors|interesting or VOLTRO_TRACING_SAMPLE<1.`), s = 0)), e.push(t));
483
+ };
484
+ let c = async () => {
485
+ if (e.length === 0) return;
486
+ let n = e.splice(0, 200);
487
+ for (let e of n) try {
488
+ await t.insert("_voltro_traces", {
489
+ id: `${e.traceId}:${e.spanId}`,
490
+ traceId: e.traceId,
491
+ spanId: e.spanId,
492
+ parentSpanId: e.parentSpanId,
493
+ name: e.name,
494
+ kind: e.kind,
495
+ status: e.status,
496
+ statusMessage: e.statusMessage ?? null,
497
+ startedAt: new Date(e.startMs),
498
+ endedAt: new Date(e.endMs),
499
+ durationMs: Math.round(e.durationMs),
500
+ attributes: e.attributes,
501
+ events: e.events ?? null
502
+ });
503
+ } catch {}
504
+ }, l = setInterval(() => {
505
+ c();
506
+ }, 1e3);
507
+ l.unref?.(), a.push(l);
508
+ }
509
+ let s = r.ttlHours, c = 2e4, l = t.raw?.bind(t), u = async () => {
510
+ try {
511
+ let e = /* @__PURE__ */ new Date(Date.now() - s * 36e5), r = 0;
512
+ if (l) for (;;) {
513
+ let t = await l({
514
+ _tag: "RawSqlFragment",
515
+ strings: ["DELETE FROM \"_voltro_traces\" WHERE \"id\" IN (SELECT \"id\" FROM \"_voltro_traces\" WHERE \"startedAt\" < ", ` LIMIT ${c}) RETURNING "id"`],
516
+ values: [e]
517
+ });
518
+ if (r += t.length, t.length < c) break;
519
+ }
520
+ else for (;;) {
521
+ let n = await t.query({
522
+ table: "_voltro_traces",
523
+ order: [],
524
+ predicate: O("startedAt", e),
525
+ projection: ["id"],
526
+ skip: void 0,
527
+ take: c
528
+ });
529
+ if (n.length === 0) break;
530
+ for (let e of n) try {
531
+ await t.delete("_voltro_traces", e.id);
532
+ } catch {}
533
+ if (r += n.length, n.length < c) break;
534
+ }
535
+ r >= c && i("gc-volume", Date.now()) && n.warn(`trace GC pruned ${r} spans past the ${s}h TTL in one pass — high durable-trace volume. If _voltro_traces stays large, cut the inflow (VOLTRO_TRACING_PERSIST=errors|interesting, VOLTRO_TRACING_SAMPLE<1) or shorten VOLTRO_TRACING_TTL_HOURS.`);
536
+ } catch (e) {
537
+ i("gc-error", Date.now()) && n.warn(`trace GC pass failed — _voltro_traces may grow until this clears: ${e instanceof Error ? e.message : String(e)}`);
538
+ }
539
+ }, d = setInterval(() => {
540
+ u();
541
+ }, 5 * 6e4);
542
+ return d.unref?.(), a.push(d), {
543
+ persistTraceSpan: (e) => o(e),
544
+ stop: () => {
545
+ for (let e of a) clearInterval(e);
546
+ }
547
+ };
548
+ }, Ke = async (e) => {
549
+ let o = !1, c = !1, l = !1, d = !1, f = !1, p = !1, m = async (e) => {
550
+ let h = await u.readdir(e, { withFileTypes: !0 }).catch(() => []);
551
+ for (let u of h) if (u.isDirectory()) {
552
+ if (u.name === "node_modules" || u.name === "dist" || u.name === ".framework" || u.name.startsWith(".")) continue;
553
+ await m(s(e, u.name));
554
+ } else {
555
+ let e = u.name;
556
+ (n.test(e) || t.test(e)) && (o = !0), i.test(e) && (c = !0), r.test(e) && (l = !0), H.test(e) && (d = !0), a.test(e) && (f = !0), W.test(e) && (p = !0);
557
+ }
558
+ };
559
+ return await m(e), {
560
+ workflows: o,
561
+ schedules: c,
562
+ webhooks: l,
563
+ agents: d,
564
+ outbox: f,
565
+ connections: p
566
+ };
567
+ }, qe = async (e) => {
568
+ try {
569
+ return (await import(c(s(e, "app.config.ts")).href)).default?.plugins ?? [];
570
+ } catch {
571
+ return [];
572
+ }
573
+ }, $ = (e) => {
574
+ let t = /* @__PURE__ */ new Map(), n = (e) => {
575
+ e?.tableName && !t.has(e.tableName) && t.set(e.tableName, e);
576
+ };
577
+ for (let t of z({
578
+ workflows: e.mix.workflows,
579
+ schedules: e.mix.schedules,
580
+ webhooks: e.mix.webhooks,
581
+ traces: Q(),
582
+ cdc: e.cdc,
583
+ ...e.cdcDialect ? { cdcDialect: e.cdcDialect } : {},
584
+ undo: ae(),
585
+ outbox: e.mix.outbox,
586
+ connections: e.mix.connections
587
+ })) n(t);
588
+ e.mix.agents && (n(de), n(ue), n(pe), n(fe));
589
+ for (let t of De(e.plugins)) n(t);
590
+ return [...t.values()];
591
+ }, Je = async (e) => {
592
+ let t = await Ke(e.root), n = await qe(e.root), r = (process.env.DB_DIALECT ?? "postgres").toLowerCase(), i = r === "mariadb" ? "mariadb" : r === "mssql" ? "mssql" : void 0;
593
+ return $({
594
+ mix: t,
595
+ plugins: n,
596
+ cdc: e.cdc ?? (i !== void 0 && (process.env.CDC ?? "1") !== "0"),
597
+ ...i ? { cdcDialect: i } : {}
598
+ });
599
+ };
600
+ //#endregion
601
+ export { be as _, q as a, he as b, W as c, Oe as d, U as f, Ee as g, Te as h, Q as i, Ne as l, ke as m, $ as n, Re as o, je as p, Ge as r, K as s, Je as t, H as u, ye as v, z as x, B as y };
@@ -0,0 +1,2 @@
1
+ import { t as e } from "./frameworkTableAssembly-DCLhpHsF.js";
2
+ export { e as assembleFrameworkTables };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, i as t, n, o as r, r as i, t as a } from "./commands-BmNi1RgZ.js";
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./commands-D-teL_TM.js";
2
2
  //#region src/index.ts
3
3
  var o = "framework";
4
4
  //#endregion