@zoraxylia/dsh-codex-adapter 0.1.5 → 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.5",
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
@@ -15064,7 +15064,7 @@ function describeBindings(config = {}) {
15064
15064
  }
15065
15065
 
15066
15066
  // src/server.mjs
15067
- var server = new McpServer({ name: "dsh-adapter", version: "0.1.5" });
15067
+ var server = new McpServer({ name: "dsh-adapter", version: "0.1.6" });
15068
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.");
15069
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).");
15070
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.5",
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,6 +123,30 @@ 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
151
  async probeRoute(llm, binding, effort) {
127
152
  try {
@@ -158,22 +183,34 @@ export class WorkerRegistry {
158
183
  for (const m of models.slice(0, 3)) candidates.push({ provider: id, model: m.id });
159
184
  if (candidates.length >= 5) break;
160
185
  }
161
- const attempts = effort && effort !== 'off' ? [effort, 'off'] : [effort];
162
- for (const attemptEffort of attempts) {
163
- for (const candidate of candidates) {
186
+ for (const candidate of candidates) {
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;
164
193
  if (!(await this.probeRoute(llm, candidate, attemptEffort))) continue;
165
- const chosen = { binding: candidate, effort: attemptEffort };
166
- this.autoTier[cacheKey] = chosen;
167
- try {
168
- writeGlobalConfig({
169
- [`${tier}_provider`]: candidate.provider,
170
- [`${tier}_model`]: candidate.model,
171
- [`${tier}_auto`]: true,
172
- });
173
- } catch { /* read-only home: keep the in-memory choice */ }
174
- this.ctx?.logger?.info?.(`dsh-adapter: ${tier} auto-bound to ${candidate.provider}/${candidate.model} @ ${attemptEffort}`);
175
- return chosen;
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;
176
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;
177
214
  }
178
215
  this.ctx?.logger?.warn?.(`dsh-adapter: no usable ${tier} route; keeping ${bound.provider}/${bound.model}`);
179
216
  return { binding: bound, effort };
@@ -643,8 +680,18 @@ export async function apply(ctx) {
643
680
  const providers = [];
644
681
  for (const p of ctx.llm.listProviders()) {
645
682
  let models = [];
683
+ const modelInfo = {};
646
684
  try { models = (await ctx.llm.listModels(p.id)).map((m) => m.id); } catch { /* adapter without a catalog */ }
647
- 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 });
648
695
  }
649
696
  return sendJson(res, 200, {
650
697
  ok: true,
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.5' });
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).');