@coreplane/switchboard 1.249.1 → 1.251.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 (57) hide show
  1. package/dist/assets/config/config.example.yaml +46 -4
  2. package/dist/assets/deploy/cloudflare-memory/worker.ts +260 -1
  3. package/dist/assets/deploy/cloudflare-resident/Dockerfile +12 -3
  4. package/dist/assets/deploy/cloudflare-sandbox/Dockerfile +7 -0
  5. package/dist/assets/package-lock.json +3 -3
  6. package/dist/assets/package.json +3 -2
  7. package/dist/assets/project.json +4 -0
  8. package/dist/assets/source.json +3 -3
  9. package/dist/assets/src/agents/registry.ts +1 -1
  10. package/dist/assets/src/core/authz/policy.ts +10 -0
  11. package/dist/assets/src/core/authz/resource.ts +6 -2
  12. package/dist/assets/src/core/authz/types.ts +2 -0
  13. package/dist/assets/src/core/budgets.ts +13 -0
  14. package/dist/assets/src/core/coordinator/contract.ts +120 -0
  15. package/dist/assets/src/core/coordinator/driver.ts +17 -3
  16. package/dist/assets/src/core/modelCard.ts +19 -3
  17. package/dist/assets/src/core/prDescriptionTypes.ts +35 -0
  18. package/dist/assets/src/core/provider.ts +57 -3
  19. package/dist/assets/src/core/refusal.ts +14 -0
  20. package/dist/assets/src/core/runEvents.ts +49 -2
  21. package/dist/assets/src/core/runFriction.ts +2 -0
  22. package/dist/assets/src/core/runLedger/decisions.ts +9 -1
  23. package/dist/assets/src/core/runLedger/sessionLog.ts +10 -0
  24. package/dist/assets/src/core/runLedger/transcript.ts +13 -3
  25. package/dist/assets/src/core/runLedger/types.ts +72 -6
  26. package/dist/assets/src/core/runRecord.ts +34 -0
  27. package/dist/assets/src/core/ship/contract.ts +17 -4
  28. package/dist/assets/src/core/ship/coordinator.ts +70 -4
  29. package/dist/assets/src/core/trace/attrs.ts +13 -2
  30. package/dist/assets/src/core/trace/workerTrace.ts +3 -2
  31. package/dist/assets/src/core/types.ts +3 -0
  32. package/dist/assets/web/dist/.vite/manifest.json +58 -52
  33. package/dist/assets/web/dist/assets/DeliveryPage-DUXd-Sl-.js +1 -0
  34. package/dist/assets/web/dist/assets/HomePage-mSiqEEcN.js +2 -0
  35. package/dist/assets/web/dist/assets/{PendingTurnRow-BuRre8it.js → PendingTurnRow-DDhMhrI7.js} +1 -1
  36. package/dist/assets/web/dist/assets/{ResidentDetailPage-BIUXyz6K.js → ResidentDetailPage-BnEoOnGQ.js} +1 -1
  37. package/dist/assets/web/dist/assets/{ResidentsIndexPage-BZymgSAb.js → ResidentsIndexPage-Dxpgf-l-.js} +1 -1
  38. package/dist/assets/web/dist/assets/RunFoldRow-CSo4-vld.js +1 -0
  39. package/dist/assets/web/dist/assets/{RunRoutePage-bgkjkA0p.js → RunRoutePage-9klVWhSF.js} +6 -6
  40. package/dist/assets/web/dist/assets/{RunsIndexPage-8S944AzB.js → RunsIndexPage-BplMIgaw.js} +1 -1
  41. package/dist/assets/web/dist/assets/{ScheduledPage-8bBtG9y3.js → ScheduledPage-B_GgeJrb.js} +1 -1
  42. package/dist/assets/web/dist/assets/{SettingsPage-DQeNvfaV.js → SettingsPage-BXX4R113.js} +1 -1
  43. package/dist/assets/web/dist/assets/{StatusDot-BPE5syBa.js → StatusDot-BOaw8le9.js} +1 -1
  44. package/dist/assets/web/dist/assets/{Tooltip-DkoeZfTs.js → Tooltip-DYZZ4l4V.js} +1 -1
  45. package/dist/assets/web/dist/assets/{UnitRoutePage-BUzw--Ii.js → UnitRoutePage-BaSW5Odq.js} +1 -1
  46. package/dist/assets/web/dist/assets/budgets-BvWYKPsY.js +1 -0
  47. package/dist/assets/web/dist/assets/{dist-D11y9ZJ4.js → dist-BCVXeBJ9.js} +1 -1
  48. package/dist/assets/web/dist/assets/indexRow-Bde9OZxG.js +1 -0
  49. package/dist/assets/web/dist/assets/{main-B6LcgNM6.js → main-Dkcbtu3u.js} +2 -2
  50. package/dist/assets/web/dist/assets/sseReplay-DPwdsaok.js +9 -0
  51. package/dist/cli.js +4594 -2743
  52. package/package.json +1 -1
  53. package/dist/assets/web/dist/assets/DeliveryPage-DF4aQypG.js +0 -1
  54. package/dist/assets/web/dist/assets/HomePage-BpQRky8B.js +0 -2
  55. package/dist/assets/web/dist/assets/RunFoldRow-3m4CPRI4.js +0 -1
  56. package/dist/assets/web/dist/assets/indexRow-BmK74Vp1.js +0 -1
  57. package/dist/assets/web/dist/assets/sseReplay-DXC7kGbN.js +0 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreplane/switchboard",
3
- "version": "1.249.1",
3
+ "version": "1.251.0",
4
4
  "description": "Mention it in Slack and an agent reviews the PR, ships the fix, or answers the question — on the model you choose, with its tools running where you decide.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://openswitchboard.dev",
@@ -1 +0,0 @@
1
- import{t as e}from"./AppShell-DAtHiuI6.js";import{An as t,Cn as n,Cr as r,Li as i,Mn as a,Pi as o,Sn as s,Tr as ee,Xr as c,_r as l,bn as u,ji as d,kn as f,ln as p,o as m,xn as h,yn as g}from"./browser-B6T5hjfR.js";import{a as _,c as te,d as ne,i as re,l as v,n as y,o as b,r as x,s as S,t as C,u as ie}from"./delivery-CTdOqpVK.js";import{t as ae}from"./wallClock-DmaC1sKA.js";var w=6e4;1440*w,10*w,5*w,60*w,10*w,60*w;var T={general:2,coding:15,review:5,research:3,explore:15,conductor:15};T.coding,T.coding,T.review;function E(e,t){return e.truncated&&e.completeFrom!==void 0&&Date.parse(`${t}T00:00:00Z`)<Date.parse(e.completeFrom)}Object.freeze({reviewers:[],agentLogins:[],agentCoauthors:[]}),Object.freeze({default:60,min:5,max:1440});var D={class:`text-xs text-muted`},O={key:1,class:`text-highlighted`},k={class:`mb-4 flex flex-wrap items-center gap-x-4 gap-y-2`},A={key:0,class:`flex items-center gap-1`,"aria-label":`Repositories`},j={key:0,class:`rounded-md bg-accented px-2.5 py-1 text-xs font-medium text-highlighted`,"aria-current":`page`},M={class:`font-mono text-sm tabular-nums text-muted`},N={class:`mb-5 grid gap-3`},P={key:0,class:`text-sm text-muted`},F={class:`grid grid-cols-[repeat(auto-fit,minmax(190px,1fr))] gap-3`},I={class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},L={class:`font-mono text-2xl font-medium tabular-nums`},R={class:`text-xs text-muted`},z={class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},B={class:`overflow-x-auto`},V={class:`weeks w-full min-w-[52rem] border-collapse whitespace-nowrap font-mono text-[0.8125rem] tabular-nums`},H=[`title`],U={key:0,class:`ml-1 text-xs`},oe={key:0,class:`text-xs text-muted`},W={class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},G={key:0,class:`text-sm text-muted`},K={key:1,class:`overflow-x-auto`},q={class:`units w-full min-w-[52rem] border-collapse font-mono text-[0.8125rem] tabular-nums`},se=[`href`],ce={key:1,class:`text-dimmed`},le=[`title`],ue=[`href`],de={class:`text-xs text-muted`},fe={class:`rounded bg-accented px-1 py-0.5`},pe={class:`border-t border-default pt-3.5 text-xs text-dimmed`},me={key:0,class:`mb-2 font-mono tabular-nums text-muted`},he={class:`mt-2 grid gap-1.5`},J=`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-xs font-medium text-muted whitespace-nowrap`,Y=`border-b border-muted px-2.5 py-1.5`,X=a({__name:`DeliveryPage`,setup(a){let w=m(`delivery`),T=g(()=>w?.report??null),X=g(()=>w?.repos??[]),Z=g(()=>T.value?ie(T.value):[]),Q=g(()=>T.value?y(T.value):void 0),$=e=>T.value?E(T.value,e):!1,ge=g(()=>T.value?.weeks.some(e=>$(e.week))??!1),_e=[1,2,4,8,13],ve=ae(void 0,6e4),ye=typeof window>`u`?``:window.location.search;return(a,m)=>{let g=ee(`RouterLink`);return T.value?(l(),h(e,{key:0,title:`${T.value.repo} delivery`,nav:`delivery`},{actions:c(()=>[u(`span`,D,[(l(),n(p,null,r(_e,(e,t)=>(l(),n(p,{key:e},[t>0?(l(),n(p,{key:0},[f(` · `)],64)):s(``,!0),e===T.value.range.weeks?(l(),n(`b`,O,i(e)+`w`,1)):(l(),h(g,{key:2,class:`text-primary hover:underline`,to:`/delivery/${T.value.repo}?weeks=${e}`},{default:c(()=>[f(i(e)+`w`,1)]),_:2},1032,[`to`]))],64))),64))])]),default:c(()=>[u(`div`,k,[X.value.length>1?(l(),n(`nav`,A,[(l(!0),n(p,null,r(X.value,e=>(l(),n(p,{key:e},[e===T.value.repo?(l(),n(`span`,j,i(e),1)):(l(),h(g,{key:1,class:`rounded-md px-2.5 py-1 text-xs text-muted no-underline hover:bg-elevated hover:text-highlighted`,to:`/delivery/${e}`},{default:c(()=>[f(i(e),1)]),_:2},1032,[`to`]))],64))),128))])):s(``,!0),u(`p`,M,i(d(b)(T.value.range.since))+` → `+i(d(b)(T.value.range.until))+` · `+i(T.value.range.weeks)+`w · weeks start Monday, UTC `,1)]),u(`section`,N,[Q.value?(l(),n(`p`,P,i(Q.value),1)):s(``,!0),u(`div`,F,[(l(!0),n(p,null,r(Z.value,e=>(l(),n(`div`,{key:e.label,class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},[u(`span`,I,i(e.label),1),u(`span`,L,i(e.value),1),u(`span`,R,i(e.note),1)]))),128))])]),u(`section`,z,[m[0]||=u(`div`,null,[u(`h2`,{class:`text-[0.9375rem] font-medium`},`By week`),u(`p`,{class:`text-sm text-muted`},`One row per Monday-start week · merged pull requests only`)],-1),u(`div`,B,[u(`table`,V,[u(`thead`,null,[u(`tr`,null,[u(`th`,{class:o([J,`text-left`])},`Week`,2),u(`th`,{class:o([J,`text-right`])},`Merged`,2),u(`th`,{class:o([J,`text-right`])},`Agent-authored`,2),u(`th`,{class:o([J,`text-right`])},`Issue → merge`,2),u(`th`,{class:o([J,`text-right`])},`First-pass CI`,2),u(`th`,{class:o([J,`text-right`])},`Rounds / PR`,2),u(`th`,{class:o([J,`text-right`])},`Findings`,2),u(`th`,{class:o([J,`text-right`])},`No human edit`,2),u(`th`,{class:o([J,`text-right`])},`Agent run min`,2)])]),u(`tbody`,null,[(l(!0),n(p,null,r(T.value.weeks,e=>(l(),n(`tr`,{key:e.week,class:o($(e.week)?`text-dimmed`:``)},[u(`td`,{class:o(Y),title:`${e.week} → ${e.until}`},[f(i(d(b)(e.week))+` – `+i(d(b)(e.until))+` `,1),$(e.week)?(l(),n(`span`,U,`(incomplete)`)):s(``,!0)],8,H),u(`td`,{class:o([Y,`text-right font-medium`])},i(e.prsMerged),3),u(`td`,{class:o([Y,`text-right`])},i(e.agentAuthoredPrs),3),u(`td`,{class:o([Y,`text-right`])},i(d(_)(e.leadTimeHours.median)),3),u(`td`,{class:o([Y,`text-right`])},i(d(C)(e)),3),u(`td`,{class:o([Y,`text-right`])},i(d(te)(e.reviewRounds.perPr)),3),u(`td`,{class:o([Y,`text-right`])},i(d(x)(e)),3),u(`td`,{class:o([Y,`text-right`])},i(d(S)(e.findings.noHumanEditShare)),3),u(`td`,{class:o([Y,`text-right`])},i(e.agentRuns.minutes.toFixed(0)),3)],2))),128))])])]),ge.value&&T.value.completeFrom?(l(),n(`p`,oe,` Incomplete weeks hold the newest pull requests the read reached — it is complete from `+i(d(v)(T.value.completeFrom))+` — so their numbers are a floor on the merges, not the week's. `,1)):s(``,!0)]),u(`section`,W,[m[3]||=u(`div`,null,[u(`h2`,{class:`text-[0.9375rem] font-medium`},`By unit`),u(`p`,{class:`text-sm text-muted`},` One row per board issue the pull requests link · the issue's opening starts the clock `)],-1),T.value.units.length===0?(l(),n(`p`,G,`Nothing merged in range.`)):(l(),n(`div`,K,[u(`table`,q,[u(`thead`,null,[u(`tr`,null,[u(`th`,{class:o([J,`text-left`])},`Issue`,2),u(`th`,{class:o([J,`text-left`])},`Unit`,2),u(`th`,{class:o([J,`text-left`])},`PRs`,2),u(`th`,{class:o([J,`text-right`])},`Issue → merge`,2),u(`th`,{class:o([J,`text-right`])},`First-pass CI`,2),u(`th`,{class:o([J,`text-right`])},`Rounds`,2),u(`th`,{class:o([J,`text-right`])},`Findings`,2),u(`th`,{class:o([J,`text-right`])},`No human edit`,2)])]),u(`tbody`,null,[(l(!0),n(p,null,r(T.value.units,e=>(l(),n(`tr`,{key:e.issue??`none`},[u(`td`,{class:o([Y,`whitespace-nowrap`])},[e.issue===null?(l(),n(`span`,ce,`—`)):(l(),n(`a`,{key:0,class:`text-primary hover:underline`,href:`https://github.com/${T.value.repo}/issues/${e.issue}`},`#`+i(e.issue),9,se))],2),u(`td`,{class:o([Y,`max-w-[28rem] truncate font-sans`]),title:e.title},i(e.title),11,le),u(`td`,{class:o([Y,`whitespace-nowrap`])},[(l(!0),n(p,null,r(e.prs,(e,t)=>(l(),n(p,{key:e},[t>0?(l(),n(p,{key:0},[f(`, `)],64)):s(``,!0),u(`a`,{class:`text-primary hover:underline`,href:`https://github.com/${T.value.repo}/pull/${e}`},i(e),9,ue)],64))),128))],2),u(`td`,{class:o([Y,`text-right`])},i(d(_)(e.leadTimeHours.median)),3),u(`td`,{class:o([Y,`text-right`])},i(d(C)(e)),3),u(`td`,{class:o([Y,`text-right`])},i(e.reviewRounds.verdicts),3),u(`td`,{class:o([Y,`text-right`])},i(d(x)(e)),3),u(`td`,{class:o([Y,`text-right`])},i(d(S)(e.findings.noHumanEditShare)),3)]))),128))])])])),u(`p`,de,[m[1]||=f(` Machine-readable twin: `,-1),u(`code`,fe,`GET /delivery/`+i(T.value.repo)+`.json`,1),m[2]||=f(` (same gate). `,-1)])]),u(`footer`,pe,[T.value.snapshotAt?(l(),n(`p`,me,[f(` As of `+i(d(v)(T.value.snapshotAt))+`, `+i(d(ne)(T.value.snapshotAt,d(ve)))+` · `,1),t(g,{class:`text-primary hover:underline`,to:`/delivery/${T.value.repo}${d(re)(d(ye))}`},{default:c(()=>[...m[4]||=[f(`read GitHub now`,-1)]]),_:1},8,[`to`])])):s(``,!0),u(`details`,null,[m[14]||=u(`summary`,{class:`cursor-pointer text-muted`},`How these numbers are computed`,-1),u(`div`,he,[m[12]||=u(`div`,null,[u(`b`,null,`Snapshot.`),f(` GitHub's record of the merged pull requests (each one's timeline and its branch's workflow runs, the board issue its body links) is read on an interval and kept as a snapshot the page, its JSON twin and `),u(`code`,null,`delivery report`),f(` serve; `),u(`code`,null,`?fresh=1`),f(` reads GitHub now. The run history you may see joins on every load. `)],-1),m[13]||=u(`div`,null,[u(`b`,null,`Issue → merge`),f(` runs from the linked board issue's opening (a closing keyword or a `),u(`code`,null,`board item`),f(` reference in the body) to the merge; a pull request that links no issue counts from its own opening. `),u(`b`,null,`First-pass CI`),f(` is green when every pull-request-triggered workflow run (`),u(`code`,null,`pull_request`),f(`, `),u(`code`,null,`pull_request_target`),f(`) on the first head succeeded at its first attempt — a rerun or a red run fails it; a head with no such run is not counted. `),u(`b`,null,`Review rounds`),f(` are the review agent's verdicts; a `),u(`i`,null,`fix round`),f(` is a verdict that followed a push. `),u(`b`,null,`No human edit`),f(` is the share of the agent's findings on pull requests where every push after the first verdict was an agent's: a bot login, or a commit co-authored by an agent. `),u(`b`,null,`Agent run minutes`),f(` are the finished runs of this repository that named a pull request. `)],-1),u(`div`,null,[m[6]||=u(`b`,null,`Identities.`,-1),m[7]||=f(` Verdicts by `,-1),u(`code`,null,i(T.value.identities.reviewers.join(`, `)||`(none configured)`),1),m[8]||=f(`; agent logins end in `,-1),m[9]||=u(`code`,null,`[bot]`,-1),T.value.identities.agentLogins.length?(l(),n(p,{key:0},[m[5]||=f(`, plus `,-1),u(`code`,null,i(T.value.identities.agentLogins.join(`, `)),1)],64)):s(``,!0),m[10]||=f(`; agent co-authors named `,-1),u(`code`,null,i(T.value.identities.agentCoauthors.join(`, `)||`(none)`),1),m[11]||=f(`. `,-1)])])])])]),_:1},8,[`title`])):s(``,!0)}}});export{X as default};
@@ -1,2 +0,0 @@
1
- import{i as e,r as t,t as n}from"./AppShell-DAtHiuI6.js";import{An as r,Cn as i,Cr as a,Ft as o,Gr as s,Ii as c,Li as l,Mn as u,Pi as d,Pt as f,Qr as p,Sn as m,Tr as h,Xr as g,_r as _,bn as v,c as y,dr as ee,en as b,hr as x,ir as S,ji as C,kn as w,l as te,ln as T,o as E,rn as D,sr as O,t as k,wr as A,xi as j,xn as M,y as N,yi as P,yn as F,yr as I}from"./browser-B6T5hjfR.js";import{t as L}from"./Tooltip-DkoeZfTs.js";import{i as R,n as ne,r as re,t as z}from"./PendingTurnRow-BuRre8it.js";import{b as ie,x as ae}from"./main-B6LcgNM6.js";import{t as oe}from"./eventSource-Bj_dZf6M.js";import{t as B}from"./wallClock-DmaC1sKA.js";import{n as V,r as se,t as H}from"./indexFormat-B-pd4r7Y.js";import{O as ce,a as le,i as ue,t as de,y as fe}from"./indexRow-BmK74Vp1.js";import{i as pe}from"./format-BldUwl_R.js";import{i as me,n as he,t as U}from"./durationTone-U_rOqo6r.js";import{D as W,E as ge,a as _e,c as G,d as ve,i as ye,n as be,o as xe,s as Se,t as K,u as q,v as Ce}from"./sseReplay-DXC7kGbN.js";var J=`To run this:`;function we(e,t){return e?t.trim()===``?`stop`:`steer`:`send`}var Te=`↪ Folded into`;function Ee(e){let t=e.trim();return t.startsWith(`To run this:`)?{kind:`handBack`,command:t.slice(J.length).trim()}:t.startsWith(Te)?{kind:`steerAck`,text:t}:{kind:`inline`,text:t}}function De(e){let t=/^\/runs\/([^/?#]+)(\?t=([^&#]+))?$/.exec(e);if(!t)return null;let n=decodeURIComponent(t[1]),r=t[3]?`?t=${t[3]}`:``;return{id:n,eventsUrl:`/runs/${t[1]}/events${r}`,stopUrl:`/runs/${t[1]}/stop${r}`}}function Y(e,t=60){let n=e.split(/\r?\n/).find(e=>e.trim()!==``)?.trim()??``;return n.length<=t?n||`New conversation`:`${n.slice(0,t-1).trimEnd()}…`}function Oe(e,t){let n=t-e;if(!(n>45e3))return`now`;let r=Math.floor(n/6e4);if(r<60)return`${Math.max(1,r)}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);return a<7?`${a}d`:V(e,t)}function ke(e,t){let n=e.surface??`web`,r=ue[n]??n,i=e.channelName?`${r} #${e.channelName}`:r;return{title:e.excerpt||e.title,when:H(e.lastAt,t),source:n===`web`?r:`${i} · read-only here`,runs:`${e.runs} run${e.runs===1?``:`s`}`,live:e.live}}var X={min:224,default:288,max:448,step:16};function Ae(e){let t=typeof e==`string`?Number(e):e;return typeof t!=`number`||!Number.isFinite(t)?X.default:Math.min(X.max,Math.max(X.min,Math.round(t)))}var Z={width:`sb.rail.width`,collapsed:`sb.rail.collapsed`};function je(e){return{width:Ae(e.width??void 0),collapsed:e.collapsed===`1`}}function Me(e,t){let n=e<5?`Still up`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`;return t?`${n}, ${t}.`:`${n}.`}function Ne(e,t){let n=t.trim();for(let t=e.length-1;t>=0;t--){let r=e[t];if(!r.folded&&r.text.trim()===n)return r}return null}function Pe(e,t=60){return e<=t}function Fe(e){return e.key===`Enter`&&!e.shiftKey&&!e.isComposing}function Ie(e,t){let n=e.trim().toLowerCase();if(n===``)return 0;let r=t.toLowerCase(),i=0,a=-1,o=-1;for(let e of n){if(e===` `)continue;let t=r.indexOf(e,i);if(t===-1)return null;a===-1&&(a=t),o=t,i=t+1}return a===-1?0:o-a}function Le(e,t){return t.trim()===``?[...e]:e.map((e,n)=>({row:e,i:n,score:Ie(t,e.title)})).filter(e=>e.score!==null).sort((e,t)=>e.score-t.score||e.i-t.i).map(e=>e.row)}function Re(e){if(!(e.metaKey||e.ctrlKey))return null;let t=e.key.toLowerCase();return t===`o`&&e.shiftKey?`newThread`:t===`k`&&!e.shiftKey?`search`:null}function ze(e,t){return t?``:e===`steer`?`Say what to add — it folds into the run at its next step`:e===`stop`?`A run is working — type to steer it, or stop it`:`Review a pull request, ship a fix, investigate a run… or type / for a command`}function Q(e){let t=new Map;for(let n of e){let[e,r]=n.chat.split(` `,2);if(!e)continue;let i=t.get(e)??{name:e,verbs:[]};r===void 0?i.bare=n:i.verbs.push({verb:r,command:n}),t.set(e,i)}return[...t.values()]}function Be(e,t,n){if(t===``)return[...e];let r=t.toLowerCase(),i=e.filter(e=>n(e)[0].toLowerCase().startsWith(r));return i.length>0?i:e.map((e,r)=>{let i=n(e).map(e=>Ie(t,e)).filter(e=>e!==null);return i.length===0?null:{item:e,i:r,score:Math.min(...i)}}).filter(e=>e!==null).sort((e,t)=>e.score-t.score||e.i-t.i).map(e=>e.item)}function Ve(e,t=0,n=new Set){let r=(e.args??[]).slice(t),i=(e.options??[]).filter(e=>!n.has(He(e.form))).map(e=>`[${e.form}]`);return[...r,...i].join(` `)}var He=e=>e.split(` `,1)[0];function Ue(e,t){let n=new Set,r=0;for(let i=0;i<t.length;i++){let a=t[i];if(a.startsWith(`-`)){n.add(a);let t=(e.options??[]).find(e=>He(e.form)===a);t&&t.form.includes(` `)&&i++}else r++}return{positionals:r,flags:n}}function We(e,t){let n=/^\/([^\n]*)$/.exec(e);if(!n||t.length===0)return null;let r=n[1].split(` `),i=r[r.length-1],a=r.slice(0,-1).filter(e=>e!==``),o=e.slice(0,e.length-i.length),s=Q(t);if(a.length===0)return{level:`group`,head:o,partial:i,rows:Be(s,i,e=>[e.name,...e.bare?[e.bare.describe]:[],...e.verbs.map(e=>e.command.describe)]).map(e=>({insert:e.name,label:`/${e.name}`,describe:e.bare?e.verbs.length>0?`${e.bare.describe} · also ${e.verbs.map(e=>e.verb).join(`, `)}`:e.bare.describe:e.verbs.map(e=>e.verb).join(` · `),kind:e.bare&&e.verbs.length===0?`command`:`group`,acceptable:!0}))};let c=s.find(e=>e.name===a[0]);if(!c)return null;if(a.length===1){let e=Be(c.verbs,i,e=>[e.verb,e.command.describe]);if(e.length===0&&c.bare&&i!==``)return Ke(c.bare,o,i,[]);if(e.length===0&&!c.bare)return{level:`verb`,head:o,partial:i,rows:[]};let t=e.map(e=>({insert:e.verb,label:`/${e.command.chat}`,describe:e.command.describe,kind:`command`,acceptable:!0}));return c.bare&&i===``&&t.unshift(Ge(c.bare,0,new Set)),{level:`verb`,head:o,partial:i,rows:t}}let l=c.verbs.find(e=>e.verb===a[1]);return l?Ke(l.command,o,i,a.slice(2)):c.bare?Ke(c.bare,o,i,a.slice(1)):null}function Ge(e,t,n){let r=Ve(e,t,n);return{insert:``,label:`/${e.chat}`,describe:r?`${r} — ${e.describe}`:e.describe,kind:`usage`,acceptable:!1}}function Ke(e,t,n,r){let i=Ue(e,r);return n.startsWith(`-`)?{level:`tail`,head:t,partial:n,rows:Be((e.options??[]).filter(e=>!i.flags.has(He(e.form))),n,e=>[He(e.form),e.describe]).map(e=>({insert:He(e.form),label:e.form,describe:e.describe,kind:`option`,acceptable:!0})),command:e}:{level:`tail`,head:t,partial:n,rows:[Ge(e,i.positionals,i.flags)],command:e}}function qe(e,t){let n=e.rows[t];if(!n)return null;if(n.acceptable){if(!n.insert.toLowerCase().startsWith(e.partial.toLowerCase()))return null;let t=n.insert.slice(e.partial.length);return t===``?null:{text:t,acceptable:!0}}if(e.partial!==``||n.kind!==`usage`)return null;let[r,...i]=n.describe.split(` — `);return i.length===0?null:{text:r,acceptable:!1}}function $(e,t){return`${e.head}${t.insert} `}function Je(e,t){if(!e.startsWith(`/`))return e;let n=e.slice(1),[r,i]=n.split(/\s+/,2);return t.some(e=>e.chat===r||i!==void 0&&e.chat===`${r} ${i}`)?n:e}var Ye={class:`composer-wrap relative`},Xe={key:0,class:`palette absolute bottom-full left-0 right-0 z-20 mb-2 max-h-72 overflow-y-auto rounded-xl border border-default bg-(--ui-bg-elevated) p-1 shadow-sm`,role:`listbox`,"aria-label":`Commands`,"data-testid":`palette`},Ze={key:0,class:`px-3 py-2 font-mono text-xs text-dimmed`},Qe=[`aria-selected`,`data-insert`,`data-kind`,`data-label`,`onClick`,`onMouseenter`],$e={class:`chat shrink-0 font-mono text-[0.8rem] font-medium text-highlighted`},et={class:`describe min-w-0 flex-1 truncate text-[0.8rem] text-muted`},tt={key:0,class:`shrink-0 rounded border border-default px-1 font-mono text-[0.62rem] text-dimmed`,"aria-hidden":`true`},nt=[`data-mode`],rt={class:`relative min-w-0 flex-1`},it=[`data-acceptable`],at={class:`invisible`},ot={class:`text-dimmed`},st=[`rows`,`value`,`placeholder`,`autofocus`,`aria-expanded`],ct=[`aria-hidden`,`data-hint`,`data-shown`],lt=u({__name:`ChatComposer`,props:{modelValue:{},mode:{},hint:{},autofocus:{type:Boolean},sweepOnMount:{type:Boolean},commands:{}},emits:[`update:modelValue`,`submit`,`stop`],setup(e,{expose:t,emit:n}){let o=e,c=n,u=j(null),p=j(!1),h=j(!1),y=F(()=>Math.min(8,Math.max(1,o.modelValue.split(`
2
- `).length))),b={send:{icon:`i-lucide-arrow-up`,label:`Send`},steer:{icon:`i-lucide-corner-down-right`,label:`Steer the run`},stop:{icon:`i-lucide-square`,label:`Stop the run`}},x=F(()=>b[o.mode]),C=F(()=>ze(o.mode,o.hint)),w=F(()=>o.hint?o.hint:o.mode===`steer`?`Enter folds this into the run in flight`:o.mode===`stop`?`A run is in flight · type to steer it, or stop it`:`Enter to send · Shift+Enter for a new line · / for a command`),E=F(()=>p.value||o.hint!==void 0||o.mode!==`send`),O=F(()=>We(o.modelValue,o.commands??[])),k=F(()=>O.value?.rows??[]),A=j(!1),P=j(0),I=F(()=>O.value!==null&&!A.value),L=F(()=>I.value&&O.value?qe(O.value,P.value):null);s(()=>`${O.value?.level??``}|${O.value?.head??``}`,()=>{A.value=!1,P.value=0}),s(k,e=>{P.value>=e.length&&(P.value=Math.max(0,e.length-1))});function R(e){O.value&&e.acceptable&&(c(`update:modelValue`,$(O.value,e)),B())}function ne(){let e=u.value;return!e||e.selectionStart===e.value.length&&e.selectionEnd===e.value.length}function re(e){c(`update:modelValue`,e.target.value)}function z(e){if(I.value){if(e.key===`ArrowDown`){e.preventDefault(),k.value.length>0&&(P.value=(P.value+1)%k.value.length);return}if(e.key===`ArrowUp`){e.preventDefault(),k.value.length>0&&(P.value=(P.value-1+k.value.length)%k.value.length);return}if(e.key===`Escape`){e.preventDefault(),A.value=!0;return}let t=k.value[P.value];if(e.key===`Tab`&&t?.acceptable){e.preventDefault(),R(t);return}if(e.key===`ArrowRight`&&L.value?.acceptable&&t&&ne()){e.preventDefault(),R(t);return}if(e.key===`Enter`&&!e.shiftKey&&t?.acceptable){e.preventDefault(),R(t);return}}Fe(e)&&(e.preventDefault(),ie())}function ie(){o.mode===`stop`?c(`stop`):o.modelValue.trim()!==``&&c(`submit`)}function ae(){h.value=!1,S().then(()=>{h.value=!0})}function oe(){p.value=!0,ae()}function B(){S().then(()=>{let e=u.value;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length),document.activeElement===e&&!p.value&&oe())})}return s(()=>o.hint,e=>{e&&B()}),ee(()=>{o.autofocus&&B(),o.sweepOnMount&&ae()}),t({focus:B}),(t,n)=>{let o=N,s=te;return _(),i(`div`,Ye,[r(f,{name:`sb-rise`},{default:g(()=>[I.value?(_(),i(`div`,Xe,[k.value.length===0?(_(),i(`p`,Ze,` No command matches "`+l(e.modelValue)+`". `,1)):m(``,!0),(_(!0),i(T,null,a(k.value,(e,t)=>(_(),i(`button`,{key:e.label,type:`button`,role:`option`,class:d([`item flex w-full items-baseline gap-3 rounded-lg px-3 py-1.5 text-left transition-colors duration-150 ease-out`,t===P.value?`bg-(--ui-bg-accented)`:`hover:bg-(--ui-bg-muted)`]),"aria-selected":t===P.value?`true`:`false`,"data-insert":e.insert,"data-kind":e.kind,"data-label":e.label,onMousedown:n[0]||=D(()=>{},[`prevent`]),onClick:t=>R(e),onMouseenter:e=>P.value=t},[v(`span`,$e,l(e.label),1),v(`span`,et,l(e.describe),1),t===P.value&&e.acceptable?(_(),i(`kbd`,tt,`Tab`)):m(``,!0)],42,Qe))),128))])):m(``,!0)]),_:1}),v(`div`,{class:d([`ring relative rounded-2xl`,h.value?`ring-sweep`:``]),onAnimationend:n[2]||=e=>h.value=!1},[v(`form`,{class:d([`composer relative flex items-end gap-2 rounded-2xl border bg-default px-3 py-2 transition-colors duration-150 ease-out`,p.value?`border-primary`:`border-default hover:border-accented`]),"data-mode":e.mode,onSubmit:D(ie,[`prevent`])},[v(`div`,rt,[L.value?(_(),i(`div`,{key:0,class:`ghost composer-text pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap break-words`,"aria-hidden":`true`,"data-testid":`ghost`,"data-acceptable":L.value.acceptable?`1`:`0`},[v(`span`,at,l(e.modelValue),1),v(`span`,ot,l(L.value.text),1)],8,it)):m(``,!0),v(`textarea`,{ref_key:`box`,ref:u,class:`box composer-text relative block min-h-6 w-full resize-none bg-transparent text-highlighted outline-none placeholder:text-dimmed`,rows:y.value,value:e.modelValue,placeholder:C.value,autofocus:e.autofocus,"aria-label":`Message`,"aria-expanded":I.value?`true`:void 0,autocomplete:`off`,spellcheck:`true`,onInput:re,onKeydown:z,onFocus:oe,onBlur:n[1]||=e=>p.value=!1},null,40,st)]),r(s,{type:`submit`,class:`control shrink-0 rounded-full transition-transform duration-150 ease-out active:scale-95`,color:e.mode===`stop`?`neutral`:`primary`,variant:e.mode===`stop`?`outline`:`solid`,size:`sm`,"aria-label":x.value.label,title:x.value.label,disabled:e.mode===`send`&&e.modelValue.trim()===``,"data-mode":e.mode},{default:g(()=>[r(f,{name:`sb-fade`,mode:`out-in`},{default:g(()=>[(_(),M(o,{key:x.value.icon,name:x.value.icon,class:`size-4`,"aria-hidden":`true`},null,8,[`name`]))]),_:1})]),_:1},8,[`color`,`variant`,`aria-label`,`title`,`disabled`,`data-mode`])],42,nt)],34),v(`p`,{class:d([`hint mt-1.5 min-h-[1.1rem] select-none px-3 font-mono text-[0.7rem] text-dimmed transition-opacity duration-150 ease-out`,E.value?`opacity-100`:`opacity-0`]),"aria-hidden":E.value?void 0:`true`,"data-hint":e.hint?`handback`:e.mode,"data-shown":E.value?`1`:`0`},l(w.value),11,ct)])}}}),ut={class:`thread-tip flex max-w-xs flex-col gap-1 text-xs`},dt={class:`tip-title leading-snug text-highlighted`},ft={class:`flex flex-wrap items-center gap-x-1.5 gap-y-0.5 font-mono text-[0.68rem] text-muted`},pt={class:`tip-when tabular-nums`},mt={class:`tip-source inline-flex items-center gap-1`},ht={class:`tip-runs`},gt={key:0,class:`tip-live inline-flex items-center gap-1 text-toned`},_t=u({__name:`ThreadTip`,props:{row:{},now:{}},setup(e){let t=e,n=F(()=>ke(t.row,t.now));return(t,r)=>(_(),i(`div`,ut,[v(`p`,dt,l(n.value.title),1),v(`p`,ft,[v(`span`,pt,l(n.value.when),1),r[1]||=v(`span`,{"aria-hidden":`true`},`·`,-1),v(`span`,mt,[e.row.surface===`slack`?(_(),M(me,{key:0})):m(``,!0),w(l(n.value.source),1)]),r[2]||=v(`span`,{"aria-hidden":`true`},`·`,-1),v(`span`,ht,l(n.value.runs),1),n.value.live?(_(),i(`span`,gt,[...r[0]||=[v(`span`,{class:`size-1.5 rounded-full bg-ok`,"aria-hidden":`true`},null,-1),w(`live`,-1)]])):m(``,!0)])]))}}),vt={class:`rail flex flex-col gap-1 text-[0.8rem]`,"aria-label":`Recent threads`},yt={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`},bt={key:0,class:`rounded border border-default px-1 font-mono text-[0.65rem] text-dimmed`},xt={key:0,class:`empty px-3 py-1 text-xs text-dimmed`},St={key:1,class:`nomatch px-3 py-1 text-xs text-dimmed`},Ct={key:0,class:`dot mt-px size-1.5 shrink-0 self-center rounded-full bg-ok motion-safe:animate-pulse`,"aria-label":`a run is in flight`},wt={class:`title min-w-0 flex-1 truncate text-toned group-hover:text-highlighted group-aria-[current=page]:text-highlighted`},Tt={class:`when shrink-0 font-mono text-[0.7rem] tabular-nums text-dimmed`},Et={class:`retention px-3 pt-1 text-[0.7rem] leading-relaxed text-dimmed`},Dt={class:`model px-3 pt-2 text-[0.7rem] leading-relaxed text-dimmed`,"data-testid":`what-is-a-thread`},Ot=500,kt=u({__name:`ConversationRail`,props:{rows:{},current:{},now:{},retention:{}},setup(e,{expose:t}){let n=e,s=j(``),c=j(null),u=F(()=>Le(n.rows,s.value));function d(){c.value?.focus(),c.value?.select()}function f(e){e.key===`Escape`&&(s.value=``,c.value?.blur())}return t({focusFilter:d}),(t,n)=>{let d=N,y=h(`RouterLink`),ee=L;return _(),i(`nav`,vt,[r(y,{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:g(()=>[r(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]||=v(`span`,null,`New thread`,-1),n[2]||=v(`span`,{class:`kbd ml-auto flex gap-0.5 font-mono text-[0.65rem] opacity-70`,"aria-label":`shortcut shift command O`},[v(`kbd`,{class:`rounded border border-current/30 px-1`},`⇧`),v(`kbd`,{class:`rounded border border-current/30 px-1`},`⌘`),v(`kbd`,{class:`rounded border border-current/30 px-1`},`O`)],-1)]),_:1},8,[`aria-current`]),v(`label`,yt,[r(d,{name:`i-lucide-search`,class:`size-3.5 shrink-0 text-dimmed`,"aria-hidden":`true`}),p(v(`input`,{ref_key:`filter`,ref:c,"onUpdate:modelValue":n[0]||=e=>s.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:f},null,544),[[b,s.value]]),s.value?m(``,!0):(_(),i(`kbd`,bt,`⌘K`))]),n[8]||=v(`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?(_(),i(`p`,xt,`Nothing yet. Ask something.`)):u.value.length===0?(_(),i(`p`,St,`Nothing matches "`+l(s.value)+`".`,1)):m(``,!0),r(o,{name:`sb-rise`,tag:`div`,class:`rows flex flex-col gap-0.5`},{default:g(()=>[(_(!0),i(T,null,a(u.value,t=>(_(),i(`div`,{key:t.id},[r(ee,{"delay-duration":Ot,content:{side:`right`,sideOffset:12,align:`start`},ui:{content:`h-auto max-w-xs px-2.5 py-2`}},{content:g(()=>[r(_t,{row:t,now:e.now},null,8,[`row`,`now`])]),default:g(()=>[r(y,{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:g(()=>[n[3]||=v(`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?(_(),i(`span`,Ct)):m(``,!0),v(`span`,wt,l(t.title),1),v(`span`,Tt,l(C(Oe)(t.lastAt,e.now)),1)]),_:2},1032,[`to`,`aria-current`,`data-surface`])]),_:2},1024)]))),128))]),_:1}),r(y,{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:g(()=>[n[4]||=w(` All runs `,-1),r(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}),v(`p`,Et,l(e.retention),1),v(`p`,Dt,[n[6]||=w(` A thread is a conversation; each message you send is a run. `,-1),r(y,{class:`text-muted hover:text-highlighted`,to:`/runs`},{default:g(()=>[...n[5]||=[w(`Runs`,-1)]]),_:1}),n[7]||=w(` lists every run across everyone's threads. `,-1)])])}}}),At={class:`empty mx-auto flex w-full max-w-2xl flex-col items-center gap-5 px-3 py-6 text-center`},jt={class:`flex flex-col gap-1.5`},Mt={class:`greeting sb-stagger text-xl font-medium tracking-tight text-highlighted`,style:{"--sb-i":`1`}},Nt={class:`sb-stagger w-full text-left`,style:{"--sb-i":`3`}},Pt={key:0,class:`chips flex flex-wrap justify-center gap-2`,"aria-label":`Suggestions`},Ft=[`onClick`],It=u({__name:`EmptyState`,props:{name:{},hour:{},suggestions:{}},emits:[`pick`],setup(e,{emit:n}){let o=n;return(n,s)=>(_(),i(`section`,At,[r(t,{draw:``,idle:``,class:`mark-lg sb-stagger text-highlighted`,style:{"font-size":`3.25rem`,"--sb-i":`0`}}),v(`div`,jt,[v(`h2`,Mt,l(C(Me)(e.hour,e.name)),1),s[0]||=v(`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)]),v(`div`,Nt,[A(n.$slots,`default`)]),e.suggestions.length>0?(_(),i(`ul`,Pt,[(_(!0),i(T,null,a(e.suggestions,(e,t)=>(_(),i(`li`,{key:e,class:`sb-stagger`,style:c({"--sb-i":t+4})},[v(`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=>o(`pick`,e)},l(e),9,Ft)],4))),128))])):m(``,!0)]))}}),Lt=[`data-pending`],Rt={class:`meta flex items-baseline gap-2 pr-1 font-mono text-[0.7rem] text-dimmed`},zt={key:0,class:`failed text-bad`},Bt={key:0,class:`folded text-muted`},Vt=[`title`],Ht=u({__name:`PersonTurn`,props:{text:{},at:{},now:{},pending:{type:Boolean},folded:{},failed:{}},setup(e){let t=e,n=F(()=>H(t.at,t.now));return(t,a)=>(_(),i(`div`,{class:`turn person flex flex-col items-end gap-1`,"data-pending":e.pending?`1`:void 0},[v(`div`,{class:d([`bubble max-w-[min(42rem,88%)] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-(--ui-bg-accented) px-4 py-2.5 text-[0.875rem] leading-normal text-highlighted transition-opacity duration-150 ease-out`,e.pending?`opacity-70`:``])},l(e.text),3),v(`div`,Rt,[e.failed?(_(),i(`span`,zt,l(e.failed),1)):m(``,!0),r(f,{name:`sb-fade`},{default:g(()=>[e.folded?(_(),i(`span`,Bt,`↪ folded in `+l(e.folded),1)):m(``,!0)]),_:1}),v(`span`,{class:`ts select-none`,title:C(pe)(e.at)},l(n.value),9,Vt)])],8,Lt))}}),Ut=[`title`],Wt={class:`preset font-medium`},Gt={class:`reason truncate font-normal opacity-80`},Kt=u({__name:`ReceiptChip`,props:{route:{}},setup(e){let t=e,n=F(()=>de[le(t.route.preset)]);return(t,r)=>(_(),i(`span`,{class:d([`receipt inline-flex max-w-full items-baseline gap-1.5 rounded border px-1.5 py-px font-mono text-[0.7rem] leading-relaxed`,n.value]),title:`routed: ${e.route.reason}`,"data-testid":`receipt`},[v(`span`,Wt,l(e.route.preset),1),v(`span`,Gt,`· `+l(e.route.reason),1)],10,Ut))}}),qt=[`data-phase`,`data-run-id`,`data-live`],Jt={class:`head flex flex-wrap items-baseline gap-2 font-mono text-[0.7rem] text-dimmed`},Yt={key:0,class:`model`},Xt={key:1,class:`elapsed ml-auto tabular-nums`,"data-testid":`elapsed`},Zt={key:0,class:`disconnected flex items-baseline gap-2 rounded-lg border border-dashed border-bad/40 px-3 py-2 font-mono text-xs text-bad`,"data-testid":`disconnected`},Qt=[`open`],$t={class:`flex min-h-6 cursor-pointer list-none items-baseline gap-2 font-mono text-[0.7rem] text-dimmed hover:text-toned [&::-webkit-details-marker]:hidden`},en={class:`summary`},tn={class:`pl-1 pt-1`},nn={key:0,class:`py-2 font-mono text-xs text-dimmed`},rn={key:1,class:`py-2 font-mono text-xs text-warn`},an={key:2,class:`m-0 list-none p-0`},on={key:0,class:`reply`,"data-testid":`reply`},sn={key:1,class:`outcome font-mono text-xs text-warn`,"data-testid":`outcome`},cn={key:2,class:`facts flex flex-wrap items-baseline gap-x-3 font-mono text-[0.7rem] text-dimmed`},ln=u({__name:`AssistantTurn`,props:{turn:{},now:{},live:{},fetch:{}},emits:[`ended`,`input`,`stop`],setup(e,{emit:t}){let n=e,u=t,p=G(),y=p.state,b=j(n.live?`connecting`:`ended`),S=j(n.turn.route??null),te=j(!0),E=F(()=>y.reply?.text??n.turn.answer??``),D=F(()=>y.meta?.agent??n.turn.agent??``),O=F(()=>{let e=y.meta?.model??n.turn.model;return e?ve(e):``}),k=F(()=>n.live!==null&&n.live!==void 0&&b.value!==`ended`),A=F(()=>b.value===`disconnected`),N=n.live?.serverNow?Se({startedAt:n.turn.startedAt,receivedAt:n.turn.receivedAt,serverNow:n.live.serverNow},n.now):null,P=n.now,L=j(void 0),R=F(()=>n.turn.finished&&n.turn.finishedAt!==void 0?Math.max(0,n.turn.finishedAt-(n.turn.receivedAt??n.turn.startedAt)):L.value===void 0?N?N.elapsedMs(n.now):Math.max(0,n.now-P):L.value),ie=F(()=>ce(R.value,`clock`)),ae=F(()=>U(k.value?void 0:R.value,`run`)),B=F(()=>he(ae.value)),V=F(()=>k.value?Ce(y,n.now):null);I(xe,V),I(ye,null),I(_e,F(()=>y.reply!==null));let se=F(()=>k.value?q(y,p.pendingCall(),n.now):null),H=F(()=>{let e=se.value;return A.value||!e||e.kind===`call`?null:e.kind===`starting`?{verb:`Starting`,elapsedMs:R.value,slow:!1}:{verb:ne(e.elapsedMs),elapsedMs:e.elapsedMs,slow:e.slow}}),ue=F(()=>y.log.filter(e=>e.kind===`step`)),pe=F(()=>ue.value.length>0?ue.value.length:n.turn.stepCount??0),me=F(()=>n.turn.finished&&n.turn.status&&n.turn.status!==`completed`?fe(n.turn.status):``),J=F(()=>`/runs/${encodeURIComponent(n.turn.id)}`),we=oe(),Te=null;function Ee(e){let t=e;t.type===`route`&&typeof t.preset==`string`&&(S.value={preset:t.preset,reason:typeof t.reason==`string`?t.reason:``}),t.type===`input`&&typeof t.text==`string`&&(te.value?te.value=!1:u(`input`,t.text,t.at)),p.handle(e)}ee(()=>{n.live&&(u(`stop`,n.live.stopUrl),Te=re({url:n.live.eventsUrl,factory:we,model:p,handle:Ee,onFinished:e=>{L.value=N&&e?N.elapsedAt(e.finishedAt):R.value},onEnd:()=>{L.value??=R.value,u(`ended`)},onDisconnected:()=>{L.value??=R.value}}),s(Te.phase,e=>b.value=e,{immediate:!0}))}),x(()=>Te?.close());let De=j(n.live!==null&&n.live!==void 0),Y=j(n.live?`ready`:`none`);s(k,e=>{e||(De.value=!1)});async function Oe(e){if(De.value=e.target.open,!De.value||Y.value!==`none`)return;Y.value=`loading`;let t=n.fetch??((...e)=>globalThis.fetch(...e));try{let e=await t(`/runs/${encodeURIComponent(n.turn.id)}/events`,{credentials:`same-origin`});if(!e.ok)throw Error(`HTTP ${e.status}`);let r=K(await e.text()).filter(e=>e.type!==`replay_note`);for(let e of(n.turn.schema??0)>=2?W(r):r)p.handle(e);p.closePhases(),Y.value=`ready`}catch{Y.value=`failed`}}let ke=F(()=>{let e=pe.value;return e>0?`${e} step${e===1?``:`s`}`:k.value?`starting`:`no steps recorded`});return(t,n)=>{let s=h(`RouterLink`);return _(),i(`div`,{class:`turn assistant flex flex-col gap-2`,"data-phase":b.value,"data-run-id":e.turn.id,"data-live":k.value?`1`:void 0},[v(`div`,Jt,[r(f,{name:`sb-rise`},{default:g(()=>[S.value?(_(),M(Kt,{key:`receipt`,route:S.value},null,8,[`route`])):D.value?(_(),i(`span`,{key:`agent`,class:d([`agent rounded border px-1.5 py-px font-medium`,C(de)[C(le)(D.value)]])},l(D.value),3)):m(``,!0)]),_:1}),O.value?(_(),i(`span`,Yt,l(O.value),1)):m(``,!0),k.value?(_(),i(`span`,Xt,l(ie.value),1)):m(``,!0)]),r(f,{name:`sb-fade`},{default:g(()=>[k.value&&H.value?(_(),M(z,{key:0,tag:`div`,verb:H.value.verb,"elapsed-ms":H.value.elapsedMs,slow:H.value.slow,model:C(y).meta?.model??e.turn.model??null},null,8,[`verb`,`elapsed-ms`,`slow`,`model`])):m(``,!0)]),_:1}),A.value?(_(),i(`p`,Zt,[n[1]||=v(`span`,null,`stream disconnected · the run may still be working`,-1),r(s,{class:`ml-auto text-primary no-underline hover:underline`,to:J.value},{default:g(()=>[...n[0]||=[w(`open the run`,-1)]]),_:1},8,[`to`])])):m(``,!0),k.value||pe.value>0||Y.value!==`none`?(_(),i(`details`,{key:1,class:`work group`,open:De.value,"data-testid":`work`,onToggle:Oe},[v(`summary`,$t,[n[2]||=v(`span`,{class:`chev select-none transition-transform duration-150 ease-out group-open:rotate-90 motion-reduce:transition-none`},`❯`,-1),v(`span`,en,l(ke.value),1)]),v(`div`,tn,[Y.value===`loading`?(_(),i(`p`,nn,`reading the run's record…`)):Y.value===`failed`?(_(),i(`p`,rn,[n[4]||=w(` the run's record could not be read — `,-1),r(s,{class:`text-primary no-underline hover:underline`,to:J.value},{default:g(()=>[...n[3]||=[w(`open the run`,-1)]]),_:1},8,[`to`])])):(_(),i(`ol`,an,[r(o,{name:`sb-rise`},{default:g(()=>[(_(!0),i(T,null,a(ue.value,e=>(_(),M(be,{key:e.key,step:e,class:`mt-3 first:mt-0`,onToggleGroup:t=>C(p).toggleGroup(e)},null,8,[`step`,`onToggleGroup`]))),128))]),_:1})]))])],40,Qt)):m(``,!0),r(f,{name:`sb-rise`},{default:g(()=>[E.value?(_(),i(`div`,on,[r(ge,{text:E.value},null,8,[`text`])])):me.value?(_(),i(`p`,sn,l(me.value),1)):m(``,!0)]),_:1}),k.value?m(``,!0):(_(),i(`div`,cn,[v(`span`,{class:d([`dur tabular-nums`,B.value?`heat`:``]),style:c(B.value)},l(ie.value),7),r(s,{class:`open text-dimmed no-underline hover:text-primary hover:underline`,to:J.value},{default:g(()=>[...n[5]||=[w(`open run`,-1)]]),_:1},8,[`to`])]))],8,qt)}}});function un(){return{runs:new Map,connected:!1}}function dn(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 fn(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 pn(e,t){return t.includes(`:`)?t:`${e}:${t}`}function mn(e){let t=e.indexOf(`:`);return t>0?e.slice(0,t):`unknown`}function hn(e,t,n){if(!t.connected)return[...e];let r=fn(t),i=new Set,a=e.map(e=>{let t=pn(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?se(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:mn(r.channelId??e)})}return o.sort((e,t)=>t.lastAt-e.lastAt),[...o,...a]}var gn={key:0,class:`mx-auto my-12 max-w-xl text-center text-toned`},_n=[`data-rail`],vn={key:0,class:`relative hidden md:block`},yn=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`],bn={class:`thread mx-auto flex min-h-[calc(100vh-8rem)] w-full max-w-3xl flex-col`},xn={key:2,class:`inline text-[0.875rem] text-toned`,"data-testid":`inline`},Sn={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`},Cn=[`href`],wn={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`},Tn=`(min-width: 48rem)`,En=u({__name:`HomePage`,setup(t){let u=E(`home`),p=B(u?.now),h=u?.conversation??``,b=y(u?.retentionDays??null),D=0,A=e=>`${e}-${++D}`,N=P([]);for(let e of u?.turns??[]){N.push({key:A(`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:u?.now}:null;N.push({key:A(`a`),kind:`assistant`,turn:e,live:t,ended:e.finished})}let L=F(()=>{for(let e=N.length-1;e>=0;e--){let t=N[e];if(t.kind===`assistant`&&t.live&&!t.ended)return t}return null}),ne=j(null),re=j(0);I(e,re);let z=j(``),V=j(void 0),se=F(()=>we(L.value!==null,z.value)),H=j(!1);s(z,()=>{V.value&&z.value===``&&(V.value=void 0)});function le(e){z.value=e,de()}async function de(){if(!u||H.value)return;let e=Je(z.value.trim(),u.commands);if(e===``)return;let t=P({key:A(`p`),kind:`person`,text:e,at:p.value,pending:!0});N.push(t),z.value=``,V.value=void 0,H.value=!0,re.value++;try{let n=await fetch(u.sendUrl,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify({text:e})}),r=await n.json().catch(()=>({}));if(n.status===202&&typeof r.viewPath==`string`&&typeof r.runId==`string`){let n=De(r.viewPath);if(!n)throw Error(`the run's view path was not one`);t.pending=!1,k.pathname()===`/threads`&&k.replaceUrl(`/threads/${encodeURIComponent(h)}`),N.push({key:A(`a`),kind:`assistant`,turn:{id:r.runId,request:e,startedAt:p.value,receivedAt:p.value,finished:!1,eventCount:0},live:{eventsUrl:n.eventsUrl,stopUrl:n.stopUrl},ended:!1});return}if(n.ok&&typeof r.reply==`string`){t.pending=!1;let e=Ee(r.reply);e.kind===`handBack`?(z.value=e.command,V.value=`Enter runs it`):e.kind===`inline`&&N.push({key:A(`i`),kind:`inline`,text:e.text});return}throw Error(r.error??`HTTP ${n.status}`)}catch(e){t.pending=!1,t.failed=`not sent: ${e instanceof Error?e.message:`error`}`}finally{H.value=!1}}function fe(){let e=ne.value;e&&fetch(`${e}${e.includes(`?`)?`&`:`?`}mode=soft`,{method:`POST`,credentials:`same-origin`})}function pe(e,t,n){let r=Ne(N.filter(e=>e.kind===`person`).map(e=>({text:e.text,folded:e.folded!==void 0,ref:e})),t);if(!r)return;let i=e.turn.receivedAt??e.turn.startedAt;r.ref.folded=n===void 0?``:`at ${ce(Math.max(0,n-i),`clock`)}`}function me(e){e.ended=!0,ne.value=null}let he=je({width:k.readPref(Z.width),collapsed:k.readPref(Z.collapsed)}),U=j(he.width),W=j(he.collapsed),_e=j(!1),G=j(k.mediaMatches(Tn)),ve=k.onMediaChange(Tn,e=>{G.value=e}),ye=j(null),be=j(null),xe=F(()=>G.value?W.value?`Show recent threads`:`Hide recent threads`:`Recent threads`);function Se(){if(G.value=k.mediaMatches(Tn),G.value){W.value=!W.value,k.writePref(Z.collapsed,W.value?`1`:`0`);return}_e.value=!0}function K(e,t){U.value=Ae(e),t&&k.writePref(Z.width,String(U.value))}let q=null;function Ce(e){q&&K(q.startWidth+(e.clientX-q.startX),!1)}function J(){window.removeEventListener(`pointermove`,Ce),q&&(q=null,k.writePref(Z.width,String(U.value)))}function Te(e){e.button===0&&(e.preventDefault(),q={startX:e.clientX,startWidth:U.value},e.currentTarget?.setPointerCapture?.(e.pointerId),window.addEventListener(`pointermove`,Ce),window.addEventListener(`pointerup`,J,{once:!0}))}function Oe(e){if(e.key===`ArrowRight`)K(U.value+X.step,!0);else if(e.key===`ArrowLeft`)K(U.value-X.step,!0);else if(e.key===`Home`)K(X.min,!0);else if(e.key===`End`)K(X.max,!0);else return;e.preventDefault()}O(()=>{window.removeEventListener(`pointermove`,Ce),window.removeEventListener(`pointerup`,J),ve()});function ke(e){let t=Re(e);if(t){if(e.preventDefault(),t===`newThread`){k.navigate(`/threads`);return}if(ye.value){ye.value.focusFilter();return}if(W.value&&k.mediaMatches(Tn)){W.value=!1,k.writePref(Z.collapsed,`0`),S().then(()=>ye.value?.focusFilter());return}_e.value=!0,S().then(()=>be.value?.focusFilter())}}let Me=j(null),Fe=j(!1);function Ie(){return document.body.scrollHeight-(window.innerHeight+window.scrollY)}s(()=>N.length,()=>{let e=Pe(Ie());S().then(()=>{e?Me.value?.scrollIntoView?.({block:`end`}):Fe.value=!0})});function Le(){Pe(Ie())&&(Fe.value=!1)}function ze(){Me.value?.scrollIntoView?.({block:`end`,behavior:`smooth`}),Fe.value=!1}ee(()=>{window.addEventListener(`scroll`,Le,{passive:!0}),window.addEventListener(`keydown`,ke),u&&We()}),x(()=>{window.removeEventListener(`scroll`,Le),window.removeEventListener(`keydown`,ke),Ue?.close()});let Q=P(un()),Be=F(()=>hn(u?.conversations??[],Q,u?.lane??``)),Ve=F(()=>{let e=L.value?.turn.id;return Q.runs.size+(e&&!Q.runs.has(e)?1:0)}),He=oe(),Ue=null;function We(){Ue=He(`/runs?stream=1&mine=1`);let e=!1;Ue.onopen=()=>{e&&Q.runs.clear(),e=!0,Q.connected=!0},Ue.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}dn(Q,t)}}let Ge=F(()=>{let e=N.find(e=>e.kind===`person`);return e?Y(e.text):`Switchboard`});s([Ge,Ve],([e,t])=>{k.setTitle(t>0?`(${t}) ${e}`:e),k.setFavicon(t>0?ae:ie)},{immediate:!0});let Ke=F(()=>new Date(p.value).getHours()),qe=F(()=>N.length===0),$=u?.elsewhere,Ye=$?$.surface===`web`?`This thread is another person's conversation. You can read it here.`:`This thread lives in ${ue[$.surface]??$.surface}.`:``;return(e,t)=>{let s=te,y=R;return _(),M(n,{title:`Threads`,nav:`home`},{leading:g(()=>[r(s,{class:`rail-toggle -ml-1`,size:`xs`,color:`neutral`,variant:`ghost`,icon:G.value&&!W.value?`i-lucide-panel-left-close`:`i-lucide-panel-left`,"aria-label":xe.value,"aria-expanded":G.value?!W.value:void 0,onClick:Se},null,8,[`icon`,`aria-label`,`aria-expanded`])]),default:g(()=>[C(u)?(_(),i(`div`,{key:1,class:d([`home gap-8 md:grid`,W.value?`md:grid-cols-[minmax(0,1fr)]`:`md:grid-cols-[var(--rail-w)_minmax(0,1fr)]`]),style:c({"--rail-w":`${U.value}px`}),"data-rail":W.value?`hidden`:`shown`},[W.value?m(``,!0):(_(),i(`aside`,vn,[r(kt,{ref_key:`rail`,ref:ye,class:`sticky top-20`,rows:Be.value,current:C(h),now:C(p),retention:C(b)},null,8,[`rows`,`current`,`now`,`retention`]),v(`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":C(X).min,"aria-valuemax":C(X).max,"aria-valuenow":U.value,tabindex:`0`,"data-testid":`rail-handle`,onPointerdown:Te,onKeydown:Oe,onDblclick:t[0]||=e=>K(C(X).default,!0)},[...t[5]||=[v(`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,yn)])),r(y,{open:_e.value,"onUpdate:open":t[1]||=e=>_e.value=e,side:`left`,title:`Recent threads`,ui:{content:`max-w-xs`}},{body:g(()=>[r(kt,{ref_key:`sheetRail`,ref:be,rows:Be.value,current:C(h),now:C(p),retention:C(b)},null,8,[`rows`,`current`,`now`,`retention`])]),_:1},8,[`open`]),v(`section`,bn,[qe.value?(_(),M(It,{key:0,class:`mb-auto mt-[clamp(1.5rem,14vh,9rem)]`,name:C(u).viewer.name,hour:Ke.value,suggestions:C(u).suggestions,onPick:le},{default:g(()=>[r(lt,{modelValue:z.value,"onUpdate:modelValue":t[2]||=e=>z.value=e,mode:se.value,hint:V.value,commands:C(u).commands,autofocus:``,"sweep-on-mount":``,onSubmit:de,onStop:fe},null,8,[`modelValue`,`mode`,`hint`,`commands`])]),_:1},8,[`name`,`hour`,`suggestions`])):(_(),M(o,{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:g(()=>[(_(!0),i(T,null,a(N,e=>(_(),i(`li`,{key:e.key},[e.kind===`person`?(_(),M(Ht,{key:0,text:e.text,at:e.at,now:C(p),pending:e.pending,folded:e.folded,failed:e.failed},null,8,[`text`,`at`,`now`,`pending`,`folded`,`failed`])):e.kind===`assistant`?(_(),M(ln,{key:1,turn:e.turn,live:e.live,now:C(p),onInput:(t,n)=>pe(e,t,n),onEnded:t=>me(e),onStop:t[3]||=e=>ne.value=e},null,8,[`turn`,`live`,`now`,`onInput`,`onEnded`])):(_(),i(`div`,xn,[r(ge,{text:e.text},null,8,[`text`])]))]))),128))]),_:1})),v(`div`,{ref_key:`end`,ref:Me,class:`end`,"aria-hidden":`true`},null,512),!qe.value&&C($)?(_(),i(`p`,Sn,[w(l(C(Ye))+` `,1),C($).url?(_(),i(`a`,{key:0,href:C($).url,target:`_blank`,rel:`noopener`,class:`text-highlighted`},`Reply there ↗`,8,Cn)):C($).surface===`web`?m(``,!0):(_(),i(T,{key:1},[w(`Reply there.`)],64))])):qe.value?m(``,!0):(_(),i(`div`,wn,[r(f,{name:`sb-rise`},{default:g(()=>[Fe.value?(_(),i(`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:ze},` ↓ new `)):m(``,!0)]),_:1}),r(lt,{modelValue:z.value,"onUpdate:modelValue":t[4]||=e=>z.value=e,mode:se.value,hint:V.value,commands:C(u).commands,autofocus:``,onSubmit:de,onStop:fe},null,8,[`modelValue`,`mode`,`hint`,`commands`])]))])],14,_n)):(_(),i(`div`,gn,`This page needs its seed.`))]),_:1})}}});export{En as default};
@@ -1 +0,0 @@
1
- import{An as e,Cn as t,Cr as n,Gr as r,Ii as i,Li as a,Mn as o,Pi as s,Sn as c,Tr as l,Xr as u,_r as d,bn as f,dr as p,ir as m,ji as h,kn as g,ln as _,rn as v,t as y,xi as b,xn as x,yn as S}from"./browser-B6T5hjfR.js";import{r as C,t as w}from"./indexFormat-B-pd4r7Y.js";import{D as T,O as E,T as D,a as O,b as k,c as A,g as j,l as M,m as ee,o as N,t as P,v as te,y as ne}from"./indexRow-BmK74Vp1.js";import"./format-BldUwl_R.js";import{a as F,n as re,t as ie}from"./durationTone-U_rOqo6r.js";import{D as I,T as L,c as ae,l as oe,n as se,t as ce,w as R}from"./sseReplay-DXC7kGbN.js";import{t as z}from"./StatusDot-BPE5syBa.js";var le={},ue={viewBox:`0 0 16 16`,class:`inline-block size-[1em] shrink-0`,"aria-hidden":`true`};function de(e,n){return d(),t(`svg`,ue,[...n[0]||=[f(`path`,{fill:`currentColor`,d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z`},null,-1)]])}var fe=F(le,[[`render`,de]]),B={"getting ready":`paint-ready`,thinking:`paint-thinking`,"in tools":`paint-tools`,"finishing up":`paint-finishing`,"Switchboard overhead":`paint-overhead`,"not recorded":`paint-lost`,"not loaded":`paint-elided`},V={getting_ready:`getting ready`,finishing_up:`finishing up`};function pe(e){return B[V[e]]}var me={id:`timeline`,class:`block mb-4 rounded-lg border border-default bg-(--ui-bg-muted) px-(--sb-gutter) py-3`,"data-testid":`timeline`},he={class:`mb-2 flex items-baseline gap-2.5 font-mono text-xs font-medium uppercase tracking-wider text-muted`},ge={class:`ml-auto flex items-baseline gap-3 font-normal normal-case tracking-normal`},_e=[`href`],ve={class:`lede font-mono text-sm text-toned`},ye={class:`shape tabular-nums`},be={key:0,class:`current text-muted`},xe={key:0,class:`note mt-0.5 text-xs text-muted`},Se=[`aria-label`],Ce=[`title`,`data-term`],we={class:`legend mt-2 flex flex-wrap gap-x-4 gap-y-1 font-mono text-xs`},Te=[`title`,`data-term`],Ee={class:`term text-muted`},De={class:`ms tabular-nums text-toned`},Oe=[`title`],ke={class:`ranked mt-1 flex flex-col gap-1 font-mono text-xs`},Ae={class:`ms w-14 shrink-0 tabular-nums text-toned`},je=[`href`,`data-anchor`,`onClick`],H=o({__name:`TimelineSection`,props:{vm:{},eventsHref:{}},emits:[`reveal`],setup(e,{emit:r}){let o=e,l=r;function u(e){return`${E(e.ms,`clock`)} ${e.term}${e.hatched?` (in flight)`:``}`}function p(){y.copyText(JSON.stringify(o.vm.debug,null,2))}return(r,o)=>(d(),t(`section`,me,[f(`h2`,he,[o[0]||=f(`span`,null,`Where the time went`,-1),f(`span`,ge,[e.eventsHref?(d(),t(`a`,{key:0,class:`text-dimmed no-underline hover:text-primary hover:underline`,href:e.eventsHref,title:`the stored events, as JSON lines`},`raw events`,8,_e)):c(``,!0),f(`button`,{type:`button`,class:`debug cursor-pointer text-dimmed hover:text-toned`,title:`the partition and the raw span names, for a bug report`,onClick:p},` Copy debug JSON `)])]),f(`p`,ve,[f(`span`,ye,a(e.vm.shown?e.vm.total:e.vm.lede),1),e.vm.current?(d(),t(`span`,be,` · `+a(e.vm.current),1)):c(``,!0)]),(d(!0),t(_,null,n(e.vm.captions,e=>(d(),t(`p`,{key:e,class:`caption mt-0.5 text-xs text-muted`},a(e),1))),128)),e.vm.note?(d(),t(`p`,xe,a(e.vm.note),1)):c(``,!0),e.vm.shown?(d(),t(_,{key:1},[f(`div`,{class:`bar mt-2.5 flex h-2 w-full overflow-hidden rounded-sm`,role:`img`,"aria-label":e.vm.lede},[(d(!0),t(_,null,n(e.vm.bar,(e,n)=>(d(),t(`div`,{key:n,class:s([`seg h-full`,[h(B)[e.term],e.hatched?`paint-hatched hatched`:``]]),style:i({width:`${e.pct}%`}),title:u(e),"data-term":e.term},null,14,Ce))),128))],8,Se),f(`ul`,we,[(d(!0),t(_,null,n(e.vm.legend,e=>(d(),t(`li`,{key:e.term,class:`flex items-baseline gap-1.5 cursor-help`,title:e.definition,"data-term":e.term},[f(`span`,{class:s([`swatch inline-block size-2 shrink-0 self-center rounded-[2px]`,h(B)[e.term]])},null,2),f(`span`,Ee,a(e.term),1),f(`span`,De,a(e.text),1)],8,Te))),128))]),e.vm.ranked.length>0?(d(),t(_,{key:0},[f(`h3`,{class:`ranked-head mt-3 inline-block cursor-help text-xs font-medium text-muted underline decoration-dotted decoration-(--ui-border-accented) underline-offset-2`,title:e.vm.rankedNote},` Longest steps `,8,Oe),f(`ol`,ke,[(d(!0),t(_,null,n(e.vm.ranked,(e,r)=>(d(),t(`li`,{key:r,class:`flex items-baseline gap-2`},[f(`span`,Ae,a(h(E)(e.ms,`clock`)),1),f(`a`,{class:`label min-w-0 truncate text-muted no-underline hover:text-primary hover:underline`,href:`#${e.anchor}`,"data-anchor":e.anchor,title:`scroll to this step`,onClick:v(t=>l(`reveal`,e.anchor),[`prevent`])},a(e.label),9,je),(d(!0),t(_,null,n(e.facts,e=>(d(),t(`span`,{key:e,class:`fact shrink-0 rounded border border-accented px-1 text-dimmed`},a(e),1))),128))]))),128))])],64)):c(``,!0)],64)):c(``,!0)]))}});function Me(e,t){let{window:n,owner:r,finished:i}=t,a=Math.max(0,n.end-n.start),o=new Map(e.map(e=>[e.spanId,e])),s=new Map,c=e=>{let t=s.get(e.spanId);if(t!==void 0)return t;s.set(e.spanId,1);let n=e.parentSpanId?o.get(e.parentSpanId):void 0,r=n?c(n)+1:1;return s.set(e.spanId,r),r},l=e=>{let t=e,n=new Set;for(;t&&!n.has(t.spanId);){if(n.add(t.spanId),L(t.name,r)?.kind===`background`)return!0;t=t.parentSpanId?o.get(t.parentSpanId):void 0}return!1},u=t.losses.map(e=>Math.max(n.start,e.from)).sort((e,t)=>e-t),d=e=>{if(e.endedAt!==void 0)return Math.min(n.end,e.endedAt);if(!i)return n.end;let t=u.find(t=>t>e.startedAt);return t===void 0?n.end:Math.min(n.end,t)},f=[],p=[];for(let t of e){let e=L(t.name,r);if(!e)continue;let i=Math.max(n.start,t.startedAt);if(e.kind===`background`){let e=Math.min(n.end,t.endedAt??n.end);e>i&&p.push([i,e]);continue}if(e.kind!==`counted`||l(t))continue;let a=d(t);a<=i||f.push({start:i,end:a,bucket:e.bucket,depth:c(t),startedAt:t.startedAt,spanId:t.spanId})}f.sort((e,t)=>t.depth-e.depth||e.startedAt-t.startedAt||(e.spanId<t.spanId?-1:+(e.spanId>t.spanId)));let m=new Set([n.start,n.end]);for(let e of f)m.add(e.start),m.add(e.end);for(let e of t.losses)m.add(U(e.from,n)),m.add(U(e.to,n));for(let[e,t]of p)m.add(e),m.add(t);let h=[...m].filter(e=>e>=n.start&&e<=n.end).sort((e,t)=>e-t),g={getting_ready:0,thinking:0,tools:0,finishing_up:0},_=0,v=0,y=0;for(let e=0;e+1<h.length;e++){let r=h[e],i=h[e+1],a=i-r;if(a<=0)continue;let o=f.find(e=>e.start<=r&&e.end>=i);if(o){g[o.bucket]+=a;continue}if(t.losses.some(e=>e.kind===`lost`&&U(e.from,n)<=r&&U(e.to,n)>=i)){_+=a;continue}if(t.losses.some(e=>e.kind===`elided`&&U(e.from,n)<=r&&U(e.to,n)>=i)){v+=a;continue}p.some(([e,t])=>e<=r&&t>=i)&&(y+=a)}let b=g.getting_ready+g.thinking+g.tools+g.finishing_up;return{windowMs:a,gettingReadyMs:g.getting_ready,thinkingMs:g.thinking,toolsMs:g.tools,finishingUpMs:g.finishing_up,overheadMs:Math.max(0,a-b-_-v),notRecordedMs:_,notLoadedMs:v,backgroundOnlyMs:y}}function U(e,t){return Math.min(t.end,Math.max(t.start,e))}function Ne(e){let t=Math.floor(e.windowMs/1e3),n=[[`getting ready`,Math.floor(e.gettingReadyMs/1e3)],[`thinking`,Math.floor(e.thinkingMs/1e3)],[`in tools`,Math.floor(e.toolsMs/1e3)],[`finishing up`,Math.floor(e.finishingUpMs/1e3)],[`not recorded`,Math.floor(e.notRecordedMs/1e3)],[`not loaded`,Math.floor(e.notLoadedMs/1e3)]],r=n.reduce((e,[,t])=>e+t,0),i=n.filter(([,e])=>e>0).map(([e,t])=>({term:e,s:t})),a=t-r;a>0&&i.push({term:`Switchboard overhead`,s:a});let o=[`getting ready`,`thinking`,`in tools`,`finishing up`,`Switchboard overhead`,`not recorded`,`not loaded`];return i.sort((e,t)=>o.indexOf(e.term)-o.indexOf(t.term)),{totalS:t,items:i}}function Pe(e){return[e.gettingReadyMs,e.thinkingMs,e.toolsMs,e.finishingUpMs,e.overheadMs,e.notRecordedMs,e.notLoadedMs].filter(t=>t>=2e3||e.windowMs>0&&t/e.windowMs>=.05).length>=2}function W(e,t){if(t===void 0||t<6e4)return;let n=E(t,`clock`);return e===`before`?`queued ${n} before we saw it`:`queued ${n} behind the previous run`}var G={"getting ready":`before the agent's first turn: reading the thread, finding the repo, checking out, loading tools`,thinking:`the model's turns — from a request to the model until its reply came back`,"in tools":`the commands and tool calls the model ran`,"finishing up":`after the agent's last turn: posting the PR, checking the workspace`,"Switchboard overhead":`orchestration between steps, and moments when only a background read was running — the time no step claims`,"not recorded":`a stretch of the run the record does not carry`,"not loaded":`a stretch of the run this page did not load — the record has the full shape`},K=`Ranked by each step's own time, its children excluded — the bar counts every instant once.`,Fe=`currently delivering`,Ie=`getting ready: not recorded (too large)`,Le=`no timing data`,Re=`not loaded (the record has the full shape)`,q={getting_ready:`getting ready`,thinking:`thinking`,tools:`in tools`,finishing_up:`finishing up`};function J(e){let{spans:t,window:n,owner:r}=e,i=e.phase!==`live`,a=Me(t,{window:n,owner:r,finished:i,losses:e.losses}),o=Ne(a),s=E(o.totalS*1e3,`clock`),c=t.find(e=>e.name===`request`&&e.parentSpanId===void 0),l=e.phase===`live`?ze(t,r,n):void 0,u=Be(e,l),d=l?R(l.name):``,f={window:n,owner:r,phase:e.phase,partition:a,spans:t.map(e=>({spanId:e.spanId,parentSpanId:e.parentSpanId,name:e.name,startedAt:e.startedAt,endedAt:e.endedAt,status:e.status,attrs:e.attrs}))};if(e.untimed)return{total:s,current:u,openStep:d,captions:[],rankedNote:K,debug:f,lede:s,shown:!1,bar:[],legend:[],ranked:[],note:Le};let p={total:s,current:u,openStep:d,captions:[W(`before`,Y(c,`queuedBeforeMs`)),W(`behind`,Y(c,`queuedBehindMs`))].filter(e=>e!==void 0),rankedNote:K,debug:f};if(!c)return{...p,lede:s,shown:!1,bar:[],legend:[],ranked:[],note:i?Ie:``};let m=t=>t===`not recorded`?`not recorded${e.truncated?` (too large)`:``}`:t===`not loaded`?Re:t,h=Pe(a)&&o.items.length>0,g=h?`${s} — ${o.items.map(({term:e,s:t})=>`${E(t*1e3,`clock`)} ${m(e)}`).join(` · `)}`:a.windowMs>0?`${s} — ${m(Ve(a))}`:s,_=h?o.items.map(({term:t,s:n})=>({term:t,text:E(n*1e3,`clock`),definition:t===`not recorded`&&e.truncated?`${G[t]} (too large)`:G[t]})):[];return{...p,lede:g,shown:h,bar:h?He(a,l):[],legend:_,ranked:h?Ue(t,c,r,n,e.callTitle):[],note:``}}function Y(e,t){let n=e?.attrs[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function ze(e,t,n){let r=new Map(e.map(e=>[e.spanId,e])),i=e=>{let t=1,n=new Set([e.spanId]),i=e.parentSpanId?r.get(e.parentSpanId):void 0;for(;i&&!n.has(i.spanId);)n.add(i.spanId),t++,i=i.parentSpanId?r.get(i.parentSpanId):void 0;return t},a;for(let o of e){if(o.endedAt!==void 0||o.startedAt>=n.end)continue;let e=L(o.name,t);if(e?.kind!==`counted`||X(o,r,t))continue;let s=i(o);(!a||s>a.depth||s===a.depth&&o.startedAt>a.span.startedAt)&&(a={span:o,depth:s,bucket:e.bucket})}if(a)return{bucket:a.bucket,name:a.span.name,elapsedMs:Math.max(0,n.end-Math.max(n.start,a.span.startedAt))}}function X(e,t,n){let r=e,i=new Set;for(;r&&!i.has(r.spanId);){if(i.add(r.spanId),L(r.name,n)?.kind===`background`)return!0;r=r.parentSpanId?t.get(r.parentSpanId):void 0}return!1}function Be(e,t){return e.phase===`delivering`?Fe:e.phase===`ended`?oe(e.delivery??{}):t?`currently ${q[t.bucket]} ${E(t.elapsedMs,`clock`)}`:``}function Z(e){return[[`getting ready`,e.gettingReadyMs],[`thinking`,e.thinkingMs],[`in tools`,e.toolsMs],[`finishing up`,e.finishingUpMs],[`Switchboard overhead`,e.overheadMs],[`not recorded`,e.notRecordedMs],[`not loaded`,e.notLoadedMs]]}function Ve(e){let t=[`getting ready`,-1];for(let n of Z(e))n[1]>t[1]&&(t=n);return t[0]}function He(e,t){let n=[],r=t=>e.windowMs>0?t/e.windowMs*100:0;for(let[i,a]of Z(e))if(!(a<=0)){if(t&&q[t.bucket]===i){let e=Math.min(t.elapsedMs,a);a-e>0&&n.push({term:i,ms:a-e,pct:r(a-e),hatched:!1}),e>0&&n.push({term:i,ms:e,pct:r(e),hatched:!0});continue}n.push({term:i,ms:a,pct:r(a),hatched:!1})}return n}function Ue(e,t,n,r,i){let a=new Map(e.map(e=>[e.spanId,e])),o=new Map;for(let t of e){if(t.parentSpanId===void 0)continue;let e=o.get(t.parentSpanId);e?e.push(t):o.set(t.parentSpanId,[t])}let s=e=>[Math.max(r.start,e.startedAt),Math.min(r.end,e.endedAt??r.end)],c=[];for(let r of e){if(r===t||r.name===`run.agent`||L(r.name,n)===void 0||X(r,a,n))continue;let[e,l]=s(r);if(l<=e)continue;let u=(o.get(r.spanId)??[]).map(s).map(([t,n])=>[Math.max(e,t),Math.min(l,n)]).filter(([e,t])=>t>e),d=l-e-We(u);if(d<=0)continue;let f=r.name.startsWith(`tool.`)&&typeof r.attrs.callId==`string`?r.attrs.callId:void 0,p=f?i?.(f):void 0;c.push({label:p??R(r.name),ms:d,facts:Ge(r),anchor:f?`call-${f}`:`span-${r.spanId}`,startedAt:r.startedAt})}return c.sort((e,t)=>t.ms-e.ms||e.startedAt-t.startedAt),c.slice(0,3).map(({label:e,ms:t,facts:n,anchor:r})=>({label:e,ms:t,facts:n,anchor:r}))}function We(e){let t=[...e].sort((e,t)=>e[0]-t[0]),n=0,r;for(let[e,i]of t)!r||e>r[1]?(r&&(n+=r[1]-r[0]),r=[e,i]):i>r[1]&&(r[1]=i);return r&&(n+=r[1]-r[0]),n}function Ge(e){let t=e.attrs,n=[];return(t.token===`expired`||t.token===`expiring`)&&n.push(`token ${t.token}`),t.budget===`clipped`&&n.push(`budget clipped`),typeof t.timeoutMs==`number`&&n.push(`timeout ${E(t.timeoutMs,`clock`)}`),typeof t.waitedMs==`number`&&n.push(`waited ${E(t.waitedMs,`clock`)}`),typeof t.exitCode==`number`&&t.exitCode!==0&&n.push(`exit ${t.exitCode}`),t.timedOut===!0&&n.push(`timed out`),typeof t.attempts==`number`&&t.attempts>1&&n.push(`${t.attempts} attempts`),e.status===`error`&&n.length===0&&n.push(`failed`),n}function Q(e){return e===`command`?`command`:`agent`}var Ke=[`data-state`],qe={key:0,class:`loading py-2 font-mono text-xs text-dimmed`},Je={key:1,class:`failed py-2 font-mono text-xs text-warn`},Ye=[`data-turn`,`data-anchor`],Xe={class:`landing-head flex flex-wrap items-baseline gap-x-2 font-mono text-xs text-muted`},Ze={class:`turn tabular-nums`},Qe={class:`what min-w-0 truncate text-toned`},$e={key:0,class:`m-0 mt-1 list-none p-0`},et=o({__name:`RunTimeline`,props:{run:{},land:{},fetch:{}},setup(n){let i=n,o=b(`loading`),s=ae(),v=S(()=>{if(o.value!==`ready`)return null;s.state.traceVersion;let e=i.run,t=e.receivedAt??e.startedAt,n=T(e)??(e.finishedAt===void 0?0:Math.max(0,e.finishedAt-t));return J({spans:s.spanSet(),losses:s.losses(t),window:{start:t,end:t+n},owner:Q(e.agent),totalMs:n,phase:`ended`,delivery:{finishedAt:e.finishedAt,sealedAt:e.sealedAt,replyOk:e.replyOk},...e.truncated===void 0?{}:{truncated:e.truncated},...(e.schema??0)>=2?{}:{untimed:!0},callTitle:s.callHeadline})}),x=S(()=>`/runs/${encodeURIComponent(i.run.id)}/events`),C=e=>`/runs/${encodeURIComponent(i.run.id)}#${e}`;function w(e){y.navigate(C(e))}let E=S(()=>{if(o.value!==`ready`||i.land===void 0)return null;s.state.traceVersion;let e=i.land,t=i.run.session;if(t&&e===t.request)return{anchor:`request`,what:`the request`};let n=t&&t.range!==`broken`?t.range.to:void 0;if(n!==void 0&&e===n&&s.state.reply)return{anchor:`reply`,what:`the reply`};let r=s.landing(e);return r?{anchor:r.anchor,what:D(r.step),step:r.step}:null});function D(e){let t=e.items.find(e=>e.kind===`call`),n=t?.kind===`call`?t.call.headline:void 0;return[e.turn?`thought ${e.turn.chip}`:void 0,n].filter(e=>e!==void 0).join(` · `)||`step ${e.index+1}`}let O=b(null),k=S(()=>E.value?`${i.land}@${E.value.anchor}`:null);return r(k,e=>{e!==null&&m().then(()=>{let e=(E.value?.step?O.value?.querySelector(`li.step`):null)??O.value;e&&(e.scrollIntoView?.({block:`center`}),e.classList.add(`revealed`),setTimeout(()=>e.classList.remove(`revealed`),1500))})}),p(async()=>{let e=i.fetch??((...e)=>globalThis.fetch(...e));try{let t=await e(x.value,{credentials:`same-origin`});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=ce(await t.text()).filter(e=>e.type!==`replay_note`);for(let e of(i.run.schema??0)>=2?I(n):n)s.handle(e);s.closePhases(),o.value=`ready`}catch{o.value=`failed`}}),(r,i)=>{let p=l(`RouterLink`);return d(),t(`div`,{class:`runtimeline pl-5`,"data-state":o.value},[o.value===`loading`?(d(),t(`p`,qe,`reading the run's record…`)):o.value===`failed`?(d(),t(`p`,Je,[i[2]||=g(` the run's record could not be read — `,-1),e(p,{class:`text-primary no-underline hover:underline`,to:`/runs/${encodeURIComponent(n.run.id)}`},{default:u(()=>[...i[1]||=[g(`open the run`,-1)]]),_:1},8,[`to`])])):v.value?(d(),t(_,{key:2},[e(H,{vm:v.value,"events-href":x.value,onReveal:w},null,8,[`vm`,`events-href`]),E.value?(d(),t(`div`,{key:0,ref_key:`landingEl`,ref:O,class:`landing mb-4 rounded-lg border border-default px-(--sb-gutter) py-2`,"data-turn":n.land,"data-anchor":E.value.anchor},[f(`p`,Xe,[f(`span`,Ze,`turn `+a(n.land),1),f(`span`,Qe,`· `+a(E.value.what),1),e(p,{class:`page ml-auto shrink-0 text-primary no-underline hover:underline`,to:C(E.value.anchor),title:`the same step on the run's own page`},{default:u(()=>[...i[3]||=[g(`open on the run's page ↗`,-1)]]),_:1},8,[`to`])]),E.value.step?(d(),t(`ol`,$e,[e(se,{step:E.value.step,onToggleGroup:i[0]||=e=>h(s).toggleGroup(E.value.step)},null,8,[`step`])])):c(``,!0)],8,Ye)):c(``,!0)],64)):c(``,!0)],8,Ke)}}}),tt=[`id`,`data-run-id`,`data-round`,`data-thread`],$=[`open`],nt={class:`row flex min-w-0 cursor-pointer list-none flex-wrap items-center gap-x-2.5 gap-y-1 px-2 py-2 hover:bg-(--ui-bg-muted) [&::-webkit-details-marker]:hidden`},rt={key:0,class:`round shrink-0 rounded border border-accented px-1.5 font-mono text-[0.7rem] font-medium tabular-nums text-toned`},it={key:2,class:`snippet min-w-0 flex-1 truncate text-muted`},at={key:3,class:`scope min-w-0 flex-1 truncate text-toned`},ot=[`title`],st=[`data-heat`],ct={class:`count shrink-0 text-right font-mono text-xs tabular-nums text-dimmed sm:min-w-[6em]`},lt={key:1,class:`row flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-1 px-2 py-2 hover:bg-(--ui-bg-muted)`},ut={key:0,class:`round shrink-0 rounded border border-accented px-1.5 font-mono text-[0.7rem] font-medium tabular-nums text-toned`},dt={key:2,class:`snippet min-w-0 flex-1 truncate text-muted`},ft={key:3,class:`scope min-w-0 flex-1 truncate text-highlighted`},pt=[`title`],mt={class:`elapsed shrink-0 text-right font-mono text-xs tabular-nums text-ok sm:min-w-[4.5em]`,title:`running for`},ht={class:`count shrink-0 text-right font-mono text-xs tabular-nums text-dimmed sm:min-w-[6em]`},gt=o({__name:`RunFoldRow`,props:{run:{},now:{},label:{},open:{type:Boolean},land:{}},setup(n){let o=n,p=b(o.open===!0);r(()=>o.open,e=>{e&&(p.value=!0)});let m=S(()=>C(o.run.label||j(o.run.id))),_=S(()=>te(o.run)),y=S(()=>ee(o.run)),T=S(()=>o.run.finished),E=S(()=>o.run.finished&&o.run.status&&o.run.status!==`completed`?ne(o.run.status):``),F=S(()=>ie(o.run.finished&&typeof o.run.finishedAt==`number`?o.run.finishedAt-o.run.startedAt:void 0,`run`)),I=S(()=>re(F.value));function L(e){p.value=e.target.open}return(r,o)=>{let b=l(`RouterLink`);return d(),t(`li`,{id:`run-${n.run.id}`,class:s([`fold group border-b border-muted`,n.run.finished?`finished`:`live`]),"data-run-id":n.run.id,"data-round":n.run.round,"data-thread":n.run.thread},[T.value?(d(),t(`details`,{key:0,class:`group/fold`,open:p.value,onToggle:L},[f(`summary`,nt,[o[2]||=f(`span`,{class:`chev select-none text-xs text-dimmed transition-transform group-open/fold:rotate-90 motion-reduce:transition-none`,"aria-hidden":`true`},`❯`,-1),e(z,{tone:_.value,label:h(k)(n.run),tip:h(A)(n.run)},null,8,[`tone`,`label`,`tip`]),n.label?(d(),t(`span`,rt,a(n.label),1)):c(``,!0),m.value.agent?(d(),t(`span`,{key:1,class:s([`agent shrink-0 rounded border px-1.5 font-mono text-[0.68rem] font-medium uppercase tracking-wider opacity-55`,h(P)[h(O)(m.value.agent)]])},a(m.value.agent),3)):c(``,!0),m.value.snippet===void 0?(d(),t(`span`,at,a(m.value.scope),1)):(d(),t(`span`,it,a(m.value.snippet),1)),E.value?(d(),t(`span`,{key:4,class:s([`outcome shrink-0 rounded border px-1.5 font-mono text-[0.7rem]`,_.value===`red`?`border-bad/30 text-bad`:`border-warn/30 text-warn`])},a(E.value),3)):c(``,!0),f(`span`,{class:`when shrink-0 font-mono text-xs tabular-nums text-dimmed`,title:h(D)(n.run)},a(h(w)(n.run.startedAt,n.now)),9,ot),f(`span`,{class:s([`elapsed shrink-0 text-right font-mono text-xs tabular-nums sm:min-w-[4.5em]`,[I.value?`heat`:`text-muted`,F.value.level>=2?`font-medium`:``]]),style:i(I.value),"data-heat":F.value.level,title:`start to finish`},a(h(M)(n.run,n.now)),15,st),f(`span`,ct,a(h(N)(n.run)),1),e(b,{class:`open shrink-0 font-mono text-xs text-primary no-underline hover:underline`,to:y.value,"aria-label":`open run ${n.run.label||h(j)(n.run.id)}`,onClick:o[0]||=v(()=>{},[`stop`])},{default:u(()=>[...o[1]||=[g(`open ↗`,-1)]]),_:1},8,[`to`,`aria-label`])]),p.value?(d(),x(et,{key:0,run:n.run,land:n.land},null,8,[`run`,`land`])):c(``,!0)],40,$)):(d(),t(`div`,lt,[o[4]||=f(`span`,{class:`chev select-none text-xs text-transparent`,"aria-hidden":`true`},`❯`,-1),e(z,{tone:_.value,label:h(k)(n.run),tip:h(A)(n.run),pulse:``},null,8,[`tone`,`label`,`tip`]),n.label?(d(),t(`span`,ut,a(n.label),1)):c(``,!0),m.value.agent?(d(),t(`span`,{key:1,class:s([`agent shrink-0 rounded border px-1.5 font-mono text-[0.68rem] font-medium uppercase tracking-wider`,h(P)[h(O)(m.value.agent)]])},a(m.value.agent),3)):c(``,!0),m.value.snippet===void 0?(d(),t(`span`,ft,a(m.value.scope),1)):(d(),t(`span`,dt,a(m.value.snippet),1)),f(`span`,{class:`when shrink-0 font-mono text-xs tabular-nums text-muted`,title:h(D)(n.run)},a(h(w)(n.run.startedAt,n.now)),9,pt),f(`span`,mt,a(h(M)(n.run,n.now)),1),f(`span`,ht,a(h(N)(n.run)),1),e(b,{class:`open shrink-0 font-mono text-xs text-primary no-underline hover:underline`,to:y.value,"aria-label":`open run ${n.run.label||h(j)(n.run.id)}`},{default:u(()=>[...o[3]||=[g(`open ↗`,-1)]]),_:1},8,[`to`,`aria-label`])]))],10,tt)}}});export{pe as a,H as i,Q as n,fe as o,J as r,gt as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./format-BldUwl_R.js";function t(e,t){if(e===void 0)return``;switch(t){case`precise`:return n(e);case`clock`:return r(e);case`report`:return i(e)}}function n(e){if(!(e>=0))return`0ms`;if(e<1e3)return`${Math.round(e)}ms`;let t=Math.round(e/100);if(t<600)return`${(t/10).toFixed(1)}s`;let n=Math.round(e/1e3);return`${Math.floor(n/60)}m ${a(n%60)}s`}function r(e){if(!(e>0))return`0s`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${a(t%60)}s`:`${Math.floor(n/60)}h ${a(n%60)}m`}function i(e){if(!(e>=0))return`0ms`;if(e<1e3)return`${Math.round(e)}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${a(t%60)}s`:`${Math.floor(n/60)}h ${a(n%60)}m`}function a(e){return e<10?`0${e}`:String(e)}function o(e,t){let n=e.finishedAt??t;if(n!==void 0)return Math.max(0,n-(e.receivedAt??e.startedAt))}function s(e){return e===`completed`?`succeeded`:e===`stopped_soft`?`stopped early`:e===`stopped_hard`?`killed`:e}function c(e){return e.state===`stopped`?s(`stopped_${e.mode}`):`${e.state} (${e.mode})`}function l(e){return e.finished?e.status?s(e.status):`finished`:`live`}function u(e){return e.finished&&!e.persisted&&e.sealedAt===void 0}function d(e){return e.finished?u(e)?`amber`:e.status===`failed`||e.status===`stopped_hard`||e.status===`interrupted`?`red`:e.status===`stopped_soft`?`amber`:`grey`:`green`}function f(e){return e===`coding`||e===`review`||e===`research`||e===`general`?e:`other`}var p={coding:`text-ok bg-ok/8 border-ok/25`,review:`text-review bg-review/8 border-review/25`,research:`text-research bg-research/8 border-research/25`,general:`text-info bg-info/8 border-info/25`,other:`text-toned bg-accented/60 border-accented`};function m(e){let t=e.stepCount??e.eventCount;return`${t} event${t===1?``:`s`}`}function h(e){return e.stepCount===void 0?`events published, span records included`:`content events; span records excluded`}function g(e){return`/runs/${encodeURIComponent(e.id)}${!e.finished&&e.token?`?t=${encodeURIComponent(e.token)}`:``}`}function _(e,t){return`/runs/${encodeURIComponent(e.id)}/stop?t=${encodeURIComponent(e.token??``)}&mode=${encodeURIComponent(t)}`}function v(e){return e.length>8?`${e.slice(0,8)}…`:e}function y(e,n){let r=o(e,e.finished?void 0:n);return r===void 0?``:t(r,`clock`)}function b(e){return typeof e.receivedAt==`number`?` (received to finish)`:``}function x(e){let t=e.channelId??``,n=t.indexOf(`:`),r=n===-1?`unknown`:t.slice(0,n);if(e.userName)return{kind:r,identity:e.userName};let i=e.userId??``,a=i.indexOf(`:`);return{kind:r,identity:a===-1?i:i.slice(a+1)}}function S(e){return`/threads/${encodeURIComponent(e)}`}var C={mine:`sb.runs.mine`,all:`sb.runs.all`},w={slack:`Slack`,http:`HTTP ingress`,mcp:`MCP`,cli:`CLI`,web:`Web`};function T(e){if(!e.finished)return e.activity?`now: ${e.activity}`:`starting…`;let n=l(e),r=o(e);return r!==void 0&&(n+=` in ${t(r,`clock`)}${b(e)}`),u(e)&&(n+=` · delivering the reply`),e.status&&e.status!==`completed`&&e.activity&&(n+=`\n${e.activity}`),n}function E(t){let n=typeof t.receivedAt==`number`?`received ${e(t.receivedAt)}\n`:``;return n+=`started ${e(t.startedAt)}`,t.finished&&typeof t.finishedAt==`number`&&(n+=`\nfinished ${e(t.finishedAt)}`),n}function D(e){let t=x(e);return`via ${w[t.kind]??t.kind}${t.identity?` · ${t.identity}`:``}`}function O(e){return x(e).identity}function k(e,t){return e.repo??(/^[\w.-]+\/[\w.-]+$/.test(t)?t:``)}function A(e){return e.sourceUrl&&/^https?:\/\//.test(e.sourceUrl)?e.sourceUrl:``}function j(e,t,n){return e.type===`upsert`&&e.run?!t&&e.run.finished?{op:`remove`,id:e.run.id}:{op:`upsert`,run:e.run}:e.type===`removed`&&e.id?t&&n?{op:`keep`}:{op:`remove`,id:e.id}:{op:`keep`}}function M(e,t){if(!e||!e.finished)return t;let n={...t};return n.finishedAt===void 0&&e.finishedAt!==void 0&&(n.finishedAt=e.finishedAt),n.status===void 0&&e.status!==void 0&&(n.status=e.status),n.receivedAt===void 0&&e.receivedAt!==void 0&&(n.receivedAt=e.receivedAt),n.sealedAt===void 0&&e.sealedAt!==void 0&&(n.sealedAt=e.sealedAt),n.replyOk===void 0&&e.replyOk!==void 0&&(n.replyOk=e.replyOk),n}function N(e,t){return e.finished&&typeof e.finishedAt==`number`&&typeof t==`number`?e.finishedAt+t:void 0}var P=864e5;export{x as C,o as D,O as E,t as O,c as S,E as T,D as _,f as a,l as b,T as c,j as d,M as f,v as g,A as h,w as i,y as l,g as m,P as n,m as o,k as p,C as r,h as s,p as t,N as u,d as v,S as w,_ as x,s as y};
@@ -1,9 +0,0 @@
1
- import{An as e,Cn as t,Cr as n,Gr as r,Ii as i,Li as a,Mn as o,Pi as s,Sn as c,Zn as l,_r as u,bn as d,dr as f,ji as p,kn as m,ln as h,rn as g,xi as _,xn as v,yi as y,yn as b}from"./browser-B6T5hjfR.js";import{n as x}from"./wallClock-DmaC1sKA.js";import{D as S,O as C}from"./indexRow-BmK74Vp1.js";import{i as w,n as T,t as E}from"./format-BldUwl_R.js";import{n as D,r as O,t as k}from"./durationTone-U_rOqo6r.js";var A=`A-Za-z0-9:@._-`;RegExp(`^[${A}]{1,128}$`),RegExp(`[^${A}]`,`g`);function j(e){return e.type===`span_start`||e.type===`span_end`}function M(e,t){return/^[A-Za-z0-9_-]{1,64}$/.test(e)?`synth:${e}`:`synth:${t}`}function N(e){let t=[];for(let n of e)n.type===`span_end`&&n.name===`run.agent`&&t.push({spanId:n.spanId,startedAt:n.startedAt,endedAt:n.startedAt+n.durationMs});return t}function P(e,t){let n;for(let r of e)r.startedAt<=t&&t<=r.endedAt&&(!n||r.endedAt-r.startedAt<n.endedAt-n.startedAt)&&(n=r);return n?.spanId}function ee(e){let t=N(e),n=new Set;for(let t of e){if(!j(t))continue;let e=t.attrs??{};t.name.startsWith(`tool.`)&&typeof e.callId==`string`&&n.add(e.callId)}let r=[],i=new Map;return e.forEach((e,a)=>{switch(e.type){case`tool_call`:{let o=e.callId;if(o===void 0||e.at===void 0||n.has(o)){r.push(e);return}let s=M(o,a);r.push(F(s,`tool.${e.tool}`,e.at,P(t,e.at),{callId:o}),e),i.set(o,{spanId:s,startedAt:e.at});return}case`tool_result`:{if(r.push(e),e.callId===void 0)return;let n=i.get(e.callId);if(!n)return;i.delete(e.callId);let a=e.at??n.startedAt,o={ok:e.ok,callId:e.callId};e.exitCode!==void 0&&(o.exitCode=e.exitCode),e.infra&&(o.infra=!0),r.push(I(n.spanId,`tool.${e.tool}`,n.startedAt,Math.max(0,a-n.startedAt),P(t,n.startedAt),o,e.ok?`ok`:`error`));return}default:r.push(e)}}),r}function F(e,t,n,r,i){return{type:`span_start`,spanId:e,...r===void 0?{}:{parentSpanId:r},name:t,...i?{attrs:i}:{},at:n}}function I(e,t,n,r,i,a,o=`ok`){return{type:`span_end`,spanId:e,...i===void 0?{}:{parentSpanId:i},name:t,startedAt:n,durationMs:r,status:o,...a?{attrs:a}:{},at:n+r}}function te(e,t,n){let r=e.get(t.spanId);if(t.type===`span_start`){if(r)return;e.set(t.spanId,{traceId:n,spanId:t.spanId,...t.parentSpanId===void 0?{}:{parentSpanId:t.parentSpanId},name:t.name,startedAt:t.at??0,attrs:t.attrs??{}});return}e.set(t.spanId,{traceId:n,spanId:t.spanId,...t.parentSpanId===void 0?r?.parentSpanId===void 0?{}:{parentSpanId:r.parentSpanId}:{parentSpanId:t.parentSpanId},name:t.name,startedAt:t.startedAt,endedAt:t.startedAt+t.durationMs,durationMs:t.durationMs,status:t.status,...t.error===void 0?{}:{errorMessage:t.error},attrs:{...r?.attrs??{},...t.attrs??{}}})}function ne(){let e,t,n=[];return{push(r){e?t&&r.seq!==void 0&&t.seq!==void 0&&r.seq>t.seq+1&&t.at!==void 0&&r.at!==void 0&&n.push({kind:`gap`,fromSeq:t.seq+1,toSeq:r.seq-1,from:Math.min(t.at,r.at),to:Math.max(t.at,r.at)}):e={seq:r.seq??1,at:r.at},r.type===`run_note`&&r.kind===`spans_dropped`&&r.from!==void 0&&r.to!==void 0&&r.to>=r.from&&n.push({kind:`note`,from:r.from,to:r.to}),t={seq:r.seq,at:r.at}},losses(t={}){let r=t.elided??[],i=(e,t)=>r.some(n=>n.fromSeq<=e&&t<=n.toSeq),a=[];e&&e.seq>1&&t.windowStart!==void 0&&e.at!==void 0&&e.at>t.windowStart&&a.push({from:t.windowStart,to:e.at,kind:`lost`});for(let e of n)a.push(e.kind===`note`?{from:e.from,to:e.to,kind:`lost`}:{from:e.from,to:e.to,kind:i(e.fromSeq,e.toSeq)?`elided`:`lost`});return a}}}function re(e,t){let n=e.ownerDocument;e.textContent=``;let r=String(t??``).replace(/\r\n?/g,`
2
- `).split(`
3
- `),i=/^(\s*)([-*]|\d+[.)])\s+(.*)$/,a=/^(```|#{1,6}\s|>)/;function o(e,t){let r=n.createElement(t);return e.appendChild(r),r}function s(e,t){t&&e.appendChild(n.createTextNode(t))}function c(e){let t=e.trim();return t[0]===`|`&&(t=t.slice(1)),t[t.length-1]===`|`&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function l(e){let t=e.trim();return t.indexOf(`|`)<0||!/^[\s:|-]+$/.test(t)?!1:c(t).every(e=>/^:?-+:?$/.test(e))}function u(e,t){let n=e[t];return n.indexOf(`|`)<0||l(n)||t+1>=e.length||!l(e[t+1])?!1:c(n).length===c(e[t+1]).length}function d(e,t){let n=0,r=``,i=()=>{s(e,r),r=``};for(;n<t.length;){let a=t[n];if(a==="`"){let r=t.indexOf("`",n+1);if(r>n+1){i(),o(e,`code`).textContent=t.slice(n+1,r),n=r+1;continue}}else if(a===`*`&&t[n+1]===`*`){let r=t.indexOf(`**`,n+2);if(r>n+2){i(),d(o(e,`strong`),t.slice(n+2,r)),n=r+2;continue}}else if(a===`*`||a===`_`){let r=n>0?t[n-1]:``;if(/\S/.test(t[n+1]||``)&&!/\w/.test(r)){let r=-1;for(let e=n+2;e<t.length;e++)if(t[e]===a&&/\S/.test(t[e-1])&&!/\w/.test(t[e+1]||``)){r=e;break}if(r>0){i(),d(o(e,`em`),t.slice(n+1,r)),n=r+1;continue}}}else if(a===`[`){let r=/^\[([^\]\n]+)\]\(([^)\s]+)\)/.exec(t.slice(n));if(r&&/^https?:\/\//i.test(r[2])){i();let t=o(e,`a`);t.setAttribute(`href`,r[2]),t.setAttribute(`rel`,`noopener noreferrer`),t.setAttribute(`target`,`_blank`),d(t,r[1]),n+=r[0].length;continue}}r+=a,n++}i()}function f(e,t,n=0){let r=0;for(;r<t.length;){let s=t[r];if(/^\s*$/.test(s)){r++;continue}if(/^```/.test(s)){let n=[];for(r++;r<t.length&&!/^```\s*$/.test(t[r]);)n.push(t[r++]);r++,o(o(e,`pre`),`code`).textContent=n.join(`
4
- `);continue}let l=/^(#{1,6})\s+(\S.*?)\s*$/.exec(s);if(l){d(o(e,`h`+l[1].length),l[2]),r++;continue}if(s[0]===`>`&&n<8){let i=[];for(;r<t.length&&t[r][0]===`>`;)i.push(t[r++].replace(/^>\s?/,``));f(o(e,`blockquote`),i,n+1);continue}if(u(t,r)){let n=c(s),i=o(e,`table`),a=o(o(i,`thead`),`tr`);for(let e of n)d(o(a,`th`),e);r+=2;let l=null;for(;r<t.length&&t[r].indexOf(`|`)>=0&&!u(t,r);){l||=o(i,`tbody`);let e=c(t[r]),a=o(l,`tr`);for(let t=0;t<n.length;t++)d(o(a,`td`),t<e.length?e[t]:``);r++}continue}if(i.test(s)){let n=[],a;for(;r<t.length&&(a=i.exec(t[r]))!==null;)n.push({indent:a[1].length,ordered:/^\d/.test(a[2]),text:a[3]}),r++;let s=n[0].indent,c=o(e,n[0].ordered?`ol`:`ul`),l=null,u=null;for(let e of n)e.indent>s&&l?(u||=o(l,e.ordered?`ol`:`ul`),d(o(u,`li`),e.text)):(l=o(c,`li`),u=null,d(l,e.text));continue}let p=[];for(;r<t.length&&!/^\s*$/.test(t[r])&&!a.test(t[r])&&!i.test(t[r])&&!u(t,r);)p.push(t[r++]);p.length===0&&p.push(t[r++]),d(o(e,`p`),p.join(`
5
- `))}}f(e,r)}var L=o({__name:`MarkdownText`,props:{text:{}},setup(e){let n=e,i=_(null);function a(){let e=i.value;if(e)try{re(e,n.text)}catch{e.textContent=n.text}}return f(a),r(()=>n.text,a),(e,n)=>(u(),t(`div`,{ref_key:`root`,ref:i,class:`md prose prose-sm prose-neutral dark:prose-invert min-w-0 max-w-none flex-1 whitespace-pre-wrap break-words font-sans text-[0.875rem] leading-normal [&_a]:font-medium [&_a]:decoration-(--ui-text-dimmed) [&_a]:underline-offset-[3px] [&_a:hover]:decoration-current [&_blockquote]:my-1.5 [&_h1]:font-medium [&_h1]:tracking-tight [&_h2]:font-medium [&_h2]:tracking-tight [&_h3]:font-medium [&_h3]:tracking-tight [&_h4]:font-medium [&_strong]:font-medium [&_li>ol]:my-0.5 [&_li>ul]:my-0.5 [&_li]:my-0.5 [&_li]:whitespace-pre-wrap [&_ol]:my-1.5 [&_ol]:whitespace-normal [&_p]:my-1.5 [&_pre]:my-2 [&_pre]:whitespace-pre [&_table]:whitespace-normal [&_ul]:my-1.5 [&_ul]:whitespace-normal`},null,512))}}),ie=[`user`,`channel`,`defaults`];function R(e){return typeof e==`string`&&ie.includes(e)}function ae(){let e=[],t=null,n=0,r=[];function i(e){return typeof e==`number`&&isFinite(e)?e:void 0}function a(e){return typeof e==`string`?e:``}function o(n){let r={index:e.length,calls:[]};return n&&(r.narration=n),e.push(r),t=r,r}function s(e){return e<1e3?String(e):e<1e6?(Math.round(e/100)/10).toFixed(1)+`k`:(Math.round(e/1e5)/10).toFixed(1)+`M`}function c(e){let t=/\((\d+) chars(?:, (\d+) lines)?\)$/.exec(e.summary);if(t)return t[2]?Number(t[2]):1;if(e.output)return e.output.split(`
6
- `).length}function l(e){let t=[],n=e.result;if(!n)return t;n.infra?t.push(`sandbox error`):e.shell?t.push(n.exitCode===void 0?n.ok?`exit 0`:`error`:`exit `+n.exitCode):n.ok||t.push(`error`);let r=c(n);return r!==void 0&&r>1&&t.push(r+` lines`),e.durationMs!==void 0&&t.push(C(e.durationMs,`precise`)),t}function u(e,t){let n={ok:t.ok===!0,infra:t.infra===!0,summary:a(t.summary),output:a(t.output),at:i(t.at)},o=i(t.exitCode);o!==void 0&&(n.exitCode=o),e.result=n;let s=r.indexOf(e);s!==-1&&r.splice(s,1),e.status=n.infra?`infra`:n.ok?`ok`:`failed`,e.status!==`ok`&&(e.tags=e.tags.concat(e.status)),e.startedAt!==void 0&&n.at!==void 0&&n.at>=e.startedAt&&(e.durationMs=n.at-e.startedAt),e.facts=l(e)}let d=[[`tests`,/\b(npm|pnpm|yarn|bun)\s+(run\s+)?test\b|\b(vitest|jest|pytest|mocha|go test|cargo test)\b/],[`build`,/\b(npm|pnpm|yarn|bun)\s+run\s+(build|typecheck|lint)\b|\b(tsc|make|cargo build|go build|eslint|prettier)\b/],[`install`,/\b(npm|pnpm|yarn|bun)\s+(i|install|ci|add)\b|\bpip3?\s+install\b|\bapt(-get)?\s+install\b|\bbrew\s+install\b/],[`git`,/(^|[\s;&|(])(git|gh)\s/],[`network`,/(^|[\s;&|(])(curl|wget)\s/],[`read`,/(^|[\s;&|(])(cat|sed|head|tail|less|ls|find|grep|rg|wc|tree|pwd|echo|env|which|stat|file|diff)\b/]];function f(e){let t=e.replace(/^(\s*cd\s+("[^"]*"|'[^']*'|\S+)\s*(&&|;)\s*)+/,``);return t.trim()?t:e}function p(e){let t=f(e);for(let[e,n]of d)if(n.test(t))return e;return`shell`}function m(e,t){let n=t?f(e):e,r=n.indexOf(`
7
- `),i=r===-1?n:n.slice(0,r).trimEnd();return i.length<e.length?i+` …`:i}function h(e,t){let o=a(e.tool),s=o===`bash`,c=t||o,l=s&&c.startsWith(`$ `)?c.slice(2):!s&&c.startsWith(o+` `)?c.slice(o.length+1):c,u={id:a(e.callId)||`c`+ ++n,tool:o,title:l,headline:m(l,s),shell:s,quiet:o===`update_status`,tags:[s?p(l):o],status:`running`,startedAt:i(e.at),facts:[]};return r.push(u),u}function g(t){for(let n=e.length-1;n>=0;n--)for(let r of e[n].calls)if(r.id===t)return{step:e[n],call:r};return null}function _(t){let n=a(t.callId);if(!n)return null;for(let t=e.length-1;t>=0;t--)for(let r of e[t].calls)if(r.id===n&&!r.result)return{step:e[t],call:r};return null}function v(e){if(!e||typeof e!=`object`)return[];let n=e;switch(n.type){case`input`:{let e={kind:`input`,text:a(n.text),messageId:a(n.messageId),at:i(n.at)},t=n.source;if(t&&typeof t==`object`){let n=t,r={};a(n.url)&&(r.url=a(n.url)),a(n.channel)&&(r.channel=a(n.channel)),a(n.user)&&(r.user=a(n.user)),a(n.run)&&(r.run=a(n.run)),Object.keys(r).length>0&&(e.source=r)}return[e]}case`answer`:return[{kind:`answer`,text:a(n.text),at:i(n.at)}];case`pr_opened`:{let e=i(n.number);return!a(n.url)||e===void 0||!Number.isInteger(e)||e<=0?[]:[{kind:`pr_opened`,url:a(n.url),number:e,created:n.created===!0,at:i(n.at)}]}case`pushed_head`:return!a(n.ref)||!a(n.sha)?[]:[{kind:`pushed_head`,ref:a(n.ref),sha:a(n.sha),at:i(n.at)}];case`run_meta`:{if(!a(n.agent))return[];let e={kind:`meta`,agent:a(n.agent),model:a(n.model),at:i(n.at)};return a(n.effort)&&(e.effort=a(n.effort)),a(n.harness)&&(e.harness=a(n.harness)),R(n.harnessScope)&&(e.harnessScope=n.harnessScope),a(n.repo)&&(e.repo=a(n.repo)),a(n.ref)&&(e.ref=a(n.ref)),i(n.pr)!==void 0&&Number.isInteger(n.pr)&&n.pr>0&&(e.pr=n.pr),/^[0-9a-f]{7,40}$/i.test(a(n.headSha))&&(e.headSha=a(n.headSha)),[e]}case`context`:return[{kind:`context`,text:a(n.text),at:i(n.at)}];case`reference`:{let e=i(n.messages);return!a(n.url)||!a(n.channelName)||e===void 0?[]:[{kind:`reference`,url:a(n.url),channelName:a(n.channelName),messages:e,text:a(n.text),at:i(n.at)}]}case`notes`:return[{kind:`note`,text:a(n.text),noteKind:`notes`,at:i(n.at)}];case`replay_note`:return[{kind:`replay_note`,text:a(n.summary)}];case`run_note`:return[{kind:`note`,text:a(n.summary),noteKind:a(n.kind),mode:a(n.mode)||void 0,at:i(n.at)}];case`assistant`:return[{kind:`step`,step:o({text:a(n.text),at:i(n.at)})}];case`review_artifact`:return[];case`span_start`:{let e=a(n.name),t=a(n.spanId);return!e||!t||e.startsWith(`tool.`)||e.startsWith(`mcp.`)||e===`model.turn`?[]:[{kind:`span`,spanId:t,name:e,open:!0,at:i(n.at)}]}case`span_end`:{let e=a(n.name),r=a(n.spanId),o=i(n.durationMs);if(!e||!r||o===void 0)return[];let c=n.status===`error`?`error`:`ok`,u=typeof n.attrs==`object`&&n.attrs!==null?n.attrs:{};if(e===`model.turn`){t=null;let e=[],c=i(u.inputTokens),l=i(u.outputTokens),d=i(u.cacheReadTokens);c!==void 0&&e.push(s(c)+` in`),l!==void 0&&e.push(s(l)+` out`),d!==void 0&&e.push(s(d)+` cached`);let f=i(u.ttftMs);f!==void 0&&e.push(`first token `+C(f,`precise`));let p=i(u.thinkingMs);p!==void 0&&e.push(`thinking `+C(p,`precise`));let m=i(u.textMs);m!==void 0&&e.push(`writing `+C(m,`precise`));let h=a(u.model);return[{kind:`turn`,spanId:r,label:`Thought for `+C(o,`precise`),facts:e,durationMs:o,...h?{model:h}:{},at:i(n.at)}]}if(e.startsWith(`tool.`)||e.startsWith(`mcp.`)){if(!e.startsWith(`tool.`))return[];let t=a(u.callId);if(!t)return[];let n=g(t);return!n||n.call.durationMs!==void 0?[]:(n.call.durationMs=o,n.call.facts=l(n.call),[{kind:`result`,step:n.step,call:n.call}])}let d=i(n.startedAt);return[{kind:`span`,spanId:r,name:e,open:!1,durationMs:o,status:c,at:i(n.at),...d===void 0?{}:{startedAt:d}}]}case`artifact`:{let e=a(n.key),t=a(n.name);if(!e||!t)return[];let r={key:e,name:t,size:i(n.size)??0,contentType:a(n.contentType),at:i(n.at)},o=a(n.messageId),s=a(n.callId),c=n.direction===`in`&&o?{...r,direction:`in`,messageId:o}:n.direction===`out`&&s?{...r,direction:`out`,callId:s}:void 0;return c?[{kind:`artifact`,artifact:c}]:[]}case`skill_use`:{let e=a(n.skill);if(!e)return[];let r=[];t||r.push({kind:`step`,step:o()});let s=a(n.source),c={name:e,description:a(n.description),agent:a(n.agent),bodyBytes:i(n.bodyBytes)??0,at:i(n.at)};return/^https?:\/\//.test(s)&&(c.source=s),r.push({kind:`skill`,step:t,skill:c}),r}case`tool_call`:{let e=[];t||e.push({kind:`step`,step:o()});let r=h(n,a(n.summary));return t.calls.push(r),e.push({kind:`call`,step:t,call:r}),e}case`tool_result`:{let e=_(n);if(e)return u(e.call,n),[{kind:`result`,step:e.step,call:e.call}];let r=[];t||r.push({kind:`step`,step:o()});let i=h(n,``);return i.startedAt=void 0,u(i,n),t.calls.push(i),r.push({kind:`call`,step:t,call:i}),r}default:return[]}}function y(){return r.length>0?r[0]:null}return{push:v,pending:y,steps:()=>e}}new Set(`request,slack.receive,dispatch.history,dispatch.admission,dispatch.ack_card,dispatch.gate.repo,dispatch.gate.pr_head,dispatch.workspace.attach,dispatch.gate.attached_head,dispatch.mcp_discovery,dispatch.compose,dispatch.channel_visibility,dispatch.repo_context,dispatch.memory_read,dispatch.refuse,dispatch.ship_preflight,dispatch.ledger_claim,dispatch.route,run.agent,run.command,run.reading_diff,run.settle_reviewed_head,run.description_turn,run.verdict_turn,run.observe_workspace,run.pr_post_step,run.review_post_step,run.reading_diff_join,run.pr_description_join,model.turn,ship.round,post.card_close,post.reply`.split(`,`));var z=new Set([`slack.receive`,`dispatch.history`,`dispatch.admission`,`dispatch.ack_card`,`dispatch.gate.repo`,`dispatch.gate.pr_head`,`dispatch.workspace.attach`,`dispatch.gate.attached_head`,`dispatch.mcp_discovery`,`dispatch.compose`,`dispatch.channel_visibility`,`dispatch.repo_context`,`dispatch.memory_read`,`dispatch.refuse`,`dispatch.ship_preflight`,`dispatch.ledger_claim`,`dispatch.route`]),oe=new Set([`run.observe_workspace`,`run.pr_post_step`,`run.review_post_step`,`run.reading_diff_join`,`run.pr_description_join`]),se=new Set([`request`,`run.agent`,`ship.round`,`run.settle_reviewed_head`,`run.description_turn`,`run.verdict_turn`,`post.card_close`,`post.reply`]),ce=new Set([`run.reading_diff`]);function B(e,t){if(ce.has(e))return{kind:`background`};if(se.has(e))return{kind:`uncounted`};if(e===`model.turn`)return{kind:`counted`,bucket:`thinking`};if(e===`run.command`||e.startsWith(`run.command.`))return{kind:`counted`,bucket:t===`command`?`tools`:`getting_ready`};if(z.has(e)||e.startsWith(`dispatch.workspace.attach.`))return{kind:`counted`,bucket:`getting_ready`};if(oe.has(e))return{kind:`counted`,bucket:`finishing_up`};if(e.startsWith(`tool.`)||e.startsWith(`mcp.`))return{kind:`counted`,bucket:`tools`}}var V={clone:`cloning the repo`,"checkout-clone":`cloning the checkout`,"worktree-clone":`cloning the worktree`,"worktree-detach":`checking out the expected commit`,"op-clone":`cloning the op tree`,fetch:`fetching the branch`,"wake-fetch":`fetching the latest commits`,"reclaim-fetch":`fetching to reclaim the mirror`,"for-each-ref":`listing the branches`,checkout:`checking out the branch`,"checkout-update":`updating the checkout`,"rev-parse":`reading the commit`,"cat-file":`checking the mirror for the commit`,"show-ref":`reading the branch tip`,"detect-default-branch":`detecting the default branch`,git:`a git command`,"git-setup":`configuring git`,"stage-perms":`securing the credential stage`,install:`installing dependencies`,build:`building`,test:`running the tests`,"clear-markers":`clearing the build markers`,"lockfile-key":`hashing the lockfile`,"deps-store-dir":`preparing the dependency store`,"deps-scratch":`cloning a scratch tree for the dependency install`,"deps-install":`installing the dependency store`,"deps-harden":`locking down the installed dependencies`,"deps-commit":`recording the installed dependencies`,"deps-adopt":`adopting the dependency store`,"deps-restore-scratch":`restoring dependencies to scratch`,"deps-restore-chown":`setting the restored dependencies' owner`,"deps-restore-commit":`recording the restored dependencies`,"deps-scratch-chown":`setting the dependency scratch owner`,"deps-evict":`evicting an old dependency store`,"unlink-deps-view":`unlinking the dependency view`,"clear-installing-marker":`clearing the install marker`,chown:`setting the workspace owner`,"worktree-chown":`setting the worktree owner`,"op-chown":`setting the op tree's owner`,"worktree-clean":`cleaning the worktree`,"clean-workspace":`cleaning the workspace`,"clean-before-restore":`cleaning before the restore`,"break-mirror":`removing the mirror's config (fault injection)`,"unmount-restores":`unmounting earlier restores`,"mirror-restore-extract":`extracting the mirror snapshot`,"checkout-restore-extract":`extracting the checkout snapshot`,"deps-restore-extract":`extracting the dependency snapshot`,evict:`evicting a stale tree`,"thread-dir":`preparing a directory`,"threads-dir":`preparing a directory`,"op-dir":`preparing a directory`,"ops-dir":`preparing a directory`,"stage-dir":`preparing a directory`,stat:`checking a file`,"boot-id":`reading the container's identity`,touch:`touching a marker`,nproc:`counting CPUs`,mutex_wait:`waiting for the workspace`,kill:`stopping the previous step`};Object.keys(V);function H(e){return Object.prototype.hasOwnProperty.call(V,e)?e:void 0}function le(e){let t=H(e);if(t!==void 0)return V[t];if(e.endsWith(`-stale-sweep`)){let t=H(e.slice(0,-12));if(t!==void 0)return`clearing leftovers before ${V[t]}`}}var U={request:`the request`,"slack.receive":`receiving`,"dispatch.history":`reading the thread`,"dispatch.admission":`checking the thread`,"dispatch.ack_card":`posting the status card`,"dispatch.gate.repo":`checking the repo`,"dispatch.gate.pr_head":`checking the PR`,"dispatch.workspace.attach":`attaching the workspace`,"dispatch.gate.attached_head":`checking out the branch`,"dispatch.mcp_discovery":`loading tools`,"dispatch.compose":`preparing the prompt`,"dispatch.channel_visibility":`checking the channel`,"dispatch.repo_context":`reading the repo's context`,"dispatch.memory_read":`recalling memory`,"dispatch.refuse":`refusing`,"dispatch.ship_preflight":`checking the ship request`,"dispatch.ledger_claim":`claiming the run's row`,"dispatch.route":`picking the preset`,"run.agent":`the agent loop`,"run.command":`the command`,"run.reading_diff":`reading the diff (in parallel)`,"run.settle_reviewed_head":`re-checking the moved branch`,"run.description_turn":`asking for the PR description`,"run.verdict_turn":`asking for the verdict`,"run.observe_workspace":`checking the workspace`,"run.pr_post_step":`posting the PR`,"run.review_post_step":`posting the review`,"run.reading_diff_join":`waiting for the diff`,"run.pr_description_join":`waiting for the PR description`,"model.turn":`a model turn`,"ship.round":`a ship round`,"post.card_close":`closing the card`,"post.reply":`posting the reply`},W=`a Switchboard step`;function G(e){if(e in U)return U[e];if(e.startsWith(`tool.`))return e.slice(5)||`a Switchboard step`;if(e.startsWith(`mcp.`)){let t=e.slice(e.lastIndexOf(`.`)+1);return t&&t!==`mcp`?t:W}for(let t of[`dispatch.workspace.attach.`,`run.command.`])if(e.startsWith(t))return le(e.slice(t.length))??`a Switchboard step`;return W}var ue=[/\bslack[\s-]?only\b/i,/\bpost\s*[:=]\s*(?:off|no|false|none)\b/i,/\bno[\s-]post\b/i,/\b(?:don['’]?t|do\s+not|never|skip|without)\s+(?:\w+\s+){0,2}?(?:post|comment)(?:ing|s)?\b/i,/\bno\s+need\s+to\s+(?:post|comment)\b/i];function de(e){return ue.some(t=>t.test(e))}var fe=/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,pe=/^[0-9a-f]{7,40}$/,me=/^(?![.-])(?!.*\.\.)(?!.*\/\/)(?!.*@\{)(?!.*\.lock$)(?!.*[./]$)[\w][\w./-]*$/;function K(e){return e&&fe.test(e)?`https://github.com/${e}`:void 0}function q(e,t){let n=K(e);if(!(!n||t===void 0||!Number.isInteger(t)||t<=0))return`${n}/pull/${t}`}function he(e,t){let n=K(e);if(n&&t&&me.test(t))return`${n}/tree/${t.split(`/`).map(encodeURIComponent).join(`/`)}`}function ge(e,t){let n=K(e);if(n&&t&&pe.test(t))return`${n}/commit/${t}`}function _e(e){return e.slice(0,7)}function ve(e){if(e===`slack.receive`||e.startsWith(`dispatch.`))return`getting_ready`;let t=B(e,`agent`);return t?.kind===`counted`&&t.bucket===`finishing_up`?`finishing_up`:void 0}function ye(e){return e===`request`||e===`run.agent`}var be={getting_ready:`Getting ready`,finishing_up:`Finishing up`};function xe(e){let t=e.rows.length,n=`${t} step${t===1?``:`s`}`,r=be[e.phase];if(t===0||e.rows.some(e=>e.open||e.at===void 0||e.durationMs===void 0))return`${r} · ${n}`;let i=Math.min(...e.rows.map(e=>e.at)),a=Math.max(...e.rows.map(e=>e.at+e.durationMs));return`${r} · ${n} · ${C(Math.max(0,a-i),`precise`)}`}function Se(e){let t=e.split(`
8
- `),n=t.indexOf(`<<<UNTRUSTED`),r=t.lastIndexOf(`UNTRUSTED>>>`);return(n>=0&&r>n?t.slice(n+1,r):t.slice(1)).filter(e=>e.length>0)}function Ce(e,t){let n=t.split(`/`).map(encodeURIComponent).join(`/`);return`${e.urlBase}${n}${e.token?`?t=${encodeURIComponent(e.token)}`:``}`}function we(e){if(typeof e!=`string`)return null;let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let{fromSeq:n,toSeq:r}=t,i=e=>typeof e==`number`&&Number.isInteger(e)&&e>0;return!i(n)||!i(r)||n>r?null:{fromSeq:n,toSeq:r}}function Te(e){let t=e.toSeq-e.fromSeq+1,n=t===1?`event ${e.fromSeq}`:`events ${e.fromSeq}–${e.toSeq}`;return`${t} ${t===1?`event`:`events`} not loaded (${n}) — the record has them`}function Ee(e,t,n){let r=!!e.model&&t!==null&&Fe(e.model,t),i=r?t:e.model??t??void 0,a=!!e.model&&t!==null&&!r;return{spanId:e.spanId,label:e.label,chip:e.label.replace(/^Thought for /,``),quick:e.durationMs<6e4,durationMs:e.durationMs,facts:e.facts,...i?{model:i}:{},switched:a,showModel:!!i&&(!n||a),at:e.at}}function De(e){let t=`${e.n} tool call${e.n===1?``:`s`}`;if(e.n===0)return`no tool calls`;if(e.ok===e.n)return`${t}, all succeeded`;if(e.running===e.n)return`${t}, all running`;let n=[];return e.bad&&n.push(`${e.bad} failed`),e.infra&&n.push(`${e.infra} sandbox error${e.infra===1?``:`s`}`),e.running&&n.push(`${e.running} still running`),`${t}, ${n.join(`, `)}`}function Oe(e){let{meta:t,prOpened:n}=e,r=t?.repo&&K(t.repo)?t.repo:void 0;if(t?.agent===`review`){if(de(e.requestText))return{text:`verdict, Slack only`};if(r&&t.pr!==void 0){let e=q(r,t.pr);return e?{text:`verdict for ${r}#${t.pr}`,href:e}:{text:`verdict`}}return{text:`verdict`}}if(t?.agent===`coding`&&n){let e=n.created?`pull request opened`:`pull request updated`,t=r?q(r,n.number):void 0;return t?{text:`${e} ${r}#${n.number}`,href:t}:{text:e}}return t?.agent===`command`?{text:`output`}:{text:`answer`}}function J(e,t){return{id:e.id,tool:e.tool,title:e.title,headline:e.headline,shell:e.shell,status:e.status,facts:[...e.facts],startedAt:e.startedAt,output:e.result?e.result.output||e.result.summary:``,hasResult:e.result!==void 0,chipOnly:!e.shell&&e.title===e.tool,durationMs:e.durationMs,exitCode:e.result?.exitCode,timedOut:O(e.result?.exitCode),open:t}}function ke(e={}){let t=e.openTags&&e.openTags.length>0?e.openTags:[`failed`,`infra`],n=ae(),r=y({request:null,meta:null,context:[],references:[],log:[],reply:null,prOpened:null,placeholder:!0,allOpen:!1,stopMode:null,model:null,firstAt:null,lastAt:null,lastAtWall:null,elided:[],traceVersion:0}),i=ne(),a=new Map,o=new Map,s=new Map,c=new Map,l=new Map,u=new Map,d=new Map,f=new Map,p=new Set,m=null,h=!1,g=-1,_=0,v=e=>`${e}-${_++}`;function b(e){return t.includes(`all`)?!0:e.some(e=>t.includes(e))}function S(e){let t=0,n=0,r=0;for(let i of e.items)i.kind===`call`&&(i.call.status===`failed`?t++:i.call.status===`infra`?n++:i.call.status===`running`&&r++);return{bad:t,infra:n,running:r}}function C(e){let{bad:t,infra:n,running:r}=S(e);(t||n||r)&&(e.groupOpen=!0)}function w(e){let t=o.get(g);t&&(t.live=!1),g=e.index;let n=m;m=null;let i=y({kind:`step`,key:v(`step`),index:e.index,at:e.narration?e.narration.at:n?.at,turn:n,narration:e.narration?e.narration.text:null,note:`no commentary`,items:[],live:!0,manual:!1,groupOpen:!0});return o.set(e.index,i),r.log.push(i),i}function T(e){return o.get(e.index)??w(e)}function E(e,t){let n=T(e);if(t.quiet){p.add(t.id),n.items.push({kind:`quiet`,at:t.startedAt,text:`✎ ${t.tool===`update_status`?`status checklist updated`:t.title}`}),C(n);return}let i=y(J(t,r.allOpen||b(t.tags)));u.set(t.id,i),d.set(t.id,n),n.items.push({kind:`call`,call:i}),C(n)}function D(e,t){if(p.has(t.id)){let t=o.get(e.index);t&&C(t);return}let n=u.get(t.id);if(!n){E(e,t);return}Object.assign(n,J(t,n.open)),b(t.tags)&&(n.open=!0);let r=o.get(e.index);r&&C(r)}function O(e,t){m&&=(r.log.push({kind:`turn`,key:v(`turn`),turn:m,note:e,...t===void 0?{}:{noteHref:t}}),null)}let k=new Map,A=y([]);function M(e){if(e.direction===`in`){k.get(e.messageId)?.files.push(e);return}A.push(e);let t=u.get(e.callId);t&&((t.files??=[]).push(e),t.open=!0)}function N(e){switch(r.placeholder=!1,e.kind){case`input`:{let t={text:e.text,messageId:e.messageId,at:e.at,...e.source?{source:e.source}:{},files:[]};r.request?r.log.push({kind:`followup`,key:v(`followup`),input:t}):r.request=t,k.set(t.messageId,t);return}case`step`:w(e.step);return;case`call`:E(e.step,e.call);return;case`result`:D(e.step,e.call);return;case`turn`:O(``),m=Ee(e,r.model,h),m.model&&(h=!0),e.model&&!(r.model!==null&&Fe(e.model,r.model))&&(r.model=e.model);return;case`meta`:r.model===null&&e.model&&(r.model=e.model),r.meta={agent:e.agent,model:e.model,...e.effort?{effort:e.effort}:{},...e.harness?{harness:e.harness}:{},...e.harnessScope?{harnessScope:e.harnessScope}:{},...e.repo?{repo:e.repo}:{},...e.ref?{ref:e.ref}:{},...e.pr===void 0?{}:{pr:e.pr},...e.headSha?{headSha:e.headSha}:{}};return;case`pr_opened`:r.prOpened={url:e.url,number:e.number,created:e.created};return;case`skill`:T(e.step).items.push({kind:`skill`,skill:e.skill});return;case`artifact`:M(e.artifact);return;case`context`:r.context.push({key:v(`ctx`),at:e.at,text:e.text});return;case`reference`:r.references.push({key:v(`ref`),at:e.at,url:e.url,channelName:e.channelName,messages:e.messages,text:e.text});return;case`note`:if(e.noteKind===`follow_up`)return;r.log.push({kind:`note`,key:v(`note`),at:e.at,replay:!1,text:e.text,noteKind:e.noteKind}),(e.noteKind===`stop_requested`||e.noteKind===`stopped`)&&(e.mode===`soft`||e.mode===`hard`)&&R(e.mode);return;case`replay_note`:r.log.push({kind:`note`,key:v(`note`),replay:!0,text:e.text});return;case`span`:{if(ye(e.name)){e.name===`run.agent`&&e.open&&P(`getting_ready`);return}e.name.startsWith(`post.`)&&e.open&&P(`finishing_up`);let t=s.get(e.spanId);if(t){t.open=e.open,e.durationMs!==void 0&&(t.durationMs=e.durationMs),e.status&&(t.status=e.status);return}let n=y({kind:`span`,key:v(`span`),spanId:e.spanId,text:G(e.name),open:e.open,...e.durationMs===void 0?{}:{durationMs:e.durationMs},...e.status?{status:e.status}:{},at:e.open?e.at:e.startedAt??e.at});s.set(e.spanId,n);let i=ve(e.name);if(i){let t=l.get(i);t||(t={group:y({kind:`phase`,phase:i,key:v(i),rows:[],open:!0}),toggled:!1},l.set(i,t),r.log.push(t.group)),t.group.rows.push(n),c.set(e.spanId,t.group);return}r.log.push(n);return}case`answer`:O(`wrote the reply`,`#reply`),r.reply={text:e.text,at:e.at,files:A};return}}function P(e){let t=l.get(e);t&&!t.toggled&&(t.group.open=!1)}function ee(e){let t=e,s=t?.type===`span_start`||t?.type===`span_end`;if(t&&typeof t.type==`string`){let t=e;i.push(t),j(t)&&te(a,t,``),r.traceVersion++}t&&!s&&typeof t.at==`number`&&((r.firstAt===null||t.at<r.firstAt)&&(r.firstAt=t.at),(r.lastAt===null||t.at>=r.lastAt)&&(r.lastAt=t.at,r.lastAtWall=x()));for(let t of n.push(e))N(t);let c=e;if((c?.type===`tool_call`||c?.type===`tool_result`)&&typeof c.logIndex==`number`&&!f.has(c.logIndex)){let e=(typeof c.callId==`string`?d.get(c.callId):void 0)??o.get(g);e&&f.set(c.logIndex,e)}}function F(e){if(e.turn)return`span-${e.turn.spanId}`;let t=e.items.find(e=>e.kind===`call`);return t?.kind===`call`?`call-${t.call.id}`:void 0}function I(e){let t=f.get(e);if(!t){let n=-1;for(let[r,i]of f)r<e&&r>n&&(n=r,t=i)}if(!t)return;let n=F(t);return n===void 0?void 0:{step:t,anchor:n}}function re(){for(let e of u.values())if(e.status===`running`)return e;return null}function L(e){r.allOpen=e;for(let t of l.values())t.group.open=e,t.toggled=!0;for(let t of u.values())t.open=e}function ie(e){if(e.startsWith(`call-`)){let t=e.slice(5),n=d.get(t);return!n||!u.has(t)?!1:(n.manual=!0,n.groupOpen=!0,!0)}if(e.startsWith(`span-`)){let t=e.slice(5),n=c.get(t);if(n){n.open=!0;let e=l.get(n.phase);return e&&(e.toggled=!0),!0}if(s.has(t))return!0;for(let e of r.log)if(e.kind===`step`&&e.turn?.spanId===t||e.kind===`turn`&&e.turn.spanId===t)return!0}return!1}function R(e){r.stopMode=e}function z(e){r.elided.push(e),r.log.push({kind:`note`,key:v(`note`),replay:!0,text:Te(e)}),r.placeholder=!1,r.traceVersion++}return{state:r,handle:ee,noteElided:z,spanSet:()=>[...a.values()],losses:e=>i.losses({windowStart:e,elided:r.elided}),pendingCall:re,flushPendingTurn:O,closePhases(){P(`getting_ready`),P(`finishing_up`)},setAllOpen:L,togglePhase(e){e.open=!e.open;let t=l.get(e.phase);t&&(t.toggled=!0)},reveal:ie,landing:I,callHeadline:e=>u.get(e)?.headline,toggleGroup(e){e.manual=!0,e.groupOpen=!e.groupOpen},toggleCall(e){e.open=!e.open},markStopping:R,opensByDefault:b}}function Y(e,t){return e.lastAt===null||e.lastAtWall===null?null:e.lastAt+(t-e.lastAtWall)}function Ae(e,t){return{now:n=>e.serverNow+(n-t),elapsedMs(t){return S(e,this.now(t))??0},elapsedAt(t){return S({receivedAt:e.receivedAt,startedAt:e.startedAt,finishedAt:t})??0}}}function je(e){if(typeof e!=`string`)return{};let t;try{t=JSON.parse(e)}catch{return{}}if(typeof t!=`object`||!t)return{};let{sealedAt:n,replyOk:r}=t;return{...typeof n==`number`&&Number.isFinite(n)&&n>0?{sealedAt:n}:{},...typeof r==`boolean`?{replyOk:r}:{}}}function Me(e){return e.replyOk===!1?`reply failed`:e.replyOk!==!0||e.finishedAt===void 0||e.sealedAt===void 0?``:`delivered in ${C(Math.max(0,e.sealedAt-e.finishedAt),`clock`)}`}function Ne(e){if(typeof e!=`string`)return null;let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let{finishedAt:n}=t;return typeof n==`number`&&Number.isFinite(n)&&n>0?{finishedAt:n}:null}var X=Symbol(`sb-runner-clock`),Z=Symbol(`sb-artifact-links`),Pe=Symbol(`sb-reply-landed`);function Fe(e,t){return e===t||!e.includes(`/`)!=!t.includes(`/`)&&Q(e)===Q(t)}function Q(e){if(!e)return`model`;let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1))||e}var Ie=6e4;function Le(e,t,n){let r=Y(e,n);if(r===null||e.lastAt===null)return{kind:`starting`};if(t)return{kind:`call`,call:t,elapsedMs:Math.max(0,r-(t.startedAt??e.lastAt))};let i=Math.max(0,r-e.lastAt);return{kind:`thinking`,elapsedMs:i,slow:i>=Ie}}var Re=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]),ze=65536,Be=new Set([`application/json`,`application/x-ndjson`,`application/xml`,`application/yaml`]);function $(e){return Re.has(e)?`image`:e.startsWith(`video/`)?`video`:e.startsWith(`audio/`)?`audio`:e.startsWith(`text/`)||Be.has(e)?`text`:`other`}var Ve=[`data-open-images`],He={class:`mb-1.5 flex items-baseline gap-2 font-mono text-[0.68rem] font-medium uppercase tracking-wider text-dimmed`},Ue={class:`count font-normal normal-case tracking-normal`},We={class:`m-0 flex list-none flex-col gap-1.5 p-0`},Ge=[`data-direction`,`data-kind`,`data-open`,`data-expired`],Ke={class:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5 font-mono text-xs`},qe=[`title`],Je=[`aria-expanded`,`aria-controls`,`onClick`],Ye={key:1,class:`name font-medium text-toned`},Xe={class:`fact text-dimmed`},Ze={class:`fact text-dimmed`},Qe={key:2,class:`expired text-warn`},$e=[`id`,`aria-hidden`],et={class:`min-h-0 overflow-hidden`},tt=[`src`,`alt`,`onError`],nt=[`src`,`onError`],rt=[`src`,`onError`],it={key:3,class:`mt-1.5`},at={key:0,class:`text max-h-96 overflow-auto rounded border border-(--ui-border) bg-elevated p-2.5 font-mono text-xs whitespace-pre-wrap break-words text-toned`},ot={key:1,class:`text-xs text-bad`},st={key:2,class:`mt-1 text-xs text-dimmed`},ct={key:4,class:`other mt-1.5 flex flex-wrap items-baseline gap-x-3 gap-y-1 font-mono text-xs text-dimmed`},lt=[`href`,`download`],ut=0,dt=o({__name:`MessageFiles`,props:{files:{},openImages:{type:Boolean,default:!0}},setup(e){let o=e,f=l(Z,null),m=y(new Set),g=y(new Set),_=y(new Set),v=y(new Map);function x(){for(let e of o.files)o.openImages&&$(e.contentType)===`image`&&!g.has(e.key)&&!_.has(e.key)&&(g.add(e.key),_.add(e.key))}x(),r(()=>[o.files,o.files.length],x),ut+=1;let S=`files-${ut}`,C=b(()=>o.files.map((e,t)=>({...e,href:f?Ce(f,e.key):null,kind:$(e.contentType),open:g.has(e.key),mounted:_.has(e.key),expired:m.has(e.key),panelId:`${S}-file-${t}`})));function w(e){if(e.href&&!e.expired){if(g.has(e.key)){g.delete(e.key);return}g.add(e.key),_.add(e.key),e.kind===`text`&&!v.has(e.key)&&T(e.key,e.href)}}async function T(e,t){v.set(e,{text:``,truncated:!1});try{let n=await fetch(t,{credentials:`same-origin`});if(n.status===410){m.add(e),v.delete(e);return}if(!n.ok||!n.body)throw Error(`HTTP ${n.status}`);let r=n.body.getReader(),i=new TextDecoder,a=``,o=0,s=!1;for(;;){let{value:e,done:t}=await r.read();if(t)break;let n=ze-o,c=e.byteLength>n?e.subarray(0,n):e;if(a+=i.decode(c,{stream:!0}),o+=c.byteLength,o>=65536){s=e.byteLength>n||!(await r.read()).done,await r.cancel();break}}v.set(e,{text:a,truncated:s})}catch(t){v.set(e,{text:``,truncated:!1,error:t instanceof Error?t.message:String(t)})}}function D(e){m.add(e),g.delete(e)}let O=e=>e===`out`?`↑ sent`:`↓ received`,k=e=>e===`out`?`sent by the run`:`received from the thread`;return(r,o)=>(u(),t(`div`,{class:`files mt-3 border-t border-(--ui-border) pt-2`,"data-open-images":e.openImages?`1`:`0`},[d(`h3`,He,[o[0]||=d(`span`,null,`Files`,-1),d(`span`,Ue,`· `+a(e.files.length)+` file`+a(e.files.length===1?``:`s`),1)]),d(`ul`,We,[(u(!0),t(h,null,n(C.value,e=>(u(),t(`li`,{key:e.key,class:`artifact`,"data-direction":e.direction,"data-kind":e.kind,"data-open":e.open?`1`:`0`,"data-expired":e.expired?`1`:`0`},[d(`div`,Ke,[d(`span`,{class:`dir shrink-0 select-none text-dimmed`,title:k(e.direction)},a(O(e.direction)),9,qe),e.href&&!e.expired?(u(),t(`button`,{key:0,type:`button`,class:`name flex cursor-pointer items-baseline gap-1.5 border-0 bg-transparent p-0 font-mono text-xs font-medium text-primary hover:underline focus-visible:outline-2 focus-visible:outline-primary`,"aria-expanded":e.open?`true`:`false`,"aria-controls":e.panelId,onClick:t=>w(e)},[d(`span`,{class:s([`chev inline-block select-none text-[0.65rem] text-dimmed transition-transform motion-reduce:transition-none`,e.open?`rotate-90`:``]),"aria-hidden":`true`},`❯`,2),d(`span`,null,a(e.name),1)],8,Je)):(u(),t(`span`,Ye,a(e.name),1)),d(`span`,Xe,a(p(E)(e.size)),1),d(`span`,Ze,a(e.contentType),1),e.expired&&p(f)?(u(),t(`span`,Qe,`expired after `+a(p(f).retentionDays)+` days`,1)):c(``,!0)]),e.href&&!e.expired?(u(),t(`div`,{key:0,id:e.panelId,class:`panel grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none`,style:i({gridTemplateRows:e.open?`1fr`:`0fr`}),"aria-hidden":e.open?`false`:`true`},[d(`div`,et,[e.mounted?(u(),t(h,{key:0},[e.kind===`image`?(u(),t(`img`,{key:0,class:`preview mt-1.5 max-h-96 max-w-full rounded border border-(--ui-border)`,src:e.href,alt:e.name,loading:`lazy`,onError:t=>D(e.key)},null,40,tt)):e.kind===`video`?(u(),t(`video`,{key:1,class:`preview mt-1.5 max-h-96 max-w-full rounded border border-(--ui-border) bg-black`,src:e.href,controls:``,playsinline:``,preload:`auto`,onError:t=>D(e.key)},null,40,nt)):e.kind===`audio`?(u(),t(`audio`,{key:2,class:`preview mt-1.5 w-full max-w-xl`,src:e.href,controls:``,preload:`auto`,onError:t=>D(e.key)},null,40,rt)):e.kind===`text`?(u(),t(`div`,it,[v.get(e.key)&&!v.get(e.key).error?(u(),t(`pre`,at,a(v.get(e.key).text),1)):c(``,!0),v.get(e.key)?.error?(u(),t(`p`,ot,` could not read the file: `+a(v.get(e.key).error),1)):v.get(e.key)?.truncated?(u(),t(`p`,st,` showing the first `+a(p(E)(p(ze)))+` of `+a(p(E)(e.size)),1)):c(``,!0)])):(u(),t(`div`,ct,[d(`span`,null,`no preview for `+a(e.contentType),1),d(`a`,{class:`download inline-block rounded border border-default px-2 py-0.5 font-medium text-toned no-underline hover:bg-accented hover:text-primary focus-visible:outline-2 focus-visible:outline-primary`,href:e.href,download:e.name},`Download `+a(p(E)(e.size)),9,lt)]))],64)):c(``,!0)])],12,$e)):c(``,!0)],8,Ge))),128))])],8,Ve))}}),ft=[`id`,`open`,`title`,`data-status`,`data-heat`],pt={key:0,class:`spin inline-block size-[0.7em] shrink-0 animate-spin self-center rounded-full border-2 border-accented border-t-info motion-reduce:animate-none`,role:`img`,"aria-label":`running`},mt={key:2,class:`dollar shrink-0 select-none text-dimmed`},ht={key:3,class:`tool shrink-0 rounded bg-accented px-1.5 text-xs leading-normal text-muted`},gt={key:0,class:`cmd brief min-w-0 flex-1 truncate text-info`},_t={key:1,class:`cmd full min-w-0 flex-1 whitespace-pre-wrap break-words text-info max-sm:order-last max-sm:basis-full`},vt={key:5,class:`cmd min-w-0 flex-1`},yt={class:`facts ml-auto flex shrink-0 gap-2.5 text-xs tabular-nums text-muted`},bt={key:0,class:`fact elapsed`,title:`since this call started (runner clock)`},xt={key:0,class:`over rounded bg-bad/15 px-1 font-medium text-bad`},St={key:1,class:`over rounded bg-bad/15 px-1 font-medium text-bad`},Ct={class:`body`},wt={key:1,class:`none px-3 py-1.5 text-xs italic text-dimmed`},Tt={key:2,class:`none px-3 py-1.5 text-xs italic text-dimmed`},Et=o({__name:`CallCard`,props:{call:{}},setup(e){let r=e,o=l(X,null),f=l(Pe,null),m=b(()=>{let e=o?.value;return r.call.status!==`running`||typeof e!=`number`||r.call.startedAt===void 0?``:C(Math.max(0,e-r.call.startedAt),`clock`)}),_=b(()=>k(r.call.durationMs,`tool`,r.call.timedOut)),y=b(()=>D(_.value)),x=b(()=>r.call.durationMs===void 0?-1:r.call.facts.length-1);function S(){r.call.open=!r.call.open}return(r,o)=>(u(),t(`details`,{id:`call-${e.call.id}`,class:s([`call rounded-lg border border-default bg-elevated font-mono open:bg-accented`,e.call.status]),open:e.call.open,title:typeof e.call.startedAt==`number`?`started ${p(w)(e.call.startedAt)}`:void 0,"data-status":e.call.status,"data-heat":_.value.level},[d(`summary`,{class:s([`flex min-w-0 cursor-pointer list-none items-baseline gap-3 rounded-lg pl-3 pr-[calc(var(--sb-gutter)-1px)] py-2 hover:bg-accented/60 focus-visible:outline-2 focus-visible:outline-primary max-sm:flex-wrap [&::-webkit-details-marker]:hidden`,e.call.open?`rounded-b-none border-b border-default`:``]),onClick:g(S,[`prevent`])},[d(`span`,{class:s([`chev shrink-0 select-none text-xs text-dimmed transition-transform motion-reduce:transition-none`,e.call.open?`rotate-90`:``])},`❯`,2),e.call.status===`running`?(u(),t(`span`,pt)):(u(),t(`span`,{key:1,class:s([`glyph w-[1em] shrink-0 text-center font-medium`,e.call.status===`ok`?`text-ok`:e.call.status===`failed`?`text-bad`:`text-warn`])},a(e.call.status===`ok`?`✓`:e.call.status===`failed`?`✗`:`⚠`),3)),e.call.shell?(u(),t(`span`,mt,`$`)):(u(),t(`span`,ht,a(e.call.tool),1)),e.call.chipOnly?(u(),t(`span`,vt)):(u(),t(h,{key:4},[e.call.open?(u(),t(`code`,_t,a(e.call.title),1)):(u(),t(`code`,gt,a(e.call.headline),1))],64)),d(`span`,yt,[m.value?(u(),t(`span`,bt,a(m.value),1)):c(``,!0),(u(!0),t(h,null,n(e.call.facts,(n,r)=>(u(),t(h,{key:r},[r===x.value&&_.value.over?(u(),t(`span`,xt,`timed out`)):c(``,!0),d(`span`,{class:s([`fact`,[e.call.status!==`ok`&&r===0?`text-bad`:``,r===x.value&&_.value.over?`font-medium text-bad`:``,r===x.value&&y.value?`heat`:``,r===x.value&&_.value.level>=2&&!_.value.over?`font-medium`:``]]),style:i(r===x.value?y.value:void 0)},a(n),7)],64))),128)),_.value.over&&x.value===-1?(u(),t(`span`,St,`timed out`)):c(``,!0)])],2),d(`div`,Ct,[e.call.hasResult&&e.call.output?(u(),t(`pre`,{key:0,class:s([`out max-h-[28rem] overflow-auto whitespace-pre-wrap break-words px-3.5 py-2.5 font-mono leading-normal`,e.call.status===`failed`?`text-bad`:`text-toned`])},a(e.call.output),3)):e.call.hasResult?(u(),t(`div`,wt,`no output`)):(u(),t(`div`,Tt,`no output yet`)),e.call.files&&e.call.files.length>0?(u(),v(dt,{key:3,class:`mx-3.5 mb-2.5`,files:e.call.files,"open-images":!p(f)},null,8,[`files`,`open-images`])):c(``,!0)])],10,ft))}}),Dt=[`title`],Ot=[`title`],kt={class:`skillname whitespace-nowrap font-mono font-medium text-skill`},At={key:0,class:`skilldesc min-w-0 flex-1 truncate text-xs text-muted`},jt={class:`facts ml-auto flex shrink-0 gap-2.5 font-mono text-xs text-muted`},Mt=[`href`],Nt={class:`fact`},Pt=o({__name:`StepItems`,props:{items:{}},setup(e){return(r,i)=>(u(!0),t(h,null,n(e.items,(e,n)=>(u(),t(h,{key:n},[e.kind===`call`?(u(),v(Et,{key:0,call:e.call},null,8,[`call`])):e.kind===`quiet`?(u(),t(`div`,{key:1,class:`quiet flex items-baseline gap-3 pl-3 pr-(--sb-gutter) py-0.5 font-mono text-xs text-dimmed`,title:e.at===void 0?void 0:p(w)(e.at)},[d(`span`,null,a(e.text),1)],8,Dt)):(u(),t(`div`,{key:2,class:`skill flex items-baseline gap-2.5 pl-3 pr-(--sb-gutter) py-0.5`,title:e.skill.at===void 0?void 0:p(w)(e.skill.at)},[i[0]||=d(`span`,{class:`skillmark shrink-0 select-none text-xs`},`📚`,-1),d(`span`,kt,`skill `+a(e.skill.name),1),e.skill.description?(u(),t(`span`,At,a(e.skill.description),1)):c(``,!0),d(`span`,jt,[e.skill.source?(u(),t(`a`,{key:0,class:`fact text-primary hover:underline`,href:e.skill.source,target:`_blank`,rel:`noopener noreferrer`},`source`,8,Mt)):c(``,!0),d(`span`,Nt,a(p(E)(e.skill.bodyBytes))+` into context`,1)])],8,Ot))],64))),128))}}),Ft=[`id`,`data-live`],It={class:`head flex items-baseline gap-x-6 pb-1.5 pr-(--sb-gutter)`},Lt={class:`min-w-0 flex-1`},Rt={key:0,class:`meta flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5 font-mono text-xs tabular-nums text-dimmed`},zt=[`data-heat`,`title`],Bt=[`title`],Vt=[`title`],Ht={key:2,class:`nonar font-sans text-sm italic text-dimmed`},Ut=[`title`],Wt={key:0,class:`narration flex items-baseline gap-3 pb-1.5 pr-(--sb-gutter)`},Gt={key:1,class:`narration flex items-baseline gap-3 pb-1.5 pr-(--sb-gutter)`},Kt={class:`nonar flex-1 font-sans text-sm italic text-dimmed`},qt={class:`calls flex flex-col gap-2`},Jt=[`open`,`data-group-open`],Yt=[`title`],Xt=[`data-ok`,`data-bad`,`data-infra`,`data-running`],Zt=[`data-heat`],Qt={class:`gbody flex flex-col gap-2 pb-1 pt-1.5`},$t=o({__name:`StepBlock`,props:{step:{}},emits:[`toggleGroup`],setup(r,{emit:o}){let l=r,f=o,_=b(()=>l.step.items.filter(e=>e.kind===`call`)),y=b(()=>_.value.length>=2),x=b(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of _.value){if(a.kind!==`call`)continue;let o=a.call;o.status===`ok`?e++:o.status===`failed`?t++:o.status===`infra`?n++:r++,typeof o.durationMs==`number`&&(i+=o.durationMs)}return{n:e+t+n+r,ok:e,bad:t,infra:n,running:r,ms:i}}),S=b(()=>De(x.value)),E=b(()=>_.value.some(e=>e.kind===`call`&&e.call.timedOut)),O=b(()=>k(x.value.ms,`tool`,E.value)),A=b(()=>D(O.value)),j=b(()=>l.step.turn?k(l.step.turn.durationMs,`turn`):void 0),M=b(()=>j.value?D(j.value):void 0),N=b(()=>{let e=_.value[0];return e?.kind===`call`?e.call.startedAt:void 0});return(o,l)=>(u(),t(`li`,{id:r.step.turn?`span-${r.step.turn.spanId}`:void 0,class:s([`step relative border-l-2 pb-3 pl-3 pt-2`,r.step.live?`border-ok/40`:`border-(--ui-border-accented)/50`]),"data-live":r.step.live?`1`:void 0},[d(`div`,It,[d(`div`,Lt,[r.step.turn?(u(),t(`div`,Rt,[d(`span`,{class:s([`thought`,[M.value?`heat`:``,j.value&&j.value.level>=2?`font-medium`:``]]),style:i(M.value),"data-heat":j.value?.level,title:r.step.turn.label},`thought `+a(r.step.turn.chip),15,zt),r.step.turn.switched?(u(),t(`span`,{key:0,class:`model-switch order-first rounded border border-warn/40 bg-warn/10 px-1.5 font-medium text-warn`,title:`model changed: this turn ran on ${r.step.turn.model}`},`⇄ `+a(p(Q)(r.step.turn.model)),9,Bt)):r.step.turn.showModel?(u(),t(`span`,{key:1,class:`model-badge order-first rounded bg-accented px-1.5 text-[0.68rem] font-medium leading-normal tracking-wider text-muted`,title:r.step.turn.model},a(p(Q)(r.step.turn.model)),9,Vt)):c(``,!0),(u(!0),t(h,null,n(r.step.turn.facts,(e,n)=>(u(),t(`span`,{key:n,class:`fact`},a(e),1))),128))])):r.step.narration===null?(u(),t(`span`,Ht,a(r.step.note),1)):(u(),v(L,{key:1,text:r.step.narration},null,8,[`text`]))]),r.step.at===void 0?c(``,!0):(u(),t(`span`,{key:0,class:`ts shrink-0 select-none font-mono text-xs tabular-nums text-dimmed`,title:p(w)(r.step.at)},a(p(T)(r.step.at)),9,Ut))]),r.step.turn&&r.step.narration!==null?(u(),t(`div`,Wt,[e(L,{text:r.step.narration},null,8,[`text`])])):r.step.turn&&r.step.narration===null&&!r.step.turn.facts.length?(u(),t(`div`,Gt,[d(`span`,Kt,a(r.step.note),1)])):c(``,!0),d(`div`,qt,[y.value?(u(),t(`details`,{key:1,class:`grp`,open:r.step.groupOpen,"data-group-open":r.step.groupOpen?`1`:`0`},[d(`summary`,{class:`gsummary flex cursor-pointer list-none items-baseline gap-3 rounded-md pl-3 pr-(--sb-gutter) py-1 font-mono text-xs text-dimmed hover:bg-accented/40 hover:text-muted focus-visible:outline-2 focus-visible:outline-primary [&::-webkit-details-marker]:hidden`,title:typeof N.value==`number`?`calls began ${p(w)(N.value)}`:void 0,onClick:l[0]||=g(e=>f(`toggleGroup`),[`prevent`])},[d(`span`,{class:s([`gchev shrink-0 select-none transition-transform motion-reduce:transition-none`,r.step.groupOpen?`rotate-90`:``])},`❯`,2),d(`span`,{class:s([`gcount`,x.value.bad||x.value.infra?`text-bad`:``]),"data-ok":x.value.ok,"data-bad":x.value.bad,"data-infra":x.value.infra,"data-running":x.value.running},a(S.value),11,Xt),x.value.ms>0?(u(),t(`span`,{key:0,class:s([`gtime ml-auto tabular-nums`,[A.value?`heat`:``,O.value.over?`font-medium text-bad`:O.value.level>=2?`font-medium`:``]]),style:i(A.value),"data-heat":O.value.level},[O.value.over?(u(),t(h,{key:0},[m(`timed out · `)],64)):c(``,!0),m(a(p(C)(x.value.ms,`clock`)),1)],14,Zt)):c(``,!0)],8,Yt),d(`div`,Qt,[e(Pt,{items:r.step.items},null,8,[`items`])])],8,Jt)):(u(),v(Pt,{key:0,items:r.step.items},null,8,[`items`]))])],10,Ft))}});function en(e){let t=[];for(let n of e.split(/\r?\n\r?\n/)){let e=n.split(/\r?\n/);if(e.some(e=>e.startsWith(`event:`)))continue;let r=e.filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).replace(/^ /,``)).join(`
9
- `);if(r!==``)try{let e=JSON.parse(r);typeof e==`object`&&e&&typeof e.type==`string`&&t.push(e)}catch{}}return t}export{_e as C,ee as D,L as E,he as S,B as T,Oe as _,Pe as a,q as b,ke as c,Q as d,je as f,Se as g,xe as h,Z as i,Me as l,we as m,$t as n,X as o,Ne as p,dt as r,Ae as s,en as t,Le as u,Y as v,G as w,K as x,ge as y};