agentwrangler 0.1.1-next.bca85ea → 0.1.1-next.fbbbe7f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -82
- package/dist/apply/jobs.js +3 -13
- package/dist/daemon/http.js +0 -2
- package/dist/daemon/index.js +6 -8
- package/dist/daemon/router.js +6 -63
- package/dist/detector/context-history-retention.js +0 -49
- package/dist/detector/detectors/d10_catalog_footprint.js +2 -2
- package/dist/detector/detectors/d1_ctx_always_loaded.js +9 -9
- package/dist/detector/detectors/d2_session_long_full_context.js +2 -2
- package/dist/detector/detectors/d4_model_mismatch.js +3 -3
- package/dist/detector/detectors/d6_tool_result_bloat.js +1 -1
- package/dist/detector/detectors/d7_loop_retry_waste.js +1 -1
- package/dist/detector/detectors/d8_cache_write_churn.js +2 -2
- package/dist/detector/detectors/d9_idle_background_session.js +1 -1
- package/dist/detector/measurement.js +3 -14
- package/dist/hook/precompact-checkpoint-hook.mjs +13 -26
- package/dist/ingest/pricing.js +0 -15
- package/dist/query/api/cost-per-success.js +1 -13
- package/dist/query/api/delivery.js +3 -25
- package/dist/query/api/effectiveness.js +5 -30
- package/dist/query/api/efficiency-headroom.js +14 -12
- package/dist/query/api/outcomes.js +1 -2
- package/dist/query/api/overview.js +6 -90
- package/dist/query/api/recommendations-ledger.js +14 -9
- package/dist/query/api/recommendations.js +1 -21
- package/dist/query/settings-store.js +0 -4
- package/dist/query/spend.js +2 -64
- package/dist/ui/assets/{BarChart-CIjCNfbI.js → BarChart-p1usctxJ.js} +3 -3
- package/dist/ui/assets/BriefsPage-CneqLVGC.js +2 -0
- package/dist/ui/assets/CacheWriteSpikesChart-zNRZbzy9.js +1 -0
- package/dist/ui/assets/Chip-Bu6udQGq.js +1 -0
- package/dist/ui/assets/ComposedChart-8D5E-Po_.js +1 -0
- package/dist/ui/assets/{EmptyState-B8vpug3_.js → EmptyState-CvQeJjjG.js} +1 -1
- package/dist/ui/assets/FlavorDecomposition-xcMLA50f.js +1 -0
- package/dist/ui/assets/FrictionCell-OafGLGxT.js +2 -0
- package/dist/ui/assets/GlossaryPage-BmOP3Syj.js +1 -0
- package/dist/ui/assets/HotSessionsPage-FoxuuDLF.js +1 -0
- package/dist/ui/assets/{InfoTip-CL8RC4vz.js → InfoTip-Dx7BHpBu.js} +1 -1
- package/dist/ui/assets/{Legend-CB7sqqJH.js → Legend--q6-rQGk.js} +3 -3
- package/dist/ui/assets/{Line-B9XY30uT.js → Line-DzVtUwF4.js} +1 -1
- package/dist/ui/assets/OverviewPage-BjSQYNvS.js +2 -0
- package/dist/ui/assets/RecommendationsPage-CRTpzcHs.js +2 -0
- package/dist/ui/assets/{Scatter-BSWm_yIZ.js → Scatter-Cr_hCkjG.js} +1 -1
- package/dist/ui/assets/SessionDetailPage-Dd3u8kVI.js +1 -0
- package/dist/ui/assets/SettingsPage-BPVQyjlc.js +25 -0
- package/dist/ui/assets/{Skeleton-Dp_m79B8.js → Skeleton-CcD61x7q.js} +1 -1
- package/dist/ui/assets/SpendPercentileChip-BaQhJQAn.js +1 -0
- package/dist/ui/assets/TrendChart-Baz3GGgE.js +1 -0
- package/dist/ui/assets/WorkspaceDetailPage-yk4z_EtQ.js +1 -0
- package/dist/ui/assets/WorkspacesPage-BDtclXJP.js +1 -0
- package/dist/ui/assets/{CartesianChart-DEnDOGKj.js → chart-theme-JH5aQymO.js} +36 -36
- package/dist/ui/assets/graphicalItemSelectors-CCbl8AKC.js +1 -0
- package/dist/ui/assets/{index-DhFiA8Ch.js → index-DRhoA51c.js} +10 -10
- package/dist/ui/assets/{index-D_IJsvkJ.css → index-SrfNUeBZ.css} +1 -1
- package/dist/ui/assets/{prompt-templates-CVzMex9L.js → prompt-templates-DhR4Qoy9.js} +4 -4
- package/dist/ui/assets/{useExperimentalActions-aI00AFZv.js → useExperimentalActions-BPDdswCN.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +1 -1
- package/dist/daemon/effect-pass.js +0 -24
- package/dist/db/migrations/018_effect_cycles.sql +0 -109
- package/dist/effects/api-contract.js +0 -1
- package/dist/effects/engine.js +0 -574
- package/dist/effects/gate.js +0 -2
- package/dist/effects/index.js +0 -5
- package/dist/effects/legacy.js +0 -28
- package/dist/effects/registry.js +0 -152
- package/dist/effects/sql-observer.js +0 -238
- package/dist/effects/store.js +0 -181
- package/dist/effects/types.js +0 -2
- package/dist/query/api/effect-service.js +0 -308
- package/dist/query/api/esf-observations.js +0 -254
- package/dist/ui/assets/BriefsPage-DIU8iFjV.js +0 -2
- package/dist/ui/assets/CacheWriteSpikesChart-1Nfnf7OX.js +0 -1
- package/dist/ui/assets/Chip-s-32Dh3o.js +0 -1
- package/dist/ui/assets/ComposedChart-DUw8Y79v.js +0 -1
- package/dist/ui/assets/FlavorDecomposition-CkHX3M-U.js +0 -1
- package/dist/ui/assets/FrictionCell-X75fKRBK.js +0 -2
- package/dist/ui/assets/GlossaryPage-D1tYumqL.js +0 -1
- package/dist/ui/assets/HotSessionsPage-8HlRe0VB.js +0 -1
- package/dist/ui/assets/OverviewPage-DL4joBBE.js +0 -2
- package/dist/ui/assets/RecommendationsPage-NkfH17eB.js +0 -2
- package/dist/ui/assets/SessionDetailPage-Ceqt7poO.js +0 -1
- package/dist/ui/assets/SettingsPage-ZK4ii5h_.js +0 -25
- package/dist/ui/assets/SpendPercentileChip-CzY6h1gP.js +0 -1
- package/dist/ui/assets/TrendChart-BSLwlBiq.js +0 -1
- package/dist/ui/assets/WorkspaceDetailPage-DFOdEB39.js +0 -1
- package/dist/ui/assets/WorkspacesPage-Doct6meK.js +0 -1
- package/dist/ui/assets/chart-theme-DYgw_Tac.js +0 -1
- package/dist/ui/assets/graphicalItemSelectors-0-Ue_y1f.js +0 -1
- package/dist/ui/assets/rec-sessions-ggz9MYgP.js +0 -1
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
* windows/cutoffs, maps rows to the frozen DTOs, and attaches the envelope.
|
|
11
11
|
*/
|
|
12
12
|
import { loadConfig } from "../../daemon/config.js";
|
|
13
|
-
import { PREMIUM_MODEL_SQL, modelInputListPrice } from "../../ingest/pricing.js";
|
|
14
13
|
import { getQueryDb } from "../db-context.js";
|
|
15
14
|
import { forecastFromDb } from "../forecast.js";
|
|
16
15
|
import { contextPerTurnByModel, globalSpend, hasStaleClaim, liveSessionCount, liveSessions, spendByWorkspace, } from "../spend.js";
|
|
@@ -109,7 +108,7 @@ function makeResponse(data, o) {
|
|
|
109
108
|
note: "",
|
|
110
109
|
...o.qualification,
|
|
111
110
|
},
|
|
112
|
-
metric_definition_version:
|
|
111
|
+
metric_definition_version: "observe-1",
|
|
113
112
|
claim_kind: o.claim_kind,
|
|
114
113
|
drilldown_ids: o.drilldown_ids ?? {},
|
|
115
114
|
},
|
|
@@ -168,20 +167,14 @@ export function getGlobalOverview(filters) {
|
|
|
168
167
|
// counts sum to `turns_total`, NOT the reconciled `turns`. This is the
|
|
169
168
|
// deliberate spend-vs-context difference (Data Model §2/§3) — a consumer must
|
|
170
169
|
// not expect model_mix turns to reconcile with the reconciled `turns` figure.
|
|
171
|
-
|
|
172
|
-
// premium models matter most per turn, and a price-stable order keeps the
|
|
173
|
-
// index-keyed card colors from shuffling as usage volume shifts.
|
|
174
|
-
const ctxSorted = [...ctx].sort((a, b) => modelInputListPrice(b.model) - modelInputListPrice(a.model) ||
|
|
175
|
-
b.n - a.n ||
|
|
176
|
-
a.model.localeCompare(b.model));
|
|
177
|
-
const context_per_turn = ctxSorted.map((r) => ({
|
|
170
|
+
const context_per_turn = ctx.map((r) => ({
|
|
178
171
|
model: r.model,
|
|
179
172
|
n: r.n,
|
|
180
173
|
avg_context_per_turn: r.avg_context_per_turn,
|
|
181
174
|
avg_output_per_turn: r.avg_output_per_turn,
|
|
182
175
|
usd_per_turn: r.usd_per_turn,
|
|
183
176
|
}));
|
|
184
|
-
const model_mix =
|
|
177
|
+
const model_mix = ctx.map((r) => ({ model: r.model, turns: r.n }));
|
|
185
178
|
const data = {
|
|
186
179
|
cost_equiv_u: g.cost_equiv_u,
|
|
187
180
|
turns: g.turns,
|
|
@@ -231,9 +224,7 @@ export function listWorkspaces(filters) {
|
|
|
231
224
|
+ cache_write_5m + cache_write_1h + cache_write_other)
|
|
232
225
|
ELSE NULL END AS cache_write_pct,
|
|
233
226
|
CAST(SUM(CASE WHEN model LIKE '%opus%' THEN 1 ELSE 0 END) AS REAL)
|
|
234
|
-
/ NULLIF(COUNT(*), 0) AS opus_pct
|
|
235
|
-
CAST(SUM(CASE WHEN ${PREMIUM_MODEL_SQL} THEN 1 ELSE 0 END) AS REAL)
|
|
236
|
-
/ NULLIF(COUNT(*), 0) AS premium_pct
|
|
227
|
+
/ NULLIF(COUNT(*), 0) AS opus_pct
|
|
237
228
|
FROM turns WHERE ts >= ? AND ts < ?
|
|
238
229
|
GROUP BY workspace_id`)
|
|
239
230
|
.all(from, to));
|
|
@@ -254,7 +245,6 @@ export function listWorkspaces(filters) {
|
|
|
254
245
|
avg_context_per_turn: agg?.avg_context_per_turn ?? null,
|
|
255
246
|
cache_write_pct: agg?.cache_write_pct ?? null,
|
|
256
247
|
opus_pct: agg?.opus_pct ?? null,
|
|
257
|
-
premium_pct: agg?.premium_pct ?? null,
|
|
258
248
|
};
|
|
259
249
|
});
|
|
260
250
|
return makeResponse({ items, next_cursor: null }, {
|
|
@@ -352,30 +342,7 @@ export function listSessions(workspace_id, filters, cursor) {
|
|
|
352
342
|
(SELECT COUNT(*) FROM tool_events te
|
|
353
343
|
WHERE te.session_id = s.session_id AND te.exit_class = 'ERROR') AS tool_error_count,
|
|
354
344
|
(SELECT COUNT(*) FROM tool_events te
|
|
355
|
-
WHERE te.session_id = s.session_id AND te.
|
|
356
|
-
(SELECT COUNT(*) FROM tool_events te
|
|
357
|
-
WHERE te.session_id = s.session_id AND te.exit_class = 'ERROR'
|
|
358
|
-
AND te.result_bytes IS NOT NULL) AS tool_completed_error_count,
|
|
359
|
-
(SELECT COUNT(*) FROM tool_events te
|
|
360
|
-
WHERE te.session_id = s.session_id AND te.exit_class = 'TEST_FAIL'
|
|
361
|
-
AND EXISTS (SELECT 1 FROM tool_event_metadata metadata
|
|
362
|
-
WHERE metadata.event_id = te.event_id AND metadata.is_test_command = 1)) AS test_fail_count,
|
|
363
|
-
(SELECT COUNT(*) FROM tool_events te JOIN tool_event_metadata metadata ON metadata.event_id = te.event_id
|
|
364
|
-
WHERE te.session_id = s.session_id AND metadata.is_test_command = 1 AND te.result_bytes IS NOT NULL) AS test_completed_count,
|
|
365
|
-
(SELECT COUNT(*) FROM tool_events te JOIN tool_event_metadata metadata ON metadata.event_id = te.event_id
|
|
366
|
-
WHERE te.session_id = s.session_id AND metadata.is_test_command = 1 AND te.exit_class = 'OK' AND te.result_bytes IS NOT NULL) AS test_pass_count,
|
|
367
|
-
CASE WHEN NOT EXISTS (SELECT 1 FROM tool_events observed JOIN tool_event_metadata observed_metadata ON observed_metadata.event_id = observed.event_id
|
|
368
|
-
WHERE observed.session_id = s.session_id AND observed_metadata.is_test_command = 1 AND observed.result_bytes IS NOT NULL)
|
|
369
|
-
THEN 'NO_TEST_OUTCOMES'
|
|
370
|
-
WHEN NOT EXISTS (SELECT 1 FROM tool_events failed JOIN tool_event_metadata failed_metadata ON failed_metadata.event_id = failed.event_id
|
|
371
|
-
WHERE failed.session_id = s.session_id AND failed_metadata.is_test_command = 1 AND failed.exit_class = 'TEST_FAIL' AND failed.result_bytes IS NOT NULL)
|
|
372
|
-
THEN 'NO_FAILURES_OBSERVED'
|
|
373
|
-
WHEN EXISTS (SELECT 1 FROM tool_events passed JOIN tool_event_metadata passed_metadata ON passed_metadata.event_id = passed.event_id
|
|
374
|
-
WHERE passed.session_id = s.session_id AND passed_metadata.is_test_command = 1 AND passed.exit_class = 'OK' AND passed.result_bytes IS NOT NULL
|
|
375
|
-
AND EXISTS (SELECT 1 FROM tool_events failed_before JOIN tool_event_metadata failed_before_metadata ON failed_before_metadata.event_id = failed_before.event_id
|
|
376
|
-
WHERE failed_before.session_id = s.session_id AND failed_before_metadata.is_test_command = 1
|
|
377
|
-
AND failed_before.exit_class = 'TEST_FAIL' AND failed_before.result_bytes IS NOT NULL AND failed_before.ts < passed.ts))
|
|
378
|
-
THEN 'FAILED_THEN_PASSED' ELSE 'FAILURES_OBSERVED' END AS test_outcome,
|
|
345
|
+
WHERE te.session_id = s.session_id AND te.exit_class = 'TEST_FAIL') AS test_fail_count,
|
|
379
346
|
s.gap_median_s, s.gap_p90_s, s.long_gap_count, s.gap_n,
|
|
380
347
|
CASE WHEN EXISTS (
|
|
381
348
|
SELECT 1 FROM tool_events te
|
|
@@ -390,11 +357,6 @@ export function listSessions(workspace_id, filters, cursor) {
|
|
|
390
357
|
)
|
|
391
358
|
) ELSE NULL END AS turns_to_first_commit,
|
|
392
359
|
CASE WHEN s.state = 'RECONCILED' AND s.user_turn_count >= 10
|
|
393
|
-
AND EXISTS (
|
|
394
|
-
SELECT 1 FROM tool_events te
|
|
395
|
-
WHERE te.session_id = s.session_id
|
|
396
|
-
AND te.tool_name IN ('Bash', 'Write', 'Edit', 'NotebookEdit')
|
|
397
|
-
)
|
|
398
360
|
AND NOT EXISTS (
|
|
399
361
|
SELECT 1 FROM tool_events te
|
|
400
362
|
WHERE te.session_id = s.session_id AND te.commit_sha IS NOT NULL
|
|
@@ -420,18 +382,9 @@ export function listSessions(workspace_id, filters, cursor) {
|
|
|
420
382
|
compaction_count: r.compaction_count,
|
|
421
383
|
api_error_count: r.api_error_count,
|
|
422
384
|
interrupt_count: r.interrupt_count,
|
|
423
|
-
interrupts_supported: false,
|
|
424
|
-
api_error_eligible_request_count: null,
|
|
425
|
-
api_error_rate: null,
|
|
426
385
|
user_turn_count: r.user_turn_count,
|
|
427
386
|
tool_error_count: r.tool_error_count,
|
|
428
|
-
tool_completed_count: r.tool_completed_count,
|
|
429
|
-
tool_completed_error_count: r.tool_completed_error_count,
|
|
430
|
-
tool_error_rate: r.tool_completed_count > 0 ? r.tool_completed_error_count / r.tool_completed_count : null,
|
|
431
387
|
test_fail_count: r.test_fail_count,
|
|
432
|
-
test_completed_count: r.test_completed_count,
|
|
433
|
-
test_pass_count: r.test_pass_count,
|
|
434
|
-
test_outcome: r.test_outcome,
|
|
435
388
|
gap_median_s: r.gap_median_s,
|
|
436
389
|
gap_p90_s: r.gap_p90_s,
|
|
437
390
|
long_gap_count: r.long_gap_count,
|
|
@@ -440,7 +393,6 @@ export function listSessions(workspace_id, filters, cursor) {
|
|
|
440
393
|
deep_abandoned: r.deep_abandoned_int !== 0,
|
|
441
394
|
}));
|
|
442
395
|
return makeResponse({ items, next_cursor: nextCursor(offset, limit, total) }, {
|
|
443
|
-
metric_definition_version: "esf-1",
|
|
444
396
|
n: items.length,
|
|
445
397
|
window,
|
|
446
398
|
claim_kind: "LIST_EQUIV",
|
|
@@ -458,30 +410,7 @@ export function getSession(id) {
|
|
|
458
410
|
(SELECT COUNT(*) FROM tool_events te
|
|
459
411
|
WHERE te.session_id = s.session_id AND te.exit_class = 'ERROR') AS tool_error_count,
|
|
460
412
|
(SELECT COUNT(*) FROM tool_events te
|
|
461
|
-
WHERE te.session_id = s.session_id AND te.
|
|
462
|
-
(SELECT COUNT(*) FROM tool_events te
|
|
463
|
-
WHERE te.session_id = s.session_id AND te.exit_class = 'ERROR'
|
|
464
|
-
AND te.result_bytes IS NOT NULL) AS tool_completed_error_count,
|
|
465
|
-
(SELECT COUNT(*) FROM tool_events te
|
|
466
|
-
WHERE te.session_id = s.session_id AND te.exit_class = 'TEST_FAIL'
|
|
467
|
-
AND EXISTS (SELECT 1 FROM tool_event_metadata metadata
|
|
468
|
-
WHERE metadata.event_id = te.event_id AND metadata.is_test_command = 1)) AS test_fail_count,
|
|
469
|
-
(SELECT COUNT(*) FROM tool_events te JOIN tool_event_metadata metadata ON metadata.event_id = te.event_id
|
|
470
|
-
WHERE te.session_id = s.session_id AND metadata.is_test_command = 1 AND te.result_bytes IS NOT NULL) AS test_completed_count,
|
|
471
|
-
(SELECT COUNT(*) FROM tool_events te JOIN tool_event_metadata metadata ON metadata.event_id = te.event_id
|
|
472
|
-
WHERE te.session_id = s.session_id AND metadata.is_test_command = 1 AND te.exit_class = 'OK' AND te.result_bytes IS NOT NULL) AS test_pass_count,
|
|
473
|
-
CASE WHEN NOT EXISTS (SELECT 1 FROM tool_events observed JOIN tool_event_metadata observed_metadata ON observed_metadata.event_id = observed.event_id
|
|
474
|
-
WHERE observed.session_id = s.session_id AND observed_metadata.is_test_command = 1 AND observed.result_bytes IS NOT NULL)
|
|
475
|
-
THEN 'NO_TEST_OUTCOMES'
|
|
476
|
-
WHEN NOT EXISTS (SELECT 1 FROM tool_events failed JOIN tool_event_metadata failed_metadata ON failed_metadata.event_id = failed.event_id
|
|
477
|
-
WHERE failed.session_id = s.session_id AND failed_metadata.is_test_command = 1 AND failed.exit_class = 'TEST_FAIL' AND failed.result_bytes IS NOT NULL)
|
|
478
|
-
THEN 'NO_FAILURES_OBSERVED'
|
|
479
|
-
WHEN EXISTS (SELECT 1 FROM tool_events passed JOIN tool_event_metadata passed_metadata ON passed_metadata.event_id = passed.event_id
|
|
480
|
-
WHERE passed.session_id = s.session_id AND passed_metadata.is_test_command = 1 AND passed.exit_class = 'OK' AND passed.result_bytes IS NOT NULL
|
|
481
|
-
AND EXISTS (SELECT 1 FROM tool_events failed_before JOIN tool_event_metadata failed_before_metadata ON failed_before_metadata.event_id = failed_before.event_id
|
|
482
|
-
WHERE failed_before.session_id = s.session_id AND failed_before_metadata.is_test_command = 1
|
|
483
|
-
AND failed_before.exit_class = 'TEST_FAIL' AND failed_before.result_bytes IS NOT NULL AND failed_before.ts < passed.ts))
|
|
484
|
-
THEN 'FAILED_THEN_PASSED' ELSE 'FAILURES_OBSERVED' END AS test_outcome,
|
|
413
|
+
WHERE te.session_id = s.session_id AND te.exit_class = 'TEST_FAIL') AS test_fail_count,
|
|
485
414
|
s.gap_median_s, s.gap_p90_s, s.long_gap_count, s.gap_n
|
|
486
415
|
FROM sessions s JOIN workspaces w USING (workspace_id)
|
|
487
416
|
WHERE s.session_id = ?`)
|
|
@@ -489,7 +418,6 @@ export function getSession(id) {
|
|
|
489
418
|
const window = resolveWindow({});
|
|
490
419
|
if (row === undefined) {
|
|
491
420
|
return makeResponse(null, {
|
|
492
|
-
metric_definition_version: "esf-1",
|
|
493
421
|
n: 0,
|
|
494
422
|
window,
|
|
495
423
|
claim_kind: "N_A",
|
|
@@ -513,20 +441,9 @@ export function getSession(id) {
|
|
|
513
441
|
compaction_count: row.compaction_count,
|
|
514
442
|
api_error_count: row.api_error_count,
|
|
515
443
|
interrupt_count: row.interrupt_count,
|
|
516
|
-
interrupts_supported: false,
|
|
517
|
-
api_error_eligible_request_count: null,
|
|
518
|
-
api_error_rate: null,
|
|
519
444
|
user_turn_count: row.user_turn_count,
|
|
520
445
|
tool_error_count: row.tool_error_count,
|
|
521
|
-
tool_completed_count: row.tool_completed_count,
|
|
522
|
-
tool_completed_error_count: row.tool_completed_error_count,
|
|
523
|
-
tool_error_rate: row.tool_completed_count > 0
|
|
524
|
-
? row.tool_completed_error_count / row.tool_completed_count
|
|
525
|
-
: null,
|
|
526
446
|
test_fail_count: row.test_fail_count,
|
|
527
|
-
test_completed_count: row.test_completed_count,
|
|
528
|
-
test_pass_count: row.test_pass_count,
|
|
529
|
-
test_outcome: row.test_outcome,
|
|
530
447
|
gap_median_s: row.gap_median_s,
|
|
531
448
|
gap_p90_s: row.gap_p90_s,
|
|
532
449
|
long_gap_count: row.long_gap_count,
|
|
@@ -534,7 +451,6 @@ export function getSession(id) {
|
|
|
534
451
|
...delivery,
|
|
535
452
|
};
|
|
536
453
|
return makeResponse(data, {
|
|
537
|
-
metric_definition_version: "esf-1",
|
|
538
454
|
n: 1,
|
|
539
455
|
window,
|
|
540
456
|
claim_kind: "LIST_EQUIV",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
import { resolveCapReadCoeff } from "../cap-weighted.js";
|
|
18
18
|
import { getQueryDb } from "../db-context.js";
|
|
19
19
|
import { buildResponse } from "../envelope.js";
|
|
20
|
-
import { capabilityForRecommendation, latestEffectCycle } from "./effect-service.js";
|
|
21
20
|
const CONFOUND_WINDOW_MS = 86_400_000; // ±1 day
|
|
22
21
|
function qualificationFor(row, detectorId, targetMetric) {
|
|
23
22
|
const isD2 = detectorId === "D2" || targetMetric.startsWith("CACHE_READ_TOKENS_PER_WK");
|
|
@@ -59,11 +58,19 @@ export function listLedger(scope) {
|
|
|
59
58
|
AND adopted_at IS NOT NULL
|
|
60
59
|
ORDER BY adopted_at DESC, rec_id ASC`)
|
|
61
60
|
.all());
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
const effectRows = db
|
|
62
|
+
.prepare(`SELECT rec_id, measured_at, before_from, before_to, after_from, after_to,
|
|
63
|
+
before_value, after_value, before_n, after_n, delta_pct, verdict
|
|
64
|
+
FROM recommendation_effects`)
|
|
65
|
+
.all();
|
|
66
|
+
const effectsByRec = new Map();
|
|
67
|
+
for (const e of effectRows) {
|
|
68
|
+
const list = effectsByRec.get(e.rec_id);
|
|
69
|
+
if (list !== undefined)
|
|
70
|
+
list.push(e);
|
|
71
|
+
else
|
|
72
|
+
effectsByRec.set(e.rec_id, [e]);
|
|
73
|
+
}
|
|
67
74
|
// Confounded-window flag: another ADOPTED+ rec within ±86400s of this adoption.
|
|
68
75
|
const adoptedTimes = recRows.map((r) => ({
|
|
69
76
|
recId: r.rec_id,
|
|
@@ -76,7 +83,7 @@ export function listLedger(scope) {
|
|
|
76
83
|
adoptedTimes.some((o) => o.recId !== r.rec_id &&
|
|
77
84
|
!Number.isNaN(o.ms) &&
|
|
78
85
|
Math.abs(o.ms - self.ms) <= CONFOUND_WINDOW_MS);
|
|
79
|
-
const effects =
|
|
86
|
+
const effects = (effectsByRec.get(r.rec_id) ?? []).map((e) => ({
|
|
80
87
|
...e,
|
|
81
88
|
qualification: qualificationFor(e, r.detector_id ?? "", r.target_metric),
|
|
82
89
|
}));
|
|
@@ -92,8 +99,6 @@ export function listLedger(scope) {
|
|
|
92
99
|
// never summed with the realized after_value / delta_pct fields.
|
|
93
100
|
modeled_cap_weighted_u_per_wk: r.modeled_savings_u_per_wk === null ? null : r.modeled_savings_u_per_wk * coeff,
|
|
94
101
|
effects,
|
|
95
|
-
effect_capability: capabilityForRecommendation(db, r.rec_id),
|
|
96
|
-
effect_cycle: latestEffectCycle(db, r.rec_id),
|
|
97
102
|
confounded_window: confounded,
|
|
98
103
|
};
|
|
99
104
|
});
|
|
@@ -11,10 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { getDetectorStatuses } from "../../detector/index.js";
|
|
13
13
|
import { AFTER_WINDOW_DAYS, isWarningClass, snapshotBeforeValue, } from "../../detector/measurement.js";
|
|
14
|
-
import { ESF_EFFECT_WRITER_ENABLED } from "../../effects/gate.js";
|
|
15
14
|
import { getQueryDb } from "../db-context.js";
|
|
16
15
|
import { buildResponse } from "../envelope.js";
|
|
17
|
-
import { EffectRequestError, capabilityForRecommendation, latestEffectCycle, trackCompletedChange, trackMachineConfirmedChange, } from "./effect-service.js";
|
|
18
16
|
/** Modeled values below $1/week are useful as evidence, but too small for a top-level card. */
|
|
19
17
|
export const ACTIVE_RECOMMENDATION_DE_MINIMIS_FLOOR_U = 1_000_000;
|
|
20
18
|
export const MINOR_ITEMS_GROUP_ID = "MINOR_ITEMS";
|
|
@@ -224,8 +222,6 @@ function toCard(r, sessionsPerWeek) {
|
|
|
224
222
|
cross_workspace: r.scope_workspace_id === null,
|
|
225
223
|
workspace_multiplier,
|
|
226
224
|
file_ref: typeof evidence.file_ref === "string" ? evidence.file_ref : null,
|
|
227
|
-
effect_capability: capabilityForRecommendation(getQueryDb(), r.rec_id),
|
|
228
|
-
effect_cycle: latestEffectCycle(getQueryDb(), r.rec_id),
|
|
229
225
|
};
|
|
230
226
|
}
|
|
231
227
|
/**
|
|
@@ -341,7 +337,7 @@ export function dismissRecommendation(rec_id, nowMs = Date.now(), dismissedUntil
|
|
|
341
337
|
* before_value = NULL and MEASURING will attempt the delta at close time.
|
|
342
338
|
* nowMs is injectable for deterministic tests; defaults to Date.now().
|
|
343
339
|
*/
|
|
344
|
-
export function adoptRecommendation(rec_id, nowMs = Date.now()
|
|
340
|
+
export function adoptRecommendation(rec_id, nowMs = Date.now()) {
|
|
345
341
|
const db = getQueryDb();
|
|
346
342
|
const adoptedAt = new Date(nowMs).toISOString();
|
|
347
343
|
const afterTo = new Date(nowMs + AFTER_WINDOW_DAYS * MS_PER_DAY).toISOString();
|
|
@@ -350,22 +346,6 @@ export function adoptRecommendation(rec_id, nowMs = Date.now(), options) {
|
|
|
350
346
|
.prepare(`SELECT rec_id, detector_id, category, scope_workspace_id, evidence_json, target_metric, state
|
|
351
347
|
FROM recommendations WHERE rec_id = ?`)
|
|
352
348
|
.get(rec_id);
|
|
353
|
-
if (ESF_EFFECT_WRITER_ENABLED) {
|
|
354
|
-
if (rec === undefined || rec.state !== "PROPOSED")
|
|
355
|
-
throw new EffectRequestError(400, `rec ${rec_id} not found or not in PROPOSED state`);
|
|
356
|
-
if (!isWarningClass(rec)) {
|
|
357
|
-
if (!options?.completedChange && !options?.machineConfirmed)
|
|
358
|
-
throw new EffectRequestError(400, "Confirm that the change is complete before tracking.");
|
|
359
|
-
const result = options?.machineConfirmed
|
|
360
|
-
? trackMachineConfirmedChange(db, rec_id, new Date(nowMs), options.actionRevision)
|
|
361
|
-
: trackCompletedChange(db, { rec_id, idempotency_key: `legacy-adopt:${rec_id}`, completed_change: true }, new Date(nowMs));
|
|
362
|
-
if (!result.supported && !options?.machineConfirmed)
|
|
363
|
-
throw new EffectRequestError(400, "Manual measurement: no supported effect handler.");
|
|
364
|
-
}
|
|
365
|
-
// Compatibility state describes adoption only. Versioned cycles own measurement truth.
|
|
366
|
-
db.prepare("UPDATE recommendations SET state='ADOPTED',adopted_at=? WHERE rec_id=?").run(adoptedAt, rec_id);
|
|
367
|
-
return buildResponse({ ok: true }, { claim_kind: "EXPERIMENTAL", n: 1, drilldown_ids: {} });
|
|
368
|
-
}
|
|
369
349
|
const tx = db.transaction(() => {
|
|
370
350
|
const result = db
|
|
371
351
|
.prepare(`UPDATE recommendations SET state='ADOPTED', adopted_at=?
|
|
@@ -390,10 +390,6 @@ export async function calibrateLimit(db, reader = fetchOAuthUsage) {
|
|
|
390
390
|
export const RESET_DATA_TABLES = [
|
|
391
391
|
"reports",
|
|
392
392
|
"apply_jobs",
|
|
393
|
-
"effect_mutation_keys",
|
|
394
|
-
"effect_rollback_operations",
|
|
395
|
-
"effect_guardrail_results",
|
|
396
|
-
"effect_cycles",
|
|
397
393
|
"recommendation_effects",
|
|
398
394
|
"recommendations",
|
|
399
395
|
"analysis_runs",
|
package/dist/query/spend.js
CHANGED
|
@@ -156,61 +156,7 @@ export function hotSessionsByCost(db, limit = 20, window) {
|
|
|
156
156
|
AND te.exit_class = 'ERROR') AS tool_error_count,
|
|
157
157
|
(SELECT COUNT(*) FROM tool_events te
|
|
158
158
|
WHERE te.session_id = s.session_id
|
|
159
|
-
AND te.exit_class = '
|
|
160
|
-
AND te.result_bytes IS NOT NULL) AS tool_completed_error_count,
|
|
161
|
-
(SELECT COUNT(*) FROM tool_events te
|
|
162
|
-
WHERE te.session_id = s.session_id
|
|
163
|
-
AND te.result_bytes IS NOT NULL) AS tool_completed_count,
|
|
164
|
-
(SELECT COUNT(*) FROM tool_events te
|
|
165
|
-
WHERE te.session_id = s.session_id
|
|
166
|
-
AND te.exit_class = 'TEST_FAIL'
|
|
167
|
-
AND EXISTS (
|
|
168
|
-
SELECT 1 FROM tool_event_metadata metadata
|
|
169
|
-
WHERE metadata.event_id = te.event_id AND metadata.is_test_command = 1
|
|
170
|
-
)) AS test_fail_count,
|
|
171
|
-
(SELECT COUNT(*) FROM tool_events te
|
|
172
|
-
JOIN tool_event_metadata metadata ON metadata.event_id = te.event_id
|
|
173
|
-
WHERE te.session_id = s.session_id
|
|
174
|
-
AND metadata.is_test_command = 1
|
|
175
|
-
AND te.result_bytes IS NOT NULL) AS test_completed_count,
|
|
176
|
-
(SELECT COUNT(*) FROM tool_events te
|
|
177
|
-
JOIN tool_event_metadata metadata ON metadata.event_id = te.event_id
|
|
178
|
-
WHERE te.session_id = s.session_id
|
|
179
|
-
AND metadata.is_test_command = 1
|
|
180
|
-
AND te.exit_class = 'OK'
|
|
181
|
-
AND te.result_bytes IS NOT NULL) AS test_pass_count,
|
|
182
|
-
CASE WHEN NOT EXISTS (
|
|
183
|
-
SELECT 1 FROM tool_events observed
|
|
184
|
-
JOIN tool_event_metadata observed_metadata ON observed_metadata.event_id = observed.event_id
|
|
185
|
-
WHERE observed.session_id = s.session_id
|
|
186
|
-
AND observed_metadata.is_test_command = 1
|
|
187
|
-
AND observed.result_bytes IS NOT NULL
|
|
188
|
-
) THEN 'NO_TEST_OUTCOMES'
|
|
189
|
-
WHEN NOT EXISTS (
|
|
190
|
-
SELECT 1 FROM tool_events failed
|
|
191
|
-
JOIN tool_event_metadata failed_metadata ON failed_metadata.event_id = failed.event_id
|
|
192
|
-
WHERE failed.session_id = s.session_id
|
|
193
|
-
AND failed_metadata.is_test_command = 1
|
|
194
|
-
AND failed.exit_class = 'TEST_FAIL'
|
|
195
|
-
AND failed.result_bytes IS NOT NULL
|
|
196
|
-
) THEN 'NO_FAILURES_OBSERVED'
|
|
197
|
-
WHEN EXISTS (
|
|
198
|
-
SELECT 1 FROM tool_events passed
|
|
199
|
-
JOIN tool_event_metadata passed_metadata ON passed_metadata.event_id = passed.event_id
|
|
200
|
-
WHERE passed.session_id = s.session_id
|
|
201
|
-
AND passed_metadata.is_test_command = 1
|
|
202
|
-
AND passed.exit_class = 'OK'
|
|
203
|
-
AND passed.result_bytes IS NOT NULL
|
|
204
|
-
AND EXISTS (
|
|
205
|
-
SELECT 1 FROM tool_events failed_before
|
|
206
|
-
JOIN tool_event_metadata failed_before_metadata ON failed_before_metadata.event_id = failed_before.event_id
|
|
207
|
-
WHERE failed_before.session_id = s.session_id
|
|
208
|
-
AND failed_before_metadata.is_test_command = 1
|
|
209
|
-
AND failed_before.exit_class = 'TEST_FAIL'
|
|
210
|
-
AND failed_before.result_bytes IS NOT NULL
|
|
211
|
-
AND failed_before.ts < passed.ts
|
|
212
|
-
)
|
|
213
|
-
) THEN 'FAILED_THEN_PASSED' ELSE 'FAILURES_OBSERVED' END AS test_outcome,
|
|
159
|
+
AND te.exit_class = 'TEST_FAIL') AS test_fail_count,
|
|
214
160
|
s.gap_median_s AS gap_median_s,
|
|
215
161
|
s.gap_p90_s AS gap_p90_s,
|
|
216
162
|
s.long_gap_count AS long_gap_count,
|
|
@@ -221,13 +167,5 @@ export function hotSessionsByCost(db, limit = 20, window) {
|
|
|
221
167
|
ORDER BY cost_equiv_u DESC, s.session_id ASC
|
|
222
168
|
LIMIT @limit`)
|
|
223
169
|
.all(window === undefined ? { limit } : { limit, from: window.from, to: window.to });
|
|
224
|
-
return rows
|
|
225
|
-
...row,
|
|
226
|
-
api_error_eligible_request_count: null,
|
|
227
|
-
api_error_rate: null,
|
|
228
|
-
interrupts_supported: false,
|
|
229
|
-
tool_error_rate: row.tool_completed_count > 0
|
|
230
|
-
? row.tool_completed_error_count / row.tool_completed_count
|
|
231
|
-
: null,
|
|
232
|
-
}));
|
|
170
|
+
return rows;
|
|
233
171
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as u}from"./index-
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ia(e,a){if(e){if(typeof e=="string")return fe(e,a);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?fe(e,a):void 0}}function fe(e,a){(a==null||a>e.length)&&(a=e.length);for(var t=0,r=Array(a);t<a;t++)r[t]=e[t];return r}function Pa(e,a){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var r,n,i,o,s=[],c=!0,l=!1;try{if(i=(t=t.call(e)).next,a!==0)for(;!(c=(r=i.call(t)).done)&&(s.push(r.value),s.length!==a);c=!0);}catch(d){l=!0,n=d}finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw n}}return s}}function ka(e){if(Array.isArray(e))return e}var me=(e,a,t)=>{var r=t??e;if(!V(r))return
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mt(e,a){if(e){if(typeof e=="string")return ye(e,a);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ye(e,a):void 0}}function ye(e,a){(a==null||a>e.length)&&(a=e.length);for(var t=0,r=Array(a);t<a;t++)r[t]=e[t];return r}function pt(e,a){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var r,n,i,o,s=[],c=!0,l=!1;try{if(i=(t=t.call(e)).next,a!==0)for(;!(c=(r=i.call(t)).done)&&(s.push(r.value),s.length!==a);c=!0);}catch(d){l=!0,n=d}finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw n}}return s}}function ht(e){if(Array.isArray(e))return e}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},D.apply(null,arguments)}function xe(e,a){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function A(e){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?arguments[a]:{};a%2?xe(Object(t),!0).forEach(function(r){yt(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):xe(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function yt(e,a,t){return(a=xt(a))in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}function xt(e){var a=gt(e,"string");return typeof a=="symbol"?a:a+""}function gt(e,a){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var r=t.call(e,a);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(e)}function U(e,a){if(e==null)return{};var t,r,n=bt(e,a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],a.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}function bt(e,a){if(e==null)return{};var t={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(a.indexOf(r)!==-1)continue;t[r]=e[r]}return t}var At=e=>{var a=e.dataKey,t=e.name,r=e.fill,n=e.legendType,i=e.hide;return[{inactive:i,dataKey:a,type:n,color:r,value:Pe(t,a),payload:e}]},It=u.memo(e=>{var a=e.dataKey,t=e.stroke,r=e.strokeWidth,n=e.fill,i=e.name,o=e.hide,s=e.unit,c=e.formatter,l=e.tooltipType,d=e.id,v={dataDefinedOnItem:void 0,getPosition:ea,settings:{stroke:t,strokeWidth:r,fill:n,dataKey:a,nameKey:void 0,name:Pe(i,a),hide:o,type:l,color:n,unit:s,formatter:c,graphicalItemId:d}};return u.createElement(Qe,{tooltipEntrySettings:v})});function Pt(e){var a=G(Be),t=e.data,r=e.dataKey,n=e.background,i=e.allOtherBarProps,o=i.onMouseEnter,s=i.onMouseLeave,c=i.onClick,l=U(i,ut),d=Ee(o,r,i.id),v=Se(s),f=Oe(c,r,i.id);if(!n||t==null)return null;var y=ca(n);return u.createElement(ae,{zIndex:Ma(n,ee.barBackground)},t.map((m,x)=>{m.value;var h=m.background;m.tooltipPosition;var b=U(m,ct);if(!h)return null;var g=d(m,m.originalDataIndex),I=v(m,m.originalDataIndex),p=f(m,m.originalDataIndex),k=A(A(A(A(A({option:n,isActive:String(m.originalDataIndex)===a},b),{},{fill:"#eee"},h),y),we(l,m,x)),{},{onMouseEnter:g,onMouseLeave:I,onClick:p,dataKey:r,index:x,className:"recharts-bar-background-rectangle"});return u.createElement(re,D({key:"background-bar-".concat(x)},k))}))}function kt(e){var a=e.showLabels,t=e.children,r=e.rects,n=r==null?void 0:r.map(i=>{var o={x:i.x,y:i.y,width:i.width,lowerWidth:i.width,upperWidth:i.width,height:i.height};return A(A({},o),{},{value:i.value,payload:i.payload,parentViewBox:i.parentViewBox,viewBox:o,fill:i.fill})});return u.createElement(ma,{value:a?n:void 0},t)}function Bt(e){var a=e.shape,t=e.activeBar,r=e.baseProps,n=e.entry,i=e.index,o=e.dataKey,s=G(Be),c=G(ha),l=t&&String(n.originalDataIndex)===s&&(c==null||o===c),d=s!=null&&(String(n.originalDataIndex)!==s||c!=null&&o!==c),v=u.useState(!1),f=he(v,2),y=f[0],m=f[1],x=u.useState(!1),h=he(x,2),b=h[0],g=h[1];u.useEffect(()=>{var P;return l?(m(!0),P=requestAnimationFrame(()=>{g(!0)})):(g(!1),d&&m(!1)),()=>{cancelAnimationFrame(P)}},[l,d]);var I=u.useCallback(()=>{l||m(!1)},[l]),p=l&&b,k=l||y,B;l?t===!0?B=a:B=t:B=a;var w=u.createElement(re,D({},r,{name:String(r.name)},n,{isActive:p,option:B,index:i,dataKey:o,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance,onTransitionEnd:I}));return k?u.createElement(ae,{zIndex:ee.activeBar},u.createElement(je,{index:n.originalDataIndex},w)):w}function Et(e){var a=e.shape,t=e.baseProps,r=e.entry,n=e.index,i=e.dataKey;return u.createElement(re,D({},t,{name:String(t.name)},r,{isActive:!1,option:a,index:n,dataKey:i,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance}))}function St(e){var a,t=e.data,r=e.props,n=e.animationElapsedTime,i=e.isAnimating,o=e.isEntrance,s=(a=pa(r))!==null&&a!==void 0?a:{},c=s.id,l=U(s,dt),d=r.shape,v=r.dataKey,f=r.activeBar,y=r.onMouseEnter,m=r.onClick,x=r.onMouseLeave,h=U(r,vt),b=Ee(y,v,c),g=Se(x),I=Oe(m,v,c);return t?u.createElement(u.Fragment,null,t.map((p,k)=>u.createElement(je,D({index:p.originalDataIndex,key:"rectangle-".concat(p==null?void 0:p.x,"-").concat(p==null?void 0:p.y,"-").concat(p==null?void 0:p.value,"-").concat(k),className:"recharts-bar-rectangle"},we(h,p,k),{onMouseEnter:b(p,p.originalDataIndex),onMouseLeave:g(p,p.originalDataIndex),onClick:I(p,p.originalDataIndex)}),f?u.createElement(Bt,{shape:d,activeBar:f,baseProps:l,entry:p,index:k,dataKey:v,animationElapsedTime:n,isAnimating:i,isEntrance:o}):u.createElement(Et,{shape:d,baseProps:l,entry:p,index:k,dataKey:v,animationElapsedTime:n,isAnimating:i,isEntrance:o})))):null}var Ot=(e,a,t)=>e==null?[]:a===1?e.flatMap(r=>r.status==="removed"?[]:[r.next]):e.flatMap(r=>{if(r.status==="removed")return t==="horizontal"?[A(A({},r.prev),{},{height:O(r.prev.height,0,a),y:O(r.prev.y,r.prev.y+r.prev.height,a)})]:[A(A({},r.prev),{},{width:O(r.prev.width,0,a)})];if(r.status==="matched")return[A(A({},r.next),{},{x:O(r.prev.x,r.next.x,a),y:O(r.prev.y,r.next.y,a),width:O(r.prev.width,r.next.width,a),height:O(r.prev.height,r.next.height,a)})];var n=r.next;return t==="horizontal"?[A(A({},n),{},{height:O(0,n.height,a),y:O(n.stackedBarStart,n.y,a)})]:[A(A({},n),{},{width:O(0,n.width,a),x:O(n.stackedBarStart,n.x,a)})]});function wt(e){var a=e.props,t=e.previousRectanglesRef,r=a.data,n=a.isAnimationActive,i=a.animationBegin,o=a.animationDuration,s=a.animationEasing,c=a.animationInterpolateFn,l=a.layout,d=da(a.onAnimationStart,a.onAnimationEnd),v=d.isAnimating,f=d.handleAnimationStart,y=d.handleAnimationEnd;return u.createElement(kt,{showLabels:!v,rects:r},u.createElement(va,{animationInput:r,animationIdPrefix:"recharts-bar-",items:r,previousItemsRef:t,isAnimationActive:n,animationBegin:i,animationDuration:o,animationEasing:s,onAnimationStart:f,onAnimationEnd:y,animationInterpolateFn:c,animationMatchBy:a.animationMatchBy,layout:l},(m,x,h)=>u.createElement(_,null,u.createElement(St,{props:a,data:m,animationElapsedTime:x,isAnimating:v||x<1,isEntrance:h}))),u.createElement(fa,{label:a.label}),a.children)}function Ct(e){var a=u.useRef(null);return u.createElement(wt,{previousRectanglesRef:a,props:e})}var Me=0,Dt=(e,a)=>{var t=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:t,errorVal:ke(e,a)}};class jt extends u.PureComponent{render(){var a=this.props,t=a.hide,r=a.data,n=a.dataKey,i=a.className,o=a.xAxisId,s=a.yAxisId,c=a.needClip,l=a.background,d=a.id;if(t||r==null)return null;var v=oa("recharts-bar",i),f=d;return u.createElement(_,{className:v,id:d},c&&u.createElement("defs",null,u.createElement(la,{clipPathId:f,xAxisId:o,yAxisId:s})),u.createElement(_,{className:"recharts-bar-rectangles",clipPath:c?"url(#clipPath-".concat(f,")"):void 0},u.createElement(Pt,{data:r,dataKey:n,background:l,allOtherBarProps:this.props}),u.createElement(Ct,this.props)))}}var Mt={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",animationInterpolateFn:Ot,animationMatchBy:Ye,background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:Me,shape:te,xAxisId:0,yAxisId:0,zIndex:ee.bar};function Kt(e){var a=e.xAxisId,t=e.yAxisId,r=e.hide,n=e.legendType,i=e.minPointSize,o=e.activeBar,s=e.animationBegin,c=e.animationDuration,l=e.animationEasing,d=e.isAnimationActive,v=aa(a,t),f=v.needClip,y=ta(),m=Ie(),x=ra(e.children,ia),h=G(I=>tt(I,e.id,m,x));if(y!=="vertical"&&y!=="horizontal")return null;var b,g=h==null?void 0:h[0];return g==null||g.height==null||g.width==null?b=0:b=y==="vertical"?g.height/2:g.width/2,u.createElement(na,{xAxisId:a,yAxisId:t,data:h,dataPointFormatter:Dt,errorBarOffset:b},u.createElement(jt,D({},e,{layout:y,needClip:f,data:h,xAxisId:a,yAxisId:t,hide:r,legendType:n,minPointSize:i,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:d})))}function zt(e){var a=e.layout,t=e.barSettings,r=t.dataKey,n=t.minPointSize,i=t.hasCustomShape,o=e.pos,s=e.bandSize,c=e.xAxis,l=e.yAxis,d=e.xAxisTicks,v=e.yAxisTicks,f=e.stackedData,y=e.displayedData,m=e.offset,x=e.cells,h=e.parentViewBox,b=e.dataStartIndex,g=a==="horizontal"?l:c,I=f?g.scale.domain():null,p=sa({numericAxis:g}),k=g.scale.map(p);return y.map((B,w)=>{var P,L,M,E,S,Z;if(f){var ne=f[w+b];if(ne==null)return null;P=ua(ne,I)}else P=ke(B,r),Array.isArray(P)||(P=[p,P]);var C=Fa(n,Me)(P[1],w);if(a==="horizontal"){var X,Y=l.scale.map(P[0]),N=l.scale.map(P[1]);if(Y==null||N==null)return null;L=de({axis:c,ticks:d,bandSize:s,offset:o.offset,entry:B,index:w}),M=(X=N??Y)!==null&&X!==void 0?X:void 0,E=o.size;var ie=Y-N;if(S=ya(ie)?0:ie,Z={x:L,y:m.top,width:E,height:m.height},Math.abs(C)>0&&Math.abs(S)<Math.abs(C)){var oe=ve(S||C)*(Math.abs(C)-Math.abs(S));M-=oe,S+=oe}}else{var H=c.scale.map(P[0]),le=c.scale.map(P[1]);if(H==null||le==null)return null;if(L=H,M=de({axis:l,ticks:v,bandSize:s,offset:o.offset,entry:B,index:w}),E=le-H,S=o.size,Z={x:m.left,y:M,width:m.width,height:S},Math.abs(C)>0&&Math.abs(E)<Math.abs(C)){var Ke=ve(E||C)*(Math.abs(C)-Math.abs(E));E+=Ke}}if(L==null||M==null||E==null||S==null||!i&&(E===0||S===0))return null;var ze=A(A({},B),{},{stackedBarStart:k,x:L,y:M,width:E,height:S,value:f?P:P[1],payload:B,background:Z,tooltipPosition:{x:L+E/2,y:M+S/2},parentViewBox:h,originalDataIndex:w},x&&x[w]&&x[w].props);return ze}).filter(Boolean)}function Lt(e){var a=Xe(e,Mt),t=ot(a.stackId),r=Ie();return u.createElement(He,{id:a.id,type:"bar"},n=>u.createElement(u.Fragment,null,u.createElement(qe,{legendPayload:At(a)}),u.createElement(It,{dataKey:a.dataKey,stroke:a.stroke,strokeWidth:a.strokeWidth,fill:a.fill,name:a.name,hide:a.hide,unit:a.unit,formatter:a.formatter,tooltipType:a.tooltipType,id:n}),u.createElement(Je,{type:"bar",id:n,data:void 0,xAxisId:a.xAxisId,yAxisId:a.yAxisId,zAxisId:0,dataKey:a.dataKey,stackId:t,hide:a.hide,barSize:a.barSize,minPointSize:a.minPointSize,maxBarSize:a.maxBarSize,isPanorama:r,hasCustomShape:a.shape!=null&&a.shape!==te}),u.createElement(ae,{zIndex:a.zIndex},u.createElement(Kt,D({},a,{id:n})))))}var Tt=u.memo(Lt,Ze);Tt.displayName="Bar";var Rt=["axis","item"],Wt=u.forwardRef((e,a)=>u.createElement(xa,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Rt,tooltipPayloadSearcher:ga,categoricalChartProps:e,ref:a}));export{Wt as B,Tt as a};
|
|
1
|
+
import{r as u}from"./index-DRhoA51c.js";import{a_ as Le,a5 as V,a$ as Y,q as Q,i as Te,b0 as Fe,r as se,a4 as Re,c as j,b1 as Ne,b2 as $e,b as R,d as We,f as T,h as F,k as ge,l as be,b3 as Ae,b4 as _e,b5 as Ge,n as ue,b6 as Ue,b7 as ce,A as Ve,L as _,t as Ze,v as qe,D as ee,aQ as He,x as Ie,y as Xe,S as Ye,z as Qe,Z as ae,B as O,E as Pe,F as Je,G as ea,J as aa,H as ta,aR as ra,K as G,ac as na,aS as ia,Q as ke,N as oa,P as la,b8 as sa,b9 as ua,ba as de,aB as Be,aU as Ee,aV as Se,aW as Oe,aD as ca,ad as we,_ as da,a0 as va,a1 as fa,a2 as ma,o as pa,bb as ha,a6 as ya,bc as ve,a7 as xa,a8 as ga}from"./chart-theme-JH5aQymO.js";import{s as K,a as z}from"./graphicalItemSelectors-CCbl8AKC.js";function ba(e,a){return ka(e)||Pa(e,a)||Ia(e,a)||Aa()}function Aa(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ia(e,a){if(e){if(typeof e=="string")return fe(e,a);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?fe(e,a):void 0}}function fe(e,a){(a==null||a>e.length)&&(a=e.length);for(var t=0,r=Array(a);t<a;t++)r[t]=e[t];return r}function Pa(e,a){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var r,n,i,o,s=[],c=!0,l=!1;try{if(i=(t=t.call(e)).next,a!==0)for(;!(c=(r=i.call(t)).done)&&(s.push(r.value),s.length!==a);c=!0);}catch(d){l=!0,n=d}finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw n}}return s}}function ka(e){if(Array.isArray(e))return e}var me=(e,a,t)=>{var r=t??e;if(!V(r))return Y(r,a,0)},Ba=(e,a,t)=>{var r={},n=e.filter(Le),i=e.filter(l=>l.stackId==null),o=n.reduce((l,d)=>{var v=l[d.stackId];return v==null&&(v=[]),v.push(d),l[d.stackId]=v,l},r),s=Object.entries(o).map(l=>{var d,v=ba(l,2),f=v[0],y=v[1],m=y.map(h=>h.dataKey),x=me(a,t,(d=y[0])===null||d===void 0?void 0:d.barSize);return{stackId:f,dataKeys:m,barSize:x}}),c=i.map(l=>{var d=[l.dataKey].filter(f=>f!=null),v=me(a,t,l.barSize);return{stackId:void 0,dataKeys:d,barSize:v}});return[...s,...c]};function pe(e,a){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function W(e){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?arguments[a]:{};a%2?pe(Object(t),!0).forEach(function(r){Ea(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):pe(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function Ea(e,a,t){return(a=Sa(a))in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}function Sa(e){var a=Oa(e,"string");return typeof a=="symbol"?a:a+""}function Oa(e,a){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var r=t.call(e,a);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(e)}function wa(e,a,t,r,n){var i,o=r.length;if(!(o<1)){var s=Y(e,t,0,!0),c,l=[];if(Q((i=r[0])===null||i===void 0?void 0:i.barSize)){var d=!1,v=t/o,f=r.reduce((g,I)=>g+(I.barSize||0),0);f+=(o-1)*s,f>=t&&(f-=(o-1)*s,s=0),f>=t&&v>0&&(d=!0,v*=.9,f=o*v);var y=Math.round((t-f)/2),m={offset:y-s,size:0};c=r.reduce((g,I)=>{var p,k={stackId:I.stackId,dataKeys:I.dataKeys,position:{offset:m.offset+m.size+s,size:d?v:(p=I.barSize)!==null&&p!==void 0?p:0}},B=[...g,k];return m=k.position,B},l)}else{var x=Y(a,t,0,!0);t-2*x-(o-1)*s<=0&&(s=0);var h=(t-2*x-(o-1)*s)/o;h>1&&(h=Math.round(h));var b=Q(n)?Math.min(h,n):h;c=r.reduce((g,I,p)=>[...g,{stackId:I.stackId,dataKeys:I.dataKeys,position:{offset:x+o*(h-b)/2+(b+s)*p,size:b}}],l)}return c}}var Ca=(e,a,t,r,n,i,o)=>{var s=V(o)?a:o,c=wa(t,r,n!==i?n:i,e,s);return n!==i&&c!=null&&(c=c.map(l=>W(W({},l),{},{position:W(W({},l.position),{},{offset:l.position.offset-n/2})}))),c},Da=(e,a)=>{var t=Te(a);if(!(!e||t==null||a==null)){var r=a.stackId;if(r!=null){var n=e[r];if(n){var i=n.stackedData;if(i)return i.find(o=>o.key===t)}}}},ja=(e,a)=>{if(!(e==null||a==null)){var t=e.find(r=>r.stackId===a.stackId&&a.dataKey!=null&&r.dataKeys.includes(a.dataKey));if(t!=null)return t.position}};function Ma(e,a){return e&&typeof e=="object"&&"zIndex"in e&&typeof e.zIndex=="number"&&Q(e.zIndex)?e.zIndex:a}var Ka="Invariant failed";function za(e,a){throw new Error(Ka)}var La=["option"];function Ta(e,a){if(e==null)return{};var t,r,n=Fa(e,a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],a.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}function Fa(e,a){if(e==null)return{};var t={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(a.indexOf(r)!==-1)continue;t[r]=e[r]}return t}var te=Fe;function re(e){var a=e.option,t=Ta(e,La);return u.createElement(Re,{option:a,DefaultShape:te,shapeProps:t,activeClassName:"recharts-active-bar",inActiveClassName:"recharts-inactive-bar"})}var Ra=function(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,n)=>{if(se(a))return a;var i=se(r)||V(r);return i?a(r,n):(i||za(),t)}},Na=(e,a,t)=>t,$a=(e,a)=>a,$=j([be,$a],(e,a)=>e.filter(t=>t.type==="bar").find(t=>t.id===a)),Wa=j([$],e=>e==null?void 0:e.maxBarSize),_a=(e,a,t,r)=>r,Ga=j([R,be,K,z,Na],(e,a,t,r,n)=>a.filter(i=>e==="horizontal"?i.xAxisId===t:i.yAxisId===r).filter(i=>i.isPanorama===n).filter(i=>i.hide===!1).filter(i=>i.type==="bar")),Ua=(e,a,t)=>{var r=R(e),n=K(e,a),i=z(e,a);if(!(n==null||i==null))return r==="horizontal"?ue(e,"yAxis",i,t):ue(e,"xAxis",n,t)},Va=(e,a)=>{var t=R(e),r=K(e,a),n=z(e,a);if(!(r==null||n==null))return t==="horizontal"?ce(e,"xAxis",r):ce(e,"yAxis",n)},Za=j([Ga,Ue,Va],Ba),qa=(e,a,t)=>{var r,n,i=$(e,a);if(i==null)return 0;var o=K(e,a),s=z(e,a);if(o==null||s==null)return 0;var c=R(e),l=Ae(e),d=i.maxBarSize,v=V(d)?l:d,f,y;return c==="horizontal"?(f=T(e,"xAxis",o,t),y=F(e,"xAxis",o,t)):(f=T(e,"yAxis",s,t),y=F(e,"yAxis",s,t)),(r=(n=ge(f,y,!0))!==null&&n!==void 0?n:v)!==null&&r!==void 0?r:0},Ce=(e,a,t)=>{var r=R(e),n=K(e,a),i=z(e,a);if(!(n==null||i==null)){var o,s;return r==="horizontal"?(o=T(e,"xAxis",n,t),s=F(e,"xAxis",n,t)):(o=T(e,"yAxis",i,t),s=F(e,"yAxis",i,t)),ge(o,s)}},Ha=j([Za,Ae,_e,Ge,qa,Ce,Wa],Ca),Xa=(e,a,t)=>{var r=K(e,a);if(r!=null)return T(e,"xAxis",r,t)},Ya=(e,a,t)=>{var r=z(e,a);if(r!=null)return T(e,"yAxis",r,t)},Qa=(e,a,t)=>{var r=K(e,a);if(r!=null)return F(e,"xAxis",r,t)},Ja=(e,a,t)=>{var r=z(e,a);if(r!=null)return F(e,"yAxis",r,t)},et=j([Ha,$],ja),at=j([Ua,$],Da),tt=j([Ne,$e,Xa,Ya,Qa,Ja,et,R,We,Ce,at,$,_a],(e,a,t,r,n,i,o,s,c,l,d,v,f)=>{var y=c.chartData,m=c.dataStartIndex,x=c.dataEndIndex;if(!(v==null||o==null||a==null||s!=="horizontal"&&s!=="vertical"||t==null||r==null||n==null||i==null||l==null)){var h=v.data,b;if(h!=null&&h.length>0?b=h:b=y==null?void 0:y.slice(m,x+1),b!=null)return zt({layout:s,barSettings:v,pos:o,parentViewBox:a,bandSize:l,xAxis:t,yAxis:r,xAxisTicks:n,yAxisTicks:i,stackedData:d,displayedData:b,offset:e,cells:f,dataStartIndex:m})}}),rt=["index"];function J(){return J=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},J.apply(null,arguments)}function nt(e,a){if(e==null)return{};var t,r,n=it(e,a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],a.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}function it(e,a){if(e==null)return{};var t={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(a.indexOf(r)!==-1)continue;t[r]=e[r]}return t}var De=u.createContext(void 0),ot=e=>{var a=u.useContext(De);if(a!=null)return a.stackId;if(e!=null)return Ve(e)},lt=(e,a)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(a),st=e=>{var a=u.useContext(De);if(a!=null){var t=a.stackId;return"url(#".concat(lt(t,e),")")}},je=e=>{var a=e.index,t=nt(e,rt),r=st(a);return u.createElement(_,J({className:"recharts-bar-stack-layer",clipPath:r},t))},ut=["onMouseEnter","onMouseLeave","onClick"],ct=["value","background","tooltipPosition"],dt=["id"],vt=["onMouseEnter","onClick","onMouseLeave"];function he(e,a){return ht(e)||pt(e,a)||mt(e,a)||ft()}function ft(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mt(e,a){if(e){if(typeof e=="string")return ye(e,a);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ye(e,a):void 0}}function ye(e,a){(a==null||a>e.length)&&(a=e.length);for(var t=0,r=Array(a);t<a;t++)r[t]=e[t];return r}function pt(e,a){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var r,n,i,o,s=[],c=!0,l=!1;try{if(i=(t=t.call(e)).next,a!==0)for(;!(c=(r=i.call(t)).done)&&(s.push(r.value),s.length!==a);c=!0);}catch(d){l=!0,n=d}finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw n}}return s}}function ht(e){if(Array.isArray(e))return e}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},D.apply(null,arguments)}function xe(e,a){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function A(e){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?arguments[a]:{};a%2?xe(Object(t),!0).forEach(function(r){yt(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):xe(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function yt(e,a,t){return(a=xt(a))in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}function xt(e){var a=gt(e,"string");return typeof a=="symbol"?a:a+""}function gt(e,a){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var r=t.call(e,a);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(e)}function U(e,a){if(e==null)return{};var t,r,n=bt(e,a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],a.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}function bt(e,a){if(e==null)return{};var t={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(a.indexOf(r)!==-1)continue;t[r]=e[r]}return t}var At=e=>{var a=e.dataKey,t=e.name,r=e.fill,n=e.legendType,i=e.hide;return[{inactive:i,dataKey:a,type:n,color:r,value:Pe(t,a),payload:e}]},It=u.memo(e=>{var a=e.dataKey,t=e.stroke,r=e.strokeWidth,n=e.fill,i=e.name,o=e.hide,s=e.unit,c=e.formatter,l=e.tooltipType,d=e.id,v={dataDefinedOnItem:void 0,getPosition:ea,settings:{stroke:t,strokeWidth:r,fill:n,dataKey:a,nameKey:void 0,name:Pe(i,a),hide:o,type:l,color:n,unit:s,formatter:c,graphicalItemId:d}};return u.createElement(Je,{tooltipEntrySettings:v})});function Pt(e){var a=G(Be),t=e.data,r=e.dataKey,n=e.background,i=e.allOtherBarProps,o=i.onMouseEnter,s=i.onMouseLeave,c=i.onClick,l=U(i,ut),d=Ee(o,r,i.id),v=Se(s),f=Oe(c,r,i.id);if(!n||t==null)return null;var y=ca(n);return u.createElement(ae,{zIndex:Ma(n,ee.barBackground)},t.map((m,x)=>{m.value;var h=m.background;m.tooltipPosition;var b=U(m,ct);if(!h)return null;var g=d(m,m.originalDataIndex),I=v(m,m.originalDataIndex),p=f(m,m.originalDataIndex),k=A(A(A(A(A({option:n,isActive:String(m.originalDataIndex)===a},b),{},{fill:"#eee"},h),y),we(l,m,x)),{},{onMouseEnter:g,onMouseLeave:I,onClick:p,dataKey:r,index:x,className:"recharts-bar-background-rectangle"});return u.createElement(re,D({key:"background-bar-".concat(x)},k))}))}function kt(e){var a=e.showLabels,t=e.children,r=e.rects,n=r==null?void 0:r.map(i=>{var o={x:i.x,y:i.y,width:i.width,lowerWidth:i.width,upperWidth:i.width,height:i.height};return A(A({},o),{},{value:i.value,payload:i.payload,parentViewBox:i.parentViewBox,viewBox:o,fill:i.fill})});return u.createElement(ma,{value:a?n:void 0},t)}function Bt(e){var a=e.shape,t=e.activeBar,r=e.baseProps,n=e.entry,i=e.index,o=e.dataKey,s=G(Be),c=G(ha),l=t&&String(n.originalDataIndex)===s&&(c==null||o===c),d=s!=null&&(String(n.originalDataIndex)!==s||c!=null&&o!==c),v=u.useState(!1),f=he(v,2),y=f[0],m=f[1],x=u.useState(!1),h=he(x,2),b=h[0],g=h[1];u.useEffect(()=>{var P;return l?(m(!0),P=requestAnimationFrame(()=>{g(!0)})):(g(!1),d&&m(!1)),()=>{cancelAnimationFrame(P)}},[l,d]);var I=u.useCallback(()=>{l||m(!1)},[l]),p=l&&b,k=l||y,B;l?t===!0?B=a:B=t:B=a;var w=u.createElement(re,D({},r,{name:String(r.name)},n,{isActive:p,option:B,index:i,dataKey:o,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance,onTransitionEnd:I}));return k?u.createElement(ae,{zIndex:ee.activeBar},u.createElement(je,{index:n.originalDataIndex},w)):w}function Et(e){var a=e.shape,t=e.baseProps,r=e.entry,n=e.index,i=e.dataKey;return u.createElement(re,D({},t,{name:String(t.name)},r,{isActive:!1,option:a,index:n,dataKey:i,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance}))}function St(e){var a,t=e.data,r=e.props,n=e.animationElapsedTime,i=e.isAnimating,o=e.isEntrance,s=(a=pa(r))!==null&&a!==void 0?a:{},c=s.id,l=U(s,dt),d=r.shape,v=r.dataKey,f=r.activeBar,y=r.onMouseEnter,m=r.onClick,x=r.onMouseLeave,h=U(r,vt),b=Ee(y,v,c),g=Se(x),I=Oe(m,v,c);return t?u.createElement(u.Fragment,null,t.map((p,k)=>u.createElement(je,D({index:p.originalDataIndex,key:"rectangle-".concat(p==null?void 0:p.x,"-").concat(p==null?void 0:p.y,"-").concat(p==null?void 0:p.value,"-").concat(k),className:"recharts-bar-rectangle"},we(h,p,k),{onMouseEnter:b(p,p.originalDataIndex),onMouseLeave:g(p,p.originalDataIndex),onClick:I(p,p.originalDataIndex)}),f?u.createElement(Bt,{shape:d,activeBar:f,baseProps:l,entry:p,index:k,dataKey:v,animationElapsedTime:n,isAnimating:i,isEntrance:o}):u.createElement(Et,{shape:d,baseProps:l,entry:p,index:k,dataKey:v,animationElapsedTime:n,isAnimating:i,isEntrance:o})))):null}var Ot=(e,a,t)=>e==null?[]:a===1?e.flatMap(r=>r.status==="removed"?[]:[r.next]):e.flatMap(r=>{if(r.status==="removed")return t==="horizontal"?[A(A({},r.prev),{},{height:O(r.prev.height,0,a),y:O(r.prev.y,r.prev.y+r.prev.height,a)})]:[A(A({},r.prev),{},{width:O(r.prev.width,0,a)})];if(r.status==="matched")return[A(A({},r.next),{},{x:O(r.prev.x,r.next.x,a),y:O(r.prev.y,r.next.y,a),width:O(r.prev.width,r.next.width,a),height:O(r.prev.height,r.next.height,a)})];var n=r.next;return t==="horizontal"?[A(A({},n),{},{height:O(0,n.height,a),y:O(n.stackedBarStart,n.y,a)})]:[A(A({},n),{},{width:O(0,n.width,a),x:O(n.stackedBarStart,n.x,a)})]});function wt(e){var a=e.props,t=e.previousRectanglesRef,r=a.data,n=a.isAnimationActive,i=a.animationBegin,o=a.animationDuration,s=a.animationEasing,c=a.animationInterpolateFn,l=a.layout,d=da(a.onAnimationStart,a.onAnimationEnd),v=d.isAnimating,f=d.handleAnimationStart,y=d.handleAnimationEnd;return u.createElement(kt,{showLabels:!v,rects:r},u.createElement(va,{animationInput:r,animationIdPrefix:"recharts-bar-",items:r,previousItemsRef:t,isAnimationActive:n,animationBegin:i,animationDuration:o,animationEasing:s,onAnimationStart:f,onAnimationEnd:y,animationInterpolateFn:c,animationMatchBy:a.animationMatchBy,layout:l},(m,x,h)=>u.createElement(_,null,u.createElement(St,{props:a,data:m,animationElapsedTime:x,isAnimating:v||x<1,isEntrance:h}))),u.createElement(fa,{label:a.label}),a.children)}function Ct(e){var a=u.useRef(null);return u.createElement(wt,{previousRectanglesRef:a,props:e})}var Me=0,Dt=(e,a)=>{var t=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:t,errorVal:ke(e,a)}};class jt extends u.PureComponent{render(){var a=this.props,t=a.hide,r=a.data,n=a.dataKey,i=a.className,o=a.xAxisId,s=a.yAxisId,c=a.needClip,l=a.background,d=a.id;if(t||r==null)return null;var v=oa("recharts-bar",i),f=d;return u.createElement(_,{className:v,id:d},c&&u.createElement("defs",null,u.createElement(la,{clipPathId:f,xAxisId:o,yAxisId:s})),u.createElement(_,{className:"recharts-bar-rectangles",clipPath:c?"url(#clipPath-".concat(f,")"):void 0},u.createElement(Pt,{data:r,dataKey:n,background:l,allOtherBarProps:this.props}),u.createElement(Ct,this.props)))}}var Mt={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",animationInterpolateFn:Ot,animationMatchBy:He,background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:Me,shape:te,xAxisId:0,yAxisId:0,zIndex:ee.bar};function Kt(e){var a=e.xAxisId,t=e.yAxisId,r=e.hide,n=e.legendType,i=e.minPointSize,o=e.activeBar,s=e.animationBegin,c=e.animationDuration,l=e.animationEasing,d=e.isAnimationActive,v=aa(a,t),f=v.needClip,y=ta(),m=Ie(),x=ra(e.children,ia),h=G(I=>tt(I,e.id,m,x));if(y!=="vertical"&&y!=="horizontal")return null;var b,g=h==null?void 0:h[0];return g==null||g.height==null||g.width==null?b=0:b=y==="vertical"?g.height/2:g.width/2,u.createElement(na,{xAxisId:a,yAxisId:t,data:h,dataPointFormatter:Dt,errorBarOffset:b},u.createElement(jt,D({},e,{layout:y,needClip:f,data:h,xAxisId:a,yAxisId:t,hide:r,legendType:n,minPointSize:i,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:d})))}function zt(e){var a=e.layout,t=e.barSettings,r=t.dataKey,n=t.minPointSize,i=t.hasCustomShape,o=e.pos,s=e.bandSize,c=e.xAxis,l=e.yAxis,d=e.xAxisTicks,v=e.yAxisTicks,f=e.stackedData,y=e.displayedData,m=e.offset,x=e.cells,h=e.parentViewBox,b=e.dataStartIndex,g=a==="horizontal"?l:c,I=f?g.scale.domain():null,p=sa({numericAxis:g}),k=g.scale.map(p);return y.map((B,w)=>{var P,L,M,E,S,Z;if(f){var ne=f[w+b];if(ne==null)return null;P=ua(ne,I)}else P=ke(B,r),Array.isArray(P)||(P=[p,P]);var C=Ra(n,Me)(P[1],w);if(a==="horizontal"){var q,H=l.scale.map(P[0]),N=l.scale.map(P[1]);if(H==null||N==null)return null;L=de({axis:c,ticks:d,bandSize:s,offset:o.offset,entry:B,index:w}),M=(q=N??H)!==null&&q!==void 0?q:void 0,E=o.size;var ie=H-N;if(S=ya(ie)?0:ie,Z={x:L,y:m.top,width:E,height:m.height},Math.abs(C)>0&&Math.abs(S)<Math.abs(C)){var oe=ve(S||C)*(Math.abs(C)-Math.abs(S));M-=oe,S+=oe}}else{var X=c.scale.map(P[0]),le=c.scale.map(P[1]);if(X==null||le==null)return null;if(L=X,M=de({axis:l,ticks:v,bandSize:s,offset:o.offset,entry:B,index:w}),E=le-X,S=o.size,Z={x:m.left,y:M,width:m.width,height:S},Math.abs(C)>0&&Math.abs(E)<Math.abs(C)){var Ke=ve(E||C)*(Math.abs(C)-Math.abs(E));E+=Ke}}if(L==null||M==null||E==null||S==null||!i&&(E===0||S===0))return null;var ze=A(A({},B),{},{stackedBarStart:k,x:L,y:M,width:E,height:S,value:f?P:P[1],payload:B,background:Z,tooltipPosition:{x:L+E/2,y:M+S/2},parentViewBox:h,originalDataIndex:w},x&&x[w]&&x[w].props);return ze}).filter(Boolean)}function Lt(e){var a=qe(e,Mt),t=ot(a.stackId),r=Ie();return u.createElement(Xe,{id:a.id,type:"bar"},n=>u.createElement(u.Fragment,null,u.createElement(Ye,{legendPayload:At(a)}),u.createElement(It,{dataKey:a.dataKey,stroke:a.stroke,strokeWidth:a.strokeWidth,fill:a.fill,name:a.name,hide:a.hide,unit:a.unit,formatter:a.formatter,tooltipType:a.tooltipType,id:n}),u.createElement(Qe,{type:"bar",id:n,data:void 0,xAxisId:a.xAxisId,yAxisId:a.yAxisId,zAxisId:0,dataKey:a.dataKey,stackId:t,hide:a.hide,barSize:a.barSize,minPointSize:a.minPointSize,maxBarSize:a.maxBarSize,isPanorama:r,hasCustomShape:a.shape!=null&&a.shape!==te}),u.createElement(ae,{zIndex:a.zIndex},u.createElement(Kt,D({},a,{id:n})))))}var Tt=u.memo(Lt,Ze);Tt.displayName="Bar";var Ft=["axis","item"],Wt=u.forwardRef((e,a)=>u.createElement(xa,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Ft,tooltipPayloadSearcher:ga,categoricalChartProps:e,ref:a}));export{Wt as B,Tt as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as p,f as D,a as P,b as y,c as B,d as I,j as t}from"./index-DRhoA51c.js";import{w as q}from"./workspace-label-CysPJNc0.js";import{I as g}from"./InfoTip-Dx7BHpBu.js";import{b as Y}from"./prompt-templates-DhR4Qoy9.js";import{f as G}from"./FrictionCell-OafGLGxT.js";import"./Chip-Bu6udQGq.js";const V=1e6,R=5,K=3;function c(e){return Number.isFinite(e)?e:0}function m(e){return c(e)/V}function W(e){let r=0,s=0;for(const d of e.buckets)r+=c(d.cache_creation_tokens),s+=c(d.cache_read_tokens);const o=r+s;return o===0?0:r/o}function E(e,r){return e.filter(s=>r===null||s.workspace_id===r)}const A={LOW:0,ELEVATED:1,HIGH:2};function X(e){if(e.length===0)return null;let r="LOW";for(const s of e){const o=G({api_error_count:s.api_error_count,tool_error_count:s.tool_error_count,test_fail_count:s.test_fail_count,compaction_count:s.compaction_count,interrupt_count:s.interrupt_count,user_turn_count:s.user_turn_count,turn_count:s.turns});A[o]>A[r]&&(r=o)}return r}function j(e,r){return{current:e,prior:r,delta:r===null?null:e-r}}function z(e,r){return c(r.cost_equiv_u)-c(e.cost_equiv_u)||e.session_id.localeCompare(r.session_id)}function J(e,r){const s=+(e.flavor!=="TURNKEY")-+(r.flavor!=="TURNKEY"),o=e.modeled_savings_usd_per_wk??Number.NEGATIVE_INFINITY,d=r.modeled_savings_usd_per_wk??Number.NEGATIVE_INFINITY;return s||d-o||e.detector_id.localeCompare(r.detector_id)||e.id.localeCompare(r.id)}function Q(e){const r=e.hotSessions.filter(n=>e.scopeWorkspaceId===null||n.workspace_id===e.scopeWorkspaceId).slice().sort(z).slice(0,R).map(n=>({session_id:n.session_id,usd:m(n.cost_equiv_u),turns:c(n.turns),avg_context_tokens:c(n.avg_context_tokens),model:n.model}));let s=0,o=0,d=0;for(const n of e.cacheTrend.buckets)s+=c(n.cache_creation_tokens),o+=c(n.cache_read_tokens),d+=c(n.turns);const x=s+o,b=e.recs.map(n=>{const f=Y(n);return f===null?null:{id:n.rec_id,detector_id:n.detector_id,lever:n.lever,flavor:f.flavor,modeled_savings_usd_per_wk:n.modeled_savings_u_per_wk===null?null:m(n.modeled_savings_u_per_wk),prompt:f.text}}).filter(n=>n!==null).sort(J),h=E(e.hotSessions,e.scopeWorkspaceId),l=e.prior!==void 0&&c(e.prior.overview.turns_total)>0?e.prior:null;return{scope:{label:e.scopeLabel,workspace_id:e.scopeWorkspaceId},verdict:{cost_usd:m(e.overview.cost_equiv_u),hot_session_count:h.length,peak_friction:X(h)},deltas:{spend_usd:j(m(e.overview.cost_equiv_u),l===null?null:m(l.overview.cost_equiv_u)),cache_write_share:j(W(e.cacheTrend),l===null?null:W(l.cacheTrend)),hot_session_count:j(h.length,l===null?null:E(l.hotSessions,e.scopeWorkspaceId).length)},actions:b.slice(0,K),overview:{cost_usd:m(e.overview.cost_equiv_u),turns:c(e.overview.turns),turns_total:c(e.overview.turns_total)},attribution:{hot_sessions:r,context_per_turn:e.overview.context_per_turn.map(n=>({model:n.model,turns:c(n.n),avg_context_per_turn:c(n.avg_context_per_turn),avg_output_per_turn:c(n.avg_output_per_turn),usd_per_turn:n.usd_per_turn===null?null:c(n.usd_per_turn)})),model_mix:e.overview.model_mix.map(n=>({model:n.model,turns:c(n.turns)})),cache_mix:{bucket_count:e.cacheTrend.buckets.length,spike_bucket_count:e.cacheTrend.spike_buckets.length,cache_write_tokens:s,cache_read_tokens:o,cache_read_share:x===0?0:o/x,turns:d}}}}function a(e){return c(e).toLocaleString(void 0,{maximumFractionDigits:6})}function k(e){const r=e.prior===null?"—":a(e.prior),s=e.delta===null?"—":a(e.delta);return`${a(e.current)} (prior ${r}, delta ${s})`}function Z(e){const r=[`# Brief: ${e.scope.label}`,"","## Verdict",`- Cost equivalent USD: ${a(e.verdict.cost_usd)}`,`- Hot sessions: ${a(e.verdict.hot_session_count)}`,`- Peak friction: ${e.verdict.peak_friction??"none"}`,"","## Change vs prior 7 days",`- Spend equivalent USD: ${k(e.deltas.spend_usd)}`,`- Cache-write share: ${k(e.deltas.cache_write_share)}`,`- Hot sessions: ${k(e.deltas.hot_session_count)}`,"","## Do these three things",`- Actions: ${a(e.actions.length)}`];return e.actions.forEach((s,o)=>{r.push(`### ${o+1}. ${s.detector_id}: ${s.id}`),r.push(`- Lever: ${s.lever}`),r.push(`- Mode: ${s.flavor}`),r.push(`- Modeled savings USD/week: ${s.modeled_savings_usd_per_wk===null?"0":a(s.modeled_savings_usd_per_wk)}`),r.push("- Prompt artifact:"),r.push(s.prompt)}),r.push("","<details>","","## Attribution",`- Hot sessions: ${a(e.attribution.hot_sessions.length)}`,...e.attribution.hot_sessions.map(s=>`- Session ${s.session_id}: USD ${a(s.usd)}, turns ${a(s.turns)}, context ${a(s.avg_context_tokens)}, model ${s.model}`),`- Context models: ${a(e.attribution.context_per_turn.length)}`,...e.attribution.context_per_turn.map(s=>{const o=s.usd_per_turn===null?"unpriced 0":`USD/turn ${a(s.usd_per_turn)}`;return`- Model ${s.model}: turns ${a(s.turns)}, context/turn ${a(s.avg_context_per_turn)}, output/turn ${a(s.avg_output_per_turn)}, ${o}`}),`- Model mix entries: ${a(e.attribution.model_mix.length)}`,...e.attribution.model_mix.map(s=>`- Model mix ${s.model}: turns ${a(s.turns)}`),`- Cache mix: ${a(e.attribution.cache_mix.bucket_count)} buckets, ${a(e.attribution.cache_mix.spike_bucket_count)} spikes, ${a(e.attribution.cache_mix.cache_write_tokens)} write tokens, ${a(e.attribution.cache_mix.cache_read_tokens)} read tokens, ${a(e.attribution.cache_mix.cache_read_share)} read share, ${a(e.attribution.cache_mix.turns)} turns`,"","</details>"),r.join(`
|
|
2
|
+
`)}const M=7,L=1440*60*1e3;function ee(e=new Date){const r=e.getTime(),s=r-M*L,o=s-M*L;return{current:{from:new Date(s).toISOString(),to:new Date(r).toISOString()},prior:{from:new Date(o).toISOString(),to:new Date(s).toISOString()},label:`${new Date(s).toLocaleDateString()} – ${new Date(r).toLocaleDateString()}`}}function u(e){return e.toLocaleString(void 0,{maximumFractionDigits:2})}function v(e){return`$${u(e)}`}function O(e){return`${(e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`}function te(e,r){if(r===null)return"Global";const s=e.find(o=>o.workspace_id===r);return s===void 0?r:q(s)}function se({delta:e,format:r}){if(e.delta===null)return t.jsx("span",{className:"brief-tile-delta brief-tile-delta-none",title:"No prior-week data to compare",children:"— vs prior week"});const s=e.delta>0?"up":e.delta<0?"down":"flat",o=s==="up"?"▲":s==="down"?"▼":"▬",d=e.delta>0?"+":"";return t.jsxs("span",{className:`brief-tile-delta brief-tile-delta-${s}`,children:[o," ",d,r(e.delta)," vs prior week"]})}function N({label:e,value:r,delta:s,format:o}){return t.jsxs("div",{className:"brief-tile",children:[t.jsx("div",{className:"brief-tile-label",children:e}),t.jsx("div",{className:"brief-tile-value",children:r}),t.jsx(se,{delta:s,format:o})]})}function re({brief:e}){const{cache_mix:r,hot_sessions:s}=e.attribution;return t.jsxs("details",{className:"briefs-details",children:[t.jsx("summary",{children:"Attribution & hot sessions"}),t.jsx("div",{className:"table-wrap",children:t.jsxs("table",{children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:"Measure"}),t.jsx("th",{scope:"col",children:"Value"})]})}),t.jsxs("tbody",{children:[t.jsxs("tr",{children:[t.jsx("td",{children:"Cost equivalent"}),t.jsx("td",{children:v(e.overview.cost_usd)})]}),t.jsxs("tr",{children:[t.jsx("td",{children:"Reconciled turns"}),t.jsx("td",{children:u(e.overview.turns)})]}),t.jsxs("tr",{children:[t.jsx("td",{children:"Total turns"}),t.jsx("td",{children:u(e.overview.turns_total)})]}),t.jsxs("tr",{children:[t.jsx("td",{children:"Cache write tokens"}),t.jsx("td",{children:u(r.cache_write_tokens)})]}),t.jsxs("tr",{children:[t.jsx("td",{children:"Cache read tokens"}),t.jsx("td",{children:u(r.cache_read_tokens)})]}),t.jsxs("tr",{children:[t.jsx("td",{children:"Hot sessions"}),t.jsx("td",{children:u(s.length)})]})]})]})}),s.length>0&&t.jsx("div",{className:"table-wrap",children:t.jsxs("table",{children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:"Session"}),t.jsx("th",{scope:"col",children:"Cost"}),t.jsx("th",{scope:"col",children:"Turns"}),t.jsx("th",{scope:"col",children:"Context / turn"}),t.jsx("th",{scope:"col",children:"Model"})]})}),t.jsx("tbody",{children:s.map(o=>t.jsxs("tr",{children:[t.jsx("td",{children:o.session_id}),t.jsx("td",{children:v(o.usd)}),t.jsx("td",{children:u(o.turns)}),t.jsx("td",{children:u(o.avg_context_tokens)}),t.jsx("td",{children:o.model})]},o.session_id))})]})})]})}function de(){const[e,r]=p.useState({status:"loading"}),[s,o]=p.useState(null),[d,x]=p.useState(!1),[b,h]=p.useState(null),l=p.useMemo(()=>ee(),[]);p.useEffect(()=>{let i=!1;return Promise.all([D(l.current),P(l.current),y(l.current),B(),I(l.current),D(l.prior),y(l.prior),I(l.prior)]).then(([_,w,S,$,U,T,C,F])=>{if(!i){if(_.data===null||w.data===null||S.data===null||$.data===null||T.data===null||C.data===null)throw new Error("Brief data was unavailable");r({status:"ok",overview:_.data,workspaces:w.data.items,cacheTrend:S.data,recs:$.data,hotSessions:U,priorOverview:T.data,priorCacheTrend:C.data,priorHotSessions:F})}}).catch(_=>{i||r({status:"error",message:String(_)})}),()=>{i=!0}},[l]);const n=e.status==="ok"?Q({scopeLabel:te(e.workspaces,s),scopeWorkspaceId:s,overview:e.overview,hotSessions:e.hotSessions,cacheTrend:e.cacheTrend,recs:e.recs.active.filter(i=>s===null||i.scope_workspace_id===null||i.scope_workspace_id===s),prior:{overview:e.priorOverview,hotSessions:e.priorHotSessions,cacheTrend:e.priorCacheTrend}}):null;async function f(){n!==null&&(await navigator.clipboard.writeText(Z(n)),x(!0),window.setTimeout(()=>x(!1),2e3))}async function H(i,_){await navigator.clipboard.writeText(_),h(i),window.setTimeout(()=>h(w=>w===i?null:w),2e3)}return t.jsxs("div",{className:"briefs-page",children:[t.jsx("div",{className:"page-top",children:t.jsxs("div",{className:"page-title",children:[t.jsx("h1",{children:"Briefs"}),t.jsx("p",{className:"page-sub",children:"This week in one page: verdict, what changed, what to do"})]})}),e.status==="loading"&&t.jsx("div",{className:"card","aria-busy":"true",children:"Loading brief data..."}),e.status==="error"&&t.jsxs("div",{className:"banner banner-error",role:"alert",children:["Could not load brief: ",e.message]}),e.status==="ok"&&n!==null&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"briefs-controls",children:[t.jsxs("label",{className:"briefs-scope",htmlFor:"briefs-scope",children:["Scope",t.jsxs("select",{id:"briefs-scope",value:s??"",onChange:i=>o(i.target.value||null),children:[t.jsx("option",{value:"",children:"Global"}),e.workspaces.map(i=>t.jsx("option",{value:i.workspace_id,children:q(i)},i.workspace_id))]})]}),t.jsx("span",{className:"briefs-window",title:"Rolling seven-day window",children:l.label}),t.jsx("button",{type:"button",className:"btn-primary",onClick:()=>void f(),children:d?"Copied":"Copy as markdown"})]}),t.jsx("section",{className:"card briefs-verdict","aria-labelledby":"briefs-verdict-heading",children:t.jsxs("h2",{id:"briefs-verdict-heading",className:"briefs-verdict-line",children:[t.jsx("strong",{children:v(n.verdict.cost_usd)})," ",t.jsx(g,{label:"What cap-weighted equivalent means",content:"Cost weighted the way your usage cap counts it — cache reads count roughly a tenth of fresh tokens. It's the number that actually moves you toward a limit, not raw token cost.",children:"cap-weighted equivalent"}),t.jsx("span",{className:"briefs-verdict-sep",children:" · "}),u(n.verdict.hot_session_count)," hot sessions",t.jsx("span",{className:"briefs-verdict-sep",children:" · "}),n.verdict.peak_friction===null?t.jsx("span",{className:"briefs-friction",children:"no friction signal"}):t.jsxs("span",{className:`briefs-friction briefs-friction-${n.verdict.peak_friction}`,children:[t.jsx(g,{label:"What peak friction means",content:"The single worst per-session friction band across this scope's hot sessions, not an average. It flags whether any one session went badly, which an average would hide.",children:"peak friction"})," ",n.verdict.peak_friction]})]})}),t.jsxs("div",{className:"brief-tiles-head",children:[t.jsx("span",{className:"brief-tiles-heading",children:"Week-over-week changes"}),t.jsx(g,{label:"What the delta tiles show",content:"Change versus the prior 7 days for spend, cache-write share, and hot-session count. A green delta is improvement; a red one is where this week got worse."})]}),t.jsxs("div",{className:"brief-tiles",children:[t.jsx(N,{label:"Spend equivalent",value:v(n.deltas.spend_usd.current),delta:n.deltas.spend_usd,format:v}),t.jsx(N,{label:"Cache-write share",value:O(n.deltas.cache_write_share.current),delta:n.deltas.cache_write_share,format:O}),t.jsx(N,{label:"Hot sessions",value:u(n.deltas.hot_session_count.current),delta:n.deltas.hot_session_count,format:u})]}),t.jsxs("section",{className:"card briefs-actions","aria-labelledby":"briefs-actions-heading",children:[t.jsx("div",{className:"section-head",children:t.jsx("h2",{id:"briefs-actions-heading",children:"Do these three things"})}),n.actions.length===0?t.jsx("p",{className:"kpi-off-hint",children:"No active recommendations were returned for this scope."}):t.jsx("ol",{className:"briefs-action-list",children:n.actions.map(i=>t.jsxs("li",{className:"briefs-action",children:[t.jsxs("div",{className:"briefs-action-main",children:[t.jsx("strong",{children:i.lever}),t.jsxs("span",{className:"kpi-off-hint",children:[i.detector_id," · ",i.flavor," · modeled savings"," ",i.modeled_savings_usd_per_wk===null?"unavailable":`${v(i.modeled_savings_usd_per_wk)} / week`]})]}),t.jsx("button",{type:"button",className:"btn-secondary briefs-action-copy",onClick:()=>void H(i.id,i.prompt),children:b===i.id?"Copied":"Copy prompt"})]},i.id))})]}),t.jsx(re,{brief:n})]})]})}export{de as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,j as m}from"./index-DRhoA51c.js";import{C as be}from"./Chip-Bu6udQGq.js";import{u as Ie,c as Pe}from"./Skeleton-CcD61x7q.js";import{c as B,b as q,d as Ee,e as Se,f as se,h as le,i as Ce,j as oe,k as _,l as Le,m as Ne,n as je,u as Oe,o as ce,p as Y,L as M,q as z,r as j,t as we,v as De,D as Re,w as We,x as de,y as Be,S as Te,z as Ke,A as Me,B as F,E as ue,F as ze,G as Fe,H as Ve,I as $e,J as Ge,K as Xe,M as Ye,N as He,O as qe,Z as Ue,P as Ze,Q as H,U as ee,V as Qe,W as Je,_ as _e,$ as ae,a0 as ea,a1 as aa,a2 as ta,a3 as ia,a4 as na,a5 as ra,a6 as sa,R as la,s as K,C as oa,g as O,X as ca,Y as da,T as ua,a as pa}from"./chart-theme-JH5aQymO.js";import{C as ha}from"./ComposedChart-8D5E-Po_.js";import{L as ma}from"./Legend--q6-rQGk.js";import{g as va,A as te,D as fa,R as ya,S as xa}from"./Scatter-Cr_hCkjG.js";import{s as U,a as Z}from"./graphicalItemSelectors-CCbl8AKC.js";var pe=(e,a,t)=>se(e,"xAxis",U(e,a),t),he=(e,a,t)=>le(e,"xAxis",U(e,a),t),me=(e,a,t)=>se(e,"yAxis",Z(e,a),t),ve=(e,a,t)=>le(e,"yAxis",Z(e,a),t),Aa=B([q,pe,me,he,ve],(e,a,t,i,r)=>oe(e,"xAxis")?_(a,i,!1):_(t,r,!1)),ga=(e,a)=>a,Q=B([Le,ga],(e,a)=>e.filter(t=>t.type==="area").find(t=>t.id===a)),fe=e=>{var a=q(e),t=oe(a,"xAxis");return t?"yAxis":"xAxis"},ka=(e,a)=>{var t=fe(e);return t==="yAxis"?Z(e,a):U(e,a)},ye=(e,a,t)=>je(e,fe(e),ka(e,a),t),ba=B([Q,ye],(e,a)=>{var t;if(!(e==null||a==null)){var i=e.stackId,r=Ce(e);if(!(i==null||r==null)){var n=(t=a[i])===null||t===void 0?void 0:t.stackedData,c=n==null?void 0:n.find(s=>s.key===r);if(c!=null)return c.map(s=>[s[0],s[1]])}}}),Ia=B([Q,ye],(e,a)=>{if(!(e==null||e.stackId==null||a==null)){var t=a[e.stackId];if(t!=null)return t.graphicalItems.map(i=>i.dataKey).filter(Ne)}}),Pa=B([q,pe,me,he,ve,ba,Ee,Aa,Q,Se,Ia],(e,a,t,i,r,n,c,s,d,u,p)=>{var o=c.chartData,v=c.dataStartIndex,I=c.dataEndIndex;if(!(d==null||e!=="horizontal"&&e!=="vertical"||a==null||t==null||i==null||r==null||i.length===0||r.length===0||s==null)){var f=d.data,y;if(f&&f.length>0?y=f:y=o==null?void 0:o.slice(v,I+1),y!=null)return Za({layout:e,xAxis:a,yAxis:t,xAxisTicks:i,yAxisTicks:r,dataStartIndex:v,areaSettings:d,stackedData:n,displayedData:y,chartBaseValue:u,bandSize:s,stackDataKeys:p})}}),Ea=["animationElapsedTime","isAnimating","isEntrance","layout","isRange","stroke","connectNulls"],Sa=["id","baseLine"];function W(){return W=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var i in t)({}).hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},W.apply(null,arguments)}function ie(e,a){if(e==null)return{};var t,i,r=Ca(e,a);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(i=0;i<n.length;i++)t=n[i],a.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}function Ca(e,a){if(e==null)return{};var t={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(a.indexOf(i)!==-1)continue;t[i]=e[i]}return t}function La(e){var a,t,i=e.alpha,r=e.baseLine,n=e.points,c=e.strokeWidth,s=(a=n[0])===null||a===void 0?void 0:a.x,d=(t=n[n.length-1])===null||t===void 0?void 0:t.x;if(!z(s)||!z(d))return null;var u=i*Math.abs(s-d),p=Math.max(...n.map(o=>o.y||0));return j(r)?p=Math.max(r,p):r&&Array.isArray(r)&&r.length&&(p=Math.max(...r.map(o=>o.y||0),p)),j(p)?l.createElement("rect",{x:s<d?s:s-u,y:0,width:u,height:Math.floor(p+(c?parseInt("".concat(c),10):1))}):null}function Na(e){var a,t,i=e.alpha,r=e.baseLine,n=e.points,c=e.strokeWidth,s=(a=n[0])===null||a===void 0?void 0:a.y,d=(t=n[n.length-1])===null||t===void 0?void 0:t.y;if(!z(s)||!z(d))return null;var u=i*Math.abs(s-d),p=Math.max(...n.map(o=>o.x||0));return j(r)?p=Math.max(r,p):r&&Array.isArray(r)&&r.length&&(p=Math.max(...r.map(o=>o.x||0),p)),j(p)?l.createElement("rect",{x:0,y:s<d?s:s-u,width:p+(c?parseInt("".concat(c),10):1),height:Math.floor(u)}):null}function ja(e){var a=e.alpha,t=e.layout,i=e.points,r=e.baseLine,n=e.strokeWidth;return t==="vertical"?l.createElement(Na,{alpha:a,points:i,baseLine:r,strokeWidth:n}):l.createElement(La,{alpha:a,points:i,baseLine:r,strokeWidth:n})}function Oa(e){var a=e.animationElapsedTime,t=a===void 0?1:a,i=e.isAnimating,r=i===void 0?!1:i,n=e.isEntrance,c=n===void 0?!1:n,s=e.layout,d=e.isRange,u=e.stroke,p=e.connectNulls,o=ie(e,Ea),v=s==="vertical"?"vertical":"horizontal",I=p??!1,f=Oe(),y=o.id,x=o.baseLine,A=ie(o,Sa),g=ce(A),S=l.createElement(Y,W({},o,{id:y,baseLine:x,connectNulls:I,stroke:"none",className:"recharts-area-area",layout:v})),L=u!=="none"&&l.createElement(Y,W({},g,{className:"recharts-area-curve",layout:v,type:o.type,connectNulls:I,fill:"none",stroke:u,points:o.points})),k=u!=="none"&&d&&Array.isArray(x)&&l.createElement(Y,W({},g,{className:"recharts-area-curve",layout:v,type:o.type,connectNulls:I,fill:"none",stroke:u,points:x}));if(c&&(r||t<1)){var h;return l.createElement(M,null,l.createElement("defs",null,l.createElement("clipPath",{id:f},l.createElement(ja,{alpha:t,points:(h=o.points)!==null&&h!==void 0?h:[],baseLine:x,layout:v,strokeWidth:o.strokeWidth}))),l.createElement(M,{clipPath:"url(#".concat(f,")")},S,L,k))}return l.createElement(l.Fragment,null,S,L,k)}var wa=["id"],Da=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function V(){return V=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var i in t)({}).hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},V.apply(null,arguments)}function xe(e,a){if(e==null)return{};var t,i,r=Ra(e,a);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(i=0;i<n.length;i++)t=n[i],a.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}function Ra(e,a){if(e==null)return{};var t={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(a.indexOf(i)!==-1)continue;t[i]=e[i]}return t}function ne(e,a){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);a&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,i)}return t}function w(e){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?arguments[a]:{};a%2?ne(Object(t),!0).forEach(function(i){Wa(e,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ne(Object(t)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))})}return e}function Wa(e,a,t){return(a=Ba(a))in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}function Ba(e){var a=Ta(e,"string");return typeof a=="symbol"?a:a+""}function Ta(e,a){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var i=t.call(e,a);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(e)}var Ka=(e,a)=>e==null?[]:a===1?e.flatMap(t=>t.status==="removed"?[]:[t.next]):e.flatMap(t=>t.status==="matched"?[w(w({},t.next),{},{x:F(t.prev.x,t.next.x,a),y:F(t.prev.y,t.next.y,a)})]:t.status==="added"?[t.next]:[]),Ae={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",animationMatchBy:We,animationInterpolateFn:Ka,connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,shape:Oa,xAxisId:0,yAxisId:0,zIndex:Re.area};function $(e,a){return e&&e!=="none"?e:a}var Ma=e=>{var a=e.dataKey,t=e.name,i=e.stroke,r=e.fill,n=e.legendType,c=e.hide;return[{inactive:c,dataKey:a,type:n,color:$(i,r),value:ue(t,a),payload:e}]},za=l.memo(e=>{var a=e.dataKey,t=e.data,i=e.stroke,r=e.strokeWidth,n=e.fill,c=e.name,s=e.hide,d=e.unit,u=e.formatter,p=e.tooltipType,o=e.id,v={dataDefinedOnItem:t,getPosition:Fe,settings:{stroke:i,strokeWidth:r,fill:n,dataKey:a,nameKey:void 0,name:ue(c,a),hide:s,type:p,color:$(i,n),unit:d,formatter:u,graphicalItemId:o}};return l.createElement(ze,{tooltipEntrySettings:v})});function Fa(e){var a=e.clipPathId,t=e.points,i=e.props,r=i.needClip,n=i.dot,c=i.dataKey,s=ce(i);return l.createElement(fa,{points:t,dot:n,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:c,baseProps:s,needClip:r,clipPathId:a})}function Va(e){var a=e.showLabels,t=e.children,i=e.points,r=i.map(n=>{var c,s,d={x:(c=n.x)!==null&&c!==void 0?c:0,y:(s=n.y)!==null&&s!==void 0?s:0,width:0,lowerWidth:0,upperWidth:0,height:0};return w(w({},d),{},{value:n.value,payload:n.payload,parentViewBox:void 0,viewBox:d,fill:void 0})});return l.createElement(ta,{value:a?r:void 0},t)}function $a(e){var a=e.points,t=e.baseLine,i=e.needClip,r=e.clipPathId,n=e.props,c=e.animationElapsedTime,s=e.isAnimating,d=e.isEntrance,u=n.layout,p=n.type,o=n.stroke,v=n.connectNulls,I=n.isRange,f=n.shape,y=n.id,x=xe(n,wa),A=ia(x),g=w(w({},A),{},{id:y,points:a,connectNulls:v,type:p,baseLine:t,layout:u,stroke:o,isRange:I,animationElapsedTime:c,isAnimating:s,isEntrance:d});return l.createElement(l.Fragment,null,(a==null?void 0:a.length)>1&&l.createElement(M,{clipPath:i?"url(#clipPath-".concat(r,")"):void 0},l.createElement(na,{option:f,DefaultShape:Ae.shape,shapeProps:g})),l.createElement(Fa,{points:a,props:x,clipPathId:r}))}function Ga(e,a,t){if(j(e)){var i=j(a)?a:void 0;return F(i,e,t)}if(ra(e)||sa(e)){var r=j(a)?a:void 0;return F(r,0,t)}return e}function Xa(e){var a=e.needClip,t=e.clipPathId,i=e.props,r=e.previousPointsRef,n=e.previousBaselineRef,c=i.points,s=i.baseLine,d=i.isAnimationActive,u=i.animationBegin,p=i.animationDuration,o=i.animationEasing,v=i.animationMatchBy,I=i.animationInterpolateFn,f=l.useMemo(()=>({points:c,baseLine:s}),[c,s]),y=Qe(f,n),x=Je(),A=_e(i.onAnimationStart,i.onAnimationEnd),g=A.isAnimating,S=A.handleAnimationStart,L=A.handleAnimationEnd,k=y.startValue;if(x==null)return null;var h;return Array.isArray(s)&&Array.isArray(k)?h=ae(k,s,v):Array.isArray(s)?h=ae(null,s,v):h=null,l.createElement(ea,{animationInput:f,animationIdPrefix:"recharts-area-",items:c,previousItemsRef:r,isAnimationActive:d,animationBegin:u,animationDuration:p,animationEasing:o,onAnimationStart:S,onAnimationEnd:L,animationInterpolateFn:I,animationMatchBy:v,layout:x},(P,b,C)=>{var E;return b===1?E=s:Array.isArray(s)?E=I(h,b,x):E=C?s:Ga(s,k,b),y.syncStepValue(E,b),l.createElement(Va,{showLabels:!g,points:c},i.children,l.createElement($a,{points:P,baseLine:E,needClip:a,clipPathId:t,props:i,animationElapsedTime:b,isAnimating:g||b<1,isEntrance:C}),l.createElement(aa,{label:i.label}))})}function Ya(e){var a=e.needClip,t=e.clipPathId,i=e.props,r=l.useRef(null),n=l.useRef();return l.createElement(Xa,{needClip:a,clipPathId:t,props:i,previousPointsRef:r,previousBaselineRef:n})}class Ha extends l.PureComponent{render(){var a=this.props,t=a.hide,i=a.dot,r=a.points,n=a.className,c=a.top,s=a.left,d=a.needClip,u=a.xAxisId,p=a.yAxisId,o=a.width,v=a.height,I=a.id,f=a.baseLine,y=a.zIndex;if(t)return null;var x=He("recharts-area",n),A=I,g=va(i),S=g.r,L=g.strokeWidth,k=qe(i),h=S*2+L,P=d?"url(#clipPath-".concat(k?"":"dots-").concat(A,")"):void 0;return l.createElement(Ue,{zIndex:y},l.createElement(M,{className:x},d&&l.createElement("defs",null,l.createElement(Ze,{clipPathId:A,xAxisId:u,yAxisId:p}),!k&&l.createElement("clipPath",{id:"clipPath-dots-".concat(A)},l.createElement("rect",{x:s-h/2,y:c-h/2,width:o+h,height:v+h}))),l.createElement(Ya,{needClip:d,clipPathId:A,props:this.props})),l.createElement(te,{points:r,mainColor:$(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:P}),this.props.isRange&&Array.isArray(f)&&l.createElement(te,{points:f,mainColor:$(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:P}))}}function qa(e){var a,t=e.activeDot,i=e.animationBegin,r=e.animationDuration,n=e.animationEasing,c=e.connectNulls,s=e.dot,d=e.fill,u=e.fillOpacity,p=e.hide,o=e.isAnimationActive,v=e.legendType,I=e.stroke,f=e.xAxisId,y=e.yAxisId,x=xe(e,Da),A=Ve(),g=$e(),S=Ge(f,y),L=S.needClip,k=de(),h=(a=Xe(G=>Pa(G,e.id,k)))!==null&&a!==void 0?a:{},P=h.points,b=h.isRange,C=h.baseLine,E=Ye();if(A!=="horizontal"&&A!=="vertical"||E==null||g!=="AreaChart"&&g!=="ComposedChart")return null;var N=E.height,D=E.width,R=E.x,T=E.y;return!P||!P.length?null:l.createElement(Ha,V({},x,{activeDot:t,animationBegin:i,animationDuration:r,animationEasing:n,baseLine:C,connectNulls:c,dot:s,fill:d,fillOpacity:u,height:N,hide:p,layout:A,isAnimationActive:o,isRange:b,legendType:v,needClip:L,points:P,stroke:I,width:D,left:R,top:T,xAxisId:f,yAxisId:y}))}var Ua=(e,a,t,i,r)=>{var n=t??a;if(j(n))return n;var c=e==="horizontal"?r:i,s=c.scale.domain();if(c.type==="number"){var d=Math.max(s[0],s[1]),u=Math.min(s[0],s[1]);return n==="dataMin"?u:n==="dataMax"||d<0?d:Math.max(Math.min(s[0],s[1]),0)}return n==="dataMin"?s[0]:n==="dataMax"?s[1]:s[0]};function Za(e){var a=e.areaSettings,t=a.connectNulls,i=a.baseValue,r=a.dataKey,n=e.stackedData,c=e.layout,s=e.chartBaseValue,d=e.xAxis,u=e.yAxis,p=e.displayedData,o=e.dataStartIndex,v=e.xAxisTicks,I=e.yAxisTicks,f=e.bandSize,y=e.stackDataKeys,x=n&&n.length,A=Ua(c,s,i,d,u),g=c==="horizontal",S=!1,L=p.map((h,P)=>{var b,C,E,N;if(x)N=n[o+P];else{var D=H(h,r);Array.isArray(D)?(N=D,S=!0):N=[A,D]}var R=(b=(C=N)===null||C===void 0?void 0:C[1])!==null&&b!==void 0?b:null,T=H(h,r),G=x&&T==null&&y!=null&&y.length>0&&y.every(ke=>H(h,ke)==null),J=R==null||x&&!t&&T==null||G;if(g){var X;return{x:ee({axis:d,ticks:v,bandSize:f,entry:h,index:P}),y:J?null:(X=u.scale.map(R))!==null&&X!==void 0?X:null,value:N,payload:h}}return{x:J?null:(E=d.scale.map(R))!==null&&E!==void 0?E:null,y:ee({axis:u,ticks:I,bandSize:f,entry:h,index:P}),value:N,payload:h}}),k;return x||S?k=L.map(h=>{var P,b=Array.isArray(h.value)?h.value[0]:null;if(g){var C;return{x:h.x,y:b!=null&&h.y!=null&&(C=u.scale.map(b))!==null&&C!==void 0?C:null,payload:h.payload}}return{x:b!=null&&(P=d.scale.map(b))!==null&&P!==void 0?P:null,y:h.y,payload:h.payload}}):k=g?u.scale.map(A):d.scale.map(A),{points:L,baseLine:k??0,isRange:S}}function Qa(e){var a=De(e,Ae),t=de();return l.createElement(Be,{id:a.id,type:"area"},i=>l.createElement(l.Fragment,null,l.createElement(Te,{legendPayload:Ma(a)}),l.createElement(za,{dataKey:a.dataKey,data:a.data,stroke:a.stroke,strokeWidth:a.strokeWidth,fill:a.fill,name:a.name,hide:a.hide,unit:a.unit,formatter:a.formatter,tooltipType:a.tooltipType,id:i}),l.createElement(Ke,{type:"area",id:i,data:a.data,dataKey:a.dataKey,xAxisId:a.xAxisId,yAxisId:a.yAxisId,zAxisId:0,stackId:Me(a.stackId),hide:a.hide,barSize:void 0,baseValue:a.baseValue,isPanorama:t,connectNulls:a.connectNulls}),l.createElement(qa,V({},a,{id:i}))))}var ge=l.memo(Qa,we);ge.displayName="Area";function re(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(Math.round(e))}function Ja(e){if(e.length<3)return null;const a=e.map(r=>r.cache_creation_tokens),t=a.reduce((r,n)=>r+n,0)/a.length,i=a.reduce((r,n)=>r+(n-t)**2,0)/a.length;return t+2*Math.sqrt(i)}function _a(e,a){const t=new Set(a);return e.map(i=>({...i,spike_value:t.has(i.bucket)?i.cache_creation_tokens:null}))}const et="insideTopLeft";function ct({state:e}){const a=Ie(),[t,i]=l.useState(!0),r=!a&&t;if(l.useEffect(()=>{e.status==="ok"&&e.value.data!==null&&i(!1)},[e]),e.status==="loading")return m.jsx("div",{className:"card","aria-busy":"true","aria-label":"Loading cache write spike chart",children:m.jsx(Pe,{})});if(e.status==="error")return m.jsxs("div",{className:"card",children:[m.jsx("div",{className:"kpi-off",children:"N/A"}),m.jsx("div",{className:"kpi-off-hint",children:"Cache write timeline unavailable"})]});const n=e.value.data;if(n===null||n.buckets.length===0)return m.jsxs("div",{className:"card",children:[m.jsx("div",{className:"section-head",children:m.jsx("h2",{children:"Cache writes over time · spike = likely miss event"})}),m.jsx("div",{className:"banner banner-info",children:m.jsx("span",{children:"No cache write data in this window."})})]});const{buckets:c,spike_buckets:s}=n,d=Ja(c),u=_a(c,s),p=u.some(o=>o.spike_value!==null);return m.jsxs("div",{className:"card",children:[m.jsxs("div",{className:"section-head",children:[m.jsx("h2",{children:"Cache writes over time · spike = likely miss event"}),m.jsx("div",{className:"chips",children:m.jsx(be,{kind:"LIST_EQUIV"})})]}),m.jsx("p",{className:"kpi-fn",style:{marginBottom:4},children:"Rising writes vs reads signals cache misses (A1 §09 · D8 companion view)"}),m.jsx("p",{className:"kpi-fn",style:{color:"var(--amber, #f39c12)",marginBottom:8},children:"⚠ TTL 5m/1h volatile · Spike threshold is TTL-sensitive · active TTL unknown (run /usage to confirm)"}),m.jsx(la,{width:"100%",height:220,children:m.jsxs(ha,{data:u,margin:{top:4,right:20,bottom:4,left:8},children:[m.jsx("defs",{children:m.jsxs("linearGradient",{id:"cache-write-gradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[m.jsx("stop",{offset:"0%",stopColor:K[1],stopOpacity:.24}),m.jsx("stop",{offset:"100%",stopColor:K[1],stopOpacity:0})]})}),m.jsx(oa,{...O.grid}),m.jsx(ca,{dataKey:"bucket",axisLine:O.axisLine,tickLine:O.tickLine,tickCount:O.tickCount,interval:"preserveStartEnd",tick:{fontSize:11},tickFormatter:o=>o.slice(5)}),m.jsx(da,{axisLine:O.axisLine,tickLine:O.tickLine,tickFormatter:re,tick:{fontSize:11}}),m.jsx(ua,{content:m.jsx(pa,{labelFormatter:o=>`Bucket: ${String(o??"")}`,nameFormatter:o=>o==="cache_creation_tokens"?"cache writes":o==="spike_value"?"spike (miss event)":String(o??"Value"),valueFormatter:o=>typeof o=="number"?re(o):String(o??"N/A")})}),m.jsx(ma,{formatter:o=>o==="cache_creation_tokens"?"cache writes":o}),m.jsx(ge,{dataKey:"cache_creation_tokens",type:"step",fill:"url(#cache-write-gradient)",stroke:K[1],dot:!1,isAnimationActive:r}),d!==null&&m.jsx(ya,{y:d,stroke:"var(--red, #e74c3c)",strokeDasharray:"4 4",label:{value:"spike threshold",position:et,offset:8,fontSize:11}}),p&&m.jsx(xa,{dataKey:"spike_value",fill:K[4],name:"spike (miss event)",isAnimationActive:r})]})})]})}export{et as SPIKE_THRESHOLD_LABEL_POSITION,_a as buildCacheWriteChartRows,ct as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as a}from"./index-DRhoA51c.js";const s={LIST_EQUIV:"chip-list-equiv",LIST_EQUIV_STALE:"chip-stale",PROXY:"chip-proxy",OBS_PROXY:"chip-obs-proxy",EXPERIMENTAL:"chip-experimental",DIRECTIONAL:"chip-directional",N_A:"chip-na",EXACT:"chip-exact",LIVE:"chip-live",MODELED:"chip-modeled",PASS:"chip-exact",ATTENTION:"chip-stale",NO_DATA:"chip-na",VERIFIED_SOURCE:"chip-list-equiv"},i={LIST_EQUIV:"LIST_EQUIV",LIST_EQUIV_STALE:"STALE",PROXY:"PROXY",OBS_PROXY:"OBS PROXY ±9% BPE",EXPERIMENTAL:"EXPERIMENTAL",DIRECTIONAL:"DIRECTIONAL",N_A:"N/A",EXACT:"EXACT",LIVE:"LIVE",MODELED:"MODELED",PASS:"PASS",ATTENTION:"ATTENTION",NO_DATA:"NO DATA",VERIFIED_SOURCE:"VERIFIED SOURCE"},o={LIST_EQUIV:"LIST_EQUIV: modeled USD equivalent using list pricing; not billed spend.",OBS_PROXY:"OBS_PROXY: observed token usage with an approximate BPE conversion.",EXPERIMENTAL:"EXPERIMENTAL: directional evidence from a methodology that is still under validation.",DIRECTIONAL:"DIRECTIONAL: coarse band derived from observed counts — not a precision score. Thresholds are declared in the friction tooltip.",EXACT:"EXACT: directly measured from observed session data.",PROXY:"PROXY: derived estimate used where direct measurement is unavailable.",MODELED:"MODELED: projected outcome from a model, not achieved savings.",N_A:"N/A: metric is defined, but no value is available.",LIVE:"LIVE: session is currently active.",LIST_EQUIV_STALE:"STALE: list-price equivalent based on pricing data that may be outdated.",PASS:"PASS: this practice is being followed based on the current measurement signal.",ATTENTION:"ATTENTION: this practice may need review — the signal is outside its declared threshold.",NO_DATA:"NO DATA: not enough signal in this window to evaluate this practice.",VERIFIED_SOURCE:"VERIFIED SOURCE: this citation links to the Anthropic documentation or blog post the practice is grounded in."};function r({kind:e,label:t,title:E}){return a.jsx("span",{className:`chip ${s[e]}`,role:"status","aria-label":i[e],title:E??o[e],children:t??i[e]})}export{r as C,o as K};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as a}from"./index-DRhoA51c.js";import{a7 as o,a8 as t}from"./chart-theme-JH5aQymO.js";var p=["axis"],l=a.forwardRef((r,e)=>a.createElement(o,{chartName:"ComposedChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:p,tooltipPayloadSearcher:t,categoricalChartProps:r,ref:e}));export{l as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./index-
|
|
1
|
+
import{j as t}from"./index-DRhoA51c.js";const s={alignItems:"flex-start",background:"var(--panel2)",border:"1px dashed var(--line)",borderRadius:8,color:"var(--text)",display:"flex",flexDirection:"column",gap:6,padding:"20px 16px",textAlign:"left"},l={background:"var(--panel)",border:"1px solid var(--line)",borderRadius:999,color:"var(--text)",cursor:"copy",fontFamily:"var(--mono)",fontSize:12,padding:"4px 8px"};function p({headline:a,why:o,whatWillAppear:r,command:e}){const i=n=>{typeof navigator>"u"||navigator.clipboard===void 0||navigator.clipboard.writeText(n).catch(()=>{})};return t.jsxs("section",{className:"empty-state onboarding-empty-state",style:s,"aria-live":"polite",children:[t.jsx("h2",{style:{fontSize:14,margin:0},children:a}),t.jsx("p",{className:"empty-state-text",style:{margin:0},children:o}),t.jsx("p",{className:"empty-state-text",style:{margin:0},children:r}),e!==void 0&&t.jsx("button",{type:"button",className:"empty-state-command",style:l,onClick:()=>i(e),"aria-label":`Copy command: ${e}`,title:"Copy command",children:t.jsx("code",{children:e})})]})}export{p as E};
|