@sma1lboy/rove 0.9.251-nightly.20261020 → 0.9.252

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 (134) hide show
  1. package/dist/cli/{chunk-dexythnk.js → chunk-032g0ahy.js} +1 -1
  2. package/dist/cli/{chunk-84bmcqyz.js → chunk-07jq0271.js} +1 -1
  3. package/dist/cli/{chunk-q9p4d9vr.js → chunk-0gxa04rx.js} +1 -1
  4. package/dist/cli/{chunk-eg2wzscx.js → chunk-17pg88dq.js} +10 -6
  5. package/dist/cli/chunk-1qge84t7.js +3 -0
  6. package/dist/cli/{chunk-n2t1ffne.js → chunk-1tebqkdv.js} +1 -1
  7. package/dist/cli/{chunk-crdyt04z.js → chunk-1v8y9xtk.js} +1 -1
  8. package/dist/cli/chunk-1zwp3ase.js +2 -0
  9. package/dist/cli/{chunk-8ja7jrhc.js → chunk-24dryfqb.js} +1 -1
  10. package/dist/cli/{chunk-3rbrwfe2.js → chunk-25867jnk.js} +1 -1
  11. package/dist/cli/{chunk-28wjmb9f.js → chunk-2bp01vf2.js} +1 -1
  12. package/dist/cli/{chunk-mv9f3b5g.js → chunk-2bxts9pp.js} +1 -1
  13. package/dist/cli/{chunk-kgw1kzk4.js → chunk-2g2w5vvn.js} +1 -1
  14. package/dist/cli/{chunk-a6mhccf6.js → chunk-2ks86x2d.js} +1 -1
  15. package/dist/cli/{chunk-z0ndesj6.js → chunk-2n1n70f2.js} +1 -1
  16. package/dist/cli/{chunk-gse10w1v.js → chunk-2rfyjb3y.js} +1 -1
  17. package/dist/cli/{chunk-71bsnsm3.js → chunk-2s762g8n.js} +1 -1
  18. package/dist/cli/{chunk-wwfatcxr.js → chunk-34468esa.js} +1 -1
  19. package/dist/cli/{chunk-ar03ag32.js → chunk-36pkmg07.js} +15 -15
  20. package/dist/cli/{chunk-6h0n4b5t.js → chunk-4ays3krf.js} +1 -1
  21. package/dist/cli/{chunk-qd3hraax.js → chunk-4e1wcgw7.js} +3 -3
  22. package/dist/cli/{chunk-d28kyy8z.js → chunk-564jgrb3.js} +1 -1
  23. package/dist/cli/{chunk-wa9jgthq.js → chunk-57wm48dh.js} +1 -1
  24. package/dist/cli/{chunk-x5c3fap3.js → chunk-5hhr44fc.js} +1 -1
  25. package/dist/cli/{chunk-fkrwqgcy.js → chunk-5q08srg6.js} +1 -1
  26. package/dist/cli/chunk-5qxp7xx3.js +2 -0
  27. package/dist/cli/{chunk-6xh5nbd3.js → chunk-6a4xqzqf.js} +3 -3
  28. package/dist/cli/{chunk-0jc516f2.js → chunk-7h7270rz.js} +3 -3
  29. package/dist/cli/{chunk-hkr8r1sg.js → chunk-7j00hbq5.js} +1 -1
  30. package/dist/cli/chunk-7zxf47xb.js +2 -0
  31. package/dist/cli/chunk-8e0nmegv.js +2 -0
  32. package/dist/cli/{chunk-p9d26ma8.js → chunk-952aedqm.js} +1 -1
  33. package/dist/cli/{chunk-x33sm4rp.js → chunk-9dregrj6.js} +1 -1
  34. package/dist/cli/{chunk-52aq1xs5.js → chunk-9e21z4gn.js} +1 -1
  35. package/dist/cli/chunk-9mcpqrx8.js +2 -0
  36. package/dist/cli/{chunk-kq8mywzd.js → chunk-9sta3ak4.js} +1 -1
  37. package/dist/cli/chunk-a1wjg2cv.js +3 -0
  38. package/dist/cli/{chunk-v312167r.js → chunk-axmpjma9.js} +1 -1
  39. package/dist/cli/{chunk-y92xbk2f.js → chunk-ayhkcv0w.js} +3 -3
  40. package/dist/cli/{chunk-e003wm6d.js → chunk-b67pjyyg.js} +1 -1
  41. package/dist/cli/{chunk-2apszxn2.js → chunk-b7xjhgts.js} +1 -1
  42. package/dist/cli/chunk-bhm24ne6.js +9 -0
  43. package/dist/cli/{chunk-1s3rtx3r.js → chunk-c0ksxg3z.js} +1 -1
  44. package/dist/cli/{chunk-z8w64xa1.js → chunk-cbd6y9at.js} +1 -1
  45. package/dist/cli/{chunk-w4cpkhzj.js → chunk-ccn7pq03.js} +1 -1
  46. package/dist/cli/{chunk-gqnnpkn8.js → chunk-cpv1rpc7.js} +1 -1
  47. package/dist/cli/chunk-csdttpme.js +52 -0
  48. package/dist/cli/{chunk-7kpxmp55.js → chunk-cvrtapqt.js} +1 -1
  49. package/dist/cli/{chunk-sjx6gn4f.js → chunk-e8pv3b92.js} +1 -1
  50. package/dist/cli/{chunk-9z690mvn.js → chunk-ebhbtvhd.js} +1 -1
  51. package/dist/cli/{chunk-1exaxwyv.js → chunk-fz0xfw86.js} +1 -1
  52. package/dist/cli/{chunk-w0gf8pe2.js → chunk-gaf6n1ea.js} +1 -1
  53. package/dist/cli/{chunk-4rx3nhvq.js → chunk-h3q3r1py.js} +1 -1
  54. package/dist/cli/{chunk-1f42tb22.js → chunk-h89ghyex.js} +1 -1
  55. package/dist/cli/{chunk-jdkr3hpe.js → chunk-j6t7xvm3.js} +1 -1
  56. package/dist/cli/{chunk-5j1p0602.js → chunk-jn7vr075.js} +1 -1
  57. package/dist/cli/{chunk-964z8ccb.js → chunk-jnj2kk2h.js} +1 -1
  58. package/dist/cli/{chunk-2pen6b1t.js → chunk-jp31bpgp.js} +1 -1
  59. package/dist/cli/{chunk-2ts19s9a.js → chunk-jwnhthx9.js} +1 -1
  60. package/dist/cli/{chunk-w456ytdd.js → chunk-kda565xs.js} +1 -1
  61. package/dist/cli/{chunk-6ms5chc3.js → chunk-ke3t032y.js} +1 -1
  62. package/dist/cli/{chunk-5r6zg1ha.js → chunk-kqv7t8jk.js} +1 -1
  63. package/dist/cli/chunk-kx0wzjj4.js +2 -0
  64. package/dist/cli/chunk-m2t2n474.js +6 -0
  65. package/dist/cli/{chunk-mt6hv8p4.js → chunk-m3bz62v4.js} +1 -1
  66. package/dist/cli/chunk-md094j05.js +3 -0
  67. package/dist/cli/chunk-my20q579.js +3 -0
  68. package/dist/cli/chunk-n2xemv4a.js +2 -0
  69. package/dist/cli/{chunk-v6d6kvmk.js → chunk-n92fz0hn.js} +1 -1
  70. package/dist/cli/{chunk-chzvy4x5.js → chunk-namxa4wy.js} +1 -1
  71. package/dist/cli/chunk-npb9xz3y.js +3 -0
  72. package/dist/cli/{chunk-gp991c3v.js → chunk-nqtvthqg.js} +1 -1
  73. package/dist/cli/{chunk-xh1051v2.js → chunk-nz9nmp4v.js} +1 -1
  74. package/dist/cli/{chunk-e171nbyx.js → chunk-p2jeq98m.js} +1 -1
  75. package/dist/cli/{chunk-1hhthz4g.js → chunk-pgmv2hwf.js} +1 -1
  76. package/dist/cli/{chunk-9ytmk0zq.js → chunk-phpt1d3e.js} +1 -1
  77. package/dist/cli/chunk-pj3gnkfr.js +3 -0
  78. package/dist/cli/{chunk-e1xvz3sv.js → chunk-q2fnt7gm.js} +1 -1
  79. package/dist/cli/chunk-q3xt0mqt.js +3 -0
  80. package/dist/cli/{chunk-zsb4p0ce.js → chunk-qh4y4e27.js} +1 -1
  81. package/dist/cli/{chunk-wghh6vj1.js → chunk-qyfmfpjg.js} +1 -1
  82. package/dist/cli/{chunk-apfzdw7g.js → chunk-rc8baevh.js} +1 -1
  83. package/dist/cli/{chunk-y5dk90tw.js → chunk-resmnaxq.js} +1 -1
  84. package/dist/cli/chunk-rj7fwa30.js +2 -0
  85. package/dist/cli/{chunk-tq4swfhw.js → chunk-rxge7bh5.js} +1 -1
  86. package/dist/cli/{chunk-pvm47wsy.js → chunk-s5a5dyab.js} +1 -1
  87. package/dist/cli/{chunk-92zmns0y.js → chunk-s5k3g5ra.js} +1 -1
  88. package/dist/cli/chunk-sbn5pbz9.js +2 -0
  89. package/dist/cli/{chunk-na6xz9r5.js → chunk-t3v57v42.js} +2 -2
  90. package/dist/cli/chunk-t5qayy7m.js +9 -0
  91. package/dist/cli/chunk-tfqrc2v1.js +31 -0
  92. package/dist/cli/chunk-trjve2xz.js +3 -0
  93. package/dist/cli/{chunk-wmv58pbj.js → chunk-va0n5rwm.js} +1 -1
  94. package/dist/cli/chunk-va5am5n6.js +2 -0
  95. package/dist/cli/{chunk-9p4gs9yq.js → chunk-vd8qqev9.js} +1 -1
  96. package/dist/cli/{chunk-rt4tg426.js → chunk-vwpcv7j1.js} +1 -1
  97. package/dist/cli/{chunk-fg1sx7hc.js → chunk-x8pk5cyf.js} +1 -1
  98. package/dist/cli/{chunk-svseq6ge.js → chunk-y1cb8pj5.js} +1 -1
  99. package/dist/cli/chunk-yt24rrvx.js +2 -0
  100. package/dist/cli/{chunk-bsqs03z8.js → chunk-zb5d61xa.js} +1 -1
  101. package/dist/cli/{chunk-5k4m5yt5.js → chunk-zcadc92x.js} +1 -1
  102. package/dist/cli/{chunk-76y3cdz7.js → chunk-zzzm2cfx.js} +1 -1
  103. package/dist/cli/index.js +5 -5
  104. package/dist/cli/pty-host-node.mjs +9 -1
  105. package/dist/cli/rove.js +1 -1
  106. package/dist/completions/rove.bash +1 -1
  107. package/dist/completions/rove.fish +1 -1
  108. package/dist/completions/rove.zsh +1 -1
  109. package/dist/web/assets/{index-BYv91-Cs.css → index-BZjPWX0N.css} +1 -1
  110. package/dist/web/assets/index-DHlgMx7L.js +109 -0
  111. package/dist/web/index.html +2 -2
  112. package/package.json +4 -4
  113. package/dist/cli/chunk-0az45yae.js +0 -2
  114. package/dist/cli/chunk-13p55zgg.js +0 -2
  115. package/dist/cli/chunk-1sjpx21n.js +0 -2
  116. package/dist/cli/chunk-71xc2sxv.js +0 -6
  117. package/dist/cli/chunk-aw6s9ayv.js +0 -3
  118. package/dist/cli/chunk-cck7f5jc.js +0 -2
  119. package/dist/cli/chunk-d3828ttr.js +0 -2
  120. package/dist/cli/chunk-dcjxtwdb.js +0 -7
  121. package/dist/cli/chunk-drhzdxb6.js +0 -3
  122. package/dist/cli/chunk-e1x88j3k.js +0 -3
  123. package/dist/cli/chunk-h9kzwj14.js +0 -2
  124. package/dist/cli/chunk-kyjdsax8.js +0 -3
  125. package/dist/cli/chunk-mqdx3p1q.js +0 -52
  126. package/dist/cli/chunk-n77bc7zh.js +0 -9
  127. package/dist/cli/chunk-nxe45n7k.js +0 -17
  128. package/dist/cli/chunk-p6d966bc.js +0 -2
  129. package/dist/cli/chunk-rm1b8fgg.js +0 -3
  130. package/dist/cli/chunk-srq21cyw.js +0 -2
  131. package/dist/cli/chunk-tkft79ag.js +0 -2
  132. package/dist/cli/chunk-xfyg3p1w.js +0 -2
  133. package/dist/cli/chunk-y18jrdkr.js +0 -3
  134. package/dist/web/assets/index-DB1fxViH.js +0 -109
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{CATALOGS,DEFAULT_LOCALE,LOCALES}from"./chunk-y18jrdkr.js";import{createStateCell}from"./chunk-cmp64q4j.js";function lookup(catalog,key){let node=catalog;for(let part of key.split("."))if(node&&typeof node==="object"&&part in node)node=node[part];else return;return typeof node==="string"?node:void 0}function interpolate(template,params){if(!params)return template;return template.replace(/\{(\w+)\}/g,(whole,name)=>(name in params)?String(params[name]):whole)}function lookupKeys(catalog,group,key){return catalog.keys[group]?.[key]}var langState=createStateCell(DEFAULT_LOCALE);function setLocaleLang(lang){if(CATALOGS[lang])langState.set(lang)}function currentLang(){return langState.get()}function intlLocale(){return LOCALES.find((locale)=>locale.id===langState.get())?.intl??"en-US"}function localeState(){return langState}var pluginNamespaces=new Set;function registerMessages(namespace,messages){let en=CATALOGS.en,zh=CATALOGS.zh;if(namespace in en&&!pluginNamespaces.has(namespace))throw Error(`i18n namespace "${namespace}" belongs to the host`);if(pluginNamespaces.add(namespace),en[namespace]=messages.en,messages.zh)zh[namespace]=messages.zh;else delete zh[namespace]}function t(key,params){let lang=langState.get(),resolved=lookup(CATALOGS[lang],key)??lookup(CATALOGS.en,key)??key;return interpolate(resolved,params)}function tKeys(group,key){let lang=langState.get();return lookupKeys(CATALOGS[lang],group,key)??lookupKeys(CATALOGS.en,group,key)??key}
2
+ import{CATALOGS,DEFAULT_LOCALE,LOCALES}from"./chunk-q3xt0mqt.js";import{createStateCell}from"./chunk-cmp64q4j.js";function lookup(catalog,key){let node=catalog;for(let part of key.split("."))if(node&&typeof node==="object"&&part in node)node=node[part];else return;return typeof node==="string"?node:void 0}function interpolate(template,params){if(!params)return template;return template.replace(/\{(\w+)\}/g,(whole,name)=>(name in params)?String(params[name]):whole)}function lookupKeys(catalog,group,key){return catalog.keys[group]?.[key]}var langState=createStateCell(DEFAULT_LOCALE);function setLocaleLang(lang){if(CATALOGS[lang])langState.set(lang)}function currentLang(){return langState.get()}function intlLocale(){return LOCALES.find((locale)=>locale.id===langState.get())?.intl??"en-US"}function localeState(){return langState}var pluginNamespaces=new Set;function registerMessages(namespace,messages){let en=CATALOGS.en,zh=CATALOGS.zh;if(namespace in en&&!pluginNamespaces.has(namespace))throw Error(`i18n namespace "${namespace}" belongs to the host`);if(pluginNamespaces.add(namespace),en[namespace]=messages.en,messages.zh)zh[namespace]=messages.zh;else delete zh[namespace]}function t(key,params){let lang=langState.get(),resolved=lookup(CATALOGS[lang],key)??lookup(CATALOGS.en,key)??key;return interpolate(resolved,params)}function tKeys(group,key){let lang=langState.get();return lookupKeys(CATALOGS[lang],group,key)??lookupKeys(CATALOGS.en,group,key)??key}
3
3
  export{setLocaleLang,currentLang,intlLocale,localeState,registerMessages,t,tKeys};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{PROJECT_DIR_TOKEN,WORKTREE_BASE_KEY,defaultLocalWorktreesRoot,legacyLocalWorktreesRoot,managedWorktreeRootsFor,normalizeWorktreeBase,worktreeRootFor}from"./chunk-41x1hrqe.js";import{execHostForRepo}from"./chunk-y5dk90tw.js";import{errorMessage}from"./chunk-2brn8e1y.js";import{getRemoteRepoConfig,isRemoteRepoKey}from"./chunk-21ek142k.js";import{loadStateFile}from"./chunk-zk5qkkb1.js";import{pathWithin}from"./chunk-pn5ygqn6.js";class IllegalTransitionError extends Error{from;to;taskId;constructor(from,to,taskId){super(`illegal transition for task ${taskId}: ${from} -> ${to}`);this.from=from;this.to=to;this.taskId=taskId;this.name="IllegalTransitionError"}}class TaskNotFoundError extends Error{constructor(taskId){super(`task not found: ${taskId}`);this.name="TaskNotFoundError"}}class CannotDeleteMainTaskError extends Error{constructor(){super("cannot delete a main task; remove the repo from saved repos instead");this.name="CannotDeleteMainTaskError"}}var DIRTY_WORKTREE_CODE="DIRTY_WORKTREE";function describeDirtyWorktreeWork(ignored,dirty=[]){if(dirty.length>0)return`uncommitted or untracked changes: ${namePaths(dirty)}`;return ignored==="unknown"?"gitignored work this check could not read (git status --ignored failed) \u2014 nothing here can confirm it is empty":ignored.length>0?`gitignored work git status cannot see: ${ignored.join(", ")}`:"uncommitted or untracked changes"}var DIRTY_PATHS_SHOWN=10;function namePaths(paths){let shown=paths.slice(0,DIRTY_PATHS_SHOWN).join(", "),more=paths.length-DIRTY_PATHS_SHOWN;return more>0?`${shown} (+${more} more)`:shown}function dirtyRefusalReason(err){let message=errorMessage(err),at=message.indexOf(DIRTY_WORKTREE_CODE);if(at<0)return null;return message.slice(at+DIRTY_WORKTREE_CODE.length).replace(/^:\s*/,"")}class DirtyWorktreeError extends Error{taskId;ignored;dirty;constructor(taskId,ignored=[],dirty=[]){super(`${DIRTY_WORKTREE_CODE}: task ${taskId} worktree has ${describeDirtyWorktreeWork(ignored,dirty)}`);this.taskId=taskId;this.ignored=ignored;this.dirty=dirty;this.name="DirtyWorktreeError"}}class WorktreeRemoveFailedError extends Error{taskId;cause;constructor(taskId,cause){super(`failed to remove worktree for task ${taskId}: ${errorMessage(cause)}`);this.taskId=taskId;this.cause=cause;this.name="WorktreeRemoveFailedError"}}var TASK_DELETING_CODE="TASK_DELETING";class TaskDeletingError extends Error{taskId;constructor(taskId){super(`${TASK_DELETING_CODE}: task ${taskId} is being deleted`);this.taskId=taskId;this.name="TaskDeletingError"}}var MAIN_CHECKOUT_DIRTY_CODE="MAIN_CHECKOUT_DIRTY";class MainCheckoutDirtyError extends Error{repo;dir;constructor(repo,dir){super(`${MAIN_CHECKOUT_DIRTY_CODE}: base checkout at ${dir} has uncommitted changes; commit them before landing (never git stash \u2014 the stash stack is shared by every worktree of this repo)`);this.repo=repo;this.dir=dir;this.name="MainCheckoutDirtyError"}}var EMPTY_BRANCH_CODE="EMPTY_BRANCH";class EmptyBranchError extends Error{branch;landedOn;constructor(branch,landedOn){super(`${EMPTY_BRANCH_CODE}: '${branch}' has no commits ahead of '${landedOn}' \u2014 landing it would be a no-op (the worker may not have delivered anything)`);this.branch=branch;this.landedOn=landedOn;this.name="EmptyBranchError"}}var EMPTY_BRANCH_DIRTY_WORKTREE_CODE="EMPTY_BRANCH_DIRTY_WORKTREE";class EmptyBranchDirtyWorktreeError extends Error{branch;landedOn;worktreePath;files;constructor(branch,landedOn,worktreePath,files){let list=files.length>0?files.join(", "):"(none reported)";super(`${EMPTY_BRANCH_DIRTY_WORKTREE_CODE}: '${branch}' has no commits ahead of '${landedOn}' but its worktree ${worktreePath} has uncommitted changes (${list}) \u2014 commit them in the worktree first, then land again`);this.branch=branch;this.landedOn=landedOn;this.worktreePath=worktreePath;this.files=files;this.name="EmptyBranchDirtyWorktreeError"}}var MISSING_REF_CODE="MISSING_REF";class MissingRefError extends Error{branch;landedOn;dir;constructor(branch,landedOn,dir){super(`${MISSING_REF_CODE}: '${branch}' does not resolve in the base repo at ${dir} (comparing against '${landedOn}') \u2014 the branch was renamed or deleted outside Rove; re-point the task with \`rove api update --branch\` or recreate the branch`);this.branch=branch;this.landedOn=landedOn;this.dir=dir;this.name="MissingRefError"}}var LAND_CONFLICT_CODE="LAND_CONFLICT";class LandConflictError extends Error{taskId;branch;files;constructor(taskId,branch,files){let list=files.length>0?files.join(", "):"(none reported)";super(`${LAND_CONFLICT_CODE}: merging '${branch}' hit conflicts, merge aborted \u2014 conflicted files: ${list}`);this.taskId=taskId;this.branch=branch;this.files=files;this.name="LandConflictError"}}var GIT_COMMAND_FAILED_CODE="GIT_COMMAND_FAILED";class GitCommandFailedError extends Error{command;stderr;constructor(command,stderr,hint){let detail=stderr.trim()||"(git printed nothing on stderr)";super(`${GIT_COMMAND_FAILED_CODE}: \`git ${command}\` failed \u2014 ${detail}${hint?`; ${hint}`:""}`);this.command=command;this.stderr=stderr;this.name="GitCommandFailedError"}}var WORKTREE_NAME_TAKEN_CODE="WORKTREE_NAME_TAKEN";class WorktreeNameTakenError extends Error{worktreeName;constructor(worktreeName){super(`${WORKTREE_NAME_TAKEN_CODE}: worktree name '${worktreeName}' is already in use in this repo \u2014 pick another, or omit --worktree-name for a generated one`);this.worktreeName=worktreeName;this.name="WorktreeNameTakenError"}}var INVALID_WORKTREE_NAME_CODE="INVALID_WORKTREE_NAME";class InvalidWorktreeNameError extends Error{worktreeName;constructor(worktreeName){super(`${INVALID_WORKTREE_NAME_CODE}: worktree name '${worktreeName}' must be a single path segment of letters, digits, '.', '_' or '-' (no '/', no '..', not starting with '.')`);this.worktreeName=worktreeName;this.name="InvalidWorktreeNameError"}}import fs from"fs";import path from"path";var WORKTREE_BASE_CUSTOM_KEY="worktree.basePath.custom",PROJECT_SIBLING_BASE=`${PROJECT_DIR_TOKEN}/..`;function worktreeBaseKindOf(raw){let trimmed=raw.trim();if(!trimmed)return"default";if(trimmed.replace(/\/+$/,"")===PROJECT_SIBLING_BASE)return"nextToProject";return"custom"}function getWorktreeBaseOverride(projectDir){let value=loadStateFile()[WORKTREE_BASE_KEY];return normalizeWorktreeBase(typeof value==="string"?value:null,projectDir)}function worktreeRootFor2(repo){return worktreeRootFor(repo,getWorktreeBaseOverride(repo))}function managedWorktreeRootsFor2(repo){return managedWorktreeRootsFor(repo,getWorktreeBaseOverride(repo))}function worktreePathFor(repo,slug){if(!slug||/[/\\\0]/.test(slug))throw Error(`worktreePathFor: invalid slug: ${JSON.stringify(slug)}`);return path.join(worktreeRootFor2(repo),slug)}async function listWorktreeDirNames(repo){if(isRemoteRepoKey(repo)){let basePath=getRemoteRepoConfig(repo)?.basePath;if(!basePath)return[];let names2=new Set,host=execHostForRepo(repo),entries=await Promise.all(remoteManagedWorktreeRootsFor(basePath).map((root)=>host.readdir(root)));for(let list of entries)for(let name of list)names2.add(name);return[...names2]}let names=new Set;for(let root of managedWorktreeRootsFor2(repo))try{for(let e of fs.readdirSync(root,{withFileTypes:!0}))if(e.isDirectory())names.add(e.name)}catch{}return[...names]}function managedWorktreeRootForPath(repo,candidate){if(!path.isAbsolute(repo)||!path.isAbsolute(candidate))return null;let target=canonicalize(candidate);for(let rootPath of managedWorktreeRootsFor2(repo)){let root=canonicalize(rootPath),rel=pathWithin(root,target);if(rel!==null&&rel!=="")return rootPath}return null}function isRoveManagedPath(repo,candidate){return managedWorktreeRootForPath(repo,candidate)!==null}function isUnderManagedWorktreesRoot(candidate,projectDir){if(!path.isAbsolute(candidate))return!1;let target=canonicalize(candidate),roots=[getWorktreeBaseOverride(projectDir)??"",defaultLocalWorktreesRoot(),legacyLocalWorktreesRoot()];for(let rootPath of roots){if(!rootPath)continue;let root=canonicalize(rootPath),rel=pathWithin(root,target);if(rel===null)continue;if(rel.split("/").filter(Boolean).length===2)return!0}return!1}function remoteWorktreeRootFor(basePath){return`${stripTrailingSlash(basePath)}/.rove/worktrees`}function remoteManagedWorktreeRootsFor(basePath){let base=stripTrailingSlash(basePath);return[`${base}/.rove/worktrees`,`${base}/.rove/worktrees`]}function remoteWorktreePathFor(basePath,slug){if(!slug||/[/\\\0]/.test(slug))throw Error(`remoteWorktreePathFor: invalid slug: ${JSON.stringify(slug)}`);return`${remoteWorktreeRootFor(basePath)}/${slug}`}function remoteManagedRootForPath(basePath,candidate){for(let root of remoteManagedWorktreeRootsFor(basePath))if(candidate===root||candidate.startsWith(`${root}/`))return root;return null}function stripTrailingSlash(p){return p.length>1&&p.endsWith("/")?p.replace(/\/+$/,""):p}function requireAbsolute(name,value){if(!value||!path.isAbsolute(value))throw Error(`${name} must be an absolute path, got: ${JSON.stringify(value)}`)}function canonicalize(p){try{return fs.realpathSync(p)}catch{return path.resolve(p)}}
2
+ import{PROJECT_DIR_TOKEN,WORKTREE_BASE_KEY,defaultLocalWorktreesRoot,legacyLocalWorktreesRoot,managedWorktreeRootsFor,normalizeWorktreeBase,worktreeRootFor}from"./chunk-41x1hrqe.js";import{execHostForRepo}from"./chunk-resmnaxq.js";import{errorMessage}from"./chunk-2brn8e1y.js";import{getRemoteRepoConfig,isRemoteRepoKey}from"./chunk-21ek142k.js";import{loadStateFile}from"./chunk-zk5qkkb1.js";import{pathWithin}from"./chunk-pn5ygqn6.js";class IllegalTransitionError extends Error{from;to;taskId;constructor(from,to,taskId){super(`illegal transition for task ${taskId}: ${from} -> ${to}`);this.from=from;this.to=to;this.taskId=taskId;this.name="IllegalTransitionError"}}class TaskNotFoundError extends Error{constructor(taskId){super(`task not found: ${taskId}`);this.name="TaskNotFoundError"}}class CannotDeleteMainTaskError extends Error{constructor(){super("cannot delete a main task; remove the repo from saved repos instead");this.name="CannotDeleteMainTaskError"}}var DIRTY_WORKTREE_CODE="DIRTY_WORKTREE";function describeDirtyWorktreeWork(ignored,dirty=[]){if(dirty.length>0)return`uncommitted or untracked changes: ${namePaths(dirty)}`;return ignored==="unknown"?"gitignored work this check could not read (git status --ignored failed) \u2014 nothing here can confirm it is empty":ignored.length>0?`gitignored work git status cannot see: ${ignored.join(", ")}`:"uncommitted or untracked changes"}var DIRTY_PATHS_SHOWN=10;function namePaths(paths){let shown=paths.slice(0,DIRTY_PATHS_SHOWN).join(", "),more=paths.length-DIRTY_PATHS_SHOWN;return more>0?`${shown} (+${more} more)`:shown}function dirtyRefusalReason(err){let message=errorMessage(err),at=message.indexOf(DIRTY_WORKTREE_CODE);if(at<0)return null;return message.slice(at+DIRTY_WORKTREE_CODE.length).replace(/^:\s*/,"")}class DirtyWorktreeError extends Error{taskId;ignored;dirty;constructor(taskId,ignored=[],dirty=[]){super(`${DIRTY_WORKTREE_CODE}: task ${taskId} worktree has ${describeDirtyWorktreeWork(ignored,dirty)}`);this.taskId=taskId;this.ignored=ignored;this.dirty=dirty;this.name="DirtyWorktreeError"}}class WorktreeRemoveFailedError extends Error{taskId;cause;constructor(taskId,cause){super(`failed to remove worktree for task ${taskId}: ${errorMessage(cause)}`);this.taskId=taskId;this.cause=cause;this.name="WorktreeRemoveFailedError"}}var TASK_DELETING_CODE="TASK_DELETING";class TaskDeletingError extends Error{taskId;constructor(taskId){super(`${TASK_DELETING_CODE}: task ${taskId} is being deleted`);this.taskId=taskId;this.name="TaskDeletingError"}}var MAIN_CHECKOUT_DIRTY_CODE="MAIN_CHECKOUT_DIRTY";class MainCheckoutDirtyError extends Error{repo;dir;constructor(repo,dir){super(`${MAIN_CHECKOUT_DIRTY_CODE}: base checkout at ${dir} has uncommitted changes; commit them before landing (never git stash \u2014 the stash stack is shared by every worktree of this repo)`);this.repo=repo;this.dir=dir;this.name="MainCheckoutDirtyError"}}var EMPTY_BRANCH_CODE="EMPTY_BRANCH";class EmptyBranchError extends Error{branch;landedOn;constructor(branch,landedOn){super(`${EMPTY_BRANCH_CODE}: '${branch}' has no commits ahead of '${landedOn}' \u2014 landing it would be a no-op (the worker may not have delivered anything)`);this.branch=branch;this.landedOn=landedOn;this.name="EmptyBranchError"}}var EMPTY_BRANCH_DIRTY_WORKTREE_CODE="EMPTY_BRANCH_DIRTY_WORKTREE";class EmptyBranchDirtyWorktreeError extends Error{branch;landedOn;worktreePath;files;constructor(branch,landedOn,worktreePath,files){let list=files.length>0?files.join(", "):"(none reported)";super(`${EMPTY_BRANCH_DIRTY_WORKTREE_CODE}: '${branch}' has no commits ahead of '${landedOn}' but its worktree ${worktreePath} has uncommitted changes (${list}) \u2014 commit them in the worktree first, then land again`);this.branch=branch;this.landedOn=landedOn;this.worktreePath=worktreePath;this.files=files;this.name="EmptyBranchDirtyWorktreeError"}}var MISSING_REF_CODE="MISSING_REF";class MissingRefError extends Error{branch;landedOn;dir;constructor(branch,landedOn,dir){super(`${MISSING_REF_CODE}: '${branch}' does not resolve in the base repo at ${dir} (comparing against '${landedOn}') \u2014 the branch was renamed or deleted outside Rove; re-point the task with \`rove api update --branch\` or recreate the branch`);this.branch=branch;this.landedOn=landedOn;this.dir=dir;this.name="MissingRefError"}}var LAND_CONFLICT_CODE="LAND_CONFLICT";class LandConflictError extends Error{taskId;branch;files;constructor(taskId,branch,files){let list=files.length>0?files.join(", "):"(none reported)";super(`${LAND_CONFLICT_CODE}: merging '${branch}' hit conflicts, merge aborted \u2014 conflicted files: ${list}`);this.taskId=taskId;this.branch=branch;this.files=files;this.name="LandConflictError"}}var GIT_COMMAND_FAILED_CODE="GIT_COMMAND_FAILED";class GitCommandFailedError extends Error{command;stderr;constructor(command,stderr,hint){let detail=stderr.trim()||"(git printed nothing on stderr)";super(`${GIT_COMMAND_FAILED_CODE}: \`git ${command}\` failed \u2014 ${detail}${hint?`; ${hint}`:""}`);this.command=command;this.stderr=stderr;this.name="GitCommandFailedError"}}var WORKTREE_NAME_TAKEN_CODE="WORKTREE_NAME_TAKEN";class WorktreeNameTakenError extends Error{worktreeName;constructor(worktreeName){super(`${WORKTREE_NAME_TAKEN_CODE}: worktree name '${worktreeName}' is already in use in this repo \u2014 pick another, or omit --worktree-name for a generated one`);this.worktreeName=worktreeName;this.name="WorktreeNameTakenError"}}var INVALID_WORKTREE_NAME_CODE="INVALID_WORKTREE_NAME";class InvalidWorktreeNameError extends Error{worktreeName;constructor(worktreeName){super(`${INVALID_WORKTREE_NAME_CODE}: worktree name '${worktreeName}' must be a single path segment of letters, digits, '.', '_' or '-' (no '/', no '..', not starting with '.')`);this.worktreeName=worktreeName;this.name="InvalidWorktreeNameError"}}import fs from"fs";import path from"path";var WORKTREE_BASE_CUSTOM_KEY="worktree.basePath.custom",PROJECT_SIBLING_BASE=`${PROJECT_DIR_TOKEN}/..`;function worktreeBaseKindOf(raw){let trimmed=raw.trim();if(!trimmed)return"default";if(trimmed.replace(/\/+$/,"")===PROJECT_SIBLING_BASE)return"nextToProject";return"custom"}function getWorktreeBaseOverride(projectDir){let value=loadStateFile()[WORKTREE_BASE_KEY];return normalizeWorktreeBase(typeof value==="string"?value:null,projectDir)}function worktreeRootFor2(repo){return worktreeRootFor(repo,getWorktreeBaseOverride(repo))}function managedWorktreeRootsFor2(repo){return managedWorktreeRootsFor(repo,getWorktreeBaseOverride(repo))}function worktreePathFor(repo,slug){if(!slug||/[/\\\0]/.test(slug))throw Error(`worktreePathFor: invalid slug: ${JSON.stringify(slug)}`);return path.join(worktreeRootFor2(repo),slug)}async function listWorktreeDirNames(repo){if(isRemoteRepoKey(repo)){let basePath=getRemoteRepoConfig(repo)?.basePath;if(!basePath)return[];let names2=new Set,host=execHostForRepo(repo),entries=await Promise.all(remoteManagedWorktreeRootsFor(basePath).map((root)=>host.readdir(root)));for(let list of entries)for(let name of list)names2.add(name);return[...names2]}let names=new Set;for(let root of managedWorktreeRootsFor2(repo))try{for(let e of fs.readdirSync(root,{withFileTypes:!0}))if(e.isDirectory())names.add(e.name)}catch{}return[...names]}function managedWorktreeRootForPath(repo,candidate){if(!path.isAbsolute(repo)||!path.isAbsolute(candidate))return null;let target=canonicalize(candidate);for(let rootPath of managedWorktreeRootsFor2(repo)){let root=canonicalize(rootPath),rel=pathWithin(root,target);if(rel!==null&&rel!=="")return rootPath}return null}function isRoveManagedPath(repo,candidate){return managedWorktreeRootForPath(repo,candidate)!==null}function isUnderManagedWorktreesRoot(candidate,projectDir){if(!path.isAbsolute(candidate))return!1;let target=canonicalize(candidate),roots=[getWorktreeBaseOverride(projectDir)??"",defaultLocalWorktreesRoot(),legacyLocalWorktreesRoot()];for(let rootPath of roots){if(!rootPath)continue;let root=canonicalize(rootPath),rel=pathWithin(root,target);if(rel===null)continue;if(rel.split("/").filter(Boolean).length===2)return!0}return!1}function remoteWorktreeRootFor(basePath){return`${stripTrailingSlash(basePath)}/.rove/worktrees`}function remoteManagedWorktreeRootsFor(basePath){let base=stripTrailingSlash(basePath);return[`${base}/.rove/worktrees`,`${base}/.rove/worktrees`]}function remoteWorktreePathFor(basePath,slug){if(!slug||/[/\\\0]/.test(slug))throw Error(`remoteWorktreePathFor: invalid slug: ${JSON.stringify(slug)}`);return`${remoteWorktreeRootFor(basePath)}/${slug}`}function remoteManagedRootForPath(basePath,candidate){for(let root of remoteManagedWorktreeRootsFor(basePath))if(candidate===root||candidate.startsWith(`${root}/`))return root;return null}function stripTrailingSlash(p){return p.length>1&&p.endsWith("/")?p.replace(/\/+$/,""):p}function requireAbsolute(name,value){if(!value||!path.isAbsolute(value))throw Error(`${name} must be an absolute path, got: ${JSON.stringify(value)}`)}function canonicalize(p){try{return fs.realpathSync(p)}catch{return path.resolve(p)}}
3
3
  export{IllegalTransitionError,TaskNotFoundError,CannotDeleteMainTaskError,DIRTY_WORKTREE_CODE,describeDirtyWorktreeWork,dirtyRefusalReason,DirtyWorktreeError,WorktreeRemoveFailedError,TASK_DELETING_CODE,TaskDeletingError,MainCheckoutDirtyError,EmptyBranchError,EMPTY_BRANCH_DIRTY_WORKTREE_CODE,EmptyBranchDirtyWorktreeError,MissingRefError,LandConflictError,GitCommandFailedError,WorktreeNameTakenError,InvalidWorktreeNameError,WORKTREE_BASE_CUSTOM_KEY,PROJECT_SIBLING_BASE,worktreeBaseKindOf,worktreePathFor,listWorktreeDirNames,managedWorktreeRootForPath,isRoveManagedPath,isUnderManagedWorktreesRoot,remoteWorktreePathFor,remoteManagedRootForPath,requireAbsolute,canonicalize};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{deriveTitleFromPrompt}from"./chunk-cbc1h345.js";import{TaskDeletingError}from"./chunk-84bmcqyz.js";import{awaitEngineProcess,buildEngineSessionLaunch,deliverToHostedKey,enginePresence,ensureHostedEngine,ensureHostedSessionHost,findHostedEngineKey,hostedSessionFailureLine,hostedTaskKeys,killHostedSessions,listHostedSessions,openHostedSessionHost,pastePromptWhenEngineUp,trustEngineWorktree}from"./chunk-p9d26ma8.js";import{engineLaunchArgv,protocolEntry}from"./chunk-z8w64xa1.js";import{resolveLoginShell}from"./chunk-vjvkkrzc.js";import{DEFAULT_TASK_VENDOR}from"./chunk-xy8be792.js";var MAX_SESSIONS_SCANNED=8;function titleFromMessages(messages){let firstUser=messages.find((m)=>m.role==="user");if(!firstUser)return"";let text=firstUser.blocks.filter((b)=>b.type==="text").map((b)=>b.text).join(" "),title=deriveTitleFromPrompt(text);return title.length>0?Buffer.from(title,"utf8").toString("utf8"):title}async function deriveTitleFromSession(worktree,vendor=DEFAULT_TASK_VENDOR){if(!worktree)return"";let{history}=protocolEntry(vendor),ids=await history.listSessionIdsForWorktree(worktree);for(let sessionId of ids.slice(0,MAX_SESSIONS_SCANNED)){let title=titleFromMessages(await history.readHistory(sessionId));if(title)return title}return""}async function deriveTitleFromSessionId(vendor,sessionId){if(!sessionId)return"";try{return titleFromMessages(await protocolEntry(vendor).history.readHistory(sessionId))}catch{return""}}async function getTask(link,taskId){let{task}=await link.request("task.get",{taskId});return task}async function ensureTaskWorktree(link,taskId){let task=await getTask(link,taskId);if(task.deletion)throw new TaskDeletingError(taskId);if(task.worktreePath)return{task,worktreePath:task.worktreePath};let{worktreePath}=await link.request("task.ensureWorktree",{taskId});if(!worktreePath)throw Error(`task ${taskId} has no worktree`);return{task,worktreePath}}async function ensureTaskSessionAdapter(link,taskId){let{task,worktreePath}=await ensureTaskWorktree(link,taskId),launch=taskEngineLaunch(task,worktreePath,{kind:"repo-init"}),host=await ensureHostedSessionHost();try{if(!(await ensureHostedEngine(host.rpc,worktreePath,launch)).alive)throw Error(`failed to start hosted engine session for ${taskId}`);if(launch.firstMessage){let engineBin=engineLaunchArgv({command:task.command,vendor:task.vendor,effort:task.modelEffort,model:task.model})[0];await pastePromptWhenEngineUp(host.rpc,launch.key,engineBin,launch.firstMessage,{initMarkerPath:launch.initMarkerPath,initTimeoutMs:launch.initTimeoutMs}).catch(()=>!1)}}finally{host.close()}return{session:launch.key,worktreePath}}async function startTaskSessionWithPromptAdapter(link,taskId,prompt){let{task,worktreePath}=await ensureTaskWorktree(link,taskId);await link.request("task.observeLanguage",{taskId,text:prompt}).catch(()=>{});let launch=taskEngineLaunch(task,worktreePath,{kind:"new-task",prompt}),host=await ensureHostedSessionHost();try{if(!(await ensureHostedEngine(host.rpc,worktreePath,launch)).alive)return{started:!1,error:"hosted session did not open"};let engineBin=engineLaunchArgv({command:task.command,vendor:task.vendor,effort:task.modelEffort,model:task.model})[0],wait={initMarkerPath:launch.initMarkerPath,initTimeoutMs:launch.initTimeoutMs};if(launch.firstMessage){if(await pastePromptWhenEngineUp(host.rpc,launch.key,engineBin,launch.firstMessage,wait)!==null)return{started:!0};return{started:!1,error:await startFailureReason(host.rpc,launch.key)}}if(await awaitEngineProcess(host.rpc,launch.key,engineBin,wait)!==null)return{started:!0};return{started:!1,error:await startFailureReason(host.rpc,launch.key)}}finally{host.close()}}async function startFailureReason(rpc,key){let tail=await hostedSessionFailureLine(rpc,key),base="engine process never started";return tail?`engine process never started; last session output: ${tail}`:"engine process never started"}function taskEngineLaunch(task,worktreePath,promptIntent){return trustEngineWorktree(task.vendor,worktreePath),buildEngineSessionLaunch({task:{id:task.id,kind:task.kind,vendor:task.vendor,repo:task.repo},worktreePath,shell:resolveLoginShell({fallback:"/bin/zsh"}),argv:engineLaunchArgv({command:task.command,vendor:task.vendor,effort:task.modelEffort,model:task.model}),promptIntent})}async function deliverPromptToLiveEngineAdapter(task,prompt){let host=await openHostedSessionHost();if(!host)return!1;try{let sessions=await listHostedSessions(host.rpc),engineArgv=engineLaunchArgv({command:task.command,vendor:task.vendor}),key=findHostedEngineKey(sessions,task.id,engineArgv[0]);if(!key)return!1;let presence=await enginePresence(sessions.find((s)=>s.key===key)?.pid,engineArgv);if(presence.kind!=="engine")return!1;return await deliverToHostedKey(host.rpc,key,prompt,{vendor:presence.vendor})!==null}catch{return!1}finally{host.close()}}function tabIdFromHostedKey(key){return key.split("::")[1]??"tab-1"}async function deliverPromptToLiveEngineDetailedAdapter(task,prompt){let host=await openHostedSessionHost();if(!host)return{outcome:"no-session"};try{let sessions=await listHostedSessions(host.rpc),engineArgv=engineLaunchArgv({command:task.command,vendor:task.vendor}),key=findHostedEngineKey(sessions,task.id,engineArgv[0]);if(!key)return{outcome:"no-session"};let presence=await enginePresence(sessions.find((s)=>s.key===key)?.pid,engineArgv);if(presence.kind!=="engine")return{outcome:"no-engine",tabId:tabIdFromHostedKey(key)};return await deliverToHostedKey(host.rpc,key,prompt,{vendor:presence.vendor})===null?{outcome:"no-session"}:{outcome:"delivered",tabId:tabIdFromHostedKey(key)}}catch{return{outcome:"no-session"}}finally{host.close()}}async function deliverPromptToLiveEngineTabDetailedAdapter(target,prompt){let host=await openHostedSessionHost();if(!host)return{outcome:"no-session"};try{let key=`${target.id}::${target.tabId}`,sessions;try{sessions=await listHostedSessions(host.rpc)}catch{return{outcome:"no-session"}}let session=sessions.find((candidate)=>candidate.alive&&candidate.key===key);if(!session)return{outcome:"no-session"};let engineArgv=engineLaunchArgv({command:target.command,vendor:target.vendor}),presence=await enginePresence(session.pid,engineArgv);if(presence.kind!=="engine")return{outcome:"no-engine",tabId:target.tabId};return await deliverToHostedKey(host.rpc,key,prompt,{vendor:presence.vendor})===null?{outcome:"no-session"}:{outcome:"delivered",tabId:target.tabId}}finally{host.close()}}async function tearDownTaskSessionAdapter(taskId){let host=await openHostedSessionHost();if(!host)return;try{await killHostedSessions(host.rpc,hostedTaskKeys(await listHostedSessions(host.rpc),taskId),{wait:!0})}catch{}finally{host.close()}}
2
+ import{deriveTitleFromPrompt}from"./chunk-cbc1h345.js";import{TaskDeletingError}from"./chunk-07jq0271.js";import{awaitEngineProcess,buildEngineSessionLaunch,deliverToHostedKey,enginePresence,ensureHostedEngine,ensureHostedSessionHost,findHostedEngineKey,hostedSessionFailureLine,hostedTaskKeys,killHostedSessions,listHostedSessions,openHostedSessionHost,pastePromptWhenEngineUp,trustEngineWorktree}from"./chunk-952aedqm.js";import{engineLaunchArgv,protocolEntry}from"./chunk-cbd6y9at.js";import{resolveLoginShell}from"./chunk-vjvkkrzc.js";import{DEFAULT_TASK_VENDOR}from"./chunk-xy8be792.js";var MAX_SESSIONS_SCANNED=8;function titleFromMessages(messages){let firstUser=messages.find((m)=>m.role==="user");if(!firstUser)return"";let text=firstUser.blocks.filter((b)=>b.type==="text").map((b)=>b.text).join(" "),title=deriveTitleFromPrompt(text);return title.length>0?Buffer.from(title,"utf8").toString("utf8"):title}async function deriveTitleFromSession(worktree,vendor=DEFAULT_TASK_VENDOR){if(!worktree)return"";let{history}=protocolEntry(vendor),ids=await history.listSessionIdsForWorktree(worktree);for(let sessionId of ids.slice(0,MAX_SESSIONS_SCANNED)){let title=titleFromMessages(await history.readHistory(sessionId));if(title)return title}return""}async function deriveTitleFromSessionId(vendor,sessionId){if(!sessionId)return"";try{return titleFromMessages(await protocolEntry(vendor).history.readHistory(sessionId))}catch{return""}}async function getTask(link,taskId){let{task}=await link.request("task.get",{taskId});return task}async function ensureTaskWorktree(link,taskId){let task=await getTask(link,taskId);if(task.deletion)throw new TaskDeletingError(taskId);if(task.worktreePath)return{task,worktreePath:task.worktreePath};let{worktreePath}=await link.request("task.ensureWorktree",{taskId});if(!worktreePath)throw Error(`task ${taskId} has no worktree`);return{task,worktreePath}}async function ensureTaskSessionAdapter(link,taskId){let{task,worktreePath}=await ensureTaskWorktree(link,taskId),launch=taskEngineLaunch(task,worktreePath,{kind:"repo-init"}),host=await ensureHostedSessionHost();try{if(!(await ensureHostedEngine(host.rpc,worktreePath,launch)).alive)throw Error(`failed to start hosted engine session for ${taskId}`);if(launch.firstMessage){let engineBin=engineLaunchArgv({command:task.command,vendor:task.vendor,effort:task.modelEffort,model:task.model})[0];await pastePromptWhenEngineUp(host.rpc,launch.key,engineBin,launch.firstMessage,{initMarkerPath:launch.initMarkerPath,initTimeoutMs:launch.initTimeoutMs}).catch(()=>!1)}}finally{host.close()}return{session:launch.key,worktreePath}}async function startTaskSessionWithPromptAdapter(link,taskId,prompt){let{task,worktreePath}=await ensureTaskWorktree(link,taskId);await link.request("task.observeLanguage",{taskId,text:prompt}).catch(()=>{});let launch=taskEngineLaunch(task,worktreePath,{kind:"new-task",prompt}),host=await ensureHostedSessionHost();try{if(!(await ensureHostedEngine(host.rpc,worktreePath,launch)).alive)return{started:!1,error:"hosted session did not open"};let engineBin=engineLaunchArgv({command:task.command,vendor:task.vendor,effort:task.modelEffort,model:task.model})[0],wait={initMarkerPath:launch.initMarkerPath,initTimeoutMs:launch.initTimeoutMs};if(launch.firstMessage){if(await pastePromptWhenEngineUp(host.rpc,launch.key,engineBin,launch.firstMessage,wait)!==null)return{started:!0};return{started:!1,error:await startFailureReason(host.rpc,launch.key)}}if(await awaitEngineProcess(host.rpc,launch.key,engineBin,wait)!==null)return{started:!0};return{started:!1,error:await startFailureReason(host.rpc,launch.key)}}finally{host.close()}}async function startFailureReason(rpc,key){let tail=await hostedSessionFailureLine(rpc,key),base="engine process never started";return tail?`engine process never started; last session output: ${tail}`:"engine process never started"}function taskEngineLaunch(task,worktreePath,promptIntent){return trustEngineWorktree(task.vendor,worktreePath),buildEngineSessionLaunch({task:{id:task.id,kind:task.kind,vendor:task.vendor,repo:task.repo},worktreePath,shell:resolveLoginShell({fallback:"/bin/zsh"}),argv:engineLaunchArgv({command:task.command,vendor:task.vendor,effort:task.modelEffort,model:task.model}),promptIntent})}async function deliverPromptToLiveEngineAdapter(task,prompt){let host=await openHostedSessionHost();if(!host)return!1;try{let sessions=await listHostedSessions(host.rpc),engineArgv=engineLaunchArgv({command:task.command,vendor:task.vendor}),key=findHostedEngineKey(sessions,task.id,engineArgv[0]);if(!key)return!1;let presence=await enginePresence(sessions.find((s)=>s.key===key)?.pid,engineArgv);if(presence.kind!=="engine")return!1;return await deliverToHostedKey(host.rpc,key,prompt,{vendor:presence.vendor})!==null}catch{return!1}finally{host.close()}}function tabIdFromHostedKey(key){return key.split("::")[1]??"tab-1"}async function deliverPromptToLiveEngineDetailedAdapter(task,prompt){let host=await openHostedSessionHost();if(!host)return{outcome:"no-session"};try{let sessions=await listHostedSessions(host.rpc),engineArgv=engineLaunchArgv({command:task.command,vendor:task.vendor}),key=findHostedEngineKey(sessions,task.id,engineArgv[0]);if(!key)return{outcome:"no-session"};let presence=await enginePresence(sessions.find((s)=>s.key===key)?.pid,engineArgv);if(presence.kind!=="engine")return{outcome:"no-engine",tabId:tabIdFromHostedKey(key)};return await deliverToHostedKey(host.rpc,key,prompt,{vendor:presence.vendor})===null?{outcome:"no-session"}:{outcome:"delivered",tabId:tabIdFromHostedKey(key)}}catch{return{outcome:"no-session"}}finally{host.close()}}async function deliverPromptToLiveEngineTabDetailedAdapter(target,prompt){let host=await openHostedSessionHost();if(!host)return{outcome:"no-session"};try{let key=`${target.id}::${target.tabId}`,sessions;try{sessions=await listHostedSessions(host.rpc)}catch{return{outcome:"no-session"}}let session=sessions.find((candidate)=>candidate.alive&&candidate.key===key);if(!session)return{outcome:"no-session"};let engineArgv=engineLaunchArgv({command:target.command,vendor:target.vendor}),presence=await enginePresence(session.pid,engineArgv);if(presence.kind!=="engine")return{outcome:"no-engine",tabId:target.tabId};return await deliverToHostedKey(host.rpc,key,prompt,{vendor:presence.vendor})===null?{outcome:"no-session"}:{outcome:"delivered",tabId:target.tabId}}finally{host.close()}}async function tearDownTaskSessionAdapter(taskId){let host=await openHostedSessionHost();if(!host)return;try{await killHostedSessions(host.rpc,hostedTaskKeys(await listHostedSessions(host.rpc),taskId),{wait:!0})}catch{}finally{host.close()}}
3
3
  export{deriveTitleFromSession,deriveTitleFromSessionId,ensureTaskSessionAdapter,startTaskSessionWithPromptAdapter,deliverPromptToLiveEngineAdapter,deliverPromptToLiveEngineDetailedAdapter,deliverPromptToLiveEngineTabDetailedAdapter,tearDownTaskSessionAdapter};