@mythicalos/ui-core 0.2.2 → 0.3.0
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/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/logic/file-explorer.d.ts +374 -0
- package/dist/logic/file-explorer.js +624 -0
- package/dist/logic/popover.d.ts +242 -0
- package/dist/logic/popover.js +303 -0
- package/dist/logic/queue.d.ts +142 -0
- package/dist/logic/queue.js +143 -0
- package/dist/logic/sendbar.d.ts +105 -0
- package/dist/logic/sendbar.js +136 -0
- package/dist/logic/session-card.d.ts +263 -0
- package/dist/logic/session-card.js +443 -0
- package/dist/logic/terminal.d.ts +222 -0
- package/dist/logic/terminal.js +264 -0
- package/package.json +1 -1
- package/styles.css +652 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/** Product-tunable context thresholds (percent). Defaults per the design card's fixed ticks. */
|
|
2
|
+
export interface CtxThresholds {
|
|
3
|
+
/** ≥ this reading is `warn`. */
|
|
4
|
+
warn: number;
|
|
5
|
+
/** ≥ this reading is `error` ("critical"). */
|
|
6
|
+
critical: number;
|
|
7
|
+
}
|
|
8
|
+
/** The design card's tick positions: warn at 75%, critical at 90% — overridable per product. */
|
|
9
|
+
export declare const CTX_THRESHOLDS_DEFAULT: CtxThresholds;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize a product's threshold pair ONCE, so the band and the bar's ticks can never disagree
|
|
12
|
+
* about where the thresholds are. Two corrections:
|
|
13
|
+
*
|
|
14
|
+
* · A member that is not a finite number strictly inside the rail (0 < t < 100) is not a usable
|
|
15
|
+
* threshold — it marks nothing the meter can draw — so it falls back to the design default
|
|
16
|
+
* rather than silently reclassifying every reading. (`{warn: NaN}` must not quietly make every
|
|
17
|
+
* session look nominal; `{warn: -5}` must not quietly make every session look hot while
|
|
18
|
+
* drawing no tick to explain why.)
|
|
19
|
+
* · The pair is ORDERED (`warn` ≤ `critical`). A mis-ordered pair leaves the higher tick
|
|
20
|
+
* unreachable — with `{warn: 90, critical: 75}` an 80% reading is already `error` while a
|
|
21
|
+
* `warn` tick still sits at 90, so the bar marks a boundary that can never be crossed. Both
|
|
22
|
+
* boundaries the product asked for are kept; only which one is named `warn` is corrected.
|
|
23
|
+
*/
|
|
24
|
+
export declare function normalizeCtxThresholds(thresholds?: CtxThresholds | null): CtxThresholds;
|
|
25
|
+
/**
|
|
26
|
+
* The context band. `"unknown"` is a FIRST-CLASS member, not a fallback to `"ok"`: a session with
|
|
27
|
+
* no reading (undefined/null/NaN/±Infinity) belongs to no health band — it is neither healthy nor
|
|
28
|
+
* hot (invariant 1).
|
|
29
|
+
*/
|
|
30
|
+
export type CtxBand = "unknown" | "ok" | "warn" | "error";
|
|
31
|
+
/**
|
|
32
|
+
* The ONE number the card works from: the reading clamped to 0–100, at FULL precision, or
|
|
33
|
+
* `undefined` when there is no reading. The band and the fill are derived from this — the
|
|
34
|
+
* threshold comparison is against what was actually reported, so an 89.5% session has NOT crossed
|
|
35
|
+
* a 90% critical line. The LABEL then adapts its precision to this same number (see
|
|
36
|
+
* `ctxValueText`) so what the card displays can never contradict what it claims.
|
|
37
|
+
*/
|
|
38
|
+
export declare function ctxReading(pct: number | null | undefined): number | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Band for a context reading, derived from the reading AS REPORTED — 89.5 has not crossed a 90
|
|
41
|
+
* critical line and must not be shown as though it had. Absent ⇒ `"unknown"`. The thresholds are
|
|
42
|
+
* normalized (and ordered) first, so the band and the bar's ticks always agree.
|
|
43
|
+
*/
|
|
44
|
+
export declare function ctxBand(pct: number | null | undefined, thresholds?: CtxThresholds | null): CtxBand;
|
|
45
|
+
/**
|
|
46
|
+
* The 0–100 fill length, or `undefined` when there is no reading. `undefined` means the binding
|
|
47
|
+
* draws NO fill at all — the caller must never substitute 0, which would render as a confident
|
|
48
|
+
* "empty context" (invariant 1).
|
|
49
|
+
*/
|
|
50
|
+
export declare function ctxFillPct(pct: number | null | undefined): number | undefined;
|
|
51
|
+
/** What an absent reading renders as — never `"0%"`. */
|
|
52
|
+
export declare const CTX_UNKNOWN_TEXT = "\u2014";
|
|
53
|
+
/**
|
|
54
|
+
* The meter's right-hand value: `"62%"` for a reading, `"—"` for none (invariant 1).
|
|
55
|
+
*
|
|
56
|
+
* Whole percents are what the design card shows, but a rounded percent must never contradict the
|
|
57
|
+
* band the card is enforcing: at the default thresholds, 89.5% is `warn`, so displaying it as
|
|
58
|
+
* "90%" would put an amber card next to the critical number. The label therefore takes the FIRST
|
|
59
|
+
* precision whose displayed number lands in the same band as the reading — "89.5%" here, plain
|
|
60
|
+
* "62%" in the ordinary case — falling back to the reading verbatim, which by definition agrees.
|
|
61
|
+
*/
|
|
62
|
+
export declare function ctxValueText(pct: number | null | undefined, thresholds?: CtxThresholds | null): string;
|
|
63
|
+
/** The meter's left-hand label and the separator the card composes its notes with. */
|
|
64
|
+
export declare const CTX_LABEL = "context";
|
|
65
|
+
export declare const SESSION_CARD_SEP = " \u00B7 ";
|
|
66
|
+
/**
|
|
67
|
+
* The meter's left-hand note. The design card annotates the band (`context · distill suggested` at
|
|
68
|
+
* warn, `context · distill now` at error, `context · stale` for a stale reading); the unknown state
|
|
69
|
+
* says so outright, and says it BEFORE `stale` — "stale" implies a last-known value, so it must
|
|
70
|
+
* never stand in for "we never measured it".
|
|
71
|
+
*/
|
|
72
|
+
export declare function ctxNoteText(band: CtxBand, opts?: {
|
|
73
|
+
stale?: boolean;
|
|
74
|
+
} | null): string;
|
|
75
|
+
/** Wrapper class for the meter — the band modifier tints the fill AND the value in one place. */
|
|
76
|
+
export declare function ctxMeterClass(input?: {
|
|
77
|
+
band: CtxBand;
|
|
78
|
+
stale?: boolean;
|
|
79
|
+
} | null): string;
|
|
80
|
+
/** The bar's user-space width: percent IS the x axis, so a reading maps 1:1 onto it. */
|
|
81
|
+
export declare const CTX_BAR_SPAN = 100;
|
|
82
|
+
/** The bar's user-space height (the design card's 8px rail). */
|
|
83
|
+
export declare const CTX_BAR_HEIGHT = 8;
|
|
84
|
+
/** `viewBox` for the bar; the binding stretches it to the card width (`preserveAspectRatio="none"`). */
|
|
85
|
+
export declare const CTX_BAR_VIEWBOX = "0 0 100 8";
|
|
86
|
+
/** Tick width in user space (≈1.5px once the bar is stretched to a ~250px card). */
|
|
87
|
+
export declare const CTX_BAR_TICK_WIDTH = 0.6;
|
|
88
|
+
export interface CtxBarTick {
|
|
89
|
+
/** The threshold this tick marks. */
|
|
90
|
+
pct: number;
|
|
91
|
+
/** Left edge in user space — centred on `pct`, then kept inside the rail. */
|
|
92
|
+
x: number;
|
|
93
|
+
width: number;
|
|
94
|
+
}
|
|
95
|
+
export interface CtxBarGeom {
|
|
96
|
+
span: number;
|
|
97
|
+
height: number;
|
|
98
|
+
/** Fill width in user space. `undefined` ⇒ draw no fill rect at all (invariant 1). */
|
|
99
|
+
fill: number | undefined;
|
|
100
|
+
/** In-range, de-duplicated, ascending threshold ticks. */
|
|
101
|
+
ticks: CtxBarTick[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Pure bar geometry, from the SAME normalized thresholds `ctxBand` uses — an unusable threshold
|
|
105
|
+
* falls back to the default in both places, so the ticks always mark the boundaries the band is
|
|
106
|
+
* actually enforcing. Duplicates collapse, so `{warn: 90, critical: 90}` draws one tick, not two
|
|
107
|
+
* stacked ones.
|
|
108
|
+
*/
|
|
109
|
+
export declare function ctxBarGeom(pct: number | null | undefined, thresholds?: CtxThresholds | null): CtxBarGeom;
|
|
110
|
+
/** Lifecycle claims a product can make. Absent ⇒ the product reported no lifecycle. */
|
|
111
|
+
export type SessionLifecycle = "spawning" | "active" | "stopping" | "stopped" | "failed" | "paused";
|
|
112
|
+
/** Activity claims a product can make. Absent ⇒ NOT reported — never collapsed to `idle`. */
|
|
113
|
+
export type SessionActivity = "working" | "idle";
|
|
114
|
+
/** Colour axis. `"unknown"` is its own tone: the card renders a HOLLOW dot for it, so an
|
|
115
|
+
* unmeasured session cannot be mistaken for a solid-dot claim of any kind. */
|
|
116
|
+
export type SessionStatusTone = "ok" | "warn" | "error" | "info" | "muted" | "unknown";
|
|
117
|
+
export type SessionStatusKey = "working" | "idle" | "context-high" | "context-critical" | "spawning" | "active" | "stopping" | "stopped" | "failed" | "paused" | "disconnected" | "unknown";
|
|
118
|
+
export interface SessionStatus {
|
|
119
|
+
/** Machine-readable outcome — what the card decided, independent of wording. */
|
|
120
|
+
key: SessionStatusKey;
|
|
121
|
+
/** Default wording; the binding lets a product override it with its own honest phrasing. */
|
|
122
|
+
label: string;
|
|
123
|
+
tone: SessionStatusTone;
|
|
124
|
+
/** ≤1/s dot pulse — transient states only; a steady state never fakes motion. */
|
|
125
|
+
pulse: boolean;
|
|
126
|
+
}
|
|
127
|
+
/** Everything the card needs to state a session's status. Every field is OPTIONAL, and every
|
|
128
|
+
* absent field means "the product did not report this" — never a default claim. */
|
|
129
|
+
export interface SessionStatusInput {
|
|
130
|
+
lifecycle?: SessionLifecycle;
|
|
131
|
+
activity?: SessionActivity;
|
|
132
|
+
/** The session's link/wake readiness. `false` ⇒ down; `undefined` ⇒ not reported. */
|
|
133
|
+
connected?: boolean;
|
|
134
|
+
}
|
|
135
|
+
/** The honest "we were told nothing" status — distinct key AND distinct tone from `idle`. */
|
|
136
|
+
export declare const SESSION_STATUS_UNKNOWN: SessionStatus;
|
|
137
|
+
/**
|
|
138
|
+
* Derive the card's status. Precedence, and why:
|
|
139
|
+
*
|
|
140
|
+
* 1. A DOWN LINK on a session the product calls `active` — or on one whose lifecycle it does not
|
|
141
|
+
* report at all — wins: whatever else was claimed, we are not hearing from it. It does NOT
|
|
142
|
+
* override `spawning`/`stopping`/`stopped`/`failed`, whose own lifecycle already explains the
|
|
143
|
+
* missing link. The label is `"disconnected"`, not the design prototype's "reconnecting…":
|
|
144
|
+
* retry machinery is a product capability this atom cannot verify (a product that really does
|
|
145
|
+
* retry can pass its own `statusLabel`).
|
|
146
|
+
* 2. An ACTIVITY claim, but only for a session that is `active` or has no reported lifecycle —
|
|
147
|
+
* a "working" claim about a stopped session is a contradiction, and the lifecycle is the
|
|
148
|
+
* stronger truth.
|
|
149
|
+
* 3. The LIFECYCLE claim. This is where an active-but-no-activity session lands: `"active"`,
|
|
150
|
+
* never a fabricated `"idle"` or `"working"` (invariant 2).
|
|
151
|
+
* 4. Nothing reported at all ⇒ `"unknown"` (invariant 2).
|
|
152
|
+
*/
|
|
153
|
+
export declare function sessionStatus(input?: SessionStatusInput | null, contextBand?: CtxBand | null): SessionStatus;
|
|
154
|
+
/** Status class: tone modifier + the transient-pulse flag. The dot is a child element, so the
|
|
155
|
+
* modifier tints the words and the dot together. */
|
|
156
|
+
export declare function sessionStatusClass(status: SessionStatus): string;
|
|
157
|
+
/**
|
|
158
|
+
* Whether the card wears the design's STALE treatment (dashed border, muted values) — true exactly
|
|
159
|
+
* when the link is down. Kept here rather than in the binding so both bindings, and any product
|
|
160
|
+
* that wants to pre-compute it, agree on one rule.
|
|
161
|
+
*/
|
|
162
|
+
export declare function sessionCardIsStale(status: SessionStatus): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* The card's stale treatment, including a product's own claim. A product may ADD staleness (its
|
|
165
|
+
* data is old for a reason the card cannot see); it may NOT take away the staleness a down link
|
|
166
|
+
* implies — `stale={false}` on a disconnected session would paint it as a live, solid-bordered
|
|
167
|
+
* card, which is exactly the lie this treatment exists to prevent.
|
|
168
|
+
*/
|
|
169
|
+
export declare function sessionCardStale(status: SessionStatus, productClaim?: boolean): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* The words beside the dot. A product may substitute its own honest phrasing for the derived
|
|
172
|
+
* label — the tone, the pulse and the stale treatment still come from the derivation.
|
|
173
|
+
*
|
|
174
|
+
* Three refusals:
|
|
175
|
+
* · a BLANK override falls back to the derived label, rather than leaving the status as colour
|
|
176
|
+
* alone (token rule #7);
|
|
177
|
+
* · the `unknown` status ignores the override entirely. There is no alternative honest wording
|
|
178
|
+
* for "the product told us nothing" — nothing was claimed, so there is nothing to reword;
|
|
179
|
+
* · an override that states another status's claim is ignored. `statusLabel="idle"` — or
|
|
180
|
+
* `"currently idle"` — on a session whose activity was never reported would state a claim no
|
|
181
|
+
* wire made; invariant 2 is structural here, not a matter of trusting the caller. The two
|
|
182
|
+
* ACTIVITY words are refused anywhere in the override; every other reserved word is refused
|
|
183
|
+
* only as the whole of it. Rewording is still free: anything outside that vocabulary
|
|
184
|
+
* (`"wake unavailable"`, `"stopped (exit 1)"`, …) passes.
|
|
185
|
+
*
|
|
186
|
+
* Documented limit: a status the context escalation has taken over (`context high` /
|
|
187
|
+
* `context critical`) can no longer use an activity word either, even if the wire did report one —
|
|
188
|
+
* the rendered status is the context claim, and the product can word it another way.
|
|
189
|
+
*/
|
|
190
|
+
export declare function sessionStatusText(status: SessionStatus, override?: string | null): string;
|
|
191
|
+
/** Container class — the WHOLE class attribute the card's root carries, including any extra
|
|
192
|
+
* classes a product passes, so neither binding composes a class string of its own. `selected` and
|
|
193
|
+
* `stale` are INDEPENDENT: a selected session can also be disconnected, so they are two
|
|
194
|
+
* modifiers, never one enum. */
|
|
195
|
+
export declare function sessionCardClass(input?: {
|
|
196
|
+
selected?: boolean;
|
|
197
|
+
stale?: boolean;
|
|
198
|
+
extra?: string | null;
|
|
199
|
+
} | null): string;
|
|
200
|
+
/** What an unnameable session's avatar shows — a question mark, not a fabricated initial. */
|
|
201
|
+
export declare const SESSION_AVATAR_UNKNOWN = "?";
|
|
202
|
+
/** Avatar initial: the first alphanumeric of the display name, uppercased; `"?"` when there is
|
|
203
|
+
* none. (Merges the two divergent copies the product carried — the rail card's "first char,
|
|
204
|
+
* em-dash fallback" and derive.ts's "first alphanumeric, ?-fallback" — on the latter, which
|
|
205
|
+
* cannot emit punctuation or whitespace as an initial.) */
|
|
206
|
+
export declare function sessionAvatarInitial(name: string | null | undefined): string;
|
|
207
|
+
/**
|
|
208
|
+
* The card's meta subline — `role · model · duration` on the design card, but deliberately a free
|
|
209
|
+
* list: the spec's own states also use it for `role · model · queued: 1 ON-DONE` and
|
|
210
|
+
* `role · last seen 00:12 ago`. Absent/blank parts COLLAPSE, so there is never a dangling
|
|
211
|
+
* separator, and an all-absent list yields `""` (the binding then omits the element entirely
|
|
212
|
+
* rather than rendering an empty row).
|
|
213
|
+
*/
|
|
214
|
+
export declare function sessionSubline(parts?: readonly (string | null | undefined)[] | null): string;
|
|
215
|
+
export interface SessionSpine {
|
|
216
|
+
/** Distills completed. `undefined` ⇒ the product did not report it — the strip is OMITTED. */
|
|
217
|
+
distills?: number;
|
|
218
|
+
/** Tokens saved. `undefined` ⇒ not reported — renders `"—"`, never `"0 tok"`. */
|
|
219
|
+
savedTok?: number;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The most nodes the strip will draw. The strip is a fixed-width row of 13px nodes, so beyond this
|
|
223
|
+
* they cannot be told apart anyway — and a runaway count from a malformed wire value must not be
|
|
224
|
+
* able to build an unbounded node list and lock the render. The LABEL beside the strip always
|
|
225
|
+
* states the TRUE count, so the bound costs no honesty: the strip is a bounded illustration, the
|
|
226
|
+
* number is the claim.
|
|
227
|
+
*/
|
|
228
|
+
export declare const SPINE_MAX_NODES = 24;
|
|
229
|
+
export interface SpineNode {
|
|
230
|
+
/** The live tip (hollow); every other node is a completed distill (filled). */
|
|
231
|
+
tip: boolean;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Nodes for the strip: one filled node per completed distill, plus the hollow live tip.
|
|
235
|
+
* An UNREPORTED `distills` yields `[]` — no strip, no fabricated "0 distills" (invariant 1). A
|
|
236
|
+
* REPORTED 0 is a real reading and yields the tip alone. Non-integer/negative counts are floored,
|
|
237
|
+
* and the list is capped at `SPINE_MAX_NODES` so a runaway value cannot lock the render (the
|
|
238
|
+
* strip's label still states the true count).
|
|
239
|
+
*/
|
|
240
|
+
export declare function sessionSpineNodes(distills: number | null | undefined): SpineNode[];
|
|
241
|
+
/** What an unreported token saving renders as. */
|
|
242
|
+
export declare const SPINE_SAVED_UNKNOWN = "\u2014";
|
|
243
|
+
/**
|
|
244
|
+
* The strip's right-hand value. Absent ⇒ `"—"` (invariant 1). A saving is a REDUCTION, so it
|
|
245
|
+
* carries a real minus sign (U+2212); a reported 0 is unsigned; a negative input (context grew)
|
|
246
|
+
* is stated as growth rather than silently re-signed.
|
|
247
|
+
*/
|
|
248
|
+
export declare function sessionSpineSavedText(savedTok: number | null | undefined): string;
|
|
249
|
+
/** The strip's left-hand label: `spine · 3 distills` (singular at 1). */
|
|
250
|
+
export declare function sessionSpineLabel(distills: number): string;
|
|
251
|
+
export interface SpineSummary {
|
|
252
|
+
nodes: SpineNode[];
|
|
253
|
+
label: string;
|
|
254
|
+
value: string;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* The whole strip, or `undefined` when the product reported no distill count — the card then
|
|
258
|
+
* renders no strip at all. `spine.savedTok` is independent: a reported distill count with an
|
|
259
|
+
* unreported saving still draws the strip, with `"—"` for the value.
|
|
260
|
+
*/
|
|
261
|
+
export declare function sessionSpineSummary(spine: SessionSpine | null | undefined): SpineSummary | undefined;
|
|
262
|
+
/** Class for one spine node — filled distill vs. the hollow live tip. */
|
|
263
|
+
export declare function spineNodeClass(node: SpineNode): string;
|