@xmoon76/dsh-pi-tui 0.5.5 → 0.5.6
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 +30 -47
- package/README.md +30 -30
- package/cordis.patch.yml +77 -7
- package/dist/{bootstrap-DLOydLLj.mjs → bootstrap-DQ4YPL-7.mjs} +12416 -7243
- package/dist/builtins.mjs +3 -8
- package/dist/{application-runtime-CbBO4bY-.mjs → client-bootstrap-Cr1JCaF5.mjs} +3098 -1747
- package/dist/{dist-C7QMk0ws.mjs → dist-CIsR7cz4.mjs} +510 -224
- package/dist/{extensions-pcFiH7Qe.mjs → extensions-Bp0L37lP.mjs} +527 -249
- package/dist/extensions.mjs +1 -1
- package/dist/{host-bootstrap-CKdfLkNS.mjs → host-bootstrap-DilsvA6f.mjs} +106 -13
- package/dist/host-foundation-probe--5jtvHVe.mjs +413 -0
- package/dist/host-runtime.d.mts +10 -6
- package/dist/host-runtime.mjs +877 -10
- package/dist/index.d.mts +11 -17
- package/dist/index.mjs +13328 -6828
- package/dist/local-client.mjs +408 -61
- package/dist/{local-discovery-CXnLT4GF.mjs → local-discovery-C9VMjc0K.mjs} +10 -6
- package/dist/{local-discovery-DVFFpfBG.mjs → local-discovery-CDaQHA_R.mjs} +1 -1
- package/dist/local-host.mjs +188 -36
- package/dist/{local-transport-C9aonplC.mjs → local-transport-BVwFYq_Y.mjs} +1 -1
- package/dist/{context-summary-D9mhxPXL.mjs → pasted-path-range-CMnxuGPx.mjs} +6166 -227
- package/dist/{context-summary-Bz0AGXa1.mjs → pasted-path-range-r6qzV_tC.mjs} +5927 -444
- package/dist/{pi-tui-remote-contribution-DRk6Tl3J.mjs → pi-tui-remote-contribution-B0EQsP0N.mjs} +27 -20
- package/dist/{pi-tui-terminal-progress-contract-XTQKj-WW.mjs → pi-tui-terminal-progress-contract-MLXZ-i3t.mjs} +2 -2
- package/dist/pi-tui-web-access-contract-BN8Cc_Ho.mjs +118 -0
- package/dist/{runtime-status-0lp9CM0V.mjs → runtime-status-Cj1nFOdS.mjs} +72 -214
- package/dist/{session-4keoXjk0.mjs → session-BKGXyh80.mjs} +7487 -2562
- package/dist/{session-B2zqv4wr.mjs → session-CPt_U8_f.mjs} +7486 -2560
- package/dist/{startup-Ct2UUjUL.mjs → startup-7BYWuvBU.mjs} +121 -6
- package/dist/startup.mjs +1 -1
- package/dist/{terminal-progress-source-BhufrZ74.mjs → terminal-progress-source-DrqQhtT8.mjs} +305 -45
- package/dist/visual-tools.d.mts +2 -2
- package/dist/visual-tools.mjs +26 -31
- package/dist/web-preferences.d.mts +29 -0
- package/dist/web-preferences.mjs +15 -0
- package/dist/web-roster-CjqnUXNk.mjs +285 -0
- package/generated/dsh-presets/cordis.patch.yml +5 -3
- package/generated/dsh-presets/ptc.patch.yml +7 -7
- package/generated/dsh-presets/standard.patch.yml +6 -4
- package/package.json +182 -168
- package/dist/client-bootstrap-DwSFzcTW.mjs +0 -872
- package/dist/custom-items-CKrOBCox.mjs +0 -655
- package/dist/dispose-cause-BzcXo4hu.mjs +0 -123
- package/dist/host-foundation-probe-CYHsbAw6.mjs +0 -143
- package/dist/host-prerequisites-9JBTtVNu.mjs +0 -36
- package/dist/runtime-Bh5OsftD.mjs +0 -6798
- package/dist/runtime-C5ROZqFj.mjs +0 -2
- package/dist/terminal-progress-source-CsBinCJ_.mjs +0 -965
package/dist/host-runtime.mjs
CHANGED
|
@@ -1,6 +1,233 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { i as PI_TUI_FILE_REFERENCES_NAMESPACE, r as PI_TUI_HOST_CONTRIBUTION, t as mergeCause } from "./dispose-cause-BzcXo4hu.mjs";
|
|
1
|
+
import { a as DirectHostDiscoveryDriver, i as listPiTuiHostFileReferences, n as PI_TUI_TERMINAL_PROGRESS_WATCH, o as hostPathQueryEnvironment, r as createTerminalProgressInterval, t as PI_TUI_TERMINAL_PROGRESS_NAMESPACE } from "./pi-tui-terminal-progress-contract-MLXZ-i3t.mjs";
|
|
3
2
|
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
3
|
+
//#region src/runtime/remote/pi-tui-file-reference-contract.ts
|
|
4
|
+
/** The wire namespace (and Host Cordis service key) of the augmentation. */
|
|
5
|
+
const PI_TUI_FILE_REFERENCES_NAMESPACE = "piTuiFileReferences";
|
|
6
|
+
/** The private method's stable endpoint identity. */
|
|
7
|
+
const PI_TUI_FILE_REFERENCES_LIST_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiFileReferences/list";
|
|
8
|
+
/** One strict JSON codec that validates a wire string. */
|
|
9
|
+
function stringCodec(typeSymbol) {
|
|
10
|
+
return {
|
|
11
|
+
mode: "strict",
|
|
12
|
+
typeSymbol,
|
|
13
|
+
create: () => ({ parse: (value) => {
|
|
14
|
+
if (typeof value !== "string") throw new TypeError(`${typeSymbol}: the wire value must be a string`);
|
|
15
|
+
return value;
|
|
16
|
+
} })
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validate and detach one wire `HostFileListResult`. The result is produced by
|
|
21
|
+
* this package's own Host router, but it is still a wire boundary on the Client
|
|
22
|
+
* and the ONLY place the shape crosses.
|
|
23
|
+
*/
|
|
24
|
+
function decodeHostFileListResult(value) {
|
|
25
|
+
if (typeof value !== "object" || value === null) throw new TypeError("piTuiFileReferences/list: the result must be an object");
|
|
26
|
+
const record = value;
|
|
27
|
+
if (record.kind === "unavailable") {
|
|
28
|
+
if (typeof record.reason !== "string") throw new TypeError("piTuiFileReferences/list: an unavailable result needs a reason");
|
|
29
|
+
return {
|
|
30
|
+
kind: "unavailable",
|
|
31
|
+
reason: record.reason
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (record.kind !== "ok" || !Array.isArray(record.items)) throw new TypeError("piTuiFileReferences/list: the result must be ok(items) or unavailable(reason)");
|
|
35
|
+
return {
|
|
36
|
+
kind: "ok",
|
|
37
|
+
items: record.items.map((entry) => {
|
|
38
|
+
if (typeof entry !== "object" || entry === null) throw new TypeError("piTuiFileReferences/list: every candidate must be an object");
|
|
39
|
+
const candidate = entry;
|
|
40
|
+
if (typeof candidate.path !== "string" || candidate.kind !== "file" && candidate.kind !== "directory") throw new TypeError("piTuiFileReferences/list: every candidate needs a string path and a file/directory kind");
|
|
41
|
+
return {
|
|
42
|
+
path: candidate.path,
|
|
43
|
+
kind: candidate.kind
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const HOST_FILE_LIST_RESULT_CODEC = {
|
|
49
|
+
mode: "strict",
|
|
50
|
+
typeSymbol: "@xmoon76/dsh-pi-tui#piTuiFileReferences/list:result",
|
|
51
|
+
create: () => ({ parse: decodeHostFileListResult }),
|
|
52
|
+
decode: decodeHostFileListResult
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The ONE shared invocation descriptor both contributions derive from. The
|
|
56
|
+
* Host registers this exact object; the Client mounts this exact object.
|
|
57
|
+
*/
|
|
58
|
+
const PI_TUI_FILE_REFERENCES_LIST = {
|
|
59
|
+
id: PI_TUI_FILE_REFERENCES_LIST_ENDPOINT,
|
|
60
|
+
service: PI_TUI_FILE_REFERENCES_NAMESPACE,
|
|
61
|
+
namespace: PI_TUI_FILE_REFERENCES_NAMESPACE,
|
|
62
|
+
method: "list",
|
|
63
|
+
invocation: { kind: "direct" },
|
|
64
|
+
parameters: [{
|
|
65
|
+
name: "sessionId",
|
|
66
|
+
wire: "sessionId",
|
|
67
|
+
source: "json",
|
|
68
|
+
codec: stringCodec("@xmoon76/dsh-pi-tui#piTuiFileReferences/list:sessionId")
|
|
69
|
+
}, {
|
|
70
|
+
name: "query",
|
|
71
|
+
wire: "query",
|
|
72
|
+
source: "json",
|
|
73
|
+
codec: stringCodec("@xmoon76/dsh-pi-tui#piTuiFileReferences/list:query")
|
|
74
|
+
}],
|
|
75
|
+
cancellation: { parameter: "signal" },
|
|
76
|
+
result: HOST_FILE_LIST_RESULT_CODEC
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/runtime/remote/pi-tui-web-access-contract.ts
|
|
80
|
+
/** The wire namespace (and Host Cordis service key) of the toggle. */
|
|
81
|
+
const PI_TUI_WEB_ACCESS_NAMESPACE = "piTuiWebAccess";
|
|
82
|
+
/** The status method's stable endpoint identity. */
|
|
83
|
+
const PI_TUI_WEB_ACCESS_GET_STATUS_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiWebAccess/getStatus";
|
|
84
|
+
/** The mutation method's stable endpoint identity. */
|
|
85
|
+
const PI_TUI_WEB_ACCESS_SET_ENABLED_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiWebAccess/setEnabled";
|
|
86
|
+
/** The authenticated-URL method's stable endpoint identity. */
|
|
87
|
+
const PI_TUI_WEB_ACCESS_GET_AUTHENTICATED_URL_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiWebAccess/getAuthenticatedUrl";
|
|
88
|
+
/** One strict JSON codec that validates a wire boolean. */
|
|
89
|
+
const BOOLEAN_CODEC = {
|
|
90
|
+
mode: "strict",
|
|
91
|
+
typeSymbol: "@xmoon76/dsh-pi-tui#piTuiWebAccess/setEnabled:enabled",
|
|
92
|
+
create: () => ({ parse: (value) => {
|
|
93
|
+
if (typeof value !== "boolean") throw new TypeError("piTuiWebAccess/setEnabled: the wire value must be a boolean");
|
|
94
|
+
return value;
|
|
95
|
+
} })
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Validate and detach one wire `PiTuiWebAccessStatus`. The status is produced by
|
|
99
|
+
* this package's own Host service, but it is still a wire boundary on the
|
|
100
|
+
* Client and the ONLY place the shape crosses.
|
|
101
|
+
*/
|
|
102
|
+
function parsePiTuiWebAccessStatus(value) {
|
|
103
|
+
if (typeof value !== "object" || value === null) throw new TypeError("piTuiWebAccess: the result must be an object");
|
|
104
|
+
const record = value;
|
|
105
|
+
const field = record.state === "unavailable" ? "reason" : void 0;
|
|
106
|
+
for (const key of Object.keys(record)) if (key !== "state" && key !== field) throw new TypeError(`piTuiWebAccess: unexpected result field ${JSON.stringify(key)}`);
|
|
107
|
+
if (record.state === "disabled" || record.state === "enabled" || record.state === "changing") return { state: record.state };
|
|
108
|
+
if (record.state !== "unavailable") throw new TypeError("piTuiWebAccess: the result state must be disabled, enabled, changing or unavailable");
|
|
109
|
+
if (typeof record.reason !== "string" || record.reason === "") throw new TypeError("piTuiWebAccess: an unavailable result needs a non-empty reason");
|
|
110
|
+
return {
|
|
111
|
+
state: "unavailable",
|
|
112
|
+
reason: record.reason
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const PI_TUI_WEB_ACCESS_STATUS_CODEC = {
|
|
116
|
+
mode: "strict",
|
|
117
|
+
typeSymbol: "@xmoon76/dsh-pi-tui#piTuiWebAccess:status",
|
|
118
|
+
create: () => ({ parse: parsePiTuiWebAccessStatus }),
|
|
119
|
+
decode: parsePiTuiWebAccessStatus
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* The `getStatus` invocation both contributions derive from. The Host
|
|
123
|
+
* registers this exact object; the Client mounts this exact object.
|
|
124
|
+
*/
|
|
125
|
+
const PI_TUI_WEB_ACCESS_GET_STATUS = {
|
|
126
|
+
id: PI_TUI_WEB_ACCESS_GET_STATUS_ENDPOINT,
|
|
127
|
+
service: PI_TUI_WEB_ACCESS_NAMESPACE,
|
|
128
|
+
namespace: PI_TUI_WEB_ACCESS_NAMESPACE,
|
|
129
|
+
method: "getStatus",
|
|
130
|
+
invocation: { kind: "direct" },
|
|
131
|
+
parameters: [],
|
|
132
|
+
result: PI_TUI_WEB_ACCESS_STATUS_CODEC
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* The `setEnabled` invocation both contributions derive from. `enabled` is one
|
|
136
|
+
* required boolean: the Host Gateway decodes it through {@link BOOLEAN_CODEC},
|
|
137
|
+
* so a malformed value is refused at the wire boundary and never reaches the
|
|
138
|
+
* toggle.
|
|
139
|
+
*/
|
|
140
|
+
const PI_TUI_WEB_ACCESS_SET_ENABLED = {
|
|
141
|
+
id: PI_TUI_WEB_ACCESS_SET_ENABLED_ENDPOINT,
|
|
142
|
+
service: PI_TUI_WEB_ACCESS_NAMESPACE,
|
|
143
|
+
namespace: PI_TUI_WEB_ACCESS_NAMESPACE,
|
|
144
|
+
method: "setEnabled",
|
|
145
|
+
invocation: { kind: "direct" },
|
|
146
|
+
parameters: [{
|
|
147
|
+
name: "enabled",
|
|
148
|
+
wire: "enabled",
|
|
149
|
+
source: "json",
|
|
150
|
+
codec: BOOLEAN_CODEC
|
|
151
|
+
}],
|
|
152
|
+
result: PI_TUI_WEB_ACCESS_STATUS_CODEC
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Validate and detach one wire `PiTuiWebAccessAuthenticatedUrl`.
|
|
156
|
+
*
|
|
157
|
+
* It is the ONE place the token-carrying value crosses the wire, so the shape is
|
|
158
|
+
* parsed strictly: exactly one `url` field, a non-empty string, and an absolute
|
|
159
|
+
* `http(s)` URL. Nothing is normalized or rewritten — the Client opens/copies
|
|
160
|
+
* the official URL verbatim.
|
|
161
|
+
*/
|
|
162
|
+
function parsePiTuiWebAccessAuthenticatedUrl(value) {
|
|
163
|
+
if (typeof value !== "object" || value === null) throw new TypeError("piTuiWebAccess: the authenticated URL result must be an object");
|
|
164
|
+
const record = value;
|
|
165
|
+
for (const key of Object.keys(record)) if (key !== "url") throw new TypeError(`piTuiWebAccess: unexpected authenticated URL field ${JSON.stringify(key)}`);
|
|
166
|
+
if (typeof record.url !== "string" || record.url === "") throw new TypeError("piTuiWebAccess: the authenticated URL must be a non-empty string");
|
|
167
|
+
let parsed;
|
|
168
|
+
try {
|
|
169
|
+
parsed = new URL(record.url);
|
|
170
|
+
} catch {
|
|
171
|
+
throw new TypeError("piTuiWebAccess: the authenticated URL must be an absolute URL");
|
|
172
|
+
}
|
|
173
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new TypeError("piTuiWebAccess: the authenticated URL must be an http(s) URL");
|
|
174
|
+
return { url: record.url };
|
|
175
|
+
}
|
|
176
|
+
/** The explicit Host contribution registered once with `ctx.typert.register`. */
|
|
177
|
+
const PI_TUI_HOST_CONTRIBUTION = {
|
|
178
|
+
package: "@xmoon76/dsh-pi-tui",
|
|
179
|
+
face: "host",
|
|
180
|
+
schemas: [],
|
|
181
|
+
model: {
|
|
182
|
+
services: [],
|
|
183
|
+
events: [],
|
|
184
|
+
objects: []
|
|
185
|
+
},
|
|
186
|
+
invocations: [
|
|
187
|
+
PI_TUI_FILE_REFERENCES_LIST,
|
|
188
|
+
PI_TUI_TERMINAL_PROGRESS_WATCH,
|
|
189
|
+
PI_TUI_WEB_ACCESS_GET_STATUS,
|
|
190
|
+
PI_TUI_WEB_ACCESS_SET_ENABLED,
|
|
191
|
+
{
|
|
192
|
+
id: PI_TUI_WEB_ACCESS_GET_AUTHENTICATED_URL_ENDPOINT,
|
|
193
|
+
service: PI_TUI_WEB_ACCESS_NAMESPACE,
|
|
194
|
+
namespace: PI_TUI_WEB_ACCESS_NAMESPACE,
|
|
195
|
+
method: "getAuthenticatedUrl",
|
|
196
|
+
invocation: { kind: "direct" },
|
|
197
|
+
parameters: [],
|
|
198
|
+
result: {
|
|
199
|
+
mode: "strict",
|
|
200
|
+
typeSymbol: "@xmoon76/dsh-pi-tui#piTuiWebAccess:authenticatedUrl",
|
|
201
|
+
create: () => ({ parse: parsePiTuiWebAccessAuthenticatedUrl }),
|
|
202
|
+
decode: parsePiTuiWebAccessAuthenticatedUrl
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
};
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/app/remote/dispose-cause.ts
|
|
209
|
+
/**
|
|
210
|
+
* Transport-neutral disposal failure chaining for the Remote composition.
|
|
211
|
+
*
|
|
212
|
+
* The helper is shared by the Host composition, the official Client runtime,
|
|
213
|
+
* the Client UI subtree and the application aggregate. It deliberately lives
|
|
214
|
+
* beside them (not inside `host-runtime.ts`) so a Client-only process entry can
|
|
215
|
+
* reuse it without importing a Host-only value graph.
|
|
216
|
+
*
|
|
217
|
+
* @module app/remote/dispose-cause
|
|
218
|
+
*/
|
|
219
|
+
/**
|
|
220
|
+
* Attach one secondary failure to `failure`'s cause chain without losing an
|
|
221
|
+
* existing cause: when the failure already carries a cause, both aggregate
|
|
222
|
+
* into a single `AggregateError`. A `undefined` secondary is a no-op.
|
|
223
|
+
*/
|
|
224
|
+
function mergeCause(failure, secondary) {
|
|
225
|
+
if (secondary === void 0) return failure;
|
|
226
|
+
const existingCause = failure.cause;
|
|
227
|
+
failure.cause = existingCause === void 0 ? secondary : new AggregateError([existingCause, secondary], "remote composition: aggregated failure causes");
|
|
228
|
+
return failure;
|
|
229
|
+
}
|
|
230
|
+
//#endregion
|
|
4
231
|
//#region src/runtime/remote/pi-tui-file-reference-host-bridge.ts
|
|
5
232
|
/**
|
|
6
233
|
* The Remote Host-side bridge for the private `piTuiFileReferences` endpoint
|
|
@@ -355,13 +582,647 @@ function randomEpoch() {
|
|
|
355
582
|
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
356
583
|
}
|
|
357
584
|
//#endregion
|
|
585
|
+
//#region src/app/host/features/web-roster.ts
|
|
586
|
+
/**
|
|
587
|
+
* The ONE production Web-only Loader roster (C8: a single static member table).
|
|
588
|
+
*
|
|
589
|
+
* These are the official Browser Web rows the Host-only overlay declares and
|
|
590
|
+
* the private `piTuiWebAccess` Host service toggles at runtime. The row set is
|
|
591
|
+
* the official Web composition of the installed DSH family: it must satisfy
|
|
592
|
+
* every `dsh.client.inject` dependency the shipped official Client UIs declare,
|
|
593
|
+
* so it is fixed by those manifests rather than by a local count.
|
|
594
|
+
*
|
|
595
|
+
* PURE DATA, NO HOST DEPENDENCY: `local-host-entry.ts` renders this table into
|
|
596
|
+
* the Host-only overlay YAML, and `web-access.ts` verifies the LIVE Loader
|
|
597
|
+
* against it. The hand-written expectations stay their own oracles and must
|
|
598
|
+
* not be derived from this module: `WEB_ROWS` in
|
|
599
|
+
* `test/app/remote-process-host-foundation.test.ts` (that test imports this
|
|
600
|
+
* production table only to compare the toggle roster with the real overlay)
|
|
601
|
+
* and `PR_A_WEB_ROWS` in `scripts/smoke/split-process/web-helpers.mjs`.
|
|
602
|
+
*
|
|
603
|
+
* @module @xmoon76/dsh-pi-tui/app/host/features/web-roster
|
|
604
|
+
*/
|
|
605
|
+
/**
|
|
606
|
+
* The official Web-only Loader rows, in the overlay's canonical order, with the
|
|
607
|
+
* exact official package each row loads. The set, never a count, is the
|
|
608
|
+
* composition contract: every entry is the ONE owner of its published package.
|
|
609
|
+
*/
|
|
610
|
+
const PI_TUI_WEB_ACCESS_ROWS = [
|
|
611
|
+
{
|
|
612
|
+
id: "web-runtime",
|
|
613
|
+
name: "@deepseek-ai/dsh-web-app"
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
id: "modules",
|
|
617
|
+
name: "@deepseek-ai/dsh-client-modules"
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
id: "client-hmr",
|
|
621
|
+
name: "@deepseek-ai/dsh-client-hmr"
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
id: "cordis-client-runner",
|
|
625
|
+
name: "@deepseek-ai/dsh-cordis-client-runner"
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
id: "ui-file-actions",
|
|
629
|
+
name: "@deepseek-ai/dsh-client-ui-file-actions"
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
id: "ui-context-menu",
|
|
633
|
+
name: "@deepseek-ai/dsh-client-ui-context-menu"
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
id: "ui-open-in-app",
|
|
637
|
+
name: "@deepseek-ai/dsh-client-ui-open-in-app"
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
id: "ui-settings-account",
|
|
641
|
+
name: "@deepseek-ai/dsh-client-ui-settings-account"
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
id: "ui-theme",
|
|
645
|
+
name: "@deepseek-ai/dsh-client-ui-theme"
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
id: "locale",
|
|
649
|
+
name: "@deepseek-ai/dsh-client-locale"
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
id: "shortcuts",
|
|
653
|
+
name: "@deepseek-ai/dsh-client-shortcuts"
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
id: "ui-shortcuts",
|
|
657
|
+
name: "@deepseek-ai/dsh-client-ui-shortcuts"
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
id: "ui-layout",
|
|
661
|
+
name: "@deepseek-ai/dsh-client-ui-layout"
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
id: "ui-renderer",
|
|
665
|
+
name: "@deepseek-ai/dsh-client-ui-renderer"
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
id: "ui-session",
|
|
669
|
+
name: "@deepseek-ai/dsh-client-ui-session"
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
id: "resources",
|
|
673
|
+
name: "@deepseek-ai/dsh-client-resources"
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
id: "ui-sidebar",
|
|
677
|
+
name: "@deepseek-ai/dsh-client-ui-sidebar"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
id: "ui-sidebar-right",
|
|
681
|
+
name: "@deepseek-ai/dsh-client-ui-sidebar-right"
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
id: "office-to-pdf",
|
|
685
|
+
name: "@deepseek-ai/dsh-office-to-pdf"
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
id: "ui-sidebar-documentpreview",
|
|
689
|
+
name: "@deepseek-ai/dsh-client-ui-sidebar-documentpreview"
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
id: "ui-sidebar-terminal",
|
|
693
|
+
name: "@deepseek-ai/dsh-client-ui-sidebar-terminal"
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
id: "ui-sidebar-files",
|
|
697
|
+
name: "@deepseek-ai/dsh-client-ui-sidebar-files"
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
id: "ui-settings",
|
|
701
|
+
name: "@deepseek-ai/dsh-client-ui-settings"
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
id: "ui-settings-general",
|
|
705
|
+
name: "@deepseek-ai/dsh-client-ui-settings-general"
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
id: "ui-settings-models",
|
|
709
|
+
name: "@deepseek-ai/dsh-client-ui-settings-models"
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
id: "ui-plugin-manager",
|
|
713
|
+
name: "@deepseek-ai/dsh-client-ui-plugin-manager"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
id: "ui-settings-plugin-inventory",
|
|
717
|
+
name: "@deepseek-ai/dsh-client-ui-settings-plugin-inventory"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
id: "ui-conversation",
|
|
721
|
+
name: "@deepseek-ai/dsh-client-ui-conversation"
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
id: "ui-approval",
|
|
725
|
+
name: "@deepseek-ai/dsh-client-ui-approval"
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
id: "message-quotes",
|
|
729
|
+
name: "@deepseek-ai/dsh-message-quotes"
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
id: "ui-chat",
|
|
733
|
+
name: "@deepseek-ai/dsh-client-ui-chat"
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
id: "ui-brand-official",
|
|
737
|
+
name: "@deepseek-ai/dsh-client-ui-brand-official"
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
id: "ui-attachment",
|
|
741
|
+
name: "@deepseek-ai/dsh-client-ui-attachment"
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
id: "ui-file-drag",
|
|
745
|
+
name: "@deepseek-ai/dsh-client-ui-file-drag"
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
id: "ui-tool",
|
|
749
|
+
name: "@deepseek-ai/dsh-client-ui-tool"
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
id: "ui-cordis",
|
|
753
|
+
name: "@deepseek-ai/dsh-client-ui-cordis"
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
id: "workspace-changes",
|
|
757
|
+
name: "@deepseek-ai/dsh-workspace-changes"
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
id: "ui-deliverables",
|
|
761
|
+
name: "@deepseek-ai/dsh-client-ui-deliverables"
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
id: "ui-workspace",
|
|
765
|
+
name: "@deepseek-ai/dsh-client-ui-workspace"
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
id: "ui-workflow-run",
|
|
769
|
+
name: "@deepseek-ai/dsh-client-ui-workflow-run"
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
id: "ui-input-trigger",
|
|
773
|
+
name: "@deepseek-ai/dsh-client-ui-input-trigger"
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
id: "ui-commands",
|
|
777
|
+
name: "@deepseek-ai/dsh-client-ui-commands"
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
id: "ui-skill",
|
|
781
|
+
name: "@deepseek-ai/dsh-client-ui-skill"
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
id: "ui-subagent",
|
|
785
|
+
name: "@deepseek-ai/dsh-client-ui-subagent"
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
id: "ui-reference",
|
|
789
|
+
name: "@deepseek-ai/dsh-client-ui-reference"
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
id: "ui-secret-mask",
|
|
793
|
+
name: "@deepseek-ai/dsh-client-ui-secret-mask"
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
id: "ui-jobs",
|
|
797
|
+
name: "@deepseek-ai/dsh-client-ui-jobs"
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
id: "ui-schedule",
|
|
801
|
+
name: "@deepseek-ai/dsh-client-ui-schedule"
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
id: "ui-goal",
|
|
805
|
+
name: "@deepseek-ai/dsh-client-ui-goal"
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
id: "ui-message-feedback",
|
|
809
|
+
name: "@deepseek-ai/dsh-client-ui-message-feedback"
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
id: "ui-model-selection",
|
|
813
|
+
name: "@deepseek-ai/dsh-client-ui-model-selection"
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
id: "ui-permission",
|
|
817
|
+
name: "@deepseek-ai/dsh-client-ui-permission-presets"
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
id: "ui-agent-preset",
|
|
821
|
+
name: "@deepseek-ai/dsh-client-ui-agent-preset"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
id: "entry-customization",
|
|
825
|
+
name: "@deepseek-ai/dsh-client-ui-entry-customization"
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
id: "ui-settings-session-log",
|
|
829
|
+
name: "@deepseek-ai/dsh-client-ui-settings-session-log"
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
id: "ui-settings-plugins",
|
|
833
|
+
name: "@deepseek-ai/dsh-client-ui-settings-plugins"
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
id: "ui-settings-shell",
|
|
837
|
+
name: "@deepseek-ai/dsh-client-ui-settings-shell"
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
id: "ui-settings-agent-loop",
|
|
841
|
+
name: "@deepseek-ai/dsh-client-ui-settings-agent-loop"
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
id: "ui-settings-subagent",
|
|
845
|
+
name: "@deepseek-ai/dsh-client-ui-settings-subagent"
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
id: "ui-settings-web-search",
|
|
849
|
+
name: "@deepseek-ai/dsh-client-ui-settings-web-search"
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
id: "ui-plan",
|
|
853
|
+
name: "@deepseek-ai/dsh-client-ui-plan"
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
id: "ui-user-questions",
|
|
857
|
+
name: "@deepseek-ai/dsh-client-ui-user-questions"
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
id: "ui-trajectory",
|
|
861
|
+
name: "@deepseek-ai/dsh-client-ui-trajectory"
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
id: "terminal-controller",
|
|
865
|
+
name: "@deepseek-ai/dsh-api-terminal-controller"
|
|
866
|
+
}
|
|
867
|
+
];
|
|
868
|
+
//#endregion
|
|
869
|
+
//#region src/app/host/features/web-access.ts
|
|
870
|
+
/** Cordis `FiberState.ACTIVE` (the enum is a const enum with no runtime value). */
|
|
871
|
+
const FIBER_ACTIVE = 2;
|
|
872
|
+
/**
|
|
873
|
+
* The production Web-only Loader roster is pure data owned by
|
|
874
|
+
* `./web-roster.ts`; this service verifies the LIVE Loader against it and owns
|
|
875
|
+
* every enable/disable transition. The table is the composition expectation,
|
|
876
|
+
* never a statement that those rows are currently mounted.
|
|
877
|
+
*/
|
|
878
|
+
/**
|
|
879
|
+
* The official Web services whose live binding is what `enabled` claims:
|
|
880
|
+
* `webApp` owns the SPA fallback, `clientModules` owns the `/plugins` graph,
|
|
881
|
+
* `terminalController` is the Web Browser's Host-side terminal owner, and
|
|
882
|
+
* `officeToPdf` is the Browser document-preview conversion provider.
|
|
883
|
+
*/
|
|
884
|
+
const REQUIRED_WEB_SERVICES = [
|
|
885
|
+
"webApp",
|
|
886
|
+
"clientModules",
|
|
887
|
+
"terminalController",
|
|
888
|
+
"officeToPdf"
|
|
889
|
+
];
|
|
890
|
+
/** The Browser graph rows that must be assembled first and released last. */
|
|
891
|
+
const BROWSER_GRAPH_ROWS = [
|
|
892
|
+
"modules",
|
|
893
|
+
"client-hmr",
|
|
894
|
+
"cordis-client-runner",
|
|
895
|
+
"terminal-controller"
|
|
896
|
+
];
|
|
897
|
+
const SPA_ROW = "web-runtime";
|
|
898
|
+
/** The Browser presentation rows, in the overlay's canonical order. */
|
|
899
|
+
const PRESENTATION_ROWS = PI_TUI_WEB_ACCESS_ROWS.map((row) => row.id).filter((id) => id !== SPA_ROW && !BROWSER_GRAPH_ROWS.includes(id));
|
|
900
|
+
/**
|
|
901
|
+
* FROZEN enable order: assemble the browser graph first, then its presentation
|
|
902
|
+
* rows, and withdraw nothing — the SPA fallback is mounted LAST so the official
|
|
903
|
+
* index is never served before the graph it advertises exists.
|
|
904
|
+
*
|
|
905
|
+
* Exported because the order is a product decision, not an implementation
|
|
906
|
+
* detail: the source test asserts THIS sequence.
|
|
907
|
+
*/
|
|
908
|
+
const PI_TUI_WEB_ACCESS_ENABLE_ORDER = [
|
|
909
|
+
...BROWSER_GRAPH_ROWS,
|
|
910
|
+
...PRESENTATION_ROWS,
|
|
911
|
+
SPA_ROW
|
|
912
|
+
];
|
|
913
|
+
/**
|
|
914
|
+
* FROZEN disable order: withdraw the SPA fallback FIRST, then the presentation
|
|
915
|
+
* rows in reverse canonical order, then the browser graph rows last so
|
|
916
|
+
* `clientModules` keeps owning `/plugins` until nothing can request it.
|
|
917
|
+
*
|
|
918
|
+
* Exported for the same reason as the enable order.
|
|
919
|
+
*/
|
|
920
|
+
const PI_TUI_WEB_ACCESS_DISABLE_ORDER = [
|
|
921
|
+
SPA_ROW,
|
|
922
|
+
...[...PRESENTATION_ROWS].reverse(),
|
|
923
|
+
...[...BROWSER_GRAPH_ROWS].reverse()
|
|
924
|
+
];
|
|
925
|
+
/** The package each roster id must load, keyed by id. */
|
|
926
|
+
const ROSTER_PACKAGES = new Map(PI_TUI_WEB_ACCESS_ROWS.map((row) => [row.id, row.name]));
|
|
927
|
+
/** Every official package exactly one roster row owns. */
|
|
928
|
+
const ROSTER_PACKAGE_NAMES = new Set(PI_TUI_WEB_ACCESS_ROWS.map((row) => row.name));
|
|
929
|
+
/** Append the best-effort cleanup failures to one redacted diagnostic. */
|
|
930
|
+
function withCleanup(reason, cleanup) {
|
|
931
|
+
if (cleanup.length === 0) return reason;
|
|
932
|
+
return `${reason} (cleanup: ${cleanup.map(reasonOf).join("; ")})`;
|
|
933
|
+
}
|
|
934
|
+
/** One fixed diagnostic for the status vocabulary (never a token/URL/path). */
|
|
935
|
+
function reasonOf(error) {
|
|
936
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
937
|
+
return message.length > 300 ? `${message.slice(0, 297)}...` : message;
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* The private Web access authority. One instance per built-in Host Runtime; the
|
|
941
|
+
* service leaves with the owning fiber.
|
|
942
|
+
*/
|
|
943
|
+
var PiTuiWebAccessHostService = class extends TypertRemoteService {
|
|
944
|
+
/**
|
|
945
|
+
* The Typert registry owns the descriptors. The Host's Loader is read PER CALL
|
|
946
|
+
* (`loader()` below) instead of declared here: this service is mounted by a
|
|
947
|
+
* Loader row, so the Loader is guaranteed in every real composition, and a
|
|
948
|
+
* Host that somehow lacks one must report `unavailable` rather than hold the
|
|
949
|
+
* mounting row pending forever.
|
|
950
|
+
*/
|
|
951
|
+
static inject = ["typert"];
|
|
952
|
+
/** The serialized mutation chain: one toggle runs at a time, failures do not poison it. */
|
|
953
|
+
tail = Promise.resolve();
|
|
954
|
+
/** The number of serialized mutations currently running (the `changing` state). */
|
|
955
|
+
inFlight = 0;
|
|
956
|
+
/**
|
|
957
|
+
* The current Host lifetime's last SUCCESSFULLY requested enablement, or
|
|
958
|
+
* `undefined` before any toggle. It is a TARGET INTENT for the recomposition
|
|
959
|
+
* repair only — NEVER a state authority: `getStatus()`/`describe()` keep
|
|
960
|
+
* reading the live Loader rows and official Web services on every call.
|
|
961
|
+
*/
|
|
962
|
+
target;
|
|
963
|
+
/**
|
|
964
|
+
* @param ctx - the Host context this row is mounted in.
|
|
965
|
+
*/
|
|
966
|
+
constructor(ctx) {
|
|
967
|
+
super(ctx, PI_TUI_WEB_ACCESS_NAMESPACE);
|
|
968
|
+
ctx.on("app-boot/config-reload", () => {
|
|
969
|
+
this.reconcileAfterRecompose();
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* The private status method (`piTuiWebAccess/getStatus`, see
|
|
974
|
+
* `pi-tui-web-access-contract.ts`). Reads the live Loader rows and the
|
|
975
|
+
* official Web services on every call; never a cached flag.
|
|
976
|
+
*/
|
|
977
|
+
async getStatus() {
|
|
978
|
+
return this.inFlight > 0 ? { state: "changing" } : this.describe();
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* The private authenticated-URL method (`piTuiWebAccess/getAuthenticatedUrl`):
|
|
982
|
+
* the official launch URL of THIS Host's Web frontend, built by the official
|
|
983
|
+
* `connection.authenticatedUrl(webServer.getOrigin() + '/')`.
|
|
984
|
+
*
|
|
985
|
+
* It answers ONLY while the live roster/status is `enabled`. The value carries
|
|
986
|
+
* the official launch token, so this method never stores it, never adds it to
|
|
987
|
+
* a status object and never writes it to a diagnostic: the caller (one
|
|
988
|
+
* explicit user action) is the only owner.
|
|
989
|
+
*
|
|
990
|
+
* @returns the official authenticated URL of the running Web frontend.
|
|
991
|
+
*/
|
|
992
|
+
async getAuthenticatedUrl() {
|
|
993
|
+
const status = await this.getStatus();
|
|
994
|
+
if (status.state !== "enabled") throw new Error(status.state === "unavailable" ? `web access: the official Web frontend is unavailable (${status.reason})` : "web access: the official Web frontend is not enabled");
|
|
995
|
+
const connection = this.ctx.get("connection");
|
|
996
|
+
if (connection === void 0 || typeof connection.authenticatedUrl !== "function") throw new Error("web access: the Host has no official Connection service");
|
|
997
|
+
const webServer = this.ctx.get("webServer");
|
|
998
|
+
if (webServer === void 0 || typeof webServer.getOrigin !== "function") throw new Error("web access: the Host has no official WebServer service");
|
|
999
|
+
return { url: connection.authenticatedUrl(`${webServer.getOrigin()}/`) };
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* The private mutation method (`piTuiWebAccess/setEnabled`). Idempotent: a
|
|
1003
|
+
* request for the already-settled state touches no row. Concurrent requests
|
|
1004
|
+
* are serialized in ONE Host-owned promise queue, and a failed mutation never
|
|
1005
|
+
* poisons the following entries.
|
|
1006
|
+
*
|
|
1007
|
+
* @param enabled - whether the official Web frontend must be serving.
|
|
1008
|
+
* @returns the status the Host actually reached, never the requested boolean.
|
|
1009
|
+
*/
|
|
1010
|
+
setEnabled(enabled) {
|
|
1011
|
+
const run = this.tail.then(() => this.applyAndTrack(enabled));
|
|
1012
|
+
this.tail = run.then(() => void 0, () => void 0);
|
|
1013
|
+
return run;
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* One serialized mutation that updates the target intent ONLY when the Host
|
|
1017
|
+
* really reached the requested state. A failed/partial mutation leaves the
|
|
1018
|
+
* previous successful intent in place and reports its reached state.
|
|
1019
|
+
*/
|
|
1020
|
+
async applyAndTrack(enabled) {
|
|
1021
|
+
const status = await this.apply(enabled);
|
|
1022
|
+
if (status.state === (enabled ? "enabled" : "disabled")) this.target = enabled ? "enabled" : "disabled";
|
|
1023
|
+
return status;
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Repair the live roster after the official profile recomposition.
|
|
1027
|
+
*
|
|
1028
|
+
* The listener runs synchronously and only ENQUEUES the repair on the same
|
|
1029
|
+
* serialized chain (the official emit does not await promises, and a settings
|
|
1030
|
+
* write also reconciles before and after its own write). The LATEST target is
|
|
1031
|
+
* re-read when the repair actually runs, so a user toggle admitted later wins
|
|
1032
|
+
* in FIFO order. No repair runs before the first successful toggle, and a
|
|
1033
|
+
* failed repair is reported by the live status (never a fabricated success).
|
|
1034
|
+
*/
|
|
1035
|
+
reconcileAfterRecompose() {
|
|
1036
|
+
const run = this.tail.then(() => {
|
|
1037
|
+
const target = this.target;
|
|
1038
|
+
if (target === void 0) return this.describe();
|
|
1039
|
+
const status = this.describe();
|
|
1040
|
+
if (status.state === target) return status;
|
|
1041
|
+
return this.applyAndTrack(target === "enabled");
|
|
1042
|
+
});
|
|
1043
|
+
this.tail = run.then(() => void 0, () => void 0);
|
|
1044
|
+
run.then((status) => {
|
|
1045
|
+
if (status.state === "unavailable") this.logger().warn("profile recomposition repair did not reach the live target", { state: status.state });
|
|
1046
|
+
}, (error) => {
|
|
1047
|
+
this.logger().warn("profile recomposition repair failed", { reason: reasonOf(error) });
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
/** The row's own Cordis logger (diagnostics only; never a state channel). */
|
|
1051
|
+
logger() {
|
|
1052
|
+
return this.ctx.logger("pi-tui-web-access");
|
|
1053
|
+
}
|
|
1054
|
+
/** Run one serialized mutation and always report the reached state. */
|
|
1055
|
+
async apply(enabled) {
|
|
1056
|
+
this.inFlight += 1;
|
|
1057
|
+
try {
|
|
1058
|
+
let roster;
|
|
1059
|
+
try {
|
|
1060
|
+
roster = this.resolveRoster();
|
|
1061
|
+
} catch (error) {
|
|
1062
|
+
return {
|
|
1063
|
+
state: "unavailable",
|
|
1064
|
+
reason: reasonOf(error)
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
const targetDisabled = !enabled;
|
|
1068
|
+
if (PI_TUI_WEB_ACCESS_ROWS.filter((row) => roster.get(row.id).disabled !== targetDisabled).length === 0) return this.describe();
|
|
1069
|
+
try {
|
|
1070
|
+
if (enabled) await this.enableRows(roster);
|
|
1071
|
+
else await this.disableRows(roster);
|
|
1072
|
+
} catch (error) {
|
|
1073
|
+
const cleanup = await this.disableRemaining(roster);
|
|
1074
|
+
return {
|
|
1075
|
+
state: "unavailable",
|
|
1076
|
+
reason: withCleanup(reasonOf(error), cleanup)
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
const settled = this.describe();
|
|
1080
|
+
if (enabled && settled.state !== "enabled") {
|
|
1081
|
+
const cleanup = await this.disableRemaining(roster);
|
|
1082
|
+
return {
|
|
1083
|
+
state: "unavailable",
|
|
1084
|
+
reason: withCleanup(settled.state === "unavailable" ? settled.reason : "web access: the Web graph did not settle", cleanup)
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
return settled;
|
|
1088
|
+
} finally {
|
|
1089
|
+
this.inFlight -= 1;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Bring the whole Web roster up in the frozen enable order. Every row is
|
|
1094
|
+
* awaited through its own fiber (so a rejected plugin apply is a real
|
|
1095
|
+
* failure) and through Loader settlement.
|
|
1096
|
+
*/
|
|
1097
|
+
async enableRows(roster) {
|
|
1098
|
+
for (const id of PI_TUI_WEB_ACCESS_ENABLE_ORDER) {
|
|
1099
|
+
const entry = roster.get(id);
|
|
1100
|
+
if (entry.disabled) await entry.update({ disabled: false });
|
|
1101
|
+
await this.settleEnabled(entry);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
/** Tear the whole Web roster down in the frozen disable order. */
|
|
1105
|
+
async disableRows(roster) {
|
|
1106
|
+
for (const id of PI_TUI_WEB_ACCESS_DISABLE_ORDER) await this.disableEntry(roster.get(id));
|
|
1107
|
+
}
|
|
1108
|
+
/** Dispose ONE Web row and await its fiber release plus Loader settlement. */
|
|
1109
|
+
async disableEntry(entry) {
|
|
1110
|
+
if (entry.disabled) return;
|
|
1111
|
+
const released = entry.fiber;
|
|
1112
|
+
await entry.update({ disabled: true });
|
|
1113
|
+
await released?.inertia;
|
|
1114
|
+
await this.loader().await();
|
|
1115
|
+
}
|
|
1116
|
+
/** Await one enabled row's fiber AND its Loader settlement. */
|
|
1117
|
+
async settleEnabled(entry) {
|
|
1118
|
+
const fiber = entry.fiber;
|
|
1119
|
+
if (fiber === void 0) throw new Error(`web access: the "${entry.options.id}" row did not mount a fiber`);
|
|
1120
|
+
await fiber.await();
|
|
1121
|
+
await this.loader().await();
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Best-effort recovery after a failed mutation: return the WHOLE Web roster
|
|
1125
|
+
* to disabled, reporting every cleanup failure instead of swallowing it. A
|
|
1126
|
+
* failed disable keeps closing; a failed enable withdraws what it mounted so
|
|
1127
|
+
* no partial Web surface stays served. Shared Host owners are never touched.
|
|
1128
|
+
*/
|
|
1129
|
+
async disableRemaining(roster) {
|
|
1130
|
+
const failures = [];
|
|
1131
|
+
for (const id of PI_TUI_WEB_ACCESS_DISABLE_ORDER) try {
|
|
1132
|
+
await this.disableEntry(roster.get(id));
|
|
1133
|
+
} catch (error) {
|
|
1134
|
+
failures.push(error);
|
|
1135
|
+
}
|
|
1136
|
+
return failures;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Read the availability the live Loader and the official Web services prove.
|
|
1140
|
+
* A settled roster is `disabled` (everything off) or `enabled` (everything on
|
|
1141
|
+
* and the Web services live); anything in between is `unavailable`, because
|
|
1142
|
+
* neither claim would be true.
|
|
1143
|
+
*/
|
|
1144
|
+
describe() {
|
|
1145
|
+
let roster;
|
|
1146
|
+
try {
|
|
1147
|
+
roster = this.resolveRoster();
|
|
1148
|
+
} catch (error) {
|
|
1149
|
+
return {
|
|
1150
|
+
state: "unavailable",
|
|
1151
|
+
reason: reasonOf(error)
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
const disabled = PI_TUI_WEB_ACCESS_ROWS.filter((row) => roster.get(row.id).disabled);
|
|
1155
|
+
if (disabled.length === PI_TUI_WEB_ACCESS_ROWS.length) {
|
|
1156
|
+
const published = REQUIRED_WEB_SERVICES.filter((service) => this.ctx.reflect.get(service) !== void 0);
|
|
1157
|
+
if (published.length > 0) return {
|
|
1158
|
+
state: "unavailable",
|
|
1159
|
+
reason: `web access: the Web rows are disabled but the official Web services are still published: ${published.join(", ")}`
|
|
1160
|
+
};
|
|
1161
|
+
return { state: "disabled" };
|
|
1162
|
+
}
|
|
1163
|
+
if (disabled.length > 0) {
|
|
1164
|
+
const named = disabled.slice(0, 8).map((row) => row.id).join(", ");
|
|
1165
|
+
const more = disabled.length > 8 ? ", ..." : "";
|
|
1166
|
+
return {
|
|
1167
|
+
state: "unavailable",
|
|
1168
|
+
reason: `web access: ${String(disabled.length)} of the ${String(PI_TUI_WEB_ACCESS_ROWS.length)} Web rows are disabled (${named}${more}) and the rest are enabled`
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
for (const row of PI_TUI_WEB_ACCESS_ROWS) {
|
|
1172
|
+
const state = roster.get(row.id).fiber?.state;
|
|
1173
|
+
if (state === FIBER_ACTIVE) continue;
|
|
1174
|
+
return {
|
|
1175
|
+
state: "unavailable",
|
|
1176
|
+
reason: `web access: the "${row.id}" row is ${state === void 0 ? "not started" : `state-${String(state)}`}, not active`
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
const missing = REQUIRED_WEB_SERVICES.filter((service) => this.ctx.reflect.get(service) === void 0);
|
|
1180
|
+
if (missing.length > 0) return {
|
|
1181
|
+
state: "unavailable",
|
|
1182
|
+
reason: `web access: the official Web services are missing: ${missing.join(", ")}`
|
|
1183
|
+
};
|
|
1184
|
+
return { state: "enabled" };
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* Resolve EXACTLY one live row per roster id from this Host's own Loader.
|
|
1188
|
+
* A missing, duplicated or re-pointed row is refused instead of toggling a
|
|
1189
|
+
* partial graph.
|
|
1190
|
+
*/
|
|
1191
|
+
resolveRoster() {
|
|
1192
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
1193
|
+
for (const entry of this.loader().entries()) {
|
|
1194
|
+
const id = entry.options.id;
|
|
1195
|
+
const expected = ROSTER_PACKAGES.get(id);
|
|
1196
|
+
if (expected === void 0) {
|
|
1197
|
+
if (ROSTER_PACKAGE_NAMES.has(entry.options.name)) throw new Error(`web access: the Loader owns a second ${JSON.stringify(entry.options.name)} row outside the roster ("${id}")`);
|
|
1198
|
+
continue;
|
|
1199
|
+
}
|
|
1200
|
+
if (entry.options.name !== expected) throw new Error(`web access: the "${id}" row loads ${JSON.stringify(entry.options.name)}, not ${JSON.stringify(expected)}`);
|
|
1201
|
+
if (resolved.has(id)) throw new Error(`web access: the Loader owns more than one "${id}" row`);
|
|
1202
|
+
resolved.set(id, entry);
|
|
1203
|
+
}
|
|
1204
|
+
const missing = PI_TUI_WEB_ACCESS_ROWS.map((row) => row.id).filter((id) => !resolved.has(id));
|
|
1205
|
+
if (missing.length > 0) throw new Error(`web access: the Host Loader does not own the Web rows: ${missing.join(", ")}`);
|
|
1206
|
+
return resolved;
|
|
1207
|
+
}
|
|
1208
|
+
/** Read the Host's own Loader service per call, never a composition snapshot. */
|
|
1209
|
+
loader() {
|
|
1210
|
+
const loader = this.ctx.get("loader");
|
|
1211
|
+
if (loader === void 0) throw new Error("web access: the Host has no Loader service");
|
|
1212
|
+
return loader;
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
//#endregion
|
|
358
1216
|
//#region src/app/host/pi-tui-host-runtime.ts
|
|
359
1217
|
/** Stable Cordis plugin name (the Loader row id in the Host-only overlay). */
|
|
360
1218
|
const name = "pi-tui-host-runtime";
|
|
361
1219
|
/**
|
|
362
1220
|
* Explicit Host dependencies: the private Typert registry plus the two live
|
|
363
1221
|
* Host facts the business rows resolve per call. `tuiStartup` remains a Loader
|
|
364
|
-
* row gate (see the Host-only overlay), not a plugin inject.
|
|
1222
|
+
* row gate (see the Host-only overlay), not a plugin inject. The Web access row
|
|
1223
|
+
* resolves the Host's OWN Loader through the service on every call, so this
|
|
1224
|
+
* published row contract does not change: this row IS a Loader row, and a Host
|
|
1225
|
+
* without a Loader fails closed (`unavailable`) instead of pending forever.
|
|
365
1226
|
*/
|
|
366
1227
|
const inject = [
|
|
367
1228
|
"typert",
|
|
@@ -396,11 +1257,12 @@ function assertPrivateBinding(ctx, serviceKey, namespace) {
|
|
|
396
1257
|
* Mount the built-in PiTui Host Runtime on the launching Host Context.
|
|
397
1258
|
*
|
|
398
1259
|
* Startup order is fixed: register the package's ONE contribution, mount the
|
|
399
|
-
* file-reference service, mount the terminal-progress service,
|
|
400
|
-
* live bindings, then publish the readiness gate.
|
|
401
|
-
* BEFORE it is awaited; a partial rejection
|
|
402
|
-
* reverse order (contribution last) while
|
|
403
|
-
* and attaching cleanup failures to its
|
|
1260
|
+
* file-reference service, mount the terminal-progress service, mount the Web
|
|
1261
|
+
* access service, verify ALL live bindings, then publish the readiness gate.
|
|
1262
|
+
* Every child fiber is recorded BEFORE it is awaited; a partial rejection
|
|
1263
|
+
* disposes the recorded children in reverse order (contribution last) while
|
|
1264
|
+
* keeping the original error primary and attaching cleanup failures to its
|
|
1265
|
+
* cause chain.
|
|
404
1266
|
*/
|
|
405
1267
|
async function apply(ctx) {
|
|
406
1268
|
const fibers = [];
|
|
@@ -425,8 +1287,14 @@ async function apply(ctx) {
|
|
|
425
1287
|
});
|
|
426
1288
|
fibers.push(terminalProgressFiber);
|
|
427
1289
|
await terminalProgressFiber;
|
|
1290
|
+
const webAccessFiber = ctx.inject(PiTuiWebAccessHostService.inject, (pluginCtx) => {
|
|
1291
|
+
new PiTuiWebAccessHostService(pluginCtx);
|
|
1292
|
+
});
|
|
1293
|
+
fibers.push(webAccessFiber);
|
|
1294
|
+
await webAccessFiber;
|
|
428
1295
|
assertPrivateBinding(ctx, "piTuiFileReferences", PI_TUI_FILE_REFERENCES_NAMESPACE);
|
|
429
1296
|
assertPrivateBinding(ctx, "piTuiTerminalProgress", PI_TUI_TERMINAL_PROGRESS_NAMESPACE);
|
|
1297
|
+
assertPrivateBinding(ctx, "piTuiWebAccess", PI_TUI_WEB_ACCESS_NAMESPACE);
|
|
430
1298
|
ctx.provide(PI_TUI_HOST_READY_SERVICE, {});
|
|
431
1299
|
} catch (error) {
|
|
432
1300
|
const cleanupErrors = [];
|
|
@@ -442,8 +1310,7 @@ async function apply(ctx) {
|
|
|
442
1310
|
}
|
|
443
1311
|
const primary = error instanceof Error ? error : new Error(String(error));
|
|
444
1312
|
if (cleanupErrors.length === 0) throw primary;
|
|
445
|
-
|
|
446
|
-
throw mergeCause(primary, secondary);
|
|
1313
|
+
throw mergeCause(primary, cleanupErrors.length === 1 ? cleanupErrors[0] : new AggregateError(cleanupErrors, "pi-tui-host-runtime: child disposal failures"));
|
|
447
1314
|
}
|
|
448
1315
|
}
|
|
449
1316
|
//#endregion
|