@zoraxylia/dsh-codex-adapter 0.1.13 → 0.1.14

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-adapter",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Dispatch subtasks to DeepSeek Harness (DSH) agents as native subagents with live progress",
5
5
  "author": {
6
6
  "name": "zx-yk"
package/lib/server.mjs CHANGED
@@ -15069,7 +15069,7 @@ function describeBindings(config = {}) {
15069
15069
  }
15070
15070
 
15071
15071
  // src/server.mjs
15072
- var server = new McpServer({ name: "dsh-adapter", version: "0.1.13" });
15072
+ var server = new McpServer({ name: "dsh-adapter", version: "0.1.14" });
15073
15073
  var tierSchema = external_exports.enum(["flash", "pro"]).optional().describe("Worker model tier. flash = mechanical, well-scoped work (single-file edits, lookups, formatting); pro = multi-file changes, debugging, design judgment. Omit to use the session default. Ignored when worker= is set.");
15074
15074
  var effortSchema = external_exports.enum(["off", "high", "max"]).optional().describe("Reasoning effort for the worker. Omit to use the session default. With worker= it only applies when passed explicitly and the profile supports it (agy maps to low/medium/high).");
15075
15075
  var workerSchema = external_exports.string().optional().describe('Named CLI worker profile (e.g. "agy" or "grok"). Explicit opt-in only: set it when the user explicitly asks for that external coding CLI, never as a default. When set, dispatch bypasses tier/mode and runs the task through that CLI; the profile pins backend\xD7model\xD7effort. See dsh_worker_config output, worker_profiles field, for the available profiles.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoraxylia/dsh-codex-adapter",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "type": "module",
5
5
  "main": "./src/hub/index.mjs",
6
6
  "description": "Dispatch tasks from Claude Code / Codex to DSH agents as native subagents with live progress; configure dispatch defaults, execution mode, and vision / image-generation access, installed into the host in one click.",
@@ -171,7 +171,7 @@ export function uninstallCodex({ home = homedir() } = {}) {
171
171
  const p = join(home, '.codex', 'prompts', f);
172
172
  if (existsSync(p)) { rmSync(p); actions.push(`removed: ${p}`); }
173
173
  }
174
- const configFile = join(home, '.codex', 'config.toml');
174
+ const configFile = join(process.env.CODEX_HOME || join(home, '.codex'), 'config.toml');
175
175
  if (existsSync(configFile)) {
176
176
  const before = readFileSync(configFile, 'utf8');
177
177
  if (before.includes('[mcp_servers.dsh-adapter]')) {
@@ -284,28 +284,93 @@ export async function installClaudeCode({ home = homedir(), statusline = false }
284
284
 
285
285
  /** Global Codex MCP entry: the desktop client and any plain session can call
286
286
  * the worker tools without spawning a subagent first. */
287
- function codexMcpBlock(serverPath) {
288
- return '[mcp_servers.dsh-adapter]\n'
289
- + `command = ${tomlString(resolveNodeBinary())}\n`
290
- + `args = [${tomlString(serverPath)}]\n`
291
- + 'default_tools_approval_mode = "approve"\n'
292
- + 'tool_timeout_sec = 3600\n';
287
+ function codexMcpBlock(serverPath, launcher) {
288
+ const lines = [
289
+ '[mcp_servers.dsh-adapter]',
290
+ `command = ${tomlString(launcher.command)}`,
291
+ `args = [${tomlString(serverPath)}]`,
292
+ 'default_tools_approval_mode = "approve"',
293
+ 'tool_timeout_sec = 3600',
294
+ ];
295
+ const env = launcher.env ?? {};
296
+ if (Object.keys(env).length > 0) {
297
+ lines.push('', '[mcp_servers.dsh-adapter.env]');
298
+ for (const [key, value] of Object.entries(env)) lines.push(`${key} = ${tomlString(value)}`);
299
+ }
300
+ return lines.join('\n') + '\n';
293
301
  }
294
302
 
295
- /** Absolute node path: a GUI client's PATH often lacks the shim a terminal
296
- * has, so "node" is not a safe launcher for the registered server. */
297
- function resolveNodeBinary() {
303
+ /** True when this binary runs a Node the plugin's server can use. */
304
+ function nodeUsable(binary) {
305
+ try {
306
+ const out = execFileSync(binary, ['-v'], { encoding: 'utf8', timeout: 5000 }).trim();
307
+ const major = Number(/^v(\d+)/.exec(out)?.[1] ?? 0);
308
+ return major >= 18;
309
+ } catch { return false; }
310
+ }
311
+
312
+ /** Any node.exe shipped inside the DSH app resources. */
313
+ function findBundledNode() {
314
+ const roots = [
315
+ join(dirname(process.execPath), 'resources', 'runtime'),
316
+ join(dirname(process.execPath), 'resources'),
317
+ ];
318
+ const names = process.platform === 'win32' ? ['node.exe'] : ['node'];
319
+ const walk = (dir, depth) => {
320
+ if (depth > 4) return undefined;
321
+ let entries = [];
322
+ try { entries = readdirSync(dir, { withFileTypes: true }); } catch { return undefined; }
323
+ for (const entry of entries) {
324
+ const full = join(dir, entry.name);
325
+ if (entry.isFile() && names.includes(entry.name)) {
326
+ if (nodeUsable(full)) return full;
327
+ }
328
+ }
329
+ for (const entry of entries) {
330
+ if (entry.isDirectory()) {
331
+ const found = walk(join(dir, entry.name), depth + 1);
332
+ if (found) return found;
333
+ }
334
+ }
335
+ return undefined;
336
+ };
337
+ for (const root of roots) {
338
+ const found = walk(root, 0);
339
+ if (found) return found;
340
+ }
341
+ return undefined;
342
+ }
343
+
344
+ /**
345
+ * Which binary should launch the MCP server on this machine. A GUI client's
346
+ * PATH often lacks the shim a terminal has, and a machine that runs DSH does
347
+ * not necessarily have Node installed at all:
348
+ * 1. explicit override DSH_ADAPTER_NODE
349
+ * 2. a system node >= 18
350
+ * 3. a node bundled inside DSH
351
+ * 4. the DSH Electron binary in ELECTRON_RUN_AS_NODE mode
352
+ * 5. bare "node" (last resort; the action line says what happened)
353
+ */
354
+ function resolveNodeLauncher() {
355
+ const override = process.env.DSH_ADAPTER_NODE;
356
+ if (override && existsSync(override) && nodeUsable(override)) return { command: override, source: 'env' };
298
357
  try {
299
358
  const which = process.platform === 'win32' ? 'where' : 'which';
300
359
  const out = execFileSync(which, ['node'], { encoding: 'utf8', timeout: 5000 });
301
- const first = out.split(/\r?\n/).map((line) => line.trim()).filter(Boolean)[0];
302
- if (first && existsSync(first)) return first;
303
- } catch { /* fall back below */ }
304
- return 'node';
360
+ for (const line of out.split(/\r?\n/).map((l) => l.trim()).filter(Boolean)) {
361
+ if (existsSync(line) && nodeUsable(line)) return { command: line, source: 'system' };
362
+ }
363
+ } catch { /* keep looking */ }
364
+ const bundled = findBundledNode();
365
+ if (bundled) return { command: bundled, source: 'bundled' };
366
+ if (process.versions?.electron && existsSync(process.execPath)) {
367
+ return { command: process.execPath, env: { ELECTRON_RUN_AS_NODE: '1' }, source: 'electron' };
368
+ }
369
+ return { command: 'node', source: 'fallback' };
305
370
  }
306
371
 
307
- function upsertCodexMcp(text, serverPath) {
308
- const block = codexMcpBlock(serverPath);
372
+ function upsertCodexMcp(text, serverPath, launcher = { command: 'node', source: 'fallback' }) {
373
+ const block = codexMcpBlock(serverPath, launcher);
309
374
  const lines = text.split(/\r?\n/);
310
375
  const start = lines.findIndex((line) => line.trim() === '[mcp_servers.dsh-adapter]');
311
376
  if (start === -1) return (text.trimEnd() ? text.trimEnd() + '\n\n' : '') + block;
@@ -349,15 +414,16 @@ export function installCodex({ home = homedir(), scope } = {}) {
349
414
  // The desktop client has no subagent spawn UI; a global MCP entry lets any
350
415
  // session call dsh_run_worker directly. Agent roles above stay for the CLI.
351
416
  try {
352
- const configFile = join(home, '.codex', 'config.toml');
417
+ const configFile = join(process.env.CODEX_HOME || join(home, '.codex'), 'config.toml');
353
418
  mkdirSync(dirname(configFile), { recursive: true });
354
419
  const before = existsSync(configFile) ? readFileSync(configFile, 'utf8') : '';
355
420
  const bak = backup(configFile);
356
421
  if (bak) actions.push(`backup: ${bak}`);
357
- const next = upsertCodexMcp(before, join(ROOT, 'src', 'server.mjs'));
422
+ const launcher = resolveNodeLauncher();
423
+ const next = upsertCodexMcp(before, join(ROOT, 'src', 'server.mjs'), launcher);
358
424
  if (next !== before) {
359
425
  writeFileSync(configFile, next);
360
- actions.push('mcp: registered dsh-adapter globally (approve, 3600s) — restart Codex to load it');
426
+ actions.push(`mcp: registered dsh-adapter globally (launcher: ${launcher.source}, approve, 3600s) — restart Codex to load it`);
361
427
  } else {
362
428
  actions.push('mcp: dsh-adapter already registered');
363
429
  }
package/src/server.mjs CHANGED
@@ -12,7 +12,7 @@ import { acquireCwdLock, releaseCwdLockByJobId, updateCwdLockHolder, getCwdLocks
12
12
  import { resolveWorkerCwd } from './paths.mjs';
13
13
  import { detectOrchestrator } from './process-info.mjs';
14
14
 
15
- const server = new McpServer({ name: 'dsh-adapter', version: '0.1.13' });
15
+ const server = new McpServer({ name: 'dsh-adapter', version: '0.1.14' });
16
16
 
17
17
  const tierSchema = z.enum(['flash', 'pro']).optional().describe('Worker model tier. flash = mechanical, well-scoped work (single-file edits, lookups, formatting); pro = multi-file changes, debugging, design judgment. Omit to use the session default. Ignored when worker= is set.');
18
18
  const effortSchema = z.enum(['off', 'high', 'max']).optional().describe('Reasoning effort for the worker. Omit to use the session default. With worker= it only applies when passed explicitly and the profile supports it (agy maps to low/medium/high).');