toolroll 0.9.109 → 0.9.110

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 (135) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/agent-detect.js +244 -0
  3. package/dist/agent-fence.js +12 -1
  4. package/dist/agentconfig.js +2 -2
  5. package/dist/approval-summary.js +344 -0
  6. package/dist/attest.js +2 -2
  7. package/dist/browser/workspace.css +2 -2
  8. package/dist/browser/workspace.js +27 -27
  9. package/dist/builder.js +36 -2
  10. package/dist/chat-actions.js +24 -17
  11. package/dist/chat-core.js +3 -1
  12. package/dist/chat-decide.js +101 -46
  13. package/dist/chat-delivery-state.js +2 -0
  14. package/dist/chat-delivery.js +3 -2
  15. package/dist/chat-live.js +2 -1
  16. package/dist/chat-task-actions.js +6 -0
  17. package/dist/check-report.js +1 -1
  18. package/dist/cli.js +2 -0
  19. package/dist/console-instance.js +10 -1
  20. package/dist/contracts/console-api.js +10 -5
  21. package/dist/contracts/engine-api.js +271 -0
  22. package/dist/coordinator.js +2 -2
  23. package/dist/discord-api.js +4 -3
  24. package/dist/discord-chat.js +3 -1
  25. package/dist/easy-start-args.js +7 -3
  26. package/dist/easy-start.js +25 -0
  27. package/dist/egress.js +72 -10
  28. package/dist/engine-handoff.js +34 -0
  29. package/dist/engine-reads.js +261 -0
  30. package/dist/eval-world.js +3 -2
  31. package/dist/evidence.js +2 -0
  32. package/dist/fast-start.js +55 -14
  33. package/dist/fast-terms.js +2 -2
  34. package/dist/first-run.js +10 -2
  35. package/dist/flexible-agents.js +234 -0
  36. package/dist/flexible-answers-schema.js +61 -0
  37. package/dist/flexible-answers.js +889 -0
  38. package/dist/flexible-custody.js +494 -0
  39. package/dist/flexible-import.js +782 -0
  40. package/dist/flexible-launch-schema.js +72 -0
  41. package/dist/flexible-launch.js +331 -0
  42. package/dist/flexible-launcher.js +88 -0
  43. package/dist/flexible-levels.js +34 -0
  44. package/dist/flexible-merge-guard.js +47 -0
  45. package/dist/flexible-refs.js +47 -0
  46. package/dist/flexible-relay-cancel.js +19 -0
  47. package/dist/flexible-relay-schema.js +55 -0
  48. package/dist/flexible-relay-upstreams.js +36 -0
  49. package/dist/flexible-relay.js +1032 -0
  50. package/dist/flexible-session.js +732 -0
  51. package/dist/flexible-ship-schema.js +81 -0
  52. package/dist/flexible-ship.js +694 -0
  53. package/dist/flexible-start.js +80 -0
  54. package/dist/flexible-thread.js +175 -25
  55. package/dist/flexible-turns-schema.js +69 -0
  56. package/dist/flexible-turns.js +490 -0
  57. package/dist/flexible.js +10 -1
  58. package/dist/flow-actions.js +6 -4
  59. package/dist/flow-steps.js +1 -1
  60. package/dist/flows-cli.js +2 -1
  61. package/dist/git-views.js +6 -3
  62. package/dist/install-mode.js +225 -0
  63. package/dist/lead-doors.js +7 -1
  64. package/dist/limits-ui.js +7 -0
  65. package/dist/live-reply.js +6 -0
  66. package/dist/live-terminal.js +425 -29
  67. package/dist/local-owner.js +6 -0
  68. package/dist/model-choices.js +12 -6
  69. package/dist/notification-delivery.js +11 -0
  70. package/dist/operate.js +74 -30
  71. package/dist/outbound-privacy.js +204 -0
  72. package/dist/passwordless.js +2 -1
  73. package/dist/project-delete.js +14 -0
  74. package/dist/provider-connection.js +5 -3
  75. package/dist/publish.js +5 -0
  76. package/dist/pull-request-flow.js +26 -7
  77. package/dist/push.js +5 -1
  78. package/dist/release-card.js +11 -3
  79. package/dist/release.js +10 -1
  80. package/dist/route-store.js +2 -2
  81. package/dist/sandbox-launch.js +32 -8
  82. package/dist/sandbox-runtime.js +16 -7
  83. package/dist/sandbox-tools.js +176 -0
  84. package/dist/scope.js +12 -36
  85. package/dist/scout-net.js +7 -2
  86. package/dist/serve.js +58 -11
  87. package/dist/server/chrome.js +3 -1
  88. package/dist/server/console.css +33 -6
  89. package/dist/server/engine-api.js +378 -0
  90. package/dist/server/flows.js +2 -2
  91. package/dist/server/http.js +7 -0
  92. package/dist/server/link-redemption.js +52 -0
  93. package/dist/server/mutation-key.js +21 -7
  94. package/dist/server/pages.js +69 -40
  95. package/dist/server/people-tokens.js +17 -41
  96. package/dist/server/render-chat.js +1 -0
  97. package/dist/server/render-new-task.js +3 -3
  98. package/dist/server/render-results.js +4 -4
  99. package/dist/server/render-tasks.js +129 -138
  100. package/dist/server/route-table.js +30 -1
  101. package/dist/server/settings-section-table.js +3 -0
  102. package/dist/server/settings-sections.js +33 -0
  103. package/dist/server/settings.js +84 -10
  104. package/dist/server/task-views.js +8 -2
  105. package/dist/server/tasks.js +25 -8
  106. package/dist/server/terminals.js +181 -28
  107. package/dist/server/welcome.js +35 -10
  108. package/dist/settings-groups-ui.js +2 -2
  109. package/dist/settings-proofs.js +13 -9
  110. package/dist/slack-api.js +4 -3
  111. package/dist/slack-chat.js +5 -3
  112. package/dist/spend.js +46 -12
  113. package/dist/status-probe.js +343 -0
  114. package/dist/store.js +102 -5
  115. package/dist/teams-api.js +4 -3
  116. package/dist/teams-chat.js +4 -2
  117. package/dist/telegram-lead.js +2 -1
  118. package/dist/telegram-live.js +2 -1
  119. package/dist/telegram-team.js +2 -1
  120. package/dist/telegram.js +17 -5
  121. package/dist/trusted-path.js +162 -0
  122. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  123. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  124. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  125. package/dist/tui/linux-x64/toolroll-tui +0 -0
  126. package/dist/tui-launch.js +282 -0
  127. package/dist/tui-source.js +5 -3
  128. package/dist/tui.js +1 -1
  129. package/dist/webhooks.js +8 -4
  130. package/dist/welcome-facts.js +22 -15
  131. package/dist/workspace-ui.js +5 -0
  132. package/package.json +1 -1
  133. package/scripts/crash-canary.mjs +1 -1
  134. package/scripts/pilot.mjs +1 -1
  135. package/scripts/provider-canary.mjs +5 -3
@@ -8,7 +8,7 @@ import { checklistLines, mergeChecklistOf } from "./merge-checklist.js";
8
8
  import { runAsLocalOwner } from "./local-owner.js";
9
9
  import { snapshotLiveRuns } from "./peek-cli.js";
10
10
  import { loadProjectRegistry } from "./repos.js";
11
- import { describeScope } from "./scope.js";
11
+ import { approvalSummaryOf, describeScope, summaryContextOf } from "./approval-summary.js";
12
12
  import { localModeOf, openStoreReadOnly } from "./store.js";
13
13
  import { routeChangeOf } from "./route-change.js";
14
14
  import { flakyCount } from "./flaky.js";
@@ -88,7 +88,9 @@ export function createTuiSource(options) {
88
88
  const task = record(answer["task"]), work = record(answer["work"]), status = record(work["status"]);
89
89
  const store = read();
90
90
  const scope = store === null ? null : store.getScope(id);
91
- const plan = scope === null || scope.approvedDigest === scope.digest ? null : { digest: scope.digest, lines: [...(store === null ? [] : routeLines(store, id)), ...describeScope(scope)].map(line => terminalText(line)) };
91
+ const context = store === null || scope === null ? null : summaryContextOf(store, id, scope, clock());
92
+ const plan = scope === null || scope.approvedDigest === scope.digest ? null : { digest: scope.digest, lines: [...(store === null ? [] : routeLines(store, id)), ...describeScope(scope, undefined, null, context)].map(line => terminalText(line)),
93
+ ...(context === null ? {} : { terms: approvalSummaryOf(scope, context).key }) };
92
94
  let hasResult = false;
93
95
  try {
94
96
  hasResult = store !== null && assignmentOf(store, id, clock(), { principal: "operator", repos: null })?.receipt != null;
@@ -149,7 +151,7 @@ export function createTuiSource(options) {
149
151
  done = "Building. It starts next.";
150
152
  break;
151
153
  case "approve":
152
- argv = ["task", "approve", act.id, "--yes", "--digest", act.digest];
154
+ argv = ["task", "approve", act.id, "--yes", "--digest", act.digest, ...(act.terms === undefined ? [] : ["--terms", act.terms])];
153
155
  done = "Approved. An agent starts on it.";
154
156
  break;
155
157
  case "stop":
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}).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:"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)}
71
71
  `),process.exitCode=1});export{t2 as startTui};
72
72
  /*! Bundled license information:
73
73
 
package/dist/webhooks.js CHANGED
@@ -3,6 +3,7 @@ import { notificationClaimHeld, claimNotifications, finalizeNotification, notifi
3
3
  import { loadDiscordCredentials } from "./discord-api.js";
4
4
  import { loadTeamsCredentials } from "./teams-api.js";
5
5
  import { loadSlackCredentials } from "./slack-api.js";
6
+ import { outboundPrivate, safeWords } from "./outbound-privacy.js";
6
7
  import { readFileSync, writeFileSync } from "node:fs";
7
8
  import { join } from "node:path";
8
9
  import { envValue } from "./names.js";
@@ -161,18 +162,21 @@ export function linkFor(consoleUrl, notification) {
161
162
  return `${consoleUrl}/next`;
162
163
  }
163
164
  export async function postWebhook(target, notification, link, fetcher = fetch) {
165
+ const withheld = outboundPrivate([notification.subject, notification.body]);
166
+ const subject = withheld ? safeWords({ project: notification.project }) : notification.subject;
167
+ const said = withheld ? [] : [notification.body];
164
168
  const body = target.kind === "slack"
165
169
  ? {
166
170
  text: [
167
- `*${notification.subject}*`,
168
- notification.body,
171
+ `*${subject}*`,
172
+ ...said,
169
173
  ...(link === null ? [] : [`<${link}|open in Toolroll>`]),
170
174
  ].join("\n"),
171
175
  }
172
176
  : {
173
177
  content: [
174
- `**${notification.subject}**`,
175
- notification.body,
178
+ `**${subject}**`,
179
+ ...said,
176
180
  ...(link === null ? [] : [link]),
177
181
  ].join("\n").slice(0, 1900),
178
182
  };
@@ -1,21 +1,25 @@
1
1
  import { basename, dirname, join } from "node:path";
2
2
  import { resolvePhaseAgent } from "./agentconfig.js";
3
- import { builderReadyFor, firstRunBuilderRepo } from "./dispatch.js";
3
+ import { builderReadyFor, firstRunBuilderRepo, modelsEverChosen } from "./dispatch.js";
4
4
  import { SAMPLE_FIRST_TASKS, SAMPLE_PROJECT_NAME, GENERIC_FIRST_TASKS, welcomeModel } from "./first-run.js";
5
- import { createConnectionChecker } from "./provider-connection.js";
5
+ import { detectAgents } from "./agent-detect.js";
6
6
  import { loadProjectRegistry } from "./repos.js";
7
7
  const AGENT_OF = { "claude-subscription": "claude", "codex-subscription": "codex" };
8
+ const CONNECTION_OF = { "signed-in": "connected", "signed-out": "signed-out", unknown: "unverified", "not-installed": "not-installed" };
8
9
  export async function welcomeHere(store, databaseFile, now, options = {}) {
9
10
  const registry = await loadProjectRegistry(join(dirname(databaseFile), "repos.json"));
10
11
  const repos = "error" in registry ? [] : registry.repos;
11
12
  const root = "error" in registry ? null : registry.roots[0] ?? null;
12
- const check = options.check ?? createConnectionChecker();
13
- const states = await Promise.all(["claude", "codex"].map(one => check(one).then(value => value.state, () => "unverified")));
14
13
  const repo = firstRunBuilderRepo(store, null, () => true, repos);
15
14
  const sample = root === null ? null : `${root.replace(/\/+$/, "")}/${SAMPLE_PROJECT_NAME}`;
16
15
  const build = resolvePhaseAgent(store, "build", repo, {});
16
+ const routed = firstTaskRouted(store, repo);
17
+ const detection = await detectAgents({ ...(options.check === undefined ? {} : { check: options.check }), routed, clock: () => now, acpChecked: acpCheckedHere(store),
18
+ store, untrusted: () => repos });
19
+ const stateOf = (id) => CONNECTION_OF[detection.agents.find(one => one.id === id)?.state ?? "unknown"];
17
20
  const model = welcomeModel({
18
- agents: { claude: states[0] ?? null, codex: states[1] ?? null },
21
+ agents: { claude: stateOf("claude"), codex: stateOf("codex") },
22
+ others: detection.agents, routed,
19
23
  inUse: AGENT_OF[store.getChatConfig()?.provider ?? ""] ?? null,
20
24
  buildsOn: build.ok ? build.spec.provider : null,
21
25
  canChoose: false,
@@ -26,7 +30,17 @@ export async function welcomeHere(store, databaseFile, now, options = {}) {
26
30
  starters: repo !== null && repo === sample ? SAMPLE_FIRST_TASKS : GENERIC_FIRST_TASKS,
27
31
  platform: options.platform ?? process.platform,
28
32
  });
29
- return { model, projects: repos };
33
+ return { model, projects: repos, detection };
34
+ }
35
+ export function firstTaskRouted(store, repo = null) {
36
+ const build = resolvePhaseAgent(store, "build", repo, {});
37
+ if (build.ok && build.source !== "default")
38
+ return build.spec.provider;
39
+ return modelsEverChosen(store) ? "claude" : null;
40
+ }
41
+ export function acpCheckedHere(store) {
42
+ const runners = store.listRunners().filter(one => one.retiredAt === null).map(one => one.name);
43
+ return provider => runners.some(name => store.acpAttestationFor(provider, name) !== null);
30
44
  }
31
45
  export const WELCOME_STEPS = ["agent", "project", "task"];
32
46
  export function welcomeStepLines(model, key, sample = null) {
@@ -34,15 +48,8 @@ export function welcomeStepLines(model, key, sample = null) {
34
48
  const lines = [];
35
49
  if (key === "agent") {
36
50
  lines.push(`1. Agent · ${mark(model.agent.done)}`);
37
- const optionalOnes = model.agent.agents.some(agent => agent.optional);
38
- if (!model.agent.done && !model.agent.checking && !optionalOnes && model.agent.agents.length > 1)
39
- lines.push(" You need one of these:");
40
- for (const agent of model.agent.agents) {
41
- const state = agent.state === "signed-in" ? "signed in" : agent.state === "checking" ? "checking" : agent.state === "not-installed" ? "not installed" : "not signed in";
42
- lines.push(` ${agent.name}${agent.optional ? " (optional)" : ""}: ${state}${agent.inUse ? " (in use)" : ""}`);
43
- if (agent.command !== null && !(agent.optional && model.agent.done))
44
- lines.push(` To sign in, run: ${agent.command}`);
45
- }
51
+ for (const line of model.agent.lines)
52
+ lines.push(` ${line}`);
46
53
  }
47
54
  else if (key === "project") {
48
55
  lines.push(`2. Project · ${mark(model.project.done)}`);
@@ -594,6 +594,11 @@ export function stepRowsOf(view) {
594
594
  const opens = step.state !== "todo" || (step.key === "ready" && hasResult) || (step.key === "build" && hasHistory) || approvalHere;
595
595
  return { key: step.key, label: step.label, state: step.state, mark, sentence: said.sentence, at: said.at, needsYou, opens, open: here || approvalHere };
596
596
  });
597
+ if (view.approve != null) {
598
+ const at = rows.findIndex(row => row.key === "plan" && (row.state === "done" || row.state === "skipped"));
599
+ if (at !== -1)
600
+ rows.splice(at, 1);
601
+ }
597
602
  const waitsOnViewer = headline === "Ready for review" || headline === "Needs you";
598
603
  if (waitsOnViewer && !rows.some(row => row.state === "current" || row.state === "stuck")) {
599
604
  const last = [...rows].reverse().find(row => row.state === "done");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolroll",
3
- "version": "0.9.109",
3
+ "version": "0.9.110",
4
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.",
5
5
  "directories": {
6
6
  "doc": "docs"
@@ -131,7 +131,7 @@ async function one(stage, round) {
131
131
  } else {
132
132
  await cli(["task", "scope", "work", "--goal", "Write the result and verify it.", "--acceptance", acceptance.map(c => `${c.statement}|${c.evidence.join(",")}`).join(";")]);
133
133
  const preview = await cli(["task", "show", "work"]);
134
- await cli(["task", "approve", "work", "--yes", "--digest", preview.scope.digest, ...auth]);
134
+ await cli(["task", "approve", "work", "--yes", "--digest", preview.scope.digest, "--terms", preview.approvalTerms, ...auth]);
135
135
  }
136
136
  const workerArgs = ["watch", "--runner", "worker", "--token-file", join(control,"token"), "--repo", repo, "--pool", pool, "--tick-every", "200", "--reconcile-every", "500", "--bridge-every", "3600000", "--stop-grace", "1000", "--db", db, "--json"];
137
137
  worker = start([...workerArgs, "--for", "180000"], opts);
package/scripts/pilot.mjs CHANGED
@@ -77,7 +77,7 @@ async function one(id,provider,wave) {
77
77
  ].join(';');
78
78
  await cli('file fixed scope',['task','scope','work','--goal',spec.goal,'--touches',spec.paths.join(','),'--acceptance',rubric,'--not','Changing tests or dependency definitions, external publication, or unrelated files.']);
79
79
  const preview=await cli('read scope',['task','show','work']);
80
- await cli('approve exact fixture scope',['task','approve','work','--yes','--digest',preview.scope.digest,...auth]);
80
+ await cli('approve exact fixture scope',['task','approve','work','--yes','--digest',preview.scope.digest,'--terms',preview.approvalTerms,...auth]);
81
81
  await writeFile(join(dir,'runner-token'),registered.token,{mode:0o600});
82
82
  console.log(name+': starting unattended build and check');
83
83
  const start=Date.now();
@@ -313,11 +313,13 @@ async function runtimeIdentity() {
313
313
  export async function checkCheckoutGit({ provider, worktree, databaseFile, repository, home = homedir() }, execute = run) {
314
314
  if (!["claude", "codex", "gemini"].includes(provider)) return null;
315
315
  if (typeof worktree !== "string" || worktree === "") throw new Error("the builder did not retain its worktree for the Git fence check");
316
- const { agentFence, taskBoundary, trustedWorktreeBinding, checkoutGitEnv, HARDENED_GIT_ARGS, fenceGrants, codexFenceArgv, macosFenceAvailable, linuxFenceAvailable, sandboxedSpawn } = await import(join(root, "dist", "agent-fence.js"));
316
+ const { agentFence, taskBoundary, trustedWorktreeBinding, checkoutGitEnv, installDenied, HARDENED_GIT_ARGS, fenceGrants, codexFenceArgv, macosFenceAvailable, linuxFenceAvailable, sandboxedSpawn } = await import(join(root, "dist", "agent-fence.js"));
317
317
  const binding = trustedWorktreeBinding(repository, worktree);
318
318
  const boundary = taskBoundary({ worktree, provider, home, binding });
319
319
  const fence = agentFence({ databaseFile, worktree, home, boundary, binding });
320
- const grants = fenceGrants({ databaseFile, worktree, boundary });
320
+ // As fenceFor makes them: Toolroll's own install write-denied, which the Linux fence needs before it runs a seccomp
321
+ // helper Toolroll's user owns (a user npm install).
322
+ const grants = installDenied(fenceGrants({ databaseFile, worktree, boundary }), worktree, home, binding?.main ?? null);
321
323
  const codexHome = provider === "codex" ? await mkdtemp(join(tmpdir(), "so-codex-canary-")) : null;
322
324
  try {
323
325
  let head = null;
@@ -488,7 +490,7 @@ async function main() {
488
490
  throw new Error("the unchanged plan did not receive the exact signed mode approval");
489
491
  }
490
492
  } else await cli("approve the exact planned scope", [
491
- "task", "approve", TASK_ID, "--yes", "--digest", digest,
493
+ "task", "approve", TASK_ID, "--yes", "--digest", digest, "--terms", afterPlan.approvalTerms,
492
494
  "--as", "canary", "--token", password,
493
495
  ]);
494
496