@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.
Files changed (90) hide show
  1. package/LICENSE +33 -0
  2. package/README.en.md +103 -814
  3. package/README.md +102 -711
  4. package/cordis.patch.yml +186 -0
  5. package/dist/acp-preferences.d.mts +29 -0
  6. package/dist/acp-preferences.mjs +15 -0
  7. package/dist/{bootstrap-DQ4YPL-7.mjs → bootstrap-CMIjGyuk.mjs} +33515 -7587
  8. package/dist/builtins.mjs +3 -3
  9. package/dist/{client-bootstrap-Cr1JCaF5.mjs → client-bootstrap-BjGPc-DM.mjs} +4637 -492
  10. package/dist/client-extension-loader-probe-BUw7q8bJ.mjs +119 -0
  11. package/dist/command-trust-DChWUamk.mjs +406 -0
  12. package/dist/daemon-launcher-Dult7Jxv.mjs +1932 -0
  13. package/dist/daemon-launcher.d.mts +159 -0
  14. package/dist/daemon-launcher.mjs +2 -0
  15. package/dist/diagnostics-D5jwc-q1.d.mts +11 -0
  16. package/dist/{dist-CIsR7cz4.mjs → dist-BFgC-5tL.mjs} +938 -487
  17. package/dist/entry-control-DjNsE3I0.mjs +190 -0
  18. package/dist/extension/advanced.d.mts +1 -1
  19. package/dist/extension/unstable.d.mts +1 -1
  20. package/dist/extension-config-probe-BDdvutkG.mjs +95 -0
  21. package/dist/extension-config.d.mts +29 -0
  22. package/dist/extension-config.mjs +22 -0
  23. package/dist/{extensions-Bp0L37lP.mjs → extensions-B4uLpSTv.mjs} +1109 -100
  24. package/dist/{extensions-Bte3XOt5.d.mts → extensions-C8eAM0gX.d.mts} +1 -1
  25. package/dist/extensions.d.mts +2 -2
  26. package/dist/extensions.mjs +1 -1
  27. package/dist/{host-bootstrap-DilsvA6f.mjs → host-bootstrap-MVxks641.mjs} +129 -24
  28. package/dist/{host-foundation-probe--5jtvHVe.mjs → host-foundation-probe-DMNTmNrH.mjs} +2 -2
  29. package/dist/host-runtime.d.mts +11 -5
  30. package/dist/host-runtime.mjs +4171 -920
  31. package/dist/index.d.mts +86 -174
  32. package/dist/index.mjs +38087 -9967
  33. package/dist/local-acp-listener-B65J0Bx4.mjs +3115 -0
  34. package/dist/local-client.mjs +1158 -59
  35. package/dist/local-daemon-control-C14q9KnD.mjs +1588 -0
  36. package/dist/local-daemon-control-TCnERL7n.mjs +1424 -0
  37. package/dist/local-discovery-DOSsCh9q.mjs +2883 -0
  38. package/dist/local-discovery-egN4_gsQ.mjs +2 -0
  39. package/dist/local-discovery-uOBfFq5j.mjs +2764 -0
  40. package/dist/local-host.mjs +812 -89
  41. package/dist/local-profile-daemon-admin-BmQSdzT0.mjs +210 -0
  42. package/dist/local-scope-DamiMqPd.mjs +1340 -0
  43. package/dist/{local-transport-BVwFYq_Y.mjs → local-transport-Iwo0mtu3.mjs} +313 -38
  44. package/dist/local-web-control-DMrjwCkl.mjs +454 -0
  45. package/dist/local-workspace-object-D06GL0UO.mjs +248 -0
  46. package/dist/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
  47. package/dist/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
  48. package/dist/open-CmOBxSjN.mjs +63 -0
  49. package/dist/persisted-setting-probe-DWZLtWoB.mjs +145 -0
  50. package/dist/pi-tui-acp-access-contract-BdLwduU6.mjs +75 -0
  51. package/dist/pi-tui-remote-contribution-Do8ECrUy.mjs +1492 -0
  52. package/dist/pi-tui-terminal-progress-contract-B3RoEzjK.mjs +146 -0
  53. package/dist/preferences.d.mts +17 -0
  54. package/dist/preferences.mjs +20 -0
  55. package/dist/preset-BcWqOtY7.mjs +46 -0
  56. package/dist/profile-preferences-migration-BfUGdPZx.mjs +500 -0
  57. package/dist/profile-preferences-migration-CThz4rHH.mjs +2 -0
  58. package/dist/prompt-sections-DUKmWb8g.mjs +2232 -0
  59. package/dist/prompt-sections-DXmjB58H.mjs +634 -0
  60. package/dist/{public-types-Dgf1bDke.d.mts → public-types-C1YgFtwC.d.mts} +56 -3
  61. package/dist/row-id-DPbyt9Nn.mjs +24 -0
  62. package/dist/{runtime-status-Cj1nFOdS.mjs → runtime-status-v-FTnWcD.mjs} +49 -3
  63. package/dist/schema-BTGYn8_X.d.mts +54 -0
  64. package/dist/schema-qE_P09zJ.mjs +124 -0
  65. package/dist/{session-BKGXyh80.mjs → session-C6tSs86s.mjs} +9672 -7270
  66. package/dist/{session-CPt_U8_f.mjs → session-CstInGIA.mjs} +9674 -7273
  67. package/dist/startup-CarQxWwi.d.mts +213 -0
  68. package/dist/{startup-7BYWuvBU.mjs → startup-EG5UqIcd.mjs} +341 -26
  69. package/dist/startup.d.mts +2 -99
  70. package/dist/startup.mjs +2 -2
  71. package/dist/{terminal-progress-source-DrqQhtT8.mjs → terminal-progress-source-CpfpQO_h.mjs} +2038 -67
  72. package/dist/{pasted-path-range-CMnxuGPx.mjs → transcript-view-C1YtJ49Y.mjs} +11590 -6718
  73. package/dist/{pasted-path-range-r6qzV_tC.mjs → transcript-view-CuJYWkhp.mjs} +12296 -6923
  74. package/dist/version-B9yC7bBk.mjs +83 -0
  75. package/dist/visual-tools.d.mts +1 -1
  76. package/dist/visual-tools.mjs +1 -1
  77. package/dist/web-preferences.d.mts +1 -1
  78. package/dist/{web-roster-CjqnUXNk.mjs → web-roster-Dis7BhrA.mjs} +63 -3
  79. package/generated/dsh-presets/cordis.patch.yml +4 -2
  80. package/generated/dsh-presets/ptc.patch.yml +4 -0
  81. package/generated/dsh-presets/standard.patch.yml +7 -0
  82. package/generated/web-access/cordis.patch.yml +239 -0
  83. package/package.json +217 -170
  84. package/dist/entry-control-DnduyDiw.mjs +0 -92
  85. package/dist/local-discovery-C9VMjc0K.mjs +0 -759
  86. package/dist/local-discovery-CDaQHA_R.mjs +0 -2
  87. package/dist/pi-tui-remote-contribution-B0EQsP0N.mjs +0 -85
  88. package/dist/pi-tui-terminal-progress-contract-CdBH9j78.mjs +0 -70
  89. package/dist/pi-tui-terminal-progress-contract-MLXZ-i3t.mjs +0 -905
  90. package/dist/version-a-eF-QER.mjs +0 -80
@@ -0,0 +1,1492 @@
1
+ import { i as PI_TUI_WEB_ACCESS_SET_ENABLED, n as PI_TUI_WEB_ACCESS_GET_STATUS, t as PI_TUI_WEB_ACCESS_GET_AUTHENTICATED_URL } from "./pi-tui-web-access-contract-BN8Cc_Ho.mjs";
2
+ import { r as PI_TUI_ACP_ACCESS_SET_ENABLED, t as PI_TUI_ACP_ACCESS_GET_STATUS } from "./pi-tui-acp-access-contract-BdLwduU6.mjs";
3
+ import { c as MAX_HOST_USER_SHELL_SPILL_PATH_BYTES, l as MAX_HOST_USER_SHELL_STREAM_BYTES, n as PI_TUI_TERMINAL_PROGRESS_WATCH, o as MAX_HOST_USER_SHELL_MESSAGE_BYTES } from "./pi-tui-terminal-progress-contract-B3RoEzjK.mjs";
4
+ import { constants } from "node:os";
5
+ //#region src/runtime/remote/pi-tui-authorization-contract.ts
6
+ /** The wire namespace (and Host Cordis service key) of the private service. */
7
+ const PI_TUI_AUTHORIZATION_NAMESPACE = "piTuiAuthorization";
8
+ /** The roster read's stable endpoint identity. */
9
+ const PI_TUI_AUTHORIZATION_LIST_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiAuthorization/list";
10
+ /** The one-attempt stream's stable endpoint identity. */
11
+ const PI_TUI_AUTHORIZATION_RUN_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiAuthorization/run";
12
+ /** The prompt answer's stable endpoint identity. */
13
+ const PI_TUI_AUTHORIZATION_RESPOND_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiAuthorization/respond";
14
+ /** The attempt cancellation request's stable endpoint identity. */
15
+ const PI_TUI_AUTHORIZATION_CANCEL_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiAuthorization/cancel";
16
+ const STARTED_FRAME_LABEL = "piTuiAuthorization/run frame (started)";
17
+ const NOTICE_FRAME_LABEL = "piTuiAuthorization/run frame (notice)";
18
+ const PROMPT_FRAME_LABEL = "piTuiAuthorization/run frame (prompt)";
19
+ const WITHDRAWN_FRAME_LABEL = "piTuiAuthorization/run frame (prompt-withdrawn)";
20
+ const SETTLED_FRAME_LABEL = "piTuiAuthorization/run frame (settled)";
21
+ const UNCONFIRMED_FRAME_LABEL = "piTuiAuthorization/run frame (unconfirmed)";
22
+ const TARGET_LABEL = "piTuiAuthorization/list target";
23
+ function recordOf$6(value, label) {
24
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${label}: the value must be an object`);
25
+ return value;
26
+ }
27
+ function exactKeys$5(record, keys, label) {
28
+ for (const key of Object.keys(record)) if (!keys.includes(key)) throw new TypeError(`${label}: unexpected field ${JSON.stringify(key)}`);
29
+ }
30
+ function requiredKeys$2(record, keys, label) {
31
+ for (const key of keys) if (!Object.hasOwn(record, key)) throw new TypeError(`${label}: missing field ${JSON.stringify(key)}`);
32
+ }
33
+ function nonEmptyString(value, label) {
34
+ if (typeof value !== "string" || value === "") throw new TypeError(`${label}: expected a non-empty string`);
35
+ return value;
36
+ }
37
+ function optionalNonEmptyString(value, label) {
38
+ if (value === void 0) return void 0;
39
+ return nonEmptyString(value, label);
40
+ }
41
+ function assertOnlyOptional(record, keys, label) {
42
+ for (const key of Object.keys(record)) if (!keys.includes(key)) throw new TypeError(`${label}: unexpected field ${JSON.stringify(key)}`);
43
+ }
44
+ function parseNotice(value) {
45
+ const record = recordOf$6(value, NOTICE_FRAME_LABEL);
46
+ assertOnlyOptional(record, [
47
+ "message",
48
+ "url",
49
+ "code"
50
+ ], NOTICE_FRAME_LABEL);
51
+ requiredKeys$2(record, ["message"], NOTICE_FRAME_LABEL);
52
+ return {
53
+ message: nonEmptyString(record.message, `${NOTICE_FRAME_LABEL} message`),
54
+ ...record.url === void 0 ? {} : { url: nonEmptyString(record.url, `${NOTICE_FRAME_LABEL} url`) },
55
+ ...record.code === void 0 ? {} : { code: nonEmptyString(record.code, `${NOTICE_FRAME_LABEL} code`) }
56
+ };
57
+ }
58
+ function parsePromptOptions(value) {
59
+ if (!Array.isArray(value) || value.length === 0) throw new TypeError(`${PROMPT_FRAME_LABEL}: a select prompt needs a non-empty options array`);
60
+ return value.map((entry) => {
61
+ const option = recordOf$6(entry, `${PROMPT_FRAME_LABEL} option`);
62
+ assertOnlyOptional(option, [
63
+ "id",
64
+ "label",
65
+ "description"
66
+ ], `${PROMPT_FRAME_LABEL} option`);
67
+ requiredKeys$2(option, ["id", "label"], `${PROMPT_FRAME_LABEL} option`);
68
+ return {
69
+ id: nonEmptyString(option.id, `${PROMPT_FRAME_LABEL} option id`),
70
+ label: nonEmptyString(option.label, `${PROMPT_FRAME_LABEL} option label`),
71
+ ...option.description === void 0 ? {} : { description: nonEmptyString(option.description, `${PROMPT_FRAME_LABEL} option description`) }
72
+ };
73
+ });
74
+ }
75
+ function parsePrompt(value) {
76
+ const record = recordOf$6(value, PROMPT_FRAME_LABEL);
77
+ const kind = record.kind;
78
+ if (kind !== "text" && kind !== "secret" && kind !== "select") throw new TypeError(`${PROMPT_FRAME_LABEL}: the prompt kind must be text, secret or select`);
79
+ if (kind === "select") {
80
+ assertOnlyOptional(record, [
81
+ "kind",
82
+ "message",
83
+ "options"
84
+ ], PROMPT_FRAME_LABEL);
85
+ requiredKeys$2(record, ["message", "options"], PROMPT_FRAME_LABEL);
86
+ return {
87
+ kind: "select",
88
+ message: nonEmptyString(record.message, `${PROMPT_FRAME_LABEL} message`),
89
+ options: parsePromptOptions(record.options)
90
+ };
91
+ }
92
+ assertOnlyOptional(record, [
93
+ "kind",
94
+ "message",
95
+ "placeholder"
96
+ ], PROMPT_FRAME_LABEL);
97
+ requiredKeys$2(record, ["message"], PROMPT_FRAME_LABEL);
98
+ return {
99
+ kind,
100
+ message: nonEmptyString(record.message, `${PROMPT_FRAME_LABEL} message`),
101
+ ...record.placeholder === void 0 ? {} : { placeholder: nonEmptyString(record.placeholder, `${PROMPT_FRAME_LABEL} placeholder`) }
102
+ };
103
+ }
104
+ /**
105
+ * Validate and detach ONE `piTuiAuthorization/run` frame. This is the ONE
106
+ * structural validator of the frame union: the descriptor's `result` codec uses
107
+ * it, and the Client adapter must call it on every downlink item because the
108
+ * framework does not decode stream items (see the module JSDoc).
109
+ *
110
+ * The validation is exact: an undeclared field (a token, a credential record, a
111
+ * Host identifier) makes the frame invalid instead of passing it through.
112
+ */
113
+ function parsePiTuiAuthorizationFrame(value) {
114
+ const record = recordOf$6(value, "piTuiAuthorization/run frame");
115
+ const kind = record.kind;
116
+ const attemptId = nonEmptyString(record.attemptId, "piTuiAuthorization/run frame attemptId");
117
+ switch (kind) {
118
+ case "started":
119
+ exactKeys$5(record, ["kind", "attemptId"], STARTED_FRAME_LABEL);
120
+ return {
121
+ kind: "started",
122
+ attemptId
123
+ };
124
+ case "notice":
125
+ exactKeys$5(record, [
126
+ "kind",
127
+ "attemptId",
128
+ "notice"
129
+ ], NOTICE_FRAME_LABEL);
130
+ requiredKeys$2(record, ["notice"], NOTICE_FRAME_LABEL);
131
+ return {
132
+ kind: "notice",
133
+ attemptId,
134
+ notice: parseNotice(record.notice)
135
+ };
136
+ case "prompt":
137
+ exactKeys$5(record, [
138
+ "kind",
139
+ "attemptId",
140
+ "promptId",
141
+ "prompt"
142
+ ], PROMPT_FRAME_LABEL);
143
+ requiredKeys$2(record, ["promptId", "prompt"], PROMPT_FRAME_LABEL);
144
+ return {
145
+ kind: "prompt",
146
+ attemptId,
147
+ promptId: nonEmptyString(record.promptId, `${PROMPT_FRAME_LABEL} promptId`),
148
+ prompt: parsePrompt(record.prompt)
149
+ };
150
+ case "prompt-withdrawn":
151
+ exactKeys$5(record, [
152
+ "kind",
153
+ "attemptId",
154
+ "promptId"
155
+ ], WITHDRAWN_FRAME_LABEL);
156
+ requiredKeys$2(record, ["promptId"], WITHDRAWN_FRAME_LABEL);
157
+ return {
158
+ kind: "prompt-withdrawn",
159
+ attemptId,
160
+ promptId: nonEmptyString(record.promptId, `${WITHDRAWN_FRAME_LABEL} promptId`)
161
+ };
162
+ case "settled": {
163
+ exactKeys$5(record, [
164
+ "kind",
165
+ "attemptId",
166
+ "status",
167
+ "code",
168
+ "message"
169
+ ], SETTLED_FRAME_LABEL);
170
+ requiredKeys$2(record, ["status"], SETTLED_FRAME_LABEL);
171
+ const status = record.status;
172
+ if (status !== "authorized" && status !== "cancelled" && status !== "failed") throw new TypeError(`${SETTLED_FRAME_LABEL}: the status must be authorized, cancelled or failed`);
173
+ const code = optionalNonEmptyString(record.code, `${SETTLED_FRAME_LABEL} code`);
174
+ const message = optionalNonEmptyString(record.message, `${SETTLED_FRAME_LABEL} message`);
175
+ return {
176
+ kind: "settled",
177
+ attemptId,
178
+ status,
179
+ ...code === void 0 ? {} : { code },
180
+ ...message === void 0 ? {} : { message }
181
+ };
182
+ }
183
+ case "unconfirmed":
184
+ exactKeys$5(record, [
185
+ "kind",
186
+ "attemptId",
187
+ "reason"
188
+ ], UNCONFIRMED_FRAME_LABEL);
189
+ requiredKeys$2(record, ["reason"], UNCONFIRMED_FRAME_LABEL);
190
+ return {
191
+ kind: "unconfirmed",
192
+ attemptId,
193
+ reason: nonEmptyString(record.reason, `${UNCONFIRMED_FRAME_LABEL} reason`)
194
+ };
195
+ default: throw new TypeError("piTuiAuthorization/run frame: the kind is unknown");
196
+ }
197
+ }
198
+ /**
199
+ * Validate and detach ONE roster target. The Host is the only producer, but a
200
+ * target still crosses the wire; exactly the declared fields are accepted so no
201
+ * credential value, Host object or provider-internal path can ride along.
202
+ */
203
+ function parsePiTuiAuthorizationTarget(value) {
204
+ const record = recordOf$6(value, TARGET_LABEL);
205
+ assertOnlyOptional(record, [
206
+ "kind",
207
+ "route",
208
+ "key",
209
+ "label",
210
+ "methods",
211
+ "inFlight"
212
+ ], TARGET_LABEL);
213
+ requiredKeys$2(record, [
214
+ "kind",
215
+ "key",
216
+ "label",
217
+ "methods",
218
+ "inFlight"
219
+ ], TARGET_LABEL);
220
+ if (record.kind !== "authorization") throw new TypeError(`${TARGET_LABEL}: the kind must be authorization`);
221
+ if (!Array.isArray(record.methods)) throw new TypeError(`${TARGET_LABEL}: methods must be an array`);
222
+ if (typeof record.inFlight !== "boolean") throw new TypeError(`${TARGET_LABEL}: inFlight must be a boolean`);
223
+ return {
224
+ kind: "authorization",
225
+ ...record.route === void 0 ? {} : { route: nonEmptyString(record.route, `${TARGET_LABEL} route`) },
226
+ key: nonEmptyString(record.key, `${TARGET_LABEL} key`),
227
+ label: nonEmptyString(record.label, `${TARGET_LABEL} label`),
228
+ methods: record.methods.map((entry) => {
229
+ const method = recordOf$6(entry, `${TARGET_LABEL} method`);
230
+ exactKeys$5(method, ["id", "label"], `${TARGET_LABEL} method`);
231
+ requiredKeys$2(method, ["id", "label"], `${TARGET_LABEL} method`);
232
+ return {
233
+ id: nonEmptyString(method.id, `${TARGET_LABEL} method id`),
234
+ label: nonEmptyString(method.label, `${TARGET_LABEL} method label`)
235
+ };
236
+ }),
237
+ inFlight: record.inFlight
238
+ };
239
+ }
240
+ /** Validate and detach one roster snapshot. */
241
+ function parsePiTuiAuthorizationTargetsSnapshot(value) {
242
+ const record = recordOf$6(value, "piTuiAuthorization/list result");
243
+ if (record.kind === "unavailable") {
244
+ exactKeys$5(record, ["kind", "reason"], "piTuiAuthorization/list result");
245
+ return {
246
+ kind: "unavailable",
247
+ reason: nonEmptyString(record.reason, "piTuiAuthorization/list result reason")
248
+ };
249
+ }
250
+ if (record.kind !== "ready") throw new TypeError("piTuiAuthorization/list result: the kind must be ready or unavailable");
251
+ exactKeys$5(record, ["kind", "targets"], "piTuiAuthorization/list result");
252
+ if (!Array.isArray(record.targets)) throw new TypeError("piTuiAuthorization/list result: targets must be an array");
253
+ return {
254
+ kind: "ready",
255
+ targets: record.targets.map(parsePiTuiAuthorizationTarget)
256
+ };
257
+ }
258
+ function parseRespondAnswer(value) {
259
+ if (value === null) return null;
260
+ if (typeof value !== "string" || value === "") throw new TypeError("piTuiAuthorization/respond answer: expected a non-empty string or null");
261
+ return value;
262
+ }
263
+ function codecOf(label, parse) {
264
+ return {
265
+ mode: "strict",
266
+ typeSymbol: `@xmoon76/dsh-pi-tui#${label}`,
267
+ create: () => ({ parse }),
268
+ decode: parse
269
+ };
270
+ }
271
+ function stringCodec$2(label) {
272
+ return codecOf(label, (value) => nonEmptyString(value, `piTuiAuthorization ${label}`));
273
+ }
274
+ const FRAME_CODEC = {
275
+ mode: "strict",
276
+ typeSymbol: `${PI_TUI_AUTHORIZATION_RUN_ENDPOINT}:frame`,
277
+ create: () => ({ parse: parsePiTuiAuthorizationFrame }),
278
+ decode: parsePiTuiAuthorizationFrame
279
+ };
280
+ const TARGETS_CODEC = {
281
+ mode: "strict",
282
+ typeSymbol: `${PI_TUI_AUTHORIZATION_LIST_ENDPOINT}:result`,
283
+ create: () => ({ parse: parsePiTuiAuthorizationTargetsSnapshot }),
284
+ decode: parsePiTuiAuthorizationTargetsSnapshot
285
+ };
286
+ const VOID_CODEC$1 = {
287
+ mode: "strict",
288
+ typeSymbol: "@xmoon76/dsh-pi-tui#piTuiAuthorization:void",
289
+ create: () => ({ parse: (value) => {
290
+ if (value !== void 0 && value !== null) throw new TypeError("piTuiAuthorization: the result must be empty");
291
+ } }),
292
+ decode: (value) => {
293
+ if (value !== void 0 && value !== null) throw new TypeError("piTuiAuthorization: the result must be empty");
294
+ }
295
+ };
296
+ /** The roster read invocation both contributions derive from. */
297
+ const PI_TUI_AUTHORIZATION_LIST = {
298
+ id: PI_TUI_AUTHORIZATION_LIST_ENDPOINT,
299
+ service: PI_TUI_AUTHORIZATION_NAMESPACE,
300
+ namespace: PI_TUI_AUTHORIZATION_NAMESPACE,
301
+ method: "list",
302
+ invocation: { kind: "direct" },
303
+ parameters: [],
304
+ cancellation: { parameter: "signal" },
305
+ result: TARGETS_CODEC
306
+ };
307
+ /**
308
+ * The one-attempt stream invocation. `method` is optional at the business
309
+ * level (`acceptsUndefined`): an absent method lets the official service pick
310
+ * the flow's first method.
311
+ */
312
+ const PI_TUI_AUTHORIZATION_RUN = {
313
+ id: PI_TUI_AUTHORIZATION_RUN_ENDPOINT,
314
+ service: PI_TUI_AUTHORIZATION_NAMESPACE,
315
+ namespace: PI_TUI_AUTHORIZATION_NAMESPACE,
316
+ method: "run",
317
+ mode: "stream",
318
+ invocation: { kind: "direct" },
319
+ parameters: [{
320
+ name: "key",
321
+ wire: "key",
322
+ source: "json",
323
+ codec: stringCodec$2("run key")
324
+ }, {
325
+ name: "method",
326
+ wire: "method",
327
+ source: "json",
328
+ acceptsUndefined: true,
329
+ codec: stringCodec$2("run method")
330
+ }],
331
+ cancellation: { parameter: "signal" },
332
+ result: FRAME_CODEC
333
+ };
334
+ /** The exact pending-prompt answer invocation. */
335
+ const PI_TUI_AUTHORIZATION_RESPOND = {
336
+ id: PI_TUI_AUTHORIZATION_RESPOND_ENDPOINT,
337
+ service: PI_TUI_AUTHORIZATION_NAMESPACE,
338
+ namespace: PI_TUI_AUTHORIZATION_NAMESPACE,
339
+ method: "respond",
340
+ invocation: { kind: "direct" },
341
+ parameters: [
342
+ {
343
+ name: "attemptId",
344
+ wire: "attemptId",
345
+ source: "json",
346
+ codec: stringCodec$2("respond attemptId")
347
+ },
348
+ {
349
+ name: "promptId",
350
+ wire: "promptId",
351
+ source: "json",
352
+ codec: stringCodec$2("respond promptId")
353
+ },
354
+ {
355
+ name: "answer",
356
+ wire: "answer",
357
+ source: "json",
358
+ codec: codecOf("respond answer", parseRespondAnswer)
359
+ }
360
+ ],
361
+ cancellation: { parameter: "signal" },
362
+ result: VOID_CODEC$1
363
+ };
364
+ /** The exact-attempt cancellation request invocation. */
365
+ const PI_TUI_AUTHORIZATION_CANCEL = {
366
+ id: PI_TUI_AUTHORIZATION_CANCEL_ENDPOINT,
367
+ service: PI_TUI_AUTHORIZATION_NAMESPACE,
368
+ namespace: PI_TUI_AUTHORIZATION_NAMESPACE,
369
+ method: "cancel",
370
+ invocation: { kind: "direct" },
371
+ parameters: [{
372
+ name: "attemptId",
373
+ wire: "attemptId",
374
+ source: "json",
375
+ codec: stringCodec$2("cancel attemptId")
376
+ }],
377
+ cancellation: { parameter: "signal" },
378
+ result: VOID_CODEC$1
379
+ };
380
+ //#endregion
381
+ //#region src/runtime/remote/pi-tui-credential-records-contract.ts
382
+ /** The wire namespace (and Host Cordis service key) of the private service. */
383
+ const PI_TUI_CREDENTIAL_RECORDS_NAMESPACE = "piTuiCredentialRecords";
384
+ /** The metadata enumeration's stable endpoint identity. */
385
+ const PI_TUI_CREDENTIAL_RECORDS_LIST_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiCredentialRecords/list";
386
+ /** The exact-key delete's stable endpoint identity. */
387
+ const PI_TUI_CREDENTIAL_RECORDS_DELETE_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiCredentialRecords/delete";
388
+ /**
389
+ * The official `<scope>/<id>` segment grammar (the same rule as the official
390
+ * `parseCredentialKey()`): two lowercase hyphenated identifiers separated by
391
+ * exactly one `/`. This is an ADDRESS grammar only — it never says a key exists
392
+ * or which provider it belongs to; the Host store decides that.
393
+ */
394
+ const CREDENTIAL_RECORD_KEY_PATTERN = /^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/;
395
+ const RECORD_LABEL = "piTuiCredentialRecords record";
396
+ const LIST_LABEL = "piTuiCredentialRecords/list result";
397
+ const KEY_LABEL = "piTuiCredentialRecords key";
398
+ function recordOf$5(value, label) {
399
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${label}: the value must be an object`);
400
+ return value;
401
+ }
402
+ function exactKeys$4(record, keys, label) {
403
+ for (const key of Object.keys(record)) if (!keys.includes(key)) throw new TypeError(`${label}: unexpected field ${JSON.stringify(key)}`);
404
+ }
405
+ function requiredKeys$1(record, keys, label) {
406
+ for (const key of keys) if (!Object.hasOwn(record, key)) throw new TypeError(`${label}: missing field ${JSON.stringify(key)}`);
407
+ }
408
+ /**
409
+ * Validate one exact `<scope>/<id>` record key as wire text and return it. A
410
+ * key outside the official grammar (non-ASCII, extra `/`, an empty segment, an
411
+ * environment-variable name) is refused; a VALID other plugin's scope is not.
412
+ */
413
+ function parsePiTuiCredentialRecordKey(value) {
414
+ if (typeof value !== "string" || !CREDENTIAL_RECORD_KEY_PATTERN.test(value)) throw new TypeError(`${KEY_LABEL}: expected an exact <scope>/<id> credential key`);
415
+ return value;
416
+ }
417
+ /** Validate and detach ONE stored-record metadata row (exactly `key`+`kind`). */
418
+ function parsePiTuiCredentialRecordMetadata(value) {
419
+ const record = recordOf$5(value, RECORD_LABEL);
420
+ exactKeys$4(record, ["key", "kind"], RECORD_LABEL);
421
+ requiredKeys$1(record, ["key", "kind"], RECORD_LABEL);
422
+ const kind = record.kind;
423
+ if (kind !== "api-key" && kind !== "grant") throw new TypeError(`${RECORD_LABEL}: the kind must be api-key or grant`);
424
+ return {
425
+ key: parsePiTuiCredentialRecordKey(record.key),
426
+ kind
427
+ };
428
+ }
429
+ /**
430
+ * Validate and detach the WHOLE `list` result. A non-array, or ANY invalid row
431
+ * (an extra field such as a payload/token/env, an invalid key, an unknown
432
+ * kind), fails the whole result: the adapter must never filter an unusable
433
+ * official projection out and then claim the remaining rows are the complete
434
+ * Host truth.
435
+ */
436
+ function parsePiTuiCredentialRecordList(value) {
437
+ if (!Array.isArray(value)) throw new TypeError(`${LIST_LABEL}: the result must be an array`);
438
+ return value.map(parsePiTuiCredentialRecordMetadata);
439
+ }
440
+ const LIST_CODEC = {
441
+ mode: "strict",
442
+ typeSymbol: `${PI_TUI_CREDENTIAL_RECORDS_LIST_ENDPOINT}:result`,
443
+ create: () => ({ parse: parsePiTuiCredentialRecordList }),
444
+ decode: parsePiTuiCredentialRecordList
445
+ };
446
+ const KEY_CODEC = {
447
+ mode: "strict",
448
+ typeSymbol: `${PI_TUI_CREDENTIAL_RECORDS_DELETE_ENDPOINT}:key`,
449
+ create: () => ({ parse: parsePiTuiCredentialRecordKey }),
450
+ decode: parsePiTuiCredentialRecordKey
451
+ };
452
+ /** The success shape of a delete: the official empty result, nothing else. */
453
+ const VOID_CODEC = {
454
+ mode: "strict",
455
+ typeSymbol: "@xmoon76/dsh-pi-tui#piTuiCredentialRecords:void",
456
+ create: () => ({ parse: (value) => {
457
+ if (value !== void 0 && value !== null) throw new TypeError("piTuiCredentialRecords: the result must be empty");
458
+ } }),
459
+ decode: (value) => {
460
+ if (value !== void 0 && value !== null) throw new TypeError("piTuiCredentialRecords: the result must be empty");
461
+ }
462
+ };
463
+ /** The metadata enumeration invocation both contributions derive from. */
464
+ const PI_TUI_CREDENTIAL_RECORDS_LIST = {
465
+ id: PI_TUI_CREDENTIAL_RECORDS_LIST_ENDPOINT,
466
+ service: PI_TUI_CREDENTIAL_RECORDS_NAMESPACE,
467
+ namespace: PI_TUI_CREDENTIAL_RECORDS_NAMESPACE,
468
+ method: "list",
469
+ invocation: { kind: "direct" },
470
+ parameters: [],
471
+ cancellation: { parameter: "signal" },
472
+ result: LIST_CODEC
473
+ };
474
+ /** The exact-key delete invocation both contributions derive from. */
475
+ const PI_TUI_CREDENTIAL_RECORDS_DELETE = {
476
+ id: PI_TUI_CREDENTIAL_RECORDS_DELETE_ENDPOINT,
477
+ service: PI_TUI_CREDENTIAL_RECORDS_NAMESPACE,
478
+ namespace: PI_TUI_CREDENTIAL_RECORDS_NAMESPACE,
479
+ method: "delete",
480
+ invocation: { kind: "direct" },
481
+ parameters: [{
482
+ name: "key",
483
+ wire: "key",
484
+ source: "json",
485
+ codec: KEY_CODEC
486
+ }],
487
+ cancellation: { parameter: "signal" },
488
+ result: VOID_CODEC
489
+ };
490
+ //#endregion
491
+ //#region src/runtime/remote/pi-tui-host-user-shell-contract.ts
492
+ /**
493
+ * The private Host one-shot Shell and Host completion wire contract. One shared
494
+ * descriptor table serves both the Host registration and Client mount.
495
+ *
496
+ * Shell execution is ONE authenticated unary invocation: the Host runs the
497
+ * command to settlement and returns one bounded semantic result. There is no
498
+ * raw-byte frame stream, no consumption acknowledgement and no request-scoped
499
+ * stream lifecycle on this endpoint.
500
+ * @module @xmoon76/dsh-pi-tui/runtime/remote/pi-tui-host-user-shell-contract
501
+ */
502
+ const PI_TUI_HOST_USER_SHELL_NAMESPACE = "piTuiHostUserShell";
503
+ const PI_TUI_HOST_USER_SHELL_RUN_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiHostUserShell/run";
504
+ const PI_TUI_HOST_USER_SHELL_COMPLETE_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiHostUserShell/complete";
505
+ const PI_TUI_HOST_USER_SHELL_COMPLETE_WORKSPACE_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiHostUserShell/completeWorkspace";
506
+ /**
507
+ * The strict codec for a Host-issued Workspace identity: a NON-EMPTY string.
508
+ * An empty `workspaceId` names no Host resource at all, so the wire boundary
509
+ * refuses it instead of letting a fabricated id reach the Host business layer.
510
+ */
511
+ function workspaceIdCodec$1(typeSymbol) {
512
+ return {
513
+ mode: "strict",
514
+ typeSymbol,
515
+ create: () => ({ parse: (value) => {
516
+ if (typeof value !== "string") throw new TypeError(`${typeSymbol}: the wire value must be a string`);
517
+ if (value === "") throw new TypeError(`${typeSymbol}: the wire value must be a non-empty Workspace id`);
518
+ return value;
519
+ } })
520
+ };
521
+ }
522
+ const signalNames = new Set(Object.keys(constants.signals));
523
+ function recordOf$4(value, label) {
524
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${label}: expected an object`);
525
+ return value;
526
+ }
527
+ function exactKeys$3(record, expected, label) {
528
+ for (const key of Object.keys(record)) if (!expected.includes(key)) throw new TypeError(`${label}: unexpected field ${JSON.stringify(key)}`);
529
+ for (const key of expected) if (!Object.hasOwn(record, key)) throw new TypeError(`${label}: missing field ${JSON.stringify(key)}`);
530
+ }
531
+ function stringOf(value, label, options = {}) {
532
+ if (typeof value !== "string" || options.empty !== true && value.length === 0) throw new TypeError(`${label}: expected a${options.empty === true ? "" : " non-empty"} string`);
533
+ return value;
534
+ }
535
+ function boundedStringOf(value, label, maxBytes) {
536
+ const text = stringOf(value, label, { empty: true });
537
+ if (Buffer.byteLength(text, "utf8") > maxBytes) throw new TypeError(`${label}: exceeds ${maxBytes} bytes`);
538
+ return text;
539
+ }
540
+ function booleanOf(value, label) {
541
+ if (typeof value !== "boolean") throw new TypeError(`${label}: expected a boolean`);
542
+ return value;
543
+ }
544
+ function stringCodec$1(typeSymbol, options = {}) {
545
+ return {
546
+ mode: "strict",
547
+ typeSymbol,
548
+ create: () => ({ parse: (value) => stringOf(value, typeSymbol, { empty: options.allowEmpty }) })
549
+ };
550
+ }
551
+ function policyOf(value, label) {
552
+ if (value !== "bypass" && value !== "sandbox") throw new TypeError(`${label}: expected bypass or sandbox`);
553
+ return value;
554
+ }
555
+ function parseExit(value) {
556
+ const exit = recordOf$4(value, "piTuiHostUserShell/run: exit");
557
+ if (exit.kind === "exit") {
558
+ exactKeys$3(exit, ["kind", "code"], "piTuiHostUserShell/run: exit");
559
+ if (!Number.isSafeInteger(exit.code) || exit.code < 0 || exit.code > 255) throw new TypeError("piTuiHostUserShell/run: exit code must be an integer from 0 through 255");
560
+ return {
561
+ kind: "exit",
562
+ code: exit.code
563
+ };
564
+ }
565
+ if (exit.kind === "signal") {
566
+ exactKeys$3(exit, ["kind", "signal"], "piTuiHostUserShell/run: exit");
567
+ const signal = stringOf(exit.signal, "piTuiHostUserShell/run: exit signal");
568
+ if (!signalNames.has(signal)) throw new TypeError("piTuiHostUserShell/run: exit signal is invalid");
569
+ return {
570
+ kind: "signal",
571
+ signal
572
+ };
573
+ }
574
+ throw new TypeError("piTuiHostUserShell/run: exit kind must be exit or signal");
575
+ }
576
+ function parseOutput(value, stream) {
577
+ const label = `piTuiHostUserShell/run: ${stream}`;
578
+ const output = recordOf$4(value, label);
579
+ for (const key of Object.keys(output)) if (key !== "text" && key !== "truncated" && key !== "spillPath") throw new TypeError(`${label}: unexpected field ${JSON.stringify(key)}`);
580
+ if (!Object.hasOwn(output, "text")) throw new TypeError(`${label}: missing field "text"`);
581
+ if (!Object.hasOwn(output, "truncated")) throw new TypeError(`${label}: missing field "truncated"`);
582
+ const text = boundedStringOf(output.text, `${label} text`, MAX_HOST_USER_SHELL_STREAM_BYTES);
583
+ const truncated = booleanOf(output.truncated, `${label} truncated`);
584
+ if (output.spillPath === void 0) return {
585
+ text,
586
+ truncated
587
+ };
588
+ const spillPath = boundedStringOf(output.spillPath, `${label} spillPath`, MAX_HOST_USER_SHELL_SPILL_PATH_BYTES);
589
+ if (spillPath.includes("\0")) throw new TypeError(`${label} spillPath: must not contain NUL`);
590
+ return {
591
+ text,
592
+ truncated,
593
+ spillPath
594
+ };
595
+ }
596
+ function parseResult(value) {
597
+ const result = recordOf$4(value, "piTuiHostUserShell/run: result");
598
+ exactKeys$3(result, [
599
+ "exit",
600
+ "stdout",
601
+ "stderr",
602
+ "sandboxDenied",
603
+ "aborted",
604
+ "timedOut"
605
+ ], "piTuiHostUserShell/run: result");
606
+ const stdout = parseOutput(result.stdout, "stdout");
607
+ const stderr = parseOutput(result.stderr, "stderr");
608
+ if (Buffer.byteLength(stdout.text, "utf8") + Buffer.byteLength(stderr.text, "utf8") > 98304) throw new TypeError("piTuiHostUserShell/run: result exceeds the combined stdout+stderr bound");
609
+ return {
610
+ exit: parseExit(result.exit),
611
+ stdout,
612
+ stderr,
613
+ sandboxDenied: booleanOf(result.sandboxDenied, "piTuiHostUserShell/run: result sandboxDenied"),
614
+ aborted: booleanOf(result.aborted, "piTuiHostUserShell/run: result aborted"),
615
+ timedOut: booleanOf(result.timedOut, "piTuiHostUserShell/run: result timedOut")
616
+ };
617
+ }
618
+ function boundedMessageOf(value, label) {
619
+ const message = stringOf(value, label);
620
+ if (Buffer.byteLength(message, "utf8") > 2048) throw new TypeError(`${label}: exceeds ${MAX_HOST_USER_SHELL_MESSAGE_BYTES} bytes`);
621
+ return message;
622
+ }
623
+ /** The single strict decoder for one unary Shell outcome. */
624
+ function parseHostUserShellRunOutcome(value) {
625
+ const outcome = recordOf$4(value, "piTuiHostUserShell/run: outcome");
626
+ if (outcome.kind === "settled") {
627
+ exactKeys$3(outcome, ["kind", "result"], "piTuiHostUserShell/run: settled outcome");
628
+ return {
629
+ kind: "settled",
630
+ result: parseResult(outcome.result)
631
+ };
632
+ }
633
+ if (outcome.kind === "refused") {
634
+ exactKeys$3(outcome, [
635
+ "kind",
636
+ "reason",
637
+ "message"
638
+ ], "piTuiHostUserShell/run: refused outcome");
639
+ if (outcome.reason !== "scope-unavailable" && outcome.reason !== "policy-unavailable" && outcome.reason !== "invalid-request") throw new TypeError("piTuiHostUserShell/run: refused reason is invalid");
640
+ return {
641
+ kind: "refused",
642
+ reason: outcome.reason,
643
+ message: boundedMessageOf(outcome.message, "piTuiHostUserShell/run: refusal message")
644
+ };
645
+ }
646
+ if (outcome.kind === "failed") {
647
+ exactKeys$3(outcome, [
648
+ "kind",
649
+ "phase",
650
+ "message"
651
+ ], "piTuiHostUserShell/run: failed outcome");
652
+ if (outcome.phase !== "sandbox-runner" && outcome.phase !== "infrastructure") throw new TypeError("piTuiHostUserShell/run: failed phase is invalid");
653
+ return {
654
+ kind: "failed",
655
+ phase: outcome.phase,
656
+ message: boundedMessageOf(outcome.message, "piTuiHostUserShell/run: failure message")
657
+ };
658
+ }
659
+ throw new TypeError("piTuiHostUserShell/run: outcome kind is invalid");
660
+ }
661
+ /** Strict decoder for Host completion arguments. */
662
+ function parseHostShellCompletionRequest(value) {
663
+ const request = recordOf$4(value, "piTuiHostUserShell/complete: request");
664
+ if (request.kind === "commands" || request.kind === "variables") {
665
+ exactKeys$3(request, ["kind", "prefix"], "piTuiHostUserShell/complete: request");
666
+ return {
667
+ kind: request.kind,
668
+ prefix: stringOf(request.prefix, "piTuiHostUserShell/complete: prefix", { empty: true })
669
+ };
670
+ }
671
+ if (request.kind === "subcommands") {
672
+ exactKeys$3(request, [
673
+ "kind",
674
+ "command",
675
+ "prefix"
676
+ ], "piTuiHostUserShell/complete: request");
677
+ return {
678
+ kind: "subcommands",
679
+ command: stringOf(request.command, "piTuiHostUserShell/complete: command"),
680
+ prefix: stringOf(request.prefix, "piTuiHostUserShell/complete: prefix", { empty: true })
681
+ };
682
+ }
683
+ if (request.kind === "paths") {
684
+ exactKeys$3(request, ["kind", "prefix"], "piTuiHostUserShell/complete: request");
685
+ return {
686
+ kind: "paths",
687
+ prefix: stringOf(request.prefix, "piTuiHostUserShell/complete: prefix", { empty: true })
688
+ };
689
+ }
690
+ throw new TypeError("piTuiHostUserShell/complete: request kind is invalid");
691
+ }
692
+ /** Strict bounded decoder for a unary completion result. */
693
+ function parseHostShellCompletionOutcome(value) {
694
+ const outcome = recordOf$4(value, "piTuiHostUserShell/complete: result");
695
+ if (outcome.kind === "unavailable") {
696
+ exactKeys$3(outcome, ["kind", "reason"], "piTuiHostUserShell/complete: unavailable result");
697
+ return {
698
+ kind: "unavailable",
699
+ reason: stringOf(outcome.reason, "piTuiHostUserShell/complete: reason")
700
+ };
701
+ }
702
+ if (outcome.kind !== "ok") throw new TypeError("piTuiHostUserShell/complete: result kind is invalid");
703
+ exactKeys$3(outcome, ["kind", "candidates"], "piTuiHostUserShell/complete: ok result");
704
+ if (!Array.isArray(outcome.candidates)) throw new TypeError("piTuiHostUserShell/complete: candidates must be an array");
705
+ if (outcome.candidates.length > 50) throw new TypeError("piTuiHostUserShell/complete: result exceeds 50 candidates");
706
+ const detached = {
707
+ kind: "ok",
708
+ candidates: outcome.candidates.map((candidate, index) => {
709
+ const text = stringOf(candidate, `piTuiHostUserShell/complete: candidate ${index}`);
710
+ if (Buffer.byteLength(text, "utf8") > 4096) throw new TypeError("piTuiHostUserShell/complete: candidate exceeds 4 KiB");
711
+ return text;
712
+ })
713
+ };
714
+ if (Buffer.byteLength(JSON.stringify(detached), "utf8") > 65536) throw new TypeError("piTuiHostUserShell/complete: result exceeds 64 KiB");
715
+ return detached;
716
+ }
717
+ function completionRequestCodec() {
718
+ return {
719
+ mode: "strict",
720
+ typeSymbol: "@xmoon76/dsh-pi-tui#piTuiHostUserShell/complete:request",
721
+ create: () => ({ parse: parseHostShellCompletionRequest }),
722
+ decode: parseHostShellCompletionRequest
723
+ };
724
+ }
725
+ function completionResultCodec() {
726
+ return {
727
+ mode: "strict",
728
+ typeSymbol: "@xmoon76/dsh-pi-tui#piTuiHostUserShell/complete:result",
729
+ create: () => ({ parse: parseHostShellCompletionOutcome }),
730
+ decode: parseHostShellCompletionOutcome
731
+ };
732
+ }
733
+ const RUN_OUTCOME_CODEC = {
734
+ mode: "strict",
735
+ typeSymbol: "@xmoon76/dsh-pi-tui#piTuiHostUserShell/run:result",
736
+ create: () => ({ parse: parseHostUserShellRunOutcome }),
737
+ decode: parseHostUserShellRunOutcome
738
+ };
739
+ const PI_TUI_HOST_USER_SHELL_RUN = {
740
+ id: PI_TUI_HOST_USER_SHELL_RUN_ENDPOINT,
741
+ service: PI_TUI_HOST_USER_SHELL_NAMESPACE,
742
+ namespace: PI_TUI_HOST_USER_SHELL_NAMESPACE,
743
+ method: "run",
744
+ invocation: { kind: "direct" },
745
+ parameters: [
746
+ {
747
+ name: "sessionId",
748
+ wire: "sessionId",
749
+ source: "json",
750
+ codec: stringCodec$1("@xmoon76/dsh-pi-tui#piTuiHostUserShell/run:sessionId")
751
+ },
752
+ {
753
+ name: "expectedCwd",
754
+ wire: "expectedCwd",
755
+ source: "json",
756
+ codec: stringCodec$1("@xmoon76/dsh-pi-tui#piTuiHostUserShell/run:expectedCwd")
757
+ },
758
+ {
759
+ name: "command",
760
+ wire: "command",
761
+ source: "json",
762
+ codec: stringCodec$1("@xmoon76/dsh-pi-tui#piTuiHostUserShell/run:command")
763
+ },
764
+ {
765
+ name: "policy",
766
+ wire: "policy",
767
+ source: "json",
768
+ codec: {
769
+ mode: "strict",
770
+ typeSymbol: "@xmoon76/dsh-pi-tui#piTuiHostUserShell/run:policy",
771
+ create: () => ({ parse: (value) => policyOf(value, "piTuiHostUserShell/run:policy") })
772
+ }
773
+ }
774
+ ],
775
+ cancellation: { parameter: "signal" },
776
+ result: RUN_OUTCOME_CODEC
777
+ };
778
+ const PI_TUI_HOST_USER_SHELL_COMPLETE = {
779
+ id: PI_TUI_HOST_USER_SHELL_COMPLETE_ENDPOINT,
780
+ service: PI_TUI_HOST_USER_SHELL_NAMESPACE,
781
+ namespace: PI_TUI_HOST_USER_SHELL_NAMESPACE,
782
+ method: "complete",
783
+ invocation: { kind: "direct" },
784
+ parameters: [{
785
+ name: "sessionId",
786
+ wire: "sessionId",
787
+ source: "json",
788
+ codec: stringCodec$1("@xmoon76/dsh-pi-tui#piTuiHostUserShell/complete:sessionId")
789
+ }, {
790
+ name: "request",
791
+ wire: "request",
792
+ source: "json",
793
+ codec: completionRequestCodec()
794
+ }],
795
+ cancellation: { parameter: "signal" },
796
+ result: completionResultCodec()
797
+ };
798
+ /**
799
+ * The ONE sessionless Workspace completion descriptor both contributions
800
+ * derive from: only the Host-issued `workspaceId` and the same strict
801
+ * completion request/result codecs as the Session method cross the wire.
802
+ */
803
+ const PI_TUI_HOST_USER_SHELL_COMPLETE_WORKSPACE = {
804
+ id: PI_TUI_HOST_USER_SHELL_COMPLETE_WORKSPACE_ENDPOINT,
805
+ service: PI_TUI_HOST_USER_SHELL_NAMESPACE,
806
+ namespace: PI_TUI_HOST_USER_SHELL_NAMESPACE,
807
+ method: "completeWorkspace",
808
+ invocation: { kind: "direct" },
809
+ parameters: [{
810
+ name: "workspaceId",
811
+ wire: "workspaceId",
812
+ source: "json",
813
+ codec: workspaceIdCodec$1("@xmoon76/dsh-pi-tui#piTuiHostUserShell/completeWorkspace:workspaceId")
814
+ }, {
815
+ name: "request",
816
+ wire: "request",
817
+ source: "json",
818
+ codec: completionRequestCodec()
819
+ }],
820
+ cancellation: { parameter: "signal" },
821
+ result: completionResultCodec()
822
+ };
823
+ //#endregion
824
+ //#region src/runtime/remote/pi-tui-skills-contract.ts
825
+ const PI_TUI_SKILLS_NAMESPACE = "piTuiSkills";
826
+ const PI_TUI_SKILLS_STANDING_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiSkills/standing";
827
+ const PI_TUI_SKILLS_WATCH_INVALIDATIONS_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiSkills/watchInvalidations";
828
+ function recordOf$3(value, label) {
829
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${label}: the value must be an object`);
830
+ return value;
831
+ }
832
+ function assertOnlyKeys(record, keys, label) {
833
+ for (const key of Object.keys(record)) if (!keys.includes(key)) throw new TypeError(`${label}: unexpected field ${JSON.stringify(key)}`);
834
+ }
835
+ function parsePiTuiSkillsStandingRequest(value) {
836
+ const record = recordOf$3(value, "piTuiSkills/standing request");
837
+ assertOnlyKeys(record, ["workspaceId", "presetId"], "piTuiSkills/standing request");
838
+ if (typeof record.workspaceId !== "string" || record.workspaceId === "") throw new TypeError("piTuiSkills/standing request: workspaceId must be a non-empty string");
839
+ if (record.presetId !== void 0 && (typeof record.presetId !== "string" || record.presetId === "")) throw new TypeError("piTuiSkills/standing request: presetId must be a non-empty string when supplied");
840
+ return {
841
+ workspaceId: record.workspaceId,
842
+ ...typeof record.presetId === "string" ? { presetId: record.presetId } : {}
843
+ };
844
+ }
845
+ function parsePiTuiSkillsStandingResult(value) {
846
+ const record = recordOf$3(value, "piTuiSkills/standing result");
847
+ assertOnlyKeys(record, [
848
+ "skills",
849
+ "complete",
850
+ "notice"
851
+ ], "piTuiSkills/standing result");
852
+ if (!Array.isArray(record.skills) || typeof record.complete !== "boolean") throw new TypeError("piTuiSkills/standing result: skills and complete are required");
853
+ if (record.notice !== void 0 && typeof record.notice !== "string") throw new TypeError("piTuiSkills/standing result: notice must be a string when supplied");
854
+ return {
855
+ skills: record.skills.map((value) => {
856
+ const skill = recordOf$3(value, "piTuiSkills/standing skill");
857
+ assertOnlyKeys(skill, [
858
+ "name",
859
+ "description",
860
+ "whenToUse",
861
+ "modelInvocable"
862
+ ], "piTuiSkills/standing skill");
863
+ if (typeof skill.name !== "string" || skill.name === "" || typeof skill.description !== "string" || typeof skill.modelInvocable !== "boolean" || skill.whenToUse !== void 0 && typeof skill.whenToUse !== "string") throw new TypeError("piTuiSkills/standing skill: malformed detached skill metadata");
864
+ return {
865
+ name: skill.name,
866
+ description: skill.description,
867
+ ...typeof skill.whenToUse === "string" ? { whenToUse: skill.whenToUse } : {},
868
+ modelInvocable: skill.modelInvocable
869
+ };
870
+ }),
871
+ complete: record.complete,
872
+ ...typeof record.notice === "string" ? { notice: record.notice } : {}
873
+ };
874
+ }
875
+ function parsePiTuiSkillsInvalidationFrame(value) {
876
+ const record = recordOf$3(value, "piTuiSkills/watchInvalidations frame");
877
+ assertOnlyKeys(record, ["kind"], "piTuiSkills/watchInvalidations frame");
878
+ if (record.kind !== "invalidated") throw new TypeError("piTuiSkills/watchInvalidations frame: kind must be invalidated");
879
+ return { kind: "invalidated" };
880
+ }
881
+ const REQUEST_CODEC = {
882
+ mode: "strict",
883
+ typeSymbol: `${PI_TUI_SKILLS_STANDING_ENDPOINT}:request`,
884
+ create: () => ({ parse: parsePiTuiSkillsStandingRequest })
885
+ };
886
+ const STANDING_RESULT_CODEC = {
887
+ mode: "strict",
888
+ typeSymbol: `${PI_TUI_SKILLS_STANDING_ENDPOINT}:result`,
889
+ create: () => ({ parse: parsePiTuiSkillsStandingResult }),
890
+ decode: parsePiTuiSkillsStandingResult
891
+ };
892
+ const INVALIDATION_FRAME_CODEC = {
893
+ mode: "strict",
894
+ typeSymbol: `${PI_TUI_SKILLS_WATCH_INVALIDATIONS_ENDPOINT}:frame`,
895
+ create: () => ({ parse: parsePiTuiSkillsInvalidationFrame }),
896
+ decode: parsePiTuiSkillsInvalidationFrame
897
+ };
898
+ const PI_TUI_SKILLS_STANDING = {
899
+ id: PI_TUI_SKILLS_STANDING_ENDPOINT,
900
+ service: PI_TUI_SKILLS_NAMESPACE,
901
+ namespace: PI_TUI_SKILLS_NAMESPACE,
902
+ method: "standing",
903
+ invocation: { kind: "direct" },
904
+ parameters: [{
905
+ name: "request",
906
+ wire: "request",
907
+ source: "json",
908
+ codec: REQUEST_CODEC
909
+ }],
910
+ cancellation: { parameter: "signal" },
911
+ result: STANDING_RESULT_CODEC
912
+ };
913
+ const PI_TUI_SKILLS_WATCH_INVALIDATIONS = {
914
+ id: PI_TUI_SKILLS_WATCH_INVALIDATIONS_ENDPOINT,
915
+ service: PI_TUI_SKILLS_NAMESPACE,
916
+ namespace: PI_TUI_SKILLS_NAMESPACE,
917
+ method: "watchInvalidations",
918
+ mode: "stream",
919
+ invocation: { kind: "direct" },
920
+ parameters: [],
921
+ cancellation: { parameter: "signal" },
922
+ result: INVALIDATION_FRAME_CODEC
923
+ };
924
+ //#endregion
925
+ //#region src/runtime/remote/pi-tui-file-reference-contract.ts
926
+ /** The wire namespace (and Host Cordis service key) of the augmentation. */
927
+ const PI_TUI_FILE_REFERENCES_NAMESPACE = "piTuiFileReferences";
928
+ /** The Session-scoped private method's stable endpoint identity. */
929
+ const PI_TUI_FILE_REFERENCES_LIST_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiFileReferences/list";
930
+ /** The sessionless Workspace method's stable endpoint identity. */
931
+ const PI_TUI_FILE_REFERENCES_LIST_WORKSPACE_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiFileReferences/listWorkspace";
932
+ /** One strict JSON codec that validates a wire string. */
933
+ function stringCodec(typeSymbol) {
934
+ return {
935
+ mode: "strict",
936
+ typeSymbol,
937
+ create: () => ({ parse: (value) => {
938
+ if (typeof value !== "string") throw new TypeError(`${typeSymbol}: the wire value must be a string`);
939
+ return value;
940
+ } })
941
+ };
942
+ }
943
+ /**
944
+ * The strict codec for a Host-issued Workspace identity: a NON-EMPTY string.
945
+ * An empty `workspaceId` names no Host resource at all, so the wire boundary
946
+ * refuses it (plan §4.2) instead of letting a fabricated id reach the Host
947
+ * business layer.
948
+ */
949
+ function workspaceIdCodec(typeSymbol) {
950
+ return {
951
+ mode: "strict",
952
+ typeSymbol,
953
+ create: () => ({ parse: (value) => {
954
+ if (typeof value !== "string") throw new TypeError(`${typeSymbol}: the wire value must be a string`);
955
+ if (value === "") throw new TypeError(`${typeSymbol}: the wire value must be a non-empty Workspace id`);
956
+ return value;
957
+ } })
958
+ };
959
+ }
960
+ /**
961
+ * Validate and detach one wire `HostFileListResult`. The result is produced by
962
+ * this package's own Host router, but it is still a wire boundary on the Client
963
+ * and the ONLY place the shape crosses.
964
+ */
965
+ function decodeHostFileListResult(value, method) {
966
+ if (typeof value !== "object" || value === null) throw new TypeError(`${method}: the result must be an object`);
967
+ const record = value;
968
+ if (record.kind === "unavailable") {
969
+ if (typeof record.reason !== "string") throw new TypeError(`${method}: an unavailable result needs a reason`);
970
+ return {
971
+ kind: "unavailable",
972
+ reason: record.reason
973
+ };
974
+ }
975
+ if (record.kind !== "ok" || !Array.isArray(record.items)) throw new TypeError(`${method}: the result must be ok(items) or unavailable(reason)`);
976
+ return {
977
+ kind: "ok",
978
+ items: record.items.map((entry) => {
979
+ if (typeof entry !== "object" || entry === null) throw new TypeError(`${method}: every candidate must be an object`);
980
+ const candidate = entry;
981
+ if (typeof candidate.path !== "string" || candidate.kind !== "file" && candidate.kind !== "directory") throw new TypeError(`${method}: every candidate needs a string path and a file/directory kind`);
982
+ return {
983
+ path: candidate.path,
984
+ kind: candidate.kind
985
+ };
986
+ })
987
+ };
988
+ }
989
+ /** The strict result codec shared by both private methods (one decoder). */
990
+ function hostFileListResultCodec(method, typeSymbol) {
991
+ const decode = (value) => decodeHostFileListResult(value, method);
992
+ return {
993
+ mode: "strict",
994
+ typeSymbol,
995
+ create: () => ({ parse: decode }),
996
+ decode
997
+ };
998
+ }
999
+ const HOST_FILE_LIST_RESULT_CODEC = hostFileListResultCodec("piTuiFileReferences/list", "@xmoon76/dsh-pi-tui#piTuiFileReferences/list:result");
1000
+ const HOST_FILE_LIST_WORKSPACE_RESULT_CODEC = hostFileListResultCodec("piTuiFileReferences/listWorkspace", "@xmoon76/dsh-pi-tui#piTuiFileReferences/listWorkspace:result");
1001
+ /**
1002
+ * The ONE shared Session-scoped invocation descriptor both contributions derive
1003
+ * from. The Host registers this exact object; the Client mounts this exact
1004
+ * object.
1005
+ */
1006
+ const PI_TUI_FILE_REFERENCES_LIST = {
1007
+ id: PI_TUI_FILE_REFERENCES_LIST_ENDPOINT,
1008
+ service: PI_TUI_FILE_REFERENCES_NAMESPACE,
1009
+ namespace: PI_TUI_FILE_REFERENCES_NAMESPACE,
1010
+ method: "list",
1011
+ invocation: { kind: "direct" },
1012
+ parameters: [{
1013
+ name: "sessionId",
1014
+ wire: "sessionId",
1015
+ source: "json",
1016
+ codec: stringCodec("@xmoon76/dsh-pi-tui#piTuiFileReferences/list:sessionId")
1017
+ }, {
1018
+ name: "query",
1019
+ wire: "query",
1020
+ source: "json",
1021
+ codec: stringCodec("@xmoon76/dsh-pi-tui#piTuiFileReferences/list:query")
1022
+ }],
1023
+ cancellation: { parameter: "signal" },
1024
+ result: HOST_FILE_LIST_RESULT_CODEC
1025
+ };
1026
+ /**
1027
+ * The ONE shared sessionless Workspace invocation descriptor both contributions
1028
+ * derive from. The Host registers this exact object; the Client mounts this
1029
+ * exact object. Only the Host-issued `workspaceId` and the official query form
1030
+ * cross the wire.
1031
+ */
1032
+ const PI_TUI_FILE_REFERENCES_LIST_WORKSPACE = {
1033
+ id: PI_TUI_FILE_REFERENCES_LIST_WORKSPACE_ENDPOINT,
1034
+ service: PI_TUI_FILE_REFERENCES_NAMESPACE,
1035
+ namespace: PI_TUI_FILE_REFERENCES_NAMESPACE,
1036
+ method: "listWorkspace",
1037
+ invocation: { kind: "direct" },
1038
+ parameters: [{
1039
+ name: "workspaceId",
1040
+ wire: "workspaceId",
1041
+ source: "json",
1042
+ codec: workspaceIdCodec("@xmoon76/dsh-pi-tui#piTuiFileReferences/listWorkspace:workspaceId")
1043
+ }, {
1044
+ name: "query",
1045
+ wire: "query",
1046
+ source: "json",
1047
+ codec: stringCodec("@xmoon76/dsh-pi-tui#piTuiFileReferences/listWorkspace:query")
1048
+ }],
1049
+ cancellation: { parameter: "signal" },
1050
+ result: HOST_FILE_LIST_WORKSPACE_RESULT_CODEC
1051
+ };
1052
+ //#endregion
1053
+ //#region src/runtime/remote/pi-tui-session-policy-contract.ts
1054
+ /** The wire namespace (and Host Cordis service key) of the private service. */
1055
+ const PI_TUI_SESSION_POLICY_NAMESPACE = "piTuiSessionPolicy";
1056
+ /** The read endpoint's stable identity. */
1057
+ const PI_TUI_SESSION_POLICY_READ_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiSessionPolicy/read";
1058
+ /** The approval write endpoint's stable identity. */
1059
+ const PI_TUI_SESSION_POLICY_SET_APPROVAL_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiSessionPolicy/setApproval";
1060
+ const READ_LABEL = "piTuiSessionPolicy/read result";
1061
+ const SET_LABEL = "piTuiSessionPolicy/setApproval result";
1062
+ const SESSION_ID_LABEL = "piTuiSessionPolicy sessionId";
1063
+ const POLICY_LABEL = "piTuiSessionPolicy policy";
1064
+ function recordOf$2(value, label) {
1065
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${label}: the value must be an object`);
1066
+ return value;
1067
+ }
1068
+ function exactKeys$2(record, keys, label) {
1069
+ for (const key of Object.keys(record)) if (!keys.includes(key)) throw new TypeError(`${label}: unexpected field ${JSON.stringify(key)}`);
1070
+ }
1071
+ function requiredKeys(record, keys, label) {
1072
+ for (const key of keys) if (!Object.hasOwn(record, key)) throw new TypeError(`${label}: missing field ${JSON.stringify(key)}`);
1073
+ }
1074
+ /** Validate one non-empty session id as wire text and return it. */
1075
+ function parseSessionPolicySessionId(value) {
1076
+ if (typeof value !== "string" || value === "") throw new TypeError(`${SESSION_ID_LABEL}: expected a non-empty string`);
1077
+ return value;
1078
+ }
1079
+ /** Validate one approval policy against the closed official vocabulary. */
1080
+ function parseSessionApprovalPolicy(value) {
1081
+ if (value !== "ask" && value !== "never") throw new TypeError(`${POLICY_LABEL}: expected ask or never`);
1082
+ return value;
1083
+ }
1084
+ const SANDBOX_MODES = [
1085
+ "read-only",
1086
+ "workspace-write",
1087
+ "danger-full-access"
1088
+ ];
1089
+ function parseSandboxMode(value, label) {
1090
+ if (!SANDBOX_MODES.includes(value)) throw new TypeError(`${label}: unknown sandbox mode ${JSON.stringify(value)}`);
1091
+ return value;
1092
+ }
1093
+ /** Validate and detach one knob's wire side (closed state union, exact keys). */
1094
+ function parsePolicySide(value, parseValue, label) {
1095
+ const record = recordOf$2(value, label);
1096
+ if (record.state === "unavailable") {
1097
+ exactKeys$2(record, ["state", "reason"], label);
1098
+ if (record.reason !== "service-not-installed") throw new TypeError(`${label}: unknown unavailable reason ${JSON.stringify(record.reason)}`);
1099
+ return {
1100
+ state: "unavailable",
1101
+ reason: "service-not-installed"
1102
+ };
1103
+ }
1104
+ if (record.state !== "ready") throw new TypeError(`${label}: unknown state ${JSON.stringify(record.state)}`);
1105
+ if (Object.hasOwn(record, "override")) {
1106
+ exactKeys$2(record, [
1107
+ "state",
1108
+ "effective",
1109
+ "override"
1110
+ ], label);
1111
+ return {
1112
+ state: "ready",
1113
+ effective: parseValue(record.effective, label),
1114
+ override: parseValue(record.override, label)
1115
+ };
1116
+ }
1117
+ exactKeys$2(record, ["state", "effective"], label);
1118
+ return {
1119
+ state: "ready",
1120
+ effective: parseValue(record.effective, label)
1121
+ };
1122
+ }
1123
+ /**
1124
+ * Validate and detach the WHOLE `read` result. An unusable frame (an extra
1125
+ * field, an unknown enum, a guessed default where the Host stated none) fails
1126
+ * the whole read: the adapter must never reshape a partially-valid frame into
1127
+ * an authoritative answer.
1128
+ */
1129
+ function parseSessionPolicyRead(value) {
1130
+ const record = recordOf$2(value, READ_LABEL);
1131
+ if (record.kind === "unavailable") {
1132
+ exactKeys$2(record, [
1133
+ "kind",
1134
+ "sessionId",
1135
+ "reason"
1136
+ ], READ_LABEL);
1137
+ if (record.reason !== "session-not-live") throw new TypeError(`${READ_LABEL}: unknown unavailable reason ${JSON.stringify(record.reason)}`);
1138
+ return {
1139
+ kind: "unavailable",
1140
+ sessionId: parseSessionPolicySessionId(record.sessionId),
1141
+ reason: "session-not-live"
1142
+ };
1143
+ }
1144
+ if (record.kind !== "ready") throw new TypeError(`${READ_LABEL}: unknown kind ${JSON.stringify(record.kind)}`);
1145
+ exactKeys$2(record, [
1146
+ "kind",
1147
+ "sessionId",
1148
+ "approval",
1149
+ "sandbox"
1150
+ ], READ_LABEL);
1151
+ requiredKeys(record, [
1152
+ "kind",
1153
+ "sessionId",
1154
+ "approval",
1155
+ "sandbox"
1156
+ ], READ_LABEL);
1157
+ return {
1158
+ kind: "ready",
1159
+ sessionId: parseSessionPolicySessionId(record.sessionId),
1160
+ approval: parsePolicySide(record.approval, parseSessionApprovalPolicy, `${READ_LABEL} approval side`),
1161
+ sandbox: parsePolicySide(record.sandbox, parseSandboxMode, `${READ_LABEL} sandbox side`)
1162
+ };
1163
+ }
1164
+ const SET_REFUSAL_REASONS = [
1165
+ "session-not-live",
1166
+ "agent-not-live",
1167
+ "approval-unavailable"
1168
+ ];
1169
+ /** Validate and detach the `setApproval` result (closed union, exact keys). */
1170
+ function parseSessionPolicySetWireOutcome(value) {
1171
+ const record = recordOf$2(value, SET_LABEL);
1172
+ if (record.kind === "applied") {
1173
+ exactKeys$2(record, ["kind", "sessionId"], SET_LABEL);
1174
+ return {
1175
+ kind: "applied",
1176
+ sessionId: parseSessionPolicySessionId(record.sessionId)
1177
+ };
1178
+ }
1179
+ if (record.kind === "refused") {
1180
+ exactKeys$2(record, ["kind", "reason"], SET_LABEL);
1181
+ if (!SET_REFUSAL_REASONS.includes(record.reason)) throw new TypeError(`${SET_LABEL}: unknown refusal reason ${JSON.stringify(record.reason)}`);
1182
+ return {
1183
+ kind: "refused",
1184
+ reason: record.reason
1185
+ };
1186
+ }
1187
+ throw new TypeError(`${SET_LABEL}: unknown kind ${JSON.stringify(record.kind)}`);
1188
+ }
1189
+ const READ_CODEC = {
1190
+ mode: "strict",
1191
+ typeSymbol: `${PI_TUI_SESSION_POLICY_READ_ENDPOINT}:result`,
1192
+ create: () => ({ parse: parseSessionPolicyRead }),
1193
+ decode: parseSessionPolicyRead
1194
+ };
1195
+ const SET_CODEC = {
1196
+ mode: "strict",
1197
+ typeSymbol: `${PI_TUI_SESSION_POLICY_SET_APPROVAL_ENDPOINT}:result`,
1198
+ create: () => ({ parse: parseSessionPolicySetWireOutcome }),
1199
+ decode: parseSessionPolicySetWireOutcome
1200
+ };
1201
+ const SESSION_ID_CODEC$1 = {
1202
+ mode: "strict",
1203
+ typeSymbol: `${PI_TUI_SESSION_POLICY_READ_ENDPOINT}:sessionId`,
1204
+ create: () => ({ parse: parseSessionPolicySessionId }),
1205
+ decode: parseSessionPolicySessionId
1206
+ };
1207
+ const POLICY_CODEC = {
1208
+ mode: "strict",
1209
+ typeSymbol: `${PI_TUI_SESSION_POLICY_SET_APPROVAL_ENDPOINT}:policy`,
1210
+ create: () => ({ parse: parseSessionApprovalPolicy }),
1211
+ decode: parseSessionApprovalPolicy
1212
+ };
1213
+ /** The exact-Session read invocation both contributions derive from. */
1214
+ const PI_TUI_SESSION_POLICY_READ = {
1215
+ id: PI_TUI_SESSION_POLICY_READ_ENDPOINT,
1216
+ service: PI_TUI_SESSION_POLICY_NAMESPACE,
1217
+ namespace: PI_TUI_SESSION_POLICY_NAMESPACE,
1218
+ method: "read",
1219
+ invocation: { kind: "direct" },
1220
+ parameters: [{
1221
+ name: "sessionId",
1222
+ wire: "sessionId",
1223
+ source: "json",
1224
+ codec: SESSION_ID_CODEC$1
1225
+ }],
1226
+ cancellation: { parameter: "signal" },
1227
+ result: READ_CODEC
1228
+ };
1229
+ /** The exact-Session approval write invocation both contributions derive from. */
1230
+ const PI_TUI_SESSION_POLICY_SET_APPROVAL = {
1231
+ id: PI_TUI_SESSION_POLICY_SET_APPROVAL_ENDPOINT,
1232
+ service: PI_TUI_SESSION_POLICY_NAMESPACE,
1233
+ namespace: PI_TUI_SESSION_POLICY_NAMESPACE,
1234
+ method: "setApproval",
1235
+ invocation: { kind: "direct" },
1236
+ parameters: [{
1237
+ name: "sessionId",
1238
+ wire: "sessionId",
1239
+ source: "json",
1240
+ codec: SESSION_ID_CODEC$1
1241
+ }, {
1242
+ name: "policy",
1243
+ wire: "policy",
1244
+ source: "json",
1245
+ codec: POLICY_CODEC
1246
+ }],
1247
+ cancellation: { parameter: "signal" },
1248
+ result: SET_CODEC
1249
+ };
1250
+ //#endregion
1251
+ //#region src/runtime/remote/pi-tui-default-model-contract.ts
1252
+ /** The wire namespace (and Host Cordis service key) of the private service. */
1253
+ const PI_TUI_DEFAULT_MODEL_NAMESPACE = "piTuiDefaultModel";
1254
+ /** The sessionless default-model save endpoint's stable identity. */
1255
+ const PI_TUI_DEFAULT_MODEL_SAVE_SELECTION_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiDefaultModel/saveSelection";
1256
+ const SELECTION_LABEL = "piTuiDefaultModel/saveSelection selection";
1257
+ const RESULT_LABEL = "piTuiDefaultModel/saveSelection result";
1258
+ const REFUSAL_REASONS$1 = [
1259
+ "owner-required",
1260
+ "default-model-service-unavailable",
1261
+ "profile-persistence-unavailable",
1262
+ "profile-entry-unavailable"
1263
+ ];
1264
+ function recordOf$1(value, label) {
1265
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${label}: the value must be an object`);
1266
+ return value;
1267
+ }
1268
+ function exactKeys$1(record, keys, label) {
1269
+ for (const key of Object.keys(record)) if (!keys.includes(key)) throw new TypeError(`${label}: unexpected field ${JSON.stringify(key)}`);
1270
+ }
1271
+ /** A model identifier: a NON-EMPTY string, deliberately NOT trimmed (whitespace
1272
+ * is part of an identifier if a provider elected to use it, matching
1273
+ * `normalizeModelSelection`). */
1274
+ function parseIdentifier(value, label) {
1275
+ if (typeof value !== "string" || value === "") throw new TypeError(`${label}: expected a non-empty string`);
1276
+ return value;
1277
+ }
1278
+ /**
1279
+ * Validate and detach one wire selection. Exact keys only: `provider` and
1280
+ * `model` (non-empty strings) plus an OPTIONAL non-empty `reasoningEffort`.
1281
+ * `null`, a number, an array or any extra field is refused at the boundary.
1282
+ */
1283
+ function parseDefaultModelSelection(value) {
1284
+ const record = recordOf$1(value, SELECTION_LABEL);
1285
+ exactKeys$1(record, [
1286
+ "provider",
1287
+ "model",
1288
+ "reasoningEffort"
1289
+ ], SELECTION_LABEL);
1290
+ if (!Object.hasOwn(record, "provider")) throw new TypeError(`${SELECTION_LABEL}: missing field "provider"`);
1291
+ if (!Object.hasOwn(record, "model")) throw new TypeError(`${SELECTION_LABEL}: missing field "model"`);
1292
+ const provider = parseIdentifier(record.provider, `${SELECTION_LABEL} provider`);
1293
+ const model = parseIdentifier(record.model, `${SELECTION_LABEL} model`);
1294
+ if (record.reasoningEffort === void 0) return {
1295
+ provider,
1296
+ model
1297
+ };
1298
+ return {
1299
+ provider,
1300
+ model,
1301
+ reasoningEffort: parseIdentifier(record.reasoningEffort, `${SELECTION_LABEL} reasoningEffort`)
1302
+ };
1303
+ }
1304
+ /** Validate and detach one Host result (closed union, exact keys). */
1305
+ function parseDefaultModelSaveResult(value) {
1306
+ const record = recordOf$1(value, RESULT_LABEL);
1307
+ if (record.kind === "saved") {
1308
+ exactKeys$1(record, ["kind"], RESULT_LABEL);
1309
+ return { kind: "saved" };
1310
+ }
1311
+ if (record.kind === "refused") {
1312
+ exactKeys$1(record, ["kind", "reason"], RESULT_LABEL);
1313
+ if (!REFUSAL_REASONS$1.includes(record.reason)) throw new TypeError(`${RESULT_LABEL}: unknown refusal reason ${JSON.stringify(record.reason)}`);
1314
+ return {
1315
+ kind: "refused",
1316
+ reason: record.reason
1317
+ };
1318
+ }
1319
+ throw new TypeError(`${RESULT_LABEL}: unknown kind ${JSON.stringify(record.kind)}`);
1320
+ }
1321
+ /** The ONE shared invocation descriptor both contributions derive from. The
1322
+ * Host registers this exact object; the Client mounts this exact object. */
1323
+ const PI_TUI_DEFAULT_MODEL_SAVE_SELECTION = {
1324
+ id: PI_TUI_DEFAULT_MODEL_SAVE_SELECTION_ENDPOINT,
1325
+ service: PI_TUI_DEFAULT_MODEL_NAMESPACE,
1326
+ namespace: PI_TUI_DEFAULT_MODEL_NAMESPACE,
1327
+ method: "saveSelection",
1328
+ invocation: { kind: "direct" },
1329
+ parameters: [{
1330
+ name: "selection",
1331
+ wire: "selection",
1332
+ source: "json",
1333
+ codec: {
1334
+ mode: "strict",
1335
+ typeSymbol: `${PI_TUI_DEFAULT_MODEL_SAVE_SELECTION_ENDPOINT}:selection`,
1336
+ create: () => ({ parse: parseDefaultModelSelection }),
1337
+ decode: parseDefaultModelSelection
1338
+ }
1339
+ }],
1340
+ cancellation: { parameter: "signal" },
1341
+ result: {
1342
+ mode: "strict",
1343
+ typeSymbol: `${PI_TUI_DEFAULT_MODEL_SAVE_SELECTION_ENDPOINT}:result`,
1344
+ create: () => ({ parse: parseDefaultModelSaveResult }),
1345
+ decode: parseDefaultModelSaveResult
1346
+ }
1347
+ };
1348
+ //#endregion
1349
+ //#region src/runtime/remote/pi-tui-prompt-presence-contract.ts
1350
+ /** The wire namespace (and Host Cordis service key) of the private service. */
1351
+ const PI_TUI_PROMPT_PRESENCE_NAMESPACE = "piTuiPromptPresence";
1352
+ /** The sync endpoint's stable identity. */
1353
+ const PI_TUI_PROMPT_PRESENCE_SYNC_VIEW_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiPromptPresence/syncView";
1354
+ const SYNC_RESULT_LABEL = "piTuiPromptPresence/syncView result";
1355
+ const REFUSAL_REASONS = [
1356
+ "owner-required",
1357
+ "session-not-live",
1358
+ "stale-revision",
1359
+ "scope-unavailable"
1360
+ ];
1361
+ /** The three selectable display presets (the wire vocabulary). */
1362
+ const DISPLAY_PRESETS = [
1363
+ "focus",
1364
+ "compact",
1365
+ "full"
1366
+ ];
1367
+ function recordOf(value, label) {
1368
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${label}: the value must be an object`);
1369
+ return value;
1370
+ }
1371
+ function exactKeys(record, keys, label) {
1372
+ for (const key of Object.keys(record)) if (!keys.includes(key)) throw new TypeError(`${label}: unexpected field ${JSON.stringify(key)}`);
1373
+ }
1374
+ /**
1375
+ * Validate one wire Session identity: a non-empty string, or `null` for "this
1376
+ * Peer currently views no Session". An empty string is NOT the null form — a
1377
+ * Client must say exactly which of the two it means.
1378
+ */
1379
+ function parsePresenceViewedSessionId(value) {
1380
+ if (value === null) return null;
1381
+ if (typeof value !== "string" || value === "") throw new TypeError("piTuiPromptPresence syncView: viewedSessionId must be a non-empty string or null");
1382
+ return value;
1383
+ }
1384
+ /** Validate one wire display preset. */
1385
+ function parsePresenceDisplayPreset(value) {
1386
+ if (typeof value === "string" && DISPLAY_PRESETS.includes(value)) return value;
1387
+ throw new TypeError(`piTuiPromptPresence syncView: displayPreset must be one of ${DISPLAY_PRESETS.join("|")}`);
1388
+ }
1389
+ /** Validate one monotonic Client revision (a positive safe integer). */
1390
+ function parsePresenceRevision(value) {
1391
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) throw new TypeError("piTuiPromptPresence syncView: revision must be a positive safe integer");
1392
+ return value;
1393
+ }
1394
+ /** Validate and detach one `syncView` result. */
1395
+ function parsePresenceSyncResult(value) {
1396
+ const record = recordOf(value, SYNC_RESULT_LABEL);
1397
+ if (record.kind === "applied") {
1398
+ exactKeys(record, ["kind", "revision"], SYNC_RESULT_LABEL);
1399
+ return {
1400
+ kind: "applied",
1401
+ revision: parsePresenceRevision(record.revision)
1402
+ };
1403
+ }
1404
+ if (record.kind === "refused") {
1405
+ exactKeys(record, ["kind", "reason"], SYNC_RESULT_LABEL);
1406
+ if (!REFUSAL_REASONS.includes(record.reason)) throw new TypeError(`${SYNC_RESULT_LABEL}: unknown refusal reason ${JSON.stringify(record.reason)}`);
1407
+ return {
1408
+ kind: "refused",
1409
+ reason: record.reason
1410
+ };
1411
+ }
1412
+ throw new TypeError(`${SYNC_RESULT_LABEL}: unknown kind ${JSON.stringify(record.kind)}`);
1413
+ }
1414
+ /** The explicit Client contribution mounted once with `ctx.remote.$mount`. */
1415
+ const PI_TUI_CLIENT_CONTRIBUTION = {
1416
+ package: "@xmoon76/dsh-pi-tui",
1417
+ descriptors: [
1418
+ PI_TUI_FILE_REFERENCES_LIST,
1419
+ PI_TUI_FILE_REFERENCES_LIST_WORKSPACE,
1420
+ PI_TUI_HOST_USER_SHELL_RUN,
1421
+ PI_TUI_HOST_USER_SHELL_COMPLETE,
1422
+ PI_TUI_HOST_USER_SHELL_COMPLETE_WORKSPACE,
1423
+ PI_TUI_TERMINAL_PROGRESS_WATCH,
1424
+ PI_TUI_WEB_ACCESS_GET_STATUS,
1425
+ PI_TUI_WEB_ACCESS_SET_ENABLED,
1426
+ PI_TUI_WEB_ACCESS_GET_AUTHENTICATED_URL,
1427
+ PI_TUI_ACP_ACCESS_GET_STATUS,
1428
+ PI_TUI_ACP_ACCESS_SET_ENABLED,
1429
+ PI_TUI_SKILLS_STANDING,
1430
+ PI_TUI_SKILLS_WATCH_INVALIDATIONS,
1431
+ PI_TUI_AUTHORIZATION_LIST,
1432
+ PI_TUI_AUTHORIZATION_RUN,
1433
+ PI_TUI_AUTHORIZATION_RESPOND,
1434
+ PI_TUI_AUTHORIZATION_CANCEL,
1435
+ PI_TUI_CREDENTIAL_RECORDS_LIST,
1436
+ PI_TUI_CREDENTIAL_RECORDS_DELETE,
1437
+ PI_TUI_SESSION_POLICY_READ,
1438
+ PI_TUI_SESSION_POLICY_SET_APPROVAL,
1439
+ PI_TUI_DEFAULT_MODEL_SAVE_SELECTION,
1440
+ {
1441
+ id: PI_TUI_PROMPT_PRESENCE_SYNC_VIEW_ENDPOINT,
1442
+ service: PI_TUI_PROMPT_PRESENCE_NAMESPACE,
1443
+ namespace: PI_TUI_PROMPT_PRESENCE_NAMESPACE,
1444
+ method: "syncView",
1445
+ invocation: { kind: "direct" },
1446
+ parameters: [
1447
+ {
1448
+ name: "viewedSessionId",
1449
+ wire: "viewedSessionId",
1450
+ source: "json",
1451
+ codec: {
1452
+ mode: "strict",
1453
+ typeSymbol: `${PI_TUI_PROMPT_PRESENCE_SYNC_VIEW_ENDPOINT}:viewedSessionId`,
1454
+ create: () => ({ parse: parsePresenceViewedSessionId }),
1455
+ decode: parsePresenceViewedSessionId
1456
+ }
1457
+ },
1458
+ {
1459
+ name: "displayPreset",
1460
+ wire: "displayPreset",
1461
+ source: "json",
1462
+ codec: {
1463
+ mode: "strict",
1464
+ typeSymbol: `${PI_TUI_PROMPT_PRESENCE_SYNC_VIEW_ENDPOINT}:displayPreset`,
1465
+ create: () => ({ parse: parsePresenceDisplayPreset }),
1466
+ decode: parsePresenceDisplayPreset
1467
+ }
1468
+ },
1469
+ {
1470
+ name: "revision",
1471
+ wire: "revision",
1472
+ source: "json",
1473
+ codec: {
1474
+ mode: "strict",
1475
+ typeSymbol: `${PI_TUI_PROMPT_PRESENCE_SYNC_VIEW_ENDPOINT}:revision`,
1476
+ create: () => ({ parse: parsePresenceRevision }),
1477
+ decode: parsePresenceRevision
1478
+ }
1479
+ }
1480
+ ],
1481
+ cancellation: { parameter: "signal" },
1482
+ result: {
1483
+ mode: "strict",
1484
+ typeSymbol: `${PI_TUI_PROMPT_PRESENCE_SYNC_VIEW_ENDPOINT}:result`,
1485
+ create: () => ({ parse: parsePresenceSyncResult }),
1486
+ decode: parsePresenceSyncResult
1487
+ }
1488
+ }
1489
+ ]
1490
+ };
1491
+ //#endregion
1492
+ export { PI_TUI_SKILLS_NAMESPACE as a, PI_TUI_CREDENTIAL_RECORDS_NAMESPACE as c, PI_TUI_AUTHORIZATION_NAMESPACE as d, parsePiTuiAuthorizationFrame as f, PI_TUI_FILE_REFERENCES_NAMESPACE as i, parsePiTuiCredentialRecordKey as l, PI_TUI_DEFAULT_MODEL_NAMESPACE as n, parsePiTuiSkillsInvalidationFrame as o, parsePiTuiAuthorizationTargetsSnapshot as p, PI_TUI_SESSION_POLICY_NAMESPACE as r, parseHostShellCompletionOutcome as s, PI_TUI_CLIENT_CONTRIBUTION as t, parsePiTuiCredentialRecordList as u };