@storacha/clawracha 0.1.1 → 0.1.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/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +41 -0
- package/dist/sync.d.ts +20 -0
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +26 -0
- package/package.json +1 -1
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,qBAAqB,CAAC;AAiH7B,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,qBAAqB,CAAC;AAiH7B,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,iBAAiB,QAgjBpD"}
|
package/dist/plugin.js
CHANGED
|
@@ -112,6 +112,7 @@ export default function plugin(api) {
|
|
|
112
112
|
},
|
|
113
113
|
async stop(ctx) {
|
|
114
114
|
for (const [workspace, sync] of activeSyncers) {
|
|
115
|
+
sync.engine.stop();
|
|
115
116
|
await sync.watcher.stop();
|
|
116
117
|
ctx.logger.info(`[${sync.agentId}] Stopped syncing: ${workspace}`);
|
|
117
118
|
}
|
|
@@ -472,5 +473,45 @@ export default function plugin(api) {
|
|
|
472
473
|
process.exit(1);
|
|
473
474
|
}
|
|
474
475
|
});
|
|
476
|
+
// --- inspect ---
|
|
477
|
+
clawracha
|
|
478
|
+
.command("inspect")
|
|
479
|
+
.description("Inspect internal sync state for debugging")
|
|
480
|
+
.requiredOption("--agent <id>", "Agent ID")
|
|
481
|
+
.action(async (opts) => {
|
|
482
|
+
try {
|
|
483
|
+
const { agentId, workspace } = requireAgent(opts.agent);
|
|
484
|
+
const deviceConfig = await loadDeviceConfig(workspace);
|
|
485
|
+
if (!deviceConfig?.agentKey || !deviceConfig.setupComplete) {
|
|
486
|
+
console.log(`Not set up. Run \`openclaw clawracha init --agent ${agentId}\` first.`);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
// Spin up a temporary engine to inspect state
|
|
490
|
+
const storachaClient = await createStorachaClient(deviceConfig);
|
|
491
|
+
const engine = new SyncEngine(storachaClient, workspace);
|
|
492
|
+
await engine.init(deviceConfig);
|
|
493
|
+
const state = await engine.inspect();
|
|
494
|
+
console.log(`🔥 Storacha Inspect [${agentId}]`);
|
|
495
|
+
console.log(`Workspace: ${workspace}`);
|
|
496
|
+
console.log(`Running: ${state.running}`);
|
|
497
|
+
console.log(`Root CID: ${state.root ?? "(none)"}`);
|
|
498
|
+
console.log(`Revisions: ${state.revisions.length}`);
|
|
499
|
+
for (const r of state.revisions) {
|
|
500
|
+
console.log(` event: ${r.event}`);
|
|
501
|
+
}
|
|
502
|
+
console.log(`\nPail entries (${state.pailKeys.length}):`);
|
|
503
|
+
for (const key of state.pailKeys) {
|
|
504
|
+
console.log(` ${key}`);
|
|
505
|
+
}
|
|
506
|
+
console.log(`\nPending ops (${state.pendingOps.length}):`);
|
|
507
|
+
for (const op of state.pendingOps) {
|
|
508
|
+
console.log(` ${op.type} ${op.key}${op.value ? ` → ${op.value}` : ""}`);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
catch (err) {
|
|
512
|
+
console.error(`Error: ${err.message}`);
|
|
513
|
+
process.exit(1);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
475
516
|
}, { commands: ["clawracha"] });
|
|
476
517
|
}
|
package/dist/sync.d.ts
CHANGED
|
@@ -46,11 +46,31 @@ export declare class SyncEngine {
|
|
|
46
46
|
* Apply remote changes to local filesystem
|
|
47
47
|
*/
|
|
48
48
|
private applyRemoteChanges;
|
|
49
|
+
/**
|
|
50
|
+
* Mark the engine as stopped.
|
|
51
|
+
*/
|
|
52
|
+
stop(): void;
|
|
49
53
|
/**
|
|
50
54
|
* Pull all remote state and write to local filesystem.
|
|
51
55
|
* Used by /storacha-join to overwrite local with remote before watcher starts.
|
|
52
56
|
*/
|
|
53
57
|
pullRemote(): Promise<number>;
|
|
58
|
+
/**
|
|
59
|
+
* Inspect internal state for debugging.
|
|
60
|
+
*/
|
|
61
|
+
inspect(): Promise<{
|
|
62
|
+
root: string | null;
|
|
63
|
+
revisions: {
|
|
64
|
+
event: string;
|
|
65
|
+
}[];
|
|
66
|
+
pailKeys: string[];
|
|
67
|
+
pendingOps: {
|
|
68
|
+
type: string;
|
|
69
|
+
key: string;
|
|
70
|
+
value?: string;
|
|
71
|
+
}[];
|
|
72
|
+
running: boolean;
|
|
73
|
+
}>;
|
|
54
74
|
status(): Promise<SyncState>;
|
|
55
75
|
exportNameArchive(): Promise<string>;
|
|
56
76
|
private storeBlocks;
|
package/dist/sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAEV,YAAY,EACb,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ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IA0BnC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC;QACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,SAAS,EAAE;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC/B,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,UAAU,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC5D,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IAiBI,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC;IAW5B,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;YAM5B,WAAW;CAK1B"}
|
package/dist/sync.js
CHANGED
|
@@ -68,6 +68,7 @@ export class SyncEngine {
|
|
|
68
68
|
throw err;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
this.running = true;
|
|
71
72
|
}
|
|
72
73
|
/**
|
|
73
74
|
* Process a batch of file changes
|
|
@@ -163,6 +164,12 @@ export class SyncEngine {
|
|
|
163
164
|
current: this.current ?? undefined,
|
|
164
165
|
});
|
|
165
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Mark the engine as stopped.
|
|
169
|
+
*/
|
|
170
|
+
stop() {
|
|
171
|
+
this.running = false;
|
|
172
|
+
}
|
|
166
173
|
/**
|
|
167
174
|
* Pull all remote state and write to local filesystem.
|
|
168
175
|
* Used by /storacha-join to overwrite local with remote before watcher starts.
|
|
@@ -192,6 +199,25 @@ export class SyncEngine {
|
|
|
192
199
|
this.lastSync = Date.now();
|
|
193
200
|
return entries.size;
|
|
194
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Inspect internal state for debugging.
|
|
204
|
+
*/
|
|
205
|
+
async inspect() {
|
|
206
|
+
const entries = await this.getPailEntries();
|
|
207
|
+
return {
|
|
208
|
+
root: this.current?.root?.toString() ?? null,
|
|
209
|
+
revisions: this.current?.revision?.map((r) => ({
|
|
210
|
+
event: r.event.cid.toString(),
|
|
211
|
+
})) ?? [],
|
|
212
|
+
pailKeys: [...entries.keys()],
|
|
213
|
+
pendingOps: this.pendingOps.map((op) => ({
|
|
214
|
+
type: op.type,
|
|
215
|
+
key: op.key,
|
|
216
|
+
value: op.value?.toString(),
|
|
217
|
+
})),
|
|
218
|
+
running: this.running,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
195
221
|
async status() {
|
|
196
222
|
const entries = await this.getPailEntries();
|
|
197
223
|
return {
|