@ran-sh/dsh-crew 0.3.1 → 0.3.2

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.
Files changed (78) hide show
  1. package/.claude-plugin/marketplace.json +17 -17
  2. package/.claude-plugin/plugin.json +8 -8
  3. package/.mcp.json +8 -8
  4. package/LICENSE +21 -21
  5. package/README.de.md +359 -359
  6. package/README.es.md +359 -359
  7. package/README.fr.md +359 -359
  8. package/README.hi.md +359 -359
  9. package/README.id.md +359 -359
  10. package/README.ja.md +359 -359
  11. package/README.ko.md +359 -359
  12. package/README.md +140 -140
  13. package/README.pt.md +359 -359
  14. package/README.ru.md +359 -359
  15. package/README.th.md +359 -359
  16. package/README.tr.md +359 -359
  17. package/README.vi.md +359 -359
  18. package/README.zh-TW.md +359 -359
  19. package/README.zh.md +140 -140
  20. package/agents/ds-flash.md +26 -26
  21. package/agents/ds-pro.md +32 -32
  22. package/agents/ds-reviewer.md +23 -23
  23. package/agents/ds-worker.md +22 -22
  24. package/codex/agents/ds-flash.toml +30 -30
  25. package/codex/agents/ds-pro.toml +31 -31
  26. package/codex/agents/ds-reviewer.toml +28 -28
  27. package/codex/agents/ds-worker.toml +28 -28
  28. package/codex/prompts/dsh-config.md +3 -3
  29. package/codex/prompts/dsh-status.md +1 -1
  30. package/commands/config.md +11 -11
  31. package/commands/off.md +5 -5
  32. package/commands/on.md +5 -5
  33. package/commands/status.md +5 -5
  34. package/cordis.patch.yml +4 -4
  35. package/lib/client.js +2765 -2765
  36. package/package.json +127 -127
  37. package/scripts/build-client.mjs +28 -28
  38. package/scripts/live-crew-smoke.mjs +39 -39
  39. package/scripts/live-policy-matrix.mjs +177 -177
  40. package/scripts/policy-probe.mjs +101 -101
  41. package/scripts/setup.mjs +295 -294
  42. package/scripts/smoke-real.mjs +110 -110
  43. package/scripts/smoke.mjs +78 -78
  44. package/scripts/verify-installer-fix.mjs +26 -26
  45. package/scripts/verify-npm-install.mjs +297 -276
  46. package/src/adaptive-routing.mjs +260 -260
  47. package/src/client/activation-summary.tsx +64 -64
  48. package/src/client/entry.tsx +236 -236
  49. package/src/client/index.tsx +1120 -1120
  50. package/src/config-readiness.mjs +59 -59
  51. package/src/delivery.mjs +205 -205
  52. package/src/dsh-cli-runtime.mjs +435 -251
  53. package/src/failure-classification.mjs +172 -172
  54. package/src/hub/entry.mjs +98 -98
  55. package/src/hub-client.mjs +132 -132
  56. package/src/hub-compatibility.mjs +49 -49
  57. package/src/i18n.mjs +19 -19
  58. package/src/install/cli.mjs +28 -28
  59. package/src/install/install-legacy.mjs +460 -460
  60. package/src/install/install.mjs +451 -451
  61. package/src/mcp-runtime.mjs +257 -257
  62. package/src/model-catalog.mjs +173 -173
  63. package/src/model-routing.mjs +391 -391
  64. package/src/policy.mjs +197 -197
  65. package/src/readiness-matrix.mjs +169 -169
  66. package/src/runtime-controls.mjs +90 -90
  67. package/src/runtime-identity.mjs +108 -108
  68. package/src/server.mjs +477 -477
  69. package/src/status-shard.mjs +52 -52
  70. package/src/structured-error-code.mjs +38 -38
  71. package/src/vision-route.mjs +138 -138
  72. package/src/workflow-runtime.mjs +573 -567
  73. package/src/workflow.mjs +160 -160
  74. package/src/workspace-audit.mjs +231 -231
  75. package/src/workspace-isolation.mjs +365 -306
  76. package/statusline/statusline.sh +14 -14
  77. package/statusline/worker-segment.sh +35 -35
  78. package/worker.cordis.yml +77 -77
package/package.json CHANGED
@@ -1,127 +1,127 @@
1
- {
2
- "name": "@ran-sh/dsh-crew",
3
- "version": "0.3.1",
4
- "type": "module",
5
- "main": "./src/hub/entry.mjs",
6
- "description": "DeepSeek Harness plugin: dispatch work to DSH agents from Claude Code / Codex, as native subagents with live progress",
7
- "dsh": {
8
- "bundle": {
9
- "patch": "./cordis.patch.yml"
10
- },
11
- "client": {
12
- "inject": [
13
- "@deepseek-ai/dsh-client-runtime",
14
- "@deepseek-ai/dsh-client-locale",
15
- "@deepseek-ai/dsh-client-ui-slots",
16
- "@deepseek-ai/dsh-client-ui-settings"
17
- ],
18
- "platform": "web"
19
- }
20
- },
21
- "scripts": {
22
- "mcp": "node src/server.mjs",
23
- "build:client": "tsdown src/client/entry.tsx --format cjs --platform browser --target es2022 --tsconfig tsconfig.client.json --deps.never-bundle react --deps.never-bundle react/jsx-runtime --deps.never-bundle react-dom --deps.never-bundle react-dom/client --out-dir .client-build --clean --logLevel warn && node scripts/build-client.mjs",
24
- "verify:npm-install": "node scripts/verify-npm-install.mjs",
25
- "verify:npm-install:official": "node scripts/verify-npm-install.mjs --with-official-dsh"
26
- },
27
- "dependencies": {
28
- "@modelcontextprotocol/sdk": "^1.17.5",
29
- "zod": "^3.24.0"
30
- },
31
- "exports": {
32
- ".": "./src/hub/entry.mjs",
33
- "./client": "./lib/client.js",
34
- "./package.json": "./package.json"
35
- },
36
- "peerDependencies": {
37
- "react": "^18.0.0",
38
- "react-dom": "^18.0.0",
39
- "@deepseek-ai/dsh-agent": "0.1.1-rc.2",
40
- "@deepseek-ai/dsh-agent-presets": "0.1.1-rc.2",
41
- "@deepseek-ai/dsh-agent-spine-demo": "0.1.1-rc.2",
42
- "@deepseek-ai/dsh-bash-local": "0.1.1-rc.2",
43
- "@deepseek-ai/dsh-compaction-basic": "0.1.1-rc.2",
44
- "@deepseek-ai/dsh-fs-local": "0.1.1-rc.2",
45
- "@deepseek-ai/dsh-fs-observation-policy": "0.1.1-rc.2",
46
- "@deepseek-ai/dsh-llm": "0.1.1-rc.2",
47
- "@deepseek-ai/dsh-llm-deepseek": "0.1.1-rc.2",
48
- "@deepseek-ai/dsh-sandbox-local": "0.1.1-rc.2",
49
- "@deepseek-ai/dsh-sandbox-policy": "0.1.1-rc.2",
50
- "@deepseek-ai/dsh-sdk-client": "0.1.1-rc.2",
51
- "@deepseek-ai/dsh-sdk-jsonrpc-demo": "0.1.1-rc.2",
52
- "@deepseek-ai/dsh-sdk-jsonrpc-server": "0.1.1-rc.2",
53
- "@deepseek-ai/dsh-session": "0.1.1-rc.2",
54
- "@deepseek-ai/dsh-session-persistence-jsonl": "0.1.1-rc.2",
55
- "@deepseek-ai/dsh-subprocess-local": "0.1.1-rc.2",
56
- "@deepseek-ai/dsh-token-meter": "0.1.1-rc.2",
57
- "@deepseek-ai/dsh-tool-fs": "0.1.1-rc.2",
58
- "@deepseek-ai/dsh-tool-todo": "0.1.1-rc.2"
59
- },
60
- "devDependencies": {
61
- "react": "^18.3.1",
62
- "react-dom": "^18.3.1",
63
- "tsdown": "^0.12.0",
64
- "typescript": "^5.6.0",
65
- "@types/react": "^18.3.0",
66
- "@deepseek-ai/dsh-agent": "0.1.1-rc.2",
67
- "@deepseek-ai/dsh-agent-presets": "0.1.1-rc.2",
68
- "@deepseek-ai/dsh-agent-spine-demo": "0.1.1-rc.2",
69
- "@deepseek-ai/dsh-bash-local": "0.1.1-rc.2",
70
- "@deepseek-ai/dsh-compaction-basic": "0.1.1-rc.2",
71
- "@deepseek-ai/dsh-fs-local": "0.1.1-rc.2",
72
- "@deepseek-ai/dsh-fs-observation-policy": "0.1.1-rc.2",
73
- "@deepseek-ai/dsh-llm": "0.1.1-rc.2",
74
- "@deepseek-ai/dsh-llm-deepseek": "0.1.1-rc.2",
75
- "@deepseek-ai/dsh-sandbox-local": "0.1.1-rc.2",
76
- "@deepseek-ai/dsh-sandbox-policy": "0.1.1-rc.2",
77
- "@deepseek-ai/dsh-sdk-client": "0.1.1-rc.2",
78
- "@deepseek-ai/dsh-sdk-jsonrpc-demo": "0.1.1-rc.2",
79
- "@deepseek-ai/dsh-sdk-jsonrpc-server": "0.1.1-rc.2",
80
- "@deepseek-ai/dsh-session": "0.1.1-rc.2",
81
- "@deepseek-ai/dsh-session-persistence-jsonl": "0.1.1-rc.2",
82
- "@deepseek-ai/dsh-subprocess-local": "0.1.1-rc.2",
83
- "@deepseek-ai/dsh-token-meter": "0.1.1-rc.2",
84
- "@deepseek-ai/dsh-tool-fs": "0.1.1-rc.2",
85
- "@deepseek-ai/dsh-tool-todo": "0.1.1-rc.2"
86
- },
87
- "license": "MIT",
88
- "repository": {
89
- "type": "git",
90
- "url": "git+https://github.com/Ran-sh/dsh-crew.git"
91
- },
92
- "homepage": "https://github.com/Ran-sh/dsh-crew",
93
- "bugs": {
94
- "url": "https://github.com/Ran-sh/dsh-crew/issues"
95
- },
96
- "keywords": [
97
- "dsh",
98
- "deepseek",
99
- "claude-code",
100
- "codex",
101
- "subagent",
102
- "worker",
103
- "multimodal",
104
- "plugin",
105
- "agent"
106
- ],
107
- "files": [
108
- "lib",
109
- "src",
110
- "scripts",
111
- "agents",
112
- "commands",
113
- "codex",
114
- "statusline",
115
- "cordis.patch.yml",
116
- "worker.cordis.yml",
117
- ".claude-plugin",
118
- ".mcp.json",
119
- "README.md",
120
- "README.*.md",
121
- "docs/images/dsh-crew-logo.png",
122
- "docs/images/dsh-crew-overview.png",
123
- "docs/images/dsh-crew-host.png",
124
- "docs/images/dsh-crew-jobs.png",
125
- "LICENSE"
126
- ]
127
- }
1
+ {
2
+ "name": "@ran-sh/dsh-crew",
3
+ "version": "0.3.2",
4
+ "type": "module",
5
+ "main": "./src/hub/entry.mjs",
6
+ "description": "DeepSeek Harness plugin: dispatch work to DSH agents from Claude Code / Codex, as native subagents with live progress",
7
+ "dsh": {
8
+ "bundle": {
9
+ "patch": "./cordis.patch.yml"
10
+ },
11
+ "client": {
12
+ "inject": [
13
+ "@deepseek-ai/dsh-client-runtime",
14
+ "@deepseek-ai/dsh-client-locale",
15
+ "@deepseek-ai/dsh-client-ui-slots",
16
+ "@deepseek-ai/dsh-client-ui-settings"
17
+ ],
18
+ "platform": "web"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "mcp": "node src/server.mjs",
23
+ "build:client": "tsdown src/client/entry.tsx --format cjs --platform browser --target es2022 --tsconfig tsconfig.client.json --deps.never-bundle react --deps.never-bundle react/jsx-runtime --deps.never-bundle react-dom --deps.never-bundle react-dom/client --out-dir .client-build --clean --logLevel warn && node scripts/build-client.mjs",
24
+ "verify:npm-install": "node scripts/verify-npm-install.mjs",
25
+ "verify:npm-install:official": "node scripts/verify-npm-install.mjs --with-official-dsh"
26
+ },
27
+ "dependencies": {
28
+ "@modelcontextprotocol/sdk": "^1.17.5",
29
+ "zod": "^3.24.0"
30
+ },
31
+ "exports": {
32
+ ".": "./src/hub/entry.mjs",
33
+ "./client": "./lib/client.js",
34
+ "./package.json": "./package.json"
35
+ },
36
+ "peerDependencies": {
37
+ "react": "^18.0.0",
38
+ "react-dom": "^18.0.0",
39
+ "@deepseek-ai/dsh-agent": "0.1.1-rc.2",
40
+ "@deepseek-ai/dsh-agent-presets": "0.1.1-rc.2",
41
+ "@deepseek-ai/dsh-agent-spine-demo": "0.1.1-rc.2",
42
+ "@deepseek-ai/dsh-bash-local": "0.1.1-rc.2",
43
+ "@deepseek-ai/dsh-compaction-basic": "0.1.1-rc.2",
44
+ "@deepseek-ai/dsh-fs-local": "0.1.1-rc.2",
45
+ "@deepseek-ai/dsh-fs-observation-policy": "0.1.1-rc.2",
46
+ "@deepseek-ai/dsh-llm": "0.1.1-rc.2",
47
+ "@deepseek-ai/dsh-llm-deepseek": "0.1.1-rc.2",
48
+ "@deepseek-ai/dsh-sandbox-local": "0.1.1-rc.2",
49
+ "@deepseek-ai/dsh-sandbox-policy": "0.1.1-rc.2",
50
+ "@deepseek-ai/dsh-sdk-client": "0.1.1-rc.2",
51
+ "@deepseek-ai/dsh-sdk-jsonrpc-demo": "0.1.1-rc.2",
52
+ "@deepseek-ai/dsh-sdk-jsonrpc-server": "0.1.1-rc.2",
53
+ "@deepseek-ai/dsh-session": "0.1.1-rc.2",
54
+ "@deepseek-ai/dsh-session-persistence-jsonl": "0.1.1-rc.2",
55
+ "@deepseek-ai/dsh-subprocess-local": "0.1.1-rc.2",
56
+ "@deepseek-ai/dsh-token-meter": "0.1.1-rc.2",
57
+ "@deepseek-ai/dsh-tool-fs": "0.1.1-rc.2",
58
+ "@deepseek-ai/dsh-tool-todo": "0.1.1-rc.2"
59
+ },
60
+ "devDependencies": {
61
+ "react": "^18.3.1",
62
+ "react-dom": "^18.3.1",
63
+ "tsdown": "^0.12.0",
64
+ "typescript": "^5.6.0",
65
+ "@types/react": "^18.3.0",
66
+ "@deepseek-ai/dsh-agent": "0.1.1-rc.2",
67
+ "@deepseek-ai/dsh-agent-presets": "0.1.1-rc.2",
68
+ "@deepseek-ai/dsh-agent-spine-demo": "0.1.1-rc.2",
69
+ "@deepseek-ai/dsh-bash-local": "0.1.1-rc.2",
70
+ "@deepseek-ai/dsh-compaction-basic": "0.1.1-rc.2",
71
+ "@deepseek-ai/dsh-fs-local": "0.1.1-rc.2",
72
+ "@deepseek-ai/dsh-fs-observation-policy": "0.1.1-rc.2",
73
+ "@deepseek-ai/dsh-llm": "0.1.1-rc.2",
74
+ "@deepseek-ai/dsh-llm-deepseek": "0.1.1-rc.2",
75
+ "@deepseek-ai/dsh-sandbox-local": "0.1.1-rc.2",
76
+ "@deepseek-ai/dsh-sandbox-policy": "0.1.1-rc.2",
77
+ "@deepseek-ai/dsh-sdk-client": "0.1.1-rc.2",
78
+ "@deepseek-ai/dsh-sdk-jsonrpc-demo": "0.1.1-rc.2",
79
+ "@deepseek-ai/dsh-sdk-jsonrpc-server": "0.1.1-rc.2",
80
+ "@deepseek-ai/dsh-session": "0.1.1-rc.2",
81
+ "@deepseek-ai/dsh-session-persistence-jsonl": "0.1.1-rc.2",
82
+ "@deepseek-ai/dsh-subprocess-local": "0.1.1-rc.2",
83
+ "@deepseek-ai/dsh-token-meter": "0.1.1-rc.2",
84
+ "@deepseek-ai/dsh-tool-fs": "0.1.1-rc.2",
85
+ "@deepseek-ai/dsh-tool-todo": "0.1.1-rc.2"
86
+ },
87
+ "license": "MIT",
88
+ "repository": {
89
+ "type": "git",
90
+ "url": "git+https://github.com/Ran-sh/dsh-crew.git"
91
+ },
92
+ "homepage": "https://github.com/Ran-sh/dsh-crew",
93
+ "bugs": {
94
+ "url": "https://github.com/Ran-sh/dsh-crew/issues"
95
+ },
96
+ "keywords": [
97
+ "dsh",
98
+ "deepseek",
99
+ "claude-code",
100
+ "codex",
101
+ "subagent",
102
+ "worker",
103
+ "multimodal",
104
+ "plugin",
105
+ "agent"
106
+ ],
107
+ "files": [
108
+ "lib",
109
+ "src",
110
+ "scripts",
111
+ "agents",
112
+ "commands",
113
+ "codex",
114
+ "statusline",
115
+ "cordis.patch.yml",
116
+ "worker.cordis.yml",
117
+ ".claude-plugin",
118
+ ".mcp.json",
119
+ "README.md",
120
+ "README.*.md",
121
+ "docs/images/dsh-crew-logo.png",
122
+ "docs/images/dsh-crew-overview.png",
123
+ "docs/images/dsh-crew-host.png",
124
+ "docs/images/dsh-crew-jobs.png",
125
+ "LICENSE"
126
+ ]
127
+ }
@@ -1,28 +1,28 @@
1
- // Wrap the compiled client bundle into the dsh-web module-loader artifact:
2
- // `window.__ModuleLoader__.load({ id, factory })`. The id must equal the
3
- // package name (= the cordis entry name). Pattern from dsh-noema.
4
-
5
- import { readFile, writeFile, rm, mkdir, readdir } from 'node:fs/promises';
6
- import { dirname, join } from 'node:path';
7
- import { fileURLToPath } from 'node:url';
8
-
9
- const root = dirname(dirname(fileURLToPath(import.meta.url)));
10
- const manifest = JSON.parse(await readFile(join(root, 'package.json'), 'utf8'));
11
- const pluginId = manifest.name;
12
- const buildDir = join(root, '.client-build');
13
- const compiledEntries = (await readdir(buildDir)).filter((name) => name.endsWith('.cjs'));
14
- if (compiledEntries.length !== 1) {
15
- throw new Error(`expected exactly one compiled client entry in .client-build, found ${compiledEntries.length}: ${compiledEntries.join(', ')}`);
16
- }
17
- const source = await readFile(join(buildDir, compiledEntries[0]), 'utf8');
18
- const wrapped = [
19
- `window.__ModuleLoader__.load({ id: ${JSON.stringify(pluginId)}, factory: (require) => {`,
20
- 'var module = { exports: {} }; var exports = module.exports;',
21
- source.replace(/\n?\/\/# sourceMappingURL=.*$/u, ''),
22
- 'return module.exports; } });',
23
- '',
24
- ].join('\n');
25
- await mkdir(join(root, 'lib'), { recursive: true });
26
- await writeFile(join(root, 'lib', 'client.js'), wrapped);
27
- await rm(buildDir, { recursive: true, force: true });
28
- console.log(`built lib/client.js (${wrapped.length} bytes) as module "${pluginId}" from ${compiledEntries[0]}`);
1
+ // Wrap the compiled client bundle into the dsh-web module-loader artifact:
2
+ // `window.__ModuleLoader__.load({ id, factory })`. The id must equal the
3
+ // package name (= the cordis entry name). Pattern from dsh-noema.
4
+
5
+ import { readFile, writeFile, rm, mkdir, readdir } from 'node:fs/promises';
6
+ import { dirname, join } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ const root = dirname(dirname(fileURLToPath(import.meta.url)));
10
+ const manifest = JSON.parse(await readFile(join(root, 'package.json'), 'utf8'));
11
+ const pluginId = manifest.name;
12
+ const buildDir = join(root, '.client-build');
13
+ const compiledEntries = (await readdir(buildDir)).filter((name) => name.endsWith('.cjs'));
14
+ if (compiledEntries.length !== 1) {
15
+ throw new Error(`expected exactly one compiled client entry in .client-build, found ${compiledEntries.length}: ${compiledEntries.join(', ')}`);
16
+ }
17
+ const source = await readFile(join(buildDir, compiledEntries[0]), 'utf8');
18
+ const wrapped = [
19
+ `window.__ModuleLoader__.load({ id: ${JSON.stringify(pluginId)}, factory: (require) => {`,
20
+ 'var module = { exports: {} }; var exports = module.exports;',
21
+ source.replace(/\n?\/\/# sourceMappingURL=.*$/u, ''),
22
+ 'return module.exports; } });',
23
+ '',
24
+ ].join('\n');
25
+ await mkdir(join(root, 'lib'), { recursive: true });
26
+ await writeFile(join(root, 'lib', 'client.js'), wrapped);
27
+ await rm(buildDir, { recursive: true, force: true });
28
+ console.log(`built lib/client.js (${wrapped.length} bytes) as module "${pluginId}" from ${compiledEntries[0]}`);
@@ -1,39 +1,39 @@
1
- // Live Crew worker smoke against a Crew-owned dsh-crew Hub (Stage 4 provider
2
- // routing). Targets the dedicated Crew Hub (DSH_CREW_HUB env or default
3
- // http://127.0.0.1:3210); it never targets or mutates the official web profile.
4
- // Creates a temp fixture as cwd, spawns flash, polls, prints job metadata.
5
- import os from 'node:os';
6
- import fs from 'node:fs';
7
- import path from 'node:path';
8
- const BASE = (process.env.DSH_CREW_HUB ?? 'http://127.0.0.1:3210').replace(/\/$/, '') + '/_dsh/dsh-crew';
9
-
10
- (async () => {
11
- const fixture = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh4-fixture-'));
12
- fs.writeFileSync(path.join(fixture, 'note.txt'), 'hello');
13
- const cwd = fixture.replace(/\\/g, '/');
14
- console.log('fixture:', cwd);
15
- console.log('provider route:', JSON.stringify(await (await fetch(`${BASE}/provider`)).json()));
16
-
17
- const tier = process.argv[2] ?? 'flash';
18
- const res = await fetch(`${BASE}/jobs`, {
19
- method: 'POST', headers: { 'content-type': 'application/json' },
20
- body: JSON.stringify({ task: 'Reply with exactly: CREW_OPENCODE_GO_OK', tier, effort: 'off', cwd }),
21
- });
22
- const spawned = await res.json();
23
- console.log('spawn:', JSON.stringify(spawned).slice(0, 260));
24
- if (!spawned.ok && !spawned.job) { process.exit(1); }
25
- const id = (spawned.job ?? spawned).id;
26
-
27
- // Poll for up to 120s.
28
- for (let i = 0; i < 40; i++) {
29
- await new Promise((r) => setTimeout(r, 3000));
30
- const r = await (await fetch(`${BASE}/jobs/${id}?wait=0`)).json();
31
- const j = r.job ?? r;
32
- if (!['running', 'pending'].includes(j.status)) {
33
- console.log('final:', JSON.stringify({ id: j.id, tier: j.tier, model: j.model, status: j.status, result: (j.result || '').slice(0, 120), error: (j.error || '').slice(0, 200), tokens: j.tokens }, null, 2));
34
- process.exit(j.status === 'done' ? 0 : 2);
35
- }
36
- }
37
- console.log('TIMEOUT waiting for job', id);
38
- process.exit(3);
39
- })();
1
+ // Live Crew worker smoke against a Crew-owned dsh-crew Hub (Stage 4 provider
2
+ // routing). Targets the dedicated Crew Hub (DSH_CREW_HUB env or default
3
+ // http://127.0.0.1:3210); it never targets or mutates the official web profile.
4
+ // Creates a temp fixture as cwd, spawns flash, polls, prints job metadata.
5
+ import os from 'node:os';
6
+ import fs from 'node:fs';
7
+ import path from 'node:path';
8
+ const BASE = (process.env.DSH_CREW_HUB ?? 'http://127.0.0.1:3210').replace(/\/$/, '') + '/_dsh/dsh-crew';
9
+
10
+ (async () => {
11
+ const fixture = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh4-fixture-'));
12
+ fs.writeFileSync(path.join(fixture, 'note.txt'), 'hello');
13
+ const cwd = fixture.replace(/\\/g, '/');
14
+ console.log('fixture:', cwd);
15
+ console.log('provider route:', JSON.stringify(await (await fetch(`${BASE}/provider`)).json()));
16
+
17
+ const tier = process.argv[2] ?? 'flash';
18
+ const res = await fetch(`${BASE}/jobs`, {
19
+ method: 'POST', headers: { 'content-type': 'application/json' },
20
+ body: JSON.stringify({ task: 'Reply with exactly: CREW_OPENCODE_GO_OK', tier, effort: 'off', cwd }),
21
+ });
22
+ const spawned = await res.json();
23
+ console.log('spawn:', JSON.stringify(spawned).slice(0, 260));
24
+ if (!spawned.ok && !spawned.job) { process.exit(1); }
25
+ const id = (spawned.job ?? spawned).id;
26
+
27
+ // Poll for up to 120s.
28
+ for (let i = 0; i < 40; i++) {
29
+ await new Promise((r) => setTimeout(r, 3000));
30
+ const r = await (await fetch(`${BASE}/jobs/${id}?wait=0`)).json();
31
+ const j = r.job ?? r;
32
+ if (!['running', 'pending'].includes(j.status)) {
33
+ console.log('final:', JSON.stringify({ id: j.id, tier: j.tier, model: j.model, status: j.status, result: (j.result || '').slice(0, 120), error: (j.error || '').slice(0, 200), tokens: j.tokens }, null, 2));
34
+ process.exit(j.status === 'done' ? 0 : 2);
35
+ }
36
+ }
37
+ console.log('TIMEOUT waiting for job', id);
38
+ process.exit(3);
39
+ })();