@coreplane/switchboard 1.267.3 → 1.268.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.
Files changed (39) hide show
  1. package/dist/assets/deploy/cloudflare-memory/worker.ts +23 -1
  2. package/dist/assets/deploy/cloudflare-resident/imageReconcileState.ts +28 -0
  3. package/dist/assets/deploy/cloudflare-resident/shared.ts +2 -3
  4. package/dist/assets/deploy/cloudflare-resident/worker.ts +162 -27
  5. package/dist/assets/package-lock.json +3 -3
  6. package/dist/assets/package.json +1 -1
  7. package/dist/assets/source.json +3 -3
  8. package/dist/assets/src/core/budgets.ts +4 -0
  9. package/dist/assets/src/core/coordinator/contract.ts +14 -8
  10. package/dist/assets/src/core/costs.ts +2 -0
  11. package/dist/assets/src/core/runEvents.ts +1 -0
  12. package/dist/assets/src/core/runLedger/types.ts +2 -0
  13. package/dist/assets/src/core/runRecord.ts +10 -0
  14. package/dist/assets/src/core/runUsage.ts +53 -0
  15. package/dist/assets/src/core/shipSpend.ts +52 -0
  16. package/dist/assets/src/execution/residentPoolSpends.ts +9 -0
  17. package/dist/assets/src/execution/residentRecreateAdmission.ts +28 -0
  18. package/dist/assets/web/dist/.vite/manifest.json +31 -31
  19. package/dist/assets/web/dist/assets/CostsPage-6P9rJ7k_.js +1 -0
  20. package/dist/assets/web/dist/assets/{HomePage-BQmun9kS.js → HomePage-B4LGwXHO.js} +1 -1
  21. package/dist/assets/web/dist/assets/ResidentDetailPage-jpGfsR5n.js +1 -0
  22. package/dist/assets/web/dist/assets/ResidentsIndexPage-C4-5nG9M.js +1 -0
  23. package/dist/assets/web/dist/assets/{RunFoldRow-C1w-mwch.js → RunFoldRow-u4FTh57c.js} +1 -1
  24. package/dist/assets/web/dist/assets/{RunRoutePage-zWMHTzla.js → RunRoutePage-CxOKb7oC.js} +4 -4
  25. package/dist/assets/web/dist/assets/{RunsIndexPage-DF16D2Gg.js → RunsIndexPage-CULSlv_d.js} +1 -1
  26. package/dist/assets/web/dist/assets/{ScheduledPage-CyRs0fXN.js → ScheduledPage-CDjkZuqM.js} +1 -1
  27. package/dist/assets/web/dist/assets/{SettingsPage-BRuMCHSj.js → SettingsPage-BMSomotV.js} +1 -1
  28. package/dist/assets/web/dist/assets/{StatusDot-BIAQN7iD.js → StatusDot-XxLkmRaK.js} +1 -1
  29. package/dist/assets/web/dist/assets/{Tooltip-CxiQ7luL.js → Tooltip-qB73RL4b.js} +1 -1
  30. package/dist/assets/web/dist/assets/{UnitRoutePage-BQB5mAAl.js → UnitRoutePage-DFRWAdOT.js} +1 -1
  31. package/dist/assets/web/dist/assets/{dist-I2OEmPqz.js → dist-BsLBAkQJ.js} +1 -1
  32. package/dist/assets/web/dist/assets/{main-DYwKyLY5.js → main-9ynpo780.js} +10 -10
  33. package/dist/assets/web/dist/assets/main-DSiJ9sHU.css +1 -0
  34. package/dist/cli.js +385 -226
  35. package/package.json +1 -1
  36. package/dist/assets/web/dist/assets/CostsPage-RRggVvIx.js +0 -1
  37. package/dist/assets/web/dist/assets/ResidentDetailPage-CT6v9INM.js +0 -1
  38. package/dist/assets/web/dist/assets/ResidentsIndexPage-CWqPFf40.js +0 -1
  39. package/dist/assets/web/dist/assets/main-DPB0UO1-.css +0 -1
@@ -0,0 +1,52 @@
1
+ import type { DateRange } from "./costs.js";
2
+ import type { RunUsage, ShipRunUsage } from "./runUsage.js";
3
+
4
+ /** Ship child costs within one snapshot, grouped by their durable unit key. */
5
+ export interface ShipSpendReport {
6
+ range: DateRange;
7
+ units: Array<{
8
+ key: string;
9
+ /** The admitted unit cap; null on older runs or inconsistent records. */
10
+ capUsd: number | null;
11
+ /** Unknown after any child with unpriced usage. */
12
+ totalUsd: number | null;
13
+ runs: Array<{ id: string; finishedAt: number; usd: number | null; cumulativeUsd: number | null }>;
14
+ }>;
15
+ }
16
+
17
+ /** The cap gate sums recorded per-model dollars; missing dollars stay unknown, while no model turns cost zero. */
18
+ function recordedUsd(usage: RunUsage | undefined): number | null {
19
+ const models = Object.values(usage?.byModel ?? {});
20
+ if (!usage || !Number.isSafeInteger(usage.turns) || usage.turns < 0) return null;
21
+ if (usage.turns === 0 && models.length === 0) return 0;
22
+ if (
23
+ models.length === 0 ||
24
+ models.reduce((sum, model) => sum + model.turns, 0) !== usage.turns ||
25
+ models.some((model) => typeof model.usd !== "number" || !Number.isFinite(model.usd) || model.usd < 0)
26
+ )
27
+ return null;
28
+ return models.reduce((sum, model) => sum + model.usd!, 0);
29
+ }
30
+
31
+ export function buildShipSpendReport(runs: readonly ShipRunUsage[], range: DateRange): ShipSpendReport {
32
+ const groups = new Map<string, ShipRunUsage[]>();
33
+ for (const run of runs) {
34
+ const day = new Date(run.finishedAt).toISOString().slice(0, 10);
35
+ if (day < range.from || day > range.to) continue;
36
+ groups.set(run.unitKey, [...(groups.get(run.unitKey) ?? []), run]);
37
+ }
38
+ const units = [...groups].map(([key, children]) => {
39
+ const ordered = children.sort((a, b) => a.finishedAt - b.finishedAt || a.id.localeCompare(b.id));
40
+ const caps = new Set(ordered.map((r) => r.costCapUsd));
41
+ const capUsd = caps.size === 1 ? (ordered[0]?.costCapUsd ?? null) : null;
42
+ let cumulative: number | null = 0;
43
+ const points = ordered.map((r) => {
44
+ const usd = recordedUsd(r.usage);
45
+ cumulative = cumulative === null || usd === null ? null : cumulative + usd;
46
+ return { id: r.id, finishedAt: r.finishedAt, usd, cumulativeUsd: cumulative };
47
+ });
48
+ return { key, capUsd, totalUsd: cumulative, runs: points };
49
+ });
50
+ units.sort((a, b) => (b.runs.at(-1)?.finishedAt ?? 0) - (a.runs.at(-1)?.finishedAt ?? 0));
51
+ return { range, units };
52
+ }
@@ -5,6 +5,15 @@ export interface SpentPoolUser {
5
5
  owner: string;
6
6
  }
7
7
 
8
+ /** An owner may reclaim its own UID; only a different owner needs a fresh one. */
9
+ export function unavailablePoolUsers(spent: ReadonlyMap<string, string>, owner: string): Set<string> {
10
+ return new Set([...spent].filter(([, prior]) => prior !== owner).map(([user]) => user));
11
+ }
12
+
13
+ export function ownedPoolUsers(spent: ReadonlyMap<string, string>, owner: string): string[] {
14
+ return [...spent].filter(([, prior]) => prior === owner).map(([user]) => user);
15
+ }
16
+
8
17
  export function parseSpentPoolUsers(value: unknown, pool: readonly string[]): ReadonlyMap<string, string> | null {
9
18
  if (
10
19
  !Array.isArray(value) ||
@@ -39,3 +39,31 @@ export class ResidentRecreateAdmission {
39
39
  }
40
40
  }
41
41
  }
42
+
43
+ /** The request asking for a new UID is the sole in-flight operation. A VM
44
+ * recycle is safe only while no other work or retained workspace owns it. */
45
+ export function idleForPoolRecycle(input: {
46
+ state: string;
47
+ draining: boolean;
48
+ imagePending: boolean;
49
+ inFlight: number;
50
+ refreshAdmissions: number;
51
+ adminWork: number;
52
+ hydrating: boolean;
53
+ registeredRuns: number;
54
+ liveBindings: number;
55
+ inspecting: number;
56
+ }): boolean {
57
+ return (
58
+ input.state === "warm" &&
59
+ !input.draining &&
60
+ !input.imagePending &&
61
+ input.inFlight === 1 &&
62
+ input.refreshAdmissions === 0 &&
63
+ input.adminWork === 0 &&
64
+ !input.hydrating &&
65
+ input.registeredRuns === 0 &&
66
+ input.liveBindings === 0 &&
67
+ input.inspecting === 0
68
+ );
69
+ }
@@ -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-I2OEmPqz.js",
31
+ "file": "assets/dist-BsLBAkQJ.js",
32
32
  "name": "dist",
33
33
  "src": "../node_modules/@pierre/diffs/dist/index.js",
34
34
  "isDynamicEntry": true,
@@ -2581,8 +2581,8 @@
2581
2581
  "_sseReplay-BDVyc8HX.js"
2582
2582
  ]
2583
2583
  },
2584
- "_RunFoldRow-C1w-mwch.js": {
2585
- "file": "assets/RunFoldRow-C1w-mwch.js",
2584
+ "_RunFoldRow-u4FTh57c.js": {
2585
+ "file": "assets/RunFoldRow-u4FTh57c.js",
2586
2586
  "name": "RunFoldRow",
2587
2587
  "imports": [
2588
2588
  "_browser-BWnzWwaT.js",
@@ -2592,7 +2592,7 @@
2592
2592
  "_SlackMark-DjJTK2tD.js",
2593
2593
  "_sseReplay-BDVyc8HX.js",
2594
2594
  "_durationTone-CVpX_yIk.js",
2595
- "_StatusDot-BIAQN7iD.js"
2595
+ "_StatusDot-XxLkmRaK.js"
2596
2596
  ]
2597
2597
  },
2598
2598
  "_RunsTabs-D7rsC4GR.js": {
@@ -2632,16 +2632,16 @@
2632
2632
  "_browser-BWnzWwaT.js"
2633
2633
  ]
2634
2634
  },
2635
- "_StatusDot-BIAQN7iD.js": {
2636
- "file": "assets/StatusDot-BIAQN7iD.js",
2635
+ "_StatusDot-XxLkmRaK.js": {
2636
+ "file": "assets/StatusDot-XxLkmRaK.js",
2637
2637
  "name": "StatusDot",
2638
2638
  "imports": [
2639
2639
  "_browser-BWnzWwaT.js",
2640
- "_Tooltip-CxiQ7luL.js"
2640
+ "_Tooltip-qB73RL4b.js"
2641
2641
  ]
2642
2642
  },
2643
- "_Tooltip-CxiQ7luL.js": {
2644
- "file": "assets/Tooltip-CxiQ7luL.js",
2643
+ "_Tooltip-qB73RL4b.js": {
2644
+ "file": "assets/Tooltip-qB73RL4b.js",
2645
2645
  "name": "Tooltip",
2646
2646
  "imports": [
2647
2647
  "_AppShell-CCPwPqvc.js",
@@ -2888,7 +2888,7 @@
2888
2888
  ]
2889
2889
  },
2890
2890
  "src/main.ts": {
2891
- "file": "assets/main-DYwKyLY5.js",
2891
+ "file": "assets/main-9ynpo780.js",
2892
2892
  "name": "main",
2893
2893
  "src": "src/main.ts",
2894
2894
  "isEntry": true,
@@ -2911,7 +2911,7 @@
2911
2911
  "_NotFoundPage-DZ6ysTXd.js"
2912
2912
  ],
2913
2913
  "css": [
2914
- "assets/main-DPB0UO1-.css"
2914
+ "assets/main-DSiJ9sHU.css"
2915
2915
  ],
2916
2916
  "assets": [
2917
2917
  "assets/instrument-sans-latin-ext-wght-normal-B5bTHO_g.woff2",
@@ -2924,7 +2924,7 @@
2924
2924
  ]
2925
2925
  },
2926
2926
  "src/pages/CostsPage.vue": {
2927
- "file": "assets/CostsPage-RRggVvIx.js",
2927
+ "file": "assets/CostsPage-6P9rJ7k_.js",
2928
2928
  "name": "CostsPage",
2929
2929
  "src": "src/pages/CostsPage.vue",
2930
2930
  "isDynamicEntry": true,
@@ -2951,14 +2951,14 @@
2951
2951
  ]
2952
2952
  },
2953
2953
  "src/pages/HomePage.vue": {
2954
- "file": "assets/HomePage-BQmun9kS.js",
2954
+ "file": "assets/HomePage-B4LGwXHO.js",
2955
2955
  "name": "HomePage",
2956
2956
  "src": "src/pages/HomePage.vue",
2957
2957
  "isDynamicEntry": true,
2958
2958
  "imports": [
2959
2959
  "_AppShell-CCPwPqvc.js",
2960
2960
  "_browser-BWnzWwaT.js",
2961
- "_Tooltip-CxiQ7luL.js",
2961
+ "_Tooltip-qB73RL4b.js",
2962
2962
  "_PendingTurnRow-BPyJ2f-i.js",
2963
2963
  "src/main.ts",
2964
2964
  "_eventSource-Ds6_gjPD.js",
@@ -2999,7 +2999,7 @@
2999
2999
  ]
3000
3000
  },
3001
3001
  "src/pages/ResidentDetailPage.vue": {
3002
- "file": "assets/ResidentDetailPage-CT6v9INM.js",
3002
+ "file": "assets/ResidentDetailPage-jpGfsR5n.js",
3003
3003
  "name": "ResidentDetailPage",
3004
3004
  "src": "src/pages/ResidentDetailPage.vue",
3005
3005
  "isDynamicEntry": true,
@@ -3007,36 +3007,36 @@
3007
3007
  "_AppShell-CCPwPqvc.js",
3008
3008
  "_browser-BWnzWwaT.js",
3009
3009
  "src/main.ts",
3010
- "_StatusDot-BIAQN7iD.js"
3010
+ "_StatusDot-XxLkmRaK.js"
3011
3011
  ]
3012
3012
  },
3013
3013
  "src/pages/ResidentsIndexPage.vue": {
3014
- "file": "assets/ResidentsIndexPage-CWqPFf40.js",
3014
+ "file": "assets/ResidentsIndexPage-C4-5nG9M.js",
3015
3015
  "name": "ResidentsIndexPage",
3016
3016
  "src": "src/pages/ResidentsIndexPage.vue",
3017
3017
  "isDynamicEntry": true,
3018
3018
  "imports": [
3019
3019
  "_AppShell-CCPwPqvc.js",
3020
3020
  "_browser-BWnzWwaT.js",
3021
- "_Tooltip-CxiQ7luL.js",
3021
+ "_Tooltip-qB73RL4b.js",
3022
3022
  "src/main.ts",
3023
3023
  "_eventSource-Ds6_gjPD.js",
3024
3024
  "_wallClock-DaewxNMY.js",
3025
3025
  "_indexFormat-B-pd4r7Y.js",
3026
3026
  "_indexRow-BGjjLnN5.js",
3027
3027
  "_format-BldUwl_R.js",
3028
- "_StatusDot-BIAQN7iD.js"
3028
+ "_StatusDot-XxLkmRaK.js"
3029
3029
  ]
3030
3030
  },
3031
3031
  "src/pages/RunRoutePage.vue": {
3032
- "file": "assets/RunRoutePage-zWMHTzla.js",
3032
+ "file": "assets/RunRoutePage-CxOKb7oC.js",
3033
3033
  "name": "RunRoutePage",
3034
3034
  "src": "src/pages/RunRoutePage.vue",
3035
3035
  "isDynamicEntry": true,
3036
3036
  "imports": [
3037
3037
  "_AppShell-CCPwPqvc.js",
3038
3038
  "_browser-BWnzWwaT.js",
3039
- "_Tooltip-CxiQ7luL.js",
3039
+ "_Tooltip-qB73RL4b.js",
3040
3040
  "_PendingTurnRow-BPyJ2f-i.js",
3041
3041
  "src/main.ts",
3042
3042
  "_eventSource-Ds6_gjPD.js",
@@ -3044,7 +3044,7 @@
3044
3044
  "_indexFormat-B-pd4r7Y.js",
3045
3045
  "_indexRow-BGjjLnN5.js",
3046
3046
  "_format-BldUwl_R.js",
3047
- "_RunFoldRow-C1w-mwch.js",
3047
+ "_RunFoldRow-u4FTh57c.js",
3048
3048
  "_SlackMark-DjJTK2tD.js",
3049
3049
  "_sseReplay-BDVyc8HX.js",
3050
3050
  "_durationTone-CVpX_yIk.js",
@@ -3058,14 +3058,14 @@
3058
3058
  ]
3059
3059
  },
3060
3060
  "src/pages/RunsIndexPage.vue": {
3061
- "file": "assets/RunsIndexPage-DF16D2Gg.js",
3061
+ "file": "assets/RunsIndexPage-CULSlv_d.js",
3062
3062
  "name": "RunsIndexPage",
3063
3063
  "src": "src/pages/RunsIndexPage.vue",
3064
3064
  "isDynamicEntry": true,
3065
3065
  "imports": [
3066
3066
  "_AppShell-CCPwPqvc.js",
3067
3067
  "_browser-BWnzWwaT.js",
3068
- "_Tooltip-CxiQ7luL.js",
3068
+ "_Tooltip-qB73RL4b.js",
3069
3069
  "_InputMenu-ymuqElZB.js",
3070
3070
  "src/main.ts",
3071
3071
  "_eventSource-Ds6_gjPD.js",
@@ -3076,18 +3076,18 @@
3076
3076
  "_SlackMark-DjJTK2tD.js",
3077
3077
  "_durationTone-CVpX_yIk.js",
3078
3078
  "_RunsTabs-D7rsC4GR.js",
3079
- "_StatusDot-BIAQN7iD.js"
3079
+ "_StatusDot-XxLkmRaK.js"
3080
3080
  ]
3081
3081
  },
3082
3082
  "src/pages/ScheduledPage.vue": {
3083
- "file": "assets/ScheduledPage-CyRs0fXN.js",
3083
+ "file": "assets/ScheduledPage-CDjkZuqM.js",
3084
3084
  "name": "ScheduledPage",
3085
3085
  "src": "src/pages/ScheduledPage.vue",
3086
3086
  "isDynamicEntry": true,
3087
3087
  "imports": [
3088
3088
  "_AppShell-CCPwPqvc.js",
3089
3089
  "_browser-BWnzWwaT.js",
3090
- "_Tooltip-CxiQ7luL.js",
3090
+ "_Tooltip-qB73RL4b.js",
3091
3091
  "_wallClock-DaewxNMY.js",
3092
3092
  "_indexFormat-B-pd4r7Y.js",
3093
3093
  "_format-BldUwl_R.js",
@@ -3095,7 +3095,7 @@
3095
3095
  ]
3096
3096
  },
3097
3097
  "src/pages/SettingsPage.vue": {
3098
- "file": "assets/SettingsPage-BRuMCHSj.js",
3098
+ "file": "assets/SettingsPage-BMSomotV.js",
3099
3099
  "name": "SettingsPage",
3100
3100
  "src": "src/pages/SettingsPage.vue",
3101
3101
  "isDynamicEntry": true,
@@ -3103,14 +3103,14 @@
3103
3103
  "_AppShell-CCPwPqvc.js",
3104
3104
  "_browser-BWnzWwaT.js",
3105
3105
  "_SettingSelect-CEkCLVWd.js",
3106
- "_Tooltip-CxiQ7luL.js",
3106
+ "_Tooltip-qB73RL4b.js",
3107
3107
  "_InputMenu-ymuqElZB.js",
3108
3108
  "_settingsApi-Dm6eaQcu.js",
3109
3109
  "_indexRow-BGjjLnN5.js"
3110
3110
  ]
3111
3111
  },
3112
3112
  "src/pages/UnitRoutePage.vue": {
3113
- "file": "assets/UnitRoutePage-BQB5mAAl.js",
3113
+ "file": "assets/UnitRoutePage-DFRWAdOT.js",
3114
3114
  "name": "UnitRoutePage",
3115
3115
  "src": "src/pages/UnitRoutePage.vue",
3116
3116
  "isDynamicEntry": true,
@@ -3122,7 +3122,7 @@
3122
3122
  "_indexFormat-B-pd4r7Y.js",
3123
3123
  "_indexRow-BGjjLnN5.js",
3124
3124
  "_format-BldUwl_R.js",
3125
- "_RunFoldRow-C1w-mwch.js",
3125
+ "_RunFoldRow-u4FTh57c.js",
3126
3126
  "_SlackMark-DjJTK2tD.js",
3127
3127
  "_sseReplay-BDVyc8HX.js",
3128
3128
  "_NotFoundPage-DZ6ysTXd.js"
@@ -0,0 +1 @@
1
+ import{t as e}from"./AppShell-CCPwPqvc.js";import{An as t,Cr as n,Dn as r,Fi as i,Jr as a,Jt as o,Mi as s,On as c,Pi as l,Qt as u,Xr as d,Zt as ee,_n as f,bn as p,hr as m,ki as h,lr as g,o as _,pr as te,sn as v,vn as y,xn as b,xr as x,yi as S,yn as C}from"./browser-BWnzWwaT.js";import{a as w,c as T,d as ne,f as re,g as E,h as D,l as O,m as ie,o as k,p as ae,s as oe,t as se,u as ce}from"./CostChart-Y5BqJKLA.js";import{t as le}from"./eventSource-Ds6_gjPD.js";import{r as ue}from"./settingsApi-Dm6eaQcu.js";import{t as de}from"./wallClock-DaewxNMY.js";var A={class:`overflow-x-auto`},j=[`viewBox`,`aria-label`],M=[`x2`,`y1`,`y2`],N=[`x2`,`y1`,`y2`],P=[`x`,`y`],F=[`points`],fe=[`href`],I=[`cx`,`cy`],L=[`y`],R=[`x`,`y`],z=900,B=250,V=58,pe=18,me=t({__name:`ShipSpendChart`,props:{unit:{}},setup(e){let t=e,n=f(()=>{let e=t.unit.runs,n=e[0]?.finishedAt??0,r=e.at(-1)?.finishedAt??n,i=Math.max(1,t.unit.capUsd??0,...e.map(e=>e.cumulativeUsd??0))*1.08,a=e=>V+(r===n?412:(e-n)/(r-n)*824),o=e=>pe+196*(1-e/i);return{capY:t.unit.capUsd===null?null:o(t.unit.capUsd),points:e.map(e=>({...e,x:a(e.finishedAt),y:e.cumulativeUsd===null?null:o(e.cumulativeUsd)})),axisY:o(0),peak:i}}),r=f(()=>n.value.points.filter(e=>e.y!==null).map(e=>`${e.x},${e.y}`).join(` `)),a=e=>new Date(e).toISOString().replace(`T`,` `).slice(0,16)+` UTC`;return(t,o)=>(m(),b(`div`,A,[(m(),b(`svg`,{class:`block h-auto w-full min-w-[36rem] font-mono`,viewBox:`0 0 ${z} ${B}`,role:`img`,"aria-label":`Ship unit spend shown in this date range for ${e.unit.key}`},[y(`line`,{x1:V,x2:882,y1:n.value.axisY,y2:n.value.axisY,class:`stroke-(--ui-border)`},null,8,M),n.value.capY===null?p(``,!0):(m(),b(v,{key:0},[y(`line`,{x1:V,x2:882,y1:n.value.capY,y2:n.value.capY,class:`stroke-(--ui-text-muted)`,"stroke-width":`1.5`,"stroke-dasharray":`6 4`,"data-ship-cap-line":``},null,8,N),y(`text`,{x:62,y:n.value.capY-6,class:`fill-(--ui-text-muted) text-[11px]`},` Unit cap `+i(h(D)(e.unit.capUsd)),9,P)],64)),r.value?(m(),b(`polyline`,{key:1,points:r.value,fill:`none`,"stroke-width":`2`,class:`stroke-[#4478b8] dark:stroke-[#7aa7e0]`},null,8,F)):p(``,!0),(m(!0),b(v,null,x(n.value.points,e=>(m(),b(v,{key:e.id},[e.y===null?p(``,!0):(m(),b(`a`,{key:0,href:`/runs/${encodeURIComponent(e.id)}`},[y(`circle`,{cx:e.x,cy:e.y,r:`4`,class:`fill-[#4478b8] dark:fill-[#7aa7e0]`},[y(`title`,null,i(a(e.finishedAt))+` · run `+i(e.id)+` · `+i(h(D)(e.usd))+` · cumulative `+i(h(D)(e.cumulativeUsd)),1)],8,I)],8,fe))],64))),128)),y(`text`,{x:V,y:242,class:`fill-(--ui-text-dimmed) text-[11px]`,"text-anchor":`start`},i(a(e.unit.runs[0].finishedAt)),9,L),y(`text`,{x:882,y:242,class:`fill-(--ui-text-dimmed) text-[11px]`,"text-anchor":`end`},i(a(e.unit.runs.at(-1).finishedAt)),9,R)],8,j))]))}}),he=[`data-dimension`],H={class:`flex flex-wrap items-center gap-x-4 gap-y-2`},U={class:`flex items-center gap-2 text-sm text-muted`},W=[`placeholder`,`aria-label`],ge=[`title`],G=[`disabled`,`aria-describedby`],_e={key:0,id:`me-hint`,class:`me-hint text-xs text-dimmed`},ve={class:`coverage font-mono text-xs tabular-nums text-muted`},K={class:`overflow-x-auto`},q={class:`by w-full min-w-[40rem] border-collapse whitespace-nowrap font-mono text-[0.8125rem] tabular-nums`},J={class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-left text-xs font-medium text-muted`},ye={class:`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-right text-xs font-medium text-muted`},Y={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`},X=[`title`],be={class:`text-highlighted`},Z={key:0,class:`ml-1.5 text-xs text-dimmed`},xe={key:1,class:`ml-1.5 rounded-xs bg-accented px-1 text-xs text-highlighted`},Q=[`title`],Se={class:`border-b border-muted px-2.5 py-1.5 text-right`},Ce={class:`border-b border-muted px-2.5 py-1.5 text-right`},we={key:0,class:`border-b border-muted px-2.5 py-1.5 text-right`},Te={class:`border-b border-muted px-2.5 py-1.5 text-right font-medium text-highlighted`},Ee={class:`border-b border-muted px-2.5 py-1.5 text-right`},De={key:0},Oe=[`colspan`],ke={key:0},Ae=[`colspan`],$={class:`px-2.5 py-1.5 text-right text-xs text-muted`},je={class:`px-2.5 py-1.5 text-right text-xs text-muted`},Me={class:`reconciliation font-mono text-xs tabular-nums text-muted`},Ne={class:`text-xs text-dimmed`},Pe=t({__name:`CostsByDimension`,props:{report:{}},setup(e){let t=e,n={user:`User`,thread:`Thread`,channel:`Channel`,agent:`Agent`,model:`Model`},a=S(``),c=S(!1),l=f(()=>t.report.dimension),ee=f(()=>t.report.viewer!==void 0),g=f(()=>(t.report.viewer?.userIds.length??0)>0),_=f(()=>t.report.cloudAllocated),te=f(()=>l.value===`model`?`Turns`:`Runs`),C=e=>l.value===`model`?e.turns:e.runs,w=f(()=>{let e=a.value.trim().toLowerCase(),n=new Set(t.report.viewer?.userIds??[]);return t.report.rows.filter(t=>c.value&&!n.has(t.key)?!1:!e||t.key.toLowerCase().includes(e)||(t.label??``).toLowerCase().includes(e))}),T=f(()=>t.report.rows.reduce((e,t)=>e+t.totalUsd,0)),ne=f(()=>w.value.reduce((e,t)=>e+t.totalUsd,0)),re=e=>t.report.viewer?.userIds.includes(e.key)??!1,E=f(()=>l.value===`user`||l.value===`thread`||l.value===`channel`),ie=e=>e.label?l.value===`channel`?`#${e.label}`:e.label:E.value?e.key.replace(/^[a-z]+:/,``):e.key,k=e=>E.value&&e.key.includes(`:`)?e.key.split(`:`)[0]:``,ae=e=>`${e} day${e===1?``:`s`}`,oe=f(()=>_.value?6:5);return(t,f)=>(m(),b(`section`,{class:`by-dimension grid gap-3`,"data-dimension":l.value},[y(`div`,H,[y(`label`,U,[f[2]||=y(`span`,null,`Filter`,-1),d(y(`input`,{"onUpdate:modelValue":f[0]||=e=>a.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,W),[[u,a.value]])]),ee.value?(m(),b(`label`,{key:0,class:s([`me-toggle flex items-center gap-2 text-sm`,g.value?`text-muted`:`text-dimmed`]),title:g.value?`Only your own runs`:void 0},[d(y(`input`,{"onUpdate:modelValue":f[1]||=e=>c.value=e,type:`checkbox`,disabled:!g.value,"aria-label":`Only me`,"aria-describedby":g.value?void 0:`me-hint`},null,8,G),[[o,c.value]]),f[3]||=y(`span`,null,`me`,-1),g.value?p(``,!0):(m(),b(`span`,_e,`— your sign-in email matched no Slack user in this range`))],10,ge)):p(``,!0),y(`p`,ve,[e.report.coverage.historyOn?(m(),b(v,{key:1},[r(` runs from `+i(h(O)(e.report.coverage.from))+` to `+i(h(O)(e.report.range.to)),1),e.report.coverage.clamped?(m(),b(v,{key:0},[r(` · earlier days are past the history's `+i(e.report.coverage.retentionDays)+`-day window`,1)],64)):p(``,!0),e.report.pending>0?(m(),b(v,{key:1},[r(` · `+i(e.report.pending)+` run`+i(e.report.pending===1?``:`s`)+` still being priced`,1)],64)):p(``,!0)],64)):(m(),b(v,{key:0},[r(`history is off — no runs to attribute`)],64))])]),y(`div`,K,[y(`table`,q,[y(`thead`,null,[y(`tr`,null,[y(`th`,J,i(n[l.value]),1),y(`th`,ye,i(te.value),1),f[5]||=y(`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),_.value?(m(),b(`th`,Y,[...f[4]||=[r(` Cloud `,-1),y(`span`,{class:`font-normal text-dimmed`},`allocated`,-1)]])):p(``,!0),f[6]||=y(`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),f[7]||=y(`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)])]),y(`tbody`,null,[(m(!0),b(v,null,x(w.value,e=>(m(),b(`tr`,{key:e.key,class:s([`by-row`,re(e)?`is-me`:``])},[y(`td`,{class:`border-b border-muted px-2.5 py-1.5`,title:e.key},[y(`span`,be,i(ie(e)),1),k(e)?(m(),b(`span`,Z,i(k(e)),1)):p(``,!0),re(e)?(m(),b(`span`,xe,`me`)):p(``,!0),e.unpricedTokens>0?(m(),b(`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,Q)):p(``,!0)],8,X),y(`td`,Se,i(C(e)),1),y(`td`,Ce,i(h(D)(e.llmUsd)),1),_.value?(m(),b(`td`,we,i(h(D)(e.cloudUsd)),1)):p(``,!0),y(`td`,Te,i(h(D)(e.totalUsd)),1),y(`td`,Ee,i(T.value>0?Math.round(e.totalUsd/T.value*100):0)+`% `,1)],2))),128)),w.value.length===0?(m(),b(`tr`,De,[y(`td`,{class:`empty px-2.5 py-3 text-sm text-muted`,colspan:oe.value},i(e.report.rows.length===0?`no runs in this range`:`no ${n[l.value].toLowerCase()} matches`),9,Oe)])):p(``,!0)]),w.value.length>0&&w.value.length<e.report.rows.length?(m(),b(`tfoot`,ke,[y(`tr`,null,[y(`td`,{class:`px-2.5 py-1.5 text-xs text-muted`,colspan:oe.value-2},`shown`,8,Ae),y(`td`,$,i(h(D)(ne.value)),1),y(`td`,je,i(T.value>0?Math.round(ne.value/T.value*100):0)+`% `,1)])])):p(``,!0)])]),y(`p`,Me,[e.report.reconciliation.comparedDays>0?(m(),b(v,{key:0},[r(` LLM attributed `+i(h(D)(e.report.reconciliation.attributedLlmUsd))+` of `+i(h(D)(e.report.reconciliation.workspaceLlmUsd))+` on the workspace over `+i(ae(e.report.reconciliation.comparedDays))+` · `,1),e.report.reconciliation.unattributedLlmUsd>=0?(m(),b(v,{key:0},[r(i(h(D)(e.report.reconciliation.unattributedLlmUsd))+` unattributed (router, review abridges, runs without a record, list vs invoice) `,1)],64)):(m(),b(v,{key:1},[r(i(h(D)(-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)):(m(),b(v,{key:1},[r(`no day in range has a workspace LLM figure to compare against`)],64)),e.report.reconciliation.uncomparedDays>0?(m(),b(v,{key:2},[r(` · `+i(ae(e.report.reconciliation.uncomparedDays))+` with `+i(h(D)(e.report.reconciliation.uncomparedLlmUsd))+` of tokens from runs but no workspace figure (billed outside this workspace) not compared`,1)],64)):p(``,!0),_.value?(m(),b(v,{key:3},[r(` · cloud allocated `+i(h(D)(e.report.reconciliation.cloudAllocatedUsd)),1),e.report.reconciliation.cloudUnallocatedUsd>0?(m(),b(v,{key:0},[r(` · `+i(h(D)(e.report.reconciliation.cloudUnallocatedUsd))+` on days with no runs`,1)],64)):p(``,!0)],64)):p(``,!0)]),y(`p`,Ne,[l.value===`model`?(m(),b(v,{key:0},[r(` 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)):(m(),b(v,{key:1},[r(` A `+i(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,he))}}),Fe={class:`mb-4 flex flex-wrap items-center gap-x-4 gap-y-2`},Ie={class:`flex items-center gap-1`,"aria-label":`Range`},Le={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`},Re={key:0,class:`flex items-center gap-1`,"aria-label":`Cost groups`},ze={key:0,class:`rounded-md bg-accented px-2.5 py-1 text-xs font-medium text-highlighted`,"aria-current":`page`},Be={class:`font-mono text-sm tabular-nums text-muted`},Ve={key:1,class:`flex basis-full flex-wrap items-center gap-x-3 gap-y-1`},He={class:`font-mono text-xs tabular-nums text-dimmed`,"data-snapshot-status":``},Ue=[`disabled`],We={key:1,class:`text-xs text-error`,role:`status`,"data-snapshot-error":``},Ge={class:`mb-5 grid grid-cols-[repeat(auto-fit,minmax(190px,1fr))] gap-3`},Ke={key:0,class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},qe={class:`font-mono text-2xl font-medium tabular-nums`},Je={class:`text-xs text-muted`},Ye={key:1,class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},Xe={class:`font-mono text-2xl font-medium tabular-nums`},Ze={class:`text-xs text-muted`},Qe={class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},$e={class:`font-mono text-2xl font-medium tabular-nums`},et={class:`text-xs text-muted`},tt={class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},nt={class:`font-mono text-2xl font-medium tabular-nums`},rt={class:`text-xs text-muted`},it={class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},at={class:`font-mono text-2xl font-medium tabular-nums`},ot={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`},lt={class:`text-xs text-muted`},ut=[`href`,`title`],dt=[`href`],ft={class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},pt={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`},ht=[`href`,`title`],gt={key:1,class:`text-xs text-warn`},_t={key:2,class:`text-xs text-muted`},vt={key:0,class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`,"data-ship-spend":``},yt={class:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-2`},bt={key:0,class:`flex items-center gap-2 text-xs text-muted`},xt=[`value`],St={key:0,class:`text-sm text-muted`},Ct={class:`text-xs text-muted`},wt={class:`overflow-x-auto`},Tt={class:`data w-full min-w-[30rem] border-collapse font-mono text-xs tabular-nums`,"data-ship-runs":``},Et={class:`border-b border-muted px-2 py-1.5`},Dt={class:`border-b border-muted px-2 py-1.5`},Ot=[`href`],kt={class:`border-b border-muted px-2 py-1.5 text-right`},At={class:`border-b border-muted px-2 py-1.5 text-right`},jt={class:`mb-3 flex flex-wrap items-center gap-1 border-b border-default`,"aria-label":`View`},Mt={key:0,class:`-mb-px border-b-2 border-primary px-3 py-1.5 text-sm font-medium text-highlighted`,"aria-current":`page`},Nt={key:1,class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},Pt={class:`text-[0.9375rem] font-medium`},Ft={class:`text-sm text-muted`},It={key:1,class:`text-sm text-warn`},Lt={class:`text-xs text-muted`},Rt={class:`rounded bg-accented px-1 py-0.5`},zt={key:2,class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},Bt={class:`w-full border-collapse font-mono text-[0.8125rem] tabular-nums`},Vt={class:`px-2.5 py-1.5`},Ht=[`href`],Ut={class:`px-2.5 py-1.5 text-right`},Wt={class:`px-2.5 py-1.5 text-right`},Gt={class:`w-2/5 px-2.5 py-1.5`},Kt={key:3,class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},qt={open:``},Jt={class:`mt-2.5 overflow-x-auto`},Yt={class:`data w-full min-w-[38rem] border-collapse whitespace-nowrap font-mono text-[0.8125rem] tabular-nums`},Xt=[`title`],Zt={key:0,class:`text-xs text-dimmed`},Qt={key:1,class:`text-xs text-dimmed`},$t={class:`border-b border-muted px-2.5 py-1.5 text-right font-medium`},en={class:`text-xs text-muted`},tn={class:`rounded bg-accented px-1 py-0.5`},nn={key:4,class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},rn=[`data-biller`],an={class:`text-sm`},on={key:1,class:`text-muted`},sn={key:2,class:`text-muted`},cn={key:0,class:`overflow-x-auto`},ln={class:`data w-full border-collapse whitespace-nowrap font-mono text-[0.8125rem] tabular-nums`},un={key:0,class:`border-b border-muted px-2.5 py-1 text-right text-xs font-medium text-muted`},dn={key:1,class:`border-b border-muted px-2.5 py-1 text-right text-xs font-medium text-muted`},fn=[`title`],pn={key:0,class:`border-b border-muted px-2.5 py-1 text-right`},mn={class:`border-b border-muted px-2.5 py-1 text-right`},hn={class:`border-b border-muted px-2.5 py-1 text-right`},gn={class:`border-b border-muted px-2.5 py-1 text-right`},_n={key:1,class:`border-b border-muted px-2.5 py-1 text-right`},vn={class:`border-t border-default pt-3.5 text-xs text-dimmed`},yn={class:`mt-2 grid gap-1.5`},bn=[`href`],xn={key:2},Sn=[`href`],Cn={key:2},wn=[`href`],Tn=[`href`],En={class:`mb-4 flex flex-wrap items-center gap-x-4 gap-y-2`},Dn={key:0,class:`flex items-center gap-1`,"aria-label":`Cost groups`},On={key:0,class:`rounded-md bg-accented px-2.5 py-1 text-xs font-medium text-highlighted`,"aria-current":`page`},kn={class:`mb-5 grid gap-2 rounded-lg border border-default bg-elevated px-5 py-4`},An={class:`flex flex-wrap items-center gap-x-3 gap-y-1`},jn={class:`font-mono text-xs tabular-nums text-muted`,"data-snapshot-status":``},Mn=[`disabled`],Nn={key:1,class:`text-xs text-error`,role:`status`,"data-snapshot-error":``},Pn=t({__name:`CostsPage`,setup(t){let o=_(`costs`),u=S(o?.report??null),O=S(``),A=f(()=>u.value?.shipSpend?.units??[]),j=f({get:()=>A.value.find(e=>e.key===O.value)?.key??A.value[0]?.key??``,set:e=>{O.value=e}}),M=f(()=>A.value.find(e=>e.key===j.value)),N=f(()=>o?.groups??[]),P=f(()=>o?.group??u.value?.group??``),F=S(o?.snapshot??null),fe=de(void 0,6e4),I=f(()=>F.value?ae(F.value,fe.value):``),L=f(()=>o?.view??`daily`),R=S(o&&o.view!==`daily`?o.by??null:null),z=[{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`}],B=f(()=>z.find(e=>e.view===L.value)??z[0]),V=f(()=>o?.canSnapshot===!0),pe=f(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`days`)),he=e=>`/costs/${P.value}${e}${pe.value?`?days=${pe.value}`:``}`,H=o?.snapshot?.snapshot?.takenAt??null,U=H,W=null;async function ge(){try{let[e,t]=await Promise.all([fetch(he(`.json`),{credentials:`same-origin`}),L.value===`daily`?Promise.resolve(null):fetch(he(`/${L.value}.json`),{credentials:`same-origin`})]);return e.ok?(u.value=await e.json(),t?.ok&&(R.value=await t.json()),!0):!1}catch{return!1}}function G(){if(W||U===null||U===H)return;let e=U;W=ge().then(t=>{t&&(H=e)}).finally(()=>{W=null,U!==e&&G()})}function _e(e){F.value=e;let t=e.snapshot?.takenAt??null;t&&(U=t,G())}let ve=le(),K=null;g(()=>{P.value&&(K=ve(`/costs/${P.value}?stream=1`),K.onmessage=e=>{let t=ce(e.data);t&&_e(t)})}),te(()=>K?.close());let q=S(!1),J=S(``);async function ye(){q.value=!0,J.value=``;let e=await ue(fetch,`costs.snapshot`,{});e.ok||(J.value=e.failure.message),q.value=!1}function Y(e,t,n){let r=[`days=${t}`];return n!==`daily`&&r.push(`view=${n}`),`/costs/${e}?${r.join(`&`)}`}let X=f(()=>u.value?re(u.value):[]),be=f(()=>u.value?oe(u.value,X.value):null),Z=f(()=>u.value?ie(u.value):null),xe=f(()=>u.value?ne(u.value):[]),Q=f(()=>u.value?T(u.value):null),Se=f(()=>u.value?k(u.value):``);function Ce(e){let t=Q.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 we(e){let t=Q.value;if(t)return e===`LLM (Anthropic)`?t.anthropic:e===`Durable Objects`?t.durableObjects:e===`Workers · storage · R2`?t.workers:t.containers}let Te=f(()=>{let e=u.value,t=Z.value;if(!e||!t)return``;let n=t.projection,r=`cloud ${D(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 ${D(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}`}`}),Ee=f(()=>u.value?[...u.value.days].reverse():[]),De=f(()=>(u.value?.billers??[]).map(e=>({...e,days:[...e.days].reverse(),unpricedTokens:e.days.reduce((e,t)=>e+(t.unpricedTokens??0),0)}))),Oe=[1,7,30],ke=e=>e===1?`today`:`${e}d`,Ae=f(()=>{let e=u.value,t=Z.value;if(!e||!t)return``;if(!e.llmAvailable)return`LLM spend not configured`;let n=[];return t.llm.yesterday!==void 0&&n.push(`yesterday ${D(t.llm.yesterday)}`),t.llm.today&&n.push(`today ${D(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(t,o)=>{let f=n(`RouterLink`);return u.value&&Z.value?(m(),C(e,{key:0,title:`${u.value.label} spend`,nav:`costs`},{default:a(()=>[y(`div`,Fe,[y(`nav`,Ie,[(m(),b(v,null,x(Oe,e=>(m(),b(v,{key:e},[e===u.value.range.days?(m(),b(`span`,Le,i(ke(e)),1)):(m(),C(f,{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`,to:Y(u.value.group,e,L.value)},{default:a(()=>[r(i(ke(e)),1)]),_:2},1032,[`to`]))],64))),64))]),N.value.length>1?(m(),b(`nav`,Re,[(m(!0),b(v,null,x(N.value,e=>(m(),b(v,{key:e},[e===u.value.group?(m(),b(`span`,ze,i(e),1)):(m(),C(f,{key:1,class:`rounded-md px-2.5 py-1 text-xs text-muted no-underline hover:bg-elevated hover:text-highlighted`,to:Y(e,u.value.range.days,L.value)},{default:a(()=>[r(i(e),1)]),_:2},1032,[`to`]))],64))),128))])):p(``,!0),y(`p`,Be,[r(i($(u.value.range.from))+` → `+i($(u.value.range.to))+` · `+i(u.value.range.days)+`d`,1),u.value.range.partialLastDay?(m(),b(v,{key:0},[r(` · today partial`)],64)):p(``,!0)]),I.value?(m(),b(`div`,Ve,[y(`p`,He,i(I.value),1),V.value?(m(),b(`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:q.value||F.value?.inFlight!==null,"data-snapshot-now":``,onClick:ye},i(F.value?.inFlight?`Taking…`:`Snapshot now`),9,Ue)):p(``,!0),J.value?(m(),b(`span`,We,i(J.value),1)):p(``,!0)])):p(``,!0)]),y(`section`,Ge,[Z.value.yesterday?(m(),b(`div`,Ke,[o[1]||=y(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`Yesterday`,-1),y(`span`,qe,i(h(D)(Z.value.yesterday.total)),1),y(`span`,Je,i(Z.value.yesterday.date)+` · last full day`,1)])):(m(),b(`div`,Ye,[o[2]||=y(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`Today so far`,-1),y(`span`,Xe,i(Z.value.today?h(D)(Z.value.today.total):`—`),1),y(`span`,Ze,i(Z.value.today?`${Z.value.today.date} · partial day, UTC`:`no day in range`),1)])),y(`div`,Qe,[o[3]||=y(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`7-day average`,-1),y(`span`,$e,i(Z.value.avg7===void 0?`—`:h(D)(Z.value.avg7)),1),y(`span`,et,i(Z.value.avg7===void 0?`no full day yet in this range`:`per day, full days only`),1)]),y(`div`,tt,[o[4]||=y(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`Projected month`,-1),y(`span`,nt,i(h(D)(Z.value.projection.monthUsd,0)),1),y(`span`,rt,i(Te.value),1)]),y(`div`,it,[o[5]||=y(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`LLM spend`,-1),y(`span`,at,i(u.value.llmAvailable?h(D)(Z.value.llm.range):`—`),1),y(`span`,ot,i(Ae.value),1)]),y(`div`,st,[o[7]||=y(`span`,{class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},`Share of account`,-1),y(`span`,ct,i(Z.value.accountShare)+`%`,1),y(`span`,lt,[r(i(h(D)(u.value.totals.cloudUsd))+` of `+i(h(D)(u.value.account.cloudUsd))+` on `,1),Q.value?(m(),b(`a`,{key:0,class:`text-primary hover:underline`,href:Q.value.account,target:`_blank`,rel:`noopener noreferrer`,title:`Cloudflare account ${u.value.account.id}`},i(Se.value),9,ut)):p(``,!0),o[6]||=r(` · Cloudflare spend in range · `,-1),Q.value?(m(),b(`a`,{key:1,class:`text-primary hover:underline`,href:Q.value.billing,target:`_blank`,rel:`noopener noreferrer`},`billing`,8,dt)):p(``,!0)])])]),y(`section`,ft,[y(`div`,pt,[o[8]||=y(`div`,null,[y(`h2`,{class:`text-[0.9375rem] font-medium`},`Daily cost`),y(`p`,{class:`text-sm text-muted`},`Stacked by component · USD list price`)],-1),y(`div`,mt,[(m(!0),b(v,null,x(X.value,(e,t)=>(m(),b(`a`,{key:e,class:`inline-flex items-center gap-1.5 no-underline hover:text-highlighted hover:underline`,href:we(e),target:`_blank`,rel:`noopener noreferrer`,title:`Open where ${e} is billed`},[y(`i`,{class:s([`inline-block size-2.5 rounded-xs`,h(w)[t%h(w).length]])},null,2),r(i(e),1)],8,ht))),128))])]),be.value?(m(),C(se,{key:0,model:be.value,label:`Daily cost, stacked by component`},null,8,[`model`])):p(``,!0),u.value.llmAvailable?u.value.days.some(e=>e.llmEstimated)?(m(),b(`p`,_t,[o[10]||=r(` 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),u.value.days.some(e=>e.llmUnpricedTokens>0)?(m(),b(v,{key:0},[r(` Some tokens ran under a model this page has no price for and are not in the estimate. `)],64)):p(``,!0)])):p(``,!0):(m(),b(`p`,gt,[...o[9]||=[r(` LLM spend not configured — set `,-1),y(`code`,null,`ANTHROPIC_ADMIN_KEY`,-1),r(` and the group's `,-1),y(`code`,null,`anthropicWorkspaceId`,-1),r(` to layer it in. `,-1)]]))]),u.value.shipSpend?(m(),b(`section`,vt,[y(`div`,yt,[o[12]||=y(`div`,null,[y(`h2`,{class:`text-[0.9375rem] font-medium`},`Ship run cost over time`),y(`p`,{class:`text-sm text-muted`},` Each point is a retained finished child run. The line adds retained costs in this date range; earlier runs are not included, and retention may have removed runs within the range. The dashed line is the unit's admitted cap. Ship runs are shared across cost groups. `)],-1),A.value.length?(m(),b(`label`,bt,[o[11]||=r(` Unit `,-1),d(y(`select`,{"onUpdate:modelValue":o[0]||=e=>j.value=e,class:`max-w-[22rem] rounded-md border border-default bg-default px-2 py-1 font-mono text-xs text-default`},[(m(!0),b(v,null,x(A.value,e=>(m(),b(`option`,{key:e.key,value:e.key},i(e.key),9,xt))),128))],512),[[ee,j.value]])])):p(``,!0)]),A.value.length?M.value?(m(),b(v,{key:1},[c(me,{unit:M.value},null,8,[`unit`]),y(`p`,Ct,i(M.value.runs.length)+` child run`+i(M.value.runs.length===1?``:`s`)+` · retained-run total `+i(M.value.totalUsd===null?`unknown (unpriced usage)`:h(D)(M.value.totalUsd))+` · `+i(M.value.capUsd===null?`no recorded unit cap`:`unit cap ${h(D)(M.value.capUsd)}`)+` · from the costs snapshot `,1),y(`div`,wt,[y(`table`,Tt,[o[13]||=y(`thead`,null,[y(`tr`,null,[y(`th`,{class:`border-b border-muted px-2 py-1.5 text-left`},`Finished UTC`),y(`th`,{class:`border-b border-muted px-2 py-1.5 text-left`},`Run`),y(`th`,{class:`border-b border-muted px-2 py-1.5 text-right`},`Child cost`),y(`th`,{class:`border-b border-muted px-2 py-1.5 text-right`},`Shown total`)])],-1),y(`tbody`,null,[(m(!0),b(v,null,x(M.value.runs,e=>(m(),b(`tr`,{key:e.id},[y(`td`,Et,i(new Date(e.finishedAt).toISOString().replace(`T`,` `).slice(0,16)),1),y(`td`,Dt,[y(`a`,{href:`/runs/${encodeURIComponent(e.id)}`,class:`no-underline hover:underline`},i(e.id.slice(0,8)),9,Ot)]),y(`td`,kt,i(e.usd===null?`unknown`:h(D)(e.usd)),1),y(`td`,At,i(e.cumulativeUsd===null?`unknown`:h(D)(e.cumulativeUsd)),1)]))),128))])])])],64)):p(``,!0):(m(),b(`p`,St,`No retained Ship child runs in this range.`))])):p(``,!0),y(`nav`,jt,[(m(),b(v,null,x(z,e=>(m(),b(v,{key:e.view},[e.view===L.value?(m(),b(`span`,Mt,i(e.tab),1)):(m(),C(f,{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`,to:Y(u.value.group,u.value.range.days,e.view)},{default:a(()=>[r(i(e.tab),1)]),_:2},1032,[`to`]))],64))),64))]),L.value===`daily`?p(``,!0):(m(),b(`section`,Nt,[y(`div`,null,[y(`h2`,Pt,`Cost `+i(B.value.tab.toLowerCase()),1),y(`p`,Ft,i(B.value.subtitle),1)]),R.value?(m(),C(Pe,{key:0,report:R.value},null,8,[`report`])):(m(),b(`p`,It,` The `+i(B.value.tab.toLowerCase())+` report did not load with this page. `,1)),y(`p`,Lt,[o[14]||=r(` Machine-readable twin: `,-1),y(`code`,Rt,`GET /costs/`+i(u.value.group)+`/`+i(L.value)+`.json`,1),o[15]||=r(` (same Access gate). `,-1)])])),L.value===`daily`?(m(),b(`section`,zt,[o[16]||=y(`div`,null,[y(`h2`,{class:`text-[0.9375rem] font-medium`},`What each cloud dollar buys`)],-1),y(`table`,Bt,[y(`tbody`,null,[(m(!0),b(v,null,x(xe.value,e=>(m(),b(`tr`,{key:e.label,class:`border-b border-muted`},[y(`td`,Vt,[Ce(e.label)?(m(),b(`a`,{key:0,class:`no-underline hover:text-highlighted hover:underline`,href:Ce(e.label),target:`_blank`,rel:`noopener noreferrer`,title:`Open where this is billed on Cloudflare`},i(e.label),9,Ht)):(m(),b(v,{key:1},[r(i(e.label),1)],64))]),y(`td`,Ut,i(h(D)(e.usd)),1),y(`td`,Wt,i(Math.round(e.percent))+`%`,1),y(`td`,Gt,[y(`i`,{class:`block h-2.5 rounded-xs bg-primary opacity-75`,style:l({width:`${e.percent.toFixed(1)}%`})},null,4)])]))),128))])])])):p(``,!0),L.value===`daily`?(m(),b(`section`,Kt,[y(`details`,qt,[o[19]||=y(`summary`,{class:`cursor-pointer text-sm text-muted`},`Table view — daily cost by component (USD)`,-1),y(`div`,Jt,[y(`table`,Yt,[y(`thead`,null,[y(`tr`,null,[o[17]||=y(`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),(m(!0),b(v,null,x(X.value,e=>(m(),b(`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`},i(e),1))),128)),o[18]||=y(`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)])]),y(`tbody`,null,[(m(!0),b(v,null,x(Ee.value,e=>(m(),b(`tr`,{key:e.date},[y(`td`,{class:`border-b border-muted px-2.5 py-1.5`,title:e.date},[r(i($(e.date))+` `,1),u.value.range.partialLastDay&&e.date===u.value.range.to?(m(),b(`span`,Zt,`(partial day`+i(e.llmEstimated?` · LLM estimated`:``)+`)`,1)):e.llmEstimated?(m(),b(`span`,Qt,`(LLM estimated)`)):p(``,!0)],8,Xt),(m(!0),b(v,null,x(X.value,t=>(m(),b(`td`,{key:t,class:`border-b border-muted px-2.5 py-1.5 text-right`},i(h(D)(h(E)(e,t),3)),1))),128)),y(`td`,$t,i(h(D)(e.total,3)),1)]))),128))])])])]),y(`p`,en,[o[20]||=r(` Machine-readable twin: `,-1),y(`code`,tn,`GET /costs/`+i(u.value.group)+`.json`,1),o[21]||=r(` (same Access gate). `,-1)])])):p(``,!0),L.value===`daily`&&De.value.length?(m(),b(`section`,nn,[o[26]||=y(`div`,null,[y(`h2`,{class:`text-[0.9375rem] font-medium`},`Invoice tie-out by biller`),y(`p`,{class:`text-xs text-muted`},[r(` Each biller's own invoice beside the summed `),y(`code`,null,`model.turn`),r(` dollars its runs attributed — an aggregator's fee against the summed fees, its BYOK upstream against the remainder. Attributed is the meter's charged figure — each turn's own `),y(`code`,null,`usd`),r(` (the provider's, the operator's or the registry's price at the time) — never the price table's repricing the dimension tabs show, so the two need not agree. `)])],-1),(m(!0),b(v,null,x(De.value,e=>(m(),b(`div`,{key:e.biller,class:`grid gap-1.5`,"data-biller":e.biller},[y(`p`,an,[y(`b`,null,i(e.biller),1),e.invoice?(m(),b(v,{key:0},[r(` · invoice `+i(h(D)(e.totals.invoiceUsd,4))+` · attributed `+i(h(D)(e.totals.attributedUsd,4)),1)],64)):(m(),b(`span`,on,` · no invoice — the block names no invoice source`)),e.unpricedTokens>0?(m(),b(`span`,sn,` · `+i(e.unpricedTokens.toLocaleString(`en-US`))+` tokens unpriced — not in the attributed figure`,1)):p(``,!0)]),e.days.length?(m(),b(`div`,cn,[y(`table`,ln,[y(`thead`,null,[y(`tr`,null,[o[22]||=y(`th`,{class:`border-b border-muted px-2.5 py-1 text-left text-xs font-medium text-muted`},`Date`,-1),e.invoice?(m(),b(`th`,un,` Invoice `)):p(``,!0),o[23]||=y(`th`,{class:`border-b border-muted px-2.5 py-1 text-right text-xs font-medium text-muted`},`Attributed`,-1),o[24]||=y(`th`,{class:`border-b border-muted px-2.5 py-1 text-right text-xs font-medium text-muted`},` Fee (invoice / rows) `,-1),o[25]||=y(`th`,{class:`border-b border-muted px-2.5 py-1 text-right text-xs font-medium text-muted`},` Upstream (invoice / remainder) `,-1),e.unpricedTokens>0?(m(),b(`th`,dn,` Unpriced tokens `)):p(``,!0)])]),y(`tbody`,null,[(m(!0),b(v,null,x(e.days,t=>(m(),b(`tr`,{key:t.date},[y(`td`,{class:`border-b border-muted px-2.5 py-1`,title:t.date},i($(t.date)),9,fn),e.invoice?(m(),b(`td`,pn,i(t.invoiceUsd===void 0?`—`:h(D)(t.invoiceUsd,4)),1)):p(``,!0),y(`td`,mn,i(h(D)(t.attributedUsd,4)),1),y(`td`,hn,[t.invoiceFeeUsd!==void 0||t.attributedFeeUsd!==void 0?(m(),b(v,{key:0},[r(i(t.invoiceFeeUsd===void 0?`—`:h(D)(t.invoiceFeeUsd,4))+` / `+i(t.attributedFeeUsd===void 0?`—`:h(D)(t.attributedFeeUsd,4)),1)],64)):(m(),b(v,{key:1},[r(`—`)],64))]),y(`td`,gn,[t.invoiceByokUsd!==void 0||t.attributedUpstreamUsd!==void 0?(m(),b(v,{key:0},[r(i(t.invoiceByokUsd===void 0?`—`:h(D)(t.invoiceByokUsd,4))+` / `+i(t.attributedUpstreamUsd===void 0?`—`:h(D)(t.attributedUpstreamUsd,4)),1)],64)):(m(),b(v,{key:1},[r(`—`)],64))]),e.unpricedTokens>0?(m(),b(`td`,_n,i((t.unpricedTokens??0).toLocaleString(`en-US`)),1)):p(``,!0)]))),128))])])])):p(``,!0)],8,rn))),128))])):p(``,!0),y(`footer`,vn,[y(`details`,null,[o[34]||=y(`summary`,{class:`cursor-pointer text-muted`},`How these numbers are computed`,-1),y(`div`,yn,[o[32]||=y(`div`,null,[y(`b`,null,`Snapshot.`),r(` 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 `),y(`em`,null,`today`),r(` 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 (`),y(`code`,null,`costs.snapshot.everyHours`),r(`, daily by default); `),y(`code`,null,`costs snapshot`),r(` 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. The invoice tie-out's attributed side is different money: the meter's charged figure from each turn's own `),y(`code`,null,`usd`),r(`, never the price table's repricing the dimension tabs show, with the tokens no turn priced counted beside it as unpriced. `)],-1),o[33]||=y(`div`,null,[y(`b`,null,`Method.`),r(` Cloudflare GraphQL Analytics, every meter a Workers deployment is billed on: `),y(`code`,null,`containersUsageAdaptiveGroups`),r(` (cpuTimeSec, allocatedMemory, allocatedDisk per app per UTC day), `),y(`code`,null,`durableObjectsPeriodicGroups`),r(` (billable `),y(`code`,null,`duration`),r(` GB-s and SQLite rows read and written per namespace), `),y(`code`,null,`durableObjectsInvocationsAdaptiveGroups`),r(` (requests per namespace), `),y(`code`,null,`durableObjectsSqlStorageGroups`),r(` (bytes stored), `),y(`code`,null,`workersInvocationsAdaptive`),r(` (requests, CPU time), `),y(`code`,null,`r2StorageAdaptiveGroups`),r(` and `),y(`code`,null,`r2OperationsAdaptiveGroups`),r(` (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),y(`div`,null,[o[27]||=y(`b`,null,`Scope.`,-1),o[28]||=r(` Attributed to this group: the Workers `,-1),(m(!0),b(v,null,x(u.value.attribution.workers,(e,t)=>(m(),b(v,{key:e},[t>0?(m(),b(v,{key:0},[r(`, `)],64)):p(``,!0),Q.value?(m(),b(`a`,{key:1,class:`font-mono hover:underline`,href:Q.value.worker(e),target:`_blank`,rel:`noopener noreferrer`},i(e),9,bn)):(m(),b(`code`,xn,i(e),1))],64))),128)),r(`, every Durable Object namespace they host (`+i(Object.keys(u.value.attribution.durableObjectNamespaces).length)+`), the R2 buckets named after them (`,1),(m(!0),b(v,null,x(Object.keys(u.value.attribution.r2Buckets),(e,t)=>(m(),b(v,{key:e},[t>0?(m(),b(v,{key:0},[r(`, `)],64)):p(``,!0),Q.value?(m(),b(`a`,{key:1,class:`font-mono hover:underline`,href:Q.value.bucket(e),target:`_blank`,rel:`noopener noreferrer`},i(e),9,Sn)):(m(),b(`code`,Cn,i(e),1))],64))),128)),Object.keys(u.value.attribution.r2Buckets).length===0?(m(),b(v,{key:0},[r(`none`)],64)):p(``,!0),o[29]||=r(`), and the container apps mapped in `,-1),y(`code`,null,`costs.groups.`+i(u.value.group),1),r(` (`+i(Object.keys(u.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),Q.value?(m(),b(`a`,{key:1,class:`hover:underline`,href:Q.value.account,target:`_blank`,rel:`noopener noreferrer`},`Cloudflare dashboard`,8,wn)):p(``,!0),o[30]||=r(` for the account `,-1),y(`code`,null,i(u.value.account.id),1),r(i(u.value.account.name?` (${u.value.account.name})`:``)+`, and `,1),Q.value?(m(),b(`a`,{key:2,class:`hover:underline`,href:Q.value.anthropic,target:`_blank`,rel:`noopener noreferrer`},`Anthropic's cost page`,8,Tn)):p(``,!0),o[31]||=r(` for the LLM line. `,-1)])])])])]),_:1},8,[`title`])):(m(),C(e,{key:1,title:`${P.value} spend`,nav:`costs`},{default:a(()=>[y(`div`,En,[N.value.length>1?(m(),b(`nav`,Dn,[(m(!0),b(v,null,x(N.value,e=>(m(),b(v,{key:e},[e===P.value?(m(),b(`span`,On,i(e),1)):(m(),C(f,{key:1,class:`rounded-md px-2.5 py-1 text-xs text-muted no-underline hover:bg-elevated hover:text-highlighted`,to:`/costs/${e}`},{default:a(()=>[r(i(e),1)]),_:2},1032,[`to`]))],64))),128))])):p(``,!0)]),y(`section`,kn,[o[35]||=y(`h2`,{class:`text-sm font-medium text-highlighted`},`Nothing to show yet`,-1),y(`div`,An,[y(`p`,jn,i(I.value),1),V.value?(m(),b(`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:q.value||F.value?.inFlight!==null,"data-snapshot-now":``,onClick:ye},i(F.value?.inFlight?`Taking…`:`Snapshot now`),9,Mn)):p(``,!0),J.value?(m(),b(`span`,Nn,i(J.value),1)):p(``,!0)]),o[36]||=y(`p`,{class:`text-xs text-dimmed`},[r(` 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 `),y(`code`,null,`costs snapshot`),r(`. `)],-1)])]),_:1},8,[`title`]))}}});export{Pn as default};
@@ -1 +1 @@
1
- import{i as e,r as t,t as n}from"./AppShell-CCPwPqvc.js";import{An as r,Cr as i,Dn as a,Fi as o,Jr as s,Mi as c,Mt as l,Nt as ee,On as u,Pi as d,Qt as f,Sr as p,Ur as m,Xr as te,_i as h,_n as g,_r as ne,ar as re,bn as _,c as ie,hr as v,ki as y,l as ae,lr as oe,nr as b,o as se,pr as ce,sn as x,t as S,vn as C,xn as w,xr as T,y as E,yi as D,yn as O}from"./browser-BWnzWwaT.js";import{t as k}from"./Tooltip-CxiQ7luL.js";import{i as le}from"./PendingTurnRow-BPyJ2f-i.js";import{b as ue,x as de}from"./main-DYwKyLY5.js";import{t as fe}from"./eventSource-Ds6_gjPD.js";import{t as pe}from"./wallClock-DaewxNMY.js";import{r as A}from"./indexFormat-B-pd4r7Y.js";import{K as me,i as he}from"./indexRow-BGjjLnN5.js";import"./format-BldUwl_R.js";import{S as j,_ as ge,a as _e,b as ve,c as M,d as ye,f as be,g as xe,h as N,i as Se,l as Ce,m as P,n as we,o as Te,p as Ee,r as De,s as F,t as Oe,u as ke,v as Ae,x as je,y as Me}from"./SilentTurn-D4MMDjWO.js";import{t as Ne}from"./SlackMark-DjJTK2tD.js";import{T as Pe}from"./sseReplay-BDVyc8HX.js";var I={class:`thread-tip flex max-w-xs flex-col gap-1 text-xs`},Fe={class:`tip-title leading-snug text-highlighted`},L={class:`flex flex-wrap items-center gap-x-1.5 gap-y-0.5 font-mono text-[0.68rem] text-muted`},R={class:`tip-when tabular-nums`},Ie={class:`tip-source inline-flex items-center gap-1`},Le={class:`tip-runs`},Re={key:0,class:`tip-live inline-flex items-center gap-1 text-toned`},z=r({__name:`ThreadTip`,props:{row:{},now:{}},setup(e){let t=e,n=g(()=>j(t.row,t.now));return(t,r)=>(v(),w(`div`,I,[C(`p`,Fe,o(n.value.title),1),C(`p`,L,[C(`span`,R,o(n.value.when),1),r[1]||=C(`span`,{"aria-hidden":`true`},`·`,-1),C(`span`,Ie,[e.row.surface===`slack`?(v(),O(Ne,{key:0})):_(``,!0),a(o(n.value.source),1)]),r[2]||=C(`span`,{"aria-hidden":`true`},`·`,-1),C(`span`,Le,o(n.value.runs),1),n.value.live?(v(),w(`span`,Re,[...r[0]||=[C(`span`,{class:`size-1.5 rounded-full bg-ok`,"aria-hidden":`true`},null,-1),a(`live`,-1)]])):_(``,!0)])]))}}),B={class:`rail flex flex-col gap-1 text-[0.8rem]`,"aria-label":`Recent threads`},V={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`},H={key:0,class:`rounded border border-default px-1 font-mono text-[0.65rem] text-dimmed`},ze={key:0,class:`empty px-3 py-1 text-xs text-dimmed`},U={key:1,class:`nomatch px-3 py-1 text-xs text-dimmed`},W={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`},Be={class:`title min-w-0 flex-1 truncate text-toned group-hover:text-highlighted group-aria-[current=page]:text-highlighted`},Ve={class:`when shrink-0 font-mono text-[0.7rem] tabular-nums text-dimmed`},G={class:`retention px-3 pt-1 text-[0.7rem] leading-relaxed text-dimmed`},K={class:`model px-3 pt-2 text-[0.7rem] leading-relaxed text-dimmed`,"data-testid":`what-is-a-thread`},q=500,He=r({__name:`ConversationRail`,props:{rows:{},current:{},now:{},retention:{}},setup(e,{expose:t}){let n=e,r=D(``),c=D(null),l=g(()=>P(n.rows,r.value));function d(){c.value?.focus(),c.value?.select()}function p(e){e.key===`Escape`&&(r.value=``,c.value?.blur())}return t({focusFilter:d}),(t,n)=>{let d=E,m=i(`RouterLink`),h=k;return v(),w(`nav`,B,[u(m,{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`,to:`/threads`,"aria-current":e.current===``?`page`:void 0,"data-testid":`new-thread`},{default:s(()=>[u(d,{name:`i-lucide-plus`,class:`size-4 shrink-0 transition-transform duration-150 ease-out group-hover:rotate-90`,"aria-hidden":`true`}),n[1]||=C(`span`,null,`New thread`,-1),n[2]||=C(`span`,{class:`kbd ml-auto flex gap-0.5 font-mono text-[0.65rem] opacity-70`,"aria-label":`shortcut shift command O`},[C(`kbd`,{class:`rounded border border-current/30 px-1`},`⇧`),C(`kbd`,{class:`rounded border border-current/30 px-1`},`⌘`),C(`kbd`,{class:`rounded border border-current/30 px-1`},`O`)],-1)]),_:1},8,[`aria-current`]),C(`label`,V,[u(d,{name:`i-lucide-search`,class:`size-3.5 shrink-0 text-dimmed`,"aria-hidden":`true`}),te(C(`input`,{ref_key:`filter`,ref:c,"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:p},null,544),[[f,r.value]]),r.value?_(``,!0):(v(),w(`kbd`,H,`⌘K`))]),n[8]||=C(`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?(v(),w(`p`,ze,`Nothing yet. Ask something.`)):l.value.length===0?(v(),w(`p`,U,`Nothing matches "`+o(r.value)+`".`,1)):_(``,!0),u(ee,{name:`sb-rise`,tag:`div`,class:`rows flex flex-col gap-0.5`},{default:s(()=>[(v(!0),w(x,null,T(l.value,t=>(v(),w(`div`,{key:t.id},[u(h,{"delay-duration":q,content:{side:`right`,sideOffset:12,align:`start`},ui:{content:`h-auto max-w-xs px-2.5 py-2`}},{content:s(()=>[u(z,{row:t,now:e.now},null,8,[`row`,`now`])]),default:s(()=>[u(m,{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)`,to:`/threads/${encodeURIComponent(t.id)}`,"aria-current":t.id===e.current?`page`:void 0,"data-surface":t.surface},{default:s(()=>[n[3]||=C(`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?(v(),w(`span`,W)):_(``,!0),C(`span`,Be,o(t.title),1),C(`span`,Ve,o(y(ye)(t.lastAt,e.now)),1)]),_:2},1032,[`to`,`aria-current`,`data-surface`])]),_:2},1024)]))),128))]),_:1}),u(m,{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`,to:`/runs`,"data-testid":`all-runs`},{default:s(()=>[n[4]||=a(` All runs `,-1),u(d,{name:`i-lucide-arrow-right`,class:`size-3 transition-transform duration-150 ease-out group-hover:translate-x-0.5`,"aria-hidden":`true`})]),_:1}),C(`p`,G,o(e.retention),1),C(`p`,K,[n[6]||=a(` A thread holds the runs its messages start. `,-1),u(m,{class:`text-muted hover:text-highlighted`,to:`/runs`},{default:s(()=>[...n[5]||=[a(`Runs`,-1)]]),_:1}),n[7]||=a(` lists every run across everyone's threads. `,-1)])])}}}),Ue={class:`empty mx-auto flex w-full max-w-2xl flex-col items-center gap-5 px-3 py-6 text-center`},We={class:`flex flex-col gap-1.5`},Ge={class:`greeting sb-stagger text-xl font-medium tracking-tight text-highlighted`,style:{"--sb-i":`1`}},Ke={class:`sb-stagger w-full text-left`,style:{"--sb-i":`3`}},J={key:0,class:`chips flex flex-wrap justify-center gap-2`,"aria-label":`Suggestions`},Y=[`onClick`],qe=r({__name:`EmptyState`,props:{name:{},hour:{},suggestions:{}},emits:[`pick`],setup(e,{emit:n}){let r=n;return(n,i)=>(v(),w(`section`,Ue,[u(t,{draw:``,idle:``,class:`mark-lg sb-stagger text-highlighted`,style:{"font-size":`3.25rem`,"--sb-i":`0`}}),C(`div`,We,[C(`h2`,Ge,o(y(N)(e.hour,e.name)),1),i[0]||=C(`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)]),C(`div`,Ke,[p(n.$slots,`default`)]),e.suggestions.length>0?(v(),w(`ul`,J,[(v(!0),w(x,null,T(e.suggestions,(e,t)=>(v(),w(`li`,{key:e,class:`sb-stagger`,style:d({"--sb-i":t+4})},[C(`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)},o(e),9,Y)],4))),128))])):_(``,!0)]))}});function Je(){return{runs:new Map,connected:!1}}function Ye(e,t){t.type===`upsert`&&t.run?t.run.finished||!t.run.threadKey?e.runs.delete(t.run.id):e.runs.set(t.run.id,{threadKey:t.run.threadKey,startedAt:t.run.startedAt,...t.run.label===void 0?{}:{label:t.run.label},...t.run.channelId===void 0?{}:{channelId:t.run.channelId}}):t.type===`removed`&&t.id&&e.runs.delete(t.id)}function Xe(e){let t=new Map;for(let n of e.runs.values()){let e=t.get(n.threadKey)??[];e.push(n),t.set(n.threadKey,e)}return t}function Ze(e,t){return t.includes(`:`)?t:`${e}:${t}`}function Qe(e){let t=e.indexOf(`:`);return t>0?e.slice(0,t):`unknown`}function $e(e,t,n){if(!t.connected)return[...e];let r=Xe(t),i=new Set,a=e.map(e=>{let t=Ze(n,e.id);i.add(t);let a=r.get(t);if(!a)return e.live?{...e,live:!1}:e;let o=e.live?0:a.length;return{...e,live:!0,runs:e.runs+o,lastAt:Math.max(e.lastAt,...a.map(e=>e.startedAt))}}),o=[];for(let[e,t]of r){if(i.has(e))continue;let r=t.reduce((e,t)=>t.startedAt>e.startedAt?t:e),a=r.label?A(r.label).snippet:void 0;o.push({id:e.startsWith(`${n}:`)?e.slice(n.length+1):e,title:a??r.label??e,excerpt:a??r.label??e,lastAt:r.startedAt,runs:t.length,live:!0,surface:Qe(r.channelId??e)})}return o.sort((e,t)=>t.lastAt-e.lastAt),[...o,...a]}var et={key:0,class:`mx-auto my-12 max-w-xl text-center text-toned`},tt=[`data-rail`],nt={key:0,class:`relative hidden md:block`},rt=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`],it={class:`thread mx-auto flex min-h-[calc(100vh-8rem)] w-full max-w-3xl flex-col`},at={key:4,class:`inline text-[0.875rem] text-toned`,"data-testid":`inline`},ot={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`},st=[`href`],ct={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`},X=`(min-width: 48rem)`,Z=r({__name:`HomePage`,setup(t){let r=se(`home`),i=pe(r?.now),f=r?.conversation??``,p=ie(r?.retentionDays??null),te=0,E=e=>`${e}-${++te}`,k=h([]);for(let e of r?.turns??[]){if(`kind`in e){e.kind===`receipt`?k.push({key:E(`s`),kind:`silent`,reason:e.reason,at:e.decidedAt}):k.push({key:E(`w`),kind:`parent`,turn:e});continue}k.push({key:E(`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:r?.now}:null;k.push({key:E(`a`),kind:`assistant`,turn:e,live:t,ended:e.finished})}let A=g(()=>{for(let e=k.length-1;e>=0;e--){let t=k[e];if(t.kind===`assistant`&&t.live&&!t.ended&&t.turn.hosted!==!0)return t}return null}),j=D(null),ye=D(0);ne(e,ye);let N=D(``),P=D(void 0),Ne=g(()=>be(A.value!==null,N.value)),I=D(!1);m(N,()=>{P.value&&N.value===``&&(P.value=void 0)});function Fe(e){N.value=e,L()}async function L(){if(!r||I.value)return;let e=Te(N.value.trim(),r.commands);if(e===``)return;let t=h({key:E(`p`),kind:`person`,text:e,at:i.value,pending:!0});k.push(t),N.value=``,P.value=void 0,I.value=!0,ye.value++;try{let n=await fetch(r.sendUrl,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify({text:e})}),a=await n.json().catch(()=>({}));if(n.status===202&&typeof a.viewPath==`string`&&typeof a.runId==`string`){let n=xe(a.viewPath);if(!n)throw Error(`the run's view path was not one`);t.pending=!1,S.pathname()===`/threads`&&S.replaceUrl(`/threads/${encodeURIComponent(f)}`),k.push({key:E(`a`),kind:`assistant`,turn:{id:a.runId,request:e,startedAt:i.value,receivedAt:i.value,finished:!1,eventCount:0},live:{eventsUrl:n.eventsUrl,stopUrl:n.stopUrl},ended:!1});return}if(n.ok&&a.offer&&typeof a.offer.line==`string`){t.pending=!1;let e=Ae({line:a.offer.line,...a.offer});N.value=e.command,P.value=e.hint;return}if(n.ok&&typeof a.reply==`string`){t.pending=!1;let e=ke(a.reply);e.kind===`inline`&&k.push({key:E(`i`),kind:`inline`,text:e.text});return}throw Error(a.error??`HTTP ${n.status}`)}catch(e){t.pending=!1,t.failed=`not sent: ${e instanceof Error?e.message:`error`}`}finally{I.value=!1}}function R(){let e=j.value;e&&fetch(`${e}${e.includes(`?`)?`&`:`?`}mode=soft`,{method:`POST`,credentials:`same-origin`})}function Ie(e,t,n){let r=k.filter(e=>e.kind===`person`),i=ge(r.map(e=>({text:e.text,folded:e.folded!==void 0,ref:e})),t);if(!i)return;let a=e.turn.receivedAt??e.turn.startedAt;i.ref.folded=n===void 0?``:`at ${me(Math.max(0,n-a),`clock`)}`}function Le(e){e.ended=!0,j.value=null}let Re=Me({width:S.readPref(F.width),collapsed:S.readPref(F.collapsed)}),z=D(Re.width),B=D(Re.collapsed),V=D(!1),H=D(S.mediaMatches(X)),ze=S.onMediaChange(X,e=>{H.value=e}),U=D(null),W=D(null),Be=g(()=>H.value?B.value?`Show recent threads`:`Hide recent threads`:`Recent threads`);function Ve(){if(H.value=S.mediaMatches(X),H.value){B.value=!B.value,S.writePref(F.collapsed,B.value?`1`:`0`);return}V.value=!0}function G(e,t){z.value=Ce(e),t&&S.writePref(F.width,String(z.value))}let K=null;function q(e){K&&G(K.startWidth+(e.clientX-K.startX),!1)}function Ue(){window.removeEventListener(`pointermove`,q),K&&(K=null,S.writePref(F.width,String(z.value)))}function We(e){e.button===0&&(e.preventDefault(),K={startX:e.clientX,startWidth:z.value},e.currentTarget?.setPointerCapture?.(e.pointerId),window.addEventListener(`pointermove`,q),window.addEventListener(`pointerup`,Ue,{once:!0}))}function Ge(e){if(e.key===`ArrowRight`)G(z.value+M.step,!0);else if(e.key===`ArrowLeft`)G(z.value-M.step,!0);else if(e.key===`Home`)G(M.min,!0);else if(e.key===`End`)G(M.max,!0);else return;e.preventDefault()}re(()=>{window.removeEventListener(`pointermove`,q),window.removeEventListener(`pointerup`,Ue),ze()});function Ke(e){let t=ve(e);if(t){if(e.preventDefault(),t===`newThread`){S.navigate(`/threads`);return}if(U.value){U.value.focusFilter();return}if(B.value&&S.mediaMatches(X)){B.value=!1,S.writePref(F.collapsed,`0`),b().then(()=>U.value?.focusFilter());return}V.value=!0,b().then(()=>W.value?.focusFilter())}}let J=D(null),Y=D(!1);function Xe(){return document.body.scrollHeight-(window.innerHeight+window.scrollY)}m(()=>k.length,()=>{let e=je(Xe());b().then(()=>{e?J.value?.scrollIntoView?.({block:`end`}):Y.value=!0})});function Ze(){je(Xe())&&(Y.value=!1)}function Qe(){J.value?.scrollIntoView?.({block:`end`,behavior:`smooth`}),Y.value=!1}oe(()=>{window.addEventListener(`scroll`,Ze,{passive:!0}),window.addEventListener(`keydown`,Ke),r&&ft()}),ce(()=>{window.removeEventListener(`scroll`,Ze),window.removeEventListener(`keydown`,Ke),Q?.close()});let Z=h(Je()),lt=g(()=>$e(r?.conversations??[],Z,r?.lane??``)),ut=g(()=>{let e=A.value?.turn.id;return Z.runs.size+(e&&!Z.runs.has(e)?1:0)}),dt=fe(),Q=null;function ft(){Q=dt(`/runs?stream=1&mine=1`);let e=!1;Q.onopen=()=>{e&&Z.runs.clear(),e=!0,Z.connected=!0},Q.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}Ye(Z,t)}}let pt=g(()=>{let e=k.find(e=>e.kind===`person`);return e?Ee(e.text):`Switchboard`});m([pt,ut],([e,t])=>{S.setTitle(t>0?`(${t}) ${e}`:e),S.setFavicon(t>0?de:ue)},{immediate:!0});let mt=g(()=>new Date(i.value).getHours()),ht=g(()=>k.length===0),$=r?.elsewhere,gt=$?$.surface===`web`?`This thread is another person's conversation. You can read it here.`:`This thread lives in ${he[$.surface]??$.surface}.`:``;return(e,t)=>{let m=ae,te=le;return v(),O(n,{title:`Threads`,nav:`home`},{leading:s(()=>[u(m,{class:`rail-toggle -ml-1`,size:`xs`,color:`neutral`,variant:`ghost`,icon:H.value&&!B.value?`i-lucide-panel-left-close`:`i-lucide-panel-left`,"aria-label":Be.value,"aria-expanded":H.value?!B.value:void 0,onClick:Ve},null,8,[`icon`,`aria-label`,`aria-expanded`])]),default:s(()=>[y(r)?(v(),w(`div`,{key:1,class:c([`home gap-8 md:grid`,B.value?`md:grid-cols-[minmax(0,1fr)]`:`md:grid-cols-[var(--rail-w)_minmax(0,1fr)]`]),style:d({"--rail-w":`${z.value}px`}),"data-rail":B.value?`hidden`:`shown`},[B.value?_(``,!0):(v(),w(`aside`,nt,[u(He,{ref_key:`rail`,ref:U,class:`sticky top-20`,rows:lt.value,current:y(f),now:y(i),retention:y(p)},null,8,[`rows`,`current`,`now`,`retention`]),C(`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":y(M).min,"aria-valuemax":y(M).max,"aria-valuenow":z.value,tabindex:`0`,"data-testid":`rail-handle`,onPointerdown:We,onKeydown:Ge,onDblclick:t[0]||=e=>G(y(M).default,!0)},[...t[5]||=[C(`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,rt)])),u(te,{open:V.value,"onUpdate:open":t[1]||=e=>V.value=e,side:`left`,title:`Recent threads`,ui:{content:`max-w-xs`}},{body:s(()=>[u(He,{ref_key:`sheetRail`,ref:W,rows:lt.value,current:y(f),now:y(i),retention:y(p)},null,8,[`rows`,`current`,`now`,`retention`])]),_:1},8,[`open`]),C(`section`,it,[ht.value?(v(),O(qe,{key:0,class:`mb-auto mt-[clamp(1.5rem,14vh,9rem)]`,name:y(r).viewer.name,hour:mt.value,suggestions:y(r).suggestions,onPick:Fe},{default:s(()=>[u(_e,{modelValue:N.value,"onUpdate:modelValue":t[2]||=e=>N.value=e,mode:Ne.value,hint:P.value,commands:y(r).commands,autofocus:``,"sweep-on-mount":``,onSubmit:L,onStop:R},null,8,[`modelValue`,`mode`,`hint`,`commands`])]),_:1},8,[`name`,`hour`,`suggestions`])):(v(),O(ee,{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(()=>[(v(!0),w(x,null,T(k,e=>(v(),w(`li`,{key:e.key},[e.kind===`person`?(v(),O(Se,{key:0,text:e.text,at:e.at,now:y(i),pending:e.pending,folded:e.folded,failed:e.failed},null,8,[`text`,`at`,`now`,`pending`,`folded`,`failed`])):e.kind===`assistant`?(v(),O(De,{key:1,turn:e.turn,live:e.live,now:y(i),onInput:(t,n)=>Ie(e,t,n),onEnded:t=>Le(e),onStop:t[3]||=e=>j.value=e},null,8,[`turn`,`live`,`now`,`onInput`,`onEnded`])):e.kind===`silent`?(v(),O(Oe,{key:2,reason:e.reason,"decided-at":e.at,now:y(i)},null,8,[`reason`,`decided-at`,`now`])):e.kind===`parent`?(v(),O(we,{key:3,turn:e.turn,now:y(i)},null,8,[`turn`,`now`])):(v(),w(`div`,at,[u(Pe,{text:e.text},null,8,[`text`])]))]))),128))]),_:1})),C(`div`,{ref_key:`end`,ref:J,class:`end`,"aria-hidden":`true`},null,512),!ht.value&&y($)?(v(),w(`p`,ot,[a(o(y(gt))+` `,1),y($).url?(v(),w(`a`,{key:0,href:y($).url,target:`_blank`,rel:`noopener`,class:`text-highlighted`},`Reply there ↗`,8,st)):y($).surface===`web`?_(``,!0):(v(),w(x,{key:1},[a(`Reply there.`)],64))])):ht.value?_(``,!0):(v(),w(`div`,ct,[u(l,{name:`sb-rise`},{default:s(()=>[Y.value?(v(),w(`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:Qe},` ↓ new `)):_(``,!0)]),_:1}),u(_e,{modelValue:N.value,"onUpdate:modelValue":t[4]||=e=>N.value=e,mode:Ne.value,hint:P.value,commands:y(r).commands,autofocus:``,onSubmit:L,onStop:R},null,8,[`modelValue`,`mode`,`hint`,`commands`])]))])],14,tt)):(v(),w(`div`,et,`This page needs its seed.`))]),_:1})}}});export{Z as default};
1
+ import{i as e,r as t,t as n}from"./AppShell-CCPwPqvc.js";import{An as r,Cr as i,Dn as a,Fi as o,Jr as s,Mi as c,Mt as l,Nt as ee,On as u,Pi as d,Qt as f,Sr as p,Ur as m,Xr as te,_i as h,_n as g,_r as ne,ar as re,bn as _,c as ie,hr as v,ki as y,l as ae,lr as oe,nr as b,o as se,pr as ce,sn as x,t as S,vn as C,xn as w,xr as T,y as E,yi as D,yn as O}from"./browser-BWnzWwaT.js";import{t as k}from"./Tooltip-qB73RL4b.js";import{i as le}from"./PendingTurnRow-BPyJ2f-i.js";import{S as ue,x as de}from"./main-9ynpo780.js";import{t as fe}from"./eventSource-Ds6_gjPD.js";import{t as pe}from"./wallClock-DaewxNMY.js";import{r as A}from"./indexFormat-B-pd4r7Y.js";import{K as me,i as he}from"./indexRow-BGjjLnN5.js";import"./format-BldUwl_R.js";import{S as j,_ as ge,a as _e,b as ve,c as M,d as ye,f as be,g as xe,h as N,i as Se,l as Ce,m as P,n as we,o as Te,p as Ee,r as De,s as F,t as Oe,u as ke,v as Ae,x as je,y as Me}from"./SilentTurn-D4MMDjWO.js";import{t as Ne}from"./SlackMark-DjJTK2tD.js";import{T as Pe}from"./sseReplay-BDVyc8HX.js";var I={class:`thread-tip flex max-w-xs flex-col gap-1 text-xs`},Fe={class:`tip-title leading-snug text-highlighted`},L={class:`flex flex-wrap items-center gap-x-1.5 gap-y-0.5 font-mono text-[0.68rem] text-muted`},R={class:`tip-when tabular-nums`},Ie={class:`tip-source inline-flex items-center gap-1`},Le={class:`tip-runs`},Re={key:0,class:`tip-live inline-flex items-center gap-1 text-toned`},z=r({__name:`ThreadTip`,props:{row:{},now:{}},setup(e){let t=e,n=g(()=>j(t.row,t.now));return(t,r)=>(v(),w(`div`,I,[C(`p`,Fe,o(n.value.title),1),C(`p`,L,[C(`span`,R,o(n.value.when),1),r[1]||=C(`span`,{"aria-hidden":`true`},`·`,-1),C(`span`,Ie,[e.row.surface===`slack`?(v(),O(Ne,{key:0})):_(``,!0),a(o(n.value.source),1)]),r[2]||=C(`span`,{"aria-hidden":`true`},`·`,-1),C(`span`,Le,o(n.value.runs),1),n.value.live?(v(),w(`span`,Re,[...r[0]||=[C(`span`,{class:`size-1.5 rounded-full bg-ok`,"aria-hidden":`true`},null,-1),a(`live`,-1)]])):_(``,!0)])]))}}),B={class:`rail flex flex-col gap-1 text-[0.8rem]`,"aria-label":`Recent threads`},V={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`},H={key:0,class:`rounded border border-default px-1 font-mono text-[0.65rem] text-dimmed`},ze={key:0,class:`empty px-3 py-1 text-xs text-dimmed`},U={key:1,class:`nomatch px-3 py-1 text-xs text-dimmed`},W={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`},Be={class:`title min-w-0 flex-1 truncate text-toned group-hover:text-highlighted group-aria-[current=page]:text-highlighted`},Ve={class:`when shrink-0 font-mono text-[0.7rem] tabular-nums text-dimmed`},G={class:`retention px-3 pt-1 text-[0.7rem] leading-relaxed text-dimmed`},K={class:`model px-3 pt-2 text-[0.7rem] leading-relaxed text-dimmed`,"data-testid":`what-is-a-thread`},q=500,He=r({__name:`ConversationRail`,props:{rows:{},current:{},now:{},retention:{}},setup(e,{expose:t}){let n=e,r=D(``),c=D(null),l=g(()=>P(n.rows,r.value));function d(){c.value?.focus(),c.value?.select()}function p(e){e.key===`Escape`&&(r.value=``,c.value?.blur())}return t({focusFilter:d}),(t,n)=>{let d=E,m=i(`RouterLink`),h=k;return v(),w(`nav`,B,[u(m,{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`,to:`/threads`,"aria-current":e.current===``?`page`:void 0,"data-testid":`new-thread`},{default:s(()=>[u(d,{name:`i-lucide-plus`,class:`size-4 shrink-0 transition-transform duration-150 ease-out group-hover:rotate-90`,"aria-hidden":`true`}),n[1]||=C(`span`,null,`New thread`,-1),n[2]||=C(`span`,{class:`kbd ml-auto flex gap-0.5 font-mono text-[0.65rem] opacity-70`,"aria-label":`shortcut shift command O`},[C(`kbd`,{class:`rounded border border-current/30 px-1`},`⇧`),C(`kbd`,{class:`rounded border border-current/30 px-1`},`⌘`),C(`kbd`,{class:`rounded border border-current/30 px-1`},`O`)],-1)]),_:1},8,[`aria-current`]),C(`label`,V,[u(d,{name:`i-lucide-search`,class:`size-3.5 shrink-0 text-dimmed`,"aria-hidden":`true`}),te(C(`input`,{ref_key:`filter`,ref:c,"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:p},null,544),[[f,r.value]]),r.value?_(``,!0):(v(),w(`kbd`,H,`⌘K`))]),n[8]||=C(`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?(v(),w(`p`,ze,`Nothing yet. Ask something.`)):l.value.length===0?(v(),w(`p`,U,`Nothing matches "`+o(r.value)+`".`,1)):_(``,!0),u(ee,{name:`sb-rise`,tag:`div`,class:`rows flex flex-col gap-0.5`},{default:s(()=>[(v(!0),w(x,null,T(l.value,t=>(v(),w(`div`,{key:t.id},[u(h,{"delay-duration":q,content:{side:`right`,sideOffset:12,align:`start`},ui:{content:`h-auto max-w-xs px-2.5 py-2`}},{content:s(()=>[u(z,{row:t,now:e.now},null,8,[`row`,`now`])]),default:s(()=>[u(m,{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)`,to:`/threads/${encodeURIComponent(t.id)}`,"aria-current":t.id===e.current?`page`:void 0,"data-surface":t.surface},{default:s(()=>[n[3]||=C(`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?(v(),w(`span`,W)):_(``,!0),C(`span`,Be,o(t.title),1),C(`span`,Ve,o(y(ye)(t.lastAt,e.now)),1)]),_:2},1032,[`to`,`aria-current`,`data-surface`])]),_:2},1024)]))),128))]),_:1}),u(m,{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`,to:`/runs`,"data-testid":`all-runs`},{default:s(()=>[n[4]||=a(` All runs `,-1),u(d,{name:`i-lucide-arrow-right`,class:`size-3 transition-transform duration-150 ease-out group-hover:translate-x-0.5`,"aria-hidden":`true`})]),_:1}),C(`p`,G,o(e.retention),1),C(`p`,K,[n[6]||=a(` A thread holds the runs its messages start. `,-1),u(m,{class:`text-muted hover:text-highlighted`,to:`/runs`},{default:s(()=>[...n[5]||=[a(`Runs`,-1)]]),_:1}),n[7]||=a(` lists every run across everyone's threads. `,-1)])])}}}),Ue={class:`empty mx-auto flex w-full max-w-2xl flex-col items-center gap-5 px-3 py-6 text-center`},We={class:`flex flex-col gap-1.5`},Ge={class:`greeting sb-stagger text-xl font-medium tracking-tight text-highlighted`,style:{"--sb-i":`1`}},Ke={class:`sb-stagger w-full text-left`,style:{"--sb-i":`3`}},J={key:0,class:`chips flex flex-wrap justify-center gap-2`,"aria-label":`Suggestions`},Y=[`onClick`],qe=r({__name:`EmptyState`,props:{name:{},hour:{},suggestions:{}},emits:[`pick`],setup(e,{emit:n}){let r=n;return(n,i)=>(v(),w(`section`,Ue,[u(t,{draw:``,idle:``,class:`mark-lg sb-stagger text-highlighted`,style:{"font-size":`3.25rem`,"--sb-i":`0`}}),C(`div`,We,[C(`h2`,Ge,o(y(N)(e.hour,e.name)),1),i[0]||=C(`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)]),C(`div`,Ke,[p(n.$slots,`default`)]),e.suggestions.length>0?(v(),w(`ul`,J,[(v(!0),w(x,null,T(e.suggestions,(e,t)=>(v(),w(`li`,{key:e,class:`sb-stagger`,style:d({"--sb-i":t+4})},[C(`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)},o(e),9,Y)],4))),128))])):_(``,!0)]))}});function Je(){return{runs:new Map,connected:!1}}function Ye(e,t){t.type===`upsert`&&t.run?t.run.finished||!t.run.threadKey?e.runs.delete(t.run.id):e.runs.set(t.run.id,{threadKey:t.run.threadKey,startedAt:t.run.startedAt,...t.run.label===void 0?{}:{label:t.run.label},...t.run.channelId===void 0?{}:{channelId:t.run.channelId}}):t.type===`removed`&&t.id&&e.runs.delete(t.id)}function Xe(e){let t=new Map;for(let n of e.runs.values()){let e=t.get(n.threadKey)??[];e.push(n),t.set(n.threadKey,e)}return t}function Ze(e,t){return t.includes(`:`)?t:`${e}:${t}`}function Qe(e){let t=e.indexOf(`:`);return t>0?e.slice(0,t):`unknown`}function $e(e,t,n){if(!t.connected)return[...e];let r=Xe(t),i=new Set,a=e.map(e=>{let t=Ze(n,e.id);i.add(t);let a=r.get(t);if(!a)return e.live?{...e,live:!1}:e;let o=e.live?0:a.length;return{...e,live:!0,runs:e.runs+o,lastAt:Math.max(e.lastAt,...a.map(e=>e.startedAt))}}),o=[];for(let[e,t]of r){if(i.has(e))continue;let r=t.reduce((e,t)=>t.startedAt>e.startedAt?t:e),a=r.label?A(r.label).snippet:void 0;o.push({id:e.startsWith(`${n}:`)?e.slice(n.length+1):e,title:a??r.label??e,excerpt:a??r.label??e,lastAt:r.startedAt,runs:t.length,live:!0,surface:Qe(r.channelId??e)})}return o.sort((e,t)=>t.lastAt-e.lastAt),[...o,...a]}var et={key:0,class:`mx-auto my-12 max-w-xl text-center text-toned`},tt=[`data-rail`],nt={key:0,class:`relative hidden md:block`},rt=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`],it={class:`thread mx-auto flex min-h-[calc(100vh-8rem)] w-full max-w-3xl flex-col`},at={key:4,class:`inline text-[0.875rem] text-toned`,"data-testid":`inline`},ot={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`},st=[`href`],ct={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`},X=`(min-width: 48rem)`,Z=r({__name:`HomePage`,setup(t){let r=se(`home`),i=pe(r?.now),f=r?.conversation??``,p=ie(r?.retentionDays??null),te=0,E=e=>`${e}-${++te}`,k=h([]);for(let e of r?.turns??[]){if(`kind`in e){e.kind===`receipt`?k.push({key:E(`s`),kind:`silent`,reason:e.reason,at:e.decidedAt}):k.push({key:E(`w`),kind:`parent`,turn:e});continue}k.push({key:E(`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:r?.now}:null;k.push({key:E(`a`),kind:`assistant`,turn:e,live:t,ended:e.finished})}let A=g(()=>{for(let e=k.length-1;e>=0;e--){let t=k[e];if(t.kind===`assistant`&&t.live&&!t.ended&&t.turn.hosted!==!0)return t}return null}),j=D(null),ye=D(0);ne(e,ye);let N=D(``),P=D(void 0),Ne=g(()=>be(A.value!==null,N.value)),I=D(!1);m(N,()=>{P.value&&N.value===``&&(P.value=void 0)});function Fe(e){N.value=e,L()}async function L(){if(!r||I.value)return;let e=Te(N.value.trim(),r.commands);if(e===``)return;let t=h({key:E(`p`),kind:`person`,text:e,at:i.value,pending:!0});k.push(t),N.value=``,P.value=void 0,I.value=!0,ye.value++;try{let n=await fetch(r.sendUrl,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify({text:e})}),a=await n.json().catch(()=>({}));if(n.status===202&&typeof a.viewPath==`string`&&typeof a.runId==`string`){let n=xe(a.viewPath);if(!n)throw Error(`the run's view path was not one`);t.pending=!1,S.pathname()===`/threads`&&S.replaceUrl(`/threads/${encodeURIComponent(f)}`),k.push({key:E(`a`),kind:`assistant`,turn:{id:a.runId,request:e,startedAt:i.value,receivedAt:i.value,finished:!1,eventCount:0},live:{eventsUrl:n.eventsUrl,stopUrl:n.stopUrl},ended:!1});return}if(n.ok&&a.offer&&typeof a.offer.line==`string`){t.pending=!1;let e=Ae({line:a.offer.line,...a.offer});N.value=e.command,P.value=e.hint;return}if(n.ok&&typeof a.reply==`string`){t.pending=!1;let e=ke(a.reply);e.kind===`inline`&&k.push({key:E(`i`),kind:`inline`,text:e.text});return}throw Error(a.error??`HTTP ${n.status}`)}catch(e){t.pending=!1,t.failed=`not sent: ${e instanceof Error?e.message:`error`}`}finally{I.value=!1}}function R(){let e=j.value;e&&fetch(`${e}${e.includes(`?`)?`&`:`?`}mode=soft`,{method:`POST`,credentials:`same-origin`})}function Ie(e,t,n){let r=k.filter(e=>e.kind===`person`),i=ge(r.map(e=>({text:e.text,folded:e.folded!==void 0,ref:e})),t);if(!i)return;let a=e.turn.receivedAt??e.turn.startedAt;i.ref.folded=n===void 0?``:`at ${me(Math.max(0,n-a),`clock`)}`}function Le(e){e.ended=!0,j.value=null}let Re=Me({width:S.readPref(F.width),collapsed:S.readPref(F.collapsed)}),z=D(Re.width),B=D(Re.collapsed),V=D(!1),H=D(S.mediaMatches(X)),ze=S.onMediaChange(X,e=>{H.value=e}),U=D(null),W=D(null),Be=g(()=>H.value?B.value?`Show recent threads`:`Hide recent threads`:`Recent threads`);function Ve(){if(H.value=S.mediaMatches(X),H.value){B.value=!B.value,S.writePref(F.collapsed,B.value?`1`:`0`);return}V.value=!0}function G(e,t){z.value=Ce(e),t&&S.writePref(F.width,String(z.value))}let K=null;function q(e){K&&G(K.startWidth+(e.clientX-K.startX),!1)}function Ue(){window.removeEventListener(`pointermove`,q),K&&(K=null,S.writePref(F.width,String(z.value)))}function We(e){e.button===0&&(e.preventDefault(),K={startX:e.clientX,startWidth:z.value},e.currentTarget?.setPointerCapture?.(e.pointerId),window.addEventListener(`pointermove`,q),window.addEventListener(`pointerup`,Ue,{once:!0}))}function Ge(e){if(e.key===`ArrowRight`)G(z.value+M.step,!0);else if(e.key===`ArrowLeft`)G(z.value-M.step,!0);else if(e.key===`Home`)G(M.min,!0);else if(e.key===`End`)G(M.max,!0);else return;e.preventDefault()}re(()=>{window.removeEventListener(`pointermove`,q),window.removeEventListener(`pointerup`,Ue),ze()});function Ke(e){let t=ve(e);if(t){if(e.preventDefault(),t===`newThread`){S.navigate(`/threads`);return}if(U.value){U.value.focusFilter();return}if(B.value&&S.mediaMatches(X)){B.value=!1,S.writePref(F.collapsed,`0`),b().then(()=>U.value?.focusFilter());return}V.value=!0,b().then(()=>W.value?.focusFilter())}}let J=D(null),Y=D(!1);function Xe(){return document.body.scrollHeight-(window.innerHeight+window.scrollY)}m(()=>k.length,()=>{let e=je(Xe());b().then(()=>{e?J.value?.scrollIntoView?.({block:`end`}):Y.value=!0})});function Ze(){je(Xe())&&(Y.value=!1)}function Qe(){J.value?.scrollIntoView?.({block:`end`,behavior:`smooth`}),Y.value=!1}oe(()=>{window.addEventListener(`scroll`,Ze,{passive:!0}),window.addEventListener(`keydown`,Ke),r&&ft()}),ce(()=>{window.removeEventListener(`scroll`,Ze),window.removeEventListener(`keydown`,Ke),Q?.close()});let Z=h(Je()),lt=g(()=>$e(r?.conversations??[],Z,r?.lane??``)),ut=g(()=>{let e=A.value?.turn.id;return Z.runs.size+(e&&!Z.runs.has(e)?1:0)}),dt=fe(),Q=null;function ft(){Q=dt(`/runs?stream=1&mine=1`);let e=!1;Q.onopen=()=>{e&&Z.runs.clear(),e=!0,Z.connected=!0},Q.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}Ye(Z,t)}}let pt=g(()=>{let e=k.find(e=>e.kind===`person`);return e?Ee(e.text):`Switchboard`});m([pt,ut],([e,t])=>{S.setTitle(t>0?`(${t}) ${e}`:e),S.setFavicon(t>0?ue:de)},{immediate:!0});let mt=g(()=>new Date(i.value).getHours()),ht=g(()=>k.length===0),$=r?.elsewhere,gt=$?$.surface===`web`?`This thread is another person's conversation. You can read it here.`:`This thread lives in ${he[$.surface]??$.surface}.`:``;return(e,t)=>{let m=ae,te=le;return v(),O(n,{title:`Threads`,nav:`home`},{leading:s(()=>[u(m,{class:`rail-toggle -ml-1`,size:`xs`,color:`neutral`,variant:`ghost`,icon:H.value&&!B.value?`i-lucide-panel-left-close`:`i-lucide-panel-left`,"aria-label":Be.value,"aria-expanded":H.value?!B.value:void 0,onClick:Ve},null,8,[`icon`,`aria-label`,`aria-expanded`])]),default:s(()=>[y(r)?(v(),w(`div`,{key:1,class:c([`home gap-8 md:grid`,B.value?`md:grid-cols-[minmax(0,1fr)]`:`md:grid-cols-[var(--rail-w)_minmax(0,1fr)]`]),style:d({"--rail-w":`${z.value}px`}),"data-rail":B.value?`hidden`:`shown`},[B.value?_(``,!0):(v(),w(`aside`,nt,[u(He,{ref_key:`rail`,ref:U,class:`sticky top-20`,rows:lt.value,current:y(f),now:y(i),retention:y(p)},null,8,[`rows`,`current`,`now`,`retention`]),C(`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":y(M).min,"aria-valuemax":y(M).max,"aria-valuenow":z.value,tabindex:`0`,"data-testid":`rail-handle`,onPointerdown:We,onKeydown:Ge,onDblclick:t[0]||=e=>G(y(M).default,!0)},[...t[5]||=[C(`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,rt)])),u(te,{open:V.value,"onUpdate:open":t[1]||=e=>V.value=e,side:`left`,title:`Recent threads`,ui:{content:`max-w-xs`}},{body:s(()=>[u(He,{ref_key:`sheetRail`,ref:W,rows:lt.value,current:y(f),now:y(i),retention:y(p)},null,8,[`rows`,`current`,`now`,`retention`])]),_:1},8,[`open`]),C(`section`,it,[ht.value?(v(),O(qe,{key:0,class:`mb-auto mt-[clamp(1.5rem,14vh,9rem)]`,name:y(r).viewer.name,hour:mt.value,suggestions:y(r).suggestions,onPick:Fe},{default:s(()=>[u(_e,{modelValue:N.value,"onUpdate:modelValue":t[2]||=e=>N.value=e,mode:Ne.value,hint:P.value,commands:y(r).commands,autofocus:``,"sweep-on-mount":``,onSubmit:L,onStop:R},null,8,[`modelValue`,`mode`,`hint`,`commands`])]),_:1},8,[`name`,`hour`,`suggestions`])):(v(),O(ee,{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(()=>[(v(!0),w(x,null,T(k,e=>(v(),w(`li`,{key:e.key},[e.kind===`person`?(v(),O(Se,{key:0,text:e.text,at:e.at,now:y(i),pending:e.pending,folded:e.folded,failed:e.failed},null,8,[`text`,`at`,`now`,`pending`,`folded`,`failed`])):e.kind===`assistant`?(v(),O(De,{key:1,turn:e.turn,live:e.live,now:y(i),onInput:(t,n)=>Ie(e,t,n),onEnded:t=>Le(e),onStop:t[3]||=e=>j.value=e},null,8,[`turn`,`live`,`now`,`onInput`,`onEnded`])):e.kind===`silent`?(v(),O(Oe,{key:2,reason:e.reason,"decided-at":e.at,now:y(i)},null,8,[`reason`,`decided-at`,`now`])):e.kind===`parent`?(v(),O(we,{key:3,turn:e.turn,now:y(i)},null,8,[`turn`,`now`])):(v(),w(`div`,at,[u(Pe,{text:e.text},null,8,[`text`])]))]))),128))]),_:1})),C(`div`,{ref_key:`end`,ref:J,class:`end`,"aria-hidden":`true`},null,512),!ht.value&&y($)?(v(),w(`p`,ot,[a(o(y(gt))+` `,1),y($).url?(v(),w(`a`,{key:0,href:y($).url,target:`_blank`,rel:`noopener`,class:`text-highlighted`},`Reply there ↗`,8,st)):y($).surface===`web`?_(``,!0):(v(),w(x,{key:1},[a(`Reply there.`)],64))])):ht.value?_(``,!0):(v(),w(`div`,ct,[u(l,{name:`sb-rise`},{default:s(()=>[Y.value?(v(),w(`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:Qe},` ↓ new `)):_(``,!0)]),_:1}),u(_e,{modelValue:N.value,"onUpdate:modelValue":t[4]||=e=>N.value=e,mode:Ne.value,hint:P.value,commands:y(r).commands,autofocus:``,onSubmit:L,onStop:R},null,8,[`modelValue`,`mode`,`hint`,`commands`])]))])],14,tt)):(v(),w(`div`,et,`This page needs its seed.`))]),_:1})}}});export{Z as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./AppShell-CCPwPqvc.js";import{An as t,Cr as n,Dn as r,Fi as i,Jr as a,Mi as ee,On as o,_n as s,bn as c,hr as l,ki as u,o as d,sn as f,vn as p,xn as m,xr as h,yn as g}from"./browser-BWnzWwaT.js";import{_ as te,a as ne,c as re,d as ie,f as ae,h as _,l as oe,n as se,o as v,s as ce,u as le,v as y,y as b}from"./main-9ynpo780.js";import{t as x}from"./StatusDot-XxLkmRaK.js";var ue={class:`mt-4 first:mt-0`},de={class:`w-full border-collapse font-mono text-[0.8125rem]`},fe={class:`border-t border-muted`},pe={class:`px-2 py-1 align-top`},me={class:`ml-1.5 font-medium`},he={class:`border-t border-muted`},S={class:`break-all px-2 py-1 align-top`},C={key:0},w={key:1,class:`text-dimmed`},T={class:`border-t border-muted`},E={class:`image-report px-2 py-1 align-top`},D={key:0,class:`ml-2 text-xs text-muted`},O={class:`border-t border-muted`},k={class:`break-all px-2 py-1 align-top`},A={key:0},j={key:1,class:`text-dimmed`},M={class:`border-t border-muted`},N={class:`break-all px-2 py-1 align-top`},P={key:0},F={key:1,class:`text-dimmed`},I={class:`border-t border-muted`},L={class:`break-all px-2 py-1 align-top`},R={key:0},ge={key:1,class:`text-dimmed`},_e={class:`border-t border-muted`},ve={class:`break-all px-2 py-1 align-top`},ye={key:1,class:`text-dimmed`},be={class:`mt-4`},xe={class:`w-full border-collapse font-mono text-[0.8125rem]`},Se={class:`border-t border-muted`},Ce={class:`break-all px-2 py-1 align-top`},we=[`href`],Te={key:1},Ee={class:`border-t border-muted`},De={class:`break-all px-2 py-1 align-top`},Oe={class:`border-t border-muted`},ke={class:`break-all px-2 py-1 align-top`},Ae=[`href`],je={key:1},Me={key:2,class:`text-dimmed`},Ne={class:`border-t border-muted`},Pe={class:`break-all px-2 py-1 align-top`},Fe={key:0},Ie={key:1,class:`text-dimmed`},Le={class:`border-t border-muted`},Re={class:`break-all px-2 py-1 align-top`},ze={key:0},Be={key:1,class:`text-dimmed`},Ve={class:`border-t border-muted`},He={class:`break-all px-2 py-1 align-top`},Ue={key:0},We={key:1,class:`text-dimmed`},Ge={class:`mt-4`},Ke={class:`w-full border-collapse font-mono text-[0.8125rem]`},qe={class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},Je={class:`break-all px-2 py-1 align-top`},Ye={class:`w-full border-collapse font-mono text-[0.8125rem]`},Xe={class:`w-32 break-all px-2 py-1 align-top text-muted sm:w-96 sm:break-words`},Ze={class:`px-2 py-1 align-top`},Qe={key:1,class:`text-xs text-muted`},$e={class:`mt-4`},et={key:0,class:`w-full border-collapse font-mono text-[0.8125rem]`},tt={class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},nt={class:`break-all px-2 py-1 align-top`},rt={key:0},it={key:1,class:`text-dimmed`},at={key:1,class:`text-xs text-muted`},z={class:`mt-4`},ot={class:`mb-1 text-xs text-muted`},st={class:`overflow-x-auto`},ct={class:`w-full border-collapse font-mono text-[0.8125rem]`},lt={class:`break-all px-2 py-1 align-top`},ut={key:0,class:`text-xs text-muted`},dt={class:`break-all px-2 py-1 align-top`},ft=[`href`],pt={key:1},mt={key:2,class:`text-dimmed`},ht={class:`break-all px-2 py-1 align-top`},gt={key:0},_t={key:1,class:`text-dimmed`},vt={key:2},yt={key:3,class:`text-dimmed`},bt={class:`break-all px-2 py-1 align-top`},xt={key:0},St={key:1,class:`text-dimmed`},Ct={key:2},wt={key:3,class:`text-dimmed`},Tt={key:1,class:`text-xs text-muted`},Et={class:`mt-4`},Dt={class:`w-full border-collapse font-mono text-[0.8125rem]`},Ot={class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},kt={class:`px-2 py-1 align-top`},At={class:`mt-4`},jt={key:0,class:`w-full border-collapse font-mono text-[0.8125rem]`},Mt={class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},Nt={class:`break-all px-2 py-1 align-top`},Pt={class:`text-xs text-muted`},Ft={key:1,class:`text-xs text-muted`},It={class:`mt-4`},Lt={class:`w-full border-collapse font-mono text-[0.8125rem]`},Rt={class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},zt={class:`break-all px-2 py-1 align-top`},Bt={key:0},Vt={key:1,class:`text-dimmed`},Ht={class:`mt-4 text-xs text-muted`},Ut={class:`rounded bg-elevated px-1 py-0.5`},Wt={class:`rounded bg-elevated px-1 py-0.5`},Gt={class:`rounded bg-elevated px-1 py-0.5`},B=t({__name:`ResidentDetailPage`,setup(t){let B=d(`resident`),V=s(()=>B?.record??{}),H=s(()=>oe(V.value)),U=s(()=>re(V.value)),W=s(()=>le(V.value)||(B?.slug??``)),G=s(()=>_(H.value.sha)),K=s(()=>se.test(W.value)?`https://github.com/${W.value}`:void 0),q=s(()=>K.value&&/^[0-9a-f]{7,40}$/.test(G.value)?`${K.value}/commit/${G.value}`:void 0),J=s(()=>{let e=H.value.snapshot;return e&&typeof e==`object`?v(e):void 0}),Kt=s(()=>v(H.value.schedules)),Y=s(()=>{let e=v(V.value.commands),t=v(V.value.effects);return Object.keys(e).sort().map(n=>({name:n,command:_(e[n]),effect:_(t[n])||`readonly`}))}),X=s(()=>ae(V.value).map(e=>({...e,threadKey:e.threadKey||`?`,ref:e.ref||`?`,sha:e.sha?e.sha.slice(0,8):``,commitHref:K.value&&/^[0-9a-f]{7,40}$/.test(e.sha)?`${K.value}/commit/${e.sha}`:void 0}))),Z=s(()=>X.value.filter(e=>!e.evicted).length),Q=s(()=>{let e=H.value.lastRestore;return e?JSON.stringify(e):``}),$=s(()=>ce(V.value)),qt=s(()=>typeof V.value.diskBudgetMb==`number`?V.value.diskBudgetMb:void 0),Jt=s(()=>{let e=$.value;if(!e)return[];let t=ne(e,qt.value),n=n=>{let r=t.room[n];return r===null?b(e.parts,n)===null?`? (checkout not measured)`:`?`:`${r} more (${y(b(e.parts,n))} each)`};return[[`used / total`,te(e)],[`free`,`${y(t.freeKiB)}${t.capped?` under the ${y(t.capacityKiB)} diskBudgetMb cap`:``}`],[`reserve`,`${y(t.reserve.totalKiB)} (snapshot staging ${y(t.reserve.stagingKiB)} + floor ${y(t.reserve.floorKiB)})`],[`headroom`,`${y(t.headroomKiB)} — room for ${n(`hardlink`)} hardlinked trees, ${n(`reconcile`)} lockfile-diverged (reconciling)`],[`measured`,e.at||`—`]]}),Yt=s(()=>{let e=$.value;if(!e)return[];let t=[[`mirror`,y(e.parts.mirror)],[`checkout deps (node_modules)`,y(e.parts.deps)],[`checkout (history + tree + build)`,y(e.parts.checkout)]];for(let[n,r]of Object.entries(e.parts.threads).sort((e,t)=>t[1]-e[1]))t.push([`thread ${n}`,y(r)]);for(let[n,r]of Object.entries(e.parts.homes).sort((e,t)=>t[1]-e[1]))r>=1024&&t.push([`home ${n}`,y(r)]);return t.push([`other (image, /tmp, …)`,y(e.parts.other)]),t});return(t,s)=>{let d=n(`RouterLink`);return l(),g(e,{title:W.value||`Resident`,nav:`residents`},{leading:a(()=>[o(d,{class:`back text-sm text-muted no-underline hover:text-primary`,to:`/residents`},{default:a(()=>[...s[0]||=[r(`← All residents`,-1)]]),_:1})]),default:a(()=>[p(`section`,ue,[s[9]||=p(`h2`,{class:`mb-1.5 font-mono text-xs font-medium uppercase tracking-wider text-muted`},`Lifecycle`,-1),p(`table`,de,[p(`tbody`,null,[p(`tr`,fe,[s[1]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`state`,-1),p(`td`,pe,[o(x,{tone:u(ie)(H.value.state),label:H.value.state},null,8,[`tone`,`label`]),p(`span`,me,i(H.value.state),1)])]),p(`tr`,he,[s[2]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`reason`,-1),p(`td`,S,[H.value.reason?(l(),m(`span`,C,i(H.value.reason),1)):(l(),m(`span`,w,`—`))])]),p(`tr`,T,[s[3]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`container image`,-1),p(`td`,E,[p(`span`,{class:ee(U.value===`pending`?`font-medium text-warn`:``)},i(U.value),3),U.value===`pending`?(l(),m(`span`,D,`waiting for the deployed image report`)):c(``,!0)])]),p(`tr`,O,[s[4]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`last refresh error`,-1),p(`td`,k,[u(_)(H.value.lastRefreshError)?(l(),m(`span`,A,i(u(_)(H.value.lastRefreshError)),1)):(l(),m(`span`,j,`—`))])]),p(`tr`,M,[s[5]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`last restore`,-1),p(`td`,N,[Q.value?(l(),m(`span`,P,i(Q.value),1)):(l(),m(`span`,F,`—`))])]),p(`tr`,I,[s[6]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`state updated`,-1),p(`td`,L,[u(_)(H.value.updatedAt)?(l(),m(`span`,R,i(u(_)(H.value.updatedAt)),1)):(l(),m(`span`,ge,`—`))])]),p(`tr`,_e,[s[8]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`idle since`,-1),p(`td`,ve,[u(_)(H.value.idleSince)?(l(),m(f,{key:0},[r(i(u(_)(H.value.idleSince))+` `,1),s[7]||=p(`span`,{class:`text-xs text-muted`},`(refresh parked; container may sleep)`,-1)],64)):(l(),m(`span`,ye,`awake`))])])])])]),p(`section`,be,[s[16]||=p(`h2`,{class:`mb-1.5 font-mono text-xs font-medium uppercase tracking-wider text-muted`},`Pinned facts`,-1),p(`table`,xe,[p(`tbody`,null,[p(`tr`,Se,[s[10]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`repository`,-1),p(`td`,Ce,[K.value?(l(),m(`a`,{key:0,class:`text-primary`,href:K.value},i(K.value),9,we)):(l(),m(`span`,Te,i(u(_)(V.value.resource)||`—`),1))])]),p(`tr`,Ee,[s[11]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`default ref`,-1),p(`td`,De,i(u(_)(H.value.defaultRef)||u(_)(V.value.defaultRef)||`—`),1)]),p(`tr`,Oe,[s[12]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`pinned sha`,-1),p(`td`,ke,[q.value?(l(),m(`a`,{key:0,class:`text-primary`,href:q.value},i(G.value),9,Ae)):G.value?(l(),m(`span`,je,i(G.value),1)):(l(),m(`span`,Me,`—`))])]),p(`tr`,Ne,[s[13]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`lockfile hash`,-1),p(`td`,Pe,[u(_)(H.value.lockfileHash)?(l(),m(`span`,Fe,i(u(_)(H.value.lockfileHash)),1)):(l(),m(`span`,Ie,`—`))])]),p(`tr`,Le,[s[14]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`provisioned`,-1),p(`td`,Re,[u(_)(H.value.provisionedAt)?(l(),m(`span`,ze,i(u(_)(H.value.provisionedAt)),1)):(l(),m(`span`,Be,`—`))])]),p(`tr`,Ve,[s[15]||=p(`td`,{class:`w-32 px-2 py-1 align-top text-muted sm:w-48 sm:whitespace-nowrap`},`last refresh`,-1),p(`td`,He,[u(_)(H.value.lastRefreshAt)?(l(),m(`span`,Ue,i(u(_)(H.value.lastRefreshAt)),1)):(l(),m(`span`,We,`—`))])])])])]),p(`section`,Ge,[s[18]||=p(`h2`,{class:`mb-1.5 font-mono text-xs font-medium uppercase tracking-wider text-muted`},`Disk`,-1),$.value?(l(),m(f,{key:0},[p(`table`,Ke,[p(`tbody`,null,[(l(!0),m(f,null,h(Jt.value,([e,t])=>(l(),m(`tr`,{key:e,class:`border-t border-muted`},[p(`td`,qe,i(e),1),p(`td`,Je,i(t),1)]))),128))])]),s[17]||=p(`p`,{class:`mb-1 mt-2 text-xs text-muted`},` components (one du, hardlinks counted once — a thread tree shows only what it does not share with the checkout) `,-1),p(`table`,Ye,[p(`tbody`,null,[(l(!0),m(f,null,h(Yt.value,([e,t])=>(l(),m(`tr`,{key:e,class:`border-t border-muted`},[p(`td`,Xe,i(e),1),p(`td`,Ze,i(t),1)]))),128))])])],64)):(l(),m(`p`,Qe,` not measured yet — the first refresh cycle or attach of this container measures it `))]),p(`section`,$e,[s[19]||=p(`h2`,{class:`mb-1.5 font-mono text-xs font-medium uppercase tracking-wider text-muted`},`Snapshot stamp`,-1),J.value?(l(),m(`table`,et,[p(`tbody`,null,[(l(),m(f,null,h([`ref`,`sha`,`lockfileHash`,`createdAt`,`mirrorBackupId`,`checkoutBackupId`],e=>p(`tr`,{key:e,class:`border-t border-muted`},[p(`td`,tt,i(e),1),p(`td`,nt,[u(_)(J.value[e])?(l(),m(`span`,rt,i(u(_)(J.value[e])),1)):(l(),m(`span`,it,`—`))])])),64))])])):(l(),m(`p`,at,`no snapshot recorded`))]),p(`section`,z,[s[23]||=p(`h2`,{class:`mb-1.5 font-mono text-xs font-medium uppercase tracking-wider text-muted`},`Thread worktrees`,-1),X.value.length>0?(l(),m(f,{key:0},[p(`p`,ot,i(Z.value)+` live · `+i(X.value.length-Z.value)+` evicted`,1),p(`div`,st,[p(`table`,ct,[p(`tbody`,null,[s[22]||=p(`tr`,{class:`text-xs text-muted`},[p(`td`,{class:`px-2 py-1`},`thread`),p(`td`,{class:`px-2 py-1`},`ref · sha`),p(`td`,{class:`px-2 py-1`},`user · deps`),p(`td`,{class:`px-2 py-1`},`bound · last attach`)],-1),(l(!0),m(f,null,h(X.value,e=>(l(),m(`tr`,{key:e.threadKey,class:`border-t border-muted`},[p(`td`,lt,[e.evicted?(l(),m(`span`,ut,[r(`evicted `+i(e.evictedAt||`—`),1),e.evictedWhy?(l(),m(f,{key:0},[r(` · `+i(e.evictedWhy),1)],64)):c(``,!0)])):(l(),g(x,{key:1,tone:`green`,label:`live`,tip:`live`})),r(` `+i(e.threadKey),1)]),p(`td`,dt,[r(i(e.ref)+` · `,1),e.commitHref?(l(),m(`a`,{key:0,class:`text-primary`,href:e.commitHref},i(e.sha),9,ft)):e.sha?(l(),m(`span`,pt,i(e.sha),1)):(l(),m(`span`,mt,`—`))]),p(`td`,ht,[e.user?(l(),m(`span`,gt,i(e.user),1)):(l(),m(`span`,_t,`—`)),s[20]||=r(` · `,-1),e.deps?(l(),m(`span`,vt,i(e.deps),1)):(l(),m(`span`,yt,`—`))]),p(`td`,bt,[e.boundAt?(l(),m(`span`,xt,i(e.boundAt),1)):(l(),m(`span`,St,`—`)),s[21]||=r(` · `,-1),e.lastAttachAt?(l(),m(`span`,Ct,i(e.lastAttachAt),1)):(l(),m(`span`,wt,`—`))])]))),128))])])])],64)):(l(),m(`p`,Tt,`no thread worktrees`))]),p(`section`,Et,[s[24]||=p(`h2`,{class:`mb-1.5 font-mono text-xs font-medium uppercase tracking-wider text-muted`},`Pending schedules`,-1),p(`table`,Dt,[p(`tbody`,null,[(l(),m(f,null,h([[`refresh`,`refresh`],[`provision run`,`provisionRun`],[`provision deadline`,`provisionDeadline`]],([e,t])=>p(`tr`,{key:t,class:`border-t border-muted`},[p(`td`,Ot,i(e),1),p(`td`,kt,i(u(_)(Kt.value[t]??0)||`0`),1)])),64))])])]),p(`section`,At,[s[26]||=p(`h2`,{class:`mb-1.5 font-mono text-xs font-medium uppercase tracking-wider text-muted`},`Command table`,-1),Y.value.length>0?(l(),m(`table`,jt,[p(`tbody`,null,[(l(!0),m(f,null,h(Y.value,e=>(l(),m(`tr`,{key:e.name,class:`border-t border-muted`},[p(`td`,Mt,i(e.name),1),p(`td`,Nt,[p(`code`,null,i(e.command),1),s[25]||=r(),p(`span`,Pt,i(e.effect),1)])]))),128))])])):(l(),m(`p`,Ft,`no command table`))]),p(`section`,It,[s[27]||=p(`h2`,{class:`mb-1.5 font-mono text-xs font-medium uppercase tracking-wider text-muted`},`Registry settings`,-1),p(`table`,Lt,[p(`tbody`,null,[(l(!0),m(f,null,h([[`onboarded`,u(_)(V.value.onboardedAt)],[`record updated`,u(_)(V.value.updatedAt)],[`provisioning timeout (ms)`,u(_)(V.value.provisioningTimeoutMs)],[`disk budget (MB)`,u(_)(V.value.diskBudgetMb)],[`worktree TTL (days)`,u(_)(V.value.worktreeTtlDays??7)]],([e,t])=>(l(),m(`tr`,{key:e,class:`border-t border-muted`},[p(`td`,Rt,i(e),1),p(`td`,zt,[t?(l(),m(`span`,Bt,i(t),1)):(l(),m(`span`,Vt,`—`))])]))),128))])])]),p(`p`,Ht,[s[28]||=r(` Manage from chat: `,-1),p(`code`,Ut,`repo rebuild `+i(W.value),1),s[29]||=r(` · `,-1),p(`code`,Wt,`repo reconfigure `+i(W.value)+` …`,1),s[30]||=r(` · `,-1),p(`code`,Gt,`repo offboard `+i(W.value)+` --dry-run`,1)])]),_:1},8,[`title`])}}});export{B as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./AppShell-CCPwPqvc.js";import{An as t,Cr as n,Dn as r,Fi as i,Jr as a,Mi as o,On as s,Ur as c,_i as l,_n as u,bn as d,hr as f,ki as p,lr as m,o as h,pr as g,sn as _,t as v,tn as y,vn as b,xn as x,xr as ee,yi as S,yn as C}from"./browser-BWnzWwaT.js";import{t as w}from"./Tooltip-qB73RL4b.js";import{_ as T,a as E,b as te,c as D,d as O,f as k,g as A,h as j,i as M,l as N,m as P,n as F,o as I,p as L,r as R,s as z,u as ne,v as B}from"./main-9ynpo780.js";import{t as re}from"./eventSource-Ds6_gjPD.js";import{t as V}from"./wallClock-DaewxNMY.js";import{n as H,r as ie}from"./indexFormat-B-pd4r7Y.js";import{A as ae,C as U,D as oe,S as se,a as ce,c as le,i as ue,l as de,t as fe,x as pe}from"./indexRow-BGjjLnN5.js";import"./format-BldUwl_R.js";import{t as W}from"./StatusDot-XxLkmRaK.js";var me=[`data-slug`,`data-running`],he=[`open`],ge={class:`row flex cursor-pointer list-none flex-wrap items-baseline gap-x-2.5 gap-y-1 rounded-md px-2 py-2 hover:bg-elevated [&::-webkit-details-marker]:hidden`},_e={class:`self-center`},ve={class:`font-mono text-[0.9375rem] font-medium text-highlighted`},ye={class:`text-sm text-toned`},be=[`title`],xe={key:0,class:`running shrink-0 rounded border border-ok/25 bg-ok/8 px-1.5 font-mono text-[0.68rem] font-medium tabular-nums text-ok`},Se=[`title`],Ce={key:2,class:`basis-full pl-[1.9rem] text-xs text-warn`},we={class:`fold pb-3 pl-[1.9rem] pr-2 pt-0.5`},Te={key:0,class:`m-0 list-none divide-y divide-(--ui-border-muted) p-0`},Ee=[`data-run-id`,`data-thread`],De={class:`pt-[0.3rem]`},Oe={class:`what min-w-0`},ke={class:`flex min-w-0 items-baseline gap-2`},Ae=[`title`],je={key:0,class:`who block truncate text-xs text-dimmed`},Me=[`href`],Ne={key:1,class:`who block text-xs text-dimmed`},Pe={class:`min-w-0 font-mono text-xs max-sm:col-span-2 max-sm:col-start-2 max-sm:row-start-2`},Fe=[`title`],Ie=[`href`],Le={key:1},Re={key:1,class:`font-sans text-dimmed`},ze={key:0,class:`facts-tree block truncate text-dimmed`},Be={class:`user`},Ve={class:`deps`},He=[`title`],Ue={class:`flex items-baseline gap-3 justify-self-end max-sm:col-start-3 max-sm:row-start-1`},We=[`title`],Ge={key:1,class:`py-1 text-xs text-dimmed`},Ke=[`data-idle`],qe={key:1},G=t({__name:`ResidentRow`,props:{record:{},runs:{},now:{},open:{type:Boolean}},setup(e){let t=e,l=S(t.open===!0);c(()=>t.open,e=>{e&&(l.value=!0)});function m(e){l.value=e.target.open}let h=u(()=>ne(t.record)),g=u(()=>h.value||j(t.record.resource)||`?`),v=u(()=>N(t.record)),w=u(()=>D(t.record)),te=u(()=>v.value.state===`warm`&&w.value===`pending`?`amber`:O(v.value.state)),P=u(()=>F.test(h.value)?`/residents/${h.value}`:null),I=u(()=>F.test(h.value)?`https://github.com/${h.value}`:void 0),L=e=>I.value&&/^[0-9a-f]{7,40}$/.test(e)?`${I.value}/commit/${e}`:void 0,R=u(()=>j(t.record.defaultRef)||`?`),re=u(()=>j(v.value.sha).slice(0,8)),V=u(()=>j(v.value.lastRefreshAt)),G=e=>{let n=e?Date.parse(e):NaN;return Number.isFinite(n)?H(n,t.now):e||`—`},K=u(()=>V.value?G(V.value):``),q=u(()=>z(t.record)),J=u(()=>q.value?T(q.value):``),Y=u(()=>{let e=q.value;if(!e)return null;let n=typeof t.record.diskBudgetMb==`number`?t.record.diskBudgetMb:void 0;return E(e,n)}),X=u(()=>[`ref ${R.value}`,re.value,K.value?`refreshed ${K.value}`:``,J.value?`disk ${J.value}`:``].filter(Boolean).join(` · `)),Je=u(()=>[V.value?`refreshed ${V.value}`:``,q.value?.at?`disk measured ${q.value.at}`:``].filter(Boolean).join(` · `)),Z=u(()=>{let e=q.value,t=Y.value;if(!e||!t)return``;let n=t.room.hardlink===null?`room not projected (checkout not measured)`:`room for ${t.room.hardlink} more ${t.room.hardlink===1?`tree`:`trees`}`;return[`${B(t.freeKiB)} free${t.capped?` under the ${B(t.capacityKiB)} cap`:``}`,n,`measured ${G(e.at)}`].join(` · `)}),Q=u(()=>k(t.record)),$=u(()=>{let e=t.runs.map(e=>{let n=ie(e.label||U(e.id)),r=M(Q.value,e.threadKey),i=ae(e);return{key:`run:${e.id}`,run:e,agent:n.agent,text:n.snippet??n.scope,who:i.identity,surface:ue[i.kind]??i.kind,threadUrl:se(e),href:pe(e),elapsed:de(e,t.now),binding:r,treeKiB:r?A(q.value,r.threadKey):null}}),n=new Set(t.runs.map(e=>e.threadKey));for(let t of Q.value)t.evicted||n.has(t.threadKey)||e.push({key:`idle:${t.threadKey}`,text:`idle`,who:``,surface:``,threadUrl:``,href:``,elapsed:``,binding:t,treeKiB:A(q.value,t.threadKey)});return e}),Ye=u(()=>$.value.filter(e=>!e.run).length);return(t,c)=>{let u=n(`RouterLink`);return f(),x(`li`,{class:`resident border-b border-muted first:border-t`,"data-slug":h.value,"data-running":e.runs.length},[b(`details`,{class:`group/fold`,open:l.value,onToggle:m},[b(`summary`,ge,[c[2]||=b(`span`,{class:`chev w-3 select-none self-center text-xs text-dimmed transition-transform group-open/fold:rotate-90 motion-reduce:transition-none`,"aria-hidden":`true`},`❯`,-1),b(`span`,_e,[s(W,{tone:te.value,label:v.value.state,tip:v.value.state},null,8,[`tone`,`label`,`tip`])]),b(`span`,ve,i(g.value),1),b(`span`,ye,i(v.value.state),1),b(`span`,{class:o([`image-report text-xs`,w.value===`pending`?`font-medium text-warn`:`text-muted`]),title:w.value===`pending`?`This container has not reported the deployed image yet`:void 0},`image `+i(w.value),11,be),e.runs.length>0?(f(),x(`span`,xe,i(e.runs.length)+` running`,1)):d(``,!0),b(`span`,{class:`facts font-mono text-xs text-muted max-sm:basis-full max-sm:pl-[1.9rem] sm:ml-2`,title:Je.value||void 0},i(X.value),9,Se),P.value?(f(),C(u,{key:1,class:`detail ml-auto shrink-0 text-xs text-muted no-underline hover:text-highlighted hover:underline`,to:P.value,onClick:c[0]||=y(()=>{},[`stop`])},{default:a(()=>[...c[1]||=[r(`detail ↗`,-1)]]),_:1},8,[`to`])):d(``,!0),v.value.reason?(f(),x(`span`,Ce,i(v.value.reason),1)):d(``,!0)]),b(`div`,we,[$.value.length>0?(f(),x(`ul`,Te,[(f(!0),x(_,null,ee($.value,t=>(f(),x(`li`,{key:t.key,class:o([`grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-x-3 gap-y-1 py-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(14rem,22rem)_auto]`,t.run?`run`:`idle`]),"data-run-id":t.run?.id,"data-thread":t.run?void 0:t.binding?.threadKey},[b(`span`,De,[t.run?(f(),C(W,{key:0,tone:`green`,label:p(oe)(t.run),tip:p(le)(t.run),pulse:``},null,8,[`label`,`tip`])):(f(),C(W,{key:1,tone:`grey`,label:`idle`,tip:`no run is using this tree`}))]),b(`span`,Oe,[b(`span`,ke,[t.agent?(f(),x(`span`,{key:0,class:o([`agent shrink-0 rounded border px-1.5 font-mono text-[0.65rem] font-medium uppercase tracking-wider`,p(fe)[p(ce)(t.agent)]])},i(t.agent),3)):d(``,!0),b(`span`,{class:o([`text min-w-0 truncate text-[0.8125rem]`,t.run?`text-highlighted`:`text-dimmed`]),title:t.run?t.text:void 0},i(t.text),11,Ae)]),t.run?(f(),x(`span`,je,[t.who?(f(),x(_,{key:0},[r(`by `+i(t.who),1)],64)):d(``,!0),t.who&&(t.threadUrl||t.surface)?(f(),x(_,{key:1},[r(i(` · `))],64)):d(``,!0),t.threadUrl?(f(),x(`a`,{key:2,class:`text-muted no-underline hover:text-highlighted hover:underline`,href:t.threadUrl,target:`_blank`,rel:`noopener noreferrer`},i(t.surface)+` thread ↗`,9,Me)):t.surface?(f(),x(_,{key:3},[r(`via `+i(t.surface),1)],64)):d(``,!0)])):t.binding?(f(),x(`span`,Ne,`last used `+i(G(t.binding.lastAttachAt)),1)):d(``,!0)]),b(`span`,Pe,[b(`span`,{class:`tree block truncate text-toned`,title:t.binding&&t.binding.ref||void 0},[t.binding?(f(),x(_,{key:0},[r(i(t.binding.ref||`?`),1),t.binding.sha?(f(),x(_,{key:0},[c[3]||=r(i(` `),-1),c[4]||=b(`span`,{class:`text-dimmed`},`@`,-1),c[5]||=r(i(` `)+` `,-1),L(t.binding.sha)?(f(),x(`a`,{key:0,class:`text-highlighted no-underline hover:underline`,href:L(t.binding.sha)},i(t.binding.sha.slice(0,8)),9,Ie)):(f(),x(`span`,Le,i(t.binding.sha.slice(0,8)),1))],64)):d(``,!0)],64)):(f(),x(`span`,Re,`no worktree bound yet`))],8,Fe),t.binding?(f(),x(`span`,ze,[b(`span`,Be,i(t.binding.user||`—`),1),c[6]||=r(` `+i(` · `),-1),b(`span`,Ve,i(t.binding.deps||`—`),1),c[7]||=r(` `+i(` · `),-1),b(`span`,{class:o([`size`,t.treeKiB===null?``:`text-muted`]),title:t.treeKiB===null?`size not measured yet`:`on disk`},i(t.treeKiB===null?`—`:p(B)(t.treeKiB)),11,He)])):d(``,!0)]),b(`span`,Ue,[t.run?(f(),x(`span`,{key:0,class:`elapsed whitespace-nowrap font-mono text-xs tabular-nums text-ok`,title:`running for · started ${p(H)(t.run.startedAt,e.now)}`},i(t.elapsed),9,We)):d(``,!0),t.run?(f(),C(u,{key:1,class:`open text-xs text-muted no-underline hover:text-highlighted hover:underline`,to:t.href,"aria-label":`open run ${t.run.label||p(U)(t.run.id)}`},{default:a(()=>[...c[8]||=[r(`open ↗`,-1)]]),_:1},8,[`to`,`aria-label`])):d(``,!0)])],10,Ee))),128))])):(f(),x(`p`,Ge,`nothing on this resident — no run, no worktree`)),b(`p`,{class:`disk mt-2 font-mono text-xs text-dimmed`,"data-idle":Ye.value},[Z.value?(f(),x(_,{key:0},[r(i(Z.value),1)],64)):(f(),x(`span`,qe,`disk not measured yet`))],8,Ke)])],40,he)],8,me)}}}),K={class:`conn flex items-center gap-1.5`},q={id:`state`,class:`text-xs text-muted`},J={key:0,class:`drain-status mb-2 rounded border border-warn/30 bg-warn/8 px-3 py-2 text-xs text-warn`},Y={key:0},X={key:1},Je={key:2},Z={key:3},Q={class:`mb-2 text-xs text-muted`},$={id:`running`,class:`font-mono tabular-nums`},Ye={id:`residents`,class:`m-0 list-none p-0`},Xe={key:2,class:`px-2 py-1.5 text-muted`},Ze=`Resident repos`,Qe=t({__name:`ResidentsIndexPage`,setup(t){let n=h(`residents`),o=l({cap:n?.cap,count:n?.count,draining:n?.draining??null,residents:n?.residents??[],runs:new Map((n?.runs??[]).map(e=>[e.id,e]))}),y=V(n?.now),T=S({tone:`amber`,text:`connecting…`}),E=typeof window<`u`?new URLSearchParams(window.location.search).get(`open`):null,D=u(()=>o.residents.map((e,t)=>{let n=e,r=ne(n);return{key:`${r||`?`}-${t}`,record:n,slug:r,runs:P(o.runs.values(),r)}})),O=u(()=>j(o.cap)||`?`),k=u(()=>j(o.count)||String(D.value.length)),A=u(()=>o.draining&&typeof o.draining==`object`?I(o.draining):null),M=u(()=>Array.isArray(A.value?.holds)?A.value.holds.filter(e=>typeof e==`string`).map(e=>e.replace(/^repo:/,``)):[]),N=u(()=>D.value.reduce((e,t)=>e+t.runs.length,0));c([N,()=>o.residents],([e,t])=>{v.setTitle((e>0?`(${e}) `:``)+Ze),v.setFavicon(te[L(t)])},{immediate:!0});let F=re(),z=null;return m(()=>{z=F(`/residents?stream=1`);let e=!1;z.onopen=()=>{if(e){v.reload();return}e=!0,T.value={tone:`green`,text:`live`}},z.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}R(o,t)},z.onerror=()=>{z&&z.readyState===2?T.value={tone:`red`,text:`disconnected`}:T.value={tone:`amber`,text:`connecting…`}}}),g(()=>{z?.close()}),(t,n)=>{let o=w;return f(),C(e,{title:Ze,nav:`residents`},{status:a(()=>[s(o,{text:`runs arrive from the registry feed; the resident listing also refreshes every 30 seconds`},{default:a(()=>[b(`span`,K,[s(W,{tone:T.value.tone,label:T.value.text},null,8,[`tone`,`label`]),b(`span`,q,i(T.value.text),1)])]),_:1})]),default:a(()=>[A.value?(f(),x(`p`,J,[n[0]||=r(` Deploy drain`,-1),p(j)(A.value.reason)?(f(),x(`span`,Y,` · `+i(p(j)(A.value.reason)),1)):d(``,!0),M.value.length?(f(),x(`span`,X,` · waiting for container images: `+i(M.value.join(`, `)),1)):(f(),x(`span`,Je,` · new runs wait until the fleet reopens`)),p(j)(A.value.holdsUntil)?(f(),x(`span`,Z,` · hold ends by `+i(p(j)(A.value.holdsUntil)),1)):d(``,!0)])):d(``,!0),D.value.length>0?(f(),x(_,{key:1},[b(`p`,Q,[r(i(`${k.value}/${O.value} resident slots in use · `),1),b(`span`,$,i(N.value)+` running`,1)]),b(`ul`,Ye,[(f(!0),x(_,null,ee(D.value,e=>(f(),C(G,{key:e.key,record:e.record,runs:e.runs,now:p(y),open:p(E)!==null&&p(E)===e.slug},null,8,[`record`,`runs`,`now`,`open`]))),128))])],64)):(f(),x(`p`,Xe,[r(` No repos onboarded (0/`+i(O.value)+`). Onboard one from chat: `,1),n[1]||=b(`code`,{class:`rounded bg-elevated px-1.5 py-0.5`},`repo onboard <owner/name>`,-1),n[2]||=r(`. `,-1)]))]),_:1})}}});export{Qe as default};