@storacha/clawracha 0.1.3 → 0.1.4
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 +21 -5
- 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;AAgH7B,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;AAgH7B,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,iBAAiB,QA6jBpD"}
|
package/dist/plugin.js
CHANGED
|
@@ -240,6 +240,7 @@ export default function plugin(api) {
|
|
|
240
240
|
.description("Set up a NEW workspace (first device). <delegation> is a file path or base64 CID string.")
|
|
241
241
|
.requiredOption("--agent <id>", "Agent ID")
|
|
242
242
|
.action(async (delegationArg, opts) => {
|
|
243
|
+
let engine = null;
|
|
243
244
|
try {
|
|
244
245
|
const { agentId, workspace } = requireAgent(opts.agent);
|
|
245
246
|
const deviceConfig = await loadDeviceConfig(workspace);
|
|
@@ -262,7 +263,7 @@ export default function plugin(api) {
|
|
|
262
263
|
deviceConfig.setupComplete = true;
|
|
263
264
|
await saveDeviceConfig(workspace, deviceConfig);
|
|
264
265
|
// Initial upload: scan all existing workspace files and sync to Storacha
|
|
265
|
-
|
|
266
|
+
engine = new SyncEngine(workspace);
|
|
266
267
|
await engine.init(deviceConfig);
|
|
267
268
|
const userIgnored = await readIgnoreFile(workspace);
|
|
268
269
|
const ignorePatterns = [
|
|
@@ -291,12 +292,19 @@ export default function plugin(api) {
|
|
|
291
292
|
console.log(`🔥 Storacha workspace ready for ${agentId}!`);
|
|
292
293
|
console.log(`Agent DID: ${agent.did()}`);
|
|
293
294
|
console.log(`Space: ${spaceDID ?? "unknown"}`);
|
|
294
|
-
console.log("\nRestart the gateway to start syncing: `openclaw gateway restart`");
|
|
295
295
|
console.log(`\nTo add another device, run \`openclaw clawracha grant <their-DID> --agent ${agentId}\` here,`);
|
|
296
296
|
console.log(`then \`openclaw clawracha join <upload> <name> --agent <id>\` on the other device.`);
|
|
297
297
|
console.log("\nSync is now active (no gateway restart needed).");
|
|
298
298
|
}
|
|
299
299
|
catch (err) {
|
|
300
|
+
if (engine) {
|
|
301
|
+
try {
|
|
302
|
+
const state = await engine.inspect();
|
|
303
|
+
console.error("\nEngine state at failure:");
|
|
304
|
+
console.error(JSON.stringify(state, null, 2));
|
|
305
|
+
}
|
|
306
|
+
catch { }
|
|
307
|
+
}
|
|
300
308
|
console.error(`Error: ${err.message}`);
|
|
301
309
|
process.exit(1);
|
|
302
310
|
}
|
|
@@ -307,6 +315,7 @@ export default function plugin(api) {
|
|
|
307
315
|
.description("Join an existing workspace from another device. Arguments are file paths or base64 CID strings.")
|
|
308
316
|
.requiredOption("--agent <id>", "Agent ID")
|
|
309
317
|
.action(async (uploadArg, nameArg, opts) => {
|
|
318
|
+
let engine = null;
|
|
310
319
|
try {
|
|
311
320
|
const { agentId, workspace } = requireAgent(opts.agent);
|
|
312
321
|
const deviceConfig = await loadDeviceConfig(workspace);
|
|
@@ -334,7 +343,7 @@ export default function plugin(api) {
|
|
|
334
343
|
await saveDeviceConfig(workspace, deviceConfig);
|
|
335
344
|
// Pull remote state before watcher starts
|
|
336
345
|
let pullCount = 0;
|
|
337
|
-
|
|
346
|
+
engine = new SyncEngine(workspace);
|
|
338
347
|
await engine.init(deviceConfig);
|
|
339
348
|
pullCount = await engine.pullRemote();
|
|
340
349
|
// Save name archive after pull
|
|
@@ -347,9 +356,17 @@ export default function plugin(api) {
|
|
|
347
356
|
console.log(`Agent DID: ${agent.did()}`);
|
|
348
357
|
console.log(`Space: ${spaceDID ?? "unknown"}`);
|
|
349
358
|
console.log(`Pulled ${pullCount} files from remote.`);
|
|
350
|
-
console.log("\
|
|
359
|
+
console.log("\nSync is now active (no gateway restart needed).");
|
|
351
360
|
}
|
|
352
361
|
catch (err) {
|
|
362
|
+
if (engine) {
|
|
363
|
+
try {
|
|
364
|
+
const state = await engine.inspect();
|
|
365
|
+
console.error("\nEngine state at failure:");
|
|
366
|
+
console.error(JSON.stringify(state, null, 2));
|
|
367
|
+
}
|
|
368
|
+
catch { }
|
|
369
|
+
}
|
|
353
370
|
console.error(`Error: ${err.message}`);
|
|
354
371
|
process.exit(1);
|
|
355
372
|
}
|
|
@@ -427,7 +444,6 @@ export default function plugin(api) {
|
|
|
427
444
|
}
|
|
428
445
|
console.log("The target device should run:");
|
|
429
446
|
console.log(` openclaw clawracha join <upload-delegation> <name-delegation> --agent <id>`);
|
|
430
|
-
console.log("\nThen restart the gateway: `openclaw gateway restart`");
|
|
431
447
|
}
|
|
432
448
|
catch (err) {
|
|
433
449
|
console.error(`Error: ${err.message}`);
|