pi-agent-ide 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/{chunk-TVH2ND35.js → chunk-35LZOKEW.js} +1 -1
- package/dist/chunk-3LVBARLW.js +33 -0
- package/dist/chunk-4GBFIGH3.js +1 -1
- package/dist/{chunk-64JTD2DJ.js → chunk-5PC5INOL.js} +1 -1
- package/dist/{chunk-FKKAHI62.js → chunk-BT2CFM7D.js} +1 -1
- package/dist/{chunk-VN3XBH2Q.js → chunk-DVNL5NZE.js} +1 -1
- package/dist/{chunk-PLMHBXWI.js → chunk-FXPY3V4L.js} +1 -1
- package/dist/{chunk-AJZVKDYC.js → chunk-HGCJDIRR.js} +1 -1
- package/dist/{chunk-RVFMH77U.js → chunk-HISGZD3C.js} +43 -44
- package/dist/{chunk-KFBRL2V4.js → chunk-HKYVP2Q6.js} +1 -1
- package/dist/{chunk-TVXZE4KW.js → chunk-HRBUY2FF.js} +1 -1
- package/dist/{chunk-QM5WDEFI.js → chunk-IOGWZNWT.js} +1 -1
- package/dist/{chunk-HT7LZN5A.js → chunk-IUJUECXH.js} +1 -1
- package/dist/chunk-LXDF2NWX.js +1 -0
- package/dist/{chunk-TVSZYABY.js → chunk-MPNE25CY.js} +1 -1
- package/dist/{chunk-Y74EKJOY.js → chunk-O7V6G3OO.js} +1 -1
- package/dist/chunk-OUCVZBOR.js +28 -0
- package/dist/{chunk-WUO3UW4J.js → chunk-PCGBM2D6.js} +1 -1
- package/dist/{chunk-V4J3TLCV.js → chunk-RIZARTUM.js} +1 -1
- package/dist/{chunk-LTADNZKW.js → chunk-T3Z4KXOX.js} +1 -1
- package/dist/chunk-TSQ6FBTB.js +1 -0
- package/dist/{chunk-CVOYSEBE.js → chunk-VNWGT367.js} +1 -1
- package/dist/{chunk-FS3KCKFX.js → chunk-X2WFNMQR.js} +1 -1
- package/dist/{chunk-7SG756UO.js → chunk-XCPIIDFS.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-1.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-16.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-18.js +1 -1
- package/dist/entry-19.js +1 -1
- package/dist/entry-2.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +1 -1
- package/dist/entry-22.js +1 -0
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +1 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-3.js +1 -1
- package/dist/entry-30.js +1 -2
- package/dist/entry-31.js +2 -1
- package/dist/entry-32.js +1 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -15
- package/dist/entry-38.js +15 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +1 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +1 -1
- package/dist/entry-46.js +1 -1
- package/dist/entry-47.js +1 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-5.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-6.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-64.js +1 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -0
- package/dist/entry-68.js +0 -1
- package/dist/entry-69.js +1 -0
- package/dist/entry-7.js +1 -1
- package/dist/entry-70.js +0 -1
- package/dist/entry-71.js +1 -1
- package/dist/entry-72.js +1 -1
- package/dist/entry-73.js +1 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +1 -0
- package/dist/entry-78.js +0 -1
- package/dist/entry-79.js +1 -0
- package/dist/entry-8.js +1 -1
- package/dist/entry-80.js +0 -1
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +1 -1
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -2
- package/dist/entry-86.js +2 -1
- package/dist/entry-87.js +1 -1
- package/dist/entry-88.js +1 -1
- package/dist/entry-89.js +1 -1
- package/dist/entry-9.js +1 -1
- package/dist/entry-90.js +1 -3
- package/dist/entry-91.js +3 -1
- package/dist/entry-92.js +1 -1
- package/dist/entry-93.js +1 -1
- package/dist/entry-94.js +1 -0
- package/dist/pi-agent-ide.js +13 -10
- package/docs/agent-guides/editing.md +3 -0
- package/docs/tools.md +2 -2
- package/node_modules/pi-agent-doctor/package.json +7 -7
- package/node_modules/pi-agent-documentation/package.json +2 -2
- package/node_modules/pi-agent-documentation/runtime/entry-30.js +1 -0
- package/node_modules/pi-agent-filesystem/package.json +8 -8
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-image/runtime/entry-32.js +2 -0
- package/node_modules/pi-agent-filesystem-jq/package.json +7 -7
- package/node_modules/pi-agent-filesystem-jq/runtime/entry-33.js +0 -1
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/runtime/entry-36.js +2 -0
- package/node_modules/pi-agent-ide-ast/package.json +15 -15
- package/node_modules/pi-agent-ide-ast/runtime/entry-37.js +0 -1
- package/node_modules/pi-agent-ide-ast/runtime/entry-38.js +2 -0
- package/node_modules/pi-agent-ide-changes/package.json +10 -10
- package/node_modules/pi-agent-ide-changes/runtime/entry-39.js +0 -1
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lsp/package.json +13 -13
- package/node_modules/pi-agent-ide-lsp/runtime/entry-44.js +2 -0
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-invariant/package.json +2 -2
- package/node_modules/pi-agent-pdf/package.json +3 -3
- package/node_modules/pi-agent-read/package.json +12 -12
- package/node_modules/pi-agent-read/runtime/entry-51.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-52.js +2 -0
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-search/package.json +9 -9
- package/node_modules/pi-agent-search/runtime/entry-56.js +0 -1
- package/node_modules/pi-agent-search-text/package.json +15 -15
- package/node_modules/pi-agent-search-text/runtime/entry-58.js +1 -0
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-62.js +1 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-63.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-65.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-67.js +2 -0
- package/node_modules/pi-agent-text-editor/package.json +26 -26
- package/node_modules/pi-agent-text-editor/runtime/entry-83.js +0 -1
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +2 -6
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +17 -36
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +40 -82
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -9
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -3
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +2 -8
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +6 -6
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/runtime/entry-89.js +1 -0
- package/node_modules/pi-agent-web/package.json +8 -8
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-94.js +2 -0
- package/package.json +61 -57
- package/src/api/capabilities.ts +60 -0
- package/src/composite/capabilities.ts +252 -0
- package/src/composite/capability-schemas.ts +53 -0
- package/src/composite/responses-tools.ts +27 -9
- package/src/composite/tool-availability.ts +28 -13
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-32.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-33.js +0 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-36.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-31.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-94.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-90.js +2 -0
- package/src/extensions/pi-agent-read/package.json +12 -12
- package/src/extensions/pi-agent-read/runtime/entry-51.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-52.js +2 -0
- package/src/extensions/pi-agent-search/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +15 -15
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-58.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-61.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-56.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-57.js +2 -0
- package/src/extensions/pi-agent-text-editor/package.json +26 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-63.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-65.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-67.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-83.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-84.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +2 -6
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +17 -36
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +40 -82
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -9
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -3
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +2 -8
- package/src/pi-agent-ide.ts +4 -1
- package/src/plugins/pi-agent-ide-ast/package.json +15 -15
- package/src/plugins/pi-agent-ide-ast/runtime/entry-37.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-38.js +2 -0
- package/src/plugins/pi-agent-ide-changes/package.json +10 -10
- package/src/plugins/pi-agent-ide-changes/runtime/entry-39.js +0 -1
- package/src/plugins/pi-agent-ide-debugger/index.ts +31 -26
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lsp/package.json +13 -13
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-44.js +2 -0
- package/src/plugins/pi-agent-ide-terminal/index.ts +42 -0
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +0 -21
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
- package/dist/chunk-7URANI6I.js +0 -28
- package/dist/chunk-K4UTEMDU.js +0 -1
- package/dist/chunk-TNAUCNUT.js +0 -33
- package/dist/entry-23.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-23.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-30.js +0 -2
- package/node_modules/pi-agent-filesystem-jq/runtime/entry-32.js +0 -1
- package/node_modules/pi-agent-ide-ast/runtime/entry-36.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-38.js +0 -1
- package/node_modules/pi-agent-image/runtime/entry-44.js +0 -1
- package/node_modules/pi-agent-resource/runtime/entry-52.js +0 -1
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-62.js +0 -2
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-63.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-65.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-67.js +0 -1
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-86.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-89.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-31.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-32.js +0 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-30.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-90.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-89.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-47.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-57.js +0 -2
- package/src/extensions/pi-agent-search/runtime/entry-53.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-62.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-63.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-65.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-84.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-67.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-36.js +0 -1
- package/src/plugins/pi-agent-ide-changes/runtime/entry-38.js +0 -1
- /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-29.js +0 -0
- /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-34.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-35.js +0 -0
- /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-40.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-41.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-42.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-43.js +0 -0
- /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-45.js +0 -0
- /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-46.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-47.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-53.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-57.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-61.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-87.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-90.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-91.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-92.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-93.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-34.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-35.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-91.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-92.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-93.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-85.js +0 -0
- /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-40.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-41.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-42.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-43.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as D,m as H}from"./chunk-YPYROPQF.js";import{a as R}from"./chunk-GXL4NMHR.js";import{c as I,d as P}from"./chunk-PQWANILR.js";import"./chunk-DDH3FP4G.js";import{b as C}from"./chunk-T4FTT3U4.js";import"./chunk-VDJSH3DQ.js";import{a as X,b as K,c as Q,d as Z,g as ee}from"./chunk-OFILFO6D.js";import{a as Y}from"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";var S=[],$=[],j=[];function L(r,e,t){if(e.some(i=>i.name===t))throw new Error(`[pi-agent-ide] ${r} "${t}" is already registered. Use a unique name.`)}l(L,"assertUniqueName");function ie(r){let e=new Set;for(let t of r){let i=`${t.kind}:${t.name}`;if(e.has(i))throw new Error(`[pi-agent-ide] ${t.kind} "${t.name}" is registered twice by one plugin.`);switch(e.add(i),t.kind){case"compiler":{L(t.kind,$,t.name);break}case"formatter":{L(t.kind,S,t.name);break}case"linter":{L(t.kind,j,t.name);break}}}for(let t of r)switch(t.kind){case"compiler":{$.push(t);break}case"formatter":{S.push(t);break}case"linter":{j.push(t);break}}}l(ie,"registerTools");async function te(r,e){let t=[];for(let i of r)try{await i.detect(e)&&t.push(i)}catch(n){console.error(`[pi-agent-ide] detect failed for "${i.name}":`,n)}return t.sort((i,n)=>n.priority-i.priority),we(t),t}l(te,"filterActive");function we(r){let e=new Map;for(let t of r)for(let i of t.extensions){let n=`${i}@${t.priority}`,o=e.get(n);if(o!==void 0)throw new Error(`[pi-agent-ide] priority conflict: tools "${o}" and "${t.name}" both claim "${i}" at priority ${t.priority}.`);e.set(n,t.name)}}l(we,"assertNoPriorityConflicts");async function re(r){let[e,t]=await Promise.all([te(S,r),te($.filter(i=>i.syntaxOnly===!0),r)]);return{ctx:r,formatters:e,compilers:t,linters:[]}}l(re,"warmupFormatting");function J(){S.length=0,$.length=0,j.length=0}l(J,"resetRegistry");import{readFile as ve}from"node:fs/promises";import k from"node:path";var A=class{constructor(e,t={}){this.sources=e;this.options=t}static{l(this,"DiagnosticStore")}files=new Map;dirty=new Set;sent=new Map;queue=[];running=0;disposed=!1;changeListeners=new Set;onDidChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}schedule(e,t,{cwd:i,parentToolCallId:n}){this.disposed||this.ensure(e,t,i,n)}async read(e,{cwd:t,mode:i,signal:n}){n?.throwIfAborted(),this.assertActive();let o=C(e,t),s=await this.readText(o,t,n);this.assertActive();let a=this.ensure(o,s,t);i==="complete"?await this.waitComplete(a,n):i!=="snapshot"&&await Te(Promise.all(a.jobs),this.options.readWaitMs??5e3),n?.throwIfAborted(),this.assertActive();let d=await this.readText(o,t,n);this.assertActive();let c=this.ensure(o,d,t);if(i==="complete"&&c!==a)throw Object.assign(new Error("File changed during diagnostics"),{code:"DIAGNOSTICS_STALE"});return{filePath:o,content:c.content,results:[...c.results.values()]}}async waitComplete(e,t){let i=t?AbortSignal.any([t,e.controller.signal]):e.controller.signal;i.throwIfAborted();let n=[];await new Promise((o,s)=>{let a=l(p=>s(Object.assign(new Error(p),{code:p,details:[...e.results.values()]})),"fail"),d=l(()=>{let p=[...e.results.values()];p.some(f=>f.status==="unavailable")?a("DIAGNOSTICS_UNAVAILABLE"):p.every(f=>f.status==="ready")&&o()},"check"),c=l(()=>s(i.reason),"abort"),u=this.onDidChange(d),g=setTimeout(()=>a("DIAGNOSTICS_TIMEOUT"),this.options.checkTimeoutMs??3e4);i.addEventListener("abort",c,{once:!0});let h=l(()=>{clearTimeout(g),u(),i.removeEventListener("abort",c)},"cleanup");Promise.resolve().then(d),n.push(h)}).finally(()=>{for(let o of n)o()})}async takeNotifications(e){let t=[];for(let i of[...this.dirty]){if(i.cwd!==(e.includes("://")?e:k.resolve(e))||(this.dirty.delete(i),!await this.isCurrent(i)))continue;let n=[...i.results.values()].filter(c=>c.status!=="pending"&&c.status!=="unavailable"&&c.diagnostics.length>0),o=this.key(i.filePath,i.cwd),s=JSON.stringify(n);if(this.sent.get(o)===s||(this.sent.set(o,s),n.length===0))continue;let a=n.map(c=>{let u=["error","warning","info","hint"].flatMap(g=>{let h=c.diagnostics.filter(p=>p.severity===g).length;return h>0?[`${h} ${g}`]:[]});return`${c.source} ${u.join(", ")}${c.status==="snapshot"?" (snapshot; completion unknown)":c.status==="unversioned"?" (unversioned)":""}`}).join("; "),d=i.filePath.includes("://")?i.filePath:k.relative(e,i.filePath);t.push({filePath:d,...i.parentToolCallId===void 0?{}:{parentToolCallId:i.parentToolCallId},results:n,text:`${JSON.stringify(d)}: ${a}.`})}return t}dispose(){this.disposed=!0,this.changeListeners.clear();for(let e of this.files.values())e.controller.abort();this.files.clear(),this.dirty.clear(),this.sent.clear(),this.pump()}async readText(e,t,i){for(let n of this.options.readers??[]){let o=await n.readText(e,{cwd:t,signal:i});if(o!==void 0)return o}if(e.includes("://"))throw Object.assign(new Error("No diagnostic reader for resource owner"),{code:"UNSUPPORTED_SOURCE"});return ve(e,{encoding:"utf8",signal:i})}key(e,t){return JSON.stringify([t.includes("://")?t:k.resolve(t),C(e,t)])}ensure(e,t,i,n){let o=this.key(e,i),s=this.files.get(o);if(s?.content===t)return s;s?.controller.abort(),s&&this.dirty.delete(s);let a={cwd:i.includes("://")?i:k.resolve(i),filePath:C(e,i),content:t,...n===void 0?{}:{parentToolCallId:n},controller:new AbortController,results:new Map,jobs:[],publications:new Map};this.files.set(o,a),this.sources.length===0&&a.results.set("diagnostics",{source:"diagnostics",status:"unavailable",diagnostics:[],reason:"No diagnostic sources registered"}),this.dirty.add(a);for(let d of this.sources){a.results.set(d.id,{source:d.id,status:"pending",diagnostics:[]});let c=new Promise(u=>{this.queue.push(async()=>{try{await this.check(a,d)}finally{u()}})});a.jobs.push(c)}return queueMicrotask(()=>this.pump()),a}pump(){for(;this.running<(this.options.concurrency??4)&&this.queue.length>0;){let e=this.queue.shift();if(!e)break;this.running++,e().finally(()=>{this.running--,this.pump()})}}active(e){return!this.disposed&&!e.controller.signal.aborted}assertActive(){if(this.disposed)throw new Error("Diagnostics session has ended")}async isCurrent(e){if(!this.active(e))return!1;let t=await this.readText(e.filePath,e.cwd,e.controller.signal).catch(()=>{});return this.active(e)&&t===e.content}async publish(e,t,i){let n=(e.publications.get(t)??0)+1;if(e.publications.set(t,n),!await this.isCurrent(e)||e.publications.get(t)!==n)return;let o={...i,source:i.source??t};if(JSON.stringify(e.results.get(t))===JSON.stringify(o))return;e.results.set(t,o),this.dirty.add(e);let s=[...e.results.values()].some(a=>a.status!=="pending"&&a.status!=="unavailable"&&a.diagnostics.length>0);s||this.sent.delete(this.key(e.filePath,e.cwd));for(let a of this.changeListeners)a(e.cwd,s)}async check(e,t){if(!await this.isCurrent(e))return;let i=new AbortController,n=AbortSignal.any([i.signal,e.controller.signal]);if(n.aborted)return;let o,s;try{let a=new Promise((c,u)=>{s=l(()=>u(n.reason),"onAbort"),n.addEventListener("abort",s,{once:!0}),o=setTimeout(()=>i.abort(new Error("Diagnostic check timed out")),this.options.checkTimeoutMs??3e4)}),d=await Promise.race([t.diagnose(e.filePath,{cwd:e.cwd,content:e.content,signal:n,publish:l(c=>{n.aborted||this.publish(e,t.id,c)},"publish")}),a]);await this.publish(e,t.id,d)}catch(a){await this.publish(e,t.id,{status:"unavailable",diagnostics:[],reason:a instanceof Error?a.message:String(a)})}finally{clearTimeout(o),s&&n.removeEventListener("abort",s)}}};async function Te(r,e){let t;try{await Promise.race([r,new Promise(i=>{t=setTimeout(i,e)})])}finally{clearTimeout(t)}}l(Te,"waitAtMost");function ne(){let r=new Map,e=[],t=[],i=new A(e,{readers:t}),n=Promise.resolve();return{diagnostics:i,registerPlugin(o){if(o.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let s=r.get(o.id);if(s!==void 0)return s;let a=n.then(async()=>{let d=[],c=[],u=[],g=!0,h={addTool(f){if(!g)throw new Error(`Plugin ${o.id} setup is already complete`);Ee(f),d.push(f)},addDiagnosticSource(f){if(!g)throw new Error(`Plugin ${o.id} setup is already complete`);xe(f),c.push(f)},addDiagnosticFileReader(f){if(!g)throw new Error(`Plugin ${o.id} setup is already complete`);if(!f.id.trim()||typeof f.readText!="function")throw new TypeError("Invalid diagnostic file reader");u.push(f)},readDiagnostics(f,E){return i.read(f,E)}};try{await o.setup(h)}catch(f){throw g=!1,f}g=!1,be(e,c);let p=new Set(t.map(f=>f.id));for(let f of u){if(p.has(f.id))throw new Error(`Diagnostic file reader ${f.id} is already registered`);p.add(f.id)}ie(d),e.push(...c),t.push(...u)});return r.set(o.id,a),n=a.catch(()=>{}),a.catch(()=>{r.delete(o.id)}),a},async waitForPendingPlugins(){await Promise.all(r.values())}}}l(ne,"createIdeCore");function be(r,e){let t=new Set(r.map(i=>i.id));for(let i of e){if(t.has(i.id))throw new Error(`Diagnostic source ${i.id} is already registered`);t.add(i.id)}}l(be,"assertUniqueDiagnosticSources");function Ee(r){if(!oe(r))throw new TypeError("IDE tool must be an object");let e=r.kind,t=e==="compiler"?r.compile:e==="formatter"?r.format:e==="linter"?r.lint:void 0;if(t===void 0||typeof t!="function"||typeof r.detect!="function"||typeof r.name!="string"||r.name.trim().length===0||typeof r.priority!="number"||!Number.isFinite(r.priority)||!Array.isArray(r.extensions)||r.extensions.length===0||r.extensions.some(i=>typeof i!="string"||i.length===0))throw new TypeError("Invalid pi-agent-ide tool contribution")}l(Ee,"assertIdeTool");function xe(r){if(!oe(r)||typeof r.id!="string"||r.id.trim().length===0||typeof r.diagnose!="function")throw new TypeError("Invalid pi-agent-ide diagnostic source contribution")}l(xe,"assertDiagnosticSource");function oe(r){return typeof r=="object"&&r!==null}l(oe,"isRecord");function se(r,e,t=console.error){let i=new Map,n=!1,o=Promise.resolve();return{schedule(s){if(n||i.has(s))return;let a=setTimeout(()=>{i.delete(s),o=o.then(async()=>{n||await r(s)}).catch(t)},e);i.set(s,a)},dispose(){n=!0;for(let s of i.values())clearTimeout(s);i.clear()}}}l(se,"createDiagnosticDelivery");import{Text as ae}from"@earendil-works/pi-tui";var G="ide-diagnostic-summary";function ce(r){let e=new Map;for(let t of r){let i=t.parentToolCallId,n=e.get(i)??[];n.push(Ie(t)),e.set(i,n)}return[...e].map(([t,i])=>({files:i,...t===void 0?{}:{parentToolCallId:t}}))}l(ce,"diagnosticEntryGroups");function Ie(r){return{filePath:r.filePath,sources:r.results.map(e=>{let t={error:0,warning:0,info:0,hint:0};for(let i of e.diagnostics)t[i.severity]++;return{source:e.source,status:e.status,counts:t}})}}l(Ie,"diagnosticEntryData");function V(r,e,t=!1){return{render(i){let n=r.sources.filter(a=>a.status!=="pending"&&a.status!=="unavailable"&&Object.values(a.counts).some(d=>d>0));if(n.length===0)return[];let o=n.map(a=>`${U(a.counts,e)} ${e.fg("dim",`(${q(a.source)})`)}`+(a.status==="ready"?"":` \xB7 ${e.fg("dim",a.status)}`)).join(" \xB7 "),s=[`${e.fg("accent","Diagnostics")} ${e.fg("toolTitle",q(r.filePath))} \xB7 ${o}`];if(t)for(let a of n)s.push(` ${e.fg("dim",q(a.source))} \xB7 ${U(a.counts,e)} \xB7 ${e.fg("dim",a.status)}`);return new ae(s.join(`
|
|
1
|
+
import{a as D,m as H}from"./chunk-YPYROPQF.js";import{a as R}from"./chunk-GXL4NMHR.js";import{c as I,d as P}from"./chunk-PQWANILR.js";import"./chunk-DDH3FP4G.js";import{b as C}from"./chunk-T4FTT3U4.js";import"./chunk-VDJSH3DQ.js";import{a as Y}from"./chunk-ZC65Z3CK.js";import{a as X,b as K,c as Q,d as Z,g as ee}from"./chunk-OFILFO6D.js";import{a as l}from"./chunk-EI7MMDWY.js";var S=[],$=[],j=[];function L(r,e,t){if(e.some(i=>i.name===t))throw new Error(`[pi-agent-ide] ${r} "${t}" is already registered. Use a unique name.`)}l(L,"assertUniqueName");function ie(r){let e=new Set;for(let t of r){let i=`${t.kind}:${t.name}`;if(e.has(i))throw new Error(`[pi-agent-ide] ${t.kind} "${t.name}" is registered twice by one plugin.`);switch(e.add(i),t.kind){case"compiler":{L(t.kind,$,t.name);break}case"formatter":{L(t.kind,S,t.name);break}case"linter":{L(t.kind,j,t.name);break}}}for(let t of r)switch(t.kind){case"compiler":{$.push(t);break}case"formatter":{S.push(t);break}case"linter":{j.push(t);break}}}l(ie,"registerTools");async function te(r,e){let t=[];for(let i of r)try{await i.detect(e)&&t.push(i)}catch(n){console.error(`[pi-agent-ide] detect failed for "${i.name}":`,n)}return t.sort((i,n)=>n.priority-i.priority),we(t),t}l(te,"filterActive");function we(r){let e=new Map;for(let t of r)for(let i of t.extensions){let n=`${i}@${t.priority}`,o=e.get(n);if(o!==void 0)throw new Error(`[pi-agent-ide] priority conflict: tools "${o}" and "${t.name}" both claim "${i}" at priority ${t.priority}.`);e.set(n,t.name)}}l(we,"assertNoPriorityConflicts");async function re(r){let[e,t]=await Promise.all([te(S,r),te($.filter(i=>i.syntaxOnly===!0),r)]);return{ctx:r,formatters:e,compilers:t,linters:[]}}l(re,"warmupFormatting");function J(){S.length=0,$.length=0,j.length=0}l(J,"resetRegistry");import{readFile as ve}from"node:fs/promises";import k from"node:path";var A=class{constructor(e,t={}){this.sources=e;this.options=t}static{l(this,"DiagnosticStore")}files=new Map;dirty=new Set;sent=new Map;queue=[];running=0;disposed=!1;changeListeners=new Set;onDidChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}schedule(e,t,{cwd:i,parentToolCallId:n}){this.disposed||this.ensure(e,t,i,n)}async read(e,{cwd:t,mode:i,signal:n}){n?.throwIfAborted(),this.assertActive();let o=C(e,t),s=await this.readText(o,t,n);this.assertActive();let a=this.ensure(o,s,t);i==="complete"?await this.waitComplete(a,n):i!=="snapshot"&&await Te(Promise.all(a.jobs),this.options.readWaitMs??5e3),n?.throwIfAborted(),this.assertActive();let d=await this.readText(o,t,n);this.assertActive();let c=this.ensure(o,d,t);if(i==="complete"&&c!==a)throw Object.assign(new Error("File changed during diagnostics"),{code:"DIAGNOSTICS_STALE"});return{filePath:o,content:c.content,results:[...c.results.values()]}}async waitComplete(e,t){let i=t?AbortSignal.any([t,e.controller.signal]):e.controller.signal;i.throwIfAborted();let n=[];await new Promise((o,s)=>{let a=l(p=>s(Object.assign(new Error(p),{code:p,details:[...e.results.values()]})),"fail"),d=l(()=>{let p=[...e.results.values()];p.some(f=>f.status==="unavailable")?a("DIAGNOSTICS_UNAVAILABLE"):p.every(f=>f.status==="ready")&&o()},"check"),c=l(()=>s(i.reason),"abort"),u=this.onDidChange(d),g=setTimeout(()=>a("DIAGNOSTICS_TIMEOUT"),this.options.checkTimeoutMs??3e4);i.addEventListener("abort",c,{once:!0});let h=l(()=>{clearTimeout(g),u(),i.removeEventListener("abort",c)},"cleanup");Promise.resolve().then(d),n.push(h)}).finally(()=>{for(let o of n)o()})}async takeNotifications(e){let t=[];for(let i of[...this.dirty]){if(i.cwd!==(e.includes("://")?e:k.resolve(e))||(this.dirty.delete(i),!await this.isCurrent(i)))continue;let n=[...i.results.values()].filter(c=>c.status!=="pending"&&c.status!=="unavailable"&&c.diagnostics.length>0),o=this.key(i.filePath,i.cwd),s=JSON.stringify(n);if(this.sent.get(o)===s||(this.sent.set(o,s),n.length===0))continue;let a=n.map(c=>{let u=["error","warning","info","hint"].flatMap(g=>{let h=c.diagnostics.filter(p=>p.severity===g).length;return h>0?[`${h} ${g}`]:[]});return`${c.source} ${u.join(", ")}${c.status==="snapshot"?" (snapshot; completion unknown)":c.status==="unversioned"?" (unversioned)":""}`}).join("; "),d=i.filePath.includes("://")?i.filePath:k.relative(e,i.filePath);t.push({filePath:d,...i.parentToolCallId===void 0?{}:{parentToolCallId:i.parentToolCallId},results:n,text:`${JSON.stringify(d)}: ${a}.`})}return t}dispose(){this.disposed=!0,this.changeListeners.clear();for(let e of this.files.values())e.controller.abort();this.files.clear(),this.dirty.clear(),this.sent.clear(),this.pump()}async readText(e,t,i){for(let n of this.options.readers??[]){let o=await n.readText(e,{cwd:t,signal:i});if(o!==void 0)return o}if(e.includes("://"))throw Object.assign(new Error("No diagnostic reader for resource owner"),{code:"UNSUPPORTED_SOURCE"});return ve(e,{encoding:"utf8",signal:i})}key(e,t){return JSON.stringify([t.includes("://")?t:k.resolve(t),C(e,t)])}ensure(e,t,i,n){let o=this.key(e,i),s=this.files.get(o);if(s?.content===t)return s;s?.controller.abort(),s&&this.dirty.delete(s);let a={cwd:i.includes("://")?i:k.resolve(i),filePath:C(e,i),content:t,...n===void 0?{}:{parentToolCallId:n},controller:new AbortController,results:new Map,jobs:[],publications:new Map};this.files.set(o,a),this.sources.length===0&&a.results.set("diagnostics",{source:"diagnostics",status:"unavailable",diagnostics:[],reason:"No diagnostic sources registered"}),this.dirty.add(a);for(let d of this.sources){a.results.set(d.id,{source:d.id,status:"pending",diagnostics:[]});let c=new Promise(u=>{this.queue.push(async()=>{try{await this.check(a,d)}finally{u()}})});a.jobs.push(c)}return queueMicrotask(()=>this.pump()),a}pump(){for(;this.running<(this.options.concurrency??4)&&this.queue.length>0;){let e=this.queue.shift();if(!e)break;this.running++,e().finally(()=>{this.running--,this.pump()})}}active(e){return!this.disposed&&!e.controller.signal.aborted}assertActive(){if(this.disposed)throw new Error("Diagnostics session has ended")}async isCurrent(e){if(!this.active(e))return!1;let t=await this.readText(e.filePath,e.cwd,e.controller.signal).catch(()=>{});return this.active(e)&&t===e.content}async publish(e,t,i){let n=(e.publications.get(t)??0)+1;if(e.publications.set(t,n),!await this.isCurrent(e)||e.publications.get(t)!==n)return;let o={...i,source:i.source??t};if(JSON.stringify(e.results.get(t))===JSON.stringify(o))return;e.results.set(t,o),this.dirty.add(e);let s=[...e.results.values()].some(a=>a.status!=="pending"&&a.status!=="unavailable"&&a.diagnostics.length>0);s||this.sent.delete(this.key(e.filePath,e.cwd));for(let a of this.changeListeners)a(e.cwd,s)}async check(e,t){if(!await this.isCurrent(e))return;let i=new AbortController,n=AbortSignal.any([i.signal,e.controller.signal]);if(n.aborted)return;let o,s;try{let a=new Promise((c,u)=>{s=l(()=>u(n.reason),"onAbort"),n.addEventListener("abort",s,{once:!0}),o=setTimeout(()=>i.abort(new Error("Diagnostic check timed out")),this.options.checkTimeoutMs??3e4)}),d=await Promise.race([t.diagnose(e.filePath,{cwd:e.cwd,content:e.content,signal:n,publish:l(c=>{n.aborted||this.publish(e,t.id,c)},"publish")}),a]);await this.publish(e,t.id,d)}catch(a){await this.publish(e,t.id,{status:"unavailable",diagnostics:[],reason:a instanceof Error?a.message:String(a)})}finally{clearTimeout(o),s&&n.removeEventListener("abort",s)}}};async function Te(r,e){let t;try{await Promise.race([r,new Promise(i=>{t=setTimeout(i,e)})])}finally{clearTimeout(t)}}l(Te,"waitAtMost");function ne(){let r=new Map,e=[],t=[],i=new A(e,{readers:t}),n=Promise.resolve();return{diagnostics:i,registerPlugin(o){if(o.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let s=r.get(o.id);if(s!==void 0)return s;let a=n.then(async()=>{let d=[],c=[],u=[],g=!0,h={addTool(f){if(!g)throw new Error(`Plugin ${o.id} setup is already complete`);Ee(f),d.push(f)},addDiagnosticSource(f){if(!g)throw new Error(`Plugin ${o.id} setup is already complete`);xe(f),c.push(f)},addDiagnosticFileReader(f){if(!g)throw new Error(`Plugin ${o.id} setup is already complete`);if(!f.id.trim()||typeof f.readText!="function")throw new TypeError("Invalid diagnostic file reader");u.push(f)},readDiagnostics(f,E){return i.read(f,E)}};try{await o.setup(h)}catch(f){throw g=!1,f}g=!1,be(e,c);let p=new Set(t.map(f=>f.id));for(let f of u){if(p.has(f.id))throw new Error(`Diagnostic file reader ${f.id} is already registered`);p.add(f.id)}ie(d),e.push(...c),t.push(...u)});return r.set(o.id,a),n=a.catch(()=>{}),a.catch(()=>{r.delete(o.id)}),a},async waitForPendingPlugins(){await Promise.all(r.values())}}}l(ne,"createIdeCore");function be(r,e){let t=new Set(r.map(i=>i.id));for(let i of e){if(t.has(i.id))throw new Error(`Diagnostic source ${i.id} is already registered`);t.add(i.id)}}l(be,"assertUniqueDiagnosticSources");function Ee(r){if(!oe(r))throw new TypeError("IDE tool must be an object");let e=r.kind,t=e==="compiler"?r.compile:e==="formatter"?r.format:e==="linter"?r.lint:void 0;if(t===void 0||typeof t!="function"||typeof r.detect!="function"||typeof r.name!="string"||r.name.trim().length===0||typeof r.priority!="number"||!Number.isFinite(r.priority)||!Array.isArray(r.extensions)||r.extensions.length===0||r.extensions.some(i=>typeof i!="string"||i.length===0))throw new TypeError("Invalid pi-agent-ide tool contribution")}l(Ee,"assertIdeTool");function xe(r){if(!oe(r)||typeof r.id!="string"||r.id.trim().length===0||typeof r.diagnose!="function")throw new TypeError("Invalid pi-agent-ide diagnostic source contribution")}l(xe,"assertDiagnosticSource");function oe(r){return typeof r=="object"&&r!==null}l(oe,"isRecord");function se(r,e,t=console.error){let i=new Map,n=!1,o=Promise.resolve();return{schedule(s){if(n||i.has(s))return;let a=setTimeout(()=>{i.delete(s),o=o.then(async()=>{n||await r(s)}).catch(t)},e);i.set(s,a)},dispose(){n=!0;for(let s of i.values())clearTimeout(s);i.clear()}}}l(se,"createDiagnosticDelivery");import{Text as ae}from"@earendil-works/pi-tui";var G="ide-diagnostic-summary";function ce(r){let e=new Map;for(let t of r){let i=t.parentToolCallId,n=e.get(i)??[];n.push(Ie(t)),e.set(i,n)}return[...e].map(([t,i])=>({files:i,...t===void 0?{}:{parentToolCallId:t}}))}l(ce,"diagnosticEntryGroups");function Ie(r){return{filePath:r.filePath,sources:r.results.map(e=>{let t={error:0,warning:0,info:0,hint:0};for(let i of e.diagnostics)t[i.severity]++;return{source:e.source,status:e.status,counts:t}})}}l(Ie,"diagnosticEntryData");function V(r,e,t=!1){return{render(i){let n=r.sources.filter(a=>a.status!=="pending"&&a.status!=="unavailable"&&Object.values(a.counts).some(d=>d>0));if(n.length===0)return[];let o=n.map(a=>`${U(a.counts,e)} ${e.fg("dim",`(${q(a.source)})`)}`+(a.status==="ready"?"":` \xB7 ${e.fg("dim",a.status)}`)).join(" \xB7 "),s=[`${e.fg("accent","Diagnostics")} ${e.fg("toolTitle",q(r.filePath))} \xB7 ${o}`];if(t)for(let a of n)s.push(` ${e.fg("dim",q(a.source))} \xB7 ${U(a.counts,e)} \xB7 ${e.fg("dim",a.status)}`);return new ae(s.join(`
|
|
2
2
|
`),0,0).render(i)},invalidate(){}}}l(V,"renderDiagnosticEntry");function le(r){r.registerEntryRenderer(G,(e,t,i)=>{let n=Y(e.data);return"files"in n?Pe(n.files,i,t.expanded):V(n,i,t.expanded)})}l(le,"registerDiagnosticEntryRenderer");function Pe(r,e,t=!1){return{render(i){let n=r.filter(d=>d.sources.some(c=>c.status!=="pending"&&c.status!=="unavailable"&&Object.values(c.counts).some(u=>u>0)));if(n.length===1&&n[0])return V(n[0],e,t).render(i);if(n.length===0)return[];let o={error:0,warning:0,info:0,hint:0},s=new Set;for(let d of n)for(let c of d.sources)if(!(c.status==="pending"||c.status==="unavailable")){s.add(c.source);for(let u of["error","warning","info","hint"])o[u]+=c.counts[u]}let a=new ae(`${e.fg("accent","Diagnostics")} \xB7 ${n.length} files \xB7 ${U(o,e)} \xB7 ${s.size} tools`,0,0).render(i);return t?[...a,...n.flatMap(d=>V(d,e,!0).render(i))]:a},invalidate(){}}}l(Pe,"renderDiagnosticBatch");function U(r,e){return["error","warning","info","hint"].filter(t=>r[t]>0).map(t=>{let i=r[t],n=t==="info"||i===1?t:`${t}s`,o=i>0&&(t==="error"||t==="warning")?t:"muted";return e.fg(o,`${i} ${n}`)}).join(", ")}l(U,"renderCounts");function q(r){return r.replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}l(q,"plain");import de from"node:path";async function ue(r){if(!de.isAbsolute(r.resourceSource)&&!r.resourceSource.startsWith("ssh://"))return{formatting:{status:"unavailable"}};let e;try{let t=await re({cwd:r.cwd}),i=de.extname(r.resourceSource).toLowerCase(),n=l(d=>d.extensions.includes(i)||d.extensions.includes("*"),"matches"),o=t.compilers.find(n);if(o&&(await o.compile({filePath:r.resourceSource},t.ctx)).syntaxErrors.length>0)return{formatting:{status:"skipped-syntax"}};let s=t.formatters.find(n);if(!s)return{formatting:{status:"unavailable"}};e=s.name;let a=await s.format({filePath:r.resourceSource},t.ctx);return a.formatter===null?{formatting:{status:"unavailable"}}:(e=a.formatter??s.name,{formatting:{status:a.ok?a.edits>0?"changed":"unchanged":"failed",formatter:e},...a.ok?{diffStatuses:[{text:`Formatted (${e})`,tone:"success",formatter:e}]}:{diffStatuses:[{text:`Formatting failed (${e})`,formatter:e,tone:"error"}]}})}catch{return{diffStatuses:[{text:"Formatting failed",tone:"error",formattingStatus:"failed",...e===void 0?{}:{formatter:e}}],formatting:{status:"failed",...e===void 0?{}:{formatter:e}}}}}l(ue,"runIdePostEditGate");import{readFile as _e}from"node:fs/promises";import me from"node:path";import{Text as Oe}from"@earendil-works/pi-tui";import{readFile as Re}from"node:fs/promises";import De from"node:path";import{Type as v}from"typebox";import{Value as Ce}from"typebox/value";import{parseDocument as Se}from"yaml";var F=".pi/pi-agent-ide/code-review.yaml",$e=v.Object({rules:v.Array(v.Object({id:v.String({pattern:"^[a-z][a-z0-9-]*$",maxLength:64}),description:v.String({minLength:1,maxLength:2048}),enabled:v.Optional(v.Boolean())},{additionalProperties:!1}),{maxItems:32})},{additionalProperties:!1});function ke(r){if(Buffer.byteLength(r,"utf8")>65536)throw new Error("Review rules file is too large (64 KiB limit).");let e=Se(r),[t]=e.errors;if(t)throw new Error(t.message);let i=e.toJS({maxAliasCount:0});if(!Ce.Check($e,i))throw new Error("Expected rules: [{ id, description, enabled? }]; at most 32 rules with descriptions up to 2048 characters.");let n=new Set,o=[];for(let s of i.rules){if(n.has(s.id))throw new Error(`Duplicate review rule: ${s.id}`);if(n.add(s.id),!s.description.trim())throw new Error(`Empty description for ${s.id}`);s.enabled!==!1&&o.push({id:s.id,description:s.description.trim()})}return o}l(ke,"parseReviewRules");async function fe(r){let e=De.resolve(r,F);try{return ke(await Re(e,"utf8"))}catch(t){if(t.code==="ENOENT")return[];throw new Error(`Cannot load ${e}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}l(fe,"readReviewRules");import{createHash as Fe}from"node:crypto";import{structuredPatch as Ae}from"diff";function ge(r,e){if(r===e)return[];if(r.length+e.length>3e5)throw new Error("File is too large for automatic review.");let t=Ae("before","after",r,e,void 0,void 0,{context:3,timeout:100});if(!t)throw new Error("Diff exceeded the automatic review time limit.");if(t.hunks.length>16)throw new Error("Change has too many fragments for automatic review (16 limit).");return t.hunks.map(i=>{let n=`@@ -${i.oldStart},${i.oldLines} +${i.newStart},${i.newLines} @@
|
|
3
3
|
${i.lines.join(`
|
|
4
4
|
`)}`;if(n.length>12e3)throw new Error("Fragment is too large for automatic review (12000 character limit).");return{diff:n}})}l(ge,"reviewFragments");function pe(r,e=300){let t=new Map,i=!1,n=Promise.resolve(),o=l(c=>!i&&r.enabled()&&t.get(c.edit.file)===c&&!c.controller.signal.aborted,"valid"),s=l(async c=>o(c)&&await r.current(c.edit.file)===c.edit.after&&o(c),"fresh");async function a(c){if(!o(c))return;c.started=!0;let{edit:u}=c;try{let g=r.runtime();if(!g)return;let h=AbortSignal.any([c.controller.signal,AbortSignal.timeout(15e3)]),p=await g.available(h),f=p.find(m=>m.provider==="typesafe"&&/jev/i.test(m.id))??p.find(m=>/jev/i.test(m.id));if(!f||!o(c))return;let E=await r.rules(u.cwd);if(E.length===0||!await s(c))return;let he=Object.fromEntries(E.map(m=>[m.id,{type:"choice",instructions:`Check whether this change violates the following project rule: ${m.description}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-NNCZYO4Q.js";import{d as k}from"./chunk-OMNKD7WW.js";import"./chunk-PS2B6THP.js";import{d as y}from"./chunk-YPYROPQF.js";import"./chunk-PQWANILR.js";import{a as P}from"./chunk-BU7IZLKB.js";import{a as h,b as w}from"./chunk-S5PL5DFQ.js";import"./chunk-DDH3FP4G.js";import{a as I,b as v,c as C,d as A,e as E,h as b}from"./chunk-
|
|
1
|
+
import"./chunk-NNCZYO4Q.js";import{d as k}from"./chunk-OMNKD7WW.js";import"./chunk-PS2B6THP.js";import{d as y}from"./chunk-YPYROPQF.js";import"./chunk-PQWANILR.js";import{a as P}from"./chunk-BU7IZLKB.js";import{a as h,b as w}from"./chunk-S5PL5DFQ.js";import"./chunk-DDH3FP4G.js";import{a as I,b as v,c as C,d as A,e as E,h as b}from"./chunk-35LZOKEW.js";import"./chunk-T4FTT3U4.js";import"./chunk-VDJSH3DQ.js";import"./chunk-ZC65Z3CK.js";import{a as T}from"./chunk-ZAWRSA7N.js";import{a as N,b as O}from"./chunk-OFILFO6D.js";import"./chunk-KINKBPPX.js";import{a as l}from"./chunk-EI7MMDWY.js";import W from"node:path";var S="diagnostics",_=k({kind:"code-view",label:"Diagnostics"});async function q(c){let n,t=l((a,f,e)=>{if(n===void 0)throw new Error("IDE diagnostics are not connected");return n(a,{cwd:f,...e})},"collect"),s={protocol:N,apiVersion:5,id:"diagnostics",setup(a){n=a.readDiagnostics}},r=new WeakMap,i=new WeakMap,o=new WeakMap,u=new WeakMap,M={protocol:h,apiVersion:w,id:"diagnostics",setup(a){a.addResolver({resolver:H(t,i),renderResult:_});let f=b();a.addView({view:"diagnostics",priority:100,presenter:j(t,u)}),a.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler(e){if(e.state?.resolvedBy==="diagnostics"){let p=e.state.content[0],g=i.get(p);return g&&r.set(e.request,g),f(e)}return e.state?.contentKind==="text"&&e.request.views?.includes("diagnostics")&&o.set(e.request,e.state.text),{kind:"continue",context:e}}}),a.addHandler({stage:"post-read",handler(e){let p=r.get(e.request);if(p&&e.result)return{kind:"continue",context:e,transform:l(d=>({...d,details:{...d.details,diagnosticCheck:p}}),"transform")};let g=o.get(e.request),R=g&&u.get(g),m=e.result,V=m?.content[0];return!R||!m||V?.type!=="text"?{kind:"continue",context:e}:{kind:"continue",context:e,transform(d){let D=d.content[0];return D?.type!=="text"?d:{...d,content:[{...D,text:`${R}
|
|
2
2
|
${D.text}`},...d.content.slice(1)],details:{...d.details,diagnosticStatus:R}}}}}}),a.describe({path:"diagnostics:<path> \u2014 lint and language-server diagnostics.",views:"diagnostics \u2014 diagnostics beside the text."})}};await Promise.all([T(c,s),P(c,M)])}l(q,"registerDiagnostics");function H(c,n){return{id:"diagnostics",tryResolve(t,s){return Promise.resolve(L(t,s.cwd,c,n,{signal:s.signal,...s.audience==="script"&&{mode:"complete"}}))}}}l(H,"createDiagnosticResolver");function L(c,n,t,s,r){let i;try{i=I(c,S,n)}catch(o){return{kind:"failed",error:o}}return i===void 0?{kind:"not-handled"}:{kind:"resolved",resource:{source:v(S,i),async read(){let o=await t(i,n,r),u=C(i,o.content,o.results);return s.set(u,u.diagnosticCheck),[u]}}}}l(L,"resolveDiagnosticSource");function j(c,n){return{id:"diagnostics",async present(t,s){if(s.purpose!=="read"||!W.isAbsolute(t.source)&&!t.source.startsWith("ssh://"))return t;let r=s.audience==="script"&&!s.requestedViews?.includes("diagnostics");if(r&&y(t.source))return t;let i=await c(t.source,s.cwd,{signal:s.signal,...s.audience==="script"&&{mode:r?"snapshot":"complete"}}).catch(o=>{if(s.signal?.throwIfAborted(),!r)throw o});if(i===void 0||r&&i.content!==t.content)return t;if(i.content!==t.content)throw new Error("File changed during diagnostic read; read it again for current source lines.");return n.set(t,E(i.results)),A(t,i.results)}}}l(j,"createDiagnosticPresenter");export{q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n}from"./chunk-EI7MMDWY.js";var l=1,d="pi-agent-ide/capabilities/register/v1",c="pi-agent-ide/capabilities/ready/v1";function p(e,o){let a=n(()=>{let r=!1,t;if(e.events.emit(d,{capability:o,accept(s){if(r)throw new Error("Capability registration was accepted twice");r=!0,t=s}}),t!==void 0)throw t;return r},"announce"),i=e.events.on(c,()=>{if(!a())throw new Error("IDE capability service did not accept registration");i()});e.on("session_shutdown",i),a()&&i()}n(p,"registerIdeCapability");export{l as a,d as b,c,p as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as b}from"./chunk-H3GEEOOL.js";import{a as y}from"./chunk-SRFWT562.js";import{a as k,b as E}from"./chunk-USG6WHAT.js";import"./chunk-AMIIOWFL.js";import{b as S}from"./chunk-LF325WYO.js";import{a as u,b as w,c as v}from"./chunk-WQIMM4SU.js";import{g as c}from"./chunk-4IWEKRSP.js";import{a as p,b as h,d as P}from"./chunk-BT2CFM7D.js";import{c as f}from"./chunk-W7CASEO3.js";import"./chunk-B25LXXNV.js";import{c as m}from"./chunk-7D7PXIVV.js";import"./chunk-BXGMMZT3.js";import"./chunk-XH5WN5XA.js";import"./chunk-FYOU4RBH.js";import"./chunk-7PVDTMEM.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import"./chunk-MDD5ORB6.js";import"./chunk-MLFJU2US.js";import"./chunk-PS2B6THP.js";import"./chunk-GXL4NMHR.js";import"./chunk-PQWANILR.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-DDH3FP4G.js";import"./chunk-756K3LJY.js";import"./chunk-35LZOKEW.js";import"./chunk-T4FTT3U4.js";import"./chunk-VDJSH3DQ.js";import"./chunk-ZC65Z3CK.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import"./chunk-KINKBPPX.js";import{a as i}from"./chunk-EI7MMDWY.js";import R from"node:path";function g(d){let n=i(o=>{let e=d.resolve(o);if(!e)throw new c("UNSUPPORTED_SOURCE",o,"not-applied");return e},"resolve");return{transport:i(o=>y(d,o),"transport"),async readText(o,e){let r=n(o);return(await r.backend.read(r.location.path,{signal:e})).bytes.toString("utf8")},async readSnapshot(o,e){let r=n(o),t=await r.backend.read(r.location.path,{signal:e});return{content:t.bytes.toString("utf8"),version:t.version}},async readBytes(o,e){let r=n(o);return(await r.backend.read(r.location.path,{signal:e})).bytes},async exists(o,e){let r=n(o);try{return await r.backend.stat(r.location.path,{signal:e}),!0}catch(t){if(t instanceof c&&t.code==="ENOENT")return!1;throw t}},async isFile(o,e){let r=n(o);return(await r.backend.stat(r.location.path,{signal:e})).kind==="file"},async entries(o,e){let r=n(o);return(await r.backend.list(r.location.path,{signal:e})).map(t=>({name:t.name,kind:t.kind==="symlink"?"other":t.kind}))}}}i(g,"createSshLspWorkspaceOwner");async function O(d){let n=new v(await w(u(f()))),o=g(n);await P(d,{workspace:i(e=>e.startsWith("ssh://")?o:void 0,"workspace"),async loadRegistry(e,r,t){t?.throwIfAborted();let s=n.resolve(e);if(s)return h.fromPackageDir(e,{signal:t,layerAccess:k(n,t),includeGlobal:!r,requireBuiltInEvidence:r,recipes:p,recipeEvidence:i(a=>E(s.backend,s.location.path,a,t),"recipeEvidence"),executableAvailability:i(a=>S(s.backend,s.location.path,a,t),"executableAvailability")});if(e.includes("://"))throw new c("UNSUPPORTED_SOURCE",e,"not-applied");return h.fromPackageDir(r?e:process.env.PI_AGENT_IDE_CONFIG_DIR??e,{signal:t,includeGlobal:!r,requireBuiltInEvidence:r,recipes:p})},async resolveProject(e,r,t){if(t?.throwIfAborted(),e.startsWith("ssh://")||r.startsWith("ssh://")){let a=n.resolve(e,r);if(!a)throw new c("UNSUPPORTED_SOURCE",e,"not-applied");let l=n.resolve(r);if(l&&l.location.target!==a.location.target)throw new c("UNSUPPORTED_SOURCE",e,"not-applied");return b(a.backend,a.location.path,l?.location.path,"lsp-servers",p,t)}let s=await m(r,e,"lsp-servers",p,t);return s===void 0?void 0:{cwd:s,external:s!==R.resolve(r)}}})}i(O,"registerOwnedLsp");export{O as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as le,b as fe,c as ue}from"./chunk-WQIMM4SU.js";import{a as de}from"./chunk-FHRHYY4M.js";import{a as N,g as l}from"./chunk-4IWEKRSP.js";import{c as ce}from"./chunk-W7CASEO3.js";import"./chunk-NNCZYO4Q.js";import{a as ne}from"./chunk-47SPPIXK.js";import{a as te,b as re}from"./chunk-VAXLSPPU.js";import{f as Z,g as ee}from"./chunk-KN6VPARZ.js";import{d as q}from"./chunk-OMNKD7WW.js";import"./chunk-PS2B6THP.js";import{a as ie}from"./chunk-GXL4NMHR.js";import{b as x,c as Q,d as X}from"./chunk-PQWANILR.js";import{a as W}from"./chunk-BU7IZLKB.js";import{a as $,b as K}from"./chunk-S5PL5DFQ.js";import{I as H}from"./chunk-DDH3FP4G.js";import{r as J}from"./chunk-VDJSH3DQ.js";import{a as se}from"./chunk-ZAWRSA7N.js";import{a as oe,b as ae}from"./chunk-OFILFO6D.js";import
|
|
1
|
+
import{a as le,b as fe,c as ue}from"./chunk-WQIMM4SU.js";import{a as de}from"./chunk-FHRHYY4M.js";import{a as N,g as l}from"./chunk-4IWEKRSP.js";import{c as ce}from"./chunk-W7CASEO3.js";import"./chunk-NNCZYO4Q.js";import{a as ne}from"./chunk-47SPPIXK.js";import{a as te,b as re}from"./chunk-VAXLSPPU.js";import{f as Z,g as ee}from"./chunk-KN6VPARZ.js";import{d as q}from"./chunk-OMNKD7WW.js";import"./chunk-PS2B6THP.js";import{a as ie}from"./chunk-GXL4NMHR.js";import{b as x,c as Q,d as X}from"./chunk-PQWANILR.js";import{a as W}from"./chunk-BU7IZLKB.js";import{a as $,b as K}from"./chunk-S5PL5DFQ.js";import{I as H}from"./chunk-DDH3FP4G.js";import{r as J}from"./chunk-VDJSH3DQ.js";import"./chunk-ZC65Z3CK.js";import{a as se}from"./chunk-ZAWRSA7N.js";import{a as oe,b as ae}from"./chunk-OFILFO6D.js";import{a as s}from"./chunk-EI7MMDWY.js";import pe from"node:path";import{StringDecoder as Oe}from"node:string_decoder";function he(r){return(o,a)=>{let i=r.resolve(o.path??".",a.cwd);if(i===void 0)return;let{backend:c,location:w}=i,e=s((t,n=w.source)=>{let m=r.resolve(t,n);if(m===void 0||m.backend!==c)throw new l("UNSUPPORTED_SOURCE",t,"not-applied");return m.location},"own");return{resolve:s((t,n)=>e(n,t.includes("://")?t:w.source).source,"resolve"),dirname:s(t=>N(w.target,pe.posix.dirname(e(t).path)).source,"dirname"),basename:s(t=>pe.posix.basename(e(t).path),"basename"),isDirectory:s(async(t,n)=>(await c.stat(e(t).path,{signal:n})).kind==="directory","isDirectory"),byteSize:s(async(t,n)=>(await c.stat(e(t).path,{signal:n})).size,"byteSize"),readText:s(async(t,n)=>(await c.read(e(t).path,{signal:n})).bytes.toString("utf8"),"readText"),async execute(t,n,m,R){let d=await c.execute(t,n,e(m).path,{signal:R});return{code:d.exitCode,stdout:d.stdout.toString("utf8"),stderr:d.stderr.toString("utf8")}},async runLines(t,n,m,R){let d=await c.startProcess("rg",t,e(n).path,{signal:R}),g=new Oe("utf8"),u=[],p=0,f="",h,y=s(E=>{let k=E.split(`
|
|
2
2
|
`);for(let[O,b]of k.entries()){if(u.push(b),p+=Buffer.byteLength(b),p>32*1024*1024)throw new l("CONTENT_LIMIT",w.source,"not-applied");O<k.length-1&&(m(u.join("")),u.length=0,p=0)}},"consume"),v=(async()=>{try{for await(let E of d.stdout)y(g.write(E));y(g.end()),p>0&&m(u.join(""))}catch(E){h=E,await d.stop()}})(),T=(async()=>{for await(let E of d.stderr)f+=E.toString("utf8"),f.length>65536&&(f=f.slice(-65536))})();try{try{await d.end()}catch(k){if(!(k instanceof l)||k.code!=="INPUT_CLOSED")throw k}let E=await d.completion;if(await Promise.all([v,T]),h!==void 0)throw h instanceof Error?h:new Error("Search output failed.",{cause:h});return R?.throwIfAborted(),{code:E.exitCode,stderr:f}}finally{await d.stop(),await Promise.allSettled([v,T])}}}}}s(he,"createSshSearchEnvironmentProvider");import{lstat as Ue,mkdir as Ee,rm as Me,symlink as He,unlink as Ve,open as ze}from"node:fs/promises";import A from"node:path";import{constants as z}from"node:fs";import{createHash as Pe,randomBytes as Te}from"node:crypto";import{constants as we}from"node:fs";import{lstat as Ie,mkdir as Ne,open as me,readFile as Ce,rename as _e,rm as Ae,unlink as Fe}from"node:fs/promises";import D from"node:path";import{fileURLToPath as Le}from"node:url";function C(r,o,a){if(a?.has(r)&&a.get(r)!==o)throw new l("CONFLICT",r,"not-applied")}s(C,"checkCapturedRevision");var Be=1024*1024,De=Ce(new URL("./ssh-transfer-worker.py",new URL("../src/backend/file-transfer.ts",import.meta.url).href),"utf8");function j(r,o){if(r.startsWith("file:"))try{return Le(r)}catch{throw new l("UNSUPPORTED_SOURCE",r,"not-applied")}if(/^[a-z][a-z\d+.-]*:/iu.test(r)&&!/^[a-z]:[\\/]/iu.test(r))throw new l("UNSUPPORTED_SOURCE",r,"not-applied");if(o.startsWith("ssh://"))throw new l("UNSUPPORTED_SOURCE",r,"not-applied");return D.resolve(o,r)}s(j,"localTransferSource");function F(r){return[r.dev,r.ino,r.mode,r.uid,r.gid,r.size,r.mtimeNs,r.ctimeNs].join(":")}s(F,"localRevision");async function U(r){let o=await Ie(r,{bigint:!0});if(!o.isFile()||o.isSymbolicLink())throw new l("INVALID_FILE_TYPE",r,"not-applied");if(o.size>BigInt(Number.MAX_SAFE_INTEGER))throw new l("CONTENT_LIMIT",r,"not-applied");return o}s(U,"localEntry");function ye(r){return r!==null&&typeof r=="object"&&"code"in r&&r.code==="ENOENT"}s(ye,"missing");function ge(r){return r!==null&&typeof r=="object"&&"code"in r&&typeof r.code=="string"&&/^[A-Z][A-Z0-9_]*$/u.test(r.code)?r.code:"TRANSFER_FAILED"}s(ge,"errorCode");async function je(r,o,a,i){a.signal?.throwIfAborted();let c=r.resolve(o.path,a.cwd),w=r.resolve(o.target??"",a.cwd),e=c?.location.source??j(o.path,a.cwd),t=w?.location.source??j(o.target??"",a.cwd);if(e===t)throw new l("SAME_FILE",e,"not-applied");let n=c?await c.backend.lstat(c.location.path,a):await U(e);if("kind"in n&&n.kind!=="file")throw new l("INVALID_FILE_TYPE",e,"not-applied");let m=Number(n.size),R=Number(n.mode),d="revision"in n?n.revision:F(n);C(e,d,i);let g;try{g=w?await w.backend.lstat(w.location.path,a):await U(t)}catch(p){if(!ye(p))throw p}if(g!==void 0){if("kind"in g&&g.kind!=="file")throw new l("INVALID_FILE_TYPE",t,"not-applied");if(C(t,"revision"in g?g.revision:F(g),i),c&&w&&c.backend.target.host===w.backend.target.host&&c.backend.target.configFile===w.backend.target.configFile&&"identity"in n&&"identity"in g&&n.identity.device===g.identity.device&&n.identity.inode===g.identity.inode)throw new l("SAME_FILE",e,"not-applied")}let u=g===void 0?null:"revision"in g?g.revision:F(g);return g===void 0&&C(t,null,i),{source:e,target:t,remoteSource:c,remoteTarget:w,size:m,mode:R,sourceRevision:d,targetRevision:u}}s(je,"prepareTransfer");async function V(r,o,a,i,c,w){let{source:e,target:t,remoteSource:n,remoteTarget:m,size:R,mode:d,sourceRevision:g,targetRevision:u}=await je(r,a,i,c);await w?.();let p=n?void 0:await me(e,we.O_RDONLY|we.O_NOFOLLOW),f,h,y,v=!1,T="",E=s(async()=>{let k=n?await n.backend.lstat(n.location.path,i):await U(e);if(("revision"in k?k.revision:F(k))!==g)throw new l("CONFLICT",e,"not-applied")},"verifySource");try{if(p&&F(await p.stat({bigint:!0}))!==g)throw new l("CONFLICT",e,"not-applied");m?(y=await de(m.backend.target,"python3",["-c",await De,JSON.stringify({destination:m.location.path,size:R,mode:d,expected:u})],"/",i),y.completion.catch(()=>{}),y.stdout.on("data",b=>{T.length<=8192&&(T+=b.toString("utf8")),T.length>8192&&y?.stop().catch(()=>{})}),y.stderr.resume()):(await Ne(D.dirname(t),{recursive:!0}),f=D.join(D.dirname(t),`.pi-ide-transfer-${Te(12).toString("hex")}`),h=await me(f,"wx",d&4095));let k=Pe("sha256");for(let b=0;b<R;){i.signal?.throwIfAborted();let S=Math.min(Be,R-b),I;if(n){let P=await n.backend.readRange(n.location.path,b,S,i);if(P.revision!==g||P.offset!==b||P.totalBytes!==R)throw new l("CONFLICT",e,"not-applied");I=P.bytes}else{if(p===void 0)throw new Error("Missing source descriptor");let P=Buffer.allocUnsafe(S),{bytesRead:B}=await p.read(P,0,S,b);I=P.subarray(0,B)}if(I.length===0)throw new l("CONFLICT",e,"not-applied");if(k.update(I),y)await y.write(I);else{if(h===void 0)throw new Error("Missing destination descriptor");for(let P=0;P<I.length;){let B=await h.write(I,P,I.length-P);if(B.bytesWritten===0)throw new l("TRANSFER_FAILED",t,"not-applied");P+=B.bytesWritten}}b+=I.length}await E(),await w?.();let O=k.digest("hex");if(i.signal?.throwIfAborted(),y){if(await y.write(Buffer.from(`${JSON.stringify({sha256:O})}
|
|
3
3
|
`)),await y.end(),(await y.completion).exitCode!==0||T.length>8192)throw new l("TRANSFER_FAILED",t,"unknown");let S;try{S=JSON.parse(T)}catch{throw new l("INVALID_REPLY",t,"unknown")}if(S===null||typeof S!="object"||!("ok"in S))throw new l("INVALID_REPLY",t,"unknown");if(S.ok!==!0){let I="effect"in S&&(S.effect==="not-applied"||S.effect==="applied")?S.effect:"unknown";throw new l(ge(S),t,I)}if(!("sha256"in S)||S.sha256!==O)throw new l("CHECKSUM_MISMATCH",t,"unknown");v=!0}else{if(h===void 0||f===void 0)throw new Error("Missing staged destination");await h.chmod(d&4095),await h.sync(),await h.close(),h=void 0;let b=null;try{b=F(await U(t))}catch(S){if(!ye(S))throw S}if(b!==u)throw new l("CONFLICT",t,"not-applied");i.signal?.throwIfAborted(),await _e(f,t),f=void 0,v=!0}return o==="move"&&(await E(),n?await n.backend.removeEntry(n.location.path,g,i):await Fe(e)),{source:e,target:t}}catch(k){throw v?new l(ge(k),e,"unknown"):k}finally{await p?.close(),await h?.close(),f!==void 0&&await Ae(f,{force:!0}),y&&await y.stop().catch(()=>{})}}s(V,"transferFile");function Re(r,o,a){let i=r.resolve(o,a.cwd);if(i===void 0){let e=j(o,a.cwd);return{path:e,source:e,cwd:a.cwd,files:x}}let c=r.resolve(a.cwd,a.cwd),w=c?.location.target===i.location.target?c.location.path:i.backend.target.workspace;return{remote:i,source:i.location.source,path:i.location.path,cwd:w,files:{owner:JSON.stringify([i.backend.target.host,i.backend.target.configFile??null]),realpath:s(e=>i.backend.realpath(e,a),"realpath"),inspect:s(e=>i.backend.lstat(e,a),"inspect"),read:s(async e=>(await i.backend.read(e,a)).bytes.toString("utf8"),"read"),git:s((e,t,n)=>i.backend.queryGit(e,t,{...a,signal:n}),"git"),source:s(e=>N(i.location.target,e).source,"source"),snapshot:s((e,t)=>i.backend.objectSnapshot(e,{...a,signal:t}),"snapshot")}}}s(Re,"endpoint");function L(r,o,a){let i=r.remote?A.posix:A;if(i.sep==="\\"&&a.split("/").some(c=>c.includes("\\")||c.includes(":")))throw new l("INVALID_TARGET",r.source,"not-applied");return i.join(o,...a.split("/"))}s(L,"leaf");function G(r,o){return r.remote?N(r.remote.location.target,o).source:o}s(G,"receiptPath");async function _(r,o,a){let i;try{i=await r.files.inspect(o)}catch(c){if(c!==null&&typeof c=="object"&&"code"in c&&c.code==="ENOENT"){if(a===void 0)return}else throw c}if(a===void 0||i?.revision!==a.revision)throw new l("TRANSFER_TARGET_CHANGED",G(r,o),"not-applied")}s(_,"checkEntry");async function M(r){let o;try{o=await Ue(r)}catch(a){if(a===null||typeof a!="object"||!("code"in a)||a.code!=="ENOENT")throw a;await M(A.dirname(r)),await Ee(r);return}if(!o.isDirectory()||o.isSymbolicLink())throw new l("INVALID_FILE_TYPE",r,"not-applied");A.dirname(r)!==r&&await M(A.dirname(r))}s(M,"directoryParents");async function ve(r,o,a,i){r.remote?await r.remote.backend.removeObject(o,a.revision,i):(await _(r,o,a),a.kind==="directory"?await Me(o,{recursive:!0,force:!1}):await Ve(o))}s(ve,"remove");async function ke(r,o,a,i,c,w){let e=Re(r,a.path,i),t=Re(r,a.target??"",i),n=await c.prepareTransfer(o,e,t),m=n.source.entries[0];if(m===void 0)throw new l("ENOENT",e.source,"not-applied");e.remote&&C(e.source,m.revision,w),t.remote&&C(t.source,n.target.entries[0]?.revision??null,w);let R=!1;try{i.signal?.throwIfAborted();for(let d of n.source.entries)L(e,n.source.path,d.relativePath),L(t,n.target.path,d.relativePath);if(n.sourceKind==="file")e.remote&&t.remote&&e.remote.location.target===t.remote.location.target?await e.remote.backend[o](n.source.path,n.target.path,m.revision,n.target.entries[0]?.revision??null,i):await V(r,o,a,i,w,async()=>{await _(e,n.source.path,m),await _(t,n.target.path,n.target.entries[0])});else{if(o==="move"&&e.remote&&t.remote&&e.files.owner===t.files.owner&&await e.remote.backend.moveObject(n.source,n.target,i))return{kind:"file-operation",operation:o,ok:!0,effect:"applied",path:e.source,target:t.source,sourceKind:n.sourceKind};let d=new Map(n.target.entries.map(u=>[u.relativePath,u])),g=new Map;o==="move"&&n.target.entries[0]&&(R=!0,await ve(t,n.target.path,n.target.entries[0],i),d.clear());for(let u of n.source.entries){i.signal?.throwIfAborted();let p=L(e,n.source.path,u.relativePath),f=L(t,n.target.path,u.relativePath);await _(e,p,u);let h=d.get(u.relativePath);if(await _(t,f,h),u.kind==="directory")h===void 0&&(R=!0),t.remote?await t.remote.backend.ensureObjectDirectory(f,u.mode|448,h?.revision??null,i):h===void 0&&(await M(A.dirname(f)),await Ee(f,{mode:u.mode|448})),h===void 0&&g.set(u.relativePath,(await t.files.inspect(f)).identity);else if(u.kind==="symlink"){if(R=!0,u.link===void 0)throw new l("INVALID_RESPONSE",e.source,"unknown");t.remote?await t.remote.backend.createObjectLink(f,u.link,i):(await M(A.dirname(f)),await He(Buffer.from(u.link,"base64"),f))}else{R=!0;let y=G(e,p),v=G(t,f);e.remote&&t.remote&&e.files.owner===t.files.owner?await e.remote.backend.copy(p,f,u.revision,h?.revision??null,i):await V(r,"copy",{path:y,target:v},i,void 0,async()=>{await _(e,p,u),await _(t,f,h)})}}for(let u of[...n.source.entries].reverse()){if(u.kind!=="directory"||d.has(u.relativePath))continue;let p=L(t,n.target.path,u.relativePath),f=await t.files.inspect(p),h=g.get(u.relativePath);if(f.kind!=="directory"||h?.device!==f.identity.device||h.inode!==f.identity.inode)throw new l("TRANSFER_TARGET_CHANGED",t.source,"unknown");if(t.remote)await t.remote.backend.setObjectMode(p,u.mode,f.revision,i);else{let y=await ze(p,z.O_RDONLY|z.O_DIRECTORY|z.O_NOFOLLOW);try{let v=await y.stat();if(String(v.dev)!==h.device||String(v.ino)!==h.inode)throw new l("TRANSFER_TARGET_CHANGED",t.source,"unknown");await y.chmod(u.mode&4095)}finally{await y.close()}}}await n.verifySource(),o==="move"&&await ve(e,n.source.path,m,i)}return{kind:"file-operation",operation:o,ok:!0,effect:"applied",path:e.source,target:t.source,sourceKind:n.sourceKind}}catch(d){throw R?Object.assign(d instanceof Error?d:new Error(String(d)),{effect:"unknown"}):d}}s(ke,"transferObject");function Se(r,o){return async(a,i,c,w)=>{let e=r.resolve(i.path,c.cwd);if(e===void 0&&(i.target===void 0||r.resolve(i.target,c.cwd)===void 0))return;if(a!=="delete"){if(w===void 0)throw new l("TRANSFER_POLICY_REQUIRED",i.path,"not-applied");return ke(r,a,i,c,w,o)}if(e===void 0)return;let t=await e.backend.lstat(e.location.path,c);C(e.location.source,t.revision,o);{if(w===void 0)throw new l("DELETE_POLICY_REQUIRED",e.location.source,"not-applied");let n=r.resolve(c.cwd,c.cwd);if(n!==void 0&&n.location.target!==e.location.target)throw new l("UNSUPPORTED_SOURCE",e.location.source,"not-applied");let m=n?.location.path??e.backend.target.workspace,R=await w.prepare(e.location.path,m,{temporaryEnvironment:s(d=>e.backend.temporaryEnvironment({...c,signal:d}),"temporaryEnvironment"),realpath:s(d=>e.backend.realpath(d,c),"realpath"),inspect:s(d=>e.backend.lstat(d,c),"inspect"),read:s(async d=>(await e.backend.read(d,c)).bytes.toString("utf8"),"read"),git:s((d,g,u)=>e.backend.queryGit(d,g,{...c,signal:u}),"git"),source:s(d=>N(e.location.target,d).source,"source")});if(R.revision!==t.revision)throw new l("DELETE_TARGET_CHANGED",e.location.source,"not-applied");return await e.backend.removeObject(R.resolvedPath,R.revision,c),{kind:"file-operation",operation:a,ok:!0,effect:"applied",path:e.location.source}}}}s(Se,"createSshFileOperationResolver");function Y(r,o,a){return{id:"ssh",async tryResolve(i,c){try{let w=r.resolve(i,c.cwd);if(!w)return{kind:"not-handled"};let{backend:e,location:t}=w,n=!1;try{n=(await e.stat(t.path,c)).kind==="directory"}catch(p){if(!(p instanceof l)||p.code!=="ENOENT")throw p}let m,R,d=s(async p=>{try{let f=await e.read(t.path,p);return m=f.version,f.bytes}catch(f){throw f instanceof l&&f.code==="ENOENT"&&(m=null),f}},"snapshot"),g=s(async p=>{if(R=void 0,n){let h=(await e.list(t.path,p)).map(y=>` ${y.kind==="directory"?"\u{1F4C1}":y.kind==="file"?"\u{1F4C4}":"\u{1F517}"} ${y.name}`);return[{type:"text",text:[`\u{1F4C1} ${t.source}/`,...h.length?["",...h]:[]].join(`
|
|
4
4
|
`)}]}return R=await d(p),o.convert({source:t.source,bytes:R},p)},"read"),u=s(async(p,f,h)=>{let v=await e.readRange(t.path,p,Math.min(f??4194304,4194304),h),T=[v.bytes],E=v.bytes.length,k=Math.min(f??v.totalBytes,v.totalBytes-v.offset);for(;E<k;){let O=await e.readRange(t.path,v.offset+E,Math.min(k-E,4194304),h);if(O.revision!==v.revision||O.totalBytes!==v.totalBytes||O.offset!==v.offset+E)throw new l("SOURCE_CHANGED",t.source,"not-applied");if(O.bytes.length===0)break;T.push(O.bytes),E+=O.bytes.length}return{bytes:Buffer.concat(T,E),byteOffset:v.offset,totalBytes:v.totalBytes}},"readBytes");return a==="read"||n?{kind:"resolved",resource:{source:t.source,link:t.source,read:g,get sourceBytes(){return R},...n?{}:{readBytes:u}}}:{kind:"resolved",resource:{source:t.source,link:t.source,read:g,readBytes:u,get sourceBytes(){return R},async write(p,f){let h=J(p);if(m===void 0)try{await d(f)}catch(y){if(!(y instanceof l)||y.code!=="ENOENT")throw y}if(m===void 0)throw new l("SNAPSHOT_REQUIRED",t.source,"not-applied");m=await e.write(t.path,Buffer.from(h,"utf8"),m,f)}}}}catch(w){return{kind:"failed",error:w}}}}}s(Y,"createSshResourceResolver");async function be(r,o){let a=await Z({id:"ssh",description:"Set up SSH targets and use remote resources",triggers:[{tool:"read",resourcePrefixes:["ssh://","raw:ssh://","ast:ssh://","web:ssh://"]},{tool:"search",resourcePrefixes:["ssh://","web:ssh://"]},{tool:"debug",resourcePrefixes:["ssh://"]},...["write","replace","insert","delete","copy","move","stage","unstage","undo"].map(n=>({tool:n,resourcePrefixes:["ssh://"]}))]});if(ee(r,[{...a,markdown:`${a.markdown}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as q}from"./chunk-756K3LJY.js";import{m as E}from"./chunk-VDJSH3DQ.js";import{a}from"./chunk-EI7MMDWY.js";import O from"cross-spawn";import{fileURLToPath as S}from"node:url";var T=5e3,R=10*1024*1024,P=S(new URL(".",new URL("../src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts",import.meta.url).href));function j(n){let t=n?.filter(r=>r==="jq"||r.startsWith("jq:"))??[];if(t.length===0)return;if(t.length>1)throw new Error("Read accepts only one jq view");if(n?.length!==1)throw new Error("The jq view cannot be combined with other views. Keep only one jq:<filter> in views.");let e=t[0];if(e===void 0||e==="jq"||e.slice(3).trim().length===0)throw new Error('The jq view requires a filter, for example views: ["jq:.scripts"]');return{filter:e.slice(3)}}a(j,"parseJqView");function y(n,t,e){return e.signal?.aborted===!0?Promise.reject(new Error("jq execution was cancelled")):J(n)?Promise.reject(new Error("jq module loading is disabled")):new Promise((r,s)=>{let i=O(e.command??"jq",["-L",P,"--",n],{cwd:e.cwd,env:b(e.cwd),shell:!1,stdio:["pipe","pipe","pipe"],windowsHide:!0}),d="",u="",c=!1,p=0,l=a(o=>{c||(c=!0,clearTimeout(h),e.signal?.removeEventListener("abort",m),o===void 0?r(d):s(o))},"finish"),g=a(o=>{i.kill(),l(o)},"stop"),m=a(()=>g(new Error("jq execution was cancelled")),"abort"),h=setTimeout(()=>g(new Error(`jq did not finish within ${T/1e3} seconds`)),T);h.unref(),e.signal?.addEventListener("abort",m,{once:!0}),i.stdout?.setEncoding("utf8"),i.stderr?.setEncoding("utf8"),i.stdout?.on("data",o=>{if(p+=Buffer.byteLength(o),p>R){g(new Error(`jq output exceeded ${R/1024/1024}MB`));return}d+=o}),i.stderr?.on("data",o=>{Buffer.byteLength(u)<16384&&(u+=o)}),i.once("error",o=>l(new Error(`Cannot start jq: ${o.message}`))),i.once("close",(o,w)=>{if(!c)if(o===0)l();else{let x=u.trim().split(/\r?\n/u).slice(0,8).join(`
|
|
2
2
|
`);l(new Error(x||`jq exited ${w===null?`with code ${String(o)}`:`after signal ${w}`}`))}}),i.stdin?.once("error",o=>l(new Error(`Cannot send JSON to jq: ${o.message}`))),i.stdin?.end(t)})}a(y,"executeJq");function J(n){let t=[0],e=0,r="";for(;e<n.length;){let s=n[e],i=t.at(-1);if(i==="string"){s==="\\"?(n[e+1]==="("&&(t.push(0),r=""),e+=2):(s==='"'&&(t.pop(),r='"'),e+=1);continue}if(s==="#"){let d=n.indexOf(`
|
|
3
3
|
`,e);e=d<0?n.length:d+1;continue}if(s==='"')t.push("string");else if(s==="(")t[t.length-1]=(i??0)+1;else if(s===")")t.length>1&&i===0?t.pop():t[t.length-1]=Math.max(0,(i??0)-1);else if(/[A-Za-z_]/u.test(s??"")){let d=e;for(;/[A-Za-z0-9_]/u.test(n[e]??"");)e+=1;let u=n.slice(d,e),c=_(n,e),p=r==="."||r==="$",l=c.startsWith(":")&&!c.startsWith("::");if(!p&&!l&&(u==="include"||u==="import"||u==="modulemeta"))return!0;r=u;continue}s!==void 0&&!/\s/u.test(s)&&(r=s),e+=1}return!1}a(J,"hasModuleOperation");function _(n,t){let e=t;for(;e<n.length;)if(/\s/u.test(n[e]??""))e+=1;else if(n[e]==="#"){let r=n.indexOf(`
|
|
4
4
|
`,e);e=r<0?n.length:r+1}else break;return n.slice(e,e+2)}a(_,"nextCode");function b(n){let t=q(n,process.env),e={};for(let r of["PATH","PATHEXT","SystemRoot","SYSTEMROOT","WINDIR"])t[r]!==void 0&&(e[r]=t[r]);return e}a(b,"safeEnvironment");function $(n){return async t=>{let e;try{e=j(t.request.views)}catch(u){return f(t,n.pluginId,"READ_FAILED",v(u))}if(e===void 0)return{kind:"continue",context:t};if(t.inputScope==="selection"||t.sourceTarget!==void 0)return f(t,n.pluginId,"UNSUPPORTED_RANGE","jq requires a complete JSON source. Read its explicit path instead of a result, search selection or text anchor.");if(t.inputScope!=="source")return f(t,n.pluginId,"READ_FAILED","This jq view requires a matching Read host that classifies complete source inputs.");let r=t.state;if(r?.contentKind!=="text")return f(t,n.pluginId,"UNSUPPORTED_CONTENT","This source does not supply structured JSON for jq.");let s=n.input(t);if(typeof s!="string")return f(t,n.pluginId,"UNSUPPORTED_CONTENT","This source does not supply structured JSON for jq.");let i;try{i=await y(e.filter,s,{cwd:t.resolverContext.cwd,...t.resolverContext.signal===void 0?{}:{signal:t.resolverContext.signal}})}catch(u){return f(t,n.pluginId,"READ_FAILED",v(u))}let d={...r,content:[{type:"text",text:i}],text:E(r.source,i),preserveTruncatedOutput:!0};return{kind:"continue",context:{...t,sourceText:void 0,sourceTarget:void 0,state:d}}}}a($,"createJqReadHandler");function v(n){return n instanceof Error?n.message:String(n)}a(v,"message");function f(n,t,e,r){let s=n.state?.source??n.request.path,i=n.state?.resolvedBy;return{kind:"return",result:{content:[{type:"text",text:`jq failed: ${r}`}],details:{source:s,resolvedBy:i,failure:{code:e,source:s,resolverId:i,pluginId:t,stage:"read",message:r}},isError:!0}}}a(f,"failure");export{$ as a};
|
package/dist/entry-0.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as le}from"./chunk-PLMHBXWI.js";import{c as te,d as re}from"./chunk-RVFMH77U.js";import"./chunk-J34VKQGJ.js";import{a as ie}from"./chunk-WAJW4G4F.js";import{b as oe}from"./chunk-YHADTHQM.js";import"./chunk-6WCHBHFW.js";import"./chunk-MXLSGMRZ.js";import"./chunk-FEZLTM4L.js";import{a as ae}from"./chunk-WEE3NM6L.js";import{a as ne}from"./chunk-C2JT2G5K.js";import"./chunk-UD3DMY3Q.js";import"./chunk-STUZZM5B.js";import{a as q}from"./chunk-KFBRL2V4.js";import{b as ee}from"./chunk-WUO3UW4J.js";import"./chunk-OBTT5INC.js";import{a as se}from"./chunk-NA2NEU4V.js";import"./chunk-QJ6V5IAY.js";import"./chunk-5BGWNYQS.js";import{a as K,b as Z}from"./chunk-H7WAM5RH.js";import"./chunk-2TZDG2JH.js";import"./chunk-IG5DXVDJ.js";import"./chunk-XH5WN5XA.js";import"./chunk-R2U5WXYR.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import"./chunk-FYOU4RBH.js";import"./chunk-7PVDTMEM.js";import{a as F}from"./chunk-H5Z54BEU.js";import"./chunk-WES2E4VR.js";import"./chunk-YGGKGZO2.js";import"./chunk-5S74Z6Y4.js";import"./chunk-GS5ZRTUG.js";import"./chunk-MPT3R4BL.js";import"./chunk-KN6VPARZ.js";import"./chunk-MDD5ORB6.js";import"./chunk-MLFJU2US.js";import"./chunk-52PFWQMU.js";import"./chunk-OMNKD7WW.js";import{e as Q}from"./chunk-PS2B6THP.js";import"./chunk-YPYROPQF.js";import"./chunk-GXL4NMHR.js";import{c as B,d as Y}from"./chunk-PQWANILR.js";import{a as X}from"./chunk-BU7IZLKB.js";import{a as V,b as J}from"./chunk-S5PL5DFQ.js";import{N as k}from"./chunk-DDH3FP4G.js";import{c as G}from"./chunk-RQ7JJ7GV.js";import"./chunk-VDJSH3DQ.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import{a as n}from"./chunk-EI7MMDWY.js";import{Type as Re}from"typebox";var ce=["read","search","write","replace","insert","delete","copy","move","diff"],de={read:["path"],search:["path"],write:["path"],replace:["path"],insert:["path"],delete:["path"],copy:["path","target"],move:["path","target"],diff:["before","after"]},ue=new Set(["read","search","diff"]),pe="pi-agent-ide/standalone-reservation/v1",m=n(a=>a!==null&&typeof a=="object"&&!Array.isArray(a),"record"),fe=n(a=>a.startsWith("pi-agent-ide/operation-approval/")||a.startsWith("pi-agent-ide/settings/"),"shared");function me(a,h){let d=h.namespace.name;if(!/^[a-z][a-z0-9_]*$/u.test(d))throw new Error("Resource host namespace must be a lowercase identifier.");let w=new Set(h.tools??ce);if([...w].some(e=>!ce.includes(e)))throw new Error("Unsupported resource host tool.");let p={namespace:d,claimed:!1};if(a.events.emit(pe,p),p.claimed)throw new Error(`Resource host namespace already registered: ${d}`);let A=a.events.on(pe,e=>{m(e)&&e.namespace===d&&(e.claimed=!0)}),R=new Map,u=new Set,g=[A],S=new Map,I=new Map,C=new Set,E=!1,D,_,y=n(e=>`${d}_${e}`,"publicName"),b=n(e=>typeof e=="string"&&e.startsWith(d+"_")&&w.has(e.slice(d.length+1))?e.slice(d.length+1):void 0,"localName"),H=n(e=>e.replace(/\b(?:read|search|select|write|replace|insert|delete|copy|move|diff)\b/gu,(o,t)=>{let s=e.slice(0,t),r=e.slice(t+o.length);return s.endsWith("tools.")||s.endsWith("`")&&/^[`.]/u.test(r)||/(?:\bUse|\band) $/u.test(s)&&r.startsWith(" to ")?y(o):o}),"words");function U(e,o){let t=e.startsWith("raw:")&&!o?e.slice(4):e;return!o&&(t.startsWith("docs:")||t.startsWith("temp:"))?!0:/^[a-z][a-z\d+.-]*:\/\//iu.test(t)&&!/^(?:file:|[a-z]:[/\\])/iu.test(t)&&h.ownsSource(t)}n(U,"owns");let j=n(()=>k(_),"targets");async function x(e,o,t){let s=j().source(e,o.cwd,!t);if(Array.isArray(s)){for(let r of s)await x(r,o,t);return}if(m(s)&&"path"in s){await x(s.path,o,t);return}if(typeof s!="string")throw new Error("Use an owned resource URI or an issued source result.");if(s.startsWith("RESULT#")){let r=j().resolve(s,o.cwd);if(r.targets.some(f=>!U(f.source,t)))throw new Error("Source selection belongs outside this resource host.");await j().verify(r,o.signal);return}if(s.startsWith("SEARCH#")){let r=await D?.read({path:s},{cwd:o.cwd,signal:o.signal},"script");if(r?.isError||r?.script?.kind!=="text"||!r.script.target)throw new Error("Unknown or expired resource search selection.");await x(r.script.target,o,t);return}if(!U(s,t))throw new Error("Use this host only for its provider-owned resource URIs; local paths are not supported.")}n(x,"checkSource");async function M(e,o,t){if(E)throw new Error("Standalone resource host is closed.");if(!m(o))throw new Error("Resource tool arguments must be an object.");let s=!ue.has(e),r=de[e]??[];if(["read","search"].includes(e)&&o.path===void 0)throw new Error("Supply an explicit owned resource or source result.");if(s&&o.path===void 0){let f=oe(_)?.source;if(!f)throw new Error("Supply an owned source before editing.");await x(f,t,!0)}for(let f of r)o[f]!==void 0&&await x(o[f],t,s);for(let f of["start","end","anchor","targetStart","targetEnd"]){let c=o[f];typeof c=="string"&&/^(?:RESULT#|SEARCH#|<system-result)/u.test(c)&&await x(c,t,s)}if(e==="write"&&typeof o.content!="string")throw new Error("Standalone resource Write accepts text/JSON content, not filesystem image writes.")}n(M,"validate");let P=n((e,o)=>a.on(e,async(t,s)=>await o({...t},s)),"subscribe");g.push(P("tool_call",async(e,o)=>{let t=b(e.toolName);if(t)try{await M(t,e.input,o)}catch(s){return{block:!0,reason:s instanceof Error?s.message:String(s)}}}));let ge=n((e,o)=>{let t=o;if(e==="session_shutdown")return u.add(t),()=>{u.delete(t)};let s=P(e,async(r,f)=>{if(E)return;let c=r;if(e.startsWith("tool_")){let i=b(r.toolName);if(i)typeof r.parentToolCallId=="string"&&C.add(r.parentToolCallId),c={...r,toolName:i};else if(typeof r.toolCallId=="string"&&C.has(r.toolCallId))c={...r,toolName:r.toolName==="codemode"?"codemode":"__standalone_parent"};else return}if(e==="message_end"){if(!m(r.message)||r.message.role!=="toolResult")return;let i=b(r.message.toolName);if(!i)return;c={...r,message:{...r.message,toolName:i}}}e==="context"&&Array.isArray(r.messages)&&(c={...r,messages:r.messages.map(i=>m(i)&&typeof i.toolName=="string"?{...i,toolName:b(i.toolName)??"__outside_resource_host"}:i)});let l=await t(c,f);if(!m(l))return l;if(e==="message_end"&&m(l.message)&&m(r.message))return{...l,message:{...l.message,toolName:r.message.toolName}};if(e==="context"&&Array.isArray(l.messages)&&Array.isArray(r.messages)){let i=r.messages;if(l.messages.length!==i.length)throw new Error("Resource host context handlers must preserve message positions.");return{...l,messages:l.messages.map((N,O)=>{let T=i[O];return m(N)&&m(T)&&typeof T.toolName=="string"?{...N,toolName:T.toolName}:N})}}return l});return g.push(s),s},"on"),he={emit(e,o){if(E)throw new Error("Standalone resource host is closed.");if(fe(e))a.events.emit(e,o);else for(let t of R.get(e)??[])t(o)},on(e,o){if(fe(e)){let s=a.events.on(e,o);return g.push(s),s}let t=R.get(e);return t||R.set(e,t=new Set),t.add(o),()=>{t.delete(o)}}};function W(e){return Array.isArray(e)?e.map(W):m(e)?Object.fromEntries(Object.entries(e).map(([o,t])=>[o,o==="description"&&typeof t=="string"?H(t):W(t)])):e}n(W,"descriptions");function we(e){return{...e,tools:e.tools.flatMap(o=>{let t=b(o.name);return t?[{...o,name:t}]:[]}),executeTool(o,t,s){if(!w.has(o))throw new Error("Tool is not owned by this resource host.");return e.executeTool(y(o),t,s)}}}n(we,"toolContext"),_={...a,events:he,on:ge,registerTool:n(e=>{let o=e.name;if(!w.has(o))return;let t=Object.getOwnPropertyDescriptors(e);t.name={value:y(o),enumerable:!0,configurable:!0},t.label={value:y(o),enumerable:!0,configurable:!0},t.namespace={value:h.namespace,enumerable:!0,configurable:!0},t.exposure={value:"deferred",enumerable:!0,configurable:!0},t.description={get:n(()=>`Use ${y(o)} to ${o==="read"?"inspect provider-owned resources and packaged guides":o==="search"?"find objects or text within an explicit provider-owned resource":`${o} provider-owned text resources`}.`,"get"),enumerable:!0,configurable:!0},t.promptSnippet={get:n(()=>H(e.promptSnippet??""),"get"),enumerable:!0,configurable:!0},t.promptGuidelines={get:n(()=>[...(e.promptGuidelines??[]).map(H),"Use only this namespace's owned resource URIs and issued results. Local filesystem paths are not supported."],"get"),enumerable:!0,configurable:!0},t.parameters={get:n(()=>{let c=W(e.parameters),l=m(c.properties)?{...c.properties}:{};for(let i of de[o]??[])m(l[i])&&(l[i]={...l[i],description:"Provider-owned resource URI, unchanged source result, or an issued reference."});return o==="write"&&(l.content=Re.String({description:"Complete text/Markdown or JSON payload for the selected provider resource."})),Object.assign({},e.parameters,c,{properties:l})},"get"),enumerable:!0,configurable:!0};let s=n(async(c,l,i,N,O)=>{if(E)throw new Error("Standalone resource host is closed.");let T=new AbortController,L=n(()=>{},"finish"),ye=new Promise(v=>{L=v});S.set(T,ye);let be=[i,O.signal,T.signal].filter(v=>v!==void 0),$=AbortSignal.any(be);try{let v={...we(O),signal:$};return await M(o,l,v),$.throwIfAborted(),await e.execute(c,l,$,N,v)}finally{S.delete(T),L()}},"execute");t.execute={value:s,enumerable:!0,configurable:!0};let r=n((c,l,i)=>!ue.has(o)&&e.renderCall?e.renderCall(c,l,i):Q(i.lastComponent,{tool:y(o),primary:{text:m(c)?String(c.path??c.query??"owned resource"):"owned resource",truncate:"end"},expanded:i.expanded},l),"renderCall");t.renderCall={value:r,enumerable:!0,configurable:!0};let f=Object.defineProperties({},t);I.set(o,()=>a.registerTool({...f,exposure:"hidden"})),a.registerTool(f)},"registerTool"),getActiveTools:n(()=>a.getActiveTools().flatMap(e=>{let o=b(e);return o?[o]:[]}),"getActiveTools"),getAllTools:n(()=>a.getAllTools().flatMap(e=>{let o=b(e.name);return o?[{...e,name:o}]:[]}),"getAllTools"),setActiveTools(e){let o=a.getActiveTools().filter(t=>!b(t));a.setActiveTools([...o,...e.filter(t=>w.has(t)).map(y)])}},g.push(P("session_start",()=>{C.clear(),!(a.getSettings().defaultTools??[]).includes("-tool_search")&&a.getAllTools().some(e=>e.name==="tool_search"&&e.exposure!=="hidden")&&!a.getActiveTools().includes("tool_search")&&a.setActiveTools([...a.getActiveTools(),"tool_search"])})),g.push(P("agent_end",()=>{C.clear()}));async function z(e,o=!0){if(E)return;E=!0;for(let r of S.keys())r.abort();await Promise.all(S.values());let t=await Promise.allSettled([...u].map(r=>r({type:"session_shutdown"},e)));for(let r of g)r();if(R.clear(),u.clear(),C.clear(),o)for(let r of I.values())r();I.clear();let s=t.find(r=>r.status==="rejected");if(s?.status==="rejected")throw s.reason}return n(z,"dispose"),g.push(P("session_shutdown",(e,o)=>z(o,!1))),{api:_,owns:U,tools:[...w].map(y),dispose:z,setApi(e){_=e},setRead(e){D=e}}}n(me,"createResourceHostApi");async function Se(a,h){G(a);let d=me(a,h),w=F(d.api,{resourceOutput:!0,promptSection:`resource_${h.namespace.name}_results`}),p=w.api;d.setApi(p);try{await Z(p);let A;await X(p,{protocol:V,apiVersion:J,id:"standalone-resource-boundary",setup(u){A=u,d.setRead(u),u.addResourceGuard({id:"standalone-resource-boundary",guard:n(g=>d.owns(g.resourceSource,!1)?{kind:"accepted"}:{kind:"rejected",reason:"Resource belongs outside this standalone host."},"guard")}),u.addHandler({stage:"post-read",handler:K(k(p),u.read,g=>d.owns(g,!0))})}}),await q(p);let R=await te(p);if(await R.registerPlugin({protocol:B,apiVersion:Y,id:"standalone-resource-boundary",setup(u){u.addMutationGuard({id:"standalone-resource-boundary",guard:n(g=>g.resources.every(S=>d.owns(S.source,!0)&&S.binary===void 0)?{kind:"accepted"}:{kind:"rejected",rejection:{code:"RESOURCE_HOST_BOUNDARY",reason:"Resource belongs outside this standalone host.",message:"Use this host only for its provider-owned text resources.",effect:"not-applied"}},"guard")})}}),await se(p),await ne(p),await ae(p),await ee(p),!A)throw new Error("Standalone Read host did not initialize.");return await le(p,{recordType:`agent-documentation-read/${h.namespace.name}`,ownsTool:n(u=>typeof u=="string"&&d.tools.includes(u),"ownsTool")}),await ie(p,{preferences:{},toolName:n(u=>`${h.namespace.name}_${u}`,"toolName")}),re(p,R),w.finalize(),{api:p,tools:d.tools,dispose:n(u=>d.dispose(u),"dispose")}}catch(A){throw await d.dispose(),A}}n(Se,"createStandaloneResourceHost");export{Se as createStandaloneResourceHost};
|
|
1
|
+
import{a as le}from"./chunk-FXPY3V4L.js";import{c as te,d as re}from"./chunk-HISGZD3C.js";import"./chunk-J34VKQGJ.js";import{a as ie}from"./chunk-WAJW4G4F.js";import{b as oe}from"./chunk-YHADTHQM.js";import"./chunk-6WCHBHFW.js";import"./chunk-MXLSGMRZ.js";import"./chunk-FEZLTM4L.js";import{a as ae}from"./chunk-WEE3NM6L.js";import"./chunk-QJ6V5IAY.js";import{a as ne}from"./chunk-C2JT2G5K.js";import"./chunk-UD3DMY3Q.js";import"./chunk-STUZZM5B.js";import{a as q}from"./chunk-HKYVP2Q6.js";import{b as ee}from"./chunk-PCGBM2D6.js";import"./chunk-OBTT5INC.js";import"./chunk-5BGWNYQS.js";import{a as se}from"./chunk-NA2NEU4V.js";import{a as K,b as Z}from"./chunk-H7WAM5RH.js";import"./chunk-2TZDG2JH.js";import"./chunk-IG5DXVDJ.js";import"./chunk-XH5WN5XA.js";import"./chunk-R2U5WXYR.js";import"./chunk-FYOU4RBH.js";import"./chunk-7PVDTMEM.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import{a as F}from"./chunk-H5Z54BEU.js";import"./chunk-WES2E4VR.js";import"./chunk-YGGKGZO2.js";import"./chunk-5S74Z6Y4.js";import"./chunk-GS5ZRTUG.js";import"./chunk-MPT3R4BL.js";import"./chunk-KN6VPARZ.js";import"./chunk-MDD5ORB6.js";import"./chunk-MLFJU2US.js";import"./chunk-52PFWQMU.js";import"./chunk-OMNKD7WW.js";import{e as Q}from"./chunk-PS2B6THP.js";import"./chunk-YPYROPQF.js";import"./chunk-GXL4NMHR.js";import{c as B,d as Y}from"./chunk-PQWANILR.js";import{a as X}from"./chunk-BU7IZLKB.js";import{a as V,b as J}from"./chunk-S5PL5DFQ.js";import{N as k}from"./chunk-DDH3FP4G.js";import"./chunk-756K3LJY.js";import{c as G}from"./chunk-RQ7JJ7GV.js";import"./chunk-VDJSH3DQ.js";import"./chunk-ZC65Z3CK.js";import{a as n}from"./chunk-EI7MMDWY.js";import{Type as Re}from"typebox";var ce=["read","search","write","replace","insert","delete","copy","move","diff"],de={read:["path"],search:["path"],write:["path"],replace:["path"],insert:["path"],delete:["path"],copy:["path","target"],move:["path","target"],diff:["before","after"]},ue=new Set(["read","search","diff"]),pe="pi-agent-ide/standalone-reservation/v1",m=n(a=>a!==null&&typeof a=="object"&&!Array.isArray(a),"record"),fe=n(a=>a.startsWith("pi-agent-ide/operation-approval/")||a.startsWith("pi-agent-ide/settings/"),"shared");function me(a,h){let d=h.namespace.name;if(!/^[a-z][a-z0-9_]*$/u.test(d))throw new Error("Resource host namespace must be a lowercase identifier.");let w=new Set(h.tools??ce);if([...w].some(e=>!ce.includes(e)))throw new Error("Unsupported resource host tool.");let p={namespace:d,claimed:!1};if(a.events.emit(pe,p),p.claimed)throw new Error(`Resource host namespace already registered: ${d}`);let A=a.events.on(pe,e=>{m(e)&&e.namespace===d&&(e.claimed=!0)}),R=new Map,u=new Set,g=[A],S=new Map,I=new Map,C=new Set,E=!1,D,_,y=n(e=>`${d}_${e}`,"publicName"),b=n(e=>typeof e=="string"&&e.startsWith(d+"_")&&w.has(e.slice(d.length+1))?e.slice(d.length+1):void 0,"localName"),H=n(e=>e.replace(/\b(?:read|search|select|write|replace|insert|delete|copy|move|diff)\b/gu,(o,t)=>{let s=e.slice(0,t),r=e.slice(t+o.length);return s.endsWith("tools.")||s.endsWith("`")&&/^[`.]/u.test(r)||/(?:\bUse|\band) $/u.test(s)&&r.startsWith(" to ")?y(o):o}),"words");function U(e,o){let t=e.startsWith("raw:")&&!o?e.slice(4):e;return!o&&(t.startsWith("docs:")||t.startsWith("temp:"))?!0:/^[a-z][a-z\d+.-]*:\/\//iu.test(t)&&!/^(?:file:|[a-z]:[/\\])/iu.test(t)&&h.ownsSource(t)}n(U,"owns");let j=n(()=>k(_),"targets");async function x(e,o,t){let s=j().source(e,o.cwd,!t);if(Array.isArray(s)){for(let r of s)await x(r,o,t);return}if(m(s)&&"path"in s){await x(s.path,o,t);return}if(typeof s!="string")throw new Error("Use an owned resource URI or an issued source result.");if(s.startsWith("RESULT#")){let r=j().resolve(s,o.cwd);if(r.targets.some(f=>!U(f.source,t)))throw new Error("Source selection belongs outside this resource host.");await j().verify(r,o.signal);return}if(s.startsWith("SEARCH#")){let r=await D?.read({path:s},{cwd:o.cwd,signal:o.signal},"script");if(r?.isError||r?.script?.kind!=="text"||!r.script.target)throw new Error("Unknown or expired resource search selection.");await x(r.script.target,o,t);return}if(!U(s,t))throw new Error("Use this host only for its provider-owned resource URIs; local paths are not supported.")}n(x,"checkSource");async function M(e,o,t){if(E)throw new Error("Standalone resource host is closed.");if(!m(o))throw new Error("Resource tool arguments must be an object.");let s=!ue.has(e),r=de[e]??[];if(["read","search"].includes(e)&&o.path===void 0)throw new Error("Supply an explicit owned resource or source result.");if(s&&o.path===void 0){let f=oe(_)?.source;if(!f)throw new Error("Supply an owned source before editing.");await x(f,t,!0)}for(let f of r)o[f]!==void 0&&await x(o[f],t,s);for(let f of["start","end","anchor","targetStart","targetEnd"]){let c=o[f];typeof c=="string"&&/^(?:RESULT#|SEARCH#|<system-result)/u.test(c)&&await x(c,t,s)}if(e==="write"&&typeof o.content!="string")throw new Error("Standalone resource Write accepts text/JSON content, not filesystem image writes.")}n(M,"validate");let P=n((e,o)=>a.on(e,async(t,s)=>await o({...t},s)),"subscribe");g.push(P("tool_call",async(e,o)=>{let t=b(e.toolName);if(t)try{await M(t,e.input,o)}catch(s){return{block:!0,reason:s instanceof Error?s.message:String(s)}}}));let ge=n((e,o)=>{let t=o;if(e==="session_shutdown")return u.add(t),()=>{u.delete(t)};let s=P(e,async(r,f)=>{if(E)return;let c=r;if(e.startsWith("tool_")){let i=b(r.toolName);if(i)typeof r.parentToolCallId=="string"&&C.add(r.parentToolCallId),c={...r,toolName:i};else if(typeof r.toolCallId=="string"&&C.has(r.toolCallId))c={...r,toolName:r.toolName==="codemode"?"codemode":"__standalone_parent"};else return}if(e==="message_end"){if(!m(r.message)||r.message.role!=="toolResult")return;let i=b(r.message.toolName);if(!i)return;c={...r,message:{...r.message,toolName:i}}}e==="context"&&Array.isArray(r.messages)&&(c={...r,messages:r.messages.map(i=>m(i)&&typeof i.toolName=="string"?{...i,toolName:b(i.toolName)??"__outside_resource_host"}:i)});let l=await t(c,f);if(!m(l))return l;if(e==="message_end"&&m(l.message)&&m(r.message))return{...l,message:{...l.message,toolName:r.message.toolName}};if(e==="context"&&Array.isArray(l.messages)&&Array.isArray(r.messages)){let i=r.messages;if(l.messages.length!==i.length)throw new Error("Resource host context handlers must preserve message positions.");return{...l,messages:l.messages.map((N,O)=>{let T=i[O];return m(N)&&m(T)&&typeof T.toolName=="string"?{...N,toolName:T.toolName}:N})}}return l});return g.push(s),s},"on"),he={emit(e,o){if(E)throw new Error("Standalone resource host is closed.");if(fe(e))a.events.emit(e,o);else for(let t of R.get(e)??[])t(o)},on(e,o){if(fe(e)){let s=a.events.on(e,o);return g.push(s),s}let t=R.get(e);return t||R.set(e,t=new Set),t.add(o),()=>{t.delete(o)}}};function W(e){return Array.isArray(e)?e.map(W):m(e)?Object.fromEntries(Object.entries(e).map(([o,t])=>[o,o==="description"&&typeof t=="string"?H(t):W(t)])):e}n(W,"descriptions");function we(e){return{...e,tools:e.tools.flatMap(o=>{let t=b(o.name);return t?[{...o,name:t}]:[]}),executeTool(o,t,s){if(!w.has(o))throw new Error("Tool is not owned by this resource host.");return e.executeTool(y(o),t,s)}}}n(we,"toolContext"),_={...a,events:he,on:ge,registerTool:n(e=>{let o=e.name;if(!w.has(o))return;let t=Object.getOwnPropertyDescriptors(e);t.name={value:y(o),enumerable:!0,configurable:!0},t.label={value:y(o),enumerable:!0,configurable:!0},t.namespace={value:h.namespace,enumerable:!0,configurable:!0},t.exposure={value:"deferred",enumerable:!0,configurable:!0},t.description={get:n(()=>`Use ${y(o)} to ${o==="read"?"inspect provider-owned resources and packaged guides":o==="search"?"find objects or text within an explicit provider-owned resource":`${o} provider-owned text resources`}.`,"get"),enumerable:!0,configurable:!0},t.promptSnippet={get:n(()=>H(e.promptSnippet??""),"get"),enumerable:!0,configurable:!0},t.promptGuidelines={get:n(()=>[...(e.promptGuidelines??[]).map(H),"Use only this namespace's owned resource URIs and issued results. Local filesystem paths are not supported."],"get"),enumerable:!0,configurable:!0},t.parameters={get:n(()=>{let c=W(e.parameters),l=m(c.properties)?{...c.properties}:{};for(let i of de[o]??[])m(l[i])&&(l[i]={...l[i],description:"Provider-owned resource URI, unchanged source result, or an issued reference."});return o==="write"&&(l.content=Re.String({description:"Complete text/Markdown or JSON payload for the selected provider resource."})),Object.assign({},e.parameters,c,{properties:l})},"get"),enumerable:!0,configurable:!0};let s=n(async(c,l,i,N,O)=>{if(E)throw new Error("Standalone resource host is closed.");let T=new AbortController,L=n(()=>{},"finish"),ye=new Promise(v=>{L=v});S.set(T,ye);let be=[i,O.signal,T.signal].filter(v=>v!==void 0),$=AbortSignal.any(be);try{let v={...we(O),signal:$};return await M(o,l,v),$.throwIfAborted(),await e.execute(c,l,$,N,v)}finally{S.delete(T),L()}},"execute");t.execute={value:s,enumerable:!0,configurable:!0};let r=n((c,l,i)=>!ue.has(o)&&e.renderCall?e.renderCall(c,l,i):Q(i.lastComponent,{tool:y(o),primary:{text:m(c)?String(c.path??c.query??"owned resource"):"owned resource",truncate:"end"},expanded:i.expanded},l),"renderCall");t.renderCall={value:r,enumerable:!0,configurable:!0};let f=Object.defineProperties({},t);I.set(o,()=>a.registerTool({...f,exposure:"hidden"})),a.registerTool(f)},"registerTool"),getActiveTools:n(()=>a.getActiveTools().flatMap(e=>{let o=b(e);return o?[o]:[]}),"getActiveTools"),getAllTools:n(()=>a.getAllTools().flatMap(e=>{let o=b(e.name);return o?[{...e,name:o}]:[]}),"getAllTools"),setActiveTools(e){let o=a.getActiveTools().filter(t=>!b(t));a.setActiveTools([...o,...e.filter(t=>w.has(t)).map(y)])}},g.push(P("session_start",()=>{C.clear(),!(a.getSettings().defaultTools??[]).includes("-tool_search")&&a.getAllTools().some(e=>e.name==="tool_search"&&e.exposure!=="hidden")&&!a.getActiveTools().includes("tool_search")&&a.setActiveTools([...a.getActiveTools(),"tool_search"])})),g.push(P("agent_end",()=>{C.clear()}));async function z(e,o=!0){if(E)return;E=!0;for(let r of S.keys())r.abort();await Promise.all(S.values());let t=await Promise.allSettled([...u].map(r=>r({type:"session_shutdown"},e)));for(let r of g)r();if(R.clear(),u.clear(),C.clear(),o)for(let r of I.values())r();I.clear();let s=t.find(r=>r.status==="rejected");if(s?.status==="rejected")throw s.reason}return n(z,"dispose"),g.push(P("session_shutdown",(e,o)=>z(o,!1))),{api:_,owns:U,tools:[...w].map(y),dispose:z,setApi(e){_=e},setRead(e){D=e}}}n(me,"createResourceHostApi");async function Se(a,h){G(a);let d=me(a,h),w=F(d.api,{resourceOutput:!0,promptSection:`resource_${h.namespace.name}_results`}),p=w.api;d.setApi(p);try{await Z(p);let A;await X(p,{protocol:V,apiVersion:J,id:"standalone-resource-boundary",setup(u){A=u,d.setRead(u),u.addResourceGuard({id:"standalone-resource-boundary",guard:n(g=>d.owns(g.resourceSource,!1)?{kind:"accepted"}:{kind:"rejected",reason:"Resource belongs outside this standalone host."},"guard")}),u.addHandler({stage:"post-read",handler:K(k(p),u.read,g=>d.owns(g,!0))})}}),await q(p);let R=await te(p);if(await R.registerPlugin({protocol:B,apiVersion:Y,id:"standalone-resource-boundary",setup(u){u.addMutationGuard({id:"standalone-resource-boundary",guard:n(g=>g.resources.every(S=>d.owns(S.source,!0)&&S.binary===void 0)?{kind:"accepted"}:{kind:"rejected",rejection:{code:"RESOURCE_HOST_BOUNDARY",reason:"Resource belongs outside this standalone host.",message:"Use this host only for its provider-owned text resources.",effect:"not-applied"}},"guard")})}}),await se(p),await ne(p),await ae(p),await ee(p),!A)throw new Error("Standalone Read host did not initialize.");return await le(p,{recordType:`agent-documentation-read/${h.namespace.name}`,ownsTool:n(u=>typeof u=="string"&&d.tools.includes(u),"ownsTool")}),await ie(p,{preferences:{},toolName:n(u=>`${h.namespace.name}_${u}`,"toolName")}),re(p,R),w.finalize(),{api:p,tools:d.tools,dispose:n(u=>d.dispose(u),"dispose")}}catch(A){throw await d.dispose(),A}}n(Se,"createStandaloneResourceHost");export{Se as createStandaloneResourceHost};
|
package/dist/entry-1.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d
|
|
1
|
+
import{a,b,c,d}from"./chunk-TSQ6FBTB.js";import"./chunk-EI7MMDWY.js";export{c as IDE_CAPABILITIES_READY,b as IDE_CAPABILITIES_REGISTER,a as IDE_CAPABILITIES_VERSION,d as registerIdeCapability};
|
package/dist/entry-10.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-57F5GTHO.js";import"./chunk-EI7MMDWY.js";export{a as connectTipProvider};
|
|
1
|
+
import{a,b,c,d,e,f,g}from"./chunk-57F5GTHO.js";import"./chunk-EI7MMDWY.js";export{c as TIP_API_VERSION,d as TIP_CORE_READY_EVENT,b as TIP_PROTOCOL,e as TIP_PROVIDER_REGISTER_EVENT,a as connectTipProvider,f as isTipCoreReady,g as isTipProviderRegistrationRequest};
|
package/dist/entry-11.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a}from"./chunk-57F5GTHO.js";import"./chunk-EI7MMDWY.js";export{a as connectTipProvider};
|
package/dist/entry-12.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import{a as h,b as i,c as j,d as k}from"./chunk-B25LXXNV.js";import"./chunk-7D7PXIVV.js";import"./chunk-BXGMMZT3.js";import{a,b,c,d,e,f,g}from"./chunk-MLFJU2US.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{c as DOCTOR_API_VERSION,d as DOCTOR_CORE_READY_EVENT,e as DOCTOR_PLUGIN_REGISTER_EVENT,b as DOCTOR_PROTOCOL,a as DOCTOR_TOOL_PATH_KEYS,j as doctorExecutableAvailable,i as doctorProcessAccess,h as doctorRuntimeOptions,f as isDoctorCoreReady,g as isDoctorPluginRegistrationRequest,k as withDoctorProbeCopy};
|
package/dist/entry-13.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"./chunk-MPT3R4BL.js";import{a,b,c,d,e,f,g}from"./chunk-KN6VPARZ.js";import"./chunk-EI7MMDWY.js";export{b as DOCUMENTATION_API_VERSION,a as DOCUMENTATION_PROTOCOL,c as DOCUMENTATION_READY_EVENT,d as DOCUMENTATION_REGISTER_EVENT,g as connectAgentDocumentation,e as createPackagedAgentGuideLoader,f as loadPackagedAgentGuide};
|
package/dist/entry-14.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{a as o}from"./chunk-MDD5ORB6.js";import"./chunk-MLFJU2US.js";import"./chunk-EI7MMDWY.js";export{o as connectDoctorPlugin};
|
package/dist/entry-15.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import"./chunk-3PMHFEJY.js";import"./chunk-XCPIIDFS.js";import"./chunk-NNCZYO4Q.js";import"./chunk-IQD6PON5.js";import"./chunk-52PFWQMU.js";import"./chunk-OMNKD7WW.js";import"./chunk-PS2B6THP.js";import"./chunk-YPYROPQF.js";import{a as l}from"./chunk-GXL4NMHR.js";import{c as a,d as s}from"./chunk-PQWANILR.js";import{a as p}from"./chunk-BU7IZLKB.js";import{a as u,b as y}from"./chunk-S5PL5DFQ.js";import"./chunk-DDH3FP4G.js";import"./chunk-756K3LJY.js";import"./chunk-VDJSH3DQ.js";import"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";function x(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/before-delete/${e.id}`,setup(t){t.addDeleteGuard({id:e.id,guard:d(n=>e.run(n),"guard")})}})}d(x,"connectBeforeDeleteHook");function m(o,e){return c(e),p(o,{protocol:u,apiVersion:y,id:`hook/before-read/${e.id}`,setup(t){t.addResourceGuard({id:e.id,async guard(n){let r=await e.run(n);return r.decision==="allow"?{kind:"accepted"}:{kind:"rejected",reason:r.reason}}})}})}d(m,"connectBeforeReadHook");function A(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/before-edit/${e.id}`,setup(t){t.addMutationGuard({id:e.id,async guard(n,r){let f=await e.run({cwd:r.cwd,intent:r.intent??"edit",resources:n.resources.map(i=>({resourceSource:i.source,existed:i.existed,before:i.before,after:i.after,changes:i.changes,...i.binary===void 0?{}:{binary:i.binary}})),...r.signal!==void 0&&{signal:r.signal}});return f.decision==="allow"?{kind:"accepted"}:{kind:"rejected",rejection:{code:"MUTATION_REJECTED",reason:f.reason,message:`Edit blocked by hook ${e.id}: ${f.reason}`,effect:"not-applied"}}}})}})}d(A,"connectBeforeEditHook");function v(o,e){return c(e),l(o,{protocol:a,apiVersion:s,id:`hook/after-edit/${e.id}`,setup(t){t.onDidEdit(async n=>{if(n.postProcessing!=="deferred")try{return await e.run(n)}catch(r){return{feedback:`After-edit hook ${e.id} failed after the edit was saved: ${r instanceof Error?r.message:String(r)}`,tone:"error"}}})}})}d(v,"connectAfterEditHook");function c(o){if(o.id.trim().length===0||typeof o.run!="function")throw new TypeError("A file hook needs a non-empty id and run function")}d(c,"assertHook");export{v as connectAfterEditHook,x as connectBeforeDeleteHook,A as connectBeforeEditHook,m as connectBeforeReadHook};
|
package/dist/entry-16.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{a}from"./chunk-K5G4FDXD.js";import"./chunk-EI7MMDWY.js";export{a as sameFilePath};
|
package/dist/entry-17.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import"./chunk-3PMHFEJY.js";import{a as u}from"./chunk-XCPIIDFS.js";import"./chunk-NNCZYO4Q.js";import{a as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p,o as q,p as r}from"./chunk-52PFWQMU.js";import{b as s,d as t}from"./chunk-OMNKD7WW.js";import"./chunk-PS2B6THP.js";import{a as h}from"./chunk-BU7IZLKB.js";import{a,b,c,d,e,f,g}from"./chunk-S5PL5DFQ.js";import"./chunk-DDH3FP4G.js";import"./chunk-756K3LJY.js";import"./chunk-VDJSH3DQ.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{s as COMPACT_READ_ROWS,b as READ_API_VERSION,c as READ_CORE_READY_EVENT,d as READ_PLUGIN_REGISTER_EVENT,a as READ_PROTOCOL,h as connectReadPlugin,u as createJqReadHandler,t as createReadResultRenderer,q as isFragmentResolverRegistration,e as isReadCoreReady,r as isReadFragmentResolution,o as isReadHandlerRegistration,f as isReadPlugin,g as isReadPluginRegistrationRequest,p as isReadViewRegistration,n as isResourceResolverRegistration,m as isTextTargetResolverRegistration,j as readDataSchema,k as readOutputSchema,i as readParameters,l as structuredRead};
|
package/dist/entry-18.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as r}from"./chunk-XE4W5YTE.js";import{a as e}from"./chunk-RIOPUTUJ.js";import"./chunk-EI7MMDWY.js";export{r as createImageContentConverter,e as createPdfContentConverter};
|
package/dist/entry-19.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u,w as v,x as w,y,z}from"./chunk-DDH3FP4G.js";import"./chunk-EI7MMDWY.js";export{D as CONTENT_API_VERSION,F as CONTENT_CONVERTER_REGISTER_EVENT,E as CONTENT_HOST_READY_EVENT,C as CONTENT_PROTOCOL,c as MAX_STRUCTURED_BYTES,x as ResourceError,o as ResourceScheduler,O as ResultImageStore,L as ResultTargetStore,f as TempResourceStore,z as UnsupportedContentError,d as assertJsonData,J as connectContentConverter,P as connectResultImages,N as connectResultTargets,I as createContentHost,A as createContentRunner,j as isAgentContent,w as isContentConversionAttempt,u as isContentConversionContext,v as isContentConverter,y as isContentConverterRegistration,H as isContentConverterRegistrationRequest,G as isContentHostReady,s as isContentInput,q as isContentTarget,k as isResource,n as isResourceResolutionAttempt,l as isResourceResolver,i as renderContentDescription,e as resourceAccesses,p as resourceErrorMetadata,t as resourceErrorMetadataOf,m as resourceErrorMetadataSchema,r as resourceScheduler,g as resultError,a as resultErrorSchema,K as resultInputSchema,b as structuredResultSchema,B as targetsEqual,M as verifyResultTargets,h as withStructuredResult};
|
package/dist/entry-2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c
|
|
1
|
+
import{a,b,c,d,e,f}from"./chunk-OJEIX7OZ.js";import"./chunk-EI7MMDWY.js";export{c as SETTINGS_READY_EVENT,b as SETTINGS_READ_EVENT,a as SETTINGS_REGISTER_EVENT,e as readAgentIdeSetting,d as registerAgentIdeSettings,f as validateAgentIdeSettings};
|
package/dist/entry-20.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as g,b as h,c as i,d as j,e as k,f as l,g as n,h as q,i as s,j as u}from"./chunk-FYOU4RBH.js";import{b as x,c as a,d as b,e as c}from"./chunk-7PVDTMEM.js";import{a as d}from"./chunk-47SPPIXK.js";import{a as o,b as r,c as e,d as f,e as m,f as p,g as t}from"./chunk-VAXLSPPU.js";import"./chunk-PS2B6THP.js";import"./chunk-DDH3FP4G.js";import"./chunk-EI7MMDWY.js";export{n as FuzzyVocabulary,r as SEARCH_API_VERSION,e as SEARCH_CORE_READY_EVENT,f as SEARCH_PLUGIN_REGISTER_EVENT,o as SEARCH_PROTOCOL,d as connectSearchPlugin,h as containsSearchMatch,u as formatFuzzyCandidate,s as fuzzyCandidateData,j as fuzzyLimits,l as isFuzzyQuery,k as isFuzzyResultData,m as isSearchCoreReady,p as isSearchPlugin,t as isSearchPluginRegistrationRequest,q as rankFuzzyIdentifiers,g as renderSearchMatches,x as searchDataSchema,a as searchOutputSchema,c as searchSchema,b as selectionData,i as splitGlobList};
|
package/dist/entry-21.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s}from"./chunk-VDJSH3DQ.js";import"./chunk-EI7MMDWY.js";export{o as TextAnchor,r as attachTextAnchorRenderer,j as createTextContentConverter,g as createTextDocument,e as getTextAnchorRenderer,a as getTextSourceLine,t as isTextAnchorRecoveryOutcome,p as isTextAnchorResolutionAttempt,m as isTextAnchorResolver,c as isTextLinePresenter,d as isTextPresenterRegistration,n as isTextTargetResolutionAttempt,k as isTextualMediaType,i as renderPresentedTextDocument,x as renderPresentedTextRows,f as renderTextAnchor,h as renderTextDocument,s as restoreText,q as storeText,l as textFromAgentContent,b as withTextSourceLine};
|
package/dist/entry-22.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-IQD6PON5.js";import{m as q}from"./chunk-YPYROPQF.js";import{a as p}from"./chunk-GXL4NMHR.js";import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-PQWANILR.js";import"./chunk-DDH3FP4G.js";import"./chunk-VDJSH3DQ.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{d as TEXT_EDITOR_API_VERSION,g as TEXT_EDITOR_CORE_READY_EVENT,h as TEXT_EDITOR_PLUGIN_REGISTER_EVENT,c as TEXT_EDITOR_PROTOCOL,e as TEXT_POSITION_ANCHOR_KIND,f as TEXT_SEARCH_ANCHOR_KIND,p as connectTextEditorPlugin,q as connectTextEditorPostEditHandler,j as isResourceResolverRegistration,k as isTextAnchorResolverRegistration,l as isTextAnchorResourceResolutionAttempt,m as isTextEditorCoreReady,n as isTextEditorPlugin,o as isTextEditorPluginRegistrationRequest,i as isTextEditorToolId,b as localFileTransferAccess,a as snapshotLocalObjects};
|
package/dist/entry-24.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"./chunk-K4ZMRDEI.js";
|
package/dist/entry-25.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a}from"./chunk-MDD5ORB6.js";import"./chunk-MLFJU2US.js";import"./chunk-EI7MMDWY.js";export{a as connectDoctorPlugin};
|
package/dist/entry-26.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b
|
|
1
|
+
import{a,b}from"./chunk-BXGMMZT3.js";import"./chunk-EI7MMDWY.js";export{b as hasProjectMarker,a as inspectRecipeEvidence};
|
package/dist/entry-27.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-756K3LJY.js";import"./chunk-EI7MMDWY.js";export{d as isExecutableAvailable,b as normalizeProcessEnvironment,e as probeExecutable,a as projectExecutableDirectories,c as projectProcessEnvironment};
|
package/dist/entry-28.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c
|
|
1
|
+
import{a,b,c}from"./chunk-R2U5WXYR.js";import"./chunk-756K3LJY.js";import"./chunk-EI7MMDWY.js";export{b as probeProjectExecutable,c as projectExecutableAvailable,a as projectFileExists};
|
package/dist/entry-29.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g}from"./chunk-MLFJU2US.js";import"./chunk-EI7MMDWY.js";export{c as DOCTOR_API_VERSION,d as DOCTOR_CORE_READY_EVENT,e as DOCTOR_PLUGIN_REGISTER_EVENT,b as DOCTOR_PROTOCOL,a as DOCTOR_TOOL_PATH_KEYS,f as isDoctorCoreReady,g as isDoctorPluginRegistrationRequest};
|
package/dist/entry-3.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as p,d as e}from"./chunk-RQ7JJ7GV.js";import"./chunk-EI7MMDWY.js";export{e as confirmOperation,p as registerOperationApproval};
|
package/dist/entry-30.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
`)}]}s(q,"readDirectoryContent");async function J(e,t,r,o){g(r);let n=await $(e,{encoding:null,...r!==void 0&&{signal:r}});return g(r),o(n),t.convert({source:e,bytes:n},r===void 0?{}:{signal:r})}s(J,"readFilesystemContent");function K(e){return/^[A-Za-z]:[\\/]/u.test(e)||e.startsWith("file://")?!0:!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(e)}s(K,"isFilesystemSource");function g(e){if(e?.aborted===!0)throw H()}s(g,"throwIfAborted");function H(){let e=new Error("The operation was aborted");return e.name="AbortError",e}s(H,"abortError");import{execFile as Q}from"node:child_process";import{existsSync as Y}from"node:fs";import{realpath as L}from"node:fs/promises";import ee from"node:os";import u from"node:path";import{fileURLToPath as te}from"node:url";async function N(e,t){let r=e.cause,o=Date.now()+500;if(t.signal?.aborted||e.source===void 0||typeof r!="object"||r===null||!("code"in r)||r.code!=="ENOENT")return;let n=e.source.startsWith("file://")?te(e.source):e.source,i=u.relative(t.cwd,u.resolve(t.cwd,n));if(!w(i)||i.includes("#"))return;let m=u.basename(i).toLowerCase();if(m.length<3||m.length>160)return;let c=u.join(process.env.PI_CODING_AGENT_DIR??u.join(ee.homedir(),".pi","agent"),"bin",process.platform==="win32"?"rg.exe":"rg"),b=await new Promise(a=>{Q(Y(c)?c:"rg",["--files","--hidden","--no-config","--no-ignore-parent","--null","--glob","!.git/**"],{cwd:t.cwd,timeout:250,maxBuffer:2*1024*1024,...t.signal===void 0?{}:{signal:t.signal}},(d,R)=>a(d?[]:R.split("\0").filter(Boolean).slice(0,2e4)))}),p=Math.min(3,Math.max(1,Math.floor(m.length*.2))),f=b.flatMap(a=>{if(t.signal?.aborted||Date.now()>o||!w(a))return[];let d=u.basename(a).toLowerCase();if(d.length>160||Math.abs(d.length-m.length)>p)return[];let R=re(m,d);if(R>p)return[];let M=u.dirname(i).toLowerCase(),U=u.dirname(a).toLowerCase();return[{path:a,distance:R,directoryDistance:M===U?0:1}]}).sort((a,d)=>a.distance-d.distance||a.directoryDistance-d.directoryDistance||a.path.localeCompare(d.path)),l=[],h=await L(t.cwd);for(let a of f.slice(0,20)){if(t.signal?.aborted||Date.now()>o)return;try{let d=await L(u.resolve(t.cwd,a.path));w(u.relative(h,d))&&l.push({path:a.path})}catch{}if(l.length===3)break}return l.length?l:void 0}s(N,"recoverFilesystemPath");function w(e){return e!==""&&!/^\.\.(?:[\\/]|$)/u.test(e)&&!u.isAbsolute(e)}s(w,"insideWorkspace");function re(e,t){let r=Array.from({length:t.length+1},(o,n)=>n);for(let o=1;o<=e.length;o++){let n=[o];for(let i=1;i<=t.length;i++)n[i]=Math.min(y(n[i-1])+1,y(r[i])+1,y(r[i-1])+(e[o-1]===t[i-1]?0:1));r=n}return y(r[t.length])}s(re,"editDistance");var ne={provider:"filesystem",capability:"read"},oe={provider:"filesystem",capability:"write"},ie=k({kind:"source",nativeResources:!0});async function se(e){let t=v(e,ne),r=v(e,oe),o=S(t),n=_(r),i={protocol:C,apiVersion:P,id:"filesystem",setup(c){c.addResolver({resolver:o,renderResult:ie,recoverFailure:N}),c.describe({path:s(()=>F("File \u2014 content; directory \u2014 listing.",t.listDescriptions()),"path")})}},m={protocol:E,apiVersion:D,id:"filesystem",setup(c){c.addResolver({resolver:n})}};await Promise.all([T(e,i),I(e,m)])}s(se,"registerFilesystemPlugin");export{se as default};
|
|
1
|
+
import{a,b,c,d,e,f,g}from"./chunk-KN6VPARZ.js";import"./chunk-EI7MMDWY.js";export{b as DOCUMENTATION_API_VERSION,a as DOCUMENTATION_PROTOCOL,c as DOCUMENTATION_READY_EVENT,d as DOCUMENTATION_REGISTER_EVENT,g as connectAgentDocumentation,e as createPackagedAgentGuideLoader,f as loadPackagedAgentGuide};
|
package/dist/entry-31.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import"./chunk-NNCZYO4Q.js";import{d as k}from"./chunk-OMNKD7WW.js";import"./chunk-PS2B6THP.js";import{a as I}from"./chunk-GXL4NMHR.js";import{c as E,d as D}from"./chunk-PQWANILR.js";import{a as T}from"./chunk-BU7IZLKB.js";import{a as C,b as P}from"./chunk-S5PL5DFQ.js";import{I as v,o as F}from"./chunk-DDH3FP4G.js";import{r as A}from"./chunk-VDJSH3DQ.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{readdirSync as W,realpathSync as B,statSync as V}from"node:fs";import{mkdir as j,readFile as $,writeFile as z}from"node:fs/promises";import O from"node:path";import{fileURLToPath as Z,pathToFileURL as G}from"node:url";function S(e){return x("read",e)}s(S,"createFilesystemReadResolver");function _(e){return x("write",e)}s(_,"createFilesystemWriteResolver");function x(e,t){return{id:"filesystem",tryResolve(r,o){return Promise.resolve(X(r,o,e,t))}}}s(x,"createFilesystemResolver");function X(e,t,r,o){if(e.length===0)return{kind:"failed",error:new TypeError("Filesystem source must not be empty")};if(!K(e))return{kind:"not-handled"};if(t.signal?.aborted===!0)return{kind:"failed",error:H()};let n=e.startsWith("file://")?B(Z(new URL(e))):O.resolve(t.cwd,e),i=G(n).href,m=(()=>{try{return V(n).isDirectory()}catch{return!1}})(),c,p={source:n,link:i,read:s(async({signal:f})=>(c=void 0,m?q(n,f):J(n,o,f,l=>{c=l})),"read"),get sourceBytes(){return c}};return r==="read"||m?{kind:"resolved",resource:p}:{kind:"resolved",resource:{...p,get sourceBytes(){return c},async write(f,l){g(l.signal);let h=A(f);await j(O.dirname(n),{recursive:!0}),g(l.signal),await z(n,h,{encoding:"utf8",...l.signal!==void 0&&{signal:l.signal}})}}}}s(X,"resolveFilesystemSource");function q(e,t){g(t);let r=W(e,{withFileTypes:!0}),o=[`\u{1F4C1} ${e}/`];r.length>0&&o.push("");for(let n of r){let i=n.isDirectory()?"\u{1F4C1}":n.isFile()?"\u{1F4C4}":"\u{1F517}";o.push(` ${i} ${n.name}`)}return[{type:"text",text:o.join(`
|
|
2
|
+
`)}]}s(q,"readDirectoryContent");async function J(e,t,r,o){g(r);let n=await $(e,{encoding:null,...r!==void 0&&{signal:r}});return g(r),o(n),t.convert({source:e,bytes:n},r===void 0?{}:{signal:r})}s(J,"readFilesystemContent");function K(e){return/^[A-Za-z]:[\\/]/u.test(e)||e.startsWith("file://")?!0:!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(e)}s(K,"isFilesystemSource");function g(e){if(e?.aborted===!0)throw H()}s(g,"throwIfAborted");function H(){let e=new Error("The operation was aborted");return e.name="AbortError",e}s(H,"abortError");import{execFile as Q}from"node:child_process";import{existsSync as Y}from"node:fs";import{realpath as L}from"node:fs/promises";import ee from"node:os";import u from"node:path";import{fileURLToPath as te}from"node:url";async function N(e,t){let r=e.cause,o=Date.now()+500;if(t.signal?.aborted||e.source===void 0||typeof r!="object"||r===null||!("code"in r)||r.code!=="ENOENT")return;let n=e.source.startsWith("file://")?te(e.source):e.source,i=u.relative(t.cwd,u.resolve(t.cwd,n));if(!w(i)||i.includes("#"))return;let m=u.basename(i).toLowerCase();if(m.length<3||m.length>160)return;let c=u.join(process.env.PI_CODING_AGENT_DIR??u.join(ee.homedir(),".pi","agent"),"bin",process.platform==="win32"?"rg.exe":"rg"),b=await new Promise(a=>{Q(Y(c)?c:"rg",["--files","--hidden","--no-config","--no-ignore-parent","--null","--glob","!.git/**"],{cwd:t.cwd,timeout:250,maxBuffer:2*1024*1024,...t.signal===void 0?{}:{signal:t.signal}},(d,R)=>a(d?[]:R.split("\0").filter(Boolean).slice(0,2e4)))}),p=Math.min(3,Math.max(1,Math.floor(m.length*.2))),f=b.flatMap(a=>{if(t.signal?.aborted||Date.now()>o||!w(a))return[];let d=u.basename(a).toLowerCase();if(d.length>160||Math.abs(d.length-m.length)>p)return[];let R=re(m,d);if(R>p)return[];let M=u.dirname(i).toLowerCase(),U=u.dirname(a).toLowerCase();return[{path:a,distance:R,directoryDistance:M===U?0:1}]}).sort((a,d)=>a.distance-d.distance||a.directoryDistance-d.directoryDistance||a.path.localeCompare(d.path)),l=[],h=await L(t.cwd);for(let a of f.slice(0,20)){if(t.signal?.aborted||Date.now()>o)return;try{let d=await L(u.resolve(t.cwd,a.path));w(u.relative(h,d))&&l.push({path:a.path})}catch{}if(l.length===3)break}return l.length?l:void 0}s(N,"recoverFilesystemPath");function w(e){return e!==""&&!/^\.\.(?:[\\/]|$)/u.test(e)&&!u.isAbsolute(e)}s(w,"insideWorkspace");function re(e,t){let r=Array.from({length:t.length+1},(o,n)=>n);for(let o=1;o<=e.length;o++){let n=[o];for(let i=1;i<=t.length;i++)n[i]=Math.min(y(n[i-1])+1,y(r[i])+1,y(r[i-1])+(e[o-1]===t[i-1]?0:1));r=n}return y(r[t.length])}s(re,"editDistance");var ne={provider:"filesystem",capability:"read"},oe={provider:"filesystem",capability:"write"},ie=k({kind:"source",nativeResources:!0});async function se(e){let t=v(e,ne),r=v(e,oe),o=S(t),n=_(r),i={protocol:C,apiVersion:P,id:"filesystem",setup(c){c.addResolver({resolver:o,renderResult:ie,recoverFailure:N}),c.describe({path:s(()=>F("File \u2014 content; directory \u2014 listing.",t.listDescriptions()),"path")})}},m={protocol:E,apiVersion:D,id:"filesystem",setup(c){c.addResolver({resolver:n})}};await Promise.all([T(e,i),I(e,m)])}s(se,"registerFilesystemPlugin");export{se as default};
|
package/dist/entry-32.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a as r}from"./chunk-XE4W5YTE.js";import{J as e}from"./chunk-DDH3FP4G.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:100};async function i(o){await e(o,n)}t(i,"registerFilesystemImage");export{i as default};
|
package/dist/entry-33.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a}from"./chunk-XCPIIDFS.js";import"./chunk-756K3LJY.js";import"./chunk-VDJSH3DQ.js";import"./chunk-EI7MMDWY.js";export{a as createJqReadHandler};
|
package/dist/entry-34.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r}from"./chunk-
|
|
1
|
+
import{a as f}from"./chunk-XCPIIDFS.js";import{a as p}from"./chunk-MDD5ORB6.js";import{b as l,c as d}from"./chunk-MLFJU2US.js";import{a as n}from"./chunk-BU7IZLKB.js";import{a as r,b as o}from"./chunk-S5PL5DFQ.js";import{d as c,e as u}from"./chunk-756K3LJY.js";import"./chunk-VDJSH3DQ.js";import{a as t}from"./chunk-EI7MMDWY.js";async function m(i){await Promise.all([n(i,w),p(i,g)])}t(m,"registerFilesystemJq");var w={protocol:r,apiVersion:o,id:"filesystem-jq",setup(i){i.addView({view:"jq",presenter:{id:"filesystem-jq",present:t(s=>s,"present")}});let e=f({pluginId:"filesystem-jq",input:t(s=>s.state?.contentKind==="text"?s.state.content[0].text:void 0,"input")});i.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler(s){let a=s.state;return a?.contentKind!=="text"||a.resolvedBy!=="filesystem"&&a.resolvedBy!=="ssh"?{kind:"continue",context:s}:e(s)}}),i.describe({views:"jq:<filter> \u2014 run jq on a JSON file or a resource whose provider supplies JSON (JSONL record by record); use alone; offset and limit apply to its output."})}},g={protocol:l,apiVersion:d,id:"filesystem-jq",setup(i){i.addSetupCheck({id:"jq",async inspect(e){return await c("jq",e.workspace?process.cwd():e.cwd,e.workspace?process.env:e.env,e.signal)?{}:{actions:[{id:"jq-unavailable",message:"JSON jq views are unavailable because jq was not found"}]}}}),i.addCheck({id:"jq",title:"JSON jq views",async run(e){e.signal?.throwIfAborted();let s=await u("jq",["--version"],e.workspace?process.cwd():e.cwd,e.workspace?process.env:e.env,e.signal);return e.signal?.throwIfAborted(),[s.ok?{status:"pass",message:"jq is available",detail:e.workspace?`Controller content adapter: ${s.detail}`:s.detail}:{status:"fail",message:"jq is not available",detail:s.detail}]}})}};export{m as default};
|
package/dist/entry-35.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as r}from"./chunk-RIOPUTUJ.js";import{J as e}from"./chunk-DDH3FP4G.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:200};async function i(o){await e(o,n)}t(i,"registerFilesystemPdf");export{i as default};
|
package/dist/entry-36.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{J as t}from"./chunk-DDH3FP4G.js";import{p as i}from"./chunk-VDJSH3DQ.js";import{a as r}from"./chunk-EI7MMDWY.js";var o=i(),n={target:{provider:"filesystem",capability:"read"},converter:o,priority:300},s={target:{provider:"filesystem",capability:"write"},converter:o,priority:300};async function a(e){await Promise.all([t(e,n),t(e,s)])}r(a,"registerFilesystemText");export{a as default};
|