pi-agent-ide 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/README.md +81 -23
- package/assets/gallery/apply-editing.png +0 -0
- package/assets/gallery/debugging.png +0 -0
- package/assets/gallery/read-web.png +0 -0
- package/assets/gallery/search-replace.png +0 -0
- package/assets/gallery/terminal.png +0 -0
- package/assets/gallery/tool-editing.png +0 -0
- package/dist/chunk-22CLOM2D.js +1 -0
- package/dist/{chunk-LY6U5EAD.js → chunk-2527OQ4Y.js} +1 -1
- package/dist/chunk-3XJ3KDPZ.js +16 -0
- package/dist/chunk-5JELU6RV.js +7 -0
- package/dist/chunk-DDKHZZDO.js +5 -0
- package/dist/chunk-FEDVTZJG.js +1 -0
- package/dist/chunk-HSM6R7IB.js +27 -0
- package/dist/chunk-K5G4FDXD.js +1 -0
- package/dist/chunk-M5IVSCR2.js +1 -0
- package/dist/chunk-OYWIZII6.js +1 -0
- package/dist/chunk-P7XO5CIP.js +2 -0
- package/dist/chunk-PCZH7GOX.js +26 -0
- package/dist/{chunk-DQXPQOF7.js → chunk-SQ7ZTGOP.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 -0
- package/dist/entry-18.js +1 -1
- package/dist/entry-19.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +1 -1
- package/dist/entry-22.js +1 -2
- package/dist/entry-23.js +2 -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 -12
- package/dist/entry-28.js +12 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +1 -1
- package/dist/entry-32.js +1 -4
- package/dist/entry-33.js +3 -8
- package/dist/entry-34.js +9 -1
- package/dist/entry-35.js +1 -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-40.js +1 -1
- package/dist/entry-41.js +1 -18
- package/dist/entry-42.js +18 -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 -7
- package/dist/entry-47.js +7 -11
- package/dist/entry-48.js +11 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -0
- package/dist/entry-57.js +0 -1
- package/dist/entry-58.js +1 -0
- package/dist/entry-59.js +0 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-64.js +1 -1
- package/dist/entry-65.js +1 -0
- package/dist/entry-66.js +0 -1
- package/dist/entry-67.js +1 -0
- package/dist/entry-68.js +0 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +1 -203
- package/dist/entry-72.js +254 -25
- package/dist/entry-73.js +30 -2
- package/dist/entry-74.js +2 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +3 -3
- package/dist/entry-78.js +3 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +1 -1
- package/dist/entry-81.js +1 -0
- package/dist/pi-agent-ide.js +3 -3
- package/docs/configuration.md +3 -1
- package/docs/development.md +0 -6
- package/docs/tools.md +12 -0
- package/node_modules/pi-agent-doctor/package.json +6 -6
- package/node_modules/pi-agent-doctor/runtime/entry-22.js +1 -0
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/runtime/entry-26.js +2 -0
- package/node_modules/pi-agent-ide-ast/package.json +12 -11
- package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +0 -1
- package/node_modules/pi-agent-ide-ast/runtime/entry-28.js +2 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +8 -6
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/runtime/entry-29.js +0 -1
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +3 -1
- package/node_modules/pi-agent-ide-lsp/package.json +10 -10
- package/node_modules/pi-agent-ide-lsp/runtime/entry-34.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 +11 -11
- package/node_modules/pi-agent-read/runtime/entry-41.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-42.js +2 -0
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +11 -6
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-search/package.json +7 -7
- package/node_modules/pi-agent-search/runtime/entry-46.js +0 -1
- package/node_modules/pi-agent-search-text/package.json +9 -9
- package/node_modules/pi-agent-search-text/runtime/entry-48.js +1 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +32 -27
- package/node_modules/pi-agent-search-text/src/search-session.ts +27 -1
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-50.js +1 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-51.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/index.ts +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-52.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-53.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/src/config.ts +2 -2
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-54.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-55.js +2 -0
- package/node_modules/pi-agent-text-editor/package.json +25 -25
- package/node_modules/pi-agent-text-editor/runtime/entry-71.js +0 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +125 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +14 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +32 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +21 -19
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +37 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +85 -34
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +2 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +589 -241
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +5 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +3 -3
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +9 -1
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +53 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +11 -41
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +8 -18
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +11 -41
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -19
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-76.js +1 -0
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/src/resolver.ts +128 -1
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-81.js +2 -0
- package/package.json +44 -39
- package/src/api/path-identity.ts +15 -0
- package/src/composite/builtin-extensions.ts +7 -2
- package/src/composite/module-labels.ts +4 -0
- package/src/composite/module-settings.ts +34 -14
- package/src/composite/preferences.ts +46 -3
- package/src/composite/selection.ts +5 -1
- package/src/doctor/inventory.ts +7 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- 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-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-26.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-23.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-81.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-77.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +128 -1
- package/src/extensions/pi-agent-read/package.json +11 -11
- package/src/extensions/pi-agent-read/runtime/entry-41.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-42.js +2 -0
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +11 -6
- package/src/extensions/pi-agent-search/package.json +7 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-49.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +32 -27
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +27 -1
- package/src/extensions/pi-agent-search/runtime/entry-46.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-47.js +2 -0
- package/src/extensions/pi-agent-text-editor/package.json +25 -25
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-51.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-52.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-53.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/config.ts +2 -2
- 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-54.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-55.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-71.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-72.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +125 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +14 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +32 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +21 -19
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +37 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +85 -34
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +2 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +589 -241
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +5 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +3 -3
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +9 -1
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +53 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +11 -41
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +8 -18
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +11 -41
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -19
- package/src/pi-agent-ide.ts +15 -2
- package/src/plugins/pi-agent-ide-ast/package.json +12 -11
- package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-28.js +2 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +8 -6
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/runtime/entry-29.js +0 -1
- package/src/plugins/pi-agent-ide-debugger/index.ts +3 -9
- package/src/plugins/pi-agent-ide-debugger/src/adapter-executables.ts +31 -0
- package/src/plugins/pi-agent-ide-debugger/src/breakpoint-view.ts +3 -1
- package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +24 -23
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +5 -2
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +55 -17
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -22
- 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/src/command-linter.ts +3 -1
- package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-34.js +2 -0
- package/src/plugins/pi-agent-ide-processes/src/registry.ts +6 -0
- package/src/plugins/pi-agent-ide-processes/src/ui.ts +28 -11
- package/src/plugins/pi-agent-ide-terminal/index.ts +1 -1
- package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +2 -0
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +32 -2
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +5 -4
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +2 -2
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +3 -1
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +1 -1
- package/src/plugins/pi-agent-ide-vision/index.ts +232 -0
- package/src/plugins/pi-agent-ide-vision/src/vision.ts +530 -0
- package/src/plugins/pi-agent-ide-vision/src/windows-display-capture.ps1 +30 -0
- package/src/plugins/pi-agent-ide-vision/src/windows-window-capture.ps1 +33 -0
- package/dist/chunk-5PLV4HLG.js +0 -1
- package/dist/chunk-BGUSBUUD.js +0 -26
- package/dist/chunk-G725MARR.js +0 -16
- package/dist/chunk-HKXDP2FD.js +0 -7
- package/dist/chunk-J4RTW44E.js +0 -1
- package/dist/chunk-QH4ZUDOD.js +0 -1
- package/dist/chunk-WGGIQ7IJ.js +0 -1
- package/dist/chunk-ZG2MWXCR.js +0 -2
- package/dist/chunk-ZUMN6U77.js +0 -27
- package/dist/entry-17.js +0 -1
- package/docs/evaluation.md +0 -14
- package/node_modules/pi-agent-doctor/runtime/entry-17.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-22.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-28.js +0 -1
- package/node_modules/pi-agent-image/runtime/entry-34.js +0 -1
- package/node_modules/pi-agent-resource/runtime/entry-42.js +0 -1
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-50.js +0 -2
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-55.js +0 -1
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-74.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-23.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-22.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-77.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-37.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +0 -2
- package/src/extensions/pi-agent-search/runtime/entry-43.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-50.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-72.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-55.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +0 -1
- package/src/plugins/pi-agent-ide-changes/runtime/entry-28.js +0 -1
- /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-23.js +0 -0
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-24.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-25.js +0 -0
- /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-30.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-32.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-35.js +0 -0
- /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-36.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-37.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-43.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-47.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-49.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-72.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-73.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-75.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-80.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-24.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-25.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-78.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-80.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-73.js +0 -0
- /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-30.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-31.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-32.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-33.js +0 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
|
|
5
|
+
import { createCanvas, loadImage } from "@napi-rs/canvas";
|
|
6
|
+
import type { ImageContent } from "pi-agent-resource";
|
|
7
|
+
|
|
8
|
+
import type { AgentIdeProcessRegistry } from "#src/plugins/pi-agent-ide-processes/src/registry.js";
|
|
9
|
+
|
|
10
|
+
const execFileAsync = promisify(execFile);
|
|
11
|
+
const MAX_CAPTURE_BYTES = 20 * 1024 * 1024;
|
|
12
|
+
|
|
13
|
+
let visionDefaults: VisionDefaults = { durationSeconds: 2, intervalSeconds: 0.5, scale: 0.5 };
|
|
14
|
+
let allowedExecutables = new Set<string>();
|
|
15
|
+
|
|
16
|
+
export interface VisionDefaults {
|
|
17
|
+
readonly durationSeconds: number;
|
|
18
|
+
readonly intervalSeconds: number;
|
|
19
|
+
readonly scale: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface VisionRegion {
|
|
23
|
+
readonly x: number;
|
|
24
|
+
readonly y: number;
|
|
25
|
+
readonly width: number;
|
|
26
|
+
readonly height: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface VisionOptions {
|
|
30
|
+
readonly mode: "image" | "sequence";
|
|
31
|
+
readonly durationSeconds?: number;
|
|
32
|
+
readonly intervalSeconds?: number;
|
|
33
|
+
readonly scale?: number;
|
|
34
|
+
readonly region?: VisionRegion;
|
|
35
|
+
/** Square grid cell size in pixels. Omit to return the bounded full image. */
|
|
36
|
+
readonly cellSize?: number;
|
|
37
|
+
/** Zero-based row-major cell index. Requires cellSize and defaults to zero. */
|
|
38
|
+
readonly cellIndex?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ProcessMetadata {
|
|
42
|
+
readonly pid: number;
|
|
43
|
+
readonly parentPid?: number;
|
|
44
|
+
readonly command: string;
|
|
45
|
+
readonly started?: string;
|
|
46
|
+
readonly owned: boolean;
|
|
47
|
+
readonly source?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface CaptureBackend {
|
|
51
|
+
captureWindow(pid: number, signal?: AbortSignal): Promise<Uint8Array>;
|
|
52
|
+
captureDisplay(index: number, signal?: AbortSignal): Promise<Uint8Array>;
|
|
53
|
+
captureUrl(url: URL, signal?: AbortSignal): Promise<Uint8Array>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Configures capture defaults and the exact executable allowlist for this runtime. */
|
|
57
|
+
export function configureVision(settings: {
|
|
58
|
+
readonly durationSeconds?: string;
|
|
59
|
+
readonly intervalSeconds?: string;
|
|
60
|
+
readonly scale?: string;
|
|
61
|
+
readonly allowedExecutables?: string;
|
|
62
|
+
}): void {
|
|
63
|
+
const defaults = validateVisionOptions({
|
|
64
|
+
mode: "sequence",
|
|
65
|
+
durationSeconds: Number(settings.durationSeconds ?? 2),
|
|
66
|
+
intervalSeconds: Number(settings.intervalSeconds ?? 0.5),
|
|
67
|
+
scale: Number(settings.scale ?? 0.5),
|
|
68
|
+
});
|
|
69
|
+
visionDefaults = {
|
|
70
|
+
durationSeconds: defaults.durationSeconds as number,
|
|
71
|
+
intervalSeconds: defaults.intervalSeconds as number,
|
|
72
|
+
scale: defaults.scale as number,
|
|
73
|
+
};
|
|
74
|
+
allowedExecutables = new Set(
|
|
75
|
+
(settings.allowedExecutables ?? "")
|
|
76
|
+
.split(",")
|
|
77
|
+
.map((name) => name.trim().toLowerCase())
|
|
78
|
+
.filter(Boolean),
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Returns the configured defaults for capture requests. */
|
|
83
|
+
export function getVisionDefaults(): VisionDefaults {
|
|
84
|
+
return visionDefaults;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Checks an external process against the exact executable-name allowlist. */
|
|
88
|
+
export function isExecutableAllowed(command: string): boolean {
|
|
89
|
+
const windowsName = command.includes("\\")
|
|
90
|
+
? command.slice(command.lastIndexOf("\\") + 1)
|
|
91
|
+
: command;
|
|
92
|
+
const firstArgument = windowsName.trim().split(/\s+/u)[0] ?? "";
|
|
93
|
+
const unixName = firstArgument.slice(firstArgument.lastIndexOf("/") + 1);
|
|
94
|
+
return allowedExecutables.has((command.includes("\\") ? windowsName : unixName).toLowerCase());
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Parses image and sequence view strings with named capture parameters. */
|
|
98
|
+
export function parseVisionView(
|
|
99
|
+
views: readonly string[] | undefined,
|
|
100
|
+
defaults: VisionDefaults,
|
|
101
|
+
): VisionOptions | undefined {
|
|
102
|
+
const selected = views?.filter((view) => /^(?:image|sequence)(?::|$)/u.test(view)) ?? [];
|
|
103
|
+
if (selected.length === 0) return undefined;
|
|
104
|
+
if (selected.length > 1) throw new Error("Use only one image or sequence view");
|
|
105
|
+
const view = selected[0] as string;
|
|
106
|
+
const separator = view.indexOf(":");
|
|
107
|
+
const mode = view.slice(0, separator < 0 ? undefined : separator) as "image" | "sequence";
|
|
108
|
+
const options: { duration?: number; interval?: number; scale?: number; region?: VisionRegion } =
|
|
109
|
+
{};
|
|
110
|
+
if (separator >= 0) parseViewParameters(view.slice(separator + 1), options);
|
|
111
|
+
if (mode === "image" && (options.duration !== undefined || options.interval !== undefined))
|
|
112
|
+
throw new Error("duration and interval are supported only by the sequence view");
|
|
113
|
+
return validateVisionOptions({
|
|
114
|
+
mode,
|
|
115
|
+
durationSeconds: options.duration ?? defaults.durationSeconds,
|
|
116
|
+
intervalSeconds: options.interval ?? defaults.intervalSeconds,
|
|
117
|
+
scale: options.scale ?? defaults.scale,
|
|
118
|
+
...(options.region === undefined ? {} : { region: options.region }),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function parseViewParameters(
|
|
123
|
+
source: string,
|
|
124
|
+
target: { duration?: number; interval?: number; scale?: number; region?: VisionRegion },
|
|
125
|
+
): void {
|
|
126
|
+
if (source.length === 0) throw new Error("View parameters cannot be empty");
|
|
127
|
+
const parts = source.split(",");
|
|
128
|
+
for (let index = 0; index < parts.length; index += 1) {
|
|
129
|
+
const part = parts[index] as string;
|
|
130
|
+
const equals = part.indexOf("=");
|
|
131
|
+
if (equals <= 0) throw new Error(`Invalid view parameter ${part}`);
|
|
132
|
+
const key = part.slice(0, equals);
|
|
133
|
+
const first = part.slice(equals + 1);
|
|
134
|
+
if (key === "region") {
|
|
135
|
+
const values = [first, parts[index + 1], parts[index + 2], parts[index + 3]].map(Number);
|
|
136
|
+
if (values.some((value) => !Number.isFinite(value)))
|
|
137
|
+
throw new Error("region requires x,y,width,height values");
|
|
138
|
+
target.region = {
|
|
139
|
+
x: values[0] as number,
|
|
140
|
+
y: values[1] as number,
|
|
141
|
+
width: values[2] as number,
|
|
142
|
+
height: values[3] as number,
|
|
143
|
+
};
|
|
144
|
+
index += 3;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (key !== "duration" && key !== "interval" && key !== "scale")
|
|
148
|
+
throw new Error(`Unknown view parameter ${key}`);
|
|
149
|
+
const value = Number(first);
|
|
150
|
+
if (!Number.isFinite(value)) throw new Error(`View parameter ${key} must be a number`);
|
|
151
|
+
if (target[key] !== undefined) throw new Error(`Duplicate view parameter ${key}`);
|
|
152
|
+
target[key] = value;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Parses display: and display:#N resource identities. */
|
|
157
|
+
export function parseDisplaySource(source: string): number | undefined {
|
|
158
|
+
if (!source.startsWith("display:")) return undefined;
|
|
159
|
+
if (source === "display:") return 0;
|
|
160
|
+
const match = /^display:#(\d+)$/u.exec(source);
|
|
161
|
+
if (match === null)
|
|
162
|
+
throw new Error("Display sources use display: or display:#N with a zero-based index");
|
|
163
|
+
const index = Number(match[1]);
|
|
164
|
+
if (!Number.isSafeInteger(index))
|
|
165
|
+
throw new Error("Display sources use display: or display:#N with a zero-based index");
|
|
166
|
+
return index;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Lists process metadata without granting window access. */
|
|
170
|
+
export async function listProcesses(registry: AgentIdeProcessRegistry): Promise<ProcessMetadata[]> {
|
|
171
|
+
const owned = new Map(
|
|
172
|
+
registry
|
|
173
|
+
.list()
|
|
174
|
+
.flatMap((process) => (process.pid === undefined ? [] : [[process.pid, process] as const])),
|
|
175
|
+
);
|
|
176
|
+
if (process.platform !== "linux" && process.platform !== "darwin") {
|
|
177
|
+
return [...owned].map(([pid, item]) => ({
|
|
178
|
+
pid,
|
|
179
|
+
command: item.description,
|
|
180
|
+
owned: true,
|
|
181
|
+
source: item.source,
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
const { stdout } = await execFileAsync("ps", ["-eo", "pid=,ppid=,lstart=,args="], {
|
|
185
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
186
|
+
});
|
|
187
|
+
const local = stdout.split("\n").flatMap((line) => {
|
|
188
|
+
const match = /^\s*(\d+)\s+(\d+)\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+(.*)$/u.exec(line);
|
|
189
|
+
if (match === null) return [];
|
|
190
|
+
const pid = Number(match[1]);
|
|
191
|
+
const item = owned.get(pid);
|
|
192
|
+
return [
|
|
193
|
+
{
|
|
194
|
+
pid,
|
|
195
|
+
parentPid: Number(match[2]),
|
|
196
|
+
started: match[3],
|
|
197
|
+
command: match[4] ?? "",
|
|
198
|
+
owned: item !== undefined,
|
|
199
|
+
...(item === undefined ? {} : { source: item.source }),
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
});
|
|
203
|
+
return isWsl() ? [...local, ...(await listWindowsProcesses())] : local;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async function listWindowsProcesses(): Promise<ProcessMetadata[]> {
|
|
207
|
+
try {
|
|
208
|
+
const { stdout } = await execFileAsync(
|
|
209
|
+
"powershell.exe",
|
|
210
|
+
[
|
|
211
|
+
"-NoLogo",
|
|
212
|
+
"-NoProfile",
|
|
213
|
+
"-NonInteractive",
|
|
214
|
+
"-Command",
|
|
215
|
+
"Get-Process | Select-Object Id,ProcessName,Path,StartTime | ConvertTo-Json -Compress",
|
|
216
|
+
],
|
|
217
|
+
{ maxBuffer: 4 * 1024 * 1024 },
|
|
218
|
+
);
|
|
219
|
+
const parsed: unknown = JSON.parse(stdout);
|
|
220
|
+
const records: unknown[] = Array.isArray(parsed) ? (parsed as unknown[]) : [parsed];
|
|
221
|
+
return records.flatMap((record): ProcessMetadata[] => {
|
|
222
|
+
if (
|
|
223
|
+
typeof record !== "object" ||
|
|
224
|
+
record === null ||
|
|
225
|
+
!("Id" in record) ||
|
|
226
|
+
typeof record.Id !== "number"
|
|
227
|
+
)
|
|
228
|
+
return [];
|
|
229
|
+
const name =
|
|
230
|
+
"ProcessName" in record && typeof record.ProcessName === "string"
|
|
231
|
+
? record.ProcessName
|
|
232
|
+
: "Windows process";
|
|
233
|
+
const path = "Path" in record && typeof record.Path === "string" ? record.Path : undefined;
|
|
234
|
+
const started =
|
|
235
|
+
"StartTime" in record && typeof record.StartTime === "string"
|
|
236
|
+
? record.StartTime
|
|
237
|
+
: undefined;
|
|
238
|
+
return [
|
|
239
|
+
{
|
|
240
|
+
pid: record.Id,
|
|
241
|
+
command: path ?? name,
|
|
242
|
+
owned: false,
|
|
243
|
+
...(started === undefined ? {} : { started }),
|
|
244
|
+
},
|
|
245
|
+
];
|
|
246
|
+
});
|
|
247
|
+
} catch {
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** Reads one PID while preserving registry ownership metadata. */
|
|
253
|
+
export async function readProcess(
|
|
254
|
+
pid: number,
|
|
255
|
+
registry: AgentIdeProcessRegistry,
|
|
256
|
+
): Promise<ProcessMetadata> {
|
|
257
|
+
if (!Number.isSafeInteger(pid) || pid <= 0)
|
|
258
|
+
throw new Error("Process PID must be a positive integer");
|
|
259
|
+
const found = (await listProcesses(registry)).find((item) => item.pid === pid);
|
|
260
|
+
if (found === undefined) throw new Error(`Process ${pid} is not running`);
|
|
261
|
+
return found;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Validates bounded capture selectors before any desktop access occurs. */
|
|
265
|
+
export function validateVisionOptions(options: VisionOptions): VisionOptions {
|
|
266
|
+
const scale = options.scale ?? 1;
|
|
267
|
+
if (!(scale > 0 && scale <= 1))
|
|
268
|
+
throw new Error("Image scale must be greater than 0 and at most 1");
|
|
269
|
+
const duration = options.durationSeconds ?? 0;
|
|
270
|
+
const interval = options.intervalSeconds ?? 1;
|
|
271
|
+
if (options.mode === "sequence") {
|
|
272
|
+
if (!(duration > 0 && duration <= 10))
|
|
273
|
+
throw new Error("Sequence duration must be greater than 0 and at most 10 seconds");
|
|
274
|
+
if (!(interval > 0)) throw new Error("Sequence interval must be greater than 0 seconds");
|
|
275
|
+
if (Math.floor(duration / interval) + 1 > 20)
|
|
276
|
+
throw new Error("Sequence capture is limited to 20 frames");
|
|
277
|
+
}
|
|
278
|
+
if (options.region !== undefined) {
|
|
279
|
+
const { x, y, width, height } = options.region;
|
|
280
|
+
if (x < 0 || y < 0 || width <= 0 || height <= 0 || x + width > 1 || y + height > 1)
|
|
281
|
+
throw new Error("Image region x,y,width,height must fit within normalized bounds 0..1");
|
|
282
|
+
}
|
|
283
|
+
if (options.cellIndex !== undefined && options.cellSize === undefined)
|
|
284
|
+
throw new Error("Image offset requires limit to set the square grid cell size");
|
|
285
|
+
if (
|
|
286
|
+
options.cellSize !== undefined &&
|
|
287
|
+
(!Number.isSafeInteger(options.cellSize) || options.cellSize <= 0)
|
|
288
|
+
)
|
|
289
|
+
throw new Error("Image limit must be a positive integer pixel size");
|
|
290
|
+
if (
|
|
291
|
+
options.cellIndex !== undefined &&
|
|
292
|
+
(!Number.isSafeInteger(options.cellIndex) || options.cellIndex < 0)
|
|
293
|
+
)
|
|
294
|
+
throw new Error("Image offset must be a zero-based cell index");
|
|
295
|
+
return options;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** Captures and transforms a bounded image or sequence. */
|
|
299
|
+
export async function captureImages(
|
|
300
|
+
capture: () => Promise<Uint8Array>,
|
|
301
|
+
options: VisionOptions,
|
|
302
|
+
signal?: AbortSignal,
|
|
303
|
+
): Promise<ImageContent[]> {
|
|
304
|
+
const selected = validateVisionOptions(options);
|
|
305
|
+
const count =
|
|
306
|
+
selected.mode === "image"
|
|
307
|
+
? 1
|
|
308
|
+
: Math.floor((selected.durationSeconds as number) / (selected.intervalSeconds as number)) + 1;
|
|
309
|
+
const images: ImageContent[] = [];
|
|
310
|
+
let bytes = 0;
|
|
311
|
+
for (let frame = 0; frame < count; frame += 1) {
|
|
312
|
+
signal?.throwIfAborted();
|
|
313
|
+
if (frame > 0) await delay((selected.intervalSeconds as number) * 1_000, signal);
|
|
314
|
+
const captured = await capture();
|
|
315
|
+
bytes += captured.byteLength;
|
|
316
|
+
if (bytes > MAX_CAPTURE_BYTES)
|
|
317
|
+
throw new Error("Captured images exceed the 20MB aggregate limit");
|
|
318
|
+
for (const png of await selectImage(captured, selected)) {
|
|
319
|
+
images.push({
|
|
320
|
+
type: "image",
|
|
321
|
+
data: Buffer.from(png).toString("base64"),
|
|
322
|
+
mimeType: "image/png",
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return images;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export async function selectImage(
|
|
330
|
+
bytes: Uint8Array,
|
|
331
|
+
options: VisionOptions,
|
|
332
|
+
): Promise<Uint8Array[]> {
|
|
333
|
+
const image = await loadImage(bytes);
|
|
334
|
+
const region = options.region ?? { x: 0, y: 0, width: 1, height: 1 };
|
|
335
|
+
const sourceX = Math.round(region.x * image.width);
|
|
336
|
+
const sourceY = Math.round(region.y * image.height);
|
|
337
|
+
const sourceWidth = Math.max(1, Math.round(region.width * image.width));
|
|
338
|
+
const sourceHeight = Math.max(1, Math.round(region.height * image.height));
|
|
339
|
+
const scale = options.scale ?? 1;
|
|
340
|
+
const width = Math.max(1, Math.round(sourceWidth * scale));
|
|
341
|
+
const height = Math.max(1, Math.round(sourceHeight * scale));
|
|
342
|
+
const transformed = createCanvas(width, height);
|
|
343
|
+
transformed
|
|
344
|
+
.getContext("2d")
|
|
345
|
+
.drawImage(image, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, width, height);
|
|
346
|
+
if (options.cellSize === undefined) return [await transformed.encode("png")];
|
|
347
|
+
const columns = Math.ceil(width / options.cellSize);
|
|
348
|
+
const rows = Math.ceil(height / options.cellSize);
|
|
349
|
+
const index = options.cellIndex ?? 0;
|
|
350
|
+
if (index >= columns * rows)
|
|
351
|
+
throw new Error(`Image cell offset ${index} exceeds the ${columns}x${rows} grid`);
|
|
352
|
+
const column = index % columns;
|
|
353
|
+
const row = Math.floor(index / columns);
|
|
354
|
+
const left = column * options.cellSize;
|
|
355
|
+
const top = row * options.cellSize;
|
|
356
|
+
const cellWidth = Math.min(options.cellSize, width - left);
|
|
357
|
+
const cellHeight = Math.min(options.cellSize, height - top);
|
|
358
|
+
const canvas = createCanvas(cellWidth, cellHeight);
|
|
359
|
+
canvas
|
|
360
|
+
.getContext("2d")
|
|
361
|
+
.drawImage(transformed, left, top, cellWidth, cellHeight, 0, 0, cellWidth, cellHeight);
|
|
362
|
+
return [await canvas.encode("png")];
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** Creates the supported local desktop and isolated browser capture backend. */
|
|
366
|
+
export function createCaptureBackend(): CaptureBackend {
|
|
367
|
+
return {
|
|
368
|
+
async captureWindow(pid, signal) {
|
|
369
|
+
signal?.throwIfAborted();
|
|
370
|
+
if (isWsl()) return captureWslWindow(pid, signal);
|
|
371
|
+
if (process.platform !== "linux" && process.platform !== "darwin")
|
|
372
|
+
throw new Error(`Window capture is unsupported on ${process.platform}`);
|
|
373
|
+
const { Window } = await import("node-screenshots");
|
|
374
|
+
let windows: ReturnType<typeof Window.all>;
|
|
375
|
+
try {
|
|
376
|
+
windows = Window.all();
|
|
377
|
+
} catch (error) {
|
|
378
|
+
throw new Error(`Desktop window enumeration is unavailable: ${errorMessage(error)}`, {
|
|
379
|
+
cause: error,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
const window = windows.find((candidate) => {
|
|
383
|
+
try {
|
|
384
|
+
return candidate.pid() === pid;
|
|
385
|
+
} catch {
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
if (window === undefined)
|
|
390
|
+
throw new Error(`No capturable desktop window belongs to PID ${pid}`);
|
|
391
|
+
const image = await window.captureImage();
|
|
392
|
+
signal?.throwIfAborted();
|
|
393
|
+
return new Uint8Array(await image.toPng());
|
|
394
|
+
},
|
|
395
|
+
async captureDisplay(index, signal) {
|
|
396
|
+
signal?.throwIfAborted();
|
|
397
|
+
if (isWsl()) return captureWslDisplay(index, signal);
|
|
398
|
+
if (
|
|
399
|
+
process.platform !== "linux" &&
|
|
400
|
+
process.platform !== "darwin" &&
|
|
401
|
+
process.platform !== "win32"
|
|
402
|
+
)
|
|
403
|
+
throw new Error(`Display capture is unsupported on ${process.platform}`);
|
|
404
|
+
const { Monitor } = await import("node-screenshots");
|
|
405
|
+
let monitors: ReturnType<typeof Monitor.all>;
|
|
406
|
+
try {
|
|
407
|
+
monitors = Monitor.all();
|
|
408
|
+
} catch (error) {
|
|
409
|
+
throw new Error(`Desktop display enumeration is unavailable: ${errorMessage(error)}`, {
|
|
410
|
+
cause: error,
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
const monitor = monitors[index];
|
|
414
|
+
if (monitor === undefined)
|
|
415
|
+
throw new Error(
|
|
416
|
+
`Display index ${index} is unavailable; found ${monitors.length} display(s)`,
|
|
417
|
+
);
|
|
418
|
+
const image = await monitor.captureImage();
|
|
419
|
+
signal?.throwIfAborted();
|
|
420
|
+
return new Uint8Array(await image.toPng());
|
|
421
|
+
},
|
|
422
|
+
async captureUrl(url, signal) {
|
|
423
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
424
|
+
throw new Error("Web screenshots require an HTTP(S) URL");
|
|
425
|
+
const { chromium } = await import("playwright-core");
|
|
426
|
+
const executablePath = await resolveBrowser();
|
|
427
|
+
const browser = await chromium.launch({
|
|
428
|
+
executablePath,
|
|
429
|
+
headless: true,
|
|
430
|
+
chromiumSandbox: false,
|
|
431
|
+
timeout: 30_000,
|
|
432
|
+
});
|
|
433
|
+
const abort = (): void => {
|
|
434
|
+
void browser.close();
|
|
435
|
+
};
|
|
436
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
437
|
+
try {
|
|
438
|
+
const page = await browser.newPage({ viewport: { width: 1280, height: 720 } });
|
|
439
|
+
await page.goto(url.href, { waitUntil: "domcontentloaded", timeout: 30_000 });
|
|
440
|
+
await page.waitForLoadState("networkidle", { timeout: 1_500 }).catch(() => undefined);
|
|
441
|
+
signal?.throwIfAborted();
|
|
442
|
+
return new Uint8Array(await page.screenshot({ type: "png", fullPage: true }));
|
|
443
|
+
} finally {
|
|
444
|
+
signal?.removeEventListener("abort", abort);
|
|
445
|
+
await browser.close().catch(() => undefined);
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
async function captureWslWindow(pid: number, signal?: AbortSignal): Promise<Uint8Array> {
|
|
452
|
+
const script = new URL("windows-window-capture.ps1", import.meta.url);
|
|
453
|
+
signal?.throwIfAborted();
|
|
454
|
+
const { stdout: windowsScript } = await execFileAsync("wslpath", ["-w", script.pathname], {
|
|
455
|
+
signal,
|
|
456
|
+
});
|
|
457
|
+
const { stdout } = await execFileAsync(
|
|
458
|
+
"powershell.exe",
|
|
459
|
+
[
|
|
460
|
+
"-NoLogo",
|
|
461
|
+
"-NoProfile",
|
|
462
|
+
"-NonInteractive",
|
|
463
|
+
"-ExecutionPolicy",
|
|
464
|
+
"Bypass",
|
|
465
|
+
"-File",
|
|
466
|
+
windowsScript.trim(),
|
|
467
|
+
"-ProcessId",
|
|
468
|
+
String(pid),
|
|
469
|
+
],
|
|
470
|
+
{ encoding: "buffer", maxBuffer: MAX_CAPTURE_BYTES, signal },
|
|
471
|
+
);
|
|
472
|
+
return new Uint8Array(stdout);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
async function captureWslDisplay(index: number, signal?: AbortSignal): Promise<Uint8Array> {
|
|
476
|
+
const script = new URL("windows-display-capture.ps1", import.meta.url);
|
|
477
|
+
signal?.throwIfAborted();
|
|
478
|
+
const { stdout: windowsScript } = await execFileAsync("wslpath", ["-w", script.pathname], {
|
|
479
|
+
signal,
|
|
480
|
+
});
|
|
481
|
+
const { stdout } = await execFileAsync(
|
|
482
|
+
"powershell.exe",
|
|
483
|
+
[
|
|
484
|
+
"-NoLogo",
|
|
485
|
+
"-NoProfile",
|
|
486
|
+
"-NonInteractive",
|
|
487
|
+
"-ExecutionPolicy",
|
|
488
|
+
"Bypass",
|
|
489
|
+
"-File",
|
|
490
|
+
windowsScript.trim(),
|
|
491
|
+
"-DisplayIndex",
|
|
492
|
+
String(index),
|
|
493
|
+
],
|
|
494
|
+
{ encoding: "buffer", maxBuffer: MAX_CAPTURE_BYTES, signal },
|
|
495
|
+
);
|
|
496
|
+
return new Uint8Array(stdout);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function isWsl(): boolean {
|
|
500
|
+
return (
|
|
501
|
+
process.platform === "linux" &&
|
|
502
|
+
(process.env.WSL_DISTRO_NAME !== undefined || os.release().toLowerCase().includes("microsoft"))
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
async function resolveBrowser(): Promise<string> {
|
|
506
|
+
const configured = process.env.PI_AGENT_IDE_BROWSER_PATH;
|
|
507
|
+
if (configured !== undefined) return configured;
|
|
508
|
+
const { stdout } = await execFileAsync("bash", [
|
|
509
|
+
"-lc",
|
|
510
|
+
"command -v google-chrome-stable || command -v google-chrome || command -v chromium || command -v chromium-browser",
|
|
511
|
+
]);
|
|
512
|
+
const path = stdout.trim();
|
|
513
|
+
if (path.length === 0)
|
|
514
|
+
throw new Error("No Chrome or Chromium executable was found; set PI_AGENT_IDE_BROWSER_PATH");
|
|
515
|
+
return path;
|
|
516
|
+
}
|
|
517
|
+
function delay(milliseconds: number, signal?: AbortSignal): Promise<void> {
|
|
518
|
+
return new Promise((resolve, reject) => {
|
|
519
|
+
const timer = setTimeout(resolve, milliseconds);
|
|
520
|
+
const abort = (): void => {
|
|
521
|
+
clearTimeout(timer);
|
|
522
|
+
reject(signal?.reason ?? new Error("Capture aborted"));
|
|
523
|
+
};
|
|
524
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
525
|
+
timer.unref();
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
function errorMessage(error: unknown): string {
|
|
529
|
+
return error instanceof Error ? error.message : String(error);
|
|
530
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
param([Parameter(Mandatory=$true)][int]$DisplayIndex)
|
|
2
|
+
$ErrorActionPreference = "Stop"
|
|
3
|
+
Add-Type -AssemblyName System.Drawing
|
|
4
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
5
|
+
Add-Type @'
|
|
6
|
+
using System;
|
|
7
|
+
using System.Runtime.InteropServices;
|
|
8
|
+
public static class PiAgentDisplayCapture {
|
|
9
|
+
[DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
|
|
10
|
+
}
|
|
11
|
+
'@
|
|
12
|
+
[PiAgentDisplayCapture]::SetProcessDPIAware() | Out-Null
|
|
13
|
+
$displays = [System.Windows.Forms.Screen]::AllScreens
|
|
14
|
+
if ($DisplayIndex -lt 0 -or $DisplayIndex -ge $displays.Length) {
|
|
15
|
+
throw "Display index $DisplayIndex is unavailable; found $($displays.Length) display(s)"
|
|
16
|
+
}
|
|
17
|
+
$bounds = $displays[$DisplayIndex].Bounds
|
|
18
|
+
if ($bounds.Width -le 0 -or $bounds.Height -le 0) { throw "Display $DisplayIndex has empty bounds" }
|
|
19
|
+
$bitmap = New-Object System.Drawing.Bitmap $bounds.Width, $bounds.Height
|
|
20
|
+
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
|
|
21
|
+
$stream = New-Object System.IO.MemoryStream
|
|
22
|
+
try {
|
|
23
|
+
$graphics.CopyFromScreen($bounds.Left, $bounds.Top, 0, 0, $bounds.Size)
|
|
24
|
+
$bitmap.Save($stream, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
25
|
+
[Console]::OpenStandardOutput().Write($stream.ToArray(), 0, $stream.Length)
|
|
26
|
+
} finally {
|
|
27
|
+
$stream.Dispose()
|
|
28
|
+
$graphics.Dispose()
|
|
29
|
+
$bitmap.Dispose()
|
|
30
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
param([Parameter(Mandatory=$true)][int]$ProcessId)
|
|
2
|
+
$ErrorActionPreference = "Stop"
|
|
3
|
+
Add-Type -AssemblyName System.Drawing
|
|
4
|
+
Add-Type @'
|
|
5
|
+
using System;
|
|
6
|
+
using System.Runtime.InteropServices;
|
|
7
|
+
public static class PiAgentWindowCapture {
|
|
8
|
+
[StructLayout(LayoutKind.Sequential)] public struct RECT { public int Left, Top, Right, Bottom; }
|
|
9
|
+
[DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
|
|
10
|
+
[DllImport("user32.dll", SetLastError=true)] public static extern bool GetWindowRect(IntPtr hwnd, out RECT rect);
|
|
11
|
+
}
|
|
12
|
+
'@
|
|
13
|
+
[PiAgentWindowCapture]::SetProcessDPIAware() | Out-Null
|
|
14
|
+
$process = Get-Process -Id $ProcessId -ErrorAction Stop
|
|
15
|
+
$handle = $process.MainWindowHandle
|
|
16
|
+
if ($handle -eq [IntPtr]::Zero) { throw "Process $ProcessId has no visible main window" }
|
|
17
|
+
$rect = New-Object PiAgentWindowCapture+RECT
|
|
18
|
+
if (-not [PiAgentWindowCapture]::GetWindowRect($handle, [ref]$rect)) { throw "GetWindowRect failed for process $ProcessId" }
|
|
19
|
+
$width = $rect.Right - $rect.Left
|
|
20
|
+
$height = $rect.Bottom - $rect.Top
|
|
21
|
+
if ($width -le 0 -or $height -le 0) { throw "Process $ProcessId has empty window bounds" }
|
|
22
|
+
$bitmap = New-Object System.Drawing.Bitmap $width, $height
|
|
23
|
+
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
|
|
24
|
+
$stream = New-Object System.IO.MemoryStream
|
|
25
|
+
try {
|
|
26
|
+
$graphics.CopyFromScreen($rect.Left, $rect.Top, 0, 0, (New-Object System.Drawing.Size($width, $height)))
|
|
27
|
+
$bitmap.Save($stream, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
28
|
+
[Console]::OpenStandardOutput().Write($stream.ToArray(), 0, $stream.Length)
|
|
29
|
+
} finally {
|
|
30
|
+
$stream.Dispose()
|
|
31
|
+
$graphics.Dispose()
|
|
32
|
+
$bitmap.Dispose()
|
|
33
|
+
}
|
package/dist/chunk-5PLV4HLG.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as s}from"./chunk-EI7MMDWY.js";var i=class{static{s(this,"AgentIdeProcessRegistry")}#t=new Map;#s=new Set;#e=new Map;add(e){return this.#e.get(e.id)?.(),this.#t.set(e.id,e),this.#e.set(e.id,e.onDidChange(()=>this.#i())),this.#i(),()=>{this.#t.get(e.id)===e&&(this.#e.get(e.id)?.(),this.#e.delete(e.id),this.#t.delete(e.id),this.#i())}}list(){return[...this.#t.values()].flatMap(e=>e.list())}onDidChange(e){return this.#s.add(e),()=>this.#s.delete(e)}dispose(){for(let e of this.#e.values())e();this.#e.clear(),this.#t.clear(),this.#s.clear()}#i(){for(let e of this.#s)e()}},n=new WeakMap;function r(t){let e=n.get(t);return e===void 0&&(e=new i,n.set(t,e)),e}s(r,"agentIdeProcessRegistry");export{r as a};
|