pi-agent-ide 0.8.4 → 0.9.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 +59 -0
- package/README.md +24 -29
- package/dist/{chunk-CM3XGY72.js → chunk-2AY526TN.js} +1 -1
- package/dist/{chunk-LEJKDYCK.js → chunk-2TZDG2JH.js} +1 -1
- package/dist/{chunk-XBQR74IK.js → chunk-4GBFIGH3.js} +1 -1
- package/dist/{chunk-PJL3UVMJ.js → chunk-4IWEKRSP.js} +1 -1
- package/dist/chunk-52PFWQMU.js +5 -0
- package/dist/chunk-5BGWNYQS.js +1 -0
- package/dist/{chunk-QUYXINGZ.js → chunk-5S74Z6Y4.js} +3 -3
- package/dist/chunk-64JTD2DJ.js +1 -0
- package/dist/{chunk-XAHU42FP.js → chunk-6A3ORNW3.js} +2 -2
- package/dist/{chunk-ANM3Y5FO.js → chunk-6WCHBHFW.js} +5 -5
- package/dist/{chunk-IMGIDBCC.js → chunk-7D7PXIVV.js} +1 -1
- package/dist/chunk-7PVDTMEM.js +1 -0
- package/dist/chunk-7SG756UO.js +4 -0
- package/dist/{chunk-GBUJOR6V.js → chunk-7URANI6I.js} +14 -14
- package/dist/{chunk-Z2MNHSJ4.js → chunk-AJZVKDYC.js} +1 -1
- package/dist/chunk-AMIIOWFL.js +1 -0
- package/dist/{chunk-TOYN4W4F.js → chunk-B25LXXNV.js} +1 -1
- package/dist/chunk-C2JT2G5K.js +1 -0
- package/dist/chunk-CVOYSEBE.js +1 -0
- package/dist/chunk-DDH3FP4G.js +3 -0
- package/dist/chunk-FEZLTM4L.js +1 -0
- package/dist/{chunk-CPELC6JE.js → chunk-FHRHYY4M.js} +1 -1
- package/dist/chunk-FKKAHI62.js +11 -0
- package/dist/chunk-FS3KCKFX.js +9 -0
- package/dist/chunk-FYOU4RBH.js +2 -0
- package/dist/chunk-G4PRFO6G.js +1 -0
- package/dist/chunk-GS5ZRTUG.js +1 -0
- package/dist/{chunk-XXLLY66B.js → chunk-GXL4NMHR.js} +1 -1
- package/dist/{chunk-QT3EAHOG.js → chunk-H3GEEOOL.js} +1 -1
- package/dist/chunk-H5Z54BEU.js +25 -0
- package/dist/chunk-H7WAM5RH.js +23 -0
- package/dist/chunk-HT7LZN5A.js +9 -0
- package/dist/chunk-IG5DXVDJ.js +1 -0
- package/dist/chunk-K4UTEMDU.js +1 -0
- package/dist/chunk-KFBRL2V4.js +3 -0
- package/dist/chunk-KN6VPARZ.js +1 -0
- package/dist/{chunk-RW2GTYQI.js → chunk-LF325WYO.js} +1 -1
- package/dist/chunk-LTADNZKW.js +2 -0
- package/dist/{chunk-YJ6T3PEP.js → chunk-MDD5ORB6.js} +1 -1
- package/dist/{chunk-S72FVLUX.js → chunk-MLFJU2US.js} +1 -1
- package/dist/chunk-NA2NEU4V.js +1 -0
- package/dist/chunk-OBTT5INC.js +6 -0
- package/dist/{chunk-IICJXZBU.js → chunk-OMNKD7WW.js} +3 -3
- package/dist/chunk-PLMHBXWI.js +10 -0
- package/dist/{chunk-235QMMVA.js → chunk-PQWANILR.js} +1 -1
- package/dist/{chunk-QRJLIV6P.js → chunk-QJ6V5IAY.js} +6 -6
- package/dist/chunk-QM5WDEFI.js +1 -0
- package/dist/{chunk-SMIFCAAX.js → chunk-RIJRPAL2.js} +1 -1
- package/dist/chunk-RIOPUTUJ.js +6 -0
- package/dist/chunk-RVFMH77U.js +82 -0
- package/dist/{chunk-NJ7C4KMA.js → chunk-SRFWT562.js} +1 -1
- package/dist/{chunk-U22JNO6N.js → chunk-STUZZM5B.js} +1 -1
- package/dist/{chunk-PT35ZFLH.js → chunk-TNAUCNUT.js} +12 -12
- package/dist/{chunk-DUUOCBS3.js → chunk-TVH2ND35.js} +1 -1
- package/dist/chunk-TVSZYABY.js +5 -0
- package/dist/chunk-TVXZE4KW.js +4 -0
- package/dist/chunk-U7YDLVFL.js +1 -0
- package/dist/{chunk-KZC7TI5M.js → chunk-UD3DMY3Q.js} +1 -1
- package/dist/{chunk-VXP5BMW7.js → chunk-USG6WHAT.js} +1 -1
- package/dist/{chunk-RMI3NMQY.js → chunk-V4J3TLCV.js} +2 -2
- package/dist/{chunk-ZPT5D4VP.js → chunk-VDJSH3DQ.js} +2 -2
- package/dist/{chunk-VMTOFEXF.js → chunk-VMLPXSMK.js} +1 -1
- package/dist/{chunk-6T7PSDQW.js → chunk-VN3XBH2Q.js} +1 -1
- package/dist/chunk-WAJW4G4F.js +22 -0
- package/dist/chunk-WEE3NM6L.js +1 -0
- package/dist/{chunk-IM24DB3K.js → chunk-WES2E4VR.js} +1 -1
- package/dist/{chunk-RIJMXO43.js → chunk-WQIMM4SU.js} +1 -1
- package/dist/chunk-WUO3UW4J.js +17 -0
- package/dist/chunk-XE4W5YTE.js +2 -0
- package/dist/chunk-XUYIK4TX.js +1 -0
- package/dist/{chunk-ZJQRLVVV.js → chunk-Y74EKJOY.js} +1 -1
- package/dist/{chunk-AAC77UD4.js → chunk-YPYROPQF.js} +1 -1
- package/dist/chunk-ZXO4D5UB.js +1 -0
- package/dist/entry-0.js +1 -1
- package/dist/entry-1.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-16.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-18.js +1 -1
- package/dist/entry-19.js +1 -1
- package/dist/entry-2.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +1 -0
- 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 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -2
- package/dist/entry-3.js +1 -1
- package/dist/entry-30.js +2 -1
- package/dist/entry-31.js +1 -4
- package/dist/entry-32.js +1 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +1 -18
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +15 -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 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -25
- package/dist/entry-5.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -3
- package/dist/entry-55.js +1 -13
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-6.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-64.js +1 -1
- package/dist/entry-65.js +1 -0
- package/dist/entry-66.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +0 -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 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -0
- package/dist/entry-76.js +1 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +0 -1
- package/dist/entry-8.js +1 -1
- package/dist/entry-80.js +1 -1
- package/dist/entry-81.js +1 -80
- package/dist/entry-82.js +1 -22
- package/dist/entry-83.js +1 -2
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +2 -1
- package/dist/entry-86.js +1 -1
- package/dist/entry-87.js +1 -1
- package/dist/entry-88.js +1 -3
- package/dist/entry-89.js +1 -1
- package/dist/entry-9.js +1 -1
- package/dist/entry-90.js +3 -1
- package/dist/entry-91.js +1 -1
- package/dist/entry-92.js +1 -0
- package/dist/entry-93.js +1 -0
- package/dist/pi-agent-ide.js +10 -34
- package/docs/agent-guides/ast-search.md +58 -0
- package/docs/agent-guides/debugger.md +1 -1
- package/docs/agent-guides/editing.md +26 -58
- package/docs/agent-guides/git-changes.md +4 -14
- package/docs/agent-guides/search.md +38 -0
- package/docs/agent-guides/ssh.md +17 -49
- package/docs/agent-guides/terminal.md +9 -15
- package/docs/configuration.md +9 -13
- package/docs/extensions.md +82 -0
- package/docs/settings-help.md +2 -2
- package/docs/structured-results.md +33 -11
- package/docs/tools.md +23 -22
- package/node_modules/pi-agent-doctor/package.json +7 -7
- package/node_modules/pi-agent-doctor/src/workspace.ts +0 -5
- package/node_modules/pi-agent-documentation/package.json +2 -2
- package/node_modules/pi-agent-documentation/runtime/entry-29.js +1 -0
- package/node_modules/pi-agent-documentation/src/index.ts +26 -10
- package/node_modules/pi-agent-filesystem/index.ts +1 -1
- 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/index.ts +9 -63
- package/node_modules/pi-agent-filesystem-jq/package.json +12 -6
- package/node_modules/pi-agent-filesystem-jq/runtime/entry-32.js +1 -0
- package/node_modules/pi-agent-filesystem-jq/src/api/jq.ts +112 -0
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-pdf/runtime/entry-34.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/extension.ts +8 -8
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +104 -26
- package/node_modules/pi-agent-ide-ast/src/tool-ast-search.ts +210 -0
- package/node_modules/pi-agent-ide-changes/index.ts +1 -2
- package/node_modules/pi-agent-ide-changes/package.json +10 -10
- package/node_modules/pi-agent-ide-changes/runtime/entry-38.js +1 -0
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +3 -3
- 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-42.js +2 -0
- package/node_modules/pi-agent-ide-lsp/index.ts +22 -28
- package/node_modules/pi-agent-ide-lsp/package.json +14 -10
- package/node_modules/pi-agent-ide-lsp/runtime/entry-43.js +2 -0
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +8 -84
- package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +1 -6
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +11 -11
- package/node_modules/pi-agent-ide-lsp/src/manager-provider.ts +8 -0
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +234 -36
- package/node_modules/pi-agent-ide-lsp/src/tool-lsp-search.ts +212 -0
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-image/src/image-converter.ts +24 -1
- 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-pdf/src/pdf-converter.ts +23 -1
- package/node_modules/pi-agent-read/package.json +12 -12
- package/node_modules/pi-agent-read/runtime/entry-49.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-51.js +2 -0
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +4 -7
- package/node_modules/pi-agent-read/src/api/tools/read.ts +2 -0
- package/node_modules/pi-agent-read/src/core/extension.ts +0 -8
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +47 -14
- package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +3 -1
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +14 -2
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +21 -8
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-resource/src/index.ts +8 -0
- package/node_modules/pi-agent-resource/src/resource-error-metadata.ts +89 -0
- package/node_modules/pi-agent-resource/src/resource-error.ts +6 -1
- package/node_modules/pi-agent-resource/src/result-images.ts +87 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +9 -3
- package/node_modules/pi-agent-resource/src/tool-result.ts +17 -0
- package/node_modules/pi-agent-search/package.json +9 -9
- package/node_modules/pi-agent-search/runtime/entry-54.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-55.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-56.js +2 -0
- package/node_modules/pi-agent-search/src/api/glob-list.ts +35 -0
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +8 -8
- package/node_modules/pi-agent-search/src/api/search.ts +14 -2
- package/node_modules/pi-agent-search/src/core/extension.ts +11 -20
- package/node_modules/pi-agent-search/src/core/search-core.ts +30 -10
- package/node_modules/pi-agent-search-text/index.ts +34 -12
- package/node_modules/pi-agent-search-text/package.json +17 -15
- package/node_modules/pi-agent-search-text/runtime/entry-57.js +1 -0
- package/node_modules/pi-agent-search-text/runtime/entry-60.js +1 -0
- package/node_modules/pi-agent-search-text/src/file-search.ts +59 -25
- package/node_modules/pi-agent-search-text/src/resolvers.ts +61 -16
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +9 -3
- package/node_modules/pi-agent-search-text/src/search-backend.ts +44 -48
- package/node_modules/pi-agent-search-text/src/search-presentation.ts +19 -15
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -1
- package/node_modules/pi-agent-search-text/src/search-result.ts +6 -2
- package/node_modules/pi-agent-search-text/src/search-session.ts +1 -0
- package/node_modules/pi-agent-search-text/src/tool-file-search.ts +146 -0
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
- 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-exact/src/anchor.ts +6 -1
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +1 -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-66.js +2 -0
- package/node_modules/pi-agent-text-editor/package.json +26 -26
- package/node_modules/pi-agent-text-editor/runtime/entry-81.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-82.js +1 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +23 -0
- package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +31 -1
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +11 -21
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +13 -7
- package/node_modules/pi-agent-text-editor/src/core/file-operation-guards.ts +22 -4
- package/node_modules/pi-agent-text-editor/src/core/image-write.ts +111 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +5 -1
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +8 -2
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +103 -20
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +146 -62
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +14 -19
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +43 -12
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +6 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +3 -7
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +6 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -6
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +3 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +37 -22
- package/node_modules/pi-agent-text-editor-renderer/index.ts +6 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-84.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +18 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +6 -6
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-85.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/runtime/entry-87.js +1 -0
- package/node_modules/pi-agent-tool-ui/runtime/entry-88.js +1 -0
- package/node_modules/pi-agent-web/index.ts +28 -6
- 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-html/src/html-converter.ts +1 -1
- 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-pdf/runtime/entry-92.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-93.js +2 -0
- package/package.json +61 -58
- package/src/api/approval.ts +2 -0
- package/src/api/read.ts +2 -0
- package/src/api/standalone.ts +7 -0
- package/src/backend/doctor-workspace.ts +0 -3
- package/src/backend/process-metadata-worker.py +9 -18
- package/src/backend/process-metadata.ts +11 -44
- package/src/backend/registration.ts +0 -10
- package/src/backend/web-browser-worker.mjs +2 -17
- package/src/backend/web-browser.ts +1 -26
- package/src/composite/builtin-extensions.ts +8 -6
- package/src/composite/ide-alias-rendering.ts +18 -2
- package/src/composite/module-labels.ts +0 -4
- package/src/composite/preferences.ts +0 -36
- package/src/composite/settings-documentation.ts +1 -2
- package/src/composite/text-results.ts +61 -23
- package/src/documentation/extension.ts +39 -15
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +1 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +9 -63
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +12 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-32.js +1 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/api/jq.ts +112 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-34.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-35.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-30.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +28 -6
- 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-html/src/html-converter.ts +1 -1
- 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-pdf/runtime/entry-92.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-93.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-89.js +2 -0
- package/src/extensions/pi-agent-read/package.json +12 -12
- package/src/extensions/pi-agent-read/runtime/entry-49.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-50.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-51.js +2 -0
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +4 -7
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +2 -0
- package/src/extensions/pi-agent-read/src/core/extension.ts +0 -8
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +47 -14
- package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +3 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +14 -2
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +21 -8
- package/src/extensions/pi-agent-search/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +34 -12
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +17 -15
- 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-59.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-60.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +59 -25
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +61 -16
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +9 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +44 -48
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +19 -15
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +6 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/tool-file-search.ts +146 -0
- package/src/extensions/pi-agent-search/runtime/entry-54.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-55.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-56.js +2 -0
- package/src/extensions/pi-agent-search/src/api/glob-list.ts +35 -0
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +8 -8
- package/src/extensions/pi-agent-search/src/api/search.ts +14 -2
- package/src/extensions/pi-agent-search/src/core/extension.ts +11 -20
- package/src/extensions/pi-agent-search/src/core/search-core.ts +30 -10
- 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-exact/src/anchor.ts +6 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +1 -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-65.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-66.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +6 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-84.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +18 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-85.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-81.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-82.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +23 -0
- package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +31 -1
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +11 -21
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +13 -7
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-guards.ts +22 -4
- package/src/extensions/pi-agent-text-editor/src/core/image-write.ts +111 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +5 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +8 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +103 -20
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +146 -62
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +14 -19
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +43 -12
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +6 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +3 -7
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +6 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -6
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +3 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +37 -22
- package/src/pi-agent-ide.ts +8 -15
- package/src/plugins/pi-agent-ide-ast/package.json +15 -15
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +8 -8
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +104 -26
- package/src/plugins/pi-agent-ide-ast/src/tool-ast-search.ts +210 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +1 -2
- package/src/plugins/pi-agent-ide-changes/package.json +10 -10
- package/src/plugins/pi-agent-ide-changes/runtime/entry-38.js +1 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +3 -3
- package/src/plugins/pi-agent-ide-debugger/index.ts +17 -4
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +2 -11
- 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-42.js +2 -0
- package/src/plugins/pi-agent-ide-lsp/index.ts +22 -28
- package/src/plugins/pi-agent-ide-lsp/package.json +14 -10
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-43.js +2 -0
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +8 -84
- package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +1 -6
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +11 -11
- package/src/plugins/pi-agent-ide-lsp/src/manager-provider.ts +8 -0
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +234 -36
- package/src/plugins/pi-agent-ide-lsp/src/tool-lsp-search.ts +212 -0
- package/src/plugins/pi-agent-ide-processes/src/ui.ts +61 -16
- package/src/plugins/pi-agent-ide-terminal/index.ts +1 -1
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +10 -7
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +1 -3
- package/src/standalone/resource-host.ts +147 -0
- package/src/standalone/scoped-api.ts +457 -0
- package/dist/chunk-2RTCSZB3.js +0 -1
- package/dist/chunk-4DIUPEDF.js +0 -2
- package/dist/chunk-6EDOLYOV.js +0 -1
- package/dist/chunk-6FGLAVPJ.js +0 -1
- package/dist/chunk-6H32W35W.js +0 -1
- package/dist/chunk-6OJ565FL.js +0 -2
- package/dist/chunk-6R3Y4AD3.js +0 -1
- package/dist/chunk-6TJPMBUQ.js +0 -1
- package/dist/chunk-6XFUICD7.js +0 -1
- package/dist/chunk-BHSO2MDK.js +0 -6
- package/dist/chunk-GSOYVIQS.js +0 -1
- package/dist/chunk-HSRH76JN.js +0 -3
- package/dist/chunk-HSZ4AQ6L.js +0 -9
- package/dist/chunk-I6NPILT5.js +0 -1
- package/dist/chunk-K7SRNBIV.js +0 -1
- package/dist/chunk-LCWBVOII.js +0 -3
- package/dist/chunk-MKEC3U2M.js +0 -4
- package/dist/chunk-NUM3YQGK.js +0 -1
- package/dist/chunk-OM4LYD3S.js +0 -1
- package/dist/chunk-PLKYHUNT.js +0 -1
- package/dist/chunk-QIJMV2P2.js +0 -2
- package/dist/chunk-RVU73VKN.js +0 -2
- package/dist/chunk-SDAH3ECM.js +0 -5
- package/dist/chunk-SGQWRIRJ.js +0 -10
- package/dist/chunk-SWBJS3U4.js +0 -1
- package/dist/chunk-T7I2VX3J.js +0 -1
- package/dist/chunk-T7MWQQIF.js +0 -3
- package/dist/chunk-VDP5CQHM.js +0 -3
- package/dist/chunk-XG7QNAKW.js +0 -9
- package/dist/chunk-XLWCSJMR.js +0 -1
- package/dist/chunk-YFP4P2FV.js +0 -1
- package/dist/chunk-YIXP2ALP.js +0 -9
- package/dist/entry-22.js +0 -1
- package/docs/agent-guides/diagnostics.md +0 -5
- package/docs/agent-guides/json-reading.md +0 -57
- package/docs/agent-guides/read-resources.md +0 -17
- package/docs/agent-guides/search-code.md +0 -76
- package/docs/agent-guides/select-code.md +0 -119
- package/docs/agent-guides/vision.md +0 -11
- package/node_modules/pi-agent-doctor/runtime/entry-22.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-29.js +0 -2
- package/node_modules/pi-agent-filesystem-pdf/runtime/entry-32.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-34.js +0 -1
- package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +0 -193
- package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +0 -59
- package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +0 -204
- package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +0 -184
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +0 -105
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +0 -387
- package/node_modules/pi-agent-ide-ast/src/selection-region.ts +0 -41
- package/node_modules/pi-agent-ide-ast/src/source-text.ts +0 -92
- package/node_modules/pi-agent-ide-ast/src/text-selection.ts +0 -214
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +0 -277
- package/node_modules/pi-agent-ide-formatter/runtime/entry-38.js +0 -2
- package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +0 -136
- package/node_modules/pi-agent-image/runtime/entry-42.js +0 -1
- package/node_modules/pi-agent-invariant/runtime/entry-43.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-51.js +0 -1
- package/node_modules/pi-agent-search-text/runtime/entry-55.js +0 -2
- package/node_modules/pi-agent-search-text/runtime/entry-56.js +0 -1
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-60.js +0 -2
- package/node_modules/pi-agent-text-editor/runtime/entry-66.js +0 -1
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-82.js +0 -2
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-84.js +0 -1
- package/node_modules/pi-agent-tool-ui/runtime/entry-85.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-87.js +0 -2
- package/node_modules/pi-agent-web-html/runtime/entry-88.js +0 -2
- package/src/backend/vision-capture-worker.py +0 -319
- package/src/backend/vision-capture.ts +0 -165
- package/src/backend/vision-registration.ts +0 -104
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-30.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-32.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-29.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-88.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-89.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-45.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-46.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-55.js +0 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-56.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-51.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-52.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-60.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-61.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-65.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-66.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-34.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-35.js +0 -2
- package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +0 -193
- package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +0 -59
- package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +0 -204
- package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +0 -184
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +0 -105
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +0 -387
- package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +0 -41
- package/src/plugins/pi-agent-ide-ast/src/source-text.ts +0 -92
- package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +0 -214
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +0 -277
- package/src/plugins/pi-agent-ide-formatter/runtime/entry-38.js +0 -2
- package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +0 -136
- package/src/plugins/pi-agent-ide-vision/index.ts +0 -439
- package/src/plugins/pi-agent-ide-vision/src/doctor-plugin.ts +0 -47
- package/src/plugins/pi-agent-ide-vision/src/vision.ts +0 -585
- package/src/plugins/pi-agent-ide-vision/src/windows-display-capture.ps1 +0 -30
- package/src/plugins/pi-agent-ide-vision/src/windows-window-capture.ps1 +0 -33
- /package/dist/{chunk-U2JKHKLK.js → chunk-3PMHFEJY.js} +0 -0
- /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-28.js +0 -0
- /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-30.js +0 -0
- /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-text}/runtime/entry-35.js +0 -0
- /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-36.js +0 -0
- /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-37.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-39.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-40.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-41.js +0 -0
- /package/node_modules/{pi-agent-pdf → pi-agent-image}/runtime/entry-44.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-45.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-46.js +0 -0
- /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-50.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-52.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-59.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text}/runtime/entry-61.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-62.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-63.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-64.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-65.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor}/runtime/entry-83.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-86.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web}/runtime/entry-89.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-html}/runtime/entry-90.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-image}/runtime/entry-91.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-31.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-33.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-html}/runtime/entry-90.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-image}/runtime/entry-91.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-62.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-63.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-64.js +0 -0
- /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-36.js +0 -0
- /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-37.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-39.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-40.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-41.js +0 -0
|
@@ -6,7 +6,7 @@ const maximumHeaderOffset = 1_024;
|
|
|
6
6
|
export function createPdfContentConverter(): ContentConverter {
|
|
7
7
|
return {
|
|
8
8
|
id: "pdf",
|
|
9
|
-
description: "PDF
|
|
9
|
+
description: "PDF — readable text.",
|
|
10
10
|
async tryConvert(input, context) {
|
|
11
11
|
const cancellation = cancellationError(context.signal);
|
|
12
12
|
|
|
@@ -24,6 +24,15 @@ export function createPdfContentConverter(): ContentConverter {
|
|
|
24
24
|
const content = await createPdfContent(input.bytes, context.signal);
|
|
25
25
|
return { kind: "converted", content };
|
|
26
26
|
} catch (error) {
|
|
27
|
+
// The header check also matches text that only mentions "%PDF-", such as source code.
|
|
28
|
+
// Leave undeclared readable text to the text converter instead of failing the read.
|
|
29
|
+
if (
|
|
30
|
+
cancellationError(context.signal) === undefined &&
|
|
31
|
+
!declaresPdf(input.source, input.mediaType) &&
|
|
32
|
+
isUtf8Text(input.bytes)
|
|
33
|
+
) {
|
|
34
|
+
return { kind: "not-handled" };
|
|
35
|
+
}
|
|
27
36
|
return {
|
|
28
37
|
kind: "failed",
|
|
29
38
|
error:
|
|
@@ -148,6 +157,19 @@ function isPdfMediaType(value: string | undefined): boolean {
|
|
|
148
157
|
return value?.split(";", 1)[0]?.trim().toLowerCase() === "application/pdf";
|
|
149
158
|
}
|
|
150
159
|
|
|
160
|
+
function declaresPdf(source: string, mediaType: string | undefined): boolean {
|
|
161
|
+
return isPdfMediaType(mediaType) || /\.pdf$/iu.test(source.split(/[?#]/u, 1)[0] ?? "");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function isUtf8Text(bytes: Uint8Array): boolean {
|
|
165
|
+
try {
|
|
166
|
+
new TextDecoder("utf8", { fatal: true }).decode(bytes);
|
|
167
|
+
return true;
|
|
168
|
+
} catch {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
151
173
|
function errorMessage(error: unknown): string {
|
|
152
174
|
return error instanceof Error ? error.message : String(error);
|
|
153
175
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-read",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -8,32 +8,32 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
"./api/connect-plugin": {
|
|
10
10
|
"types": "./src/api/connect-plugin.ts",
|
|
11
|
-
"default": "./runtime/entry-
|
|
11
|
+
"default": "./runtime/entry-47.js"
|
|
12
12
|
},
|
|
13
13
|
"./api/rendering": {
|
|
14
14
|
"types": "./src/api/rendering.ts",
|
|
15
|
-
"default": "./runtime/entry-
|
|
15
|
+
"default": "./runtime/entry-48.js"
|
|
16
16
|
},
|
|
17
17
|
"./api/plugin-protocol": {
|
|
18
18
|
"types": "./src/api/plugin-protocol.ts",
|
|
19
|
-
"default": "./runtime/entry-
|
|
19
|
+
"default": "./runtime/entry-49.js"
|
|
20
20
|
},
|
|
21
21
|
"./api/tools/read": {
|
|
22
22
|
"types": "./src/api/tools/read.ts",
|
|
23
|
-
"default": "./runtime/entry-
|
|
23
|
+
"default": "./runtime/entry-50.js"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"pi-agent-documentation": "0.
|
|
28
|
-
"pi-agent-invariant": "0.
|
|
29
|
-
"pi-agent-resource": "0.
|
|
30
|
-
"pi-agent-text": "0.
|
|
31
|
-
"pi-agent-tool-call-interception": "0.
|
|
32
|
-
"pi-agent-tool-ui": "0.
|
|
27
|
+
"pi-agent-documentation": "0.9.0",
|
|
28
|
+
"pi-agent-invariant": "0.9.0",
|
|
29
|
+
"pi-agent-resource": "0.9.0",
|
|
30
|
+
"pi-agent-text": "0.9.0",
|
|
31
|
+
"pi-agent-tool-call-interception": "0.9.0",
|
|
32
|
+
"pi-agent-tool-ui": "0.9.0"
|
|
33
33
|
},
|
|
34
34
|
"pi": {
|
|
35
35
|
"extensions": [
|
|
36
|
-
"./runtime/entry-
|
|
36
|
+
"./runtime/entry-51.js"
|
|
37
37
|
]
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
@@ -34,13 +34,10 @@ export type ReadParameterText = Partial<Record<keyof ReadRequest, string>>;
|
|
|
34
34
|
|
|
35
35
|
// Keep the shared schema's metadata stable for Diff; these descriptions belong to Read.
|
|
36
36
|
const coreDescriptions: Record<keyof ReadRequest, string> = {
|
|
37
|
-
path: "
|
|
38
|
-
offset:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"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.",
|
|
42
|
-
views:
|
|
43
|
-
"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.",
|
|
37
|
+
path: "What to read: a path, URL, unchanged Read/Search result or its UUID, or one of the forms below. temp:<id> — saved output; raw:<file> — original bytes.",
|
|
38
|
+
offset: "First line, from 1; negative counts from the end. For raw:, a byte offset.",
|
|
39
|
+
limit: "Maximum lines. For raw:, bytes.",
|
|
40
|
+
views: "Extra presentations; combine them unless a view says otherwise.",
|
|
44
41
|
};
|
|
45
42
|
|
|
46
43
|
/** Build a fresh Read schema snapshot without changing the shared schema or accepted types. */
|
|
@@ -143,6 +143,8 @@ export interface ReadNativeState extends ReadStateBase {
|
|
|
143
143
|
export type ReadState = ReadTextState | ReadNativeState;
|
|
144
144
|
|
|
145
145
|
export interface ReadPipelineContext {
|
|
146
|
+
/** A selection/anchor acquires its source internally but does not expose the complete source to transformations. */
|
|
147
|
+
readonly inputScope?: "source" | "selection";
|
|
146
148
|
/** Original UTF-8 file snapshot from this acquisition. Derived-view handlers clear it, even when their output matches the source. */
|
|
147
149
|
readonly sourceText?: string;
|
|
148
150
|
/** Original strict selection handle; surrounding Read lines do not widen its authority. */
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { connectResultTargets } from "pi-agent-resource";
|
|
3
3
|
import { createReadResultTargetHandler } from "#src/core/tools/read/result-target.js";
|
|
4
|
-
import { connectAgentDocumentation, loadPackagedAgentGuide } from "pi-agent-documentation";
|
|
5
4
|
import {
|
|
6
5
|
ToolCallInterceptionRenderStore,
|
|
7
6
|
withToolCallInterceptionRendering,
|
|
@@ -29,13 +28,6 @@ export default async function registerReadCore(
|
|
|
29
28
|
pi: ExtensionAPI,
|
|
30
29
|
context?: { readonly preferences: Readonly<Record<string, string>> },
|
|
31
30
|
): Promise<void> {
|
|
32
|
-
connectAgentDocumentation(pi, [
|
|
33
|
-
await loadPackagedAgentGuide({
|
|
34
|
-
id: "read-resources",
|
|
35
|
-
description: "Read results, selection boundaries, and composition",
|
|
36
|
-
triggers: [{ tool: "read" }],
|
|
37
|
-
}),
|
|
38
|
-
]);
|
|
39
31
|
const core = createReadCore(parsePresentation(context?.preferences["ui.read"]));
|
|
40
32
|
const targets = connectResultTargets(pi);
|
|
41
33
|
await core.registerPlugin({
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
} from "#src/api/tools/read.js";
|
|
12
12
|
import {
|
|
13
13
|
ResourceError,
|
|
14
|
+
resourceErrorMetadataOf,
|
|
14
15
|
type AgentContent,
|
|
15
16
|
type ImageContent,
|
|
16
17
|
type TextContent,
|
|
@@ -141,7 +142,7 @@ function renderFinalTextLines(
|
|
|
141
142
|
.join("");
|
|
142
143
|
}
|
|
143
144
|
|
|
144
|
-
function
|
|
145
|
+
function deepestCause(failure: ReadFailure): Error | undefined {
|
|
145
146
|
let cause = failure.cause;
|
|
146
147
|
let error: Error | undefined;
|
|
147
148
|
const visited = new Set<Error>();
|
|
@@ -150,6 +151,45 @@ function readFailureMessage(failure: ReadFailure): string {
|
|
|
150
151
|
error = cause;
|
|
151
152
|
cause = cause.cause;
|
|
152
153
|
}
|
|
154
|
+
return error;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const requestRecovery = "Supply path with a source or an unchanged result reference.";
|
|
158
|
+
const fragmentRecovery = (source: string) =>
|
|
159
|
+
`Read ${JSON.stringify(source)} with views=["anchors"] and choose a current anchor.`;
|
|
160
|
+
|
|
161
|
+
function candidateLines(failure: ReadFailure): string[] {
|
|
162
|
+
return failure.candidates?.length
|
|
163
|
+
? [
|
|
164
|
+
"Possible matches:",
|
|
165
|
+
...failure.candidates.map((candidate) => `- ${JSON.stringify(candidate.path)}`),
|
|
166
|
+
"",
|
|
167
|
+
"Retry read with an exact candidate path.",
|
|
168
|
+
]
|
|
169
|
+
: [];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Public recovery steps for a failed Read, built only from its code, source and path
|
|
174
|
+
* candidates, never from provider messages. Codemode receives them with the failure value.
|
|
175
|
+
*/
|
|
176
|
+
export function readFailureRecovery(failure: ReadFailure): string[] {
|
|
177
|
+
const error = deepestCause(failure);
|
|
178
|
+
const code = error !== undefined && "code" in error ? error.code : undefined;
|
|
179
|
+
const steps: string[] = [];
|
|
180
|
+
if (code === "ENOENT" && !failure.candidates?.length) steps.push("Search for the correct path.");
|
|
181
|
+
if (failure.code === "INVALID_REQUEST") steps.push(requestRecovery);
|
|
182
|
+
else if (failure.code === "FRAGMENT_FAILED" && failure.source !== undefined)
|
|
183
|
+
steps.push(fragmentRecovery(failure.source));
|
|
184
|
+
else if (failure.code === "NO_RESOLVER")
|
|
185
|
+
steps.push("Choose a supported source from the path parameter.");
|
|
186
|
+
else if (failure.code === "NO_FRAGMENT_RESOLVER")
|
|
187
|
+
steps.push("Read the source without the anchor.");
|
|
188
|
+
return [...steps, ...candidateLines(failure)];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function readFailureMessage(failure: ReadFailure): string {
|
|
192
|
+
const error = deepestCause(failure);
|
|
153
193
|
const code = error !== undefined && "code" in error ? error.code : undefined;
|
|
154
194
|
let reason = error?.message || failure.message;
|
|
155
195
|
if (code === "ENOENT")
|
|
@@ -167,10 +207,9 @@ function readFailureMessage(failure: ReadFailure): string {
|
|
|
167
207
|
reason = "This source is not supported. Choose a supported source from the path parameter.";
|
|
168
208
|
else if (failure.code === "NO_FRAGMENT_RESOLVER")
|
|
169
209
|
reason = "This anchor is not supported. Read the source without the anchor.";
|
|
170
|
-
if (failure.code === "INVALID_REQUEST")
|
|
171
|
-
reason += ". Supply path with a source or an unchanged result reference.";
|
|
210
|
+
if (failure.code === "INVALID_REQUEST") reason += `. ${requestRecovery}`;
|
|
172
211
|
else if (failure.code === "FRAGMENT_FAILED" && failure.source !== undefined)
|
|
173
|
-
reason += `\
|
|
212
|
+
reason += `\n${fragmentRecovery(failure.source)}`;
|
|
174
213
|
const source = failure.source === undefined ? "" : ` for ${JSON.stringify(failure.source)}`;
|
|
175
214
|
return `Read failed${source}: ${reason}`;
|
|
176
215
|
}
|
|
@@ -202,7 +241,9 @@ export function failureResult(failure: ReadFailure): ReadToolResult {
|
|
|
202
241
|
...failure,
|
|
203
242
|
source: failure.source ?? safe.source,
|
|
204
243
|
message: `${safe.code}: ${failure.source ?? safe.source}`,
|
|
205
|
-
cause: new ResourceError(safe.code, safe.source, safe.effect
|
|
244
|
+
cause: new ResourceError(safe.code, safe.source, safe.effect, {
|
|
245
|
+
metadata: resourceErrorMetadataOf(safe),
|
|
246
|
+
}),
|
|
206
247
|
};
|
|
207
248
|
} else if (
|
|
208
249
|
failure.cause instanceof Error &&
|
|
@@ -221,15 +262,7 @@ export function failureResult(failure: ReadFailure): ReadToolResult {
|
|
|
221
262
|
type: "text",
|
|
222
263
|
text: [
|
|
223
264
|
readFailureMessage(failure),
|
|
224
|
-
...(failure.candidates?.length
|
|
225
|
-
? [
|
|
226
|
-
"",
|
|
227
|
-
"Possible matches:",
|
|
228
|
-
...failure.candidates.map((candidate) => `- ${JSON.stringify(candidate.path)}`),
|
|
229
|
-
"",
|
|
230
|
-
"Retry read with an exact candidate path.",
|
|
231
|
-
]
|
|
232
|
-
: []),
|
|
265
|
+
...(failure.candidates?.length ? ["", ...candidateLines(failure)] : []),
|
|
233
266
|
].join("\n"),
|
|
234
267
|
},
|
|
235
268
|
],
|
|
@@ -6,12 +6,14 @@ import type { ReadPostReadHandler, ReadToolPluginApi } from "#src/api/tools/read
|
|
|
6
6
|
export function createReadResultTargetHandler(
|
|
7
7
|
store: ResultTargetStore,
|
|
8
8
|
read: ReadToolPluginApi["read"],
|
|
9
|
+
ownsSource: (source: string, resolver: string) => boolean = (_source, resolver) =>
|
|
10
|
+
["filesystem", "ssh"].includes(resolver),
|
|
9
11
|
): ReadPostReadHandler {
|
|
10
12
|
return async (context) => {
|
|
11
13
|
const state = context.state;
|
|
12
14
|
if (
|
|
13
15
|
state?.contentKind !== "text" ||
|
|
14
|
-
!
|
|
16
|
+
!ownsSource(state.source, state.resolvedBy) ||
|
|
15
17
|
context.sourceText !== state.text.content
|
|
16
18
|
)
|
|
17
19
|
return { kind: "continue", context };
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ResourceError,
|
|
4
|
+
resourceErrorMetadataOf,
|
|
5
|
+
structuredResultSchema,
|
|
6
|
+
withStructuredResult,
|
|
7
|
+
} from "pi-agent-resource";
|
|
3
8
|
import type { ReadScriptData, ReadToolResult } from "#src/api/tools/read.js";
|
|
4
9
|
import type { TextLine } from "pi-agent-text";
|
|
10
|
+
import { readFailureRecovery } from "#src/core/tools/read/read-result.js";
|
|
5
11
|
|
|
6
12
|
const reference = Type.Object(
|
|
7
13
|
{ value: Type.String(), kind: Type.String(), state: Type.Optional(Type.String()) },
|
|
@@ -175,6 +181,7 @@ function publicData(value: ReadScriptData): unknown {
|
|
|
175
181
|
export function structuredRead(result: ReadToolResult): ReadToolResult {
|
|
176
182
|
const failure = result.details.failure;
|
|
177
183
|
const safe = failure?.cause instanceof ResourceError ? failure.cause : undefined;
|
|
184
|
+
const metadata = safe === undefined ? undefined : resourceErrorMetadataOf(safe);
|
|
178
185
|
if (result.isError || failure !== undefined)
|
|
179
186
|
return withStructuredResult(result, readDataSchema, {
|
|
180
187
|
status: "error",
|
|
@@ -188,9 +195,14 @@ export function structuredRead(result: ReadToolResult): ReadToolResult {
|
|
|
188
195
|
code: safe?.code ?? failure?.code ?? "READ_FAILED",
|
|
189
196
|
message:
|
|
190
197
|
safe === undefined
|
|
191
|
-
?
|
|
198
|
+
? // Keep the recovery steps that direct calls show; scripts see only this value.
|
|
199
|
+
[
|
|
200
|
+
failure?.message ?? "Read failed",
|
|
201
|
+
...(failure === undefined ? [] : readFailureRecovery(failure)),
|
|
202
|
+
].join("\n")
|
|
192
203
|
: `${safe.code}: ${failure?.source ?? safe.source}`,
|
|
193
204
|
...(failure?.source === undefined ? {} : { source: failure.source }),
|
|
205
|
+
...(metadata === undefined ? {} : { metadata }),
|
|
194
206
|
},
|
|
195
207
|
],
|
|
196
208
|
});
|
|
@@ -4,6 +4,7 @@ import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
|
4
4
|
import {
|
|
5
5
|
isAgentContent,
|
|
6
6
|
isResourceResolutionAttempt,
|
|
7
|
+
ResourceError,
|
|
7
8
|
resourceScheduler,
|
|
8
9
|
resourceAccesses,
|
|
9
10
|
type ResourceResolver,
|
|
@@ -173,10 +174,7 @@ export function createReadTool(
|
|
|
173
174
|
promptSnippet: "Read supported sources as text or bytes, with optional views",
|
|
174
175
|
description: "Use read to inspect files and other supported resources.",
|
|
175
176
|
get promptGuidelines(): string[] {
|
|
176
|
-
return [
|
|
177
|
-
"Use read to inspect supported sources and search to locate workspace content.",
|
|
178
|
-
...(pluginPromptGuidelines?.() ?? []),
|
|
179
|
-
];
|
|
177
|
+
return [...(pluginPromptGuidelines?.() ?? [])];
|
|
180
178
|
},
|
|
181
179
|
get parameters() {
|
|
182
180
|
return describeReadParameters(parameterDescriptions?.() ?? {});
|
|
@@ -439,7 +437,12 @@ async function executeRead(
|
|
|
439
437
|
);
|
|
440
438
|
if (targeted !== undefined) return targeted;
|
|
441
439
|
}
|
|
442
|
-
let pipeline: ReadPipelineContext = {
|
|
440
|
+
let pipeline: ReadPipelineContext = {
|
|
441
|
+
inputScope: "source",
|
|
442
|
+
request: { ...request },
|
|
443
|
+
resolverContext,
|
|
444
|
+
audience,
|
|
445
|
+
};
|
|
443
446
|
|
|
444
447
|
if (!pipeline.request.path?.startsWith("temp:")) {
|
|
445
448
|
const preRead = await runPreReadHandlers(pipeline, handlerSnapshot);
|
|
@@ -479,7 +482,11 @@ async function executeRead(
|
|
|
479
482
|
|
|
480
483
|
if (split !== undefined) {
|
|
481
484
|
const wholeSource = { result: resolved, pipeline };
|
|
482
|
-
const barePipeline = {
|
|
485
|
+
const barePipeline: ReadPipelineContext = {
|
|
486
|
+
...pipeline,
|
|
487
|
+
inputScope: "selection",
|
|
488
|
+
request: { ...pipeline.request, path: split.source },
|
|
489
|
+
};
|
|
483
490
|
const retried = await resolveSource(
|
|
484
491
|
barePipeline,
|
|
485
492
|
resolverSnapshot,
|
|
@@ -569,8 +576,13 @@ const RETRYABLE_FAILURE_CODES: ReadonlySet<ReadFailure["code"]> = new Set([
|
|
|
569
576
|
|
|
570
577
|
/** True when reading the whole source failed for a reason an anchor split might fix. */
|
|
571
578
|
function isRetryableFailure(result: ReadToolResult): boolean {
|
|
572
|
-
const
|
|
573
|
-
|
|
579
|
+
const failure = result.details.failure;
|
|
580
|
+
// A declared provider failure belongs to the complete source, not a text anchor.
|
|
581
|
+
return (
|
|
582
|
+
failure !== undefined &&
|
|
583
|
+
!(failure.cause instanceof ResourceError) &&
|
|
584
|
+
RETRYABLE_FAILURE_CODES.has(failure.code)
|
|
585
|
+
);
|
|
574
586
|
}
|
|
575
587
|
|
|
576
588
|
async function resolveTextTargets(
|
|
@@ -651,6 +663,7 @@ async function resolveTextTargets(
|
|
|
651
663
|
(sourceTarget !== undefined && range.end.column > 0 ? 1 : 0),
|
|
652
664
|
);
|
|
653
665
|
let rangePipeline: ReadPipelineContext = {
|
|
666
|
+
inputScope: "selection",
|
|
654
667
|
sourceTarget,
|
|
655
668
|
request: {
|
|
656
669
|
...request,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-resource",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"imports": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./src/index.ts",
|
|
12
|
-
"default": "./runtime/entry-
|
|
12
|
+
"default": "./runtime/entry-52.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
@@ -12,6 +12,13 @@ export {
|
|
|
12
12
|
type StructuredResult,
|
|
13
13
|
} from "./tool-result.js";
|
|
14
14
|
export { ResourceError } from "./resource-error.js";
|
|
15
|
+
export {
|
|
16
|
+
resourceErrorMetadata,
|
|
17
|
+
resourceErrorMetadataOf,
|
|
18
|
+
resourceErrorMetadataSchema,
|
|
19
|
+
type ResourceErrorMetadata,
|
|
20
|
+
type ResourceRateLimit,
|
|
21
|
+
} from "./resource-error-metadata.js";
|
|
15
22
|
export type {
|
|
16
23
|
AgentContent,
|
|
17
24
|
AgentContentBlock,
|
|
@@ -100,3 +107,4 @@ export {
|
|
|
100
107
|
type ResultSourceTarget,
|
|
101
108
|
type ResolvedResultTargets,
|
|
102
109
|
} from "./result-targets.js";
|
|
110
|
+
export { connectResultImages, ResultImageStore } from "./result-images.js";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
|
|
3
|
+
const numericFields = [
|
|
4
|
+
"retryAfterMs",
|
|
5
|
+
"resetAt",
|
|
6
|
+
"requestsLimit",
|
|
7
|
+
"requestsRemaining",
|
|
8
|
+
"complexityLimit",
|
|
9
|
+
"complexityRemaining",
|
|
10
|
+
"endpointLimit",
|
|
11
|
+
"endpointRemaining",
|
|
12
|
+
] as const;
|
|
13
|
+
|
|
14
|
+
export type ResourceRateLimit = Readonly<
|
|
15
|
+
Partial<Record<(typeof numericFields)[number], number>> & { endpoint?: string }
|
|
16
|
+
>;
|
|
17
|
+
/** Explicit public diagnostics. Arbitrary provider details are never metadata. */
|
|
18
|
+
export interface ResourceErrorMetadata {
|
|
19
|
+
readonly rateLimit?: ResourceRateLimit;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const resourceErrorMetadataSchema = Type.Object(
|
|
23
|
+
{
|
|
24
|
+
rateLimit: Type.Optional(
|
|
25
|
+
Type.Object(
|
|
26
|
+
{
|
|
27
|
+
...Object.fromEntries(
|
|
28
|
+
numericFields.map((field) => [
|
|
29
|
+
field,
|
|
30
|
+
Type.Optional(
|
|
31
|
+
Type.Integer({
|
|
32
|
+
minimum: 0,
|
|
33
|
+
maximum: field === "retryAfterMs" ? 86400000 : Number.MAX_SAFE_INTEGER,
|
|
34
|
+
}),
|
|
35
|
+
),
|
|
36
|
+
]),
|
|
37
|
+
),
|
|
38
|
+
endpoint: Type.Optional(
|
|
39
|
+
Type.String({ maxLength: 80, pattern: "^[A-Za-z0-9_:-]{1,80}$" }),
|
|
40
|
+
),
|
|
41
|
+
},
|
|
42
|
+
{ additionalProperties: false },
|
|
43
|
+
),
|
|
44
|
+
),
|
|
45
|
+
},
|
|
46
|
+
{ additionalProperties: false },
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
function own(value: unknown, key: string): unknown {
|
|
50
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
51
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
52
|
+
return descriptor && "value" in descriptor ? descriptor.value : undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Revalidate at each public boundary; copy only data properties and never invoke getters. */
|
|
56
|
+
export function resourceErrorMetadata(value: unknown): ResourceErrorMetadata | undefined {
|
|
57
|
+
try {
|
|
58
|
+
const input = own(value, "rateLimit");
|
|
59
|
+
const rateLimit: Partial<Record<(typeof numericFields)[number], number>> & {
|
|
60
|
+
endpoint?: string;
|
|
61
|
+
} = {};
|
|
62
|
+
for (const field of numericFields) {
|
|
63
|
+
const number = own(input, field);
|
|
64
|
+
if (
|
|
65
|
+
typeof number === "number" &&
|
|
66
|
+
Number.isSafeInteger(number) &&
|
|
67
|
+
number >= 0 &&
|
|
68
|
+
(field !== "retryAfterMs" || number <= 86400000)
|
|
69
|
+
)
|
|
70
|
+
rateLimit[field] = number;
|
|
71
|
+
}
|
|
72
|
+
const endpoint = own(input, "endpoint");
|
|
73
|
+
if (typeof endpoint === "string" && /^[A-Za-z0-9_:-]{1,80}$/u.test(endpoint))
|
|
74
|
+
rateLimit.endpoint = endpoint;
|
|
75
|
+
if (Object.keys(rateLimit).length)
|
|
76
|
+
return Object.freeze({ rateLimit: Object.freeze(rateLimit) });
|
|
77
|
+
} catch {
|
|
78
|
+
// Optional metadata cannot replace the owning failure when a foreign object is unreadable.
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Read opt-in metadata without letting a foreign descriptor replace its owning failure. */
|
|
83
|
+
export function resourceErrorMetadataOf(value: unknown): ResourceErrorMetadata | undefined {
|
|
84
|
+
try {
|
|
85
|
+
return resourceErrorMetadata(own(value, "metadata"));
|
|
86
|
+
} catch {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resourceErrorMetadataOf, type ResourceErrorMetadata } from "./resource-error-metadata.js";
|
|
2
|
+
|
|
1
3
|
const resourceErrorBrand = Symbol.for("pi-agent-resource.ResourceError");
|
|
2
4
|
/**
|
|
3
5
|
* A provider failure whose code and source are safe to show to the agent and user.
|
|
@@ -6,6 +8,7 @@ const resourceErrorBrand = Symbol.for("pi-agent-resource.ResourceError");
|
|
|
6
8
|
*/
|
|
7
9
|
export class ResourceError extends Error {
|
|
8
10
|
readonly [resourceErrorBrand] = true;
|
|
11
|
+
readonly metadata?: ResourceErrorMetadata;
|
|
9
12
|
|
|
10
13
|
/** Recognize failures from separately loaded extension SDKs without trusting error-shaped objects. */
|
|
11
14
|
static [Symbol.hasInstance](value: unknown): boolean {
|
|
@@ -19,10 +22,12 @@ export class ResourceError extends Error {
|
|
|
19
22
|
readonly code: string,
|
|
20
23
|
readonly source: string,
|
|
21
24
|
readonly effect: "not-applied" | "applied" | "unknown",
|
|
22
|
-
options?: { readonly cause
|
|
25
|
+
options?: { readonly cause?: ResourceError; readonly metadata?: ResourceErrorMetadata },
|
|
23
26
|
) {
|
|
24
27
|
if (!/^[A-Z][A-Z0-9_]*$/u.test(code)) throw new TypeError("Invalid resource failure code");
|
|
25
28
|
super(`${code}: ${source}`, options);
|
|
26
29
|
this.name = "ResourceError";
|
|
30
|
+
const metadata = resourceErrorMetadataOf(options);
|
|
31
|
+
if (metadata) this.metadata = metadata;
|
|
27
32
|
}
|
|
28
33
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import type { ImageContent } from "./content.js";
|
|
4
|
+
|
|
5
|
+
const event = "pi-agent-resource:result-images";
|
|
6
|
+
/** Base64 characters of images kept for later writes; the oldest results drop out first. */
|
|
7
|
+
const keptImageSize = 64 * 1024 * 1024;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Keeps the images of issued results so Write can save them by result reference.
|
|
11
|
+
* Separate from ResultTargetStore, which another extension's older copy can own.
|
|
12
|
+
*/
|
|
13
|
+
export class ResultImageStore {
|
|
14
|
+
readonly #results = new Map<string, { cwd: string; images: readonly ImageContent[] }>();
|
|
15
|
+
#size = 0;
|
|
16
|
+
|
|
17
|
+
/** Forget results when the session closes or the extensions reload. */
|
|
18
|
+
public clear(): void {
|
|
19
|
+
this.#results.clear();
|
|
20
|
+
this.#size = 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Record an issued result by its displayed envelope, with its images or none. */
|
|
24
|
+
public keep(shown: string, cwd: string, images: readonly ImageContent[]): void {
|
|
25
|
+
const id = /^<system-result\b[^>]*><uuid>([a-f\d-]{36})<\/uuid>/u.exec(shown)?.[1];
|
|
26
|
+
if (id === undefined) return;
|
|
27
|
+
this.#results.set(id, { cwd: path.resolve(cwd), images });
|
|
28
|
+
this.#size += imageSize(images);
|
|
29
|
+
for (const [kept, result] of this.#results) {
|
|
30
|
+
if (this.#size <= keptImageSize || kept === id) break;
|
|
31
|
+
if (result.images.length === 0) continue;
|
|
32
|
+
this.#results.set(kept, { ...result, images: [] });
|
|
33
|
+
this.#size -= imageSize(result.images);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Return the images of an issued result named exactly by its UUID or RESULT# reference.
|
|
39
|
+
* Any other text is not a reference and returns undefined.
|
|
40
|
+
*/
|
|
41
|
+
public images(input: string, cwd: string): readonly ImageContent[] | undefined {
|
|
42
|
+
const id = /^(?:RESULT#)?([a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12})$/u.exec(
|
|
43
|
+
input,
|
|
44
|
+
)?.[1];
|
|
45
|
+
const result = id === undefined ? undefined : this.#results.get(id);
|
|
46
|
+
if (result === undefined) return undefined;
|
|
47
|
+
if (result.cwd !== path.resolve(cwd)) throw new Error("Result belongs to another worktree.");
|
|
48
|
+
if (result.images.length === 0)
|
|
49
|
+
throw new Error(
|
|
50
|
+
"This result has no kept images. Read the image again and pass the new result.",
|
|
51
|
+
);
|
|
52
|
+
return result.images;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function imageSize(images: readonly ImageContent[]): number {
|
|
57
|
+
return images.reduce((size, image) => size + image.data.length, 0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Share one image store through Pi's extension event bus, without process-global state. */
|
|
61
|
+
export function connectResultImages(pi: ExtensionAPI): ResultImageStore {
|
|
62
|
+
let existing: ResultImageStore | undefined;
|
|
63
|
+
pi.events.emit(event, {
|
|
64
|
+
accept: (store: ResultImageStore) => {
|
|
65
|
+
existing = store;
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
if (existing !== undefined) return existing;
|
|
69
|
+
const store = new ResultImageStore();
|
|
70
|
+
const unsubscribe = pi.events.on(event, (request) => {
|
|
71
|
+
if (
|
|
72
|
+
request !== null &&
|
|
73
|
+
typeof request === "object" &&
|
|
74
|
+
"accept" in request &&
|
|
75
|
+
typeof request.accept === "function"
|
|
76
|
+
)
|
|
77
|
+
(request.accept as (store: ResultImageStore) => void)(store);
|
|
78
|
+
});
|
|
79
|
+
pi.on("session_start", () => {
|
|
80
|
+
store.clear();
|
|
81
|
+
});
|
|
82
|
+
pi.on("session_shutdown", () => {
|
|
83
|
+
store.clear();
|
|
84
|
+
unsubscribe();
|
|
85
|
+
});
|
|
86
|
+
return store;
|
|
87
|
+
}
|
|
@@ -33,6 +33,7 @@ export const resultInputSchema = Type.Union([Type.String(), Type.Array(Type.Stri
|
|
|
33
33
|
|
|
34
34
|
const prefix = "RESULT#";
|
|
35
35
|
const event = "pi-agent-resource:result-targets";
|
|
36
|
+
const liveResource = /^(?:shell|debug):/u;
|
|
36
37
|
|
|
37
38
|
type ResultEntry = { readonly cwd: string } & (
|
|
38
39
|
| (ResolvedResultTargets & { readonly state: "ready" })
|
|
@@ -259,7 +260,7 @@ export class ResultTargetStore {
|
|
|
259
260
|
const resource = result.resources.length === 1 ? result.resources[0] : undefined;
|
|
260
261
|
if (
|
|
261
262
|
resource &&
|
|
262
|
-
(allowResource === true || (allowResource === "live" &&
|
|
263
|
+
(allowResource === true || (allowResource === "live" && liveResource.test(resource)))
|
|
263
264
|
)
|
|
264
265
|
return resource;
|
|
265
266
|
throw new Error("This result has no reusable text selection.");
|
|
@@ -285,9 +286,14 @@ export class ResultTargetStore {
|
|
|
285
286
|
this.#results.delete(id);
|
|
286
287
|
}
|
|
287
288
|
|
|
288
|
-
/**
|
|
289
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Detect filesystem generations; a known content change also retires URI snapshots without stamps.
|
|
291
|
+
* Pending mutation handles survive invalidation so their committed spans can still be confirmed.
|
|
292
|
+
*/
|
|
293
|
+
public refresh(source: string, cwd: string, changed = false): void {
|
|
290
294
|
const identity = sourcePath(source, cwd);
|
|
295
|
+
// Live session results stay current by design, so input sent to them never retires the result.
|
|
296
|
+
if (changed && !liveResource.test(source)) this.invalidate(identity);
|
|
291
297
|
const key = JSON.stringify([path.resolve(cwd), identity]);
|
|
292
298
|
const stamp = fileStamp(source, cwd);
|
|
293
299
|
const previous = this.#snapshots.get(key);
|