@blackbelt-technology/pi-dashboard-cost-estimator 0.9.0 → 0.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blackbelt-technology/pi-dashboard-cost-estimator",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Software cost & effort estimation from use cases, functional and non-functional requirements and a tech stack. Sizes with Use Case Points + COCOMO II scale, routes NFRs to derived scope or a residual multiplier, distributes effort across 11 roles, compares four delivery modes (human_only, human_with_ai, ai_steered_human_supervised, agentic_hitl), and runs a Beta-PERT Monte Carlo plus an NPV/ROI business case. Calibrates agent cost and steering time from real pi session telemetry.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -65,11 +65,13 @@
65
65
  {
66
66
  "slot": "command-route",
67
67
  "component": "CostView",
68
+ "module": "./src/client/CostEstimator.tsx",
68
69
  "command": "cost"
69
70
  },
70
71
  {
71
72
  "slot": "settings-section",
72
73
  "component": "CostSettings",
74
+ "module": "./src/client/CostEstimator.tsx",
73
75
  "config": {
74
76
  "tab": "general"
75
77
  }
@@ -94,9 +96,9 @@
94
96
  "react": ">=18.0.0"
95
97
  },
96
98
  "dependencies": {
97
- "@blackbelt-technology/dashboard-plugin-runtime": "^0.9.0",
98
- "@blackbelt-technology/pi-dashboard-session-distiller": "^0.9.0",
99
- "@blackbelt-technology/pi-dashboard-shared": "^0.9.0"
99
+ "@blackbelt-technology/dashboard-plugin-runtime": "^0.10.0",
100
+ "@blackbelt-technology/pi-dashboard-session-distiller": "^0.10.0",
101
+ "@blackbelt-technology/pi-dashboard-shared": "^0.10.0"
100
102
  },
101
103
  "devDependencies": {
102
104
  "@types/react": "^19.0.0",
@@ -0,0 +1,396 @@
1
+ /**
2
+ * cost-estimator · CLIENT entry.
3
+ *
4
+ * Renders measured delivery telemetry: active steering hours per project, the
5
+ * meter-equivalent spend, and — when a seat plan is configured — the ACTUAL
6
+ * subscription cost plus the leverage between the two.
7
+ *
8
+ * DISPLAY INVARIANT: the meter figure is labelled "meter-equivalent" wherever it
9
+ * appears, and leverage is labelled leverage, never a saving. Presenting the
10
+ * theoretical meter as cash out is the single easiest way to make an estimate
11
+ * indefensible under scrutiny.
12
+ */
13
+
14
+ import {
15
+ NumberField,
16
+ SelectField,
17
+ useSettingsDraftSource,
18
+ } from "@blackbelt-technology/dashboard-plugin-runtime";
19
+ import { usePluginConfig, usePluginSend } from "@blackbelt-technology/dashboard-plugin-runtime/context";
20
+ import type React from "react";
21
+ import { useCallback, useEffect, useRef, useState } from "react";
22
+
23
+ interface Measured {
24
+ sessions: number;
25
+ activeHours: number;
26
+ steeringDays: number;
27
+ totalCost: number;
28
+ costPerSteeringHour: number;
29
+ costPerSteeringDay: number;
30
+ contextFactor: number;
31
+ revisionFactorLowerBound: number;
32
+ outputShare: number;
33
+ cacheReadShare: number;
34
+ assistantPerHumanTurn: number;
35
+ activeMonths: number;
36
+ hoursPerMonth: number;
37
+ meterPerMonth: number;
38
+ unmeteredHourShare: number;
39
+ }
40
+
41
+ interface ProjectRow {
42
+ project: string;
43
+ sessions: number;
44
+ activeHours: number;
45
+ steeringDays: number;
46
+ cost: number;
47
+ costPerHour: number;
48
+ }
49
+
50
+ interface Subscription {
51
+ monthlySeatCost: number;
52
+ months: number;
53
+ subscriptionCost: number;
54
+ meterEquivalent: number;
55
+ leverage: number;
56
+ effectiveCostPerHour: number;
57
+ meteredCostPerHour: number;
58
+ }
59
+
60
+ interface TelemetryPayload {
61
+ ok: boolean;
62
+ empty?: boolean;
63
+ error?: string;
64
+ measured: Measured | null;
65
+ projects: ProjectRow[];
66
+ subscription: Subscription | null;
67
+ seatPlan?: string;
68
+ seats?: number;
69
+ }
70
+
71
+ export interface CostEstimatorConfig {
72
+ gapCapMinutes: number;
73
+ hoursPerDay: number;
74
+ seatPlan: string;
75
+ seatMonthlyUsd: number;
76
+ seats: number;
77
+ }
78
+
79
+ const num = (value: number, digits = 0) =>
80
+ value.toLocaleString("en-US", { minimumFractionDigits: digits, maximumFractionDigits: digits });
81
+
82
+ const cell: React.CSSProperties = { padding: "4px 10px", textAlign: "right", whiteSpace: "nowrap" };
83
+ const label: React.CSSProperties = { ...cell, textAlign: "left" };
84
+ const muted: React.CSSProperties = { fontSize: "11px", opacity: 0.65 };
85
+
86
+ /** CostView — full-screen measured-cost view. Claimed on content-view + command-route. */
87
+ export function CostView() {
88
+ const [data, setData] = useState<TelemetryPayload | null>(null);
89
+ const [failed, setFailed] = useState<string | null>(null);
90
+
91
+ useEffect(() => {
92
+ let cancelled = false;
93
+ fetch("/api/cost-estimator/telemetry")
94
+ .then((response) => {
95
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
96
+ return response.json() as Promise<TelemetryPayload>;
97
+ })
98
+ .then((payload) => {
99
+ if (!cancelled) setData(payload);
100
+ })
101
+ .catch((error: unknown) => {
102
+ if (!cancelled) setFailed(error instanceof Error ? error.message : String(error));
103
+ });
104
+ return () => {
105
+ cancelled = true;
106
+ };
107
+ }, []);
108
+
109
+ if (failed) return <div style={{ padding: 16 }}>Could not load cost telemetry: {failed}</div>;
110
+ if (!data) return <div style={{ padding: 16 }}>Measuring sessions…</div>;
111
+ if (!data.ok) return <div style={{ padding: 16 }}>Cost telemetry unavailable: {data.error}</div>;
112
+ if (data.empty || !data.measured) return <div style={{ padding: 16 }}>No sessions measured yet.</div>;
113
+
114
+ const m = data.measured;
115
+ const sub = data.subscription;
116
+
117
+ return (
118
+ <div data-testid="cost-view" style={{ padding: 16, overflow: "auto", fontSize: 13 }}>
119
+ <h2 style={{ margin: "0 0 4px" }}>Measured delivery cost</h2>
120
+ <div style={muted}>
121
+ {num(m.sessions)} sessions · {num(m.activeHours, 1)} active steering hours ({num(m.steeringDays, 1)} steering-days)
122
+ · {m.activeMonths} active months · breaks over the configured gap are excluded
123
+ </div>
124
+
125
+ {sub ? (
126
+ <section style={{ marginTop: 16 }}>
127
+ <h3 style={{ margin: "0 0 4px" }}>Actual cost — subscription</h3>
128
+ <table>
129
+ <tbody>
130
+ <tr>
131
+ <td style={label}>Cash out ({data.seats}× {data.seatPlan}, {num(sub.months, 0)} mo)</td>
132
+ <td style={{ ...cell, fontWeight: 600 }}>${num(sub.subscriptionCost, 2)}</td>
133
+ </tr>
134
+ <tr>
135
+ <td style={label}>Effective per steering hour</td>
136
+ <td style={cell}>${num(sub.effectiveCostPerHour, 2)}</td>
137
+ </tr>
138
+ <tr>
139
+ <td style={label}>Meter-equivalent (theoretical, not paid)</td>
140
+ <td style={{ ...cell, opacity: 0.7 }}>${num(sub.meterEquivalent, 2)}</td>
141
+ </tr>
142
+ <tr>
143
+ <td style={label}>Subscription leverage</td>
144
+ <td style={{ ...cell, fontWeight: 600 }}>{sub.leverage.toFixed(1)}×</td>
145
+ </tr>
146
+ </tbody>
147
+ </table>
148
+ <div style={{ ...muted, marginTop: 4 }}>
149
+ {sub.leverage >= 1
150
+ ? "Leverage is on-demand value the flat plan captured — not a saving to pass on as a discount."
151
+ : "The plan costs more than metering at this volume; pay-as-you-go would be cheaper."}
152
+ </div>
153
+ </section>
154
+ ) : (
155
+ <section style={{ marginTop: 16 }}>
156
+ <h3 style={{ margin: "0 0 4px" }}>Metered basis</h3>
157
+ <div style={muted}>
158
+ No seat plan configured, so costs below are billed meter figures. If capacity is actually bought on a
159
+ subscription, set the plan in Settings — otherwise these numbers are theoretical.
160
+ </div>
161
+ </section>
162
+ )}
163
+
164
+ <section style={{ marginTop: 16 }}>
165
+ <h3 style={{ margin: "0 0 4px" }}>Meter-equivalent rates</h3>
166
+ <table>
167
+ <tbody>
168
+ <tr>
169
+ <td style={label}>Per steering hour</td>
170
+ <td style={cell}>${num(m.costPerSteeringHour, 2)}</td>
171
+ </tr>
172
+ <tr>
173
+ <td style={label}>Per steering day</td>
174
+ <td style={cell}>${num(m.costPerSteeringDay, 2)}</td>
175
+ </tr>
176
+ <tr>
177
+ <td style={label}>Per active month</td>
178
+ <td style={cell}>${num(m.meterPerMonth, 2)}</td>
179
+ </tr>
180
+ <tr>
181
+ <td style={label}>Cache-read share of tokens</td>
182
+ <td style={cell}>{(m.cacheReadShare * 100).toFixed(1)}%</td>
183
+ </tr>
184
+ <tr>
185
+ <td style={label}>Assistant turns per human turn</td>
186
+ <td style={cell}>{m.assistantPerHumanTurn.toFixed(1)} : 1</td>
187
+ </tr>
188
+ </tbody>
189
+ </table>
190
+ {m.unmeteredHourShare > 0.01 && (
191
+ <div style={{ ...muted, marginTop: 4 }}>
192
+ {(m.unmeteredHourShare * 100).toFixed(1)}% of hours ran on models the meter priced at $0 (routed or
193
+ subscription-billed) — the rates above are understated by that much.
194
+ </div>
195
+ )}
196
+ </section>
197
+
198
+ <section style={{ marginTop: 16 }}>
199
+ <h3 style={{ margin: "0 0 4px" }}>By project</h3>
200
+ <table>
201
+ <thead>
202
+ <tr>
203
+ <th style={label}>Project</th>
204
+ <th style={cell}>Sessions</th>
205
+ <th style={cell}>Active h</th>
206
+ <th style={cell}>Steering days</th>
207
+ <th style={cell}>Meter $</th>
208
+ <th style={cell}>$/h</th>
209
+ </tr>
210
+ </thead>
211
+ <tbody>
212
+ {data.projects.slice(0, 25).map((row) => (
213
+ <tr key={row.project}>
214
+ <td style={label}>{row.project}</td>
215
+ <td style={cell}>{num(row.sessions)}</td>
216
+ <td style={cell}>{num(row.activeHours, 1)}</td>
217
+ <td style={cell}>{num(row.steeringDays, 1)}</td>
218
+ <td style={cell}>{num(row.cost, 0)}</td>
219
+ <td style={cell}>{num(row.costPerHour, 2)}</td>
220
+ </tr>
221
+ ))}
222
+ </tbody>
223
+ </table>
224
+ </section>
225
+
226
+ <div style={{ ...muted, marginTop: 16 }}>
227
+ Active time counts hours where a human was engaged with the session. It is not billable-hours truth, and it does
228
+ not capture work done outside the agent.
229
+ </div>
230
+ </div>
231
+ );
232
+ }
233
+
234
+ /** Seat-plan options: stored value → label. Unset plan = "metered". */
235
+ const SEAT_PLANS = [
236
+ { value: "metered", label: "Metered (pay as you go)" },
237
+ { value: "anthropic-pro", label: "Claude Pro · $20" },
238
+ { value: "anthropic-max-5x", label: "Claude Max 5× · $100" },
239
+ { value: "anthropic-max-20x", label: "Claude Max 20× · $200" },
240
+ { value: "openai-plus", label: "ChatGPT Plus · $20" },
241
+ { value: "openai-pro-5x", label: "ChatGPT Pro 5× · $100" },
242
+ { value: "openai-pro-20x", label: "ChatGPT Pro 20× · $200" },
243
+ { value: "glm-lite", label: "GLM Coding Lite · $18" },
244
+ { value: "glm-pro", label: "GLM Coding Pro · $72" },
245
+ { value: "glm-max", label: "GLM Coding Max · $160" },
246
+ { value: "custom", label: "Custom…" },
247
+ ];
248
+
249
+ type EditableKey = "seatPlan" | "seatMonthlyUsd" | "seats" | "gapCapMinutes";
250
+ type Edits = Partial<Pick<CostEstimatorConfig, EditableKey>>;
251
+
252
+ /** Defaults the page SHOWS when a key is unset (never written unless edited). */
253
+ const DEFAULTS: Required<Edits> = {
254
+ gapCapMinutes: 15,
255
+ seatPlan: "metered",
256
+ seatMonthlyUsd: 0,
257
+ seats: 1,
258
+ };
259
+
260
+ const isWhole = (n: number) => Number.isInteger(n);
261
+
262
+ /** Range checks; `NaN` (an emptied field) is always invalid, never coerced to 0. */
263
+ function validate(values: Pick<CostEstimatorConfig, EditableKey>): Partial<Record<EditableKey, string>> {
264
+ const errors: Partial<Record<EditableKey, string>> = {};
265
+ if (values.seatPlan === "custom" && !(values.seatMonthlyUsd >= 0)) {
266
+ errors.seatMonthlyUsd = "Enter a price of 0 or more.";
267
+ }
268
+ if (!(isWhole(values.seats) && values.seats >= 1)) errors.seats = "Enter a whole number of 1 or more.";
269
+ if (!(isWhole(values.gapCapMinutes) && values.gapCapMinutes >= 1 && values.gapCapMinutes <= 120)) {
270
+ errors.gapCapMinutes = "Enter a whole number from 1 to 120.";
271
+ }
272
+ return errors;
273
+ }
274
+
275
+ /**
276
+ * CostSettings — seat plan configuration. Claimed on settings-section.
277
+ *
278
+ * Edits are held as a draft on the host Save bar (`plugin:cost-estimator`): no write per
279
+ * keystroke, commit sends ONLY the edited keys (the server merges), an emptied or
280
+ * out-of-range number blocks the commit. Unedited keys follow `plugin_config_update`.
281
+ * See change: retro-ux-plugin-settings-wave-2.
282
+ */
283
+ export function CostSettings() {
284
+ const config = usePluginConfig<Partial<CostEstimatorConfig>>();
285
+ const send = usePluginSend();
286
+ const [edits, setEdits] = useState<Edits>({});
287
+
288
+ // A broadcast that now equals an edit settles it (saved here or elsewhere), so a
289
+ // stale edit never shadows a later broadcast.
290
+ useEffect(() => {
291
+ setEdits((prev) => {
292
+ const keys = (Object.keys(prev) as EditableKey[]).filter((k) => prev[k] === config[k]);
293
+ if (keys.length === 0) return prev;
294
+ const next = { ...prev };
295
+ for (const k of keys) delete next[k];
296
+ return next;
297
+ });
298
+ }, [config]);
299
+
300
+ const value = <K extends EditableKey>(key: K): CostEstimatorConfig[K] =>
301
+ (key in edits ? edits[key] : (config[key] ?? DEFAULTS[key])) as CostEstimatorConfig[K];
302
+ const values = {
303
+ seatPlan: value("seatPlan"),
304
+ seatMonthlyUsd: value("seatMonthlyUsd"),
305
+ seats: value("seats"),
306
+ gapCapMinutes: value("gapCapMinutes"),
307
+ };
308
+ const errors = validate(values);
309
+
310
+ // Only keys that differ from what is stored; the custom price is owned only by the custom plan.
311
+ const changed: Edits = {};
312
+ for (const k of Object.keys(edits) as EditableKey[]) {
313
+ if (k === "seatMonthlyUsd" && values.seatPlan !== "custom") continue;
314
+ if (edits[k] !== config[k]) (changed as Record<string, unknown>)[k] = edits[k];
315
+ }
316
+ const isDirty = Object.keys(changed).length > 0;
317
+
318
+ const latest = useRef({ changed, errors });
319
+ latest.current = { changed, errors };
320
+ const commit = useCallback(async () => {
321
+ const { changed: payload, errors: errs } = latest.current;
322
+ if (Object.keys(errs).length > 0) throw new Error("Fix the invalid fields before saving.");
323
+ if (Object.keys(payload).length === 0) return;
324
+ await send({ type: "plugin_config_write", id: "cost-estimator", config: payload });
325
+ }, [send]);
326
+ const reset = useCallback(() => setEdits({}), []);
327
+ useSettingsDraftSource({ id: "plugin:cost-estimator", isDirty, commit, reset });
328
+
329
+ // Setting a field back to its stored value drops the edit (no ghost draft that a
330
+ // later broadcast would turn into an edit). doubt-review 4.50 #1.
331
+ const edit = (patch: Edits) =>
332
+ setEdits((prev) => {
333
+ const next: Edits = { ...prev, ...patch };
334
+ for (const k of Object.keys(patch) as EditableKey[]) if (next[k] === config[k]) delete next[k];
335
+ return next;
336
+ });
337
+ const state = (key: EditableKey) => (values[key] === DEFAULTS[key] ? "default" : "changed");
338
+
339
+ return (
340
+ <div data-testid="cost-settings" className="space-y-3">
341
+ <p className="text-xs text-[var(--text-secondary)]">
342
+ Sessions are priced at metered API rates. If you pay for a subscription instead, pick it here so cost reports
343
+ show what you really pay.
344
+ </p>
345
+
346
+ <SelectField
347
+ label="Subscription"
348
+ hint="The plan each seat is on. Metered keeps API prices."
349
+ value={values.seatPlan}
350
+ options={SEAT_PLANS}
351
+ onChange={(seatPlan) => edit({ seatPlan })}
352
+ state={state("seatPlan")}
353
+ testIds={{ control: "cost-seat-plan" }}
354
+ />
355
+
356
+ {values.seatPlan === "custom" && (
357
+ <NumberField
358
+ label="Price per seat"
359
+ unit="USD / month"
360
+ hint="What one seat costs per month."
361
+ value={values.seatMonthlyUsd}
362
+ decimal
363
+ allowEmpty
364
+ step="any"
365
+ onChange={(seatMonthlyUsd) => edit({ seatMonthlyUsd })}
366
+ error={errors.seatMonthlyUsd}
367
+ state={state("seatMonthlyUsd")}
368
+ testIds={{ control: "cost-seat-monthly" }}
369
+ />
370
+ )}
371
+
372
+ <NumberField
373
+ label="Seats"
374
+ hint="How many people share the plan."
375
+ value={values.seats}
376
+ allowEmpty
377
+ onChange={(seats) => edit({ seats })}
378
+ error={errors.seats}
379
+ state={state("seats")}
380
+ testIds={{ control: "cost-seats" }}
381
+ />
382
+
383
+ <NumberField
384
+ label="Break after"
385
+ unit="min"
386
+ hint="Idle gaps longer than this don't count as active time. 1–120."
387
+ value={values.gapCapMinutes}
388
+ allowEmpty
389
+ onChange={(gapCapMinutes) => edit({ gapCapMinutes })}
390
+ error={errors.gapCapMinutes}
391
+ state={state("gapCapMinutes")}
392
+ testIds={{ control: "cost-gap-cap" }}
393
+ />
394
+ </div>
395
+ );
396
+ }
@@ -1,300 +1,11 @@
1
1
  /**
2
- * cost-estimator · CLIENT entry.
2
+ * cost-estimator · CLIENT entry (intentionally empty).
3
3
  *
4
- * Renders measured delivery telemetry: active steering hours per project, the
5
- * meter-equivalent spend, and — when a seat plan is configured — the ACTUAL
6
- * subscription cost plus the leverage between the two.
4
+ * Both claims (`CostView` command-route, `CostSettings` settings-section) load
5
+ * lazily from `./CostEstimator.tsx` via the manifest `module` field. Do NOT
6
+ * re-export them here: the registry generator rejects a main entry that also
7
+ * exports a lazy component.
7
8
  *
8
- * DISPLAY INVARIANT: the meter figure is labelled "meter-equivalent" wherever it
9
- * appears, and leverage is labelled leverage, never a saving. Presenting the
10
- * theoretical meter as cash out is the single easiest way to make an estimate
11
- * indefensible under scrutiny.
9
+ * See change: lazy-plugin-claim-modules.
12
10
  */
13
- import React, { useEffect, useState } from "react";
14
- import { usePluginConfig, usePluginSend } from "@blackbelt-technology/dashboard-plugin-runtime/context";
15
-
16
- interface Measured {
17
- sessions: number;
18
- activeHours: number;
19
- steeringDays: number;
20
- totalCost: number;
21
- costPerSteeringHour: number;
22
- costPerSteeringDay: number;
23
- contextFactor: number;
24
- revisionFactorLowerBound: number;
25
- outputShare: number;
26
- cacheReadShare: number;
27
- assistantPerHumanTurn: number;
28
- activeMonths: number;
29
- hoursPerMonth: number;
30
- meterPerMonth: number;
31
- unmeteredHourShare: number;
32
- }
33
-
34
- interface ProjectRow {
35
- project: string;
36
- sessions: number;
37
- activeHours: number;
38
- steeringDays: number;
39
- cost: number;
40
- costPerHour: number;
41
- }
42
-
43
- interface Subscription {
44
- monthlySeatCost: number;
45
- months: number;
46
- subscriptionCost: number;
47
- meterEquivalent: number;
48
- leverage: number;
49
- effectiveCostPerHour: number;
50
- meteredCostPerHour: number;
51
- }
52
-
53
- interface TelemetryPayload {
54
- ok: boolean;
55
- empty?: boolean;
56
- error?: string;
57
- measured: Measured | null;
58
- projects: ProjectRow[];
59
- subscription: Subscription | null;
60
- seatPlan?: string;
61
- seats?: number;
62
- }
63
-
64
- export interface CostEstimatorConfig {
65
- gapCapMinutes: number;
66
- hoursPerDay: number;
67
- seatPlan: string;
68
- seatMonthlyUsd: number;
69
- seats: number;
70
- }
71
-
72
- const num = (value: number, digits = 0) =>
73
- value.toLocaleString("en-US", { minimumFractionDigits: digits, maximumFractionDigits: digits });
74
-
75
- const cell: React.CSSProperties = { padding: "4px 10px", textAlign: "right", whiteSpace: "nowrap" };
76
- const label: React.CSSProperties = { ...cell, textAlign: "left" };
77
- const muted: React.CSSProperties = { fontSize: "11px", opacity: 0.65 };
78
-
79
- /** CostView — full-screen measured-cost view. Claimed on content-view + command-route. */
80
- export function CostView() {
81
- const [data, setData] = useState<TelemetryPayload | null>(null);
82
- const [failed, setFailed] = useState<string | null>(null);
83
-
84
- useEffect(() => {
85
- let cancelled = false;
86
- fetch("/api/cost-estimator/telemetry")
87
- .then((response) => {
88
- if (!response.ok) throw new Error(`HTTP ${response.status}`);
89
- return response.json() as Promise<TelemetryPayload>;
90
- })
91
- .then((payload) => {
92
- if (!cancelled) setData(payload);
93
- })
94
- .catch((error: unknown) => {
95
- if (!cancelled) setFailed(error instanceof Error ? error.message : String(error));
96
- });
97
- return () => {
98
- cancelled = true;
99
- };
100
- }, []);
101
-
102
- if (failed) return <div style={{ padding: 16 }}>Could not load cost telemetry: {failed}</div>;
103
- if (!data) return <div style={{ padding: 16 }}>Measuring sessions…</div>;
104
- if (!data.ok) return <div style={{ padding: 16 }}>Cost telemetry unavailable: {data.error}</div>;
105
- if (data.empty || !data.measured) return <div style={{ padding: 16 }}>No sessions measured yet.</div>;
106
-
107
- const m = data.measured;
108
- const sub = data.subscription;
109
-
110
- return (
111
- <div data-testid="cost-view" style={{ padding: 16, overflow: "auto", fontSize: 13 }}>
112
- <h2 style={{ margin: "0 0 4px" }}>Measured delivery cost</h2>
113
- <div style={muted}>
114
- {num(m.sessions)} sessions · {num(m.activeHours, 1)} active steering hours ({num(m.steeringDays, 1)} steering-days)
115
- · {m.activeMonths} active months · breaks over the configured gap are excluded
116
- </div>
117
-
118
- {sub ? (
119
- <section style={{ marginTop: 16 }}>
120
- <h3 style={{ margin: "0 0 4px" }}>Actual cost — subscription</h3>
121
- <table>
122
- <tbody>
123
- <tr>
124
- <td style={label}>Cash out ({data.seats}× {data.seatPlan}, {num(sub.months, 0)} mo)</td>
125
- <td style={{ ...cell, fontWeight: 600 }}>${num(sub.subscriptionCost, 2)}</td>
126
- </tr>
127
- <tr>
128
- <td style={label}>Effective per steering hour</td>
129
- <td style={cell}>${num(sub.effectiveCostPerHour, 2)}</td>
130
- </tr>
131
- <tr>
132
- <td style={label}>Meter-equivalent (theoretical, not paid)</td>
133
- <td style={{ ...cell, opacity: 0.7 }}>${num(sub.meterEquivalent, 2)}</td>
134
- </tr>
135
- <tr>
136
- <td style={label}>Subscription leverage</td>
137
- <td style={{ ...cell, fontWeight: 600 }}>{sub.leverage.toFixed(1)}×</td>
138
- </tr>
139
- </tbody>
140
- </table>
141
- <div style={{ ...muted, marginTop: 4 }}>
142
- {sub.leverage >= 1
143
- ? "Leverage is on-demand value the flat plan captured — not a saving to pass on as a discount."
144
- : "The plan costs more than metering at this volume; pay-as-you-go would be cheaper."}
145
- </div>
146
- </section>
147
- ) : (
148
- <section style={{ marginTop: 16 }}>
149
- <h3 style={{ margin: "0 0 4px" }}>Metered basis</h3>
150
- <div style={muted}>
151
- No seat plan configured, so costs below are billed meter figures. If capacity is actually bought on a
152
- subscription, set the plan in Settings — otherwise these numbers are theoretical.
153
- </div>
154
- </section>
155
- )}
156
-
157
- <section style={{ marginTop: 16 }}>
158
- <h3 style={{ margin: "0 0 4px" }}>Meter-equivalent rates</h3>
159
- <table>
160
- <tbody>
161
- <tr>
162
- <td style={label}>Per steering hour</td>
163
- <td style={cell}>${num(m.costPerSteeringHour, 2)}</td>
164
- </tr>
165
- <tr>
166
- <td style={label}>Per steering day</td>
167
- <td style={cell}>${num(m.costPerSteeringDay, 2)}</td>
168
- </tr>
169
- <tr>
170
- <td style={label}>Per active month</td>
171
- <td style={cell}>${num(m.meterPerMonth, 2)}</td>
172
- </tr>
173
- <tr>
174
- <td style={label}>Cache-read share of tokens</td>
175
- <td style={cell}>{(m.cacheReadShare * 100).toFixed(1)}%</td>
176
- </tr>
177
- <tr>
178
- <td style={label}>Assistant turns per human turn</td>
179
- <td style={cell}>{m.assistantPerHumanTurn.toFixed(1)} : 1</td>
180
- </tr>
181
- </tbody>
182
- </table>
183
- {m.unmeteredHourShare > 0.01 && (
184
- <div style={{ ...muted, marginTop: 4 }}>
185
- {(m.unmeteredHourShare * 100).toFixed(1)}% of hours ran on models the meter priced at $0 (routed or
186
- subscription-billed) — the rates above are understated by that much.
187
- </div>
188
- )}
189
- </section>
190
-
191
- <section style={{ marginTop: 16 }}>
192
- <h3 style={{ margin: "0 0 4px" }}>By project</h3>
193
- <table>
194
- <thead>
195
- <tr>
196
- <th style={label}>Project</th>
197
- <th style={cell}>Sessions</th>
198
- <th style={cell}>Active h</th>
199
- <th style={cell}>Steering days</th>
200
- <th style={cell}>Meter $</th>
201
- <th style={cell}>$/h</th>
202
- </tr>
203
- </thead>
204
- <tbody>
205
- {data.projects.slice(0, 25).map((row) => (
206
- <tr key={row.project}>
207
- <td style={label}>{row.project}</td>
208
- <td style={cell}>{num(row.sessions)}</td>
209
- <td style={cell}>{num(row.activeHours, 1)}</td>
210
- <td style={cell}>{num(row.steeringDays, 1)}</td>
211
- <td style={cell}>{num(row.cost, 0)}</td>
212
- <td style={cell}>{num(row.costPerHour, 2)}</td>
213
- </tr>
214
- ))}
215
- </tbody>
216
- </table>
217
- </section>
218
-
219
- <div style={{ ...muted, marginTop: 16 }}>
220
- Active time counts hours where a human was engaged with the session. It is not billable-hours truth, and it does
221
- not capture work done outside the agent.
222
- </div>
223
- </div>
224
- );
225
- }
226
-
227
- /** CostSettings — seat plan configuration. Claimed on settings-section. */
228
- export function CostSettings() {
229
- const config = usePluginConfig<CostEstimatorConfig>();
230
- const send = usePluginSend();
231
-
232
- const write = (partial: Partial<CostEstimatorConfig>) =>
233
- send({ type: "plugin_config_write", id: "cost-estimator", config: { ...config, ...partial } });
234
-
235
- return (
236
- <div data-testid="cost-settings" style={{ fontSize: 12 }}>
237
- <div style={{ ...muted, marginBottom: 6 }}>
238
- Session cost is recorded as a metered API price. If capacity is bought on a subscription, set the plan here so
239
- the dashboard reports real cash rather than a theoretical meter.
240
- </div>
241
-
242
- <label style={{ display: "block", marginBottom: 6 }}>
243
- Seat plan{" "}
244
- <select
245
- data-testid="cost-seat-plan"
246
- value={config.seatPlan ?? "anthropic-max-20x"}
247
- onChange={(event) => write({ seatPlan: event.target.value })}
248
- >
249
- <option value="metered">Metered (pay-as-you-go)</option>
250
- <option value="anthropic-pro">Claude Pro — $20</option>
251
- <option value="anthropic-max-5x">Claude Max 5× — $100</option>
252
- <option value="anthropic-max-20x">Claude Max 20× — $200</option>
253
- <option value="openai-plus">ChatGPT Plus — $20</option>
254
- <option value="openai-pro-5x">ChatGPT Pro 5× — $100</option>
255
- <option value="openai-pro-20x">ChatGPT Pro 20× — $200</option>
256
- <option value="glm-lite">GLM Coding Lite — $18</option>
257
- <option value="glm-pro">GLM Coding Pro — $72</option>
258
- <option value="glm-max">GLM Coding Max — $160</option>
259
- <option value="custom">Custom…</option>
260
- </select>
261
- </label>
262
-
263
- {config.seatPlan === "custom" && (
264
- <label style={{ display: "block", marginBottom: 6 }}>
265
- USD per seat per month{" "}
266
- <input
267
- data-testid="cost-seat-monthly"
268
- type="number"
269
- min={0}
270
- value={config.seatMonthlyUsd ?? 0}
271
- onChange={(event) => write({ seatMonthlyUsd: Number(event.target.value) })}
272
- />
273
- </label>
274
- )}
275
-
276
- <label style={{ display: "block", marginBottom: 6 }}>
277
- Seats{" "}
278
- <input
279
- data-testid="cost-seats"
280
- type="number"
281
- min={1}
282
- value={config.seats ?? 1}
283
- onChange={(event) => write({ seats: Number(event.target.value) })}
284
- />
285
- </label>
286
-
287
- <label style={{ display: "block" }}>
288
- Break threshold (minutes){" "}
289
- <input
290
- data-testid="cost-gap-cap"
291
- type="number"
292
- min={1}
293
- max={120}
294
- value={config.gapCapMinutes ?? 15}
295
- onChange={(event) => write({ gapCapMinutes: Number(event.target.value) })}
296
- />
297
- </label>
298
- </div>
299
- );
300
- }
11
+ export {};