trellis 2.1.7 → 2.1.9

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 (240) hide show
  1. package/README.md +100 -10
  2. package/dist/cli/index.d.ts +14 -0
  3. package/dist/cli/index.d.ts.map +1 -0
  4. package/dist/cli/index.js +199 -9
  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/core/agents/harness.d.ts +49 -0
  14. package/dist/core/agents/harness.d.ts.map +1 -0
  15. package/dist/core/agents/index.d.ts +8 -0
  16. package/dist/core/agents/index.d.ts.map +1 -0
  17. package/dist/core/agents/types.d.ts +63 -0
  18. package/dist/core/agents/types.d.ts.map +1 -0
  19. package/dist/core/index.d.ts +25 -0
  20. package/dist/core/index.d.ts.map +1 -0
  21. package/dist/core/index.js +15 -9
  22. package/dist/core/kernel/middleware.d.ts +28 -0
  23. package/dist/core/kernel/middleware.d.ts.map +1 -0
  24. package/dist/core/kernel/trellis-kernel.d.ts +162 -0
  25. package/dist/core/kernel/trellis-kernel.d.ts.map +1 -0
  26. package/dist/core/ontology/builtins.d.ts +16 -0
  27. package/dist/core/ontology/builtins.d.ts.map +1 -0
  28. package/dist/core/ontology/index.d.ts +10 -0
  29. package/dist/core/ontology/index.d.ts.map +1 -0
  30. package/dist/core/ontology/registry.d.ts +70 -0
  31. package/dist/core/ontology/registry.d.ts.map +1 -0
  32. package/dist/core/ontology/types.d.ts +97 -0
  33. package/dist/core/ontology/types.d.ts.map +1 -0
  34. package/dist/core/ontology/validator.d.ts +34 -0
  35. package/dist/core/ontology/validator.d.ts.map +1 -0
  36. package/dist/core/persist/backend.d.ts +60 -0
  37. package/dist/core/persist/backend.d.ts.map +1 -0
  38. package/dist/core/persist/sqlite-backend.d.ts +41 -0
  39. package/dist/core/persist/sqlite-backend.d.ts.map +1 -0
  40. package/dist/core/plugins/index.d.ts +8 -0
  41. package/dist/core/plugins/index.d.ts.map +1 -0
  42. package/dist/core/plugins/registry.d.ts +69 -0
  43. package/dist/core/plugins/registry.d.ts.map +1 -0
  44. package/dist/core/plugins/types.d.ts +87 -0
  45. package/dist/core/plugins/types.d.ts.map +1 -0
  46. package/dist/core/query/datalog.d.ts +52 -0
  47. package/dist/core/query/datalog.d.ts.map +1 -0
  48. package/dist/core/query/engine.d.ts +42 -0
  49. package/dist/core/query/engine.d.ts.map +1 -0
  50. package/dist/core/query/index.d.ts +12 -0
  51. package/dist/core/query/index.d.ts.map +1 -0
  52. package/dist/core/query/parser.d.ts +37 -0
  53. package/dist/core/query/parser.d.ts.map +1 -0
  54. package/dist/core/query/types.d.ts +135 -0
  55. package/dist/core/query/types.d.ts.map +1 -0
  56. package/dist/core/store/eav-store.d.ts +107 -0
  57. package/dist/core/store/eav-store.d.ts.map +1 -0
  58. package/dist/db/index.d.ts +18 -0
  59. package/dist/db/index.d.ts.map +1 -0
  60. package/dist/db/index.js +83 -0
  61. package/dist/db/inspector.js +28 -0
  62. package/dist/db/trellis.css +1 -0
  63. package/dist/decisions/auto-capture.d.ts +31 -0
  64. package/dist/decisions/auto-capture.d.ts.map +1 -0
  65. package/dist/decisions/hooks.d.ts +48 -0
  66. package/dist/decisions/hooks.d.ts.map +1 -0
  67. package/dist/decisions/index.d.ts +36 -0
  68. package/dist/decisions/index.d.ts.map +1 -0
  69. package/dist/decisions/types.d.ts +73 -0
  70. package/dist/decisions/types.d.ts.map +1 -0
  71. package/dist/deploy-99j5dc9c.js +9 -0
  72. package/dist/embeddings/auto-embed.d.ts +52 -0
  73. package/dist/embeddings/auto-embed.d.ts.map +1 -0
  74. package/dist/embeddings/chunker.d.ts +73 -0
  75. package/dist/embeddings/chunker.d.ts.map +1 -0
  76. package/dist/embeddings/index.d.ts +18 -0
  77. package/dist/embeddings/index.d.ts.map +1 -0
  78. package/dist/embeddings/model.d.ts +30 -0
  79. package/dist/embeddings/model.d.ts.map +1 -0
  80. package/dist/embeddings/search.d.ts +87 -0
  81. package/dist/embeddings/search.d.ts.map +1 -0
  82. package/dist/embeddings/store.d.ts +66 -0
  83. package/dist/embeddings/store.d.ts.map +1 -0
  84. package/dist/embeddings/types.d.ts +54 -0
  85. package/dist/embeddings/types.d.ts.map +1 -0
  86. package/dist/engine-y0724kjq.js +8 -0
  87. package/dist/engine.d.ts +216 -0
  88. package/dist/engine.d.ts.map +1 -0
  89. package/dist/garden/cluster.d.ts +57 -0
  90. package/dist/garden/cluster.d.ts.map +1 -0
  91. package/dist/garden/garden.d.ts +104 -0
  92. package/dist/garden/garden.d.ts.map +1 -0
  93. package/dist/garden/index.d.ts +15 -0
  94. package/dist/garden/index.d.ts.map +1 -0
  95. package/dist/git/git-exporter.d.ts +37 -0
  96. package/dist/git/git-exporter.d.ts.map +1 -0
  97. package/dist/git/git-importer.d.ts +36 -0
  98. package/dist/git/git-importer.d.ts.map +1 -0
  99. package/dist/git/git-reader.d.ts +63 -0
  100. package/dist/git/git-reader.d.ts.map +1 -0
  101. package/dist/git/index.d.ts +10 -0
  102. package/dist/git/index.d.ts.map +1 -0
  103. package/dist/identity/governance.d.ts +54 -0
  104. package/dist/identity/governance.d.ts.map +1 -0
  105. package/dist/identity/identity.d.ts +63 -0
  106. package/dist/identity/identity.d.ts.map +1 -0
  107. package/dist/identity/index.d.ts +10 -0
  108. package/dist/identity/index.d.ts.map +1 -0
  109. package/dist/identity/signing-middleware.d.ts +38 -0
  110. package/dist/identity/signing-middleware.d.ts.map +1 -0
  111. package/dist/import-fyg5sgq4.js +11 -0
  112. package/dist/{index-5m0g9r0y.js → index-04sq3h27.js} +1 -496
  113. package/dist/index-2r4jxwnb.js +32 -0
  114. package/dist/index-4beszbgg.js +292 -0
  115. package/dist/index-5bhe57y9.js +326 -0
  116. package/dist/index-5p6zgspx.js +77 -0
  117. package/dist/index-7t92ej34.js +544 -0
  118. package/dist/index-8fjwnztt.js +155 -0
  119. package/dist/{index-22jx9qsz.js → index-czecrvvn.js} +4 -4
  120. package/dist/index-hgd30epa.js +149 -0
  121. package/dist/index-k5b0xskw.js +1 -0
  122. package/dist/index-kbnht9p8.js +1 -0
  123. package/dist/index-n9f2qyh5.js +495 -0
  124. package/dist/index-xr7rx360.js +814 -0
  125. package/dist/index-xzym9w0m.js +43 -0
  126. package/dist/index-yp88he8n.js +316 -0
  127. package/dist/index.d.ts +23 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/index.js +9 -7
  130. package/dist/links/index.d.ts +16 -0
  131. package/dist/links/index.d.ts.map +1 -0
  132. package/dist/links/lifecycle.d.ts +112 -0
  133. package/dist/links/lifecycle.d.ts.map +1 -0
  134. package/dist/links/parser.d.ts +56 -0
  135. package/dist/links/parser.d.ts.map +1 -0
  136. package/dist/links/ref-index.d.ts +55 -0
  137. package/dist/links/ref-index.d.ts.map +1 -0
  138. package/dist/links/resolver.d.ts +90 -0
  139. package/dist/links/resolver.d.ts.map +1 -0
  140. package/dist/links/types.d.ts +70 -0
  141. package/dist/links/types.d.ts.map +1 -0
  142. package/dist/mcp/docs.d.ts +18 -0
  143. package/dist/mcp/docs.d.ts.map +1 -0
  144. package/dist/mcp/index.d.ts +9 -0
  145. package/dist/mcp/index.d.ts.map +1 -0
  146. package/dist/mcp/server.d.ts +26 -0
  147. package/dist/mcp/server.d.ts.map +1 -0
  148. package/dist/react/index.js +189 -0
  149. package/dist/sdk-sj8rp0m7.js +15 -0
  150. package/dist/semantic/csharp-parser.d.ts +12 -0
  151. package/dist/semantic/csharp-parser.d.ts.map +1 -0
  152. package/dist/semantic/go-parser.d.ts +12 -0
  153. package/dist/semantic/go-parser.d.ts.map +1 -0
  154. package/dist/semantic/index.d.ts +22 -0
  155. package/dist/semantic/index.d.ts.map +1 -0
  156. package/dist/semantic/java-parser.d.ts +12 -0
  157. package/dist/semantic/java-parser.d.ts.map +1 -0
  158. package/dist/semantic/python-parser.d.ts +12 -0
  159. package/dist/semantic/python-parser.d.ts.map +1 -0
  160. package/dist/semantic/ruby-parser.d.ts +12 -0
  161. package/dist/semantic/ruby-parser.d.ts.map +1 -0
  162. package/dist/semantic/rust-parser.d.ts +12 -0
  163. package/dist/semantic/rust-parser.d.ts.map +1 -0
  164. package/dist/semantic/semantic-merge.d.ts +20 -0
  165. package/dist/semantic/semantic-merge.d.ts.map +1 -0
  166. package/dist/semantic/ts-parser.d.ts +13 -0
  167. package/dist/semantic/ts-parser.d.ts.map +1 -0
  168. package/dist/semantic/types.d.ts +130 -0
  169. package/dist/semantic/types.d.ts.map +1 -0
  170. package/dist/server/auth.d.ts +72 -0
  171. package/dist/server/auth.d.ts.map +1 -0
  172. package/dist/server/deploy.d.ts +44 -0
  173. package/dist/server/deploy.d.ts.map +1 -0
  174. package/dist/server/import.d.ts +40 -0
  175. package/dist/server/import.d.ts.map +1 -0
  176. package/dist/server/index.d.ts +24 -0
  177. package/dist/server/index.d.ts.map +1 -0
  178. package/dist/server/index.js +60 -0
  179. package/dist/server/permissions.d.ts +84 -0
  180. package/dist/server/permissions.d.ts.map +1 -0
  181. package/dist/server/realtime.d.ts +78 -0
  182. package/dist/server/realtime.d.ts.map +1 -0
  183. package/dist/server/server.d.ts +43 -0
  184. package/dist/server/server.d.ts.map +1 -0
  185. package/dist/server/tenancy.d.ts +53 -0
  186. package/dist/server/tenancy.d.ts.map +1 -0
  187. package/dist/server-3vkpnpbz.js +11 -0
  188. package/dist/sync/http-transport.d.ts +47 -0
  189. package/dist/sync/http-transport.d.ts.map +1 -0
  190. package/dist/sync/index.d.ts +22 -0
  191. package/dist/sync/index.d.ts.map +1 -0
  192. package/dist/sync/memory-transport.d.ts +27 -0
  193. package/dist/sync/memory-transport.d.ts.map +1 -0
  194. package/dist/sync/multi-repo.d.ts +82 -0
  195. package/dist/sync/multi-repo.d.ts.map +1 -0
  196. package/dist/sync/reconciler.d.ts +48 -0
  197. package/dist/sync/reconciler.d.ts.map +1 -0
  198. package/dist/sync/sync-engine.d.ts +65 -0
  199. package/dist/sync/sync-engine.d.ts.map +1 -0
  200. package/dist/sync/types.d.ts +71 -0
  201. package/dist/sync/types.d.ts.map +1 -0
  202. package/dist/sync/ws-transport.d.ts +41 -0
  203. package/dist/sync/ws-transport.d.ts.map +1 -0
  204. package/dist/tenancy-tjr7kk2v.js +13 -0
  205. package/dist/ui/server.d.ts +38 -0
  206. package/dist/ui/server.d.ts.map +1 -0
  207. package/dist/vcs/blob-store.d.ts +49 -0
  208. package/dist/vcs/blob-store.d.ts.map +1 -0
  209. package/dist/vcs/branch.d.ts +35 -0
  210. package/dist/vcs/branch.d.ts.map +1 -0
  211. package/dist/vcs/checkpoint.d.ts +24 -0
  212. package/dist/vcs/checkpoint.d.ts.map +1 -0
  213. package/dist/vcs/decompose.d.ts +19 -0
  214. package/dist/vcs/decompose.d.ts.map +1 -0
  215. package/dist/vcs/diff.d.ts +65 -0
  216. package/dist/vcs/diff.d.ts.map +1 -0
  217. package/dist/vcs/engine-context.d.ts +21 -0
  218. package/dist/vcs/engine-context.d.ts.map +1 -0
  219. package/dist/vcs/index.d.ts +23 -0
  220. package/dist/vcs/index.d.ts.map +1 -0
  221. package/dist/vcs/issue.d.ts +159 -0
  222. package/dist/vcs/issue.d.ts.map +1 -0
  223. package/dist/vcs/merge.d.ts +55 -0
  224. package/dist/vcs/merge.d.ts.map +1 -0
  225. package/dist/vcs/milestone.d.ts +30 -0
  226. package/dist/vcs/milestone.d.ts.map +1 -0
  227. package/dist/vcs/ops.d.ts +27 -0
  228. package/dist/vcs/ops.d.ts.map +1 -0
  229. package/dist/vcs/types.d.ts +94 -0
  230. package/dist/vcs/types.d.ts.map +1 -0
  231. package/dist/vcs/vcs-middleware.d.ts +14 -0
  232. package/dist/vcs/vcs-middleware.d.ts.map +1 -0
  233. package/dist/watcher/fs-watcher.d.ts +51 -0
  234. package/dist/watcher/fs-watcher.d.ts.map +1 -0
  235. package/dist/watcher/index.d.ts +9 -0
  236. package/dist/watcher/index.d.ts.map +1 -0
  237. package/dist/watcher/ingestion.d.ts +28 -0
  238. package/dist/watcher/ingestion.d.ts.map +1 -0
  239. package/package.json +44 -4
  240. package/dist/index-hybgxe40.js +0 -1174
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Trellis
2
2
 
3
- > **A comprehensive graph-native platform for code, knowledge, and collaboration.**
3
+ > **The Agentic State Engine** — an event-sourced, causal graph engine for building stateful, auditable, branchable applications. Use it as version control for code, a runtime for AI agents, or a reactive backend for collaborative apps.
4
4
 
5
- | Capability | Description |
6
- | :--------------------- | :------------------------------------------------------------ |
7
- | **Graph-Native VCS** | Immutable causal ops, semantic patching, narrative milestones |
8
- | **Knowledge Graph** | EAV store, wiki-links, embeddings, ontology validation |
9
- | **Intelligent Agents** | Tool registry, decision traces, agent orchestration |
10
- | **Collaboration** | Peer sync, multi-repo federation, HTTP/WebSocket transports |
5
+ | Use Case | How |
6
+ | :--- | :--- |
7
+ | **AI agent runtime** | Tool registry + decision traces + branching — agents operate on state they can fork, audit, and roll back |
8
+ | **Collaborative app backend** | CRDT sync + multi-tenancy + realtime subscriptions via `trellis/server` and `trellis/react` |
9
+ | **Version control for code** | Semantic patching + narrative milestones + Idea Garden for abandoned work revival |
10
+ | **Auditable data platform** | Immutable op log + time travel + identity governance — every mutation is signed and causal |
11
11
 
12
12
  ---
13
13
 
@@ -66,7 +66,7 @@ npx trellis import --from /path/to/git-repo
66
66
 
67
67
  ## Platform Overview
68
68
 
69
- Trellis is a comprehensive platform that unifies version control, knowledge management, semantic analysis, and intelligent automation. Built on a graph-native foundation, it treats every action—code changes, decisions, links, and embeddingsas first-class entities in a causal graph.
69
+ Trellis is an event-sourced causal graph engine that unifies version control, knowledge management, semantic analysis, and intelligent automation. Every action code changes, agent decisions, wiki-links, embeddingsis an immutable operation in a causal stream, giving you time-travel, branching, and full auditability out of the box.
70
70
 
71
71
  The platform consists of multiple integrated surfaces:
72
72
 
@@ -128,6 +128,10 @@ trellis/
128
128
  │ │ ├── query/ # EQL-S query engine and Datalog evaluator
129
129
  │ │ ├── agents/ # Agent harness, tool registry, decision traces
130
130
  │ │ └── plugins/ # Plugin registry, event bus, workspace config
131
+ │ ├── server/ # HTTP+WS server, auth, permissions, tenancy, deploy
132
+ │ │ └── inspector/ # Visual DB inspector (web component)
133
+ │ ├── client/ # Isomorphic SDK (local + remote), config
134
+ │ ├── react/ # React hooks: useTrellis, useEntity, useQuery, useMutation
131
135
  │ ├── vcs/ # Version control: ops, branches, milestones, diff, merge
132
136
  │ ├── links/ # Wiki-link parsing, resolution, backlink index
133
137
  │ ├── embeddings/ # Semantic indexing, vector search, auto-embed, RAG
@@ -140,6 +144,7 @@ trellis/
140
144
  │ ├── watcher/ # File watching + ingestion pipeline
141
145
  │ ├── mcp/ # Model Context Protocol server integration
142
146
  │ ├── cli/ # CLI entrypoint
147
+ │ ├── db/ # ⚠️ Deprecated shim — re-exports from server + client
143
148
  │ ├── engine.ts # Composition root
144
149
  │ └── index.ts # Main package entrypoint
145
150
  ├── vscode-extension/ # VS Code extension surface
@@ -325,6 +330,15 @@ import { TrellisVcsEngine } from 'trellis';
325
330
  import { EAVStore, TrellisKernel } from 'trellis/core';
326
331
  import type { Fact, Link, EntityRecord } from 'trellis/core';
327
332
 
333
+ // Server — HTTP+WS host, auth, permissions, multi-tenancy
334
+ import { startServer, TenantPool } from 'trellis/server';
335
+
336
+ // Client — isomorphic SDK (local or remote)
337
+ import { TrellisClient } from 'trellis/client';
338
+
339
+ // React — reactive hooks for graph subscriptions
340
+ import { TrellisProvider, useEntity, useQuery } from 'trellis/react';
341
+
328
342
  // Version control primitives
329
343
  import type { VcsOp, VcsOpKind } from 'trellis/vcs';
330
344
 
@@ -464,6 +478,81 @@ const decs = queryDecisions(ctx, { tool: 'trellis_issue_*' });
464
478
  const chain = queryDecisions(ctx, { entity: 'TRL-5' }); // Full decision chain
465
479
  ```
466
480
 
481
+ ### `trellis/server` — HTTP + WebSocket Server
482
+
483
+ Production-grade server host for the Trellis engine: multi-tenancy, auth (JWT + OAuth), permission middleware, realtime subscriptions, file uploads, and deployment tooling.
484
+
485
+ ```typescript
486
+ import { startServer, TenantPool } from 'trellis/server';
487
+
488
+ const pool = new TenantPool('/data/tenants');
489
+ await startServer({
490
+ port: 3000,
491
+ dbPath: '/data/trellis',
492
+ apiKey: 'secret',
493
+ tenantPool: pool,
494
+ });
495
+ ```
496
+
497
+ ### `trellis/client` — Isomorphic SDK
498
+
499
+ TypeScript client that works in two modes — **local** (embeds TrellisKernel, zero network) or **remote** (calls the Trellis Server HTTP API). Includes CRUD, EQL-S queries, file uploads, auth, and WebSocket subscriptions.
500
+
501
+ ```typescript
502
+ import { TrellisClient } from 'trellis/client';
503
+
504
+ // Remote mode
505
+ const db = new TrellisClient({ url: 'https://myapp.example.com', apiKey: '...' });
506
+
507
+ // Local mode (Node/Bun only)
508
+ const local = new TrellisClient({ path: './.trellis-db' });
509
+
510
+ // CRUD
511
+ const note = await db.create('Note', { title: 'Hello', body: 'World' });
512
+ const notes = await db.list('Note', { limit: 10 });
513
+
514
+ // Realtime subscriptions
515
+ const sub = db.subscribe("find Note where pinned = 'true'", (results) => {
516
+ console.log('Live update:', results);
517
+ });
518
+ ```
519
+
520
+ ### `trellis/react` — React Hooks
521
+
522
+ Reactive hooks that turn the Trellis client into a live data layer for React applications. Auto-subscribes via WebSocket and cleans up on unmount.
523
+
524
+ ```tsx
525
+ import { TrellisProvider, useEntity, useEntities, useQuery, useMutation } from 'trellis/react';
526
+
527
+ function App() {
528
+ return (
529
+ <TrellisProvider url="http://localhost:3000" apiKey="...">
530
+ <NoteList />
531
+ </TrellisProvider>
532
+ );
533
+ }
534
+
535
+ function NoteList() {
536
+ const { data: notes, loading } = useEntities<Note>('Note', { limit: 20 });
537
+ const { create } = useMutation();
538
+
539
+ if (loading) return <p>Loading...</p>;
540
+ return notes.map(n => <NoteCard key={n.id} note={n} />);
541
+ }
542
+
543
+ function NoteDetail({ id }: { id: string }) {
544
+ const { data: note, loading } = useEntity<Note>(id);
545
+ if (loading || !note) return <p>Loading...</p>;
546
+ return <h1>{note.title}</h1>;
547
+ }
548
+ ```
549
+
550
+ ### `trellis/db` — Deprecated Alias
551
+
552
+ > **⚠️ Deprecated.** Use `trellis/server` and `trellis/client` instead.
553
+
554
+ This subpath re-exports everything from `trellis/server` and `trellis/client` for backward compatibility. It will be removed in a future major version.
555
+
467
556
  ### `src/garden/` — Idea Garden
468
557
 
469
558
  Detects abandoned work using three heuristics, then exposes a query API.
@@ -760,5 +849,6 @@ just publish
760
849
  | P15 | Plugin system + event bus + workspace config | ✅ | |
761
850
  | P16 | Sync federation + multi-repo linking | ✅ | |
762
851
  | P17 | Advanced knowledge graph + cross-repo intelligence | 🚧 | In Progress |
763
- | P18 | Enterprise collaboration features + RBAC | 📋 | Planned |
764
- | P19 | Advanced AI capabilities + intelligent automation | 📋 | Planned |
852
+ | P18 | Agentic State Engine pivot server/client/react split | | |
853
+ | P19 | Enterprise collaboration features + RBAC | 📋 | Planned |
854
+ | P20 | Advanced AI capabilities + intelligent automation | 📋 | Planned |
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * TrellisVCS CLI
4
+ *
5
+ * Commands:
6
+ * init Initialize a new TrellisVCS repository
7
+ * status Show current repository status
8
+ * log Show operation history
9
+ * watch Start file watcher (foreground)
10
+ * files List tracked files
11
+ * import Import from a Git repository
12
+ */
13
+ export {};
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;GAUG"}
package/dist/cli/index.js CHANGED
@@ -3,19 +3,12 @@
3
3
  import {
4
4
  TrellisVcsEngine,
5
5
  init_engine
6
- } from "../index-22jx9qsz.js";
6
+ } from "../index-czecrvvn.js";
7
7
  import {
8
8
  OntologyRegistry,
9
9
  builtinOntologies,
10
- parseQuery,
11
- parseSimple,
12
10
  validateStore
13
- } from "../index-5m0g9r0y.js";
14
- import {
15
- QueryEngine,
16
- SqliteKernelBackend,
17
- TrellisKernel
18
- } from "../index-hybgxe40.js";
11
+ } from "../index-04sq3h27.js";
19
12
  import"../index-3ejh8k6v.js";
20
13
  import {
21
14
  VectorStore,
@@ -38,6 +31,18 @@ import {
38
31
  createVcsOp,
39
32
  init_ops
40
33
  } from "../index-v9b4hqa7.js";
34
+ import {
35
+ parseQuery,
36
+ parseSimple
37
+ } from "../index-n9f2qyh5.js";
38
+ import {
39
+ SqliteKernelBackend,
40
+ TrellisKernel
41
+ } from "../index-7t92ej34.js";
42
+ import"../index-5bhe57y9.js";
43
+ import {
44
+ QueryEngine
45
+ } from "../index-yp88he8n.js";
41
46
  import {
42
47
  __commonJS,
43
48
  __esm,
@@ -5726,4 +5731,189 @@ function formatRelativeTime(iso) {
5726
5731
  return `${Math.floor(diff / 3600000)}h ago`;
5727
5732
  return `${Math.floor(diff / 86400000)}d ago`;
5728
5733
  }
5734
+ var db = program2.command("db").description("Trellis DB \u2014 use Trellis as an application database");
5735
+ db.command("init").description("Initialize a new Trellis DB in the current directory").option("-p, --path <path>", "Database directory", ".trellis-db").option("--port <port>", "Server port", "3000").option("--key <key>", "API key (auto-generated if omitted)").option("--jwt-secret <secret>", "JWT secret (auto-generated if omitted)").option("--multi-tenant", "Enable multi-tenancy (separate SQLite per tenant)").action(async (opts) => {
5736
+ const { writeConfig, defaultLocalConfig, hasConfig, configPath } = await import("../config-8hczw0rs.js");
5737
+ const { resolve: resolve2 } = await import("path");
5738
+ if (hasConfig(".")) {
5739
+ console.log(source_default.yellow(`Already initialized (${configPath(".")}). Use \`trellis db serve\` to start.`));
5740
+ return;
5741
+ }
5742
+ const dbPath = resolve2(opts.path);
5743
+ const apiKey = opts.key ?? `spk_${crypto.randomUUID().replace(/-/g, "")}`;
5744
+ const jwtSecret = opts.jwtSecret ?? `jws_${crypto.randomUUID().replace(/-/g, "")}`;
5745
+ writeConfig(defaultLocalConfig(dbPath, {
5746
+ port: parseInt(opts.port),
5747
+ apiKey,
5748
+ jwtSecret,
5749
+ multiTenant: !!opts.multiTenant
5750
+ }), ".");
5751
+ console.log(source_default.green("\u2713 Trellis DB initialized"));
5752
+ console.log(source_default.dim(` Config: .trellis-db.json`));
5753
+ console.log(source_default.dim(` DB path: ${dbPath}`));
5754
+ console.log(source_default.dim(` API key: ${apiKey}`));
5755
+ console.log(source_default.dim(` Port: ${opts.port}`));
5756
+ console.log("");
5757
+ console.log(source_default.bold("Next steps:"));
5758
+ console.log(` ${source_default.cyan("trellis db serve")} Start the local HTTP server`);
5759
+ console.log(` ${source_default.cyan("trellis db deploy --name <n>")} Deploy to Sprites`);
5760
+ });
5761
+ db.command("serve").description("Start the Trellis DB HTTP + WebSocket server").option("-p, --port <port>", "Override port from config").option("--config-dir <dir>", "Directory containing .trellis-db.json", ".").action(async (opts) => {
5762
+ const { readConfig } = await import("../config-8hczw0rs.js");
5763
+ const { TenantPool } = await import("../tenancy-tjr7kk2v.js");
5764
+ const { startServer } = await import("../server-3vkpnpbz.js");
5765
+ const config = readConfig(opts.configDir);
5766
+ if (!config) {
5767
+ console.error(source_default.red("No .trellis-db.json found. Run `trellis db init` first."));
5768
+ process.exit(1);
5769
+ }
5770
+ if (!config.dbPath) {
5771
+ console.error(source_default.red("Config is missing dbPath. Re-run `trellis db init`."));
5772
+ process.exit(1);
5773
+ }
5774
+ const port = opts.port ? parseInt(opts.port) : config.port ?? 3000;
5775
+ const pool = new TenantPool(config.dbPath);
5776
+ const server = startServer({ port, config, pool });
5777
+ console.log(source_default.green(`\u2713 Trellis DB running`));
5778
+ console.log(source_default.dim(` URL: http://localhost:${port}`));
5779
+ console.log(source_default.dim(` Docs: GET http://localhost:${port}/health`));
5780
+ if (config.apiKey) {
5781
+ console.log(source_default.dim(` Key: ${config.apiKey}`));
5782
+ }
5783
+ });
5784
+ db.command("create <type> [json]").description("Create an entity (json can be a JSON string or @file.json)").option("--config-dir <dir>", "Config directory", ".").option("--tenant <id>", "Tenant ID").action(async (type, jsonArg, opts) => {
5785
+ const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
5786
+ const db2 = TrellisDb.fromConfig(opts.configDir);
5787
+ let attributes = {};
5788
+ if (jsonArg) {
5789
+ const { readFileSync: readFileSync4 } = await import("fs");
5790
+ const raw = jsonArg.startsWith("@") ? readFileSync4(jsonArg.slice(1), "utf8") : jsonArg;
5791
+ attributes = JSON.parse(raw);
5792
+ }
5793
+ const id = await db2.create(type, attributes);
5794
+ console.log(source_default.green(`\u2713 Created: ${source_default.bold(id)}`));
5795
+ db2.close();
5796
+ });
5797
+ db.command("read <id>").description("Read an entity by ID").option("--config-dir <dir>", "Config directory", ".").action(async (id, opts) => {
5798
+ const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
5799
+ const db2 = TrellisDb.fromConfig(opts.configDir);
5800
+ const entity = await db2.read(id);
5801
+ if (!entity) {
5802
+ console.error(source_default.red(`Not found: ${id}`));
5803
+ process.exit(1);
5804
+ }
5805
+ console.log(JSON.stringify(entity, null, 2));
5806
+ db2.close();
5807
+ });
5808
+ db.command("update <id> <json>").description("Update entity attributes (JSON string or @file.json)").option("--config-dir <dir>", "Config directory", ".").action(async (id, jsonArg, opts) => {
5809
+ const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
5810
+ const db2 = TrellisDb.fromConfig(opts.configDir);
5811
+ const { readFileSync: readFileSync4 } = await import("fs");
5812
+ const raw = jsonArg.startsWith("@") ? readFileSync4(jsonArg.slice(1), "utf8") : jsonArg;
5813
+ await db2.update(id, JSON.parse(raw));
5814
+ console.log(source_default.green(`\u2713 Updated: ${source_default.bold(id)}`));
5815
+ db2.close();
5816
+ });
5817
+ db.command("delete <id>").description("Delete an entity by ID").option("--config-dir <dir>", "Config directory", ".").action(async (id, opts) => {
5818
+ const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
5819
+ const db2 = TrellisDb.fromConfig(opts.configDir);
5820
+ await db2.delete(id);
5821
+ console.log(source_default.green(`\u2713 Deleted: ${source_default.bold(id)}`));
5822
+ db2.close();
5823
+ });
5824
+ db.command("list").description("List entities").option("--type <type>", "Filter by entity type").option("--limit <n>", "Max results", "50").option("--offset <n>", "Offset", "0").option("--config-dir <dir>", "Config directory", ".").action(async (opts) => {
5825
+ const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
5826
+ const db2 = TrellisDb.fromConfig(opts.configDir);
5827
+ const result = await db2.list(opts.type, {
5828
+ limit: parseInt(opts.limit),
5829
+ offset: parseInt(opts.offset)
5830
+ });
5831
+ console.log(JSON.stringify(result, null, 2));
5832
+ db2.close();
5833
+ });
5834
+ db.command("query <eql>").description("Run an EQL-S query").option("--config-dir <dir>", "Config directory", ".").action(async (eql, opts) => {
5835
+ const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
5836
+ const db2 = TrellisDb.fromConfig(opts.configDir);
5837
+ const result = await db2.query(eql);
5838
+ console.log(JSON.stringify(result.bindings, null, 2));
5839
+ console.log(source_default.dim(`Execution time: ${result.executionTime}ms`));
5840
+ db2.close();
5841
+ });
5842
+ db.command("upload <file>").description("Upload a file to the blob store").option("--config-dir <dir>", "Config directory", ".").option("--type <mime>", "MIME type (auto-detected if omitted)").action(async (filePath, opts) => {
5843
+ const { readFileSync: readFileSync4 } = await import("fs");
5844
+ const { extname } = await import("path");
5845
+ const { TrellisDb } = await import("../sdk-sj8rp0m7.js");
5846
+ const mimeMap = {
5847
+ ".png": "image/png",
5848
+ ".jpg": "image/jpeg",
5849
+ ".jpeg": "image/jpeg",
5850
+ ".gif": "image/gif",
5851
+ ".pdf": "application/pdf",
5852
+ ".json": "application/json",
5853
+ ".txt": "text/plain"
5854
+ };
5855
+ const contentType = opts.type ?? mimeMap[extname(filePath).toLowerCase()] ?? "application/octet-stream";
5856
+ const buffer = readFileSync4(filePath);
5857
+ const db2 = TrellisDb.fromConfig(opts.configDir);
5858
+ const result = await db2.upload(new Uint8Array(buffer), contentType);
5859
+ console.log(source_default.green(`\u2713 Uploaded`));
5860
+ console.log(source_default.dim(` Hash: ${result.hash}`));
5861
+ console.log(source_default.dim(` Size: ${result.size} bytes`));
5862
+ db2.close();
5863
+ });
5864
+ db.command("import <file>").description("Import data from CSV, JSON, NDJSON, or Parquet").requiredOption("--type <type>", "Entity type to assign to each record").option("--id-field <field>", "Field to use as entity ID").option("--limit <n>", "Max rows to import").option("--config-dir <dir>", "Config directory", ".").option("--tenant <id>", "Tenant ID").action(async (filePath, opts) => {
5865
+ const { readConfig } = await import("../config-8hczw0rs.js");
5866
+ const { TenantPool } = await import("../tenancy-tjr7kk2v.js");
5867
+ const { importFile } = await import("../import-fyg5sgq4.js");
5868
+ const config = readConfig(opts.configDir);
5869
+ if (!config?.dbPath) {
5870
+ console.error(source_default.red("No .trellis-db.json found. Run `trellis db init` first."));
5871
+ process.exit(1);
5872
+ }
5873
+ const pool = new TenantPool(config.dbPath);
5874
+ const kernel = pool.get(opts.tenant ?? null);
5875
+ const result = await importFile(kernel, filePath, {
5876
+ type: opts.type,
5877
+ idField: opts.idField,
5878
+ limit: opts.limit ? parseInt(opts.limit) : undefined
5879
+ });
5880
+ console.log(source_default.green(`\u2713 Import complete`));
5881
+ console.log(source_default.dim(` Imported: ${result.imported}`));
5882
+ console.log(source_default.dim(` Skipped: ${result.skipped}`));
5883
+ if (result.errors.length > 0) {
5884
+ console.log(source_default.yellow(` Errors: ${result.errors.length}`));
5885
+ result.errors.slice(0, 5).forEach((e) => {
5886
+ console.log(source_default.red(` Row ${e.row}: ${e.message}`));
5887
+ });
5888
+ }
5889
+ pool.closeAll();
5890
+ });
5891
+ db.command("deploy").description("Deploy Trellis DB to a Sprites cloud environment").requiredOption("--name <name>", "Sprite name (becomes <name>.sprites.app)").option("--key <key>", "API key for the deployed server (auto-generated if omitted)").option("--jwt-secret <secret>", "JWT secret (auto-generated if omitted)").option("--port <port>", "Port to run on inside Sprite", "3000").option("--config-dir <dir>", "Config directory", ".").action(async (opts) => {
5892
+ const { deploy } = await import("../deploy-99j5dc9c.js");
5893
+ const { readConfig } = await import("../config-8hczw0rs.js");
5894
+ const config = readConfig(opts.configDir);
5895
+ console.log(source_default.bold(`Deploying to Sprites: ${opts.name}...`));
5896
+ try {
5897
+ const result = await deploy({
5898
+ name: opts.name,
5899
+ dbPath: config?.dbPath,
5900
+ apiKey: opts.key,
5901
+ jwtSecret: opts.jwtSecret,
5902
+ port: opts.port ? parseInt(opts.port) : 3000,
5903
+ configDir: opts.configDir,
5904
+ onProgress: (msg) => console.log(source_default.dim(` ${msg}`))
5905
+ });
5906
+ console.log("");
5907
+ console.log(source_default.green(`\u2713 Deployed successfully`));
5908
+ console.log(source_default.dim(` URL: ${result.url}`));
5909
+ console.log(source_default.dim(` Key: ${result.apiKey}`));
5910
+ console.log("");
5911
+ console.log(source_default.bold("SDK usage:"));
5912
+ console.log(source_default.cyan(` import { TrellisClient } from 'trellis/client';`));
5913
+ console.log(source_default.cyan(` const db = new TrellisClient({ url: '${result.url}', apiKey: '${result.apiKey}' });`));
5914
+ } catch (err) {
5915
+ console.error(source_default.red(`Deploy failed: ${err.message}`));
5916
+ process.exit(1);
5917
+ }
5918
+ });
5729
5919
  program2.parse();
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Trellis Client — Configuration
3
+ *
4
+ * Manages `.trellis-db.json` — the local project config file that records
5
+ * whether this instance is running locally or deployed to Sprites.
6
+ *
7
+ * @module trellis/client
8
+ */
9
+ export type DbMode = 'local' | 'remote';
10
+ export interface TrellisDbConfig {
11
+ /** Whether the DB is local (SQLite) or remote (Sprites/custom URL). */
12
+ mode: DbMode;
13
+ /** Absolute path to the SQLite database directory (local mode). */
14
+ dbPath?: string;
15
+ /** Remote API base URL (remote mode). */
16
+ url?: string;
17
+ /** API key for remote mode authentication. */
18
+ apiKey?: string;
19
+ /** Sprites sprite name (used for deploy). */
20
+ spriteName?: string;
21
+ /** ISO timestamp of last deploy. */
22
+ deployedAt?: string;
23
+ /** Port for local server mode (default: 3000). */
24
+ port?: number;
25
+ /** Enable multi-tenancy (separate SQLite per tenant). */
26
+ multiTenant?: boolean;
27
+ /** Secret used to sign/verify JWTs. */
28
+ jwtSecret?: string;
29
+ }
30
+ export declare const CONFIG_FILE = ".trellis-db.json";
31
+ /**
32
+ * Resolve the config file path relative to a directory.
33
+ */
34
+ export declare function configPath(dir?: string): string;
35
+ /**
36
+ * Check if a `.trellis-db.json` exists in the given directory.
37
+ */
38
+ export declare function hasConfig(dir?: string): boolean;
39
+ /**
40
+ * Read and parse the `.trellis-db.json` config file.
41
+ * Returns null if the file doesn't exist.
42
+ */
43
+ export declare function readConfig(dir?: string): TrellisDbConfig | null;
44
+ /**
45
+ * Write a config to `.trellis-db.json`.
46
+ */
47
+ export declare function writeConfig(config: TrellisDbConfig, dir?: string): void;
48
+ /**
49
+ * Merge partial updates into an existing config file (creates if missing).
50
+ */
51
+ export declare function updateConfig(updates: Partial<TrellisDbConfig>, dir?: string): TrellisDbConfig;
52
+ /**
53
+ * Build a local config with sensible defaults for a given directory.
54
+ */
55
+ export declare function defaultLocalConfig(dbPath: string, opts?: Partial<TrellisDbConfig>): TrellisDbConfig;
56
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/client/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAExC,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,eAAO,MAAM,WAAW,qBAAqB,CAAC;AAM9C;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,SAAM,GAAG,MAAM,CAE5C;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,SAAM,GAAG,OAAO,CAE5C;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,SAAM,GAAG,eAAe,GAAG,IAAI,CAQ5D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,SAAM,GAAG,IAAI,CAGpE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EACjC,GAAG,SAAM,GACR,eAAe,CAKjB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,OAAO,CAAC,eAAe,CAAM,GAClC,eAAe,CAQjB"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Trellis Client — Public API Surface
3
+ *
4
+ * Isomorphic SDK for interacting with Trellis (local or remote).
5
+ * Import from `trellis/client`:
6
+ *
7
+ * import { TrellisClient } from 'trellis/client';
8
+ *
9
+ * @module trellis/client
10
+ */
11
+ export { TrellisDb as TrellisClient, TrellisDb, FetchError } from './sdk.js';
12
+ export type { EntityData, ListResult, QueryResult, UploadResult, AuthResult, Subscription, SubscriptionCallback, TrellisDbLocalOptions, TrellisDbRemoteOptions, TrellisDbOptions, } from './sdk.js';
13
+ export { readConfig, writeConfig, updateConfig, hasConfig, configPath, defaultLocalConfig, CONFIG_FILE, } from './config.js';
14
+ export type { TrellisDbConfig, DbMode } from './config.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC7E,YAAY,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,UAAU,EACV,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,32 @@
1
+ // @bun
2
+ import"../index-k5b0xskw.js";
3
+ import {
4
+ FetchError,
5
+ TrellisDb
6
+ } from "../index-4beszbgg.js";
7
+ import {
8
+ CONFIG_FILE,
9
+ configPath,
10
+ defaultLocalConfig,
11
+ hasConfig,
12
+ readConfig,
13
+ updateConfig,
14
+ writeConfig
15
+ } from "../index-xzym9w0m.js";
16
+ import"../index-5p6zgspx.js";
17
+ import"../index-7t92ej34.js";
18
+ import"../index-5bhe57y9.js";
19
+ import"../index-yp88he8n.js";
20
+ import"../index-a76rekgs.js";
21
+ export {
22
+ writeConfig,
23
+ updateConfig,
24
+ readConfig,
25
+ hasConfig,
26
+ defaultLocalConfig,
27
+ configPath,
28
+ TrellisDb,
29
+ TrellisDb as TrellisClient,
30
+ FetchError,
31
+ CONFIG_FILE
32
+ };
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Trellis Client — TypeScript SDK
3
+ *
4
+ * Isomorphic client that works in two modes:
5
+ *
6
+ * Local — embeds TrellisKernel directly (Node/Bun only, zero network)
7
+ * Remote — calls the Trellis Server HTTP API (works anywhere, including browsers)
8
+ *
9
+ * Usage:
10
+ * // Local (embeds SQLite kernel)
11
+ * const db = new TrellisClient({ path: './.trellis-db' });
12
+ *
13
+ * // Remote (hits HTTP server or Sprites deployment)
14
+ * const db = new TrellisClient({ url: 'https://myapp.sprites.app', apiKey: '...' });
15
+ *
16
+ * // Auto (reads .trellis-db.json from cwd)
17
+ * const db = await TrellisClient.fromConfig();
18
+ *
19
+ * @module trellis/client
20
+ */
21
+ export interface EntityData {
22
+ id: string;
23
+ type: string;
24
+ [key: string]: unknown;
25
+ }
26
+ export interface ListResult<T = EntityData> {
27
+ data: T[];
28
+ total: number;
29
+ limit: number;
30
+ offset: number;
31
+ }
32
+ export interface QueryResult {
33
+ bindings: Record<string, unknown>[];
34
+ executionTime: number;
35
+ }
36
+ export interface UploadResult {
37
+ hash: string;
38
+ size: number;
39
+ contentType: string;
40
+ }
41
+ export interface AuthResult {
42
+ token: string;
43
+ userId: string;
44
+ }
45
+ export interface Subscription<T = EntityData> {
46
+ unsubscribe(): void;
47
+ }
48
+ export type SubscriptionCallback<T = EntityData> = (result: T[], diff: {
49
+ added: T[];
50
+ updated: T[];
51
+ removed: T[];
52
+ }) => void;
53
+ export interface TrellisDbLocalOptions {
54
+ /** Path to the SQLite database directory. */
55
+ path: string;
56
+ /** Agent ID for attributing ops. Default: 'sdk'. */
57
+ agentId?: string;
58
+ /** Tenant ID (multi-tenant mode). */
59
+ tenantId?: string;
60
+ }
61
+ export interface TrellisDbRemoteOptions {
62
+ /** Base URL of the Trellis DB server. */
63
+ url: string;
64
+ /** API key or JWT for authentication. */
65
+ apiKey?: string;
66
+ /** Tenant ID (passed as query param if not in JWT). */
67
+ tenantId?: string;
68
+ }
69
+ export type TrellisDbOptions = TrellisDbLocalOptions | TrellisDbRemoteOptions;
70
+ export declare class TrellisDb {
71
+ private opts;
72
+ private _pool;
73
+ private _ws;
74
+ private _subCallbacks;
75
+ constructor(opts: TrellisDbOptions);
76
+ /**
77
+ * Create a TrellisDb instance from `.trellis-db.json` in the given directory.
78
+ */
79
+ static fromConfig(dir?: string): TrellisDb;
80
+ /**
81
+ * Create a new entity.
82
+ * Returns the generated entity ID.
83
+ */
84
+ create(type: string, attributes?: Record<string, unknown>, links?: Array<{
85
+ attribute: string;
86
+ targetEntityId: string;
87
+ }>): Promise<string>;
88
+ /**
89
+ * Read an entity by ID.
90
+ * Returns null if not found.
91
+ */
92
+ read<T extends EntityData = EntityData>(id: string): Promise<T | null>;
93
+ /**
94
+ * Update an entity's attributes (partial update).
95
+ */
96
+ update(id: string, attributes: Record<string, unknown>): Promise<void>;
97
+ /**
98
+ * Delete an entity by ID.
99
+ */
100
+ delete(id: string): Promise<void>;
101
+ /**
102
+ * List entities of a given type.
103
+ */
104
+ list<T extends EntityData = EntityData>(type?: string, opts?: {
105
+ limit?: number;
106
+ offset?: number;
107
+ filters?: Record<string, unknown>;
108
+ }): Promise<ListResult<T>>;
109
+ /**
110
+ * Run an EQL-S query string.
111
+ */
112
+ query(eql: string): Promise<QueryResult>;
113
+ /**
114
+ * Upload a file to the blob store.
115
+ * Returns a content-addressed hash.
116
+ */
117
+ upload(data: Uint8Array | ArrayBuffer, contentType?: string): Promise<UploadResult>;
118
+ /**
119
+ * Download a file by its blob hash.
120
+ */
121
+ getFile(hash: string): Promise<Uint8Array | null>;
122
+ register(email: string, password: string, name?: string): Promise<AuthResult>;
123
+ login(email: string, password: string): Promise<AuthResult>;
124
+ /**
125
+ * Set the active API key / JWT token for subsequent requests.
126
+ */
127
+ setToken(token: string): void;
128
+ /**
129
+ * Subscribe to a live EQL-S query.
130
+ * Callback is fired immediately with the initial result, then on every update.
131
+ *
132
+ * Requires remote mode (WebSocket to server).
133
+ */
134
+ subscribe<T = EntityData>(eql: string, callback: SubscriptionCallback<T>): Subscription<T>;
135
+ /**
136
+ * Close the WebSocket connection.
137
+ */
138
+ disconnect(): void;
139
+ /**
140
+ * Close local kernel pool connections.
141
+ */
142
+ close(): void;
143
+ private _getPool;
144
+ private _fetch;
145
+ private _ensureWs;
146
+ }
147
+ export declare class FetchError extends Error {
148
+ status: number;
149
+ body?: unknown | undefined;
150
+ constructor(status: number, message: string, body?: unknown | undefined);
151
+ }
152
+ //# sourceMappingURL=sdk.d.ts.map