trellis 2.1.7 → 3.0.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 (346) hide show
  1. package/README.md +65 -706
  2. package/dist/cli/index.d.ts +16 -0
  3. package/dist/cli/index.d.ts.map +1 -0
  4. package/dist/cli/index.js +3188 -232
  5. package/dist/client/config.d.ts +56 -0
  6. package/dist/client/config.d.ts.map +1 -0
  7. package/dist/client/index.d.ts +15 -0
  8. package/dist/client/index.d.ts.map +1 -0
  9. package/dist/client/index.js +32 -0
  10. package/dist/client/sdk.d.ts +152 -0
  11. package/dist/client/sdk.d.ts.map +1 -0
  12. package/dist/config-8hczw0rs.js +20 -0
  13. package/dist/context/heat-map-manager.d.ts +100 -0
  14. package/dist/context/heat-map-manager.d.ts.map +1 -0
  15. package/dist/context/manager.d.ts +16 -0
  16. package/dist/context/manager.d.ts.map +1 -0
  17. package/dist/context/types.d.ts +20 -0
  18. package/dist/context/types.d.ts.map +1 -0
  19. package/dist/core/agents/harness.d.ts +58 -0
  20. package/dist/core/agents/harness.d.ts.map +1 -0
  21. package/dist/core/agents/index.d.ts +8 -0
  22. package/dist/core/agents/index.d.ts.map +1 -0
  23. package/dist/core/agents/types.d.ts +79 -0
  24. package/dist/core/agents/types.d.ts.map +1 -0
  25. package/dist/core/computation/expr-evaluator.d.ts +52 -0
  26. package/dist/core/computation/expr-evaluator.d.ts.map +1 -0
  27. package/dist/core/index.d.ts +25 -0
  28. package/dist/core/index.d.ts.map +1 -0
  29. package/dist/core/index.js +105 -11
  30. package/dist/core/kernel/logic-middleware.d.ts +19 -0
  31. package/dist/core/kernel/logic-middleware.d.ts.map +1 -0
  32. package/dist/core/kernel/middleware.d.ts +28 -0
  33. package/dist/core/kernel/middleware.d.ts.map +1 -0
  34. package/dist/core/kernel/schema-middleware.d.ts +15 -0
  35. package/dist/core/kernel/schema-middleware.d.ts.map +1 -0
  36. package/dist/core/kernel/security-middleware.d.ts +24 -0
  37. package/dist/core/kernel/security-middleware.d.ts.map +1 -0
  38. package/dist/core/kernel/sync-provider.d.ts +59 -0
  39. package/dist/core/kernel/sync-provider.d.ts.map +1 -0
  40. package/dist/core/kernel/trellis-kernel.d.ts +217 -0
  41. package/dist/core/kernel/trellis-kernel.d.ts.map +1 -0
  42. package/dist/core/ontology/builtins.d.ts +16 -0
  43. package/dist/core/ontology/builtins.d.ts.map +1 -0
  44. package/dist/core/ontology/core-ontology.d.ts +20 -0
  45. package/dist/core/ontology/core-ontology.d.ts.map +1 -0
  46. package/dist/core/ontology/index.d.ts +12 -0
  47. package/dist/core/ontology/index.d.ts.map +1 -0
  48. package/dist/core/ontology/registry.d.ts +70 -0
  49. package/dist/core/ontology/registry.d.ts.map +1 -0
  50. package/dist/core/ontology/types.d.ts +201 -0
  51. package/dist/core/ontology/types.d.ts.map +1 -0
  52. package/dist/core/ontology/validator.d.ts +34 -0
  53. package/dist/core/ontology/validator.d.ts.map +1 -0
  54. package/dist/core/persist/backend.d.ts +62 -0
  55. package/dist/core/persist/backend.d.ts.map +1 -0
  56. package/dist/core/persist/better-sqlite-backend.d.ts +33 -0
  57. package/dist/core/persist/better-sqlite-backend.d.ts.map +1 -0
  58. package/dist/core/persist/sqlite-backend.d.ts +43 -0
  59. package/dist/core/persist/sqlite-backend.d.ts.map +1 -0
  60. package/dist/core/plugins/index.d.ts +8 -0
  61. package/dist/core/plugins/index.d.ts.map +1 -0
  62. package/dist/core/plugins/registry.d.ts +69 -0
  63. package/dist/core/plugins/registry.d.ts.map +1 -0
  64. package/dist/core/plugins/types.d.ts +87 -0
  65. package/dist/core/plugins/types.d.ts.map +1 -0
  66. package/dist/core/query/datalog.d.ts +52 -0
  67. package/dist/core/query/datalog.d.ts.map +1 -0
  68. package/dist/core/query/engine.d.ts +42 -0
  69. package/dist/core/query/engine.d.ts.map +1 -0
  70. package/dist/core/query/index.d.ts +12 -0
  71. package/dist/core/query/index.d.ts.map +1 -0
  72. package/dist/core/query/parser.d.ts +37 -0
  73. package/dist/core/query/parser.d.ts.map +1 -0
  74. package/dist/core/query/types.d.ts +135 -0
  75. package/dist/core/query/types.d.ts.map +1 -0
  76. package/dist/core/store/eav-store.d.ts +111 -0
  77. package/dist/core/store/eav-store.d.ts.map +1 -0
  78. package/dist/db/index.d.ts +18 -0
  79. package/dist/db/index.d.ts.map +1 -0
  80. package/dist/db/index.js +85 -0
  81. package/dist/db/inspector.js +28 -0
  82. package/dist/db/trellis.css +1 -0
  83. package/dist/decisions/auto-capture.d.ts +31 -0
  84. package/dist/decisions/auto-capture.d.ts.map +1 -0
  85. package/dist/decisions/hooks.d.ts +48 -0
  86. package/dist/decisions/hooks.d.ts.map +1 -0
  87. package/dist/decisions/index.d.ts +36 -0
  88. package/dist/decisions/index.d.ts.map +1 -0
  89. package/dist/decisions/types.d.ts +73 -0
  90. package/dist/decisions/types.d.ts.map +1 -0
  91. package/dist/deploy-999q207z.js +10 -0
  92. package/dist/embeddings/auto-embed.d.ts +52 -0
  93. package/dist/embeddings/auto-embed.d.ts.map +1 -0
  94. package/dist/embeddings/chunker.d.ts +73 -0
  95. package/dist/embeddings/chunker.d.ts.map +1 -0
  96. package/dist/embeddings/index.d.ts +18 -0
  97. package/dist/embeddings/index.d.ts.map +1 -0
  98. package/dist/embeddings/model.d.ts +30 -0
  99. package/dist/embeddings/model.d.ts.map +1 -0
  100. package/dist/embeddings/search.d.ts +87 -0
  101. package/dist/embeddings/search.d.ts.map +1 -0
  102. package/dist/embeddings/store.d.ts +66 -0
  103. package/dist/embeddings/store.d.ts.map +1 -0
  104. package/dist/embeddings/types.d.ts +54 -0
  105. package/dist/embeddings/types.d.ts.map +1 -0
  106. package/dist/engine-y0724kjq.js +8 -0
  107. package/dist/engine.d.ts +218 -0
  108. package/dist/engine.d.ts.map +1 -0
  109. package/dist/evals/types.d.ts +29 -0
  110. package/dist/evals/types.d.ts.map +1 -0
  111. package/dist/garden/cluster.d.ts +57 -0
  112. package/dist/garden/cluster.d.ts.map +1 -0
  113. package/dist/garden/garden.d.ts +104 -0
  114. package/dist/garden/garden.d.ts.map +1 -0
  115. package/dist/garden/index.d.ts +15 -0
  116. package/dist/garden/index.d.ts.map +1 -0
  117. package/dist/git/git-exporter.d.ts +37 -0
  118. package/dist/git/git-exporter.d.ts.map +1 -0
  119. package/dist/git/git-importer.d.ts +36 -0
  120. package/dist/git/git-importer.d.ts.map +1 -0
  121. package/dist/git/git-reader.d.ts +63 -0
  122. package/dist/git/git-reader.d.ts.map +1 -0
  123. package/dist/git/index.d.ts +10 -0
  124. package/dist/git/index.d.ts.map +1 -0
  125. package/dist/identity/governance.d.ts +54 -0
  126. package/dist/identity/governance.d.ts.map +1 -0
  127. package/dist/identity/identity.d.ts +63 -0
  128. package/dist/identity/identity.d.ts.map +1 -0
  129. package/dist/identity/index.d.ts +10 -0
  130. package/dist/identity/index.d.ts.map +1 -0
  131. package/dist/identity/signing-middleware.d.ts +38 -0
  132. package/dist/identity/signing-middleware.d.ts.map +1 -0
  133. package/dist/import-s2b8e0ft.js +11 -0
  134. package/dist/{index-3ejh8k6v.js → index-0q7wbasy.js} +18 -4
  135. package/dist/index-0zk3fx2s.js +1004 -0
  136. package/dist/index-2r4jxwnb.js +32 -0
  137. package/dist/index-6n5dcebj.js +847 -0
  138. package/dist/index-7e27kvvj.js +292 -0
  139. package/dist/index-bmyt7k8n.js +90 -0
  140. package/dist/index-c9h37r6h.js +1 -0
  141. package/dist/{index-k5kf7sd0.js → index-hmdbnd4n.js} +1 -1
  142. package/dist/index-k5b0xskw.js +1 -0
  143. package/dist/index-n9f2qyh5.js +495 -0
  144. package/dist/{index-22jx9qsz.js → index-q31hfjja.js} +861 -51
  145. package/dist/index-skhn0agf.js +155 -0
  146. package/dist/{index-5m0g9r0y.js → index-w7ng765c.js} +4 -497
  147. package/dist/index-wt8rz4gn.js +132 -0
  148. package/dist/index-xzym9w0m.js +43 -0
  149. package/dist/index-y3d71wzd.js +77 -0
  150. package/dist/index-y6a4kj0p.js +43 -0
  151. package/dist/index-yhwjgfvj.js +342 -0
  152. package/dist/index-yp88he8n.js +316 -0
  153. package/dist/index.d.ts +25 -0
  154. package/dist/index.d.ts.map +1 -0
  155. package/dist/index.js +21 -9
  156. package/dist/links/index.d.ts +16 -0
  157. package/dist/links/index.d.ts.map +1 -0
  158. package/dist/links/lifecycle.d.ts +112 -0
  159. package/dist/links/lifecycle.d.ts.map +1 -0
  160. package/dist/links/parser.d.ts +56 -0
  161. package/dist/links/parser.d.ts.map +1 -0
  162. package/dist/links/ref-index.d.ts +55 -0
  163. package/dist/links/ref-index.d.ts.map +1 -0
  164. package/dist/links/resolver.d.ts +90 -0
  165. package/dist/links/resolver.d.ts.map +1 -0
  166. package/dist/links/types.d.ts +70 -0
  167. package/dist/links/types.d.ts.map +1 -0
  168. package/dist/llm/provider.d.ts +11 -0
  169. package/dist/llm/provider.d.ts.map +1 -0
  170. package/dist/llm/types.d.ts +74 -0
  171. package/dist/llm/types.d.ts.map +1 -0
  172. package/dist/mcp/docs.d.ts +18 -0
  173. package/dist/mcp/docs.d.ts.map +1 -0
  174. package/dist/mcp/index.d.ts +15 -0
  175. package/dist/mcp/index.d.ts.map +1 -0
  176. package/dist/mcp/server.d.ts +26 -0
  177. package/dist/mcp/server.d.ts.map +1 -0
  178. package/dist/orchestration/types.d.ts +22 -0
  179. package/dist/orchestration/types.d.ts.map +1 -0
  180. package/dist/plugins/agent-memory/graph-context-manager.d.ts +75 -0
  181. package/dist/plugins/agent-memory/graph-context-manager.d.ts.map +1 -0
  182. package/dist/plugins/agent-memory/index.d.ts +30 -0
  183. package/dist/plugins/agent-memory/index.d.ts.map +1 -0
  184. package/dist/plugins/agent-memory/ontology.d.ts +13 -0
  185. package/dist/plugins/agent-memory/ontology.d.ts.map +1 -0
  186. package/dist/plugins/agent-memory/plugin.d.ts +17 -0
  187. package/dist/plugins/agent-memory/plugin.d.ts.map +1 -0
  188. package/dist/plugins/brand/cache.d.ts +18 -0
  189. package/dist/plugins/brand/cache.d.ts.map +1 -0
  190. package/dist/plugins/brand/catalog-generator.d.ts +89 -0
  191. package/dist/plugins/brand/catalog-generator.d.ts.map +1 -0
  192. package/dist/plugins/brand/constraints.d.ts +55 -0
  193. package/dist/plugins/brand/constraints.d.ts.map +1 -0
  194. package/dist/plugins/brand/index.d.ts +44 -0
  195. package/dist/plugins/brand/index.d.ts.map +1 -0
  196. package/dist/plugins/brand/mcp-tools.d.ts +101 -0
  197. package/dist/plugins/brand/mcp-tools.d.ts.map +1 -0
  198. package/dist/plugins/brand/ontology.d.ts +13 -0
  199. package/dist/plugins/brand/ontology.d.ts.map +1 -0
  200. package/dist/plugins/brand/plugin.d.ts +21 -0
  201. package/dist/plugins/brand/plugin.d.ts.map +1 -0
  202. package/dist/plugins/brand/voice-tone.d.ts +24 -0
  203. package/dist/plugins/brand/voice-tone.d.ts.map +1 -0
  204. package/dist/plugins/idea-garden/api.d.ts +26 -0
  205. package/dist/plugins/idea-garden/api.d.ts.map +1 -0
  206. package/dist/plugins/idea-garden/index.d.ts +12 -0
  207. package/dist/plugins/idea-garden/index.d.ts.map +1 -0
  208. package/dist/plugins/idea-garden/plugin.d.ts +16 -0
  209. package/dist/plugins/idea-garden/plugin.d.ts.map +1 -0
  210. package/dist/plugins/idea-garden/types.d.ts +22 -0
  211. package/dist/plugins/idea-garden/types.d.ts.map +1 -0
  212. package/dist/plugins/plan-approval/index.d.ts +36 -0
  213. package/dist/plugins/plan-approval/index.d.ts.map +1 -0
  214. package/dist/plugins/plan-approval/ontology.d.ts +11 -0
  215. package/dist/plugins/plan-approval/ontology.d.ts.map +1 -0
  216. package/dist/plugins/plan-approval/plan-manager.d.ts +104 -0
  217. package/dist/plugins/plan-approval/plan-manager.d.ts.map +1 -0
  218. package/dist/plugins/plan-approval/plugin.d.ts +110 -0
  219. package/dist/plugins/plan-approval/plugin.d.ts.map +1 -0
  220. package/dist/plugins/proactive-watcher/index.d.ts +28 -0
  221. package/dist/plugins/proactive-watcher/index.d.ts.map +1 -0
  222. package/dist/plugins/proactive-watcher/ontology.d.ts +8 -0
  223. package/dist/plugins/proactive-watcher/ontology.d.ts.map +1 -0
  224. package/dist/plugins/proactive-watcher/plugin.d.ts +20 -0
  225. package/dist/plugins/proactive-watcher/plugin.d.ts.map +1 -0
  226. package/dist/plugins/proactive-watcher/watcher-manager.d.ts +36 -0
  227. package/dist/plugins/proactive-watcher/watcher-manager.d.ts.map +1 -0
  228. package/dist/plugins/sprite-tools/checkpoint-middleware.d.ts +43 -0
  229. package/dist/plugins/sprite-tools/checkpoint-middleware.d.ts.map +1 -0
  230. package/dist/plugins/sprite-tools/index.d.ts +40 -0
  231. package/dist/plugins/sprite-tools/index.d.ts.map +1 -0
  232. package/dist/plugins/sprite-tools/plugin.d.ts +69 -0
  233. package/dist/plugins/sprite-tools/plugin.d.ts.map +1 -0
  234. package/dist/react/index.js +189 -0
  235. package/dist/scaffold/index.d.ts +13 -0
  236. package/dist/scaffold/index.d.ts.map +1 -0
  237. package/dist/scaffold/infer.d.ts +42 -0
  238. package/dist/scaffold/infer.d.ts.map +1 -0
  239. package/dist/scaffold/profile.d.ts +51 -0
  240. package/dist/scaffold/profile.d.ts.map +1 -0
  241. package/dist/scaffold/seed.d.ts +27 -0
  242. package/dist/scaffold/seed.d.ts.map +1 -0
  243. package/dist/scaffold/write.d.ts +53 -0
  244. package/dist/scaffold/write.d.ts.map +1 -0
  245. package/dist/sdk-snn5gad3.js +15 -0
  246. package/dist/semantic/csharp-parser.d.ts +12 -0
  247. package/dist/semantic/csharp-parser.d.ts.map +1 -0
  248. package/dist/semantic/go-parser.d.ts +12 -0
  249. package/dist/semantic/go-parser.d.ts.map +1 -0
  250. package/dist/semantic/index.d.ts +22 -0
  251. package/dist/semantic/index.d.ts.map +1 -0
  252. package/dist/semantic/java-parser.d.ts +12 -0
  253. package/dist/semantic/java-parser.d.ts.map +1 -0
  254. package/dist/semantic/python-parser.d.ts +12 -0
  255. package/dist/semantic/python-parser.d.ts.map +1 -0
  256. package/dist/semantic/ruby-parser.d.ts +12 -0
  257. package/dist/semantic/ruby-parser.d.ts.map +1 -0
  258. package/dist/semantic/rust-parser.d.ts +12 -0
  259. package/dist/semantic/rust-parser.d.ts.map +1 -0
  260. package/dist/semantic/semantic-merge.d.ts +20 -0
  261. package/dist/semantic/semantic-merge.d.ts.map +1 -0
  262. package/dist/semantic/ts-parser.d.ts +13 -0
  263. package/dist/semantic/ts-parser.d.ts.map +1 -0
  264. package/dist/semantic/types.d.ts +130 -0
  265. package/dist/semantic/types.d.ts.map +1 -0
  266. package/dist/server/auth.d.ts +72 -0
  267. package/dist/server/auth.d.ts.map +1 -0
  268. package/dist/server/deploy.d.ts +44 -0
  269. package/dist/server/deploy.d.ts.map +1 -0
  270. package/dist/server/import.d.ts +40 -0
  271. package/dist/server/import.d.ts.map +1 -0
  272. package/dist/server/index.d.ts +26 -0
  273. package/dist/server/index.d.ts.map +1 -0
  274. package/dist/server/index.js +90 -0
  275. package/dist/server/permissions.d.ts +84 -0
  276. package/dist/server/permissions.d.ts.map +1 -0
  277. package/dist/server/realtime.d.ts +78 -0
  278. package/dist/server/realtime.d.ts.map +1 -0
  279. package/dist/server/server.d.ts +43 -0
  280. package/dist/server/server.d.ts.map +1 -0
  281. package/dist/server/sprites.d.ts +26 -0
  282. package/dist/server/sprites.d.ts.map +1 -0
  283. package/dist/server/tenancy.d.ts +53 -0
  284. package/dist/server/tenancy.d.ts.map +1 -0
  285. package/dist/server/vm-config.d.ts +60 -0
  286. package/dist/server/vm-config.d.ts.map +1 -0
  287. package/dist/server-mrctdwzr.js +11 -0
  288. package/dist/sprites-vc4qbrp1.js +16 -0
  289. package/dist/streaming/types.d.ts +43 -0
  290. package/dist/streaming/types.d.ts.map +1 -0
  291. package/dist/sync/http-transport.d.ts +47 -0
  292. package/dist/sync/http-transport.d.ts.map +1 -0
  293. package/dist/sync/index.d.ts +22 -0
  294. package/dist/sync/index.d.ts.map +1 -0
  295. package/dist/sync/memory-transport.d.ts +27 -0
  296. package/dist/sync/memory-transport.d.ts.map +1 -0
  297. package/dist/sync/multi-repo.d.ts +82 -0
  298. package/dist/sync/multi-repo.d.ts.map +1 -0
  299. package/dist/sync/reconciler.d.ts +48 -0
  300. package/dist/sync/reconciler.d.ts.map +1 -0
  301. package/dist/sync/sync-engine.d.ts +65 -0
  302. package/dist/sync/sync-engine.d.ts.map +1 -0
  303. package/dist/sync/types.d.ts +71 -0
  304. package/dist/sync/types.d.ts.map +1 -0
  305. package/dist/sync/ws-transport.d.ts +41 -0
  306. package/dist/sync/ws-transport.d.ts.map +1 -0
  307. package/dist/tenancy-7d1g4ayp.js +13 -0
  308. package/dist/ui/client.html +460 -664
  309. package/dist/ui/server.d.ts +42 -0
  310. package/dist/ui/server.d.ts.map +1 -0
  311. package/dist/vcs/blob-store.d.ts +49 -0
  312. package/dist/vcs/blob-store.d.ts.map +1 -0
  313. package/dist/vcs/branch.d.ts +35 -0
  314. package/dist/vcs/branch.d.ts.map +1 -0
  315. package/dist/vcs/checkpoint.d.ts +24 -0
  316. package/dist/vcs/checkpoint.d.ts.map +1 -0
  317. package/dist/vcs/decompose.d.ts +19 -0
  318. package/dist/vcs/decompose.d.ts.map +1 -0
  319. package/dist/vcs/diff.d.ts +65 -0
  320. package/dist/vcs/diff.d.ts.map +1 -0
  321. package/dist/vcs/engine-context.d.ts +21 -0
  322. package/dist/vcs/engine-context.d.ts.map +1 -0
  323. package/dist/vcs/index.d.ts +23 -0
  324. package/dist/vcs/index.d.ts.map +1 -0
  325. package/dist/vcs/index.js +2 -2
  326. package/dist/vcs/issue.d.ts +159 -0
  327. package/dist/vcs/issue.d.ts.map +1 -0
  328. package/dist/vcs/merge.d.ts +55 -0
  329. package/dist/vcs/merge.d.ts.map +1 -0
  330. package/dist/vcs/milestone.d.ts +30 -0
  331. package/dist/vcs/milestone.d.ts.map +1 -0
  332. package/dist/vcs/ops.d.ts +27 -0
  333. package/dist/vcs/ops.d.ts.map +1 -0
  334. package/dist/vcs/types.d.ts +95 -0
  335. package/dist/vcs/types.d.ts.map +1 -0
  336. package/dist/vcs/vcs-middleware.d.ts +14 -0
  337. package/dist/vcs/vcs-middleware.d.ts.map +1 -0
  338. package/dist/vm-config-6xhsj6b3.js +22 -0
  339. package/dist/watcher/fs-watcher.d.ts +51 -0
  340. package/dist/watcher/fs-watcher.d.ts.map +1 -0
  341. package/dist/watcher/index.d.ts +9 -0
  342. package/dist/watcher/index.d.ts.map +1 -0
  343. package/dist/watcher/ingestion.d.ts +28 -0
  344. package/dist/watcher/ingestion.d.ts.map +1 -0
  345. package/package.json +57 -7
  346. package/dist/index-hybgxe40.js +0 -1174
@@ -0,0 +1,155 @@
1
+ // @bun
2
+ import {
3
+ init_eav_store,
4
+ jsonEntityFacts
5
+ } from "./index-yhwjgfvj.js";
6
+ import {
7
+ __require
8
+ } from "./index-a76rekgs.js";
9
+
10
+ // src/server/import.ts
11
+ init_eav_store();
12
+ import { readFileSync } from "fs";
13
+ import { extname } from "path";
14
+ async function importFile(kernel, filePath, opts) {
15
+ const ext = extname(filePath).toLowerCase();
16
+ switch (ext) {
17
+ case ".json":
18
+ return importJson(kernel, filePath, opts);
19
+ case ".ndjson":
20
+ case ".jsonl":
21
+ return importNdjson(kernel, filePath, opts);
22
+ case ".csv":
23
+ case ".tsv":
24
+ return importCsv(kernel, filePath, opts);
25
+ case ".parquet":
26
+ return importParquet(kernel, filePath, opts);
27
+ default:
28
+ throw new Error(`Unsupported file format: ${ext}. Supported: .json, .ndjson, .jsonl, .csv, .tsv, .parquet`);
29
+ }
30
+ }
31
+ async function importRecords(kernel, records, opts) {
32
+ return _ingestRows(kernel, records, opts);
33
+ }
34
+ async function importJson(kernel, filePath, opts) {
35
+ const raw = readFileSync(filePath, "utf8");
36
+ const parsed = JSON.parse(raw);
37
+ const rows = Array.isArray(parsed) ? parsed : [parsed];
38
+ return _ingestRows(kernel, rows, opts);
39
+ }
40
+ async function importNdjson(kernel, filePath, opts) {
41
+ const raw = readFileSync(filePath, "utf8");
42
+ const rows = raw.split(`
43
+ `).map((l) => l.trim()).filter(Boolean).map((line, i) => {
44
+ try {
45
+ return JSON.parse(line);
46
+ } catch {
47
+ return null;
48
+ }
49
+ }).filter(Boolean);
50
+ return _ingestRows(kernel, rows, opts);
51
+ }
52
+ async function importCsv(kernel, filePath, opts) {
53
+ const raw = readFileSync(filePath, "utf8");
54
+ const sep = filePath.endsWith(".tsv") ? "\t" : ",";
55
+ const rows = parseCsv(raw, sep);
56
+ return _ingestRows(kernel, rows, opts);
57
+ }
58
+ function parseCsv(raw, sep = ",") {
59
+ const lines = raw.split(/\r?\n/);
60
+ if (lines.length < 2)
61
+ return [];
62
+ const headers = splitCsvLine(lines[0], sep);
63
+ const result = [];
64
+ for (let i = 1;i < lines.length; i++) {
65
+ const line = lines[i];
66
+ if (!line || line.trim() === "")
67
+ continue;
68
+ const values = splitCsvLine(line, sep);
69
+ const row = {};
70
+ headers.forEach((h, idx) => {
71
+ row[h] = values[idx] ?? "";
72
+ });
73
+ result.push(row);
74
+ }
75
+ return result;
76
+ }
77
+ function splitCsvLine(line, sep) {
78
+ const result = [];
79
+ let current = "";
80
+ let inQuotes = false;
81
+ for (let i = 0;i < line.length; i++) {
82
+ const ch = line[i];
83
+ if (ch === '"') {
84
+ if (inQuotes && line[i + 1] === '"') {
85
+ current += '"';
86
+ i++;
87
+ } else {
88
+ inQuotes = !inQuotes;
89
+ }
90
+ } else if (ch === sep && !inQuotes) {
91
+ result.push(current);
92
+ current = "";
93
+ } else {
94
+ current += ch;
95
+ }
96
+ }
97
+ result.push(current);
98
+ return result;
99
+ }
100
+ async function importParquet(kernel, filePath, opts) {
101
+ let parquet;
102
+ try {
103
+ parquet = await import("parquetjs");
104
+ } catch {
105
+ try {
106
+ parquet = await import("@dsnp/parquetjs");
107
+ } catch {
108
+ throw new Error("Parquet support requires `parquetjs` or `@dsnp/parquetjs`.\nRun: bun add parquetjs");
109
+ }
110
+ }
111
+ const reader = await parquet.ParquetReader.openFile(filePath);
112
+ const cursor = reader.getCursor();
113
+ const rows = [];
114
+ let row;
115
+ while ((row = await cursor.next()) !== null) {
116
+ rows.push(row);
117
+ }
118
+ await reader.close();
119
+ return _ingestRows(kernel, rows, opts);
120
+ }
121
+ async function _ingestRows(kernel, rows, opts) {
122
+ const result = {
123
+ imported: 0,
124
+ skipped: 0,
125
+ errors: [],
126
+ entityIds: []
127
+ };
128
+ const limit = opts.limit ?? Infinity;
129
+ let count = 0;
130
+ for (let i = 0;i < rows.length; i++) {
131
+ if (count >= limit)
132
+ break;
133
+ const row = rows[i];
134
+ if (!row || opts.skipEmpty && Object.keys(row).length === 0) {
135
+ result.skipped++;
136
+ continue;
137
+ }
138
+ try {
139
+ const entityId = opts.idField ? `${opts.idPrefix ?? "import:"}${String(row[opts.idField] ?? "")}` : `${opts.idPrefix ?? "import:"}${crypto.randomUUID()}`;
140
+ const facts = jsonEntityFacts(entityId, row, opts.type);
141
+ await kernel.mutate("addFacts", { facts });
142
+ result.imported++;
143
+ result.entityIds.push(entityId);
144
+ count++;
145
+ } catch (err) {
146
+ result.errors.push({
147
+ row: i,
148
+ message: err instanceof Error ? err.message : String(err)
149
+ });
150
+ }
151
+ }
152
+ return result;
153
+ }
154
+
155
+ export { importFile, importRecords };
@@ -1,499 +1,4 @@
1
1
  // @bun
2
- import {
3
- QueryEngine,
4
- literal,
5
- variable
6
- } from "./index-hybgxe40.js";
7
-
8
- // src/core/query/parser.ts
9
- function tokenize(input) {
10
- const tokens = [];
11
- let i = 0;
12
- while (i < input.length) {
13
- if (/\s/.test(input[i])) {
14
- i++;
15
- continue;
16
- }
17
- if (input[i] === "/" && input[i + 1] === "/") {
18
- while (i < input.length && input[i] !== `
19
- `)
20
- i++;
21
- continue;
22
- }
23
- const pos = i;
24
- if ("[](){},:".includes(input[i])) {
25
- tokens.push({ kind: "symbol", value: input[i], pos });
26
- i++;
27
- continue;
28
- }
29
- if (input[i] === "!" && input[i + 1] === "=") {
30
- tokens.push({ kind: "symbol", value: "!=", pos });
31
- i += 2;
32
- continue;
33
- }
34
- if (input[i] === "<" && input[i + 1] === "=") {
35
- tokens.push({ kind: "symbol", value: "<=", pos });
36
- i += 2;
37
- continue;
38
- }
39
- if (input[i] === ">" && input[i + 1] === "=") {
40
- tokens.push({ kind: "symbol", value: ">=", pos });
41
- i += 2;
42
- continue;
43
- }
44
- if ("<>=".includes(input[i])) {
45
- tokens.push({ kind: "symbol", value: input[i], pos });
46
- i++;
47
- continue;
48
- }
49
- if (input[i] === '"') {
50
- i++;
51
- let s = "";
52
- while (i < input.length && input[i] !== '"') {
53
- if (input[i] === "\\" && i + 1 < input.length) {
54
- s += input[i + 1];
55
- i += 2;
56
- } else {
57
- s += input[i];
58
- i++;
59
- }
60
- }
61
- if (i < input.length)
62
- i++;
63
- tokens.push({ kind: "string", value: s, pos });
64
- continue;
65
- }
66
- if (/[0-9]/.test(input[i]) || input[i] === "-" && i + 1 < input.length && /[0-9]/.test(input[i + 1])) {
67
- let n = input[i];
68
- i++;
69
- while (i < input.length && /[0-9.]/.test(input[i])) {
70
- n += input[i];
71
- i++;
72
- }
73
- tokens.push({ kind: "number", value: n, pos });
74
- continue;
75
- }
76
- if (/[?a-zA-Z_]/.test(input[i])) {
77
- let w = "";
78
- while (i < input.length && /[?a-zA-Z0-9_.:/-]/.test(input[i])) {
79
- w += input[i];
80
- i++;
81
- }
82
- tokens.push({ kind: "word", value: w, pos });
83
- continue;
84
- }
85
- i++;
86
- }
87
- tokens.push({ kind: "eof", value: "", pos: input.length });
88
- return tokens;
89
- }
90
-
91
- class Parser {
92
- tokens;
93
- pos = 0;
94
- constructor(tokens) {
95
- this.tokens = tokens;
96
- }
97
- peek() {
98
- return this.tokens[this.pos];
99
- }
100
- advance() {
101
- return this.tokens[this.pos++];
102
- }
103
- expect(kind, value) {
104
- const t = this.advance();
105
- if (t.kind !== kind || value !== undefined && t.value !== value) {
106
- throw new Error(`Expected ${kind}${value ? ` "${value}"` : ""} at pos ${t.pos}, got ${t.kind} "${t.value}"`);
107
- }
108
- return t;
109
- }
110
- match(kind, value) {
111
- const t = this.peek();
112
- if (t.kind === kind && (value === undefined || t.value === value)) {
113
- this.pos++;
114
- return true;
115
- }
116
- return false;
117
- }
118
- isAt(kind, value) {
119
- const t = this.peek();
120
- return t.kind === kind && (value === undefined || t.value === value);
121
- }
122
- parseTerm() {
123
- const t = this.peek();
124
- if (t.kind === "word" && t.value.startsWith("?")) {
125
- this.advance();
126
- return variable(t.value.slice(1));
127
- }
128
- if (t.kind === "string") {
129
- this.advance();
130
- return literal(t.value);
131
- }
132
- if (t.kind === "number") {
133
- this.advance();
134
- const n = Number(t.value);
135
- return literal(n);
136
- }
137
- if (t.kind === "word") {
138
- const v = t.value;
139
- this.advance();
140
- if (v === "true")
141
- return literal(true);
142
- if (v === "false")
143
- return literal(false);
144
- return literal(v);
145
- }
146
- throw new Error(`Unexpected token at pos ${t.pos}: ${t.kind} "${t.value}"`);
147
- }
148
- parsePattern() {
149
- const t = this.peek();
150
- if (t.kind === "word" && t.value.toUpperCase() === "NOT") {
151
- this.advance();
152
- const inner = this.parsePattern();
153
- return { kind: "not", pattern: inner };
154
- }
155
- if (t.kind === "word" && t.value.toUpperCase() === "OR") {
156
- this.advance();
157
- const branches = [];
158
- while (this.isAt("symbol", "{")) {
159
- this.advance();
160
- const branch = [];
161
- while (!this.isAt("symbol", "}") && !this.isAt("eof", undefined)) {
162
- branch.push(this.parsePattern());
163
- }
164
- this.expect("symbol", "}");
165
- branches.push(branch);
166
- }
167
- return { kind: "or", branches };
168
- }
169
- if (t.kind === "symbol" && t.value === "[") {
170
- this.advance();
171
- const entity = this.parseTerm();
172
- const attribute = this.parseTerm();
173
- const value = this.parseTerm();
174
- this.expect("symbol", "]");
175
- return { kind: "fact", entity, attribute, value };
176
- }
177
- if (t.kind === "symbol" && t.value === "(") {
178
- this.advance();
179
- const source = this.parseTerm();
180
- const attribute = this.parseTerm();
181
- const target = this.parseTerm();
182
- this.expect("symbol", ")");
183
- return { kind: "link", source, attribute, target };
184
- }
185
- if (t.kind === "word" && !t.value.startsWith("?")) {
186
- const name = this.advance().value;
187
- if (this.isAt("symbol", "(")) {
188
- this.advance();
189
- const args = [];
190
- while (!this.isAt("symbol", ")") && !this.isAt("eof", undefined)) {
191
- args.push(this.parseTerm());
192
- this.match("symbol", ",");
193
- }
194
- this.expect("symbol", ")");
195
- return { kind: "rule", name, args };
196
- }
197
- throw new Error(`Expected '(' after rule name "${name}" at pos ${t.pos}`);
198
- }
199
- throw new Error(`Cannot parse pattern at pos ${t.pos}: ${t.kind} "${t.value}"`);
200
- }
201
- parseFilter() {
202
- const left = this.parseTerm();
203
- const op = this.advance().value;
204
- const right = this.parseTerm();
205
- return { kind: "filter", left, op, right };
206
- }
207
- parseQuery() {
208
- const query = {
209
- select: [],
210
- where: [],
211
- filters: [],
212
- aggregates: [],
213
- orderBy: [],
214
- limit: 0,
215
- offset: 0
216
- };
217
- while (!this.isAt("eof", undefined)) {
218
- const kw = this.peek();
219
- if (kw.kind !== "word") {
220
- throw new Error(`Expected keyword at pos ${kw.pos}, got ${kw.kind} "${kw.value}"`);
221
- }
222
- switch (kw.value.toUpperCase()) {
223
- case "SELECT": {
224
- this.advance();
225
- while (this.peek().kind === "word" && this.peek().value.startsWith("?")) {
226
- query.select.push(this.advance().value.slice(1));
227
- }
228
- break;
229
- }
230
- case "WHERE": {
231
- this.advance();
232
- this.expect("symbol", "{");
233
- while (!this.isAt("symbol", "}") && !this.isAt("eof", undefined)) {
234
- query.where.push(this.parsePattern());
235
- }
236
- this.expect("symbol", "}");
237
- break;
238
- }
239
- case "FILTER": {
240
- this.advance();
241
- query.filters.push(this.parseFilter());
242
- break;
243
- }
244
- case "AGGREGATE": {
245
- this.advance();
246
- const op = this.advance().value;
247
- this.expect("symbol", "(");
248
- const varName = this.advance().value;
249
- const varClean = varName.startsWith("?") ? varName.slice(1) : varName;
250
- this.expect("symbol", ")");
251
- this.expect("word", "AS");
252
- const asName = this.advance().value;
253
- const asClean = asName.startsWith("?") ? asName.slice(1) : asName;
254
- query.aggregates.push({ op, variable: varClean, as: asClean });
255
- break;
256
- }
257
- case "ORDER": {
258
- this.advance();
259
- this.expect("word", "BY");
260
- while (this.peek().kind === "word" && this.peek().value.startsWith("?")) {
261
- const v = this.advance().value.slice(1);
262
- let dir = "asc";
263
- if (this.peek().kind === "word" && ["ASC", "DESC"].includes(this.peek().value.toUpperCase())) {
264
- dir = this.advance().value.toLowerCase();
265
- }
266
- query.orderBy.push({ variable: v, direction: dir });
267
- }
268
- break;
269
- }
270
- case "LIMIT": {
271
- this.advance();
272
- query.limit = Number(this.expect("number").value);
273
- break;
274
- }
275
- case "OFFSET": {
276
- this.advance();
277
- query.offset = Number(this.expect("number").value);
278
- break;
279
- }
280
- default:
281
- throw new Error(`Unknown keyword "${kw.value}" at pos ${kw.pos}`);
282
- }
283
- }
284
- return query;
285
- }
286
- parseRule() {
287
- const name = this.expect("word").value;
288
- this.expect("symbol", "(");
289
- const params = [];
290
- while (!this.isAt("symbol", ")") && !this.isAt("eof", undefined)) {
291
- const v = this.expect("word").value;
292
- params.push(v.startsWith("?") ? v.slice(1) : v);
293
- this.match("symbol", ",");
294
- }
295
- this.expect("symbol", ")");
296
- if (this.isAt("symbol", ":")) {
297
- this.advance();
298
- if (this.peek().kind === "number" && this.peek().value.startsWith("-")) {
299
- this.advance();
300
- }
301
- } else if (this.isAt("word", ":-")) {
302
- this.advance();
303
- }
304
- const body = [];
305
- const filters = [];
306
- while (!this.isAt("eof", undefined)) {
307
- if (this.peek().kind === "word" && this.peek().value.toUpperCase() === "FILTER") {
308
- this.advance();
309
- filters.push(this.parseFilter());
310
- } else {
311
- body.push(this.parsePattern());
312
- }
313
- this.match("symbol", ",");
314
- }
315
- return { name, params, body, filters };
316
- }
317
- }
318
- function parseQuery(input) {
319
- const tokens = tokenize(input);
320
- return new Parser(tokens).parseQuery();
321
- }
322
- function parseRule(input) {
323
- const tokens = tokenize(input);
324
- return new Parser(tokens).parseRule();
325
- }
326
- function parseSimple(input) {
327
- const trimmed = input.trim();
328
- const upper = trimmed.toUpperCase();
329
- if (upper.startsWith("SELECT") || upper.startsWith("WHERE")) {
330
- return parseQuery(trimmed);
331
- }
332
- const findMatch = trimmed.match(/^find\s+(.+?)\s+where\s+(.+)$/i);
333
- if (findMatch) {
334
- const vars = findMatch[1].trim().split(/\s+/);
335
- const conditions = findMatch[2].trim();
336
- const selectVars = vars.map((v) => v.startsWith("?") ? v : `?${v}`);
337
- const entity = selectVars[0];
338
- const parts = conditions.split(/\s+and\s+/i);
339
- const patterns = [];
340
- const filters = [];
341
- for (const part of parts) {
342
- const eqMatch = part.match(/^(\S+)\s*(=|!=|<|<=|>|>=|contains|startsWith|endsWith|matches)\s*(.+)$/);
343
- if (eqMatch) {
344
- const [, attr, op, val] = eqMatch;
345
- const valTrimmed = val.trim();
346
- if (op === "=") {
347
- patterns.push(`[${entity} "${attr}" ${valTrimmed}]`);
348
- } else {
349
- const tmpVar = `?_${attr.replace(/[^a-zA-Z0-9]/g, "_")}`;
350
- patterns.push(`[${entity} "${attr}" ${tmpVar}]`);
351
- filters.push(`FILTER ${tmpVar} ${op} ${valTrimmed}`);
352
- }
353
- }
354
- }
355
- const fullQuery = `SELECT ${selectVars.join(" ")}
356
- WHERE {
357
- ${patterns.join(`
358
- `)}
359
- }
360
- ${filters.join(`
361
- `)}`;
362
- return parseQuery(fullQuery);
363
- }
364
- throw new Error(`Cannot parse query: "${trimmed}". Use full EQL-S syntax or "find ?e where attr = value".`);
365
- }
366
-
367
- // src/core/query/datalog.ts
368
- function transitiveClosureRules(ruleName, linkAttribute) {
369
- return [
370
- {
371
- name: ruleName,
372
- params: ["x", "y"],
373
- body: [
374
- {
375
- kind: "link",
376
- source: variable("x"),
377
- attribute: literal(linkAttribute),
378
- target: variable("y")
379
- }
380
- ],
381
- filters: []
382
- },
383
- {
384
- name: ruleName,
385
- params: ["x", "y"],
386
- body: [
387
- {
388
- kind: "link",
389
- source: variable("x"),
390
- attribute: literal(linkAttribute),
391
- target: variable("z")
392
- },
393
- {
394
- kind: "rule",
395
- name: ruleName,
396
- args: [variable("z"), variable("y")]
397
- }
398
- ],
399
- filters: []
400
- }
401
- ];
402
- }
403
- function reverseReachabilityRules(ruleName, linkAttribute) {
404
- return [
405
- {
406
- name: ruleName,
407
- params: ["x", "y"],
408
- body: [
409
- {
410
- kind: "link",
411
- source: variable("y"),
412
- attribute: literal(linkAttribute),
413
- target: variable("x")
414
- }
415
- ],
416
- filters: []
417
- },
418
- {
419
- name: ruleName,
420
- params: ["x", "y"],
421
- body: [
422
- {
423
- kind: "link",
424
- source: variable("z"),
425
- attribute: literal(linkAttribute),
426
- target: variable("x")
427
- },
428
- {
429
- kind: "rule",
430
- name: ruleName,
431
- args: [variable("z"), variable("y")]
432
- }
433
- ],
434
- filters: []
435
- }
436
- ];
437
- }
438
- function siblingRules(ruleName, linkAttribute) {
439
- return [
440
- {
441
- name: ruleName,
442
- params: ["a", "b"],
443
- body: [
444
- {
445
- kind: "link",
446
- source: variable("a"),
447
- attribute: literal(linkAttribute),
448
- target: variable("parent")
449
- },
450
- {
451
- kind: "link",
452
- source: variable("b"),
453
- attribute: literal(linkAttribute),
454
- target: variable("parent")
455
- }
456
- ],
457
- filters: [
458
- {
459
- kind: "filter",
460
- left: variable("a"),
461
- op: "!=",
462
- right: variable("b")
463
- }
464
- ]
465
- }
466
- ];
467
- }
468
-
469
- class DatalogRuntime {
470
- engine;
471
- constructor(store) {
472
- this.engine = new QueryEngine(store);
473
- }
474
- addRule(rule) {
475
- this.engine.addRule(rule);
476
- }
477
- addRules(rules) {
478
- for (const r of rules)
479
- this.engine.addRule(r);
480
- }
481
- removeRule(name) {
482
- this.engine.removeRule(name);
483
- }
484
- registerTransitiveClosure(ruleName, linkAttribute) {
485
- this.addRules(transitiveClosureRules(ruleName, linkAttribute));
486
- }
487
- registerReverseReachability(ruleName, linkAttribute) {
488
- this.addRules(reverseReachabilityRules(ruleName, linkAttribute));
489
- }
490
- registerSiblings(ruleName, linkAttribute) {
491
- this.addRules(siblingRules(ruleName, linkAttribute));
492
- }
493
- getEngine() {
494
- return this.engine;
495
- }
496
- }
497
2
  // src/core/ontology/registry.ts
498
3
  class OntologyRegistry {
499
4
  schemas = new Map;
@@ -786,7 +291,9 @@ var agentOntology = {
786
291
  { name: "status", type: "string", enum: ["running", "completed", "failed", "cancelled"], default: "running" },
787
292
  { name: "input", type: "string" },
788
293
  { name: "output", type: "string" },
789
- { name: "tokenCount", type: "number" }
294
+ { name: "totalTokens", type: "number" },
295
+ { name: "promptTokens", type: "number" },
296
+ { name: "completionTokens", type: "number" }
790
297
  ]
791
298
  },
792
299
  {
@@ -1097,4 +604,4 @@ function createValidationMiddleware(registry, options) {
1097
604
  }
1098
605
  };
1099
606
  }
1100
- export { parseQuery, parseRule, parseSimple, DatalogRuntime, OntologyRegistry, projectOntology, teamOntology, agentOntology, builtinOntologies, validateEntity, validateStore, createValidationMiddleware };
607
+ export { OntologyRegistry, projectOntology, teamOntology, agentOntology, builtinOntologies, validateEntity, validateStore, createValidationMiddleware };