@omgbase/sync 0.6.0 → 0.6.1

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.
@@ -65,9 +65,10 @@ export class Coordinator {
65
65
  if (digest.origin === "observed")
66
66
  continue; // came from a source; don't echo back
67
67
  for (const rev of digest.revisions) {
68
- // `changes_since` reports the reference form (`path`, spec/surface
69
- // §1.2); the source takes storage paths.
70
- const path = storagePath(rev.path);
68
+ // `changes_since` reports a revision under the row's engine names
69
+ // (`_id`, `_path`, `_hash` — spec/surface §1.2, 5.0) in the
70
+ // reference form; the source takes storage paths.
71
+ const path = storagePath(rev._path);
71
72
  const doc = await this.engine.readDoc(path);
72
73
  if (doc) {
73
74
  await this.source.write(path, doc.content);
@@ -8,7 +8,7 @@ export interface ChangesPage {
8
8
  }
9
9
  export interface DocBytes {
10
10
  content: string;
11
- /** hex of the doc's current rendered/file hash (matches a changes_since revision's `hash`). */
11
+ /** hex of the doc's current rendered/file hash (matches a changes_since revision's `_hash`). */
12
12
  contentHash: string;
13
13
  }
14
14
  export interface EngineClient {
@@ -30,7 +30,7 @@ export class InProcessEngineClient {
30
30
  const res = docsRead(this.store, row.doc_id);
31
31
  if (!res)
32
32
  return Promise.resolve(null);
33
- return Promise.resolve({ content: res.raw, contentHash: row.file_hash?.toString("hex") ?? "" });
33
+ return Promise.resolve({ content: res._raw, contentHash: row.file_hash?.toString("hex") ?? "" });
34
34
  }
35
35
  close() {
36
36
  // The store's lifetime is owned by the caller (it may serve other work).
@@ -1,5 +1,5 @@
1
1
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
- import { type ObserveResult, type ObserveDeleteResult } from "@omgbase/core";
2
+ import { type ObserveResult, type ObserveDeleteResult, type SurfaceObserveResult } from "@omgbase/core";
3
3
  import type { EngineClient, ChangesPage, DocBytes } from "./engine-client.js";
4
4
  /** Wraps a connected MCP SDK Client, calling the engine's sync tools. */
5
5
  export declare class McpEngineClient implements EngineClient {
@@ -33,6 +33,11 @@ export declare class McpEngineClient implements EngineClient {
33
33
  readDoc(path: string): Promise<DocBytes | null>;
34
34
  close(): Promise<void>;
35
35
  }
36
+ /** A wire observe outcome (`{ _id, _path, … }`, spec/surface §3, 5.0) as the library's `{ docId, path, … }`. */
37
+ export declare function fromWireObserve<T extends {
38
+ docId: string | null;
39
+ path: string;
40
+ }>(w: SurfaceObserveResult<T>): T;
36
41
  /** Connect to an omgbase MCP server over stdio by spawning `command args`
37
42
  * (e.g. `omg mcp -C /vault`). Returns a ready EngineClient. */
38
43
  export declare function connectStdioEngine(spec: {
@@ -48,9 +48,12 @@ export class McpEngineClient {
48
48
  }
49
49
  return body;
50
50
  }
51
- // The wire spells a document's identity `id`/`path` (spec/surface §1.2,
52
- // 3.0); the engine-client contract keeps the library's `docId`/`path`
53
- // (spec/store's observe outcome), so the two are mapped back here.
51
+ // The wire spells a document's identity `_id`/`_path` (spec/surface §1.2,
52
+ // 5.0: an underscore-prefixed name is an engine field); the engine-client
53
+ // contract keeps the library's `docId`/`path` (spec/store's observe
54
+ // outcome), so the two are mapped back here. The `observe*` ARGUMENTS keep
55
+ // `path` and `files[].path`: a file event's path is a role, not a row
56
+ // attribute (§4 "Arguments").
54
57
  async observeMany(files) {
55
58
  const out = await this.callTool("observe_many", { files });
56
59
  return out.map(fromWireObserve);
@@ -67,8 +70,11 @@ export class McpEngineClient {
67
70
  }
68
71
  async readDoc(path) {
69
72
  try {
70
- const res = await this.callTool("docs_read", { path });
71
- return { content: res.raw, contentHash: createHash("sha256").update(res.raw, "utf8").digest("hex") };
73
+ // `docs_read { _path }` — the argument addresses the row's `_path`
74
+ // (5.0; a bare `path` is refused, no tolerance) — and `_raw` is the
75
+ // document's reconstructed bytes.
76
+ const res = await this.callTool("docs_read", { _path: path });
77
+ return { content: res._raw, contentHash: createHash("sha256").update(res._raw, "utf8").digest("hex") };
72
78
  }
73
79
  catch {
74
80
  // doc_missing (or any read failure) → treat as absent.
@@ -79,10 +85,10 @@ export class McpEngineClient {
79
85
  await this.client.close();
80
86
  }
81
87
  }
82
- /** A wire observe outcome (`{ id, path, … }`) as the library's `{ docId, path, … }`. */
83
- function fromWireObserve(w) {
84
- const { id, path, ...rest } = w;
85
- return { docId: id, path: path, ...rest };
88
+ /** A wire observe outcome (`{ _id, _path, … }`, spec/surface §3, 5.0) as the library's `{ docId, path, … }`. */
89
+ export function fromWireObserve(w) {
90
+ const { _id, _path, ...rest } = w;
91
+ return { docId: _id, path: _path, ...rest };
86
92
  }
87
93
  /** Connect to an omgbase MCP server over stdio by spawning `command args`
88
94
  * (e.g. `omg mcp -C /vault`). Returns a ready EngineClient. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omgbase/sync",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
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,7 +53,7 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@modelcontextprotocol/sdk": "^1.30.0",
56
- "@omgbase/core": "^0.28.0",
56
+ "@omgbase/core": "^0.29.0",
57
57
  "@omgbase/fs-adapter": "^0.2.0"
58
58
  },
59
59
  "scripts": {