pi-agent-ide 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +5 -3
- package/dist/{chunk-TGC2ZACO.js → chunk-235QMMVA.js} +1 -1
- package/dist/{chunk-OI3HBIPK.js → chunk-4DIUPEDF.js} +1 -1
- package/dist/{chunk-2ITKAXHO.js → chunk-6FGLAVPJ.js} +1 -1
- package/dist/{chunk-7LOVUWNI.js → chunk-6H32W35W.js} +1 -1
- package/dist/{chunk-YHREORHH.js → chunk-6OJ565FL.js} +1 -1
- package/dist/{chunk-E2PHA4SQ.js → chunk-6R3Y4AD3.js} +1 -1
- package/dist/{chunk-VNTY7BKC.js → chunk-6T7PSDQW.js} +1 -1
- package/dist/{chunk-D4IA2MTA.js → chunk-6TJPMBUQ.js} +1 -1
- package/dist/{chunk-JKMXND6V.js → chunk-6XFUICD7.js} +1 -1
- package/dist/chunk-7VSVJRRF.js +28 -0
- package/dist/{chunk-A64JRDZK.js → chunk-AAC77UD4.js} +1 -1
- package/dist/{chunk-HFJGCYFO.js → chunk-ANM3Y5FO.js} +5 -5
- package/dist/{chunk-Q5X6OXNS.js → chunk-CPELC6JE.js} +1 -1
- package/dist/chunk-FTPC44FP.js +33 -0
- package/dist/{chunk-3WO2NOEQ.js → chunk-GSOYVIQS.js} +1 -1
- package/dist/{chunk-AIT3YWR5.js → chunk-HSRH76JN.js} +1 -1
- package/dist/{chunk-ID4RJIVZ.js → chunk-HSZ4AQ6L.js} +1 -1
- package/dist/chunk-I6NPILT5.js +1 -0
- package/dist/chunk-K7SRNBIV.js +1 -0
- package/dist/{chunk-DXONCYWF.js → chunk-LCWBVOII.js} +3 -3
- package/dist/{chunk-EMRJP6EM.js → chunk-LEJKDYCK.js} +1 -1
- package/dist/{chunk-HCK7OIQ3.js → chunk-NJ7C4KMA.js} +1 -1
- package/dist/{chunk-BQAKA3FU.js → chunk-NUM3YQGK.js} +1 -1
- package/dist/chunk-OJEIX7OZ.js +1 -0
- package/dist/{chunk-4HWKBCBH.js → chunk-PJL3UVMJ.js} +1 -1
- package/dist/{chunk-AKNHSDGV.js → chunk-QT3EAHOG.js} +1 -1
- package/dist/{chunk-LLRUJD62.js → chunk-RIJMXO43.js} +1 -1
- package/dist/chunk-RMI3NMQY.js +23 -0
- package/dist/chunk-RQ7JJ7GV.js +4 -0
- package/dist/{chunk-AUL5FGGK.js → chunk-RVU73VKN.js} +1 -1
- package/dist/{chunk-WPBQ45ZL.js → chunk-RW2GTYQI.js} +1 -1
- package/dist/{chunk-BR7GRH4A.js → chunk-SDAH3ECM.js} +1 -1
- package/dist/chunk-SGQWRIRJ.js +10 -0
- package/dist/{chunk-N56WAVYA.js → chunk-SMIFCAAX.js} +1 -1
- package/dist/chunk-SWBJS3U4.js +1 -0
- package/dist/{chunk-WXGTU2M6.js → chunk-VMTOFEXF.js} +1 -1
- package/dist/{chunk-GEMDU6XW.js → chunk-VXP5BMW7.js} +1 -1
- package/dist/{chunk-LAJQSHEI.js → chunk-XAHU42FP.js} +3 -3
- package/dist/{chunk-ZV5ETNLQ.js → chunk-XBQR74IK.js} +1 -1
- package/dist/{chunk-TXG2H7YQ.js → chunk-XG7QNAKW.js} +1 -1
- package/dist/{chunk-PRLIHLCS.js → chunk-XLWCSJMR.js} +1 -1
- package/dist/{chunk-M4TVRCMZ.js → chunk-XXLLY66B.js} +1 -1
- package/dist/chunk-YFP4P2FV.js +1 -0
- package/dist/{chunk-SWA5B5B2.js → chunk-YIXP2ALP.js} +1 -1
- package/dist/{chunk-246NTPOS.js → chunk-ZJQRLVVV.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-1.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-16.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-18.js +1 -1
- package/dist/entry-19.js +1 -0
- package/dist/entry-2.js +1 -1
- package/dist/entry-20.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 -1
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +1 -2
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +2 -4
- package/dist/entry-3.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +4 -1
- package/dist/entry-32.js +1 -1
- package/dist/entry-33.js +1 -18
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +18 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -1
- 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 -1
- package/dist/entry-46.js +1 -1
- package/dist/entry-47.js +1 -25
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +25 -1
- package/dist/entry-5.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -3
- package/dist/entry-53.js +1 -13
- package/dist/entry-54.js +3 -1
- package/dist/entry-55.js +13 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-6.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -0
- package/dist/entry-64.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +0 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-7.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +1 -1
- package/dist/entry-72.js +1 -1
- package/dist/entry-73.js +1 -0
- package/dist/entry-74.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +0 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -80
- package/dist/entry-8.js +1 -1
- package/dist/entry-80.js +1 -22
- package/dist/entry-81.js +80 -2
- package/dist/entry-82.js +22 -1
- package/dist/entry-83.js +2 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -3
- package/dist/entry-86.js +1 -1
- package/dist/entry-87.js +1 -1
- package/dist/entry-88.js +3 -1
- package/dist/entry-89.js +1 -0
- package/dist/entry-9.js +1 -1
- package/dist/entry-90.js +1 -0
- package/dist/entry-91.js +1 -0
- package/dist/pi-agent-ide.js +29 -36
- package/docs/agent-guides/debugger.md +2 -0
- package/docs/agent-guides/editing.md +3 -3
- package/docs/agent-guides/search-code.md +2 -2
- package/docs/agent-guides/select-code.md +9 -6
- package/docs/code-review.md +5 -0
- package/docs/configuration.md +36 -4
- package/docs/development.md +8 -0
- package/docs/directory-operations.md +1 -1
- package/docs/extensions.md +98 -1
- package/docs/structured-results.md +11 -6
- package/docs/user-hooks.md +2 -2
- package/node_modules/pi-agent-doctor/package.json +7 -7
- package/node_modules/pi-agent-doctor/runtime/entry-27.js +1 -0
- package/node_modules/pi-agent-documentation/package.json +2 -2
- package/node_modules/pi-agent-documentation/runtime/entry-28.js +1 -0
- package/node_modules/pi-agent-filesystem/package.json +8 -8
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-jq/package.json +6 -6
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-pdf/runtime/entry-32.js +2 -0
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-ide-ast/package.json +15 -15
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +6 -5
- package/node_modules/pi-agent-ide-changes/package.json +10 -10
- package/node_modules/pi-agent-ide-changes/runtime/entry-36.js +1 -0
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +6 -5
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/runtime/entry-40.js +2 -0
- package/node_modules/pi-agent-ide-lsp/package.json +10 -10
- package/node_modules/pi-agent-ide-lsp/runtime/entry-41.js +2 -0
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-invariant/package.json +2 -2
- package/node_modules/pi-agent-pdf/package.json +3 -3
- package/node_modules/pi-agent-read/package.json +12 -12
- package/node_modules/pi-agent-read/runtime/entry-47.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-49.js +2 -0
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-resource/src/resource-error.ts +11 -0
- package/node_modules/pi-agent-search/package.json +9 -9
- package/node_modules/pi-agent-search/runtime/entry-52.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-53.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-54.js +2 -0
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +6 -5
- package/node_modules/pi-agent-search-text/package.json +14 -14
- package/node_modules/pi-agent-search-text/runtime/entry-55.js +1 -0
- package/node_modules/pi-agent-search-text/runtime/entry-58.js +1 -0
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-64.js +2 -0
- package/node_modules/pi-agent-text-editor/index.ts +2 -0
- package/node_modules/pi-agent-text-editor/package.json +26 -26
- package/node_modules/pi-agent-text-editor/runtime/entry-79.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-80.js +1 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +5 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +45 -44
- 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/native-text-edit-batch.ts +27 -18
- package/node_modules/pi-agent-text-editor/src/core/text-edit-origin.ts +38 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +106 -48
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +29 -6
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +39 -44
- package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +6 -5
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +14 -3
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +17 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +6 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-83.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-84.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +6 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-85.js +1 -0
- package/node_modules/pi-agent-tool-ui/runtime/entry-86.js +1 -0
- package/node_modules/pi-agent-tool-ui/src/operation-approval.ts +271 -0
- package/node_modules/pi-agent-web/package.json +8 -8
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-image/runtime/entry-89.js +2 -0
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-90.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-91.js +2 -0
- package/package.json +62 -54
- package/src/api/approval.ts +5 -0
- package/src/api/settings.ts +198 -0
- package/src/backend/debugger-registration.ts +5 -1
- package/src/code-review/extension.ts +10 -4
- package/src/code-review/reviewer.ts +8 -0
- package/src/composite/host-version.ts +29 -5
- package/src/composite/ide-alias-rendering.ts +97 -0
- package/src/composite/nested-tool-rendering.ts +74 -4
- package/src/composite/search-facts.ts +45 -0
- package/src/composite/settings-documentation.ts +32 -23
- package/src/composite/settings-registry.ts +94 -0
- package/src/composite/text-results.ts +120 -8
- package/src/composite/tool-availability.ts +11 -2
- package/src/core/diagnostic-entry.ts +31 -8
- package/src/core/diagnostic-store.ts +19 -3
- package/src/core/extension.ts +7 -2
- package/src/documentation/registry.ts +10 -2
- 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/package.json +6 -6
- 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-pdf/runtime/entry-32.js +2 -0
- 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-33.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-29.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-89.js +2 -0
- 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-pdf/runtime/entry-90.js +2 -0
- 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-91.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-87.js +2 -0
- package/src/extensions/pi-agent-read/package.json +12 -12
- package/src/extensions/pi-agent-read/runtime/entry-47.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-48.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-49.js +2 -0
- package/src/extensions/pi-agent-search/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -14
- 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/runtime/entry-57.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-58.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-52.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-53.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-54.js +2 -0
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +6 -5
- package/src/extensions/pi-agent-text-editor/index.ts +2 -0
- package/src/extensions/pi-agent-text-editor/package.json +26 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
- 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-63.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-64.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-82.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +14 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +17 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +6 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-79.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-80.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-81.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +5 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +45 -44
- 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/native-text-edit-batch.ts +27 -18
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-origin.ts +38 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +106 -48
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +29 -6
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +39 -44
- package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +6 -5
- package/src/pi-agent-ide.ts +61 -14
- package/src/plugins/pi-agent-ide-ast/package.json +15 -15
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +6 -5
- package/src/plugins/pi-agent-ide-changes/package.json +10 -10
- package/src/plugins/pi-agent-ide-changes/runtime/entry-36.js +1 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +6 -5
- package/src/plugins/pi-agent-ide-debugger/index.ts +158 -55
- package/src/plugins/pi-agent-ide-debugger/src/debugmcp-client.ts +118 -0
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +47 -0
- package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +2 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +146 -1
- package/src/plugins/pi-agent-ide-debugger/src/ui.ts +12 -0
- package/src/plugins/pi-agent-ide-debugger/src/vscode-backend.ts +497 -0
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lint/runtime/entry-40.js +2 -0
- package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-41.js +2 -0
- package/src/plugins/pi-agent-ide-terminal/index.ts +2 -0
- package/src/plugins/pi-agent-ide-terminal/src/origin.ts +30 -0
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +34 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +11 -2
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +9 -0
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +72 -26
- package/dist/chunk-GNACBJM3.js +0 -1
- package/dist/chunk-VMGZMXEM.js +0 -10
- package/dist/chunk-W3YFF6OO.js +0 -1
- package/dist/chunk-W7M3V7FR.js +0 -28
- package/dist/chunk-WMHSVEIT.js +0 -29
- package/dist/chunk-XSIKDVAR.js +0 -25
- package/dist/chunk-YTYLS2UM.js +0 -1
- package/dist/chunk-Z2QGNTGQ.js +0 -1
- package/dist/entry-21.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-20.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-21.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-27.js +0 -2
- package/node_modules/pi-agent-filesystem-image/runtime/entry-28.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-32.js +0 -1
- package/node_modules/pi-agent-ide-formatter/runtime/entry-36.js +0 -2
- package/node_modules/pi-agent-image/runtime/entry-40.js +0 -1
- package/node_modules/pi-agent-invariant/runtime/entry-41.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-49.js +0 -1
- package/node_modules/pi-agent-search-text/runtime/entry-53.js +0 -2
- package/node_modules/pi-agent-search-text/runtime/entry-54.js +0 -1
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-58.js +0 -2
- package/node_modules/pi-agent-text-editor/runtime/entry-64.js +0 -1
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-80.js +0 -2
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-82.js +0 -1
- package/node_modules/pi-agent-tool-ui/runtime/entry-83.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-84.js +0 -2
- package/node_modules/pi-agent-web-html/runtime/entry-85.js +0 -2
- package/node_modules/pi-agent-web-image/runtime/entry-86.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-28.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-29.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-27.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-85.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-86.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-84.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-43.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-44.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +0 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-54.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-49.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-50.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-58.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-63.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-64.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-32.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-33.js +0 -2
- package/src/plugins/pi-agent-ide-formatter/runtime/entry-36.js +0 -2
- /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-26.js +0 -0
- /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem}/runtime/entry-29.js +0 -0
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-30.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-text}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-34.js +0 -0
- /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-35.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-37.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-38.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-39.js +0 -0
- /package/node_modules/{pi-agent-pdf → pi-agent-image}/runtime/entry-42.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-43.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-44.js +0 -0
- /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-48.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-50.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-57.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text}/runtime/entry-59.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-60.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-61.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-62.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-63.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor}/runtime/entry-81.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web}/runtime/entry-87.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-88.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-30.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-31.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-88.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-60.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-61.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-62.js +0 -0
- /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-34.js +0 -0
- /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-35.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-37.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-38.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-39.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.2 — 2026-10-20
|
|
4
|
+
|
|
5
|
+
### Debug through VS Code
|
|
6
|
+
|
|
7
|
+
- When the project is open in a VS Code window with the [DebugMCP](https://github.com/microsoft/DebugMCP) extension, `debug` runs the session in that window by default. You see its breakpoints and session in VS Code, and the same `debug:` resources, Insert actions and Delete work as before. Install the extension with `code --install-extension ozzafar.debugmcpextension`.
|
|
8
|
+
- Choose the backend with `backend`: `auto` (default) uses VS Code only for a local project open in a DebugMCP window with no active debug session and no `args` or `mainClass`; `vscode` fails with the unmet condition instead of falling back; `native` always uses the installed adapter. `adapter` is now required only for native sessions.
|
|
9
|
+
- Launch a `.vscode/launch.json` entry with `configuration`, for example to pass arguments or debug a compiled executable, or debug one test with `test`.
|
|
10
|
+
- Pi never takes over a debug session you started and removes only the breakpoints it added. Set `PI_DEBUGMCP_PORT` if you changed `debugmcp.serverPort`. Doctor reports whether the VS Code backend is available and shows the install command when DebugMCP is missing.
|
|
11
|
+
- On Windows, find the VS Code window regardless of drive-letter case. A start that VS Code never begins fails after 60 seconds with a hint and can be retried. In Remote-WSL windows, stopped frames keep their function and line, and the file is taken from Pi's breakpoint when VS Code does not report it.
|
|
12
|
+
- A failed debugger action, such as a start that cannot launch, shows the debugger's own reason instead of "file operation failed".
|
|
13
|
+
|
|
14
|
+
### Terminal
|
|
15
|
+
|
|
16
|
+
- On Windows, finished terminal sessions no longer leave a `conhost.exe` process running until Pi exits, and short PowerShell commands start about three times faster.
|
|
17
|
+
- Keep only the 50 most recently finished terminal sessions in memory. Older sessions are released; their full output log stays on disk, and background sessions whose completion you have not yet received are kept.
|
|
18
|
+
- Show delayed terminal completion notices under the call that launched the command.
|
|
19
|
+
|
|
20
|
+
### Codemode
|
|
21
|
+
|
|
22
|
+
- Search in Codemode returns `{ result, hasMatches, complete }`, so scripts can check for matches without parsing text. Pass `result` to other tools as before; direct Search output is unchanged.
|
|
23
|
+
- Read of an image returns a native image value that scripts can pass to `image()` or `models.classify()`. Multi-frame reads return every frame.
|
|
24
|
+
- Nested IDE panels show each call's recorded execution time.
|
|
25
|
+
- Extensions that provide resources can return a value to Codemode scripts, and their receipts stay visible in nested panels.
|
|
26
|
+
- Local MCP aliases of IDE tools, such as those from Claude connectors, keep the native IDE results and Codemode rendering.
|
|
27
|
+
|
|
28
|
+
### Approvals and YOLO
|
|
29
|
+
|
|
30
|
+
- Operation approvals use one shared dialog with **Deny**, **Allow once** and **Allow for session**, shown one at a time and marked as waiting in Herdr. Other extensions can use the same dialog. Without a UI, the operation is refused.
|
|
31
|
+
- Add **YOLO: allow all operations** and **YOLO: filesystem operations** in `/agent-ide-settings`. They are off by default; extensions can register their own YOLO setting, and an explicit extension setting wins over the common one.
|
|
32
|
+
|
|
33
|
+
### Editing
|
|
34
|
+
|
|
35
|
+
- A write that was saved stays reported as applied even when reading it back fails.
|
|
36
|
+
- A rejected Copy destination no longer blocks a valid source selection.
|
|
37
|
+
- Issued result references are checked before filename anchors, and rejected references show a safe reason in the panel.
|
|
38
|
+
|
|
39
|
+
### Feedback placement
|
|
40
|
+
|
|
41
|
+
- Late diagnostics summaries and advisory code-review notices appear under the tool call that caused them.
|
|
42
|
+
|
|
43
|
+
### Pi 1.3
|
|
44
|
+
|
|
45
|
+
- On Pi 1.3.0 and newer, resumed sessions keep Pi's restored tool loadout, so a tool removed with `--tools -name` stays off. Tools excluded in settings remain unavailable. Pi 0.99.1 or newer is still supported.
|
|
46
|
+
|
|
3
47
|
## 0.8.1 — 2026-10-11
|
|
4
48
|
|
|
5
49
|
### Settings and help
|
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
<div align="center">
|
|
26
26
|
|
|
27
|
-
[](https://huggingface.co/spaces/alexshpunt/benchmark-explorer?card=harness%3Api-agent-ide%40latest)
|
|
27
|
+
[](https://huggingface.co/spaces/alexshpunt/benchmark-explorer?card=harness%3Api-agent-ide-codemode%40latest)
|
|
28
28
|
|
|
29
29
|
</div>
|
|
30
30
|
|
|
@@ -144,6 +144,8 @@ The terminal is a first-class cross-platform interface. The agent can run comman
|
|
|
144
144
|
|
|
145
145
|
Debugger sessions use the same resource model. The agent can set breakpoints, inspect stack frames and variables, evaluate expressions, step through execution, and return to a running session later.
|
|
146
146
|
|
|
147
|
+
When the project is open in VS Code with the [DebugMCP](https://github.com/microsoft/DebugMCP) extension, the agent debugs it there by default, so you can follow the session in your editor. See [VS Code debugger](./docs/configuration.md#vs-code-debugger).
|
|
148
|
+
|
|
147
149
|
<div align="center">
|
|
148
150
|
|
|
149
151
|
[](assets/summary/debugging.png)
|
|
@@ -194,7 +196,7 @@ Windows and WSL are first-class supported environments alongside Linux. Run `/pi
|
|
|
194
196
|
|
|
195
197
|
### Built through data-driven development
|
|
196
198
|
|
|
197
|
-
Pi Agent IDE is developed through daily use on real software and measured with the [Explicit Edit Benchmark](https://github.com/alexshpunt/explicit-edit-benchmark).
|
|
199
|
+
Pi Agent IDE is developed through daily use on real software and measured with the [Explicit Edit Benchmark](https://github.com/alexshpunt/explicit-edit-benchmark). The badge tracks the [Codemode-enabled profile](https://huggingface.co/spaces/alexshpunt/benchmark-explorer?card=harness%3Api-agent-ide-codemode%40latest), with native Codemode alongside standalone IDE tools. [Earlier standalone-only observations](https://huggingface.co/spaces/alexshpunt/benchmark-explorer?card=harness%3Api-agent-ide%40latest) remain separate. A profile's badge appears after its first accepted observation; not every release has a run. All observations are available in the [published dataset](https://huggingface.co/datasets/alexshpunt/explicit-edit-benchmark).
|
|
198
200
|
|
|
199
201
|
The project is also used to develop itself. Weak interactions, missing affordances, and agent failure modes appear in real work instead of remaining theoretical. Problems are fixed as they are found, and the tools evolve through regular releases.
|
|
200
202
|
|
|
@@ -202,7 +204,7 @@ Pi Agent IDE is experimental and under active development. Interfaces and behavi
|
|
|
202
204
|
|
|
203
205
|
## Installation
|
|
204
206
|
|
|
205
|
-
Install [Pi](https://pi.dev/) **0.99.1 or newer** first, then install Pi Agent IDE from npm. Development and integration tests use Pi 1.
|
|
207
|
+
Install [Pi](https://pi.dev/) **0.99.1 or newer** first, then install Pi Agent IDE from npm. Development and integration tests use Pi 1.3.0. Older hosts are rejected with an upgrade message.
|
|
206
208
|
|
|
207
209
|
```bash
|
|
208
210
|
pi install npm:pi-agent-ide
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as E}from"./chunk-
|
|
1
|
+
import{o as E}from"./chunk-LCWBVOII.js";import{e as f}from"./chunk-ZPT5D4VP.js";import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";import{execFile as I}from"node:child_process";import{lstat as O,readdir as k,readFile as _,readlink as L,realpath as h}from"node:fs/promises";import i from"node:path";import v from"node:os";import{promisify as C}from"node:util";var F=C(I);function A(t){return t.isSymbolicLink()?"symlink":t.isDirectory()?"directory":t.isFile()?"file":"other"}o(A,"kind");function R(t){return JSON.stringify([t.dev,t.ino,t.birthtimeMs,t.ctimeMs,t.mtimeMs,t.size,t.mode])}o(R,"revision");async function x(t){return O(t).catch(r=>{if(r.code!=="ENOENT")throw r})}o(x,"optionalStat");async function b(t){try{return await h(t)}catch(r){if(r.code!=="ENOENT"||await x(t))throw r;return i.join(await b(i.dirname(t)),i.basename(t))}}o(b,"resolveParent");async function S(t,r){let c=i.join(await b(i.dirname(t)),i.basename(t)),l=[],p=o(async(s,d)=>{r?.throwIfAborted();let a=await x(s);if(a===void 0){if(d!=="")throw Object.assign(new Error("Transfer entry disappeared"),{code:"TRANSFER_TARGET_CHANGED"});return}let T={relativePath:d,kind:A(a),revision:R(a),identity:{device:String(a.dev),inode:String(a.ino)},mode:a.mode,...a.isSymbolicLink()?{link:(await L(s,{encoding:"buffer"})).toString("base64")}:{}};if(l.push(T),T.kind==="directory"){for(let m of(await k(s)).sort())await p(i.join(s,m),d===""?m:`${d}/${m}`);let y=await x(s);if(y===void 0||R(y)!==T.revision)throw Object.assign(new Error("Transfer directory changed while inspecting its children"),{code:"TRANSFER_TARGET_CHANGED"})}},"walk");return await p(c,""),{path:c,entries:l}}o(S,"snapshotLocalObjects");var N={owner:"local",async temporaryEnvironment(t){t?.throwIfAborted();let r=process.env.PI_CODING_AGENT_DIR?.trim();return{home:v.homedir(),temporary:v.tmpdir(),...r?{agentDirectory:i.resolve(r)}:{}}},pathStyle:"native",realpath:h,async inspect(t){let r=await O(t);return{kind:A(r),revision:R(r),identity:{device:String(r.dev),inode:String(r.ino)},mode:r.mode}},read:o(t=>_(t,"utf8"),"read"),async git(t,r,c){let l=Object.fromEntries(Object.entries(process.env).filter(([s])=>!s.startsWith("GIT_"))),{stdout:p}=await F("git",["-C",t,...r],{env:{...l,GIT_OPTIONAL_LOCKS:"0"},signal:c,timeout:5e3,maxBuffer:16*1024*1024});return p},source:o(t=>t,"source"),snapshot:S};var u="pi-agent-text-editor",P=32,oe="pi-agent-text-editor/position",ie="pi-agent-text-editor/search",ne=`${u}/core/ready`,se=`${u}/plugin/register`,g=e.Function([],e.Unknown()),D=e.Object({tryResolve:g},{additionalProperties:!0}),j=e.Object({lineNumber:e.Integer({minimum:1}),column:e.Integer({minimum:0})}),M=e.Object({start:j,end:j,linewise:e.Optional(e.Boolean())}),G=e.Object({source:e.String({minLength:1}),ranges:e.Optional(e.Array(M))}),q=e.Union([e.Object({kind:e.Literal("not-handled")},{additionalProperties:!0}),e.Object({kind:e.Literal("resolved"),targets:e.Array(G,{minItems:1})},{additionalProperties:!0}),e.Object({kind:e.Literal("rejected"),rejection:e.Object({code:e.Union([e.Literal("invalid"),e.Literal("stale"),e.Literal("missing"),e.Literal("ambiguous")]),reason:e.String(),contextRange:e.Optional(e.Object({offset:e.Number(),limit:e.Number()}))})},{additionalProperties:!0}),e.Object({kind:e.Literal("failed"),error:e.Unknown()},{additionalProperties:!0})]),V=e.String({pattern:"\\S"}),X=e.Object({resolver:e.Unknown(),priority:e.Optional(e.Number())}),U=e.Object({resolver:e.Unknown(),resources:e.Optional(e.Unknown()),kind:e.String({pattern:"\\S"}),type:e.Union([e.Literal("major"),e.Literal("auxiliary"),e.Literal("constant")]),priority:e.Optional(e.Number())}),H=e.Object({protocol:e.Literal(u),apiVersion:e.Literal(P)}),w=e.Object({protocol:e.Literal(u),apiVersion:e.Literal(P),id:e.String(),setup:g}),K=e.Object({plugin:w,accept:g});function ae(t){return n.Check(V,t)}o(ae,"isTextEditorToolId");function ce(t){if(!n.Check(X,t))return!1;let r=t;return E(r.resolver)&&(!("priority"in r)||typeof r.priority=="number")}o(ce,"isResourceResolverRegistration");function le(t){if(!n.Check(U,t))return!1;let r=t;return f(r.resolver)&&(!("resources"in r)||n.Check(D,r.resources))&&(!("priority"in r)||typeof r.priority=="number")}o(le,"isTextAnchorResolverRegistration");function pe(t){return n.Check(q,t)}o(pe,"isTextAnchorResourceResolutionAttempt");function de(t){return n.Check(H,t)}o(de,"isTextEditorCoreReady");function ue(t){return n.Check(w,t)}o(ue,"isTextEditorPlugin");function Te(t){return n.Check(K,t)}o(Te,"isTextEditorPluginRegistrationRequest");export{S as a,N as b,u as c,P as d,oe as e,ie as f,ne as g,se as h,ae as i,ce as j,le as k,pe as l,de as m,ue as n,Te as o};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as k,e as f}from"./chunk-
|
|
1
|
+
import{b as k,e as f}from"./chunk-I6NPILT5.js";import{a as v,b}from"./chunk-PS2B6THP.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{pathToFileURL as T}from"node:url";function P(e,n,r,o,i,a=[],l=[]){let c=a.map(t=>({kind:"note",text:t}));c.push(...b(e.flatMap(t=>{let p=h.isAbsolute(t.source),D=p&&i?h.relative(i,t.source)||h.basename(t.source):t.source,z=p?T(t.source).href:/^https?:/iu.test(t.source)?t.source:void 0,x=t.endLineNumber??t.lineNumber;return(x===t.lineNumber?[t.lineText]:[t.lineText,...t.matchedText.split(/\r\n|\n|\r/u).slice(1)]).slice(0,20).map((R,m)=>({source:t.source,label:D,...z===void 0?{}:{link:z},...p?{}:{badge:t.source.startsWith("docs:")?"DOC":/^https?:/iu.test(t.source)?"WEB":"SH"},lineNumber:t.lineNumber+m,text:R,ranges:[{from:m?0:t.startColumn,to:t.lineNumber+m===x?t.endColumn:R.length}]}))}))),e.length||c.push({kind:"note",text:"No matches found"}),e.some(t=>(t.endLineNumber??t.lineNumber)-t.lineNumber>=20)&&c.push({kind:"note",text:"\u2026 source preview shortened"}),c.push(...l.map(t=>({kind:"note",text:t,expandedOnly:!0})));let u=`${e.length}${n?"":"+"}`,y=new Set(e.map(t=>t.source)),F=e.length>0&&e.every(t=>h.isAbsolute(t.source));return new v({summary:`${u} ${e.length===1?"match":"matches"} in ${y.size} ${F?y.size===1?"file":"files":y.size===1?"source":"sources"}`,rows:c},r,o)}s(P,"renderSearchMatches");function $(e,n){return e.targets.some(r=>r.source===n.source&&r.ranges.some(o=>(o.start.lineNumber<n.lineNumber||o.start.lineNumber===n.lineNumber&&o.start.column<=n.startColumn)&&(o.end.lineNumber>(n.endLineNumber??n.lineNumber)||o.end.lineNumber===(n.endLineNumber??n.lineNumber)&&o.end.column>=n.endColumn)))}s($,"containsSearchMatch");import{Value as N}from"typebox/value";var d={candidates:5,previewMatches:3,identifiers:2e4,identifierLength:80,vocabularyBytes:8*1024*1024,matchesPerCandidate:200,verificationBytes:4*1024*1024,timeoutMs:2e3};function I(e){return N.Check(k,e)}s(I,"isFuzzyResultData");function g(e){return e.length>=5&&e.length<=d.identifierLength&&/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(e)&&/[A-Za-z]/u.test(e)}s(g,"isFuzzyQuery");var S=class{static{s(this,"FuzzyVocabulary")}names=new Set;bytes=0;limited=!1;account(n){return this.bytes+=n,this.bytes>d.vocabularyBytes&&(this.limited=!0),!this.limited}add(n){if(!(this.limited||!g(n)||this.names.has(n))){if(this.names.size===d.identifiers){this.limited=!0;return}this.names.add(n)}}addText(n){if(this.account(Buffer.byteLength(n))){for(let r of n.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/gu))if(this.add(r[0]),this.limited)break}}};function w(e){return e.replace(/([A-Z]+)([A-Z][a-z])/gu,"$1 $2").replace(/([a-z0-9])([A-Z])/gu,"$1 $2").split(/[^A-Za-z0-9]+/u).filter(Boolean).map(n=>n.toLowerCase())}s(w,"splitName");function C(e,n){return e.length===n.length&&e.every((r,o)=>r===n[o])}s(C,"same");function L(e,n){if(e.length<5||n.length<5||Math.abs(e.length-n.length)>1||/\d/u.test(e+n))return!1;let r=0;for(;r<Math.min(e.length,n.length)&&e[r]===n[r];)r++;if(e.length===n.length)return e.slice(r+1)===n.slice(r+1)||e[r]===n[r+1]&&e[r+1]===n[r]&&e.slice(r+2)===n.slice(r+2);let o=e.length<n.length?e:n,i=e.length<n.length?n:e;return o.slice(r)===i.slice(r+1)}s(L,"oneTypo");function M(e,n){if(e.join("")===n.join(""))return{kind:"normalized",reason:"same spelling with different case or separators"};let r=e.length<n.length?e:n,o=e.length<n.length?n:e;if(o.length===r.length+1&&r.length>=2&&r.every(l=>l.length>=3)){let l=C(r,o.slice(1)),c=C(r,o.slice(0,-1));if(l||c)return{kind:"component",reason:`${e.length>n.length?"remove":"add"} ${l?"leading":"trailing"} component '${l?o[0]:o.at(-1)}'`}}if(e.length!==n.length)return;let i=e.flatMap((l,c)=>{let u=n[c];return u!==void 0&&l!==u?[{word:l,other:u}]:[]}),a=i[0];if(!(i.length!==1||!a||!L(a.word,a.other)))return{kind:"typo",reason:`one character edit: '${a.word}' \u2192 '${a.other}'`}}s(M,"relation");var A={normalized:0,component:1,typo:2};function E(e,n){if(!g(e))return[];let r=w(e);if(r.length===0)return[];let o=[];for(let i of new Set(n)){if(i===e||!g(i))continue;let a=M(r,w(i));a&&o.push({identifier:i,...a})}return o.sort((i,a)=>A[i.kind]-A[a.kind]||(i.identifier<a.identifier?-1:i.identifier>a.identifier?1:0)).slice(0,d.candidates)}s(E,"rankFuzzyIdentifiers");function _(e,n,r){return{identifier:e.identifier,kind:e.kind,reason:e.reason,matchCount:e.matches.length,fileCount:new Set(e.matches.map(o=>o.source)).size,selection:{...f(e.matches.slice(0,d.previewMatches),e.complete,n,r),truncated:e.matches.length>d.previewMatches}}}s(_,"fuzzyCandidateData");function O(e){let n=e.selection.complete?"":"+",r=e.selection.all?.line??e.selection.matches[0]?.references?.line,o=e.selection.matches[0],i=r??o?.source;return[`Possible name: ${e.identifier} (${e.reason})`,`${e.matchCount}${n} ${e.matchCount===1&&e.selection.complete?"match":"matches"} in ${e.fileCount}${n} ${e.fileCount===1&&e.selection.complete?"file":"files"}`,`Exact alternative: ${JSON.stringify(e.identifier)} (case-sensitive, whole identifier)`,...e.selection.complete?[]:["Capture limit reached; no complete all reference. Inspect the returned location; do not treat this candidate as a complete match set."],...i?[`Read: ${i}${r||!o?"":` \xB7 line ${o.range.startLine}`}`]:[]].join(`
|
|
2
2
|
`)}s(O,"formatFuzzyCandidate");export{P as a,$ as b,d as c,I as d,g as e,S as f,E as g,_ as h,O as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as I}from"./chunk-
|
|
1
|
+
import{a as I}from"./chunk-6XFUICD7.js";import{g as r}from"./chunk-PJL3UVMJ.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as n}from"./chunk-
|
|
1
|
+
import{b as n}from"./chunk-NUM3YQGK.js";import{g as s}from"./chunk-PJL3UVMJ.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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{f as m,j as g,k as x,o as h}from"./chunk-
|
|
1
|
+
import{f as m,j as g,k as x,o as h}from"./chunk-LCWBVOII.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
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f,b as u}from"./chunk-
|
|
1
|
+
import{a as f,b as u}from"./chunk-6XFUICD7.js";import{g as o}from"./chunk-PJL3UVMJ.js";import{b as w}from"./chunk-VDP5CQHM.js";import{a as d}from"./chunk-EI7MMDWY.js";import{readFile as R}from"node:fs/promises";import{Type as i}from"typebox";import{Value as g}from"typebox/value";var y=i.Object({url:i.String(),status:i.Integer({minimum:200,maximum:599}),statusText:i.String(),headers:i.Array(i.Tuple([i.String(),i.String()])),body:i.String()}),b=new Set(["INVALID_SOURCE","BYTE_LIMIT","TIMEOUT","HTTP_FAILED"]),m;async function S(n,s,t,c){c?.throwIfAborted(),m??=R(new URL("./web-http-worker.py",new URL("../src/backend/web-http.ts",import.meta.url).href),"utf8");try{let e=await f(n,"python3",["-c",await m,JSON.stringify({url:s.href,timeoutSeconds:30})],t,{signal:c,timeoutMs:3e4,maxBytes:33554432});if(e.exitCode!==0)throw new o("HTTP_FAILED",t,"not-applied");let r;try{r=JSON.parse(e.stdout.toString("utf8"))}catch{throw new o("INVALID_RESPONSE",t,"not-applied")}if(typeof r=="object"&&r!==null&&"error"in r)throw new o(typeof r.error=="string"&&b.has(r.error)?r.error:"INVALID_RESPONSE",t,"not-applied");if(!g.Check(y,r))throw new o("INVALID_RESPONSE",t,"not-applied");let h=Buffer.from(r.body,"base64");if(h.toString("base64")!==r.body||h.length>16*1024*1024)throw new o("INVALID_RESPONSE",t,"not-applied");let a;try{let p=new URL(r.url);if(!["http:","https:"].includes(p.protocol)||p.username||p.password)throw new Error("Invalid native HTTP redirect");a=new Response([204,205,304].includes(r.status)?null:h,{status:r.status,statusText:r.statusText,headers:r.headers}),Object.defineProperty(a,"url",{value:p.href})}catch{throw new o("INVALID_RESPONSE",t,"not-applied")}return a}catch(e){throw e instanceof o?new o(e.code,t,e.effect):e}}d(S,"fetchSshWebResponse");function I(n){if(!/^web:/iu.test(n))return;let s=/^web:ssh:\/\/([a-z0-9._-]+)\/(https?:\/\/.+)$/iu.exec(n);if(!s?.[1]||!s[2])throw new o("INVALID_SOURCE",n,"not-applied");let t;try{t=new URL(s[2])}catch{throw new o("INVALID_SOURCE",n,"not-applied")}if(t.username||t.password)throw new o("INVALID_SOURCE",n,"not-applied");return{target:s[1],url:t,source:`web:ssh://${s[1]}/${t.href}`}}d(I,"parseSshWebSource");function D(n,s){return{id:"ssh-web",async tryResolve(t,c){try{let e=I(t);if(!e)return{kind:"not-handled"};c.signal?.throwIfAborted();let r=s.resolve(`ssh://${e.target}/`);if(!r)throw new o("UNSUPPORTED_SOURCE",e.source,"not-applied");let a=await w(n,{fetch:d(async(p,l)=>S(r.backend.target,e.url,e.source,l?.signal??void 0),"fetch"),browser:{load(p,l){return u(r.backend.target,p,e.source,l)}}}).tryResolve(e.url.href,c);return a.kind!=="resolved"?a:{kind:"resolved",resource:{...a.resource,source:e.source}}}catch(e){return{kind:"failed",error:e instanceof o?new o(e.code,t,e.effect):e}}}}}d(D,"createSshWebResolver");export{I as a,D as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C}from"./chunk-
|
|
1
|
+
import{a as C}from"./chunk-QT3EAHOG.js";import{a as w}from"./chunk-SMIFCAAX.js";import{a as E,b as g}from"./chunk-VXP5BMW7.js";import{b as S}from"./chunk-RW2GTYQI.js";import{a as u,b as v,c as U}from"./chunk-RIJMXO43.js";import"./chunk-VMTOFEXF.js";import"./chunk-CPELC6JE.js";import{g as l}from"./chunk-PJL3UVMJ.js";import{a as p,b as O,c as f,e as j}from"./chunk-MKEC3U2M.js";import{c as R}from"./chunk-W7CASEO3.js";import"./chunk-TOYN4W4F.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-K5G4FDXD.js";import"./chunk-LCWBVOII.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import{c as P}from"./chunk-IMGIDBCC.js";import"./chunk-BXGMMZT3.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{fileURLToPath as x}from"node:url";function A(i){let c=E(i),T=w(i);return{async resolveProject(e,o){if(e.startsWith("ssh://")||o.startsWith("ssh://")){let n=i.resolve(e,o);if(!n)throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let a=i.resolve(o);if(a&&a.location.target!==n.location.target)throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let r=await C(n.backend,n.location.path,a?.location.path,"linters",p);return r?{projectRoot:r.cwd,external:r.external}:void 0}if(e.includes("://")||o.includes("://"))throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let t=await P(o,e,"linters",p);return t===void 0?void 0:{projectRoot:t,external:t!==h.resolve(o)}},async loadRegistry(e,o){let t=i.resolve(e);return O.fromDirectory(e,{includeGlobal:!o,requireBuiltInEvidence:!0,...t?{layerAccess:c,executableAvailability:s(n=>S(t.backend,t.location.path,n),"executableAvailability"),recipeEvidence:s(n=>g(t.backend,t.location.path,n),"recipeEvidence")}:{}})},async run(e,o){let t=i.resolve(o.filePath);if(!t)return f(e,o);let n=i.resolve(o.projectRoot);if(!n||n.location.target!==t.location.target)throw new l("UNSUPPORTED_SOURCE",o.filePath,"not-applied");let a=e.check.cwd==="file"?h.posix.dirname(t.location.path):n.location.path;return f(e,{...o,processAccess:T,acceptsFile(r){if(r.startsWith("ssh://")){let d=i.resolve(r);return d?.location.target===t.location.target&&d.location.path===t.location.path}let m=r.startsWith("file:")?x(r):r;return m.includes("://")?!1:h.posix.resolve(a,m)===t.location.path}})}}}s(A,"createOwnedLintRuntime");async function L(i){let c=new U(await v(u(R())));await j(i,A(c))}s(L,"registerOwnedLint");export{A as createOwnedLintRuntime,L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as S,d as C}from"./chunk-
|
|
1
|
+
import{c as S,d as C}from"./chunk-4DIUPEDF.js";import{a as h}from"./chunk-EI7MMDWY.js";import z from"node:path";import{pathToFileURL as x}from"node:url";function b(e,n){let r=new Map;for(let t of e){let i=r.get(t.source)??[];i.push(t),r.set(t.source,i)}let a=new Set,u=e.length,s=[...r].sort(([t,i],[d,m])=>m.length-i.length||t.localeCompare(d));for(let[t,i]of s){if(u<=n)break;a.add(t),u-=i.length-1}let c=[],o=n,l=[...r].sort(([t],[i])=>Number(a.has(t))-Number(a.has(i))||t.localeCompare(i));for(let[t,i]of l){if(!a.has(t)){if(i.length>o)continue;c.push({kind:"detailed",source:t,matches:i}),o-=i.length;continue}if(o<1)continue;o--;let d=new Map;for(let g of i)d.set(g.lineText,(d.get(g.lineText)??0)+1);let m=r.size===1?[...d].sort(([g,p],[F,w])=>w-p||g.localeCompare(F)).slice(0,o).map(([g,p])=>({text:g,matchCount:p})):[];o-=m.length,c.push({kind:"compacted",source:t,matchCount:i.length,uniqueLineCount:d.size,groups:m})}return c.sort((t,i)=>t.source.localeCompare(i.source)),{files:c}}h(b,"planSearchPresentation");function N(e,n,r,a,u,s=50){let c=b(n,s),o=new Set(n.map(t=>t.source)).size,l=c.files.map(t=>t.kind==="detailed"?L(t.source,t.matches,a):{path:M(t.source,a),link:x(t.source).href,matchCount:t.matchCount,uniqueLineCount:t.uniqueLineCount,groups:t.groups,lines:[]});return{...u!==void 0&&{sessionId:u},query:e,matchCount:n.length,fileCount:o,...c.files.length<o?{omittedFileCount:o-l.length,omittedMatchCount:n.length-l.reduce((t,i)=>t+i.matchCount,0)}:{},complete:r,files:l}}h(N,"createSearchToolDetails");function $(e,n){return{fileCount:new Set(e.flatMap(r=>r.matches.map(a=>a.source))).size,groups:e.map(r=>{let u=N(r.identifier,r.matches.slice(0,S.previewMatches),r.complete,n).files.map(s=>{let c=s.lines.map(o=>{let l=Math.max(0,(o.ranges[0]?.from??0)-64),t=Math.min(o.text.length,(o.ranges[0]?.to??0)+64),i=l>0?"\u2026":"",d=o.ranges.filter(m=>m.from>=l&&m.to<=t).map(m=>({from:m.from-l+i.length,to:m.to-l+i.length}));return{...o,text:i+o.text.slice(l,t)+(t<o.text.length?"\u2026":""),ranges:d,matchCount:d.length}});return{...s,lines:c,matchCount:c.reduce((o,l)=>o+l.matchCount,0)}});return{identifier:r.identifier,files:u}})}}h($,"createFuzzyPresentation");function k(e){return f(e)&&y(e.fileCount)&&Array.isArray(e.groups)&&e.groups.every(n=>f(n)&&typeof n.identifier=="string"&&Array.isArray(n.files)&&n.files.every(R))}h(k,"isFuzzyPresentation");function E(e){if(!f(e)||typeof e.query!="string"||!y(e.matchCount)||!y(e.fileCount)||e.omittedFileCount!==void 0&&!y(e.omittedFileCount)||e.omittedMatchCount!==void 0&&!y(e.omittedMatchCount)||typeof e.complete!="boolean"||e.sessionId!==void 0&&typeof e.sessionId!="string"||e.fuzzy!==void 0&&!C(e.fuzzy)||e.fuzzyPresentation!==void 0&&!k(e.fuzzyPresentation)||!Array.isArray(e.files)||!e.files.every(R))return!1;let n=e.files;return e.fileCount===n.length+(e.omittedFileCount??0)&&e.matchCount===n.reduce((r,a)=>r+a.matchCount,0)+(e.omittedMatchCount??0)}h(E,"isSearchToolDetails");function L(e,n,r){let a=new Map;for(let s of n){let c=a.get(s.lineNumber);if(c!==void 0&&c.text!==s.lineText)throw new Error(`Search results disagree about line ${String(s.lineNumber)} in ${e}.`);let o=c??{lineNumber:s.lineNumber,text:s.lineText,ranges:[]};o.ranges.push({from:s.startColumn,to:s.endColumn}),a.set(s.lineNumber,o)}let u=[...a.values()].sort((s,c)=>s.lineNumber-c.lineNumber).map(s=>{let c=[...s.ranges].sort((o,l)=>o.from-l.from||o.to-l.to);return{lineNumber:s.lineNumber,text:s.text,matchCount:c.length,ranges:c}});return{path:M(e,r),link:x(e).href,matchCount:n.length,lines:u}}h(L,"createSearchResultFile");function R(e){if(!f(e)||typeof e.path!="string"||typeof e.link!="string"||!y(e.matchCount)||!Array.isArray(e.lines)||!e.lines.every(P))return!1;let n=e.lines,r=e.groups,a=new Set(n.flatMap(u=>u.logicalMatchIds??[]));return(r===void 0||Array.isArray(r)&&r.every(u=>f(u)&&typeof u.text=="string"&&y(u.matchCount)))&&(e.uniqueLineCount===void 0||y(e.uniqueLineCount))&&(n.length===0||(a.size>0?a.size===e.matchCount:e.matchCount===n.reduce((u,s)=>u+s.matchCount,0)))}h(R,"isSearchResultFile");function P(e){return f(e)&&Number.isSafeInteger(e.lineNumber)&&e.lineNumber>=1&&typeof e.text=="string"&&y(e.matchCount)&&Array.isArray(e.ranges)&&e.ranges.length===e.matchCount&&(e.logicalMatchIds===void 0||Array.isArray(e.logicalMatchIds)&&e.logicalMatchIds.every(n=>typeof n=="string"))&&e.ranges.every(n=>A(n,e.text))}h(P,"isSearchResultLine");function A(e,n){return f(e)&&Number.isSafeInteger(e.from)&&Number.isSafeInteger(e.to)&&e.from>=0&&e.to>e.from&&e.to<=n.length}h(A,"isSearchResultRange");function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}h(f,"isRecord");function y(e){return Number.isSafeInteger(e)&&e>=0}h(y,"isCount");function M(e,n){if(e.includes("://"))return e;let r=z.relative(n,e);return r.length>0&&!r.startsWith("..")&&!z.isAbsolute(r)?r:e}h(M,"displaySource");export{b as a,N as b,$ as c,E as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d}from"./chunk-
|
|
1
|
+
import{a as d}from"./chunk-VMTOFEXF.js";import{g as n}from"./chunk-PJL3UVMJ.js";import{a as p}from"./chunk-EI7MMDWY.js";import{readFile as h}from"node:fs/promises";import{Type as m}from"typebox";import{Value as g}from"typebox/value";async function f(s,a,e,o,t){return d(s,a,e,o,{...t,effect:"not-applied"})}p(f,"readOwnedSshCommand");var S=m.Object({html:m.String(),source:m.String()}),u=new Set(["CAPABILITY_UNAVAILABLE","INVALID_SOURCE","BYTE_LIMIT","TIMEOUT","HTTP_FAILED","BROWSER_FAILED","CANCELLED"]),l;async function B(s,a,e,o){let t=await w(s,a,e,o,"html");if(!g.Check(S,t)||Buffer.byteLength(t.html,"utf8")>16*1024*1024)throw new n("INVALID_RESPONSE",e,"not-applied");let r=new URL(t.source);if(!["http:","https:"].includes(r.protocol)||r.username||r.password)throw new n("INVALID_RESPONSE",e,"not-applied");return t}p(B,"readSshBrowserPage");async function N(s,a,e,o){let t=await w(s,a,e,{signal:o,timeoutMs:3e4},"image");if(typeof t!="object"||t===null||!("png"in t)||typeof t.png!="string")throw new n("INVALID_RESPONSE",e,"not-applied");let r=Buffer.from(t.png,"base64");if(r.toString("base64")!==t.png||r.length>20*1024*1024||!r.subarray(0,8).equals(Buffer.from("89504e470d0a1a0a","hex")))throw new n("INVALID_RESPONSE",e,"not-applied");return r}p(N,"captureSshBrowserImage");async function R(s,a,e){let o=await w(s,new URL("about:blank"),a,{signal:e,timeoutMs:3e4},"probe");if(!g.Check(m.Object({ready:m.Literal(!0)}),o))throw new n("INVALID_RESPONSE",a,"not-applied")}p(R,"probeSshBrowser");async function w(s,a,e,o,t){o.signal?.throwIfAborted(),l??=h(new URL("./web-browser-worker.mjs",new URL("../src/backend/web-browser.ts",import.meta.url).href),"utf8");try{let r=await f(s,"node",["--input-type=module","-e",await l,JSON.stringify({kind:t,url:a.href,timeoutMs:o.timeoutMs})],e,{signal:o.signal,timeoutMs:o.timeoutMs,maxBytes:33554432});if(r.exitCode!==0)throw new n("BROWSER_FAILED",e,"not-applied");let i;try{i=JSON.parse(r.stdout.toString("utf8"))}catch{throw new n("INVALID_RESPONSE",e,"not-applied")}if(typeof i=="object"&&i!==null&&"error"in i)throw new n(typeof i.error=="string"&&u.has(i.error)?i.error:"INVALID_RESPONSE",e,"not-applied");return i}catch(r){throw r instanceof n?new n(r.code==="ENOENT"?"CAPABILITY_UNAVAILABLE":r.code,e,r.effect):r}}p(w,"runBrowser");export{f as a,B as b,N as c,R as d};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import{a as we,b as Se,c as Te}from"./chunk-ESPNEJHK.js";import{a as ye}from"./chunk-L2B4DTVS.js";import{a as ge,b as he,c as M}from"./chunk-RIJMXO43.js";import"./chunk-PJL3UVMJ.js";import{a as de}from"./chunk-47SPPIXK.js";import{a as me}from"./chunk-4DIUPEDF.js";import{a as ue,b as ce}from"./chunk-VAXLSPPU.js";import{e as pe}from"./chunk-I6NPILT5.js";import{c as fe}from"./chunk-W7CASEO3.js";import"./chunk-QUYXINGZ.js";import{a as _}from"./chunk-XLWCSJMR.js";import{e as te,f as ne}from"./chunk-T7I2VX3J.js";import{a as le}from"./chunk-XXLLY66B.js";import{c as se,d as ae}from"./chunk-235QMMVA.js";import{b as C}from"./chunk-IICJXZBU.js";import"./chunk-PS2B6THP.js";import{a as oe}from"./chunk-BU7IZLKB.js";import{a as re,b as ie}from"./chunk-S5PL5DFQ.js";import{i as q,j as L}from"./chunk-LCWBVOII.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import ut from"node:path";import{stripVTControlCharacters as ct}from"node:util";import{truncateLine as dt}from"@earendil-works/pi-coding-agent";import{Text as E}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as be,DEFAULT_MAX_LINES as xe,formatSize as at,truncateTail as lt}from"@earendil-works/pi-coding-agent";function $(t){return lt(t,{maxBytes:be-4096,maxLines:xe-32})}l($,"terminalOutputTail");function D(t){let e=$(t.output),n=[`session: ${t.source}`,`status: ${t.status}`,`shell: ${t.shell}`,`cwd: ${t.cwd}`,`elapsedMs: ${t.elapsedMs}`,t.exitCode===void 0?void 0:`exitCode: ${t.exitCode}`,t.signal===void 0?void 0:`signal: ${t.signal}`,t.error===void 0?void 0:`error: ${t.error}`,t.waitReason===void 0?void 0:`reason: ${t.waitReason}`,t.completionReason===void 0?void 0:`completionReason: ${t.completionReason}`,t.status==="running"&&t.background?`next: Continue independent work or finish your turn; completion or a one-time idle inspection notice will wake the agent. Read ${t.source} to inspect output; use write or insert when input is needed.`:void 0,`outputRange: ${t.outputStart}-${t.outputEnd}`,t.truncated?"retainedOutput: earlier data omitted from memory":void 0,e.truncated?`fullOutput: ${t.fullOutputPath}`:void 0].filter(o=>o!==void 0),r=e.content.trimEnd();if(!e.truncated)return`${n.join(`
|
|
2
|
+
`)}
|
|
3
|
+
output:${r.length===0?" (empty)":`
|
|
4
|
+
${r}`}`;let i=e.truncatedBy==="lines"?`${xe} line output budget`:`${at(be)} output budget`,a=`[Earlier output omitted: showing the last ${e.outputLines} of ${e.totalLines} lines (${i}). Full output: ${t.fullOutputPath}]`;return`${n.join(`
|
|
5
|
+
`)}
|
|
6
|
+
output:
|
|
7
|
+
${a}${r.length===0?"":`
|
|
8
|
+
${r}`}`}l(D,"formatAgentTerminalSnapshot");var mt=500;function ve(t,e,n,r,i){let a=e?"background":"wait",o=`${i.fg("toolTitle",r.displayName.toLocaleLowerCase())} ${i.fg("muted",`\xB7 ${N(n)} \xB7 ${a}`)}`;return new E(`${o}
|
|
9
|
+
${i.fg("accent",X(r.family))} ${t}`,0,0)}l(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 E(r.join(`
|
|
10
|
+
`),0,0)}l(Re,"renderTerminalActionResult");function Pe(t,e,n,r,i){let a=[gt(t,i),i.fg("accent",`${e} ${n}`)];return r.length>0&&a.push(...r.map(o=>` ${i.fg("dim",o)}`)),new E(a.join(`
|
|
11
|
+
`),0,0)}l(Pe,"renderTerminalAction");function k(t,e,n,r){let i=ke(t,C,n);return r!==void 0&&i.splice(1,1,n.fg("accent",r)),new E(i.join(`
|
|
12
|
+
`),0,0)}l(k,"renderTerminalResult");function Ee(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 E(I(t,(u,c)=>n.fg(u,c)),0,0);let o=O(t.output??"",C),s=[...o.omission===void 0?[]:[` ${n.fg("muted",o.omission)}`],...o.lines.map(u=>` ${n.fg("dim",u)}`),...t.error===void 0?[]:[` ${n.fg("error",t.error)}`],I(t,(u,c)=>n.fg(u,c))];return new E(s.join(`
|
|
13
|
+
`),0,0)}if(e==="full"){let a=ke(t,Number.POSITIVE_INFINITY,n).slice(2);return new E(a.join(`
|
|
14
|
+
`),0,0)}let r=O(t.output??"",C),i=[...r.omission===void 0?[]:[` ${n.fg("muted",r.omission)}`],...r.lines.map(a=>` ${n.fg("dim",a)}`)];return i.push(I(t,(a,o)=>n.fg(a,o))),new E(i.join(`
|
|
15
|
+
`),0,0)}l(Ee,"renderRunResult");function Ae(t,e){let n=l((o,s)=>e?.fg(o,s)??s,"color"),i=[`${n("accent",t.shell.toLocaleLowerCase())} ${n("muted",`\xB7 ${N(t.cwd)} \xB7 ${t.background?"background":"wait"}`)}`,`${n("accent",X(t.shellFamily))} ${V(t.command,84)}`],a=pt(t.output,2);return a.length>0&&i.push(...a.map(o=>` ${n("dim",V(o,90))}`)),i.push(I(t,n)),i.join(`
|
|
16
|
+
`)}l(Ae,"renderActiveTerminal");function ke(t,e,n){let r=(t.shell??"terminal").toLocaleLowerCase(),i=t.background===!0?"background":"wait",a=t.cwd===void 0?"workspace":N(t.cwd),o=t.shellFamily??"posix",s=[`${n.fg("accent",r)} ${n.fg("muted",`\xB7 ${a} \xB7 ${i}`)}`,`${n.fg("accent",X(o))} ${t.command??""}`],u=O(t.output??"",e);return u.omission!==void 0&&s.push(` ${n.fg("muted",u.omission)}`),u.lines.length>0&&s.push(...u.lines.map(c=>` ${n.fg("dim",c)}`)),s.push(I(t,(c,d)=>n.fg(c,d))),s}l(ke,"terminalCardLines");function pt(t,e){return O(t,e).lines}l(pt,"outputTail");function O(t,e){let n=$(ct(t).replaceAll("\r","")),r=n.content.split(`
|
|
17
|
+
`).map(u=>dt(u.trimEnd(),mt).text);r.at(-1)===""&&r.pop();let i=Number.isFinite(e)?Math.max(0,e):r.length,a=Math.max(0,r.length-i),o=Math.max(0,n.totalLines-n.outputLines),s=a+o;return{lines:r.slice(a),...n.truncated||s>0?{omission:s>0?`\u2026 ${s} earlier lines`:"\u2026 earlier output omitted"}:{}}}l(O,"outputWindow");function I(t,e){let n=t.status??"running",r=ft(n),i=n==="completed"?"success":n==="running"?"accent":"error",a=[`${r} ${n}`,ht(t.elapsedMs??0)];return t.waitReason!==void 0&&a.push(`background \xB7 ${t.waitReason}`),t.completionReason!==void 0&&a.push(`reason ${t.completionReason}`),t.exitCode!==void 0?a.push(`exit ${t.exitCode}`):t.signal!==void 0&&a.push(`signal ${t.signal}`),e(i,a.join(" \xB7 "))}l(I,"statusLine");function ft(t){return t==="completed"?"\u2713":t==="running"?"\u25CF":t==="stopping"?"\u25CC":"\u2717"}l(ft,"statusIcon");function X(t){return t==="powershell"?"PS>":t==="cmd"?">":"$"}l(X,"promptMarker");function gt(t,e){let n=(t.shell??"terminal").toLocaleLowerCase(),r=t.cwd===void 0?"workspace":N(t.cwd),i=t.background===!0?"background":"wait",a=V(t.command??"process",48);return`${e.fg("toolTitle",n)} ${e.fg("muted",`\xB7 ${r} \xB7 ${i} \xB7 ${a}`)}`}l(gt,"terminalIdentity");function N(t){let e=process.env.HOME;return e!==void 0&&(t===e||t.startsWith(`${e}${ut.sep}`))?`~${t.slice(e.length)}`:t}l(N,"shortCwd");function V(t,e){let n=t.replaceAll(/\s+/gu," ").trim();return n.length<=e?n:`${n.slice(0,e-1)}\u2026`}l(V,"oneLine");function ht(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}l(ht,"formatElapsed");function Ce(t){return{id:"terminal",onDidChange:l(e=>t.onDidChange(e),"onDidChange"),list:l(()=>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:l(n=>Ae(e,n).split(`
|
|
18
|
+
`),"renderSummary"),renderDetail:l(n=>k(e,!0,n),"renderDetail"),sendInput:l(n=>{Promise.resolve(t.write(e.source,n)).catch(()=>{})},"sendInput"),stop:l(()=>t.delete(e.source),"stop")})),"list")}}l(Ce,"terminalProcessProvider");import{setTimeout as bt}from"node:timers/promises";var yt="#d8dee9",Y="#111418",wt=["#000000","#cd0000","#00cd00","#cdcd00","#0000ee","#cd00cd","#00cdcd","#e5e5e5","#7f7f7f","#ff0000","#00ff00","#ffff00","#5c5cff","#ff00ff","#00ffff","#ffffff"];async function K(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:a}=await import("@napi-rs/canvas"),o=Math.max(0,Math.min(i.rows-1,n?.start??0)),s=Math.max(1,Math.min(i.rows-o,n?.count??i.rows)),u=i.cols*9+24,c=s*18+24,d=a(Math.max(1,Math.round(u*r)),Math.max(1,Math.round(c*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,h=Math.max(0,p.baseY);for(let g=0;g<s;g+=1){let S=p.getLine(h+o+g);if(S!==void 0)for(let y=0;y<i.cols;y+=1){let v=S.getCell(y);v===void 0||v.getWidth()===0||St(m,v,y,g)}}return i.status==="running"&&p.cursorY>=o&&p.cursorY<o+s&&(m.fillStyle="rgba(216, 222, 233, 0.75)",m.fillRect(12+p.cursorX*9,12+(p.cursorY-o)*18+18-2,9,2)),d.toBuffer("image/png").toString("base64")}l(K,"renderTerminalScreen");function St(t,e,n,r){let i=$e(e,"foreground"),a=$e(e,"background");e.isInverse()&&([i,a]=[a,i]);let o=12+n*9,s=12+r*18;a!==Y&&(t.fillStyle=a,t.fillRect(o,s,9*Math.max(1,e.getWidth()),18));let u=e.getChars();u.length!==0&&(t.font=`${e.isBold()?"bold ":""}14px monospace`,t.fillStyle=i,t.fillText(u,o,s),e.isUnderline()&&t.fillRect(o,s+18-2,9*Math.max(1,e.getWidth()),1))}l(St,"drawCell");function $e(t,e){let n=e==="foreground";if(n?t.isFgDefault():t.isBgDefault())return n?yt:Y;let i=n?t.isFgRGB():t.isBgRGB(),a=n?t.getFgColor():t.getBgColor();return i?`#${a.toString(16).padStart(6,"0")}`:Tt(a)}l($e,"cellColor");function Tt(t){let e=wt[t];if(e!==void 0)return e;if(t>=232){let s=8+(t-232)*10;return Ie(s,s,s)}let n=Math.max(0,t-16),r=Math.floor(n/36),i=Math.floor(n%36/6),a=n%6,o=l(s=>s===0?0:55+s*40,"channel");return Ie(o(r),o(i),o(a))}l(Tt,"ansiColor");function Ie(t,e,n){return`#${[t,e,n].map(r=>r.toString(16).padStart(2,"0")).join("")}`}l(Ie,"rgb");var Z="\0pi-terminal-write\0",J="\0pi-terminal-keys\0";function xt(t){let e=t?.find(u=>u==="image"||u==="sequence"||u.startsWith("image:")||u.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 u of e.slice(n+1).split(",")){let[c,d,m]=u.split("=");if(c===void 0||d===void 0||m!==void 0||d.length===0)throw new Error(`Invalid terminal ${r} view parameter: ${u}`);if(c!=="duration"&&c!=="interval"&&c!=="scale")throw new Error(`Unsupported terminal ${r} view parameter: ${c}`);let p=Number(d);if(!Number.isFinite(p))throw new Error(`Terminal ${c} must be a number`);i.set(c,p)}let a=i.get("duration")??2,o=i.get("interval")??.5,s=i.get("scale")??1;if(!(s>0&&s<=1))throw new Error("Terminal image scale must be greater than 0 and at most 1");if(r==="sequence"){if(!(a>0&&a<=10))throw new Error("Terminal sequence duration must be greater than 0 and at most 10 seconds");if(!(o>0))throw new Error("Terminal sequence interval must be greater than 0 seconds");if(Math.floor(a/o)+1>20)throw new Error("Terminal sequence capture is limited to 20 frames")}return{mode:r,duration:a,interval:o,scale:s}}l(xt,"parseTerminalVisualView");async function De(t,e){let n=new Map,r=new Map,i={protocol:re,apiVersion:ie,id:"terminal",setup(o){o.addResolver({resolver:vt(e),preserveTruncatedOutput:!0,renderResult(s,u,c){let d=s.details,m=d.source===void 0?void 0:e.get(d.source),p=m===void 0?{}:e.snapshot(m);return k(m===void 0?p:{...p,output:e.screenTail(m).join(`
|
|
19
|
+
`)},u.expanded,c,"read terminal")}}),o.addHandler({stage:"pre-read",async handler(s){let u=s.request.path;if(u===void 0||!x(u))return{kind:"continue",context:s};let c;try{c=xt(s.request.views)}catch(m){return{kind:"return",result:z(u,m instanceof Error?m.message:String(m))}}if(c===void 0)return{kind:"continue",context:s};let d=e.get(u);if(d===void 0)return{kind:"return",result:z(u,`Unknown terminal session ${u}`)};try{e.markInspected(u);let m=c.mode==="image"?1:Math.floor(c.duration/c.interval)+1,p=[];for(let h=0;h<m;h+=1){s.resolverContext.signal?.throwIfAborted(),h>0&&await bt(c.interval*1e3,void 0,{signal:s.resolverContext.signal});let g=await K(e,u,void 0,c.scale);p.push({type:"image",data:g,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:c.mode}}}}catch(m){return{kind:"return",result:z(u,m instanceof Error?m.message:String(m))}}}}),o.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."})}},a={protocol:se,apiVersion:ae,id:"terminal",setup(o){o.addResolver({resolver:Rt(e)}),o.tool("write").addHandler({stage:"text-pre-edit",handler:l(async s=>(Me(s.input,e,n),await Le(s.input,e,r),Pt(s,Z)),"handler")}),o.tool("insert").addHandler({stage:"text-pre-edit",handler:l(async s=>(await Le(s.input,e,r),Me(s.input,e,n),Et(s)),"handler")});for(let s of["write","insert","delete"])o.addToolRenderer({tool:s,matches:l((u,c)=>$t(u,c),"matches"),renderCall(u,c,d){let m=u,p=typeof m.path=="string"?e.get(m.path):void 0,h=d.state;return p!==void 0&&(h.snapshot=e.snapshot(p)),Pe(h.snapshot??{},s,_e(s,m),[],c)},renderResult(u,c,d){let m=Ct(u.details);return Re(m.action,m.changedLines,d)}});o.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."),o.tool("write").describe("When path is shell:<session>, send content exactly as terminal input without adding Enter."),o.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([oe(t,i),le(t,a)]),t.on("tool_result",async(o,s)=>{if(!R(o.input))return;let u=o.input.path;if(o.toolName==="replace"&&typeof u=="string"&&x(u)){let w=`replace is unsupported for ${u}; use write for text, insert for keys, or delete to terminate and remove the session.`;return L({content:[{type:"text",text:w}],details:o.details},_(o.toolName),{status:"error",errors:[q(w,"UNSUPPORTED_OPERATION",u)],data:{operation:"replace",effect:"not-applied",files:[{source:u,effect:"not-applied"}]}})}if(o.toolName==="delete"&&typeof u=="string"&&x(u)){let w=e.get(u);if(w===void 0)return;let A=e.snapshot(w);return e.delete(u).then(()=>L({content:[{type:"text",text:`Deleted terminal session ${u}.`}],details:{source:u,deleted:!0,snapshot:A,action:"delete",input:"session",changedLines:[]}},_(o.toolName),{status:"success",errors:[],data:{operation:"delete",effect:"applied",files:[{source:u,effect:"applied"}]}}),T=>L({content:[{type:"text",text:T instanceof Error?T.message:String(T)}],details:{source:u,deleted:!1}},_(o.toolName),{status:"error",errors:[q(T,"TERMINAL_DELETE_FAILED",u)],data:{operation:"delete",effect:"unknown",files:[{source:u,effect:"unknown"}]}}))}if(o.toolName!=="write"&&o.toolName!=="insert"||o.isError)return;let c=o.input.path;if(typeof c!="string"||!x(c))return;let d=e.get(c);if(d===void 0)return;let m=r.get(c)??e.screenRows(d);r.delete(c);let p=n.get(c)??d.outputStart+d.output.length;n.delete(c),await e.waitForOutputAfter(d,p);let h=e.snapshot(d),g=o.toolName,S=_e(g,o.input),y=e.screenChangeRegion(d,m,6),v=[{type:"text",text:`Sent ${S} to ${d.source}.`}];return s.model?.input.includes("image")===!0&&v.push({type:"image",data:await K(e,c,{start:y.startRow,count:y.lines.length}),mimeType:"image/png"}),{content:v,details:{source:d.source,action:g,status:d.status,snapshot:h,input:S,changedLines:y.lines},isError:o.isError,...o.structuredContent===void 0?{}:{structuredContent:o.structuredContent}}})}l(De,"registerTerminalResources");function vt(t){return{id:"terminal",async tryResolve(e){if(!x(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:At(r)}]}}}}}}l(vt,"createReadResolver");function Rt(t){return{id:"terminal-input",async tryResolve(e){if(!x(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=kt(r),a=i.indexOf(Z),o=i.indexOf(J);if(a>=0){await t.write(n.source,i.slice(a+Z.length));return}if(o>=0){await t.sendKeys(n.source,i.slice(o+J.length).trim());return}throw new Error(`Unsupported text operation for ${n.source}`)}}}}}}l(Rt,"createInputResolver");function Pt(t,e){return!R(t.input)||!Oe(t.input.path)?t:{...t,input:{...t.input,content:`${e}${typeof t.input.content=="string"?t.input.content:""}`}}}l(Pt,"transformWriteInput");function Et(t){if(!R(t.input)||!Oe(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:`${J}${typeof t.input.text=="string"?t.input.text:""}`}}}l(Et,"transformInsertInput");function At(t){return D(t)}l(At,"formatSnapshot");function kt(t){if(t.length!==1||t[0].type!=="text")throw new Error("Terminal input must contain one text block");return t[0].text}l(kt,"singleText");function z(t,e){return{content:[{type:"text",text:e}],details:{source:t,failure:{code:"READ_FAILED",source:t,resolverId:"terminal",message:e}},isError:!0}}l(z,"failure");function x(t){return/^shell:[a-f\d]{12}$/u.test(t)}l(x,"isShellSource");function Oe(t){return typeof t=="string"&&x(t)}l(Oe,"isShellSourceValue");function Ct(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}:{}}}}l(Ct,"terminalActionDetails");async function Le(t,e,n){if(!R(t)||typeof t.path!="string"||!x(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))}l(Le,"rememberScreen");function Me(t,e,n){if(!R(t)||typeof t.path!="string"||!x(t.path))return;let r=e.get(t.path);r!==void 0&&n.set(t.path,r.outputStart+r.output.length)}l(Me,"rememberOutputEnd");function _e(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}`}l(_e,"terminalInputLabel");function $t(t,e){if(!R(t))return!1;if(e==="call")return typeof t.path=="string"&&x(t.path);let n=t.details;return R(n)&&typeof n.source=="string"&&x(n.source)}l($t,"isTerminalRenderValue");function R(t){return typeof t=="object"&&t!==null}l(R,"isRecord");async function Ne(t,e){await de(t,{protocol:ue,apiVersion:ce,id:"terminal",setup(r){r.addResolver({resolver:It(e),priority:100}),r.describe("path shell:<session> searches the retained text output of that terminal, including rows outside its current screen.")}})}l(Ne,"registerTerminalSearch");function It(t){return{readResources:l(e=>e.path?.startsWith("shell:")?[e.path]:[],"readResources"),id:"terminal",toScriptData(e){let n=B(e);return pe(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=Lt(r,e);return{kind:"resolved",payload:{snapshot:r,query:e.query,matches:i}}},format(e){let n=B(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,a=Q(i)?B(i.payload):B(void 0);return me(a.matches,!1,r,n.expanded===!0,void 0,[`Retained terminal output \xB7 ${a.snapshot.status} \xB7 read-only`])}}}l(It,"terminalSearchResolver");function Lt(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[a,o]of t.output.replaceAll("\r","").split(`
|
|
23
|
+
`).entries()){let s=e.caseSensitive===!0?o:o.toLocaleLowerCase(),u=0;for(;r.length<i;){let c=s.indexOf(n,u);if(c<0)break;let d=c+n.length;(e.wholeWord!==!0||Mt(s,c,d))&&r.push({source:t.source,lineNumber:a+1,startColumn:c,endColumn:d,matchedText:o.slice(c,d),lineText:o}),u=Math.max(d,c+1)}if(r.length>=i)break}return r}l(Lt,"findTerminalMatches");function Mt(t,e,n){return!/[\p{L}\p{N}_]/u.test(t[e-1]??"")&&!/[\p{L}\p{N}_]/u.test(t[n]??"")}l(Mt,"isWordBoundary");function B(t){if(!_t(t))throw new TypeError("Invalid terminal search result");return t}l(B,"parsePayload");function _t(t){return Q(t)&&typeof t.query=="string"&&Array.isArray(t.matches)&&Q(t.snapshot)&&typeof t.snapshot.source=="string"}l(_t,"isTerminalSearchPayload");function Q(t){return typeof t=="object"&&t!==null}l(Q,"isRecord");import{spawn as Ot}from"node:child_process";import{closeSync as Nt,mkdirSync as Bt,openSync as Ut,rmSync as Wt,writeSync as Ft}from"node:fs";import jt from"node:os";import Fe from"node:path";import{createRequire as Ht}from"node:module";import{randomUUID as Gt}from"node:crypto";import{stripVTControlCharacters as qt}from"node:util";import{StringDecoder as Vt}from"node:string_decoder";import Dt from"node:os";import Be from"node:path";var U={executable:"/bin/bash",displayName:"Bash over SSH",family:"posix",commandArgs:l(t=>["-lc",t],"commandArgs")};function Ue(t=process.platform,e=process.env){if(t==="win32"){let i=e.SHELL?.trim()||"powershell.exe",a=Be.win32.basename(i).toLowerCase();return a==="cmd"||a==="cmd.exe"?{executable:i,displayName:"Command Prompt",family:"cmd",commandArgs:l(o=>["/d","/s","/c",o],"commandArgs")}:{executable:i,displayName:a.startsWith("pwsh")?"PowerShell":"Windows PowerShell",family:"powershell",commandArgs:l(o=>["-NoLogo","-NoProfile","-Command",o],"commandArgs")}}let n=e.SHELL?.trim()||Dt.userInfo().shell||(t==="darwin"?"/bin/zsh":"/bin/bash"),r=Be.basename(n);return{executable:n,displayName:r==="zsh"?"zsh":r==="bash"?"Bash":r,family:"posix",commandArgs:l(i=>["-c",i],"commandArgs")}}l(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.`}}l(We,"shellSyntaxGuidance");var Ge=Ht(new URL("../src/plugins/pi-agent-ide-terminal/src/session-manager.ts",import.meta.url).href),je=1e6,Xt=100,Yt=30,Kt=2e3,zt=50,F=class{static{l(this,"TerminalSessionManager")}#l;#e=new Map;#r=new Set;#i=new Set;#o=new Map;#s=new Map;#u=!1;constructor(e=Qt){this.#l=e}onDidChange(e){return this.#r.add(e),()=>this.#r.delete(e)}onDidComplete(e){return this.#i.add(e),()=>this.#i.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(en(e))}snapshot(e,n=Date.now()){return{id:e.id,source:e.source,...e.origin===void 0?{}:{origin:e.origin},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:a}=n,o;try{let u=Ge("node-pty"),c={name:"xterm-256color",cols:i,rows:a,cwd:e.cwd,env:nn(tn()),...globalThis.process.platform==="win32"?{useConptyDll:!0}:{}};o=u.spawn(e.shell.executable,[...e.shell.commandArgs(e.command)],c)}catch(u){let c={...n,status:"failed",endedAt:Date.now(),error:W(u)};return this.#e.set(r,c),this.#n(r),n.resolveCompletion(c),queueMicrotask(()=>this.#a(c)),c}let s={...n,process:o};return this.#e.set(r,s),o.onData(u=>this.#d(s,u)),globalThis.process.platform==="win32"&&s.screen.onData(u=>{if(!P(s.status))try{o.write(u)}catch{}}),o.onExit(({exitCode:u,signal:c})=>{P(s.status)||(s.endedAt=Date.now(),s.exitCode=u,c!==0&&(s.signal=c),s.status=s.status==="stopping"?"stopped":u===0?"completed":"failed",(u===124||u===137)&&(s.completionReason="timeout"),this.#n(s.id),s.resolveCompletion(s),this.#t(s),this.#a(s))}),this.#t(s),s}#c(e){if(this.#u)throw new Error("Terminal session manager is closed");let n=this.#l();if(!/^[a-f0-9]{12}$/u.test(n)||this.#e.has(n)||this.#s.has(n))throw new Error("Terminal session IDs must be unique 12-character hexadecimal values");let r=sn(n);this.#o.set(n,Ut(r,"a",384));let i=e.cols??Xt,a=e.rows??Yt,o=Jt(i,a),s=l(c=>{},"resolveCompletion"),u=new Promise(c=>{s=c});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:a,fullOutputPath:r,screen:o,status:"running",output:"",outputStart:0,screenReady:Promise.resolve(),completion:u,resolveCompletion:s,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.#s.set(r.id,{abort:i,completion:r.completion});let a=l(()=>i.abort(),"abortStartup");e.signal?.addEventListener("abort",a,{once:!0}),e.signal?.aborted&&a();try{let o=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",a)),s={...r,remote:{target:e.remote.location.target,process:o}};this.#e.set(s.id,s);let u=new Vt("utf8");o.stdout.on("data",d=>this.#d(s,u.write(d))),o.stderr.resume();let c=l(()=>{this.#d(s,u.end()),s.endedAt=Date.now(),this.#n(s.id),s.resolveCompletion(s),this.#t(s),this.#a(s)},"finish");return o.completion.then(({exitCode:d})=>{s.exitCode=d,d<0&&(s.signal=-d),s.status=s.status==="stopping"?"stopped":d===0?"completed":"failed",(d===124||d===137)&&(s.completionReason="timeout"),c()},d=>{s.status="lost",s.error=W(d),c()}),this.#t(s),s}catch(o){let s={...r,status:"failed",endedAt:Date.now(),error:W(o)};return this.#e.set(s.id,s),this.#n(s.id),s.resolveCompletion(s),queueMicrotask(()=>this.#a(s)),s}finally{this.#s.delete(r.id)}}async wait(e,n){let r=this.required(e);return P(r.status)?r:n?.aborted===!0?(await this.stop(r.source,"cancelled"),r):await new Promise((i,a)=>{let o=l(()=>{this.stop(r.source,"cancelled").then(i,a)},"onAbort");n?.addEventListener("abort",o,{once:!0}),r.completion.then(s=>{n?.removeEventListener("abort",o),i(s)},a)})}async waitForForeground(e,n){let r=this.required(e);if(P(r.status))return{session:r};let i=n.interactiveDelayMs??3e3;return await new Promise(a=>{let o=!1,s,u=l(p=>{o||(p!==void 0&&P(r.status)&&(p=void 0),o=!0,clearTimeout(d),clearInterval(m),n.signal?.removeEventListener("abort",c),p!==void 0&&(r.background=!0,p!=="aborted"&&(r.waitReason=p),this.#t(r)),a({session:r,...p===void 0?{}:{reason:p}}))},"finish"),c=l(()=>u("aborted"),"onAbort"),d=setTimeout(()=>u("timeout"),n.timeoutMs),m=setInterval(()=>{if(!Zt(r)){s=void 0;return}s??=Date.now(),Date.now()-s>=i&&u("interactive")},Math.min(100,Math.max(10,i/2)));n.signal?.addEventListener("abort",c,{once:!0}),n.signal?.aborted===!0&&c(),r.completion.then(()=>u())})}async waitForOutputAfter(e,n){let r=Date.now()+300,i=n,a;for(;Date.now()<r;){let o=e.outputStart+e.output.length;if(o!==i)i=o,a=Date.now(),await e.screenReady;else if(a!==void 0&&Date.now()-a>=40)return;await ee(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),a=Math.max(1,Math.min(e.rows,r)),o=Math.max(0,e.screen.buffer.active.cursorY-Math.floor(a/2)),s=-1;for(let d=0;d<=e.rows-a;d+=1){let m=0;for(let p=d;p<d+a;p+=1){let h=n[p]??"",g=i[p]??"",S=g.length>0&&!n.includes(g),y=h.length>0&&g.length===0;h!==g&&(S||y)&&(m+=1)}m>s&&(s=m,o=d)}let u=e.screen.buffer.active;return{lines:i.slice(o,o+a).map((d,m)=>{if(o+m!==u.cursorY)return d;let h=d.padEnd(u.cursorX," ");return`${h.slice(0,u.cursorX)}\u258C${h.slice(u.cursorX)}`}),startRow:o}}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),a=[];for(let o=0;o<e.rows;o+=1){let s=r.getLine(i+o)?.translateToString(!0).trimEnd();s!==void 0&&s.length>0&&a.push(s)}return a.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,rn(n))}async stop(e,n="stopped"){let r=this.required(e);return P(r.status)||(r.status="stopping",this.#t(r),await He(r,!1),await Promise.race([r.completion.then(()=>!0),ee(Kt).then(()=>!1)])||(await He(r,!0),await Promise.race([r.completion,ee(1e3)])),P(r.status)||(r.status=n,r.endedAt=Date.now(),this.#n(r.id),r.resolveCompletion(r),this.#a(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.#n(n.id),Wt(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=[],a=Math.max(0,r.baseY);for(let o=a;o<a+n.rows;o+=1)i.push(r.getLine(o)?.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.#u)return;this.#u=!0;let e=[...this.#s.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=>!P(n.status)).map(n=>this.stop(n.source)));for(let n of this.#e.values())n.screen.dispose(),this.#n(n.id);this.#r.clear(),this.#i.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}#d(e,n){e.lastActivityAt=Date.now();let r=qt(n),i=this.#o.get(e.id);if(i!==void 0&&Ft(i,r),e.output+=r,e.output.length>je){let a=e.output.length-je;e.output=e.output.slice(a),e.outputStart+=a}e.screenReady=e.screenReady.then(()=>new Promise(a=>{e.screen.write(n,a)})),this.#t(e)}#n(e){let n=this.#o.get(e);n!==void 0&&(Nt(n),this.#o.delete(e))}#t(e){for(let n of this.#r)n(e)}#a(e){for(let n of this.#i)n(e);this.#m()}#m(){let e=[...this.#e.values()].filter(n=>P(n.status)).sort((n,r)=>(r.endedAt??0)-(n.endedAt??0));for(let n of e.slice(zt))n.background&&!n.completionDelivered||(n.screen.dispose(),this.#n(n.id),this.#e.delete(n.id))}};function Zt(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)}l(Zt,"looksInteractive");function Jt(t,e){let{Terminal:n}=Ge("@xterm/headless");return new n({cols:t,rows:e,scrollback:2e3,allowProposedApi:!0})}l(Jt,"createScreen");function Qt(){return Gt().replaceAll("-","").slice(0,12)}l(Qt,"defaultSessionId");function en(t){return t.startsWith("shell:")?t.slice(6):t}l(en,"normalizeSessionId");function P(t){return t!=="running"&&t!=="stopping"}l(P,"isTerminalStatus");function tn(){return process.env}l(tn,"processEnvironment");function nn(t){return{...Object.fromEntries(Object.entries(t).filter(e=>e[1]!==void 0)),PAGER:"cat",GIT_PAGER:"cat",SYSTEMD_PAGER:"cat",GH_PAGER:"cat"}}l(nn,"cleanEnvironment");function rn(t){return t.split(/[\s,]+/u).filter(Boolean).map(on).join("")}l(rn,"encodeTerminalKeys");function on(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"),a=r.has("alt")||r.has("meta"),o=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 a?`\x1B${m}`:m}let s={enter:"\r",tab:" ",escape:"\x1B",esc:"\x1B",backspace:"\x7F",home:"\x1B[H",end:"\x1B[F",delete:"\x1B[3~"};if(!i&&!a&&!o&&s[n]!==void 0)return s[n];if(a&&!i&&!o&&s[n]!==void 0)return`\x1B${s[n]}`;let c={up:"A",down:"B",right:"C",left:"D",home:"H",end:"F"}[n];if(c!==void 0)return!i&&!a&&!o?`\x1B[${c}`:`\x1B[1;${1+(o?1:0)+(a?2:0)+(i?4:0)}${c}`;if(a&&!i&&n.length===1)return`\x1B${o?n.toUpperCase():n}`;throw new Error(`Unsupported terminal key ${t}`)}l(on,"encodeTerminalKey");async function He(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=Ot("taskkill.exe",["/PID",String(n.pid),"/T",...e?["/F"]:[]],{windowsHide:!0,stdio:"ignore"});i.once("error",()=>r()),i.once("exit",()=>r())})}}l(He,"terminateProcessTree");function ee(t){return new Promise(e=>setTimeout(e,t))}l(ee,"delay");function W(t){return t instanceof Error?t.message:String(t)}l(W,"errorMessage");function sn(t){let e=Fe.join(jt.tmpdir(),`pi-agent-ide-terminal-${process.pid}`);return Bt(e,{recursive:!0,mode:448}),Fe.join(e,`${t}.log`)}l(sn,"createOutputLog");import{AgentSession as an}from"@earendil-works/pi-coding-agent";var j=Symbol.for("pi-agent-ide.terminal-steering-observers");function qe(t){let e=an.prototype,n=e[j]??ln(e);return n.listeners.add(t),()=>{n.listeners.delete(t),n.listeners.size===0&&n.restore()}}l(qe,"observeQueuedSteering");function ln(t){let e=t.prompt,n=t.steer,r=new Set,i=l(u=>{for(let c of[...r])c(u)},"notify"),a=l(function(u,c){return c?.streamingBehavior!=="steer"?e.call(this,u,c):e.call(this,u,{...c,preflightResult:l(d=>{c.preflightResult?.(d),d==="queued"&&i(this)},"preflightResult")})},"prompt"),o=l(async function(...u){let c=await n.apply(this,u);return c==="queued"&&i(this),c},"steer");t.prompt=a,t.steer=o;let s={listeners:r,restore:l(()=>{t[j]===s&&(t.prompt===a&&(t.prompt=e),t.steer===o&&(t.steer=n),delete t[j])},"restore")};return t[j]=s,s}l(ln,"installObservers");import Ke from"node:path";import{stripVTControlCharacters as cn}from"node:util";import{defineTool as dn}from"@earendil-works/pi-coding-agent";import{Type as b}from"typebox";import{Text as mn}from"@earendil-works/pi-tui";import{open as un}from"node:fs/promises";import{Type as f}from"typebox";var Ve=1024*1024,Xe=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 un(t.fullOutputPath,"r");try{let n=(await e.stat()).size,r=l(async(s,u)=>{let c=Buffer.alloc(u),d=0;for(;d<u;){let m=await e.read(c,d,u-d,s+d);if(m.bytesRead===0)throw new Error("Shell output log ended before its snapshot size");d+=m.bytesRead}return c},"readRange"),i,a,o=n>Ve;if(!o)i=(await r(0,n)).toString("utf8"),a=[{start:0,end:n}];else{let s=Ve/2,u=await r(0,s),c=await r(n-s,s),d=new TextDecoder().decode(u,{stream:!0}),m=0;for(;m<c.length&&(c.readUInt8(m)&192)===128;)m++;let p=c.subarray(m).toString("utf8");i=d+p,a=[{start:0,end:Buffer.byteLength(d)},{start:n-s+m,end:n}]}return{output:i,truncated:o,full_output_path:t.fullOutputPath,output_ranges:a,...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()}}l(Ye,"structuredShellResult");var pn=l(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 ze(t,e,n,r,i="compact",a=new M([]),o){let s=new Set,u=process.platform==="win32"?"powershell":"bash",c=pn(n);return t.registerTool(dn({name:u,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 ${u} 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 ${u} 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:Xe,async execute(d,m,p,h,g){r.bind(g);let S=o?.(d,g),y=a.resolve(m.cwd??g.cwd,g.cwd),v={command:m.command,background:m.background??!1,...m.cols===void 0?{}:{cols:m.cols},...m.rows===void 0?{}:{rows:m.rows}},w=y?await e.startRemote({...v,remote:y,...p===void 0?{}:{signal:p}}):e.start({...v,cwd:m.cwd===void 0?g.cwd:Ke.resolve(g.cwd,m.cwd),shell:n});if(w.origin??=S,m.background===!0&&w.status!=="failed")return await fn(e,w,h),w.status!=="running"&&(w.completionDelivered=!0),H(e.snapshot(w));if(w.status==="failed")return H(e.snapshot(w));let A=new AbortController;s.add(A);let T;try{T=await e.waitForForeground(w.source,{signal:p===void 0?A.signal:AbortSignal.any([p,A.signal]),timeoutMs:(m.timeoutSeconds??60)*1e3})}finally{s.delete(A)}return T.reason==="aborted"&&A.signal.aborted&&p?.aborted!==!0?(T.session.waitReason="steering",H(e.snapshot(T.session))):(T.reason==="aborted"&&r.notifyWaitTransition(T.session),H(e.snapshot(T.session)))},renderCall(d,m,p){if((p.expanded?"full":i)==="disabled")return new mn(m.fg("toolTitle",u),0,0);let g=typeof d.command=="string"?d.command:"",S=typeof d.cwd=="string"&&d.cwd.startsWith("ssh:"),y=typeof d.cwd=="string"?S?d.cwd:Ke.resolve(process.cwd(),d.cwd):process.cwd();return ve(g,d.background===!0,y,S?U:n,m)},renderResult(d,m,p){return Ee(d.details,m.expanded?"full":i,p)}})),()=>{for(let d of s)d.abort()}}l(ze,"registerTerminalTools");function Ze(t){let e=$(t.output).content;return{content:[{type:"text",text:D(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"}}l(Ze,"terminalPreview");async function H(t){return{...Ze(t),structuredContent:await Ye(t)}}l(H,"terminalResult");async function fn(t,e,n){await new Promise(r=>{let i=!1,a,o=l(()=>{},"unsubscribe"),s=l(()=>{i||(i=!0,clearTimeout(a),o(),r())},"finish"),u=l(()=>{let c=t.snapshot(e);n?.(Ze(c)),(cn(c.output).replaceAll("\r","").split(`
|
|
24
|
+
`).filter(m=>m.length>0).length>=C||c.status!=="running")&&s()},"publish");o=t.onDidChange(c=>{c.id===e.id&&u()}),a=setTimeout(s,2e3),u()})}l(fn,"captureInitialBackgroundPreview");import{Box as et,Container as tt}from"@earendil-works/pi-tui";var gn=120,hn=12e4,G=class{constructor(e,n,r=hn){this.pi=e;this.manager=n;this.staleIntervalMs=r;e.registerMessageRenderer("terminal-stale",(i,{expanded:a},o)=>Je(i.details,a,o)),e.registerMessageRenderer("terminal-completion",(i,{expanded:a},o)=>Qe(i.details,a,o)),e.registerEntryRenderer("terminal-stale-display",(i,{expanded:a},o)=>Je(i.data,a,o)),e.registerEntryRenderer("terminal-completion-display",(i,{expanded:a},o)=>Qe(i.data,a,o)),this.#u=[n.onDidChange(i=>this.#c(i)),n.onDidComplete(i=>{this.#a(i.id),i.background&&this.#m(i)})]}static{l(this,"TerminalUi")}#l=new Map;#e;#r=new Map;#i=new Set;#o;#s=!1;#u;bind(e){this.#o=e;for(let n of this.manager.list()){let r=this.manager.get(n.id);r===void 0||!r.background||(r.status==="running"?this.#c(r):r.status!=="stopping"&&this.#m(r))}}onAgentSettled(e){this.#o=e;for(let n of[...this.#i]){this.#i.delete(n);let r=this.manager.get(n);r!==void 0&&this.#c(r,!0)}}notifyWaitTransition(e){let n=this.#n(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.#s=!0,this.#e!==void 0&&clearTimeout(this.#e),this.#e=void 0,this.#l.clear();for(let e of this.#r.values())clearTimeout(e);this.#r.clear(),this.#i.clear(),this.#o=void 0;for(let e of this.#u)e()}#c(e,n=!1){if(this.#a(e.id),this.#s||e.staleReminderDelivered||!e.background||e.status!=="running")return;let r=this.#n(e),i=Math.max(0,this.staleIntervalMs-r.idleMs);if(n&&i===0){this.#d(e);return}this.#r.set(e.id,setTimeout(()=>this.#d(e),i))}#d(e){if(this.#r.delete(e.id),this.#s||e.staleReminderDelivered||e.status!=="running"||!e.background)return;if(this.#o?.isIdle()!==!0){this.#i.add(e.id);return}e.staleReminderDelivered=!0;let n=this.#n(e);this.pi.sendMessage({customType:"terminal-stale",display:!1,content:Sn(n),details:n},{triggerTurn:!0,deliverAs:"followUp"}),this.pi.appendEntry("terminal-stale-display",{...n,...this.#t(n)})}#n(e){return{...this.manager.snapshot(e),...e.origin===void 0?{}:{origin:e.origin}}}#t(e){let n=e.origin;return n!==void 0&&n.sessionId===this.#o?.sessionManager.getSessionId()?{parentToolCallId:n.parentToolCallId}:{}}#a(e){let n=this.#r.get(e);n!==void 0&&clearTimeout(n),this.#r.delete(e),this.#i.delete(e)}#m(e){this.#s||e.completionDelivered||(this.#l.set(e.id,e),this.#e===void 0&&(this.#e=setTimeout(()=>{this.#e=void 0;let n=[...this.#l.values()].filter(a=>!a.completionDelivered);if(this.#l.clear(),this.#s||n.length===0)return;for(let a of n)a.completionDelivered=!0;let r=n.map(a=>this.#n(a));this.pi.sendMessage({customType:"terminal-completion",display:!1,content:wn(r),details:{sessions:r}},{triggerTurn:!0,deliverAs:"steer"});let i=new Map;for(let a of r){let o=this.#t(a).parentToolCallId,s=i.get(o)??[];s.push(a),i.set(o,s)}for(let[a,o]of i)this.pi.appendEntry("terminal-completion-display",{sessions:o,...a===void 0?{}:{parentToolCallId:a}})},gn)))}};function Je(t,e,n){let r=new tt;nt(t)&&r.addChild(k(t,e,n,"stale \xB7 inspect session"));let i=new et(1,1,a=>n.bg("toolPendingBg",a));return i.addChild(r),i}l(Je,"renderStale");function Qe(t,e,n){let r=new tt;for(let a of yn(t))r.addChild(k(a,e,n));let i=new et(1,1,a=>n.bg("toolSuccessBg",a));return i.addChild(r),i}l(Qe,"renderCompletion");function yn(t){return!it(t)||!Array.isArray(t.sessions)?[]:t.sessions.filter(nt)}l(yn,"completionSnapshots");function nt(t){return it(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"}l(nt,"isTerminalSessionSnapshot");function wn(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}`,a=n.output.trimEnd().slice(-2e3);return`- ${n.source}: ${n.status}${r}${i}, ${rt(n.elapsedMs)}
|
|
26
|
+
${a||"(no output)"}`}).join(`
|
|
27
|
+
`)}`}l(wn,"formatCompletionMessage");function Sn(t){let e=t.output.trimEnd().slice(-2e3);return`Background terminal ${t.source} has produced no output for ${rt(t.idleMs)}. Inspect it with read. If it is healthy, keep waiting; otherwise send input or stop it.
|
|
28
|
+
${e||"(no output)"}`}l(Sn,"formatStaleMessage");function rt(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}l(rt,"formatElapsed");function it(t){return typeof t=="object"&&t!==null}l(it,"isRecord");function ot(t){let e=new Map;return t.on("tool_call",n=>{let r=n.parentToolCallId;e.set(n.toolCallId,r===void 0?n.toolCallId:e.get(r)??r)}),t.on("tool_result",n=>{e.delete(n.toolCallId)}),t.on("agent_end",()=>{e.clear()}),t.on("session_shutdown",()=>{e.clear()}),(n,r)=>({toolCallId:n,parentToolCallId:e.get(n)??n,sessionId:r.sessionManager.getSessionId()})}l(ot,"registerTerminalOrigins");function st(t){return t==="full"||t==="disabled"?t:"compact"}l(st,"toolPresentation");async function Tn(t,e){ne(t,[await te({id:"terminal",description:"Foreground and background commands, shell resources, and processes",triggers:[{tool:"bash"},{tool:"powershell"},...["read","write","insert","delete"].map(c=>({tool:c,resourcePrefixes:["shell:","process:"]}))]})]);let n=Se("terminal")??new F,r=Ue(),i=new M(await he(ge(fe()))),a=new G(t,n),o=ye(t).add(Ce(n));await Promise.all([De(t,n),Ne(t,n)]);let s=ze(t,n,r,a,st(e?.preferences["ui.terminal"]),i,ot(t)),u=l(()=>{},"removeSteeringObserver");t.on("session_start",(c,d)=>{a.bind(d),u(),u=qe(m=>{m.sessionManager===d.sessionManager&&s()})}),t.on("agent_settled",(c,d)=>a.onAgentSettled(d)),t.on("session_shutdown",async c=>{if(u(),a.dispose(),o(),c.reason!=="quit"){we("terminal",n);return}Te("terminal",n),await n.dispose()})}l(Tn,"registerTerminal");export{Tn as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as h,g as w,m as P}from"./chunk-
|
|
1
|
+
import{c as h,g as w,m as P}from"./chunk-235QMMVA.js";import{a as E,c as T}from"./chunk-LCWBVOII.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a as o}from"./chunk-EI7MMDWY.js";import{AsyncLocalStorage as S}from"node:async_hooks";var p=new S,m=new S;function C(t){let e=m.getStore();e?e.push(t):t()}o(C,"afterPostEditScope");async function O(t){if(m.getStore())return t();let e=[];try{return await m.run(e,t)}finally{for(let r of e)r()}}o(O,"collectPostEditNotifications");function q(t,e){let r=p.getStore();return r?r.immediate?(r.pending.delete(t),!1):(r.pending.set(t,e),!0):!1}o(q,"deferPostEdit");function D(t){return p.getStore()?.pending.has(t)??!1}o(D,"hasDeferredPostEdit");function F(t){p.getStore()?.pending.delete(t)}o(F,"forgetDeferredPostEdit");function L(t=process.cwd()){let e=new Map;return{run(r,a=!1){return p.run({pending:e,immediate:a},r)},forget(r){e.delete(r)},sources(){return[...e.keys()]},async finish(r,a){let s=[...e];e.clear();let c=[],i=[];if(await O(async()=>{let u=new E,b=await Promise.allSettled(s.map(([g,d])=>u.run(T(g,t,"write"),d)));for(let[g,d]of b.entries()){let y=x(s[g])[0];if(d.status==="rejected"){i.push(d.reason);try{a?.(y,d.reason)}catch(l){i.push(l)}continue}c.push(d.value);try{r?.(d.value)}catch(l){i.push(l);try{a?.(y,l)}catch(k){i.push(k)}}}}),i.length>0)throw new AggregateError(i,`Some final post-processing failed; completed edits remain applied. ${i.map(u=>u instanceof Error?u.message:String(u)).join("; ")}`);return c}}}o(L,"createPostEditScope");import{Type as n}from"typebox";import{Value as f}from"typebox/value";var A=`${h}/post-edit/register`;function $(t){return f.Check(n.Object({formatting:n.Object({status:n.Union(["disabled","unavailable","skipped-syntax","unchanged","changed","failed","not-reported","deferred"].map(e=>n.Literal(e))),formatter:n.Optional(n.String())})}),t)}o($,"isFormattingContribution");function W(t){return f.Check(n.Object({diffStatuses:n.Array(n.Object({text:n.String({minLength:1}),origin:n.Optional(n.Literal("after-edit")),formatter:n.Optional(n.String()),tone:n.Optional(n.Union(["muted","success","warning","error"].map(e=>n.Literal(e))))}))}),t)}o(W,"isDiffStatusContribution");var R=n.Function([],n.Unknown()),v=n.Object({id:n.String({minLength:1}),handler:R}),H=n.Object({registration:v,accept:R});function j(t){return f.Check(v,t)}o(j,"isTextPostEditHandlerRegistration");function B(t){return f.Check(H,t)}o(B,"isTextPostEditHandlerRegistrationRequest");function G(t){if(typeof t!="object"||t===null)return!1;let e=t;return Array.isArray(e.hints)&&typeof e.scopeMarkers=="object"&&e.scopeMarkers!==null&&Array.isArray(e.warnings)}o(G,"isTextMutationResultContributionData");function K(t,e){if(!j(e))throw new TypeError("Invalid text editor post-edit handler registration");let r,a=o(()=>{let c={registration:e,accept(i){if(r!==void 0)throw new Error(`Post-edit handler ${e.id} was accepted more than once`);r=i}};return t.events.emit(A,c),r!==void 0},"announce"),s=o(()=>{},"unsubscribeReady");s=t.events.on(w,c=>{if(!P(c))throw new Error("Invalid pi-agent-text-editor core readiness event");if(!a())throw new Error("pi-agent-text-editor core announced readiness without accepting the post-edit handler");s()}),t.on("session_shutdown",()=>{s(),r?.()}),a()&&s()}o(K,"connectTextEditorPostEditHandler");export{C as a,O as b,q as c,D as d,F as e,L as f,A as g,$ as h,W as i,j,B as k,G as l,K as m};
|