@ran-sh/dsh-crew 1.1.0 → 1.2.0-rc.4
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 +16 -17
- package/.claude-plugin/plugin.json +7 -1
- package/README.md +44 -15
- package/README.zh.md +37 -12
- package/agents/ds-flash.md +16 -18
- package/agents/ds-pro.md +16 -24
- package/agents/ds-reviewer.md +15 -15
- package/agents/ds-worker.md +16 -16
- package/bin/dsh-crew.mjs +16 -12
- package/codex/AGENTS.md +37 -85
- package/codex/agents/ds-flash.toml +18 -14
- package/codex/agents/ds-pro.toml +18 -15
- package/codex/agents/ds-reviewer.toml +17 -13
- package/codex/agents/ds-worker.toml +17 -13
- package/codex/prompts/dsh-config.md +17 -1
- package/codex/prompts/dsh-status.md +5 -1
- package/commands/config.md +16 -4
- package/commands/status.md +6 -2
- package/docs/installation.md +54 -9
- package/docs/readiness-matrix.md +14 -6
- package/docs/ui-surfaces.md +32 -17
- package/lib/client.js +5434 -4844
- package/official-web-bridge/lib/client.js +567 -479
- package/official-web-bridge/overlay-entry.mjs +59 -0
- package/package.json +6 -3
- package/scripts/build-client.mjs +2 -0
- package/scripts/setup.mjs +8 -7
- package/scripts/verify-crew-ui-polish.mjs +145 -0
- package/scripts/verify-history-ui.mjs +97 -0
- package/scripts/verify-npm-install.mjs +1 -1
- package/src/client/history-panel.tsx +108 -0
- package/src/client/host-readiness.mjs +15 -6
- package/src/client/index.tsx +86 -64
- package/src/client/model-callability-view.mjs +17 -0
- package/src/client/panel-chrome.tsx +40 -0
- package/src/client/quick-panel.tsx +88 -73
- package/src/client/readiness-envelope.mjs +34 -0
- package/src/config-readiness.mjs +181 -115
- package/src/extension-contract.mjs +44 -26
- package/src/history/admission-gate.mjs +51 -0
- package/src/history/archive-store.mjs +261 -0
- package/src/history/cleanup-plan.mjs +64 -0
- package/src/history/http.mjs +32 -0
- package/src/history/operation.mjs +86 -0
- package/src/history/runner.mjs +51 -0
- package/src/history/runtime.mjs +28 -0
- package/src/history/service.mjs +137 -0
- package/src/history/state.mjs +27 -0
- package/src/hub/index.mjs +141 -24
- package/src/hub-client.mjs +17 -15
- package/src/image-output.mjs +71 -0
- package/src/install/install-legacy.mjs +126 -23
- package/src/install/npx-lifecycle.mjs +373 -64
- package/src/install/official-frontend-assets.mjs +78 -0
- package/src/install/payload-content.mjs +88 -0
- package/src/install/windows-startup.mjs +107 -19
- package/src/install/windows-supervisor-adapter.mjs +443 -0
- package/src/install/windows-supervisor-lifecycle.mjs +782 -0
- package/src/install/zcode.mjs +53 -14
- package/src/job-contracts.mjs +37 -31
- package/src/jobs.mjs +2 -2
- package/src/mcp-runtime.mjs +74 -9
- package/src/model-callability-contract.mjs +79 -0
- package/src/multimodal.mjs +0 -0
- package/src/official-web-bridge.mjs +0 -2
- package/src/provider-health.mjs +130 -124
- package/src/provider-profile-store.mjs +12 -0
- package/src/provider-settings-store.mjs +347 -5
- package/src/readiness-matrix.mjs +20 -15
- package/src/runtime-identity-contract.mjs +34 -0
- package/src/runtime-identity.mjs +14 -4
- package/src/runtime-readiness-snapshot.mjs +285 -87
- package/src/server.mjs +86 -76
- package/src/standalone-sdk.mjs +23 -0
- package/src/supervisor/restart-request.mjs +64 -10
- package/src/workflow-runtime.mjs +28 -13
- package/windows/start-dsh-crew.cmd +57 -57
- package/windows/start-dsh-crew.ps1 +327 -55
- package/windows/supervisor-control.ps1 +467 -0
- package/zcode/AGENTS.md +4 -1
- package/zcode/agents/ds-reviewer.md +31 -36
- package/zcode/agents/ds-worker.md +31 -39
- package/zcode/commands/dsh-config.md +17 -6
- package/zcode/commands/dsh-status.md +5 -4
- package/.mcp.json +0 -8
package/src/provider-health.mjs
CHANGED
|
@@ -1,124 +1,130 @@
|
|
|
1
|
-
// Bounded provider/model callability evidence.
|
|
2
|
-
//
|
|
3
|
-
// Catalog presence is not proof of a callable route. This store keeps only
|
|
4
|
-
// sanitized state and timestamps; raw provider errors never leave the caller.
|
|
5
|
-
|
|
6
|
-
export const PROVIDER_HEALTH_STATES = Object.freeze([
|
|
7
|
-
'callable', 'credential-missing', 'quota-exhausted', 'rate-limited',
|
|
8
|
-
'timeout', 'internal-error', 'disabled', 'not-configured', 'tombstoned', 'unprobed',
|
|
9
|
-
]);
|
|
10
|
-
|
|
11
|
-
const REASON_CODES = Object.freeze({
|
|
12
|
-
callable: 'PROVIDER_CALLABLE',
|
|
13
|
-
'credential-missing': 'CREDENTIAL_MISSING',
|
|
14
|
-
'quota-exhausted': 'QUOTA_EXHAUSTED',
|
|
15
|
-
'rate-limited': 'RATE_LIMITED',
|
|
16
|
-
timeout: 'PROBE_TIMEOUT',
|
|
17
|
-
'internal-error': 'PROVIDER_INTERNAL_ERROR',
|
|
18
|
-
disabled: 'PROVIDER_DISABLED',
|
|
19
|
-
'not-configured': 'PROVIDER_NOT_CONFIGURED',
|
|
20
|
-
tombstoned: 'PROVIDER_TOMBSTONED',
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const DEFAULT_TTLS = Object.freeze({
|
|
24
|
-
callable: 5 * 60 * 1000,
|
|
25
|
-
'credential-missing': 30 * 1000,
|
|
26
|
-
'quota-exhausted': 15 * 60 * 1000,
|
|
27
|
-
'rate-limited': 60 * 1000,
|
|
28
|
-
timeout: 60 * 1000,
|
|
29
|
-
'internal-error': 60 * 1000,
|
|
30
|
-
disabled: 5 * 60 * 1000,
|
|
31
|
-
'not-configured': 30 * 1000,
|
|
32
|
-
tombstoned: 5 * 60 * 1000,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
function text(value) {
|
|
36
|
-
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function providerKey(provider, model) {
|
|
40
|
-
const p = text(provider);
|
|
41
|
-
const m = text(model);
|
|
42
|
-
return p && m ? `${p}\u0000${m}` : null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function errorText(error) {
|
|
46
|
-
if (!error || typeof error !== 'object') return '';
|
|
47
|
-
return [error.code, error.name, error.message, error.status].filter((value) => value !== undefined && value !== null).join(' ').toLowerCase();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** Map an upstream error to one bounded, secret-free callability state. */
|
|
51
|
-
export function classifyProviderError(error = {}) {
|
|
52
|
-
const textValue = errorText(error);
|
|
53
|
-
const code = text(error?.code)?.toUpperCase() ?? '';
|
|
54
|
-
if (code === 'MISSING_CREDENTIAL' || code === 'CREDENTIAL_MISSING' || /no (api )?key|credential.*missing|missing.*credential/.test(textValue)) {
|
|
55
|
-
return { state: 'credential-missing', reason_code: REASON_CODES['credential-missing'] };
|
|
56
|
-
}
|
|
57
|
-
if (code === 'QUOTA_EXCEEDED' || /monthly|account/.test(textValue) && /quota|exhaust|limit/.test(textValue)) {
|
|
58
|
-
return { state: 'quota-exhausted', reason_code: REASON_CODES['quota-exhausted'] };
|
|
59
|
-
}
|
|
60
|
-
if (Number(error?.status) === 429 || code === 'RATE_LIMITED' || /rate.?limit|too many requests/.test(textValue)) {
|
|
61
|
-
return { state: 'rate-limited', reason_code: REASON_CODES['rate-limited'] };
|
|
62
|
-
}
|
|
63
|
-
if (error?.name === 'TimeoutError' || error?.name === 'AbortError' || code === 'TIMEOUT' || /timed? out|timeout|aborted/.test(textValue)) {
|
|
64
|
-
return { state: 'timeout', reason_code: REASON_CODES.timeout };
|
|
65
|
-
}
|
|
66
|
-
return { state: 'internal-error', reason_code: REASON_CODES['internal-error'] };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function boundedTimestamp(value, fallback) {
|
|
70
|
-
return Number.isFinite(value) && value >= 0 ? value : fallback;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function view(entry, now) {
|
|
74
|
-
if (!entry) return { state: 'unprobed', reason_code: null, observed_at: null, expires_at: null, fresh: false };
|
|
75
|
-
const fresh = now < entry.expires_at;
|
|
76
|
-
if (!fresh) return { state: 'unprobed', reason_code: null, observed_at: entry.observed_at, expires_at: entry.expires_at, fresh: false };
|
|
77
|
-
return { ...entry, fresh: true };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function createProviderHealthStore({ clock = () => Date.now(), ttls = {}, maxEntries = 256 } = {}) {
|
|
81
|
-
const records = new Map();
|
|
82
|
-
const limits = { ...DEFAULT_TTLS };
|
|
83
|
-
for (const state of PROVIDER_HEALTH_STATES) {
|
|
84
|
-
if (Number.isFinite(ttls[state]) && ttls[state] >= 0) limits[state] = Math.min(ttls[state], 24 * 60 * 60 * 1000);
|
|
85
|
-
}
|
|
86
|
-
const boundedMax = Number.isInteger(maxEntries) && maxEntries > 0 ? Math.min(maxEntries, 2048) : 256;
|
|
87
|
-
|
|
88
|
-
const get = (provider, model) => {
|
|
89
|
-
const key = providerKey(provider, model);
|
|
90
|
-
if (!key) return { provider: text(provider), model: text(model), state: 'unprobed', reason_code: null, observed_at: null, expires_at: null, fresh: false };
|
|
91
|
-
const entry = records.get(key);
|
|
92
|
-
const current = view(entry, clock());
|
|
93
|
-
if (entry && !current.fresh) records.delete(key);
|
|
94
|
-
return { provider: text(provider), model: text(model), ...current };
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const record = (provider, model, result = {}) => {
|
|
98
|
-
const key = providerKey(provider, model);
|
|
99
|
-
if (!key) return null;
|
|
100
|
-
const now = clock();
|
|
101
|
-
const observed = boundedTimestamp(result.observed_at, now);
|
|
102
|
-
const previous = records.get(key);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (result.
|
|
106
|
-
else
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
1
|
+
// Bounded provider/model callability evidence.
|
|
2
|
+
//
|
|
3
|
+
// Catalog presence is not proof of a callable route. This store keeps only
|
|
4
|
+
// sanitized state and timestamps; raw provider errors never leave the caller.
|
|
5
|
+
|
|
6
|
+
export const PROVIDER_HEALTH_STATES = Object.freeze([
|
|
7
|
+
'callable', 'credential-missing', 'quota-exhausted', 'rate-limited',
|
|
8
|
+
'timeout', 'internal-error', 'disabled', 'not-configured', 'tombstoned', 'unprobed',
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const REASON_CODES = Object.freeze({
|
|
12
|
+
callable: 'PROVIDER_CALLABLE',
|
|
13
|
+
'credential-missing': 'CREDENTIAL_MISSING',
|
|
14
|
+
'quota-exhausted': 'QUOTA_EXHAUSTED',
|
|
15
|
+
'rate-limited': 'RATE_LIMITED',
|
|
16
|
+
timeout: 'PROBE_TIMEOUT',
|
|
17
|
+
'internal-error': 'PROVIDER_INTERNAL_ERROR',
|
|
18
|
+
disabled: 'PROVIDER_DISABLED',
|
|
19
|
+
'not-configured': 'PROVIDER_NOT_CONFIGURED',
|
|
20
|
+
tombstoned: 'PROVIDER_TOMBSTONED',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const DEFAULT_TTLS = Object.freeze({
|
|
24
|
+
callable: 5 * 60 * 1000,
|
|
25
|
+
'credential-missing': 30 * 1000,
|
|
26
|
+
'quota-exhausted': 15 * 60 * 1000,
|
|
27
|
+
'rate-limited': 60 * 1000,
|
|
28
|
+
timeout: 60 * 1000,
|
|
29
|
+
'internal-error': 60 * 1000,
|
|
30
|
+
disabled: 5 * 60 * 1000,
|
|
31
|
+
'not-configured': 30 * 1000,
|
|
32
|
+
tombstoned: 5 * 60 * 1000,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
function text(value) {
|
|
36
|
+
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function providerKey(provider, model) {
|
|
40
|
+
const p = text(provider);
|
|
41
|
+
const m = text(model);
|
|
42
|
+
return p && m ? `${p}\u0000${m}` : null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function errorText(error) {
|
|
46
|
+
if (!error || typeof error !== 'object') return '';
|
|
47
|
+
return [error.code, error.name, error.message, error.status].filter((value) => value !== undefined && value !== null).join(' ').toLowerCase();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Map an upstream error to one bounded, secret-free callability state. */
|
|
51
|
+
export function classifyProviderError(error = {}) {
|
|
52
|
+
const textValue = errorText(error);
|
|
53
|
+
const code = text(error?.code)?.toUpperCase() ?? '';
|
|
54
|
+
if (code === 'MISSING_CREDENTIAL' || code === 'CREDENTIAL_MISSING' || /no (api )?key|credential.*missing|missing.*credential/.test(textValue)) {
|
|
55
|
+
return { state: 'credential-missing', reason_code: REASON_CODES['credential-missing'] };
|
|
56
|
+
}
|
|
57
|
+
if (code === 'QUOTA_EXCEEDED' || /monthly|account/.test(textValue) && /quota|exhaust|limit/.test(textValue)) {
|
|
58
|
+
return { state: 'quota-exhausted', reason_code: REASON_CODES['quota-exhausted'] };
|
|
59
|
+
}
|
|
60
|
+
if (Number(error?.status) === 429 || code === 'RATE_LIMITED' || /rate.?limit|too many requests/.test(textValue)) {
|
|
61
|
+
return { state: 'rate-limited', reason_code: REASON_CODES['rate-limited'] };
|
|
62
|
+
}
|
|
63
|
+
if (error?.name === 'TimeoutError' || error?.name === 'AbortError' || code === 'TIMEOUT' || /timed? out|timeout|aborted/.test(textValue)) {
|
|
64
|
+
return { state: 'timeout', reason_code: REASON_CODES.timeout };
|
|
65
|
+
}
|
|
66
|
+
return { state: 'internal-error', reason_code: REASON_CODES['internal-error'] };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function boundedTimestamp(value, fallback) {
|
|
70
|
+
return Number.isFinite(value) && value >= 0 ? value : fallback;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function view(entry, now) {
|
|
74
|
+
if (!entry) return { state: 'unprobed', reason_code: null, observed_at: null, expires_at: null, fresh: false };
|
|
75
|
+
const fresh = now < entry.expires_at;
|
|
76
|
+
if (!fresh) return { state: 'unprobed', reason_code: null, observed_at: entry.observed_at, expires_at: entry.expires_at, fresh: false };
|
|
77
|
+
return { ...entry, fresh: true };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function createProviderHealthStore({ clock = () => Date.now(), ttls = {}, maxEntries = 256 } = {}) {
|
|
81
|
+
const records = new Map();
|
|
82
|
+
const limits = { ...DEFAULT_TTLS };
|
|
83
|
+
for (const state of PROVIDER_HEALTH_STATES) {
|
|
84
|
+
if (Number.isFinite(ttls[state]) && ttls[state] >= 0) limits[state] = Math.min(ttls[state], 24 * 60 * 60 * 1000);
|
|
85
|
+
}
|
|
86
|
+
const boundedMax = Number.isInteger(maxEntries) && maxEntries > 0 ? Math.min(maxEntries, 2048) : 256;
|
|
87
|
+
|
|
88
|
+
const get = (provider, model) => {
|
|
89
|
+
const key = providerKey(provider, model);
|
|
90
|
+
if (!key) return { provider: text(provider), model: text(model), state: 'unprobed', reason_code: null, observed_at: null, expires_at: null, fresh: false };
|
|
91
|
+
const entry = records.get(key);
|
|
92
|
+
const current = view(entry, clock());
|
|
93
|
+
if (entry && !current.fresh) records.delete(key);
|
|
94
|
+
return { provider: text(provider), model: text(model), ...current };
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const record = (provider, model, result = {}) => {
|
|
98
|
+
const key = providerKey(provider, model);
|
|
99
|
+
if (!key) return null;
|
|
100
|
+
const now = clock();
|
|
101
|
+
const observed = boundedTimestamp(result.observed_at, now);
|
|
102
|
+
const previous = records.get(key);
|
|
103
|
+
let classified;
|
|
104
|
+
if (result.ok === true) classified = { state: 'callable', reason_code: REASON_CODES.callable };
|
|
105
|
+
else if (PROVIDER_HEALTH_STATES.includes(result.state) && result.state !== 'unprobed') classified = { state: result.state, reason_code: REASON_CODES[result.state] ?? null };
|
|
106
|
+
else classified = classifyProviderError(result.error ?? result);
|
|
107
|
+
if (previous && previous.observed_at > observed) return get(provider, model);
|
|
108
|
+
if (previous && previous.observed_at === observed) {
|
|
109
|
+
const previousFailure = previous.state !== 'callable';
|
|
110
|
+
const incomingFailure = classified.state !== 'callable';
|
|
111
|
+
if (previousFailure && !incomingFailure) return get(provider, model);
|
|
112
|
+
if (previousFailure && incomingFailure && String(previous.state).localeCompare(String(classified.state)) <= 0) return get(provider, model);
|
|
113
|
+
}
|
|
114
|
+
const expires = observed + limits[classified.state];
|
|
115
|
+
records.set(key, {
|
|
116
|
+
provider: text(provider), model: text(model), ...classified,
|
|
117
|
+
observed_at: observed, expires_at: expires,
|
|
118
|
+
});
|
|
119
|
+
while (records.size > boundedMax) {
|
|
120
|
+
const oldest = [...records.entries()].sort((a, b) => a[1].observed_at - b[1].observed_at)[0]?.[0];
|
|
121
|
+
if (!oldest) break;
|
|
122
|
+
records.delete(oldest);
|
|
123
|
+
}
|
|
124
|
+
return get(provider, model);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const list = () => [...records.values()].map((entry) => view(entry, clock())).filter((entry) => entry.fresh).slice(0, boundedMax);
|
|
128
|
+
|
|
129
|
+
return { get, record, list, ttls: { ...limits }, maxEntries: boundedMax };
|
|
130
|
+
}
|
|
@@ -24,6 +24,18 @@ function nonBlank(line) {
|
|
|
24
24
|
function parseProviderMap(source) {
|
|
25
25
|
if (typeof source !== 'string') return { ok: false, code: 'PROVIDER_PROFILE_SCHEMA_UNSUPPORTED' };
|
|
26
26
|
const lines = source.split(/\r?\n/);
|
|
27
|
+
if (source.trim() === '[]') {
|
|
28
|
+
return {
|
|
29
|
+
ok: true,
|
|
30
|
+
style: 'empty-profile',
|
|
31
|
+
lines,
|
|
32
|
+
llmStart: -1,
|
|
33
|
+
blockEnd: lines.length,
|
|
34
|
+
providersLine: -1,
|
|
35
|
+
providerIndent: 0,
|
|
36
|
+
entries: [],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
27
39
|
const llmStart = lines.findIndex((line) => /^-\s+id:\s*llm-pi-ai\s*$/.test(line));
|
|
28
40
|
if (llmStart < 0) return { ok: false, code: 'PROVIDER_PROFILE_SCHEMA_UNSUPPORTED' };
|
|
29
41
|
|