@xmoon76/dsh-pi-tui 0.5.3 → 0.5.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/README.en.md +174 -150
- package/README.md +118 -103
- package/cordis.patch.yml +54 -2
- package/dist/builtins.mjs +2 -2
- package/dist/client-bootstrap-F5DHFI9t.mjs +5576 -0
- package/dist/context-summary-DAisTA_7.mjs +8557 -0
- package/dist/dispose-cause-CNFuUnjR.mjs +24 -0
- package/dist/entry-control-DvSrndWd.mjs +111 -0
- package/dist/extension/advanced.d.mts +1 -1
- package/dist/extension/unstable.d.mts +1 -1
- package/dist/{extensions-DzpBiiYb.d.mts → extensions-Bte3XOt5.d.mts} +1 -1
- package/dist/{extensions-a-rxanjw.mjs → extensions-CcuMY4n2.mjs} +722 -324
- package/dist/extensions.d.mts +2 -2
- package/dist/extensions.mjs +1 -1
- package/dist/host-bootstrap-DAgKknbY.mjs +119 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +45243 -27018
- package/dist/local-client.mjs +323 -0
- package/dist/local-host.mjs +176 -0
- package/dist/{performance-host-BJT6scGF.mjs → performance-host-CcDJjjVA.mjs} +1 -1
- package/dist/performance-host.mjs +1 -1
- package/dist/{performance-view-jvvd8Jn7.mjs → performance-view-CfGvLZyD.mjs} +1 -1
- package/dist/{public-types-gZi3iFNh.d.mts → public-types-Dgf1bDke.d.mts} +3 -3
- package/dist/runtime-status-0lp9CM0V.mjs +1923 -0
- package/dist/{runtime-BtPH-UUb.mjs → runtime-vc4mdr-R.mjs} +1395 -1088
- package/dist/{session-BZLxhrPQ.mjs → session-tdJHLnJR.mjs} +3329 -281
- package/dist/{startup-D5Xu8diR.mjs → startup-JaVZoTIl.mjs} +54 -13
- package/dist/startup.d.mts +2 -1
- package/dist/startup.mjs +1 -1
- package/dist/{terminal-progress-source-BlmksrSD.mjs → terminal-progress-source-xor3vakJ.mjs} +102 -46
- package/dist/visual-tools.d.mts +62 -0
- package/dist/visual-tools.mjs +556 -0
- package/generated/dsh-presets/README.md +1 -1
- package/package.json +132 -113
- package/dist/context-summary-CxUpNkA9.mjs +0 -2951
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { i as writeEntryRecord, n as createEntryDiag, r as readProcessStartIdentity, t as attachEntryControl } from "./entry-control-DvSrndWd.mjs";
|
|
3
|
+
import { t as mergeCause } from "./dispose-cause-CNFuUnjR.mjs";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { realpathSync } from "node:fs";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
//#region src/runtime/process/errors.ts
|
|
8
|
+
/**
|
|
9
|
+
* Shared, TOTAL error-observation helpers for every async boundary in the
|
|
10
|
+
* TUI: the owned/detached entries (`tasks.ts`), the lifecycle roots
|
|
11
|
+
* (startup, exit, flush), the per-task callbacks and the diagnostics
|
|
12
|
+
* formatter. One implementation, one behavior — no drift between modules.
|
|
13
|
+
*
|
|
14
|
+
* CONTRACT (deliberately scoped, honestly worded): the SYNC boundary is
|
|
15
|
+
* total — observing any legal JavaScript value (a Proxy with a throwing
|
|
16
|
+
* `getPrototypeOf` trap, a throwing `message` getter, a throwing
|
|
17
|
+
* `toString`/`Symbol.toPrimitive`) can never make THIS code throw or
|
|
18
|
+
* reject; every observation is protected and every fallback is a fixed
|
|
19
|
+
* constant that never touches the value again. What is NOT guaranteed: an
|
|
20
|
+
* observer (getter/trap/coercion) that, WHILE being observed, spawns its
|
|
21
|
+
* OWN detached async work (e.g. `void Promise.reject(...)` inside
|
|
22
|
+
* `toString`) — that rejection belongs to the observer, not to this
|
|
23
|
+
* boundary, and no synchronous try/catch can intercept it. Callers must
|
|
24
|
+
* not describe this module as a strict "any legal value, zero side
|
|
25
|
+
* effects" guarantee.
|
|
26
|
+
* @module @xmoon76/dsh-pi-tui/runtime/process/errors
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Describe an arbitrary thrown value as a string WITHOUT ever throwing:
|
|
30
|
+
* `instanceof`, property reads and coercion are all inside the protection,
|
|
31
|
+
* the fallbacks are FIXED constants that never touch the value again, and
|
|
32
|
+
* a hostile Proxy/getter/`Symbol.toPrimitive` yields a stable placeholder
|
|
33
|
+
* instead of escaping. (Best-effort beyond the sync boundary — see the
|
|
34
|
+
* module contract.)
|
|
35
|
+
*/
|
|
36
|
+
function safeErrorMessage(value) {
|
|
37
|
+
try {
|
|
38
|
+
if (value instanceof Error) try {
|
|
39
|
+
const message = value.message;
|
|
40
|
+
return typeof message === "string" ? message : "<error with non-string message>";
|
|
41
|
+
} catch {
|
|
42
|
+
return "<error with unreadable message>";
|
|
43
|
+
}
|
|
44
|
+
return String(value);
|
|
45
|
+
} catch {
|
|
46
|
+
return "<unprintable error>";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/runtime/process/tasks.ts
|
|
51
|
+
/**
|
|
52
|
+
* Whether an error represents an abort/cancel rather than a real failure.
|
|
53
|
+
* TOTAL over the whole `unknown` domain: every probe (prototype-chain
|
|
54
|
+
* walk, `name`/`code` getters) is inside the protection, and a hostile
|
|
55
|
+
* value that throws while being observed simply classifies as NOT a
|
|
56
|
+
* cancellation — recognizing a cancellation must never mint a new primary
|
|
57
|
+
* error.
|
|
58
|
+
*/
|
|
59
|
+
function isCancellation(error) {
|
|
60
|
+
try {
|
|
61
|
+
if (!(error instanceof Error)) return false;
|
|
62
|
+
return error.name === "AbortError" || error.code === "ABORT_ERR";
|
|
63
|
+
} catch {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Read the live session id for diagnostics WITHOUT ever throwing: a
|
|
68
|
+
* throwing `sessionId()` callback degrades to `undefined` (diagnostics
|
|
69
|
+
* must not crash classification or the final sink). */
|
|
70
|
+
function safeSessionId(options) {
|
|
71
|
+
try {
|
|
72
|
+
return options.sessionId?.();
|
|
73
|
+
} catch {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Invoke the task factory SYNCHRONOUSLY (an ownership action inside the
|
|
79
|
+
* factory — a stop, a latch, a spawn — must take effect before the helper
|
|
80
|
+
* returns, so two calls in one input batch cannot both start), and convert
|
|
81
|
+
* a synchronous throw into a rejected promise so it classifies exactly like
|
|
82
|
+
* a rejection.
|
|
83
|
+
*/
|
|
84
|
+
function invokeTask(task) {
|
|
85
|
+
try {
|
|
86
|
+
return Promise.resolve(task());
|
|
87
|
+
} catch (error) {
|
|
88
|
+
return Promise.reject(error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Attach rejection handling to a fire-and-forget task. The factory is
|
|
93
|
+
* invoked synchronously (a synchronous throw is a rejection like any
|
|
94
|
+
* other); every rejection is caught and classified:
|
|
95
|
+
* - cancellation → debug diagnostics only (never a user error);
|
|
96
|
+
* - recoverable (per the options hook) → notify + warn;
|
|
97
|
+
* - anything else → warn.
|
|
98
|
+
* The log line carries the task label and the live session id — never the
|
|
99
|
+
* task payload (no API keys, prompt bodies, or shell output). A throwing
|
|
100
|
+
* notify/diag/sessionId path cannot escape: it lands in the handler-failure
|
|
101
|
+
* sink, which is itself total over the `unknown` domain.
|
|
102
|
+
*/
|
|
103
|
+
function runDetached(label, task, options) {
|
|
104
|
+
invokeTask(task).catch((error) => {
|
|
105
|
+
if (isCancellation(error)) {
|
|
106
|
+
options.diag.debug(label, {
|
|
107
|
+
session: safeSessionId(options),
|
|
108
|
+
cancelled: true
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const message = safeErrorMessage(error);
|
|
113
|
+
options.diag.warn(label, {
|
|
114
|
+
session: safeSessionId(options),
|
|
115
|
+
error: message
|
|
116
|
+
});
|
|
117
|
+
if (options.recoverable?.(error) === true) options.notify?.(`${label}: ${message}`);
|
|
118
|
+
}).catch(handlerFailure(label, options));
|
|
119
|
+
}
|
|
120
|
+
/** Identity registry for the internal wrappers: `WeakSet.has` compares by
|
|
121
|
+
* identity and never walks the argument's prototype chain, so a hostile
|
|
122
|
+
* thrown value (a Proxy with a throwing `getPrototypeOf` trap) can be
|
|
123
|
+
* tested safely — `instanceof HandlerFailure` on an untrusted value could
|
|
124
|
+
* itself throw. */
|
|
125
|
+
const handlerFailures = /* @__PURE__ */ new WeakSet();
|
|
126
|
+
/** Whether a value is one of OUR wrapper instances (identity only; total
|
|
127
|
+
* over the whole `unknown` domain). */
|
|
128
|
+
function isHandlerFailure(value) {
|
|
129
|
+
return typeof value === "object" && value !== null && handlerFailures.has(value);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The final sink of both helpers: a terminal side-effect handler
|
|
133
|
+
* (onResult's own invocation aside — see {@link runOwned}), a task-local
|
|
134
|
+
* classifier, or the diagnostics channel itself threw. The ENTIRE body is
|
|
135
|
+
* protected — wrapper unwrapping, error description, the session read and
|
|
136
|
+
* the diag call all live inside the try, and the fallback is a fixed
|
|
137
|
+
* constant that never touches the hostile value again — so the sink is a
|
|
138
|
+
* total function over the `unknown` domain: it can NEVER reject, and there
|
|
139
|
+
* is no lower sink to leak into.
|
|
140
|
+
*/
|
|
141
|
+
function handlerFailure(label, options) {
|
|
142
|
+
return (error) => {
|
|
143
|
+
try {
|
|
144
|
+
const cause = isHandlerFailure(error) ? error.cause : error;
|
|
145
|
+
options.diag.error(`${label} handler failed`, {
|
|
146
|
+
session: safeSessionId(options),
|
|
147
|
+
error: safeErrorMessage(cause)
|
|
148
|
+
});
|
|
149
|
+
} catch {}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/app/remote-process/local-client-entry.ts
|
|
154
|
+
/**
|
|
155
|
+
* M4-A0 Client-only process entry.
|
|
156
|
+
*
|
|
157
|
+
* The Client PID owns a real Cordis root and mounts only the Client-local
|
|
158
|
+
* subtree (TUI startup facts, extension host, first-party builtins). It never
|
|
159
|
+
* imports the Host runtime, the in-process carrier, or the application
|
|
160
|
+
* aggregate, and it reports `transport: not-connected` until M4-B1 supplies
|
|
161
|
+
* the official authenticated Connection.
|
|
162
|
+
*
|
|
163
|
+
* The launcher supplies the DSH installation anchor and profile name through
|
|
164
|
+
* `SPLIT_PROCESS_DSH_ANCHOR` / `SPLIT_PROCESS_PROFILE` so this process can install the same official
|
|
165
|
+
* package-resolution interception the dsh launcher uses. The package's own
|
|
166
|
+
* `dist/` location stays the installation point — no repository source path or
|
|
167
|
+
* tsx loader is involved.
|
|
168
|
+
*
|
|
169
|
+
* @module app/remote-process/local-client-entry
|
|
170
|
+
*/
|
|
171
|
+
/** Load the published DSH modules this entry needs, from the installation anchor. */
|
|
172
|
+
async function loadOfficialClientHost(anchor) {
|
|
173
|
+
const requireFromDsh = createRequire(realpathSync(anchor));
|
|
174
|
+
const importResolved = async (specifier) => import(pathToFileURL(requireFromDsh.resolve(specifier)).href);
|
|
175
|
+
const appBoot = await importResolved("@deepseek-ai/dsh-app-boot");
|
|
176
|
+
return {
|
|
177
|
+
Context: (await importResolved("@deepseek-ai/cordis")).Context,
|
|
178
|
+
PluginPackages: appBoot.PluginPackages,
|
|
179
|
+
loadProfile: appBoot.loadProfile,
|
|
180
|
+
createRuntimeResolution: appBoot.createRuntimeResolution
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Run one Client-only process until its launcher requests shutdown. Exported
|
|
185
|
+
* for the qualification harness; `import.meta.main` is the only production
|
|
186
|
+
* caller.
|
|
187
|
+
*/
|
|
188
|
+
async function runLocalClientEntry(options) {
|
|
189
|
+
const host = await loadOfficialClientHost(options.dshAnchor);
|
|
190
|
+
const loadedProfile = host.loadProfile("split-process-client", options.profile, options.dshAnchor);
|
|
191
|
+
const resolution = await host.createRuntimeResolution({
|
|
192
|
+
installAnchor: options.dshAnchor,
|
|
193
|
+
profile: loadedProfile
|
|
194
|
+
});
|
|
195
|
+
const context = new host.Context();
|
|
196
|
+
let handle;
|
|
197
|
+
try {
|
|
198
|
+
await context.plugin(host.PluginPackages, { resolution });
|
|
199
|
+
writeEntryRecord({
|
|
200
|
+
m4a0: "context-ready",
|
|
201
|
+
processRole: "client",
|
|
202
|
+
pid: process.pid,
|
|
203
|
+
phase: "context-ready"
|
|
204
|
+
});
|
|
205
|
+
const { startLocalClient } = await import("./client-bootstrap-F5DHFI9t.mjs");
|
|
206
|
+
handle = await startLocalClient(context, {}, readProcessStartIdentity());
|
|
207
|
+
writeEntryRecord({
|
|
208
|
+
m4a0: "ready",
|
|
209
|
+
...handle.status
|
|
210
|
+
});
|
|
211
|
+
let stopping = false;
|
|
212
|
+
const stop = async (code) => {
|
|
213
|
+
if (stopping) return;
|
|
214
|
+
stopping = true;
|
|
215
|
+
if (handle === void 0) {
|
|
216
|
+
process.exit(code);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
process.exit(await stopLocalClient(handle, code));
|
|
220
|
+
};
|
|
221
|
+
const diag = createEntryDiag("client");
|
|
222
|
+
process.on("SIGTERM", () => {
|
|
223
|
+
runDetached("local client: SIGTERM shutdown", () => stop(0), { diag });
|
|
224
|
+
});
|
|
225
|
+
process.on("SIGINT", () => {
|
|
226
|
+
runDetached("local client: SIGINT shutdown", () => stop(130), { diag });
|
|
227
|
+
});
|
|
228
|
+
attachEntryControl(async (request) => {
|
|
229
|
+
if (request.op === "status") {
|
|
230
|
+
writeEntryRecord({
|
|
231
|
+
m4a0: "status",
|
|
232
|
+
...request.requestId === void 0 ? {} : { requestId: request.requestId },
|
|
233
|
+
...handle.status
|
|
234
|
+
});
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
if (request.op === "shutdown") {
|
|
238
|
+
await stop(0);
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
writeEntryRecord({
|
|
242
|
+
m4a0: "control-error",
|
|
243
|
+
error: `local client entry: unknown op ${JSON.stringify(request.op)}`
|
|
244
|
+
});
|
|
245
|
+
return false;
|
|
246
|
+
});
|
|
247
|
+
} catch (error) {
|
|
248
|
+
let primary = error instanceof Error ? error : new Error(String(error));
|
|
249
|
+
if (handle !== void 0) try {
|
|
250
|
+
await handle.dispose();
|
|
251
|
+
} catch (cleanupError) {
|
|
252
|
+
primary = mergeCause(primary, cleanupError);
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
await context.fiber.dispose();
|
|
256
|
+
} catch (cleanupError) {
|
|
257
|
+
primary = mergeCause(primary, cleanupError);
|
|
258
|
+
}
|
|
259
|
+
writeEntryRecord({
|
|
260
|
+
m4a0: "failure",
|
|
261
|
+
processRole: "client",
|
|
262
|
+
phase: "after-context",
|
|
263
|
+
pid: process.pid,
|
|
264
|
+
error: primary.message,
|
|
265
|
+
...primary.stack === void 0 ? {} : { stack: primary.stack },
|
|
266
|
+
...primary.cause === void 0 ? {} : { cause: primary.cause instanceof Error ? primary.cause.message : String(primary.cause) }
|
|
267
|
+
});
|
|
268
|
+
writeEntryRecord({
|
|
269
|
+
m4a0: "cleanup",
|
|
270
|
+
processRole: "client",
|
|
271
|
+
phase: "after-context",
|
|
272
|
+
pid: process.pid,
|
|
273
|
+
status: "completed"
|
|
274
|
+
});
|
|
275
|
+
process.exitCode = 1;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Dispose the Client-owned root and classify a rejecting disposer as a real
|
|
280
|
+
* cleanup failure. The requested success code becomes 1; an interrupt/signal
|
|
281
|
+
* code keeps its nonzero identity. Never returns the success code after a
|
|
282
|
+
* failed dispose, and a second stop call is prevented by the caller's latch.
|
|
283
|
+
*/
|
|
284
|
+
async function stopLocalClient(handle, requestedCode, emit = writeEntryRecord) {
|
|
285
|
+
try {
|
|
286
|
+
await handle.dispose();
|
|
287
|
+
return requestedCode;
|
|
288
|
+
} catch (error) {
|
|
289
|
+
emit({
|
|
290
|
+
m4a0: "cleanup-failure",
|
|
291
|
+
processRole: "client",
|
|
292
|
+
phase: "shutdown",
|
|
293
|
+
pid: process.pid,
|
|
294
|
+
error: error instanceof Error ? error.message : String(error),
|
|
295
|
+
...error instanceof Error && error.stack !== void 0 ? { stack: error.stack } : {}
|
|
296
|
+
});
|
|
297
|
+
return requestedCode === 0 ? 1 : requestedCode;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/** Read the launcher environment; a missing anchor is a hard startup failure. */
|
|
301
|
+
function optionsFromEnvironment() {
|
|
302
|
+
const dshAnchor = process.env.SPLIT_PROCESS_DSH_ANCHOR;
|
|
303
|
+
if (dshAnchor === void 0 || dshAnchor === "") throw new Error("local client entry: SPLIT_PROCESS_DSH_ANCHOR must name the installed @deepseek-ai/dsh/package.json");
|
|
304
|
+
return {
|
|
305
|
+
dshAnchor,
|
|
306
|
+
profile: process.env.SPLIT_PROCESS_PROFILE ?? "pi-tui"
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
if (import.meta.main) try {
|
|
310
|
+
await runLocalClientEntry(optionsFromEnvironment());
|
|
311
|
+
} catch (error) {
|
|
312
|
+
writeEntryRecord({
|
|
313
|
+
m4a0: "failure",
|
|
314
|
+
processRole: "client",
|
|
315
|
+
phase: "startup",
|
|
316
|
+
pid: process.pid,
|
|
317
|
+
error: error instanceof Error ? error.message : String(error),
|
|
318
|
+
...error instanceof Error && error.stack !== void 0 ? { stack: error.stack } : {}
|
|
319
|
+
});
|
|
320
|
+
process.exit(1);
|
|
321
|
+
}
|
|
322
|
+
//#endregion
|
|
323
|
+
export { runLocalClientEntry, stopLocalClient };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { i as writeEntryRecord, r as readProcessStartIdentity, t as attachEntryControl } from "./entry-control-DvSrndWd.mjs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { mkdirSync, mkdtempSync, realpathSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
//#region src/app/remote-process/local-host-entry.ts
|
|
9
|
+
/**
|
|
10
|
+
* M4-A0 Host-only process entry.
|
|
11
|
+
*
|
|
12
|
+
* Boots the ordinary DSH profile through the real launcher owner
|
|
13
|
+
* (`@deepseek-ai/dsh/profile-boot` → `@deepseek-ai/dsh-app-boot` → Loader /
|
|
14
|
+
* Include) rather than a hand-built Context. The launcher-owned Host-only
|
|
15
|
+
* overlay disables exactly the TUI runner and the Client extension host /
|
|
16
|
+
* builtins; every Host-plane row (including `tuiStartup`-gated workspace files,
|
|
17
|
+
* the loopback webserver and the performance projection) keeps its production
|
|
18
|
+
* source.
|
|
19
|
+
*
|
|
20
|
+
* The entry is an internal qualification artifact, not a package export or a
|
|
21
|
+
* CLI command: the launcher supplies the DSH installation anchor, profile name
|
|
22
|
+
* and scratch directory through `SPLIT_PROCESS_DSH_ANCHOR` / `SPLIT_PROCESS_PROFILE` / `SPLIT_PROCESS_SCRATCH`.
|
|
23
|
+
*
|
|
24
|
+
* @module app/remote-process/local-host-entry
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* The Host-only overlay applied over the profile's own patch stack. It keeps
|
|
28
|
+
* `tui-startup` mounted (the Host rows gated on `tuiStartup` need its parsed
|
|
29
|
+
* facts) and disables only the three surface rows that must not exist in a
|
|
30
|
+
* Host-only PID.
|
|
31
|
+
*/
|
|
32
|
+
const HOST_ONLY_PATCH = `# M4-A0 Host-only profile overlay: production Host rows only.
|
|
33
|
+
- id: tui-app
|
|
34
|
+
disabled: true
|
|
35
|
+
- id: pi-tui-extension-host
|
|
36
|
+
disabled: true
|
|
37
|
+
- id: pi-tui-builtins
|
|
38
|
+
disabled: true
|
|
39
|
+
`;
|
|
40
|
+
/** Resolve one published DSH subpath from the installation anchor supplied by the launcher. */
|
|
41
|
+
async function loadOfficialDsh(anchor) {
|
|
42
|
+
const requireFromDsh = createRequire(realpathSync(anchor));
|
|
43
|
+
const importResolved = async (specifier) => import(pathToFileURL(requireFromDsh.resolve(specifier)).href);
|
|
44
|
+
const profileBoot = await importResolved("@deepseek-ai/dsh/profile-boot");
|
|
45
|
+
const appBoot = await importResolved("@deepseek-ai/dsh-app-boot");
|
|
46
|
+
return {
|
|
47
|
+
runProfile: profileBoot.runProfile,
|
|
48
|
+
loadLayeredEnv: appBoot.loadLayeredEnv
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Run one Host-only process until its launcher requests shutdown. Exported so
|
|
53
|
+
* the process-level qualification harness can document its exact contract; the
|
|
54
|
+
* module's `import.meta.main` block is the only caller in production.
|
|
55
|
+
*/
|
|
56
|
+
async function runLocalHostEntry(options) {
|
|
57
|
+
const { dshAnchor, profile, scratchDir } = options;
|
|
58
|
+
mkdirSync(scratchDir, { recursive: true });
|
|
59
|
+
const overlayPath = join(scratchDir, "host-only.patch.yml");
|
|
60
|
+
writeFileSync(overlayPath, HOST_ONLY_PATCH);
|
|
61
|
+
const dsh = await loadOfficialDsh(dshAnchor);
|
|
62
|
+
const processStartIdentity = readProcessStartIdentity();
|
|
63
|
+
process.env.DSH_PI_TUI_ROLE = "host";
|
|
64
|
+
if (process.argv[1] !== void 0) process.env.DSH_PI_TUI_HOST_ENTRY = realpathSync(process.argv[1]);
|
|
65
|
+
const handle = await dsh.runProfile({
|
|
66
|
+
environment: dsh.loadLayeredEnv("dsh", process.cwd()),
|
|
67
|
+
profile,
|
|
68
|
+
patchFiles: [overlayPath, ...options.extraPatchFiles ?? []],
|
|
69
|
+
args: []
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
writeEntryRecord({
|
|
73
|
+
m4a0: "profile-booted",
|
|
74
|
+
processRole: "host",
|
|
75
|
+
pid: process.pid,
|
|
76
|
+
phase: "profile-booted"
|
|
77
|
+
});
|
|
78
|
+
const { settleHostEntries, collectHostEntryStatus } = await import("./host-bootstrap-DAgKknbY.mjs");
|
|
79
|
+
await settleHostEntries(handle.ctx);
|
|
80
|
+
const status = collectHostEntryStatus(handle.ctx, {
|
|
81
|
+
profile,
|
|
82
|
+
processStartIdentity
|
|
83
|
+
});
|
|
84
|
+
writeEntryRecord({
|
|
85
|
+
m4a0: "ready",
|
|
86
|
+
...status
|
|
87
|
+
});
|
|
88
|
+
attachEntryControl(async (request) => {
|
|
89
|
+
if (request.op === "status") {
|
|
90
|
+
writeEntryRecord({
|
|
91
|
+
m4a0: "status",
|
|
92
|
+
...request.requestId === void 0 ? {} : { requestId: request.requestId },
|
|
93
|
+
...collectHostEntryStatus(handle.ctx, {
|
|
94
|
+
profile,
|
|
95
|
+
processStartIdentity
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
if (request.op === "shutdown") {
|
|
101
|
+
await handle.shutdown.shutdown(0);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
writeEntryRecord({
|
|
105
|
+
m4a0: "control-error",
|
|
106
|
+
error: `local host entry: unknown op ${JSON.stringify(request.op)}`
|
|
107
|
+
});
|
|
108
|
+
return false;
|
|
109
|
+
});
|
|
110
|
+
} catch (error) {
|
|
111
|
+
writeEntryRecord({
|
|
112
|
+
m4a0: "failure",
|
|
113
|
+
processRole: "host",
|
|
114
|
+
phase: "after-boot",
|
|
115
|
+
pid: process.pid,
|
|
116
|
+
error: error instanceof Error ? error.message : String(error),
|
|
117
|
+
...error instanceof Error && error.stack !== void 0 ? { stack: error.stack } : {}
|
|
118
|
+
});
|
|
119
|
+
await finishHostFailureCleanup(handle.shutdown);
|
|
120
|
+
process.exitCode = 1;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Finish one failed Host startup with the launcher's official shutdown owner.
|
|
125
|
+
* A successful disposal emits exactly one `cleanup: completed`; a rejecting
|
|
126
|
+
* disposal emits one `cleanup-failure` and NEVER a completed record. Exported
|
|
127
|
+
* for the review-fix negative control.
|
|
128
|
+
*/
|
|
129
|
+
async function finishHostFailureCleanup(shutdownOwner, emit = writeEntryRecord) {
|
|
130
|
+
try {
|
|
131
|
+
await shutdownOwner.shutdown(1);
|
|
132
|
+
emit({
|
|
133
|
+
m4a0: "cleanup",
|
|
134
|
+
processRole: "host",
|
|
135
|
+
phase: "after-boot",
|
|
136
|
+
pid: process.pid,
|
|
137
|
+
status: "completed"
|
|
138
|
+
});
|
|
139
|
+
return true;
|
|
140
|
+
} catch (cleanupError) {
|
|
141
|
+
emit({
|
|
142
|
+
m4a0: "cleanup-failure",
|
|
143
|
+
processRole: "host",
|
|
144
|
+
phase: "after-boot",
|
|
145
|
+
pid: process.pid,
|
|
146
|
+
error: cleanupError instanceof Error ? cleanupError.message : String(cleanupError)
|
|
147
|
+
});
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** Read the launcher environment; a missing anchor is a hard startup failure. */
|
|
152
|
+
function optionsFromEnvironment() {
|
|
153
|
+
const dshAnchor = process.env.SPLIT_PROCESS_DSH_ANCHOR;
|
|
154
|
+
if (dshAnchor === void 0 || dshAnchor === "") throw new Error("local host entry: SPLIT_PROCESS_DSH_ANCHOR must name the installed @deepseek-ai/dsh/package.json");
|
|
155
|
+
return {
|
|
156
|
+
dshAnchor,
|
|
157
|
+
profile: process.env.SPLIT_PROCESS_PROFILE ?? "pi-tui",
|
|
158
|
+
scratchDir: process.env.SPLIT_PROCESS_SCRATCH ?? mkdtempSync(join(tmpdir(), "split-process-host-")),
|
|
159
|
+
...process.env.SPLIT_PROCESS_EXTRA_PATCH === void 0 || process.env.SPLIT_PROCESS_EXTRA_PATCH === "" ? {} : { extraPatchFiles: [process.env.SPLIT_PROCESS_EXTRA_PATCH] }
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
if (import.meta.main) try {
|
|
163
|
+
await runLocalHostEntry(optionsFromEnvironment());
|
|
164
|
+
} catch (error) {
|
|
165
|
+
writeEntryRecord({
|
|
166
|
+
m4a0: "failure",
|
|
167
|
+
processRole: "host",
|
|
168
|
+
phase: "startup",
|
|
169
|
+
pid: process.pid,
|
|
170
|
+
error: error instanceof Error ? error.message : String(error),
|
|
171
|
+
...error instanceof Error && error.stack !== void 0 ? { stack: error.stack } : {}
|
|
172
|
+
});
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
export { HOST_ONLY_PATCH, finishHostFailureCleanup, runLocalHostEntry };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
-
import { a as firstTokenTimeFromAssistantStream, c as usageFromAssistantSettlement, r as emptyPerformanceView, t as PI_TUI_PERFORMANCE_KEY } from "./performance-view-
|
|
2
|
+
import { a as firstTokenTimeFromAssistantStream, c as usageFromAssistantSettlement, r as emptyPerformanceView, t as PI_TUI_PERFORMANCE_KEY } from "./performance-view-CfGvLZyD.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/app/host/performance-projection.ts
|
|
5
5
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as name, n as apply, r as inject, t as PI_TUI_PERFORMANCE_READY_SERVICE } from "./performance-host-
|
|
1
|
+
import { i as name, n as apply, r as inject, t as PI_TUI_PERFORMANCE_READY_SERVICE } from "./performance-host-CcDJjjVA.mjs";
|
|
2
2
|
export { PI_TUI_PERFORMANCE_READY_SERVICE, apply, inject, name };
|
|
@@ -403,7 +403,7 @@ var StepUsageAccumulator = class {
|
|
|
403
403
|
* weighted rate, and the display precision policy: it never selects a route,
|
|
404
404
|
* folds an event, reads a Session, or holds a sample ring. The Host reducer
|
|
405
405
|
* (`src/app/host/performance-projection.ts`) owns every sample; the Direct /
|
|
406
|
-
* Remote carriers,
|
|
406
|
+
* Remote carriers, the About report, and the footer all read this one contract.
|
|
407
407
|
*
|
|
408
408
|
* @module @xmoon76/dsh-pi-tui/domain/status/performance-view
|
|
409
409
|
*/
|
|
@@ -114,7 +114,7 @@ interface RegistrationSpec {
|
|
|
114
114
|
readonly order?: number;
|
|
115
115
|
/** Winner selection for `single` slots: lowest `priority` wins. */
|
|
116
116
|
readonly priority?: number;
|
|
117
|
-
/** Human-readable description for diagnostics
|
|
117
|
+
/** Human-readable description for diagnostics output. */
|
|
118
118
|
readonly description?: string;
|
|
119
119
|
}
|
|
120
120
|
/** Live control of one registered contribution. */
|
|
@@ -152,7 +152,7 @@ interface ContributionRecord<T> {
|
|
|
152
152
|
/** The live contribution value. */
|
|
153
153
|
readonly value: T;
|
|
154
154
|
}
|
|
155
|
-
/** Health state of one contribution (
|
|
155
|
+
/** Health state of one contribution (Plugin Manager diagnostics). */
|
|
156
156
|
type ContributionState = 'active' | 'shadowed' | 'failed' | 'disposed';
|
|
157
157
|
/** Diagnostic health record for one contribution (M1: recorded, surfaced later). */
|
|
158
158
|
interface ContributionHealth {
|
|
@@ -544,7 +544,7 @@ interface TuiCommandBridgeView {
|
|
|
544
544
|
* P2: a bare name shared the custom-FILE namespace, so a persisted value's
|
|
545
545
|
* meaning depended on which source existed). */
|
|
546
546
|
interface TuiThemeRegistryView {
|
|
547
|
-
/** The display names (diagnostics
|
|
547
|
+
/** The display names (diagnostics counts only). */
|
|
548
548
|
names(): string[];
|
|
549
549
|
/** DEPRECATED (still functional for the current API version — removal
|
|
550
550
|
* requires the next breaking API version): the palette behind a bare
|