@zoraxylia/dsh-codex-adapter 0.1.12 → 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.12",
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.12" });
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.12",
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.",
@@ -6,6 +6,7 @@ import { readFileSync, writeFileSync, mkdirSync, copyFileSync, existsSync, readd
6
6
  import { dirname, join, resolve, relative } from 'node:path';
7
7
  import { fileURLToPath } from 'node:url';
8
8
  import { homedir } from 'node:os';
9
+ import { execFileSync } from 'node:child_process';
9
10
 
10
11
  const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..');
11
12
  const MARKETPLACE_NAME = 'dsh-adapter';
@@ -170,7 +171,7 @@ export function uninstallCodex({ home = homedir() } = {}) {
170
171
  const p = join(home, '.codex', 'prompts', f);
171
172
  if (existsSync(p)) { rmSync(p); actions.push(`removed: ${p}`); }
172
173
  }
173
- const configFile = join(home, '.codex', 'config.toml');
174
+ const configFile = join(process.env.CODEX_HOME || join(home, '.codex'), 'config.toml');
174
175
  if (existsSync(configFile)) {
175
176
  const before = readFileSync(configFile, 'utf8');
176
177
  if (before.includes('[mcp_servers.dsh-adapter]')) {
@@ -283,16 +284,93 @@ export async function installClaudeCode({ home = homedir(), statusline = false }
283
284
 
284
285
  /** Global Codex MCP entry: the desktop client and any plain session can call
285
286
  * the worker tools without spawning a subagent first. */
286
- function codexMcpBlock(serverPath) {
287
- return '[mcp_servers.dsh-adapter]\n'
288
- + 'command = "node"\n'
289
- + `args = [${tomlString(serverPath)}]\n`
290
- + 'default_tools_approval_mode = "approve"\n'
291
- + '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';
292
301
  }
293
302
 
294
- function upsertCodexMcp(text, serverPath) {
295
- const block = codexMcpBlock(serverPath);
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' };
357
+ try {
358
+ const which = process.platform === 'win32' ? 'where' : 'which';
359
+ const out = execFileSync(which, ['node'], { encoding: 'utf8', timeout: 5000 });
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' };
370
+ }
371
+
372
+ function upsertCodexMcp(text, serverPath, launcher = { command: 'node', source: 'fallback' }) {
373
+ const block = codexMcpBlock(serverPath, launcher);
296
374
  const lines = text.split(/\r?\n/);
297
375
  const start = lines.findIndex((line) => line.trim() === '[mcp_servers.dsh-adapter]');
298
376
  if (start === -1) return (text.trimEnd() ? text.trimEnd() + '\n\n' : '') + block;
@@ -336,15 +414,16 @@ export function installCodex({ home = homedir(), scope } = {}) {
336
414
  // The desktop client has no subagent spawn UI; a global MCP entry lets any
337
415
  // session call dsh_run_worker directly. Agent roles above stay for the CLI.
338
416
  try {
339
- const configFile = join(home, '.codex', 'config.toml');
417
+ const configFile = join(process.env.CODEX_HOME || join(home, '.codex'), 'config.toml');
340
418
  mkdirSync(dirname(configFile), { recursive: true });
341
419
  const before = existsSync(configFile) ? readFileSync(configFile, 'utf8') : '';
342
420
  const bak = backup(configFile);
343
421
  if (bak) actions.push(`backup: ${bak}`);
344
- const next = upsertCodexMcp(before, join(ROOT, 'src', 'server.mjs'));
422
+ const launcher = resolveNodeLauncher();
423
+ const next = upsertCodexMcp(before, join(ROOT, 'src', 'server.mjs'), launcher);
345
424
  if (next !== before) {
346
425
  writeFileSync(configFile, next);
347
- actions.push('mcp: registered dsh-adapter globally (approve, 3600s)');
426
+ actions.push(`mcp: registered dsh-adapter globally (launcher: ${launcher.source}, approve, 3600s) — restart Codex to load it`);
348
427
  } else {
349
428
  actions.push('mcp: dsh-adapter already registered');
350
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.12' });
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).');