@zoraxylia/dsh-codex-adapter 0.1.13 → 0.1.15

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.15",
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/client.js CHANGED
@@ -404,6 +404,8 @@ const COPY = {
404
404
  title: "DSH Adapter",
405
405
  intro: "Claude Code / Codex 可以给 DSH agent 分派任务,在宿主里显示为原生子代理、进度可见。配置派发默认值、执行方式,以及接入视觉与生图能力,一键装进宿主。",
406
406
  integrations: "集成",
407
+ globalMcp: "Codex 全局 MCP(CLI 与桌面端都可直接调用)",
408
+ globalMcpHint: "关闭后只安装 ds-flash / ds-pro 子代理角色,不注册全局 MCP;桌面端将无法直接调用。",
407
409
  collapse: "折叠",
408
410
  expand: "展开",
409
411
  doneAt: (t) => `已更新 · ${t}`,
@@ -574,6 +576,8 @@ const COPY = {
574
576
  title: "DSH Adapter",
575
577
  intro: "Claude Code / Codex can dispatch tasks to DSH agents and see them as native subagents in the host with live progress. Configure dispatch defaults, execution mode, and vision / image-generation access, then install into the host in one click.",
576
578
  integrations: "Integrations",
579
+ globalMcp: "Codex global MCP (callable from both CLI and the desktop client)",
580
+ globalMcpHint: "When off, only the ds-flash / ds-pro agent roles are installed; the desktop client cannot call the worker tools directly.",
577
581
  collapse: "Collapse",
578
582
  expand: "Expand",
579
583
  doneAt: (t) => `Updated · ${t}`,
@@ -1799,7 +1803,34 @@ function WorkersPanel({ ctx }) {
1799
1803
  }) : null, "claude", "claude-uninstall", copy.tips.claude),
1800
1804
  integrationRow("Codex", !!status?.codex?.installed, null, "codex", "codex-uninstall", copy.tips.codex),
1801
1805
  integrationRow("Antigravity", !!status?.agy?.installed, null, "agy", "agy-uninstall", copy.tips.agy),
1802
- integrationRow("Grok", !!status?.grok?.installed, null, "grok", "grok-uninstall", copy.tips.grok)
1806
+ integrationRow("Grok", !!status?.grok?.installed, null, "grok", "grok-uninstall", copy.tips.grok),
1807
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1808
+ style: {
1809
+ display: "flex",
1810
+ alignItems: "center",
1811
+ gap: 6,
1812
+ fontSize: 12,
1813
+ paddingLeft: 2,
1814
+ opacity: config ? 1 : .5
1815
+ },
1816
+ title: copy.globalMcpHint,
1817
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1818
+ type: "checkbox",
1819
+ checked: config?.codex_global_mcp !== false,
1820
+ disabled: busy || !config,
1821
+ onChange: (e) => {
1822
+ const on = e.target.checked;
1823
+ setConfig((c) => ({
1824
+ ...c,
1825
+ codex_global_mcp: on
1826
+ }));
1827
+ post("/config", { codex_global_mcp: on }).then((r) => {
1828
+ if (r.ok) setConfig(r.config);
1829
+ if (status?.codex?.installed) act("codex");
1830
+ });
1831
+ }
1832
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: copy.globalMcp })]
1833
+ })
1803
1834
  ]
1804
1835
  }),
1805
1836
  sectionHeader(copy.globalConfig, globalConfigCollapsed, toggleGlobalConfig),
package/lib/server.mjs CHANGED
@@ -14402,6 +14402,9 @@ var GLOBAL_CONFIG_DEFAULTS = {
14402
14402
  // auto = orchestrator picks the tier; flash-only / pro-only clamp every
14403
14403
  // dispatch to one tier at the tool layer regardless of what was requested.
14404
14404
  tier_policy: "auto",
14405
+ // Register the MCP server globally in ~/.codex/config.toml so the Codex
14406
+ // desktop client (which has no subagent spawn UI) can call the worker tools.
14407
+ codex_global_mcp: true,
14405
14408
  // When a blocking flash run fails, retry the same task once on pro.
14406
14409
  escalate_on_failure: false,
14407
14410
  // Multimodal bridge: which subscription CLI lends the text-only DS model
@@ -15069,7 +15072,7 @@ function describeBindings(config = {}) {
15069
15072
  }
15070
15073
 
15071
15074
  // src/server.mjs
15072
- var server = new McpServer({ name: "dsh-adapter", version: "0.1.13" });
15075
+ var server = new McpServer({ name: "dsh-adapter", version: "0.1.15" });
15073
15076
  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
15077
  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
15078
  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.15",
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.",
@@ -88,6 +88,8 @@ const COPY = {
88
88
  title: 'DSH Adapter',
89
89
  intro: 'Claude Code / Codex 可以给 DSH agent 分派任务,在宿主里显示为原生子代理、进度可见。配置派发默认值、执行方式,以及接入视觉与生图能力,一键装进宿主。',
90
90
  integrations: '集成',
91
+ globalMcp: 'Codex 全局 MCP(CLI 与桌面端都可直接调用)',
92
+ globalMcpHint: '关闭后只安装 ds-flash / ds-pro 子代理角色,不注册全局 MCP;桌面端将无法直接调用。',
91
93
  collapse: '折叠', expand: '展开',
92
94
  doneAt: (t: string) => `已更新 · ${t}`,
93
95
  installed: '已安装', notInstalled: '未安装', hud: 'HUD 段',
@@ -182,6 +184,8 @@ const COPY = {
182
184
  title: 'DSH Adapter',
183
185
  intro: 'Claude Code / Codex can dispatch tasks to DSH agents and see them as native subagents in the host with live progress. Configure dispatch defaults, execution mode, and vision / image-generation access, then install into the host in one click.',
184
186
  integrations: 'Integrations',
187
+ globalMcp: 'Codex global MCP (callable from both CLI and the desktop client)',
188
+ globalMcpHint: 'When off, only the ds-flash / ds-pro agent roles are installed; the desktop client cannot call the worker tools directly.',
185
189
  collapse: 'Collapse', expand: 'Expand',
186
190
  doneAt: (t: string) => `Updated · ${t}`,
187
191
  installed: 'installed', notInstalled: 'not installed', hud: 'HUD segment',
@@ -813,6 +817,19 @@ function WorkersPanel({ ctx }: { ctx: any }) {
813
817
  {integrationRow('Codex', !!status?.codex?.installed, null, 'codex', 'codex-uninstall', (copy as any).tips.codex)}
814
818
  {integrationRow('Antigravity', !!status?.agy?.installed, null, 'agy', 'agy-uninstall', (copy as any).tips.agy)}
815
819
  {integrationRow('Grok', !!status?.grok?.installed, null, 'grok', 'grok-uninstall', (copy as any).tips.grok)}
820
+ <label style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 12, paddingLeft: 2, opacity: config ? 1 : 0.5 }}
821
+ title={copy.globalMcpHint}>
822
+ <input type="checkbox" checked={config?.codex_global_mcp !== false} disabled={busy || !config}
823
+ onChange={(e) => {
824
+ const on = e.target.checked;
825
+ setConfig((c: any) => ({ ...c, codex_global_mcp: on }));
826
+ void post('/config', { codex_global_mcp: on }).then((r) => {
827
+ if (r.ok) setConfig(r.config);
828
+ if (status?.codex?.installed) void act('codex');
829
+ });
830
+ }} />
831
+ <span>{copy.globalMcp}</span>
832
+ </label>
816
833
  </div>
817
834
  )}
818
835
 
package/src/hub/index.mjs CHANGED
@@ -890,7 +890,7 @@ export async function apply(ctx) {
890
890
  actions: [...base.actions, ...hud.actions.map((a) => `hud: ${a}`)],
891
891
  });
892
892
  }
893
- if (target === 'codex') return sendJson(res, 200, installCodex({}));
893
+ if (target === 'codex') return sendJson(res, 200, installCodex({ globalMcp: hub.getConfig().codex_global_mcp !== false }));
894
894
  if (target === 'agy') return sendJson(res, 200, installAgy({}));
895
895
  if (target === 'grok') return sendJson(res, 200, installGrok({}));
896
896
  if (target === 'claude-uninstall') return sendJson(res, 200, await uninstallClaudeCode({}));
@@ -83,6 +83,9 @@ export const GLOBAL_CONFIG_DEFAULTS = {
83
83
  // auto = orchestrator picks the tier; flash-only / pro-only clamp every
84
84
  // dispatch to one tier at the tool layer regardless of what was requested.
85
85
  tier_policy: 'auto',
86
+ // Register the MCP server globally in ~/.codex/config.toml so the Codex
87
+ // desktop client (which has no subagent spawn UI) can call the worker tools.
88
+ codex_global_mcp: true,
86
89
  // When a blocking flash run fails, retry the same task once on pro.
87
90
  escalate_on_failure: false,
88
91
  // Multimodal bridge: which subscription CLI lends the text-only DS model
@@ -171,7 +174,7 @@ export function uninstallCodex({ home = homedir() } = {}) {
171
174
  const p = join(home, '.codex', 'prompts', f);
172
175
  if (existsSync(p)) { rmSync(p); actions.push(`removed: ${p}`); }
173
176
  }
174
- const configFile = join(home, '.codex', 'config.toml');
177
+ const configFile = join(process.env.CODEX_HOME || join(home, '.codex'), 'config.toml');
175
178
  if (existsSync(configFile)) {
176
179
  const before = readFileSync(configFile, 'utf8');
177
180
  if (before.includes('[mcp_servers.dsh-adapter]')) {
@@ -284,28 +287,93 @@ export async function installClaudeCode({ home = homedir(), statusline = false }
284
287
 
285
288
  /** Global Codex MCP entry: the desktop client and any plain session can call
286
289
  * 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';
290
+ function codexMcpBlock(serverPath, launcher) {
291
+ const lines = [
292
+ '[mcp_servers.dsh-adapter]',
293
+ `command = ${tomlString(launcher.command)}`,
294
+ `args = [${tomlString(serverPath)}]`,
295
+ 'default_tools_approval_mode = "approve"',
296
+ 'tool_timeout_sec = 3600',
297
+ ];
298
+ const env = launcher.env ?? {};
299
+ if (Object.keys(env).length > 0) {
300
+ lines.push('', '[mcp_servers.dsh-adapter.env]');
301
+ for (const [key, value] of Object.entries(env)) lines.push(`${key} = ${tomlString(value)}`);
302
+ }
303
+ return lines.join('\n') + '\n';
293
304
  }
294
305
 
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() {
306
+ /** True when this binary runs a Node the plugin's server can use. */
307
+ function nodeUsable(binary) {
308
+ try {
309
+ const out = execFileSync(binary, ['-v'], { encoding: 'utf8', timeout: 5000 }).trim();
310
+ const major = Number(/^v(\d+)/.exec(out)?.[1] ?? 0);
311
+ return major >= 18;
312
+ } catch { return false; }
313
+ }
314
+
315
+ /** Any node.exe shipped inside the DSH app resources. */
316
+ function findBundledNode() {
317
+ const roots = [
318
+ join(dirname(process.execPath), 'resources', 'runtime'),
319
+ join(dirname(process.execPath), 'resources'),
320
+ ];
321
+ const names = process.platform === 'win32' ? ['node.exe'] : ['node'];
322
+ const walk = (dir, depth) => {
323
+ if (depth > 4) return undefined;
324
+ let entries = [];
325
+ try { entries = readdirSync(dir, { withFileTypes: true }); } catch { return undefined; }
326
+ for (const entry of entries) {
327
+ const full = join(dir, entry.name);
328
+ if (entry.isFile() && names.includes(entry.name)) {
329
+ if (nodeUsable(full)) return full;
330
+ }
331
+ }
332
+ for (const entry of entries) {
333
+ if (entry.isDirectory()) {
334
+ const found = walk(join(dir, entry.name), depth + 1);
335
+ if (found) return found;
336
+ }
337
+ }
338
+ return undefined;
339
+ };
340
+ for (const root of roots) {
341
+ const found = walk(root, 0);
342
+ if (found) return found;
343
+ }
344
+ return undefined;
345
+ }
346
+
347
+ /**
348
+ * Which binary should launch the MCP server on this machine. A GUI client's
349
+ * PATH often lacks the shim a terminal has, and a machine that runs DSH does
350
+ * not necessarily have Node installed at all:
351
+ * 1. explicit override DSH_ADAPTER_NODE
352
+ * 2. a system node >= 18
353
+ * 3. a node bundled inside DSH
354
+ * 4. the DSH Electron binary in ELECTRON_RUN_AS_NODE mode
355
+ * 5. bare "node" (last resort; the action line says what happened)
356
+ */
357
+ function resolveNodeLauncher() {
358
+ const override = process.env.DSH_ADAPTER_NODE;
359
+ if (override && existsSync(override) && nodeUsable(override)) return { command: override, source: 'env' };
298
360
  try {
299
361
  const which = process.platform === 'win32' ? 'where' : 'which';
300
362
  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';
363
+ for (const line of out.split(/\r?\n/).map((l) => l.trim()).filter(Boolean)) {
364
+ if (existsSync(line) && nodeUsable(line)) return { command: line, source: 'system' };
365
+ }
366
+ } catch { /* keep looking */ }
367
+ const bundled = findBundledNode();
368
+ if (bundled) return { command: bundled, source: 'bundled' };
369
+ if (process.versions?.electron && existsSync(process.execPath)) {
370
+ return { command: process.execPath, env: { ELECTRON_RUN_AS_NODE: '1' }, source: 'electron' };
371
+ }
372
+ return { command: 'node', source: 'fallback' };
305
373
  }
306
374
 
307
- function upsertCodexMcp(text, serverPath) {
308
- const block = codexMcpBlock(serverPath);
375
+ function upsertCodexMcp(text, serverPath, launcher = { command: 'node', source: 'fallback' }) {
376
+ const block = codexMcpBlock(serverPath, launcher);
309
377
  const lines = text.split(/\r?\n/);
310
378
  const start = lines.findIndex((line) => line.trim() === '[mcp_servers.dsh-adapter]');
311
379
  if (start === -1) return (text.trimEnd() ? text.trimEnd() + '\n\n' : '') + block;
@@ -325,7 +393,7 @@ function removeCodexMcp(text) {
325
393
  return [...lines.slice(0, start), ...lines.slice(end)].join('\n');
326
394
  }
327
395
 
328
- export function installCodex({ home = homedir(), scope } = {}) {
396
+ export function installCodex({ home = homedir(), scope, globalMcp = true } = {}) {
329
397
  const actions = [];
330
398
  const agentsDir = scope === 'project' ? join(process.cwd(), '.codex', 'agents') : join(home, '.codex', 'agents');
331
399
  mkdirSync(agentsDir, { recursive: true });
@@ -349,15 +417,27 @@ export function installCodex({ home = homedir(), scope } = {}) {
349
417
  // The desktop client has no subagent spawn UI; a global MCP entry lets any
350
418
  // session call dsh_run_worker directly. Agent roles above stay for the CLI.
351
419
  try {
352
- const configFile = join(home, '.codex', 'config.toml');
420
+ const configFile = join(process.env.CODEX_HOME || join(home, '.codex'), 'config.toml');
353
421
  mkdirSync(dirname(configFile), { recursive: true });
354
422
  const before = existsSync(configFile) ? readFileSync(configFile, 'utf8') : '';
423
+ if (!globalMcp) {
424
+ if (before.includes('[mcp_servers.dsh-adapter]')) {
425
+ const bak = backup(configFile);
426
+ if (bak) actions.push(`backup: ${bak}`);
427
+ writeFileSync(configFile, removeCodexMcp(before));
428
+ actions.push('mcp: global registration disabled — entry removed');
429
+ } else {
430
+ actions.push('mcp: global registration disabled');
431
+ }
432
+ return { ok: true, actions };
433
+ }
355
434
  const bak = backup(configFile);
356
435
  if (bak) actions.push(`backup: ${bak}`);
357
- const next = upsertCodexMcp(before, join(ROOT, 'src', 'server.mjs'));
436
+ const launcher = resolveNodeLauncher();
437
+ const next = upsertCodexMcp(before, join(ROOT, 'src', 'server.mjs'), launcher);
358
438
  if (next !== before) {
359
439
  writeFileSync(configFile, next);
360
- actions.push('mcp: registered dsh-adapter globally (approve, 3600s) — restart Codex to load it');
440
+ actions.push(`mcp: registered dsh-adapter globally (launcher: ${launcher.source}, approve, 3600s) — restart Codex to load it`);
361
441
  } else {
362
442
  actions.push('mcp: dsh-adapter already registered');
363
443
  }
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.15' });
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).');