toolroll 0.9.114 → 0.9.116

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 (96) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dist/agent-state-words.js +1 -1
  3. package/dist/assignment-ui.js +1 -1
  4. package/dist/browser/terminal.css +1 -1
  5. package/dist/browser/terminal.js +1 -1
  6. package/dist/browser/workspace.css +2 -2
  7. package/dist/browser/workspace.js +29 -28
  8. package/dist/chat-controls.js +1 -1
  9. package/dist/chat-quiet.js +2 -2
  10. package/dist/chat-voice.js +3 -3
  11. package/dist/check-levels.js +1 -1
  12. package/dist/claim.js +7 -2
  13. package/dist/cli.js +1 -0
  14. package/dist/code-map-cli.js +2 -1
  15. package/dist/coding-shipping-ui.js +2 -1
  16. package/dist/console-instance.js +21 -1
  17. package/dist/contracts/console-api.js +6 -2
  18. package/dist/contracts/engine-api.js +32 -4
  19. package/dist/demo-chat.js +1 -1
  20. package/dist/design/kit.css +3 -0
  21. package/dist/design/kit.js +1 -1
  22. package/dist/dispatch.js +19 -2
  23. package/dist/easy-start.js +23 -11
  24. package/dist/engine-reads.js +98 -7
  25. package/dist/export.js +16 -4
  26. package/dist/flexible-authority-end.js +94 -0
  27. package/dist/flexible-everyday-schema.js +76 -0
  28. package/dist/flexible-interactive-schema.js +133 -0
  29. package/dist/flexible-interactive.js +94 -0
  30. package/dist/flexible-laptop.js +38 -0
  31. package/dist/flexible-relay.js +9 -3
  32. package/dist/flexible-session.js +430 -10
  33. package/dist/flexible-ship.js +77 -12
  34. package/dist/flexible-sign-in.js +16 -1
  35. package/dist/flexible-start.js +17 -2
  36. package/dist/flexible-thread.js +1 -1
  37. package/dist/flexible-turns.js +9 -0
  38. package/dist/flexible-ui.js +3 -2
  39. package/dist/flexible.js +13 -0
  40. package/dist/flow-card-task.js +1 -1
  41. package/dist/home-groups.js +1 -1
  42. package/dist/lead-status.js +5 -3
  43. package/dist/lead-tools.js +1 -0
  44. package/dist/local-owner-acts.js +44 -1
  45. package/dist/local-owner.js +10 -0
  46. package/dist/needs-you.js +18 -6
  47. package/dist/operate-remote-arguments.js +1 -1
  48. package/dist/operate.js +250 -32
  49. package/dist/plan-problems-schema.js +4 -0
  50. package/dist/planner.js +17 -6
  51. package/dist/release-cli.js +2 -2
  52. package/dist/result-actions.js +1 -2
  53. package/dist/retention-ui.js +1 -1
  54. package/dist/scope.js +18 -7
  55. package/dist/server/chat.js +3 -3
  56. package/dist/server/console.css +15 -10
  57. package/dist/server/engine-api.js +161 -15
  58. package/dist/server/flows.js +4 -3
  59. package/dist/server/home.js +1 -1
  60. package/dist/server/kit.js +2 -2
  61. package/dist/server/render-chat.js +1 -1
  62. package/dist/server/render-pages.js +1 -1
  63. package/dist/server/render-tasks.js +21 -12
  64. package/dist/server/route-table.js +16 -0
  65. package/dist/server/settings-sections.js +6 -2
  66. package/dist/server/settings.js +22 -8
  67. package/dist/server/task-views.js +10 -4
  68. package/dist/server/tasks.js +51 -4
  69. package/dist/settings-kit.js +3 -3
  70. package/dist/skills-ui.js +3 -2
  71. package/dist/spend-report.js +2 -2
  72. package/dist/spend.js +3 -3
  73. package/dist/store.js +202 -7
  74. package/dist/subagent-admin.js +23 -10
  75. package/dist/subagent-backup-schema.js +36 -0
  76. package/dist/subagent-backup.js +92 -0
  77. package/dist/subagent-week.js +2 -2
  78. package/dist/subagent-work.js +70 -47
  79. package/dist/subagents-ui.js +6 -2
  80. package/dist/subagents.js +5 -2
  81. package/dist/subscription-chat.js +4 -0
  82. package/dist/surface.js +8 -1
  83. package/dist/task-status.js +13 -13
  84. package/dist/telegram-status.js +3 -3
  85. package/dist/terminal-safety.js +114 -0
  86. package/dist/toolroll-update.js +2 -1
  87. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  88. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  89. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  90. package/dist/tui/linux-x64/toolroll-tui +0 -0
  91. package/dist/tui-launch.js +20 -1
  92. package/dist/tui.js +1 -1
  93. package/dist/work-index.js +23 -10
  94. package/dist/workspace-ui.js +5 -5
  95. package/dist/youiyoux-intake.js +1 -1
  96. package/package.json +2 -2
package/dist/tui.js CHANGED
@@ -67,7 +67,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
67
67
  `))}patchConsole(){this.options.debug||(this.restoreConsole=_c((u,a)=>{u==="stdout"&&this.writeToStdout(a),u==="stderr"&&(a.startsWith("The above error occurred")||this.writeToStderr(a))}))}initKittyKeyboard(){if(!this.options.kittyKeyboard)return;let u=this.options.kittyKeyboard,a=u.mode??"auto";if(a==="disabled"||!this.options.stdin.isTTY||!this.options.stdout.isTTY)return;let l=u.flags??["disambiguateEscapeCodes"];if(a==="enabled"){this.enableKittyProtocol(l);return}let g=Ui.env.TERM??"",E=Ui.env.TERM_PROGRAM??"",s="KITTY_WINDOW_ID"in Ui.env||g==="xterm-kitty"||E==="WezTerm"||E==="ghostty";!Xe&&s&&this.confirmKittySupport(l)}confirmKittySupport(u){let{stdin:a,stdout:l}=this.options,g=[],E=()=>{this.cancelKittyDetection=void 0,clearTimeout(I),a.removeListener("data",s);let Q=Iy(g);g=[],Q.length>0&&a.unshift(Buffer.from(Q))},s=Q=>{let S=typeof Q=="string"?Buffer.from(Q):Q;for(let v of S)g.push(v);Cy(g)&&(E(),this.isUnmounted||this.enableKittyProtocol(u))};a.on("data",s);let I=setTimeout(E,200);this.cancelKittyDetection=E,l.write("\x1B[?u")}enableKittyProtocol(u){this.options.stdout.write(`\x1B[>${_Q(u)}u`),this.kittyProtocolEnabled=!0}};var fy=(e,u)=>{let a={stdout:Uo.stdout,stdin:Uo.stdin,stderr:Uo.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,maxFps:30,incrementalRendering:!1,concurrent:!1,...Dy(u)},l=dy(a.stdout,()=>new za(a),a.concurrent??!1);return l.render(e),{rerender:l.render,unmount(){l.unmount()},waitUntilExit:l.waitUntilExit,cleanup:()=>Hi.delete(a.stdout),clear:l.clear}},TE=fy,Dy=(e={})=>e instanceof Qy?{stdout:e,stdin:Uo.stdin}:e,dy=(e,u,a)=>{let l=Hi.get(e);return l?l.isConcurrent!==a&&console.warn(`Warning: render() was called with concurrent: ${a}, but the existing instance for this stdout uses concurrent: ${l.isConcurrent}. The concurrent option only takes effect on the first render. Call unmount() first if you need to change the rendering mode.`):(l=u(),Hi.set(e,l)),l};var py=oA(Zl(),1);var To=oA(SA(),1);var XQ=oA(SA(),1);var my=oA(SA(),1);var hy=oA(SA(),1);var LE=oA(SA(),1);import{Buffer as yy}from"node:buffer";var Sy=/^(?:\x1b)([a-zA-Z0-9])$/,Fy=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,jQ={OP:"f1",OQ:"f2",OR:"f3",OS:"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"},VQ=[...Object.values(jQ),"backspace"],Ny=e=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e),Ry=e=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e),WQ=/^\x1b\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,vy=/^\x1b\[(\d+);(\d+):(\d+)([A-Za-z~])$/,wy={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},Gy={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"},ZQ={27:"escape",9:"tab",127:"delete",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"},PQ=e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),bE=e=>PQ(e)?String.fromCodePoint(e):"?";function $Q(e){return e===3?"release":e===2?"repeat":"press"}function Af(e){return{ctrl:!!(e&Pe.ctrl),shift:!!(e&Pe.shift),meta:!!(e&Pe.meta),option:!!(e&Pe.alt),super:!!(e&Pe.super),hyper:!!(e&Pe.hyper),capsLock:!!(e&Pe.capsLock),numLock:!!(e&Pe.numLock)}}var My=e=>{let u=WQ.exec(e);if(!u)return null;let a=parseInt(u[1],10),l=u[2]?Math.max(0,parseInt(u[2],10)-1):0,g=u[3]?parseInt(u[3],10):1,E=u[4];if(!PQ(a))return null;let s;E&&(s=E.split(":").map(S=>bE(parseInt(S,10))).join(""));let I,Q;return a===32?(I="space",Q=!0):a===13?(I="return",Q=!0):ZQ[a]?(I=ZQ[a],Q=!1):a>=1&&a<=26?(I=String.fromCodePoint(a+96),Q=!1):(I=bE(a).toLowerCase(),Q=!0),Q&&!s&&(s=bE(a)),{name:I,...Af(l),eventType:$Q(g),sequence:e,raw:e,isKittyProtocol:!0,isPrintable:Q,text:s}},xy=e=>{let u=vy.exec(e);if(!u)return null;let a=parseInt(u[1],10),l=Math.max(0,parseInt(u[2],10)-1),g=parseInt(u[3],10),E=u[4],s=E==="~"?Gy[a]:wy[E];return s?{name:s,...Af(l),eventType:$Q(g),sequence:e,raw:e,isKittyProtocol:!0,isPrintable:!1}:null},Hy=(e="")=>{let u;yy.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e="\x1B"+String(e)):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");let a=My(e);if(a)return a;let l=xy(e);if(l)return l;if(WQ.test(e))return{name:"",ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e,isKittyProtocol:!0,isPrintable:!1};let g={name:"",ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e};if(g.sequence=g.sequence||e||g.name,e==="\r"||e==="\x1B\r")g.raw=void 0,g.name="return",g.option=e.length===2;else if(e===`
68
68
  `)g.name="enter";else if(e===" ")g.name="tab";else if(e==="\b"||e==="\x1B\b")g.name="backspace",g.meta=e.charAt(0)==="\x1B";else if(e===""||e==="\x1B")g.name="delete",g.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")g.name="escape",g.meta=e.length===2;else if(e===" "||e==="\x1B ")g.name="space",g.meta=e.length===2;else if(e.length===1&&e<="")g.name=String.fromCharCode(e.charCodeAt(0)+97-1),g.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")g.name="number";else if(e.length===1&&e>="a"&&e<="z")g.name=e;else if(e.length===1&&e>="A"&&e<="Z")g.name=e.toLowerCase(),g.shift=!0;else if(u=Sy.exec(e))g.meta=!0,g.shift=/^[A-Z]$/.test(u[1]);else if(u=Fy.exec(e)){let E=[...e];E[0]==="\x1B"&&E[1]==="\x1B"&&(g.option=!0);let s=[u[1],u[2],u[4],u[6]].filter(Boolean).join(""),I=(u[3]||u[5]||1)-1;g.ctrl=!!(I&4),g.meta=!!(I&10),g.shift=!!(I&1),g.code=s,g.name=jQ[s],g.shift=Ny(s)||g.shift,g.ctrl=Ry(s)||g.ctrl}return g},tf=Hy;var ef=oA(SA(),1);var Uy=()=>(0,ef.useContext)(Ro),bo=Uy;var Ty=(e,u={})=>{let{stdin:a,setRawMode:l,internal_exitOnCtrlC:g,internal_eventEmitter:E}=bo();(0,LE.useEffect)(()=>{if(u.isActive!==!1)return l(!0),()=>{l(!1)}},[u.isActive,l]),(0,LE.useEffect)(()=>{if(u.isActive===!1)return;let s=I=>{let Q=tf(I),S={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||Q.name==="escape"||Q.option,super:Q.super??!1,hyper:Q.hyper??!1,capsLock:Q.capsLock??!1,numLock:Q.numLock??!1,eventType:Q.eventType},v;Q.isKittyProtocol?Q.isPrintable?v=Q.text??Q.name:Q.ctrl&&Q.name.length===1?v=Q.name:v="":Q.ctrl?v=Q.name:v=Q.sequence,!Q.isKittyProtocol&&VQ.includes(Q.name)&&(v=""),v.startsWith("\x1B")&&(v=v.slice(1)),v.length===1&&typeof v[0]=="string"&&/[A-Z]/.test(v[0])&&(S.shift=!0),(!(v==="c"&&S.ctrl)||!g)&&de.batchedUpdates(()=>{e(v,S)})};return E?.on("input",s),()=>{E?.removeListener("input",s)}},[u.isActive,a,g,e])},OE=Ty;var nf=oA(SA(),1);var by=()=>(0,nf.useContext)(No),kE=by;var Ly=oA(SA(),1);var Oy=oA(SA(),1);var JE=oA(SA(),1);var ky=oA(SA(),1);var Jy=oA(SA(),1);var Lo=oA(SA(),1);import{pathToFileURL as A2}from"node:url";var Ky=["[data-ink-approve]",'[data-ink-act="accept"]',"[data-accept-result][data-primary-action]"],Yy=['[data-act="request-changes"]','[data-act="revise"]','a.result-feedback-link[href="#request-changes"]'],_y=['[data-act="retry"]','form[data-retry] button[type="submit"]','form[data-rebuild] button[type="submit"]'],zy=['form[action$="/plan"] button[type="submit"]'],KE=[{keys:"n",says:"new task",web:{kind:"go",href:"/tasks/new"},tui:"new"},{keys:"a",says:"Approve or Accept (presses the button on the page)",web:{kind:"press",selectors:Ky},tui:"ink"},{keys:"b",says:"Send back (opens its note)",web:{kind:"press",selectors:Yy},tui:"send-back"},{keys:"r",says:"Retry (presses the button on the page)",web:{kind:"press",selectors:_y},tui:"retry"},{keys:"p",says:"Ask for a plan (presses the button on the page)",web:{kind:"press",selectors:zy},tui:"plan"},{keys:"/",says:"search",web:{kind:"search"},tui:{none:"The terminal has no search; press w to open the console."}},{keys:"g h",says:"go Home",web:{kind:"go",href:"/"},tui:"list"},{keys:"g t",says:"go to Work",web:{kind:"go",href:"/"},tui:"list"},{keys:"?",says:"these shortcuts",web:{kind:"help"},tui:"help"}],uf=e=>e.split(" ").join(" then ");var jA=oA(SA(),1);var qy=/[‪-‮⁦-⁩]/g;function Xy(e){return e.replace(/(?:\x1b\[|\u009b)[0-?]*[ -/]*[@-~]/g,"").replace(/(?:\x1b\]|\u009d)[^\x07\x1b\u009c]*(?:\x07|\x1b\\|\u009c)?/g,"").replace(/\x1b[ -/]*[0-~]/g,"").replace(/\t/g," ").replace(/[\x00-\x1f\x7f-\x9f]/g,"").replace(new RegExp("\\p{Cf}","gu"),"").replace(qy,"")}function af(e){return e.split(`
69
69
  `).map(Xy).join(`
70
- `)}var YE=["you","working","done"],lf={you:"Waiting on you",working:"Working",done:"Done"};var L=oA(qa(),1);function NA({children:e,...u}){return(0,L.jsx)(eA,{...u,children:af(e)})}var Vy={new:"new task",ink:"approve the plan (shows it in full first)","send-back":"send the result back",retry:"retry",plan:"ask for a plan",list:"back to the task list",help:"these keys"},Wy=["j / k or ↑ / ↓ move","Enter open the task",...[...KE.filter(e=>typeof e.tui=="string").reduce((e,u)=>e.set(u.tui,[...e.get(u.tui)??[],uf(u.keys)]),new Map)].flatMap(([e,u])=>[`${u.join(", ").padEnd(15)} ${Vy[e]}`,...e==="ink"?["c accept the result (shows it first)"]:[]]),"s stop the running attempt","1–9 answer the task's question","w open in the browser","Esc back","q quit"];function Py(e){let u=a=>a.group===null?YE.length:YE.indexOf(a.group);return e.map((a,l)=>({row:a,index:l})).sort((a,l)=>u(a.row)-u(l.row)||a.index-l.index).map(a=>a.row)}var $y=e=>e.group===null?"Other":lf[e.group];function Ef(e,u){return!u||e.status!=="Planning"&&e.status!=="Building"?e:{...e,status:"Waiting",detail:"Toolroll's background worker isn't running.",liveRunId:null}}var sf=e=>[...e].filter(u=>u>=" "&&u!=="").join("");function Bf({source:e,session:u,onExit:a,pollMs:l=1e3}){let{exit:g}=kE(),[E,s]=(0,jA.useState)(null),[I,Q]=(0,jA.useState)(null),[S,v]=(0,jA.useState)(0),[N,p]=(0,jA.useState)({kind:"main"}),[M,U]=(0,jA.useState)(null),[O,H]=(0,jA.useState)(null),[W,FA]=(0,jA.useState)([]),[dA,EA]=(0,jA.useState)(()=>u.stopped?.()??null),GA=(0,jA.useRef)(null),kA=(0,jA.useRef)(0),JA=(0,jA.useRef)(!1),HA=Py(E?.rows??[]).map(y=>Ef(y,dA!==null)),TA=HA[Math.min(S,Math.max(HA.length-1,0))],It=(0,jA.useCallback)(async()=>{let y=await e.snapshot();s(y),y.rows.length===0&&Q(await e.setup())},[e]);(0,jA.useEffect)(()=>{It()},[It]),(0,jA.useEffect)(()=>{let y=setInterval(()=>{let G=u.stopped?.()??null;EA(P=>P===G?P:G),kA.current+=1;let K=e.changed();(K!==GA.current||kA.current%5===0)&&(GA.current=K,It())},l);return()=>clearInterval(y)},[e,u,It,l]);let kt=TA?.id??null;(0,jA.useEffect)(()=>{if(kt===null){FA([]);return}FA(e.live(kt));let y=setInterval(()=>FA(e.live(kt)),l);return()=>clearInterval(y)},[e,kt,l]);let Qt=y=>{JA.current||(JA.current=!0,g(),a?.(y))},vt=(0,jA.useRef)(!1),bA=async(y,G="Working…")=>{H(G);try{let K=await e.act(y);return K.ok?(U(K.message),await It(),!0):(K.needsPassword?p({kind:"password",message:K.message}):U(K.message),!1)}finally{H(null)}},ft=async(y,G)=>{let K=await e.task(y);K===null?U("That task can't be read now."):G(K)},Jt=y=>ft(y,G=>{G.plan===null?U("No plan is waiting for your approval on this task."):p({kind:"approve",task:G})}),bt=async(y,G=!1)=>{let K=await e.result(y);if(K===null){U("This task has no finished result to accept.");return}p({kind:"accept",result:K,reason:"",changed:G})},vA=y=>ft(y,G=>{G.plan!==null?p({kind:"approve",task:G}):G.hasResult?bt(y):U("No plan or result is waiting for you on this task.")}),Dt=async(y,G,K)=>{H("Working…");let P;try{P=await e.act({kind:"complete",id:y.id,runId:y.runId,digest:y.digest,checked:G,reason:K})}finally{H(null)}if(P.ok){U(P.message),p(u.shouldAskBackground()?{kind:"background"}:{kind:"main"}),await It();return}if(P.changed===!0){p({kind:"main"}),U("This result changed while you were reading it. Nothing was accepted."),await bt(y.id,!0);return}P.needsPassword?p({kind:"password",message:P.message}):(U(P.message),p({kind:"main"}))},Ue=async y=>{let G=await e.result(y);if(G===null){U("This task has no finished result to send back.");return}p({kind:"compose",purpose:"revise",id:y,text:"",project:0,runId:G.runId})},Te=y=>ft(y,G=>{G.retry==null?U("Nothing to retry on this task."):p({kind:"retry",task:G,retry:G.retry})}),ae=y=>ft(y,G=>{G.planAsk==null?U("This task can't be planned now."):bA({kind:"plan",id:y,source:G.planAsk.source})}),be=(y,G)=>{if(G===null){U("Nothing is running on this task.");return}bA({kind:"stop",id:y,runId:G})},Zt=(y,G)=>{let K=y.decisions[0],P=K?.options[G];K===void 0||P===void 0||bA({kind:"answer",decision:K.id,option:P.id}).then(MA=>{MA&&p({kind:"main"})})},VA=()=>{H("Opening the browser…"),u.openBrowser().then(y=>{U(y),H(null)})},le=()=>{u.owned()?p({kind:"quit"}):Qt("leave")},Kt=(y,G,K)=>{if(vt.current&&(vt.current=!1,y==="h"||y==="t"))return p({kind:"main"}),!0;if(y==="g")return vt.current=!0,!0;if(y==="/"){let P=KE.find(MA=>MA.keys==="/").tui;return U(typeof P=="string"?null:P.none),!0}return y==="n"?(p({kind:"compose",purpose:"new",id:null,text:"",project:0,runId:null}),!0):y==="w"?(VA(),!0):y==="?"?(p({kind:"help"}),!0):y==="q"?(le(),!0):G===null?!1:y==="a"?(vA(G),!0):y==="s"?(be(G,K),!0):y==="b"?(Ue(G),!0):y==="r"?(Te(G),!0):y==="c"?(bt(G),!0):y==="p"?(ae(G),!0):!1},it=(y,G)=>{if(O===null){if(G.ctrl&&y==="c"){le();return}switch(N.kind){case"main":{if(y==="j"||G.downArrow){v(K=>Math.min(K+1,Math.max(HA.length-1,0)));return}if(y==="k"||G.upArrow){v(K=>Math.max(K-1,0));return}if(G.return&&TA!==void 0){ft(TA.id,K=>p({kind:"task",task:K}));return}if(G.escape){U(null);return}if(y==="s"&&HA.length===0&&I?.sample===!0){bA({kind:"sample"},"Adding the sample project…");return}Kt(y,TA?.id??null,TA?.liveRunId??null);return}case"task":{if(G.escape||G.leftArrow){p({kind:"main"});return}if(/^[1-9]$/.test(y)){Zt(N.task,Number(y)-1);return}Kt(y,N.task.id,N.task.liveRunId);return}case"approve":{if(G.escape||y==="n"){p({kind:"main"}),U("Nothing approved.");return}if(y==="y"){let{task:K}=N;bA({kind:"approve",id:K.id,digest:K.plan.digest,...K.plan.terms===void 0?{}:{terms:K.plan.terms}}).then(P=>{P&&p({kind:"main"})})}return}case"retry":{if(G.escape||y==="n"){p({kind:"main"}),U("Nothing retried.");return}if(y==="y"){let{task:K,retry:P}=N;bA({kind:"retry",id:K.id,runId:P.runId,digest:P.digest}).then(()=>p(MA=>MA.kind==="retry"?{kind:"main"}:MA))}return}case"accept":{let{result:K}=N,P=()=>{p({kind:"main"}),U("Nothing accepted.")};if(G.escape){P();return}if(!K.ready||K.owed!=="exception"){if(y==="w"){VA();return}if(!K.ready){(y==="n"||y==="q")&&P();return}if(y==="n"){P();return}y==="y"&&Dt(K,K.owed==="person-check",null);return}if(G.backspace||G.delete){p({...N,reason:N.reason.slice(0,-1)});return}if(G.return){let tt=N.reason.trim();tt!==""&&Dt(K,!1,tt);return}let MA=sf(y);MA!==""&&p({...N,reason:N.reason+MA});return}case"build":{if(G.escape){p({kind:"main"}),U("Nothing started.");return}if(y==="p"){let{text:K,repo:P}=N;p({kind:"main"}),bA({kind:"new",text:K,repo:P});return}if(G.return){let{preview:K,digest:P}=N.terms;bA({kind:"build",preview:K,digest:P}).then(MA=>{MA&&p({kind:"main"})})}return}case"compose":{if(G.escape){p({kind:"main"});return}let K=E?.projects??[];if(G.tab&&N.purpose==="new"&&K.length>1){p({...N,project:(N.project+1)%K.length});return}if(G.backspace||G.delete){p({...N,text:N.text.slice(0,-1)});return}if(G.return){let MA=N.text.trim();if(MA==="")return;let tt=N.purpose==="new"?{kind:"new",text:MA,repo:K[N.project]??null}:{kind:"revise",id:N.id,text:MA,runId:N.runId};if(p({kind:"main"}),tt.kind==="new"){H("Reading it…"),e.fastTerms(MA,tt.repo).catch(()=>null).then(Vt=>{H(null),Vt===null?bA(tt):p({kind:"build",terms:Vt,text:MA,repo:tt.repo})});return}bA(tt);return}let P=sf(y);P!==""&&p({...N,text:N.text+P});return}case"quit":{y==="s"?Qt("stop"):y==="b"?Qt("keep"):G.escape&&p({kind:"main"});return}case"background":{let K=y==="y"||y==="Y";if(!K&&y!=="n"&&y!=="N"&&!G.return)return;p({kind:"main"}),H(K?"Moving Toolroll to the background…":"Saving…"),u.answerBackground(K).then(P=>{U(P),H(null)});return}default:(G.escape||G.return||y==="q")&&p({kind:"main"})}}},aA=(0,jA.useRef)(it);aA.current=it,OE((0,jA.useCallback)((y,G)=>aA.current(y,G),[]));let jt=O??dA??M;return(0,L.jsxs)(CA,{flexDirection:"column",children:[(0,L.jsxs)(CA,{justifyContent:"space-between",children:[(0,L.jsx)(eA,{bold:!0,children:"Toolroll"}),E?.needsYou?(0,L.jsx)(NA,{bold:!0,children:E.needsYou}):(0,L.jsx)(eA,{dimColor:!0,children:"Nothing needs you"}),E?.learning?(0,L.jsx)(NA,{dimColor:!0,children:E.learning}):null]}),lA(),jt===null?null:(0,L.jsx)(NA,{...O===null&&dA!==null?{bold:!0}:{},children:jt}),(0,L.jsx)(eA,{dimColor:!0,children:V()})]});function V(){switch(N.kind){case"main":return HA.length===0?`${I?.sample===!0?"s sample project · ":""}n new task · w browser · ? help · q quit`:"j/k move · Enter open · n new · a approve/accept · b send back · r retry · p plan · s stop · w browser · ? help · q quit";case"task":return`a approve/accept · b send back · r retry${N.task.planAsk==null?"":" · p plan it"} · s stop · 1–9 answer · w browser · Esc back`;case"approve":return"y approve · Esc cancel";case"retry":return"y retry · Esc cancel";case"accept":return N.result.ready?N.result.owed==="person-check"?"y yes, it looks right · n no · w open in the browser · Esc cancel":N.result.owed==="exception"?"Enter accept · Esc cancel":"y accept · w open in the browser · Esc cancel":"w open in the browser · Esc back";case"build":return"Enter Build · p plan it first · Esc cancel";case"compose":return N.purpose==="new"&&(E?.projects.length??0)>1?"Enter send · Tab project · Esc cancel":"Enter send · Esc cancel";case"quit":return"s stop · b background · Esc cancel";case"background":return"y yes · n no";default:return"Esc back"}}function lA(){switch(N.kind){case"help":return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(eA,{bold:!0,children:"Keys"}),Wy.map(y=>(0,L.jsx)(eA,{children:y},y))]});case"password":return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(eA,{bold:!0,children:"This needs your password"}),(0,L.jsx)(NA,{children:N.message}),E?.passwordSet?(0,L.jsx)(eA,{children:"Sign in in the browser, then do it there."}):(0,L.jsx)(eA,{children:"Set a password: run `toolroll password set`"})]});case"quit":return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(eA,{bold:!0,children:"Quit Toolroll?"}),(0,L.jsx)(eA,{children:"s Stop agents and quit (running work is saved)"}),(0,L.jsx)(eA,{children:"b Keep running, and start when you log in"})]});case"background":return(0,L.jsx)(CA,{borderStyle:"single",paddingX:1,children:(0,L.jsx)(eA,{bold:!0,children:"Start Toolroll when you log in, so tasks keep going? (y/N)"})});case"build":return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(eA,{bold:!0,children:"Build approves exactly this:"}),N.terms.terms.map((y,G)=>(0,L.jsx)(NA,{children:`${y.label}: ${y.words}`},G))]});case"compose":{let y=E?.projects[N.project]??null;return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[(0,L.jsx)(eA,{bold:!0,children:N.purpose==="new"?"New task":"What should change?"}),N.purpose==="new"&&y!==null?(0,L.jsx)(NA,{dimColor:!0,children:`In ${y}`}):null,(0,L.jsxs)(eA,{children:[(0,L.jsx)(NA,{children:N.text}),(0,L.jsx)(eA,{inverse:!0,children:" "})]})]})}case"accept":{let{result:y}=N;return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(NA,{bold:!0,children:`Accept this result? ${y.title}`}),(0,L.jsx)(NA,{dimColor:!0,children:`Build #${y.runId}`}),N.changed?(0,L.jsx)(eA,{bold:!0,children:"This result changed while you were reading it. This is the new one."}):null,y.summary.length===0?null:(0,L.jsx)(CA,{flexDirection:"column",marginTop:1,children:y.summary.map((G,K)=>(0,L.jsx)(NA,{children:G},K))}),(0,L.jsxs)(CA,{flexDirection:"column",marginTop:1,children:[(0,L.jsx)(eA,{bold:!0,children:"Changed files"}),y.files===null?(0,L.jsx)(eA,{children:"The changed files couldn't be read. Press w to see them in the browser."}):y.files.names.length===0?(0,L.jsx)(eA,{children:"None."}):(0,L.jsxs)(L.Fragment,{children:[y.files.names.map(G=>(0,L.jsx)(NA,{children:` ${G}`},G)),y.files.more>0?(0,L.jsx)(eA,{children:` and ${y.files.more} more`}):null]})]}),y.requirements.length===0?null:(0,L.jsxs)(CA,{flexDirection:"column",marginTop:1,children:[(0,L.jsx)(eA,{bold:!0,children:"Requirements"}),y.requirements.map((G,K)=>(0,L.jsx)(NA,{children:` ${G.word}: ${G.statement}`},K))]}),y.checks.length===0?null:(0,L.jsx)(CA,{flexDirection:"column",marginTop:1,children:y.checks.map((G,K)=>(0,L.jsx)(NA,{...K===0?{bold:!0}:{},children:G},K))}),(0,L.jsx)(CA,{flexDirection:"column",marginTop:1,children:y.ready?y.owed==="person-check"?(0,L.jsx)(eA,{bold:!0,children:"Did you check it yourself? (y/n)"}):y.owed==="exception"?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(eA,{bold:!0,children:"Say why you accept it anyway:"}),(0,L.jsxs)(eA,{children:[(0,L.jsx)(NA,{children:N.reason}),(0,L.jsx)(eA,{inverse:!0,children:" "})]})]}):(0,L.jsx)(eA,{bold:!0,children:"Accept it and mark the task done? (y/n)"}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(eA,{bold:!0,children:"You can't accept it yet."}),y.blockers.map((G,K)=>(0,L.jsx)(NA,{children:G},K))]})})]})}case"retry":return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(NA,{bold:!0,children:`Retry build #${N.retry.runId}? ${N.task.title}`}),(0,L.jsx)(eA,{children:"Same plan, same agent. Its branch and workspace are kept."})]});case"approve":return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(NA,{bold:!0,children:`Approve this plan? ${N.task.title}`}),N.task.plan.lines.map((y,G)=>(0,L.jsx)(NA,{children:y},G))]});case"task":{let y=Ef(N.task,dA!==null),G=y.decisions[0];return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(NA,{bold:!0,children:y.title}),(0,L.jsx)(NA,{children:`${y.status}${y.detail===""?"":` · ${y.detail}`}`}),y.plan===null?null:(0,L.jsx)(eA,{children:"A plan waits for your approval (a)."}),(y.ready?.length??0)===0?null:(0,L.jsx)(CA,{flexDirection:"column",marginTop:1,children:y.ready.map((K,P)=>(0,L.jsx)(NA,{...P===0?{bold:!0}:{},children:K},P))}),G===void 0?null:(0,L.jsxs)(CA,{flexDirection:"column",marginTop:1,children:[(0,L.jsx)(NA,{bold:!0,children:G.question}),G.options.map((K,P)=>(0,L.jsx)(NA,{children:`${P+1} ${K.label}`},K.id))]}),W.length===0?null:(0,L.jsx)(CA,{flexDirection:"column",marginTop:1,children:W.slice(-12).map((K,P)=>(0,L.jsx)(NA,{dimColor:!0,children:K},P))})]})}default:return E===null?(0,L.jsx)(eA,{dimColor:!0,children:"Loading…"}):HA.length===0?(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(eA,{bold:!0,children:"Get to your first result"}),(I?.lines??["No tasks yet. Press n to write one."]).map((y,G)=>(0,L.jsx)(NA,{children:y},G))]}):(0,L.jsxs)(CA,{children:[(0,L.jsx)(CA,{flexDirection:"column",width:"45%",borderStyle:"single",paddingX:1,children:HA.map((y,G)=>(0,L.jsxs)(jA.Fragment,{children:[G===0||HA[G-1].group!==y.group?(0,L.jsx)(eA,{bold:!0,children:$y(y)}):null,(0,L.jsxs)(eA,{inverse:y===TA,wrap:"truncate-end",children:[y===TA?"> ":" ",(0,L.jsx)(NA,{children:y.title})," ",(0,L.jsx)(NA,{...y.needsYou?{bold:!0}:{dimColor:!0},children:y.status})]})]},y.id))}),(0,L.jsx)(CA,{flexDirection:"column",flexGrow:1,borderStyle:"single",paddingX:1,children:TA===void 0?(0,L.jsx)(eA,{dimColor:!0,children:"Nothing selected"}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(NA,{bold:!0,wrap:"truncate-end",children:TA.title}),(0,L.jsx)(NA,{children:`${TA.status}${TA.detail===""?"":` · ${TA.detail}`}`}),W.length===0?(0,L.jsx)(eA,{dimColor:!0,children:TA.liveRunId===null?"No agent is working on it now.":"Waiting for output…"}):W.slice(-12).map((y,G)=>(0,L.jsx)(NA,{dimColor:!0,wrap:"truncate-end",children:y},G))]})})]})}}}function cf(){let e=[{id:"t3",title:"Sample: upgrade the test runner",status:"Needs you",detail:"Plan ready to approve",needsYou:!0,liveRunId:null,repo:null,group:"you"},{id:"t1",title:"Sample: fix the login redirect",status:"Running",detail:"Sample task (not real)",needsYou:!1,liveRunId:1,repo:null,group:"working"},{id:"t2",title:"Sample: add CSV export",status:"Complete",detail:"Sample task (not real)",needsYou:!1,liveRunId:null,repo:null,group:"done"}];return{fastTerms:async()=>null,snapshot:async()=>({rows:e,needsYou:"1 task needs you: Sample: upgrade the test runner",projects:[],passwordSet:!1}),task:async u=>{let a=e.find(g=>g.id===u);return a===void 0?null:{id:u,title:a.title,status:a.status,detail:a.detail,liveRunId:a.liveRunId,hasResult:a.status==="Complete",decisions:[],plan:a.needsYou?{digest:"sample",lines:["Goal: upgrade the test runner (sample)"]}:null}},live:u=>u==="t1"?["Editing src/auth.ts (sample)"]:[],changed:()=>0,act:async()=>({ok:!1,message:"This is a sample: nothing changes.",needsPassword:!1}),result:async u=>u!=="t2"?null:{id:u,runId:2,digest:"sample",title:"Sample: add CSV export",ready:!0,blockers:[],summary:["Added a CSV export button to the orders page (sample)."],files:{names:["src/export.ts (sample)"],more:0},requirements:[{word:"You check",statement:"The CSV opens in a spreadsheet (sample)."}],checks:["Sample: checks are not real here."],owed:"person-check"},setup:async()=>null}}function Cf(){return{owned:()=>!1,openBrowser:async()=>"This is a sample.",shouldAskBackground:()=>!1,answerBackground:async()=>"This is a sample."}}var Qf=oA(qa(),1);async function t2(e=cf(),u=Cf()){if(!process.stdin.isTTY||!process.stdout.isTTY)throw new Error("The terminal UI needs an interactive terminal.");let a="leave";return await TE((0,Qf.jsx)(Bf,{source:e,session:u,onExit:g=>{a=g}}),{exitOnCtrlC:!1}).waitUntilExit(),a}var If=process.argv[1];If!==void 0&&import.meta.url===A2(If).href&&t2().catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
70
+ `)}var YE=["you","working","done"],lf={you:"Waiting on you",working:"Working",done:"Complete"};var L=oA(qa(),1);function NA({children:e,...u}){return(0,L.jsx)(eA,{...u,children:af(e)})}var Vy={new:"new task",ink:"approve the plan (shows it in full first)","send-back":"send the result back",retry:"retry",plan:"ask for a plan",list:"back to the task list",help:"these keys"},Wy=["j / k or ↑ / ↓ move","Enter open the task",...[...KE.filter(e=>typeof e.tui=="string").reduce((e,u)=>e.set(u.tui,[...e.get(u.tui)??[],uf(u.keys)]),new Map)].flatMap(([e,u])=>[`${u.join(", ").padEnd(15)} ${Vy[e]}`,...e==="ink"?["c accept the result (shows it first)"]:[]]),"s stop the running attempt","1–9 answer the task's question","w open in the browser","Esc back","q quit"];function Py(e){let u=a=>a.group===null?YE.length:YE.indexOf(a.group);return e.map((a,l)=>({row:a,index:l})).sort((a,l)=>u(a.row)-u(l.row)||a.index-l.index).map(a=>a.row)}var $y=e=>e.group===null?"Other":lf[e.group];function Ef(e,u){return!u||e.status!=="Planning"&&e.status!=="Building"?e:{...e,status:"Waiting",detail:"Toolroll's background worker isn't running.",liveRunId:null}}var sf=e=>[...e].filter(u=>u>=" "&&u!=="").join("");function Bf({source:e,session:u,onExit:a,pollMs:l=1e3}){let{exit:g}=kE(),[E,s]=(0,jA.useState)(null),[I,Q]=(0,jA.useState)(null),[S,v]=(0,jA.useState)(0),[N,p]=(0,jA.useState)({kind:"main"}),[M,U]=(0,jA.useState)(null),[O,H]=(0,jA.useState)(null),[W,FA]=(0,jA.useState)([]),[dA,EA]=(0,jA.useState)(()=>u.stopped?.()??null),GA=(0,jA.useRef)(null),kA=(0,jA.useRef)(0),JA=(0,jA.useRef)(!1),HA=Py(E?.rows??[]).map(y=>Ef(y,dA!==null)),TA=HA[Math.min(S,Math.max(HA.length-1,0))],It=(0,jA.useCallback)(async()=>{let y=await e.snapshot();s(y),y.rows.length===0&&Q(await e.setup())},[e]);(0,jA.useEffect)(()=>{It()},[It]),(0,jA.useEffect)(()=>{let y=setInterval(()=>{let G=u.stopped?.()??null;EA(P=>P===G?P:G),kA.current+=1;let K=e.changed();(K!==GA.current||kA.current%5===0)&&(GA.current=K,It())},l);return()=>clearInterval(y)},[e,u,It,l]);let kt=TA?.id??null;(0,jA.useEffect)(()=>{if(kt===null){FA([]);return}FA(e.live(kt));let y=setInterval(()=>FA(e.live(kt)),l);return()=>clearInterval(y)},[e,kt,l]);let Qt=y=>{JA.current||(JA.current=!0,g(),a?.(y))},vt=(0,jA.useRef)(!1),bA=async(y,G="Working…")=>{H(G);try{let K=await e.act(y);return K.ok?(U(K.message),await It(),!0):(K.needsPassword?p({kind:"password",message:K.message}):U(K.message),!1)}finally{H(null)}},ft=async(y,G)=>{let K=await e.task(y);K===null?U("That task can't be read now."):G(K)},Jt=y=>ft(y,G=>{G.plan===null?U("No plan is waiting for your approval on this task."):p({kind:"approve",task:G})}),bt=async(y,G=!1)=>{let K=await e.result(y);if(K===null){U("This task has no finished result to accept.");return}p({kind:"accept",result:K,reason:"",changed:G})},vA=y=>ft(y,G=>{G.plan!==null?p({kind:"approve",task:G}):G.hasResult?bt(y):U("No plan or result is waiting for you on this task.")}),Dt=async(y,G,K)=>{H("Working…");let P;try{P=await e.act({kind:"complete",id:y.id,runId:y.runId,digest:y.digest,checked:G,reason:K})}finally{H(null)}if(P.ok){U(P.message),p(u.shouldAskBackground()?{kind:"background"}:{kind:"main"}),await It();return}if(P.changed===!0){p({kind:"main"}),U("This result changed while you were reading it. Nothing was accepted."),await bt(y.id,!0);return}P.needsPassword?p({kind:"password",message:P.message}):(U(P.message),p({kind:"main"}))},Ue=async y=>{let G=await e.result(y);if(G===null){U("This task has no finished result to send back.");return}p({kind:"compose",purpose:"revise",id:y,text:"",project:0,runId:G.runId})},Te=y=>ft(y,G=>{G.retry==null?U("Nothing to retry on this task."):p({kind:"retry",task:G,retry:G.retry})}),ae=y=>ft(y,G=>{G.planAsk==null?U("This task can't be planned now."):bA({kind:"plan",id:y,source:G.planAsk.source})}),be=(y,G)=>{if(G===null){U("Nothing is running on this task.");return}bA({kind:"stop",id:y,runId:G})},Zt=(y,G)=>{let K=y.decisions[0],P=K?.options[G];K===void 0||P===void 0||bA({kind:"answer",decision:K.id,option:P.id}).then(MA=>{MA&&p({kind:"main"})})},VA=()=>{H("Opening the browser…"),u.openBrowser().then(y=>{U(y),H(null)})},le=()=>{u.owned()?p({kind:"quit"}):Qt("leave")},Kt=(y,G,K)=>{if(vt.current&&(vt.current=!1,y==="h"||y==="t"))return p({kind:"main"}),!0;if(y==="g")return vt.current=!0,!0;if(y==="/"){let P=KE.find(MA=>MA.keys==="/").tui;return U(typeof P=="string"?null:P.none),!0}return y==="n"?(p({kind:"compose",purpose:"new",id:null,text:"",project:0,runId:null}),!0):y==="w"?(VA(),!0):y==="?"?(p({kind:"help"}),!0):y==="q"?(le(),!0):G===null?!1:y==="a"?(vA(G),!0):y==="s"?(be(G,K),!0):y==="b"?(Ue(G),!0):y==="r"?(Te(G),!0):y==="c"?(bt(G),!0):y==="p"?(ae(G),!0):!1},it=(y,G)=>{if(O===null){if(G.ctrl&&y==="c"){le();return}switch(N.kind){case"main":{if(y==="j"||G.downArrow){v(K=>Math.min(K+1,Math.max(HA.length-1,0)));return}if(y==="k"||G.upArrow){v(K=>Math.max(K-1,0));return}if(G.return&&TA!==void 0){ft(TA.id,K=>p({kind:"task",task:K}));return}if(G.escape){U(null);return}if(y==="s"&&HA.length===0&&I?.sample===!0){bA({kind:"sample"},"Adding the sample project…");return}Kt(y,TA?.id??null,TA?.liveRunId??null);return}case"task":{if(G.escape||G.leftArrow){p({kind:"main"});return}if(/^[1-9]$/.test(y)){Zt(N.task,Number(y)-1);return}Kt(y,N.task.id,N.task.liveRunId);return}case"approve":{if(G.escape||y==="n"){p({kind:"main"}),U("Nothing approved.");return}if(y==="y"){let{task:K}=N;bA({kind:"approve",id:K.id,digest:K.plan.digest,...K.plan.terms===void 0?{}:{terms:K.plan.terms}}).then(P=>{P&&p({kind:"main"})})}return}case"retry":{if(G.escape||y==="n"){p({kind:"main"}),U("Nothing retried.");return}if(y==="y"){let{task:K,retry:P}=N;bA({kind:"retry",id:K.id,runId:P.runId,digest:P.digest}).then(()=>p(MA=>MA.kind==="retry"?{kind:"main"}:MA))}return}case"accept":{let{result:K}=N,P=()=>{p({kind:"main"}),U("Nothing accepted.")};if(G.escape){P();return}if(!K.ready||K.owed!=="exception"){if(y==="w"){VA();return}if(!K.ready){(y==="n"||y==="q")&&P();return}if(y==="n"){P();return}y==="y"&&Dt(K,K.owed==="person-check",null);return}if(G.backspace||G.delete){p({...N,reason:N.reason.slice(0,-1)});return}if(G.return){let tt=N.reason.trim();tt!==""&&Dt(K,!1,tt);return}let MA=sf(y);MA!==""&&p({...N,reason:N.reason+MA});return}case"build":{if(G.escape){p({kind:"main"}),U("Nothing started.");return}if(y==="p"){let{text:K,repo:P}=N;p({kind:"main"}),bA({kind:"new",text:K,repo:P});return}if(G.return){let{preview:K,digest:P}=N.terms;bA({kind:"build",preview:K,digest:P}).then(MA=>{MA&&p({kind:"main"})})}return}case"compose":{if(G.escape){p({kind:"main"});return}let K=E?.projects??[];if(G.tab&&N.purpose==="new"&&K.length>1){p({...N,project:(N.project+1)%K.length});return}if(G.backspace||G.delete){p({...N,text:N.text.slice(0,-1)});return}if(G.return){let MA=N.text.trim();if(MA==="")return;let tt=N.purpose==="new"?{kind:"new",text:MA,repo:K[N.project]??null}:{kind:"revise",id:N.id,text:MA,runId:N.runId};if(p({kind:"main"}),tt.kind==="new"){H("Reading it…"),e.fastTerms(MA,tt.repo).catch(()=>null).then(Vt=>{H(null),Vt===null?bA(tt):p({kind:"build",terms:Vt,text:MA,repo:tt.repo})});return}bA(tt);return}let P=sf(y);P!==""&&p({...N,text:N.text+P});return}case"quit":{y==="s"?Qt("stop"):y==="b"?Qt("keep"):G.escape&&p({kind:"main"});return}case"background":{let K=y==="y"||y==="Y";if(!K&&y!=="n"&&y!=="N"&&!G.return)return;p({kind:"main"}),H(K?"Moving Toolroll to the background…":"Saving…"),u.answerBackground(K).then(P=>{U(P),H(null)});return}default:(G.escape||G.return||y==="q")&&p({kind:"main"})}}},aA=(0,jA.useRef)(it);aA.current=it,OE((0,jA.useCallback)((y,G)=>aA.current(y,G),[]));let jt=O??dA??M;return(0,L.jsxs)(CA,{flexDirection:"column",children:[(0,L.jsxs)(CA,{justifyContent:"space-between",children:[(0,L.jsx)(eA,{bold:!0,children:"Toolroll"}),E?.needsYou?(0,L.jsx)(NA,{bold:!0,children:E.needsYou}):(0,L.jsx)(eA,{dimColor:!0,children:"Nothing needs you"}),E?.learning?(0,L.jsx)(NA,{dimColor:!0,children:E.learning}):null]}),lA(),jt===null?null:(0,L.jsx)(NA,{...O===null&&dA!==null?{bold:!0}:{},children:jt}),(0,L.jsx)(eA,{dimColor:!0,children:V()})]});function V(){switch(N.kind){case"main":return HA.length===0?`${I?.sample===!0?"s sample project · ":""}n new task · w browser · ? help · q quit`:"j/k move · Enter open · n new · a approve/accept · b send back · r retry · p plan · s stop · w browser · ? help · q quit";case"task":return`a approve/accept · b send back · r retry${N.task.planAsk==null?"":" · p plan it"} · s stop · 1–9 answer · w browser · Esc back`;case"approve":return"y approve · Esc cancel";case"retry":return"y retry · Esc cancel";case"accept":return N.result.ready?N.result.owed==="person-check"?"y yes, it looks right · n no · w open in the browser · Esc cancel":N.result.owed==="exception"?"Enter accept · Esc cancel":"y accept · w open in the browser · Esc cancel":"w open in the browser · Esc back";case"build":return"Enter Build · p plan it first · Esc cancel";case"compose":return N.purpose==="new"&&(E?.projects.length??0)>1?"Enter send · Tab project · Esc cancel":"Enter send · Esc cancel";case"quit":return"s stop · b background · Esc cancel";case"background":return"y yes · n no";default:return"Esc back"}}function lA(){switch(N.kind){case"help":return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(eA,{bold:!0,children:"Keys"}),Wy.map(y=>(0,L.jsx)(eA,{children:y},y))]});case"password":return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(eA,{bold:!0,children:"This needs your password"}),(0,L.jsx)(NA,{children:N.message}),E?.passwordSet?(0,L.jsx)(eA,{children:"Sign in in the browser, then do it there."}):(0,L.jsx)(eA,{children:"Set a password: run `toolroll password set`"})]});case"quit":return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(eA,{bold:!0,children:"Quit Toolroll?"}),(0,L.jsx)(eA,{children:"s Stop agents and quit (running work is saved)"}),(0,L.jsx)(eA,{children:"b Keep running, and start when you log in"})]});case"background":return(0,L.jsx)(CA,{borderStyle:"single",paddingX:1,children:(0,L.jsx)(eA,{bold:!0,children:"Start Toolroll when you log in, so tasks keep going? (y/N)"})});case"build":return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(eA,{bold:!0,children:"Build approves exactly this:"}),N.terms.terms.map((y,G)=>(0,L.jsx)(NA,{children:`${y.label}: ${y.words}`},G))]});case"compose":{let y=E?.projects[N.project]??null;return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[(0,L.jsx)(eA,{bold:!0,children:N.purpose==="new"?"New task":"What should change?"}),N.purpose==="new"&&y!==null?(0,L.jsx)(NA,{dimColor:!0,children:`In ${y}`}):null,(0,L.jsxs)(eA,{children:[(0,L.jsx)(NA,{children:N.text}),(0,L.jsx)(eA,{inverse:!0,children:" "})]})]})}case"accept":{let{result:y}=N;return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(NA,{bold:!0,children:`Accept this result? ${y.title}`}),(0,L.jsx)(NA,{dimColor:!0,children:`Build #${y.runId}`}),N.changed?(0,L.jsx)(eA,{bold:!0,children:"This result changed while you were reading it. This is the new one."}):null,y.summary.length===0?null:(0,L.jsx)(CA,{flexDirection:"column",marginTop:1,children:y.summary.map((G,K)=>(0,L.jsx)(NA,{children:G},K))}),(0,L.jsxs)(CA,{flexDirection:"column",marginTop:1,children:[(0,L.jsx)(eA,{bold:!0,children:"Changed files"}),y.files===null?(0,L.jsx)(eA,{children:"The changed files couldn't be read. Press w to see them in the browser."}):y.files.names.length===0?(0,L.jsx)(eA,{children:"None."}):(0,L.jsxs)(L.Fragment,{children:[y.files.names.map(G=>(0,L.jsx)(NA,{children:` ${G}`},G)),y.files.more>0?(0,L.jsx)(eA,{children:` and ${y.files.more} more`}):null]})]}),y.requirements.length===0?null:(0,L.jsxs)(CA,{flexDirection:"column",marginTop:1,children:[(0,L.jsx)(eA,{bold:!0,children:"Requirements"}),y.requirements.map((G,K)=>(0,L.jsx)(NA,{children:` ${G.word}: ${G.statement}`},K))]}),y.checks.length===0?null:(0,L.jsx)(CA,{flexDirection:"column",marginTop:1,children:y.checks.map((G,K)=>(0,L.jsx)(NA,{...K===0?{bold:!0}:{},children:G},K))}),(0,L.jsx)(CA,{flexDirection:"column",marginTop:1,children:y.ready?y.owed==="person-check"?(0,L.jsx)(eA,{bold:!0,children:"Did you check it yourself? (y/n)"}):y.owed==="exception"?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(eA,{bold:!0,children:"Say why you accept it anyway:"}),(0,L.jsxs)(eA,{children:[(0,L.jsx)(NA,{children:N.reason}),(0,L.jsx)(eA,{inverse:!0,children:" "})]})]}):(0,L.jsx)(eA,{bold:!0,children:"Accept it and mark the task done? (y/n)"}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(eA,{bold:!0,children:"You can't accept it yet."}),y.blockers.map((G,K)=>(0,L.jsx)(NA,{children:G},K))]})})]})}case"retry":return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(NA,{bold:!0,children:`Retry build #${N.retry.runId}? ${N.task.title}`}),(0,L.jsx)(eA,{children:"Same plan, same agent. Its branch and workspace are kept."})]});case"approve":return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(NA,{bold:!0,children:`Approve this plan? ${N.task.title}`}),N.task.plan.lines.map((y,G)=>(0,L.jsx)(NA,{children:y},G))]});case"task":{let y=Ef(N.task,dA!==null),G=y.decisions[0];return(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(NA,{bold:!0,children:y.title}),(0,L.jsx)(NA,{children:`${y.status}${y.detail===""?"":` · ${y.detail}`}`}),y.plan===null?null:(0,L.jsx)(eA,{children:"A plan waits for your approval (a)."}),(y.ready?.length??0)===0?null:(0,L.jsx)(CA,{flexDirection:"column",marginTop:1,children:y.ready.map((K,P)=>(0,L.jsx)(NA,{...P===0?{bold:!0}:{},children:K},P))}),G===void 0?null:(0,L.jsxs)(CA,{flexDirection:"column",marginTop:1,children:[(0,L.jsx)(NA,{bold:!0,children:G.question}),G.options.map((K,P)=>(0,L.jsx)(NA,{children:`${P+1} ${K.label}`},K.id))]}),W.length===0?null:(0,L.jsx)(CA,{flexDirection:"column",marginTop:1,children:W.slice(-12).map((K,P)=>(0,L.jsx)(NA,{dimColor:!0,children:K},P))})]})}default:return E===null?(0,L.jsx)(eA,{dimColor:!0,children:"Loading…"}):HA.length===0?(0,L.jsxs)(CA,{flexDirection:"column",borderStyle:"single",paddingX:1,children:[(0,L.jsx)(eA,{bold:!0,children:"Get to your first result"}),(I?.lines??["No tasks yet. Press n to write one."]).map((y,G)=>(0,L.jsx)(NA,{children:y},G))]}):(0,L.jsxs)(CA,{children:[(0,L.jsx)(CA,{flexDirection:"column",width:"45%",borderStyle:"single",paddingX:1,children:HA.map((y,G)=>(0,L.jsxs)(jA.Fragment,{children:[G===0||HA[G-1].group!==y.group?(0,L.jsx)(eA,{bold:!0,children:$y(y)}):null,(0,L.jsxs)(eA,{inverse:y===TA,wrap:"truncate-end",children:[y===TA?"> ":" ",(0,L.jsx)(NA,{children:y.title})," ",(0,L.jsx)(NA,{...y.needsYou?{bold:!0}:{dimColor:!0},children:y.status})]})]},y.id))}),(0,L.jsx)(CA,{flexDirection:"column",flexGrow:1,borderStyle:"single",paddingX:1,children:TA===void 0?(0,L.jsx)(eA,{dimColor:!0,children:"Nothing selected"}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(NA,{bold:!0,wrap:"truncate-end",children:TA.title}),(0,L.jsx)(NA,{children:`${TA.status}${TA.detail===""?"":` · ${TA.detail}`}`}),W.length===0?(0,L.jsx)(eA,{dimColor:!0,children:TA.liveRunId===null?"No agent is working on it now.":"Waiting for output…"}):W.slice(-12).map((y,G)=>(0,L.jsx)(NA,{dimColor:!0,wrap:"truncate-end",children:y},G))]})})]})}}}function cf(){let e=[{id:"t3",title:"Sample: upgrade the test runner",status:"Needs you",detail:"Plan ready to approve",needsYou:!0,liveRunId:null,repo:null,group:"you"},{id:"t1",title:"Sample: fix the login redirect",status:"Running",detail:"Sample task (not real)",needsYou:!1,liveRunId:1,repo:null,group:"working"},{id:"t2",title:"Sample: add CSV export",status:"Complete",detail:"Sample task (not real)",needsYou:!1,liveRunId:null,repo:null,group:"done"}];return{fastTerms:async()=>null,snapshot:async()=>({rows:e,needsYou:"1 task needs you: Sample: upgrade the test runner",projects:[],passwordSet:!1}),task:async u=>{let a=e.find(g=>g.id===u);return a===void 0?null:{id:u,title:a.title,status:a.status,detail:a.detail,liveRunId:a.liveRunId,hasResult:a.status==="Complete",decisions:[],plan:a.needsYou?{digest:"sample",lines:["Goal: upgrade the test runner (sample)"]}:null}},live:u=>u==="t1"?["Editing src/auth.ts (sample)"]:[],changed:()=>0,act:async()=>({ok:!1,message:"This is a sample: nothing changes.",needsPassword:!1}),result:async u=>u!=="t2"?null:{id:u,runId:2,digest:"sample",title:"Sample: add CSV export",ready:!0,blockers:[],summary:["Added a CSV export button to the orders page (sample)."],files:{names:["src/export.ts (sample)"],more:0},requirements:[{word:"You check",statement:"The CSV opens in a spreadsheet (sample)."}],checks:["Sample: checks are not real here."],owed:"person-check"},setup:async()=>null}}function Cf(){return{owned:()=>!1,openBrowser:async()=>"This is a sample.",shouldAskBackground:()=>!1,answerBackground:async()=>"This is a sample."}}var Qf=oA(qa(),1);async function t2(e=cf(),u=Cf()){if(!process.stdin.isTTY||!process.stdout.isTTY)throw new Error("The terminal UI needs an interactive terminal.");let a="leave";return await TE((0,Qf.jsx)(Bf,{source:e,session:u,onExit:g=>{a=g}}),{exitOnCtrlC:!1}).waitUntilExit(),a}var If=process.argv[1];If!==void 0&&import.meta.url===A2(If).href&&t2().catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
71
71
  `),process.exitCode=1});export{t2 as startTui};
72
72
  /*! Bundled license information:
73
73
 
@@ -38,14 +38,14 @@ const GATE_PAUSE_ON_TASK = pauseOnTaskProviders('p', 'c.ref_id');
38
38
  const INDEX_NEED = Object.fromEntries(['earlier-active', 'process-needs-attention', 'invalid-scope', 'decision-queue', 'history-problem']
39
39
  .map(code => [code, CODE_READING[code].need]));
40
40
  const PERSON_CODES = ['finding-held', 'history-problem', 'earlier-active', 'ready-to-check', 'waiting-decision', 'decision-queue', 'result-needs-attention',
41
- 'process-needs-attention', 'failed', 'vanished-run', 'stopped', 'held', 'waiting-incident', 'terminal-dependency', 'needs-project',
41
+ 'process-needs-attention', 'failed', 'vanished-run', 'stopped', 'held', 'waiting-incident', 'plan-stopped', 'planning-stopped', 'terminal-dependency', 'needs-project',
42
42
  'needs-scope', 'invalid-scope', 'needs-agent-profile', 'needs-approval', 'missing-requirement', 'no-worker-registered', 'no-worker-online', 'signed-out', 'storage-blocked'];
43
43
  const HELD_FINDINGS = `(SELECT COUNT(*) FROM finding fd WHERE fd.family_root=root.id AND fd.state='with-person')`;
44
44
  export const WAITING_CODES = ['cancelled', 'complete', 'running', 'queued',
45
- ...['stopping', 'updating', 'retry-scheduled', 'waiting-dependency', 'worker-at-capacity', 'planning-ready', 'scouting-ready'].filter(code => isWaitCode(code))];
45
+ ...['stopping', 'updating', 'retry-scheduled', 'plan-retry', 'waiting-dependency', 'worker-at-capacity', 'planning-ready', 'scouting-ready'].filter(code => isWaitCode(code))];
46
46
  const WAITING_SQL = WAITING_CODES.map(code => `'${code}'`).join(',');
47
47
  const STATE_ACT_LABEL = {
48
- 'ready-to-check': 'Open result', complete: 'Open result', cancelled: 'View task details', failed: 'Review and retry', 'waiting-incident': 'Review and retry',
48
+ 'ready-to-check': 'Open result', complete: 'Open result', cancelled: 'View task details', failed: 'Review and retry', 'waiting-incident': 'Review and retry', 'plan-stopped': 'Plan again', 'planning-stopped': 'Plan again',
49
49
  stopped: 'Review pause', held: 'Review hold', 'result-needs-attention': 'Open the build', 'process-needs-attention': 'Open the build',
50
50
  };
51
51
  export function askOfCode(code, custody = false) {
@@ -58,7 +58,7 @@ export function askOfCode(code, custody = false) {
58
58
  const codesOf = (ask) => PERSON_CODES.filter(code => askOfCode(code) === ask).map(code => `'${code}'`).join(',');
59
59
  const ASK_RANK = `CASE WHEN code IN (${codesOf('decide')}) THEN 0 WHEN code IN (${codesOf('review')}) AND NOT custody_unresolved THEN 1 ELSE 2 END`;
60
60
  const ASK_GROUP_SQL = `CASE WHEN code='needs-approval' AND c.id IN (SELECT value FROM json_each($releaseTasks)) THEN 'release' WHEN code='needs-approval' THEN 'approve' WHEN code IN ('waiting-decision','decision-queue') THEN 'answer'
61
- WHEN code IN ('failed','waiting-incident','vanished-run') THEN 'wrong' WHEN code IN (${codesOf('review')}) AND NOT custody_unresolved THEN 'review' ELSE 'other' END`;
61
+ WHEN code IN ('failed','waiting-incident','plan-stopped','planning-stopped','vanished-run') THEN 'wrong' WHEN code IN (${codesOf('review')}) AND NOT custody_unresolved THEN 'review' ELSE 'other' END`;
62
62
  const ORDER = `(CASE WHEN rank=0 THEN ask_rank WHEN rank=1 THEN 3 ELSE 4 END)`;
63
63
  const CUSTODY_WAITS = `(custody_unresolved AND code IN ('process-needs-attention','result-needs-attention') AND ref_id IN (SELECT value FROM json_each($waitingCustody)))`;
64
64
  const PROJECTION = `WITH RECURSIVE admitted AS MATERIALIZED (
@@ -126,7 +126,7 @@ const PROJECTION = `WITH RECURSIVE admitted AS MATERIALIZED (
126
126
  root.id root_id,root.title root_title,fam.fam_refs,fam.fam_ids,
127
127
  result.role result_role,result.outcome result_outcome,result.head_revision,result.scope_digest,result.finished_at,
128
128
  (SELECT id FROM run WHERE task_ref=c.ref_id AND lease_id=c.live_lease AND outcome IS NULL ORDER BY id DESC LIMIT 1) live_run,
129
- h.owner_kind hold_kind,h.reason hold_reason,h.until hold_until,
129
+ h.owner_kind hold_kind,h.owner_id hold_owner,h.reason hold_reason,h.until hold_until,
130
130
  sc.task_id scope_id,sc.digest,sc.approved_at,sc.proposed_at,sc.profile_state,
131
131
  -- A prepared candidate: the machine checks out that commit and runs its check; no agent runs (machine-check.ts).
132
132
  (typeof(sc.candidate)='text' AND sc.candidate<>'') machine_check,
@@ -230,8 +230,16 @@ const PROJECTION = `WITH RECURSIVE admitted AS MATERIALIZED (
230
230
  WHEN state='running' OR unfinished IS NOT NULL THEN 'vanished-run'
231
231
  WHEN EXISTS(SELECT 1 FROM sqlite_master WHERE type='trigger' AND name GLOB 'so_desktop_update_*') THEN 'updating'
232
232
  WHEN hold_kind='backoff' AND substr(hold_reason,1,${STORAGE_HOLD_PREFIX.length})='${STORAGE_HOLD_PREFIX}' THEN 'storage-blocked'
233
+ -- A planner's own backoff (claim.ts sealPlanFailure: owner plan:<ref>) tries the plan again, never a build.
234
+ WHEN hold_kind='backoff' AND substr(hold_owner,1,5)='plan:' THEN 'plan-retry'
233
235
  WHEN hold_kind='backoff' THEN 'retry-scheduled'
234
236
  WHEN hold_kind='decision' THEN 'waiting-decision'
237
+ -- A planning incident (its planning turn's plan or question failed its checks, or planning failed again and again):
238
+ -- Plan again is the way on, never Retry.
239
+ WHEN hold_kind='incident' AND EXISTS(SELECT 1 FROM incident pi JOIN run pr ON pr.id=pi.run WHERE pi.id=CAST(hold_owner AS INTEGER) AND pr.role='planner'
240
+ AND pi.kind='plan-attempts-exhausted') THEN 'planning-stopped'
241
+ WHEN hold_kind='incident' AND EXISTS(SELECT 1 FROM incident pi JOIN run pr ON pr.id=pi.run WHERE pi.id=CAST(hold_owner AS INTEGER) AND pr.role='planner'
242
+ AND pi.kind IN ('malformed-plan','malformed-decision')) THEN 'plan-stopped'
235
243
  WHEN hold_kind='incident' THEN 'waiting-incident'
236
244
  WHEN hold_kind='stop' THEN 'stopped'
237
245
  WHEN hold_id IS NOT NULL THEN 'held'
@@ -558,7 +566,7 @@ export function workReadyForReview(store, now, access, limit = 5) {
558
566
  let cursor = null;
559
567
  do {
560
568
  const page = workIndexPage(store, now, access, { view: 'needs-you', limit: WORK_INDEX_MAX_LIMIT, cursor });
561
- ready.push(...page.items.filter(one => one.status.label === 'Ready for review'));
569
+ ready.push(...page.items.filter(one => one.status.label === 'Ready'));
562
570
  cursor = page.nextCursor;
563
571
  } while (cursor !== null);
564
572
  return { count: ready.length, results: ready.slice(0, Math.max(0, limit)).map(one => ({ rootId: one.rootId, taskId: one.activeTaskId, run: one.resultRunId })) };
@@ -703,13 +711,18 @@ function itemOf(row, principal, probe, leadName, readiness, readable = false, no
703
711
  }
704
712
  if (code === 'cancelled')
705
713
  detail = 'This task was cancelled.';
714
+ if (code === 'plan-stopped')
715
+ detail = (s(row, 'hold_reason') ?? '').startsWith('malformed-decision') ? "The planner's question didn't pass its checks. Plan again, or edit the task." : "The plan didn't pass its checks. Plan again, or edit the task.";
716
+ if (code === 'planning-stopped')
717
+ detail = 'Planning stopped after repeated failures. Plan again, or edit the task.';
706
718
  if (code === 'waiting-incident')
707
719
  detail = `The last attempts failed the same way (${failedAttemptSentence(s(row, 'attempt_reason')).replace(/[.\s]+$/, '').replace(/^./, first => first.toLowerCase())}). Retry, or change the plan.`;
708
720
  const context = code === 'stopping' ? { build: n(row, 'stop_run') || null }
709
- : code === 'retry-scheduled' ? { build: n(row, 'attempt_run') || null, attempt: n(row, 'attempt_no') || null, retry: s(row, 'hold_until') === null ? null : retryWhenWords(s(row, 'hold_until'), now) }
710
- : code === 'vanished-run' ? { build: n(row, 'unfinished') || null }
711
- : code === 'earlier-active' ? { task: s(row, 'earlier_id') }
712
- : code === 'waiting-dependency' ? { task: s(row, 'dependency_id') } : {};
721
+ : code === 'plan-retry' ? { retry: s(row, 'hold_until') === null ? null : retryWhenWords(s(row, 'hold_until'), now) }
722
+ : code === 'retry-scheduled' ? { build: n(row, 'attempt_run') || null, attempt: n(row, 'attempt_no') || null, retry: s(row, 'hold_until') === null ? null : retryWhenWords(s(row, 'hold_until'), now) }
723
+ : code === 'vanished-run' ? { build: n(row, 'unfinished') || null }
724
+ : code === 'earlier-active' ? { task: s(row, 'earlier_id') }
725
+ : code === 'waiting-dependency' ? { task: s(row, 'dependency_id') } : {};
713
726
  if (code === 'signed-out' && n(row, 'no_agent') > 0 && s(row, 'signed_out') === null) {
714
727
  label = NO_AGENT_TITLE;
715
728
  detail = noAgentWords(agentlessCommand(n(row, 'no_agent') === 2, n(row, 'no_agent') === 3), n(row, 'models_cleared') === 1);
@@ -13,7 +13,7 @@ export const WORK_VIEWS = [
13
13
  { key: "ready", label: "Ready", hint: "Results waiting for you to accept or send back.", empty: "Nothing is ready for review." },
14
14
  { key: "running", label: "Running", hint: "Attempts a builder owns right now.", empty: "Nothing is running right now. Approved tasks start when a builder with capacity is connected." },
15
15
  { key: "queued", label: "Queued", hint: "Tasks that start on their own: waiting for a builder, a dependency or a retry.", empty: "Nothing is queued." },
16
- { key: "completed", label: "Finished", hint: "Tasks the lead or you accepted. Recorded check results stay available.", empty: "Nothing has finished in this view yet." },
16
+ { key: "completed", label: "Complete", hint: "Tasks the lead or you accepted. Recorded check results stay available.", empty: "Nothing has finished in this view yet." },
17
17
  { key: "archived", label: "Archived", hint: "Tasks archived by you or automatically. Their history and results are kept.", empty: "Nothing is archived." },
18
18
  ];
19
19
  export function parseWorkView(raw) {
@@ -250,7 +250,7 @@ const DISPATCH_ACTION_LABELS = {
250
250
  "place-task": "Choose a project",
251
251
  "write-scope": "Define the task",
252
252
  "select-agent": "Choose an agent",
253
- "approve-scope": "Approve plan",
253
+ "approve-scope": "Review plan",
254
254
  "answer-decision": "Answer the question",
255
255
  unhold: "Review hold",
256
256
  "inspect-hold": "Review hold",
@@ -566,7 +566,7 @@ export function stepRowsOf(view) {
566
566
  if (step.state === "done")
567
567
  return { sentence: "Project checks passed", at: null };
568
568
  if (step.state === "skipped")
569
- return { sentence: said === "Checks not run" ? "The checks didn't run" : said === "Checks at release" ? "Checked at release" : "No checks were recorded", at: null };
569
+ return { sentence: said === "Checks not run" ? "The checks didn't run" : said === "Checks at release" ? "Checks deferred to release" : "No checks were recorded", at: null };
570
570
  if (step.state === "stuck")
571
571
  return { sentence: step.needsYou && said === null ? "" : said === "Checks unreadable" ? "The checks couldn't be read" : said === "Checks failed" ? "The checks failed" : stoppedWord, at: null };
572
572
  if (step.state === "current")
@@ -575,7 +575,7 @@ export function stepRowsOf(view) {
575
575
  }
576
576
  case "ready":
577
577
  if (step.state === "done")
578
- return { sentence: headline === "Complete" ? "Finished" : view.scout ? "Report ready" : "Ready", at: lastResult };
578
+ return { sentence: headline === "Complete" ? "Complete" : view.scout ? "Report ready" : "Ready", at: lastResult };
579
579
  if (here)
580
580
  return { sentence: step.needsYou ? "" : step.state === "stuck" ? stoppedWord : "Waiting", at: null };
581
581
  if (hasResult)
@@ -599,7 +599,7 @@ export function stepRowsOf(view) {
599
599
  if (at !== -1)
600
600
  rows.splice(at, 1);
601
601
  }
602
- const waitsOnViewer = headline === "Ready for review" || headline === "Needs you";
602
+ const waitsOnViewer = headline === "Ready" || headline === "Needs you";
603
603
  if (waitsOnViewer && !rows.some(row => row.state === "current" || row.state === "stuck")) {
604
604
  const last = [...rows].reverse().find(row => row.state === "done");
605
605
  if (last !== undefined)
@@ -27,7 +27,7 @@ export const INTAKE_EVERY_MS = 30_000;
27
27
  const REQUEST_FILE = /^(r-[0-9a-f]{10})\.json$/;
28
28
  export const STATUS_OF_HEADLINE = {
29
29
  Queued: "queued", Planning: "building", "Needs you": "needs-you", Waiting: "building", Building: "building",
30
- "Ready for review": "ready", Complete: "done", Failed: "failed", Stopped: "stopped",
30
+ "Ready": "ready", Complete: "done", Failed: "failed", Stopped: "stopped",
31
31
  };
32
32
  const plural = (count, one) => `${count} ${one}${count === 1 ? "" : "s"}`;
33
33
  const isMissing = (error) => error?.code === "ENOENT";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "toolroll",
3
- "version": "0.9.114",
4
- "description": "Your agents build. You decide. A control plane for coding agents — Claude Code, Codex, Gemini: approve the exact scope once, get results back Ready with the diff, the passing check and screenshots. Runs on your machine.",
3
+ "version": "0.9.116",
4
+ "description": "Your agents build. You decide. A control plane for coding agents \u2014 Claude Code, Codex, Gemini: approve the exact scope once, get results back Ready with the diff, the passing check and screenshots. Runs on your machine.",
5
5
  "directories": {
6
6
  "doc": "docs"
7
7
  },