@ran-sh/dsh-crew 1.8.0 → 1.9.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.
Files changed (151) hide show
  1. package/.claude-plugin/marketplace.json +16 -16
  2. package/.claude-plugin/plugin.json +14 -14
  3. package/LICENSE +21 -21
  4. package/README.de.md +359 -359
  5. package/README.es.md +359 -359
  6. package/README.fr.md +359 -359
  7. package/README.hi.md +359 -359
  8. package/README.id.md +359 -359
  9. package/README.ja.md +359 -359
  10. package/README.ko.md +359 -359
  11. package/README.md +126 -126
  12. package/README.pt.md +359 -359
  13. package/README.ru.md +359 -359
  14. package/README.th.md +359 -359
  15. package/README.tr.md +359 -359
  16. package/README.vi.md +359 -359
  17. package/README.zh-TW.md +359 -359
  18. package/README.zh.md +116 -116
  19. package/agents/ds-flash.md +24 -24
  20. package/agents/ds-pro.md +24 -24
  21. package/agents/ds-reviewer.md +23 -23
  22. package/agents/ds-worker.md +23 -23
  23. package/bin/dsh-crew.mjs +16 -16
  24. package/codex/agents/ds-flash.toml +34 -34
  25. package/codex/agents/ds-pro.toml +34 -34
  26. package/codex/agents/ds-reviewer.toml +32 -32
  27. package/codex/agents/ds-worker.toml +32 -32
  28. package/codex/prompts/dsh-config.md +19 -19
  29. package/codex/prompts/dsh-status.md +5 -5
  30. package/commands/config.md +23 -23
  31. package/commands/off.md +5 -5
  32. package/commands/on.md +5 -5
  33. package/commands/status.md +9 -9
  34. package/cordis.patch.yml +4 -4
  35. package/docs/gpt-relay-extension.md +103 -103
  36. package/docs/installation.md +138 -138
  37. package/docs/job-contracts.md +103 -103
  38. package/docs/readiness-matrix.md +85 -85
  39. package/docs/ui-surfaces.md +107 -107
  40. package/official-web-bridge/cordis.patch.yml +4 -4
  41. package/official-web-bridge/entry.mjs +1 -1
  42. package/official-web-bridge/overlay-entry.mjs +59 -59
  43. package/official-web-bridge/package.json +25 -25
  44. package/package.json +1 -1
  45. package/scripts/build-client.mjs +49 -49
  46. package/scripts/live-crew-smoke.mjs +39 -39
  47. package/scripts/live-policy-matrix.mjs +177 -177
  48. package/scripts/policy-probe.mjs +101 -101
  49. package/scripts/remove-legacy-official-bridge.ps1 +89 -89
  50. package/scripts/setup.mjs +393 -393
  51. package/scripts/smoke-real.mjs +110 -110
  52. package/scripts/smoke.mjs +78 -78
  53. package/scripts/verify-crew-ui-polish.mjs +145 -145
  54. package/scripts/verify-history-ui.mjs +97 -97
  55. package/scripts/verify-installer-fix.mjs +26 -26
  56. package/scripts/verify-npm-install.mjs +311 -311
  57. package/scripts/verify-official-bridge-e2e.mjs +192 -192
  58. package/src/adaptive-routing.mjs +260 -260
  59. package/src/client/activation-summary.tsx +64 -64
  60. package/src/client/collapsible-sections.mjs +55 -55
  61. package/src/client/history-panel.tsx +108 -108
  62. package/src/client/host-readiness.mjs +71 -71
  63. package/src/client/index.tsx +1711 -1711
  64. package/src/client/model-callability-view.mjs +17 -17
  65. package/src/client/panel-chrome.tsx +40 -40
  66. package/src/client/quick-entry.tsx +10 -10
  67. package/src/client/quick-panel.tsx +275 -275
  68. package/src/client/readiness-envelope.mjs +34 -34
  69. package/src/client/surface-detection.mjs +43 -43
  70. package/src/config-readiness.mjs +226 -226
  71. package/src/credential-reference.mjs +38 -38
  72. package/src/delivery.mjs +205 -205
  73. package/src/dsh-cli-runtime.mjs +1021 -1021
  74. package/src/dsh-cohort.mjs +20 -20
  75. package/src/extension-contract.mjs +104 -104
  76. package/src/failure-classification.mjs +201 -201
  77. package/src/history/admission-gate.mjs +67 -67
  78. package/src/history/archive-store.mjs +272 -272
  79. package/src/history/cleanup-plan.mjs +89 -89
  80. package/src/history/http.mjs +32 -32
  81. package/src/history/operation.mjs +86 -86
  82. package/src/history/runner-detach.mjs +34 -34
  83. package/src/history/runner.mjs +52 -52
  84. package/src/history/runtime.mjs +36 -36
  85. package/src/history/service.mjs +177 -177
  86. package/src/history/state.mjs +27 -27
  87. package/src/hub/entry.mjs +104 -104
  88. package/src/hub/index.mjs +2694 -2694
  89. package/src/hub-client.mjs +154 -154
  90. package/src/hub-compatibility.mjs +42 -42
  91. package/src/i18n.mjs +19 -19
  92. package/src/information-flow.mjs +67 -67
  93. package/src/install/cli.mjs +28 -28
  94. package/src/install/install-legacy.mjs +711 -711
  95. package/src/install/install.mjs +483 -483
  96. package/src/install/npx-lifecycle.mjs +3456 -3456
  97. package/src/install/official-frontend-assets.mjs +78 -78
  98. package/src/install/official-web.mjs +95 -95
  99. package/src/install/payload-content.mjs +88 -88
  100. package/src/install/windows-startup.mjs +236 -236
  101. package/src/install/windows-supervisor-adapter.mjs +443 -443
  102. package/src/install/windows-supervisor-lifecycle.mjs +782 -782
  103. package/src/install/zcode.mjs +397 -397
  104. package/src/job-contracts.mjs +255 -255
  105. package/src/local-request-guard.mjs +60 -60
  106. package/src/mcp-runtime.mjs +340 -332
  107. package/src/model-callability-contract.mjs +79 -79
  108. package/src/model-catalog.mjs +180 -180
  109. package/src/model-routing.mjs +586 -586
  110. package/src/model-schedule.mjs +207 -207
  111. package/src/official-web-bridge.mjs +447 -447
  112. package/src/policy.mjs +235 -235
  113. package/src/provider-delete-adapters.mjs +1934 -1934
  114. package/src/provider-health.mjs +130 -130
  115. package/src/provider-inventory.mjs +182 -182
  116. package/src/provider-layer-migration-adapters.mjs +759 -759
  117. package/src/provider-layer-migration.mjs +198 -198
  118. package/src/provider-lifecycle-state.mjs +103 -103
  119. package/src/provider-lifecycle.mjs +252 -252
  120. package/src/provider-profile-store.mjs +390 -390
  121. package/src/provider-settings-store.mjs +633 -633
  122. package/src/provider-store-lock.mjs +67 -67
  123. package/src/readiness-matrix.mjs +181 -181
  124. package/src/removable-waiter.mjs +29 -29
  125. package/src/role-profiles.mjs +107 -107
  126. package/src/runtime-controls.mjs +84 -84
  127. package/src/runtime-identity-contract.mjs +34 -34
  128. package/src/runtime-identity.mjs +235 -235
  129. package/src/runtime-readiness-snapshot.mjs +285 -285
  130. package/src/server.mjs +581 -581
  131. package/src/session-origins.mjs +60 -60
  132. package/src/standalone-sdk.mjs +23 -23
  133. package/src/status-shard.mjs +63 -63
  134. package/src/structured-error-code.mjs +38 -38
  135. package/src/supervisor/restart-request.mjs +256 -256
  136. package/src/workflow-runtime.mjs +739 -739
  137. package/src/workflow.mjs +155 -155
  138. package/src/workspace-audit.mjs +231 -231
  139. package/src/workspace-context.mjs +146 -146
  140. package/src/workspace-isolation.mjs +455 -401
  141. package/src/workspace-readiness.mjs +32 -32
  142. package/statusline/statusline.sh +14 -14
  143. package/statusline/worker-segment.sh +35 -35
  144. package/windows/start-dsh-crew.cmd +57 -57
  145. package/windows/start-dsh-crew.ps1 +1302 -1302
  146. package/windows/supervisor-control.ps1 +467 -467
  147. package/worker.cordis.yml +67 -67
  148. package/zcode/agents/ds-reviewer.md +31 -31
  149. package/zcode/agents/ds-worker.md +31 -31
  150. package/zcode/commands/dsh-config.md +17 -17
  151. package/zcode/commands/dsh-status.md +5 -5
@@ -1,192 +1,192 @@
1
- // Real, disposable official-UI acceptance for the 3080 -> isolated 3210 bridge.
2
- // It never edits the user's official profile or Crew installation.
3
-
4
- import { spawn, spawnSync } from 'node:child_process';
5
- import {
6
- existsSync,
7
- mkdirSync,
8
- mkdtempSync,
9
- readFileSync,
10
- realpathSync,
11
- rmSync,
12
- symlinkSync,
13
- writeFileSync,
14
- } from 'node:fs';
15
- import { homedir, tmpdir } from 'node:os';
16
- import { createServer } from 'node:net';
17
- import { dirname, join, resolve } from 'node:path';
18
- import { fileURLToPath } from 'node:url';
19
- import { npxInstall, npxIntegrate } from '../src/install/npx-lifecycle.mjs';
20
- import { TARGET_DSH_VERSION } from '../src/dsh-cohort.mjs';
21
-
22
- // RETIRED as a release gate: the legacy 3080 -> 3210 bridge is retired and
23
- // npxIntegrate()/npxDetach() always return OFFICIAL_WEB_PROFILE_READ_ONLY, so
24
- // the bridge journey this script asserts can no longer pass on current code.
25
- // Kept only as an operator diagnostic: run with --diagnostic-only to skip the
26
- // retired integrate assertion and report the read-only policy explicitly.
27
- const diagnosticOnly = process.argv.includes('--diagnostic-only');
28
- if (diagnosticOnly) {
29
- console.log('[diagnostic] legacy official-bridge e2e retired; official web profile is read-only; nothing to verify.');
30
- process.exit(0);
31
- }
32
-
33
- const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
34
- const candidateVersion = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')).version;
35
- if (typeof candidateVersion !== 'string' || candidateVersion === '') throw new Error('candidate package version is unavailable');
36
- const realHome = homedir();
37
- const runtimeRoot = join(realHome, '.config', 'dsh-crew', 'harness', 'runtime');
38
- const runtimeModule = join(runtimeRoot, 'node_modules', '@deepseek-ai', 'dsh', 'lib', 'bin.js');
39
- if (!existsSync(runtimeModule)) throw new Error('real Crew DSH runtime is not installed');
40
-
41
- const sandbox = mkdtempSync(join(tmpdir(), 'dsh-crew-official-e2e-'));
42
- const officialHome = join(sandbox, '.dsh');
43
- const crewRoot = join(sandbox, '.config', 'dsh-crew');
44
- const harnessHome = join(crewRoot, 'harness');
45
- const profileRoot = join(officialHome, 'profiles', 'web');
46
- const logs = [];
47
- let official;
48
-
49
- async function reservePort() {
50
- const server = createServer();
51
- await new Promise((resolveListen, reject) => {
52
- server.once('error', reject);
53
- server.listen(0, '127.0.0.1', resolveListen);
54
- });
55
- const port = server.address().port;
56
- await new Promise((resolveClose) => server.close(resolveClose));
57
- return port;
58
- }
59
-
60
- const officialPort = await reservePort();
61
- const crewPort = await reservePort();
62
- const officialUrl = `http://127.0.0.1:${officialPort}`;
63
- const crewUrl = `http://127.0.0.1:${crewPort}`;
64
-
65
- function assert(condition, message) {
66
- if (!condition) throw new Error(message);
67
- }
68
-
69
- async function waitFor(url, { timeout = 30_000 } = {}) {
70
- const deadline = Date.now() + timeout;
71
- let last;
72
- while (Date.now() < deadline) {
73
- try {
74
- const response = await fetch(url, { signal: AbortSignal.timeout(2_000) });
75
- if (response.ok) return response;
76
- last = `HTTP ${response.status}`;
77
- } catch (error) { last = error?.message ?? String(error); }
78
- await new Promise((resolveWait) => setTimeout(resolveWait, 250));
79
- }
80
- throw new Error(`timed out waiting for ${url}: ${last}`);
81
- }
82
-
83
- async function waitForPageMarker(url, marker, { timeout = 30_000 } = {}) {
84
- const deadline = Date.now() + timeout;
85
- while (Date.now() < deadline) {
86
- try {
87
- const response = await fetch(url, { signal: AbortSignal.timeout(2_000) });
88
- const body = await response.text();
89
- if (response.ok && body.includes(marker)) return body;
90
- } catch {}
91
- await new Promise((resolveWait) => setTimeout(resolveWait, 250));
92
- }
93
- throw new Error(`timed out waiting for ${marker} in ${url}`);
94
- }
95
-
96
- function stopOwnedProcesses() {
97
- if (process.platform !== 'win32') return;
98
- const escaped = sandbox.replace(/'/g, "''");
99
- const command = [
100
- `$sandbox = '${escaped}'`,
101
- "$processes = Get-CimInstance Win32_Process -Filter \"Name='node.exe'\"",
102
- 'foreach ($process in $processes) {',
103
- ' if ($process.CommandLine -and $process.CommandLine.Contains($sandbox)) { Stop-Process -Id $process.ProcessId -Force }',
104
- '}',
105
- ].join('; ');
106
- spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', command], { windowsHide: true });
107
- }
108
-
109
- try {
110
- mkdirSync(profileRoot, { recursive: true });
111
- writeFileSync(join(profileRoot, 'package.json'), JSON.stringify({
112
- name: 'dsh-profile-web',
113
- private: true,
114
- dependencies: {},
115
- dsh: { profile: { bundles: ['@deepseek-ai/dsh-base', '@deepseek-ai/dsh-web-app'] } },
116
- }, null, 2));
117
- writeFileSync(join(profileRoot, 'cordis.patch.yml'), '[]\n');
118
- writeFileSync(join(profileRoot, 'pnpm-workspace.yaml'), 'packages:\n - .\n\nnodeLinker: hoisted\nautoInstallPeers: false\n');
119
-
120
- const currentConfig = join(realHome, '.config', 'dsh-crew', 'config.json');
121
- let sandboxConfig = {};
122
- if (existsSync(currentConfig)) {
123
- mkdirSync(crewRoot, { recursive: true });
124
- sandboxConfig = JSON.parse(readFileSync(currentConfig, 'utf8'));
125
- }
126
- mkdirSync(crewRoot, { recursive: true });
127
- writeFileSync(join(crewRoot, 'config.json'), JSON.stringify({ ...sandboxConfig, hub_url: crewUrl }, null, 2));
128
-
129
- const installer = {
130
- installCodex: () => ({ ok: true, actions: [] }),
131
- installClaudeCode: async () => ({ ok: true, actions: [] }),
132
- installStatus: () => ({ codex: { installed: true }, claude: { installed: true } }),
133
- };
134
- const installed = await npxInstall({
135
- home: sandbox,
136
- sourceRoot: root,
137
- installer,
138
- log: (line) => logs.push(line),
139
- ensureRuntime: async () => {
140
- const target = join(harnessHome, 'runtime');
141
- mkdirSync(dirname(target), { recursive: true });
142
- symlinkSync(realpathSync(runtimeRoot), target, process.platform === 'win32' ? 'junction' : 'dir');
143
- return { ok: true, version: TARGET_DSH_VERSION };
144
- },
145
- });
146
- assert(installed.ok, `disposable install failed: ${logs.join(' | ')}`);
147
- const integrated = await npxIntegrate({ home: sandbox, log: (line) => logs.push(line) });
148
- assert(integrated.ok, `disposable integrate failed: ${logs.join(' | ')}`);
149
-
150
- official = spawn(process.execPath, [
151
- runtimeModule, '--profile', 'web', '--host', '127.0.0.1', '--port', String(officialPort), '--no-open',
152
- ], {
153
- env: { ...process.env, HOME: sandbox, USERPROFILE: sandbox, DSH_HOME: officialHome, DSH_CREW_BRIDGE_TARGET: crewUrl },
154
- stdio: ['ignore', 'pipe', 'pipe'],
155
- windowsHide: true,
156
- });
157
- const capture = (chunk) => { if (logs.join('\n').length < 20_000) logs.push(String(chunk)); };
158
- official.stdout.on('data', capture);
159
- official.stderr.on('data', capture);
160
-
161
- await waitForPageMarker(`${officialUrl}/`, '@ran-sh/dsh-crew-web-bridge');
162
- const bridgeStatus = await (await waitFor(`${officialUrl}/_dsh/dsh-crew/bridge-status`)).json();
163
- assert(bridgeStatus.mode === 'official-3080-isolated-3210', 'bridge status mode mismatch');
164
- const proxiedRuntime = await (await waitFor(`${officialUrl}/_dsh/dsh-crew/runtime`, { timeout: 45_000 })).json();
165
- assert(proxiedRuntime.runtime_version === candidateVersion, `proxied runtime version mismatch (${proxiedRuntime.runtime_version} != ${candidateVersion})`);
166
- const directRuntime = await (await waitFor(`${crewUrl}/_dsh/dsh-crew/runtime`)).json();
167
- assert(directRuntime.runtime_version === candidateVersion, `direct runtime version mismatch (${directRuntime.runtime_version} != ${candidateVersion})`);
168
- const models = await (await waitFor(`${officialUrl}/_dsh/dsh-crew/models`)).json();
169
- assert(Array.isArray(models.providers), 'proxied model catalog missing providers');
170
-
171
- console.log(JSON.stringify({
172
- ok: true,
173
- official_ui: officialUrl,
174
- isolated_backend: crewUrl,
175
- runtime_version: proxiedRuntime.runtime_version,
176
- provider_count: models.providers.length,
177
- official_profile: profileRoot,
178
- crew_home: harnessHome,
179
- }));
180
- } catch (error) {
181
- console.error(`OFFICIAL_BRIDGE_E2E_FAIL=${error?.message ?? error}`);
182
- console.error(logs.join('\n').slice(-8_000));
183
- process.exitCode = 1;
184
- } finally {
185
- if (official && official.exitCode === null) official.kill();
186
- stopOwnedProcesses();
187
- await new Promise((resolveWait) => setTimeout(resolveWait, 1_500));
188
- const resolvedSandbox = resolve(sandbox);
189
- assert(resolvedSandbox.startsWith(resolve(tmpdir())), 'refusing to remove non-temp sandbox');
190
- if (process.env.DSH_CREW_E2E_KEEP === '1') console.error(`OFFICIAL_BRIDGE_E2E_SANDBOX=${resolvedSandbox}`);
191
- else rmSync(resolvedSandbox, { recursive: true, force: true, maxRetries: 10, retryDelay: 250 });
192
- }
1
+ // Real, disposable official-UI acceptance for the 3080 -> isolated 3210 bridge.
2
+ // It never edits the user's official profile or Crew installation.
3
+
4
+ import { spawn, spawnSync } from 'node:child_process';
5
+ import {
6
+ existsSync,
7
+ mkdirSync,
8
+ mkdtempSync,
9
+ readFileSync,
10
+ realpathSync,
11
+ rmSync,
12
+ symlinkSync,
13
+ writeFileSync,
14
+ } from 'node:fs';
15
+ import { homedir, tmpdir } from 'node:os';
16
+ import { createServer } from 'node:net';
17
+ import { dirname, join, resolve } from 'node:path';
18
+ import { fileURLToPath } from 'node:url';
19
+ import { npxInstall, npxIntegrate } from '../src/install/npx-lifecycle.mjs';
20
+ import { TARGET_DSH_VERSION } from '../src/dsh-cohort.mjs';
21
+
22
+ // RETIRED as a release gate: the legacy 3080 -> 3210 bridge is retired and
23
+ // npxIntegrate()/npxDetach() always return OFFICIAL_WEB_PROFILE_READ_ONLY, so
24
+ // the bridge journey this script asserts can no longer pass on current code.
25
+ // Kept only as an operator diagnostic: run with --diagnostic-only to skip the
26
+ // retired integrate assertion and report the read-only policy explicitly.
27
+ const diagnosticOnly = process.argv.includes('--diagnostic-only');
28
+ if (diagnosticOnly) {
29
+ console.log('[diagnostic] legacy official-bridge e2e retired; official web profile is read-only; nothing to verify.');
30
+ process.exit(0);
31
+ }
32
+
33
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
34
+ const candidateVersion = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')).version;
35
+ if (typeof candidateVersion !== 'string' || candidateVersion === '') throw new Error('candidate package version is unavailable');
36
+ const realHome = homedir();
37
+ const runtimeRoot = join(realHome, '.config', 'dsh-crew', 'harness', 'runtime');
38
+ const runtimeModule = join(runtimeRoot, 'node_modules', '@deepseek-ai', 'dsh', 'lib', 'bin.js');
39
+ if (!existsSync(runtimeModule)) throw new Error('real Crew DSH runtime is not installed');
40
+
41
+ const sandbox = mkdtempSync(join(tmpdir(), 'dsh-crew-official-e2e-'));
42
+ const officialHome = join(sandbox, '.dsh');
43
+ const crewRoot = join(sandbox, '.config', 'dsh-crew');
44
+ const harnessHome = join(crewRoot, 'harness');
45
+ const profileRoot = join(officialHome, 'profiles', 'web');
46
+ const logs = [];
47
+ let official;
48
+
49
+ async function reservePort() {
50
+ const server = createServer();
51
+ await new Promise((resolveListen, reject) => {
52
+ server.once('error', reject);
53
+ server.listen(0, '127.0.0.1', resolveListen);
54
+ });
55
+ const port = server.address().port;
56
+ await new Promise((resolveClose) => server.close(resolveClose));
57
+ return port;
58
+ }
59
+
60
+ const officialPort = await reservePort();
61
+ const crewPort = await reservePort();
62
+ const officialUrl = `http://127.0.0.1:${officialPort}`;
63
+ const crewUrl = `http://127.0.0.1:${crewPort}`;
64
+
65
+ function assert(condition, message) {
66
+ if (!condition) throw new Error(message);
67
+ }
68
+
69
+ async function waitFor(url, { timeout = 30_000 } = {}) {
70
+ const deadline = Date.now() + timeout;
71
+ let last;
72
+ while (Date.now() < deadline) {
73
+ try {
74
+ const response = await fetch(url, { signal: AbortSignal.timeout(2_000) });
75
+ if (response.ok) return response;
76
+ last = `HTTP ${response.status}`;
77
+ } catch (error) { last = error?.message ?? String(error); }
78
+ await new Promise((resolveWait) => setTimeout(resolveWait, 250));
79
+ }
80
+ throw new Error(`timed out waiting for ${url}: ${last}`);
81
+ }
82
+
83
+ async function waitForPageMarker(url, marker, { timeout = 30_000 } = {}) {
84
+ const deadline = Date.now() + timeout;
85
+ while (Date.now() < deadline) {
86
+ try {
87
+ const response = await fetch(url, { signal: AbortSignal.timeout(2_000) });
88
+ const body = await response.text();
89
+ if (response.ok && body.includes(marker)) return body;
90
+ } catch {}
91
+ await new Promise((resolveWait) => setTimeout(resolveWait, 250));
92
+ }
93
+ throw new Error(`timed out waiting for ${marker} in ${url}`);
94
+ }
95
+
96
+ function stopOwnedProcesses() {
97
+ if (process.platform !== 'win32') return;
98
+ const escaped = sandbox.replace(/'/g, "''");
99
+ const command = [
100
+ `$sandbox = '${escaped}'`,
101
+ "$processes = Get-CimInstance Win32_Process -Filter \"Name='node.exe'\"",
102
+ 'foreach ($process in $processes) {',
103
+ ' if ($process.CommandLine -and $process.CommandLine.Contains($sandbox)) { Stop-Process -Id $process.ProcessId -Force }',
104
+ '}',
105
+ ].join('; ');
106
+ spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', command], { windowsHide: true });
107
+ }
108
+
109
+ try {
110
+ mkdirSync(profileRoot, { recursive: true });
111
+ writeFileSync(join(profileRoot, 'package.json'), JSON.stringify({
112
+ name: 'dsh-profile-web',
113
+ private: true,
114
+ dependencies: {},
115
+ dsh: { profile: { bundles: ['@deepseek-ai/dsh-base', '@deepseek-ai/dsh-web-app'] } },
116
+ }, null, 2));
117
+ writeFileSync(join(profileRoot, 'cordis.patch.yml'), '[]\n');
118
+ writeFileSync(join(profileRoot, 'pnpm-workspace.yaml'), 'packages:\n - .\n\nnodeLinker: hoisted\nautoInstallPeers: false\n');
119
+
120
+ const currentConfig = join(realHome, '.config', 'dsh-crew', 'config.json');
121
+ let sandboxConfig = {};
122
+ if (existsSync(currentConfig)) {
123
+ mkdirSync(crewRoot, { recursive: true });
124
+ sandboxConfig = JSON.parse(readFileSync(currentConfig, 'utf8'));
125
+ }
126
+ mkdirSync(crewRoot, { recursive: true });
127
+ writeFileSync(join(crewRoot, 'config.json'), JSON.stringify({ ...sandboxConfig, hub_url: crewUrl }, null, 2));
128
+
129
+ const installer = {
130
+ installCodex: () => ({ ok: true, actions: [] }),
131
+ installClaudeCode: async () => ({ ok: true, actions: [] }),
132
+ installStatus: () => ({ codex: { installed: true }, claude: { installed: true } }),
133
+ };
134
+ const installed = await npxInstall({
135
+ home: sandbox,
136
+ sourceRoot: root,
137
+ installer,
138
+ log: (line) => logs.push(line),
139
+ ensureRuntime: async () => {
140
+ const target = join(harnessHome, 'runtime');
141
+ mkdirSync(dirname(target), { recursive: true });
142
+ symlinkSync(realpathSync(runtimeRoot), target, process.platform === 'win32' ? 'junction' : 'dir');
143
+ return { ok: true, version: TARGET_DSH_VERSION };
144
+ },
145
+ });
146
+ assert(installed.ok, `disposable install failed: ${logs.join(' | ')}`);
147
+ const integrated = await npxIntegrate({ home: sandbox, log: (line) => logs.push(line) });
148
+ assert(integrated.ok, `disposable integrate failed: ${logs.join(' | ')}`);
149
+
150
+ official = spawn(process.execPath, [
151
+ runtimeModule, '--profile', 'web', '--host', '127.0.0.1', '--port', String(officialPort), '--no-open',
152
+ ], {
153
+ env: { ...process.env, HOME: sandbox, USERPROFILE: sandbox, DSH_HOME: officialHome, DSH_CREW_BRIDGE_TARGET: crewUrl },
154
+ stdio: ['ignore', 'pipe', 'pipe'],
155
+ windowsHide: true,
156
+ });
157
+ const capture = (chunk) => { if (logs.join('\n').length < 20_000) logs.push(String(chunk)); };
158
+ official.stdout.on('data', capture);
159
+ official.stderr.on('data', capture);
160
+
161
+ await waitForPageMarker(`${officialUrl}/`, '@ran-sh/dsh-crew-web-bridge');
162
+ const bridgeStatus = await (await waitFor(`${officialUrl}/_dsh/dsh-crew/bridge-status`)).json();
163
+ assert(bridgeStatus.mode === 'official-3080-isolated-3210', 'bridge status mode mismatch');
164
+ const proxiedRuntime = await (await waitFor(`${officialUrl}/_dsh/dsh-crew/runtime`, { timeout: 45_000 })).json();
165
+ assert(proxiedRuntime.runtime_version === candidateVersion, `proxied runtime version mismatch (${proxiedRuntime.runtime_version} != ${candidateVersion})`);
166
+ const directRuntime = await (await waitFor(`${crewUrl}/_dsh/dsh-crew/runtime`)).json();
167
+ assert(directRuntime.runtime_version === candidateVersion, `direct runtime version mismatch (${directRuntime.runtime_version} != ${candidateVersion})`);
168
+ const models = await (await waitFor(`${officialUrl}/_dsh/dsh-crew/models`)).json();
169
+ assert(Array.isArray(models.providers), 'proxied model catalog missing providers');
170
+
171
+ console.log(JSON.stringify({
172
+ ok: true,
173
+ official_ui: officialUrl,
174
+ isolated_backend: crewUrl,
175
+ runtime_version: proxiedRuntime.runtime_version,
176
+ provider_count: models.providers.length,
177
+ official_profile: profileRoot,
178
+ crew_home: harnessHome,
179
+ }));
180
+ } catch (error) {
181
+ console.error(`OFFICIAL_BRIDGE_E2E_FAIL=${error?.message ?? error}`);
182
+ console.error(logs.join('\n').slice(-8_000));
183
+ process.exitCode = 1;
184
+ } finally {
185
+ if (official && official.exitCode === null) official.kill();
186
+ stopOwnedProcesses();
187
+ await new Promise((resolveWait) => setTimeout(resolveWait, 1_500));
188
+ const resolvedSandbox = resolve(sandbox);
189
+ assert(resolvedSandbox.startsWith(resolve(tmpdir())), 'refusing to remove non-temp sandbox');
190
+ if (process.env.DSH_CREW_E2E_KEEP === '1') console.error(`OFFICIAL_BRIDGE_E2E_SANDBOX=${resolvedSandbox}`);
191
+ else rmSync(resolvedSandbox, { recursive: true, force: true, maxRetries: 10, retryDelay: 250 });
192
+ }