@zoraxylia/dsh-codex-adapter 0.1.3 → 0.1.5

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.3",
3
+ "version": "0.1.5",
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
@@ -14432,6 +14432,11 @@ var GLOBAL_CONFIG_DEFAULTS = {
14432
14432
  flash_model: "",
14433
14433
  pro_provider: "",
14434
14434
  pro_model: "",
14435
+ // Set when the binding was discovered by the usable-route fallback rather
14436
+ // than chosen by the user; such a binding is re-validated when the default
14437
+ // effort changes instead of being treated as a deliberate pin.
14438
+ flash_auto: false,
14439
+ pro_auto: false,
14435
14440
  // Hub-mode agent preset per tier: 'default' follows the DSH roster default.
14436
14441
  preset_flash: "minimal",
14437
14442
  preset_pro: "default"
@@ -15059,7 +15064,7 @@ function describeBindings(config = {}) {
15059
15064
  }
15060
15065
 
15061
15066
  // src/server.mjs
15062
- var server = new McpServer({ name: "dsh-adapter", version: "0.1.3" });
15067
+ var server = new McpServer({ name: "dsh-adapter", version: "0.1.5" });
15063
15068
  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.");
15064
15069
  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).");
15065
15070
  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.');
@@ -15087,7 +15092,8 @@ var sessionConfig = {
15087
15092
  origin_depth_limit: DEFAULT_ORIGIN_DEPTH_LIMIT
15088
15093
  };
15089
15094
  function bindingForTier(tier) {
15090
- return resolveTierBinding(tier, sessionConfig);
15095
+ const pinned = [sessionConfig[`${tier}_provider`], sessionConfig[`${tier}_model`]].some((v) => typeof v === "string" && v.trim() !== "");
15096
+ return pinned ? resolveTierBinding(tier, sessionConfig) : {};
15091
15097
  }
15092
15098
  function presetForTier(tier) {
15093
15099
  const p = tier === "flash" ? sessionConfig.preset_flash : sessionConfig.preset_pro;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoraxylia/dsh-codex-adapter",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "./src/hub/index.mjs",
6
6
  "description": "DeepSeek Harness plugin: dispatch work to DSH agents from Claude Code / Codex, as native subagents with live progress",
package/src/hub/index.mjs CHANGED
@@ -123,9 +123,9 @@ export class WorkerRegistry {
123
123
  }
124
124
 
125
125
  /** One bounded capability probe; the route counts as usable when it streams. */
126
- async probeRoute(llm, binding) {
126
+ async probeRoute(llm, binding, effort) {
127
127
  try {
128
- const result = await probeProvider(llm, binding, { timeoutMs: 12000 });
128
+ const result = await probeProvider(llm, { ...binding, ...(effort ? { reasoningEffort: effort } : {}) }, { timeoutMs: 12000 });
129
129
  return result.status === 'verified' || result.status === 'no_tool_call';
130
130
  } catch { return false; }
131
131
  }
@@ -138,17 +138,18 @@ export class WorkerRegistry {
138
138
  * first route that streams, and persist it so later dispatches skip the
139
139
  * search. Pinned bindings never reach this path.
140
140
  */
141
- async resolveUsableTier(tier, bound) {
141
+ async resolveUsableTier(tier, bound, effort) {
142
142
  this.autoTier ??= {};
143
- if (this.autoTier[tier]) return this.autoTier[tier];
143
+ const cacheKey = tier + ':' + effort;
144
+ if (this.autoTier[cacheKey]) return this.autoTier[cacheKey];
144
145
  const llm = this.ctx?.get?.('llm') ?? this.ctx?.llm;
145
- if (!llm) return bound;
146
- if (await this.probeRoute(llm, bound)) { this.autoTier[tier] = bound; return bound; }
146
+ if (!llm) return { binding: bound, effort };
147
+ if (await this.probeRoute(llm, bound, effort)) { this.autoTier[cacheKey] = { binding: bound, effort }; return this.autoTier[cacheKey]; }
147
148
  const builtin = new Set(['deepseek-official', 'deepseek-account']);
148
149
  let ids = [];
149
150
  try {
150
151
  ids = llm.listProviders().map((p) => p.id).filter((id) => id !== bound.provider);
151
- } catch { return bound; }
152
+ } catch { return { binding: bound, effort }; }
152
153
  ids.sort((a, b) => Number(builtin.has(a)) - Number(builtin.has(b)));
153
154
  const candidates = [];
154
155
  for (const id of ids) {
@@ -157,18 +158,25 @@ export class WorkerRegistry {
157
158
  for (const m of models.slice(0, 3)) candidates.push({ provider: id, model: m.id });
158
159
  if (candidates.length >= 5) break;
159
160
  }
160
- for (const candidate of candidates) {
161
- if (await this.probeRoute(llm, candidate)) {
162
- this.autoTier[tier] = candidate;
161
+ const attempts = effort && effort !== 'off' ? [effort, 'off'] : [effort];
162
+ for (const attemptEffort of attempts) {
163
+ for (const candidate of candidates) {
164
+ if (!(await this.probeRoute(llm, candidate, attemptEffort))) continue;
165
+ const chosen = { binding: candidate, effort: attemptEffort };
166
+ this.autoTier[cacheKey] = chosen;
163
167
  try {
164
- writeGlobalConfig({ [`${tier}_provider`]: candidate.provider, [`${tier}_model`]: candidate.model });
168
+ writeGlobalConfig({
169
+ [`${tier}_provider`]: candidate.provider,
170
+ [`${tier}_model`]: candidate.model,
171
+ [`${tier}_auto`]: true,
172
+ });
165
173
  } catch { /* read-only home: keep the in-memory choice */ }
166
- this.ctx?.logger?.info?.(`dsh-adapter: ${tier} auto-bound to ${candidate.provider}/${candidate.model}`);
167
- return candidate;
174
+ this.ctx?.logger?.info?.(`dsh-adapter: ${tier} auto-bound to ${candidate.provider}/${candidate.model} @ ${attemptEffort}`);
175
+ return chosen;
168
176
  }
169
177
  }
170
178
  this.ctx?.logger?.warn?.(`dsh-adapter: no usable ${tier} route; keeping ${bound.provider}/${bound.model}`);
171
- return bound;
179
+ return { binding: bound, effort };
172
180
  }
173
181
 
174
182
  async spawn({ task, tier = 'flash', effort = 'max', cwd, source = 'api', provider, model, preset }) {
@@ -177,13 +185,19 @@ export class WorkerRegistry {
177
185
  // session-level overrides, exactly as it does for presets); otherwise the
178
186
  // hub's own stored config decides, and failing that the tier default.
179
187
  const tierConfig = this.getConfig?.() ?? {};
180
- const pinned = [provider, model, tierConfig[`${tier}_provider`], tierConfig[`${tier}_model`]]
181
- .some((v) => typeof v === 'string' && v.trim() !== '');
188
+ const explicitArgs = [provider, model].some((v) => typeof v === 'string' && v.trim() !== '');
189
+ const configPinned = [tierConfig[`${tier}_provider`], tierConfig[`${tier}_model`]]
190
+ .some((v) => typeof v === 'string' && v.trim() !== '') && tierConfig[`${tier}_auto`] !== true;
191
+ const pinned = explicitArgs || configPinned;
182
192
  let bound = resolveTierBinding(tier, tierConfig);
183
- // Nothing pinned means the user is on the shipped default (deepseek-official),
184
- // which needs DEEPSEEK_API_KEY. Find a route that actually works once, then
185
- // remember it, instead of failing every dispatch on a missing key.
186
- if (!pinned) bound = await this.resolveUsableTier(tier, bound);
193
+ let dispatchEffort = effort;
194
+ // An unpinned tier gets a route that actually works for this effort; an
195
+ // auto-bound one is re-checked because the model catalog can change.
196
+ if (!pinned) {
197
+ const usable = await this.resolveUsableTier(tier, bound, effort);
198
+ bound = usable.binding;
199
+ dispatchEffort = usable.effort ?? effort;
200
+ }
187
201
  const resolvedProvider = typeof provider === 'string' && provider.trim() !== '' ? provider.trim() : bound.provider;
188
202
  const resolvedModel = typeof model === 'string' && model.trim() !== '' ? model.trim() : bound.model;
189
203
  if (!['off', 'high', 'max'].includes(effort)) throw new Error(`unknown effort "${effort}"`);
@@ -197,7 +211,7 @@ export class WorkerRegistry {
197
211
  const id = `hub-${this.nextId++}-${Date.now().toString(36)}`;
198
212
  const sessionId = `session-${randomUUID()}`;
199
213
  const job = {
200
- id, sessionId, tier, model: resolvedModel, provider: resolvedProvider, effort, task, source, cwd: cwdPath,
214
+ id, sessionId, tier, model: resolvedModel, provider: resolvedProvider, effort: dispatchEffort, task, source, cwd: cwdPath,
201
215
  status: 'running', turn: 0, step: 0, currentTool: null, toolCalls: 0,
202
216
  tokens: { input: 0, output: 0, reasoning: 0 },
203
217
  startedAt: new Date().toISOString(), endedAt: null,
@@ -206,7 +220,7 @@ export class WorkerRegistry {
206
220
  };
207
221
  this.jobs.set(id, job);
208
222
 
209
- const selection = { provider: resolvedProvider, model: resolvedModel, reasoningEffort: effort };
223
+ const selection = { provider: resolvedProvider, model: resolvedModel, reasoningEffort: dispatchEffort };
210
224
  const presets = this.ctx.get('agentPresets');
211
225
  const cfg = this.getConfig?.() ?? {};
212
226
  const wanted = preset ?? (tier === 'flash' ? cfg.preset_flash : cfg.preset_pro);
@@ -437,18 +451,33 @@ export async function apply(ctx) {
437
451
  // hub_url goes stale after each restart and the host-side MCP shim falls
438
452
  // back to standalone mode. Publish this instance's origin into the shared
439
453
  // config instead; a hub_url that names another machine is left untouched.
454
+ const originOf = () => {
455
+ try {
456
+ const value = webServer.getOrigin?.();
457
+ if (typeof value === 'string' && value) return value;
458
+ } catch { /* listener not bound yet */ }
459
+ try {
460
+ const port = webServer.port;
461
+ if (Number.isInteger(port) && port > 0) return 'http://127.0.0.1:' + port;
462
+ } catch { /* port accessor unavailable */ }
463
+ return undefined;
464
+ };
440
465
  const syncHubUrl = (attempt = 0) => {
466
+ const origin = originOf();
467
+ if (!origin) {
468
+ // The listener can bind well after plugins apply; keep trying quietly.
469
+ if (attempt < 15) { setTimeout(() => syncHubUrl(attempt + 1), 2000).unref?.(); return; }
470
+ ctx.logger?.warn?.('dsh-adapter: hub_url sync gave up waiting for the listener');
471
+ return;
472
+ }
441
473
  try {
442
- const origin = webServer.getOrigin?.();
443
474
  const current = readGlobalConfig();
444
475
  const isLocal = /^https?:\/\/(127\.0\.0\.1|localhost|\[::1\]):\d+$/.test(current.hub_url ?? '');
445
- if (origin && (!current.hub_url || isLocal) && current.hub_url !== origin) {
476
+ if ((!current.hub_url || isLocal) && current.hub_url !== origin) {
446
477
  writeGlobalConfig({ hub_url: origin });
447
478
  ctx.logger?.info?.('dsh-adapter: hub_url synced to ' + origin);
448
479
  }
449
480
  } catch (err) {
450
- // getOrigin() throws until the listener is bound; retry briefly.
451
- if (attempt < 3) { setTimeout(() => syncHubUrl(attempt + 1), 1500).unref?.(); return; }
452
481
  ctx.logger?.warn?.('dsh-adapter: hub_url sync skipped: ' + (err?.message ?? err));
453
482
  }
454
483
  };
@@ -109,6 +109,11 @@ export const GLOBAL_CONFIG_DEFAULTS = {
109
109
  flash_model: '',
110
110
  pro_provider: '',
111
111
  pro_model: '',
112
+ // Set when the binding was discovered by the usable-route fallback rather
113
+ // than chosen by the user; such a binding is re-validated when the default
114
+ // effort changes instead of being treated as a deliberate pin.
115
+ flash_auto: false,
116
+ pro_auto: false,
112
117
  // Hub-mode agent preset per tier: 'default' follows the DSH roster default.
113
118
  preset_flash: 'minimal',
114
119
  preset_pro: 'default',
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.3' });
15
+ const server = new McpServer({ name: 'dsh-adapter', version: '0.1.5' });
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).');
@@ -46,9 +46,16 @@ const sessionConfig = {
46
46
  origin_depth_limit: DEFAULT_ORIGIN_DEPTH_LIMIT,
47
47
  };
48
48
 
49
- /** The {provider, model} this session dispatches `tier` to. */
49
+ /**
50
+ * The {provider, model} this session pins for `tier`, or {} when the user has
51
+ * not pinned anything. Sending the resolved default here would look like an
52
+ * explicit choice to the hub and disable its usable-route fallback, which is
53
+ * exactly how an install without DEEPSEEK_API_KEY kept failing.
54
+ */
50
55
  function bindingForTier(tier) {
51
- return resolveTierBinding(tier, sessionConfig);
56
+ const pinned = [sessionConfig[`${tier}_provider`], sessionConfig[`${tier}_model`]]
57
+ .some((v) => typeof v === 'string' && v.trim() !== '');
58
+ return pinned ? resolveTierBinding(tier, sessionConfig) : {};
52
59
  }
53
60
 
54
61
  function presetForTier(tier) {