@agentdeck/shared 0.1.0 → 0.2.3
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/LICENSE +21 -0
- package/dist/adapter.d.ts +18 -3
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +62 -0
- package/dist/adapter.js.map +1 -1
- package/dist/command-builders.d.ts +35 -0
- package/dist/command-builders.d.ts.map +1 -0
- package/dist/command-builders.js +75 -0
- package/dist/command-builders.js.map +1 -0
- package/dist/connection-status.d.ts +42 -0
- package/dist/connection-status.d.ts.map +1 -0
- package/dist/connection-status.js +52 -0
- package/dist/connection-status.js.map +1 -0
- package/dist/d200h-layout.d.ts +131 -0
- package/dist/d200h-layout.d.ts.map +1 -0
- package/dist/d200h-layout.js +627 -0
- package/dist/d200h-layout.js.map +1 -0
- package/dist/design-tokens.d.ts +259 -0
- package/dist/design-tokens.d.ts.map +1 -0
- package/dist/design-tokens.js +156 -0
- package/dist/design-tokens.js.map +1 -0
- package/dist/eval-schema.d.ts +235 -0
- package/dist/eval-schema.d.ts.map +1 -0
- package/dist/eval-schema.js +23 -0
- package/dist/eval-schema.js.map +1 -0
- package/dist/format-utils.d.ts +52 -0
- package/dist/format-utils.d.ts.map +1 -0
- package/dist/format-utils.js +165 -0
- package/dist/format-utils.js.map +1 -0
- package/dist/gateway-protocol.d.ts +391 -0
- package/dist/gateway-protocol.d.ts.map +1 -0
- package/dist/gateway-protocol.js +19 -0
- package/dist/gateway-protocol.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/dist/llm-settings.d.ts +52 -0
- package/dist/llm-settings.d.ts.map +1 -0
- package/dist/llm-settings.js +118 -0
- package/dist/llm-settings.js.map +1 -0
- package/dist/net-utils.d.ts +2 -1
- package/dist/net-utils.d.ts.map +1 -1
- package/dist/net-utils.js +100 -3
- package/dist/net-utils.js.map +1 -1
- package/dist/pricing.d.ts +45 -0
- package/dist/pricing.d.ts.map +1 -0
- package/dist/pricing.js +93 -0
- package/dist/pricing.js.map +1 -0
- package/dist/protocol.d.ts +496 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +30 -1
- package/dist/protocol.js.map +1 -1
- package/dist/sample.d.ts +152 -0
- package/dist/sample.d.ts.map +1 -0
- package/dist/sample.js +22 -0
- package/dist/sample.js.map +1 -0
- package/dist/session-utils.d.ts +142 -0
- package/dist/session-utils.d.ts.map +1 -0
- package/dist/session-utils.js +304 -0
- package/dist/session-utils.js.map +1 -0
- package/dist/state-colors.d.ts +16 -0
- package/dist/state-colors.d.ts.map +1 -0
- package/dist/state-colors.js +48 -0
- package/dist/state-colors.js.map +1 -0
- package/dist/states.d.ts +2 -0
- package/dist/states.d.ts.map +1 -1
- package/dist/states.js +6 -1
- package/dist/states.js.map +1 -1
- package/dist/svg-renderers/agent-logos.d.ts +45 -0
- package/dist/svg-renderers/agent-logos.d.ts.map +1 -0
- package/dist/svg-renderers/agent-logos.js +238 -0
- package/dist/svg-renderers/agent-logos.js.map +1 -0
- package/dist/svg-renderers/index.d.ts +4 -0
- package/dist/svg-renderers/index.d.ts.map +1 -0
- package/dist/svg-renderers/index.js +4 -0
- package/dist/svg-renderers/index.js.map +1 -0
- package/dist/svg-renderers/session-slot-renderer.d.ts +78 -0
- package/dist/svg-renderers/session-slot-renderer.d.ts.map +1 -0
- package/dist/svg-renderers/session-slot-renderer.js +506 -0
- package/dist/svg-renderers/session-slot-renderer.js.map +1 -0
- package/dist/svg-renderers/text-utils.d.ts +29 -0
- package/dist/svg-renderers/text-utils.d.ts.map +1 -0
- package/dist/svg-renderers/text-utils.js +122 -0
- package/dist/svg-renderers/text-utils.js.map +1 -0
- package/dist/telemetry-envelope.d.ts +108 -0
- package/dist/telemetry-envelope.d.ts.map +1 -0
- package/dist/telemetry-envelope.js +34 -0
- package/dist/telemetry-envelope.js.map +1 -0
- package/dist/timeline-icons.d.ts +70 -0
- package/dist/timeline-icons.d.ts.map +1 -0
- package/dist/timeline-icons.js +161 -0
- package/dist/timeline-icons.js.map +1 -0
- package/dist/timeline-label.d.ts +38 -0
- package/dist/timeline-label.d.ts.map +1 -0
- package/dist/timeline-label.js +95 -0
- package/dist/timeline-label.js.map +1 -0
- package/dist/timeline-markdown.d.ts +80 -0
- package/dist/timeline-markdown.d.ts.map +1 -0
- package/dist/timeline-markdown.js +221 -0
- package/dist/timeline-markdown.js.map +1 -0
- package/dist/timeline-summarizer.d.ts +37 -0
- package/dist/timeline-summarizer.d.ts.map +1 -0
- package/dist/timeline-summarizer.js +125 -0
- package/dist/timeline-summarizer.js.map +1 -0
- package/dist/timeline.d.ts +135 -0
- package/dist/timeline.d.ts.map +1 -0
- package/dist/timeline.js +633 -0
- package/dist/timeline.js.map +1 -0
- package/dist/voice-paths.d.ts +4 -0
- package/dist/voice-paths.d.ts.map +1 -1
- package/dist/voice-paths.js +5 -0
- package/dist/voice-paths.js.map +1 -1
- package/package.json +9 -3
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentDeck eval v1 — canonical schema for APME (Agent Performance Monitoring & Evaluation).
|
|
3
|
+
*
|
|
4
|
+
* Source-of-truth for evaluation data emitted by AgentDeck. Versioned so external
|
|
5
|
+
* consumers (dashboards, exporters, future tooling) have a stable contract.
|
|
6
|
+
*
|
|
7
|
+
* Versioning rule (also in docs/apme.md):
|
|
8
|
+
* - Adding a new optional field, axis, or category: stays v1 (additive).
|
|
9
|
+
* - Renaming, removing, or changing the meaning of a field: requires v2.
|
|
10
|
+
* - Bridge tags every APME HTTP response body with `schema: EVAL_SCHEMA_VERSION`.
|
|
11
|
+
*
|
|
12
|
+
* Authoritative storage layout: `bridge/src/apme/store.ts`. These types match the
|
|
13
|
+
* SQLite schema's logical fields (camelCase) — column-level naming lives in the DAO.
|
|
14
|
+
*/
|
|
15
|
+
import type { AgentType } from './adapter.js';
|
|
16
|
+
/** Wire-format version. Bump on any breaking change to the types in this file. */
|
|
17
|
+
export declare const EVAL_SCHEMA_VERSION: "agentdeck-eval/v1";
|
|
18
|
+
export type EvalSchemaVersion = typeof EVAL_SCHEMA_VERSION;
|
|
19
|
+
export interface ApmeRunRow {
|
|
20
|
+
id: string;
|
|
21
|
+
sessionId: string;
|
|
22
|
+
agentType: AgentType;
|
|
23
|
+
modelId?: string | null;
|
|
24
|
+
projectName?: string | null;
|
|
25
|
+
projectPath?: string | null;
|
|
26
|
+
taskPrompt?: string | null;
|
|
27
|
+
startedAt: number;
|
|
28
|
+
endedAt?: number | null;
|
|
29
|
+
inputTokens?: number | null;
|
|
30
|
+
outputTokens?: number | null;
|
|
31
|
+
costUsd?: number | null;
|
|
32
|
+
exitCode?: number | null;
|
|
33
|
+
gitBefore?: string | null;
|
|
34
|
+
gitAfter?: string | null;
|
|
35
|
+
/** JSON string. Per-run hardware sample (cpu/memory/load). */
|
|
36
|
+
hwProfile?: string | null;
|
|
37
|
+
/** JSON string. Output of the rule-based classifier — tool counts, file scopes, etc. */
|
|
38
|
+
taskSignals?: string | null;
|
|
39
|
+
taskCategory?: string | null;
|
|
40
|
+
/** 'auto' | 'user' | 'llm' | 'rule'. */
|
|
41
|
+
taskCategorySource?: string | null;
|
|
42
|
+
/** committed | abandoned | iterated | ab_winner | ab_loser | interrupted | exploratory. */
|
|
43
|
+
outcome?: string | null;
|
|
44
|
+
/** high | medium | low. */
|
|
45
|
+
outcomeConfidence?: string | null;
|
|
46
|
+
/** JSON string. Efficiency metrics (response_kind, tool churn, etc.). */
|
|
47
|
+
efficiencyJson?: string | null;
|
|
48
|
+
/** Weighted aggregate of outcome / judge / efficiency / vibe. 0–1 scale. */
|
|
49
|
+
compositeScore?: number | null;
|
|
50
|
+
}
|
|
51
|
+
export interface ApmeStepRow {
|
|
52
|
+
id?: number;
|
|
53
|
+
runId: string;
|
|
54
|
+
ts: number;
|
|
55
|
+
/** PreToolUse | PostToolUse | Stop | UserPromptSubmit | chat_start | tool_request | … */
|
|
56
|
+
kind: string;
|
|
57
|
+
toolName?: string | null;
|
|
58
|
+
/** JSON string of the original event payload. */
|
|
59
|
+
payload: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ApmeArtifactRow {
|
|
62
|
+
id?: number;
|
|
63
|
+
runId: string;
|
|
64
|
+
/** before_snapshot | after_snapshot | diff | pty_log | lint_out | test_out | … */
|
|
65
|
+
kind: 'before_snapshot' | 'after_snapshot' | 'diff' | 'pty_log' | 'lint_out' | 'test_out' | string;
|
|
66
|
+
path: string;
|
|
67
|
+
sha256?: string | null;
|
|
68
|
+
bytes?: number | null;
|
|
69
|
+
}
|
|
70
|
+
export type ApmeEvalLayer = 'deterministic' | 'llm_judge' | 'vibe' | 'turn_judge' | 'task_judge'
|
|
71
|
+
/** Pure, sample-trajectory scorers (no LLM): trajectory quality, tool
|
|
72
|
+
* efficiency, reliability. Computed over a SessionSample's typed events. */
|
|
73
|
+
| 'trajectory';
|
|
74
|
+
export interface ApmeEvalRowDb {
|
|
75
|
+
id?: number;
|
|
76
|
+
runId: string;
|
|
77
|
+
layer: ApmeEvalLayer;
|
|
78
|
+
/** Axis name. Rubric-specific (e.g. 'task_completion', 'accuracy', 'overall'). */
|
|
79
|
+
metric: string;
|
|
80
|
+
score: number;
|
|
81
|
+
/** Raw judge JSON (reasoning, done, missed, summary). */
|
|
82
|
+
raw?: string | null;
|
|
83
|
+
rubricVer?: number | null;
|
|
84
|
+
judgeModel?: string | null;
|
|
85
|
+
createdAt: number;
|
|
86
|
+
}
|
|
87
|
+
/** A `task` groups consecutive turns within a run. Boundaries are detected
|
|
88
|
+
* automatically from agent events:
|
|
89
|
+
* - `todo_complete` — TodoWrite PostToolUse where every todo.status === 'completed'
|
|
90
|
+
* - `clear` — UserPromptSubmit `/clear` (also splits the run)
|
|
91
|
+
* - `session_end` — closeRun finalization
|
|
92
|
+
* - `manual` — reserved for a future explicit task-end marker
|
|
93
|
+
*
|
|
94
|
+
* A task-level judge reads all turns belonging to the task and writes a
|
|
95
|
+
* one-line `summary` + `compositeScore`. Individual axis scores land in
|
|
96
|
+
* `evals` rows with `layer='task_judge'` and `taskId` set.
|
|
97
|
+
*/
|
|
98
|
+
export type TaskBoundarySignal = 'todo_complete' | 'clear' | 'session_end' | 'manual' | 'idle_gap' | 'open' | string;
|
|
99
|
+
export interface ApmeTaskRow {
|
|
100
|
+
id: string;
|
|
101
|
+
runId: string;
|
|
102
|
+
taskIndex: number;
|
|
103
|
+
boundarySignal: TaskBoundarySignal;
|
|
104
|
+
startedAt: number;
|
|
105
|
+
endedAt?: number | null;
|
|
106
|
+
firstTurnIndex?: number | null;
|
|
107
|
+
lastTurnIndex?: number | null;
|
|
108
|
+
summary?: string | null;
|
|
109
|
+
outcome?: string | null;
|
|
110
|
+
compositeScore?: number | null;
|
|
111
|
+
taskCategory?: string | null;
|
|
112
|
+
/** Raw judge JSON (done/missed/reasoning) for the task rollup. */
|
|
113
|
+
notesJson?: string | null;
|
|
114
|
+
/** Real model id for this sample (the task IS the SessionSample header). */
|
|
115
|
+
modelId?: string | null;
|
|
116
|
+
/** JSON string of SampleModelConfig (provider, subagents, mcpServers). */
|
|
117
|
+
modelConfig?: string | null;
|
|
118
|
+
/** Aggregated from the sample's ModelEvents. */
|
|
119
|
+
inputTokens?: number | null;
|
|
120
|
+
outputTokens?: number | null;
|
|
121
|
+
costUsd?: number | null;
|
|
122
|
+
latencyMs?: number | null;
|
|
123
|
+
}
|
|
124
|
+
/** Per-(agent, model, category) scorecard row at sample granularity — the
|
|
125
|
+
* recommender's real unit. Backed by `v_sample_scorecard`. */
|
|
126
|
+
export interface ApmeSampleScorecardRow {
|
|
127
|
+
agentType: string;
|
|
128
|
+
modelId: string;
|
|
129
|
+
taskCategory: string | null;
|
|
130
|
+
samples: number;
|
|
131
|
+
avgQuality: number | null;
|
|
132
|
+
totalCost: number | null;
|
|
133
|
+
avgLatencyMs: number | null;
|
|
134
|
+
costPerQuality: number | null;
|
|
135
|
+
}
|
|
136
|
+
export interface ApmeRubricRow {
|
|
137
|
+
version: number;
|
|
138
|
+
/** 'general' | 'conversation' | 'planning' | 'research' | 'debugging' | 'refactoring'
|
|
139
|
+
* | 'review' | 'ops' | 'task_rollup' | … */
|
|
140
|
+
purpose: string;
|
|
141
|
+
prompt: string;
|
|
142
|
+
/** JSON string mapping axis → weight. */
|
|
143
|
+
weights: string;
|
|
144
|
+
createdAt: number;
|
|
145
|
+
parentVer?: number | null;
|
|
146
|
+
notes?: string | null;
|
|
147
|
+
}
|
|
148
|
+
export interface ApmeVibeRow {
|
|
149
|
+
id?: number;
|
|
150
|
+
runId: string;
|
|
151
|
+
verdict: 'approve' | 'reject' | 'neutral';
|
|
152
|
+
note?: string | null;
|
|
153
|
+
ts: number;
|
|
154
|
+
}
|
|
155
|
+
export interface ApmeScorecardRow {
|
|
156
|
+
agentType: string;
|
|
157
|
+
modelId: string;
|
|
158
|
+
runs: number;
|
|
159
|
+
avgOverall: number | null;
|
|
160
|
+
avgTestsPass: number | null;
|
|
161
|
+
totalCost: number | null;
|
|
162
|
+
costPerQuality: number | null;
|
|
163
|
+
}
|
|
164
|
+
export interface ApmeCategoryScorecardRow {
|
|
165
|
+
taskCategory: string;
|
|
166
|
+
modelId: string;
|
|
167
|
+
runs: number;
|
|
168
|
+
avgOverall: number | null;
|
|
169
|
+
avgTestsPass: number | null;
|
|
170
|
+
totalCost: number | null;
|
|
171
|
+
}
|
|
172
|
+
/** Parsed shape of a judge LLM's JSON response. Rubric-specific axes land in
|
|
173
|
+
* `scores` (e.g. `task_completion`, `accuracy`, `overall`). `summary` is
|
|
174
|
+
* populated only by the `task_rollup` rubric. */
|
|
175
|
+
export interface ParsedJudge {
|
|
176
|
+
scores: Record<string, number>;
|
|
177
|
+
reasoning: string;
|
|
178
|
+
/** Items the agent completed (for human verification of judge reasoning). */
|
|
179
|
+
done?: string[];
|
|
180
|
+
/** Items the agent missed. */
|
|
181
|
+
missed?: string[];
|
|
182
|
+
/** One-sentence task summary, ≤ 140 chars (task_rollup rubric only). */
|
|
183
|
+
summary?: string;
|
|
184
|
+
}
|
|
185
|
+
/** Response classification stored in `turns.efficiency_json.response_kind`. Drives
|
|
186
|
+
* which turns make it to the LLM judge — `tool_only` / `empty` are silence to
|
|
187
|
+
* the judge and produce noise scores. */
|
|
188
|
+
export type ResponseKind = 'text' | 'tool_only' | 'empty';
|
|
189
|
+
/** Common envelope for every APME GET response. External consumers should check
|
|
190
|
+
* `schema` and refuse to deserialize unknown major versions. */
|
|
191
|
+
export interface ApmeApiEnvelope {
|
|
192
|
+
schema: EvalSchemaVersion;
|
|
193
|
+
}
|
|
194
|
+
export interface ApmeRunEvalSummary {
|
|
195
|
+
layer: string;
|
|
196
|
+
metric: string;
|
|
197
|
+
score: number;
|
|
198
|
+
rubricVer: number | null;
|
|
199
|
+
judgeModel: string | null;
|
|
200
|
+
createdAt: number;
|
|
201
|
+
}
|
|
202
|
+
export interface ApmeRunWithEvalsSummary extends ApmeRunRow {
|
|
203
|
+
evals: ApmeRunEvalSummary[];
|
|
204
|
+
overallScore: number | null;
|
|
205
|
+
vibe: {
|
|
206
|
+
verdict: ApmeVibeRow['verdict'];
|
|
207
|
+
} | null;
|
|
208
|
+
}
|
|
209
|
+
export interface ApmeRunsResponse extends ApmeApiEnvelope {
|
|
210
|
+
runs: ApmeRunWithEvalsSummary[];
|
|
211
|
+
}
|
|
212
|
+
export interface ApmeRunDetailResponse extends ApmeApiEnvelope {
|
|
213
|
+
run: ApmeRunRow;
|
|
214
|
+
evals: ApmeEvalRowDb[];
|
|
215
|
+
steps: ApmeStepRow[];
|
|
216
|
+
/** Raw turn rows (snake_case from SQLite) plus per-turn evals. */
|
|
217
|
+
turns: Array<Record<string, unknown> & {
|
|
218
|
+
turnEvals: ApmeEvalRowDb[];
|
|
219
|
+
}>;
|
|
220
|
+
vibe: ApmeVibeRow | null;
|
|
221
|
+
overallScore: number | null;
|
|
222
|
+
}
|
|
223
|
+
export interface ApmeScorecardResponse extends ApmeApiEnvelope {
|
|
224
|
+
scorecards: ApmeScorecardRow[];
|
|
225
|
+
}
|
|
226
|
+
export interface ApmeCategoriesResponse extends ApmeApiEnvelope {
|
|
227
|
+
categories: ApmeCategoryScorecardRow[];
|
|
228
|
+
}
|
|
229
|
+
export interface ApmeRubricResponse extends ApmeApiEnvelope {
|
|
230
|
+
rubric: ApmeRubricRow;
|
|
231
|
+
}
|
|
232
|
+
/** Wrap any payload with the schema version envelope. Used by the bridge's
|
|
233
|
+
* HTTP routes so callers don't have to remember the constant. */
|
|
234
|
+
export declare function withSchemaEnvelope<T extends Record<string, unknown>>(body: T): T & ApmeApiEnvelope;
|
|
235
|
+
//# sourceMappingURL=eval-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eval-schema.d.ts","sourceRoot":"","sources":["../src/eval-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,EAAG,mBAA4B,CAAC;AAChE,MAAM,MAAM,iBAAiB,GAAG,OAAO,mBAAmB,CAAC;AAI3D,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IA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).
|
|
3
|
+
*
|
|
4
|
+
* Source-of-truth for evaluation data emitted by AgentDeck. Versioned so external
|
|
5
|
+
* consumers (dashboards, exporters, future tooling) have a stable contract.
|
|
6
|
+
*
|
|
7
|
+
* Versioning rule (also in docs/apme.md):
|
|
8
|
+
* - Adding a new optional field, axis, or category: stays v1 (additive).
|
|
9
|
+
* - Renaming, removing, or changing the meaning of a field: requires v2.
|
|
10
|
+
* - Bridge tags every APME HTTP response body with `schema: EVAL_SCHEMA_VERSION`.
|
|
11
|
+
*
|
|
12
|
+
* Authoritative storage layout: `bridge/src/apme/store.ts`. These types match the
|
|
13
|
+
* SQLite schema's logical fields (camelCase) — column-level naming lives in the DAO.
|
|
14
|
+
*/
|
|
15
|
+
/** Wire-format version. Bump on any breaking change to the types in this file. */
|
|
16
|
+
export const EVAL_SCHEMA_VERSION = 'agentdeck-eval/v1';
|
|
17
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
18
|
+
/** Wrap any payload with the schema version envelope. Used by the bridge's
|
|
19
|
+
* HTTP routes so callers don't have to remember the constant. */
|
|
20
|
+
export function withSchemaEnvelope(body) {
|
|
21
|
+
return { schema: EVAL_SCHEMA_VERSION, ...body };
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=eval-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eval-schema.js","sourceRoot":"","sources":["../src/eval-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,kFAAkF;AAClF,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAA4B,CAAC;AA6PhE,iFAAiF;AAEjF;kEACkE;AAClE,MAAM,UAAU,kBAAkB,CAChC,IAAO;IAEP,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,IAAI,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared format utilities — canonical implementations for time, count, bytes.
|
|
3
|
+
* Used by bridge, plugin, and ported to Android/Apple (manual sync).
|
|
4
|
+
*/
|
|
5
|
+
/** Format ISO timestamp to relative time like "2h 30m" or "1d 5h" */
|
|
6
|
+
export declare function formatResetTime(isoString: string | undefined): string | undefined;
|
|
7
|
+
/** Compact format without spaces — "2d5h", "4h23m". For pixel-constrained displays. */
|
|
8
|
+
export declare function formatResetTimeCompact(isoString: string): string;
|
|
9
|
+
/** Format count: 1234 → "1.2K", 1500000 → "1.5M" */
|
|
10
|
+
export declare function formatCount(n: number): string;
|
|
11
|
+
/** Format byte size: 1073741824 → "1.0G", 1048576 → "1M" */
|
|
12
|
+
export declare function formatBytes(bytes: number): string;
|
|
13
|
+
/** Format uptime from seconds: 3725 → "1h 2m" */
|
|
14
|
+
export declare function formatUptime(sec: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Reconcile a rate-limit percent against its resets_at timestamp.
|
|
17
|
+
*
|
|
18
|
+
* - Future resets_at → trust percent (current window).
|
|
19
|
+
* - Recently past resets_at → return 0 (window just rolled over; old percent is meaningless).
|
|
20
|
+
* - Far-past resets_at (> 1h) → trust percent (server is returning a prior window's
|
|
21
|
+
* final value because no new window is active; zeroing would underreport).
|
|
22
|
+
* Consumers should pair this with a `usageStale` badge so the user sees uncertainty.
|
|
23
|
+
*/
|
|
24
|
+
export declare function adjustUsagePercent(percent: number | null | undefined, resetsAt: string | null | undefined): number | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* A Codex rolling-window snapshot is stale once its window has ended: `resetsAt`
|
|
27
|
+
* is in the past beyond a short grace. Codex usage is read passively from the
|
|
28
|
+
* newest local rollout file, so once Codex stops being used the snapshot freezes
|
|
29
|
+
* — `usedPercent` stays at its last value and `resetsAt` slides into the past. At
|
|
30
|
+
* that point a "now" countdown would mislead (the bar still shows the old percent),
|
|
31
|
+
* so consumers should dim the gauge and show a "stale" marker instead.
|
|
32
|
+
*
|
|
33
|
+
* Grace (default 5m) keeps a genuinely-just-reset window briefly showing "now".
|
|
34
|
+
*/
|
|
35
|
+
export declare function isCodexWindowStale(resetsAt: string | undefined, graceMs?: number): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Antigravity plan name → compact "AGY <tier>" chip.
|
|
38
|
+
*
|
|
39
|
+
* "Google AI Pro" → "AGY Pro"
|
|
40
|
+
* "Google AI Ultra" → "AGY Ultra"
|
|
41
|
+
* "" / undefined → undefined (nothing to show)
|
|
42
|
+
*
|
|
43
|
+
* The raw `availableCredits` count is deliberately never surfaced — it's backend
|
|
44
|
+
* metering with no glanceable meaning (see antigravity-local.ts). This is the
|
|
45
|
+
* canonical definition; the native mirrors (ESP32 `util/usage_format.h`
|
|
46
|
+
* `formatAgyPlan`, Android `EinkMonitorScreen.buildAntigravityLimitValue`) must
|
|
47
|
+
* match it. Idempotent: an already-"AGY …" string is returned unchanged.
|
|
48
|
+
*/
|
|
49
|
+
export declare function formatAntigravityPlanShort(planName?: string | null): string | undefined;
|
|
50
|
+
/** Plain-text gauge bar: "████░░" (no ANSI colors) */
|
|
51
|
+
export declare function gaugeBar(percent: number, width?: number): string;
|
|
52
|
+
//# sourceMappingURL=format-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-utils.d.ts","sourceRoot":"","sources":["../src/format-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAyBjF;AAED,uFAAuF;AACvF,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAahE;AAED,oDAAoD;AACpD,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAI7C;AAED,4DAA4D;AAC5D,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWjD;AAED,iDAAiD;AACjD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAClC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAClC,MAAM,GAAG,SAAS,CAapB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,SAAa,GAAG,OAAO,CAK9F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CASvF;AAED,sDAAsD;AACtD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM,CAK3D"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared format utilities — canonical implementations for time, count, bytes.
|
|
3
|
+
* Used by bridge, plugin, and ported to Android/Apple (manual sync).
|
|
4
|
+
*/
|
|
5
|
+
/** Format ISO timestamp to relative time like "2h 30m" or "1d 5h" */
|
|
6
|
+
export function formatResetTime(isoString) {
|
|
7
|
+
if (!isoString)
|
|
8
|
+
return undefined;
|
|
9
|
+
// Already pre-formatted (no 'T' in ISO dates means it's a relative string)
|
|
10
|
+
if (!isoString.includes('T'))
|
|
11
|
+
return isoString;
|
|
12
|
+
try {
|
|
13
|
+
const resetMs = new Date(isoString).getTime();
|
|
14
|
+
if (isNaN(resetMs))
|
|
15
|
+
return undefined;
|
|
16
|
+
const diffMs = resetMs - Date.now();
|
|
17
|
+
if (diffMs <= 0)
|
|
18
|
+
return 'now';
|
|
19
|
+
const diffMin = Math.floor(diffMs / 60000);
|
|
20
|
+
if (diffMin < 60)
|
|
21
|
+
return `${diffMin}m`;
|
|
22
|
+
const h = Math.floor(diffMin / 60);
|
|
23
|
+
const m = diffMin % 60;
|
|
24
|
+
if (h < 24)
|
|
25
|
+
return m > 0 ? `${h}h ${m}m` : `${h}h`;
|
|
26
|
+
const d = Math.floor(h / 24);
|
|
27
|
+
const rh = h % 24;
|
|
28
|
+
return rh > 0 ? `${d}d ${rh}h` : `${d}d`;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Compact format without spaces — "2d5h", "4h23m". For pixel-constrained displays. */
|
|
35
|
+
export function formatResetTimeCompact(isoString) {
|
|
36
|
+
const ms = new Date(isoString).getTime() - Date.now();
|
|
37
|
+
if (ms <= 0)
|
|
38
|
+
return '0m';
|
|
39
|
+
const totalMins = Math.max(1, Math.ceil(ms / 60000));
|
|
40
|
+
const hours = Math.floor(totalMins / 60);
|
|
41
|
+
const days = Math.floor(hours / 24);
|
|
42
|
+
const remHours = hours % 24;
|
|
43
|
+
const mins = totalMins % 60;
|
|
44
|
+
if (days > 0 && remHours > 0)
|
|
45
|
+
return `${days}d${remHours}h`;
|
|
46
|
+
if (days > 0)
|
|
47
|
+
return `${days}d`;
|
|
48
|
+
if (hours > 0 && mins > 0)
|
|
49
|
+
return `${hours}h${mins}m`;
|
|
50
|
+
if (hours > 0)
|
|
51
|
+
return `${hours}h`;
|
|
52
|
+
return `${mins}m`;
|
|
53
|
+
}
|
|
54
|
+
/** Format count: 1234 → "1.2K", 1500000 → "1.5M" */
|
|
55
|
+
export function formatCount(n) {
|
|
56
|
+
if (n >= 1_000_000)
|
|
57
|
+
return `${(n / 1_000_000).toFixed(1)}M`;
|
|
58
|
+
if (n >= 1_000)
|
|
59
|
+
return `${(n / 1_000).toFixed(1)}K`;
|
|
60
|
+
return String(n);
|
|
61
|
+
}
|
|
62
|
+
/** Format byte size: 1073741824 → "1.0G", 1048576 → "1M" */
|
|
63
|
+
export function formatBytes(bytes) {
|
|
64
|
+
if (bytes >= 1_073_741_824) {
|
|
65
|
+
const gb = bytes / 1_073_741_824;
|
|
66
|
+
return gb >= 10 ? `${Math.round(gb)}G` : `${gb.toFixed(1)}G`;
|
|
67
|
+
}
|
|
68
|
+
if (bytes >= 1_048_576) {
|
|
69
|
+
const mb = bytes / 1_048_576;
|
|
70
|
+
return mb >= 10 ? `${Math.round(mb)}M` : `${mb.toFixed(1)}M`;
|
|
71
|
+
}
|
|
72
|
+
if (bytes >= 1024)
|
|
73
|
+
return `${Math.round(bytes / 1024)}K`;
|
|
74
|
+
return `${bytes}B`;
|
|
75
|
+
}
|
|
76
|
+
/** Format uptime from seconds: 3725 → "1h 2m" */
|
|
77
|
+
export function formatUptime(sec) {
|
|
78
|
+
if (sec < 60)
|
|
79
|
+
return `${sec}s`;
|
|
80
|
+
const m = Math.floor(sec / 60);
|
|
81
|
+
const h = Math.floor(m / 60);
|
|
82
|
+
if (h > 0)
|
|
83
|
+
return `${h}h ${m % 60}m`;
|
|
84
|
+
return `${m}m`;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Reconcile a rate-limit percent against its resets_at timestamp.
|
|
88
|
+
*
|
|
89
|
+
* - Future resets_at → trust percent (current window).
|
|
90
|
+
* - Recently past resets_at → return 0 (window just rolled over; old percent is meaningless).
|
|
91
|
+
* - Far-past resets_at (> 1h) → trust percent (server is returning a prior window's
|
|
92
|
+
* final value because no new window is active; zeroing would underreport).
|
|
93
|
+
* Consumers should pair this with a `usageStale` badge so the user sees uncertainty.
|
|
94
|
+
*/
|
|
95
|
+
export function adjustUsagePercent(percent, resetsAt) {
|
|
96
|
+
if (percent == null)
|
|
97
|
+
return undefined;
|
|
98
|
+
if (resetsAt) {
|
|
99
|
+
try {
|
|
100
|
+
const resetMs = new Date(resetsAt).getTime();
|
|
101
|
+
if (!isNaN(resetMs)) {
|
|
102
|
+
const elapsed = Date.now() - resetMs;
|
|
103
|
+
if (elapsed > 3_600_000)
|
|
104
|
+
return percent;
|
|
105
|
+
if (elapsed > 0)
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch { /* fall through */ }
|
|
110
|
+
}
|
|
111
|
+
return percent;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A Codex rolling-window snapshot is stale once its window has ended: `resetsAt`
|
|
115
|
+
* is in the past beyond a short grace. Codex usage is read passively from the
|
|
116
|
+
* newest local rollout file, so once Codex stops being used the snapshot freezes
|
|
117
|
+
* — `usedPercent` stays at its last value and `resetsAt` slides into the past. At
|
|
118
|
+
* that point a "now" countdown would mislead (the bar still shows the old percent),
|
|
119
|
+
* so consumers should dim the gauge and show a "stale" marker instead.
|
|
120
|
+
*
|
|
121
|
+
* Grace (default 5m) keeps a genuinely-just-reset window briefly showing "now".
|
|
122
|
+
*/
|
|
123
|
+
export function isCodexWindowStale(resetsAt, graceMs = 5 * 60_000) {
|
|
124
|
+
if (!resetsAt)
|
|
125
|
+
return false;
|
|
126
|
+
const t = new Date(resetsAt).getTime();
|
|
127
|
+
if (isNaN(t))
|
|
128
|
+
return false;
|
|
129
|
+
return Date.now() - t > graceMs;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Antigravity plan name → compact "AGY <tier>" chip.
|
|
133
|
+
*
|
|
134
|
+
* "Google AI Pro" → "AGY Pro"
|
|
135
|
+
* "Google AI Ultra" → "AGY Ultra"
|
|
136
|
+
* "" / undefined → undefined (nothing to show)
|
|
137
|
+
*
|
|
138
|
+
* The raw `availableCredits` count is deliberately never surfaced — it's backend
|
|
139
|
+
* metering with no glanceable meaning (see antigravity-local.ts). This is the
|
|
140
|
+
* canonical definition; the native mirrors (ESP32 `util/usage_format.h`
|
|
141
|
+
* `formatAgyPlan`, Android `EinkMonitorScreen.buildAntigravityLimitValue`) must
|
|
142
|
+
* match it. Idempotent: an already-"AGY …" string is returned unchanged.
|
|
143
|
+
*/
|
|
144
|
+
export function formatAntigravityPlanShort(planName) {
|
|
145
|
+
const raw = planName?.trim();
|
|
146
|
+
if (!raw)
|
|
147
|
+
return undefined;
|
|
148
|
+
if (raw === 'AGY' || raw.startsWith('AGY '))
|
|
149
|
+
return raw;
|
|
150
|
+
let tier = raw;
|
|
151
|
+
if (/^Google AI\b/.test(tier))
|
|
152
|
+
tier = tier.slice('Google AI'.length);
|
|
153
|
+
else if (/^Antigravity\b/.test(tier))
|
|
154
|
+
tier = tier.slice('Antigravity'.length);
|
|
155
|
+
tier = tier.trim();
|
|
156
|
+
return tier ? `AGY ${tier}` : 'AGY';
|
|
157
|
+
}
|
|
158
|
+
/** Plain-text gauge bar: "████░░" (no ANSI colors) */
|
|
159
|
+
export function gaugeBar(percent, width = 6) {
|
|
160
|
+
const clamped = Math.max(0, Math.min(100, percent));
|
|
161
|
+
const filled = Math.round((clamped / 100) * width);
|
|
162
|
+
const empty = width - filled;
|
|
163
|
+
return '█'.repeat(filled) + '░'.repeat(empty);
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=format-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-utils.js","sourceRoot":"","sources":["../src/format-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,qEAAqE;AACrE,MAAM,UAAU,eAAe,CAAC,SAA6B;IAC3D,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC;IACjC,2EAA2E;IAC3E,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IAE/C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;QAC9C,IAAI,KAAK,CAAC,OAAO,CAAC;YAAE,OAAO,SAAS,CAAC;QACrC,MAAM,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEpC,IAAI,MAAM,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QAE9B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;QAC3C,IAAI,OAA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