@xmoon76/dsh-pi-tui 0.5.6 → 0.5.8
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 +33 -0
- package/README.en.md +103 -814
- package/README.md +102 -711
- package/cordis.patch.yml +186 -0
- package/dist/acp-preferences.d.mts +29 -0
- package/dist/acp-preferences.mjs +15 -0
- package/dist/{bootstrap-DQ4YPL-7.mjs → bootstrap-CMIjGyuk.mjs} +33515 -7587
- package/dist/builtins.mjs +3 -3
- package/dist/{client-bootstrap-Cr1JCaF5.mjs → client-bootstrap-BjGPc-DM.mjs} +4637 -492
- package/dist/client-extension-loader-probe-BUw7q8bJ.mjs +119 -0
- package/dist/command-trust-DChWUamk.mjs +406 -0
- package/dist/daemon-launcher-Dult7Jxv.mjs +1932 -0
- package/dist/daemon-launcher.d.mts +159 -0
- package/dist/daemon-launcher.mjs +2 -0
- package/dist/diagnostics-D5jwc-q1.d.mts +11 -0
- package/dist/{dist-CIsR7cz4.mjs → dist-BFgC-5tL.mjs} +938 -487
- package/dist/entry-control-DjNsE3I0.mjs +190 -0
- package/dist/extension/advanced.d.mts +1 -1
- package/dist/extension/unstable.d.mts +1 -1
- package/dist/extension-config-probe-BDdvutkG.mjs +95 -0
- package/dist/extension-config.d.mts +29 -0
- package/dist/extension-config.mjs +22 -0
- package/dist/{extensions-Bp0L37lP.mjs → extensions-B4uLpSTv.mjs} +1109 -100
- package/dist/{extensions-Bte3XOt5.d.mts → extensions-C8eAM0gX.d.mts} +1 -1
- package/dist/extensions.d.mts +2 -2
- package/dist/extensions.mjs +1 -1
- package/dist/{host-bootstrap-DilsvA6f.mjs → host-bootstrap-MVxks641.mjs} +129 -24
- package/dist/{host-foundation-probe--5jtvHVe.mjs → host-foundation-probe-DMNTmNrH.mjs} +2 -2
- package/dist/host-runtime.d.mts +11 -5
- package/dist/host-runtime.mjs +4171 -920
- package/dist/index.d.mts +86 -174
- package/dist/index.mjs +38087 -9967
- package/dist/local-acp-listener-B65J0Bx4.mjs +3115 -0
- package/dist/local-client.mjs +1158 -59
- package/dist/local-daemon-control-C14q9KnD.mjs +1588 -0
- package/dist/local-daemon-control-TCnERL7n.mjs +1424 -0
- package/dist/local-discovery-DOSsCh9q.mjs +2883 -0
- package/dist/local-discovery-egN4_gsQ.mjs +2 -0
- package/dist/local-discovery-uOBfFq5j.mjs +2764 -0
- package/dist/local-host.mjs +812 -89
- package/dist/local-profile-daemon-admin-BmQSdzT0.mjs +210 -0
- package/dist/local-scope-DamiMqPd.mjs +1340 -0
- package/dist/{local-transport-BVwFYq_Y.mjs → local-transport-Iwo0mtu3.mjs} +313 -38
- package/dist/local-web-control-DMrjwCkl.mjs +454 -0
- package/dist/local-workspace-object-D06GL0UO.mjs +248 -0
- package/dist/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
- package/dist/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
- package/dist/open-CmOBxSjN.mjs +63 -0
- package/dist/persisted-setting-probe-DWZLtWoB.mjs +145 -0
- package/dist/pi-tui-acp-access-contract-BdLwduU6.mjs +75 -0
- package/dist/pi-tui-remote-contribution-Do8ECrUy.mjs +1492 -0
- package/dist/pi-tui-terminal-progress-contract-B3RoEzjK.mjs +146 -0
- package/dist/preferences.d.mts +17 -0
- package/dist/preferences.mjs +20 -0
- package/dist/preset-BcWqOtY7.mjs +46 -0
- package/dist/profile-preferences-migration-BfUGdPZx.mjs +500 -0
- package/dist/profile-preferences-migration-CThz4rHH.mjs +2 -0
- package/dist/prompt-sections-DUKmWb8g.mjs +2232 -0
- package/dist/prompt-sections-DXmjB58H.mjs +634 -0
- package/dist/{public-types-Dgf1bDke.d.mts → public-types-C1YgFtwC.d.mts} +56 -3
- package/dist/row-id-DPbyt9Nn.mjs +24 -0
- package/dist/{runtime-status-Cj1nFOdS.mjs → runtime-status-v-FTnWcD.mjs} +49 -3
- package/dist/schema-BTGYn8_X.d.mts +54 -0
- package/dist/schema-qE_P09zJ.mjs +124 -0
- package/dist/{session-BKGXyh80.mjs → session-C6tSs86s.mjs} +9672 -7270
- package/dist/{session-CPt_U8_f.mjs → session-CstInGIA.mjs} +9674 -7273
- package/dist/startup-CarQxWwi.d.mts +213 -0
- package/dist/{startup-7BYWuvBU.mjs → startup-EG5UqIcd.mjs} +341 -26
- package/dist/startup.d.mts +2 -99
- package/dist/startup.mjs +2 -2
- package/dist/{terminal-progress-source-DrqQhtT8.mjs → terminal-progress-source-CpfpQO_h.mjs} +2038 -67
- package/dist/{pasted-path-range-CMnxuGPx.mjs → transcript-view-C1YtJ49Y.mjs} +11590 -6718
- package/dist/{pasted-path-range-r6qzV_tC.mjs → transcript-view-CuJYWkhp.mjs} +12296 -6923
- package/dist/version-B9yC7bBk.mjs +83 -0
- package/dist/visual-tools.d.mts +1 -1
- package/dist/visual-tools.mjs +1 -1
- package/dist/web-preferences.d.mts +1 -1
- package/dist/{web-roster-CjqnUXNk.mjs → web-roster-Dis7BhrA.mjs} +63 -3
- package/generated/dsh-presets/cordis.patch.yml +4 -2
- package/generated/dsh-presets/ptc.patch.yml +4 -0
- package/generated/dsh-presets/standard.patch.yml +7 -0
- package/generated/web-access/cordis.patch.yml +239 -0
- package/package.json +217 -170
- package/dist/entry-control-DnduyDiw.mjs +0 -92
- package/dist/local-discovery-C9VMjc0K.mjs +0 -759
- package/dist/local-discovery-CDaQHA_R.mjs +0 -2
- package/dist/pi-tui-remote-contribution-B0EQsP0N.mjs +0 -85
- package/dist/pi-tui-terminal-progress-contract-CdBH9j78.mjs +0 -70
- package/dist/pi-tui-terminal-progress-contract-MLXZ-i3t.mjs +0 -905
- package/dist/version-a-eF-QER.mjs +0 -80
|
@@ -3,6 +3,7 @@ import { closeSync, mkdirSync, openSync, readFileSync, realpathSync, writeSync }
|
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { basename, dirname, join } from "node:path";
|
|
5
5
|
import { parseCmdline } from "@deepseek-ai/dsh-cmdline";
|
|
6
|
+
import z from "@deepseek-ai/schemastery";
|
|
6
7
|
//#region src/dsh-compat-matrix.json
|
|
7
8
|
var dsh_compat_matrix_default = {
|
|
8
9
|
$comment: [
|
|
@@ -23,8 +24,8 @@ var dsh_compat_matrix_default = {
|
|
|
23
24
|
"package.json's version), the runtime floor it imposes, the recommended published DSH",
|
|
24
25
|
"target and the recovery wording. The floor and the target are distinct values and",
|
|
25
26
|
"must stay independently derived. Consumed by src/startup.ts (inlined by the bundler)",
|
|
26
|
-
"and, through scripts/lib/dsh-compat.mjs, by the release tooling
|
|
27
|
-
"
|
|
27
|
+
"and, through scripts/lib/dsh-compat.mjs, by the release tooling and the",
|
|
28
|
+
"release-notes tests.",
|
|
28
29
|
"package.json restates the newest row's `dshFrom` as `engines.dsh` `>=<dshFrom>`; DSH",
|
|
29
30
|
"prefers that field over the DSH peer ranges and only falls back to the peers when it",
|
|
30
31
|
"is absent, so the peers keep the npm-level fallback in sync with the same floor",
|
|
@@ -33,11 +34,11 @@ var dsh_compat_matrix_default = {
|
|
|
33
34
|
"not by itself qualify every such prerelease."
|
|
34
35
|
],
|
|
35
36
|
current: {
|
|
36
|
-
"since": "0.5.
|
|
37
|
-
"requires": "DeepSeek Harness 0.2.2-rc.
|
|
38
|
-
"upgradeDsh": "0.2.2-rc.
|
|
39
|
-
"upgradeCommand": "npm install -g --allow-scripts=@deepseek-ai/dsh-subprocess-local,koffi,node-pty @deepseek-ai/dsh@0.2.2-rc.
|
|
40
|
-
"guidance": "The 0.5.
|
|
37
|
+
"since": "0.5.8",
|
|
38
|
+
"requires": "DeepSeek Harness 0.2.2-rc.3 or later",
|
|
39
|
+
"upgradeDsh": "0.2.2-rc.5",
|
|
40
|
+
"upgradeCommand": "npm install -g --allow-scripts=@deepseek-ai/dsh-subprocess-local,koffi,node-pty @deepseek-ai/dsh@0.2.2-rc.5",
|
|
41
|
+
"guidance": "The 0.5.8 release requires DeepSeek Harness 0.2.2-rc.3 or later; this checkout validates that runtime floor and targets 0.2.2-rc.5 (validated pairing; on Hosts older than rc.5 the automatic web-search routing decision may differ). The previous 0.2.2-rc.2 and 0.2.2-rc.1 pairings are no longer claimed by this release, so finish in-flight turns and background jobs before upgrading. See README.en.md for the DSH/TUI pairing table, and docs/guides/dsh-compatibility.md for compatibility/recovery rules."
|
|
41
42
|
},
|
|
42
43
|
floor: {
|
|
43
44
|
"below": "0.1.0-rc.8",
|
|
@@ -134,6 +135,19 @@ var dsh_compat_matrix_default = {
|
|
|
134
135
|
"dshFrom": "0.2.2-rc.1",
|
|
135
136
|
"tui": "0.5.6",
|
|
136
137
|
"versions": ["0.2.2-rc.1"]
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"dshFrom": "0.2.2-rc.2",
|
|
141
|
+
"versions": ["0.2.2-rc.2"]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"dshFrom": "0.2.2-rc.3",
|
|
145
|
+
"tui": "0.5.8",
|
|
146
|
+
"versions": [
|
|
147
|
+
"0.2.2-rc.3",
|
|
148
|
+
"0.2.2-rc.4",
|
|
149
|
+
"0.2.2-rc.5"
|
|
150
|
+
]
|
|
137
151
|
}
|
|
138
152
|
]
|
|
139
153
|
};
|
|
@@ -278,15 +292,29 @@ function bundleVersionLabel(since) {
|
|
|
278
292
|
return `>= ${since}`;
|
|
279
293
|
}
|
|
280
294
|
}
|
|
295
|
+
/** The official Profile identity composed by the DSH Profile Loader for this
|
|
296
|
+
* process. Startup messages must name the Profile the user actually launched;
|
|
297
|
+
* the fixed `pi-tui` help examples are not a runtime identity. */
|
|
298
|
+
function runningProfileName(ctx) {
|
|
299
|
+
const name = ctx.get("profileContext")?.name;
|
|
300
|
+
if (typeof name !== "string" || name === "") throw new Error("dsh-pi-tui startup: ctx.profileContext.name is required");
|
|
301
|
+
return name;
|
|
302
|
+
}
|
|
303
|
+
/** POSIX-safe single-argument quoting for a copy-paste recovery command. This
|
|
304
|
+
* module is a zero-dependency island, so the one small formatter stays here. */
|
|
305
|
+
function shellQuoteProfile(profile) {
|
|
306
|
+
if (/^[A-Za-z0-9_@%+=:,./-]+$/u.test(profile)) return profile;
|
|
307
|
+
return `'${profile.replace(/'/gu, `'\\''`)}'`;
|
|
308
|
+
}
|
|
281
309
|
/** The actionable compatibility notice printed when the installed harness
|
|
282
310
|
* falls in an incompatible range. `entry` MUST be the entry
|
|
283
311
|
* {@link harnessCompatEntryFor} matched for `installed`. The notice is
|
|
284
312
|
* advisory: DSH Loader mounts profile entries concurrently, so this row cannot
|
|
285
313
|
* guarantee that its output precedes another row's import failure. */
|
|
286
|
-
function incompatibleHarnessMessage(installed, entry) {
|
|
314
|
+
function incompatibleHarnessMessage(installed, entry, profile) {
|
|
287
315
|
const recovery = [];
|
|
288
316
|
if (entry.upgradeDsh !== void 0) recovery.push("Upgrade DeepSeek Harness:", ` ${entry.upgradeCommand ?? `npm install -g @deepseek-ai/dsh@${entry.upgradeDsh}`}`);
|
|
289
|
-
if (entry.fallbackTui !== void 0) recovery.push("Or keep your current Harness and use the compatible TUI line:", ` dsh plugin --profile
|
|
317
|
+
if (entry.fallbackTui !== void 0) recovery.push("Or keep your current Harness and use the compatible TUI line:", ` dsh plugin --profile ${shellQuoteProfile(profile)} -- add @xmoon76/dsh-pi-tui@${entry.fallbackTui}`);
|
|
290
318
|
if (entry.guidance !== void 0) recovery.push(entry.guidance);
|
|
291
319
|
return [
|
|
292
320
|
`dsh-pi-tui ${bundleVersionLabel(entry.since)} requires ${entry.requires},`,
|
|
@@ -297,32 +325,221 @@ function incompatibleHarnessMessage(installed, entry) {
|
|
|
297
325
|
"",
|
|
298
326
|
...recovery
|
|
299
327
|
],
|
|
300
|
-
|
|
328
|
+
`Then re-run: dsh --profile ${shellQuoteProfile(profile)}`
|
|
301
329
|
].join("\n");
|
|
302
330
|
}
|
|
303
331
|
/** Service provided by this plugin and injected by the TUI runner row. */
|
|
304
332
|
const TUI_STARTUP_SERVICE = "tuiStartup";
|
|
305
333
|
/**
|
|
334
|
+
* Service provided when the invocation selects the local daemon backend
|
|
335
|
+
* (M6-2A). The daemon-launcher row injects it, launches exactly one foreground
|
|
336
|
+
* Client OS process, and waits for its real exit.
|
|
337
|
+
*/
|
|
338
|
+
const TUI_DAEMON_STARTUP_SERVICE = "tuiDaemonStartup";
|
|
339
|
+
/** The environment variable that overrides the persisted Profile backend for
|
|
340
|
+
* one cold launch. It is never written back to the Profile. */
|
|
341
|
+
const BACKEND_ENV = "DSH_PI_TUI_BACKEND";
|
|
342
|
+
const Config = z.object({ backend: z.string().default("direct").volatile() });
|
|
343
|
+
/** Resolve the daemon platform/tty prerequisite, or undefined when satisfiable.
|
|
344
|
+
* Daemon is a local Linux/macOS foreground process that owns a real
|
|
345
|
+
* interactive TTY; any other OS or a non-interactive launch must fail closed
|
|
346
|
+
* with a reason. The Host process itself is not launched here. */
|
|
347
|
+
function daemonPrerequisiteError() {
|
|
348
|
+
if (process.platform !== "linux" && process.platform !== "darwin") return {
|
|
349
|
+
kind: "error",
|
|
350
|
+
code: "unsupported-platform",
|
|
351
|
+
message: `the daemon backend is only supported on Linux and macOS (this is ${process.platform}); use DSH_PI_TUI_BACKEND=direct or unset it`
|
|
352
|
+
};
|
|
353
|
+
if (process.stdin.isTTY !== true || process.stdout.isTTY !== true) return {
|
|
354
|
+
kind: "error",
|
|
355
|
+
code: "no-interactive-tty",
|
|
356
|
+
message: "the daemon backend requires an interactive terminal: both stdin and stdout must be a TTY (input and output terminal capabilities are checked separately)"
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
/** Read the persisted Profile backend. An absent config (a structural test
|
|
360
|
+
* provider mounting the row without the Loader schema) resolves to the schema
|
|
361
|
+
* default, so a bare `apply(ctx)` keeps the historical Direct behavior. */
|
|
362
|
+
function profileBackendOf(config) {
|
|
363
|
+
const ref = config?.backend;
|
|
364
|
+
if (ref === void 0 || typeof ref.get !== "function") return "direct";
|
|
365
|
+
return ref.get();
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* The ONE frozen public-backend decision for a cold launch.
|
|
369
|
+
*
|
|
370
|
+
* Precedence is fixed (plan §5): `DSH_PI_TUI_BACKEND` > Profile backend >
|
|
371
|
+
* `direct`. An empty or unknown environment value is an illegal input, never
|
|
372
|
+
* "unset" and never a Direct fallback. An illegal Profile value fails closed
|
|
373
|
+
* unless an explicit valid environment value overrides it for this launch.
|
|
374
|
+
*/
|
|
375
|
+
function resolveBackendDecision(config) {
|
|
376
|
+
const envRaw = process.env[BACKEND_ENV];
|
|
377
|
+
if (envRaw !== void 0) {
|
|
378
|
+
if (envRaw === "direct" || envRaw === "daemon") {
|
|
379
|
+
if (envRaw === "daemon") {
|
|
380
|
+
const error = daemonPrerequisiteError();
|
|
381
|
+
if (error !== void 0) return error;
|
|
382
|
+
}
|
|
383
|
+
return {
|
|
384
|
+
kind: "ok",
|
|
385
|
+
backend: envRaw,
|
|
386
|
+
source: "env"
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
return {
|
|
390
|
+
kind: "error",
|
|
391
|
+
code: "invalid-backend",
|
|
392
|
+
message: `${BACKEND_ENV} must be "direct" or "daemon" (got ${JSON.stringify(envRaw)})`
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
const profileRaw = profileBackendOf(config);
|
|
396
|
+
if (profileRaw === "direct" || profileRaw === "daemon") {
|
|
397
|
+
if (profileRaw === "daemon") {
|
|
398
|
+
const error = daemonPrerequisiteError();
|
|
399
|
+
if (error !== void 0) return error;
|
|
400
|
+
}
|
|
401
|
+
return {
|
|
402
|
+
kind: "ok",
|
|
403
|
+
backend: profileRaw,
|
|
404
|
+
source: "profile"
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
return {
|
|
408
|
+
kind: "error",
|
|
409
|
+
code: "invalid-backend",
|
|
410
|
+
message: `the tui-startup Profile backend must be "direct" or "daemon" (got ${JSON.stringify(profileRaw)})`
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
/** The actionable error for a committed daemon startup whose Coordinator never
|
|
414
|
+
* mounted. The launcher row is missing, failed or still pending on
|
|
415
|
+
* `tuiDaemonStartup`; DSH treats that as an optional plugin failure, so the
|
|
416
|
+
* explicitly requested launch owns the verdict. */
|
|
417
|
+
function coordinatorNotMountedMessage(profile) {
|
|
418
|
+
return [
|
|
419
|
+
`dsh-pi-tui ${bundleVersionLabel(CURRENT_DSH_REQUIREMENT.since)} was invoked for the daemon backend, but the daemon launcher row did not mount.`,
|
|
420
|
+
"The pi-tui-daemon-launcher row failed to import/apply or stayed pending on tuiDaemonStartup (see the loader warnings above); DSH app-boot treats that as an optional plugin failure.",
|
|
421
|
+
`This installation cannot start the daemon TUI; reinstall the profile or fix its composition, then re-run: DSH_PI_TUI_BACKEND=daemon dsh --profile ${shellQuoteProfile(profile)}`
|
|
422
|
+
].join("\n");
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
306
425
|
* The actionable error for a committed startup whose TUI surface never
|
|
307
|
-
* mounted. The launcher proved the tree booted, but
|
|
308
|
-
*
|
|
426
|
+
* mounted. The launcher proved the tree booted, but this Profile asked for
|
|
427
|
+
* this surface, so the outcome is an error rather than an optional plugin
|
|
309
428
|
* warning.
|
|
310
429
|
*/
|
|
311
|
-
function surfaceNotMountedMessage() {
|
|
430
|
+
function surfaceNotMountedMessage(profile) {
|
|
312
431
|
return [
|
|
313
|
-
`dsh-pi-tui ${bundleVersionLabel(CURRENT_DSH_REQUIREMENT.since)} was invoked with --profile
|
|
432
|
+
`dsh-pi-tui ${bundleVersionLabel(CURRENT_DSH_REQUIREMENT.since)} was invoked with --profile ${shellQuoteProfile(profile)}, but the required TUI surface did not mount.`,
|
|
314
433
|
"The tui-app row failed to import/apply or stayed pending on a dependency (see the loader warnings above); DSH app-boot treats that as an optional plugin failure.",
|
|
315
|
-
|
|
434
|
+
`This installation cannot run the terminal UI; reinstall the profile or fix its composition, then re-run: dsh --profile ${shellQuoteProfile(profile)}`
|
|
316
435
|
].join("\n");
|
|
317
436
|
}
|
|
437
|
+
/** Force every Commander usage rejection below `command` onto the fixed
|
|
438
|
+
* `CLI_USAGE` exit code (2) without changing its printed text. `parseCmdline`
|
|
439
|
+
* maps a thrown `CommanderError` to `ctx.appExit(error.exitCode)`. */
|
|
440
|
+
function withUsageExitCode(command) {
|
|
441
|
+
const original = command.error.bind(command);
|
|
442
|
+
command.error = ((message, options) => original(message, {
|
|
443
|
+
...options,
|
|
444
|
+
exitCode: 2
|
|
445
|
+
}));
|
|
446
|
+
return command;
|
|
447
|
+
}
|
|
448
|
+
/** Reject the public Session launch flags on a management invocation.
|
|
449
|
+
* Commander parses root options before the subcommand, so a flag placed before
|
|
450
|
+
* the verb reaches this action instead of being an unknown subcommand option. */
|
|
451
|
+
function rejectSessionFlags(program, command, family) {
|
|
452
|
+
const options = program.opts();
|
|
453
|
+
if (options.continue === true || options.session !== void 0 || options.preset !== void 0) command.error(`error: --session, --continue and --preset are only valid for a normal TUI launch, not with ${family} commands`);
|
|
454
|
+
}
|
|
318
455
|
/** This app's command: its flags, its description, and its help text. */
|
|
319
|
-
function tuiCommand() {
|
|
320
|
-
|
|
456
|
+
function tuiCommand(ctx) {
|
|
457
|
+
const program = new Command().name("dsh --profile pi-tui").description("Run the DeepSeek Harness terminal UI.").helpOption("-h, --help", "show this help").option("--session [id-or-query]", "open the session browser; a full session id or a listed unique prefix resumes it").option("-c, --continue", "continue the most recent session in the confirmed workspace").option("--preset <id>", "agent preset for a fresh session (falls back to $DSH_PI_TUI_PRESET, then the saved default)");
|
|
458
|
+
const daemon = withUsageExitCode(program.command("daemon").description("Manage the local daemon Host for this profile."));
|
|
459
|
+
daemon.action(() => {
|
|
460
|
+
daemon.error("error: a daemon command is required (status, start, stop, restart, logs, install or uninstall)");
|
|
461
|
+
});
|
|
462
|
+
const addControlVerb = (name, description, configure) => {
|
|
463
|
+
const command = withUsageExitCode(daemon.command(name).description(description));
|
|
464
|
+
configure?.(command);
|
|
465
|
+
command.action((options = {}) => {
|
|
466
|
+
rejectSessionFlags(program, command, "daemon");
|
|
467
|
+
if (isHostOnlyRole()) command.error("error: daemon management commands are not available in a Host-only process");
|
|
468
|
+
let lines;
|
|
469
|
+
if (options.lines !== void 0) {
|
|
470
|
+
if (!/^[0-9]+$/u.test(options.lines)) command.error("error: --lines must be an integer between 1 and 1000");
|
|
471
|
+
const parsed = Number(options.lines);
|
|
472
|
+
if (!Number.isSafeInteger(parsed) || parsed < 1 || parsed > 1e3) command.error("error: --lines must be an integer between 1 and 1000");
|
|
473
|
+
lines = parsed;
|
|
474
|
+
}
|
|
475
|
+
publishDaemonControl(ctx, {
|
|
476
|
+
verb: name,
|
|
477
|
+
...lines === void 0 ? {} : { lines }
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
return command;
|
|
481
|
+
};
|
|
482
|
+
addControlVerb("status", "show the manager, unit, Host readiness and compatibility of this profile");
|
|
483
|
+
addControlVerb("start", "start the profile Host and wait until it is authenticated");
|
|
484
|
+
addControlVerb("stop", "stop this profile Host through its verified supervision owner");
|
|
485
|
+
addControlVerb("restart", "stop the profile Host, confirm its exit, then start a new instance");
|
|
486
|
+
addControlVerb("logs", "show the current Host log source (systemd journal, launchd logs or the scope host.log)", (command) => {
|
|
487
|
+
command.option("--lines <count>", "number of log lines to show (1-1000, default 100)");
|
|
488
|
+
});
|
|
489
|
+
addControlVerb("install", "install this profile service definition (systemd unit or launchd plist) without starting it");
|
|
490
|
+
addControlVerb("uninstall", "remove only this profile managed service definition");
|
|
491
|
+
daemon.addHelpText("after", `
|
|
492
|
+
Examples:
|
|
493
|
+
dsh --profile pi-tui daemon status
|
|
494
|
+
dsh --profile pi-tui daemon start
|
|
495
|
+
dsh --profile pi-tui daemon stop
|
|
496
|
+
dsh --profile pi-tui daemon restart
|
|
497
|
+
dsh --profile pi-tui daemon logs --lines 200
|
|
498
|
+
dsh --profile pi-tui daemon install
|
|
499
|
+
dsh --profile pi-tui daemon uninstall
|
|
500
|
+
`);
|
|
501
|
+
const web = withUsageExitCode(program.command("web").description("Inspect or control the running Host's official Web frontend."));
|
|
502
|
+
web.action(() => {
|
|
503
|
+
web.error("error: a web command is required (status, enable, disable, url or open)");
|
|
504
|
+
});
|
|
505
|
+
const addWebVerb = (name, description) => {
|
|
506
|
+
const command = withUsageExitCode(web.command(name).description(description));
|
|
507
|
+
command.action(() => {
|
|
508
|
+
rejectSessionFlags(program, command, "web");
|
|
509
|
+
if (isHostOnlyRole()) command.error("error: web commands are not available in a Host-only process");
|
|
510
|
+
publishDaemonService(ctx, {
|
|
511
|
+
kind: "web-control",
|
|
512
|
+
control: { verb: name }
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
return command;
|
|
516
|
+
};
|
|
517
|
+
addWebVerb("status", "show the running Host's Web frontend state");
|
|
518
|
+
addWebVerb("enable", "enable the running Host's Web frontend");
|
|
519
|
+
addWebVerb("disable", "disable the running Host's Web frontend");
|
|
520
|
+
addWebVerb("url", "print the authenticated Web URL of the running Host");
|
|
521
|
+
addWebVerb("open", "request the local browser opener for the authenticated Web URL");
|
|
522
|
+
web.addHelpText("after", `
|
|
523
|
+
Examples:
|
|
524
|
+
dsh --profile pi-tui web status
|
|
525
|
+
dsh --profile pi-tui web enable
|
|
526
|
+
dsh --profile pi-tui web disable
|
|
527
|
+
dsh --profile pi-tui web url
|
|
528
|
+
dsh --profile pi-tui web open
|
|
529
|
+
`);
|
|
530
|
+
program.addHelpText("after", `
|
|
321
531
|
Examples:
|
|
322
532
|
dsh --profile pi-tui start the terminal UI
|
|
323
|
-
dsh --profile pi-tui --session
|
|
324
|
-
dsh --profile pi-tui --
|
|
533
|
+
dsh --profile pi-tui --session browse all sessions
|
|
534
|
+
dsh --profile pi-tui --session mysql search sessions for "mysql"
|
|
535
|
+
dsh --profile pi-tui --session <id> resume a listed or full session id
|
|
536
|
+
dsh --profile pi-tui --continue continue the last session in this workspace
|
|
537
|
+
dsh --profile pi-tui --session <id> --preset minimal
|
|
538
|
+
dsh --profile pi-tui daemon status inspect the local daemon Host
|
|
539
|
+
dsh --profile pi-tui web status inspect the Host's Web frontend
|
|
540
|
+
dsh --profile pi-tui web url print the authenticated Web URL
|
|
325
541
|
`);
|
|
542
|
+
return program;
|
|
326
543
|
}
|
|
327
544
|
/** The two official provider tags whose model-listing diagnostics leave the
|
|
328
545
|
* terminal. The tag is the provider plugin name in brackets, exactly as
|
|
@@ -438,15 +655,39 @@ function installModelListingLogInterceptor() {
|
|
|
438
655
|
* nothing is provided, so no TUI row mounts.
|
|
439
656
|
* @param ctx - plugin context carrying the command line.
|
|
440
657
|
*/
|
|
441
|
-
function apply(ctx) {
|
|
442
|
-
const program = tuiCommand();
|
|
658
|
+
function apply(ctx, config) {
|
|
659
|
+
const program = tuiCommand(ctx);
|
|
443
660
|
program.action(() => {
|
|
661
|
+
const options = program.opts();
|
|
662
|
+
if (options.continue === true && options.session !== void 0) program.error("error: --session and --continue are mutually exclusive");
|
|
663
|
+
const sessionLaunch = options.continue === true ? { kind: "continue" } : options.session === void 0 ? void 0 : typeof options.session === "string" && options.session.trim() !== "" ? {
|
|
664
|
+
kind: "lookup",
|
|
665
|
+
query: options.session.trim()
|
|
666
|
+
} : {
|
|
667
|
+
kind: "browse",
|
|
668
|
+
query: ""
|
|
669
|
+
};
|
|
670
|
+
if (!isHostOnlyRole()) {
|
|
671
|
+
const decision = resolveBackendDecision(config);
|
|
672
|
+
if (decision.kind === "error") {
|
|
673
|
+
process.stderr.write(`\ndsh-pi-tui: cannot start (${decision.code}): ${decision.message}\n\n`);
|
|
674
|
+
ctx.get("appExit")?.(1);
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
if (decision.backend === "daemon") {
|
|
678
|
+
publishDaemonStartup(ctx, sessionLaunch, options.preset, {
|
|
679
|
+
value: decision.backend,
|
|
680
|
+
source: decision.source
|
|
681
|
+
});
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
444
685
|
if (!isHostOnlyRole()) ctx.effect(() => installModelListingLogInterceptor(), "tui-startup model-listing log interception");
|
|
445
686
|
const installed = installedDshVersion();
|
|
446
687
|
if (installed !== void 0) {
|
|
447
688
|
const entry = harnessCompatEntryFor(installed);
|
|
448
689
|
if (entry !== void 0) {
|
|
449
|
-
const message = incompatibleHarnessMessage(installed, entry);
|
|
690
|
+
const message = incompatibleHarnessMessage(installed, entry, runningProfileName(ctx));
|
|
450
691
|
process.stderr.write(`\n${message}\n\n`);
|
|
451
692
|
}
|
|
452
693
|
}
|
|
@@ -457,7 +698,7 @@ function apply(ctx) {
|
|
|
457
698
|
const cancel = ready.onReady(() => {
|
|
458
699
|
if (!registrationReturned) return;
|
|
459
700
|
if (surfaceMounted) return;
|
|
460
|
-
process.stderr.write(`\n${surfaceNotMountedMessage()}\n\n`);
|
|
701
|
+
process.stderr.write(`\n${surfaceNotMountedMessage(runningProfileName(ctx))}\n\n`);
|
|
461
702
|
ctx.get("appExit")?.(1);
|
|
462
703
|
});
|
|
463
704
|
registrationReturned = true;
|
|
@@ -465,9 +706,8 @@ function apply(ctx) {
|
|
|
465
706
|
cancel();
|
|
466
707
|
}, "tui-startup readiness handshake");
|
|
467
708
|
}
|
|
468
|
-
const options = program.opts();
|
|
469
709
|
ctx.provide(TUI_STARTUP_SERVICE, {
|
|
470
|
-
...
|
|
710
|
+
...sessionLaunch !== void 0 ? { sessionLaunch } : {},
|
|
471
711
|
...options.preset !== void 0 ? { presetId: options.preset } : {},
|
|
472
712
|
markSurfaceMounted: () => {
|
|
473
713
|
surfaceMounted = true;
|
|
@@ -476,5 +716,80 @@ function apply(ctx) {
|
|
|
476
716
|
});
|
|
477
717
|
parseCmdline(ctx, program);
|
|
478
718
|
}
|
|
719
|
+
/** The actionable error for a committed management startup whose launcher row
|
|
720
|
+
* never mounted. A missing/failed supervisor row must not look like a
|
|
721
|
+
* successful management command. */
|
|
722
|
+
function controlNotMountedMessage() {
|
|
723
|
+
return [
|
|
724
|
+
`dsh-pi-tui ${bundleVersionLabel(CURRENT_DSH_REQUIREMENT.since)} was invoked for a daemon management command, but the daemon launcher row did not mount.`,
|
|
725
|
+
"The pi-tui-daemon-launcher row failed to import/apply or stayed pending on tuiDaemonStartup (see the loader warnings above); DSH app-boot treats that as an optional plugin failure.",
|
|
726
|
+
"This installation cannot run daemon management commands; reinstall the profile or fix its composition, then re-run the command."
|
|
727
|
+
].join("\n");
|
|
728
|
+
}
|
|
729
|
+
/** The actionable error for a committed Web CLI startup whose launcher row
|
|
730
|
+
* never mounted. A missing/failed supervisor must not look like a successful
|
|
731
|
+
* web command, and the text must not claim the daemon TUI was requested. */
|
|
732
|
+
function webControlNotMountedMessage(profile) {
|
|
733
|
+
return [
|
|
734
|
+
`dsh-pi-tui ${bundleVersionLabel(CURRENT_DSH_REQUIREMENT.since)} was invoked for a web CLI command, but the daemon launcher row did not mount.`,
|
|
735
|
+
"The pi-tui-daemon-launcher row failed to import/apply or stayed pending on tuiDaemonStartup (see the loader warnings above); DSH app-boot treats that as an optional plugin failure.",
|
|
736
|
+
`This installation cannot run the web CLI; reinstall the profile or fix its composition, then re-run: dsh --profile ${shellQuoteProfile(profile)} web status`
|
|
737
|
+
].join("\n");
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Publish the daemon startup service. The daemon-launcher row injects it,
|
|
741
|
+
* spawns exactly ONE foreground Client OS process and waits for its real exit.
|
|
742
|
+
*
|
|
743
|
+
* The daemon supervisor paints no TUI, so it installs no console interception
|
|
744
|
+
* and never arms the Direct surface handshake. It owns the compatibility notice
|
|
745
|
+
* and one `coordinatorMounted` cold-ready handshake: readiness that commits
|
|
746
|
+
* without the launcher row having mounted (missing/failed/pending) is an error,
|
|
747
|
+
* not a silent optional failure.
|
|
748
|
+
*/
|
|
749
|
+
function publishDaemonService(ctx, values) {
|
|
750
|
+
const installed = installedDshVersion();
|
|
751
|
+
if (installed !== void 0) {
|
|
752
|
+
const entry = harnessCompatEntryFor(installed);
|
|
753
|
+
if (entry !== void 0) process.stderr.write(`\n${incompatibleHarnessMessage(installed, entry, runningProfileName(ctx))}\n\n`);
|
|
754
|
+
}
|
|
755
|
+
let coordinatorMounted = false;
|
|
756
|
+
const ready = ctx.get("appReady");
|
|
757
|
+
if (ready !== void 0) {
|
|
758
|
+
let registrationReturned = false;
|
|
759
|
+
const cancel = ready.onReady(() => {
|
|
760
|
+
if (!registrationReturned) return;
|
|
761
|
+
if (coordinatorMounted) return;
|
|
762
|
+
const message = values.kind === "control" ? controlNotMountedMessage() : values.kind === "web-control" ? webControlNotMountedMessage(runningProfileName(ctx)) : coordinatorNotMountedMessage(runningProfileName(ctx));
|
|
763
|
+
process.stderr.write(`\n${message}\n\n`);
|
|
764
|
+
ctx.get("appExit")?.(1);
|
|
765
|
+
});
|
|
766
|
+
registrationReturned = true;
|
|
767
|
+
ctx.effect(() => () => {
|
|
768
|
+
cancel();
|
|
769
|
+
}, "tui-daemon-startup readiness handshake");
|
|
770
|
+
}
|
|
771
|
+
ctx.provide(TUI_DAEMON_STARTUP_SERVICE, {
|
|
772
|
+
...values,
|
|
773
|
+
markCoordinatorMounted: () => {
|
|
774
|
+
coordinatorMounted = true;
|
|
775
|
+
}
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
function publishDaemonStartup(ctx, sessionLaunch, presetId, backendSource) {
|
|
779
|
+
publishDaemonService(ctx, {
|
|
780
|
+
kind: "client",
|
|
781
|
+
...sessionLaunch !== void 0 ? { sessionLaunch } : {},
|
|
782
|
+
...presetId !== void 0 ? { presetId } : {},
|
|
783
|
+
...backendSource !== void 0 ? { backendSource } : {}
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
/** Publish the ONE management intent; the launcher row runs it once after the
|
|
787
|
+
* real cold-ready commit and never opens the TUI/Client. */
|
|
788
|
+
function publishDaemonControl(ctx, control) {
|
|
789
|
+
publishDaemonService(ctx, {
|
|
790
|
+
kind: "control",
|
|
791
|
+
control
|
|
792
|
+
});
|
|
793
|
+
}
|
|
479
794
|
//#endregion
|
|
480
|
-
export {
|
|
795
|
+
export { apply as a, incompatibleHarnessMessage as c, TUI_STARTUP_SERVICE as i, inject as l, HARNESS_COMPAT as n, bundleVersionLabel as o, TUI_DAEMON_STARTUP_SERVICE as r, harnessCompatEntryFor as s, Config as t, name as u };
|
package/dist/startup.d.mts
CHANGED
|
@@ -1,99 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/startup.d.ts
|
|
4
|
-
/** Stable Cordis plugin name. */
|
|
5
|
-
declare const name = "tui-startup";
|
|
6
|
-
/** Services required before the flags can be resolved. */
|
|
7
|
-
declare const inject: string[];
|
|
8
|
-
/** Incompatible dsh harness ranges and the guidance each deserves. Entries
|
|
9
|
-
* are checked in ORDER and the first whose range covers the installed dsh
|
|
10
|
-
* version wins.
|
|
11
|
-
*
|
|
12
|
-
* Range semantics: `min` is inclusive, `max` is EXCLUSIVE. An entry with
|
|
13
|
-
* only `max` covers everything below it (the common "too old" case); an
|
|
14
|
-
* entry with only `min` covers everything at or above it ("too new" —
|
|
15
|
-
* e.g. a harness that removed a seam we still use).
|
|
16
|
-
*
|
|
17
|
-
* `since` names the bundle release line that FIRST imposed the constraint:
|
|
18
|
-
* it is shown as the fallback version label (`>= <since>`) when the
|
|
19
|
-
* bundle's own version cannot be read, so the message stays truthful.
|
|
20
|
-
*
|
|
21
|
-
* The current line has a minimum of the published npm release
|
|
22
|
-
* dsh-v0.2.1-rc.2 and a recommended upgrade target of the newer
|
|
23
|
-
* dsh-v0.2.1-rc.5. The recovery guidance names the recommended published
|
|
24
|
-
* upgrade target — which may be NEWER than the floor — and allows its native
|
|
25
|
-
* install scripts. The already-published 0.5.0 line keeps its own
|
|
26
|
-
* rc.1-era contract and remains the compatible fallback for a
|
|
27
|
-
* dsh-v0.2.0-rc.1 runtime.
|
|
28
|
-
*/
|
|
29
|
-
interface HarnessCompatEntry {
|
|
30
|
-
/** Inclusive lower bound of the incompatible range; absent = unbounded below. */
|
|
31
|
-
min?: string;
|
|
32
|
-
/** Exclusive upper bound of the incompatible range; absent = unbounded above. */
|
|
33
|
-
max?: string;
|
|
34
|
-
/** The bundle release line that first required this constraint. */
|
|
35
|
-
since: string;
|
|
36
|
-
/** Human-readable requirement, e.g. `DeepSeek Harness 0.1.7-alpha.2 or later`. */
|
|
37
|
-
requires: string;
|
|
38
|
-
/** The target DSH version to install when the current runtime is too old. */
|
|
39
|
-
upgradeDsh?: string;
|
|
40
|
-
/** An exact install command when the target needs install-script flags. */
|
|
41
|
-
upgradeCommand?: string;
|
|
42
|
-
/** The compatible TUI line to install when keeping an old DSH runtime. */
|
|
43
|
-
fallbackTui?: string;
|
|
44
|
-
/** Special guidance for a range that is not covered by the normal recovery
|
|
45
|
-
* commands, such as an unvalidated future DSH line. */
|
|
46
|
-
guidance?: string;
|
|
47
|
-
}
|
|
48
|
-
/** The compatibility table, derived from the shared matrix and ordered from
|
|
49
|
-
* oldest to newest so `harnessCompatEntryFor()` can return the first matching
|
|
50
|
-
* range. The oldest entry is the catch-all floor; each matrix row contributes
|
|
51
|
-
* a range that ends at the NEXT row's lower bound (the last row is the current
|
|
52
|
-
* supported line and produces no incompatible entry).
|
|
53
|
-
*
|
|
54
|
-
* Two boundaries are worth keeping in mind: cross-core prereleases do not
|
|
55
|
-
* satisfy an older TUI package's semver peer range, and the official
|
|
56
|
-
* dsh-v0.1.5-alpha.1/.2 tags predate the setup contract required by the next
|
|
57
|
-
* supported TUI line, so they carry no fallback. */
|
|
58
|
-
declare const HARNESS_COMPAT: readonly HarnessCompatEntry[];
|
|
59
|
-
/** The compat entry covering the installed dsh version, or undefined when
|
|
60
|
-
* the harness is supported. */
|
|
61
|
-
declare function harnessCompatEntryFor(installed: string): HarnessCompatEntry | undefined;
|
|
62
|
-
/** The bundle's own version label for the gate message, read from
|
|
63
|
-
* package.json at runtime (never hardcoded). Falls back to the release
|
|
64
|
-
* line that first imposed the requirement when unreadable. */
|
|
65
|
-
declare function bundleVersionLabel(since: string): string;
|
|
66
|
-
/** The actionable compatibility notice printed when the installed harness
|
|
67
|
-
* falls in an incompatible range. `entry` MUST be the entry
|
|
68
|
-
* {@link harnessCompatEntryFor} matched for `installed`. The notice is
|
|
69
|
-
* advisory: DSH Loader mounts profile entries concurrently, so this row cannot
|
|
70
|
-
* guarantee that its output precedes another row's import failure. */
|
|
71
|
-
declare function incompatibleHarnessMessage(installed: string, entry: HarnessCompatEntry): string;
|
|
72
|
-
/** Service provided by this plugin and injected by the TUI runner row. */
|
|
73
|
-
declare const TUI_STARTUP_SERVICE = "tuiStartup";
|
|
74
|
-
/** What the runner row reads from {@link TUI_STARTUP_SERVICE}. */
|
|
75
|
-
interface TuiStartupValues {
|
|
76
|
-
/** `--session`, absent when the invocation did not name one. */
|
|
77
|
-
sessionId?: string;
|
|
78
|
-
/** `--preset`, the agent preset a fresh session starts on. */
|
|
79
|
-
presetId?: string;
|
|
80
|
-
/**
|
|
81
|
-
* Mark the TUI required surface as mounted. `src/index.ts` calls this once
|
|
82
|
-
* its synchronous initialization succeeded and its async startup root is
|
|
83
|
-
* established. The readiness handshake registered by this row exits nonzero
|
|
84
|
-
* when the launcher commits readiness without it: 0.1.6 app-boot treats a
|
|
85
|
-
* failed `tui-app` row as an OPTIONAL plugin failure, so without this the
|
|
86
|
-
* explicitly requested TUI could report a successful startup that never
|
|
87
|
-
* mounted. Optional so structural test providers can omit it.
|
|
88
|
-
*/
|
|
89
|
-
markSurfaceMounted?(): void;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Parse and provide the TUI invocation as an ordinary Cordis service. The
|
|
93
|
-
* command's action publishes the flags this invocation named; on `--help`
|
|
94
|
-
* nothing is provided, so no TUI row mounts.
|
|
95
|
-
* @param ctx - plugin context carrying the command line.
|
|
96
|
-
*/
|
|
97
|
-
declare function apply(ctx: Context): void;
|
|
98
|
-
//#endregion
|
|
99
|
-
export { HARNESS_COMPAT, HarnessCompatEntry, TUI_STARTUP_SERVICE, TuiStartupValues, apply, bundleVersionLabel, harnessCompatEntryFor, incompatibleHarnessMessage, inject, name };
|
|
1
|
+
import { S as name, _ as apply, a as HARNESS_COMPAT, b as incompatibleHarnessMessage, c as TUI_DAEMON_STARTUP_SERVICE, d as TuiDaemonControlStartup, f as TuiDaemonStartupValues, g as WebControlVerb, h as WebControlIntent, i as DaemonControlVerb, l as TUI_STARTUP_SERVICE, m as TuiWebControlStartup, n as Config, o as HarnessCompatEntry, p as TuiStartupValues, r as DaemonControlIntent, s as PublicBackend, t as CliSessionLaunchIntent, u as TuiDaemonClientStartup, v as bundleVersionLabel, x as inject, y as harnessCompatEntryFor } from "./startup-CarQxWwi.mjs";
|
|
2
|
+
export { CliSessionLaunchIntent, Config, DaemonControlIntent, DaemonControlVerb, HARNESS_COMPAT, HarnessCompatEntry, PublicBackend, TUI_DAEMON_STARTUP_SERVICE, TUI_STARTUP_SERVICE, TuiDaemonClientStartup, TuiDaemonControlStartup, TuiDaemonStartupValues, TuiStartupValues, TuiWebControlStartup, WebControlIntent, WebControlVerb, apply, bundleVersionLabel, harnessCompatEntryFor, incompatibleHarnessMessage, inject, name };
|
package/dist/startup.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { HARNESS_COMPAT, TUI_STARTUP_SERVICE, apply, bundleVersionLabel, harnessCompatEntryFor, incompatibleHarnessMessage, inject, name };
|
|
1
|
+
import { a as apply, c as incompatibleHarnessMessage, i as TUI_STARTUP_SERVICE, l as inject, n as HARNESS_COMPAT, o as bundleVersionLabel, r as TUI_DAEMON_STARTUP_SERVICE, s as harnessCompatEntryFor, t as Config, u as name } from "./startup-EG5UqIcd.mjs";
|
|
2
|
+
export { Config, HARNESS_COMPAT, TUI_DAEMON_STARTUP_SERVICE, TUI_STARTUP_SERVICE, apply, bundleVersionLabel, harnessCompatEntryFor, incompatibleHarnessMessage, inject, name };
|