@xmoon76/dsh-pi-tui 0.5.3 → 0.5.5
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 +195 -150
- package/README.md +137 -103
- package/cordis.patch.yml +54 -2
- package/dist/application-runtime-CbBO4bY-.mjs +6860 -0
- package/dist/bootstrap-DLOydLLj.mjs +108410 -0
- package/dist/builtins.mjs +2 -3
- package/dist/client-bootstrap-DwSFzcTW.mjs +872 -0
- package/dist/context-summary-Bz0AGXa1.mjs +12027 -0
- package/dist/context-summary-D9mhxPXL.mjs +10015 -0
- package/dist/custom-items-CKrOBCox.mjs +655 -0
- package/dist/disposal-BYBbEpVY.mjs +54 -0
- package/dist/dispose-cause-BzcXo4hu.mjs +123 -0
- package/dist/dispose-cause-CNFuUnjR.mjs +24 -0
- package/dist/dist-C7QMk0ws.mjs +15431 -0
- package/dist/entry-control-DnduyDiw.mjs +92 -0
- package/dist/extension/advanced.d.mts +1 -1
- package/dist/extension/unstable.d.mts +1 -1
- package/dist/{extensions-DzpBiiYb.d.mts → extensions-Bte3XOt5.d.mts} +1 -1
- package/dist/{extensions-a-rxanjw.mjs → extensions-pcFiH7Qe.mjs} +1498 -410
- package/dist/extensions.d.mts +2 -2
- package/dist/extensions.mjs +1 -1
- package/dist/host-bootstrap-CKdfLkNS.mjs +188 -0
- package/dist/host-foundation-probe-CYHsbAw6.mjs +143 -0
- package/dist/host-prerequisites-9JBTtVNu.mjs +36 -0
- package/dist/host-runtime.d.mts +26 -0
- package/dist/host-runtime.mjs +450 -0
- package/dist/index.d.mts +9 -2
- package/dist/index.mjs +45779 -24480
- package/dist/local-client.mjs +1816 -0
- package/dist/local-discovery-CXnLT4GF.mjs +755 -0
- package/dist/local-discovery-DVFFpfBG.mjs +2 -0
- package/dist/local-host.mjs +1025 -0
- package/dist/local-transport-C9aonplC.mjs +513 -0
- package/dist/performance-host.d.mts +2 -2
- package/dist/performance-host.mjs +258 -1
- package/dist/{performance-view-jvvd8Jn7.mjs → performance-view-CfGvLZyD.mjs} +1 -1
- package/dist/pi-tui-remote-contribution-DRk6Tl3J.mjs +78 -0
- package/dist/pi-tui-terminal-progress-contract-CdBH9j78.mjs +70 -0
- package/dist/pi-tui-terminal-progress-contract-XTQKj-WW.mjs +905 -0
- package/dist/{public-types-gZi3iFNh.d.mts → public-types-Dgf1bDke.d.mts} +3 -3
- package/dist/{runtime-BtPH-UUb.mjs → runtime-Bh5OsftD.mjs} +1311 -1024
- package/dist/runtime-C5ROZqFj.mjs +2 -0
- package/dist/runtime-status-0lp9CM0V.mjs +1923 -0
- package/dist/session-4keoXjk0.mjs +10869 -0
- package/dist/session-B2zqv4wr.mjs +10869 -0
- package/dist/{startup-D5Xu8diR.mjs → startup-Ct2UUjUL.mjs} +55 -13
- package/dist/startup.d.mts +2 -1
- package/dist/startup.mjs +1 -1
- package/dist/terminal-progress-source-BhufrZ74.mjs +6000 -0
- package/dist/terminal-progress-source-CsBinCJ_.mjs +965 -0
- package/dist/visual-tools.d.mts +62 -0
- package/dist/visual-tools.mjs +556 -0
- package/generated/dsh-presets/README.md +1 -1
- package/package.json +145 -117
- package/dist/context-summary-CxUpNkA9.mjs +0 -2951
- package/dist/performance-host-BJT6scGF.mjs +0 -266
- package/dist/rolldown-runtime-8H4AJuhK.mjs +0 -14
- package/dist/session-BZLxhrPQ.mjs +0 -5697
- package/dist/terminal-progress-source-BlmksrSD.mjs +0 -2200
|
@@ -1,2 +1,259 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as firstTokenTimeFromAssistantStream, c as usageFromAssistantSettlement, r as emptyPerformanceView, t as PI_TUI_PERFORMANCE_KEY } from "./performance-view-CfGvLZyD.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/app/host/performance-projection.ts
|
|
4
|
+
/**
|
|
5
|
+
* The `piTuiPerformance` Host fold: the ONE statistics state machine for the
|
|
6
|
+
* recent (R5) and Session-lifetime ("All") model-request output rate and for
|
|
7
|
+
* the recent time-to-first-token.
|
|
8
|
+
*
|
|
9
|
+
* The unit is a pure synchronous fold over committed Session events (plan §3.3
|
|
10
|
+
* / §3.4). The official session-projection seam owns the subscription, the
|
|
11
|
+
* per-session cell, the checkpoint cache and the change feed; this module owns
|
|
12
|
+
* only the computation and its plain-JSON state:
|
|
13
|
+
*
|
|
14
|
+
* ```text
|
|
15
|
+
* step/start open the logical step (turn, step, startTime)
|
|
16
|
+
* assistant/attempt fill the step's missing first-token evidence only
|
|
17
|
+
* assistant/message close it ONCE: route epoch, All pair, R5 pair, TTFB sample
|
|
18
|
+
* step/end, turn/end close a step that produced no message (no accounting)
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Every other event returns the SAME state object (zero downstream work), and
|
|
22
|
+
* an internal-only transition that changes nothing observable reuses the
|
|
23
|
+
* previous view object, so the seam publishes no frame for it (plan §3.3).
|
|
24
|
+
*
|
|
25
|
+
* Usage parsing and the observable-first-token predicate are the SHARED
|
|
26
|
+
* transcript facts (`domain/transcript/usage.ts`), never a second parser; the
|
|
27
|
+
* route identity is the message's `(provider, model)` pair, encoded
|
|
28
|
+
* unambiguously.
|
|
29
|
+
*
|
|
30
|
+
* @module @xmoon76/dsh-pi-tui/app/host/performance-projection
|
|
31
|
+
*/
|
|
32
|
+
const counterSchema = z.strictObject({
|
|
33
|
+
outputTokens: z.number().nonnegative(),
|
|
34
|
+
modelMs: z.number().nonnegative(),
|
|
35
|
+
samples: z.number().int().nonnegative()
|
|
36
|
+
});
|
|
37
|
+
const recentCounterSchema = z.strictObject({
|
|
38
|
+
outputTokens: z.number().nonnegative(),
|
|
39
|
+
modelMs: z.number().nonnegative(),
|
|
40
|
+
samples: z.number().int().nonnegative(),
|
|
41
|
+
firstTokenMs: z.number().nonnegative(),
|
|
42
|
+
firstTokenSamples: z.number().int().nonnegative()
|
|
43
|
+
});
|
|
44
|
+
const viewSchema = z.strictObject({
|
|
45
|
+
recent: recentCounterSchema,
|
|
46
|
+
all: counterSchema
|
|
47
|
+
});
|
|
48
|
+
const stateSchema = z.strictObject({
|
|
49
|
+
view: viewSchema,
|
|
50
|
+
openStep: z.strictObject({
|
|
51
|
+
turn: z.number().int().nonnegative(),
|
|
52
|
+
step: z.number().int().nonnegative(),
|
|
53
|
+
startTime: z.number().nonnegative(),
|
|
54
|
+
firstTokenTime: z.number().nonnegative().nullable()
|
|
55
|
+
}).nullable(),
|
|
56
|
+
routeKey: z.string().nullable(),
|
|
57
|
+
recentSamples: z.array(z.strictObject({
|
|
58
|
+
outputTokens: z.number().nonnegative(),
|
|
59
|
+
modelMs: z.number().nonnegative()
|
|
60
|
+
})).max(5),
|
|
61
|
+
firstTokenSamples: z.array(z.number().nonnegative()).max(5)
|
|
62
|
+
});
|
|
63
|
+
/** The empty fold state. */
|
|
64
|
+
function emptyPerformanceState() {
|
|
65
|
+
return {
|
|
66
|
+
view: emptyPerformanceView(),
|
|
67
|
+
openStep: null,
|
|
68
|
+
routeKey: null,
|
|
69
|
+
recentSamples: [],
|
|
70
|
+
firstTokenSamples: []
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** Whether a replacement-surface rewrite (compaction) carries no new evidence. */
|
|
74
|
+
function isReplacementSurface(event) {
|
|
75
|
+
const op = event.surfaceOp;
|
|
76
|
+
return typeof op === "object" && op !== null && op.op === "replace";
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The step's `(provider, model)` route identity. Only a message whose source is
|
|
80
|
+
* a model route yields a key — a missing identity never resets the window
|
|
81
|
+
* (fail-soft), it only keeps that step out of the route-scoped rings.
|
|
82
|
+
*/
|
|
83
|
+
function performanceRouteKeyOf(message) {
|
|
84
|
+
const source = message.source;
|
|
85
|
+
if (source?.kind !== "model") return void 0;
|
|
86
|
+
if (typeof source.provider !== "string" || typeof source.model !== "string") return void 0;
|
|
87
|
+
return JSON.stringify([source.provider, source.model]);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* One eligible TPS pair: a finite positive output count AND a finite positive
|
|
91
|
+
* model wall time. Provider-boundary validation: an invalid, absent,
|
|
92
|
+
* NaN/Infinity or negative value never enters the All counter or an R5 ring.
|
|
93
|
+
*/
|
|
94
|
+
function eligibleSample(outputTokens, modelMs) {
|
|
95
|
+
if (outputTokens === void 0 || !Number.isFinite(outputTokens) || outputTokens <= 0) return void 0;
|
|
96
|
+
if (!Number.isFinite(modelMs) || modelMs <= 0) return void 0;
|
|
97
|
+
return {
|
|
98
|
+
outputTokens,
|
|
99
|
+
modelMs
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Append to a bounded ring, dropping the oldest entries past the limit. */
|
|
103
|
+
function appendRing(ring, value) {
|
|
104
|
+
const next = [...ring, value];
|
|
105
|
+
return next.length > 5 ? next.slice(next.length - 5) : next;
|
|
106
|
+
}
|
|
107
|
+
/** Whether two published views are numerically identical. */
|
|
108
|
+
function sameView(left, right) {
|
|
109
|
+
return left.recent.outputTokens === right.recent.outputTokens && left.recent.modelMs === right.recent.modelMs && left.recent.samples === right.recent.samples && left.recent.firstTokenMs === right.recent.firstTokenMs && left.recent.firstTokenSamples === right.recent.firstTokenSamples && left.all.outputTokens === right.all.outputTokens && left.all.modelMs === right.all.modelMs && left.all.samples === right.all.samples;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Close ONE step at its `assistant/message` boundary and produce the next
|
|
113
|
+
* state (plan §3.4 rules 4-7, 9, 10):
|
|
114
|
+
*
|
|
115
|
+
* 1. a validly declared route different from the current one clears both
|
|
116
|
+
* route-scoped rings BEFORE this step's samples join (A→B→A included);
|
|
117
|
+
* 2. an eligible pair (`outputTokens > 0`, `modelMs > 0`) joins the All counter
|
|
118
|
+
* always and the R5 ring only for a route-identified step;
|
|
119
|
+
* 3. a completed step with first-token evidence inside
|
|
120
|
+
* `[step/start, assistant/message]` joins the TTFB ring for a
|
|
121
|
+
* route-identified step, independent of `outputTokens`;
|
|
122
|
+
* 4. the view object is recreated only when one of its numbers changed.
|
|
123
|
+
*/
|
|
124
|
+
function settleCompletedStep(state, open, eventTime, topLevelUsage, stream, message) {
|
|
125
|
+
const modelMs = eventTime - open.startTime;
|
|
126
|
+
const declaredRouteKey = performanceRouteKeyOf(message);
|
|
127
|
+
let routeKey = state.routeKey;
|
|
128
|
+
let recentSamples = state.recentSamples;
|
|
129
|
+
let firstTokenSamples = state.firstTokenSamples;
|
|
130
|
+
if (declaredRouteKey !== void 0) {
|
|
131
|
+
if (routeKey !== null && routeKey !== declaredRouteKey) {
|
|
132
|
+
recentSamples = [];
|
|
133
|
+
firstTokenSamples = [];
|
|
134
|
+
}
|
|
135
|
+
routeKey = declaredRouteKey;
|
|
136
|
+
}
|
|
137
|
+
const sample = eligibleSample(usageFromAssistantSettlement("message", topLevelUsage, stream)?.outputTokens, modelMs);
|
|
138
|
+
if (sample !== void 0 && declaredRouteKey !== void 0) recentSamples = appendRing(recentSamples, sample);
|
|
139
|
+
const firstTokenTime = open.firstTokenTime ?? firstTokenTimeFromAssistantStream(stream) ?? null;
|
|
140
|
+
if (declaredRouteKey !== void 0 && firstTokenTime !== null) {
|
|
141
|
+
const firstTokenMs = firstTokenTime - open.startTime;
|
|
142
|
+
if (Number.isFinite(firstTokenMs) && firstTokenMs >= 0 && firstTokenMs <= modelMs) firstTokenSamples = appendRing(firstTokenSamples, firstTokenMs);
|
|
143
|
+
}
|
|
144
|
+
const previousAll = state.view.all;
|
|
145
|
+
const all = sample === void 0 ? previousAll : {
|
|
146
|
+
outputTokens: previousAll.outputTokens + sample.outputTokens,
|
|
147
|
+
modelMs: previousAll.modelMs + sample.modelMs,
|
|
148
|
+
samples: previousAll.samples + 1
|
|
149
|
+
};
|
|
150
|
+
const nextView = {
|
|
151
|
+
recent: {
|
|
152
|
+
outputTokens: recentSamples.reduce((sum, pair) => sum + pair.outputTokens, 0),
|
|
153
|
+
modelMs: recentSamples.reduce((sum, pair) => sum + pair.modelMs, 0),
|
|
154
|
+
samples: recentSamples.length,
|
|
155
|
+
firstTokenMs: firstTokenSamples.reduce((sum, value) => sum + value, 0),
|
|
156
|
+
firstTokenSamples: firstTokenSamples.length
|
|
157
|
+
},
|
|
158
|
+
all
|
|
159
|
+
};
|
|
160
|
+
return {
|
|
161
|
+
view: sameView(state.view, nextView) ? state.view : nextView,
|
|
162
|
+
openStep: null,
|
|
163
|
+
routeKey,
|
|
164
|
+
recentSamples,
|
|
165
|
+
firstTokenSamples
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The `piTuiPerformance` projection unit. `stateVersion` gates the persisted
|
|
170
|
+
* cache: a row from another fold version is discarded and refolded, never
|
|
171
|
+
* forward-applied into garbage.
|
|
172
|
+
*/
|
|
173
|
+
const piTuiPerformanceDefinition = {
|
|
174
|
+
key: PI_TUI_PERFORMANCE_KEY,
|
|
175
|
+
stateVersion: 1,
|
|
176
|
+
stateSchema,
|
|
177
|
+
init: () => emptyPerformanceState(),
|
|
178
|
+
apply: (state, event) => {
|
|
179
|
+
if (isReplacementSurface(event)) return state;
|
|
180
|
+
switch (event.type) {
|
|
181
|
+
case "step/start": return {
|
|
182
|
+
...state,
|
|
183
|
+
openStep: {
|
|
184
|
+
turn: event.data.turn,
|
|
185
|
+
step: event.data.step,
|
|
186
|
+
startTime: event.time,
|
|
187
|
+
firstTokenTime: null
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
case "assistant/attempt": {
|
|
191
|
+
const open = state.openStep;
|
|
192
|
+
if (open === null || open.turn !== event.data.turn || open.step !== event.data.step) return state;
|
|
193
|
+
if (open.firstTokenTime !== null) return state;
|
|
194
|
+
const firstTokenTime = firstTokenTimeFromAssistantStream(event.data.stream);
|
|
195
|
+
if (firstTokenTime === void 0 || !Number.isFinite(firstTokenTime)) return state;
|
|
196
|
+
return {
|
|
197
|
+
...state,
|
|
198
|
+
openStep: {
|
|
199
|
+
...open,
|
|
200
|
+
firstTokenTime
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
case "assistant/message": {
|
|
205
|
+
const open = state.openStep;
|
|
206
|
+
if (open === null || open.turn !== event.data.turn || open.step !== event.data.step) return state;
|
|
207
|
+
return settleCompletedStep(state, open, event.time, event.data.usage, event.data.stream, event.data.message);
|
|
208
|
+
}
|
|
209
|
+
case "step/end":
|
|
210
|
+
case "turn/end": return state.openStep === null ? state : {
|
|
211
|
+
...state,
|
|
212
|
+
openStep: null
|
|
213
|
+
};
|
|
214
|
+
default: return state;
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
wire: {
|
|
218
|
+
viewSchema,
|
|
219
|
+
view: (state) => state.view
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/app/host/performance-host.ts
|
|
224
|
+
/** Stable Cordis plugin name (the Loader row id in `cordis.patch.yml`). */
|
|
225
|
+
const name = "pi-tui-performance-host";
|
|
226
|
+
/** The projection registry is this plugin's whole purpose: without it the fiber stays pending. */
|
|
227
|
+
const inject = ["sessionProjections"];
|
|
228
|
+
/**
|
|
229
|
+
* The readiness gate this row publishes after the unit is registered. It
|
|
230
|
+
* carries NO data — it is not a second performance authority, only the
|
|
231
|
+
* ordering proof that the Host projection exists before the TUI mounts.
|
|
232
|
+
*
|
|
233
|
+
* The key is declared the way this repository declares its OWN Cordis
|
|
234
|
+
* services (`src/startup.ts`'s `TUI_STARTUP_SERVICE`): an exported string
|
|
235
|
+
* constant, consumed by the dependent row's `inject` list in
|
|
236
|
+
* `cordis.patch.yml`. The gate is data-free, so there is no value shape to
|
|
237
|
+
* declare and no `Context` augmentation to add; a consumer that needs to
|
|
238
|
+
* narrow the read does it at its own call site, exactly as the `tuiStartup`
|
|
239
|
+
* consumers do.
|
|
240
|
+
*/
|
|
241
|
+
const PI_TUI_PERFORMANCE_READY_SERVICE = "piTuiPerformanceReady";
|
|
242
|
+
/**
|
|
243
|
+
* Register the `piTuiPerformance` unit and publish the readiness gate.
|
|
244
|
+
*
|
|
245
|
+
* The registry is resolved through the context's reflection layer, the
|
|
246
|
+
* documented Host-plane idiom of this repository (`app/host/pi-tui-host-runtime.ts`
|
|
247
|
+
* and `app/host/features/file-reference.ts` do the same): this module IS
|
|
248
|
+
* the Host plane, so its Host-service read is not Client-side coupling and the
|
|
249
|
+
* client-boundary inventory stays unchanged. `inject` above is what guarantees
|
|
250
|
+
* the service is present and active here.
|
|
251
|
+
*
|
|
252
|
+
* @param ctx - the Host context that owns this row's fiber.
|
|
253
|
+
*/
|
|
254
|
+
function apply(ctx) {
|
|
255
|
+
ctx.reflect.get("sessionProjections").register(piTuiPerformanceDefinition);
|
|
256
|
+
ctx.provide(PI_TUI_PERFORMANCE_READY_SERVICE, {});
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
2
259
|
export { PI_TUI_PERFORMANCE_READY_SERVICE, apply, inject, name };
|
|
@@ -403,7 +403,7 @@ var StepUsageAccumulator = class {
|
|
|
403
403
|
* weighted rate, and the display precision policy: it never selects a route,
|
|
404
404
|
* folds an event, reads a Session, or holds a sample ring. The Host reducer
|
|
405
405
|
* (`src/app/host/performance-projection.ts`) owns every sample; the Direct /
|
|
406
|
-
* Remote carriers,
|
|
406
|
+
* Remote carriers, the About report, and the footer all read this one contract.
|
|
407
407
|
*
|
|
408
408
|
* @module @xmoon76/dsh-pi-tui/domain/status/performance-view
|
|
409
409
|
*/
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { n as PI_TUI_TERMINAL_PROGRESS_WATCH } from "./pi-tui-terminal-progress-contract-CdBH9j78.mjs";
|
|
2
|
+
//#region src/runtime/remote/pi-tui-file-reference-contract.ts
|
|
3
|
+
/** The wire namespace (and Host Cordis service key) of the augmentation. */
|
|
4
|
+
const PI_TUI_FILE_REFERENCES_NAMESPACE = "piTuiFileReferences";
|
|
5
|
+
/** The private method's stable endpoint identity. */
|
|
6
|
+
const PI_TUI_FILE_REFERENCES_LIST_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiFileReferences/list";
|
|
7
|
+
/** One strict JSON codec that validates a wire string. */
|
|
8
|
+
function stringCodec(typeSymbol) {
|
|
9
|
+
return {
|
|
10
|
+
mode: "strict",
|
|
11
|
+
typeSymbol,
|
|
12
|
+
create: () => ({ parse: (value) => {
|
|
13
|
+
if (typeof value !== "string") throw new TypeError(`${typeSymbol}: the wire value must be a string`);
|
|
14
|
+
return value;
|
|
15
|
+
} })
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validate and detach one wire `HostFileListResult`. The result is produced by
|
|
20
|
+
* this package's own Host router, but it is still a wire boundary on the Client
|
|
21
|
+
* and the ONLY place the shape crosses.
|
|
22
|
+
*/
|
|
23
|
+
function decodeHostFileListResult(value) {
|
|
24
|
+
if (typeof value !== "object" || value === null) throw new TypeError("piTuiFileReferences/list: the result must be an object");
|
|
25
|
+
const record = value;
|
|
26
|
+
if (record.kind === "unavailable") {
|
|
27
|
+
if (typeof record.reason !== "string") throw new TypeError("piTuiFileReferences/list: an unavailable result needs a reason");
|
|
28
|
+
return {
|
|
29
|
+
kind: "unavailable",
|
|
30
|
+
reason: record.reason
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (record.kind !== "ok" || !Array.isArray(record.items)) throw new TypeError("piTuiFileReferences/list: the result must be ok(items) or unavailable(reason)");
|
|
34
|
+
return {
|
|
35
|
+
kind: "ok",
|
|
36
|
+
items: record.items.map((entry) => {
|
|
37
|
+
if (typeof entry !== "object" || entry === null) throw new TypeError("piTuiFileReferences/list: every candidate must be an object");
|
|
38
|
+
const candidate = entry;
|
|
39
|
+
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");
|
|
40
|
+
return {
|
|
41
|
+
path: candidate.path,
|
|
42
|
+
kind: candidate.kind
|
|
43
|
+
};
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const HOST_FILE_LIST_RESULT_CODEC = {
|
|
48
|
+
mode: "strict",
|
|
49
|
+
typeSymbol: "@xmoon76/dsh-pi-tui#piTuiFileReferences/list:result",
|
|
50
|
+
create: () => ({ parse: decodeHostFileListResult }),
|
|
51
|
+
decode: decodeHostFileListResult
|
|
52
|
+
};
|
|
53
|
+
/** The explicit Client contribution mounted once with `ctx.remote.$mount`. */
|
|
54
|
+
const PI_TUI_CLIENT_CONTRIBUTION = {
|
|
55
|
+
package: "@xmoon76/dsh-pi-tui",
|
|
56
|
+
descriptors: [{
|
|
57
|
+
id: PI_TUI_FILE_REFERENCES_LIST_ENDPOINT,
|
|
58
|
+
service: PI_TUI_FILE_REFERENCES_NAMESPACE,
|
|
59
|
+
namespace: PI_TUI_FILE_REFERENCES_NAMESPACE,
|
|
60
|
+
method: "list",
|
|
61
|
+
invocation: { kind: "direct" },
|
|
62
|
+
parameters: [{
|
|
63
|
+
name: "sessionId",
|
|
64
|
+
wire: "sessionId",
|
|
65
|
+
source: "json",
|
|
66
|
+
codec: stringCodec("@xmoon76/dsh-pi-tui#piTuiFileReferences/list:sessionId")
|
|
67
|
+
}, {
|
|
68
|
+
name: "query",
|
|
69
|
+
wire: "query",
|
|
70
|
+
source: "json",
|
|
71
|
+
codec: stringCodec("@xmoon76/dsh-pi-tui#piTuiFileReferences/list:query")
|
|
72
|
+
}],
|
|
73
|
+
cancellation: { parameter: "signal" },
|
|
74
|
+
result: HOST_FILE_LIST_RESULT_CODEC
|
|
75
|
+
}, PI_TUI_TERMINAL_PROGRESS_WATCH]
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { PI_TUI_FILE_REFERENCES_NAMESPACE as n, PI_TUI_CLIENT_CONTRIBUTION as t };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//#region src/runtime/remote/pi-tui-terminal-progress-contract.ts
|
|
2
|
+
/** The wire namespace (and Host Cordis service key) of the private stream. */
|
|
3
|
+
const PI_TUI_TERMINAL_PROGRESS_NAMESPACE = "piTuiTerminalProgress";
|
|
4
|
+
/** The private method's stable endpoint identity. */
|
|
5
|
+
const PI_TUI_TERMINAL_PROGRESS_WATCH_ENDPOINT = "@xmoon76/dsh-pi-tui#piTuiTerminalProgress/watch";
|
|
6
|
+
/** One strict JSON codec that validates a wire string. */
|
|
7
|
+
function stringCodec(typeSymbol) {
|
|
8
|
+
return {
|
|
9
|
+
mode: "strict",
|
|
10
|
+
typeSymbol,
|
|
11
|
+
create: () => ({ parse: (value) => {
|
|
12
|
+
if (typeof value !== "string") throw new TypeError(`${typeSymbol}: the wire value must be a string`);
|
|
13
|
+
return value;
|
|
14
|
+
} })
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Validate and detach one `PiTuiTerminalProgressFrame`. This is the ONE
|
|
19
|
+
* structural validator of the frame shape: the descriptor's `result` codec
|
|
20
|
+
* uses it, and the R2 Client source must call it on every downlink item because
|
|
21
|
+
* the framework does not (see the module JSDoc).
|
|
22
|
+
*/
|
|
23
|
+
function parsePiTuiTerminalProgressFrame(value) {
|
|
24
|
+
if (typeof value !== "object" || value === null) throw new TypeError("piTuiTerminalProgress/watch: the frame must be an object");
|
|
25
|
+
const frame = value;
|
|
26
|
+
if (frame.kind !== "snapshot" && frame.kind !== "update") throw new TypeError("piTuiTerminalProgress/watch: the frame kind must be snapshot or update");
|
|
27
|
+
if (typeof frame.sessionId !== "string") throw new TypeError("piTuiTerminalProgress/watch: the frame needs a string sessionId");
|
|
28
|
+
if (typeof frame.hostEpoch !== "string") throw new TypeError("piTuiTerminalProgress/watch: the frame needs a string hostEpoch");
|
|
29
|
+
if (typeof frame.agentEpoch !== "number") throw new TypeError("piTuiTerminalProgress/watch: the frame needs a numeric agentEpoch");
|
|
30
|
+
if (typeof frame.revision !== "number") throw new TypeError("piTuiTerminalProgress/watch: the frame needs a numeric revision");
|
|
31
|
+
if (typeof frame.running !== "boolean") throw new TypeError("piTuiTerminalProgress/watch: the frame needs a boolean running");
|
|
32
|
+
if (frame.outcome !== "idle" && frame.outcome !== "done" && frame.outcome !== "error") throw new TypeError("piTuiTerminalProgress/watch: the frame outcome must be idle, done or error");
|
|
33
|
+
return {
|
|
34
|
+
kind: frame.kind,
|
|
35
|
+
sessionId: frame.sessionId,
|
|
36
|
+
hostEpoch: frame.hostEpoch,
|
|
37
|
+
agentEpoch: frame.agentEpoch,
|
|
38
|
+
revision: frame.revision,
|
|
39
|
+
running: frame.running,
|
|
40
|
+
outcome: frame.outcome
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const PI_TUI_TERMINAL_PROGRESS_FRAME_CODEC = {
|
|
44
|
+
mode: "strict",
|
|
45
|
+
typeSymbol: "@xmoon76/dsh-pi-tui#piTuiTerminalProgress/watch:frame",
|
|
46
|
+
create: () => ({ parse: parsePiTuiTerminalProgressFrame }),
|
|
47
|
+
decode: parsePiTuiTerminalProgressFrame
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The ONE shared invocation descriptor both contributions derive from. The
|
|
51
|
+
* Host registers this exact object; the Client mounts this exact object.
|
|
52
|
+
*/
|
|
53
|
+
const PI_TUI_TERMINAL_PROGRESS_WATCH = {
|
|
54
|
+
id: PI_TUI_TERMINAL_PROGRESS_WATCH_ENDPOINT,
|
|
55
|
+
service: PI_TUI_TERMINAL_PROGRESS_NAMESPACE,
|
|
56
|
+
namespace: PI_TUI_TERMINAL_PROGRESS_NAMESPACE,
|
|
57
|
+
method: "watch",
|
|
58
|
+
mode: "stream",
|
|
59
|
+
invocation: { kind: "direct" },
|
|
60
|
+
parameters: [{
|
|
61
|
+
name: "sessionId",
|
|
62
|
+
wire: "sessionId",
|
|
63
|
+
source: "json",
|
|
64
|
+
codec: stringCodec("@xmoon76/dsh-pi-tui#piTuiTerminalProgress/watch:sessionId")
|
|
65
|
+
}],
|
|
66
|
+
cancellation: { parameter: "signal" },
|
|
67
|
+
result: PI_TUI_TERMINAL_PROGRESS_FRAME_CODEC
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
export { PI_TUI_TERMINAL_PROGRESS_WATCH as n, parsePiTuiTerminalProgressFrame as r, PI_TUI_TERMINAL_PROGRESS_NAMESPACE as t };
|