clawdock 0.2.7 → 0.2.9
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 +35 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -434,20 +434,37 @@ program.command("run <bundle>").description("Pull and run an agent locally").opt
|
|
|
434
434
|
const agentDir = path.join(os.homedir(), ".openclaw", "agents", agentName, "agent");
|
|
435
435
|
fs.mkdirSync(agentDir, { recursive: true });
|
|
436
436
|
const authProfilesPath = path.join(agentDir, "auth-profiles.json");
|
|
437
|
-
const
|
|
438
|
-
authProfiles
|
|
437
|
+
const profileKey = `${provider}:default`;
|
|
438
|
+
const authProfiles = {
|
|
439
|
+
version: 1,
|
|
440
|
+
profiles: {
|
|
441
|
+
[profileKey]: {
|
|
442
|
+
type: "token",
|
|
443
|
+
provider,
|
|
444
|
+
token: apiKey
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
lastGood: {
|
|
448
|
+
[provider]: profileKey
|
|
449
|
+
}
|
|
450
|
+
};
|
|
439
451
|
fs.writeFileSync(authProfilesPath, JSON.stringify(authProfiles, null, 2));
|
|
440
452
|
}
|
|
441
453
|
const introMessage = "Hello! I just pulled you from ClawDock. Introduce yourself.";
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
{
|
|
454
|
+
let child;
|
|
455
|
+
if (isWindows) {
|
|
456
|
+
const cmd = `"${runtimeBin}" agent --agent ${agentName} --local -m "${introMessage}"`;
|
|
457
|
+
child = spawn(cmd, [], {
|
|
446
458
|
stdio: "inherit",
|
|
447
459
|
env: { ...process.env },
|
|
448
|
-
shell:
|
|
449
|
-
}
|
|
450
|
-
|
|
460
|
+
shell: true
|
|
461
|
+
});
|
|
462
|
+
} else {
|
|
463
|
+
child = spawn(runtimeBin, ["agent", "--agent", agentName, "--local", "-m", introMessage], {
|
|
464
|
+
stdio: "inherit",
|
|
465
|
+
env: { ...process.env }
|
|
466
|
+
});
|
|
467
|
+
}
|
|
451
468
|
child.on("error", (err) => {
|
|
452
469
|
console.error(`\u274C Failed to start: ${err.message}`);
|
|
453
470
|
process.exit(1);
|
|
@@ -477,18 +494,21 @@ program.command("run <bundle>").description("Pull and run an agent locally").opt
|
|
|
477
494
|
}
|
|
478
495
|
};
|
|
479
496
|
fs.writeFileSync(configPath, JSON.stringify(nullclawConfig, null, 2));
|
|
480
|
-
const
|
|
497
|
+
const nullChild = isWindows ? spawn(`"${runtimeBin}" --config "${configPath}" --workspace "${workspaceDir}"`, [], {
|
|
481
498
|
stdio: "inherit",
|
|
482
499
|
cwd: workspaceDir,
|
|
483
|
-
shell:
|
|
500
|
+
shell: true
|
|
501
|
+
}) : spawn(runtimeBin, ["--config", configPath, "--workspace", workspaceDir], {
|
|
502
|
+
stdio: "inherit",
|
|
503
|
+
cwd: workspaceDir
|
|
484
504
|
});
|
|
485
|
-
|
|
505
|
+
nullChild.on("error", (err) => {
|
|
486
506
|
console.error(`\u274C Failed to start NullClaw: ${err.message}`);
|
|
487
507
|
process.exit(1);
|
|
488
508
|
});
|
|
489
|
-
|
|
490
|
-
process.on("SIGINT", () =>
|
|
491
|
-
process.on("SIGTERM", () =>
|
|
509
|
+
nullChild.on("exit", (code) => process.exit(code || 0));
|
|
510
|
+
process.on("SIGINT", () => nullChild.kill("SIGINT"));
|
|
511
|
+
process.on("SIGTERM", () => nullChild.kill("SIGTERM"));
|
|
492
512
|
}
|
|
493
513
|
});
|
|
494
514
|
program.command("update").description("Update clawdock CLI to the latest version").action(async () => {
|