@zoraxylia/dsh-codex-adapter 0.1.11 → 0.1.13

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.11",
3
+ "version": "0.1.13",
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.11" });
15072
+ var server = new McpServer({ name: "dsh-adapter", version: "0.1.13" });
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.11",
3
+ "version": "0.1.13",
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,6 +171,15 @@ 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
  }
174
+ const configFile = join(home, '.codex', 'config.toml');
175
+ if (existsSync(configFile)) {
176
+ const before = readFileSync(configFile, 'utf8');
177
+ if (before.includes('[mcp_servers.dsh-adapter]')) {
178
+ backup(configFile);
179
+ writeFileSync(configFile, removeCodexMcp(before));
180
+ actions.push('mcp: removed dsh-adapter from config.toml (backup kept)');
181
+ }
182
+ }
173
183
  return { ok: true, actions: actions.length ? actions : ['nothing to remove'] };
174
184
  }
175
185
 
@@ -271,6 +281,50 @@ export async function installClaudeCode({ home = homedir(), statusline = false }
271
281
  return { ok: true, actions };
272
282
  }
273
283
 
284
+
285
+ /** Global Codex MCP entry: the desktop client and any plain session can call
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';
293
+ }
294
+
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() {
298
+ try {
299
+ const which = process.platform === 'win32' ? 'where' : 'which';
300
+ 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';
305
+ }
306
+
307
+ function upsertCodexMcp(text, serverPath) {
308
+ const block = codexMcpBlock(serverPath);
309
+ const lines = text.split(/\r?\n/);
310
+ const start = lines.findIndex((line) => line.trim() === '[mcp_servers.dsh-adapter]');
311
+ if (start === -1) return (text.trimEnd() ? text.trimEnd() + '\n\n' : '') + block;
312
+ let end = start + 1;
313
+ while (end < lines.length && !/^\s*\[/.test(lines[end])) end += 1;
314
+ const before = lines.slice(0, start).join('\n').trimEnd();
315
+ const after = lines.slice(end).join('\n').trim();
316
+ return [before, block.trimEnd(), after].filter(Boolean).join('\n\n') + '\n';
317
+ }
318
+
319
+ function removeCodexMcp(text) {
320
+ const lines = text.split(/\r?\n/);
321
+ const start = lines.findIndex((line) => line.trim() === '[mcp_servers.dsh-adapter]');
322
+ if (start === -1) return text;
323
+ let end = start + 1;
324
+ while (end < lines.length && !/^\s*\[/.test(lines[end])) end += 1;
325
+ return [...lines.slice(0, start), ...lines.slice(end)].join('\n');
326
+ }
327
+
274
328
  export function installCodex({ home = homedir(), scope } = {}) {
275
329
  const actions = [];
276
330
  const agentsDir = scope === 'project' ? join(process.cwd(), '.codex', 'agents') : join(home, '.codex', 'agents');
@@ -292,6 +346,24 @@ export function installCodex({ home = homedir(), scope } = {}) {
292
346
  writeFileSync(join(promptsDir, f), readFileSync(join(promptsSrc, f), 'utf8'));
293
347
  actions.push(`prompt: ${join(promptsDir, f)}`);
294
348
  }
349
+ // The desktop client has no subagent spawn UI; a global MCP entry lets any
350
+ // session call dsh_run_worker directly. Agent roles above stay for the CLI.
351
+ try {
352
+ const configFile = join(home, '.codex', 'config.toml');
353
+ mkdirSync(dirname(configFile), { recursive: true });
354
+ const before = existsSync(configFile) ? readFileSync(configFile, 'utf8') : '';
355
+ const bak = backup(configFile);
356
+ if (bak) actions.push(`backup: ${bak}`);
357
+ const next = upsertCodexMcp(before, join(ROOT, 'src', 'server.mjs'));
358
+ if (next !== before) {
359
+ writeFileSync(configFile, next);
360
+ actions.push('mcp: registered dsh-adapter globally (approve, 3600s) — restart Codex to load it');
361
+ } else {
362
+ actions.push('mcp: dsh-adapter already registered');
363
+ }
364
+ } catch (err) {
365
+ actions.push(`mcp: registration failed — ${String(err?.message ?? err).slice(0, 160)}`);
366
+ }
295
367
  return { ok: true, actions };
296
368
  }
297
369
 
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.11' });
15
+ const server = new McpServer({ name: 'dsh-adapter', version: '0.1.13' });
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).');