@xmoon76/dsh-pi-tui 0.5.7 → 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.
Files changed (33) hide show
  1. package/README.en.md +13 -11
  2. package/README.md +13 -11
  3. package/dist/{bootstrap-C9nl6e13.mjs → bootstrap-CMIjGyuk.mjs} +532 -416
  4. package/dist/builtins.mjs +2 -2
  5. package/dist/{client-bootstrap-CGezi85O.mjs → client-bootstrap-BjGPc-DM.mjs} +826 -3
  6. package/dist/{daemon-launcher-H_1r5Cqs.mjs → daemon-launcher-Dult7Jxv.mjs} +121 -4
  7. package/dist/daemon-launcher.mjs +1 -1
  8. package/dist/{entry-control-jBfKn1qO.mjs → entry-control-DjNsE3I0.mjs} +1 -1
  9. package/dist/{extensions-6a5vvJUT.mjs → extensions-B4uLpSTv.mjs} +1 -4
  10. package/dist/extensions.mjs +1 -1
  11. package/dist/{host-foundation-probe-DK7n5jDu.mjs → host-foundation-probe-DMNTmNrH.mjs} +1 -1
  12. package/dist/index.mjs +532 -298
  13. package/dist/{local-acp-listener-CNkguN5-.mjs → local-acp-listener-B65J0Bx4.mjs} +561 -12
  14. package/dist/local-client.mjs +442 -45
  15. package/dist/{local-daemon-control-Cu_4FIdd.mjs → local-daemon-control-C14q9KnD.mjs} +5 -2
  16. package/dist/{local-daemon-control-Bg9s2aYi.mjs → local-daemon-control-TCnERL7n.mjs} +3 -3
  17. package/dist/{local-discovery-Bq3jLAn1.mjs → local-discovery-DOSsCh9q.mjs} +1 -1
  18. package/dist/{local-discovery-BMoNXZjJ.mjs → local-discovery-egN4_gsQ.mjs} +1 -1
  19. package/dist/{local-discovery-BPZw1wEd.mjs → local-discovery-uOBfFq5j.mjs} +1 -1
  20. package/dist/local-host.mjs +24 -6
  21. package/dist/local-profile-daemon-admin-BmQSdzT0.mjs +210 -0
  22. package/dist/{local-scope-DEuGAy8l.mjs → local-scope-DamiMqPd.mjs} +118 -1
  23. package/dist/{local-transport-X4ZCe2uE.mjs → local-transport-Iwo0mtu3.mjs} +2 -2
  24. package/dist/{local-web-control-DKWtXIkr.mjs → local-web-control-DMrjwCkl.mjs} +2 -2
  25. package/dist/{session-DC0XQr5O.mjs → session-C6tSs86s.mjs} +2 -2
  26. package/dist/{session-Cihe8PPS.mjs → session-CstInGIA.mjs} +1 -1
  27. package/dist/{startup-CARqn3kV.mjs → startup-EG5UqIcd.mjs} +3 -3
  28. package/dist/startup.mjs +1 -1
  29. package/dist/{terminal-progress-source-D4DHyXDo.mjs → terminal-progress-source-CpfpQO_h.mjs} +3 -6
  30. package/dist/{transcript-view-hvNVkPtv.mjs → transcript-view-C1YtJ49Y.mjs} +191 -192
  31. package/dist/{transcript-view-a7cROAaI.mjs → transcript-view-CuJYWkhp.mjs} +190 -191
  32. package/package.json +6 -6
  33. package/dist/local-profile-daemon-admin-AXgVH-6y.mjs +0 -91
@@ -2,7 +2,7 @@ import { n as runSyncDisposalStepsWithPrimary } from "./disposal-BYBbEpVY.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { closeSync, constants, existsSync, fchmodSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, statSync, writeSync } from "node:fs";
4
4
  import { constants as constants$1, userInfo } from "node:os";
5
- import { dirname, isAbsolute, join, relative, sep } from "node:path";
5
+ import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
6
6
  import { createHash } from "node:crypto";
7
7
  import { spawn } from "node:child_process";
8
8
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -55,6 +55,121 @@ function decimal(value) {
55
55
  throw new Error(`expected an exact 64-bit integer, got ${String(value)}`);
56
56
  }
57
57
  let loaded;
58
+ /** One installed `@deepseek-ai/dsh` manifest, or undefined when the path is
59
+ * unreadable, malformed, or belongs to another package. The name check is
60
+ * load-bearing: `createRequire` would otherwise walk into an unrelated ancestor
61
+ * `node_modules` and silently borrow a Koffi copy that does not belong to the
62
+ * running DSH installation. */
63
+ function installedDshManifest(path) {
64
+ try {
65
+ const real = realpathSync(path);
66
+ const manifest = JSON.parse(readFileSync(real, "utf8"));
67
+ if (manifest === null || typeof manifest !== "object" || Array.isArray(manifest)) return void 0;
68
+ const record = manifest;
69
+ return record.name === "@deepseek-ai/dsh" && typeof record.version === "string" && record.version !== "" ? real : void 0;
70
+ } catch {
71
+ return;
72
+ }
73
+ }
74
+ /**
75
+ * The installed `@deepseek-ai/dsh/package.json` this process runs on.
76
+ *
77
+ * A real Direct launcher entry (`process.argv[1]`) identifies its own installed
78
+ * DSH package and always wins over an inherited environment anchor: a shell or
79
+ * tool child of a Split Host inherits SPLIT_PROCESS_DSH_ANCHOR, but a Direct
80
+ * `dsh` CLI started from it must use the installation executing that CLI.
81
+ * Only a Split Host/Client entry, whose argv[1] is the product's own
82
+ * local-host/local-client script, falls back to the launcher-verified
83
+ * SPLIT_PROCESS_DSH_ANCHOR. No NODE_PATH, profile node_modules or source tree
84
+ * is consulted.
85
+ */
86
+ function installedDshAnchor() {
87
+ const entry = process.argv[1];
88
+ if (entry !== void 0) try {
89
+ let dir = dirname(realpathSync(entry));
90
+ for (let depth = 0; depth < 8; depth += 1) {
91
+ const anchor = installedDshManifest(join(dir, "package.json"));
92
+ if (anchor !== void 0) return anchor;
93
+ const parent = dirname(dir);
94
+ if (parent === dir) break;
95
+ dir = parent;
96
+ }
97
+ } catch {}
98
+ const provided = process.env.SPLIT_PROCESS_DSH_ANCHOR;
99
+ return provided !== void 0 && provided !== "" ? installedDshManifest(provided) : void 0;
100
+ }
101
+ /** The nearest `node_modules` directory above a package directory. */
102
+ function nearestModuleRoot(packageDir) {
103
+ for (let dir = packageDir;; dir = dirname(dir)) {
104
+ if (basename(dir) === "node_modules") return dir;
105
+ const parent = dirname(dir);
106
+ if (parent === dir) return void 0;
107
+ dir = parent;
108
+ }
109
+ }
110
+ function isInside(path, root) {
111
+ return path === root || path.startsWith(`${root}${sep}`);
112
+ }
113
+ /** Prove a resolved dependency belongs to its owner's installation closure.
114
+ *
115
+ * npm keeps sibling dependencies in the owner's nearest `node_modules`. pnpm
116
+ * keeps every package in a shared virtual store (`.mise` in the mise install
117
+ * and `.pnpm` in a project install), with each package in its own
118
+ * `<name>@<version>/node_modules` directory. Any other ancestor `node_modules`
119
+ * is an accidental hoist and must not supply a dependency. */
120
+ function assertInstallClosure(ownerDir, dependencyDir, label) {
121
+ const nearest = nearestModuleRoot(ownerDir);
122
+ if (nearest !== void 0 && isInside(dependencyDir, nearest)) return;
123
+ for (let dir = ownerDir;; dir = dirname(dir)) {
124
+ if ((basename(dir) === ".mise" || basename(dir) === ".pnpm") && isInside(dependencyDir, dir)) return;
125
+ const parent = dirname(dir);
126
+ if (parent === dir) break;
127
+ dir = parent;
128
+ }
129
+ throw new Error(`native process identity: ${label} resolved outside the installed DSH module tree`);
130
+ }
131
+ /** Read one JSON package manifest as an object, or undefined when unreadable. */
132
+ function readManifestObject(path) {
133
+ try {
134
+ const manifest = JSON.parse(readFileSync(realpathSync(path), "utf8"));
135
+ if (manifest === null || typeof manifest !== "object" || Array.isArray(manifest)) return void 0;
136
+ return manifest;
137
+ } catch {
138
+ return;
139
+ }
140
+ }
141
+ /** Require one dependency declaration from an owner manifest. */
142
+ function assertDeclaredDependency(manifest, name, label) {
143
+ const dependencies = manifest.dependencies;
144
+ const declared = dependencies !== null && typeof dependencies === "object" && !Array.isArray(dependencies) ? dependencies[name] : void 0;
145
+ if (typeof declared !== "string" || declared === "") throw new Error(`native process identity: ${label} does not declare ${name}`);
146
+ }
147
+ /**
148
+ * Resolve the Koffi entry owned by the running DSH installation:
149
+ * DSH anchor -> `@deepseek-ai/dsh-subprocess-local` manifest -> that package's
150
+ * own `koffi` dependency. The TUI never resolves Koffi from its own package, a
151
+ * profile, or an ambient module path.
152
+ *
153
+ * The owner's declared dependency selects the implementation; this code does
154
+ * not pin or compare a Koffi version, because the running DSH installation owns
155
+ * that choice and an upgrade must not be rejected only for a different version
156
+ * number. The ABI/struct-size checks in loadBridge decide actual compatibility.
157
+ */
158
+ function resolveDshKoffi(anchor) {
159
+ const manifest = installedDshManifest(anchor);
160
+ if (manifest === void 0) throw new Error("native process identity: the DSH anchor is not an installed @deepseek-ai/dsh manifest");
161
+ const dshDir = dirname(manifest);
162
+ const subprocessManifest = realpathSync(createRequire(manifest).resolve("@deepseek-ai/dsh-subprocess-local/package.json"));
163
+ const subprocessDir = dirname(subprocessManifest);
164
+ assertInstallClosure(dshDir, subprocessDir, "@deepseek-ai/dsh-subprocess-local");
165
+ const subprocess = readManifestObject(subprocessManifest);
166
+ if (subprocess?.name !== "@deepseek-ai/dsh-subprocess-local") throw new Error("native process identity: the resolved subprocess manifest is not @deepseek-ai/dsh-subprocess-local");
167
+ assertDeclaredDependency(subprocess, "koffi", "@deepseek-ai/dsh-subprocess-local");
168
+ const koffiEntry = realpathSync(createRequire(subprocessManifest).resolve("koffi"));
169
+ assertInstallClosure(subprocessDir, dirname(koffiEntry), "koffi");
170
+ if (readManifestObject(join(dirname(koffiEntry), "package.json"))?.name !== "koffi") throw new Error("native process identity: the resolved koffi is not the koffi package");
171
+ return koffiEntry;
172
+ }
58
173
  /** Load and ABI-check the Darwin bridge once per process. The loader itself
59
174
  * never throws: an unavailable dylib/addon or an unexpected struct size is a
60
175
  * classified observation, and the caller fails closed. */
@@ -62,7 +177,9 @@ function loadBridge() {
62
177
  if (loaded !== void 0) return loaded;
63
178
  let result;
64
179
  try {
65
- const koffi = createRequire(import.meta.url)("koffi");
180
+ const anchor = installedDshAnchor();
181
+ if (anchor === void 0) throw new Error("native process identity: no installed DSH anchor");
182
+ const koffi = createRequire(import.meta.url)(resolveDshKoffi(anchor));
66
183
  const libproc = koffi.load(LIBPROC);
67
184
  const libsystem = koffi.load(LIBSYSTEM);
68
185
  const bsdInfo = koffi.struct({
@@ -1787,7 +1904,7 @@ function applyManagement(ctx, startup, profileContext, appExit) {
1787
1904
  const controller = new AbortController();
1788
1905
  mountManagementRunner(ctx, startup, new DaemonControlRunner({
1789
1906
  run: async () => {
1790
- const { runDaemonControl } = await import("./local-daemon-control-Cu_4FIdd.mjs");
1907
+ const { runDaemonControl } = await import("./local-daemon-control-C14q9KnD.mjs");
1791
1908
  return await runDaemonControl(startup.control, profile, { signal: controller.signal });
1792
1909
  },
1793
1910
  appExit
@@ -1800,7 +1917,7 @@ function applyWebControl(ctx, startup, profileContext, appExit) {
1800
1917
  const controller = new AbortController();
1801
1918
  mountManagementRunner(ctx, startup, new DaemonControlRunner({
1802
1919
  run: async () => {
1803
- const { runLocalWebControl } = await import("./local-web-control-DKWtXIkr.mjs");
1920
+ const { runLocalWebControl } = await import("./local-web-control-DMrjwCkl.mjs");
1804
1921
  return await runLocalWebControl(startup.control, profile, { signal: controller.signal });
1805
1922
  },
1806
1923
  appExit,
@@ -1,2 +1,2 @@
1
- import { a as createLoaderDumpScheduler, c as name, d as writeQualificationDump, i as buildChildEnvironment, l as resolveClientEntry, n as DaemonCoordinator, o as encodeLaunchEnvelope, r as apply, s as inject, t as DaemonControlRunner, u as resolveProfilePackageRoot } from "./daemon-launcher-H_1r5Cqs.mjs";
1
+ import { a as createLoaderDumpScheduler, c as name, d as writeQualificationDump, i as buildChildEnvironment, l as resolveClientEntry, n as DaemonCoordinator, o as encodeLaunchEnvelope, r as apply, s as inject, t as DaemonControlRunner, u as resolveProfilePackageRoot } from "./daemon-launcher-Dult7Jxv.mjs";
2
2
  export { DaemonControlRunner, DaemonCoordinator, apply, buildChildEnvironment, createLoaderDumpScheduler, encodeLaunchEnvelope, inject, name, resolveClientEntry, resolveProfilePackageRoot, writeQualificationDump };
@@ -1,4 +1,4 @@
1
- import "./local-scope-DEuGAy8l.mjs";
1
+ import "./local-scope-DamiMqPd.mjs";
2
2
  //#region src/app/remote-process/entry-control.ts
3
3
  /** The single opt-in for the raw M4-A0 JSONL stream, frozen at process start. */
4
4
  const ENTRY_RECORDS_ENABLED = process.env.DSH_PI_TUI_ENTRY_RECORDS === "1";
@@ -1,4 +1,4 @@
1
- import { i as TUI_STARTUP_SERVICE } from "./startup-CARqn3kV.mjs";
1
+ import { i as TUI_STARTUP_SERVICE } from "./startup-EG5UqIcd.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import * as fs from "node:fs";
4
4
  import { readFileSync } from "node:fs";
@@ -17722,7 +17722,6 @@ const SESSIONLESS_COMMANDS = /* @__PURE__ */ new Set([
17722
17722
  "focus",
17723
17723
  "footer",
17724
17724
  "settings",
17725
- "help",
17726
17725
  "attach",
17727
17726
  "image",
17728
17727
  "login",
@@ -17821,7 +17820,6 @@ const LOCAL_COMMANDS = /* @__PURE__ */ new Set([
17821
17820
  "focus",
17822
17821
  "footer",
17823
17822
  "fork",
17824
- "help",
17825
17823
  "attach",
17826
17824
  "image",
17827
17825
  "keybindings",
@@ -18070,7 +18068,6 @@ const READ_ONLY_LOCAL_COMMANDS = /* @__PURE__ */ new Set([
18070
18068
  "reload",
18071
18069
  "exit",
18072
18070
  "quit",
18073
- "help",
18074
18071
  "keybindings",
18075
18072
  "copy",
18076
18073
  "attach",
@@ -1,2 +1,2 @@
1
- import { a as API_VERSION, i as PI_TUI_EXTENSIONS_SERVICE, n as inject, o as describeKey, r as name, t as apply } from "./extensions-6a5vvJUT.mjs";
1
+ import { a as API_VERSION, i as PI_TUI_EXTENSIONS_SERVICE, n as inject, o as describeKey, r as name, t as apply } from "./extensions-B4uLpSTv.mjs";
2
2
  export { API_VERSION, PI_TUI_EXTENSIONS_SERVICE, apply, describeKey, inject, name };
@@ -1,4 +1,4 @@
1
- import { r as writeEntryRecord } from "./entry-control-jBfKn1qO.mjs";
1
+ import { r as writeEntryRecord } from "./entry-control-DjNsE3I0.mjs";
2
2
  import { t as mergeCause } from "./dispose-cause-CNFuUnjR.mjs";
3
3
  import { t as PI_TUI_CLIENT_CONTRIBUTION } from "./pi-tui-remote-contribution-Do8ECrUy.mjs";
4
4
  import { createRequire } from "node:module";