@sma1lboy/rove 0.9.250 → 0.9.251

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 (171) hide show
  1. package/dist/cli/chunk-032g0ahy.js +3 -0
  2. package/dist/cli/{chunk-h86p4zzr.js → chunk-094cgrcc.js} +1 -1
  3. package/dist/cli/{chunk-5bfern2b.js → chunk-11wyec8z.js} +1 -1
  4. package/dist/cli/{chunk-kxaqge09.js → chunk-14f459aa.js} +1 -1
  5. package/dist/cli/{chunk-8gmxg77t.js → chunk-1exaxwyv.js} +1 -1
  6. package/dist/cli/{chunk-mptaj95j.js → chunk-1tebqkdv.js} +1 -1
  7. package/dist/cli/{chunk-h9cg0j3a.js → chunk-21ek142k.js} +1 -1
  8. package/dist/cli/{chunk-9q1m5qz0.js → chunk-28wjmb9f.js} +1 -1
  9. package/dist/cli/chunk-29kvfqeh.js +23 -0
  10. package/dist/cli/chunk-2dpr8gps.js +2 -0
  11. package/dist/cli/{chunk-mn6qth54.js → chunk-2g2w5vvn.js} +1 -1
  12. package/dist/cli/{chunk-7xttx9m1.js → chunk-2pen6b1t.js} +1 -1
  13. package/dist/cli/{chunk-a82ec09z.js → chunk-2wd4744g.js} +1 -1
  14. package/dist/cli/chunk-3msnqacf.js +2 -0
  15. package/dist/cli/{chunk-wtdj8n93.js → chunk-4rx3nhvq.js} +1 -1
  16. package/dist/cli/{chunk-2vgc5cyj.js → chunk-4z01vg3t.js} +1 -1
  17. package/dist/cli/{chunk-y2bga5cw.js → chunk-5456ttpr.js} +3 -3
  18. package/dist/cli/{chunk-f7zjggfv.js → chunk-568q390y.js} +2 -2
  19. package/dist/cli/chunk-5q08srg6.js +2 -0
  20. package/dist/cli/chunk-5r71q63g.js +2 -0
  21. package/dist/cli/chunk-6ahc8w4p.js +87 -0
  22. package/dist/cli/{chunk-3c58659p.js → chunk-6f01fsje.js} +1 -1
  23. package/dist/cli/{chunk-rvqse0aa.js → chunk-6h0n4b5t.js} +2 -2
  24. package/dist/cli/chunk-6rrzq5et.js +3 -0
  25. package/dist/cli/chunk-719avf77.js +2 -0
  26. package/dist/cli/chunk-76n3d9x3.js +2 -0
  27. package/dist/cli/{chunk-jh11snb1.js → chunk-7j00hbq5.js} +1 -1
  28. package/dist/cli/{chunk-8n19nb0s.js → chunk-7vv6160d.js} +1 -1
  29. package/dist/cli/{chunk-gc77ewk2.js → chunk-7z9yfnjd.js} +1 -1
  30. package/dist/cli/{chunk-4xns5j33.js → chunk-84bmcqyz.js} +1 -1
  31. package/dist/cli/{chunk-hm6qe86k.js → chunk-86chrjqr.js} +1 -1
  32. package/dist/cli/{chunk-kqc0kym1.js → chunk-88czbfqx.js} +1 -1
  33. package/dist/cli/{chunk-r07zjer5.js → chunk-8ezc1ban.js} +2 -2
  34. package/dist/cli/{chunk-ntrwd6ks.js → chunk-8ja7jrhc.js} +2 -2
  35. package/dist/cli/chunk-8s0mz115.js +52 -0
  36. package/dist/cli/{chunk-rjxj5tf4.js → chunk-8sbbzs5g.js} +1 -1
  37. package/dist/cli/{chunk-rtdr5bm8.js → chunk-8spmjwwz.js} +1 -1
  38. package/dist/cli/{chunk-wqfp8d9w.js → chunk-91sykzqq.js} +2 -2
  39. package/dist/cli/{chunk-jk8knad0.js → chunk-963er0h4.js} +3 -3
  40. package/dist/cli/{chunk-y7mg74jx.js → chunk-964z8ccb.js} +1 -1
  41. package/dist/cli/chunk-9h940gnr.js +2 -0
  42. package/dist/cli/{chunk-z0ewb9k9.js → chunk-9v568ape.js} +1 -1
  43. package/dist/cli/{chunk-tbrkck2f.js → chunk-9xtg2k54.js} +1 -1
  44. package/dist/cli/{chunk-xv8fhxxm.js → chunk-a7m7w6d1.js} +1 -1
  45. package/dist/cli/{chunk-3pdg2afa.js → chunk-apfzdw7g.js} +2 -2
  46. package/dist/cli/{chunk-fxqp6zt5.js → chunk-ayr5dpgc.js} +1 -1
  47. package/dist/cli/{chunk-j3c4kygc.js → chunk-bvqwgrar.js} +1 -1
  48. package/dist/cli/{chunk-ktzbg4jg.js → chunk-cb1dg7nz.js} +1 -1
  49. package/dist/cli/{chunk-nhakrm1f.js → chunk-cmp64q4j.js} +1 -1
  50. package/dist/cli/chunk-cp5jp5mq.js +3 -0
  51. package/dist/cli/{chunk-78xjh4gg.js → chunk-crdyt04z.js} +1 -1
  52. package/dist/cli/chunk-d99385f2.js +22 -0
  53. package/dist/cli/chunk-daw4mxq3.js +2 -0
  54. package/dist/cli/{chunk-wtb8cycx.js → chunk-dcjxtwdb.js} +1 -1
  55. package/dist/cli/{chunk-78kh1fet.js → chunk-dgbcpkr2.js} +1 -1
  56. package/dist/cli/{chunk-easxds8p.js → chunk-e003wm6d.js} +2 -2
  57. package/dist/cli/{chunk-2mrwdd50.js → chunk-e1xvz3sv.js} +1 -1
  58. package/dist/cli/chunk-f7rmd4zk.js +6 -0
  59. package/dist/cli/{chunk-7mq1ascs.js → chunk-fktvtdkb.js} +1 -1
  60. package/dist/cli/{chunk-2r696a8v.js → chunk-fsdh66fa.js} +1 -1
  61. package/dist/cli/{chunk-06d596z0.js → chunk-g5rr5fpn.js} +1 -1
  62. package/dist/cli/chunk-g872swb8.js +82 -0
  63. package/dist/cli/{chunk-t8v9rpdx.js → chunk-g8wrdp7n.js} +1 -1
  64. package/dist/cli/{chunk-fxm1cmp9.js → chunk-ga5f2pyc.js} +1 -1
  65. package/dist/cli/{chunk-ce16ecse.js → chunk-gaf6n1ea.js} +1 -1
  66. package/dist/cli/{chunk-53cyns0f.js → chunk-gp991c3v.js} +1 -1
  67. package/dist/cli/chunk-h9kzwj14.js +2 -0
  68. package/dist/cli/{chunk-yjs6d5w1.js → chunk-jfnr89qj.js} +1 -1
  69. package/dist/cli/{chunk-d5xc67hp.js → chunk-jrdwedn2.js} +1 -1
  70. package/dist/cli/{chunk-wnwzj8am.js → chunk-k9spgfmx.js} +1 -1
  71. package/dist/cli/{chunk-41r8zj46.js → chunk-kb3zvtkj.js} +1 -1
  72. package/dist/cli/{chunk-vb2tzcde.js → chunk-m4wy9ja5.js} +1 -1
  73. package/dist/cli/chunk-md094j05.js +3 -0
  74. package/dist/cli/{chunk-09y4jh6p.js → chunk-mdnrrj16.js} +1 -1
  75. package/dist/cli/{chunk-whbm14qr.js → chunk-meyfwc50.js} +1 -1
  76. package/dist/cli/{chunk-wkt6h5cf.js → chunk-mf7fb92r.js} +1 -1
  77. package/dist/cli/chunk-mnm9n2vr.js +2 -0
  78. package/dist/cli/chunk-mnpewdhd.js +17 -0
  79. package/dist/cli/chunk-mq06xpqr.js +3 -0
  80. package/dist/cli/{chunk-93r6tgf1.js → chunk-mre9g9vq.js} +1 -1
  81. package/dist/cli/{chunk-c01899mr.js → chunk-mv0hp5cv.js} +1 -1
  82. package/dist/cli/{chunk-21xgqgmv.js → chunk-n52x0ehz.js} +1 -1
  83. package/dist/cli/{chunk-g8fjjbnj.js → chunk-ncrr0fa3.js} +1 -1
  84. package/dist/cli/{chunk-k39sf30b.js → chunk-nep425b6.js} +1 -1
  85. package/dist/cli/{chunk-pe6wnsww.js → chunk-nj53wrzz.js} +1 -1
  86. package/dist/cli/{chunk-ap3r73bm.js → chunk-nsqsvgry.js} +3 -3
  87. package/dist/cli/{chunk-p83wf4zw.js → chunk-nxe45n7k.js} +2 -2
  88. package/dist/cli/{chunk-38s9e8dh.js → chunk-ny12rama.js} +1 -1
  89. package/dist/cli/{chunk-q8q22wq3.js → chunk-p2jeq98m.js} +1 -1
  90. package/dist/cli/chunk-q3xt0mqt.js +3 -0
  91. package/dist/cli/{chunk-7s67c0kw.js → chunk-q5bhq11t.js} +1 -1
  92. package/dist/cli/chunk-q6qhk171.js +2 -0
  93. package/dist/cli/{chunk-9aydqazr.js → chunk-q854fweb.js} +1 -1
  94. package/dist/cli/chunk-qft75bkm.js +2 -0
  95. package/dist/cli/{chunk-p18ehv9y.js → chunk-qstjfseh.js} +1 -1
  96. package/dist/cli/chunk-qxzrdfh7.js +11 -0
  97. package/dist/cli/{chunk-bvqazrbz.js → chunk-qyfmfpjg.js} +1 -1
  98. package/dist/cli/{chunk-gcxcq22q.js → chunk-r0etyq15.js} +1 -1
  99. package/dist/cli/{chunk-hbn1t161.js → chunk-r2c5nbcq.js} +1 -1
  100. package/dist/cli/chunk-r7tbzgt7.js +2 -0
  101. package/dist/cli/{chunk-s57vy3k3.js → chunk-ra40m849.js} +1 -1
  102. package/dist/cli/chunk-regtterm.js +9 -0
  103. package/dist/cli/{chunk-pvm3fc44.js → chunk-rf0jrh3q.js} +1 -1
  104. package/dist/cli/chunk-rhq87p4r.js +2 -0
  105. package/dist/cli/chunk-rkgnrfga.js +2 -0
  106. package/dist/cli/chunk-rqpwy31f.js +2 -0
  107. package/dist/cli/{chunk-8mfpv3fh.js → chunk-rt4tg426.js} +1 -1
  108. package/dist/cli/{chunk-n5dea05t.js → chunk-s2t9acrv.js} +1 -1
  109. package/dist/cli/{chunk-fz17c524.js → chunk-s5a5dyab.js} +1 -1
  110. package/dist/cli/{chunk-8gqkrbyr.js → chunk-s5k3g5ra.js} +1 -1
  111. package/dist/cli/{chunk-des00203.js → chunk-sgegp9x9.js} +1 -1
  112. package/dist/cli/chunk-sqp33pwr.js +2 -0
  113. package/dist/cli/chunk-t33z2kdv.js +3 -0
  114. package/dist/cli/{chunk-fvmee0tr.js → chunk-t71nxngb.js} +1 -1
  115. package/dist/cli/{chunk-ng12dprz.js → chunk-tntdcyra.js} +1 -1
  116. package/dist/cli/{chunk-4nt1gnwq.js → chunk-v312167r.js} +1 -1
  117. package/dist/cli/{chunk-j4cqwqnc.js → chunk-v6d6kvmk.js} +1 -1
  118. package/dist/cli/chunk-vd8qqev9.js +4 -0
  119. package/dist/cli/{chunk-vej49hnt.js → chunk-vgknea9y.js} +2 -2
  120. package/dist/cli/chunk-vwg79maj.js +20 -0
  121. package/dist/cli/{chunk-99n8qsw9.js → chunk-w4cpkhzj.js} +1 -1
  122. package/dist/cli/{chunk-3dey6b3r.js → chunk-w7yg0bbz.js} +1 -1
  123. package/dist/cli/{chunk-85q2tgmg.js → chunk-ws6yep7z.js} +1 -1
  124. package/dist/cli/{chunk-9jsm6h5y.js → chunk-x0rvg54z.js} +1 -1
  125. package/dist/cli/{chunk-enq6vwz5.js → chunk-x7cv6deh.js} +1 -1
  126. package/dist/cli/{chunk-qb1agm2c.js → chunk-y1cb8pj5.js} +1 -1
  127. package/dist/cli/{chunk-cbjh43yc.js → chunk-y5dk90tw.js} +1 -1
  128. package/dist/cli/{chunk-zfvg4w3t.js → chunk-yjyjg7sk.js} +1 -1
  129. package/dist/cli/{chunk-0gz3an4p.js → chunk-yknavm97.js} +1 -1
  130. package/dist/cli/{chunk-hhvvcwjq.js → chunk-zcadc92x.js} +1 -1
  131. package/dist/cli/{chunk-3hcsvyeq.js → chunk-zcwgmz5p.js} +1 -1
  132. package/dist/cli/chunk-zk5qkkb1.js +3 -0
  133. package/dist/cli/index.js +9 -9
  134. package/dist/cli/pty-host-node.mjs +10 -2
  135. package/dist/cli/rove-run.js +1 -1
  136. package/dist/cli/rove.js +1 -1
  137. package/dist/web/assets/{index-BYv91-Cs.css → index-BZjPWX0N.css} +1 -1
  138. package/dist/web/assets/index-DHlgMx7L.js +109 -0
  139. package/dist/web/index.html +2 -2
  140. package/package.json +4 -4
  141. package/dist/cli/chunk-191gy3f0.js +0 -2
  142. package/dist/cli/chunk-2kshjtcs.js +0 -2
  143. package/dist/cli/chunk-5fft208x.js +0 -2
  144. package/dist/cli/chunk-66r43sfd.js +0 -3
  145. package/dist/cli/chunk-6axpatfy.js +0 -2
  146. package/dist/cli/chunk-79hrybcd.js +0 -2
  147. package/dist/cli/chunk-7q43tysm.js +0 -3
  148. package/dist/cli/chunk-86tw1190.js +0 -4
  149. package/dist/cli/chunk-8kx2k2s8.js +0 -52
  150. package/dist/cli/chunk-8m5crcy5.js +0 -82
  151. package/dist/cli/chunk-8pna13mr.js +0 -2
  152. package/dist/cli/chunk-9853bbb9.js +0 -18
  153. package/dist/cli/chunk-asy33vdy.js +0 -2
  154. package/dist/cli/chunk-cmss5e88.js +0 -3
  155. package/dist/cli/chunk-e8d5951a.js +0 -2
  156. package/dist/cli/chunk-fe7kwz48.js +0 -3
  157. package/dist/cli/chunk-g4k86vkr.js +0 -2
  158. package/dist/cli/chunk-gcdm2jke.js +0 -2
  159. package/dist/cli/chunk-gpb49qs3.js +0 -3
  160. package/dist/cli/chunk-hzfq0sst.js +0 -2
  161. package/dist/cli/chunk-kecy2zcc.js +0 -9
  162. package/dist/cli/chunk-knfnbv60.js +0 -17
  163. package/dist/cli/chunk-m3sq1vgk.js +0 -40
  164. package/dist/cli/chunk-pkk9j80z.js +0 -7
  165. package/dist/cli/chunk-vt6ghz8y.js +0 -2
  166. package/dist/cli/chunk-vt7bc8d6.js +0 -87
  167. package/dist/cli/chunk-w594v1n8.js +0 -2
  168. package/dist/cli/chunk-x8fd9y51.js +0 -3
  169. package/dist/cli/chunk-zh30b87y.js +0 -9
  170. package/dist/cli/chunk-zwq8cb8p.js +0 -2
  171. package/dist/web/assets/index-DaovU92T.js +0 -109
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{closeTab,engineTabArgv,initialTabs,setTabTitle,tabPtyKeyFor,terminalTabsKey}from"./chunk-09y4jh6p.js";import{awaitEngineProcess,buildEngineSessionLaunch,deliverToHostedKey,enginePresence,ensureHostedSessionHost,findHostedEngineKey,hostedSessionFailureLine,hostedTaskKeys,initMarkerSaysFinished,isHostedTaskKey,killHostedSessions,listHostedSessions,listHostedSessionsOrNull,openHostedSessionHost,pastePromptWhenEngineUp,readPersistedTerminalDefaultColors,sessionArgvNamesEngine}from"./chunk-z0ewb9k9.js";import{engineLaunchArgv}from"./chunk-93r6tgf1.js";import{engineProcessIn,parsePsSnapshot,psSnapshot,vendorFromArgv}from"./chunk-ntrwd6ks.js";import{ApiError}from"./chunk-f7zjggfv.js";import{loadStateFile,patchStateFile,updateStateFile}from"./chunk-7q43tysm.js";import{basename}from"path";function wireNode(node){if(node.kind==="leaf")return{kind:"leaf",id:node.id,title:node.title??null,own:node.content===null};return{kind:"group",orientation:node.orientation,children:node.children.map(wireNode)}}function wireSplit(tree){return tree?{root:wireNode(tree.root),activeLeafId:tree.activeLeafId}:null}function taskEngineArgv(task){return engineLaunchArgv({command:task.command,vendor:task.vendor})}function readTabsSnapshot(taskId){try{let snap=loadStateFile()[terminalTabsKey(taskId)];return snap&&Array.isArray(snap.tabs)?snap:void 0}catch{return}}function closeTabsSnapshot(taskId,tabId){let closing,key=terminalTabsKey(taskId);return updateStateFile((store)=>{let state=store[key];if(!state||!Array.isArray(state.tabs))return!1;if(closing=state.tabs.find((tab)=>tab.id===tabId),!closing)return!1;let{state:next,closedId}=closeTab(state,tabId,{allowEmpty:!0});if(!closedId)return closing=void 0,!1;store[key]=next;return}),closing}function renameTabsSnapshot(taskId,tabId,title){let found=!1,key=terminalTabsKey(taskId);return updateStateFile((store)=>{let state=store[key];if(!state||!Array.isArray(state.tabs))return!1;if(!state.tabs.some((tab)=>tab.id===tabId))return!1;found=!0;let next=setTabTitle(state,tabId,title);if(next===state)return!1;store[key]=next;return}),found}var aliveKeysOf=(sessions)=>new Set(sessions.filter((s)=>s.alive).map((s)=>s.key));function unregisteredTabIds(snapshot,taskId,sessions){let known=new Set((snapshot?.tabs??[]).map((t)=>t.id)),prefix=`${taskId}::`,out=[];for(let s of sessions){if(!s.alive||!s.key.startsWith(prefix))continue;let tabId=s.key.slice(prefix.length);if(tabId.includes("::"))continue;if(!known.has(tabId)&&!out.includes(tabId))out.push(tabId)}return out}var abnormalExit=(exit)=>exit&&(exit.code!==0||exit.signal!==null)?exit:null;function joinTaskTabs(snapshot,taskId,sessions,persistedExits={},liveVendors,engineAlive){let unknown=sessions===null,rows0=sessions??[],alive=aliveKeysOf(rows0),sessionExits=new Map(rows0.map((s)=>[s.key,s.exit])),deadExit=(key)=>{let ex=abnormalExit(sessionExits.get(key)??persistedExits[key]);if(!ex)return null;let record=persistedExits[key],sameDeath=record?.at===ex.at,tail=sameDeath?record?.tail:void 0,code=ex.code??(sameDeath?record?.code??null:null),layer=record?.layer??"pty";return{code,signal:ex.signal,at:ex.at,layer,...tail&&tail.length>0?{tail}:{}}},engineExit=(key)=>{let record=persistedExits[`${key}#engine`];if(!record)return null;let{code,signal,at,tail,atApproximate}=record;return{code,signal,at,layer:"engine",...atApproximate?{atApproximate}:{},...tail&&tail.length>0?{tail}:{}}},rows=(snapshot?.tabs??[]).map((t)=>{let key=tabPtyKeyFor(taskId,t),isAlive=unknown?null:alive.has(key),walked=isAlive===!0&&liveVendors?.has(key)===!0?liveVendors.get(key)??null:void 0,engineIsAlive=engineAliveOf(key,isAlive,engineAlive);return{id:t.id,kind:t.kind,title:t.title??null,vendor:t.vendor??null,liveVendor:walked!==void 0?walked:t.liveVendor??null,lastTitle:t.lastTitle??null,autoTitle:t.autoTitle??null,alive:isAlive,engineAlive:engineIsAlive,exit:isAlive===!1?deadExit(key):engineIsAlive===!1?engineExit(key):null,...t.splitTree?{split:wireSplit(t.splitTree)}:{},...t.kind==="engine"&&t.ptyTask?{viewOf:t.ptyTask.id}:{}}});for(let tabId of unregisteredTabIds(snapshot,taskId,rows0))rows.push({id:tabId,kind:"engine",title:null,vendor:null,liveVendor:null,lastTitle:null,autoTitle:null,alive:!0,engineAlive:engineAliveOf(`${taskId}::${tabId}`,!0,engineAlive),exit:null,unregistered:!0});return rows}function engineAliveOf(key,isAlive,engineAlive){if(isAlive===null)return null;if(!isAlive)return!1;return engineAlive?.has(key)===!0?engineAlive.get(key)??null:null}function publishCliTabSnapshot(taskId,sessionId){if(!taskId)return;try{let key=terminalTabsKey(taskId);if(loadStateFile()[key]!==void 0)return;let seeded=initialTabs();patchStateFile({[key]:sessionId?{...seeded,tabs:seeded.tabs.map((t)=>t.kind==="engine"?{...t,sessionId,spawned:!0}:t)}:seeded})}catch{}}function markCliTabSession(taskId,tabId,sessionId){try{let key=terminalTabsKey(taskId);updateStateFile((store)=>{let existing=store[key];if(!existing||!Array.isArray(existing.tabs))return!1;store[key]={...existing,tabs:existing.tabs.map((t)=>t.id===tabId&&t.kind==="engine"?{...t,...sessionId?{sessionId}:{},spawned:!0}:t)};return})}catch{}}function allocateTab(taskId,build,taken=new Set){let key=terminalTabsKey(taskId),out={};if(updateStateFile((store)=>{let existing=store[key],state=existing&&Array.isArray(existing.tabs)&&existing.tabs.length>0?existing:initialTabs(),ordinal=typeof state.nextOrdinal==="number"&&state.nextOrdinal>1?state.nextOrdinal:2;while(taken.has(`tab-${ordinal}`)||state.tabs.some((t)=>t.id===`tab-${ordinal}`))ordinal++;let tab=build(`tab-${ordinal}`,ordinal);out.tab=tab,store[key]={...state,tabs:[...state.tabs,tab],activeId:tab.id,nextOrdinal:ordinal+1};return}),!out.tab)throw Error(`tab allocation for ${taskId} did not run`);return out.tab}function mintCliTab(taskId,vendor,command){try{return allocateTab(taskId,(id,ordinal)=>({kind:"engine",id,title:null,ordinal,...vendor?{vendor}:{},...command?{engineCommand:command}:{}})).id}catch{return`tab-cli-${Date.now().toString(36)}`}}async function countLiveEngineSessions(sessions,snapshot=psSnapshot){let tabs=sessions.filter((s)=>s.alive&&s.key.split("::").length===2);if(!tabs.length)return 0;let rows;try{if(rows=parsePsSnapshot(await snapshot(tabs.flatMap((s)=>s.pid?[s.pid]:[]))),!rows.length)return tabs.length}catch{return tabs.length}return tabs.filter((s)=>{if(!s.pid)return!0;let root=rows.find((row)=>row.pid===s.pid);if(!root)return!0;if(engineProcessIn(rows,s.pid)||vendorFromArgv(root.args))return!0;let[taskId,tabId]=s.key.split("::"),labelled=readTabsSnapshot(taskId)?.tabs.some((tab)=>tab.id===tabId&&tab.kind==="engine");if(tabId!=="tab-1"&&!labelled&&!sessionArgvNamesEngine(s.command))return!1;let executable=basename(root.args.split(/\s+/)[0]).toLowerCase().replace(/^-/,"").replace(/\.exe$/,"");if(["sh","bash","zsh","fish","dash","ash","ksh","mksh"].includes(executable))return/^\S+\s+-[a-zA-Z]*c\b/.test(root.args);return!0}).length}async function openAdmittedEngine(rpc,spec,opts){let limit=opts.maxLiveEngines;if(limit===void 0)return rpc.request("pty.open",spec);for(let attempt=0;attempt<20;attempt++){let{sessions,admissionToken}=await rpc.request("pty.list",{});if(typeof admissionToken!=="string")throw new ApiError("the PTY host must be updated before enforcing engine.maxLiveSessions","ENGINE_ADMISSION_UNAVAILABLE",{taskId:opts.taskId,hint:"the running PTY host predates atomic admission; update and restart the PTY host before retrying",nextCommandArgs:opts.retryArgs});let live=await countLiveEngineSessions(sessions,opts.snapshot);if(!sessions.some((s)=>s.key===spec.key&&s.alive)&&live>=limit)throw new ApiError(`${live} engine sessions are already running (engine.maxLiveSessions is ${limit})`,"ENGINE_LIMIT",{taskId:opts.taskId,live,limit,hint:"wait for an engine to finish or close a tab, then retry; raise engine.maxLiveSessions in state.json to allow more",nextCommandArgs:opts.retryArgs});let result=await rpc.request("pty.openChecked",{...spec,admissionToken});if(result.kind==="opened")return result.open}throw new ApiError("PTY inventory kept changing during engine admission; retry the send","ENGINE_ADMISSION_BUSY",{taskId:opts.taskId,nextCommandArgs:opts.retryArgs})}function restoredTabsOf(sessions,taskId,exceptKey){let prefix=`${taskId}::`,ids=[];for(let s of sessions){if(s.alive||s.restored!==!0||s.key===exceptKey||!s.key.startsWith(prefix))continue;let tab=s.key.slice(prefix.length);if(tab.includes("::"))continue;if(!ids.includes(tab))ids.push(tab)}let tabs=readTabsSnapshot(taskId)?.tabs??[];return ids.map((tab)=>{let sessionId=tabs.find((t)=>t.id===tab)?.sessionId;return sessionId?{tab,sessionId}:{tab}})}function restoredTabLaunch(task,tabId,worktreePath,shell){let tab=readTabsSnapshot(task.id)?.tabs.find((t)=>t.id===tabId&&t.kind==="engine");if(!tab)return null;let base=engineLaunchArgv({command:tab.engineCommand??(tab.vendor?void 0:task.command),vendor:tab.vendor??task.vendor,effort:task.modelEffort,model:tab.engineCommand||tab.vendor?void 0:task.model});return buildEngineSessionLaunch({task:{id:task.id,kind:task.kind??"task",vendor:tab.vendor??task.vendor,repo:task.repo},worktreePath,shell,argv:engineTabArgv(tab,base,!1,task.vendor),promptIntent:{kind:"none"},tabId})}var isTaskKey=isHostedTaskKey,findEngineKey=findHostedEngineKey,taskKeys=hostedTaskKeys,openPtyHost=openHostedSessionHost,ensurePtyHost=ensureHostedSessionHost,listSessions=listHostedSessions,listSessionsOrNull=listHostedSessionsOrNull,deliverToKey=deliverToHostedKey,ENGINE_START_PROBE_MS=3000,ENGINE_START_POLL_MS=150,ENGINE_NOT_OBSERVED_REASON=`no engine process appeared in the session within ${ENGINE_START_PROBE_MS}ms`;function outcomeFields(outcome){if(!outcome)return{engineReady:!1,delivered:!1};return{engineReady:outcome.ready,delivered:!0,bytes:outcome.bytes,promptEcho:outcome.confirmed?"confirmed":"unconfirmed"}}async function deliverHostedPrompt(rpc,target,cwd,prompt,launch,opts){let{sessions=[]}=await rpc.request("pty.list",{}),existingKey=opts?.forceNew?null:findEngineKey(sessions,target.id,target.engineBin);if(existingKey){let pid=sessions.find((s)=>s.key===existingKey)?.pid,presence=await enginePresence(pid,target.engineBin,opts?.snapshot);if(presence.kind==="unknown")throw new ApiError(`could not read the process table, so task ${target.id}'s engine tab (${existingKey}) could not be checked for a live engine`,"ENGINE_PROBE_FAILED",{hint:"the `ps` probe failed or timed out; retry, or check the machine's process table",nextCommandArgs:["api","pty-list"]});if(presence.kind!=="engine")throw new ApiError(`task ${target.id}'s engine tab (${existingKey}) has no live engine process \u2014 its engine exited into a plain shell`,"ENGINE_NOT_RUNNING",{hint:"spawn a fresh engine tab for this prompt with --tab new",nextCommandArgs:["api","send","--task-id",target.id,"--tab","new","--plain","--prompt",prompt]});let outcome=await deliverToKey(rpc,existingKey,prompt,{vendor:presence.vendor});return{session:existingKey,pane:existingKey,started:!1,...outcomeFields(outcome)}}if(!opts?.forceNew){let aliveTabs=sessions.filter((s)=>s.alive&&isTaskKey(s.key,target.id)).map((s)=>s.key);if(aliveTabs.length>0)throw new ApiError(`task ${target.id} has live tabs (${aliveTabs.join(", ")}) but none resolves as its engine tab \u2014 refusing to spawn a new engine`,"NO_ENGINE_TAB",{hint:"address a live engine tab explicitly with --tab <tab-N> (see pty-list), or spawn a fresh engine tab with --tab new",nextCommandArgs:["api","pty-list"]})}let frozen=restoredTabsOf(sessions,target.id,launch.key),disclose=frozen.length>0?{frozenTabs:frozen}:{},staleCanonical=sessions.find((session)=>session.key===launch.key&&!session.alive);if(staleCanonical&&staleCanonical.restored!==!0)await rpc.request("pty.kill",{key:launch.key});let open=await openAdmittedEngine(rpc,{key:launch.key,cwd,command:launch.command,defaultColors:readPersistedTerminalDefaultColors()},{maxLiveEngines:opts?.maxLiveEngines,snapshot:opts?.snapshot,taskId:target.id,retryArgs:opts?.retryArgs??["api","send","--task-id",target.id,...opts?.forceNew?["--tab","new"]:[],"--plain","--prompt",prompt]});try{if(!open.alive)return{session:launch.key,pane:launch.key,started:open.created!==!1||open.respawned===!0,engineReady:!1,delivered:!1,...disclose};if(launch.firstMessage){let outcome=await pastePromptWhenEngineUp(rpc,launch.key,target.engineBin,launch.firstMessage,{initMarkerPath:launch.initMarkerPath,initTimeoutMs:launch.initTimeoutMs});return{session:launch.key,pane:launch.key,started:open.created!==!1||open.respawned===!0,...outcomeFields(outcome),...disclose}}let started=open.created!==!1||open.respawned===!0;if(open.created===!1&&open.respawned!==!0){let outcome=await pastePromptWhenEngineUp(rpc,launch.key,target.engineBin,prompt,{snapshot:opts?.snapshot});return{session:launch.key,pane:launch.key,started,...outcomeFields(outcome),...disclose}}let pendingInit={session:launch.key,pane:launch.key,started,engineReady:!1,delivered:!0,reason:"repo init script is still running; the engine has not started yet",...disclose};if(launch.initMarkerPath&&!initMarkerSaysFinished(launch.initMarkerPath))return pendingInit;if(await awaitEngineProcess(rpc,launch.key,target.engineBin,{timeoutMs:ENGINE_START_PROBE_MS,intervalMs:ENGINE_START_POLL_MS,snapshot:opts?.snapshot})===null){if(launch.initMarkerPath&&!initMarkerSaysFinished(launch.initMarkerPath)&&(await listSessions(rpc)).some((session)=>session.key===launch.key&&session.alive)&&!initMarkerSaysFinished(launch.initMarkerPath))return pendingInit;return{session:launch.key,pane:launch.key,started,engineReady:!1,delivered:!1,reason:await hostedSessionFailureLine(rpc,launch.key)??ENGINE_NOT_OBSERVED_REASON,...disclose}}return{session:launch.key,pane:launch.key,started,engineReady:!0,delivered:!0,...disclose}}finally{await rpc.request("pty.detach",{key:launch.key}).catch(()=>{})}}var killTaskSessions=killHostedSessions;
2
+ import{closeTab,engineTabArgv,initialTabs,setTabTitle,tabPtyKeyFor,terminalTabsKey}from"./chunk-mdnrrj16.js";import{awaitEngineProcess,buildEngineSessionLaunch,deliverToHostedKey,enginePresence,ensureHostedSessionHost,findHostedEngineKey,hostedSessionFailureLine,hostedTaskKeys,initMarkerSaysFinished,isHostedTaskKey,killHostedSessions,listHostedSessions,listHostedSessionsOrNull,openHostedSessionHost,pastePromptWhenEngineUp,readPersistedTerminalDefaultColors,sessionArgvNamesEngine}from"./chunk-9v568ape.js";import{engineLaunchArgv}from"./chunk-mre9g9vq.js";import{engineProcessIn,parsePsSnapshot,psSnapshot,vendorFromArgv}from"./chunk-8ja7jrhc.js";import{ApiError}from"./chunk-568q390y.js";import{loadStateFile,patchStateFile,updateStateFile}from"./chunk-zk5qkkb1.js";import{basename}from"path";function wireNode(node){if(node.kind==="leaf")return{kind:"leaf",id:node.id,title:node.title??null,own:node.content===null};return{kind:"group",orientation:node.orientation,children:node.children.map(wireNode)}}function wireSplit(tree){return tree?{root:wireNode(tree.root),activeLeafId:tree.activeLeafId}:null}function taskEngineArgv(task){return engineLaunchArgv({command:task.command,vendor:task.vendor})}function readTabsSnapshot(taskId){try{let snap=loadStateFile()[terminalTabsKey(taskId)];return snap&&Array.isArray(snap.tabs)?snap:void 0}catch{return}}function closeTabsSnapshot(taskId,tabId){let closing,key=terminalTabsKey(taskId);return updateStateFile((store)=>{let state=store[key];if(!state||!Array.isArray(state.tabs))return!1;if(closing=state.tabs.find((tab)=>tab.id===tabId),!closing)return!1;let{state:next,closedId}=closeTab(state,tabId,{allowEmpty:!0});if(!closedId)return closing=void 0,!1;store[key]=next;return}),closing}function renameTabsSnapshot(taskId,tabId,title){let found=!1,key=terminalTabsKey(taskId);return updateStateFile((store)=>{let state=store[key];if(!state||!Array.isArray(state.tabs))return!1;if(!state.tabs.some((tab)=>tab.id===tabId))return!1;found=!0;let next=setTabTitle(state,tabId,title);if(next===state)return!1;store[key]=next;return}),found}var aliveKeysOf=(sessions)=>new Set(sessions.filter((s)=>s.alive).map((s)=>s.key));function unregisteredTabIds(snapshot,taskId,sessions){let known=new Set((snapshot?.tabs??[]).map((t)=>t.id)),prefix=`${taskId}::`,out=[];for(let s of sessions){if(!s.alive||!s.key.startsWith(prefix))continue;let tabId=s.key.slice(prefix.length);if(tabId.includes("::"))continue;if(!known.has(tabId)&&!out.includes(tabId))out.push(tabId)}return out}var abnormalExit=(exit)=>exit&&(exit.code!==0||exit.signal!==null)?exit:null;function joinTaskTabs(snapshot,taskId,sessions,persistedExits={},liveVendors,engineAlive){let unknown=sessions===null,rows0=sessions??[],alive=aliveKeysOf(rows0),sessionExits=new Map(rows0.map((s)=>[s.key,s.exit])),deadExit=(key)=>{let ex=abnormalExit(sessionExits.get(key)??persistedExits[key]);if(!ex)return null;let record=persistedExits[key],sameDeath=record?.at===ex.at,tail=sameDeath?record?.tail:void 0,code=ex.code??(sameDeath?record?.code??null:null),layer=record?.layer??"pty";return{code,signal:ex.signal,at:ex.at,layer,...tail&&tail.length>0?{tail}:{}}},engineExit=(key)=>{let record=persistedExits[`${key}#engine`];if(!record)return null;let{code,signal,at,tail,atApproximate}=record;return{code,signal,at,layer:"engine",...atApproximate?{atApproximate}:{},...tail&&tail.length>0?{tail}:{}}},rows=(snapshot?.tabs??[]).map((t)=>{let key=tabPtyKeyFor(taskId,t),isAlive=unknown?null:alive.has(key),walked=isAlive===!0&&liveVendors?.has(key)===!0?liveVendors.get(key)??null:void 0,engineIsAlive=engineAliveOf(key,isAlive,engineAlive);return{id:t.id,kind:t.kind,title:t.title??null,vendor:t.vendor??null,liveVendor:walked!==void 0?walked:t.liveVendor??null,lastTitle:t.lastTitle??null,autoTitle:t.autoTitle??null,alive:isAlive,engineAlive:engineIsAlive,exit:isAlive===!1?deadExit(key):engineIsAlive===!1?engineExit(key):null,...t.splitTree?{split:wireSplit(t.splitTree)}:{},...t.kind==="engine"&&t.ptyTask?{viewOf:t.ptyTask.id}:{}}});for(let tabId of unregisteredTabIds(snapshot,taskId,rows0))rows.push({id:tabId,kind:"engine",title:null,vendor:null,liveVendor:null,lastTitle:null,autoTitle:null,alive:!0,engineAlive:engineAliveOf(`${taskId}::${tabId}`,!0,engineAlive),exit:null,unregistered:!0});return rows}function engineAliveOf(key,isAlive,engineAlive){if(isAlive===null)return null;if(!isAlive)return!1;return engineAlive?.has(key)===!0?engineAlive.get(key)??null:null}function publishCliTabSnapshot(taskId,sessionId){if(!taskId)return;try{let key=terminalTabsKey(taskId);if(loadStateFile()[key]!==void 0)return;let seeded=initialTabs();patchStateFile({[key]:sessionId?{...seeded,tabs:seeded.tabs.map((t)=>t.kind==="engine"?{...t,sessionId,spawned:!0}:t)}:seeded})}catch{}}function markCliTabSession(taskId,tabId,sessionId){try{let key=terminalTabsKey(taskId);updateStateFile((store)=>{let existing=store[key];if(!existing||!Array.isArray(existing.tabs))return!1;store[key]={...existing,tabs:existing.tabs.map((t)=>t.id===tabId&&t.kind==="engine"?{...t,...sessionId?{sessionId}:{},spawned:!0}:t)};return})}catch{}}function allocateTab(taskId,build,taken=new Set){let key=terminalTabsKey(taskId),out={};if(updateStateFile((store)=>{let existing=store[key],state=existing&&Array.isArray(existing.tabs)&&existing.tabs.length>0?existing:initialTabs(),ordinal=typeof state.nextOrdinal==="number"&&state.nextOrdinal>1?state.nextOrdinal:2;while(taken.has(`tab-${ordinal}`)||state.tabs.some((t)=>t.id===`tab-${ordinal}`))ordinal++;let tab=build(`tab-${ordinal}`,ordinal);out.tab=tab,store[key]={...state,tabs:[...state.tabs,tab],activeId:tab.id,nextOrdinal:ordinal+1};return}),!out.tab)throw Error(`tab allocation for ${taskId} did not run`);return out.tab}function mintCliTab(taskId,vendor,command){try{return allocateTab(taskId,(id,ordinal)=>({kind:"engine",id,title:null,ordinal,...vendor?{vendor}:{},...command?{engineCommand:command}:{}})).id}catch{return`tab-cli-${Date.now().toString(36)}`}}async function countLiveEngineSessions(sessions,snapshot=psSnapshot){let tabs=sessions.filter((s)=>s.alive&&s.key.split("::").length===2);if(!tabs.length)return 0;let rows;try{if(rows=parsePsSnapshot(await snapshot(tabs.flatMap((s)=>s.pid?[s.pid]:[]))),!rows.length)return tabs.length}catch{return tabs.length}return tabs.filter((s)=>{if(!s.pid)return!0;let root=rows.find((row)=>row.pid===s.pid);if(!root)return!0;if(engineProcessIn(rows,s.pid)||vendorFromArgv(root.args))return!0;let[taskId,tabId]=s.key.split("::"),labelled=readTabsSnapshot(taskId)?.tabs.some((tab)=>tab.id===tabId&&tab.kind==="engine");if(tabId!=="tab-1"&&!labelled&&!sessionArgvNamesEngine(s.command))return!1;let executable=basename(root.args.split(/\s+/)[0]).toLowerCase().replace(/^-/,"").replace(/\.exe$/,"");if(["sh","bash","zsh","fish","dash","ash","ksh","mksh"].includes(executable))return/^\S+\s+-[a-zA-Z]*c\b/.test(root.args);return!0}).length}async function openAdmittedEngine(rpc,spec,opts){let limit=opts.maxLiveEngines;if(limit===void 0)return rpc.request("pty.open",spec);for(let attempt=0;attempt<20;attempt++){let{sessions,admissionToken}=await rpc.request("pty.list",{});if(typeof admissionToken!=="string")throw new ApiError("the PTY host must be updated before enforcing engine.maxLiveSessions","ENGINE_ADMISSION_UNAVAILABLE",{taskId:opts.taskId,hint:"the running PTY host predates atomic admission; update and restart the PTY host before retrying",nextCommandArgs:opts.retryArgs});let live=await countLiveEngineSessions(sessions,opts.snapshot);if(!sessions.some((s)=>s.key===spec.key&&s.alive)&&live>=limit)throw new ApiError(`${live} engine sessions are already running (engine.maxLiveSessions is ${limit})`,"ENGINE_LIMIT",{taskId:opts.taskId,live,limit,hint:"wait for an engine to finish or close a tab, then retry; raise engine.maxLiveSessions in state.json to allow more",nextCommandArgs:opts.retryArgs});let result=await rpc.request("pty.openChecked",{...spec,admissionToken});if(result.kind==="opened")return result.open}throw new ApiError("PTY inventory kept changing during engine admission; retry the send","ENGINE_ADMISSION_BUSY",{taskId:opts.taskId,nextCommandArgs:opts.retryArgs})}function restoredTabsOf(sessions,taskId,exceptKey){let prefix=`${taskId}::`,ids=[];for(let s of sessions){if(s.alive||s.restored!==!0||s.key===exceptKey||!s.key.startsWith(prefix))continue;let tab=s.key.slice(prefix.length);if(tab.includes("::"))continue;if(!ids.includes(tab))ids.push(tab)}let tabs=readTabsSnapshot(taskId)?.tabs??[];return ids.map((tab)=>{let sessionId=tabs.find((t)=>t.id===tab)?.sessionId;return sessionId?{tab,sessionId}:{tab}})}function restoredTabLaunch(task,tabId,worktreePath,shell){let tab=readTabsSnapshot(task.id)?.tabs.find((t)=>t.id===tabId&&t.kind==="engine");if(!tab)return null;let base=engineLaunchArgv({command:tab.engineCommand??(tab.vendor?void 0:task.command),vendor:tab.vendor??task.vendor,effort:task.modelEffort,model:tab.engineCommand||tab.vendor?void 0:task.model});return buildEngineSessionLaunch({task:{id:task.id,kind:task.kind??"task",vendor:tab.vendor??task.vendor,repo:task.repo},worktreePath,shell,argv:engineTabArgv(tab,base,!1,task.vendor),promptIntent:{kind:"none"},tabId})}var isTaskKey=isHostedTaskKey,findEngineKey=findHostedEngineKey,taskKeys=hostedTaskKeys,openPtyHost=openHostedSessionHost,ensurePtyHost=ensureHostedSessionHost,listSessions=listHostedSessions,listSessionsOrNull=listHostedSessionsOrNull,deliverToKey=deliverToHostedKey,ENGINE_START_PROBE_MS=3000,ENGINE_START_POLL_MS=150,ENGINE_NOT_OBSERVED_REASON=`no engine process appeared in the session within ${ENGINE_START_PROBE_MS}ms`;function outcomeFields(outcome){if(!outcome)return{engineReady:!1,delivered:!1};return{engineReady:outcome.ready,delivered:!0,bytes:outcome.bytes,promptEcho:outcome.confirmed?"confirmed":"unconfirmed"}}async function deliverHostedPrompt(rpc,target,cwd,prompt,launch,opts){let{sessions=[]}=await rpc.request("pty.list",{}),existingKey=opts?.forceNew?null:findEngineKey(sessions,target.id,target.engineBin);if(existingKey){let pid=sessions.find((s)=>s.key===existingKey)?.pid,presence=await enginePresence(pid,target.engineBin,opts?.snapshot);if(presence.kind==="unknown")throw new ApiError(`could not read the process table, so task ${target.id}'s engine tab (${existingKey}) could not be checked for a live engine`,"ENGINE_PROBE_FAILED",{hint:"the `ps` probe failed or timed out; retry, or check the machine's process table",nextCommandArgs:["api","pty-list"]});if(presence.kind!=="engine")throw new ApiError(`task ${target.id}'s engine tab (${existingKey}) has no live engine process \u2014 its engine exited into a plain shell`,"ENGINE_NOT_RUNNING",{hint:"spawn a fresh engine tab for this prompt with --tab new",nextCommandArgs:["api","send","--task-id",target.id,"--tab","new","--plain","--prompt",prompt]});let outcome=await deliverToKey(rpc,existingKey,prompt,{vendor:presence.vendor});return{session:existingKey,pane:existingKey,started:!1,...outcomeFields(outcome)}}if(!opts?.forceNew){let aliveTabs=sessions.filter((s)=>s.alive&&isTaskKey(s.key,target.id)).map((s)=>s.key);if(aliveTabs.length>0)throw new ApiError(`task ${target.id} has live tabs (${aliveTabs.join(", ")}) but none resolves as its engine tab \u2014 refusing to spawn a new engine`,"NO_ENGINE_TAB",{hint:"address a live engine tab explicitly with --tab <tab-N> (see pty-list), or spawn a fresh engine tab with --tab new",nextCommandArgs:["api","pty-list"]})}let frozen=restoredTabsOf(sessions,target.id,launch.key),disclose=frozen.length>0?{frozenTabs:frozen}:{},staleCanonical=sessions.find((session)=>session.key===launch.key&&!session.alive);if(staleCanonical&&staleCanonical.restored!==!0)await rpc.request("pty.kill",{key:launch.key});let open=await openAdmittedEngine(rpc,{key:launch.key,cwd,command:launch.command,defaultColors:readPersistedTerminalDefaultColors()},{maxLiveEngines:opts?.maxLiveEngines,snapshot:opts?.snapshot,taskId:target.id,retryArgs:opts?.retryArgs??["api","send","--task-id",target.id,...opts?.forceNew?["--tab","new"]:[],"--plain","--prompt",prompt]});try{if(!open.alive)return{session:launch.key,pane:launch.key,started:open.created!==!1||open.respawned===!0,engineReady:!1,delivered:!1,...disclose};if(launch.firstMessage){let outcome=await pastePromptWhenEngineUp(rpc,launch.key,target.engineBin,launch.firstMessage,{initMarkerPath:launch.initMarkerPath,initTimeoutMs:launch.initTimeoutMs});return{session:launch.key,pane:launch.key,started:open.created!==!1||open.respawned===!0,...outcomeFields(outcome),...disclose}}let started=open.created!==!1||open.respawned===!0;if(open.created===!1&&open.respawned!==!0){let outcome=await pastePromptWhenEngineUp(rpc,launch.key,target.engineBin,prompt,{snapshot:opts?.snapshot});return{session:launch.key,pane:launch.key,started,...outcomeFields(outcome),...disclose}}let pendingInit={session:launch.key,pane:launch.key,started,engineReady:!1,delivered:!0,reason:"repo init script is still running; the engine has not started yet",...disclose};if(launch.initMarkerPath&&!initMarkerSaysFinished(launch.initMarkerPath))return pendingInit;if(await awaitEngineProcess(rpc,launch.key,target.engineBin,{timeoutMs:ENGINE_START_PROBE_MS,intervalMs:ENGINE_START_POLL_MS,snapshot:opts?.snapshot})===null){if(launch.initMarkerPath&&!initMarkerSaysFinished(launch.initMarkerPath)&&(await listSessions(rpc)).some((session)=>session.key===launch.key&&session.alive)&&!initMarkerSaysFinished(launch.initMarkerPath))return pendingInit;return{session:launch.key,pane:launch.key,started,engineReady:!1,delivered:!1,reason:await hostedSessionFailureLine(rpc,launch.key)??ENGINE_NOT_OBSERVED_REASON,...disclose}}return{session:launch.key,pane:launch.key,started,engineReady:!0,delivered:!0,...disclose}}finally{await rpc.request("pty.detach",{key:launch.key}).catch(()=>{})}}var killTaskSessions=killHostedSessions;
3
3
  export{wireSplit,taskEngineArgv,readTabsSnapshot,closeTabsSnapshot,renameTabsSnapshot,unregisteredTabIds,joinTaskTabs,publishCliTabSnapshot,markCliTabSession,allocateTab,mintCliTab,openAdmittedEngine,restoredTabLaunch,isTaskKey,findEngineKey,taskKeys,openPtyHost,ensurePtyHost,listSessions,listSessionsOrNull,deliverToKey,ENGINE_START_PROBE_MS,ENGINE_START_POLL_MS,ENGINE_NOT_OBSERVED_REASON,outcomeFields,deliverHostedPrompt,killTaskSessions};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{TaskIndexStore}from"./chunk-h7y9v8k1.js";import"./chunk-qkehg2c1.js";import"./chunk-qzsahxd9.js";import"./chunk-xy8be792.js";import"./chunk-h2m7em1e.js";import"./chunk-tdhk4dz8.js";import"./chunk-mw0ysrpd.js";import"./chunk-a7kq09ke.js";import"./chunk-zt7wfnva.js";import"./chunk-yt15y085.js";import"./chunk-hq9tbzqa.js";import"./chunk-npwzmmv9.js";import"./chunk-b39sdtt0.js";import"./chunk-nc46gddg.js";import"./chunk-wqfp8d9w.js";export{TaskIndexStore};
2
+ import{TaskIndexStore}from"./chunk-h7y9v8k1.js";import"./chunk-qkehg2c1.js";import"./chunk-qzsahxd9.js";import"./chunk-xy8be792.js";import"./chunk-h2m7em1e.js";import"./chunk-tdhk4dz8.js";import"./chunk-mw0ysrpd.js";import"./chunk-a7kq09ke.js";import"./chunk-zt7wfnva.js";import"./chunk-yt15y085.js";import"./chunk-hq9tbzqa.js";import"./chunk-npwzmmv9.js";import"./chunk-b39sdtt0.js";import"./chunk-nc46gddg.js";import"./chunk-91sykzqq.js";export{TaskIndexStore};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{SUBCOMMAND_VERBS}from"./chunk-e1x88j3k.js";import{NPX_MISSING_EXIT,bundledSkillDir,installedSkillDiffersFromBundled,npxSkillsCommand,roveSkillPaths,roveSkillState,runNpxSkillsInstall}from"./chunk-rvqse0aa.js";import"./chunk-h9cg0j3a.js";import"./chunk-40dgv828.js";import"./chunk-3342qzve.js";import"./chunk-7q43tysm.js";import"./chunk-mw0ysrpd.js";import"./chunk-a7kq09ke.js";import"./chunk-prqeddy7.js";import{ROVE_PRODUCT_NAME}from"./chunk-zt7wfnva.js";import"./chunk-yt15y085.js";import"./chunk-pn5ygqn6.js";import"./chunk-npwzmmv9.js";import"./chunk-b39sdtt0.js";import"./chunk-nc46gddg.js";import{__require}from"./chunk-wqfp8d9w.js";import{existsSync,readFileSync}from"fs";import{join}from"path";var CLI_NAME=ROVE_PRODUCT_NAME,SKILL_VERBS=SUBCOMMAND_VERBS.skill;function skillUsage(){return[`usage: ${CLI_NAME} skill <verb>`,"","verbs:"," install [--global|-g | --project|-p] [--agent NAME]\u2026 Install the Rove agent skill (wraps `npx skills add`)"," status Show whether the skill is installed"," command [--global|-g | --project|-p] [--agent NAME]\u2026 Print the underlying npx command without running it",` print Print the bundled SKILL.md (also: \`${CLI_NAME} --skill\`)`,"",`The skill teaches a coding agent how to drive \`${CLI_NAME} api\`. Installs are`,"global (user-level) by default; --global/-g says so explicitly, --project/-p","installs into the current project instead. With no --agent, the agent-skills","CLI detects your installed agents and asks; repeat --agent to name them","(e.g. --agent claude-code --agent codex)."].join(`
2
+ import{SUBCOMMAND_VERBS}from"./chunk-e1x88j3k.js";import{NPX_MISSING_EXIT,bundledSkillDir,installedSkillDiffersFromBundled,npxSkillsCommand,roveSkillPaths,roveSkillState,runNpxSkillsInstall}from"./chunk-6h0n4b5t.js";import"./chunk-21ek142k.js";import"./chunk-40dgv828.js";import"./chunk-3342qzve.js";import"./chunk-zk5qkkb1.js";import"./chunk-mw0ysrpd.js";import"./chunk-a7kq09ke.js";import"./chunk-prqeddy7.js";import{ROVE_PRODUCT_NAME}from"./chunk-zt7wfnva.js";import"./chunk-yt15y085.js";import"./chunk-pn5ygqn6.js";import"./chunk-npwzmmv9.js";import"./chunk-b39sdtt0.js";import"./chunk-nc46gddg.js";import{__require}from"./chunk-91sykzqq.js";import{existsSync,readFileSync}from"fs";import{join}from"path";var CLI_NAME=ROVE_PRODUCT_NAME,SKILL_VERBS=SUBCOMMAND_VERBS.skill;function skillUsage(){return[`usage: ${CLI_NAME} skill <verb>`,"","verbs:"," install [--global|-g | --project|-p] [--agent NAME]\u2026 Install the Rove agent skill (wraps `npx skills add`)"," status Show whether the skill is installed"," command [--global|-g | --project|-p] [--agent NAME]\u2026 Print the underlying npx command without running it",` print Print the bundled SKILL.md (also: \`${CLI_NAME} --skill\`)`,"",`The skill teaches a coding agent how to drive \`${CLI_NAME} api\`. Installs are`,"global (user-level) by default; --global/-g says so explicitly, --project/-p","installs into the current project instead. With no --agent, the agent-skills","CLI detects your installed agents and asks; repeat --agent to name them","(e.g. --agent claude-code --agent codex)."].join(`
3
3
  `)}function parseInstallFlags(rest){let global=!0,agents=[];for(let i=0;i<rest.length;i++){let arg=rest[i];if(arg==="--project"||arg==="-p")global=!1;else if(arg==="--global"||arg==="-g")global=!0;else if(arg==="--agent"){let v=rest[i+1];if(!v||v.startsWith("--"))process.stderr.write(`${CLI_NAME} skill: --agent requires a value
4
4
  `),process.exit(2);agents.push(v),i++}else if(arg.startsWith("--agent="))agents.push(arg.slice(8));else process.stderr.write(`${CLI_NAME} skill: unknown flag "${arg}"
5
5
 
@@ -11,7 +11,7 @@ ${skillUsage()}
11
11
 
12
12
  ${skillUsage()}
13
13
  `),process.exit(2);if(verb==="print"){let bundled2=bundledSkillDir(),path=bundled2?join(bundled2,"SKILL.md"):roveSkillPaths().find((p)=>existsSync(p));if(!path)process.stderr.write(`${CLI_NAME} skill: no SKILL.md found (not bundled, not installed) \u2014 run \`${CLI_NAME} skill install\`
14
- `),process.exit(1);process.stdout.write(readFileSync(path,"utf8"));return}if(verb==="status"){let{isRovePluginEnabled}=await import("./chunk-8mfpv3fh.js"),state=roveSkillState(),paths=roveSkillPaths(),pluginNote=isRovePluginEnabled()?` note: the Rove Claude Code plugin is enabled \u2014 for Claude Code the skill ships
14
+ `),process.exit(1);process.stdout.write(readFileSync(path,"utf8"));return}if(verb==="status"){let{isRovePluginEnabled}=await import("./chunk-rt4tg426.js"),state=roveSkillState(),paths=roveSkillPaths(),pluginNote=isRovePluginEnabled()?` note: the Rove Claude Code plugin is enabled \u2014 for Claude Code the skill ships
15
15
  inside the plugin and versions with it (staleness prompts are suppressed).
16
16
  `:"",head=!state.installed?"\u2717 not installed":state.stale?`\u26A0 out of date (installed ${state.installedVersion===null?"unstamped":`v${state.installedVersion}`}, this Rove wants v${state.currentVersion})`:`\u2713 installed (v${state.installedVersion})`,contentDrift=state.installed&&!state.stale&&!!state.path&&installedSkillDiffersFromBundled(state.path);process.stdout.write([`${CLI_NAME} skill: ${head}`,...contentDrift?[" \u26A0 content differs from the copy bundled with this Rove at the same version \u2014",` run \`${CLI_NAME} --skill > ${state.path}\` to refresh it`]:[],` looked in: ${paths.join(`
17
17
  `)}`,state.installed&&!state.stale?"":` \u2192 run \`${CLI_NAME} skill install\` to install / refresh`,""].join(`
@@ -21,5 +21,5 @@ ${bundled?"":`${CLI_NAME} skill: no bundled skill found \u2014 falling back to a
21
21
  `}`);let code=await runNpxSkillsInstall(agents,global);if(code!==0){if(code!==NPX_MISSING_EXIT)process.stderr.write(`
22
22
  ${CLI_NAME} skill install failed (npx exited ${code}).
23
23
  You can run it yourself: ${npxSkillsCommand({agent:agents,global})}
24
- `);process.exit(code||1)}if(global){let{settleWelcomeInstall}=await import("./chunk-2kshjtcs.js");settleWelcomeInstall("skill")}process.stdout.write(`${CLI_NAME} skill: installed.
24
+ `);process.exit(code||1)}if(global){let{settleWelcomeInstall}=await import("./chunk-mnm9n2vr.js");settleWelcomeInstall("skill")}process.stdout.write(`${CLI_NAME} skill: installed.
25
25
  `)}export{runSkillSubcommand};
@@ -1,12 +1,12 @@
1
1
  // @bun
2
- import{discoverMachine}from"./chunk-wtb8cycx.js";import{addMachine,defaultMachineAlias,duplicateAliasOf,getMachine,isValidMachineAlias,listMachines,machineSocketDir,parseSshTarget,readMachines,removeMachine,sanitizeAlias,setMachineIdentity,sshTargetOf}from"./chunk-9aydqazr.js";import{loadStateFile}from"./chunk-7q43tysm.js";import"./chunk-mw0ysrpd.js";import"./chunk-a7kq09ke.js";import"./chunk-prqeddy7.js";import{ROVE_PRODUCT_NAME}from"./chunk-zt7wfnva.js";import"./chunk-yt15y085.js";import"./chunk-npwzmmv9.js";import"./chunk-b39sdtt0.js";import"./chunk-nc46gddg.js";import{__require}from"./chunk-wqfp8d9w.js";var CLI_NAME=ROVE_PRODUCT_NAME,MACHINE_USAGE=[`Usage: ${CLI_NAME} machine <add|remove|list> [options]`,"","Manage the other computers running Rove. Each one is reached over SSH;","its tasks appear in the sidebar under a row of its own.","","Commands:"," add <ssh-target> Register a machine (verifies it before saving)"," remove <alias> Forget a machine (nothing on it is touched)"," list Show registered machines","","Add options:"," --alias <name> Local name for the machine (default: the target you typed)"," --port <n> SSH port (default: whatever ssh_config says)"," --identity <file> SSH private key (default: ssh-agent / ssh_config)",""," <ssh-target> is [user@]host[:port] \u2014 usually just an ssh_config Host alias."," The machine must already have Rove installed (`npm i -g @sma1lboy/rove`).",""].join(`
2
+ import{discoverMachine}from"./chunk-dcjxtwdb.js";import{addMachine,defaultMachineAlias,duplicateAliasOf,getMachine,isValidMachineAlias,listMachines,machineSocketDir,parseSshTarget,readMachines,removeMachine,sanitizeAlias,setMachineIdentity,sshTargetOf}from"./chunk-q854fweb.js";import{loadStateFile}from"./chunk-zk5qkkb1.js";import"./chunk-mw0ysrpd.js";import"./chunk-a7kq09ke.js";import"./chunk-prqeddy7.js";import{ROVE_PRODUCT_NAME}from"./chunk-zt7wfnva.js";import"./chunk-yt15y085.js";import"./chunk-npwzmmv9.js";import"./chunk-b39sdtt0.js";import"./chunk-nc46gddg.js";import{__require}from"./chunk-91sykzqq.js";var CLI_NAME=ROVE_PRODUCT_NAME,MACHINE_USAGE=[`Usage: ${CLI_NAME} machine <add|remove|list> [options]`,"","Manage the other computers running Rove. Each one is reached over SSH;","its tasks appear in the sidebar under a row of its own.","","Commands:"," add <ssh-target> Register a machine (verifies it before saving)"," remove <alias> Forget a machine (nothing on it is touched)"," list Show registered machines","","Add options:"," --alias <name> Local name for the machine (default: the target you typed)"," --port <n> SSH port (default: whatever ssh_config says)"," --identity <file> SSH private key (default: ssh-agent / ssh_config)",""," <ssh-target> is [user@]host[:port] \u2014 usually just an ssh_config Host alias."," The machine must already have Rove installed (`npm i -g @sma1lboy/rove`).",""].join(`
3
3
  `);function usageError(message){process.stderr.write(`${CLI_NAME} machine: ${message}
4
4
 
5
5
  ${MACHINE_USAGE}
6
6
  `),process.exit(2)}function fail(message){process.stderr.write(`${CLI_NAME} machine: ${message}
7
7
  `),process.exit(1)}function flagValue(argv,name){for(let i=0;i<argv.length;i++){let arg=argv[i];if(arg===void 0)continue;if(arg.startsWith(`--${name}=`))return arg.slice(name.length+3);if(arg!==`--${name}`)continue;let value=argv[i+1];if(value===void 0||value.startsWith("--"))usageError(`--${name} needs a value`);return value}return}async function runMachineSubcommand(argv){let[verb,...rest]=argv;if(!verb||verb==="--help"||verb==="-h"||verb==="help"){process.stdout.write(`${MACHINE_USAGE}
8
8
  `);return}if(verb==="list")return list();if(verb==="add")return await add(rest);if(verb==="remove")return remove(rest);usageError(`unknown verb "${verb}"`)}async function add(argv){let target=positionalOf(argv);if(!target)usageError("add needs an ssh target, e.g. `machine add narwhal`");let parsed=parseSshTarget(target);if(!parsed)usageError(`"${target}" is not a valid ssh target ([user@]host[:port])`);let portFlag=flagValue(argv,"port"),port=portFlag?Number(portFlag):parsed.port;if(port!==void 0&&(!Number.isInteger(port)||port<1||port>65535))usageError("--port must be 1-65535");let identity=flagValue(argv,"identity"),requested=flagValue(argv,"alias");if(requested&&!isValidMachineAlias(requested))usageError(`--alias must be letters/digits/._- and cannot be "local" (got "${requested}")`);let probeAlias=requested??sanitizeAlias(parsed.host),config={host:parsed.host,...parsed.user?{user:parsed.user}:{},...port?{port}:{},auth:identity?{kind:"key",keyPath:identity}:{kind:"key"}};process.stderr.write(`${CLI_NAME} machine: contacting ${sshTargetOf(config)}\u2026
9
- `);let found=await discoverMachine(probeAlias,config);if(!found.ok)fail(found.message);let alias=requested??defaultMachineAlias({typedHost:parsed.host,typedUser:parsed.user,port,remoteHostname:found.status.hostname});if(!isValidMachineAlias(alias))fail(`could not derive a usable alias from "${found.status.hostname}" \u2014 pass --alias`);let identityTriple={hostname:found.status.hostname,homeDir:found.status.homeDir,daemonPid:found.status.daemonPid},duplicate=duplicateAliasOf(readMachines(loadStateFile()),alias,identityTriple),sockets={daemon:found.status.socketPath,pty:found.status.ptySocketPath};addMachine(alias,{...config,identity:identityTriple,sockets}),setMachineIdentity(alias,identityTriple);let{ensureForwards}=await import("./chunk-3c58659p.js"),up=await ensureForwards({alias,config,remoteDaemonSocket:sockets.daemon,remotePtySocket:sockets.pty});if(process.stdout.write(`${CLI_NAME} machine: ${alias} \u2192 ${sshTargetOf(config)} (rove ${found.status.roveVersion||"?"} on ${found.status.hostname||"?"})
9
+ `);let found=await discoverMachine(probeAlias,config);if(!found.ok)fail(found.message);let alias=requested??defaultMachineAlias({typedHost:parsed.host,typedUser:parsed.user,port,remoteHostname:found.status.hostname});if(!isValidMachineAlias(alias))fail(`could not derive a usable alias from "${found.status.hostname}" \u2014 pass --alias`);let identityTriple={hostname:found.status.hostname,homeDir:found.status.homeDir,daemonPid:found.status.daemonPid},duplicate=duplicateAliasOf(readMachines(loadStateFile()),alias,identityTriple),sockets={daemon:found.status.socketPath,pty:found.status.ptySocketPath};addMachine(alias,{...config,identity:identityTriple,sockets}),setMachineIdentity(alias,identityTriple);let{ensureForwards}=await import("./chunk-6f01fsje.js"),up=await ensureForwards({alias,config,remoteDaemonSocket:sockets.daemon,remotePtySocket:sockets.pty});if(process.stdout.write(`${CLI_NAME} machine: ${alias} \u2192 ${sshTargetOf(config)} (rove ${found.status.roveVersion||"?"} on ${found.status.hostname||"?"})
10
10
  `),!up)process.stderr.write(`${CLI_NAME} machine: registered, but could not forward ${alias}'s socket yet \u2014 it will show as offline until the connection comes up
11
11
  `);if(duplicate)process.stdout.write(`${CLI_NAME} machine: ${alias} is the same machine as ${duplicate} (hostname/homeDir/pid match) \u2014 the sidebar shows one row
12
12
  `)}function remove(argv){let alias=argv[0];if(!alias)usageError("remove needs an alias, e.g. `machine remove narwhal`");if(!getMachine(alias))fail(`no machine named "${alias}" (see \`${CLI_NAME} machine list\`)`);removeMachine(alias),process.stdout.write(`${CLI_NAME} machine: removed ${alias}. Nothing on that machine was changed \u2014 its daemon, tasks and worktrees are untouched.
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{__require}from"./chunk-wqfp8d9w.js";var CHANNEL_LOADERS={weixin:async()=>(await import("./chunk-d5xc67hp.js")).default};async function runChannelCli(id,argv){let load=CHANNEL_LOADERS[id];if(!load)throw Error(`no chat channel "${id}"`);await(await load()).runCli(argv)}async function startChatChannels(ctx){let started=[];for(let[id,load]of Object.entries(CHANNEL_LOADERS))try{let channel=(await load()).createChannel();await channel.start(ctx),started.push(channel)}catch(err){ctx.log("channel",`${id} did not start: ${err instanceof Error?err.message:String(err)}`)}return started}
2
+ import{__require}from"./chunk-91sykzqq.js";var CHANNEL_LOADERS={weixin:async()=>(await import("./chunk-jrdwedn2.js")).default};async function runChannelCli(id,argv){let load=CHANNEL_LOADERS[id];if(!load)throw Error(`no chat channel "${id}"`);await(await load()).runCli(argv)}async function startChatChannels(ctx){let started=[];for(let[id,load]of Object.entries(CHANNEL_LOADERS))try{let channel=(await load()).createChannel();await channel.start(ctx),started.push(channel)}catch(err){ctx.log("channel",`${id} did not start: ${err instanceof Error?err.message:String(err)}`)}return started}
3
3
  export{runChannelCli,startChatChannels};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{pluginConfigDir,pluginStateDir}from"./chunk-86tw1190.js";function buildPluginEnv(opts){let configDir=pluginConfigDir(opts.pluginId,opts.homeDir),stateDir=pluginStateDir(opts.pluginId,opts.homeDir),extra=withPluginEnvAliases(opts.extra??{});return{...process.env,...opts.homeDir?{ROVE_HOME_DIR:opts.homeDir}:{},ROVE_SOCKET_PATH:opts.socketPath,ROVE_BIN_PATH:opts.binPath,ROVE_PLUGIN_ID:opts.pluginId,ROVE_PLUGIN_ROOT:opts.pluginRoot,ROVE_PLUGIN_CONFIG_DIR:configDir,ROVE_PLUGIN_STATE_DIR:stateDir,...extra}}function withPluginEnvAliases(values){let aliases={};for(let[key,value]of Object.entries(values))if(key.startsWith("ROVE_"))aliases[`ROVE_${key.slice(5)}`]=value;else if(key.startsWith("ROVE_"))aliases[`ROVE_${key.slice(5)}`]=value;return{...aliases,...values}}
2
+ import{pluginConfigDir,pluginStateDir}from"./chunk-vd8qqev9.js";function buildPluginEnv(opts){let configDir=pluginConfigDir(opts.pluginId,opts.homeDir),stateDir=pluginStateDir(opts.pluginId,opts.homeDir),extra=withPluginEnvAliases(opts.extra??{});return{...process.env,...opts.homeDir?{ROVE_HOME_DIR:opts.homeDir}:{},ROVE_SOCKET_PATH:opts.socketPath,ROVE_BIN_PATH:opts.binPath,ROVE_PLUGIN_ID:opts.pluginId,ROVE_PLUGIN_ROOT:opts.pluginRoot,ROVE_PLUGIN_CONFIG_DIR:configDir,ROVE_PLUGIN_STATE_DIR:stateDir,...extra}}function withPluginEnvAliases(values){let aliases={};for(let[key,value]of Object.entries(values))if(key.startsWith("ROVE_"))aliases[`ROVE_${key.slice(5)}`]=value;else if(key.startsWith("ROVE_"))aliases[`ROVE_${key.slice(5)}`]=value;return{...aliases,...values}}
3
3
  export{buildPluginEnv};