pi-agent-ide 0.7.3 → 0.8.0
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 +27 -0
- package/README.md +63 -17
- package/dist/{chunk-2ZMMRINH.js → chunk-2K65BSXS.js} +1 -1
- package/dist/chunk-3G54ZL2L.js +1 -0
- package/dist/chunk-3ZGDMTMD.js +25 -0
- package/dist/{chunk-ZIWPKIBZ.js → chunk-4OYVLXWD.js} +1 -1
- package/dist/chunk-4W7GH3T7.js +10 -0
- package/dist/chunk-4XPUN4QN.js +2 -0
- package/dist/chunk-5KFVDYCI.js +1 -0
- package/dist/chunk-6EDOLYOV.js +1 -0
- package/dist/chunk-756K3LJY.js +1 -0
- package/dist/chunk-75SWXD2Z.js +9 -0
- package/dist/chunk-7HDK3NRQ.js +1 -0
- package/dist/chunk-7JV4VN73.js +1 -0
- package/dist/chunk-7NS3QUIE.js +9 -0
- package/dist/chunk-7TJ6DWW3.js +2 -0
- package/dist/chunk-ABFCAOU5.js +1 -0
- package/dist/chunk-BIG45IPN.js +2 -0
- package/dist/chunk-BQ67M4NC.js +3 -0
- package/dist/chunk-BXGMMZT3.js +1 -0
- package/dist/chunk-CPZJPGLG.js +1 -0
- package/dist/chunk-CSXHCSTH.js +9 -0
- package/dist/chunk-CTJV77FR.js +1 -0
- package/dist/chunk-DUUOCBS3.js +3 -0
- package/dist/chunk-E4HPRLRB.js +1 -0
- package/dist/chunk-EY65TFHJ.js +1 -0
- package/dist/{chunk-WLZIUMJL.js → chunk-GW6NZQTQ.js} +1 -1
- package/dist/chunk-HCN5W76B.js +1 -0
- package/dist/chunk-ICDI27GZ.js +1 -0
- package/dist/{chunk-TXOTNK6B.js → chunk-IH5NW5JX.js} +1 -1
- package/dist/chunk-IMGIDBCC.js +1 -0
- package/dist/chunk-IUSLSROY.js +1 -0
- package/dist/chunk-KL776TGR.js +1 -0
- package/dist/chunk-L2B4DTVS.js +1 -0
- package/dist/chunk-LEKC4GQK.js +5 -0
- package/dist/chunk-MKEC3U2M.js +4 -0
- package/dist/chunk-MOJ5RR35.js +1 -0
- package/dist/{chunk-H445SHSJ.js → chunk-MZXX353D.js} +1 -1
- package/dist/{chunk-ZTYWHL2F.js → chunk-N7LMRL64.js} +1 -1
- package/dist/chunk-NULNW6GK.js +1 -0
- package/dist/chunk-O36UC74T.js +1 -0
- package/dist/chunk-OFILFO6D.js +1 -0
- package/dist/chunk-OJX3RJ5A.js +1 -0
- package/dist/chunk-OLI3JPHJ.js +28 -0
- package/dist/{chunk-S6QRG3TQ.js → chunk-OM4LYD3S.js} +1 -1
- package/dist/chunk-PNP2KNGP.js +5 -0
- package/dist/chunk-QP2QSQ4U.js +2 -0
- package/dist/chunk-R2U5WXYR.js +1 -0
- package/dist/chunk-R5XJSEOE.js +3 -0
- package/dist/{chunk-7UGNGK7Y.js → chunk-RAZP42IQ.js} +1 -1
- package/dist/chunk-S72FVLUX.js +1 -0
- package/dist/chunk-SBLKPTL3.js +1 -0
- package/dist/chunk-SBNR4WZF.js +1 -0
- package/dist/chunk-SSWUUBIR.js +1 -0
- package/dist/chunk-T4FTT3U4.js +1 -0
- package/dist/chunk-TOYN4W4F.js +1 -0
- package/dist/chunk-TWWND6NI.js +1 -0
- package/dist/chunk-UBH6X3D3.js +1 -0
- package/dist/{chunk-QFTBY67N.js → chunk-UEVGZUII.js} +3 -3
- package/dist/chunk-UUJJRXHG.js +29 -0
- package/dist/chunk-VDP5CQHM.js +3 -0
- package/dist/chunk-WE42GBGU.js +4 -0
- package/dist/chunk-XZDOVPRC.js +1 -0
- package/dist/chunk-YJ6T3PEP.js +1 -0
- package/dist/chunk-Z3PGADVA.js +3 -0
- package/dist/{chunk-QDLTO5PH.js → chunk-ZAWRSA7N.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-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-17.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 -1
- package/dist/entry-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -2
- package/dist/entry-26.js +2 -1
- package/dist/entry-27.js +1 -2
- package/dist/entry-28.js +4 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +1 -17
- package/dist/entry-32.js +18 -1
- package/dist/entry-33.js +1 -3
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -4
- package/dist/entry-37.js +1 -9
- package/dist/entry-38.js +1 -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 -25
- package/dist/entry-46.js +25 -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-50.js +1 -3
- package/dist/entry-51.js +3 -13
- package/dist/entry-52.js +13 -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-60.js +1 -1
- package/dist/entry-61.js +1 -0
- package/dist/entry-62.js +0 -1
- package/dist/entry-63.js +1 -0
- package/dist/entry-64.js +0 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +1 -0
- package/dist/entry-72.js +0 -1
- package/dist/entry-73.js +1 -0
- package/dist/entry-74.js +0 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +1 -80
- package/dist/entry-78.js +76 -15
- package/dist/entry-79.js +21 -2
- package/dist/entry-8.js +1 -1
- package/dist/entry-80.js +2 -1
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +1 -5
- package/dist/entry-83.js +1 -3
- package/dist/entry-84.js +3 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/entry-87.js +1 -0
- package/dist/pi-agent-ide.js +19 -19
- package/docs/agent-guides/debugger.md +2 -0
- package/docs/agent-guides/editing.md +1 -1
- package/docs/agent-guides/search-code.md +4 -1
- package/docs/agent-guides/ssh.md +58 -0
- package/docs/agent-guides/vision.md +6 -0
- package/docs/configuration.md +34 -0
- package/docs/tools.md +21 -14
- package/docs/user-hooks.md +5 -3
- package/node_modules/pi-agent-doctor/package.json +6 -2
- package/node_modules/pi-agent-doctor/src/evidence.ts +49 -4
- package/node_modules/pi-agent-doctor/src/executable.ts +46 -16
- package/node_modules/pi-agent-doctor/src/fixtures/executable-probe.ts +78 -0
- package/node_modules/pi-agent-doctor/src/fixtures/probe-executable-wait.mjs +10 -0
- package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +6 -0
- package/node_modules/pi-agent-doctor/src/project-probes.ts +73 -0
- package/node_modules/pi-agent-doctor/src/workspace.ts +106 -0
- package/node_modules/pi-agent-documentation/package.json +2 -2
- package/node_modules/pi-agent-documentation/runtime/entry-25.js +1 -0
- package/node_modules/pi-agent-filesystem/package.json +8 -8
- package/node_modules/pi-agent-filesystem/src/resolver.ts +23 -7
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-jq/index.ts +33 -6
- package/node_modules/pi-agent-filesystem-jq/package.json +6 -6
- package/node_modules/pi-agent-filesystem-jq/src/jq.ts +67 -0
- 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-30.js +2 -0
- package/node_modules/pi-agent-ide-ast/package.json +15 -15
- package/node_modules/pi-agent-ide-ast/runtime/entry-31.js +0 -1
- package/node_modules/pi-agent-ide-ast/runtime/entry-32.js +2 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +2 -1
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +10 -3
- package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +4 -1
- package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +3 -3
- package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +13 -10
- package/node_modules/pi-agent-ide-ast/src/extension.ts +17 -1
- package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +32 -4
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +4 -3
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +100 -42
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +3 -2
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +2 -1
- package/node_modules/pi-agent-ide-changes/index.ts +10 -2
- package/node_modules/pi-agent-ide-changes/package.json +10 -10
- package/node_modules/pi-agent-ide-changes/runtime/entry-33.js +0 -1
- package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +7 -2
- package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +18 -1
- package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +3 -0
- package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +59 -7
- package/node_modules/pi-agent-ide-changes/src/changes/git-paths.ts +49 -0
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +10 -2
- package/node_modules/pi-agent-ide-changes/src/doctor-plugin.ts +13 -14
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +2 -1
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +47 -11
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +6 -1
- package/node_modules/pi-agent-ide-formatter/index.ts +14 -2
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-formatter/src/doctor-plugin.ts +47 -35
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +41 -11
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -28
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-lint/index.ts +35 -4
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +14 -10
- package/node_modules/pi-agent-ide-lint/src/doctor-plugin.ts +47 -39
- package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -25
- package/node_modules/pi-agent-ide-lsp/index.ts +107 -25
- package/node_modules/pi-agent-ide-lsp/package.json +10 -10
- package/node_modules/pi-agent-ide-lsp/runtime/entry-38.js +2 -0
- package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +6 -2
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +5 -1
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +5 -3
- package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +27 -11
- package/node_modules/pi-agent-ide-lsp/src/lsp/abort.ts +62 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +245 -103
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +26 -45
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/document-uri.ts +40 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/file-watchers.ts +8 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +24 -17
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +255 -56
- package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +51 -11
- package/node_modules/pi-agent-ide-lsp/src/lsp/owner-transport.ts +67 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +149 -18
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +79 -31
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +15 -12
- package/node_modules/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +16 -0
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +67 -46
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +50 -19
- 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-45.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-46.js +2 -0
- package/node_modules/pi-agent-read/src/api/tools/read.ts +4 -2
- package/node_modules/pi-agent-read/src/core/extension.ts +4 -1
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +143 -69
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +25 -1
- package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +67 -44
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +8 -3
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +20 -5
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +75 -16
- package/node_modules/pi-agent-resource/src/index.ts +3 -0
- package/node_modules/pi-agent-resource/src/resource-error.ts +17 -0
- package/node_modules/pi-agent-resource/src/resource.ts +23 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +16 -2
- package/node_modules/pi-agent-resource/src/validation.ts +2 -1
- package/node_modules/pi-agent-search/package.json +9 -9
- package/node_modules/pi-agent-search/runtime/entry-50.js +0 -1
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +6 -2
- package/node_modules/pi-agent-search/src/api/search.ts +44 -2
- package/node_modules/pi-agent-search/src/core/extension.ts +2 -3
- package/node_modules/pi-agent-search/src/core/search-core.ts +78 -8
- package/node_modules/pi-agent-search-text/index.ts +35 -1
- package/node_modules/pi-agent-search-text/package.json +14 -12
- package/node_modules/pi-agent-search-text/runtime/entry-52.js +1 -0
- package/node_modules/pi-agent-search-text/src/doctor-plugin.ts +10 -5
- package/node_modules/pi-agent-search-text/src/file-search.ts +26 -3
- package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +54 -3
- package/node_modules/pi-agent-search-text/src/resolvers.ts +22 -5
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +4 -5
- package/node_modules/pi-agent-search-text/src/search-backend.ts +110 -12
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +5 -1
- package/node_modules/pi-agent-search-text/src/search-result.ts +1 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +100 -24
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-56.js +1 -0
- package/node_modules/pi-agent-text/src/text-document.ts +2 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-57.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-58.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-59.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-60.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-61.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +3 -1
- package/node_modules/pi-agent-text-editor/package.json +26 -26
- package/node_modules/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +29 -2
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/file-operations.ts +55 -0
- package/node_modules/pi-agent-text-editor/src/api/file-transfers.ts +41 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/native-files.ts +127 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +20 -1
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +1 -0
- package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +94 -80
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +14 -2
- package/node_modules/pi-agent-text-editor/src/core/file-operation-guards.ts +81 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +21 -4
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +123 -27
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +30 -1
- package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +147 -105
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +91 -14
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +72 -7
- package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +40 -20
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +4 -3
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +307 -32
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +79 -23
- package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +4 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +117 -27
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +1 -0
- package/node_modules/pi-agent-web/index.ts +28 -4
- package/node_modules/pi-agent-web/package.json +8 -8
- package/node_modules/pi-agent-web/src/doctor-plugin.ts +21 -6
- package/node_modules/pi-agent-web/src/resolver.ts +12 -2
- package/node_modules/pi-agent-web/src/search.ts +2 -1
- 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-87.js +2 -0
- package/package.json +35 -35
- package/src/api/doctor-runtime.ts +80 -0
- package/src/api/doctor.ts +6 -0
- package/src/api/hooks.ts +3 -0
- package/src/api/plugin-protocol.ts +11 -1
- package/src/api/tool-config.ts +143 -24
- package/src/backend/config.ts +85 -0
- package/src/backend/configured-process.ts +59 -0
- package/src/backend/dap-java-transport.ts +112 -0
- package/src/backend/dap-java-worker.py +218 -0
- package/src/backend/dap-node-transport.ts +112 -0
- package/src/backend/dap-powershell-worker.py +44 -0
- package/src/backend/dap-r-worker.py +210 -0
- package/src/backend/dap-tcp-transport.ts +42 -0
- package/src/backend/dap-tcp-worker.py +125 -0
- package/src/backend/dap-transport.ts +69 -0
- package/src/backend/dap-unix-worker.py +63 -0
- package/src/backend/debugger-registration.ts +62 -0
- package/src/backend/debugger-workspace-owner.ts +413 -0
- package/src/backend/doctor-inventory-worker.py +54 -0
- package/src/backend/doctor-probe-worker.py +140 -0
- package/src/backend/doctor-registration.ts +18 -0
- package/src/backend/doctor-workspace.ts +381 -0
- package/src/backend/file-operation-resolver.ts +58 -0
- package/src/backend/file-revision.ts +13 -0
- package/src/backend/file-transfer.ts +302 -0
- package/src/backend/file-watch-worker.py +119 -0
- package/src/backend/formatter-registration.ts +114 -0
- package/src/backend/git-registration.ts +60 -0
- package/src/backend/identity.ts +47 -0
- package/src/backend/index.ts +12 -0
- package/src/backend/lint-registration.ts +102 -0
- package/src/backend/lsp-file-watchers.ts +220 -0
- package/src/backend/lsp-registration.ts +83 -0
- package/src/backend/lsp-transport.ts +87 -0
- package/src/backend/lsp-workspace-owner.ts +50 -0
- package/src/backend/object-transfer.ts +299 -0
- package/src/backend/owned-command.ts +105 -0
- package/src/backend/owned-process-stop.ts +36 -0
- package/src/backend/owned-read-command.ts +20 -0
- package/src/backend/process-environment.ts +77 -0
- package/src/backend/process-metadata-worker.py +98 -0
- package/src/backend/process-metadata.ts +99 -0
- package/src/backend/recipe-evidence-worker.py +26 -0
- package/src/backend/recipe-evidence.ts +77 -0
- package/src/backend/registration.ts +124 -0
- package/src/backend/registry.ts +29 -0
- package/src/backend/resource-resolver.ts +147 -0
- package/src/backend/search-environment.ts +100 -0
- package/src/backend/ssh-channel-worker.py +306 -0
- package/src/backend/ssh-channel.ts +376 -0
- package/src/backend/ssh-transfer-worker.py +99 -0
- package/src/backend/ssh-transport.ts +54 -0
- package/src/backend/ssh-worker.py +730 -0
- package/src/backend/ssh.ts +610 -0
- package/src/backend/tool-config-access.ts +63 -0
- package/src/backend/tool-project.ts +71 -0
- package/src/backend/vision-capture-worker.py +319 -0
- package/src/backend/vision-capture.ts +165 -0
- package/src/backend/vision-registration.ts +104 -0
- package/src/backend/web-browser-worker.mjs +182 -0
- package/src/backend/web-browser.ts +128 -0
- package/src/backend/web-http-worker.py +62 -0
- package/src/backend/web-http.ts +79 -0
- package/src/backend/web-owner.ts +68 -0
- package/src/backend/web-registration.ts +14 -0
- package/src/code-view/diagnostic-view.ts +2 -2
- package/src/code-view/reference.ts +9 -0
- package/src/composite/builtin-extensions.ts +9 -14
- package/src/composite/module-labels.ts +1 -0
- package/src/composite/nested-tool-rendering.ts +10 -1
- package/src/core/diagnostic-store.ts +32 -10
- package/src/core/ide-core.ts +22 -2
- package/src/doctor/arguments.ts +19 -0
- package/src/doctor/config-writer.ts +72 -29
- package/src/doctor/discovery.ts +53 -15
- package/src/doctor/extension.ts +27 -10
- package/src/doctor/run.ts +42 -7
- 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-jq/index.ts +33 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +67 -0
- 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-30.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-26.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +23 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +28 -4
- 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-87.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/doctor-plugin.ts +21 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +12 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +2 -1
- package/src/extensions/pi-agent-read/package.json +12 -12
- package/src/extensions/pi-agent-read/runtime/entry-45.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-46.js +2 -0
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +4 -2
- package/src/extensions/pi-agent-read/src/core/extension.ts +4 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +143 -69
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +25 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +67 -44
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +8 -3
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +20 -5
- package/src/extensions/pi-agent-search/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +35 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -12
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-52.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-55.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/doctor-plugin.ts +10 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +26 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +54 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +22 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +4 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +110 -12
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +5 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +100 -24
- package/src/extensions/pi-agent-search/runtime/entry-50.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-51.js +2 -0
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +6 -2
- package/src/extensions/pi-agent-search/src/api/search.ts +44 -2
- package/src/extensions/pi-agent-search/src/core/extension.ts +2 -3
- package/src/extensions/pi-agent-search/src/core/search-core.ts +78 -8
- 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-57.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-58.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-59.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-60.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-61.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +3 -1
- 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-renderer/src/renderer.ts +117 -27
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +29 -2
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/file-operations.ts +55 -0
- package/src/extensions/pi-agent-text-editor/src/api/file-transfers.ts +41 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/native-files.ts +127 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +20 -1
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +1 -0
- package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +94 -80
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +14 -2
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-guards.ts +81 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +21 -4
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +123 -27
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +30 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +147 -105
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +91 -14
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +72 -7
- package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +40 -20
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +4 -3
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +307 -32
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +79 -23
- package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +4 -1
- package/src/plugins/pi-agent-ide-ast/package.json +15 -15
- package/src/plugins/pi-agent-ide-ast/runtime/entry-31.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-32.js +2 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +2 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +10 -3
- package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +4 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +3 -3
- package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +13 -10
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +17 -1
- package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +32 -4
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +4 -3
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +100 -42
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +3 -2
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +2 -1
- package/src/plugins/pi-agent-ide-changes/index.ts +10 -2
- package/src/plugins/pi-agent-ide-changes/package.json +10 -10
- package/src/plugins/pi-agent-ide-changes/runtime/entry-33.js +0 -1
- package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +7 -2
- package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +18 -1
- package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +3 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +59 -7
- package/src/plugins/pi-agent-ide-changes/src/changes/git-paths.ts +49 -0
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +10 -2
- package/src/plugins/pi-agent-ide-changes/src/doctor-plugin.ts +13 -14
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +2 -1
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +47 -11
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +6 -1
- package/src/plugins/pi-agent-ide-debugger/index.ts +62 -25
- package/src/plugins/pi-agent-ide-debugger/src/adapter-executables.ts +3 -1
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +33 -0
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +150 -171
- package/src/plugins/pi-agent-ide-debugger/src/process-provider.ts +2 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +152 -58
- package/src/plugins/pi-agent-ide-debugger/src/workspace-owner.ts +28 -0
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +4 -1
- package/src/plugins/pi-agent-ide-formatter/index.ts +14 -2
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-formatter/src/doctor-plugin.ts +47 -35
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +41 -11
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -28
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-lint/index.ts +35 -4
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +14 -10
- package/src/plugins/pi-agent-ide-lint/src/doctor-plugin.ts +47 -39
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -25
- package/src/plugins/pi-agent-ide-lsp/index.ts +107 -25
- package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-38.js +2 -0
- package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +6 -2
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +5 -1
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +5 -3
- package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +27 -11
- package/src/plugins/pi-agent-ide-lsp/src/lsp/abort.ts +62 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +245 -103
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +26 -45
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/document-uri.ts +40 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/file-watchers.ts +8 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +24 -17
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +255 -56
- package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +51 -11
- package/src/plugins/pi-agent-ide-lsp/src/lsp/owner-transport.ts +67 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +149 -18
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +79 -31
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +15 -12
- package/src/plugins/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +16 -0
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +67 -46
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +50 -19
- package/src/plugins/pi-agent-ide-processes/src/registry.ts +8 -1
- package/src/plugins/pi-agent-ide-terminal/index.ts +7 -0
- package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +5 -1
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +5 -2
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +161 -42
- package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +7 -0
- package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +11 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +33 -8
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +5 -0
- package/src/plugins/pi-agent-ide-vision/index.ts +170 -9
- package/src/plugins/pi-agent-ide-vision/src/doctor-plugin.ts +47 -0
- package/src/plugins/pi-agent-ide-vision/src/vision.ts +42 -1
- package/src/post-edit/gate.ts +4 -1
- package/src/toolchain/types.ts +2 -0
- package/dist/chunk-3YK4XMWB.js +0 -0
- package/dist/chunk-5JELU6RV.js +0 -7
- package/dist/chunk-6U5OU77O.js +0 -3
- package/dist/chunk-7LD2OQH3.js +0 -14
- package/dist/chunk-BYZSBXUK.js +0 -2
- package/dist/chunk-CEX73RI5.js +0 -28
- package/dist/chunk-DZWTKF2K.js +0 -1
- package/dist/chunk-EOKEQ3YH.js +0 -25
- package/dist/chunk-HZ5BNF3A.js +0 -1
- package/dist/chunk-IG56UGSO.js +0 -2
- package/dist/chunk-KVHDMIZS.js +0 -3
- package/dist/chunk-M5IVSCR2.js +0 -1
- package/dist/chunk-M5MJP7Z2.js +0 -1
- package/dist/chunk-MGCHOGQD.js +0 -1
- package/dist/chunk-N34ATN52.js +0 -1
- package/dist/chunk-NHKPP2AI.js +0 -28
- package/dist/chunk-OB46OPMZ.js +0 -1
- package/dist/chunk-Q6CZ6GBR.js +0 -3
- package/dist/chunk-QIK2E64R.js +0 -1
- package/dist/chunk-SBP3ABH4.js +0 -5
- package/dist/chunk-STBJO3Z3.js +0 -2
- package/dist/chunk-T6LX2RX5.js +0 -1
- package/dist/chunk-WZI4YC2O.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-25.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-32.js +0 -1
- package/node_modules/pi-agent-image/runtime/entry-38.js +0 -1
- package/node_modules/pi-agent-resource/runtime/entry-46.js +0 -1
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-56.js +0 -2
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-57.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-59.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-61.js +0 -1
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-26.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-25.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-41.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-51.js +0 -2
- package/src/extensions/pi-agent-search/runtime/entry-47.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-56.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-57.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-59.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-61.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +0 -1
- package/src/plugins/pi-agent-ide-changes/runtime/entry-32.js +0 -1
- /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-24.js +0 -0
- /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-26.js +0 -0
- /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-27.js +0 -0
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-28.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-29.js +0 -0
- /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-34.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-35.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-36.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-37.js +0 -0
- /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-39.js +0 -0
- /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-40.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-41.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-47.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-51.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-55.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-81.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-83.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-27.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-28.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-29.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
- /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-34.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-35.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-36.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-37.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as B,h as M}from"./chunk-XH5WN5XA.js";import{a as N}from"./chunk-
|
|
1
|
+
import{d as B,h as M}from"./chunk-XH5WN5XA.js";import{a as N}from"./chunk-GW6NZQTQ.js";import{i as w,j as P}from"./chunk-R5XJSEOE.js";import{a as y}from"./chunk-EI7MMDWY.js";import{Allow as $}from"partial-json";import{Guard as f}from"typebox-guard/guard";import{Allow as F,parse as H}from"partial-json";function _(o,e=F.ALL){if(!(!o||o.trim().length===0))try{let t=H(o,e);return t==null||typeof t!="object"||Array.isArray(t)?void 0:t}catch{return}}y(_,"resolvePartial");var R=class{static{y(this,"PartialToolRecoveryRegistry")}registrations=new Map;states=new Map;register(e){this.registrations.set(e.recoveryKey??e.toolName,e)}unregister(e){for(let[t,n]of this.registrations)(n.toolName===e||t===e)&&this.registrations.delete(t)}recoveryKeyFor(e){for(let[t,n]of this.registrations)if(n.toolName===e||n.toolNames?.includes(e)||t===e)return t}async recover(e){let t=this.states.get(e.contentIndex);if(t?.status==="done")return t.result;if(t?.status==="running")return t.promise;let n=this.registrations.get(e.recoveryKey??e.toolName);if(!n)return;let r=this.run(n,e);this.states.set(e.contentIndex,{status:"running",promise:r});let a=await r;return this.states.set(e.contentIndex,{status:"done",result:a}),a}cancel(e){this.states.delete(e)}cleanup(e){this.states.delete(e)}cleanupAll(){this.states.clear()}async run(e,t){let n=[],r=new Set(t.completedEntryIndexes),a=new Set(t.blockedEntryIndexes),i=e.extractEntries(t).filter(c=>{if(r.has(c.index))return n.push({index:c.index,reason:"entry already completed before recovery"}),!1;if(a.has(c.index))return n.push({index:c.index,reason:"entry was blocked by a guard"}),!1;let g=e.isCompleteEntry?.(c,t)??c.complete;return g||n.push({index:c.index,reason:t.recoverCompleteBatch?"entry was incomplete in the recovered batch":"entry was incomplete before the stale entry"}),!t.recoverCompleteBatch&&t.staleEntryIndex!==void 0&&c.index>=t.staleEntryIndex?!1:g}),s=e.filterEntries?.(i,t)??i,d=new Set(s.map(c=>c.index));for(let c of i)d.has(c.index)||n.push({index:c.index,reason:"entry was excluded by recovery filtering"});let u=[];for(let c of s)try{e.validateEntry?.(c,t),u.push(c)}catch(g){n.push({index:c.index,reason:g instanceof Error?g.message:String(g)})}let m={toolName:t.toolName,contentIndex:t.contentIndex,...t.staleEntryIndex!==void 0&&{staleEntryIndex:t.staleEntryIndex},staleDetails:t.staleDetails};if(u.length===0)return{...m,status:"skipped",appliedEntries:[],skippedEntries:n};try{let c=e.buildParams(u,t),g=await e.execute(c,{contentIndex:t.contentIndex,toolCallId:t.toolCallId,toolName:t.toolName,cwd:t.cwd,ctx:t.ctx,signal:new AbortController().signal});return{...m,status:"recovered",appliedEntries:e.getAppliedEntries?.(g,u,t)??u.map(b=>b.index),skippedEntries:n,normalResult:g}}catch(c){return{...m,status:"failed",appliedEntries:[],skippedEntries:n,error:c instanceof Error?c.message:String(c)}}}};import{createAssistantMessageEventStream as W}from"@earendil-works/pi-ai";var O=Symbol.for("pi-agent-text-editor.tool-call-interceptor.streaming-provider.state");function K(o,e,t,n){let r=new Map,a={context:void 0,processStreamEvent:e,markStreamEventProcessed:t,finalizeStreamInterception:n},l=y((i,s)=>{if(!i)return;let d=s.modelRegistry.getProvider(i.provider);if(!d)return;let u=r.get(i.provider);if(u){if(u.subscribers.add(a),u.api===i.api&&d.streamSimple===u.wrapper)return;u.api=i.api;let p=s.modelRegistry.getRegisteredProviderConfig(i.provider);o.registerProvider(i.provider,{...p,api:i.api,streamSimple:u.wrapper});return}let m=d.streamSimple[O];if(m){if(m.subscribers.add(a),r.set(i.provider,m),m.api===i.api)return;m.api=i.api;let p=s.modelRegistry.getRegisteredProviderConfig(i.provider);o.registerProvider(i.provider,{...p,api:i.api,streamSimple:m.wrapper});return}let c=d.streamSimple.bind(d),g=new Set([a]),b=y((p,v,C)=>U(c,p,v,C,g),"wrapper"),E={api:i.api,delegate:c,wrapper:b,subscribers:g};b[O]=E;let h=s.modelRegistry.getRegisteredProviderConfig(i.provider);o.registerProvider(i.provider,{...h,api:i.api,streamSimple:b}),r.set(i.provider,E)},"install");o.on("before_provider_request",(i,s)=>{a.context=s,l(s.model,s)}),o.on("turn_start",(i,s)=>{a.context=s,l(s.model,s)}),o.on("agent_start",(i,s)=>{a.context=s,l(s.model,s)}),o.on("session_start",(i,s)=>{a.context=s,l(s.model,s)}),o.on("model_select",(i,s)=>{a.context=s,l(i.model,s)}),o.on("session_shutdown",()=>{for(let[i,s]of r)s.subscribers.delete(a),s.subscribers.size===0&&o.unregisterProvider(i);r.clear(),a.context=void 0})}y(K,"registerStreamingInterceptorProvider");function U(o,e,t,n,r){let a=W(),l=new AbortController,i=n?.signal,s=!1,d=Y(e),u=new Set,m=new Set,c=new Set,g=new Set,b=y(h=>{for(let p of r)p.markStreamEventProcessed(h)},"markStreamEventProcessed"),E=y(()=>{l.abort()},"abortFromParent");return i&&(i.aborted?l.abort():i.addEventListener("abort",E,{once:!0})),(async()=>{try{let h=o(e,t,{...n,signal:l.signal});for await(let p of h){if(s)continue;p.type==="done"?d=structuredClone(p.message):p.type==="error"?d=structuredClone(p.error):d=structuredClone(p.partial),Q(p,u);let v;for(let C of r){let I=C.context;if(I){let T=await C.processStreamEvent(p,I);v??=T}}if(b(p),q(p,m,c,g),a.push(structuredClone(p)),v){if(p.type==="toolcall_delta"||p.type==="toolcall_end")for(let x of r)x.finalizeStreamInterception(p.contentIndex);s=!0,l.abort();let C=p.type==="toolcall_delta"||p.type==="toolcall_end"?p.contentIndex:void 0,I={...d,content:d.content.filter((x,A)=>u.has(A)&&(C===void 0||A<=C||g.has(A))).map(x=>x.type==="toolCall"&&x.id===v.toolCallId?{...x,arguments:structuredClone(v.arguments)}:x)};V(a,b,I,u,m,c,g);let{errorMessage:T,...L}=I;a.push({type:"done",reason:"toolUse",message:{...L,stopReason:"toolUse"}}),a.end();continue}if(p.type==="done"||p.type==="error"){a.end();return}}}catch(h){if(s)return;let p=d,v=i?.aborted===!0?"aborted":"error",C={...p,stopReason:v,errorMessage:h instanceof Error?h.message:String(h)};a.push({type:"error",reason:v,error:C}),a.end()}finally{i?.removeEventListener("abort",E)}})(),a}y(U,"wrapStream");function Q(o,e){(o.type==="text_start"||o.type==="thinking_start"||o.type==="toolcall_start")&&e.add(o.contentIndex)}y(Q,"rememberStartEvent");function q(o,e,t,n){switch(o.type){case"text_end":{e.add(o.contentIndex);break}case"thinking_end":{t.add(o.contentIndex);break}case"toolcall_end":{n.add(o.contentIndex);break}}}y(q,"rememberEndEvent");function V(o,e,t,n,r,a,l){for(let[i,s]of t.content.entries())if(n.has(i)){if(s.type==="text"&&!r.has(i)){let d={type:"text_end",contentIndex:i,content:s.text,partial:t};e(d),o.push(d)}else if(s.type==="thinking"&&!a.has(i)){let d={type:"thinking_end",contentIndex:i,content:s.thinking,partial:t};e(d),o.push(d)}else if(s.type==="toolCall"&&!l.has(i)){let d={type:"toolcall_end",contentIndex:i,toolCall:s,partial:t};e(d),o.push(d)}}}y(V,"emitMissingEndEvents");function Y(o){return{role:"assistant",content:[],api:o.api,provider:o.provider,model:o.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"toolUse",timestamp:Date.now()}}y(Y,"emptyAssistantMessage");var Z="agentic-ide-partial-tool-recovery",G="pi-agent-text-editor/tool-call-annotation",S=new WeakMap,k=class{constructor(e){this.pi=e;e.on("tool_call",t=>{let n=this.toolCallRecords.get(t.toolCallId),r=n?.blockExecution?n.guardResult:void 0;return r?{block:!0,reason:r.content.filter(l=>l.type==="text").map(l=>l.text).join(`
|
|
2
2
|
`)||`Tool call ${t.toolName} was blocked by a streaming interceptor.`}:void 0}),e.on("tool_result",t=>{let n=this.toolCallBatchEntryIndexes.get(t.toolCallId);n!==void 0&&this.completedBatchEntryIndexes.add(n);let r=this.toolCallRecords.get(t.toolCallId)?.guardResult;if(this.toolCallRecords.delete(t.toolCallId),r){let a=r.details,l=typeof a=="object"&&a!==null&&"effect"in a&&(a.effect==="not-applied"||a.effect==="applied")?a.effect:"unknown",i=r.content.flatMap(s=>s.type==="text"?[s.text]:[]).join(`
|
|
3
3
|
`);return P({content:r.content,details:a},N(t.toolName),{status:"error",errors:[w(i,"INTERCEPTED")],data:{operation:t.toolName,operationId:t.toolCallId,effect:l,files:[]}})}}),e.on("message_update",async(t,n)=>{let r=t.assistantMessageEvent;this.consumeProcessedStreamEvent(r)||await this.processStreamEvent(r,n)}),e.on("message_end",async t=>{if(await this.finalizeRecovery(),this.annotateIncompleteCalls(),t.message.role!=="assistant")return;let n=this.pendingAbortReason;if(this.pendingAbortReason=void 0,!(n===void 0||t.message.stopReason!=="aborted"))return{message:{...t.message,errorMessage:n}}}),e.on("agent_end",async()=>{await this.finalizeRecovery(),this.annotateIncompleteCalls(),this.cleanupAll()})}static{y(this,"InterceptorImpl")}handlers=new Map;recoveryRegistry=new R;pendingRecoveryBlocks=[];pendingAbortReason;recoveryAppliedBatchIndexes=new Set;partialBuffers=new Map;completeArgumentContentIndices=new Set;streamedBatchEntries=new Map;batchEntryIndexes=new Map;toolCallBatchEntryIndexes=new Map;completedBatchEntryIndexes=new Set;nextBatchEntryIndex=0;contentNames=new Map;contentToolCallIds=new Map;pendingToolCallAnnotations=new Map;emittedToolCallAnnotationKinds=new Map;abortedContentIndices=new Set;dispatchQueues=new Map;abortCleanups=new Map;processedStreamEvents=new WeakSet;processedStreamEventKeys=new Map;toolCallRecords=new Map;blockedCallSink;processStreamEvent(e,t){if(e.type==="toolcall_start"){let n=e.partial.content[e.contentIndex];if(n?.type==="toolCall"){let r=this.getOrCreateBatchEntryIndex(e.contentIndex);this.contentNames.set(e.contentIndex,n.name),typeof n.id=="string"&&this.bindToolCallId(e.contentIndex,n.id),this.partialBuffers.set(e.contentIndex,""),this.streamedBatchEntries.set(e.contentIndex,{index:r,toolName:n.name,args:{},complete:!1}),this.installAbortCleanup(e.contentIndex,t.signal)}return Promise.resolve(void 0)}return e.type==="toolcall_delta"?this.enqueue(e.contentIndex,async()=>{let n=this.contentNames.get(e.contentIndex),r=this.contentToolCallIds.get(e.contentIndex);if(!n)return;let a=(this.partialBuffers.get(e.contentIndex)??"")+e.delta;this.partialBuffers.set(e.contentIndex,a),this.installAbortCleanup(e.contentIndex,t.signal);let l=_(a,$.OBJ|$.ARR)??{},i=ee(a),s=this.getOrCreateBatchEntryIndex(e.contentIndex);this.streamedBatchEntries.set(e.contentIndex,{index:s,toolName:n,args:l,complete:i!==void 0});let d=this.handlers.get(n);if(!r||!d||d.length===0||!i&&Object.keys(l).length===0)return;let u=i!==void 0;if(u&&this.completeArgumentContentIndices.has(e.contentIndex))return;u&&this.completeArgumentContentIndices.add(e.contentIndex);let m=i??l,c=await this.dispatchHandlers(d,{toolCall:{id:r,name:n,arguments:m},args:m,...!u&&{partialArgs:l},batchEntryIndex:s,batchEntries:this.getBatchEntries(s),contentIndex:e.contentIndex,cwd:t.cwd,signal:t.signal,ctx:t});return c&&this.rememberOriginalArguments(c.toolCallId,c.arguments),c}):e.type==="toolcall_end"?this.enqueue(e.contentIndex,async()=>{let n=e.toolCall.name,r=this.handlers.get(n),a=this.getOrCreateBatchEntryIndex(e.contentIndex);this.bindToolCallId(e.contentIndex,e.toolCall.id);let l=this.toolCallRecords.get(e.toolCall.id);this.toolCallRecords.set(e.toolCall.id,{originalArguments:structuredClone(e.toolCall.arguments),...l?.guardResult&&{guardResult:l.guardResult},...l?.blockExecution&&{blockExecution:!0}}),this.streamedBatchEntries.set(e.contentIndex,{index:a,toolName:n,args:e.toolCall.arguments,complete:!1});let i=!this.completeArgumentContentIndices.has(e.contentIndex),s;i&&(this.completeArgumentContentIndices.add(e.contentIndex),s=r&&r.length>0?await this.dispatchHandlers(r,{toolCall:e.toolCall,args:e.toolCall.arguments,batchEntryIndex:a,batchEntries:this.getBatchEntries(a),contentIndex:e.contentIndex,cwd:t.cwd,signal:t.signal,ctx:t}):void 0);let d=this.streamedBatchEntries.get(e.contentIndex);return d&&this.streamedBatchEntries.set(e.contentIndex,{...d,complete:!0}),this.cleanupContent(e.contentIndex,n),s}):Promise.resolve(void 0)}markStreamEventProcessed(e){this.processedStreamEvents.add(e);let t=j(e);t!==void 0&&this.processedStreamEventKeys.set(t,(this.processedStreamEventKeys.get(t)??0)+1)}consumeProcessedStreamEvent(e){let t=this.processedStreamEvents.delete(e),n=j(e);if(n===void 0)return t;let r=this.processedStreamEventKeys.get(n)??0;return r===0?t:(r===1?this.processedStreamEventKeys.delete(n):this.processedStreamEventKeys.set(n,r-1),!0)}finalizeStreamInterception(e){this.cleanupTransientContent(e,void 0,!0)}getToolCallRecord(e){return this.toolCallRecords.get(e)}rememberOriginalArguments(e,t){let n=this.toolCallRecords.get(e);n&&this.toolCallRecords.set(e,{originalArguments:structuredClone(t),...n.guardResult&&{guardResult:n.guardResult},...n.blockExecution&&{blockExecution:!0}})}async dispatchHandlers(e,t){for(let n of e){let r=await n.intercept(t);if(r!==void 0){this.pendingRecoveryBlocks.push({blocked:r,ctx:t});let a={content:[{type:"text",text:r.message.content}],details:r.message.details??null};return this.blockedCallSink?.({callId:t.toolCall.id,toolName:t.toolCall.name,arguments:structuredClone(t.args),...t.contentIndex!==void 0&&{contentIndex:t.contentIndex},...t.batchEntryIndex!==void 0&&{batchEntryIndex:t.batchEntryIndex},...r.message.details!==void 0&&{details:r.message.details},result:a,nativeExecutionBlocked:n.blockExecution===!0}),{toolCallId:t.toolCall.id,arguments:structuredClone(t.args),result:this.abortToolCall(r,t,n.name,n.blockExecution===!0)}}}}annotateIncompleteCalls(){for(let[e,t]of this.streamedBatchEntries)!t.complete&&this.contentNames.has(e)&&!this.recoveryAppliedBatchIndexes.has(t.index)&&!this.emittedToolCallAnnotationKinds.get(e)?.has("stale-anchor")&&this.annotateContent(e,{kind:"aborted"})}bindToolCallId(e,t){this.contentToolCallIds.set(e,t);let n=this.batchEntryIndexes.get(e);n!==void 0&&this.toolCallBatchEntryIndexes.set(t,n);let r=this.pendingToolCallAnnotations.get(e);if(r){for(let a of r)this.emitToolCallAnnotation(t,a);this.pendingToolCallAnnotations.delete(e)}}annotateContent(e,t){let n=this.emittedToolCallAnnotationKinds.get(e)??new Set;if(n.has(t.kind))return;n.add(t.kind),this.emittedToolCallAnnotationKinds.set(e,n);let r=this.contentToolCallIds.get(e);if(r){this.emitToolCallAnnotation(r,t);return}let a=this.pendingToolCallAnnotations.get(e)??[];a.push(t),this.pendingToolCallAnnotations.set(e,a)}emitToolCallAnnotation(e,t){let n={toolCallId:e,annotation:t};this.pi.events.emit(G,n)}getOrCreateBatchEntryIndex(e){let t=this.batchEntryIndexes.get(e);if(t!==void 0)return t;let n=this.nextBatchEntryIndex;return this.nextBatchEntryIndex+=1,this.batchEntryIndexes.set(e,n),n}getBatchEntries(e){return[...this.streamedBatchEntries.values()].filter(t=>t.index<=e).sort((t,n)=>t.index-n.index)}getAllBatchEntries(){return[...this.streamedBatchEntries.values()].sort((e,t)=>e.index-t.index)}abortToolCall(e,t,n,r){let a=X(e,n),l=e.annotation?e.annotation.kind==="aborted"&&e.annotation.label===void 0?{...e.annotation,label:a}:e.annotation:e.message.customType==="text-editor-stale-anchor-block"?{kind:"stale-anchor",label:a}:{kind:"aborted",label:a,color:"error"};t.contentIndex!==void 0&&(this.abortedContentIndices.add(t.contentIndex),this.annotateContent(t.contentIndex,l));let i={content:[{type:"text",text:e.message.content}],details:B(e.message.details,l,a)};return this.toolCallRecords.set(t.toolCall.id,{originalArguments:structuredClone(t.args),guardResult:i,...r&&{blockExecution:!0}}),i}async finalizeRecovery(){let e=this.pendingRecoveryBlocks.splice(0);if(e.length===0)return;let t=new Map;for(let n of e){let r=this.recoveryRegistry.recoveryKeyFor(n.ctx.toolCall.name);if(r===void 0)continue;let a=t.get(r)??[];a.push(n),t.set(r,a)}for(let n of t.values()){let r=n[0];if(!r)continue;let a=await this.recoverIfNeeded(r.blocked,r.ctx,this.getAllBatchEntries(),n);if(a===r.blocked)continue;let l=a.message.details,s=(f.IsObjectNotArray(l)&&f.IsObjectNotArray(l.recovery)?l.recovery:void 0)?.appliedEntries;if(Array.isArray(s))for(let d of s)typeof d=="number"&&this.recoveryAppliedBatchIndexes.add(d)}}async recoverIfNeeded(e,t,n,r){if(t.contentIndex===void 0)return e;let a=e.message.details,l=f.IsObjectNotArray(a)&&typeof a.entryIndex=="number"?a.entryIndex:void 0,i=[...new Set(r.map(g=>g.ctx.batchEntryIndex).filter(g=>g!==void 0))],s=[...new Set(r.map(g=>g.ctx.toolCall.id))],d=r.map(g=>g.blocked.message.details),u=r[0],m=u?this.recoveryRegistry.recoveryKeyFor(u.ctx.toolCall.name):void 0;if(!m)return e;let c=await this.recoveryRegistry.recover({contentIndex:t.contentIndex,toolCallId:t.toolCall.id,toolName:t.toolCall.name,...l!==void 0&&{staleEntryIndex:l},staleDetails:a,...t.partialArgs&&{partialArgs:t.partialArgs},args:t.args,batchEntries:n,...t.batchEntryIndex!==void 0&&{batchEntryIndex:t.batchEntryIndex},recoverCompleteBatch:!0,completedEntryIndexes:[...this.completedBatchEntryIndexes],blockedEntryIndexes:i,blockedToolCallIds:s,blockedDetails:d,recoveryKey:m,cwd:t.cwd,ctx:t.ctx});return c&&(c.appliedEntries.length>0||c.skippedEntries.length>0)?re(e,c):e}async enqueue(e,t){let r=(this.dispatchQueues.get(e)??Promise.resolve()).catch(()=>{}).then(t);this.dispatchQueues.set(e,r);try{return await r}finally{this.dispatchQueues.get(e)===r&&this.dispatchQueues.delete(e)}}installAbortCleanup(e,t){if(!t||this.abortCleanups.has(e))return;let n=y(()=>{let r=this.contentNames.get(e),a=r?this.handlers.get(r):void 0;for(let l of a??[])l.onAbort?.(e)},"listener");t.addEventListener("abort",n,{once:!0}),this.abortCleanups.set(e,()=>{t.removeEventListener("abort",n)})}cleanupContent(e,t){this.cleanupTransientContent(e,t),this.recoveryRegistry.cleanup(e)}cleanupTransientContent(e,t,n=!1){let r=t??this.contentNames.get(e),a=r?this.handlers.get(r):void 0;for(let l of a??[])n&&l.onAbort?.(e),l.onContentEnd?.(e);this.abortCleanups.get(e)?.(),this.abortCleanups.delete(e),this.contentNames.delete(e),this.contentToolCallIds.delete(e),this.pendingToolCallAnnotations.delete(e),this.emittedToolCallAnnotationKinds.delete(e),this.completeArgumentContentIndices.delete(e),this.partialBuffers.delete(e),this.abortedContentIndices.delete(e)}cleanupAll(){for(let e of this.handlers.values())for(let t of e)t.onAgentEnd?.();for(let e of this.abortCleanups.values())e();this.abortCleanups.clear(),this.contentNames.clear(),this.contentToolCallIds.clear(),this.pendingToolCallAnnotations.clear(),this.completeArgumentContentIndices.clear(),this.emittedToolCallAnnotationKinds.clear(),this.partialBuffers.clear(),this.streamedBatchEntries.clear(),this.batchEntryIndexes.clear(),this.toolCallBatchEntryIndexes.clear(),this.toolCallRecords.clear(),this.completedBatchEntryIndexes.clear(),this.nextBatchEntryIndex=0,this.abortedContentIndices.clear(),this.pendingAbortReason=void 0,this.dispatchQueues.clear(),this.processedStreamEventKeys.clear(),this.recoveryRegistry.cleanupAll(),this.pendingRecoveryBlocks.length=0,this.recoveryAppliedBatchIndexes.clear()}registerRecovery(e){this.recoveryRegistry.register(e)}unregisterRecovery(e){this.recoveryRegistry.unregister(e)}registerBlockedCallSink(e){this.blockedCallSink=e}register(e){let t=new Set(e.toolNames);for(let[n,r]of this.handlers){let a=r.findIndex(l=>l.name===e.name);a!==-1&&(t.has(n)?(r[a]=e,t.delete(n)):r.splice(a,1))}for(let n of t){let r=this.handlers.get(n)??[];r.push(e),this.handlers.set(n,r)}}unregister(e){for(let[t,n]of this.handlers)this.handlers.set(t,n.filter(r=>r.name!==e))}};function j(o){if(o.type==="toolcall_end")return`${o.type}\0${o.contentIndex}\0${o.toolCall.id}`;if(o.type!=="toolcall_start"&&o.type!=="toolcall_delta")return;let e=o.partial.content[o.contentIndex],t=e?.type==="toolCall"?e.id:"",n=o.type==="toolcall_delta"?o.delta:"";return`${o.type}\0${o.contentIndex}\0${t}\0${n}`}y(j,"toolStreamEventKey");function X(o,e){return o.annotation?.reason?o.annotation.reason:o.annotation?.label?o.annotation.label:o.message.customType==="text-editor-stale-anchor-block"?"Stale Anchor":e.replace(/[-_]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())||"Blocked"}y(X,"abortReason");function ee(o){try{let e=JSON.parse(o);return f.IsObjectNotArray(e)?e:void 0}catch{return}}y(ee,"parseCompleteArguments");function te(o){let e=o.normalResult;if(!f.IsObjectNotArray(e)||!f.IsObjectNotArray(e.details))return[];let t=e.details.results;if(!Array.isArray(t))return[];let n=f.IsObjectNotArray(o.staleDetails)&&typeof o.staleDetails.path=="string"?o.staleDetails.path:void 0,r=t.filter(f.IsObjectNotArray).map(s=>f.IsObjectNotArray(s.data)?s.data:s),a=n===void 0?r:r.filter(s=>s.path===n),i=(a.length>0?a:r).flatMap(s=>{let d=s.freshAnchors;return Array.isArray(d)?d.filter(u=>typeof u=="string"):[]});return[...new Set(i)]}y(te,"freshAnchorsAfterRecovery");function ne(o,e){let n=o.indexOf(`
|
|
4
4
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as v}from"./chunk-BXGMMZT3.js";import{b as E,c as A,d as j}from"./chunk-756K3LJY.js";import{a as h}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import F from"cross-spawn";import{access as M,readFile as P,writeFile as D}from"node:fs/promises";import _ from"node:os";import l from"node:path";import{fileURLToPath as U}from"node:url";var N=1;function se(e){return l.win32.basename(h(e[0]))}a(se,"configuredExecutableName");async function ae(e,o,n,r,i){i?.throwIfAborted();let s=l.resolve(e),t=l.resolve(s,o),c=r.filter(d=>H(d,t));if(X(s,t))return s;let f=l.dirname(t);for(;;){if(i?.throwIfAborted(),await Q(S(f,n),i)||[...(await v(f,c,void 0,i)).values()].some(p=>p.score>0))return f;let u=l.dirname(f);if(u===f)return;f=u}}a(ae,"resolveExternalToolProjectRoot");function G(e){return l.join(e,".pi","pi-agent-ide")}a(G,"projectIdeConfigDirectory");function S(e,o){return l.join(G(e),`${o}.json`)}a(S,"projectIdeConfigPath");function B(e,o,n={}){let i=(n.environment??process.env).PI_CODING_AGENT_DIR?.trim(),s=i===void 0||i.length===0?l.join(n.homeDirectory??_.homedir(),".pi","agent"):l.resolve(i);return{project:S(e,o),global:l.join(s,"extensions","pi-agent-ide",`${o}.json`),builtIn:U(new URL(`tool-config/${o}.json`,new URL("../src/api/tool-config.ts",import.meta.url).href))}}a(B,"resolveToolConfigPaths");async function le(e,o,n,r={}){let i=r.signal;i?.throwIfAborted();let s=r.layerAccess;if(e.includes("://")&&!s)throw Object.assign(new Error("No config owner for this project"),{code:"UNSUPPORTED_SOURCE"});let t={...B(e,o,r),...s?await s.paths(e,o,i):{}},c=[{layer:"project",sourcePath:t.project,optional:!0},...r.includeGlobal===!1?[]:[{layer:"global",sourcePath:t.global,optional:!0}],{layer:"built-in",sourcePath:t.builtIn,optional:!1}],f=[],d=new Set;for(let u of c){i?.throwIfAborted();let p=await z(u,o,n,u.layer!=="built-in"&&s?m=>s.readText(m,i):void 0,i);for(let[m,C]of Object.entries(p))d.has(m)||(d.add(m),f.push({id:m,config:C,layer:u.layer,sourcePath:u.sourcePath}))}return{entries:f,paths:t}}a(le,"loadLayeredToolConfig");function J(e,o,n){let r=l.extname(o).toLowerCase();if(e.extensions.every(t=>!(L(t)===r||t==="*"))&&!e.fileNames?.some(t=>process.platform==="win32"?t.toLowerCase()===l.basename(o).toLowerCase():t===l.basename(o)))return!1;let i=l.relative(n,o).split(l.sep).join("/"),s=a(t=>t?.some(c=>l.matchesGlob(i,c))??!1,"matches");return(e.include===void 0||s(e.include))&&!s(e.exclude)}a(J,"matchesConfiguredFile");function ce(e,o,n,r,i){let s=l.resolve(i,r),t=e.filter(d=>J(d.config,s,i)),c=t.find(d=>d.layer!=="built-in");if(c!==void 0)return c;let f=Math.max(0,...t.map(d=>n.get(d.id)?.score??0));return t.find(d=>o.has(d.id)&&(n.get(d.id)?.score??0)===f)}a(ce,"selectConfiguredEntry");async function q(e,o,n=process.env,r){r?.throwIfAborted(),w(e,"process");let i=h(e.command[0]).replaceAll("{project}",o),s=k(e,o,n);return j(i,o,s,r)}a(q,"hasConfiguredExecutable");async function fe(e,o,n,r){if(r.signal?.throwIfAborted(),e.includes("://")&&!r.executableAvailability)throw Object.assign(new Error("Tool probes require their resource owner"),{code:"UNSUPPORTED_SOURCE"});let i=r.executableAvailability?await r.executableAvailability(o.map(t=>t.config),r.signal):await Promise.all(o.map(t=>q(t.config,e,r.environment??process.env,r.signal)));if(r.signal?.throwIfAborted(),i.length!==o.length||i.some(t=>typeof t!="boolean"))throw new TypeError("Invalid tool executable availability report");let s=r.recipeEvidence?await r.recipeEvidence(n,r.signal):await v(e,n,void 0,r.signal);return r.signal?.throwIfAborted(),{available:new Set(o.filter((t,c)=>i[c]===!0&&(!r.requireBuiltInEvidence||(s.get(t.id)?.score??0)>0)).map(t=>t.id)),evidence:s}}a(fe,"toolRuntimeEvidence");async function V(e,o){if(w(e,"process"),o.processAccess)return o.processAccess.run(e,o);if(o.projectRoot.includes("://")||o.filePath.includes("://"))throw Object.assign(new Error("No process owner for this resource"),{code:"UNSUPPORTED_SOURCE"});let n=e.command.map(f=>W(f,o)),r=h(n[0]),i=n.slice(1),s=e.cwd==="file"?l.dirname(o.filePath):o.projectRoot,t=e.successExitCodes??[0],c=k(e,o.projectRoot,o.env??process.env);return new Promise((f,d)=>{let u=F(r,i,{cwd:s,env:c,signal:o.signal,killSignal:"SIGKILL",stdio:["ignore","pipe","pipe"]}),p="",m="",C=h(u.stdout),x=h(u.stderr),T=!1,R=setTimeout(()=>{T=!0,u.kill("SIGKILL")},e.timeoutMs??3e4);C.setEncoding("utf8"),x.setEncoding("utf8"),C.on("data",g=>{p+=g}),x.on("data",g=>{m+=g}),u.on("error",g=>{clearTimeout(R),d(g)}),u.on("close",g=>{clearTimeout(R),f({ok:!T&&g!==null&&t.includes(g),exitCode:g,stdout:p,stderr:m})})})}a(V,"runConfiguredProcess");async function de(e,o){let n=await P(o.filePath,"utf8"),r=await V(e.run,o);if(!r.ok)return{ok:!1,changed:await P(o.filePath,"utf8")!==n};e.output==="stdout"&&r.stdout!==n&&await D(o.filePath,r.stdout,"utf8");let i=await P(o.filePath,"utf8");return{ok:!0,changed:n!==i}}a(de,"runConfiguredFormatter");function ue(e){let o=$(e,"formatters");for(let[n,r]of Object.entries(o.entries)){let i=y(r,`formatter ${n}`);if(O(i,`formatter ${n}`),w(i.run,`formatter ${n}.run`),i.output!=="in-place"&&i.output!=="stdout")throw new Error(`formatter ${n}.output must be in-place or stdout`)}return e}a(ue,"parseFormattersConfig");function ge(e){let o=$(e,"linters"),n=new Set(["pi-json","eslint-json","sarif","checkstyle","gcc","clang","regex"]);for(let[r,i]of Object.entries(o.entries)){let s=y(i,`linter ${r}`);O(s,`linter ${r}`),w(s.check,`linter ${r}.check`),s.fix!==void 0&&w(s.fix,`linter ${r}.fix`);let t=y(s.diagnostics,`linter ${r}.diagnostics`);if(!n.has(String(t.format)))throw new Error(`linter ${r} has an unsupported diagnostics format`);if(t.columnBase!==void 0&&(t.format!=="regex"||t.columnBase!==0&&t.columnBase!==1))throw new Error(`linter ${r} columnBase must be 0 or 1 for regex diagnostics`);if(t.format==="regex"&&typeof t.pattern!="string")throw new Error(`linter ${r} regex diagnostics require pattern`)}return e}a(ge,"parseLintersConfig");function $(e,o){let n=y(e,"tool config");if(n.version!==N)throw new Error(`tool config version must be ${N}`);return{entries:y(n[o],o)}}a($,"configRoot");function O(e,o){b(e.extensions,`${o}.extensions`,!1),e.fileNames!==void 0&&b(e.fileNames,`${o}.fileNames`,!1),e.include!==void 0&&b(e.include,`${o}.include`,!1),e.exclude!==void 0&&b(e.exclude,`${o}.exclude`,!0)}a(O,"assertMatcher");function w(e,o){let n=y(e,o);if(b(n.command,`${o}.command`,!1),n.cwd!==void 0&&n.cwd!=="project"&&n.cwd!=="file")throw new Error(`${o}.cwd must be project or file`);if(n.timeoutMs!==void 0&&(!Number.isFinite(n.timeoutMs)||Number(n.timeoutMs)<=0))throw new Error(`${o}.timeoutMs must be positive`);if(n.successExitCodes!==void 0&&(!Array.isArray(n.successExitCodes)||n.successExitCodes.some(r=>!Number.isInteger(r))))throw new Error(`${o}.successExitCodes must contain integers`);if(n.env!==void 0){let r=y(n.env,`${o}.env`);if(Object.values(r).some(i=>typeof i!="string"))throw new Error(`${o}.env values must be strings`)}}a(w,"assertProcessConfig");function b(e,o,n){if(!Array.isArray(e)||!n&&e.length===0||e.some(r=>typeof r!="string"||r.length===0))throw new Error(`${o} must be ${n?"an":"a non-empty"} array of strings`)}a(b,"assertStringArray");function y(e,o){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${o} must be an object`);return e}a(y,"configRecord");function L(e){return e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`}a(L,"normalizeExtension");async function z(e,o,n,r,i){i?.throwIfAborted();let s;try{s=r?await r(e.sourcePath):await P(e.sourcePath,{encoding:"utf8",signal:i})}catch(t){if(i?.throwIfAborted(),e.optional&&K(t))return{};throw new Error(`Cannot read ${e.layer} ${o} config at ${e.sourcePath}: ${I(t)}`,{cause:t})}i?.throwIfAborted();try{return n(JSON.parse(s))}catch(t){throw new Error(`Invalid ${e.layer} ${o} config at ${e.sourcePath}: ${I(t)}`,{cause:t})}}a(z,"readToolConfigLayer");function K(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}a(K,"isMissingFile");function I(e){return e instanceof Error?e.message:String(e)}a(I,"errorMessage");function k(e,o,n){return A(o,{...E(n),...E(e.env??{})})}a(k,"createConfiguredProcessEnvironment");function W(e,o){let n=l.relative(o.projectRoot,o.filePath);return e.replaceAll("{project}",o.projectRoot).replaceAll("{fileDir}",l.dirname(o.filePath)).replaceAll("{relativeFile}",n).replaceAll("{file}",o.filePath)}a(W,"expandPlaceholders");function H(e,o){let n=l.extname(o).toLowerCase(),r=l.basename(o),i=a((s,t=[])=>s.some(c=>L(c)===n)||t.some(c=>c===r),"matches");return e.formatter?i(e.formatter.extensions,e.formatter.fileNames):e.linter?i(e.linter.extensions,e.linter.fileNames):e.lsp?i(Object.values(e.lsp.languageIds).flat(),Object.values(e.lsp.fileNames??{}).flat()):!1}a(H,"recipeMatchesFile");async function Q(e,o){o?.throwIfAborted();try{return await M(e),o?.throwIfAborted(),!0}catch{return o?.throwIfAborted(),!1}}a(Q,"fileExists");function X(e,o){let n=l.relative(e,o);return n===""||n!==".."&&!n.startsWith(`..${l.sep}`)&&!l.isAbsolute(n)}a(X,"isPathInside");export{N as a,se as b,ae as c,G as d,S as e,B as f,le as g,J as h,ce as i,q as j,fe as k,V as l,de as m,ue as n,ge as o,k as p,H as q};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f}from"./chunk-OJX3RJ5A.js";import{a as d}from"./chunk-XZDOVPRC.js";import{g as m}from"./chunk-EY65TFHJ.js";import{a as c}from"./chunk-EI7MMDWY.js";import l from"node:path";function k(p){return{async run(t,e){e.signal?.throwIfAborted();let r=p.resolve(e.projectRoot),n=p.resolve(e.filePath);if(!r||!n||r.location.target!==n.location.target)throw new m("UNSUPPORTED_SOURCE",e.filePath,"not-applied");let o=r.location.path,s=n.location.path,u=c(a=>a.replaceAll("{project}",o).replaceAll("{fileDir}",l.posix.dirname(s)).replaceAll("{relativeFile}",l.posix.relative(o,s)).replaceAll("{file}",s),"expand"),h=t.command.map(u),g=await f(r.backend,o,t.env,e.signal);e.signal?.throwIfAborted();let i=await d({...r.backend.target,workspace:t.cwd==="file"?l.posix.dirname(s):o},"env",[...Object.entries(g).map(([a,w])=>`${a}=${w}`),...h],e.filePath,{signal:e.signal,timeoutMs:t.timeoutMs??3e4,maxBytes:20*1024*1024,closeInput:!0,effect:"unknown"});return{ok:(t.successExitCodes??[0]).includes(i.exitCode),exitCode:i.exitCode,stdout:i.stdout.toString("utf8"),stderr:i.stderr.toString("utf8")}}}}c(k,"createSshConfiguredProcessAccess");export{k as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as n}from"./chunk-CTJV77FR.js";import{g as s}from"./chunk-EY65TFHJ.js";import{a as o}from"./chunk-EI7MMDWY.js";async function h(r,c,d){try{await r.stop()}catch(t){if(!(t instanceof s)||t.code!=="TRANSPORT_FAILED"||!r.identity)throw t;let e;try{e=await n(c,d,r.pid)}catch(i){throw new AggregateError([t,i],"Owned SSH cleanup could not be reconciled",{cause:i})}if(e===void 0||e.identity!==r.identity)return;throw t}}o(h,"stopOwnedSshProcess");export{h as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n}from"./chunk-EI7MMDWY.js";var s=class{static{n(this,"AgentIdeProcessRegistry")}#t=new Map;#n=new Set;#e=new Map;add(e){return this.#e.get(e.id)?.(),this.#t.set(e.id,e),this.#e.set(e.id,e.onDidChange(()=>this.#s())),this.#s(),()=>{this.#t.get(e.id)===e&&(this.#e.get(e.id)?.(),this.#e.delete(e.id),this.#t.delete(e.id),this.#s())}}list(){return[...this.#t.values()].flatMap(e=>e.list())}onDidChange(e){return this.#n.add(e),()=>this.#n.delete(e)}dispose(){for(let e of this.#e.values())e();this.#e.clear(),this.#t.clear(),this.#n.clear()}#s(){for(let e of this.#n)e()}},i=new WeakMap;function r(t){let e=i.get(t);return e===void 0&&(e=new s,i.set(t,e)),e}n(r,"agentIdeProcessRegistry");export{r as a};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as o}from"./chunk-EI7MMDWY.js";import{readFile as l}from"node:fs/promises";var i=256*1024;async function c(e){if(e.includes("://"))throw new Error("URI outlines require an owned text snapshot, not a local file read.");let t=await l(e);if(t.byteLength>i)throw new Error(`File exceeds the ${i}-byte AST outline limit: ${e}`);if(t.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${e}`);let n=t.toString("utf8").replaceAll(`\r
|
|
2
|
+
`,`
|
|
3
|
+
`),r=n.endsWith(`
|
|
4
|
+
`)?n.slice(0,-1):n,s=r.length===0?[]:r.split(`
|
|
5
|
+
`);return{content:n,lines:s}}o(c,"readTextFile");export{i as a,c as b};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as v,b as O,c as _,d as z}from"./chunk-TOYN4W4F.js";import{a as F}from"./chunk-YJ6T3PEP.js";import{b as T,c as N}from"./chunk-S72FVLUX.js";import{a as M}from"./chunk-K5G4FDXD.js";import{a as j}from"./chunk-ZAWRSA7N.js";import{a as R,b}from"./chunk-OFILFO6D.js";import{b as P,c as E,g as D,i as S,k as I,l as $,o as A}from"./chunk-IMGIDBCC.js";import{a as u}from"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import le from"node:path";var p=[c("dart-analyze",["dart"],["dart"],["analysis_options.yaml","pubspec.yaml"],[".dart"],["dart","analyze","--format","machine","{file}"],"regex","https://dart.dev/tools/dart-analyze","^(?<severity>[^|]+)\\|[^|]+\\|(?<code>[^|]+)\\|(?<file>[^|]+)\\|(?<line>\\d+)\\|(?<column>\\d+)\\|\\d+\\|(?<message>.*)$",void 0,[0,1,2,3]),c("zig-ast-check",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","ast-check","{file}"],"gcc","https://ziglang.org/documentation/master/"),c("lintr",["r"],["Rscript"],[".lintr","DESCRIPTION"],[".r"],["Rscript","-e","print(lintr::lint(commandArgs(TRUE)[1]))","{file}"],"regex","https://lintr.r-lib.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[^:]+): \\[(?<code>[^\\]]+)\\] (?<message>.*)$"),c("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),c("eslint",["javascript","typescript","vue","svelte"],["eslint"],["eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts",".eslintrc",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc.yaml",".eslintrc.yml"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".vue",".svelte"],["eslint","--format","json","{file}"],"eslint-json","https://eslint.org/docs/latest/",void 0,["eslint"]),c("oxlint",["javascript","typescript"],["oxlint"],[".oxlintrc.json",".oxlintrc.jsonc","oxlint.config.ts","oxlint.config.mts"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts"],["oxlint","--format","sarif","{file}"],"sarif","https://oxc.rs/docs/guide/usage/linter.html",void 0,["oxlint"]),c("ruff",["python"],["ruff"],["pyproject.toml","ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","check","--output-format","concise","{file}"],"regex","https://docs.astral.sh/ruff/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<code>\\S+) (?<message>.+)$",["ruff"]),c("golangci-lint",["go"],["golangci-lint"],[".golangci.yml",".golangci.yaml","go.mod"],[".go"],["golangci-lint","run","--output.text.path=","--output.checkstyle.path=stdout","--show-stats=false","./..."],"checkstyle","https://golangci-lint.run/"),c("clippy",["rust"],["cargo"],["Cargo.toml","clippy.toml"],[".rs"],["cargo","clippy","--message-format","short"],"gcc","https://doc.rust-lang.org/clippy/"),c("dotnet-format",["csharp"],["dotnet"],[".editorconfig","global.json"],[".cs"],["dotnet","format","--verify-no-changes","--include","{relativeFile}"],"regex","https://learn.microsoft.com/dotnet/core/tools/dotnet-format","^(?<file>.+)\\((?<line>\\d+),(?<column>\\d+)\\): (?<severity>error|warning) (?<code>[^:]+): (?<message>.*?)(?: \\[.*\\])?$",void 0,[0,2]),c("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-c","checkstyle.xml","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),c("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}","--config","detekt.yml"],"regex","https://detekt.dev/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<message>.*?) \\[(?<code>[^\\]]+)\\]$",void 0,[0,2]),c("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"regex","https://docs.rubocop.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?:\\[Correctable\\] )?(?<code>[^:]+): (?<message>.*)$"),c("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=checkstyle","{file}"],"checkstyle","https://github.com/PHPCSStandards/PHP_CodeSniffer",void 0,void 0,[0,1,2,3]),c("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--quiet","--reporter","checkstyle","{file}"],"checkstyle","https://github.com/realm/SwiftLint",void 0,void 0,[0,2]),c("scalafix",["scala"],["scalafix"],[".scalafix.conf"],[".scala",".sc"],["scalafix","--check","--files","{file}"],"gcc","https://scalacenter.github.io/scalafix/",void 0,void 0,[0,2,64,66]),c("credo",["elixir"],["mix"],["mix.exs",".credo.exs"],[".ex",".exs"],["mix","credo","--strict","--format","flycheck","--files-included","{file}"],"regex","https://hexdocs.pm/credo/","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?<message>.+)$",void 0,Array.from({length:32},(t,e)=>e)),c("psscriptanalyzer",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};Invoke-ScriptAnalyzer -Path $args[0] @options | ForEach-Object {"$($_.ScriptPath):$($_.Line):$($_.Column): $($_.Severity): $($_.Message) [$($_.RuleName)]"}',"{file}"],"regex","https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>\\w+): (?<message>.+) \\[(?<code>[^\\]]+)\\]$",void 0,[0]),c("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","--codes","--no-color","{file}"],"regex","https://github.com/lunarmodules/luacheck","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): \\((?<code>(?<severity>[WE])\\d+)\\) (?<message>.+)$",void 0,[0,1,2]),c("shellcheck",["shell"],["shellcheck"],[".shellcheckrc"],[".sh",".bash",".zsh"],["shellcheck","-f","gcc","{file}"],"gcc","https://www.shellcheck.net/"),c("stylelint",["css"],["stylelint"],["stylelint.config.js",".stylelintrc.json"],[".css",".scss",".sass",".less"],["stylelint","--formatter","compact","{file}"],"regex","https://stylelint.io/","^(?<file>.+): line (?<line>\\d+), col (?<column>\\d+), (?<severity>error|warning) - (?<message>.+) \\((?<code>[^)]+)\\)$",["stylelint"],[0,2]),c("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"regex","https://yamllint.readthedocs.io/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): \\[(?<severity>[^\\]]+)\\] (?<message>.*?) \\((?<code>[^)]+)\\)$"),c("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"regex","https://github.com/DavidAnson/markdownlint","^(?<file>.+?):(?<line>\\d+)(?::(?<column>\\d+))? (?<severity>error|warning) (?<code>MD\\d+)(?:/\\S+)? (?<message>.*)$"),c("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),c("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],[".dockerfile"],["hadolint","--format","checkstyle","{file}"],"checkstyle","https://github.com/hadolint/hadolint",void 0,void 0,[0,1],void 0,["Dockerfile","Containerfile"]),c("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","checkstyle"],"checkstyle","https://github.com/terraform-linters/tflint",void 0,void 0,[0,2]),c("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"regex","https://cmake-format.readthedocs.io/","^(?<file>.+?):(?<line>\\d+),(?<column>\\d+): \\[(?<code>(?<severity>[A-Z])\\d+)\\] (?<message>.*)$",void 0,[0,1],0,["CMakeLists.txt"]),c("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","checkstyle","--nocolor","{file}"],"checkstyle","https://htmlhint.com/"),c("jsonlint",["json"],["jsonlint"],[".jsonlintrc",".jsonlintrc.json",".jsonlintrc.yaml",".jsonlintrc.yml",".jsonlintrc.js",".jsonlintrc.cjs","jsonlint.config.js","jsonlint.config.cjs"],[".json"],["jsonlint","-q","{file}"],"regex","https://github.com/prantlf/jsonlint","^(?:Error: )?(?<message>Parse (?<severity>error) on line (?<line>\\d+)(?:, column (?<column>\\d+))?:[^\\n]*)$",["@prantlf/jsonlint","jsonlint"]),c("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","--colors","never","{file}"],"regex","https://taplo.tamasfe.dev/","^(?<severity>error): (?<message>[^\\n]+)\\n\\s*\u250C\u2500 (?<file>.+):(?<line>\\d+):(?<column>\\d+)"),c("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"regex","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html","^(?<file>.+?):(?<line>\\d+): (?<severity>(?:parser |validity )?(?:error|warning)) : (?<message>.*)$",void 0,[0,1,2,3,4])];function c(t,e,n,r,o,s,f,i,a,d,m=[0,1],k,y){return{id:t,name:t,kind:"linter",languages:e,executables:n,configFiles:r,documentation:i,...d&&{dependencies:d},linter:{extensions:o,...y&&{fileNames:y},check:{command:s,successExitCodes:m},diagnostics:{format:f,...a&&{pattern:a},...k!==void 0&&{columnBase:k}}}}}l(c,"recipe");import x from"node:path";import ie from"node:os";import{fileURLToPath as re}from"node:url";function V(t,e){if(t.trim().length===0)return[];switch(e.format){case"pi-json":return H(t);case"eslint-json":return B(t);case"sarif":return Z(t);case"checkstyle":return X(t);case"gcc":case"clang":return K(t);case"regex":return Q(t,u(e.pattern),e.columnBase??1)}}l(V,"parseDiagnostics");function H(t){let e=JSON.parse(t);return Array.isArray(e.diagnostics)?e.diagnostics.flatMap(h):[]}l(H,"parsePiJson");function B(t){return JSON.parse(t).flatMap(n=>Array.isArray(n.messages)?n.messages.flatMap(r=>h(r).map(o=>({...o,...n.filePath&&{file:n.filePath}}))):[])}l(B,"parseEslintJson");function Z(t){return(JSON.parse(t).runs??[]).flatMap(n=>(n.results??[]).flatMap(r=>{let o=r.locations?.[0]?.physicalLocation,s=o?.region??{},f=r.message;return h({file:o?.artifactLocation?.uri,line:s.startLine,column:s.startColumn,message:f?.text,code:r.ruleId,severity:te(r.level)})}))}l(Z,"parseSarif");function X(t){let e=[];for(let n of t.matchAll(/<file\s+([^>]+)>([\s\S]*?)<\/file>/gu)){let r=q(u(n[1])).name;for(let o of u(n[2]).matchAll(/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu)){let s=q(u(o[1]));e.push(...h({file:r,line:Number(s.line),column:Number(s.column??1),message:s.message,code:s.source,severity:s.severity}))}}return e}l(X,"parseCheckstyle");function q(t){return Object.fromEntries([...t.matchAll(/([\w-]+)="([^"]*)"/gu)].map(e=>[u(e[1]),ne(u(e[2]))]))}l(q,"xmlAttributes");function K(t){return Y(t,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}l(K,"parseCompilerLines");function Q(t,e,n){return[...t.replaceAll(`\r
|
|
2
|
+
`,`
|
|
3
|
+
`).matchAll(new RegExp(e,"gmu"))].flatMap(r=>r.groups===void 0?[]:h({...r.groups,...r.groups.column!==void 0&&{column:Number(r.groups.column)+(1-n)}}))}l(Q,"parseRegexLines");function Y(t,e){return t.split(/\r?\n/u).flatMap(n=>{let r=n.match(e)?.groups;return r===void 0?[]:h(r)})}l(Y,"parseMatchingLines");function h(t){if(typeof t!="object"||t===null)return[];let e=t,n=J(e.line??e.startLine),r=J(e.column??e.startColumn,1),o=typeof e.message=="string"?e.message:void 0;return n===void 0||o===void 0?[]:[{...typeof e.file=="string"&&{file:e.file},code:U(e.code??e.ruleId,"lint"),message:o,line:n,column:r??1,severity:ee(e.severity)}]}l(h,"normalizeDiagnostic");function J(t,e){let n=typeof t=="string"?Number.parseInt(t,10):t;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:e}l(J,"numberValue");function U(t,e){return typeof t=="string"||typeof t=="number"?String(t):e}l(U,"stringValue");function ee(t){if(t===2)return"error";if(t===1)return"warning";let e=U(t,"warning").toLowerCase();return e.includes("error")||e==="e"||e==="f"||e==="fatal"?"error":e==="info"||e==="note"||e==="notice"?"info":e==="hint"?"hint":"warning"}l(ee,"severityValue");function te(t){return t==="error"||t==="warning"||t==="note"?t:"warning"}l(te,"sarifSeverity");function ne(t){return t.replace(/&#(x[0-9a-f]+|\d+);/giu,(e,n)=>{let r=n.toLowerCase().startsWith("x")?Number.parseInt(n.slice(1),16):Number(n);return r<=1114111?String.fromCodePoint(r):e}).replaceAll(""",'"').replaceAll("'","'").replaceAll("<","<").replaceAll(">",">").replaceAll("&","&")}l(ne,"decodeXml");var g=class t{constructor(e,n,r=new Map){this.linters=e;this.availableBuiltIns=n;this.evidence=r}static{l(this,"LintCommandRegistry")}static async fromDirectory(e,n={}){let r=await D(e,"linters",i=>A(i).linters,n),{available:o,evidence:s}=await I(e,r.entries.filter(i=>i.layer==="built-in").map(i=>({id:i.id,config:i.config.check})),p,n),f=[...r.entries].sort((i,a)=>i.layer==="built-in"&&a.layer==="built-in"?(s.get(a.id)?.score??0)-(s.get(i.id)?.score??0):0);return new t(f,o,s)}static fromConfig(e){return new t(Object.entries(e.linters).map(([n,r])=>({id:n,config:r,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(e,n){return this.resolveEntry(e,n)?.config}resolveEntry(e,n){return S(this.linters,this.availableBuiltIns,this.evidence,e,n)}get entries(){return this.linters}};async function C(t,e){let n;try{let i=x.basename(t.check.command[0]??"").toLocaleLowerCase(),a=i==="ruff"||i==="ruff.exe",d=e.env??process.env;n=await $(t.check,{...e,...a&&!e.processAccess?{env:{...d,RUFF_CACHE_DIR:d.RUFF_CACHE_DIR??x.join(ie.tmpdir(),"pi-agent-ide","ruff-cache")}}:{}})}catch(i){return{ok:!1,diagnostics:[],failure:`command could not start: ${i instanceof Error?i.message:String(i)}`}}let r=t.diagnostics.format==="regex"||t.diagnostics.format==="clang"?[n.stdout,n.stderr].filter(i=>i.trim().length>0).join(`
|
|
4
|
+
`):n.stdout.trim().length>0?n.stdout:n.stderr,o;try{o=V(r,t.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${t.diagnostics.format} diagnostics: ${r.trim().slice(0,200)||"empty command output"}`}}let s=n.ok&&(n.exitCode===0||o.length>0),f=t.check.cwd==="file"?x.dirname(e.filePath):e.projectRoot;return o=o.filter(i=>{if(i.file===void 0)return!0;if(e.acceptsFile)return e.acceptsFile(i.file);let a=i.file.startsWith("file:")?re(i.file):i.file;return M(x.resolve(f,a),e.filePath)}).map(({file:i,...a})=>a),{ok:s,diagnostics:o,...!s&&{failure:n.stderr.trim().slice(0,200)||`command exited with code ${String(n.exitCode)}`}}}l(C,"runConfiguredLinter");function W(t,e=C){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:l(()=>Promise.resolve(!0),"detect"),async lint({filePath:n,fix:r},o){let s=t.resolve(n,o.cwd);if(s===void 0)return{ok:!0,diagnostics:[]};let f=r===!0&&s.fix!==void 0?s.fix:s.check,i=await e({...s,check:f},{projectRoot:o.cwd,filePath:n});return{ok:i.ok,diagnostics:i.diagnostics}}}}l(W,"createCommandLinter");var G={protocol:T,apiVersion:N,id:"lint",setup(t){for(let e of p)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:oe}),t.addCheck({id:"config",title:"Linter",async run(e){try{let n=await g.fromDirectory(e.cwd,v(e)),r=se(n,e.files,e.cwd);return r.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(r.map(async({entry:o,source:s})=>{let f=`${o.id} [${o.layer}] command ${JSON.stringify(o.config.check.command)}`;return z(e,s,async i=>{try{let a=await C(o.config,{projectRoot:e.cwd,filePath:i,env:e.env,signal:e.signal,processAccess:O(e)});return e.signal?.throwIfAborted(),a.ok?{status:"pass",message:`${f}: probe passed`,detail:o.sourcePath}:{status:"fail",message:`${f}: probe failed`,detail:a.failure??o.sourcePath}}catch(a){return e.signal?.throwIfAborted(),{status:"fail",message:`${f}: ${a instanceof Error?a.message:String(a)}`,detail:o.sourcePath}}})}))}catch(n){return e.signal?.throwIfAborted(),[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function oe(t){try{let e=await g.fromDirectory(t.cwd,v(t)),n=[],r=new Map;for(let[o,s]of t.detectedLanguages){let f=s.map(i=>e.resolveEntry(i,t.cwd)).find(i=>i!==void 0);f!==void 0&&(n.push({kind:"linter",languageId:o,toolId:f.id}),await _(t,f.config.check)||r.set(f.id,{id:`linter-${f.id}-unavailable`,message:`Configured linter ${f.id} cannot run ${JSON.stringify(f.config.check.command)}`}))}return{selections:n,actions:[...r.values()]}}catch(e){return t.signal?.throwIfAborted(),{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}l(oe,"inspectLinterSetup");function se(t,e,n){let r=new Map;for(let o of e){let s=t.resolveEntry(o,n);s!==void 0&&!r.has(s.id)&&r.set(s.id,{entry:s,source:o})}return[...r.values()]}l(se,"applicableLinters");async function ae(t){await ce(t)}l(ae,"registerLint");async function ce(t,e){let n=new Map,r=l((i,a=!1)=>{let d=JSON.stringify([i,a]),m=n.get(d);return m===void 0&&(m=e?e.loadRegistry(i,a):fe(i,a),n.set(d,m)),m},"registryFor"),o=l(async(i,a)=>{if(e)return e.resolveProject(i,a);if(i.includes("://")||a.includes("://"))throw Object.assign(new Error("Linter requires its resource owner"),{code:"UNSUPPORTED_SOURCE"});let d=await E(a,i,"linters",p);return d===void 0?void 0:{projectRoot:d,external:d!==le.resolve(a)}},"resolveProject"),s={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:l(async i=>(await r(i.cwd),!0),"detect"),async lint(i,a){let d=await o(i.filePath,a.cwd);if(d===void 0)return{ok:!0,diagnostics:[]};let m=await r(d.projectRoot,d.external);return W(m,e?.run).lint(i,{cwd:d.projectRoot})}},f={protocol:R,apiVersion:5,id:"lint",setup(i){i.addTool(s),i.addDiagnosticSource({id:"lint",async diagnose(a,d){let m=await o(a,d.cwd);if(m===void 0)return{status:"unavailable",diagnostics:[],reason:"No linter project found for this file"};let k=await r(m.projectRoot,m.external);d.signal.throwIfAborted();let y=k.resolve(a,m.projectRoot);if(!y)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let L=P(y.check.command),w=await(e?.run??C)(y,{projectRoot:m.projectRoot,filePath:a,signal:d.signal});return!w.ok&&w.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:w.failure??"Lint check failed",source:L}:{status:"ready",diagnostics:w.diagnostics,source:L}}})}};await Promise.all([j(t,f),F(t,G)])}l(ce,"registerLintWithOwner");async function fe(t,e){let n=e?t:process.env.PI_AGENT_IDE_CONFIG_DIR??t;return g.fromDirectory(n,{includeGlobal:!e,requireBuiltInEvidence:!0})}l(fe,"loadRegistry");export{p as a,g as b,C as c,ae as d,ce as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as O}from"./chunk-E4HPRLRB.js";import{a as R}from"./chunk-IUSLSROY.js";import{a as v,b as S}from"./chunk-7HDK3NRQ.js";import{b as y}from"./chunk-OJX3RJ5A.js";import"./chunk-XZDOVPRC.js";import{a as w,b as E,c as b}from"./chunk-HCN5W76B.js";import"./chunk-7TJ6DWW3.js";import{g as s}from"./chunk-EY65TFHJ.js";import{a as p,b as k,d as C}from"./chunk-6EDOLYOV.js";import{c as g}from"./chunk-W7CASEO3.js";import"./chunk-TOYN4W4F.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-R5XJSEOE.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import{c as u,l as h,m as P}from"./chunk-IMGIDBCC.js";import"./chunk-BXGMMZT3.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import T from"node:path";function A(i){let l=v(i),U=R(i),d=new Map;return{async resolveProject(r,o){if(r.startsWith("ssh://")||o.startsWith("ssh://")){let e=i.resolve(r,o);if(!e)throw new s("UNSUPPORTED_SOURCE",r,"not-applied");let t=i.resolve(o);if(t&&t.location.target!==e.location.target)throw new s("UNSUPPORTED_SOURCE",r,"not-applied");return O(e.backend,e.location.path,t?.location.path,"formatters",p)}if(r.includes("://")||o.includes("://"))throw new s("UNSUPPORTED_SOURCE",r,"not-applied");let n=await u(o,r,"formatters",p);return n===void 0?void 0:{cwd:n,external:n!==T.resolve(o)}},async loadRegistry(r,o){let n=JSON.stringify([r,o]),e=d.get(n);if(!e){let t=i.resolve(r);e=k.fromDirectory(r,{includeGlobal:!o,requireBuiltInEvidence:!0,...t?{layerAccess:l,executableAvailability:c(a=>y(t.backend,t.location.path,a),"executableAvailability"),recipeEvidence:c(a=>S(t.backend,t.location.path,a),"recipeEvidence")}:{}}),d.set(n,e)}return e},async run(r,o,n){let e=i.resolve(n);if(!e){if(n.includes("://")||o.includes("://"))throw new s("UNSUPPORTED_SOURCE",n,"not-applied");return P(r,{projectRoot:o,filePath:n})}let t=await e.backend.read(e.location.path),a=await h(r.run,{projectRoot:o,filePath:n,processAccess:U}),m=await e.backend.read(e.location.path);if(!a.ok)return{ok:!1,changed:!m.bytes.equals(t.bytes)};if(r.output==="stdout"){if(m.version!==t.version)throw new s("CONFLICT",n,"not-applied");let f=Buffer.from(a.stdout);return f.equals(t.bytes)||await e.backend.write(e.location.path,f,t.version),{ok:!0,changed:!f.equals(t.bytes)}}return{ok:!0,changed:!m.bytes.equals(t.bytes)}}}}c(A,"createOwnedFormatterRuntime");async function F(i){let l=new b(await E(w(g())));await C(i,A(l))}c(F,"registerOwnedFormatter");export{A as createOwnedFormatterRuntime,F as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as R}from"./chunk-
|
|
1
|
+
import{d as R}from"./chunk-4OYVLXWD.js";import{a as S}from"./chunk-PS2B6THP.js";import{t as p,u as y}from"./chunk-ZPT5D4VP.js";import{a as c}from"./chunk-EI7MMDWY.js";import{keyText as T}from"@earendil-works/pi-coding-agent";import{Text as $}from"@earendil-works/pi-tui";function x(e){return e.replaceAll("\u27E6","").replaceAll("\u27E7","")}c(x,"sourceText");function w(e,r){let{files:o,...t}=e,s=x(r);return{...t,storedFiles:o.map(({lines:l,...a})=>({...a,lines:l.map(n=>{let i=[n.lineNumber,p(n.text,s),n.ranges];return n.logicalMatchIds===void 0?i:[...i,n.logicalMatchIds]})}))}}c(w,"compactSearchDetails");function g(e,r){if("files"in e)return e;let{storedFiles:o,...t}=e,s=x(r);return{...t,files:o.map(({lines:l,...a})=>({...a,lines:l.map(([n,i,h,u])=>({lineNumber:n,text:y(i,s),ranges:h,matchCount:h.length,...u===void 0?{}:{logicalMatchIds:u}}))}))}}c(g,"restoreSearchDetails");var k=new WeakMap,C=12;function v(e,r,o,t){if(typeof e.details=="object"){let a=k.get(e.details);a===void 0&&(a=g(e.details,e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
|
|
2
2
|
`)),k.set(e.details,a)),e={...e,details:a}}if(r.isPartial||t.isError||!R(e.details)){let a=e.content[0],n=a?.type==="text"?a.text:"",i=t.isError?"error":r.isPartial?"dim":"toolOutput";return new $(o.fg(i,n),0,0)}let l=(t.lastComponent instanceof m?t.lastComponent:void 0)??new m(e.details,o,r.expanded);return l.updateSearch(e.details,o,r.expanded),l}c(v,"renderSearchResult");var m=class extends S{static{c(this,"SearchResultPanel")}constructor(r,o,t){super(z(r,t),o,t)}updateSearch(r,o,t){super.update(z(r,t),o,t)}};function z(e,r){let o=D(e,r).map(t=>t.kind==="file"?{kind:"source",label:t.file.path,link:t.file.link,count:t.file.matchCount}:t.kind==="line"?{kind:"line",...t.line}:t.kind==="candidate"?{kind:"note",text:t.identifier}:t.kind==="summary"?{kind:"note",text:t.text}:t.kind==="omitted"?{kind:"note",text:`\u2026 ${t.matches} more ${d(t.matches,"match","matches")} \xB7 ${T("app.tools.expand")} to expand`}:{kind:"note",text:"No matches found"});return{summary:P(e),rows:o}}c(z,"searchModel");function D(e,r){let o=e.fuzzy?.status==="ready"&&e.fuzzy.candidates.length>0,t=e.files.length===0?o?[]:[{kind:"empty"}]:e.files.flatMap(n=>[{kind:"file",file:n},...n.uniqueLineCount===void 0?n.lines.map(i=>({kind:"line",file:n,line:i})):[{kind:"summary",text:`${String(n.uniqueLineCount)} unique line texts \xB7 search this path with a narrower query`},...(n.groups??[]).map(i=>({kind:"summary",text:`\xD7${String(i.matchCount)} ${i.text}`}))]]);if(e.fuzzy!==void 0&&(e.fuzzy.status==="skipped"?t.push({kind:"summary",text:"Fuzzy search unavailable"}):e.fuzzy.candidates.length>0&&t.push(...e.fuzzy.candidates.flatMap(n=>{let i=e.fuzzyPresentation?.groups.find(u=>u.identifier===n.identifier)?.files??[],h=i.reduce((u,f)=>u+f.matchCount,0);return[{kind:"candidate",identifier:n.identifier},...i.length===0?[]:[{kind:"summary",text:`Shown ${String(h)} of ${String(n.matchCount)}${n.selection.complete?"":"+"}`},...i.flatMap(u=>[{kind:"file",file:u},...u.lines.map(f=>({kind:"line",file:u,line:f}))])]]}))),(e.omittedFileCount??0)>0&&t.push({kind:"summary",text:`\u2026 ${e.omittedFileCount} more files (${e.omittedMatchCount} matches) \xB7 narrow path, include, or query`}),e.fuzzy!==void 0||r||t.length<=C)return t;let s=t.slice(0,C-1);for(;s.at(-1)?.kind==="file";)s.pop();let l=new Set(s.flatMap(n=>n.kind==="line"?n.line.logicalMatchIds??[]:[])),a=l.size>0?l.size:s.reduce((n,i)=>n+(i.kind==="line"?i.line.matchCount:0),0);return[...s,{kind:"omitted",matches:Math.max(0,e.matchCount-a)}]}c(D,"searchViewport");function P(e){if(e.matchCount===0&&e.fuzzy?.status==="ready"&&e.fuzzy.candidates.length>0&&e.fuzzyPresentation!==void 0){let o=e.fuzzy.candidates.reduce((l,a)=>l+a.matchCount,0),t=e.fuzzy.candidates.every(l=>l.selection.complete)?"":"+",s=e.fuzzyPresentation.fileCount;return`0 exact \xB7 ${String(o)}${t} fuzzy ${d(o,"match","matches")} \xB7 ${String(s)}${t} ${d(s,"file","files")}`}return e.matchCount===0?e.complete?"No matches":"No matches \xB7 incomplete":`${`${String(e.matchCount)}${e.complete?"":"+"}`} ${d(e.matchCount,"match","matches")} in ${String(e.fileCount)} ${d(e.fileCount,"file","files")}`}c(P,"searchSummary");function d(e,r,o){return e===1?r:o}c(d,"plural");export{w as a,v as b,m as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c,d,e as u}from"./chunk-
|
|
1
|
+
import{c,d,e as u}from"./chunk-RAZP42IQ.js";import{a as r}from"./chunk-EI7MMDWY.js";function E(t,o){let s=r(()=>{let e,i={plugin:o,accept(g){if(e!==void 0)throw new Error(`Plugin ${o.id} registration was accepted more than once`);e=g}};return t.events.emit(d,i),e},"announce"),n=r(()=>{},"unsubscribe");n=t.events.on(c,e=>{if(!u(e))throw new Error("Invalid pi-agent-search core readiness event");let i=s();if(i===void 0)throw new Error("pi-agent-search core announced readiness without accepting the plugin");n(),i.catch(()=>{})}),t.on("session_shutdown",n);let a=s();if(a!==void 0)return n(),a}r(E,"connectSearchPlugin");export{E as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as I}from"./chunk-SBLKPTL3.js";import{g as r}from"./chunk-EY65TFHJ.js";import{a as l}from"./chunk-EI7MMDWY.js";import{readFile as S}from"node:fs/promises";async function m(h,t,o){o?.throwIfAborted(),w??=S(new URL("./vision-capture-worker.py",new URL("../src/backend/vision-capture.ts",import.meta.url).href),"utf8");let s=await I(h,"python3",["-c",await w,JSON.stringify({kind:"probe"})],t,{signal:o,timeoutMs:5e3,maxBytes:128*1024});if(o?.throwIfAborted(),s.exitCode!==0)throw new r("CAPABILITY_UNAVAILABLE",t,"not-applied");let e;try{e=JSON.parse(s.stdout.toString("utf8"))}catch{throw new r("INVALID_RESPONSE",t,"not-applied")}if(typeof e!="object"||e===null)throw new r("INVALID_RESPONSE",t,"not-applied");if("display"in e&&e.display===!0&&"window"in e&&typeof e.window=="boolean"&&(e.window||"error"in e&&e.error==="CAPABILITY_UNAVAILABLE"))return{display:{ok:!0,detail:"Target X11 connection opened without pixels; capture opt-in unchanged"},window:{ok:e.window,detail:e.window?"Target X-Resource 1.2 is available; individual window authorization is not checked":`CAPABILITY_UNAVAILABLE: ${t} (trusted X11 client identity unavailable)`}};let n="error"in e&&typeof e.error=="string"&&y.has(e.error)?e.error:"INVALID_RESPONSE";throw new r(n,t,"not-applied")}l(m,"probeSshCapture");var w,E=Buffer.from([137,80,78,71,13,10,26,10]),y=new Set(["DESKTOP_UNAVAILABLE","CAPABILITY_UNAVAILABLE","ENOENT","EACCES","STALE_PROCESS","AMBIGUOUS_WINDOW","WINDOW_OBSCURED","CONTENT_LIMIT","PIXEL_LIMIT","BYTE_LIMIT"]);async function g(h,t,o,s){s?.throwIfAborted();let e=o.kind==="window"?"window:":"display:";if(!t.startsWith(`${e}ssh://`))throw new r("INVALID_SOURCE",t,"not-applied");let n=new URL(t.slice(e.length)),p=o.kind==="window"?o.pid:o.index;if(n.username||n.password||n.port||n.search||!Number.isSafeInteger(p)||(o.kind==="window"?p<1||n.pathname!==`/${p}`||n.hash!=="":p<0||n.pathname!=="/"||n.hash!==`#${p}`&&!(p===0&&n.hash==="")))throw new r("INVALID_SOURCE",t,"not-applied");try{let a=h.resolve(`ssh://${n.hostname}/`);if(!a)throw new r("UNSUPPORTED_SOURCE",t,"not-applied");w??=S(new URL("./vision-capture-worker.py",new URL("../src/backend/vision-capture.ts",import.meta.url).href),"utf8");let i=await I(a.backend.target,"python3",["-c",await w,JSON.stringify(o)],t,{signal:s,timeoutMs:1e4,maxBytes:20*1024*1024});if(s?.throwIfAborted(),i.exitCode!==0)throw new r("CAPABILITY_UNAVAILABLE",t,"not-applied");if(i.stdout.subarray(0,8).equals(E)){if(i.stdout.length<33||i.stdout.length>20*1024*1024||i.stdout.toString("ascii",12,16)!=="IHDR")throw new r("INVALID_RESPONSE",t,"not-applied");let A=i.stdout.readUInt32BE(16),f=i.stdout.readUInt32BE(20);if(A<1||f<1||A*f>16*1024*1024)throw new r("PIXEL_LIMIT",t,"not-applied");return i.stdout}let d;try{d=JSON.parse(i.stdout.toString("utf8"))}catch{throw new r("INVALID_RESPONSE",t,"not-applied")}let c=typeof d=="object"&&d!==null&&"error"in d&&typeof d.error=="string"&&y.has(d.error)?d.error:"INVALID_RESPONSE";throw new r(c,t,"not-applied")}catch(a){throw a instanceof r?new r(a.code,t,a.effect):a}}l(g,"captureSshFrame");export{m as a,g as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as n}from"./chunk-TWWND6NI.js";import"./chunk-SBLKPTL3.js";import"./chunk-XZDOVPRC.js";import{a as o,b as t,c as i}from"./chunk-HCN5W76B.js";import"./chunk-7TJ6DWW3.js";import"./chunk-EY65TFHJ.js";import{b as s}from"./chunk-Z3PGADVA.js";import"./chunk-VDP5CQHM.js";import{c as r}from"./chunk-W7CASEO3.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-NNCZYO4Q.js";import"./chunk-IICJXZBU.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-N7LMRL64.js";import"./chunk-RAZP42IQ.js";import"./chunk-BIG45IPN.js";import"./chunk-SSWUUBIR.js";import"./chunk-PS2B6THP.js";import"./chunk-R5XJSEOE.js";import"./chunk-ZPT5D4VP.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import{a as e}from"./chunk-EI7MMDWY.js";async function g(a){let m=new i(await t(o(r())));await s(a,f=>n(f,m))}e(g,"registerOwnedWeb");export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./chunk-EI7MMDWY.js";var t="pi-agent-ide",r=5,a="pi-agent-ide/core/ready",s="pi-agent-ide/plugin/register";function d(e){return n(e)&&e.protocol===t&&e.apiVersion===5}o(d,"isIdeCoreReady");function i(e){return n(e)&&e.protocol===t&&e.apiVersion===5&&typeof e.id=="string"&&e.id.length>0&&typeof e.setup=="function"}o(i,"isIdePlugin");function c(e){return n(e)&&i(e.plugin)&&typeof e.accept=="function"}o(c,"isIdePluginRegistrationRequest");function n(e){return typeof e=="object"&&e!==null}o(n,"isUnknownRecord");export{t as a,r as b,a as c,s as d,d as e,i as f,c as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as d}from"./chunk-EY65TFHJ.js";import{a as p}from"./chunk-EI7MMDWY.js";import l from"node:path";async function y(e,o,t={},r){r?.throwIfAborted();for(let n of Object.keys(t))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(n))throw new TypeError("Invalid remote process environment key");let i=await e.execute("python3",["-c",'import os; print(os.environ.get("PATH", os.defpath), end="")'],o,{signal:r});if(i.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",e.target.id,"not-applied");return{...t,PATH:[...["node_modules/.bin",".venv/bin","venv/bin","vendor/bin"].map(n=>l.posix.join(o,n)),t.PATH??i.stdout].join(":")}}p(y,"sshProjectEnvironment");async function v(e,o,t,r){r?.throwIfAborted();let i=t.map(s=>{for(let h of Object.keys(s.env??{}))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(h))throw new TypeError("Invalid remote process environment key");return{command:s.command[0]?.replaceAll("{project}",o)??"",path:s.env?.PATH}}),n=await e.execute("python3",["-c","import json,os,shutil,sys; candidates=json.loads(sys.argv[1]); root=sys.argv[2]; prefixes=[os.path.join(root,p) for p in ['node_modules/.bin','.venv/bin','venv/bin','vendor/bin']]; print(json.dumps([bool(shutil.which(c['command'],path=os.pathsep.join(prefixes+[c.get('path',os.environ.get('PATH',os.defpath))]))) for c in candidates]))",JSON.stringify(i),o],o,{signal:r});if(n.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",e.target.id,"not-applied");let a=JSON.parse(n.stdout.toString("utf8"));if(!Array.isArray(a)||a.length!==t.length||a.some(s=>typeof s!="boolean"))throw new d("INVALID_RESPONSE",e.target.id,"not-applied");return a}p(v,"sshProjectExecutableAvailability");export{y as a,v as b};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import{a as we,b as ye,c as Se}from"./chunk-ESPNEJHK.js";import{a as he}from"./chunk-L2B4DTVS.js";import{a as fe,b as ge,c as L}from"./chunk-HCN5W76B.js";import"./chunk-EY65TFHJ.js";import{c as pe}from"./chunk-W7CASEO3.js";import"./chunk-QUYXINGZ.js";import{a as M}from"./chunk-GW6NZQTQ.js";import{e as ee,f as te}from"./chunk-T7I2VX3J.js";import{a as ae}from"./chunk-2K65BSXS.js";import{c as oe,d as se}from"./chunk-ICDI27GZ.js";import{b as A}from"./chunk-IICJXZBU.js";import{a as ie}from"./chunk-BU7IZLKB.js";import{a as ne,b as re}from"./chunk-S5PL5DFQ.js";import{a as ce}from"./chunk-N7LMRL64.js";import{a as le,b as ue}from"./chunk-RAZP42IQ.js";import{a as de}from"./chunk-BIG45IPN.js";import{e as me}from"./chunk-SSWUUBIR.js";import"./chunk-PS2B6THP.js";import{i as G,j as I}from"./chunk-R5XJSEOE.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import st from"node:path";import{stripVTControlCharacters as at}from"node:util";import{truncateLine as lt}from"@earendil-works/pi-coding-agent";import{Text as P}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as Te,DEFAULT_MAX_LINES as be,formatSize as it,truncateTail as ot}from"@earendil-works/pi-coding-agent";function k(t){return ot(t,{maxBytes:Te-4096,maxLines:be-32})}a(k,"terminalOutputTail");function _(t){let e=k(t.output),n=[`session: ${t.source}`,`status: ${t.status}`,`shell: ${t.shell}`,`cwd: ${t.cwd}`,`elapsedMs: ${t.elapsedMs}`,t.exitCode===void 0?void 0:`exitCode: ${t.exitCode}`,t.signal===void 0?void 0:`signal: ${t.signal}`,t.error===void 0?void 0:`error: ${t.error}`,t.waitReason===void 0?void 0:`reason: ${t.waitReason}`,t.completionReason===void 0?void 0:`completionReason: ${t.completionReason}`,t.status==="running"&&t.background?`next: Continue independent work or finish your turn; completion or a one-time idle inspection notice will wake the agent. Read ${t.source} to inspect output; use write or insert when input is needed.`:void 0,`outputRange: ${t.outputStart}-${t.outputEnd}`,t.truncated?"retainedOutput: earlier data omitted from memory":void 0,e.truncated?`fullOutput: ${t.fullOutputPath}`:void 0].filter(s=>s!==void 0),r=e.content.trimEnd();if(!e.truncated)return`${n.join(`
|
|
2
|
+
`)}
|
|
3
|
+
output:${r.length===0?" (empty)":`
|
|
4
|
+
${r}`}`;let i=e.truncatedBy==="lines"?`${be} line output budget`:`${it(Te)} output budget`,l=`[Earlier output omitted: showing the last ${e.outputLines} of ${e.totalLines} lines (${i}). Full output: ${t.fullOutputPath}]`;return`${n.join(`
|
|
5
|
+
`)}
|
|
6
|
+
output:
|
|
7
|
+
${l}${r.length===0?"":`
|
|
8
|
+
${r}`}`}a(_,"formatAgentTerminalSnapshot");var ut=500;function ve(t,e,n,r,i){let l=e?"background":"wait",s=`${i.fg("toolTitle",r.displayName.toLocaleLowerCase())} ${i.fg("muted",`\xB7 ${O(n)} \xB7 ${l}`)}`;return new P(`${s}
|
|
9
|
+
${i.fg("accent",V(r.family))} ${t}`,0,0)}a(ve,"renderRunCall");function Re(t,e,n){let r=e.map(i=>` ${n.fg("dim",i)}`);return r.push(n.fg("success",t==="delete"?"\u2713 stopped":"\u2713 sent")),new P(r.join(`
|
|
10
|
+
`),0,0)}a(Re,"renderTerminalActionResult");function Pe(t,e,n,r,i){let l=[mt(t,i),i.fg("accent",`${e} ${n}`)];return r.length>0&&l.push(...r.map(s=>` ${i.fg("dim",s)}`)),new P(l.join(`
|
|
11
|
+
`),0,0)}a(Pe,"renderTerminalAction");function x(t,e,n,r){let i=Ae(t,A,n);return r!==void 0&&i.splice(1,1,n.fg("accent",r)),new P(i.join(`
|
|
12
|
+
`),0,0)}a(x,"renderTerminalResult");function xe(t,e,n){if(e===!0?e="full":e===!1&&(e="compact"),e==="disabled"){if(!(t.status!==void 0&&!["running","completed"].includes(t.status)||t.exitCode!==void 0&&t.exitCode!==0||t.error!==void 0))return new P($(t,(c,u)=>n.fg(c,u)),0,0);let s=D(t.output??"",A),o=[...s.omission===void 0?[]:[` ${n.fg("muted",s.omission)}`],...s.lines.map(c=>` ${n.fg("dim",c)}`),...t.error===void 0?[]:[` ${n.fg("error",t.error)}`],$(t,(c,u)=>n.fg(c,u))];return new P(o.join(`
|
|
13
|
+
`),0,0)}if(e==="full"){let l=Ae(t,Number.POSITIVE_INFINITY,n).slice(2);return new P(l.join(`
|
|
14
|
+
`),0,0)}let r=D(t.output??"",A),i=[...r.omission===void 0?[]:[` ${n.fg("muted",r.omission)}`],...r.lines.map(l=>` ${n.fg("dim",l)}`)];return i.push($(t,(l,s)=>n.fg(l,s))),new P(i.join(`
|
|
15
|
+
`),0,0)}a(xe,"renderRunResult");function Ee(t,e){let n=a((s,o)=>e?.fg(s,o)??o,"color"),i=[`${n("accent",t.shell.toLocaleLowerCase())} ${n("muted",`\xB7 ${O(t.cwd)} \xB7 ${t.background?"background":"wait"}`)}`,`${n("accent",V(t.shellFamily))} ${q(t.command,84)}`],l=ct(t.output,2);return l.length>0&&i.push(...l.map(s=>` ${n("dim",q(s,90))}`)),i.push($(t,n)),i.join(`
|
|
16
|
+
`)}a(Ee,"renderActiveTerminal");function Ae(t,e,n){let r=(t.shell??"terminal").toLocaleLowerCase(),i=t.background===!0?"background":"wait",l=t.cwd===void 0?"workspace":O(t.cwd),s=t.shellFamily??"posix",o=[`${n.fg("accent",r)} ${n.fg("muted",`\xB7 ${l} \xB7 ${i}`)}`,`${n.fg("accent",V(s))} ${t.command??""}`],c=D(t.output??"",e);return c.omission!==void 0&&o.push(` ${n.fg("muted",c.omission)}`),c.lines.length>0&&o.push(...c.lines.map(u=>` ${n.fg("dim",u)}`)),o.push($(t,(u,d)=>n.fg(u,d))),o}a(Ae,"terminalCardLines");function ct(t,e){return D(t,e).lines}a(ct,"outputTail");function D(t,e){let n=k(at(t).replaceAll("\r","")),r=n.content.split(`
|
|
17
|
+
`).map(c=>lt(c.trimEnd(),ut).text);r.at(-1)===""&&r.pop();let i=Number.isFinite(e)?Math.max(0,e):r.length,l=Math.max(0,r.length-i),s=Math.max(0,n.totalLines-n.outputLines),o=l+s;return{lines:r.slice(l),...n.truncated||o>0?{omission:o>0?`\u2026 ${o} earlier lines`:"\u2026 earlier output omitted"}:{}}}a(D,"outputWindow");function $(t,e){let n=t.status??"running",r=dt(n),i=n==="completed"?"success":n==="running"?"accent":"error",l=[`${r} ${n}`,pt(t.elapsedMs??0)];return t.waitReason!==void 0&&l.push(`background \xB7 ${t.waitReason}`),t.completionReason!==void 0&&l.push(`reason ${t.completionReason}`),t.exitCode!==void 0?l.push(`exit ${t.exitCode}`):t.signal!==void 0&&l.push(`signal ${t.signal}`),e(i,l.join(" \xB7 "))}a($,"statusLine");function dt(t){return t==="completed"?"\u2713":t==="running"?"\u25CF":t==="stopping"?"\u25CC":"\u2717"}a(dt,"statusIcon");function V(t){return t==="powershell"?"PS>":t==="cmd"?">":"$"}a(V,"promptMarker");function mt(t,e){let n=(t.shell??"terminal").toLocaleLowerCase(),r=t.cwd===void 0?"workspace":O(t.cwd),i=t.background===!0?"background":"wait",l=q(t.command??"process",48);return`${e.fg("toolTitle",n)} ${e.fg("muted",`\xB7 ${r} \xB7 ${i} \xB7 ${l}`)}`}a(mt,"terminalIdentity");function O(t){let e=process.env.HOME;return e!==void 0&&(t===e||t.startsWith(`${e}${st.sep}`))?`~${t.slice(e.length)}`:t}a(O,"shortCwd");function q(t,e){let n=t.replaceAll(/\s+/gu," ").trim();return n.length<=e?n:`${n.slice(0,e-1)}\u2026`}a(q,"oneLine");function pt(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}a(pt,"formatElapsed");function ke(t){return{id:"terminal",onDidChange:a(e=>t.onDidChange(e),"onDidChange"),list:a(()=>t.list().filter(e=>e.status==="running"||e.status==="stopping").map(e=>({source:e.source,kind:"terminal",title:e.shell.toLocaleLowerCase(),description:e.command,status:e.status==="stopping"?"stopping":"running",...e.pid===void 0?{}:{pid:e.pid,owned:!0},...e.remote===void 0?{}:{remote:e.remote,owned:!0},renderSummary:a(n=>Ee(e,n).split(`
|
|
18
|
+
`),"renderSummary"),renderDetail:a(n=>x(e,!0,n),"renderDetail"),sendInput:a(n=>{Promise.resolve(t.write(e.source,n)).catch(()=>{})},"sendInput"),stop:a(()=>t.delete(e.source),"stop")})),"list")}}a(ke,"terminalProcessProvider");import{setTimeout as yt}from"node:timers/promises";var ft="#d8dee9",Y="#111418",gt=["#000000","#cd0000","#00cd00","#cdcd00","#0000ee","#cd00cd","#00cdcd","#e5e5e5","#7f7f7f","#ff0000","#00ff00","#ffff00","#5c5cff","#ff00ff","#00ffff","#ffffff"];async function X(t,e,n,r=1){let i=t.get(e);if(i===void 0)throw new Error(`Unknown terminal session ${e}`);await i.screenReady;let{createCanvas:l}=await import("@napi-rs/canvas"),s=Math.max(0,Math.min(i.rows-1,n?.start??0)),o=Math.max(1,Math.min(i.rows-s,n?.count??i.rows)),c=i.cols*9+24,u=o*18+24,d=l(Math.max(1,Math.round(c*r)),Math.max(1,Math.round(u*r))),m=d.getContext("2d");m.scale(r,r),m.fillStyle=Y,m.fillRect(0,0,d.width,d.height),m.textBaseline="top";let p=i.screen.buffer.active,g=Math.max(0,p.baseY);for(let h=0;h<o;h+=1){let S=p.getLine(g+s+h);if(S!==void 0)for(let w=0;w<i.cols;w+=1){let T=S.getCell(w);T===void 0||T.getWidth()===0||ht(m,T,w,h)}}return i.status==="running"&&p.cursorY>=s&&p.cursorY<s+o&&(m.fillStyle="rgba(216, 222, 233, 0.75)",m.fillRect(12+p.cursorX*9,12+(p.cursorY-s)*18+18-2,9,2)),d.toBuffer("image/png").toString("base64")}a(X,"renderTerminalScreen");function ht(t,e,n,r){let i=$e(e,"foreground"),l=$e(e,"background");e.isInverse()&&([i,l]=[l,i]);let s=12+n*9,o=12+r*18;l!==Y&&(t.fillStyle=l,t.fillRect(s,o,9*Math.max(1,e.getWidth()),18));let c=e.getChars();c.length!==0&&(t.font=`${e.isBold()?"bold ":""}14px monospace`,t.fillStyle=i,t.fillText(c,s,o),e.isUnderline()&&t.fillRect(s,o+18-2,9*Math.max(1,e.getWidth()),1))}a(ht,"drawCell");function $e(t,e){let n=e==="foreground";if(n?t.isFgDefault():t.isBgDefault())return n?ft:Y;let i=n?t.isFgRGB():t.isBgRGB(),l=n?t.getFgColor():t.getBgColor();return i?`#${l.toString(16).padStart(6,"0")}`:wt(l)}a($e,"cellColor");function wt(t){let e=gt[t];if(e!==void 0)return e;if(t>=232){let o=8+(t-232)*10;return Ce(o,o,o)}let n=Math.max(0,t-16),r=Math.floor(n/36),i=Math.floor(n%36/6),l=n%6,s=a(o=>o===0?0:55+o*40,"channel");return Ce(s(r),s(i),s(l))}a(wt,"ansiColor");function Ce(t,e,n){return`#${[t,e,n].map(r=>r.toString(16).padStart(2,"0")).join("")}`}a(Ce,"rgb");var z="\0pi-terminal-write\0",Z="\0pi-terminal-keys\0";function St(t){let e=t?.find(c=>c==="image"||c==="sequence"||c.startsWith("image:")||c.startsWith("sequence:"));if(e===void 0)return;let n=e.indexOf(":"),r=n<0?e:e.slice(0,n),i=new Map;if(n>=0)for(let c of e.slice(n+1).split(",")){let[u,d,m]=c.split("=");if(u===void 0||d===void 0||m!==void 0||d.length===0)throw new Error(`Invalid terminal ${r} view parameter: ${c}`);if(u!=="duration"&&u!=="interval"&&u!=="scale")throw new Error(`Unsupported terminal ${r} view parameter: ${u}`);let p=Number(d);if(!Number.isFinite(p))throw new Error(`Terminal ${u} must be a number`);i.set(u,p)}let l=i.get("duration")??2,s=i.get("interval")??.5,o=i.get("scale")??1;if(!(o>0&&o<=1))throw new Error("Terminal image scale must be greater than 0 and at most 1");if(r==="sequence"){if(!(l>0&&l<=10))throw new Error("Terminal sequence duration must be greater than 0 and at most 10 seconds");if(!(s>0))throw new Error("Terminal sequence interval must be greater than 0 seconds");if(Math.floor(l/s)+1>20)throw new Error("Terminal sequence capture is limited to 20 frames")}return{mode:r,duration:l,interval:s,scale:o}}a(St,"parseTerminalVisualView");async function _e(t,e){let n=new Map,r=new Map,i={protocol:ne,apiVersion:re,id:"terminal",setup(s){s.addResolver({resolver:Tt(e),preserveTruncatedOutput:!0,renderResult(o,c,u){let d=o.details,m=d.source===void 0?void 0:e.get(d.source),p=m===void 0?{}:e.snapshot(m);return x(m===void 0?p:{...p,output:e.screenTail(m).join(`
|
|
19
|
+
`)},c.expanded,u,"read terminal")}}),s.addHandler({stage:"pre-read",async handler(o){let c=o.request.path;if(c===void 0||!v(c))return{kind:"continue",context:o};let u;try{u=St(o.request.views)}catch(m){return{kind:"return",result:K(c,m instanceof Error?m.message:String(m))}}if(u===void 0)return{kind:"continue",context:o};let d=e.get(c);if(d===void 0)return{kind:"return",result:K(c,`Unknown terminal session ${c}`)};try{e.markInspected(c);let m=u.mode==="image"?1:Math.floor(u.duration/u.interval)+1,p=[];for(let g=0;g<m;g+=1){o.resolverContext.signal?.throwIfAborted(),g>0&&await yt(u.interval*1e3,void 0,{signal:o.resolverContext.signal});let h=await X(e,c,void 0,u.scale);p.push({type:"image",data:h,mimeType:"image/png"})}return{kind:"return",result:{content:p,script:{kind:"native",source:d.source,blocks:p},details:{source:d.source,resolvedBy:"terminal",frames:m,mode:u.mode}}}}catch(m){return{kind:"return",result:K(c,m instanceof Error?m.message:String(m))}}}}),s.describe({path:"shell:<session> \u2014 terminal status and a bounded output tail with a full-log path when truncated.",views:"On shell:<session>, image[:scale=S] returns the virtual terminal screen; sequence[:duration=D,interval=I,scale=S] returns ordered PNG frames. Defaults: D=2 seconds, I=0.5 seconds, S=1. Scale satisfies 0 < S <= 1; sequences require 0 < D <= 10, I > 0, and at most 20 frames (floor(D/I)+1). Terminal captures do not support region or image grid selection; offset/limit do not crop their frames."})}},l={protocol:oe,apiVersion:se,id:"terminal",setup(s){s.addResolver({resolver:bt(e)}),s.tool("write").addHandler({stage:"text-pre-edit",handler:a(async o=>(Le(o.input,e,n),await Ie(o.input,e,r),vt(o,z)),"handler")}),s.tool("insert").addHandler({stage:"text-pre-edit",handler:a(async o=>(await Ie(o.input,e,r),Le(o.input,e,n),Rt(o)),"handler")});for(let o of["write","insert","delete"])s.addToolRenderer({tool:o,matches:a((c,u)=>At(c,u),"matches"),renderCall(c,u,d){let m=c,p=typeof m.path=="string"?e.get(m.path):void 0,g=d.state;return p!==void 0&&(g.snapshot=e.snapshot(p)),Pe(g.snapshot??{},o,Me(o,m),[],u)},renderResult(c,u,d){let m=Et(c.details);return Re(m.action,m.changedLines,d)}});s.describe("For shell:<session> resources, write sends exact terminal input, insert sends named keys at end, and delete terminates and removes the session. replace is unsupported."),s.tool("write").describe("When path is shell:<session>, send content exactly as terminal input without adding Enter."),s.tool("insert").describe("When path is shell:<session>, omit anchor or use end, keep before false, and put whitespace- or comma-separated named keys and chords such as Enter, Ctrl+C, Ctrl+Left, Ctrl+Shift+Left, Up, or Backspace in text. Use Unix caret forms such as ^C and ^U for control characters.")}};await Promise.all([ie(t,i),ae(t,l)]),t.on("tool_result",async(s,o)=>{if(!R(s.input))return;let c=s.input.path;if(s.toolName==="replace"&&typeof c=="string"&&v(c)){let y=`replace is unsupported for ${c}; use write for text, insert for keys, or delete to terminate and remove the session.`;return I({content:[{type:"text",text:y}],details:s.details},M(s.toolName),{status:"error",errors:[G(y,"UNSUPPORTED_OPERATION",c)],data:{operation:"replace",effect:"not-applied",files:[{source:c,effect:"not-applied"}]}})}if(s.toolName==="delete"&&typeof c=="string"&&v(c)){let y=e.get(c);if(y===void 0)return;let rt=e.snapshot(y);return e.delete(c).then(()=>I({content:[{type:"text",text:`Deleted terminal session ${c}.`}],details:{source:c,deleted:!0,snapshot:rt,action:"delete",input:"session",changedLines:[]}},M(s.toolName),{status:"success",errors:[],data:{operation:"delete",effect:"applied",files:[{source:c,effect:"applied"}]}}),C=>I({content:[{type:"text",text:C instanceof Error?C.message:String(C)}],details:{source:c,deleted:!1}},M(s.toolName),{status:"error",errors:[G(C,"TERMINAL_DELETE_FAILED",c)],data:{operation:"delete",effect:"unknown",files:[{source:c,effect:"unknown"}]}}))}if(s.toolName!=="write"&&s.toolName!=="insert"||s.isError)return;let u=s.input.path;if(typeof u!="string"||!v(u))return;let d=e.get(u);if(d===void 0)return;let m=r.get(u)??e.screenRows(d);r.delete(u);let p=n.get(u)??d.outputStart+d.output.length;n.delete(u),await e.waitForOutputAfter(d,p);let g=e.snapshot(d),h=s.toolName,S=Me(h,s.input),w=e.screenChangeRegion(d,m,6),T=[{type:"text",text:`Sent ${S} to ${d.source}.`}];return o.model?.input.includes("image")===!0&&T.push({type:"image",data:await X(e,u,{start:w.startRow,count:w.lines.length}),mimeType:"image/png"}),{content:T,details:{source:d.source,action:h,status:d.status,snapshot:g,input:S,changedLines:w.lines},isError:s.isError,...s.structuredContent===void 0?{}:{structuredContent:s.structuredContent}}})}a(_e,"registerTerminalResources");function Tt(t){return{id:"terminal",async tryResolve(e){if(!v(e))return{kind:"not-handled"};let n=t.get(e);return n===void 0?{kind:"failed",error:new Error(`Unknown terminal session ${e}`)}:{kind:"resolved",resource:{source:n.source,async read(){t.markInspected(n.source);let r=t.snapshot(n);return[{type:"text",text:Pt(r)}]}}}}}}a(Tt,"createReadResolver");function bt(t){return{id:"terminal-input",async tryResolve(e){if(!v(e))return{kind:"not-handled"};let n=t.get(e);return n===void 0?{kind:"failed",error:new Error(`Unknown terminal session ${e}`)}:{kind:"resolved",resource:{source:n.source,skipPostEdit:!0,async read(){return[{type:"text",text:"terminal input"}]},async write(r){let i=xt(r),l=i.indexOf(z),s=i.indexOf(Z);if(l>=0){await t.write(n.source,i.slice(l+z.length));return}if(s>=0){await t.sendKeys(n.source,i.slice(s+Z.length).trim());return}throw new Error(`Unsupported text operation for ${n.source}`)}}}}}}a(bt,"createInputResolver");function vt(t,e){return!R(t.input)||!De(t.input.path)?t:{...t,input:{...t.input,content:`${e}${typeof t.input.content=="string"?t.input.content:""}`}}}a(vt,"transformWriteInput");function Rt(t){if(!R(t.input)||!De(t.input.path))return t;if(t.input.before===!0)throw new Error("Shell keys can only be inserted after the active input position");return{...t,input:{...t.input,anchor:"end",before:!1,text:`${Z}${typeof t.input.text=="string"?t.input.text:""}`}}}a(Rt,"transformInsertInput");function Pt(t){return _(t)}a(Pt,"formatSnapshot");function xt(t){if(t.length!==1||t[0].type!=="text")throw new Error("Terminal input must contain one text block");return t[0].text}a(xt,"singleText");function K(t,e){return{content:[{type:"text",text:e}],details:{source:t,failure:{code:"READ_FAILED",source:t,resolverId:"terminal",message:e}},isError:!0}}a(K,"failure");function v(t){return/^shell:[a-f\d]{12}$/u.test(t)}a(v,"isShellSource");function De(t){return typeof t=="string"&&v(t)}a(De,"isShellSourceValue");function Et(t){if(!R(t)||!R(t.snapshot))throw new TypeError("Invalid terminal action result");let e=t.snapshot,n=t.action;if(n!=="write"&&n!=="insert"&&n!=="delete")throw new TypeError("Invalid terminal action");return{source:typeof t.source=="string"?t.source:"shell:unknown",action:n,input:typeof t.input=="string"?t.input:"",changedLines:Array.isArray(t.changedLines)?t.changedLines.filter(r=>typeof r=="string"):[],snapshot:{...typeof e.shell=="string"?{shell:e.shell}:{},...typeof e.cwd=="string"?{cwd:e.cwd}:{},...typeof e.command=="string"?{command:e.command}:{},...typeof e.background=="boolean"?{background:e.background}:{},...typeof e.status=="string"?{status:e.status}:{}}}}a(Et,"terminalActionDetails");async function Ie(t,e,n){if(!R(t)||typeof t.path!="string"||!v(t.path))return;let r=e.get(t.path);r!==void 0&&await r.screenReady,r!==void 0&&n.set(t.path,e.screenRows(r))}a(Ie,"rememberScreen");function Le(t,e,n){if(!R(t)||typeof t.path!="string"||!v(t.path))return;let r=e.get(t.path);r!==void 0&&n.set(t.path,r.outputStart+r.output.length)}a(Le,"rememberOutputEnd");function Me(t,e){if(t==="delete")return"session";let n=t==="write"?e.content:e.text,r=typeof n=="string"?n:"";return t==="write"?`text ${JSON.stringify(r)}`:`keys ${r}`}a(Me,"terminalInputLabel");function At(t,e){if(!R(t))return!1;if(e==="call")return typeof t.path=="string"&&v(t.path);let n=t.details;return R(n)&&typeof n.source=="string"&&v(n.source)}a(At,"isTerminalRenderValue");function R(t){return typeof t=="object"&&t!==null}a(R,"isRecord");async function Oe(t,e){await ce(t,{protocol:le,apiVersion:ue,id:"terminal",setup(r){r.addResolver({resolver:kt(e),priority:100}),r.describe("path shell:<session> searches the retained text output of that terminal, including rows outside its current screen.")}})}a(Oe,"registerTerminalSearch");function kt(t){return{readResources:a(e=>e.path?.startsWith("shell:")?[e.path]:[],"readResources"),id:"terminal",toScriptData(e){let n=N(e);return me(n.matches,!1)},async tryResolve(e){if(e.path===void 0||!e.path.startsWith("shell:"))return{kind:"not-handled"};let n=t.get(e.path);if(n===void 0)return{kind:"failed",error:new Error(`Unknown terminal session ${e.path}`)};let r=t.snapshot(n),i=$t(r,e);return{kind:"resolved",payload:{snapshot:r,query:e.query,matches:i}}},format(e){let n=N(e),r=n.matches.map(i=>`${n.snapshot.source}:${i.lineNumber}: ${i.lineText}`);return{content:[{type:"text",text:r.length===0?`No matches in ${n.snapshot.source}`:`${r.join(`
|
|
20
|
+
`)}
|
|
21
|
+
|
|
22
|
+
${r.length} match${r.length===1?"":"es"} in ${n.snapshot.source}`}],details:{source:n.snapshot.source,payload:n}}},renderResult(e,n,r){let i=e.details,l=J(i)?N(i.payload):N(void 0);return de(l.matches,!1,r,n.expanded===!0,void 0,[`Retained terminal output \xB7 ${l.snapshot.status} \xB7 read-only`])}}}a(kt,"terminalSearchResolver");function $t(t,e){let n=e.caseSensitive===!0?e.query:e.query.toLocaleLowerCase();if(n.length===0)return[];let r=[],i=e.limit??100;for(let[l,s]of t.output.replaceAll("\r","").split(`
|
|
23
|
+
`).entries()){let o=e.caseSensitive===!0?s:s.toLocaleLowerCase(),c=0;for(;r.length<i;){let u=o.indexOf(n,c);if(u<0)break;let d=u+n.length;(e.wholeWord!==!0||Ct(o,u,d))&&r.push({source:t.source,lineNumber:l+1,startColumn:u,endColumn:d,matchedText:s.slice(u,d),lineText:s}),c=Math.max(d,u+1)}if(r.length>=i)break}return r}a($t,"findTerminalMatches");function Ct(t,e,n){return!/[\p{L}\p{N}_]/u.test(t[e-1]??"")&&!/[\p{L}\p{N}_]/u.test(t[n]??"")}a(Ct,"isWordBoundary");function N(t){if(!It(t))throw new TypeError("Invalid terminal search result");return t}a(N,"parsePayload");function It(t){return J(t)&&typeof t.query=="string"&&Array.isArray(t.matches)&&J(t.snapshot)&&typeof t.snapshot.source=="string"}a(It,"isTerminalSearchPayload");function J(t){return typeof t=="object"&&t!==null}a(J,"isRecord");import{spawn as Mt}from"node:child_process";import{closeSync as _t,mkdirSync as Dt,openSync as Ot,rmSync as Nt,writeSync as Ut}from"node:fs";import Wt from"node:os";import Be from"node:path";import{createRequire as Bt}from"node:module";import{randomUUID as Ft}from"node:crypto";import{stripVTControlCharacters as jt}from"node:util";import{StringDecoder as Ht}from"node:string_decoder";import Lt from"node:os";import Ne from"node:path";var U={executable:"/bin/bash",displayName:"Bash over SSH",family:"posix",commandArgs:a(t=>["-lc",t],"commandArgs")};function Ue(t=process.platform,e=process.env){if(t==="win32"){let i=e.SHELL?.trim()||"powershell.exe",l=Ne.win32.basename(i).toLowerCase();return l==="cmd"||l==="cmd.exe"?{executable:i,displayName:"Command Prompt",family:"cmd",commandArgs:a(s=>["/d","/s","/c",s],"commandArgs")}:{executable:i,displayName:l.startsWith("pwsh")?"PowerShell":"Windows PowerShell",family:"powershell",commandArgs:a(s=>["-NoLogo","-NoProfile","-Command",s],"commandArgs")}}let n=e.SHELL?.trim()||Lt.userInfo().shell||(t==="darwin"?"/bin/zsh":"/bin/bash"),r=Ne.basename(n);return{executable:n,displayName:r==="zsh"?"zsh":r==="bash"?"Bash":r,family:"posix",commandArgs:a(i=>["-c",i],"commandArgs")}}a(Ue,"resolveShellProfile");function We(t){switch(t.family){case"powershell":return"Write PowerShell syntax. Use PowerShell cmdlets, `$env:NAME` for environment variables, and `;` or pipelines to compose commands.";case"cmd":return"Write Command Prompt syntax. Use `%NAME%` for environment variables and `&&` to chain successful commands.";case"posix":return`Write ${t.displayName} syntax. Use POSIX-style paths, \`$NAME\` for environment variables, and \`&&\` or pipelines to compose commands.`}}a(We,"shellSyntaxGuidance");var He=Bt(new URL("../src/plugins/pi-agent-ide-terminal/src/session-manager.ts",import.meta.url).href),Fe=1e6,Gt=100,qt=30,Vt=2e3,B=class{static{a(this,"TerminalSessionManager")}#a;#e=new Map;#n=new Set;#r=new Set;#s=new Map;#i=new Map;#l=!1;constructor(e=Kt){this.#a=e}onDidChange(e){return this.#n.add(e),()=>this.#n.delete(e)}onDidComplete(e){return this.#r.add(e),()=>this.#r.delete(e)}list(){return[...this.#e.values()].sort((e,n)=>n.startedAt-e.startedAt).map(e=>this.snapshot(e))}get(e){return this.#e.get(zt(e))}snapshot(e,n=Date.now()){return{id:e.id,source:e.source,command:e.command,cwd:e.cwd,shell:e.shell.displayName,shellFamily:e.shell.family,...e.process===void 0?{}:{pid:e.process.pid},...e.remote===void 0?{}:{remote:{target:e.remote.target,pid:e.remote.process.pid,...e.remote.process.identity===void 0?{}:{identity:e.remote.process.identity}}},background:e.background,status:e.status,...e.waitReason===void 0?{}:{waitReason:e.waitReason},...e.completionReason===void 0?{}:{completionReason:e.completionReason},lastActivityAt:e.lastActivityAt,idleMs:Math.max(0,n-e.lastActivityAt),startedAt:e.startedAt,...e.endedAt===void 0?{}:{endedAt:e.endedAt},elapsedMs:(e.endedAt??n)-e.startedAt,...e.exitCode===void 0?{}:{exitCode:e.exitCode},...e.signal===void 0?{}:{signal:e.signal},...e.error===void 0?{}:{error:e.error},output:e.output,outputStart:e.outputStart,outputEnd:e.outputStart+e.output.length,truncated:e.outputStart>0,fullOutputPath:e.fullOutputPath,cols:e.cols,rows:e.rows}}start(e){let n=this.#c(e),{id:r,cols:i,rows:l}=n,s;try{let c=He("node-pty"),u={name:"xterm-256color",cols:i,rows:l,cwd:e.cwd,env:Jt(Zt())};s=c.spawn(e.shell.executable,[...e.shell.commandArgs(e.command)],u)}catch(c){let u={...n,status:"failed",endedAt:Date.now(),error:W(c)};return this.#e.set(r,u),this.#o(r),n.resolveCompletion(u),queueMicrotask(()=>this.#d(u)),u}let o={...n,process:s};return this.#e.set(r,o),s.onData(c=>this.#u(o,c)),s.onExit(({exitCode:c,signal:u})=>{E(o.status)||(o.endedAt=Date.now(),o.exitCode=c,u!==0&&(o.signal=u),o.status=o.status==="stopping"?"stopped":c===0?"completed":"failed",(c===124||c===137)&&(o.completionReason="timeout"),this.#o(o.id),o.resolveCompletion(o),this.#t(o),this.#d(o))}),this.#t(o),o}#c(e){if(this.#l)throw new Error("Terminal session manager is closed");let n=this.#a();if(!/^[a-f0-9]{12}$/u.test(n)||this.#e.has(n)||this.#i.has(n))throw new Error("Terminal session IDs must be unique 12-character hexadecimal values");let r=tn(n);this.#s.set(n,Ot(r,"a",384));let i=e.cols??Gt,l=e.rows??qt,s=Xt(i,l),o=a(u=>{},"resolveCompletion"),c=new Promise(u=>{o=u});return{id:n,source:`shell:${n}`,command:e.command,background:e.background,cwd:e.cwd,shell:e.shell,startedAt:Date.now(),lastActivityAt:Date.now(),cols:i,rows:l,fullOutputPath:r,screen:s,status:"running",output:"",outputStart:0,screenReady:Promise.resolve(),completion:c,resolveCompletion:o,completionDelivered:!1,staleReminderDelivered:!1}}async startRemote(e){let n=U,r=this.#c({...e,cwd:e.remote.location.source,shell:n}),i=new AbortController;this.#i.set(r.id,{abort:i,completion:r.completion});let l=a(()=>i.abort(),"abortStartup");e.signal?.addEventListener("abort",l,{once:!0}),e.signal?.aborted&&l();try{let s=await e.remote.backend.startProcess(n.executable,n.commandArgs(e.command),e.remote.location.path,{pty:{cols:r.cols,rows:r.rows},signal:i.signal}).finally(()=>e.signal?.removeEventListener("abort",l)),o={...r,remote:{target:e.remote.location.target,process:s}};this.#e.set(o.id,o);let c=new Ht("utf8");s.stdout.on("data",d=>this.#u(o,c.write(d))),s.stderr.resume();let u=a(()=>{this.#u(o,c.end()),o.endedAt=Date.now(),this.#o(o.id),o.resolveCompletion(o),this.#t(o),this.#d(o)},"finish");return s.completion.then(({exitCode:d})=>{o.exitCode=d,d<0&&(o.signal=-d),o.status=o.status==="stopping"?"stopped":d===0?"completed":"failed",(d===124||d===137)&&(o.completionReason="timeout"),u()},d=>{o.status="lost",o.error=W(d),u()}),this.#t(o),o}catch(s){let o={...r,status:"failed",endedAt:Date.now(),error:W(s)};return this.#e.set(o.id,o),this.#o(o.id),o.resolveCompletion(o),queueMicrotask(()=>this.#d(o)),o}finally{this.#i.delete(r.id)}}async wait(e,n){let r=this.required(e);return E(r.status)?r:n?.aborted===!0?(await this.stop(r.source,"cancelled"),r):await new Promise((i,l)=>{let s=a(()=>{this.stop(r.source,"cancelled").then(i,l)},"onAbort");n?.addEventListener("abort",s,{once:!0}),r.completion.then(o=>{n?.removeEventListener("abort",s),i(o)},l)})}async waitForForeground(e,n){let r=this.required(e);if(E(r.status))return{session:r};let i=n.interactiveDelayMs??3e3;return await new Promise(l=>{let s=!1,o,c=a(p=>{s||(p!==void 0&&E(r.status)&&(p=void 0),s=!0,clearTimeout(d),clearInterval(m),n.signal?.removeEventListener("abort",u),p!==void 0&&(r.background=!0,p!=="aborted"&&(r.waitReason=p),this.#t(r)),l({session:r,...p===void 0?{}:{reason:p}}))},"finish"),u=a(()=>c("aborted"),"onAbort"),d=setTimeout(()=>c("timeout"),n.timeoutMs),m=setInterval(()=>{if(!Yt(r)){o=void 0;return}o??=Date.now(),Date.now()-o>=i&&c("interactive")},Math.min(100,Math.max(10,i/2)));n.signal?.addEventListener("abort",u,{once:!0}),n.signal?.aborted===!0&&u(),r.completion.then(()=>c())})}async waitForOutputAfter(e,n){let r=Date.now()+300,i=n,l;for(;Date.now()<r;){let s=e.outputStart+e.output.length;if(s!==i)i=s,l=Date.now(),await e.screenReady;else if(l!==void 0&&Date.now()-l>=40)return;await Q(10)}await e.screenReady}screenRows(e){let n=e.screen.buffer.active;return Array.from({length:e.rows},(r,i)=>(n.getLine(n.baseY+i)?.translateToString(!0)??"").trimEnd())}screenChangeRegion(e,n,r=6){let i=this.screenRows(e),l=Math.max(1,Math.min(e.rows,r)),s=Math.max(0,e.screen.buffer.active.cursorY-Math.floor(l/2)),o=-1;for(let d=0;d<=e.rows-l;d+=1){let m=0;for(let p=d;p<d+l;p+=1){let g=n[p]??"",h=i[p]??"",S=h.length>0&&!n.includes(h),w=g.length>0&&h.length===0;g!==h&&(S||w)&&(m+=1)}m>o&&(o=m,s=d)}let c=e.screen.buffer.active;return{lines:i.slice(s,s+l).map((d,m)=>{if(s+m!==c.cursorY)return d;let g=d.padEnd(c.cursorX," ");return`${g.slice(0,c.cursorX)}\u258C${g.slice(c.cursorX)}`}),startRow:s}}screenChangeWindow(e,n,r=6){return this.screenChangeRegion(e,n,r).lines}screenTail(e,n=e.rows){let r=e.screen.buffer.active,i=Math.max(0,r.baseY),l=[];for(let s=0;s<e.rows;s+=1){let o=r.getLine(i+s)?.translateToString(!0).trimEnd();o!==void 0&&o.length>0&&l.push(o)}return l.slice(-Math.max(0,n))}markInspected(e){let n=this.required(e);n.status==="running"&&(n.lastActivityAt=Date.now(),this.#t(n))}write(e,n){let r=this.requiredRunning(e);if(r.remote)return r.remote.process.write(Buffer.from(n)).catch(i=>{throw r.error=W(i),this.#t(r),i});r.process?.write(n)}sendKeys(e,n){return this.write(e,Qt(n))}async stop(e,n="stopped"){let r=this.required(e);return E(r.status)||(r.status="stopping",this.#t(r),await je(r,!1),await Promise.race([r.completion.then(()=>!0),Q(Vt).then(()=>!1)])||(await je(r,!0),await Promise.race([r.completion,Q(1e3)])),E(r.status)||(r.status=n,r.endedAt=Date.now(),this.#o(r.id),r.resolveCompletion(r),this.#d(r)),n==="cancelled"&&(r.status="cancelled"),this.#t(r)),r}async delete(e){let n=this.required(e);n.completionDelivered=!0,await this.stop(n.source),n.screen.dispose(),this.#o(n.id),Nt(n.fullOutputPath,{force:!0}),this.#e.delete(n.id),this.#t(n)}async screenLines(e){let n=this.required(e);await n.screenReady;let r=n.screen.buffer.active,i=[],l=Math.max(0,r.baseY);for(let s=l;s<l+n.rows;s+=1)i.push(r.getLine(s)?.translateToString(!0)??"");return i}cursor(e){let n=this.required(e);return{x:n.screen.buffer.active.cursorX,y:n.screen.buffer.active.cursorY}}async dispose(){if(this.#l)return;this.#l=!0;let e=[...this.#i.values()];for(let n of e)n.abort.abort();await Promise.all(e.map(n=>n.completion)),await Promise.all([...this.#e.values()].filter(n=>!E(n.status)).map(n=>this.stop(n.source)));for(let n of this.#e.values())n.screen.dispose(),this.#o(n.id);this.#n.clear(),this.#r.clear()}required(e){let n=this.get(e);if(n===void 0)throw new Error(`Unknown terminal session ${e}`);return n}requiredRunning(e){let n=this.required(e);if(n.status!=="running")throw new Error(`Terminal session ${n.source} is ${n.status}; input is unavailable`);return n}#u(e,n){e.lastActivityAt=Date.now();let r=jt(n),i=this.#s.get(e.id);if(i!==void 0&&Ut(i,r),e.output+=r,e.output.length>Fe){let l=e.output.length-Fe;e.output=e.output.slice(l),e.outputStart+=l}e.screenReady=e.screenReady.then(()=>new Promise(l=>{e.screen.write(n,l)})),this.#t(e)}#o(e){let n=this.#s.get(e);n!==void 0&&(_t(n),this.#s.delete(e))}#t(e){for(let n of this.#n)n(e)}#d(e){for(let n of this.#r)n(e)}};function Yt(t){if(t.status!=="running")return!1;let e=t.screen.buffer.active,n=e.getLine(e.baseY+e.cursorY)?.translateToString(!0).trimEnd()??"";return/\[[^\]\n]{1,20}(?:\/[^\]\n]{1,20})+\]\s*[:?>]?\s*$/iu.test(n)||/(?:choose|select|enter|password|confirm|continue|proceed)[^\n]{0,60}[:?]\s*$/iu.test(n)||/^(?:❯|›)\s+\S/u.test(n)}a(Yt,"looksInteractive");function Xt(t,e){let{Terminal:n}=He("@xterm/headless");return new n({cols:t,rows:e,scrollback:2e3,allowProposedApi:!0})}a(Xt,"createScreen");function Kt(){return Ft().replaceAll("-","").slice(0,12)}a(Kt,"defaultSessionId");function zt(t){return t.startsWith("shell:")?t.slice(6):t}a(zt,"normalizeSessionId");function E(t){return t!=="running"&&t!=="stopping"}a(E,"isTerminalStatus");function Zt(){return process.env}a(Zt,"processEnvironment");function Jt(t){return{...Object.fromEntries(Object.entries(t).filter(e=>e[1]!==void 0)),PAGER:"cat",GIT_PAGER:"cat",SYSTEMD_PAGER:"cat",GH_PAGER:"cat"}}a(Jt,"cleanEnvironment");function Qt(t){return t.split(/[\s,]+/u).filter(Boolean).map(en).join("")}a(Qt,"encodeTerminalKeys");function en(t){if(/^\^[?@A-Z[\\\]^_]$/iu.test(t)){let d=t.slice(1).toUpperCase();return d==="?"?"\x7F":String.fromCharCode(d.charCodeAt(0)&31)}let e=t.toLowerCase().split("+"),n=e.pop()??"",r=new Set(e);if([...r].some(d=>!["ctrl","control","alt","meta","shift"].includes(d)))throw new Error(`Unsupported terminal key ${t}`);let i=r.has("ctrl")||r.has("control"),l=r.has("alt")||r.has("meta"),s=r.has("shift");if(i&&n.length===1&&/[a-z@[\\\]^_?]/u.test(n)){let d=n.toUpperCase(),m=d==="?"?"\x7F":String.fromCharCode(d.charCodeAt(0)&31);return l?`\x1B${m}`:m}let o={enter:"\r",tab:" ",escape:"\x1B",esc:"\x1B",backspace:"\x7F",home:"\x1B[H",end:"\x1B[F",delete:"\x1B[3~"};if(!i&&!l&&!s&&o[n]!==void 0)return o[n];if(l&&!i&&!s&&o[n]!==void 0)return`\x1B${o[n]}`;let u={up:"A",down:"B",right:"C",left:"D",home:"H",end:"F"}[n];if(u!==void 0)return!i&&!l&&!s?`\x1B[${u}`:`\x1B[1;${1+(s?1:0)+(l?2:0)+(i?4:0)}${u}`;if(l&&!i&&n.length===1)return`\x1B${s?n.toUpperCase():n}`;throw new Error(`Unsupported terminal key ${t}`)}a(en,"encodeTerminalKey");async function je(t,e){if(t.remote){await t.remote.process.stop().catch(()=>{});return}let n=t.process;if(n!==void 0){if(globalThis.process.platform!=="win32")try{globalThis.process.kill(-n.pid,e?"SIGKILL":"SIGTERM");return}catch{try{n.kill(e?"SIGKILL":"SIGTERM")}catch{}return}await new Promise(r=>{let i=Mt("taskkill.exe",["/PID",String(n.pid),"/T",...e?["/F"]:[]],{windowsHide:!0,stdio:"ignore"});i.once("error",()=>r()),i.once("exit",()=>r())})}}a(je,"terminateProcessTree");function Q(t){return new Promise(e=>setTimeout(e,t))}a(Q,"delay");function W(t){return t instanceof Error?t.message:String(t)}a(W,"errorMessage");function tn(t){let e=Be.join(Wt.tmpdir(),`pi-agent-ide-terminal-${process.pid}`);return Dt(e,{recursive:!0,mode:448}),Be.join(e,`${t}.log`)}a(tn,"createOutputLog");import{AgentSession as nn}from"@earendil-works/pi-coding-agent";var F=Symbol.for("pi-agent-ide.terminal-steering-observers");function Ge(t){let e=nn.prototype,n=e[F]??rn(e);return n.listeners.add(t),()=>{n.listeners.delete(t),n.listeners.size===0&&n.restore()}}a(Ge,"observeQueuedSteering");function rn(t){let e=t.prompt,n=t.steer,r=new Set,i=a(c=>{for(let u of[...r])u(c)},"notify"),l=a(function(c,u){return u?.streamingBehavior!=="steer"?e.call(this,c,u):e.call(this,c,{...u,preflightResult:a(d=>{u.preflightResult?.(d),d==="queued"&&i(this)},"preflightResult")})},"prompt"),s=a(async function(...c){let u=await n.apply(this,c);return u==="queued"&&i(this),u},"steer");t.prompt=l,t.steer=s;let o={listeners:r,restore:a(()=>{t[F]===o&&(t.prompt===l&&(t.prompt=e),t.steer===s&&(t.steer=n),delete t[F])},"restore")};return t[F]=o,o}a(rn,"installObservers");import Xe from"node:path";import{stripVTControlCharacters as sn}from"node:util";import{defineTool as an}from"@earendil-works/pi-coding-agent";import{Type as b}from"typebox";import{Text as ln}from"@earendil-works/pi-tui";import{open as on}from"node:fs/promises";import{Type as f}from"typebox";var qe=1024*1024,Ve=f.Object({output:f.String({description:"ANSI-free PTY output, up to 1 MiB. Longer output joins the first and last 512 KiB without adding labels or an omission marker. See output_ranges for the gap."}),truncated:f.Boolean({description:"Whether output omits bytes from the retained log. This is independent of whether the process has finished."}),full_output_path:f.String({description:"UTF-8 log of all output received so far. Available until the shell session is deleted."}),output_ranges:f.Array(f.Object({start:f.Integer(),end:f.Integer()}),{description:"Zero-based, end-exclusive UTF-8 byte ranges in the log, concatenated into output."}),exit_code:f.Optional(f.Number({description:"Process exit code, only when known."})),wall_time_seconds:f.Number(),session:f.String({description:"Session ID."}),source:f.String({description:"Persistent shell: source for Read, input and termination."}),status:f.Union(["running","completed","failed","stopping","stopped","cancelled","lost"].map(t=>f.Literal(t))),background:f.Boolean(),cwd:f.String({description:"Actual working directory; SSH sessions retain their canonical ssh:// target URI."}),remote:f.Optional(f.Object({target:f.String(),pid:f.Integer({minimum:1})},{description:"Remote process identity, never a local native PID."})),wait_reason:f.Optional(f.Union([f.Literal("timeout"),f.Literal("interactive"),f.Literal("steering")])),completion_reason:f.Optional(f.Literal("timeout")),signal:f.Optional(f.Number()),error:f.Optional(f.String())});async function Ye(t){let e=await on(t.fullOutputPath,"r");try{let n=(await e.stat()).size,r=a(async(o,c)=>{let u=Buffer.alloc(c),d=0;for(;d<c;){let m=await e.read(u,d,c-d,o+d);if(m.bytesRead===0)throw new Error("Shell output log ended before its snapshot size");d+=m.bytesRead}return u},"readRange"),i,l,s=n>qe;if(!s)i=(await r(0,n)).toString("utf8"),l=[{start:0,end:n}];else{let o=qe/2,c=await r(0,o),u=await r(n-o,o),d=new TextDecoder().decode(c,{stream:!0}),m=0;for(;m<u.length&&(u.readUInt8(m)&192)===128;)m++;let p=u.subarray(m).toString("utf8");i=d+p,l=[{start:0,end:Buffer.byteLength(d)},{start:n-o+m,end:n}]}return{output:i,truncated:s,full_output_path:t.fullOutputPath,output_ranges:l,...t.exitCode===void 0?{}:{exit_code:t.exitCode},wall_time_seconds:t.elapsedMs/1e3,session:t.id,source:t.source,status:t.status,background:t.background,cwd:t.cwd,...t.remote===void 0?{}:{remote:t.remote},...t.waitReason===void 0?{}:{wait_reason:t.waitReason},...t.completionReason===void 0?{}:{completion_reason:t.completionReason},...t.signal===void 0?{}:{signal:t.signal},...t.error===void 0?{}:{error:t.error}}}finally{await e.close()}}a(Ye,"structuredShellResult");var un=a(t=>b.Object({command:b.String({minLength:1,description:`Command for ${t.displayName} (${t.executable}). ${We(t)}`}),background:b.Optional(b.Boolean({description:"Set true to return after an initial output preview instead of waiting for completion. Defaults to false."})),timeoutSeconds:b.Optional(b.Number({minimum:.1,maximum:86400,description:"Set the foreground wait limit in seconds. On expiry, the live session returns in background without stopping the process. Ignored when background is true. Defaults to 60."})),cwd:b.Optional(b.String({description:"Working directory. Relative paths resolve from the current workspace."})),cols:b.Optional(b.Integer({minimum:20,maximum:300,description:"Virtual terminal width in cells"})),rows:b.Optional(b.Integer({minimum:5,maximum:120,description:"Virtual terminal height in cells"}))},{additionalProperties:!1}),"createRunParameters");function Ke(t,e,n,r,i="compact",l=new L([])){let s=new Set,o=process.platform==="win32"?"powershell":"bash",c=un(n);return t.registerTool(an({name:o,exposure:"direct",namespace:{name:"ide_terminal",description:"Run shell commands in persistent terminal sessions."},annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},label:n.displayName,promptSnippet:`Execute ${n.displayName} commands in synchronous or background terminal sessions`,promptGuidelines:[`Do not use ${o} commands or scripts to edit files. Use the standalone editing tools instead. Commands that inherently generate files, such as formatters and code generators, are allowed.`],description:`Use ${o} to execute a command in the user's configured shell. Each call creates a new terminal session and returns its shell: source for inspection and interaction.`,parameters:c,outputSchema:Ve,async execute(u,d,m,p,g){r.bind(g);let h=l.resolve(d.cwd??g.cwd,g.cwd),S={command:d.command,background:d.background??!1,...d.cols===void 0?{}:{cols:d.cols},...d.rows===void 0?{}:{rows:d.rows}},w=h?await e.startRemote({...S,remote:h,...m===void 0?{}:{signal:m}}):e.start({...S,cwd:d.cwd===void 0?g.cwd:Xe.resolve(g.cwd,d.cwd),shell:n});if(d.background===!0&&w.status!=="failed")return await cn(e,w,p),w.status!=="running"&&(w.completionDelivered=!0),j(e.snapshot(w));if(w.status==="failed")return j(e.snapshot(w));let T=new AbortController;s.add(T);let y;try{y=await e.waitForForeground(w.source,{signal:m===void 0?T.signal:AbortSignal.any([m,T.signal]),timeoutMs:(d.timeoutSeconds??60)*1e3})}finally{s.delete(T)}return y.reason==="aborted"&&T.signal.aborted&&m?.aborted!==!0?(y.session.waitReason="steering",j(e.snapshot(y.session))):(y.reason==="aborted"&&r.notifyWaitTransition(y.session),j(e.snapshot(y.session)))},renderCall(u,d,m){if((m.expanded?"full":i)==="disabled")return new ln(d.fg("toolTitle",o),0,0);let g=typeof u.command=="string"?u.command:"",h=typeof u.cwd=="string"&&u.cwd.startsWith("ssh:"),S=typeof u.cwd=="string"?h?u.cwd:Xe.resolve(process.cwd(),u.cwd):process.cwd();return ve(g,u.background===!0,S,h?U:n,d)},renderResult(u,d,m){return xe(u.details,d.expanded?"full":i,m)}})),()=>{for(let u of s)u.abort()}}a(Ke,"registerTerminalTools");function ze(t){let e=k(t.output).content;return{content:[{type:"text",text:_(t)}],details:{...t,output:e,outputStart:t.outputEnd-e.length,truncated:t.truncated||e.length<t.output.length},isError:t.status==="failed"||t.status==="lost"}}a(ze,"terminalPreview");async function j(t){return{...ze(t),structuredContent:await Ye(t)}}a(j,"terminalResult");async function cn(t,e,n){await new Promise(r=>{let i=!1,l,s=a(()=>{},"unsubscribe"),o=a(()=>{i||(i=!0,clearTimeout(l),s(),r())},"finish"),c=a(()=>{let u=t.snapshot(e);n?.(ze(u)),(sn(u.output).replaceAll("\r","").split(`
|
|
24
|
+
`).filter(m=>m.length>0).length>=A||u.status!=="running")&&o()},"publish");s=t.onDidChange(u=>{u.id===e.id&&c()}),l=setTimeout(o,2e3),c()})}a(cn,"captureInitialBackgroundPreview");import{Box as Ze,Container as Je}from"@earendil-works/pi-tui";var dn=120,mn=12e4,H=class{constructor(e,n,r=mn){this.pi=e;this.manager=n;this.staleIntervalMs=r;e.registerMessageRenderer("terminal-stale",(i,{expanded:l},s)=>{let o=Qe(i.details)?i.details:void 0,c=new Je;o!==void 0&&c.addChild(x(o,l,s,"stale \xB7 inspect session"));let u=new Ze(1,1,d=>s.bg("toolPendingBg",d));return u.addChild(c),u}),e.registerMessageRenderer("terminal-completion",(i,{expanded:l},s)=>{let o=new Je;for(let u of pn(i.details))o.addChild(x(u,l,s));let c=new Ze(1,1,u=>s.bg("toolSuccessBg",u));return c.addChild(o),c}),this.#l=[n.onDidChange(i=>this.#c(i)),n.onDidComplete(i=>{this.#o(i.id),i.background&&this.#t(i)})]}static{a(this,"TerminalUi")}#a=new Map;#e;#n=new Map;#r=new Set;#s;#i=!1;#l;bind(e){this.#s=e}onAgentSettled(e){this.#s=e;for(let n of[...this.#r]){this.#r.delete(n);let r=this.manager.get(n);r!==void 0&&this.#c(r,!0)}}notifyWaitTransition(e){let n=this.manager.snapshot(e);this.pi.sendMessage({customType:"terminal-wait-transition",display:!1,content:`Terminal wait ended; ${n.source} is still running in background. Read it to inspect output, then use write or insert to send input.`,details:n},{triggerTurn:!0,deliverAs:"steer"})}dispose(){this.#i=!0,this.#e!==void 0&&clearTimeout(this.#e),this.#e=void 0,this.#a.clear();for(let e of this.#n.values())clearTimeout(e);this.#n.clear(),this.#r.clear(),this.#s=void 0;for(let e of this.#l)e()}#c(e,n=!1){if(this.#o(e.id),this.#i||e.staleReminderDelivered||!e.background||e.status!=="running")return;let r=this.manager.snapshot(e),i=Math.max(0,this.staleIntervalMs-r.idleMs);if(n&&i===0){this.#u(e);return}this.#n.set(e.id,setTimeout(()=>this.#u(e),i))}#u(e){if(this.#n.delete(e.id),this.#i||e.staleReminderDelivered||e.status!=="running"||!e.background)return;if(this.#s?.isIdle()!==!0){this.#r.add(e.id);return}e.staleReminderDelivered=!0;let n=this.manager.snapshot(e);this.pi.sendMessage({customType:"terminal-stale",display:!0,content:gn(n),details:n},{triggerTurn:!0,deliverAs:"followUp"})}#o(e){let n=this.#n.get(e);n!==void 0&&clearTimeout(n),this.#n.delete(e),this.#r.delete(e)}#t(e){this.#i||e.completionDelivered||(this.#a.set(e.id,e),this.#e===void 0&&(this.#e=setTimeout(()=>{this.#e=void 0;let n=[...this.#a.values()].filter(i=>!i.completionDelivered);if(this.#a.clear(),this.#i||n.length===0)return;for(let i of n)i.completionDelivered=!0;let r=n.map(i=>this.manager.snapshot(i));this.pi.sendMessage({customType:"terminal-completion",display:!0,content:fn(r),details:{sessions:r}},{triggerTurn:!0,deliverAs:"steer"})},dn)))}};function pn(t){return!tt(t)||!Array.isArray(t.sessions)?[]:t.sessions.filter(Qe)}a(pn,"completionSnapshots");function Qe(t){return tt(t)&&typeof t.id=="string"&&typeof t.source=="string"&&typeof t.command=="string"&&typeof t.cwd=="string"&&typeof t.shell=="string"&&typeof t.background=="boolean"&&typeof t.status=="string"&&typeof t.startedAt=="number"&&typeof t.elapsedMs=="number"&&typeof t.output=="string"}a(Qe,"isTerminalSessionSnapshot");function fn(t){return`${t.length===1?"Background terminal completed:":"Background terminals completed:"}
|
|
25
|
+
${t.map(n=>{let r=n.exitCode===void 0?"":`, exit ${n.exitCode}`,i=n.completionReason===void 0?"":`, reason ${n.completionReason}`,l=n.output.trimEnd().slice(-2e3);return`- ${n.source}: ${n.status}${r}${i}, ${et(n.elapsedMs)}
|
|
26
|
+
${l||"(no output)"}`}).join(`
|
|
27
|
+
`)}`}a(fn,"formatCompletionMessage");function gn(t){let e=t.output.trimEnd().slice(-2e3);return`Background terminal ${t.source} has produced no output for ${et(t.idleMs)}. Inspect it with read. If it is healthy, keep waiting; otherwise send input or stop it.
|
|
28
|
+
${e||"(no output)"}`}a(gn,"formatStaleMessage");function et(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}a(et,"formatElapsed");function tt(t){return typeof t=="object"&&t!==null}a(tt,"isRecord");function nt(t){return t==="full"||t==="disabled"?t:"compact"}a(nt,"toolPresentation");async function hn(t,e){te(t,[await ee({id:"terminal",description:"Foreground and background commands, shell resources, and processes",triggers:[{tool:"bash"},{tool:"powershell"},...["read","write","insert","delete"].map(u=>({tool:u,resourcePrefixes:["shell:","process:"]}))]})]);let n=ye("terminal")??new B,r=Ue(),i=new L(await ge(fe(pe()))),l=new H(t,n),s=he(t).add(ke(n));await Promise.all([_e(t,n),Oe(t,n)]);let o=Ke(t,n,r,l,nt(e?.preferences["ui.terminal"]),i),c=a(()=>{},"removeSteeringObserver");t.on("session_start",(u,d)=>{l.bind(d),c(),c=Ge(m=>{m.sessionManager===d.sessionManager&&o()})}),t.on("agent_settled",(u,d)=>l.onAgentSettled(d)),t.on("session_shutdown",async u=>{if(c(),l.dispose(),s(),u.reason!=="quit"){we("terminal",n);return}Se("terminal",n),await n.dispose()})}a(hn,"registerTerminal");export{hn as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as w}from"./chunk-
|
|
1
|
+
import{a as w}from"./chunk-L2B4DTVS.js";import{c as S,d as M}from"./chunk-W7CASEO3.js";import{a as n}from"./chunk-EI7MMDWY.js";import{Container as _,Key as x,matchesKey as P,SelectList as k,Text as v,truncateToWidth as T,visibleWidth as A}from"@earendil-works/pi-tui";var I=class{constructor(e,o,s){this.registry=e;this.activityMode=o;e.onDidChange(()=>this.#s()),s.registerCommand("agent-ide-processes",{description:"Show active terminal and debugger processes created by Agent IDE",handler:n(async(d,c)=>{if(this.bind(c),c.mode!=="tui"){c.ui.notify("The Agent IDE process overlay requires the TUI.","info");return}await this.#r(c)},"handler")})}static{n(this,"AgentIdeProcessesUi")}#t;#i=!1;#e;bind(e){this.#i||(this.#t=e,this.#s())}dispose(){this.#i=!0,this.#e!==void 0&&clearInterval(this.#e),this.#e=void 0,this.#t?.ui.setWidget("agent-ide-processes",void 0),this.#t?.ui.setStatus("agent-ide-processes",void 0),this.#t=void 0}#n(){return this.registry.list()}#s(){let e=this.#t;if(this.#i||e===void 0||!e.hasUI)return;let o=this.#n();if(this.activityMode==="off"||o.length===0){e.ui.setWidget("agent-ide-processes",void 0),e.ui.setStatus("agent-ide-processes",void 0),this.#e!==void 0&&clearInterval(this.#e),this.#e=void 0;return}if(this.activityMode==="compact"){e.ui.setWidget("agent-ide-processes",void 0),e.ui.setStatus("agent-ide-processes",`Agent IDE processes: ${o.length}`);return}e.ui.setStatus("agent-ide-processes",void 0),e.ui.setWidget("agent-ide-processes",(s,d)=>({invalidate(){},render:n(c=>q(o,c,d),"render")}),{placement:"belowEditor"}),this.#e??=setInterval(()=>this.#s(),1e3)}async#r(e){for(;;){if(this.#n().length===0){e.ui.notify("No active Agent IDE processes.","info");return}let o=n(()=>{},"disposeRefresh"),s,d;try{d=await e.ui.custom((g,a,O,E)=>{let h=this.#n(),l="list",f,$=n(r=>{let u=h.map(t=>({value:t.source,label:`${t.status} ${t.kind} ${t.title}`,description:t.description})),p=new k(u,Math.min(u.length,12),{selectedPrefix:n(t=>a.fg("accent",t),"selectedPrefix"),selectedText:n(t=>a.fg("accent",t),"selectedText"),description:n(t=>a.fg("muted",t),"description"),scrollInfo:n(t=>a.fg("dim",t),"scrollInfo"),noMatch:n(t=>a.fg("warning",t),"noMatch")}),y=u.findIndex(t=>t.value===r);return y>=0&&p.setSelectedIndex(y),p.onSelect=t=>{f=h.find(W=>W.source===t.value),l="detail",g.requestRender()},p.onCancel=()=>E(null),p},"createList"),m=$(),C=n(()=>{let r=f?.source??m.getSelectedItem()?.value;h=this.#n(),f=l==="list"?void 0:h.find(u=>u.source===r),m=$(r),g.requestRender()},"refresh");return o=this.registry.onDidChange(C),s=setInterval(C,1e3),{invalidate:n(()=>m.invalidate(),"invalidate"),render(r){let u=new _;l==="list"?(u.addChild(m),u.addChild(new v(a.fg("dim",h.length===0?"esc close":"enter view \xB7 d stop \xB7 esc close"),1,0))):f===void 0?(u.addChild(new v(a.fg("warning","Process is no longer active."),1,0)),u.addChild(new v(a.fg("dim","esc back"),1,0))):(u.addChild(f.renderDetail(a)),u.addChild(new v(a.fg(l==="confirm"?"warning":"dim",l==="confirm"?"Stop this process? y confirm \xB7 n/esc cancel":l==="input"?"input mode \xB7 type to send \xB7 esc stop input":f.sendInput===void 0?"esc back \xB7 d stop":"i input \xB7 esc back \xB7 d stop"),1,0)));let p=n(t=>a.fg("accent",t),"accent"),y=Math.max(1,r-2);return[D("Agent IDE Processes",`${h.length} active`,r,p),...u.render(y).map(t=>b(t,r,p)),R(r,p)]},handleInput(r){l==="list"?r==="d"?(f=h.find(u=>u.source===m.getSelectedItem()?.value),f!==void 0&&(l="confirm")):m.handleInput(r):l==="detail"?P(r,x.escape)?l="list":r==="d"&&f!==void 0?l="confirm":r==="i"&&f?.sendInput!==void 0&&(l="input"):l==="input"?P(r,x.escape)?l="detail":f?.sendInput?.(r):r==="y"&&f!==void 0?E({source:f.source}):(r==="n"||P(r,x.escape))&&(l="detail"),g.requestRender()}}},{overlay:!0,overlayOptions:{width:"75%",maxHeight:"80%",minWidth:52}})}finally{o(),s!==void 0&&clearInterval(s)}if(d===null)return;let c=this.#n().find(g=>g.source===d.source);c!==void 0&&await c.stop()}}};function q(i,e,o){if(i.length===0)return[];let s=n(c=>o.fg("accent",c),"accent"),d=[D("Agent IDE Processes",`${i.length} active`,e,s)];for(let[c,g]of i.entries()){for(let a of g.renderSummary(o))d.push(b(` ${a} `,e,s));c<i.length-1&&d.push(b("",e,s))}return d.push(R(e,s)),d}n(q,"renderProcessWidget");function D(i,e,o,s){if(o<=1)return s("\u256D");let d=o-2,c=`\u2500 ${i} `,g=` ${e} \u2500`,a="\u2500".repeat(Math.max(0,d-A(c)-A(g)));return s(`\u256D${T(`${c}${a}${g}`,d).padEnd(d,"\u2500")}\u256E`)}n(D,"borderTop");function b(i,e,o){if(e<=1)return o("\u2502");let s=e-2,d=T(i,s);return`${o("\u2502")}${d}${" ".repeat(Math.max(0,s-A(d)))}${o("\u2502")}`}n(b,"borderLine");function R(i,e){return e(i<=1?"\u2570":`\u2570${"\u2500".repeat(i-2)}\u256F`)}n(R,"borderBottom");async function L(i){let e=w(i),o=await M(S()),s=new I(e,K(o.preferences?.["processes.activity"]),i);i.on("session_start",(d,c)=>s.bind(c)),i.on("session_shutdown",()=>s.dispose())}n(L,"registerAgentIdeProcesses");function K(i){return i==="compact"||i==="off"?i:"detailed"}n(K,"activityMode");export{L as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as oe}from"./chunk-L2B4DTVS.js";import{b as O}from"./chunk-NULNW6GK.js";import{a as $}from"./chunk-CTJV77FR.js";import{a as se}from"./chunk-TWWND6NI.js";import{c as re}from"./chunk-SBLKPTL3.js";import"./chunk-XZDOVPRC.js";import{a as ee,b as te,c as ne}from"./chunk-HCN5W76B.js";import"./chunk-7TJ6DWW3.js";import{g as y}from"./chunk-EY65TFHJ.js";import"./chunk-VDP5CQHM.js";import{c as Z}from"./chunk-W7CASEO3.js";import{e as z,f as F}from"./chunk-T7I2VX3J.js";import{a as H}from"./chunk-YJ6T3PEP.js";import{b as B,c as _}from"./chunk-S72FVLUX.js";import{a as G}from"./chunk-BU7IZLKB.js";import{a as j,b as Y}from"./chunk-S5PL5DFQ.js";import{a as Q}from"./chunk-N7LMRL64.js";import{a as J,b as K}from"./chunk-RAZP42IQ.js";import{a as X}from"./chunk-PS2B6THP.js";import"./chunk-R5XJSEOE.js";import{a as d}from"./chunk-EI7MMDWY.js";var ie={protocol:B,apiVersion:_,id:"vision",setup(e){e.addCheck({id:"target-graphics",title:"Target screen capture readiness",async run(t){if(!t.workspace)return[];try{if(t.signal?.throwIfAborted(),!t.workspace.probeCapture)throw new Error("Project owner does not provide a capture readiness probe");let n=await t.workspace.probeCapture(t.signal);return t.signal?.throwIfAborted(),[{status:n.display.ok?"pass":"warn",message:"Native display connection",detail:n.display.detail},{status:n.window.ok?"pass":"warn",message:"Trusted native window identity",detail:n.window.detail}]}catch(n){return t.signal?.throwIfAborted(),[{status:"warn",message:"Native capture readiness is unavailable",detail:n instanceof Error?n.message:String(n)}]}}})}};import{execFile as be}from"node:child_process";import Pe from"node:os";import{promisify as ve}from"node:util";import{createCanvas as ae,loadImage as Se}from"@napi-rs/canvas";var v=ve(be),k=20*1024*1024,de={durationSeconds:2,intervalSeconds:.5,scale:.5},q=new Set;function D(e,t){let n=t.list().find(r=>r.owned===!0&&r.remote?.target===e.target&&r.remote.pid===e.pid&&r.remote.identity===e.identity&&(r.status==="running"||r.status==="stopping"||r.status==="paused"));return n?{...e,owned:!0,source:n.source}:{...e,owned:!1,source:void 0}}d(D,"withRemoteProcessOwnership");function le(e){let t=V({mode:"sequence",durationSeconds:Number(e.durationSeconds??2),intervalSeconds:Number(e.intervalSeconds??.5),scale:Number(e.scale??.5)});de={durationSeconds:t.durationSeconds,intervalSeconds:t.intervalSeconds,scale:t.scale},q=new Set((e.allowedExecutables??"").split(",").map(n=>n.trim().toLowerCase()).filter(Boolean))}d(le,"configureVision");function C(){return de}d(C,"getVisionDefaults");function ue(e){let t=e.includes("\\")?e.slice(e.lastIndexOf("\\")+1):e,n=t.trim().split(/\s+/u)[0]??"",r=n.slice(n.lastIndexOf("/")+1);return q.has((e.includes("\\")?t:r).toLowerCase())}d(ue,"isExecutableAllowed");function pe(e){return q.has(e.slice(e.lastIndexOf("/")+1).toLowerCase())}d(pe,"isNativeExecutableAllowed");function we(e,t){let n=e?.filter(u=>/^(?:image|sequence)(?::|$)/u.test(u))??[];if(n.length===0)return;if(n.length>1)throw new Error("Use only one image or sequence view");let r=n[0],s=r.indexOf(":"),c=r.slice(0,s<0?void 0:s),a={};if(s>=0&&xe(r.slice(s+1),a),c==="image"&&(a.duration!==void 0||a.interval!==void 0))throw new Error("duration and interval are supported only by the sequence view");return V({mode:c,durationSeconds:a.duration??t.durationSeconds,intervalSeconds:a.interval??t.intervalSeconds,scale:a.scale??t.scale,...a.region===void 0?{}:{region:a.region}})}d(we,"parseVisionView");function xe(e,t){if(e.length===0)throw new Error("View parameters cannot be empty");let n=e.split(",");for(let r=0;r<n.length;r+=1){let s=n[r],c=s.indexOf("=");if(c<=0)throw new Error(`Invalid view parameter ${s}`);let a=s.slice(0,c),u=s.slice(c+1);if(a==="region"){let o=[u,n[r+1],n[r+2],n[r+3]].map(Number);if(o.some(w=>!Number.isFinite(w)))throw new Error("region requires x,y,width,height values");t.region={x:o[0],y:o[1],width:o[2],height:o[3]},r+=3;continue}if(a!=="duration"&&a!=="interval"&&a!=="scale")throw new Error(`Unknown view parameter ${a}`);let i=Number(u);if(!Number.isFinite(i))throw new Error(`View parameter ${a} must be a number`);if(t[a]!==void 0)throw new Error(`Duplicate view parameter ${a}`);t[a]=i}}d(xe,"parseViewParameters");function me(e){if(!e.startsWith("display:"))return;if(e==="display:")return 0;let t=/^display:#(\d+)$/u.exec(e);if(t===null)throw new Error("Display sources use display: or display:#N with a zero-based index");let n=Number(t[1]);if(!Number.isSafeInteger(n))throw new Error("Display sources use display: or display:#N with a zero-based index");return n}d(me,"parseDisplaySource");async function T(e){let t=new Map(e.list().flatMap(s=>s.remote!==void 0||s.pid===void 0?[]:[[s.pid,s]]));if(process.platform!=="linux"&&process.platform!=="darwin")return[...t].map(([s,c])=>({pid:s,command:c.description,owned:!0,source:c.source,host:"local"}));let{stdout:n}=await v("ps",["-eo","pid=,ppid=,lstart=,args="],{maxBuffer:4*1024*1024}),r=n.split(`
|
|
2
|
+
`).flatMap(s=>{let c=/^\s*(\d+)\s+(\d+)\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+(.*)$/u.exec(s);if(c===null)return[];let a=Number(c[1]),u=t.get(a);return[{pid:a,parentPid:Number(c[2]),started:c[3],command:c[4]??"",owned:u!==void 0,host:"local",...u===void 0?{}:{source:u.source}}]});return M()?[...r,...await Ie()]:r}d(T,"listProcesses");async function Ie(){try{let{stdout:e}=await v("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-Command","Get-Process | Select-Object Id,ProcessName,Path,StartTime | ConvertTo-Json -Compress"],{maxBuffer:4194304}),t=JSON.parse(e);return(Array.isArray(t)?t:[t]).flatMap(r=>{if(typeof r!="object"||r===null||!("Id"in r)||typeof r.Id!="number")return[];let s="ProcessName"in r&&typeof r.ProcessName=="string"?r.ProcessName:"Windows process",c="Path"in r&&typeof r.Path=="string"?r.Path:void 0,a="StartTime"in r&&typeof r.StartTime=="string"?r.StartTime:void 0;return[{pid:r.Id,command:c??s,owned:!1,host:"windows",...a===void 0?{}:{started:a}}]})}catch{return[]}}d(Ie,"listWindowsProcesses");async function W(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error("Process PID must be a positive integer");let n=(await T(t)).find(r=>r.pid===e);if(n===void 0)throw new Error(`Process ${e} is not running`);return n}d(W,"readProcess");function V(e){let t=e.scale??1;if(!(t>0&&t<=1))throw new Error("Image scale must be greater than 0 and at most 1");let n=e.durationSeconds??0,r=e.intervalSeconds??1;if(e.mode==="sequence"){if(!(n>0&&n<=10))throw new Error("Sequence duration must be greater than 0 and at most 10 seconds");if(!(r>0))throw new Error("Sequence interval must be greater than 0 seconds");if(Math.floor(n/r)+1>20)throw new Error("Sequence capture is limited to 20 frames")}if(e.region!==void 0){let{x:s,y:c,width:a,height:u}=e.region;if(s<0||c<0||a<=0||u<=0||s+a>1||c+u>1)throw new Error("Image region x,y,width,height must fit within normalized bounds 0..1")}if(e.cellIndex!==void 0&&e.cellSize===void 0)throw new Error("Image offset requires limit to set the square grid cell size");if(e.cellSize!==void 0&&(!Number.isSafeInteger(e.cellSize)||e.cellSize<=0))throw new Error("Image limit must be a positive integer pixel size");if(e.cellIndex!==void 0&&(!Number.isSafeInteger(e.cellIndex)||e.cellIndex<0))throw new Error("Image offset must be a zero-based cell index");return e}d(V,"validateVisionOptions");async function I(e,t,n){let r=V(t),s=r.mode==="image"?1:Math.floor(r.durationSeconds/r.intervalSeconds)+1,c=[],a=0;for(let u=0;u<s;u+=1){n?.throwIfAborted(),u>0&&await Ne(r.intervalSeconds*1e3,n);let i=await e();if(a+=i.byteLength,a>k)throw new Error("Captured images exceed the 20MB aggregate limit");for(let o of await Ee(i,r))c.push({type:"image",data:Buffer.from(o).toString("base64"),mimeType:"image/png"})}return c}d(I,"captureImages");async function Ee(e,t){let n=await Se(e),r=t.region??{x:0,y:0,width:1,height:1},s=Math.round(r.x*n.width),c=Math.round(r.y*n.height),a=Math.max(1,Math.round(r.width*n.width)),u=Math.max(1,Math.round(r.height*n.height)),i=t.scale??1,o=Math.max(1,Math.round(a*i)),w=Math.max(1,Math.round(u*i)),f=ae(o,w);if(f.getContext("2d").drawImage(n,s,c,a,u,0,0,o,w),t.cellSize===void 0)return[await f.encode("png")];let m=Math.ceil(o/t.cellSize),l=Math.ceil(w/t.cellSize),p=t.cellIndex??0;if(p>=m*l)throw new Error(`Image cell offset ${p} exceeds the ${m}x${l} grid`);let g=p%m,N=Math.floor(p/m),A=g*t.cellSize,b=N*t.cellSize,P=Math.min(t.cellSize,o-A),x=Math.min(t.cellSize,w-b),L=ae(P,x);return L.getContext("2d").drawImage(f,A,b,P,x,0,0,P,x),[await L.encode("png")]}d(Ee,"selectImage");function Ae(e,t){return e&&t==="windows"}d(Ae,"usesWindowsHostWindowCapture");function fe(){return{async captureWindow(e,t,n){if(n?.throwIfAborted(),Ae(M(),t))return Re(e,n);if(process.platform!=="linux"&&process.platform!=="darwin")throw new Error(`Window capture is unsupported on ${process.platform}`);let{Window:r}=await import("node-screenshots"),s;try{s=r.all()}catch(u){throw new Error(`Desktop window enumeration is unavailable: ${ce(u)}`,{cause:u})}let c=s.find(u=>{try{return u.pid()===e}catch{return!1}});if(c===void 0)throw new Error(`No capturable desktop window belongs to PID ${e}`);let a=await c.captureImage();return n?.throwIfAborted(),new Uint8Array(await a.toPng())},async captureDisplay(e,t){if(t?.throwIfAborted(),M())return De(e,t);if(process.platform!=="linux"&&process.platform!=="darwin"&&process.platform!=="win32")throw new Error(`Display capture is unsupported on ${process.platform}`);let{Monitor:n}=await import("node-screenshots"),r;try{r=n.all()}catch(a){throw new Error(`Desktop display enumeration is unavailable: ${ce(a)}`,{cause:a})}let s=r[e];if(s===void 0)throw new Error(`Display index ${e} is unavailable; found ${r.length} display(s)`);let c=await s.captureImage();return t?.throwIfAborted(),new Uint8Array(await c.toPng())},async captureUrl(e,t){if(e.protocol!=="http:"&&e.protocol!=="https:")throw new Error("Web screenshots require an HTTP(S) URL");let{chromium:n}=await import("playwright-core"),r=await Ce(),s=await n.launch({executablePath:r,headless:!0,chromiumSandbox:!1,timeout:3e4}),c=d(()=>{s.close()},"abort");t?.addEventListener("abort",c,{once:!0});try{let a=await s.newPage({viewport:{width:1280,height:720}});return await a.goto(e.href,{waitUntil:"domcontentloaded",timeout:3e4}),await a.waitForLoadState("networkidle",{timeout:1500}).catch(()=>{}),t?.throwIfAborted(),new Uint8Array(await a.screenshot({type:"png",fullPage:!0}))}finally{t?.removeEventListener("abort",c),await s.close().catch(()=>{})}}}}d(fe,"createCaptureBackend");async function Re(e,t){let n=new URL("windows-window-capture.ps1",new URL("../src/plugins/pi-agent-ide-vision/src/vision.ts",import.meta.url).href);t?.throwIfAborted();let{stdout:r}=await v("wslpath",["-w",n.pathname],{signal:t}),{stdout:s}=await v("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-File",r.trim(),"-ProcessId",String(e)],{encoding:"buffer",maxBuffer:k,signal:t});return new Uint8Array(s)}d(Re,"captureWslWindow");async function De(e,t){let n=new URL("windows-display-capture.ps1",new URL("../src/plugins/pi-agent-ide-vision/src/vision.ts",import.meta.url).href);t?.throwIfAborted();let{stdout:r}=await v("wslpath",["-w",n.pathname],{signal:t}),{stdout:s}=await v("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-File",r.trim(),"-DisplayIndex",String(e)],{encoding:"buffer",maxBuffer:k,signal:t});return new Uint8Array(s)}d(De,"captureWslDisplay");function M(){return process.platform==="linux"&&(process.env.WSL_DISTRO_NAME!==void 0||Pe.release().toLowerCase().includes("microsoft"))}d(M,"isWsl");async function Ce(){let e=process.env.PI_AGENT_IDE_BROWSER_PATH;if(e!==void 0)return e;let{stdout:t}=await v("bash",["-lc","command -v google-chrome-stable || command -v google-chrome || command -v chromium || command -v chromium-browser"]),n=t.trim();if(n.length===0)throw new Error("No Chrome or Chromium executable was found; set PI_AGENT_IDE_BROWSER_PATH");return n}d(Ce,"resolveBrowser");function Ne(e,t){return new Promise((n,r)=>{let s=setTimeout(n,e),c=d(()=>{clearTimeout(s),r(t?.reason??new Error("Capture aborted"))},"abort");t?.addEventListener("abort",c,{once:!0}),s.unref()})}d(Ne,"delay");function ce(e){return e instanceof Error?e.message:String(e)}d(ce,"errorMessage");async function ye(e,t,n,r){F(e,[await z({id:"vision",description:"Window, display, image, and sequence capture",triggers:[{tool:"read",resourcePrefixes:["process:","window:","display:"]},{tool:"read",resourcePrefixes:["web:ssh://"],viewPrefixes:["image","sequence"]}]})]);let s=t?.preferences??{};le({durationSeconds:s["vision.sequenceDurationSeconds"],intervalSeconds:s["vision.sequenceIntervalSeconds"],scale:s["vision.imageScale"],allowedExecutables:s["vision.allowedExecutables"]});let c=oe(e),a=fe();await Promise.all([H(e,ie),G(e,{protocol:j,apiVersion:Y,id:"vision",setup(u){for(let i of["image","sequence"])u.addView({contentKind:"any",view:i,presenter:{id:`vision-${i}`,present:d(o=>o,"present")}});u.addHandler({stage:"pre-read",async handler(i){let o=i.request.path;if(o===void 0)return{kind:"continue",context:i};if(o.startsWith("window:ssh://")||o.startsWith("display:ssh://"))try{let l=o.startsWith("window:"),p=new URL(o.slice(l?7:8));if(p.username||p.password||p.port||p.search||(l?p.hash!==""||!/^\/[1-9][0-9]*$/u.test(p.pathname):p.pathname!=="/"||p.hash!==""&&!/^#\d+$/u.test(p.hash)))throw new Error(`Invalid target capture resource: ${o}`);if(!l&&e.getFlag("pi-agent-ide-vision-displays")!==!0)return h(o,"Display capture is disabled. Enable --pi-agent-ide-vision-displays to allow it.");if(!r)return h(o,`Target capture is unavailable: ${o}`);let g=Number(l?p.pathname.slice(1):p.hash.slice(1)||"0");if(!Number.isSafeInteger(g))throw new Error(`Invalid target capture resource: ${o}`);let N=await I(async()=>{if(!l)return r.captureDisplay(o,g,i.resolverContext.signal);let A=`process:ssh://${p.hostname}/${g}`,b=await n?.read(A,i.resolverContext.signal);if(!b||b.resource!==A||b.pid!==g||b.target!==p.hostname)throw new Error(`Target process identity is unavailable: ${o}`);let P=D(b,c),x=P.executable;if(!P.owned&&(!x||!pe(x))&&e.getFlag("pi-agent-ide-vision-arbitrary-windows")!==!0)throw new Error(`Window capture is denied for the target executable: ${o}`);return r.captureWindow(o,P,i.resolverContext.signal)},R(i.request),i.resolverContext.signal);return S(o,N)}catch(l){return h(o,E(l))}if(o.startsWith("web:")&&he(i.request))try{let l=r?.captureWeb?.bind(r);if(!l)return h(o,`Target web capture is unavailable: ${o}`);let p=await I(()=>l(o,i.resolverContext.signal),R(i.request),i.resolverContext.signal);return S(o,p)}catch(l){return h(o,E(l))}let w=me(o);if(w!==void 0){if(e.getFlag("pi-agent-ide-vision-displays")!==!0)return h(o,"Display capture is disabled. Enable --pi-agent-ide-vision-displays to allow it.");try{let l=await I(()=>a.captureDisplay(w,i.resolverContext.signal),R(i.request),i.resolverContext.signal);return S(o,l)}catch(l){return h(o,E(l))}}try{let l=await n?.read(o,i.resolverContext.signal);if(l)return S(o,[{type:"text",text:U(D(l,c))}])}catch(l){return h(o,E(l))}let f=ge(o,"process:");if(f!==void 0){let l=await W(f,c);return S(o,[{type:"text",text:U(l)}])}let m=ge(o,"window:");if(m!==void 0){let l=await W(m,c);if(!l.owned&&!ue(l.command)&&e.getFlag("pi-agent-ide-vision-arbitrary-windows")!==!0)return h(o,`Window capture for PID ${m} is denied because the process is neither Agent IDE-owned nor allowlisted by executable name. Enable --pi-agent-ide-vision-arbitrary-windows to allow it.`);try{let p=await I(()=>a.captureWindow(m,l.host,i.resolverContext.signal),R(i.request),i.resolverContext.signal);return S(o,p)}catch(p){return h(o,E(p))}}if(/^https?:\/\//iu.test(o)&&he(i.request)){let l=new URL(o);try{let p=await I(()=>a.captureUrl(l,i.resolverContext.signal),R(i.request),i.resolverContext.signal);return S(l.href,p)}catch(p){return h(l.href,E(p))}}return{kind:"continue",context:i}}}),u.describe({path:d(()=>`process:ssh://target/PID, window:ssh://target/PID and display:ssh://target/ select configured Linux SSH targets; missing target facilities fail without local fallback. web:ssh://target/https://\u2026 captures with target-installed Playwright/Chromium. process:PID \u2014 process metadata. window:PID \u2014 capture a window of an IDE-owned or allowlisted process${e.getFlag("pi-agent-ide-vision-arbitrary-windows")===!0?"; arbitrary windows are enabled":"; other processes require --pi-agent-ide-vision-arbitrary-windows"}. display: or display:#N \u2014 display capture with a zero-based index; ${e.getFlag("pi-agent-ide-vision-displays")===!0?"enabled":"requires --pi-agent-ide-vision-displays"}. HTTP(S) URLs accept image or sequence screenshots.`,"path"),views:d(()=>{let i=C();return`image or image:scale=S,region=X,Y,W,H \u2014 one screenshot. sequence or sequence:duration=D,interval=I,scale=S,region=X,Y,W,H \u2014 timed frames. Only one image/sequence view per request. duration and interval are seconds and only valid for sequence: 0 < D <= 10, I > 0, at most 20 frames (floor(D/I)+1). Scale satisfies 0 < S <= 1. Region uses normalized x,y,width,height: x,y >= 0, width,height > 0, and the rectangle must fit in 0..1; crop runs before scaling. Settings are optional; defaults: duration=${i.durationSeconds}, interval=${i.intervalSeconds}, scale=${i.scale}.`},"views"),offset:"For window:, display: and HTTP(S) image/sequence captures, a non-negative integer zero-based row-major grid cell index in the transformed image. Requires limit; omit to select cell 0 when limit is set.",limit:"For window:, display: and HTTP(S) image/sequence captures, a positive integer square grid cell size in output pixels. Omit both offset and limit for the bounded transformed image."})}}),Q(e,{protocol:J,apiVersion:K,id:"vision-processes",setup(u){u.addResolver({priority:-100,resolver:{id:"processes",readResources:d(i=>/^process:/iu.test(i.query)?void 0:[],"readResources"),toScriptData(i){return{kind:"custom",resolverId:"processes",value:{processes:i.map(w=>({pid:w.pid,command:w.command,...w.host==="ssh"?{host:w.host,target:w.target,resource:w.resource,identity:w.identity,owned:w.owned,parentPid:w.parentPid,started:w.started,executable:w.executable,...w.source===void 0?{}:{source:w.source}}:{}}))}}},async tryResolve(i,o){let w=/^process:(.*)$/isu.exec(i.query);if(w===null)return{kind:"not-handled"};let f=(w[1]??"").trim().toLowerCase(),m=i.path??o.cwd,l=await n?.list(m,o.signal);if(m.includes("://")&&l===void 0)throw new Error("Process scope has no resource owner");return{kind:"resolved",payload:(l?.map(g=>D(g,c))??await T(c)).filter(g=>f.length===0||String(g.pid)===f||g.command.toLowerCase().includes(f)).slice(0,Math.min(i.limit??50,100))}},renderResult(i,o,w){let f=i.details;return new X({summary:`${f.processes.length} processes shown`,rows:f.processes.length?f.processes.map(m=>({kind:"note",text:`${m.pid} ${m.command}`})):[{kind:"note",text:"No matching processes"}]},w,o.expanded)},format(i){let o=i;return{content:[{type:"text",text:o.length===0?"No matching processes.":o.map(U).join(`
|
|
3
|
+
|
|
4
|
+
`)}],details:{count:o.length,processes:o}}}}}),u.describe("process:<query> finds running processes by PID or command. Select a configured Linux target with an SSH path; its results retain process:ssh://target/PID, target and kernel start identity. Use process:PID for local metadata. Use window:ssh://target/PID for authorized target capture, never window:PID with a remote PID. Discovery alone does not grant capture or process control.")}})])}d(ye,"registerVisionWithOwner");function ge(e,t){if(!e.startsWith(t))return;let n=e.slice(t.length);if(!/^\d+$/u.test(n))throw new Error(`${t} sources require a numeric PID`);return Number(n)}d(ge,"prefixedPid");function R(e){return{...we(e.views,C())??{mode:"image",...C()},...e.limit===void 0?{}:{cellSize:e.limit},...e.offset===void 0?{}:{cellIndex:e.offset}}}d(R,"options");function he(e){return e.views?.some(t=>/^(?:image|sequence)(?::|$)/u.test(t))===!0}d(he,"requestsScreenshot");function S(e,t){return{kind:"return",result:{content:t,script:{kind:"native",source:e,blocks:t},details:{source:e,resolvedBy:"vision"}}}}d(S,"returned");function h(e,t){return{kind:"return",result:{content:[{type:"text",text:t}],details:{source:e,resolvedBy:"vision",failure:{code:"READ_FAILED",source:e,resolverId:"vision",message:t}},isError:!0}}}d(h,"failed");function E(e){return e instanceof Error?e.message:String(e)}d(E,"errorMessage");function U(e){return[`PID: ${e.pid}`,...e.host==="ssh"?[`Target: ${e.target}`,`Resource: ${e.resource}`,`Identity: ${e.identity}`]:[],`Command: ${e.command}`,`Owned by Agent IDE: ${e.owned?"yes":"no"}`,...e.host==="ssh"&&e.executable!==null?[`Executable: ${e.executable}`]:[],...e.parentPid===void 0?[]:[`Parent PID: ${e.parentPid}`],...e.started===void 0?[]:[`Started: ${e.started}`],...e.source===void 0?[]:[`Agent IDE source: ${e.source}`]].join(`
|
|
5
|
+
`)}d(U,"formatProcess");function $e(e){return{async read(t,n){if(!t.startsWith("process:ssh://"))return;let r=new URL(t.slice(8));if(r.username||r.password||r.port||r.search||r.hash||!/^\/[1-9][0-9]*$/u.test(r.pathname))throw new y("INVALID_SOURCE",t,"not-applied");try{let[s]=await $(e,`ssh://${r.hostname}/`,Number(r.pathname.slice(1)),n);if(!s)throw new y("ENOENT",t,"not-applied");return s}catch(s){throw s instanceof y?new y(s.code,t,s.effect):s}},async list(t,n){if(t.startsWith("ssh://"))return $(e,t,void 0,n)}}}d($e,"createSshProcessOwner");function Oe(e){return{captureWindow(t,n,r){if(!n.executable)throw new y("CAPABILITY_UNAVAILABLE",t,"not-applied");return O(e,t,{kind:"window",pid:n.pid,identity:n.identity,executable:n.executable},r)},async captureWeb(t,n){let r=se(t);if(!r)throw new y("INVALID_SOURCE",t,"not-applied");try{let s=e.resolve(`ssh://${r.target}/`);if(!s)throw new y("UNSUPPORTED_SOURCE",t,"not-applied");return await re(s.backend.target,r.url,t,n)}catch(s){throw s instanceof y?new y(s.code,t,s.effect):s}},captureDisplay(t,n,r){return O(e,t,{kind:"display",index:n},r)}}}d(Oe,"createSshCaptureOwner");async function Me(e,t){let n=new ne(await te(ee(Z())));await ye(e,t,$e(n),Oe(n))}d(Me,"registerOwnedVision");export{Oe as createSshCaptureOwner,$e as createSshProcessOwner,Me as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{f as m,j as g,k as x,o as h}from"./chunk-R5XJSEOE.js";import{a as i}from"./chunk-EI7MMDWY.js";import{Type as r}from"typebox";import{Value as y}from"typebox/value";import{Type as l}from"typebox";var u=l.Object({path:l.Optional(l.String({description:"What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# or RESULT# reference, or registered protocol source. Supply a path; an empty call cannot select a source."})),offset:l.Optional(l.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor, SEARCH or RESULT# selections, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit."})),limit:l.Optional(l.Number({description:"For raw: sources, use a non-negative byte count (0 reads no bytes). Otherwise, maximum lines from the selected starting position. Output is bounded; omit for the default read. For image and sequence views, limit is the square grid cell size in pixels; omit offset to select cell 0, or omit both for the bounded full image."})),views:l.Optional(l.Array(l.String(),{description:`Optional source-specific presentations. Combine views when both presentations are needed, for example ["anchors", "ast"]. Omit for the source's default presentation.`}))}),L={path:"Source to read: a resource path, unchanged source result or its UUID. Supply a source; an empty call cannot select one. temp:<id> reads saved output. raw:<local-file> reads original bytes from a regular file; relative, absolute and file:// paths are accepted.",offset:"For raw: sources, a zero-based integer byte offset; negative offsets count from the file end. For text sources, the first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end.",limit:"For raw: sources, a non-negative integer byte count (0 reads no bytes). For text sources, the maximum lines from the selected starting position. Omit for the default read. For other non-text sources, use only a range form described for that source.",views:"Source-specific presentations. Omit for the source's default presentation. Supply settings after a colon using the syntax below. Combine views only when their contracts allow it. raw: sources do not accept views."};function _(e){let n=i((s,a)=>({...s,description:[L[a],e[a]].filter(R=>R!==void 0).join(`
|
|
2
|
+
`)}),"describe");return{...u,properties:{path:n(u.properties.path,"path"),offset:n(u.properties.offset,"offset"),limit:n(u.properties.limit,"limit"),views:n(u.properties.views,"views")}}}i(_,"describeReadParameters");import{Type as t}from"typebox";var k=t.Object({value:t.String(),kind:t.String(),state:t.Optional(t.String())},{additionalProperties:!1}),w=t.Object({lineNumber:t.Integer(),content:t.String(),lineEnding:t.String(),anchors:t.Optional(t.Array(t.String()))},{additionalProperties:!1}),P=t.Object({path:t.String(),offset:t.Integer()},{additionalProperties:!1}),f={source:t.String(),truncated:t.Boolean(),continuation:t.Optional(P),fullResult:t.Optional(t.String())},b=t.Object({...f,kind:t.Literal("text"),target:t.Optional(t.String()),lines:t.Array(w),startLine:t.Integer(),endLine:t.Integer(),totalLines:t.Integer(),references:t.Optional(t.Array(k))},{additionalProperties:!1}),S=t.Object({...f,kind:t.Literal("bytes"),bytes:t.Array(t.Integer({minimum:0,maximum:255})),byteOffset:t.Integer(),byteLength:t.Integer(),totalBytes:t.Integer()},{additionalProperties:!1}),v=t.Union([t.Object({type:t.Literal("text"),text:t.String()},{additionalProperties:!1}),t.Object({type:t.Literal("image"),mimeType:t.String()},{additionalProperties:!1})]),T=t.Object({...f,kind:t.Literal("native"),blocks:t.Array(v)},{additionalProperties:!1}),p=t.Union([t.Object({kind:t.Literal("recovery"),source:t.String(),candidates:t.Array(t.Object({path:t.String()},{additionalProperties:!1}))},{additionalProperties:!1}),b,S,T,t.Object({kind:t.Literal("resources"),source:t.Optional(t.String()),resources:t.Array(t.Union([b,S,T])),truncated:t.Boolean(),fullResult:t.Optional(t.String())},{additionalProperties:!1})]),C=m(p);function E(e){return{lineNumber:e.lineNumber,content:e.content,lineEnding:e.lineEnding,...e.anchors===void 0?{}:{anchors:[...e.anchors]}}}i(E,"publicLine");function O(e){if(e.kind==="resources"){let o=e.resources.map(d=>O(d));return{kind:e.kind,...e.source===void 0?{}:{source:e.source},resources:o,truncated:o.some(d=>typeof d=="object"&&d!==null&&"truncated"in d&&d.truncated===!0)}}if(e.kind==="bytes"){let o=e.bytes.slice(0,32768),d=e.truncated===!0||o.length<e.bytes.length;return{kind:e.kind,source:e.source,bytes:o,byteOffset:e.byteOffset,byteLength:o.length,totalBytes:e.totalBytes,truncated:d,...e.byteOffset+o.length<e.totalBytes?{continuation:{path:e.source,offset:e.byteOffset+o.length}}:{}}}if(e.kind==="native")return{kind:e.kind,source:e.source,truncated:!1,blocks:e.blocks.map(o=>{if(o.type==="text")return{type:o.type,text:o.text};if(o.type==="image")return{type:o.type,mimeType:o.mimeType};throw new TypeError("Custom content requires a structured adapter")})};let n=[],s=0;for(let o of e.lines){let d=E(o);if(s+=Buffer.byteLength(JSON.stringify(d)),n.length>=2e3||s>512*1024)break;n.push(d)}if(n.length===0&&e.lines.length>0)throw new RangeError("Selected line exceeds the structured window; use a raw byte range or a source-specific view");let a=n.length<e.lines.length,R=n.at(-1)?.lineNumber??e.startLine-1;return{kind:e.kind,source:e.source,...e.target===void 0?{}:{target:e.target},lines:n,startLine:n[0]?.lineNumber??0,endLine:n.at(-1)?.lineNumber??0,totalLines:e.totalLines,truncated:a,...e.target===void 0?{}:{target:e.target},...e.references===void 0?{}:{references:e.references},...a||R<e.totalLines?{continuation:{path:e.source,offset:R+1}}:{}}}i(O,"publicData");function D(e){let n=e.details.failure,s=n?.cause instanceof x?n.cause:void 0;if(e.isError||n!==void 0)return g(e,p,{status:"error",...n?.candidates?.length&&n.source!==void 0?{data:{kind:"recovery",source:n.source,candidates:n.candidates}}:{},errors:[{code:s?.code??n?.code??"READ_FAILED",message:s===void 0?n?.message??"Read failed":`${s.code}: ${n?.source??s.source}`,...n?.source===void 0?{}:{source:n.source}}]});try{if(e.script===void 0)throw new TypeError("Read handler must return structured script data");let a=O(e.script);return g(e,p,{status:"success",data:e.details.temporarySource!==void 0&&typeof a=="object"&&a!==null?{...a,fullResult:e.details.temporarySource}:a,errors:[]})}catch(a){return g(e,p,{status:"error",errors:[{code:a instanceof RangeError?"STRUCTURED_RESULT_TOO_LARGE":"STRUCTURED_ADAPTER_REQUIRED",message:a instanceof Error?a.message:String(a)}]})}}i(D,"structuredRead");var c=r.Function([],r.Unknown()),A=r.Object({resolver:r.Unknown(),matchesCall:r.Optional(c),renderCall:r.Optional(c),priority:r.Optional(r.Number()),renderResult:r.Optional(c),preserveTruncatedOutput:r.Optional(r.Boolean())}),F=r.Object({resolver:r.Unknown(),priority:r.Optional(r.Number())}),N=r.Object({id:r.String({pattern:"\\S"}),priority:r.Optional(r.Number()),resolve:c}),U=r.Object({view:r.String({pattern:"\\S"}),contentKind:r.Optional(r.Union([r.Literal("text"),r.Literal("any")])),includes:r.Optional(r.Array(r.String({pattern:"\\S"}))),presenter:r.Object({id:r.String(),present:c}),priority:r.Optional(r.Number())}),j=r.Object({resolvedBy:r.String({pattern:"\\S"}),contentKind:r.Union([r.Literal("text"),r.Literal("any")])}),I=r.Union([r.Object({stage:r.Literal("pre-read"),handler:c}),r.Object({stage:r.Literal("read"),when:j,handler:c}),r.Object({stage:r.Literal("post-read"),handler:c})]);function J(e){if(!y.Check(F,e))return!1;let n=e,s=n.resolver;return typeof s.id=="string"&&s.id.length>0&&typeof s.tryResolve=="function"&&(!("priority"in n)||typeof n.priority=="number")}i(J,"isTextTargetResolverRegistration");function Y(e){if(!y.Check(A,e))return!1;let n=e;return h(n.resolver)?n.resolver.id!=="any"&&(!("priority"in n)||typeof n.priority=="number")&&(!("matchesCall"in n)||typeof n.matchesCall=="function")&&(!("renderCall"in n)||typeof n.renderCall=="function")&&"matchesCall"in n=="renderCall"in n&&(!("renderResult"in n)||typeof n.renderResult=="function"):!1}i(Y,"isResourceResolverRegistration");function X(e){return y.Check(I,e)}i(X,"isReadHandlerRegistration");function Z(e){return y.Check(U,e)}i(Z,"isReadViewRegistration");function ee(e){return y.Check(N,e)}i(ee,"isFragmentResolverRegistration");function te(e){return B(e)?e.kind==="not-handled"?!0:e.kind==="failed"?typeof e.message=="string"&&e.message.length>0:e.kind==="resolved"&&typeof e.originLine=="number":!1}i(te,"isReadFragmentResolution");function B(e){return typeof e=="object"&&e!==null}i(B,"isRecord");export{u as a,_ as b,p as c,C as d,D as e,J as f,Y as g,X as h,Z as i,ee as j,te as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as a,e as s}from"./chunk-756K3LJY.js";import{a as t}from"./chunk-EI7MMDWY.js";import{access as b}from"node:fs/promises";async function p(r,o){if(r.signal?.throwIfAborted(),r.workspace)return r.workspace.exists(o,r.signal);if(o.includes("://"))throw Object.assign(new Error("Doctor needs the file owner"),{code:"UNSUPPORTED_SOURCE"});try{return await b(o),r.signal?.throwIfAborted(),!0}catch(e){if(r.signal?.throwIfAborted(),typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT")return!1;throw e}}t(p,"projectFileExists");async function f(r,o,e){if(r.signal?.throwIfAborted(),!r.workspace){let n=await s(o,e,r.cwd,r.env,r.signal);return r.signal?.throwIfAborted(),n}let i=await r.workspace.run({command:[o,...e],timeoutMs:5e3},r.cwd,r.signal);r.signal?.throwIfAborted();let l=(i.stdout.trim()||i.stderr.trim()).split(/\r?\n/u)[0]||`${o} exited with code ${String(i.exitCode)}`;return{ok:i.ok,detail:l}}t(f,"probeProjectExecutable");async function c(r,o){if(r.signal?.throwIfAborted(),!r.workspace)return a(o,r.cwd,r.env,r.signal);let e=await r.workspace.executableAvailability([{command:[o]}],r.signal);if(r.signal?.throwIfAborted(),e.length!==1||typeof e[0]!="boolean")throw new TypeError("Invalid Doctor availability report");return e[0]}t(c,"projectExecutableAvailable");export{p as a,f as b,c};
|