trellis 3.1.35 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -5
- package/README.md +63 -156
- package/bin/trellis.mjs +2 -75
- package/dist/{better-sqlite-backend-ahx5p0br.js → better-sqlite-backend-2P4F6AOJ.js} +91 -29
- package/dist/boot-middleware-MHLHFCUC.js +9 -0
- package/dist/browser/index.d.ts +18 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +95 -0
- package/dist/{index-53f3b8p8.js → chunk-2W3MHTMG.js} +552 -213
- package/dist/chunk-44FFQKQX.js +142 -0
- package/dist/chunk-4HYPLFJD.js +150 -0
- package/dist/chunk-4XIVMVHC.js +361 -0
- package/dist/{index-yp88he8n.js → chunk-6CTA6MCE.js} +88 -64
- package/dist/chunk-6GEZ6DN5.js +394 -0
- package/dist/chunk-7ZFRVCUE.js +211 -0
- package/dist/chunk-CAG4FULI.js +121 -0
- package/dist/chunk-FF36CQHZ.js +61 -0
- package/dist/{index-h32txmxe.js → chunk-FKQO5A3H.js} +6 -13
- package/dist/{index-nq520y6k.js → chunk-FWRS4CSC.js} +46 -32
- package/dist/chunk-GFZCJ4EH.js +108 -0
- package/dist/chunk-GLM4HGN4.js +55 -0
- package/dist/{index-4cdr7x2x.js → chunk-GU374KWZ.js} +182 -111
- package/dist/chunk-H6JB3PZ3.js +45 -0
- package/dist/chunk-IZX2PLIB.js +1240 -0
- package/dist/chunk-J2TXUFCZ.js +289 -0
- package/dist/chunk-J3WYZO3Q.js +211 -0
- package/dist/{index-xzym9w0m.js → chunk-JA7AIHRK.js} +12 -7
- package/dist/chunk-JHHEXEDM.js +162 -0
- package/dist/chunk-JUEMDWLU.js +233 -0
- package/dist/chunk-KFQGP6VL.js +33 -0
- package/dist/chunk-KIJITUZB.js +419 -0
- package/dist/{index-4wxa8xz4.js → chunk-KQ4A2D2P.js} +162 -23
- package/dist/chunk-KSU2GW22.js +958 -0
- package/dist/{index-rv1p47gp.js → chunk-L5N5PR2S.js} +3015 -2480
- package/dist/{index-h9e2efx4.js → chunk-LNUIGRDZ.js} +71 -55
- package/dist/{index-skhn0agf.js → chunk-MLC5BUYO.js} +19 -20
- package/dist/chunk-MPXUVGT3.js +104 -0
- package/dist/chunk-N6MYZT4O.js +68 -0
- package/dist/chunk-O2AV5WMN.js +48 -0
- package/dist/chunk-PZ4XYZ4J.js +143 -0
- package/dist/chunk-QB5ISE47.js +419 -0
- package/dist/chunk-RSWUFTO2.js +857 -0
- package/dist/chunk-S3XLFZ27.js +1095 -0
- package/dist/{index-w5wccer3.js → chunk-S6GBJ2ZB.js} +28 -12
- package/dist/{index-7pjz3tsy.js → chunk-SGMDTWJJ.js} +57 -15
- package/dist/chunk-SPSPV5BC.js +390 -0
- package/dist/chunk-TCKXSOBP.js +123 -0
- package/dist/chunk-UBGUDMUV.js +59 -0
- package/dist/{index-wt8rz4gn.js → chunk-UQISRW6T.js} +97 -26
- package/dist/chunk-USEINYUL.js +12 -0
- package/dist/{index-bmyt7k8n.js → chunk-UZRUP7QW.js} +12 -4
- package/dist/{index-xhcp6xrn.js → chunk-VBYUTRXX.js} +695 -514
- package/dist/{index-vkpkfwhq.js → chunk-VDAKEOML.js} +234 -194
- package/dist/chunk-WXSWA3MV.js +0 -0
- package/dist/{index-n9f2qyh5.js → chunk-X5FLTRUB.js} +55 -33
- package/dist/{index-h7zxhhhh.js → chunk-XMQ7G77X.js} +46 -38
- package/dist/{index-w7ng765c.js → chunk-YCM7ZYEZ.js} +102 -49
- package/dist/cli/deploy-cli.d.ts +18 -0
- package/dist/cli/deploy-cli.d.ts.map +1 -0
- package/dist/cli/errors.d.ts +6 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/examples.d.ts +23 -0
- package/dist/cli/examples.d.ts.map +1 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2426 -6225
- package/dist/client/index.browser.d.ts +29 -0
- package/dist/client/index.browser.d.ts.map +1 -0
- package/dist/client/index.browser.js +64 -0
- package/dist/client/index.d.ts +6 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +41 -21
- package/dist/client/live.d.ts +67 -0
- package/dist/client/live.d.ts.map +1 -0
- package/dist/client/reactive.d.ts +31 -0
- package/dist/client/reactive.d.ts.map +1 -0
- package/dist/client/sdk.browser.d.ts +104 -0
- package/dist/client/sdk.browser.d.ts.map +1 -0
- package/dist/client/sdk.browser.js +9 -0
- package/dist/client/sdk.d.ts +26 -2
- package/dist/client/sdk.d.ts.map +1 -1
- package/dist/client/sdk.js +9 -0
- package/dist/client/vcs-client.d.ts +129 -0
- package/dist/client/vcs-client.d.ts.map +1 -0
- package/dist/cms/index.js +171 -163
- package/dist/{config-8hczw0rs.js → config-PFTP67TR.js} +8 -9
- package/dist/core/computation/index.d.ts +5 -0
- package/dist/core/computation/index.d.ts.map +1 -0
- package/dist/core/computation/rollup.d.ts +18 -0
- package/dist/core/computation/rollup.d.ts.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +171 -104
- package/dist/core/kernel/boot-middleware.d.ts +10 -0
- package/dist/core/kernel/boot-middleware.d.ts.map +1 -0
- package/dist/core/kernel/logic-middleware.d.ts +7 -1
- package/dist/core/kernel/logic-middleware.d.ts.map +1 -1
- package/dist/core/kernel/trellis-kernel.d.ts.map +1 -1
- package/dist/core/ontology/types.d.ts +5 -0
- package/dist/core/ontology/types.d.ts.map +1 -1
- package/dist/core/persist/better-sqlite-backend.d.ts +9 -2
- package/dist/core/persist/better-sqlite-backend.d.ts.map +1 -1
- package/dist/core/persist/factory.d.ts +6 -7
- package/dist/core/persist/factory.d.ts.map +1 -1
- package/dist/core/persist/factory.js +2 -3
- package/dist/core/persist/sqljs-backend.js +2 -3
- package/dist/db/index.d.ts +4 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +67 -54
- package/dist/db/inspector.js +11 -19
- package/dist/db/trellis.css +1 -1
- package/dist/decisions/index.js +9 -10
- package/dist/deploy-LQ7GUGJ5.js +9 -0
- package/dist/deploy-YNVG5E4E.js +9 -0
- package/dist/deploy-cli-24BCHAXY.js +67 -0
- package/dist/deploy-cli-C35HTITO.js +67 -0
- package/dist/embeddings/auto-embed.d.ts +2 -2
- package/dist/embeddings/auto-embed.d.ts.map +1 -1
- package/dist/embeddings/index.js +20 -22
- package/dist/embeddings/search.d.ts +2 -1
- package/dist/embeddings/search.d.ts.map +1 -1
- package/dist/embeddings/store.d.ts +25 -4
- package/dist/embeddings/store.d.ts.map +1 -1
- package/dist/engine.d.ts +59 -19
- package/dist/engine.d.ts.map +1 -1
- package/dist/import-UZEKXU3B.js +10 -0
- package/dist/index.js +102 -93
- package/dist/launch-explorer-HZ4ZJA4X.js +95 -0
- package/dist/links/index.js +24 -26
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/plugins/agent-memory/index.js +316 -0
- package/dist/plugins/idea-garden/index.js +165 -0
- package/dist/plugins/plan-approval/index.js +579 -0
- package/dist/plugins/proactive-watcher/index.js +194 -0
- package/dist/{index-2r4jxwnb.js → query-XYLTJYSA.js} +14 -15
- package/dist/react/index.js +39 -70
- package/dist/react/realtime.js +11 -0
- package/dist/react/schema-hooks.js +87 -0
- package/dist/realtime/broadcast-channel-transport.d.ts +43 -0
- package/dist/realtime/broadcast-channel-transport.d.ts.map +1 -0
- package/dist/realtime/durable-object-relay-transport.d.ts +96 -0
- package/dist/realtime/durable-object-relay-transport.d.ts.map +1 -0
- package/dist/realtime/index.d.ts +44 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/index.js +40 -0
- package/dist/realtime/memory-hub.d.ts +32 -0
- package/dist/realtime/memory-hub.d.ts.map +1 -0
- package/dist/realtime/persistent-channel.d.ts +105 -0
- package/dist/realtime/persistent-channel.d.ts.map +1 -0
- package/dist/realtime/presence.d.ts +73 -0
- package/dist/realtime/presence.d.ts.map +1 -0
- package/dist/realtime/relay-persistence.d.ts +37 -0
- package/dist/realtime/relay-persistence.d.ts.map +1 -0
- package/dist/realtime/relay-persistence.js +107 -0
- package/dist/realtime/relay-server.d.ts +103 -0
- package/dist/realtime/relay-server.d.ts.map +1 -0
- package/dist/realtime/room.d.ts +98 -0
- package/dist/realtime/room.d.ts.map +1 -0
- package/dist/realtime/text.d.ts +73 -0
- package/dist/realtime/text.d.ts.map +1 -0
- package/dist/realtime/types.d.ts +89 -0
- package/dist/realtime/types.d.ts.map +1 -0
- package/dist/realtime/websocket-relay-transport.d.ts +28 -0
- package/dist/realtime/websocket-relay-transport.d.ts.map +1 -0
- package/dist/realtime.bundle.js +1100 -0
- package/dist/{remote-manager-xvbg4230.js → remote-manager-ODE3T2KR.js} +25 -15
- package/dist/scaffold/seed.d.ts.map +1 -1
- package/dist/scaffold/write.d.ts +1 -1
- package/dist/scaffold/write.d.ts.map +1 -1
- package/dist/schema/define.d.ts +137 -0
- package/dist/schema/define.d.ts.map +1 -0
- package/dist/schema/entity-projection.d.ts +34 -0
- package/dist/schema/entity-projection.d.ts.map +1 -0
- package/dist/schema/eql.d.ts +46 -0
- package/dist/schema/eql.d.ts.map +1 -0
- package/dist/schema/index.d.ts +21 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +46 -0
- package/dist/schema/kernel-resolve.d.ts +21 -0
- package/dist/schema/kernel-resolve.d.ts.map +1 -0
- package/dist/schema/mutations.d.ts +20 -0
- package/dist/schema/mutations.d.ts.map +1 -0
- package/dist/schema/resolve.d.ts +21 -0
- package/dist/schema/resolve.d.ts.map +1 -0
- package/dist/server/deploy-meta.d.ts +25 -0
- package/dist/server/deploy-meta.d.ts.map +1 -0
- package/dist/server/deploy.d.ts +7 -2
- package/dist/server/deploy.d.ts.map +1 -1
- package/dist/server/index.d.ts +7 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +100 -58
- package/dist/server/node-adapter.js +5 -104
- package/dist/server/realtime.d.ts +14 -3
- package/dist/server/realtime.d.ts.map +1 -1
- package/dist/server/server.d.ts +8 -16
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/sprites.d.ts +18 -1
- package/dist/server/sprites.d.ts.map +1 -1
- package/dist/server/tenancy.d.ts +4 -0
- package/dist/server/tenancy.d.ts.map +1 -1
- package/dist/server/usage-meter.d.ts +53 -0
- package/dist/server/usage-meter.d.ts.map +1 -0
- package/dist/server-MB3OPSPI.js +18 -0
- package/dist/server-ZVWGLLRF.js +18 -0
- package/dist/sprites-KQGTGM6W.js +27 -0
- package/dist/{sprites-vc4qbrp1.js → sprites-RU3E4XQN.js} +6 -7
- package/dist/svelte/index.d.ts +17 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +51 -0
- package/dist/svelte/schema-hooks.d.ts +45 -0
- package/dist/svelte/schema-hooks.d.ts.map +1 -0
- package/dist/svelte/schema-hooks.js +71 -0
- package/dist/svelte/stores.d.ts +78 -0
- package/dist/svelte/stores.d.ts.map +1 -0
- package/dist/sync/http-transport.d.ts +3 -3
- package/dist/sync/http-transport.d.ts.map +1 -1
- package/dist/sync/index.d.ts +15 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +617 -0
- package/dist/sync/memory-room.d.ts +37 -0
- package/dist/sync/memory-room.d.ts.map +1 -0
- package/dist/sync/memory-transport.d.ts +3 -3
- package/dist/sync/memory-transport.d.ts.map +1 -1
- package/dist/sync/partykit-room.d.ts +40 -0
- package/dist/sync/partykit-room.d.ts.map +1 -0
- package/dist/sync/partykit-transport.d.ts +84 -0
- package/dist/sync/partykit-transport.d.ts.map +1 -0
- package/dist/sync/room-core.d.ts +53 -0
- package/dist/sync/room-core.d.ts.map +1 -0
- package/dist/sync/sync-engine.d.ts +40 -2
- package/dist/sync/sync-engine.d.ts.map +1 -1
- package/dist/sync/sync-room-server.d.ts +39 -0
- package/dist/sync/sync-room-server.d.ts.map +1 -0
- package/dist/sync/types.d.ts +70 -3
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/vcs-sync-peer.d.ts +63 -0
- package/dist/sync/vcs-sync-peer.d.ts.map +1 -0
- package/dist/sync/ws-transport.d.ts +2 -2
- package/dist/sync/ws-transport.d.ts.map +1 -1
- package/dist/tenancy-NBLLGCNJ.js +14 -0
- package/dist/tenancy-POMWQP6M.js +16 -0
- package/dist/ui/client.html +355 -67
- package/dist/ui/launch-explorer.d.ts +22 -0
- package/dist/ui/launch-explorer.d.ts.map +1 -0
- package/dist/ui/server.d.ts +1 -1
- package/dist/ui/server.d.ts.map +1 -1
- package/dist/vcs/blob-store.d.ts.map +1 -1
- package/dist/vcs/idb-op-log.d.ts +67 -0
- package/dist/vcs/idb-op-log.d.ts.map +1 -0
- package/dist/vcs/index.d.ts +1 -0
- package/dist/vcs/index.d.ts.map +1 -1
- package/dist/vcs/index.js +81 -72
- package/dist/vcs/issue.d.ts +22 -5
- package/dist/vcs/issue.d.ts.map +1 -1
- package/dist/vcs/lane-materialize.d.ts +5 -0
- package/dist/vcs/lane-materialize.d.ts.map +1 -1
- package/dist/vcs/op-log.d.ts +28 -2
- package/dist/vcs/op-log.d.ts.map +1 -1
- package/dist/vcs/ops.d.ts +10 -0
- package/dist/vcs/ops.d.ts.map +1 -1
- package/dist/vcs/types.d.ts +2 -0
- package/dist/vcs/types.d.ts.map +1 -1
- package/dist/{vm-config-6xhsj6b3.js → vm-config-JI4OXKDQ.js} +9 -10
- package/dist/vue/hooks.d.ts +64 -0
- package/dist/vue/hooks.d.ts.map +1 -0
- package/dist/vue/index.d.ts +19 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/index.js +59 -0
- package/dist/vue/schema-hooks.d.ts +41 -0
- package/dist/vue/schema-hooks.d.ts.map +1 -0
- package/dist/vue/schema-hooks.js +64 -0
- package/package.json +130 -17
- package/dist/deploy-999q207z.js +0 -10
- package/dist/engine-y0724kjq.js +0 -8
- package/dist/import-s2b8e0ft.js +0 -11
- package/dist/index-a76rekgs.js +0 -67
- package/dist/index-c9h37r6h.js +0 -1
- package/dist/index-hr9qvv77.js +0 -860
- package/dist/index-k5b0xskw.js +0 -1
- package/dist/index-nzb3am4f.js +0 -80
- package/dist/index-wncptktd.js +0 -292
- package/dist/index-y6a4kj0p.js +0 -43
- package/dist/index-yhwjgfvj.js +0 -342
- package/dist/sdk-bepky0xs.js +0 -16
- package/dist/server-szdjx0nt.js +0 -13
- package/dist/sqlite-backend-0vsmc6qj.js +0 -8
- package/dist/tenancy-pjm32b4v.js +0 -14
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// @bun
|
|
2
1
|
import {
|
|
3
2
|
__require
|
|
4
|
-
} from "./
|
|
3
|
+
} from "./chunk-KFQGP6VL.js";
|
|
5
4
|
|
|
6
5
|
// src/core/persist/sqljs-backend.ts
|
|
7
6
|
var SCHEMA_SQL = `
|
|
@@ -29,20 +28,23 @@ CREATE INDEX IF NOT EXISTS idx_ops_agent ON ops(agent_id);
|
|
|
29
28
|
CREATE INDEX IF NOT EXISTS idx_ops_previous ON ops(previous_hash);
|
|
30
29
|
CREATE INDEX IF NOT EXISTS idx_snapshots_op ON snapshots(last_op_hash);
|
|
31
30
|
`;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
var SqlJsKernelBackend = class _SqlJsKernelBackend {
|
|
32
|
+
constructor(opts) {
|
|
33
|
+
this.opts = opts;
|
|
34
|
+
this.flushEvery = opts.autoFlushEvery ?? 50;
|
|
35
|
+
}
|
|
35
36
|
db;
|
|
36
37
|
stmts;
|
|
37
38
|
writes = 0;
|
|
38
39
|
flushEvery;
|
|
39
40
|
initialized = false;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Async factory — sql.js WASM init is async, but the resulting backend
|
|
43
|
+
* exposes the synchronous KernelBackend surface, so it slots into the
|
|
44
|
+
* existing kernel without interface changes.
|
|
45
|
+
*/
|
|
44
46
|
static async create(opts) {
|
|
45
|
-
const backend = new
|
|
47
|
+
const backend = new _SqlJsKernelBackend(opts);
|
|
46
48
|
await backend.bootstrap();
|
|
47
49
|
return backend;
|
|
48
50
|
}
|
|
@@ -52,7 +54,9 @@ class SqlJsKernelBackend {
|
|
|
52
54
|
const mod = await import("sql.js");
|
|
53
55
|
initSqlJs = mod.default ?? mod;
|
|
54
56
|
} catch (e) {
|
|
55
|
-
throw new Error(
|
|
57
|
+
throw new Error(
|
|
58
|
+
'SqlJsKernelBackend requires the optional dependency "sql.js". Install it: npm install sql.js'
|
|
59
|
+
);
|
|
56
60
|
}
|
|
57
61
|
let sqljsDistDir = null;
|
|
58
62
|
if (typeof window === "undefined") {
|
|
@@ -68,31 +72,26 @@ class SqlJsKernelBackend {
|
|
|
68
72
|
}
|
|
69
73
|
const SQL = await initSqlJs({
|
|
70
74
|
locateFile: (file) => {
|
|
71
|
-
if (typeof window !== "undefined")
|
|
72
|
-
|
|
73
|
-
if (sqljsDistDir)
|
|
74
|
-
return `${sqljsDistDir}/${file}`;
|
|
75
|
+
if (typeof window !== "undefined") return `/sql-wasm/${file}`;
|
|
76
|
+
if (sqljsDistDir) return `${sqljsDistDir}/${file}`;
|
|
75
77
|
return file;
|
|
76
78
|
}
|
|
77
79
|
});
|
|
78
80
|
const existing = this.loadFromDisk();
|
|
79
|
-
this.db = existing ? new SQL.Database(existing) : new SQL.Database;
|
|
81
|
+
this.db = existing ? new SQL.Database(existing) : new SQL.Database();
|
|
80
82
|
}
|
|
81
83
|
loadFromDisk() {
|
|
82
|
-
if (this.opts.dbPath === ":memory:")
|
|
83
|
-
return null;
|
|
84
|
+
if (this.opts.dbPath === ":memory:") return null;
|
|
84
85
|
try {
|
|
85
86
|
const fs = __require("fs");
|
|
86
|
-
if (!fs.existsSync(this.opts.dbPath))
|
|
87
|
-
return null;
|
|
87
|
+
if (!fs.existsSync(this.opts.dbPath)) return null;
|
|
88
88
|
return new Uint8Array(fs.readFileSync(this.opts.dbPath));
|
|
89
89
|
} catch {
|
|
90
90
|
return null;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
flushToDisk() {
|
|
94
|
-
if (this.opts.dbPath === ":memory:")
|
|
95
|
-
return;
|
|
94
|
+
if (this.opts.dbPath === ":memory:") return;
|
|
96
95
|
try {
|
|
97
96
|
const fs = __require("fs");
|
|
98
97
|
const path = __require("path");
|
|
@@ -101,34 +100,50 @@ class SqlJsKernelBackend {
|
|
|
101
100
|
const tmp = `${this.opts.dbPath}.tmp`;
|
|
102
101
|
fs.writeFileSync(tmp, Buffer.from(data));
|
|
103
102
|
fs.renameSync(tmp, this.opts.dbPath);
|
|
104
|
-
} catch {
|
|
103
|
+
} catch {
|
|
104
|
+
}
|
|
105
105
|
}
|
|
106
106
|
init() {
|
|
107
|
-
if (this.initialized)
|
|
108
|
-
return;
|
|
107
|
+
if (this.initialized) return;
|
|
109
108
|
this.db.exec(SCHEMA_SQL);
|
|
110
109
|
this.prepareStatements();
|
|
111
110
|
this.initialized = true;
|
|
112
111
|
}
|
|
113
112
|
prepareStatements() {
|
|
114
113
|
this.stmts = {
|
|
115
|
-
insert: this.db.prepare(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
insert: this.db.prepare(
|
|
115
|
+
`INSERT OR IGNORE INTO ops (hash, kind, timestamp, agent_id, previous_hash, payload)
|
|
116
|
+
VALUES ($hash, $kind, $timestamp, $agentId, $previousHash, $payload)`
|
|
117
|
+
),
|
|
118
|
+
readAll: this.db.prepare(
|
|
119
|
+
`SELECT hash, kind, timestamp, agent_id, previous_hash, payload
|
|
120
|
+
FROM ops ORDER BY rowid ASC`
|
|
121
|
+
),
|
|
122
|
+
readUntil: this.db.prepare(
|
|
123
|
+
`SELECT hash, kind, timestamp, agent_id, previous_hash, payload
|
|
120
124
|
FROM ops WHERE rowid <= (SELECT rowid FROM ops WHERE hash = $hash)
|
|
121
|
-
ORDER BY rowid ASC`
|
|
122
|
-
|
|
125
|
+
ORDER BY rowid ASC`
|
|
126
|
+
),
|
|
127
|
+
readAfter: this.db.prepare(
|
|
128
|
+
`SELECT hash, kind, timestamp, agent_id, previous_hash, payload
|
|
123
129
|
FROM ops WHERE rowid > (SELECT rowid FROM ops WHERE hash = $hash)
|
|
124
|
-
ORDER BY rowid ASC`
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
FROM ops
|
|
130
|
+
ORDER BY rowid ASC`
|
|
131
|
+
),
|
|
132
|
+
getByHash: this.db.prepare(
|
|
133
|
+
`SELECT hash, kind, timestamp, agent_id, previous_hash, payload
|
|
134
|
+
FROM ops WHERE hash = $hash`
|
|
135
|
+
),
|
|
136
|
+
getLast: this.db.prepare(
|
|
137
|
+
`SELECT hash, kind, timestamp, agent_id, previous_hash, payload
|
|
138
|
+
FROM ops ORDER BY rowid DESC LIMIT 1`
|
|
139
|
+
),
|
|
129
140
|
count: this.db.prepare(`SELECT COUNT(*) AS cnt FROM ops`),
|
|
130
|
-
saveSnapshot: this.db.prepare(
|
|
131
|
-
|
|
141
|
+
saveSnapshot: this.db.prepare(
|
|
142
|
+
`INSERT INTO snapshots (last_op_hash, data) VALUES ($lastOpHash, $data)`
|
|
143
|
+
),
|
|
144
|
+
loadSnapshot: this.db.prepare(
|
|
145
|
+
`SELECT last_op_hash, data FROM snapshots ORDER BY id DESC LIMIT 1`
|
|
146
|
+
)
|
|
132
147
|
};
|
|
133
148
|
}
|
|
134
149
|
append(op) {
|
|
@@ -161,8 +176,10 @@ class SqlJsKernelBackend {
|
|
|
161
176
|
return this.runAll(this.stmts.readAfter, { $hash: hash });
|
|
162
177
|
}
|
|
163
178
|
readUntilTimestamp(iso) {
|
|
164
|
-
const stmt = this.db.prepare(
|
|
165
|
-
|
|
179
|
+
const stmt = this.db.prepare(
|
|
180
|
+
`SELECT hash, kind, timestamp, agent_id, previous_hash, payload
|
|
181
|
+
FROM ops WHERE timestamp <= $ts ORDER BY rowid ASC`
|
|
182
|
+
);
|
|
166
183
|
const rows = this.runAll(stmt, { $ts: iso });
|
|
167
184
|
stmt.free();
|
|
168
185
|
return rows;
|
|
@@ -193,7 +210,7 @@ class SqlJsKernelBackend {
|
|
|
193
210
|
const has = this.stmts.loadSnapshot.step();
|
|
194
211
|
if (!has) {
|
|
195
212
|
this.stmts.loadSnapshot.reset();
|
|
196
|
-
return;
|
|
213
|
+
return void 0;
|
|
197
214
|
}
|
|
198
215
|
const row = this.stmts.loadSnapshot.getAsObject();
|
|
199
216
|
this.stmts.loadSnapshot.reset();
|
|
@@ -203,36 +220,33 @@ class SqlJsKernelBackend {
|
|
|
203
220
|
try {
|
|
204
221
|
this.flushToDisk();
|
|
205
222
|
} finally {
|
|
206
|
-
for (const s of Object.values(this.stmts ?? {}))
|
|
207
|
-
s?.free?.();
|
|
223
|
+
for (const s of Object.values(this.stmts ?? {})) s?.free?.();
|
|
208
224
|
this.db?.close?.();
|
|
209
225
|
}
|
|
210
226
|
}
|
|
227
|
+
/** Force a write of the in-memory DB image to disk. */
|
|
211
228
|
flush() {
|
|
212
229
|
this.flushToDisk();
|
|
213
230
|
}
|
|
214
231
|
runAll(stmt, params = {}) {
|
|
215
232
|
stmt.bind(params);
|
|
216
233
|
const rows = [];
|
|
217
|
-
while (stmt.step())
|
|
218
|
-
rows.push(rowToOp(stmt.getAsObject()));
|
|
234
|
+
while (stmt.step()) rows.push(rowToOp(stmt.getAsObject()));
|
|
219
235
|
stmt.reset();
|
|
220
236
|
return rows;
|
|
221
237
|
}
|
|
222
238
|
runOne(stmt, params = {}) {
|
|
223
239
|
stmt.bind(params);
|
|
224
240
|
const has = stmt.step();
|
|
225
|
-
const row = has ? stmt.getAsObject() :
|
|
241
|
+
const row = has ? stmt.getAsObject() : void 0;
|
|
226
242
|
stmt.reset();
|
|
227
|
-
return row ? rowToOp(row) :
|
|
243
|
+
return row ? rowToOp(row) : void 0;
|
|
228
244
|
}
|
|
229
245
|
tickFlush() {
|
|
230
|
-
if (this.flushEvery === 0)
|
|
231
|
-
|
|
232
|
-
if (++this.writes % this.flushEvery === 0)
|
|
233
|
-
this.flushToDisk();
|
|
246
|
+
if (this.flushEvery === 0) return;
|
|
247
|
+
if (++this.writes % this.flushEvery === 0) this.flushToDisk();
|
|
234
248
|
}
|
|
235
|
-
}
|
|
249
|
+
};
|
|
236
250
|
function rowToOp(row) {
|
|
237
251
|
const payload = JSON.parse(row.payload);
|
|
238
252
|
return {
|
|
@@ -240,7 +254,7 @@ function rowToOp(row) {
|
|
|
240
254
|
kind: row.kind,
|
|
241
255
|
timestamp: row.timestamp,
|
|
242
256
|
agentId: row.agent_id,
|
|
243
|
-
previousHash: row.previous_hash ??
|
|
257
|
+
previousHash: row.previous_hash ?? void 0,
|
|
244
258
|
facts: payload.facts,
|
|
245
259
|
links: payload.links,
|
|
246
260
|
deleteFacts: payload.deleteFacts,
|
|
@@ -248,4 +262,6 @@ function rowToOp(row) {
|
|
|
248
262
|
};
|
|
249
263
|
}
|
|
250
264
|
|
|
251
|
-
export {
|
|
265
|
+
export {
|
|
266
|
+
SqlJsKernelBackend
|
|
267
|
+
};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
// @bun
|
|
2
1
|
import {
|
|
3
2
|
init_eav_store,
|
|
4
3
|
jsonEntityFacts
|
|
5
|
-
} from "./
|
|
6
|
-
import {
|
|
7
|
-
__require
|
|
8
|
-
} from "./index-a76rekgs.js";
|
|
4
|
+
} from "./chunk-4XIVMVHC.js";
|
|
9
5
|
|
|
10
6
|
// src/server/import.ts
|
|
11
7
|
init_eav_store();
|
|
@@ -25,7 +21,9 @@ async function importFile(kernel, filePath, opts) {
|
|
|
25
21
|
case ".parquet":
|
|
26
22
|
return importParquet(kernel, filePath, opts);
|
|
27
23
|
default:
|
|
28
|
-
throw new Error(
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Unsupported file format: ${ext}. Supported: .json, .ndjson, .jsonl, .csv, .tsv, .parquet`
|
|
26
|
+
);
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
29
|
async function importRecords(kernel, records, opts) {
|
|
@@ -39,8 +37,7 @@ async function importJson(kernel, filePath, opts) {
|
|
|
39
37
|
}
|
|
40
38
|
async function importNdjson(kernel, filePath, opts) {
|
|
41
39
|
const raw = readFileSync(filePath, "utf8");
|
|
42
|
-
const rows = raw.split(
|
|
43
|
-
`).map((l) => l.trim()).filter(Boolean).map((line, i) => {
|
|
40
|
+
const rows = raw.split("\n").map((l) => l.trim()).filter(Boolean).map((line, i) => {
|
|
44
41
|
try {
|
|
45
42
|
return JSON.parse(line);
|
|
46
43
|
} catch {
|
|
@@ -51,20 +48,18 @@ async function importNdjson(kernel, filePath, opts) {
|
|
|
51
48
|
}
|
|
52
49
|
async function importCsv(kernel, filePath, opts) {
|
|
53
50
|
const raw = readFileSync(filePath, "utf8");
|
|
54
|
-
const sep = filePath.endsWith(".tsv") ? "
|
|
51
|
+
const sep = filePath.endsWith(".tsv") ? " " : ",";
|
|
55
52
|
const rows = parseCsv(raw, sep);
|
|
56
53
|
return _ingestRows(kernel, rows, opts);
|
|
57
54
|
}
|
|
58
55
|
function parseCsv(raw, sep = ",") {
|
|
59
56
|
const lines = raw.split(/\r?\n/);
|
|
60
|
-
if (lines.length < 2)
|
|
61
|
-
return [];
|
|
57
|
+
if (lines.length < 2) return [];
|
|
62
58
|
const headers = splitCsvLine(lines[0], sep);
|
|
63
59
|
const result = [];
|
|
64
|
-
for (let i = 1;i < lines.length; i++) {
|
|
60
|
+
for (let i = 1; i < lines.length; i++) {
|
|
65
61
|
const line = lines[i];
|
|
66
|
-
if (!line || line.trim() === "")
|
|
67
|
-
continue;
|
|
62
|
+
if (!line || line.trim() === "") continue;
|
|
68
63
|
const values = splitCsvLine(line, sep);
|
|
69
64
|
const row = {};
|
|
70
65
|
headers.forEach((h, idx) => {
|
|
@@ -78,7 +73,7 @@ function splitCsvLine(line, sep) {
|
|
|
78
73
|
const result = [];
|
|
79
74
|
let current = "";
|
|
80
75
|
let inQuotes = false;
|
|
81
|
-
for (let i = 0;i < line.length; i++) {
|
|
76
|
+
for (let i = 0; i < line.length; i++) {
|
|
82
77
|
const ch = line[i];
|
|
83
78
|
if (ch === '"') {
|
|
84
79
|
if (inQuotes && line[i + 1] === '"') {
|
|
@@ -105,7 +100,9 @@ async function importParquet(kernel, filePath, opts) {
|
|
|
105
100
|
try {
|
|
106
101
|
parquet = await import("@dsnp/parquetjs");
|
|
107
102
|
} catch {
|
|
108
|
-
throw new Error(
|
|
103
|
+
throw new Error(
|
|
104
|
+
"Parquet support requires `parquetjs` or `@dsnp/parquetjs`.\nRun: bun add parquetjs"
|
|
105
|
+
);
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
108
|
const reader = await parquet.ParquetReader.openFile(filePath);
|
|
@@ -127,9 +124,8 @@ async function _ingestRows(kernel, rows, opts) {
|
|
|
127
124
|
};
|
|
128
125
|
const limit = opts.limit ?? Infinity;
|
|
129
126
|
let count = 0;
|
|
130
|
-
for (let i = 0;i < rows.length; i++) {
|
|
131
|
-
if (count >= limit)
|
|
132
|
-
break;
|
|
127
|
+
for (let i = 0; i < rows.length; i++) {
|
|
128
|
+
if (count >= limit) break;
|
|
133
129
|
const row = rows[i];
|
|
134
130
|
if (!row || opts.skipEmpty && Object.keys(row).length === 0) {
|
|
135
131
|
result.skipped++;
|
|
@@ -152,4 +148,7 @@ async function _ingestRows(kernel, rows, opts) {
|
|
|
152
148
|
return result;
|
|
153
149
|
}
|
|
154
150
|
|
|
155
|
-
export {
|
|
151
|
+
export {
|
|
152
|
+
importFile,
|
|
153
|
+
importRecords
|
|
154
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// src/vcs/idb-op-log.ts
|
|
2
|
+
var IdbOpLog = class {
|
|
3
|
+
ops = [];
|
|
4
|
+
hashes = /* @__PURE__ */ new Set();
|
|
5
|
+
db = null;
|
|
6
|
+
nextSeq = 0;
|
|
7
|
+
pendingWrites = Promise.resolve();
|
|
8
|
+
dbName;
|
|
9
|
+
storeName;
|
|
10
|
+
factory;
|
|
11
|
+
constructor(opts) {
|
|
12
|
+
this.dbName = opts.dbName;
|
|
13
|
+
this.storeName = opts.storeName ?? "ops";
|
|
14
|
+
const factory = opts.indexedDB ?? globalThis.indexedDB;
|
|
15
|
+
if (!factory) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
"IdbOpLog requires IndexedDB. Pass `indexedDB` in options for non-browser hosts."
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
this.factory = factory;
|
|
21
|
+
}
|
|
22
|
+
async load() {
|
|
23
|
+
this.db = await this.openDb();
|
|
24
|
+
const records = await this.readAllRecords();
|
|
25
|
+
records.sort((a, b) => a.seq - b.seq);
|
|
26
|
+
this.ops = records.map((r) => r.op);
|
|
27
|
+
this.hashes = new Set(this.ops.map((op) => op.hash));
|
|
28
|
+
this.nextSeq = records.length > 0 ? records[records.length - 1].seq + 1 : 0;
|
|
29
|
+
}
|
|
30
|
+
append(op) {
|
|
31
|
+
if (this.hashes.has(op.hash)) return;
|
|
32
|
+
if (!this.db) {
|
|
33
|
+
throw new Error("IdbOpLog.append() called before load(). Await load() first.");
|
|
34
|
+
}
|
|
35
|
+
this.ops.push(op);
|
|
36
|
+
this.hashes.add(op.hash);
|
|
37
|
+
const seq = this.nextSeq++;
|
|
38
|
+
const record = { hash: op.hash, seq, op };
|
|
39
|
+
this.pendingWrites = this.pendingWrites.then(() => this.putRecord(record));
|
|
40
|
+
}
|
|
41
|
+
readAll() {
|
|
42
|
+
return [...this.ops];
|
|
43
|
+
}
|
|
44
|
+
getLastOp() {
|
|
45
|
+
return this.ops.length > 0 ? this.ops[this.ops.length - 1] : void 0;
|
|
46
|
+
}
|
|
47
|
+
count() {
|
|
48
|
+
return this.ops.length;
|
|
49
|
+
}
|
|
50
|
+
async flush() {
|
|
51
|
+
await this.pendingWrites;
|
|
52
|
+
}
|
|
53
|
+
async close() {
|
|
54
|
+
await this.flush();
|
|
55
|
+
this.db?.close();
|
|
56
|
+
this.db = null;
|
|
57
|
+
}
|
|
58
|
+
// --- private ---------------------------------------------------------------
|
|
59
|
+
openDb() {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
const request = this.factory.open(this.dbName, 1);
|
|
62
|
+
request.onupgradeneeded = () => {
|
|
63
|
+
const db = request.result;
|
|
64
|
+
if (!db.objectStoreNames.contains(this.storeName)) {
|
|
65
|
+
const store = db.createObjectStore(this.storeName, { keyPath: "hash" });
|
|
66
|
+
store.createIndex("seq", "seq", { unique: true });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
request.onsuccess = () => resolve(request.result);
|
|
70
|
+
request.onerror = () => reject(request.error ?? new Error("IndexedDB open failed."));
|
|
71
|
+
request.onblocked = () => reject(new Error(`IDB open blocked for database '${this.dbName}'.`));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
readAllRecords() {
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
if (!this.db) {
|
|
77
|
+
reject(new Error("IdbOpLog: database not open."));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const tx = this.db.transaction(this.storeName, "readonly");
|
|
81
|
+
const store = tx.objectStore(this.storeName);
|
|
82
|
+
const request = store.getAll();
|
|
83
|
+
request.onsuccess = () => resolve(request.result ?? []);
|
|
84
|
+
request.onerror = () => reject(request.error ?? new Error("IdbOpLog.getAll() failed."));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
putRecord(record) {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
if (!this.db) {
|
|
90
|
+
reject(new Error("IdbOpLog: database not open."));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const tx = this.db.transaction(this.storeName, "readwrite");
|
|
94
|
+
const store = tx.objectStore(this.storeName);
|
|
95
|
+
const request = store.put(record);
|
|
96
|
+
request.onsuccess = () => resolve();
|
|
97
|
+
request.onerror = () => reject(request.error ?? new Error("IdbOpLog.put() failed."));
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
IdbOpLog
|
|
104
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__esm
|
|
3
|
+
} from "./chunk-KFQGP6VL.js";
|
|
4
|
+
|
|
5
|
+
// src/vcs/types.ts
|
|
6
|
+
function fileEntityId(path) {
|
|
7
|
+
return `file:${path}`;
|
|
8
|
+
}
|
|
9
|
+
function dirEntityId(path) {
|
|
10
|
+
return `dir:${path}`;
|
|
11
|
+
}
|
|
12
|
+
function branchEntityId(name) {
|
|
13
|
+
return `branch:${name}`;
|
|
14
|
+
}
|
|
15
|
+
function milestoneEntityId(hash) {
|
|
16
|
+
return `milestone:${hash}`;
|
|
17
|
+
}
|
|
18
|
+
function checkpointEntityId(hash) {
|
|
19
|
+
return `checkpoint:${hash}`;
|
|
20
|
+
}
|
|
21
|
+
function issueEntityId(id) {
|
|
22
|
+
return id.startsWith("issue:") ? id : `issue:${id}`;
|
|
23
|
+
}
|
|
24
|
+
function criterionEntityId(issueId, index) {
|
|
25
|
+
const bare = issueId.replace(/^issue:/, "");
|
|
26
|
+
return `criterion:${bare}:ac-${index}`;
|
|
27
|
+
}
|
|
28
|
+
function decisionEntityId(id) {
|
|
29
|
+
return id.startsWith("decision:") ? id : `decision:${id}`;
|
|
30
|
+
}
|
|
31
|
+
function laneEntityId(id) {
|
|
32
|
+
return id.startsWith("lane:") ? id : `lane:${id}`;
|
|
33
|
+
}
|
|
34
|
+
var DEFAULT_CONFIG;
|
|
35
|
+
var init_types = __esm({
|
|
36
|
+
"src/vcs/types.ts"() {
|
|
37
|
+
"use strict";
|
|
38
|
+
DEFAULT_CONFIG = {
|
|
39
|
+
ignorePatterns: [
|
|
40
|
+
"node_modules",
|
|
41
|
+
".git",
|
|
42
|
+
".trellis",
|
|
43
|
+
"dist",
|
|
44
|
+
"build",
|
|
45
|
+
".DS_Store",
|
|
46
|
+
"*.log"
|
|
47
|
+
],
|
|
48
|
+
debounceMs: 300,
|
|
49
|
+
defaultBranch: "main",
|
|
50
|
+
dbPath: ".trellis/trellis.db",
|
|
51
|
+
indexWorkspace: true
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
fileEntityId,
|
|
58
|
+
dirEntityId,
|
|
59
|
+
branchEntityId,
|
|
60
|
+
milestoneEntityId,
|
|
61
|
+
checkpointEntityId,
|
|
62
|
+
issueEntityId,
|
|
63
|
+
criterionEntityId,
|
|
64
|
+
decisionEntityId,
|
|
65
|
+
laneEntityId,
|
|
66
|
+
DEFAULT_CONFIG,
|
|
67
|
+
init_types
|
|
68
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/react/realtime.ts
|
|
2
|
+
import { useEffect, useState, useSyncExternalStore } from "react";
|
|
3
|
+
function useSignal(signal) {
|
|
4
|
+
return useSyncExternalStore(
|
|
5
|
+
(onStoreChange) => signal.subscribe(() => onStoreChange()),
|
|
6
|
+
() => signal.peek(),
|
|
7
|
+
() => signal.peek()
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
function useRoom(create, deps = []) {
|
|
11
|
+
const [room, setRoom] = useState(null);
|
|
12
|
+
const [presence, setPresence] = useState([]);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const r = create();
|
|
15
|
+
setRoom(r);
|
|
16
|
+
const unsub = r.presenceSignal.subscribe(setPresence);
|
|
17
|
+
return () => {
|
|
18
|
+
unsub();
|
|
19
|
+
r.leave();
|
|
20
|
+
setRoom(null);
|
|
21
|
+
setPresence([]);
|
|
22
|
+
};
|
|
23
|
+
}, deps);
|
|
24
|
+
return {
|
|
25
|
+
room,
|
|
26
|
+
presence,
|
|
27
|
+
others: presence.filter((p) => !p.self)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function usePresence(room) {
|
|
31
|
+
const [presence, setPresence] = useState(
|
|
32
|
+
() => room?.getPresence() ?? []
|
|
33
|
+
);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!room) {
|
|
36
|
+
setPresence([]);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
return room.presenceSignal.subscribe(setPresence);
|
|
40
|
+
}, [room]);
|
|
41
|
+
return presence;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
useSignal,
|
|
46
|
+
useRoom,
|
|
47
|
+
usePresence
|
|
48
|
+
};
|