@zoraxylia/dsh-codex-adapter 0.1.2 → 0.1.3
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.
- package/.claude-plugin/plugin.json +1 -1
- package/lib/client.js +14 -2
- package/lib/server.mjs +3 -1
- package/package.json +1 -1
- package/src/client/index.tsx +15 -2
- package/src/hub/index.mjs +63 -2
- package/src/server.mjs +5 -1
package/lib/client.js
CHANGED
|
@@ -1145,13 +1145,25 @@ function WorkersPanel({ ctx }) {
|
|
|
1145
1145
|
]);
|
|
1146
1146
|
if (j.ok) mergeJobs(j.jobs ?? []);
|
|
1147
1147
|
if (s.ok) setStatus(s.status);
|
|
1148
|
-
if (c.ok)
|
|
1148
|
+
if (c.ok) {
|
|
1149
|
+
setConfig((prev) => prev ?? c.config);
|
|
1150
|
+
const origin = window.location.origin;
|
|
1151
|
+
const hubUrl = String(c.config?.hub_url ?? "");
|
|
1152
|
+
const isLocalOrEmpty = hubUrl === "" || /^https?:\/\/(127\.0\.0\.1|localhost|\[::1\]):\d+$/.test(hubUrl);
|
|
1153
|
+
if (/^https?:\/\//.test(origin) && isLocalOrEmpty && hubUrl !== origin) post("/config", { hub_url: origin }).then((r) => {
|
|
1154
|
+
if (r.ok) setConfig(r.config);
|
|
1155
|
+
}).catch(() => {});
|
|
1156
|
+
}
|
|
1149
1157
|
if (pr.ok) setPresetRoster({
|
|
1150
1158
|
defaultId: pr.defaultId,
|
|
1151
1159
|
presets: pr.presets ?? []
|
|
1152
1160
|
});
|
|
1153
1161
|
} catch {}
|
|
1154
|
-
}, [
|
|
1162
|
+
}, [
|
|
1163
|
+
get,
|
|
1164
|
+
post,
|
|
1165
|
+
mergeJobs
|
|
1166
|
+
]);
|
|
1155
1167
|
(0, react.useEffect)(() => {
|
|
1156
1168
|
refreshAll();
|
|
1157
1169
|
const timer = setInterval(() => {
|
package/lib/server.mjs
CHANGED
|
@@ -15059,7 +15059,7 @@ function describeBindings(config = {}) {
|
|
|
15059
15059
|
}
|
|
15060
15060
|
|
|
15061
15061
|
// src/server.mjs
|
|
15062
|
-
var server = new McpServer({ name: "dsh-adapter", version: "0.1.
|
|
15062
|
+
var server = new McpServer({ name: "dsh-adapter", version: "0.1.3" });
|
|
15063
15063
|
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
15064
|
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
15065
|
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.');
|
|
@@ -15271,11 +15271,13 @@ server.registerTool("dsh_worker_config", {
|
|
|
15271
15271
|
const bindings = describeBindings(sessionConfig);
|
|
15272
15272
|
const custom2 = Object.entries(bindings).filter(([, b]) => b.custom).map(([tier]) => tier);
|
|
15273
15273
|
const unknown = available === null ? [] : custom2.filter((tier) => !available.some((p) => p.id === bindings[tier].provider));
|
|
15274
|
+
const availableModels = available === null ? null : Object.fromEntries(available.map((p) => [p.id, p.models ?? []]));
|
|
15274
15275
|
return text({
|
|
15275
15276
|
...sessionConfig,
|
|
15276
15277
|
hub_reachable: reachable,
|
|
15277
15278
|
bindings,
|
|
15278
15279
|
available_providers: available,
|
|
15280
|
+
available_models: availableModels,
|
|
15279
15281
|
...available === null && custom2.length > 0 ? { providers_note: "The hub is not reachable, so the configured provider ids could not be checked against what DSH actually has. A route DSH does not know will fail at dispatch, not here." } : {},
|
|
15280
15282
|
...unknown.length > 0 ? { providers_warning: `DSH has no provider route named ${unknown.map((t) => JSON.stringify(bindings[t].provider)).join(", ")} (bound to: ${unknown.join(", ")}). Configure it in DSH first, or these dispatches will fail.` } : {},
|
|
15281
15283
|
...custom2.length > 0 ? { route_caveat: 'Appearing in available_providers only means an adapter is registered, NOT that it can run a worker. Measured: a route registered purely to re-route another provider fails a dispatch with "registration.adapter.prepareCall is not a function". Nor does DSH report tool-calling support anywhere, and a worker that cannot call tools returns prose and touches no files. A tier bound to a custom route is therefore UNVERIFIED until you call dsh_worker_probe for the configured route; the probe observes one request and is not a permanent capability guarantee.' } : {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zoraxylia/dsh-codex-adapter",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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/client/index.tsx
CHANGED
|
@@ -516,10 +516,23 @@ function WorkersPanel({ ctx }: { ctx: any }) {
|
|
|
516
516
|
const [j, s, c, pr] = await Promise.all([get('/jobs'), get('/install/status'), get('/config'), get('/presets')]);
|
|
517
517
|
if (j.ok) mergeJobs(j.jobs ?? []);
|
|
518
518
|
if (s.ok) setStatus(s.status);
|
|
519
|
-
if (c.ok)
|
|
519
|
+
if (c.ok) {
|
|
520
|
+
setConfig((prev: any) => prev ?? c.config);
|
|
521
|
+
// The desktop host binds an OS-assigned port on every launch, so the
|
|
522
|
+
// stored hub_url goes stale and host-side MCP shims fall back to
|
|
523
|
+
// standalone mode. Opening this page is the natural moment to repoint
|
|
524
|
+
// it at the address the page itself was served from. A hub_url naming
|
|
525
|
+
// another machine is left alone.
|
|
526
|
+
const origin = window.location.origin;
|
|
527
|
+
const hubUrl = String(c.config?.hub_url ?? '');
|
|
528
|
+
const isLocalOrEmpty = hubUrl === '' || /^https?:\/\/(127\.0\.0\.1|localhost|\[::1\]):\d+$/.test(hubUrl);
|
|
529
|
+
if (/^https?:\/\//.test(origin) && isLocalOrEmpty && hubUrl !== origin) {
|
|
530
|
+
void post('/config', { hub_url: origin }).then((r) => { if (r.ok) setConfig(r.config); }).catch(() => {});
|
|
531
|
+
}
|
|
532
|
+
}
|
|
520
533
|
if (pr.ok) setPresetRoster({ defaultId: pr.defaultId, presets: pr.presets ?? [] });
|
|
521
534
|
} catch { /* instance restarting */ }
|
|
522
|
-
}, [get, mergeJobs]);
|
|
535
|
+
}, [get, post, mergeJobs]);
|
|
523
536
|
|
|
524
537
|
useEffect(() => {
|
|
525
538
|
void refreshAll();
|
package/src/hub/index.mjs
CHANGED
|
@@ -122,12 +122,68 @@ export class WorkerRegistry {
|
|
|
122
122
|
this.shard.publish([...this.jobs.values()].map((j) => this.view(j)));
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/** One bounded capability probe; the route counts as usable when it streams. */
|
|
126
|
+
async probeRoute(llm, binding) {
|
|
127
|
+
try {
|
|
128
|
+
const result = await probeProvider(llm, binding, { timeoutMs: 12000 });
|
|
129
|
+
return result.status === 'verified' || result.status === 'no_tool_call';
|
|
130
|
+
} catch { return false; }
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Resolve a tier that the user has not pinned. The shipped default route
|
|
135
|
+
* (deepseek-official) fails on installs without DEEPSEEK_API_KEY, and a
|
|
136
|
+
* provider that exists may still have no channel for the requested model —
|
|
137
|
+
* the pro tier hits exactly that. Probe the configured providers, take the
|
|
138
|
+
* first route that streams, and persist it so later dispatches skip the
|
|
139
|
+
* search. Pinned bindings never reach this path.
|
|
140
|
+
*/
|
|
141
|
+
async resolveUsableTier(tier, bound) {
|
|
142
|
+
this.autoTier ??= {};
|
|
143
|
+
if (this.autoTier[tier]) return this.autoTier[tier];
|
|
144
|
+
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; }
|
|
147
|
+
const builtin = new Set(['deepseek-official', 'deepseek-account']);
|
|
148
|
+
let ids = [];
|
|
149
|
+
try {
|
|
150
|
+
ids = llm.listProviders().map((p) => p.id).filter((id) => id !== bound.provider);
|
|
151
|
+
} catch { return bound; }
|
|
152
|
+
ids.sort((a, b) => Number(builtin.has(a)) - Number(builtin.has(b)));
|
|
153
|
+
const candidates = [];
|
|
154
|
+
for (const id of ids) {
|
|
155
|
+
let models = [];
|
|
156
|
+
try { models = await llm.listModels(id); } catch { continue; }
|
|
157
|
+
for (const m of models.slice(0, 3)) candidates.push({ provider: id, model: m.id });
|
|
158
|
+
if (candidates.length >= 5) break;
|
|
159
|
+
}
|
|
160
|
+
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;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
this.ctx?.logger?.warn?.(`dsh-adapter: no usable ${tier} route; keeping ${bound.provider}/${bound.model}`);
|
|
171
|
+
return bound;
|
|
172
|
+
}
|
|
173
|
+
|
|
125
174
|
async spawn({ task, tier = 'flash', effort = 'max', cwd, source = 'api', provider, model, preset }) {
|
|
126
175
|
if (!TIERS.includes(tier)) throw new Error(`unknown tier "${tier}"`);
|
|
127
176
|
// An explicit {provider, model} from the caller wins (the MCP process owns
|
|
128
177
|
// session-level overrides, exactly as it does for presets); otherwise the
|
|
129
178
|
// hub's own stored config decides, and failing that the tier default.
|
|
130
|
-
const
|
|
179
|
+
const tierConfig = this.getConfig?.() ?? {};
|
|
180
|
+
const pinned = [provider, model, tierConfig[`${tier}_provider`], tierConfig[`${tier}_model`]]
|
|
181
|
+
.some((v) => typeof v === 'string' && v.trim() !== '');
|
|
182
|
+
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);
|
|
131
187
|
const resolvedProvider = typeof provider === 'string' && provider.trim() !== '' ? provider.trim() : bound.provider;
|
|
132
188
|
const resolvedModel = typeof model === 'string' && model.trim() !== '' ? model.trim() : bound.model;
|
|
133
189
|
if (!['off', 'high', 'max'].includes(effort)) throw new Error(`unknown effort "${effort}"`);
|
|
@@ -555,7 +611,12 @@ export async function apply(ctx) {
|
|
|
555
611
|
if (!isLoopbackRequest(req)) return sendJson(res, 403, { ok: false, error: 'loopback only' });
|
|
556
612
|
try {
|
|
557
613
|
const { readGlobalConfig } = await import('../install/install.mjs');
|
|
558
|
-
const providers =
|
|
614
|
+
const providers = [];
|
|
615
|
+
for (const p of ctx.llm.listProviders()) {
|
|
616
|
+
let models = [];
|
|
617
|
+
try { models = (await ctx.llm.listModels(p.id)).map((m) => m.id); } catch { /* adapter without a catalog */ }
|
|
618
|
+
providers.push({ id: p.id, name: p.name ?? p.id, models });
|
|
619
|
+
}
|
|
559
620
|
return sendJson(res, 200, {
|
|
560
621
|
ok: true,
|
|
561
622
|
providers,
|
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.
|
|
15
|
+
const server = new McpServer({ name: 'dsh-adapter', version: '0.1.3' });
|
|
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).');
|
|
@@ -282,11 +282,15 @@ server.registerTool('dsh_worker_config', {
|
|
|
282
282
|
const unknown = available === null
|
|
283
283
|
? []
|
|
284
284
|
: custom.filter((tier) => !available.some((p) => p.id === bindings[tier].provider));
|
|
285
|
+
const availableModels = available === null
|
|
286
|
+
? null
|
|
287
|
+
: Object.fromEntries(available.map((p) => [p.id, p.models ?? []]));
|
|
285
288
|
return text({
|
|
286
289
|
...sessionConfig,
|
|
287
290
|
hub_reachable: reachable,
|
|
288
291
|
bindings,
|
|
289
292
|
available_providers: available,
|
|
293
|
+
available_models: availableModels,
|
|
290
294
|
...(available === null && custom.length > 0
|
|
291
295
|
? { providers_note: 'The hub is not reachable, so the configured provider ids could not be checked against what DSH actually has. A route DSH does not know will fail at dispatch, not here.' }
|
|
292
296
|
: {}),
|