@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/origin-guard.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Origin-chain guard against recursive worker self-amplification (WPC9 guardrail 1).
|
|
2
2
|
//
|
|
3
3
|
// Every dispatch carries an origin chain: the ordered list of (backend, cwd)
|
|
4
|
-
// hops the task has already travelled. A
|
|
5
|
-
// someone else's worker — CC dispatches to codex, codex (
|
|
4
|
+
// hops the task has already travelled. A adapter-enabled host can itself be
|
|
5
|
+
// someone else's worker — CC dispatches to codex, codex (adapter installed)
|
|
6
6
|
// dispatches back — and without a guard the host×backend matrix lets one
|
|
7
7
|
// worker spawn another forever: quota burns through in minutes while every
|
|
8
8
|
// single vantage point along the chain looks innocent.
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
// source: orchestrator id of the dispatching host ('claude-code', 'codex', ...) }
|
|
14
14
|
//
|
|
15
15
|
// Cross-process transport:
|
|
16
|
-
// - This MCP server reads
|
|
17
|
-
// startup and inherits it as INHERITED_ORIGIN;
|
|
16
|
+
// - This MCP server reads DSH_ADAPTER_ORIGIN_CHAIN (JSON array of hops) at
|
|
17
|
+
// startup and inherits it as INHERITED_ORIGIN; adapter instances spawned
|
|
18
18
|
// down-chain do the same, so the chain survives process boundaries.
|
|
19
19
|
// - Every dispatch appends its own hop and passes the extended chain to the
|
|
20
|
-
// worker: env vars
|
|
20
|
+
// worker: env vars DSH_ADAPTER_ORIGIN_CHAIN / DSH_ADAPTER_DEPTH for CLI and
|
|
21
21
|
// standalone children (jobs.mjs / cli-workers.mjs spawn env), and
|
|
22
22
|
// origin_chain / origin_depth spec fields for hub spawns (hub-client is
|
|
23
23
|
// unchanged; the current hub ignores unknown spec fields and this
|
|
24
24
|
// client-side session re-attaches them to every hub view it returns).
|
|
25
|
-
// -
|
|
25
|
+
// - DSH_ADAPTER_DEPTH is written alongside as an integer for observability but
|
|
26
26
|
// is never trusted on read: the chain is authoritative and depth is
|
|
27
27
|
// derived from its length (env can be hostile).
|
|
28
28
|
//
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
|
|
34
34
|
import { normalizeCwd } from './cwd-lock.mjs';
|
|
35
35
|
|
|
36
|
-
export const ORIGIN_CHAIN_ENV = '
|
|
37
|
-
export const ORIGIN_DEPTH_ENV = '
|
|
36
|
+
export const ORIGIN_CHAIN_ENV = 'DSH_ADAPTER_ORIGIN_CHAIN';
|
|
37
|
+
export const ORIGIN_DEPTH_ENV = 'DSH_ADAPTER_DEPTH';
|
|
38
38
|
|
|
39
39
|
// Why 3: depth = number of dispatch hops. 1 is a direct worker, 2 a worker
|
|
40
40
|
// delegating once, 3 one more legitimate re-delegation — real fan-out graphs
|
package/src/plugin-env.mjs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
export const PLUGIN_ENV_PREFIX = 'DSHPLUGIN_';
|
|
18
18
|
export const LEGACY_ENV_PREFIX = 'DSH_';
|
|
19
19
|
|
|
20
|
-
const PLUGIN_LABEL = 'dsh-
|
|
20
|
+
const PLUGIN_LABEL = 'dsh-adapter';
|
|
21
21
|
|
|
22
22
|
/** One warning per legacy variable per process, not one per lookup. */
|
|
23
23
|
const warned = new Set();
|
|
@@ -38,7 +38,7 @@ export function legacyEnvName(suffix) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* Read one plugin variable by its suffix (e.g. '
|
|
41
|
+
* Read one plugin variable by its suffix (e.g. 'ADAPTER_HUB').
|
|
42
42
|
*
|
|
43
43
|
* Resolution is by PRESENCE, not truthiness: a new variable set to the empty
|
|
44
44
|
* string is a deliberate "no override" and must not silently resurrect a stale
|
package/src/proc-kill.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// OS process a job ran in. Standalone runtimes and agy/grok CLI workers are
|
|
5
5
|
// independent processes: when their dispatching host dies, the process can
|
|
6
6
|
// survive as a true orphan. This module backs the hub endpoints
|
|
7
|
-
// (/_dsh/dsh-
|
|
7
|
+
// (/_dsh/dsh-adapter/proc-alive and /_dsh/dsh-adapter/proc-kill):
|
|
8
8
|
//
|
|
9
9
|
// 1. Is pid alive? process.kill(pid, 0) - the same probe the status shard
|
|
10
10
|
// uses for writer liveness (status-shard.mjs writerProcessAlive).
|
|
@@ -114,13 +114,13 @@ export function isWorkerCommand(command) {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
const NOT_A_WORKER_ZH = (pid, command) =>
|
|
117
|
-
'拒绝杀死 pid ' + pid + ':其命令行不匹配任何 dsh-
|
|
117
|
+
'拒绝杀死 pid ' + pid + ':其命令行不匹配任何 dsh-adapter 工作进程特征(该 pid 可能已被系统回收复用)。\n' +
|
|
118
118
|
'命令行:' + command + '\n' +
|
|
119
119
|
'可杀特征:standalone DSH 运行时(…dsh-sdk-jsonrpc-demo… worker.cordis.yml)、' +
|
|
120
120
|
'agy(…--output-format stream-json…)、grok(…streaming-messages-json…)。';
|
|
121
121
|
|
|
122
122
|
const NOT_A_WORKER_EN = (pid, command) =>
|
|
123
|
-
'Refusing to kill pid ' + pid + ': its command line matches no process shape dsh-
|
|
123
|
+
'Refusing to kill pid ' + pid + ': its command line matches no process shape dsh-adapter spawns (the pid may have been recycled).\n' +
|
|
124
124
|
'command: ' + command + '\n' +
|
|
125
125
|
'Accepted shapes: standalone DSH runtime (…dsh-sdk-jsonrpc-demo… worker.cordis.yml), ' +
|
|
126
126
|
'agy (…--output-format stream-json…), grok (…streaming-messages-json…).';
|
|
@@ -143,8 +143,8 @@ export async function killWorkerProcess({ pid, pgid, graceMs = PROC_KILL_GRACE_M
|
|
|
143
143
|
if (groupKill && (parsePid(pgid) === null || pgid !== pid)) {
|
|
144
144
|
throw new ProcKillRefused(
|
|
145
145
|
'pgid-mismatch',
|
|
146
|
-
'pgid ' + pgid + ' 与 pid ' + pid + ' 不一致 — 拒绝整组杀死(dsh-
|
|
147
|
-
'pgid ' + pgid + ' does not match pid ' + pid + ' — refusing the group kill (dsh-
|
|
146
|
+
'pgid ' + pgid + ' 与 pid ' + pid + ' 不一致 — 拒绝整组杀死(dsh-adapter 只会记录 pgid === pid 的进程组)',
|
|
147
|
+
'pgid ' + pgid + ' does not match pid ' + pid + ' — refusing the group kill (dsh-adapter only ever records pgid === pid)',
|
|
148
148
|
{ pid, pgid },
|
|
149
149
|
);
|
|
150
150
|
}
|
package/src/provider-probe.mjs
CHANGED
|
@@ -9,12 +9,12 @@ export async function probeProvider(llm, binding, { timeoutMs = 20000 } = {}) {
|
|
|
9
9
|
const collect = async () => {
|
|
10
10
|
let finish, matched = false;
|
|
11
11
|
for await (const chunk of llm.stream({ ...binding, maxTokens: 256, signal: controller.signal,
|
|
12
|
-
messages: [{ role: 'user', content: [{ type: 'text', text: `Call
|
|
13
|
-
tools: [{ name: '
|
|
12
|
+
messages: [{ role: 'user', content: [{ type: 'text', text: `Call dsh_adapter_probe_noop exactly once with nonce ${nonce}. This tool has no side effects. Do not answer with prose.` }] }],
|
|
13
|
+
tools: [{ name: 'dsh_adapter_probe_noop', description: 'A capability check with no filesystem or network effects.', parameters: {
|
|
14
14
|
type: 'object', properties: { nonce: { type: 'string' } }, required: ['nonce'], additionalProperties: false,
|
|
15
15
|
} }],
|
|
16
16
|
})) {
|
|
17
|
-
if (chunk.type === 'block-end' && chunk.block?.type === 'tool-call' && chunk.block.name === '
|
|
17
|
+
if (chunk.type === 'block-end' && chunk.block?.type === 'tool-call' && chunk.block.name === 'dsh_adapter_probe_noop') {
|
|
18
18
|
try { const args = JSON.parse(chunk.block.arguments); if (args?.nonce === nonce && Object.keys(args).length === 1) matched = true; } catch {}
|
|
19
19
|
}
|
|
20
20
|
if (chunk.type === 'finish') finish = chunk.reason?.kind;
|
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-
|
|
15
|
+
const server = new McpServer({ name: 'dsh-adapter', version: '0.1.1' });
|
|
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).');
|
|
@@ -21,7 +21,7 @@ const allowConcurrentCwdSchema = z.boolean().optional().describe('Allow this dis
|
|
|
21
21
|
|
|
22
22
|
// Session-level configuration. This MCP server process lives exactly as long
|
|
23
23
|
// as one Claude Code / Codex session, so plain memory IS session scope.
|
|
24
|
-
// Initial values come from the global config (~/.config/dsh-
|
|
24
|
+
// Initial values come from the global config (~/.config/dsh-adapter/config.json,
|
|
25
25
|
// edited on the DSH settings page); dsh_worker_config overrides per session.
|
|
26
26
|
import { readGlobalConfig } from './install/install.mjs';
|
|
27
27
|
import { describeBindings, resolveTierBinding } from './tier-binding.mjs';
|
|
@@ -73,8 +73,8 @@ const ORCHESTRATOR = detectOrchestrator();
|
|
|
73
73
|
|
|
74
74
|
// ---------- WPC9 guardrails ----------
|
|
75
75
|
|
|
76
|
-
// Origin chain this
|
|
77
|
-
// startup from the env written by the dispatching
|
|
76
|
+
// Origin chain this adapter instance inherited from whoever spawned it (read at
|
|
77
|
+
// startup from the env written by the dispatching adapter — origin-guard.mjs).
|
|
78
78
|
// Every dispatch appends its own hop and refuses loops / over-deep chains
|
|
79
79
|
// BEFORE anything is spawned, so recursion can never start burning quota.
|
|
80
80
|
const INHERITED_ORIGIN = readInheritedOrigin(process.env);
|
package/src/status-shard.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Sharded worker-status publishing: every writer (hub process, per-session
|
|
2
|
-
// standalone MCP server) owns one file under ~/.config/dsh-
|
|
2
|
+
// standalone MCP server) owns one file under ~/.config/dsh-adapter/status.d/
|
|
3
3
|
// and readers merge all fresh shards. Kills the last-writer-wins race that a
|
|
4
4
|
// single shared status.json had with multiple concurrent writers.
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ import { writeFileSync, mkdirSync, rmSync, readdirSync, readFileSync } from 'nod
|
|
|
7
7
|
import { join } from 'node:path';
|
|
8
8
|
import { homedir } from 'node:os';
|
|
9
9
|
|
|
10
|
-
const CONFIG_DIR = join(homedir(), '.config', 'dsh-
|
|
10
|
+
const CONFIG_DIR = join(homedir(), '.config', 'dsh-adapter');
|
|
11
11
|
const SHARD_DIR = join(CONFIG_DIR, 'status.d');
|
|
12
12
|
export const SHARD_FRESH_MS = 30 * 60 * 1000;
|
|
13
13
|
|
package/src/vision-route.mjs
CHANGED
|
@@ -22,7 +22,7 @@ import { tr } from './i18n.mjs';
|
|
|
22
22
|
|
|
23
23
|
const VISION_PROVIDER = 'deepseek-vision';
|
|
24
24
|
const DELEGATE = 'deepseek-official';
|
|
25
|
-
const ATTACH_DIR = join(homedir(), '.config', 'dsh-
|
|
25
|
+
const ATTACH_DIR = join(homedir(), '.config', 'dsh-adapter', 'attachments');
|
|
26
26
|
|
|
27
27
|
const EXT = { 'image/png': 'png', 'image/jpeg': 'jpg', 'image/webp': 'webp', 'image/gif': 'gif' };
|
|
28
28
|
|
|
@@ -112,7 +112,7 @@ export function installVisionRoute(ctx, getConfig) {
|
|
|
112
112
|
const { text: desc, provider } = await describeFileWithProvenance(getConfig, path, tr(
|
|
113
113
|
'详细描述这张图片:整体内容、布局结构、可见文字(逐字)、颜色与显著元素。',
|
|
114
114
|
'Describe this image in detail: overall content, layout, any visible text (verbatim), colours and notable elements.'));
|
|
115
|
-
ctx.logger?.info?.(`dsh-
|
|
115
|
+
ctx.logger?.info?.(`dsh-adapter: vision transcript for ${path} via ${provider}`);
|
|
116
116
|
content.push({
|
|
117
117
|
type: 'text',
|
|
118
118
|
text: `${TRANSCRIPT_PREFIX(name)}\n${desc}\n${tr(
|
|
@@ -134,6 +134,6 @@ export function installVisionRoute(ctx, getConfig) {
|
|
|
134
134
|
return changed ? { kind: 'enter', messages: rewritten } : decision;
|
|
135
135
|
}));
|
|
136
136
|
|
|
137
|
-
ctx.logger?.info?.('dsh-
|
|
137
|
+
ctx.logger?.info?.('dsh-adapter: vision route registered (provider "deepseek-vision" + pre-step transcription)');
|
|
138
138
|
return () => { for (const d of disposers.reverse()) { try { d(); } catch {} } };
|
|
139
139
|
}
|
package/statusline/statusline.sh
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# dsh-
|
|
2
|
+
# dsh-adapter statusline: prepends the live worker-pool segment (merged from
|
|
3
3
|
# all status shards) to a basic statusline. For claude-hud users prefer
|
|
4
4
|
# wiring worker-segment.sh via --extra-cmd instead (cli.mjs hud does this).
|
|
5
5
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
# Compact DSH worker segment for claude-hud --extra-cmd (or any statusline).
|
|
3
|
-
# Merges all fresh status shards (~/.config/dsh-
|
|
3
|
+
# Merges all fresh status shards (~/.config/dsh-adapter/status.d/*.json plus
|
|
4
4
|
# the legacy status.json during transition) so workers dispatched by ANY
|
|
5
5
|
# orchestrator on this machine are visible. Running jobs show tier, elapsed,
|
|
6
6
|
# and tokens; idle with history shows "⚙dsh ✓N"; no jobs prints nothing.
|
|
7
|
-
# Override the shard dir with $
|
|
7
|
+
# Override the shard dir with $DSH_ADAPTER_STATUS_DIR (mainly for tests).
|
|
8
8
|
|
|
9
|
-
dir="${
|
|
9
|
+
dir="${DSH_ADAPTER_STATUS_DIR:-$HOME/.config/dsh-adapter}"
|
|
10
10
|
files=()
|
|
11
11
|
for f in "$dir"/status.d/*.json "$dir"/status.json; do
|
|
12
12
|
[ -f "$f" ] && files+=("$f")
|
package/worker.cordis.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# dsh-
|
|
1
|
+
# dsh-adapter: unattended coding-worker composition for dsh-jsonrpc-agent.
|
|
2
2
|
# stdout is reserved for JSON-RPC frames; never add a console logger here.
|
|
3
3
|
# Model/provider arrive per process via the SDK initialize handshake.
|
|
4
4
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|