nvicode 0.1.14 → 0.1.15
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/cli.js +10 -13
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -649,18 +649,14 @@ const findExecutableInPath = async (name) => {
|
|
|
649
649
|
}
|
|
650
650
|
return null;
|
|
651
651
|
};
|
|
652
|
-
const buildOpenClawEnv = (baseEnv,
|
|
652
|
+
const buildOpenClawEnv = (baseEnv, activeApiKey) => ({
|
|
653
653
|
...baseEnv,
|
|
654
|
-
OPENCLAW_HOME: openclawHome,
|
|
655
654
|
...(activeApiKey ? { CUSTOM_API_KEY: activeApiKey } : {}),
|
|
656
655
|
});
|
|
657
656
|
const getOpenClawPaths = () => {
|
|
658
657
|
const paths = getNvicodePaths();
|
|
659
|
-
const openclawHome = path.join(paths.stateDir, "openclaw");
|
|
660
658
|
return {
|
|
661
|
-
|
|
662
|
-
workspaceDir: path.join(openclawHome, "workspace"),
|
|
663
|
-
markerFile: path.join(openclawHome, "nvicode-profile.json"),
|
|
659
|
+
markerFile: path.join(paths.stateDir, "openclaw-profile.json"),
|
|
664
660
|
};
|
|
665
661
|
};
|
|
666
662
|
const getOpenClawProviderId = (config) => config.provider === "openrouter" ? "nvicode-openrouter" : "nvicode-nvidia";
|
|
@@ -694,15 +690,15 @@ const ensureOpenClawConfigured = async (openclawBinary, config, activeApiKey) =>
|
|
|
694
690
|
throw new Error(`OpenClaw requires Node.js >=22.14.0. Current version is ${process.versions.node}.`);
|
|
695
691
|
}
|
|
696
692
|
const openclawPaths = getOpenClawPaths();
|
|
697
|
-
const baseEnv = buildOpenClawEnv(process.env,
|
|
698
|
-
await fs.mkdir(openclawPaths.
|
|
693
|
+
const baseEnv = buildOpenClawEnv(process.env, activeApiKey);
|
|
694
|
+
await fs.mkdir(path.dirname(openclawPaths.markerFile), { recursive: true });
|
|
699
695
|
const profileSignature = getOpenClawProfileSignature(config, activeApiKey);
|
|
700
696
|
const existingMarkerRaw = await readIfExists(openclawPaths.markerFile);
|
|
701
697
|
if (existingMarkerRaw) {
|
|
702
698
|
try {
|
|
703
699
|
const parsed = JSON.parse(existingMarkerRaw);
|
|
704
700
|
if (parsed.signature === profileSignature) {
|
|
705
|
-
return baseEnv;
|
|
701
|
+
return { env: baseEnv, updated: false };
|
|
706
702
|
}
|
|
707
703
|
}
|
|
708
704
|
catch {
|
|
@@ -716,8 +712,6 @@ const ensureOpenClawConfigured = async (openclawBinary, config, activeApiKey) =>
|
|
|
716
712
|
"--accept-risk",
|
|
717
713
|
"--flow",
|
|
718
714
|
"advanced",
|
|
719
|
-
"--workspace",
|
|
720
|
-
openclawPaths.workspaceDir,
|
|
721
715
|
"--auth-choice",
|
|
722
716
|
"custom-api-key",
|
|
723
717
|
"--secret-input-mode",
|
|
@@ -746,7 +740,7 @@ const ensureOpenClawConfigured = async (openclawBinary, config, activeApiKey) =>
|
|
|
746
740
|
model: getActiveModel(config),
|
|
747
741
|
configuredAt: new Date().toISOString(),
|
|
748
742
|
}, null, 2)}\n`);
|
|
749
|
-
return baseEnv;
|
|
743
|
+
return { env: baseEnv, updated: true };
|
|
750
744
|
};
|
|
751
745
|
const spawnClaudeProcess = (claudeBinary, args, env) => {
|
|
752
746
|
if (isWindows && /\.(cmd|bat)$/i.test(claudeBinary)) {
|
|
@@ -767,7 +761,10 @@ const runLaunchOpenClaw = async (args) => {
|
|
|
767
761
|
const config = await ensureConfigured();
|
|
768
762
|
const activeApiKey = getActiveApiKey(config);
|
|
769
763
|
const openclawBinary = await resolveOpenClawBinary();
|
|
770
|
-
const env = await ensureOpenClawConfigured(openclawBinary, config, activeApiKey);
|
|
764
|
+
const { env, updated } = await ensureOpenClawConfigured(openclawBinary, config, activeApiKey);
|
|
765
|
+
if (updated) {
|
|
766
|
+
console.error("nvicode updated the default OpenClaw config. Restart the OpenClaw gateway to apply it: `openclaw gateway restart`.");
|
|
767
|
+
}
|
|
771
768
|
const child = spawnClaudeProcess(openclawBinary, args, env);
|
|
772
769
|
await new Promise((resolve, reject) => {
|
|
773
770
|
child.on("exit", (code, signal) => {
|