@divergeai/cli 0.1.6 → 0.1.7
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/diverge.mjs +37 -5
- package/package.json +1 -1
package/dist/diverge.mjs
CHANGED
|
@@ -7387,7 +7387,7 @@ import path10 from "node:path";
|
|
|
7387
7387
|
import { parseArgs } from "node:util";
|
|
7388
7388
|
|
|
7389
7389
|
// src/version.ts
|
|
7390
|
-
var VERSION = true ? "0.1.
|
|
7390
|
+
var VERSION = true ? "0.1.7" : "dev";
|
|
7391
7391
|
var USER_AGENT = `diverge/${VERSION}`;
|
|
7392
7392
|
|
|
7393
7393
|
// src/http.ts
|
|
@@ -8068,6 +8068,19 @@ function dshArgs(overlayPath, args) {
|
|
|
8068
8068
|
const rest = args.includes("--profile") ? args : args.length === 0 ? ["--profile", "web"] : ["--profile", "headless", ...args];
|
|
8069
8069
|
return ["--patch", overlayPath, ...rest];
|
|
8070
8070
|
}
|
|
8071
|
+
function dshLaunch(binary, args, platform = process.platform, execPath = process.execPath) {
|
|
8072
|
+
if (platform !== "win32" || !/\.(cmd|bat)$/i.test(binary)) return { command: binary, args };
|
|
8073
|
+
const packageDir = path7.join(path7.dirname(binary), "node_modules", "@deepseek-ai", "dsh");
|
|
8074
|
+
let bin;
|
|
8075
|
+
try {
|
|
8076
|
+
bin = JSON.parse(fs4.readFileSync(path7.join(packageDir, "package.json"), "utf8")).bin;
|
|
8077
|
+
} catch {
|
|
8078
|
+
throw new CliError(`${binary} is not an npm shim for @deepseek-ai/dsh (no ${packageDir}); reinstall: npm install -g @deepseek-ai/dsh`);
|
|
8079
|
+
}
|
|
8080
|
+
const script = typeof bin === "string" ? bin : typeof bin === "object" && bin !== null ? bin.dsh : void 0;
|
|
8081
|
+
if (typeof script !== "string") throw new CliError(`${packageDir}/package.json declares no dsh entry; reinstall: npm install -g @deepseek-ai/dsh`);
|
|
8082
|
+
return { command: execPath, args: [path7.join(packageDir, script), ...args] };
|
|
8083
|
+
}
|
|
8071
8084
|
async function keepTokenFresh(loop) {
|
|
8072
8085
|
let written = null;
|
|
8073
8086
|
while (loop.isRunning()) {
|
|
@@ -8086,12 +8099,21 @@ function runDsh(options) {
|
|
|
8086
8099
|
writeDshToken(options.credentialsPath, options.initialToken);
|
|
8087
8100
|
const env = {};
|
|
8088
8101
|
for (const [key, value] of Object.entries(options.env)) if (key !== "DIVERGENT_TOKEN" && value !== void 0) env[key] = value;
|
|
8089
|
-
const
|
|
8102
|
+
const launch = dshLaunch(options.binary, dshArgs(options.overlayPath, options.args));
|
|
8103
|
+
const child = spawn2(launch.command, launch.args, { env, stdio: "inherit" });
|
|
8090
8104
|
let exited = false;
|
|
8105
|
+
let wake = null;
|
|
8106
|
+
const finish = () => {
|
|
8107
|
+
exited = true;
|
|
8108
|
+
wake?.();
|
|
8109
|
+
};
|
|
8091
8110
|
const done = new Promise((resolve, reject) => {
|
|
8092
|
-
child.on("error",
|
|
8111
|
+
child.on("error", (error) => {
|
|
8112
|
+
finish();
|
|
8113
|
+
reject(error);
|
|
8114
|
+
});
|
|
8093
8115
|
child.on("exit", (code2, signal) => {
|
|
8094
|
-
|
|
8116
|
+
finish();
|
|
8095
8117
|
resolve(code2 ?? (signal ? 128 + 15 : 1));
|
|
8096
8118
|
});
|
|
8097
8119
|
});
|
|
@@ -8104,7 +8126,17 @@ function runDsh(options) {
|
|
|
8104
8126
|
freshToken: options.freshToken,
|
|
8105
8127
|
write: (token) => writeDshToken(options.credentialsPath, token),
|
|
8106
8128
|
isRunning: () => !exited,
|
|
8107
|
-
sleep: (ms) => new Promise((resolve) =>
|
|
8129
|
+
sleep: (ms) => new Promise((resolve) => {
|
|
8130
|
+
const timer = setTimeout(() => {
|
|
8131
|
+
wake = null;
|
|
8132
|
+
resolve();
|
|
8133
|
+
}, ms);
|
|
8134
|
+
wake = () => {
|
|
8135
|
+
clearTimeout(timer);
|
|
8136
|
+
wake = null;
|
|
8137
|
+
resolve();
|
|
8138
|
+
};
|
|
8139
|
+
})
|
|
8108
8140
|
});
|
|
8109
8141
|
return done.finally(async () => {
|
|
8110
8142
|
process.off("SIGINT", ignore);
|