@xmoon76/dsh-pi-tui 0.5.4 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.en.md +46 -42
  2. package/README.md +46 -27
  3. package/cordis.patch.yml +77 -7
  4. package/dist/bootstrap-DQ4YPL-7.mjs +113583 -0
  5. package/dist/builtins.mjs +3 -9
  6. package/dist/{runtime-vc4mdr-R.mjs → client-bootstrap-Cr1JCaF5.mjs} +3670 -2277
  7. package/dist/disposal-BYBbEpVY.mjs +54 -0
  8. package/dist/dist-CIsR7cz4.mjs +15717 -0
  9. package/dist/{entry-control-DvSrndWd.mjs → entry-control-DnduyDiw.mjs} +12 -31
  10. package/dist/{extensions-CcuMY4n2.mjs → extensions-Bp0L37lP.mjs} +1239 -271
  11. package/dist/extensions.mjs +1 -1
  12. package/dist/host-bootstrap-DilsvA6f.mjs +281 -0
  13. package/dist/host-foundation-probe--5jtvHVe.mjs +413 -0
  14. package/dist/host-runtime.d.mts +30 -0
  15. package/dist/host-runtime.mjs +1317 -0
  16. package/dist/index.d.mts +19 -18
  17. package/dist/index.mjs +18410 -8836
  18. package/dist/local-client.mjs +2027 -187
  19. package/dist/local-discovery-C9VMjc0K.mjs +759 -0
  20. package/dist/local-discovery-CDaQHA_R.mjs +2 -0
  21. package/dist/local-host.mjs +1088 -87
  22. package/dist/local-transport-BVwFYq_Y.mjs +513 -0
  23. package/dist/{context-summary-DAisTA_7.mjs → pasted-path-range-CMnxuGPx.mjs} +7613 -216
  24. package/dist/pasted-path-range-r6qzV_tC.mjs +17510 -0
  25. package/dist/performance-host.d.mts +2 -2
  26. package/dist/performance-host.mjs +258 -1
  27. package/dist/pi-tui-remote-contribution-B0EQsP0N.mjs +85 -0
  28. package/dist/pi-tui-terminal-progress-contract-CdBH9j78.mjs +70 -0
  29. package/dist/pi-tui-terminal-progress-contract-MLXZ-i3t.mjs +905 -0
  30. package/dist/pi-tui-web-access-contract-BN8Cc_Ho.mjs +118 -0
  31. package/dist/{runtime-status-0lp9CM0V.mjs → runtime-status-Cj1nFOdS.mjs} +72 -214
  32. package/dist/session-BKGXyh80.mjs +15794 -0
  33. package/dist/{session-tdJHLnJR.mjs → session-CPt_U8_f.mjs} +10707 -3657
  34. package/dist/{startup-JaVZoTIl.mjs → startup-7BYWuvBU.mjs} +124 -8
  35. package/dist/startup.d.mts +1 -1
  36. package/dist/startup.mjs +1 -1
  37. package/dist/{client-bootstrap-F5DHFI9t.mjs → terminal-progress-source-DrqQhtT8.mjs} +3653 -2969
  38. package/dist/visual-tools.d.mts +2 -2
  39. package/dist/visual-tools.mjs +26 -31
  40. package/dist/web-preferences.d.mts +29 -0
  41. package/dist/web-preferences.mjs +15 -0
  42. package/dist/web-roster-CjqnUXNk.mjs +285 -0
  43. package/generated/dsh-presets/cordis.patch.yml +5 -3
  44. package/generated/dsh-presets/ptc.patch.yml +7 -7
  45. package/generated/dsh-presets/standard.patch.yml +6 -4
  46. package/package.json +195 -172
  47. package/dist/host-bootstrap-DAgKknbY.mjs +0 -119
  48. package/dist/performance-host-CcDJjjVA.mjs +0 -266
  49. package/dist/rolldown-runtime-8H4AJuhK.mjs +0 -14
  50. package/dist/terminal-progress-source-xor3vakJ.mjs +0 -2256
@@ -1,266 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
- import { a as firstTokenTimeFromAssistantStream, c as usageFromAssistantSettlement, r as emptyPerformanceView, t as PI_TUI_PERFORMANCE_KEY } from "./performance-view-CfGvLZyD.mjs";
3
- import { z } from "zod";
4
- //#region src/app/host/performance-projection.ts
5
- /**
6
- * The `piTuiPerformance` Host fold: the ONE statistics state machine for the
7
- * recent (R5) and Session-lifetime ("All") model-request output rate and for
8
- * the recent time-to-first-token.
9
- *
10
- * The unit is a pure synchronous fold over committed Session events (plan §3.3
11
- * / §3.4). The official session-projection seam owns the subscription, the
12
- * per-session cell, the checkpoint cache and the change feed; this module owns
13
- * only the computation and its plain-JSON state:
14
- *
15
- * ```text
16
- * step/start open the logical step (turn, step, startTime)
17
- * assistant/attempt fill the step's missing first-token evidence only
18
- * assistant/message close it ONCE: route epoch, All pair, R5 pair, TTFB sample
19
- * step/end, turn/end close a step that produced no message (no accounting)
20
- * ```
21
- *
22
- * Every other event returns the SAME state object (zero downstream work), and
23
- * an internal-only transition that changes nothing observable reuses the
24
- * previous view object, so the seam publishes no frame for it (plan §3.3).
25
- *
26
- * Usage parsing and the observable-first-token predicate are the SHARED
27
- * transcript facts (`domain/transcript/usage.ts`), never a second parser; the
28
- * route identity is the message's `(provider, model)` pair, encoded
29
- * unambiguously.
30
- *
31
- * @module @xmoon76/dsh-pi-tui/app/host/performance-projection
32
- */
33
- const counterSchema = z.strictObject({
34
- outputTokens: z.number().nonnegative(),
35
- modelMs: z.number().nonnegative(),
36
- samples: z.number().int().nonnegative()
37
- });
38
- const recentCounterSchema = z.strictObject({
39
- outputTokens: z.number().nonnegative(),
40
- modelMs: z.number().nonnegative(),
41
- samples: z.number().int().nonnegative(),
42
- firstTokenMs: z.number().nonnegative(),
43
- firstTokenSamples: z.number().int().nonnegative()
44
- });
45
- const viewSchema = z.strictObject({
46
- recent: recentCounterSchema,
47
- all: counterSchema
48
- });
49
- const stateSchema = z.strictObject({
50
- view: viewSchema,
51
- openStep: z.strictObject({
52
- turn: z.number().int().nonnegative(),
53
- step: z.number().int().nonnegative(),
54
- startTime: z.number().nonnegative(),
55
- firstTokenTime: z.number().nonnegative().nullable()
56
- }).nullable(),
57
- routeKey: z.string().nullable(),
58
- recentSamples: z.array(z.strictObject({
59
- outputTokens: z.number().nonnegative(),
60
- modelMs: z.number().nonnegative()
61
- })).max(5),
62
- firstTokenSamples: z.array(z.number().nonnegative()).max(5)
63
- });
64
- /** The empty fold state. */
65
- function emptyPerformanceState() {
66
- return {
67
- view: emptyPerformanceView(),
68
- openStep: null,
69
- routeKey: null,
70
- recentSamples: [],
71
- firstTokenSamples: []
72
- };
73
- }
74
- /** Whether a replacement-surface rewrite (compaction) carries no new evidence. */
75
- function isReplacementSurface(event) {
76
- const op = event.surfaceOp;
77
- return typeof op === "object" && op !== null && op.op === "replace";
78
- }
79
- /**
80
- * The step's `(provider, model)` route identity. Only a message whose source is
81
- * a model route yields a key — a missing identity never resets the window
82
- * (fail-soft), it only keeps that step out of the route-scoped rings.
83
- */
84
- function performanceRouteKeyOf(message) {
85
- const source = message.source;
86
- if (source?.kind !== "model") return void 0;
87
- if (typeof source.provider !== "string" || typeof source.model !== "string") return void 0;
88
- return JSON.stringify([source.provider, source.model]);
89
- }
90
- /**
91
- * One eligible TPS pair: a finite positive output count AND a finite positive
92
- * model wall time. Provider-boundary validation: an invalid, absent,
93
- * NaN/Infinity or negative value never enters the All counter or an R5 ring.
94
- */
95
- function eligibleSample(outputTokens, modelMs) {
96
- if (outputTokens === void 0 || !Number.isFinite(outputTokens) || outputTokens <= 0) return void 0;
97
- if (!Number.isFinite(modelMs) || modelMs <= 0) return void 0;
98
- return {
99
- outputTokens,
100
- modelMs
101
- };
102
- }
103
- /** Append to a bounded ring, dropping the oldest entries past the limit. */
104
- function appendRing(ring, value) {
105
- const next = [...ring, value];
106
- return next.length > 5 ? next.slice(next.length - 5) : next;
107
- }
108
- /** Whether two published views are numerically identical. */
109
- function sameView(left, right) {
110
- 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;
111
- }
112
- /**
113
- * Close ONE step at its `assistant/message` boundary and produce the next
114
- * state (plan §3.4 rules 4-7, 9, 10):
115
- *
116
- * 1. a validly declared route different from the current one clears both
117
- * route-scoped rings BEFORE this step's samples join (A→B→A included);
118
- * 2. an eligible pair (`outputTokens > 0`, `modelMs > 0`) joins the All counter
119
- * always and the R5 ring only for a route-identified step;
120
- * 3. a completed step with first-token evidence inside
121
- * `[step/start, assistant/message]` joins the TTFB ring for a
122
- * route-identified step, independent of `outputTokens`;
123
- * 4. the view object is recreated only when one of its numbers changed.
124
- */
125
- function settleCompletedStep(state, open, eventTime, topLevelUsage, stream, message) {
126
- const modelMs = eventTime - open.startTime;
127
- const declaredRouteKey = performanceRouteKeyOf(message);
128
- let routeKey = state.routeKey;
129
- let recentSamples = state.recentSamples;
130
- let firstTokenSamples = state.firstTokenSamples;
131
- if (declaredRouteKey !== void 0) {
132
- if (routeKey !== null && routeKey !== declaredRouteKey) {
133
- recentSamples = [];
134
- firstTokenSamples = [];
135
- }
136
- routeKey = declaredRouteKey;
137
- }
138
- const sample = eligibleSample(usageFromAssistantSettlement("message", topLevelUsage, stream)?.outputTokens, modelMs);
139
- if (sample !== void 0 && declaredRouteKey !== void 0) recentSamples = appendRing(recentSamples, sample);
140
- const firstTokenTime = open.firstTokenTime ?? firstTokenTimeFromAssistantStream(stream) ?? null;
141
- if (declaredRouteKey !== void 0 && firstTokenTime !== null) {
142
- const firstTokenMs = firstTokenTime - open.startTime;
143
- if (Number.isFinite(firstTokenMs) && firstTokenMs >= 0 && firstTokenMs <= modelMs) firstTokenSamples = appendRing(firstTokenSamples, firstTokenMs);
144
- }
145
- const previousAll = state.view.all;
146
- const all = sample === void 0 ? previousAll : {
147
- outputTokens: previousAll.outputTokens + sample.outputTokens,
148
- modelMs: previousAll.modelMs + sample.modelMs,
149
- samples: previousAll.samples + 1
150
- };
151
- const nextView = {
152
- recent: {
153
- outputTokens: recentSamples.reduce((sum, pair) => sum + pair.outputTokens, 0),
154
- modelMs: recentSamples.reduce((sum, pair) => sum + pair.modelMs, 0),
155
- samples: recentSamples.length,
156
- firstTokenMs: firstTokenSamples.reduce((sum, value) => sum + value, 0),
157
- firstTokenSamples: firstTokenSamples.length
158
- },
159
- all
160
- };
161
- return {
162
- view: sameView(state.view, nextView) ? state.view : nextView,
163
- openStep: null,
164
- routeKey,
165
- recentSamples,
166
- firstTokenSamples
167
- };
168
- }
169
- /**
170
- * The `piTuiPerformance` projection unit. `stateVersion` gates the persisted
171
- * cache: a row from another fold version is discarded and refolded, never
172
- * forward-applied into garbage.
173
- */
174
- const piTuiPerformanceDefinition = {
175
- key: PI_TUI_PERFORMANCE_KEY,
176
- stateVersion: 1,
177
- stateSchema,
178
- init: () => emptyPerformanceState(),
179
- apply: (state, event) => {
180
- if (isReplacementSurface(event)) return state;
181
- switch (event.type) {
182
- case "step/start": return {
183
- ...state,
184
- openStep: {
185
- turn: event.data.turn,
186
- step: event.data.step,
187
- startTime: event.time,
188
- firstTokenTime: null
189
- }
190
- };
191
- case "assistant/attempt": {
192
- const open = state.openStep;
193
- if (open === null || open.turn !== event.data.turn || open.step !== event.data.step) return state;
194
- if (open.firstTokenTime !== null) return state;
195
- const firstTokenTime = firstTokenTimeFromAssistantStream(event.data.stream);
196
- if (firstTokenTime === void 0 || !Number.isFinite(firstTokenTime)) return state;
197
- return {
198
- ...state,
199
- openStep: {
200
- ...open,
201
- firstTokenTime
202
- }
203
- };
204
- }
205
- case "assistant/message": {
206
- const open = state.openStep;
207
- if (open === null || open.turn !== event.data.turn || open.step !== event.data.step) return state;
208
- return settleCompletedStep(state, open, event.time, event.data.usage, event.data.stream, event.data.message);
209
- }
210
- case "step/end":
211
- case "turn/end": return state.openStep === null ? state : {
212
- ...state,
213
- openStep: null
214
- };
215
- default: return state;
216
- }
217
- },
218
- wire: {
219
- viewSchema,
220
- view: (state) => state.view
221
- }
222
- };
223
- //#endregion
224
- //#region src/app/host/performance-host.ts
225
- var performance_host_exports = /* @__PURE__ */ __exportAll({
226
- PI_TUI_PERFORMANCE_READY_SERVICE: () => PI_TUI_PERFORMANCE_READY_SERVICE,
227
- apply: () => apply,
228
- inject: () => inject,
229
- name: () => name
230
- });
231
- /** Stable Cordis plugin name (the Loader row id in `cordis.patch.yml`). */
232
- const name = "pi-tui-performance-host";
233
- /** The projection registry is this plugin's whole purpose: without it the fiber stays pending. */
234
- const inject = ["sessionProjections"];
235
- /**
236
- * The readiness gate this row publishes after the unit is registered. It
237
- * carries NO data — it is not a second performance authority, only the
238
- * ordering proof that the Host projection exists before the TUI mounts.
239
- *
240
- * The key is declared the way this repository declares its OWN Cordis
241
- * services (`src/startup.ts`'s `TUI_STARTUP_SERVICE`): an exported string
242
- * constant, consumed by the dependent row's `inject` list in
243
- * `cordis.patch.yml`. The gate is data-free, so there is no value shape to
244
- * declare and no `Context` augmentation to add; a consumer that needs to
245
- * narrow the read does it at its own call site, exactly as the `tuiStartup`
246
- * consumers do.
247
- */
248
- const PI_TUI_PERFORMANCE_READY_SERVICE = "piTuiPerformanceReady";
249
- /**
250
- * Register the `piTuiPerformance` unit and publish the readiness gate.
251
- *
252
- * The registry is resolved through the context's reflection layer, the
253
- * documented Host-plane idiom of this repository (`app/remote/host-runtime.ts`
254
- * and `app/remote/pi-tui-file-reference-host.ts` do the same): this module IS
255
- * the Host plane, so its Host-service read is not Client-side coupling and the
256
- * client-boundary inventory stays unchanged. `inject` above is what guarantees
257
- * the service is present and active here.
258
- *
259
- * @param ctx - the Host context that owns this row's fiber.
260
- */
261
- function apply(ctx) {
262
- ctx.reflect.get("sessionProjections").register(piTuiPerformanceDefinition);
263
- ctx.provide(PI_TUI_PERFORMANCE_READY_SERVICE, {});
264
- }
265
- //#endregion
266
- export { performance_host_exports as a, name as i, apply as n, inject as r, PI_TUI_PERFORMANCE_READY_SERVICE as t };
@@ -1,14 +0,0 @@
1
- import "node:module";
2
- //#region \0rolldown/runtime.js
3
- var __defProp = Object.defineProperty;
4
- var __exportAll = (all, no_symbols) => {
5
- let target = {};
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
11
- return target;
12
- };
13
- //#endregion
14
- export { __exportAll as t };