humanish 0.90.0 → 0.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +11 -7
  2. package/dist/automatic-analysis-completion.d.ts +4 -4
  3. package/dist/automatic-analysis-completion.js +10 -8
  4. package/dist/automatic-analysis-completion.js.map +1 -1
  5. package/dist/automatic-analysis-config.d.ts +9 -1
  6. package/dist/automatic-analysis-config.js +15 -2
  7. package/dist/automatic-analysis-config.js.map +1 -1
  8. package/dist/automatic-study-analysis.d.ts +5 -2
  9. package/dist/automatic-study-analysis.js +34 -15
  10. package/dist/automatic-study-analysis.js.map +1 -1
  11. package/dist/concurrent-shared-world-lab.js +1 -1
  12. package/dist/concurrent-shared-world-lab.js.map +1 -1
  13. package/dist/cua-actor-lab.js +1 -1
  14. package/dist/cua-actor-lab.js.map +1 -1
  15. package/dist/e2b-terminal-lab.js +6 -1
  16. package/dist/e2b-terminal-lab.js.map +1 -1
  17. package/dist/index.d.ts +3 -2
  18. package/dist/index.js +1 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/lab-config.d.ts +2 -2
  21. package/dist/lab-config.js +2 -2
  22. package/dist/lab-config.js.map +1 -1
  23. package/dist/lab-preflight.d.ts +3 -0
  24. package/dist/lab-preflight.js +3 -0
  25. package/dist/lab-preflight.js.map +1 -1
  26. package/dist/lab-summary.js +6 -4
  27. package/dist/lab-summary.js.map +1 -1
  28. package/dist/observer-app.html +8 -8
  29. package/dist/program.js +7 -1
  30. package/dist/program.js.map +1 -1
  31. package/dist/scripted-browser-lab.js +5 -5
  32. package/dist/scripted-browser-lab.js.map +1 -1
  33. package/dist/shared-world-lab.js +1 -1
  34. package/dist/shared-world-lab.js.map +1 -1
  35. package/dist/study-analysis-engine.d.ts +1 -1
  36. package/dist/study-analysis-engine.js +9 -3
  37. package/dist/study-analysis-engine.js.map +1 -1
  38. package/dist/study-analysis-evidence.js +233 -47
  39. package/dist/study-analysis-evidence.js.map +1 -1
  40. package/dist/study-analysis-job.d.ts +1 -0
  41. package/dist/study-analysis-job.js +1 -1
  42. package/dist/study-analysis-job.js.map +1 -1
  43. package/dist/study-analysis-validation.d.ts +133 -0
  44. package/dist/study-analysis-validation.js +51 -22
  45. package/dist/study-analysis-validation.js.map +1 -1
  46. package/dist/study-analysis.d.ts +8 -0
  47. package/dist/terminal-participant-activity.d.ts +6 -0
  48. package/dist/terminal-participant-activity.js +34 -0
  49. package/dist/terminal-participant-activity.js.map +1 -0
  50. package/dist/tui-app.js +1 -1
  51. package/docs/architecture/examples/state-driven-local-app/README.md +5 -0
  52. package/docs/architecture/examples/state-driven-local-app/runner.mjs +1 -0
  53. package/docs/contracts/schemas.md +1 -1
  54. package/docs/contracts/study-analysis.md +31 -5
  55. package/docs/goals/current.md +4 -4
  56. package/docs/principles/invariants-and-defaults.md +7 -3
  57. package/docs/product/automatic-analysis.md +25 -7
  58. package/docs/ramp/README.md +7 -2
  59. package/docs/release/0.91.0-analysis-quality-and-defaults.md +33 -0
  60. package/package.json +1 -1
package/dist/tui-app.js CHANGED
@@ -283,7 +283,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
283
283
  `))}patchConsole(){this.options.debug||(this.restoreConsole=t1((i,o)=>{i==="stdout"&&this.writeToStdout(o),i==="stderr"&&(o.startsWith("The above error occurred")||this.writeToStderr(o))}))}registerInputControl(i,o){this.pauseInput=i,this.resumeInput=o}async suspendTerminal(i){if(this.beginSuspend(),i){try{await i()}finally{await this.endSuspend()}return}let o=u(async()=>{await this.endSuspend()},"resume");return{resume:o,[Symbol.asyncDispose]:o}}setAlternateScreen(i){this.alternateScreen=this.resolveAlternateScreenOption(i,this.interactive),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,Hn.enterAlternativeScreen),this.writeBestEffort(this.options.stdout,yc))}resolveInteractiveOption(i){return i??(!eB&&!!this.options.stdout.isTTY)}resolveAlternateScreenOption(i,o){return!!i&&o&&!!this.options.stdout.isTTY}shouldSync(){return MR(this.options.stdout,this.interactive)}writeBestEffort(i,o){try{i.write(o)}catch{}}async awaitExit(){try{await this.exitPromise}catch{}}hasPendingConcurrentWork(){let i=this.container;return(i.pendingLanes??0)!==0&&i.callbackNode!==void 0&&i.callbackNode!==null}async awaitNextRender(){if(!this.nextRenderCommit){let i,o=new Promise(c=>{i=c});this.nextRenderCommit={promise:o,resolve:i}}return this.nextRenderCommit.promise}renderInteractiveFrame(i,o,c){let d=c!=="",m=this.options.stdout.isTTY,h=m?mc(this.options.stdout).rows:24,y=m&&o>=h?i:i+`
284
284
  `;if(pH({isTty:m,viewportRows:h,previousOutputHeight:this.lastOutputHeight,nextOutputHeight:o,isUnmounting:this.isUnmounting})){let x=this.shouldSync();x&&this.options.stdout.write(Dc),this.options.stdout.write(Hn.clearTerminal+this.fullStaticOutput+y),this.lastOutput=i,this.lastOutputToRender=y,this.lastOutputHeight=o,this.log.sync(y),x&&this.options.stdout.write(Kr);return}if(d){let x=this.shouldSync();x&&this.options.stdout.write(Dc),this.log.clear(),this.options.stdout.write(c),this.log(y),x&&this.options.stdout.write(Kr)}else(i!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(y);this.lastOutput=i,this.lastOutputToRender=y,this.lastOutputHeight=o}initKittyKeyboard(){if(!this.options.kittyKeyboard)return;let i=this.options.kittyKeyboard,o=i.mode??"auto";if(o==="disabled")return;let c=i.flags??["disambiguateEscapeCodes"];if(o==="enabled"){this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(c);return}!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(c)}confirmKittySupport(i){let{stdin:o,stdout:c}=this.options,d=[],m=u(()=>{this.cancelKittyDetection=void 0,clearTimeout(Q),o.removeListener("data",h);let y=EH(d);d=[],y.length>0&&o.unshift(Uint8Array.from(y))},"cleanup"),h=u(y=>{let N=typeof y=="string"?iH.encode(y):y;for(let x of N)d.push(x);dH(d)&&(m(),this.isUnmounted||this.enableKittyProtocol(i))},"onData");o.on("data",h);let Q=setTimeout(m,200);this.cancelKittyDetection=m,c.write("\x1B[?u")}enableKittyProtocol(i){this.options.stdout.write(`\x1B[>${R0(i)}u`),this.kittyProtocolEnabled=!0,this.kittyFlags=i}beginSuspend(){if(this.isSuspended)throw new Error("The terminal is already suspended. Resume the current suspension before suspending again.");if(this.isSuspended=!0,!(!this.interactive||this.isUnmounted||this.isUnmounting))try{let i=this.options.stdout,{canWriteToStdout:o}=uh(i);sd(this.throttledOnRender,o),sd(this.throttledLog,o),o&&(this.log.clear(),this.log.done(),this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen&&this.writeBestEffort(this.options.stdout,Hn.exitAlternativeScreen)),this.pauseInput?.()}catch(i){this.isSuspended=!1;try{this.resumeInput?.()}catch{}throw i}}async endSuspend(){if(!this.isSuspended||(this.isSuspended=!1,this.resumeInput?.(),!this.interactive||this.isUnmounted||this.isUnmounting))return;let i=this.options.stdout,{canWriteToStdout:o}=uh(i);o&&(this.alternateScreen&&this.writeBestEffort(this.options.stdout,Hn.enterAlternativeScreen),this.kittyProtocolEnabled&&this.kittyFlags&&this.writeBestEffort(this.options.stdout,`\x1B[>${R0(this.kittyFlags)}u`)),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.log.reset();try{this.calculateLayout(),this.onRender(),await this.waitUntilRenderFlush()}catch{}}};var BH=u((n,i)=>{let o={stdout:Vm.stdout,stdin:Vm.stdin,stderr:Vm.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,maxFps:30,incrementalRendering:!1,concurrent:!1,alternateScreen:!1,...hH(i)},c=IH(o.stdout,()=>new km(o));return c.render(n),{rerender:c.render,unmount(){c.unmount()},waitUntilExit:c.waitUntilExit,waitUntilRenderFlush:c.waitUntilRenderFlush,cleanup(){c.unmount()},clear:c.clear}},"render"),T0=BH,hH=u((n={})=>n instanceof CH?{stdout:n,stdin:Vm.stdin}:n,"getOptions"),IH=u((n,i)=>{let o=Jm.get(n);if(o===void 0){let c=i();return Jm.set(n,c),c}return Vm.stderr.write(`Warning: render() was called again for the same stdout before the previous Ink instance was unmounted. Reusing stdout across multiple render() calls is unsupported. Call unmount() first.
285
285
  `),o},"getInstance");var QH=Tt(iB(),1);var rh=Tt(Ue(),1);var B2=Tt(Ue(),1);var yH=Tt(Ue(),1);var SH=Tt(Ue(),1);var Xm=Tt(Ue(),1);var h2=new TextDecoder,vH=/^(?:\x1b)([a-zA-Z0-9])$/,DH=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Q2={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},y2=[...Object.values(Q2),"backspace"],RH=u(n=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(n),"isShiftKey"),NH=u(n=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(n),"isCtrlKey"),S2=/^\x1b\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,bH=/^\x1b\[(\d+);(\d+):(\d+)([A-Za-z~])$/,TH={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},xH={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},I2={27:"escape",9:"tab",127:"backspace",8:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},v2=u(n=>n>=0&&n<=1114111&&!(n>=55296&&n<=57343),"isValidCodepoint"),x0=u(n=>v2(n)?String.fromCodePoint(n):"?","safeFromCodePoint");function D2(n){return n===3?"release":n===2?"repeat":"press"}u(D2,"resolveEventType");function R2(n){return{ctrl:!!(n&qu.ctrl),shift:!!(n&qu.shift),meta:!!(n&(qu.meta|qu.alt)),super:!!(n&qu.super),hyper:!!(n&qu.hyper),capsLock:!!(n&qu.capsLock),numLock:!!(n&qu.numLock)}}u(R2,"parseKittyModifiers");var _H=u(n=>{let i=S2.exec(n);if(!i)return null;let o=parseInt(i[1],10),c=i[2]?Math.max(0,parseInt(i[2],10)-1):0,d=i[3]?parseInt(i[3],10):1,m=i[4];if(!v2(o))return null;let h;m&&(h=m.split(":").map(N=>x0(parseInt(N,10))).join(""));let Q,y;return o===32?(Q="space",y=!0):o===13?(Q="return",y=!0):I2[o]?(Q=I2[o],y=!1):o>=1&&o<=26?(Q=String.fromCodePoint(o+96),y=!1):(Q=x0(o).toLowerCase(),y=!0),y&&!h&&(h=x0(o)),{name:Q,...R2(c),eventType:D2(d),sequence:n,raw:n,isKittyProtocol:!0,isPrintable:y,text:h}},"parseKittyKeypress"),MH=u(n=>{let i=bH.exec(n);if(!i)return null;let o=parseInt(i[1],10),c=Math.max(0,parseInt(i[2],10)-1),d=parseInt(i[3],10),m=i[4],h=m==="~"?xH[o]:TH[m];return h?{name:h,...R2(c),eventType:D2(d),sequence:n,raw:n,isKittyProtocol:!0,isPrintable:!1}:null},"parseKittySpecialKey"),UH=u((n="")=>{let i;n instanceof Uint8Array?n[0]>127&&n[1]===void 0?(n[0]-=128,n="\x1B"+h2.decode(n)):n=h2.decode(n):n!==void 0&&typeof n!="string"?n=String(n):n||(n="");let o=_H(n);if(o)return o;let c=MH(n);if(c)return c;if(S2.test(n))return{name:"",ctrl:!1,meta:!1,shift:!1,sequence:n,raw:n,isKittyProtocol:!0,isPrintable:!1};let d={name:"",ctrl:!1,meta:!1,shift:!1,sequence:n,raw:n};if(d.sequence=d.sequence||n||d.name,n==="\r"||n==="\x1B\r")d.raw=void 0,d.name="return",d.meta=n.length===2;else if(n===`
286
- `)d.name="enter";else if(n===" ")d.name="tab";else if(n==="\b"||n==="\x1B\b")d.name="backspace",d.meta=n.charAt(0)==="\x1B";else if(n==="\x7F"||n==="\x1B\x7F")d.name="backspace",d.meta=n.charAt(0)==="\x1B";else if(n==="\x1B"||n==="\x1B\x1B")d.name="escape",d.meta=n.length===2;else if(n===" "||n==="\x1B ")d.name="space",d.meta=n.length===2;else if(n.length===1&&n<="")d.name=String.fromCharCode(n.charCodeAt(0)+97-1),d.ctrl=!0;else if(n.length===1&&n>="0"&&n<="9")d.name="number";else if(n.length===1&&n>="a"&&n<="z")d.name=n;else if(n.length===1&&n>="A"&&n<="Z")d.name=n.toLowerCase(),d.shift=!0;else if(i=vH.exec(n))d.name=i[1].toLowerCase(),d.meta=!0,d.shift=/^[A-Z]$/.test(i[1]);else if(i=DH.exec(n)){let m=[...n];m[0]==="\x1B"&&m[1]==="\x1B"&&(d.meta=!0);let h=[i[1],i[2],i[4],i[6]].filter(Boolean).join(""),Q=(i[3]||i[5]||1)-1;d.ctrl=!!(Q&4),d.meta=d.meta||!!(Q&10),d.shift=!!(Q&1),d.code=h,d.name=Q2[h]??"",d.shift=RH(h)||d.shift,d.ctrl=NH(h)||d.ctrl}return d},"parseKeypress"),N2=UH;var b2=Tt(Ue(),1);var _0=u(()=>(0,b2.useContext)(eh),"useStdinContext");var HH=u((n,i={})=>{let{setRawMode:o,internal_exitOnCtrlC:c,internal_eventEmitter:d}=_0();(0,Xm.useEffect)(()=>{if(i.isActive!==!1)return o(!0),()=>{o(!1)}},[i.isActive,o]);let m=(0,Xm.useEffectEvent)(h=>{let Q=N2(h),y={upArrow:Q.name==="up",downArrow:Q.name==="down",leftArrow:Q.name==="left",rightArrow:Q.name==="right",pageDown:Q.name==="pagedown",pageUp:Q.name==="pageup",home:Q.name==="home",end:Q.name==="end",return:Q.name==="return",escape:Q.name==="escape",ctrl:Q.ctrl,shift:Q.shift,tab:Q.name==="tab",backspace:Q.name==="backspace",delete:Q.name==="delete",meta:Q.meta,super:Q.super??!1,hyper:Q.hyper??!1,capsLock:Q.capsLock??!1,numLock:Q.numLock??!1,eventType:Q.eventType},N;Q.isKittyProtocol?Q.isPrintable?N=Q.text??Q.name:Q.ctrl&&Q.name.length===1?N=Q.name:N="":Q.ctrl?N=Q.name??"":N=Q.sequence,!Q.isKittyProtocol&&y2.includes(Q.name)&&(N=""),N.startsWith("\x1B")&&(N=N.slice(1)),N.length===1&&/[A-Z]/.test(N)&&(y.shift=!0),!(N==="c"&&y.ctrl&&c)&&wa.discreteUpdates(()=>{n(N,y)})});(0,Xm.useEffect)(()=>{if(i.isActive!==!1)return d.on("input",m),()=>{d.removeListener("input",m)}},[i.isActive,d])},"useInput"),M0=HH;var T2=Tt(Ue(),1);var x2=Tt(Ue(),1);var OH=u(()=>(0,x2.useContext)(th),"useApp"),U0=OH;var _2=Tt(Ue(),1);var wH=u(()=>(0,_2.useContext)(nh),"useStdout"),sh=wH;var GH=Tt(Ue(),1);var H0=Tt(Ue(),1);var zH=Tt(Ue(),1);var YH=Tt(Ue(),1);var ch=Tt(Ue(),1);var Zm=Tt(Ue(),1);var M2=Tt(Ue(),1);var fh=Tt(Ue(),1);var JH=/utf-?8/i;function Rc(n=process.env){if(process.platform==="win32")return!0;let i=n.LC_ALL??n.LC_CTYPE??n.LANG;return i===void 0||i.trim().length===0?!1:JH.test(i)}u(Rc,"terminalRendersUnicode");var KH=new Map([["\u2014","--"],["\u2013","-"],["\u2019","'"],["\u2018","'"],["\u201C",'"'],["\u201D",'"'],["\u2026","..."],["\xB7","-"],["\u276F",">"],["\u2039","<"],["\u25B8",">"],["\u2713","+"],["\u2691","!"],["\u23CE","Enter"],["\u2191","^"],["\u2193","v"],["\u2190","<-"],["\u2192","->"],["\xD7","x"],["\u2248","~"],["\u2717","x"]]);function U2(n,i=process.env){if(Rc(i))return n;let o="";for(let c of n){if(c.codePointAt(0)<128){o+=c;continue}o+=KH.get(c)??"?"}return o}u(U2,"forTerminal");var Xe=Tt(Ue(),1);var be={accent:"#93a2ff",ok:"#7dc9a0",warn:"#d9a441",bad:"#e0796b"};var Di=Tt(Qa(),1);function G2({columns:n}){let i=[["\u2191 \u2193 \xB7 k j","move the cursor"],["\u23CE \xB7 \u2192","open what the cursor is on, or run the action it names"],["esc \xB7 \u2190","back \u2014 and it cancels an armed confirmation first"],["g \xB7 G","jump to the top, jump to the bottom"],["?","these keys"],["q","quit \u2014 a run you started keeps going without this window"]];return(0,Di.jsxs)(ht,{flexDirection:"column",width:n,children:[(0,Di.jsx)(rt,{color:be.accent,bold:!0,children:"Keys"}),(0,Di.jsx)(ht,{marginTop:1,flexDirection:"column",children:i.map(([o,c])=>(0,Di.jsxs)(ht,{children:[(0,Di.jsx)(ht,{width:16,children:(0,Di.jsx)(rt,{bold:!0,children:o})}),(0,Di.jsx)(rt,{dimColor:!0,children:c})]},o))}),(0,Di.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[(0,Di.jsx)(rt,{dimColor:!0,children:"Starting a run asks twice when it spends money: the first \u23CE arms and"}),(0,Di.jsx)(rt,{dimColor:!0,children:"restates the cost, the second commits. A dry run never asks."})]})]})}u(G2,"HelpScreen");function jH(n){let i=new Map,o=[];for(let d of n){let m=d.lab?.id;if(m===void 0){o.push(d);continue}let h=i.get(m);h===void 0?i.set(m,[d]):h.push(d)}let c=[...i.entries()].map(([d,m])=>{let h=m.filter(Q=>Q.liveness==="running");return{labId:d,runs:m.length,live:h.length,...m[0]===void 0?{}:{latest:m[0]},liveRuns:h}});return c.sort((d,m)=>d.live!==m.live?m.live-d.live:Eh(m.latest)-Eh(d.latest)),{labs:c,unattributed:o}}u(jH,"groupRunsByLab");function Eh(n){if(n===void 0)return 0;for(let i of[n.completedAt,n.updatedAt,n.startedAt]){if(i===void 0)continue;let o=Date.parse(i);if(Number.isFinite(o))return o}return 0}u(Eh,"recencyOf");function L2(n,i){let c=(i===void 0?n:n.filter(Q=>Q.mode===i)).filter(Q=>Q.liveness==="finished"),d=c.map(Q=>Q.durationMs).filter(Q=>typeof Q=="number"&&Number.isFinite(Q)&&Q>=0).sort((Q,y)=>Q-y),m=c.map(Q=>Q.estimatedCostUsd).filter(Q=>typeof Q=="number"&&Number.isFinite(Q)).sort((Q,y)=>Q-y),h=c.filter(Q=>Q.estimatedCostUsd===null||Q.estimatedCostUsd===void 0).length;return{sample:c.length,...d.length===0?{}:{medianDurationMs:z2(d),durationRangeMs:{min:d[0],max:d[d.length-1]}},...m.length===0?{}:{medianCostUsd:z2(m)},costUnknown:h}}u(L2,"expectationFor");function z2(n){let i=Math.floor(n.length/2);return n.length%2===1?n[i]:(n[i-1]+n[i])/2}u(z2,"median");function Wm(n){if(n.sample===0)return"no runs yet";let i=[];if(n.durationRangeMs!==void 0){let{min:m,max:h}=n.durationRangeMs;i.push(m===h?Ri(m):`${Ri(m)}\u2013${Ri(h)}`)}n.medianCostUsd!==void 0&&i.push(`~$${n.medianCostUsd.toFixed(2)} median`);let o=`${n.sample} run${n.sample===1?"":"s"}`,c=n.sample>0&&n.costUnknown===n.sample,d=n.costUnknown===0?"":c?", none priced":`, ${n.costUnknown} unpriced`;return i.length===0?c?`${o}, nothing recorded`:`${o}${d}, nothing timed`:`${i.join(" \xB7 ")} \xB7 ${o}${d}`}u(Wm,"expectationLine");function mh(n){return n.runs===0?n.declared?"never run":"no runs":n.liveExpectation.sample>0?Wm(n.liveExpectation):`${n.runs} ${n.runs===1?"run":"runs"}, none live`}u(mh,"labSummaryLine");function Ri(n){let i=Math.max(0,Math.round(n/1e3));if(i<60)return`${i}s`;let o=Math.floor(i/60);if(o<60)return i%60===0?`${o}m`:`${o}m ${i%60}s`;let c=Math.floor(o/60);return o%60===0?`${c}h`:`${c}h ${o%60}m`}u(Ri,"formatDuration");function cd(n,i){let o=Math.max(8,Math.floor(i.width)),c=Math.max(1,Math.floor(i.maxLines)),d=n.replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\s*\n+\s*/g," ").replace(/\s{2,}/g," ").trim();if(d==="")return{lines:[],truncated:!1};let m=d.split(" "),h=[],Q="",y=0;for(;y<m.length;y+=1){let x=m[y],G=Q===""?x:`${Q} ${x}`;if(G.length<=o){Q=G;continue}if(Q!==""&&h.push(Q),Q=x.length<=o?x:`${x.slice(0,o-1)}\u2026`,x.length>o&&(h.push(Q),Q=""),h.length===c)break}h.length<c&&Q!==""&&(h.push(Q),y=m.length);let N=y<m.length;if(N&&h.length>0){let x=h[h.length-1];h[h.length-1]=x.length+1<=o?`${x}\u2026`:`${x.slice(0,o-1)}\u2026`}return{lines:h,truncated:N}}u(cd,"normalizeThought");function fd(n){let i=Math.max(0,Math.floor(n.total)),o=Math.max(1,Math.floor(n.viewport));if(i<=o)return{start:0,end:i};let c=Math.min(Math.max(0,Math.floor(n.selected)),i-1),d=Math.min(Math.max(0,Math.floor(n.margin??1)),Math.floor((o-1)/2)),m=Math.min(Math.max(0,c-d),i-o);return c>=m+o-d&&(m=Math.min(c-o+1+d,i-o)),m=Math.max(0,Math.min(m,i-o)),{start:m,end:m+o}}u(fd,"listWindow");function Y2(n){return(n.split("/").pop()??n).replace(/\.(ya?ml)$/i,"")}u(Y2,"labNameFromPath");function J2(n,i){let{labs:o,unattributed:c}=jH(i),d=new Map(o.map(G=>[G.labId,G])),m=new Map;for(let G of i){let b=G.lab?.id;if(b===void 0)continue;let L=m.get(b);L===void 0?m.set(b,[G]):L.push(G)}let h=new Map;for(let G of n)h.set(G.id,(h.get(G.id)??0)+1);let Q=u((G,b,L)=>{let j=d.get(G),q=b?.path;return{key:q??`id:${G}`,labId:G,name:q===void 0?G:Y2(q),...b?.title===void 0?{}:{title:b.title},...q===void 0?{}:{path:q},...b?.origin===void 0?{}:{origin:b.origin},declared:L,label:b?.title??(q===void 0?G:Y2(q)),...b?.description===void 0?{}:{description:b.description},sharesIdWith:Math.max(0,(h.get(G)??0)-1),runs:j?.runs??0,live:j?.live??0,...j?.latest===void 0?{}:{latest:j.latest},liveRuns:j?.liveRuns??[],expectation:L2(m.get(G)??[]),liveExpectation:L2(m.get(G)??[],"live")}},"build"),y=new Set(n.map(G=>G.id)),N=[...n.map(G=>Q(G.id,G,!0)),...o.filter(G=>!y.has(G.labId)).map(G=>Q(G.labId,void 0,!1))];kH(N);let x=u(G=>G.label,"label");return N.sort((G,b)=>{if(G.live!==b.live)return b.live-G.live;let L=u(q=>q.runs>0?0:q.declared?1:2,"rank");if(L(G)!==L(b))return L(G)-L(b);if(G.runs>0&&b.runs>0){let q=Eh(b.latest)-Eh(G.latest);if(q!==0)return q}let j=x(G).localeCompare(x(b));return j!==0?j:G.key.localeCompare(b.key)}),{rows:N,unattributed:c}}u(J2,"labRows");function kH(n){let i=u(d=>{let m=new Map;for(let h of d)m.set(h,(m.get(h)??0)+1);return m},"count"),o=i(n.map(d=>d.title??d.name)),c=i(n.map(d=>d.name));for(let d of n){let m=d.title??d.name;if((o.get(m)??0)===1){d.label=m;continue}d.label=(c.get(d.name)??0)===1?d.name:d.path??d.name}}u(kH,"assignLabels");function w0(n){switch(n.name){case"labs":return"labs";case"all-runs":return"all-runs";case"lab":return`lab:${n.labKey}`;default:return`run:${n.runId}`}}u(w0,"screenKey");function K2(){return{stack:[{name:"labs"}],selection:{},quit:!1}}u(K2,"initialNav");function Pm(n){return n.stack[n.stack.length-1]??{name:"labs"}}u(Pm,"currentScreen");function F2(n){return n.selection[w0(Pm(n))]??0}u(F2,"selectedIndex");function q2(n,i){switch(i.type){case"enter":return{...n,stack:[...n.stack,i.screen]};case"back":return n.stack.length<=1?{...n,quit:!0}:{...n,stack:n.stack.slice(0,-1)};case"move":{if(i.total<=0)return n;let o=w0(Pm(n)),c=n.selection[o]??0,d=Math.min(Math.max(0,c+i.delta),i.total-1);return d===c?n:{...n,selection:{...n.selection,[o]:d}}}case"select":{if(i.total<=0)return n;let o=w0(Pm(n)),c=Math.min(Math.max(0,i.index),i.total-1);return{...n,selection:{...n.selection,[o]:c}}}default:return{...n,quit:!0}}}u(q2,"navigate");function cA(n){return n===void 0?{}:{color:n}}u(cA,"color");var gu=Tt(Qa(),1),VH=96;function ph(n){return Math.max(20,Math.min(VH,n))}u(ph,"contentWidth");function j2({columns:n,context:i,breadcrumb:o,hints:c,children:d}){let m=ph(n);return(0,gu.jsxs)(ht,{flexDirection:"column",width:m,children:[(0,gu.jsxs)(ht,{width:m,children:[(0,gu.jsx)(rt,{bold:!0,children:"human(ish)"}),(0,gu.jsx)(ht,{flexGrow:1}),i===void 0?null:(0,gu.jsx)(rt,{dimColor:!0,wrap:"truncate-start",children:i})]}),o===void 0?null:(0,gu.jsx)(rt,{dimColor:!0,wrap:"truncate-start",children:o}),(0,gu.jsx)(ht,{marginTop:1,flexDirection:"column",children:d}),(0,gu.jsx)(ht,{marginTop:1,children:(0,gu.jsx)(rt,{dimColor:!0,children:c})})]})}u(j2,"Frame");var G0=Rc()?["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]:["|","/","-","\\","|","/","-","\\","|","/"];function $m(n){return G0[Math.abs(Math.floor(n))%G0.length]??G0[0]}u($m,"spinnerFrame");function Ni(n){return n?Rc()?"\u276F":">":" "}u(Ni,"gutter");function tp(n){if(n.liveness==="running")return $m(n.tick??0);let i=Rc();return n.liveness==="interrupted"||n.verdict==="fail"?i?"\u2691":"!":n.verdict===void 0?i?"\xB7":"-":i?"\u2713":"+"}u(tp,"verdictGlyph");function XH(n){if(n.liveness==="running")return be.ok;if(n.liveness==="interrupted")return be.warn;if(n.verdict==="fail")return be.bad}u(XH,"verdictColor");var gd=u(n=>cA(XH(n)),"glyphColor");function jr(n,i){let o=Math.max(4,Math.floor(i));return n.length<=o?n:`${n.slice(0,o-1)}\u2026`}u(jr,"fitLabelToWidth");var Rn=Tt(Qa(),1);function X2({runs:n,details:i,labels:o,expected:c,selected:d,columns:m,viewport:h,tick:Q,now:y}){if(n.length===0)return(0,Rn.jsxs)(ht,{flexDirection:"column",children:[(0,Rn.jsx)(rt,{children:"nobody is working right now"}),(0,Rn.jsx)(rt,{dimColor:!0,children:"start a run from any lab and it appears here"})]});let N=fd({total:n.length,selected:d,viewport:Math.max(2,h-6)}),x=n[Math.min(Math.max(0,d),n.length-1)],G=x===void 0?void 0:i.get(x.runId),b=G?.participants[0],L=b?.thought===void 0?void 0:cd(b.thought.text,{width:Math.max(16,m-2),maxLines:2});return(0,Rn.jsxs)(ht,{flexDirection:"column",children:[n.slice(N.start,N.end).map((j,q)=>(0,Rn.jsx)(ZH,{run:j,who:k2(i.get(j.runId))??"starting\u2026",lab:o.get(j.runId)??j.lab?.id??"",expectedMs:c.get(j.lab?.id??""),active:N.start+q===d,columns:m,tick:Q,now:y},j.runId)),L===void 0?null:(0,Rn.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[L.lines.map((j,q)=>(0,Rn.jsxs)(ht,{width:m,children:[(0,Rn.jsx)(ht,{width:2,flexShrink:0,children:(0,Rn.jsx)(rt,{color:be.accent,children:"\u258C"})}),(0,Rn.jsxs)(rt,{dimColor:!0,wrap:"truncate-end",children:[q===0?`"${j}`:j,q===L.lines.length-1?'"':""]})]},q)),(0,Rn.jsxs)(ht,{width:m,children:[(0,Rn.jsx)(ht,{width:2,flexShrink:0,children:(0,Rn.jsx)(rt,{children:" "})}),(0,Rn.jsx)(rt,{dimColor:!0,wrap:"truncate-end",children:jr([k2(G),o.get(x?.runId??"")].filter(Boolean).join(" \xB7 "),Math.max(10,m-2))})]})]}),(0,Rn.jsx)(ht,{marginTop:1,children:(0,Rn.jsx)(rt,{dimColor:!0,children:WH(n,i)})})]})}u(X2,"AllRunsScreen");function k2(n){let i=n?.participants[0];return i?.personaId??i?.label}u(k2,"personaOf");function ZH({run:n,who:i,lab:o,expectedMs:c,active:d,columns:m,tick:h,now:Q}){let y=n.startedAt===void 0?Number.NaN:Date.parse(n.startedAt),N=Number.isFinite(y)?V2(Q-y):"",x=c===void 0?N:`${N} / ~${V2(c)}`,G=Math.max(10,Math.floor((m-x.length-6)*.5)),b=Math.max(8,m-x.length-G-6);return(0,Rn.jsxs)(ht,{width:m,children:[(0,Rn.jsxs)(rt,{...cA(d?be.accent:void 0),bold:d,children:[Ni(d)," "]}),(0,Rn.jsxs)(rt,{color:be.ok,children:[$m(h)," "]}),(0,Rn.jsx)(ht,{width:G,children:(0,Rn.jsx)(rt,{...cA(d?be.accent:void 0),bold:d,wrap:"truncate-end",children:jr(i,G)})}),(0,Rn.jsx)(ht,{width:b,children:(0,Rn.jsx)(rt,{dimColor:!0,wrap:"truncate-end",children:jr(o,b)})}),(0,Rn.jsx)(ht,{flexGrow:1}),(0,Rn.jsx)(rt,{dimColor:!0,children:x})]})}u(ZH,"RunRow");function WH(n,i){let o=0,c=0;for(let h of n){let Q=h.estimatedCostUsd??i.get(h.runId)?.participants[0]?.estimatedCostUsd;typeof Q=="number"&&(o+=Q,c+=1)}if(c===0)return"no spend recorded yet \u2014 a live run prices itself as it goes";let d=n.length-c,m=d===0?"":` \xB7 ${d} not priced yet`;return`spend ~$${o.toFixed(2)} so far across ${c} of ${n.length}${m}`}u(WH,"spendLine");function V2(n){if(!Number.isFinite(n)||n<0)return"0:00";let i=Math.floor(n/1e3),o=Math.floor(i/60);return o<60?`${o}:${String(i%60).padStart(2,"0")}`:Ri(n)}u(V2,"clockOf");var Pt=Tt(Qa(),1);function Ch(n,i){return[...i?[{kind:"start",mode:"dry-run"},{kind:"start",mode:"live"}]:[],...n.map(c=>({kind:"run",run:c}))]}u(Ch,"labItems");function $2(n){let{row:i,summary:o,runs:c,selected:d,columns:m,viewport:h,now:Q,tick:y,canStart:N}=n,x=Ch(c,N);return(0,Pt.jsxs)(ht,{flexDirection:"column",children:[o?.description===void 0?null:(0,Pt.jsx)(rt,{wrap:"truncate-end",children:AO(o.description)}),o?.subject===void 0?null:(0,Pt.jsx)(rt,{dimColor:!0,wrap:"truncate-end",children:[o.subject,o.participants,o.model,o.reasoningEffort===void 0?void 0:`${o.reasoningEffort} effort`].filter(Boolean).join(" \xB7 ")}),(0,Pt.jsxs)(ht,{width:m,children:[(0,Pt.jsxs)(rt,{dimColor:!0,wrap:"truncate-end",children:[mh(i),nO(o)]}),(0,Pt.jsx)(ht,{flexGrow:1}),o?.keysReady===void 0?null:(0,Pt.jsx)(rt,{...cA(o.keysReady?be.ok:be.warn),children:o.keysReady?"keys \u2713":"keys \u2717"})]}),o?.analysis===void 0?null:(0,Pt.jsxs)(rt,{wrap:"wrap",children:["After live runs: analysis \xB7 ",o.analysis.model," \xB7 separate $",o.analysis.maxCostUsd," estimate limit"]}),o?.keysReady===!1?(0,Pt.jsxs)(ht,{flexDirection:"column",width:m,children:[(0,Pt.jsxs)(rt,{...cA(be.warn),children:[o.missingKeys?.join(", ")," not found"]}),(0,Pt.jsxs)(rt,{dimColor:!0,children:[" ","humanish keys set openai"," ","\u2014 stores them for every project"]}),(0,Pt.jsxs)(rt,{dimColor:!0,children:[" ","humanish tui --env-file .env"," ","\u2014 or just this session"]})]}):null,n.launchNote===void 0?null:(0,Pt.jsx)(ht,{marginTop:1,children:(0,Pt.jsx)(rt,{dimColor:!0,children:n.launchNote})}),n.launchError===void 0?null:(0,Pt.jsx)(ht,{marginTop:1,children:(0,Pt.jsx)(rt,{color:be.bad,children:n.launchError})}),N?(0,Pt.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[(0,Pt.jsx)(W2,{...n,mode:"dry-run",active:Z2(x,d)==="dry-run"}),(0,Pt.jsx)(W2,{...n,mode:"live",active:Z2(x,d)==="live"}),n.confirming==="live"?(0,Pt.jsx)(ht,{marginTop:1,children:(0,Pt.jsxs)(rt,{color:be.warn,children:[" ","start a live run? ",Wm(n.row.liveExpectation),o?.analysis?` + analysis ($${o.analysis.maxCostUsd} estimate limit)`:""," \xB7 \u23CE confirm \xB7 esc cancel"]})}):null]}):null,i.declared?null:(0,Pt.jsx)(ht,{marginTop:1,children:(0,Pt.jsx)(rt,{color:be.warn,children:"no manifest here \u2014 renamed, deleted, or run from elsewhere"})}),i.sharesIdWith>0?(0,Pt.jsxs)(rt,{color:be.warn,children:[i.sharesIdWith+1,' manifests declare "',i.labId,'" \u2014 these runs are shared between them']}):null,(0,Pt.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[(0,Pt.jsx)(rt,{dimColor:!0,children:"Runs"}),n.liveDetail?.automaticAnalysis===void 0?null:(0,Pt.jsxs)(rt,{children:["Latest analysis: ",n.liveDetail.automaticAnalysis.state," \xB7 open run for details"]}),c.length===0?(0,Pt.jsx)(rt,{dimColor:!0,children:" none yet"}):(0,Pt.jsx)(PH,{runs:c,liveDetail:n.liveDetail,selected:d-Ch([],N).length,columns:m,viewport:Math.max(2,h-6),now:Q,tick:y,expectedMs:i.liveExpectation.medianDurationMs})]})]})}u($2,"LabScreen");function Z2(n,i){let o=n[i];return o?.kind==="start"?o.mode:void 0}u(Z2,"activeStart");function W2({mode:n,confirming:i,active:o,columns:c,row:d,summary:m}){let h=n==="live",Q=h&&m?.keysReady===!1,y=h?be.warn:be.accent;return(0,Pt.jsxs)(ht,{width:c,children:[(0,Pt.jsxs)(rt,{...cA(o?y:void 0),bold:o,dimColor:Q&&!o,children:[Ni(o)," ",h?"Start a LIVE run":"Start a dry run"]}),(0,Pt.jsx)(ht,{flexGrow:1}),(0,Pt.jsx)(rt,{dimColor:!Q,...cA(Q?be.warn:void 0),children:h?Q?`${Wm(d.liveExpectation)} \xB7 needs keys`:Wm(d.liveExpectation):"free \xB7 no keys, no spend"})]})}u(W2,"StartRow");function PH({runs:n,liveDetail:i,selected:o,columns:c,viewport:d,now:m,tick:h,expectedMs:Q}){let y=fd({total:n.length,selected:o,viewport:d});return(0,Pt.jsxs)(ht,{flexDirection:"column",children:[y.start>0?(0,Pt.jsxs)(rt,{dimColor:!0,children:[" \u2191 ",y.start," more"]}):null,n.slice(y.start,y.end).map((N,x)=>N.liveness==="running"?(0,Pt.jsx)($H,{run:N,detail:i,active:y.start+x===o,columns:c,now:m,tick:h,expectedMs:Q},N.runId):(0,Pt.jsx)(eO,{run:N,active:y.start+x===o,columns:c},N.runId)),y.end<n.length?(0,Pt.jsxs)(rt,{dimColor:!0,children:[" \u2193 ",n.length-y.end," more"]}):null]})}u(PH,"RunList");function $H({run:n,detail:i,active:o,columns:c,now:d,tick:m,expectedMs:h}){let Q=i?.participants[0],y=n.startedAt===void 0?Number.NaN:Date.parse(n.startedAt),N=Number.isFinite(y)?P2(d-y):void 0,x=h===void 0?"":` of ~${P2(h)}`,G=Q?.thought===void 0?void 0:cd(Q.thought.text,{width:Math.max(16,c-6),maxLines:3});return(0,Pt.jsxs)(ht,{flexDirection:"column",children:[(0,Pt.jsxs)(ht,{width:c,children:[(0,Pt.jsxs)(rt,{...cA(o?be.accent:void 0),bold:o,children:[Ni(o)," "]}),(0,Pt.jsxs)(rt,{color:be.ok,children:[tp({liveness:"running",tick:m})," "]}),(0,Pt.jsx)(rt,{...cA(o?be.accent:void 0),bold:o,wrap:"truncate-end",children:Q?.personaId??Q?.label??"starting\u2026"}),(0,Pt.jsx)(ht,{flexGrow:1}),(0,Pt.jsx)(rt,{dimColor:!0,children:N===void 0?"":`${N}${x}`})]}),G===void 0?null:(0,Pt.jsx)(ht,{flexDirection:"column",marginLeft:4,children:G.lines.map((b,L)=>(0,Pt.jsxs)(rt,{dimColor:L>0,children:[L===0?`"${b}`:b,L===G.lines.length-1?'"':""]},L))}),Q===void 0?null:(0,Pt.jsx)(ht,{width:c,children:(0,Pt.jsxs)(rt,{dimColor:!0,children:[" ",tO(Q)]})})]})}u($H,"LiveRun");function tO(n){let i=[];return n.actions!==void 0&&i.push(`${n.actions} actions`),n.thoughts!==void 0&&i.push(`${n.thoughts} thoughts`),n.turns!==void 0&&i.push(`${n.turns} turns`),i.length===0?"working\u2026":i.join(" \xB7 ")}u(tO,"activityLine");function eO({run:n,active:i,columns:o}){let c=aO(n.completedAt??n.startedAt),d=n.participants===void 0?n.verdict??"no verdict":`${n.participants.reachedGoal}/${n.participants.total} reached the goal`,m=n.estimatedCostUsd===void 0||n.estimatedCostUsd===null?"":` \xB7 ~$${n.estimatedCostUsd.toFixed(2)}`,h=[c,d].filter(Boolean).join(" \xB7 ")+m;return(0,Pt.jsxs)(ht,{width:o,children:[(0,Pt.jsxs)(rt,{...cA(i?be.accent:void 0),bold:i,children:[Ni(i)," "]}),(0,Pt.jsxs)(rt,{...gd(n),children:[tp(n)," "]}),(0,Pt.jsx)(rt,{...cA(i?be.accent:void 0),bold:i,wrap:"truncate-end",children:h})]})}u(eO,"PastRun");function nO(n){let i=n?.caps.laneUsd,o=n?.caps.studyUsd;if(i===void 0&&o===void 0)return"";let c=[];return i!==void 0&&c.push(`$${i} lane`),o!==void 0&&c.push(`$${o} study`),` \xB7 caps ${c.join(" / ")}`}u(nO,"capsLine");function AO(n){let i=n.replace(/\s+/g," ").trim(),o=i.indexOf(". ");return o===-1?i:i.slice(0,o+1)}u(AO,"firstSentence");function aO(n){if(n===void 0)return"";let i=Date.parse(n);if(!Number.isFinite(i))return"";let o=new Date(i),c=u(d=>String(d).padStart(2,"0"),"pad");return`${c(o.getUTCMonth()+1)}-${c(o.getUTCDate())} ${c(o.getUTCHours())}:${c(o.getUTCMinutes())}`}u(aO,"shortDate");function P2(n){if(!Number.isFinite(n)||n<0)return"0:00";let i=Math.floor(n/1e3),o=Math.floor(i/60);return o<60?`${o}:${String(i%60).padStart(2,"0")}`:Ri(n)}u(P2,"clockOf");var wn=Tt(Qa(),1);function ep(n,i){return["queued","running"].includes(i?.automaticAnalysis?.state??"")?i?.observerPath===void 0?["cancel-analysis"]:["observer","cancel-analysis"]:n.liveness==="interrupted"?i?.observerPath===void 0?["reclaim"]:["reclaim","observer"]:n.liveness==="running"?["stop"]:i?.observerPath===void 0?["again"]:["observer","again"]}u(ep,"runActions");function lO(n){switch(n){case"observer":return"Open in Observer";case"again":return"Run again";case"stop":return"Stop this run";case"cancel-analysis":return"Cancel analysis";default:return"Reclaim \u2014 stop sandboxes, keep evidence"}}u(lO,"actionLabel");function tN({run:n,detail:i,columns:o,selected:c,tick:d,now:m,actionNote:h}){let Q=i?.participants[0],y=ep(n,i),N=n.liveness==="interrupted";return(0,wn.jsxs)(ht,{flexDirection:"column",children:[(0,wn.jsx)(ht,{children:(0,wn.jsxs)(rt,{...gd(n),bold:!0,children:[tp({...n,tick:d})," ",iO(n,Q)]})}),N?(0,wn.jsx)(oO,{run:n,detail:i,participant:Q,now:m,columns:o}):(0,wn.jsx)(uO,{run:n,participant:Q,columns:o}),i?.automaticAnalysis===void 0?null:(0,wn.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[(0,wn.jsxs)(rt,{children:["Analysis: ",i.automaticAnalysis.state]}),i.automaticAnalysis.reason===null?null:(0,wn.jsx)(rt,{dimColor:!0,wrap:"wrap",children:i.automaticAnalysis.reason})]}),y.length===0?null:(0,wn.jsx)(ht,{marginTop:1,flexDirection:"column",children:y.map((x,G)=>(0,wn.jsx)(ht,{children:(0,wn.jsxs)(rt,{...cA(G===c?be.accent:void 0),bold:G===c,children:[Ni(G===c)," ",jr(lO(x),Math.max(10,o-3))]})},x))}),h===void 0?null:(0,wn.jsx)(ht,{marginTop:1,children:(0,wn.jsx)(rt,{dimColor:!0,wrap:"truncate-end",children:h})})]})}u(tN,"RunScreen");function iO(n,i){if(n.liveness==="interrupted")return"interrupted \u2014 no outcome recorded";if(n.liveness==="running"){let d=i?.personaId??i?.label;return d===void 0?"starting\u2026":`${d} is working`}let o=n.participants;if(o===void 0)return n.verdict??"finished, no verdict recorded";let c=o.reportedFriction===void 0||o.reportedFriction===0?"":` \xB7 ${o.reportedFriction} reported friction`;return`${o.reachedGoal}/${o.total} reached the goal${c}`}u(iO,"headline");function uO({run:n,participant:i,columns:o}){let c=i?.thought===void 0?void 0:cd(i.thought.text,{width:Math.max(16,o),maxLines:3}),d=[n.durationMs===void 0?void 0:Ri(n.durationMs),i?.turns===void 0?void 0:`${i.turns} turns`,i?.thoughts===void 0?void 0:`${i.thoughts} thoughts`].filter(Boolean).join(" \xB7 ");return(0,wn.jsxs)(ht,{flexDirection:"column",children:[c===void 0?null:(0,wn.jsx)(ht,{marginTop:1,flexDirection:"column",children:c.lines.map((m,h)=>(0,wn.jsxs)(rt,{children:[h===0?`"${m}`:m,h===c.lines.length-1?'"':""]},h))}),(0,wn.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[d===""?null:(0,wn.jsx)(rt,{dimColor:!0,children:d}),(0,wn.jsx)(rt,{dimColor:!0,children:eN(n,i)})]})]})}u(uO,"FinishedFacts");function oO({run:n,detail:i,participant:o,now:c,columns:d}){let m=n.startedAt===void 0?Number.NaN:Date.parse(n.startedAt),h=n.updatedAt===void 0?Number.NaN:c-Date.parse(n.updatedAt),Q=[o?.thoughts===void 0?void 0:`${o.thoughts} thoughts`,o?.actions===void 0?void 0:`${o.actions} actions`].filter(Boolean).join(" \xB7 ");return(0,wn.jsxs)(ht,{marginTop:1,flexDirection:"column",width:d,children:[(0,wn.jsxs)(rt,{dimColor:!0,children:[Number.isFinite(m)?`started ${rO(m)}`:"start time not recorded",Number.isFinite(h)?` \xB7 quiet ${Ri(h)}`:"",Q===""?"":` \xB7 ${Q} captured`]}),(0,wn.jsxs)(ht,{children:[(0,wn.jsx)(rt,{dimColor:!0,children:n.estimatedCostUsd===void 0&&o?.estimatedCostUsd===void 0?"cost unknown \u2014 it ended before pricing itself":eN(n,o)}),(0,wn.jsx)(rt,{color:be.warn,children:" sandboxes may still be running"})]})]})}u(oO,"InterruptedFacts");function eN(n,i){let o=n.estimatedCostUsd===void 0?i?.estimatedCostUsd:n.estimatedCostUsd;return o===void 0?"cost not recorded":o===null?"cost declared absent":`~$${o.toFixed(2)} estimated`}u(eN,"costLine");function rO(n){let i=new Date(n),o=u(c=>String(c).padStart(2,"0"),"pad");return`${o(i.getUTCHours())}:${o(i.getUTCMinutes())}`}u(rO,"clockTime");var nN=Tt(Ue(),1);var Ke=Tt(Qa(),1);function AN({rows:n,selected:i,columns:o,viewport:c,unattributed:d,tick:m,liveParticipants:h,now:Q,initialized:y,peerSelected:N,liveTotal:x,initArmed:G,actionNote:b}){if(n.length===0)return y?(0,Ke.jsxs)(ht,{flexDirection:"column",children:[(0,Ke.jsx)(rt,{children:"no labs here yet"}),(0,Ke.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[(0,Ke.jsx)(rt,{dimColor:!0,children:"a lab is a study: who to send, to what, and what counts as done."}),(0,Ke.jsx)(rt,{dimColor:!0,children:"write one in humanish/labs/, or `humanish init` for three to start from."})]})]}):(0,Ke.jsxs)(ht,{flexDirection:"column",children:[(0,Ke.jsx)(rt,{children:"this directory is not a humanish project"}),(0,Ke.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[(0,Ke.jsx)(rt,{dimColor:!0,children:"humanish studies live in a project: a humanish/ directory of labs and"}),(0,Ke.jsx)(rt,{dimColor:!0,children:"personas beside the app they study."})]}),(0,Ke.jsxs)(ht,{marginTop:1,children:[(0,Ke.jsxs)(rt,{...cA(be.accent),bold:!0,children:[Ni(!0)," Set up humanish here"]}),(0,Ke.jsx)(ht,{flexGrow:1}),(0,Ke.jsx)(rt,{dimColor:!0,children:G?"\u23CE again to confirm \xB7 esc cancel":"writes humanish/ and updates package.json"})]}),b===void 0?null:(0,Ke.jsx)(ht,{marginTop:1,children:(0,Ke.jsx)(rt,{dimColor:!0,children:b})})]});let L=fd({total:n.length,selected:i,viewport:c});return(0,Ke.jsxs)(ht,{flexDirection:"column",children:[L.start>0?(0,Ke.jsxs)(rt,{dimColor:!0,children:[" \u2191 ",L.start," more"]}):null,n.slice(L.start,L.end).map((j,q)=>{let F=L.start+q,gt=F>0?n[F-1]:void 0,xt=j.runs===0&&gt!==void 0&&gt.runs>0;return(0,Ke.jsxs)(nN.default.Fragment,{children:[xt?(0,Ke.jsx)(ht,{marginTop:1,children:(0,Ke.jsxs)(rt,{dimColor:!0,children:[" ","not yet run"]})}):null,(0,Ke.jsx)(cO,{row:j,columns:o,active:F===i,tick:m,liveParticipants:h,now:Q})]},j.key)}),L.end<n.length?(0,Ke.jsxs)(rt,{dimColor:!0,children:[" \u2193 ",n.length-L.end," more"]}):null,(0,Ke.jsxs)(ht,{marginTop:1,children:[(0,Ke.jsxs)(rt,{...cA(N?be.accent:void 0),bold:N,dimColor:!N,children:[Ni(N)," All runs"]}),x>0?(0,Ke.jsxs)(rt,{color:be.ok,children:[" ",x," working"]}):null]}),d>0?(0,Ke.jsx)(ht,{marginTop:1,children:(0,Ke.jsxs)(rt,{dimColor:!0,children:[d," ",d===1?"run":"runs"," with no lab"]})}):null,(0,Ke.jsxs)(ht,{marginTop:1,width:o,children:[(0,Ke.jsx)(rt,{...cA(be.accent),children:"\u25B8"}),(0,Ke.jsx)(rt,{dimColor:!0,wrap:"truncate-end",children:` ${sO(n[i],N)}`})]})]})}u(AN,"LabsScreen");function sO(n,i){if(i)return"every run in this project, newest first \u2014 across every lab";if(n===void 0)return"";let o=n.description?.split(/(?<=[.!?])\s/)[0]?.trim();return o!==void 0&&o.length>0?o:"no description in the manifest"}u(sO,"describe");function cO({row:n,columns:i,active:o,tick:c,liveParticipants:d,now:m}){let h=n.liveRuns[0],Q=h===void 0?mh(n):fO(n,h,d.get(h.runId),m),y=Math.max(10,Math.floor(i/2)-2),N=Q.length<=y?Q:gO(n),x=Math.max(8,i-N.length-6);return(0,Ke.jsxs)(ht,{width:i,children:[(0,Ke.jsxs)(rt,{...cA(o?be.accent:void 0),bold:o,children:[Ni(o)," "]}),(0,Ke.jsxs)(rt,{...gd({liveness:h===void 0?"finished":"running"}),children:[h===void 0?" ":$m(c)," "]}),(0,Ke.jsx)(rt,{...cA(o?be.accent:void 0),bold:o,wrap:"truncate-end",children:jr(n.label,x)}),(0,Ke.jsx)(ht,{flexGrow:1}),(0,Ke.jsx)(rt,{...cA(h===void 0?void 0:be.ok),dimColor:h===void 0,children:N})]})}u(cO,"LabRowView");function fO(n,i,o,c){let d=i.startedAt===void 0?Number.NaN:Date.parse(i.startedAt),m=Number.isFinite(d)?dO(c-d):void 0,h=o??"starting\u2026",Q=n.live>1?` +${n.live-1}`:"";return m===void 0?`${h}${Q}`:`${h} \xB7 ${m}${Q}`}u(fO,"liveStatus");function gO(n){return n.live>0?`${n.live} running`:n.runs===0?n.declared?"never run":"no runs":`${n.runs} runs`}u(gO,"fallbackStatus");function dO(n){if(!Number.isFinite(n)||n<0)return"0:00";let i=Math.floor(n/1e3),o=Math.floor(i/60),c=i%60;return o<60?`${o}:${String(c).padStart(2,"0")}`:Ri(n)}u(dO,"clockOf");var Bh=Tt(Ue(),1);function aN(){let{stdout:n}=sh(),i=u(()=>({columns:Math.max(20,n.columns||80),rows:Math.max(6,n.rows||24)}),"read"),[o,c]=(0,Bh.useState)(i);return(0,Bh.useEffect)(()=>{let d=u(()=>{c(h=>{let Q=i();return Q.columns===h.columns&&Q.rows===h.rows?h:Q})},"update");n.on("resize",d);let m=setTimeout(d,0);return()=>{n.off("resize",d),clearTimeout(m)}},[n]),o}u(aN,"useTerminalSize");var bi=Tt(Qa(),1),EO=6,L0=2e3,mO=5e3,pO=100,z0=400,CO=120;function uN({options:n,onReady:i,now:o,tick:c}){let{exit:d}=U0(),m=aN(),[h,Q]=(0,Xe.useReducer)(q2,void 0,K2),[y,N]=(0,Xe.useState)(void 0),[x,G]=(0,Xe.useState)(void 0),[b,L]=(0,Xe.useState)(void 0),[j,q]=(0,Xe.useState)(void 0),[F,gt]=(0,Xe.useState)(void 0),[xt,kt]=(0,Xe.useState)(void 0),[Mt,pe]=(0,Xe.useState)(void 0),[Ce,Yt]=(0,Xe.useState)(void 0),[wt,Ct]=(0,Xe.useState)(void 0),[Gt,se]=(0,Xe.useState)(!1),[vt,rn]=(0,Xe.useState)(void 0),[He,ft]=(0,Xe.useState)(0),Ut=c??He,[Jt,Rt]=(0,Xe.useState)(void 0),[ie,sn]=(0,Xe.useState)(new Map),tt=(0,Xe.useMemo)(()=>n.capabilities.readProjectState(n.cwd),[n]),Ot=o??Date.now(),ue=(0,Xe.useRef)(void 0),le=(0,Xe.useRef)({name:"labs"});(0,Xe.useEffect)(()=>{let it=!1,Lt=u(async()=>{try{let[Vt,ye]=await Promise.all([n.capabilities.readRunIndex(n.cwd),n.capabilities.listLabs(n.cwd)]);if(it)return;G(void 0),N(lN(Vt,ye.labs))}catch(Vt){if(it)return;G(Vt instanceof Error?Vt.message:String(Vt))}},"read");Lt();let de=setInterval(()=>{Lt()},L0);return de.unref?.(),()=>{it=!0,clearInterval(de)}},[n]),(0,Xe.useEffect)(()=>{(y!==void 0||x!==void 0)&&i?.()},[y,x,i]);let Kt=Pm(h),fn=F2(h),ce=iN(Kt,y,Mt);(0,Xe.useEffect)(()=>{le.current=Kt;let it=yO(Kt,y,fn);it!==void 0&&(ue.current=it)},[Kt,y,fn]),(0,Xe.useEffect)(()=>{if(y===void 0)return;let it=ue.current;if(it===void 0)return;let Lt=SO(Kt,y,it);Lt>=0&&Lt!==fn&&Q({type:"select",index:Lt,total:iN(Kt,y,Mt)})},[y,Kt]);let Oe=(0,Xe.useCallback)(async(it,Lt)=>{if(Lt==="live"&&b!=="live"){L("live"),kt(Date.now());return}if(Lt==="live"&&xt!==void 0&&Date.now()-xt<z0)return;L(void 0),kt(void 0),q(void 0),gt({labKey:it.key,text:`starting ${it.name}\u2026`});let de=await n.capabilities.startRun({cwd:n.cwd,lab:it.name,mode:Lt});if(!de.ok){gt(void 0),q({labKey:it.key,text:de.error.message});return}let Vt=Date.parse(de.run.launchedAt),ye=u(gA=>{if(gA.pid!==de.run.pid)return!1;let nA=gA.startedAt===void 0?Number.NaN:Date.parse(gA.startedAt);return!Number.isFinite(nA)||!Number.isFinite(Vt)?!1:nA>=Vt-1e3},"isOurs"),Ve=Date.now()+mO;for(;;){let gA=await n.capabilities.readRunIndex(n.cwd),nA=gA.runs.find(ye);if(nA!==void 0){let WA=await n.capabilities.listLabs(n.cwd);N(lN(gA,WA.labs)),gt(void 0),le.current.name==="lab"&&le.current.labKey===it.key&&Q({type:"enter",screen:{name:"run",labId:it.labId,runId:nA.runId}});return}if(Date.now()>=Ve)break;await new Promise(WA=>setTimeout(WA,pO))}let eA=await n.capabilities.readLaunchLog(de.run.logPath);gt(void 0),q({labKey:it.key,text:eA===""?`${it.name} started (pid ${de.run.pid}) but has not reported in. Check ${de.run.logPath}.`:`${it.name} did not report in. Its log ends:
286
+ `)d.name="enter";else if(n===" ")d.name="tab";else if(n==="\b"||n==="\x1B\b")d.name="backspace",d.meta=n.charAt(0)==="\x1B";else if(n==="\x7F"||n==="\x1B\x7F")d.name="backspace",d.meta=n.charAt(0)==="\x1B";else if(n==="\x1B"||n==="\x1B\x1B")d.name="escape",d.meta=n.length===2;else if(n===" "||n==="\x1B ")d.name="space",d.meta=n.length===2;else if(n.length===1&&n<="")d.name=String.fromCharCode(n.charCodeAt(0)+97-1),d.ctrl=!0;else if(n.length===1&&n>="0"&&n<="9")d.name="number";else if(n.length===1&&n>="a"&&n<="z")d.name=n;else if(n.length===1&&n>="A"&&n<="Z")d.name=n.toLowerCase(),d.shift=!0;else if(i=vH.exec(n))d.name=i[1].toLowerCase(),d.meta=!0,d.shift=/^[A-Z]$/.test(i[1]);else if(i=DH.exec(n)){let m=[...n];m[0]==="\x1B"&&m[1]==="\x1B"&&(d.meta=!0);let h=[i[1],i[2],i[4],i[6]].filter(Boolean).join(""),Q=(i[3]||i[5]||1)-1;d.ctrl=!!(Q&4),d.meta=d.meta||!!(Q&10),d.shift=!!(Q&1),d.code=h,d.name=Q2[h]??"",d.shift=RH(h)||d.shift,d.ctrl=NH(h)||d.ctrl}return d},"parseKeypress"),N2=UH;var b2=Tt(Ue(),1);var _0=u(()=>(0,b2.useContext)(eh),"useStdinContext");var HH=u((n,i={})=>{let{setRawMode:o,internal_exitOnCtrlC:c,internal_eventEmitter:d}=_0();(0,Xm.useEffect)(()=>{if(i.isActive!==!1)return o(!0),()=>{o(!1)}},[i.isActive,o]);let m=(0,Xm.useEffectEvent)(h=>{let Q=N2(h),y={upArrow:Q.name==="up",downArrow:Q.name==="down",leftArrow:Q.name==="left",rightArrow:Q.name==="right",pageDown:Q.name==="pagedown",pageUp:Q.name==="pageup",home:Q.name==="home",end:Q.name==="end",return:Q.name==="return",escape:Q.name==="escape",ctrl:Q.ctrl,shift:Q.shift,tab:Q.name==="tab",backspace:Q.name==="backspace",delete:Q.name==="delete",meta:Q.meta,super:Q.super??!1,hyper:Q.hyper??!1,capsLock:Q.capsLock??!1,numLock:Q.numLock??!1,eventType:Q.eventType},N;Q.isKittyProtocol?Q.isPrintable?N=Q.text??Q.name:Q.ctrl&&Q.name.length===1?N=Q.name:N="":Q.ctrl?N=Q.name??"":N=Q.sequence,!Q.isKittyProtocol&&y2.includes(Q.name)&&(N=""),N.startsWith("\x1B")&&(N=N.slice(1)),N.length===1&&/[A-Z]/.test(N)&&(y.shift=!0),!(N==="c"&&y.ctrl&&c)&&wa.discreteUpdates(()=>{n(N,y)})});(0,Xm.useEffect)(()=>{if(i.isActive!==!1)return d.on("input",m),()=>{d.removeListener("input",m)}},[i.isActive,d])},"useInput"),M0=HH;var T2=Tt(Ue(),1);var x2=Tt(Ue(),1);var OH=u(()=>(0,x2.useContext)(th),"useApp"),U0=OH;var _2=Tt(Ue(),1);var wH=u(()=>(0,_2.useContext)(nh),"useStdout"),sh=wH;var GH=Tt(Ue(),1);var H0=Tt(Ue(),1);var zH=Tt(Ue(),1);var YH=Tt(Ue(),1);var ch=Tt(Ue(),1);var Zm=Tt(Ue(),1);var M2=Tt(Ue(),1);var fh=Tt(Ue(),1);var JH=/utf-?8/i;function Rc(n=process.env){if(process.platform==="win32")return!0;let i=n.LC_ALL??n.LC_CTYPE??n.LANG;return i===void 0||i.trim().length===0?!1:JH.test(i)}u(Rc,"terminalRendersUnicode");var KH=new Map([["\u2014","--"],["\u2013","-"],["\u2019","'"],["\u2018","'"],["\u201C",'"'],["\u201D",'"'],["\u2026","..."],["\xB7","-"],["\u276F",">"],["\u2039","<"],["\u25B8",">"],["\u2713","+"],["\u2691","!"],["\u23CE","Enter"],["\u2191","^"],["\u2193","v"],["\u2190","<-"],["\u2192","->"],["\xD7","x"],["\u2248","~"],["\u2717","x"]]);function U2(n,i=process.env){if(Rc(i))return n;let o="";for(let c of n){if(c.codePointAt(0)<128){o+=c;continue}o+=KH.get(c)??"?"}return o}u(U2,"forTerminal");var Xe=Tt(Ue(),1);var be={accent:"#93a2ff",ok:"#7dc9a0",warn:"#d9a441",bad:"#e0796b"};var Di=Tt(Qa(),1);function G2({columns:n}){let i=[["\u2191 \u2193 \xB7 k j","move the cursor"],["\u23CE \xB7 \u2192","open what the cursor is on, or run the action it names"],["esc \xB7 \u2190","back \u2014 and it cancels an armed confirmation first"],["g \xB7 G","jump to the top, jump to the bottom"],["?","these keys"],["q","quit \u2014 a run you started keeps going without this window"]];return(0,Di.jsxs)(ht,{flexDirection:"column",width:n,children:[(0,Di.jsx)(rt,{color:be.accent,bold:!0,children:"Keys"}),(0,Di.jsx)(ht,{marginTop:1,flexDirection:"column",children:i.map(([o,c])=>(0,Di.jsxs)(ht,{children:[(0,Di.jsx)(ht,{width:16,children:(0,Di.jsx)(rt,{bold:!0,children:o})}),(0,Di.jsx)(rt,{dimColor:!0,children:c})]},o))}),(0,Di.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[(0,Di.jsx)(rt,{dimColor:!0,children:"Starting a run asks twice when it spends money: the first \u23CE arms and"}),(0,Di.jsx)(rt,{dimColor:!0,children:"restates the cost, the second commits. A dry run never asks."})]})]})}u(G2,"HelpScreen");function jH(n){let i=new Map,o=[];for(let d of n){let m=d.lab?.id;if(m===void 0){o.push(d);continue}let h=i.get(m);h===void 0?i.set(m,[d]):h.push(d)}let c=[...i.entries()].map(([d,m])=>{let h=m.filter(Q=>Q.liveness==="running");return{labId:d,runs:m.length,live:h.length,...m[0]===void 0?{}:{latest:m[0]},liveRuns:h}});return c.sort((d,m)=>d.live!==m.live?m.live-d.live:Eh(m.latest)-Eh(d.latest)),{labs:c,unattributed:o}}u(jH,"groupRunsByLab");function Eh(n){if(n===void 0)return 0;for(let i of[n.completedAt,n.updatedAt,n.startedAt]){if(i===void 0)continue;let o=Date.parse(i);if(Number.isFinite(o))return o}return 0}u(Eh,"recencyOf");function L2(n,i){let c=(i===void 0?n:n.filter(Q=>Q.mode===i)).filter(Q=>Q.liveness==="finished"),d=c.map(Q=>Q.durationMs).filter(Q=>typeof Q=="number"&&Number.isFinite(Q)&&Q>=0).sort((Q,y)=>Q-y),m=c.map(Q=>Q.estimatedCostUsd).filter(Q=>typeof Q=="number"&&Number.isFinite(Q)).sort((Q,y)=>Q-y),h=c.filter(Q=>Q.estimatedCostUsd===null||Q.estimatedCostUsd===void 0).length;return{sample:c.length,...d.length===0?{}:{medianDurationMs:z2(d),durationRangeMs:{min:d[0],max:d[d.length-1]}},...m.length===0?{}:{medianCostUsd:z2(m)},costUnknown:h}}u(L2,"expectationFor");function z2(n){let i=Math.floor(n.length/2);return n.length%2===1?n[i]:(n[i-1]+n[i])/2}u(z2,"median");function Wm(n){if(n.sample===0)return"no runs yet";let i=[];if(n.durationRangeMs!==void 0){let{min:m,max:h}=n.durationRangeMs;i.push(m===h?Ri(m):`${Ri(m)}\u2013${Ri(h)}`)}n.medianCostUsd!==void 0&&i.push(`~$${n.medianCostUsd.toFixed(2)} median`);let o=`${n.sample} run${n.sample===1?"":"s"}`,c=n.sample>0&&n.costUnknown===n.sample,d=n.costUnknown===0?"":c?", none priced":`, ${n.costUnknown} unpriced`;return i.length===0?c?`${o}, nothing recorded`:`${o}${d}, nothing timed`:`${i.join(" \xB7 ")} \xB7 ${o}${d}`}u(Wm,"expectationLine");function mh(n){return n.runs===0?n.declared?"never run":"no runs":n.liveExpectation.sample>0?Wm(n.liveExpectation):`${n.runs} ${n.runs===1?"run":"runs"}, none live`}u(mh,"labSummaryLine");function Ri(n){let i=Math.max(0,Math.round(n/1e3));if(i<60)return`${i}s`;let o=Math.floor(i/60);if(o<60)return i%60===0?`${o}m`:`${o}m ${i%60}s`;let c=Math.floor(o/60);return o%60===0?`${c}h`:`${c}h ${o%60}m`}u(Ri,"formatDuration");function cd(n,i){let o=Math.max(8,Math.floor(i.width)),c=Math.max(1,Math.floor(i.maxLines)),d=n.replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\s*\n+\s*/g," ").replace(/\s{2,}/g," ").trim();if(d==="")return{lines:[],truncated:!1};let m=d.split(" "),h=[],Q="",y=0;for(;y<m.length;y+=1){let x=m[y],G=Q===""?x:`${Q} ${x}`;if(G.length<=o){Q=G;continue}if(Q!==""&&h.push(Q),Q=x.length<=o?x:`${x.slice(0,o-1)}\u2026`,x.length>o&&(h.push(Q),Q=""),h.length===c)break}h.length<c&&Q!==""&&(h.push(Q),y=m.length);let N=y<m.length;if(N&&h.length>0){let x=h[h.length-1];h[h.length-1]=x.length+1<=o?`${x}\u2026`:`${x.slice(0,o-1)}\u2026`}return{lines:h,truncated:N}}u(cd,"normalizeThought");function fd(n){let i=Math.max(0,Math.floor(n.total)),o=Math.max(1,Math.floor(n.viewport));if(i<=o)return{start:0,end:i};let c=Math.min(Math.max(0,Math.floor(n.selected)),i-1),d=Math.min(Math.max(0,Math.floor(n.margin??1)),Math.floor((o-1)/2)),m=Math.min(Math.max(0,c-d),i-o);return c>=m+o-d&&(m=Math.min(c-o+1+d,i-o)),m=Math.max(0,Math.min(m,i-o)),{start:m,end:m+o}}u(fd,"listWindow");function Y2(n){return(n.split("/").pop()??n).replace(/\.(ya?ml)$/i,"")}u(Y2,"labNameFromPath");function J2(n,i){let{labs:o,unattributed:c}=jH(i),d=new Map(o.map(G=>[G.labId,G])),m=new Map;for(let G of i){let b=G.lab?.id;if(b===void 0)continue;let L=m.get(b);L===void 0?m.set(b,[G]):L.push(G)}let h=new Map;for(let G of n)h.set(G.id,(h.get(G.id)??0)+1);let Q=u((G,b,L)=>{let j=d.get(G),q=b?.path;return{key:q??`id:${G}`,labId:G,name:q===void 0?G:Y2(q),...b?.title===void 0?{}:{title:b.title},...q===void 0?{}:{path:q},...b?.origin===void 0?{}:{origin:b.origin},declared:L,label:b?.title??(q===void 0?G:Y2(q)),...b?.description===void 0?{}:{description:b.description},sharesIdWith:Math.max(0,(h.get(G)??0)-1),runs:j?.runs??0,live:j?.live??0,...j?.latest===void 0?{}:{latest:j.latest},liveRuns:j?.liveRuns??[],expectation:L2(m.get(G)??[]),liveExpectation:L2(m.get(G)??[],"live")}},"build"),y=new Set(n.map(G=>G.id)),N=[...n.map(G=>Q(G.id,G,!0)),...o.filter(G=>!y.has(G.labId)).map(G=>Q(G.labId,void 0,!1))];kH(N);let x=u(G=>G.label,"label");return N.sort((G,b)=>{if(G.live!==b.live)return b.live-G.live;let L=u(q=>q.runs>0?0:q.declared?1:2,"rank");if(L(G)!==L(b))return L(G)-L(b);if(G.runs>0&&b.runs>0){let q=Eh(b.latest)-Eh(G.latest);if(q!==0)return q}let j=x(G).localeCompare(x(b));return j!==0?j:G.key.localeCompare(b.key)}),{rows:N,unattributed:c}}u(J2,"labRows");function kH(n){let i=u(d=>{let m=new Map;for(let h of d)m.set(h,(m.get(h)??0)+1);return m},"count"),o=i(n.map(d=>d.title??d.name)),c=i(n.map(d=>d.name));for(let d of n){let m=d.title??d.name;if((o.get(m)??0)===1){d.label=m;continue}d.label=(c.get(d.name)??0)===1?d.name:d.path??d.name}}u(kH,"assignLabels");function w0(n){switch(n.name){case"labs":return"labs";case"all-runs":return"all-runs";case"lab":return`lab:${n.labKey}`;default:return`run:${n.runId}`}}u(w0,"screenKey");function K2(){return{stack:[{name:"labs"}],selection:{},quit:!1}}u(K2,"initialNav");function Pm(n){return n.stack[n.stack.length-1]??{name:"labs"}}u(Pm,"currentScreen");function F2(n){return n.selection[w0(Pm(n))]??0}u(F2,"selectedIndex");function q2(n,i){switch(i.type){case"enter":return{...n,stack:[...n.stack,i.screen]};case"back":return n.stack.length<=1?{...n,quit:!0}:{...n,stack:n.stack.slice(0,-1)};case"move":{if(i.total<=0)return n;let o=w0(Pm(n)),c=n.selection[o]??0,d=Math.min(Math.max(0,c+i.delta),i.total-1);return d===c?n:{...n,selection:{...n.selection,[o]:d}}}case"select":{if(i.total<=0)return n;let o=w0(Pm(n)),c=Math.min(Math.max(0,i.index),i.total-1);return{...n,selection:{...n.selection,[o]:c}}}default:return{...n,quit:!0}}}u(q2,"navigate");function cA(n){return n===void 0?{}:{color:n}}u(cA,"color");var gu=Tt(Qa(),1),VH=96;function ph(n){return Math.max(20,Math.min(VH,n))}u(ph,"contentWidth");function j2({columns:n,context:i,breadcrumb:o,hints:c,children:d}){let m=ph(n);return(0,gu.jsxs)(ht,{flexDirection:"column",width:m,children:[(0,gu.jsxs)(ht,{width:m,children:[(0,gu.jsx)(rt,{bold:!0,children:"human(ish)"}),(0,gu.jsx)(ht,{flexGrow:1}),i===void 0?null:(0,gu.jsx)(rt,{dimColor:!0,wrap:"truncate-start",children:i})]}),o===void 0?null:(0,gu.jsx)(rt,{dimColor:!0,wrap:"truncate-start",children:o}),(0,gu.jsx)(ht,{marginTop:1,flexDirection:"column",children:d}),(0,gu.jsx)(ht,{marginTop:1,children:(0,gu.jsx)(rt,{dimColor:!0,children:c})})]})}u(j2,"Frame");var G0=Rc()?["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]:["|","/","-","\\","|","/","-","\\","|","/"];function $m(n){return G0[Math.abs(Math.floor(n))%G0.length]??G0[0]}u($m,"spinnerFrame");function Ni(n){return n?Rc()?"\u276F":">":" "}u(Ni,"gutter");function tp(n){if(n.liveness==="running")return $m(n.tick??0);let i=Rc();return n.liveness==="interrupted"||n.verdict==="fail"?i?"\u2691":"!":n.verdict===void 0?i?"\xB7":"-":i?"\u2713":"+"}u(tp,"verdictGlyph");function XH(n){if(n.liveness==="running")return be.ok;if(n.liveness==="interrupted")return be.warn;if(n.verdict==="fail")return be.bad}u(XH,"verdictColor");var gd=u(n=>cA(XH(n)),"glyphColor");function jr(n,i){let o=Math.max(4,Math.floor(i));return n.length<=o?n:`${n.slice(0,o-1)}\u2026`}u(jr,"fitLabelToWidth");var Rn=Tt(Qa(),1);function X2({runs:n,details:i,labels:o,expected:c,selected:d,columns:m,viewport:h,tick:Q,now:y}){if(n.length===0)return(0,Rn.jsxs)(ht,{flexDirection:"column",children:[(0,Rn.jsx)(rt,{children:"nobody is working right now"}),(0,Rn.jsx)(rt,{dimColor:!0,children:"start a run from any lab and it appears here"})]});let N=fd({total:n.length,selected:d,viewport:Math.max(2,h-6)}),x=n[Math.min(Math.max(0,d),n.length-1)],G=x===void 0?void 0:i.get(x.runId),b=G?.participants[0],L=b?.thought===void 0?void 0:cd(b.thought.text,{width:Math.max(16,m-2),maxLines:2});return(0,Rn.jsxs)(ht,{flexDirection:"column",children:[n.slice(N.start,N.end).map((j,q)=>(0,Rn.jsx)(ZH,{run:j,who:k2(i.get(j.runId))??"starting\u2026",lab:o.get(j.runId)??j.lab?.id??"",expectedMs:c.get(j.lab?.id??""),active:N.start+q===d,columns:m,tick:Q,now:y},j.runId)),L===void 0?null:(0,Rn.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[L.lines.map((j,q)=>(0,Rn.jsxs)(ht,{width:m,children:[(0,Rn.jsx)(ht,{width:2,flexShrink:0,children:(0,Rn.jsx)(rt,{color:be.accent,children:"\u258C"})}),(0,Rn.jsxs)(rt,{dimColor:!0,wrap:"truncate-end",children:[q===0?`"${j}`:j,q===L.lines.length-1?'"':""]})]},q)),(0,Rn.jsxs)(ht,{width:m,children:[(0,Rn.jsx)(ht,{width:2,flexShrink:0,children:(0,Rn.jsx)(rt,{children:" "})}),(0,Rn.jsx)(rt,{dimColor:!0,wrap:"truncate-end",children:jr([k2(G),o.get(x?.runId??"")].filter(Boolean).join(" \xB7 "),Math.max(10,m-2))})]})]}),(0,Rn.jsx)(ht,{marginTop:1,children:(0,Rn.jsx)(rt,{dimColor:!0,children:WH(n,i)})})]})}u(X2,"AllRunsScreen");function k2(n){let i=n?.participants[0];return i?.personaId??i?.label}u(k2,"personaOf");function ZH({run:n,who:i,lab:o,expectedMs:c,active:d,columns:m,tick:h,now:Q}){let y=n.startedAt===void 0?Number.NaN:Date.parse(n.startedAt),N=Number.isFinite(y)?V2(Q-y):"",x=c===void 0?N:`${N} / ~${V2(c)}`,G=Math.max(10,Math.floor((m-x.length-6)*.5)),b=Math.max(8,m-x.length-G-6);return(0,Rn.jsxs)(ht,{width:m,children:[(0,Rn.jsxs)(rt,{...cA(d?be.accent:void 0),bold:d,children:[Ni(d)," "]}),(0,Rn.jsxs)(rt,{color:be.ok,children:[$m(h)," "]}),(0,Rn.jsx)(ht,{width:G,children:(0,Rn.jsx)(rt,{...cA(d?be.accent:void 0),bold:d,wrap:"truncate-end",children:jr(i,G)})}),(0,Rn.jsx)(ht,{width:b,children:(0,Rn.jsx)(rt,{dimColor:!0,wrap:"truncate-end",children:jr(o,b)})}),(0,Rn.jsx)(ht,{flexGrow:1}),(0,Rn.jsx)(rt,{dimColor:!0,children:x})]})}u(ZH,"RunRow");function WH(n,i){let o=0,c=0;for(let h of n){let Q=h.estimatedCostUsd??i.get(h.runId)?.participants[0]?.estimatedCostUsd;typeof Q=="number"&&(o+=Q,c+=1)}if(c===0)return"no spend recorded yet \u2014 a live run prices itself as it goes";let d=n.length-c,m=d===0?"":` \xB7 ${d} not priced yet`;return`spend ~$${o.toFixed(2)} so far across ${c} of ${n.length}${m}`}u(WH,"spendLine");function V2(n){if(!Number.isFinite(n)||n<0)return"0:00";let i=Math.floor(n/1e3),o=Math.floor(i/60);return o<60?`${o}:${String(i%60).padStart(2,"0")}`:Ri(n)}u(V2,"clockOf");var Pt=Tt(Qa(),1);function Ch(n,i){return[...i?[{kind:"start",mode:"dry-run"},{kind:"start",mode:"live"}]:[],...n.map(c=>({kind:"run",run:c}))]}u(Ch,"labItems");function $2(n){let{row:i,summary:o,runs:c,selected:d,columns:m,viewport:h,now:Q,tick:y,canStart:N}=n,x=Ch(c,N);return(0,Pt.jsxs)(ht,{flexDirection:"column",children:[o?.description===void 0?null:(0,Pt.jsx)(rt,{wrap:"truncate-end",children:AO(o.description)}),o?.subject===void 0?null:(0,Pt.jsx)(rt,{dimColor:!0,wrap:"truncate-end",children:[o.subject,o.participants,o.model,o.reasoningEffort===void 0?void 0:`${o.reasoningEffort} effort`].filter(Boolean).join(" \xB7 ")}),(0,Pt.jsxs)(ht,{width:m,children:[(0,Pt.jsxs)(rt,{dimColor:!0,wrap:"truncate-end",children:[mh(i),nO(o)]}),(0,Pt.jsx)(ht,{flexGrow:1}),o?.keysReady===void 0?null:(0,Pt.jsx)(rt,{...cA(o.keysReady?be.ok:be.warn),children:o.keysReady?"keys \u2713":"keys \u2717"})]}),o?.analysis===void 0?null:(0,Pt.jsxs)(rt,{wrap:"wrap",children:["After live runs: analysis \xB7 ",o.analysis.model," \xB7 separate $",o.analysis.maxCostUsd," admission estimate limit \xB7 not a billing cap"]}),o?.keysReady===!1?(0,Pt.jsxs)(ht,{flexDirection:"column",width:m,children:[(0,Pt.jsxs)(rt,{...cA(be.warn),children:[o.missingKeys?.join(", ")," not found"]}),(0,Pt.jsxs)(rt,{dimColor:!0,children:[" ","humanish keys set openai"," ","\u2014 stores them for every project"]}),(0,Pt.jsxs)(rt,{dimColor:!0,children:[" ","humanish tui --env-file .env"," ","\u2014 or just this session"]})]}):null,n.launchNote===void 0?null:(0,Pt.jsx)(ht,{marginTop:1,children:(0,Pt.jsx)(rt,{dimColor:!0,children:n.launchNote})}),n.launchError===void 0?null:(0,Pt.jsx)(ht,{marginTop:1,children:(0,Pt.jsx)(rt,{color:be.bad,children:n.launchError})}),N?(0,Pt.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[(0,Pt.jsx)(W2,{...n,mode:"dry-run",active:Z2(x,d)==="dry-run"}),(0,Pt.jsx)(W2,{...n,mode:"live",active:Z2(x,d)==="live"}),n.confirming==="live"?(0,Pt.jsx)(ht,{marginTop:1,children:(0,Pt.jsxs)(rt,{color:be.warn,children:[" ","start a live run? ",Wm(n.row.liveExpectation),o?.analysis?` + analysis ($${o.analysis.maxCostUsd} admission estimate limit, separate from participant spend)`:""," \xB7 \u23CE confirm \xB7 esc cancel"]})}):null]}):null,i.declared?null:(0,Pt.jsx)(ht,{marginTop:1,children:(0,Pt.jsx)(rt,{color:be.warn,children:"no manifest here \u2014 renamed, deleted, or run from elsewhere"})}),i.sharesIdWith>0?(0,Pt.jsxs)(rt,{color:be.warn,children:[i.sharesIdWith+1,' manifests declare "',i.labId,'" \u2014 these runs are shared between them']}):null,(0,Pt.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[(0,Pt.jsx)(rt,{dimColor:!0,children:"Runs"}),n.liveDetail?.automaticAnalysis===void 0?null:(0,Pt.jsxs)(rt,{children:["Latest analysis: ",n.liveDetail.automaticAnalysis.state," \xB7 open run for details"]}),c.length===0?(0,Pt.jsx)(rt,{dimColor:!0,children:" none yet"}):(0,Pt.jsx)(PH,{runs:c,liveDetail:n.liveDetail,selected:d-Ch([],N).length,columns:m,viewport:Math.max(2,h-6),now:Q,tick:y,expectedMs:i.liveExpectation.medianDurationMs})]})]})}u($2,"LabScreen");function Z2(n,i){let o=n[i];return o?.kind==="start"?o.mode:void 0}u(Z2,"activeStart");function W2({mode:n,confirming:i,active:o,columns:c,row:d,summary:m}){let h=n==="live",Q=h&&m?.keysReady===!1,y=h?be.warn:be.accent;return(0,Pt.jsxs)(ht,{width:c,children:[(0,Pt.jsxs)(rt,{...cA(o?y:void 0),bold:o,dimColor:Q&&!o,children:[Ni(o)," ",h?"Start a LIVE run":"Start a dry run"]}),(0,Pt.jsx)(ht,{flexGrow:1}),(0,Pt.jsx)(rt,{dimColor:!Q,...cA(Q?be.warn:void 0),children:h?Q?`${Wm(d.liveExpectation)} \xB7 needs keys`:Wm(d.liveExpectation):"free \xB7 no keys, no spend"})]})}u(W2,"StartRow");function PH({runs:n,liveDetail:i,selected:o,columns:c,viewport:d,now:m,tick:h,expectedMs:Q}){let y=fd({total:n.length,selected:o,viewport:d});return(0,Pt.jsxs)(ht,{flexDirection:"column",children:[y.start>0?(0,Pt.jsxs)(rt,{dimColor:!0,children:[" \u2191 ",y.start," more"]}):null,n.slice(y.start,y.end).map((N,x)=>N.liveness==="running"?(0,Pt.jsx)($H,{run:N,detail:i,active:y.start+x===o,columns:c,now:m,tick:h,expectedMs:Q},N.runId):(0,Pt.jsx)(eO,{run:N,active:y.start+x===o,columns:c},N.runId)),y.end<n.length?(0,Pt.jsxs)(rt,{dimColor:!0,children:[" \u2193 ",n.length-y.end," more"]}):null]})}u(PH,"RunList");function $H({run:n,detail:i,active:o,columns:c,now:d,tick:m,expectedMs:h}){let Q=i?.participants[0],y=n.startedAt===void 0?Number.NaN:Date.parse(n.startedAt),N=Number.isFinite(y)?P2(d-y):void 0,x=h===void 0?"":` of ~${P2(h)}`,G=Q?.thought===void 0?void 0:cd(Q.thought.text,{width:Math.max(16,c-6),maxLines:3});return(0,Pt.jsxs)(ht,{flexDirection:"column",children:[(0,Pt.jsxs)(ht,{width:c,children:[(0,Pt.jsxs)(rt,{...cA(o?be.accent:void 0),bold:o,children:[Ni(o)," "]}),(0,Pt.jsxs)(rt,{color:be.ok,children:[tp({liveness:"running",tick:m})," "]}),(0,Pt.jsx)(rt,{...cA(o?be.accent:void 0),bold:o,wrap:"truncate-end",children:Q?.personaId??Q?.label??"starting\u2026"}),(0,Pt.jsx)(ht,{flexGrow:1}),(0,Pt.jsx)(rt,{dimColor:!0,children:N===void 0?"":`${N}${x}`})]}),G===void 0?null:(0,Pt.jsx)(ht,{flexDirection:"column",marginLeft:4,children:G.lines.map((b,L)=>(0,Pt.jsxs)(rt,{dimColor:L>0,children:[L===0?`"${b}`:b,L===G.lines.length-1?'"':""]},L))}),Q===void 0?null:(0,Pt.jsx)(ht,{width:c,children:(0,Pt.jsxs)(rt,{dimColor:!0,children:[" ",tO(Q)]})})]})}u($H,"LiveRun");function tO(n){let i=[];return n.actions!==void 0&&i.push(`${n.actions} actions`),n.thoughts!==void 0&&i.push(`${n.thoughts} thoughts`),n.turns!==void 0&&i.push(`${n.turns} turns`),i.length===0?"working\u2026":i.join(" \xB7 ")}u(tO,"activityLine");function eO({run:n,active:i,columns:o}){let c=aO(n.completedAt??n.startedAt),d=n.participants===void 0?n.verdict??"no verdict":`${n.participants.reachedGoal}/${n.participants.total} reached the goal`,m=n.estimatedCostUsd===void 0||n.estimatedCostUsd===null?"":` \xB7 ~$${n.estimatedCostUsd.toFixed(2)}`,h=[c,d].filter(Boolean).join(" \xB7 ")+m;return(0,Pt.jsxs)(ht,{width:o,children:[(0,Pt.jsxs)(rt,{...cA(i?be.accent:void 0),bold:i,children:[Ni(i)," "]}),(0,Pt.jsxs)(rt,{...gd(n),children:[tp(n)," "]}),(0,Pt.jsx)(rt,{...cA(i?be.accent:void 0),bold:i,wrap:"truncate-end",children:h})]})}u(eO,"PastRun");function nO(n){let i=n?.caps.laneUsd,o=n?.caps.studyUsd;if(i===void 0&&o===void 0)return"";let c=[];return i!==void 0&&c.push(`$${i} lane`),o!==void 0&&c.push(`$${o} study`),` \xB7 caps ${c.join(" / ")}`}u(nO,"capsLine");function AO(n){let i=n.replace(/\s+/g," ").trim(),o=i.indexOf(". ");return o===-1?i:i.slice(0,o+1)}u(AO,"firstSentence");function aO(n){if(n===void 0)return"";let i=Date.parse(n);if(!Number.isFinite(i))return"";let o=new Date(i),c=u(d=>String(d).padStart(2,"0"),"pad");return`${c(o.getUTCMonth()+1)}-${c(o.getUTCDate())} ${c(o.getUTCHours())}:${c(o.getUTCMinutes())}`}u(aO,"shortDate");function P2(n){if(!Number.isFinite(n)||n<0)return"0:00";let i=Math.floor(n/1e3),o=Math.floor(i/60);return o<60?`${o}:${String(i%60).padStart(2,"0")}`:Ri(n)}u(P2,"clockOf");var wn=Tt(Qa(),1);function ep(n,i){return["queued","running"].includes(i?.automaticAnalysis?.state??"")?i?.observerPath===void 0?["cancel-analysis"]:["observer","cancel-analysis"]:n.liveness==="interrupted"?i?.observerPath===void 0?["reclaim"]:["reclaim","observer"]:n.liveness==="running"?["stop"]:i?.observerPath===void 0?["again"]:["observer","again"]}u(ep,"runActions");function lO(n){switch(n){case"observer":return"Open in Observer";case"again":return"Run again";case"stop":return"Stop this run";case"cancel-analysis":return"Cancel analysis";default:return"Reclaim \u2014 stop sandboxes, keep evidence"}}u(lO,"actionLabel");function tN({run:n,detail:i,columns:o,selected:c,tick:d,now:m,actionNote:h}){let Q=i?.participants[0],y=ep(n,i),N=n.liveness==="interrupted";return(0,wn.jsxs)(ht,{flexDirection:"column",children:[(0,wn.jsx)(ht,{children:(0,wn.jsxs)(rt,{...gd(n),bold:!0,children:[tp({...n,tick:d})," ",iO(n,Q)]})}),N?(0,wn.jsx)(oO,{run:n,detail:i,participant:Q,now:m,columns:o}):(0,wn.jsx)(uO,{run:n,participant:Q,columns:o}),i?.automaticAnalysis===void 0?null:(0,wn.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[(0,wn.jsxs)(rt,{children:["Analysis: ",i.automaticAnalysis.state]}),i.automaticAnalysis.reason===null?null:(0,wn.jsx)(rt,{dimColor:!0,wrap:"wrap",children:i.automaticAnalysis.reason})]}),y.length===0?null:(0,wn.jsx)(ht,{marginTop:1,flexDirection:"column",children:y.map((x,G)=>(0,wn.jsx)(ht,{children:(0,wn.jsxs)(rt,{...cA(G===c?be.accent:void 0),bold:G===c,children:[Ni(G===c)," ",jr(lO(x),Math.max(10,o-3))]})},x))}),h===void 0?null:(0,wn.jsx)(ht,{marginTop:1,children:(0,wn.jsx)(rt,{dimColor:!0,wrap:"truncate-end",children:h})})]})}u(tN,"RunScreen");function iO(n,i){if(n.liveness==="interrupted")return"interrupted \u2014 no outcome recorded";if(n.liveness==="running"){let d=i?.personaId??i?.label;return d===void 0?"starting\u2026":`${d} is working`}let o=n.participants;if(o===void 0)return n.verdict??"finished, no verdict recorded";let c=o.reportedFriction===void 0||o.reportedFriction===0?"":` \xB7 ${o.reportedFriction} reported friction`;return`${o.reachedGoal}/${o.total} reached the goal${c}`}u(iO,"headline");function uO({run:n,participant:i,columns:o}){let c=i?.thought===void 0?void 0:cd(i.thought.text,{width:Math.max(16,o),maxLines:3}),d=[n.durationMs===void 0?void 0:Ri(n.durationMs),i?.turns===void 0?void 0:`${i.turns} turns`,i?.thoughts===void 0?void 0:`${i.thoughts} thoughts`].filter(Boolean).join(" \xB7 ");return(0,wn.jsxs)(ht,{flexDirection:"column",children:[c===void 0?null:(0,wn.jsx)(ht,{marginTop:1,flexDirection:"column",children:c.lines.map((m,h)=>(0,wn.jsxs)(rt,{children:[h===0?`"${m}`:m,h===c.lines.length-1?'"':""]},h))}),(0,wn.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[d===""?null:(0,wn.jsx)(rt,{dimColor:!0,children:d}),(0,wn.jsx)(rt,{dimColor:!0,children:eN(n,i)})]})]})}u(uO,"FinishedFacts");function oO({run:n,detail:i,participant:o,now:c,columns:d}){let m=n.startedAt===void 0?Number.NaN:Date.parse(n.startedAt),h=n.updatedAt===void 0?Number.NaN:c-Date.parse(n.updatedAt),Q=[o?.thoughts===void 0?void 0:`${o.thoughts} thoughts`,o?.actions===void 0?void 0:`${o.actions} actions`].filter(Boolean).join(" \xB7 ");return(0,wn.jsxs)(ht,{marginTop:1,flexDirection:"column",width:d,children:[(0,wn.jsxs)(rt,{dimColor:!0,children:[Number.isFinite(m)?`started ${rO(m)}`:"start time not recorded",Number.isFinite(h)?` \xB7 quiet ${Ri(h)}`:"",Q===""?"":` \xB7 ${Q} captured`]}),(0,wn.jsxs)(ht,{children:[(0,wn.jsx)(rt,{dimColor:!0,children:n.estimatedCostUsd===void 0&&o?.estimatedCostUsd===void 0?"cost unknown \u2014 it ended before pricing itself":eN(n,o)}),(0,wn.jsx)(rt,{color:be.warn,children:" sandboxes may still be running"})]})]})}u(oO,"InterruptedFacts");function eN(n,i){let o=n.estimatedCostUsd===void 0?i?.estimatedCostUsd:n.estimatedCostUsd;return o===void 0?"cost not recorded":o===null?"cost declared absent":`~$${o.toFixed(2)} estimated`}u(eN,"costLine");function rO(n){let i=new Date(n),o=u(c=>String(c).padStart(2,"0"),"pad");return`${o(i.getUTCHours())}:${o(i.getUTCMinutes())}`}u(rO,"clockTime");var nN=Tt(Ue(),1);var Ke=Tt(Qa(),1);function AN({rows:n,selected:i,columns:o,viewport:c,unattributed:d,tick:m,liveParticipants:h,now:Q,initialized:y,peerSelected:N,liveTotal:x,initArmed:G,actionNote:b}){if(n.length===0)return y?(0,Ke.jsxs)(ht,{flexDirection:"column",children:[(0,Ke.jsx)(rt,{children:"no labs here yet"}),(0,Ke.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[(0,Ke.jsx)(rt,{dimColor:!0,children:"a lab is a study: who to send, to what, and what counts as done."}),(0,Ke.jsx)(rt,{dimColor:!0,children:"write one in humanish/labs/, or `humanish init` for three to start from."})]})]}):(0,Ke.jsxs)(ht,{flexDirection:"column",children:[(0,Ke.jsx)(rt,{children:"this directory is not a humanish project"}),(0,Ke.jsxs)(ht,{marginTop:1,flexDirection:"column",children:[(0,Ke.jsx)(rt,{dimColor:!0,children:"humanish studies live in a project: a humanish/ directory of labs and"}),(0,Ke.jsx)(rt,{dimColor:!0,children:"personas beside the app they study."})]}),(0,Ke.jsxs)(ht,{marginTop:1,children:[(0,Ke.jsxs)(rt,{...cA(be.accent),bold:!0,children:[Ni(!0)," Set up humanish here"]}),(0,Ke.jsx)(ht,{flexGrow:1}),(0,Ke.jsx)(rt,{dimColor:!0,children:G?"\u23CE again to confirm \xB7 esc cancel":"writes humanish/ and updates package.json"})]}),b===void 0?null:(0,Ke.jsx)(ht,{marginTop:1,children:(0,Ke.jsx)(rt,{dimColor:!0,children:b})})]});let L=fd({total:n.length,selected:i,viewport:c});return(0,Ke.jsxs)(ht,{flexDirection:"column",children:[L.start>0?(0,Ke.jsxs)(rt,{dimColor:!0,children:[" \u2191 ",L.start," more"]}):null,n.slice(L.start,L.end).map((j,q)=>{let F=L.start+q,gt=F>0?n[F-1]:void 0,xt=j.runs===0&&gt!==void 0&&gt.runs>0;return(0,Ke.jsxs)(nN.default.Fragment,{children:[xt?(0,Ke.jsx)(ht,{marginTop:1,children:(0,Ke.jsxs)(rt,{dimColor:!0,children:[" ","not yet run"]})}):null,(0,Ke.jsx)(cO,{row:j,columns:o,active:F===i,tick:m,liveParticipants:h,now:Q})]},j.key)}),L.end<n.length?(0,Ke.jsxs)(rt,{dimColor:!0,children:[" \u2193 ",n.length-L.end," more"]}):null,(0,Ke.jsxs)(ht,{marginTop:1,children:[(0,Ke.jsxs)(rt,{...cA(N?be.accent:void 0),bold:N,dimColor:!N,children:[Ni(N)," All runs"]}),x>0?(0,Ke.jsxs)(rt,{color:be.ok,children:[" ",x," working"]}):null]}),d>0?(0,Ke.jsx)(ht,{marginTop:1,children:(0,Ke.jsxs)(rt,{dimColor:!0,children:[d," ",d===1?"run":"runs"," with no lab"]})}):null,(0,Ke.jsxs)(ht,{marginTop:1,width:o,children:[(0,Ke.jsx)(rt,{...cA(be.accent),children:"\u25B8"}),(0,Ke.jsx)(rt,{dimColor:!0,wrap:"truncate-end",children:` ${sO(n[i],N)}`})]})]})}u(AN,"LabsScreen");function sO(n,i){if(i)return"every run in this project, newest first \u2014 across every lab";if(n===void 0)return"";let o=n.description?.split(/(?<=[.!?])\s/)[0]?.trim();return o!==void 0&&o.length>0?o:"no description in the manifest"}u(sO,"describe");function cO({row:n,columns:i,active:o,tick:c,liveParticipants:d,now:m}){let h=n.liveRuns[0],Q=h===void 0?mh(n):fO(n,h,d.get(h.runId),m),y=Math.max(10,Math.floor(i/2)-2),N=Q.length<=y?Q:gO(n),x=Math.max(8,i-N.length-6);return(0,Ke.jsxs)(ht,{width:i,children:[(0,Ke.jsxs)(rt,{...cA(o?be.accent:void 0),bold:o,children:[Ni(o)," "]}),(0,Ke.jsxs)(rt,{...gd({liveness:h===void 0?"finished":"running"}),children:[h===void 0?" ":$m(c)," "]}),(0,Ke.jsx)(rt,{...cA(o?be.accent:void 0),bold:o,wrap:"truncate-end",children:jr(n.label,x)}),(0,Ke.jsx)(ht,{flexGrow:1}),(0,Ke.jsx)(rt,{...cA(h===void 0?void 0:be.ok),dimColor:h===void 0,children:N})]})}u(cO,"LabRowView");function fO(n,i,o,c){let d=i.startedAt===void 0?Number.NaN:Date.parse(i.startedAt),m=Number.isFinite(d)?dO(c-d):void 0,h=o??"starting\u2026",Q=n.live>1?` +${n.live-1}`:"";return m===void 0?`${h}${Q}`:`${h} \xB7 ${m}${Q}`}u(fO,"liveStatus");function gO(n){return n.live>0?`${n.live} running`:n.runs===0?n.declared?"never run":"no runs":`${n.runs} runs`}u(gO,"fallbackStatus");function dO(n){if(!Number.isFinite(n)||n<0)return"0:00";let i=Math.floor(n/1e3),o=Math.floor(i/60),c=i%60;return o<60?`${o}:${String(c).padStart(2,"0")}`:Ri(n)}u(dO,"clockOf");var Bh=Tt(Ue(),1);function aN(){let{stdout:n}=sh(),i=u(()=>({columns:Math.max(20,n.columns||80),rows:Math.max(6,n.rows||24)}),"read"),[o,c]=(0,Bh.useState)(i);return(0,Bh.useEffect)(()=>{let d=u(()=>{c(h=>{let Q=i();return Q.columns===h.columns&&Q.rows===h.rows?h:Q})},"update");n.on("resize",d);let m=setTimeout(d,0);return()=>{n.off("resize",d),clearTimeout(m)}},[n]),o}u(aN,"useTerminalSize");var bi=Tt(Qa(),1),EO=6,L0=2e3,mO=5e3,pO=100,z0=400,CO=120;function uN({options:n,onReady:i,now:o,tick:c}){let{exit:d}=U0(),m=aN(),[h,Q]=(0,Xe.useReducer)(q2,void 0,K2),[y,N]=(0,Xe.useState)(void 0),[x,G]=(0,Xe.useState)(void 0),[b,L]=(0,Xe.useState)(void 0),[j,q]=(0,Xe.useState)(void 0),[F,gt]=(0,Xe.useState)(void 0),[xt,kt]=(0,Xe.useState)(void 0),[Mt,pe]=(0,Xe.useState)(void 0),[Ce,Yt]=(0,Xe.useState)(void 0),[wt,Ct]=(0,Xe.useState)(void 0),[Gt,se]=(0,Xe.useState)(!1),[vt,rn]=(0,Xe.useState)(void 0),[He,ft]=(0,Xe.useState)(0),Ut=c??He,[Jt,Rt]=(0,Xe.useState)(void 0),[ie,sn]=(0,Xe.useState)(new Map),tt=(0,Xe.useMemo)(()=>n.capabilities.readProjectState(n.cwd),[n]),Ot=o??Date.now(),ue=(0,Xe.useRef)(void 0),le=(0,Xe.useRef)({name:"labs"});(0,Xe.useEffect)(()=>{let it=!1,Lt=u(async()=>{try{let[Vt,ye]=await Promise.all([n.capabilities.readRunIndex(n.cwd),n.capabilities.listLabs(n.cwd)]);if(it)return;G(void 0),N(lN(Vt,ye.labs))}catch(Vt){if(it)return;G(Vt instanceof Error?Vt.message:String(Vt))}},"read");Lt();let de=setInterval(()=>{Lt()},L0);return de.unref?.(),()=>{it=!0,clearInterval(de)}},[n]),(0,Xe.useEffect)(()=>{(y!==void 0||x!==void 0)&&i?.()},[y,x,i]);let Kt=Pm(h),fn=F2(h),ce=iN(Kt,y,Mt);(0,Xe.useEffect)(()=>{le.current=Kt;let it=yO(Kt,y,fn);it!==void 0&&(ue.current=it)},[Kt,y,fn]),(0,Xe.useEffect)(()=>{if(y===void 0)return;let it=ue.current;if(it===void 0)return;let Lt=SO(Kt,y,it);Lt>=0&&Lt!==fn&&Q({type:"select",index:Lt,total:iN(Kt,y,Mt)})},[y,Kt]);let Oe=(0,Xe.useCallback)(async(it,Lt)=>{if(Lt==="live"&&b!=="live"){L("live"),kt(Date.now());return}if(Lt==="live"&&xt!==void 0&&Date.now()-xt<z0)return;L(void 0),kt(void 0),q(void 0),gt({labKey:it.key,text:`starting ${it.name}\u2026`});let de=await n.capabilities.startRun({cwd:n.cwd,lab:it.name,mode:Lt});if(!de.ok){gt(void 0),q({labKey:it.key,text:de.error.message});return}let Vt=Date.parse(de.run.launchedAt),ye=u(gA=>{if(gA.pid!==de.run.pid)return!1;let nA=gA.startedAt===void 0?Number.NaN:Date.parse(gA.startedAt);return!Number.isFinite(nA)||!Number.isFinite(Vt)?!1:nA>=Vt-1e3},"isOurs"),Ve=Date.now()+mO;for(;;){let gA=await n.capabilities.readRunIndex(n.cwd),nA=gA.runs.find(ye);if(nA!==void 0){let WA=await n.capabilities.listLabs(n.cwd);N(lN(gA,WA.labs)),gt(void 0),le.current.name==="lab"&&le.current.labKey===it.key&&Q({type:"enter",screen:{name:"run",labId:it.labId,runId:nA.runId}});return}if(Date.now()>=Ve)break;await new Promise(WA=>setTimeout(WA,pO))}let eA=await n.capabilities.readLaunchLog(de.run.logPath);gt(void 0),q({labKey:it.key,text:eA===""?`${it.name} started (pid ${de.run.pid}) but has not reported in. Check ${de.run.logPath}.`:`${it.name} did not report in. Its log ends:
287
287
  ${eA.split(`
288
288
  `).slice(-3).join(`
289
289
  `)}`})},[b,xt,n]),$t=(0,Xe.useCallback)(async(it,Lt)=>{if(Lt==="stop"||Lt==="cancel-analysis"){if(wt===void 0){Ct(Date.now()),Yt(Lt==="cancel-analysis"?"cancel analysis? \u23CE again to confirm \xB7 esc keep analyzing":"stop this run? \u23CE again to confirm \xB7 esc cancel");return}if(Date.now()-wt<z0)return;Ct(void 0),Yt(Lt==="cancel-analysis"?"cancelling analysis\u2026":"stopping\u2026");let Ve=await n.capabilities.stopRun(n.cwd,it.runId,Lt==="cancel-analysis"?"analysis":"run");Yt(Ve.message);return}if(Lt==="observer"){let Ve=Mt?.observerPath;if(Ve===void 0){Yt("this run has no Observer artifact on disk");return}Yt("opening\u2026");let eA=await n.capabilities.openObserver(n.cwd,Ve);Yt(eA.message);return}if(Lt==="reclaim"){Yt("reclaiming \u2014 stopping sandboxes, keeping evidence\u2026");let Ve=await n.capabilities.reclaimRun(n.cwd,it.runId);Yt(Ve.ok?`reclaimed ${Ve.receiptCount} recorded resource${Ve.receiptCount===1?"":"s"}`:`could not reclaim: ${Ve.error?.message??"unknown"}`);return}let de=it.lab?.id,Vt=de===void 0?void 0:y?.rows.find(Ve=>Ve.labId===de);if(Vt===void 0||!Vt.declared){Yt("cannot run this again \u2014 its lab has no manifest here any more");return}Yt(`starting ${Vt.name}\u2026`);let ye=await n.capabilities.startRun({cwd:n.cwd,lab:Vt.name,mode:it.mode==="live"?"live":"dry-run"});Yt(ye.ok?`started ${Vt.name} (pid ${ye.run.pid})`:ye.error.message)},[Mt,n,y,wt]);M0((0,Xe.useCallback)((it,Lt)=>{if(Gt){se(!1),it==="q"&&d();return}if(it==="?"){se(!0);return}if(it==="q"){d();return}if(it==="g"||it==="G"){b!==void 0&&(L(void 0),kt(void 0)),Q({type:"move",delta:it==="g"?-ce:ce,total:ce});return}if(Lt.upArrow||it==="k"||Lt.downArrow||it==="j"){b!==void 0&&(L(void 0),kt(void 0)),Q({type:"move",delta:Lt.upArrow||it==="k"?-1:1,total:ce});return}if(Lt.escape||Lt.leftArrow){if(b!==void 0){L(void 0),kt(void 0);return}if(wt!==void 0){Ct(void 0),Yt(void 0);return}if(vt!==void 0){rn(void 0);return}Q({type:"back"});return}if(Lt.return||Lt.rightArrow){if(Kt.name==="labs"&&tt.initialized===!1){if(vt===void 0){rn(Date.now());return}if(Date.now()-vt<z0)return;rn(void 0),(async()=>{let Vt=await n.capabilities.initProject(n.cwd);Yt(Vt.message)})();return}if(Kt.name==="run"&&y!==void 0){let Vt=y.runsById.get(Kt.runId);if(Vt!==void 0){let ye=ep(Vt,Mt)[fn];if(ye!==void 0){$t(Vt,ye);return}}}if(Kt.name==="lab"&&y!==void 0){let{row:Vt,items:ye}=dd(y,Kt.labKey),Ve=ye[fn];if(Vt!==void 0&&Ve?.kind==="start"){Oe(Vt,Ve.mode);return}}let de=vO(Kt,y,fn);de!==void 0&&Q({type:"enter",screen:de})}},[d,ce,Kt,y,fn,b,Oe,Mt,$t,wt,Gt,vt,tt,n])),(0,Xe.useEffect)(()=>{h.quit&&d()},[h.quit,d]);let ge=Kt.name==="run"?Kt.runId:void 0;(0,Xe.useEffect)(()=>{if(Yt(void 0),Ct(void 0),ge===void 0){pe(void 0);return}let it=!1;pe(void 0);let Lt=u(async()=>{try{let Vt=await n.capabilities.readRunDetail(n.cwd,ge);it||pe(Vt)}catch{it||pe(null)}},"read");Lt();let de=setInterval(()=>{Lt()},L0);return de.unref?.(),()=>{it=!0,clearInterval(de)}},[ge,n]),(0,Xe.useEffect)(()=>{if(c!==void 0)return;let it=setInterval(()=>ft(Lt=>Lt+1),CO);return it.unref?.(),()=>clearInterval(it)},[c]);let fA=Kt.name==="lab"?y?.rows.find(it=>it.key===Kt.labKey):void 0,IA=fA===void 0?void 0:y?.runsByLab.get(fA.labId)?.[0]?.runId,NA=[...new Set([...(y?.rows??[]).flatMap(it=>it.liveRuns.map(Lt=>Lt.runId)),...IA===void 0?[]:[IA]])].join(",");(0,Xe.useEffect)(()=>{if(NA===""){sn(new Map);return}let it=!1,Lt=!1,de=u(async()=>{if(Lt)return;Lt=!0;let ye=NA.split(","),Ve=await Promise.all(ye.map(async eA=>{let gA=await n.capabilities.readRunDetail(n.cwd,eA).catch(()=>null);return gA===null?null:[eA,gA]}));it||sn(new Map(Ve.filter(eA=>eA!==null))),Lt=!1},"read");de();let Vt=setInterval(()=>{de()},L0);return Vt.unref?.(),()=>{it=!0,clearInterval(Vt)}},[NA,n]);let Be=Kt.name==="lab"?Kt.labKey:void 0,we=Be===void 0?void 0:y?.rows.find(it=>it.key===Be)?.name;(0,Xe.useEffect)(()=>{if(we===void 0){Rt(void 0);return}let it=!1;return Rt(void 0),(async()=>{let Lt=await n.capabilities.readLabSummary(n.cwd,we,{checkKeys:!0}).catch(()=>null);it||Rt(Lt)})(),()=>{it=!0}},[we,n]);let tn=Math.max(1,m.rows-EO),yn=(0,Xe.useMemo)(()=>Gt?(0,bi.jsx)(G2,{columns:ph(m.columns)}):x!==void 0?(0,bi.jsxs)(rt,{color:be.bad,children:["could not read this project: ",x]}):y===void 0?(0,bi.jsx)(rt,{dimColor:!0,children:"reading project\u2026"}):DO({screen:Kt,data:y,selected:fn,columns:ph(m.columns),viewport:tn,now:Ot,confirming:b,launchError:j,launchNote:F,detail:Mt,summary:Jt,liveDetails:ie,tick:Ut,initialized:tt.initialized,actionNote:Ce,initArmed:vt!==void 0}),[Gt,x,y,Kt,fn,m.columns,tn,Ot,b,j,F,Mt,Jt,ie,Ut,tt,Ce]);return(0,bi.jsx)(j2,{columns:m.columns,context:BO(Kt,y,n),breadcrumb:hO(Kt,y),hints:Gt?"any key returns q quit":IO(Kt,y,fn,b,tt.initialized),children:yn})}u(uN,"App");function BO(n,i,o){let c=o.cwd.split("/").filter(Boolean).pop();if(n.name==="run"&&i!==void 0){let m=i.runsById.get(n.runId),h=n.runId.split("-").pop()??n.runId;return[m?.lab?.id,h].filter(Boolean).join(" \xB7 ")}if(i===void 0)return c;let d=Nc(i).length;return d===0?c:`${c} \xB7 ${d} participant${d===1?"":"s"} working`}u(BO,"contextLine");function hO(n,i){if(n.name==="labs")return;if(n.name==="all-runs")return"\u2039 labs / all runs";if(n.name==="lab")return`\u2039 labs / ${i?.rows.find(d=>d.key===n.labKey)?.name??n.labKey}`;let o=n.labId;return o===void 0?"\u2039 labs / run":`\u2039 labs / ${o} / run`}u(hO,"breadcrumbOf");function IO(n,i,o,c,d){let m="\u2191\u2193 move";switch(n.name){case"labs":return(i?.rows.length??0)>0?`${m} \u23CE open ? keys q quit`:d===!1?"\u23CE set up humanish here ? keys q quit":"? keys q quit";case"lab":{if(c!==void 0)return"\u21B5 confirm \xB7 esc cancel";let Q=(i===void 0?void 0:dd(i,n.labKey).items[o])?.kind==="start"?"\u23CE start":"\u23CE open run";return`${m} ${Q} esc back ? keys q quit`}case"all-runs":return`${m} \u23CE open run esc back ? keys q quit`;default:{let h=i===void 0?void 0:i.runsById.get(n.name==="run"?n.runId:"");return h!==void 0&&ep(h,void 0).length>0?`${m} \u23CE select esc back ? keys q quit`:"esc back ? keys q quit"}}}u(IO,"keyHints");function lN(n,i){let{rows:o,unattributed:c}=J2(i.map(h=>({id:h.id,...h.title===void 0?{}:{title:h.title},...h.description===void 0?{}:{description:h.description},path:h.path,origin:h.origin})),n.runs),d=new Map,m=new Map;for(let h of n.runs){m.set(h.runId,h);let Q=h.lab?.id;if(Q===void 0)continue;let y=d.get(Q);y===void 0?d.set(Q,[h]):y.push(h)}return{rows:o,unattributed:c,runsByLab:d,runsById:m,unreadable:n.unreadable}}u(lN,"project");function Nc(n){let i=new Set,o=[];for(let c of n.rows.flatMap(d=>d.liveRuns))i.has(c.runId)||(i.add(c.runId),o.push(c));return o}u(Nc,"liveRunsOf");function QO(n,i){return i===void 0?"":n.rows.find(o=>o.labId===i)?.label??i}u(QO,"labelForLab");function dd(n,i){let o=n.rows.find(c=>c.key===i);return o===void 0?{items:[]}:{row:o,items:Ch(n.runsByLab.get(o.labId)??[],o.declared)}}u(dd,"itemsForLab");function iN(n,i,o){if(i===void 0)return 0;switch(n.name){case"labs":return i.rows.length+1;case"all-runs":return Nc(i).length;case"lab":return dd(i,n.labKey).items.length;case"run":{let c=i.runsById.get(n.runId);return c===void 0?0:ep(c,o).length}default:return 0}}u(iN,"countRows");function yO(n,i,o){if(i!==void 0){if(n.name==="labs")return i.rows[o]?.key??"peer:all-runs";if(n.name==="all-runs")return Nc(i)[o]?.runId;if(n.name==="lab"){let c=dd(i,n.labKey).items[o];return c===void 0?void 0:c.kind==="start"?`start:${c.mode}`:`run:${c.run.runId}`}}}u(yO,"identityOf");function SO(n,i,o){return n.name==="labs"?o==="peer:all-runs"?i.rows.length:i.rows.findIndex(c=>c.key===o):n.name==="all-runs"?Nc(i).findIndex(c=>c.runId===o):n.name==="lab"?dd(i,n.labKey).items.findIndex(c=>c.kind==="start"?o===`start:${c.mode}`:`run:${c.run.runId}`===o):-1}u(SO,"indexOfIdentity");function vO(n,i,o){if(i!==void 0){if(n.name==="labs"){let c=i.rows[o];return c===void 0?o===i.rows.length?{name:"all-runs"}:void 0:{name:"lab",labKey:c.key}}if(n.name==="all-runs"){let c=Nc(i)[o];return c===void 0?void 0:{name:"run",...c.lab?.id===void 0?{}:{labId:c.lab.id},runId:c.runId}}if(n.name==="lab"){let{row:c,items:d}=dd(i,n.labKey),m=d[o];return c===void 0||m===void 0||m.kind!=="run"?void 0:{name:"run",labId:c.labId,runId:m.run.runId}}}}u(vO,"openSelected");function DO(n){let{screen:i,data:o,selected:c,columns:d,viewport:m,now:h,confirming:Q,launchError:y,launchNote:N,detail:x}=n,{summary:G,liveDetails:b,tick:L,initialized:j,actionNote:q}=n;if(i.name==="labs")return(0,bi.jsx)(AN,{rows:o.rows,selected:c,columns:d,viewport:m,unattributed:o.unattributed.length,tick:L,initialized:j,peerSelected:c===o.rows.length,liveTotal:Nc(o).length,...n.initArmed===!0?{initArmed:!0}:{},...n.actionNote===void 0?{}:{actionNote:n.actionNote},liveParticipants:new Map([...b.entries()].map(([gt,xt])=>{let kt=xt.participants[0]?.personaId??xt.participants[0]?.label;return kt===void 0?null:[gt,kt]}).filter(gt=>gt!==null)),now:h});if(i.name==="lab"){let gt=o.rows.find(xt=>xt.key===i.labKey);return gt===void 0?(0,bi.jsx)(rt,{color:be.warn,children:"that lab is no longer in this project"}):(0,bi.jsx)($2,{row:gt,summary:G,runs:o.runsByLab.get(gt.labId)??[],liveDetail:b.get(gt.liveRuns[0]?.runId??o.runsByLab.get(gt.labId)?.[0]?.runId??""),selected:c,columns:d,viewport:m,now:h,tick:L,canStart:gt.declared,confirming:Q,launchError:y?.labKey===gt.key?y.text:void 0,launchNote:N?.labKey===gt.key?N.text:void 0})}if(i.name==="all-runs"){let gt=Nc(o);return(0,bi.jsx)(X2,{runs:gt,details:b,labels:new Map(gt.map(xt=>[xt.runId,QO(o,xt.lab?.id)])),expected:new Map(o.rows.map(xt=>xt.liveExpectation.medianDurationMs===void 0?null:[xt.labId,xt.liveExpectation.medianDurationMs]).filter(xt=>xt!==null)),selected:c,columns:d,viewport:m,tick:L,now:h})}let F=o.runsById.get(i.runId);return F===void 0?(0,bi.jsx)(rt,{color:be.warn,children:"that run is no longer on disk"}):(0,bi.jsx)(tN,{run:F,detail:x,columns:d,viewport:m,selected:c,tick:L,now:h,actionNote:q})}u(DO,"renderScreen");var oN=Tt(Qa(),1);function RO(n){if(Rc())return n;let i=Object.create(n);return i.write=((o,...c)=>n.write(typeof o=="string"?U2(o):o,...c)),i}u(RO,"encodeFor");var f7=u(async n=>{let i=u(()=>{},"ready"),o=new Promise(m=>{i=m}),c=RO(n.stdout),d=T0((0,oN.jsx)(uN,{options:n,onReady:i}),{stdin:n.stdin,stdout:c,patchConsole:!1,exitOnCtrlC:!0,interactive:!0});n.exitAfterFirstFrame===!0&&(await o,await new Promise(m=>setImmediate(m)),d.unmount());try{return await d.waitUntilExit(),0}catch(m){return d.unmount(),n.stdout.write(`humanish tui exited: ${m instanceof Error?m.message:String(m)}
@@ -73,3 +73,8 @@ npx tsc --allowJs --checkJs --noEmit --strict --skipLibCheck --types node --targ
73
73
  See the [state-driven executor guide](../../state-driven-executor.md) for progress
74
74
  projection limits, runtime-only state, unpinned local-app provenance, and the
75
75
  fail-closed guards on this route.
76
+
77
+ The example explicitly sets `review: { analysis: false }` to keep post-run
78
+ analysis free of provider requests too. Supported live recordings otherwise
79
+ use the separate default analysis budget; a deterministic participant provider
80
+ does not replace the analysis provider.
@@ -68,6 +68,7 @@ try {
68
68
  // This registry id selects the CUA loop. buildProvider supplies the actual provider.
69
69
  actors: [{ type: "openai-computer-use", persona: "pixel-pat", mission: "Greet the app." }],
70
70
  scenario: { mode: "live" },
71
+ review: { analysis: false }, // Keep this deterministic example free of provider requests.
71
72
  execution: { timeoutMs: 15_000 }
72
73
  });
73
74
  if (!parsed.ok) throw new Error(parsed.error.message);
@@ -3,7 +3,7 @@
3
3
  Date: 2026-06-02 (current-state note updated 2026-07-14)
4
4
 
5
5
  Status: reference map for the major contracts shipped through source version
6
- `0.90.0`; it is not an exhaustive inventory of command/result envelopes. Exported types,
6
+ `0.91.0`; it is not an exhaustive inventory of command/result envelopes. Exported types,
7
7
  schema constants, parsers, and validators in `src/` are authoritative. Rows
8
8
  marked "reserved" name layering intent only — no code emits or validates them
9
9
  yet. Do not emit a reserved schema.
@@ -1,8 +1,11 @@
1
1
  # Study analysis
2
2
 
3
- Study analysis is an optional interpretation of retained participant evidence.
3
+ Study analysis is an independent interpretation of retained participant evidence.
4
4
  It is separate from the participant's account, recorded outcome, and the run's
5
5
  deterministic review verdict. Opening an Observer never starts a provider request.
6
+ Supported live runs request analysis on completion by default, with a separate
7
+ $3 admission estimate limit. Set `review.analysis: false` to disable that request;
8
+ see [automatic analysis](../product/automatic-analysis.md).
6
9
 
7
10
  ## Invocation
8
11
 
@@ -59,8 +62,15 @@ stopped, an operator can remove the empty lock directory and retry.
59
62
 
60
63
  The packet currently admits up to 16 participants, 800 evidence items, 40 PNG
61
64
  captures, 160 KiB of text and 20 MiB of images. Individual source files, image
62
- dimensions and result sizes have separate limits. Selection follows retained
63
- source order; it is not a statistically representative sample. Selection
65
+ dimensions and result sizes have separate limits. Count and text budgets are
66
+ distributed across included participants, with unused capacity from short
67
+ sessions available to longer ones. Capture selection prioritizes session endings
68
+ and beginnings, context around recorded failures, and spread across each whole
69
+ session. Failure priority uses structured source status, not application-specific
70
+ keywords or image interpretation. Unflagged visual errors may still be omitted.
71
+ Bounded reads and the total image byte limit can reduce coverage further.
72
+ Selected entries retain their original source order, frame and event identities;
73
+ this is not a statistically representative sample. Selection
64
74
  omissions and unreadable or invalid capture files make declared coverage
65
75
  incomplete. Coverage records file availability and selection; it does not
66
76
  certify visual legibility, correct interpretation, or exhaustive issue discovery.
@@ -72,7 +82,8 @@ to an earlier capture retain that context without creating another frame.
72
82
  Scripted lanes use their recorded `ui.intent` goal when no participant assignment
73
83
  exists. Missing assignments and declared captures without supported trace
74
84
  references are explicit omissions. Artifacts without `captureVersion` continue
75
- to validate against the original selection rules.
85
+ to validate against the original capture mapping; previously saved selections
86
+ are not recomputed or rewritten.
76
87
 
77
88
  The standard review covers session summary, apparent intent, observed outcome,
78
89
  friction, dead ends, recovery, and participant feedback. Findings are ordered by
@@ -80,6 +91,21 @@ observed task impact, replication among exposed participants, and recovery.
80
91
  Impact and confidence remain separate. There is no numeric frustration or
81
92
  universal priority score.
82
93
 
94
+ The standard review also accounts for material participant concerns before
95
+ ranking findings. Reported uncertainty can be useful even when the interface is
96
+ correct or study setup may explain it. Claims distinguish that experience from
97
+ an established product defect, preserve consequential recoveries, and check
98
+ participant accounts against the actual assignment and captured state.
99
+
100
+ New results include `concernReviews`: evidence-linked observations with a
101
+ `finding`, `context`, or `unsupported` disposition and a concise reason. A finding
102
+ disposition references an existing local finding ID; other dispositions use null.
103
+ The Observer's **Concerns considered** disclosure exposes these decisions and
104
+ their original evidence. There is no required finding count or inventory of every
105
+ thought. Older reports may omit this field and remain readable. The disclosure
106
+ is model-generated assessment, not an independent completeness audit or a human
107
+ reviewer annotation.
108
+
83
109
  Every observation cites packet-local evidence IDs. The model cannot choose a
84
110
  filesystem path or fetch another resource. Validation checks participant
85
111
  membership, unique counts, quote fidelity, evidence type and reference
@@ -105,7 +131,7 @@ status, usage and validated findings:
105
131
  analysis/<analysis>/corrections/<correction>/correction.json
106
132
  analysis-attempts/<analysis>/receipt.json
107
133
  observer/study-analysis.json
108
- analysis-automatic/job.json # opt-in run lifecycle; never a retry instruction
134
+ analysis-automatic/job.json # post-run lifecycle; never a retry instruction
109
135
  ```
110
136
 
111
137
  The optional automatic job is separate from the immutable analysis. Its view
@@ -1,9 +1,9 @@
1
1
  # Current Goals
2
2
 
3
- Status date: 2026-09-15. Release baseline: `0.90.0`.
3
+ Status date: 2026-09-15. Release baseline: `0.91.0`.
4
4
 
5
5
  This page guides work on current merged source. Published behavior is described
6
- in the [release notes](../release/0.90.0-automatic-analysis.md).
6
+ in the [release notes](../release/0.91.0-analysis-quality-and-defaults.md).
7
7
  The [September 9 history](https://github.com/danielgwilson/humanish/blob/main/docs/goals/current-history-2026-09-09.md)
8
8
  preserves the former status log; its queues do not supersede this page.
9
9
 
@@ -88,7 +88,7 @@ requires decision-equivalent retained evidence and a real deletion branch.
88
88
  No first-party deletion branch has met that gate. Public demonstrations do not
89
89
  substitute for it.
90
90
 
91
- ## Current Program Truth (source `0.90.0`)
91
+ ## Current Program Truth (source `0.91.0`)
92
92
 
93
93
  | Surface | Available in merged source | Remaining boundary |
94
94
  | --- | --- | --- |
@@ -99,7 +99,7 @@ substitute for it.
99
99
  | Shared state | Sequential and concurrent single-origin shared-world studies with retained evidence | Multi-origin implementation remains gated; concurrent state change does not establish per-action causation |
100
100
  | Observer | Live/recorded views, participant assignments, action-specific links, saved moments, zoom, comparison and phone-width review | Sparse captures cannot prove every action's effect; visual comparison alone is not a controlled experiment |
101
101
  | Review and feedback | Verification grades, feedback drafts, portable HTML, redacted bundle derivatives and computer-use completion-source labels | Sharing requires the appropriate grade; participant reports and condition matches still need task adjudication |
102
- | Study findings | Explicit `analyze` or opt-in post-run analysis, bounded evidence selection, versioned findings, exact source links and append-only corrections within the Observer study shell | Model interpretation needs review; bounded selection and source truncation limit coverage; opening Observer never dispatches analysis |
102
+ | Study findings | Default post-run analysis on supported live routes with a separate disclosed $3 admission estimate limit and opt-out; explicit `analyze`, fairer evidence selection, concern review and versioned findings with exact source links | Model interpretation needs review; bounded selection and source truncation limit coverage; opening Observer never dispatches analysis |
103
103
  | TUI and serving | Detached starts, run stopping, reclamation, Observer attachment, loopback serving and run library | Stopping a process does not itself prove sandbox cleanup; TUI views over CLI `stats`/`export` remain follow-ups |
104
104
  | Off-app communication | In-sandbox email/SMS catch and digest-only thread evidence | This does not establish real-provider delivery |
105
105
  | Mobile and media | Hosted viewport/emulation, desktop geometry checks, bounded dwell and declared camera feed | Physical-device and touch fidelity remain unproven; unsupported microphone declarations are rejected |
@@ -34,9 +34,12 @@ certify (see the conformance suite).
34
34
  terminal) is only ever pointed at a URL the harness itself issued or validated under a
35
35
  declared policy (loopback entry, provisioned subject, declared external target). Never an
36
36
  arbitrary URL from unvalidated input.
37
- 3. **Live spend is explicit.** No configuration default, omission, or fallback may cause
38
- provider or sandbox spend. Spend requires an affirmative declaration (`scenario.mode:
39
- live`, an env opt-in gate for spend-bearing tests).
37
+ 3. **Live spend requires an explicit live invocation.** No omission or fallback may
38
+ turn a dry run, preview, reader or unsupported route into provider or sandbox
39
+ spend. An explicitly live supported study includes the disclosed default
40
+ post-run analysis budget unless `review.analysis: false` disables it. Analysis
41
+ has a separate admission estimate limit, not a provider billing cap or part of
42
+ the actor budget. Spend-bearing tests retain their explicit env gates.
40
43
  4. **Evidence verifies fail-closed.** A run bundle that cannot pass verification (schema,
41
44
  redaction status, artifact presence, public-safety scan) is a failed run, even when the
42
45
  session "worked." The gate applies to the harness's own error reports.
@@ -82,6 +85,7 @@ silently drifting from one is not.
82
85
  | Default | Why it is the default | Legitimate override |
83
86
  |---|---|---|
84
87
  | Dry-run | Spend safety (invariant 3 sets the floor; dry-run keeps the floor far away) | `scenario.mode: live` |
88
+ | Post-run analysis on supported live studies | Findings accompany the recording; a separate $3 admission estimate limit is visible before execution | `review.analysis: false` disables it; an explicit mapping sets another analysis budget. Dry-run and unsupported routes never dispatch; missing default credentials produce a recorded skip |
85
89
  | Per-lane worlds | Isolation, attribution, reproducibility | `subject.topology: shared-world` — N seats against ONE provisioned, mutable plane for scenarios that ARE about interaction between roles (#164). `execution.concurrency: 1` (an explicit choice) = SEQUENTIAL turns (one sandbox); higher = CONCURRENT — and since #350 an omitted concurrency fills to the seat count, so every declared seat runs live at once by default (one getHost-exposed subject sandbox + N actor sandboxes driving it at once, synthetic-subject only). The bundle declares the weaker `attributionClass: shared-world` + a verify-enforced `attributionLimits` ceiling (the concurrent set drops `sequential-only` and adds `best-effort-causal-attribution` etc.), so the looser per-role attribution is honest, not hidden. |
86
90
  | External key placement | Smallest blast radius: when the keyed process (e.g. a computer-use provider loop) runs outside the sandbox, its key never enters | In-sandbox placement when the keyed process runs inside (an agent harness under test); declared per actor type, with a spend budget |
87
91
  | Loopback entry URLs | Public-safety: never drive third-party sites unbidden | `policies.allowPublicTargets` for an owner-declared deployment/preview (a Vercel preview of your own app). Multi-lane public/preview fan-out needs explicit `actors[0].lanes[].target` for every lane, so the adapter-owned topology is declared rather than inferred. Provisioned clone subjects always serve in-sandbox on loopback |
@@ -1,8 +1,11 @@
1
1
  # Automatic study analysis
2
2
 
3
- A lab can request analysis after each live recording finishes. Findings remain
3
+ Supported live studies automatically request analysis after each recording finishes. Findings remain
4
4
  separate from participant feedback and the recorded study verdict.
5
5
 
6
+ The default is `gpt-6-astra` with high reasoning effort, a separate $3 admission
7
+ estimate limit, a 300-second timeout and 16,384 output tokens. To customize it:
8
+
6
9
  ```yaml
7
10
  review:
8
11
  analysis:
@@ -14,26 +17,37 @@ review:
14
17
  # question: Where did participants need to recover?
15
18
  ```
16
19
 
17
- Omit `review.analysis` to leave the existing run behavior unchanged. The budget
18
- is required when analysis is present. It limits an admission estimate, not the
20
+ Omitting `review.analysis` uses these defaults. Set `review.analysis: false` to
21
+ run participants without the additional analysis request. An explicit analysis
22
+ mapping requires `maxCostUsd`. This limits an admission estimate, not the
19
23
  provider's final bill, and is separate from participant spending limits. Analysis
20
24
  sends selected retained text and captures to OpenAI using `OPENAI_API_KEY`.
21
25
  Analysis runs in the Humanish runner using its credentials. This setting adds no
22
26
  credential channel to the target application; each participant backend retains
23
- its existing authentication boundary. Review a manifest's opt-in before running
24
- it live.
27
+ its existing authentication boundary. Review the separate analysis budget before running a manifest live; an actor's
28
+ zero-dollar cap does not cap post-run analysis. The bundled first-contact
29
+ zero-spend product fixture explicitly disables analysis.
25
30
 
26
31
  The same configuration works through `humanish run <lab>`, `lab run <lab>`,
27
32
  `watch <lab>`, and TUI live starts. Direct library calls to the five recording
28
33
  producers honor it too. Supported routes are computer-use, scripted-browser,
29
34
  terminal-product, sequential shared-world and concurrent shared-world. Synthetic,
30
- smoke and meta routes reject the setting before execution. Dry runs show analysis
35
+ smoke and meta routes never enable analysis by default and reject an explicit
36
+ analysis mapping before execution. `false` is accepted on every route. Dry runs show analysis
31
37
  as skipped, without reading analysis credentials or making a provider request.
32
38
 
33
39
  Participant execution finishes and its recording is finalized before analysis is
34
40
  queued. A participant who was blocked or interrupted can still have useful
35
41
  retained evidence; analysis requires a verified live recording, not a successful
36
42
  participant outcome. An active, missing or invalid recording is not analyzed.
43
+ Default analysis also skips recordings containing only setup or failure records
44
+ with no retained participant activity. A desktop startup failure does not start
45
+ an analysis request. The original failure remains visible.
46
+
47
+ CLI live starts disclose the separate admission estimate limit before execution.
48
+ `humanish lab preflight <lab> --json` and the TUI lab screen also expose the
49
+ resolved budget without dispatching analysis. Library callers can inspect
50
+ `resolveAutomaticAnalysis` or `automaticAnalysisBudget` before running.
37
51
 
38
52
  The command waits for analysis and reports its separate state. A TUI-launched
39
53
  runner continues after the TUI closes; reopening the TUI or Observer reads the
@@ -54,7 +68,11 @@ accepted. Known usage is retained; missing usage remains unknown.
54
68
 
55
69
  The CLI's JSON keeps `runOk` for the original backend result, `automaticAnalysis`
56
70
  for post-run analysis, and `ok` for the overall request. Failed, cancelled or
57
- unknown analysis produces exit code 2 without discarding the recording. Partial
71
+ unknown analysis produces exit code 2 without discarding the recording. A missing
72
+ `OPENAI_API_KEY` skips default analysis and preserves a successful run exit;
73
+ `automaticAnalysisTrigger: "default"` distinguishes that case in JSON. A missing
74
+ key for an explicitly configured analysis remains a failed overall request.
75
+ Either skip is retained for review and does not retry automatically. Partial
58
76
  findings remain visibly partial; a valid partial result can succeed, while a
59
77
  partial result with an analysis error still fails the command. Recorded task
60
78
  outcomes and the deterministic review verdict are never rewritten by analysis.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Status: public-safe contributor and agent ramp.
4
4
 
5
- Package/source version in this tree: `0.90.0` (2026-09-15). The Observer is phone-usable as a stated requirement (observer/AGENTS.md); interactive primitives start from Base UI. The Observer renderer is the observer/ workspace artifact only; the legacy string-concat renderer was deleted at cutover (#426), and rollback is a version pin to 0.42.0. The containment boundary introduced in
5
+ Package/source version in this tree: `0.91.0` (2026-09-15). The Observer is phone-usable as a stated requirement (observer/AGENTS.md); interactive primitives start from Base UI. The Observer renderer is the observer/ workspace artifact only; the legacy string-concat renderer was deleted at cutover (#426), and rollback is a version pin to 0.42.0. The containment boundary introduced in
6
6
  `0.15.1` remains in force: managed run and output paths bind to validated
7
7
  physical filesystem identities, and stored provider IDs are evidence, not
8
8
  cleanup authority. The bundled OSS meta-lab is dry-run only until
@@ -47,6 +47,11 @@ If a change does not improve one of those loops, it probably belongs elsewhere.
47
47
 
48
48
  ## Current State
49
49
 
50
+ The [0.91.0 release note](../release/0.91.0-analysis-quality-and-defaults.md)
51
+ describes automatic analysis by default on supported live recordings, its
52
+ separate disclosed budget and opt-out, fairer evidence selection, and
53
+ evidence-linked review of material concerns and exclusions.
54
+
50
55
  The [0.90.0 release note](../release/0.90.0-automatic-analysis.md) describes
51
56
  opt-in analysis after live runs, truthful job states, cancellation, and scripted
52
57
  captures and assignments in findings and playback.
@@ -99,7 +104,7 @@ Implemented:
99
104
 
100
105
  - `commander` CLI with stable command help;
101
106
  - `init`, `doctor`, `run`, `watch`, `verify`, `review`, `runs`, `analyze`, and `feedback`;
102
- - opt-in study analysis with bounded provider admission, immutable findings,
107
+ - study analysis with bounded provider admission, a live-run default and opt-out, immutable findings,
103
108
  source-bound corrections and evidence-linked Observer review;
104
109
  - synthetic run bundles;
105
110
  - public-safety verification with machine-readable `shareSafety.status`
@@ -0,0 +1,33 @@
1
+ # Humanish 0.91.0
2
+
3
+ Supported live studies now request analysis when the recording finishes, using
4
+ `gpt-6-astra` with high reasoning and a separate $3 admission estimate limit.
5
+ The CLI, preflight and TUI disclose that budget. Set `review.analysis: false` to
6
+ disable the extra request, or supply an analysis mapping with `maxCostUsd` to
7
+ customize it. The estimate is additional to participant and desktop costs and
8
+ is not a provider billing cap. Missing default credentials record a skip while
9
+ preserving a successful recording; explicit analysis failures remain failures.
10
+ Startup failures with no retained participant activity skip default analysis.
11
+
12
+ Analysis now reviews material participant concerns before ranking findings.
13
+ Useful reported uncertainty and recovered mistakes can remain findings even
14
+ when product fault is unproven. **Concerns considered** shows evidence-linked
15
+ decisions, including why material concerns were left out of the ranked list.
16
+ It is model assessment, separate from original participant feedback and human
17
+ reviewer annotations.
18
+
19
+ Evidence selection shares count and text budgets across participants and samples
20
+ their whole sessions, prioritizing beginnings, endings and context around
21
+ recorded failures. Original frame and event identities remain intact. Missing
22
+ assignments remain explicit; historical assignments are never invented.
23
+ Existing analysis versions remain readable and unchanged.
24
+
25
+ Selection is bounded and can still omit important moments. Concern review does
26
+ not certify exhaustive discovery or accurate causal diagnosis. Opening Observer,
27
+ exporting a recording and reading history never start a model request. Dry-runs
28
+ and unsupported default routes remain request-free, and examples advertised as
29
+ zero-spend explicitly disable automatic analysis.
30
+
31
+ See the [analysis contract](../contracts/study-analysis.md),
32
+ [automatic analysis guide](../product/automatic-analysis.md), and
33
+ [bounded evaluation receipt](https://github.com/danielgwilson/humanish/blob/main/docs/goals/computer-use-actor/receipts/analysis-quality-and-defaults-2026-09-15.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "humanish",
3
- "version": "0.90.0",
3
+ "version": "0.91.0",
4
4
  "description": "Open-source-safe CLI for persona simulation, observer review, and public-safe feedback drafts.",
5
5
  "author": "Daniel G Wilson <daniel@danielgwilson.com>",
6
6
  "keywords": [