@parcha/agentrun-serve 0.1.0-beta.60 → 0.1.0-beta.62

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 (179) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/README.md +139 -22
  3. package/dist/acp-package.d.ts +4 -0
  4. package/dist/api-only.d.ts +23 -1
  5. package/dist/api-only.js +43 -4
  6. package/dist/archil-settings.d.ts +9 -0
  7. package/dist/archil-settings.js +8 -1
  8. package/dist/bash-read-only.d.ts +3 -0
  9. package/dist/bash-read-only.js +6 -3
  10. package/dist/browser-person.d.ts +1 -1
  11. package/dist/browser-person.js +1 -1
  12. package/dist/calendar/tools.js +1 -1
  13. package/dist/chatgpt-plan.d.ts +26 -8
  14. package/dist/chatgpt-plan.js +89 -21
  15. package/dist/claude-login.d.ts +12 -5
  16. package/dist/claude-login.js +28 -3
  17. package/dist/cli.js +61 -18
  18. package/dist/composio-triggers.d.ts +9 -3
  19. package/dist/computers.d.ts +3 -0
  20. package/dist/computers.js +2 -1
  21. package/dist/console/assets/{backend-QnwGVBeU.js → backend-DEgVn5lC.js} +1 -1
  22. package/dist/console/assets/index-CG5tELph.js +639 -0
  23. package/dist/console/assets/share-CIeFK2Oe.js +6 -0
  24. package/dist/console/assets/{styles-CcceGcu2.js → styles-BGZxYkky.js} +2 -2
  25. package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
  26. package/dist/console/index.html +3 -3
  27. package/dist/console/share.html +3 -3
  28. package/dist/cut-pool.d.ts +14 -0
  29. package/dist/cut-pool.js +98 -0
  30. package/dist/cut-worker.d.ts +14 -0
  31. package/dist/cut-worker.js +16 -0
  32. package/dist/decisions.d.ts +4 -0
  33. package/dist/decisions.js +9 -1
  34. package/dist/env-switch.d.ts +3 -0
  35. package/dist/env-switch.js +3 -0
  36. package/dist/errors.d.ts +1 -0
  37. package/dist/errors.js +2 -0
  38. package/dist/harness-check.js +2 -1
  39. package/dist/harness-recipe.d.ts +13 -2
  40. package/dist/harness-recipe.js +30 -7
  41. package/dist/harness-sign-in.js +2 -1
  42. package/dist/harness-table.d.ts +12 -3
  43. package/dist/harness-table.js +13 -8
  44. package/dist/import.d.ts +8 -1
  45. package/dist/import.js +36 -5
  46. package/dist/key-check.js +22 -8
  47. package/dist/key-refusal.js +6 -4
  48. package/dist/learn/secrets.d.ts +2 -1
  49. package/dist/learn/secrets.js +2 -2
  50. package/dist/learned-nodes.d.ts +37 -0
  51. package/dist/learned-nodes.js +24 -0
  52. package/dist/local-model.d.ts +144 -0
  53. package/dist/local-model.js +214 -0
  54. package/dist/mcp-gateway.d.ts +24 -0
  55. package/dist/mcp-gateway.js +97 -8
  56. package/dist/mcp-probe.d.ts +7 -0
  57. package/dist/mcp-probe.js +7 -0
  58. package/dist/mcp-servers-store.d.ts +7 -10
  59. package/dist/mcp-servers-store.js +15 -9
  60. package/dist/native/cli.js +5 -1
  61. package/dist/ollama-provider.d.ts +42 -0
  62. package/dist/ollama-provider.js +118 -2
  63. package/dist/openapi.js +85 -16
  64. package/dist/otel/tracer.d.ts +6 -3
  65. package/dist/otel/tracer.js +24 -6
  66. package/dist/page.d.ts +7 -0
  67. package/dist/page.js +17 -4
  68. package/dist/place.d.ts +28 -11
  69. package/dist/place.js +43 -14
  70. package/dist/print.d.ts +3 -2
  71. package/dist/print.js +8 -6
  72. package/dist/redact/match.d.ts +17 -4
  73. package/dist/redact/match.js +57 -15
  74. package/dist/run-export.js +4 -2
  75. package/dist/run-launch.js +16 -3
  76. package/dist/run-model-key.d.ts +2 -1
  77. package/dist/run-model-key.js +2 -1
  78. package/dist/run-reads-over-store.d.ts +7 -0
  79. package/dist/run-reads-over-store.js +32 -4
  80. package/dist/run-usage.js +3 -2
  81. package/dist/runnable.d.ts +6 -3
  82. package/dist/runnable.js +16 -6
  83. package/dist/runner/adapter-loop.d.ts +8 -1
  84. package/dist/runner/adapter-loop.js +148 -29
  85. package/dist/runner/adapter-run-spec.d.ts +9 -6
  86. package/dist/runner/adapter-run-spec.js +38 -52
  87. package/dist/runner/adapters/index.d.ts +4 -0
  88. package/dist/runner/adapters/index.js +2 -1
  89. package/dist/runner/adapters/pi.d.ts +3 -2
  90. package/dist/runner/adapters/pi.js +3 -1
  91. package/dist/runner/audit.d.ts +1 -1
  92. package/dist/runner/claim-secrets.d.ts +3 -1
  93. package/dist/runner/claim-secrets.js +18 -7
  94. package/dist/runner/cli-run-spec.js +24 -17
  95. package/dist/runner/compare-end.d.ts +1 -1
  96. package/dist/runner/dispatch.js +4 -2
  97. package/dist/runner/harness-loops.d.ts +14 -0
  98. package/dist/runner/harness-loops.js +51 -5
  99. package/dist/runner/held.d.ts +4 -1
  100. package/dist/runner/live-ticker.js +5 -4
  101. package/dist/runner/loop-contract.d.ts +4 -1
  102. package/dist/runner/mcp-claim.js +3 -2
  103. package/dist/runner/mcp-run.d.ts +24 -4
  104. package/dist/runner/mcp-run.js +47 -2
  105. package/dist/runner/meta-tools.js +4 -4
  106. package/dist/runner/metrics.d.ts +6 -0
  107. package/dist/runner/metrics.js +12 -4
  108. package/dist/runner/monid-run.js +3 -1
  109. package/dist/runner/native-loop.js +3 -3
  110. package/dist/runner/redact.d.ts +3 -0
  111. package/dist/runner/redact.js +7 -0
  112. package/dist/runner/run-child-host.d.ts +10 -6
  113. package/dist/runner/run-child-host.js +44 -29
  114. package/dist/runner/run-child.js +1 -0
  115. package/dist/runner/runner.js +2 -0
  116. package/dist/runner/sdk-loop.js +5 -3
  117. package/dist/runner/workflow-calls.d.ts +5 -1
  118. package/dist/runner/workflow-calls.js +65 -19
  119. package/dist/runner/workflow-loop.d.ts +1 -1
  120. package/dist/runner/workflow-loop.js +3 -1
  121. package/dist/runner/workflow-spec.d.ts +4 -0
  122. package/dist/runner/workflow-spec.js +18 -13
  123. package/dist/runs-over-store.d.ts +2 -2
  124. package/dist/runs-over-store.js +1 -1
  125. package/dist/secret-cut.js +7 -4
  126. package/dist/secret-rules.d.ts +0 -1
  127. package/dist/secret-rules.js +122 -88
  128. package/dist/server.d.ts +17 -1
  129. package/dist/server.js +208 -69
  130. package/dist/share-host.d.ts +111 -0
  131. package/dist/share-host.js +666 -0
  132. package/dist/slack.js +2 -1
  133. package/dist/store/postgres/migrate.js +3 -1
  134. package/dist/store-reads/analytics.d.ts +15 -0
  135. package/dist/store-reads/analytics.js +17 -0
  136. package/dist/store-reads/learning.d.ts +5 -4
  137. package/dist/store-reads/learning.js +7 -4
  138. package/dist/suggestions.js +32 -3
  139. package/dist/templates.d.ts +3 -1
  140. package/dist/templates.js +7 -3
  141. package/dist/tool-gate.d.ts +25 -9
  142. package/dist/tool-gate.js +58 -19
  143. package/dist/tool-plane.d.ts +24 -1
  144. package/dist/tool-plane.js +75 -3
  145. package/dist/tools.d.ts +12 -2
  146. package/dist/tools.js +42 -7
  147. package/dist/trigger-composio.js +1 -1
  148. package/dist/trigger-launch-hook.d.ts +2 -2
  149. package/dist/trigger-launch-hook.js +1 -1
  150. package/dist/triggers.d.ts +7 -4
  151. package/dist/triggers.js +4 -4
  152. package/dist/webhooks.d.ts +3 -0
  153. package/dist/webhooks.js +5 -0
  154. package/dist/workspace/archil-claim.d.ts +7 -3
  155. package/dist/workspace/archil-claim.js +13 -5
  156. package/dist/workspace/archil-mount-credential.d.ts +6 -0
  157. package/dist/workspace/archil-mount-credential.js +11 -0
  158. package/dist/workspace/computer-deps.d.ts +5 -3
  159. package/dist/workspace/computer-deps.js +11 -9
  160. package/dist/workspace/computer-for-claim.d.ts +6 -2
  161. package/dist/workspace/computer-for-claim.js +43 -12
  162. package/dist/workspace/computer-janitor.d.ts +7 -4
  163. package/dist/workspace/computer-janitor.js +7 -4
  164. package/dist/workspace/computer-kept.d.ts +7 -1
  165. package/dist/workspace/computer-kept.js +7 -1
  166. package/dist/workspace/kind-skills/desktop/SKILL.md +12 -3
  167. package/dist/workspace/mount-revoke-left.d.ts +16 -4
  168. package/dist/workspace/mount-revoke-left.js +42 -22
  169. package/dist/workspace/resolve-computer.d.ts +11 -5
  170. package/dist/workspace/resolve-computer.js +22 -13
  171. package/dist/workspace/run-end-computers.js +1 -1
  172. package/dist/workspace/run-tools.d.ts +10 -3
  173. package/dist/workspace/run-tools.js +5 -4
  174. package/dist/wrapped.d.ts +29 -2
  175. package/dist/wrapped.js +20 -3
  176. package/launcher/agentrun-serve +1 -1
  177. package/package.json +12 -12
  178. package/dist/console/assets/index-DZi-muIj.js +0 -629
  179. package/dist/console/assets/share-pz61zIn9.js +0 -6
@@ -0,0 +1,6 @@
1
+ var z=Object.defineProperty;var B=(t,s,a)=>s in t?z(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var T=(t,s,a)=>B(t,typeof s!="symbol"?s+"":s,a);import{c as L,a6 as e,a9 as F,ao as P,r as c,b1 as M,am as R,as as D,cM as N,aY as U,a7 as v,a_ as G,bU as H,cr as K,cu as V,cB as W,a$ as Y,b6 as Z,aR as J,bV as q,ab as C,ag as $,cK as Q,cL as X}from"./styles-BGZxYkky.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const ee=L("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),te="agentrun.share/1",se=new Set(["label","personal","jev"]),ae=(t,s=!1)=>se.has(t.kind)&&(s||t.restorable===!0),j={format:"A known key format: never published.",held:"A value this server holds: never published.",dump:"An environment or file dump: never published."},re=[{kind:"personal",name:"Personal",about:"Emails, home folders, private addresses. Restore one only if you mean to publish it."},{kind:"label",name:"Labelled",about:"A value written after a name like PASSWORD= or token:. Restore one only if it is not a secret."},{kind:"jev",name:"Judged",about:"A value a model judged to be private."},{kind:"format",name:"Key formats",about:j.format},{kind:"held",name:"Held values",about:j.held},{kind:"dump",name:"Dumps",about:j.dump}];function ne(t,s){const a=s.restored.map(n=>n.id);return["agentrun share",t,...a.length?["--restore",a.join(",")]:[],"--expect",s.sha256].join(" ")}const oe=t=>t.replace(/~1/g,"/").replace(/~0/g,"~");function k(t,s){var l;const[a,...n]=t.split("/").slice(1).map(oe);if(a==="rows"&&n.length>=1)return`Timeline step ${Number(n[0])+1}${n.length>1?` · ${n.slice(1).join(".")}`:""}`;if(a==="run"){const r=n.join("/");return r==="title"?"Run title":r==="result/final_answer"?"Answer":r.startsWith("result/output")?"Output":`Run ${r.replace(/[/_]/g," ")}`}if(a==="files"&&n.length>=1){const r=((l=s.files[Number(n[0])])==null?void 0:l.path)??`File ${Number(n[0])+1}`;return n[1]==="path"?`${r} (its name)`:r}return a==="agent"?"Agent name":a==="graph"?`Graph · ${n.join("/")}`:t}function _(t){const s=t;return!!s&&s.format===te&&typeof s.sha256=="string"&&!!s.run&&typeof s.run=="object"&&Array.isArray(s.rows)&&Array.isArray(s.files)&&Array.isArray(s.cuts)&&Array.isArray(s.restored)&&Array.isArray(s.omitted)}function le({runId:t,base:s=""}){return{async load(a,n){const l=`${s}/v2/runs/${encodeURIComponent(t)}/export${a.length?`?restore=${a.map(encodeURIComponent).join(",")}`:""}`;let r;try{r=await fetch(l,{method:"GET",credentials:"same-origin",headers:{accept:"application/json"},signal:n})}catch(o){if((o==null?void 0:o.name)==="AbortError")throw o;return{ok:!1,status:0}}if(!r.ok)return{ok:!1,status:r.status};const i=await r.json().catch(()=>{});return _(i)?{ok:!0,bundle:i}:{ok:!1,status:500}}}}function ie({shareId:t,base:s=""}){return{async load(a,n){let l;try{l=await fetch(`${s}/r/${encodeURIComponent(t)}/bundle.json`,{method:"GET",credentials:"omit",headers:{accept:"application/json"},signal:n})}catch(i){if((i==null?void 0:i.name)==="AbortError")throw i;return{ok:!1,status:0}}if(!l.ok)return{ok:!1,status:l.status};const r=await l.json().catch(()=>{});return _(r)?{ok:!0,bundle:r}:{ok:!1,status:500}}}}const de=/^[a-z2-7]{26}$/;function ce(t){const s=/^\/r\/([^/]+)\/?$/.exec(t);return s&&de.test(s[1])?s[1]:null}function he(t){const s=(new URLSearchParams(t).get("restore")??"").split(",").map(a=>a.trim());return[...new Set(s.filter(a=>/^c_[0-9a-f]{16}$/.test(a)))]}const ue=/^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;function me(t){const s=/^\/share\/([^/]+)\/?$/.exec(t);return s&&ue.test(s[1])?s[1]:null}const S=t=>{var s;return`${((s=/^\/rows\/\d+(?=\/)/.exec(t.at))==null?void 0:s[0])??t.at}|${t.rule}|${t.start}|${t.end}`};function xe(t){const s=new Map;for(const a of t)s.set(S(a),[...s.get(S(a))??[],a]);return[...s.values()].flatMap(a=>a.map((n,l)=>({...n,first:l===0})))}function pe({bundle:t,onToggle:s,pending:a}){const n=[...t.cuts.map(r=>({id:r.id,at:r.at,start:r.start,end:r.end,rule:r.rule,kind:r.kind,shape:r.shape,restored:!1,restorable:r.restorable})),...t.restored.map(r=>({id:r.id,at:r.at,start:r.start,end:r.end,rule:r.rule,kind:r.kind,restored:!0}))],l=re.map(r=>({...r,items:xe(n.filter(i=>i.kind===r.kind))})).filter(r=>r.items.length);return e.jsxs("section",{"aria-label":"Cuts",className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"caps text-small font-semibold text-muted-foreground",children:"What the scrubber cut"}),e.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:n.length?`${n.length} ${n.length===1?"value":"values"} cut from this run. A switch exports it again with that value put back.`:"Nothing in this run needed a cut."})]}),l.map(r=>{const i=Object.hasOwn(j,r.kind);return e.jsxs("section",{"data-kind":r.kind,className:"border bg-card",children:[e.jsxs("header",{className:"border-b px-3 py-2",children:[e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"caps text-small font-semibold",children:r.name}),e.jsx(F,{tone:i?"muted":"plain",children:e.jsx("span",{"data-count":!0,children:r.items.length})})]}),e.jsx("p",{className:"mt-1 text-label text-muted-foreground",children:r.about})]}),e.jsx("ul",{children:r.items.map((o,h)=>{const p=ae(o,o.restored),f=`Restore the ${o.rule} value in ${k(o.at,t)}`;return e.jsxs("li",{"data-cut":o.id,className:`flex items-center gap-3 px-3 ${o.first?`py-2${h>0?" border-t":""}`:"pb-2"}`,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate font-mono text-small",title:k(o.at,t),children:k(o.at,t)}),e.jsxs("p",{className:"truncate font-mono text-label text-muted-foreground",title:`${o.at} ${o.start}–${o.end}`,children:[e.jsxs("span",{"data-pointer":!0,children:[o.at," ",o.start,"–",o.end]})," · ",o.rule,o.restored?" · restored, published as it is":o.shape?` · ${o.shape}`:""]})]}),p?e.jsx(P,{checked:o.restored,onChange:b=>s(o.id,b),label:f,busy:a}):e.jsxs("span",{"data-locked":!0,className:"flex shrink-0 items-center gap-1 font-mono text-label text-muted-foreground",title:j[o.kind]??"Not restorable.",children:[e.jsx(ee,{className:"size-3","aria-hidden":!0})," Locked"]})]},o.id)})})]},r.kind)})]})}const fe=t=>{if(t.what==="recordings")return"Recordings and screenshots are never shared.";if(t.what==="files")return"The run's file list was cut at its cap: the files past it are not in the bundle.";const s={binary:"binary: no scrubber reads it",too_large:"over 256 KiB",over_total:"past the 4 MiB the files may take",over_count:"past 200 files",unreadable:"could not be read"};return`${t.path}: ${s[t.why]??t.why}`};function O({bundle:t,preview:s}){var y;const{run:a}=t,n=a,l=t.files.map(d=>({path:d.path,size_bytes:d.bytes})),[r,i]=c.useState("report"),[o,h]=c.useState(null),p=d=>{h(d),i("files")},f=[{id:"report",label:"Report"},{id:"timeline",label:`Timeline (${t.rows.length})`},...t.graph?[{id:"graph",label:"Graph"}]:[],{id:"files",label:`Files (${t.files.length})`}],b=M(a.status),w=[t.agent.name||"An agent",a.kind==="workflow"?"Workflow":null,a.created_at?`${R(a.created_at)}${a.ended_at?` to ${R(a.ended_at)}`:""}`:null,a.cost?D(a.cost,{ended:b}):null,(y=a.imported_from)!=null&&y.source?`Imported from ${a.imported_from.source}`:null].filter(Boolean),g=s?"max-w-6xl":"max-w-4xl";return e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx("header",{className:"shrink-0 border-b",children:e.jsxs("div",{className:v("mx-auto px-5 py-4 md:px-8",g),children:[e.jsx("p",{className:"caps text-label text-muted-foreground",children:s?"AgentRun · share preview":"AgentRun · shared run"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3",children:[e.jsx("h1",{className:"min-w-0 break-words text-2xl font-semibold",children:e.jsx(N,{text:a.title||"Untitled run"})}),e.jsx(U,{run:n})]}),e.jsx("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:w.map((d,u)=>e.jsxs("span",{children:[u?" · ":"",e.jsx(N,{text:d})]},u))})]})}),e.jsx("main",{className:"min-h-0 flex-1 overflow-auto",children:e.jsxs("div",{className:v("mx-auto flex flex-col gap-8 py-6 lg:flex-row",g),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(G,{id:"share",tabs:f,value:r,onChange:i,label:"The run's views"}),e.jsxs("div",{...Y("share",r),className:"space-y-6 px-5 py-6 md:px-8",children:[r==="report"&&e.jsxs(e.Fragment,{children:[a.status==="failed"&&a.error&&e.jsx(H,{error:a.error}),a.review&&e.jsxs("section",{className:"border border-warning/50 bg-warning/10 p-4","aria-label":"Needs review",children:[e.jsx("p",{className:"caps text-label text-warning-text",children:"Needs review"}),e.jsx("p",{className:"mt-2 text-lead",children:e.jsx(N,{text:a.review.reason})})]}),e.jsx(K,{run:n,rows:t.rows,files:l,onOpen:d=>p(d.path),shared:!0})]}),r==="timeline"&&e.jsx(V,{rows:t.rows,live:!1,ended:!0,files:l,onOpen:d=>p(d.path),shared:!0}),r==="graph"&&t.graph&&e.jsx("div",{className:"-mx-5 border-y md:-mx-8",children:e.jsx(W,{data:t.graph,fileUrl:()=>"",shared:!0})}),r==="files"&&e.jsx(ge,{bundle:t,open:o,onOpen:h})]})]}),s&&e.jsx("aside",{className:"w-full shrink-0 px-5 md:px-8 lg:w-[360px] lg:pl-0",children:e.jsx(pe,{bundle:t,onToggle:s.onToggle,pending:s.pending})})]})}),s&&e.jsx(be,{bundle:t,preview:s,width:g})]})}function ge({bundle:t,open:s,onOpen:a}){const n=t.files.find(l=>l.path===s);return e.jsxs("div",{className:"space-y-6",children:[t.files.length?e.jsx("ul",{className:"divide-y border bg-card",children:t.files.map(l=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:v("flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-accent",l.path===s&&"bg-primary/[0.06] text-primary"),onClick:()=>a(l.path),"aria-pressed":l.path===s,children:[e.jsx(Z,{className:"size-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:l.path}),e.jsx("span",{className:"font-mono text-label text-muted-foreground tabular-nums",children:J(l.bytes)})]})},l.path))}):e.jsx("p",{className:"text-body text-muted-foreground",children:"The bundle carries no files."}),n&&e.jsxs("section",{"aria-label":n.path,children:[e.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:n.path}),e.jsx("pre",{className:"max-h-[60dvh] overflow-auto whitespace-pre-wrap break-words border bg-card p-4 font-mono text-small leading-[1.7]",children:e.jsx(N,{text:n.content})})]}),t.omitted.length>0&&e.jsxs("section",{children:[e.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:"Left out of the bundle"}),e.jsx("ul",{className:"space-y-1 font-mono text-small text-muted-foreground",children:t.omitted.map((l,r)=>e.jsx("li",{children:fe(l)},r))})]})]})}function be({bundle:t,preview:s,width:a}){const n=ne(s.runId,t);return e.jsx("footer",{className:"shrink-0 border-t bg-card",children:e.jsxs("div",{className:v("mx-auto space-y-2 px-5 py-3 md:px-8",a),children:[e.jsx("p",{className:"text-body font-semibold",children:"Nothing was sent. This is the exact page a share host would show."}),e.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:["sha256 ",e.jsx("span",{className:"break-all text-foreground",children:t.sha256})]}),s.pending?e.jsx("p",{className:"font-mono text-small text-muted-foreground",role:"status",children:"Exporting again with your restores…"}):e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all border bg-background px-3 py-2 font-mono text-small",children:n}),e.jsx(q,{text:n,label:"Copy"})]}),e.jsx("p",{className:"text-label text-muted-foreground max-sm:hidden",children:"Publishing comes with a share host in a later beta. The command checks a fresh export against this sha256 and refuses if the run changed."})]})})}function je(t,s){switch(t){case 0:return{title:"Can't reach agentrun-serve.",why:"It may be restarting. Try again in a moment."};case 400:return{title:"The server refused the restore.",why:"A cut it names is not restorable, or is not in this run's bundle. Nothing was restored."};case 401:return{title:"This browser is not signed in to this server.",why:"Open the console at this address, sign in, then open this page again."};case 403:return{title:"This run is withheld.",why:"This server can't read back a sign-in the run was handed, so nothing of the run is exported."};case 404:return{title:`This server has no run ${s}.`,why:"Check the run id in the address."};case 409:return{title:"This run hasn't ended.",why:"A run can be shared once it has ended. Open this page again then."};case 413:return{title:"This run is too large to share.",why:"Its bundle is over 8 MiB. Nothing of it is cut short, so it does not export."};default:return{title:"The export failed closed.",why:"Nothing of the run is shown, and nothing was sent. The server's log says why."}}}function we(t){switch(t){case 0:return{title:"Can't reach this share host.",why:"Try again in a moment."};case 404:return{title:"There is no share at this address.",why:"Check the link you were given."};case 410:return{title:"This share was deleted.",why:"Its owner deleted it, and nothing of it is kept here."};default:return{title:"This share can't be shown.",why:"Try again in a moment."}}}function I({title:t,why:s,retry:a}){return e.jsx("main",{className:"flex min-h-dvh items-start justify-center px-5 py-16",children:e.jsxs("section",{className:"flex max-w-xl gap-3 border bg-card px-5 py-4",role:"alert",children:[e.jsx(C,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"caps text-label text-muted-foreground",children:"AgentRun · shared run"}),e.jsx("p",{className:"mt-2 text-prose font-semibold",children:t}),e.jsx("p",{className:"mt-1 text-lead leading-relaxed",children:s}),a&&e.jsx("div",{className:"mt-3",children:e.jsx($,{type:"button",size:"sm",onClick:a,children:"Try again"})})]})]})})}class ye extends c.Component{constructor(){super(...arguments);T(this,"state",{failed:!1})}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?e.jsx(I,{title:"This share can't be shown.",why:"Its stored document doesn't have the shape this page draws."}):this.props.children}}function Ne({source:t}){const[s,a]=c.useState(0),[n,l]=c.useState(null);if(c.useEffect(()=>{const o=new AbortController;return l(null),t.load([],o.signal).then(l,h=>{(h==null?void 0:h.name)!=="AbortError"&&l({ok:!1,status:0})}),()=>o.abort()},[t,s]),!n)return e.jsx("main",{className:"flex min-h-dvh items-center justify-center",children:e.jsx("p",{className:"font-mono text-body text-muted-foreground",role:"status",children:"Loading the share…"})});if(n.ok)return e.jsx(ye,{children:e.jsx(O,{bundle:n.bundle})});const{title:r,why:i}=we(n.status);return e.jsx(I,{title:r,why:i,retry:n.status!==404&&n.status!==410?()=>a(o=>o+1):void 0})}function ve({source:t,runId:s,restore:a=[]}){const[n,l]=c.useState(a),[r,i]=c.useState(0),[o,h]=c.useState(null),[p,f]=c.useState(null),[b,w]=c.useState(!0),g=c.useRef(0);if(c.useEffect(()=>{const d=++g.current,u=new AbortController;w(!0);const m=x=>{d===g.current&&(w(!1),x.ok?(h(x.bundle),f(null)):(h(null),f(x.status)))};return t.load(n,u.signal).then(m,x=>{(x==null?void 0:x.name)!=="AbortError"&&m({ok:!1,status:0})}),()=>u.abort()},[t,n,r]),p!==null){const{title:d,why:u}=je(p,s);return e.jsx("main",{className:"flex min-h-dvh items-start justify-center px-5 py-16",children:e.jsxs("section",{className:"flex max-w-xl gap-3 border bg-card px-5 py-4",role:"alert",children:[e.jsx(C,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"caps text-label text-muted-foreground",children:"AgentRun · share preview"}),e.jsx("p",{className:"mt-2 text-prose font-semibold",children:d}),e.jsx("p",{className:"mt-1 text-lead leading-relaxed",children:u}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:p===400?e.jsx($,{type:"button",size:"sm",onClick:()=>l([]),children:"Start again with every cut in place"}):e.jsx($,{type:"button",size:"sm",onClick:()=>i(m=>m+1),children:"Try again"})})]})]})})}if(!o)return e.jsx("main",{className:"flex min-h-dvh items-center justify-center",children:e.jsx("p",{className:"font-mono text-body text-muted-foreground",role:"status",children:"Exporting the run…"})});const y=(d,u)=>l(m=>u?m.includes(d)?m:[...m,d]:m.filter(x=>x!==d));return e.jsx(O,{bundle:o,preview:{runId:s,onToggle:y,pending:b}})}Q();const A=me(window.location.pathname),E=ce(window.location.pathname);X.createRoot(document.getElementById("root")).render(e.jsx(c.StrictMode,{children:E?e.jsx(Ne,{source:ie({shareId:E})}):A?e.jsx(ve,{source:le({runId:A}),runId:A,restore:he(window.location.search)}):e.jsx("main",{className:"p-8 font-mono text-body text-muted-foreground",role:"alert",children:"This address names no run. A share preview opens at /share/<run id>."})}));
@@ -272,7 +272,7 @@ ${r}</tr>
272
272
  `+this.renderer.text(h);o?i+=this.renderer.paragraph({type:"paragraph",raw:g,text:g,tokens:[{type:"text",raw:g,text:g,escaped:!0}]}):i+=g;continue}default:{const h='Token with "'+m.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return i}parseInline(r,o=this.renderer){var a,u;let i="";for(let f=0;f<r.length;f++){const d=r[f];if((u=(a=this.options.extensions)==null?void 0:a.renderers)!=null&&u[d.type]){const h=this.options.extensions.renderers[d.type].call({parser:this},d);if(h!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(d.type)){i+=h||"";continue}}const m=d;switch(m.type){case"escape":{i+=o.text(m);break}case"html":{i+=o.html(m);break}case"link":{i+=o.link(m);break}case"image":{i+=o.image(m);break}case"strong":{i+=o.strong(m);break}case"em":{i+=o.em(m);break}case"codespan":{i+=o.codespan(m);break}case"br":{i+=o.br(m);break}case"del":{i+=o.del(m);break}case"text":{i+=o.text(m);break}default:{const h='Token with "'+m.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return i}}class li{constructor(r){Te(this,"options");Te(this,"block");this.options=r||fo}preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}provideLexer(){return this.block?Kt.lex:Kt.lexInline}provideParser(){return this.block?Yt.parse:Yt.parseInline}}Te(li,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class S1{constructor(...r){Te(this,"defaults",Yc());Te(this,"options",this.setOptions);Te(this,"parse",this.parseMarkdown(!0));Te(this,"parseInline",this.parseMarkdown(!1));Te(this,"Parser",Yt);Te(this,"Renderer",Kl);Te(this,"TextRenderer",rd);Te(this,"Lexer",Kt);Te(this,"Tokenizer",Ql);Te(this,"Hooks",li);this.use(...r)}walkTokens(r,o){var a,u;let i=[];for(const f of r)switch(i=i.concat(o.call(this,f)),f.type){case"table":{const d=f;for(const m of d.header)i=i.concat(this.walkTokens(m.tokens,o));for(const m of d.rows)for(const h of m)i=i.concat(this.walkTokens(h.tokens,o));break}case"list":{const d=f;i=i.concat(this.walkTokens(d.items,o));break}default:{const d=f;(u=(a=this.defaults.extensions)==null?void 0:a.childTokens)!=null&&u[d.type]?this.defaults.extensions.childTokens[d.type].forEach(m=>{const h=d[m].flat(1/0);i=i.concat(this.walkTokens(h,o))}):d.tokens&&(i=i.concat(this.walkTokens(d.tokens,o)))}}return i}use(...r){const o=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(i=>{const a={...i};if(a.async=this.defaults.async||a.async||!1,i.extensions&&(i.extensions.forEach(u=>{if(!u.name)throw new Error("extension name required");if("renderer"in u){const f=o.renderers[u.name];f?o.renderers[u.name]=function(...d){let m=u.renderer.apply(this,d);return m===!1&&(m=f.apply(this,d)),m}:o.renderers[u.name]=u.renderer}if("tokenizer"in u){if(!u.level||u.level!=="block"&&u.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const f=o[u.level];f?f.unshift(u.tokenizer):o[u.level]=[u.tokenizer],u.start&&(u.level==="block"?o.startBlock?o.startBlock.push(u.start):o.startBlock=[u.start]:u.level==="inline"&&(o.startInline?o.startInline.push(u.start):o.startInline=[u.start]))}"childTokens"in u&&u.childTokens&&(o.childTokens[u.name]=u.childTokens)}),a.extensions=o),i.renderer){const u=this.defaults.renderer||new Kl(this.defaults);for(const f in i.renderer){if(!(f in u))throw new Error(`renderer '${f}' does not exist`);if(["options","parser"].includes(f))continue;const d=f,m=i.renderer[d],h=u[d];u[d]=(...g)=>{let w=m.apply(u,g);return w===!1&&(w=h.apply(u,g)),w||""}}a.renderer=u}if(i.tokenizer){const u=this.defaults.tokenizer||new Ql(this.defaults);for(const f in i.tokenizer){if(!(f in u))throw new Error(`tokenizer '${f}' does not exist`);if(["options","rules","lexer"].includes(f))continue;const d=f,m=i.tokenizer[d],h=u[d];u[d]=(...g)=>{let w=m.apply(u,g);return w===!1&&(w=h.apply(u,g)),w}}a.tokenizer=u}if(i.hooks){const u=this.defaults.hooks||new li;for(const f in i.hooks){if(!(f in u))throw new Error(`hook '${f}' does not exist`);if(["options","block"].includes(f))continue;const d=f,m=i.hooks[d],h=u[d];li.passThroughHooks.has(f)?u[d]=g=>{if(this.defaults.async)return Promise.resolve(m.call(u,g)).then(x=>h.call(u,x));const w=m.call(u,g);return h.call(u,w)}:u[d]=(...g)=>{let w=m.apply(u,g);return w===!1&&(w=h.apply(u,g)),w}}a.hooks=u}if(i.walkTokens){const u=this.defaults.walkTokens,f=i.walkTokens;a.walkTokens=function(d){let m=[];return m.push(f.call(this,d)),u&&(m=m.concat(u.call(this,d))),m}}this.defaults={...this.defaults,...a}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,o){return Kt.lex(r,o??this.defaults)}parser(r,o){return Yt.parse(r,o??this.defaults)}parseMarkdown(r){return(i,a)=>{const u={...a},f={...this.defaults,...u},d=this.onError(!!f.silent,!!f.async);if(this.defaults.async===!0&&u.async===!1)return d(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof i>"u"||i===null)return d(new Error("marked(): input parameter is undefined or null"));if(typeof i!="string")return d(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(i)+", string expected"));f.hooks&&(f.hooks.options=f,f.hooks.block=r);const m=f.hooks?f.hooks.provideLexer():r?Kt.lex:Kt.lexInline,h=f.hooks?f.hooks.provideParser():r?Yt.parse:Yt.parseInline;if(f.async)return Promise.resolve(f.hooks?f.hooks.preprocess(i):i).then(g=>m(g,f)).then(g=>f.hooks?f.hooks.processAllTokens(g):g).then(g=>f.walkTokens?Promise.all(this.walkTokens(g,f.walkTokens)).then(()=>g):g).then(g=>h(g,f)).then(g=>f.hooks?f.hooks.postprocess(g):g).catch(d);try{f.hooks&&(i=f.hooks.preprocess(i));let g=m(i,f);f.hooks&&(g=f.hooks.processAllTokens(g)),f.walkTokens&&this.walkTokens(g,f.walkTokens);let w=h(g,f);return f.hooks&&(w=f.hooks.postprocess(w)),w}catch(g){return d(g)}}}onError(r,o){return i=>{if(i.message+=`
273
273
  Please report this to https://github.com/markedjs/marked.`,r){const a="<p>An error occurred:</p><pre>"+bn(i.message+"",!0)+"</pre>";return o?Promise.resolve(a):a}if(o)return Promise.reject(i);throw i}}}const lo=new S1;function $e(t,r){return lo.parse(t,r)}$e.options=$e.setOptions=function(t){return lo.setOptions(t),$e.defaults=lo.defaults,hg($e.defaults),$e};$e.getDefaults=Yc;$e.defaults=fo;$e.use=function(...t){return lo.use(...t),$e.defaults=lo.defaults,hg($e.defaults),$e};$e.walkTokens=function(t,r){return lo.walkTokens(t,r)};$e.parseInline=lo.parseInline;$e.Parser=Yt;$e.parser=Yt.parse;$e.Renderer=Kl;$e.TextRenderer=rd;$e.Lexer=Kt;$e.lexer=Kt.lex;$e.Tokenizer=Ql;$e.Hooks=li;$e.parse=$e;$e.options;$e.setOptions;$e.use;$e.walkTokens;$e.parseInline;Yt.parse;Kt.lex;function _g(t,r){return r&&(t!=null&&t.startsWith(`${r}/`))&&t.length>r.length+1?t.slice(r.length+1):t}const m_="https://chatgpt.com/#settings",Oc="chatgpt",od=t=>!!t&&t.startsWith(`${Oc}/`)&&t.length>Oc.length+1,E1="Codex and pi agents run on your ChatGPT plan. Claude Agent, OpenCode, Jev decisions and paid tools need their own keys.",_1="This server sends its models to a gateway, so agents run there by default. An agent runs on your ChatGPT plan only when it names one of the plan's models (chatgpt/…).",g_=(t,r,o)=>t==="gateway"&&!od(_g(r,o))?_1:E1,y_="Signing in on this computer finishes by itself. On a server elsewhere, the tab ends on a page that won't load: copy that tab's whole address and paste it here.",v_="This sign-in is yours: don't let other people run agents on this server with it.",w_="Signed out. If ChatGPT still lists AgentRun under connected apps, disconnect it there.",x_="Signed out here. OpenAI didn't confirm the revocation: remove AgentRun in your ChatGPT settings.",k_="Your ChatGPT sign-in expired. Sign in again.",Ng="Requests on your ChatGPT plan cost no dollars here; your plan's own limits apply.",b_=`Counts dollars. ${Ng}`,N1=new Set(["signed_out","pending","signed_in","expired"]),S_=t=>t&&typeof t=="object"&&N1.has(String(t.state))?t:null,C1=t=>t.charAt(0).toUpperCase()+t.slice(1),E_=t=>`Signed in as ${t.email??"your ChatGPT account"}${t.plan?` (${C1(t.plan)})`:""}`,__="Use Claude Code's login on this machine",N_="claude-agent",C_=t=>t===void 0||t===""||typeof t=="string"&&t.startsWith("anthropic/"),T_="Claude Agent runs on your Claude plan through the Claude Code CLI on this server's machine. The CLI keeps the login and calls Anthropic itself; AgentRun only asks it whether it is signed in.",T1="Only I run agents on this server",$_="Runs here would use your Claude plan, which is yours alone.",j_=`Tick "${T1}" to turn it on.`;function A_(t,r){var o;return t==="agentrun"?"A login of AgentRun's own (sign in once for it)":`This machine's Claude Code login (${((o=r.machine)==null?void 0:o.folder)??"~/.claude"})`}const R_=t=>`AgentRun asks the CLI about the login in ${t}.`,O_="That is Claude Code's default folder. If your Claude Code keeps its login in another one (it runs with CLAUDE_CONFIG_DIR set), start AgentRun with CLAUDE_CONFIG_DIR set to that folder as well.",L_=t=>t?`Its credentials are read from ${t}, as CLAUDE_SECURESTORAGE_CONFIG_DIR in the server's environment says.`:"Its credentials are read where CLAUDE_SECURESTORAGE_CONFIG_DIR set empty in the server's environment puts them: ~/.claude, and on macOS the Keychain item with no suffix.";function Uh(t){if(t>=6e4){const o=Math.round(t/6e4);return`${o} minute${o===1?"":"s"}`}const r=Math.max(1,Math.round(t/1e3));return`${r} second${r===1?"":"s"}`}function P_(t){const r=t.sign_in;if(!r||t.state==="signed_in")return null;switch(r.state){case"waiting":return`Waiting for the browser: finish signing in on the page the CLI opened. The sign-in stops after ${Uh(r.limit_ms)}.`;case"timed_out":return`The sign-in stopped after ${Uh(r.limit_ms)} with no answer from the browser, so a sign-in page still open can't finish. Open the CLI's sign-in here starts it again.`;case"failed":return`The CLI's sign-in ended without signing in (${r.exit_code!==void 0?`exit code ${r.exit_code}`:r.signal?`ended by ${r.signal}`:"no exit code"}). Open the CLI's sign-in here starts it again, or run the line above in a terminal.`;case"not_started":return`The CLI's sign-in could not start${r.error?`: ${r.error}`:""}. Run the line above in a terminal.`;case"signed_in":return`The CLI's sign-in ended signed in, but the CLI says the login${t.folder?` in ${t.folder}`:""} is not signed in. Run the line above in a terminal on the server's machine.`}}const M_="Not signed in. Run this in a terminal on the server's machine; the CLI opens a browser there:",I_="No Claude Code CLI here yet: the first Claude Agent run installs it. Or run this with a claude CLI of your own:",z_="The Claude Code CLI didn't say whether it is signed in. Sign in again with:",D_="Turned on for another machine: Claude Agent runs here use the model keys.",F_="Turned on, and not used while this server refuses its folders: Claude Agent runs here use the model keys. It is used again once that is mended, or turn it off.",U_=t=>t.state==="signed_in"&&t.place==="agentrun",W_="Sign out of Claude here? AgentRun's copy of the login is removed and the mode turns off. Turn it on again to sign in, with this account or another.",B_="Signed out. Turn it on again to sign in, with this account or another.",$1="Requests on your Claude plan through Claude Code's login cost no dollars here; your plan's own limits apply.",j1=new Set(["off","other_machine","refused","signed_in","signed_out","no_cli","unknown"]);function H_(t){if(!t||typeof t!="object"||!j1.has(String(t.state)))return null;const{folder:r,machine:o,...i}=t,a=o&&typeof o=="object"&&typeof o.folder=="string"&&typeof o.source=="string";return{...i,...typeof r=="string"?{folder:r}:{},...a?{machine:o}:{}}}function G_(t){var o,i;const r=(o=t.account)!=null&&o.plan?` (${t.account.plan.charAt(0).toUpperCase()}${t.account.plan.slice(1)})`:"";return`Signed in as ${((i=t.account)==null?void 0:i.email)??"your Claude account"}${r}`}const q_="Claude Max, Ultra and Team plans include monthly API credits: a key from the Claude Console organization linked to the plan runs Claude Agent on them, AgentRun Cloud included. Pro, Free and Enterprise plans don't.",sd=String.raw`\[redacted:[a-z0-9-]{1,64}(?: \d{1,9} lines)?\]`,Cg=new RegExp(sd,"g"),Tg=t=>/^\[redacted:([a-z0-9-]+)/.exec(t)[1],$g="redaction";function ao({text:t}){const r=[];let o=0;for(const i of t.matchAll(Cg))i.index>o&&r.push(t.slice(o,i.index)),r.push(y.jsx("span",{className:$g,"data-rule":Tg(i[0]),children:i[0]},i.index)),o=i.index+i[0].length;return r.length?(o<t.length&&r.push(t.slice(o)),y.jsx(O.Fragment,{children:r})):t}function A1(t){const r=t.ownerDocument,o=r.createTreeWalker(t,4),i=[];for(let a=o.nextNode();a;a=o.nextNode())new RegExp(sd).test(a.nodeValue??"")&&i.push(a);for(const a of i){const u=a.nodeValue,f=r.createDocumentFragment();let d=0;for(const m of u.matchAll(Cg)){m.index>d&&f.append(u.slice(d,m.index));const h=r.createElement("span");h.className=$g,h.dataset.rule=Tg(m[0]),h.textContent=m[0],f.append(h),d=m.index+m[0].length}d<u.length&&f.append(u.slice(d)),a.replaceWith(f)}}let Ys;const R1=t=>(Ys||(Fl.addHook("uponSanitizeElement",(r,o)=>{Ys??(Ys=o.allowedTags)}),Fl.sanitize("<b></b>"),Fl.removeHook("uponSanitizeElement")),(Ys==null?void 0:Ys[t.toLowerCase()])===!0),O1=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");$e.use({breaks:!0,renderer:{html:({text:t,block:r})=>{let o=0;const i=t.replace(/<\/?([A-Za-z][\w:-]*)[^<>]*>/g,(a,u)=>R1(u)?(o++,a):O1(a));return r&&!o&&i!==t?`<p>${i.trim().replace(/\n/g,`<br>
274
274
  `)}</p>
275
- `:i}}});const V_=t=>t.slice(-8),L1=t=>new Date(t).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),Q_=t=>new Date(t).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function K_(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}const Y_=t=>t.basis==="estimate",P1=t=>t.basis==="estimate"?" est.":t.basis==="reported"?" reported":"",X_=t=>t.basis==="estimate"?"A local estimate, not a bill":t.basis==="reported"?"As the provider or gateway reported it":t.basis==="unpriced"?"No model request was priced":void 0;function Z_(t){const r=t==null?void 0:t.tokens;if(!r)return;const o=[`${qo(r.input)} in`,`${qo(r.output)} out`];return r.cache_read>0&&o.push(`${qo(r.cache_read)} cache read`),r.cache_write>0&&o.push(`${qo(r.cache_write)} cache write`),r.unmetered&&o.push(`${qo(r.unmetered)} ${r.unmetered===1?"request":"requests"} unmetered`),o.join(" · ")}const jg=t=>t>0&&t<1e-4?"<$0.0001":t<.01?`$${t.toFixed(4)}`:`$${t.toFixed(2)}`,Yl=t=>{if(t>0&&t<1e-4)return"<$0.0001";if(t>=1)return`$${t.toFixed(2)}`;const[r,o=""]=t.toFixed(4).split(".");return`$${r}.${o.replace(/0+$/,"").padEnd(2,"0")}`},Ag=t=>t&&t.usd===null&&typeof t.so_far_usd=="number"&&typeof t.unpriced=="number"?t:void 0,J_=(t,{ended:r=!1}={})=>`The charges priced${r?"":" so far"}. ${t.unpriced} ${t.unpriced===1?"charge has":"charges have"} no price, so this is not the whole cost.`,M1=new Set(["completed","failed","cancelled"]),eN=t=>typeof t=="string"&&M1.has(t),I1="$0 · free model",z1="Unknown · cost not read",Rg=t=>t.usd===0&&t.free===!0,Og=t=>t.upper_bound===!0?"at most ":"",D1=(t,{ended:r=!1}={})=>t.usd!==null?`${Og(t)}${jg(t.usd)}`:typeof t.so_far_usd=="number"?r?`${Yl(t.so_far_usd)} known, ${t.unpriced??0} not priced`:`so far ${Yl(t.so_far_usd)}, ${t.unpriced??0} not priced`:"not priced";function F1(t,{ended:r=!1}={}){const o=Lg(t),i=(o==null?void 0:o.on)==="claude_code";if(o&&(t==null?void 0:t.usd)===0)return`${qo(o.tokens)} tokens · ${i?"On your Claude plan":"Using ChatGPT plan"}`;const a=U1(t,r);return o?`${a} + ${i?"your Claude plan":"ChatGPT plan"}`:a}function U1(t,r){const o=Ag(t),i=P1;return o?r?`${Yl(o.so_far_usd)}${i(o)} known · ${o.unpriced} not priced`:`so far ${Yl(o.so_far_usd)}${i(o)} · ${o.unpriced} not priced`:!t||t.usd===null?(t==null?void 0:t.unknown)==="booking_unread"?z1:"Unknown":Rg(t)?I1:`${Og(t)}${jg(t.usd)}${i(t)}`}const Lg=t=>t!=null&&t.plan&&t.plan.requests>0?t.plan:void 0,tN=t=>t.on==="claude_code"?$1:Ng;function qo(t){if(t<1e4)return t.toLocaleString("en-US");const[r,o]=t<1e6?[t/1e3,"K"]:t<1e9?[t/1e6,"M"]:[t/1e9,"B"];return`${r<100?r.toFixed(1).replace(/\.0$/,""):Math.round(r)}${o}`}function nN(t,r,{ended:o=!1,text:i}={}){const a=i??F1(t,{ended:o});return typeof r!="number"?a:(i!==void 0?W1.test(i):!Ag(t)&&!Lg(t)&&!!t&&t.usd!==null&&!Rg(t))?`${a} of ${Wh(r)}`:`${a} · cap ${Wh(r)}`}const W1=/^<?\$[\d.,]+( est\.| reported)?$/;function Wh(t){for(let r=2;r<8;r++)if(Number(t.toFixed(r))===t)return`$${t.toFixed(r)}`;return`$${t.toFixed(8)}`}function B1(t,r){if(t.startsWith("/")||t.startsWith("#"))return null;const o=r.from?`${r.from.replace(/\/*$/,"").split("/").map(encodeURIComponent).join("/")}/`:"";try{const i=decodeURIComponent(new URL(t,`file:///${o}`).pathname.slice(1));return r.paths.includes(i)?i:null}catch{return null}}const H1={FORBID_TAGS:["svg","image","video","audio","picture","source","track","input"],FORBID_ATTR:["src","srcset","poster","background","style","xlink:href"]};function ai(t,r){const o=Fl.sanitize($e.parse(t,{async:!1}),{RETURN_DOM:!0,...(r==null?void 0:r.images)===!1?H1:{}});if((r==null?void 0:r.images)===!1)for(const i of[...o.querySelectorAll("img")])i.replaceWith(i.getAttribute("alt")??"");for(const i of[...o.querySelectorAll("pre")])i.classList.add("whitespace-pre-wrap","break-words","[overflow-wrap:anywhere]");A1(o);for(const i of[...o.querySelectorAll("a[href]")]){const a=i.getAttribute("href").trim();if(/^(https?|ftps?):/i.test(a)){i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer");continue}if(/^[a-z][a-z\d+.-]*:/i.test(a))continue;const u=r&&B1(a,r);if(u){const f=i.ownerDocument.createElement("button");f.type="button",f.title=`Open ${u}`,f.dataset.runFile=u,f.append(...i.childNodes),i.replaceWith(f)}else i.replaceWith(...i.childNodes)}return o.innerHTML}const Pg=t=>r=>{var i,a,u;const o=(u=(a=(i=r.target).closest)==null?void 0:a.call(i,"[data-run-file]"))==null?void 0:u.getAttribute("data-run-file");o&&(r.preventDefault(),t(o))},G1=t=>{const r=o=>{var i;return(i=new RegExp(`\\b${o}="([^"]*)"`).exec(t))==null?void 0:i[1]};return r("scheme")==="github"||r("source")==="github"?"A GitHub event":r("source")==="webhook"?"A webhook request":"A trigger's request"};function rN(t){const{title:r}=t;if(!t.trigger)return r;let o=r.search(/<trigger-payload\b/);if(o<0){const a=/<([a-z-]*)…$/.exec(r);if(!a||!"trigger-payload".startsWith(a[1]))return r;o=a.index}return r.slice(0,o).trim()||G1(r.slice(o))}function oN(t,r){if(r.unchanged&&!r.reset&&!r.drop.length&&!r.rows.length)return t;const o=new Map;if(!r.reset)for(const i of t)o.set(i.id,i);for(const i of r.drop)o.delete(i);for(const i of r.rows)o.set(i.id,i);return[...o.values()].sort((i,a)=>i.seq-a.seq)}const q1=t=>(t.kind==="tool_use"?t.tool_input_preview:t.kind==="tool_result"?t.tool_result_preview:t.text)??null,Mg=t=>t.refused===!0,V1=t=>t.tool_status==="failed"&&!Mg(t)||t.kind==="error",Q1=t=>t.paused===!0;function K1(t){const r=new Map(t.filter(h=>h.kind==="tool_result"&&h.tool_use_id).map(h=>[h.tool_use_id,h])),o=new Set(t.filter(h=>h.kind==="tool_use"&&h.tool_use_id).map(h=>h.tool_use_id)),i=new Set(t.filter(h=>h.kind==="waiting"&&h.id.endsWith(":waiting")).map(h=>h.id.slice(0,-8))),a=h=>{var g;return i.has(h.id)||(h.tool_use_id?i.has(((g=r.get(h.tool_use_id))==null?void 0:g.id)??""):!1)},u=t.findLast(h=>h.kind==="usage"),f=[],d=new Map;let m;for(const h of t){if(h.kind==="usage")continue;if(h.tool_name==="ask_person"&&(h.kind==="tool_use"||h.kind==="tool_result")&&a(h)){m=void 0;continue}if(h.kind==="tool_result"&&h.tool_use_id&&o.has(h.tool_use_id)){m=d.get(h.tool_use_id);continue}if(h.kind==="phase"&&h.path&&m&&(m.row.kind==="tool_result"||m.row.kind==="tool_use")&&!m.saved){m.saved=h.path;continue}const g=f.at(-1);if(h.kind==="error"&&(g==null?void 0:g.row.kind)==="error"&&g.row.summary===h.summary&&g.row.text===h.text&&(g.row.agent_label??null)===(h.agent_label??null)){g.times=(g.times??1)+1,g.until=h.timestamp,m=g;continue}let w;const x=h.kind==="tool_use"&&h.tool_use_id?r.get(h.tool_use_id):void 0;if(x){const k=x.tool_status!=="failed",b=[h.tool_input_preview,x.tool_result_preview].filter(Boolean),C=x.tool_status!==null;w={row:{...x,id:h.id,seq:h.seq,timestamp:h.timestamp,summary:k?(x.summary??"").replace(/:\s*ok$/i,""):x.summary,...h.usage?{usage:h.usage}:{}},...C?{ms:Math.max(0,Date.parse(x.timestamp)-Date.parse(h.timestamp))}:{},detail:b.length===2?`${b[0]}
275
+ `:i}}});const V_=t=>t.slice(-8),L1=t=>new Date(t).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),Q_=t=>new Date(t).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function K_(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024**3?`${(t/1024/1024).toFixed(1)} MB`:`${(t/1024**3).toFixed(1)} GB`}const Y_=t=>t.basis==="estimate",P1=t=>t.basis==="estimate"?" est.":t.basis==="reported"?" reported":"",X_=t=>t.basis==="estimate"?"A local estimate, not a bill":t.basis==="reported"?"As the provider or gateway reported it":t.basis==="unpriced"?"No model request was priced":void 0;function Z_(t){const r=t==null?void 0:t.tokens;if(!r)return;const o=[`${qo(r.input)} in`,`${qo(r.output)} out`];return r.cache_read>0&&o.push(`${qo(r.cache_read)} cache read`),r.cache_write>0&&o.push(`${qo(r.cache_write)} cache write`),r.unmetered&&o.push(`${qo(r.unmetered)} ${r.unmetered===1?"request":"requests"} unmetered`),o.join(" · ")}const jg=t=>t>0&&t<1e-4?"<$0.0001":t<.01?`$${t.toFixed(4)}`:`$${t.toFixed(2)}`,Yl=t=>{if(t>0&&t<1e-4)return"<$0.0001";if(t>=1)return`$${t.toFixed(2)}`;const[r,o=""]=t.toFixed(4).split(".");return`$${r}.${o.replace(/0+$/,"").padEnd(2,"0")}`},Ag=t=>t&&t.usd===null&&typeof t.so_far_usd=="number"&&typeof t.unpriced=="number"?t:void 0,J_=(t,{ended:r=!1}={})=>`The charges priced${r?"":" so far"}. ${t.unpriced} ${t.unpriced===1?"charge has":"charges have"} no price, so this is not the whole cost.`,M1=new Set(["completed","failed","cancelled"]),eN=t=>typeof t=="string"&&M1.has(t),I1="$0 · free model",z1="Unknown · cost not read",Rg=t=>t.usd===0&&t.free===!0,Og=t=>t.upper_bound===!0?"at most ":"",D1=(t,{ended:r=!1}={})=>t.usd!==null?`${Og(t)}${jg(t.usd)}`:typeof t.so_far_usd=="number"?r?`${Yl(t.so_far_usd)} known, ${t.unpriced??0} not priced`:`so far ${Yl(t.so_far_usd)}, ${t.unpriced??0} not priced`:"not priced";function F1(t,{ended:r=!1}={}){const o=Lg(t),i=(o==null?void 0:o.on)==="claude_code";if(o&&(t==null?void 0:t.usd)===0)return`${qo(o.tokens)} tokens · ${i?"On your Claude plan":"Using ChatGPT plan"}`;const a=U1(t,r);return o?`${a} + ${i?"your Claude plan":"ChatGPT plan"}`:a}function U1(t,r){const o=Ag(t),i=P1;return o?r?`${Yl(o.so_far_usd)}${i(o)} known · ${o.unpriced} not priced`:`so far ${Yl(o.so_far_usd)}${i(o)} · ${o.unpriced} not priced`:!t||t.usd===null?(t==null?void 0:t.unknown)==="booking_unread"?z1:"Unknown":Rg(t)?I1:`${Og(t)}${jg(t.usd)}${i(t)}`}const Lg=t=>t!=null&&t.plan&&t.plan.requests>0?t.plan:void 0,tN=t=>t.on==="claude_code"?$1:Ng;function qo(t){if(t<1e4)return t.toLocaleString("en-US");const[r,o]=t<1e6?[t/1e3,"K"]:t<1e9?[t/1e6,"M"]:[t/1e9,"B"];return`${r<100?r.toFixed(1).replace(/\.0$/,""):Math.round(r)}${o}`}function nN(t,r,{ended:o=!1,text:i}={}){const a=i??F1(t,{ended:o});return typeof r!="number"?a:(i!==void 0?W1.test(i):!Ag(t)&&!Lg(t)&&!!t&&t.usd!==null&&!Rg(t))?`${a} of ${Wh(r)}`:`${a} · cap ${Wh(r)}`}const W1=/^<?\$[\d.,]+( est\.| reported)?$/;function Wh(t){for(let r=2;r<8;r++)if(Number(t.toFixed(r))===t)return`$${t.toFixed(r)}`;return`$${t.toFixed(8)}`}function B1(t,r){if(t.startsWith("/")||t.startsWith("#"))return null;const o=r.from?`${r.from.replace(/\/*$/,"").split("/").map(encodeURIComponent).join("/")}/`:"";try{const i=decodeURIComponent(new URL(t,`file:///${o}`).pathname.slice(1));return r.paths.includes(i)?i:null}catch{return null}}const H1={FORBID_TAGS:["svg","image","video","audio","picture","source","track","input"],FORBID_ATTR:["src","srcset","poster","background","style","xlink:href"]};function ai(t,r){const o=Fl.sanitize($e.parse(t,{async:!1}),{RETURN_DOM:!0,...(r==null?void 0:r.images)===!1?H1:{}});if((r==null?void 0:r.images)===!1)for(const i of[...o.querySelectorAll("img")])i.replaceWith(i.getAttribute("alt")??"");for(const i of[...o.querySelectorAll("pre")])i.classList.add("whitespace-pre-wrap","break-words","[overflow-wrap:anywhere]");A1(o);for(const i of[...o.querySelectorAll("a[href]")]){const a=i.getAttribute("href").trim();if(/^(https?|ftps?):/i.test(a)){i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer");continue}if(/^[a-z][a-z\d+.-]*:/i.test(a))continue;const u=r&&B1(a,r);if(u){const f=i.ownerDocument.createElement("button");f.type="button",f.title=`Open ${u}`,f.dataset.runFile=u,f.append(...i.childNodes),i.replaceWith(f)}else i.replaceWith(...i.childNodes)}return o.innerHTML}const Pg=t=>r=>{var i,a,u;const o=(u=(a=(i=r.target).closest)==null?void 0:a.call(i,"[data-run-file]"))==null?void 0:u.getAttribute("data-run-file");o&&(r.preventDefault(),t(o))},G1=t=>{const r=o=>{var i;return(i=new RegExp(`\\b${o}="([^"]*)"`).exec(t))==null?void 0:i[1]};return r("scheme")==="github"||r("source")==="github"?"A GitHub event":r("source")==="webhook"?"A webhook request":"A trigger's request"};function rN(t){const{title:r}=t;if(!t.trigger)return r;let o=r.search(/<trigger-payload\b/);if(o<0){const a=/<([a-z-]*)…$/.exec(r);if(!a||!"trigger-payload".startsWith(a[1]))return r;o=a.index}return r.slice(0,o).trim()||G1(r.slice(o))}function oN(t,r){if(r.unchanged&&!r.reset&&!r.drop.length&&!r.rows.length)return t;const o=new Map;if(!r.reset)for(const i of t)o.set(i.id,i);for(const i of r.drop)o.delete(i);for(const i of r.rows)o.set(i.id,i);return[...o.values()].sort((i,a)=>i.seq-a.seq)}const q1=t=>(t.kind==="tool_use"?t.tool_input_preview:t.kind==="tool_result"?t.tool_result_preview:t.text)??null,Mg=t=>t.refused===!0,V1=t=>t.tool_status==="failed"&&!Mg(t)||t.kind==="error",Q1=t=>t.paused===!0;function K1(t){const r=new Map(t.filter(h=>h.kind==="tool_result"&&h.tool_use_id).map(h=>[h.tool_use_id,h])),o=new Set(t.filter(h=>h.kind==="tool_use"&&h.tool_use_id).map(h=>h.tool_use_id)),i=new Set(t.filter(h=>h.kind==="waiting"&&h.id.endsWith(":waiting")).map(h=>h.id.slice(0,-8))),a=h=>{var g;return i.has(h.id)||(h.tool_use_id?i.has(((g=r.get(h.tool_use_id))==null?void 0:g.id)??""):!1)},u=t.findLast(h=>h.kind==="usage"),f=[],d=new Map;let m;for(const h of t){if(h.kind==="usage")continue;if(h.tool_name==="ask_person"&&(h.kind==="tool_use"||h.kind==="tool_result")&&a(h)){m=void 0;continue}if(h.kind==="tool_result"&&h.tool_use_id&&o.has(h.tool_use_id)){m=d.get(h.tool_use_id);continue}if(h.kind==="phase"&&h.path&&m&&(m.row.kind==="tool_result"||m.row.kind==="tool_use")&&!m.saved){m.saved=h.path;continue}const g=f.at(-1);if(h.kind==="error"&&(g==null?void 0:g.row.kind)==="error"&&g.row.summary===h.summary&&g.row.text===h.text&&(g.row.agent_label??null)===(h.agent_label??null)){g.times=(g.times??1)+1,g.until=h.timestamp,m=g;continue}let w;const x=h.kind==="tool_use"&&h.tool_use_id?r.get(h.tool_use_id):void 0;if(x){const k=x.tool_status!=="failed",b=[h.tool_input_preview,x.tool_result_preview].filter(Boolean),C=x.tool_status!==null;w={row:{...x,id:h.id,seq:h.seq,timestamp:h.timestamp,summary:k?(x.summary??"").replace(/:\s*ok$/i,""):x.summary,...h.usage?{usage:h.usage}:{}},...C?{ms:Math.max(0,Date.parse(x.timestamp)-Date.parse(h.timestamp))}:{},detail:b.length===2?`${b[0]}
276
276
 
277
277
  → ${b[1]}`:b[0]??null}}else w={row:h};f.push(w),h.kind==="tool_use"&&h.tool_use_id&&d.set(h.tool_use_id,w),m=w}return u&&f.push({row:u}),f}class Y1 extends Error{constructor(o,i,a,u=!1,f){super(a);Te(this,"fields");Te(this,"retryAfterMs");Te(this,"details");Te(this,"problems");this.status=o,this.code=i,this.retryable=u,this.requestId=f,this.name="ClientError"}toApiError(){return{code:this.code,message:this.message,retryable:this.retryable,request_id:this.requestId,...this.details?{details:this.details}:{}}}}const He=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),X1=t=>t.replace(/~/g,"~0").replace(/\//g,"~1"),Lc=128,Z1=t=>{try{return JSON.stringify(t)??"null"}catch{return JSON.stringify(`[${typeof t}:${String(t)}]`)}},Pc=(t,r=0)=>r>Lc?'"…"':Array.isArray(t)?`[${t.map(o=>Pc(o,r+1)).join(",")}]`:He(t)?`{${Object.keys(t).filter(o=>t[o]!==void 0).sort().map(o=>`${JSON.stringify(o)}:${Pc(t[o],r+1)}`).join(",")}}`:Z1(t),J1=t=>{let r=2166136261;for(let o=0;o<t.length;o+=1)r=Math.imul(r^t.charCodeAt(o),16777619);return(r>>>0).toString(16).padStart(8,"0")},Xs=(t,r)=>Object.fromEntries(Object.entries(t).filter(([o])=>o!==r)),eb=t=>{switch(t.node){case"chain":return Xs(t,"steps");case"parallel":return Xs(t,"branches");case"map":case"loop":return Xs(t,"body");case"route":return He(t.branches)?{...t,branches:Object.fromEntries(Object.entries(t.branches).map(([r,o])=>[r,He(o)?Xs(o,"body"):o]))}:t;case"workflow":return He(t.workflow)?{...t,workflow:Xs(t.workflow,"root")}:t;default:return t}};function tb(t){const r=[],o=[],i=(a,u,f,d)=>{if(!He(a)||typeof a.node!="string"||f>Lc)return;r.push({path:u,kind:a.node,label:typeof a.label=="string"?a.label:a.node,...a.node==="call"&&typeof a.via=="string"?{via:a.via}:{},changeCheck:J1(Pc(eb(a))),...rb(a,d)});const m=(h,g,w,x=u,k=d)=>{!He(h)||typeof h.node!="string"||f+1>Lc||(o.push({from:x,to:g,kind:w}),i(h,g,f+1,k))};switch(a.node){case"chain":Array.isArray(a.steps)&&a.steps.forEach((h,g)=>m(h,`${u}/steps/${g}`,"next",g===0?u:`${u}/steps/${g-1}`));break;case"parallel":Array.isArray(a.branches)&&a.branches.forEach((h,g)=>m(h,`${u}/branches/${g}`,"branch"));break;case"map":m(a.body,`${u}/body`,"item");break;case"loop":m(a.body,`${u}/body`,"next");break;case"route":if(He(a.branches))for(const[h,g]of Object.entries(a.branches))He(g)&&m(g.body,`${u}/branches/${X1(h)}/body`,"route");break;case"workflow":He(a.workflow)&&m(a.workflow.root,`${u}/workflow/root`,"child",u,He(a.workflow.schemas)?a.workflow.schemas:{});break}};return i(He(t)?t.root:void 0,"/root",0,He(t)&&He(t.schemas)?t.schemas:{}),{nodes:r,edges:o}}const nb=(t,r)=>{const o=typeof t=="string"&&Object.hasOwn(r,t)?r[t]:void 0,i=u=>{var f;for(let d=0;He(u)&&typeof u.$ref=="string"&&d<8;d+=1){const m=(f=/^#\/definitions\/(.+)$/.exec(u.$ref))==null?void 0:f[1],h=He(o)&&He(o.definitions)?o.definitions:{};u=m===void 0?void 0:Object.hasOwn(h,m)?h[m]:Object.hasOwn(r,m)?r[m]:void 0}return u},a=i(o);return!He(a)||!He(a.properties)?[]:Object.entries(a.properties).map(([u,f])=>{const d=i(f),m=He(d)&&typeof d.description=="string"?d.description:"",h=He(d)?(Array.isArray(d.type)?d.type:[d.type]).filter(g=>g!=="null"):[];return He(d)&&Array.isArray(d.enum)?{id:u,type:"choice",instructions:m,options:d.enum.map(String)}:h.length===1&&h[0]==="boolean"?{id:u,type:"noul",instructions:m}:h.length===1&&h[0]==="integer"?{id:u,type:"score",instructions:m}:{id:u,type:"unknown",instructions:m}})},rb=(t,r)=>{let o=t,i;const a=u=>typeof u=="string"?u:"";switch(t.node){case"judge":case"sift":i=nb(t.out,r);break;case"pick":i=[{id:"pick",type:"choice",instructions:a(t.instructions)}];break;case"route":if(t.valuePath!==void 0)return{};i=[{id:"branch",type:"choice",instructions:a(t.instructions),options:He(t.branches)?Object.keys(t.branches):[]}];break;case"loop":case"escalate":{const u=t.node==="loop"?t.until:t.when;if(!He(u)||u.predicate!=="ask")return{};o=u,i=[{id:"holds",type:"noul",instructions:a(u.instructions)}];break}default:return{}}return{...typeof o.provider=="string"?{provider:o.provider}:{},...typeof o.model=="string"?{model:o.model}:{},questions:i,...He(o.images)&&Object.keys(o.images).length?{images:Object.keys(o.images)}:{}}};function sN(t,r){const o=R=>JSON.stringify([R.kind,R.label]),i=R=>{const M=new Map;for(const G of R.nodes)M.set(o(G),(M.get(o(G))??0)+1);return M},[a,u]=[i(t),i(r)],f=R=>a.get(o(R))===1&&u.get(o(R))===1,d=new Map,m=new Map,h=(R,M)=>{d.set(M,R),m.set(R,M)},g=new Map(t.nodes.filter(f).map(R=>[o(R),R.path]));for(const R of r.nodes){const M=f(R)?g.get(o(R)):void 0;M!==void 0&&h(M,R.path)}const w=new Map(t.nodes.map(R=>[R.path,R])),x=[];for(const R of r.nodes){const M=w.get(R.path);d.has(R.path)||M===void 0||m.has(M.path)||(h(M.path,R.path),(M.kind!==R.kind||M.label!==R.label)&&x.push({prev:M.path,next:R.path,was:{kind:M.kind,label:M.label},now:{kind:R.kind,label:R.label}}))}const k=[];for(const R of r.nodes){const M=d.get(R.path),G=M===void 0?void 0:w.get(M);G===void 0||G.kind!==R.kind||G.label!==R.label||G.changeCheck!==void 0&&R.changeCheck!==void 0&&G.changeCheck!==R.changeCheck&&k.push({prev:G.path,next:R.path,kind:R.kind,label:R.label})}const b=({path:R,kind:M,label:G})=>({path:R,kind:M,label:G}),C=(R,M,G)=>JSON.stringify([R,M,G]),j=new Set(t.edges.map(R=>C(R.from,R.to,R.kind))),P=new Set(r.edges.map(R=>C(R.from,R.to,R.kind))),F=(R,M,G)=>{const[Y,V]=[M.get(R.from),M.get(R.to)];return Y!==void 0&&V!==void 0&&G.has(C(Y,V,R.kind))};return{added:r.nodes.filter(R=>!d.has(R.path)).map(b),removed:t.nodes.filter(R=>!m.has(R.path)).map(b),changed:x,moved:r.nodes.flatMap(R=>{const M=d.get(R.path);return M!==void 0&&M!==R.path?[{prev:M,next:R.path}]:[]}),rewritten:k,edges:{added:r.edges.filter(R=>!F(R,d,j)).map(({from:R,to:M,kind:G})=>({from:R,to:M,kind:G})),removed:t.edges.filter(R=>!F(R,m,P)).map(({from:R,to:M,kind:G})=>({from:R,to:M,kind:G}))}}}const Ze=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Ul=t=>t.replace(/~/g,"~0").replace(/\//g,"~1");function iN(t){const r=new Map;let o=0;const i=d=>{throw Object.assign(new Error(d),{offset:o})},a=()=>{for(;o<t.length&&`
278
278
  \r`.includes(t[o]);)o++},u=()=>{const d=o;for(o++;o<t.length&&t[o]!=='"';)t[o]==="\\"?o++:t.charCodeAt(o)<32&&i("a string cannot hold a raw line break or control character"),o++;o>=t.length&&(o=d,i("this string is not closed")),o++;try{return JSON.parse(t.slice(d,o))}catch{return o=d,i("this string has a bad escape")}},f=d=>{a();const m=o;let h;const g=t[o];if(g==="{"){o++;const w={};if(a(),t[o]==="}")o++;else for(;;){a(),t[o]!=='"'&&i(t[o]==="}"?"a trailing comma before }":"expected a key in double quotes");const x=u();if(a(),t[o]!==":"&&i("expected : after the key"),o++,w[x]=f(`${d}/${Ul(x)}`),a(),t[o]===","){o++;continue}if(t[o]==="}"){o++;break}i("expected , or } after the value")}h=w}else if(g==="["){o++;const w=[];if(a(),t[o]==="]")o++;else for(;;){if(w.push(f(`${d}/${w.length}`)),a(),t[o]===","){o++,a(),t[o]==="]"&&i("a trailing comma before ]");continue}if(t[o]==="]"){o++;break}i("expected , or ] after the value")}h=w}else if(g==='"')h=u();else{const w=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(t.slice(o,o+400));w||i(o>=t.length?"the text ends before the value":"expected a value"),o+=w[0].length,h=JSON.parse(w[0])}return r.set(d,{start:m,end:o}),h};try{const d=f("");return a(),o<t.length&&i("text after the end of the JSON"),{ok:!0,value:d,spans:r}}catch(d){return{ok:!1,error:{message:d.message,offset:d.offset??0}}}}function lN(t,r){let o=1,i=-1;for(let a=0;a<Math.min(r,t.length);a++)t[a]===`
@@ -288,4 +288,4 @@ ${a.questions.map(C=>`• ${C.text}`).join(`
288
288
  `)&&M[1].length>80):[],R=F.length?Object.fromEntries(Object.entries(P).filter(([M])=>!F.some(([G])=>G===M))):P;return y.jsxs("div",{className:"space-y-8",children:[F.map(([M,G])=>y.jsxs("section",{children:[y.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:M.replace(/_/g," ")}),y.jsx("article",{className:"report max-w-none border bg-card p-5",onClick:m,dangerouslySetInnerHTML:{__html:ai(G,d)}})]},M)),(!F.length||Object.keys(R).length>0)&&y.jsxs("section",{children:[y.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:F.length?"The rest of the output":"Output"}),y.jsx("pre",{className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] border bg-card p-4 font-mono text-small leading-[1.8]",children:y.jsx(ao,{text:JSON.stringify(R,null,2)})})]})]})}return null}const Go=(t,r={})=>({type:"object",properties:{op:{const:t,description:`Action operation. Use "op": "${t}"; never use a "kind" field.`},id:{type:"string",description:'Bracketed ID copied from the latest snapshot, as a string. Use "id"; never use "ref".'},...r},required:["op","id",...Object.keys(r).filter(o=>o!=="delay")],additionalProperties:!1}),Cn=(t,r=[])=>({type:"object",additionalProperties:!1,properties:t,...r.length?{required:r}:{}}),dS={name:"snapshot",label:"Browser: snapshot",description:"Capture the active page's accessibility tree and hydrate its displayed IDs for subsequent run actions. Every call replaces the active page's ID map. On an agent's browser computer a frame another site runs in its own process is not in the tree: the snapshot names each frame it left out.",parameters:Cn({includeIframes:{type:"boolean",default:!0}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},fS=Object.freeze({cookies:"It keeps cookies across pages: use it for a page that depends on an earlier one, or one that sets cookies.",signIns:"This browser opens with this agent's saved browser profile: a site the agent was signed in to there opens signed in here, and only here (web_fetch reads every page signed out). Use it for anything behind a sign-in, or a page that depends on an earlier one."}),pS=t=>`Browse and automate websites in the persistent browser. ${fS.cookies} Navigate with JavaScript such as await page.goto("https://example.com"), or with a goto action; there is no separate navigate or start tool. Execute either a JavaScript workflow against the Stagehand Playwright facade or a batch of actions using IDs from the latest snapshot. Code is the body of an async function with page, context and browser in scope: \`return\` the value you want back. Provide exactly one of code or actions. An agent's browser computer (Browserbase, Kernel or Local Chrome) takes actions only: code is refused there. Each action must use "op" (never "kind") and "id" (never "ref"), but goto, which takes a "url". Copy the bracketed snapshot ID as a string. Examples: {"actions":[{"op":"goto","url":"https://example.com"}]}, {"actions":[{"op":"click","id":"1-42"}]}, {"actions":[{"op":"fill","id":"2-14","value":"Miami"}]}, {"actions":[{"op":"select","id":"3-9","values":"Lowest price"}]}.`,hS={name:"run",label:"Browser: run",description:pS(),parameters:Cn({code:{type:"string",minLength:1},actions:{type:"array",description:'Snapshot actions with the exact fields "op" and "id" (goto: "op" and "url"). Do not use "kind" or "ref".',items:{oneOf:[{type:"object",properties:{op:{const:"goto",description:'Action operation. Use "op": "goto"; never use a "kind" field.'},url:{type:"string",description:"The http or https URL to open in the active page (or about:blank)."}},required:["op","url"],additionalProperties:!1},Go("click"),Go("hover"),Go("fill",{value:{type:"string"}}),Go("type",{text:{type:"string"},delay:{type:"number",minimum:0}}),Go("press",{key:{type:"string"}}),Go("select",{values:{oneOf:[{type:"string"},{type:"array",items:{type:"string"},minItems:1}]}})]},minItems:1}}),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"always"},mS={name:"screenshot",label:"Browser: screenshot",description:'Capture a screenshot of the active page. For size-constrained MCP clients, prefer a viewport JPEG: {"type":"jpeg","quality":40,"fullPage":false}.',parameters:Cn({fullPage:{type:"boolean"},type:{type:"string",enum:["png","jpeg"]},quality:{type:"number",minimum:0,maximum:100},ask:{type:"string",description:"What you want to know from this capture. It travels with the image, so a host can answer it from the pixels when your model cannot see them."},clip:{...Cn({x:{type:"number"},y:{type:"number"},width:{type:"number"},height:{type:"number"}},["x","y","width","height"]),description:"Capture only this region, in CSS pixels from the viewport's top-left corner (what the page shows now). Width and height 0 mean no clip: leave it out, or send zeros, to capture the whole viewport. A region that leaves the viewport is refused. Use one of clip, id or selector; an empty id or selector means none."},id:{type:"string",description:"Capture only this element: a bracketed ID from the latest snapshot, as a string. It is scrolled into view first. It must match one element."},selector:{type:"string",description:"Capture only the element this CSS selector matches (when there is no snapshot ID for it). It is scrolled into view first. It must match exactly one element."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"image",listedWhen:"always"},gS={name:"browser_read",label:"Browser: read",description:"Read the CURRENT page of the browser as evidence and persist it under evidence/ with the page URL: `what` = markdown (the whole page as markdown, the default for citing), text, html, url, or title. This is the citable door for anything you saw in the browser: snapshot, screenshot and run return values are not evidence. Cite the returned URL. A browser page URL in a receipt keeps its query names but shows every value replaced by a redaction marker, the word redacted in square brackets (the site chose where the browser went, and a value in it can be a credential); web_fetch keeps a query value that is in the URL you asked for.",parameters:Cn({what:{type:"string",enum:["markdown","text","html","url","title"],description:"Default markdown."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"receipt",listedWhen:"always"},yS={name:"browser_release",label:"Browser: release",description:"Release the browser session now. You do not need it to finish: the session is released when your work ends and after a stretch with no browser call. Call it only to drop a session mid-task (to start the next browser call on a fresh session, or before a long stretch of work that needs no browser). Your next browser call launches a fresh session (a new tab, no cookies from the old one), so finish a flow before releasing.",parameters:Cn({}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},vS={name:"browser_relaunch",label:"Browser: relaunch",description:"Replace the browser session with a fresh one, after a site blocked it (403/429, a CAPTCHA wall, a bot-detection page, an empty page that should have content). The new session is Verified whenever the run's sessions are, and a relaunch never lowers that: `verified: true` asks for a Verified session where the run's sessions are not (a Verified browser carries a stronger identity and costs more). Use `geolocation` to browse as a visitor from a given place: the proxy egresses from that country (ISO alpha-2), optionally a US state and a city, so geo-aware sites (storefront region, prices, payment methods, content availability) show what a local sees. Page state is lost; navigate again with run.",parameters:Cn({verified:{type:"boolean",description:"true launches the new session as a Verified browser. false, or leaving it out, keeps the run's setting: a Verified run's sessions stay Verified."},geolocation:{type:"object",additionalProperties:!1,description:"Proxy egress location for the new session. Omit to keep the run's default.",properties:{country:{type:"string",description:"ISO 3166-1 alpha-2 country code, e.g. GB, US, DE."},state:{type:"string",description:"US state abbreviation, United States only."},city:{type:"string",description:"City name, e.g. LONDON or SAO_PAULO."}},required:["country"]}}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},wS={name:"browser_request_handoff",label:"Browser: hand to a person",description:"Hand the browser to a person for a step only a human can do: a CAPTCHA you cannot pass, a sign-in that needs their device, a confirmation only they can give. Say in instruction what they should do and in completion_condition what the page shows once it is done. The call waits until the person finishes, cancels or the request expires; while they have the browser, every other browser call fails with waiting_for_human. The same request_id retries the same request. Afterwards take a snapshot and check the completion condition on the page before acting.",parameters:Cn({request_id:{type:"string",pattern:"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",description:"A UUID you choose for this request; the same one retries the same request."},instruction:{type:"string",minLength:1,maxLength:2e3,description:"What the person should do, in plain words."},completion_condition:{type:"string",minLength:1,maxLength:1e3,description:"What the page shows once the step is done, for you to verify afterwards."}},["request_id","instruction","completion_condition"]),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"handoff"},xS={name:"browser_downloads",label:"Browser: downloads",description:"Copy the files this browser session downloaded into the workspace under downloads/, with downloads/manifest.json listing each file's SHA-256. Returns the files fetched now, those fetched before and those skipped with why, never their bytes; open a fetched file with read. A file the browser is still downloading is skipped as still downloading: call again to fetch it.",parameters:Cn({}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"files",listedWhen:"downloads"},kS={name:"browser_upload",label:"Browser: upload",description:"Choose one workspace file in a file input on the page, as a person picking it would; nothing is submitted. Returns the file's name, size and SHA-256; submit the form with run afterwards.",parameters:Cn({path:{type:"string",minLength:1,maxLength:1e3,description:"The file's path relative to the workspace, for example reports/q3.pdf."},selector:{type:"string",minLength:1,maxLength:500,description:'CSS selector of the <input type="file">, for example input[type=file].'}},["path","selector"]),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"upload"},bS=Object.freeze([dS,hS,mS,gS,yS,vS,wS,xS,kS]),SS=Object.freeze(bS.map(t=>t.name)),ES={"com.apple.systempreferences":"System Settings","com.apple.iCal":"Calendar","com.apple.finder":"Finder","com.android.settings":"Settings","com.android.chrome":"Chrome","com.android.deskclock":"Clock","com.android.contacts":"Contacts","com.android.documentsui":"Files","org.wikipedia":"Wikipedia","xfce4-terminal":"Terminal","org.xfce.terminal":"Terminal",xterm:"XTerm","firefox-esr":"Firefox","google-chrome":"Chrome"};function _S(t){const r=t.split(".").at(-1)||t;return ES[t]??(r?r[0].toUpperCase()+r.slice(1):t)}const NS=new Set(["enter","tab","space","backspace","delete","escape","insert","up","down","left","right","home","end","pageup","pagedown","f1","f2","f3","f4","f5","f6","f7","f8","f9","f10","f11","f12","shift","ctrl","alt","super","capslock"]),CS=new Set(["ctrl","alt","super"]);function TS(t){if(typeof t!="string"||!t)return;const o=(t.endsWith("++")?[...t.slice(0,-2).split("+"),"+"]:t.split("+")).map(i=>i.toLowerCase());return o.some(i=>CS.has(i))||o.every(i=>NS.has(i))?t:void 0}const $S=["press","set","perform","click","type","key","nav","scroll","drag"];function jS(t,r){const o=t&&typeof t=="object"&&!Array.isArray(t)?t:{},i=$S.find(m=>m in o)??"step",a=i==="type"?o.into:o[i],u=typeof a=="string"?r(a):void 0,f=i==="key"?TS(o.key):void 0,d=i==="nav"&&typeof o.nav=="string"?o.nav:void 0;return{do:i,...u?{on:u}:{},...f?{keys:f}:{},...d?{nav:d}:{}}}const AS={textbox:"text box",searchbox:"search box",checkbox:"check box",combobox:"pop-up",switch:"switch",slider:"slider",list:"list",table:"table",scrollarea:"scroll area",window:"window",dialog:"dialog",menu:"menu",toolbar:"toolbar",image:"image",text:"text",heading:"heading",group:"group",progressbar:"progress bar"},RS=new Set(["button","link","menuitem","tab","listitem","row","cell","radio","generic","text","heading"]);function OS(t){if(!t)return;const r=AS[t.role]??(t.role==="generic"?"element":t.role);return t.name?RS.has(t.role)?`“${t.name}”`:`the ${r} “${t.name}”`:`the ${r}`}const LS={s:["Saved","save"],a:["Selected all","select all"],c:["Copied","copy"],v:["Pasted","paste"],x:["Cut","cut"],z:["Undid","undo"],w:["Closed the window","close the window"],q:["Quit","quit"],t:["Opened a new tab","open a new tab"]},PS={super:"⌘",shift:"⇧",alt:"⌥",ctrl:"⌃"},kc={enter:"Return",escape:"Esc",tab:"Tab",space:"Space",backspace:"Delete",delete:"Forward Delete",up:"↑",down:"↓",left:"←",right:"→"},nt=(t,r,o="")=>({did:`${t}${o}`,tried:`${r}${o}`});function MS(t){const r=t.endsWith("++")?[...t.slice(0,-2).split("+"),"+"]:t.split("+"),o=r.at(-1)??"",i=r.slice(0,-1).map(f=>f.toLowerCase()),a=r.length===1&&kc[o.toLowerCase()]?kc[o.toLowerCase()]:`${i.map(f=>PS[f]??`${f}+`).join("")}${kc[o.toLowerCase()]??(o.length===1?o.toUpperCase():o)}`,u=i.length===1&&i[0]==="super"?LS[o.toLowerCase()]:void 0;return u?nt(u[0],u[1],` (${a})`):nt("Pressed","press",` ${a}`)}const IS={back:["Went","go"," back"],home:["Went","go"," home"],app_switch:["Opened","open"," the recent apps"]};function zS(t){const r=OS(t.on),o=i=>` ${r??i}`;switch(t.do){case"press":return nt("Pressed","press",o("an element"));case"click":return nt("Clicked","click",r?` ${r}`:" at a point");case"set":return nt("Set","set",o("an element"));case"perform":return nt("Acted on","act on",o("an element"));case"type":return r?nt("Typed into","type into",` ${r}`):nt("Typed text","type text");case"key":return t.keys?MS(t.keys):nt("Pressed a key","press a key");case"nav":{const[i,a,u]=t.nav&&IS[t.nav]||["Navigated","navigate",""];return nt(i,a,u)}case"scroll":return r?nt("Scrolled","scroll",` ${r}`):nt("Scrolled","scroll");case"drag":return nt("Dragged","drag"," across the screen");default:return nt("Acted","act")}}function nm(t){const r=zS(t);return t.error===void 0?r.did:`Could not ${r.tried}`}const rm=3,zc=t=>t[0].toLowerCase()+t.slice(1);function DS(t){const r=t.slice(0,rm).map(nm),o=t.slice(rm),i=o.findIndex(u=>u.error!==void 0),a=i<0?o.length:o.length-1;return[r[0],...r.slice(1).map(zc),...a>0?[`+${a} more`]:[],...i<0?[]:[zc(nm(o[i]))]].join(", ")}const FS={"screen.shot":["Took a screenshot","take a screenshot"],"screen.watch":["Watched the screen","watch the screen"],"input.actions":["Used the pointer and keys","use the pointer and keys"],"apps.list":["Listed the apps","list the apps"],"files.read":["Read a file","read a file"],"files.write":["Wrote a file","write a file"],"files.list":["Listed a folder","list a folder"],"files.stat":["Looked up a file","look up a file"],"exec.run":["Ran a command","run a command"],"process.start":["Started a process","start a process"],ping:["Checked the computer","check the computer"]};function _n(t){const r=t.app?_S(t.app):void 0,o=(()=>{var i;switch(t.method){case"apps.launch":return nt("Opened","open",` ${r??"an app"}`);case"apps.terminate":return nt("Quit","quit",` ${r??"an app"}`);case"ui.observe":return nt("Looked at","look at",` ${r??"the window"}`);case"ui.act":return t.ok&&((i=t.steps)!=null&&i.length)?{did:DS(t.steps),tried:""}:t.ok?nt("Waited for","wait for",` ${r??"the window"}${t.expect==="unmet"?" (not seen)":""}`):nt("Acted on","act on",` ${r??"the computer"}`);default:{const[a,u]=FS[t.method]??[t.method,t.method];return nt(a,u)}}})();return t.ok?o.did:`Could not ${o.tried}`}const US=t=>t.map((r,o)=>o===0?_n(r):zc(_n(r))).join(", "),Xg='\\s"`<>\\\\',WS=new RegExp(`https?://[^${Xg}|]+`,"gi"),BS=new RegExp(`https?://[^${Xg}]+`,"gi"),HS=".,;:!?*)]}'",GS={")":"(","]":"[","}":"{"};function qS(t){const r={"(":0,")":0,"[":0,"]":0,"{":0,"}":0};for(const i of t)i in r&&(r[i]+=1);let o=t.length;for(;o>0&&HS.includes(t[o-1]);o--){const i=t[o-1],a=GS[i];if(a&&r[a]>=r[i])break;a&&(r[i]-=1)}return t.slice(0,o)}new RegExp(`\\]\\(|${WS.source}`,"gi");const Tn=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0,Ae=t=>typeof t=="string"?t:void 0,uo=(t,r)=>t.length>r?`${t.slice(0,r-3)}...`:t,Zg=t=>t.split(`
289
289
  `).map(r=>r.trim()).find(Boolean)??"";function Jo(t){try{return Tn(JSON.parse(t))}catch{return}}const VS=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;function Xo(t){const r=VS.exec(t.trim());return uo(r?`${r[1]}${r[2]==="/"?"":r[2]}`:t.split(/[?#]/)[0]??"",80)}const QS="…",KS=/https?:\/\//gi,YS=/^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i,XS=/(https?:\/\/)[^@/?#\s]*@/gi,ZS=/[A-Za-z0-9]/;function md(t){return t.replace(BS,r=>{const o=[0];let[i,a]=[0,!1];for(const u of r.matchAll(KS)){if(u.index===0)continue;for(;i<u.index;i++)a||(a=r[i]==="?"||r[i]==="#");if(a)continue;let f=!1;for(let d=u.index-1;d>o.at(-1)&&!ZS.test(r[d]);d--)f||(f=r[d]==="'");f&&o.push(u.index)}return o.map((u,f)=>JS(r.slice(u,o[f+1]??r.length))).join("")})}function JS(t){const r=qS(t).length,o=YS.exec(t.slice(0,r));if(!o)return t;const i=u=>u.replace(XS,"$1"),a=[...new Set((o[4]??"").split("&").map(u=>i(u.split("=")[0])).filter(Boolean))];return`${o[1]}${i(`${o[2]}${o[3]}`)}${a.length?`?${a.map(u=>`${u}=${QS}`).join("&")}`:""}${t.slice(r)}`}const eE=t=>t.length>2?`${t.slice(0,2).join(", ")}, +${t.length-2} more`:t.join(", "),tE=new Map,nE=new Map,Jg=new Map,rE=new Map;function Qe(t,r,o,{name:i,saysFailure:a}={}){tE.set(t,r),o&&nE.set(t,o),i&&Jg.set(t,i),a&&rE.set(t,a===!0?()=>!0:a)}const oE=/^mcp__([a-z][a-z0-9-]{0,31})__([A-Za-z0-9_-]{1,64})$/,sE=/^mcp:([a-z][a-z0-9-]{0,31})\/([A-Za-z0-9_-]{1,64})$/,iE=t=>{const r=sE.exec(t)??oE.exec(t);return r&&r[1]!=="hands"?`${r[1]} · ${r[2]}`:void 0},lE=t=>Jg.get(t)??iE(t)??t,aE=new Map;function ya(t,r){aE.set(t,r)}const uE=new Set(["snapshot","run","screenshot","browser_read","browser_downloads"]);[...uE];const gd=t=>Ae(t.path)??Ae(t.file_path),cE=/page\.goto\(\s*["'`]([^"'`]+)/;Qe("read",t=>`Read ${gd(t)??"a file"}`,{many:t=>`Read ${t} files`,subject:t=>t??void 0,path:!0},{name:"Read files"});Qe("write",t=>`Wrote ${gd(t)??"a file"}`,{many:t=>`Wrote ${t} files`,subject:t=>t??void 0,path:!0},{name:"Write files"});Qe("edit",t=>`Edited ${gd(t)??"a file"}`,{many:t=>`Edited ${t} files`,subject:t=>t??void 0,path:!0},{name:"Edit files"});Qe("bash",t=>`Ran \`${uo(md(Zg(Ae(t.command)??"")),60)}\``,{many:t=>`Ran ${t} commands`},{name:"Run commands"});const yd=t=>{const r=t&&Tn(Jo(t.text)??Jo(Zg(t.text)));if((r==null?void 0:r.ok)!==!1)return;const o=Ae(r.refused);return o!==void 0?{refused:!0,detail:o.replace(/^refused:\s*/,"")}:{refused:!1,detail:Ae(r.error)??Ae(r.message)??"no detail"}},dE=(t,r)=>`${yd(r)?"Tried to fetch":"Fetched"} ${Xo(Ae(t.url)??"a page")}`,fE={many:t=>`Fetched ${t} pages`,subject:t=>t?Xo(t):void 0},ey=t=>{const r=yd(t);return r&&{failed:!0,text:`${r.refused?"refused":"failed"}: ${r.detail}`}};Qe("web_fetch",dE,fE,{name:"Fetch web pages"});ya("web_fetch",ey);const pE=(t,r)=>{var a;const o=r&&Ae((a=Tn(Jo(r.text)))==null?void 0:a.path),i=Ae(t.path);return o??(i?i.includes("/")?i:`media/${i}`:"a file")},hE=t=>{var o;const r=(o=URL.parse(Ae(t.url)??""))==null?void 0:o.host;return r?` from ${r}`:""};Qe("web_save",(t,r)=>`${yd(r)?"Tried to save":"Saved"} ${pE(t,r)}${hE(t)}`,{many:t=>`Saved ${t} files from the web`,subject:t=>t??void 0},{name:"Save files from the web"});ya("web_save",ey);Qe("web_search",t=>{const r=(Array.isArray(t.queries)?t.queries.map(Ae).find(Boolean):void 0)??Ae(t.objective)??Ae(t.query);return r?`Searched the web for "${uo(md(r),60)}"`:"Searched the web"},{many:t=>`Searched the web ${t} times`,subject:t=>t?`"${uo(t,40)}"`:void 0},{name:"Search the web"});ya("web_search",t=>{var o;const r=Ae((o=Tn(Jo(t.text)))==null?void 0:o.error);return r!==void 0?{failed:!0,text:`failed: ${r}`}:void 0});Qe("browser_read",(t,r)=>{var i;const o=r&&((i=/^title: (.+)$/m.exec(r.text))==null?void 0:i[1]);return o?`Read the page "${uo(md(o),60)}"`:"Read the page"},{many:t=>`Read ${t} pages`,subject:(t,r)=>{var i;const o=r&&((i=/^url: (\S+)/m.exec(r))==null?void 0:i[1]);return o?Xo(o):void 0}},{name:"Read the browser's page"});Qe("snapshot",()=>"Looked at the page structure",{many:t=>`Looked at the page structure ${t} times`},{name:"Look at the page structure"});Qe("screenshot",()=>"Took a screenshot",{many:t=>`Took ${t} screenshots`},{name:"Take screenshots"});const om=t=>{const r=(t==null?void 0:t.isError)===!0?Tn(Jo(t.text)):void 0;return Ae(r==null?void 0:r.code)==="refused"&&Ae(r==null?void 0:r.effect)==="none"};Qe("run",(t,r)=>{var u,f;const o=(u=cE.exec(Ae(t.code)??""))==null?void 0:u[1];if(om(r))return Ae(t.code)===void 0?"The browser refused the action":o?`The browser refused the code to open ${Xo(o)}`:"The browser refused the agent's code";if(o)return`Opened ${Xo(o)}`;const i=(f=Tn(r==null?void 0:r.details))==null?void 0:f.sent,a=Array.isArray(i)?i.flatMap(d=>{const m=Tn(d),[h,g]=[Ae(m==null?void 0:m.method),Ae(m==null?void 0:m.url)];return h&&g?`${h} ${Xo(g)}`:[]}):[];return a.length?`Acted on the page (${a.length} request${a.length===1?"":"s"} sent: ${eE(a)})`:"Acted on the page"},{many:t=>`Acted on the page ${t} times`},{name:"Open or act on a page in the browser",saysFailure:om});Qe("browser_downloads",(t,r)=>{var a;const o=r&&((a=Jo(r.text))==null?void 0:a.fetched),i=Array.isArray(o)?o.flatMap(u=>{var f;return Ae((f=Tn(u))==null?void 0:f.name)??[]}):[];return i.length===1?`Downloaded ${i[0]}`:i.length?`Downloaded ${i.length} files`:"Downloaded files"},{many:t=>`Downloaded files ${t} times`},{name:"Download files in the browser"});Qe("browser_release",()=>"Released the browser session",void 0,{name:"Release the browser session"});Qe("browser_relaunch",()=>"Started a fresh browser session",void 0,{name:"Start a fresh browser session"});Qe("submit",()=>"Submitted the answer",void 0,{name:"Submit the answer"});Qe("codemode",()=>"Ran a script",{many:t=>`Ran ${t} scripts`},{name:"Run scripts"});Qe("request_sign_in",()=>"Asked you to sign in",void 0,{name:"Ask you to sign in"});const mE=/^(\d+)\. [a-z_.]+(?: into)?(?: @\S+ ([a-z]+)(?: ("(?:[^"\\]|\\.)*"))?)?(?: \[secure\])?: (.*)$/,gE=t=>{if(t!==void 0)try{return Ae(JSON.parse(t))}catch{return}};function ty(t){var o;const r=new Map;for(const i of(t??"").split(`
290
290
  `)){const a=mE.exec(i);if(!a)continue;const u=gE(a[3]),f=(o=/^refused \([^)]*\): (.*)$/.exec(a[4]))==null?void 0:o[1],d=a[2]===void 0?void 0:{role:a[2],...u?{name:u}:{}};r.set(Number(a[1]),{...d?{on:d}:{},...f!==void 0?{refused:f}:{}})}return r}function yE(t,r){return{...jS(t,()=>r==null?void 0:r.on),...(r==null?void 0:r.refused)!==void 0?{error:"refused"}:{}}}Qe("computer_act",(t,r)=>{var d;const o=Array.isArray(t.steps)?t.steps.flatMap(m=>{const h=Tn(m);return h?[h]:[]}):[],i={method:"ui.act",started_at:"",ms:0,...Ae(t.app)?{app:Ae(t.app)}:{}};if(r!=null&&r.isError)return _n({...i,ok:!1});const a=r===void 0?void 0:ty(r.text),u=a===void 0?o:o.filter((m,h)=>a.has(h+1));if(o.length>0&&u.length===0)return _n({...i,ok:!1});const f=r&&((d=/^expect: (met|unmet)$/m.exec(r.text))==null?void 0:d[1]);return _n({...i,ok:!0,steps:u.map((m,h)=>yE(m,a==null?void 0:a.get(h+1))),...f==="met"||f==="unmet"?{expect:f}:{}})},{many:t=>`Acted on the computer ${t} times`},{name:"Act on the computer",saysFailure:!0});ya("computer_act",t=>{for(const[r,o]of ty(t.text))if(o.refused!==void 0)return{failed:!0,text:`step ${r} refused: ${o.refused}`}});const sm=/^state \S+ · (\S+)/,vE=/^screen \S+ px · (?:\S+ in front|no app in front)/;Qe("computer_observe",(t,r)=>{var i;if(r&&!r.isError&&!sm.test(r.text)){const a=vE.test(r.text),u=(d,m)=>({method:d,started_at:"",ms:0,ok:!0,...m?{app:m}:{}}),f=a?Ae(t.app):void 0;return US([...f?[u("apps.launch",f)]:[],u("screen.shot"),...a?[u("apps.list")]:[]])}const o=Ae(t.app)??(r&&((i=sm.exec(r.text))==null?void 0:i[1]));return _n({method:"ui.observe",ok:(r==null?void 0:r.isError)!==!0,...o?{app:o}:{}})},{many:t=>`Looked at the screen ${t} times`},{name:"Look at the computer",saysFailure:!0});Qe("computer_screenshot",(t,r)=>_n({method:"screen.shot",ok:(r==null?void 0:r.isError)!==!0}),{many:t=>`Took ${t} screenshots`},{name:"Take screenshots of the computer",saysFailure:!0});const im={"input.act":"input.actions","apps.list":"apps.list","apps.open":"apps.launch","shell.run":"exec.run","processes.start":"process.start","files.read":"files.read","files.write":"files.write","files.list":"files.list","files.stat":"files.stat"};Qe("computer_op",(t,r)=>{var u;const o=Ae(t.op),i=o!==void 0&&Object.hasOwn(im,o)?im[o]:void 0;if(!i)return r!=null&&r.isError?"Could not act on the computer":"Acted on the computer";const a=i==="apps.launch"?Ae((u=Tn(t.args))==null?void 0:u.id):void 0;return _n({method:i,ok:(r==null?void 0:r.isError)!==!0,...a?{app:a}:{}})},{many:t=>`Acted on the computer ${t} times`},{name:"Use the computer's apps, shell and files",saysFailure:!0});Qe("computer_script",(t,r)=>{var i;const o=(i=Ae(t.title))==null?void 0:i.replace(/\s+/g," ").trim();return r!=null&&r.isError?o?`Could not run the script “${uo(o,120)}”`:"Could not run a script on the computer":o?uo(o,120):"Ran a script on the computer"},{many:t=>`Ran ${t} scripts on the computer`},{name:"Run scripts on the computer",saysFailure:!0});const wE=["schedule","webhook","slack","github","composio","email","feed"];new Set(wE);const xE=":feedback",kE=t=>{var r;return t.kind==="user_message"&&((r=t.id)==null?void 0:r.endsWith(xE))===!0},bE={user_message:Tw,thinking:pw,tool_use:rh,tool_result:rh,waiting:vm,usage:yw,final_answer:kw,phase:ym,error:Bc,decision:Nw,text_block:Sw,tool_approval_requested:Cw},lm=t=>{var r;return t.kind==="tool_approval_requested"?(r=/\n\n(Not sent: [\s\S]*)$/.exec(t.text??""))==null?void 0:r[1]:void 0},am=t=>t.kind==="tool_approval_requested"&&(t.summary??"").startsWith("Waiting for your approval"),vd=t=>t.origin==="server",ny=t=>t.origin==="trigger",ry=t=>{var u;const r=t.summary??"",o=(u=t.trigger)==null?void 0:u.name,i=o?r.indexOf(` ${o}: `):-1;if(o&&i>0&&!r.slice(0,i).includes(" "))return{who:r.slice(0,i+1+o.length),said:r.slice(i+o.length+3).trimStart()};const a=/^([^:]+):\s*/.exec(r);return a?{who:a[1],said:r.slice(a[0].length)}:{who:null,said:r}},SE=new RegExp(String.raw`(${sd}|\*\*[^*\n]+?\*\*|`+"`[^`\\n]+`"+String.raw`|\[[^\]\n]+\]\((?:[^()\s]|\([^()\s]*\))+\)|<https?:\/\/[^>\s]+>)`);function ea(t){const r=t.split(SE);return r.length===1?t:r.map((o,i)=>i%2===0?o:o.startsWith("[redacted:")?y.jsx(ao,{text:o},i):o.startsWith("`")?y.jsx("code",{className:"font-mono",children:y.jsx(ao,{text:o.slice(1,-1)})},i):o.startsWith("[")?y.jsx(O.Fragment,{children:ea(o.slice(1,o.indexOf("](")))},i):o.startsWith("<")?o.slice(1,-1):y.jsx("strong",{className:"font-semibold",children:ea(o.slice(2,-2))},i))}const oy=t=>{var i;const r=ny(t)?ry(t).said:(t.summary??"").replace(vd(t)?/^AgentRun:\s*/:/^(You|Thinking|Asked you|Waiting for you):\s*/,"");if(t.kind==="user_message"&&r.startsWith("{"))try{return Object.entries(JSON.parse(r)).map(([a,u])=>`${a}: ${typeof u=="string"?u:JSON.stringify(u)}`).join(" · ")}catch{}const o=(t.text??"").split(`
291
- `).filter(a=>a.trim()).length>1?"…":"";return t.kind==="final_answer"?!r.trim()&&!((i=t.text)!=null&&i.trim())?hb:`${r.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"")}${o}`:t.kind==="user_message"?`${r}${o}`:r},di=t=>t<1e3?`${t} ms`:`${(t/1e3).toFixed(1)} s`,EE=new Set(SS),_E=new Map(Object.entries({read:"Read",write:"Write",edit:"Edit",multiedit:"Edit",apply_patch:"Edit",notebookedit:"Edit",bash:"Shell",shell:"Shell",local_shell:"Shell",exec_command:"Shell",web_fetch:"Fetch",webfetch:"Fetch",fetch:"Fetch",web_search:"Search",websearch:"Search",ls:"List files",glob:"Find files",find:"Find files",grep:"Search files",ask_person:"Question",submit:"Answer",codemode:"Script",todowrite:"To-dos",task:"Subagent",skill:"Skill"}));function NE(t){const r=_E.get(t.toLowerCase());if(r)return r;const o=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return o?o[0].toUpperCase()+o.slice(1):t}const um=t=>t&&(Tb(t)??(EE.has(t)?lE(t):NE(t))),Dc=t=>vd(t)?"AgentRun":ny(t)?ry(t).who??"Trigger":kE(t)?"Your grade":{user_message:"You",thinking:"Thinking",tool_use:um(t.tool_name)??"Tool",tool_result:um(t.tool_name)??"Result",waiting:"Waiting for you",usage:"Usage",final_answer:"Answer",phase:"Phase",error:"Error",decision:"Decision",text_block:"Text",tool_approval_requested:"Your approval",learning:"Learning"}[t.kind]??t.kind,WN=t=>Dc(t);function BN({row:t}){return ea(oy(t))}const CE={budget:"Paused at cap"};function TE({step:t,last:r,ended:o,waitingChip:i,files:a,onOpen:u,shared:f}){var j,P;const d=t.row,[m,h]=O.useState(!1),w=Q1(d)?gm:bE[d.kind]??ym,x=t.above?d.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":oy(d),k=t.above?null:t.detail??q1(d),b=k&&k.trim()!==x.trim()?k:null,C=V1(d);return y.jsxs("li",{className:"relative flex gap-3",children:[y.jsxs("div",{className:"flex w-7 shrink-0 flex-col items-center",children:[y.jsx("span",{className:Ce("mt-3 flex size-7 items-center justify-center border bg-background",(d.kind==="waiting"||am(d))&&"border-warning/60 text-warning-text",C&&"border-destructive/60 text-destructive-text"),children:y.jsx(w,{className:"size-3.5","aria-hidden":!0})}),!r&&y.jsx("span",{className:"w-px flex-1 bg-border","aria-hidden":!0})]}),y.jsxs("div",{className:"min-w-0 flex-1 border-b py-3",children:[y.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:()=>h(F=>!F),"aria-expanded":m,disabled:!b,children:[y.jsxs("span",{className:"min-w-0 flex-1",children:[y.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-body text-muted-foreground",children:[y.jsx("span",{"data-label":!0,className:"min-w-0 truncate",title:Dc(d),children:Dc(d)}),(d.kind==="tool_use"||d.kind==="tool_result")&&d.usage&&y.jsxs("span",{className:"font-mono text-label",children:["· ",D1(d.usage,{ended:o})]}),d.kind==="waiting"&&y.jsx(Qt,{tone:"warning",children:i??"Input required"}),am(d)&&y.jsx(Qt,{tone:"warning",children:"Approval required"}),C&&y.jsx(Qt,{tone:"error",children:"Error"}),Mg(d)&&y.jsx(Qt,{tone:"muted",title:d.tool_name==="codemode"?"Refused before it started, or stopped at a refused call: the calls under it say which ran":"Not run: refused before it ran",children:"Refused"}),d.agent_label&&y.jsx(Qt,{label:!0,title:d.agent_label,children:d.agent_label}),t.ms!==void 0&&y.jsx("span",{className:"font-mono text-label",children:di(t.ms)}),t.times&&y.jsxs("span",{className:"font-mono text-label",children:[t.times," times",t.until?` over ${di(Math.max(0,Date.parse(t.until)-Date.parse(d.timestamp)))}`:""]})]}),y.jsx("span",{className:Ce("mt-0.5 block break-words text-prose leading-snug",vd(d)&&"text-muted-foreground"),children:ea(x)}),t.saved&&y.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",t.saved]}),lm(d)&&y.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:lm(d)})]}),y.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:L1(d.timestamp)}),b&&y.jsx(Lr,{className:Ce("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",m&&"rotate-90"),"aria-hidden":!0})]}),m&&b&&d.tool_name&&y.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:d.tool_name}),m&&b&&d.kind==="final_answer"&&y.jsx("article",{className:"report mt-3 max-h-80 max-w-none overflow-auto border bg-card p-3",onClick:Pg(F=>{const R=a==null?void 0:a.find(M=>M.path===F);R&&(u==null||u(R))}),dangerouslySetInnerHTML:{__html:ai(b,u&&a?{paths:a.map(F=>F.path),...f?{images:!1}:{}}:f?{paths:[],images:!1}:void 0)}}),m&&b&&d.kind!=="final_answer"&&y.jsx("pre",{className:"mt-3 max-h-80 overflow-auto whitespace-pre-wrap break-words border bg-card p-3 font-mono text-small leading-[1.7]",children:y.jsx(ao,{text:b})}),(j=d.learned_nodes)!=null&&j.length?y.jsx(AE,{nodes:d.learned_nodes}):null,(P=d.computer_calls)!=null&&P.length?y.jsx($E,{calls:d.computer_calls,dropped:d.computer_calls_dropped??0}):null]})]})}function $E({calls:t,dropped:r}){const[o,i]=O.useState(!1),a=t.filter(m=>!m.ok).length,u=t.length+r,f=[`${u} computer ${u===1?"call":"calls"}`,...a?[`${a} failed`]:[]].join(" · "),d=Date.parse(t[0].started_at);return y.jsxs("div",{className:"mt-2",children:[y.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>i(m=>!m),"aria-expanded":o,"aria-label":`${o?"Hide":"Show"} the computer calls`,children:[y.jsx(Lr,{className:Ce("size-3 transition-transform",o&&"rotate-90"),"aria-hidden":!0}),y.jsx(Ew,{className:"size-3","aria-hidden":!0}),f]}),o&&y.jsxs("ol",{"aria-label":"The computer calls",className:"mt-2 divide-y border bg-card",children:[t.map((m,h)=>y.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[y.jsxs("span",{className:"w-14 shrink-0 font-mono text-label text-muted-foreground",children:["+",di(Math.max(0,Date.parse(m.started_at)-d))]}),y.jsx("span",{className:Ce("min-w-0 flex-1 truncate text-body",!m.ok&&"text-destructive-text"),title:_n(m),children:_n(m)}),!m.ok&&m.code&&y.jsx("span",{className:"shrink-0 font-mono text-label text-destructive-text",children:m.code}),y.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:di(m.ms)})]},h)),r>0&&y.jsxs("li",{className:"px-3 py-1.5 text-body text-muted-foreground",children:[r," more not kept"]})]})]})}const jE={ok:"success",failed:"error",escalated:"warning"};function AE({nodes:t}){const[r,o]=O.useState(!1),i=Object.entries(t.reduce((u,f)=>({...u,[f.status]:(u[f.status]??0)+1}),{})).filter(([u])=>u!=="ok"),a=[`${t.length} ${t.length===1?"node":"nodes"}`,...i.map(([u,f])=>`${f} ${u}`)].join(" · ");return y.jsxs("div",{className:"mt-2",children:[y.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>o(u=>!u),"aria-expanded":r,"aria-label":`${r?"Hide":"Show"} the workflow's ${t.length===1?"node":"nodes"}`,children:[y.jsx(Lr,{className:Ce("size-3 transition-transform",r&&"rotate-90"),"aria-hidden":!0}),y.jsx($w,{className:"size-3","aria-hidden":!0}),a]}),r&&y.jsx("ol",{"aria-label":"The workflow's nodes",className:"mt-2 divide-y border bg-card",children:t.map((u,f)=>y.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[y.jsx("span",{"data-status":u.status,className:"contents",children:y.jsx(Qt,{tone:jE[u.status]??"muted",className:"w-[5.5rem] justify-center",children:u.status})}),y.jsx("span",{className:"min-w-0 flex-1 truncate text-body",title:u.label,children:u.label}),y.jsx("span",{"data-kind":!0,className:"font-mono text-label text-muted-foreground",title:Hg(u)||void 0,children:ud(u.kind,u)}),y.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:di(u.duration_ms)})]},f))})]})}function HN({rows:t,live:r,fold:o=6,asking:i,waitingOn:a,files:u,onOpen:f,ended:d=!1,shared:m=!1}){var j;const h=a==="budget"?t.findLastIndex(P=>P.paused===!0):-1,g=h>=0?(j=t.slice(h+1).findLast(P=>P.kind==="waiting"))==null?void 0:j.id:void 0,[w,x]=O.useState(!1),k=K1(t).map(P=>i&&P.row.id===i?{...P,above:!0}:P),b=w?0:Math.max(0,k.length-o),C=k.slice(b);return t.length?y.jsxs("div",{children:[b>0&&y.jsxs("button",{type:"button",className:"caps mb-1 ml-10 flex items-center gap-1 py-2 text-label text-muted-foreground hover:text-foreground",onClick:()=>x(!0),children:[y.jsx(Lr,{className:"size-3","aria-hidden":!0})," ",b," earlier ",b===1?"step":"steps"]}),y.jsx("ol",{children:C.map((P,F)=>y.jsx(TE,{step:P,last:F===C.length-1&&!r,ended:d,waitingChip:P.row.id===g&&a?CE[a]:void 0,files:u,onOpen:f,shared:m},P.row.id))}),r&&y.jsx(cm,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):y.jsx(cm,{title:r?"The run is starting":"Nothing on the timeline",note:r?"Steps appear here as the agent works.":"This run recorded no steps.",spin:r})}function cm({title:t,note:r,spin:o=!0}){return y.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-center",children:[o&&y.jsx(kk,{className:"size-5"}),y.jsx("p",{className:"caps text-label font-semibold",children:t}),y.jsx("p",{className:"max-w-sm text-body text-muted-foreground",children:r})]})}const sy=new Set(["chain","parallel","route","map","loop","workflow"]),RE={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},OE=t=>t==="review"?"needs review":t.replace("-"," ");function wd({state:t}){const r=Xl(t)??"pending";return y.jsx(Qt,{tone:RE[r]??"plain",className:"whitespace-nowrap",children:OE(r)})}function xd({provider:t}){if(!t)return null;const r=t==="parallel"?"--wf-parallel":t==="openrouter"?"--wf-openrouter":"--wf-jev";return y.jsx("span",{className:"caps inline-flex h-5 items-center border px-1.5 text-micro leading-none",style:{color:`hsl(var(${r}))`,borderColor:`hsl(var(${r}) / .6)`,background:`hsl(var(${r}) / .12)`},children:t})}const iy={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},kd=(t,r)=>t&&r?Date.parse(r)-Date.parse(t):void 0;function LE({data:t,selected:r,onSelect:o,onClose:i,fileUrl:a,shared:u=!1}){var P,F,R,M,G,Y;const f=t.graph.nodes.find(V=>V.path===r.path),[d,m]=O.useState(null);if(!f)return null;const h=t.nodes[f.path],g=id(t.workflow,f.path,f),w=f.kind==="map"?f.path:(P=t.graph.nodes.find(V=>V.kind==="map"&&f.path.startsWith(`${V.path}/body/`)))==null?void 0:P.path,x=r.item!=null&&w?(R=(F=t.nodes[w])==null?void 0:F.items)==null?void 0:R.find(V=>V.index===r.item):void 0,k=t.decisions.filter(V=>V.node===f.path),b=t.effects.filter(V=>V.node===f.path),C=!!w&&f.kind!=="map",j=kd(h==null?void 0:h.startedAt,h==null?void 0:h.endedAt);return y.jsxs("aside",{className:"flex min-h-0 flex-col bg-background","aria-label":"Node details",children:[y.jsxs("header",{className:"border-b px-5 py-4",children:[y.jsxs("div",{className:"flex items-start gap-3",children:[y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsxs("p",{className:"caps flex items-center gap-1.5 text-label text-muted-foreground",children:[g.decision?f.kind:ud(f.kind,h),g.tool?` · ${uy(g.tool)}`:f.via?` · ${f.via}`:"",g.tool&&vi(g.tool)&&y.jsx(cy,{}),x&&y.jsxs(y.Fragment,{children:[y.jsx(Lr,{className:"size-3","aria-hidden":!0})," item ",x.index+1]})]}),y.jsx("h2",{className:"mt-1 break-words font-mono text-lg font-semibold leading-tight",children:x?ui(t,w,x.index)??`Item ${x.index+1}`:f.label}),y.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[y.jsx(wd,{state:x?x.status:h==null?void 0:h.status}),x&&(()=>{const V=ld(t,w,x);return V.outcome?y.jsxs("span",{className:"font-mono text-label",title:V.pNote,children:["outcome ",y.jsx("b",{className:iy[V.tone??""],children:V.outcome}),V.p!==void 0&&y.jsxs("span",{className:"text-muted-foreground",children:[" · ",Zt(V.p)]})]}):null})(),g.decision&&y.jsx(xd,{provider:g.provider}),g.decision&&((h==null?void 0:h.model)??g.model)&&y.jsx("span",{className:"font-mono text-label text-muted-foreground",children:(h==null?void 0:h.model)??g.model}),(h==null?void 0:h.branch)&&y.jsxs("span",{className:"font-mono text-label",children:["took ",y.jsx("b",{children:h.branch})]}),!x&&j!==void 0&&y.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Ko(j)})]})]}),y.jsx(Kn,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:i,children:y.jsx(xm,{"aria-hidden":!0})})]}),x&&y.jsxs("button",{type:"button",className:"caps mt-3 text-label text-muted-foreground hover:text-foreground",onClick:()=>o({path:w,item:null}),children:["All ",(G=(M=t.nodes[w])==null?void 0:M.items)==null?void 0:G.length," items of ",(Y=t.graph.nodes.find(V=>V.path===w))==null?void 0:Y.label]})]}),y.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-auto px-5 py-5",children:[x?y.jsx(zE,{data:t,mapPath:w,index:x.index,status:x.status,fileUrl:a,zoom:m,shared:u}):f.kind==="map"?y.jsx(PE,{data:t,mapPath:f.path,onSelect:o}):C&&(k.length||b.length)?y.jsx(ME,{data:t,path:f.path,mapPath:w,onSelect:o}):y.jsxs(y.Fragment,{children:[f.kind==="parallel"&&y.jsx(IE,{data:t,path:f.path,onSelect:o}),k.map((V,fe)=>y.jsx(ay,{d:V,fileUrl:a,zoom:m,shared:u},V.id??fe)),b.map((V,fe)=>y.jsx(dy,{e:V,fileUrl:a,zoom:m,shared:u},fe)),!k.length&&!b.length&&f.kind!=="parallel"&&y.jsx(ly,{kind:f.kind,status:h==null?void 0:h.status,meta:g})]}),y.jsx(BE,{workflow:t.workflow,path:f.path,kind:f.kind})]}),d&&y.jsx(HE,{src:d,onClose:()=>m(null)})]})}function ly({kind:t,status:r,meta:o}){const i=o.decision?r==="working"?"Asking now. The verdict shows here when the answer comes back.":"Not asked yet.":t==="code"?"A code node: a pure transform of the run's state. It calls nothing, so it leaves no record of its own.":t==="route"?"Routed by a value already in the state: no model was asked.":sy.has(t)?"Its nodes are drawn inside it. Pick one to see what it did.":"Nothing recorded yet.";return y.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:i})}function PE({data:t,mapPath:r,onSelect:o}){var u;const i=((u=t.nodes[r])==null?void 0:u.items)??[],a=Ug(i);return y.jsxs("section",{children:[y.jsx("div",{className:"mb-3 grid grid-cols-5 border",children:[["Items",a.total],["Done",a.done],["Working",a.working],["Review",a.review],["Failed",a.failed]].map(([f,d])=>y.jsxs("div",{className:"border-r px-3 py-2 last:border-r-0",children:[y.jsx("p",{className:"caps text-micro text-muted-foreground",children:f}),y.jsx("p",{className:"font-mono text-lg font-semibold tabular-nums",children:d})]},f))}),y.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[y.jsx("thead",{children:y.jsxs("tr",{className:"caps text-left text-micro text-muted-foreground",children:[y.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"#"}),y.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Item"}),y.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"State"}),y.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Verdict"}),y.jsx("th",{className:"border-b py-1.5 text-right font-normal",children:"Cost"})]})}),y.jsx("tbody",{children:i.map(f=>{const d=t.decisions.filter(g=>{var w;return g.item===f.index&&!!((w=g.node)!=null&&w.startsWith(`${r}/body`))}),m=ld(t,r,f),h=d.length?d.some(g=>g.cost_usd===null)?null:d.reduce((g,w)=>g+(w.cost_usd??0),0):void 0;return y.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>o({path:r,item:f.index}),children:[y.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:f.index+1}),y.jsx("td",{className:"max-w-[140px] truncate border-b py-1.5 pr-2",title:ui(t,r,f.index),children:ui(t,r,f.index)??"—"}),y.jsx("td",{className:"border-b py-1.5 pr-2",children:y.jsx(wd,{state:f.status})}),y.jsx("td",{className:"max-w-[150px] truncate whitespace-nowrap border-b py-1.5 pr-2",title:[m.pNote,...d.map(g=>Zo(g))].filter(Boolean).join(", "),children:m.outcome?y.jsxs(y.Fragment,{children:[y.jsx("span",{className:Ce("font-semibold",iy[m.tone??""]),children:m.outcome}),m.p!==void 0&&y.jsx("span",{className:"ml-2 tabular-nums text-muted-foreground",children:Zt(m.p)})]}):d.map(g=>Zo(g)).filter(Boolean).join(", ")||y.jsx("span",{className:"text-muted-foreground",children:"—"})}),y.jsx("td",{className:"border-b py-1.5 text-right tabular-nums",children:h===void 0?y.jsx("span",{className:"text-muted-foreground",children:"—"}):yi(h)})]},f.index)})})]})]})}function ME({data:t,path:r,mapPath:o,onSelect:i}){var g;const a=t.decisions.filter(w=>w.node===r),u=t.effects.filter(w=>w.node===r),f=(((g=t.nodes[o])==null?void 0:g.items)??[]).map(w=>({it:w,d:a.find(x=>x.item===w.index),e:u.find(x=>x.item===w.index)})).filter(w=>w.d||w.e),d=a.filter(w=>w.cost_usd!==null),m=a.filter(w=>w.latency_ms!==null),h=m.length?m.reduce((w,x)=>w+(x.latency_ms??0),0)/m.length:void 0;return y.jsxs("section",{children:[a.length>0&&y.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[a.length," asked · ",yi(d.reduce((w,x)=>w+(x.cost_usd??0),0)),d.length<a.length?` + ${a.length-d.length} unknown`:""," · mean ",Ko(h)]}),y.jsx("table",{className:"w-full border-collapse font-mono text-small",children:y.jsx("tbody",{children:f.map(({it:w,d:x,e:k})=>y.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>i({path:o,item:w.index}),children:[y.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:w.index+1}),y.jsx("td",{className:"max-w-[150px] truncate border-b py-1.5 pr-2",children:ui(t,o,w.index)}),y.jsx("td",{className:"border-b py-1.5 pr-2",children:x?Zo(x):k?y.jsx(wd,{state:k.status}):null}),y.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:x?Ko(x.latency_ms):k?Ko(kd(k.startedAt,k.endedAt)):""})]},w.index))})})]})}function IE({data:t,path:r,onSelect:o}){var x,k;const i=`${r}/branches/`,a=t.decisions.filter(b=>{var C;return((C=b.node)==null?void 0:C.startsWith(i))&&/^\d+$/.test(b.node.slice(i.length))&&b.item===null}),u=new Set(a.flatMap(b=>Object.keys(b.answers??{}))),[f]=[...u],d=a.map(b=>{var C;return{d:b,a:(C=b.answers)==null?void 0:C[f]}}).filter(b=>{var C;return((C=b.a)==null?void 0:C.type)==="noul"});if(u.size!==1||d.length<2)return y.jsx(ly,{kind:"parallel",meta:{decision:!1}});const m=d.map(b=>b.a.noul),h=m.reduce((b,C)=>b+C,0)/m.length,g=Math.max(...m)-Math.min(...m),w=b=>{var C;return((C=t.graph.nodes.find(j=>j.path===b.node))==null?void 0:C.label)??b.node};return y.jsxs("section",{className:"border bg-card",children:[y.jsxs("header",{className:"border-b px-4 py-2.5",children:[y.jsxs("p",{className:"caps text-micro text-muted-foreground",children:["Jury · ",d.length," models · ",f]}),y.jsx("p",{className:"mt-1 text-body leading-snug",children:((k=(x=a[0].questions)==null?void 0:x[f])==null?void 0:k.instructions)??f})]}),y.jsx("ul",{className:"divide-y",children:d.map(({d:b,a:C})=>y.jsx("li",{children:y.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-2 text-left font-mono text-small hover:bg-accent",onClick:()=>o({path:b.node,item:null}),children:[y.jsx("span",{className:"w-[92px] shrink-0",children:y.jsx(xd,{provider:b.provider})}),y.jsx("span",{className:"w-[132px] shrink-0 truncate",title:b.model??"",children:b.model??w(b)}),y.jsx(Fc,{p:C.noul,strong:!0,tick:.5,tone:C.noul>=.5?"fg":"muted"}),y.jsx("span",{className:"w-10 text-right tabular-nums",children:Zt(C.noul)})]})},b.id??b.executionPath))}),y.jsxs("dl",{className:"grid grid-cols-3 border-t font-mono text-small",children:[y.jsxs("div",{className:"border-r px-4 py-2",children:[y.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Mean P(yes)"}),y.jsx("dd",{className:"font-semibold tabular-nums",children:Zt(h)})]}),y.jsxs("div",{className:"border-r px-4 py-2",children:[y.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Spread"}),y.jsx("dd",{className:Ce("font-semibold tabular-nums",g>.3&&"text-warning-text"),children:Zt(g)})]}),y.jsxs("div",{className:"px-4 py-2",children:[y.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),y.jsx("dd",{className:"tabular-nums",children:yi(d.some(b=>b.d.cost_usd===null)?null:d.reduce((b,C)=>b+(C.d.cost_usd??0),0))})]})]})]})}function zE({data:t,mapPath:r,index:o,status:i,fileUrl:a,zoom:u,shared:f=!1}){const m=t.graph.nodes.filter(h=>h.path.startsWith(`${r}/body`)).map(h=>({n:h,ds:t.decisions.filter(g=>g.node===h.path&&g.item===o),es:t.effects.filter(g=>g.node===h.path&&g.item===o)})).filter(h=>!sy.has(h.n.kind)||h.ds.length||h.es.length);return i==="pending"?y.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"Not started: this item waits for a free slot in the map."}):y.jsxs("div",{className:"space-y-5",children:[m.map(({n:h,ds:g,es:w})=>g.length||w.length?y.jsxs("div",{className:"space-y-3",children:[y.jsx("p",{className:"caps text-label text-muted-foreground",children:h.label}),w.map((x,k)=>y.jsx(dy,{e:x,fileUrl:a,zoom:u,compact:!0,shared:f},k)),g.map((x,k)=>y.jsx(ay,{d:x,fileUrl:a,zoom:u,shared:f},x.id??k))]},h.path):null),i==="working"&&!m.some(h=>h.ds.length)&&y.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"In flight: the verdict shows here when it comes back."})]})}const dm=t=>`${Math.round(t*100)}%`,Zt=t=>t.toFixed(2);function Fc({p:t,strong:r,tick:o,tone:i="fg"}){const a={fg:"bg-foreground",success:"bg-success",warning:"bg-warning",muted:"bg-muted-foreground/50"}[i];return y.jsxs("span",{className:"relative block h-2 flex-1 bg-muted",children:[y.jsx("span",{className:Ce("absolute inset-y-0 left-0 transition-[width] duration-slow",r?a:"bg-muted-foreground/45"),style:{width:dm(Math.max(0,Math.min(1,t)))}}),o!==void 0&&y.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:dm(o)},title:`threshold ${Zt(o)}`})]})}function DE({id:t,q:r,a:o,rule:i}){const a=d=>{var m;return(i==null?void 0:i.kind)==="pick"&&(r==null?void 0:r.type)==="choice"&&typeof((m=r.criteria)==null?void 0:m[d])=="string"?r.criteria[d]:d},u=(r==null?void 0:r.instructions)??t,f=(i==null?void 0:i.kind)==="route"?i.unsure:null;return y.jsxs("div",{className:"py-2.5",children:[y.jsxs("p",{className:"mb-2 text-body leading-snug",children:[y.jsx("span",{className:"mr-2 font-mono text-label text-muted-foreground",children:t}),u]}),o?o.type==="refusal"?y.jsx("p",{className:"font-mono text-small text-warning-text",children:"Refused to answer."}):o.type==="noul"?y.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[y.jsx("span",{className:Ce("w-8 font-semibold",o.noul>=.5?"text-foreground":"text-muted-foreground"),children:o.noul>=.5?"YES":"NO"}),y.jsx(Fc,{p:o.noul,strong:!0,tick:.5,tone:o.noul>=.5?"fg":"muted"}),y.jsxs("span",{className:"w-24 text-right tabular-nums text-muted-foreground",children:["P(yes) ",Zt(o.noul)]})]}):o.type==="box"?y.jsxs("p",{className:"font-mono text-small",children:["box ",JSON.stringify(o.box)]}):y.jsxs("div",{className:"space-y-1.5",children:[Object.entries(o.probabilities).sort((d,m)=>m[1]-d[1]).slice(0,(i==null?void 0:i.kind)==="pick"?5:void 0).map(([d,m])=>{const h=(o.type==="choice"?o.choice:String(o.score))===d;return y.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[y.jsx("span",{className:Ce("truncate",(i==null?void 0:i.kind)==="pick"?"w-48":"w-28",h?"font-semibold":"text-muted-foreground"),title:a(d),children:o.type==="score"?`${d} ${o.legend[d]??""}`:a(d)}),y.jsx(Fc,{p:m,strong:h,tick:h&&f?f.gte:void 0}),y.jsx("span",{className:"w-12 text-right tabular-nums text-muted-foreground",children:Zt(m)})]},d)}),(i==null?void 0:i.kind)==="pick"&&Object.keys(o.probabilities).length>5&&y.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[Object.keys(o.probabilities).length-5," more options, each less likely"]})]}):y.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No answer."})]})}function FE(t){if(!t)return"No rule applied: nothing came back to decide on.";switch(t.kind){case"judge":return"Each answer is decoded on its own: a yes/no is yes at P(yes) ≥ 0.50, a choice is its top option.";case"route":return t.unsure?`Take the chosen branch; below ${Zt(t.unsure.gte)} confidence take "${t.unsure.branch}".`:"Take the chosen branch.";case"pick":return`Pick one of ${t.options.length} options${t.none?`, or "${t.none}"`:""}.`;case"ask":return`Holds when P(yes) ≥ ${Zt(t.gte)}.`;case"sift":return t.keep?`Keep an item when its ${t.keep.id} ${t.keep.measure} ≥ ${Zt(t.keep.gte)}.`:"Keep every item.";case"verify":return"A yes/no fails below its threshold."}}function UE(t){var o,i,a,u;const r=t.action;if(r==null)return t.status==="cancelled"?"None: the outcome is unknown, so it goes to review and is not asked again.":"None.";if(((o=t.rule)==null?void 0:o.kind)==="route"){const f=((a=(i=t.answers)==null?void 0:i.branch)==null?void 0:a.type)==="choice"?t.answers.branch.confidence:void 0;return r.unsure?`Took "${String(r.taken)}": "${String(r.branch)}" at ${f!==void 0?Zt(f):"?"} is below the threshold.`:`Took "${String(r.taken??r.branch)}".`}if(((u=t.rule)==null?void 0:u.kind)==="pick"&&typeof r.index=="number"){const f=t.rule.options[r.index];return r.none?`None of the options: "${t.rule.none??"none"}".`:`Picked ${f!==void 0?`"${Dg(t,Object.keys(t.questions??{})[0]??"pick",f)}"`:`option ${r.index}`}.`}return typeof r=="object"?Object.entries(r).map(([f,d])=>`${f} = ${typeof d=="object"?JSON.stringify(d):String(d)}`).join(" · "):String(r)}function ay({d:t,fileUrl:r,zoom:o,shared:i=!1}){var f,d,m;const a=Array.from(new Set([...Object.keys(t.questions??{}),...Object.keys(t.answers??{})])),u=t.status==="answered"?"success":t.status==="cancelled"?"warning":"error";return y.jsxs("section",{className:"border bg-card",children:[y.jsxs("header",{className:"flex flex-wrap items-center gap-2 border-b px-4 py-2.5",children:[y.jsx(xd,{provider:t.provider}),y.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:t.model??"default model"}),y.jsx(Qt,{tone:u,children:t.status==="cancelled"?"outcome unknown":t.status})]}),y.jsxs("dl",{className:"grid grid-cols-[minmax(0,1fr)_100px_92px] border-b font-mono text-small",children:[y.jsxs("div",{className:"border-r px-4 py-2",children:[y.jsx("dt",{className:"caps text-micro text-muted-foreground",children:Object.keys(t.answers??{}).length>1&&((f=t.rule)==null?void 0:f.kind)!=="route"?"Least sure answer":"Verdict"}),y.jsx("dd",{className:"break-words font-semibold",children:Zo(t)??"—"})]}),y.jsxs("div",{className:"border-r px-4 py-2",children:[y.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),y.jsx("dd",{className:"tabular-nums",title:t.cost_basis??void 0,children:yi(t.cost_usd)})]}),y.jsxs("div",{className:"px-4 py-2",children:[y.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Latency"}),y.jsx("dd",{className:"tabular-nums",children:Ko(t.latency_ms)})]})]}),t.error&&y.jsx("p",{className:Ce("border-b px-4 py-2.5 font-mono text-small",t.status==="cancelled"?"text-warning-text":"text-destructive-text"),children:t.error}),!!((d=t.images)!=null&&d.length)&&y.jsx("div",{className:"space-y-3 border-b px-4 py-3",children:t.images.map(h=>({img:h,src:i?void 0:h.ref&&r(h.ref)||Kg(h.url)})).filter(({src:h})=>i||h).map(({img:h,src:g})=>y.jsxs("figure",{className:"flex gap-3",children:[g&&y.jsx("button",{type:"button",className:"block shrink-0 border bg-white hover:border-foreground",onClick:()=>o(g),"aria-label":`Open ${h.ref}`,children:y.jsx("img",{src:g,alt:`The page the model saw as ${h.token}`,className:"block h-[155px] w-[120px] object-cover object-top",loading:"lazy"})}),y.jsxs("figcaption",{className:"min-w-0 flex-1 space-y-1.5 font-mono text-label",children:[y.jsx("p",{className:"caps text-micro text-muted-foreground",children:"What the model saw"}),y.jsxs("p",{children:[y.jsx("span",{className:"text-muted-foreground",children:"token "}),h.token]}),y.jsxs("p",{className:"break-all",children:[y.jsx("span",{className:"text-muted-foreground",children:"page "}),h.ref]}),h.sha256&&y.jsxs("p",{className:"break-all",title:h.sha256,children:[y.jsx("span",{className:"text-muted-foreground",children:"sha256 "}),h.sha256.slice(0,16),"…"]}),(h.mime||h.bytes)&&y.jsx("p",{className:"text-muted-foreground",children:[h.mime,h.bytes?`${Math.round(h.bytes/1024)} KB`:null].filter(Boolean).join(" · ")})]})]},h.token))}),y.jsx("div",{className:"divide-y px-4",children:a.map(h=>{var g,w;return y.jsx(DE,{id:h,q:(g=t.questions)==null?void 0:g[h],a:(w=t.answers)==null?void 0:w[h],rule:t.rule},h)})}),y.jsxs("dl",{className:"space-y-2 border-t px-4 py-3 text-body",children:[y.jsxs("div",{className:"flex gap-3",children:[y.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Rule"}),y.jsx("dd",{children:FE(t.rule)})]}),y.jsxs("div",{className:"flex gap-3",children:[y.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Action"}),y.jsx("dd",{className:"font-mono text-small",children:UE(t)})]})]}),!!((m=t.evidence)!=null&&m.length)&&y.jsx(WE,{evidence:t.evidence}),t.state!=null&&y.jsxs("details",{className:"group border-t",children:[y.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 px-4 py-2.5 text-label text-muted-foreground hover:text-foreground",children:[y.jsx(Lr,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," What the model saw",t.state_truncated?" (cut at 64 KB)":""]}),y.jsx(ta,{value:t.state})]})]})}function WE({evidence:t}){return y.jsxs("section",{className:"border-t px-4 py-3",children:[y.jsxs("p",{className:"caps mb-2 text-micro text-muted-foreground",children:["Sources · ",t.length]}),y.jsx("ol",{className:"space-y-3",children:t.map((r,o)=>{let i=r.url;try{i=new URL(r.url).host}catch{}const a=Kg(r.url);return y.jsxs("li",{className:"flex gap-3",children:[y.jsx("span",{className:"font-mono text-label text-muted-foreground",children:o+1}),y.jsxs("div",{className:"min-w-0 flex-1",children:[a?y.jsxs("a",{href:a,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-start gap-1 text-body font-semibold leading-snug hover:underline",children:[r.title??i,y.jsx(ww,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}):y.jsx("span",{className:"break-all text-body font-semibold leading-snug",children:r.title??i}),y.jsxs("p",{className:"mt-0.5 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[i,r.scope&&y.jsx("span",{className:"border px-1",children:r.scope})]}),r.excerpts.slice(0,2).map((u,f)=>y.jsx("blockquote",{className:"mt-1.5 line-clamp-3 border-l-2 border-wf-parallel/[.6] pl-2.5 text-body leading-snug text-muted-foreground",children:u},f))]})]},o)})})]})}const uy=t=>{const r=vi(t);return r?`${r.tool} on ${r.server}`:t},cy=()=>y.jsx(Qt,{tone:"muted",title:"An MCP server's tool",children:y.jsx("span",{"data-mcp":!0,children:"MCP"})});function dy({e:t,fileUrl:r,zoom:o,compact:i=!1,shared:a=!1}){var w;const u=t.output,f=u!=null,d=u&&typeof u=="object"?u:null,m=!t.endedAt&&!["done","ok","failed","stopped"].includes(t.status),h=t.error??(d!=null&&d.error?`${d.error.code?`${d.error.code}: `:""}${d.error.message??""}`:null),g=t.status==="done"||t.status==="ok"?"success":t.status==="failed"?"error":t.status==="stopped"?"muted":"active";return y.jsxs("section",{className:"border bg-card",children:[y.jsxs("header",{className:"flex items-center gap-2 border-b px-4 py-2.5",children:[y.jsx("span",{className:"caps inline-flex h-5 items-center border border-wf-tool/[.6] bg-wf-tool/[.12] px-1.5 text-micro leading-none text-wf-tool",children:"tool"}),y.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",title:t.tool,children:uy(t.tool)}),vi(t.tool)&&y.jsx(cy,{}),y.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:t.endedAt?Ko(kd(t.startedAt,t.endedAt)):""}),y.jsx(Qt,{tone:g,children:t.status})]}),y.jsxs("div",{className:"space-y-3 px-4 py-3",children:[i?y.jsxs("p",{className:"break-all font-mono text-label",children:[y.jsx("span",{className:"caps mr-2 text-micro text-muted-foreground",children:"Input"}),JSON.stringify(t.input)]}):y.jsxs("div",{children:[y.jsx("p",{className:"caps mb-1 text-micro text-muted-foreground",children:"Input"}),y.jsx(ta,{value:t.input,small:!0})]}),h&&y.jsx("p",{className:"font-mono text-small text-destructive-text",children:h}),!!((w=d==null?void 0:d.pages)!=null&&w.length)&&y.jsx("div",{className:"flex flex-wrap gap-3",children:d.pages.map(x=>a?y.jsxs("span",{className:"border px-2 py-1 font-mono text-label text-muted-foreground",children:["Page ",x.page]},x.page):y.jsx("button",{type:"button",className:"block border bg-white hover:border-foreground",onClick:()=>o(r(x.image)),"aria-label":`Open page ${x.page}`,children:y.jsx("img",{src:r(x.image),alt:`Page ${x.page}`,className:"block h-[124px] w-[96px] object-cover object-top",loading:"lazy"})},x.page))}),f&&!h&&y.jsxs("details",{className:"group",children:[y.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 text-micro text-muted-foreground hover:text-foreground",children:[y.jsx(Lr,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Output"]}),y.jsx(ta,{value:u,small:!0})]}),!f&&!h&&y.jsx("p",{className:"font-mono text-small text-muted-foreground",children:t.status==="stopped"?"Stopped before it answered.":m?"Running…":"Finished with no output."})]})]})}function BE({workflow:t,path:r,kind:o}){const i=Ig(t,r);if(!i)return null;const a=Object.fromEntries(Object.entries(i).map(([u,f])=>[u,(u==="steps"||u==="branches"&&o==="parallel")&&Array.isArray(f)?`… ${tS(f.length)}`:u==="body"?"… its body":u==="branches"&&o==="route"&&f&&typeof f=="object"?Object.fromEntries(Object.entries(f).map(([d,m])=>[d,(m==null?void 0:m.criteria)??"…"])):f]));return y.jsxs("details",{className:"group border",children:[y.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 px-4 py-2.5 text-label text-muted-foreground hover:text-foreground",children:[y.jsx(Lr,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Definition ",y.jsx("span",{className:"normal-case tracking-normal",children:r})]}),y.jsx(ta,{value:a})]})}function ta({value:t,small:r}){return y.jsx("pre",{className:Ce("overflow-auto whitespace-pre-wrap break-words border-t bg-background px-4 py-3 font-mono leading-[1.6]",r?"max-h-48 border text-label":"max-h-80 text-small"),children:JSON.stringify(t,null,2)})}function HE({src:t,onClose:r}){return y.jsx(ag,{open:!0,onClose:r,title:"Page image",size:"full",children:y.jsx("img",{src:t,alt:"Page",className:"mx-auto max-h-full max-w-full border bg-white"})})}const GE=t=>[400,401,403,404,405,410,422].includes((t==null?void 0:t.status)??0);function GN(t,{everyMs:r=1e3,key:o="",enabled:i=!0}={}){const[a,u]=O.useState(null),[f,d]=O.useState(null),[m,h]=O.useState(0),[g,w]=O.useState(0),x=O.useRef(t);return x.current=t,O.useEffect(()=>{if(!i)return;const k=new AbortController;let b;const C=async()=>{try{const j=Date.now(),P=await x.current(k.signal);if(k.signal.aborted||(u(P),d(null),h(j),ha(P.run.status)))return}catch(j){if(k.signal.aborted)return;d(j);const P=j;if(P.retryable){b=setTimeout(C,Math.min(r,P.retryAfterMs??500));return}if(GE(j))return}b=setTimeout(C,r)};return C(),()=>{k.abort(),clearTimeout(b)}},[o,r,g,i]),{data:a,error:f,readAt:m,reload:()=>w(k=>k+1)}}function qN({data:t,actions:r={},fileUrl:o,initial:i=null,lastRead:a,shared:u=!1}){const[f,d]=O.useState(i),m=O.useMemo(()=>ab(t,f),[t,f]),h=ha(t.run.status),[g,w]=O.useState(()=>Date.now()),x=O.useMemo(()=>Date.now(),[t]);return O.useEffect(()=>{if(h||t.run.paused)return;const k=setInterval(()=>w(Date.now()),1e3);return()=>clearInterval(k)},[h,t.run.paused]),y.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[y.jsx(qE,{data:t,readAt:x,now:g,actions:r,stale:!h&&a&&g-a>5e3?Math.max(1e3,g-a):0}),t.run.paused&&y.jsx("p",{className:"border-b border-warning/40 bg-warning/10 px-5 py-2 font-mono text-small text-warning-text md:px-8",role:"status",children:"Paused. Calls already in flight finish; no new node starts until you resume. The run keeps its place across a restart."}),y.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[y.jsx("div",{className:"min-h-[320px] min-w-0 flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px]",children:y.jsxs("div",{className:"px-5 py-6 md:px-8",children:[t.run.withheld&&y.jsx("p",{className:"mb-4 border p-4 font-mono text-body text-muted-foreground",role:"status",children:"This run's agent and revision are withheld: a saved secret is split across them, so neither is shown."}),t.graph.withheld&&y.jsx("p",{className:"mb-4 border p-4 font-mono text-body text-muted-foreground",role:"status",children:"This run's workflow graph is withheld: a saved secret is split across two of its words, so none of them is shown."}),typeof t.nodes=="string"&&y.jsx("p",{className:"mb-4 border p-4 font-mono text-body text-muted-foreground",role:"status",children:"This run's node states are withheld: a saved secret is split across them, so none is shown."}),y.jsx(sS,{graph:t.graph,marks:m,onSelect:k=>d(b=>b&&b.path===k.path&&(b.item??null)===k.item?null:k),label:"The run's workflow graph"})]})}),f&&y.jsx("div",{className:"flex min-h-0 shrink-0 flex-col border-t lg:w-[460px] lg:border-l lg:border-t-0",children:y.jsx(LE,{data:t,selected:f,onSelect:d,onClose:()=>d(null),fileUrl:o,shared:u})})]}),y.jsx("div",{className:"border-t px-5 py-2 md:px-8",children:y.jsx(iS,{run:!0})})]})}function qE({data:t,readAt:r,now:o,actions:i,stale:a}){const u=ha(t.run.status),f=t.graph.nodes.find(w=>{var x,k;return w.kind==="map"&&((k=(x=t.nodes[w.path])==null?void 0:x.items)==null?void 0:k.length)}),d=f?Ug(t.nodes[f.path].items):null,{usd:m,unknown:h}=db(t),g=[["Elapsed",Gh(fb(t,r,o))],["Cost",y.jsxs(y.Fragment,{children:[yi(m),h>0&&y.jsxs("span",{className:"text-label font-normal text-muted-foreground",children:[" + ",h," unknown"]})]}),"Decisions and model calls, as the providers priced them"],["Decisions",t.totals.decisions],["Tool calls",t.totals.effects],["Agents",QE(t),"Agent loops this run started. Decision models and tools answer one call each; none of them is an agent."]];return d&&g.push(["Items",y.jsxs(y.Fragment,{children:[y.jsx("span",{children:d.done}),y.jsxs("span",{className:"text-muted-foreground",children:["/",d.total]}),d.failed>0&&y.jsxs("span",{className:"ml-2 text-label text-destructive-text",children:[d.failed," failed"]}),d.review>0&&y.jsxs("span",{className:"ml-2 text-label text-warning-text",children:[d.review," review"]})]})]),y.jsxs("div",{className:"flex flex-wrap items-stretch border-b",children:[t.run.paused&&y.jsx("div",{className:"flex items-center pl-5 md:pl-8",children:y.jsxs(Qt,{tone:"warning",children:[y.jsx(bc,{className:"size-3","aria-hidden":!0})," Paused"]})}),g.map(([w,x,k],b)=>y.jsxs("div",{className:Ce("px-4 py-2",b?"border-l":"pl-5 md:pl-8"),title:k,children:[y.jsx("p",{className:"caps text-micro text-muted-foreground",children:w}),y.jsx("p",{className:"font-mono text-prose font-semibold tabular-nums",children:x})]},w)),y.jsxs("div",{className:"flex flex-1 items-center justify-end gap-3 px-5 py-2 md:px-8",children:[a>0&&y.jsxs("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:["Last read ",Gh(a)," ago, reading again"]}),!u&&(t.run.paused?y.jsxs(Kn,{size:"sm",variant:"solid",onClick:i.onResume,disabled:!i.onResume||!!i.busy,children:[y.jsx(_w,{"aria-hidden":!0})," ",i.busy==="resume"?"Resuming":"Resume"]}):y.jsxs(Kn,{size:"sm",onClick:i.onPause,disabled:!i.onPause||!!i.busy,title:"Calls in flight finish; no new node starts.",children:[y.jsx(bc,{"aria-hidden":!0})," ",i.busy==="pause"?"Pausing":"Pause"]}))]})]})}const VE=new Set(["agent","decide","extract","report","artifact"]),QE=t=>t.graph.nodes.filter(r=>{var o;return VE.has(r.kind)&&!["pending","not_run"].includes(((o=t.nodes[r.path])==null?void 0:o.status)??"pending")}).length;function VN({error:t}){const r=t==null?void 0:t.status;return y.jsx("p",{className:Ce("m-8 border p-4 font-mono text-body",r===404?"text-muted-foreground":"text-destructive-text"),role:"status",children:t==null?"Reading the run's graph...":r===404?"This server does not give run graphs: GET /v2/runs/{id}/graph is not there.":`The run's graph could not be read: ${t.message??String(t)}`})}const QN=["system","light","dark"],Uc="agentrun.theme",KE="(prefers-color-scheme: dark)",va=()=>{try{return globalThis.localStorage??null}catch{return null}},fy=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(KE):null;let Wc=null;function YE(t=va()){try{const r=t==null?void 0:t.getItem(Uc);return r==="light"||r==="dark"?r:"system"}catch{return"system"}}const fm=(t=va())=>Wc??YE(t);function KN(t,r=va()){Wc=null;try{t==="system"?r==null||r.removeItem(Uc):r==null||r.setItem(Uc,t)}catch{Wc=t}}function pm(t,r=document.documentElement,o=fy()){const i=t==="dark"||t==="system"&&!!(o!=null&&o.matches);r.classList.toggle("dark",i),r.classList.toggle("light",!i)}function YN(t=document.documentElement,r=fy(),o=va()){pm(fm(o),t,r);const i=()=>{fm(o)==="system"&&pm("system",t,r)};return r==null||r.addEventListener("change",i),()=>r==null?void 0:r.removeEventListener("change",i)}export{Lm as $,Yn as A,l0 as B,qm as C,qc as D,r_ as E,s_ as F,ce as G,Gc as H,la as I,fn as J,en as K,o_ as L,Jx as M,k0 as N,g0 as O,Zx as P,x0 as Q,z0 as R,Fm as S,Wx as T,co as U,e_ as V,u0 as W,N0 as X,jt as Y,Hl as Z,$r as _,hx as a,h_ as a$,vh as a0,a_ as a1,r0 as a2,Wm as a3,u_ as a4,qn as a5,y as a6,Ce as a7,hw as a8,Qt as a9,tS as aA,DN as aB,ib as aC,sN as aD,bc as aE,Lr as aF,V_ as aG,sS as aH,iS as aI,xw as aJ,ai as aK,rN as aL,Tw as aM,tw as aN,jg as aO,Sb as aP,L1 as aQ,K_ as aR,ad as aS,yw as aT,vm as aU,LN as aV,$b as aW,MN as aX,xN as aY,AN as aZ,p_ as a_,Bc as aa,wm as ab,gw as ac,nh as ad,xm as ae,px as af,Kn as ag,vw as ah,$w as ai,Y1 as aj,oN as ak,dx as al,Q_ as am,_w as an,f_ as ao,c_ as ap,ag as aq,qo as ar,F1 as as,gN as at,yN as au,ha as av,V1 as aw,q1 as ax,Gh as ay,tb as az,n_ as b,kN as b$,Ag as b0,eN as b1,Ew as b2,NN as b3,_N as b4,EN as b5,kw as b6,iN as b7,aN as b8,cN as b9,P_ as bA,R_ as bB,O_ as bC,L_ as bD,__ as bE,T_ as bF,G_ as bG,D_ as bH,F_ as bI,M_ as bJ,I_ as bK,z_ as bL,A_ as bM,T1 as bN,$_ as bO,j_ as bP,U_ as bQ,W_ as bR,B_ as bS,ym as bT,FN as bU,d_ as bV,q_ as bW,TN as bX,CN as bY,Eb as bZ,qh as b_,uN as ba,lN as bb,ON as bc,IN as bd,jb as be,PN as bf,zN as bg,RN as bh,Sk as bi,bk as bj,rh as bk,pw as bl,od as bm,b_ as bn,dN as bo,S_ as bp,g_ as bq,k_ as br,E_ as bs,Kg as bt,y_ as bu,x_ as bv,w_ as bw,m_ as bx,v_ as by,H_ as bz,Oe as c,SN as c0,_g as c1,kk as c2,Cw as c3,xb as c4,mb as c5,Lg as c6,nN as c7,Z_ as c8,fw as c9,qN as cA,fm as cB,QN as cC,KN as cD,pm as cE,N_ as cF,C_ as cG,bN as cH,$N as cI,YN as cJ,ZE as cK,ao as cL,jN as ca,tN as cb,J_ as cc,X_ as cd,mN as ce,pN as cf,hN as cg,Pg as ch,Wh as ci,Y_ as cj,K1 as ck,WN as cl,BN as cm,fN as cn,vN as co,vb as cp,UN as cq,cm as cr,hb as cs,HN as ct,wN as cu,GN as cv,GE as cw,db as cx,yi as cy,VN as cz,xx as d,pi as e,_c as f,t_ as g,Ax as h,$n as i,Rl as j,Tx as k,fi as l,ro as m,$t as n,Me as o,oa as p,Ar as q,O as r,Gl as s,Gm as t,vx as u,Yp as v,Nn as w,Dm as x,jn as y,Gx as z};
291
+ `).filter(a=>a.trim()).length>1?"…":"";return t.kind==="final_answer"?!r.trim()&&!((i=t.text)!=null&&i.trim())?hb:`${r.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"")}${o}`:t.kind==="user_message"?`${r}${o}`:r},di=t=>t<1e3?`${t} ms`:`${(t/1e3).toFixed(1)} s`,EE=new Set(SS),_E=new Map(Object.entries({read:"Read",write:"Write",edit:"Edit",multiedit:"Edit",apply_patch:"Edit",notebookedit:"Edit",bash:"Shell",shell:"Shell",local_shell:"Shell",exec_command:"Shell",web_fetch:"Fetch",webfetch:"Fetch",fetch:"Fetch",web_search:"Search",websearch:"Search",ls:"List files",glob:"Find files",find:"Find files",grep:"Search files",ask_person:"Question",submit:"Answer",codemode:"Script",todowrite:"To-dos",task:"Subagent",skill:"Skill"}));function NE(t){const r=_E.get(t.toLowerCase());if(r)return r;const o=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return o?o[0].toUpperCase()+o.slice(1):t}const um=t=>t&&(Tb(t)??(EE.has(t)?lE(t):NE(t))),Dc=t=>vd(t)?"AgentRun":ny(t)?ry(t).who??"Trigger":kE(t)?"Your grade":{user_message:"You",thinking:"Thinking",tool_use:um(t.tool_name)??"Tool",tool_result:um(t.tool_name)??"Result",waiting:"Waiting for you",usage:"Usage",final_answer:"Answer",phase:"Phase",error:"Error",decision:"Decision",text_block:"Text",tool_approval_requested:"Your approval",learning:"Learning"}[t.kind]??t.kind,WN=t=>Dc(t);function BN({row:t}){return ea(oy(t))}const CE={budget:"Paused at cap"};function TE({step:t,last:r,ended:o,waitingChip:i,files:a,onOpen:u,shared:f}){var j,P;const d=t.row,[m,h]=O.useState(!1),w=Q1(d)?gm:bE[d.kind]??ym,x=t.above?d.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":oy(d),k=t.above?null:t.detail??q1(d),b=k&&k.trim()!==x.trim()?k:null,C=V1(d);return y.jsxs("li",{className:"relative flex gap-3",children:[y.jsxs("div",{className:"flex w-7 shrink-0 flex-col items-center",children:[y.jsx("span",{className:Ce("mt-3 flex size-7 items-center justify-center border bg-background",(d.kind==="waiting"||am(d))&&"border-warning/60 text-warning-text",C&&"border-destructive/60 text-destructive-text"),children:y.jsx(w,{className:"size-3.5","aria-hidden":!0})}),!r&&y.jsx("span",{className:"w-px flex-1 bg-border","aria-hidden":!0})]}),y.jsxs("div",{className:"min-w-0 flex-1 border-b py-3",children:[y.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:()=>h(F=>!F),"aria-expanded":m,disabled:!b,children:[y.jsxs("span",{className:"min-w-0 flex-1",children:[y.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-body text-muted-foreground",children:[y.jsx("span",{"data-label":!0,className:"min-w-0 truncate",title:Dc(d),children:Dc(d)}),(d.kind==="tool_use"||d.kind==="tool_result")&&d.usage&&y.jsxs("span",{className:"font-mono text-label",children:["· ",D1(d.usage,{ended:o})]}),d.kind==="waiting"&&y.jsx(Qt,{tone:"warning",children:i??"Input required"}),am(d)&&y.jsx(Qt,{tone:"warning",children:"Approval required"}),C&&y.jsx(Qt,{tone:"error",children:"Error"}),Mg(d)&&y.jsx(Qt,{tone:"muted",title:d.tool_name==="codemode"?"Refused before it started, or stopped at a refused call: the calls under it say which ran":"Not run: refused before it ran",children:"Refused"}),d.agent_label&&y.jsx(Qt,{label:!0,title:d.agent_label,children:d.agent_label}),t.ms!==void 0&&y.jsx("span",{className:"font-mono text-label",children:di(t.ms)}),t.times&&y.jsxs("span",{className:"font-mono text-label",children:[t.times," times",t.until?` over ${di(Math.max(0,Date.parse(t.until)-Date.parse(d.timestamp)))}`:""]})]}),y.jsx("span",{className:Ce("mt-0.5 block break-words text-prose leading-snug",vd(d)&&"text-muted-foreground"),children:ea(x)}),t.saved&&y.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",t.saved]}),lm(d)&&y.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:lm(d)})]}),y.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:L1(d.timestamp)}),b&&y.jsx(Lr,{className:Ce("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",m&&"rotate-90"),"aria-hidden":!0})]}),m&&b&&d.tool_name&&y.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:d.tool_name}),m&&b&&d.kind==="final_answer"&&y.jsx("article",{className:"report mt-3 max-h-80 max-w-none overflow-auto border bg-card p-3",onClick:Pg(F=>{const R=a==null?void 0:a.find(M=>M.path===F);R&&(u==null||u(R))}),dangerouslySetInnerHTML:{__html:ai(b,u&&a?{paths:a.map(F=>F.path),...f?{images:!1}:{}}:f?{paths:[],images:!1}:void 0)}}),m&&b&&d.kind!=="final_answer"&&y.jsx("pre",{className:"mt-3 max-h-80 overflow-auto whitespace-pre-wrap break-words border bg-card p-3 font-mono text-small leading-[1.7]",children:y.jsx(ao,{text:b})}),(j=d.learned_nodes)!=null&&j.length?y.jsx(AE,{nodes:d.learned_nodes}):null,(P=d.computer_calls)!=null&&P.length?y.jsx($E,{calls:d.computer_calls,dropped:d.computer_calls_dropped??0}):null]})]})}function $E({calls:t,dropped:r}){const[o,i]=O.useState(!1),a=t.filter(m=>!m.ok).length,u=t.length+r,f=[`${u} computer ${u===1?"call":"calls"}`,...a?[`${a} failed`]:[]].join(" · "),d=Date.parse(t[0].started_at);return y.jsxs("div",{className:"mt-2",children:[y.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>i(m=>!m),"aria-expanded":o,"aria-label":`${o?"Hide":"Show"} the computer calls`,children:[y.jsx(Lr,{className:Ce("size-3 transition-transform",o&&"rotate-90"),"aria-hidden":!0}),y.jsx(Ew,{className:"size-3","aria-hidden":!0}),f]}),o&&y.jsxs("ol",{"aria-label":"The computer calls",className:"mt-2 divide-y border bg-card",children:[t.map((m,h)=>y.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[y.jsxs("span",{className:"w-14 shrink-0 font-mono text-label text-muted-foreground",children:["+",di(Math.max(0,Date.parse(m.started_at)-d))]}),y.jsx("span",{className:Ce("min-w-0 flex-1 truncate text-body",!m.ok&&"text-destructive-text"),title:_n(m),children:_n(m)}),!m.ok&&m.code&&y.jsx("span",{className:"shrink-0 font-mono text-label text-destructive-text",children:m.code}),y.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:di(m.ms)})]},h)),r>0&&y.jsxs("li",{className:"px-3 py-1.5 text-body text-muted-foreground",children:[r," more not kept"]})]})]})}const jE={ok:"success",failed:"error",escalated:"warning"};function AE({nodes:t}){const[r,o]=O.useState(!1),i=Object.entries(t.reduce((u,f)=>({...u,[f.status]:(u[f.status]??0)+1}),{})).filter(([u])=>u!=="ok"),a=[`${t.length} ${t.length===1?"node":"nodes"}`,...i.map(([u,f])=>`${f} ${u}`)].join(" · ");return y.jsxs("div",{className:"mt-2",children:[y.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>o(u=>!u),"aria-expanded":r,"aria-label":`${r?"Hide":"Show"} the workflow's ${t.length===1?"node":"nodes"}`,children:[y.jsx(Lr,{className:Ce("size-3 transition-transform",r&&"rotate-90"),"aria-hidden":!0}),y.jsx($w,{className:"size-3","aria-hidden":!0}),a]}),r&&y.jsx("ol",{"aria-label":"The workflow's nodes",className:"mt-2 divide-y border bg-card",children:t.map((u,f)=>y.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[y.jsx("span",{"data-status":u.status,className:"contents",children:y.jsx(Qt,{tone:jE[u.status]??"muted",className:"w-[5.5rem] justify-center",children:u.status})}),y.jsx("span",{className:"min-w-0 flex-1 truncate text-body",title:u.label,children:u.label}),y.jsx("span",{"data-kind":!0,className:"font-mono text-label text-muted-foreground",title:Hg(u)||void 0,children:ud(u.kind,u)}),y.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:di(u.duration_ms)})]},f))})]})}function HN({rows:t,live:r,fold:o=6,asking:i,waitingOn:a,files:u,onOpen:f,ended:d=!1,shared:m=!1}){var j;const h=a==="budget"?t.findLastIndex(P=>P.paused===!0):-1,g=h>=0?(j=t.slice(h+1).findLast(P=>P.kind==="waiting"))==null?void 0:j.id:void 0,[w,x]=O.useState(!1),k=K1(t).map(P=>i&&P.row.id===i?{...P,above:!0}:P),b=w?0:Math.max(0,k.length-o),C=k.slice(b);return t.length?y.jsxs("div",{children:[b>0&&y.jsxs("button",{type:"button",className:"caps mb-1 ml-10 flex items-center gap-1 py-2 text-label text-muted-foreground hover:text-foreground",onClick:()=>x(!0),children:[y.jsx(Lr,{className:"size-3","aria-hidden":!0})," ",b," earlier ",b===1?"step":"steps"]}),y.jsx("ol",{children:C.map((P,F)=>y.jsx(TE,{step:P,last:F===C.length-1&&!r,ended:d,waitingChip:P.row.id===g&&a?CE[a]:void 0,files:u,onOpen:f,shared:m},P.row.id))}),r&&y.jsx(cm,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):y.jsx(cm,{title:r?"The run is starting":"Nothing on the timeline",note:r?"Steps appear here as the agent works.":"This run recorded no steps.",spin:r})}function cm({title:t,note:r,spin:o=!0}){return y.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-center",children:[o&&y.jsx(kk,{className:"size-5"}),y.jsx("p",{className:"caps text-label font-semibold",children:t}),y.jsx("p",{className:"max-w-sm text-body text-muted-foreground",children:r})]})}const sy=new Set(["chain","parallel","route","map","loop","workflow"]),RE={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},OE=t=>t==="review"?"needs review":t.replace("-"," ");function wd({state:t}){const r=Xl(t)??"pending";return y.jsx(Qt,{tone:RE[r]??"plain",className:"whitespace-nowrap",children:OE(r)})}function xd({provider:t}){if(!t)return null;const r=t==="parallel"?"--wf-parallel":t==="openrouter"?"--wf-openrouter":"--wf-jev";return y.jsx("span",{className:"caps inline-flex h-5 items-center border px-1.5 text-micro leading-none",style:{color:`hsl(var(${r}))`,borderColor:`hsl(var(${r}) / .6)`,background:`hsl(var(${r}) / .12)`},children:t})}const iy={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},kd=(t,r)=>t&&r?Date.parse(r)-Date.parse(t):void 0;function LE({data:t,selected:r,onSelect:o,onClose:i,fileUrl:a,shared:u=!1}){var P,F,R,M,G,Y;const f=t.graph.nodes.find(V=>V.path===r.path),[d,m]=O.useState(null);if(!f)return null;const h=t.nodes[f.path],g=id(t.workflow,f.path,f),w=f.kind==="map"?f.path:(P=t.graph.nodes.find(V=>V.kind==="map"&&f.path.startsWith(`${V.path}/body/`)))==null?void 0:P.path,x=r.item!=null&&w?(R=(F=t.nodes[w])==null?void 0:F.items)==null?void 0:R.find(V=>V.index===r.item):void 0,k=t.decisions.filter(V=>V.node===f.path),b=t.effects.filter(V=>V.node===f.path),C=!!w&&f.kind!=="map",j=kd(h==null?void 0:h.startedAt,h==null?void 0:h.endedAt);return y.jsxs("aside",{className:"flex min-h-0 flex-col bg-background","aria-label":"Node details",children:[y.jsxs("header",{className:"border-b px-5 py-4",children:[y.jsxs("div",{className:"flex items-start gap-3",children:[y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsxs("p",{className:"caps flex items-center gap-1.5 text-label text-muted-foreground",children:[g.decision?f.kind:ud(f.kind,h),g.tool?` · ${uy(g.tool)}`:f.via?` · ${f.via}`:"",g.tool&&vi(g.tool)&&y.jsx(cy,{}),x&&y.jsxs(y.Fragment,{children:[y.jsx(Lr,{className:"size-3","aria-hidden":!0})," item ",x.index+1]})]}),y.jsx("h2",{className:"mt-1 break-words font-mono text-lg font-semibold leading-tight",children:x?ui(t,w,x.index)??`Item ${x.index+1}`:f.label}),y.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[y.jsx(wd,{state:x?x.status:h==null?void 0:h.status}),x&&(()=>{const V=ld(t,w,x);return V.outcome?y.jsxs("span",{className:"font-mono text-label",title:V.pNote,children:["outcome ",y.jsx("b",{className:iy[V.tone??""],children:V.outcome}),V.p!==void 0&&y.jsxs("span",{className:"text-muted-foreground",children:[" · ",Zt(V.p)]})]}):null})(),g.decision&&y.jsx(xd,{provider:g.provider}),g.decision&&((h==null?void 0:h.model)??g.model)&&y.jsx("span",{className:"font-mono text-label text-muted-foreground",children:(h==null?void 0:h.model)??g.model}),(h==null?void 0:h.branch)&&y.jsxs("span",{className:"font-mono text-label",children:["took ",y.jsx("b",{children:h.branch})]}),!x&&j!==void 0&&y.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Ko(j)})]})]}),y.jsx(Kn,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:i,children:y.jsx(xm,{"aria-hidden":!0})})]}),x&&y.jsxs("button",{type:"button",className:"caps mt-3 text-label text-muted-foreground hover:text-foreground",onClick:()=>o({path:w,item:null}),children:["All ",(G=(M=t.nodes[w])==null?void 0:M.items)==null?void 0:G.length," items of ",(Y=t.graph.nodes.find(V=>V.path===w))==null?void 0:Y.label]})]}),y.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-auto px-5 py-5",children:[x?y.jsx(zE,{data:t,mapPath:w,index:x.index,status:x.status,fileUrl:a,zoom:m,shared:u}):f.kind==="map"?y.jsx(PE,{data:t,mapPath:f.path,onSelect:o}):C&&(k.length||b.length)?y.jsx(ME,{data:t,path:f.path,mapPath:w,onSelect:o}):y.jsxs(y.Fragment,{children:[f.kind==="parallel"&&y.jsx(IE,{data:t,path:f.path,onSelect:o}),k.map((V,fe)=>y.jsx(ay,{d:V,fileUrl:a,zoom:m,shared:u},V.id??fe)),b.map((V,fe)=>y.jsx(dy,{e:V,fileUrl:a,zoom:m,shared:u},fe)),!k.length&&!b.length&&f.kind!=="parallel"&&y.jsx(ly,{kind:f.kind,status:h==null?void 0:h.status,meta:g})]}),y.jsx(BE,{workflow:t.workflow,path:f.path,kind:f.kind})]}),d&&y.jsx(HE,{src:d,onClose:()=>m(null)})]})}function ly({kind:t,status:r,meta:o}){const i=o.decision?r==="working"?"Asking now. The verdict shows here when the answer comes back.":"Not asked yet.":t==="code"?"A code node: a pure transform of the run's state. It calls nothing, so it leaves no record of its own.":t==="route"?"Routed by a value already in the state: no model was asked.":sy.has(t)?"Its nodes are drawn inside it. Pick one to see what it did.":"Nothing recorded yet.";return y.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:i})}function PE({data:t,mapPath:r,onSelect:o}){var u;const i=((u=t.nodes[r])==null?void 0:u.items)??[],a=Ug(i);return y.jsxs("section",{children:[y.jsx("div",{className:"mb-3 grid grid-cols-5 border",children:[["Items",a.total],["Done",a.done],["Working",a.working],["Review",a.review],["Failed",a.failed]].map(([f,d])=>y.jsxs("div",{className:"border-r px-3 py-2 last:border-r-0",children:[y.jsx("p",{className:"caps text-micro text-muted-foreground",children:f}),y.jsx("p",{className:"font-mono text-lg font-semibold tabular-nums",children:d})]},f))}),y.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[y.jsx("thead",{children:y.jsxs("tr",{className:"caps text-left text-micro text-muted-foreground",children:[y.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"#"}),y.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Item"}),y.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"State"}),y.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Verdict"}),y.jsx("th",{className:"border-b py-1.5 text-right font-normal",children:"Cost"})]})}),y.jsx("tbody",{children:i.map(f=>{const d=t.decisions.filter(g=>{var w;return g.item===f.index&&!!((w=g.node)!=null&&w.startsWith(`${r}/body`))}),m=ld(t,r,f),h=d.length?d.some(g=>g.cost_usd===null)?null:d.reduce((g,w)=>g+(w.cost_usd??0),0):void 0;return y.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>o({path:r,item:f.index}),children:[y.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:f.index+1}),y.jsx("td",{className:"max-w-[140px] truncate border-b py-1.5 pr-2",title:ui(t,r,f.index),children:ui(t,r,f.index)??"—"}),y.jsx("td",{className:"border-b py-1.5 pr-2",children:y.jsx(wd,{state:f.status})}),y.jsx("td",{className:"max-w-[150px] truncate whitespace-nowrap border-b py-1.5 pr-2",title:[m.pNote,...d.map(g=>Zo(g))].filter(Boolean).join(", "),children:m.outcome?y.jsxs(y.Fragment,{children:[y.jsx("span",{className:Ce("font-semibold",iy[m.tone??""]),children:m.outcome}),m.p!==void 0&&y.jsx("span",{className:"ml-2 tabular-nums text-muted-foreground",children:Zt(m.p)})]}):d.map(g=>Zo(g)).filter(Boolean).join(", ")||y.jsx("span",{className:"text-muted-foreground",children:"—"})}),y.jsx("td",{className:"border-b py-1.5 text-right tabular-nums",children:h===void 0?y.jsx("span",{className:"text-muted-foreground",children:"—"}):yi(h)})]},f.index)})})]})]})}function ME({data:t,path:r,mapPath:o,onSelect:i}){var g;const a=t.decisions.filter(w=>w.node===r),u=t.effects.filter(w=>w.node===r),f=(((g=t.nodes[o])==null?void 0:g.items)??[]).map(w=>({it:w,d:a.find(x=>x.item===w.index),e:u.find(x=>x.item===w.index)})).filter(w=>w.d||w.e),d=a.filter(w=>w.cost_usd!==null),m=a.filter(w=>w.latency_ms!==null),h=m.length?m.reduce((w,x)=>w+(x.latency_ms??0),0)/m.length:void 0;return y.jsxs("section",{children:[a.length>0&&y.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[a.length," asked · ",yi(d.reduce((w,x)=>w+(x.cost_usd??0),0)),d.length<a.length?` + ${a.length-d.length} unknown`:""," · mean ",Ko(h)]}),y.jsx("table",{className:"w-full border-collapse font-mono text-small",children:y.jsx("tbody",{children:f.map(({it:w,d:x,e:k})=>y.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>i({path:o,item:w.index}),children:[y.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:w.index+1}),y.jsx("td",{className:"max-w-[150px] truncate border-b py-1.5 pr-2",children:ui(t,o,w.index)}),y.jsx("td",{className:"border-b py-1.5 pr-2",children:x?Zo(x):k?y.jsx(wd,{state:k.status}):null}),y.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:x?Ko(x.latency_ms):k?Ko(kd(k.startedAt,k.endedAt)):""})]},w.index))})})]})}function IE({data:t,path:r,onSelect:o}){var x,k;const i=`${r}/branches/`,a=t.decisions.filter(b=>{var C;return((C=b.node)==null?void 0:C.startsWith(i))&&/^\d+$/.test(b.node.slice(i.length))&&b.item===null}),u=new Set(a.flatMap(b=>Object.keys(b.answers??{}))),[f]=[...u],d=a.map(b=>{var C;return{d:b,a:(C=b.answers)==null?void 0:C[f]}}).filter(b=>{var C;return((C=b.a)==null?void 0:C.type)==="noul"});if(u.size!==1||d.length<2)return y.jsx(ly,{kind:"parallel",meta:{decision:!1}});const m=d.map(b=>b.a.noul),h=m.reduce((b,C)=>b+C,0)/m.length,g=Math.max(...m)-Math.min(...m),w=b=>{var C;return((C=t.graph.nodes.find(j=>j.path===b.node))==null?void 0:C.label)??b.node};return y.jsxs("section",{className:"border bg-card",children:[y.jsxs("header",{className:"border-b px-4 py-2.5",children:[y.jsxs("p",{className:"caps text-micro text-muted-foreground",children:["Jury · ",d.length," models · ",f]}),y.jsx("p",{className:"mt-1 text-body leading-snug",children:((k=(x=a[0].questions)==null?void 0:x[f])==null?void 0:k.instructions)??f})]}),y.jsx("ul",{className:"divide-y",children:d.map(({d:b,a:C})=>y.jsx("li",{children:y.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-2 text-left font-mono text-small hover:bg-accent",onClick:()=>o({path:b.node,item:null}),children:[y.jsx("span",{className:"w-[92px] shrink-0",children:y.jsx(xd,{provider:b.provider})}),y.jsx("span",{className:"w-[132px] shrink-0 truncate",title:b.model??"",children:b.model??w(b)}),y.jsx(Fc,{p:C.noul,strong:!0,tick:.5,tone:C.noul>=.5?"fg":"muted"}),y.jsx("span",{className:"w-10 text-right tabular-nums",children:Zt(C.noul)})]})},b.id??b.executionPath))}),y.jsxs("dl",{className:"grid grid-cols-3 border-t font-mono text-small",children:[y.jsxs("div",{className:"border-r px-4 py-2",children:[y.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Mean P(yes)"}),y.jsx("dd",{className:"font-semibold tabular-nums",children:Zt(h)})]}),y.jsxs("div",{className:"border-r px-4 py-2",children:[y.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Spread"}),y.jsx("dd",{className:Ce("font-semibold tabular-nums",g>.3&&"text-warning-text"),children:Zt(g)})]}),y.jsxs("div",{className:"px-4 py-2",children:[y.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),y.jsx("dd",{className:"tabular-nums",children:yi(d.some(b=>b.d.cost_usd===null)?null:d.reduce((b,C)=>b+(C.d.cost_usd??0),0))})]})]})]})}function zE({data:t,mapPath:r,index:o,status:i,fileUrl:a,zoom:u,shared:f=!1}){const m=t.graph.nodes.filter(h=>h.path.startsWith(`${r}/body`)).map(h=>({n:h,ds:t.decisions.filter(g=>g.node===h.path&&g.item===o),es:t.effects.filter(g=>g.node===h.path&&g.item===o)})).filter(h=>!sy.has(h.n.kind)||h.ds.length||h.es.length);return i==="pending"?y.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"Not started: this item waits for a free slot in the map."}):y.jsxs("div",{className:"space-y-5",children:[m.map(({n:h,ds:g,es:w})=>g.length||w.length?y.jsxs("div",{className:"space-y-3",children:[y.jsx("p",{className:"caps text-label text-muted-foreground",children:h.label}),w.map((x,k)=>y.jsx(dy,{e:x,fileUrl:a,zoom:u,compact:!0,shared:f},k)),g.map((x,k)=>y.jsx(ay,{d:x,fileUrl:a,zoom:u,shared:f},x.id??k))]},h.path):null),i==="working"&&!m.some(h=>h.ds.length)&&y.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"In flight: the verdict shows here when it comes back."})]})}const dm=t=>`${Math.round(t*100)}%`,Zt=t=>t.toFixed(2);function Fc({p:t,strong:r,tick:o,tone:i="fg"}){const a={fg:"bg-foreground",success:"bg-success",warning:"bg-warning",muted:"bg-muted-foreground/50"}[i];return y.jsxs("span",{className:"relative block h-2 flex-1 bg-muted",children:[y.jsx("span",{className:Ce("absolute inset-y-0 left-0 transition-[width] duration-slow",r?a:"bg-muted-foreground/45"),style:{width:dm(Math.max(0,Math.min(1,t)))}}),o!==void 0&&y.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:dm(o)},title:`threshold ${Zt(o)}`})]})}function DE({id:t,q:r,a:o,rule:i}){const a=d=>{var m;return(i==null?void 0:i.kind)==="pick"&&(r==null?void 0:r.type)==="choice"&&typeof((m=r.criteria)==null?void 0:m[d])=="string"?r.criteria[d]:d},u=(r==null?void 0:r.instructions)??t,f=(i==null?void 0:i.kind)==="route"?i.unsure:null;return y.jsxs("div",{className:"py-2.5",children:[y.jsxs("p",{className:"mb-2 text-body leading-snug",children:[y.jsx("span",{className:"mr-2 font-mono text-label text-muted-foreground",children:t}),u]}),o?o.type==="refusal"?y.jsx("p",{className:"font-mono text-small text-warning-text",children:"Refused to answer."}):o.type==="noul"?y.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[y.jsx("span",{className:Ce("w-8 font-semibold",o.noul>=.5?"text-foreground":"text-muted-foreground"),children:o.noul>=.5?"YES":"NO"}),y.jsx(Fc,{p:o.noul,strong:!0,tick:.5,tone:o.noul>=.5?"fg":"muted"}),y.jsxs("span",{className:"w-24 text-right tabular-nums text-muted-foreground",children:["P(yes) ",Zt(o.noul)]})]}):o.type==="box"?y.jsxs("p",{className:"font-mono text-small",children:["box ",JSON.stringify(o.box)]}):y.jsxs("div",{className:"space-y-1.5",children:[Object.entries(o.probabilities).sort((d,m)=>m[1]-d[1]).slice(0,(i==null?void 0:i.kind)==="pick"?5:void 0).map(([d,m])=>{const h=(o.type==="choice"?o.choice:String(o.score))===d;return y.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[y.jsx("span",{className:Ce("truncate",(i==null?void 0:i.kind)==="pick"?"w-48":"w-28",h?"font-semibold":"text-muted-foreground"),title:a(d),children:o.type==="score"?`${d} ${o.legend[d]??""}`:a(d)}),y.jsx(Fc,{p:m,strong:h,tick:h&&f?f.gte:void 0}),y.jsx("span",{className:"w-12 text-right tabular-nums text-muted-foreground",children:Zt(m)})]},d)}),(i==null?void 0:i.kind)==="pick"&&Object.keys(o.probabilities).length>5&&y.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[Object.keys(o.probabilities).length-5," more options, each less likely"]})]}):y.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No answer."})]})}function FE(t){if(!t)return"No rule applied: nothing came back to decide on.";switch(t.kind){case"judge":return"Each answer is decoded on its own: a yes/no is yes at P(yes) ≥ 0.50, a choice is its top option.";case"route":return t.unsure?`Take the chosen branch; below ${Zt(t.unsure.gte)} confidence take "${t.unsure.branch}".`:"Take the chosen branch.";case"pick":return`Pick one of ${t.options.length} options${t.none?`, or "${t.none}"`:""}.`;case"ask":return`Holds when P(yes) ≥ ${Zt(t.gte)}.`;case"sift":return t.keep?`Keep an item when its ${t.keep.id} ${t.keep.measure} ≥ ${Zt(t.keep.gte)}.`:"Keep every item.";case"verify":return"A yes/no fails below its threshold."}}function UE(t){var o,i,a,u;const r=t.action;if(r==null)return t.status==="cancelled"?"None: the outcome is unknown, so it goes to review and is not asked again.":"None.";if(((o=t.rule)==null?void 0:o.kind)==="route"){const f=((a=(i=t.answers)==null?void 0:i.branch)==null?void 0:a.type)==="choice"?t.answers.branch.confidence:void 0;return r.unsure?`Took "${String(r.taken)}": "${String(r.branch)}" at ${f!==void 0?Zt(f):"?"} is below the threshold.`:`Took "${String(r.taken??r.branch)}".`}if(((u=t.rule)==null?void 0:u.kind)==="pick"&&typeof r.index=="number"){const f=t.rule.options[r.index];return r.none?`None of the options: "${t.rule.none??"none"}".`:`Picked ${f!==void 0?`"${Dg(t,Object.keys(t.questions??{})[0]??"pick",f)}"`:`option ${r.index}`}.`}return typeof r=="object"?Object.entries(r).map(([f,d])=>`${f} = ${typeof d=="object"?JSON.stringify(d):String(d)}`).join(" · "):String(r)}function ay({d:t,fileUrl:r,zoom:o,shared:i=!1}){var f,d,m;const a=Array.from(new Set([...Object.keys(t.questions??{}),...Object.keys(t.answers??{})])),u=t.status==="answered"?"success":t.status==="cancelled"?"warning":"error";return y.jsxs("section",{className:"border bg-card",children:[y.jsxs("header",{className:"flex flex-wrap items-center gap-2 border-b px-4 py-2.5",children:[y.jsx(xd,{provider:t.provider}),y.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:t.model??"default model"}),y.jsx(Qt,{tone:u,children:t.status==="cancelled"?"outcome unknown":t.status})]}),y.jsxs("dl",{className:"grid grid-cols-[minmax(0,1fr)_100px_92px] border-b font-mono text-small",children:[y.jsxs("div",{className:"border-r px-4 py-2",children:[y.jsx("dt",{className:"caps text-micro text-muted-foreground",children:Object.keys(t.answers??{}).length>1&&((f=t.rule)==null?void 0:f.kind)!=="route"?"Least sure answer":"Verdict"}),y.jsx("dd",{className:"break-words font-semibold",children:Zo(t)??"—"})]}),y.jsxs("div",{className:"border-r px-4 py-2",children:[y.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),y.jsx("dd",{className:"tabular-nums",title:t.cost_basis??void 0,children:yi(t.cost_usd)})]}),y.jsxs("div",{className:"px-4 py-2",children:[y.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Latency"}),y.jsx("dd",{className:"tabular-nums",children:Ko(t.latency_ms)})]})]}),t.error&&y.jsx("p",{className:Ce("border-b px-4 py-2.5 font-mono text-small",t.status==="cancelled"?"text-warning-text":"text-destructive-text"),children:t.error}),!!((d=t.images)!=null&&d.length)&&y.jsx("div",{className:"space-y-3 border-b px-4 py-3",children:t.images.map(h=>({img:h,src:i?void 0:h.ref&&r(h.ref)||Kg(h.url)})).filter(({src:h})=>i||h).map(({img:h,src:g})=>y.jsxs("figure",{className:"flex gap-3",children:[g&&y.jsx("button",{type:"button",className:"block shrink-0 border bg-white hover:border-foreground",onClick:()=>o(g),"aria-label":`Open ${h.ref}`,children:y.jsx("img",{src:g,alt:`The page the model saw as ${h.token}`,className:"block h-[155px] w-[120px] object-cover object-top",loading:"lazy"})}),y.jsxs("figcaption",{className:"min-w-0 flex-1 space-y-1.5 font-mono text-label",children:[y.jsx("p",{className:"caps text-micro text-muted-foreground",children:"What the model saw"}),y.jsxs("p",{children:[y.jsx("span",{className:"text-muted-foreground",children:"token "}),h.token]}),y.jsxs("p",{className:"break-all",children:[y.jsx("span",{className:"text-muted-foreground",children:"page "}),h.ref]}),h.sha256&&y.jsxs("p",{className:"break-all",title:h.sha256,children:[y.jsx("span",{className:"text-muted-foreground",children:"sha256 "}),h.sha256.slice(0,16),"…"]}),(h.mime||h.bytes)&&y.jsx("p",{className:"text-muted-foreground",children:[h.mime,h.bytes?`${Math.round(h.bytes/1024)} KB`:null].filter(Boolean).join(" · ")})]})]},h.token))}),y.jsx("div",{className:"divide-y px-4",children:a.map(h=>{var g,w;return y.jsx(DE,{id:h,q:(g=t.questions)==null?void 0:g[h],a:(w=t.answers)==null?void 0:w[h],rule:t.rule},h)})}),y.jsxs("dl",{className:"space-y-2 border-t px-4 py-3 text-body",children:[y.jsxs("div",{className:"flex gap-3",children:[y.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Rule"}),y.jsx("dd",{children:FE(t.rule)})]}),y.jsxs("div",{className:"flex gap-3",children:[y.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Action"}),y.jsx("dd",{className:"font-mono text-small",children:UE(t)})]})]}),!!((m=t.evidence)!=null&&m.length)&&y.jsx(WE,{evidence:t.evidence}),t.state!=null&&y.jsxs("details",{className:"group border-t",children:[y.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 px-4 py-2.5 text-label text-muted-foreground hover:text-foreground",children:[y.jsx(Lr,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," What the model saw",t.state_truncated?" (cut at 64 KB)":""]}),y.jsx(ta,{value:t.state})]})]})}function WE({evidence:t}){return y.jsxs("section",{className:"border-t px-4 py-3",children:[y.jsxs("p",{className:"caps mb-2 text-micro text-muted-foreground",children:["Sources · ",t.length]}),y.jsx("ol",{className:"space-y-3",children:t.map((r,o)=>{let i=r.url;try{i=new URL(r.url).host}catch{}const a=Kg(r.url);return y.jsxs("li",{className:"flex gap-3",children:[y.jsx("span",{className:"font-mono text-label text-muted-foreground",children:o+1}),y.jsxs("div",{className:"min-w-0 flex-1",children:[a?y.jsxs("a",{href:a,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-start gap-1 text-body font-semibold leading-snug hover:underline",children:[r.title??i,y.jsx(ww,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}):y.jsx("span",{className:"break-all text-body font-semibold leading-snug",children:r.title??i}),y.jsxs("p",{className:"mt-0.5 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[i,r.scope&&y.jsx("span",{className:"border px-1",children:r.scope})]}),r.excerpts.slice(0,2).map((u,f)=>y.jsx("blockquote",{className:"mt-1.5 line-clamp-3 border-l-2 border-wf-parallel/[.6] pl-2.5 text-body leading-snug text-muted-foreground",children:u},f))]})]},o)})})]})}const uy=t=>{const r=vi(t);return r?`${r.tool} on ${r.server}`:t},cy=()=>y.jsx(Qt,{tone:"muted",title:"An MCP server's tool",children:y.jsx("span",{"data-mcp":!0,children:"MCP"})});function dy({e:t,fileUrl:r,zoom:o,compact:i=!1,shared:a=!1}){var w;const u=t.output,f=u!=null,d=u&&typeof u=="object"?u:null,m=!t.endedAt&&!["done","ok","failed","stopped"].includes(t.status),h=t.error??(d!=null&&d.error?`${d.error.code?`${d.error.code}: `:""}${d.error.message??""}`:null),g=t.status==="done"||t.status==="ok"?"success":t.status==="failed"?"error":t.status==="stopped"?"muted":"active";return y.jsxs("section",{className:"border bg-card",children:[y.jsxs("header",{className:"flex items-center gap-2 border-b px-4 py-2.5",children:[y.jsx("span",{className:"caps inline-flex h-5 items-center border border-wf-tool/[.6] bg-wf-tool/[.12] px-1.5 text-micro leading-none text-wf-tool",children:"tool"}),y.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",title:t.tool,children:uy(t.tool)}),vi(t.tool)&&y.jsx(cy,{}),y.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:t.endedAt?Ko(kd(t.startedAt,t.endedAt)):""}),y.jsx(Qt,{tone:g,children:t.status})]}),y.jsxs("div",{className:"space-y-3 px-4 py-3",children:[i?y.jsxs("p",{className:"break-all font-mono text-label",children:[y.jsx("span",{className:"caps mr-2 text-micro text-muted-foreground",children:"Input"}),JSON.stringify(t.input)]}):y.jsxs("div",{children:[y.jsx("p",{className:"caps mb-1 text-micro text-muted-foreground",children:"Input"}),y.jsx(ta,{value:t.input,small:!0})]}),h&&y.jsx("p",{className:"font-mono text-small text-destructive-text",children:h}),!!((w=d==null?void 0:d.pages)!=null&&w.length)&&y.jsx("div",{className:"flex flex-wrap gap-3",children:d.pages.map(x=>a?y.jsxs("span",{className:"border px-2 py-1 font-mono text-label text-muted-foreground",children:["Page ",x.page]},x.page):y.jsx("button",{type:"button",className:"block border bg-white hover:border-foreground",onClick:()=>o(r(x.image)),"aria-label":`Open page ${x.page}`,children:y.jsx("img",{src:r(x.image),alt:`Page ${x.page}`,className:"block h-[124px] w-[96px] object-cover object-top",loading:"lazy"})},x.page))}),f&&!h&&y.jsxs("details",{className:"group",children:[y.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 text-micro text-muted-foreground hover:text-foreground",children:[y.jsx(Lr,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Output"]}),y.jsx(ta,{value:u,small:!0})]}),!f&&!h&&y.jsx("p",{className:"font-mono text-small text-muted-foreground",children:t.status==="stopped"?"Stopped before it answered.":m?"Running…":"Finished with no output."})]})]})}function BE({workflow:t,path:r,kind:o}){const i=Ig(t,r);if(!i)return null;const a=Object.fromEntries(Object.entries(i).map(([u,f])=>[u,(u==="steps"||u==="branches"&&o==="parallel")&&Array.isArray(f)?`… ${tS(f.length)}`:u==="body"?"… its body":u==="branches"&&o==="route"&&f&&typeof f=="object"?Object.fromEntries(Object.entries(f).map(([d,m])=>[d,(m==null?void 0:m.criteria)??"…"])):f]));return y.jsxs("details",{className:"group border",children:[y.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 px-4 py-2.5 text-label text-muted-foreground hover:text-foreground",children:[y.jsx(Lr,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Definition ",y.jsx("span",{className:"normal-case tracking-normal",children:r})]}),y.jsx(ta,{value:a})]})}function ta({value:t,small:r}){return y.jsx("pre",{className:Ce("overflow-auto whitespace-pre-wrap break-words border-t bg-background px-4 py-3 font-mono leading-[1.6]",r?"max-h-48 border text-label":"max-h-80 text-small"),children:JSON.stringify(t,null,2)})}function HE({src:t,onClose:r}){return y.jsx(ag,{open:!0,onClose:r,title:"Page image",size:"full",children:y.jsx("img",{src:t,alt:"Page",className:"mx-auto max-h-full max-w-full border bg-white"})})}const GE=t=>[400,401,403,404,405,410,422].includes((t==null?void 0:t.status)??0);function GN(t,{everyMs:r=1e3,key:o="",enabled:i=!0}={}){const[a,u]=O.useState(null),[f,d]=O.useState(null),[m,h]=O.useState(0),[g,w]=O.useState(0),x=O.useRef(t);return x.current=t,O.useEffect(()=>{if(!i)return;const k=new AbortController;let b;const C=async()=>{try{const j=Date.now(),P=await x.current(k.signal);if(k.signal.aborted||(u(P),d(null),h(j),ha(P.run.status)))return}catch(j){if(k.signal.aborted)return;d(j);const P=j;if(P.retryable){b=setTimeout(C,Math.min(r,P.retryAfterMs??500));return}if(GE(j))return}b=setTimeout(C,r)};return C(),()=>{k.abort(),clearTimeout(b)}},[o,r,g,i]),{data:a,error:f,readAt:m,reload:()=>w(k=>k+1)}}function qN({data:t,actions:r={},fileUrl:o,initial:i=null,lastRead:a,shared:u=!1}){const[f,d]=O.useState(i),m=O.useMemo(()=>ab(t,f),[t,f]),h=ha(t.run.status),[g,w]=O.useState(()=>Date.now()),x=O.useMemo(()=>Date.now(),[t]);return O.useEffect(()=>{if(h||t.run.paused)return;const k=setInterval(()=>w(Date.now()),1e3);return()=>clearInterval(k)},[h,t.run.paused]),y.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[y.jsx(qE,{data:t,readAt:x,now:g,actions:r,stale:!h&&a&&g-a>5e3?Math.max(1e3,g-a):0}),t.run.paused&&y.jsx("p",{className:"border-b border-warning/40 bg-warning/10 px-5 py-2 font-mono text-small text-warning-text md:px-8",role:"status",children:"Paused. Calls already in flight finish; no new node starts until you resume. The run keeps its place across a restart."}),y.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[y.jsx("div",{className:"min-h-[320px] min-w-0 flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px]",children:y.jsxs("div",{className:"px-5 py-6 md:px-8",children:[t.run.withheld&&y.jsx("p",{className:"mb-4 border p-4 font-mono text-body text-muted-foreground",role:"status",children:"This run's agent and revision are withheld: a saved secret is split across them, so neither is shown."}),t.graph.withheld&&y.jsx("p",{className:"mb-4 border p-4 font-mono text-body text-muted-foreground",role:"status",children:"This run's workflow graph is withheld: a saved secret is split across two of its words, so none of them is shown."}),typeof t.nodes=="string"&&y.jsx("p",{className:"mb-4 border p-4 font-mono text-body text-muted-foreground",role:"status",children:"This run's node states are withheld: a saved secret is split across them, so none is shown."}),y.jsx(sS,{graph:t.graph,marks:m,onSelect:k=>d(b=>b&&b.path===k.path&&(b.item??null)===k.item?null:k),label:"The run's workflow graph"})]})}),f&&y.jsx("div",{className:"flex min-h-0 shrink-0 flex-col border-t lg:w-[460px] lg:border-l lg:border-t-0",children:y.jsx(LE,{data:t,selected:f,onSelect:d,onClose:()=>d(null),fileUrl:o,shared:u})})]}),y.jsx("div",{className:"border-t px-5 py-2 md:px-8",children:y.jsx(iS,{run:!0})})]})}function qE({data:t,readAt:r,now:o,actions:i,stale:a}){const u=ha(t.run.status),f=t.graph.nodes.find(w=>{var x,k;return w.kind==="map"&&((k=(x=t.nodes[w.path])==null?void 0:x.items)==null?void 0:k.length)}),d=f?Ug(t.nodes[f.path].items):null,{usd:m,unknown:h}=db(t),g=[["Elapsed",Gh(fb(t,r,o))],["Cost",y.jsxs(y.Fragment,{children:[yi(m),h>0&&y.jsxs("span",{className:"text-label font-normal text-muted-foreground",children:[" + ",h," unknown"]})]}),"Decisions and model calls, as the providers priced them"],["Decisions",t.totals.decisions],["Tool calls",t.totals.effects],["Agents",QE(t),"Agent loops this run started. Decision models and tools answer one call each; none of them is an agent."]];return d&&g.push(["Items",y.jsxs(y.Fragment,{children:[y.jsx("span",{children:d.done}),y.jsxs("span",{className:"text-muted-foreground",children:["/",d.total]}),d.failed>0&&y.jsxs("span",{className:"ml-2 text-label text-destructive-text",children:[d.failed," failed"]}),d.review>0&&y.jsxs("span",{className:"ml-2 text-label text-warning-text",children:[d.review," review"]})]})]),y.jsxs("div",{className:"flex flex-wrap items-stretch border-b",children:[t.run.paused&&y.jsx("div",{className:"flex items-center pl-5 md:pl-8",children:y.jsxs(Qt,{tone:"warning",children:[y.jsx(bc,{className:"size-3","aria-hidden":!0})," Paused"]})}),g.map(([w,x,k],b)=>y.jsxs("div",{className:Ce("px-4 py-2",b?"border-l":"pl-5 md:pl-8"),title:k,children:[y.jsx("p",{className:"caps text-micro text-muted-foreground",children:w}),y.jsx("p",{className:"font-mono text-prose font-semibold tabular-nums",children:x})]},w)),y.jsxs("div",{className:"flex flex-1 items-center justify-end gap-3 px-5 py-2 md:px-8",children:[a>0&&y.jsxs("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:["Last read ",Gh(a)," ago, reading again"]}),!u&&(t.run.paused?y.jsxs(Kn,{size:"sm",variant:"solid",onClick:i.onResume,disabled:!i.onResume||!!i.busy,children:[y.jsx(_w,{"aria-hidden":!0})," ",i.busy==="resume"?"Resuming":"Resume"]}):y.jsxs(Kn,{size:"sm",onClick:i.onPause,disabled:!i.onPause||!!i.busy,title:"Calls in flight finish; no new node starts.",children:[y.jsx(bc,{"aria-hidden":!0})," ",i.busy==="pause"?"Pausing":"Pause"]}))]})]})}const VE=new Set(["agent","decide","extract","report","artifact"]),QE=t=>t.graph.nodes.filter(r=>{var o;return VE.has(r.kind)&&!["pending","not_run"].includes(((o=t.nodes[r.path])==null?void 0:o.status)??"pending")}).length;function VN({error:t}){const r=t==null?void 0:t.status;return y.jsx("p",{className:Ce("m-8 border p-4 font-mono text-body",r===404?"text-muted-foreground":"text-destructive-text"),role:"status",children:t==null?"Reading the run's graph...":r===404?"This server does not give run graphs: GET /v2/runs/{id}/graph is not there.":`The run's graph could not be read: ${t.message??String(t)}`})}const QN=["system","light","dark"],Uc="agentrun.theme",KE="(prefers-color-scheme: dark)",va=()=>{try{return globalThis.localStorage??null}catch{return null}},fy=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(KE):null;let Wc=null;function YE(t=va()){try{const r=t==null?void 0:t.getItem(Uc);return r==="light"||r==="dark"?r:"system"}catch{return"system"}}const fm=(t=va())=>Wc??YE(t);function KN(t,r=va()){Wc=null;try{t==="system"?r==null||r.removeItem(Uc):r==null||r.setItem(Uc,t)}catch{Wc=t}}function pm(t,r=document.documentElement,o=fy()){const i=t==="dark"||t==="system"&&!!(o!=null&&o.matches);r.classList.toggle("dark",i),r.classList.toggle("light",!i)}function YN(t=document.documentElement,r=fy(),o=va()){pm(fm(o),t,r);const i=()=>{fm(o)==="system"&&pm("system",t,r)};return r==null||r.addEventListener("change",i),()=>r==null?void 0:r.removeEventListener("change",i)}export{Lm as $,Yn as A,l0 as B,qm as C,qc as D,r_ as E,s_ as F,ce as G,Gc as H,la as I,fn as J,en as K,o_ as L,Jx as M,k0 as N,g0 as O,Zx as P,x0 as Q,z0 as R,Fm as S,Wx as T,co as U,e_ as V,u0 as W,N0 as X,jt as Y,Hl as Z,$r as _,hx as a,h_ as a$,vh as a0,a_ as a1,r0 as a2,Wm as a3,u_ as a4,qn as a5,y as a6,Ce as a7,hw as a8,Qt as a9,tS as aA,DN as aB,ib as aC,sN as aD,bc as aE,Lr as aF,V_ as aG,sS as aH,iS as aI,xw as aJ,ai as aK,rN as aL,Tw as aM,tw as aN,jg as aO,Sb as aP,L1 as aQ,K_ as aR,ad as aS,yw as aT,vm as aU,LN as aV,$b as aW,MN as aX,xN as aY,AN as aZ,p_ as a_,Bc as aa,wm as ab,gw as ac,nh as ad,xm as ae,px as af,Kn as ag,vw as ah,$w as ai,Y1 as aj,oN as ak,dx as al,Q_ as am,_w as an,f_ as ao,c_ as ap,ag as aq,qo as ar,F1 as as,gN as at,yN as au,ha as av,V1 as aw,q1 as ax,Gh as ay,tb as az,n_ as b,kN as b$,Ag as b0,eN as b1,Ew as b2,NN as b3,_N as b4,EN as b5,kw as b6,iN as b7,aN as b8,cN as b9,P_ as bA,R_ as bB,O_ as bC,L_ as bD,__ as bE,T_ as bF,G_ as bG,D_ as bH,F_ as bI,M_ as bJ,I_ as bK,z_ as bL,A_ as bM,T1 as bN,$_ as bO,j_ as bP,U_ as bQ,W_ as bR,B_ as bS,ym as bT,FN as bU,d_ as bV,q_ as bW,TN as bX,CN as bY,Eb as bZ,qh as b_,uN as ba,lN as bb,ON as bc,IN as bd,jb as be,PN as bf,zN as bg,RN as bh,Sk as bi,bk as bj,rh as bk,pw as bl,od as bm,b_ as bn,dN as bo,S_ as bp,g_ as bq,k_ as br,E_ as bs,Kg as bt,y_ as bu,x_ as bv,w_ as bw,m_ as bx,v_ as by,H_ as bz,Oe as c,SN as c0,_g as c1,Wg as c2,kk as c3,Cw as c4,xb as c5,mb as c6,Lg as c7,nN as c8,Z_ as c9,VN as cA,qN as cB,fm as cC,QN as cD,KN as cE,pm as cF,N_ as cG,C_ as cH,bN as cI,$N as cJ,YN as cK,ZE as cL,ao as cM,fw as ca,jN as cb,tN as cc,J_ as cd,X_ as ce,mN as cf,pN as cg,hN as ch,Pg as ci,Wh as cj,Y_ as ck,K1 as cl,WN as cm,BN as cn,fN as co,vN as cp,vb as cq,UN as cr,cm as cs,hb as ct,HN as cu,wN as cv,GN as cw,GE as cx,db as cy,yi as cz,xx as d,pi as e,_c as f,t_ as g,Ax as h,$n as i,Rl as j,Tx as k,fi as l,ro as m,$t as n,Me as o,oa as p,Ar as q,O as r,Gl as s,Gm as t,vx as u,Yp as v,Nn as w,Dm as x,jn as y,Gx as z};