pi-agent-ide 1.0.0 → 1.0.1

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 (121) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/{chunk-LG22ELG4.js → chunk-26SMC6OS.js} +1 -1
  3. package/dist/{chunk-QC6VFZSB.js → chunk-3BRGWFEI.js} +1 -1
  4. package/dist/chunk-3JBQYLJ4.js +5 -0
  5. package/dist/{chunk-LRAMFOUP.js → chunk-3KM5DSWL.js} +1 -1
  6. package/dist/{chunk-FVWMI4GP.js → chunk-7OAAM5FL.js} +1 -1
  7. package/dist/{chunk-X4CU7CMR.js → chunk-C327T6YP.js} +1 -1
  8. package/dist/{chunk-WZ7MNISG.js → chunk-KM4NOIOB.js} +1 -1
  9. package/dist/{chunk-NGWQRV25.js → chunk-L2YDUMZC.js} +1 -1
  10. package/dist/chunk-MCHU3BLO.js +53 -0
  11. package/dist/{chunk-AKUBFJAR.js → chunk-NSBRKTZ7.js} +1 -1
  12. package/dist/{chunk-SKHD2QIT.js → chunk-QUK5ZEYX.js} +1 -1
  13. package/dist/{chunk-E6G3UVS7.js → chunk-RYJEEBET.js} +1 -1
  14. package/dist/chunk-UN3XLVPR.js +18 -0
  15. package/dist/{chunk-KJ6HZC6L.js → chunk-VQ2RA43A.js} +1 -1
  16. package/dist/{chunk-HUICUICD.js → chunk-VWYI4WF7.js} +1 -1
  17. package/dist/{chunk-UHGHVYAW.js → chunk-W25HNEMR.js} +1 -1
  18. package/dist/entry-0.js +1 -1
  19. package/dist/entry-20.js +1 -1
  20. package/dist/entry-38.js +1 -1
  21. package/dist/entry-44.js +1 -1
  22. package/dist/entry-57.js +1 -1
  23. package/dist/entry-58.js +1 -1
  24. package/dist/entry-59.js +1 -1
  25. package/dist/entry-60.js +1 -1
  26. package/dist/entry-61.js +1 -1
  27. package/dist/entry-62.js +1 -1
  28. package/dist/entry-94.js +1 -1
  29. package/dist/pi-agent-ide.js +1 -1
  30. package/docs/nightly.md +7 -1
  31. package/docs/releases.md +1 -1
  32. package/node_modules/pi-agent-doctor/package.json +1 -1
  33. package/node_modules/pi-agent-documentation/package.json +1 -1
  34. package/node_modules/pi-agent-filesystem/package.json +7 -7
  35. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  36. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  37. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  38. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  39. package/node_modules/pi-agent-ide-ast/package.json +13 -13
  40. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  41. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  42. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  43. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  44. package/node_modules/pi-agent-ide-lsp/package.json +12 -12
  45. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +28 -0
  46. package/node_modules/pi-agent-ide-lsp/src/lsp/corrected-names.ts +16 -5
  47. package/node_modules/pi-agent-ide-lsp/src/lsp/declaration-scan.ts +116 -0
  48. package/node_modules/pi-agent-ide-lsp/src/lsp/initialization-options.ts +37 -0
  49. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +138 -128
  50. package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +1 -24
  51. package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +40 -12
  52. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +98 -40
  53. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +48 -0
  54. package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +61 -0
  55. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +1 -1
  56. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +51 -2
  57. package/node_modules/pi-agent-image/package.json +2 -2
  58. package/node_modules/pi-agent-invariant/package.json +1 -1
  59. package/node_modules/pi-agent-pdf/package.json +2 -2
  60. package/node_modules/pi-agent-read/package.json +7 -7
  61. package/node_modules/pi-agent-resource/package.json +1 -1
  62. package/node_modules/pi-agent-search/package.json +4 -4
  63. package/node_modules/pi-agent-search/src/api/structured-result.ts +28 -4
  64. package/node_modules/pi-agent-search-text/package.json +10 -10
  65. package/node_modules/pi-agent-text/package.json +2 -2
  66. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  67. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  68. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  69. package/node_modules/pi-agent-text-editor/package.json +8 -8
  70. package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
  71. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
  72. package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
  73. package/node_modules/pi-agent-tool-ui/package.json +1 -1
  74. package/node_modules/pi-agent-web/package.json +7 -7
  75. package/node_modules/pi-agent-web-html/package.json +2 -2
  76. package/node_modules/pi-agent-web-image/package.json +3 -3
  77. package/node_modules/pi-agent-web-pdf/package.json +3 -3
  78. package/node_modules/pi-agent-web-text/package.json +3 -3
  79. package/package.json +35 -35
  80. package/src/composite/script-values/lsp-search.ts +56 -12
  81. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  82. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  83. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  84. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  85. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  86. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  87. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
  88. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
  89. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
  90. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
  91. package/src/extensions/pi-agent-read/package.json +7 -7
  92. package/src/extensions/pi-agent-search/package.json +4 -4
  93. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +10 -10
  94. package/src/extensions/pi-agent-search/src/api/structured-result.ts +28 -4
  95. package/src/extensions/pi-agent-text-editor/package.json +8 -8
  96. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  97. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  98. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  99. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
  100. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
  101. package/src/plugins/pi-agent-ide-ast/package.json +13 -13
  102. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  103. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  104. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  105. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  106. package/src/plugins/pi-agent-ide-lsp/package.json +12 -12
  107. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +28 -0
  108. package/src/plugins/pi-agent-ide-lsp/src/lsp/corrected-names.ts +16 -5
  109. package/src/plugins/pi-agent-ide-lsp/src/lsp/declaration-scan.ts +116 -0
  110. package/src/plugins/pi-agent-ide-lsp/src/lsp/initialization-options.ts +37 -0
  111. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +138 -128
  112. package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +1 -24
  113. package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +40 -12
  114. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +98 -40
  115. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +48 -0
  116. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +61 -0
  117. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +1 -1
  118. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +51 -2
  119. package/dist/chunk-4AEYLVSR.js +0 -5
  120. package/dist/chunk-DSB6A5P5.js +0 -53
  121. package/dist/chunk-YSGPCH52.js +0 -18
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.1 — 2026-11-23
4
+
5
+ ### Fixed
6
+
7
+ - `lsp_search` no longer aborts a whole query when one workspace symbol cannot be anchored. It returns the hits it can resolve and lists the skipped symbols.
8
+ - `lsp_search` finds the declarations of an exact name in every project under the searched directory. Before, a language server that indexes only the projects it has loaded (clangd with several compilation databases, gopls with several modules, TypeScript with several projects) could miss a declaration in a sibling project and still report a complete result. The files that write the name are now opened so their own server answers; files past a limit of 64 are reported as unchecked and make the result incomplete.
9
+ - Vue and TypeScript projects: a declaration in a nested TypeScript project is found, and an import binding is no longer reported as the definition of the symbol it imports.
10
+ - Go and Rust: qualified names that the server's index spells differently from the file outline are anchored to their real declaration. This covers Go methods with a pointer receiver (`Engine.Start` for `(*Engine).Start`), struct fields (`Holder.Value`) and Rust alias entries. Two types with a member of the same name stay distinct, and a stale range never anchors a different declaration.
11
+ - When a server caps its `workspace/symbol` reply (gopls at 100 candidates, rust-analyzer at 128 by default), `lsp_search` marks the result incomplete, names the server, and does not offer an anchor for all matches.
12
+
3
13
  ## 1.0.0 — 2026-11-22
4
14
 
5
15
  ### Breaking changes
@@ -1,2 +1,2 @@
1
- import{a as x,e as C}from"./chunk-SKHD2QIT.js";import{a as R}from"./chunk-PS2B6THP.js";import{A as y,B as S,G as p}from"./chunk-IRLWXPL4.js";import{a as u}from"./chunk-EI7MMDWY.js";import{keyText as $}from"@earendil-works/pi-coding-agent";import{Text as D}from"@earendil-works/pi-tui";function w(e,r){let{files:o,...t}=e,s=p(r);return{...t,storedFiles:o.map(({lines:l,...a})=>({...a,lines:l.map(n=>{let i=[n.lineNumber,y(n.text,s),n.ranges];return n.logicalMatchIds===void 0?i:[...i,n.logicalMatchIds]})}))}}u(w,"compactSearchDetails");function g(e,r){if("files"in e)return e;let{storedFiles:o,...t}=e,s=p(r);return{...t,files:o.map(({lines:l,...a})=>({...a,lines:l.map(([n,i,h,c])=>({lineNumber:n,text:S(i,s),ranges:h,matchCount:h.length,...c===void 0?{}:{logicalMatchIds:c}}))}))}}u(g,"restoreSearchDetails");var k=new WeakMap,z=12;function j(e,r,o,t){if(typeof e.details=="object"){let a=k.get(e.details);a===void 0&&(a=g(e.details,e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
1
+ import{a as x,e as C}from"./chunk-QUK5ZEYX.js";import{a as R}from"./chunk-PS2B6THP.js";import{A as y,B as S,G as p}from"./chunk-IRLWXPL4.js";import{a as u}from"./chunk-EI7MMDWY.js";import{keyText as $}from"@earendil-works/pi-coding-agent";import{Text as D}from"@earendil-works/pi-tui";function w(e,r){let{files:o,...t}=e,s=p(r);return{...t,storedFiles:o.map(({lines:l,...a})=>({...a,lines:l.map(n=>{let i=[n.lineNumber,y(n.text,s),n.ranges];return n.logicalMatchIds===void 0?i:[...i,n.logicalMatchIds]})}))}}u(w,"compactSearchDetails");function g(e,r){if("files"in e)return e;let{storedFiles:o,...t}=e,s=p(r);return{...t,files:o.map(({lines:l,...a})=>({...a,lines:l.map(([n,i,h,c])=>({lineNumber:n,text:S(i,s),ranges:h,matchCount:h.length,...c===void 0?{}:{logicalMatchIds:c}}))}))}}u(g,"restoreSearchDetails");var k=new WeakMap,z=12;function j(e,r,o,t){if(typeof e.details=="object"){let a=k.get(e.details);a===void 0&&(a=g(e.details,e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
2
2
  `)),k.set(e.details,a)),e={...e,details:a}}if(r.isPartial||t.isError||!C(e.details)){let a=e.content[0],n=a?.type==="text"?a.text:"",i=t.isError?"error":r.isPartial?"dim":"toolOutput";return new D(o.fg(i,n),0,0)}let l=(t.lastComponent instanceof m?t.lastComponent:void 0)??new m(e.details,o,r.expanded);return l.updateSearch(e.details,o,r.expanded),l}u(j,"renderSearchResult");var m=class extends R{static{u(this,"SearchResultPanel")}constructor(r,o,t){super(T(r,t),o,t)}updateSearch(r,o,t){super.update(T(r,t),o,t)}};function T(e,r){let o=P(e,r).map(t=>t.kind==="file"?{kind:"source",label:t.file.path,link:t.file.link,count:t.file.matchCount}:t.kind==="line"?{kind:"line",...t.line}:t.kind==="candidate"?{kind:"note",text:t.identifier}:t.kind==="summary"?{kind:"note",text:t.text}:t.kind==="omitted"?{kind:"note",text:`\u2026 ${t.matches} more ${d(t.matches,"match","matches")} \xB7 ${$("app.tools.expand")} to expand`}:{kind:"note",text:"No matches found"});return{summary:b(e),rows:o}}u(T,"searchModel");function P(e,r){let o=e.fuzzy?.status==="ready"&&e.fuzzy.candidates.length>0,t=e.files.length===0?o?[]:[{kind:"empty"}]:e.files.flatMap(n=>[{kind:"file",file:n},...n.uniqueLineCount===void 0?n.lines.map(i=>({kind:"line",file:n,line:i})):[{kind:"summary",text:`${String(n.uniqueLineCount)} unique line texts \xB7 ${x(n.matchCount)}`},...(n.groups??[]).map(i=>({kind:"summary",text:`\xD7${String(i.matchCount)} ${i.text}`}))]]);if(e.fuzzy!==void 0&&(e.fuzzy.status==="skipped"?t.push({kind:"summary",text:"Fuzzy search unavailable"}):e.fuzzy.candidates.length>0&&t.push(...e.fuzzy.candidates.flatMap(n=>{let i=e.fuzzyPresentation?.groups.find(c=>c.identifier===n.identifier)?.files??[],h=i.reduce((c,f)=>c+f.matchCount,0);return[{kind:"candidate",identifier:n.identifier},...i.length===0?[]:[{kind:"summary",text:`Shown ${String(h)} of ${String(n.matchCount)}${n.selection.complete?"":"+"}`},...i.flatMap(c=>[{kind:"file",file:c},...c.lines.map(f=>({kind:"line",file:c,line:f}))])]]}))),(e.omittedFileCount??0)>0&&t.push({kind:"summary",text:`\u2026 ${e.omittedFileCount} more files (${e.omittedMatchCount} matches) \xB7 narrow path, include, or query`}),e.fuzzy!==void 0||r||t.length<=z)return t;let s=t.slice(0,z-1);for(;s.at(-1)?.kind==="file";)s.pop();let l=new Set(s.flatMap(n=>n.kind==="line"?n.line.logicalMatchIds??[]:[])),a=l.size>0?l.size:s.reduce((n,i)=>n+(i.kind==="line"?i.line.matchCount:0),0);return[...s,{kind:"omitted",matches:Math.max(0,e.matchCount-a)}]}u(P,"searchViewport");function b(e){if(e.matchCount===0&&e.fuzzy?.status==="ready"&&e.fuzzy.candidates.length>0&&e.fuzzyPresentation!==void 0){let o=e.fuzzy.candidates.reduce((l,a)=>l+a.matchCount,0),t=e.fuzzy.candidates.every(l=>l.selection.complete)?"":"+",s=e.fuzzyPresentation.fileCount;return`0 exact \xB7 ${String(o)}${t} fuzzy ${d(o,"match","matches")} \xB7 ${String(s)}${t} ${d(s,"file","files")}`}return e.matchCount===0?e.complete?"No matches":"No matches \xB7 incomplete":`${`${String(e.matchCount)}${e.complete?"":"+"}`} ${d(e.matchCount,"match","matches")} in ${String(e.fileCount)} ${d(e.fileCount,"file","files")}`}u(b,"searchSummary");function d(e,r,o){return e===1?r:o}u(d,"plural");export{w as a,j as b,m as c};
@@ -1,2 +1,2 @@
1
- import{a as U,b as A,c as I,d as $}from"./chunk-SF44YQCB.js";import{a as k,s as v}from"./chunk-4AEYLVSR.js";import{H as F,i as E,j as D,o as C}from"./chunk-OEEE5BLN.js";import{a as u}from"./chunk-EI7MMDWY.js";import{spawn as G}from"node:child_process";import{stat as O}from"node:fs/promises";import m from"node:path";import{createInterface as T}from"node:readline";async function Z(s,r,t,d,n){let b=r.limit??100,f=["--files","--sort","path","--line-buffered","--hidden","--no-config","--glob","!.git/**"];for(let e of v(r.include))f.push("--glob",e);for(let e of v(r.exclude))f.push("--glob",`!${e}`);let l=r.paths??(r.path===void 0?[]:[r.path]),g=Symbol("file search match limit"),p=new AbortController,i=d===void 0?p.signal:AbortSignal.any([d,p.signal]),a=new Set;E(e=>{let o=[...a],h=C(e);return F({...h,content:[...h.content,{type:"text",text:[`Incomplete file list (${o.length} found)`,...o.slice(0,100)].join(`
1
+ import{a as U,b as A,c as I,d as $}from"./chunk-SF44YQCB.js";import{a as k,s as v}from"./chunk-3JBQYLJ4.js";import{H as F,i as E,j as D,o as C}from"./chunk-OEEE5BLN.js";import{a as u}from"./chunk-EI7MMDWY.js";import{spawn as G}from"node:child_process";import{stat as O}from"node:fs/promises";import m from"node:path";import{createInterface as T}from"node:readline";async function Z(s,r,t,d,n){let b=r.limit??100,f=["--files","--sort","path","--line-buffered","--hidden","--no-config","--glob","!.git/**"];for(let e of v(r.include))f.push("--glob",e);for(let e of v(r.exclude))f.push("--glob",`!${e}`);let l=r.paths??(r.path===void 0?[]:[r.path]),g=Symbol("file search match limit"),p=new AbortController,i=d===void 0?p.signal:AbortSignal.any([d,p.signal]),a=new Set;E(e=>{let o=[...a],h=C(e);return F({...h,content:[...h.content,{type:"text",text:[`Incomplete file list (${o.length} found)`,...o.slice(0,100)].join(`
2
2
  `)}]},k,{status:"partial",data:{kind:"files",complete:!1,files:o},errors:[{code:e.code,source:e.target,message:e.message}]},{maxBytes:1/0})});let w,x=u((e,o)=>{i.aborted||!K(e,s)||(a.add(o),a.size>=b&&p.abort(g))},"accept"),P=u((e,o)=>{if(!p.signal.aborted&&e.failed(o))throw new Error(e.message||`rg exited with code ${String(o)}`);w=$(w,e.unreadable(p.signal.aborted?2:o))},"recordExit");try{if(i.throwIfAborted(),n!==void 0){let e=(l.length===0?["."]:l).map(o=>n.resolve(t,o)).toSorted();for(let o of e){let h=await n.isDirectory(o,i),c=h?o:n.dirname(o),y=[...f,...h?await A(o,n,i):[],"--",h?".":`./${n.basename(o)}`];i.throwIfAborted();let R=await n.runLines(y,c,S=>{let z=S.replace(/^\.\//u,"");x(z,n.resolve(c,S))},i),L=new I(S=>n.resolve(c,S));L.write(R.stderr),P(L,R.code),i.throwIfAborted()}}else{if(l.some(c=>c.includes("://"))||t.includes("://"))throw new Error("No search environment owns this scope.");let e=l.toSorted((c,y)=>j(m.resolve(t,c),m.resolve(t,y)));f.push(...await H(e,t,i)),e.length>0&&f.push("--",...e),i.throwIfAborted();let o=new I(c=>m.resolve(t,c)),h=await B(f,t,o,i,c=>{let y=m.relative(t,m.resolve(t,c));x(y,y)});P(o,h),i.throwIfAborted()}}catch(e){if(d?.throwIfAborted(),e!==g)throw e}return{files:[...a],complete:!p.signal.aborted,...w===void 0?{}:{unreadable:w}}}u(Z,"searchFiles");function j(s,r){return s<r?-1:s>r?1:0}u(j,"comparePaths");function B(s,r,t,d,n){return new Promise((b,f)=>{let l=G(U(),s,{cwd:r,stdio:["ignore","pipe","pipe"],windowsHide:!0}),g,p=new Promise(a=>l.once("close",()=>a())),i=u(()=>{D(p),l.kill("SIGKILL")},"abort");d.addEventListener("abort",i,{once:!0}),l.stderr.setEncoding("utf8"),l.stderr.on("data",a=>t.write(a)),T({input:l.stdout,crlfDelay:1/0}).on("line",a=>{if(!(a===""||d.aborted||g!==void 0))try{n(a)}catch(w){g=w,i()}}),l.once("error",a=>{g=a}),l.once("close",a=>{d.removeEventListener("abort",i),g!==void 0?f(g):b(a)})})}u(B,"runLocalLines");async function H(s,r,t){return(await Promise.all((s.length===0?["."]:s).map(async n=>{let b=m.resolve(r,n);return await O(b).then(l=>l.isDirectory(),()=>!1)?A(b,void 0,t):[]}))).some(n=>n.length>0)?["--no-ignore-parent"]:[]}u(H,"localParentIgnoreArguments");function K(s,r){if(/[*?[\]{}]/u.test(r)){let t=r.replace(/^\.\//u,"");return m.matchesGlob(t.includes("/")?s:m.basename(s),t)}return M(s,r)}u(K,"matchFile");function M(s,r){if(r.length===0)return!0;let t=0,d=s.toLowerCase();for(let n of r.toLowerCase()){if(t=d.indexOf(n,t),t===-1)return!1;t+=1}return!0}u(M,"fuzzyMatch");export{Z as a};
@@ -0,0 +1,5 @@
1
+ import{a as D,b as M}from"./chunk-PS2B6THP.js";import{D as F,la as E,pa as N}from"./chunk-OEEE5BLN.js";import{a as s}from"./chunk-EI7MMDWY.js";function K(e,t,r){return{limit:e??(t&&r==="matches"?Number.MAX_SAFE_INTEGER:void 0),audience:t?"script":"agent",uncappedFiles:t&&r==="files"}}s(K,"searchCallPolicy");import{Type as u}from"typebox";var I="File, directory, URL (no read needed first), docs:all for all packaged guide bodies, docs:<id> for one guide, unchanged Read/Search/edit result or its UUID, or an array of file and directory paths or of results. Use literal text or regex: for docs: sources. Results select only their registered ranges.",m=u.Object({query:u.String({minLength:1,description:"Text to find, matched literally, quotes included. Uppercase AND, OR, NOT, || or a spaced | make it a Boolean expression, where quotes group literal text. Use regex:<pattern> for regular expressions."}),path:u.Optional(u.Union(E.anyOf,{description:I})),include:u.Optional(u.String({description:"Optional include glob for local or SSH files"})),exclude:u.Optional(u.String({description:"Optional exclude glob for local or SSH files"})),caseSensitive:u.Optional(u.Boolean({description:"Match letter case"})),wholeWord:u.Optional(u.Boolean({description:"Match complete words"})),multiline:u.Optional(u.Boolean({description:"Let text or regex:<pattern> match across lines; . also matches line breaks. Local or SSH files and result scopes only."})),limit:u.Optional(u.Integer({minimum:1,maximum:1e3,description:"Maximum displayed items, including compact file summaries (default 50)."}))},{additionalProperties:!1});function Ae(e){let t=[...new Set(e.flatMap(o=>o.split(`
2
+ `)))].filter(o=>o.trim()!=="");if(t.length===0)return m;let r=s(o=>({...o,description:[I,...t].join(`
3
+ `)}),"describe");return{...m,properties:{...m.properties,path:r(m.properties.path)}}}s(Ae,"describeSearchParameters");import x from"node:path";import{pathToFileURL as Y}from"node:url";function ee(e,t,r,o,i,l=[],c=[]){let d=l.map(a=>({kind:"note",text:a}));d.push(...M(e.flatMap(a=>{let w=x.isAbsolute(a.source),X=w&&i?x.relative(i,a.source)||x.basename(a.source):a.source,L=w?Y(a.source).href:/^https?:/iu.test(a.source)?a.source:void 0,P=a.endLineNumber??a.lineNumber;return(P===a.lineNumber?[a.lineText]:[a.lineText,...a.matchedText.split(`
4
+ `).slice(1)]).slice(0,20).map(($,k)=>({source:a.source,label:X,...L===void 0?{}:{link:L},...w?{}:{badge:a.source.startsWith("docs:")?"DOC":/^https?:/iu.test(a.source)?"WEB":"SH"},lineNumber:a.lineNumber+k,text:$,ranges:[{from:k?0:a.startColumn,to:a.lineNumber+k===P?a.endColumn:$.length}]}))}))),e.length||d.push({kind:"note",text:"No matches found"}),e.some(a=>(a.endLineNumber??a.lineNumber)-a.lineNumber>=20)&&d.push({kind:"note",text:"\u2026 source preview shortened"}),d.push(...c.map(a=>({kind:"note",text:a,expandedOnly:!0})));let g=`${e.length}${t?"":"+"}`,z=new Set(e.map(a=>a.source)),J=e.length>0&&e.every(a=>x.isAbsolute(a.source));return new D({summary:`${g} ${e.length===1?"match":"matches"} in ${z.size} ${J?z.size===1?"file":"files":z.size===1?"source":"sources"}`,rows:d},r,o)}s(ee,"renderSearchMatches");var y=class extends Error{static{s(this,"SearchScopeChangedError")}code="SCOPE_CHANGED";constructor(t,r){super(`The scope this search ran in is no longer in its file (${t}). Run the search again from a current Read or Search result.`,r),this.name="SearchScopeChangedError"}};async function te(e,t){if(e.scope!==void 0)try{return e.rescope!==void 0?await e.rescope(t):(await N(e.scope,t),e.scope)}catch(r){throw t?.aborted===!0||r instanceof y?r:new y(r instanceof Error?r.message:String(r),{cause:r})}}s(te,"currentScope");function ne(e,t){return e.targets.some(r=>r.source===t.source&&r.ranges.some(o=>(o.start.lineNumber<t.lineNumber||o.start.lineNumber===t.lineNumber&&o.start.column<=t.startColumn)&&(o.end.lineNumber>(t.endLineNumber??t.lineNumber)||o.end.lineNumber===(t.endLineNumber??t.lineNumber)&&o.end.column>=t.endColumn)))}s(ne,"containsSearchMatch");function re(e){if(e===void 0)return[];let t=[],r=0,o="";for(let i of e){if(i==="{"?r+=1:i==="}"&&(r=Math.max(0,r-1)),r===0&&(i===","||/\s/u.test(i))){o.length>0&&(t.push(o),o="");continue}o+=i}return o.length>0&&t.push(o),t}s(re,"splitGlobList");var h=class extends Error{static{s(this,"SearchCaptureLimitError")}constructor(t="the query"){super(`Search capture exceeded its safety budget. Narrow path, include/exclude globs, or ${t} and retry. limit only controls presentation; no complete result or edit scope was captured.`),this.name="SearchCaptureLimitError"}},v=class{constructor(t){this.query=t}static{s(this,"SearchCaptureGuard")}outputBytes=0;textBytes=0;matches=0;addOutput(t){if(this.outputBytes+=t,this.outputBytes>67108864)throw new h(this.query)}addText(t){if(this.textBytes+=t*2,this.textBytes>67108864)throw new h(this.query)}addMatch(t){this.addLine(t.source),this.addText(t.matchedText.length+t.lineText.length+(t.linesText?.length??0))}addLine(t){if(this.matches++,this.matches>5e4)throw new h(this.query);this.addText(t.length)}};var b="\0null";function oe(e,t){if(typeof e!="object"||e===null||Array.isArray(e))return e;let r=Object.entries(e).filter(([,l])=>l===null);if(r.length===0)return e;let o=t.properties??{},i={...e};for(let[l]of r){let c=o[l];if(c===void 0||!j(c))throw new Error(`${l} is null. Omit ${l} instead; a null here usually means the call that produced it failed or selected no text.`);i[l]=b}return i}s(oe,"markNullFields");function ie(e){let t=Object.entries(e).filter(([,o])=>o===b).map(([o])=>o);return t.length===0?void 0:`${t.length===1?`${t[0]} is`:`${t.join(", ")} are`} null: the call that produced the value probably failed or selected no text. Omit the field to leave it unset; an omitted path searches the working directory.`}s(ie,"nullFieldsMessage");function j(e){let{type:t,anyOf:r}=e;return t==="string"||(r?.some(j)??!1)}s(j,"acceptsString");import se from"node:path";var ae=/^(?:RESULT#|SEARCH#|<system-result\b)|^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/u;function T(e){return typeof e!="string"||ae.test(e)}s(T,"isResultReference");function le(e){let t=e.filter(r=>!T(r));if(t.length!==0){if(t.length<e.length)throw new Error("A path list holds either file and directory paths or Read/Search/edit results and their UUIDs, not both. Search them in separate calls.");for(let r of t){if(r.trim().length===0)throw new Error("A path in a path list must not be empty.");if(/^[a-z][a-z\d+.-]+:/iu.test(r)&&!r.startsWith("ssh://"))throw new Error(`A path list takes local or ssh:// file and directory paths. Search ${r} in a separate call.`)}return t}}s(le,"plainPathList");function ce(e,t){let r=new Set;return e.filter(o=>{let i=B(o,t);return r.has(i)?!1:(r.add(i),!0)})}s(ce,"uniquePaths");function ue(e,t){let r=B(e,t);if(!r.includes("://"))return"local";let o=new URL(r);return`${o.protocol}//${o.host}`}s(ue,"pathMachine");function de(e){return typeof e=="string"?e===b?"null":e:Array.isArray(e)&&e.length>0&&!e.some(T)?e.join(", "):"result scope"}s(de,"describePathArgument");function B(e,t){return e.includes("://")?e.replace(/\/+$/u,""):t.includes("://")?new URL(e,t.endsWith("/")?t:`${t}/`).href.replace(/\/+$/u,""):se.resolve(t,e)}s(B,"absoluteSource");import{Type as n}from"typebox";var _=n.Object({startLine:n.Integer(),startColumn:n.Integer(),endLine:n.Integer(),endColumn:n.Integer()},{additionalProperties:!1}),H=n.Object({line:n.Optional(n.String()),match:n.Optional(n.String())},{additionalProperties:!1}),U={source:n.String(),target:n.Optional(n.String()),range:_,matchedText:n.Optional(n.String()),lineText:n.Optional(n.String()),textTruncated:n.Optional(n.Boolean()),references:n.Optional(H)},pe=n.Object({...U,captures:n.Optional(n.Record(n.String(),n.Array(n.Object(U,{additionalProperties:!1})))),role:n.Optional(n.Union([n.Literal("definition"),n.Literal("reference")])),symbol:n.Optional(n.Object({id:n.String(),name:n.String(),kind:n.String(),selector:n.Optional(n.Array(n.String())),source:n.String(),range:_},{additionalProperties:!1}))},{additionalProperties:!1}),Z={target:n.Optional(n.String()),kind:n.Literal("matches"),truncated:n.Optional(n.Boolean()),fullResult:n.Optional(n.String()),complete:n.Boolean(),matches:n.Array(pe),all:n.Optional(H),notices:n.Optional(n.Array(n.String())),editWarning:n.Optional(n.String()),fallback:n.Optional(n.Union([n.Literal("regex"),n.Literal("words")]))},A=n.Object({status:n.Union([n.Literal("ready"),n.Literal("skipped")]),message:n.Optional(n.String()),candidates:n.Array(n.Object({identifier:n.String(),kind:n.Union([n.Literal("normalized"),n.Literal("component"),n.Literal("typo")]),reason:n.String(),matchCount:n.Integer(),fileCount:n.Integer(),selection:n.Object(Z,{additionalProperties:!1})},{additionalProperties:!1}))},{additionalProperties:!1}),W=n.Union([n.Object({...Z,fuzzy:n.Optional(A),candidateLimits:n.Optional(n.Array(n.Object({server:n.String(),limit:n.Integer({minimum:0})},{additionalProperties:!1}))),skipped:n.Optional(n.Array(n.Object({name:n.String(),source:n.String()},{additionalProperties:!1})))},{additionalProperties:!1}),n.Object({kind:n.Literal("files"),complete:n.Boolean(),files:n.Array(n.String())},{additionalProperties:!1}),n.Object({kind:n.Literal("custom"),resolverId:n.String(),value:n.Unknown()},{additionalProperties:!1})]),he=F(W);function C(e,t,r,o){return{kind:"matches",...o?.target===void 0?{}:{target:o.target},complete:t,matches:e.map((i,l)=>{let c=i.linesText??((i.endLineNumber??i.lineNumber)===i.lineNumber?i.lineText:void 0);return{source:i.source,...o?.matchTargets?.[l]===void 0?{}:{target:o.matchTargets[l]},range:{startLine:i.lineNumber,startColumn:i.startColumn,endLine:i.endLineNumber??i.lineNumber,endColumn:i.endColumn},matchedText:i.matchedText,...c===void 0?{}:{lineText:c},...r===void 0?{}:{references:{line:`SEARCH#${r}:${l+1}:line`,match:`SEARCH#${r}:${l+1}:match`}}}}),...t&&r!==void 0?{all:{line:`SEARCH#${r}:all:line`,match:`SEARCH#${r}:all:match`}}:{}}}s(C,"selectionData");var S={matches:100,textBytes:4096};function fe(e){if(f(e)&&e.kind==="custom"&&f(e.value))return{...e,value:Object.fromEntries(Object.entries(e.value).map(([o,i])=>[o,fe(i)]))};if(!f(e)||e.kind!=="matches"||!Array.isArray(e.matches))return e;let t=e.matches,r=Array.isArray(e.skipped)?e.skipped:void 0;return{...e,...(t.length>S.matches||(r?.length??0)>S.matches)&&{truncated:!0},...r!==void 0&&{skipped:r.slice(0,S.matches)},matches:t.slice(0,S.matches).map(o=>{if(!f(o))return o;let i=f(o.captures)?Object.fromEntries(Object.entries(o.captures).map(([l,c])=>[l,Array.isArray(c)?c.map(d=>f(d)?q(d):d):c])):void 0;return{...q(o),...i!==void 0&&{captures:i}}})}}s(fe,"selectionPreview");function q(e){let t={...e};for(let r of["matchedText","lineText"])typeof t[r]=="string"&&Buffer.byteLength(t[r])>S.textBytes&&(delete t[r],t.textTruncated=!0);return t}s(q,"previewText");function f(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(f,"isRecord");import{Value as ge}from"typebox/value";var p={candidates:5,previewMatches:3,identifiers:2e4,identifierLength:80,vocabularyBytes:8*1024*1024,matchesPerCandidate:200,verificationBytes:4*1024*1024,timeoutMs:2e3};function me(e){return ge.Check(A,e)}s(me,"isFuzzyResultData");function R(e){return e.length>=5&&e.length<=p.identifierLength&&/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(e)&&/[A-Za-z]/u.test(e)}s(R,"isFuzzyQuery");var O=class{static{s(this,"FuzzyVocabulary")}names=new Set;bytes=0;limited=!1;account(t){return this.bytes+=t,this.bytes>p.vocabularyBytes&&(this.limited=!0),!this.limited}add(t){if(!(this.limited||!R(t)||this.names.has(t))){if(this.names.size===p.identifiers){this.limited=!0;return}this.names.add(t)}}addText(t){if(this.account(Buffer.byteLength(t))){for(let r of t.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/gu))if(this.add(r[0]),this.limited)break}}};function V(e){return e.replace(/([A-Z]+)([A-Z][a-z])/gu,"$1 $2").replace(/([a-z0-9])([A-Z])/gu,"$1 $2").split(/[^A-Za-z0-9]+/u).filter(Boolean).map(t=>t.toLowerCase())}s(V,"splitName");function G(e,t){return e.length===t.length&&e.every((r,o)=>r===t[o])}s(G,"same");function ye(e,t){if(e.length<5||t.length<5||Math.abs(e.length-t.length)>1||/\d/u.test(e+t))return!1;let r=0;for(;r<Math.min(e.length,t.length)&&e[r]===t[r];)r++;if(e.length===t.length)return e.slice(r+1)===t.slice(r+1)||e[r]===t[r+1]&&e[r+1]===t[r]&&e.slice(r+2)===t.slice(r+2);let o=e.length<t.length?e:t,i=e.length<t.length?t:e;return o.slice(r)===i.slice(r+1)}s(ye,"oneTypo");function Se(e,t){if(e.join("")===t.join(""))return{kind:"normalized",reason:"same spelling with different case or separators"};let r=e.length<t.length?e:t,o=e.length<t.length?t:e;if(o.length===r.length+1&&r.length>=2&&r.every(c=>c.length>=3)){let c=G(r,o.slice(1)),d=G(r,o.slice(0,-1));if(c||d)return{kind:"component",reason:`${e.length>t.length?"remove":"add"} ${c?"leading":"trailing"} component '${c?o[0]:o.at(-1)}'`}}if(e.length!==t.length)return;let i=e.flatMap((c,d)=>{let g=t[d];return g!==void 0&&c!==g?[{word:c,other:g}]:[]}),l=i[0];if(!(i.length!==1||!l||!ye(l.word,l.other)))return{kind:"typo",reason:`one character edit: '${l.word}' \u2192 '${l.other}'`}}s(Se,"relation");var Q={normalized:0,component:1,typo:2};function xe(e,t){if(!R(e))return[];let r=V(e);if(r.length===0)return[];let o=[];for(let i of new Set(t)){if(i===e||!R(i))continue;let l=Se(r,V(i));l&&o.push({identifier:i,...l})}return o.sort((i,l)=>Q[i.kind]-Q[l.kind]||(i.identifier<l.identifier?-1:i.identifier>l.identifier?1:0)).slice(0,p.candidates)}s(xe,"rankFuzzyIdentifiers");function be(e,t,r){return{identifier:e.identifier,kind:e.kind,reason:e.reason,matchCount:e.matches.length,fileCount:new Set(e.matches.map(o=>o.source)).size,selection:{...C(e.matches.slice(0,p.previewMatches),e.complete,t,r),truncated:e.matches.length>p.previewMatches}}}s(be,"fuzzyCandidateData");function Re(e){let t=e.selection.complete?"":"+",r=e.selection.all?.line??e.selection.matches[0]?.references?.line,o=e.selection.matches[0],i=r??o?.source;return[`Possible name: ${e.identifier} (${e.reason})`,`${e.matchCount}${t} ${e.matchCount===1&&e.selection.complete?"match":"matches"} in ${e.fileCount}${t} ${e.fileCount===1&&e.selection.complete?"file":"files"}`,`Exact alternative: ${JSON.stringify(e.identifier)} (case-sensitive, whole identifier)`,...e.selection.complete?[]:["Capture limit reached; no complete all reference. Inspect the returned location; do not treat this candidate as a complete match set."],...i?[`Read: ${i}${r||!o?"":` \xB7 line ${o.range.startLine}`}`]:[]].join(`
5
+ `)}s(Re,"formatFuzzyCandidate");export{W as a,he as b,C as c,fe as d,oe as e,ie as f,T as g,le as h,ce as i,ue as j,de as k,K as l,m,Ae as n,ee as o,y as p,te as q,ne as r,re as s,h as t,v as u,p as v,me as w,R as x,O as y,xe as z,be as A,Re as B};
@@ -1,4 +1,4 @@
1
- import{a as Ne,b as We,c as Be}from"./chunk-PBQDHYNX.js";import{a as De}from"./chunk-NKI4TZSS.js";import{d as q,k as _e,l as Le,m as V}from"./chunk-S4GTWS2J.js";import{c as Me}from"./chunk-XHFAV2NI.js";import{c as Ee,o as $e}from"./chunk-4AEYLVSR.js";import{a as Ae}from"./chunk-47SPPIXK.js";import{a as ve,b as Pe}from"./chunk-VAXLSPPU.js";import"./chunk-VNNAVC4S.js";import{a as j}from"./chunk-6DC2Q5BI.js";import{f as oe}from"./chunk-BW3XONMZ.js";import"./chunk-GTZOIJCH.js";import{f as Ce,g as Ie}from"./chunk-KN6VPARZ.js";import{b as L}from"./chunk-IZTOXSTR.js";import{a as ke}from"./chunk-JY63UUC2.js";import{a as be}from"./chunk-I3G6K7QU.js";import{a as Se,b as Te}from"./chunk-HSAGZWPO.js";import"./chunk-PS2B6THP.js";import{d as xe,e as Re}from"./chunk-XEPCURYZ.js";import{G as se,H as G}from"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import{d as Oe}from"./chunk-TSQ6FBTB.js";import"./chunk-IRLWXPL4.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import qt from"node:path";import{stripVTControlCharacters as Vt}from"node:util";import{truncateLine as Xt}from"@earendil-works/pi-coding-agent";import{Text as k}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as Ue,DEFAULT_MAX_LINES as Fe,formatSize as Gt,truncateTail as jt}from"@earendil-works/pi-coding-agent";function N(t){return jt(t,{maxBytes:Ue-4096,maxLines:Fe-32})}a(N,"terminalOutputTail");var X=2e3;function He(t){let e=t.output.trimEnd().length,n=Math.max(0,e-X);return n===0&&e===t.output.length?t:{...t,output:t.output.slice(n,e),outputStart:t.outputStart+n,outputEnd:t.outputStart+e,truncated:t.truncated||n>0}}a(He,"noticeSnapshot");function z(t){let e=N(t.output),n=[`session: ${t.source}`,`status: ${t.status}`,`shell: ${t.shell}`,`cwd: ${t.cwd}`,`elapsedMs: ${t.elapsedMs}`,t.exitCode===void 0?void 0:`exitCode: ${t.exitCode}`,t.signal===void 0?void 0:`signal: ${t.signal}`,t.error===void 0?void 0:`error: ${t.error}`,t.waitReason===void 0?void 0:`reason: ${t.waitReason}`,t.completionReason===void 0?void 0:`completionReason: ${t.completionReason}`,t.status==="running"&&t.background?`next: Continue independent work or finish your turn; completion or a one-time idle inspection notice will wake the agent. Read ${t.source} to inspect output; use write or insert when input is needed.`:void 0,`outputRange: ${t.outputStart}-${t.outputEnd}`,t.truncated?"retainedOutput: earlier data omitted from memory":void 0,e.truncated?`fullOutput: ${t.fullOutputPath}`:void 0].filter(o=>o!==void 0),r=e.content.trimEnd();if(!e.truncated)return`${n.join(`
1
+ import{a as Ne,b as We,c as Be}from"./chunk-PBQDHYNX.js";import{a as De}from"./chunk-NKI4TZSS.js";import{d as q,k as _e,l as Le,m as V}from"./chunk-S4GTWS2J.js";import{c as Me}from"./chunk-XHFAV2NI.js";import{c as Ee,o as $e}from"./chunk-3JBQYLJ4.js";import{a as Ae}from"./chunk-47SPPIXK.js";import{a as ve,b as Pe}from"./chunk-VAXLSPPU.js";import"./chunk-VNNAVC4S.js";import{a as j}from"./chunk-6DC2Q5BI.js";import{f as oe}from"./chunk-BW3XONMZ.js";import"./chunk-GTZOIJCH.js";import{f as Ce,g as Ie}from"./chunk-KN6VPARZ.js";import{b as L}from"./chunk-IZTOXSTR.js";import{a as ke}from"./chunk-JY63UUC2.js";import{a as be}from"./chunk-I3G6K7QU.js";import{a as Se,b as Te}from"./chunk-HSAGZWPO.js";import"./chunk-PS2B6THP.js";import{d as xe,e as Re}from"./chunk-XEPCURYZ.js";import{G as se,H as G}from"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import{d as Oe}from"./chunk-TSQ6FBTB.js";import"./chunk-IRLWXPL4.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import qt from"node:path";import{stripVTControlCharacters as Vt}from"node:util";import{truncateLine as Xt}from"@earendil-works/pi-coding-agent";import{Text as k}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as Ue,DEFAULT_MAX_LINES as Fe,formatSize as Gt,truncateTail as jt}from"@earendil-works/pi-coding-agent";function N(t){return jt(t,{maxBytes:Ue-4096,maxLines:Fe-32})}a(N,"terminalOutputTail");var X=2e3;function He(t){let e=t.output.trimEnd().length,n=Math.max(0,e-X);return n===0&&e===t.output.length?t:{...t,output:t.output.slice(n,e),outputStart:t.outputStart+n,outputEnd:t.outputStart+e,truncated:t.truncated||n>0}}a(He,"noticeSnapshot");function z(t){let e=N(t.output),n=[`session: ${t.source}`,`status: ${t.status}`,`shell: ${t.shell}`,`cwd: ${t.cwd}`,`elapsedMs: ${t.elapsedMs}`,t.exitCode===void 0?void 0:`exitCode: ${t.exitCode}`,t.signal===void 0?void 0:`signal: ${t.signal}`,t.error===void 0?void 0:`error: ${t.error}`,t.waitReason===void 0?void 0:`reason: ${t.waitReason}`,t.completionReason===void 0?void 0:`completionReason: ${t.completionReason}`,t.status==="running"&&t.background?`next: Continue independent work or finish your turn; completion or a one-time idle inspection notice will wake the agent. Read ${t.source} to inspect output; use write or insert when input is needed.`:void 0,`outputRange: ${t.outputStart}-${t.outputEnd}`,t.truncated?"retainedOutput: earlier data omitted from memory":void 0,e.truncated?`fullOutput: ${t.fullOutputPath}`:void 0].filter(o=>o!==void 0),r=e.content.trimEnd();if(!e.truncated)return`${n.join(`
2
2
  `)}
3
3
  output:${r.length===0?" (empty)":`
4
4
  ${r}`}`;let i=e.truncatedBy==="lines"?`${Fe} line output budget`:`${Gt(Ue)} output budget`,s=`[Earlier output omitted: showing the last ${e.outputLines} of ${e.totalLines} lines (${i}). Full output: ${t.fullOutputPath}]`;return`${n.join(`
@@ -1 +1 @@
1
- import{a as g,b as R}from"./chunk-QSU5AEKW.js";import{c as u,f as w,j as o,k as m,l as S,m as y}from"./chunk-S4GTWS2J.js";import{a as b,c as I}from"./chunk-WZ7MNISG.js";import{c as l}from"./chunk-XHFAV2NI.js";import"./chunk-NNCZYO4Q.js";import"./chunk-4AEYLVSR.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import"./chunk-2YO6RVX4.js";import"./chunk-MLFJU2US.js";import"./chunk-IZTOXSTR.js";import"./chunk-I3G6K7QU.js";import"./chunk-HSAGZWPO.js";import"./chunk-PS2B6THP.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-2EY3LEZ7.js";import"./chunk-IRLWXPL4.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import{Type as i}from"typebox";import{Value as k}from"typebox/value";var v=i.Object({url:i.String(),status:i.Integer({minimum:200,maximum:599}),statusText:i.String(),headers:i.Array(i.Tuple([i.String(),i.String()])),body:i.String()}),L=new Set(["INVALID_SOURCE","BYTE_LIMIT","TIMEOUT","HTTP_FAILED"]),O=u(new URL("./web-http-worker.py",new URL("../src/backend/web-http.ts",import.meta.url).href));async function E(n,s,r,d){d?.throwIfAborted();try{let e=await g(n,w(await O),[JSON.stringify({url:s.href,timeoutSeconds:30})],r,{signal:d,timeoutMs:3e4,maxBytes:33554432});if(e.exitCode!==0)throw new o("HTTP_FAILED",r,"not-applied");let t;try{t=JSON.parse(e.stdout.toString("utf8"))}catch{throw new o("INVALID_RESPONSE",r,"not-applied")}if(typeof t=="object"&&t!==null&&"error"in t)throw new o(typeof t.error=="string"&&L.has(t.error)?t.error:"INVALID_RESPONSE",r,"not-applied");if(!k.Check(v,t))throw new o("INVALID_RESPONSE",r,"not-applied");let f=Buffer.from(t.body,"base64");if(f.toString("base64")!==t.body||f.length>16*1024*1024)throw new o("INVALID_RESPONSE",r,"not-applied");let p;try{let c=new URL(t.url);if(!["http:","https:"].includes(c.protocol)||c.username||c.password)throw new Error("Invalid native HTTP redirect");p=new Response([204,205,304].includes(t.status)?null:f,{status:t.status,statusText:t.statusText,headers:t.headers}),Object.defineProperty(p,"url",{value:c.href})}catch{throw new o("INVALID_RESPONSE",r,"not-applied")}return p}catch(e){throw e instanceof o?new o(e.code,r,e.effect):e}}a(E,"fetchSshWebResponse");function T(n){if(!/^web:/iu.test(n))return;let s=/^web:ssh:\/\/([a-z0-9._-]+)\/(https?:\/\/.+)$/iu.exec(n);if(!s?.[1]||!s[2])throw new o("INVALID_SOURCE",n,"not-applied");let r;try{r=new URL(s[2])}catch{throw new o("INVALID_SOURCE",n,"not-applied")}if(r.username||r.password)throw new o("INVALID_SOURCE",n,"not-applied");return{target:s[1],url:r,source:`web:ssh://${s[1]}/${r.href}`}}a(T,"parseSshWebSource");function P(n,s){return{id:"ssh-web",async tryResolve(r,d){try{let e=T(r);if(!e)return{kind:"not-handled"};d.signal?.throwIfAborted();let t=s.resolve(`ssh://${e.target}/`);if(!t)throw new o("UNSUPPORTED_SOURCE",e.source,"not-applied");let p=await b(n,{fetch:a(async(c,h)=>E(t.backend.target,e.url,e.source,h?.signal??void 0),"fetch"),browser:{load(c,h){return R(t.backend.target,c,e.source,h)}}}).tryResolve(e.url.href,d);return p.kind!=="resolved"?p:{kind:"resolved",resource:{...p.resource,source:e.source}}}catch(e){return{kind:"failed",error:e instanceof o?new o(e.code,r,e.effect):e}}}}}a(P,"createSshWebResolver");async function A(n){let s=new y(await S(m(l())));await I(n,r=>P(r,s))}a(A,"registerOwnedWeb");export{A as default};
1
+ import{a as g,b as R}from"./chunk-QSU5AEKW.js";import{c as u,f as w,j as o,k as m,l as S,m as y}from"./chunk-S4GTWS2J.js";import{a as b,c as I}from"./chunk-KM4NOIOB.js";import{c as l}from"./chunk-XHFAV2NI.js";import"./chunk-NNCZYO4Q.js";import"./chunk-3JBQYLJ4.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import"./chunk-2YO6RVX4.js";import"./chunk-MLFJU2US.js";import"./chunk-IZTOXSTR.js";import"./chunk-I3G6K7QU.js";import"./chunk-HSAGZWPO.js";import"./chunk-PS2B6THP.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-2EY3LEZ7.js";import"./chunk-IRLWXPL4.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import{Type as i}from"typebox";import{Value as k}from"typebox/value";var v=i.Object({url:i.String(),status:i.Integer({minimum:200,maximum:599}),statusText:i.String(),headers:i.Array(i.Tuple([i.String(),i.String()])),body:i.String()}),L=new Set(["INVALID_SOURCE","BYTE_LIMIT","TIMEOUT","HTTP_FAILED"]),O=u(new URL("./web-http-worker.py",new URL("../src/backend/web-http.ts",import.meta.url).href));async function E(n,s,r,d){d?.throwIfAborted();try{let e=await g(n,w(await O),[JSON.stringify({url:s.href,timeoutSeconds:30})],r,{signal:d,timeoutMs:3e4,maxBytes:33554432});if(e.exitCode!==0)throw new o("HTTP_FAILED",r,"not-applied");let t;try{t=JSON.parse(e.stdout.toString("utf8"))}catch{throw new o("INVALID_RESPONSE",r,"not-applied")}if(typeof t=="object"&&t!==null&&"error"in t)throw new o(typeof t.error=="string"&&L.has(t.error)?t.error:"INVALID_RESPONSE",r,"not-applied");if(!k.Check(v,t))throw new o("INVALID_RESPONSE",r,"not-applied");let f=Buffer.from(t.body,"base64");if(f.toString("base64")!==t.body||f.length>16*1024*1024)throw new o("INVALID_RESPONSE",r,"not-applied");let p;try{let c=new URL(t.url);if(!["http:","https:"].includes(c.protocol)||c.username||c.password)throw new Error("Invalid native HTTP redirect");p=new Response([204,205,304].includes(t.status)?null:f,{status:t.status,statusText:t.statusText,headers:t.headers}),Object.defineProperty(p,"url",{value:c.href})}catch{throw new o("INVALID_RESPONSE",r,"not-applied")}return p}catch(e){throw e instanceof o?new o(e.code,r,e.effect):e}}a(E,"fetchSshWebResponse");function T(n){if(!/^web:/iu.test(n))return;let s=/^web:ssh:\/\/([a-z0-9._-]+)\/(https?:\/\/.+)$/iu.exec(n);if(!s?.[1]||!s[2])throw new o("INVALID_SOURCE",n,"not-applied");let r;try{r=new URL(s[2])}catch{throw new o("INVALID_SOURCE",n,"not-applied")}if(r.username||r.password)throw new o("INVALID_SOURCE",n,"not-applied");return{target:s[1],url:r,source:`web:ssh://${s[1]}/${r.href}`}}a(T,"parseSshWebSource");function P(n,s){return{id:"ssh-web",async tryResolve(r,d){try{let e=T(r);if(!e)return{kind:"not-handled"};d.signal?.throwIfAborted();let t=s.resolve(`ssh://${e.target}/`);if(!t)throw new o("UNSUPPORTED_SOURCE",e.source,"not-applied");let p=await b(n,{fetch:a(async(c,h)=>E(t.backend.target,e.url,e.source,h?.signal??void 0),"fetch"),browser:{load(c,h){return R(t.backend.target,c,e.source,h)}}}).tryResolve(e.url.href,d);return p.kind!=="resolved"?p:{kind:"resolved",resource:{...p.resource,source:e.source}}}catch(e){return{kind:"failed",error:e instanceof o?new o(e.code,r,e.effect):e}}}}}a(P,"createSshWebResolver");async function A(n){let s=new y(await S(m(l())));await I(n,r=>P(r,s))}a(A,"registerOwnedWeb");export{A as default};
@@ -1,4 +1,4 @@
1
- import{a as st}from"./chunk-QC6VFZSB.js";import{a as Qe,b as Je,c as j,d as et,e as Z,f as U,g as tt,h as nt,n as rt,o as it,p as ot,q as at}from"./chunk-KJ6HZC6L.js";import{a as M,c as X}from"./chunk-SF44YQCB.js";import{a as ct,b as lt}from"./chunk-LG22ELG4.js";import{a as Xe,b as Ze,c as V,d as Ue,e as Ke,f as k,g as Ye}from"./chunk-SKHD2QIT.js";import{b as Be,c as Ge}from"./chunk-D23NS4VV.js";import{A as De,B as _e,a as W,b as Ee,c as J,e as Ne,f as Pe,g as ke,k as ze,l as ve,q as qe,u as Ie,v as x,x as Me,y as Fe,z as Oe}from"./chunk-4AEYLVSR.js";import{a as Le}from"./chunk-47SPPIXK.js";import{a as Ae,b as $e}from"./chunk-VAXLSPPU.js";import{f as Te,g as Ce}from"./chunk-JXULBI4S.js";import{a as je}from"./chunk-2YO6RVX4.js";import{b as He,c as We}from"./chunk-MLFJU2US.js";import{a as Ve}from"./chunk-JY63UUC2.js";import{a as ye}from"./chunk-I3G6K7QU.js";import{a as pe,b as ge}from"./chunk-HSAGZWPO.js";import{a as Re,e as xe}from"./chunk-PS2B6THP.js";import{d as Se,e as be,g as we}from"./chunk-XEPCURYZ.js";import{G as me,H as L,I as H,i as ce,o as le,r as de,s as ue,ta as he,w as fe}from"./chunk-OEEE5BLN.js";import{E as G,F as Q,m as I}from"./chunk-IRLWXPL4.js";import{a as m}from"./chunk-EI7MMDWY.js";import{readFile as Jt}from"node:fs/promises";import{Text as Et}from"@earendil-works/pi-tui";import{Type as T}from"typebox";var dt=T.Object({pattern:T.String({minLength:1,description:"Glob (*, **, ?, [abc], {a,b}) or plain text matched as a case-insensitive subsequence. A glob with / matches paths relative to path; one without / matches file names at any depth."}),path:T.Optional(T.Union([T.String(),T.Array(T.String())],{description:"Directory or file to search, or an array of them, local or ssh://; defaults to cwd."})),include:T.Optional(T.String({description:"Include glob"})),exclude:T.Optional(T.String({description:"Exclude glob"})),limit:T.Optional(T.Integer({minimum:1,maximum:1e3,description:"Maximum files (default 100; in Codemode, all files)."}))},{additionalProperties:!1});function ft(e,r,t){let a=H(e,"file_search");e.registerTool(Ce({name:"file_search",label:"file_search",exposure:"direct",namespace:{name:"ide_file_search",description:"Find files by path."},annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},description:"Use file_search to find file paths by glob or partial name, locally or over SSH. Pass a returned path to read or an edit tool.",promptSnippet:"Find file paths by glob or partial name",parameters:dt,outputSchema:Ee,prepareArguments:m(n=>Ne(n,dt),"prepareArguments"),renderCall(n,c,s){return xe(s.lastComponent,{tool:"file_search",primary:{text:n.pattern,color:"accent",truncate:"end"},qualifiers:[...n.path===void 0?[]:[{text:`in ${ze(n.path)}`,color:"accent",truncate:"start"}],...n.include===void 0?[]:[{text:`include ${n.include}`}],...n.exclude===void 0?[]:[{text:`exclude ${n.exclude}`}],...n.limit===void 0?[]:[{text:`limit ${String(n.limit)}`}]],expanded:s.expanded},c)},renderResult(n,c,s,o){let l=n.details;return r.renderResult!==void 0&&l?.payload!==void 0&&!o.isError&&!c.isPartial?r.renderResult({...n,details:l.payload},c,s,o):new Et(n.content.flatMap(i=>i.type==="text"?[i.text]:[]).join(`
1
+ import{a as st}from"./chunk-3BRGWFEI.js";import{a as Qe,b as Je,c as j,d as et,e as Z,f as U,g as tt,h as nt,n as rt,o as it,p as ot,q as at}from"./chunk-VQ2RA43A.js";import{a as M,c as X}from"./chunk-SF44YQCB.js";import{a as ct,b as lt}from"./chunk-26SMC6OS.js";import{a as Xe,b as Ze,c as V,d as Ue,e as Ke,f as k,g as Ye}from"./chunk-QUK5ZEYX.js";import{b as Be,c as Ge}from"./chunk-D23NS4VV.js";import{A as De,B as _e,a as W,b as Ee,c as J,e as Ne,f as Pe,g as ke,k as ze,l as ve,q as qe,u as Ie,v as x,x as Me,y as Fe,z as Oe}from"./chunk-3JBQYLJ4.js";import{a as Le}from"./chunk-47SPPIXK.js";import{a as Ae,b as $e}from"./chunk-VAXLSPPU.js";import{f as Te,g as Ce}from"./chunk-JXULBI4S.js";import{a as je}from"./chunk-2YO6RVX4.js";import{b as He,c as We}from"./chunk-MLFJU2US.js";import{a as Ve}from"./chunk-JY63UUC2.js";import{a as ye}from"./chunk-I3G6K7QU.js";import{a as pe,b as ge}from"./chunk-HSAGZWPO.js";import{a as Re,e as xe}from"./chunk-PS2B6THP.js";import{d as Se,e as be,g as we}from"./chunk-XEPCURYZ.js";import{G as me,H as L,I as H,i as ce,o as le,r as de,s as ue,ta as he,w as fe}from"./chunk-OEEE5BLN.js";import{E as G,F as Q,m as I}from"./chunk-IRLWXPL4.js";import{a as m}from"./chunk-EI7MMDWY.js";import{readFile as Jt}from"node:fs/promises";import{Text as Et}from"@earendil-works/pi-tui";import{Type as T}from"typebox";var dt=T.Object({pattern:T.String({minLength:1,description:"Glob (*, **, ?, [abc], {a,b}) or plain text matched as a case-insensitive subsequence. A glob with / matches paths relative to path; one without / matches file names at any depth."}),path:T.Optional(T.Union([T.String(),T.Array(T.String())],{description:"Directory or file to search, or an array of them, local or ssh://; defaults to cwd."})),include:T.Optional(T.String({description:"Include glob"})),exclude:T.Optional(T.String({description:"Exclude glob"})),limit:T.Optional(T.Integer({minimum:1,maximum:1e3,description:"Maximum files (default 100; in Codemode, all files)."}))},{additionalProperties:!1});function ft(e,r,t){let a=H(e,"file_search");e.registerTool(Ce({name:"file_search",label:"file_search",exposure:"direct",namespace:{name:"ide_file_search",description:"Find files by path."},annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},description:"Use file_search to find file paths by glob or partial name, locally or over SSH. Pass a returned path to read or an edit tool.",promptSnippet:"Find file paths by glob or partial name",parameters:dt,outputSchema:Ee,prepareArguments:m(n=>Ne(n,dt),"prepareArguments"),renderCall(n,c,s){return xe(s.lastComponent,{tool:"file_search",primary:{text:n.pattern,color:"accent",truncate:"end"},qualifiers:[...n.path===void 0?[]:[{text:`in ${ze(n.path)}`,color:"accent",truncate:"start"}],...n.include===void 0?[]:[{text:`include ${n.include}`}],...n.exclude===void 0?[]:[{text:`exclude ${n.exclude}`}],...n.limit===void 0?[]:[{text:`limit ${String(n.limit)}`}]],expanded:s.expanded},c)},renderResult(n,c,s,o){let l=n.details;return r.renderResult!==void 0&&l?.payload!==void 0&&!o.isError&&!c.isPartial?r.renderResult({...n,details:l.payload},c,s,o):new Et(n.content.flatMap(i=>i.type==="text"?[i.text]:[]).join(`
2
2
  `),0,0)},async execute(n,c,s,o,l){let i=Pe(c);if(i!==void 0)return ut(i);let{limit:d,audience:u,uncappedFiles:h}=ve(c.limit,a(n),"files"),f={pattern:c.pattern,...h&&{uncapped:!0}};return c.path!==void 0&&[c.path].flat().some(ke)?ut("file_search takes file and directory paths, not Read/Search results. Pass the paths themselves."):await(await t).searchWith(r,{query:c.pattern,...c.path===void 0?{}:{path:c.path},...c.include===void 0?{}:{include:c.include},...c.exclude===void 0?{}:{exclude:c.exclude},...d===void 0?{}:{limit:d},options:{files:f}},{cwd:l.cwd,...s!==void 0&&{signal:s},...o!==void 0&&{onUpdate:o}},u)}},new Te))}m(ft,"registerFileSearchTool");function ut(e){return L({content:[{type:"text",text:e}],details:{failure:{code:"INVALID_REQUEST",message:e}}},W,{status:"error",errors:[me(new Error(e),"SEARCH_FAILED")]})}m(ut,"fileSearchFailure");var mt={protocol:He,apiVersion:We,id:"search-text",setup(e){e.addSetupCheck({id:"ripgrep",async inspect(r){let t=r.workspace?"rg":M(r.env.PI_CODING_AGENT_DIR);return await Ge(r,t)?{}:{actions:[{id:"ripgrep-unavailable",message:"Local search is unavailable because ripgrep was not found"}]}}}),e.addCheck({id:"ripgrep",title:"Local search",async run(r){let t=r.env.PI_CODING_AGENT_DIR,a=r.workspace?"rg":M(t),n=await Be(r,a,["--version"]);return[n.ok?{status:"pass",message:"ripgrep is available",detail:n.detail}:{status:"fail",message:"ripgrep is not available",detail:n.detail}]}})}};import Lt from"node:path";import{pathToFileURL as Ht}from"node:url";async function K(e,r,t,a){if(e.include!==void 0||e.exclude!==void 0)throw new Error("Include/exclude globs are unsupported for result scopes; filter the target array instead.");let n=m(async(i,d=e.condition)=>{let u=[],h=new Set,f=new Ie;for(let p of r.targets){a?.throwIfAborted();let g=I(p.source,p.expectedContent),y=[0];for(let S of g.lines)y.push((y.at(-1)??0)+S.content.length+S.lineEnding.length);for(let S of p.ranges){let $=(y[S.start.lineNumber-1]??g.content.length)+S.start.column,z=(y[S.end.lineNumber-1]??g.content.length)+S.end.column,O=await j({...e,query:i,condition:d},g.content.slice($,z),t.includes("://")?process.cwd():t,a);for(let C of O.matches){let b=S.start.lineNumber+C.lineNumber-1,w=C.endLineNumber??C.lineNumber,R=m(D=>D===1?S.start.column:0,"shift"),A={...C,source:p.source,lineNumber:b,startColumn:C.startColumn+R(C.lineNumber),...C.endLineNumber===void 0?{}:{endLineNumber:S.start.lineNumber+C.endLineNumber-1},endColumn:C.endColumn+R(w),lineText:g.lines[b-1]?.content??""},v=JSON.stringify([A.source,b,A.startColumn,A.endLineNumber??b,A.endColumn]);h.has(v)||(h.add(v),f.addMatch(A),u.push(A))}}}return u.sort((p,g)=>p.source.localeCompare(g.source)||p.lineNumber-g.lineNumber||p.startColumn-g.startColumn||p.endColumn-g.endColumn),{matches:u,complete:r.complete}},"search"),c=e.query,s,o=await n(c),l=[];for(let i of e.fallbacks??[]){if(o.matches.length>0||!o.complete)break;try{o=await n(i.query,i.condition),c=i.query,s=i.mode,l.push(tt(i.mode))}catch(d){if(a?.aborted||i.mode!=="regex"||!(d instanceof Error)||!/regex parse error:|PCRE2: error compiling pattern/iu.test(d.message))throw d;l.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...o,query:c,notices:l,...s===void 0?{}:{fallback:s}}}m(K,"runScopedSearch");var Nt=3;async function Y(e,r,t){let a=e.matches,n=e.complete,c=e.query,s=e.fallback,o;for(let l=1;;l+=1){let{contents:i,unreadable:d}=await Pt(a,t),u=a.filter(y=>!d.has(y.source));if(d.size>0&&(u.length===0||t.requireEverySource===!0))throw It(d,r);let h=n&&d.size===0,f=qt(d,r),p=ht(u,i);if(p.size===0)return{matches:u,complete:h,contents:i,notices:f,query:c,...s===void 0?{}:{fallback:s},...o===void 0?{}:{rerunNotices:o}};if(t.inContent){let y=await kt(u,i,p,r,t),S=ht(y,i);if(S.size>0)throw Ft(S,r);return{matches:y,complete:h,contents:i,notices:f,query:c,...s===void 0?{}:{fallback:s},...o===void 0?{}:{rerunNotices:o}}}if(t.rerun===void 0||l>=Nt)throw Mt(p,r);let g=await t.rerun(t.signal);a=g.matches.map(y=>({...y,source:ot(y.source)})),n=g.complete,c=g.query,s=g.fallback,o=g.notices}}m(Y,"captureCurrentMatches");async function Pt(e,r){let t=[...new Set(e.map(s=>s.source))],a=await Promise.all(t.map(async s=>{r.signal?.throwIfAborted();try{return{source:s,failed:!1,content:await r.read(s,r.signal)}}catch(o){return r.signal?.throwIfAborted(),{source:s,failed:!0,error:o}}})),n=new Map,c=new Map;for(let s of a)s.failed?c.set(s.source,s.error):n.set(s.source,s.content??"");return{contents:n,unreadable:c}}m(Pt,"readSources");function ht(e,r){let t=new Set,a=new Map;for(let n of e){if(t.has(n.source))continue;let c=r.get(n.source);if(c===void 0){t.add(n.source);continue}let s=a.get(n.source);s===void 0&&(s=I(n.source,c),a.set(n.source,s)),it(s,n)||t.add(n.source)}return t}m(ht,"changedSources");async function kt(e,r,t,a,n){let c=e.filter(o=>!t.has(o.source)),s=a.includes("://")?process.cwd():a;for(let o of t){n.signal?.throwIfAborted();let l=r.get(o);if(l===void 0)continue;let i=await j(n.request,l,s,n.signal),d=I(o,l),u=vt(l);for(let h of i.matches)n.accept?.(h)!==!1&&c.push(zt(o,d,u,l,(u[h.lineNumber-1]??0)+h.startColumn,(u[(h.endLineNumber??h.lineNumber)-1]??0)+h.endColumn))}return c}m(kt,"matchesInCapturedText");function zt(e,r,t,a,n,c){let s=pt(t,n),o=pt(t,c);return{source:e,lineNumber:s.lineNumber,startColumn:s.column,...o.lineNumber===s.lineNumber?{}:{endLineNumber:o.lineNumber},endColumn:o.column,matchedText:a.slice(n,c),lineText:r.lines[s.lineNumber-1]?.content??""}}m(zt,"inDocument");function vt(e){let r=[0];for(let t=e.indexOf(`
3
3
  `);t!==-1;t=e.indexOf(`
4
4
  `,t+1))r.push(t+1);return r}m(vt,"lineStarts");function pt(e,r){let t=0,a=e.length-1;for(;t<a;){let n=Math.ceil((t+a)/2);(e[n]??0)<=r?t=n:a=n-1}return{lineNumber:t+1,column:r-(e[t]??0)}}m(pt,"positionAt");function qt(e,r){let t=[...e].slice(0,3),a=t.map(([c,s])=>`Search notice: ${k(c,r)} could not be read while the search registered its results: ${gt(s)}. Its matches are not shown; search again for it once it can be read.`),n=e.size-t.length;return n>0&&a.push(`Search notice: ${String(n)} more matched ${n===1?"file":"files"} could not be read either, and ${n===1?"its":"their"} matches are not shown.`),a}m(qt,"unreadableNotices");function It(e,r){let t=[...e.values()][0];return new Error(`${ee([...e.keys()],r)} could not be read while the search registered its results: ${gt(t)}. Repeat the search once ${e.size===1?"it":"they"} can be read.`,{cause:t})}m(It,"unreadableSources");function Mt(e,r){return new Error(`${ee([...e],r)} kept changing while the search registered its results, because another process is writing ${e.size===1?"it":"them"}. Repeat the search and use its new anchors.`)}m(Mt,"sourceChanged");function Ft(e,r){return new Error(`The matches in ${ee([...e],r)} could not be placed in the text the search read, so no anchors were registered. Read the file and edit it by its own text.`)}m(Ft,"notDescribed");function gt(e){return e instanceof Error?e.message:String(e)}m(gt,"reason");function ee(e,r){let t=e.slice(0,3).map(n=>k(n,r)),a=e.length-t.length;return a>0?`${t.join(", ")} and ${String(a)} more`:t.join(", ")}m(ee,"describeSources");import{spawn as Ot}from"node:child_process";import{stat as Dt}from"node:fs/promises";async function yt(e,r,t,a){let n=AbortSignal.timeout(x.timeoutMs),c=t===void 0?n:AbortSignal.any([t,n]);try{if(c.throwIfAborted(),a!==void 0&&a.byteSize===void 0)return F("source owner cannot bound candidate snapshots");let s=await St(e,r,c,a);if(s.limited)return F("name collection reached its byte or unique-name budget");let o=[],l=0,i=new Set;for(let d of Oe(e.query,s.names)){c.throwIfAborted();let u=await te({...e,query:d.identifier},r,c,a);if(u.matches.length===0){if(!u.complete)return F("candidate verification reached its byte budget before capturing a match");continue}for(let h of u.matches)if(!i.has(h.source)&&(i.add(h.source),l+=a===void 0?(await Dt(h.source)).size:await _t(a,h.source,c),l>x.vocabularyBytes))return F("candidate source snapshots exceeded the byte budget");o.push({...d,...u})}return o.length===0?void 0:{status:"ready",candidates:o}}catch(s){return t?.throwIfAborted(),F(n.aborted?"extra search reached its time budget":`extra search failed: ${s instanceof Error?s.message:String(s)}`)}}m(yt,"searchFuzzy");async function te(e,r,t,a){let n=AbortSignal.timeout(x.timeoutMs),c=t===void 0?n:AbortSignal.any([t,n]),s=await Qe({...e,regex:!1,caseSensitive:!0,wholeWord:!0},r,c,{matches:x.matchesPerCandidate,bytes:x.verificationBytes},a);return{matches:s.matches.filter(ne),complete:s.complete}}m(te,"searchFuzzyAlternative");function ne(e){return e.lineText[e.startColumn-1]!=="$"&&e.lineText[e.endColumn]!=="$"}m(ne,"isWholeIdentifierMatch");async function _t(e,r,t){if(e.byteSize===void 0)throw new Error("Source owner cannot bound candidate snapshots");return e.byteSize(r,t)}m(_t,"ownedByteSize");function F(e){return{status:"skipped",message:e,candidates:[]}}m(F,"skipped");async function St(e,r,t,a,n=new Fe){if(e.paths!==void 0){for(let s of e.paths){if(n.limited)break;await St({...e,paths:void 0,path:s},r,t,a,n)}return n}let c=await Je(e,r,a,t);if(a!==void 0){let s=new AbortController,o=AbortSignal.any([t,s.signal]);try{let l=await a.runLines(["--only-matching","--no-filename","--case-sensitive",...c.arguments,"--","[A-Za-z_$][A-Za-z0-9_$]*",c.target],c.cwd,d=>{s.signal.aborted||(n.account(Buffer.byteLength(d)+1)&&n.add(d),n.limited&&s.abort())},o),i=new X;if(i.write(l.stderr),!n.limited&&i.failed(l.code))throw new Error(i.message||"Ripgrep failed.")}catch(l){if(t.throwIfAborted(),!n.limited)throw l}return n}return t.throwIfAborted(),new Promise((s,o)=>{let l=Ot(M(),["--only-matching","--no-filename","--case-sensitive",...c.arguments,"--","[A-Za-z_$][A-Za-z0-9_$]*",c.target],{cwd:c.cwd,stdio:["ignore","pipe","pipe"]}),i="",d=!1,u=new X,h=m(()=>{l.kill()},"abort"),f=m(()=>{t.removeEventListener("abort",h)},"cleanup");l.stdout.on("data",p=>{if(!n.account(p.length)){l.kill();return}for(let g of p)if(g===10){if(d||n.add(i),i="",d=!1,n.limited){l.kill();break}}else d||(i.length===x.identifierLength?(i="",d=!0):i+=String.fromCharCode(g))}),l.stderr.setEncoding("utf8"),l.stderr.on("data",p=>{u.write(p)}),l.once("error",p=>{f(),o(p)}),l.once("close",p=>{if(f(),t.aborted){o(t.reason);return}if(!n.limited&&u.failed(p)){o(new Error(u.message||`ripgrep exited with code ${String(p)}`));return}s(n)}),t.addEventListener("abort",h,{once:!0}),t.aborted&&h()})}m(St,"collectNames");var xt="Anchors: SEARCH#HASH:N:line (line), SEARCH#HASH:N:match (exact match), SEARCH#HASH:all:line (each unique containing line), SEARCH#HASH:all:match (every exact match)";function Wt(e){let r=e.request.query;if(r===e.recipe.query)return e.recipe;let t=e.recipe.fallbacks?.find(c=>c.query===r),{condition:a,...n}=e.recipe;return t?.condition===void 0?{...n,query:r,regex:!0}:{...n,query:r,regex:!0,condition:t.condition}}m(Wt,"effectiveRequest");async function jt(e,r,t,a){let n=await Y(e,t,{...a,request:r,inContent:!0,accept:ne,requireEverySource:!0});return n.matches.length<=x.matchesPerCandidate?n:{...n,matches:[...n.matches].sort(at).slice(0,x.matchesPerCandidate),complete:!1}}m(jt,"captureCandidate");function bt(e,r){return[...r].flatMap(([t,a])=>{let n=e.get(t);return n===void 0?[]:[{source:t,content:n,ranges:a}]})}m(bt,"searchWindows");function Vt(e){let r=new Map;for(let t of e){let a=t.endLineNumber??t.lineNumber,n=t.linesText??(a===t.lineNumber?t.lineText:void 0),c=r.get(t.source)??[];if(c.push({start:{lineNumber:t.lineNumber,column:t.startColumn},end:{lineNumber:a,column:t.endColumn}}),n!==void 0){let s=n.lastIndexOf(`
@@ -1,4 +1,4 @@
1
- import{A as w,B as z,c as I,o as L,v as g,x as $,y as H,z as W}from"./chunk-4AEYLVSR.js";import{a as _}from"./chunk-47SPPIXK.js";import{a as k,b as B}from"./chunk-VAXLSPPU.js";import{a as U}from"./chunk-2YO6RVX4.js";import{b as M,c as O}from"./chunk-MLFJU2US.js";import{d as C}from"./chunk-IZTOXSTR.js";import{a as T}from"./chunk-I3G6K7QU.js";import{a as x,b as P}from"./chunk-HSAGZWPO.js";import{J as E,ba as A}from"./chunk-OEEE5BLN.js";import{e as F}from"./chunk-2EY3LEZ7.js";import{a}from"./chunk-EI7MMDWY.js";import{constants as J}from"node:fs";import{access as K}from"node:fs/promises";import y from"node:path";var Q=["google-chrome-stable","google-chrome","chromium","chromium-browser"],X=["/usr/bin/google-chrome-stable","/usr/bin/google-chrome","/usr/bin/chromium","/usr/bin/chromium-browser","/opt/google/chrome/chrome"];function D(e={}){let t;return{async load(r,o){t??=v(e.executablePath,e.environment??process.env);let n=await t;o.signal?.throwIfAborted();let{chromium:i}=await import("playwright-core");o.signal?.throwIfAborted();let s=await i.launch({executablePath:n,headless:!0,chromiumSandbox:!1,timeout:o.timeoutMs}),l=a(()=>{s.close()},"closeOnAbort");o.signal?.addEventListener("abort",l,{once:!0});try{o.signal?.throwIfAborted();let c=await s.newPage(),u=await c.goto(r.href,{timeout:o.timeoutMs,waitUntil:"domcontentloaded"});if(u!==null&&!u.ok())throw new Error(`HTTP ${u.status()}: ${u.statusText()}`);await c.waitForLoadState("networkidle",{timeout:Math.min(o.timeoutMs,1500)}).catch(()=>{}),o.signal?.throwIfAborted(),await Z(c);let d={html:await c.content(),source:c.url()};return o.signal?.throwIfAborted(),d}catch(c){throw o.signal?.aborted===!0?ee(o.signal):new Error(`Browser read failed for ${r.href}: ${re(c)}`,{cause:c})}finally{o.signal?.removeEventListener("abort",l),await s.close().catch(()=>{})}}}}a(D,"createSystemBrowserHtmlLoader");async function v(e=process.env.PI_AGENT_IDE_BROWSER_PATH,t=process.env){if(e!==void 0&&e.trim().length>0){let r=y.resolve(e);if(await R(r))return r;throw new Error(`PI_AGENT_IDE_BROWSER_PATH is not executable: ${r}`)}for(let r of(t.PATH??"").split(y.delimiter).filter(Boolean))for(let o of Q){let n=y.join(r,o);if(await R(n))return n}for(let r of X)if(await R(r))return r;throw new Error("No system Chrome or Chromium executable was found. Install Chrome/Chromium or set PI_AGENT_IDE_BROWSER_PATH.")}a(v,"resolveSystemBrowserExecutable");async function Z(e){await e.locator("body *").evaluateAll(t=>{for(let r of t.toReversed()){let o=globalThis.getComputedStyle(r);(r.hasAttribute("hidden")||r.getAttribute("aria-hidden")==="true"||o.display==="none"||o.visibility==="hidden"||o.visibility==="collapse")&&r.remove()}})}a(Z,"removeHiddenElements");async function R(e){try{return await K(e,J.X_OK),!0}catch{return!1}}a(R,"isExecutable");function ee(e){return e.reason instanceof Error?e.reason:te()}a(ee,"abortReason");function te(){let e=new Error("The operation was aborted");return e.name="AbortError",e}a(te,"abortError");function re(e){return e instanceof Error?e.message:String(e)}a(re,"errorMessage");var N={protocol:M,apiVersion:O,id:"web-browser",setup(e){e.addCheck({id:"system-browser",title:"Browser web reads",async run(t){try{t.signal?.throwIfAborted();let r=t.workspace?await oe(t.workspace,t.signal):await F(await v(t.env.PI_AGENT_IDE_BROWSER_PATH,t.env),["--version"],t.cwd,t.env,t.signal);return t.signal?.throwIfAborted(),[r.ok?{status:"pass",message:"Chrome/Chromium is available",detail:r.detail}:{status:"warn",message:"Chrome/Chromium cannot start",detail:r.detail}]}catch(r){return t.signal?.throwIfAborted(),[{status:"warn",message:"Browser reads are unavailable",detail:r instanceof Error?r.message:String(r)}]}}})}};async function oe(e,t){if(!e.probeBrowser)throw new Error("Project owner does not provide a browser probe");return e.probeBrowser(t)}a(oe,"probeOwnerBrowser");var ne=4096;function V(e,t={}){let r=se(t);return{id:"web",async tryResolve(o,n){if(/^web:/iu.test(o)){let i=await t.owner?.tryResolve(o,n);return i!==void 0&&i.kind!=="not-handled"?i:{kind:"failed",error:new Error(`Target web execution is unavailable: ${o}`)}}return ae(o,e,r)}}}a(V,"createWebResolver");function se(e){let t=e.timeoutMs??3e4;if(!Number.isFinite(t)||t<=0)throw new TypeError("Web timeout must be a positive finite number");return{timeoutMs:t,fetchResource:e.fetch??globalThis.fetch,browser:e.browser??D(),autoBrowserFallback:e.autoBrowserFallback??!0}}a(se,"resolverSettings");function ae(e,t,r){let o;try{o=new URL(e)}catch(n){return we(e)?{kind:"failed",error:new TypeError(`Invalid HTTP source ${e}`,{cause:n})}:{kind:"not-handled"}}return o.protocol!=="http:"&&o.protocol!=="https:"?{kind:"not-handled"}:{kind:"resolved",resource:{source:o.href,read({signal:n}){return ie(o,t,r,n)}}}}a(ae,"resolveHttpSource");async function ie(e,t,r,o){let n=G(o,r.timeoutMs),i=!0;try{n.signal.throwIfAborted();let s=await r.fetchResource(e,{method:"GET",redirect:"follow",signal:n.signal,headers:{"User-Agent":"Mozilla/5.0 (compatible; Pi-LPT/1.0; +https://github.com/alexshpunt/sasha-pi)",Accept:"text/html,application/xhtml+xml,application/pdf,application/json,text/plain,image/*,*/*;q=0.8","Accept-Language":"en-US,en;q=0.5"}});if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);let l=s.headers.get("content-type")??void 0;if(ue(l)&&!de(e)){let h=await me(s,ne,n.signal);return[{type:"text",text:fe(e,s,l,h)}]}let c=new Uint8Array(await s.arrayBuffer());n.signal.throwIfAborted();let d={source:s.url.length===0?e.href:s.url,bytes:c,...l!==void 0&&{mediaType:l}};i=ge(c,l);let m=await t.convert(d,{signal:n.signal});if(n.signal.throwIfAborted(),r.autoBrowserFallback&&i&&q(m))throw new Error("HTTP read returned empty HTML content");return m}catch(s){if(o?.throwIfAborted(),!r.autoBrowserFallback||!i)throw s;n.dispose();try{return await ce(e,t,r,o)}catch(l){throw o?.throwIfAborted(),new Error(`HTTP read failed (${j(s)}) and browser fallback failed: ${j(l)}`,{cause:l})}}finally{n.dispose()}}a(ie,"readWebContent");async function ce(e,t,r,o){let n=G(o,r.timeoutMs);try{n.signal.throwIfAborted();let i=await le(e,t,r,n.signal);if(n.signal.throwIfAborted(),q(i))throw new Error("Browser read returned empty content");return i}finally{n.dispose()}}a(ce,"readBrowserContent");async function le(e,t,r,o){let n=await r.browser.load(e,{signal:o,timeoutMs:r.timeoutMs});return o.throwIfAborted(),t.convert({source:n.source,bytes:new TextEncoder().encode(n.html),mediaType:"text/html; charset=utf-8"},{signal:o})}a(le,"loadAndConvertBrowser");function ue(e){if(e===void 0)return!1;let t=e.split(";",1)[0]?.trim().toLowerCase()??"";return!(t.startsWith("text/")||t.startsWith("image/")||t==="application/json"||t.endsWith("+json")||t==="application/xml"||t.endsWith("+xml")||t==="application/xhtml+xml"||t==="application/pdf")}a(ue,"isUnsupportedBinaryMediaType");function de(e){return/\.(?:avif|bmp|gif|jpe?g|pdf|png|webp)$/iu.test(e.pathname)}a(de,"hasSupportedDocumentExtension");async function me(e,t,r){if(e.body===null)return new Uint8Array;let o=e.body.getReader(),n=[],i=0;try{for(;i<t;){r.throwIfAborted();let c=await o.read();if(c.done)break;let u=t-i,d=c.value.subarray(0,u);if(n.push(d),i+=d.length,c.value.length>u)break}}finally{await o.cancel().catch(()=>{})}let s=new Uint8Array(i),l=0;for(let c of n)s.set(c,l),l+=c.length;return s}a(me,"readBoundedBody");function fe(e,t,r,o){let n=["Unsupported binary response","Read cannot convert this Content-Type. Showing response metadata and a byte preview, not document text.",`URL: ${e.href}`,`HTTP: ${t.status} ${t.statusText}`.trimEnd(),`Content-Type: ${r??"unknown"}`],i=t.headers.get("content-disposition"),s=i===null?void 0:he(i);s!==void 0&&n.push(`Filename: ${s}`);let l=t.headers.get("content-length");l!==null&&n.push(`Content-Length: ${l}`);let c=[...t.headers].filter(([u])=>!pe(u)&&u!=="content-type"&&u!=="content-length").sort(([u],[d])=>u.localeCompare(d)).map(([u,d])=>`${u}: ${d}`);return c.length>0&&n.push("","Headers:",...c),n.push("",`Preview: first ${o.length} bytes (hex).`,be(o)),n.join(`
1
+ import{A as w,B as z,c as I,o as L,v as g,x as $,y as H,z as W}from"./chunk-3JBQYLJ4.js";import{a as _}from"./chunk-47SPPIXK.js";import{a as k,b as B}from"./chunk-VAXLSPPU.js";import{a as U}from"./chunk-2YO6RVX4.js";import{b as M,c as O}from"./chunk-MLFJU2US.js";import{d as C}from"./chunk-IZTOXSTR.js";import{a as T}from"./chunk-I3G6K7QU.js";import{a as x,b as P}from"./chunk-HSAGZWPO.js";import{J as E,ba as A}from"./chunk-OEEE5BLN.js";import{e as F}from"./chunk-2EY3LEZ7.js";import{a}from"./chunk-EI7MMDWY.js";import{constants as J}from"node:fs";import{access as K}from"node:fs/promises";import y from"node:path";var Q=["google-chrome-stable","google-chrome","chromium","chromium-browser"],X=["/usr/bin/google-chrome-stable","/usr/bin/google-chrome","/usr/bin/chromium","/usr/bin/chromium-browser","/opt/google/chrome/chrome"];function D(e={}){let t;return{async load(r,o){t??=v(e.executablePath,e.environment??process.env);let n=await t;o.signal?.throwIfAborted();let{chromium:i}=await import("playwright-core");o.signal?.throwIfAborted();let s=await i.launch({executablePath:n,headless:!0,chromiumSandbox:!1,timeout:o.timeoutMs}),l=a(()=>{s.close()},"closeOnAbort");o.signal?.addEventListener("abort",l,{once:!0});try{o.signal?.throwIfAborted();let c=await s.newPage(),u=await c.goto(r.href,{timeout:o.timeoutMs,waitUntil:"domcontentloaded"});if(u!==null&&!u.ok())throw new Error(`HTTP ${u.status()}: ${u.statusText()}`);await c.waitForLoadState("networkidle",{timeout:Math.min(o.timeoutMs,1500)}).catch(()=>{}),o.signal?.throwIfAborted(),await Z(c);let d={html:await c.content(),source:c.url()};return o.signal?.throwIfAborted(),d}catch(c){throw o.signal?.aborted===!0?ee(o.signal):new Error(`Browser read failed for ${r.href}: ${re(c)}`,{cause:c})}finally{o.signal?.removeEventListener("abort",l),await s.close().catch(()=>{})}}}}a(D,"createSystemBrowserHtmlLoader");async function v(e=process.env.PI_AGENT_IDE_BROWSER_PATH,t=process.env){if(e!==void 0&&e.trim().length>0){let r=y.resolve(e);if(await R(r))return r;throw new Error(`PI_AGENT_IDE_BROWSER_PATH is not executable: ${r}`)}for(let r of(t.PATH??"").split(y.delimiter).filter(Boolean))for(let o of Q){let n=y.join(r,o);if(await R(n))return n}for(let r of X)if(await R(r))return r;throw new Error("No system Chrome or Chromium executable was found. Install Chrome/Chromium or set PI_AGENT_IDE_BROWSER_PATH.")}a(v,"resolveSystemBrowserExecutable");async function Z(e){await e.locator("body *").evaluateAll(t=>{for(let r of t.toReversed()){let o=globalThis.getComputedStyle(r);(r.hasAttribute("hidden")||r.getAttribute("aria-hidden")==="true"||o.display==="none"||o.visibility==="hidden"||o.visibility==="collapse")&&r.remove()}})}a(Z,"removeHiddenElements");async function R(e){try{return await K(e,J.X_OK),!0}catch{return!1}}a(R,"isExecutable");function ee(e){return e.reason instanceof Error?e.reason:te()}a(ee,"abortReason");function te(){let e=new Error("The operation was aborted");return e.name="AbortError",e}a(te,"abortError");function re(e){return e instanceof Error?e.message:String(e)}a(re,"errorMessage");var N={protocol:M,apiVersion:O,id:"web-browser",setup(e){e.addCheck({id:"system-browser",title:"Browser web reads",async run(t){try{t.signal?.throwIfAborted();let r=t.workspace?await oe(t.workspace,t.signal):await F(await v(t.env.PI_AGENT_IDE_BROWSER_PATH,t.env),["--version"],t.cwd,t.env,t.signal);return t.signal?.throwIfAborted(),[r.ok?{status:"pass",message:"Chrome/Chromium is available",detail:r.detail}:{status:"warn",message:"Chrome/Chromium cannot start",detail:r.detail}]}catch(r){return t.signal?.throwIfAborted(),[{status:"warn",message:"Browser reads are unavailable",detail:r instanceof Error?r.message:String(r)}]}}})}};async function oe(e,t){if(!e.probeBrowser)throw new Error("Project owner does not provide a browser probe");return e.probeBrowser(t)}a(oe,"probeOwnerBrowser");var ne=4096;function V(e,t={}){let r=se(t);return{id:"web",async tryResolve(o,n){if(/^web:/iu.test(o)){let i=await t.owner?.tryResolve(o,n);return i!==void 0&&i.kind!=="not-handled"?i:{kind:"failed",error:new Error(`Target web execution is unavailable: ${o}`)}}return ae(o,e,r)}}}a(V,"createWebResolver");function se(e){let t=e.timeoutMs??3e4;if(!Number.isFinite(t)||t<=0)throw new TypeError("Web timeout must be a positive finite number");return{timeoutMs:t,fetchResource:e.fetch??globalThis.fetch,browser:e.browser??D(),autoBrowserFallback:e.autoBrowserFallback??!0}}a(se,"resolverSettings");function ae(e,t,r){let o;try{o=new URL(e)}catch(n){return we(e)?{kind:"failed",error:new TypeError(`Invalid HTTP source ${e}`,{cause:n})}:{kind:"not-handled"}}return o.protocol!=="http:"&&o.protocol!=="https:"?{kind:"not-handled"}:{kind:"resolved",resource:{source:o.href,read({signal:n}){return ie(o,t,r,n)}}}}a(ae,"resolveHttpSource");async function ie(e,t,r,o){let n=G(o,r.timeoutMs),i=!0;try{n.signal.throwIfAborted();let s=await r.fetchResource(e,{method:"GET",redirect:"follow",signal:n.signal,headers:{"User-Agent":"Mozilla/5.0 (compatible; Pi-LPT/1.0; +https://github.com/alexshpunt/sasha-pi)",Accept:"text/html,application/xhtml+xml,application/pdf,application/json,text/plain,image/*,*/*;q=0.8","Accept-Language":"en-US,en;q=0.5"}});if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);let l=s.headers.get("content-type")??void 0;if(ue(l)&&!de(e)){let h=await me(s,ne,n.signal);return[{type:"text",text:fe(e,s,l,h)}]}let c=new Uint8Array(await s.arrayBuffer());n.signal.throwIfAborted();let d={source:s.url.length===0?e.href:s.url,bytes:c,...l!==void 0&&{mediaType:l}};i=ge(c,l);let m=await t.convert(d,{signal:n.signal});if(n.signal.throwIfAborted(),r.autoBrowserFallback&&i&&q(m))throw new Error("HTTP read returned empty HTML content");return m}catch(s){if(o?.throwIfAborted(),!r.autoBrowserFallback||!i)throw s;n.dispose();try{return await ce(e,t,r,o)}catch(l){throw o?.throwIfAborted(),new Error(`HTTP read failed (${j(s)}) and browser fallback failed: ${j(l)}`,{cause:l})}}finally{n.dispose()}}a(ie,"readWebContent");async function ce(e,t,r,o){let n=G(o,r.timeoutMs);try{n.signal.throwIfAborted();let i=await le(e,t,r,n.signal);if(n.signal.throwIfAborted(),q(i))throw new Error("Browser read returned empty content");return i}finally{n.dispose()}}a(ce,"readBrowserContent");async function le(e,t,r,o){let n=await r.browser.load(e,{signal:o,timeoutMs:r.timeoutMs});return o.throwIfAborted(),t.convert({source:n.source,bytes:new TextEncoder().encode(n.html),mediaType:"text/html; charset=utf-8"},{signal:o})}a(le,"loadAndConvertBrowser");function ue(e){if(e===void 0)return!1;let t=e.split(";",1)[0]?.trim().toLowerCase()??"";return!(t.startsWith("text/")||t.startsWith("image/")||t==="application/json"||t.endsWith("+json")||t==="application/xml"||t.endsWith("+xml")||t==="application/xhtml+xml"||t==="application/pdf")}a(ue,"isUnsupportedBinaryMediaType");function de(e){return/\.(?:avif|bmp|gif|jpe?g|pdf|png|webp)$/iu.test(e.pathname)}a(de,"hasSupportedDocumentExtension");async function me(e,t,r){if(e.body===null)return new Uint8Array;let o=e.body.getReader(),n=[],i=0;try{for(;i<t;){r.throwIfAborted();let c=await o.read();if(c.done)break;let u=t-i,d=c.value.subarray(0,u);if(n.push(d),i+=d.length,c.value.length>u)break}}finally{await o.cancel().catch(()=>{})}let s=new Uint8Array(i),l=0;for(let c of n)s.set(c,l),l+=c.length;return s}a(me,"readBoundedBody");function fe(e,t,r,o){let n=["Unsupported binary response","Read cannot convert this Content-Type. Showing response metadata and a byte preview, not document text.",`URL: ${e.href}`,`HTTP: ${t.status} ${t.statusText}`.trimEnd(),`Content-Type: ${r??"unknown"}`],i=t.headers.get("content-disposition"),s=i===null?void 0:he(i);s!==void 0&&n.push(`Filename: ${s}`);let l=t.headers.get("content-length");l!==null&&n.push(`Content-Length: ${l}`);let c=[...t.headers].filter(([u])=>!pe(u)&&u!=="content-type"&&u!=="content-length").sort(([u],[d])=>u.localeCompare(d)).map(([u,d])=>`${u}: ${d}`);return c.length>0&&n.push("","Headers:",...c),n.push("",`Preview: first ${o.length} bytes (hex).`,be(o)),n.join(`
2
2
  `)}a(fe,"formatUnsupportedBinaryResponse");function he(e){let t=/filename\*=UTF-8''([^;]+)/iu.exec(e)?.[1];if(t!==void 0)try{return decodeURIComponent(t).replaceAll(/[\r\n]/gu,"")}catch{return t.replaceAll(/[\r\n]/gu,"")}return/filename=(?:"([^"]+)"|([^;]+))/iu.exec(e)?.slice(1).find(Boolean)?.trim()}a(he,"attachmentFilename");function pe(e){return["content-location","link","location","refresh","set-cookie"].includes(e.toLowerCase())}a(pe,"isSensitiveRedirectHeader");function be(e){if(e.length===0)return"(empty body)";let t=[];for(let r=0;r<e.length;r+=16){let o=e.subarray(r,r+16),n=[...o].map(s=>s.toString(16).padStart(2,"0")).join(" "),i=[...o].map(s=>s>=32&&s<=126?String.fromCodePoint(s):".").join("");t.push(`${r.toString(16).padStart(8,"0")} ${n.padEnd(47)} |${i}|`)}return t.join(`
3
3
  `)}a(be,"formatHexPreview");function ge(e,t){let r=t?.split(";",1)[0]?.trim().toLowerCase();if(r==="text/html"||r==="application/xhtml+xml")return!0;let o=new TextDecoder("utf8").decode(e.subarray(0,1024));return/^\u{FEFF}?\s*(?:<!doctype\s+html\b|<(?:article|body|head|html)\b)/iu.test(o)}a(ge,"isHtml");function q(e){return e.every(t=>t.type==="text"&&t.text.trim().length===0)}a(q,"isEmptyTextContent");function G(e,t){let r=new AbortController,o=a(()=>{r.abort(ye(e))},"abortFromParent"),n=setTimeout(()=>{r.abort(ve(t))},t);return n.unref(),e?.aborted===!0?o():e?.addEventListener("abort",o,{once:!0}),{signal:r.signal,dispose(){clearTimeout(n),e?.removeEventListener("abort",o)}}}a(G,"createOperationSignal");function we(e){return/^https?:/iu.test(e)}a(we,"claimsHttpScheme");function ye(e){return e?.reason instanceof Error?e.reason:Re()}a(ye,"abortReason");function Re(){let e=new Error("The operation was aborted");return e.name="AbortError",e}a(Re,"abortError");function ve(e){let t=new Error(`Web read timed out after ${e}ms`);return t.name="TimeoutError",t}a(ve,"timeoutError");function j(e){return e instanceof Error?e.message:String(e)}a(j,"errorMessage");function Y(e){return{id:"web",readResources:a(t=>t.path!==void 0&&/^https?:/iu.test(t.path)?[t.path]:[],"readResources"),async tryResolve(t,r){let o=t.path;if(o===void 0||!/^(?:https?:|web:)/iu.test(o))return{kind:"not-handled"};if(t.include!==void 0||t.exclude!==void 0)return{kind:"failed",error:new Error("File include/exclude globs do not apply to a web page.")};let n=Ae(t),i=await e.tryResolve(o,r);if(i.kind!=="resolved")return i;if(i.resource.read===void 0)return{kind:"failed",error:new Error(`Cannot read ${o}`)};let s=await i.resource.read({signal:r.signal});if(s.some(m=>m.type!=="text"))return{kind:"failed",error:new Error(`Web search requires text content: ${o}`)};let l=s.map(m=>m.type==="text"?m.text:"").join(`
4
4
  `),c=[],u=t.limit??50;for(let[m,h]of l.split(/\r\n|\n|\r/u).entries()){r.signal?.throwIfAborted();for(let f of h.matchAll(n)){if(f[0].length===0)continue;let p=f.index,b=p+f[0].length;if(!(t.wholeWord===!0&&(new RegExp("\\p{L}|\\p{N}|_","u").test(h[p-1]??"")||new RegExp("\\p{L}|\\p{N}|_","u").test(h[b]??"")))){if(c.length===u)return{kind:"resolved",payload:{source:o,matches:c,complete:!1}};c.push({source:o,lineNumber:m+1,startColumn:p,endColumn:b,matchedText:f[0],lineText:h})}}}let d=c.length===0&&$(t.query)?Se(l,o,t.query,r.signal):void 0;return{kind:"resolved",payload:{source:o,matches:c,complete:!0,...d===void 0?{}:{fuzzy:d}}}},toScriptData(t){let r=t;return{...I(r.matches,r.complete),...r.fuzzy===void 0?{}:{fuzzy:{...r.fuzzy,candidates:r.fuzzy.candidates.map(o=>w(o))}}}},renderResult(t,r,o){let n=t.details;return L(n.matches,n.complete,o,r.expanded,void 0,["Web page \xB7 read-only",...n.complete?[]:["Limit reached \xB7 incomplete results"]])},format(t){let r=t,o=r.matches.length===0?`No matches in ${r.source}`:`${r.matches.length}${r.complete?"":"+"} matches in ${r.source}${r.complete?"":" (limit reached)"}`,n=[o];r.fuzzy?.status==="skipped"&&n.push(`Possible-name fallback skipped: ${r.fuzzy.message}`),r.fuzzy?.candidates.length&&n.push("Possible names \u2014 spelling suggestions, not equivalent behavior.",...r.fuzzy.candidates.map(s=>z(w(s))));let i=Buffer.byteLength(o);for(let s of r.matches){let l=`${r.source}:${s.lineNumber}:${s.startColumn+1} ${Ee(s)}`;if(i+=Buffer.byteLength(l)+1,i>48*1024){n.push("Output shortened. Narrow the query or lower the limit.");break}n.push(l)}return{content:[{type:"text",text:n.join(`
@@ -1,4 +1,4 @@
1
- import{b as W}from"./chunk-X7CHS7JB.js";import"./chunk-JYITLCXC.js";import{a as M}from"./chunk-QC6VFZSB.js";import"./chunk-SF44YQCB.js";import{s as V}from"./chunk-4AEYLVSR.js";import"./chunk-PS2B6THP.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import{f as J}from"./chunk-YNOR4LIE.js";import{a as l}from"./chunk-EI7MMDWY.js";import{spawn as me}from"node:child_process";import{createHash as he}from"node:crypto";import{constants as N}from"node:fs";import{access as be,chmod as ye,copyFile as Ee,link as xe,mkdir as ve,mkdtemp as K,rm as X,realpath as U,stat as Y,writeFile as Pe}from"node:fs/promises";import{homedir as Q,tmpdir as Ae}from"node:os";import{delimiter as Se,isAbsolute as _e,join as x,relative as q,resolve as Z,sep as I}from"node:path";var ee="1.8.5",je=`https://github.com/lightonai/next-plaid/releases/download/v${ee}`,ke={"linux:x64":{name:"colgrep-x86_64-unknown-linux-gnu.tar.xz",sha256:"532e1da739f6b5d489cdaefd20c5918fa1bb0ff9f456c89098eb49a6379ae205"},"linux:arm64":{name:"colgrep-aarch64-unknown-linux-gnu.tar.xz",sha256:"90ccb4132ca34c5202ca3d9789e722446dfed85b3be6247321ee55e1a909f34b"},"darwin:x64":{name:"colgrep-x86_64-apple-darwin.tar.xz",sha256:"6f23777e87a7cee9c31846514bc0a70736df71f201abfff6aedb51dc27ec6c2a"},"darwin:arm64":{name:"colgrep-aarch64-apple-darwin.tar.xz",sha256:"2cd013c820a6ba9d4066c58ce7e6b75ea614dd77a9a18a88836e005f1ef126bc"},"win32:x64":{name:"colgrep-x86_64-pc-windows-msvc.zip",sha256:"4f8f240ccbf17740e70d36b798904cf592622719bf11e9c1c86dc01cf9f2c42d"}};function C(n){if(/^[a-z][a-z\d+.-]*:\/\//iu.test(n))throw new Error("Semantic search supports local projects only");return Z(n)}l(C,"localProject");function re(n){let e=n.HOME||n.USERPROFILE||Q();return process.platform==="win32"?x(n.LOCALAPPDATA||x(e,"AppData","Local"),"pi-agent-ide","bin"):x(n.XDG_DATA_HOME||x(e,".local","share"),"pi-agent-ide","bin")}l(re,"managedDirectory");function A(){return process.platform==="win32"?"colgrep.exe":"colgrep"}l(A,"binaryName");async function S(n,e,t,r){return r.signal?.throwIfAborted(),new Promise((a,u)=>{let d=me(n,[...e],{cwd:t,env:r.env??process.env,signal:r.signal,windowsHide:!0,stdio:["ignore","pipe","pipe"]}),g="",w="";d.stdout.setEncoding("utf8"),d.stderr.setEncoding("utf8"),d.stdout.on("data",f=>{g=(g+f).slice(-4e6),r.onProgress?.(f)}),d.stderr.on("data",f=>{w=(w+f).slice(-64e3),r.onProgress?.(f)}),d.on("error",u),d.on("close",f=>f===0?a(g):u(new Error(`${n} exited with code ${f}: ${w.trim()}`)))})}l(S,"run");async function te(n={}){let e=n.env??process.env,t=[...(e.PATH??"").split(Se).filter(Boolean).map(r=>x(r,A())),x(re(e),A()),x(e.CARGO_HOME||x(e.HOME||e.USERPROFILE||Q(),".cargo"),"bin",A())];for(let r of new Set(t)){n.signal?.throwIfAborted();try{await be(r,process.platform==="win32"?N.F_OK:N.X_OK);let a=await S(r,["--version"],process.cwd(),{...n,signal:n.signal?AbortSignal.any([n.signal,AbortSignal.timeout(5e3)]):AbortSignal.timeout(5e3),onProgress:void 0});if(/^colgrep\s+\d+\.\d+\.\d+/u.test(a))return r}catch{n.signal?.throwIfAborted()}}}l(te,"findColgrep");async function O(n,e={}){let t=C(n),r=await te(e);if(!r)return{usable:!1};try{let a=await S(r,["status","--color","never"],t,{...e,signal:e.signal?AbortSignal.any([e.signal,AbortSignal.timeout(5e3)]):AbortSignal.timeout(5e3),onProgress:void 0}),u=/^Index:\s+(.+)\s*$/mu.exec(a)?.[1]?.trim();return!u||!(await Y(u)).isDirectory()?{usable:!1,executable:r}:{usable:!0,executable:r,indexPath:u}}catch{return e.signal?.throwIfAborted(),{usable:!1,executable:r}}}l(O,"inspectProject");async function Ie(n){let e=ke[`${process.platform}:${process.arch}`];if(!e)throw new Error(`No ColGREP binary for ${process.platform}/${process.arch}; install colgrep yourself`);n.onProgress?.(`Downloading ColGREP ${ee}
1
+ import{b as W}from"./chunk-X7CHS7JB.js";import"./chunk-JYITLCXC.js";import{a as M}from"./chunk-3BRGWFEI.js";import"./chunk-SF44YQCB.js";import{s as V}from"./chunk-3JBQYLJ4.js";import"./chunk-PS2B6THP.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import{f as J}from"./chunk-YNOR4LIE.js";import{a as l}from"./chunk-EI7MMDWY.js";import{spawn as me}from"node:child_process";import{createHash as he}from"node:crypto";import{constants as N}from"node:fs";import{access as be,chmod as ye,copyFile as Ee,link as xe,mkdir as ve,mkdtemp as K,rm as X,realpath as U,stat as Y,writeFile as Pe}from"node:fs/promises";import{homedir as Q,tmpdir as Ae}from"node:os";import{delimiter as Se,isAbsolute as _e,join as x,relative as q,resolve as Z,sep as I}from"node:path";var ee="1.8.5",je=`https://github.com/lightonai/next-plaid/releases/download/v${ee}`,ke={"linux:x64":{name:"colgrep-x86_64-unknown-linux-gnu.tar.xz",sha256:"532e1da739f6b5d489cdaefd20c5918fa1bb0ff9f456c89098eb49a6379ae205"},"linux:arm64":{name:"colgrep-aarch64-unknown-linux-gnu.tar.xz",sha256:"90ccb4132ca34c5202ca3d9789e722446dfed85b3be6247321ee55e1a909f34b"},"darwin:x64":{name:"colgrep-x86_64-apple-darwin.tar.xz",sha256:"6f23777e87a7cee9c31846514bc0a70736df71f201abfff6aedb51dc27ec6c2a"},"darwin:arm64":{name:"colgrep-aarch64-apple-darwin.tar.xz",sha256:"2cd013c820a6ba9d4066c58ce7e6b75ea614dd77a9a18a88836e005f1ef126bc"},"win32:x64":{name:"colgrep-x86_64-pc-windows-msvc.zip",sha256:"4f8f240ccbf17740e70d36b798904cf592622719bf11e9c1c86dc01cf9f2c42d"}};function C(n){if(/^[a-z][a-z\d+.-]*:\/\//iu.test(n))throw new Error("Semantic search supports local projects only");return Z(n)}l(C,"localProject");function re(n){let e=n.HOME||n.USERPROFILE||Q();return process.platform==="win32"?x(n.LOCALAPPDATA||x(e,"AppData","Local"),"pi-agent-ide","bin"):x(n.XDG_DATA_HOME||x(e,".local","share"),"pi-agent-ide","bin")}l(re,"managedDirectory");function A(){return process.platform==="win32"?"colgrep.exe":"colgrep"}l(A,"binaryName");async function S(n,e,t,r){return r.signal?.throwIfAborted(),new Promise((a,u)=>{let d=me(n,[...e],{cwd:t,env:r.env??process.env,signal:r.signal,windowsHide:!0,stdio:["ignore","pipe","pipe"]}),g="",w="";d.stdout.setEncoding("utf8"),d.stderr.setEncoding("utf8"),d.stdout.on("data",f=>{g=(g+f).slice(-4e6),r.onProgress?.(f)}),d.stderr.on("data",f=>{w=(w+f).slice(-64e3),r.onProgress?.(f)}),d.on("error",u),d.on("close",f=>f===0?a(g):u(new Error(`${n} exited with code ${f}: ${w.trim()}`)))})}l(S,"run");async function te(n={}){let e=n.env??process.env,t=[...(e.PATH??"").split(Se).filter(Boolean).map(r=>x(r,A())),x(re(e),A()),x(e.CARGO_HOME||x(e.HOME||e.USERPROFILE||Q(),".cargo"),"bin",A())];for(let r of new Set(t)){n.signal?.throwIfAborted();try{await be(r,process.platform==="win32"?N.F_OK:N.X_OK);let a=await S(r,["--version"],process.cwd(),{...n,signal:n.signal?AbortSignal.any([n.signal,AbortSignal.timeout(5e3)]):AbortSignal.timeout(5e3),onProgress:void 0});if(/^colgrep\s+\d+\.\d+\.\d+/u.test(a))return r}catch{n.signal?.throwIfAborted()}}}l(te,"findColgrep");async function O(n,e={}){let t=C(n),r=await te(e);if(!r)return{usable:!1};try{let a=await S(r,["status","--color","never"],t,{...e,signal:e.signal?AbortSignal.any([e.signal,AbortSignal.timeout(5e3)]):AbortSignal.timeout(5e3),onProgress:void 0}),u=/^Index:\s+(.+)\s*$/mu.exec(a)?.[1]?.trim();return!u||!(await Y(u)).isDirectory()?{usable:!1,executable:r}:{usable:!0,executable:r,indexPath:u}}catch{return e.signal?.throwIfAborted(),{usable:!1,executable:r}}}l(O,"inspectProject");async function Ie(n){let e=ke[`${process.platform}:${process.arch}`];if(!e)throw new Error(`No ColGREP binary for ${process.platform}/${process.arch}; install colgrep yourself`);n.onProgress?.(`Downloading ColGREP ${ee}
2
2
  `);let t=await fetch(`${je}/${e.name}`,{signal:n.signal});if(!t.ok)throw new Error(`ColGREP download failed: HTTP ${t.status}`);let r=Buffer.from(await t.arrayBuffer());if(he("sha256").update(r).digest("hex")!==e.sha256)throw new Error("ColGREP download checksum mismatch");let a=await K(x(Ae(),"pi-colgrep-"));try{let u=x(a,e.name);await Pe(u,r),await S("tar",["-xf",u,"-C",a],a,{...n,onProgress:void 0});let d=e.name.replace(/\.(?:tar\.xz|zip)$/u,""),g=x(a,d,A()),w=re(n.env??process.env);await ve(w,{recursive:!0});let f=x(w,A()),y=await K(x(w,".install-"));try{let o=x(y,A());await Ee(g,o,N.COPYFILE_EXCL),process.platform!=="win32"&&await ye(o,493);try{await xe(o,f)}catch(s){if(s.code!=="EEXIST")throw s}}finally{await X(y,{recursive:!0,force:!0})}return await S(f,["--version"],a,{...n,onProgress:void 0}),f}finally{await X(a,{recursive:!0,force:!0})}}l(Ie,"installColgrep");async function ne(n,e={}){let t=C(n),r=await te(e)??await Ie(e);e.onProgress?.(`Indexing project with ColGREP
3
3
  `),await S(r,["init","--yes","--color","never"],t,e);let a=await O(t,e);if(!a.usable)throw new Error("ColGREP did not create a usable project index");return a}l(ne,"indexProject");async function ae(n,e,t={}){let r=C(n);if(!e.trim())throw new Error("A semantic search query is required");let a=await O(r,t);if(!a.usable||!a.executable)throw new Error("No usable semantic index for this project");let u=t.limit??15;if(!Number.isInteger(u)||u<1||u>100)throw new Error("Invalid result limit");let d,g=!1;if(t.path!==void 0){if(!t.path.trim()||/^[a-z][a-z\d+.-]*:\/\//iu.test(t.path))throw new Error("Invalid semantic search scope");let s=Z(r,t.path),h=await U(r),b;try{b=await U(s)}catch{throw new Error("Invalid semantic search scope: path does not exist")}let i=l((E,c)=>{let v=process.platform==="win32"?E.toLowerCase():E,T=process.platform==="win32"?c.toLowerCase():c;return T===v||T.startsWith(v.endsWith(I)?v:v+I)},"inside");if(!i(r,s)||!i(h,b))throw new Error("Invalid semantic search scope: outside project");let p=await Y(b);if(!p.isFile()&&!p.isDirectory())throw new Error("Invalid semantic search scope: not a file or directory");g=p.isFile(),d=q(r,s)||"."}let w=["search","--json","--yes","--color","never","-k",String(u)];for(let s of V(t.include))w.push("--include",s);for(let s of V(t.exclude))w.push("--exclude",s);w.push("--",e),d!==void 0&&w.push(d);let f=await S(a.executable,w,r,t),y=JSON.parse(f);if(!Array.isArray(y))throw new Error("Invalid ColGREP search output");let o=new Map;for(let s of y){if(!s||typeof s!="object"||!("unit"in s))throw new Error("Invalid ColGREP search output");let{unit:h}=s;if(!h||typeof h!="object"||!("file"in h)||typeof h.file!="string")throw new Error("Invalid ColGREP search output");let b=r.endsWith(I)?r:r+I,i=_e(h.file)&&h.file.startsWith(b)?q(r,h.file):h.file,p="matches"in s?s.matches:void 0;if(p!==void 0&&!Array.isArray(p))throw new Error("Invalid ColGREP search output");let E=p?.length?p:[h];for(let c of E){if(!c||typeof c!="object"||!("line"in c)||typeof c.line!="number"||!("end_line"in c)||typeof c.end_line!="number"||!("name"in c)||!Number.isInteger(c.line)||!Number.isInteger(c.end_line)||c.line<1||c.end_line<c.line||typeof c.name!="string")throw new Error("Invalid ColGREP search output");let v=o.get(i)??new Set;v.add(`${c.line}-${c.end_line}`),o.set(i,v)}}if(!o.size)return{text:"No semantic search results.",files:[]};if(g){let s=[];for(let[h,b]of o){let i=[...b];s.push(...i.slice(0,15).map(p=>`${h}:${p}`)),i.length>15&&s.push(`${i.length-15} additional retrieved ranges omitted`)}return{text:`Approximate ranges (read before editing):
4
4
  ${s.join(`
@@ -0,0 +1,53 @@
1
+ import{a as tt}from"./chunk-VNG4QPPT.js";import{d as et}from"./chunk-BW3XONMZ.js";import{a as Ze}from"./chunk-I3G6K7QU.js";import{a as Ye,b as Ke}from"./chunk-HSAGZWPO.js";import{B as He,g as ve,k as De,m as Ue,ma as ce,na as Ge,ta as Xe,u as Ie,va as Qe,x as ze}from"./chunk-OEEE5BLN.js";import{a as je}from"./chunk-2QCE7GOV.js";import{a as i}from"./chunk-EI7MMDWY.js";import{createHash as Kt}from"node:crypto";import Ot from"node:path";import{DEFAULT_MAX_BYTES as Nt,DEFAULT_MAX_LINES as qt,truncateHead as Jt}from"@earendil-works/pi-coding-agent";var G={bytes:Nt,lines:qt,pixels:4e6,images:20,imageBytes:20*1024*1024};async function K(e,n="",t,r={}){let s=typeof n=="string"?[n]:n,a=[],c=e.flatMap(R=>{if(R.type!=="text")return[];let O=s.find(v=>v.length>0&&R.text.endsWith(v));return O?(a.push(O),[R.text.slice(0,-O.length)]):[R.text]}).join(`
2
+ `),d=a.join(""),g=r.limitText===!1?{truncated:!1,content:c,firstLineExceedsLimit:!1}:Jt(c,{maxBytes:G.bytes,maxLines:G.lines}),k=[],V;if(g.truncated&&t!==void 0)try{V=await t(c)}catch{k.push("[Full output could not be saved. Narrow the request to inspect it.]")}g.truncated&&k.push(`[Output truncated: useful content is limited to ${G.bytes} bytes / ${G.lines} lines. Narrow the request or read a smaller source range.]`),V!==void 0&&k.push(`[Full output: ${JSON.stringify(V)}. Read with offset/limit, or read ${JSON.stringify("raw:"+V)} for byte ranges. Available until this runtime is disposed.]`);let B=e.filter(R=>R.type==="image"),N=B.slice(0,G.images),W=[],F=Math.floor(G.pixels/Math.max(1,N.length)),Q=0,U=B.length-N.length,q;for(let[R,O]of N.entries())try{q??=await import("@napi-rs/canvas");let{createCanvas:v,loadImage:pe}=q,se=Buffer.from(O.data,"base64"),z=await pe(se),ee=Math.min(1,Math.sqrt(F/(z.width*z.height))),o=Math.min(F,Math.max(1,Math.floor(z.height*ee))),u=Math.min(Math.floor(F/o),Math.max(1,Math.floor(z.width*ee))),p=se,h=O.mimeType;if(ee<1||Q+p.byteLength>G.imageBytes){let f=v(u,o);f.getContext("2d").drawImage(z,0,0,u,o),p=await f.encode("png"),h="image/png"}if(Q+p.byteLength>G.imageBytes){U++;continue}Q+=p.byteLength,W.push({type:"image",data:p.toString("base64"),mimeType:h}),ee<1&&k.push(`[Image ${R+1} resized from ${z.width}x${z.height} to ${u}x${o} to fit the shared media budget.]`)}catch{U++,k.push(`[Image ${R+1} could not be decoded and was not returned.]`)}return U>0&&k.push(`[${U} images omitted from the result. Read fewer frames or a smaller image region.]`),{text:g.firstLineExceedsLimit?Wt(c):g.content,textTruncated:g.truncated,images:W,notices:k,metadataSuffix:d,fullOutput:V}}i(K,"limitIdeOutput");function Wt(e){let n=0,t=0;for(let r of e){let s=Buffer.byteLength(r);if(n+s>G.bytes)break;n+=s,t+=r.length}return e.slice(0,t)}i(Wt,"bytePrefix");import _e from"node:path";var E={type:"object",properties:{path:{type:"string"},line:{allOf:[{type:"integer"}]},text:{type:"string"},lineText:{type:"string",description:"Complete containing lines without the final line ending; absent when unavailable."},id:{type:"string"}},required:["path","line","text"],additionalProperties:!1};function ge(e,n){if(n===void 0||!_e.isAbsolute(e))return e;let t=_e.relative(n,e);return t.length>0&&!t.startsWith("..")&&!_e.isAbsolute(t)?t:e}i(ge,"scriptMatchPath");var le=/^<system-result\b[^>]*><uuid>([a-f\d-]{36})<\/uuid><\/system-result>\n?/u;function L(e){let n=le.exec(e)?.[1];return n===void 0?void 0:`RESULT#${n}`}i(L,"resultReference");function oe(e=E,n={}){return{anyOf:[{type:"object",properties:{id:{type:"string"},complete:{type:"boolean"},matches:{type:"array",items:e},...n},required:["complete","matches"],additionalProperties:!1},{type:"string",description:"Readable result of a search whose results are not text matches, such as a provider's object list."}]}}i(oe,"matchListSchema");function he(e,n=!1){let t=x(e.outcome)&&e.outcome.status===(n?"partial":"success")?e.outcome.data:void 0,r=L(e.shown);if(r===void 0||!x(t)||t.kind!=="matches"||!Array.isArray(t.matches)||typeof t.complete!="boolean")return;let s=Ce(t.matches,e.cwd);if(s!==void 0)return{...typeof t.target=="string"&&{id:r},complete:t.complete&&t.truncated!==!0,matches:s}}i(he,"matchList");function Ce(e,n){let t=[];for(let r of e){if(!x(r))return;let s=Me(r,n);if(s===void 0)return;t.push({match:s,data:r})}return t}i(Ce,"matchEntries");function Me(e,n){let{source:t,matchedText:r,target:s,range:a}=e,c=x(a)?a.startLine:void 0;if(!(typeof t!="string"||typeof r!="string"||typeof c!="number"))return{path:ge(t,n),line:c,text:r,...typeof e.lineText=="string"&&{lineText:e.lineText},...typeof s=="string"&&{id:s}}}i(Me,"scriptMatch");function x(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(x,"record");var Te={type:"object",properties:{text:{type:"string"},id:{type:"string"}},required:["text"],additionalProperties:!1},we={schema:oe({...E,properties:{...E.properties,captures:{type:"object",additionalProperties:{type:"array",items:Te}}},required:[...E.required,"captures"]}),project(e){let n=he(e);if(n===void 0)return e.shown;let t=[];for(let{match:r,data:s}of n.matches){let a={};for(let[c,d]of Object.entries(x(s.captures)?s.captures:{})){if(!Array.isArray(d))return e.shown;let g=[];for(let k of d){let V=x(k)?Me(k,e.cwd):void 0;if(V===void 0)return e.shown;g.push({text:V.text,...V.id!==void 0&&{id:V.id}})}a[c]=g}t.push({...r,captures:a})}return{...n.id!==void 0&&{id:n.id},complete:n.complete,matches:t}}};var Ee={type:"object",description:"Value returned by a resource provider, such as a computer action outcome.",additionalProperties:!0};function ue(e){let n=xe(e)?e.metadata:void 0,t=xe(n)?n.semanticAction:void 0,r=xe(t)?t.script:void 0;return xe(r)&&!Array.isArray(r)?r:void 0}i(ue,"providerValue");function xe(e){return e!==null&&typeof e=="object"}i(xe,"record");var P={schema:{anyOf:[{type:"string",description:"RESULT#<uuid> that selects the text the edit produced; pass it to a source parameter. Null when the edit selects no text or its selection cannot be verified, even if the edit succeeded. Check the failure block; read the file before further edits when no selection is verified."},Ee]},project:i(e=>ue(e.details)??Ft(e),"project"),failed:i(({details:e})=>ue(e),"failed")},rt={schema:Ee,project:i(({details:e})=>ue(e)??null,"project"),failed:i(({details:e})=>ue(e),"failed")};function Ft({outcome:e,shown:n}){let t=nt(e)&&e.status==="success"?e.data:void 0;return!nt(t)||typeof t.target!="string"?null:L(n)??null}i(Ft,"editSelection");function nt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(nt,"record");var ot=P;var st=rt;var at={schema:{type:"string",description:'Complete unified diff of the two sources; "" when they are equal.'},project({details:e,shown:n}){let t=it(e)?e.comparison:void 0;return!it(t)||typeof t.equal!="boolean"||typeof t.diff!="string"?n:t.equal?"":t.diff}};function it(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(it,"record");function be(e){return{schema:{type:"array",items:{type:"string"}},project:i(({outcome:n})=>{let t=ct(n)?n.data:void 0,r=ct(t)&&(e===void 0||t.kind===e)?t.files:void 0;return Array.isArray(r)&&r.every(s=>typeof s=="string")?r:null},"project")}}i(be,"pathListValue");function ct(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(ct,"record");var lt=be("files"),ut={...lt,failed:lt.project};var dt=P;var ke={schema:oe(E,{fallback:{type:"object",properties:{mode:{type:"string",enum:["regex","words"]},id:{type:"string"},complete:{type:"boolean"},matches:{type:"array",items:E}},required:["mode","complete","matches"],additionalProperties:!1},notices:{type:"array",items:{type:"string"}},editWarning:{type:"string"}}),project(e){return pt(e)??e.shown},failed(e){return pt(e,!0)}};function pt(e,n=!1){let t=he(e,n);if(t===void 0)return;let r=t.matches.map(({match:g})=>({...g})),s=x(e.outcome)&&x(e.outcome.data)?e.outcome.data:{},a=s.fallback==="regex"||s.fallback==="words"?s.fallback:void 0,c=Array.isArray(s.notices)&&s.notices.every(g=>typeof g=="string")?s.notices:[],d={...t.id!==void 0&&{id:t.id},complete:t.complete,matches:r};return{...a===void 0?d:{complete:!0,matches:[],fallback:{mode:a,...d}},...c.length===0?{}:{notices:c},...typeof s.editWarning=="string"?{editWarning:s.editWarning}:{}}}i(pt,"projectSearch");var Oe={type:"array",items:E},ft={schema:{anyOf:[{type:"object",description:"calls: references in matches, callers in incoming, callees in outgoing.",properties:{id:{type:"string"},complete:{type:"boolean"},matches:Oe,incoming:Oe,outgoing:Oe},required:["id","complete","matches","incoming","outgoing"],additionalProperties:!1},...oe({...E,properties:{...E.properties,captures:{type:"object",properties:{name:{type:"array",items:Te}},additionalProperties:!1}}},{candidateLimits:{type:"array",description:"Workspace symbol candidate limits reached before scope filtering.",items:{type:"object",properties:{server:{type:"string"},limit:{type:"integer"}},required:["server","limit"],additionalProperties:!1}},skipped:{type:"array",description:"Query candidates with no declaration anchor; the result is incomplete.",items:{type:"object",properties:{name:{type:"string"},path:{type:"string"}},required:["name","path"],additionalProperties:!1}}}).anyOf]},project(e){let n=x(e.outcome)&&e.outcome.status==="success"?e.outcome.data:void 0;if(x(n)&&n.kind==="custom")return vt(n.value,e)??e.shown;if(x(n)&&Array.isArray(n.matches)&&n.matches.some(r=>x(r)&&x(r.captures)))return we.project(e);let t=ke.project(e);return!x(t)||!x(n)?t:{...t,...Array.isArray(n.candidateLimits)&&{candidateLimits:n.candidateLimits.flatMap(r=>x(r)&&typeof r.server=="string"&&typeof r.limit=="number"?[{server:r.server,limit:r.limit}]:[])},...Array.isArray(n.skipped)&&{skipped:n.skipped.flatMap(r=>x(r)&&typeof r.name=="string"&&typeof r.source=="string"?[{name:r.name,path:ge(r.source,e.cwd)}]:[])}}}};function vt(e,n){if(!x(e))return;let t=[e.matches,e.incoming,e.outgoing].map(c=>Dt(c,n.cwd)),[r,s,a]=t;if(!(typeof e.target!="string"||typeof e.complete!="boolean"||r===void 0||s===void 0||a===void 0))return{id:e.target,complete:e.complete&&t.every(c=>c?.complete===!0),matches:r.matches,incoming:s.matches,outgoing:a.matches}}i(vt,"callGraph");function Dt(e,n){if(!x(e)||e.kind!=="matches"||!Array.isArray(e.matches))return;let t=Ce(e.matches,n);if(t!==void 0)return{complete:e.truncated!==!0,matches:t.map(({match:r})=>({...r}))}}i(Dt,"places");var mt=P;var yt={type:"object",properties:{type:{const:"image"},data:{type:"string"},mimeType:{type:"string"}},required:["type","data","mimeType"]},xt={type:"object",description:"Text, exactly as requested, without notices. Pass the value or its id to a source parameter.",properties:{text:{type:"string"},id:{type:"string"}},required:["text","id"]},gt=[xt,{type:"object",properties:{bytes:{type:"string"}},required:["bytes"]},{type:"object",properties:{entries:{type:"array",items:{type:"string"}}},required:["entries"]},yt,{type:"object",description:"Several images, such as sequence frames, in source order.",properties:{type:{const:"images"},images:{type:"array",items:yt}},required:["type","images"]}],$e={schema:{anyOf:[...gt,{type:"array",description:"For an array path: the value of each path in order, null when it failed.",items:{anyOf:[...gt,{type:"null"}]}}]},project(e){let n=wt(e.content);if(e.script!==!0)return kt(n)??e.shown;let t=St(e.outcome);return M(t)&&t.kind==="list"?ht(t,e,n):bt(t,L(e.shown),n)??e.shown},failed(e){let n=M(e.outcome)?e.outcome.data:void 0;if(!(e.script!==!0||!M(n)||n.kind!=="list"))return ht(n,e,wt(e.content))},failureReason({outcome:e}){return!M(e)||!M(e.data)||e.data.kind!=="list"?void 0:(Array.isArray(e.errors)?e.errors:[]).flatMap(t=>M(t)&&typeof t.message=="string"?[t.message]:[]).join(`
3
+ `)||void 0}},Le={schema:xt,project:$e.project};function ht(e,n,t){let r=Array.isArray(e.items)?e.items:[],s=0;return r.map(a=>{let c=St(a);if(!M(c))return null;let d=Ut(c),g=t.slice(s,s+d);s+=d;let k=Pe(c),V=k===void 0?void 0:n.publish?.(a,k);return bt(c,V,g)??null})}i(ht,"listValue");function bt(e,n,t){if(!M(e))return;let r=kt(t);if(r!==void 0)return r;if(e.kind==="bytes"&&Array.isArray(e.bytes))return{bytes:Buffer.from(e.bytes.filter(zt)).toString("base64")};if(e.kind==="text"&&Array.isArray(e.entries))return{entries:e.entries.filter(a=>typeof a=="string")};let s=Pe(e);return s===void 0||n===void 0?void 0:{text:s,id:n}}i(bt,"sourceValue");function Pe(e){if(e.kind==="text")return typeof e.text=="string"?e.text:(Array.isArray(e.lines)?e.lines:[]).map(t=>M(t)&&typeof t.content=="string"&&typeof t.lineEnding=="string"?t.content+t.lineEnding:"").join("");if(e.kind==="native"&&Array.isArray(e.blocks))return e.blocks.flatMap(t=>M(t)&&typeof t.text=="string"?[t.text]:[]).join(`
4
+ `);if(e.kind==="resources"&&Array.isArray(e.resources))return e.resources.flatMap(t=>{let r=M(t)?Pe(t):void 0;return r===void 0?[]:[r]}).join(`
5
+ `)}i(Pe,"textOf");function Ut(e){return!M(e)||e.kind!=="native"||!Array.isArray(e.blocks)?0:e.blocks.filter(t=>M(t)&&t.type==="image").length}i(Ut,"imageCount");function wt(e){return e.filter(n=>n.type==="image").map(({data:n,mimeType:t})=>({type:"image",data:n,mimeType:t}))}i(wt,"imageBlocks");function kt(e){let[n]=e;if(n!==void 0)return e.length===1?{...n}:{type:"images",images:e.map(t=>({...t}))}}i(kt,"imageValue");function St(e){return M(e)&&e.status==="success"?e.data:void 0}i(St,"successData");function zt(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=255}i(zt,"isByte");function M(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(M,"record");var Vt=P;var At=be();var Ht={type:"object",properties:{output:{type:"string"},truncated:{type:"boolean"},full_output_path:{type:"string"},exit_code:{type:"number"},wall_time_seconds:{type:"number"},session:{type:"string"}},required:["output","truncated","full_output_path","wall_time_seconds","session"],additionalProperties:!1},de={schema:Ht,project:i(({outcome:e})=>Gt(e)??null,"project"),succeeded:i(({outcome:e})=>{let n=Rt(e);return n!==void 0&&!(n.status==="failed"&&n.exit_code===void 0)},"succeeded")};function Gt(e){let n=Rt(e);if(n!==void 0)return{output:Xt(n),truncated:n.truncated,full_output_path:n.full_output_path,...n.exit_code===void 0?{}:{exit_code:n.exit_code},wall_time_seconds:n.wall_time_seconds,session:n.source}}i(Gt,"terminalOutcome");function Xt({output:e,output_ranges:n}){let[t,r]=n;if(n.length!==2||t===void 0||r===void 0)return e;let s=Buffer.from(e,"utf8"),a=t.end-t.start,c=r.start-t.end;return`${s.subarray(0,a).toString("utf8")}
6
+
7
+ [... ${c} bytes omitted ...]
8
+
9
+ ${s.subarray(a).toString("utf8")}`}i(Xt,"markedOutput");function Rt(e){let n=Be(e)?e.data:void 0;if(!Be(n))return;let{output:t,truncated:r,full_output_path:s,output_ranges:a,exit_code:c}=n,{wall_time_seconds:d,source:g,status:k}=n;if(typeof t!="string"||typeof r!="boolean"||typeof s!="string"||!Array.isArray(a)||typeof d!="number"||typeof g!="string"||typeof k!="string"||c!==void 0&&typeof c!="number")return;let V=a.flatMap(B=>Be(B)&&typeof B.start=="number"&&typeof B.end=="number"?[{start:B.start,end:B.end}]:[]);return{output:t,truncated:r,full_output_path:s,output_ranges:V,...c===void 0?{}:{exit_code:c},wall_time_seconds:d,source:g,status:k}}i(Rt,"shellRecord");function Be(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(Be,"record");var jt={schema:{type:"string"},project:i(({shown:e})=>e,"project")};var It=P;var _t=P;var Qt={read:$e,outline:Le,diagnostics:Le,search:ke,ast_search:we,lsp_search:ft,file_search:ut,semantic_search:At,replace:Vt,insert:dt,delete:st,write:_t,copy:ot,move:mt,undo:It,diff:at,bash:de,powershell:de,remote_bash:de,remote_powershell:de};function Ne(e){return Qt[e]??jt}i(Ne,"scriptValueOf");function Ct(e){let n=e.schema.anyOf;return{anyOf:[...Array.isArray(n)?n:[e.schema],{type:"null"}]}}i(Ct,"nullableValueSchema");var Se=class{static{i(this,"CodemodeCallLedger")}#e=new Map;record(n,t,r){let s=this.#e.get(n)??{calls:new Map,failures:new Map};s.calls.set(t.id,t),r!==void 0&&s.failures.set(t.id,{...Mt(t),...r}),this.#e.set(n,s)}updateReason(n,t,r){let s=this.#e.get(n)?.failures,a=s?.get(t);a!==void 0&&s?.set(t,{...a,reason:r})}recordBatch(n,t){let r=this.#e.get(n);if(r!==void 0)for(let s of t){let a=r.calls.get(s.id);a===void 0||r.failures.has(s.id)||s.errors.length===0&&s.effect!=="unknown"||r.failures.set(s.id,{...Mt(a),reason:["The edit was accepted, then its editor batch failed when it was saved.",...s.errors.map(c=>c.message)].join(`
10
+ `),...s.changed===void 0?{}:{changed:s.changed},...s.unknown===void 0?{}:{unknown:s.unknown}})}}take(n){let t=this.#e.get(n);return this.#e.delete(n),t===void 0||t.failures.size===0?void 0:Yt(t.calls.size,[...t.calls.keys()].flatMap(r=>t.failures.get(r)??[]))}clear(){this.#e.clear()}};function Mt(e){return{tool:e.tool,...e.source===void 0?{}:{source:e.source}}}i(Mt,"identity");function Yt(e,n){let t=[`${n.length} of ${e} IDE call${e===1?"":"s"} failed:`];for(let r of n){t.push(`- ${r.tool}${r.source===void 0?"":` ${r.source}`}`);let s=[...r.changed?.length?[`Changed: ${r.changed.join(", ")}.`]:[],...r.unknown?.length?[`Effect unknown: ${r.unknown.join(", ")}.`]:[]];s.length>0&&t.push(` ${s.join(" ")} Do not repeat this edit blindly; Read the files first.`);for(let a of r.reason.split(`
11
+ `))t.push(a===""?"":` ${a}`)}return t.join(`
12
+ `)}i(Yt,"formatFailures");function Ve(e,n=t=>t){let t=Z(e)?e.data:void 0,r=Z(t)&&Array.isArray(t.files)?t.files:[],s=i(d=>r.flatMap(g=>Z(g)&&g.effect===d&&typeof g.source=="string"?[n(g.source)]:[]),"sources"),a=s("applied"),c=s("unknown");return{...a.length>0&&{changed:a},...c.length>0&&{unknown:c}}}i(Ve,"fileEffects");function Tt(e,n=t=>t){let t=Z(e)?e.editorBatchResults:void 0;return Array.isArray(t)?t.flatMap(r=>(Z(r)&&Z(r.data)&&Array.isArray(r.data.operations)?r.data.operations:[]).flatMap(a=>Z(a)&&typeof a.id=="string"&&typeof a.effect=="string"&&Array.isArray(a.errors)?[{id:a.id,effect:a.effect,errors:a.errors.flatMap(c=>Z(c)&&typeof c.message=="string"?[{message:c.message}]:[]),...Ve({data:{files:a.files}},n)}]:[])):[]}i(Tt,"batchOperations");function Z(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(Z,"record");function Et(e,n,t,r){if(!X(n)||n.status!=="success"||!X(n.data))return[];let s=n.data,a=X(t)&&X(t.metadata)?t.metadata:void 0,c=a&&X(a.semanticAction)?a.semanticAction:void 0;return e==="write"&&c?.kind==="direct-mutation"&&c.ok===!0&&c.effect==="applied"&&Array.isArray(c.files)?c.files.filter(d=>typeof d=="string").map(d=>`write ${r(d)}: saved`):e==="write"&&c===void 0&&X(t)&&t.effect==="not-applied"&&Array.isArray(t.results)?t.results.flatMap(d=>{let g=X(d)&&X(d.data)?d.data:void 0;return g?.ok===!0&&typeof g.path=="string"?[`write ${r(g.path)}: unchanged`]:[]}):s.effect!=="applied"?[]:e==="copy"||e==="move"?c?.kind!=="file-operation"||c.ok!==!0||c.effect!=="applied"||typeof c.path!="string"||typeof c.target!="string"?[]:[`${e} ${r(c.path)} \u2192 ${r(c.target)}: applied`]:e!=="write"||c!==void 0||!Array.isArray(s.files)?[]:s.files.flatMap(d=>X(d)&&d.effect==="applied"&&typeof d.source=="string"&&!/^(?:shell|debug):/u.test(d.source)?[`write ${r(d.source)}: saved`]:[])}i(Et,"fileReceipts");function X(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(X,"record");var $t=200,Zt=new Set(["write","replace","insert","delete","copy","move","undo","stage","unstage"]),Re={read:["path"],outline:["path"],search:["path"],ast_search:["path"],lsp_search:["path"],file_search:["path"],replace:["path"],insert:["path"],delete:["path"],write:["path"],copy:["path","target"],move:["path","target"],undo:["file"],diff:["before","after"]},en={bash:["command"],powershell:["command"],remote_bash:["command"],remote_powershell:["command"],debug:["program"],stage:["file"],unstage:["file"]};function Lt(e,n){let t=i(a=>{if(Array.isArray(a))return a.flatMap(t);let c=ce(a);if(c!==void 0)return t(c);if(a!==null&&typeof a=="object"&&"path"in a)return t(a.path);if(typeof a!="string"||a==="")return[];let d=L(a)??a.replaceAll(/\s+/gu," ");return[d.length>$t?`${d.slice(0,$t)}\u2026`:d]},"labels"),s=(en[e]??Re[e]??["path"]).map(a=>t(n[a]).join(", ")).filter(a=>a!=="");return s.length===0?void 0:s.join(" \u2192 ")}i(Lt,"sourceLabel");function Ae(e,n){let t=n.endsWith(Ot.sep)?n:n+Ot.sep;return e.startsWith(t)&&e.length>t.length?e.slice(t.length):e}i(Ae,"displayPath");async function tn(e,n){if(typeof e!="object"||e===null||!("editorBatches"in e)||!("editorBatchResults"in e))return;let{editorBatches:t,editorBatchResults:r,...s}=e,a=JSON.stringify({editorBatches:t,editorBatchResults:r});if(Buffer.byteLength(a)<=24*1024)return;let c=await n(a).catch(()=>{});return{...s,editorBatchReceipts:{truncated:!0,...c===void 0?{}:{fullOutput:c}}}}i(tn,"boundEditorBatchReceipts");function Dr(e,n={}){let t=Xe(e),r=Qe(e),s=new Set,a=new Map,c=new ze,d=i(o=>n.resourceOutput?c.save(o):c.saveFile(o),"saveFullOutput"),g=new Map,k=i(o=>Kt("sha256").update(JSON.stringify(o)).digest("hex"),"signature"),V=i(async(o,u)=>{let p=k(u),h=g.get(o);if(h&&(h.source===p||k(await h.content)===p))return h.content;let f=K(u,"",d).then(l=>[{type:"text",text:l.text+(l.notices.length?`
13
+
14
+ ${l.notices.join(`
15
+ `)}`:"")},...l.images]);return g.set(o,{source:p,content:f}),f},"limitError");Ze(e,{protocol:Ye,apiVersion:Ke,id:"ide-output-retention",setup(o){o.setOutputSaver(d),n.resourceOutput&&o.addResolver({priority:-1e3,resolver:{id:"ide-output-retention",async tryResolve(u,p){let h=await c.resolver.tryResolve(u,p);return h.kind==="failed"?{kind:"not-handled"}:h}}})}}),e.on("session_shutdown",()=>c.dispose());let B=i((o,u)=>{if(o==="message_end"){let h=u;return e.on("message_end",async(f,l)=>{let y=await h(f,l),m=y?.message??f.message;return m.role!=="toolResult"||!m.isError||!s.has(m.toolName)||m.content.some(b=>b.type==="text"&&b.text.startsWith("<system-result"))?y:{...y,message:{...m,content:await V(m.toolCallId,m.content)}}})}let p=u;return o!=="tool_call"?e.on(o,p):e.on("tool_call",async(h,f)=>{let l=s.has(h.toolName);if(l&&N.has(h.toolCallId))return;let y=await p(h,f);if(!y?.block||!l||y.terminate===!0)return y;let m=await K([{type:"text",text:y.reason??"Tool execution was blocked"}],"",d);N.set(h.toolCallId,{...N.get(h.toolCallId),reason:m.text+(m.notices.length?`
16
+
17
+ ${m.notices.join(`
18
+ `)}`:"")})})},"on"),N=new Map,W=new Map,F=new Se,Q=new Set,U=new Map,q=new Map,R=new Map,O=new Map,v=new Map,pe=i(()=>{N.clear(),W.clear(),F.clear(),Q.clear(),U.clear(),R.clear(),O.clear()},"clearCalls"),se=i(()=>{q.clear(),v.clear(),g.clear(),pe()},"clear");e.on("session_start",se),e.on("session_shutdown",se),e.on("agent_end",pe),e.on("before_agent_start",o=>{o.systemPromptOptions.sections[n.promptSection??"ide_results"]="Direct IDE calls return readable text; the system-result reference is not file content. Pass an unchanged result or its UUID to compose tools. Codemode calls return the inline value types. Text Read values hold exactly the requested text without notices; bytes are base64 and directory names end with /. Search match lists hold every found match with whole text and a one-based line; AST captures are keyed by metavariable name without $. An id selects its result, match or capture; pass that value or its RESULT# id to a source or selector parameter. A result selects only its returned ranges, not surrounding preview context. Sources without selections have no id. A false complete means incomplete coverage, so an empty list proves nothing. A broadened Search keeps the original matches empty and places hints in fallback; refine the query before editing them. LSP calls put references in matches and whole caller/callee declarations in incoming/outgoing. Diff is complete, or empty for equal sources. Edits return the id of verified output text or null when no text is selected; filesystem/text delete returns null. A failed IDE call normally resolves to null and the script continues; a multi-source Read keeps its array with null at failed sources, and a provider action keeps its receipt. Terminal exit_code is absent while running; a nonzero exit is a value, not a tool failure. Check the Codemode result's failed calls and effects before retrying. Pi can still reject invalid or blocked calls. Omit optional arguments rather than passing null. Store/load retains values in the session; references cannot be reused across sessions."}),e.on("tool_execution_start",o=>{o.parentToolCallId!==void 0&&q.set(o.toolCallId,q.get(o.parentToolCallId)??o.parentToolCallId)}),e.on("tool_execution_end",o=>{let u=U.get(o.toolCallId);U.delete(o.toolCallId);let p=o.result;if(u&&p!==null&&typeof p=="object"&&"content"in p&&Array.isArray(p.content)){let f=p.content.filter(l=>l!==null&&typeof l=="object"&&"type"in l&&l.type==="text"&&"text"in l&&typeof l.text=="string").map(l=>l.text).join(`
19
+ `).replace(le,"");if(f!==u.original){let l=u.original?f.indexOf(u.original):-1,y=l>=0&&l===f.lastIndexOf(u.original),m=u.filtered?y?f.slice(0,l)+u.reason+f.slice(l+u.original.length):u.reason:f;F.updateReason(u.parent,o.toolCallId,m)}}Q.delete(o.toolCallId)&&p!==null&&typeof p=="object"&&Object.assign(p,{structuredContent:null})}),B("tool_call",(o,u)=>{if(!s.has(o.toolName))return;let p=a.get(o.toolName)?.(),h=p?je(o.input,p,{cwd:u.cwd,sourceFields:[...Re[o.toolName]??[],"path"],resolveSource:i(l=>t.source(l,u.cwd,!0),"resolveSource")}):o.input;W.set(o.toolCallId,Lt(o.toolName,h));let f={...h};try{for(let l of Re[o.toolName]??[]){let y=f[l];if(y!==void 0)if(o.toolName==="diff"&&ce(y)===void 0&&y!==null&&typeof y=="object"&&"path"in y)f[l]={...y,path:t.source(y.path,u.cwd,!0)};else if(o.toolName==="read"){let m=i(b=>{let A=t.source(b,u.cwd,!0);if(Array.isArray(A)||typeof A=="string"&&A.startsWith("RESULT#")){let w=ce(b)??b;if(typeof w=="string"&&!w.startsWith("SEARCH#"))return L(w)??(w.startsWith("RESULT#")?w:`RESULT#${w}`)}if(!Array.isArray(A))return A;let j=t.resolve(A,u.cwd);return t.register(j.targets,u.cwd,j.complete)},"readSource");f[l]=Array.isArray(y)?y.map(m):m(y)}else f[l]=t.source(y,u.cwd,["write","insert","delete"].includes(o.toolName)?"live":!1)}for(let l of et(o.toolName))f[l]!==void 0&&(f[l]=Ge(t,f[l],u.cwd));for(let l of["text","content"]){let y=f[l];if(typeof y=="string"&&(y.trimStart().startsWith("<system-result")||/<system-result\b[^>]*><uuid>[a-f\d-]{36}<\/uuid><\/system-result>/iu.test(y)))return{block:!0,reason:"A system result reference is not file content. Do not insert it into a file."}}Object.assign(o.input,f)}catch(l){let y=l instanceof Error?l.message:String(l);return l instanceof He&&N.set(o.toolCallId,{reason:y,details:{code:l.code,effect:l.effect}}),{block:!0,reason:y}}});let z=i(o=>{s.add(o.name),a.set(o.name,()=>o.parameters);let u={},p=Object.getOwnPropertyDescriptors(o),h=i(m=>{tt(e.events,m);let b=je(m,o.parameters);return o.prepareArguments?o.prepareArguments(b):b},"prepareArguments");p.prepareArguments={value:h,enumerable:!0,configurable:!0,writable:!0},p.outputSchema={value:Ct(Ne(o.name)),enumerable:!0,configurable:!0,writable:!0};let f=i(async(...m)=>{let b=N.get(m[0]);if(b!==void 0)return N.delete(m[0]),{content:[{type:"text",text:b.reason}],details:b.details??{},isError:!0};let A=!(["read","outline"].includes(o.name)&&q.has(m[0])),j=i(async te=>{let C=await o.execute(m[0],m[1],te,m[3],m[4]).catch(async D=>{let ne=await K([{type:"text",text:D instanceof Error?D.message:String(D)}],"",d);throw ne.notices.length===0?D:new Error(ne.text+`
20
+
21
+ ${ne.notices.join(`
22
+ `)}`,{cause:D})}),Y=C.structuredContent,$=typeof Y=="object"&&Y!==null&&"data"in Y?Y.data:void 0;typeof $=="object"&&$!==null&&"effect"in $&&($.effect==="applied"||$.effect==="unknown"||$.effect==="not-applied")&&De($.effect);let T=await K(C.content,Pt(C.details),d,{limitText:A}),ie={type:"text",text:T.text+T.metadataSuffix+(T.notices.length?`
23
+
24
+ ${T.notices.join(`
25
+ `)}`:"")};return{...C,content:[T.textTruncated?ie:Ie(C.content,ie),...T.images]}},"run"),w=ve(o.name);if(w===void 0)return j(m[2]);let J=W.get(m[0])??Lt(o.name,m[1])??m[4].cwd;return await Ue(o.name,J,w,m[2],Zt.has(o.name)||o.annotations?.readOnlyHint===!1?"unknown":void 0,j)},"execute");p.execute={value:f,enumerable:!0,configurable:!0,writable:!0};let l=o.renderCall;if(l){let m=i((b,A,j)=>l(nn(o.name,b),A,j),"renderCall");p.renderCall={value:m,enumerable:!0,configurable:!0,writable:!0}}let y=o.renderResult;if(y){let m=i((b,A,j,w)=>y({...b,content:b.content.map(J=>J.type==="text"?{...J,text:J.text.replace(le,"")}:J)},A,j,w),"renderer");p.renderResult={value:m,enumerable:!0,configurable:!0,writable:!0}}Object.defineProperties(u,p),e.registerTool(u)},"registerTool"),ee=i(()=>{e.on("context",async o=>({messages:await Promise.all(o.messages.map(async u=>u.role!=="toolResult"||!u.isError||!s.has(u.toolName)||u.content.some(p=>p.type==="text"&&p.text.startsWith("<system-result"))?u:{...u,content:await V(u.toolCallId,u.content)}))})),e.on("tool_result",async(o,u)=>{if(o.toolName==="codemode"){t.refreshAll();let S=new Set(o.content.flatMap(_=>_.type==="image"?[_.data]:[])),I=(v.get(o.toolCallId)??[]).filter(_=>!S.has(_.data));v.delete(o.toolCallId);for(let[_,Bt]of q)Bt===o.toolCallId&&q.delete(_);let H=o.content.filter(_=>_.type==="text"&&_.text.startsWith(`
26
+
27
+ ---
28
+
29
+ # Guide:`));F.recordBatch(o.toolCallId,Tt(o.details,_=>Ae(_,u.cwd)));let re=F.take(o.toolCallId),Je=await tn(o.details,d),fe=R.get(o.toolCallId)??[];R.delete(o.toolCallId);let We=O.get(o.toolCallId)??[];O.delete(o.toolCallId);let Fe=o.content.filter(_=>!H.includes(_)),me=We.length?await K([{type:"text",text:We.join(`
30
+ `)}],"",d):void 0,ae=await K([...Fe,...I,...fe.length?[{type:"text",text:`
31
+
32
+ ${fe.join(`
33
+ `)}`}]:[]],"",d),ye=re===void 0?void 0:await K([{type:"text",text:re}],"",d);return{...Je===void 0?{}:{details:Je},content:[...ae.textTruncated?[{type:"text",text:ae.text}]:[...Fe.filter(_=>_.type==="text"),...fe.length?[{type:"text",text:`
34
+
35
+ ${fe.join(`
36
+ `)}`}]:[]],...ae.images,...ae.notices.length?[{type:"text",text:`
37
+
38
+ ${ae.notices.join(`
39
+ `)}`}]:[],...H,...me===void 0?[]:[{type:"text",text:`
40
+
41
+ ${me.text}${me.notices.length?`
42
+
43
+ ${me.notices.join(`
44
+ `)}`:""}`}],...ye===void 0?[]:[{type:"text",text:`
45
+
46
+ ${ye.text}${ye.notices.length?`
47
+
48
+ ${ye.notices.join(`
49
+ `)}`:""}`}]]}}if(!s.has(o.toolName))return;let p=o.content.filter(S=>S.type==="text").map(S=>S.text).join(`
50
+ `),h=o.structuredContent,f=h!==null&&typeof h=="object"&&"data"in h?h:{status:o.isError?"error":"success",data:h},l=f.data,y=l!==null&&typeof l=="object"&&"effect"in l&&l.effect==="applied"&&"targetUnavailable"in l&&typeof l.targetUnavailable=="string"?l.targetUnavailable:void 0,m=y===void 0||p.includes(y)?p:`${p}
51
+
52
+ This result has no verified text selection: ${y}
53
+ Read/Search the file before the next edit; do not repeat the applied edit.`,b=qe(f),A=o.isError||f.status==="error"||f.status==="partial",j=t.publish(f,m,u.cwd,b);r.keep(j,u.cwd,o.toolName==="read"&&!A?o.content.filter(S=>S.type==="image"):[]);let w=q.get(o.toolCallId);q.delete(o.toolCallId);let J={shown:j,outcome:f,content:o.content,details:o.details,cwd:u.cwd,script:w!==void 0,publish:i((S,I)=>L(t.publish(S,I,u.cwd,qe(S))),"publish")},te=Ne(o.toolName),C,Y,$;try{C=A&&te.succeeded?.(J)!==!0,Y=C?te.failed?.(J):te.project(J),C&&w!==void 0&&($=te.failureReason?.(J))}catch(S){let I=W.get(o.toolCallId);if(W.delete(o.toolCallId),w===void 0)return;let H=S instanceof Error?S.message:String(S);return F.record(w,{id:o.toolCallId,tool:o.toolName,...I===void 0?{}:{source:I}},{reason:H,...Ve(f,re=>Ae(re,u.cwd))}),Q.add(o.toolCallId),{content:[{type:"text",text:H}]}}let T=Y===j?void 0:Y,ie=W.get(o.toolCallId);W.delete(o.toolCallId);let D=m.replace(le,"");if(w!==void 0){if(!C){let I=Et(o.toolName,f,o.details,H=>Ae(H,u.cwd));I.length&&O.set(w,[...O.get(w)??[],...I])}if(o.toolName==="search"&&!C&&l!==null&&typeof l=="object"){let I="notices"in l&&Array.isArray(l.notices)?l.notices.filter(re=>typeof re=="string"):[],H="editWarning"in l&&typeof l.editWarning=="string"?[l.editWarning]:[];R.set(w,[...new Set([...R.get(w)??[],...I,...H])])}let S=o.content.filter(I=>I.type==="image");S.length&&v.set(w,[...v.get(w)??[],...S]),F.record(w,{id:o.toolCallId,tool:o.toolName,...ie===void 0?{}:{source:ie}},C?{reason:$??D,...Ve(f,I=>Ae(I,u.cwd))}:void 0),C&&U.set(o.toolCallId,{parent:w,original:D,reason:$??D,filtered:$!==void 0}),(T===null||C&&T===void 0)&&Q.add(o.toolCallId)}let ne={type:"text",text:A?D:j};return{content:[w===void 0&&!A?Ie(o.content,ne):ne,...o.content.filter(S=>S.type!=="text")],...T!=null&&(w!==void 0||T!==L(j))&&{structuredContent:T}}})},"finalize");return{api:{...e,on:B,registerTool:z},finalize:ee}}i(Dr,"createIdeTextResults");function Pt(e){if(e===null||typeof e!="object")return[];let n="outputNotice"in e&&typeof e.outputNotice=="string"?[e.outputNotice]:[];if("resources"in e&&Array.isArray(e.resources)){let t=e.resources;for(let r of t)r!==null&&typeof r=="object"&&"details"in r&&n.push(...Pt(r.details))}return n}i(Pt,"outputNotices");function nn(e,n){let t=i(s=>{if(Array.isArray(s))return s.map(t);let a=ce(s);return a!==void 0?a:s!==null&&typeof s=="object"&&"path"in s?{...s,path:t(s.path)}:typeof s!="string"?s:L(s)??s},"label"),r={...n};for(let s of Re[e]??[])n[s]!==void 0&&Object.assign(r,{[s]:t(n[s])});return r}i(nn,"displaySources");function qe(e){if(e===null||typeof e!="object"||!("data"in e))return[];let n=e.data;return n===null||typeof n!="object"?[]:"resources"in n&&Array.isArray(n.resources)?n.resources.flatMap(r=>qe({data:r})):"files"in n&&Array.isArray(n.files)?n.files.flatMap(r=>r!==null&&typeof r=="object"&&"source"in r&&typeof r.source=="string"&&/^(?:shell|debug):/u.test(r.source)?[r.source]:[]):"source"in n&&typeof n.source=="string"?[n.source]:[]}i(qe,"resultResources");export{Dr as a};
@@ -1 +1 @@
1
- import{a as b}from"./chunk-MMQIHUU5.js";import{a as E}from"./chunk-4DLSZYUO.js";import{a as S,b as g}from"./chunk-VPBGKSFI.js";import"./chunk-T5PXAYWC.js";import{b as y}from"./chunk-V2LLMBTA.js";import{b as u,j as c,k as w,l as k,m as v}from"./chunk-S4GTWS2J.js";import{a as l,b as f,c as P,d as O,f as R}from"./chunk-YSGPCH52.js";import{c as h}from"./chunk-XHFAV2NI.js";import"./chunk-PBMHSK6J.js";import{c as m}from"./chunk-OA26FH5G.js";import"./chunk-BXGMMZT3.js";import"./chunk-4AEYLVSR.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import"./chunk-BW3XONMZ.js";import"./chunk-GTZOIJCH.js";import"./chunk-JXULBI4S.js";import"./chunk-2YO6RVX4.js";import"./chunk-MLFJU2US.js";import"./chunk-JY63UUC2.js";import"./chunk-I3G6K7QU.js";import"./chunk-HSAGZWPO.js";import"./chunk-PS2B6THP.js";import"./chunk-XEPCURYZ.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-2EY3LEZ7.js";import"./chunk-YNOR4LIE.js";import"./chunk-JKM4E5VB.js";import"./chunk-XQMNVPNS.js";import"./chunk-IRLWXPL4.js";import"./chunk-ZC65Z3CK.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import"./chunk-KINKBPPX.js";import{a}from"./chunk-EI7MMDWY.js";import T from"node:path";import I from"node:path";function C(d){let s=a(o=>{let t=d.resolve(o);if(!t)throw new c("UNSUPPORTED_SOURCE",o,"not-applied");return t},"resolve");return{transport:a(o=>E(d,o),"transport"),async readText(o,t){let e=s(o);return(await e.backend.read(e.location.path,{signal:t})).bytes.toString("utf8")},async readSnapshot(o,t){let e=s(o),r=await e.backend.read(e.location.path,{signal:t});return{content:r.bytes.toString("utf8"),version:r.version}},async readBytes(o,t){let e=s(o);return(await e.backend.read(e.location.path,{signal:t})).bytes},async exists(o,t){let e=s(o);try{return await e.backend.stat(e.location.path,{signal:t}),!0}catch(r){if(r instanceof c&&r.code==="ENOENT")return!1;throw r}},async isFile(o,t){let e=s(o);return(await e.backend.stat(e.location.path,{signal:t})).kind==="file"},async entries(o,t){let e=s(o);return(await e.backend.list(e.location.path,{signal:t})).map(r=>({name:r.name,kind:r.kind==="symlink"?"other":r.kind}))},async filesContaining(o,t,e,r){let n=s(o),i=await n.backend.execute("rg",[...P(t,e)],n.location.path,{signal:r});if(i.exitCode!==0&&i.exitCode!==1)throw new Error(`Listing files that contain ${t} on ${n.location.target} failed: ${i.stderr.toString("utf8")}`);return O(i.stdout.toString("utf8")).map(p=>u(n.location.target,I.posix.join(n.location.path,p)).source)}}}a(C,"createSshLspWorkspaceOwner");async function U(d){let s=new v(await k(w(h()))),o=C(s);await R(d,{workspace:a(t=>t.startsWith("ssh://")?o:void 0,"workspace"),async loadRegistry(t,e,r){r?.throwIfAborted();let n=s.resolve(t);if(n)return f.fromPackageDir(t,{signal:r,layerAccess:S(s,r),includeGlobal:!e,requireBuiltInEvidence:e,recipes:l,recipeEvidence:a(i=>g(n.backend,n.location.path,i,r),"recipeEvidence"),executableAvailability:a(i=>y(n.backend,n.location.path,i,r),"executableAvailability")});if(t.includes("://"))throw new c("UNSUPPORTED_SOURCE",t,"not-applied");return f.fromPackageDir(e?t:process.env.PI_AGENT_IDE_CONFIG_DIR??t,{signal:r,includeGlobal:!e,requireBuiltInEvidence:e,recipes:l})},async resolveProject(t,e,r){if(r?.throwIfAborted(),t.startsWith("ssh://")||e.startsWith("ssh://")){let i=s.resolve(t,e);if(!i)throw new c("UNSUPPORTED_SOURCE",t,"not-applied");let p=s.resolve(e);if(p&&p.location.target!==i.location.target)throw new c("UNSUPPORTED_SOURCE",t,"not-applied");return b(i.backend,i.location.path,p?.location.path,"lsp-servers",l,r)}let n=await m(e,t,"lsp-servers",l,r);return n===void 0?void 0:{cwd:n,external:n!==T.resolve(e)}}})}a(U,"registerOwnedLsp");export{U as default};
1
+ import{a as b}from"./chunk-MMQIHUU5.js";import{a as E}from"./chunk-4DLSZYUO.js";import{a as S,b as g}from"./chunk-VPBGKSFI.js";import"./chunk-T5PXAYWC.js";import{b as y}from"./chunk-V2LLMBTA.js";import{b as u,j as c,k as w,l as k,m as v}from"./chunk-S4GTWS2J.js";import{a as l,b as f,c as P,d as O,f as R}from"./chunk-UN3XLVPR.js";import{c as h}from"./chunk-XHFAV2NI.js";import"./chunk-PBMHSK6J.js";import{c as m}from"./chunk-OA26FH5G.js";import"./chunk-BXGMMZT3.js";import"./chunk-3JBQYLJ4.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import"./chunk-BW3XONMZ.js";import"./chunk-GTZOIJCH.js";import"./chunk-JXULBI4S.js";import"./chunk-2YO6RVX4.js";import"./chunk-MLFJU2US.js";import"./chunk-JY63UUC2.js";import"./chunk-I3G6K7QU.js";import"./chunk-HSAGZWPO.js";import"./chunk-PS2B6THP.js";import"./chunk-XEPCURYZ.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-2EY3LEZ7.js";import"./chunk-YNOR4LIE.js";import"./chunk-JKM4E5VB.js";import"./chunk-XQMNVPNS.js";import"./chunk-IRLWXPL4.js";import"./chunk-ZC65Z3CK.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import"./chunk-KINKBPPX.js";import{a}from"./chunk-EI7MMDWY.js";import T from"node:path";import I from"node:path";function C(d){let s=a(o=>{let t=d.resolve(o);if(!t)throw new c("UNSUPPORTED_SOURCE",o,"not-applied");return t},"resolve");return{transport:a(o=>E(d,o),"transport"),async readText(o,t){let e=s(o);return(await e.backend.read(e.location.path,{signal:t})).bytes.toString("utf8")},async readSnapshot(o,t){let e=s(o),r=await e.backend.read(e.location.path,{signal:t});return{content:r.bytes.toString("utf8"),version:r.version}},async readBytes(o,t){let e=s(o);return(await e.backend.read(e.location.path,{signal:t})).bytes},async exists(o,t){let e=s(o);try{return await e.backend.stat(e.location.path,{signal:t}),!0}catch(r){if(r instanceof c&&r.code==="ENOENT")return!1;throw r}},async isFile(o,t){let e=s(o);return(await e.backend.stat(e.location.path,{signal:t})).kind==="file"},async entries(o,t){let e=s(o);return(await e.backend.list(e.location.path,{signal:t})).map(r=>({name:r.name,kind:r.kind==="symlink"?"other":r.kind}))},async filesContaining(o,t,e,r){let n=s(o),i=await n.backend.execute("rg",[...P(t,e)],n.location.path,{signal:r});if(i.exitCode!==0&&i.exitCode!==1)throw new Error(`Listing files that contain ${t} on ${n.location.target} failed: ${i.stderr.toString("utf8")}`);return O(i.stdout.toString("utf8")).map(p=>u(n.location.target,I.posix.join(n.location.path,p)).source)}}}a(C,"createSshLspWorkspaceOwner");async function U(d){let s=new v(await k(w(h()))),o=C(s);await R(d,{workspace:a(t=>t.startsWith("ssh://")?o:void 0,"workspace"),async loadRegistry(t,e,r){r?.throwIfAborted();let n=s.resolve(t);if(n)return f.fromPackageDir(t,{signal:r,layerAccess:S(s,r),includeGlobal:!e,requireBuiltInEvidence:e,recipes:l,recipeEvidence:a(i=>g(n.backend,n.location.path,i,r),"recipeEvidence"),executableAvailability:a(i=>y(n.backend,n.location.path,i,r),"executableAvailability")});if(t.includes("://"))throw new c("UNSUPPORTED_SOURCE",t,"not-applied");return f.fromPackageDir(e?t:process.env.PI_AGENT_IDE_CONFIG_DIR??t,{signal:r,includeGlobal:!e,requireBuiltInEvidence:e,recipes:l})},async resolveProject(t,e,r){if(r?.throwIfAborted(),t.startsWith("ssh://")||e.startsWith("ssh://")){let i=s.resolve(t,e);if(!i)throw new c("UNSUPPORTED_SOURCE",t,"not-applied");let p=s.resolve(e);if(p&&p.location.target!==i.location.target)throw new c("UNSUPPORTED_SOURCE",t,"not-applied");return b(i.backend,i.location.path,p?.location.path,"lsp-servers",l,r)}let n=await m(e,t,"lsp-servers",l,r);return n===void 0?void 0:{cwd:n,external:n!==T.resolve(e)}}})}a(U,"registerOwnedLsp");export{U as default};
@@ -1 +1 @@
1
- import{v as b,w as x}from"./chunk-4AEYLVSR.js";import{a as h}from"./chunk-EI7MMDWY.js";import R from"node:path";import{pathToFileURL as M}from"node:url";function q(e,t="this path"){return e<=1e3?`Search ${t} with limit: ${String(e)}`:`Read a bounded window of ${t}, then Search that result`}h(q,"searchCompactionHint");function z(e,t){let r=new Map;for(let n of e){let s=r.get(n.source)??[];s.push(n),r.set(n.source,s)}let a=new Set,c=e.length,i=[...r].sort(([n,s],[m,d])=>d.length-s.length||n.localeCompare(m));for(let[n,s]of i){if(c<=t)break;a.add(n),c-=s.length-1}let u=[],o=t,l=[...r].sort(([n],[s])=>Number(a.has(n))-Number(a.has(s))||n.localeCompare(s));for(let[n,s]of l){if(!a.has(n)){if(s.length>o)continue;u.push({kind:"detailed",source:n,matches:s}),o-=s.length;continue}if(o<1)continue;o--;let m=new Map;for(let y of s){let p=m.get(y.lineText);p===void 0?m.set(y.lineText,{matchCount:1,first:y}):p.matchCount++}let d=[...m].sort(([y,p],[N,P])=>P.matchCount-p.matchCount||y.localeCompare(N)).map(([y,p])=>({text:y,...p})),C=r.size===1?Math.min(o,d.length-1):0,w=d.slice(0,1+C);o-=C,u.push({kind:"compacted",source:n,matchCount:s.length,uniqueLineCount:m.size,groups:w})}return u.sort((n,s)=>n.source.localeCompare(s.source)),{files:u}}h(z,"planSearchPresentation");function T(e,t,r,a,c,i=50){let u=z(t,i),o=new Set(t.map(n=>n.source)).size,l=u.files.map(n=>n.kind==="detailed"?k(n.source,n.matches,a):{path:S(n.source,a),link:M(n.source).href,matchCount:n.matchCount,uniqueLineCount:n.uniqueLineCount,groups:n.groups.map(({text:s,matchCount:m})=>({text:s,matchCount:m})),lines:[]});return{...c!==void 0&&{sessionId:c},query:e,matchCount:t.length,fileCount:o,...u.files.length<o?{omittedFileCount:o-l.length,omittedMatchCount:t.length-l.reduce((n,s)=>n+s.matchCount,0)}:{},complete:r,files:l}}h(T,"createSearchToolDetails");function H(e,t){return{fileCount:new Set(e.flatMap(r=>r.matches.map(a=>a.source))).size,groups:e.map(r=>{let c=T(r.identifier,r.matches.slice(0,b.previewMatches),r.complete,t).files.map(i=>{let u=i.lines.map(o=>{let l=Math.max(0,(o.ranges[0]?.from??0)-64),n=Math.min(o.text.length,(o.ranges[0]?.to??0)+64),s=l>0?"\u2026":"",m=o.ranges.filter(d=>d.from>=l&&d.to<=n).map(d=>({from:d.from-l+s.length,to:d.to-l+s.length}));return{...o,text:s+o.text.slice(l,n)+(n<o.text.length?"\u2026":""),ranges:m,matchCount:m.length}});return{...i,lines:u,matchCount:u.reduce((o,l)=>o+l.matchCount,0)}});return{identifier:r.identifier,files:c}})}}h(H,"createFuzzyPresentation");function L(e){return g(e)&&f(e.fileCount)&&Array.isArray(e.groups)&&e.groups.every(t=>g(t)&&typeof t.identifier=="string"&&Array.isArray(t.files)&&t.files.every(F))}h(L,"isFuzzyPresentation");function W(e){if(!g(e)||typeof e.query!="string"||!f(e.matchCount)||!f(e.fileCount)||e.omittedFileCount!==void 0&&!f(e.omittedFileCount)||e.omittedMatchCount!==void 0&&!f(e.omittedMatchCount)||typeof e.complete!="boolean"||e.sessionId!==void 0&&typeof e.sessionId!="string"||e.fuzzy!==void 0&&!x(e.fuzzy)||e.fuzzyPresentation!==void 0&&!L(e.fuzzyPresentation)||!Array.isArray(e.files)||!e.files.every(F))return!1;let t=e.files;return e.fileCount===t.length+(e.omittedFileCount??0)&&e.matchCount===t.reduce((r,a)=>r+a.matchCount,0)+(e.omittedMatchCount??0)}h(W,"isSearchToolDetails");function k(e,t,r){let a=new Map;for(let i of t){let u=a.get(i.lineNumber);if(u!==void 0&&u.text!==i.lineText)throw new Error(`Search results disagree about line ${String(i.lineNumber)} in ${e}.`);let o=u??{lineNumber:i.lineNumber,text:i.lineText,ranges:[]};o.ranges.push({from:i.startColumn,to:i.endLineNumber===void 0?i.endColumn:i.lineText.length}),a.set(i.lineNumber,o)}let c=[...a.values()].sort((i,u)=>i.lineNumber-u.lineNumber).map(i=>{let u=[...i.ranges].sort((o,l)=>o.from-l.from||o.to-l.to);return{lineNumber:i.lineNumber,text:i.text,matchCount:u.length,ranges:u}});return{path:S(e,r),link:M(e).href,matchCount:t.length,lines:c}}h(k,"createSearchResultFile");function F(e){if(!g(e)||typeof e.path!="string"||typeof e.link!="string"||!f(e.matchCount)||!Array.isArray(e.lines)||!e.lines.every(A))return!1;let t=e.lines,r=e.groups,a=new Set(t.flatMap(c=>c.logicalMatchIds??[]));return(r===void 0||Array.isArray(r)&&r.every(c=>g(c)&&typeof c.text=="string"&&f(c.matchCount)))&&(e.uniqueLineCount===void 0||f(e.uniqueLineCount))&&(t.length===0||(a.size>0?a.size===e.matchCount:e.matchCount===t.reduce((c,i)=>c+i.matchCount,0)))}h(F,"isSearchResultFile");function A(e){return g(e)&&Number.isSafeInteger(e.lineNumber)&&e.lineNumber>=1&&typeof e.text=="string"&&f(e.matchCount)&&Array.isArray(e.ranges)&&e.ranges.length===e.matchCount&&(e.logicalMatchIds===void 0||Array.isArray(e.logicalMatchIds)&&e.logicalMatchIds.every(t=>typeof t=="string"))&&e.ranges.every(t=>I(t,e.text))}h(A,"isSearchResultLine");function I(e,t){return g(e)&&Number.isSafeInteger(e.from)&&Number.isSafeInteger(e.to)&&e.from>=0&&e.to>e.from&&e.to<=t.length}h(I,"isSearchResultRange");function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}h(g,"isRecord");function f(e){return Number.isSafeInteger(e)&&e>=0}h(f,"isCount");function S(e,t){if(e.includes("://"))return e;let r=R.relative(t,e);return r.length>0&&!r.startsWith("..")&&!R.isAbsolute(r)?r:e}h(S,"displaySource");function J(e,t){let r=e.count===1?"1 path":`${e.count} paths`,{path:a,error:c}=e.first;return`Search notice: could not read ${r}, so matches in them are missing. First: ${S(a,t)}: ${c}`}h(J,"unreadableNotice");export{q as a,z as b,T as c,H as d,W as e,S as f,J as g};
1
+ import{v as b,w as x}from"./chunk-3JBQYLJ4.js";import{a as h}from"./chunk-EI7MMDWY.js";import R from"node:path";import{pathToFileURL as M}from"node:url";function q(e,t="this path"){return e<=1e3?`Search ${t} with limit: ${String(e)}`:`Read a bounded window of ${t}, then Search that result`}h(q,"searchCompactionHint");function z(e,t){let r=new Map;for(let n of e){let s=r.get(n.source)??[];s.push(n),r.set(n.source,s)}let a=new Set,c=e.length,i=[...r].sort(([n,s],[m,d])=>d.length-s.length||n.localeCompare(m));for(let[n,s]of i){if(c<=t)break;a.add(n),c-=s.length-1}let u=[],o=t,l=[...r].sort(([n],[s])=>Number(a.has(n))-Number(a.has(s))||n.localeCompare(s));for(let[n,s]of l){if(!a.has(n)){if(s.length>o)continue;u.push({kind:"detailed",source:n,matches:s}),o-=s.length;continue}if(o<1)continue;o--;let m=new Map;for(let y of s){let p=m.get(y.lineText);p===void 0?m.set(y.lineText,{matchCount:1,first:y}):p.matchCount++}let d=[...m].sort(([y,p],[N,P])=>P.matchCount-p.matchCount||y.localeCompare(N)).map(([y,p])=>({text:y,...p})),C=r.size===1?Math.min(o,d.length-1):0,w=d.slice(0,1+C);o-=C,u.push({kind:"compacted",source:n,matchCount:s.length,uniqueLineCount:m.size,groups:w})}return u.sort((n,s)=>n.source.localeCompare(s.source)),{files:u}}h(z,"planSearchPresentation");function T(e,t,r,a,c,i=50){let u=z(t,i),o=new Set(t.map(n=>n.source)).size,l=u.files.map(n=>n.kind==="detailed"?k(n.source,n.matches,a):{path:S(n.source,a),link:M(n.source).href,matchCount:n.matchCount,uniqueLineCount:n.uniqueLineCount,groups:n.groups.map(({text:s,matchCount:m})=>({text:s,matchCount:m})),lines:[]});return{...c!==void 0&&{sessionId:c},query:e,matchCount:t.length,fileCount:o,...u.files.length<o?{omittedFileCount:o-l.length,omittedMatchCount:t.length-l.reduce((n,s)=>n+s.matchCount,0)}:{},complete:r,files:l}}h(T,"createSearchToolDetails");function H(e,t){return{fileCount:new Set(e.flatMap(r=>r.matches.map(a=>a.source))).size,groups:e.map(r=>{let c=T(r.identifier,r.matches.slice(0,b.previewMatches),r.complete,t).files.map(i=>{let u=i.lines.map(o=>{let l=Math.max(0,(o.ranges[0]?.from??0)-64),n=Math.min(o.text.length,(o.ranges[0]?.to??0)+64),s=l>0?"\u2026":"",m=o.ranges.filter(d=>d.from>=l&&d.to<=n).map(d=>({from:d.from-l+s.length,to:d.to-l+s.length}));return{...o,text:s+o.text.slice(l,n)+(n<o.text.length?"\u2026":""),ranges:m,matchCount:m.length}});return{...i,lines:u,matchCount:u.reduce((o,l)=>o+l.matchCount,0)}});return{identifier:r.identifier,files:c}})}}h(H,"createFuzzyPresentation");function L(e){return g(e)&&f(e.fileCount)&&Array.isArray(e.groups)&&e.groups.every(t=>g(t)&&typeof t.identifier=="string"&&Array.isArray(t.files)&&t.files.every(F))}h(L,"isFuzzyPresentation");function W(e){if(!g(e)||typeof e.query!="string"||!f(e.matchCount)||!f(e.fileCount)||e.omittedFileCount!==void 0&&!f(e.omittedFileCount)||e.omittedMatchCount!==void 0&&!f(e.omittedMatchCount)||typeof e.complete!="boolean"||e.sessionId!==void 0&&typeof e.sessionId!="string"||e.fuzzy!==void 0&&!x(e.fuzzy)||e.fuzzyPresentation!==void 0&&!L(e.fuzzyPresentation)||!Array.isArray(e.files)||!e.files.every(F))return!1;let t=e.files;return e.fileCount===t.length+(e.omittedFileCount??0)&&e.matchCount===t.reduce((r,a)=>r+a.matchCount,0)+(e.omittedMatchCount??0)}h(W,"isSearchToolDetails");function k(e,t,r){let a=new Map;for(let i of t){let u=a.get(i.lineNumber);if(u!==void 0&&u.text!==i.lineText)throw new Error(`Search results disagree about line ${String(i.lineNumber)} in ${e}.`);let o=u??{lineNumber:i.lineNumber,text:i.lineText,ranges:[]};o.ranges.push({from:i.startColumn,to:i.endLineNumber===void 0?i.endColumn:i.lineText.length}),a.set(i.lineNumber,o)}let c=[...a.values()].sort((i,u)=>i.lineNumber-u.lineNumber).map(i=>{let u=[...i.ranges].sort((o,l)=>o.from-l.from||o.to-l.to);return{lineNumber:i.lineNumber,text:i.text,matchCount:u.length,ranges:u}});return{path:S(e,r),link:M(e).href,matchCount:t.length,lines:c}}h(k,"createSearchResultFile");function F(e){if(!g(e)||typeof e.path!="string"||typeof e.link!="string"||!f(e.matchCount)||!Array.isArray(e.lines)||!e.lines.every(A))return!1;let t=e.lines,r=e.groups,a=new Set(t.flatMap(c=>c.logicalMatchIds??[]));return(r===void 0||Array.isArray(r)&&r.every(c=>g(c)&&typeof c.text=="string"&&f(c.matchCount)))&&(e.uniqueLineCount===void 0||f(e.uniqueLineCount))&&(t.length===0||(a.size>0?a.size===e.matchCount:e.matchCount===t.reduce((c,i)=>c+i.matchCount,0)))}h(F,"isSearchResultFile");function A(e){return g(e)&&Number.isSafeInteger(e.lineNumber)&&e.lineNumber>=1&&typeof e.text=="string"&&f(e.matchCount)&&Array.isArray(e.ranges)&&e.ranges.length===e.matchCount&&(e.logicalMatchIds===void 0||Array.isArray(e.logicalMatchIds)&&e.logicalMatchIds.every(t=>typeof t=="string"))&&e.ranges.every(t=>I(t,e.text))}h(A,"isSearchResultLine");function I(e,t){return g(e)&&Number.isSafeInteger(e.from)&&Number.isSafeInteger(e.to)&&e.from>=0&&e.to>e.from&&e.to<=t.length}h(I,"isSearchResultRange");function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}h(g,"isRecord");function f(e){return Number.isSafeInteger(e)&&e>=0}h(f,"isCount");function S(e,t){if(e.includes("://"))return e;let r=R.relative(t,e);return r.length>0&&!r.startsWith("..")&&!R.isAbsolute(r)?r:e}h(S,"displaySource");function J(e,t){let r=e.count===1?"1 path":`${e.count} paths`,{path:a,error:c}=e.first;return`Search notice: could not read ${r}, so matches in them are missing. First: ${S(a,t)}: ${c}`}h(J,"unreadableNotice");export{q as a,z as b,T as c,H as d,W as e,S as f,J as g};
@@ -1 +1 @@
1
- import{a}from"./chunk-UHGHVYAW.js";import"./chunk-4AEYLVSR.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import"./chunk-XKVU6AAS.js";import"./chunk-MPT3R4BL.js";import"./chunk-KN6VPARZ.js";import"./chunk-I3G6K7QU.js";import"./chunk-HSAGZWPO.js";import"./chunk-PS2B6THP.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-EI7MMDWY.js";export{a as default};
1
+ import{a}from"./chunk-W25HNEMR.js";import"./chunk-3JBQYLJ4.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import"./chunk-XKVU6AAS.js";import"./chunk-MPT3R4BL.js";import"./chunk-KN6VPARZ.js";import"./chunk-I3G6K7QU.js";import"./chunk-HSAGZWPO.js";import"./chunk-PS2B6THP.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-EI7MMDWY.js";export{a as default};