noskills 4.5.1 → 4.5.2

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 (91) hide show
  1. package/chunks/{ajan-bridge-T5M4DPDT.js → ajan-bridge-BNPC757J.js} +1 -1
  2. package/chunks/{anthropic-TS7EMQML.js → anthropic-ZKOMTKX2.js} +1 -1
  3. package/chunks/{approve-HEW3VFYH.js → approve-3TKOHYHH.js} +1 -1
  4. package/chunks/{ask-AXHTCVD6.js → ask-UB26SBWQ.js} +1 -1
  5. package/chunks/{block-VN76CXZW.js → block-Q4WAIX7X.js} +1 -1
  6. package/chunks/{cancel-7WRAST62.js → cancel-DY76ADX4.js} +1 -1
  7. package/chunks/{chunk-4PF2MT7S.js → chunk-34RPTI4K.js} +7 -7
  8. package/chunks/chunk-3JTDWOAJ.js +2 -0
  9. package/chunks/{chunk-GQTHILPL.js → chunk-5FX4EBFY.js} +1 -1
  10. package/chunks/chunk-5OTECUN7.js +1 -0
  11. package/chunks/{chunk-6YSS6PEL.js → chunk-7PBHRFOZ.js} +1 -1
  12. package/chunks/{chunk-7GC46XEU.js → chunk-AB3N327V.js} +1 -1
  13. package/chunks/{chunk-KMLNG3EC.js → chunk-BYPCI5VU.js} +1 -1
  14. package/chunks/{chunk-QKWJ72HI.js → chunk-CKIZYL4O.js} +1 -1
  15. package/chunks/{chunk-S4MUTKHT.js → chunk-DYCGJ4RY.js} +1 -1
  16. package/chunks/{chunk-UE56BMAW.js → chunk-EVJYA7S3.js} +1 -1
  17. package/chunks/{chunk-LN4NDYT6.js → chunk-FYFUEK4U.js} +1 -1
  18. package/chunks/chunk-GNMOE7H3.js +48 -0
  19. package/chunks/chunk-HB62UGZI.js +2 -0
  20. package/chunks/{chunk-EIMBEXUJ.js → chunk-IM73MYMS.js} +1 -1
  21. package/chunks/{chunk-KM64FL2X.js → chunk-J25XTDQQ.js} +1 -1
  22. package/chunks/{chunk-JL3MAFYQ.js → chunk-LGQEWL5X.js} +1 -1
  23. package/chunks/{chunk-5DZHAHXW.js → chunk-LKZZ4JN5.js} +1 -1
  24. package/chunks/{chunk-DBKXMYLF.js → chunk-NPWXEWRN.js} +1 -1
  25. package/chunks/{chunk-PKEQKXZW.js → chunk-ONJVI5AZ.js} +1 -1
  26. package/chunks/{chunk-EIGFDYGQ.js → chunk-OP4XAIGW.js} +1 -1
  27. package/chunks/{chunk-W4TQLLUK.js → chunk-T6NZVA6P.js} +1 -1
  28. package/chunks/{chunk-5PBNUBBY.js → chunk-TCSIXKUD.js} +1 -1
  29. package/chunks/{chunk-KRKOWSYW.js → chunk-WDKWHGJU.js} +5 -7
  30. package/chunks/{chunk-PRQ5CRIG.js → chunk-XDPATEP5.js} +1 -1
  31. package/chunks/{chunk-CML74SNT.js → chunk-Y45DQJSS.js} +1 -1
  32. package/chunks/{chunk-RAQY37P6.js → chunk-YUTDPPXX.js} +1 -1
  33. package/chunks/claude-code-OQJIUKZP.js +1 -0
  34. package/chunks/{concern-QSENGU6C.js → concern-UIGVWDFS.js} +1 -1
  35. package/chunks/{config-S3UXTJN2.js → config-72Z4PIJN.js} +1 -1
  36. package/chunks/{decision-ledger-GY2W6VWL.js → decision-ledger-5IPPTRT7.js} +1 -1
  37. package/chunks/{delegate-WKXIER7E.js → delegate-OV6NY434.js} +1 -1
  38. package/chunks/{diagrams-A7W2EBYV.js → diagrams-OX4FBDGP.js} +1 -1
  39. package/chunks/{done-WR3UFYJT.js → done-V54GSSTY.js} +1 -1
  40. package/chunks/{followup-5EGZEF5Q.js → followup-NL7EPIGF.js} +1 -1
  41. package/chunks/{free-KJQHRYZA.js → free-KD344KRL.js} +1 -1
  42. package/chunks/{gemini-IWP24T63.js → gemini-23EOEXSF.js} +1 -1
  43. package/chunks/{init-437SU6XH.js → init-WDRNFT57.js} +1 -1
  44. package/chunks/{invoke-hook-LMCWNF65.js → invoke-hook-I3NTD36Q.js} +1 -1
  45. package/chunks/kiro-TPAAIMY6.js +1 -0
  46. package/chunks/{learn-ZTYKBZER.js → learn-WBWNJEB2.js} +1 -1
  47. package/chunks/{ledger-FOOPJ2UO.js → ledger-QYK252DV.js} +1 -1
  48. package/chunks/{list-HNGIOVBK.js → list-WO6RS7JX.js} +1 -1
  49. package/chunks/{manager-2MOLEJ4Q.js → manager-ZSPRC5R4.js} +1 -1
  50. package/chunks/{mod-AJIRKRAH.js → mod-B6LBGYON.js} +1 -1
  51. package/chunks/{mod-6EZYRKWV.js → mod-MMHDQRNF.js} +1 -1
  52. package/chunks/{mod-7X5TKHKC.js → mod-RBGAMGZA.js} +1 -1
  53. package/chunks/{mod-TGOMO3CJ.js → mod-SV4VELMH.js} +1 -1
  54. package/chunks/{next-Y6FOPM4Z.js → next-QXCLZ7P3.js} +1 -1
  55. package/chunks/node-2XIHQ2M4.js +1 -0
  56. package/chunks/node-BXYZKSJY.js +15 -0
  57. package/chunks/node-DMUOWFGA.js +69 -0
  58. package/chunks/ollama-MXRDGQDF.js +1 -0
  59. package/chunks/openai-LE47IWMQ.js +30 -0
  60. package/chunks/{openai-YES2XJDU.js → openai-MSJF4B6H.js} +1 -1
  61. package/chunks/opencode-ZDHKR2P6.js +1 -0
  62. package/chunks/{pack-KUT53Z24.js → pack-NS64WU6M.js} +1 -1
  63. package/chunks/{plan-export-PG2BVRQZ.js → plan-export-HECAF7D4.js} +1 -1
  64. package/chunks/{purge-JGNJNEET.js → purge-PSQNN42H.js} +1 -1
  65. package/chunks/{reopen-RPDXN3CF.js → reopen-L37M5XUI.js} +1 -1
  66. package/chunks/{reset-RBCQO2RF.js → reset-OOTZXW6Q.js} +1 -1
  67. package/chunks/{review-VMS5MYOV.js → review-QLD6WSOB.js} +1 -1
  68. package/chunks/{rule-IB4VKSBC.js → rule-OOANQBHB.js} +1 -1
  69. package/chunks/{run-62PWXVII.js → run-YHCIRY7Z.js} +1 -1
  70. package/chunks/{sdk-FR7Z4YSC.js → sdk-OQIHH3OY.js} +1 -1
  71. package/chunks/{session-Q43KMFL2.js → session-OWWDH7KA.js} +1 -1
  72. package/chunks/{spec-4RKLPOEM.js → spec-O7F525UN.js} +1 -1
  73. package/chunks/{status-OGLFEFF7.js → status-SZZXY7V3.js} +1 -1
  74. package/chunks/{sync-H35O5DN5.js → sync-3RYRGTEA.js} +1 -1
  75. package/chunks/{validate-JX7UTAK5.js → validate-UZD6JBSG.js} +1 -1
  76. package/chunks/{vertexai-WF5CKMYI.js → vertexai-CVCRCO24.js} +1 -1
  77. package/chunks/{watch-SOZDHLSC.js → watch-5DNM646U.js} +1 -1
  78. package/chunks/{web-3VGRM3W4.js → web-662LNB3K.js} +1 -1
  79. package/chunks/{wontfix-RBOGLLWJ.js → wontfix-UDCTLHNB.js} +1 -1
  80. package/noskills.js +1 -1
  81. package/package.json +1 -1
  82. package/chunks/chunk-3ZJ3UGQL.js +0 -48
  83. package/chunks/chunk-575Y3OEG.js +0 -1
  84. package/chunks/chunk-IGDFEGCH.js +0 -2
  85. package/chunks/claude-code-DIWRQKZA.js +0 -1
  86. package/chunks/kiro-THWCXS5L.js +0 -1
  87. package/chunks/node-AZK2C657.js +0 -12
  88. package/chunks/node-GQQ42DT2.js +0 -68
  89. package/chunks/ollama-2KAMCXVL.js +0 -1
  90. package/chunks/openai-HHE35TAX.js +0 -31
  91. package/chunks/opencode-S4M7WJTO.js +0 -1
@@ -1 +1 @@
1
- import{a as $,b as V,h as E,i as B,j as H,k as m,l as a,m as h,n as y,o as w}from"./chunk-AUZWXMWA.js";import"./chunk-KM64FL2X.js";import{a as Q}from"./chunk-EIMBEXUJ.js";import{a as ce,b as le}from"./chunk-KJLEPI7T.js";import{b as ie,e as oe,f as ae}from"./chunk-5DZHAHXW.js";import{d as re}from"./chunk-7PPUGTKL.js";import{N as ne}from"./chunk-UE56BMAW.js";import"./chunk-XDRX4ZBJ.js";import{a as ee,c as te,d as se}from"./chunk-IFE5SYGK.js";import"./chunk-CTTMQSHF.js";import{a as Z}from"./chunk-Z7OYXH3J.js";import"./chunk-VXU6XZ66.js";import"./chunk-EJYSOUEA.js";import"./chunk-JYVB6UAV.js";import"./chunk-VJRCTYGL.js";import"./chunk-PKEQKXZW.js";import{b as j}from"./chunk-O4KKKYCH.js";import{D as X,b as W,c as G,g as J,k as Y,n as q,o as O,p as z,r as K,t as U}from"./chunk-KRKOWSYW.js";import"./chunk-IGDFEGCH.js";import"./chunk-ENP4P2YH.js";import"./chunk-575Y3OEG.js";import"./chunk-4PF2MT7S.js";import"./chunk-CH6A3LES.js";import{a as _}from"./chunk-OAWYVETM.js";import{i as g}from"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var de=Q;var ve=async t=>{try{return await g.fs.stat(t),!0}catch{return!1}},Se=[{id:"claude-code",paths:["CLAUDE.md",".claude"]},{id:"cursor",paths:[".cursorrules",".cursor"]},{id:"kiro",paths:[".kiro"]},{id:"copilot",paths:[".github/copilot-instructions.md"]},{id:"windsurf",paths:[".windsurfrules"]},{id:"codex",paths:[".codex",".codex/config.toml"]},{id:"copilot-cli",paths:[".copilot",".github/hooks"]}],ue=async t=>{let e=[];for(let i of Se)for(let n of i.paths)if(await ve(`${t}/${n}`)){e.push(i.id);break}return e};var l=async t=>{try{return await g.fs.stat(t),!0}catch{return!1}},pe=async(t,e)=>{try{let i=await g.fs.readTextFile(t);return JSON.parse(i)[e]??null}catch{return null}},Pe=async t=>{let e=[];return(await l(`${t}/package.json`)||await l(`${t}/deno.json`))&&e.push("typescript"),await l(`${t}/go.mod`)&&e.push("go"),await l(`${t}/Cargo.toml`)&&e.push("rust"),(await l(`${t}/pyproject.toml`)||await l(`${t}/setup.py`))&&e.push("python"),e},Te=async t=>{let e=[],i=await pe(`${t}/package.json`,"dependencies");return i!==null&&("react"in i&&e.push("react"),"vue"in i&&e.push("vue"),"svelte"in i&&e.push("svelte"),"next"in i&&e.push("nextjs"),"express"in i&&e.push("express"),"hono"in i&&e.push("hono")),e},be=async t=>{let e=[];return await l(`${t}/.github/workflows`)&&e.push("github-actions"),await l(`${t}/.gitlab-ci.yml`)&&e.push("gitlab-ci"),await l(`${t}/Jenkinsfile`)&&e.push("jenkins"),await l(`${t}/.circleci`)&&e.push("circleci"),e},Ie=async t=>{if(await l(`${t}/deno.json`))return"deno";let e=await pe(`${t}/package.json`,"devDependencies");if(e!==null){if("vitest"in e)return"vitest";if("jest"in e)return"jest";if("playwright"in e)return"playwright"}return null},ge=async t=>{let[e,i,n,u]=await Promise.all([Pe(t),Te(t),be(t),Ie(t)]);return{languages:e,frameworks:i,ci:n,testRunner:u}};var me=(t,e)=>{let i=String(e.concernCount).padStart(2);m(t),a(t,"\u2714 noskills is ready"),m(t),a(t," Your project has:"),a(t,` \u2022 ${i} active concerns shaping every spec`),a(t," \u2022 Hooks enforcing quality gates"),e.toolCount>0&&a(t," \u2022 Rules synced to your coding tools"),m(t),a(t," To start your first spec:"),a(t," 1. Switch to PLAN MODE in your coding tool"),a(t," (Claude Code: Shift+Tab twice)"),a(t," 2. Describe what you want to build"),a(t," 3. noskills will guide you through discovery"),m(t),a(t,' Or just type: noskills spec new "your feature description"')};var Ke=async t=>{let e=g.process.cwd(),i=ce(t),n=V({target:i==="agent"?"non-interactive":"interactive"}),u=le(t),C=fe(u,"--concerns"),f=fe(u,"--tools"),p=u.includes("--non-interactive")||i==="agent",P=await X(e);B(n,"noskills init");let x=w(n,"Checking directories...");x.start(),await U(e),x.succeed("Config: .eser/");let A=w(n,"Scanning project...");A.start();let T=await ge(e);A.succeed("Project scanned");for(let s of T.languages)y.step(n,` ${s}`);for(let s of T.frameworks)y.step(n,` ${s}`);h(n);let L=w(n,"Detecting coding tools...");L.start();let R=await ue(e),v=Z(),N=v!==null&&!R.includes(v)?[v]:[],S=[...new Set([...N,...R])];L.succeed(`${S.length} coding tool(s) detected`);let d;if(f!==null){let s=["claude-code","cursor","kiro","copilot","windsurf","opencode","codex","copilot-cli"],o=f.filter(r=>s.includes(r));d=[...new Set([...N,...o])]}else if(P){let s=await O(e);d=s!==null?[...s.tools]:[...S]}else p?d=[...S]:(h(n),d=await je(n,S,v));h(n);let M=w(n,"Detecting AI providers...");M.start();let b=(await de()).filter(s=>s.available).map(s=>s.name);M.succeed(`${b.length} provider(s) detected`),h(n);let I=await j(),c;if(C!==null){let s=I.map(o=>o.id);c=C.filter(o=>s.includes(o)).sort((o,r)=>s.indexOf(o)-s.indexOf(r))}else if(P){let s=await O(e);c=s!==null?[...s.concerns]:[]}else if(p)c=[];else{let s=I.map(r=>({value:r.id,label:r.name,hint:r.description.slice(0,60)})),o=await E(n,{message:"What kind of project is this? (space to toggle, enter to confirm)",options:s});c=$(o)?[]:[...o]}c.length>0&&y.success(n,` Concerns: ${c.join(", ")}`),h(n);let he=I.filter(s=>c.includes(s.id));for(let s of he)await K(e,s);let F=await se();ee(F);let D={...G(c,d,b,T),command:F};if(await z(e,D),!P){let s=W();await Y(e,s)}if(d.length>0){let s=w(n,"Syncing tool files...");s.start();let o=await ae(e,d,D);s.succeed(`Synced ${o.length} tool(s)`);for(let r of o)y.step(n,` ${r}`)}if(H(n,`Done. ${d.length} tool(s), ${b.length} provider(s), ${c.length} concern(s).`),i==="agent"){let s=await J(e),r=(await j()).filter(ye=>c.includes(ye.id)),k=await ie(e),we=oe(D?.tools??[]),Ce=await ne(s,r,k,D,void 0,void 0,void 0,we);await re(Ce,"json")}else{let s=new Set(["DISCOVERY","DISCOVERY_REFINEMENT","SPEC_PROPOSAL","SPEC_APPROVED","EXECUTING","BLOCKED"]),o=[];try{o=await q(e)}catch{}o.some(k=>s.has(k.phase??""))?(m(n),a(n,`Start a spec with: ${te('spec new "..."')}`)):me(n,{concernCount:c.length,toolCount:d.length})}return _(void 0)},Ee=[{value:"claude-code",label:"Claude Code"},{value:"cursor",label:"Cursor"},{value:"kiro",label:"Kiro"},{value:"copilot",label:"GitHub Copilot"},{value:"windsurf",label:"Windsurf"},{value:"opencode",label:"OpenCode"},{value:"codex",label:"Codex CLI"},{value:"copilot-cli",label:"Copilot CLI"}],je=async(t,e,i)=>{let n=e.length===0?"No coding tools detected. Which tools do you use? (space to toggle)":"Any additional tools? (space to toggle, enter to skip)",u=new Set(e),C=await E(t,{message:n,options:Ee.map(p=>({...p,hint:p.value===i?"you're running inside it":u.has(p.value)?"detected":void 0,disabled:p.value===i})),initialValues:[...e],required:!1});if($(C))return[...e];let f=[...C];return i!==null&&!f.includes(i)&&f.unshift(i),f},fe=(t,e)=>{if(t===void 0)return null;for(let i of t)if(i.startsWith(`${e}=`))return i.slice(e.length+1).split(",").map(n=>n.trim()).filter(Boolean);return null};export{Ke as main};
1
+ import{a as $,b as V,h as E,i as B,j as H,k as m,l as a,m as h,n as y,o as w}from"./chunk-AUZWXMWA.js";import"./chunk-J25XTDQQ.js";import"./chunk-CTTMQSHF.js";import{a as Q}from"./chunk-IM73MYMS.js";import"./chunk-VXU6XZ66.js";import{a as ce,b as le}from"./chunk-KJLEPI7T.js";import{a as Z}from"./chunk-Z7OYXH3J.js";import{b as ie,e as oe,f as ae}from"./chunk-LKZZ4JN5.js";import{d as re}from"./chunk-7PPUGTKL.js";import{N as ne}from"./chunk-EVJYA7S3.js";import"./chunk-XDRX4ZBJ.js";import{a as ee,c as te,d as se}from"./chunk-IFE5SYGK.js";import"./chunk-EJYSOUEA.js";import"./chunk-JYVB6UAV.js";import"./chunk-VJRCTYGL.js";import{b as j}from"./chunk-O4KKKYCH.js";import"./chunk-ONJVI5AZ.js";import{D as X,b as W,c as G,g as J,k as Y,n as q,o as O,p as z,r as K,t as U}from"./chunk-WDKWHGJU.js";import"./chunk-HB62UGZI.js";import"./chunk-ENP4P2YH.js";import"./chunk-3JTDWOAJ.js";import"./chunk-34RPTI4K.js";import"./chunk-CH6A3LES.js";import{a as _}from"./chunk-OAWYVETM.js";import{i as g}from"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var de=Q;var ve=async t=>{try{return await g.fs.stat(t),!0}catch{return!1}},Se=[{id:"claude-code",paths:["CLAUDE.md",".claude"]},{id:"cursor",paths:[".cursorrules",".cursor"]},{id:"kiro",paths:[".kiro"]},{id:"copilot",paths:[".github/copilot-instructions.md"]},{id:"windsurf",paths:[".windsurfrules"]},{id:"codex",paths:[".codex",".codex/config.toml"]},{id:"copilot-cli",paths:[".copilot",".github/hooks"]}],ue=async t=>{let e=[];for(let i of Se)for(let n of i.paths)if(await ve(`${t}/${n}`)){e.push(i.id);break}return e};var l=async t=>{try{return await g.fs.stat(t),!0}catch{return!1}},pe=async(t,e)=>{try{let i=await g.fs.readTextFile(t);return JSON.parse(i)[e]??null}catch{return null}},Pe=async t=>{let e=[];return(await l(`${t}/package.json`)||await l(`${t}/deno.json`))&&e.push("typescript"),await l(`${t}/go.mod`)&&e.push("go"),await l(`${t}/Cargo.toml`)&&e.push("rust"),(await l(`${t}/pyproject.toml`)||await l(`${t}/setup.py`))&&e.push("python"),e},Te=async t=>{let e=[],i=await pe(`${t}/package.json`,"dependencies");return i!==null&&("react"in i&&e.push("react"),"vue"in i&&e.push("vue"),"svelte"in i&&e.push("svelte"),"next"in i&&e.push("nextjs"),"express"in i&&e.push("express"),"hono"in i&&e.push("hono")),e},be=async t=>{let e=[];return await l(`${t}/.github/workflows`)&&e.push("github-actions"),await l(`${t}/.gitlab-ci.yml`)&&e.push("gitlab-ci"),await l(`${t}/Jenkinsfile`)&&e.push("jenkins"),await l(`${t}/.circleci`)&&e.push("circleci"),e},Ie=async t=>{if(await l(`${t}/deno.json`))return"deno";let e=await pe(`${t}/package.json`,"devDependencies");if(e!==null){if("vitest"in e)return"vitest";if("jest"in e)return"jest";if("playwright"in e)return"playwright"}return null},ge=async t=>{let[e,i,n,u]=await Promise.all([Pe(t),Te(t),be(t),Ie(t)]);return{languages:e,frameworks:i,ci:n,testRunner:u}};var me=(t,e)=>{let i=String(e.concernCount).padStart(2);m(t),a(t,"\u2714 noskills is ready"),m(t),a(t," Your project has:"),a(t,` \u2022 ${i} active concerns shaping every spec`),a(t," \u2022 Hooks enforcing quality gates"),e.toolCount>0&&a(t," \u2022 Rules synced to your coding tools"),m(t),a(t," To start your first spec:"),a(t," 1. Switch to PLAN MODE in your coding tool"),a(t," (Claude Code: Shift+Tab twice)"),a(t," 2. Describe what you want to build"),a(t," 3. noskills will guide you through discovery"),m(t),a(t,' Or just type: noskills spec new "your feature description"')};var Ke=async t=>{let e=g.process.cwd(),i=ce(t),n=V({target:i==="agent"?"non-interactive":"interactive"}),u=le(t),C=fe(u,"--concerns"),f=fe(u,"--tools"),p=u.includes("--non-interactive")||i==="agent",P=await X(e);B(n,"noskills init");let x=w(n,"Checking directories...");x.start(),await U(e),x.succeed("Config: .eser/");let A=w(n,"Scanning project...");A.start();let T=await ge(e);A.succeed("Project scanned");for(let s of T.languages)y.step(n,` ${s}`);for(let s of T.frameworks)y.step(n,` ${s}`);h(n);let L=w(n,"Detecting coding tools...");L.start();let R=await ue(e),v=Z(),N=v!==null&&!R.includes(v)?[v]:[],S=[...new Set([...N,...R])];L.succeed(`${S.length} coding tool(s) detected`);let d;if(f!==null){let s=["claude-code","cursor","kiro","copilot","windsurf","opencode","codex","copilot-cli"],o=f.filter(r=>s.includes(r));d=[...new Set([...N,...o])]}else if(P){let s=await O(e);d=s!==null?[...s.tools]:[...S]}else p?d=[...S]:(h(n),d=await je(n,S,v));h(n);let M=w(n,"Detecting AI providers...");M.start();let b=(await de()).filter(s=>s.available).map(s=>s.name);M.succeed(`${b.length} provider(s) detected`),h(n);let I=await j(),c;if(C!==null){let s=I.map(o=>o.id);c=C.filter(o=>s.includes(o)).sort((o,r)=>s.indexOf(o)-s.indexOf(r))}else if(P){let s=await O(e);c=s!==null?[...s.concerns]:[]}else if(p)c=[];else{let s=I.map(r=>({value:r.id,label:r.name,hint:r.description.slice(0,60)})),o=await E(n,{message:"What kind of project is this? (space to toggle, enter to confirm)",options:s});c=$(o)?[]:[...o]}c.length>0&&y.success(n,` Concerns: ${c.join(", ")}`),h(n);let he=I.filter(s=>c.includes(s.id));for(let s of he)await K(e,s);let F=await se();ee(F);let D={...G(c,d,b,T),command:F};if(await z(e,D),!P){let s=W();await Y(e,s)}if(d.length>0){let s=w(n,"Syncing tool files...");s.start();let o=await ae(e,d,D);s.succeed(`Synced ${o.length} tool(s)`);for(let r of o)y.step(n,` ${r}`)}if(H(n,`Done. ${d.length} tool(s), ${b.length} provider(s), ${c.length} concern(s).`),i==="agent"){let s=await J(e),r=(await j()).filter(ye=>c.includes(ye.id)),k=await ie(e),we=oe(D?.tools??[]),Ce=await ne(s,r,k,D,void 0,void 0,void 0,we);await re(Ce,"json")}else{let s=new Set(["DISCOVERY","DISCOVERY_REFINEMENT","SPEC_PROPOSAL","SPEC_APPROVED","EXECUTING","BLOCKED"]),o=[];try{o=await q(e)}catch{}o.some(k=>s.has(k.phase??""))?(m(n),a(n,`Start a spec with: ${te('spec new "..."')}`)):me(n,{concernCount:c.length,toolCount:d.length})}return _(void 0)},Ee=[{value:"claude-code",label:"Claude Code"},{value:"cursor",label:"Cursor"},{value:"kiro",label:"Kiro"},{value:"copilot",label:"GitHub Copilot"},{value:"windsurf",label:"Windsurf"},{value:"opencode",label:"OpenCode"},{value:"codex",label:"Codex CLI"},{value:"copilot-cli",label:"Copilot CLI"}],je=async(t,e,i)=>{let n=e.length===0?"No coding tools detected. Which tools do you use? (space to toggle)":"Any additional tools? (space to toggle, enter to skip)",u=new Set(e),C=await E(t,{message:n,options:Ee.map(p=>({...p,hint:p.value===i?"you're running inside it":u.has(p.value)?"detected":void 0,disabled:p.value===i})),initialValues:[...e],required:!1});if($(C))return[...e];let f=[...C];return i!==null&&!f.includes(i)&&f.unshift(i),f},fe=(t,e)=>{if(t===void 0)return null;for(let i of t)if(i.startsWith(`${e}=`))return i.slice(e.length+1).split(",").map(n=>n.trim()).filter(Boolean);return null};export{Ke as main};
@@ -1,4 +1,4 @@
1
- import{a as L,b as $,c as A,d as F}from"./chunk-DEHRWREM.js";import{a as q,b as B}from"./chunk-W4TQLLUK.js";import{a as Q}from"./chunk-NGCBWJML.js";import{a as V,b as W,d as K,e as J}from"./chunk-5DZHAHXW.js";import{N as Y,O as v}from"./chunk-UE56BMAW.js";import"./chunk-XDRX4ZBJ.js";import{c as k}from"./chunk-IFE5SYGK.js";import"./chunk-VJRCTYGL.js";import"./chunk-PKEQKXZW.js";import{f as G}from"./chunk-O4KKKYCH.js";import{D as M,f,g as C,h as N,o as O,s as x,w as _,x as U}from"./chunk-KRKOWSYW.js";import{a}from"./chunk-OAWYVETM.js";import{i}from"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var X=e=>new Set(e.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu," ").split(/\s+/).filter(n=>n.length>2)),z=(e,n)=>{let s=X(e),t=X(n);if(s.size===0||t.size===0)return 0;let c=0;for(let r of s)t.has(r)&&c++;let o=s.size+t.size-c;return o===0?0:c/o};var I=async()=>{let e=i.process.stdin.getReader(),n=[];try{for(;;){let{done:o,value:r}=await e.read();if(o||r===void 0)break;n.push(r)}}finally{e.releaseLock()}let s=0,t=new Uint8Array(n.reduce((o,r)=>o+r.length,0));for(let o of n)t.set(o,s),s+=o.length;let c=new TextDecoder().decode(t);try{return JSON.parse(c)}catch{return{}}},b=async e=>{let n=new TextEncoder,s=i.process.stdout.getWriter();await s.write(n.encode(JSON.stringify(e))),s.releaseLock()},ye=async e=>{switch(e?.[0]){case"pre-tool-use":return await ne();case"stop":return await ie();case"post-file-write":return await oe();case"post-bash":return await re();case"session-start":return await ae();case"post-ask-user-question":return await le();default:return a(void 0)}},y=async e=>{await b({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`noskills: ${e}`}})},se=async e=>{await b({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"allow",additionalContext:e}})},H=(e,n)=>{if(n)return null;let s=F(e);if(!s.includes("git"))return null;let t=$(s);for(let c of t)if(!L(c))return"Git write operations are not allowed. Only read commands (log, diff, status, show, blame, branch, tag) are permitted. The user controls git, the agent controls files.";return A(s)?"Git write operations detected in subshell or pipe. Only read commands are permitted. The user controls git, the agent controls files.":null},ne=async()=>{let e=await I(),n=e.tool_name??"unknown",s=e.tool_input??{},t=e.cwd??i.env.get("NOSKILLS_PROJECT_ROOT")??i.process.cwd(),c=await O(t),o=i.env.get("NOSKILLS_SESSION")??null;if(o!==null){let l=await _(t,o);if(l!==null&&l.mode==="free"){if(n==="Bash"){let d=(s.command??"").trim(),u=c?.allowGit??!1;if(!u&&d.includes("git")){let w=H(d,u);if(w!==null)return await y(w),a(void 0)}}return a(void 0)}}let r={};if(o!==null){let l=await _(t,o);if(l!==null&&l.mode==="spec"&&l.phase!==null)r={phase:l.phase};else if(l!==null&&l.spec!==null)try{r=await N(t,l.spec)}catch{return a(void 0)}else return a(void 0)}else{let l=await U(t);if(l.length>0){let d={DISCOVERY:10,DISCOVERY_REFINEMENT:10,SPEC_PROPOSAL:10,SPEC_APPROVED:8,BLOCKED:8,EXECUTING:2,IDLE:0,COMPLETED:0},u="IDLE",w=0;for(let D of l){let S=D.phase??"IDLE",T=d[S]??0;T>w&&(w=T,u=S)}r={phase:u};let R=new TextEncoder,h=i.process.stderr.getWriter();await h.write(R.encode(`noskills: WARNING \u2014 ${l.length} session(s) active but NOSKILLS_SESSION not set. Using most restrictive phase (${u}). Set NOSKILLS_SESSION for correct per-instance enforcement.
1
+ import{a as L,b as $,c as A,d as F}from"./chunk-DEHRWREM.js";import{a as q,b as B}from"./chunk-T6NZVA6P.js";import{a as Q}from"./chunk-NGCBWJML.js";import{a as V,b as W,d as K,e as J}from"./chunk-LKZZ4JN5.js";import{N as Y,O as v}from"./chunk-EVJYA7S3.js";import"./chunk-XDRX4ZBJ.js";import{c as k}from"./chunk-IFE5SYGK.js";import"./chunk-VJRCTYGL.js";import{f as G}from"./chunk-O4KKKYCH.js";import"./chunk-ONJVI5AZ.js";import{D as M,f,g as C,h as N,o as O,s as x,w as _,x as U}from"./chunk-WDKWHGJU.js";import{a}from"./chunk-OAWYVETM.js";import{i}from"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var X=e=>new Set(e.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu," ").split(/\s+/).filter(n=>n.length>2)),z=(e,n)=>{let s=X(e),t=X(n);if(s.size===0||t.size===0)return 0;let c=0;for(let r of s)t.has(r)&&c++;let o=s.size+t.size-c;return o===0?0:c/o};var I=async()=>{let e=i.process.stdin.getReader(),n=[];try{for(;;){let{done:o,value:r}=await e.read();if(o||r===void 0)break;n.push(r)}}finally{e.releaseLock()}let s=0,t=new Uint8Array(n.reduce((o,r)=>o+r.length,0));for(let o of n)t.set(o,s),s+=o.length;let c=new TextDecoder().decode(t);try{return JSON.parse(c)}catch{return{}}},b=async e=>{let n=new TextEncoder,s=i.process.stdout.getWriter();await s.write(n.encode(JSON.stringify(e))),s.releaseLock()},ye=async e=>{switch(e?.[0]){case"pre-tool-use":return await ne();case"stop":return await ie();case"post-file-write":return await oe();case"post-bash":return await re();case"session-start":return await ae();case"post-ask-user-question":return await le();default:return a(void 0)}},y=async e=>{await b({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`noskills: ${e}`}})},se=async e=>{await b({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"allow",additionalContext:e}})},H=(e,n)=>{if(n)return null;let s=F(e);if(!s.includes("git"))return null;let t=$(s);for(let c of t)if(!L(c))return"Git write operations are not allowed. Only read commands (log, diff, status, show, blame, branch, tag) are permitted. The user controls git, the agent controls files.";return A(s)?"Git write operations detected in subshell or pipe. Only read commands are permitted. The user controls git, the agent controls files.":null},ne=async()=>{let e=await I(),n=e.tool_name??"unknown",s=e.tool_input??{},t=e.cwd??i.env.get("NOSKILLS_PROJECT_ROOT")??i.process.cwd(),c=await O(t),o=i.env.get("NOSKILLS_SESSION")??null;if(o!==null){let l=await _(t,o);if(l!==null&&l.mode==="free"){if(n==="Bash"){let d=(s.command??"").trim(),u=c?.allowGit??!1;if(!u&&d.includes("git")){let w=H(d,u);if(w!==null)return await y(w),a(void 0)}}return a(void 0)}}let r={};if(o!==null){let l=await _(t,o);if(l!==null&&l.mode==="spec"&&l.phase!==null)r={phase:l.phase};else if(l!==null&&l.spec!==null)try{r=await N(t,l.spec)}catch{return a(void 0)}else return a(void 0)}else{let l=await U(t);if(l.length>0){let d={DISCOVERY:10,DISCOVERY_REFINEMENT:10,SPEC_PROPOSAL:10,SPEC_APPROVED:8,BLOCKED:8,EXECUTING:2,IDLE:0,COMPLETED:0},u="IDLE",w=0;for(let D of l){let S=D.phase??"IDLE",T=d[S]??0;T>w&&(w=T,u=S)}r={phase:u};let R=new TextEncoder,h=i.process.stderr.getWriter();await h.write(R.encode(`noskills: WARNING \u2014 ${l.length} session(s) active but NOSKILLS_SESSION not set. Using most restrictive phase (${u}). Set NOSKILLS_SESSION for correct per-instance enforcement.
2
2
  `)),h.releaseLock()}else try{let d=await C(t),u=d;if(d.spec!==null&&d.spec!==void 0)try{u=await N(t,d.spec)}catch{}r=u}catch{return a(void 0)}}if(n==="Bash"){let l=(s.command??"").trim(),d=c?.allowGit??!1,u=H(l,d);return u!==null?(await y(u),a(void 0)):a(void 0)}let m=["Write","Edit","MultiEdit"];if(!m.includes(n))return a(void 0);let p=s.file_path??s.path??"";if(p.includes(".eser/")||p.includes(".claude/"))return a(void 0);let g=r.phase??"UNKNOWN";if(g==="UNKNOWN")return await y("Phase unknown \u2014 file edit blocked. Run `noskills status` to check state."),a(void 0);if(g==="EXECUTING"&&r.execution?.criteriaScope==="review-gate")return await y('Review gate active \u2014 file edits blocked. Evaluate concern dimensions against the existing implementation and submit findings via `noskills next --answer=\'{"completed":[...],"remaining":[]}\'`.'),a(void 0);if(g==="EXECUTING"||g==="IDLE"||g==="COMPLETED"){if(g==="EXECUTING"&&m.includes(n)){let l=`${t}/${f.progressesDir}/executor-warned.flag`;try{await i.fs.readTextFile(l)}catch{try{await i.fs.mkdir(`${t}/${f.progressesDir}`,{recursive:!0}),await i.fs.writeTextFile(l,new Date().toISOString());let d=new TextEncoder,u=i.process.stderr.getWriter();await u.write(d.encode(`noskills: REMINDER \u2014 You should be spawning a noskills-executor sub-agent for implementation work. If you're the main orchestrator agent, delegate to a sub-agent instead of editing directly. If you ARE a sub-agent, ignore this message and continue.
3
3
  `)),u.releaseLock()}catch{}}}if(g==="EXECUTING"&&p.length>0)try{let l=[],d=await V(t),u=K(d,"EXECUTING",p);l.push(...u);let w=await Q(t,[p]);for(let E of w)l.push(`(${E.folder}/) ${E.rule}`);let h=r.classification??null,D=await x(t),S=await O(t),T=D.filter(E=>S!==null&&S.concerns.includes(E.id)),j=G(T,p,h);if(l.push(...j),l.length>0){let E=`[noskills] Rules for this file:
4
4
  `+l.map(Z=>`- ${Z}`).join(`
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-CKIZYL4O.js";import"./chunk-Y45DQJSS.js";import"./chunk-JYVB6UAV.js";import"./chunk-HB62UGZI.js";import"./chunk-ENP4P2YH.js";import"./chunk-3JTDWOAJ.js";import"./chunk-34RPTI4K.js";import"./chunk-OAWYVETM.js";import"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";export{a as KiroModel,b as kiroFactory};
@@ -1,4 +1,4 @@
1
- import{f as R}from"./chunk-5DZHAHXW.js";import{a as D,b as x,c as C}from"./chunk-XDRX4ZBJ.js";import"./chunk-IFE5SYGK.js";import{c as P,d as a,f as o,g,o as b,q as I,r as T}from"./chunk-VXU6XZ66.js";import{E as S,f as k,i as E,o as L}from"./chunk-KRKOWSYW.js";import{a as u,b as w}from"./chunk-OAWYVETM.js";import{i as $}from"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var U=async(i,e,t)=>{let d=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,50),h=`---
1
+ import{c as P,d as a,f as o,g,o as b,q as I,r as T}from"./chunk-VXU6XZ66.js";import{f as R}from"./chunk-LKZZ4JN5.js";import{a as D,b as x,c as C}from"./chunk-XDRX4ZBJ.js";import"./chunk-IFE5SYGK.js";import{E as S,f as k,i as E,o as L}from"./chunk-WDKWHGJU.js";import{a as u,b as w}from"./chunk-OAWYVETM.js";import{i as $}from"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var U=async(i,e,t)=>{let d=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,50),h=`---
2
2
  phases: [EXECUTING]
3
3
  source: learned from spec "${t}" on ${new Date().toISOString().slice(0,10)}
4
4
  ---
@@ -1 +1 @@
1
- import{a as k,d as m}from"./chunk-7PPUGTKL.js";import{b as n}from"./chunk-IFE5SYGK.js";import{d as u,f as p,o as c,q as f,r as g}from"./chunk-VXU6XZ66.js";import{d as y,e as w,f as h}from"./chunk-GQTHILPL.js";import"./chunk-VJRCTYGL.js";import"./chunk-PKEQKXZW.js";import"./chunk-O4KKKYCH.js";import{E as S,i as L}from"./chunk-KRKOWSYW.js";import{a as o,b as l}from"./chunk-OAWYVETM.js";import"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var A=a=>{for(let t of a)if(t.startsWith("--format=")){let e=t.slice(9).toLowerCase();if(e==="measurement-draft"||e==="measurement"||e==="draft")return"measurement-draft"}return"ledger"},D=async a=>{let{root:t}=await S(),e=a??[],F=L(e),x=e.find(s=>!s.startsWith("-")),r=F??x??null,d=k(e);if(r===null||r.length===0){let s=c({renderer:g.ansi(),sink:f.stdout()});return s.writeln(p("Error: spec name is required.")),s.writeln(u(`Usage: ${n()} spec <name> ledger (or: ${n()} ledger <name>)`)),await s.close(),l({exitCode:1})}let i=await w(t,r);if(A(e)==="measurement-draft")return await m(y(r,i),d),o(void 0);let v=await h(t,r);return await m({spec:r,records:i,summary:v},d),o(void 0)};export{D as main};
1
+ import{d as u,f as p,o as c,q as f,r as g}from"./chunk-VXU6XZ66.js";import{a as k,d as m}from"./chunk-7PPUGTKL.js";import{b as n}from"./chunk-IFE5SYGK.js";import{d as y,e as w,f as h}from"./chunk-5FX4EBFY.js";import"./chunk-VJRCTYGL.js";import"./chunk-O4KKKYCH.js";import"./chunk-ONJVI5AZ.js";import{E as S,i as L}from"./chunk-WDKWHGJU.js";import{a as o,b as l}from"./chunk-OAWYVETM.js";import"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var A=a=>{for(let t of a)if(t.startsWith("--format=")){let e=t.slice(9).toLowerCase();if(e==="measurement-draft"||e==="measurement"||e==="draft")return"measurement-draft"}return"ledger"},D=async a=>{let{root:t}=await S(),e=a??[],F=L(e),x=e.find(s=>!s.startsWith("-")),r=F??x??null,d=k(e);if(r===null||r.length===0){let s=c({renderer:g.ansi(),sink:f.stdout()});return s.writeln(p("Error: spec name is required.")),s.writeln(u(`Usage: ${n()} spec <name> ledger (or: ${n()} ledger <name>)`)),await s.close(),l({exitCode:1})}let i=await w(t,r);if(A(e)==="measurement-draft")return await m(y(r,i),d),o(void 0);let v=await h(t,r);return await m({spec:r,records:i,summary:v},d),o(void 0)};export{D as main};
@@ -1 +1 @@
1
- import{a as p}from"./chunk-EIMBEXUJ.js";import{c as t,d as a,g as l,m as n,o,q as m,r as d}from"./chunk-VXU6XZ66.js";import"./chunk-IGDFEGCH.js";import"./chunk-ENP4P2YH.js";import"./chunk-575Y3OEG.js";import"./chunk-4PF2MT7S.js";import{a as i}from"./chunk-OAWYVETM.js";import"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var $=async b=>{let e=o({renderer:d.ansi(),sink:m.stdout()});e.writeln(t("AI Providers")),e.writeln("");let r=await p(),v=r.map(s=>[s.available?l("\u25CF"):a("\u25CB"),s.available?t(`${s.name} (${s.alias})`):a(`${s.name} (${s.alias})`),a(s.type),s.available?s.detail:a(s.detail)]);e.writeln(n(["","Provider","Type","Status"],v));let u=r.filter(s=>s.available).length;return e.writeln(a(`${u}/${r.length} providers available`)),await e.close(),i(void 0)};export{$ as main};
1
+ import{a as p}from"./chunk-IM73MYMS.js";import{c as t,d as a,g as l,m as n,o,q as m,r as d}from"./chunk-VXU6XZ66.js";import"./chunk-HB62UGZI.js";import"./chunk-ENP4P2YH.js";import"./chunk-3JTDWOAJ.js";import"./chunk-34RPTI4K.js";import{a as i}from"./chunk-OAWYVETM.js";import"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var $=async b=>{let e=o({renderer:d.ansi(),sink:m.stdout()});e.writeln(t("AI Providers")),e.writeln("");let r=await p(),v=r.map(s=>[s.available?l("\u25CF"):a("\u25CB"),s.available?t(`${s.name} (${s.alias})`):a(`${s.name} (${s.alias})`),a(s.type),s.available?s.detail:a(s.detail)]);e.writeln(n(["","Provider","Type","Status"],v));let u=r.filter(s=>s.available).length;return e.writeln(a(`${u}/${r.length} providers available`)),await e.close(),i(void 0)};export{$ as main};
@@ -1,3 +1,3 @@
1
- import"./chunk-DEHRWREM.js";import{b as ve,c as xe}from"./chunk-DBKXMYLF.js";import"./chunk-Q4TI7EYT.js";import{c as me,d as Ue,e as $e,p as C,q as f,r as $,s as fe,t as He,u as W,v as Ge}from"./chunk-AUZWXMWA.js";import{a as nt}from"./chunk-EROZRDGT.js";import"./chunk-LN4NDYT6.js";import{h as be}from"./chunk-5RLCKUIF.js";import"./chunk-UE56BMAW.js";import"./chunk-XDRX4ZBJ.js";import{b as Se}from"./chunk-IFE5SYGK.js";import"./chunk-VXU6XZ66.js";import"./chunk-GQTHILPL.js";import"./chunk-VJRCTYGL.js";import"./chunk-PKEQKXZW.js";import"./chunk-O4KKKYCH.js";import{A as Ye,C as we,D as Je,E as Ze,f as We,g as qe,h as ye,l as je,n as Xe,o as Qe,v as ge,y as he}from"./chunk-KRKOWSYW.js";import{f as et,g as tt}from"./chunk-IGDFEGCH.js";import"./chunk-ENP4P2YH.js";import"./chunk-575Y3OEG.js";import"./chunk-4PF2MT7S.js";import{a as pe,b as _e}from"./chunk-OAWYVETM.js";import{i as U}from"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import{m as ue}from"./chunk-FE4MKOI4.js";import{d as j}from"./chunk-HISXAZ4Y.js";var Z={};j(Z,{createInitialState:()=>Ie,geometry:()=>Ae,reduce:()=>J,sanitizeRemoteAction:()=>Ce,sanitizeRemoteMessage:()=>Me,sanitizeRemoteTransport:()=>ct,tree:()=>Y});var Y={};j(Y,{collectLeaves:()=>z,firstLeaf:()=>K,hasLeaf:()=>D,leaf:()=>X,removeLeaf:()=>H,resizeFocused:()=>Q,splitLeaf:()=>q});var rt=e=>e<.1?.1:e>.9?.9:e,X=e=>({kind:"leaf",pane:e}),z=e=>e.kind==="leaf"?[e.pane]:[...z(e.first),...z(e.second)],D=(e,t)=>e.kind==="leaf"?e.pane===t:D(e.first,t)||D(e.second,t),K=e=>{let t=e;for(;t.kind==="branch";)t=t.first;return t.pane},q=(e,t,n,r,o=.5)=>e.kind==="leaf"?e.pane!==t?e:{kind:"branch",direction:n,first:e,second:X(r),ratio:rt(o)}:D(e.first,t)?{...e,first:q(e.first,t,n,r,o)}:D(e.second,t)?{...e,second:q(e.second,t,n,r,o)}:e,H=(e,t)=>{if(e.kind==="leaf")return e.pane===t?{root:null,promoted:null}:{root:e,promoted:null};if(e.first.kind==="leaf"&&e.first.pane===t)return{root:e.second,promoted:K(e.second)};if(e.second.kind==="leaf"&&e.second.pane===t)return{root:e.first,promoted:K(e.first)};if(D(e.first,t)){let n=H(e.first,t);return n.root===null?{root:e.second,promoted:K(e.second)}:{root:{...e,first:n.root},promoted:n.promoted}}if(D(e.second,t)){let n=H(e.second,t);return n.root===null?{root:e.first,promoted:K(e.first)}:{root:{...e,second:n.root},promoted:n.promoted}}return{root:e,promoted:null}},Q=(e,t,n,r)=>{if(e.kind==="leaf")return e;let o=D(e.first,t)?"first":D(e.second,t)?"second":null;if(o===null)return e;let i=e[o],s=Q(i,t,n,r);if(s!==i)return{...e,[o]:s};let c=n==="left"||n==="right"?"vertical":"horizontal";if(e.direction!==c)return e;let u=n==="right"||n==="down"?1:-1;return{...e,ratio:rt(e.ratio+u*r)}};var Ae={};j(Ae,{DEFAULT_CHROME:()=>L,computeTabGeoms:()=>B,decorationRegions:()=>Ee,effectiveChrome:()=>Te,neighborInDirection:()=>Re});var L={tabBarRows:1,statusBarRows:1},xt=10,Pt=3,Te=(e,t)=>{let n=t.leftCols??0,r=t.rightCols??0,o=t.topRows??0,i=t.bottomRows??0;e.cols-n-r<xt&&(n=0,r=0);let s=t.tabBarRows+t.statusBarRows+o+i;return e.rows-s<Pt&&(o=0,i=0),{...t,leftCols:n,rightCols:r,topRows:o,bottomRows:i}},Ee=(e,t)=>{let n=t.leftCols??0,r=t.rightCols??0,o=t.topRows??0,i=t.bottomRows??0,s=t.tabBarRows+1,c=Math.max(0,e.rows-t.tabBarRows-t.statusBarRows),u=n+1,w=Math.max(0,e.cols-n-r),l={};return n>0&&(l.left={x:1,y:s,width:n,height:c}),r>0&&(l.right={x:e.cols-r+1,y:s,width:r,height:c}),o>0&&(l.top={x:u,y:s,width:w,height:o}),i>0&&(l.bottom={x:u,y:e.rows-t.statusBarRows-i+1,width:w,height:i}),l},ot=100,Pe=e=>{if(e.kind==="leaf")return{id:e.pane,size:{type:"flex",grow:1}};let t=e.direction==="vertical"?"row":"column",n=Math.max(1,Math.round(e.ratio*ot)),r=Math.max(1,Math.round((1-e.ratio)*ot));return{direction:t,size:{type:"flex",grow:1},children:[{...Pe(e.first),size:{type:"flex",grow:n}},{...Pe(e.second),size:{type:"flex",grow:r}}]}},B=(e,t,n)=>{let r=n.leftCols??0,o=n.rightCols??0,i=n.topRows??0,s=n.bottomRows??0,c=r,u=n.tabBarRows+i,w=Math.max(0,t.cols-r-o),l=Math.max(0,t.rows-n.tabBarRows-n.statusBarRows-i-s),b=new Map;if(e.fullscreenPane!==void 0)return b.set(e.fullscreenPane,{x:c,y:u,width:w,height:l}),b;let T=He.computeLayout(Pe(e.root),w,l);for(let v of T)v.id!==void 0&&b.set(v.id,{x:v.x+c,y:v.y+u,width:v.width,height:v.height});return b},Re=(e,t,n)=>{let r=e.get(t);if(r===void 0)return null;let o=n==="left"||n==="right",i=r.x+r.width/2,s=r.y+r.height/2,c=null,u=1/0;for(let[w,l]of e){if(w===t||!(o?l.y<r.y+r.height&&l.y+l.height>r.y:l.x<r.x+r.width&&l.x+l.width>r.x))continue;let T=o?l.x+l.width/2:l.y+l.height/2,v=o?i:s;if(!(n==="left"||n==="up"?T<v:T>v))continue;let d=Math.abs(T-v);d<u&&(u=d,c=w)}return c};var Tt=.05,O=[{type:"render"}],Ie=e=>({panes:{},tabs:[],activeTab:0,mode:"normal",viewport:e,running:!0,nextPaneSeq:1,nextTabSeq:1}),R=e=>({state:e,effects:[]}),F=e=>e.tabs[e.activeTab],V=(e,t)=>({...e,tabs:e.tabs.map((n,r)=>r===e.activeTab?t:n)}),it=(e,t)=>{let n=`pane-${e.nextPaneSeq}`,r={id:n,kind:t.kind??"terminal",title:t.title??t.command??"shell",cwd:t.cwd,command:t.command,args:t.args,meta:t.meta};return{pane:r,state:{...e,panes:{...e.panes,[n]:r},nextPaneSeq:e.nextPaneSeq+1}}},at=(e,t)=>{let n=e.tabs[t];if(n===void 0)return R(e);let r=z(n.root),o=r.map(u=>({type:"killPty",pane:u})),i={...e.panes};for(let u of r)delete i[u];let s=e.tabs.filter((u,w)=>w!==t);if(s.length===0)return{state:{...e,panes:i,tabs:s,running:!1},effects:[...o,{type:"exit"}]};let c=t<e.activeTab?e.activeTab-1:Math.min(e.activeTab,s.length-1);return{state:{...e,panes:i,tabs:s,activeTab:c},effects:[...o,{type:"render"}]}},Et=e=>at(e,e.activeTab),st=(e,t,n)=>{let r=F(e);if(r===void 0)return R(e);let{pane:o,state:i}=it(e,n),s=q(r.root,r.focusedPane,t,o.id),c={...r,root:s,focusedPane:o.id,fullscreenPane:void 0};return{state:V(i,c),effects:[{type:"spawnPty",pane:o.id},{type:"render"}]}},J=(e,t)=>{switch(t.type){case"switchMode":return{state:{...e,mode:t.mode},effects:O};case"splitPane":return st(e,t.direction,{});case"newPane":return st(e,t.direction??"vertical",{kind:t.kind,command:t.command,args:t.args,cwd:t.cwd,title:t.title,meta:t.meta});case"closeFocusedPane":{let n=F(e);if(n===void 0)return R(e);let r=n.focusedPane,{root:o,promoted:i}=H(n.root,r);if(o===null)return Et(e);let s={...e.panes};delete s[r];let c={...n,root:o,focusedPane:i??K(o),fullscreenPane:void 0};return{state:V({...e,panes:s},c),effects:[{type:"killPty",pane:r},{type:"render"}]}}case"focusDirection":{let n=F(e);if(n===void 0)return R(e);let r=B(n,e.viewport,L),o=Re(r,n.focusedPane,t.direction);return o===null?R(e):{state:V(e,{...n,focusedPane:o}),effects:O}}case"focusNext":case"focusPrev":{let n=F(e);if(n===void 0)return R(e);let r=z(n.root);if(r.length<=1)return R(e);let o=r.indexOf(n.focusedPane),i=t.type==="focusNext"?1:-1,s=r[(o+i+r.length)%r.length];return{state:V(e,{...n,focusedPane:s}),effects:O}}case"focusPane":{let n=F(e);return n===void 0||!D(n.root,t.pane)?R(e):{state:V(e,{...n,focusedPane:t.pane}),effects:O}}case"toggleFullscreen":{let n=F(e);if(n===void 0)return R(e);let r=n.fullscreenPane===n.focusedPane?void 0:n.focusedPane;return{state:V(e,{...n,fullscreenPane:r}),effects:O}}case"resizePane":{let n=F(e);if(n===void 0)return R(e);let r=Q(n.root,n.focusedPane,t.direction,Tt);return r===n.root?R(e):{state:V(e,{...n,root:r}),effects:O}}case"newTab":{let n=`tab-${e.nextTabSeq}`,{pane:r,state:o}=it(e,{kind:t.kind,command:t.command,args:t.args,cwd:t.cwd,title:t.title,meta:t.meta}),i={id:n,name:t.title??`tab ${e.nextTabSeq}`,root:X(r.id),focusedPane:r.id},s=[...o.tabs,i];return{state:{...o,tabs:s,activeTab:s.length-1,nextTabSeq:o.nextTabSeq+1},effects:[{type:"spawnPty",pane:r.id},{type:"render"}]}}case"closeTab":return at(e,t.index??e.activeTab);case"gotoTab":return t.index<0||t.index>=e.tabs.length?R(e):{state:{...e,activeTab:t.index},effects:O};case"nextTab":case"prevTab":{if(e.tabs.length<=1)return R(e);let n=t.type==="nextTab"?1:-1,r=(e.activeTab+n+e.tabs.length)%e.tabs.length;return{state:{...e,activeTab:r},effects:O}}case"scroll":{let n=F(e);return n===void 0?R(e):{state:e,effects:[{type:"scrollPane",pane:n.focusedPane,action:t.action}]}}case"writeInput":{let n=F(e);return n===void 0?R(e):{state:e,effects:[{type:"writePty",pane:n.focusedPane,data:t.data}]}}case"writeToPane":return e.panes[t.pane]===void 0?R(e):{state:e,effects:[{type:"writePty",pane:t.pane,data:t.data}]};case"resizeViewport":return{state:{...e,viewport:{cols:t.cols,rows:t.rows}},effects:O};case"paneExited":{let n=e.tabs.findIndex(l=>D(l.root,t.pane));if(n<0)return R(e);let r=e.tabs[n],{root:o,promoted:i}=H(r.root,t.pane),s={...e.panes};if(delete s[t.pane],o===null){let l=e.tabs.filter((T,v)=>v!==n);if(l.length===0)return{state:{...e,panes:s,tabs:l,running:!1},effects:[{type:"exit"}]};let b=n<e.activeTab?e.activeTab-1:Math.min(e.activeTab,l.length-1);return{state:{...e,panes:s,tabs:l,activeTab:b},effects:O}}let c=r.focusedPane===t.pane?i??K(o):r.focusedPane,u=r.fullscreenPane===t.pane?void 0:r.fullscreenPane,w={...r,root:o,focusedPane:c,fullscreenPane:u};return{state:{...e,panes:s,tabs:e.tabs.map((l,b)=>b===n?w:l)},effects:O}}case"detach":return{state:e,effects:[{type:"detach"}]};case"quit":return{state:{...e,running:!1},effects:[{type:"exit"}]}}};var Ce=e=>{if(e.type!=="newTab"&&e.type!=="newPane"||e.command===void 0&&e.args===void 0&&e.cwd===void 0)return e;let t={...e.kind===void 0?{}:{kind:e.kind},...e.title===void 0?{}:{title:e.title},...e.meta===void 0?{}:{meta:e.meta}};return e.type==="newPane"?{type:"newPane",...e.direction===void 0?{}:{direction:e.direction},...t}:{type:"newTab",...t}},Me=e=>{if(e.t!=="action")return e;let t=Ce(e.action);return t===e.action?e:{...e,action:t}},ct=e=>({...e,onMessage:t=>{e.onMessage(n=>t(Me(n)))}});var re={};j(re,{buildKeymap:()=>te,defaultKeymap:()=>De,lookup:()=>ne,mergeOverrides:()=>lt,parseChord:()=>ee});var ee=e=>{let t=[];e.ctrl&&t.push("ctrl"),e.meta&&t.push("alt");let n=e.name.length===1;return e.shift&&!n&&t.push("shift"),t.push(n?e.name.toLowerCase():e.name),t.join("+")};var dt=e=>Array.isArray(e)?e:[e],te=e=>{let t=new Map;for(let n of Object.keys(e)){let r=e[n];if(r===void 0)continue;let o=new Map;for(let i of Object.keys(r))o.set(i,dt(r[i]));t.set(n,o)}return t},ne=(e,t,n)=>e.get(t)?.get(n),lt=(e,t)=>{let n=new Map;for(let[r,o]of e)n.set(r,new Map(o));for(let r of Object.keys(t)){let o=t[r];if(o===void 0)continue;let i=n.get(r)??new Map;for(let s of Object.keys(o))i.set(s,dt(o[s]));n.set(r,i)}return n};var A={type:"switchMode",mode:"normal"},Rt={normal:{"ctrl+p":{type:"switchMode",mode:"pane"},"ctrl+t":{type:"switchMode",mode:"tab"},"ctrl+n":{type:"switchMode",mode:"resize"},"ctrl+s":{type:"switchMode",mode:"scroll"},"ctrl+g":{type:"switchMode",mode:"locked"},"ctrl+o":{type:"detach"},"ctrl+q":{type:"quit"}},pane:{n:[{type:"newPane"},A],v:[{type:"splitPane",direction:"vertical"},A],s:[{type:"splitPane",direction:"horizontal"},A],x:[{type:"closeFocusedPane"},A],f:[{type:"toggleFullscreen"},A],z:[{type:"toggleFullscreen"},A],left:{type:"focusDirection",direction:"left"},right:{type:"focusDirection",direction:"right"},up:{type:"focusDirection",direction:"up"},down:{type:"focusDirection",direction:"down"},h:{type:"focusDirection",direction:"left"},l:{type:"focusDirection",direction:"right"},k:{type:"focusDirection",direction:"up"},j:{type:"focusDirection",direction:"down"},enter:A,escape:A},tab:{n:[{type:"newTab"},A],x:[{type:"closeTab"},A],left:{type:"prevTab"},h:{type:"prevTab"},right:{type:"nextTab"},l:{type:"nextTab"},1:{type:"gotoTab",index:0},2:{type:"gotoTab",index:1},3:{type:"gotoTab",index:2},4:{type:"gotoTab",index:3},5:{type:"gotoTab",index:4},6:{type:"gotoTab",index:5},7:{type:"gotoTab",index:6},8:{type:"gotoTab",index:7},9:{type:"gotoTab",index:8},enter:A,escape:A},resize:{left:{type:"resizePane",direction:"left"},right:{type:"resizePane",direction:"right"},up:{type:"resizePane",direction:"up"},down:{type:"resizePane",direction:"down"},h:{type:"resizePane",direction:"left"},l:{type:"resizePane",direction:"right"},k:{type:"resizePane",direction:"up"},j:{type:"resizePane",direction:"down"},enter:A,escape:A},scroll:{up:{type:"scroll",action:"up"},down:{type:"scroll",action:"down"},k:{type:"scroll",action:"up"},j:{type:"scroll",action:"down"},pageup:{type:"scroll",action:"pageUp"},pagedown:{type:"scroll",action:"pageDown"},g:{type:"scroll",action:"home"},"shift+g":{type:"scroll",action:"end"},enter:A,escape:A},locked:{"ctrl+g":A}},De=te(Rt);var Oe=(e,t=L)=>{let n=e.tabs[e.activeTab];if(n===void 0)return{tabs:[],activeTab:0,mode:e.mode,viewport:e.viewport,focusedPane:null,panes:[],chrome:t};let r=B(n,e.viewport,t),o=z(n.root),i=[];for(let s of o){let c=r.get(s);if(c===void 0)continue;let u=e.panes[s];i.push({id:s,kind:u?.kind??"terminal",title:u?.title??s,geom:c,focused:s===n.focusedPane,exited:u?.exited??!1})}return{tabs:e.tabs.map(s=>({id:s.id,name:s.name})),activeTab:e.activeTab,mode:e.mode,viewport:e.viewport,focusedPane:n.focusedPane,panes:i,chrome:t}};var At=(e,t)=>e.tabBarRows===t.tabBarRows&&e.statusBarRows===t.statusBarRows&&(e.leftCols??0)===(t.leftCols??0)&&(e.rightCols??0)===(t.rightCols??0)&&(e.topRows??0)===(t.topRows??0)&&(e.bottomRows??0)===(t.bottomRows??0),It=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].id!==t[n].id||e[n].name!==t[n].name)return!1;return!0},Ct=(e,t)=>e.id===t.id&&e.kind===t.kind&&e.title===t.title&&e.focused===t.focused&&e.exited===t.exited&&e.geom.x===t.geom.x&&e.geom.y===t.geom.y&&e.geom.width===t.geom.width&&e.geom.height===t.geom.height,Mt=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ct(e[n],t[n]))return!1;return!0},Dt=(e,t)=>e.cols===t.cols&&e.rows===t.rows,ke=(e,t)=>{if(e===null)return{mode:t.mode,activeTab:t.activeTab,focusedPane:t.focusedPane,viewport:t.viewport,tabs:t.tabs,panes:t.panes,chrome:t.chrome};let n={},r=!1;return e.mode!==t.mode&&(n.mode=t.mode,r=!0),e.activeTab!==t.activeTab&&(n.activeTab=t.activeTab,r=!0),e.focusedPane!==t.focusedPane&&(n.focusedPane=t.focusedPane,r=!0),Dt(e.viewport,t.viewport)||(n.viewport=t.viewport,r=!0),It(e.tabs,t.tabs)||(n.tabs=t.tabs,r=!0),Mt(e.panes,t.panes)||(n.panes=t.panes,r=!0),At(e.chrome,t.chrome)||(n.chrome=t.chrome,r=!0),r?n:null};var oe=()=>{let e=null,t=null,n=!1,r=!1;return[{send(s){r||t?.(s)},onMessage(s){e=s},close(){n=!0}},{send(s){n||e?.(s)},onMessage(s){t=s},close(){r=!0}}]};var Le=(e,t=16)=>{let n=!1,r=!1,o=null,i=()=>{n=!1,o=null;let c=r;r=!1,e(c)},s=()=>{n||(n=!0,o=setTimeout(i,t))};return{schedule:s,requestFull(){r=!0,s()},stop(){o!==null&&(clearTimeout(o),o=null),n=!1}}};var kt={normal:"ctrl+p pane \xB7 ctrl+t tab \xB7 ctrl+n resize \xB7 ctrl+s scroll \xB7 ctrl+q quit",pane:"PANE: n new \xB7 v|s split \xB7 x close \xB7 f full \xB7 hjkl focus \xB7 esc",tab:"TAB: n new \xB7 x close \xB7 h/l switch \xB7 1-9 goto \xB7 esc",resize:"RESIZE: hjkl/arrows \xB7 esc",scroll:"SCROLL: j/k \xB7 g/G \xB7 esc",locked:"LOCKED: ctrl+g to unlock"},Lt=(e,t)=>{let n=e.viewport.cols,r=t??` ${e.mode.toUpperCase()} ${kt[e.mode]}`,o=f.visibleLength(r),i=f.truncate(r,n)+" ".repeat(Math.max(0,n-o));return f.moveTo(e.viewport.rows,1)+f.inverse(i)},pt=(e,t,n)=>{let r=[];n.fullRedraw&&r.push(C.clearScreenSeq());let o=Ge.renderTabBar({tabs:e.tabs.map(s=>({id:s.id,label:s.name})),activeIndex:e.activeTab,maxWidth:e.viewport.cols});r.push(f.moveTo(1,1)+o);let i={row:e.viewport.rows,col:1,visible:!1};for(let s of e.panes){if(s.geom.width<2||s.geom.height<2)continue;let c={id:s.id,x:s.geom.x+1,y:s.geom.y+1,width:s.geom.width,height:s.geom.height};r.push($.drawBox({...c,title:s.title,borderStyle:s.focused?"double":"single",skipInterior:!0}));let u=t.getWidget(s.id);u!==void 0&&(r.push(u.render(c,n.fullRedraw)),s.focused&&(i={row:c.y+1+u.terminal.cursorRow,col:c.x+1+u.terminal.cursorCol,visible:!0}))}return r.push(Lt(e,n.statusText)),{data:r.join(""),cursor:i}};var Ft=new TextDecoder,ut=(e,t,n)=>{let r=ne(n,t,ee(e));return r!==void 0?r.map(o=>({t:"action",action:o})):t==="normal"||t==="locked"?[{t:"action",action:{type:"writeInput",data:Ft.decode(e.raw)}}]:[]},mt=(e,t)=>{if(t===null||e.type!=="mousedown")return[];for(let n of t.panes){let r=n.geom.x+1,o=n.geom.y+1;if(e.x>=r&&e.x<r+n.geom.width&&e.y>=o&&e.y<o+n.geom.height)return[{t:"action",action:{type:"focusPane",pane:n.id}}]}return[]};var Nt=new TextEncoder,se=e=>{let{transport:t,keymap:n}=e,r=new Map,o=null,i=!1,s=!1,c=null,u=null,w={cols:80,rows:24},l=h=>U.process.writeToStdout(Nt.encode(h)),b=h=>{let y=r.get(h);if(y!==void 0)return y;let a=o?.panes.find(x=>x.id===h),g=a?Math.max(1,a.geom.width-2):80,P=a?Math.max(1,a.geom.height-2):24,p=new fe(P,g);return r.set(h,p),p},T=()=>{if(o===null)return;let h=new Set;for(let y of o.panes){h.add(y.id);let a=Math.max(1,y.geom.width-2),g=Math.max(1,y.geom.height-2),P=r.get(y.id);P===void 0?r.set(y.id,new fe(g,a)):(P.terminal.rows!==g||P.terminal.cols!==a)&&P.resize(g,a)}for(let y of[...r.keys()])h.has(y)||r.delete(y)},m=Le(h=>{if(s||o===null)return;let y=pt(o,{getWidget:g=>r.get(g)},{fullRedraw:h,statusText:e.statusText}),a=C.hideCursorSeq()+y.data;e.decorate!==void 0&&(a+=e.decorate({regions:Ee(o.viewport,o.chrome),scene:o})),a+=f.moveTo(y.cursor.row,y.cursor.col)+(y.cursor.visible?C.showCursorSeq():""),l(a)}),d=h=>{switch(h.t){case"scene":{let y=o,a=h.delta;o={tabs:a.tabs??y?.tabs??[],activeTab:a.activeTab??y?.activeTab??0,mode:a.mode??y?.mode??"normal",viewport:a.viewport??y?.viewport??w,focusedPane:a.focusedPane!==void 0?a.focusedPane:y?.focusedPane??null,panes:a.panes??y?.panes??[],chrome:a.chrome??y?.chrome??L};let g=h.full||a.panes!==void 0||a.tabs!==void 0||a.viewport!==void 0||a.chrome!==void 0;g&&T(),g?m.requestFull():m.schedule();break}case"output":b(h.pane).write(h.data),m.schedule();break;case"exit":S();break}},E=()=>{u=setInterval(()=>{let h=C.getTerminalSize();(h.cols!==w.cols||h.rows!==w.rows)&&(w={cols:h.cols,rows:h.rows},t.send({t:"resize",viewport:w}))},e.sizePollMs??250)},S=()=>{i&&(i=!1,s=!0,c?.abort(),u!==null&&clearInterval(u),m.stop(),l(me.disableMouse()+C.showCursorSeq()+C.exitAlternateScreen()),t.close())};return{handle:d,run:async()=>{i=!0,t.onMessage(d),l(C.enterAlternateScreen()+C.hideCursorSeq()+C.clearScreenSeq()+me.enableMouse());let h=C.getTerminalSize();w={cols:h.cols,rows:h.rows},t.send({t:"attach",viewport:w}),E(),c=new AbortController,await Ue(async()=>{for await(let y of $e(U.process.stdin,c.signal)){if(!i)break;try{if(y.kind==="mouse"){if(e.onMouse?.(y.event,o)===!0)continue;for(let a of mt(y.event,o))t.send(a)}else{if(e.onKey?.(y.event,o)===!0)continue;for(let a of ut(y.event,o?.mode??"normal",n))t.send(a)}}catch{}}})},stop:S,refresh:()=>{s||m.schedule()}}};var Fe=e=>{let t=new Map,n=new Map;return{async spawn(r){if(t.has(r.pane))return;let o=await tt({command:r.command,args:[...r.args],cwd:r.cwd,env:r.env,cols:r.cols,rows:r.rows});t.set(r.pane,o),n.set(r.pane,`${r.cols}x${r.rows}`),o.onData(i=>e.onData(r.pane,i)),o.exitCode.then(i=>e.onExit(r.pane,i)).catch(()=>e.onExit(r.pane,-1))},write(r,o){t.get(r)?.write(o)},resize(r,o,i){let s=`${o}x${i}`;n.get(r)!==s&&(n.set(r,s),t.get(r)?.resize(o,i))},kill(r){let o=t.get(r);o!==void 0&&(o.kill(),t.delete(r),n.delete(r))},forget(r){t.delete(r),n.delete(r)},async killAll(){let r=[...t.values()];t.clear(),n.clear();for(let c of r)c.kill("SIGTERM");let o=r.map(c=>c.exitCode.catch(()=>-1)),i,s=await Promise.race([Promise.allSettled(o).then(()=>!1),new Promise(c=>{i=setTimeout(()=>c(!0),2e3)})]);if(i!==void 0&&clearTimeout(i),s)for(let c of r)c.kill("SIGKILL")},has(r){return t.has(r)}}};var zt={up:"\x1B[A\x1B[A\x1B[A",down:"\x1B[B\x1B[B\x1B[B",pageUp:"\x1B[5~",pageDown:"\x1B[6~",home:"\x1B[H",end:"\x1B[F"},ie=e=>{let t=e.chrome??L,n=e.initialState,r=e.exitOnEmpty??!0,o=()=>Te(n.viewport,t),i=null,s=null,c=!1,u=new Set,w=new Set,l=(e.createHost??Fe)({onData:(a,g)=>i?.send({t:"output",pane:a,data:g}),onExit:(a,g)=>{l.forget(a),S({type:"paneExited",pane:a,code:g}),e.onPaneExit?.(a)}}),b=()=>{let a=n.tabs[n.activeTab];return a===void 0?new Map:B(a,n.viewport,o())},T=a=>({cols:a?Math.max(1,a.width-2):Math.max(1,n.viewport.cols-2),rows:a?Math.max(1,a.height-2):Math.max(1,n.viewport.rows-2)}),v=async a=>{let g=n.panes[a];if(!(g===void 0||l.has(a)||u.has(a))){u.add(a);try{let P=b().get(a),{cols:p,rows:x}=T(P),I=e.resolveSpawn(g,P??{x:0,y:0,width:p,height:x});await l.spawn({pane:a,command:I.command,args:I.args,cwd:I.cwd,env:I.env,cols:p,rows:x})}finally{u.delete(a),w.delete(a)&&l.has(a)&&l.kill(a)}}},m=()=>{for(let[a,g]of b()){if(!l.has(a))continue;let{cols:P,rows:p}=T(g);l.resize(a,P,p)}},d=()=>{let a=Oe(n,o()),g=s===null,P=ke(s,a);s=a,P!==null&&i?.send({t:"scene",full:g,delta:P})},E=a=>{switch(a.type){case"spawnPty":v(a.pane).catch(g=>{let P=g instanceof Error?g.message:String(g);i?.send({t:"output",pane:a.pane,data:`\r
1
+ import"./chunk-DEHRWREM.js";import{b as ve,c as xe}from"./chunk-NPWXEWRN.js";import"./chunk-Q4TI7EYT.js";import{c as me,d as Ue,e as $e,p as C,q as f,r as $,s as fe,t as He,u as W,v as Ge}from"./chunk-AUZWXMWA.js";import"./chunk-VXU6XZ66.js";import{a as nt}from"./chunk-EROZRDGT.js";import"./chunk-FYFUEK4U.js";import{h as be}from"./chunk-5RLCKUIF.js";import"./chunk-EVJYA7S3.js";import"./chunk-XDRX4ZBJ.js";import{b as Se}from"./chunk-IFE5SYGK.js";import"./chunk-5FX4EBFY.js";import"./chunk-VJRCTYGL.js";import"./chunk-O4KKKYCH.js";import"./chunk-ONJVI5AZ.js";import{A as Ye,C as we,D as Je,E as Ze,f as We,g as qe,h as ye,l as je,n as Xe,o as Qe,v as ge,y as he}from"./chunk-WDKWHGJU.js";import{f as et,g as tt}from"./chunk-HB62UGZI.js";import"./chunk-ENP4P2YH.js";import"./chunk-3JTDWOAJ.js";import"./chunk-34RPTI4K.js";import{a as pe,b as _e}from"./chunk-OAWYVETM.js";import{i as U}from"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import{m as ue}from"./chunk-FE4MKOI4.js";import{d as j}from"./chunk-HISXAZ4Y.js";var Z={};j(Z,{createInitialState:()=>Ie,geometry:()=>Ae,reduce:()=>J,sanitizeRemoteAction:()=>Ce,sanitizeRemoteMessage:()=>Me,sanitizeRemoteTransport:()=>ct,tree:()=>Y});var Y={};j(Y,{collectLeaves:()=>z,firstLeaf:()=>K,hasLeaf:()=>D,leaf:()=>X,removeLeaf:()=>H,resizeFocused:()=>Q,splitLeaf:()=>q});var rt=e=>e<.1?.1:e>.9?.9:e,X=e=>({kind:"leaf",pane:e}),z=e=>e.kind==="leaf"?[e.pane]:[...z(e.first),...z(e.second)],D=(e,t)=>e.kind==="leaf"?e.pane===t:D(e.first,t)||D(e.second,t),K=e=>{let t=e;for(;t.kind==="branch";)t=t.first;return t.pane},q=(e,t,n,r,o=.5)=>e.kind==="leaf"?e.pane!==t?e:{kind:"branch",direction:n,first:e,second:X(r),ratio:rt(o)}:D(e.first,t)?{...e,first:q(e.first,t,n,r,o)}:D(e.second,t)?{...e,second:q(e.second,t,n,r,o)}:e,H=(e,t)=>{if(e.kind==="leaf")return e.pane===t?{root:null,promoted:null}:{root:e,promoted:null};if(e.first.kind==="leaf"&&e.first.pane===t)return{root:e.second,promoted:K(e.second)};if(e.second.kind==="leaf"&&e.second.pane===t)return{root:e.first,promoted:K(e.first)};if(D(e.first,t)){let n=H(e.first,t);return n.root===null?{root:e.second,promoted:K(e.second)}:{root:{...e,first:n.root},promoted:n.promoted}}if(D(e.second,t)){let n=H(e.second,t);return n.root===null?{root:e.first,promoted:K(e.first)}:{root:{...e,second:n.root},promoted:n.promoted}}return{root:e,promoted:null}},Q=(e,t,n,r)=>{if(e.kind==="leaf")return e;let o=D(e.first,t)?"first":D(e.second,t)?"second":null;if(o===null)return e;let i=e[o],s=Q(i,t,n,r);if(s!==i)return{...e,[o]:s};let c=n==="left"||n==="right"?"vertical":"horizontal";if(e.direction!==c)return e;let u=n==="right"||n==="down"?1:-1;return{...e,ratio:rt(e.ratio+u*r)}};var Ae={};j(Ae,{DEFAULT_CHROME:()=>L,computeTabGeoms:()=>B,decorationRegions:()=>Ee,effectiveChrome:()=>Te,neighborInDirection:()=>Re});var L={tabBarRows:1,statusBarRows:1},xt=10,Pt=3,Te=(e,t)=>{let n=t.leftCols??0,r=t.rightCols??0,o=t.topRows??0,i=t.bottomRows??0;e.cols-n-r<xt&&(n=0,r=0);let s=t.tabBarRows+t.statusBarRows+o+i;return e.rows-s<Pt&&(o=0,i=0),{...t,leftCols:n,rightCols:r,topRows:o,bottomRows:i}},Ee=(e,t)=>{let n=t.leftCols??0,r=t.rightCols??0,o=t.topRows??0,i=t.bottomRows??0,s=t.tabBarRows+1,c=Math.max(0,e.rows-t.tabBarRows-t.statusBarRows),u=n+1,w=Math.max(0,e.cols-n-r),l={};return n>0&&(l.left={x:1,y:s,width:n,height:c}),r>0&&(l.right={x:e.cols-r+1,y:s,width:r,height:c}),o>0&&(l.top={x:u,y:s,width:w,height:o}),i>0&&(l.bottom={x:u,y:e.rows-t.statusBarRows-i+1,width:w,height:i}),l},ot=100,Pe=e=>{if(e.kind==="leaf")return{id:e.pane,size:{type:"flex",grow:1}};let t=e.direction==="vertical"?"row":"column",n=Math.max(1,Math.round(e.ratio*ot)),r=Math.max(1,Math.round((1-e.ratio)*ot));return{direction:t,size:{type:"flex",grow:1},children:[{...Pe(e.first),size:{type:"flex",grow:n}},{...Pe(e.second),size:{type:"flex",grow:r}}]}},B=(e,t,n)=>{let r=n.leftCols??0,o=n.rightCols??0,i=n.topRows??0,s=n.bottomRows??0,c=r,u=n.tabBarRows+i,w=Math.max(0,t.cols-r-o),l=Math.max(0,t.rows-n.tabBarRows-n.statusBarRows-i-s),b=new Map;if(e.fullscreenPane!==void 0)return b.set(e.fullscreenPane,{x:c,y:u,width:w,height:l}),b;let T=He.computeLayout(Pe(e.root),w,l);for(let v of T)v.id!==void 0&&b.set(v.id,{x:v.x+c,y:v.y+u,width:v.width,height:v.height});return b},Re=(e,t,n)=>{let r=e.get(t);if(r===void 0)return null;let o=n==="left"||n==="right",i=r.x+r.width/2,s=r.y+r.height/2,c=null,u=1/0;for(let[w,l]of e){if(w===t||!(o?l.y<r.y+r.height&&l.y+l.height>r.y:l.x<r.x+r.width&&l.x+l.width>r.x))continue;let T=o?l.x+l.width/2:l.y+l.height/2,v=o?i:s;if(!(n==="left"||n==="up"?T<v:T>v))continue;let d=Math.abs(T-v);d<u&&(u=d,c=w)}return c};var Tt=.05,O=[{type:"render"}],Ie=e=>({panes:{},tabs:[],activeTab:0,mode:"normal",viewport:e,running:!0,nextPaneSeq:1,nextTabSeq:1}),R=e=>({state:e,effects:[]}),F=e=>e.tabs[e.activeTab],V=(e,t)=>({...e,tabs:e.tabs.map((n,r)=>r===e.activeTab?t:n)}),it=(e,t)=>{let n=`pane-${e.nextPaneSeq}`,r={id:n,kind:t.kind??"terminal",title:t.title??t.command??"shell",cwd:t.cwd,command:t.command,args:t.args,meta:t.meta};return{pane:r,state:{...e,panes:{...e.panes,[n]:r},nextPaneSeq:e.nextPaneSeq+1}}},at=(e,t)=>{let n=e.tabs[t];if(n===void 0)return R(e);let r=z(n.root),o=r.map(u=>({type:"killPty",pane:u})),i={...e.panes};for(let u of r)delete i[u];let s=e.tabs.filter((u,w)=>w!==t);if(s.length===0)return{state:{...e,panes:i,tabs:s,running:!1},effects:[...o,{type:"exit"}]};let c=t<e.activeTab?e.activeTab-1:Math.min(e.activeTab,s.length-1);return{state:{...e,panes:i,tabs:s,activeTab:c},effects:[...o,{type:"render"}]}},Et=e=>at(e,e.activeTab),st=(e,t,n)=>{let r=F(e);if(r===void 0)return R(e);let{pane:o,state:i}=it(e,n),s=q(r.root,r.focusedPane,t,o.id),c={...r,root:s,focusedPane:o.id,fullscreenPane:void 0};return{state:V(i,c),effects:[{type:"spawnPty",pane:o.id},{type:"render"}]}},J=(e,t)=>{switch(t.type){case"switchMode":return{state:{...e,mode:t.mode},effects:O};case"splitPane":return st(e,t.direction,{});case"newPane":return st(e,t.direction??"vertical",{kind:t.kind,command:t.command,args:t.args,cwd:t.cwd,title:t.title,meta:t.meta});case"closeFocusedPane":{let n=F(e);if(n===void 0)return R(e);let r=n.focusedPane,{root:o,promoted:i}=H(n.root,r);if(o===null)return Et(e);let s={...e.panes};delete s[r];let c={...n,root:o,focusedPane:i??K(o),fullscreenPane:void 0};return{state:V({...e,panes:s},c),effects:[{type:"killPty",pane:r},{type:"render"}]}}case"focusDirection":{let n=F(e);if(n===void 0)return R(e);let r=B(n,e.viewport,L),o=Re(r,n.focusedPane,t.direction);return o===null?R(e):{state:V(e,{...n,focusedPane:o}),effects:O}}case"focusNext":case"focusPrev":{let n=F(e);if(n===void 0)return R(e);let r=z(n.root);if(r.length<=1)return R(e);let o=r.indexOf(n.focusedPane),i=t.type==="focusNext"?1:-1,s=r[(o+i+r.length)%r.length];return{state:V(e,{...n,focusedPane:s}),effects:O}}case"focusPane":{let n=F(e);return n===void 0||!D(n.root,t.pane)?R(e):{state:V(e,{...n,focusedPane:t.pane}),effects:O}}case"toggleFullscreen":{let n=F(e);if(n===void 0)return R(e);let r=n.fullscreenPane===n.focusedPane?void 0:n.focusedPane;return{state:V(e,{...n,fullscreenPane:r}),effects:O}}case"resizePane":{let n=F(e);if(n===void 0)return R(e);let r=Q(n.root,n.focusedPane,t.direction,Tt);return r===n.root?R(e):{state:V(e,{...n,root:r}),effects:O}}case"newTab":{let n=`tab-${e.nextTabSeq}`,{pane:r,state:o}=it(e,{kind:t.kind,command:t.command,args:t.args,cwd:t.cwd,title:t.title,meta:t.meta}),i={id:n,name:t.title??`tab ${e.nextTabSeq}`,root:X(r.id),focusedPane:r.id},s=[...o.tabs,i];return{state:{...o,tabs:s,activeTab:s.length-1,nextTabSeq:o.nextTabSeq+1},effects:[{type:"spawnPty",pane:r.id},{type:"render"}]}}case"closeTab":return at(e,t.index??e.activeTab);case"gotoTab":return t.index<0||t.index>=e.tabs.length?R(e):{state:{...e,activeTab:t.index},effects:O};case"nextTab":case"prevTab":{if(e.tabs.length<=1)return R(e);let n=t.type==="nextTab"?1:-1,r=(e.activeTab+n+e.tabs.length)%e.tabs.length;return{state:{...e,activeTab:r},effects:O}}case"scroll":{let n=F(e);return n===void 0?R(e):{state:e,effects:[{type:"scrollPane",pane:n.focusedPane,action:t.action}]}}case"writeInput":{let n=F(e);return n===void 0?R(e):{state:e,effects:[{type:"writePty",pane:n.focusedPane,data:t.data}]}}case"writeToPane":return e.panes[t.pane]===void 0?R(e):{state:e,effects:[{type:"writePty",pane:t.pane,data:t.data}]};case"resizeViewport":return{state:{...e,viewport:{cols:t.cols,rows:t.rows}},effects:O};case"paneExited":{let n=e.tabs.findIndex(l=>D(l.root,t.pane));if(n<0)return R(e);let r=e.tabs[n],{root:o,promoted:i}=H(r.root,t.pane),s={...e.panes};if(delete s[t.pane],o===null){let l=e.tabs.filter((T,v)=>v!==n);if(l.length===0)return{state:{...e,panes:s,tabs:l,running:!1},effects:[{type:"exit"}]};let b=n<e.activeTab?e.activeTab-1:Math.min(e.activeTab,l.length-1);return{state:{...e,panes:s,tabs:l,activeTab:b},effects:O}}let c=r.focusedPane===t.pane?i??K(o):r.focusedPane,u=r.fullscreenPane===t.pane?void 0:r.fullscreenPane,w={...r,root:o,focusedPane:c,fullscreenPane:u};return{state:{...e,panes:s,tabs:e.tabs.map((l,b)=>b===n?w:l)},effects:O}}case"detach":return{state:e,effects:[{type:"detach"}]};case"quit":return{state:{...e,running:!1},effects:[{type:"exit"}]}}};var Ce=e=>{if(e.type!=="newTab"&&e.type!=="newPane"||e.command===void 0&&e.args===void 0&&e.cwd===void 0)return e;let t={...e.kind===void 0?{}:{kind:e.kind},...e.title===void 0?{}:{title:e.title},...e.meta===void 0?{}:{meta:e.meta}};return e.type==="newPane"?{type:"newPane",...e.direction===void 0?{}:{direction:e.direction},...t}:{type:"newTab",...t}},Me=e=>{if(e.t!=="action")return e;let t=Ce(e.action);return t===e.action?e:{...e,action:t}},ct=e=>({...e,onMessage:t=>{e.onMessage(n=>t(Me(n)))}});var re={};j(re,{buildKeymap:()=>te,defaultKeymap:()=>De,lookup:()=>ne,mergeOverrides:()=>lt,parseChord:()=>ee});var ee=e=>{let t=[];e.ctrl&&t.push("ctrl"),e.meta&&t.push("alt");let n=e.name.length===1;return e.shift&&!n&&t.push("shift"),t.push(n?e.name.toLowerCase():e.name),t.join("+")};var dt=e=>Array.isArray(e)?e:[e],te=e=>{let t=new Map;for(let n of Object.keys(e)){let r=e[n];if(r===void 0)continue;let o=new Map;for(let i of Object.keys(r))o.set(i,dt(r[i]));t.set(n,o)}return t},ne=(e,t,n)=>e.get(t)?.get(n),lt=(e,t)=>{let n=new Map;for(let[r,o]of e)n.set(r,new Map(o));for(let r of Object.keys(t)){let o=t[r];if(o===void 0)continue;let i=n.get(r)??new Map;for(let s of Object.keys(o))i.set(s,dt(o[s]));n.set(r,i)}return n};var A={type:"switchMode",mode:"normal"},Rt={normal:{"ctrl+p":{type:"switchMode",mode:"pane"},"ctrl+t":{type:"switchMode",mode:"tab"},"ctrl+n":{type:"switchMode",mode:"resize"},"ctrl+s":{type:"switchMode",mode:"scroll"},"ctrl+g":{type:"switchMode",mode:"locked"},"ctrl+o":{type:"detach"},"ctrl+q":{type:"quit"}},pane:{n:[{type:"newPane"},A],v:[{type:"splitPane",direction:"vertical"},A],s:[{type:"splitPane",direction:"horizontal"},A],x:[{type:"closeFocusedPane"},A],f:[{type:"toggleFullscreen"},A],z:[{type:"toggleFullscreen"},A],left:{type:"focusDirection",direction:"left"},right:{type:"focusDirection",direction:"right"},up:{type:"focusDirection",direction:"up"},down:{type:"focusDirection",direction:"down"},h:{type:"focusDirection",direction:"left"},l:{type:"focusDirection",direction:"right"},k:{type:"focusDirection",direction:"up"},j:{type:"focusDirection",direction:"down"},enter:A,escape:A},tab:{n:[{type:"newTab"},A],x:[{type:"closeTab"},A],left:{type:"prevTab"},h:{type:"prevTab"},right:{type:"nextTab"},l:{type:"nextTab"},1:{type:"gotoTab",index:0},2:{type:"gotoTab",index:1},3:{type:"gotoTab",index:2},4:{type:"gotoTab",index:3},5:{type:"gotoTab",index:4},6:{type:"gotoTab",index:5},7:{type:"gotoTab",index:6},8:{type:"gotoTab",index:7},9:{type:"gotoTab",index:8},enter:A,escape:A},resize:{left:{type:"resizePane",direction:"left"},right:{type:"resizePane",direction:"right"},up:{type:"resizePane",direction:"up"},down:{type:"resizePane",direction:"down"},h:{type:"resizePane",direction:"left"},l:{type:"resizePane",direction:"right"},k:{type:"resizePane",direction:"up"},j:{type:"resizePane",direction:"down"},enter:A,escape:A},scroll:{up:{type:"scroll",action:"up"},down:{type:"scroll",action:"down"},k:{type:"scroll",action:"up"},j:{type:"scroll",action:"down"},pageup:{type:"scroll",action:"pageUp"},pagedown:{type:"scroll",action:"pageDown"},g:{type:"scroll",action:"home"},"shift+g":{type:"scroll",action:"end"},enter:A,escape:A},locked:{"ctrl+g":A}},De=te(Rt);var Oe=(e,t=L)=>{let n=e.tabs[e.activeTab];if(n===void 0)return{tabs:[],activeTab:0,mode:e.mode,viewport:e.viewport,focusedPane:null,panes:[],chrome:t};let r=B(n,e.viewport,t),o=z(n.root),i=[];for(let s of o){let c=r.get(s);if(c===void 0)continue;let u=e.panes[s];i.push({id:s,kind:u?.kind??"terminal",title:u?.title??s,geom:c,focused:s===n.focusedPane,exited:u?.exited??!1})}return{tabs:e.tabs.map(s=>({id:s.id,name:s.name})),activeTab:e.activeTab,mode:e.mode,viewport:e.viewport,focusedPane:n.focusedPane,panes:i,chrome:t}};var At=(e,t)=>e.tabBarRows===t.tabBarRows&&e.statusBarRows===t.statusBarRows&&(e.leftCols??0)===(t.leftCols??0)&&(e.rightCols??0)===(t.rightCols??0)&&(e.topRows??0)===(t.topRows??0)&&(e.bottomRows??0)===(t.bottomRows??0),It=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].id!==t[n].id||e[n].name!==t[n].name)return!1;return!0},Ct=(e,t)=>e.id===t.id&&e.kind===t.kind&&e.title===t.title&&e.focused===t.focused&&e.exited===t.exited&&e.geom.x===t.geom.x&&e.geom.y===t.geom.y&&e.geom.width===t.geom.width&&e.geom.height===t.geom.height,Mt=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ct(e[n],t[n]))return!1;return!0},Dt=(e,t)=>e.cols===t.cols&&e.rows===t.rows,ke=(e,t)=>{if(e===null)return{mode:t.mode,activeTab:t.activeTab,focusedPane:t.focusedPane,viewport:t.viewport,tabs:t.tabs,panes:t.panes,chrome:t.chrome};let n={},r=!1;return e.mode!==t.mode&&(n.mode=t.mode,r=!0),e.activeTab!==t.activeTab&&(n.activeTab=t.activeTab,r=!0),e.focusedPane!==t.focusedPane&&(n.focusedPane=t.focusedPane,r=!0),Dt(e.viewport,t.viewport)||(n.viewport=t.viewport,r=!0),It(e.tabs,t.tabs)||(n.tabs=t.tabs,r=!0),Mt(e.panes,t.panes)||(n.panes=t.panes,r=!0),At(e.chrome,t.chrome)||(n.chrome=t.chrome,r=!0),r?n:null};var oe=()=>{let e=null,t=null,n=!1,r=!1;return[{send(s){r||t?.(s)},onMessage(s){e=s},close(){n=!0}},{send(s){n||e?.(s)},onMessage(s){t=s},close(){r=!0}}]};var Le=(e,t=16)=>{let n=!1,r=!1,o=null,i=()=>{n=!1,o=null;let c=r;r=!1,e(c)},s=()=>{n||(n=!0,o=setTimeout(i,t))};return{schedule:s,requestFull(){r=!0,s()},stop(){o!==null&&(clearTimeout(o),o=null),n=!1}}};var kt={normal:"ctrl+p pane \xB7 ctrl+t tab \xB7 ctrl+n resize \xB7 ctrl+s scroll \xB7 ctrl+q quit",pane:"PANE: n new \xB7 v|s split \xB7 x close \xB7 f full \xB7 hjkl focus \xB7 esc",tab:"TAB: n new \xB7 x close \xB7 h/l switch \xB7 1-9 goto \xB7 esc",resize:"RESIZE: hjkl/arrows \xB7 esc",scroll:"SCROLL: j/k \xB7 g/G \xB7 esc",locked:"LOCKED: ctrl+g to unlock"},Lt=(e,t)=>{let n=e.viewport.cols,r=t??` ${e.mode.toUpperCase()} ${kt[e.mode]}`,o=f.visibleLength(r),i=f.truncate(r,n)+" ".repeat(Math.max(0,n-o));return f.moveTo(e.viewport.rows,1)+f.inverse(i)},pt=(e,t,n)=>{let r=[];n.fullRedraw&&r.push(C.clearScreenSeq());let o=Ge.renderTabBar({tabs:e.tabs.map(s=>({id:s.id,label:s.name})),activeIndex:e.activeTab,maxWidth:e.viewport.cols});r.push(f.moveTo(1,1)+o);let i={row:e.viewport.rows,col:1,visible:!1};for(let s of e.panes){if(s.geom.width<2||s.geom.height<2)continue;let c={id:s.id,x:s.geom.x+1,y:s.geom.y+1,width:s.geom.width,height:s.geom.height};r.push($.drawBox({...c,title:s.title,borderStyle:s.focused?"double":"single",skipInterior:!0}));let u=t.getWidget(s.id);u!==void 0&&(r.push(u.render(c,n.fullRedraw)),s.focused&&(i={row:c.y+1+u.terminal.cursorRow,col:c.x+1+u.terminal.cursorCol,visible:!0}))}return r.push(Lt(e,n.statusText)),{data:r.join(""),cursor:i}};var Ft=new TextDecoder,ut=(e,t,n)=>{let r=ne(n,t,ee(e));return r!==void 0?r.map(o=>({t:"action",action:o})):t==="normal"||t==="locked"?[{t:"action",action:{type:"writeInput",data:Ft.decode(e.raw)}}]:[]},mt=(e,t)=>{if(t===null||e.type!=="mousedown")return[];for(let n of t.panes){let r=n.geom.x+1,o=n.geom.y+1;if(e.x>=r&&e.x<r+n.geom.width&&e.y>=o&&e.y<o+n.geom.height)return[{t:"action",action:{type:"focusPane",pane:n.id}}]}return[]};var Nt=new TextEncoder,se=e=>{let{transport:t,keymap:n}=e,r=new Map,o=null,i=!1,s=!1,c=null,u=null,w={cols:80,rows:24},l=h=>U.process.writeToStdout(Nt.encode(h)),b=h=>{let y=r.get(h);if(y!==void 0)return y;let a=o?.panes.find(x=>x.id===h),g=a?Math.max(1,a.geom.width-2):80,P=a?Math.max(1,a.geom.height-2):24,p=new fe(P,g);return r.set(h,p),p},T=()=>{if(o===null)return;let h=new Set;for(let y of o.panes){h.add(y.id);let a=Math.max(1,y.geom.width-2),g=Math.max(1,y.geom.height-2),P=r.get(y.id);P===void 0?r.set(y.id,new fe(g,a)):(P.terminal.rows!==g||P.terminal.cols!==a)&&P.resize(g,a)}for(let y of[...r.keys()])h.has(y)||r.delete(y)},m=Le(h=>{if(s||o===null)return;let y=pt(o,{getWidget:g=>r.get(g)},{fullRedraw:h,statusText:e.statusText}),a=C.hideCursorSeq()+y.data;e.decorate!==void 0&&(a+=e.decorate({regions:Ee(o.viewport,o.chrome),scene:o})),a+=f.moveTo(y.cursor.row,y.cursor.col)+(y.cursor.visible?C.showCursorSeq():""),l(a)}),d=h=>{switch(h.t){case"scene":{let y=o,a=h.delta;o={tabs:a.tabs??y?.tabs??[],activeTab:a.activeTab??y?.activeTab??0,mode:a.mode??y?.mode??"normal",viewport:a.viewport??y?.viewport??w,focusedPane:a.focusedPane!==void 0?a.focusedPane:y?.focusedPane??null,panes:a.panes??y?.panes??[],chrome:a.chrome??y?.chrome??L};let g=h.full||a.panes!==void 0||a.tabs!==void 0||a.viewport!==void 0||a.chrome!==void 0;g&&T(),g?m.requestFull():m.schedule();break}case"output":b(h.pane).write(h.data),m.schedule();break;case"exit":S();break}},E=()=>{u=setInterval(()=>{let h=C.getTerminalSize();(h.cols!==w.cols||h.rows!==w.rows)&&(w={cols:h.cols,rows:h.rows},t.send({t:"resize",viewport:w}))},e.sizePollMs??250)},S=()=>{i&&(i=!1,s=!0,c?.abort(),u!==null&&clearInterval(u),m.stop(),l(me.disableMouse()+C.showCursorSeq()+C.exitAlternateScreen()),t.close())};return{handle:d,run:async()=>{i=!0,t.onMessage(d),l(C.enterAlternateScreen()+C.hideCursorSeq()+C.clearScreenSeq()+me.enableMouse());let h=C.getTerminalSize();w={cols:h.cols,rows:h.rows},t.send({t:"attach",viewport:w}),E(),c=new AbortController,await Ue(async()=>{for await(let y of $e(U.process.stdin,c.signal)){if(!i)break;try{if(y.kind==="mouse"){if(e.onMouse?.(y.event,o)===!0)continue;for(let a of mt(y.event,o))t.send(a)}else{if(e.onKey?.(y.event,o)===!0)continue;for(let a of ut(y.event,o?.mode??"normal",n))t.send(a)}}catch{}}})},stop:S,refresh:()=>{s||m.schedule()}}};var Fe=e=>{let t=new Map,n=new Map;return{async spawn(r){if(t.has(r.pane))return;let o=await tt({command:r.command,args:[...r.args],cwd:r.cwd,env:r.env,cols:r.cols,rows:r.rows});t.set(r.pane,o),n.set(r.pane,`${r.cols}x${r.rows}`),o.onData(i=>e.onData(r.pane,i)),o.exitCode.then(i=>e.onExit(r.pane,i)).catch(()=>e.onExit(r.pane,-1))},write(r,o){t.get(r)?.write(o)},resize(r,o,i){let s=`${o}x${i}`;n.get(r)!==s&&(n.set(r,s),t.get(r)?.resize(o,i))},kill(r){let o=t.get(r);o!==void 0&&(o.kill(),t.delete(r),n.delete(r))},forget(r){t.delete(r),n.delete(r)},async killAll(){let r=[...t.values()];t.clear(),n.clear();for(let c of r)c.kill("SIGTERM");let o=r.map(c=>c.exitCode.catch(()=>-1)),i,s=await Promise.race([Promise.allSettled(o).then(()=>!1),new Promise(c=>{i=setTimeout(()=>c(!0),2e3)})]);if(i!==void 0&&clearTimeout(i),s)for(let c of r)c.kill("SIGKILL")},has(r){return t.has(r)}}};var zt={up:"\x1B[A\x1B[A\x1B[A",down:"\x1B[B\x1B[B\x1B[B",pageUp:"\x1B[5~",pageDown:"\x1B[6~",home:"\x1B[H",end:"\x1B[F"},ie=e=>{let t=e.chrome??L,n=e.initialState,r=e.exitOnEmpty??!0,o=()=>Te(n.viewport,t),i=null,s=null,c=!1,u=new Set,w=new Set,l=(e.createHost??Fe)({onData:(a,g)=>i?.send({t:"output",pane:a,data:g}),onExit:(a,g)=>{l.forget(a),S({type:"paneExited",pane:a,code:g}),e.onPaneExit?.(a)}}),b=()=>{let a=n.tabs[n.activeTab];return a===void 0?new Map:B(a,n.viewport,o())},T=a=>({cols:a?Math.max(1,a.width-2):Math.max(1,n.viewport.cols-2),rows:a?Math.max(1,a.height-2):Math.max(1,n.viewport.rows-2)}),v=async a=>{let g=n.panes[a];if(!(g===void 0||l.has(a)||u.has(a))){u.add(a);try{let P=b().get(a),{cols:p,rows:x}=T(P),I=e.resolveSpawn(g,P??{x:0,y:0,width:p,height:x});await l.spawn({pane:a,command:I.command,args:I.args,cwd:I.cwd,env:I.env,cols:p,rows:x})}finally{u.delete(a),w.delete(a)&&l.has(a)&&l.kill(a)}}},m=()=>{for(let[a,g]of b()){if(!l.has(a))continue;let{cols:P,rows:p}=T(g);l.resize(a,P,p)}},d=()=>{let a=Oe(n,o()),g=s===null,P=ke(s,a);s=a,P!==null&&i?.send({t:"scene",full:g,delta:P})},E=a=>{switch(a.type){case"spawnPty":v(a.pane).catch(g=>{let P=g instanceof Error?g.message:String(g);i?.send({t:"output",pane:a.pane,data:`\r
2
2
  [mux] failed to start pane: ${P}\r
3
3
  `})});break;case"writePty":l.write(a.pane,a.data);break;case"killPty":l.has(a.pane)?l.kill(a.pane):u.has(a.pane)&&w.add(a.pane);break;case"scrollPane":l.write(a.pane,zt[a.action]);break;case"render":break;case"detach":i?.send({t:"exit",code:0});break;case"exit":if(!r)break;i?.send({t:"exit",code:0}),y();break}},S=a=>{if(c)return;let g=J(n,a);n=g.state;for(let P of g.effects)E(P);m(),d()},k=a=>{switch(a.t){case"attach":n={...n,viewport:a.viewport},s=null,m(),d();break;case"action":S(a.action);break;case"resize":S({type:"resizeViewport",cols:a.viewport.cols,rows:a.viewport.rows});break}},h=null,y=()=>(h!==null||(c=!0,h=(async()=>{await l.killAll(),i?.close()})()),h);return{connect(a){let g=i;i=a,s=null,a.onMessage(k),g!==null&&g!==a&&g.close()},disconnect(a){i===a&&(i=null)},dispatch:S,setChrome(a){t=a,m(),d()},getState:()=>n,dispose:y}};var ft=async e=>{let t=ue()==="windows"?"where":"which";try{return await et`${t} ${e}`.noThrow().code()===0}catch{return!1}},yt=async e=>{for(let t of e)if(await ft(t))return t;return null},_=e=>{let t=null,n=async()=>(t!==null||(t=await yt(e.candidates)),t);return{id:e.id,displayName:e.displayName,capabilities:{supportsBracketedPaste:!0,...e.capabilities},resolveCommand:n,async buildSpawnSpec(r){let o=await n();return o===null?null:{command:o,args:[],env:{...r.baseEnv,...r.extraEnv},cwd:r.cwd}}}};var ae=_({id:"claude-code",displayName:"Claude Code",candidates:["claude","claude-code"]});var Ne=_({id:"opencode",displayName:"OpenCode",candidates:["opencode"]});var Ke=_({id:"codex",displayName:"Codex",candidates:["codex"]});var Vt=[ae,Ne,Ke];var ze=e=>Vt.find(t=>t.id===e),Be=()=>ae;var $t=["IDLE","DISCOVERY","REVIEW","DRAFT","APPROVED","EXECUTING","DONE","IDLE"],Ht=e=>{let n={DISCOVERY_REFINEMENT:"REVIEW",SPEC_PROPOSAL:"DRAFT",SPEC_APPROVED:"APPROVED",COMPLETED:"DONE",BLOCKED:"EXECUTING"}[e]??e;return $t.map(r=>r===n?`[ ${r} ]`:r).join(" \u2192 ")},gt=async(e,t)=>{let n;try{n=await je(e,t)}catch{n=await qe(e)}let r=await nt(e,t),o=new Set(n.execution.completedTasks??[]),i=(r?.tasks??[]).map(m=>({id:m.id,description:m.title,done:o.has(m.id),...m.files!==void 0&&m.files.length>0?{files:m.files}:{}})),s=[...new Set(n.discovery.answers.map(m=>"user"in m?m.user:null).filter(m=>m!==null&&m!=="Unknown User"))],c=(n.specNotes??[]).filter(m=>m.text.startsWith("[QUESTION] ")).map(m=>({id:m.id,text:m.text.replace("[QUESTION] ",""),user:m.user,ts:m.timestamp})),u=n.transitionHistory??[],w=u.length>0?u[0].timestamp:new Date().toISOString(),l=n.lastCalledAt??w,b=n.execution.confidenceFindings??[],T=b.length>0?Math.round(b.reduce((m,d)=>m+d.confidence,0)/b.length*10)/10:null,v=b.filter(m=>m.confidence<5).length;return{name:t,slug:t,phase:n.phase,description:n.specDescription??"",tasks:i,contributors:s,delegations:n.discovery.delegations??[],pendingQuestions:c,pendingSignoffs:[],roadmap:Ht(n.phase),createdAt:w,updatedAt:l,avgConfidence:T,lowConfidenceItems:v}},ce=async e=>{let t=await Xe(e),n=new Set(t.map(d=>d.name));try{let d=`${e}/${We.specsDir}`;for await(let E of(await import("./mod-7VTKN6Q5.js")).runtime.fs.readDir(d))E.isDirectory&&!n.has(E.name)&&n.add(E.name)}catch{}let r=[];for(let d of n)try{r.push(await gt(e,d))}catch{}r.sort((d,E)=>{let S=d.phase!=="COMPLETED"&&d.phase!=="IDLE",k=E.phase!=="COMPLETED"&&E.phase!=="IDLE";return S&&!k?-1:!S&&k?1:E.updatedAt.localeCompare(d.updatedAt)});let o=r.find(d=>d.phase!=="COMPLETED"&&d.phase!=="IDLE")??null,i=await ve(e,{limit:50}),s=i.filter(d=>d.type==="mention"),c=new Set(i.filter(d=>d.type==="mention-reply").map(d=>d.mentionId)),u=s.filter(d=>!c.has(d.id)).map(d=>({id:d.id??"",spec:d.spec,from:d.from??d.user,to:d.to??"",question:d.question??"",status:"pending",ts:d.ts})),l=i.filter(d=>d.type==="signoff").filter(d=>d.status==="pending").map(d=>({spec:d.spec,role:d.role??"",status:"pending",ts:d.ts})),b=await be(e),T=b!==void 0?{name:b.name,email:b.email}:null,m=(await Qe(e))?.roles??null;return{specs:r,activeSpec:o,pendingMentions:u,pendingSignoffs:l,recentEvents:i,currentUser:T,roles:m}};var qt=e=>e===null?"\u2014":{DISCOVERY:"DISC",DISCOVERY_REFINEMENT:"REVW",SPEC_PROPOSAL:"DRFT",SPEC_APPROVED:"APPR",EXECUTING:"EXEC",BLOCKED:"BLKD",COMPLETED:"DONE",IDLE:"IDLE"}[e]??e.slice(0,4),jt=e=>{switch(e){case"EXECUTING":return"green";case"DISCOVERY":case"DISCOVERY_REFINEMENT":return"cyan";case"BLOCKED":return"red";case"SPEC_PROPOSAL":case"SPEC_APPROVED":return"yellow";case"COMPLETED":return"dim";default:return"dim"}},Xt=(e,t)=>{switch(t){case"green":return f.green(e);case"yellow":return f.yellow(e);case"red":return f.red(e);case"cyan":return f.cyan(e);case"dim":return f.dim(e);default:return e}},Qt=(e,t)=>{let n=new Set(t.filter(o=>o.spec!==null).map(o=>o.spec)),r=e.map(o=>({label:o.name,badge:qt(o.phase),badgeColor:jt(o.phase),active:n.has(o.name),dimmed:o.phase==="COMPLETED"}));return r.length===0&&r.push({label:"No specs yet",dimmed:!0,selectable:!1}),r},ht=(e,t,n,r)=>{let o=Qt(e,t),i=$.drawBox({x:r.x,y:r.y,width:r.width,height:r.height,title:"Specs",borderStyle:"rounded"}),s=r.width-2,c=r.height-2,u=Math.max(0,Math.min(n,o.length-1)),w=W.ensureVisible(W.createScrollState(o.length,c),u),l=W.visibleRange(w),b=[];for(let m=0;m<c;m++){let d=l.start+m,E=r.y+1+m;if(d>=l.end||d>=o.length){b.push(f.moveTo(E,r.x+1)+" ".repeat(s));continue}let S=o[d];if(S===void 0){b.push(f.moveTo(E,r.x+1)+" ".repeat(s));continue}let k=S.selectable!==!1,h=d===n&&k,y=S.active?f.green("\u25CF"):h?"\u25B8":" ",a=S.badge!==void 0?" "+Xt(`[${S.badge}]`,S.badgeColor??"dim"):"",g=S.dimmed?f.dim(S.label):S.label,P=` ${y} ${g}${a}`,p=f.truncate(P,s),x=Math.max(0,s-f.visibleLength(p));h?b.push(f.moveTo(E,r.x+1)+f.inverse(p+" ".repeat(x))):b.push(f.moveTo(E,r.x+1)+p+" ".repeat(x))}let T={id:r.id,x:r.x,y:r.y+1,width:r.width-1,height:c},v=W.renderScrollbar(T,w);return i+b.join("")+v};var Jt=["IDLE","DISCOVERY","REVIEW","DRAFT","APPROVED","EXECUTING","DONE","IDLE"],Zt=e=>{if(e===null||e==="IDLE")return"IDLE";let n={DISCOVERY_REFINEMENT:"REVIEW",SPEC_PROPOSAL:"DRAFT",SPEC_APPROVED:"APPROVED",COMPLETED:"DONE"}[e]??e;return Jt.map(r=>r===n?f.bold(`\u2726${r}\u2726`):f.dim(r)).join("\u2192")},en=(e,t,n)=>{if(t===0)return f.dim("no tasks");let r=Math.round(e/t*n),o=n-r;return f.green("\u2588".repeat(r))+f.dim("\u2591".repeat(o))+` ${e}/${t}`},wt=(e,t,n)=>{let r=[];return e===null?(r.push(f.bold("Mode: ")+f.cyan("IDLE")),r.push(f.dim("No active spec"))):e.mode==="free"?(r.push(f.bold("Mode: ")+f.cyan("IDLE")),r.push(f.dim("No active spec")),r.push(""),r.push(f.dim(`Session: ${e.sessionId}`))):(r.push(f.bold("Spec: ")+(e.spec??"unknown")),r.push(f.bold("Phase: ")+(e.phase??"unknown")),r.push(""),r.push(Zt(e.phase)),r.push(""),n!==void 0&&r.push(f.bold("Progress: ")+en(n.completed,n.total,15)),r.push(""),r.push(f.dim(`Session: ${e.sessionId}`))),$.fillBox({x:t.x,y:t.y,width:t.width,height:t.height,title:"Monitor",borderStyle:"rounded"},r)};var de=()=>new Date().toISOString(),St=(e,t={})=>{let n=typeof e=="function"?e:()=>e;return r=>{let o=U.env.toObject(),i=n();return{command:r.command??o.SHELL??"/bin/sh",args:r.args??[],cwd:r.cwd??i,env:{...o,NOSKILLS_SESSION:r.meta?.sessionId??t.sessionId?.()??"",NOSKILLS_PROJECT_ROOT:i}}}},bt=async(e,t)=>{let n=we();return await ge(e,{id:n,spec:null,mode:"free",phase:null,pid:0,startedAt:de(),lastActiveAt:de(),tool:t}),{sessionId:n,spec:null,mode:"free",phase:null}},vt=async(e,t,n)=>{let r=null;try{r=(await ye(e,t)).phase}catch{}let o=we();return await ge(e,{id:o,spec:t,mode:"spec",phase:r,pid:0,startedAt:de(),lastActiveAt:de(),tool:n}),{sessionId:o,spec:t,mode:"spec",phase:r}};var rn=30,on=8,wo=async e=>{let t=e?.includes("--dry-run")??!1,{root:n}=await Ze();if(!await Je(n))return console.error("noskills is not initialized. Run:",Se(),"init"),_e({exitCode:1});let r=ze("claude-code")??Be(),o=(await ce(n)).specs.map(p=>({name:p.name,phase:p.phase,hasActiveSession:!1})),i=0,s=!1,c=new Map;if(t)return console.log(`noskills manager | ${o.length} spec(s) | ${Se()}`),pe(void 0);let u=!0,w=()=>({tabBarRows:1,statusBarRows:1,leftCols:u?rn:0,topRows:on}),l=St(n),{cols:b,rows:T}=C.getTerminalSize(),v=ie({initialState:Z.createInitialState({cols:b,rows:T}),resolveSpawn:l,chrome:w()}),m=async p=>{let x=await r.resolveCommand()??"claude";v.dispatch({type:"newTab",command:x,cwd:n,title:p.spec??"free",meta:{sessionId:p.sessionId}});let I=v.getState(),M=I.tabs[I.activeTab];M!==void 0&&c.set(M.id,{id:M.id,spec:p.spec,mode:p.mode,sessionId:p.sessionId,phase:p.phase})},d=async()=>{await m(await bt(n,r.id))},E=async p=>{for(let x of c.values())if(x.spec===p){let I=v.getState().tabs.findIndex(M=>M.id===x.id);if(I>=0){v.dispatch({type:"gotoTab",index:I});return}}await m(await vt(n,p,r.id))},S,k=p=>{let x=new Set(p.scene.tabs.map(N=>N.id));for(let N of[...c.keys()])if(!x.has(N)){let le=c.get(N);c.delete(N),he(n,le.sessionId).catch(()=>{})}let I=[...c.values()],M="";if(p.regions.left!==void 0&&(M+=ht(o,I,i,{id:"specs",...p.regions.left})),p.regions.top!==void 0){let N=p.scene.tabs[p.scene.activeTab]?.id,le=N!==void 0?c.get(N)??null:null;M+=wt(le,{id:"monitor",...p.regions.top})}return M},h=p=>{if(s)switch(p.name){case"up":return i=Math.max(0,i-1),S.refresh(),!0;case"down":return i=Math.min(Math.max(0,o.length-1),i+1),S.refresh(),!0;case"return":{let x=o[i];return s=!1,x!==void 0&&E(x.name).catch(()=>{}),S.refresh(),!0}case"x":return s=!1,v.dispatch({type:"closeFocusedPane"}),S.refresh(),!0;case"escape":case"tab":return s=!1,S.refresh(),!0;default:return!0}return p.ctrl&&p.name==="e"?(s=!0,S.refresh(),!0):p.ctrl&&p.name==="t"?(d().catch(()=>{}),!0):p.ctrl&&p.name==="w"?(u=!u,v.setChrome(w()),!0):p.ctrl&&/^[1-9]$/.test(p.name)?(v.dispatch({type:"gotoTab",index:Number(p.name)-1}),!0):!1},y=(p,x)=>{if(x===null)return!1;let I=x.chrome.leftCols??0;if(I>0&&p.x<=I&&p.type==="mousedown"){let M=p.y-3;return M>=0&&M<o.length&&(i=M,E(o[M].name).catch(()=>{}),S.refresh()),!0}return!1},[a,g]=oe();v.connect(a),S=se({transport:g,keymap:re.buildKeymap({normal:{"ctrl+q":{type:"quit"}}}),decorate:k,onKey:h,onMouse:y,statusText:" noskills | ctrl+e specs \xB7 ctrl+t new tab \xB7 ctrl+1-9 switch \xB7 ctrl+w hide \xB7 ctrl+q quit"});let P=xe(n,async()=>{try{o=(await ce(n)).specs.map(x=>({name:x.name,phase:x.phase,hasActiveSession:!1})),i>=o.length&&(i=Math.max(0,o.length-1)),S.refresh()}catch{}});await d();try{await S.run()}finally{P(),S.stop();for(let p of c.values())await he(n,p.sessionId).catch(()=>{});await v.dispose(),await Ye(n)}return pe(void 0)};export{wo as main};
@@ -1 +1 @@
1
- import{a,b,c,d,e}from"./chunk-4PF2MT7S.js";import"./chunk-HISXAZ4Y.js";export{c as detectRuntime,a as getLibraryExtension,e as loadEserAjan,b as resolveLibraryPath,d as selectBackend};
1
+ import{a,b,c,d,e}from"./chunk-34RPTI4K.js";import"./chunk-HISXAZ4Y.js";export{c as detectRuntime,a as getLibraryExtension,e as loadEserAjan,b as resolveLibraryPath,d as selectBackend};
@@ -1 +1 @@
1
- import{a as g,b as v}from"./chunk-EIGFDYGQ.js";import{a as G,b as O}from"./chunk-RAQY37P6.js";import{a as h,b as R}from"./chunk-5PBNUBBY.js";import{a as k,b as E}from"./chunk-JL3MAFYQ.js";import{a as L,b as S}from"./chunk-QKWJ72HI.js";import{a as w,b as A,c as M,d as C,e as T,f as B,g as I}from"./chunk-CML74SNT.js";import{a as b,b as j,c as _,d as D,e as J}from"./chunk-PRQ5CRIG.js";import{a as n,b as s}from"./chunk-7GC46XEU.js";import{a as d,b as l}from"./chunk-S4MUTKHT.js";import{a as x,b as P}from"./chunk-KMLNG3EC.js";import{a as m,b as y,c as p,d as F,e as f,f as u}from"./chunk-PSX63TYP.js";import"./chunk-EJYSOUEA.js";import"./chunk-JYVB6UAV.js";import"./chunk-IGDFEGCH.js";import"./chunk-ENP4P2YH.js";import"./chunk-575Y3OEG.js";import"./chunk-4PF2MT7S.js";import"./chunk-OAWYVETM.js";import"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var a=null,Y=()=>(a??=V(),a),i={anthropic:async()=>(await import("./anthropic-TS7EMQML.js")).anthropicFactory,openai:async()=>(await import("./openai-YES2XJDU.js")).openaiFactory,gemini:async()=>(await import("./gemini-IWP24T63.js")).geminiFactory,vertexai:async()=>(await import("./vertexai-WF5CKMYI.js")).vertexaiFactory,"claude-code":async()=>(await import("./claude-code-DIWRQKZA.js")).claudeCodeFactory,ollama:async()=>(await import("./ollama-2KAMCXVL.js")).ollamaFactory,opencode:async()=>(await import("./opencode-S4M7WJTO.js")).openCodeFactory,kiro:async()=>(await import("./kiro-THWCXS5L.js")).kiroFactory},t=null,c=()=>(t??=(async()=>{let{tryLoadBridgeFactories:o}=await import("./ajan-bridge-T5M4DPDT.js");return await o()})(),t),K=async o=>await i[o]?.(),q=async o=>{for(let e of await c())if(e.provider===o)return e;return await K(o)},V=async()=>{let o=await Promise.all(Object.values(i).map(r=>r())),e=new Map;for(let r of o)e.set(r.provider,r);for(let r of await c())e.set(r.provider,r);return[...e.values()]};export{b as AjanBridgeModel,j as AjanBridgeModelFactory,n as AnthropicModel,G as ClaudeCodeModel,x as GeminiModel,L as KiroModel,h as OllamaModel,d as OpenAIModel,k as OpenCodeModel,g as VertexAIModel,s as anthropicFactory,T as captureStderr,B as classifyExitCode,u as classifyGenAIError,O as claudeCodeFactory,_ as createBridgeFactories,Y as defaultFactories,q as factoryFor,I as formatMessagesAsText,P as geminiFactory,J as getBridgeLoadError,S as kiroFactory,y as mapContentBlockToGenAIPart,f as mapGenAIResponseToResult,p as mapMessagesToGenAI,m as mapRoleToGenAI,F as mapToolsToGenAI,R as ollamaFactory,E as openCodeFactory,l as openaiFactory,M as parseJsonlStream,C as parseTextOutput,w as resolveBinary,A as spawnCliProcess,D as tryLoadBridgeFactories,K as tsFactoryFor,v as vertexaiFactory};
1
+ import{a as x,b as P}from"./chunk-BYPCI5VU.js";import{a as g,b as v}from"./chunk-OP4XAIGW.js";import{a as m,b as y,c as p,d as F,e as f,f as u}from"./chunk-PSX63TYP.js";import{a as G,b as O}from"./chunk-YUTDPPXX.js";import{a as h,b as R}from"./chunk-TCSIXKUD.js";import{a as k,b as E}from"./chunk-LGQEWL5X.js";import{a as L,b as S}from"./chunk-CKIZYL4O.js";import{a as w,b as A,c as M,d as C,e as T,f as B,g as I}from"./chunk-Y45DQJSS.js";import{a as b,b as j,c as _,d as D,e as J}from"./chunk-XDPATEP5.js";import{a as n,b as s}from"./chunk-AB3N327V.js";import"./chunk-EJYSOUEA.js";import{a as d,b as l}from"./chunk-DYCGJ4RY.js";import"./chunk-JYVB6UAV.js";import"./chunk-HB62UGZI.js";import"./chunk-ENP4P2YH.js";import"./chunk-3JTDWOAJ.js";import"./chunk-34RPTI4K.js";import"./chunk-OAWYVETM.js";import"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var a=null,Y=()=>(a??=V(),a),i={anthropic:async()=>(await import("./anthropic-ZKOMTKX2.js")).anthropicFactory,openai:async()=>(await import("./openai-MSJF4B6H.js")).openaiFactory,gemini:async()=>(await import("./gemini-23EOEXSF.js")).geminiFactory,vertexai:async()=>(await import("./vertexai-CVCRCO24.js")).vertexaiFactory,"claude-code":async()=>(await import("./claude-code-OQJIUKZP.js")).claudeCodeFactory,ollama:async()=>(await import("./ollama-MXRDGQDF.js")).ollamaFactory,opencode:async()=>(await import("./opencode-ZDHKR2P6.js")).openCodeFactory,kiro:async()=>(await import("./kiro-TPAAIMY6.js")).kiroFactory},t=null,c=()=>(t??=(async()=>{let{tryLoadBridgeFactories:o}=await import("./ajan-bridge-BNPC757J.js");return await o()})(),t),K=async o=>await i[o]?.(),q=async o=>{for(let e of await c())if(e.provider===o)return e;return await K(o)},V=async()=>{let o=await Promise.all(Object.values(i).map(r=>r())),e=new Map;for(let r of o)e.set(r.provider,r);for(let r of await c())e.set(r.provider,r);return[...e.values()]};export{b as AjanBridgeModel,j as AjanBridgeModelFactory,n as AnthropicModel,G as ClaudeCodeModel,x as GeminiModel,L as KiroModel,h as OllamaModel,d as OpenAIModel,k as OpenCodeModel,g as VertexAIModel,s as anthropicFactory,T as captureStderr,B as classifyExitCode,u as classifyGenAIError,O as claudeCodeFactory,_ as createBridgeFactories,Y as defaultFactories,q as factoryFor,I as formatMessagesAsText,P as geminiFactory,J as getBridgeLoadError,S as kiroFactory,y as mapContentBlockToGenAIPart,f as mapGenAIResponseToResult,p as mapMessagesToGenAI,m as mapRoleToGenAI,F as mapToolsToGenAI,R as ollamaFactory,E as openCodeFactory,l as openaiFactory,M as parseJsonlStream,C as parseTextOutput,w as resolveBinary,A as spawnCliProcess,D as tryLoadBridgeFactories,K as tsFactoryFor,v as vertexaiFactory};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h}from"./chunk-IGDFEGCH.js";import"./chunk-ENP4P2YH.js";import"./chunk-575Y3OEG.js";import"./chunk-4PF2MT7S.js";import"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";export{d as CommandBuilder,a as CommandError,h as ProcessGroup,f as exec,e as parseCommand,c as spawnChildGo,b as spawnChildGoSync,g as spawnPty};
1
+ import{a,b,c,d,e,f,g,h}from"./chunk-HB62UGZI.js";import"./chunk-ENP4P2YH.js";import"./chunk-3JTDWOAJ.js";import"./chunk-34RPTI4K.js";import"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";export{d as CommandBuilder,a as CommandError,h as ProcessGroup,f as exec,e as parseCommand,c as spawnChildGo,b as spawnChildGoSync,g as spawnPty};
@@ -1 +1 @@
1
- import{a as A,b as E}from"./chunk-KM64FL2X.js";import{a as C,b as D}from"./chunk-EIMBEXUJ.js";import{a as k,b as w,c as x,d as y,e as z,f as B}from"./chunk-CTTMQSHF.js";import{a,b,c,d,e,f,g,h,i,j}from"./chunk-EJYSOUEA.js";import{a as l,b as m,c as n,d as o,e as p,f as q,g as r,h as s,i as t,j as u,k as v}from"./chunk-JYVB6UAV.js";import"./chunk-IGDFEGCH.js";import"./chunk-ENP4P2YH.js";import"./chunk-575Y3OEG.js";import"./chunk-4PF2MT7S.js";import"./chunk-CH6A3LES.js";import"./chunk-OAWYVETM.js";import"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";export{l as AiError,n as AuthFailedError,p as BadRequestError,o as InsufficientCreditsError,s as ModelAlreadyExistsError,r as ModelNotFoundError,m as RateLimitedError,B as Registry,q as ServiceUnavailableError,t as UnsupportedProviderError,c as audioMessage,v as classifyAndWrap,u as classifyStatusCode,z as collectStream,i as decodeDataUrl,C as detectAllProviders,j as detectMimeFromUrl,D as getAvailableProviderNames,b as imageMessage,A as isBatchCapable,h as isDataUrl,E as moduleDef,w as text,e as textBlock,a as textMessage,x as textResult,f as toolCallBlock,y as toolCalls,g as toolResultBlock,d as toolResultMessage,k as withDefaults};
1
+ import{a as A,b as E}from"./chunk-J25XTDQQ.js";import{a as k,b as w,c as x,d as y,e as z,f as B}from"./chunk-CTTMQSHF.js";import{a as C,b as D}from"./chunk-IM73MYMS.js";import{a,b,c,d,e,f,g,h,i,j}from"./chunk-EJYSOUEA.js";import{a as l,b as m,c as n,d as o,e as p,f as q,g as r,h as s,i as t,j as u,k as v}from"./chunk-JYVB6UAV.js";import"./chunk-HB62UGZI.js";import"./chunk-ENP4P2YH.js";import"./chunk-3JTDWOAJ.js";import"./chunk-34RPTI4K.js";import"./chunk-CH6A3LES.js";import"./chunk-OAWYVETM.js";import"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";export{l as AiError,n as AuthFailedError,p as BadRequestError,o as InsufficientCreditsError,s as ModelAlreadyExistsError,r as ModelNotFoundError,m as RateLimitedError,B as Registry,q as ServiceUnavailableError,t as UnsupportedProviderError,c as audioMessage,v as classifyAndWrap,u as classifyStatusCode,z as collectStream,i as decodeDataUrl,C as detectAllProviders,j as detectMimeFromUrl,D as getAvailableProviderNames,b as imageMessage,A as isBatchCapable,h as isDataUrl,E as moduleDef,w as text,e as textBlock,a as textMessage,x as textResult,f as toolCallBlock,y as toolCalls,g as toolResultBlock,d as toolResultMessage,k as withDefaults};
@@ -1,4 +1,4 @@
1
- import{a as he}from"./chunk-NGCBWJML.js";import{a as Xe}from"./chunk-KJLEPI7T.js";import{a as ue,c as me,e as fe}from"./chunk-5DZHAHXW.js";import{a as Ge,b as Ke,d as O}from"./chunk-7PPUGTKL.js";import{a as Ze}from"./chunk-6YSS6PEL.js";import{a as X}from"./chunk-EROZRDGT.js";import{a as et,b as tt,c as st,d as nt}from"./chunk-LN4NDYT6.js";import{h as K}from"./chunk-5RLCKUIF.js";import{B as le,C as He,L as pe,M as Ye,N as de,P as Be,a as Me,b as qe,c as ne,d as Le,e as Ue,f as ie,g as j,h as re,i as je,j as Y,k as oe,l as _e,n as Ve,p as ae,q as Je,t as ce,u as We,v as B,w as Qe,x as ze}from"./chunk-UE56BMAW.js";import"./chunk-XDRX4ZBJ.js";import{c as G}from"./chunk-IFE5SYGK.js";import"./chunk-Z7OYXH3J.js";import{a as we,b as ve,c as ye}from"./chunk-VJRCTYGL.js";import{a as xe,b as Ce,c as De,d as Re,e as Ie,g as ke,h as Pe,j as Ae,k as U}from"./chunk-PKEQKXZW.js";import{h as Q}from"./chunk-O4KKKYCH.js";import{D as Oe,E as Ne,b as ge,d as Se,f as $,h as Ee,i as be,m as $e,n as Te,o as z,p as te,s as Fe,u as H,z as se}from"./chunk-KRKOWSYW.js";import{a as W,b as L}from"./chunk-OAWYVETM.js";import{i as R}from"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var Ut=async i=>{let{root:e}=await Ne(),c=Ge(i),a=Ke(i);if(!await Oe(e))return await O({error:`noskills not initialized. Run: ${G("init")}`},c),L({exitCode:1});let r=null;for(let m of a)m.startsWith("--answer=")&&(r=m.slice(9));let t=be(a),s;try{s=await Ee(e,t)}catch(m){let g=m instanceof Error?m.message:String(m);return await O({error:g},c),L({exitCode:1})}if(t===null&&s.phase!=="IDLE"&&s.phase!=="COMPLETED")return await O({error:"Error: --spec=<name> is required. Use `noskills spec list` to see available specs."},c),L({exitCode:1});let l=await z(e);if(l?.command!==void 0){let{setCommandPrefix:m}=await import("./cmd-46ZIHXLB.js");m(l.command)}if(l===null)return await O({error:"No config found"},c),L({exitCode:1});if(s.spec!==null&&s.phase!=="IDLE"&&s.phase!=="COMPLETED"){let m=`${e}/${$.specDir(s.spec)}`;try{await R.fs.stat(m)}catch{return await O({error:!0,message:`Active spec '${s.spec}' directory not found. Files may have been deleted manually.`,suggestion:`Run \`${G("reset")}\` to return to idle, or \`${G("cancel")}\` to mark as cancelled.`},c),L({exitCode:1})}}let f=Xe(a,l);s.phase==="DISCOVERY"&&s.discovery.audience!==f&&(s={...s,discovery:{...s.discovery,audience:f}});let o=(await Fe(e)).filter(m=>l.concerns.includes(m.id));if(r!==null){let m=await K(e),g=await ft(e,s,l,o,r,m);await H(e,g);let w={...g,lastCalledAt:new Date().toISOString()};await H(e,w);let q=R.env.get("NOSKILLS_SESSION")??null;q!==null&&await se(e,q,w.phase);let _=await ue(e),{tier1:N,tier2Count:Z}=me(_,w.phase),ee=w.spec!==null?await X(e,w.spec):null,v=await ot(e,w),D=await he(e,v),M=fe(l?.tools??[]),F=await K(e),P=await de(w,o,N,l,ee,D,void 0,M,F,Z,e),C=r.trim().toLowerCase()==="save",b=w.phase===s.phase;if(C&&b&&(w.phase==="SPEC_PROPOSAL"||w.phase==="SPEC_APPROVED")){let V=w.phase==="SPEC_PROPOSAL"?"Spec draft saved. The spec stays in DRAFT and can be reviewed by anyone. Other users can add ACs (`ac add`), notes (`note add`), or tasks (`task add`) while in draft. When ready, any user can approve with `noskills spec <name> approve`.":'Spec is approved and parked. Others can still add ACs or notes. When ready, run `noskills next --answer="start"` to begin execution.',J={...P,instruction:V,saved:!0};return await O(J,c),W(void 0)}return await O(P,c),W(void 0)}let p={...s,lastCalledAt:new Date().toISOString()};await H(e,p);let d=R.env.get("NOSKILLS_SESSION")??null;d!==null&&await se(e,d,p.phase);let u=await ue(e),{tier1:S,tier2Count:y}=me(u,p.phase),x=p.spec!==null?await X(e,p.spec):null,I=await ot(e,p),k=await he(e,I),T;p.phase==="IDLE"&&(T={existingSpecs:(await Te(e)).map(g=>({name:g.name,phase:g.state.phase,iteration:g.state.execution.iteration,detail:g.state.phase==="EXECUTING"?`${g.state.execution.completedTasks.length} tasks done, iteration ${g.state.execution.iteration}`:g.state.phase==="SPEC_PROPOSAL"?"awaiting approval":g.state.phase==="COMPLETED"?"completed":void 0})),rulesCount:S.length});let A=fe(l?.tools??[]),E=await K(e),h=await de(p,o,S,l,x,k,T,A,E,y,e);return await O(h,c),W(void 0)},at=async(i,e,c)=>{let a=`${i}/${$.askTokenFile}`;try{let r=await R.fs.readTextFile(a),t=JSON.parse(r);if((t.spec??null)!==(e??null))return{source:"INFERRED",questionMatch:"not-asked"};if(t.stepId!==c)return{source:"INFERRED",questionMatch:"not-asked"};let s=Date.now()-new Date(t.createdAt??0).getTime();if(!isFinite(s)||s<0||s>1800*1e3)return{source:"INFERRED",questionMatch:"not-asked"};try{await R.fs.remove(a)}catch{}return{source:"STATED",questionMatch:t.match??"exact"}}catch{return{source:"INFERRED",questionMatch:"not-asked"}}},ct=(i,e,c)=>{let a=i.discovery.answers,r=-1;for(let n=a.length-1;n>=0;n--){let o=a[n];if(o!==void 0&&o.questionId===e){r=n;break}}if(r===-1)return i;let t=a[r];if(t===void 0)return i;let l={...Se(t),source:c.source,questionMatch:c.questionMatch},f=[...a.slice(0,r),l,...a.slice(r+1)];return{...i,discovery:{...i.discovery,answers:f}}},pt=["status_quo","ambition","reversibility","user_impact","verification","scope_boundary"],dt=(i,e)=>i===null&&e===null?!0:i===null||e===null?!1:i.involvesWebUI===e.involvesWebUI&&i.involvesCLI===e.involvesCLI&&i.involvesPublicAPI===e.involvesPublicAPI&&i.involvesMigration===e.involvesMigration&&i.involvesDataHandling===e.involvesDataHandling,ut=async(i,e,c,a,r,t)=>{if(e.spec===null||e.specState.path===null)return{newState:e,revealNotification:null};let s=Pe(c),l=new Date,f=r?.name??"Unknown User",n=e.classification??null,o=Ye(e),p=!dt(n,o),d=xe(t),u=Ie(e.specState.placeholders,s,f,l);u=Ce(u,d,o);let S=ke(e.specState.metadata,{type:"answer",user:f,section:s},l),y={...e,classification:o,specState:{...e.specState,placeholders:u,metadata:S}},x=null;if(p){let I=Re(e.specState.placeholders,u),k=I?.revealed??[],T=I?.hidden??[],A=k.map(m=>{let g=d.find(q=>q.id===m),w=g?.concernSource!==void 0?` (from concern: ${g.concernSource})`:"";return` \u2022 ${g?.title??m}${w}`}),E=T.map(m=>` \u2022 ${d.find(w=>w.id===m)?.title??m}`),h=[];if(A.length>0){let m=De(n,o);h.push(`
1
+ import{a as he}from"./chunk-NGCBWJML.js";import{a as Ze}from"./chunk-7PBHRFOZ.js";import{a as X}from"./chunk-EROZRDGT.js";import{a as et,b as tt,c as st,d as nt}from"./chunk-FYFUEK4U.js";import{h as K}from"./chunk-5RLCKUIF.js";import{a as Xe}from"./chunk-KJLEPI7T.js";import"./chunk-Z7OYXH3J.js";import{a as ue,c as me,e as fe}from"./chunk-LKZZ4JN5.js";import{a as Ge,b as Ke,d as O}from"./chunk-7PPUGTKL.js";import{B as le,C as He,L as pe,M as Ye,N as de,P as Be,a as Me,b as qe,c as ne,d as Le,e as Ue,f as ie,g as j,h as re,i as je,j as Y,k as oe,l as _e,n as Ve,p as ae,q as Je,t as ce,u as We,v as B,w as Qe,x as ze}from"./chunk-EVJYA7S3.js";import"./chunk-XDRX4ZBJ.js";import{c as G}from"./chunk-IFE5SYGK.js";import{a as we,b as ve,c as ye}from"./chunk-VJRCTYGL.js";import{h as Q}from"./chunk-O4KKKYCH.js";import{a as xe,b as Ce,c as De,d as Re,e as Ie,g as ke,h as Pe,j as Ae,k as U}from"./chunk-ONJVI5AZ.js";import{D as Oe,E as Ne,b as ge,d as Se,f as $,h as Ee,i as be,m as $e,n as Te,o as z,p as te,s as Fe,u as H,z as se}from"./chunk-WDKWHGJU.js";import{a as W,b as L}from"./chunk-OAWYVETM.js";import{i as R}from"./chunk-Y5E7ZCCX.js";import"./chunk-LJEWPIEI.js";import"./chunk-FE4MKOI4.js";import"./chunk-HISXAZ4Y.js";var Ut=async i=>{let{root:e}=await Ne(),c=Ge(i),a=Ke(i);if(!await Oe(e))return await O({error:`noskills not initialized. Run: ${G("init")}`},c),L({exitCode:1});let r=null;for(let m of a)m.startsWith("--answer=")&&(r=m.slice(9));let t=be(a),s;try{s=await Ee(e,t)}catch(m){let g=m instanceof Error?m.message:String(m);return await O({error:g},c),L({exitCode:1})}if(t===null&&s.phase!=="IDLE"&&s.phase!=="COMPLETED")return await O({error:"Error: --spec=<name> is required. Use `noskills spec list` to see available specs."},c),L({exitCode:1});let l=await z(e);if(l?.command!==void 0){let{setCommandPrefix:m}=await import("./cmd-46ZIHXLB.js");m(l.command)}if(l===null)return await O({error:"No config found"},c),L({exitCode:1});if(s.spec!==null&&s.phase!=="IDLE"&&s.phase!=="COMPLETED"){let m=`${e}/${$.specDir(s.spec)}`;try{await R.fs.stat(m)}catch{return await O({error:!0,message:`Active spec '${s.spec}' directory not found. Files may have been deleted manually.`,suggestion:`Run \`${G("reset")}\` to return to idle, or \`${G("cancel")}\` to mark as cancelled.`},c),L({exitCode:1})}}let f=Xe(a,l);s.phase==="DISCOVERY"&&s.discovery.audience!==f&&(s={...s,discovery:{...s.discovery,audience:f}});let o=(await Fe(e)).filter(m=>l.concerns.includes(m.id));if(r!==null){let m=await K(e),g=await ft(e,s,l,o,r,m);await H(e,g);let w={...g,lastCalledAt:new Date().toISOString()};await H(e,w);let q=R.env.get("NOSKILLS_SESSION")??null;q!==null&&await se(e,q,w.phase);let _=await ue(e),{tier1:N,tier2Count:Z}=me(_,w.phase),ee=w.spec!==null?await X(e,w.spec):null,v=await ot(e,w),D=await he(e,v),M=fe(l?.tools??[]),F=await K(e),P=await de(w,o,N,l,ee,D,void 0,M,F,Z,e),C=r.trim().toLowerCase()==="save",b=w.phase===s.phase;if(C&&b&&(w.phase==="SPEC_PROPOSAL"||w.phase==="SPEC_APPROVED")){let V=w.phase==="SPEC_PROPOSAL"?"Spec draft saved. The spec stays in DRAFT and can be reviewed by anyone. Other users can add ACs (`ac add`), notes (`note add`), or tasks (`task add`) while in draft. When ready, any user can approve with `noskills spec <name> approve`.":'Spec is approved and parked. Others can still add ACs or notes. When ready, run `noskills next --answer="start"` to begin execution.',J={...P,instruction:V,saved:!0};return await O(J,c),W(void 0)}return await O(P,c),W(void 0)}let p={...s,lastCalledAt:new Date().toISOString()};await H(e,p);let d=R.env.get("NOSKILLS_SESSION")??null;d!==null&&await se(e,d,p.phase);let u=await ue(e),{tier1:S,tier2Count:y}=me(u,p.phase),x=p.spec!==null?await X(e,p.spec):null,I=await ot(e,p),k=await he(e,I),T;p.phase==="IDLE"&&(T={existingSpecs:(await Te(e)).map(g=>({name:g.name,phase:g.state.phase,iteration:g.state.execution.iteration,detail:g.state.phase==="EXECUTING"?`${g.state.execution.completedTasks.length} tasks done, iteration ${g.state.execution.iteration}`:g.state.phase==="SPEC_PROPOSAL"?"awaiting approval":g.state.phase==="COMPLETED"?"completed":void 0})),rulesCount:S.length});let A=fe(l?.tools??[]),E=await K(e),h=await de(p,o,S,l,x,k,T,A,E,y,e);return await O(h,c),W(void 0)},at=async(i,e,c)=>{let a=`${i}/${$.askTokenFile}`;try{let r=await R.fs.readTextFile(a),t=JSON.parse(r);if((t.spec??null)!==(e??null))return{source:"INFERRED",questionMatch:"not-asked"};if(t.stepId!==c)return{source:"INFERRED",questionMatch:"not-asked"};let s=Date.now()-new Date(t.createdAt??0).getTime();if(!isFinite(s)||s<0||s>1800*1e3)return{source:"INFERRED",questionMatch:"not-asked"};try{await R.fs.remove(a)}catch{}return{source:"STATED",questionMatch:t.match??"exact"}}catch{return{source:"INFERRED",questionMatch:"not-asked"}}},ct=(i,e,c)=>{let a=i.discovery.answers,r=-1;for(let n=a.length-1;n>=0;n--){let o=a[n];if(o!==void 0&&o.questionId===e){r=n;break}}if(r===-1)return i;let t=a[r];if(t===void 0)return i;let l={...Se(t),source:c.source,questionMatch:c.questionMatch},f=[...a.slice(0,r),l,...a.slice(r+1)];return{...i,discovery:{...i.discovery,answers:f}}},pt=["status_quo","ambition","reversibility","user_impact","verification","scope_boundary"],dt=(i,e)=>i===null&&e===null?!0:i===null||e===null?!1:i.involvesWebUI===e.involvesWebUI&&i.involvesCLI===e.involvesCLI&&i.involvesPublicAPI===e.involvesPublicAPI&&i.involvesMigration===e.involvesMigration&&i.involvesDataHandling===e.involvesDataHandling,ut=async(i,e,c,a,r,t)=>{if(e.spec===null||e.specState.path===null)return{newState:e,revealNotification:null};let s=Pe(c),l=new Date,f=r?.name??"Unknown User",n=e.classification??null,o=Ye(e),p=!dt(n,o),d=xe(t),u=Ie(e.specState.placeholders,s,f,l);u=Ce(u,d,o);let S=ke(e.specState.metadata,{type:"answer",user:f,section:s},l),y={...e,classification:o,specState:{...e.specState,placeholders:u,metadata:S}},x=null;if(p){let I=Re(e.specState.placeholders,u),k=I?.revealed??[],T=I?.hidden??[],A=k.map(m=>{let g=d.find(q=>q.id===m),w=g?.concernSource!==void 0?` (from concern: ${g.concernSource})`:"";return` \u2022 ${g?.title??m}${w}`}),E=T.map(m=>` \u2022 ${d.find(w=>w.id===m)?.title??m}`),h=[];if(A.length>0){let m=De(n,o);h.push(`
2
2
  Classification updated. ${A.length} new section(s) appeared:
3
3
  `+A.join(`
4
4
  `)+`
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g}from"./chunk-5OTECUN7.js";import"./chunk-HISXAZ4Y.js";export{a as child_process,b as crypto,c as fs,d as os,e as path,f as stream,g as util};
@@ -0,0 +1,15 @@
1
+ import{A as Ge,B as He,C as ve,a as u,b as a,c as b,r as qe,s as ze,t as ce,x as R,y as m,z as le}from"./chunk-GNMOE7H3.js";import{a as Be,b as C,c as L,e as h,f as Me,g as Ye}from"./chunk-5OTECUN7.js";import"./chunk-HISXAZ4Y.js";import*as g from"node:fs/promises";import*as oe from"node:fs";import*as M from"node:path";import*as je from"node:child_process";import*as Et from"node:crypto";import*as bt from"node:readline";function P(o){if(o.inputSchema.type!=="object")throw new Error(`JSON schema for tool "${o.name}" must be an object, but got ${o.inputSchema.type}`);return{type:"custom",name:o.name,input_schema:o.inputSchema,description:o.description,run:o.run,parse:e=>e,...o.close?{close:o.close}:{}}}var W=L.promises,Z=448,Nt=384;function fe(o,e){let t=h.relative(o,e);return t===""||!t.startsWith(".."+h.sep)&&t!==".."&&!h.isAbsolute(t)}async function ke(o,e){for(let t of o)if(fe(await J(h.resolve(t)),e))return t}var Rt=40;function Q(o){let e=o?.code;return typeof e=="string"?e:void 0}async function J(o){let e=[],t=o,r=0;for(;;){let i;try{i=await W.realpath(t)}catch(n){let s;try{s=(await W.lstat(t)).isSymbolicLink()}catch(c){let l=Q(c);if(l!=="ENOENT"&&l!=="ENOTDIR")throw c;let f=h.dirname(t);if(f===t)throw c;e.push(h.basename(t)),t=f;continue}if(!s)throw n;if(++r>Rt)throw Object.assign(new Error("too many levels of symbolic links"),{code:"ELOOP"});t=h.resolve(h.dirname(t),await W.readlink(t));continue}return e.length?h.join(i,...e.reverse()):i}}async function Ke(o,e,t){let r=t?.allowedRoots??[],i=await J(h.resolve(o)),n;try{n=await J(h.resolve(i,e))}catch(c){throw new m(z(c,`path ${JSON.stringify(e)}`))}if(fe(i,n)||await ke(r,n)!==void 0)return n;let s=r.length?"the session's working directory and its other permitted directories":"the session's working directory";throw new m(`path ${JSON.stringify(e)} is outside ${s}`)}async function Ie(o,e){let t=h.dirname(o),r=h.join(t,`.tmp-${process.pid}-${C.randomUUID()}`),i=await W.stat(o).then(s=>s.mode&511,()=>{}),n;try{n=await W.open(r,"wx",Nt),i!==void 0&&await n.chmod(i),await n.writeFile(e,"utf-8"),await n.sync(),await n.close(),n=void 0,await W.rename(r,o)}catch(s){throw n&&await n.close().catch(()=>{}),await W.unlink(r).catch(()=>{}),s}}function z(o,e){let t=Q(o);switch(t){case"ENOENT":return`${e}: no such file or directory`;case"EACCES":case"EPERM":return`${e}: permission denied`;case"ENOTDIR":return`${e}: not a directory`;case"EISDIR":return`${e}: is a directory`;case"ELOOP":return`${e}: too many levels of symbolic links`;case"ENAMETOOLONG":return`${e}: file name too long`;case"ENOSPC":return`${e}: no space left on device`;case"EMFILE":case"ENFILE":return`${e}: too many open files`;default:return`${e}: ${t!==void 0?`i/o error (${t})`:"i/o error"}`}}var I=L.promises,Tt=Ye.promisify(Be.execFile);async function Lt(o){let{client:e,sessionId:t}=o;if(!e)return async()=>{};let r=ce(e),i=o.session;if(!i){if(t===void 0)return async()=>{};r.warn("AgentToolContext.sessionId is deprecated and costs an extra session fetch; fetch the session once and set `session` instead",{component:"agent-tool-context"}),i=await e.beta.sessions.retrieve(t)}let n=h.resolve(o.workdir,"skills"),s=[];for(let c of i.agent.skills)try{let l=await e.beta.skills.versions.retrieve(c.version,{skill_id:c.skill_id}),f=h.basename(l.name.trim());(f===""||f==="."||f==="..")&&(f=c.skill_id);let d=h.resolve(n,f);if(d!==n&&!d.startsWith(n+h.sep)){r.warn("skill name escapes the skills dir; skipping",{component:"agent-tool-context",name:l.name});continue}let y=await e.beta.skills.versions.download(l.id,{skill_id:c.skill_id});await I.rm(d,{recursive:!0,force:!0}),await I.mkdir(d,{recursive:!0,mode:Z}),s.push(d),await Je(y,d),r.info("downloaded skill",{component:"agent-tool-context",skill_id:c.skill_id,version:l.id,dest:d})}catch(l){r.warn("failed to download skill",{component:"agent-tool-context",skill_id:c.skill_id,error:String(l)})}return async()=>{for(let c of s)await I.rm(c,{recursive:!0,force:!0}).catch(l=>{r.warn("failed to clean up skill",{component:"agent-tool-context",dest:c,error:String(l)})})}}function $t(o){for(let e of o){let t=e.trim();if(t&&(h.isAbsolute(t)||t.split(/[\\/]/).includes("..")))throw new b(`refusing to extract unsafe archive member: ${t}`)}}var Re="skill archive listing is inconsistent; refusing to extract",At={unzip:new Set(["-","d","?"]),tar:new Set(["-","d","C"])};function Ve(o){let e=o.split(`
2
+ `);return e[e.length-1]===""&&e.pop(),e}function xt(o,e){return/^[\x20-\x7E]+$/.test(e)&&!/[\\^#]/.test(e)&&!(o==="unzip"&&e.startsWith("-"))}function Dt(o,e,t){let r=Ve(e),i=Ve(t);if(r.length!==i.length)throw new b(Re);let n=[],s=[];return r.forEach((c,l)=>{if(At[o].has(i[l].charAt(0))){n.push(c);return}if(!xt(o,c))throw new b(`refusing to extract archive: cannot safely exclude member ${JSON.stringify(c)}`);s.push(c)}),{plain:n,special:s}}async function Xe(o){for(let e of await I.readdir(o,{withFileTypes:!0}))if(e.isDirectory())await Xe(h.join(o,e.name));else if(!e.isFile())throw new b(Re)}async function Ne(o,e){try{let{stdout:t}=await Tt(o,e);return t}catch(t){throw Q(t)==="ENOENT"?new b(`skill extraction requires the \`${o}\` command, but it was not found on PATH`):t}}function Ft(o){let e,t=!1;for(let r of o){let i=r.trim().split("/").filter(s=>s!==""&&s!==".");if(i.length===0)continue;let n=i[0];if(e===void 0)e=n;else if(n!==e)return"";i.length>1&&(t=!0)}return e!==void 0&&t?e:""}async function Je(o,e){let t=h.join(e,`.skill-archive-${process.pid}-${Date.now()}`);if(!o.body)throw new b("skill download response had no body");await Me.promises.pipeline(Me.Readable.fromWeb(o.body),L.createWriteStream(t));let r=h.join(h.dirname(e),`.skill-stage-${process.pid}-${Date.now()}`),i=h.join(h.dirname(e),`.skill-exclude-${process.pid}-${Date.now()}`);try{let n=await Pt(t,4),s=n.length>=4&&n[0]===80&&n[1]===75&&n[2]===3&&n[3]===4,c=s?"unzip":"tar",l=await Ne(c,s?["-Z1",t]:["-tf",t]),f=await Ne(c,s?["-Z","--h","--t",t]:["-tvf",t]),{plain:d,special:y}=Dt(c,l,f);$t([...d,...y]);let E=Ft(d);await I.mkdir(r,{recursive:!0,mode:Z}),d.length>0&&await Ne(c,await Ct(c,t,r,y,i)),await Xe(r);let k=E?h.join(r,E):r,T=await I.readdir(k).catch(F=>{throw Q(F)==="ENOENT"?new b(Re):F});for(let F of T)await I.rename(h.join(k,F),h.join(e,F))}finally{await I.rm(t,{force:!0}),await I.rm(i,{force:!0}),await I.rm(r,{recursive:!0,force:!0})}}async function Ct(o,e,t,r,i){let n=r.map(s=>s.replace(/[*?[\\]/g,"\\$&"));return o==="unzip"?["-oq",e,"-d",t,...n.length>0?["-x",...n]:[]]:n.length===0?["-xf",e,"-C",t]:(await I.writeFile(i,n.join(`
3
+ `)+`
4
+ `,{flag:"wx",mode:384}),["-xf",e,"-C",t,"-X",i])}async function Pt(o,e){let t=await I.open(o,"r");try{let r=Buffer.alloc(e),{bytesRead:i}=await t.read(r,0,e,0);return r.subarray(0,i)}finally{await t.close()}}var S=L.promises,G=L.constants,tt=448,Wt=384,Ut=448,Le=G.O_NOFOLLOW??0,jt=G.O_NONBLOCK??0,w=(()=>{class o extends Error{constructor(t,r){super(`path ${JSON.stringify(r)} ${t}`),this.name="FileStoreError",this.reason=t,this.relPath=r}}return o.ESCAPES_ROOT="escapes the store root",o.IS_A_SYMLINK="is a symlink",o.NOT_A_FILE="is not a regular file",o.NOT_A_DIRECTORY="is not a directory",o.NOT_UTF8="is not valid utf-8",o.MOVE_DESTINATION_EXISTS="already exists",o})();function $e(o){return o.startsWith("/")&&!o.split("/").includes("..")}var Te=(()=>{class o{constructor(t,r,i=!1){this.hashes=new Map,this.rootPath=t,this.removedOnDispose=r,this.decoder=i?new TextDecoder("utf-8",{fatal:!0}):void 0}static async open(t,r){if(!Bt())throw new Error("FileStore requires O_NOFOLLOW support on this platform");let i=!1;try{await S.lstat(t)}catch(n){if(n.code!=="ENOENT")throw n;i=!0}return new o(h.resolve(t),i,r?.utf8??!1)}async createRoot(){await Yt(this.rootPath)}root(){return{path:this.rootPath,removedOnDispose:this.removedOnDispose}}async dispose(){this.removedOnDispose&&await S.rm(this.rootPath,{recursive:!0,force:!0})}async put(t,r,i){let n=t.replace(/\\/g,"/");if(n.endsWith("/")||n.endsWith("/.")||n===""||n===".")throw new w(w.NOT_A_FILE,t);let s=this.resolveUnderRoot(t),c=typeof r=="string"?qe(r):r;this.requireUtf8(t,c),await Ze(this.rootPath,h.dirname(s)),await qt(s,c,i?.executable??!1)}async get(t){let r=this.resolveUnderRoot(t),i;try{i=await rt(t,r)}catch(s){if(s.code==="ENOENT")return null;throw s}let n;try{let s=await i.readFile();n=new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}finally{await i.close()}return this.requireUtf8(t,n),n}async ls(t="/"){let r=this.resolveUnderRoot(t);return new Set((await Qe(this.rootPath,t,r)).map(([i])=>i))}async findSymlinks(t="/"){let r=this.resolveUnderRoot(t);return Gt(this.rootPath,t,r)}async hashtree(t="/"){let r=this.resolveUnderRoot(t),i=de.nowNs(),n=Object.create(null);for(let[s,c]of await Qe(this.rootPath,t,r)){let l=await this.hashViaCache(s,c,i);l!==null&&(n[s]=l)}return n}async hashFile(t){let r=this.resolveUnderRoot(t),i;try{i=await S.lstat(r,{bigint:!0})}catch(s){if(s.code==="ENOENT")return null;throw s}if(i.isSymbolicLink())throw new w(w.IS_A_SYMLINK,t);if(!i.isFile())throw new w(w.NOT_A_FILE,t);let n=h.relative(this.rootPath,r).split(h.sep).join("/");return this.hashViaCache(n,r,de.nowNs())}async move(t,r){let i=this.resolveUnderRoot(t),n=this.resolveUnderRoot(r);if(i===this.rootPath||n===this.rootPath)return;if(await S.stat(n).then(()=>!0,()=>!1))throw new w(w.MOVE_DESTINATION_EXISTS,r);await Ze(this.rootPath,h.dirname(n)),await S.rename(i,n)}async remove(t){let r=this.resolveUnderRoot(t);if(r===this.rootPath)return;let i;try{i=await S.lstat(r,{bigint:!0})}catch(n){if(n.code==="ENOENT")return;throw n}if(i.isDirectory())await S.rm(r,{recursive:!0,force:!0});else try{await S.unlink(r)}catch(n){if(n.code!=="ENOENT")throw n}}resolveUnderRoot(t){let r=t.replace(/\\/g,"/").replace(/^\/+/,""),i=r.split("/").filter(n=>n!==""&&n!==".");if(h.posix.isAbsolute(r)||i.includes(".."))throw new w(w.ESCAPES_ROOT,t);return i.length===0?this.rootPath:h.join(this.rootPath,...i)}requireUtf8(t,r){if(this.decoder)try{this.decoder.decode(r)}catch{throw new w(w.NOT_UTF8,t)}}async hashViaCache(t,r,i){let n;try{n=await S.lstat(r,{bigint:!0})}catch(l){if(l.code==="ENOENT")return null;throw l}if(!n.isFile())return null;let s=this.hashes.get(t),c;if(s!==void 0&&Kt(s,n))c=s.sha;else try{c=await de.hashFile(r)}catch(l){let f=l.code;if(f==="ENOENT"||l instanceof w||f==="ELOOP"||f==="EMLINK")return null;throw l}return Vt(n,i)&&this.hashes.set(t,{mtimeNs:n.mtimeNs,ctimeNs:n.ctimeNs,size:n.size,sha:c}),c}}return o.isPathLegal=$e,o})();function Bt(){return Le!==0}async function Yt(o){let e=[],t=o;for(;;){try{await S.stat(t);break}catch(i){let n=i.code;if(n!=="ENOENT"&&n!=="ENOTDIR"&&n!=="ELOOP")throw i}e.push(t);let r=h.dirname(t);if(r===t)break;t=r}for(let r of e.reverse())try{await S.mkdir(r,{mode:tt})}catch(i){if(i.code!=="EEXIST")throw i}}async function Ze(o,e){let t=h.relative(o,e);if(t==="")return;let r=o;for(let i of t.split(h.sep)){r=h.join(r,i);try{await S.mkdir(r,{mode:tt})}catch(n){if(n.code!=="EEXIST")throw n}}}async function qt(o,e,t){let r=t?Ut:Wt,i=h.join(h.dirname(o),`.fs-${C.randomBytes(8).toString("hex")}.tmp`),n;try{n=await S.open(i,G.O_WRONLY|G.O_CREAT|G.O_EXCL|Le,r),await n.writeFile(e),await n.close(),n=void 0,await S.rename(i,o)}catch(s){throw n&&await n.close().catch(()=>{}),await S.unlink(i).catch(()=>{}),s}}async function rt(o,e){let t;try{t=await S.open(e,G.O_RDONLY|Le|jt)}catch(r){let i=r.code;throw i==="ELOOP"||i==="EMLINK"?new w(w.IS_A_SYMLINK,o):r}try{if(!(await t.stat()).isFile())throw new w(w.NOT_A_FILE,o)}catch(r){throw await t.close().catch(()=>{}),r}return t}async function zt(o){let e=C.createHash("sha256"),t=await rt(h.basename(o),o),r=new Uint8Array(1024*1024);try{for(;;){let{bytesRead:i}=await t.read(r,0,r.length);if(i===0)break;e.update(r.subarray(0,i))}}finally{await t.close()}return e.digest("hex")}async function Qe(o,e,t){if(!await Ht(e,t))return[];let r=[];return await it(t,(i,n)=>{n.isFile()&&r.push([h.relative(o,i).split(h.sep).join("/"),i])}),r.sort(),r}async function Gt(o,e,t){let r=s=>h.relative(o,s).split(h.sep).join("/"),i;try{i=await S.lstat(t,{bigint:!0})}catch(s){let c=s.code;if(c==="ENOENT"||c==="ENOTDIR")return new Set;throw s}if(i.isSymbolicLink())return new Set([r(t)]);if(!i.isDirectory())throw new w(w.NOT_A_DIRECTORY,e);let n=new Set;return await it(t,(s,c)=>{c.isSymbolicLink()&&n.add(r(s))}),n}async function Ht(o,e){let t;try{t=await S.lstat(e,{bigint:!0})}catch(r){let i=r.code;if(i==="ENOENT"||i==="ENOTDIR")return!1;throw r}if(!t.isDirectory())throw new w(w.NOT_A_DIRECTORY,o);return!0}async function it(o,e){let t=[o];for(;t.length;){let r=t.pop(),i;try{i=await S.readdir(r,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")continue;throw n}for(let n of i){let s=h.join(r,n.name);e(s,n),n.isDirectory()&&!n.isSymbolicLink()&&t.push(s)}}}function Kt(o,e){return e.mtimeNs===o.mtimeNs&&e.ctimeNs===o.ctimeNs&&e.size===o.size}function Vt(o,e){return(o.mtimeNs>o.ctimeNs?o.mtimeNs:o.ctimeNs)<e-de.timestampTrustMarginNs}var Xt=2000000000n,de={hashFile:zt,timestampTrustMarginNs:Xt,nowNs:()=>BigInt(Date.now())*1000000n},nt=Te,et=Symbol.asyncDispose;et&&Object.defineProperty(Te.prototype,et,{value:Te.prototype.dispose,configurable:!0,writable:!0});var _,A,ye,ee,we,p,H,ue,$,ht,pe,mt,ut,Ae,De,ot,st,xe,at,ct,he,me,lt,ft,Jt=3e4,K=".anthropic-memory-store",pt=1;function dt(o){return C.createHash("sha256").update(`version ${pt}
5
+ ${o}`,"utf-8").digest("hex")}var Zt=3e4,Qt=100,er=20,tr=16,rr=32,ir=8,nr=50,x=class extends b{constructor(e,t){super(e),this.name="SessionMemoryError",t!==void 0&&(this.cause=t)}},Fe=class{constructor(e,t,r){this.mode=e,this.cap=t,this.waiveWindow=r,this.attempted=0,this.capped=0,this.suppressed=0}takeSlot(){return this.attempted>=this.cap?(this.capped++,!1):(this.attempted++,!0)}},Ce=class{constructor(e,t){_.add(this),A.set(this,void 0),ye.set(this,void 0),ee.set(this,void 0),we.set(this,void 0),p.set(this,void 0),H.set(this,void 0),ue.set(this,!1),$.set(this,[]),u(this,A,e,"f"),u(this,ye,t.workdir,"f"),u(this,ee,t.syncIntervalMs??le,"f"),He(a(this,ee,"f"),"syncIntervalMs"),u(this,we,t.syncDeletions??"enabled","f"),u(this,p,ce(e),"f"),u(this,H,Date.now(),"f")}get roots(){return a(this,$,"f").map(e=>e.files.root().path)}get readOnlyRoots(){return a(this,$,"f").filter(e=>e.readOnly).map(e=>e.files.root().path)}async download(e){for(let t of e.resources){if(t.type!=="memory_store")continue;let r=a(this,_,"m",ht).call(this,t),i;try{if(i={memoryStoreId:t.memory_store_id,files:await nt.open(r,{utf8:!0}),readOnly:t.access==="read_only",baseline:new Map,refusedShas:new Map,pendingDeletes:new Map},!i.files.root().removedOnDispose)throw new x(`something already exists at the memory store's path: ${r} (memory_store_id=${t.memory_store_id}); it must not exist when the session starts`);try{await i.files.createRoot()}catch(n){throw V(n)?new x(`cannot create the memory store's folder: ${r} (memory_store_id=${t.memory_store_id}): ${n}; the worker host must make this mount path writable`,n):n}await a(this,_,"m",De).call(this,i),a(this,p,"f").info("downloaded memories",{count:i.baseline.size,memory_store_id:i.memoryStoreId,dest:i.files.root().path}),a(this,$,"f").push(i)}catch(n){throw i&&await i.files.dispose().catch(()=>{}),n instanceof x?n:new x(`failed to download memory store memory_store_id=${t.memory_store_id}: ${n}`,n)}}u(this,H,Date.now(),"f")}async finish(){if(a(this,ue,"f"))throw new b("finish() was already called: it is the session's last sync and runs once");u(this,ue,!0,"f"),await this.syncAll(!0)}async syncAll(e){await Promise.all(a(this,$,"f").map(t=>a(this,_,"m",mt).call(this,t,e))),u(this,H,Date.now(),"f")}async syncIfDue(){Date.now()-a(this,H,"f")<a(this,ee,"f")||await this.syncAll(!1)}async flushWrites(e){await Promise.all(a(this,$,"f").map(t=>a(this,_,"m",ut).call(this,t,e)))}async dispose(){for(let e of a(this,$,"f")){let t=e.files.root();try{let r=await a(this,_,"m",pe).call(this,e);if(!r.markerOk&&Object.keys(r.files).length>0){a(this,p,"f").warn(`${r.distrustReason}; leaving the memory store folder on disk`,{root:t.path,memory_store_id:e.memoryStoreId});continue}await e.files.dispose()}catch(r){if(!(r instanceof w)&&!V(r))throw r;a(this,p,"f").warn("failed to remove the memory store folder",{root:e.files.root().path,memory_store_id:e.memoryStoreId,error:String(r)});continue}t.removedOnDispose&&a(this,p,"f").info("removed memory store dir",{dest:t.path,memory_store_id:e.memoryStoreId})}}};A=new WeakMap,ye=new WeakMap,ee=new WeakMap,we=new WeakMap,p=new WeakMap,H=new WeakMap,ue=new WeakMap,$=new WeakMap,_=new WeakSet,ht=function(e){if(e.mount_path){if(!$e(e.mount_path))throw new x(`memory store mount_path is not a clean absolute path: ${JSON.stringify(e.mount_path)} (memory_store_id=${e.memory_store_id})`);return e.mount_path}return h.join(a(this,ye,"f"),"memory",e.name||e.memory_store_id)},pe=async function(e){let t=await e.files.hashtree(),r=t[K];return delete t[K],r===dt(e.memoryStoreId)?{files:t,markerOk:!0,distrustReason:null}:{files:t,markerOk:!1,distrustReason:r!==void 0?"the marker file does not match this store":"the marker file is gone"}},mt=async function(e,t){try{let r=await a(this,_,"m",pe).call(this,e),i=r.files;if(!r.markerOk){if(Object.keys(i).length>0){a(this,p,"f").warn(`${r.distrustReason}; leaving the memory store folder as found and not syncing`,{root:e.files.root().path,memory_store_id:e.memoryStoreId});return}await a(this,_,"m",Ae).call(this,e,"the folder or its marker is gone");return}if(Object.keys(i).length===0&&e.baseline.size>1){await a(this,_,"m",Ae).call(this,e,"every memory file is gone at once");return}let n=new Map;for await(let[d,y]of a(this,_,"m",he).call(this,e.memoryStoreId))n.set(d,y);let s=new Fe(a(this,we,"f"),Math.max(ir,Math.min(nr,Math.floor(e.baseline.size/4))),t),c=[],l=new Map,f=[...new Set([...n.keys(),...Object.keys(i),...e.baseline.keys()])].sort();for(let d of f){let y=n.get(d),E=i[d],k=e.baseline.get(d),T;E===void 0&&k!==void 0&&y!==void 0&&y.content_sha256===k&&!e.readOnly?T=await a(this,_,"m",lt).call(this,e,d,y,k,s):T=await a(this,_,"m",ot).call(this,e,d,y,E,c),T!==void 0&&l.set(d,T)}e.baseline=l,await a(this,_,"m",at).call(this,e,c),s.suppressed>0&&a(this,p,"f").debug("remote deletes are disabled; locally deleted memories stay on the server",{count:s.suppressed,memory_store_id:e.memoryStoreId}),s.capped>0&&a(this,p,"f").warn(`delete cap reached: ${s.mode==="log_only"?"would send":"sent"} ${s.attempted} deletes, held ${s.capped} for later syncs`,{memory_store_id:e.memoryStoreId})}catch(r){a(this,p,"f").warn("memory sync failed",{memory_store_id:e.memoryStoreId,error:String(r)})}},ut=async function(e,t){let r=new Map,i=new Set,n=async()=>{if(e.readOnly)return;let s=await a(this,_,"m",pe).call(this,e);if(!s.markerOk){a(this,p,"f").warn(`${s.distrustReason}; not uploading anything from the memory store folder`,{root:e.files.root().path,memory_store_id:e.memoryStoreId});return}for(let[f,d]of Object.entries(s.files))d!==e.baseline.get(f)&&e.refusedShas.get(f)!==d&&(r.set(f,d),i.add(f));if(r.size===0||t?.aborted)return;let c=new Map;for await(let[f,d]of a(this,_,"m",he).call(this,e.memoryStoreId)){if(t?.aborted)return;c.set(f,d)}let l=[];for(let f of[...r.keys()].sort()){let d=r.get(f),y=e.baseline.get(f),E=c.get(f);if(E!==void 0&&E.content_sha256===d){e.baseline.set(f,E.content_sha256),i.delete(f);continue}if(E!==void 0&&E.content_sha256!==y){a(this,p,"f").warn("memory changed both locally and remotely; the flush leaves the remote version",{path:f,memory_store_id:e.memoryStoreId}),i.delete(f);continue}l.push([f,d,E])}await a(this,_,"m",ct).call(this,e,l,i,t)};try{await or(n(),t),t?.aborted&&i.size>0&&a(this,p,"f").warn(`memory flush cut off part-way; ${i.size} of ${r.size} changed files had not finished uploading`,{memory_store_id:e.memoryStoreId})}catch(s){a(this,p,"f").warn("memory flush failed",{memory_store_id:e.memoryStoreId,error:String(s)})}},Ae=async function(e,t){a(this,p,"f").warn(`${t}; re-downloading the memory store folder instead of syncing`,{root:e.files.root().path,memory_store_id:e.memoryStoreId}),await e.files.createRoot(),await a(this,_,"m",De).call(this,e)},De=async function(e){e.baseline=new Map,e.pendingDeletes.clear(),await e.files.put(K,`version ${pt}
6
+ ${e.memoryStoreId}`);for await(let[t,r]of a(this,_,"m",he).call(this,e.memoryStoreId,"full"))await a(this,_,"m",xe).call(this,e,t,r.content??"")&&e.baseline.set(t,r.content_sha256)},ot=async function(e,t,r,i,n){let s=e.baseline.get(t);if(i!==void 0&&e.pendingDeletes.delete(t),!r){if(i===void 0){e.pendingDeletes.delete(t);return}if(s!==void 0){if(i===s){let y=await a(this,_,"m",st).call(this,e,t,s);if(y===void 0)return;if(y===s)return s;i=y}e.readOnly?a(this,p,"f").warn("memory deleted remotely but edited locally; keeping the file, which a read-only store cannot push",{path:t,memory_store_id:e.memoryStoreId}):e.refusedShas.get(t)!==i&&a(this,p,"f").info("memory deleted remotely but edited locally; re-creating it from the file",{path:t,memory_store_id:e.memoryStoreId})}return e.readOnly||e.refusedShas.get(t)===i?void 0:await a(this,_,"m",me).call(this,e,t,i,void 0)}let c=r.content_sha256,l=c!==s,f=i!==void 0&&i!==s&&i!==c,d=!e.readOnly&&f;return i===void 0&&s!==void 0?(l&&(a(this,p,"f").warn("memory deleted locally but changed remotely; restoring the remote version",{path:t,memory_store_id:e.memoryStoreId}),e.pendingDeletes.delete(t),n.push([t,r])),s):l?i===c?c:(f&&a(this,p,"f").warn("memory changed both locally and remotely; keeping the remote version",{path:t,memory_store_id:e.memoryStoreId}),n.push([t,r]),s):d?e.refusedShas.get(t)===i?c:await a(this,_,"m",me).call(this,e,t,i,r)??c:c},st=async function(e,t,r){let i;try{i=await e.files.hashFile(t)}catch(n){if(!(n instanceof w)&&!V(n))throw n;return r}if(i!==null){if(i!==r)return i;try{await e.files.remove(t)}catch(n){if(!(n instanceof w)&&!V(n))throw n;return a(this,p,"f").warn("failed to remove memory deleted remotely",{path:t,memory_store_id:e.memoryStoreId,error:String(n)}),r}}},xe=async function(e,t,r){try{await e.files.put(t,r)}catch(i){if(!(i instanceof w)&&!V(i))throw i;return a(this,p,"f").warn("failed to write memory",{path:t,memory_store_id:e.memoryStoreId,error:String(i)}),!1}return!0},at=async function(e,t){if(t.length===0)return;let r=async(s,c)=>{let l;try{l=await a(this,A,"f").beta.memoryStores.memories.retrieve(c.id,{memory_store_id:e.memoryStoreId,view:"full"})}catch(f){if(R(f,404))return;a(this,p,"f").warn("failed to fetch memory content",{path:s,memory_store_id:e.memoryStoreId,error:String(f)});return}await a(this,_,"m",xe).call(this,e,s,l.content??"")&&e.baseline.set(s,l.content_sha256)},i=t[Symbol.iterator](),n=async()=>{for(let[s,c]of i)await r(s,c)};await Promise.all(Array.from({length:Math.min(tr,t.length)},n))},ct=async function(e,t,r,i){let n=t[Symbol.iterator](),s=async()=>{for(let[c,l,f]of n){if(i?.aborted)return;let d=await a(this,_,"m",me).call(this,e,c,l,f);r.delete(c),d!==void 0&&e.baseline.set(c,d)}};await Promise.all(Array.from({length:Math.min(rr,t.length)},s))},he=async function*(e,t="basic"){let r=t==="basic"?Qt:er;for await(let i of a(this,A,"f").beta.memoryStores.memories.list(e,{view:t,limit:r})){if(i.type!=="memory")continue;let n=i.path.replace(/^\/+/,"");if(n===K){a(this,p,"f").warn("the server listed the reserved marker path; skipping",{path:i.path,memory_store_id:e});continue}yield[n,i]}},me=async function o(e,t,r,i){try{let n=await e.files.get(t);if(n===null)return;let s=ze(n),c=i?await a(this,A,"f").beta.memoryStores.memories.update(i.id,{memory_store_id:e.memoryStoreId,content:s,precondition:{type:"content_sha256",content_sha256:i.content_sha256}}):await a(this,A,"f").beta.memoryStores.memories.create(e.memoryStoreId,{path:"/"+t,content:s});return e.refusedShas.delete(t),c.content_sha256}catch(n){if(i&&R(n,404))return await a(this,_,"m",o).call(this,e,t,r,void 0);let s=n instanceof w||R(n,400)||R(n,413);i&&R(n,409)?a(this,p,"f").warn("memory changed both locally and remotely; the upload was refused and the local edit loses",{path:t,memory_store_id:e.memoryStoreId}):s&&r!==void 0?(e.refusedShas.set(t,r),a(this,p,"f").warn("the server rejected this memory file, so it stays un-synced until its content changes",{path:t,memory_store_id:e.memoryStoreId,rejection:String(n)})):a(this,p,"f").warn("failed to upload memory",{path:t,memory_store_id:e.memoryStoreId,error:String(n)});return}},lt=async function(e,t,r,i,n){if(n.mode==="disabled")return n.suppressed++,i;let s=e.pendingDeletes.get(t);if(s===void 0&&(s=Date.now(),e.pendingDeletes.set(t,s)),!n.waiveWindow&&Date.now()-s<Zt)return i;let c,l;try{c=await e.files.hashFile(K)===dt(e.memoryStoreId),l=await e.files.hashFile(t)===null}catch(d){if(!(d instanceof w)&&!V(d))throw d;c=l=!1}if(!c)return i;if(!l)return e.pendingDeletes.delete(t),i;if(!n.takeSlot())return i;if(n.mode==="log_only")return a(this,p,"f").info("log-only: sync would delete this memory on the server",{path:t,memory_store_id:e.memoryStoreId}),i;let f=await a(this,_,"m",ft).call(this,e,t,r,i);return f===void 0&&e.pendingDeletes.delete(t),f},ft=async function(e,t,r,i){try{await a(this,A,"f").beta.memoryStores.memories.delete(r.id,{memory_store_id:e.memoryStoreId,expected_content_sha256:i})}catch(n){return R(n,404)?void 0:(R(n,409)||R(n,412)?a(this,p,"f").warn("memory deleted locally but changed remotely; keeping the remote version",{path:t,memory_store_id:e.memoryStoreId}):a(this,p,"f").warn("failed to delete memory",{path:t,memory_store_id:e.memoryStoreId,error:String(n)}),i)}a(this,p,"f").info("propagated local deletion",{path:t,memory_store_id:e.memoryStoreId})};function V(o){return typeof o=="object"&&o!==null&&typeof o.code=="string"}async function or(o,e){if(!e){await o;return}let t,r=new Promise(i=>{t=i,e.aborted&&i()});e.addEventListener("abort",t,{once:!0});try{await Promise.race([o,r])}finally{e.removeEventListener("abort",t)}}var _e,O,v,te,U,N,Pe,Se,re,ge,Ee,B,Y,X,j,ie,D,gt,yt,wt=100*1024,Ot=12e4,sr=256*1024,ar=64*1024,_t=Buffer.from(`
7
+ `),ne=100*1024,cr=2e3,lr=200,We=class extends b{constructor(e){super(`bash command timed out after ${e}ms`),this.name="BashTimeoutError",this.timeoutMs=e}},fr=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,dr=g.glob;function Mt(o){return o===void 0?sr:o}function q(o){if(o!==void 0)throw new b("The `unrestrictedPaths` option you passed to the agent toolset (AgentToolContext) is no longer supported. The toolset's file tools (read, write, edit, glob, grep) are now always confined to the working directory plus the directories listed in `allowedRoots`. Remove `unrestrictedPaths` from your context; to let the file tools reach any other directory, add it to `allowedRoots`.")}function ti(o){return[ur(o),pr(o),wr(o),_r(o),gr(o),Er(o)]}async function se(o,e){return q(o.unrestrictedPaths),Ke(o.workdir,e,{allowedRoots:o.allowedRoots??[]})}function vt(o,e){return ke(o.readOnlyRoots??[],e)}function hr(){let o={};for(let[e,t]of Object.entries(process.env))e.startsWith("ANTHROPIC_")||(o[e]=t);return o}var mr=(()=>{class o{constructor(t,r=hr()){_e.add(this),O.set(this,void 0),v.set(this,""),te.set(this,!1),U.set(this,!1),N.set(this,null),u(this,O,je.spawn("/bin/bash",["--noprofile","--norc"],{cwd:t,env:{...r,PS1:"",PS2:"",TERM:"dumb"},stdio:["pipe","pipe","pipe"],detached:!0}),"f"),a(this,O,"f").stdout.setEncoding("utf8"),a(this,O,"f").stderr.setEncoding("utf8"),a(this,O,"f").stdout.on("data",i=>a(this,_e,"m",Pe).call(this,i)),a(this,O,"f").stderr.on("data",i=>a(this,_e,"m",Pe).call(this,i)),a(this,O,"f").once("close",()=>{u(this,U,!0,"f");let i=a(this,N,"f");u(this,N,null,"f"),i?.resolve()})}get closed(){return a(this,U,"f")}async exec(t,r={}){if(a(this,U,"f"))throw new b("bash session terminated");let i=r.timeoutMs??Ot,n=r.signal;n?.throwIfAborted(),u(this,v,"","f"),u(this,te,!1,"f");let s=`__ANT_CMD_${Et.randomUUID()}_DONE__`,c=`${s.slice(0,8)}''${s.slice(8)}`,l=`{ ${t}
8
+ } </dev/null 2>&1; printf '\\n${c}%d\\n' $?
9
+ `;if(a(this,O,"f").stdin.write(l),a(this,v,"f").indexOf(s)<0){let{promise:T,resolve:F}=ve();u(this,N,{sentinel:s,resolve:F},"f");let be,ae;try{await Promise.race([T,new Promise((It,Oe)=>{be=setTimeout(()=>Oe(new We(i)),i)}),new Promise((It,Oe)=>{n&&(ae=()=>Oe(n.reason),n.addEventListener("abort",ae,{once:!0}))})])}finally{be&&clearTimeout(be),ae&&n&&n.removeEventListener("abort",ae),u(this,N,null,"f")}}let f=a(this,v,"f").indexOf(s);if(f<0)throw new b("bash session terminated");let y=a(this,v,"f").slice(f+s.length).match(/^(-?\d+)/),E=y?parseInt(y[1],10):-1,k=a(this,v,"f").slice(0,f).replace(fr,"").replace(/\n+$/,"");return a(this,te,"f")&&(k=`[output truncated]
10
+ ${k}`),{output:k,exitCode:E}}close(){if(a(this,U,"f"))return;u(this,U,!0,"f");let t=a(this,N,"f");u(this,N,null,"f"),t?.resolve(),a(this,O,"f").stdout.destroy(),a(this,O,"f").stderr.destroy(),a(this,O,"f").stdin.destroy();try{process.kill(-a(this,O,"f").pid,"SIGKILL")}catch{a(this,O,"f").kill("SIGKILL")}a(this,O,"f").unref()}}return O=new WeakMap,v=new WeakMap,te=new WeakMap,U=new WeakMap,N=new WeakMap,_e=new WeakSet,Pe=function(t){if(u(this,v,a(this,v,"f")+t,"f"),a(this,v,"f").length>wt&&(u(this,v,a(this,v,"f").slice(a(this,v,"f").length-wt),"f"),u(this,te,!0,"f")),a(this,N,"f")&&a(this,v,"f").indexOf(a(this,N,"f").sentinel)>=0){let r=a(this,N,"f");u(this,N,null,"f"),r.resolve()}},o})();function ur(o){q(o.unrestrictedPaths);let e,t=Promise.resolve();return P({name:"bash",description:"Run a bash command in a persistent shell. State (cwd, env vars) persists across calls.",inputSchema:{type:"object",properties:{command:{type:"string",description:"The command to run"},restart:{type:"boolean",description:"Restart the persistent shell before running"},timeout_ms:{type:"integer",description:"Per-call timeout in milliseconds"}}},run:async({command:r,restart:i,timeout_ms:n},s)=>{let c=t,l=ve();t=l.promise;try{await c}catch{}try{if(i&&(e?.close(),e=void 0),!r){if(i)return"bash session restarted";throw new m("bash: command is required")}e??(e=new mr(o.workdir,o.env));try{let{output:f,exitCode:d}=await e.exec(r,{timeoutMs:n??Ot,signal:s?.signal});if(d!==0)throw new m(f||`exit ${d}`);return f}catch(f){throw f instanceof m?f:(e.close(),e=void 0,new m(`bash: ${f instanceof Error?f.message:String(f)}`))}}finally{l.resolve()}},close:()=>{e?.close(),e=void 0}})}function pr(o){return q(o.unrestrictedPaths),P({name:"read",description:"Read a UTF-8 text file relative to the workdir.",inputSchema:{type:"object",properties:{file_path:{type:"string"},view_range:{type:"array",items:{type:"integer"},description:"[start_line, end_line] 1-indexed inclusive"}},required:["file_path"]},run:async({file_path:e,view_range:t})=>{if(!e)throw new m("read: file_path is required");let r=await se(o,e);if(t?.length&&t.length!==2)throw new m("read: view_range must be [start_line, end_line]");let i;try{let d=await g.stat(r);if(!d.isFile())throw new m(`read: ${e} is not a regular file`);let y=Mt(o.maxFileBytes);if(y!==null&&d.size>y){if(!t?.length)throw new m(`read: ${e} is ${d.size} bytes, exceeds ${y}-byte limit. Use the view_range parameter to read specific line ranges, e.g. view_range: [1, 500].`);let[E,k]=t;return await yr(r,e,E,k,y)}i=await g.readFile(r,"utf8")}catch(d){throw d instanceof m?d:new m(`read: ${z(d,e)}`)}if(!t?.length)return i;let[n,s]=t,c=i.split(`
11
+ `),l=Math.max(0,n-1),f=s>0?s:c.length;return c.slice(l,f).join(`
12
+ `)}})}async function yr(o,e,t,r,i){let n=new Ue(e,t,r,i);if(n.rangeIsEmpty())return"";let s=oe.createReadStream(o,{highWaterMark:ar});try{for await(let c of s)if(n.collectFrom(c),n.rangeIsCollected())break}finally{s.destroy()}return n.text()}var Ue=class{constructor(e,t,r,i){Se.add(this),re.set(this,void 0),ge.set(this,void 0),Ee.set(this,void 0),B.set(this,void 0),Y.set(this,void 0),X.set(this,void 0),j.set(this,0),ie.set(this,[]),D.set(this,0),u(this,re,e,"f"),u(this,ge,t,"f"),u(this,Ee,r,"f"),u(this,B,Math.max(0,t-1),"f"),u(this,Y,r>0?r:1/0,"f"),u(this,X,i,"f")}rangeIsEmpty(){return a(this,Y,"f")<=a(this,B,"f")}rangeIsCollected(){return a(this,j,"f")>=a(this,Y,"f")}collectFrom(e){var t;let r=0;for(;r<e.length&&!this.rangeIsCollected();){let i=e.indexOf(10,r),n=i<0?e.length:i;if(a(this,j,"f")>=a(this,B,"f")&&a(this,Se,"m",gt).call(this,e.subarray(r,n),i>=0),i<0)break;u(this,j,(t=a(this,j,"f"),t++,t),"f"),r=i+1}}text(){return Buffer.concat(a(this,ie,"f"),a(this,D,"f")).toString("utf8")}};re=new WeakMap,ge=new WeakMap,Ee=new WeakMap,B=new WeakMap,Y=new WeakMap,X=new WeakMap,j=new WeakMap,ie=new WeakMap,D=new WeakMap,Se=new WeakSet,gt=function(e,t){if(a(this,ie,"f").push(e),u(this,D,a(this,D,"f")+e.length,"f"),t&&a(this,j,"f")+1<a(this,Y,"f")&&(a(this,ie,"f").push(_t),u(this,D,a(this,D,"f")+_t.length,"f")),a(this,D,"f")>a(this,X,"f"))throw a(this,Se,"m",yt).call(this)},yt=function(){return a(this,Y,"f")-a(this,B,"f")===1?new m(`read: line ${a(this,B,"f")+1} of ${a(this,re,"f")} alone exceeds ${a(this,X,"f")}-byte limit. The read tool cannot return part of a line, so view_range cannot narrow this further.`):new m(`read: view_range [${a(this,ge,"f")}, ${a(this,Ee,"f")}] of ${a(this,re,"f")} exceeds ${a(this,X,"f")}-byte limit. Narrow the view_range to read a smaller portion.`)};function wr(o){return q(o.unrestrictedPaths),P({name:"write",description:"Write a UTF-8 text file relative to the workdir, creating parent directories as needed.",inputSchema:{type:"object",properties:{file_path:{type:"string"},content:{type:"string"}},required:["file_path","content"]},run:async({file_path:e,content:t})=>{if(!e)throw new m("write: file_path is required");let r=await se(o,e),i=await vt(o,r);if(i!==void 0)throw new m(`write: ${e} is inside read-only directory ${i}`);try{await g.mkdir(M.dirname(r),{recursive:!0,mode:Z}),await Ie(r,t??"")}catch(n){throw new m(`write: ${z(n,e)}`)}return`wrote ${Buffer.byteLength(t??"")} bytes to ${e}`}})}function _r(o){return q(o.unrestrictedPaths),P({name:"edit",description:"Replace old_string with new_string in a file. old_string must be unique unless replace_all.",inputSchema:{type:"object",properties:{file_path:{type:"string"},old_string:{type:"string"},new_string:{type:"string"},replace_all:{type:"boolean"}},required:["file_path","old_string","new_string"]},run:async({file_path:e,old_string:t,new_string:r,replace_all:i})=>{if(!e)throw new m("edit: file_path is required");if(!t)throw new m("edit: old_string is required");let n=await se(o,e),s=await vt(o,n);if(s!==void 0)throw new m(`edit: ${e} is inside read-only directory ${s}`);let c;try{let d=await g.stat(n);if(!d.isFile())throw new m(`edit: ${e} is not a regular file`);let y=Mt(o.maxFileBytes);if(y!==null&&d.size>y)throw new m(`edit: ${e} is ${d.size} bytes, exceeds ${y}-byte limit. The edit tool loads the whole file and cannot modify a file this large.`);c=await g.readFile(n,"utf8")}catch(d){throw d instanceof m?d:new m(`edit: ${z(d,e)}`)}let l=c.split(t).length-1;if(l===0)throw new m(`edit: old_string not found in ${e}`);let f;if(i)f=c.split(t).join(r);else{if(l>1)throw new m(`edit: old_string appears ${l} times in ${e} (must be unique)`);f=c.replace(t,()=>r)}try{await Ie(n,f)}catch(d){throw new m(`edit: write: ${z(d,e)}`)}return`edited ${e} (${i?l:1} replacement(s))`}})}function Sr(o){return o.split(/[\\/{},]/).includes("..")}function gr(o){return q(o.unrestrictedPaths),P({name:"glob",description:"Match files under the workdir against a glob pattern. Results are mtime-sorted, newest first.",inputSchema:{type:"object",properties:{pattern:{type:"string"},path:{type:"string",description:"Directory to search in. Defaults to the workdir."}},required:["pattern"]},run:async({pattern:e,path:t})=>{if(!e)throw new m("glob: pattern is required");if(M.isAbsolute(e))throw new m("glob: absolute pattern not permitted; pass a relative pattern (and optionally path)");if(Sr(e))throw new m('glob: ".." is not permitted in the pattern');let r=t?await se(o,t):M.resolve(o.workdir),i=t?r:await J(r),n=[],s=kt;try{for await(let c of dr(e,{cwd:r,withFileTypes:!0,exclude:l=>l.name===".git"||l.name==="node_modules"})){if(s--<=0)break;if(!c.isFile())continue;let l=M.join(c.parentPath,c.name),f;try{f=await g.realpath(l)}catch{continue}if(!fe(i,f))continue;let d=0;try{d=(await g.stat(l)).mtimeMs}catch{}n.push({path:l,mtime:d})}}catch(c){throw new m(`glob: ${c instanceof Error?c.message:String(c)}`)}return n.length===0?"no matches":(n.sort((c,l)=>l.mtime-c.mtime),n.slice(0,lr).map(c=>c.path).join(`
13
+ `))}})}function Er(o){return q(o.unrestrictedPaths),P({name:"grep",description:"Search file contents for a regex. Uses ripgrep if available, otherwise a built-in walker.",inputSchema:{type:"object",properties:{pattern:{type:"string"},path:{type:"string"}},required:["pattern"]},run:async({pattern:e,path:t},r)=>{if(!e)throw new m("grep: pattern is required");let i=M.resolve(o.workdir);t&&(i=await se(o,t));let n=await kr();return n?br(n,e,i,r?.signal):Or(e,i,r?.signal)}})}function br(o,e,t,r){return new Promise((i,n)=>{let s=je.spawn(o,["-n","--no-heading","-e",e,"--",t],{...r?{signal:r}:{}}),c="",l="",f=!1;s.stdout.on("data",d=>{f||(c+=d,c.length>ne&&(f=!0,c=c.slice(0,ne),s.kill("SIGKILL")))}),s.stderr.on("data",d=>l+=d),s.on("close",d=>{if(r?.aborted)return n(new m("grep: aborted"));if(f)return i(c+`
14
+ [output truncated at ${ne} bytes]`);if(d===0)return i(c);if(d===1)return i("no matches");n(new m(`grep: rg failed: ${l||`exit ${d}`}`))}),s.on("error",d=>{if(r?.aborted)return n(new m("grep: aborted"));n(new m(`grep: rg failed: ${d.message}`))})})}async function Or(o,e,t){let r;try{r=new RegExp(o)}catch(l){throw new m(`grep: invalid regex: ${l instanceof Error?l.message:String(l)}`)}let i=[],n=ne,s=l=>(n-=l.length+1,n<0?(i.push(`[output truncated at ${ne} bytes]`),!1):(i.push(l),!0));if((await g.stat(e).catch(()=>null))?.isFile()?await St(e,r,s):await vr(e,"",l=>St(M.join(e,l),r,s),t),t?.aborted)throw new m("grep: aborted");return i.length===0?"no matches":i.join(`
15
+ `)}async function St(o,e,t){let r=oe.createReadStream(o,{encoding:"utf8"}),i=bt.createInterface({input:r,crlfDelay:1/0}),n=0;try{for await(let s of i)if(n++,!(s.length>cr)&&e.test(s)&&!t(`${o}:${n}:${s}`))return!1}catch{}finally{r.destroy()}return!0}var Mr=40,kt=5e4;async function vr(o,e,t,r){let i=kt;async function n(s,c){if(c>Mr)return!0;if(r?.aborted)return!1;let l;try{l=await g.readdir(M.join(o,s),{withFileTypes:!0})}catch{return!0}for(let f of l){if(f.name===".git"||f.name==="node_modules")continue;if(i--<=0||r?.aborted)return!1;let d=s?M.join(s,f.name):f.name;if(f.isDirectory()){if(!await n(d,c+1))return!1}else if(f.isFile()&&await t(d)===!1)return!1}return!0}await n(e,0)}async function kr(){let o=(process.env.PATH??"").split(M.delimiter);for(let e of o){let t=M.join(e,"rg");try{return await g.access(t,oe.constants.X_OK),t}catch{}}return null}export{mr as BashSession,We as BashTimeoutError,le as DEFAULT_MEMORY_SYNC_INTERVAL_MS,K as MARKER_PATH,Jt as MEMORY_FLUSH_TIMEOUT_MS,Ge as MIN_MEMORY_SYNC_INTERVAL_MS,x as SessionMemoryError,Ce as SessionMemoryStores,ti as betaAgentToolset20260401,ur as betaBashTool,_r as betaEditTool,gr as betaGlobTool,Er as betaGrepTool,pr as betaReadTool,wr as betaWriteTool,Je as extractSkillArchive,se as resolvePath,Lt as setupSkills};