trellis 3.1.3 → 3.1.7

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 (60) hide show
  1. package/README.md +1 -0
  2. package/bin/trellis.mjs +68 -2
  3. package/dist/better-sqlite-backend-ahx5p0br.js +147 -0
  4. package/dist/cli/index.js +116 -45
  5. package/dist/client/index.js +5 -4
  6. package/dist/cms/client.d.ts +4 -3
  7. package/dist/cms/client.d.ts.map +1 -1
  8. package/dist/cms/formula.d.ts +10 -0
  9. package/dist/cms/formula.d.ts.map +1 -0
  10. package/dist/cms/index.d.ts +3 -2
  11. package/dist/cms/index.d.ts.map +1 -1
  12. package/dist/cms/index.js +156 -4
  13. package/dist/cms/types.d.ts +11 -0
  14. package/dist/cms/types.d.ts.map +1 -1
  15. package/dist/core/index.d.ts +4 -0
  16. package/dist/core/index.d.ts.map +1 -1
  17. package/dist/core/index.js +14 -4
  18. package/dist/core/persist/factory.d.ts +28 -0
  19. package/dist/core/persist/factory.d.ts.map +1 -0
  20. package/dist/core/persist/factory.js +8 -0
  21. package/dist/core/persist/sqlite-backend.d.ts.map +1 -1
  22. package/dist/core/persist/sqljs-backend.d.ts +60 -0
  23. package/dist/core/persist/sqljs-backend.d.ts.map +1 -0
  24. package/dist/core/persist/sqljs-backend.js +8 -0
  25. package/dist/db/index.js +11 -10
  26. package/dist/embeddings/index.js +1 -1
  27. package/dist/embeddings/store.d.ts.map +1 -1
  28. package/dist/{index-0zk3fx2s.js → index-4wxa8xz4.js} +4 -237
  29. package/dist/{index-6n5dcebj.js → index-53f3b8p8.js} +84 -30
  30. package/dist/{index-y3d71wzd.js → index-7pjz3tsy.js} +36 -6
  31. package/dist/{index-0q7wbasy.js → index-a2a394zz.js} +7 -3
  32. package/dist/index-h32txmxe.js +42 -0
  33. package/dist/index-h7zxhhhh.js +252 -0
  34. package/dist/index-h9e2efx4.js +251 -0
  35. package/dist/{index-2917tjd8.js → index-hr9qvv77.js} +15 -3
  36. package/dist/{index-hmdbnd4n.js → index-hy73j9z8.js} +1 -1
  37. package/dist/{index-q31hfjja.js → index-jgda3xyv.js} +1 -1
  38. package/dist/{index-7e27kvvj.js → index-wncptktd.js} +1 -1
  39. package/dist/index.js +8 -6
  40. package/dist/react/index.js +5 -4
  41. package/dist/{sdk-snn5gad3.js → sdk-bepky0xs.js} +5 -4
  42. package/dist/server/index.d.ts +2 -2
  43. package/dist/server/index.d.ts.map +1 -1
  44. package/dist/server/index.js +27 -24
  45. package/dist/server/node-adapter.d.ts +38 -0
  46. package/dist/server/node-adapter.d.ts.map +1 -0
  47. package/dist/server/node-adapter.js +108 -0
  48. package/dist/server/server-shared.d.ts +21 -0
  49. package/dist/server/server-shared.d.ts.map +1 -0
  50. package/dist/server/server.d.ts +19 -2
  51. package/dist/server/server.d.ts.map +1 -1
  52. package/dist/server/tenancy.d.ts +28 -2
  53. package/dist/server/tenancy.d.ts.map +1 -1
  54. package/dist/{server-mrctdwzr.js → server-szdjx0nt.js} +5 -3
  55. package/dist/sqlite-backend-0vsmc6qj.js +8 -0
  56. package/dist/{tenancy-7d1g4ayp.js → tenancy-pjm32b4v.js} +4 -3
  57. package/dist/vcs/blob-store.d.ts +2 -1
  58. package/dist/vcs/blob-store.d.ts.map +1 -1
  59. package/dist/vcs/index.js +2 -2
  60. package/package.json +16 -3
@@ -1,5 +1,25 @@
1
1
  // @bun
2
2
  import"../index-c9h37r6h.js";
3
+ import {
4
+ deploy
5
+ } from "../index-wt8rz4gn.js";
6
+ import {
7
+ getActiveSprite,
8
+ getSprite,
9
+ isSpriteTracked,
10
+ loadVmConfig,
11
+ saveVmConfig,
12
+ setActiveSprite,
13
+ trackSprite,
14
+ untrackSprite
15
+ } from "../index-bmyt7k8n.js";
16
+ import {
17
+ assertSpriteCli,
18
+ resolveSprite,
19
+ runSpriteCmd,
20
+ runSpriteCopy,
21
+ runSpriteInteractive
22
+ } from "../index-y6a4kj0p.js";
3
23
  import {
4
24
  ADMIN_ONLY,
5
25
  ANONYMOUS,
@@ -16,46 +36,29 @@ import {
16
36
  resolveAuth,
17
37
  signJwt,
18
38
  startServer,
39
+ startServerCrossRuntime,
19
40
  verifyJwt
20
- } from "../index-6n5dcebj.js";
41
+ } from "../index-53f3b8p8.js";
21
42
  import {
22
43
  importFile,
23
44
  importRecords
24
45
  } from "../index-skhn0agf.js";
25
- import {
26
- deploy
27
- } from "../index-wt8rz4gn.js";
28
- import {
29
- getActiveSprite,
30
- getSprite,
31
- isSpriteTracked,
32
- loadVmConfig,
33
- saveVmConfig,
34
- setActiveSprite,
35
- trackSprite,
36
- untrackSprite
37
- } from "../index-bmyt7k8n.js";
38
- import {
39
- assertSpriteCli,
40
- resolveSprite,
41
- runSpriteCmd,
42
- runSpriteCopy,
43
- runSpriteInteractive
44
- } from "../index-y6a4kj0p.js";
45
46
  import"../index-n9f2qyh5.js";
46
47
  import"../index-xzym9w0m.js";
47
48
  import {
48
49
  DEFAULT_TENANT,
49
50
  TenantPool
50
- } from "../index-y3d71wzd.js";
51
- import"../index-0zk3fx2s.js";
52
- import"../index-yhwjgfvj.js";
51
+ } from "../index-7pjz3tsy.js";
52
+ import"../index-4wxa8xz4.js";
53
53
  import"../index-yp88he8n.js";
54
+ import"../index-yhwjgfvj.js";
55
+ import"../index-h7zxhhhh.js";
54
56
  import"../index-a76rekgs.js";
55
57
  export {
56
58
  verifyJwt,
57
59
  untrackSprite,
58
60
  trackSprite,
61
+ startServerCrossRuntime,
59
62
  startServer,
60
63
  signJwt,
61
64
  setActiveSprite,
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Node.js HTTP + WebSocket adapter for the Trellis server.
3
+ *
4
+ * Runs the same request handler as the Bun.serve path, but via Node's
5
+ * `node:http` module and the `ws` library. Used when the host runtime is
6
+ * Node (or WebContainer) rather than Bun.
7
+ *
8
+ * Optional dependency: `ws`. Install only if you intend to run Trellis
9
+ * outside of Bun.
10
+ *
11
+ * @module trellis/server
12
+ */
13
+ import type { TrellisHttpServer } from './server-shared.js';
14
+ export interface NodeAdapterOptions {
15
+ port: number;
16
+ hostname?: string;
17
+ /**
18
+ * Fetch-style request handler. Receives a standard `Request`, returns a
19
+ * standard `Response`. The HTTP routing module already produces these.
20
+ */
21
+ fetch: (req: Request) => Promise<Response>;
22
+ /** Hooks invoked for each WebSocket lifecycle event. */
23
+ websocket: {
24
+ open: (ws: WsLike) => void | Promise<void>;
25
+ message: (ws: WsLike, data: string | Buffer) => void | Promise<void>;
26
+ close: (ws: WsLike) => void;
27
+ };
28
+ }
29
+ /**
30
+ * Minimal interface satisfied by both Bun's WebSocket and the `ws` library's
31
+ * WebSocket. The subscription manager only uses `readyState` and `send`.
32
+ */
33
+ export interface WsLike {
34
+ readyState: number;
35
+ send(data: string): void;
36
+ }
37
+ export declare function startNodeServer(opts: NodeAdapterOptions): Promise<TrellisHttpServer>;
38
+ //# sourceMappingURL=node-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-adapter.d.ts","sourceRoot":"","sources":["../../src/server/node-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3C,wDAAwD;IACxD,SAAS,EAAE;QACT,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3C,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACrE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;KAC7B,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,iBAAiB,CAAC,CA6D5B"}
@@ -0,0 +1,108 @@
1
+ // @bun
2
+ import {
3
+ __require
4
+ } from "../index-a76rekgs.js";
5
+
6
+ // src/server/node-adapter.ts
7
+ async function startNodeServer(opts) {
8
+ const http = await import("http");
9
+ let WebSocketServer;
10
+ try {
11
+ ({ WebSocketServer } = await import("ws"));
12
+ } catch {
13
+ throw new Error('Running the Trellis server outside Bun requires the optional dependency "ws". Install it: npm install ws');
14
+ }
15
+ const httpServer = http.createServer(async (req, res) => {
16
+ try {
17
+ const fetchReq = await toFetchRequest(req);
18
+ const fetchRes = await opts.fetch(fetchReq);
19
+ await writeFetchResponse(res, fetchRes);
20
+ } catch (err) {
21
+ const msg = err instanceof Error ? err.message : String(err);
22
+ res.statusCode = 500;
23
+ res.setHeader("Content-Type", "application/json");
24
+ res.end(JSON.stringify({ error: "Internal Server Error", message: msg }));
25
+ }
26
+ });
27
+ const wss = new WebSocketServer({ noServer: true });
28
+ httpServer.on("upgrade", (req, socket, head) => {
29
+ wss.handleUpgrade(req, socket, head, (ws) => {
30
+ wss.emit("connection", ws, req);
31
+ });
32
+ });
33
+ wss.on("connection", (ws) => {
34
+ Promise.resolve(opts.websocket.open(ws)).catch(() => {});
35
+ ws.on("message", (raw) => {
36
+ const data = Array.isArray(raw) ? Buffer.concat(raw).toString() : raw instanceof ArrayBuffer ? Buffer.from(raw).toString() : raw.toString();
37
+ Promise.resolve(opts.websocket.message(ws, data)).catch(() => {});
38
+ });
39
+ ws.on("close", () => opts.websocket.close(ws));
40
+ });
41
+ await new Promise((resolve) => httpServer.listen(opts.port, opts.hostname, resolve));
42
+ const addr = httpServer.address();
43
+ const boundPort = typeof addr === "object" && addr ? addr.port : opts.port;
44
+ const boundHost = typeof addr === "object" && addr ? addr.address : opts.hostname;
45
+ return wrapNodeServer(httpServer, wss, boundPort, boundHost);
46
+ }
47
+ async function toFetchRequest(req) {
48
+ const host = req.headers.host ?? "localhost";
49
+ const protocol = req.socket?.encrypted ? "https" : "http";
50
+ const url = `${protocol}://${host}${req.url ?? "/"}`;
51
+ const method = req.method ?? "GET";
52
+ const headers = new Headers;
53
+ for (const [key, value] of Object.entries(req.headers)) {
54
+ if (Array.isArray(value)) {
55
+ for (const v of value)
56
+ headers.append(key, v);
57
+ } else if (value != null) {
58
+ headers.set(key, value);
59
+ }
60
+ }
61
+ const hasBody = method !== "GET" && method !== "HEAD";
62
+ const body = hasBody ? new Uint8Array(await readBody(req)) : undefined;
63
+ return new Request(url, { method, headers, body });
64
+ }
65
+ function readBody(req) {
66
+ return new Promise((resolve, reject) => {
67
+ const chunks = [];
68
+ req.on("data", (c) => chunks.push(c));
69
+ req.on("end", () => resolve(Buffer.concat(chunks)));
70
+ req.on("error", reject);
71
+ });
72
+ }
73
+ async function writeFetchResponse(res, fetchRes) {
74
+ res.statusCode = fetchRes.status;
75
+ fetchRes.headers.forEach((value, key) => res.setHeader(key, value));
76
+ if (!fetchRes.body) {
77
+ res.end();
78
+ return;
79
+ }
80
+ const reader = fetchRes.body.getReader();
81
+ while (true) {
82
+ const { done, value } = await reader.read();
83
+ if (done)
84
+ break;
85
+ res.write(value);
86
+ }
87
+ res.end();
88
+ }
89
+ function wrapNodeServer(httpServer, wss, port, hostname) {
90
+ return {
91
+ port,
92
+ hostname: hostname ?? "localhost",
93
+ stop(closeActiveConnections) {
94
+ return new Promise((resolve, reject) => {
95
+ if (closeActiveConnections) {
96
+ for (const client of wss.clients)
97
+ client.terminate();
98
+ }
99
+ wss.close(() => {
100
+ httpServer.close((err) => err ? reject(err) : resolve());
101
+ });
102
+ });
103
+ }
104
+ };
105
+ }
106
+ export {
107
+ startNodeServer
108
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Shared runtime-agnostic types for the Trellis HTTP server.
3
+ *
4
+ * @module trellis/server
5
+ */
6
+ /**
7
+ * Minimal interface satisfied by both Bun's server (returned from `Bun.serve`)
8
+ * and the Node http adapter. Use this when you only need the cross-runtime
9
+ * surface — most consumers only call `.stop()`.
10
+ */
11
+ export interface TrellisHttpServer {
12
+ port: number;
13
+ hostname?: string;
14
+ /**
15
+ * Shut down the server. On Bun the returned value may be void; on Node the
16
+ * returned promise resolves once both the HTTP server and the WebSocket
17
+ * server have closed.
18
+ */
19
+ stop(closeActiveConnections?: boolean): void | Promise<void>;
20
+ }
21
+ //# sourceMappingURL=server-shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-shared.d.ts","sourceRoot":"","sources":["../../src/server/server-shared.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,IAAI,CAAC,sBAAsB,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D"}
@@ -28,6 +28,8 @@
28
28
  import type { TrellisDbConfig } from '../client/config.js';
29
29
  import type { TenantPool } from './tenancy.js';
30
30
  import type { PermissionRegistry } from './permissions.js';
31
+ import type { TrellisHttpServer } from './server-shared.js';
32
+ export type { TrellisHttpServer } from './server-shared.js';
31
33
  export interface ServerConfig {
32
34
  port?: number;
33
35
  config: TrellisDbConfig;
@@ -36,8 +38,23 @@ export interface ServerConfig {
36
38
  oauthProviders?: Record<string, import('./auth.js').OAuthProvider>;
37
39
  }
38
40
  /**
39
- * Start the Trellis DB HTTP + WebSocket server.
40
- * Returns the Bun server instance.
41
+ * Start the Trellis DB HTTP + WebSocket server under Bun.
42
+ *
43
+ * For runtime-portable code that may also run under Node or WebContainer,
44
+ * use `startServerCrossRuntime` instead — it dispatches to either Bun.serve
45
+ * or a Node http+ws adapter based on the host runtime.
41
46
  */
42
47
  export declare function startServer(opts: ServerConfig): ReturnType<typeof Bun.serve>;
48
+ /**
49
+ * Runtime-dispatched server boot. Use this when your code might run outside
50
+ * Bun (Node, WebContainer, browser).
51
+ *
52
+ * - Under Bun, this calls `Bun.serve` and returns the Bun server wrapped
53
+ * in a `TrellisHttpServer` interface.
54
+ * - Under Node, uses `node:http` + the `ws` library (optional dependency).
55
+ *
56
+ * Returns a `Promise<TrellisHttpServer>` — the minimal cross-runtime surface
57
+ * with `.port` / `.stop()`.
58
+ */
59
+ export declare function startServerCrossRuntime(opts: ServerConfig): Promise<TrellisHttpServer>;
43
60
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAU/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAQ3D,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,WAAW,EAAE,aAAa,CAAC,CAAC;CACpE;AAMD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,KAAK,CAAC,CAqF5E"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAWH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAU/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAM5D,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,WAAW,EAAE,aAAa,CAAC,CAAC;CACpE;AAMD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,KAAK,CAAC,CAE5E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,iBAAiB,CAAC,CAU5B"}
@@ -9,6 +9,7 @@
9
9
  * @module trellis/server
10
10
  */
11
11
  import { TrellisKernel } from '../core/kernel/trellis-kernel.js';
12
+ import type { CreateKernelBackendOptions } from '../core/persist/factory.js';
12
13
  export declare const DEFAULT_TENANT = "default";
13
14
  /**
14
15
  * A pool of `TrellisKernel` instances keyed by tenant ID.
@@ -17,16 +18,39 @@ export declare const DEFAULT_TENANT = "default";
17
18
  * - Each tenant's data lives in `<dbPath>/tenants/<tenantId>.sqlite`.
18
19
  * - The default tenant lives at `<dbPath>/default.sqlite`.
19
20
  */
21
+ export interface TenantPoolOptions {
22
+ agentId?: string;
23
+ /**
24
+ * Backend selection forwarded to `createKernelBackend`. Only consulted by
25
+ * `preload()` — `get()` always uses the synchronous bun:sqlite backend
26
+ * for back-compat.
27
+ */
28
+ backend?: CreateKernelBackendOptions;
29
+ }
20
30
  export declare class TenantPool {
21
31
  private pool;
22
32
  private dbPath;
23
33
  private agentId;
24
- constructor(dbPath: string, agentId?: string);
34
+ private backendOpts;
35
+ constructor(dbPath: string, agentIdOrOpts?: string | TenantPoolOptions);
25
36
  /**
26
37
  * Get (or create) the kernel for a tenant.
27
38
  * Pass `null` or `undefined` to get the default tenant.
39
+ *
40
+ * Uses the synchronous bun:sqlite backend. To use an async backend
41
+ * (better-sqlite3, sql.js) call `preload(tenantId)` first; subsequent
42
+ * `get()` calls will return the preloaded kernel from the pool.
28
43
  */
29
44
  get(tenantId?: string | null): TrellisKernel;
45
+ /**
46
+ * Pre-create a tenant's kernel using the runtime-selected backend.
47
+ * Required when running with an async-only backend (sql.js / WebContainer
48
+ * / browser). Idempotent — safe to call multiple times.
49
+ *
50
+ * After `preload()`, subsequent `get(tenantId)` returns the same kernel
51
+ * synchronously from the pool.
52
+ */
53
+ preload(tenantId?: string | null): Promise<TrellisKernel>;
30
54
  /**
31
55
  * Check whether a tenant has been initialized (kernel created).
32
56
  */
@@ -47,7 +71,9 @@ export declare class TenantPool {
47
71
  * Return the SQLite file path for a given tenant.
48
72
  */
49
73
  dbFilePath(tenantId?: string | null): string;
50
- private _createKernel;
74
+ private _createKernelSync;
75
+ private _createKernelAsync;
76
+ private _wrapKernel;
51
77
  private _ensureDirs;
52
78
  }
53
79
  //# sourceMappingURL=tenancy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tenancy.d.ts","sourceRoot":"","sources":["../../src/server/tenancy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAOjE,eAAO,MAAM,cAAc,YAAY,CAAC;AAOxC;;;;;;GAMG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,IAAI,CAAyC;IACrD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,MAAM,EAAE,OAAO,SAAe;IAUlD;;;OAGG;IACH,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,aAAa;IAQ5C;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI9B;;OAEG;IACH,aAAa,IAAI,MAAM,EAAE;IAIzB;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAQ7B;;OAEG;IACH,QAAQ,IAAI,IAAI;IAOhB;;OAEG;IACH,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM;IAY5C,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,WAAW;CASpB"}
1
+ {"version":3,"file":"tenancy.d.ts","sourceRoot":"","sources":["../../src/server/tenancy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAGjE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAM7E,eAAO,MAAM,cAAc,YAAY,CAAC;AAOxC;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,0BAA0B,CAAC;CACtC;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,IAAI,CAAyC;IACrD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAyC;gBAG1D,MAAM,EAAE,MAAM,EACd,aAAa,GAAE,MAAM,GAAG,iBAAgC;IAiB1D;;;;;;;OAOG;IACH,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,aAAa;IAQ5C;;;;;;;OAOG;IACG,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC;IAS/D;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI9B;;OAEG;IACH,aAAa,IAAI,MAAM,EAAE;IAIzB;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAQ7B;;OAEG;IACH,QAAQ,IAAI,IAAI;IAOhB;;OAEG;IACH,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM;IAY5C,OAAO,CAAC,iBAAiB;YAMX,kBAAkB;IAShC,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,WAAW;CASpB"}
@@ -1,11 +1,13 @@
1
1
  // @bun
2
2
  import {
3
- startServer
4
- } from "./index-6n5dcebj.js";
3
+ startServer,
4
+ startServerCrossRuntime
5
+ } from "./index-53f3b8p8.js";
5
6
  import"./index-n9f2qyh5.js";
6
- import"./index-yhwjgfvj.js";
7
7
  import"./index-yp88he8n.js";
8
+ import"./index-yhwjgfvj.js";
8
9
  import"./index-a76rekgs.js";
9
10
  export {
11
+ startServerCrossRuntime,
10
12
  startServer
11
13
  };
@@ -0,0 +1,8 @@
1
+ // @bun
2
+ import {
3
+ SqliteKernelBackend
4
+ } from "./index-h7zxhhhh.js";
5
+ import"./index-a76rekgs.js";
6
+ export {
7
+ SqliteKernelBackend
8
+ };
@@ -2,10 +2,11 @@
2
2
  import {
3
3
  DEFAULT_TENANT,
4
4
  TenantPool
5
- } from "./index-y3d71wzd.js";
6
- import"./index-0zk3fx2s.js";
7
- import"./index-yhwjgfvj.js";
5
+ } from "./index-7pjz3tsy.js";
6
+ import"./index-4wxa8xz4.js";
8
7
  import"./index-yp88he8n.js";
8
+ import"./index-yhwjgfvj.js";
9
+ import"./index-h7zxhhhh.js";
9
10
  import"./index-a76rekgs.js";
10
11
  export {
11
12
  TenantPool,
@@ -33,7 +33,8 @@ export declare class BlobStore {
33
33
  */
34
34
  hash(content: Buffer | Uint8Array): Promise<string>;
35
35
  /**
36
- * Compute SHA-256 hash of content (sync, using Bun's CryptoHasher).
36
+ * Compute SHA-256 hash of content (sync).
37
+ * Uses Bun.CryptoHasher when running under Bun, else node:crypto.
37
38
  */
38
39
  hashSync(content: Buffer | Uint8Array): string;
39
40
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"blob-store.d.ts","sourceRoot":"","sources":["../../src/vcs/blob-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAS;gBAEZ,UAAU,EAAE,MAAM;IAO9B;;;OAGG;IACG,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IASxD;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM;IAS7C;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAQhC;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAQzD;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM;IAM9C;;OAEG;IACH,KAAK,IAAI,MAAM;IASf;;OAEG;IACH,SAAS,IAAI,MAAM;IAgBnB,OAAO,CAAC,aAAa;CAKtB"}
1
+ {"version":3,"file":"blob-store.d.ts","sourceRoot":"","sources":["../../src/vcs/blob-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAS;gBAEZ,UAAU,EAAE,MAAM;IAO9B;;;OAGG;IACG,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IASxD;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM;IAS7C;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAQhC;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAQzD;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM;IAW9C;;OAEG;IACH,KAAK,IAAI,MAAM;IASf;;OAEG;IACH,SAAS,IAAI,MAAM;IAgBnB,OAAO,CAAC,aAAa;CAKtB"}
package/dist/vcs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  VcsMiddleware
4
- } from "../index-hmdbnd4n.js";
4
+ } from "../index-hy73j9z8.js";
5
5
  import {
6
6
  BlobStore,
7
7
  addCriterion,
@@ -40,7 +40,7 @@ import {
40
40
  triageIssue,
41
41
  unblockIssue,
42
42
  updateIssue
43
- } from "../index-0q7wbasy.js";
43
+ } from "../index-a2a394zz.js";
44
44
  import {
45
45
  DEFAULT_CONFIG,
46
46
  branchEntityId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trellis",
3
- "version": "3.1.3",
3
+ "version": "3.1.7",
4
4
  "description": "Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -91,6 +91,14 @@
91
91
  "./persist/better-sqlite": {
92
92
  "types": "./dist/persist/better-sqlite-backend.d.ts",
93
93
  "import": "./dist/persist/better-sqlite-backend.js"
94
+ },
95
+ "./persist/sqljs": {
96
+ "types": "./dist/persist/sqljs-backend.d.ts",
97
+ "import": "./dist/persist/sqljs-backend.js"
98
+ },
99
+ "./persist/factory": {
100
+ "types": "./dist/persist/factory.d.ts",
101
+ "import": "./dist/persist/factory.js"
94
102
  }
95
103
  },
96
104
  "files": [
@@ -107,7 +115,7 @@
107
115
  "cli": "bun run src/cli/index.ts",
108
116
  "mcp": "bun run src/mcp/index.ts",
109
117
  "mcp:docs": "bun run src/mcp/docs.ts",
110
- "build": "bun build src/index.ts src/core/index.ts src/vcs/index.ts src/embeddings/index.ts src/links/index.ts src/decisions/index.ts src/server/index.ts src/client/index.ts src/react/index.ts src/db/index.ts src/cli/index.ts src/cms/index.ts --outdir dist --target bun --splitting --format esm --root src --external @xenova/transformers --external @huggingface/transformers --external react && mkdir -p dist/ui && cp src/ui/client.html dist/ui/client.html && tsc -p tsconfig.build.json --emitDeclarationOnly --noEmit false --noEmitOnError false && bun run build:inspector",
118
+ "build": "bun build src/index.ts src/core/index.ts src/vcs/index.ts src/embeddings/index.ts src/links/index.ts src/decisions/index.ts src/server/index.ts src/client/index.ts src/react/index.ts src/db/index.ts src/cli/index.ts src/cms/index.ts src/core/persist/sqljs-backend.ts src/core/persist/factory.ts src/server/node-adapter.ts --outdir dist --target bun --splitting --format esm --root src --external @xenova/transformers --external @huggingface/transformers --external react --external sql.js --external ws && mkdir -p dist/ui && cp src/ui/client.html dist/ui/client.html && tsc -p tsconfig.build.json --emitDeclarationOnly --noEmit false --noEmitOnError false && bun run build:inspector",
111
119
  "build:inspector": "vite build --config vite.inspector.config.ts",
112
120
  "test": "bun test test/core test/cms test/vcs test/git test/p2 test/p3 test/p4 test/p5 test/p6 test/p7 test/engine.test.ts",
113
121
  "test:all": "bun test",
@@ -119,11 +127,14 @@
119
127
  "chalk": "^5.4.1",
120
128
  "commander": "^13.1.0",
121
129
  "opencode-ai": "^1.3.5",
130
+ "turtlecode": "^0.3.22",
122
131
  "zod": "3"
123
132
  },
124
133
  "optionalDependencies": {
125
134
  "@huggingface/transformers": "^3.0.0",
126
- "@xenova/transformers": "^2.17.2"
135
+ "@xenova/transformers": "^2.17.2",
136
+ "sql.js": "^1.14.1",
137
+ "ws": "^8.20.1"
127
138
  },
128
139
  "peerDependencies": {
129
140
  "better-sqlite3": "^11.0.0",
@@ -140,6 +151,8 @@
140
151
  "devDependencies": {
141
152
  "@types/bun": "latest",
142
153
  "@types/react": "^19.1.2",
154
+ "@types/sql.js": "^1.4.11",
155
+ "@types/ws": "^8.18.1",
143
156
  "@vitejs/plugin-vue": "^5.2.3",
144
157
  "react": "^19.1.0",
145
158
  "typescript": "^5",