@adhdev/daemon-core 0.9.77-rc.47 → 0.9.77-rc.48
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/dist/index.js +0 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -18
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-sync.d.ts +4 -12
- package/package.json +1 -1
- package/src/mesh/mesh-sync.ts +4 -34
package/dist/mesh/mesh-sync.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mesh Sync — Sync local mesh
|
|
2
|
+
* Mesh Sync — Sync local mesh metadata to/from cloud D1
|
|
3
3
|
*
|
|
4
4
|
* When cloud is available, this module pushes local mesh config
|
|
5
5
|
* to the server and pulls remote meshes that were created from
|
|
6
6
|
* other machines. The local ~/.adhdev/meshes.json remains the
|
|
7
|
-
* canonical source; cloud is a
|
|
7
|
+
* canonical source; cloud is a membership/metadata layer only.
|
|
8
|
+
* Task/chat/ledger evidence remains local-first and must not be
|
|
9
|
+
* synchronized through Cloud/D1.
|
|
8
10
|
*
|
|
9
11
|
* This is called lazily (not on daemon startup) — only when the
|
|
10
12
|
* user explicitly opens the mesh page or runs `adhdev mesh sync`.
|
|
@@ -26,12 +28,6 @@ export interface MeshSyncTransport {
|
|
|
26
28
|
}>;
|
|
27
29
|
/** DELETE /api/v1/repo-meshes/:id */
|
|
28
30
|
deleteRemoteMesh(meshId: string): Promise<void>;
|
|
29
|
-
/** POST /api/v1/repo-meshes/:id/ledger/sync */
|
|
30
|
-
syncMeshLedger?(meshId: string, data: {
|
|
31
|
-
newEntries: any[];
|
|
32
|
-
}): Promise<{
|
|
33
|
-
missingEntries: any[];
|
|
34
|
-
}>;
|
|
35
31
|
}
|
|
36
32
|
export interface RemoteMeshRecord {
|
|
37
33
|
id: string;
|
|
@@ -55,7 +51,3 @@ export interface MeshSyncResult {
|
|
|
55
51
|
* Pull remote meshes that don't exist locally.
|
|
56
52
|
*/
|
|
57
53
|
export declare function syncMeshes(transport: MeshSyncTransport): Promise<MeshSyncResult>;
|
|
58
|
-
/**
|
|
59
|
-
* Sync the task ledger for a specific mesh.
|
|
60
|
-
*/
|
|
61
|
-
export declare function syncMeshLedger(meshId: string, transport: MeshSyncTransport): Promise<void>;
|
package/package.json
CHANGED
package/src/mesh/mesh-sync.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mesh Sync — Sync local mesh
|
|
2
|
+
* Mesh Sync — Sync local mesh metadata to/from cloud D1
|
|
3
3
|
*
|
|
4
4
|
* When cloud is available, this module pushes local mesh config
|
|
5
5
|
* to the server and pulls remote meshes that were created from
|
|
6
6
|
* other machines. The local ~/.adhdev/meshes.json remains the
|
|
7
|
-
* canonical source; cloud is a
|
|
7
|
+
* canonical source; cloud is a membership/metadata layer only.
|
|
8
|
+
* Task/chat/ledger evidence remains local-first and must not be
|
|
9
|
+
* synchronized through Cloud/D1.
|
|
8
10
|
*
|
|
9
11
|
* This is called lazily (not on daemon startup) — only when the
|
|
10
12
|
* user explicitly opens the mesh page or runs `adhdev mesh sync`.
|
|
@@ -26,8 +28,6 @@ export interface MeshSyncTransport {
|
|
|
26
28
|
}): Promise<{ mesh: RemoteMeshRecord }>;
|
|
27
29
|
/** DELETE /api/v1/repo-meshes/:id */
|
|
28
30
|
deleteRemoteMesh(meshId: string): Promise<void>;
|
|
29
|
-
/** POST /api/v1/repo-meshes/:id/ledger/sync */
|
|
30
|
-
syncMeshLedger?(meshId: string, data: { newEntries: any[] }): Promise<{ missingEntries: any[] }>;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export interface RemoteMeshRecord {
|
|
@@ -107,35 +107,5 @@ export async function syncMeshes(transport: MeshSyncTransport): Promise<MeshSync
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
// Sync ledgers for all local meshes if the transport supports it
|
|
111
|
-
if (transport.syncMeshLedger) {
|
|
112
|
-
for (const local of localMeshes) {
|
|
113
|
-
try {
|
|
114
|
-
await syncMeshLedger(local.id, transport);
|
|
115
|
-
} catch (e: any) {
|
|
116
|
-
result.errors.push(`Ledger sync failed for "${local.name}": ${e.message}`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
110
|
return result;
|
|
122
111
|
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Sync the task ledger for a specific mesh.
|
|
126
|
-
*/
|
|
127
|
-
export async function syncMeshLedger(meshId: string, transport: MeshSyncTransport): Promise<void> {
|
|
128
|
-
if (!transport.syncMeshLedger) return;
|
|
129
|
-
const { readLedgerEntries, appendRemoteLedgerEntries } = await import('./mesh-ledger.js');
|
|
130
|
-
|
|
131
|
-
// Read all local entries (no tail)
|
|
132
|
-
const localEntries = readLedgerEntries(meshId);
|
|
133
|
-
|
|
134
|
-
// Send to cloud and get missing entries back
|
|
135
|
-
const res = await transport.syncMeshLedger(meshId, { newEntries: localEntries });
|
|
136
|
-
|
|
137
|
-
// Append any missing entries from the cloud
|
|
138
|
-
if (res.missingEntries && res.missingEntries.length > 0) {
|
|
139
|
-
appendRemoteLedgerEntries(meshId, res.missingEntries);
|
|
140
|
-
}
|
|
141
|
-
}
|