@coreplane/switchboard 1.242.0 → 1.243.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/config/config.example.yaml +20 -1
- package/dist/assets/deploy/cloudflare-memory/worker.ts +86 -29
- package/dist/assets/deploy/cloudflare-resident/worker.ts +105 -13
- package/dist/assets/package-lock.json +3 -3
- package/dist/assets/package.json +1 -1
- package/dist/assets/project.json +3 -3
- package/dist/assets/source.json +3 -3
- package/dist/assets/src/agents/registry.ts +30 -34
- package/dist/assets/src/config/profile.ts +68 -3
- package/dist/assets/src/core/authz/policy.ts +4 -0
- package/dist/assets/src/core/budgets.ts +313 -0
- package/dist/assets/src/core/coordinator/driver.ts +0 -10
- package/dist/assets/src/core/costs.ts +9 -76
- package/dist/assets/src/core/modelPricing.ts +212 -0
- package/dist/assets/src/core/prDescriptionTypes.ts +29 -24
- package/dist/assets/src/core/reviewVerdict.ts +7 -0
- package/dist/assets/src/core/runEvents.ts +28 -4
- package/dist/assets/src/core/runFriction.ts +2 -1
- package/dist/assets/src/core/runRecord.ts +47 -0
- package/dist/assets/src/core/runUsage.ts +158 -47
- package/dist/assets/src/core/schedules.ts +3 -0
- package/dist/assets/src/core/ship/coordinator.ts +101 -84
- package/dist/assets/src/core/ship/handoff.ts +9 -0
- package/dist/assets/src/execution/bashTimeout.ts +8 -5
- package/dist/assets/src/execution/residentRefresh.ts +28 -3
- package/dist/assets/src/execution/residentSteps.ts +1 -1
- package/dist/assets/web/dist/.vite/manifest.json +67 -64
- package/dist/assets/web/dist/assets/CostsPage-CwXOmkeQ.js +2 -0
- package/dist/assets/web/dist/assets/HomePage-PRxjQiGG.js +2 -0
- package/dist/assets/web/dist/assets/PendingTurnRow-BT9RhFZ7.js +1 -0
- package/dist/assets/web/dist/assets/{ResidentDetailPage-DTMBgnIW.js → ResidentDetailPage-DACalNVF.js} +1 -1
- package/dist/assets/web/dist/assets/ResidentsIndexPage-SHPdu6uZ.js +1 -0
- package/dist/assets/web/dist/assets/RunFoldRow-0SdOmOr5.js +1 -0
- package/dist/assets/web/dist/assets/RunRoutePage-BaFS2p8I.js +9 -0
- package/dist/assets/web/dist/assets/RunsIndexPage-DYI-iALj.js +1 -0
- package/dist/assets/web/dist/assets/ScheduledPage-DJ8HiCPt.js +1 -0
- package/dist/assets/web/dist/assets/{SettingsPage-BIGio8Y0.js → SettingsPage-DLiN5IgY.js} +1 -1
- package/dist/assets/web/dist/assets/{StatusDot-ELoXHlFt.js → StatusDot-Dw0T1M-P.js} +1 -1
- package/dist/assets/web/dist/assets/{Tooltip-BoeFwYP2.js → Tooltip-BbLuIAiS.js} +1 -1
- package/dist/assets/web/dist/assets/UnitRoutePage-DicUG96U.js +1 -0
- package/dist/assets/web/dist/assets/{dist-BU5UivXC.js → dist-twkFmSUY.js} +1 -1
- package/dist/assets/web/dist/assets/format-BldUwl_R.js +1 -0
- package/dist/assets/web/dist/assets/indexRow-B_s5tKyq.js +1 -0
- package/dist/assets/web/dist/assets/{main-B2fX10aW.css → main-B4kEF3Sg.css} +1 -1
- package/dist/assets/web/dist/assets/{main-D4EA1g6n.js → main-d-w-tIKt.js} +2 -2
- package/dist/assets/web/dist/assets/{sseReplay-g7ml86LM.js → sseReplay-C9m_EB8J.js} +4 -4
- package/dist/cli.js +2758 -1445
- package/package.json +1 -1
- package/dist/assets/web/dist/assets/CostsPage-CtmKhhOF.js +0 -2
- package/dist/assets/web/dist/assets/HomePage-QtH1EwYF.js +0 -2
- package/dist/assets/web/dist/assets/PendingTurnRow-BZA_vQt3.js +0 -1
- package/dist/assets/web/dist/assets/ResidentsIndexPage-CaDvXhzJ.js +0 -1
- package/dist/assets/web/dist/assets/RunFoldRow-mgyLW0oV.js +0 -1
- package/dist/assets/web/dist/assets/RunRoutePage-DypJYMQa.js +0 -6
- package/dist/assets/web/dist/assets/RunsIndexPage-DYraPoWD.js +0 -1
- package/dist/assets/web/dist/assets/ScheduledPage-DXD2gLJk.js +0 -1
- package/dist/assets/web/dist/assets/UnitRoutePage-jhCrWW3i.js +0 -1
- package/dist/assets/web/dist/assets/indexRow-BD1VT8o8.js +0 -1
- package/dist/assets/web/dist/assets/localIso-L06jV29p.js +0 -1
|
@@ -2,28 +2,31 @@
|
|
|
2
2
|
// one set of bounds, shared by the tool layer, every executor, and both deploy
|
|
3
3
|
// Workers (which import from src/execution like shellQuote/residentDetach).
|
|
4
4
|
// Deliberately free of node: imports so wrangler can bundle it into Workers.
|
|
5
|
+
// The numbers are rows of src/core/budgets.ts (docs/decisions/0046); this file
|
|
6
|
+
// keeps their names for the readers that learned them here.
|
|
7
|
+
import { ALLOWANCES, BASH_COMMAND, MINUTE_MS } from "../core/budgets.js";
|
|
5
8
|
|
|
6
9
|
/** Default per-command budget when the caller passes no timeoutMs. */
|
|
7
|
-
export const BASH_TIMEOUT_MS =
|
|
10
|
+
export const BASH_TIMEOUT_MS = BASH_COMMAND.defaultMinutes * MINUTE_MS;
|
|
8
11
|
|
|
9
12
|
/** Floor: anything lower is a typo or an attack, not a budget. */
|
|
10
|
-
export const BASH_TIMEOUT_MIN_MS =
|
|
13
|
+
export const BASH_TIMEOUT_MIN_MS = BASH_COMMAND.minMs;
|
|
11
14
|
|
|
12
15
|
/** Hard ceiling a caller can raise the budget to. Not by itself a guarantee
|
|
13
16
|
* against one command eating a run — 20 minutes is 80% of a 25-minute review
|
|
14
17
|
* — which is what `bashBudgetWithinRun` below is for. */
|
|
15
|
-
export const BASH_TIMEOUT_MAX_MS =
|
|
18
|
+
export const BASH_TIMEOUT_MAX_MS = BASH_COMMAND.maxMinutes * MINUTE_MS;
|
|
16
19
|
|
|
17
20
|
/** Wall clock a run keeps back from its last command for the write-up: the
|
|
18
21
|
* runner's deadline forces a final answer, and a command still running at
|
|
19
22
|
* that moment would have been wasted anyway. */
|
|
20
|
-
export const RUN_DEADLINE_RESERVE_MS =
|
|
23
|
+
export const RUN_DEADLINE_RESERVE_MS = ALLOWANCES.commandWriteUp * MINUTE_MS;
|
|
21
24
|
|
|
22
25
|
/** Margin the remote exec clients add to their HTTP wait over the command
|
|
23
26
|
* budget, so the server's own timeout answer (a streamed exit 124) wins the
|
|
24
27
|
* race against the client's transport deadline instead of both firing at the
|
|
25
28
|
* same instant. */
|
|
26
|
-
export const EXEC_CALL_MARGIN_MS =
|
|
29
|
+
export const EXEC_CALL_MARGIN_MS = ALLOWANCES.execCall * MINUTE_MS;
|
|
27
30
|
|
|
28
31
|
/** The documented clamp rule, applied identically bot-side and server-side
|
|
29
32
|
* (a server never trusts the client's number): a finite number is truncated
|
|
@@ -209,9 +209,34 @@ const INTERRUPTION_SIGNATURE = /\bexit 143\b|Session terminated|SIGTERM|^restore
|
|
|
209
209
|
* exec path and the refresh classifier agree on one wording list (a container
|
|
210
210
|
* stop mid-snapshot produces "Process supervisor is closed"; classified as the
|
|
211
211
|
* repo's own `snapshot-failed` it would end the instance `degraded` instead of
|
|
212
|
-
* being retried into the same step).
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
* being retried into the same step).
|
|
213
|
+
*
|
|
214
|
+
* The list is the union of two a reader tells apart, because the resident's
|
|
215
|
+
* `/exec` answer treats them differently (resident-repos item 43): the SDK's
|
|
216
|
+
* words that vouch the runtime MOVED — a new incarnation serves the thread,
|
|
217
|
+
* so the container the command was aimed at is gone whatever else is known
|
|
218
|
+
* — and the platform's words for a container that is merely DOWN, which say
|
|
219
|
+
* nothing about a replacement: a stopped container answers "Process
|
|
220
|
+
* supervisor is closed" to a spawn, and the workerd binding answers "The
|
|
221
|
+
* container is not running" whether the container is asleep, starting, or
|
|
222
|
+
* gone under a roll. For the refresh classifier and `isRuntimeReplacement`
|
|
223
|
+
* the union is right: a step interrupted either way is retried onto the
|
|
224
|
+
* container that comes back. */
|
|
225
|
+
export const RUNTIME_MOVED_WORDING =
|
|
226
|
+
/previous runtime incarnation|interrupted because the runtime changed|runtime identity is no longer active|sandbox lifetime is no longer current|platform was updating the sandbox runtime|no longer identifies pid/i;
|
|
227
|
+
/** The platform's words for a container that is down under a command (see
|
|
228
|
+
* `RUNTIME_MOVED_WORDING`): the spawn refusal of a stopped container and the
|
|
229
|
+
* binding's not-running refusal, anchored to the full phrase so a genuine
|
|
230
|
+
* crash ("container exited with unexpected exit code") and the readiness
|
|
231
|
+
* probe ("the container is not listening") never match. The harness's
|
|
232
|
+
* container seam reads the same two as a container down under its one more
|
|
233
|
+
* command — a wait, never a judgement (harness.md item 6). */
|
|
234
|
+
export const STOPPED_CONTAINER_WORDING =
|
|
235
|
+
/process supervisor is closed|container is not running, consider calling start/i;
|
|
236
|
+
export const RUNTIME_REPLACEMENT_WORDING = new RegExp(
|
|
237
|
+
`${RUNTIME_MOVED_WORDING.source}|${STOPPED_CONTAINER_WORDING.source}`,
|
|
238
|
+
"i",
|
|
239
|
+
);
|
|
215
240
|
|
|
216
241
|
/** `runtimeUnreachable` is the caller's word that the failure was the SDK's
|
|
217
242
|
* connect abort at the exec choke point (the Worker's typed check over the
|
|
@@ -49,7 +49,7 @@ export const RESIDENT_STEP_LABELS = {
|
|
|
49
49
|
"worktree-clean": "cleaning the worktree",
|
|
50
50
|
"clean-workspace": "cleaning the workspace",
|
|
51
51
|
"clean-before-restore": "cleaning before the restore",
|
|
52
|
-
"break-mirror": "removing the mirror's
|
|
52
|
+
"break-mirror": "removing the mirror's config (fault injection)",
|
|
53
53
|
"unmount-restores": "unmounting earlier restores",
|
|
54
54
|
"mirror-restore-extract": "extracting the mirror snapshot",
|
|
55
55
|
"checkout-restore-extract": "extracting the checkout snapshot",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"src": "../node_modules/@fontsource-variable/jetbrains-mono/files/jetbrains-mono-vietnamese-wght-normal.woff2"
|
|
29
29
|
},
|
|
30
30
|
"../node_modules/@pierre/diffs/dist/index.js": {
|
|
31
|
-
"file": "assets/dist-
|
|
31
|
+
"file": "assets/dist-twkFmSUY.js",
|
|
32
32
|
"name": "dist",
|
|
33
33
|
"src": "../node_modules/@pierre/diffs/dist/index.js",
|
|
34
34
|
"isDynamicEntry": true,
|
|
@@ -2554,28 +2554,30 @@
|
|
|
2554
2554
|
"_RunsTabs-BUfdk0lH.js"
|
|
2555
2555
|
]
|
|
2556
2556
|
},
|
|
2557
|
-
"_PendingTurnRow-
|
|
2558
|
-
"file": "assets/PendingTurnRow-
|
|
2557
|
+
"_PendingTurnRow-BT9RhFZ7.js": {
|
|
2558
|
+
"file": "assets/PendingTurnRow-BT9RhFZ7.js",
|
|
2559
2559
|
"name": "PendingTurnRow",
|
|
2560
2560
|
"imports": [
|
|
2561
2561
|
"_AppShell-IDMGG6yi.js",
|
|
2562
2562
|
"_seed-DeKSHrt2.js",
|
|
2563
2563
|
"src/main.ts",
|
|
2564
|
-
"_indexRow-
|
|
2565
|
-
"
|
|
2564
|
+
"_indexRow-B_s5tKyq.js",
|
|
2565
|
+
"_format-BldUwl_R.js",
|
|
2566
|
+
"_sseReplay-C9m_EB8J.js"
|
|
2566
2567
|
]
|
|
2567
2568
|
},
|
|
2568
|
-
"_RunFoldRow-
|
|
2569
|
-
"file": "assets/RunFoldRow-
|
|
2569
|
+
"_RunFoldRow-0SdOmOr5.js": {
|
|
2570
|
+
"file": "assets/RunFoldRow-0SdOmOr5.js",
|
|
2570
2571
|
"name": "RunFoldRow",
|
|
2571
2572
|
"imports": [
|
|
2572
2573
|
"_AppShell-IDMGG6yi.js",
|
|
2573
2574
|
"_seed-DeKSHrt2.js",
|
|
2574
2575
|
"_indexFormat-B-pd4r7Y.js",
|
|
2575
|
-
"_indexRow-
|
|
2576
|
-
"
|
|
2576
|
+
"_indexRow-B_s5tKyq.js",
|
|
2577
|
+
"_format-BldUwl_R.js",
|
|
2577
2578
|
"_durationTone-BobbycC-.js",
|
|
2578
|
-
"
|
|
2579
|
+
"_sseReplay-C9m_EB8J.js",
|
|
2580
|
+
"_StatusDot-Dw0T1M-P.js"
|
|
2579
2581
|
]
|
|
2580
2582
|
},
|
|
2581
2583
|
"_RunsTabs-BUfdk0lH.js": {
|
|
@@ -2586,16 +2588,16 @@
|
|
|
2586
2588
|
"_seed-DeKSHrt2.js"
|
|
2587
2589
|
]
|
|
2588
2590
|
},
|
|
2589
|
-
"_StatusDot-
|
|
2590
|
-
"file": "assets/StatusDot-
|
|
2591
|
+
"_StatusDot-Dw0T1M-P.js": {
|
|
2592
|
+
"file": "assets/StatusDot-Dw0T1M-P.js",
|
|
2591
2593
|
"name": "StatusDot",
|
|
2592
2594
|
"imports": [
|
|
2593
2595
|
"_seed-DeKSHrt2.js",
|
|
2594
|
-
"_Tooltip-
|
|
2596
|
+
"_Tooltip-BbLuIAiS.js"
|
|
2595
2597
|
]
|
|
2596
2598
|
},
|
|
2597
|
-
"_Tooltip-
|
|
2598
|
-
"file": "assets/Tooltip-
|
|
2599
|
+
"_Tooltip-BbLuIAiS.js": {
|
|
2600
|
+
"file": "assets/Tooltip-BbLuIAiS.js",
|
|
2599
2601
|
"name": "Tooltip",
|
|
2600
2602
|
"imports": [
|
|
2601
2603
|
"_AppShell-IDMGG6yi.js",
|
|
@@ -2656,6 +2658,10 @@
|
|
|
2656
2658
|
"file": "assets/favicon-D1hkyC5j.js",
|
|
2657
2659
|
"name": "favicon"
|
|
2658
2660
|
},
|
|
2661
|
+
"_format-BldUwl_R.js": {
|
|
2662
|
+
"file": "assets/format-BldUwl_R.js",
|
|
2663
|
+
"name": "format"
|
|
2664
|
+
},
|
|
2659
2665
|
"_glsl-tRec3Fcu.js": {
|
|
2660
2666
|
"file": "assets/glsl-tRec3Fcu.js",
|
|
2661
2667
|
"name": "glsl",
|
|
@@ -2697,11 +2703,11 @@
|
|
|
2697
2703
|
"file": "assets/indexFormat-B-pd4r7Y.js",
|
|
2698
2704
|
"name": "indexFormat"
|
|
2699
2705
|
},
|
|
2700
|
-
"_indexRow-
|
|
2701
|
-
"file": "assets/indexRow-
|
|
2706
|
+
"_indexRow-B_s5tKyq.js": {
|
|
2707
|
+
"file": "assets/indexRow-B_s5tKyq.js",
|
|
2702
2708
|
"name": "indexRow",
|
|
2703
2709
|
"imports": [
|
|
2704
|
-
"
|
|
2710
|
+
"_format-BldUwl_R.js"
|
|
2705
2711
|
]
|
|
2706
2712
|
},
|
|
2707
2713
|
"_java-DL0gWf34.js": {
|
|
@@ -2732,10 +2738,6 @@
|
|
|
2732
2738
|
"_AppShell-IDMGG6yi.js"
|
|
2733
2739
|
]
|
|
2734
2740
|
},
|
|
2735
|
-
"_localIso-L06jV29p.js": {
|
|
2736
|
-
"file": "assets/localIso-L06jV29p.js",
|
|
2737
|
-
"name": "localIso"
|
|
2738
|
-
},
|
|
2739
2741
|
"_lua-DcMBATrl.js": {
|
|
2740
2742
|
"file": "assets/lua-DcMBATrl.js",
|
|
2741
2743
|
"name": "lua",
|
|
@@ -2792,14 +2794,14 @@
|
|
|
2792
2794
|
"_AppShell-IDMGG6yi.js"
|
|
2793
2795
|
]
|
|
2794
2796
|
},
|
|
2795
|
-
"_sseReplay-
|
|
2796
|
-
"file": "assets/sseReplay-
|
|
2797
|
+
"_sseReplay-C9m_EB8J.js": {
|
|
2798
|
+
"file": "assets/sseReplay-C9m_EB8J.js",
|
|
2797
2799
|
"name": "sseReplay",
|
|
2798
2800
|
"imports": [
|
|
2799
2801
|
"_seed-DeKSHrt2.js",
|
|
2800
2802
|
"_wallClock-61NpVkY6.js",
|
|
2801
|
-
"_indexRow-
|
|
2802
|
-
"
|
|
2803
|
+
"_indexRow-B_s5tKyq.js",
|
|
2804
|
+
"_format-BldUwl_R.js",
|
|
2803
2805
|
"_durationTone-BobbycC-.js"
|
|
2804
2806
|
]
|
|
2805
2807
|
},
|
|
@@ -2848,7 +2850,7 @@
|
|
|
2848
2850
|
]
|
|
2849
2851
|
},
|
|
2850
2852
|
"src/main.ts": {
|
|
2851
|
-
"file": "assets/main-
|
|
2853
|
+
"file": "assets/main-d-w-tIKt.js",
|
|
2852
2854
|
"name": "main",
|
|
2853
2855
|
"src": "src/main.ts",
|
|
2854
2856
|
"isEntry": true,
|
|
@@ -2869,7 +2871,7 @@
|
|
|
2869
2871
|
"_NotFoundPage-C97EhJcQ.js"
|
|
2870
2872
|
],
|
|
2871
2873
|
"css": [
|
|
2872
|
-
"assets/main-
|
|
2874
|
+
"assets/main-B4kEF3Sg.css"
|
|
2873
2875
|
],
|
|
2874
2876
|
"assets": [
|
|
2875
2877
|
"assets/instrument-sans-latin-ext-wght-normal-B5bTHO_g.woff2",
|
|
@@ -2882,7 +2884,7 @@
|
|
|
2882
2884
|
]
|
|
2883
2885
|
},
|
|
2884
2886
|
"src/pages/CostsPage.vue": {
|
|
2885
|
-
"file": "assets/CostsPage-
|
|
2887
|
+
"file": "assets/CostsPage-CwXOmkeQ.js",
|
|
2886
2888
|
"name": "CostsPage",
|
|
2887
2889
|
"src": "src/pages/CostsPage.vue",
|
|
2888
2890
|
"isDynamicEntry": true,
|
|
@@ -2908,76 +2910,77 @@
|
|
|
2908
2910
|
]
|
|
2909
2911
|
},
|
|
2910
2912
|
"src/pages/HomePage.vue": {
|
|
2911
|
-
"file": "assets/HomePage-
|
|
2913
|
+
"file": "assets/HomePage-PRxjQiGG.js",
|
|
2912
2914
|
"name": "HomePage",
|
|
2913
2915
|
"src": "src/pages/HomePage.vue",
|
|
2914
2916
|
"isDynamicEntry": true,
|
|
2915
2917
|
"imports": [
|
|
2916
2918
|
"_AppShell-IDMGG6yi.js",
|
|
2917
2919
|
"_seed-DeKSHrt2.js",
|
|
2918
|
-
"_Tooltip-
|
|
2919
|
-
"_PendingTurnRow-
|
|
2920
|
+
"_Tooltip-BbLuIAiS.js",
|
|
2921
|
+
"_PendingTurnRow-BT9RhFZ7.js",
|
|
2920
2922
|
"_eventSource-tRprhqm7.js",
|
|
2921
2923
|
"_wallClock-61NpVkY6.js",
|
|
2922
2924
|
"_favicon-D1hkyC5j.js",
|
|
2923
2925
|
"_indexFormat-B-pd4r7Y.js",
|
|
2924
|
-
"_indexRow-
|
|
2925
|
-
"
|
|
2926
|
-
"
|
|
2927
|
-
"
|
|
2926
|
+
"_indexRow-B_s5tKyq.js",
|
|
2927
|
+
"_format-BldUwl_R.js",
|
|
2928
|
+
"_durationTone-BobbycC-.js",
|
|
2929
|
+
"_sseReplay-C9m_EB8J.js"
|
|
2928
2930
|
]
|
|
2929
2931
|
},
|
|
2930
2932
|
"src/pages/ResidentDetailPage.vue": {
|
|
2931
|
-
"file": "assets/ResidentDetailPage-
|
|
2933
|
+
"file": "assets/ResidentDetailPage-DACalNVF.js",
|
|
2932
2934
|
"name": "ResidentDetailPage",
|
|
2933
2935
|
"src": "src/pages/ResidentDetailPage.vue",
|
|
2934
2936
|
"isDynamicEntry": true,
|
|
2935
2937
|
"imports": [
|
|
2936
2938
|
"_AppShell-IDMGG6yi.js",
|
|
2937
2939
|
"_seed-DeKSHrt2.js",
|
|
2938
|
-
"_StatusDot-
|
|
2940
|
+
"_StatusDot-Dw0T1M-P.js",
|
|
2939
2941
|
"_residentsModel-By1fThvk.js"
|
|
2940
2942
|
]
|
|
2941
2943
|
},
|
|
2942
2944
|
"src/pages/ResidentsIndexPage.vue": {
|
|
2943
|
-
"file": "assets/ResidentsIndexPage-
|
|
2945
|
+
"file": "assets/ResidentsIndexPage-SHPdu6uZ.js",
|
|
2944
2946
|
"name": "ResidentsIndexPage",
|
|
2945
2947
|
"src": "src/pages/ResidentsIndexPage.vue",
|
|
2946
2948
|
"isDynamicEntry": true,
|
|
2947
2949
|
"imports": [
|
|
2948
2950
|
"_AppShell-IDMGG6yi.js",
|
|
2949
2951
|
"_seed-DeKSHrt2.js",
|
|
2950
|
-
"_Tooltip-
|
|
2952
|
+
"_Tooltip-BbLuIAiS.js",
|
|
2951
2953
|
"_eventSource-tRprhqm7.js",
|
|
2952
2954
|
"_wallClock-61NpVkY6.js",
|
|
2953
2955
|
"_favicon-D1hkyC5j.js",
|
|
2954
2956
|
"_indexFormat-B-pd4r7Y.js",
|
|
2955
|
-
"_indexRow-
|
|
2956
|
-
"
|
|
2957
|
+
"_indexRow-B_s5tKyq.js",
|
|
2958
|
+
"_format-BldUwl_R.js",
|
|
2959
|
+
"_StatusDot-Dw0T1M-P.js",
|
|
2957
2960
|
"_residentsModel-By1fThvk.js"
|
|
2958
2961
|
]
|
|
2959
2962
|
},
|
|
2960
2963
|
"src/pages/RunRoutePage.vue": {
|
|
2961
|
-
"file": "assets/RunRoutePage-
|
|
2964
|
+
"file": "assets/RunRoutePage-BaFS2p8I.js",
|
|
2962
2965
|
"name": "RunRoutePage",
|
|
2963
2966
|
"src": "src/pages/RunRoutePage.vue",
|
|
2964
2967
|
"isDynamicEntry": true,
|
|
2965
2968
|
"imports": [
|
|
2966
2969
|
"_AppShell-IDMGG6yi.js",
|
|
2967
2970
|
"_seed-DeKSHrt2.js",
|
|
2968
|
-
"_Tooltip-
|
|
2969
|
-
"_PendingTurnRow-
|
|
2971
|
+
"_Tooltip-BbLuIAiS.js",
|
|
2972
|
+
"_PendingTurnRow-BT9RhFZ7.js",
|
|
2970
2973
|
"src/main.ts",
|
|
2971
2974
|
"_eventSource-tRprhqm7.js",
|
|
2972
2975
|
"_wallClock-61NpVkY6.js",
|
|
2973
2976
|
"_favicon-D1hkyC5j.js",
|
|
2974
2977
|
"_indexFormat-B-pd4r7Y.js",
|
|
2975
|
-
"_indexRow-
|
|
2976
|
-
"
|
|
2977
|
-
"_sseReplay-g7ml86LM.js",
|
|
2978
|
+
"_indexRow-B_s5tKyq.js",
|
|
2979
|
+
"_format-BldUwl_R.js",
|
|
2978
2980
|
"_durationTone-BobbycC-.js",
|
|
2981
|
+
"_sseReplay-C9m_EB8J.js",
|
|
2979
2982
|
"_NotFoundPage-C97EhJcQ.js",
|
|
2980
|
-
"_RunFoldRow-
|
|
2983
|
+
"_RunFoldRow-0SdOmOr5.js"
|
|
2981
2984
|
],
|
|
2982
2985
|
"dynamicImports": [
|
|
2983
2986
|
"../node_modules/@pierre/diffs/dist/index.js"
|
|
@@ -2987,55 +2990,55 @@
|
|
|
2987
2990
|
]
|
|
2988
2991
|
},
|
|
2989
2992
|
"src/pages/RunsIndexPage.vue": {
|
|
2990
|
-
"file": "assets/RunsIndexPage-
|
|
2993
|
+
"file": "assets/RunsIndexPage-DYI-iALj.js",
|
|
2991
2994
|
"name": "RunsIndexPage",
|
|
2992
2995
|
"src": "src/pages/RunsIndexPage.vue",
|
|
2993
2996
|
"isDynamicEntry": true,
|
|
2994
2997
|
"imports": [
|
|
2995
2998
|
"_AppShell-IDMGG6yi.js",
|
|
2996
2999
|
"_seed-DeKSHrt2.js",
|
|
2997
|
-
"_Tooltip-
|
|
3000
|
+
"_Tooltip-BbLuIAiS.js",
|
|
2998
3001
|
"_eventSource-tRprhqm7.js",
|
|
2999
3002
|
"_wallClock-61NpVkY6.js",
|
|
3000
3003
|
"_favicon-D1hkyC5j.js",
|
|
3001
3004
|
"_indexFormat-B-pd4r7Y.js",
|
|
3002
|
-
"_indexRow-
|
|
3003
|
-
"
|
|
3005
|
+
"_indexRow-B_s5tKyq.js",
|
|
3006
|
+
"_format-BldUwl_R.js",
|
|
3004
3007
|
"_durationTone-BobbycC-.js",
|
|
3005
3008
|
"_RunsTabs-BUfdk0lH.js",
|
|
3006
|
-
"_StatusDot-
|
|
3009
|
+
"_StatusDot-Dw0T1M-P.js"
|
|
3007
3010
|
]
|
|
3008
3011
|
},
|
|
3009
3012
|
"src/pages/ScheduledPage.vue": {
|
|
3010
|
-
"file": "assets/ScheduledPage-
|
|
3013
|
+
"file": "assets/ScheduledPage-DJ8HiCPt.js",
|
|
3011
3014
|
"name": "ScheduledPage",
|
|
3012
3015
|
"src": "src/pages/ScheduledPage.vue",
|
|
3013
3016
|
"isDynamicEntry": true,
|
|
3014
3017
|
"imports": [
|
|
3015
3018
|
"_AppShell-IDMGG6yi.js",
|
|
3016
3019
|
"_seed-DeKSHrt2.js",
|
|
3017
|
-
"_Tooltip-
|
|
3020
|
+
"_Tooltip-BbLuIAiS.js",
|
|
3018
3021
|
"_wallClock-61NpVkY6.js",
|
|
3019
3022
|
"_indexFormat-B-pd4r7Y.js",
|
|
3020
|
-
"
|
|
3023
|
+
"_format-BldUwl_R.js",
|
|
3021
3024
|
"_RunsTabs-BUfdk0lH.js"
|
|
3022
3025
|
]
|
|
3023
3026
|
},
|
|
3024
3027
|
"src/pages/SettingsPage.vue": {
|
|
3025
|
-
"file": "assets/SettingsPage-
|
|
3028
|
+
"file": "assets/SettingsPage-DLiN5IgY.js",
|
|
3026
3029
|
"name": "SettingsPage",
|
|
3027
3030
|
"src": "src/pages/SettingsPage.vue",
|
|
3028
3031
|
"isDynamicEntry": true,
|
|
3029
3032
|
"imports": [
|
|
3030
3033
|
"_AppShell-IDMGG6yi.js",
|
|
3031
3034
|
"_seed-DeKSHrt2.js",
|
|
3032
|
-
"_Tooltip-
|
|
3035
|
+
"_Tooltip-BbLuIAiS.js",
|
|
3033
3036
|
"_settingsApi-priOPiwu.js",
|
|
3034
|
-
"_indexRow-
|
|
3037
|
+
"_indexRow-B_s5tKyq.js"
|
|
3035
3038
|
]
|
|
3036
3039
|
},
|
|
3037
3040
|
"src/pages/UnitRoutePage.vue": {
|
|
3038
|
-
"file": "assets/UnitRoutePage-
|
|
3041
|
+
"file": "assets/UnitRoutePage-DicUG96U.js",
|
|
3039
3042
|
"name": "UnitRoutePage",
|
|
3040
3043
|
"src": "src/pages/UnitRoutePage.vue",
|
|
3041
3044
|
"isDynamicEntry": true,
|
|
@@ -3044,11 +3047,11 @@
|
|
|
3044
3047
|
"_seed-DeKSHrt2.js",
|
|
3045
3048
|
"_wallClock-61NpVkY6.js",
|
|
3046
3049
|
"_indexFormat-B-pd4r7Y.js",
|
|
3047
|
-
"
|
|
3048
|
-
"_sseReplay-g7ml86LM.js",
|
|
3050
|
+
"_format-BldUwl_R.js",
|
|
3049
3051
|
"_durationTone-BobbycC-.js",
|
|
3052
|
+
"_sseReplay-C9m_EB8J.js",
|
|
3050
3053
|
"_NotFoundPage-C97EhJcQ.js",
|
|
3051
|
-
"_RunFoldRow-
|
|
3054
|
+
"_RunFoldRow-0SdOmOr5.js"
|
|
3052
3055
|
]
|
|
3053
3056
|
}
|
|
3054
3057
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./AppShell-IDMGG6yi.js";import{Ci as t,Lr as n,Lt as r,Qn as i,Vt as a,Xt as o,_n as s,ci as c,cn as l,gn as u,ir as d,ln as f,nr as p,on as m,r as h,sn as g,un as _,ur as v,vi as y,wi as b,xi as x,yn as S,zr as C}from"./seed-DeKSHrt2.js";import{d as w,f as T,l as E}from"./delivery-CTdOqpVK.js";import{t as D}from"./eventSource-tRprhqm7.js";import{i as ee}from"./settingsApi-priOPiwu.js";import{t as O}from"./wallClock-61NpVkY6.js";var k=`Durable Objects`;function te(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let n=t;if(n.type!==`status`||typeof n.everyHours!=`number`)return null;let{type:r,...i}=n;return i}var A=e=>e===`schedule`?`on schedule`:`by ${e}`;function j(e,t){let n=[];if(e.inFlight?(n.push(`Taking a snapshot now — started ${w(e.inFlight.startedAt,t)} ${A(e.inFlight.by)}`),e.snapshot&&n.push(`showing the one from ${E(e.snapshot.takenAt)} meanwhile`)):e.snapshot?(n.push(`Snapshot from ${E(e.snapshot.takenAt)}, ${w(e.snapshot.takenAt,t)} ${A(e.snapshot.takenBy)}`),e.nextAt&&n.push(`next ${T(e.nextAt,t)}`)):e.nextAt?n.push(`No snapshot yet — next attempt ${T(e.nextAt,t)}`):n.push(`No snapshot yet — the first one is taken within a minute of startup`),e.lastFailure&&!e.inFlight){let r=e.lastFailure.count>1?` (${e.lastFailure.count} in a row)`:``;n.push(`last attempt ${w(e.lastFailure.at,t)} failed${r}: ${e.lastFailure.message.slice(0,120)}`)}return n.join(` · `)}var M=`Workers · storage · R2`,N=`LLM (Anthropic)`,P=(e,t=2)=>`$${e.toFixed(t)}`,F=e=>e.workersUsd+e.doRowsUsd+e.doStorageUsd+e.r2Usd+e.workflowsUsd;function ne(e){let t=[];for(let n of e.days)for(let e of Object.keys(n.containers))t.includes(e)||t.push(e);return e.days.some(e=>Object.keys(e.durableObjects).length>0)&&t.push(k),e.days.some(e=>F(e)>0)&&t.push(M),e.llmAvailable&&t.push(N),t}function I(e,t){return t===`Durable Objects`?Object.values(e.durableObjects).reduce((e,t)=>e+t,0)+e.doRequestsUsd:t===`Workers · storage · R2`?F(e):t===`LLM (Anthropic)`?e.llmUsd:e.containers[t]?.total??0}var re=30.4;function ie(e){let t=e.range.partialLastDay?e.days.slice(0,-1):e.days,n=e.range.partialLastDay?e.days[e.days.length-1]:void 0,r=t[t.length-1],i=t.slice(-7),a=i.length?i.reduce((e,t)=>e+t.total,0)/i.length:void 0,o=e.account.cloudUsd>0?Math.round(e.totals.cloudUsd/e.account.cloudUsd*100):0;return{...r?{yesterday:{date:r.date,total:r.total}}:{},...n?{today:{date:n.date,total:n.total}}:{},...a===void 0?{}:{avg7:a},projection:R(e,t,n),llm:{range:e.totals.llmUsd,...r?{yesterday:r.llmUsd}:{},...n?{today:{usd:n.llmUsd,estimated:n.llmEstimated}}:{}},accountShare:o}}var L=e=>e.reduce((e,t)=>e+t,0)/e.length;function ae(e,t){let n=Date.parse(`${t.date}T00:00:00Z`),r=(e.generatedAt-n)/864e5;return Math.min(1,Math.max(1/24,Number.isFinite(r)?r:1))}function R(e,t,n){let r=n?ae(e,n):1,i=t.slice(-7),a=0,o=`full-days`;i.length?a=L(i.map(e=>e.cloudUsd)):n&&(a=n.cloudUsd/r,o=`today`);let s=0,c=`none`,l=0;if(e.llmAvailable){let e=t.findIndex(e=>e.llmUsd>0),i=e===-1?[]:t.slice(e).slice(-7);i.length?(s=L(i.map(e=>e.llmUsd)),c=`closed-days`,l=i.length):n&&n.llmUsd>0&&(s=n.llmUsd/r,c=`today`)}return{monthUsd:(a+s)*re,cloudRate:a,llmRate:s,cloudBasis:o,llmBasis:c,llmClosedDays:l}}function oe(e){let t=`https://dash.cloudflare.com/${e.account.id}`;return{account:t,billing:`${t}/billing`,containers:`${t}/workers/containers`,durableObjects:`${t}/workers/durable-objects`,workers:`${t}/workers-and-pages`,r2:`${t}/r2/overview`,workflows:`${t}/workers/workflows`,worker:e=>`${t}/workers/services/view/${encodeURIComponent(e)}/production/metrics`,bucket:e=>`${t}/r2/default/buckets/${encodeURIComponent(e)}`,anthropic:`https://platform.claude.com/cost`}}var se=e=>e.account.name??`${e.account.id.slice(0,8)}…`;function z(e,t,n){let r=[`${e.date} · total ${P(e.total)}${n?` (partial day)`:``}`];for(let n of t){let t=I(e,n);t<=0||r.push(`${n} ${P(t)}${n===`LLM (Anthropic)`&&e.llmEstimated?` (estimate)`:``}`)}return r.join(`
|
|
2
|
+
`)}function B(e){let t=new Date(`${e}T00:00:00Z`);return Number.isNaN(t.getTime())?e:`${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.getUTCMonth()]} ${t.getUTCDate()}`}function ce(e,t,n){let r=t.map(t=>({series:t,usd:I(e,t),estimated:t===`LLM (Anthropic)`&&e.llmEstimated})).filter(e=>e.usd>0).sort((e,t)=>t.usd-e.usd);return{date:e.date,label:B(e.date),partial:n,total:e.total,rows:r}}function V(e,t){let n={t:12,r:12,b:30,l:48},r=960-n.l-n.r,i=260-n.t-n.b,a=e.days,o=Math.max(1e-9,...a.map(e=>e.total))*1.08,s=r/Math.max(1,a.length),c=Math.min(10,s*.28),l=e=>n.t+i-e/o*i,u=Array.from({length:5},(e,t)=>{let n=o/4*t;return{y:Number(l(n).toFixed(1)),label:P(n)}}),d=[],f=[],p=[];return a.forEach((r,o)=>{let u=0,m=n.l+o*s+c/2,h=s-c;f.push({x:Number((n.l+o*s).toFixed(1)),y:n.t,width:Number(s.toFixed(1)),height:i,title:z(r,t,e.range.partialLastDay&&o===a.length-1),tip:ce(r,t,e.range.partialLastDay&&o===a.length-1)}),t.forEach((e,t)=>{let n=I(r,e);if(n<=0)return;let i=l(u+n),a=l(u),o=Math.max(0,a-i-2);d.push({seriesIndex:t,x:Number(m.toFixed(1)),y:Number(i.toFixed(1)),width:Number(h.toFixed(1)),height:Number(o.toFixed(1))}),u+=n}),(a.length<=16||o%Math.ceil(a.length/16)===0)&&p.push({x:Number((m+h/2).toFixed(1)),label:r.date.slice(5)})}),{width:960,height:260,gridLines:u,segments:d,dayHovers:f,dayLabels:p,axisY:Number(l(0).toFixed(1)),marginLeft:n.l,marginRight:n.r}}function le(e){let t=e.totals.byResource,n=[[`Memory (provisioned while awake)`,t.memory],[`vCPU (active use only)`,t.cpu],[`Durable Object duration + requests`,t.durableObjects],[`Disk (provisioned while awake)`,t.disk],[`Workers requests + CPU`,t.workers],[`Durable Object SQLite rows`,t.doRows],[`Durable Object SQLite storage`,t.doStorage],[`R2 storage + operations`,t.r2],[`Workflow steps + state`,t.workflows]],r=n.reduce((e,t)=>e+t[1],0)||1;return n.map(([e,t])=>({label:e,usd:t,percent:t/r*100}))}var H=[`fill-[#4478b8] dark:fill-[#7aa7e0]`,`fill-[#c8823b] dark:fill-[#e0a95a]`,`fill-[#4c8c57] dark:fill-[#6fae7a]`,`fill-[#b8963e] dark:fill-[#d4b45a]`,`fill-[#b0568c] dark:fill-[#d489b8]`,`fill-[#6b7bcc] dark:fill-[#98a5e6]`,`fill-[#d05252] dark:fill-[#e07a74]`,`fill-[#3e8e96] dark:fill-[#6fb9c0]`],ue=[`bg-[#4478b8] dark:bg-[#7aa7e0]`,`bg-[#c8823b] dark:bg-[#e0a95a]`,`bg-[#4c8c57] dark:bg-[#6fae7a]`,`bg-[#b8963e] dark:bg-[#d4b45a]`,`bg-[#b0568c] dark:bg-[#d489b8]`,`bg-[#6b7bcc] dark:bg-[#98a5e6]`,`bg-[#d05252] dark:bg-[#e07a74]`,`bg-[#3e8e96] dark:bg-[#6fb9c0]`],de={class:`overflow-x-auto`},U=[`viewBox`],W=[`x1`,`x2`,`y1`,`y2`],G=[`x`,`y`],K=[`x`,`y`,`width`,`height`],q=[`aria-label`,`x`,`y`,`width`,`height`,`onPointerenter`,`onPointermove`],J=[`x`,`y`],Y=[`x1`,`x2`,`y1`,`y2`],fe={class:`tip-head mb-1.5 flex items-baseline justify-between gap-3 border-b border-muted pb-1.5`},X={class:`font-medium text-highlighted`},pe={key:0,class:`ml-1.5 font-normal text-dimmed`},me={class:`font-medium text-highlighted`},he={class:`tip-name truncate text-muted`},ge={class:`text-highlighted`},_e={class:`tip-usd`},ve={key:0,class:`ml-1 text-dimmed`},Z=256,Q=12,ye=S({__name:`CostChart`,props:{report:{},series:{}},setup(e){let n=e,r=m(()=>V(n.report,n.series)),i=e=>44+e*20,a=c(null),s=c(null);function l(e,t){let n=s.value,r=n?.getBoundingClientRect(),o=t.clientX-(r?.left??0),c=t.clientY-(r?.top??0),l=n?.clientWidth??0,u=n?.clientHeight??0,d=i(e.tip.rows.length),f=l>0&&o+Q+Z>l,p=u>0&&c+Q+d>u;a.value={x:Math.max(0,f?o-Q-Z:o+Q),y:Math.max(0,p?c-Q-d:c+Q),data:e.tip}}return(e,n)=>(d(),_(`div`,{ref_key:`host`,ref:s,class:`chart-host relative`},[g(`div`,de,[(d(),_(`svg`,{class:`block h-auto w-full font-mono`,viewBox:`0 0 ${r.value.width} ${r.value.height}`,role:`img`,"aria-label":`Daily cost, stacked by component`},[(d(!0),_(o,null,v(r.value.gridLines,(e,t)=>(d(),_(o,{key:`g${t}`},[g(`line`,{class:`stroke-(--ui-border-muted)`,x1:r.value.marginLeft,x2:r.value.width-r.value.marginRight,y1:e.y,y2:e.y},null,8,W),g(`text`,{class:`fill-(--ui-text-dimmed) text-[11px] tabular-nums`,x:r.value.marginLeft-8,y:e.y+4,"text-anchor":`end`},b(e.label),9,G)],64))),128)),(d(!0),_(o,null,v(r.value.segments,(e,t)=>(d(),_(`rect`,{key:`s${t}`,class:x([`seg hover:opacity-85`,y(H)[e.seriesIndex%y(H).length]]),x:e.x,y:e.y,width:e.width,height:e.height},null,10,K))),128)),(d(!0),_(o,null,v(r.value.dayHovers,(e,t)=>(d(),_(`rect`,{key:`h${t}`,class:`day fill-transparent`,role:`img`,"aria-label":e.title,x:e.x,y:e.y,width:e.width,height:e.height,onPointerenter:t=>l(e,t),onPointermove:t=>l(e,t),onPointerleave:n[0]||=e=>a.value=null},null,40,q))),128)),(d(!0),_(o,null,v(r.value.dayLabels,(e,t)=>(d(),_(`text`,{key:`d${t}`,class:`fill-(--ui-text-dimmed) text-[11px]`,x:e.x,y:r.value.height-10,"text-anchor":`middle`},b(e.label),9,J))),128)),g(`line`,{class:`stroke-(--ui-border)`,x1:r.value.marginLeft,x2:r.value.width-r.value.marginRight,y1:r.value.axisY,y2:r.value.axisY},null,8,Y)],8,U))]),a.value?(d(),_(`div`,{key:0,class:`chart-tip pointer-events-none absolute z-10 w-64 rounded-md border border-default bg-elevated px-3 py-2 font-mono text-xs tabular-nums whitespace-nowrap shadow-lg`,role:`tooltip`,style:t({left:`${a.value.x}px`,top:`${a.value.y}px`})},[g(`div`,fe,[g(`span`,X,[u(b(a.value.data.label),1),a.value.data.partial?(d(),_(`span`,pe,`partial day`)):f(``,!0)]),g(`span`,me,b(y(P)(a.value.data.total)),1)]),(d(!0),_(o,null,v(a.value.data.rows,e=>(d(),_(`div`,{key:e.series,class:`tip-row flex items-baseline justify-between gap-3 leading-5`},[g(`span`,he,b(e.series),1),g(`span`,ge,[g(`span`,_e,b(y(P)(e.usd)),1),e.estimated?(d(),_(`span`,ve,`est.`)):f(``,!0)])]))),128))],4)):f(``,!0)],512))}}),$=[`data-dimension`],be={class:`flex flex-wrap items-center gap-x-4 gap-y-2`},xe={class:`flex items-center gap-2 text-sm text-muted`},Se=[`placeholder`,`aria-label`],Ce=[`title`],we=[`disabled`,`aria-describedby`],Te={key:0,id:`me-hint`,class:`me-hint text-xs text-dimmed`},Ee={class:`coverage font-mono text-xs tabular-nums text-muted`},De={class:`overflow-x-auto`},Oe={class:`by w-full min-w-[40rem] border-collapse whitespace-nowrap font-mono text-[0.8125rem] tabular-nums`},ke={class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-left text-xs font-medium text-muted`},Ae={class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},je={key:0,class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},Me=[`title`],Ne={class:`text-highlighted`},Pe={key:0,class:`ml-1.5 text-xs text-dimmed`},Fe={key:1,class:`ml-1.5 rounded-xs bg-accented px-1 text-xs text-highlighted`},Ie=[`title`],Le={class:`border-b border-muted px-2.5 py-1.5 text-right`},Re={class:`border-b border-muted px-2.5 py-1.5 text-right`},ze={key:0,class:`border-b border-muted px-2.5 py-1.5 text-right`},Be={class:`border-b border-muted px-2.5 py-1.5 text-right font-medium text-highlighted`},Ve={class:`border-b border-muted px-2.5 py-1.5 text-right`},He={key:0},Ue=[`colspan`],We={key:0},Ge=[`colspan`],Ke={class:`px-2.5 py-1.5 text-right text-xs text-muted`},qe={class:`px-2.5 py-1.5 text-right text-xs text-muted`},Je={class:`reconciliation font-mono text-xs tabular-nums text-muted`},Ye={class:`text-xs text-dimmed`},Xe=S({__name:`CostsByDimension`,props:{report:{}},setup(e){let t=e,n={user:`User`,thread:`Thread`,channel:`Channel`,agent:`Agent`,model:`Model`},i=c(``),s=c(!1),l=m(()=>t.report.dimension),p=m(()=>t.report.viewer!==void 0),h=m(()=>(t.report.viewer?.userIds.length??0)>0),S=m(()=>t.report.cloudAllocated),w=m(()=>l.value===`model`?`Turns`:`Runs`),T=e=>l.value===`model`?e.turns:e.runs,E=m(()=>{let e=i.value.trim().toLowerCase(),n=new Set(t.report.viewer?.userIds??[]);return t.report.rows.filter(t=>s.value&&!n.has(t.key)?!1:!e||t.key.toLowerCase().includes(e)||(t.label??``).toLowerCase().includes(e))}),D=m(()=>t.report.rows.reduce((e,t)=>e+t.totalUsd,0)),ee=m(()=>E.value.reduce((e,t)=>e+t.totalUsd,0)),O=e=>t.report.viewer?.userIds.includes(e.key)??!1,k=m(()=>l.value===`user`||l.value===`thread`||l.value===`channel`),te=e=>e.label??(k.value?e.key.replace(/^[a-z]+:/,``):e.key),A=e=>k.value&&e.key.includes(`:`)?e.key.split(`:`)[0]:``,j=e=>`${e} day${e===1?``:`s`}`,M=m(()=>S.value?6:5);return(t,c)=>(d(),_(`section`,{class:`by-dimension grid gap-3`,"data-dimension":l.value},[g(`div`,be,[g(`label`,xe,[c[2]||=g(`span`,null,`Filter`,-1),C(g(`input`,{"onUpdate:modelValue":c[0]||=e=>i.value=e,class:`key-filter rounded-md border border-default bg-elevated px-2.5 py-1 font-mono text-xs text-highlighted`,type:`search`,placeholder:l.value===`user`?`name or id`:n[l.value].toLowerCase(),"aria-label":`Filter by ${n[l.value].toLowerCase()}`},null,8,Se),[[a,i.value]])]),p.value?(d(),_(`label`,{key:0,class:x([`me-toggle flex items-center gap-2 text-sm`,h.value?`text-muted`:`text-dimmed`]),title:h.value?`Only your own runs`:void 0},[C(g(`input`,{"onUpdate:modelValue":c[1]||=e=>s.value=e,type:`checkbox`,disabled:!h.value,"aria-label":`Only me`,"aria-describedby":h.value?void 0:`me-hint`},null,8,we),[[r,s.value]]),c[3]||=g(`span`,null,`me`,-1),h.value?f(``,!0):(d(),_(`span`,Te,`— your sign-in email matched no Slack user in this range`))],10,Ce)):f(``,!0),g(`p`,Ee,[e.report.coverage.historyOn?(d(),_(o,{key:1},[u(` runs from `+b(y(B)(e.report.coverage.from))+` to `+b(y(B)(e.report.range.to)),1),e.report.coverage.clamped?(d(),_(o,{key:0},[u(` · earlier days are past the history's `+b(e.report.coverage.retentionDays)+`-day window`,1)],64)):f(``,!0),e.report.pending>0?(d(),_(o,{key:1},[u(` · `+b(e.report.pending)+` run`+b(e.report.pending===1?``:`s`)+` still being priced`,1)],64)):f(``,!0)],64)):(d(),_(o,{key:0},[u(`run history is off — no runs to attribute`)],64))])]),g(`div`,De,[g(`table`,Oe,[g(`thead`,null,[g(`tr`,null,[g(`th`,ke,b(n[l.value]),1),g(`th`,Ae,b(w.value),1),c[5]||=g(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},` LLM `,-1),S.value?(d(),_(`th`,je,[...c[4]||=[u(` Cloud `,-1),g(`span`,{class:`font-normal text-dimmed`},`allocated`,-1)]])):f(``,!0),c[6]||=g(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},` Total `,-1),c[7]||=g(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},` Share `,-1)])]),g(`tbody`,null,[(d(!0),_(o,null,v(E.value,e=>(d(),_(`tr`,{key:e.key,class:x([`by-row`,O(e)?`is-me`:``])},[g(`td`,{class:`border-b border-muted px-2.5 py-1.5`,title:e.key},[g(`span`,Ne,b(te(e)),1),A(e)?(d(),_(`span`,Pe,b(A(e)),1)):f(``,!0),O(e)?(d(),_(`span`,Fe,`me`)):f(``,!0),e.unpricedTokens>0?(d(),_(`span`,{key:2,class:`ml-1.5 text-xs text-warn`,title:`${e.unpricedTokens} tokens ran under a model with no price`},`unpriced tokens`,8,Ie)):f(``,!0)],8,Me),g(`td`,Le,b(T(e)),1),g(`td`,Re,b(y(P)(e.llmUsd)),1),S.value?(d(),_(`td`,ze,b(y(P)(e.cloudUsd)),1)):f(``,!0),g(`td`,Be,b(y(P)(e.totalUsd)),1),g(`td`,Ve,b(D.value>0?Math.round(e.totalUsd/D.value*100):0)+`% `,1)],2))),128)),E.value.length===0?(d(),_(`tr`,He,[g(`td`,{class:`empty px-2.5 py-3 text-sm text-muted`,colspan:M.value},b(e.report.rows.length===0?`no runs in this range`:`no ${n[l.value].toLowerCase()} matches`),9,Ue)])):f(``,!0)]),E.value.length>0&&E.value.length<e.report.rows.length?(d(),_(`tfoot`,We,[g(`tr`,null,[g(`td`,{class:`px-2.5 py-1.5 text-xs text-muted`,colspan:M.value-2},`shown`,8,Ge),g(`td`,Ke,b(y(P)(ee.value)),1),g(`td`,qe,b(D.value>0?Math.round(ee.value/D.value*100):0)+`% `,1)])])):f(``,!0)])]),g(`p`,Je,[e.report.reconciliation.comparedDays>0?(d(),_(o,{key:0},[u(` LLM attributed `+b(y(P)(e.report.reconciliation.attributedLlmUsd))+` of `+b(y(P)(e.report.reconciliation.workspaceLlmUsd))+` on the workspace over `+b(j(e.report.reconciliation.comparedDays))+` · `,1),e.report.reconciliation.unattributedLlmUsd>=0?(d(),_(o,{key:0},[u(b(y(P)(e.report.reconciliation.unattributedLlmUsd))+` unattributed (router, review abridges, runs without a record, list vs invoice) `,1)],64)):(d(),_(o,{key:1},[u(b(y(P)(-e.report.reconciliation.unattributedLlmUsd))+` more attributed than the workspace figure (list vs invoice, or spend billed outside this workspace on a compared day) `,1)],64))],64)):(d(),_(o,{key:1},[u(`no day in range has a workspace LLM figure to compare against`)],64)),e.report.reconciliation.uncomparedDays>0?(d(),_(o,{key:2},[u(` · `+b(j(e.report.reconciliation.uncomparedDays))+` with `+b(y(P)(e.report.reconciliation.uncomparedLlmUsd))+` of run tokens but no workspace figure (billed outside this workspace) not compared`,1)],64)):f(``,!0),S.value?(d(),_(o,{key:3},[u(` · cloud allocated `+b(y(P)(e.report.reconciliation.cloudAllocatedUsd)),1),e.report.reconciliation.cloudUnallocatedUsd>0?(d(),_(o,{key:0},[u(` · `+b(y(P)(e.report.reconciliation.cloudUnallocatedUsd))+` on days with no runs`,1)],64)):f(``,!0)],64)):f(``,!0)]),g(`p`,Ye,[l.value===`model`?(d(),_(o,{key:0},[u(` A model's LLM is the runs' tokens on it, priced through the price table (the configured rates over Anthropic list; cache writes at the 5-minute rate); a run that spent on two models counts under both, and cloud is not split by model — a container runs a run, not a model. `)],64)):(d(),_(o,{key:1},[u(` A `+b(n[l.value].toLowerCase())+`'s LLM is its runs' tokens priced through the price table (the configured rates over Anthropic list; cache writes at the 5-minute rate); a child run bills to whoever started its parent, in the child's own thread and agent. Cloud is each day's Cloudflare spend split by share of run wall-clock — an allocation, not a meter. `,1)],64))])],8,$))}}),Ze={class:`mb-4 flex flex-wrap items-center gap-x-4 gap-y-2`},Qe={class:`flex items-center gap-1`,"aria-label":`Range`},$e={key:0,class:`rounded-md bg-accented px-2.5 py-1 font-mono text-xs font-medium tabular-nums text-highlighted`,"aria-current":`page`},et=[`href`],tt={key:0,class:`flex items-center gap-1`,"aria-label":`Cost groups`},nt={key:0,class:`rounded-md bg-accented px-2.5 py-1 text-xs font-medium text-highlighted`,"aria-current":`page`},rt=[`href`],it={class:`font-mono text-sm tabular-nums text-muted`},at={key:1,class:`flex basis-full flex-wrap items-center gap-x-3 gap-y-1`},ot={class:`font-mono text-xs tabular-nums text-dimmed`,"data-snapshot-status":``},st=[`disabled`],ct={key:1,class:`text-xs text-error`,role:`status`,"data-snapshot-error":``},lt={class:`mb-5 grid grid-cols-[repeat(auto-fit,minmax(190px,1fr))] gap-3`},ut={key:0,class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},dt={class:`font-mono text-2xl font-medium tabular-nums`},ft={class:`text-xs text-muted`},pt={key:1,class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},mt={class:`font-mono text-2xl font-medium tabular-nums`},ht={class:`text-xs text-muted`},gt={class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},_t={class:`font-mono text-2xl font-medium tabular-nums`},vt={class:`text-xs text-muted`},yt={class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},bt={class:`font-mono text-2xl font-medium tabular-nums`},xt={class:`text-xs text-muted`},St={class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},Ct={class:`font-mono text-2xl font-medium tabular-nums`},wt={class:`text-xs text-muted`},Tt={class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},Et={class:`font-mono text-2xl font-medium tabular-nums`},Dt={class:`text-xs text-muted`},Ot=[`href`,`title`],kt=[`href`],At={class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},jt={class:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-2`},Mt={class:`legend flex flex-wrap gap-x-4 gap-y-1.5 text-xs text-muted`},Nt=[`href`,`title`],Pt={key:0,class:`text-xs text-warn`},Ft={key:1,class:`text-xs text-muted`},It={class:`mb-3 flex flex-wrap items-center gap-1 border-b border-default`,"aria-label":`View`},Lt={key:0,class:`-mb-px border-b-2 border-primary px-3 py-1.5 text-sm font-medium text-highlighted`,"aria-current":`page`},Rt=[`href`],zt={key:0,class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},Bt={class:`text-[0.9375rem] font-medium`},Vt={class:`text-sm text-muted`},Ht={key:1,class:`text-sm text-warn`},Ut={class:`text-xs text-muted`},Wt={class:`rounded bg-accented px-1 py-0.5`},Gt={key:1,class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},Kt={class:`w-full border-collapse font-mono text-[0.8125rem] tabular-nums`},qt={class:`px-2.5 py-1.5`},Jt=[`href`],Yt={class:`px-2.5 py-1.5 text-right`},Xt={class:`px-2.5 py-1.5 text-right`},Zt={class:`w-2/5 px-2.5 py-1.5`},Qt={key:2,class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},$t={open:``},en={class:`mt-2.5 overflow-x-auto`},tn={class:`data w-full min-w-[38rem] border-collapse whitespace-nowrap font-mono text-[0.8125rem] tabular-nums`},nn=[`title`],rn={key:0,class:`text-xs text-dimmed`},an={key:1,class:`text-xs text-dimmed`},on={class:`border-b border-muted px-2.5 py-1.5 text-right font-medium`},sn={class:`text-xs text-muted`},cn={class:`rounded bg-accented px-1 py-0.5`},ln={class:`border-t border-default pt-3.5 text-xs text-dimmed`},un={class:`mt-2 grid gap-1.5`},dn=[`href`],fn={key:2},pn=[`href`],mn={key:2},hn=[`href`],gn=[`href`],_n={class:`mb-4 flex flex-wrap items-center gap-x-4 gap-y-2`},vn={key:0,class:`flex items-center gap-1`,"aria-label":`Cost groups`},yn={key:0,class:`rounded-md bg-accented px-2.5 py-1 text-xs font-medium text-highlighted`,"aria-current":`page`},bn=[`href`],xn={class:`mb-5 grid gap-2 rounded-lg border border-default bg-elevated px-5 py-4`},Sn={class:`flex flex-wrap items-center gap-x-3 gap-y-1`},Cn={class:`font-mono text-xs tabular-nums text-muted`,"data-snapshot-status":``},wn=[`disabled`],Tn={key:1,class:`text-xs text-error`,role:`status`,"data-snapshot-error":``},En=S({__name:`CostsPage`,setup(r){let a=h(`costs`),S=c(a?.report??null),C=m(()=>a?.groups??[]),w=m(()=>a?.group??S.value?.group??``),T=c(a?.snapshot??null),E=O(void 0,6e4),k=m(()=>T.value?j(T.value,E.value):``),A=m(()=>a?.view??`daily`),M=c(a&&a.view!==`daily`?a.by??null:null),N=[{view:`daily`,tab:`Daily`,subtitle:``},{view:`users`,tab:`By user`,subtitle:`Who started the runs · LLM from their tokens through the price table · cloud allocated by wall-clock`},{view:`threads`,tab:`By thread`,subtitle:`The thread each run ran in · LLM from its tokens through the price table · cloud allocated by wall-clock`},{view:`channels`,tab:`By channel`,subtitle:`The channel each run ran in · LLM from its tokens through the price table · cloud allocated by wall-clock`},{view:`agents`,tab:`By agent`,subtitle:`The agent each run ran on · LLM from its tokens through the price table · cloud allocated by wall-clock`},{view:`models`,tab:`By model`,subtitle:`The model each turn ran on · LLM from its tokens through the price table · cloud is not split by model`}],F=m(()=>N.find(e=>e.view===A.value)??N[0]),re=m(()=>a?.canSnapshot===!0),L=m(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`days`)),ae=e=>`/costs/${w.value}${e}${L.value?`?days=${L.value}`:``}`,R=a?.snapshot?.snapshot?.takenAt??null,z=R,B=null;async function ce(){try{let[e,t]=await Promise.all([fetch(ae(`.json`),{credentials:`same-origin`}),A.value===`daily`?Promise.resolve(null):fetch(ae(`/${A.value}.json`),{credentials:`same-origin`})]);return e.ok?(S.value=await e.json(),t?.ok&&(M.value=await t.json()),!0):!1}catch{return!1}}function V(){if(B||z===null||z===R)return;let e=z;B=ce().then(t=>{t&&(R=e)}).finally(()=>{B=null,z!==e&&V()})}function H(e){T.value=e;let t=e.snapshot?.takenAt??null;t&&(z=t,V())}let de=D(),U=null;i(()=>{w.value&&(U=de(`/costs/${w.value}?stream=1`),U.onmessage=e=>{let t=te(e.data);t&&H(t)})}),p(()=>U?.close());let W=c(!1),G=c(``);async function K(){W.value=!0,G.value=``;let e=await ee(fetch,`costs.snapshot`,{});e.ok||(G.value=e.failure.message),W.value=!1}function q(e,t,n){let r=[`days=${t}`];return n!==`daily`&&r.push(`view=${n}`),`/costs/${e}?${r.join(`&`)}`}let J=m(()=>S.value?ne(S.value):[]),Y=m(()=>S.value?ie(S.value):null),fe=m(()=>S.value?le(S.value):[]),X=m(()=>S.value?oe(S.value):null),pe=m(()=>S.value?se(S.value):``);function me(e){let t=X.value;if(t){if(/^(Memory|vCPU|Disk)/.test(e))return t.containers;if(e.startsWith(`Durable Object`))return t.durableObjects;if(e.startsWith(`Workers`))return t.workers;if(e.startsWith(`R2`))return t.r2;if(e.startsWith(`Workflow`))return t.workflows}}function he(e){let t=X.value;if(t)return e===`LLM (Anthropic)`?t.anthropic:e===`Durable Objects`?t.durableObjects:e===`Workers · storage · R2`?t.workers:t.containers}let ge=m(()=>{let e=S.value,t=Y.value;if(!e||!t)return``;let n=t.projection,r=`cloud ${P(n.cloudRate)}/day`,i=n.cloudBasis===`today`?`cloud from today so far`:`cloud from the last 7 full days`;if(!e.llmAvailable)return`${r} × 30.4 · ${i} · before plan fees and included allowances`;let a=`LLM ${P(n.llmRate)}/day`,o=n.llmBasis===`closed-days`?`LLM from ${n.llmClosedDays} closed day${n.llmClosedDays===1?``:`s`}`:n.llmBasis===`today`?`LLM from today so far`:`no LLM spend in range`;return`${r} + ${a} · × 30.4 · ${n.cloudBasis===`today`&&n.llmBasis===`today`?`both from today so far`:`${i} · ${o}`}`}),_e=m(()=>S.value?[...S.value.days].reverse():[]),ve=[1,7,30],Z=e=>e===1?`today`:`${e}d`,Q=m(()=>{let e=S.value,t=Y.value;if(!e||!t)return``;if(!e.llmAvailable)return`LLM spend not configured`;let n=[];return t.llm.yesterday!==void 0&&n.push(`yesterday ${P(t.llm.yesterday)}`),t.llm.today&&n.push(`today ${P(t.llm.today.usd)}${t.llm.today.estimated?` (estimate)`:``}`),n.length?n.join(` · `):`in range`});function $(e){let t=new Date(`${e}T00:00:00Z`);return Number.isNaN(t.getTime())?e:`${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.getUTCMonth()]} ${t.getUTCDate()}`}return(r,i)=>S.value&&Y.value?(d(),l(e,{key:0,title:`${S.value.label} spend`,nav:`costs`},{default:n(()=>[g(`div`,Ze,[g(`nav`,Qe,[(d(),_(o,null,v(ve,e=>(d(),_(o,{key:e},[e===S.value.range.days?(d(),_(`span`,$e,b(Z(e)),1)):(d(),_(`a`,{key:1,class:`rounded-md px-2.5 py-1 font-mono text-xs tabular-nums text-muted no-underline hover:bg-elevated hover:text-highlighted`,href:q(S.value.group,e,A.value)},b(Z(e)),9,et))],64))),64))]),C.value.length>1?(d(),_(`nav`,tt,[(d(!0),_(o,null,v(C.value,e=>(d(),_(o,{key:e},[e===S.value.group?(d(),_(`span`,nt,b(e),1)):(d(),_(`a`,{key:1,class:`rounded-md px-2.5 py-1 text-xs text-muted no-underline hover:bg-elevated hover:text-highlighted`,href:q(e,S.value.range.days,A.value)},b(e),9,rt))],64))),128))])):f(``,!0),g(`p`,it,[u(b($(S.value.range.from))+` → `+b($(S.value.range.to))+` · `+b(S.value.range.days)+`d`,1),S.value.range.partialLastDay?(d(),_(o,{key:0},[u(` · today partial`)],64)):f(``,!0)]),k.value?(d(),_(`div`,at,[g(`p`,ot,b(k.value),1),re.value?(d(),_(`button`,{key:0,type:`button`,class:`rounded-md border border-default px-2 py-0.5 text-xs text-muted hover:bg-elevated hover:text-highlighted disabled:cursor-not-allowed disabled:opacity-60`,disabled:W.value||T.value?.inFlight!==null,"data-snapshot-now":``,onClick:K},b(T.value?.inFlight?`Taking…`:`Snapshot now`),9,st)):f(``,!0),G.value?(d(),_(`span`,ct,b(G.value),1)):f(``,!0)])):f(``,!0)]),g(`section`,lt,[Y.value.yesterday?(d(),_(`div`,ut,[i[0]||=g(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`Yesterday`,-1),g(`span`,dt,b(y(P)(Y.value.yesterday.total)),1),g(`span`,ft,b(Y.value.yesterday.date)+` · last full day`,1)])):(d(),_(`div`,pt,[i[1]||=g(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`Today so far`,-1),g(`span`,mt,b(Y.value.today?y(P)(Y.value.today.total):`—`),1),g(`span`,ht,b(Y.value.today?`${Y.value.today.date} · partial day, UTC`:`no day in range`),1)])),g(`div`,gt,[i[2]||=g(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`7-day average`,-1),g(`span`,_t,b(Y.value.avg7===void 0?`—`:y(P)(Y.value.avg7)),1),g(`span`,vt,b(Y.value.avg7===void 0?`no full day yet in this range`:`per day, full days only`),1)]),g(`div`,yt,[i[3]||=g(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`Projected month`,-1),g(`span`,bt,b(y(P)(Y.value.projection.monthUsd,0)),1),g(`span`,xt,b(ge.value),1)]),g(`div`,St,[i[4]||=g(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`LLM spend`,-1),g(`span`,Ct,b(S.value.llmAvailable?y(P)(Y.value.llm.range):`—`),1),g(`span`,wt,b(Q.value),1)]),g(`div`,Tt,[i[6]||=g(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`Share of account`,-1),g(`span`,Et,b(Y.value.accountShare)+`%`,1),g(`span`,Dt,[u(b(y(P)(S.value.totals.cloudUsd))+` of `+b(y(P)(S.value.account.cloudUsd))+` on `,1),X.value?(d(),_(`a`,{key:0,class:`text-primary hover:underline`,href:X.value.account,target:`_blank`,rel:`noopener noreferrer`,title:`Cloudflare account ${S.value.account.id}`},b(pe.value),9,Ot)):f(``,!0),i[5]||=u(` · Cloudflare spend in range · `,-1),X.value?(d(),_(`a`,{key:1,class:`text-primary hover:underline`,href:X.value.billing,target:`_blank`,rel:`noopener noreferrer`},`billing`,8,kt)):f(``,!0)])])]),g(`section`,At,[g(`div`,jt,[i[7]||=g(`div`,null,[g(`h2`,{class:`text-[0.9375rem] font-medium`},`Daily cost`),g(`p`,{class:`text-sm text-muted`},`Stacked by component · USD list price`)],-1),g(`div`,Mt,[(d(!0),_(o,null,v(J.value,(e,t)=>(d(),_(`a`,{key:e,class:`inline-flex items-center gap-1.5 no-underline hover:text-highlighted hover:underline`,href:he(e),target:`_blank`,rel:`noopener noreferrer`,title:`Open where ${e} is billed`},[g(`i`,{class:x([`inline-block size-2.5 rounded-xs`,y(ue)[t%y(ue).length]])},null,2),u(b(e),1)],8,Nt))),128))])]),s(ye,{report:S.value,series:J.value},null,8,[`report`,`series`]),S.value.llmAvailable?S.value.days.some(e=>e.llmEstimated)?(d(),_(`p`,Ft,[i[9]||=u(` A day the Anthropic cost report has not closed yet (today, and yesterday until a few hours after midnight UTC) shows its LLM figure as an estimate: the hourly usage report priced at list. The closed days are the cost report itself. `,-1),S.value.days.some(e=>e.llmUnpricedTokens>0)?(d(),_(o,{key:0},[u(` Some tokens ran under a model this page has no price for and are not in the estimate. `)],64)):f(``,!0)])):f(``,!0):(d(),_(`p`,Pt,[...i[8]||=[u(` LLM spend not configured — set `,-1),g(`code`,null,`ANTHROPIC_ADMIN_KEY`,-1),u(` and the group's `,-1),g(`code`,null,`anthropicWorkspaceId`,-1),u(` to layer it in. `,-1)]]))]),g(`nav`,It,[(d(),_(o,null,v(N,e=>(d(),_(o,{key:e.view},[e.view===A.value?(d(),_(`span`,Lt,b(e.tab),1)):(d(),_(`a`,{key:1,class:`-mb-px border-b-2 border-transparent px-3 py-1.5 text-sm text-muted no-underline hover:border-muted hover:text-highlighted`,href:q(S.value.group,S.value.range.days,e.view)},b(e.tab),9,Rt))],64))),64))]),A.value===`daily`?f(``,!0):(d(),_(`section`,zt,[g(`div`,null,[g(`h2`,Bt,`Cost `+b(F.value.tab.toLowerCase()),1),g(`p`,Vt,b(F.value.subtitle),1)]),M.value?(d(),l(Xe,{key:0,report:M.value},null,8,[`report`])):(d(),_(`p`,Ht,` The `+b(F.value.tab.toLowerCase())+` report did not load with this page. `,1)),g(`p`,Ut,[i[10]||=u(` Machine-readable twin: `,-1),g(`code`,Wt,`GET /costs/`+b(S.value.group)+`/`+b(A.value)+`.json`,1),i[11]||=u(` (same Access gate). `,-1)])])),A.value===`daily`?(d(),_(`section`,Gt,[i[12]||=g(`div`,null,[g(`h2`,{class:`text-[0.9375rem] font-medium`},`What each cloud dollar buys`)],-1),g(`table`,Kt,[g(`tbody`,null,[(d(!0),_(o,null,v(fe.value,e=>(d(),_(`tr`,{key:e.label,class:`border-b border-muted`},[g(`td`,qt,[me(e.label)?(d(),_(`a`,{key:0,class:`no-underline hover:text-highlighted hover:underline`,href:me(e.label),target:`_blank`,rel:`noopener noreferrer`,title:`Open where this is billed on Cloudflare`},b(e.label),9,Jt)):(d(),_(o,{key:1},[u(b(e.label),1)],64))]),g(`td`,Yt,b(y(P)(e.usd)),1),g(`td`,Xt,b(Math.round(e.percent))+`%`,1),g(`td`,Zt,[g(`i`,{class:`block h-2.5 rounded-xs bg-primary opacity-75`,style:t({width:`${e.percent.toFixed(1)}%`})},null,4)])]))),128))])])])):f(``,!0),A.value===`daily`?(d(),_(`section`,Qt,[g(`details`,$t,[i[15]||=g(`summary`,{class:`cursor-pointer text-sm text-muted`},`Table view — daily cost by component (USD)`,-1),g(`div`,en,[g(`table`,tn,[g(`thead`,null,[g(`tr`,null,[i[13]||=g(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-left text-xs font-medium text-muted`},` Date `,-1),(d(!0),_(o,null,v(J.value,e=>(d(),_(`th`,{key:e,class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},b(e),1))),128)),i[14]||=g(`th`,{class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},` Total `,-1)])]),g(`tbody`,null,[(d(!0),_(o,null,v(_e.value,e=>(d(),_(`tr`,{key:e.date},[g(`td`,{class:`border-b border-muted px-2.5 py-1.5`,title:e.date},[u(b($(e.date))+` `,1),S.value.range.partialLastDay&&e.date===S.value.range.to?(d(),_(`span`,rn,`(partial day`+b(e.llmEstimated?` · LLM estimated`:``)+`)`,1)):e.llmEstimated?(d(),_(`span`,an,`(LLM estimated)`)):f(``,!0)],8,nn),(d(!0),_(o,null,v(J.value,t=>(d(),_(`td`,{key:t,class:`border-b border-muted px-2.5 py-1.5 text-right`},b(y(P)(y(I)(e,t),3)),1))),128)),g(`td`,on,b(y(P)(e.total,3)),1)]))),128))])])])]),g(`p`,sn,[i[16]||=u(` Machine-readable twin: `,-1),g(`code`,cn,`GET /costs/`+b(S.value.group)+`.json`,1),i[17]||=u(` (same Access gate). `,-1)])])):f(``,!0),g(`footer`,ln,[g(`details`,null,[i[25]||=g(`summary`,{class:`cursor-pointer text-muted`},`How these numbers are computed`,-1),g(`div`,un,[i[23]||=g(`div`,null,[g(`b`,null,`Snapshot.`),u(` Both billing sources and the run history are read once over the widest range this page offers and kept as a snapshot; every figure here, the JSON twins and the dimension tabs are arithmetic over it, with `),g(`em`,null,`today`),u(` the day it was taken. The line under the range says when that was, how old it is and when the next one is due (`),g(`code`,null,`costs.snapshot.everyHours`),u(`, daily by default); `),g(`code`,null,`costs snapshot`),u(` takes one now. Cloudflare bills vCPU on active use only; memory and disk bill on the provisioned size for every second a container is awake. LLM spend is the Anthropic Admin API cost report for this group's workspace (gross, USD); a day the cost report has not closed is the Admin API usage report, hourly, priced at Anthropic list per model (input, output, cache writes, cache reads) and marked as an estimate. `)],-1),i[24]||=g(`div`,null,[g(`b`,null,`Method.`),u(` Cloudflare GraphQL Analytics, every meter a Workers deployment is billed on: `),g(`code`,null,`containersUsageAdaptiveGroups`),u(` (cpuTimeSec, allocatedMemory, allocatedDisk per app per UTC day), `),g(`code`,null,`durableObjectsPeriodicGroups`),u(` (billable `),g(`code`,null,`duration`),u(` GB-s and SQLite rows read and written per namespace), `),g(`code`,null,`durableObjectsInvocationsAdaptiveGroups`),u(` (requests per namespace), `),g(`code`,null,`durableObjectsSqlStorageGroups`),u(` (bytes stored), `),g(`code`,null,`workersInvocationsAdaptive`),u(` (requests, CPU time), `),g(`code`,null,`r2StorageAdaptiveGroups`),u(` and `),g(`code`,null,`r2OperationsAdaptiveGroups`),u(` (bytes stored, class A/B operations). Prices: vCPU $0.000020/s, memory $0.0000025/GiB-s, disk $0.00000007/GB-s, DO duration $12.50 per million GB-s, DO requests $0.15/M, SQLite rows $0.001/M read and $1.00/M written, DO storage $0.20/GB-month, Workers $0.30/M requests and $0.02/M CPU-ms, R2 $0.015/GB-month, $4.50/M class A and $0.36/M class B (deletes free). Storage is the day's peak, prorated over a 30.44-day month. Gross list price — plan fees and included allowances are not subtracted; Workers Logs volume has no analytics dataset and is not priced. `)],-1),g(`div`,null,[i[18]||=g(`b`,null,`Scope.`,-1),i[19]||=u(` Attributed to this group: the Workers `,-1),(d(!0),_(o,null,v(S.value.attribution.workers,(e,t)=>(d(),_(o,{key:e},[t>0?(d(),_(o,{key:0},[u(`, `)],64)):f(``,!0),X.value?(d(),_(`a`,{key:1,class:`font-mono hover:underline`,href:X.value.worker(e),target:`_blank`,rel:`noopener noreferrer`},b(e),9,dn)):(d(),_(`code`,fn,b(e),1))],64))),128)),u(`, every Durable Object namespace they host (`+b(Object.keys(S.value.attribution.durableObjectNamespaces).length)+`), the R2 buckets named after them (`,1),(d(!0),_(o,null,v(Object.keys(S.value.attribution.r2Buckets),(e,t)=>(d(),_(o,{key:e},[t>0?(d(),_(o,{key:0},[u(`, `)],64)):f(``,!0),X.value?(d(),_(`a`,{key:1,class:`font-mono hover:underline`,href:X.value.bucket(e),target:`_blank`,rel:`noopener noreferrer`},b(e),9,pn)):(d(),_(`code`,mn,b(e),1))],64))),128)),Object.keys(S.value.attribution.r2Buckets).length===0?(d(),_(o,{key:0},[u(`none`)],64)):f(``,!0),i[20]||=u(`), and the container apps mapped in `,-1),g(`code`,null,`costs.groups.`+b(S.value.group),1),u(` (`+b(Object.keys(S.value.attribution.containerApps).length)+`). Everything else in the account is priced the same way into the account total, which is what "share of account" divides by. Every figure above links to where it is billed: the `,1),X.value?(d(),_(`a`,{key:1,class:`hover:underline`,href:X.value.account,target:`_blank`,rel:`noopener noreferrer`},`Cloudflare dashboard`,8,hn)):f(``,!0),i[21]||=u(` for the account `,-1),g(`code`,null,b(S.value.account.id),1),u(b(S.value.account.name?` (${S.value.account.name})`:``)+`, and `,1),X.value?(d(),_(`a`,{key:2,class:`hover:underline`,href:X.value.anthropic,target:`_blank`,rel:`noopener noreferrer`},`Anthropic's cost page`,8,gn)):f(``,!0),i[22]||=u(` for the LLM line. `,-1)])])])])]),_:1},8,[`title`])):(d(),l(e,{key:1,title:`${w.value} spend`,nav:`costs`},{default:n(()=>[g(`div`,_n,[C.value.length>1?(d(),_(`nav`,vn,[(d(!0),_(o,null,v(C.value,e=>(d(),_(o,{key:e},[e===w.value?(d(),_(`span`,yn,b(e),1)):(d(),_(`a`,{key:1,class:`rounded-md px-2.5 py-1 text-xs text-muted no-underline hover:bg-elevated hover:text-highlighted`,href:`/costs/${e}`},b(e),9,bn))],64))),128))])):f(``,!0)]),g(`section`,xn,[i[26]||=g(`h2`,{class:`text-sm font-medium text-highlighted`},`Nothing to show yet`,-1),g(`div`,Sn,[g(`p`,Cn,b(k.value),1),re.value?(d(),_(`button`,{key:0,type:`button`,class:`rounded-md border border-default px-2 py-0.5 text-xs text-muted hover:bg-elevated hover:text-highlighted disabled:cursor-not-allowed disabled:opacity-60`,disabled:W.value||T.value?.inFlight!==null,"data-snapshot-now":``,onClick:K},b(T.value?.inFlight?`Taking…`:`Snapshot now`),9,wn)):f(``,!0),G.value?(d(),_(`span`,Tn,b(G.value),1)):f(``,!0)]),i[27]||=g(`p`,{class:`text-xs text-dimmed`},[u(` The page prices a stored snapshot of both billing sources, never a live read; the figures appear here the moment the first one lands (this page listens for it), or take one now with `),g(`code`,null,`costs snapshot`),u(`. `)],-1)])]),_:1},8,[`title`]))}});export{En as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e,n as t,r as n,t as r}from"./AppShell-IDMGG6yi.js";import{Ci as i,Gn as a,Jn as o,Lr as s,Mr as c,Qn as l,St as u,Vt as d,Wt as f,Xt as p,_n as m,a as ee,ci as h,cn as g,dr as _,gn as v,i as y,ir as b,ln as x,m as S,nr as te,oi as C,on as w,or as T,r as E,sn as D,un as O,ur as ne,vi as k,wi as A,xi as j,xt as M,yn as N,zr as P}from"./seed-DeKSHrt2.js";import{t as F}from"./Tooltip-BbLuIAiS.js";import{i as I,n as L,r as re,t as ie}from"./PendingTurnRow-BT9RhFZ7.js";import{t as R}from"./eventSource-tRprhqm7.js";import{t as ae}from"./wallClock-61NpVkY6.js";import{n as oe,r as se}from"./favicon-D1hkyC5j.js";import{n as z,t as ce}from"./indexFormat-B-pd4r7Y.js";import{E as le,i as ue,r as B,t as de,v as fe}from"./indexRow-B_s5tKyq.js";import{i as V}from"./format-BldUwl_R.js";import{i as pe,n as me,t as he}from"./durationTone-BobbycC-.js";import{D as H,E as ge,a as U,c as _e,d as W,i as ve,n as ye,o as be,s as xe,t as Se,u as G,v as K}from"./sseReplay-C9m_EB8J.js";var q=`To run this:`;function Ce(e,t){return e?t.trim()===``?`stop`:`steer`:`send`}var we=`↪ Folded into`;function Te(e){let t=e.trim();return t.startsWith(`To run this:`)?{kind:`handBack`,command:t.slice(q.length).trim()}:t.startsWith(we)?{kind:`steerAck`,text:t}:{kind:`inline`,text:t}}function Ee(e){let t=/^\/runs\/([^/?#]+)(\?t=([^&#]+))?$/.exec(e);if(!t)return null;let n=decodeURIComponent(t[1]),r=t[3]?`?t=${t[3]}`:``;return{id:n,eventsUrl:`/runs/${t[1]}/events${r}`,stopUrl:`/runs/${t[1]}/stop${r}`}}function De(e,t=60){let n=e.split(/\r?\n/).find(e=>e.trim()!==``)?.trim()??``;return n.length<=t?n||`New conversation`:`${n.slice(0,t-1).trimEnd()}…`}function J(e,t){let n=t-e;if(!(n>45e3))return`now`;let r=Math.floor(n/6e4);if(r<60)return`${Math.max(1,r)}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);return a<7?`${a}d`:z(e,t)}function Oe(e,t){let n=e.surface??`web`,r=B[n]??n;return{title:e.excerpt||e.title,when:ce(e.lastAt,t),source:n===`web`?r:`${r} · read-only here`,runs:`${e.runs} run${e.runs===1?``:`s`}`,live:e.live}}var Y={min:224,default:288,max:448,step:16};function ke(e){let t=typeof e==`string`?Number(e):e;return typeof t!=`number`||!Number.isFinite(t)?Y.default:Math.min(Y.max,Math.max(Y.min,Math.round(t)))}var X={width:`sb.rail.width`,collapsed:`sb.rail.collapsed`};function Ae(e){return{width:ke(e.width??void 0),collapsed:e.collapsed===`1`}}function je(e,t){let n=e<5?`Still up`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`;return t?`${n}, ${t}.`:`${n}.`}function Me(e,t){let n=t.trim();for(let t=e.length-1;t>=0;t--){let r=e[t];if(!r.folded&&r.text.trim()===n)return r}return null}function Ne(e,t=60){return e<=t}function Pe(e){return e.key===`Enter`&&!e.shiftKey&&!e.isComposing}function Z(e,t){let n=e.trim().toLowerCase();if(n===``)return 0;let r=t.toLowerCase(),i=0,a=-1,o=-1;for(let e of n){if(e===` `)continue;let t=r.indexOf(e,i);if(t===-1)return null;a===-1&&(a=t),o=t,i=t+1}return a===-1?0:o-a}function Fe(e,t){return t.trim()===``?[...e]:e.map((e,n)=>({row:e,i:n,score:Z(t,e.title)})).filter(e=>e.score!==null).sort((e,t)=>e.score-t.score||e.i-t.i).map(e=>e.row)}function Ie(e){if(!(e.metaKey||e.ctrlKey))return null;let t=e.key.toLowerCase();return t===`o`&&e.shiftKey?`newThread`:t===`k`&&!e.shiftKey?`search`:null}function Le(e,t){return t?``:e===`steer`?`Say what to add — it folds into the run at its next step`:e===`stop`?`A run is working — type to steer it, or stop it`:`Review a pull request, ship a fix, investigate a run… or type / for a command`}function Re(e){let t=new Map;for(let n of e){let[e,r]=n.chat.split(` `,2);if(!e)continue;let i=t.get(e)??{name:e,verbs:[]};r===void 0?i.bare=n:i.verbs.push({verb:r,command:n}),t.set(e,i)}return[...t.values()]}function ze(e,t,n){if(t===``)return[...e];let r=t.toLowerCase(),i=e.filter(e=>n(e)[0].toLowerCase().startsWith(r));return i.length>0?i:e.map((e,r)=>{let i=n(e).map(e=>Z(t,e)).filter(e=>e!==null);return i.length===0?null:{item:e,i:r,score:Math.min(...i)}}).filter(e=>e!==null).sort((e,t)=>e.score-t.score||e.i-t.i).map(e=>e.item)}function Be(e,t=0,n=new Set){let r=(e.args??[]).slice(t),i=(e.options??[]).filter(e=>!n.has(Q(e.form))).map(e=>`[${e.form}]`);return[...r,...i].join(` `)}var Q=e=>e.split(` `,1)[0];function $(e,t){let n=new Set,r=0;for(let i=0;i<t.length;i++){let a=t[i];if(a.startsWith(`-`)){n.add(a);let t=(e.options??[]).find(e=>Q(e.form)===a);t&&t.form.includes(` `)&&i++}else r++}return{positionals:r,flags:n}}function Ve(e,t){let n=/^\/([^\n]*)$/.exec(e);if(!n||t.length===0)return null;let r=n[1].split(` `),i=r[r.length-1],a=r.slice(0,-1).filter(e=>e!==``),o=e.slice(0,e.length-i.length),s=Re(t);if(a.length===0)return{level:`group`,head:o,partial:i,rows:ze(s,i,e=>[e.name,...e.bare?[e.bare.describe]:[],...e.verbs.map(e=>e.command.describe)]).map(e=>({insert:e.name,label:`/${e.name}`,describe:e.bare?e.verbs.length>0?`${e.bare.describe} · also ${e.verbs.map(e=>e.verb).join(`, `)}`:e.bare.describe:e.verbs.map(e=>e.verb).join(` · `),kind:e.bare&&e.verbs.length===0?`command`:`group`,acceptable:!0}))};let c=s.find(e=>e.name===a[0]);if(!c)return null;if(a.length===1){let e=ze(c.verbs,i,e=>[e.verb,e.command.describe]);if(e.length===0&&c.bare&&i!==``)return Ue(c.bare,o,i,[]);if(e.length===0&&!c.bare)return{level:`verb`,head:o,partial:i,rows:[]};let t=e.map(e=>({insert:e.verb,label:`/${e.command.chat}`,describe:e.command.describe,kind:`command`,acceptable:!0}));return c.bare&&i===``&&t.unshift(He(c.bare,0,new Set)),{level:`verb`,head:o,partial:i,rows:t}}let l=c.verbs.find(e=>e.verb===a[1]);return l?Ue(l.command,o,i,a.slice(2)):c.bare?Ue(c.bare,o,i,a.slice(1)):null}function He(e,t,n){let r=Be(e,t,n);return{insert:``,label:`/${e.chat}`,describe:r?`${r} — ${e.describe}`:e.describe,kind:`usage`,acceptable:!1}}function Ue(e,t,n,r){let i=$(e,r);return n.startsWith(`-`)?{level:`tail`,head:t,partial:n,rows:ze((e.options??[]).filter(e=>!i.flags.has(Q(e.form))),n,e=>[Q(e.form),e.describe]).map(e=>({insert:Q(e.form),label:e.form,describe:e.describe,kind:`option`,acceptable:!0})),command:e}:{level:`tail`,head:t,partial:n,rows:[He(e,i.positionals,i.flags)],command:e}}function We(e,t){let n=e.rows[t];if(!n)return null;if(n.acceptable){if(!n.insert.toLowerCase().startsWith(e.partial.toLowerCase()))return null;let t=n.insert.slice(e.partial.length);return t===``?null:{text:t,acceptable:!0}}if(e.partial!==``||n.kind!==`usage`)return null;let[r,...i]=n.describe.split(` — `);return i.length===0?null:{text:r,acceptable:!1}}function Ge(e,t){return`${e.head}${t.insert} `}function Ke(e,t){if(!e.startsWith(`/`))return e;let n=e.slice(1),[r,i]=n.split(/\s+/,2);return t.some(e=>e.chat===r||i!==void 0&&e.chat===`${r} ${i}`)?n:e}var qe={class:`composer-wrap relative`},Je={key:0,class:`palette absolute bottom-full left-0 right-0 z-20 mb-2 max-h-72 overflow-y-auto rounded-xl border border-default bg-(--ui-bg-elevated) p-1 shadow-sm`,role:`listbox`,"aria-label":`Commands`,"data-testid":`palette`},Ye={key:0,class:`px-3 py-2 font-mono text-xs text-dimmed`},Xe=[`aria-selected`,`data-insert`,`data-kind`,`data-label`,`onClick`,`onMouseenter`],Ze={class:`chat shrink-0 font-mono text-[0.8rem] font-medium text-highlighted`},Qe={class:`describe min-w-0 flex-1 truncate text-[0.8rem] text-muted`},$e={key:0,class:`shrink-0 rounded border border-default px-1 font-mono text-[0.62rem] text-dimmed`,"aria-hidden":`true`},et=[`data-mode`],tt={class:`relative min-w-0 flex-1`},nt=[`data-acceptable`],rt={class:`invisible`},it={class:`text-dimmed`},at=[`rows`,`value`,`placeholder`,`autofocus`,`aria-expanded`],ot=[`aria-hidden`,`data-hint`,`data-shown`],st=N({__name:`ChatComposer`,props:{modelValue:{},mode:{},hint:{},autofocus:{type:Boolean},sweepOnMount:{type:Boolean},commands:{}},emits:[`update:modelValue`,`submit`,`stop`],setup(e,{expose:t,emit:n}){let r=e,i=n,o=h(null),u=h(!1),d=h(!1),_=w(()=>Math.min(8,Math.max(1,r.modelValue.split(`
|
|
2
|
+
`).length))),v={send:{icon:`i-lucide-arrow-up`,label:`Send`},steer:{icon:`i-lucide-corner-down-right`,label:`Steer the run`},stop:{icon:`i-lucide-square`,label:`Stop the run`}},y=w(()=>v[r.mode]),te=w(()=>Le(r.mode,r.hint)),C=w(()=>r.hint?r.hint:r.mode===`steer`?`Enter folds this into the run in flight`:r.mode===`stop`?`A run is in flight · type to steer it, or stop it`:`Enter to send · Shift+Enter for a new line · / for a command`),T=w(()=>u.value||r.hint!==void 0||r.mode!==`send`),E=w(()=>Ve(r.modelValue,r.commands??[])),k=w(()=>E.value?.rows??[]),N=h(!1),P=h(0),F=w(()=>E.value!==null&&!N.value),I=w(()=>F.value&&E.value?We(E.value,P.value):null);c(()=>`${E.value?.level??``}|${E.value?.head??``}`,()=>{N.value=!1,P.value=0}),c(k,e=>{P.value>=e.length&&(P.value=Math.max(0,e.length-1))});function L(e){E.value&&e.acceptable&&(i(`update:modelValue`,Ge(E.value,e)),z())}function re(){let e=o.value;return!e||e.selectionStart===e.value.length&&e.selectionEnd===e.value.length}function ie(e){i(`update:modelValue`,e.target.value)}function R(e){if(F.value){if(e.key===`ArrowDown`){e.preventDefault(),k.value.length>0&&(P.value=(P.value+1)%k.value.length);return}if(e.key===`ArrowUp`){e.preventDefault(),k.value.length>0&&(P.value=(P.value-1+k.value.length)%k.value.length);return}if(e.key===`Escape`){e.preventDefault(),N.value=!0;return}let t=k.value[P.value];if(e.key===`Tab`&&t?.acceptable){e.preventDefault(),L(t);return}if(e.key===`ArrowRight`&&I.value?.acceptable&&t&&re()){e.preventDefault(),L(t);return}if(e.key===`Enter`&&!e.shiftKey&&t?.acceptable){e.preventDefault(),L(t);return}}Pe(e)&&(e.preventDefault(),ae())}function ae(){r.mode===`stop`?i(`stop`):r.modelValue.trim()!==``&&i(`submit`)}function oe(){d.value=!1,a().then(()=>{d.value=!0})}function se(){u.value=!0,oe()}function z(){a().then(()=>{let e=o.value;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length),document.activeElement===e&&!u.value&&se())})}return c(()=>r.hint,e=>{e&&z()}),l(()=>{r.autofocus&&z(),r.sweepOnMount&&oe()}),t({focus:z}),(t,n)=>{let r=S,i=ee;return b(),O(`div`,qe,[m(M,{name:`sb-rise`},{default:s(()=>[F.value?(b(),O(`div`,Je,[k.value.length===0?(b(),O(`p`,Ye,` No command matches "`+A(e.modelValue)+`". `,1)):x(``,!0),(b(!0),O(p,null,ne(k.value,(e,t)=>(b(),O(`button`,{key:e.label,type:`button`,role:`option`,class:j([`item flex w-full items-baseline gap-3 rounded-lg px-3 py-1.5 text-left transition-colors duration-150 ease-out`,t===P.value?`bg-(--ui-bg-accented)`:`hover:bg-(--ui-bg-muted)`]),"aria-selected":t===P.value?`true`:`false`,"data-insert":e.insert,"data-kind":e.kind,"data-label":e.label,onMousedown:n[0]||=f(()=>{},[`prevent`]),onClick:t=>L(e),onMouseenter:e=>P.value=t},[D(`span`,Ze,A(e.label),1),D(`span`,Qe,A(e.describe),1),t===P.value&&e.acceptable?(b(),O(`kbd`,$e,`Tab`)):x(``,!0)],42,Xe))),128))])):x(``,!0)]),_:1}),D(`div`,{class:j([`ring relative rounded-2xl`,d.value?`ring-sweep`:``]),onAnimationend:n[2]||=e=>d.value=!1},[D(`form`,{class:j([`composer relative flex items-end gap-2 rounded-2xl border bg-default px-3 py-2 transition-colors duration-150 ease-out`,u.value?`border-primary`:`border-default hover:border-accented`]),"data-mode":e.mode,onSubmit:f(ae,[`prevent`])},[D(`div`,tt,[I.value?(b(),O(`div`,{key:0,class:`ghost composer-text pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap break-words`,"aria-hidden":`true`,"data-testid":`ghost`,"data-acceptable":I.value.acceptable?`1`:`0`},[D(`span`,rt,A(e.modelValue),1),D(`span`,it,A(I.value.text),1)],8,nt)):x(``,!0),D(`textarea`,{ref_key:`box`,ref:o,class:`box composer-text relative block min-h-6 w-full resize-none bg-transparent text-highlighted outline-none placeholder:text-dimmed`,rows:_.value,value:e.modelValue,placeholder:te.value,autofocus:e.autofocus,"aria-label":`Message`,"aria-expanded":F.value?`true`:void 0,autocomplete:`off`,spellcheck:`true`,onInput:ie,onKeydown:R,onFocus:se,onBlur:n[1]||=e=>u.value=!1},null,40,at)]),m(i,{type:`submit`,class:`control shrink-0 rounded-full transition-transform duration-150 ease-out active:scale-95`,color:e.mode===`stop`?`neutral`:`primary`,variant:e.mode===`stop`?`outline`:`solid`,size:`sm`,"aria-label":y.value.label,title:y.value.label,disabled:e.mode===`send`&&e.modelValue.trim()===``,"data-mode":e.mode},{default:s(()=>[m(M,{name:`sb-fade`,mode:`out-in`},{default:s(()=>[(b(),g(r,{key:y.value.icon,name:y.value.icon,class:`size-4`,"aria-hidden":`true`},null,8,[`name`]))]),_:1})]),_:1},8,[`color`,`variant`,`aria-label`,`title`,`disabled`,`data-mode`])],42,et)],34),D(`p`,{class:j([`hint mt-1.5 min-h-[1.1rem] select-none px-3 font-mono text-[0.7rem] text-dimmed transition-opacity duration-150 ease-out`,T.value?`opacity-100`:`opacity-0`]),"aria-hidden":T.value?void 0:`true`,"data-hint":e.hint?`handback`:e.mode,"data-shown":T.value?`1`:`0`},A(C.value),11,ot)])}}}),ct={class:`thread-tip flex max-w-xs flex-col gap-1 text-xs`},lt={class:`tip-title leading-snug text-highlighted`},ut={class:`flex flex-wrap items-center gap-x-1.5 gap-y-0.5 font-mono text-[0.68rem] text-muted`},dt={class:`tip-when tabular-nums`},ft={class:`tip-source inline-flex items-center gap-1`},pt={class:`tip-runs`},mt={key:0,class:`tip-live inline-flex items-center gap-1 text-toned`},ht=N({__name:`ThreadTip`,props:{row:{},now:{}},setup(e){let t=e,n=w(()=>Oe(t.row,t.now));return(t,r)=>(b(),O(`div`,ct,[D(`p`,lt,A(n.value.title),1),D(`p`,ut,[D(`span`,dt,A(n.value.when),1),r[1]||=D(`span`,{"aria-hidden":`true`},`·`,-1),D(`span`,ft,[e.row.surface===`slack`?(b(),g(pe,{key:0})):x(``,!0),v(A(n.value.source),1)]),r[2]||=D(`span`,{"aria-hidden":`true`},`·`,-1),D(`span`,pt,A(n.value.runs),1),n.value.live?(b(),O(`span`,mt,[...r[0]||=[D(`span`,{class:`size-1.5 rounded-full bg-ok`,"aria-hidden":`true`},null,-1),v(`live`,-1)]])):x(``,!0)])]))}}),gt={class:`rail flex flex-col gap-1 text-[0.8rem]`,"aria-label":`Recent threads`},_t=[`aria-current`],vt={class:`filter mb-2 flex items-center gap-2 rounded-lg border border-default px-2.5 py-1.5 transition-colors duration-150 ease-out focus-within:border-primary hover:border-accented`},yt={key:0,class:`rounded border border-default px-1 font-mono text-[0.65rem] text-dimmed`},bt={key:0,class:`empty px-3 py-1 text-xs text-dimmed`},xt={key:1,class:`nomatch px-3 py-1 text-xs text-dimmed`},St=[`href`,`aria-current`,`data-surface`],Ct={key:0,class:`dot mt-px size-1.5 shrink-0 self-center rounded-full bg-ok motion-safe:animate-pulse`,"aria-label":`a run is in flight`},wt={class:`title min-w-0 flex-1 truncate text-toned group-hover:text-highlighted group-aria-[current=page]:text-highlighted`},Tt={class:`when shrink-0 font-mono text-[0.7rem] tabular-nums text-dimmed`},Et={class:`all mt-3 flex items-center gap-1.5 px-3 py-1 text-xs font-medium text-muted no-underline transition-colors duration-150 ease-out hover:text-highlighted`,href:`/runs`,"data-testid":`all-runs`},Dt={class:`retention px-3 pt-1 text-[0.7rem] leading-relaxed text-dimmed`},Ot=500,kt=N({__name:`ConversationRail`,props:{rows:{},current:{},now:{},retention:{}},setup(e,{expose:t}){let n=e,r=h(``),i=h(null),a=w(()=>Fe(n.rows,r.value));function o(){i.value?.focus(),i.value?.select()}function c(e){e.key===`Escape`&&(r.value=``,i.value?.blur())}return t({focusFilter:o}),(t,n)=>{let o=S,l=F;return b(),O(`nav`,gt,[D(`a`,{class:`new group mb-3 flex items-center gap-2 rounded-xl bg-inverted px-3 py-2 font-medium text-inverted no-underline transition-[transform,opacity] duration-150 ease-out hover:-translate-y-px hover:opacity-90 active:translate-y-0 active:opacity-100`,href:`/threads`,"aria-current":e.current===``?`page`:void 0,"data-testid":`new-thread`},[m(o,{name:`i-lucide-plus`,class:`size-4 shrink-0 transition-transform duration-150 ease-out group-hover:rotate-90`,"aria-hidden":`true`}),n[1]||=D(`span`,null,`New thread`,-1),n[2]||=D(`span`,{class:`kbd ml-auto flex gap-0.5 font-mono text-[0.65rem] opacity-70`,"aria-label":`shortcut shift command O`},[D(`kbd`,{class:`rounded border border-current/30 px-1`},`⇧`),D(`kbd`,{class:`rounded border border-current/30 px-1`},`⌘`),D(`kbd`,{class:`rounded border border-current/30 px-1`},`O`)],-1)],8,_t),D(`label`,vt,[m(o,{name:`i-lucide-search`,class:`size-3.5 shrink-0 text-dimmed`,"aria-hidden":`true`}),P(D(`input`,{ref_key:`filter`,ref:i,"onUpdate:modelValue":n[0]||=e=>r.value=e,class:`min-w-0 flex-1 bg-transparent text-[0.8rem] text-highlighted outline-none placeholder:text-dimmed`,type:`text`,placeholder:`Filter recent`,"aria-label":`Filter recent threads`,autocomplete:`off`,onKeydown:c},null,544),[[d,r.value]]),r.value?x(``,!0):(b(),O(`kbd`,yt,`⌘K`))]),n[5]||=D(`p`,{class:`label px-3 pb-1 font-mono text-[0.65rem] font-medium uppercase tracking-wider text-dimmed`},`Recent`,-1),e.rows.length===0?(b(),O(`p`,bt,`Nothing yet. Ask something.`)):a.value.length===0?(b(),O(`p`,xt,`Nothing matches "`+A(r.value)+`".`,1)):x(``,!0),m(u,{name:`sb-rise`,tag:`div`,class:`rows flex flex-col gap-0.5`},{default:s(()=>[(b(!0),O(p,null,ne(a.value,t=>(b(),O(`div`,{key:t.id},[m(l,{"delay-duration":Ot,content:{side:`right`,sideOffset:12,align:`start`},ui:{content:`h-auto max-w-xs px-2.5 py-2`}},{content:s(()=>[m(ht,{row:t,now:e.now},null,8,[`row`,`now`])]),default:s(()=>[D(`a`,{class:`row group relative flex items-baseline gap-2 rounded-lg px-3 py-1.5 no-underline transition-colors duration-150 ease-out hover:bg-(--ui-bg-muted) aria-[current=page]:bg-(--ui-bg-accented)`,href:`/threads/${encodeURIComponent(t.id)}`,"aria-current":t.id===e.current?`page`:void 0,"data-surface":t.surface},[n[3]||=D(`span`,{class:`bar absolute left-0 top-1/2 h-4 w-0.5 -translate-y-1/2 rounded-full bg-primary opacity-0 transition-opacity duration-150 ease-out group-aria-[current=page]:opacity-100`,"aria-hidden":`true`},null,-1),t.live?(b(),O(`span`,Ct)):x(``,!0),D(`span`,wt,A(t.title),1),D(`span`,Tt,A(k(J)(t.lastAt,e.now)),1)],8,St)]),_:2},1024)]))),128))]),_:1}),D(`a`,Et,[n[4]||=v(` All runs `,-1),m(o,{name:`i-lucide-arrow-right`,class:`size-3 transition-transform duration-150 ease-out group-hover:translate-x-0.5`,"aria-hidden":`true`})]),D(`p`,Dt,A(e.retention),1)])}}}),At={class:`empty mx-auto flex w-full max-w-2xl flex-col items-center gap-5 px-3 py-6 text-center`},jt={class:`flex flex-col gap-1.5`},Mt={class:`greeting sb-stagger text-xl font-medium tracking-tight text-highlighted`,style:{"--sb-i":`1`}},Nt={class:`sb-stagger w-full text-left`,style:{"--sb-i":`3`}},Pt={key:0,class:`chips flex flex-wrap justify-center gap-2`,"aria-label":`Suggestions`},Ft=[`onClick`],It=N({__name:`EmptyState`,props:{name:{},hour:{},suggestions:{}},emits:[`pick`],setup(e,{emit:t}){let r=t;return(t,a)=>(b(),O(`section`,At,[m(n,{draw:``,idle:``,class:`mark-lg sb-stagger text-highlighted`,style:{"font-size":`3.25rem`,"--sb-i":`0`}}),D(`div`,jt,[D(`h2`,Mt,A(k(je)(e.hour,e.name)),1),a[0]||=D(`p`,{class:`sub sb-stagger text-[0.875rem] text-muted`,style:{"--sb-i":`2`}},` Ask in plain words. The right agent picks it up, and you watch it work here. `,-1)]),D(`div`,Nt,[_(t.$slots,`default`)]),e.suggestions.length>0?(b(),O(`ul`,Pt,[(b(!0),O(p,null,ne(e.suggestions,(e,t)=>(b(),O(`li`,{key:e,class:`sb-stagger`,style:i({"--sb-i":t+4})},[D(`button`,{type:`button`,class:`chip rounded-full border border-default px-3 py-1 text-[0.8rem] text-toned transition-[color,border-color,background-color,transform] duration-150 ease-out hover:-translate-y-px hover:border-accented hover:bg-(--ui-bg-muted) hover:text-highlighted focus-visible:outline-2 focus-visible:outline-primary active:translate-y-0`,onClick:t=>r(`pick`,e)},A(e),9,Ft)],4))),128))])):x(``,!0)]))}}),Lt=[`data-pending`],Rt={class:`meta flex items-baseline gap-2 pr-1 font-mono text-[0.7rem] text-dimmed`},zt={key:0,class:`failed text-bad`},Bt={key:0,class:`folded text-muted`},Vt=[`title`],Ht=N({__name:`PersonTurn`,props:{text:{},at:{},now:{},pending:{type:Boolean},folded:{},failed:{}},setup(e){let t=e,n=w(()=>ce(t.at,t.now));return(t,r)=>(b(),O(`div`,{class:`turn person flex flex-col items-end gap-1`,"data-pending":e.pending?`1`:void 0},[D(`div`,{class:j([`bubble max-w-[min(42rem,88%)] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-(--ui-bg-accented) px-4 py-2.5 text-[0.875rem] leading-normal text-highlighted transition-opacity duration-150 ease-out`,e.pending?`opacity-70`:``])},A(e.text),3),D(`div`,Rt,[e.failed?(b(),O(`span`,zt,A(e.failed),1)):x(``,!0),m(M,{name:`sb-fade`},{default:s(()=>[e.folded?(b(),O(`span`,Bt,`↪ folded in `+A(e.folded),1)):x(``,!0)]),_:1}),D(`span`,{class:`ts select-none`,title:k(V)(e.at)},A(n.value),9,Vt)])],8,Lt))}}),Ut=[`title`],Wt={class:`preset font-medium`},Gt={class:`reason truncate font-normal opacity-80`},Kt=N({__name:`ReceiptChip`,props:{route:{}},setup(e){let t=e,n=w(()=>de[ue(t.route.preset)]);return(t,r)=>(b(),O(`span`,{class:j([`receipt inline-flex max-w-full items-baseline gap-1.5 rounded border px-1.5 py-px font-mono text-[0.7rem] leading-relaxed`,n.value]),title:`routed: ${e.route.reason}`,"data-testid":`receipt`},[D(`span`,Wt,A(e.route.preset),1),D(`span`,Gt,`· `+A(e.route.reason),1)],10,Ut))}}),qt=[`data-phase`,`data-run-id`,`data-live`],Jt={class:`head flex flex-wrap items-baseline gap-2 font-mono text-[0.7rem] text-dimmed`},Yt={key:0,class:`model`},Xt={key:1,class:`elapsed ml-auto tabular-nums`,"data-testid":`elapsed`},Zt={key:0,class:`disconnected flex items-baseline gap-2 rounded-lg border border-dashed border-bad/40 px-3 py-2 font-mono text-xs text-bad`,"data-testid":`disconnected`},Qt=[`href`],$t=[`open`],en={class:`flex min-h-6 cursor-pointer list-none items-baseline gap-2 font-mono text-[0.7rem] text-dimmed hover:text-toned [&::-webkit-details-marker]:hidden`},tn={class:`summary`},nn={class:`pl-1 pt-1`},rn={key:0,class:`py-2 font-mono text-xs text-dimmed`},an={key:1,class:`py-2 font-mono text-xs text-warn`},on=[`href`],sn={key:2,class:`m-0 list-none p-0`},cn={key:0,class:`reply`,"data-testid":`reply`},ln={key:1,class:`outcome font-mono text-xs text-warn`,"data-testid":`outcome`},un={key:2,class:`facts flex flex-wrap items-baseline gap-x-3 font-mono text-[0.7rem] text-dimmed`},dn=[`href`],fn=N({__name:`AssistantTurn`,props:{turn:{},now:{},live:{},fetch:{}},emits:[`ended`,`input`,`stop`],setup(e,{emit:t}){let n=e,r=t,a=_e(),o=a.state,d=h(n.live?`connecting`:`ended`),f=h(n.turn.route??null),ee=h(!0),_=w(()=>o.reply?.text??n.turn.answer??``),y=w(()=>o.meta?.agent??n.turn.agent??``),S=w(()=>{let e=o.meta?.model??n.turn.model;return e?W(e):``}),C=w(()=>n.live!==null&&n.live!==void 0&&d.value!==`ended`),E=w(()=>d.value===`disconnected`),N=n.live?.serverNow?xe({startedAt:n.turn.startedAt,receivedAt:n.turn.receivedAt,serverNow:n.live.serverNow},n.now):null,P=n.now,F=h(void 0),I=w(()=>n.turn.finished&&n.turn.finishedAt!==void 0?Math.max(0,n.turn.finishedAt-(n.turn.receivedAt??n.turn.startedAt)):F.value===void 0?N?N.elapsedMs(n.now):Math.max(0,n.now-P):F.value),ae=w(()=>le(I.value,`clock`)),oe=w(()=>he(C.value?void 0:I.value,`run`)),se=w(()=>me(oe.value)),z=w(()=>C.value?K(o,n.now):null);T(be,z),T(ve,null),T(U,w(()=>o.reply!==null));let ce=w(()=>C.value?G(o,a.pendingCall(),n.now):null),B=w(()=>{let e=ce.value;return E.value||!e||e.kind===`call`?null:e.kind===`starting`?{verb:`Starting`,elapsedMs:I.value,slow:!1}:{verb:L(e.elapsedMs),elapsedMs:e.elapsedMs,slow:e.slow}}),V=w(()=>o.log.filter(e=>e.kind===`step`)),pe=w(()=>V.value.length>0?V.value.length:n.turn.stepCount??0),q=w(()=>n.turn.finished&&n.turn.status&&n.turn.status!==`completed`?fe(n.turn.status):``),Ce=w(()=>`/runs/${encodeURIComponent(n.turn.id)}`),we=R(),Te=null;function Ee(e){let t=e;t.type===`route`&&typeof t.preset==`string`&&(f.value={preset:t.preset,reason:typeof t.reason==`string`?t.reason:``}),t.type===`input`&&typeof t.text==`string`&&(ee.value?ee.value=!1:r(`input`,t.text,t.at)),a.handle(e)}l(()=>{n.live&&(r(`stop`,n.live.stopUrl),Te=re({url:n.live.eventsUrl,factory:we,model:a,handle:Ee,onFinished:e=>{F.value=N&&e?N.elapsedAt(e.finishedAt):I.value},onEnd:()=>{F.value??=I.value,r(`ended`)},onDisconnected:()=>{F.value??=I.value}}),c(Te.phase,e=>d.value=e,{immediate:!0}))}),te(()=>Te?.close());let De=h(n.live!==null&&n.live!==void 0),J=h(n.live?`ready`:`none`);c(C,e=>{e||(De.value=!1)});async function Oe(e){if(De.value=e.target.open,!De.value||J.value!==`none`)return;J.value=`loading`;let t=n.fetch??((...e)=>globalThis.fetch(...e));try{let e=await t(`/runs/${encodeURIComponent(n.turn.id)}/events`,{credentials:`same-origin`});if(!e.ok)throw Error(`HTTP ${e.status}`);let r=Se(await e.text()).filter(e=>e.type!==`replay_note`);for(let e of(n.turn.schema??0)>=2?H(r):r)a.handle(e);a.closePhases(),J.value=`ready`}catch{J.value=`failed`}}let Y=w(()=>{let e=pe.value;return e>0?`${e} step${e===1?``:`s`}`:C.value?`starting`:`no steps recorded`});return(t,n)=>(b(),O(`div`,{class:`turn assistant flex flex-col gap-2`,"data-phase":d.value,"data-run-id":e.turn.id,"data-live":C.value?`1`:void 0},[D(`div`,Jt,[m(M,{name:`sb-rise`},{default:s(()=>[f.value?(b(),g(Kt,{key:`receipt`,route:f.value},null,8,[`route`])):y.value?(b(),O(`span`,{key:`agent`,class:j([`agent rounded border px-1.5 py-px font-medium`,k(de)[k(ue)(y.value)]])},A(y.value),3)):x(``,!0)]),_:1}),S.value?(b(),O(`span`,Yt,A(S.value),1)):x(``,!0),C.value?(b(),O(`span`,Xt,A(ae.value),1)):x(``,!0)]),m(M,{name:`sb-fade`},{default:s(()=>[C.value&&B.value?(b(),g(ie,{key:0,tag:`div`,verb:B.value.verb,"elapsed-ms":B.value.elapsedMs,slow:B.value.slow,model:k(o).meta?.model??e.turn.model??null},null,8,[`verb`,`elapsed-ms`,`slow`,`model`])):x(``,!0)]),_:1}),E.value?(b(),O(`p`,Zt,[n[0]||=D(`span`,null,`stream disconnected · the run may still be working`,-1),D(`a`,{class:`ml-auto text-primary no-underline hover:underline`,href:Ce.value},`open the run`,8,Qt)])):x(``,!0),C.value||pe.value>0||J.value!==`none`?(b(),O(`details`,{key:1,class:`work group`,open:De.value,"data-testid":`work`,onToggle:Oe},[D(`summary`,en,[n[1]||=D(`span`,{class:`chev select-none transition-transform duration-150 ease-out group-open:rotate-90 motion-reduce:transition-none`},`❯`,-1),D(`span`,tn,A(Y.value),1)]),D(`div`,nn,[J.value===`loading`?(b(),O(`p`,rn,`reading the run's record…`)):J.value===`failed`?(b(),O(`p`,an,[n[2]||=v(` the run's record could not be read — `,-1),D(`a`,{class:`text-primary no-underline hover:underline`,href:Ce.value},`open the run`,8,on)])):(b(),O(`ol`,sn,[m(u,{name:`sb-rise`},{default:s(()=>[(b(!0),O(p,null,ne(V.value,e=>(b(),g(ye,{key:e.key,step:e,class:`mt-3 first:mt-0`,onToggleGroup:t=>k(a).toggleGroup(e)},null,8,[`step`,`onToggleGroup`]))),128))]),_:1})]))])],40,$t)):x(``,!0),m(M,{name:`sb-rise`},{default:s(()=>[_.value?(b(),O(`div`,cn,[m(ge,{text:_.value},null,8,[`text`])])):q.value?(b(),O(`p`,ln,A(q.value),1)):x(``,!0)]),_:1}),C.value?x(``,!0):(b(),O(`div`,un,[D(`span`,{class:j([`dur tabular-nums`,se.value?`heat`:``]),style:i(se.value)},A(ae.value),7),D(`a`,{class:`open text-dimmed no-underline hover:text-primary hover:underline`,href:Ce.value},`open run`,8,dn)]))],8,qt))}}),pn={key:0,class:`mx-auto my-12 max-w-xl text-center text-toned`},mn=[`data-rail`],hn={key:0,class:`relative hidden md:block`},gn=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`],_n={class:`thread mx-auto flex min-h-[calc(100vh-8rem)] w-full max-w-3xl flex-col`},vn={key:2,class:`inline text-[0.875rem] text-toned`,"data-testid":`inline`},yn={key:2,class:`elsewhere sticky bottom-0 z-10 -mx-3 mt-auto bg-default/85 px-3 py-4 text-center text-[0.8rem] text-toned backdrop-blur sm:-mx-5 sm:px-5`,"data-testid":`elsewhere`},bn=[`href`],xn={key:3,class:`composer-dock sticky bottom-0 z-10 -mx-3 mt-auto bg-default/85 px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] pt-3 backdrop-blur sm:-mx-5 sm:px-5`},Sn=`(min-width: 48rem)`,Cn=N({__name:`HomePage`,setup(n){let d=E(`home`),f=ae(d?.now),_=d?.conversation??``,S=y(d?.retentionDays??null),N=0,P=e=>`${e}-${++N}`,F=C([]);for(let e of d?.turns??[]){F.push({key:P(`p`),kind:`person`,text:e.request,at:e.receivedAt??e.startedAt,pending:!1});let t=!e.finished&&e.token?{eventsUrl:`/runs/${encodeURIComponent(e.id)}/events?t=${e.token}`,stopUrl:`/runs/${encodeURIComponent(e.id)}/stop?t=${e.token}`,serverNow:d?.now}:null;F.push({key:P(`a`),kind:`assistant`,turn:e,live:t,ended:e.finished})}let L=w(()=>{for(let e=F.length-1;e>=0;e--){let t=F[e];if(t.kind===`assistant`&&t.live&&!t.ended)return t}return null}),re=h(null),ie=h(0);T(e,ie);let R=h(``),z=h(void 0),ce=w(()=>Ce(L.value!==null,R.value)),ue=h(!1);c(R,()=>{z.value&&R.value===``&&(z.value=void 0)});function de(e){R.value=e,fe()}async function fe(){if(!d||ue.value)return;let e=Ke(R.value.trim(),d.commands);if(e===``)return;let n=C({key:P(`p`),kind:`person`,text:e,at:f.value,pending:!0});F.push(n),R.value=``,z.value=void 0,ue.value=!0,ie.value++;try{let r=await fetch(d.sendUrl,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify({text:e})}),i=await r.json().catch(()=>({}));if(r.status===202&&typeof i.viewPath==`string`&&typeof i.runId==`string`){let r=Ee(i.viewPath);if(!r)throw Error(`the run's view path was not one`);n.pending=!1,t.pathname()===`/threads`&&t.replaceUrl(`/threads/${encodeURIComponent(_)}`),F.push({key:P(`a`),kind:`assistant`,turn:{id:i.runId,request:e,startedAt:f.value,receivedAt:f.value,finished:!1,eventCount:0},live:{eventsUrl:r.eventsUrl,stopUrl:r.stopUrl},ended:!1});return}if(r.ok&&typeof i.reply==`string`){n.pending=!1;let e=Te(i.reply);e.kind===`handBack`?(R.value=e.command,z.value=`Enter runs it`):e.kind===`inline`&&F.push({key:P(`i`),kind:`inline`,text:e.text});return}throw Error(i.error??`HTTP ${r.status}`)}catch(e){n.pending=!1,n.failed=`not sent: ${e instanceof Error?e.message:`error`}`}finally{ue.value=!1}}function V(){let e=re.value;e&&fetch(`${e}${e.includes(`?`)?`&`:`?`}mode=soft`,{method:`POST`,credentials:`same-origin`})}function pe(e,t,n){let r=Me(F.filter(e=>e.kind===`person`).map(e=>({text:e.text,folded:e.folded!==void 0,ref:e})),t);if(!r)return;let i=e.turn.receivedAt??e.turn.startedAt;r.ref.folded=n===void 0?``:`at ${le(Math.max(0,n-i),`clock`)}`}function me(e){e.ended=!0,re.value=null}let he=Ae({width:t.readPref(X.width),collapsed:t.readPref(X.collapsed)}),H=h(he.width),U=h(he.collapsed),_e=h(!1),W=h(t.mediaMatches(Sn)),ve=t.onMediaChange(Sn,e=>{W.value=e}),ye=h(null),be=h(null),xe=w(()=>W.value?U.value?`Show recent threads`:`Hide recent threads`:`Recent threads`);function Se(){if(W.value=t.mediaMatches(Sn),W.value){U.value=!U.value,t.writePref(X.collapsed,U.value?`1`:`0`);return}_e.value=!0}function G(e,n){H.value=ke(e),n&&t.writePref(X.width,String(H.value))}let K=null;function q(e){K&&G(K.startWidth+(e.clientX-K.startX),!1)}function we(){window.removeEventListener(`pointermove`,q),K&&(K=null,t.writePref(X.width,String(H.value)))}function J(e){e.button===0&&(e.preventDefault(),K={startX:e.clientX,startWidth:H.value},e.currentTarget?.setPointerCapture?.(e.pointerId),window.addEventListener(`pointermove`,q),window.addEventListener(`pointerup`,we,{once:!0}))}function Oe(e){if(e.key===`ArrowRight`)G(H.value+Y.step,!0);else if(e.key===`ArrowLeft`)G(H.value-Y.step,!0);else if(e.key===`Home`)G(Y.min,!0);else if(e.key===`End`)G(Y.max,!0);else return;e.preventDefault()}o(()=>{window.removeEventListener(`pointermove`,q),window.removeEventListener(`pointerup`,we),ve()});function je(e){let n=Ie(e);if(n){if(e.preventDefault(),n===`newThread`){t.navigate(`/threads`);return}if(ye.value){ye.value.focusFilter();return}if(U.value&&t.mediaMatches(Sn)){U.value=!1,t.writePref(X.collapsed,`0`),a().then(()=>ye.value?.focusFilter());return}_e.value=!0,a().then(()=>be.value?.focusFilter())}}let Pe=h(null),Z=h(!1);function Fe(){return document.body.scrollHeight-(window.innerHeight+window.scrollY)}c(()=>F.length,()=>{let e=Ne(Fe());a().then(()=>{e?Pe.value?.scrollIntoView?.({block:`end`}):Z.value=!0})});function Le(){Ne(Fe())&&(Z.value=!1)}function Re(){Pe.value?.scrollIntoView?.({block:`end`,behavior:`smooth`}),Z.value=!1}l(()=>{window.addEventListener(`scroll`,Le,{passive:!0}),window.addEventListener(`keydown`,je)}),te(()=>{window.removeEventListener(`scroll`,Le),window.removeEventListener(`keydown`,je)});let ze=w(()=>{let e=F.find(e=>e.kind===`person`);return e?De(e.text):`Switchboard`});c([ze,L],([e,n])=>{t.setTitle(n?`(1) ${e}`:e),t.setFavicon(n?se:oe)},{immediate:!0});let Be=w(()=>new Date(f.value).getHours()),Q=w(()=>F.length===0),$=d?.elsewhere,Ve=$?$.surface===`web`?`This thread is another person's conversation. You can read it here.`:`This thread lives in ${B[$.surface]??$.surface}.`:``;return(e,t)=>{let n=ee,a=I;return b(),g(r,{title:`Threads`,nav:`home`},{leading:s(()=>[m(n,{class:`rail-toggle -ml-1`,size:`xs`,color:`neutral`,variant:`ghost`,icon:W.value&&!U.value?`i-lucide-panel-left-close`:`i-lucide-panel-left`,"aria-label":xe.value,"aria-expanded":W.value?!U.value:void 0,onClick:Se},null,8,[`icon`,`aria-label`,`aria-expanded`])]),default:s(()=>[k(d)?(b(),O(`div`,{key:1,class:j([`home gap-8 md:grid`,U.value?`md:grid-cols-[minmax(0,1fr)]`:`md:grid-cols-[var(--rail-w)_minmax(0,1fr)]`]),style:i({"--rail-w":`${H.value}px`}),"data-rail":U.value?`hidden`:`shown`},[U.value?x(``,!0):(b(),O(`aside`,hn,[m(kt,{ref_key:`rail`,ref:ye,class:`sticky top-20`,rows:k(d).conversations,current:k(_),now:k(f),retention:k(S)},null,8,[`rows`,`current`,`now`,`retention`]),D(`div`,{class:`handle group/handle absolute inset-y-0 -right-5 flex w-3 cursor-col-resize touch-none select-none justify-center outline-none`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the recent threads column`,"aria-valuemin":k(Y).min,"aria-valuemax":k(Y).max,"aria-valuenow":H.value,tabindex:`0`,"data-testid":`rail-handle`,onPointerdown:J,onKeydown:Oe,onDblclick:t[0]||=e=>G(k(Y).default,!0)},[...t[5]||=[D(`span`,{class:`w-px rounded-full bg-(--ui-border-accented) opacity-0 transition-opacity duration-150 ease-out group-hover/handle:opacity-100 group-focus-visible/handle:opacity-100`,"aria-hidden":`true`},null,-1)]],40,gn)])),m(a,{open:_e.value,"onUpdate:open":t[1]||=e=>_e.value=e,side:`left`,title:`Recent threads`,ui:{content:`max-w-xs`}},{body:s(()=>[m(kt,{ref_key:`sheetRail`,ref:be,rows:k(d).conversations,current:k(_),now:k(f),retention:k(S)},null,8,[`rows`,`current`,`now`,`retention`])]),_:1},8,[`open`]),D(`section`,_n,[Q.value?(b(),g(It,{key:0,class:`mb-auto mt-[clamp(1.5rem,14vh,9rem)]`,name:k(d).viewer.name,hour:Be.value,suggestions:k(d).suggestions,onPick:de},{default:s(()=>[m(st,{modelValue:R.value,"onUpdate:modelValue":t[2]||=e=>R.value=e,mode:ce.value,hint:z.value,commands:k(d).commands,autofocus:``,"sweep-on-mount":``,onSubmit:fe,onStop:V},null,8,[`modelValue`,`mode`,`hint`,`commands`])]),_:1},8,[`name`,`hour`,`suggestions`])):(b(),g(u,{key:1,name:`sb-rise`,"move-class":`sb-move-move`,tag:`ol`,class:`transcript m-0 flex list-none flex-col gap-6 p-0 pb-32 pt-2`},{default:s(()=>[(b(!0),O(p,null,ne(F,e=>(b(),O(`li`,{key:e.key},[e.kind===`person`?(b(),g(Ht,{key:0,text:e.text,at:e.at,now:k(f),pending:e.pending,folded:e.folded,failed:e.failed},null,8,[`text`,`at`,`now`,`pending`,`folded`,`failed`])):e.kind===`assistant`?(b(),g(fn,{key:1,turn:e.turn,live:e.live,now:k(f),onInput:(t,n)=>pe(e,t,n),onEnded:t=>me(e),onStop:t[3]||=e=>re.value=e},null,8,[`turn`,`live`,`now`,`onInput`,`onEnded`])):(b(),O(`div`,vn,[m(ge,{text:e.text},null,8,[`text`])]))]))),128))]),_:1})),D(`div`,{ref_key:`end`,ref:Pe,class:`end`,"aria-hidden":`true`},null,512),!Q.value&&k($)?(b(),O(`p`,yn,[v(A(k(Ve))+` `,1),k($).url?(b(),O(`a`,{key:0,href:k($).url,target:`_blank`,rel:`noopener`,class:`text-highlighted`},`Reply there ↗`,8,bn)):k($).surface===`web`?x(``,!0):(b(),O(p,{key:1},[v(`Reply there.`)],64))])):Q.value?x(``,!0):(b(),O(`div`,xn,[m(M,{name:`sb-rise`},{default:s(()=>[Z.value?(b(),O(`button`,{key:0,type:`button`,class:`new-pill absolute -top-9 left-1/2 -translate-x-1/2 rounded-full border border-default bg-(--ui-bg-elevated) px-3 py-1 font-mono text-[0.7rem] text-toned shadow-sm hover:text-highlighted`,onClick:Re},` ↓ new `)):x(``,!0)]),_:1}),m(st,{modelValue:R.value,"onUpdate:modelValue":t[4]||=e=>R.value=e,mode:ce.value,hint:z.value,commands:k(d).commands,autofocus:``,onSubmit:fe,onStop:V},null,8,[`modelValue`,`mode`,`hint`,`commands`])]))])],14,mn)):(b(),O(`div`,pn,`This page needs its seed.`))]),_:1})}}});export{Cn as default};
|