@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
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { t as extensionConfigRowId } from "./row-id-DPbyt9Nn.mjs";
|
|
2
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
//#region src/app/remote-process/client-extension-loader-probe.ts
|
|
5
|
+
/**
|
|
6
|
+
* Qualification-only probe for the Client-local `./tui` loader lifecycle.
|
|
7
|
+
*
|
|
8
|
+
* Runs on ONE real surface revision AFTER the production Client extension
|
|
9
|
+
* activation. It drives the official Plugin Manager port to disable and
|
|
10
|
+
* re-enable package A's trusted Config carrier row, then reconciles the
|
|
11
|
+
* CURRENT revision's mount owner exactly like the Plugin Manager's committed
|
|
12
|
+
* refresh callback would. Production never sets the enabling env variable.
|
|
13
|
+
*
|
|
14
|
+
* @module @xmoon76/dsh-pi-tui/app/remote-process/client-extension-loader-probe
|
|
15
|
+
*/
|
|
16
|
+
const PACKAGES_ENV = "SPLIT_PROCESS_CLIENT_EXTENSION_LOADER_PACKAGES";
|
|
17
|
+
function probePackages() {
|
|
18
|
+
const raw = process.env[PACKAGES_ENV];
|
|
19
|
+
if (raw === void 0 || raw === "") throw new Error(`client extension probe: ${PACKAGES_ENV} is not set`);
|
|
20
|
+
const parsed = JSON.parse(raw);
|
|
21
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`client extension probe: ${PACKAGES_ENV} must be an object`);
|
|
22
|
+
const value = parsed;
|
|
23
|
+
if (typeof value.a !== "string" || value.a === "" || typeof value.b !== "string" || value.b === "") throw new Error(`client extension probe: ${PACKAGES_ENV} requires package names a and b`);
|
|
24
|
+
return {
|
|
25
|
+
a: value.a,
|
|
26
|
+
b: value.b
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function phaseOf(observations, packageName) {
|
|
30
|
+
return observations.find((entry) => entry.packageName === packageName)?.phase ?? "absent";
|
|
31
|
+
}
|
|
32
|
+
function carrierEntryId(snapshot, packageName) {
|
|
33
|
+
const rowId = extensionConfigRowId(packageName);
|
|
34
|
+
const row = snapshot.plugins.find((entry) => entry.patchId === rowId);
|
|
35
|
+
if (row === void 0) throw new Error(`client extension probe: no addressable carrier row for "${packageName}"`);
|
|
36
|
+
return row.entryId;
|
|
37
|
+
}
|
|
38
|
+
/** Resolve the installed package's own `./tui` file for this qualification-only
|
|
39
|
+
* byte-change control. Production never reads a path this way. */
|
|
40
|
+
function tuiFile(packageName, packages, parentURL) {
|
|
41
|
+
const pkg = packages.packageOf(packageName, parentURL);
|
|
42
|
+
if (pkg === void 0) throw new Error(`client extension probe: package "${packageName}" is not resolvable`);
|
|
43
|
+
const entry = pkg.manifest.exports;
|
|
44
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) throw new Error(`client extension probe: package "${packageName}" declares no exports`);
|
|
45
|
+
const tui = entry["./tui"];
|
|
46
|
+
if (typeof tui !== "string") throw new Error(`client extension probe: package "${packageName}" has no string ./tui export`);
|
|
47
|
+
return join(pkg.dir, tui);
|
|
48
|
+
}
|
|
49
|
+
/** One fixed disable -> reconcile -> enable -> reconcile lifecycle probe. */
|
|
50
|
+
async function runClientExtensionLoaderProbe(input) {
|
|
51
|
+
const packages = probePackages();
|
|
52
|
+
const initial = input.ui.clientExtensionObservation();
|
|
53
|
+
const entryId = carrierEntryId(await input.pluginManager.snapshot(), packages.a);
|
|
54
|
+
const disable = await input.pluginManager.setPluginEnabled(entryId, false);
|
|
55
|
+
await input.ui.reconcileClientExtensions(await input.pluginManager.snapshot());
|
|
56
|
+
const afterDisable = input.ui.clientExtensionObservation();
|
|
57
|
+
const enable = await input.pluginManager.setPluginEnabled(entryId, true);
|
|
58
|
+
await input.ui.reconcileClientExtensions(await input.pluginManager.snapshot());
|
|
59
|
+
const afterEnable = input.ui.clientExtensionObservation();
|
|
60
|
+
let afterBytesA;
|
|
61
|
+
let afterBytesB;
|
|
62
|
+
let afterRestoreA;
|
|
63
|
+
if (input.pluginPackages !== void 0 && input.parentURL !== void 0) {
|
|
64
|
+
const file = tuiFile(packages.a, input.pluginPackages, input.parentURL);
|
|
65
|
+
const original = readFileSync(file, "utf8");
|
|
66
|
+
if (!original.includes("R8-A-LIVE")) throw new Error("client extension probe: fixture A footer marker is missing");
|
|
67
|
+
const keepBytes = process.env.SPLIT_PROCESS_CLIENT_EXTENSION_LOADER_KEEP_BYTES === "1";
|
|
68
|
+
writeFileSync(file, original.replace("R8-A-LIVE", "R8-A-NEW"));
|
|
69
|
+
try {
|
|
70
|
+
await input.ui.reconcileClientExtensions(await input.pluginManager.snapshot());
|
|
71
|
+
const afterBytes = input.ui.clientExtensionObservation();
|
|
72
|
+
afterBytesA = phaseOf(afterBytes, packages.a);
|
|
73
|
+
afterBytesB = phaseOf(afterBytes, packages.b);
|
|
74
|
+
} finally {
|
|
75
|
+
if (!keepBytes) writeFileSync(file, original);
|
|
76
|
+
}
|
|
77
|
+
if (!keepBytes) {
|
|
78
|
+
await input.ui.reconcileClientExtensions(await input.pluginManager.snapshot());
|
|
79
|
+
afterRestoreA = phaseOf(input.ui.clientExtensionObservation(), packages.a);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
op: "client-extension-loader-probe",
|
|
84
|
+
initialA: phaseOf(initial, packages.a),
|
|
85
|
+
initialB: phaseOf(initial, packages.b),
|
|
86
|
+
disable: disable.application,
|
|
87
|
+
afterDisableA: phaseOf(afterDisable, packages.a),
|
|
88
|
+
afterDisableB: phaseOf(afterDisable, packages.b),
|
|
89
|
+
enable: enable.application,
|
|
90
|
+
afterEnableA: phaseOf(afterEnable, packages.a),
|
|
91
|
+
afterEnableB: phaseOf(afterEnable, packages.b),
|
|
92
|
+
...afterBytesA === void 0 ? {} : { afterBytesA },
|
|
93
|
+
...afterBytesB === void 0 ? {} : { afterBytesB },
|
|
94
|
+
...afterRestoreA === void 0 ? {} : { afterRestoreA },
|
|
95
|
+
bytesKept: process.env.SPLIT_PROCESS_CLIENT_EXTENSION_LOADER_KEEP_BYTES === "1"
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** One qualification-only changed-bytes notification probe, run after the
|
|
99
|
+
* physical surface is ready so the REAL notification seam is live. */
|
|
100
|
+
async function runClientExtensionReloadNoticeProbe(input) {
|
|
101
|
+
const packages = probePackages();
|
|
102
|
+
if (input.pluginPackages === void 0 || input.parentURL === void 0) throw new Error("client extension notice probe: package lookup was not supplied");
|
|
103
|
+
const file = tuiFile(packages.a, input.pluginPackages, input.parentURL);
|
|
104
|
+
const original = readFileSync(file, "utf8");
|
|
105
|
+
if (!original.includes("R8-A-LIVE")) throw new Error("client extension notice probe: fixture A footer marker is missing");
|
|
106
|
+
writeFileSync(file, original.replace("R8-A-LIVE", "R8-A-NEW"));
|
|
107
|
+
try {
|
|
108
|
+
await input.ui.reconcileClientExtensions(await input.pluginManager.snapshot());
|
|
109
|
+
return {
|
|
110
|
+
op: "client-extension-reload-notice-probe",
|
|
111
|
+
phaseA: phaseOf(input.ui.clientExtensionObservation(), packages.a),
|
|
112
|
+
phaseB: phaseOf(input.ui.clientExtensionObservation(), packages.b)
|
|
113
|
+
};
|
|
114
|
+
} finally {
|
|
115
|
+
writeFileSync(file, original);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { runClientExtensionLoaderProbe, runClientExtensionReloadNoticeProbe };
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
//#region src/domain/footer/layout.ts
|
|
2
|
+
/** The per-id default `Hide in TSP` value (Owner-frozen): the three items
|
|
3
|
+
* that a capable TSP composer already carries are hidden by default; every
|
|
4
|
+
* other item keeps the historical TSP behavior. This is the EDITOR default
|
|
5
|
+
* (a capability shortage must never turn the editor's On into Off). */
|
|
6
|
+
function defaultHideInTsp(id) {
|
|
7
|
+
return id === "permission-preset" || id === "model" || id === "reasoning";
|
|
8
|
+
}
|
|
9
|
+
/** The ONE TSP effective-visibility decision for one placement. An explicit
|
|
10
|
+
* user boolean always wins; otherwise the three default-On ids hide only
|
|
11
|
+
* when their corresponding composer control is actually available (so the
|
|
12
|
+
* permission state never disappears on an old client without the control),
|
|
13
|
+
* and every other id stays visible. */
|
|
14
|
+
function hideFooterRefInTsp(ref, affordances) {
|
|
15
|
+
if (ref.hideInTsp !== void 0) return ref.hideInTsp;
|
|
16
|
+
if (!defaultHideInTsp(ref.id)) return false;
|
|
17
|
+
switch (ref.id) {
|
|
18
|
+
case "permission-preset": return affordances.permission;
|
|
19
|
+
case "model": return affordances.model;
|
|
20
|
+
case "reasoning": return affordances.reasoning;
|
|
21
|
+
default: return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** The semantic tone vocabulary a layout may reference. */
|
|
25
|
+
const TONES = /* @__PURE__ */ new Set([
|
|
26
|
+
"primary",
|
|
27
|
+
"accent",
|
|
28
|
+
"text",
|
|
29
|
+
"textStrong",
|
|
30
|
+
"textDim",
|
|
31
|
+
"textMuted",
|
|
32
|
+
"border",
|
|
33
|
+
"success",
|
|
34
|
+
"warning",
|
|
35
|
+
"error",
|
|
36
|
+
"roleUser",
|
|
37
|
+
"shellMode"
|
|
38
|
+
]);
|
|
39
|
+
const MAX_ROWS = 2;
|
|
40
|
+
const MAX_SEPARATOR_LENGTH = 8;
|
|
41
|
+
const MAX_PREFIX_SUFFIX_LENGTH = 16;
|
|
42
|
+
const MAX_IMPORTANCE = 1e3;
|
|
43
|
+
function isRecord(value) {
|
|
44
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
45
|
+
}
|
|
46
|
+
/** Terminal control characters (C0, DEL and C1): a layout is display
|
|
47
|
+
* decoration — ESC/OSC/CSI sequences must never reach the terminal through
|
|
48
|
+
* an id/prefix/suffix/separator (a project-supplied layout could otherwise
|
|
49
|
+
* inject title/clipboard/cursor/screen sequences — including through the
|
|
50
|
+
* configurator's unknown-id label fallback, which renders a raw id). */
|
|
51
|
+
const CONTROL_CHARS = /[\u0000-\u001f\u007f-\u009f]/;
|
|
52
|
+
/** The GLOBAL form, used only for stripping (a non-global replace removes
|
|
53
|
+
* just the FIRST control character — the `.test()` callers above must
|
|
54
|
+
* keep the non-global regex: a global one is stateful across calls). */
|
|
55
|
+
const CONTROL_CHARS_GLOBAL = /[\u0000-\u001f\u007f-\u009f]/g;
|
|
56
|
+
/** Strip EVERY terminal control character from display text (the
|
|
57
|
+
* configurator's unknown-item label fallback: a raw id must never carry
|
|
58
|
+
* ESC/OSC/C0 into the panel — the parser already rejects such ids, this
|
|
59
|
+
* is defense in depth for any other id source). */
|
|
60
|
+
function stripControlChars(text) {
|
|
61
|
+
return text.replace(CONTROL_CHARS_GLOBAL, "");
|
|
62
|
+
}
|
|
63
|
+
/** Narrow a parse result onto the error arm (the ref type has no kind). */
|
|
64
|
+
function isError(value) {
|
|
65
|
+
return value.kind === "error";
|
|
66
|
+
}
|
|
67
|
+
function parseItemRef(input, index) {
|
|
68
|
+
if (!isRecord(input)) return {
|
|
69
|
+
kind: "error",
|
|
70
|
+
message: `item ${index}: expected an object`
|
|
71
|
+
};
|
|
72
|
+
const id = input.id;
|
|
73
|
+
if (typeof id !== "string" || id.trim() === "") return {
|
|
74
|
+
kind: "error",
|
|
75
|
+
message: `item ${index}: id must be a non-empty string`
|
|
76
|
+
};
|
|
77
|
+
if (CONTROL_CHARS.test(id)) return {
|
|
78
|
+
kind: "error",
|
|
79
|
+
message: `item ${index}: id must not contain terminal control characters`
|
|
80
|
+
};
|
|
81
|
+
const ref = { id };
|
|
82
|
+
if (input.format !== void 0) {
|
|
83
|
+
if (typeof input.format !== "string") return {
|
|
84
|
+
kind: "error",
|
|
85
|
+
message: `item ${index}: format must be a string`
|
|
86
|
+
};
|
|
87
|
+
ref.format = input.format;
|
|
88
|
+
}
|
|
89
|
+
if (input.tone !== void 0) {
|
|
90
|
+
if (typeof input.tone !== "string" || input.tone !== "auto" && !TONES.has(input.tone)) return {
|
|
91
|
+
kind: "error",
|
|
92
|
+
message: `item ${index}: unknown tone "${String(input.tone)}"`
|
|
93
|
+
};
|
|
94
|
+
ref.tone = input.tone;
|
|
95
|
+
}
|
|
96
|
+
if (input.prefix !== void 0) {
|
|
97
|
+
if (typeof input.prefix !== "string" || input.prefix.length > MAX_PREFIX_SUFFIX_LENGTH) return {
|
|
98
|
+
kind: "error",
|
|
99
|
+
message: `item ${index}: prefix must be a string of at most ${MAX_PREFIX_SUFFIX_LENGTH} chars`
|
|
100
|
+
};
|
|
101
|
+
if (CONTROL_CHARS.test(input.prefix)) return {
|
|
102
|
+
kind: "error",
|
|
103
|
+
message: `item ${index}: prefix must not contain terminal control characters`
|
|
104
|
+
};
|
|
105
|
+
ref.prefix = input.prefix;
|
|
106
|
+
}
|
|
107
|
+
if (input.suffix !== void 0) {
|
|
108
|
+
if (typeof input.suffix !== "string" || input.suffix.length > MAX_PREFIX_SUFFIX_LENGTH) return {
|
|
109
|
+
kind: "error",
|
|
110
|
+
message: `item ${index}: suffix must be a string of at most ${MAX_PREFIX_SUFFIX_LENGTH} chars`
|
|
111
|
+
};
|
|
112
|
+
if (CONTROL_CHARS.test(input.suffix)) return {
|
|
113
|
+
kind: "error",
|
|
114
|
+
message: `item ${index}: suffix must not contain terminal control characters`
|
|
115
|
+
};
|
|
116
|
+
ref.suffix = input.suffix;
|
|
117
|
+
}
|
|
118
|
+
if (input.importance !== void 0) {
|
|
119
|
+
if (typeof input.importance !== "number" || !Number.isFinite(input.importance) || input.importance < 0 || input.importance > MAX_IMPORTANCE) return {
|
|
120
|
+
kind: "error",
|
|
121
|
+
message: `item ${index}: importance must be a number in 0..${MAX_IMPORTANCE}`
|
|
122
|
+
};
|
|
123
|
+
ref.importance = input.importance;
|
|
124
|
+
}
|
|
125
|
+
if (input.hideInTsp !== void 0) {
|
|
126
|
+
if (typeof input.hideInTsp !== "boolean") return {
|
|
127
|
+
kind: "error",
|
|
128
|
+
message: `item ${index}: hideInTsp must be a boolean`
|
|
129
|
+
};
|
|
130
|
+
ref.hideInTsp = input.hideInTsp;
|
|
131
|
+
}
|
|
132
|
+
return ref;
|
|
133
|
+
}
|
|
134
|
+
function parseRow(input, index) {
|
|
135
|
+
if (!isRecord(input)) return {
|
|
136
|
+
kind: "error",
|
|
137
|
+
message: `row ${index}: expected an object`
|
|
138
|
+
};
|
|
139
|
+
const leftInput = input.left === void 0 ? [] : input.left;
|
|
140
|
+
const rightInput = input.right === void 0 ? [] : input.right;
|
|
141
|
+
if (!Array.isArray(leftInput) || !Array.isArray(rightInput)) return {
|
|
142
|
+
kind: "error",
|
|
143
|
+
message: `row ${index}: left/right must be arrays`
|
|
144
|
+
};
|
|
145
|
+
if (leftInput.length + rightInput.length > 32) return {
|
|
146
|
+
kind: "error",
|
|
147
|
+
message: `row ${index}: more than 32 items`
|
|
148
|
+
};
|
|
149
|
+
const left = [];
|
|
150
|
+
for (let i = 0; i < leftInput.length; i += 1) {
|
|
151
|
+
const item = parseItemRef(leftInput[i], i);
|
|
152
|
+
if (isError(item)) return item;
|
|
153
|
+
left.push(item);
|
|
154
|
+
}
|
|
155
|
+
const right = [];
|
|
156
|
+
for (let i = 0; i < rightInput.length; i += 1) {
|
|
157
|
+
const item = parseItemRef(rightInput[i], i);
|
|
158
|
+
if (isError(item)) return item;
|
|
159
|
+
right.push(item);
|
|
160
|
+
}
|
|
161
|
+
const row = {
|
|
162
|
+
left,
|
|
163
|
+
right
|
|
164
|
+
};
|
|
165
|
+
if (input.separator !== void 0) {
|
|
166
|
+
if (!isRecord(input.separator)) return {
|
|
167
|
+
kind: "error",
|
|
168
|
+
message: `row ${index}: separator must be an object`
|
|
169
|
+
};
|
|
170
|
+
const text = input.separator.text;
|
|
171
|
+
if (text === void 0) {} else if (typeof text !== "string" || text.length > MAX_SEPARATOR_LENGTH) return {
|
|
172
|
+
kind: "error",
|
|
173
|
+
message: `row ${index}: separator text must be a string of at most ${MAX_SEPARATOR_LENGTH} chars`
|
|
174
|
+
};
|
|
175
|
+
else {
|
|
176
|
+
if (CONTROL_CHARS.test(text)) return {
|
|
177
|
+
kind: "error",
|
|
178
|
+
message: `row ${index}: separator text must not contain terminal control characters`
|
|
179
|
+
};
|
|
180
|
+
row.separator = { text };
|
|
181
|
+
if (input.separator.tone !== void 0) {
|
|
182
|
+
if (typeof input.separator.tone !== "string" || !TONES.has(input.separator.tone)) return {
|
|
183
|
+
kind: "error",
|
|
184
|
+
message: `row ${index}: unknown separator tone "${String(input.separator.tone)}"`
|
|
185
|
+
};
|
|
186
|
+
row.separator.tone = input.separator.tone;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return row;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Parse and validate a persisted footerLayout value.
|
|
194
|
+
* @param input - the raw settings value (unknown — never trusted).
|
|
195
|
+
* @returns the validated layout or a fail-soft error.
|
|
196
|
+
*/
|
|
197
|
+
function parseFooterLayout(input) {
|
|
198
|
+
if (!isRecord(input)) return {
|
|
199
|
+
kind: "error",
|
|
200
|
+
message: "footerLayout must be an object"
|
|
201
|
+
};
|
|
202
|
+
if (input.schemaVersion !== 1) return {
|
|
203
|
+
kind: "error",
|
|
204
|
+
message: `unsupported footerLayout schemaVersion ${String(input.schemaVersion)}`
|
|
205
|
+
};
|
|
206
|
+
if (!Array.isArray(input.rows)) return {
|
|
207
|
+
kind: "error",
|
|
208
|
+
message: "footerLayout.rows must be an array"
|
|
209
|
+
};
|
|
210
|
+
if (input.rows.length < 1 || input.rows.length > MAX_ROWS) return {
|
|
211
|
+
kind: "error",
|
|
212
|
+
message: `footerLayout must have 1..${MAX_ROWS} rows`
|
|
213
|
+
};
|
|
214
|
+
const rows = [];
|
|
215
|
+
for (let i = 0; i < input.rows.length; i += 1) {
|
|
216
|
+
const row = parseRow(input.rows[i], i);
|
|
217
|
+
if (isError(row)) return row;
|
|
218
|
+
rows.push(row);
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
schemaVersion: 1,
|
|
222
|
+
rows
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/** Whether a parsed value is a valid layout (not an error). */
|
|
226
|
+
function isFooterLayout(value) {
|
|
227
|
+
return !isError(value);
|
|
228
|
+
}
|
|
229
|
+
/** M5: resolve the command surface's native fallback from the PERSISTED
|
|
230
|
+
* document. The resolution is explicit and restart-proof: 'compact' keeps
|
|
231
|
+
* the compact preset; 'custom' uses the persisted custom layout (an
|
|
232
|
+
* invalid one degrades to the builtin default — the APPLY side then
|
|
233
|
+
* resets to the full preset); 'default' (or an absent field — existing
|
|
234
|
+
* documents predate the field) resolves to the builtin default, which the
|
|
235
|
+
* apply side restores EXPLICITLY (never "whatever the memory holds").
|
|
236
|
+
* Never reads in-memory state. */
|
|
237
|
+
function resolveCommandFooterFallback(doc) {
|
|
238
|
+
if (doc?.footerFallbackMode === "compact") return {
|
|
239
|
+
mode: "compact",
|
|
240
|
+
layout: void 0
|
|
241
|
+
};
|
|
242
|
+
if (doc?.footerFallbackMode === "custom") {
|
|
243
|
+
const parsed = parseFooterLayout(doc.footerLayout);
|
|
244
|
+
return {
|
|
245
|
+
mode: "custom",
|
|
246
|
+
layout: isFooterLayout(parsed) ? parsed : void 0
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
mode: "default",
|
|
251
|
+
layout: void 0
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/domain/footer/command-config.ts
|
|
256
|
+
/** The timeout ceiling. */
|
|
257
|
+
const MAX_COMMAND_TIMEOUT_MS = 1e3;
|
|
258
|
+
/** The minimum refresh interval (plan §17.7). */
|
|
259
|
+
const MIN_COMMAND_REFRESH_MS = 1e3;
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/domain/footer/command-trust.ts
|
|
262
|
+
/**
|
|
263
|
+
* The footer command TRUST GATE (plan §17.4): a repository/project config
|
|
264
|
+
* must NEVER silently trigger arbitrary shell execution. The command is
|
|
265
|
+
* read ONLY from the settings descriptor's USER layer (the stored
|
|
266
|
+
* document's user section) — never from the merged/resolved value, which
|
|
267
|
+
* a project layer could influence. When the user layer cannot prove the
|
|
268
|
+
* command, command mode is disabled and the native layout applies.
|
|
269
|
+
* @module @xmoon76/dsh-pi-tui/domain/footer/command-trust
|
|
270
|
+
*/
|
|
271
|
+
/** Validate the persisted footerCommand value (bounds per plan §17.3). */
|
|
272
|
+
function parseFooterCommandConfig(input) {
|
|
273
|
+
if (typeof input !== "object" || input === null) return void 0;
|
|
274
|
+
const raw = input;
|
|
275
|
+
if (raw.schemaVersion !== 1) return void 0;
|
|
276
|
+
if (typeof raw.command !== "string" || raw.command.trim() === "") return void 0;
|
|
277
|
+
if (/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/.test(raw.command)) return void 0;
|
|
278
|
+
const timeoutMs = raw.timeoutMs === void 0 ? 300 : typeof raw.timeoutMs === "number" && Number.isFinite(raw.timeoutMs) ? Math.min(Math.max(1, raw.timeoutMs), MAX_COMMAND_TIMEOUT_MS) : 300;
|
|
279
|
+
const refreshIntervalMs = raw.refreshIntervalMs === void 0 ? MIN_COMMAND_REFRESH_MS : typeof raw.refreshIntervalMs === "number" && Number.isFinite(raw.refreshIntervalMs) ? Math.max(MIN_COMMAND_REFRESH_MS, raw.refreshIntervalMs) : MIN_COMMAND_REFRESH_MS;
|
|
280
|
+
const maxRows = raw.maxRows === void 0 ? 1 : typeof raw.maxRows === "number" && Number.isFinite(raw.maxRows) ? Math.min(Math.max(1, Math.floor(raw.maxRows)), 2) : 1;
|
|
281
|
+
return {
|
|
282
|
+
command: raw.command,
|
|
283
|
+
timeoutMs,
|
|
284
|
+
refreshIntervalMs,
|
|
285
|
+
maxRows
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Resolve the TRUSTED command config: the footerCommand value must be
|
|
290
|
+
* present in the USER layer of the tui-app settings descriptor. A
|
|
291
|
+
* merged/project-supplied value is refused (undefined = command mode
|
|
292
|
+
* disabled, native fallback, diagnostic warning).
|
|
293
|
+
* @param descriptors - the settings provider's describe() output.
|
|
294
|
+
* @param namespace - the tui-app settings/profile Config namespace value.
|
|
295
|
+
* @returns the validated config, or undefined when untrusted/invalid.
|
|
296
|
+
*/
|
|
297
|
+
function resolveTrustedFooterCommand(descriptors, namespace) {
|
|
298
|
+
if (descriptors === void 0) return void 0;
|
|
299
|
+
const descriptor = descriptors.find((entry) => entry.ns === namespace);
|
|
300
|
+
if (descriptor === void 0) return void 0;
|
|
301
|
+
const user = descriptor.user;
|
|
302
|
+
if (typeof user !== "object" || user === null) return void 0;
|
|
303
|
+
const raw = user.footerCommand;
|
|
304
|
+
return parseFooterCommandConfig(raw);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Resolve the USER layer's declared footer mode. Command mode must be
|
|
308
|
+
* user-layer-owned as well: a project can flip the MERGED `footer:
|
|
309
|
+
* command`, but the gate never lets a project config silently trigger the
|
|
310
|
+
* user's command — the user layer must declare the command mode too.
|
|
311
|
+
* @returns the user layer's footer value, or undefined when absent.
|
|
312
|
+
*/
|
|
313
|
+
function resolveUserLayerFooterMode(descriptors, namespace) {
|
|
314
|
+
if (descriptors === void 0) return void 0;
|
|
315
|
+
const descriptor = descriptors.find((entry) => entry.ns === namespace);
|
|
316
|
+
if (descriptor === void 0) return void 0;
|
|
317
|
+
const user = descriptor.user;
|
|
318
|
+
if (typeof user !== "object" || user === null) return void 0;
|
|
319
|
+
const mode = user.footer;
|
|
320
|
+
return typeof mode === "string" ? mode : void 0;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Resolve the USER layer's declared custom layout (PR D activation trust):
|
|
324
|
+
* the layout whose refs MAY authorize custom command items — but only
|
|
325
|
+
* while the USER layer itself declares footer: custom (see
|
|
326
|
+
* resolveUserCommandItemActivationIds). A project can supply a MERGED
|
|
327
|
+
* `footerLayout` for rendering, but it can never activate a dormant USER
|
|
328
|
+
* command — the same principle as the command-mode gate above: the user
|
|
329
|
+
* layer must own the layout that decides what executes.
|
|
330
|
+
* @returns the validated USER-layer layout, or undefined when absent or
|
|
331
|
+
* invalid (an invalid user layout authorizes nothing — fail-safe).
|
|
332
|
+
*/
|
|
333
|
+
function resolveUserLayerFooterLayout(descriptors, namespace) {
|
|
334
|
+
if (descriptors === void 0) return void 0;
|
|
335
|
+
const descriptor = descriptors.find((entry) => entry.ns === namespace);
|
|
336
|
+
if (descriptor === void 0) return void 0;
|
|
337
|
+
const user = descriptor.user;
|
|
338
|
+
if (typeof user !== "object" || user === null) return void 0;
|
|
339
|
+
const layout = user.footerLayout;
|
|
340
|
+
const parsed = parseFooterLayout(layout);
|
|
341
|
+
return isFooterLayout(parsed) ? parsed : void 0;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Resolve the USER layer's declared footerFallbackMode (the native mode
|
|
345
|
+
* the user's own command-mode fallback restores).
|
|
346
|
+
*/
|
|
347
|
+
function resolveUserLayerFooterFallbackMode(descriptors, namespace) {
|
|
348
|
+
if (descriptors === void 0) return void 0;
|
|
349
|
+
const descriptor = descriptors.find((entry) => entry.ns === namespace);
|
|
350
|
+
if (descriptor === void 0) return void 0;
|
|
351
|
+
const user = descriptor.user;
|
|
352
|
+
if (typeof user !== "object" || user === null) return void 0;
|
|
353
|
+
const mode = user.footerFallbackMode;
|
|
354
|
+
return typeof mode === "string" ? mode : void 0;
|
|
355
|
+
}
|
|
356
|
+
/** The shared empty authorization set. */
|
|
357
|
+
const EMPTY_IDS = /* @__PURE__ */ new Set();
|
|
358
|
+
/** Every item id a layout references (the authorization projection). */
|
|
359
|
+
function layoutRefIds(layout) {
|
|
360
|
+
const ids = /* @__PURE__ */ new Set();
|
|
361
|
+
for (const row of layout.rows) {
|
|
362
|
+
for (const ref of row.left) ids.add(ref.id);
|
|
363
|
+
for (const ref of row.right) ids.add(ref.id);
|
|
364
|
+
}
|
|
365
|
+
return ids;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* The ids the USER layer AUTHORIZES for custom command item execution
|
|
369
|
+
* (PR D activation trust, mode-gated): the USER custom layout's refs, but
|
|
370
|
+
* ONLY while the USER layer itself declares `footer: custom`. A stale
|
|
371
|
+
* leftover layout under `footer: default/compact` (the /settings switch
|
|
372
|
+
* deliberately keeps the old layout) authorizes NOTHING — a project
|
|
373
|
+
* flipping the MERGED mode to custom can never resurrect a dormant USER
|
|
374
|
+
* command. `footer: command` authorizes nothing while the whole-footer
|
|
375
|
+
* command surface runs (the caller suspends per-item runners); the native
|
|
376
|
+
* fallback case uses resolveUserCommandItemFallbackActivationIds.
|
|
377
|
+
*/
|
|
378
|
+
function resolveUserCommandItemActivationIds(descriptors, namespace) {
|
|
379
|
+
if (resolveUserLayerFooterMode(descriptors, namespace) !== "custom") return EMPTY_IDS;
|
|
380
|
+
const layout = resolveUserLayerFooterLayout(descriptors, namespace);
|
|
381
|
+
return layout === void 0 ? EMPTY_IDS : layoutRefIds(layout);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* The ids authorized for the native FALLBACK surface (a merged
|
|
385
|
+
* `footer: command` the USER layer does not own). The FULL semantic is
|
|
386
|
+
* encoded HERE so no caller can forget the outer mode gate:
|
|
387
|
+
*
|
|
388
|
+
* USER footer === 'command'
|
|
389
|
+
* && USER footerFallbackMode === 'custom'
|
|
390
|
+
* && valid USER footerLayout
|
|
391
|
+
* → the layout's refs
|
|
392
|
+
* otherwise → empty
|
|
393
|
+
*
|
|
394
|
+
* A USER who never opted into command mode (footer: default/compact)
|
|
395
|
+
* authorizes NOTHING even with stale fallback metadata; a PROJECT
|
|
396
|
+
* forcing the merged command mode can never turn it into execution
|
|
397
|
+
* authorization.
|
|
398
|
+
*/
|
|
399
|
+
function resolveUserCommandItemFallbackActivationIds(descriptors, namespace) {
|
|
400
|
+
if (resolveUserLayerFooterMode(descriptors, namespace) !== "command") return EMPTY_IDS;
|
|
401
|
+
if (resolveUserLayerFooterFallbackMode(descriptors, namespace) !== "custom") return EMPTY_IDS;
|
|
402
|
+
const layout = resolveUserLayerFooterLayout(descriptors, namespace);
|
|
403
|
+
return layout === void 0 ? EMPTY_IDS : layoutRefIds(layout);
|
|
404
|
+
}
|
|
405
|
+
//#endregion
|
|
406
|
+
export { resolveUserLayerFooterMode as a, hideFooterRefInTsp as c, resolveCommandFooterFallback as d, stripControlChars as f, resolveUserCommandItemFallbackActivationIds as i, isFooterLayout as l, resolveTrustedFooterCommand as n, MAX_COMMAND_TIMEOUT_MS as o, resolveUserCommandItemActivationIds as r, defaultHideInTsp as s, parseFooterCommandConfig as t, parseFooterLayout as u };
|