nvicode 0.1.14 → 0.1.16
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 -15
- 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,12 +712,8 @@ 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
|
-
"--secret-input-mode",
|
|
724
|
-
"ref",
|
|
725
717
|
"--custom-provider-id",
|
|
726
718
|
providerId,
|
|
727
719
|
"--custom-compatibility",
|
|
@@ -746,7 +738,7 @@ const ensureOpenClawConfigured = async (openclawBinary, config, activeApiKey) =>
|
|
|
746
738
|
model: getActiveModel(config),
|
|
747
739
|
configuredAt: new Date().toISOString(),
|
|
748
740
|
}, null, 2)}\n`);
|
|
749
|
-
return baseEnv;
|
|
741
|
+
return { env: baseEnv, updated: true };
|
|
750
742
|
};
|
|
751
743
|
const spawnClaudeProcess = (claudeBinary, args, env) => {
|
|
752
744
|
if (isWindows && /\.(cmd|bat)$/i.test(claudeBinary)) {
|
|
@@ -767,7 +759,10 @@ const runLaunchOpenClaw = async (args) => {
|
|
|
767
759
|
const config = await ensureConfigured();
|
|
768
760
|
const activeApiKey = getActiveApiKey(config);
|
|
769
761
|
const openclawBinary = await resolveOpenClawBinary();
|
|
770
|
-
const env = await ensureOpenClawConfigured(openclawBinary, config, activeApiKey);
|
|
762
|
+
const { env, updated } = await ensureOpenClawConfigured(openclawBinary, config, activeApiKey);
|
|
763
|
+
if (updated) {
|
|
764
|
+
console.error("nvicode updated the default OpenClaw config. Restart the OpenClaw gateway to apply it: `openclaw gateway restart` (or `openclaw gateway run` for a foreground test).");
|
|
765
|
+
}
|
|
771
766
|
const child = spawnClaudeProcess(openclawBinary, args, env);
|
|
772
767
|
await new Promise((resolve, reject) => {
|
|
773
768
|
child.on("exit", (code, signal) => {
|