@ran-sh/dsh-crew 0.3.8 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ran-sh/dsh-crew",
3
- "version": "0.3.8",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "main": "./src/hub/entry.mjs",
6
6
  "bin": {
@@ -124,6 +124,9 @@
124
124
  ".mcp.json",
125
125
  "README.md",
126
126
  "README.*.md",
127
+ "docs/job-contracts.md",
128
+ "docs/readiness-matrix.md",
129
+ "docs/gpt-relay-extension.md",
127
130
  "docs/images/dsh-crew-logo.png",
128
131
  "docs/images/dsh-crew-overview.png",
129
132
  "docs/images/dsh-crew-host.png",
@@ -3,7 +3,6 @@
3
3
 
4
4
  import { spawn, spawnSync } from 'node:child_process';
5
5
  import {
6
- copyFileSync,
7
6
  existsSync,
8
7
  mkdirSync,
9
8
  mkdtempSync,
@@ -14,11 +13,14 @@ import {
14
13
  writeFileSync,
15
14
  } from 'node:fs';
16
15
  import { homedir, tmpdir } from 'node:os';
16
+ import { createServer } from 'node:net';
17
17
  import { dirname, join, resolve } from 'node:path';
18
18
  import { fileURLToPath } from 'node:url';
19
19
  import { npxInstall, npxIntegrate } from '../src/install/npx-lifecycle.mjs';
20
20
 
21
21
  const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
22
+ const candidateVersion = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')).version;
23
+ if (typeof candidateVersion !== 'string' || candidateVersion === '') throw new Error('candidate package version is unavailable');
22
24
  const realHome = homedir();
23
25
  const runtimeRoot = join(realHome, '.config', 'dsh-crew', 'harness', 'runtime');
24
26
  const runtimeModule = join(runtimeRoot, 'node_modules', '@deepseek-ai', 'dsh', 'lib', 'bin.js');
@@ -32,6 +34,22 @@ const profileRoot = join(officialHome, 'profiles', 'web');
32
34
  const logs = [];
33
35
  let official;
34
36
 
37
+ async function reservePort() {
38
+ const server = createServer();
39
+ await new Promise((resolveListen, reject) => {
40
+ server.once('error', reject);
41
+ server.listen(0, '127.0.0.1', resolveListen);
42
+ });
43
+ const port = server.address().port;
44
+ await new Promise((resolveClose) => server.close(resolveClose));
45
+ return port;
46
+ }
47
+
48
+ const officialPort = await reservePort();
49
+ const crewPort = await reservePort();
50
+ const officialUrl = `http://127.0.0.1:${officialPort}`;
51
+ const crewUrl = `http://127.0.0.1:${crewPort}`;
52
+
35
53
  function assert(condition, message) {
36
54
  if (!condition) throw new Error(message);
37
55
  }
@@ -88,10 +106,13 @@ try {
88
106
  writeFileSync(join(profileRoot, 'pnpm-workspace.yaml'), 'packages:\n - .\n\nnodeLinker: hoisted\nautoInstallPeers: false\n');
89
107
 
90
108
  const currentConfig = join(realHome, '.config', 'dsh-crew', 'config.json');
109
+ let sandboxConfig = {};
91
110
  if (existsSync(currentConfig)) {
92
111
  mkdirSync(crewRoot, { recursive: true });
93
- copyFileSync(currentConfig, join(crewRoot, 'config.json'));
112
+ sandboxConfig = JSON.parse(readFileSync(currentConfig, 'utf8'));
94
113
  }
114
+ mkdirSync(crewRoot, { recursive: true });
115
+ writeFileSync(join(crewRoot, 'config.json'), JSON.stringify({ ...sandboxConfig, hub_url: crewUrl }, null, 2));
95
116
 
96
117
  const installer = {
97
118
  installCodex: () => ({ ok: true, actions: [] }),
@@ -115,9 +136,9 @@ try {
115
136
  assert(integrated.ok, `disposable integrate failed: ${logs.join(' | ')}`);
116
137
 
117
138
  official = spawn(process.execPath, [
118
- runtimeModule, '--profile', 'web', '--host', '127.0.0.1', '--port', '3080', '--no-open',
139
+ runtimeModule, '--profile', 'web', '--host', '127.0.0.1', '--port', String(officialPort), '--no-open',
119
140
  ], {
120
- env: { ...process.env, HOME: sandbox, USERPROFILE: sandbox, DSH_HOME: officialHome },
141
+ env: { ...process.env, HOME: sandbox, USERPROFILE: sandbox, DSH_HOME: officialHome, DSH_CREW_BRIDGE_TARGET: crewUrl },
121
142
  stdio: ['ignore', 'pipe', 'pipe'],
122
143
  windowsHide: true,
123
144
  });
@@ -125,20 +146,20 @@ try {
125
146
  official.stdout.on('data', capture);
126
147
  official.stderr.on('data', capture);
127
148
 
128
- await waitForPageMarker('http://127.0.0.1:3080/', '@ran-sh/dsh-crew-web-bridge');
129
- const bridgeStatus = await (await waitFor('http://127.0.0.1:3080/_dsh/dsh-crew/bridge-status')).json();
149
+ await waitForPageMarker(`${officialUrl}/`, '@ran-sh/dsh-crew-web-bridge');
150
+ const bridgeStatus = await (await waitFor(`${officialUrl}/_dsh/dsh-crew/bridge-status`)).json();
130
151
  assert(bridgeStatus.mode === 'official-3080-isolated-3210', 'bridge status mode mismatch');
131
- const proxiedRuntime = await (await waitFor('http://127.0.0.1:3080/_dsh/dsh-crew/runtime', { timeout: 45_000 })).json();
132
- assert(proxiedRuntime.runtime_version === '0.3.8', 'proxied runtime version mismatch');
133
- const directRuntime = await (await waitFor('http://127.0.0.1:3210/_dsh/dsh-crew/runtime')).json();
134
- assert(directRuntime.runtime_version === '0.3.8', 'direct runtime version mismatch');
135
- const models = await (await waitFor('http://127.0.0.1:3080/_dsh/dsh-crew/models')).json();
152
+ const proxiedRuntime = await (await waitFor(`${officialUrl}/_dsh/dsh-crew/runtime`, { timeout: 45_000 })).json();
153
+ assert(proxiedRuntime.runtime_version === candidateVersion, `proxied runtime version mismatch (${proxiedRuntime.runtime_version} != ${candidateVersion})`);
154
+ const directRuntime = await (await waitFor(`${crewUrl}/_dsh/dsh-crew/runtime`)).json();
155
+ assert(directRuntime.runtime_version === candidateVersion, `direct runtime version mismatch (${directRuntime.runtime_version} != ${candidateVersion})`);
156
+ const models = await (await waitFor(`${officialUrl}/_dsh/dsh-crew/models`)).json();
136
157
  assert(Array.isArray(models.providers), 'proxied model catalog missing providers');
137
158
 
138
159
  console.log(JSON.stringify({
139
160
  ok: true,
140
- official_ui: 'http://127.0.0.1:3080',
141
- isolated_backend: 'http://127.0.0.1:3210',
161
+ official_ui: officialUrl,
162
+ isolated_backend: crewUrl,
142
163
  runtime_version: proxiedRuntime.runtime_version,
143
164
  provider_count: models.providers.length,
144
165
  official_profile: profileRoot,
@@ -0,0 +1,78 @@
1
+ // Stable extension-capability projection for GPT-first orchestrators. It
2
+ // describes only DSH Crew and deliberately never advertises itself as a top-
3
+ // level Executor or control plane.
4
+
5
+ export const EXTENSION_CONTRACT_SCHEMA_VERSION = 1;
6
+
7
+ function row(matrix, id) {
8
+ return Array.isArray(matrix?.rows) ? matrix.rows.find((entry) => entry?.id === id) : undefined;
9
+ }
10
+
11
+ function component(status, reasonCode, evidence = null) {
12
+ return { status, reason_code: reasonCode, ...(evidence ? { evidence } : {}) };
13
+ }
14
+
15
+ function workspaceComponent(workspace) {
16
+ if (workspace?.status === 'CONFLICT' || workspace?.status === 'READ_ONLY') {
17
+ return { ...component('DEGRADED', workspace.reason_code ?? `WORKSPACE_${workspace.status}`), state: workspace.status };
18
+ }
19
+ if (workspace?.status === 'UNAVAILABLE') {
20
+ return { ...component('UNAVAILABLE', workspace.reason_code ?? 'WORKSPACE_UNAVAILABLE'), state: 'UNAVAILABLE' };
21
+ }
22
+ if (workspace?.status === 'READY') {
23
+ return { ...component('READY', workspace.reason_code ?? 'WORKSPACE_READY'), state: 'READY' };
24
+ }
25
+ return workspace?.ok === true
26
+ ? { ...component('READY', workspace.context ? 'WORKSPACE_CONTEXT_RESOLVED' : 'WORKSPACE_CONTEXT_NOT_REQUESTED'), state: 'READY' }
27
+ : { ...component('UNAVAILABLE', workspace?.code ?? 'WORKSPACE_NOT_CHECKED'), state: 'UNAVAILABLE' };
28
+ }
29
+
30
+ function readinessFromRow(entry, { pass = 'READY', notRun = 'DEGRADED' } = {}) {
31
+ if (!entry) return component('UNAVAILABLE', 'NO_EVIDENCE');
32
+ if (entry.status === 'PASS') return component(pass, entry.reason_code ?? 'CHECK_PASSED');
33
+ if (entry.status === 'NOT_RUN' || entry.status === 'SKIP') return component(notRun, entry.reason_code ?? 'CHECK_NOT_RUN');
34
+ return component('UNAVAILABLE', entry.reason_code ?? 'CHECK_FAILED');
35
+ }
36
+
37
+ export function buildExtensionContract({ config = {}, readinessMatrix = {}, workspace = null, profiles = null, runtime = null } = {}) {
38
+ const workerEnabled = config.subagents_enabled !== false && config.worker_state !== 'disabled';
39
+ const reviewerEnabled = config.subagents_enabled !== false && config.review_state !== 'disabled';
40
+ const realModelEvidence = ['model_execution', 'deepseek_flash', 'deepseek_pro', 'opencode_go_mimo_qwen']
41
+ .map((id) => row(readinessMatrix, id))
42
+ .find((entry) => entry?.status === 'PASS');
43
+ const catalogEvidence = row(readinessMatrix, 'provider_catalog');
44
+ const modelReadiness = realModelEvidence
45
+ ? component('READY', realModelEvidence.reason_code ?? 'MODEL_EXECUTION_PASSED')
46
+ : catalogEvidence?.status === 'PASS' || catalogEvidence?.status === 'SKIP'
47
+ ? component('DEGRADED', 'MODEL_CATALOG_ONLY')
48
+ : component('UNAVAILABLE', catalogEvidence?.reason_code ?? 'NO_EVIDENCE');
49
+ const components = {
50
+ harness: readinessFromRow(row(readinessMatrix, 'hub_compatibility')),
51
+ model: modelReadiness,
52
+ workspace: workspaceComponent(workspace),
53
+ reviewer: reviewerEnabled
54
+ ? readinessFromRow(row(readinessMatrix, 'reviewer_pipeline'))
55
+ : component('DEGRADED', 'REVIEWER_DISABLED'),
56
+ };
57
+ const states = Object.values(components).map((entry) => entry.status);
58
+ const readiness = states.includes('UNAVAILABLE') ? 'UNAVAILABLE' : states.includes('DEGRADED') ? 'DEGRADED' : 'READY';
59
+ return {
60
+ schema_version: EXTENSION_CONTRACT_SCHEMA_VERSION,
61
+ kind: 'dsh-crew-extension',
62
+ runtime: runtime ?? null,
63
+ capabilities: {
64
+ 'deepseek.worker': workerEnabled,
65
+ 'deepseek.reviewer': reviewerEnabled,
66
+ 'worktree.isolation': true,
67
+ 'model.fallback': config.escalate_on_failure === true,
68
+ 'job.cancel': true,
69
+ 'job.watch': true,
70
+ 'job.resume': false,
71
+ 'result.evidence': true,
72
+ 'events.canonical': true,
73
+ 'profiles.roles': profiles?.ok === true,
74
+ 'workspace.context': true,
75
+ },
76
+ readiness: { status: readiness, components },
77
+ };
78
+ }
@@ -69,6 +69,11 @@ const RUNTIME_CODES = new Set([
69
69
  'GIT_ERROR',
70
70
  'WORKTREE_LOCKED',
71
71
  'WORKTREE_CREATE_FAILED',
72
+ 'PROFILE_NOT_FOUND',
73
+ 'PROFILE_ROLE_MISMATCH',
74
+ 'WORKSPACE_CONTEXT_NOT_FOUND',
75
+ 'WORKSPACE_ROOT_MISMATCH',
76
+ 'WORKSPACE_CONTEXT_REFS_INVALID',
72
77
  'CANDIDATE_CAPTURE_FAILED',
73
78
  'ATTEMPT_INFRA_FAILURE',
74
79
  'HUB_REQUEST_FAILED',
@@ -78,13 +83,37 @@ function normalizedCode(value) {
78
83
  return typeof value === 'string' && value.trim() ? value.trim() : null;
79
84
  }
80
85
 
86
+ function failureFamily(category, reasonCode, sourceCode) {
87
+ const code = sourceCode ?? reasonCode ?? '';
88
+ if (category === 'none') return 'NONE';
89
+ if (category === 'compatibility' || code.startsWith('HUB_')) return 'HARNESS';
90
+ if (category === 'provider' || code.startsWith('MODEL_') || code.startsWith('PROVIDER_')) return 'MODEL';
91
+ if (/^(WORK|GIT_|ISOLATION_|CANDIDATE_|PROFILE_)/.test(code)) return 'WORKSPACE';
92
+ if (String(reasonCode).startsWith('REVIEW_')) return 'REVIEW';
93
+ if (category === 'policy') return 'POLICY';
94
+ return 'JOB';
95
+ }
96
+
97
+ function failureDisposition(category, family) {
98
+ if (category === 'none') return 'none';
99
+ if (category === 'cancelled') return 'terminal';
100
+ if (category === 'compatibility') return 'retry';
101
+ if (category === 'provider') return 'fallback';
102
+ if (category === 'policy' || family === 'WORKSPACE' || family === 'REVIEW') return 'human';
103
+ if (category === 'runtime') return 'retry';
104
+ return 'terminal';
105
+ }
106
+
81
107
  function result(category, reasonCode, { sourceCode = null, terminalReason = null } = {}) {
108
+ const family = failureFamily(category, reasonCode, sourceCode);
82
109
  return {
83
110
  schema_version: 1,
84
111
  category,
85
112
  reason_code: reasonCode,
86
113
  ...(sourceCode ? { source_code: sourceCode } : {}),
87
114
  ...(terminalReason ? { terminal_reason: terminalReason } : {}),
115
+ family,
116
+ disposition: failureDisposition(category, family),
88
117
  };
89
118
  }
90
119