@zoraxylia/dsh-codex-adapter 0.0.0-stage → 0.1.0
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 +15 -0
- package/.claude-plugin/plugin.json +8 -0
- package/.mcp.json +8 -0
- package/LICENSE +21 -0
- package/README.de.md +480 -0
- package/README.es.md +480 -0
- package/README.fr.md +480 -0
- package/README.hi.md +480 -0
- package/README.id.md +480 -0
- package/README.ja.md +478 -0
- package/README.ko.md +480 -0
- package/README.md +483 -2
- package/README.pt.md +480 -0
- package/README.ru.md +480 -0
- package/README.th.md +480 -0
- package/README.tr.md +480 -0
- package/README.vi.md +480 -0
- package/README.zh-TW.md +478 -0
- package/README.zh.md +482 -0
- package/agents/ds-flash.md +17 -0
- package/agents/ds-pro.md +17 -0
- package/agy/agents/ds-flash.md +18 -0
- package/agy/agents/ds-pro.md +18 -0
- package/agy/skills/dsh-config/SKILL.md +6 -0
- package/agy/skills/dsh-playbook/SKILL.md +65 -0
- package/agy/skills/dsh-status/SKILL.md +6 -0
- package/codex/agents/ds-flash.toml +23 -0
- package/codex/agents/ds-pro.toml +23 -0
- package/codex/prompts/dsh-config.md +3 -0
- package/codex/prompts/dsh-playbook.md +60 -0
- package/codex/prompts/dsh-status.md +1 -0
- package/commands/config.md +9 -0
- package/commands/off.md +5 -0
- package/commands/on.md +5 -0
- package/commands/playbook.md +64 -0
- package/commands/status.md +5 -0
- package/cordis.patch.yml +4 -0
- package/docs/images/dsh-crew-host.png +0 -0
- package/docs/images/dsh-crew-jobs.png +0 -0
- package/docs/images/dsh-crew-logo.png +0 -0
- package/docs/images/dsh-crew-overview.png +0 -0
- package/grok/agents/ds-flash.md +19 -0
- package/grok/agents/ds-pro.md +19 -0
- package/grok/commands/dsh-config.md +9 -0
- package/grok/commands/dsh-playbook.md +66 -0
- package/grok/commands/dsh-status.md +5 -0
- package/lib/client.js +2684 -0
- package/lib/server.mjs +15417 -0
- package/package.json +137 -4
- package/scripts/build-client.mjs +23 -0
- package/scripts/build-mcp.mjs +43 -0
- package/scripts/fake-agy.sh +23 -0
- package/scripts/release-local.mjs +87 -0
- package/scripts/smoke-bundle.mjs +166 -0
- package/scripts/smoke-cwd.mjs +41 -0
- package/scripts/smoke-pack.mjs +285 -0
- package/scripts/smoke.mjs +79 -0
- package/scripts/verify-cli-workers.mjs +133 -0
- package/scripts/verify-wpc10-client.mjs +237 -0
- package/scripts/verify-wpc14-proc-endpoints.mjs +356 -0
- package/scripts/verify-wpc9-guardrails.mjs +432 -0
- package/src/cli-workers.mjs +396 -0
- package/src/client/index.tsx +1133 -0
- package/src/client/jobs-view.ts +374 -0
- package/src/cwd-lock.mjs +91 -0
- package/src/hub/index.mjs +643 -0
- package/src/hub-client.mjs +72 -0
- package/src/i18n.mjs +19 -0
- package/src/install/cli.mjs +34 -0
- package/src/install/install.mjs +577 -0
- package/src/jobs.mjs +289 -0
- package/src/multimodal.mjs +744 -0
- package/src/origin-guard.mjs +133 -0
- package/src/paths.mjs +43 -0
- package/src/plugin-env.mjs +65 -0
- package/src/proc-kill.mjs +208 -0
- package/src/process-info.mjs +60 -0
- package/src/provider-probe.mjs +35 -0
- package/src/server.mjs +438 -0
- package/src/status-shard.mjs +95 -0
- package/src/tier-binding.mjs +63 -0
- package/src/vision-route.mjs +139 -0
- package/src/worker-profiles.mjs +95 -0
- package/src/worker-question.mjs +22 -0
- package/statusline/statusline.sh +14 -0
- package/statusline/worker-segment.sh +35 -0
- package/worker.cordis.yml +77 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
// Smoke test for the published tarball. It reproduces, step by step, the
|
|
2
|
+
// exact failure that shipped in 0.1.0-rc.1 and 0.1.0-rc.2 and guards against
|
|
3
|
+
// it coming back:
|
|
4
|
+
//
|
|
5
|
+
// 1. npm pack the current tree (prepack runs smoke:mcp, which rebuilds
|
|
6
|
+
// lib/server.mjs and asserts the bundle invariants first);
|
|
7
|
+
// 2. install the tarball with plain npm into a brand-new empty directory;
|
|
8
|
+
// 3. the install must succeed with NO ERESOLVE, and must NOT pull any
|
|
9
|
+
// @deepseek-ai/* package into node_modules (@deepseek-ai/* is host
|
|
10
|
+
// runtime only - the DSH host provides it, plain npm never must);
|
|
11
|
+
// 4. both src/server.mjs and lib/server.mjs must answer initialize +
|
|
12
|
+
// tools/list with the full 6-tool roster and matching versions.
|
|
13
|
+
//
|
|
14
|
+
// Why this exists: rc.1/rc.2 declared the whole @deepseek-ai/* stack as
|
|
15
|
+
// REQUIRED peerDependencies. npm 7+ auto-installs peers, and the pinned
|
|
16
|
+
// 0.1.0-rc.6 versions conflict with the 0.1.0-rc.8 transitive resolution
|
|
17
|
+
// inside dsh-agent-spine-demo -> dsh-tools -> dsh-agent, so a plain
|
|
18
|
+
// \`npm i @zoraxylia/dsh-codex-adapter\` died with ERESOLVE. rc.3 first marked every
|
|
19
|
+
// @deepseek-ai/* peer optional - and still failed: npm also auto-places
|
|
20
|
+
// optional peers (peerOptional) when they fit, and the exact rc.6 pins
|
|
21
|
+
// ERESOLVE against the rc.8 tree (dsh-llm rc.6 vs dsh-session rc.8).
|
|
22
|
+
// The fix that actually installs: NO @deepseek-ai/* in peerDependencies at
|
|
23
|
+
// all; the host stack is documented in the inert dshHostRuntime field.
|
|
24
|
+
// The \`dsh plugin add\` path never hit any of this because the DSH host
|
|
25
|
+
// provides those packages itself - which is why two releases shipped
|
|
26
|
+
// without anyone noticing. Installing the packed tarball is now part of
|
|
27
|
+
// the test, not a step someone has to remember.
|
|
28
|
+
//
|
|
29
|
+
// npm run smoke:pack
|
|
30
|
+
//
|
|
31
|
+
// Deliberately NOT wired into prepack (npm pack runs prepack, and this
|
|
32
|
+
// script calls npm pack itself - that would recurse). Run it explicitly as
|
|
33
|
+
// the last gate before publishing.
|
|
34
|
+
|
|
35
|
+
import { execFileSync, spawn } from 'node:child_process';
|
|
36
|
+
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync } from 'node:fs';
|
|
37
|
+
import { tmpdir } from 'node:os';
|
|
38
|
+
import { dirname, join } from 'node:path';
|
|
39
|
+
import { fileURLToPath } from 'node:url';
|
|
40
|
+
|
|
41
|
+
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
42
|
+
const PKG_NAME = '@zoraxylia/dsh-codex-adapter';
|
|
43
|
+
const EXPECTED_TOOLS = [
|
|
44
|
+
'dsh_run_worker',
|
|
45
|
+
'dsh_worker_config',
|
|
46
|
+
'dsh_worker_probe',
|
|
47
|
+
'dsh_spawn_worker',
|
|
48
|
+
'dsh_worker_status',
|
|
49
|
+
'dsh_worker_result',
|
|
50
|
+
'dsh_worker_cancel',
|
|
51
|
+
].sort();
|
|
52
|
+
|
|
53
|
+
const HOST_RUNTIME_PACKAGES = [
|
|
54
|
+
'@deepseek-ai/dsh-agent',
|
|
55
|
+
'@deepseek-ai/dsh-agent-presets',
|
|
56
|
+
'@deepseek-ai/dsh-agent-spine-demo',
|
|
57
|
+
'@deepseek-ai/dsh-bash-local',
|
|
58
|
+
'@deepseek-ai/dsh-compaction-basic',
|
|
59
|
+
'@deepseek-ai/dsh-fs-local',
|
|
60
|
+
'@deepseek-ai/dsh-fs-observation-policy',
|
|
61
|
+
'@deepseek-ai/dsh-llm',
|
|
62
|
+
'@deepseek-ai/dsh-llm-deepseek',
|
|
63
|
+
'@deepseek-ai/dsh-sandbox-local',
|
|
64
|
+
'@deepseek-ai/dsh-sandbox-policy',
|
|
65
|
+
'@deepseek-ai/dsh-sdk-client',
|
|
66
|
+
'@deepseek-ai/dsh-sdk-jsonrpc-demo',
|
|
67
|
+
'@deepseek-ai/dsh-sdk-jsonrpc-server',
|
|
68
|
+
'@deepseek-ai/dsh-session',
|
|
69
|
+
'@deepseek-ai/dsh-session-persistence-jsonl',
|
|
70
|
+
'@deepseek-ai/dsh-subprocess-local',
|
|
71
|
+
'@deepseek-ai/dsh-token-meter',
|
|
72
|
+
'@deepseek-ai/dsh-tool-fs',
|
|
73
|
+
'@deepseek-ai/dsh-tool-todo',
|
|
74
|
+
].sort();
|
|
75
|
+
|
|
76
|
+
const tempDirs = [];
|
|
77
|
+
let child = null;
|
|
78
|
+
|
|
79
|
+
function cleanup() {
|
|
80
|
+
for (const d of tempDirs) {
|
|
81
|
+
try { rmSync(d, { recursive: true, force: true }); } catch {}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function fail(msg) {
|
|
86
|
+
if (child) { try { child.kill(); } catch {} }
|
|
87
|
+
cleanup();
|
|
88
|
+
console.error('\nSMOKE FAILED: ' + msg);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function run(cmd, args, { cwd, timeoutMs = 300_000, env = {} } = {}) {
|
|
93
|
+
// Windows ships npm as a .cmd shim, which execFileSync cannot start without a
|
|
94
|
+
// shell. Run the bundled CLI through the current node binary instead, so the
|
|
95
|
+
// same code path works on Linux, macOS and Windows.
|
|
96
|
+
if (cmd === 'npm') {
|
|
97
|
+
const npmCli = join(dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js');
|
|
98
|
+
if (existsSync(npmCli)) {
|
|
99
|
+
args = [npmCli, ...args];
|
|
100
|
+
cmd = process.execPath;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
return execFileSync(cmd, args, {
|
|
105
|
+
cwd,
|
|
106
|
+
env: { ...process.env, ...env },
|
|
107
|
+
encoding: 'utf8',
|
|
108
|
+
timeout: timeoutMs,
|
|
109
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
110
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
111
|
+
});
|
|
112
|
+
} catch (err) {
|
|
113
|
+
const tail = (s) => (s || '').slice(-4000);
|
|
114
|
+
fail(cmd + ' ' + args.join(' ') + ' failed in ' + cwd +
|
|
115
|
+
'\n--- stdout tail ---\n' + tail(err.stdout) +
|
|
116
|
+
'\n--- stderr tail ---\n' + tail(err.stderr));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function handshake(serverRel, label) {
|
|
121
|
+
const serverPath = join(installDir, 'node_modules', PKG_NAME, serverRel);
|
|
122
|
+
console.log('\n=== ' + label + ' ===');
|
|
123
|
+
console.log('$ node ' + serverPath);
|
|
124
|
+
child = spawn(process.execPath, [serverPath], { cwd: installDir, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
125
|
+
let stderr = '';
|
|
126
|
+
let finished = false;
|
|
127
|
+
child.stderr.on('data', (d) => { stderr += d.toString(); });
|
|
128
|
+
child.on('exit', (code) => {
|
|
129
|
+
if (!finished) fail(label + ' exited early (code ' + code + ')\nstderr: ' + stderr.trim());
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const pending = new Map();
|
|
133
|
+
const responses = [];
|
|
134
|
+
let buf = '';
|
|
135
|
+
let nextId = 1;
|
|
136
|
+
|
|
137
|
+
function send(msg) { child.stdin.write(JSON.stringify(msg) + '\n'); }
|
|
138
|
+
function request(method, params) {
|
|
139
|
+
return new Promise((resolve, reject) => {
|
|
140
|
+
const id = nextId++;
|
|
141
|
+
const timer = setTimeout(() => reject(new Error('timed out waiting for ' + method + ' (stderr: ' + stderr.trim() + ')')), 15000);
|
|
142
|
+
pending.set(id, { resolve, reject, timer });
|
|
143
|
+
send({ jsonrpc: '2.0', id, method, params });
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function routeLine(line) {
|
|
148
|
+
const raw = line.trim();
|
|
149
|
+
if (!raw) return;
|
|
150
|
+
let msg;
|
|
151
|
+
try { msg = JSON.parse(raw); }
|
|
152
|
+
catch { fail(label + ': non-JSON line on stdout (protocol broken): ' + raw.slice(0, 200)); }
|
|
153
|
+
if (msg.id !== undefined && pending.has(msg.id)) {
|
|
154
|
+
const p = pending.get(msg.id);
|
|
155
|
+
pending.delete(msg.id);
|
|
156
|
+
clearTimeout(p.timer);
|
|
157
|
+
if (msg.error) p.reject(new Error(msg.error.code + ': ' + msg.error.message));
|
|
158
|
+
else p.resolve(msg);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
child.stdout.on('data', (d) => {
|
|
163
|
+
buf += d.toString();
|
|
164
|
+
let i;
|
|
165
|
+
while ((i = buf.indexOf('\n')) >= 0) {
|
|
166
|
+
const line = buf.slice(0, i);
|
|
167
|
+
buf = buf.slice(i + 1);
|
|
168
|
+
if (line.trim()) { responses.push(line.trim()); routeLine(line); }
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const initParams = { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'smoke-pack', version: '0.0.0' } };
|
|
173
|
+
console.log('--- initialize request ---');
|
|
174
|
+
console.log(JSON.stringify({ jsonrpc: '2.0', method: 'initialize', params: initParams }));
|
|
175
|
+
|
|
176
|
+
const init = await request('initialize', initParams);
|
|
177
|
+
console.log('--- initialize response (raw) ---');
|
|
178
|
+
console.log(responses[responses.length - 1]);
|
|
179
|
+
const info = init.result && init.result.serverInfo;
|
|
180
|
+
if (!info || info.name !== 'dsh-crew') fail(label + ': serverInfo.name is ' + JSON.stringify(info && info.name) + ', expected dsh-crew');
|
|
181
|
+
|
|
182
|
+
send({ jsonrpc: '2.0', method: 'notifications/initialized' });
|
|
183
|
+
|
|
184
|
+
const list = await request('tools/list', {});
|
|
185
|
+
console.log('--- tools/list response (raw) ---');
|
|
186
|
+
console.log(responses[responses.length - 1]);
|
|
187
|
+
const names = (list.result && list.result.tools || []).map((t) => t.name).sort();
|
|
188
|
+
if (JSON.stringify(names) !== JSON.stringify(EXPECTED_TOOLS)) {
|
|
189
|
+
fail(label + ': tools/list returned ' + JSON.stringify(names) + ', expected ' + JSON.stringify(EXPECTED_TOOLS));
|
|
190
|
+
}
|
|
191
|
+
console.log('[' + label + '] OK: ' + names.length + ' tools, serverInfo=' + JSON.stringify(info));
|
|
192
|
+
|
|
193
|
+
finished = true;
|
|
194
|
+
child.kill();
|
|
195
|
+
child = null;
|
|
196
|
+
return info;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// ---------------------------------------------------------------------------
|
|
200
|
+
// 1. Pack the current tree. prepack runs smoke:mcp (rebuild + bundle
|
|
201
|
+
// assertions), so a stale or broken lib/server.mjs cannot get packed.
|
|
202
|
+
console.log('[smoke:pack] 1/5 npm pack (prepack runs smoke:mcp first) ...');
|
|
203
|
+
const packDir = mkdtempSync(join(tmpdir(), 'dsh-crew-pack-'));
|
|
204
|
+
tempDirs.push(packDir);
|
|
205
|
+
// Hermetic npm cache: a shared ~/.npm cache can be stale, or (as seen on
|
|
206
|
+
// the author's machine) hold root-owned leftovers from older npm versions,
|
|
207
|
+
// which would fail this test with EPERM instead of testing the tarball.
|
|
208
|
+
const cacheDir = mkdtempSync(join(tmpdir(), 'dsh-crew-npm-cache-'));
|
|
209
|
+
tempDirs.push(cacheDir);
|
|
210
|
+
const packOut = run('npm', ['pack', '--cache', cacheDir, '--pack-destination', packDir], { cwd: ROOT, env: { npm_config_cache: cacheDir } });
|
|
211
|
+
console.log(packOut.split('\n').slice(-6).join('\n'));
|
|
212
|
+
const tarballs = readdirSync(packDir).filter((f) => f.endsWith('.tgz'));
|
|
213
|
+
if (tarballs.length !== 1) fail('expected exactly one tarball in ' + packDir + ', found ' + JSON.stringify(tarballs));
|
|
214
|
+
const tarballPath = join(packDir, tarballs[0]);
|
|
215
|
+
console.log('[smoke:pack] tarball: ' + tarballPath + ' (' + statSync(tarballPath).size + ' bytes)');
|
|
216
|
+
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
// 2. Install into a brand-new empty directory - the external-user scenario
|
|
219
|
+
// from issue #3 that never worked before.
|
|
220
|
+
console.log('\n[smoke:pack] 2/5 npm init -y && npm i ' + tarballPath);
|
|
221
|
+
const installDir = mkdtempSync(join(tmpdir(), 'dsh-crew-install-'));
|
|
222
|
+
tempDirs.push(installDir);
|
|
223
|
+
console.log(run('npm', ['init', '-y', '--cache', cacheDir], { cwd: installDir, env: { npm_config_cache: cacheDir } }).split('\n').slice(0, 3).join('\n'));
|
|
224
|
+
const installOut = run('npm', ['i', tarballPath, '--cache', cacheDir], { cwd: installDir, timeoutMs: 600_000, env: { npm_config_cache: cacheDir } });
|
|
225
|
+
console.log(installOut.split('\n').slice(-12).join('\n'));
|
|
226
|
+
if (/ERESOLVE/.test(installOut)) fail('npm i printed ERESOLVE - optional peers are still being auto-installed');
|
|
227
|
+
|
|
228
|
+
// ---------------------------------------------------------------------------
|
|
229
|
+
// 3. No @deepseek-ai/* may land in node_modules. The DSH host owns them.
|
|
230
|
+
console.log('\n[smoke:pack] 3/5 asserting no @deepseek-ai/* in node_modules');
|
|
231
|
+
const nmDir = join(installDir, 'node_modules');
|
|
232
|
+
if (!existsSync(nmDir)) fail('node_modules missing after install');
|
|
233
|
+
if (existsSync(join(nmDir, '@deepseek-ai'))) {
|
|
234
|
+
fail('node_modules/@deepseek-ai exists: ' + readdirSync(join(nmDir, '@deepseek-ai')).join(', '));
|
|
235
|
+
}
|
|
236
|
+
console.log('[smoke:pack] node_modules/@deepseek-ai absent. top level: ' + readdirSync(nmDir).sort().join(', '));
|
|
237
|
+
|
|
238
|
+
// Regression guard on the declaration itself. npm 7+ auto-installs peers -
|
|
239
|
+
// optional ones included when they can be placed - so the only shape that
|
|
240
|
+
// keeps a plain npm install clean AND @deepseek-ai/*-free is to have no
|
|
241
|
+
// @deepseek-ai/* in peerDependencies at all (the 0.1.0-rc.3 fix for issue
|
|
242
|
+
// #3). The host-runtime stack is documented in the inert dshHostRuntime
|
|
243
|
+
// field instead, and that list is asserted here too.
|
|
244
|
+
const installedPkg = JSON.parse(readFileSync(join(installDir, 'node_modules', PKG_NAME, 'package.json'), 'utf8'));
|
|
245
|
+
for (const name of Object.keys(installedPkg.peerDependencies || {})) {
|
|
246
|
+
if (name.startsWith('@deepseek-ai/')) {
|
|
247
|
+
fail('peer ' + name + ' is still in peerDependencies - @deepseek-ai/* must be host runtime only (see dshHostRuntime)');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const hostRuntime = installedPkg.dshHostRuntime || {};
|
|
251
|
+
for (const name of HOST_RUNTIME_PACKAGES) {
|
|
252
|
+
if (!hostRuntime[name]) fail('dshHostRuntime is missing ' + name + ' - keep the host-runtime list in sync with worker.cordis.yml / the DSH host profile');
|
|
253
|
+
}
|
|
254
|
+
console.log('[smoke:pack] package.json guard OK: 0 @deepseek-ai/* peers; all ' +
|
|
255
|
+
HOST_RUNTIME_PACKAGES.length + ' host-runtime packages documented in dshHostRuntime; version=' + installedPkg.version);
|
|
256
|
+
|
|
257
|
+
// ---------------------------------------------------------------------------
|
|
258
|
+
// 4+5. Both server entry points must serve the full roster. src/ needs the
|
|
259
|
+
// installed zod + MCP SDK; lib/ is the self-contained bundle. Either one
|
|
260
|
+
// failing means an installed copy dies at startup - the issue #1 scenario.
|
|
261
|
+
const srcInfo = await handshake('src/server.mjs', '[smoke:pack] 4/5 src/server.mjs (installed copy)');
|
|
262
|
+
const libInfo = await handshake('lib/server.mjs', '[smoke:pack] 5/5 lib/server.mjs (installed copy)');
|
|
263
|
+
if (srcInfo.version !== libInfo.version) {
|
|
264
|
+
fail('version mismatch: src/server.mjs reports ' + srcInfo.version + ' but lib/server.mjs reports ' + libInfo.version + ' - run npm run build:mcp');
|
|
265
|
+
}
|
|
266
|
+
if (srcInfo.version !== installedPkg.version) {
|
|
267
|
+
fail('version mismatch: servers report ' + srcInfo.version + ' but package.json says ' + installedPkg.version);
|
|
268
|
+
}
|
|
269
|
+
// The plugin manifest is the version the host displays, and nothing else
|
|
270
|
+
// checks it: 0.1.0-rc.5 shipped with package.json at rc.5 and this file still
|
|
271
|
+
// at rc.4 because a release bumped one place and not the other.
|
|
272
|
+
const manifestPath = join(installDir, 'node_modules', PKG_NAME, '.claude-plugin', 'plugin.json');
|
|
273
|
+
let manifestVersion;
|
|
274
|
+
try {
|
|
275
|
+
manifestVersion = JSON.parse(readFileSync(manifestPath, 'utf8')).version;
|
|
276
|
+
} catch (err) {
|
|
277
|
+
fail('cannot read .claude-plugin/plugin.json from the installed copy: ' + err.message);
|
|
278
|
+
}
|
|
279
|
+
if (manifestVersion !== installedPkg.version) {
|
|
280
|
+
fail('version mismatch: .claude-plugin/plugin.json says ' + manifestVersion + ' but package.json says ' + installedPkg.version);
|
|
281
|
+
}
|
|
282
|
+
console.log('[smoke:pack] version guard OK: package.json, plugin.json, src/server.mjs and lib/server.mjs all report ' + installedPkg.version);
|
|
283
|
+
|
|
284
|
+
cleanup();
|
|
285
|
+
console.log('\nSMOKE PASSED: the packed tarball installs with plain npm (no ERESOLVE), pulls zero @deepseek-ai/* packages, and both src/server.mjs and lib/server.mjs serve initialize + tools/list with all ' + EXPECTED_TOOLS.length + ' tools.');
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Smoke test: dispatch one cheap flash job to verify the installation.
|
|
2
|
+
// Probes the hub first (if DSH web instance is running); falls back to
|
|
3
|
+
// standalone mode. Always exercises the path the user actually installed.
|
|
4
|
+
|
|
5
|
+
import { hubAvailable, hub } from '../src/hub-client.mjs';
|
|
6
|
+
import { readGlobalConfig } from '../src/install/install.mjs';
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
const hubUrl = process.env.DSHPLUGIN_CREW_HUB ?? process.env.DSH_CREW_HUB ?? readGlobalConfig().hub_url;
|
|
10
|
+
const isHubUp = await hubAvailable();
|
|
11
|
+
|
|
12
|
+
if (isHubUp) {
|
|
13
|
+
// Dispatch through the hub
|
|
14
|
+
console.log(`hub at ${hubUrl} is reachable, using hub mode`);
|
|
15
|
+
const job = await hub.spawn({
|
|
16
|
+
task: 'Reply with exactly the word: ok',
|
|
17
|
+
tier: 'flash',
|
|
18
|
+
effort: 'off',
|
|
19
|
+
cwd: process.cwd(),
|
|
20
|
+
source: 'smoke',
|
|
21
|
+
});
|
|
22
|
+
console.log(`spawned ${job.id} ...`);
|
|
23
|
+
const result = await hub.get(job.id, 120);
|
|
24
|
+
if (result.status === 'done') {
|
|
25
|
+
console.log(`worker replied: ${result.result}`);
|
|
26
|
+
console.log('smoke test passed — configuration OK');
|
|
27
|
+
} else if (result.status === 'running') {
|
|
28
|
+
// The wait returns early once the job settles, so this is a real timeout.
|
|
29
|
+
console.error(`smoke test failed: job ${job.id} still running after 120s`);
|
|
30
|
+
console.error('Hint: it is still live in the DSH instance — check its session for what is stuck');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
} else {
|
|
33
|
+
console.error(`smoke test failed: status=${result.status} error=${result.error}`);
|
|
34
|
+
console.error('Hint: check the DSH instance logs and verify DeepSeek provider credentials');
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
// Fall back to standalone mode
|
|
39
|
+
console.log(`no hub at ${hubUrl}, falling back to standalone mode`);
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const { startJob, waitJob, jobView } = await import('../src/jobs.mjs');
|
|
43
|
+
const job = await startJob({
|
|
44
|
+
task: 'Reply with exactly the word: ok',
|
|
45
|
+
tier: 'flash',
|
|
46
|
+
effort: 'off',
|
|
47
|
+
cwd: process.cwd(),
|
|
48
|
+
});
|
|
49
|
+
console.log(`spawned ${job.id} (deepseek-v4-flash) ...`);
|
|
50
|
+
await waitJob(job.id, 120_000);
|
|
51
|
+
const v = jobView(job, { withResult: true });
|
|
52
|
+
if (v.status === 'done') {
|
|
53
|
+
console.log(`worker replied: ${v.result}`);
|
|
54
|
+
console.log('smoke test passed — configuration OK');
|
|
55
|
+
} else {
|
|
56
|
+
console.error(`smoke test failed: status=${v.status} error=${v.error}`);
|
|
57
|
+
console.error('Hint: DEEPSEEK_API_KEY missing or invalid in env or ~/.config/dsh-crew/.env, or runtime not installed');
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
} catch (err) {
|
|
61
|
+
// The standalone runtime lives in this package's own node_modules; the
|
|
62
|
+
// @deepseek-ai/* packages are host runtime (documented in dshHostRuntime),
|
|
63
|
+
// so an installed copy of the plugin has none of them and the dynamic
|
|
64
|
+
// import above is what tells
|
|
65
|
+
// us so. Anything else here is a dispatch failure, not a missing runtime.
|
|
66
|
+
if (err.code === 'ERR_MODULE_NOT_FOUND' || err.code === 'MODULE_NOT_FOUND') {
|
|
67
|
+
console.error('smoke test failed: the standalone runtime is not installed in this copy');
|
|
68
|
+
console.error('Hint: run "pnpm install" from a source checkout, or start a DSH instance to use hub mode');
|
|
69
|
+
} else {
|
|
70
|
+
console.error(`smoke test failed: ${err.message}`);
|
|
71
|
+
console.error('Hint: DEEPSEEK_API_KEY missing or invalid in env or ~/.config/dsh-crew/.env');
|
|
72
|
+
}
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} catch (err) {
|
|
77
|
+
console.error(`smoke test failed: ${err.message}`);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Real-CLI verification for the cli-workers adapter (WPC4). NOT part of the
|
|
2
|
+
// published payload or the prepack smoke suite: it spends real model tokens
|
|
3
|
+
// and requires agy / grok installed and authenticated on the machine.
|
|
4
|
+
//
|
|
5
|
+
// GROK_HOME=/tmp/wpc4-grok-home node scripts/verify-cli-workers.mjs
|
|
6
|
+
//
|
|
7
|
+
// (GROK_HOME is optional in production; it exists here so the run can write
|
|
8
|
+
// grok session files into a writable dir inside a restricted sandbox.)
|
|
9
|
+
//
|
|
10
|
+
// Tests:
|
|
11
|
+
// 1. agy real dispatch: "Reply with exactly the word: ok"
|
|
12
|
+
// 2. grok real dispatch: "Reply with exactly the word: ok"
|
|
13
|
+
// 3. timeout (agy): long generation task, 20 s timeout -> failed/timeout
|
|
14
|
+
// 4. cancel (grok): long generation task, cancel at 8 s -> cancelled
|
|
15
|
+
// Each test also verifies the process group is gone afterwards (no orphans).
|
|
16
|
+
|
|
17
|
+
import { mkdirSync } from 'node:fs';
|
|
18
|
+
import { resolve } from 'node:path';
|
|
19
|
+
import { startCliJob } from '../src/cli-workers.mjs';
|
|
20
|
+
import { cancelJob, getJob, jobView, waitJob } from '../src/jobs.mjs';
|
|
21
|
+
import { listProfiles } from '../src/worker-profiles.mjs';
|
|
22
|
+
|
|
23
|
+
const BASE = '/tmp/wpc4-verify';
|
|
24
|
+
mkdirSync(BASE, { recursive: true });
|
|
25
|
+
|
|
26
|
+
const LONG_TASK = 'Print the integers from 1 to 4000 inclusive, one per line, and nothing else.';
|
|
27
|
+
|
|
28
|
+
// WPC14: job.pgid is now the positive process-group id (detached spawn ⇒
|
|
29
|
+
// pgid === pid); kill(-pgid, 0) probes the whole group.
|
|
30
|
+
function groupAlive(pgid) {
|
|
31
|
+
try { process.kill(-pgid, 0); return true; } catch (e) { return e.code !== 'ESRCH'; }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
35
|
+
|
|
36
|
+
function report(job, label, extra = {}) {
|
|
37
|
+
const j = getJob(job.id);
|
|
38
|
+
const v = jobView(j, { withResult: true });
|
|
39
|
+
console.log(`\n===== ${label} =====`);
|
|
40
|
+
console.log(JSON.stringify(v, null, 2));
|
|
41
|
+
console.log('rawLines:', j._rawLines.length, 'stderrTail:', JSON.stringify(j._stderrTail.trim().slice(-300)));
|
|
42
|
+
console.log('groupAlive after settle:', groupAlive(job.pgid), '(pgid', job.pgid + ')');
|
|
43
|
+
console.log('child exit:', JSON.stringify({ code: job.harness?.child?.exitCode, signal: job.harness?.child?.signalCode }));
|
|
44
|
+
for (const [k, val] of Object.entries(extra)) console.log(k + ':', val);
|
|
45
|
+
return { view: v, job: j };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// waitJob returns early once the status flips (cancel/timeout set it before
|
|
49
|
+
// the process is fully dead), so wait for the actual settle marker instead.
|
|
50
|
+
async function waitSettled(id, maxMs = 15_000) {
|
|
51
|
+
const deadline = Date.now() + maxMs;
|
|
52
|
+
for (;;) {
|
|
53
|
+
const j = getJob(id);
|
|
54
|
+
if (!j) throw new Error(`job ${id} vanished`);
|
|
55
|
+
if (j.endedAt) return j;
|
|
56
|
+
if (Date.now() > deadline) throw new Error(`job ${id} did not settle within ${maxMs}ms (status=${j.status}, groupAlive=${groupAlive(j.pgid)})`);
|
|
57
|
+
await sleep(250);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function testRealDispatch(profileName, label) {
|
|
62
|
+
const cwd = resolve(BASE, profileName);
|
|
63
|
+
mkdirSync(cwd, { recursive: true });
|
|
64
|
+
const t0 = Date.now();
|
|
65
|
+
const job = await startCliJob({
|
|
66
|
+
worker: profileName,
|
|
67
|
+
task: 'Reply with exactly the word: ok',
|
|
68
|
+
cwd,
|
|
69
|
+
timeoutMs: 180_000,
|
|
70
|
+
source: 'verify-script',
|
|
71
|
+
});
|
|
72
|
+
const r = await waitJob(job.id, 185_000);
|
|
73
|
+
const wall = ((Date.now() - t0) / 1000).toFixed(1);
|
|
74
|
+
const rep = report(job, label, { wallSeconds: wall });
|
|
75
|
+
if (rep.view.status !== 'done') throw new Error(`${label}: expected done, got ${rep.view.status}`);
|
|
76
|
+
return rep;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function testTimeout() {
|
|
80
|
+
const cwd = resolve(BASE, 'agy-timeout');
|
|
81
|
+
mkdirSync(cwd, { recursive: true });
|
|
82
|
+
const t0 = Date.now();
|
|
83
|
+
const job = await startCliJob({ worker: 'agy', task: LONG_TASK, cwd, timeoutMs: 20_000, source: 'verify-script' });
|
|
84
|
+
const seen = [];
|
|
85
|
+
const sampleTimer = setInterval(() => {
|
|
86
|
+
const j = getJob(job.id);
|
|
87
|
+
if (j) seen.push({ at: ((Date.now() - t0) / 1000).toFixed(0) + 's', status: j.status, liveness: j.liveness, events: j.activity.events, lastEventAt: j.activity.lastEventAt });
|
|
88
|
+
}, 3000);
|
|
89
|
+
const r = await waitJob(job.id, 40_000);
|
|
90
|
+
clearInterval(sampleTimer);
|
|
91
|
+
const rep = report(job, 'timeout (agy, 20s deadline)', { wallSeconds: ((Date.now() - t0) / 1000).toFixed(1), livenessSamples: seen });
|
|
92
|
+
if (rep.view.status !== 'failed' || rep.view.stopReason !== 'timeout') {
|
|
93
|
+
throw new Error(`timeout test: expected failed/timeout, got ${rep.view.status}/${rep.view.stopReason} (result: ${String(rep.view.result).slice(0, 60)})`);
|
|
94
|
+
}
|
|
95
|
+
if (rep.job._settled !== true || groupAlive(job.pgid)) throw new Error('timeout test: process group still alive after settle');
|
|
96
|
+
return rep;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function testCancel() {
|
|
100
|
+
const cwd = resolve(BASE, 'grok-cancel');
|
|
101
|
+
mkdirSync(cwd, { recursive: true });
|
|
102
|
+
const t0 = Date.now();
|
|
103
|
+
const job = await startCliJob({ worker: 'grok', task: LONG_TASK, cwd, timeoutMs: 300_000, source: 'verify-script' });
|
|
104
|
+
const seen = [];
|
|
105
|
+
const sampleTimer = setInterval(() => {
|
|
106
|
+
const j = getJob(job.id);
|
|
107
|
+
if (j) seen.push({ at: ((Date.now() - t0) / 1000).toFixed(0) + 's', status: j.status, liveness: j.liveness, events: j.activity.events });
|
|
108
|
+
}, 2000);
|
|
109
|
+
await new Promise((res) => setTimeout(res, 8000));
|
|
110
|
+
const cancelled = await cancelJob(job.id);
|
|
111
|
+
clearInterval(sampleTimer);
|
|
112
|
+
const settled = await waitSettled(job.id, 15_000); // status flips before the kill lands
|
|
113
|
+
const rep = report(job, 'cancel (grok, cancel at ~8s)', { wallSeconds: ((Date.now() - t0) / 1000).toFixed(1), livenessSamples: seen, cancelReturned: cancelled.status, settleWallSeconds: ((Date.now() - t0) / 1000).toFixed(1) });
|
|
114
|
+
if (rep.view.status !== 'cancelled' || settled.stopReason !== 'cancelled') throw new Error(`cancel test: expected cancelled, got ${rep.view.status}/${settled.stopReason}`);
|
|
115
|
+
if (groupAlive(job.pgid)) throw new Error('cancel test: process group still alive after settle');
|
|
116
|
+
return rep;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
console.log('worker_profiles (registry):');
|
|
120
|
+
console.log(JSON.stringify(listProfiles(), null, 2));
|
|
121
|
+
|
|
122
|
+
const results = {};
|
|
123
|
+
results.agyOk = await testRealDispatch('agy', 'REAL DISPATCH agy (profile=agy)');
|
|
124
|
+
results.grokOk = await testRealDispatch('grok', 'REAL DISPATCH grok (profile=grok)');
|
|
125
|
+
results.timeout = await testTimeout();
|
|
126
|
+
results.cancel = await testCancel();
|
|
127
|
+
|
|
128
|
+
console.log('\n===== VERIFICATION SUMMARY =====');
|
|
129
|
+
for (const [k, r] of Object.entries(results)) {
|
|
130
|
+
const v = r.view;
|
|
131
|
+
console.log(`${k}: status=${v.status} stopReason=${v.stopReason} backend=${v.backend} profile=${v.profile} model=${v.model} result=${JSON.stringify(String(v.result ?? v.error ?? '').slice(0, 80))}`);
|
|
132
|
+
}
|
|
133
|
+
console.log('ALL_TESTS_PASSED');
|