@openagents-org/agent-launcher 0.2.202 → 0.2.203
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/package.json +1 -1
- package/registry.json +6 -6
- package/src/adapters/deepseek-runtime.js +26 -3
- package/src/adapters/deepseek.js +6 -1
- package/src/adapters/openclaw.js +116 -41
- package/src/env.js +28 -7
package/package.json
CHANGED
package/registry.json
CHANGED
|
@@ -1793,12 +1793,12 @@
|
|
|
1793
1793
|
"requires": [
|
|
1794
1794
|
"nodejs"
|
|
1795
1795
|
],
|
|
1796
|
-
"supported_version": "0.1
|
|
1796
|
+
"supported_version": "0.2.1-rc.2",
|
|
1797
1797
|
"verify": "dsh -V >/dev/null 2>&1",
|
|
1798
1798
|
"verify_win": "dsh -V >nul 2>nul",
|
|
1799
|
-
"macos": "npm install -g @deepseek-ai/dsh@0.1
|
|
1800
|
-
"linux": "npm install -g @deepseek-ai/dsh@0.1
|
|
1801
|
-
"windows": "npm install -g @deepseek-ai/dsh@0.1
|
|
1799
|
+
"macos": "npm install -g @deepseek-ai/dsh@0.2.1-rc.2",
|
|
1800
|
+
"linux": "npm install -g @deepseek-ai/dsh@0.2.1-rc.2",
|
|
1801
|
+
"windows": "npm install -g @deepseek-ai/dsh@0.2.1-rc.2"
|
|
1802
1802
|
},
|
|
1803
1803
|
"uninstall": {
|
|
1804
1804
|
"macos": "npm uninstall -g @deepseek-ai/dsh",
|
|
@@ -1829,9 +1829,9 @@
|
|
|
1829
1829
|
},
|
|
1830
1830
|
{
|
|
1831
1831
|
"name": "DEEPSEEK_BASE_URL",
|
|
1832
|
-
"description": "Optional gateway/proxy base URL. Leave blank for the public DeepSeek API.",
|
|
1832
|
+
"description": "Optional gateway/proxy base URL speaking the Anthropic Messages API. Leave blank for the public DeepSeek API (https://api.deepseek.com/anthropic).",
|
|
1833
1833
|
"required": false,
|
|
1834
|
-
"placeholder": "https://api.deepseek.com"
|
|
1834
|
+
"placeholder": "https://api.deepseek.com/anthropic"
|
|
1835
1835
|
},
|
|
1836
1836
|
{
|
|
1837
1837
|
"name": "DEEPSEEK_MODEL",
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* so the adapter itself stays a thin subprocess driver. The split mirrors
|
|
6
6
|
* cline-stream.js / pi-stream.js.
|
|
7
7
|
*
|
|
8
|
-
* Verified against @deepseek-ai/dsh 0.1
|
|
8
|
+
* Verified against @deepseek-ai/dsh 0.2.1-rc.2 (bin `dsh` -> lib/bin.js, ESM).
|
|
9
9
|
*
|
|
10
10
|
* Three things here exist because dsh is unlike every other CLI in this repo:
|
|
11
11
|
*
|
|
12
|
-
* 1. It is a PREVIEW release (`0.1
|
|
12
|
+
* 1. It is a PREVIEW release (`0.2.1-rc.2`) and upstream says compatibility may
|
|
13
13
|
* break between previews, so the gate is exact equality — not a floor. The
|
|
14
14
|
* two version comparators already in this repo (installer.js's
|
|
15
15
|
* `compareVersions`, pi-stream.js's `parseVersion`) both DROP the `-rc.N`
|
|
@@ -45,7 +45,7 @@ const path = require('path');
|
|
|
45
45
|
* from there and only falls back here when the registry entry cannot be read at
|
|
46
46
|
* all. Mirrors pi-stream.js's MIN_PI_VERSION rationale.
|
|
47
47
|
*/
|
|
48
|
-
const SUPPORTED_DSH_VERSION = '0.1
|
|
48
|
+
const SUPPORTED_DSH_VERSION = '0.2.1-rc.2';
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* dsh's Node requirement, from the upstream repository's root package.json:
|
|
@@ -424,6 +424,27 @@ function buildPrivatePatch({ model, provider, permissionMode } = {}) {
|
|
|
424
424
|
return { text: lines.join('\n'), mode };
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
+
// ---------------------------------------------------------------------------
|
|
428
|
+
// Base URL
|
|
429
|
+
// ---------------------------------------------------------------------------
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Whether `url` is DeepSeek's own API root rather than a gateway.
|
|
433
|
+
*
|
|
434
|
+
* dsh talks to DeepSeek over the Anthropic Messages API and defaults to
|
|
435
|
+
* `https://api.deepseek.com/anthropic`. The OpenAI-style roots people copy
|
|
436
|
+
* from DeepSeek's docs (and that other agents' setup forms prefill) —
|
|
437
|
+
* `https://api.deepseek.com` and `…/v1` — answer that API with a 404, so the
|
|
438
|
+
* adapter drops them and lets dsh use its default.
|
|
439
|
+
*/
|
|
440
|
+
function isOfficialDeepseekRoot(url) {
|
|
441
|
+
let parsed;
|
|
442
|
+
try { parsed = new URL(String(url || '').trim()); } catch { return false; }
|
|
443
|
+
if (parsed.hostname.toLowerCase() !== 'api.deepseek.com') return false;
|
|
444
|
+
const p = parsed.pathname.replace(/\/+$/, '').toLowerCase();
|
|
445
|
+
return p === '' || p === '/v1';
|
|
446
|
+
}
|
|
447
|
+
|
|
427
448
|
// ---------------------------------------------------------------------------
|
|
428
449
|
// Permission mode
|
|
429
450
|
// ---------------------------------------------------------------------------
|
|
@@ -616,6 +637,8 @@ module.exports = {
|
|
|
616
637
|
yamlScalar,
|
|
617
638
|
buildPrivatePatch,
|
|
618
639
|
|
|
640
|
+
isOfficialDeepseekRoot,
|
|
641
|
+
|
|
619
642
|
normalizePermissionMode,
|
|
620
643
|
resolvePermissionMode,
|
|
621
644
|
|
package/src/adapters/deepseek.js
CHANGED
|
@@ -74,6 +74,7 @@ const {
|
|
|
74
74
|
classifyNodeVersion,
|
|
75
75
|
cleanStdout,
|
|
76
76
|
defaultInstallCommand,
|
|
77
|
+
isOfficialDeepseekRoot,
|
|
77
78
|
nodeRequirementText,
|
|
78
79
|
resolvePermissionMode,
|
|
79
80
|
safeDshHomeName,
|
|
@@ -400,7 +401,8 @@ class DeepSeekAdapter extends BaseAdapter {
|
|
|
400
401
|
}
|
|
401
402
|
|
|
402
403
|
_baseUrl() {
|
|
403
|
-
|
|
404
|
+
const base = String(this.agentEnv.DEEPSEEK_BASE_URL || this.agentEnv.LLM_BASE_URL || '').trim();
|
|
405
|
+
return isOfficialDeepseekRoot(base) ? '' : base;
|
|
404
406
|
}
|
|
405
407
|
|
|
406
408
|
_model() {
|
|
@@ -567,8 +569,11 @@ class DeepSeekAdapter extends BaseAdapter {
|
|
|
567
569
|
|
|
568
570
|
const key = this._apiKey();
|
|
569
571
|
if (key) env.DEEPSEEK_API_KEY = key;
|
|
572
|
+
// Set or cleared, never inherited: env already carries the raw agent value,
|
|
573
|
+
// and _baseUrl() drops DeepSeek's own OpenAI-style roots.
|
|
570
574
|
const base = this._baseUrl();
|
|
571
575
|
if (base) env.DEEPSEEK_BASE_URL = base;
|
|
576
|
+
else delete env.DEEPSEEK_BASE_URL;
|
|
572
577
|
|
|
573
578
|
// The task file references this by NAME; the value never appears in it.
|
|
574
579
|
env[TOKEN_ENV] = this.token;
|
package/src/adapters/openclaw.js
CHANGED
|
@@ -66,6 +66,23 @@ function retireOwnLegacyAuthProfiles(knownKeys) {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Whether OpenClaw refused to start because local state from an older release
|
|
71
|
+
* still needs its own migration ("Legacy workspace setup state requires
|
|
72
|
+
* migration …; run openclaw doctor --fix", "requires legacy credential
|
|
73
|
+
* migration; run openclaw doctor --fix").
|
|
74
|
+
*
|
|
75
|
+
* Every upgrade across a storage change hits this, and the user's only way out
|
|
76
|
+
* was a terminal. The adapter runs that same Doctor repair itself and retries.
|
|
77
|
+
*/
|
|
78
|
+
function needsDoctorMigration(message) {
|
|
79
|
+
const text = String(message || '');
|
|
80
|
+
return /requires[^\n]*\bmigration\b/i.test(text) && /openclaw doctor --fix/i.test(text);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Budget for one `openclaw doctor --fix` run. */
|
|
84
|
+
const DOCTOR_REPAIR_TIMEOUT_MS = 120000;
|
|
85
|
+
|
|
69
86
|
class OpenClawAdapter extends BaseAdapter {
|
|
70
87
|
/**
|
|
71
88
|
* @param {object} opts - BaseAdapter opts plus:
|
|
@@ -281,7 +298,7 @@ class OpenClawAdapter extends BaseAdapter {
|
|
|
281
298
|
await this.sendStatus(msgChannel, 'thinking...');
|
|
282
299
|
|
|
283
300
|
try {
|
|
284
|
-
const responseText = await this.
|
|
301
|
+
const responseText = await this._runCliAgentWithMigration(content, msgChannel);
|
|
285
302
|
if (this._stoppingChannels.has(msgChannel)) return;
|
|
286
303
|
|
|
287
304
|
if (responseText) {
|
|
@@ -299,6 +316,101 @@ class OpenClawAdapter extends BaseAdapter {
|
|
|
299
316
|
// CLI mode (openclaw agent --local)
|
|
300
317
|
// ------------------------------------------------------------------
|
|
301
318
|
|
|
319
|
+
/**
|
|
320
|
+
* Run the turn; when OpenClaw refuses to start over an unmigrated state
|
|
321
|
+
* store, run its Doctor repair once and retry. Doctor archives what it
|
|
322
|
+
* migrates rather than deleting it.
|
|
323
|
+
*/
|
|
324
|
+
async _runCliAgentWithMigration(userMessage, channel) {
|
|
325
|
+
try {
|
|
326
|
+
return await this._runCliAgent(userMessage, channel);
|
|
327
|
+
} catch (e) {
|
|
328
|
+
// At most one repair per turn; a repair that failed is not retried on
|
|
329
|
+
// every later message.
|
|
330
|
+
if (!needsDoctorMigration(e && e.message) || this._doctorRepairFailed) throw e;
|
|
331
|
+
this._log('OpenClaw needs a state migration — running openclaw doctor --fix --non-interactive');
|
|
332
|
+
await this.sendStatus(channel, 'Migrating OpenClaw local data...').catch(() => {});
|
|
333
|
+
const repair = await this._runDoctorRepair();
|
|
334
|
+
this._log(`Doctor repair ${repair.ok ? 'finished' : `failed: ${repair.detail}`}`);
|
|
335
|
+
if (!repair.ok) {
|
|
336
|
+
this._doctorRepairFailed = true;
|
|
337
|
+
throw e;
|
|
338
|
+
}
|
|
339
|
+
return this._runCliAgent(userMessage, channel);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** `openclaw doctor --fix --non-interactive`, resolved to {ok, detail}. */
|
|
344
|
+
_runDoctorRepair() {
|
|
345
|
+
return new Promise((resolve) => {
|
|
346
|
+
const binary = this._openclawBinary || this._findOpenclawBinary();
|
|
347
|
+
if (!binary) { resolve({ ok: false, detail: 'OpenClaw binary not found' }); return; }
|
|
348
|
+
const { spawnBin, spawnArgs } = this._spawnTarget(binary, ['doctor', '--fix', '--non-interactive']);
|
|
349
|
+
let tail = '';
|
|
350
|
+
const keepTail = (d) => { tail = (tail + d).slice(-300); };
|
|
351
|
+
let proc;
|
|
352
|
+
try {
|
|
353
|
+
proc = spawn(spawnBin, spawnArgs, {
|
|
354
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
355
|
+
env: this._spawnEnv(),
|
|
356
|
+
cwd: this.workingDir || process.env.HOME || '/',
|
|
357
|
+
timeout: DOCTOR_REPAIR_TIMEOUT_MS,
|
|
358
|
+
windowsHide: true,
|
|
359
|
+
});
|
|
360
|
+
} catch (err) {
|
|
361
|
+
resolve({ ok: false, detail: err.message });
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
proc.stdout.on('data', keepTail);
|
|
365
|
+
proc.stderr.on('data', keepTail);
|
|
366
|
+
proc.on('error', (err) => resolve({ ok: false, detail: err.message }));
|
|
367
|
+
proc.on('exit', (code) => resolve({ ok: code === 0, detail: `exit ${code}: ${tail.trim()}` }));
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** The child environment for an `openclaw` run. */
|
|
372
|
+
_spawnEnv() {
|
|
373
|
+
const spawnEnv = { ...(this.agentEnv || process.env) };
|
|
374
|
+
if (IS_WINDOWS) {
|
|
375
|
+
const nodeBinDir = path.dirname(process.execPath);
|
|
376
|
+
const npmBin = path.join(process.env.APPDATA || '', 'npm');
|
|
377
|
+
const portableDir = path.join(os.homedir(), '.openagents', 'nodejs');
|
|
378
|
+
const runtimeBin = path.join(getRuntimePrefix('openclaw'), 'node_modules', '.bin');
|
|
379
|
+
for (const p of [runtimeBin, nodeBinDir, npmBin, portableDir]) {
|
|
380
|
+
if (p && !(spawnEnv.PATH || '').includes(p)) {
|
|
381
|
+
spawnEnv.PATH = p + path.delimiter + (spawnEnv.PATH || '');
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return spawnEnv;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* How to start `openclaw <args>`: always node + openclaw.mjs directly (no
|
|
390
|
+
* shims, no cmd.exe, cross-platform). This avoids Windows .cmd shim issues
|
|
391
|
+
* and Unicode path encoding problems.
|
|
392
|
+
*/
|
|
393
|
+
_spawnTarget(binary, args) {
|
|
394
|
+
const portableDir = path.join(os.homedir(), '.openagents', 'nodejs');
|
|
395
|
+
// Unified path first (symlink on Unix), then legacy bin/ fallback, then system node
|
|
396
|
+
const nodeUnified = path.join(portableDir, IS_WINDOWS ? 'node.exe' : 'node');
|
|
397
|
+
let nodeBin = fs.existsSync(nodeUnified) ? nodeUnified : path.join(portableDir, 'bin', 'node');
|
|
398
|
+
if (!fs.existsSync(nodeBin)) nodeBin = whereBinary('node') || 'node';
|
|
399
|
+
|
|
400
|
+
// binary from _findOpenclawBinary() is already resolved to .mjs when possible
|
|
401
|
+
if (binary && binary.endsWith('.mjs')) {
|
|
402
|
+
// Direct node + .mjs invocation (works for managed, legacy, AND global installs)
|
|
403
|
+
return { spawnBin: nodeBin, spawnArgs: [binary, ...args] };
|
|
404
|
+
}
|
|
405
|
+
// Check managed locations explicitly
|
|
406
|
+
const runtimeMjs = path.join(getRuntimePrefix('openclaw'), 'node_modules', 'openclaw', 'openclaw.mjs');
|
|
407
|
+
const legacyMjs = path.join(portableDir, 'node_modules', 'openclaw', 'openclaw.mjs');
|
|
408
|
+
const openclawMjs = fs.existsSync(runtimeMjs) ? runtimeMjs : (fs.existsSync(legacyMjs) ? legacyMjs : null);
|
|
409
|
+
if (openclawMjs) return { spawnBin: nodeBin, spawnArgs: [openclawMjs, ...args] };
|
|
410
|
+
// Last resort: spawn binary directly with shell (handles .cmd on Windows)
|
|
411
|
+
return { spawnBin: binary, spawnArgs: args };
|
|
412
|
+
}
|
|
413
|
+
|
|
302
414
|
_runCliAgent(userMessage, channel) {
|
|
303
415
|
return new Promise((resolve, reject) => {
|
|
304
416
|
// Stopped while this turn was being prepared: start nothing (no tokens).
|
|
@@ -333,18 +445,7 @@ class OpenClawAdapter extends BaseAdapter {
|
|
|
333
445
|
|
|
334
446
|
this._log(`CLI: ${binary} ${args.slice(0, 5).join(' ')} ...`);
|
|
335
447
|
|
|
336
|
-
const spawnEnv =
|
|
337
|
-
if (IS_WINDOWS) {
|
|
338
|
-
const nodeBinDir = path.dirname(process.execPath);
|
|
339
|
-
const npmBin = path.join(process.env.APPDATA || '', 'npm');
|
|
340
|
-
const portableDir2 = path.join(os.homedir(), '.openagents', 'nodejs');
|
|
341
|
-
const runtimeBin = path.join(getRuntimePrefix('openclaw'), 'node_modules', '.bin');
|
|
342
|
-
for (const p of [runtimeBin, nodeBinDir, npmBin, portableDir2]) {
|
|
343
|
-
if (p && !(spawnEnv.PATH || '').includes(p)) {
|
|
344
|
-
spawnEnv.PATH = p + path.delimiter + (spawnEnv.PATH || '');
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
448
|
+
const spawnEnv = this._spawnEnv();
|
|
348
449
|
|
|
349
450
|
// Tool name → human-readable status
|
|
350
451
|
const toolLabels = {
|
|
@@ -382,34 +483,7 @@ class OpenClawAdapter extends BaseAdapter {
|
|
|
382
483
|
const stderrFd = fs.openSync(stderrFile, 'w');
|
|
383
484
|
this._log('Spawn: stderr → ' + stderrFile);
|
|
384
485
|
|
|
385
|
-
|
|
386
|
-
// This avoids Windows .cmd shim issues and Unicode path encoding problems.
|
|
387
|
-
const portableDir = path.join(os.homedir(), '.openagents', 'nodejs');
|
|
388
|
-
// Unified path first (symlink on Unix), then legacy bin/ fallback, then system node
|
|
389
|
-
const nodeUnified = path.join(portableDir, IS_WINDOWS ? 'node.exe' : 'node');
|
|
390
|
-
let nodeBin = fs.existsSync(nodeUnified) ? nodeUnified : path.join(portableDir, 'bin', 'node');
|
|
391
|
-
if (!fs.existsSync(nodeBin)) nodeBin = whereBinary('node') || 'node';
|
|
392
|
-
|
|
393
|
-
// binary from _findOpenclawBinary() is already resolved to .mjs when possible
|
|
394
|
-
let spawnBin, spawnArgs;
|
|
395
|
-
if (binary && binary.endsWith('.mjs')) {
|
|
396
|
-
// Direct node + .mjs invocation (works for managed, legacy, AND global installs)
|
|
397
|
-
spawnBin = nodeBin;
|
|
398
|
-
spawnArgs = [binary, ...args];
|
|
399
|
-
} else {
|
|
400
|
-
// Check managed locations explicitly
|
|
401
|
-
const runtimeMjs = path.join(getRuntimePrefix('openclaw'), 'node_modules', 'openclaw', 'openclaw.mjs');
|
|
402
|
-
const legacyMjs = path.join(portableDir, 'node_modules', 'openclaw', 'openclaw.mjs');
|
|
403
|
-
const openclawMjs = fs.existsSync(runtimeMjs) ? runtimeMjs : (fs.existsSync(legacyMjs) ? legacyMjs : null);
|
|
404
|
-
if (openclawMjs) {
|
|
405
|
-
spawnBin = nodeBin;
|
|
406
|
-
spawnArgs = [openclawMjs, ...args];
|
|
407
|
-
} else {
|
|
408
|
-
// Last resort: spawn binary directly with shell (handles .cmd on Windows)
|
|
409
|
-
spawnBin = binary;
|
|
410
|
-
spawnArgs = args;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
486
|
+
const { spawnBin, spawnArgs } = this._spawnTarget(binary, args);
|
|
413
487
|
const proc = spawn(spawnBin, spawnArgs, {
|
|
414
488
|
stdio: ['ignore', 'pipe', stderrFd],
|
|
415
489
|
env: spawnEnv,
|
|
@@ -703,3 +777,4 @@ class OpenClawAdapter extends BaseAdapter {
|
|
|
703
777
|
|
|
704
778
|
module.exports = OpenClawAdapter;
|
|
705
779
|
module.exports.retireOwnLegacyAuthProfiles = retireOwnLegacyAuthProfiles;
|
|
780
|
+
module.exports.needsDoctorMigration = needsDoctorMigration;
|
package/src/env.js
CHANGED
|
@@ -203,15 +203,36 @@ function modelKeys(agentType, registry) {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
|
-
*
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
206
|
+
* Whether the agent's own env carries a key (not just an endpoint).
|
|
207
|
+
*/
|
|
208
|
+
function hasOwnKey(agentType, registry, agentEnv) {
|
|
209
|
+
if (!agentEnv) return false;
|
|
210
|
+
for (const key of credentialKeys(agentType, registry)) {
|
|
211
|
+
if (/BASE_URL$/.test(key)) continue;
|
|
212
|
+
if (String(agentEnv[key] == null ? '' : agentEnv[key]).trim()) return true;
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* The part of <type>.env an agent runs on. All of it for an agent that brings
|
|
219
|
+
* no credentials of its own.
|
|
220
|
+
*
|
|
221
|
+
* A signed-in agent, or one with a key of its own, takes none of the type's
|
|
222
|
+
* keys or endpoints, and none of its model either: that model was picked for
|
|
223
|
+
* the type key's endpoint (a relay's openai-gpt-oss-20b), which neither the
|
|
224
|
+
* account behind a sign-in nor the agent's own provider serves. Resolution
|
|
225
|
+
* maps the generic LLM_* names over the provider ones, so a relay left in
|
|
226
|
+
* <type>.env used to override an agent configured for DeepSeek: its
|
|
227
|
+
* LLM_BASE_URL and LLM_MODEL became PI_BASE_URL and PI_MODEL, and the agent's
|
|
228
|
+
* key went to the relay. Its model is the one in its own env, else the CLI's
|
|
229
|
+
* default.
|
|
211
230
|
*/
|
|
212
231
|
function typeEnvFor(agentType, typeEnv, registry, agentEnv) {
|
|
213
|
-
|
|
214
|
-
|
|
232
|
+
const signedIn = isCliLogin(agentEnv);
|
|
233
|
+
if (!signedIn && !hasOwnKey(agentType, registry, agentEnv)) return typeEnv;
|
|
234
|
+
const out = { ...typeEnv };
|
|
235
|
+
for (const key of credentialKeys(agentType, registry)) delete out[key];
|
|
215
236
|
for (const key of modelKeys(agentType, registry)) delete out[key];
|
|
216
237
|
return out;
|
|
217
238
|
}
|