@ran-sh/dsh-crew 1.0.1 → 1.0.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.
@@ -5,20 +5,20 @@
5
5
  // - HUB_PROTOCOL_VERSION changes only when Hub <-> MCP wire semantics become
6
6
  // incompatible.
7
7
  //
8
- // Keep this module dependency-light so Hub, MCP and tests all use the exact
9
- // same compatibility rules.
10
-
11
- import { randomUUID } from 'node:crypto';
12
-
13
- // Production Crew execution is intentionally bound to the isolated 3210 Hub.
14
- // These fields are public provenance only; no credential or session secret is
15
- // included in the identity contract.
16
- export const PRODUCTION_EXECUTION_PLANE = 'hub-3210';
17
- export const PRODUCTION_PROFILE = 'dsh-crew';
18
- export const PRODUCTION_LISTEN_PORT = 3210;
19
- const RUNTIME_ID = randomUUID();
20
-
21
- export const RUNTIME_VERSION = '1.0.1';
8
+ // Keep this module dependency-light so Hub, MCP and tests all use the exact
9
+ // same compatibility rules.
10
+
11
+ import { randomUUID } from 'node:crypto';
12
+
13
+ // Production Crew execution is intentionally bound to the isolated 3210 Hub.
14
+ // These fields are public provenance only; no credential or session secret is
15
+ // included in the identity contract.
16
+ export const PRODUCTION_EXECUTION_PLANE = 'hub-3210';
17
+ export const PRODUCTION_PROFILE = 'dsh-crew';
18
+ export const PRODUCTION_LISTEN_PORT = 3210;
19
+ const RUNTIME_ID = randomUUID();
20
+
21
+ export const RUNTIME_VERSION = '1.0.2';
22
22
  export const HUB_PROTOCOL_VERSION = 1;
23
23
 
24
24
  export const HUB_CAPABILITIES = Object.freeze([
@@ -33,17 +33,17 @@ export const HUB_CAPABILITIES = Object.freeze([
33
33
  'config',
34
34
  'canonical-events',
35
35
  'evidence',
36
- 'profiles',
37
- 'workspace-context',
38
- 'extension-contract',
39
- 'provider-inventory',
40
- 'provider-lifecycle-v1',
41
- 'provider-health-v1',
42
- 'provider-probe-stream-v1',
43
- 'credential-reference-inventory-v1',
44
- 'credential-purge-v1',
45
- 'runtime-provenance-v1',
46
- ]);
36
+ 'profiles',
37
+ 'workspace-context',
38
+ 'extension-contract',
39
+ 'provider-inventory',
40
+ 'provider-lifecycle-v1',
41
+ 'provider-health-v1',
42
+ 'provider-probe-stream-v1',
43
+ 'credential-reference-inventory-v1',
44
+ 'credential-purge-v1',
45
+ 'runtime-provenance-v1',
46
+ ]);
47
47
 
48
48
  // Capabilities the current MCP workflow depends on for full Hub execution.
49
49
  // Additional capabilities may be advertised without breaking compatibility.
@@ -60,12 +60,12 @@ export const HUB_COMPATIBILITY_CODES = Object.freeze({
60
60
  UNREACHABLE: 'HUB_UNREACHABLE',
61
61
  HTTP_ERROR: 'HUB_HTTP_ERROR',
62
62
  SERVICE_MISMATCH: 'HUB_SERVICE_MISMATCH',
63
- PROTOCOL_MISSING: 'HUB_PROTOCOL_MISSING',
64
- PROTOCOL_MISMATCH: 'HUB_PROTOCOL_MISMATCH',
65
- CAPABILITY_MISSING: 'HUB_CAPABILITY_MISSING',
66
- PROVENANCE_MISSING: 'HUB_PROVENANCE_MISSING',
67
- EXECUTION_PLANE_MISMATCH: 'HUB_EXECUTION_PLANE_MISMATCH',
68
- LISTEN_PORT_MISMATCH: 'HUB_LISTEN_PORT_MISMATCH',
63
+ PROTOCOL_MISSING: 'HUB_PROTOCOL_MISSING',
64
+ PROTOCOL_MISMATCH: 'HUB_PROTOCOL_MISMATCH',
65
+ CAPABILITY_MISSING: 'HUB_CAPABILITY_MISSING',
66
+ PROVENANCE_MISSING: 'HUB_PROVENANCE_MISSING',
67
+ EXECUTION_PLANE_MISMATCH: 'HUB_EXECUTION_PLANE_MISMATCH',
68
+ LISTEN_PORT_MISMATCH: 'HUB_LISTEN_PORT_MISMATCH',
69
69
  });
70
70
 
71
71
  function normalizedCapabilities(value) {
@@ -74,17 +74,17 @@ function normalizedCapabilities(value) {
74
74
  }
75
75
 
76
76
  export function getHubRuntimeIdentity() {
77
- return {
78
- service: 'dsh-crew-hub',
79
- surface: 'native-crew-harness',
80
- ui_role: 'runtime',
81
- runtime_version: RUNTIME_VERSION,
82
- protocol_version: HUB_PROTOCOL_VERSION,
83
- execution_plane: PRODUCTION_EXECUTION_PLANE,
84
- profile: PRODUCTION_PROFILE,
85
- listen_port: PRODUCTION_LISTEN_PORT,
86
- runtime_id: RUNTIME_ID,
87
- capabilities: [...HUB_CAPABILITIES],
77
+ return {
78
+ service: 'dsh-crew-hub',
79
+ surface: 'native-crew-harness',
80
+ ui_role: 'runtime',
81
+ runtime_version: RUNTIME_VERSION,
82
+ protocol_version: HUB_PROTOCOL_VERSION,
83
+ execution_plane: PRODUCTION_EXECUTION_PLANE,
84
+ profile: PRODUCTION_PROFILE,
85
+ listen_port: PRODUCTION_LISTEN_PORT,
86
+ runtime_id: RUNTIME_ID,
87
+ capabilities: [...HUB_CAPABILITIES],
88
88
  };
89
89
  }
90
90
 
@@ -95,51 +95,51 @@ export function getHubRuntimeIdentity() {
95
95
  * `compatible` means the response is from dsh-crew and satisfies the current
96
96
  * protocol + required capability contract.
97
97
  */
98
- export function evaluateHubHandshake(body, { requiredCapabilities = REQUIRED_HUB_CAPABILITIES, strictProduction = false } = {}) {
98
+ export function evaluateHubHandshake(body, { requiredCapabilities = REQUIRED_HUB_CAPABILITIES, strictProduction = false } = {}) {
99
99
  const capabilities = normalizedCapabilities(body?.capabilities);
100
100
  const base = {
101
101
  reachable: true,
102
102
  compatible: false,
103
103
  service: typeof body?.service === 'string' ? body.service : null,
104
- runtime_version: typeof body?.runtime_version === 'string' ? body.runtime_version : null,
105
- protocol_version: Number.isInteger(body?.protocol_version) ? body.protocol_version : null,
106
- execution_plane: typeof body?.execution_plane === 'string' ? body.execution_plane : null,
107
- profile: typeof body?.profile === 'string' ? body.profile : null,
108
- listen_port: Number.isInteger(body?.listen_port) ? body.listen_port : null,
109
- runtime_id: typeof body?.runtime_id === 'string' ? body.runtime_id : null,
104
+ runtime_version: typeof body?.runtime_version === 'string' ? body.runtime_version : null,
105
+ protocol_version: Number.isInteger(body?.protocol_version) ? body.protocol_version : null,
106
+ execution_plane: typeof body?.execution_plane === 'string' ? body.execution_plane : null,
107
+ profile: typeof body?.profile === 'string' ? body.profile : null,
108
+ listen_port: Number.isInteger(body?.listen_port) ? body.listen_port : null,
109
+ runtime_id: typeof body?.runtime_id === 'string' ? body.runtime_id : null,
110
110
  capabilities,
111
111
  missing_capabilities: [],
112
112
  code: null,
113
113
  };
114
114
 
115
- if (body?.service !== 'dsh-crew-hub') {
116
- return { ...base, code: HUB_COMPATIBILITY_CODES.SERVICE_MISMATCH };
117
- }
118
-
119
- // An explicit execution identity that is not the isolated 3210 Crew plane
120
- // must never be accepted as the production Hub. Missing legacy fields remain
121
- // compatible with the older protocol contract and are handled below.
122
- if (body?.execution_plane !== undefined && body.execution_plane !== PRODUCTION_EXECUTION_PLANE) {
123
- return { ...base, code: HUB_COMPATIBILITY_CODES.EXECUTION_PLANE_MISMATCH };
124
- }
125
- if (body?.listen_port !== undefined && body.listen_port !== PRODUCTION_LISTEN_PORT) {
126
- return { ...base, code: HUB_COMPATIBILITY_CODES.LISTEN_PORT_MISMATCH };
127
- }
115
+ if (body?.service !== 'dsh-crew-hub') {
116
+ return { ...base, code: HUB_COMPATIBILITY_CODES.SERVICE_MISMATCH };
117
+ }
118
+
119
+ // An explicit execution identity that is not the isolated 3210 Crew plane
120
+ // must never be accepted as the production Hub. Missing legacy fields remain
121
+ // compatible with the older protocol contract and are handled below.
122
+ if (body?.execution_plane !== undefined && body.execution_plane !== PRODUCTION_EXECUTION_PLANE) {
123
+ return { ...base, code: HUB_COMPATIBILITY_CODES.EXECUTION_PLANE_MISMATCH };
124
+ }
125
+ if (body?.listen_port !== undefined && body.listen_port !== PRODUCTION_LISTEN_PORT) {
126
+ return { ...base, code: HUB_COMPATIBILITY_CODES.LISTEN_PORT_MISMATCH };
127
+ }
128
128
 
129
129
  if (!Number.isInteger(body?.protocol_version)) {
130
130
  return { ...base, code: HUB_COMPATIBILITY_CODES.PROTOCOL_MISSING };
131
131
  }
132
132
 
133
- if (body.protocol_version !== HUB_PROTOCOL_VERSION) {
134
- return { ...base, code: HUB_COMPATIBILITY_CODES.PROTOCOL_MISMATCH };
135
- }
136
-
137
- if (strictProduction && !(body?.execution_plane === PRODUCTION_EXECUTION_PLANE
138
- && body?.profile === PRODUCTION_PROFILE
139
- && Number.isInteger(body?.listen_port) && body.listen_port === PRODUCTION_LISTEN_PORT
140
- && typeof body?.runtime_id === 'string' && body.runtime_id.trim().length > 0)) {
141
- return { ...base, code: HUB_COMPATIBILITY_CODES.PROVENANCE_MISSING };
142
- }
133
+ if (body.protocol_version !== HUB_PROTOCOL_VERSION) {
134
+ return { ...base, code: HUB_COMPATIBILITY_CODES.PROTOCOL_MISMATCH };
135
+ }
136
+
137
+ if (strictProduction && !(body?.execution_plane === PRODUCTION_EXECUTION_PLANE
138
+ && body?.profile === PRODUCTION_PROFILE
139
+ && Number.isInteger(body?.listen_port) && body.listen_port === PRODUCTION_LISTEN_PORT
140
+ && typeof body?.runtime_id === 'string' && body.runtime_id.trim().length > 0)) {
141
+ return { ...base, code: HUB_COMPATIBILITY_CODES.PROVENANCE_MISSING };
142
+ }
143
143
 
144
144
  const required = normalizedCapabilities(requiredCapabilities);
145
145
  const advertised = new Set(capabilities);