@zoraxylia/dsh-codex-adapter 0.1.0 → 0.1.1
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/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +2 -2
- package/.mcp.json +1 -1
- package/README.de.md +32 -32
- package/README.es.md +32 -32
- package/README.fr.md +32 -32
- package/README.hi.md +32 -32
- package/README.id.md +32 -32
- package/README.ja.md +32 -32
- package/README.ko.md +32 -32
- package/README.md +33 -33
- package/README.pt.md +32 -32
- package/README.ru.md +32 -32
- package/README.th.md +32 -32
- package/README.tr.md +32 -32
- package/README.vi.md +32 -32
- package/README.zh-TW.md +32 -32
- package/README.zh.md +33 -33
- package/agy/agents/ds-flash.md +1 -1
- package/agy/agents/ds-pro.md +1 -1
- package/agy/skills/dsh-playbook/SKILL.md +1 -1
- package/codex/agents/ds-flash.toml +2 -2
- package/codex/agents/ds-pro.toml +2 -2
- package/codex/prompts/dsh-playbook.md +1 -1
- package/commands/off.md +1 -1
- package/commands/playbook.md +1 -1
- package/cordis.patch.yml +2 -2
- package/grok/agents/ds-flash.md +1 -1
- package/grok/agents/ds-pro.md +1 -1
- package/grok/commands/dsh-config.md +1 -1
- package/grok/commands/dsh-playbook.md +2 -2
- package/grok/commands/dsh-status.md +1 -1
- package/lib/client.js +37 -27
- package/lib/server.mjs +22 -22
- package/package.json +6 -5
- package/scripts/bump-version.mjs +79 -0
- package/scripts/fake-agy.sh +3 -3
- package/scripts/release-local.mjs +2 -2
- package/scripts/smoke-bundle.mjs +2 -2
- package/scripts/smoke-pack.mjs +4 -4
- package/scripts/smoke.mjs +3 -3
- package/scripts/verify-wpc10-client.mjs +2 -2
- package/scripts/verify-wpc14-proc-endpoints.mjs +6 -6
- package/scripts/verify-wpc9-guardrails.mjs +10 -10
- package/src/cli-workers.mjs +1 -1
- package/src/client/index.tsx +34 -32
- package/src/cwd-lock.mjs +1 -1
- package/src/hub/index.mjs +10 -10
- package/src/hub-client.mjs +4 -4
- package/src/install/install.mjs +35 -32
- package/src/jobs.mjs +2 -2
- package/src/multimodal.mjs +18 -18
- package/src/origin-guard.mjs +8 -8
- package/src/plugin-env.mjs +2 -2
- package/src/proc-kill.mjs +5 -5
- package/src/provider-probe.mjs +3 -3
- package/src/server.mjs +4 -4
- package/src/status-shard.mjs +2 -2
- package/src/vision-route.mjs +3 -3
- package/statusline/statusline.sh +1 -1
- package/statusline/worker-segment.sh +3 -3
- package/worker.cordis.yml +1 -1
- /package/docs/images/{dsh-crew-host.png → dsh-adapter-host.png} +0 -0
- /package/docs/images/{dsh-crew-jobs.png → dsh-adapter-jobs.png} +0 -0
- /package/docs/images/{dsh-crew-logo.png → dsh-adapter-logo.png} +0 -0
- /package/docs/images/{dsh-crew-overview.png → dsh-adapter-overview.png} +0 -0
package/src/client/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Browser half of dsh-
|
|
1
|
+
// Browser half of dsh-adapter: integrations (install/update/restore),
|
|
2
2
|
// global worker configuration, and the live jobs table.
|
|
3
3
|
// Talks only to the plugin's own loopback routes.
|
|
4
4
|
|
|
@@ -15,17 +15,17 @@ import { reconcileGhosts, displayJobs, groupJobs, workspaceKey, basenameOf, abbr
|
|
|
15
15
|
|
|
16
16
|
export const inject = ['slots', 'locale'];
|
|
17
17
|
|
|
18
|
-
const API = '/_dsh/dsh-
|
|
18
|
+
const API = '/_dsh/dsh-adapter';
|
|
19
19
|
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
21
21
|
// Collapsible-state helpers. Integrations / global config are one-time setup
|
|
22
|
-
// (dsh-
|
|
23
|
-
// finished-job folds use dsh-
|
|
24
|
-
// dsh-
|
|
22
|
+
// (dsh-adapter.settings.collapse.<section>); per-workspace job groups and their
|
|
23
|
+
// finished-job folds use dsh-adapter.jobs.collapse.<workspace-hash> and
|
|
24
|
+
// dsh-adapter.settings.collapse.finished-jobs.<workspace-hash> (WPC13). When
|
|
25
25
|
// localStorage is unavailable (privacy mode, sandboxed iframe, …) we degrade
|
|
26
26
|
// to session-only memory. First visit defaults to expanded.
|
|
27
|
-
const COLLAPSE_PREFIX = 'dsh-
|
|
28
|
-
const WS_COLLAPSE_PREFIX = 'dsh-
|
|
27
|
+
const COLLAPSE_PREFIX = 'dsh-adapter.settings.collapse.';
|
|
28
|
+
const WS_COLLAPSE_PREFIX = 'dsh-adapter.jobs.collapse.';
|
|
29
29
|
const collapseSessionMemory: Record<string, boolean> = {};
|
|
30
30
|
|
|
31
31
|
function readCollapsed(key: string, defaultCollapsed = false): boolean {
|
|
@@ -42,10 +42,10 @@ function persistCollapsed(key: string, collapsed: boolean): void {
|
|
|
42
42
|
|
|
43
43
|
// Orphan ghosts (WPC10): running jobs the panel saw that later vanished from
|
|
44
44
|
// an OK /jobs response without reaching a terminal state. Persisted under
|
|
45
|
-
// dsh-
|
|
45
|
+
// dsh-adapter.jobs.ghosts so a page reload does not erase the trace of a job
|
|
46
46
|
// that died while nobody was looking (the WPC10 incident). Same try/catch
|
|
47
47
|
// degradation as the collapse keys.
|
|
48
|
-
const GHOST_STORE_KEY = 'dsh-
|
|
48
|
+
const GHOST_STORE_KEY = 'dsh-adapter.jobs.ghosts';
|
|
49
49
|
const ghostSessionMemory: Record<string, any> = {};
|
|
50
50
|
function readGhosts(): Record<string, any> {
|
|
51
51
|
try {
|
|
@@ -60,7 +60,7 @@ function writeGhosts(ghosts: Record<string, any>): void {
|
|
|
60
60
|
catch { Object.assign(ghostSessionMemory, ghosts); }
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
/** Section open state + toggle, persisted under dsh-
|
|
63
|
+
/** Section open state + toggle, persisted under dsh-adapter.settings.collapse.<section>. */
|
|
64
64
|
function useCollapseSection(section: string, defaultCollapsed = false): [boolean, () => void] {
|
|
65
65
|
const [collapsed, setCollapsed] = useState<boolean>(() => readCollapsed(COLLAPSE_PREFIX + section, defaultCollapsed));
|
|
66
66
|
const toggle = useCallback(() => {
|
|
@@ -71,7 +71,7 @@ function useCollapseSection(section: string, defaultCollapsed = false): [boolean
|
|
|
71
71
|
return [collapsed, toggle];
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
/** Per-workspace job-group collapse, persisted under dsh-
|
|
74
|
+
/** Per-workspace job-group collapse, persisted under dsh-adapter.jobs.collapse.<workspaceKey> (WPC13). */
|
|
75
75
|
function useWorkspaceCollapse(wsKey: string): [boolean, () => void] {
|
|
76
76
|
const [collapsed, setCollapsed] = useState<boolean>(() => readCollapsed(WS_COLLAPSE_PREFIX + wsKey));
|
|
77
77
|
const toggle = useCallback(() => {
|
|
@@ -84,17 +84,18 @@ function useWorkspaceCollapse(wsKey: string): [boolean, () => void] {
|
|
|
84
84
|
|
|
85
85
|
const COPY = {
|
|
86
86
|
zh: {
|
|
87
|
-
label: 'DSH
|
|
88
|
-
title: 'DSH
|
|
87
|
+
label: 'DSH Adapter',
|
|
88
|
+
title: 'DSH Adapter',
|
|
89
89
|
intro: '把 Claude Code / Codex 的子任务派给本实例的 DSH agent,在宿主里显示为原生子代理、进度可见。配置派发默认值、执行方式,以及接入视觉与生图能力,一键装进宿主。',
|
|
90
90
|
integrations: '集成',
|
|
91
91
|
collapse: '折叠', expand: '展开',
|
|
92
92
|
installed: '已安装', notInstalled: '未安装', hud: 'HUD 段',
|
|
93
93
|
install: '安装', update: '更新', restore: '还原',
|
|
94
|
-
confirmRestore: (name: string) => `确定从 ${name} 移除 dsh-
|
|
94
|
+
confirmRestore: (name: string) => `确定从 ${name} 移除 dsh-adapter 集成?(settings 会先备份)`,
|
|
95
95
|
globalConfig: '全局配置',
|
|
96
|
-
globalHint: '修改即时保存到 ~/.config/dsh-
|
|
96
|
+
globalHint: '修改即时保存到 ~/.config/dsh-adapter/config.json;CC / Codex 的新会话自动读取为默认值(会话内可用 /dsh-adapter:config 临时覆盖)。',
|
|
97
97
|
tier: '默认档位', effort: '默认推理', mode: '执行模式', timeout: '默认超时(秒)', hubUrl: 'Hub 地址',
|
|
98
|
+
tierFlash: 'flash · 默认', tierPro: 'pro · 备选',
|
|
98
99
|
tierPolicy: '档位策略', escalate: '失败升档',
|
|
99
100
|
tierPolicyDesc: { auto: 'auto · orchestrator 自选', 'flash-only': '只用 flash', 'pro-only': '只用 pro' },
|
|
100
101
|
escalateHint: 'flash 失败自动用 pro 重试一次',
|
|
@@ -108,7 +109,7 @@ const COPY = {
|
|
|
108
109
|
providerType: '接入方式', typeApi: 'API · 兼容 OpenAI 接口', typeCli: 'CLI · 本地命令',
|
|
109
110
|
baseUrl: 'Base URL', apiKey: 'API Key', imagegenModel: '生图模型(留空=不提供生图)',
|
|
110
111
|
visionCmd: '视觉命令(可选)', imagegenCmd: '生图命令(可选)',
|
|
111
|
-
apiFormHint: '走 OpenAI 兼容接口:视觉调 {base}/chat/completions(图片以 base64 内联),生图调 {base}/images/generations。Key 保存在本机 ~/.config/dsh-
|
|
112
|
+
apiFormHint: '走 OpenAI 兼容接口:视觉调 {base}/chat/completions(图片以 base64 内联),生图调 {base}/images/generations。Key 保存在本机 ~/.config/dsh-adapter/config.json,不会外发到第三方。',
|
|
112
113
|
cliFormHint: '命令经 bash 执行,占位符会被安全引用后代入。视觉: {image} {question} {model},stdout 即答案;生图: {prompt} {output} {size},命令须把图片写到 {output}。两条命令至少填一条。',
|
|
113
114
|
saveProvider: '保存', cancel: '取消', edit: '编辑', del: '删除',
|
|
114
115
|
testProvider: '连通测试', testing: '测试中…',
|
|
@@ -144,7 +145,7 @@ const COPY = {
|
|
|
144
145
|
procKillDone: '已向失联进程发送终止信号',
|
|
145
146
|
procKillAlreadyGone: '进程已不存在(可能已自行退出)',
|
|
146
147
|
procAliveBadgeTip: (pid: number) => `任务已失联,但其工作进程仍在运行(pid ${pid}):很可能是派活宿主崩溃后留下的孤儿进程`,
|
|
147
|
-
procKillTip: (pid: number) => `杀死 pid ${pid}:先读取命令行校验确为 dsh-
|
|
148
|
+
procKillTip: (pid: number) => `杀死 pid ${pid}:先读取命令行校验确为 dsh-adapter 工作进程(DSH 运行时 / agy / grok),再 SIGTERM,约 3 秒后仍存活则 SIGKILL`,
|
|
148
149
|
finishedJobs: '已结束',
|
|
149
150
|
noCwdGroup: '(未指定工作区)',
|
|
150
151
|
lockBadgeTip: (h: any) => `「${h?.cwd ?? '此工作区'}」正被运行中任务持锁(job ${h?.jobId} · backend ${h?.backend} · 开始于 ${h?.startedAt}):对该 cwd 的再次派发会被拒绝,除非传 allow_concurrent_cwd: true。`,
|
|
@@ -164,29 +165,30 @@ const COPY = {
|
|
|
164
165
|
restore: '删除 ~/.codex/ 下的 ds-flash / ds-pro 角色与 dsh 命令文件(角色文件先备份)',
|
|
165
166
|
},
|
|
166
167
|
agy: {
|
|
167
|
-
install: '把 dsh-
|
|
168
|
+
install: '把 dsh-adapter MCP server 注册进 ~/.gemini/config/mcp_config.json,并将 ds-flash / ds-pro 代理与 dsh-config / dsh-status skills 复制到 ~/.gemini/config/agents 与 skills(修改前自动备份)',
|
|
168
169
|
update: '重新覆盖 MCP 配置、代理与 skills(插件路径或配置变更后用);原文件先备份',
|
|
169
|
-
restore: '从 ~/.gemini/config 移除 dsh-
|
|
170
|
+
restore: '从 ~/.gemini/config 移除 dsh-adapter 的 mcp_config.json 条目、ds-flash / ds-pro 代理与 dsh-config / dsh-status skills(修改前备份)',
|
|
170
171
|
},
|
|
171
172
|
grok: {
|
|
172
|
-
install: '把 dsh-
|
|
173
|
+
install: '把 dsh-adapter MCP server 段写入 ~/.grok/config.toml,并将 ds-flash / ds-pro 代理与 dsh-config / dsh-status 命令复制到 ~/.grok/agents 与 commands(修改前自动备份)。提示:grok 出于安全设计,在未信任的项目目录里不会启动仓库级 MCP server —— 全局安装不受影响,但在未信任目录里用 grok mcp doctor 检查时会看到 "folder untrusted",换个目录或加 --trust 即可。',
|
|
173
174
|
update: '重新覆盖 config.toml 的 MCP 段、代理与命令(插件路径或配置变更后用);原文件先备份',
|
|
174
|
-
restore: '从 ~/.grok 移除 dsh-
|
|
175
|
+
restore: '从 ~/.grok 移除 dsh-adapter 的 config.toml 段、ds-flash / ds-pro 代理与 dsh-config / dsh-status 命令(修改前备份)',
|
|
175
176
|
},
|
|
176
177
|
},
|
|
177
178
|
},
|
|
178
179
|
en: {
|
|
179
|
-
label: 'DSH
|
|
180
|
-
title: 'DSH
|
|
180
|
+
label: 'DSH Adapter',
|
|
181
|
+
title: 'DSH Adapter',
|
|
181
182
|
intro: 'Dispatch Claude Code / Codex subtasks to DSH agents within this instance, displayed as native subagents in the host with live progress. Configure dispatch defaults, execution mode, and vision/image generation (via subscription CLI or your own OpenAI API), then one-click install into the host.',
|
|
182
183
|
integrations: 'Integrations',
|
|
183
184
|
collapse: 'Collapse', expand: 'Expand',
|
|
184
185
|
installed: 'installed', notInstalled: 'not installed', hud: 'HUD segment',
|
|
185
186
|
install: 'Install', update: 'Update', restore: 'Restore',
|
|
186
|
-
confirmRestore: (name: string) => `Remove the dsh-
|
|
187
|
+
confirmRestore: (name: string) => `Remove the dsh-adapter integration from ${name}? (settings are backed up first)`,
|
|
187
188
|
globalConfig: 'Global configuration',
|
|
188
|
-
globalHint: 'Changes save instantly to ~/.config/dsh-
|
|
189
|
+
globalHint: 'Changes save instantly to ~/.config/dsh-adapter/config.json; new CC / Codex sessions pick them up as defaults (override per session with /dsh-adapter:config).',
|
|
189
190
|
tier: 'Default tier', effort: 'Default effort', mode: 'Mode', timeout: 'Timeout (s)', hubUrl: 'Hub URL',
|
|
191
|
+
tierFlash: 'flash · default', tierPro: 'pro · alternate',
|
|
190
192
|
tierPolicy: 'Tier policy', escalate: 'Escalate on failure',
|
|
191
193
|
tierPolicyDesc: { auto: 'auto · orchestrator picks', 'flash-only': 'flash only', 'pro-only': 'pro only' },
|
|
192
194
|
escalateHint: 'retry a failed flash run once on pro',
|
|
@@ -200,7 +202,7 @@ const COPY = {
|
|
|
200
202
|
providerType: 'Connection', typeApi: 'API · OpenAI-compatible', typeCli: 'CLI · local command',
|
|
201
203
|
baseUrl: 'Base URL', apiKey: 'API key', imagegenModel: 'Image-gen model (empty = no image generation)',
|
|
202
204
|
visionCmd: 'Vision command (optional)', imagegenCmd: 'Image-gen command (optional)',
|
|
203
|
-
apiFormHint: 'OpenAI-compatible: vision calls {base}/chat/completions (image inlined as base64), image-gen calls {base}/images/generations. The key is stored locally in ~/.config/dsh-
|
|
205
|
+
apiFormHint: 'OpenAI-compatible: vision calls {base}/chat/completions (image inlined as base64), image-gen calls {base}/images/generations. The key is stored locally in ~/.config/dsh-adapter/config.json and never sent to third parties.',
|
|
204
206
|
cliFormHint: 'Commands run via bash with shell-quoted placeholders. Vision: {image} {question} {model}, stdout is the answer; image-gen: {prompt} {output} {size}, the command must write the image to {output}. Fill in at least one command.',
|
|
205
207
|
saveProvider: 'Save', cancel: 'Cancel', edit: 'Edit', del: 'Delete',
|
|
206
208
|
testProvider: 'Test', testing: 'Testing…',
|
|
@@ -256,14 +258,14 @@ const COPY = {
|
|
|
256
258
|
restore: 'Delete ds-flash / ds-pro roles and dsh prompts from ~/.codex/ (roles backed up first)',
|
|
257
259
|
},
|
|
258
260
|
agy: {
|
|
259
|
-
install: 'Register the dsh-
|
|
261
|
+
install: 'Register the dsh-adapter MCP server in ~/.gemini/config/mcp_config.json and copy ds-flash / ds-pro agents plus dsh-config / dsh-status skills into ~/.gemini/config/agents and skills (backed up first)',
|
|
260
262
|
update: 'Re-write the MCP entry, agents and skills (after path/config changes); originals backed up',
|
|
261
|
-
restore: 'Remove the dsh-
|
|
263
|
+
restore: 'Remove the dsh-adapter mcp_config.json entry, ds-flash / ds-pro agents and dsh-config / dsh-status skills from ~/.gemini/config (backed up first)',
|
|
262
264
|
},
|
|
263
265
|
grok: {
|
|
264
|
-
install: 'Write the dsh-
|
|
266
|
+
install: 'Write the dsh-adapter MCP server section into ~/.grok/config.toml and copy ds-flash / ds-pro agents plus dsh-config / dsh-status commands into ~/.grok/agents and commands (backed up first). Note: by security design grok does not start repo-level MCP servers in untrusted project directories — a global install is unaffected, but grok mcp doctor reports "folder untrusted" in an untrusted directory; change directory or pass --trust.',
|
|
265
267
|
update: 'Re-write the config.toml MCP section, agents and commands (after path/config changes); originals backed up',
|
|
266
|
-
restore: 'Remove the dsh-
|
|
268
|
+
restore: 'Remove the dsh-adapter config.toml section, ds-flash / ds-pro agents and dsh-config / dsh-status commands from ~/.grok (backed up first)',
|
|
267
269
|
},
|
|
268
270
|
},
|
|
269
271
|
},
|
|
@@ -792,7 +794,7 @@ function WorkersPanel({ ctx }: { ctx: any }) {
|
|
|
792
794
|
{block(copy.cardDispatch, (<>
|
|
793
795
|
<label style={S.field}><span style={S.fieldLabel}>{copy.tier}</span>
|
|
794
796
|
<CustomSelect value={config.default_tier} onChange={(v) => field('default_tier', v)}
|
|
795
|
-
options={[{ value: 'flash' }, { value: 'pro' }]} /></label>
|
|
797
|
+
options={[{ value: 'flash', label: copy.tierFlash }, { value: 'pro', label: copy.tierPro }]} /></label>
|
|
796
798
|
<label style={S.field}><span style={S.fieldLabel}>{copy.effort}</span>
|
|
797
799
|
<CustomSelect value={config.default_effort} onChange={(v) => field('default_effort', v)}
|
|
798
800
|
options={[{ value: 'off' }, { value: 'high' }, { value: 'max' }]} /></label>
|
|
@@ -1099,7 +1101,7 @@ export function apply(ctx: any): void {
|
|
|
1099
1101
|
return ctx.slots.register(
|
|
1100
1102
|
{
|
|
1101
1103
|
name: 'settings.section',
|
|
1102
|
-
id: 'dsh-
|
|
1104
|
+
id: 'dsh-adapter',
|
|
1103
1105
|
order: 65,
|
|
1104
1106
|
label: () => {
|
|
1105
1107
|
const base = COPY[ctx.locale.getLocale().active === 'zh' ? 'zh' : 'en'].label;
|
package/src/cwd-lock.mjs
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// then share one lock), resolve() otherwise.
|
|
16
16
|
// - Process memory only, on purpose: no file locks, so a crashed dispatch
|
|
17
17
|
// process can never leave a permanent deadlock behind — its locks die
|
|
18
|
-
// with it. Locks therefore coordinate dispatches within one
|
|
18
|
+
// with it. Locks therefore coordinate dispatches within one adapter MCP
|
|
19
19
|
// session (one per host session).
|
|
20
20
|
// - Advisory: allow_concurrent_cwd: true skips acquisition entirely
|
|
21
21
|
// (read-only fan-out over one repo is legitimate).
|
package/src/hub/index.mjs
CHANGED
|
@@ -56,7 +56,7 @@ function userMessage(text) {
|
|
|
56
56
|
*/
|
|
57
57
|
export function unattendedQuestion() {
|
|
58
58
|
const error = new Error(
|
|
59
|
-
'no one is attending this dsh-
|
|
59
|
+
'no one is attending this dsh-adapter worker session, so a question cannot be answered and must not be waited on. '
|
|
60
60
|
+ 'Stop and put the unresolved question in your final message so the orchestrator can obtain the required answer or approval. '
|
|
61
61
|
+ 'An unanswered question grants no permission; never select an option automatically.',
|
|
62
62
|
);
|
|
@@ -65,7 +65,7 @@ export function unattendedQuestion() {
|
|
|
65
65
|
return error;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
export const name = 'dsh-
|
|
68
|
+
export const name = 'dsh-adapter';
|
|
69
69
|
export const inject = ['agents', 'sessions', 'agentDefaultModel', 'tools', 'llm', 'attachments'];
|
|
70
70
|
|
|
71
71
|
// Optional: the host's durable locale preference seeds server-side strings
|
|
@@ -79,12 +79,12 @@ function seedLangFromHost(ctx) {
|
|
|
79
79
|
|
|
80
80
|
import { setLang } from '../i18n.mjs';
|
|
81
81
|
|
|
82
|
-
const ROUTE_BASE = '/_dsh/dsh-
|
|
82
|
+
const ROUTE_BASE = '/_dsh/dsh-adapter';
|
|
83
83
|
// Tier -> {provider, model}. The defaults live in tier-binding.mjs; the
|
|
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
|
-
const CONFIG_DIR = join(homedir(), '.config', 'dsh-
|
|
87
|
+
const CONFIG_DIR = join(homedir(), '.config', 'dsh-adapter');
|
|
88
88
|
|
|
89
89
|
// ---------- job registry ----------
|
|
90
90
|
|
|
@@ -220,7 +220,7 @@ export class WorkerRegistry {
|
|
|
220
220
|
await ws.attachSession(sessionId);
|
|
221
221
|
}
|
|
222
222
|
} catch (err) {
|
|
223
|
-
this.ctx.logger?.warn?.(`dsh-
|
|
223
|
+
this.ctx.logger?.warn?.(`dsh-adapter: workspace attach failed for ${cwdPath}: ${err?.message ?? err}`);
|
|
224
224
|
}
|
|
225
225
|
await handle.agent.whenIdle();
|
|
226
226
|
handle.agent.followup(userMessage(task));
|
|
@@ -357,10 +357,10 @@ export async function apply(ctx) {
|
|
|
357
357
|
const { createMultimodalTools } = await import('../multimodal.mjs');
|
|
358
358
|
const { readGlobalConfig } = await import('../install/install.mjs');
|
|
359
359
|
for (const tool of createMultimodalTools(() => readGlobalConfig())) {
|
|
360
|
-
disposers.push(ctx.effect(() => ctx.tools.register(tool), `dsh-
|
|
360
|
+
disposers.push(ctx.effect(() => ctx.tools.register(tool), `dsh-adapter: ${tool.name} tool`));
|
|
361
361
|
}
|
|
362
362
|
} catch (err) {
|
|
363
|
-
ctx.logger?.warn?.(`dsh-
|
|
363
|
+
ctx.logger?.warn?.(`dsh-adapter: multimodal tools unavailable: ${err?.message ?? err}`);
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
// Vision route: image paste on the text-only DS models (admission adapter +
|
|
@@ -370,7 +370,7 @@ export async function apply(ctx) {
|
|
|
370
370
|
const { readGlobalConfig } = await import('../install/install.mjs');
|
|
371
371
|
disposers.push(installVisionRoute(ctx, () => readGlobalConfig()));
|
|
372
372
|
} catch (err) {
|
|
373
|
-
ctx.logger?.warn?.(`dsh-
|
|
373
|
+
ctx.logger?.warn?.(`dsh-adapter: vision route unavailable: ${err?.message ?? err}`);
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
ctx.inject(['webServer'], (webCtx) => {
|
|
@@ -394,7 +394,7 @@ export async function apply(ctx) {
|
|
|
394
394
|
|
|
395
395
|
disposers.push(webServer.register({
|
|
396
396
|
kind: 'exact', path: `${ROUTE_BASE}/ping`,
|
|
397
|
-
handler: (req, res) => sendJson(res, 200, { ok: true, service: 'dsh-
|
|
397
|
+
handler: (req, res) => sendJson(res, 200, { ok: true, service: 'dsh-adapter-hub' }),
|
|
398
398
|
}));
|
|
399
399
|
|
|
400
400
|
// WPC14: liveness probe for a ghost job's recorded pid. The panel probes
|
|
@@ -635,7 +635,7 @@ export async function apply(ctx) {
|
|
|
635
635
|
return () => { for (const d of disposers.reverse()) d(); };
|
|
636
636
|
});
|
|
637
637
|
|
|
638
|
-
ctx.logger?.info?.('dsh-
|
|
638
|
+
ctx.logger?.info?.('dsh-adapter hub mounted (jobs API + installer endpoints + multimodal tools)');
|
|
639
639
|
return async () => {
|
|
640
640
|
for (const d of disposers.reverse()) { try { d(); } catch {} }
|
|
641
641
|
await hub.dispose();
|
package/src/hub-client.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// Client for the in-host workers-hub jobs API. When a DSH web instance with the
|
|
2
|
-
// dsh-
|
|
2
|
+
// dsh-adapter bundle is running, jobs run inside it (sessions visible in the
|
|
3
3
|
// Web UI); otherwise the MCP server falls back to standalone runtimes.
|
|
4
4
|
|
|
5
5
|
import { readGlobalConfig } from './install/install.mjs';
|
|
6
6
|
import { pluginEnv } from './plugin-env.mjs';
|
|
7
7
|
|
|
8
|
-
const BASE = (pluginEnv('
|
|
9
|
-
const API = `${BASE}/_dsh/dsh-
|
|
8
|
+
const BASE = (pluginEnv('ADAPTER_HUB') ?? readGlobalConfig().hub_url).replace(/\/$/, '');
|
|
9
|
+
const API = `${BASE}/_dsh/dsh-adapter`;
|
|
10
10
|
|
|
11
11
|
let lastProbe = { at: 0, ok: false };
|
|
12
12
|
|
|
@@ -15,7 +15,7 @@ export async function hubAvailable() {
|
|
|
15
15
|
try {
|
|
16
16
|
const res = await fetch(`${API}/ping`, { signal: AbortSignal.timeout(800) });
|
|
17
17
|
const body = await res.json();
|
|
18
|
-
lastProbe = { at: Date.now(), ok: res.ok && body?.service === 'dsh-
|
|
18
|
+
lastProbe = { at: Date.now(), ok: res.ok && body?.service === 'dsh-adapter-hub' };
|
|
19
19
|
} catch {
|
|
20
20
|
lastProbe = { at: Date.now(), ok: false };
|
|
21
21
|
}
|
package/src/install/install.mjs
CHANGED
|
@@ -8,13 +8,13 @@ import { fileURLToPath } from 'node:url';
|
|
|
8
8
|
import { homedir } from 'node:os';
|
|
9
9
|
|
|
10
10
|
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
11
|
-
const MARKETPLACE_NAME = 'dsh-
|
|
12
|
-
const PLUGIN_KEY = `dsh-
|
|
11
|
+
const MARKETPLACE_NAME = 'dsh-adapter';
|
|
12
|
+
const PLUGIN_KEY = `dsh-adapter@${MARKETPLACE_NAME}`;
|
|
13
13
|
const MCP_TOOLS = ['dsh_run_worker', 'dsh_spawn_worker', 'dsh_worker_status', 'dsh_worker_result', 'dsh_worker_cancel'];
|
|
14
14
|
|
|
15
15
|
function backup(file) {
|
|
16
16
|
if (existsSync(file)) {
|
|
17
|
-
const bak = `${file}.dsh-
|
|
17
|
+
const bak = `${file}.dsh-adapter-backup-${Date.now()}`;
|
|
18
18
|
copyFileSync(file, bak);
|
|
19
19
|
return bak;
|
|
20
20
|
}
|
|
@@ -57,18 +57,21 @@ export function tomlString(s) {
|
|
|
57
57
|
return JSON.stringify(String(s)).replace(/\x7f/g, '\\u007f');
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
// One-time migration
|
|
60
|
+
// One-time migration of the config dir across renames:
|
|
61
|
+
// dsh-workers -> dsh-adapter (this plugin's older name), then
|
|
62
|
+
// dsh-crew -> dsh-adapter (the name before the crew->adapter rebrand).
|
|
63
|
+
// The newest directory wins: a user who already has dsh-adapter keeps it.
|
|
61
64
|
try {
|
|
62
|
-
const
|
|
63
|
-
const newDir = join(homedir(), '.config', 'dsh-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
renameSync(oldDir, newDir);
|
|
65
|
+
const { renameSync } = await import('node:fs');
|
|
66
|
+
const newDir = join(homedir(), '.config', 'dsh-adapter');
|
|
67
|
+
for (const legacy of ['dsh-workers', 'dsh-crew']) {
|
|
68
|
+
const oldDir = join(homedir(), '.config', legacy);
|
|
69
|
+
if (existsSync(oldDir) && !existsSync(newDir)) renameSync(oldDir, newDir);
|
|
67
70
|
}
|
|
68
71
|
} catch {}
|
|
69
72
|
|
|
70
73
|
const GLOBAL_CONFIG_FILE = join(CONFIG_DIR_HOME(), 'config.json');
|
|
71
|
-
function CONFIG_DIR_HOME() { return join(homedir(), '.config', 'dsh-
|
|
74
|
+
function CONFIG_DIR_HOME() { return join(homedir(), '.config', 'dsh-adapter'); }
|
|
72
75
|
|
|
73
76
|
export const GLOBAL_CONFIG_DEFAULTS = {
|
|
74
77
|
default_tier: 'flash',
|
|
@@ -83,8 +86,8 @@ export const GLOBAL_CONFIG_DEFAULTS = {
|
|
|
83
86
|
escalate_on_failure: false,
|
|
84
87
|
// Multimodal bridge: which subscription CLI lends the text-only DS model
|
|
85
88
|
// eyes (describe_image) and a brush (generate_image).
|
|
86
|
-
vision_provider: '
|
|
87
|
-
vision_model: '
|
|
89
|
+
vision_provider: 'codex', // codex | claude-code | grok | agy | <custom id> | off
|
|
90
|
+
vision_model: 'default', // model passed to the vision CLI; free-form
|
|
88
91
|
imagegen_provider: 'codex', // codex | agy | grok | <custom id> | off
|
|
89
92
|
// User-defined providers, each either an OpenAI-compatible HTTP endpoint or a
|
|
90
93
|
// local command. Entry shape:
|
|
@@ -134,10 +137,10 @@ export function installStatus({ home = homedir() } = {}) {
|
|
|
134
137
|
&& settings.statusLine.command.includes('worker-segment.sh');
|
|
135
138
|
const codexInstalled = existsSync(join(home, '.codex', 'agents', 'ds-flash.toml'));
|
|
136
139
|
const agyMcp = readJson(join(home, '.gemini', 'config', 'mcp_config.json'), {});
|
|
137
|
-
const agyInstalled = !!(agyMcp.mcpServers && agyMcp.mcpServers['dsh-
|
|
140
|
+
const agyInstalled = !!(agyMcp.mcpServers && agyMcp.mcpServers['dsh-adapter'])
|
|
138
141
|
|| existsSync(join(home, '.gemini', 'config', 'agents', 'ds-flash.md'));
|
|
139
142
|
const grokTxt = readText(join(home, '.grok', 'config.toml'));
|
|
140
|
-
const grokInstalled = grokTxt.includes('[mcp_servers.dsh-
|
|
143
|
+
const grokInstalled = grokTxt.includes('[mcp_servers.dsh-adapter]')
|
|
141
144
|
|| existsSync(join(home, '.grok', 'agents', 'ds-flash.md'));
|
|
142
145
|
return {
|
|
143
146
|
claude: { installed: claudeInstalled, hud: hudWired },
|
|
@@ -210,7 +213,7 @@ export async function installClaudeCode({ home = homedir(), statusline = false }
|
|
|
210
213
|
actions.push(`removed ${preRename.length} pre-rename permission rules`);
|
|
211
214
|
}
|
|
212
215
|
for (const tool of MCP_TOOLS) {
|
|
213
|
-
const rule = `mcp__plugin_dsh-
|
|
216
|
+
const rule = `mcp__plugin_dsh-adapter_dsh-adapter__${tool}`;
|
|
214
217
|
if (!allow.includes(rule)) allow.push(rule);
|
|
215
218
|
}
|
|
216
219
|
settings.permissions.allow = allow;
|
|
@@ -306,9 +309,9 @@ export function installAgy({ home = homedir() } = {}) {
|
|
|
306
309
|
if (bak) actions.push(`backup: ${bak}`);
|
|
307
310
|
const cfg = readJson(mcpFile, {});
|
|
308
311
|
cfg.mcpServers = cfg.mcpServers ?? {};
|
|
309
|
-
cfg.mcpServers['dsh-
|
|
312
|
+
cfg.mcpServers['dsh-adapter'] = { command: 'node', args: [serverPath], disabled: false };
|
|
310
313
|
writeFileSync(mcpFile, JSON.stringify(cfg, null, 2) + '\n');
|
|
311
|
-
actions.push(`mcp: registered dsh-
|
|
314
|
+
actions.push(`mcp: registered dsh-adapter (node ${serverPath}) in ${mcpFile}`);
|
|
312
315
|
|
|
313
316
|
// 2. Agent definitions (no path rendering needed — agy reads the global MCP
|
|
314
317
|
// config itself, so the roles never embed a server path).
|
|
@@ -339,11 +342,11 @@ export function uninstallAgy({ home = homedir() } = {}) {
|
|
|
339
342
|
|
|
340
343
|
const mcpFile = join(home, '.gemini', 'config', 'mcp_config.json');
|
|
341
344
|
const cfg = readJson(mcpFile, null);
|
|
342
|
-
if (cfg && cfg.mcpServers && cfg.mcpServers['dsh-
|
|
345
|
+
if (cfg && cfg.mcpServers && cfg.mcpServers['dsh-adapter']) {
|
|
343
346
|
backup(mcpFile);
|
|
344
|
-
delete cfg.mcpServers['dsh-
|
|
347
|
+
delete cfg.mcpServers['dsh-adapter'];
|
|
345
348
|
writeFileSync(mcpFile, JSON.stringify(cfg, null, 2) + '\n');
|
|
346
|
-
actions.push(`mcp: removed dsh-
|
|
349
|
+
actions.push(`mcp: removed dsh-adapter from ${mcpFile} (backup kept)`);
|
|
347
350
|
}
|
|
348
351
|
|
|
349
352
|
for (const f of ['ds-flash.md', 'ds-pro.md']) {
|
|
@@ -367,7 +370,7 @@ export function uninstallAgy({ home = homedir() } = {}) {
|
|
|
367
370
|
|
|
368
371
|
// Tool-schema caches (regenerable — agy re-creates them on next server use).
|
|
369
372
|
for (const flavour of ['antigravity', 'antigravity-cli', 'antigravity-ide']) {
|
|
370
|
-
const p = join(home, '.gemini', flavour, 'mcp', 'dsh-
|
|
373
|
+
const p = join(home, '.gemini', flavour, 'mcp', 'dsh-adapter');
|
|
371
374
|
if (existsSync(p)) {
|
|
372
375
|
rmSync(p, { recursive: true, force: true });
|
|
373
376
|
actions.push(`removed mcp cache: ${p}`);
|
|
@@ -394,16 +397,16 @@ export function installGrok({ home = homedir() } = {}) {
|
|
|
394
397
|
}
|
|
395
398
|
|
|
396
399
|
// 1. MCP server section in ~/.grok/config.toml (idempotent: replace the
|
|
397
|
-
// existing [mcp_servers.dsh-
|
|
400
|
+
// existing [mcp_servers.dsh-adapter] block if present, keep the rest).
|
|
398
401
|
const cfgFile = join(home, '.grok', 'config.toml');
|
|
399
402
|
mkdirSync(dirname(cfgFile), { recursive: true });
|
|
400
403
|
const bak = backup(cfgFile);
|
|
401
404
|
if (bak) actions.push(`backup: ${bak}`);
|
|
402
405
|
let toml = readText(cfgFile);
|
|
403
|
-
toml = removeTomlSection(toml, 'mcp_servers.dsh-
|
|
404
|
-
toml += `\n\n[mcp_servers.dsh-
|
|
406
|
+
toml = removeTomlSection(toml, 'mcp_servers.dsh-adapter').replace(/\n+$/, '');
|
|
407
|
+
toml += `\n\n[mcp_servers.dsh-adapter]\ncommand = "node"\nargs = [${tomlString(serverPath)}]\nenabled = true\n`;
|
|
405
408
|
writeFileSync(cfgFile, toml);
|
|
406
|
-
actions.push(`mcp: registered dsh-
|
|
409
|
+
actions.push(`mcp: registered dsh-adapter (node ${serverPath}) in ${cfgFile}`);
|
|
407
410
|
|
|
408
411
|
// 2. Agent definitions.
|
|
409
412
|
const agentsDir = join(home, '.grok', 'agents');
|
|
@@ -435,15 +438,15 @@ export function uninstallGrok({ home = homedir() } = {}) {
|
|
|
435
438
|
const cfgFile = join(home, '.grok', 'config.toml');
|
|
436
439
|
if (existsSync(cfgFile)) {
|
|
437
440
|
const before = readText(cfgFile);
|
|
438
|
-
let after = removeTomlSection(before, 'mcp_servers.dsh-
|
|
439
|
-
// Drop dsh-
|
|
440
|
-
after = after.split('\n').map((l) => (l.includes('disabled_mcp_servers') && l.includes('dsh-
|
|
441
|
-
? l.replace(/"dsh-
|
|
441
|
+
let after = removeTomlSection(before, 'mcp_servers.dsh-adapter');
|
|
442
|
+
// Drop dsh-adapter from any disabled_mcp_servers list grok may have written.
|
|
443
|
+
after = after.split('\n').map((l) => (l.includes('disabled_mcp_servers') && l.includes('dsh-adapter')
|
|
444
|
+
? l.replace(/"dsh-adapter"\s*,?\s*/g, '').replace(/,\s*\]/g, ']')
|
|
442
445
|
: l)).join('\n');
|
|
443
446
|
if (after !== before) {
|
|
444
447
|
backup(cfgFile);
|
|
445
448
|
writeFileSync(cfgFile, after.replace(/\n{3,}$/, '\n'));
|
|
446
|
-
actions.push(`mcp: removed dsh-
|
|
449
|
+
actions.push(`mcp: removed dsh-adapter from ${cfgFile} (backup kept)`);
|
|
447
450
|
}
|
|
448
451
|
}
|
|
449
452
|
|
|
@@ -506,7 +509,7 @@ export function installHudSegment({ home = homedir() } = {}) {
|
|
|
506
509
|
|
|
507
510
|
/**
|
|
508
511
|
* Array-form extraKnownMarketplaces entries are keyed objects shaped like
|
|
509
|
-
* { "dsh-
|
|
512
|
+
* { "dsh-adapter": { source: { source: 'directory', path } } } — never arrays
|
|
510
513
|
* of paths. Match any element that names this marketplace, or whose
|
|
511
514
|
* directory (source.path, or a top-level path for safety) resolves to the
|
|
512
515
|
* repo ROOT this installer registers.
|
|
@@ -538,7 +541,7 @@ export async function uninstallClaudeCode({ home = homedir() } = {}) {
|
|
|
538
541
|
delete settings.enabledPlugins[PLUGIN_KEY];
|
|
539
542
|
}
|
|
540
543
|
if (settings.permissions?.allow) {
|
|
541
|
-
settings.permissions.allow = settings.permissions.allow.filter((r) => !r.startsWith('mcp__plugin_dsh-
|
|
544
|
+
settings.permissions.allow = settings.permissions.allow.filter((r) => !r.startsWith('mcp__plugin_dsh-adapter_'));
|
|
542
545
|
}
|
|
543
546
|
writeFileSync(settingsFile, JSON.stringify(settings, null, 2) + '\n');
|
|
544
547
|
actions.push('settings: unregistered from settings.json (backup kept)');
|
package/src/jobs.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { dirname, join, resolve } from 'node:path';
|
|
|
11
11
|
import { homedir } from 'node:os';
|
|
12
12
|
|
|
13
13
|
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
14
|
-
const CONFIG_DIR = join(homedir(), '.config', 'dsh-
|
|
14
|
+
const CONFIG_DIR = join(homedir(), '.config', 'dsh-adapter');
|
|
15
15
|
const STATUS_FILE = join(CONFIG_DIR, 'status.json');
|
|
16
16
|
const RUNTIME_BIN = join(ROOT, 'node_modules', '.bin', 'dsh-jsonrpc-agent');
|
|
17
17
|
const CORDIS = join(ROOT, 'worker.cordis.yml');
|
|
@@ -175,7 +175,7 @@ export async function startJob({ task, tier = 'flash', effort = 'max', cwd, maxT
|
|
|
175
175
|
DSH_SESSION_ROOT: join(CONFIG_DIR, 'sessions'),
|
|
176
176
|
DSH_REASONING_EFFORT: effort,
|
|
177
177
|
// Origin guard: the worker runtime inherits the dispatch chain, so a
|
|
178
|
-
//
|
|
178
|
+
// adapter instance it starts itself continues the chain (WPC9).
|
|
179
179
|
...(origin ? { [ORIGIN_CHAIN_ENV]: JSON.stringify(origin.chain), [ORIGIN_DEPTH_ENV]: String(origin.depth) } : {}),
|
|
180
180
|
},
|
|
181
181
|
requestTimeoutMs: timeoutMs,
|
package/src/multimodal.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// subscription CLIs (claude -p, codex exec, agy).
|
|
4
4
|
//
|
|
5
5
|
// Vision ladder (WPC11): native DeepSeek VL model deepseek-v4-flash-vision-exp
|
|
6
|
-
// (direct API call, key from DEEPSEEK_API_KEY or ~/.config/dsh-
|
|
6
|
+
// (direct API call, key from DEEPSEEK_API_KEY or ~/.config/dsh-adapter/.env — the
|
|
7
7
|
// same source the standalone dispatch uses) is preferred whenever a key is
|
|
8
8
|
// available; every failure degrades to the pre-existing CLI provider chain,
|
|
9
9
|
// which is kept byte-for-byte as the fallback. Image generation is untouched:
|
|
@@ -20,7 +20,7 @@ import { join, isAbsolute, dirname } from 'node:path';
|
|
|
20
20
|
import { homedir } from 'node:os';
|
|
21
21
|
import { tr, setLang } from './i18n.mjs';
|
|
22
22
|
|
|
23
|
-
const CONFIG_DIR = join(homedir(), '.config', 'dsh-
|
|
23
|
+
const CONFIG_DIR = join(homedir(), '.config', 'dsh-adapter');
|
|
24
24
|
const CACHE_FILE = join(CONFIG_DIR, 'vision-cache.json');
|
|
25
25
|
const CACHE_CAP = 200;
|
|
26
26
|
|
|
@@ -52,7 +52,7 @@ function loadDotEnv() {
|
|
|
52
52
|
return dotEnv;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/** Key for the native call: env wins, then ~/.config/dsh-
|
|
55
|
+
/** Key for the native call: env wins, then ~/.config/dsh-adapter/.env (same
|
|
56
56
|
* precedence the standalone dispatch applies). */
|
|
57
57
|
function deepseekApiKey() {
|
|
58
58
|
return String(process.env.DEEPSEEK_API_KEY ?? '').trim() || String(loadDotEnv().DEEPSEEK_API_KEY ?? '').trim();
|
|
@@ -250,8 +250,8 @@ async function generateViaApi(entry, prompt, outputPath, size) {
|
|
|
250
250
|
// fail late (or bill for nothing). Image generation is opt-in per provider.
|
|
251
251
|
const m = String(entry.imagegen_model ?? '').trim();
|
|
252
252
|
if (!m) throw new Error(tr(
|
|
253
|
-
`自定义 provider "${entry.name ?? entry.id}" 未配置生图模型(在设置 → DSH
|
|
254
|
-
`Custom provider "${entry.name ?? entry.id}" has no image-gen model (fill in "Image-gen model" under Settings → DSH
|
|
253
|
+
`自定义 provider "${entry.name ?? entry.id}" 未配置生图模型(在设置 → DSH Adapter → 自定义 Provider 的"生图模型"里填写)`,
|
|
254
|
+
`Custom provider "${entry.name ?? entry.id}" has no image-gen model (fill in "Image-gen model" under Settings → DSH Adapter → Custom providers)`));
|
|
255
255
|
const body = { model: m, prompt, n: 1 };
|
|
256
256
|
if (size && /^\d+x\d+$/.test(size)) body.size = size;
|
|
257
257
|
const data = await fetchJson(`${base}/images/generations`, { apiKey: entry.api_key, timeoutMs: 480_000, body });
|
|
@@ -547,8 +547,8 @@ export async function listVisionModels(provider, force = false, getConfig = null
|
|
|
547
547
|
function envelope(tool, text) { return { ok: true, tool, text }; }
|
|
548
548
|
|
|
549
549
|
const VISION_PROVIDER_HINT = tr(
|
|
550
|
-
`未知视觉 provider: PROVIDER(内置: ${BUILTIN_VISION.join(' / ')} / native,或在设置 → DSH
|
|
551
|
-
`Unknown vision provider: PROVIDER (built-in: ${BUILTIN_VISION.join(' / ')} / native, or add one under Settings → DSH
|
|
550
|
+
`未知视觉 provider: PROVIDER(内置: ${BUILTIN_VISION.join(' / ')} / native,或在设置 → DSH Adapter → 自定义 Provider 里添加)`,
|
|
551
|
+
`Unknown vision provider: PROVIDER (built-in: ${BUILTIN_VISION.join(' / ')} / native, or add one under Settings → DSH Adapter → Custom providers)`);
|
|
552
552
|
|
|
553
553
|
/**
|
|
554
554
|
* Cache key for one vision answer. The leading 'v3' version tag plus the
|
|
@@ -592,7 +592,7 @@ async function describeViaCli(provider, model, custom, imagePath, question) {
|
|
|
592
592
|
*/
|
|
593
593
|
export async function describeFileWithProvenance(getConfig, imagePath, question) {
|
|
594
594
|
const config = getConfig();
|
|
595
|
-
const configured = config.vision_provider ?? '
|
|
595
|
+
const configured = config.vision_provider ?? 'codex';
|
|
596
596
|
if (configured === 'off') throw new Error('vision bridge is disabled');
|
|
597
597
|
const model = config.vision_model ?? 'haiku';
|
|
598
598
|
const stat = statSync(imagePath);
|
|
@@ -604,7 +604,7 @@ export async function describeFileWithProvenance(getConfig, imagePath, question)
|
|
|
604
604
|
}
|
|
605
605
|
// For an explicit 'native' id the CLI degradation target is the default
|
|
606
606
|
// chain entry; for built-in CLI providers it is that provider itself.
|
|
607
|
-
const cliProvider = isNativeId ? '
|
|
607
|
+
const cliProvider = isNativeId ? 'codex' : configured;
|
|
608
608
|
const useNativeLadder = BUILTIN_VISION.includes(configured) || isNativeId;
|
|
609
609
|
const cache = readCache();
|
|
610
610
|
|
|
@@ -613,8 +613,8 @@ export async function describeFileWithProvenance(getConfig, imagePath, question)
|
|
|
613
613
|
const apiKey = deepseekApiKey();
|
|
614
614
|
if (!apiKey) {
|
|
615
615
|
nativeIssue = { skipped: true, reason: tr(
|
|
616
|
-
'缺少 DEEPSEEK_API_KEY(环境变量或 ~/.config/dsh-
|
|
617
|
-
'no DEEPSEEK_API_KEY (env or ~/.config/dsh-
|
|
616
|
+
'缺少 DEEPSEEK_API_KEY(环境变量或 ~/.config/dsh-adapter/.env)',
|
|
617
|
+
'no DEEPSEEK_API_KEY (env or ~/.config/dsh-adapter/.env)') };
|
|
618
618
|
} else {
|
|
619
619
|
const key = visionCacheKey({ backend: 'native', provider: 'deepseek', model: NATIVE_VISION_MODEL, imagePath, stat, question, baseUrl: deepseekBaseUrl() });
|
|
620
620
|
if (cache[key]) {
|
|
@@ -626,11 +626,11 @@ export async function describeFileWithProvenance(getConfig, imagePath, question)
|
|
|
626
626
|
if (text === '') throw new Error('native returned an empty answer');
|
|
627
627
|
cache[key] = text;
|
|
628
628
|
writeCache(cache);
|
|
629
|
-
console.warn(`dsh-
|
|
629
|
+
console.warn(`dsh-adapter: vision answered by native ${NATIVE_VISION_MODEL} in ${Date.now() - started}ms`);
|
|
630
630
|
return { text, provider: `native · ${NATIVE_VISION_MODEL}`, model: NATIVE_VISION_MODEL, cached: false };
|
|
631
631
|
} catch (err) {
|
|
632
632
|
nativeIssue = { skipped: false, reason: String(err?.message ?? err) };
|
|
633
|
-
console.warn(`dsh-
|
|
633
|
+
console.warn(`dsh-adapter: native vision failed, falling back to "${cliProvider}": ${nativeIssue.reason}`);
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
636
|
}
|
|
@@ -679,8 +679,8 @@ export function createMultimodalTools(getConfig) {
|
|
|
679
679
|
},
|
|
680
680
|
async execute(args) {
|
|
681
681
|
const config = getConfig();
|
|
682
|
-
const provider = config.vision_provider ?? '
|
|
683
|
-
if (provider === 'off') throw new Error(tr('视觉桥已关闭(设置 → DSH
|
|
682
|
+
const provider = config.vision_provider ?? 'codex';
|
|
683
|
+
if (provider === 'off') throw new Error(tr('视觉桥已关闭(设置 → DSH Adapter → 视觉 provider)', 'the vision bridge is disabled (Settings → DSH Adapter → Vision provider)'));
|
|
684
684
|
const imagePath = String(args.image_path ?? '');
|
|
685
685
|
if (!isAbsolute(imagePath) || !existsSync(imagePath)) throw new Error(`image_path must be an existing absolute path, got: ${imagePath}`);
|
|
686
686
|
const question = typeof args.question === 'string' && args.question !== ''
|
|
@@ -715,7 +715,7 @@ export function createMultimodalTools(getConfig) {
|
|
|
715
715
|
async execute(args) {
|
|
716
716
|
const config = getConfig();
|
|
717
717
|
const provider = args.provider ?? config.imagegen_provider ?? 'codex';
|
|
718
|
-
if (provider === 'off') throw new Error(tr('生图已关闭(设置 → DSH
|
|
718
|
+
if (provider === 'off') throw new Error(tr('生图已关闭(设置 → DSH Adapter → 生图 provider)', 'image generation is disabled (Settings → DSH Adapter → Image-gen provider)'));
|
|
719
719
|
const outputPath = String(args.output_path ?? '');
|
|
720
720
|
if (!isAbsolute(outputPath)) throw new Error(`output_path must be absolute, got: ${outputPath}`);
|
|
721
721
|
const prompt = String(args.prompt ?? '').trim();
|
|
@@ -723,8 +723,8 @@ export function createMultimodalTools(getConfig) {
|
|
|
723
723
|
const custom = BUILTIN_IMAGEGEN.includes(provider) ? null : findCustomProvider(config, provider);
|
|
724
724
|
if (!BUILTIN_IMAGEGEN.includes(provider) && !custom) {
|
|
725
725
|
throw new Error(tr(
|
|
726
|
-
`未知生图 provider: ${provider}(内置: ${BUILTIN_IMAGEGEN.join(' / ')},或在设置 → DSH
|
|
727
|
-
`Unknown image-gen provider: ${provider} (built-in: ${BUILTIN_IMAGEGEN.join(' / ')}, or add one under Settings → DSH
|
|
726
|
+
`未知生图 provider: ${provider}(内置: ${BUILTIN_IMAGEGEN.join(' / ')},或在设置 → DSH Adapter → 自定义 Provider 里添加)`,
|
|
727
|
+
`Unknown image-gen provider: ${provider} (built-in: ${BUILTIN_IMAGEGEN.join(' / ')}, or add one under Settings → DSH Adapter → Custom providers)`));
|
|
728
728
|
}
|
|
729
729
|
const saved = custom
|
|
730
730
|
? (entryType(custom) === 'cli'
|