@zoraxylia/dsh-codex-adapter 0.1.8 → 0.1.10
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/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/client.js +2 -2
- package/lib/server.mjs +1 -1
- package/package.json +4 -3
- package/scripts/sync-model-caps.mjs +185 -0
- package/src/client/index.tsx +2 -2
- package/src/hub/index.mjs +50 -5
- package/src/multimodal.mjs +4 -1
- package/src/server.mjs +1 -1
- package/src/vision-route.mjs +9 -0
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<strong>
|
|
12
|
+
<strong>Claude Code / Codex can dispatch tasks to DSH agents and see them as native subagents in the host with live progress. Configure dispatch defaults, execution mode, and vision / image-generation access, then install into the host in one click.</strong><br />
|
|
13
13
|
<sub>Native Progress UI • Tier Policy & Escalation • Dispatch Guardrails • Jobs Board • In-Host DSH Sessions • Vision & Image Gen (Native-First) • One-Click Install</sub>
|
|
14
14
|
</p>
|
|
15
15
|
|
package/README.zh.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<strong
|
|
12
|
+
<strong>Claude Code / Codex 可以给 DSH agent 分派任务,在宿主里显示为原生子代理、进度可见。配置派发默认值、执行方式,以及接入视觉与生图能力,一键装进宿主。</strong><br />
|
|
13
13
|
<sub>原生进度 UI • 档位策略与失败升档 • 派发护栏 • 任务看板 • DSH 会话进宿主 • 原生优先视觉与生图 • 一键安装</sub>
|
|
14
14
|
</p>
|
|
15
15
|
|
package/lib/client.js
CHANGED
|
@@ -402,7 +402,7 @@ const COPY = {
|
|
|
402
402
|
zh: {
|
|
403
403
|
label: "DSH Adapter",
|
|
404
404
|
title: "DSH Adapter",
|
|
405
|
-
intro: "
|
|
405
|
+
intro: "Claude Code / Codex 可以给 DSH agent 分派任务,在宿主里显示为原生子代理、进度可见。配置派发默认值、执行方式,以及接入视觉与生图能力,一键装进宿主。",
|
|
406
406
|
integrations: "集成",
|
|
407
407
|
collapse: "折叠",
|
|
408
408
|
expand: "展开",
|
|
@@ -571,7 +571,7 @@ const COPY = {
|
|
|
571
571
|
en: {
|
|
572
572
|
label: "DSH Adapter",
|
|
573
573
|
title: "DSH Adapter",
|
|
574
|
-
intro: "
|
|
574
|
+
intro: "Claude Code / Codex can dispatch tasks to DSH agents and see them as native subagents in the host with live progress. Configure dispatch defaults, execution mode, and vision / image-generation access, then install into the host in one click.",
|
|
575
575
|
integrations: "Integrations",
|
|
576
576
|
collapse: "Collapse",
|
|
577
577
|
expand: "Expand",
|
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.
|
|
15072
|
+
var server = new McpServer({ name: "dsh-adapter", version: "0.1.10" });
|
|
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,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zoraxylia/dsh-codex-adapter",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/hub/index.mjs",
|
|
6
|
-
"description": "
|
|
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.",
|
|
7
7
|
"dsh": {
|
|
8
8
|
"bundle": {
|
|
9
9
|
"patch": "./cordis.patch.yml"
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"version:bump": "node scripts/bump-version.mjs",
|
|
29
29
|
"prepack": "npm run smoke:cwd && npm run smoke:mcp",
|
|
30
30
|
"prepublishOnly": "npm run smoke:mcp && npm run smoke:pack",
|
|
31
|
-
"test": "node --test tests/*.test.mjs"
|
|
31
|
+
"test": "node --test tests/*.test.mjs",
|
|
32
|
+
"caps:sync": "node scripts/sync-model-caps.mjs"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@modelcontextprotocol/sdk": "^1.17.5",
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// Sync a DSH profile's declared model capabilities with what the provider's
|
|
2
|
+
// own catalog says.
|
|
3
|
+
//
|
|
4
|
+
// DSH validates a dispatch against the LOCAL declaration (`reasoningEfforts` in
|
|
5
|
+
// the llm-pi-ai profile), while the gateway decides what a model really
|
|
6
|
+
// accepts. When those drift, a worker fails with "does not support reasoning
|
|
7
|
+
// effort" even though the model is healthy. This script rewrites the profile's
|
|
8
|
+
// `reasoningEfforts` blocks from the upstream catalog, leaving everything else
|
|
9
|
+
// byte-identical.
|
|
10
|
+
//
|
|
11
|
+
// node scripts/sync-model-caps.mjs # dry run, desktop profile
|
|
12
|
+
// node scripts/sync-model-caps.mjs --write # apply (creates .bak)
|
|
13
|
+
// node scripts/sync-model-caps.mjs --provider codeman --profile desktop
|
|
14
|
+
//
|
|
15
|
+
// Models the upstream catalog does not describe (or describes without any
|
|
16
|
+
// capability field) are left untouched.
|
|
17
|
+
|
|
18
|
+
import { copyFileSync, existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
19
|
+
import { homedir } from 'node:os';
|
|
20
|
+
import { join } from 'node:path';
|
|
21
|
+
import { fetchUpstreamCaps, readCapsCache, resolveProviderEndpoint } from '../src/model-caps.mjs';
|
|
22
|
+
|
|
23
|
+
const argv = process.argv.slice(2);
|
|
24
|
+
const flag = (name) => argv.includes(name);
|
|
25
|
+
const value = (name, fallback) => {
|
|
26
|
+
const i = argv.indexOf(name);
|
|
27
|
+
return i === -1 || argv[i + 1] === undefined ? fallback : argv[i + 1];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const profile = value('--profile', 'desktop');
|
|
31
|
+
const explicitProvider = value('--provider', undefined);
|
|
32
|
+
const write = flag('--write');
|
|
33
|
+
const LEVELS = ['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
34
|
+
|
|
35
|
+
const patchPath = join(homedir(), '.dsh', 'profiles', profile, 'cordis.patch.yml');
|
|
36
|
+
if (!existsSync(patchPath)) {
|
|
37
|
+
console.error(`no such profile patch: ${patchPath}`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let text = readFileSync(patchPath, 'utf8');
|
|
42
|
+
const lines = text.split('\n');
|
|
43
|
+
|
|
44
|
+
/** Line indexes of one provider's `models:` list inside the profile patch. */
|
|
45
|
+
function findModelsBlock(provider) {
|
|
46
|
+
const head = new RegExp(`^(\\s{2,})${provider.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*:\\s*$`);
|
|
47
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
48
|
+
const m = head.exec(lines[i]);
|
|
49
|
+
if (!m) continue;
|
|
50
|
+
const providerIndent = m[1].length;
|
|
51
|
+
let modelsLine = -1;
|
|
52
|
+
let modelsIndent = -1;
|
|
53
|
+
for (let j = i + 1; j < lines.length; j += 1) {
|
|
54
|
+
const line = lines[j];
|
|
55
|
+
if (line.trim() === '') continue;
|
|
56
|
+
const ind = line.length - line.trimStart().length;
|
|
57
|
+
if (ind <= providerIndent) break;
|
|
58
|
+
const mm = /^(\s*)models\s*:\s*$/.exec(line);
|
|
59
|
+
if (mm) { modelsLine = j; modelsIndent = mm[1].length; break; }
|
|
60
|
+
}
|
|
61
|
+
if (modelsLine === -1) continue;
|
|
62
|
+
const items = [];
|
|
63
|
+
const itemRe = /^(\s*)-\s+id\s*:\s*['"]?([^'"\s]+)['"]?\s*$/;
|
|
64
|
+
for (let j = modelsLine + 1; j < lines.length; j += 1) {
|
|
65
|
+
const line = lines[j];
|
|
66
|
+
if (line.trim() === '') continue;
|
|
67
|
+
const ind = line.length - line.trimStart().length;
|
|
68
|
+
if (ind <= modelsIndent) break;
|
|
69
|
+
const mm = itemRe.exec(line);
|
|
70
|
+
if (!mm || mm[1].length !== modelsIndent + 2) continue;
|
|
71
|
+
let end = lines.length;
|
|
72
|
+
for (let k = j + 1; k < lines.length; k += 1) {
|
|
73
|
+
const l = lines[k];
|
|
74
|
+
if (l.trim() === '') continue;
|
|
75
|
+
if (l.length - l.trimStart().length <= mm[1].length) { end = k; break; }
|
|
76
|
+
}
|
|
77
|
+
items.push({ id: mm[2], start: j, end });
|
|
78
|
+
}
|
|
79
|
+
return { items };
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function desiredBlock(caps) {
|
|
85
|
+
if (caps.efforts === undefined) return undefined;
|
|
86
|
+
if (caps.efforts.length === 0) return ['reasoningEfforts: false'];
|
|
87
|
+
const offered = caps.efforts.filter((level) => LEVELS.includes(level));
|
|
88
|
+
if (offered.length === 0) return undefined;
|
|
89
|
+
const ordered = LEVELS.filter((level) => level === 'off' || offered.includes(level));
|
|
90
|
+
if (!ordered.includes('off')) ordered.unshift('off');
|
|
91
|
+
return ['reasoningEfforts:', ...ordered.map((level) => (level === 'off' ? ' off: null' : ` ${level}: ${level}`))];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const providers = explicitProvider ? [explicitProvider] : listProviderIds(text);
|
|
95
|
+
if (providers.length === 0) {
|
|
96
|
+
console.error('no providers found in the profile patch');
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const cache = readCapsCache();
|
|
101
|
+
const changes = [];
|
|
102
|
+
let output = text;
|
|
103
|
+
|
|
104
|
+
for (const provider of providers) {
|
|
105
|
+
const endpoint = resolveProviderEndpoint(provider, {});
|
|
106
|
+
if (!endpoint) { console.log(`- ${provider}: no endpoint (skipped)`); continue; }
|
|
107
|
+
const entry = await fetchUpstreamCaps(provider, endpoint, {});
|
|
108
|
+
if (entry.error) { console.log(`- ${provider}: ${entry.error} (skipped)`); continue; }
|
|
109
|
+
cache.providers[provider] = entry;
|
|
110
|
+
const block = findModelsBlock(provider);
|
|
111
|
+
if (!block) { console.log(`- ${provider}: no models: list (skipped)`); continue; }
|
|
112
|
+
// Reverse order: an edit inside a later item cannot shift an earlier item's
|
|
113
|
+
// line indexes, so the captured starts stay valid.
|
|
114
|
+
for (const item of [...block.items].reverse()) {
|
|
115
|
+
const caps = entry.models?.[item.id];
|
|
116
|
+
const wanted = caps ? desiredBlock(caps) : undefined;
|
|
117
|
+
if (!wanted) continue;
|
|
118
|
+
const result = rewriteItem(output.split('\n'), item, wanted);
|
|
119
|
+
if (result) {
|
|
120
|
+
changes.push({ provider, model: item.id, from: result.from, to: wanted.join(' / ') });
|
|
121
|
+
output = result.text;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
changes.sort((a, b) => a.model.localeCompare(b.model));
|
|
127
|
+
for (const change of changes) {
|
|
128
|
+
console.log(`~ ${change.provider}/${change.model}`);
|
|
129
|
+
console.log(` was: ${change.from || '(none)'}`);
|
|
130
|
+
console.log(` now: ${change.to}`);
|
|
131
|
+
}
|
|
132
|
+
console.log(`\n${changes.length} model(s) ${write ? 'updated' : 'would change'} in ${patchPath}`);
|
|
133
|
+
|
|
134
|
+
if (write && changes.length > 0) {
|
|
135
|
+
copyFileSync(patchPath, patchPath + '.bak-' + Date.now());
|
|
136
|
+
writeFileSync(patchPath, output);
|
|
137
|
+
console.log('written (backup kept next to the profile patch)');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function listProviderIds(source) {
|
|
141
|
+
const out = [];
|
|
142
|
+
const lines2 = source.split('\n');
|
|
143
|
+
const providerHead = /^\s{2,}([A-Za-z0-9_-]+)\s*:\s*$/;
|
|
144
|
+
for (let i = 0; i < lines2.length; i += 1) {
|
|
145
|
+
if (!/^\s{2,}providers\s*:\s*$/.test(lines2[i])) continue;
|
|
146
|
+
const base = lines2[i].length - lines2[i].trimStart().length;
|
|
147
|
+
for (let j = i + 1; j < lines2.length; j += 1) {
|
|
148
|
+
const line = lines2[j];
|
|
149
|
+
if (line.trim() === '') continue;
|
|
150
|
+
const ind = line.length - line.trimStart().length;
|
|
151
|
+
if (ind <= base) break;
|
|
152
|
+
const m = providerHead.exec(line);
|
|
153
|
+
if (m && ind === base + 2) out.push(m[1]);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Replace or insert the reasoningEfforts property inside one list item. */
|
|
160
|
+
function rewriteItem(all, item, wanted) {
|
|
161
|
+
const indent = all[item.start].length - all[item.start].trimStart().length;
|
|
162
|
+
const propIndent = ' '.repeat(indent + 2);
|
|
163
|
+
const childIndent = ' '.repeat(indent + 4);
|
|
164
|
+
let start = -1;
|
|
165
|
+
let end = -1;
|
|
166
|
+
for (let i = item.start + 1; i < item.end; i += 1) {
|
|
167
|
+
if (/^\s*reasoningEfforts\s*:/.test(all[i])) {
|
|
168
|
+
start = i;
|
|
169
|
+
end = i + 1;
|
|
170
|
+
while (end < item.end && (all[end].trim() === '' || all[end].length - all[end].trimStart().length > indent + 2)) end += 1;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const block = wanted.map((line, index) => (index === 0 ? propIndent + line : childIndent + line.slice(2)));
|
|
175
|
+
if (start === -1) {
|
|
176
|
+
// Append at the end of the item.
|
|
177
|
+
let insertAt = item.end;
|
|
178
|
+
while (insertAt > item.start + 1 && all[insertAt - 1].trim() === '') insertAt -= 1;
|
|
179
|
+
all.splice(insertAt, 0, ...block);
|
|
180
|
+
return { text: all.join('\n'), from: '' };
|
|
181
|
+
}
|
|
182
|
+
const from = all.slice(start, end).map((l) => l.trim()).join(' / ');
|
|
183
|
+
all.splice(start, end - start, ...block);
|
|
184
|
+
return { text: all.join('\n'), from };
|
|
185
|
+
}
|
package/src/client/index.tsx
CHANGED
|
@@ -86,7 +86,7 @@ const COPY = {
|
|
|
86
86
|
zh: {
|
|
87
87
|
label: 'DSH Adapter',
|
|
88
88
|
title: 'DSH Adapter',
|
|
89
|
-
intro: '
|
|
89
|
+
intro: 'Claude Code / Codex 可以给 DSH agent 分派任务,在宿主里显示为原生子代理、进度可见。配置派发默认值、执行方式,以及接入视觉与生图能力,一键装进宿主。',
|
|
90
90
|
integrations: '集成',
|
|
91
91
|
collapse: '折叠', expand: '展开',
|
|
92
92
|
installed: '已安装', notInstalled: '未安装', hud: 'HUD 段',
|
|
@@ -179,7 +179,7 @@ const COPY = {
|
|
|
179
179
|
en: {
|
|
180
180
|
label: 'DSH Adapter',
|
|
181
181
|
title: 'DSH Adapter',
|
|
182
|
-
intro: '
|
|
182
|
+
intro: 'Claude Code / Codex can dispatch tasks to DSH agents and see them as native subagents in the host with live progress. Configure dispatch defaults, execution mode, and vision / image-generation access, then install into the host in one click.',
|
|
183
183
|
integrations: 'Integrations',
|
|
184
184
|
collapse: 'Collapse', expand: 'Expand',
|
|
185
185
|
installed: 'installed', notInstalled: 'not installed', hud: 'HUD segment',
|
package/src/hub/index.mjs
CHANGED
|
@@ -494,9 +494,49 @@ async function readBody(req, limit = 64 * 1024) {
|
|
|
494
494
|
export async function apply(ctx) {
|
|
495
495
|
seedLangFromHost(ctx);
|
|
496
496
|
const hub = new WorkerRegistry(ctx);
|
|
497
|
+
// Providers DSH already has configured are offered to the multimodal bridge
|
|
498
|
+
// as ready-made entries, so a vision model needs no manual base URL or key.
|
|
499
|
+
let autoProviders = [];
|
|
500
|
+
const mergeAutoProviders = (cfg) => {
|
|
501
|
+
const user = cfg.custom_providers ?? [];
|
|
502
|
+
const extra = autoProviders.filter((a) => !user.some((u) => u.id === a.id));
|
|
503
|
+
return extra.length === 0 ? cfg : { ...cfg, custom_providers: [...user, ...extra] };
|
|
504
|
+
};
|
|
505
|
+
const refreshAutoProviders = async () => {
|
|
506
|
+
try {
|
|
507
|
+
const cfg = readGlobalConfig();
|
|
508
|
+
const list = [];
|
|
509
|
+
for (const p of ctx.llm.listProviders()) {
|
|
510
|
+
const endpoint = resolveProviderEndpoint(p.id, (cfg.upstream_caps ?? {})[p.id]);
|
|
511
|
+
if (!endpoint?.baseUrl) continue;
|
|
512
|
+
const models = [];
|
|
513
|
+
try {
|
|
514
|
+
for (const m of await ctx.llm.listModels(p.id)) {
|
|
515
|
+
try {
|
|
516
|
+
const info = await ctx.llm.resolveModelInfo(p.id, m.id);
|
|
517
|
+
if ((info.inputModalities ?? []).includes('image')) models.push(m.id);
|
|
518
|
+
} catch { /* model without metadata */ }
|
|
519
|
+
}
|
|
520
|
+
} catch { /* adapter without a catalog */ }
|
|
521
|
+
if (models.length === 0) continue;
|
|
522
|
+
list.push({
|
|
523
|
+
id: 'dsh-' + p.id,
|
|
524
|
+
name: (p.name ?? p.id) + ' (DSH)',
|
|
525
|
+
type: 'api',
|
|
526
|
+
base_url: endpoint.baseUrl,
|
|
527
|
+
...(endpoint.apiKeyEnv === undefined ? {} : { api_key_env: endpoint.apiKeyEnv }),
|
|
528
|
+
models,
|
|
529
|
+
auto: true,
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
autoProviders = list;
|
|
533
|
+
} catch { /* multimodal stays manual */ }
|
|
534
|
+
};
|
|
497
535
|
try {
|
|
498
536
|
const { readGlobalConfig } = await import('../install/install.mjs');
|
|
499
|
-
hub.getConfig = () => readGlobalConfig();
|
|
537
|
+
hub.getConfig = () => mergeAutoProviders(readGlobalConfig());
|
|
538
|
+
hub.refreshAutoProviders = refreshAutoProviders;
|
|
539
|
+
void refreshAutoProviders();
|
|
500
540
|
} catch {}
|
|
501
541
|
const disposers = [];
|
|
502
542
|
|
|
@@ -505,7 +545,7 @@ export async function apply(ctx) {
|
|
|
505
545
|
try {
|
|
506
546
|
const { createMultimodalTools } = await import('../multimodal.mjs');
|
|
507
547
|
const { readGlobalConfig } = await import('../install/install.mjs');
|
|
508
|
-
for (const tool of createMultimodalTools(() =>
|
|
548
|
+
for (const tool of createMultimodalTools(() => hub.getConfig())) {
|
|
509
549
|
disposers.push(ctx.effect(() => ctx.tools.register(tool), `dsh-adapter: ${tool.name} tool`));
|
|
510
550
|
}
|
|
511
551
|
} catch (err) {
|
|
@@ -517,7 +557,7 @@ export async function apply(ctx) {
|
|
|
517
557
|
try {
|
|
518
558
|
const { installVisionRoute } = await import('../vision-route.mjs');
|
|
519
559
|
const { readGlobalConfig } = await import('../install/install.mjs');
|
|
520
|
-
disposers.push(installVisionRoute(ctx, () =>
|
|
560
|
+
disposers.push(installVisionRoute(ctx, () => hub.getConfig()));
|
|
521
561
|
} catch (err) {
|
|
522
562
|
ctx.logger?.warn?.(`dsh-adapter: vision route unavailable: ${err?.message ?? err}`);
|
|
523
563
|
}
|
|
@@ -680,9 +720,13 @@ export async function apply(ctx) {
|
|
|
680
720
|
const { readGlobalConfig, writeGlobalConfig } = await import(`../install/install.mjs?t=${Date.now()}`);
|
|
681
721
|
if (req.method === 'GET') {
|
|
682
722
|
adoptLang(new URL(req.url, 'http://localhost').searchParams.get('lang'));
|
|
683
|
-
|
|
723
|
+
await hub.refreshAutoProviders?.();
|
|
724
|
+
return sendJson(res, 200, { ok: true, config: hub.getConfig() });
|
|
725
|
+
}
|
|
726
|
+
if (req.method === 'POST') {
|
|
727
|
+
writeGlobalConfig(await readBody(req));
|
|
728
|
+
return sendJson(res, 200, { ok: true, config: hub.getConfig() });
|
|
684
729
|
}
|
|
685
|
-
if (req.method === 'POST') return sendJson(res, 200, { ok: true, config: writeGlobalConfig(await readBody(req)) });
|
|
686
730
|
return sendJson(res, 405, { ok: false, error: 'GET or POST' }, { allow: 'GET, POST' });
|
|
687
731
|
} catch (err) {
|
|
688
732
|
return sendJson(res, 500, { ok: false, error: err?.message ?? String(err) });
|
|
@@ -719,6 +763,7 @@ export async function apply(ctx) {
|
|
|
719
763
|
if (!isLoopbackRequest(req)) return sendJson(res, 403, { ok: false, error: 'loopback only' });
|
|
720
764
|
try {
|
|
721
765
|
const { readGlobalConfig } = await import('../install/install.mjs');
|
|
766
|
+
await hub.refreshAutoProviders?.();
|
|
722
767
|
const providers = [];
|
|
723
768
|
for (const p of ctx.llm.listProviders()) {
|
|
724
769
|
let models = [];
|
package/src/multimodal.mjs
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// discipline.
|
|
15
15
|
|
|
16
16
|
import { spawn } from 'node:child_process';
|
|
17
|
+
import { readCredentialRef } from './model-caps.mjs';
|
|
17
18
|
import { createHash } from 'node:crypto';
|
|
18
19
|
import { readFileSync, writeFileSync, mkdirSync, existsSync, statSync } from 'node:fs';
|
|
19
20
|
import { join, isAbsolute, dirname } from 'node:path';
|
|
@@ -202,8 +203,10 @@ async function describeViaApi(entry, imagePath, question, model) {
|
|
|
202
203
|
const m = model && model !== 'default' ? model : entry.models?.[0];
|
|
203
204
|
if (!m) throw new Error(tr(`自定义 provider "${entry.name ?? entry.id}" 未配置模型列表,无法确定视觉模型`, `Custom provider "${entry.name ?? entry.id}" has no models configured`));
|
|
204
205
|
const b64 = readFileSync(imagePath).toString('base64');
|
|
206
|
+
const apiKey = entry.api_key
|
|
207
|
+
?? (entry.api_key_env ? (process.env[entry.api_key_env] ?? readCredentialRef(entry.api_key_env)) : undefined);
|
|
205
208
|
const data = await fetchJson(`${base}/chat/completions`, {
|
|
206
|
-
apiKey
|
|
209
|
+
apiKey,
|
|
207
210
|
timeoutMs: 240_000,
|
|
208
211
|
body: {
|
|
209
212
|
model: m,
|
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.10' });
|
|
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).');
|
package/src/vision-route.mjs
CHANGED
|
@@ -86,6 +86,15 @@ export function installVisionRoute(ctx, getConfig) {
|
|
|
86
86
|
const decision = await next();
|
|
87
87
|
if (decision.kind !== 'enter') return decision;
|
|
88
88
|
if (getConfig().vision_provider === 'off') return decision;
|
|
89
|
+
// A model that accepts images itself needs no transcription; adding one
|
|
90
|
+
// would duplicate the picture's content in every step.
|
|
91
|
+
try {
|
|
92
|
+
const selection = payload.modelSelection;
|
|
93
|
+
if (selection?.provider && selection?.model) {
|
|
94
|
+
const info = await ctx.llm.resolveModelInfo(selection.provider, selection.model);
|
|
95
|
+
if ((info?.inputModalities ?? []).includes('image')) return decision;
|
|
96
|
+
}
|
|
97
|
+
} catch { /* metadata unavailable: keep transcribing */ }
|
|
89
98
|
let changed = false;
|
|
90
99
|
const rewritten = [];
|
|
91
100
|
for (const message of decision.messages) {
|