@omgbase/sync 0.3.0 → 0.4.0
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.
|
@@ -32,7 +32,8 @@ export declare class Coordinator {
|
|
|
32
32
|
syncOut(cursor?: number): Promise<SyncOutSummary>;
|
|
33
33
|
/**
|
|
34
34
|
* Live source→engine sync: subscribe to the source's change batches and
|
|
35
|
-
* reconcile each. Returns the subscription (
|
|
35
|
+
* reconcile each. Returns the subscription (`.ready` resolves once the source
|
|
36
|
+
* reported its feed primed — spec/sync §5; call `.stop()`), or null if the
|
|
36
37
|
* source cannot watch. Reconcile runs off the batch callback; `onSummary`
|
|
37
38
|
* observes each batch's result, `onError` any failure.
|
|
38
39
|
*/
|
package/dist/src/coordinator.js
CHANGED
|
@@ -80,15 +80,18 @@ export class Coordinator {
|
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Live source→engine sync: subscribe to the source's change batches and
|
|
83
|
-
* reconcile each. Returns the subscription (
|
|
83
|
+
* reconcile each. Returns the subscription (`.ready` resolves once the source
|
|
84
|
+
* reported its feed primed — spec/sync §5; call `.stop()`), or null if the
|
|
84
85
|
* source cannot watch. Reconcile runs off the batch callback; `onSummary`
|
|
85
86
|
* observes each batch's result, `onError` any failure.
|
|
86
87
|
*/
|
|
87
88
|
async watchIn(handlers = {}) {
|
|
88
89
|
if (!this.source.watch)
|
|
89
90
|
return null;
|
|
90
|
-
return this.source.watch((
|
|
91
|
-
|
|
91
|
+
return this.source.watch((ev) => {
|
|
92
|
+
if (ev.event !== "batch")
|
|
93
|
+
return;
|
|
94
|
+
this.reconcile(ev.paths).then((s) => handlers.onSummary?.(s), (err) => handlers.onError?.(err));
|
|
92
95
|
});
|
|
93
96
|
}
|
|
94
97
|
}
|
package/dist/src/mirror.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { fsAdapterBinPath } from "@omgbase/fs-adapter";
|
|
1
|
+
import { createExternalSource, awaitReady, WATCH_READY_PATIENCE_MS } from "@omgbase/core";
|
|
2
|
+
import { fsAdapterLaunch } from "@omgbase/fs-adapter";
|
|
4
3
|
import { connectEngine } from "./mcp-engine-client.js";
|
|
5
4
|
import { Coordinator } from "./coordinator.js";
|
|
6
5
|
/**
|
|
@@ -14,7 +13,10 @@ export async function runFsMirror(opts) {
|
|
|
14
13
|
? { kind: "stdio", command: opts.server[0], args: opts.server.slice(1) }
|
|
15
14
|
: opts.server;
|
|
16
15
|
const engine = await connectEngine(spec);
|
|
17
|
-
|
|
16
|
+
// The built-in fs adapter, launched per spec/sync §5 (1.2): `$OMGBASE_FS_ADAPTER`
|
|
17
|
+
// when set, else the bundled bin under the running node; no registry here, so
|
|
18
|
+
// no fixed args — just the rendered `--root`.
|
|
19
|
+
const source = await createExternalSource(fsAdapterLaunch([], ["--root", opts.root]));
|
|
18
20
|
const coord = new Coordinator(engine, source);
|
|
19
21
|
const shutdown = async () => {
|
|
20
22
|
try {
|
|
@@ -41,6 +43,9 @@ export async function runFsMirror(opts) {
|
|
|
41
43
|
await shutdown();
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
46
|
+
// spec/sync §5: report live only once the feed is primed (bounded patience).
|
|
47
|
+
if (!(await awaitReady(sub.ready, WATCH_READY_PATIENCE_MS)))
|
|
48
|
+
log(`the fs adapter did not report ready within ${WATCH_READY_PATIENCE_MS / 1000}s — proceeding as if ready`);
|
|
44
49
|
log("watching — Ctrl-C to stop");
|
|
45
50
|
await new Promise((resolve) => {
|
|
46
51
|
const stop = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omgbase/sync",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Open Markdown Graph Base — standalone store-to-store synchronizer: a coordinator over an EngineClient seam (in-process or MCP-client) and source adapters",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
56
|
-
"@omgbase/core": "^0.
|
|
57
|
-
"@omgbase/fs-adapter": "^0.
|
|
56
|
+
"@omgbase/core": "^0.4.0",
|
|
57
|
+
"@omgbase/fs-adapter": "^0.2.0"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "tsc -p tsconfig.json",
|