@zoraxylia/dsh-codex-adapter 0.1.4 → 0.1.6

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.4",
3
+ "version": "0.1.6",
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.4" });
15067
+ var server = new McpServer({ name: "dsh-adapter", version: "0.1.6" });
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.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoraxylia/dsh-codex-adapter",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
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
@@ -84,6 +84,7 @@ const ROUTE_BASE = '/_dsh/dsh-adapter';
84
84
  // caller may override per dispatch, and the hub's own config is the fallback
85
85
  // when it does not (the same shape the preset lookup below uses).
86
86
  import { describeBindings, resolveTierBinding, TIERS } from '../tier-binding.mjs';
87
+ import { readGlobalConfig, writeGlobalConfig } from '../install/install.mjs';
87
88
  const CONFIG_DIR = join(homedir(), '.config', 'dsh-adapter');
88
89
 
89
90
  // ---------- job registry ----------
@@ -122,10 +123,34 @@ export class WorkerRegistry {
122
123
  this.shard.publish([...this.jobs.values()].map((j) => this.view(j)));
123
124
  }
124
125
 
126
+ /**
127
+ * Ask the host what reasoning efforts this exact model accepts. DSH resolves
128
+ * model metadata through the adapter (the same call that rejects an
129
+ * unsupported effort before any provider I/O), so this is the authoritative
130
+ * dictionary - no provider-specific guessing. Returns {effort} for the value
131
+ * to dispatch with, or null when the adapter offers no reasoning metadata.
132
+ */
133
+ async effortForModel(llm, binding, desired) {
134
+ if (typeof llm.resolveModelInfo !== 'function') return null;
135
+ let info;
136
+ try { info = await llm.resolveModelInfo(binding.provider, binding.model); }
137
+ catch { return null; }
138
+ const reasoning = info?.reasoning;
139
+ if (!reasoning) return { effort: undefined, supported: [] };
140
+ const ids = (reasoning.efforts ?? []).map((e) => e.id).filter((id) => typeof id === 'string');
141
+ if (ids.length === 0) return null;
142
+ if (desired === undefined) return { effort: reasoning.defaultEffort ?? ids[0], supported: ids };
143
+ if (ids.includes(desired)) return { effort: desired, supported: ids };
144
+ for (const candidate of ['max', 'high', 'medium', 'off']) {
145
+ if (ids.includes(candidate)) return { effort: candidate, supported: ids };
146
+ }
147
+ return { effort: reasoning.defaultEffort ?? ids[0], supported: ids };
148
+ }
149
+
125
150
  /** One bounded capability probe; the route counts as usable when it streams. */
126
- async probeRoute(llm, binding) {
151
+ async probeRoute(llm, binding, effort) {
127
152
  try {
128
- const result = await probeProvider(llm, binding, { timeoutMs: 12000 });
153
+ const result = await probeProvider(llm, { ...binding, ...(effort ? { reasoningEffort: effort } : {}) }, { timeoutMs: 12000 });
129
154
  return result.status === 'verified' || result.status === 'no_tool_call';
130
155
  } catch { return false; }
131
156
  }
@@ -138,17 +163,18 @@ export class WorkerRegistry {
138
163
  * first route that streams, and persist it so later dispatches skip the
139
164
  * search. Pinned bindings never reach this path.
140
165
  */
141
- async resolveUsableTier(tier, bound) {
166
+ async resolveUsableTier(tier, bound, effort) {
142
167
  this.autoTier ??= {};
143
- if (this.autoTier[tier]) return this.autoTier[tier];
168
+ const cacheKey = tier + ':' + effort;
169
+ if (this.autoTier[cacheKey]) return this.autoTier[cacheKey];
144
170
  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; }
171
+ if (!llm) return { binding: bound, effort };
172
+ if (await this.probeRoute(llm, bound, effort)) { this.autoTier[cacheKey] = { binding: bound, effort }; return this.autoTier[cacheKey]; }
147
173
  const builtin = new Set(['deepseek-official', 'deepseek-account']);
148
174
  let ids = [];
149
175
  try {
150
176
  ids = llm.listProviders().map((p) => p.id).filter((id) => id !== bound.provider);
151
- } catch { return bound; }
177
+ } catch { return { binding: bound, effort }; }
152
178
  ids.sort((a, b) => Number(builtin.has(a)) - Number(builtin.has(b)));
153
179
  const candidates = [];
154
180
  for (const id of ids) {
@@ -158,17 +184,36 @@ export class WorkerRegistry {
158
184
  if (candidates.length >= 5) break;
159
185
  }
160
186
  for (const candidate of candidates) {
161
- if (await this.probeRoute(llm, candidate)) {
162
- this.autoTier[tier] = candidate;
163
- try {
164
- writeGlobalConfig({ [`${tier}_provider`]: candidate.provider, [`${tier}_model`]: candidate.model });
165
- } 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;
187
+ const known = await this.effortForModel(llm, candidate, effort);
188
+ let attemptEffort;
189
+ if (known) {
190
+ // The host already answered which efforts this model accepts; the
191
+ // probe below only proves the route streams.
192
+ attemptEffort = known.supported.length === 0 ? undefined : known.effort;
193
+ if (!(await this.probeRoute(llm, candidate, attemptEffort))) continue;
194
+ } else {
195
+ // No reasoning metadata from the adapter: probe the wanted effort, then
196
+ // 'off', which is the cheapest compatible setting.
197
+ attemptEffort = undefined;
198
+ for (const candidateEffort of effort && effort !== 'off' ? [effort, 'off'] : [effort ?? undefined]) {
199
+ if (await this.probeRoute(llm, candidate, candidateEffort)) { attemptEffort = candidateEffort; break; }
200
+ }
201
+ if (attemptEffort === undefined && !(await this.probeRoute(llm, candidate, undefined))) continue;
168
202
  }
203
+ const chosen = { binding: candidate, effort: attemptEffort };
204
+ this.autoTier[cacheKey] = chosen;
205
+ try {
206
+ writeGlobalConfig({
207
+ [`${tier}_provider`]: candidate.provider,
208
+ [`${tier}_model`]: candidate.model,
209
+ [`${tier}_auto`]: true,
210
+ });
211
+ } catch { /* read-only home: keep the in-memory choice */ }
212
+ this.ctx?.logger?.info?.(`dsh-adapter: ${tier} auto-bound to ${candidate.provider}/${candidate.model} @ ${attemptEffort ?? '(none)'}`);
213
+ return chosen;
169
214
  }
170
215
  this.ctx?.logger?.warn?.(`dsh-adapter: no usable ${tier} route; keeping ${bound.provider}/${bound.model}`);
171
- return bound;
216
+ return { binding: bound, effort };
172
217
  }
173
218
 
174
219
  async spawn({ task, tier = 'flash', effort = 'max', cwd, source = 'api', provider, model, preset }) {
@@ -177,13 +222,19 @@ export class WorkerRegistry {
177
222
  // session-level overrides, exactly as it does for presets); otherwise the
178
223
  // hub's own stored config decides, and failing that the tier default.
179
224
  const tierConfig = this.getConfig?.() ?? {};
180
- const pinned = [provider, model, tierConfig[`${tier}_provider`], tierConfig[`${tier}_model`]]
181
- .some((v) => typeof v === 'string' && v.trim() !== '');
225
+ const explicitArgs = [provider, model].some((v) => typeof v === 'string' && v.trim() !== '');
226
+ const configPinned = [tierConfig[`${tier}_provider`], tierConfig[`${tier}_model`]]
227
+ .some((v) => typeof v === 'string' && v.trim() !== '') && tierConfig[`${tier}_auto`] !== true;
228
+ const pinned = explicitArgs || configPinned;
182
229
  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);
230
+ let dispatchEffort = effort;
231
+ // An unpinned tier gets a route that actually works for this effort; an
232
+ // auto-bound one is re-checked because the model catalog can change.
233
+ if (!pinned) {
234
+ const usable = await this.resolveUsableTier(tier, bound, effort);
235
+ bound = usable.binding;
236
+ dispatchEffort = usable.effort ?? effort;
237
+ }
187
238
  const resolvedProvider = typeof provider === 'string' && provider.trim() !== '' ? provider.trim() : bound.provider;
188
239
  const resolvedModel = typeof model === 'string' && model.trim() !== '' ? model.trim() : bound.model;
189
240
  if (!['off', 'high', 'max'].includes(effort)) throw new Error(`unknown effort "${effort}"`);
@@ -197,7 +248,7 @@ export class WorkerRegistry {
197
248
  const id = `hub-${this.nextId++}-${Date.now().toString(36)}`;
198
249
  const sessionId = `session-${randomUUID()}`;
199
250
  const job = {
200
- id, sessionId, tier, model: resolvedModel, provider: resolvedProvider, effort, task, source, cwd: cwdPath,
251
+ id, sessionId, tier, model: resolvedModel, provider: resolvedProvider, effort: dispatchEffort, task, source, cwd: cwdPath,
201
252
  status: 'running', turn: 0, step: 0, currentTool: null, toolCalls: 0,
202
253
  tokens: { input: 0, output: 0, reasoning: 0 },
203
254
  startedAt: new Date().toISOString(), endedAt: null,
@@ -206,7 +257,7 @@ export class WorkerRegistry {
206
257
  };
207
258
  this.jobs.set(id, job);
208
259
 
209
- const selection = { provider: resolvedProvider, model: resolvedModel, reasoningEffort: effort };
260
+ const selection = { provider: resolvedProvider, model: resolvedModel, reasoningEffort: dispatchEffort };
210
261
  const presets = this.ctx.get('agentPresets');
211
262
  const cfg = this.getConfig?.() ?? {};
212
263
  const wanted = preset ?? (tier === 'flash' ? cfg.preset_flash : cfg.preset_pro);
@@ -629,8 +680,18 @@ export async function apply(ctx) {
629
680
  const providers = [];
630
681
  for (const p of ctx.llm.listProviders()) {
631
682
  let models = [];
683
+ const modelInfo = {};
632
684
  try { models = (await ctx.llm.listModels(p.id)).map((m) => m.id); } catch { /* adapter without a catalog */ }
633
- providers.push({ id: p.id, name: p.name ?? p.id, models });
685
+ for (const id of models) {
686
+ try {
687
+ const info = await ctx.llm.resolveModelInfo(p.id, id);
688
+ modelInfo[id] = {
689
+ efforts: (info?.reasoning?.efforts ?? []).map((e) => e.id),
690
+ ...(info?.reasoning?.defaultEffort === undefined ? {} : { defaultEffort: info.reasoning.defaultEffort }),
691
+ };
692
+ } catch { /* metadata optional */ }
693
+ }
694
+ providers.push({ id: p.id, name: p.name ?? p.id, models, model_info: modelInfo });
634
695
  }
635
696
  return sendJson(res, 200, {
636
697
  ok: true,
@@ -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.4' });
15
+ const server = new McpServer({ name: 'dsh-adapter', version: '0.1.6' });
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).');