@avantf/dsh-mission 0.3.0
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/LICENSE +21 -0
- package/README.md +249 -0
- package/cordis.patch.yml +13 -0
- package/lib/client.js +225 -0
- package/lib/dsh-build.json +16 -0
- package/lib/envinit-bootstrap.js +334 -0
- package/lib/index.js +7021 -0
- package/lib/interface-version.json +4 -0
- package/lib/mission-core/capacity.d.ts +100 -0
- package/lib/mission-core/continuation.d.ts +106 -0
- package/lib/mission-core/dispatch.d.ts +165 -0
- package/lib/mission-core/engine.d.ts +331 -0
- package/lib/mission-core/index.d.ts +25 -0
- package/lib/mission-core/liveness.d.ts +99 -0
- package/lib/mission-core/prompt.d.ts +112 -0
- package/lib/mission-core/resources.d.ts +57 -0
- package/lib/mission-core/timing.d.ts +37 -0
- package/lib/mission-core/tree.d.ts +447 -0
- package/lib/mission-core/trouble.d.ts +40 -0
- package/lib/mission-core/types.d.ts +409 -0
- package/lib/mission-core/wellformed.d.ts +98 -0
- package/lib/types/claims.d.ts +3 -0
- package/lib/types/claims.d.ts.map +1 -0
- package/lib/types/client/MissionTreeView.d.ts +247 -0
- package/lib/types/client/MissionTreeView.d.ts.map +1 -0
- package/lib/types/client/api.d.ts +184 -0
- package/lib/types/client/api.d.ts.map +1 -0
- package/lib/types/client/contract.d.ts +209 -0
- package/lib/types/client/contract.d.ts.map +1 -0
- package/lib/types/client/index.d.ts +48 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/seat.d.ts +26 -0
- package/lib/types/client/seat.d.ts.map +1 -0
- package/lib/types/client/styles.d.ts +6 -0
- package/lib/types/client/styles.d.ts.map +1 -0
- package/lib/types/coldResume.d.ts +123 -0
- package/lib/types/coldResume.d.ts.map +1 -0
- package/lib/types/domain.d.ts +93 -0
- package/lib/types/domain.d.ts.map +1 -0
- package/lib/types/envinit.d.ts +126 -0
- package/lib/types/envinit.d.ts.map +1 -0
- package/lib/types/executorSession.d.ts +129 -0
- package/lib/types/executorSession.d.ts.map +1 -0
- package/lib/types/faces.d.ts +30 -0
- package/lib/types/faces.d.ts.map +1 -0
- package/lib/types/host.d.ts +752 -0
- package/lib/types/host.d.ts.map +1 -0
- package/lib/types/index.d.ts +48 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/interface_gate.d.ts +51 -0
- package/lib/types/interface_gate.d.ts.map +1 -0
- package/lib/types/log.d.ts +18 -0
- package/lib/types/log.d.ts.map +1 -0
- package/lib/types/projectionCache.d.ts +22 -0
- package/lib/types/projectionCache.d.ts.map +1 -0
- package/lib/types/prompt.d.ts +106 -0
- package/lib/types/prompt.d.ts.map +1 -0
- package/lib/types/source.d.ts +22 -0
- package/lib/types/source.d.ts.map +1 -0
- package/lib/types/store.d.ts +20 -0
- package/lib/types/store.d.ts.map +1 -0
- package/lib/types/timeFormat.d.ts +56 -0
- package/lib/types/timeFormat.d.ts.map +1 -0
- package/lib/types/tools.d.ts +34 -0
- package/lib/types/tools.d.ts.map +1 -0
- package/lib/types/wellformed.d.ts +43 -0
- package/lib/types/wellformed.d.ts.map +1 -0
- package/lib/types/wire.d.ts +178 -0
- package/lib/types/wire.d.ts.map +1 -0
- package/lib/types/workerEvents.d.ts +36 -0
- package/lib/types/workerEvents.d.ts.map +1 -0
- package/lib/types/workerSessions.d.ts +256 -0
- package/lib/types/workerSessions.d.ts.map +1 -0
- package/package.json +145 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@deepseek-ai/dsh-agent": "0.2.0-rc.2",
|
|
3
|
+
"@deepseek-ai/dsh-brand": "0.2.0-rc.2",
|
|
4
|
+
"@deepseek-ai/dsh-commands": "0.2.0-rc.2",
|
|
5
|
+
"@deepseek-ai/dsh-llm": "0.2.0-rc.2",
|
|
6
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.2",
|
|
7
|
+
"@deepseek-ai/dsh-session-query": "0.2.0-rc.2",
|
|
8
|
+
"@deepseek-ai/dsh-spill": "0.2.0-rc.2",
|
|
9
|
+
"@deepseek-ai/dsh-storage-domain": "0.2.0-rc.2",
|
|
10
|
+
"@deepseek-ai/dsh-subagent": "0.2.0-rc.2",
|
|
11
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
|
|
12
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.2",
|
|
13
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.0-rc.2",
|
|
14
|
+
"@deepseek-ai/dsh-typert-registry": "0.2.0-rc.2",
|
|
15
|
+
"@deepseek-ai/dsh-util-values": "0.2.0-rc.2"
|
|
16
|
+
}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the framework copy the caller's tree already has.
|
|
3
|
+
* @module bootstrap
|
|
4
|
+
*/
|
|
5
|
+
import { promises as fsp } from 'node:fs';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import { dirname, join } from 'node:path';
|
|
8
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
9
|
+
/** The bootstrap version; the resolved framework must satisfy {@link supportedRange}. */
|
|
10
|
+
export const VERSION = '0.4.0';
|
|
11
|
+
/**
|
|
12
|
+
* The framework interval this bootstrap can launch.
|
|
13
|
+
*
|
|
14
|
+
* Kept equal to the plugins' peer range for the base: the plugin passes no override, so THIS is the
|
|
15
|
+
* runtime gate. It is a plain comparator interval, NOT a caret: the package version is ordinary
|
|
16
|
+
* semver again and no longer tracks the interface, so the interval stays as wide as the family's
|
|
17
|
+
* compatibility promise — `>=0.3.0 <1.0.0` admits every 0.x base this generation of plugins can
|
|
18
|
+
* consume, and stops at the major that invented a new interface generation. The interface itself is
|
|
19
|
+
* the separate, runtime axis: a base inside this interval whose `INTERFACE_VERSION` differs is judged
|
|
20
|
+
* by the base's own gate (INTERFACE.md §1, §3) — an OLDER base degrades, a NEWER one is `ok` + a
|
|
21
|
+
* warning (generations are additive), and neither ever refuses the mount.
|
|
22
|
+
*/
|
|
23
|
+
export const supportedRange = '>=0.3.0 <1.0.0';
|
|
24
|
+
const PACKAGE = '@avantf/dsh-plugin-base';
|
|
25
|
+
function parseVersion(input) {
|
|
26
|
+
const match = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(input.trim());
|
|
27
|
+
if (match === null)
|
|
28
|
+
return undefined;
|
|
29
|
+
const minor = match[2] === undefined ? undefined : Number(match[2]);
|
|
30
|
+
const patch = match[3] === undefined ? undefined : Number(match[3]);
|
|
31
|
+
const parts = patch !== undefined ? 3 : minor !== undefined ? 2 : 1;
|
|
32
|
+
const pre = match[4] === undefined || match[4] === '' ? [] : match[4].split('.').map(part => (/^\d+$/.test(part) ? Number(part) : part));
|
|
33
|
+
return { major: Number(match[1]), minor: minor ?? 0, patch: patch ?? 0, pre, parts };
|
|
34
|
+
}
|
|
35
|
+
function comparePre(a, b) {
|
|
36
|
+
if (a.length === 0 && b.length === 0)
|
|
37
|
+
return 0;
|
|
38
|
+
if (a.length === 0)
|
|
39
|
+
return 1;
|
|
40
|
+
if (b.length === 0)
|
|
41
|
+
return -1;
|
|
42
|
+
for (let index = 0; index < Math.max(a.length, b.length); index += 1) {
|
|
43
|
+
const left = a[index];
|
|
44
|
+
const right = b[index];
|
|
45
|
+
if (left === undefined)
|
|
46
|
+
return -1;
|
|
47
|
+
if (right === undefined)
|
|
48
|
+
return 1;
|
|
49
|
+
if (typeof left === 'number' && typeof right === 'number') {
|
|
50
|
+
if (left !== right)
|
|
51
|
+
return left - right;
|
|
52
|
+
}
|
|
53
|
+
else if (typeof left === 'number')
|
|
54
|
+
return -1;
|
|
55
|
+
else if (typeof right === 'number')
|
|
56
|
+
return 1;
|
|
57
|
+
else if (left !== right)
|
|
58
|
+
return left < right ? -1 : 1;
|
|
59
|
+
}
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
function compare(a, b) {
|
|
63
|
+
if (a.major !== b.major)
|
|
64
|
+
return a.major - b.major;
|
|
65
|
+
if (a.minor !== b.minor)
|
|
66
|
+
return a.minor - b.minor;
|
|
67
|
+
if (a.patch !== b.patch)
|
|
68
|
+
return a.patch - b.patch;
|
|
69
|
+
return comparePre(a.pre, b.pre);
|
|
70
|
+
}
|
|
71
|
+
function tuple(major, minor, patch) {
|
|
72
|
+
return { major, minor, patch, pre: [], parts: 3 };
|
|
73
|
+
}
|
|
74
|
+
/** The next release boundary a partial `>`/`<=` desugars to. */
|
|
75
|
+
function bumpPartial(partial, keepPrerelease) {
|
|
76
|
+
const pre = keepPrerelease ? partial.pre : [];
|
|
77
|
+
if (partial.parts === 2)
|
|
78
|
+
return { major: partial.major, minor: partial.minor + 1, patch: 0, pre, parts: 3 };
|
|
79
|
+
return { major: partial.major + 1, minor: 0, patch: 0, pre, parts: 3 };
|
|
80
|
+
}
|
|
81
|
+
/** Expand one range token into comparators; `undefined` for a token outside the subset. */
|
|
82
|
+
function comparatorsOf(token) {
|
|
83
|
+
const match = /^(\^|~|>=|<=|>|<|=)?(.*)$/.exec(token);
|
|
84
|
+
if (match === null)
|
|
85
|
+
return undefined;
|
|
86
|
+
const operator = match[1] ?? '';
|
|
87
|
+
const partial = parseVersion(match[2] ?? '');
|
|
88
|
+
if (partial === undefined)
|
|
89
|
+
return undefined;
|
|
90
|
+
switch (operator) {
|
|
91
|
+
case '>':
|
|
92
|
+
// A partial `>1.2` desugars to `>=1.3.0`.
|
|
93
|
+
return partial.parts === 3 ? [{ op: '>', version: partial }] : [{ op: '>=', version: bumpPartial(partial, true) }];
|
|
94
|
+
case '<=':
|
|
95
|
+
// A partial `<=1.2` desugars to `<1.3.0`.
|
|
96
|
+
return partial.parts === 3 ? [{ op: '<=', version: partial }] : [{ op: '<', version: bumpPartial(partial, false) }];
|
|
97
|
+
case '>=':
|
|
98
|
+
case '<':
|
|
99
|
+
return [{ op: operator, version: partial }];
|
|
100
|
+
case '':
|
|
101
|
+
case '=':
|
|
102
|
+
if (partial.parts === 3)
|
|
103
|
+
return [{ op: '=', version: partial }];
|
|
104
|
+
if (partial.parts === 2)
|
|
105
|
+
return [{ op: '>=', version: partial }, { op: '<', version: tuple(partial.major, partial.minor + 1, 0) }];
|
|
106
|
+
return [{ op: '>=', version: partial }, { op: '<', version: tuple(partial.major + 1, 0, 0) }];
|
|
107
|
+
case '^': {
|
|
108
|
+
const upper = partial.major > 0 || partial.parts === 1
|
|
109
|
+
? tuple(partial.major + 1, 0, 0)
|
|
110
|
+
: partial.minor > 0 || partial.parts === 2
|
|
111
|
+
? tuple(0, partial.minor + 1, 0)
|
|
112
|
+
: tuple(0, 0, partial.patch + 1);
|
|
113
|
+
return [{ op: '>=', version: partial }, { op: '<', version: upper }];
|
|
114
|
+
}
|
|
115
|
+
case '~': {
|
|
116
|
+
const upper = partial.parts === 1 ? tuple(partial.major + 1, 0, 0) : tuple(partial.major, partial.minor + 1, 0);
|
|
117
|
+
return [{ op: '>=', version: partial }, { op: '<', version: upper }];
|
|
118
|
+
}
|
|
119
|
+
default:
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function matchesComparator(version, comparator) {
|
|
124
|
+
const order = compare(version, comparator.version);
|
|
125
|
+
switch (comparator.op) {
|
|
126
|
+
case '=':
|
|
127
|
+
return order === 0;
|
|
128
|
+
case '>':
|
|
129
|
+
return order > 0;
|
|
130
|
+
case '>=':
|
|
131
|
+
return order >= 0;
|
|
132
|
+
case '<':
|
|
133
|
+
return order < 0;
|
|
134
|
+
case '<=':
|
|
135
|
+
return order <= 0;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Does `parsed` satisfy `range`? Unsupported tokens answer `false`.
|
|
140
|
+
* A prerelease only matches a comparator naming a prerelease of the same tuple.
|
|
141
|
+
*/
|
|
142
|
+
function satisfies(parsed, range) {
|
|
143
|
+
const text = range.trim();
|
|
144
|
+
if (text === '')
|
|
145
|
+
return false;
|
|
146
|
+
if (text === '*')
|
|
147
|
+
return true;
|
|
148
|
+
return text.split('||').some(branch => {
|
|
149
|
+
const tokens = branch.trim().split(/[\s,]+/).filter(token => token !== '');
|
|
150
|
+
if (tokens.length === 0)
|
|
151
|
+
return false;
|
|
152
|
+
const comparators = [];
|
|
153
|
+
for (const token of tokens) {
|
|
154
|
+
const expanded = comparatorsOf(token);
|
|
155
|
+
if (expanded === undefined)
|
|
156
|
+
return false;
|
|
157
|
+
comparators.push(...expanded);
|
|
158
|
+
}
|
|
159
|
+
if (!comparators.every(comparator => matchesComparator(parsed, comparator)))
|
|
160
|
+
return false;
|
|
161
|
+
if (parsed.pre.length === 0)
|
|
162
|
+
return true;
|
|
163
|
+
return comparators.some(comparator => comparator.version.pre.length > 0 &&
|
|
164
|
+
comparator.version.major === parsed.major &&
|
|
165
|
+
comparator.version.minor === parsed.minor &&
|
|
166
|
+
comparator.version.patch === parsed.patch);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/** Does `version` fall inside the `supported` interval? */
|
|
170
|
+
function withinSupported(version, supported) {
|
|
171
|
+
const parsed = parseVersion(version);
|
|
172
|
+
return parsed !== undefined && satisfies(parsed, supported);
|
|
173
|
+
}
|
|
174
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
175
|
+
// Resolution
|
|
176
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
177
|
+
/** Read `<dir>/package.json` as an object, or `undefined`. */
|
|
178
|
+
async function readManifest(dir) {
|
|
179
|
+
try {
|
|
180
|
+
const parsed = JSON.parse(await fsp.readFile(join(dir, 'package.json'), 'utf8'));
|
|
181
|
+
return typeof parsed === 'object' && parsed !== null ? parsed : undefined;
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/** The entry file a `package.json` points at (`.` export → `main` → `index.js`). */
|
|
188
|
+
function entryOf(dir, manifest) {
|
|
189
|
+
const exported = manifest['exports'];
|
|
190
|
+
let relative;
|
|
191
|
+
if (typeof exported === 'string')
|
|
192
|
+
relative = exported;
|
|
193
|
+
else if (typeof exported === 'object' && exported !== null) {
|
|
194
|
+
const dot = exported['.'] ?? exported;
|
|
195
|
+
if (typeof dot === 'string')
|
|
196
|
+
relative = dot;
|
|
197
|
+
else if (typeof dot === 'object' && dot !== null) {
|
|
198
|
+
const conditions = dot;
|
|
199
|
+
for (const key of ['import', 'default', 'require']) {
|
|
200
|
+
const value = conditions[key];
|
|
201
|
+
if (typeof value === 'string') {
|
|
202
|
+
relative = value;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (relative === undefined && typeof manifest['main'] === 'string')
|
|
209
|
+
relative = manifest['main'];
|
|
210
|
+
return join(dir, relative ?? 'index.js');
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Report the framework copy this caller's tree resolves to, or `undefined` with a warning.
|
|
214
|
+
* Never throws and never installs anything.
|
|
215
|
+
*
|
|
216
|
+
* @param options - the logger and an optional interval override.
|
|
217
|
+
* @returns the located copy, or `undefined` when it is absent or outside the interval.
|
|
218
|
+
*/
|
|
219
|
+
export async function ensureFramework(options) {
|
|
220
|
+
const warn = (message) => {
|
|
221
|
+
try {
|
|
222
|
+
options.logger?.warn(`bootstrap: ${message}`);
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
// The warning is best-effort.
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
try {
|
|
229
|
+
if (options.supportedRange !== undefined && typeof options.supportedRange !== 'string') {
|
|
230
|
+
warn(`supportedRange must be a string; got ${typeof options.supportedRange}`);
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
const supported = options.supportedRange ?? supportedRange;
|
|
234
|
+
let dir;
|
|
235
|
+
try {
|
|
236
|
+
dir = dirname(createRequire(import.meta.url).resolve(`${PACKAGE}/package.json`));
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
warn(`${PACKAGE} is not installed for this plugin — install it with the package manager (pnpm install)`);
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
const manifest = await readManifest(dir);
|
|
243
|
+
const version = typeof manifest?.['version'] === 'string' ? manifest['version'] : undefined;
|
|
244
|
+
if (manifest === undefined || version === undefined) {
|
|
245
|
+
warn(`${join(dir, 'package.json')} is missing or has no version`);
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
if (!withinSupported(version, supported)) {
|
|
249
|
+
warn(`the installed ${PACKAGE}@${version} is outside supportedRange "${supported}"; install a supported version`);
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
return { url: pathToFileURL(entryOf(dir, manifest)).href, version, dir, source: 'resolved' };
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
warn(`unexpected failure: ${error instanceof Error ? error.message : String(error)}`);
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/** `ensureFramework` + a dynamic `import()` of the located module; never throws. */
|
|
260
|
+
export async function loadFramework(options) {
|
|
261
|
+
try {
|
|
262
|
+
const location = await ensureFramework(options);
|
|
263
|
+
if (location === undefined)
|
|
264
|
+
return undefined;
|
|
265
|
+
return (await import(location.url));
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
try {
|
|
269
|
+
options.logger?.warn(`bootstrap: could not load ${PACKAGE}: ${error instanceof Error ? error.message : String(error)}`);
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
// best-effort
|
|
273
|
+
}
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Read the range a plugin declares in the nearest `package.json`: walk up from `from`,
|
|
279
|
+
* preferring `peerDependencies` over `devDependencies`; `undefined` when none is found.
|
|
280
|
+
*/
|
|
281
|
+
export async function readDependencyRange(from = process.cwd()) {
|
|
282
|
+
let current = from;
|
|
283
|
+
if (from.startsWith('file:')) {
|
|
284
|
+
try {
|
|
285
|
+
current = fileURLToPath(from);
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
// A malformed `file:` URL yields no range.
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
try {
|
|
293
|
+
const info = await fsp.stat(current);
|
|
294
|
+
if (info.isFile())
|
|
295
|
+
current = dirname(current);
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
// Not an existing path: treat it as a starting directory and walk up from its parent.
|
|
299
|
+
const parent = dirname(current);
|
|
300
|
+
if (parent !== current)
|
|
301
|
+
current = parent;
|
|
302
|
+
}
|
|
303
|
+
for (;;) {
|
|
304
|
+
const manifestPath = join(current, 'package.json');
|
|
305
|
+
let text;
|
|
306
|
+
try {
|
|
307
|
+
text = await fsp.readFile(manifestPath, 'utf8');
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
const parent = dirname(current);
|
|
311
|
+
if (parent === current)
|
|
312
|
+
return undefined;
|
|
313
|
+
current = parent;
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
try {
|
|
317
|
+
const parsed = JSON.parse(text);
|
|
318
|
+
if (typeof parsed !== 'object' || parsed === null)
|
|
319
|
+
return undefined;
|
|
320
|
+
const manifest = parsed;
|
|
321
|
+
return rangeOf(manifest['peerDependencies']) ?? rangeOf(manifest['devDependencies']);
|
|
322
|
+
}
|
|
323
|
+
catch {
|
|
324
|
+
// The nearest manifest is unparseable: stop.
|
|
325
|
+
return undefined;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function rangeOf(value) {
|
|
330
|
+
if (typeof value !== 'object' || value === null)
|
|
331
|
+
return undefined;
|
|
332
|
+
const range = value[PACKAGE];
|
|
333
|
+
return typeof range === 'string' && range.trim() !== '' ? range : undefined;
|
|
334
|
+
}
|