principles-disciple 1.147.0 → 1.149.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.
- package/dist/core/principle-tree-ledger.d.ts +27 -79
- package/dist/core/principle-tree-ledger.js +39 -524
- package/dist/core/reflection/reflection-context.d.ts +2 -2
- package/dist/core/workspace-context.d.ts +2 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -5
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/core/principle-tree-ledger-adapter.d.ts +0 -32
- package/dist/core/principle-tree-ledger-adapter.js +0 -125
- package/dist/service/central-database.d.ts +0 -138
- package/dist/service/central-database.js +0 -731
- package/dist/service/central-sync-service.d.ts +0 -8
- package/dist/service/central-sync-service.js +0 -71
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CentralSyncService - Periodically sync workspace data to central database.
|
|
3
|
-
*
|
|
4
|
-
* Ensures thinking_model_events and other workspace data are aggregated
|
|
5
|
-
* into the central database for cross-workspace queries and WebUI display.
|
|
6
|
-
*/
|
|
7
|
-
import type { OpenClawPluginService } from '../openclaw-sdk.js';
|
|
8
|
-
export declare const CentralSyncService: OpenClawPluginService;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CentralSyncService - Periodically sync workspace data to central database.
|
|
3
|
-
*
|
|
4
|
-
* Ensures thinking_model_events and other workspace data are aggregated
|
|
5
|
-
* into the central database for cross-workspace queries and WebUI display.
|
|
6
|
-
*/
|
|
7
|
-
import { CentralDatabase } from './central-database.js';
|
|
8
|
-
import { WORKFLOW_TTL_MS } from '../config/defaults/runtime.js';
|
|
9
|
-
let syncInterval = null;
|
|
10
|
-
let logger = undefined;
|
|
11
|
-
let centralDb = null;
|
|
12
|
-
async function runSyncCycle() {
|
|
13
|
-
if (!centralDb) {
|
|
14
|
-
logger?.warn?.('[PD:CentralSync] CentralDatabase not initialized, skipping sync');
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
const results = centralDb.syncAll();
|
|
19
|
-
const totalSynced = Array.from(results.values()).reduce((sum, count) => sum + count, 0);
|
|
20
|
-
const workspacesSynced = Array.from(results.entries())
|
|
21
|
-
.filter(([, count]) => count > 0)
|
|
22
|
-
.map(([name, count]) => `${name}:${count}`)
|
|
23
|
-
.join(', ');
|
|
24
|
-
if (totalSynced > 0) {
|
|
25
|
-
logger?.info?.(`[PD:CentralSync] Synced ${totalSynced} records from workspaces: ${workspacesSynced}`);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
logger?.debug?.(`[PD:CentralSync] No new records to sync`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
logger?.error?.(`[PD:CentralSync] Sync failed: ${String(err)}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export const CentralSyncService = {
|
|
36
|
-
id: 'principles-central-sync',
|
|
37
|
-
async start(ctx) {
|
|
38
|
-
const { logger: ctxLogger, config } = ctx;
|
|
39
|
-
logger = ctxLogger;
|
|
40
|
-
const { intervals } = config;
|
|
41
|
-
const intervalMs = intervals?.central_sync_ms ?? WORKFLOW_TTL_MS;
|
|
42
|
-
// Initialize CentralDatabase
|
|
43
|
-
centralDb = new CentralDatabase();
|
|
44
|
-
// Initial sync on start
|
|
45
|
-
logger?.info?.(`[PD:CentralSync] Starting with interval ${intervalMs}ms`);
|
|
46
|
-
await runSyncCycle();
|
|
47
|
-
// Schedule periodic sync
|
|
48
|
-
syncInterval = setInterval(runSyncCycle, intervalMs);
|
|
49
|
-
// Don't keep the process alive just for this timer
|
|
50
|
-
syncInterval.unref();
|
|
51
|
-
logger?.info?.(`[PD:CentralSync] Service started, syncing every ${intervalMs / 1000}s`);
|
|
52
|
-
},
|
|
53
|
-
async stop(ctx) {
|
|
54
|
-
if (syncInterval) {
|
|
55
|
-
clearInterval(syncInterval);
|
|
56
|
-
syncInterval = null;
|
|
57
|
-
}
|
|
58
|
-
// Final sync on stop
|
|
59
|
-
if (centralDb) {
|
|
60
|
-
try {
|
|
61
|
-
centralDb.syncAll();
|
|
62
|
-
ctx.logger?.info?.(`[PD:CentralSync] Final sync completed`);
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
ctx.logger?.error?.(`[PD:CentralSync] Final sync failed: ${String(err)}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
centralDb = null;
|
|
69
|
-
ctx.logger?.info?.(`[PD:CentralSync] Service stopped`);
|
|
70
|
-
},
|
|
71
|
-
};
|