trellis 3.1.35 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/CHANGELOG.md +23 -5
  2. package/README.md +63 -156
  3. package/bin/trellis.mjs +2 -75
  4. package/dist/{better-sqlite-backend-ahx5p0br.js → better-sqlite-backend-2P4F6AOJ.js} +91 -29
  5. package/dist/boot-middleware-MHLHFCUC.js +9 -0
  6. package/dist/browser/index.d.ts +18 -0
  7. package/dist/browser/index.d.ts.map +1 -0
  8. package/dist/browser/index.js +95 -0
  9. package/dist/{index-53f3b8p8.js → chunk-2W3MHTMG.js} +552 -213
  10. package/dist/chunk-44FFQKQX.js +142 -0
  11. package/dist/chunk-4HYPLFJD.js +150 -0
  12. package/dist/chunk-4XIVMVHC.js +361 -0
  13. package/dist/{index-yp88he8n.js → chunk-6CTA6MCE.js} +88 -64
  14. package/dist/chunk-6GEZ6DN5.js +394 -0
  15. package/dist/chunk-7ZFRVCUE.js +211 -0
  16. package/dist/chunk-CAG4FULI.js +121 -0
  17. package/dist/chunk-FF36CQHZ.js +61 -0
  18. package/dist/{index-h32txmxe.js → chunk-FKQO5A3H.js} +6 -13
  19. package/dist/{index-nq520y6k.js → chunk-FWRS4CSC.js} +46 -32
  20. package/dist/chunk-GFZCJ4EH.js +108 -0
  21. package/dist/chunk-GLM4HGN4.js +55 -0
  22. package/dist/{index-4cdr7x2x.js → chunk-GU374KWZ.js} +182 -111
  23. package/dist/chunk-H6JB3PZ3.js +45 -0
  24. package/dist/chunk-IZX2PLIB.js +1240 -0
  25. package/dist/chunk-J2TXUFCZ.js +289 -0
  26. package/dist/chunk-J3WYZO3Q.js +211 -0
  27. package/dist/{index-xzym9w0m.js → chunk-JA7AIHRK.js} +12 -7
  28. package/dist/chunk-JHHEXEDM.js +162 -0
  29. package/dist/chunk-JUEMDWLU.js +233 -0
  30. package/dist/chunk-KFQGP6VL.js +33 -0
  31. package/dist/chunk-KIJITUZB.js +419 -0
  32. package/dist/{index-4wxa8xz4.js → chunk-KQ4A2D2P.js} +162 -23
  33. package/dist/chunk-KSU2GW22.js +958 -0
  34. package/dist/{index-rv1p47gp.js → chunk-L5N5PR2S.js} +3015 -2480
  35. package/dist/{index-h9e2efx4.js → chunk-LNUIGRDZ.js} +71 -55
  36. package/dist/{index-skhn0agf.js → chunk-MLC5BUYO.js} +19 -20
  37. package/dist/chunk-MPXUVGT3.js +104 -0
  38. package/dist/chunk-N6MYZT4O.js +68 -0
  39. package/dist/chunk-O2AV5WMN.js +48 -0
  40. package/dist/chunk-PZ4XYZ4J.js +143 -0
  41. package/dist/chunk-QB5ISE47.js +419 -0
  42. package/dist/chunk-RSWUFTO2.js +857 -0
  43. package/dist/chunk-S3XLFZ27.js +1095 -0
  44. package/dist/{index-w5wccer3.js → chunk-S6GBJ2ZB.js} +28 -12
  45. package/dist/{index-7pjz3tsy.js → chunk-SGMDTWJJ.js} +57 -15
  46. package/dist/chunk-SPSPV5BC.js +390 -0
  47. package/dist/chunk-TCKXSOBP.js +123 -0
  48. package/dist/chunk-UBGUDMUV.js +59 -0
  49. package/dist/{index-wt8rz4gn.js → chunk-UQISRW6T.js} +97 -26
  50. package/dist/chunk-USEINYUL.js +12 -0
  51. package/dist/{index-bmyt7k8n.js → chunk-UZRUP7QW.js} +12 -4
  52. package/dist/{index-xhcp6xrn.js → chunk-VBYUTRXX.js} +695 -514
  53. package/dist/{index-vkpkfwhq.js → chunk-VDAKEOML.js} +234 -194
  54. package/dist/chunk-WXSWA3MV.js +0 -0
  55. package/dist/{index-n9f2qyh5.js → chunk-X5FLTRUB.js} +55 -33
  56. package/dist/{index-h7zxhhhh.js → chunk-XMQ7G77X.js} +46 -38
  57. package/dist/{index-w7ng765c.js → chunk-YCM7ZYEZ.js} +102 -49
  58. package/dist/cli/deploy-cli.d.ts +18 -0
  59. package/dist/cli/deploy-cli.d.ts.map +1 -0
  60. package/dist/cli/errors.d.ts +6 -0
  61. package/dist/cli/errors.d.ts.map +1 -0
  62. package/dist/cli/examples.d.ts +23 -0
  63. package/dist/cli/examples.d.ts.map +1 -0
  64. package/dist/cli/index.d.ts +1 -1
  65. package/dist/cli/index.d.ts.map +1 -1
  66. package/dist/cli/index.js +2426 -6225
  67. package/dist/client/index.browser.d.ts +29 -0
  68. package/dist/client/index.browser.d.ts.map +1 -0
  69. package/dist/client/index.browser.js +64 -0
  70. package/dist/client/index.d.ts +6 -1
  71. package/dist/client/index.d.ts.map +1 -1
  72. package/dist/client/index.js +41 -21
  73. package/dist/client/live.d.ts +67 -0
  74. package/dist/client/live.d.ts.map +1 -0
  75. package/dist/client/reactive.d.ts +31 -0
  76. package/dist/client/reactive.d.ts.map +1 -0
  77. package/dist/client/sdk.browser.d.ts +104 -0
  78. package/dist/client/sdk.browser.d.ts.map +1 -0
  79. package/dist/client/sdk.browser.js +9 -0
  80. package/dist/client/sdk.d.ts +26 -2
  81. package/dist/client/sdk.d.ts.map +1 -1
  82. package/dist/client/sdk.js +9 -0
  83. package/dist/client/vcs-client.d.ts +129 -0
  84. package/dist/client/vcs-client.d.ts.map +1 -0
  85. package/dist/cms/index.js +171 -163
  86. package/dist/{config-8hczw0rs.js → config-PFTP67TR.js} +8 -9
  87. package/dist/core/computation/index.d.ts +5 -0
  88. package/dist/core/computation/index.d.ts.map +1 -0
  89. package/dist/core/computation/rollup.d.ts +18 -0
  90. package/dist/core/computation/rollup.d.ts.map +1 -0
  91. package/dist/core/index.d.ts +5 -0
  92. package/dist/core/index.d.ts.map +1 -1
  93. package/dist/core/index.js +171 -104
  94. package/dist/core/kernel/boot-middleware.d.ts +10 -0
  95. package/dist/core/kernel/boot-middleware.d.ts.map +1 -0
  96. package/dist/core/kernel/logic-middleware.d.ts +7 -1
  97. package/dist/core/kernel/logic-middleware.d.ts.map +1 -1
  98. package/dist/core/kernel/trellis-kernel.d.ts.map +1 -1
  99. package/dist/core/ontology/types.d.ts +5 -0
  100. package/dist/core/ontology/types.d.ts.map +1 -1
  101. package/dist/core/persist/better-sqlite-backend.d.ts +9 -2
  102. package/dist/core/persist/better-sqlite-backend.d.ts.map +1 -1
  103. package/dist/core/persist/factory.d.ts +6 -7
  104. package/dist/core/persist/factory.d.ts.map +1 -1
  105. package/dist/core/persist/factory.js +2 -3
  106. package/dist/core/persist/sqljs-backend.js +2 -3
  107. package/dist/db/index.d.ts +4 -1
  108. package/dist/db/index.d.ts.map +1 -1
  109. package/dist/db/index.js +67 -54
  110. package/dist/db/inspector.js +11 -19
  111. package/dist/db/trellis.css +1 -1
  112. package/dist/decisions/index.js +9 -10
  113. package/dist/deploy-LQ7GUGJ5.js +9 -0
  114. package/dist/deploy-YNVG5E4E.js +9 -0
  115. package/dist/deploy-cli-24BCHAXY.js +67 -0
  116. package/dist/deploy-cli-C35HTITO.js +67 -0
  117. package/dist/embeddings/auto-embed.d.ts +2 -2
  118. package/dist/embeddings/auto-embed.d.ts.map +1 -1
  119. package/dist/embeddings/index.js +20 -22
  120. package/dist/embeddings/search.d.ts +2 -1
  121. package/dist/embeddings/search.d.ts.map +1 -1
  122. package/dist/embeddings/store.d.ts +25 -4
  123. package/dist/embeddings/store.d.ts.map +1 -1
  124. package/dist/engine.d.ts +59 -19
  125. package/dist/engine.d.ts.map +1 -1
  126. package/dist/import-UZEKXU3B.js +10 -0
  127. package/dist/index.js +102 -93
  128. package/dist/launch-explorer-HZ4ZJA4X.js +95 -0
  129. package/dist/links/index.js +24 -26
  130. package/dist/mcp/server.d.ts.map +1 -1
  131. package/dist/plugins/agent-memory/index.js +316 -0
  132. package/dist/plugins/idea-garden/index.js +165 -0
  133. package/dist/plugins/plan-approval/index.js +579 -0
  134. package/dist/plugins/proactive-watcher/index.js +194 -0
  135. package/dist/{index-2r4jxwnb.js → query-XYLTJYSA.js} +14 -15
  136. package/dist/react/index.js +39 -70
  137. package/dist/react/realtime.js +11 -0
  138. package/dist/react/schema-hooks.js +87 -0
  139. package/dist/realtime/broadcast-channel-transport.d.ts +43 -0
  140. package/dist/realtime/broadcast-channel-transport.d.ts.map +1 -0
  141. package/dist/realtime/durable-object-relay-transport.d.ts +96 -0
  142. package/dist/realtime/durable-object-relay-transport.d.ts.map +1 -0
  143. package/dist/realtime/index.d.ts +44 -0
  144. package/dist/realtime/index.d.ts.map +1 -0
  145. package/dist/realtime/index.js +40 -0
  146. package/dist/realtime/memory-hub.d.ts +32 -0
  147. package/dist/realtime/memory-hub.d.ts.map +1 -0
  148. package/dist/realtime/persistent-channel.d.ts +105 -0
  149. package/dist/realtime/persistent-channel.d.ts.map +1 -0
  150. package/dist/realtime/presence.d.ts +73 -0
  151. package/dist/realtime/presence.d.ts.map +1 -0
  152. package/dist/realtime/relay-persistence.d.ts +37 -0
  153. package/dist/realtime/relay-persistence.d.ts.map +1 -0
  154. package/dist/realtime/relay-persistence.js +107 -0
  155. package/dist/realtime/relay-server.d.ts +103 -0
  156. package/dist/realtime/relay-server.d.ts.map +1 -0
  157. package/dist/realtime/room.d.ts +98 -0
  158. package/dist/realtime/room.d.ts.map +1 -0
  159. package/dist/realtime/text.d.ts +73 -0
  160. package/dist/realtime/text.d.ts.map +1 -0
  161. package/dist/realtime/types.d.ts +89 -0
  162. package/dist/realtime/types.d.ts.map +1 -0
  163. package/dist/realtime/websocket-relay-transport.d.ts +28 -0
  164. package/dist/realtime/websocket-relay-transport.d.ts.map +1 -0
  165. package/dist/realtime.bundle.js +1100 -0
  166. package/dist/{remote-manager-xvbg4230.js → remote-manager-ODE3T2KR.js} +25 -15
  167. package/dist/scaffold/seed.d.ts.map +1 -1
  168. package/dist/scaffold/write.d.ts +1 -1
  169. package/dist/scaffold/write.d.ts.map +1 -1
  170. package/dist/schema/define.d.ts +137 -0
  171. package/dist/schema/define.d.ts.map +1 -0
  172. package/dist/schema/entity-projection.d.ts +34 -0
  173. package/dist/schema/entity-projection.d.ts.map +1 -0
  174. package/dist/schema/eql.d.ts +46 -0
  175. package/dist/schema/eql.d.ts.map +1 -0
  176. package/dist/schema/index.d.ts +21 -0
  177. package/dist/schema/index.d.ts.map +1 -0
  178. package/dist/schema/index.js +46 -0
  179. package/dist/schema/kernel-resolve.d.ts +21 -0
  180. package/dist/schema/kernel-resolve.d.ts.map +1 -0
  181. package/dist/schema/mutations.d.ts +20 -0
  182. package/dist/schema/mutations.d.ts.map +1 -0
  183. package/dist/schema/resolve.d.ts +21 -0
  184. package/dist/schema/resolve.d.ts.map +1 -0
  185. package/dist/server/deploy-meta.d.ts +25 -0
  186. package/dist/server/deploy-meta.d.ts.map +1 -0
  187. package/dist/server/deploy.d.ts +7 -2
  188. package/dist/server/deploy.d.ts.map +1 -1
  189. package/dist/server/index.d.ts +7 -2
  190. package/dist/server/index.d.ts.map +1 -1
  191. package/dist/server/index.js +100 -58
  192. package/dist/server/node-adapter.js +5 -104
  193. package/dist/server/realtime.d.ts +14 -3
  194. package/dist/server/realtime.d.ts.map +1 -1
  195. package/dist/server/server.d.ts +8 -16
  196. package/dist/server/server.d.ts.map +1 -1
  197. package/dist/server/sprites.d.ts +18 -1
  198. package/dist/server/sprites.d.ts.map +1 -1
  199. package/dist/server/tenancy.d.ts +4 -0
  200. package/dist/server/tenancy.d.ts.map +1 -1
  201. package/dist/server/usage-meter.d.ts +53 -0
  202. package/dist/server/usage-meter.d.ts.map +1 -0
  203. package/dist/server-MB3OPSPI.js +18 -0
  204. package/dist/server-ZVWGLLRF.js +18 -0
  205. package/dist/sprites-KQGTGM6W.js +27 -0
  206. package/dist/{sprites-vc4qbrp1.js → sprites-RU3E4XQN.js} +6 -7
  207. package/dist/svelte/index.d.ts +17 -0
  208. package/dist/svelte/index.d.ts.map +1 -0
  209. package/dist/svelte/index.js +51 -0
  210. package/dist/svelte/schema-hooks.d.ts +45 -0
  211. package/dist/svelte/schema-hooks.d.ts.map +1 -0
  212. package/dist/svelte/schema-hooks.js +71 -0
  213. package/dist/svelte/stores.d.ts +78 -0
  214. package/dist/svelte/stores.d.ts.map +1 -0
  215. package/dist/sync/http-transport.d.ts +3 -3
  216. package/dist/sync/http-transport.d.ts.map +1 -1
  217. package/dist/sync/index.d.ts +15 -1
  218. package/dist/sync/index.d.ts.map +1 -1
  219. package/dist/sync/index.js +617 -0
  220. package/dist/sync/memory-room.d.ts +37 -0
  221. package/dist/sync/memory-room.d.ts.map +1 -0
  222. package/dist/sync/memory-transport.d.ts +3 -3
  223. package/dist/sync/memory-transport.d.ts.map +1 -1
  224. package/dist/sync/partykit-room.d.ts +40 -0
  225. package/dist/sync/partykit-room.d.ts.map +1 -0
  226. package/dist/sync/partykit-transport.d.ts +84 -0
  227. package/dist/sync/partykit-transport.d.ts.map +1 -0
  228. package/dist/sync/room-core.d.ts +53 -0
  229. package/dist/sync/room-core.d.ts.map +1 -0
  230. package/dist/sync/sync-engine.d.ts +40 -2
  231. package/dist/sync/sync-engine.d.ts.map +1 -1
  232. package/dist/sync/sync-room-server.d.ts +39 -0
  233. package/dist/sync/sync-room-server.d.ts.map +1 -0
  234. package/dist/sync/types.d.ts +70 -3
  235. package/dist/sync/types.d.ts.map +1 -1
  236. package/dist/sync/vcs-sync-peer.d.ts +63 -0
  237. package/dist/sync/vcs-sync-peer.d.ts.map +1 -0
  238. package/dist/sync/ws-transport.d.ts +2 -2
  239. package/dist/sync/ws-transport.d.ts.map +1 -1
  240. package/dist/tenancy-NBLLGCNJ.js +14 -0
  241. package/dist/tenancy-POMWQP6M.js +16 -0
  242. package/dist/ui/client.html +355 -67
  243. package/dist/ui/launch-explorer.d.ts +22 -0
  244. package/dist/ui/launch-explorer.d.ts.map +1 -0
  245. package/dist/ui/server.d.ts +1 -1
  246. package/dist/ui/server.d.ts.map +1 -1
  247. package/dist/vcs/blob-store.d.ts.map +1 -1
  248. package/dist/vcs/idb-op-log.d.ts +67 -0
  249. package/dist/vcs/idb-op-log.d.ts.map +1 -0
  250. package/dist/vcs/index.d.ts +1 -0
  251. package/dist/vcs/index.d.ts.map +1 -1
  252. package/dist/vcs/index.js +81 -72
  253. package/dist/vcs/issue.d.ts +22 -5
  254. package/dist/vcs/issue.d.ts.map +1 -1
  255. package/dist/vcs/lane-materialize.d.ts +5 -0
  256. package/dist/vcs/lane-materialize.d.ts.map +1 -1
  257. package/dist/vcs/op-log.d.ts +28 -2
  258. package/dist/vcs/op-log.d.ts.map +1 -1
  259. package/dist/vcs/ops.d.ts +10 -0
  260. package/dist/vcs/ops.d.ts.map +1 -1
  261. package/dist/vcs/types.d.ts +2 -0
  262. package/dist/vcs/types.d.ts.map +1 -1
  263. package/dist/{vm-config-6xhsj6b3.js → vm-config-JI4OXKDQ.js} +9 -10
  264. package/dist/vue/hooks.d.ts +64 -0
  265. package/dist/vue/hooks.d.ts.map +1 -0
  266. package/dist/vue/index.d.ts +19 -0
  267. package/dist/vue/index.d.ts.map +1 -0
  268. package/dist/vue/index.js +59 -0
  269. package/dist/vue/schema-hooks.d.ts +41 -0
  270. package/dist/vue/schema-hooks.d.ts.map +1 -0
  271. package/dist/vue/schema-hooks.js +64 -0
  272. package/package.json +130 -17
  273. package/dist/deploy-999q207z.js +0 -10
  274. package/dist/engine-y0724kjq.js +0 -8
  275. package/dist/import-s2b8e0ft.js +0 -11
  276. package/dist/index-a76rekgs.js +0 -67
  277. package/dist/index-c9h37r6h.js +0 -1
  278. package/dist/index-hr9qvv77.js +0 -860
  279. package/dist/index-k5b0xskw.js +0 -1
  280. package/dist/index-nzb3am4f.js +0 -80
  281. package/dist/index-wncptktd.js +0 -292
  282. package/dist/index-y6a4kj0p.js +0 -43
  283. package/dist/index-yhwjgfvj.js +0 -342
  284. package/dist/sdk-bepky0xs.js +0 -16
  285. package/dist/server-szdjx0nt.js +0 -13
  286. package/dist/sqlite-backend-0vsmc6qj.js +0 -8
  287. package/dist/tenancy-pjm32b4v.js +0 -14
@@ -1,9 +1,9 @@
1
- // @bun
2
1
  import {
3
2
  QueryEngine,
4
3
  literal,
5
4
  variable
6
- } from "./index-yp88he8n.js";
5
+ } from "./chunk-6CTA6MCE.js";
6
+
7
7
  // src/core/query/parser.ts
8
8
  function tokenize(input) {
9
9
  const tokens = [];
@@ -14,9 +14,7 @@ function tokenize(input) {
14
14
  continue;
15
15
  }
16
16
  if (input[i] === "/" && input[i + 1] === "/") {
17
- while (i < input.length && input[i] !== `
18
- `)
19
- i++;
17
+ while (i < input.length && input[i] !== "\n") i++;
20
18
  continue;
21
19
  }
22
20
  const pos = i;
@@ -57,8 +55,7 @@ function tokenize(input) {
57
55
  i++;
58
56
  }
59
57
  }
60
- if (i < input.length)
61
- i++;
58
+ if (i < input.length) i++;
62
59
  tokens.push({ kind: "string", value: s, pos });
63
60
  continue;
64
61
  }
@@ -86,8 +83,7 @@ function tokenize(input) {
86
83
  tokens.push({ kind: "eof", value: "", pos: input.length });
87
84
  return tokens;
88
85
  }
89
-
90
- class Parser {
86
+ var Parser = class {
91
87
  tokens;
92
88
  pos = 0;
93
89
  constructor(tokens) {
@@ -101,14 +97,14 @@ class Parser {
101
97
  }
102
98
  expect(kind, value) {
103
99
  const t = this.advance();
104
- if (t.kind !== kind || value !== undefined && t.value !== value) {
100
+ if (t.kind !== kind || value !== void 0 && t.value !== value) {
105
101
  throw new Error(`Expected ${kind}${value ? ` "${value}"` : ""} at pos ${t.pos}, got ${t.kind} "${t.value}"`);
106
102
  }
107
103
  return t;
108
104
  }
109
105
  match(kind, value) {
110
106
  const t = this.peek();
111
- if (t.kind === kind && (value === undefined || t.value === value)) {
107
+ if (t.kind === kind && (value === void 0 || t.value === value)) {
112
108
  this.pos++;
113
109
  return true;
114
110
  }
@@ -116,8 +112,11 @@ class Parser {
116
112
  }
117
113
  isAt(kind, value) {
118
114
  const t = this.peek();
119
- return t.kind === kind && (value === undefined || t.value === value);
115
+ return t.kind === kind && (value === void 0 || t.value === value);
120
116
  }
117
+ // -----------------------------------------------------------------------
118
+ // Terms
119
+ // -----------------------------------------------------------------------
121
120
  parseTerm() {
122
121
  const t = this.peek();
123
122
  if (t.kind === "word" && t.value.startsWith("?")) {
@@ -136,14 +135,15 @@ class Parser {
136
135
  if (t.kind === "word") {
137
136
  const v = t.value;
138
137
  this.advance();
139
- if (v === "true")
140
- return literal(true);
141
- if (v === "false")
142
- return literal(false);
138
+ if (v === "true") return literal(true);
139
+ if (v === "false") return literal(false);
143
140
  return literal(v);
144
141
  }
145
142
  throw new Error(`Unexpected token at pos ${t.pos}: ${t.kind} "${t.value}"`);
146
143
  }
144
+ // -----------------------------------------------------------------------
145
+ // Patterns
146
+ // -----------------------------------------------------------------------
147
147
  parsePattern() {
148
148
  const t = this.peek();
149
149
  if (t.kind === "word" && t.value.toUpperCase() === "NOT") {
@@ -157,7 +157,7 @@ class Parser {
157
157
  while (this.isAt("symbol", "{")) {
158
158
  this.advance();
159
159
  const branch = [];
160
- while (!this.isAt("symbol", "}") && !this.isAt("eof", undefined)) {
160
+ while (!this.isAt("symbol", "}") && !this.isAt("eof", void 0)) {
161
161
  branch.push(this.parsePattern());
162
162
  }
163
163
  this.expect("symbol", "}");
@@ -186,7 +186,7 @@ class Parser {
186
186
  if (this.isAt("symbol", "(")) {
187
187
  this.advance();
188
188
  const args = [];
189
- while (!this.isAt("symbol", ")") && !this.isAt("eof", undefined)) {
189
+ while (!this.isAt("symbol", ")") && !this.isAt("eof", void 0)) {
190
190
  args.push(this.parseTerm());
191
191
  this.match("symbol", ",");
192
192
  }
@@ -197,12 +197,18 @@ class Parser {
197
197
  }
198
198
  throw new Error(`Cannot parse pattern at pos ${t.pos}: ${t.kind} "${t.value}"`);
199
199
  }
200
+ // -----------------------------------------------------------------------
201
+ // Filter
202
+ // -----------------------------------------------------------------------
200
203
  parseFilter() {
201
204
  const left = this.parseTerm();
202
205
  const op = this.advance().value;
203
206
  const right = this.parseTerm();
204
207
  return { kind: "filter", left, op, right };
205
208
  }
209
+ // -----------------------------------------------------------------------
210
+ // Full Query
211
+ // -----------------------------------------------------------------------
206
212
  parseQuery() {
207
213
  const query = {
208
214
  select: [],
@@ -213,7 +219,7 @@ class Parser {
213
219
  limit: 0,
214
220
  offset: 0
215
221
  };
216
- while (!this.isAt("eof", undefined)) {
222
+ while (!this.isAt("eof", void 0)) {
217
223
  const kw = this.peek();
218
224
  if (kw.kind !== "word") {
219
225
  throw new Error(`Expected keyword at pos ${kw.pos}, got ${kw.kind} "${kw.value}"`);
@@ -229,7 +235,7 @@ class Parser {
229
235
  case "WHERE": {
230
236
  this.advance();
231
237
  this.expect("symbol", "{");
232
- while (!this.isAt("symbol", "}") && !this.isAt("eof", undefined)) {
238
+ while (!this.isAt("symbol", "}") && !this.isAt("eof", void 0)) {
233
239
  query.where.push(this.parsePattern());
234
240
  }
235
241
  this.expect("symbol", "}");
@@ -282,11 +288,14 @@ class Parser {
282
288
  }
283
289
  return query;
284
290
  }
291
+ // -----------------------------------------------------------------------
292
+ // Datalog Rule
293
+ // -----------------------------------------------------------------------
285
294
  parseRule() {
286
295
  const name = this.expect("word").value;
287
296
  this.expect("symbol", "(");
288
297
  const params = [];
289
- while (!this.isAt("symbol", ")") && !this.isAt("eof", undefined)) {
298
+ while (!this.isAt("symbol", ")") && !this.isAt("eof", void 0)) {
290
299
  const v = this.expect("word").value;
291
300
  params.push(v.startsWith("?") ? v.slice(1) : v);
292
301
  this.match("symbol", ",");
@@ -302,7 +311,7 @@ class Parser {
302
311
  }
303
312
  const body = [];
304
313
  const filters = [];
305
- while (!this.isAt("eof", undefined)) {
314
+ while (!this.isAt("eof", void 0)) {
306
315
  if (this.peek().kind === "word" && this.peek().value.toUpperCase() === "FILTER") {
307
316
  this.advance();
308
317
  filters.push(this.parseFilter());
@@ -313,7 +322,7 @@ class Parser {
313
322
  }
314
323
  return { name, params, body, filters };
315
324
  }
316
- }
325
+ };
317
326
  function parseQuery(input) {
318
327
  const tokens = tokenize(input);
319
328
  return new Parser(tokens).parseQuery();
@@ -353,18 +362,18 @@ function parseSimple(input) {
353
362
  }
354
363
  const fullQuery = `SELECT ${selectVars.join(" ")}
355
364
  WHERE {
356
- ${patterns.join(`
357
- `)}
365
+ ${patterns.join("\n ")}
358
366
  }
359
- ${filters.join(`
360
- `)}`;
367
+ ${filters.join("\n")}`;
361
368
  return parseQuery(fullQuery);
362
369
  }
363
370
  throw new Error(`Cannot parse query: "${trimmed}". Use full EQL-S syntax or "find ?e where attr = value".`);
364
371
  }
372
+
365
373
  // src/core/query/datalog.ts
366
374
  function transitiveClosureRules(ruleName, linkAttribute) {
367
375
  return [
376
+ // Base case: direct link
368
377
  {
369
378
  name: ruleName,
370
379
  params: ["x", "y"],
@@ -378,6 +387,7 @@ function transitiveClosureRules(ruleName, linkAttribute) {
378
387
  ],
379
388
  filters: []
380
389
  },
390
+ // Recursive case: indirect via intermediate
381
391
  {
382
392
  name: ruleName,
383
393
  params: ["x", "y"],
@@ -463,33 +473,45 @@ function siblingRules(ruleName, linkAttribute) {
463
473
  }
464
474
  ];
465
475
  }
466
-
467
- class DatalogRuntime {
476
+ var DatalogRuntime = class {
468
477
  engine;
469
478
  constructor(store) {
470
479
  this.engine = new QueryEngine(store);
471
480
  }
481
+ /** Register a Datalog rule (or multiple). */
472
482
  addRule(rule) {
473
483
  this.engine.addRule(rule);
474
484
  }
475
485
  addRules(rules) {
476
- for (const r of rules)
477
- this.engine.addRule(r);
486
+ for (const r of rules) this.engine.addRule(r);
478
487
  }
479
488
  removeRule(name) {
480
489
  this.engine.removeRule(name);
481
490
  }
491
+ /** Register built-in transitive closure for a link attribute. */
482
492
  registerTransitiveClosure(ruleName, linkAttribute) {
483
493
  this.addRules(transitiveClosureRules(ruleName, linkAttribute));
484
494
  }
495
+ /** Register built-in reverse reachability for a link attribute. */
485
496
  registerReverseReachability(ruleName, linkAttribute) {
486
497
  this.addRules(reverseReachabilityRules(ruleName, linkAttribute));
487
498
  }
499
+ /** Register built-in sibling rule for a link attribute. */
488
500
  registerSiblings(ruleName, linkAttribute) {
489
501
  this.addRules(siblingRules(ruleName, linkAttribute));
490
502
  }
503
+ /** Get the underlying QueryEngine for direct query execution. */
491
504
  getEngine() {
492
505
  return this.engine;
493
506
  }
494
- }
495
- export { parseQuery, parseRule, parseSimple, transitiveClosureRules, reverseReachabilityRules, siblingRules, DatalogRuntime };
507
+ };
508
+
509
+ export {
510
+ parseQuery,
511
+ parseRule,
512
+ parseSimple,
513
+ transitiveClosureRules,
514
+ reverseReachabilityRules,
515
+ siblingRules,
516
+ DatalogRuntime
517
+ };
@@ -1,20 +1,20 @@
1
- // @bun
2
1
  import {
3
2
  __require
4
- } from "./index-a76rekgs.js";
3
+ } from "./chunk-KFQGP6VL.js";
5
4
 
6
5
  // src/core/persist/sqlite-backend.ts
7
6
  var _DatabaseCtor = null;
8
7
  function loadDatabaseCtor() {
9
- if (_DatabaseCtor)
10
- return _DatabaseCtor;
8
+ if (_DatabaseCtor) return _DatabaseCtor;
11
9
  try {
12
10
  const { createRequire } = __require("module");
13
11
  const requireCJS = createRequire(import.meta.url);
14
12
  _DatabaseCtor = requireCJS("bun:sqlite").Database;
15
13
  return _DatabaseCtor;
16
14
  } catch {
17
- throw new Error("SqliteKernelBackend requires the Bun runtime (built-in `bun:sqlite`). " + "In Node / WebContainer use `createKernelBackend()` from " + "`trellis/core` \u2014 it auto-selects better-sqlite3 or sql.js.");
15
+ throw new Error(
16
+ "SqliteKernelBackend requires the Bun runtime (built-in `bun:sqlite`). In Node / WebContainer use `createKernelBackend()` from `trellis/core` \u2014 it auto-selects better-sqlite3 or sql.js."
17
+ );
18
18
  }
19
19
  }
20
20
  var SCHEMA_SQL = `
@@ -45,16 +45,14 @@ CREATE INDEX IF NOT EXISTS idx_ops_agent ON ops(agent_id);
45
45
  CREATE INDEX IF NOT EXISTS idx_ops_previous ON ops(previous_hash);
46
46
  CREATE INDEX IF NOT EXISTS idx_snapshots_op ON snapshots(last_op_hash);
47
47
  `;
48
-
49
- class SqliteKernelBackend {
50
- dbPath;
51
- db;
52
- _stmts = null;
48
+ var SqliteKernelBackend = class {
53
49
  constructor(dbPath) {
54
50
  this.dbPath = dbPath;
55
51
  const DatabaseCtor = loadDatabaseCtor();
56
52
  this.db = new DatabaseCtor(dbPath);
57
53
  }
54
+ db;
55
+ _stmts = null;
58
56
  init() {
59
57
  this.db.exec("PRAGMA journal_mode=WAL;");
60
58
  this.db.exec("PRAGMA foreign_keys=ON;");
@@ -110,6 +108,9 @@ class SqliteKernelBackend {
110
108
  `)
111
109
  };
112
110
  }
111
+ // -------------------------------------------------------------------------
112
+ // Op operations
113
+ // -------------------------------------------------------------------------
113
114
  append(op) {
114
115
  const payload = JSON.stringify({
115
116
  facts: op.facts,
@@ -129,8 +130,7 @@ class SqliteKernelBackend {
129
130
  });
130
131
  }
131
132
  appendBatch(ops) {
132
- if (ops.length === 0)
133
- return;
133
+ if (ops.length === 0) return;
134
134
  this.db.transaction(() => {
135
135
  for (const op of ops) {
136
136
  this.append(op);
@@ -150,13 +150,15 @@ class SqliteKernelBackend {
150
150
  return rows.map(rowToOp);
151
151
  }
152
152
  readUntilTimestamp(isoTimestamp) {
153
- const rows = this.db.prepare(`SELECT hash, kind, timestamp, agent_id, previous_hash, payload
154
- FROM ops WHERE timestamp <= $ts ORDER BY rowid ASC`).all({ $ts: isoTimestamp });
153
+ const rows = this.db.prepare(
154
+ `SELECT hash, kind, timestamp, agent_id, previous_hash, payload
155
+ FROM ops WHERE timestamp <= $ts ORDER BY rowid ASC`
156
+ ).all({ $ts: isoTimestamp });
155
157
  return rows.map(rowToOp);
156
158
  }
157
159
  getLastOp() {
158
160
  const row = this._stmts.getLast.get();
159
- return row ? rowToOp(row) : undefined;
161
+ return row ? rowToOp(row) : void 0;
160
162
  }
161
163
  getByHash(hash) {
162
164
  return this.getOpByHash(hash);
@@ -166,14 +168,18 @@ class SqliteKernelBackend {
166
168
  }
167
169
  getOpByHash(hash) {
168
170
  const row = this._stmts.getByHash.get({ $hash: hash });
169
- return row ? rowToOp(row) : undefined;
171
+ return row ? rowToOp(row) : void 0;
170
172
  }
171
173
  count() {
172
174
  const row = this._stmts.count.get();
173
175
  return row?.cnt ?? 0;
174
176
  }
177
+ /**
178
+ * Find the common ancestor op of two op hashes by walking
179
+ * previousHash chains until they converge.
180
+ */
175
181
  findCommonAncestor(hashA, hashB) {
176
- const ancestorsA = new Set;
182
+ const ancestorsA = /* @__PURE__ */ new Set();
177
183
  let cursor = hashA;
178
184
  while (cursor) {
179
185
  ancestorsA.add(cursor);
@@ -188,8 +194,11 @@ class SqliteKernelBackend {
188
194
  const op = this.getOpByHash(cursor);
189
195
  cursor = op?.previousHash;
190
196
  }
191
- return;
197
+ return void 0;
192
198
  }
199
+ // -------------------------------------------------------------------------
200
+ // Snapshot operations
201
+ // -------------------------------------------------------------------------
193
202
  saveSnapshot(lastOpHash, data) {
194
203
  this._stmts.saveSnapshot.run({
195
204
  $lastOpHash: lastOpHash,
@@ -198,13 +207,15 @@ class SqliteKernelBackend {
198
207
  }
199
208
  loadLatestSnapshot() {
200
209
  const row = this._stmts.loadSnapshot.get();
201
- if (!row)
202
- return;
210
+ if (!row) return void 0;
203
211
  return {
204
212
  lastOpHash: row.last_op_hash,
205
213
  data: JSON.parse(row.data)
206
214
  };
207
215
  }
216
+ // -------------------------------------------------------------------------
217
+ // Blob operations
218
+ // -------------------------------------------------------------------------
208
219
  putBlob(hash, content) {
209
220
  this._stmts.putBlob.run({
210
221
  $hash: hash,
@@ -213,17 +224,19 @@ class SqliteKernelBackend {
213
224
  }
214
225
  getBlob(hash) {
215
226
  const row = this._stmts.getBlob.get({ $hash: hash });
216
- if (!row)
217
- return;
227
+ if (!row) return void 0;
218
228
  return new Uint8Array(row.content);
219
229
  }
220
230
  hasBlob(hash) {
221
231
  return !!this._stmts.hasBlob.get({ $hash: hash });
222
232
  }
233
+ // -------------------------------------------------------------------------
234
+ // Lifecycle
235
+ // -------------------------------------------------------------------------
223
236
  close() {
224
237
  this.db.close();
225
238
  }
226
- }
239
+ };
227
240
  function rowToOp(row) {
228
241
  const payload = JSON.parse(row.payload);
229
242
  const op = {
@@ -232,21 +245,16 @@ function rowToOp(row) {
232
245
  timestamp: row.timestamp,
233
246
  agentId: row.agent_id
234
247
  };
235
- if (row.previous_hash)
236
- op.previousHash = row.previous_hash;
237
- if (payload.facts)
238
- op.facts = payload.facts;
239
- if (payload.links)
240
- op.links = payload.links;
241
- if (payload.deleteFacts)
242
- op.deleteFacts = payload.deleteFacts;
243
- if (payload.deleteLinks)
244
- op.deleteLinks = payload.deleteLinks;
245
- if (payload.vcs)
246
- op.vcs = payload.vcs;
247
- if (payload.signature)
248
- op.signature = payload.signature;
248
+ if (row.previous_hash) op.previousHash = row.previous_hash;
249
+ if (payload.facts) op.facts = payload.facts;
250
+ if (payload.links) op.links = payload.links;
251
+ if (payload.deleteFacts) op.deleteFacts = payload.deleteFacts;
252
+ if (payload.deleteLinks) op.deleteLinks = payload.deleteLinks;
253
+ if (payload.vcs) op.vcs = payload.vcs;
254
+ if (payload.signature) op.signature = payload.signature;
249
255
  return op;
250
256
  }
251
257
 
252
- export { SqliteKernelBackend };
258
+ export {
259
+ SqliteKernelBackend
260
+ };