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

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 (128) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +32 -13
  3. package/dist/adapters.js +4 -2
  4. package/dist/agent-delete.d.ts +3 -3
  5. package/dist/agent-delete.js +50 -4
  6. package/dist/chatgpt-plan.d.ts +8 -1
  7. package/dist/chatgpt-plan.js +55 -6
  8. package/dist/console/assets/{backend-DEgVn5lC.js → backend-BxQ2G1M0.js} +2 -2
  9. package/dist/console/assets/{index-CG5tELph.js → index-C8Y5Zl8x.js} +2 -2
  10. package/dist/console/assets/share-CjBJ_rxP.js +6 -0
  11. package/dist/console/index.html +1 -1
  12. package/dist/console/share.html +1 -1
  13. package/dist/harness-opencode/adapter.d.ts +3 -1
  14. package/dist/harness-opencode/adapter.js +6 -2
  15. package/dist/harness-opencode/harness.d.ts +4 -0
  16. package/dist/harness-opencode/harness.js +6 -1
  17. package/dist/host-tools.d.ts +18 -3
  18. package/dist/host-tools.js +27 -4
  19. package/dist/learn/ledger.d.ts +37 -16
  20. package/dist/learn/ledger.js +56 -24
  21. package/dist/learn/promote.d.ts +4 -1
  22. package/dist/learning-cost.d.ts +5 -3
  23. package/dist/learning-model.js +7 -5
  24. package/dist/learning-work.d.ts +69 -0
  25. package/dist/learning-work.js +148 -0
  26. package/dist/openapi.js +23 -9
  27. package/dist/run-export.js +7 -4
  28. package/dist/run-launch.d.ts +6 -1
  29. package/dist/run-launch.js +10 -3
  30. package/dist/run-view.js +9 -3
  31. package/dist/runnable.js +5 -5
  32. package/dist/runner/adapter-loop.js +31 -3
  33. package/dist/runner/adapter-run-spec.d.ts +14 -3
  34. package/dist/runner/adapter-run-spec.js +50 -19
  35. package/dist/runner/adapters/index.d.ts +2 -0
  36. package/dist/runner/adapters/index.js +3 -0
  37. package/dist/runner/adapters/pi.d.ts +42 -3
  38. package/dist/runner/adapters/pi.js +114 -13
  39. package/dist/runner/audit.d.ts +8 -2
  40. package/dist/runner/audit.js +34 -18
  41. package/dist/runner/book-cut.d.ts +6 -0
  42. package/dist/runner/book-cut.js +38 -0
  43. package/dist/runner/claim-secrets.d.ts +9 -4
  44. package/dist/runner/claim-secrets.js +10 -5
  45. package/dist/runner/cli-run-spec.d.ts +0 -2
  46. package/dist/runner/cli-run-spec.js +44 -19
  47. package/dist/runner/held.d.ts +6 -3
  48. package/dist/runner/learned-first.d.ts +5 -0
  49. package/dist/runner/learned-first.js +1 -1
  50. package/dist/runner/learning-end.d.ts +15 -8
  51. package/dist/runner/learning-end.js +23 -7
  52. package/dist/runner/loop-contract.d.ts +4 -0
  53. package/dist/runner/main.js +2 -0
  54. package/dist/runner/model-route.d.ts +4 -0
  55. package/dist/runner/model-route.js +1 -1
  56. package/dist/runner/pr-checkout.d.ts +12 -0
  57. package/dist/runner/pr-checkout.js +21 -2
  58. package/dist/runner/promotion.d.ts +9 -2
  59. package/dist/runner/promotion.js +79 -28
  60. package/dist/runner/reflect-hook.d.ts +7 -0
  61. package/dist/runner/reflect-hook.js +2 -1
  62. package/dist/runner/run-child-host.js +21 -12
  63. package/dist/runner/run-child.js +1 -0
  64. package/dist/runner/runner.d.ts +9 -0
  65. package/dist/runner/runner.js +156 -25
  66. package/dist/runner/store-port.d.ts +4 -1
  67. package/dist/runner/workflow-first.js +4 -3
  68. package/dist/runner/workflow-loop.js +13 -1
  69. package/dist/secret-cut.d.ts +4 -0
  70. package/dist/secret-cut.js +1 -1
  71. package/dist/secret-rules.d.ts +2 -0
  72. package/dist/secret-rules.js +63 -19
  73. package/dist/server.js +20 -9
  74. package/dist/share-host.js +6 -3
  75. package/dist/store/schema.d.ts +4 -3
  76. package/dist/store/schema.js +4 -3
  77. package/dist/store/seal.d.ts +8 -2
  78. package/dist/store/seal.js +13 -2
  79. package/dist/store/sqlite/learning-rows.js +2 -1
  80. package/dist/store/sqlite/run-patch.js +4 -4
  81. package/dist/store/sqlite/store.js +28 -4
  82. package/dist/store/store.d.ts +5 -0
  83. package/dist/store-reads/journal.d.ts +2 -0
  84. package/dist/store-reads/journal.js +1 -1
  85. package/dist/store-reads/learning.d.ts +4 -3
  86. package/dist/store-reads/learning.js +62 -18
  87. package/dist/store-view.d.ts +3 -0
  88. package/dist/store-view.js +18 -1
  89. package/dist/tool-list.d.ts +4 -0
  90. package/dist/tool-list.js +4 -0
  91. package/dist/tools.js +2 -2
  92. package/dist/workspace/attach.js +22 -5
  93. package/dist/workspace/kind-skills/desktop/SKILL.md +7 -3
  94. package/package.json +12 -12
  95. package/templates/kyb/agent.md +7 -1
  96. package/templates/kyb/evals/list-file-fuzzy-alias/case.yaml +10 -0
  97. package/templates/kyb/evals/list-file-fuzzy-alias/fixtures/web.json +58 -0
  98. package/templates/kyb/evals/list-file-fuzzy-alias/graders/finds-the-transliteration.md +17 -0
  99. package/templates/kyb/evals/list-file-fuzzy-alias/graders/greps-the-files.md +11 -0
  100. package/templates/kyb/evals/list-file-fuzzy-alias/graders/saves-the-uk-file.md +8 -0
  101. package/templates/kyb/evals/list-file-fuzzy-alias/prompt.md +7 -0
  102. package/templates/kyb/evals/list-file-hit/case.yaml +10 -0
  103. package/templates/kyb/evals/list-file-hit/fixtures/web.json +58 -0
  104. package/templates/kyb/evals/list-file-hit/graders/greps-the-files.md +11 -0
  105. package/templates/kyb/evals/list-file-hit/graders/hits-by-company-number.md +18 -0
  106. package/templates/kyb/evals/list-file-hit/graders/saves-the-uk-file.md +8 -0
  107. package/templates/kyb/evals/list-file-hit/prompt.md +7 -0
  108. package/templates/kyb/evals/list-file-no-hit/case.yaml +10 -0
  109. package/templates/kyb/evals/list-file-no-hit/fixtures/web.json +58 -0
  110. package/templates/kyb/evals/list-file-no-hit/graders/greps-the-files.md +11 -0
  111. package/templates/kyb/evals/list-file-no-hit/graders/no-hit-by-whole-file.md +12 -0
  112. package/templates/kyb/evals/list-file-no-hit/graders/saves-the-uk-file.md +8 -0
  113. package/templates/kyb/evals/list-file-no-hit/prompt.md +7 -0
  114. package/templates/kyb/evals/list-file-short-name/case.yaml +9 -0
  115. package/templates/kyb/evals/list-file-short-name/fixtures/web.json +58 -0
  116. package/templates/kyb/evals/list-file-short-name/graders/finds-the-short-name.md +19 -0
  117. package/templates/kyb/evals/list-file-short-name/graders/greps-the-files.md +11 -0
  118. package/templates/kyb/evals/list-file-short-name/graders/saves-the-uk-file.md +8 -0
  119. package/templates/kyb/evals/list-file-short-name/prompt.md +7 -0
  120. package/templates/kyb/evals/list-file-split-name/case.yaml +11 -0
  121. package/templates/kyb/evals/list-file-split-name/fixtures/web.json +58 -0
  122. package/templates/kyb/evals/list-file-split-name/graders/finds-the-director.md +18 -0
  123. package/templates/kyb/evals/list-file-split-name/graders/greps-the-files.md +11 -0
  124. package/templates/kyb/evals/list-file-split-name/graders/saves-the-uk-file.md +8 -0
  125. package/templates/kyb/evals/list-file-split-name/prompt.md +7 -0
  126. package/templates/kyb/kyb.schema.json +2 -2
  127. package/templates/kyb/rules/SANCTIONS.md +82 -13
  128. package/dist/console/assets/share-CIeFK2Oe.js +0 -6
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./backend-DEgVn5lC.js","./styles-BGZxYkky.js","./styles-D0SufbzK.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./backend-BxQ2G1M0.js","./styles-BGZxYkky.js","./styles-D0SufbzK.css"])))=>i.map(i=>d[i]);
2
2
  import{r as u,c as Ee,G as Ke,p as To,o as Je,l as Xg,a as zt,f as Zg,s as eb,m as qk,b as Hk,E as tb,Y as Bs,d as _u,y as fn,n as Jt,e as Rs,K as Ks,L as Gk,g as Nf,h as fd,i as _l,j as Sf,k as Bk,q as Kk,t as Yk,u as $u,v as Vk,w as $l,T as sb,x as El,z as nb,A as Ts,B as rb,C as ab,S as mt,D as Cf,F as ob,V as Ao,H as Hi,I as ib,N as lb,J as Pn,M as cb,O as db,P as ub,Q as mb,R as hb,U as fb,W as pb,X as xb,Z as Gi,_ as _f,$ as ct,a0 as Jk,a1 as Rc,a2 as Qk,a3 as Xk,a4 as Zk,a5 as $f,a6 as t,a7 as q,a8 as dn,a9 as de,aa as pd,ab as ks,ac as eN,ad as tN,ae as Hn,af as jt,ag as I,ah as Sr,ai as ga,aj as ge,ak as sN,al as ke,am as Me,an as As,ao as Us,ap as io,aq as gr,ar as wt,as as In,at as xd,au as gb,av as nN,aw as bb,ax as rN,ay as Rl,az as lo,aA as Eu,aB as Ru,aC as Tl,aD as vb,aE as Tu,aF as Al,aG as un,aH as Ol,aI as Ml,aJ as Au,aK as co,aL as kt,aM as aN,aN as oN,aO as Cr,aP as yb,aQ as Fn,aR as ts,aS as aa,aT as wb,aU as iN,aV as Ou,aW as Ws,aX as lN,aY as Nn,aZ as jb,a_ as Mu,a$ as Xa,b0 as ba,b1 as Os,b2 as va,b3 as kb,b4 as cN,b5 as Nb,b6 as ya,b7 as dN,b8 as uN,b9 as mN,ba as Ef,bb as hN,bc as fN,bd as pN,be as xN,bf as gN,bg as bN,bh as Sb,bi as vN,bj as yN,bk as Cb,bl as Oo,bm as gd,bn as wN,bo as jN,bp as Bi,bq as _b,br as kN,bs as NN,bt as Nt,bu as SN,bv as CN,bw as _N,bx as $N,by as EN,bz as Ri,bA as RN,bB as TN,bC as Rf,bD as AN,bE as Tf,bF as ON,bG as MN,bH as IN,bI as LN,bJ as PN,bK as FN,bL as zN,bM as DN,bN as UN,bO as WN,bP as qN,bQ as Af,bR as HN,bS as Of,bT as GN,bU as Ys,bV as uo,bW as BN,bX as KN,bY as jn,bZ as YN,b_ as Mf,b$ as Il,c0 as VN,c1 as JN,c2 as Ki,c3 as zn,c4 as QN,c5 as Ll,c6 as Pl,c7 as Yi,c8 as bd,c9 as vd,ca as XN,cb as $b,cc as ZN,cd as If,ce as e1,cf as Eb,cg as Rb,ch as Tb,ci as t1,cj as yd,ck as s1,cl as Iu,cm as n1,cn as r1,co as a1,cp as Fl,cq as Lu,cr as o1,cs as i1,ct as l1,cu as Ab,cv as c1,cw as d1,cx as u1,cy as m1,cz as h1,cA as f1,cB as p1,cC as x1,cD as g1,cE as b1,cF as v1,cG as y1,cH as w1,cI as j1,cJ as k1,cK as N1,cL as S1}from"./styles-BGZxYkky.js";const C1="modulepreload",_1=function(e,s){return new URL(e,s).href},Lf={},$1=function(s,n,r){let a=Promise.resolve();if(n&&n.length>0){let l=function(p){return Promise.all(p.map(x=>Promise.resolve(x).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const i=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=l(n.map(p=>{if(p=_1(p,r),p in Lf)return;Lf[p]=!0;const x=p.endsWith(".css"),f=x?'[rel="stylesheet"]':"";if(!!r)for(let g=i.length-1;g>=0;g--){const b=i[g];if(b.href===p&&(!x||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${p}"]${f}`))return;const m=document.createElement("link");if(m.rel=x?"stylesheet":C1,x||(m.as="script"),m.crossOrigin="",m.href=p,d&&m.setAttribute("nonce",d),document.head.appendChild(m),x)return new Promise((g,b)=>{m.addEventListener("load",g),m.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${p}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return a.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return s().catch(o)})};function It(e){const s=e&&typeof e=="object"?e.sdk:void 0;if((s==null?void 0:s.runtime)==="external"){const n=s.platform;return typeof n=="string"&&n.length>0&&n.trim()===n&&[...n].length<=80&&!/[\u0000-\u001f\u007f-\u009f\uD800-\uDFFF]/u.test(n)?{runtime:"external",platform:n}:{runtime:"external",platform:"External platform"}}return(s==null?void 0:s.platform)===void 0&&((s==null?void 0:s.runtime)==="claude-agent-sdk"||(s==null?void 0:s.runtime)==="codex-sdk"||(s==null?void 0:s.runtime)==="eve")?{runtime:s.runtime}:void 0}const E1={"claude-agent-sdk":"Claude Agent SDK","codex-sdk":"Codex SDK",eve:"Vercel eve"},qs=e=>e.runtime==="external"?e.platform:E1[e.runtime];let Wr=null;function Ja(e,s){return Wr?Wr({to:e,replay:s}):!1}function Ob(e){const[s,n]=u.useState(null),r=u.useRef(location.hash);return u.useEffect(()=>{if(!e)return;const a=l=>l.to===r.current?!1:(n(l),!0);Wr=a;const o=l=>{l.preventDefault(),l.returnValue=""};return window.addEventListener("beforeunload",o),()=>{Wr===a&&(Wr=null),window.removeEventListener("beforeunload",o)}},[e]),{asking:s!==null,stay:()=>n(null),leave:()=>{var a;if(s!==null){if(n(null),s.to===null){(a=s.replay)==null||a.call(s);return}if(Wr=null,!s.replay){location.hash=s.to;return}location.hash!==r.current?window.addEventListener("hashchange",s.replay,{once:!0}):s.replay()}}}}let Qr=0;const wd=()=>{var s;const e=(s=history.state)==null?void 0:s.console_at;return typeof e=="number"?e:void 0},Pf=e=>{Qr=e,history.replaceState({...history.state??{},console_at:e},"")};function R1(){const e=wd();e===void 0?Pf(0):Qr=e;const s=()=>{const n=wd();n===void 0?Pf(Qr+1):Qr=n};return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)}function T1(){const e=wd();return e===void 0?-1:Qr-e}function zl(e){if(Qr>0){history.back();return}const s=()=>{history.replaceState({...history.state??{},console_at:0},"",e),window.dispatchEvent(new HashChangeEvent("hashchange"))};Ja(e,s)||s()}/**
3
3
  * @license lucide-react v0.468.0 - ISC
4
4
  *
@@ -636,4 +636,4 @@ I selected observation of an existing application. Preserve its current job trig
636
636
  <path fill="currentColor" fill-rule="evenodd" d="M 389 37.500 L 389 44 380.500 44 L 372 44 372 49.500 L 372 55 380.403 55 L 388.806 55 389.153 72.750 C 389.457 88.317, 389.746 90.918, 391.500 93.895 C 395.413 100.538, 397.738 101.460, 411.573 101.853 L 424 102.206 424 96.603 L 424 91 415.155 91 C 402.732 91, 403 91.437, 403 71.171 L 403 55 413.500 55 L 424 55 424 49.500 L 424 44 413.500 44 L 403 44 403 37.500 L 403 31 396 31 L 389 31 389 37.500 M 131 43.871 C 125.643 45.644, 120.084 49.079, 118.285 51.727 C 116.195 54.806, 114 59.579, 114 61.047 C 114 61.571, 117.120 62, 120.933 62 C 126.956 62, 127.947 61.741, 128.492 60.026 C 129.478 56.918, 133.930 54, 137.685 54 C 143.116 54, 146.753 56.444, 148.122 61.012 C 148.781 63.213, 149.071 65.262, 148.767 65.567 C 148.462 65.871, 142.797 67.362, 136.178 68.880 C 122.542 72.006, 116.670 75.152, 114.421 80.534 C 112.426 85.309, 112.646 88.882, 115.250 93.994 C 118.135 99.660, 124.135 103.002, 131.407 102.994 C 138.831 102.986, 143.475 101.377, 146.674 97.703 L 149.500 94.459 153.095 98.229 C 156.425 101.722, 157.108 102, 162.345 102 L 168 102 168 97 C 168 92.852, 167.693 92, 166.200 92 C 162.514 92, 162 90.041, 162 75.982 C 162 66.900, 161.509 60.711, 160.527 57.404 C 159.055 52.445, 154.878 47.463, 150.159 45.036 C 147.247 43.538, 134.369 42.755, 131 43.871 M 193.266 44.657 C 184.547 47.744, 178 59.013, 178 70.933 C 178 80.006, 180.437 86.535, 185.825 91.901 C 194.754 100.791, 207.352 101.478, 215.250 93.504 L 218 90.727 218 95.929 C 218 98.791, 217.537 101.997, 216.970 103.055 C 215.335 106.111, 210.560 108, 204.473 108 C 199.506 108, 198.480 107.634, 195.725 104.879 C 192.768 101.922, 192.295 101.786, 186.723 102.291 C 183.489 102.585, 180.584 103.083, 180.268 103.398 C 179.953 103.714, 181.019 106.116, 182.638 108.736 C 186.959 115.728, 192.213 118.299, 203.264 118.827 C 209.969 119.148, 213.136 118.838, 216.571 117.526 C 222.577 115.232, 226.886 111.461, 229.120 106.541 C 230.766 102.919, 230.958 99.464, 230.978 73.250 L 231 44 225 44 L 219 44 219 48 C 219 50.200, 218.820 52, 218.600 52 C 218.380 52, 216.671 50.471, 214.803 48.603 C 209.396 43.196, 201.485 41.747, 193.266 44.657 M 262.826 43.979 C 253.472 46.803, 247.020 53.859, 244.384 64.145 C 240.567 79.044, 246.323 94.533, 257.772 100.171 C 261.528 102.021, 264.144 102.500, 270.500 102.500 C 279.633 102.500, 284.181 100.774, 289.515 95.281 C 292.968 91.726, 295.711 86.378, 294.633 85.300 C 294.284 84.950, 291.544 84.461, 288.545 84.212 C 283.330 83.780, 282.943 83.918, 279.678 87.380 C 276.559 90.687, 275.788 91, 270.767 91 C 264.381 91, 260.594 88.666, 258.379 83.364 C 255.619 76.758, 254.906 77, 277.145 77 L 297.289 77 296.673 70.402 C 295.481 57.633, 288.342 47.367, 278.655 44.490 C 273.249 42.885, 267.108 42.687, 262.826 43.979 M 332.459 44.817 C 330.236 45.861, 327.224 48.133, 325.767 49.866 L 323.116 53.016 322.808 48.758 L 322.500 44.500 316.750 44.200 L 311 43.900 311 72.950 L 311 102 317.500 102 L 324 102 324.015 82.750 C 324.025 69.463, 324.412 62.755, 325.265 61.096 C 328.741 54.332, 337.812 52.359, 342.750 57.293 L 345.500 60.041 345.822 81.021 L 346.145 102 352.640 102 L 359.135 102 358.818 79.250 C 358.509 57.113, 358.433 56.381, 356 52.089 C 352.498 45.909, 349.398 43.923, 342.403 43.378 C 337.960 43.032, 335.500 43.387, 332.459 44.817 M 199.096 55.265 C 194.596 57.578, 192.592 61.537, 192.173 68.941 C 191.504 80.780, 195.062 86.802, 203.272 87.727 C 212.382 88.754, 217.934 82.307, 217.978 70.651 C 218.005 63.565, 215.789 58.453, 211.580 55.886 C 208.052 53.734, 202.602 53.463, 199.096 55.265 M 262.514 57.168 C 260.228 58.965, 257 64.411, 257 66.468 C 257 66.761, 262.625 67, 269.500 67 L 282 67 282 64.400 C 282 62.776, 280.723 60.523, 278.600 58.400 C 275.646 55.446, 274.548 55, 270.235 55 C 266.656 55, 264.500 55.605, 262.514 57.168 M 138.229 77.968 C 130.016 79.956, 127 82.103, 127 85.964 C 127 90.322, 129.136 92.216, 134.582 92.686 C 138.352 93.012, 140.272 92.627, 142.810 91.034 C 146.429 88.763, 149 83.777, 149 79.032 C 149 75.472, 148.674 75.440, 138.229 77.968"/>
637
637
  <path fill="#ff8700" fill-rule="evenodd" d="M 46 56.500 L 61.476 72 46 87.500 L 30.524 103 40.524 103 L 50.524 103 66 87.500 L 81.476 72 66 56.500 L 50.524 41 40.524 41 L 30.524 41 46 56.500 M 591.008 45.177 C 588.538 46.455, 585.500 49.029, 584.258 50.898 L 582 54.296 582 49.148 L 582 44 576 44 L 570 44 570 73 L 570 102 576.500 102 L 583 102 583 82.648 C 583 64.145, 583.100 63.147, 585.287 59.898 C 588.261 55.478, 593.871 53.472, 598.754 55.084 C 604.317 56.920, 605 59.915, 605 82.468 L 605 102 611.566 102 L 618.133 102 617.816 78.674 L 617.500 55.348 614.752 51.198 C 611.046 45.602, 608.140 43.906, 601.286 43.336 C 596.568 42.944, 594.671 43.284, 591.008 45.177 M 440 49.500 L 440 55 447 55 L 454 55 454 73 L 454 91 447 91 L 440 91 440 96.500 L 440 102 462.500 102 L 485 102 485 96.500 L 485 91 476.500 91 L 468 91 468 76.723 C 468 65.403, 468.323 61.983, 469.561 60.217 C 472.207 56.439, 476.313 55, 484.450 55 L 492 55 492 49.500 L 492 44 484.250 44.002 C 475.131 44.003, 470.664 45.818, 467.270 50.898 L 465 54.296 465 50.730 C 465 43.982, 465.035 44, 451.893 44 L 440 44 440 49.500 M 505 63.951 C 505 74.924, 505.490 86.187, 506.089 88.980 C 508.017 97.970, 514.078 103, 522.982 103 C 529.339 103, 533.848 101.158, 537.179 97.199 L 539.765 94.126 540.394 98.063 L 541.024 102 547.012 102 L 553 102 553 73 L 553 44 546.500 44 L 540 44 539.956 60.750 C 539.903 81.412, 539.195 85.543, 535.078 89.222 C 528.800 94.831, 520.627 91.663, 518.950 82.971 C 518.475 80.512, 518.068 70.737, 518.044 61.250 L 518 44 511.500 44 L 505 44 505 63.951"/>
638
638
  </svg>
639
- `;function Cl(){return t.jsx("span",{role:"img","aria-label":"AgentRun",className:"inline-flex h-8 align-middle text-foreground [&>svg]:h-full [&>svg]:w-auto",dangerouslySetInnerHTML:{__html:CF}})}const _F={mission:"Mission Control",factory:"Agent Factory",playground:"Playground",agents:"Agents",runs:"Runs",dojo:"Dojo",templates:"Templates",suggestions:"Suggested agents",triggers:"Triggers",wrapped:"Wrapped",settings:"Settings",free:"Free"},$F={mission:"#/",factory:"#/factory",playground:"#/playground",agents:"#/agents",runs:"#/runs",dojo:"#/dojo",templates:"#/templates",suggestions:"#/suggestions",triggers:"#/triggers",wrapped:"#/wrapped",settings:"#/settings/keys",free:"#/free"},EF={system:["System",va],light:["Light",sS],dark:["Dark",K1]};function RF(){const[e,s]=u.useState(()=>x1()),n=r=>{b1(r),v1(r),s(r)};return t.jsx("div",{role:"group","aria-label":"Theme",className:"flex gap-1 border p-1",children:g1.map(r=>{const[a,o]=EF[r];return t.jsx(I,{variant:"ghost",size:"sm","aria-label":a,title:a,"aria-pressed":e===r,onClick:()=>n(r),className:q("flex flex-1 items-center justify-center py-1.5 text-muted-foreground hover:bg-accent hover:text-foreground",e===r&&"bg-accent text-foreground"),children:t.jsx(o,{className:"size-4","aria-hidden":!0})},r)})})}function TF({active:e,settings:s=!1,triggers:n=!1,banners:r,onNavigate:a,onSignOut:o,onSignOutEverywhere:l,children:i}){const[c,d]=u.useState(!1),[p,x]=u.useState(!1),f=u.useRef(null),h=u.useRef(null),m=u.useRef(!1);u.useEffect(()=>{var y,w;p?(y=h.current)==null||y.focus():m.current&&((w=f.current)==null||w.focus())},[p]);const g=()=>{m.current=!0,x(!1)},b=y=>{a?a(y):location.hash=$F[y],d(!1)},v=_F[e];u.useEffect(()=>{document.title=v?`${v} · AgentRun`:"AgentRun"},[v]);const k=u.useRef(null);return t.jsxs("div",{className:"relative flex h-dvh min-h-0 flex-col overflow-hidden bg-background text-foreground roomy:flex-row",children:[t.jsx(I,{type:"button",size:"sm",onClick:()=>{var y;return(y=k.current)==null?void 0:y.focus()},className:"sr-only focus-visible:not-sr-only focus-visible:absolute focus-visible:left-2 focus-visible:top-2 focus-visible:z-toast focus-visible:inline-flex focus-visible:bg-card focus-visible:px-3",children:"Skip to the page"}),t.jsxs("header",{className:"flex h-12 shrink-0 items-center justify-between border-b px-4 roomy:hidden",children:[t.jsx("button",{type:"button",onClick:()=>b("mission"),"aria-label":"AgentRun home",children:t.jsx(Cl,{})}),t.jsx(I,{size:"icon","aria-label":"Navigation","aria-expanded":c,onClick:()=>d(y=>!y),children:t.jsx(H1,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("aside",{className:q("shrink-0 flex-col border-r bg-background roomy:flex roomy:h-dvh roomy:overflow-y-auto roomy:w-sidebar",c?"flex max-h-[60dvh] overflow-y-auto border-b roomy:max-h-none":"hidden"),children:[t.jsx("div",{className:"hidden h-12 shrink-0 items-center border-b px-4 roomy:flex",children:t.jsx("button",{type:"button",onClick:()=>b("mission"),"aria-label":"AgentRun home",children:t.jsx(Cl,{})})}),t.jsxs("nav",{"aria-label":"Navigation",className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-3 pt-3",children:[t.jsxs("div",{className:"space-y-0.5",children:[t.jsxs(gs,{className:"w-full",active:e==="mission",onClick:()=>b("mission"),children:[t.jsx(Du,{className:"size-4 shrink-0","aria-hidden":!0}),"Mission Control"]}),t.jsxs(gs,{className:"w-full",active:e==="factory",onClick:()=>b("factory"),children:[t.jsx(zb,{className:"size-4 shrink-0","aria-hidden":!0}),"Agent Factory"]}),t.jsxs(gs,{className:"w-full",active:e==="playground",onClick:()=>b("playground"),children:[t.jsx(Fu,{className:"size-4 shrink-0","aria-hidden":!0}),"API playground"]}),t.jsxs(gs,{className:"w-full",active:e==="free",onClick:()=>b("free"),children:[t.jsx(Mb,{className:"size-4 shrink-0","aria-hidden":!0}),"Free"]}),t.jsxs(gs,{className:"w-full",active:e==="agents",onClick:()=>b("agents"),children:[t.jsx(Oo,{className:"size-4 shrink-0","aria-hidden":!0}),"Agents"]}),t.jsxs(gs,{className:"w-full",active:e==="suggestions",onClick:()=>b("suggestions"),children:[t.jsx(Hl,{className:"size-4 shrink-0","aria-hidden":!0}),"Suggested"]}),t.jsxs(gs,{className:"w-full",active:e==="templates",onClick:()=>b("templates"),children:[t.jsx(Uu,{className:"size-4 shrink-0","aria-hidden":!0}),"Templates"]}),t.jsxs(gs,{className:"w-full",active:e==="runs",onClick:()=>b("runs"),children:[t.jsx(An,{className:"size-4 shrink-0","aria-hidden":!0}),"Runs"]}),n&&t.jsxs(gs,{className:"w-full",active:e==="triggers",onClick:()=>b("triggers"),children:[t.jsx(Io,{className:"size-4 shrink-0","aria-hidden":!0}),"Triggers"]}),t.jsxs(gs,{className:"w-full",active:e==="dojo",onClick:()=>b("dojo"),children:[t.jsx(bj,{size:16,className:"shrink-0"}),"Learning Dojo"]})]}),s&&t.jsx("div",{"data-sidebar-account":!0,className:"mt-auto border-t pb-2 pt-3",children:t.jsxs(gs,{className:"w-full",active:e==="settings",onClick:()=>b("settings"),children:[t.jsx(ql,{className:"size-4 shrink-0","aria-hidden":!0}),"Settings"]})})]}),t.jsxs("div",{className:"shrink-0 space-y-2 px-3 pb-4 pt-3",children:[t.jsx(RF,{}),t.jsxs(I,{onClick:o,className:"w-full justify-start",children:[t.jsx(q1,{"aria-hidden":!0}),"Sign out"]}),l&&(p?t.jsxs("div",{role:"alertdialog","aria-label":"Sign out everywhere?",onKeyDown:y=>{y.key==="Escape"&&g()},className:"mt-2 space-y-2 border border-destructive/50 px-3 py-2.5 text-small",children:[t.jsx("p",{children:"Signs out every browser and phone signed in to this server, this one too."}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(I,{size:"xs",variant:"destructive",onClick:()=>{x(!1),l()},children:"Sign out everywhere"}),t.jsx(I,{size:"xs",ref:h,onClick:g,children:"Cancel"})]})]}):t.jsx(I,{size:"sm",variant:"ghost",ref:f,onClick:()=>x(!0),className:"mt-1 w-full justify-start text-muted-foreground hover:text-foreground",children:"Sign out everywhere"}))]})]}),t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t.jsx($5,{}),r,t.jsx("main",{ref:k,tabIndex:-1,className:"relative min-h-0 min-w-0 flex-1 overflow-auto outline-none",children:i})]})]})}const ud={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},Gg={sign_in:{title:"Sign in",body:"Sign in to make agents, start runs and follow them on this server."},setup:{title:"Start building",body:"This is the server's first visit: set the owner's password. You sign in with it from now on."},token_link:{title:"Open the server's link",body:"This server has no accounts. Open the link it printed when it started: it signs this browser in, and its code leaves the address."}};function AF({mode:e,code:s=null,codeNeeded:n=!1,onSubmit:r,onNewCode:a,problem:o=null,offer:l=null,host:i=typeof window>"u"?"":window.location.hostname}){const[c,d]=u.useState(""),[p,x]=u.useState([]),[f,h]=u.useState(""),[m,g]=u.useState(s??"");u.useEffect(()=>{s!==null&&g(s)},[s]);const[b,v]=u.useState(o),[k,y]=u.useState(!1),[w,j]=u.useState(null),[S,N]=u.useState(!1),$=async()=>{if(!(!a||S)){N(!0);try{j(await a()),v(null)}catch(A){j(null),v(A instanceof Error?A.message:String(A))}finally{N(!1)}}},R=e==="setup",E=R&&l!==null&&!("sessions"in l&&l.sessions===0),C=R&&(n||s!==null),_=e!=="token_link"&&c.length>0&&(!R||c===f&&c.length>=12)&&(!C||m.trim()!==""),T=async()=>{if(!_||!r)return;y(!0);const A=R&&l&&"candidates"in l?(l.candidates??[]).map(M=>M.id):[],F=await r(c,C&&m.trim()?m.trim():void 0,p.filter(M=>A.includes(M)));y(!1),v(F)};return t.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:t.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[t.jsx(Cl,{}),t.jsx("h1",{className:"mb-3 mt-8 text-2xl font-semibold",children:Gg[e].title}),t.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:Gg[e].body}),e!=="token_link"&&t.jsxs("form",{className:"space-y-5",onSubmit:A=>{A.preventDefault(),T()},children:[C&&t.jsx(Re,{label:"Setup code",id:"setup-code",hint:aM(i).map((A,F)=>t.jsx("span",{className:q("block leading-relaxed",F>0&&"mt-1.5"),children:A},F)),children:t.jsx(ye,{name:"setup-code",value:m,onChange:A=>g(A.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),C&&a&&t.jsxs("div",{className:"!mt-3",children:[t.jsx(I,{type:"button",size:"sm",disabled:S,"aria-busy":S||void 0,onClick:()=>void $(),children:"Get a new code"}),w&&t.jsx("p",{className:"mt-2 text-small leading-relaxed text-foreground",role:"status",children:w})]}),t.jsx(Re,{label:ud[e].label,note:R?"12 characters or more.":void 0,children:t.jsxs("span",{className:q(nl,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Dn,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(ye,{bare:!0,type:"password",value:c,onChange:A=>d(A.target.value),autoComplete:ud[e].autocomplete,autoFocus:!0,"aria-label":ud[e].label,className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),R&&t.jsx(Re,{label:"Again",note:f&&f!==c?"The two passwords differ.":void 0,children:t.jsxs("span",{className:q(nl,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Dn,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(ye,{bare:!0,type:"password",value:f,onChange:A=>h(A.target.value),autoComplete:"new-password","aria-label":"Password again",className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),E&&t.jsx(IF,{offer:l,chosen:p,onChange:x}),t.jsx(I,{type:"submit",variant:"solid",disabled:!_||k,"aria-busy":k||void 0,className:"w-full text-body",children:k?"Signing in":R?"Set password and continue":"Continue"}),b&&t.jsx("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:b}),!R&&t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:["Forgot it? Where the server runs: ",t.jsx("code",{className:"font-mono text-foreground",children:"npx @parcha/agentrun reset-password"})," (add"," ",t.jsx("code",{className:"font-mono text-foreground",children:"--data DIR"})," if you started it with one). For a server you started yourself:"," ",t.jsx("code",{className:"font-mono text-foreground",children:"agentrun-serve reset-password --data DIR"})," (in the image:"," ",t.jsx("code",{className:"font-mono text-foreground",children:"--data /data"}),"). The next visit here sets a new one."]})]})]})})}const Va=(e,s)=>`${e.toLocaleString("en-US")} ${s}${e===1?"":"s"}`,Tk={"claude-code":"Claude Code",codex:"Codex",pi:"pi",opencode:"OpenCode",copilot:"Copilot CLI"},OF=e=>Tk[e]??e,MF=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function Bg(e){const s=Object.keys(Tk),n=r=>s.includes(r)?s.indexOf(r):s.length;return[...new Set(e.flatMap(r=>r.sources))].sort((r,a)=>n(r)-n(a)||r.localeCompare(a)).map(OF)}const md="Import sessions from this machine";function IF({offer:e,chosen:s,onChange:n}){if("counting"in e)return t.jsx(Re,{group:!0,label:md,children:t.jsxs("p",{className:"flex items-center gap-2 text-small text-muted-foreground",role:"status",children:[t.jsx(zn,{}),"Looking for this machine's coding-agent sessions…"]})});const r=e.candidates??[];if(e.sessions===null||e.projects===null||!r.length)return t.jsx(Re,{group:!0,label:md,children:t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:"This machine's sessions couldn't be listed, so there is nothing to choose here. To import them later, run agentrun-serve import with the server stopped."})});const a=r.filter(x=>s.includes(x.id)),o=a.length===r.length,l=Date.now(),i=MF(Bg(r)),c="Tick the projects to import: each becomes an agent, each session a run you can read. Nothing is imported unless you tick it.",d=`${Va(e.sessions,"session")} in ${Va(e.projects,"project")}`,p=e.projects>r.length?`${d}. ${c} The ${r.length.toLocaleString("en-US")} most recently active are listed, with sessions from ${i}.`:`${d}, from ${i}. ${c}`;return t.jsx(Re,{group:!0,label:md,aside:t.jsx(I,{type:"button",size:"xs",variant:"ghost",onClick:()=>n(o?[]:r.map(x=>x.id)),children:o?"Clear":"Select all"}),note:p,hint:t.jsx("span",{"aria-live":"polite",children:a.length?`${Va(a.length,"project")}, ${Va(a.reduce((x,f)=>x+f.sessions,0),"session")} chosen.`:"None chosen: nothing will be imported."}),children:t.jsx("div",{className:"max-h-56 space-y-3 overflow-y-auto border p-3",children:r.map(x=>t.jsx(ec,{name:"import",value:x.id,checked:s.includes(x.id),onChange:f=>n(f.target.checked?[...s,x.id]:s.filter(h=>h!==x.id)),label:t.jsx("span",{className:"break-all font-mono",children:x.name}),note:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block",children:[Va(x.sessions,"session"),Bg([x]).join(", "),...x.last_active?[`active ${Aa(x.last_active,l)} ago`]:[]].join(" · ")}),t.jsx("span",{className:"block break-all font-mono",children:x.path})]})},x.id))})})}function LF({problem:e,starting:s=!1,onRetry:n}){return t.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:t.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[t.jsx(Cl,{}),t.jsx("h1",{className:"mb-3 mt-8 text-2xl font-semibold",children:s?"This server is starting":"Can't read this server's sign-in"}),t.jsx("p",{className:"mb-4 text-prose leading-relaxed text-muted-foreground",children:s?"Its address answers for it until it is up (a first start, a redeploy or a wake can take a minute or two). Trying again…":"The page asked the server whether it has its owner yet, and got no answer it could read, so it can't show setup or sign-in. It asks again on its own."}),t.jsx("p",{className:"mb-6 break-words font-mono text-body text-destructive-text",role:"alert",children:e}),t.jsx(I,{type:"button",variant:"solid",onClick:n,className:"w-full text-body",children:"Retry now"})]})})}const PF=1e4;function Kg(e=location.hash){if(e==="#/dojo")return{section:"dojo"};const s=e.match(/^#\/wrapped(?:\?(.*))?$/);if(s){const i=new URLSearchParams(s[1]??"").get("year");return{section:"wrapped",...i&&/^\d{4}$/.test(i)?{year:Number(i)}:{}}}const n=e.match(/^#\/observations\/([^/?]+)$/);if(n)return{section:"agents",observation:decodeURIComponent(n[1])};if(e==="#/factory"||e==="#/factory/")return{section:"factory"};let r=e.match(/^#\/runs\/([^/?]+)$/);if(r)return{section:"runs",run:decodeURIComponent(r[1])};if(e==="#/races/new")return{section:"runs",newRace:!0};if(r=e.match(/^#\/races\/([^/?]+)$/),r)return{section:"runs",race:decodeURIComponent(r[1])};if(e==="#/compare"||e.startsWith("#/compare?"))return{section:"runs",compare:ZL(e.split("?")[1]??"")};if(e==="#/agents/connect"||e.startsWith("#/agents/connect?")){const i=new URLSearchParams(e.split("?")[1]??"").get("source");return{section:"agents",nativeConnect:!0,...i==="remote"||i==="observe"?{connectionSource:i}:{}}}if(e==="#/agents/new"||e.startsWith("#/agents/new?")){const i=new URLSearchParams(e.split("?")[1]??""),c=i.get("editor")==="true"||i.get("editor")==="",d=i.get("instructions");return{section:"agents",agent:null,...c?{edit:!0,...d?{initialInstructions:d}:{}}:{}}}if(r=e.match(/^#\/agents\/([^/?]+)\/(edit|settings)(?:\?(.*))?$/),r){const i=new URLSearchParams(r[3]??""),c=i.get("tool");return{section:"agents",agent:decodeURIComponent(r[1]),...r[2]==="edit"?{edit:!0}:{tab:"settings"},...i.get("section")==="tools"||i.get("section")==="skills"?{settingsSection:i.get("section")}:{},...c?{tool:c}:{}}}if(r=e.match(/^#\/agents\/([^/?]+)(?:\/([a-z]+))?$/),r)return{section:"agents",agent:decodeURIComponent(r[1]),...r[2]==="edit"?{edit:!0}:r[2]?{tab:r[2]}:{}};if(e.startsWith("#/agents"))return{section:"agents",archived:/[?&]archived=true\b/.test(e)};if(e.startsWith("#/playground")){const i=new URLSearchParams(e.split("?")[1]??""),c=i.get("agent"),d=i.get("operation"),p=i.get("draft");if(d==="apply-template"){const x=i.get("template");return{section:"playground",operation:d,...x?{template:x}:{},...p!==null?{draft:p}:{}}}return{section:"playground",...c?{playgroundAgent:c}:{},...d==="create-agent"||d==="edit-agent"||d==="list-runs"?{operation:d}:{},...p!==null?{draft:p}:{},...d==="list-runs"&&vl.includes(i.get("status"))?{status:i.get("status")}:{},...d==="list-runs"&&i.get("archived")==="true"?{archived:!0}:{},...d==="list-runs"&&!c&&Yg.test(i.get("source")??"")?{source:i.get("source")}:{},...d==="list-runs"&&!c?Vg(i):{}}}if(r=e.match(/^#\/suggestions(?:\?(.*))?$/),r){const i=B5(r[1]);return{section:"suggestions",...i?{repo:i}:{}}}if(r=e.match(/^#\/templates\/install\?(.*)$/),r)return{section:"templates",install:new URLSearchParams(r[1]).get("src")??""};if(r=e.match(/^#\/templates\/([^/?]+)(?:\?(.*))?$/),r){const i=new URLSearchParams(r[2]??"").get("model");return{section:"templates",template:decodeURIComponent(r[1]),...i?{templateModel:i}:{}}}if(e==="#/free")return{section:"free"};if(e.startsWith("#/templates"))return{section:"templates"};if(e==="#/triggers/new")return{section:"triggers",trigger:null,kind:"schedule"};if(e==="#/triggers/new-webhook")return{section:"triggers",trigger:null,kind:"webhook"};if(e==="#/triggers/new-github")return{section:"triggers",trigger:null,kind:"github"};if(e==="#/triggers/new-composio")return{section:"triggers",trigger:null,kind:"composio"};if(e==="#/triggers/new-feed")return{section:"triggers",trigger:null,kind:"feed"};if(e==="#/triggers/new-email")return{section:"triggers",trigger:null,kind:"email"};if(r=e.match(/^#\/triggers\/([^/?]+)(\/edit)?$/),r)return{section:"triggers",trigger:decodeURIComponent(r[1]),...r[2]?{edit:!0}:{}};if(e.startsWith("#/triggers"))return{section:"triggers"};if(r=e.match(/^#\/settings\/mcp(?:\?(.*))?$/),r){const i=j1(r[1]);return{section:"settings",settings:"mcp",signIn:k1(r[1]),...i?{add:i}:{}}}if(r=e.match(/^#\/settings\/github(?:\?(.*))?$/),r){const i=z5(r[1]);return{section:"settings",settings:"github",...i?{github:i}:{}}}if(r=e.match(/^#\/settings(?:\/(keys|harness-keys|api-keys|tools|email|computers|workspace|webhook|slack|demo))?$/),r)return{section:"settings",settings:r[1]??"keys"};if(e===""||e==="#"||e==="#/"||e.startsWith("#/start")||e.startsWith("#/mission"))return{section:"mission"};if(!e.startsWith("#/runs?"))return{section:"runs"};const a=new URLSearchParams(e.slice(7)),o=a.get("agent"),l=a.get("status");return{section:"runs",...o?{runsOf:o}:{},...l&&vl.includes(l)?{status:l}:{},...a.get("archived")==="true"?{archived:!0}:{},...!o&&Yg.test(a.get("source")??"")?{source:a.get("source")}:{},...o?{}:Vg(a)}}const Yg=/^[a-z][a-z0-9-]{0,31}$/,FF=/^[^\u0000-\u001f\u007f]{1,256}$/;function Vg(e){const s=Jg(e.get("from")),n=Jg(e.get("to")),r=e.get("model");return{...s?{from:s}:{},...n?{to:n}:{},...r!==null&&FF.test(r)?{model:r}:{}}}function Jg(e){const s=e==null?void 0:e.match(/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})?)?$/i);if(!s)return;const[n,r,a,o=0,l=0,i=0]=s.slice(1,7).map(m=>m===void 0?void 0:Number(m)),c=Number((s[7]??"").padEnd(3,"0")),d=s[8],p=d?new Date(Date.UTC(n,r-1,a,o,l,i,c)):new Date(n,r-1,a,o,l,i,c),x=d?[p.getUTCFullYear(),p.getUTCMonth()+1,p.getUTCDate(),p.getUTCHours(),p.getUTCMinutes(),p.getUTCSeconds()]:[p.getFullYear(),p.getMonth()+1,p.getDate(),p.getHours(),p.getMinutes(),p.getSeconds()];if(Number.isNaN(p.getTime())||x.join()!==[n,r,a,o,l,i].join())return;if(!d||d.toUpperCase()==="Z")return p.toISOString();const[f,h]=d.slice(1).split(":").map(Number);if(!(f>23||h>59))return new Date(p.getTime()-(d[0]==="-"?-1:1)*(f*60+h)*6e4).toISOString()}const Qg=e=>!!(e.source||e.from||e.to||e.model);function zF({runsOf:e,status:s,archived:n,source:r,from:a,to:o,model:l}){const i=new URLSearchParams;return e&&i.set("agent",e),s&&i.set("status",s),n&&i.set("archived","true"),r&&!e&&i.set("source",r),a&&!e&&i.set("from",a),o&&!e&&i.set("to",o),l&&!e&&i.set("model",l),`#/runs${i.size?`?${i}`:""}`}let hd;function DF(){if(!hd){const{code:e,rest:s}=s0(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${s}`),hd={code:e}}return hd.code}const UF=e=>Math.min(1e3*2**e,3e4),Ak=1e3,WF=30;function qF(e){return e.state==="running"?"Importing this machine's sessions: agents appear as they arrive.":e.state==="stopped"?"The import of this machine's sessions stopped. It goes on when the server starts again.":e.state==="failed"?"The import of this machine's sessions was given up before it finished. The server's log says why.":`Imported ${`${e.runs.toLocaleString("en-US")} session${e.runs===1?"":"s"}`} into ${e.agents.toLocaleString("en-US")} agent${e.agents===1?"":"s"}${e.skipped?`; ${e.skipped.toLocaleString("en-US")} left out`:""}.`}function HF(){const[e]=u.useState(w$),[s,n]=u.useState(null),[r,a]=u.useState(!1),o=u.useRef(null);o.current=s;const l=u.useRef(!1),i=u.useRef(async()=>{}),c=u.useMemo(()=>jp({fetch:e.fetch,onSignedOut:()=>void i.current()}),[e]),[d,p]=u.useState(()=>I5());u.useEffect(()=>L5(p),[]);const[x,f]=u.useState(null);u.useEffect(()=>{if(!d){f(null);return}let E=!0;return $1(async()=>{const{createDemo:C}=await import("./backend-DEgVn5lC.js");return{createDemo:C}},__vite__mapDeps([0,1,2]),import.meta.url).then(({createDemo:C})=>{if(!E)return;const _=C({real:e.fetch});f({...jp({fetch:_.fetch,onSignedOut:()=>void i.current()}),fileUrl:_.fileUrl})},()=>{E&&hu(!1)}),()=>{E=!1}},[d,e]);const[h,m]=u.useState(DF);u.useEffect(()=>{if(s!=="setup")return;const E=()=>{const{code:C,rest:_}=s0(location.hash);C!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${_}`),m(C))};return window.addEventListener("hashchange",E),E(),()=>window.removeEventListener("hashchange",E)},[s]);const[g,b]=u.useState(!1),v=async()=>{const E=await c.session(),C=oh(E)?await c.listAgents().then(()=>200,_=>_ instanceof ge?_.status:0):void 0;return{mode:nM(E,C),codeNeeded:rM(E)}},k=async()=>{const E=await v();return b(E.codeNeeded),E.mode},y=async()=>n(await k());i.current=async()=>{if(!(o.current!=="signed_in"||l.current)){l.current=!0;try{const E=await k();E!=="signed_in"&&o.current==="signed_in"&&(a(!0),n(E))}catch{}finally{l.current=!1}}};const[w,j]=u.useState(null),[S,N]=u.useState(0);u.useEffect(()=>{let E=!0,C;return v().then(_=>{!E||o.current!==null||(b(_.codeNeeded),n(_.mode),j(null))},_=>{if(!E||o.current!==null)return;const T=UF(S),A=_ instanceof ge?_:null,F=(A==null?void 0:A.code)==="http_error",M=F&&[502,503,504].includes(A.status);j({problem:A===null?st(_):M?`Its address answered ${A.status}, not the server.`:`GET /v2/auth/session answered ${A.status}${F?", not as this server answers":`: ${A.message}`}`,starting:M}),C=setTimeout(()=>N(L=>L+1),T)}),()=>{E=!1,clearTimeout(C)}},[c,S]);const[$,R]=u.useState(null);return u.useEffect(()=>{if(s!=="setup")return;let E=!0;return(async()=>{for(let C=!1;E;){const _=await c.setupImport().then(T=>T,()=>{});if(!E)return;if(_===void 0&&C)return void R({projects:null,sessions:null});if(_!==void 0&&(!_||!("counting"in _||"sessions"in _)||(R(_),C=!0,!("counting"in _))))return;await new Promise(T=>setTimeout(T,Ak))}})(),()=>{E=!1}},[c,s]),s===null&&w!==null?t.jsx(LF,{problem:w.problem,starting:w.starting,onRetry:()=>N(E=>E+1)}):s===null?t.jsx(Dx,{connection:e,children:t.jsx(GF,{})}):s!=="signed_in"?t.jsx(AF,{mode:s,code:h,codeNeeded:g,offer:$,problem:r&&s==="sign_in"?"You were signed out. Sign in to go on.":null,onSubmit:async(E,C,_)=>{try{return await(s==="setup"?c.setup(E,C,_):c.signIn(E)),a(!1),n("signed_in"),null}catch(T){return T instanceof ge&&T.status===403&&s==="setup"&&await y().catch(()=>{}),T instanceof ge?cM(T):T instanceof Error?T.message:String(T)}},onNewCode:async()=>{try{return oM(window.location.hostname,await c.setupCode())}catch(E){throw E instanceof ge&&E.status===403&&await y().catch(()=>{}),new Error(E instanceof ge?lM(E):E instanceof Error?E.message:String(E))}}},s):d&&!x?t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Opening the demo…"}):t.jsx(Dx,{connection:e,children:t.jsx(BF,{v2:d&&x?x:c,demo:d,onSignedOut:()=>{a(!1),n("sign_in")}})})}function GF(){return rh().state==="offline"?t.jsx(E5,{}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function BF(e){const s=u.useMemo(Er,[e.v2]);return t.jsx(KF,{...e},s)}function KF({v2:e,onSignedOut:s,demo:n=!1}){var _h,$h,Eh,Rh,Th,Ah,Oh,Mh,Ih,Lh,Ph,Fh,zh,Dh,Uh,Wh,qh,Hh,Gh,Bh,Kh,Yh,Vh,Jh,Qh,Xh,Zh,ef,tf,sf,nf,rf,af,of,lf,cf,df,uf,mf,hf,ff,pf,xf,gf,bf,vf,yf,wf,jf;const{writable:r,whyNot:a}=S3(e),[o,l]=u.useState(null),[i,c]=u.useState(()=>Kg()),[d,p]=u.useState(null),x=(($h=(_h=d==null?void 0:d.features)==null?void 0:_h.triggers)==null?void 0:$h.routes)===!0,[f,h]=u.useState(new Map);u.useEffect(()=>{if(!x)return;let re=!0;return e.listTriggers().then(pe=>{re&&h(new Map(pe.triggers.map(je=>[je.id,{name:je.name,kind:je.source.kind}])))},()=>{}),()=>{re=!1}},[e,x,i.section,i.trigger]);const[m,g]=u.useState(null),[b,v]=u.useState(null),[k,y]=u.useState(0),[w,j]=u.useState("30d"),S=w==="7d"?7:30,N=bm(e,{active:i.section==="mission"||i.section==="runs"&&!i.run&&!i.race&&!i.compare&&!i.runsOf&&!i.archived&&!i.status&&!Qg(i),days:S}),[$,R]=u.useState(null),[E,C]=u.useState(!1),[_,T]=u.useState(!1),A=u.useRef(!1),[F,M]=u.useState(null),[L,O]=u.useState(null),[U,K]=u.useState(null),[Z,D]=u.useState(0),Y=u.useRef(null),[P,B]=u.useState(!1),[V,G]=u.useState(!1),[z,ne]=u.useState(!1),[le,H]=u.useState(null),[ee,we]=u.useState(null),[fe,ae]=u.useState(!1),[ue,be]=u.useState({}),[he,X]=u.useState(!1),ie=u.useRef(0),[W,Ne]=u.useState([]),[_e,Ie]=u.useState(null),[xe,Ye]=u.useState(null),He=u.useRef(-1),[me,Fe]=u.useState(null),[ut,se]=u.useState(0),ve=u.useRef(0),Se=re=>{Ja(re)||(location.hash=re)},[Pe,De]=u.useState(null),[at,Ct]=u.useState(0);u.useEffect(()=>{let re=!0;return(async()=>{let pe=!1;for(let je=0;re&&je<WF;){const Ze=await e.setupImport().then(Ve=>Ve,()=>{});if(!re)return;if(Ze===void 0)je+=1;else{if(je=0,!Ze||!("state"in Ze))return;if(De(Ze),Ze.state!=="running")return void(pe&&Ct(Ve=>Ve+1));pe=!0}await new Promise(Ve=>setTimeout(Ve,Ak))}})(),()=>{re=!1}},[e]),u.useEffect(()=>{const re=()=>{const pe=T1();Ja(location.hash,()=>{pe&&history.go(-pe)})?pe&&history.go(pe):c(Kg())};return window.addEventListener("hashchange",re),()=>window.removeEventListener("hashchange",re)},[]),u.useEffect(()=>R1(),[]);const ze=u.useRef(0),ht=u.useRef(!1),[Bt,nt]=u.useState(!1),Pt=()=>{const re=++ze.current;return e.capabilities().then(pe=>(re===ze.current&&(p(pe),nt(!1)),pe),()=>(re===ze.current&&nt(!0),null))},Le=()=>Pt().then(re=>re!==null);u.useEffect(()=>{Le()},[e]),u.useEffect(()=>{if(ie.current&&i.section!=="runs"&&i.section!=="mission"&&i.section!=="factory"&&i.section!=="triggers"&&He.current===at)return;He.current=at;const re=++ie.current;X(!1),Promise.allSettled([!1,!0].map(pe=>rn(je=>e.listAgents({archived:pe,cursor:je}),je=>je.agents))).then(pe=>{if(re!==ie.current)return;const je=Object.fromEntries(pe.flatMap(Ve=>Ve.status==="fulfilled"?Ve.value:[]).map(Ve=>[Ve.agent_id,Ve.definition.name??Ve.agent_id])),Ze=pe.every(Ve=>Ve.status==="fulfilled");be(Ve=>Ze?je:{...Ve,...je}),X(Ze)})},[e,i,at]);const vt={status:i.status,archived:i.archived,source:i.source,from:i.from,to:i.to,model:i.model};u.useEffect(()=>{if(i.section!=="runs"||i.run||i.race||i.compare)return;const re=++ve.current;H(null),Fe(null),(i.runsOf?e.listAgentRuns(i.runsOf,50,null,vt):e.listRuns(50,null,vt)).then(pe=>{re===ve.current&&(H(pe.runs),we(pe.next_cursor))}).catch(pe=>{re===ve.current&&Fe(ot(pe,"the runs"))})},[e,i,at,ut]);const _t=re=>{var pe;return ue[re]??((pe=ns==null?void 0:ns.find(je=>je.agent_id===re))==null?void 0:pe.definition.name)??(he?re:"")},J=d,oe={harnesses:(J==null?void 0:J.harnesses)??[],tools:xp(J==null?void 0:J.tools),thinking:((Eh=J==null?void 0:J.features)==null?void 0:Eh.thinking)??[],...typeof((Rh=d==null?void 0:d.limits)==null?void 0:Rh.free_model_requests)=="number"?{freeRequests:d.limits.free_model_requests}:{},places:B_(d),mcp:!!((Th=d==null?void 0:d.features)!=null&&Th.mcp_client),mcpHarnesses:(Oh=(Ah=d==null?void 0:d.features)==null?void 0:Ah.mcp_client)==null?void 0:Oh.harnesses},$e=z4(J==null?void 0:J.tools),Ae=U4(J==null?void 0:J.tools),ce=[...(Ih=(Mh=d==null?void 0:d.features)==null?void 0:Mh.tool_keys)!=null&&Ih.routes?["keys"]:[],...(Ph=(Lh=d==null?void 0:d.features)==null?void 0:Lh.harness_keys)!=null&&Ph.routes?["harness-keys"]:[],...(zh=(Fh=d==null?void 0:d.features)==null?void 0:Fh.api_keys)!=null&&zh.routes?["api-keys"]:[],...$e.length||Ae.length?["tools"]:[],"mcp","github","email","computers","workspace",...(Uh=(Dh=d==null?void 0:d.features)==null?void 0:Dh.webhooks)!=null&&Uh.routes?["webhook"]:[],...(qh=(Wh=d==null?void 0:d.features)==null?void 0:Wh.slack)!=null&&qh.routes?["slack"]:[],"demo"],Ce=n?["demo"]:ce,et=n?"demo":i.settings??"keys",Mt=re=>Se({runs:"#/runs",agents:"#/agents",playground:"#/playground",dojo:"#/dojo",mission:"#/",factory:"#/factory",triggers:"#/triggers",templates:"#/templates",suggestions:"#/suggestions",free:"#/free",wrapped:"#/wrapped",settings:`#/settings/${Ce[0]??"keys"}`}[re]),yt=u.useRef(Yn()).current,[te,Ue]=u.useState(null),[tt,it]=u.useState(!1),Xt=re=>{Ue(`ollama/${re}`),Le()},os=async re=>{const pe=_0(oe.harnesses,te);if(!pe)return"This server has no model to run it on yet.";try{const je=await mI(e,re,pe,yt);return Se(`#/runs/${encodeURIComponent(je)}`),null}catch(je){return st(je)}},Cn=((m==null?void 0:m.analytics.by_source)??[]).filter(re=>re.source!=="live").reduce((re,pe)=>re+pe.runs,0),[ns,Oe]=u.useState(null),[Ge,lt]=u.useState([]),[Kt,is]=u.useState(null),[si,ni]=u.useState({revision:""}),Vn=u.useRef(Kt);Vn.current=Kt;const[Pa,Jn]=u.useState(null),[ri,Fa]=u.useState(0),Qn=u.useRef(0);u.useEffect(()=>{Oe(null),Jn(null),is(null),Vn.current=null},[e,i.section,i.operation,i.playgroundAgent]),u.useEffect(()=>{if(i.section!=="playground"||i.operation)return;Jn(null);const re=++Qn.current;return rn(pe=>e.listAgents({cursor:pe}),pe=>pe.agents).then(pe=>{var Ve;if(re!==Qn.current)return;const je=pe.filter(Zs=>!Zs.archived_at),Ze=Vn.current??i.playgroundAgent;if(Ze&&!je.some(Zs=>Zs.agent_id===Ze)){Oe(null),is(null),Jn("The selected agent is unavailable or archived. Choose another agent from Agents.");return}Oe(pe),is(Ze??((Ve=je[0])==null?void 0:Ve.agent_id)??null)}).catch(pe=>{if(re===Qn.current){const je=ot(pe,"the agents");Jn(`${je.why} ${je.next}${je.said?` (${je.said})`:""}`)}}),()=>{Qn.current++}},[e,i.section,i.operation,i.playgroundAgent,ri,at]),u.useEffect(()=>{if(i.section!=="mission")return;let re=!0;A.current=!0,v(null),T(!0);const pe=ol(w);return Promise.all([e.statsOver({...pe?{from:pe}:{},...$?{agent:$}:{}}),E?Promise.resolve({runs:[]}):$?e.listAgentRuns($,10):e.listRuns(10)]).then(([je,Ze])=>{re&&(g($$(je,Ze.runs)),$||K(Ve=>Ve||m5(Ze.runs,je.analytics.by_source)))}).catch(je=>{re&&v(ot(je,"Mission Control"))}).finally(()=>{re&&(A.current=!1,T(!1))}),()=>{re=!1,A.current=!1}},[e,i.section,k,w,$,E,at]),ah(()=>y(re=>re+1)),u.useEffect(()=>{if(i.section!=="mission")return;const re=()=>{!document.hidden&&!A.current&&y(je=>je+1)};window.addEventListener("focus",re),document.addEventListener("visibilitychange",re);const pe=setInterval(re,15e3);return()=>{window.removeEventListener("focus",re),document.removeEventListener("visibilitychange",re),clearInterval(pe)}},[i.section]),u.useEffect(()=>{if(i.section!=="mission"){Y.current=null,Ie(null),Ye(null);return}let re=!0;const pe=Y,je=Ft=>rn(ls=>e.listRuns(50,ls,{status:Ft}),ls=>ls.runs,2),Ze=()=>rn(Ft=>e.listAgents({archived:!1,cursor:Ft}),Ft=>Ft.agents).then(Ft=>{re&&(Ne(Ft.filter(ls=>il(ls)>0).map(ls=>({agent_id:ls.agent_id,name:ls.definition.name??ls.agent_id,pending:il(ls)}))),Ie(Ft),Ye(null))},Ft=>{re&&Ye(st(Ft))}),Zs=f5(()=>Promise.allSettled([je("input_required"),je("failed"),je("working"),Ze()]).then(([Ft,ls,ii])=>{var li,Ss,kf;if(!re)return;const _n=[Ft,ls,ii],Ec=Date.now()-u5;if(O(Mx(null,_n).problem),((li=_n[0])==null?void 0:li.status)==="fulfilled"&&B(!0),((Ss=_n[1])==null?void 0:Ss.status)==="fulfilled"){G(!0);const ci=_n[1].value.map($n=>$n.run_id),Mr=pe.current;Mr&&ci.some($n=>!Mr.has($n))&&y($n=>$n+1),pe.current=new Set(ci)}((kf=_n[2])==null?void 0:kf.status)==="fulfilled"&&ne(!0),M(ci=>{const{needs:Mr}=Mx(ci,_n);return{asking:Mr.asking.filter(Hj),failed:Mr.failed.filter($n=>Date.parse($n.ended_at??$n.created_at)>Ec),live:Mr.live}})}),1e4);return()=>{re=!1,Zs()}},[e,i.section,Z]);const ai=u.useRef(mw()).current,Q=()=>setTimeout(()=>D(re=>re+1),2500),Te=async(re,pe)=>{try{return await uw(ai(re),re,pe,e.sendMessage),Q(),null}catch(je){return st(je)}},rt=u.useRef(new Map).current,Ut=async re=>{const pe=[];try{for(const je of re){const Ze=h5(je.kind==="workflow"?je:await e.getRun(je.run_id));if("refusal"in Ze)throw new Error(Ze.refusal);const Ve=rt.get(je.run_id)??Er();rt.set(je.run_id,Ve),await e.startRun(je.agent_id,Ze.body,Ve),pe.push(je.run_id)}return Q(),{started:pe,problem:null}}catch(je){return pe.length&&Q(),{started:pe,problem:st(je)}}},Ps=async re=>{try{return await e.stop(re),Q(),null}catch(pe){return st(pe)}},Xn=async(re,pe,je,Ze,Ve)=>{let Zs=null;try{await e.answerApproval(re,pe,je,Ze,Ve)}catch(Ft){Zs=U0(Ft)}return D(Ft=>Ft+1),Zs},Zn=async(re,pe)=>{let je=null;try{await e.handBackComputer(re,pe)}catch(Ze){je=ku(Ze,"hand")}return D(Ze=>Ze+1),je},rs=u.useRef(0),Tr=re=>{const pe=++rs.current;rn(je=>e.listRevisions(re,je),je=>je.revisions).then(je=>{pe===rs.current&&lt(je)}).catch(()=>{})};u.useEffect(()=>{++rs.current,lt([]),ni({revision:""}),Kt&&Tr(Kt)},[e,Kt]);const[Ok,Mk]=u.useState(0),Ik=async(re,pe,je)=>{const Ze=performance.now();try{const Ve=await e.startRun(re,pe,je);return{status:Ve.status,ms:Math.round(performance.now()-Ze),body:Ve.run,runId:Ve.run.run_id}}catch(Ve){return nh(Ve,Math.round(performance.now()-Ze))}finally{Mk(Ve=>Ve+1)}},Lk=async re=>{const{agent:pe,etag:je}=await e.getAgent(re),Ze=pe.definition.tools??[],Ve=await e.computers().then(Ss=>Ss.kinds,()=>null),Zs=async()=>{const Ss=await Pt();return tu({kind:"none"},Ze,xp(Ss==null?void 0:Ss.tools),Ve)},Ft=tu({kind:"none"},Ze,oe.tools,Ve)??await Zs();if(!Ft)throw new Error("the server's tools could not be read, so which of them run only in a box is unknown. Try again.");const{unchanged:ls,...ii}=$r(pe,Ft,"Moved to the runner, where Claude Code's login on this machine runs it");if(ls)return{revision:pe.revision,saved:!1,dropped:[]};const _n=new Set(ii.definition.tools??[]),Ec=(pe.definition.tools??[]).filter(Ss=>!_n.has(Ss)),li=await e.updateDefinition(re,ii,je);return Fa(Ss=>Ss+1),Vn.current===re&&Tr(re),{revision:li.agent.revision,saved:!0,dropped:Ec}},gh=((Hh=d==null?void 0:d.features)==null?void 0:Hh.efforts)??[],oi=d?((Gh=d.features)==null?void 0:Gh.learning)??null:void 0;oe.learning=oi??void 0;const bh={...oe,routePrefix:(Bh=J==null?void 0:J.models)==null?void 0:Bh.route_prefix,decisionProvider:e$(d==null?void 0:d.workflows),mcp:!!((Kh=d==null?void 0:d.features)!=null&&Kh.mcp_client),mcpHarnesses:(Vh=(Yh=d==null?void 0:d.features)==null?void 0:Yh.mcp_client)==null?void 0:Vh.harnesses},Ar=(Jh=d==null?void 0:d.models)==null?void 0:Jh.ready;u.useEffect(()=>{var Ze;if(Ar!==!1&&((Ze=d==null?void 0:d.learning_model)==null?void 0:Ze.ready)!==!1)return;const re=()=>{ht.current||(ht.current=!0,Le().finally(()=>{ht.current=!1}))},pe=()=>Le(),je=setInterval(re,PF);return window.addEventListener("focus",pe),()=>{clearInterval(je),window.removeEventListener("focus",pe)}},[e,Ar,(Qh=d==null?void 0:d.learning_model)==null?void 0:Qh.ready]);const[er,Sc]=u.useState(null);u.useEffect(()=>{if(Ar!==!1)return;let re=!0;return e.chatGPT().then(pe=>{re&&Sc(Bi(pe))},()=>{re&&Sc(null)}),()=>{re=!1}},[e,Ar]);const vh=((Xh=d==null?void 0:d.features)==null?void 0:Xh.claude_login)===!0,yh=i.section==="settings",[Pk,Cc]=u.useState(!1);u.useEffect(()=>{if(Ar!==!1||!vh){Cc(!1);return}if(yh)return;let re=!0;return e.claudeLogin().then(pe=>{var je;re&&Cc(((je=Ri(pe))==null?void 0:je.state)==="signed_in")},()=>{re&&Cc(!1)}),()=>{re=!1}},[e,Ar,vh,yh,Ok]);const[wh,jh]=u.useState(!1),[kh,_c]=u.useState(!1),Fk=re=>{Sc(re),(re.state==="pending"||re.state==="signed_in")&&jh(!0),re.state==="signed_in"&&Le()},Or=ns==null?void 0:ns.find(re=>re.agent_id===Kt),zk=Or==null?void 0:Or.definition,Xs=si.revision?si.definition:zk,Dk=(Xs==null?void 0:Xs.native)||It(Xs),$c=Xs&&Or?(Zh=ky({kind:Or.kind,definition:Xs},oe.places))==null?void 0:Zh.place:void 0,Uk=((tf=(ef=oe.places)==null?void 0:ef.defaultPlace)==null?void 0:tf.mode)==="runner",Wk=Pk&&((sf=d==null?void 0:d.models)==null?void 0:sf.needs)!=="model"&&(Or?(Xs==null?void 0:Xs.harness)===y1&&w1(Xs.model)&&($c==null?void 0:$c.mode)==="runner":Uk),Nh=i.operation?i.playgroundAgent:Kt??i.playgroundAgent,Sh=!Dk&&((nf=d==null?void 0:d.models)==null?void 0:nf.ready)===!1&&!Wk&&t.jsx(CO,{needs:d.models.needs,source:d.models.source,model:d.models.default,settings:((af=(rf=d.features)==null?void 0:rf.tool_keys)==null?void 0:af.routes)===!0&&d.features.tool_keys.at_rest==="sealed",chatgpt:(er==null?void 0:er.state)==="signed_out"||(er==null?void 0:er.state)==="expired"}),Ch=t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"sr-only",htmlFor:"api-operation",children:"API operation"}),t.jsx(qe,{id:"api-operation",label:"API operation",steady:!0,value:i.operation??"run",onChange:re=>{const pe=Nh,je=new URLSearchParams;re!=="run"&&je.set("operation",re),re!=="create-agent"&&re!=="apply-template"&&pe&&je.set("agent",pe),Se(`#/playground${je.size?`?${je}`:""}`)},options:[{value:"create-agent",label:"POST · Create an agent"},{value:"apply-template",label:"POST · Apply a template"},{value:"run",label:"POST · Start a run"},{value:"list-runs",label:"GET · Query runs"},{value:"edit-agent",label:"PUT · Edit agent",disabled:!Nh}]})]});return t.jsx(Dj.Provider,{value:f,children:t.jsx(TF,{active:i.section,settings:ce.length>0,triggers:x,onNavigate:Mt,onSignOut:()=>{const re=()=>void e.signOut().then(s,pe=>l(pe instanceof ge?pe.message:"The sign-out did not reach the server. Try again."));Ja(null,re)||re()},onSignOutEverywhere:()=>{const re=()=>void e.signOutEverywhere().then(s,pe=>l(pe instanceof ge?pe.message:"The sign-out did not reach the server. Try again."));Ja(null,re)||re()},banners:t.jsxs(t.Fragment,{children:[n&&t.jsx(A5,{onOff:()=>{hu(!1),location.hash="#/settings/demo"}}),o&&t.jsxs("p",{className:"border-b bg-card px-5 py-3 font-mono text-body text-destructive-text md:px-8",role:"alert",children:["Not signed out: ",o]}),Pe&&t.jsxs("p",{className:"flex items-center gap-3 border-b bg-card px-5 py-3 font-mono text-body md:px-8",role:"status",children:[t.jsx("span",{className:"flex-1",children:qF(Pe)}),Pe.state!=="running"&&t.jsx(I,{size:"xs",type:"button",onClick:()=>De(null),children:"Dismiss"})]})]}),children:i.section==="settings"?t.jsx(r3,{active:et,offered:Ce,children:et==="demo"?t.jsx(T5,{on:n,onChange:hu,v2:e,go:Se}):i.settings==="harness-keys"?t.jsx(k5,{v2:e,writable:r,whyNot:a,onChange:()=>void Le()}):i.settings==="api-keys"?t.jsx(n5,{v2:e,writable:r,whyNot:a,origin:location.origin}):i.settings==="tools"?t.jsx(F5,{v2:e,choices:$e,gates:Ae,harnesses:oe.harnesses,mcp:!!oe.mcp,onSaved:Le,onOpen:Le}):i.settings==="mcp"?t.jsx(oO,{v2:e,signIn:i.signIn,add:i.add,writable:r,whyNot:a,choices:$e}):i.settings==="github"?t.jsx(sO,{v2:e,returned:i.github}):i.settings==="email"?t.jsx(OO,{v2:e,writable:r,whyNot:a}):i.settings==="computers"?t.jsx(qO,{v2:e,writable:r,whyNot:a}):i.settings==="workspace"?t.jsx(tM,{v2:e,writable:r,whyNot:a}):i.settings==="webhook"?t.jsx(IO,{v2:e}):i.settings==="slack"?t.jsx(FO,{v2:e,writable:r,whyNot:a}):t.jsx(y5,{v2:e,onChange:Le,writable:r,whyNot:a,harnesses:oe.harnesses,plan:t.jsxs(t.Fragment,{children:[t.jsx(E3,{v2:e,writable:r,whyNot:a,source:(of=d==null?void 0:d.models)==null?void 0:of.source,defaultModel:(lf=d==null?void 0:d.models)==null?void 0:lf.default,routePrefix:(cf=d==null?void 0:d.models)==null?void 0:cf.route_prefix,onChange:()=>void Le()}),t.jsx(M3,{v2:e,writable:r,whyNot:a,available:d?((df=d.features)==null?void 0:df.claude_login)!==!1:Bt,onChange:()=>void Le()}),t.jsx(z3,{v2:e,writable:r,whyNot:a,onChange:()=>void Le()})]})})}):i.section==="dojo"?t.jsx(mA,{v2:e,server:oi,modelAccess:d==null?void 0:d.learning_model},at):i.section==="mission"?t.jsx("div",{className:"flex h-full flex-col",children:t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(J6,{yearLink:!n,observed:N,agents:_e,agentsError:xe,view:m,error:b,onRetry:()=>y(re=>re+1),actions:t.jsxs(t.Fragment,{children:[t.jsx(I,{size:"icon","aria-label":"Refresh Mission Control",disabled:_,onClick:()=>{y(re=>re+1),D(re=>re+1),N.refresh()},children:t.jsx(pn,{className:"size-4","aria-hidden":!0})}),E&&$?t.jsx(xt,{label:"Ask about this session",prompt:F_(location.origin,$,ol(w)),playgroundHref:xm($),playgroundLabel:"Connected agent"}):t.jsx(xt,{label:"Ask about runs",prompt:tc(location.origin,$??void 0),playgroundHref:vm($??void 0)}),t.jsx(xh,{variant:"primary"})]}),scope:{range:w,onRange:j,agent:$,onAgent:re=>{var pe;C(!!re&&!!((pe=N.data)!=null&&pe.sessions.some(je=>je.id===re))),R(re)},refreshing:_&&m!==null},asking:F&&P?F.asking.length:null,failed:F&&V?qj(F.failed):null,live:F&&z?F.live.length:null,needsYou:F&&t.jsx(hF,{asking:F.asking,failed:F.failed,failedAll:m==null?void 0:m.runs.failed,live:F.live,learning:W,problem:L,agentName:_t,onAnswer:Te,onApprove:Xn,onHandBack:Zn,onRunAgain:Ut,onStop:Ps}),startHere:U===!1&&!((uf=N.data)!=null&&uf.sessions.length)?t.jsx(SF,{harnesses:oe.harnesses,tools:oe.tools,onTry:os,imported:Cn,keySettings:((hf=(mf=d==null?void 0:d.features)==null?void 0:mf.tool_keys)==null?void 0:hf.routes)===!0&&d.features.tool_keys.at_rest==="sealed",modelSetup:d&&(d.models.ready===!1||wh||kh)?t.jsxs(t.Fragment,{children:[(d.models.ready===!1||kh)&&t.jsx(Kx,{v2:e,onPulling:()=>_c(!0),onReady:re=>{_c(!0),Xt(re)},onDone:()=>_c(!1)}),(d.models.ready===!1||wh)&&t.jsx(SO,{v2:e,needs:d.models.needs,model:d.models.default,source:d.models.source,routePrefix:d.models.route_prefix,capsRead:d.models,onSaved:Le,writable:r,whyNot:a,plan:er,harnesses:oe.harnesses,onPlan:Fk,onDone:()=>jh(!1)})]}):void 0}):void 0})})}):i.section==="wrapped"?t.jsx(bL,{v2:e,year:i.year,go:Se}):i.section==="suggestions"?t.jsx(xI,{v2:e,repo:i.repo,go:Se}):i.section==="factory"?t.jsx(mF,{v2:e,agentName:_t}):i.section==="templates"?t.jsx(ig,{v2:e,name:i.template,install:i.install,model:i.templateModel,freeIds:J?wl(J.harnesses).map(re=>re.id):void 0,go:Se},i.install!==void 0?`install:${i.install}`:`${i.template??""}:${i.templateModel??""}`):i.section==="free"?t.jsx(hI,{v2:e,harnesses:oe.harnesses,tools:J==null?void 0:J.tools,freeRequests:oe.freeRequests,routePrefix:(ff=J==null?void 0:J.models)==null?void 0:ff.route_prefix,go:Se,fit:t.jsx(Kx,{v2:e,onPulling:()=>it(!0),onReady:Xt,onDone:()=>it(!1)}),fitHeld:tt,localModel:te}):i.section==="triggers"?t.jsx(xM,{v2:e,view:{trigger:i.trigger,kind:i.kind,edit:i.edit},go:Se,agentName:_t,minEvery:(xf=(pf=d==null?void 0:d.features)==null?void 0:pf.triggers)==null?void 0:xf.min_every_s,failuresToPause:(bf=(gf=d==null?void 0:d.features)==null?void 0:gf.triggers)==null?void 0:bf.failures_to_pause,publicUrl:(yf=(vf=d==null?void 0:d.features)==null?void 0:vf.triggers)==null?void 0:yf.public_url}):i.section==="playground"?t.jsxs("section",{className:"flex h-full min-h-0 flex-col",children:[t.jsx("header",{className:q(Lt,"gap-2 px-5"),children:t.jsxs("h1",{className:ss,children:[t.jsx(Fu,{className:"size-4","aria-hidden":!0}),"API playground"]})}),(i.operation||!ns)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-5 py-3 md:px-6",children:[Ch,t.jsx("span",{className:"min-w-0 break-all font-mono text-small text-muted-foreground",children:i.operation==="apply-template"?`/v2/templates/${i.template?encodeURIComponent(i.template):"{template}"}/apply`:i.operation==="list-runs"?i.playgroundAgent?`/v2/agents/${i.playgroundAgent}/runs`:"/v2/runs":i.operation==="create-agent"?"/v2/agents":i.operation==="edit-agent"?`/v2/agents/${i.playgroundAgent??"{agent_id}"}/definition`:"/v2/agents/{agent_id}/runs"})]}),i.operation==="apply-template"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(ig,{v2:e,name:i.template,go:Se,playground:!0,draft:i.draft,freeIds:J?wl(J.harnesses).map(re=>re.id):void 0},i.template??"")}):i.operation==="list-runs"?t.jsx(Z3,{v2:e,origin:location.origin,agentId:i.playgroundAgent,filter:{status:i.status,archived:i.archived,source:i.source,from:i.from,to:i.to,model:i.model}},`list:${i.playgroundAgent??""}:${i.status??""}:${i.archived??!1}:${i.source??""}:${i.from??""}:${i.to??""}:${i.model??""}`):i.operation?t.jsx(t5,{v2:e,operation:i.operation,origin:location.origin,agentId:i.playgroundAgent,draft:i.draft,harnesses:oe.harnesses,routePrefix:(wf=J==null?void 0:J.models)==null?void 0:wf.route_prefix},`${i.operation}:${i.playgroundAgent??""}:${i.draft??""}`):t.jsxs(t.Fragment,{children:[!ns&&Sh,Pa&&t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"text-lead text-destructive-text",children:["The agents could not be read: ",Pa]}),t.jsx(I,{size:"sm",className:"mt-3",type:"button",onClick:()=>Fa(re=>re+1),children:"Try again"})]}),ns&&t.jsx(Q3,{lead:Ch,notice:Sh,agents:ns.filter(re=>!re.archived_at),revisions:Ge,efforts:gh,origin:location.origin,agentId:Kt??void 0,onAgent:is,onRevision:(re,pe)=>ni({revision:re,definition:pe}),onSend:Ik,limits:d==null?void 0:d.limits,...n?{upload:Wx}:{},removeUpload:e.deleteUpload,onMoveToRunner:Lk,onOpenRun:re=>Se(`#/runs/${encodeURIComponent(re)}`),live:re=>t.jsx(Mg,{v2:e,runId:re,caps:d,agentName:_t},re)})]})]}):i.section==="agents"?i.observation?t.jsx(d$,{v2:e,sessionId:i.observation,go:Se}):i.nativeConnect?t.jsx(jF,{v2:e,go:Se,initialSource:i.connectionSource}):i.agent===void 0?t.jsx(g3,{v2:e,archived:!!i.archived,go:Se,learning:oi},at):i.agent!==null?t.jsx(nA,{v2:e,agentId:i.agent,tab:i.edit?"settings":i.tab,learning:oi,routePrefix:(jf=J==null?void 0:J.models)==null?void 0:jf.route_prefix,harnesses:oe.harnesses,efforts:gh,limits:d==null?void 0:d.limits,places:oe.places,go:Se,...n?{upload:Wx}:{},renderEditor:(re,pe)=>t.jsx(Cx,{initialStep:i.settingsSection,embedded:!0,onAgent:re,onEditPromptChange:pe,v2:e,choices:$e,gates:Ae,focusTool:i.tool,caps:bh,agentId:i.agent,go:Se},`${i.agent}:${i.edit?"edit":"settings"}:${i.settingsSection??""}:${i.tool??""}`)},i.agent):t.jsx(Cx,{v2:e,choices:$e,gates:Ae,caps:bh,initialInstructions:i.initialInstructions,agentId:null,go:Se},`new:${i.edit?"legacy-editor":"editor"}:${i.initialInstructions??""}`):i.newRace?d?t.jsx(Y6,{v2:e,harnesses:oe.harnesses,tools:oe.tools,places:oe.places??null,go:Se}):Bt?t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(ke,{tone:"error",actions:t.jsx(I,{size:"xs",onClick:()=>void Le(),children:"Try again"}),children:"The server's harnesses could not be read, so there is nothing to pick a lane from yet."})}):t.jsx(oc,{}):i.race?t.jsx(H6,{v2:e,label:i.race},i.race):i.compare?t.jsx(V6,{v2:e,ids:i.compare},i.compare.join(",")):i.run?t.jsx(Mg,{v2:e,runId:i.run,caps:d,agentName:_t},i.run):t.jsx(G3,{observations:!i.runsOf&&!i.archived&&!i.status&&!Qg(i)?N:void 0,runs:le,agentName:_t,agentId:i.runsOf,error:me,onRetry:()=>se(re=>re+1),onOpen:re=>Se(`#/runs/${encodeURIComponent(re)}`),loadingMore:fe,filter:vt,onFilter:re=>Se(zF({runsOf:i.runsOf,...re})),onMore:ee?()=>{const re=ve.current;ae(!0),(i.runsOf?e.listAgentRuns(i.runsOf,50,ee,vt):e.listRuns(50,ee,vt)).then(pe=>{re===ve.current&&(H(je=>Gd(je??[],pe.runs)),we(pe.next_cursor),Fe(null))}).catch(pe=>Fe(ot(pe,"more runs"))).finally(()=>ae(!1))}:void 0})})})}N1();S1.createRoot(document.getElementById("root")).render(t.jsx(u.StrictMode,{children:t.jsx(T_,{children:t.jsx(HF,{})})}));export{VF as D,JF as d};
639
+ `;function Cl(){return t.jsx("span",{role:"img","aria-label":"AgentRun",className:"inline-flex h-8 align-middle text-foreground [&>svg]:h-full [&>svg]:w-auto",dangerouslySetInnerHTML:{__html:CF}})}const _F={mission:"Mission Control",factory:"Agent Factory",playground:"Playground",agents:"Agents",runs:"Runs",dojo:"Dojo",templates:"Templates",suggestions:"Suggested agents",triggers:"Triggers",wrapped:"Wrapped",settings:"Settings",free:"Free"},$F={mission:"#/",factory:"#/factory",playground:"#/playground",agents:"#/agents",runs:"#/runs",dojo:"#/dojo",templates:"#/templates",suggestions:"#/suggestions",triggers:"#/triggers",wrapped:"#/wrapped",settings:"#/settings/keys",free:"#/free"},EF={system:["System",va],light:["Light",sS],dark:["Dark",K1]};function RF(){const[e,s]=u.useState(()=>x1()),n=r=>{b1(r),v1(r),s(r)};return t.jsx("div",{role:"group","aria-label":"Theme",className:"flex gap-1 border p-1",children:g1.map(r=>{const[a,o]=EF[r];return t.jsx(I,{variant:"ghost",size:"sm","aria-label":a,title:a,"aria-pressed":e===r,onClick:()=>n(r),className:q("flex flex-1 items-center justify-center py-1.5 text-muted-foreground hover:bg-accent hover:text-foreground",e===r&&"bg-accent text-foreground"),children:t.jsx(o,{className:"size-4","aria-hidden":!0})},r)})})}function TF({active:e,settings:s=!1,triggers:n=!1,banners:r,onNavigate:a,onSignOut:o,onSignOutEverywhere:l,children:i}){const[c,d]=u.useState(!1),[p,x]=u.useState(!1),f=u.useRef(null),h=u.useRef(null),m=u.useRef(!1);u.useEffect(()=>{var y,w;p?(y=h.current)==null||y.focus():m.current&&((w=f.current)==null||w.focus())},[p]);const g=()=>{m.current=!0,x(!1)},b=y=>{a?a(y):location.hash=$F[y],d(!1)},v=_F[e];u.useEffect(()=>{document.title=v?`${v} · AgentRun`:"AgentRun"},[v]);const k=u.useRef(null);return t.jsxs("div",{className:"relative flex h-dvh min-h-0 flex-col overflow-hidden bg-background text-foreground roomy:flex-row",children:[t.jsx(I,{type:"button",size:"sm",onClick:()=>{var y;return(y=k.current)==null?void 0:y.focus()},className:"sr-only focus-visible:not-sr-only focus-visible:absolute focus-visible:left-2 focus-visible:top-2 focus-visible:z-toast focus-visible:inline-flex focus-visible:bg-card focus-visible:px-3",children:"Skip to the page"}),t.jsxs("header",{className:"flex h-12 shrink-0 items-center justify-between border-b px-4 roomy:hidden",children:[t.jsx("button",{type:"button",onClick:()=>b("mission"),"aria-label":"AgentRun home",children:t.jsx(Cl,{})}),t.jsx(I,{size:"icon","aria-label":"Navigation","aria-expanded":c,onClick:()=>d(y=>!y),children:t.jsx(H1,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("aside",{className:q("shrink-0 flex-col border-r bg-background roomy:flex roomy:h-dvh roomy:overflow-y-auto roomy:w-sidebar",c?"flex max-h-[60dvh] overflow-y-auto border-b roomy:max-h-none":"hidden"),children:[t.jsx("div",{className:"hidden h-12 shrink-0 items-center border-b px-4 roomy:flex",children:t.jsx("button",{type:"button",onClick:()=>b("mission"),"aria-label":"AgentRun home",children:t.jsx(Cl,{})})}),t.jsxs("nav",{"aria-label":"Navigation",className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-3 pt-3",children:[t.jsxs("div",{className:"space-y-0.5",children:[t.jsxs(gs,{className:"w-full",active:e==="mission",onClick:()=>b("mission"),children:[t.jsx(Du,{className:"size-4 shrink-0","aria-hidden":!0}),"Mission Control"]}),t.jsxs(gs,{className:"w-full",active:e==="factory",onClick:()=>b("factory"),children:[t.jsx(zb,{className:"size-4 shrink-0","aria-hidden":!0}),"Agent Factory"]}),t.jsxs(gs,{className:"w-full",active:e==="playground",onClick:()=>b("playground"),children:[t.jsx(Fu,{className:"size-4 shrink-0","aria-hidden":!0}),"API playground"]}),t.jsxs(gs,{className:"w-full",active:e==="free",onClick:()=>b("free"),children:[t.jsx(Mb,{className:"size-4 shrink-0","aria-hidden":!0}),"Free"]}),t.jsxs(gs,{className:"w-full",active:e==="agents",onClick:()=>b("agents"),children:[t.jsx(Oo,{className:"size-4 shrink-0","aria-hidden":!0}),"Agents"]}),t.jsxs(gs,{className:"w-full",active:e==="suggestions",onClick:()=>b("suggestions"),children:[t.jsx(Hl,{className:"size-4 shrink-0","aria-hidden":!0}),"Suggested"]}),t.jsxs(gs,{className:"w-full",active:e==="templates",onClick:()=>b("templates"),children:[t.jsx(Uu,{className:"size-4 shrink-0","aria-hidden":!0}),"Templates"]}),t.jsxs(gs,{className:"w-full",active:e==="runs",onClick:()=>b("runs"),children:[t.jsx(An,{className:"size-4 shrink-0","aria-hidden":!0}),"Runs"]}),n&&t.jsxs(gs,{className:"w-full",active:e==="triggers",onClick:()=>b("triggers"),children:[t.jsx(Io,{className:"size-4 shrink-0","aria-hidden":!0}),"Triggers"]}),t.jsxs(gs,{className:"w-full",active:e==="dojo",onClick:()=>b("dojo"),children:[t.jsx(bj,{size:16,className:"shrink-0"}),"Learning Dojo"]})]}),s&&t.jsx("div",{"data-sidebar-account":!0,className:"mt-auto border-t pb-2 pt-3",children:t.jsxs(gs,{className:"w-full",active:e==="settings",onClick:()=>b("settings"),children:[t.jsx(ql,{className:"size-4 shrink-0","aria-hidden":!0}),"Settings"]})})]}),t.jsxs("div",{className:"shrink-0 space-y-2 px-3 pb-4 pt-3",children:[t.jsx(RF,{}),t.jsxs(I,{onClick:o,className:"w-full justify-start",children:[t.jsx(q1,{"aria-hidden":!0}),"Sign out"]}),l&&(p?t.jsxs("div",{role:"alertdialog","aria-label":"Sign out everywhere?",onKeyDown:y=>{y.key==="Escape"&&g()},className:"mt-2 space-y-2 border border-destructive/50 px-3 py-2.5 text-small",children:[t.jsx("p",{children:"Signs out every browser and phone signed in to this server, this one too."}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(I,{size:"xs",variant:"destructive",onClick:()=>{x(!1),l()},children:"Sign out everywhere"}),t.jsx(I,{size:"xs",ref:h,onClick:g,children:"Cancel"})]})]}):t.jsx(I,{size:"sm",variant:"ghost",ref:f,onClick:()=>x(!0),className:"mt-1 w-full justify-start text-muted-foreground hover:text-foreground",children:"Sign out everywhere"}))]})]}),t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t.jsx($5,{}),r,t.jsx("main",{ref:k,tabIndex:-1,className:"relative min-h-0 min-w-0 flex-1 overflow-auto outline-none",children:i})]})]})}const ud={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},Gg={sign_in:{title:"Sign in",body:"Sign in to make agents, start runs and follow them on this server."},setup:{title:"Start building",body:"This is the server's first visit: set the owner's password. You sign in with it from now on."},token_link:{title:"Open the server's link",body:"This server has no accounts. Open the link it printed when it started: it signs this browser in, and its code leaves the address."}};function AF({mode:e,code:s=null,codeNeeded:n=!1,onSubmit:r,onNewCode:a,problem:o=null,offer:l=null,host:i=typeof window>"u"?"":window.location.hostname}){const[c,d]=u.useState(""),[p,x]=u.useState([]),[f,h]=u.useState(""),[m,g]=u.useState(s??"");u.useEffect(()=>{s!==null&&g(s)},[s]);const[b,v]=u.useState(o),[k,y]=u.useState(!1),[w,j]=u.useState(null),[S,N]=u.useState(!1),$=async()=>{if(!(!a||S)){N(!0);try{j(await a()),v(null)}catch(A){j(null),v(A instanceof Error?A.message:String(A))}finally{N(!1)}}},R=e==="setup",E=R&&l!==null&&!("sessions"in l&&l.sessions===0),C=R&&(n||s!==null),_=e!=="token_link"&&c.length>0&&(!R||c===f&&c.length>=12)&&(!C||m.trim()!==""),T=async()=>{if(!_||!r)return;y(!0);const A=R&&l&&"candidates"in l?(l.candidates??[]).map(M=>M.id):[],F=await r(c,C&&m.trim()?m.trim():void 0,p.filter(M=>A.includes(M)));y(!1),v(F)};return t.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:t.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[t.jsx(Cl,{}),t.jsx("h1",{className:"mb-3 mt-8 text-2xl font-semibold",children:Gg[e].title}),t.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:Gg[e].body}),e!=="token_link"&&t.jsxs("form",{className:"space-y-5",onSubmit:A=>{A.preventDefault(),T()},children:[C&&t.jsx(Re,{label:"Setup code",id:"setup-code",hint:aM(i).map((A,F)=>t.jsx("span",{className:q("block leading-relaxed",F>0&&"mt-1.5"),children:A},F)),children:t.jsx(ye,{name:"setup-code",value:m,onChange:A=>g(A.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),C&&a&&t.jsxs("div",{className:"!mt-3",children:[t.jsx(I,{type:"button",size:"sm",disabled:S,"aria-busy":S||void 0,onClick:()=>void $(),children:"Get a new code"}),w&&t.jsx("p",{className:"mt-2 text-small leading-relaxed text-foreground",role:"status",children:w})]}),t.jsx(Re,{label:ud[e].label,note:R?"12 characters or more.":void 0,children:t.jsxs("span",{className:q(nl,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Dn,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(ye,{bare:!0,type:"password",value:c,onChange:A=>d(A.target.value),autoComplete:ud[e].autocomplete,autoFocus:!0,"aria-label":ud[e].label,className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),R&&t.jsx(Re,{label:"Again",note:f&&f!==c?"The two passwords differ.":void 0,children:t.jsxs("span",{className:q(nl,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Dn,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(ye,{bare:!0,type:"password",value:f,onChange:A=>h(A.target.value),autoComplete:"new-password","aria-label":"Password again",className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),E&&t.jsx(IF,{offer:l,chosen:p,onChange:x}),t.jsx(I,{type:"submit",variant:"solid",disabled:!_||k,"aria-busy":k||void 0,className:"w-full text-body",children:k?"Signing in":R?"Set password and continue":"Continue"}),b&&t.jsx("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:b}),!R&&t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:["Forgot it? Where the server runs: ",t.jsx("code",{className:"font-mono text-foreground",children:"npx @parcha/agentrun reset-password"})," (add"," ",t.jsx("code",{className:"font-mono text-foreground",children:"--data DIR"})," if you started it with one). For a server you started yourself:"," ",t.jsx("code",{className:"font-mono text-foreground",children:"agentrun-serve reset-password --data DIR"})," (in the image:"," ",t.jsx("code",{className:"font-mono text-foreground",children:"--data /data"}),"). The next visit here sets a new one."]})]})]})})}const Va=(e,s)=>`${e.toLocaleString("en-US")} ${s}${e===1?"":"s"}`,Tk={"claude-code":"Claude Code",codex:"Codex",pi:"pi",opencode:"OpenCode",copilot:"Copilot CLI"},OF=e=>Tk[e]??e,MF=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function Bg(e){const s=Object.keys(Tk),n=r=>s.includes(r)?s.indexOf(r):s.length;return[...new Set(e.flatMap(r=>r.sources))].sort((r,a)=>n(r)-n(a)||r.localeCompare(a)).map(OF)}const md="Import sessions from this machine";function IF({offer:e,chosen:s,onChange:n}){if("counting"in e)return t.jsx(Re,{group:!0,label:md,children:t.jsxs("p",{className:"flex items-center gap-2 text-small text-muted-foreground",role:"status",children:[t.jsx(zn,{}),"Looking for this machine's coding-agent sessions…"]})});const r=e.candidates??[];if(e.sessions===null||e.projects===null||!r.length)return t.jsx(Re,{group:!0,label:md,children:t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:"This machine's sessions couldn't be listed, so there is nothing to choose here. To import them later, run agentrun-serve import with the server stopped."})});const a=r.filter(x=>s.includes(x.id)),o=a.length===r.length,l=Date.now(),i=MF(Bg(r)),c="Tick the projects to import: each becomes an agent, each session a run you can read. Nothing is imported unless you tick it.",d=`${Va(e.sessions,"session")} in ${Va(e.projects,"project")}`,p=e.projects>r.length?`${d}. ${c} The ${r.length.toLocaleString("en-US")} most recently active are listed, with sessions from ${i}.`:`${d}, from ${i}. ${c}`;return t.jsx(Re,{group:!0,label:md,aside:t.jsx(I,{type:"button",size:"xs",variant:"ghost",onClick:()=>n(o?[]:r.map(x=>x.id)),children:o?"Clear":"Select all"}),note:p,hint:t.jsx("span",{"aria-live":"polite",children:a.length?`${Va(a.length,"project")}, ${Va(a.reduce((x,f)=>x+f.sessions,0),"session")} chosen.`:"None chosen: nothing will be imported."}),children:t.jsx("div",{className:"max-h-56 space-y-3 overflow-y-auto border p-3",children:r.map(x=>t.jsx(ec,{name:"import",value:x.id,checked:s.includes(x.id),onChange:f=>n(f.target.checked?[...s,x.id]:s.filter(h=>h!==x.id)),label:t.jsx("span",{className:"break-all font-mono",children:x.name}),note:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block",children:[Va(x.sessions,"session"),Bg([x]).join(", "),...x.last_active?[`active ${Aa(x.last_active,l)} ago`]:[]].join(" · ")}),t.jsx("span",{className:"block break-all font-mono",children:x.path})]})},x.id))})})}function LF({problem:e,starting:s=!1,onRetry:n}){return t.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:t.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[t.jsx(Cl,{}),t.jsx("h1",{className:"mb-3 mt-8 text-2xl font-semibold",children:s?"This server is starting":"Can't read this server's sign-in"}),t.jsx("p",{className:"mb-4 text-prose leading-relaxed text-muted-foreground",children:s?"Its address answers for it until it is up (a first start, a redeploy or a wake can take a minute or two). Trying again…":"The page asked the server whether it has its owner yet, and got no answer it could read, so it can't show setup or sign-in. It asks again on its own."}),t.jsx("p",{className:"mb-6 break-words font-mono text-body text-destructive-text",role:"alert",children:e}),t.jsx(I,{type:"button",variant:"solid",onClick:n,className:"w-full text-body",children:"Retry now"})]})})}const PF=1e4;function Kg(e=location.hash){if(e==="#/dojo")return{section:"dojo"};const s=e.match(/^#\/wrapped(?:\?(.*))?$/);if(s){const i=new URLSearchParams(s[1]??"").get("year");return{section:"wrapped",...i&&/^\d{4}$/.test(i)?{year:Number(i)}:{}}}const n=e.match(/^#\/observations\/([^/?]+)$/);if(n)return{section:"agents",observation:decodeURIComponent(n[1])};if(e==="#/factory"||e==="#/factory/")return{section:"factory"};let r=e.match(/^#\/runs\/([^/?]+)$/);if(r)return{section:"runs",run:decodeURIComponent(r[1])};if(e==="#/races/new")return{section:"runs",newRace:!0};if(r=e.match(/^#\/races\/([^/?]+)$/),r)return{section:"runs",race:decodeURIComponent(r[1])};if(e==="#/compare"||e.startsWith("#/compare?"))return{section:"runs",compare:ZL(e.split("?")[1]??"")};if(e==="#/agents/connect"||e.startsWith("#/agents/connect?")){const i=new URLSearchParams(e.split("?")[1]??"").get("source");return{section:"agents",nativeConnect:!0,...i==="remote"||i==="observe"?{connectionSource:i}:{}}}if(e==="#/agents/new"||e.startsWith("#/agents/new?")){const i=new URLSearchParams(e.split("?")[1]??""),c=i.get("editor")==="true"||i.get("editor")==="",d=i.get("instructions");return{section:"agents",agent:null,...c?{edit:!0,...d?{initialInstructions:d}:{}}:{}}}if(r=e.match(/^#\/agents\/([^/?]+)\/(edit|settings)(?:\?(.*))?$/),r){const i=new URLSearchParams(r[3]??""),c=i.get("tool");return{section:"agents",agent:decodeURIComponent(r[1]),...r[2]==="edit"?{edit:!0}:{tab:"settings"},...i.get("section")==="tools"||i.get("section")==="skills"?{settingsSection:i.get("section")}:{},...c?{tool:c}:{}}}if(r=e.match(/^#\/agents\/([^/?]+)(?:\/([a-z]+))?$/),r)return{section:"agents",agent:decodeURIComponent(r[1]),...r[2]==="edit"?{edit:!0}:r[2]?{tab:r[2]}:{}};if(e.startsWith("#/agents"))return{section:"agents",archived:/[?&]archived=true\b/.test(e)};if(e.startsWith("#/playground")){const i=new URLSearchParams(e.split("?")[1]??""),c=i.get("agent"),d=i.get("operation"),p=i.get("draft");if(d==="apply-template"){const x=i.get("template");return{section:"playground",operation:d,...x?{template:x}:{},...p!==null?{draft:p}:{}}}return{section:"playground",...c?{playgroundAgent:c}:{},...d==="create-agent"||d==="edit-agent"||d==="list-runs"?{operation:d}:{},...p!==null?{draft:p}:{},...d==="list-runs"&&vl.includes(i.get("status"))?{status:i.get("status")}:{},...d==="list-runs"&&i.get("archived")==="true"?{archived:!0}:{},...d==="list-runs"&&!c&&Yg.test(i.get("source")??"")?{source:i.get("source")}:{},...d==="list-runs"&&!c?Vg(i):{}}}if(r=e.match(/^#\/suggestions(?:\?(.*))?$/),r){const i=B5(r[1]);return{section:"suggestions",...i?{repo:i}:{}}}if(r=e.match(/^#\/templates\/install\?(.*)$/),r)return{section:"templates",install:new URLSearchParams(r[1]).get("src")??""};if(r=e.match(/^#\/templates\/([^/?]+)(?:\?(.*))?$/),r){const i=new URLSearchParams(r[2]??"").get("model");return{section:"templates",template:decodeURIComponent(r[1]),...i?{templateModel:i}:{}}}if(e==="#/free")return{section:"free"};if(e.startsWith("#/templates"))return{section:"templates"};if(e==="#/triggers/new")return{section:"triggers",trigger:null,kind:"schedule"};if(e==="#/triggers/new-webhook")return{section:"triggers",trigger:null,kind:"webhook"};if(e==="#/triggers/new-github")return{section:"triggers",trigger:null,kind:"github"};if(e==="#/triggers/new-composio")return{section:"triggers",trigger:null,kind:"composio"};if(e==="#/triggers/new-feed")return{section:"triggers",trigger:null,kind:"feed"};if(e==="#/triggers/new-email")return{section:"triggers",trigger:null,kind:"email"};if(r=e.match(/^#\/triggers\/([^/?]+)(\/edit)?$/),r)return{section:"triggers",trigger:decodeURIComponent(r[1]),...r[2]?{edit:!0}:{}};if(e.startsWith("#/triggers"))return{section:"triggers"};if(r=e.match(/^#\/settings\/mcp(?:\?(.*))?$/),r){const i=j1(r[1]);return{section:"settings",settings:"mcp",signIn:k1(r[1]),...i?{add:i}:{}}}if(r=e.match(/^#\/settings\/github(?:\?(.*))?$/),r){const i=z5(r[1]);return{section:"settings",settings:"github",...i?{github:i}:{}}}if(r=e.match(/^#\/settings(?:\/(keys|harness-keys|api-keys|tools|email|computers|workspace|webhook|slack|demo))?$/),r)return{section:"settings",settings:r[1]??"keys"};if(e===""||e==="#"||e==="#/"||e.startsWith("#/start")||e.startsWith("#/mission"))return{section:"mission"};if(!e.startsWith("#/runs?"))return{section:"runs"};const a=new URLSearchParams(e.slice(7)),o=a.get("agent"),l=a.get("status");return{section:"runs",...o?{runsOf:o}:{},...l&&vl.includes(l)?{status:l}:{},...a.get("archived")==="true"?{archived:!0}:{},...!o&&Yg.test(a.get("source")??"")?{source:a.get("source")}:{},...o?{}:Vg(a)}}const Yg=/^[a-z][a-z0-9-]{0,31}$/,FF=/^[^\u0000-\u001f\u007f]{1,256}$/;function Vg(e){const s=Jg(e.get("from")),n=Jg(e.get("to")),r=e.get("model");return{...s?{from:s}:{},...n?{to:n}:{},...r!==null&&FF.test(r)?{model:r}:{}}}function Jg(e){const s=e==null?void 0:e.match(/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})?)?$/i);if(!s)return;const[n,r,a,o=0,l=0,i=0]=s.slice(1,7).map(m=>m===void 0?void 0:Number(m)),c=Number((s[7]??"").padEnd(3,"0")),d=s[8],p=d?new Date(Date.UTC(n,r-1,a,o,l,i,c)):new Date(n,r-1,a,o,l,i,c),x=d?[p.getUTCFullYear(),p.getUTCMonth()+1,p.getUTCDate(),p.getUTCHours(),p.getUTCMinutes(),p.getUTCSeconds()]:[p.getFullYear(),p.getMonth()+1,p.getDate(),p.getHours(),p.getMinutes(),p.getSeconds()];if(Number.isNaN(p.getTime())||x.join()!==[n,r,a,o,l,i].join())return;if(!d||d.toUpperCase()==="Z")return p.toISOString();const[f,h]=d.slice(1).split(":").map(Number);if(!(f>23||h>59))return new Date(p.getTime()-(d[0]==="-"?-1:1)*(f*60+h)*6e4).toISOString()}const Qg=e=>!!(e.source||e.from||e.to||e.model);function zF({runsOf:e,status:s,archived:n,source:r,from:a,to:o,model:l}){const i=new URLSearchParams;return e&&i.set("agent",e),s&&i.set("status",s),n&&i.set("archived","true"),r&&!e&&i.set("source",r),a&&!e&&i.set("from",a),o&&!e&&i.set("to",o),l&&!e&&i.set("model",l),`#/runs${i.size?`?${i}`:""}`}let hd;function DF(){if(!hd){const{code:e,rest:s}=s0(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${s}`),hd={code:e}}return hd.code}const UF=e=>Math.min(1e3*2**e,3e4),Ak=1e3,WF=30;function qF(e){return e.state==="running"?"Importing this machine's sessions: agents appear as they arrive.":e.state==="stopped"?"The import of this machine's sessions stopped. It goes on when the server starts again.":e.state==="failed"?"The import of this machine's sessions was given up before it finished. The server's log says why.":`Imported ${`${e.runs.toLocaleString("en-US")} session${e.runs===1?"":"s"}`} into ${e.agents.toLocaleString("en-US")} agent${e.agents===1?"":"s"}${e.skipped?`; ${e.skipped.toLocaleString("en-US")} left out`:""}.`}function HF(){const[e]=u.useState(w$),[s,n]=u.useState(null),[r,a]=u.useState(!1),o=u.useRef(null);o.current=s;const l=u.useRef(!1),i=u.useRef(async()=>{}),c=u.useMemo(()=>jp({fetch:e.fetch,onSignedOut:()=>void i.current()}),[e]),[d,p]=u.useState(()=>I5());u.useEffect(()=>L5(p),[]);const[x,f]=u.useState(null);u.useEffect(()=>{if(!d){f(null);return}let E=!0;return $1(async()=>{const{createDemo:C}=await import("./backend-BxQ2G1M0.js");return{createDemo:C}},__vite__mapDeps([0,1,2]),import.meta.url).then(({createDemo:C})=>{if(!E)return;const _=C({real:e.fetch});f({...jp({fetch:_.fetch,onSignedOut:()=>void i.current()}),fileUrl:_.fileUrl})},()=>{E&&hu(!1)}),()=>{E=!1}},[d,e]);const[h,m]=u.useState(DF);u.useEffect(()=>{if(s!=="setup")return;const E=()=>{const{code:C,rest:_}=s0(location.hash);C!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${_}`),m(C))};return window.addEventListener("hashchange",E),E(),()=>window.removeEventListener("hashchange",E)},[s]);const[g,b]=u.useState(!1),v=async()=>{const E=await c.session(),C=oh(E)?await c.listAgents().then(()=>200,_=>_ instanceof ge?_.status:0):void 0;return{mode:nM(E,C),codeNeeded:rM(E)}},k=async()=>{const E=await v();return b(E.codeNeeded),E.mode},y=async()=>n(await k());i.current=async()=>{if(!(o.current!=="signed_in"||l.current)){l.current=!0;try{const E=await k();E!=="signed_in"&&o.current==="signed_in"&&(a(!0),n(E))}catch{}finally{l.current=!1}}};const[w,j]=u.useState(null),[S,N]=u.useState(0);u.useEffect(()=>{let E=!0,C;return v().then(_=>{!E||o.current!==null||(b(_.codeNeeded),n(_.mode),j(null))},_=>{if(!E||o.current!==null)return;const T=UF(S),A=_ instanceof ge?_:null,F=(A==null?void 0:A.code)==="http_error",M=F&&[502,503,504].includes(A.status);j({problem:A===null?st(_):M?`Its address answered ${A.status}, not the server.`:`GET /v2/auth/session answered ${A.status}${F?", not as this server answers":`: ${A.message}`}`,starting:M}),C=setTimeout(()=>N(L=>L+1),T)}),()=>{E=!1,clearTimeout(C)}},[c,S]);const[$,R]=u.useState(null);return u.useEffect(()=>{if(s!=="setup")return;let E=!0;return(async()=>{for(let C=!1;E;){const _=await c.setupImport().then(T=>T,()=>{});if(!E)return;if(_===void 0&&C)return void R({projects:null,sessions:null});if(_!==void 0&&(!_||!("counting"in _||"sessions"in _)||(R(_),C=!0,!("counting"in _))))return;await new Promise(T=>setTimeout(T,Ak))}})(),()=>{E=!1}},[c,s]),s===null&&w!==null?t.jsx(LF,{problem:w.problem,starting:w.starting,onRetry:()=>N(E=>E+1)}):s===null?t.jsx(Dx,{connection:e,children:t.jsx(GF,{})}):s!=="signed_in"?t.jsx(AF,{mode:s,code:h,codeNeeded:g,offer:$,problem:r&&s==="sign_in"?"You were signed out. Sign in to go on.":null,onSubmit:async(E,C,_)=>{try{return await(s==="setup"?c.setup(E,C,_):c.signIn(E)),a(!1),n("signed_in"),null}catch(T){return T instanceof ge&&T.status===403&&s==="setup"&&await y().catch(()=>{}),T instanceof ge?cM(T):T instanceof Error?T.message:String(T)}},onNewCode:async()=>{try{return oM(window.location.hostname,await c.setupCode())}catch(E){throw E instanceof ge&&E.status===403&&await y().catch(()=>{}),new Error(E instanceof ge?lM(E):E instanceof Error?E.message:String(E))}}},s):d&&!x?t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Opening the demo…"}):t.jsx(Dx,{connection:e,children:t.jsx(BF,{v2:d&&x?x:c,demo:d,onSignedOut:()=>{a(!1),n("sign_in")}})})}function GF(){return rh().state==="offline"?t.jsx(E5,{}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function BF(e){const s=u.useMemo(Er,[e.v2]);return t.jsx(KF,{...e},s)}function KF({v2:e,onSignedOut:s,demo:n=!1}){var _h,$h,Eh,Rh,Th,Ah,Oh,Mh,Ih,Lh,Ph,Fh,zh,Dh,Uh,Wh,qh,Hh,Gh,Bh,Kh,Yh,Vh,Jh,Qh,Xh,Zh,ef,tf,sf,nf,rf,af,of,lf,cf,df,uf,mf,hf,ff,pf,xf,gf,bf,vf,yf,wf,jf;const{writable:r,whyNot:a}=S3(e),[o,l]=u.useState(null),[i,c]=u.useState(()=>Kg()),[d,p]=u.useState(null),x=(($h=(_h=d==null?void 0:d.features)==null?void 0:_h.triggers)==null?void 0:$h.routes)===!0,[f,h]=u.useState(new Map);u.useEffect(()=>{if(!x)return;let re=!0;return e.listTriggers().then(pe=>{re&&h(new Map(pe.triggers.map(je=>[je.id,{name:je.name,kind:je.source.kind}])))},()=>{}),()=>{re=!1}},[e,x,i.section,i.trigger]);const[m,g]=u.useState(null),[b,v]=u.useState(null),[k,y]=u.useState(0),[w,j]=u.useState("30d"),S=w==="7d"?7:30,N=bm(e,{active:i.section==="mission"||i.section==="runs"&&!i.run&&!i.race&&!i.compare&&!i.runsOf&&!i.archived&&!i.status&&!Qg(i),days:S}),[$,R]=u.useState(null),[E,C]=u.useState(!1),[_,T]=u.useState(!1),A=u.useRef(!1),[F,M]=u.useState(null),[L,O]=u.useState(null),[U,K]=u.useState(null),[Z,D]=u.useState(0),Y=u.useRef(null),[P,B]=u.useState(!1),[V,G]=u.useState(!1),[z,ne]=u.useState(!1),[le,H]=u.useState(null),[ee,we]=u.useState(null),[fe,ae]=u.useState(!1),[ue,be]=u.useState({}),[he,X]=u.useState(!1),ie=u.useRef(0),[W,Ne]=u.useState([]),[_e,Ie]=u.useState(null),[xe,Ye]=u.useState(null),He=u.useRef(-1),[me,Fe]=u.useState(null),[ut,se]=u.useState(0),ve=u.useRef(0),Se=re=>{Ja(re)||(location.hash=re)},[Pe,De]=u.useState(null),[at,Ct]=u.useState(0);u.useEffect(()=>{let re=!0;return(async()=>{let pe=!1;for(let je=0;re&&je<WF;){const Ze=await e.setupImport().then(Ve=>Ve,()=>{});if(!re)return;if(Ze===void 0)je+=1;else{if(je=0,!Ze||!("state"in Ze))return;if(De(Ze),Ze.state!=="running")return void(pe&&Ct(Ve=>Ve+1));pe=!0}await new Promise(Ve=>setTimeout(Ve,Ak))}})(),()=>{re=!1}},[e]),u.useEffect(()=>{const re=()=>{const pe=T1();Ja(location.hash,()=>{pe&&history.go(-pe)})?pe&&history.go(pe):c(Kg())};return window.addEventListener("hashchange",re),()=>window.removeEventListener("hashchange",re)},[]),u.useEffect(()=>R1(),[]);const ze=u.useRef(0),ht=u.useRef(!1),[Bt,nt]=u.useState(!1),Pt=()=>{const re=++ze.current;return e.capabilities().then(pe=>(re===ze.current&&(p(pe),nt(!1)),pe),()=>(re===ze.current&&nt(!0),null))},Le=()=>Pt().then(re=>re!==null);u.useEffect(()=>{Le()},[e]),u.useEffect(()=>{if(ie.current&&i.section!=="runs"&&i.section!=="mission"&&i.section!=="factory"&&i.section!=="triggers"&&He.current===at)return;He.current=at;const re=++ie.current;X(!1),Promise.allSettled([!1,!0].map(pe=>rn(je=>e.listAgents({archived:pe,cursor:je}),je=>je.agents))).then(pe=>{if(re!==ie.current)return;const je=Object.fromEntries(pe.flatMap(Ve=>Ve.status==="fulfilled"?Ve.value:[]).map(Ve=>[Ve.agent_id,Ve.definition.name??Ve.agent_id])),Ze=pe.every(Ve=>Ve.status==="fulfilled");be(Ve=>Ze?je:{...Ve,...je}),X(Ze)})},[e,i,at]);const vt={status:i.status,archived:i.archived,source:i.source,from:i.from,to:i.to,model:i.model};u.useEffect(()=>{if(i.section!=="runs"||i.run||i.race||i.compare)return;const re=++ve.current;H(null),Fe(null),(i.runsOf?e.listAgentRuns(i.runsOf,50,null,vt):e.listRuns(50,null,vt)).then(pe=>{re===ve.current&&(H(pe.runs),we(pe.next_cursor))}).catch(pe=>{re===ve.current&&Fe(ot(pe,"the runs"))})},[e,i,at,ut]);const _t=re=>{var pe;return ue[re]??((pe=ns==null?void 0:ns.find(je=>je.agent_id===re))==null?void 0:pe.definition.name)??(he?re:"")},J=d,oe={harnesses:(J==null?void 0:J.harnesses)??[],tools:xp(J==null?void 0:J.tools),thinking:((Eh=J==null?void 0:J.features)==null?void 0:Eh.thinking)??[],...typeof((Rh=d==null?void 0:d.limits)==null?void 0:Rh.free_model_requests)=="number"?{freeRequests:d.limits.free_model_requests}:{},places:B_(d),mcp:!!((Th=d==null?void 0:d.features)!=null&&Th.mcp_client),mcpHarnesses:(Oh=(Ah=d==null?void 0:d.features)==null?void 0:Ah.mcp_client)==null?void 0:Oh.harnesses},$e=z4(J==null?void 0:J.tools),Ae=U4(J==null?void 0:J.tools),ce=[...(Ih=(Mh=d==null?void 0:d.features)==null?void 0:Mh.tool_keys)!=null&&Ih.routes?["keys"]:[],...(Ph=(Lh=d==null?void 0:d.features)==null?void 0:Lh.harness_keys)!=null&&Ph.routes?["harness-keys"]:[],...(zh=(Fh=d==null?void 0:d.features)==null?void 0:Fh.api_keys)!=null&&zh.routes?["api-keys"]:[],...$e.length||Ae.length?["tools"]:[],"mcp","github","email","computers","workspace",...(Uh=(Dh=d==null?void 0:d.features)==null?void 0:Dh.webhooks)!=null&&Uh.routes?["webhook"]:[],...(qh=(Wh=d==null?void 0:d.features)==null?void 0:Wh.slack)!=null&&qh.routes?["slack"]:[],"demo"],Ce=n?["demo"]:ce,et=n?"demo":i.settings??"keys",Mt=re=>Se({runs:"#/runs",agents:"#/agents",playground:"#/playground",dojo:"#/dojo",mission:"#/",factory:"#/factory",triggers:"#/triggers",templates:"#/templates",suggestions:"#/suggestions",free:"#/free",wrapped:"#/wrapped",settings:`#/settings/${Ce[0]??"keys"}`}[re]),yt=u.useRef(Yn()).current,[te,Ue]=u.useState(null),[tt,it]=u.useState(!1),Xt=re=>{Ue(`ollama/${re}`),Le()},os=async re=>{const pe=_0(oe.harnesses,te);if(!pe)return"This server has no model to run it on yet.";try{const je=await mI(e,re,pe,yt);return Se(`#/runs/${encodeURIComponent(je)}`),null}catch(je){return st(je)}},Cn=((m==null?void 0:m.analytics.by_source)??[]).filter(re=>re.source!=="live").reduce((re,pe)=>re+pe.runs,0),[ns,Oe]=u.useState(null),[Ge,lt]=u.useState([]),[Kt,is]=u.useState(null),[si,ni]=u.useState({revision:""}),Vn=u.useRef(Kt);Vn.current=Kt;const[Pa,Jn]=u.useState(null),[ri,Fa]=u.useState(0),Qn=u.useRef(0);u.useEffect(()=>{Oe(null),Jn(null),is(null),Vn.current=null},[e,i.section,i.operation,i.playgroundAgent]),u.useEffect(()=>{if(i.section!=="playground"||i.operation)return;Jn(null);const re=++Qn.current;return rn(pe=>e.listAgents({cursor:pe}),pe=>pe.agents).then(pe=>{var Ve;if(re!==Qn.current)return;const je=pe.filter(Zs=>!Zs.archived_at),Ze=Vn.current??i.playgroundAgent;if(Ze&&!je.some(Zs=>Zs.agent_id===Ze)){Oe(null),is(null),Jn("The selected agent is unavailable or archived. Choose another agent from Agents.");return}Oe(pe),is(Ze??((Ve=je[0])==null?void 0:Ve.agent_id)??null)}).catch(pe=>{if(re===Qn.current){const je=ot(pe,"the agents");Jn(`${je.why} ${je.next}${je.said?` (${je.said})`:""}`)}}),()=>{Qn.current++}},[e,i.section,i.operation,i.playgroundAgent,ri,at]),u.useEffect(()=>{if(i.section!=="mission")return;let re=!0;A.current=!0,v(null),T(!0);const pe=ol(w);return Promise.all([e.statsOver({...pe?{from:pe}:{},...$?{agent:$}:{}}),E?Promise.resolve({runs:[]}):$?e.listAgentRuns($,10):e.listRuns(10)]).then(([je,Ze])=>{re&&(g($$(je,Ze.runs)),$||K(Ve=>Ve||m5(Ze.runs,je.analytics.by_source)))}).catch(je=>{re&&v(ot(je,"Mission Control"))}).finally(()=>{re&&(A.current=!1,T(!1))}),()=>{re=!1,A.current=!1}},[e,i.section,k,w,$,E,at]),ah(()=>y(re=>re+1)),u.useEffect(()=>{if(i.section!=="mission")return;const re=()=>{!document.hidden&&!A.current&&y(je=>je+1)};window.addEventListener("focus",re),document.addEventListener("visibilitychange",re);const pe=setInterval(re,15e3);return()=>{window.removeEventListener("focus",re),document.removeEventListener("visibilitychange",re),clearInterval(pe)}},[i.section]),u.useEffect(()=>{if(i.section!=="mission"){Y.current=null,Ie(null),Ye(null);return}let re=!0;const pe=Y,je=Ft=>rn(ls=>e.listRuns(50,ls,{status:Ft}),ls=>ls.runs,2),Ze=()=>rn(Ft=>e.listAgents({archived:!1,cursor:Ft}),Ft=>Ft.agents).then(Ft=>{re&&(Ne(Ft.filter(ls=>il(ls)>0).map(ls=>({agent_id:ls.agent_id,name:ls.definition.name??ls.agent_id,pending:il(ls)}))),Ie(Ft),Ye(null))},Ft=>{re&&Ye(st(Ft))}),Zs=f5(()=>Promise.allSettled([je("input_required"),je("failed"),je("working"),Ze()]).then(([Ft,ls,ii])=>{var li,Ss,kf;if(!re)return;const _n=[Ft,ls,ii],Ec=Date.now()-u5;if(O(Mx(null,_n).problem),((li=_n[0])==null?void 0:li.status)==="fulfilled"&&B(!0),((Ss=_n[1])==null?void 0:Ss.status)==="fulfilled"){G(!0);const ci=_n[1].value.map($n=>$n.run_id),Mr=pe.current;Mr&&ci.some($n=>!Mr.has($n))&&y($n=>$n+1),pe.current=new Set(ci)}((kf=_n[2])==null?void 0:kf.status)==="fulfilled"&&ne(!0),M(ci=>{const{needs:Mr}=Mx(ci,_n);return{asking:Mr.asking.filter(Hj),failed:Mr.failed.filter($n=>Date.parse($n.ended_at??$n.created_at)>Ec),live:Mr.live}})}),1e4);return()=>{re=!1,Zs()}},[e,i.section,Z]);const ai=u.useRef(mw()).current,Q=()=>setTimeout(()=>D(re=>re+1),2500),Te=async(re,pe)=>{try{return await uw(ai(re),re,pe,e.sendMessage),Q(),null}catch(je){return st(je)}},rt=u.useRef(new Map).current,Ut=async re=>{const pe=[];try{for(const je of re){const Ze=h5(je.kind==="workflow"?je:await e.getRun(je.run_id));if("refusal"in Ze)throw new Error(Ze.refusal);const Ve=rt.get(je.run_id)??Er();rt.set(je.run_id,Ve),await e.startRun(je.agent_id,Ze.body,Ve),pe.push(je.run_id)}return Q(),{started:pe,problem:null}}catch(je){return pe.length&&Q(),{started:pe,problem:st(je)}}},Ps=async re=>{try{return await e.stop(re),Q(),null}catch(pe){return st(pe)}},Xn=async(re,pe,je,Ze,Ve)=>{let Zs=null;try{await e.answerApproval(re,pe,je,Ze,Ve)}catch(Ft){Zs=U0(Ft)}return D(Ft=>Ft+1),Zs},Zn=async(re,pe)=>{let je=null;try{await e.handBackComputer(re,pe)}catch(Ze){je=ku(Ze,"hand")}return D(Ze=>Ze+1),je},rs=u.useRef(0),Tr=re=>{const pe=++rs.current;rn(je=>e.listRevisions(re,je),je=>je.revisions).then(je=>{pe===rs.current&&lt(je)}).catch(()=>{})};u.useEffect(()=>{++rs.current,lt([]),ni({revision:""}),Kt&&Tr(Kt)},[e,Kt]);const[Ok,Mk]=u.useState(0),Ik=async(re,pe,je)=>{const Ze=performance.now();try{const Ve=await e.startRun(re,pe,je);return{status:Ve.status,ms:Math.round(performance.now()-Ze),body:Ve.run,runId:Ve.run.run_id}}catch(Ve){return nh(Ve,Math.round(performance.now()-Ze))}finally{Mk(Ve=>Ve+1)}},Lk=async re=>{const{agent:pe,etag:je}=await e.getAgent(re),Ze=pe.definition.tools??[],Ve=await e.computers().then(Ss=>Ss.kinds,()=>null),Zs=async()=>{const Ss=await Pt();return tu({kind:"none"},Ze,xp(Ss==null?void 0:Ss.tools),Ve)},Ft=tu({kind:"none"},Ze,oe.tools,Ve)??await Zs();if(!Ft)throw new Error("the server's tools could not be read, so which of them run only in a box is unknown. Try again.");const{unchanged:ls,...ii}=$r(pe,Ft,"Moved to the runner, where Claude Code's login on this machine runs it");if(ls)return{revision:pe.revision,saved:!1,dropped:[]};const _n=new Set(ii.definition.tools??[]),Ec=(pe.definition.tools??[]).filter(Ss=>!_n.has(Ss)),li=await e.updateDefinition(re,ii,je);return Fa(Ss=>Ss+1),Vn.current===re&&Tr(re),{revision:li.agent.revision,saved:!0,dropped:Ec}},gh=((Hh=d==null?void 0:d.features)==null?void 0:Hh.efforts)??[],oi=d?((Gh=d.features)==null?void 0:Gh.learning)??null:void 0;oe.learning=oi??void 0;const bh={...oe,routePrefix:(Bh=J==null?void 0:J.models)==null?void 0:Bh.route_prefix,decisionProvider:e$(d==null?void 0:d.workflows),mcp:!!((Kh=d==null?void 0:d.features)!=null&&Kh.mcp_client),mcpHarnesses:(Vh=(Yh=d==null?void 0:d.features)==null?void 0:Yh.mcp_client)==null?void 0:Vh.harnesses},Ar=(Jh=d==null?void 0:d.models)==null?void 0:Jh.ready;u.useEffect(()=>{var Ze;if(Ar!==!1&&((Ze=d==null?void 0:d.learning_model)==null?void 0:Ze.ready)!==!1)return;const re=()=>{ht.current||(ht.current=!0,Le().finally(()=>{ht.current=!1}))},pe=()=>Le(),je=setInterval(re,PF);return window.addEventListener("focus",pe),()=>{clearInterval(je),window.removeEventListener("focus",pe)}},[e,Ar,(Qh=d==null?void 0:d.learning_model)==null?void 0:Qh.ready]);const[er,Sc]=u.useState(null);u.useEffect(()=>{if(Ar!==!1)return;let re=!0;return e.chatGPT().then(pe=>{re&&Sc(Bi(pe))},()=>{re&&Sc(null)}),()=>{re=!1}},[e,Ar]);const vh=((Xh=d==null?void 0:d.features)==null?void 0:Xh.claude_login)===!0,yh=i.section==="settings",[Pk,Cc]=u.useState(!1);u.useEffect(()=>{if(Ar!==!1||!vh){Cc(!1);return}if(yh)return;let re=!0;return e.claudeLogin().then(pe=>{var je;re&&Cc(((je=Ri(pe))==null?void 0:je.state)==="signed_in")},()=>{re&&Cc(!1)}),()=>{re=!1}},[e,Ar,vh,yh,Ok]);const[wh,jh]=u.useState(!1),[kh,_c]=u.useState(!1),Fk=re=>{Sc(re),(re.state==="pending"||re.state==="signed_in")&&jh(!0),re.state==="signed_in"&&Le()},Or=ns==null?void 0:ns.find(re=>re.agent_id===Kt),zk=Or==null?void 0:Or.definition,Xs=si.revision?si.definition:zk,Dk=(Xs==null?void 0:Xs.native)||It(Xs),$c=Xs&&Or?(Zh=ky({kind:Or.kind,definition:Xs},oe.places))==null?void 0:Zh.place:void 0,Uk=((tf=(ef=oe.places)==null?void 0:ef.defaultPlace)==null?void 0:tf.mode)==="runner",Wk=Pk&&((sf=d==null?void 0:d.models)==null?void 0:sf.needs)!=="model"&&(Or?(Xs==null?void 0:Xs.harness)===y1&&w1(Xs.model)&&($c==null?void 0:$c.mode)==="runner":Uk),Nh=i.operation?i.playgroundAgent:Kt??i.playgroundAgent,Sh=!Dk&&((nf=d==null?void 0:d.models)==null?void 0:nf.ready)===!1&&!Wk&&t.jsx(CO,{needs:d.models.needs,source:d.models.source,model:d.models.default,settings:((af=(rf=d.features)==null?void 0:rf.tool_keys)==null?void 0:af.routes)===!0&&d.features.tool_keys.at_rest==="sealed",chatgpt:(er==null?void 0:er.state)==="signed_out"||(er==null?void 0:er.state)==="expired"}),Ch=t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"sr-only",htmlFor:"api-operation",children:"API operation"}),t.jsx(qe,{id:"api-operation",label:"API operation",steady:!0,value:i.operation??"run",onChange:re=>{const pe=Nh,je=new URLSearchParams;re!=="run"&&je.set("operation",re),re!=="create-agent"&&re!=="apply-template"&&pe&&je.set("agent",pe),Se(`#/playground${je.size?`?${je}`:""}`)},options:[{value:"create-agent",label:"POST · Create an agent"},{value:"apply-template",label:"POST · Apply a template"},{value:"run",label:"POST · Start a run"},{value:"list-runs",label:"GET · Query runs"},{value:"edit-agent",label:"PUT · Edit agent",disabled:!Nh}]})]});return t.jsx(Dj.Provider,{value:f,children:t.jsx(TF,{active:i.section,settings:ce.length>0,triggers:x,onNavigate:Mt,onSignOut:()=>{const re=()=>void e.signOut().then(s,pe=>l(pe instanceof ge?pe.message:"The sign-out did not reach the server. Try again."));Ja(null,re)||re()},onSignOutEverywhere:()=>{const re=()=>void e.signOutEverywhere().then(s,pe=>l(pe instanceof ge?pe.message:"The sign-out did not reach the server. Try again."));Ja(null,re)||re()},banners:t.jsxs(t.Fragment,{children:[n&&t.jsx(A5,{onOff:()=>{hu(!1),location.hash="#/settings/demo"}}),o&&t.jsxs("p",{className:"border-b bg-card px-5 py-3 font-mono text-body text-destructive-text md:px-8",role:"alert",children:["Not signed out: ",o]}),Pe&&t.jsxs("p",{className:"flex items-center gap-3 border-b bg-card px-5 py-3 font-mono text-body md:px-8",role:"status",children:[t.jsx("span",{className:"flex-1",children:qF(Pe)}),Pe.state!=="running"&&t.jsx(I,{size:"xs",type:"button",onClick:()=>De(null),children:"Dismiss"})]})]}),children:i.section==="settings"?t.jsx(r3,{active:et,offered:Ce,children:et==="demo"?t.jsx(T5,{on:n,onChange:hu,v2:e,go:Se}):i.settings==="harness-keys"?t.jsx(k5,{v2:e,writable:r,whyNot:a,onChange:()=>void Le()}):i.settings==="api-keys"?t.jsx(n5,{v2:e,writable:r,whyNot:a,origin:location.origin}):i.settings==="tools"?t.jsx(F5,{v2:e,choices:$e,gates:Ae,harnesses:oe.harnesses,mcp:!!oe.mcp,onSaved:Le,onOpen:Le}):i.settings==="mcp"?t.jsx(oO,{v2:e,signIn:i.signIn,add:i.add,writable:r,whyNot:a,choices:$e}):i.settings==="github"?t.jsx(sO,{v2:e,returned:i.github}):i.settings==="email"?t.jsx(OO,{v2:e,writable:r,whyNot:a}):i.settings==="computers"?t.jsx(qO,{v2:e,writable:r,whyNot:a}):i.settings==="workspace"?t.jsx(tM,{v2:e,writable:r,whyNot:a}):i.settings==="webhook"?t.jsx(IO,{v2:e}):i.settings==="slack"?t.jsx(FO,{v2:e,writable:r,whyNot:a}):t.jsx(y5,{v2:e,onChange:Le,writable:r,whyNot:a,harnesses:oe.harnesses,plan:t.jsxs(t.Fragment,{children:[t.jsx(E3,{v2:e,writable:r,whyNot:a,source:(of=d==null?void 0:d.models)==null?void 0:of.source,defaultModel:(lf=d==null?void 0:d.models)==null?void 0:lf.default,routePrefix:(cf=d==null?void 0:d.models)==null?void 0:cf.route_prefix,onChange:()=>void Le()}),t.jsx(M3,{v2:e,writable:r,whyNot:a,available:d?((df=d.features)==null?void 0:df.claude_login)!==!1:Bt,onChange:()=>void Le()}),t.jsx(z3,{v2:e,writable:r,whyNot:a,onChange:()=>void Le()})]})})}):i.section==="dojo"?t.jsx(mA,{v2:e,server:oi,modelAccess:d==null?void 0:d.learning_model},at):i.section==="mission"?t.jsx("div",{className:"flex h-full flex-col",children:t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(J6,{yearLink:!n,observed:N,agents:_e,agentsError:xe,view:m,error:b,onRetry:()=>y(re=>re+1),actions:t.jsxs(t.Fragment,{children:[t.jsx(I,{size:"icon","aria-label":"Refresh Mission Control",disabled:_,onClick:()=>{y(re=>re+1),D(re=>re+1),N.refresh()},children:t.jsx(pn,{className:"size-4","aria-hidden":!0})}),E&&$?t.jsx(xt,{label:"Ask about this session",prompt:F_(location.origin,$,ol(w)),playgroundHref:xm($),playgroundLabel:"Connected agent"}):t.jsx(xt,{label:"Ask about runs",prompt:tc(location.origin,$??void 0),playgroundHref:vm($??void 0)}),t.jsx(xh,{variant:"primary"})]}),scope:{range:w,onRange:j,agent:$,onAgent:re=>{var pe;C(!!re&&!!((pe=N.data)!=null&&pe.sessions.some(je=>je.id===re))),R(re)},refreshing:_&&m!==null},asking:F&&P?F.asking.length:null,failed:F&&V?qj(F.failed):null,live:F&&z?F.live.length:null,needsYou:F&&t.jsx(hF,{asking:F.asking,failed:F.failed,failedAll:m==null?void 0:m.runs.failed,live:F.live,learning:W,problem:L,agentName:_t,onAnswer:Te,onApprove:Xn,onHandBack:Zn,onRunAgain:Ut,onStop:Ps}),startHere:U===!1&&!((uf=N.data)!=null&&uf.sessions.length)?t.jsx(SF,{harnesses:oe.harnesses,tools:oe.tools,onTry:os,imported:Cn,keySettings:((hf=(mf=d==null?void 0:d.features)==null?void 0:mf.tool_keys)==null?void 0:hf.routes)===!0&&d.features.tool_keys.at_rest==="sealed",modelSetup:d&&(d.models.ready===!1||wh||kh)?t.jsxs(t.Fragment,{children:[(d.models.ready===!1||kh)&&t.jsx(Kx,{v2:e,onPulling:()=>_c(!0),onReady:re=>{_c(!0),Xt(re)},onDone:()=>_c(!1)}),(d.models.ready===!1||wh)&&t.jsx(SO,{v2:e,needs:d.models.needs,model:d.models.default,source:d.models.source,routePrefix:d.models.route_prefix,capsRead:d.models,onSaved:Le,writable:r,whyNot:a,plan:er,harnesses:oe.harnesses,onPlan:Fk,onDone:()=>jh(!1)})]}):void 0}):void 0})})}):i.section==="wrapped"?t.jsx(bL,{v2:e,year:i.year,go:Se}):i.section==="suggestions"?t.jsx(xI,{v2:e,repo:i.repo,go:Se}):i.section==="factory"?t.jsx(mF,{v2:e,agentName:_t}):i.section==="templates"?t.jsx(ig,{v2:e,name:i.template,install:i.install,model:i.templateModel,freeIds:J?wl(J.harnesses).map(re=>re.id):void 0,go:Se},i.install!==void 0?`install:${i.install}`:`${i.template??""}:${i.templateModel??""}`):i.section==="free"?t.jsx(hI,{v2:e,harnesses:oe.harnesses,tools:J==null?void 0:J.tools,freeRequests:oe.freeRequests,routePrefix:(ff=J==null?void 0:J.models)==null?void 0:ff.route_prefix,go:Se,fit:t.jsx(Kx,{v2:e,onPulling:()=>it(!0),onReady:Xt,onDone:()=>it(!1)}),fitHeld:tt,localModel:te}):i.section==="triggers"?t.jsx(xM,{v2:e,view:{trigger:i.trigger,kind:i.kind,edit:i.edit},go:Se,agentName:_t,minEvery:(xf=(pf=d==null?void 0:d.features)==null?void 0:pf.triggers)==null?void 0:xf.min_every_s,failuresToPause:(bf=(gf=d==null?void 0:d.features)==null?void 0:gf.triggers)==null?void 0:bf.failures_to_pause,publicUrl:(yf=(vf=d==null?void 0:d.features)==null?void 0:vf.triggers)==null?void 0:yf.public_url}):i.section==="playground"?t.jsxs("section",{className:"flex h-full min-h-0 flex-col",children:[t.jsx("header",{className:q(Lt,"gap-2 px-5"),children:t.jsxs("h1",{className:ss,children:[t.jsx(Fu,{className:"size-4","aria-hidden":!0}),"API playground"]})}),(i.operation||!ns)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-5 py-3 md:px-6",children:[Ch,t.jsx("span",{className:"min-w-0 break-all font-mono text-small text-muted-foreground",children:i.operation==="apply-template"?`/v2/templates/${i.template?encodeURIComponent(i.template):"{template}"}/apply`:i.operation==="list-runs"?i.playgroundAgent?`/v2/agents/${i.playgroundAgent}/runs`:"/v2/runs":i.operation==="create-agent"?"/v2/agents":i.operation==="edit-agent"?`/v2/agents/${i.playgroundAgent??"{agent_id}"}/definition`:"/v2/agents/{agent_id}/runs"})]}),i.operation==="apply-template"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(ig,{v2:e,name:i.template,go:Se,playground:!0,draft:i.draft,freeIds:J?wl(J.harnesses).map(re=>re.id):void 0},i.template??"")}):i.operation==="list-runs"?t.jsx(Z3,{v2:e,origin:location.origin,agentId:i.playgroundAgent,filter:{status:i.status,archived:i.archived,source:i.source,from:i.from,to:i.to,model:i.model}},`list:${i.playgroundAgent??""}:${i.status??""}:${i.archived??!1}:${i.source??""}:${i.from??""}:${i.to??""}:${i.model??""}`):i.operation?t.jsx(t5,{v2:e,operation:i.operation,origin:location.origin,agentId:i.playgroundAgent,draft:i.draft,harnesses:oe.harnesses,routePrefix:(wf=J==null?void 0:J.models)==null?void 0:wf.route_prefix},`${i.operation}:${i.playgroundAgent??""}:${i.draft??""}`):t.jsxs(t.Fragment,{children:[!ns&&Sh,Pa&&t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"text-lead text-destructive-text",children:["The agents could not be read: ",Pa]}),t.jsx(I,{size:"sm",className:"mt-3",type:"button",onClick:()=>Fa(re=>re+1),children:"Try again"})]}),ns&&t.jsx(Q3,{lead:Ch,notice:Sh,agents:ns.filter(re=>!re.archived_at),revisions:Ge,efforts:gh,origin:location.origin,agentId:Kt??void 0,onAgent:is,onRevision:(re,pe)=>ni({revision:re,definition:pe}),onSend:Ik,limits:d==null?void 0:d.limits,...n?{upload:Wx}:{},removeUpload:e.deleteUpload,onMoveToRunner:Lk,onOpenRun:re=>Se(`#/runs/${encodeURIComponent(re)}`),live:re=>t.jsx(Mg,{v2:e,runId:re,caps:d,agentName:_t},re)})]})]}):i.section==="agents"?i.observation?t.jsx(d$,{v2:e,sessionId:i.observation,go:Se}):i.nativeConnect?t.jsx(jF,{v2:e,go:Se,initialSource:i.connectionSource}):i.agent===void 0?t.jsx(g3,{v2:e,archived:!!i.archived,go:Se,learning:oi},at):i.agent!==null?t.jsx(nA,{v2:e,agentId:i.agent,tab:i.edit?"settings":i.tab,learning:oi,routePrefix:(jf=J==null?void 0:J.models)==null?void 0:jf.route_prefix,harnesses:oe.harnesses,efforts:gh,limits:d==null?void 0:d.limits,places:oe.places,go:Se,...n?{upload:Wx}:{},renderEditor:(re,pe)=>t.jsx(Cx,{initialStep:i.settingsSection,embedded:!0,onAgent:re,onEditPromptChange:pe,v2:e,choices:$e,gates:Ae,focusTool:i.tool,caps:bh,agentId:i.agent,go:Se},`${i.agent}:${i.edit?"edit":"settings"}:${i.settingsSection??""}:${i.tool??""}`)},i.agent):t.jsx(Cx,{v2:e,choices:$e,gates:Ae,caps:bh,initialInstructions:i.initialInstructions,agentId:null,go:Se},`new:${i.edit?"legacy-editor":"editor"}:${i.initialInstructions??""}`):i.newRace?d?t.jsx(Y6,{v2:e,harnesses:oe.harnesses,tools:oe.tools,places:oe.places??null,go:Se}):Bt?t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(ke,{tone:"error",actions:t.jsx(I,{size:"xs",onClick:()=>void Le(),children:"Try again"}),children:"The server's harnesses could not be read, so there is nothing to pick a lane from yet."})}):t.jsx(oc,{}):i.race?t.jsx(H6,{v2:e,label:i.race},i.race):i.compare?t.jsx(V6,{v2:e,ids:i.compare},i.compare.join(",")):i.run?t.jsx(Mg,{v2:e,runId:i.run,caps:d,agentName:_t},i.run):t.jsx(G3,{observations:!i.runsOf&&!i.archived&&!i.status&&!Qg(i)?N:void 0,runs:le,agentName:_t,agentId:i.runsOf,error:me,onRetry:()=>se(re=>re+1),onOpen:re=>Se(`#/runs/${encodeURIComponent(re)}`),loadingMore:fe,filter:vt,onFilter:re=>Se(zF({runsOf:i.runsOf,...re})),onMore:ee?()=>{const re=ve.current;ae(!0),(i.runsOf?e.listAgentRuns(i.runsOf,50,ee,vt):e.listRuns(50,ee,vt)).then(pe=>{re===ve.current&&(H(je=>Gd(je??[],pe.runs)),we(pe.next_cursor),Fe(null))}).catch(pe=>Fe(ot(pe,"more runs"))).finally(()=>ae(!1))}:void 0})})})}N1();S1.createRoot(document.getElementById("root")).render(t.jsx(u.StrictMode,{children:t.jsx(T_,{children:t.jsx(HF,{})})}));export{VF as D,JF as d};
@@ -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 F,a6 as e,a9 as P,ao as M,r as c,b1 as D,am as R,as as H,cM as N,aY as K,a7 as v,a_ as U,bU as G,cr as V,cu as W,cB as Y,a$ as Z,b6 as J,aR as q,bV as Q,ab as C,ag as $,cK as X,cL as ee}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 te=F("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"}]]),se="agentrun.share/1",ae=new Set(["label","personal","jev"]),re=(t,s=!1)=>ae.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."},ne=[{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}],_="<url>";function oe(t,s){const a=s.restored.map(n=>n.id);return["agentrun share",t,"--to",_,...a.length?["--restore",a.join(",")]:[],"--expect",s.sha256].join(" ")}const le=t=>t.replace(/~1/g,"/").replace(/~0/g,"~");function k(t,s){var l;const[a,...n]=t.split("/").slice(1).map(le);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 O(t){const s=t;return!!s&&s.format===se&&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 ie({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 O(i)?{ok:!0,bundle:i}:{ok:!1,status:500}}}}function de({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 O(r)?{ok:!0,bundle:r}:{ok:!1,status:500}}}}const ce=/^[a-z2-7]{26}$/;function he(t){const s=/^\/r\/([^/]+)\/?$/.exec(t);return s&&ce.test(s[1])?s[1]:null}function ue(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 me=/^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;function xe(t){const s=/^\/share\/([^/]+)\/?$/.exec(t);return s&&me.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 pe(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 fe({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=ne.map(r=>({...r,items:pe(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(P,{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=re(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(M,{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(te,{className:"size-3","aria-hidden":!0})," Locked"]})]},o.id)})})]},r.kind)})]})}const ge=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 I({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=D(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?H(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(K,{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(U,{id:"share",tabs:f,value:r,onChange:i,label:"The run's views"}),e.jsxs("div",{...Z("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(G,{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(V,{run:n,rows:t.rows,files:l,onOpen:d=>p(d.path),shared:!0})]}),r==="timeline"&&e.jsx(W,{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(Y,{data:t.graph,fileUrl:()=>"",shared:!0})}),r==="files"&&e.jsx(be,{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(fe,{bundle:t,onToggle:s.onToggle,pending:s.pending})})]})}),s&&e.jsx(je,{bundle:t,preview:s,width:g})]})}function be({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(J,{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:q(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:ge(l)},r))})]})]})}function je({bundle:t,preview:s,width:a}){const n=oe(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("span",{className:"text-label text-muted-foreground",children:"Publish to your share host with"}),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.jsxs("p",{className:"text-label text-muted-foreground max-sm:hidden",children:["The command checks a fresh export against this sha256 and refuses if the run changed. Sign in to the share host once with ",e.jsxs("code",{className:"font-mono",children:["agentrun login --share ",_," < TOKEN_FILE"]}),"."]})]})})}function we(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 ye(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 L({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 Ne extends c.Component{constructor(){super(...arguments);T(this,"state",{failed:!1})}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?e.jsx(L,{title:"This share can't be shown.",why:"Its stored document doesn't have the shape this page draws."}):this.props.children}}function ve({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(Ne,{children:e.jsx(I,{bundle:n.bundle})});const{title:r,why:i}=ye(n.status);return e.jsx(L,{title:r,why:i,retry:n.status!==404&&n.status!==410?()=>a(o=>o+1):void 0})}function ke({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}=we(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(I,{bundle:o,preview:{runId:s,onToggle:y,pending:b}})}X();const A=xe(window.location.pathname),E=he(window.location.pathname);ee.createRoot(document.getElementById("root")).render(e.jsx(c.StrictMode,{children:E?e.jsx(ve,{source:de({shareId:E})}):A?e.jsx(ke,{source:ie({runId:A}),runId:A,restore:ue(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>."})}));
@@ -6,7 +6,7 @@
6
6
  <meta name="color-scheme" content="light dark" />
7
7
  <title>AgentRun</title>
8
8
  <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201080%201080'%3e%3cpath%20fill='%23ff8700'%20d='M271%20216H485L809%20540%20485%20864H271L595%20540Z'/%3e%3c/svg%3e" />
9
- <script type="module" crossorigin src="./assets/index-CG5tELph.js"></script>
9
+ <script type="module" crossorigin src="./assets/index-C8Y5Zl8x.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="./assets/styles-BGZxYkky.js">
11
11
  <link rel="stylesheet" crossorigin href="./assets/styles-D0SufbzK.css">
12
12
  </head>
@@ -7,7 +7,7 @@
7
7
  <meta name="robots" content="noindex" />
8
8
  <title>Share preview · AgentRun</title>
9
9
  <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' fill='%23ff8000'/%3E%3Cpath d='M12 9l11 7-11 7z' fill='%23000'/%3E%3C/svg%3E" />
10
- <script type="module" crossorigin src="./assets/share-CIeFK2Oe.js"></script>
10
+ <script type="module" crossorigin src="./assets/share-CjBJ_rxP.js"></script>
11
11
  <link rel="modulepreload" crossorigin href="./assets/styles-BGZxYkky.js">
12
12
  <link rel="stylesheet" crossorigin href="./assets/styles-D0SufbzK.css">
13
13
  </head>
@@ -23,7 +23,9 @@ export interface OpenCodeAdapterOptions {
23
23
  price?: ModelProxyOptions["price"];
24
24
  /** The most output tokens one request may ask for. Default 32 000. */
25
25
  maxOutputTokens?: number;
26
- /** The model's context window. Default 272 000. */
26
+ /** The model's context window, in tokens: OpenCode is told it (its model's `limit.context`), and the host's bound on one
27
+ * tool result is its share of it (the kernel's resultMaxChars). A session's own (SessionSpec.contextWindow) wins. With
28
+ * neither, OpenCode is told 272 000 and the host's bound alone holds a result. */
27
29
  contextWindow?: number;
28
30
  /** Where sessions keep their private directories when the host lends none (`io.dir`): one per session key. */
29
31
  sessionsDir?: string;
@@ -12,7 +12,7 @@ import { createHash, randomBytes, randomUUID } from "node:crypto";
12
12
  import { join } from "node:path";
13
13
  import { READ_SKILL_FILE, hostedTool, readSkillFileTool, skillProblems, toolSchemaProblems } from "@parcha/agentrun-kernel";
14
14
  import { abortedOutcome, openDrive, pendingSubmissions, SessionHalt } from "@parcha/agentrun-kernel/kernel";
15
- import { bridgeTool, recoveryNote, settleTurn, transcriptOf } from "@parcha/agentrun-kernel/process";
15
+ import { bridgeTool, recoveryNote, settleTurn, transcriptOf, windowBudget } from "@parcha/agentrun-kernel/process";
16
16
  import { serialWriter, startModelProxy } from "@parcha/agentrun-kernel/host";
17
17
  import { openCodeHarness, sentSubmissions } from "./harness.js";
18
18
  import { openCodePolicy, TOOL_PREFIX } from "./host/policy.js";
@@ -131,6 +131,7 @@ export function openCodeAdapter(options) {
131
131
  }
132
132
  const instructions = [...spec.system, ...(skills.length ? [skillsNote(skills)] : [])].join("\n\n");
133
133
  const effort = spec.effort ?? spec.thinking;
134
+ const window = spec.contextWindow ?? options.contextWindow;
134
135
  let control;
135
136
  const harness = openCodeHarness({
136
137
  tools: tools.map((tool) => bridgeTool(tool)),
@@ -146,7 +147,10 @@ export function openCodeAdapter(options) {
146
147
  hooks: io.models,
147
148
  ...(options.price ? { price: options.price } : {}),
148
149
  ...(options.maxOutputTokens ? { maxOutputTokens: options.maxOutputTokens } : {}),
149
- contextWindow: options.contextWindow ?? 272_000,
150
+ // The window the host knows (the session's, from its catalog; else this adapter's). Only with neither is OpenCode
151
+ // told 272,000, a guess, and then no tool result is held to it: the host's bound alone.
152
+ contextWindow: window ?? 272_000,
153
+ ...windowBudget(window, spec.system),
150
154
  ...(options.eventConnectMs ? { eventConnectMs: options.eventConnectMs } : {}),
151
155
  ...(options.log ? { log: options.log } : {}),
152
156
  ...(options.fetch ? { fetch: options.fetch } : {}),
@@ -1,5 +1,6 @@
1
1
  import type { GateAnswer, GateCall } from "@parcha/agentrun-kernel";
2
2
  import type { DriveContext, HostTool, SessionState } from "@parcha/agentrun-kernel/kernel";
3
+ import { type ResultBudget } from "@parcha/agentrun-kernel/process";
3
4
  import { type ModelProxyHooks, type ModelProxyOptions, type ParentWatch } from "@parcha/agentrun-kernel/host";
4
5
  import { type ConfineChild } from "./host/server.js";
5
6
  /** The journal stream that holds OpenCode's own events for the session, as `/sync/history` gives them. */
@@ -51,6 +52,9 @@ export interface OpenCodeHarnessOptions {
51
52
  price?: ModelProxyOptions["price"];
52
53
  maxOutputTokens?: number;
53
54
  contextWindow: number;
55
+ /** What the session's model can take of one tool result (its context window): the tool bridge holds every result to
56
+ * it (boundResult's budget). Absent: the host's bound alone (HOST_RESULT_MAX_CHARS). */
57
+ resultBudget?: ResultBudget;
54
58
  /** How long one try of the event stream may take to open. Default EVENT_CONNECT_MS. */
55
59
  eventConnectMs?: number;
56
60
  log?: (message: string, fields?: Record<string, unknown>) => void;
@@ -17,7 +17,7 @@
17
17
  import { createHash, randomBytes } from "node:crypto";
18
18
  import { mkdirSync, rmSync, writeFileSync } from "node:fs";
19
19
  import { isAbsolute, join, normalize } from "node:path";
20
- import { journalRecords, NativeJournal, placeSubmissions, recoveryNote, resumeUnstartedCalls, toolBridge, transcriptOf } from "@parcha/agentrun-kernel/process";
20
+ import { journalRecords, journalTurn, NativeJournal, placeSubmissions, recoveryNote, resumeUnstartedCalls, toolBridge, transcriptOf } from "@parcha/agentrun-kernel/process";
21
21
  import { startModelProxy } from "@parcha/agentrun-kernel/host";
22
22
  import { openCodeConfig } from "./config.js";
23
23
  import { danglingCalls, settleCall } from "./transcript.js";
@@ -187,6 +187,8 @@ export function openCodeHarness(options, control) {
187
187
  mkdirSync(root, { recursive: true, mode: 0o700 });
188
188
  const configFile = join(dirs.config, "agentrun-opencode.json");
189
189
  const journal = new NativeJournal(ctx);
190
+ // The turn's budget kept on this drive's journal: a resume answers the calls it left on its answer's facts.
191
+ journalTurn(options.resultBudget?.turn, journal);
190
192
  const mirrored = (await journal.read(SYNC_STREAM)).map((r) => r.data).filter(isSyncEvent);
191
193
  const prompts = (await journal.read(PROMPT_STREAM)).map((r) => r.data);
192
194
  let sessionID = mirrored[0]?.aggregate_id;
@@ -226,6 +228,7 @@ export function openCodeHarness(options, control) {
226
228
  const bridge = toolBridge(ctx, options.tools, {
227
229
  ...(gate ? { gate: async (call) => (await barrier(), gate(call)) } : {}),
228
230
  beforeNever: () => barrier(),
231
+ ...(options.resultBudget ? { budget: options.resultBudget } : {}),
229
232
  });
230
233
  // A resumed session: each call OpenCode started and never ended goes through the shared decision before OpenCode
231
234
  // starts again. A call that never reached its intent runs through the bridge under its own id (the gate, its intent,
@@ -252,6 +255,8 @@ export function openCodeHarness(options, control) {
252
255
  const proxy = await startModelProxy({
253
256
  policy: openCodePolicy({ model: options.model, tools: options.tools.map((t) => t.name), ...(options.maxOutputTokens ? { maxOutputTokens: options.maxOutputTokens } : {}), onCall: (call) => calls.add(call) }),
254
257
  hooks,
258
+ // The turn budget the bridge's calls share: the proxy opens it with each answer's facts.
259
+ ...(options.resultBudget?.turn ? { turn: options.resultBudget.turn } : {}),
255
260
  model: options.model,
256
261
  origin: options.provider.origin,
257
262
  credential: async () => (await options.provider.credential()) ?? "",
@@ -18,7 +18,8 @@ export type ToolResults = Map<string, {
18
18
  * `waitForTask` are the run's own Harness's (run.harness, the claim's journal on the runner), as `commit` is: a
19
19
  * document or a task of this run, never another's. A remote executor (workspace/executors.ts
20
20
  * piExecutor) has no run Harness and gives none of these three (RUN_ONLY_MEMBERS); the coding tools it runs read none.
21
- * `memo` and `taskId` are a pi tool task's own, which a host tool runs in none of: they are not given here. */
21
+ * `memo` and `taskId` are a pi tool task's own, which a host tool runs in none of: they are not given here, but to a tool
22
+ * whose binding runs each call once (RUNS_ONCE), whose `memo` is the call's own. */
22
23
  export declare const HOST_API_MEMBERS: readonly ["env", "callId", "commit", "output", "outputWindow", "retainedOutput", "diagnostic", "agent", "models", "conversationId", "snapshot", "waitForTask"];
23
24
  /** The members a host tool's api gives only on a run's Harness: a remote executor's api has none of them. */
24
25
  export declare const RUN_ONLY_MEMBERS: readonly ["conversationId", "snapshot", "waitForTask"];
@@ -44,8 +45,22 @@ export interface HostToolCtx {
44
45
  refused: string;
45
46
  } | undefined;
46
47
  }
48
+ /** How a tool with no host row (tool-list.ts `replay`) runs as a host tool, given by its own binding: the browser on a
49
+ * harness other than pi (runner/adapter-run-spec.ts browserHostTools). It is never replay-safe, so its call's intent is
50
+ * flushed before it acts (runner/side-effects.ts) and a crash at any point leaves the call's start on the record. Each
51
+ * call runs once, and its api's `memo` is the call's own, empty at its start and gone at its end: no other call, before,
52
+ * after or beside it, reads it. pi's memo is a tool task's, durable across that task's invocations, which lets pi run a
53
+ * cut call again from what it kept; a call that runs once has one invocation. So a run that resumes with such a call in
54
+ * flight (its runner stopped or crashed) has that call ended interrupted by the record's open ("may or may not have
55
+ * taken effect", runner/adapter-loop.ts openCliRecord), never runs it again, and the model goes on from that answer.
56
+ * After a crash the session it drove is the binding's reconcile's to take back on the next claim; a runner's own stop
57
+ * lets it go (the loop's beforeRelease on a shutdown). */
58
+ export declare const RUNS_ONCE: {
59
+ readonly replay: "never";
60
+ readonly memo: "call";
61
+ };
47
62
  /** One pi ToolRegistration `tool` (named `name` by its catalog name) as the kernel's HostTool an adapter session takes:
48
63
  * the paid-call seam, then the tool on the run's environment and harness, its answer the text a
49
64
  * model reads (the output or the failure, a write's or an error's path named relative to the run's folder). Undefined when
50
- * `name` is not one a host runs (tool-list.ts `replay`). */
51
- export declare function hostToolOf(name: string, tool: ToolRegistration, ctx: HostToolCtx): HostTool | undefined;
65
+ * `name` is not one a host runs (tool-list.ts `replay`) and its binding gives no `own` way to run it (RUNS_ONCE). */
66
+ export declare function hostToolOf(name: string, tool: ToolRegistration, ctx: HostToolCtx, own?: typeof RUNS_ONCE): HostTool | undefined;
@@ -19,7 +19,8 @@ export { cutUtf8, MAX_BYTES, MAX_LINES } from "./workspace/executors.js";
19
19
  * `waitForTask` are the run's own Harness's (run.harness, the claim's journal on the runner), as `commit` is: a
20
20
  * document or a task of this run, never another's. A remote executor (workspace/executors.ts
21
21
  * piExecutor) has no run Harness and gives none of these three (RUN_ONLY_MEMBERS); the coding tools it runs read none.
22
- * `memo` and `taskId` are a pi tool task's own, which a host tool runs in none of: they are not given here. */
22
+ * `memo` and `taskId` are a pi tool task's own, which a host tool runs in none of: they are not given here, but to a tool
23
+ * whose binding runs each call once (RUNS_ONCE), whose `memo` is the call's own. */
23
24
  export const HOST_API_MEMBERS = ["env", "callId", "commit", "output", "outputWindow", "retainedOutput", "diagnostic", "agent", "models", "conversationId", "snapshot", "waitForTask"];
24
25
  /** The members a host tool's api gives only on a run's Harness: a remote executor's api has none of them. */
25
26
  export const RUN_ONLY_MEMBERS = ["conversationId", "snapshot", "waitForTask"];
@@ -32,12 +33,33 @@ const hostApi = (given) => new Proxy(given, {
32
33
  });
33
34
  /** The tools whose result is pi's own words about a path (`Successfully wrote to <path>`), never a file's text. */
34
35
  const SAYS_PATH = new Set(["write", "edit"]);
36
+ /** How a tool with no host row (tool-list.ts `replay`) runs as a host tool, given by its own binding: the browser on a
37
+ * harness other than pi (runner/adapter-run-spec.ts browserHostTools). It is never replay-safe, so its call's intent is
38
+ * flushed before it acts (runner/side-effects.ts) and a crash at any point leaves the call's start on the record. Each
39
+ * call runs once, and its api's `memo` is the call's own, empty at its start and gone at its end: no other call, before,
40
+ * after or beside it, reads it. pi's memo is a tool task's, durable across that task's invocations, which lets pi run a
41
+ * cut call again from what it kept; a call that runs once has one invocation. So a run that resumes with such a call in
42
+ * flight (its runner stopped or crashed) has that call ended interrupted by the record's open ("may or may not have
43
+ * taken effect", runner/adapter-loop.ts openCliRecord), never runs it again, and the model goes on from that answer.
44
+ * After a crash the session it drove is the binding's reconcile's to take back on the next claim; a runner's own stop
45
+ * lets it go (the loop's beforeRelease on a shutdown). */
46
+ export const RUNS_ONCE = { replay: "never", memo: "call" };
47
+ /** One call's memo, as pi's tool task's reads: `memo(name, context)` reads it, `memo(name, candidate, context)` stores the
48
+ * candidate unless one is stored and answers the one stored. */
49
+ function callMemo() {
50
+ const kept = new Map();
51
+ return (async (name, ...rest) => {
52
+ if (rest.length >= 2 && !kept.has(name))
53
+ kept.set(name, rest[0]);
54
+ return kept.get(name);
55
+ });
56
+ }
35
57
  /** One pi ToolRegistration `tool` (named `name` by its catalog name) as the kernel's HostTool an adapter session takes:
36
58
  * the paid-call seam, then the tool on the run's environment and harness, its answer the text a
37
59
  * model reads (the output or the failure, a write's or an error's path named relative to the run's folder). Undefined when
38
- * `name` is not one a host runs (tool-list.ts `replay`). */
39
- export function hostToolOf(name, tool, ctx) {
40
- const replay = replayOf(name);
60
+ * `name` is not one a host runs (tool-list.ts `replay`) and its binding gives no `own` way to run it (RUNS_ONCE). */
61
+ export function hostToolOf(name, tool, ctx, own) {
62
+ const replay = own?.replay ?? replayOf(name);
41
63
  if (!replay)
42
64
  return undefined;
43
65
  return {
@@ -66,6 +88,7 @@ export function hostToolOf(name, tool, ctx) {
66
88
  models: createModels(),
67
89
  conversationId: ROOT_CONVERSATION_ID,
68
90
  snapshot: ctx.snapshot, waitForTask: ctx.waitForTask,
91
+ ...(own ? { memo: callMemo() } : {}),
69
92
  });
70
93
  // A tool that throws (bash on a non-zero exit or a timeout) still answers with its output, as pi's harness does;
71
94
  // one that answers a failure as an error result is kept as it is.