kiki-agent 0.5.1 → 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/dist/builtin/examples/custom-json.mjs +7 -1
- package/dist/builtin/rules/claude/entry.mjs +8 -7
- package/dist/builtin/rules/codex/entry.mjs +8 -7
- package/dist/builtin/rules/files.mjs +6 -1
- package/dist/builtin/rules/grok.mjs +2 -2
- package/dist/builtin/rules/opencode.mjs +2 -2
- package/dist/builtin/rules/pi.mjs +3 -3
- package/dist/cpu-worker.mjs +7964 -3067
- package/dist/docs/en/configuration/config-files.md +180 -23
- package/dist/docs/en/configuration/data-locations.md +7 -4
- package/dist/docs/en/configuration/env-vars.md +1 -1
- package/dist/docs/en/configuration/providers.md +65 -17
- package/dist/docs/en/customization/agent-profiles.md +2 -2
- package/dist/docs/en/customization/agents-and-subagents.md +77 -15
- package/dist/docs/en/customization/hooks.md +77 -21
- package/dist/docs/en/customization/personas.md +3 -3
- package/dist/docs/en/customization/plugins.md +157 -7
- package/dist/docs/en/customization/prompt-fields.md +7 -5
- package/dist/docs/en/customization/recipes.md +3 -3
- package/dist/docs/en/customization/skills.md +1 -1
- package/dist/docs/en/customization/skins.md +1 -1
- package/dist/docs/en/features/agent-workflows.md +1 -1
- package/dist/docs/en/features/daily.md +5 -3
- package/dist/docs/en/features/ecosystem.md +1 -1
- package/dist/docs/en/features/freedom.md +4 -4
- package/dist/docs/en/features/index.md +4 -3
- package/dist/docs/en/features/long-work.md +4 -2
- package/dist/docs/en/features/look.md +1 -1
- package/dist/docs/en/features/people.md +2 -2
- package/dist/docs/en/features/phone.md +1 -1
- package/dist/docs/en/features/spaces.md +38 -26
- package/dist/docs/en/features/workbench.md +2 -0
- package/dist/docs/en/getting-started/first-launch.md +11 -9
- package/dist/docs/en/getting-started/installation.md +65 -2
- package/dist/docs/en/getting-started/use-cases.md +2 -2
- package/dist/docs/en/guides/interaction.md +12 -10
- package/dist/docs/en/guides/interface.md +22 -12
- package/dist/docs/en/guides/memory.md +3 -3
- package/dist/docs/en/guides/sessions.md +8 -4
- package/dist/docs/en/guides/settings.md +53 -52
- package/dist/docs/en/index.md +9 -6
- package/dist/docs/en/reference/command.md +58 -11
- package/dist/docs/en/reference/keyboard.md +32 -15
- package/dist/docs/en/reference/model-vocabulary.md +5 -9
- package/dist/docs/en/reference/slash-commands.md +10 -4
- package/dist/docs/en/reference/tools.md +80 -44
- package/dist/docs/en/server/local-server.md +11 -5
- package/dist/docs/en/server/mcp.md +2 -2
- package/dist/docs/en/server/rest-api.md +185 -59
- package/dist/docs/en/server/script-tools.md +1 -1
- package/dist/docs/zh/configuration/config-files.md +180 -23
- package/dist/docs/zh/configuration/data-locations.md +7 -4
- package/dist/docs/zh/configuration/env-vars.md +1 -1
- package/dist/docs/zh/configuration/providers.md +65 -17
- package/dist/docs/zh/customization/agent-profiles.md +2 -2
- package/dist/docs/zh/customization/agents-and-subagents.md +77 -15
- package/dist/docs/zh/customization/hooks.md +78 -22
- package/dist/docs/zh/customization/personas.md +3 -3
- package/dist/docs/zh/customization/plugins.md +157 -7
- package/dist/docs/zh/customization/prompt-fields.md +7 -5
- package/dist/docs/zh/customization/recipes.md +3 -3
- package/dist/docs/zh/customization/skills.md +1 -1
- package/dist/docs/zh/customization/skins.md +1 -1
- package/dist/docs/zh/features/agent-workflows.md +1 -1
- package/dist/docs/zh/features/daily.md +5 -3
- package/dist/docs/zh/features/ecosystem.md +1 -1
- package/dist/docs/zh/features/freedom.md +4 -4
- package/dist/docs/zh/features/index.md +4 -3
- package/dist/docs/zh/features/long-work.md +4 -2
- package/dist/docs/zh/features/look.md +1 -1
- package/dist/docs/zh/features/people.md +2 -2
- package/dist/docs/zh/features/phone.md +1 -1
- package/dist/docs/zh/features/spaces.md +39 -27
- package/dist/docs/zh/features/workbench.md +2 -0
- package/dist/docs/zh/getting-started/first-launch.md +11 -9
- package/dist/docs/zh/getting-started/installation.md +65 -2
- package/dist/docs/zh/getting-started/use-cases.md +2 -2
- package/dist/docs/zh/guides/interaction.md +12 -10
- package/dist/docs/zh/guides/interface.md +22 -12
- package/dist/docs/zh/guides/memory.md +4 -4
- package/dist/docs/zh/guides/sessions.md +8 -4
- package/dist/docs/zh/guides/settings.md +54 -53
- package/dist/docs/zh/index.md +9 -6
- package/dist/docs/zh/reference/command.md +58 -11
- package/dist/docs/zh/reference/keyboard.md +32 -15
- package/dist/docs/zh/reference/model-vocabulary.md +5 -9
- package/dist/docs/zh/reference/slash-commands.md +10 -4
- package/dist/docs/zh/reference/tools.md +79 -43
- package/dist/docs/zh/server/local-server.md +11 -5
- package/dist/docs/zh/server/mcp.md +2 -2
- package/dist/docs/zh/server/rest-api.md +176 -52
- package/dist/docs/zh/server/script-tools.md +1 -1
- package/dist/external-harness/agy-cli-acp.mjs +3859 -857
- package/dist/external-harness/agy-hook-registration.mjs +72 -20
- package/dist/external-harness/agy-permission-hook.mjs +10 -1
- package/dist/history-navigation-worker.mjs +25565 -0
- package/dist/hostRunner.mjs +753 -7
- package/dist/mailbox-worker.mjs +158 -57
- package/dist/main.mjs +2 -2
- package/dist/memory-worker.mjs +240 -64
- package/dist/native/windows-process-helper.exe +0 -0
- package/dist/plugin-isolation-worker.mjs +57 -0
- package/dist/query-store-worker.mjs +766 -53
- package/dist/sqlite-indexer.mjs +6088 -294
- package/dist/sqlite-query-worker.mjs +5896 -234
- package/dist/usage-parser-worker.mjs +36 -0
- package/dist/usage-read-model-worker.mjs +135 -37
- package/dist/web/assets/App-DCxEkgD4.js +181 -0
- package/dist/web/assets/App-DCxEkgD4.js.br +0 -0
- package/dist/web/assets/App-DCxEkgD4.js.gz +0 -0
- package/dist/web/assets/AppErrorBoundary-C2kI_Mfb.js +1 -0
- package/dist/web/assets/AppErrorBoundary-C2kI_Mfb.js.br +0 -0
- package/dist/web/assets/AppErrorBoundary-C2kI_Mfb.js.gz +0 -0
- package/dist/web/assets/ArchivedSessionsPage-CJQBRKlz.js +1 -0
- package/dist/web/assets/ArchivedSessionsPage-CJQBRKlz.js.br +0 -0
- package/dist/web/assets/ArchivedSessionsPage-CJQBRKlz.js.gz +0 -0
- package/dist/web/assets/CapabilitiesPage-C4ggBXI7.js +15 -0
- package/dist/web/assets/CapabilitiesPage-C4ggBXI7.js.br +0 -0
- package/dist/web/assets/CapabilitiesPage-C4ggBXI7.js.gz +0 -0
- package/dist/web/assets/CodeEditor-BAdDaRcl.js +4 -0
- package/dist/web/assets/CodeEditor-BAdDaRcl.js.br +0 -0
- package/dist/web/assets/CodeEditor-BAdDaRcl.js.gz +0 -0
- package/dist/web/assets/ExternalEnginesSection-Ci1_RIkB.js +2 -0
- package/dist/web/assets/ExternalEnginesSection-Ci1_RIkB.js.br +0 -0
- package/dist/web/assets/ExternalEnginesSection-Ci1_RIkB.js.gz +0 -0
- package/dist/web/assets/GlobalCronPanel-DEYDD-iB.js +1 -0
- package/dist/web/assets/GlobalCronPanel-DEYDD-iB.js.br +0 -0
- package/dist/web/assets/GlobalCronPanel-DEYDD-iB.js.gz +0 -0
- package/dist/web/assets/ImageViewport-osmMzHUM.js +1 -0
- package/dist/web/assets/ImageViewport-osmMzHUM.js.br +0 -0
- package/dist/web/assets/ImageViewport-osmMzHUM.js.gz +0 -0
- package/dist/web/assets/ListParts-DL6n2vZD.js +1 -0
- package/dist/web/assets/ListParts-DL6n2vZD.js.br +0 -0
- package/dist/web/assets/ListParts-DL6n2vZD.js.gz +0 -0
- package/dist/web/assets/MediaLightbox-DfDTfyyo.js +1 -0
- package/dist/web/assets/MediaLightbox-DfDTfyyo.js.br +0 -0
- package/dist/web/assets/MediaLightbox-DfDTfyyo.js.gz +0 -0
- package/dist/web/assets/MemoryPage-C4VM8pO8.js +1 -0
- package/dist/web/assets/MemoryPage-C4VM8pO8.js.br +0 -0
- package/dist/web/assets/MemoryPage-C4VM8pO8.js.gz +0 -0
- package/dist/web/assets/Middleware-CQ3TZHhI.js +67 -0
- package/dist/web/assets/Middleware-CQ3TZHhI.js.br +0 -0
- package/dist/web/assets/Middleware-CQ3TZHhI.js.gz +0 -0
- package/dist/web/assets/MobileAppShell-CPW83S2x.js +23 -0
- package/dist/web/assets/MobileAppShell-CPW83S2x.js.br +0 -0
- package/dist/web/assets/MobileAppShell-CPW83S2x.js.gz +0 -0
- package/dist/web/assets/ModelConnectCard-CY1w-R_8.js +2 -0
- package/dist/web/assets/ModelConnectCard-CY1w-R_8.js.br +0 -0
- package/dist/web/assets/ModelConnectCard-CY1w-R_8.js.gz +0 -0
- package/dist/web/assets/NavScopeBoundary-7FLzmaAe.js +1 -0
- package/dist/web/assets/NavScopeBoundary-7FLzmaAe.js.br +0 -0
- package/dist/web/assets/NavScopeBoundary-7FLzmaAe.js.gz +0 -0
- package/dist/web/assets/PersonasPage-CB5q8dUU.js +3 -0
- package/dist/web/assets/PersonasPage-CB5q8dUU.js.br +0 -0
- package/dist/web/assets/PersonasPage-CB5q8dUU.js.gz +0 -0
- package/dist/web/assets/PluginPanelHost-BNSzFpXj.js +1 -0
- package/dist/web/assets/PluginPanelHost-BNSzFpXj.js.br +0 -0
- package/dist/web/assets/PluginPanelHost-BNSzFpXj.js.gz +0 -0
- package/dist/web/assets/PreviewWorkspace-itdg7TxB.js +1 -0
- package/dist/web/assets/PreviewWorkspace-itdg7TxB.js.br +0 -0
- package/dist/web/assets/PreviewWorkspace-itdg7TxB.js.gz +0 -0
- package/dist/web/assets/RoomPage-DqICeoEq.js +1 -0
- package/dist/web/assets/RoomPage-DqICeoEq.js.br +0 -0
- package/dist/web/assets/RoomPage-DqICeoEq.js.gz +0 -0
- package/dist/web/assets/SecretField-DhvasDWA.js +1 -0
- package/dist/web/assets/SecretField-DhvasDWA.js.br +0 -0
- package/dist/web/assets/SecretField-DhvasDWA.js.gz +0 -0
- package/dist/web/assets/SectionCard-CDWn1QiO.js +1 -0
- package/dist/web/assets/SectionCard-CDWn1QiO.js.br +0 -0
- package/dist/web/assets/SectionCard-CDWn1QiO.js.gz +0 -0
- package/dist/web/assets/SettingsPage-BhaVVzpG.js +259 -0
- package/dist/web/assets/SettingsPage-BhaVVzpG.js.br +0 -0
- package/dist/web/assets/SettingsPage-BhaVVzpG.js.gz +0 -0
- package/dist/web/assets/ShellEntry-DNaOXNB7.js +2 -0
- package/dist/web/assets/ShellEntry-DNaOXNB7.js.br +0 -0
- package/dist/web/assets/ShellEntry-DNaOXNB7.js.gz +0 -0
- package/dist/web/assets/TasksPage-HHJ20hzK.js +1 -0
- package/dist/web/assets/TasksPage-HHJ20hzK.js.br +0 -0
- package/dist/web/assets/TasksPage-HHJ20hzK.js.gz +0 -0
- package/dist/web/assets/TerminalPanel-D7EDH4hR.js +9 -0
- package/dist/web/assets/TerminalPanel-D7EDH4hR.js.br +0 -0
- package/dist/web/assets/TerminalPanel-D7EDH4hR.js.gz +0 -0
- package/dist/web/assets/UsagePage-CyB5c-8F.js +1 -0
- package/dist/web/assets/UsagePage-CyB5c-8F.js.br +0 -0
- package/dist/web/assets/UsagePage-CyB5c-8F.js.gz +0 -0
- package/dist/web/assets/WorkPage-hiw_Nngy.js +1 -0
- package/dist/web/assets/WorkPage-hiw_Nngy.js.br +0 -0
- package/dist/web/assets/WorkPage-hiw_Nngy.js.gz +0 -0
- package/dist/web/assets/abap-BdImnpbu.js.br +0 -0
- package/dist/web/assets/abap-BdImnpbu.js.gz +0 -0
- package/dist/web/assets/actionscript-3-CoDkCxhg.js.br +0 -0
- package/dist/web/assets/actionscript-3-CoDkCxhg.js.gz +0 -0
- package/dist/web/assets/ada-bCR0ucgS.js.br +0 -0
- package/dist/web/assets/ada-bCR0ucgS.js.gz +0 -0
- package/dist/web/assets/androidBridge-DgaAG2Pi.js +1 -0
- package/dist/web/assets/androidBridge-DgaAG2Pi.js.br +0 -0
- package/dist/web/assets/androidBridge-DgaAG2Pi.js.gz +0 -0
- package/dist/web/assets/andromeeda-C4gqWexZ.js.br +0 -0
- package/dist/web/assets/andromeeda-C4gqWexZ.js.gz +0 -0
- package/dist/web/assets/angular-html-CU67Zn6k.js.br +0 -0
- package/dist/web/assets/angular-html-CU67Zn6k.js.gz +0 -0
- package/dist/web/assets/angular-ts-BwZT4LLn.js.br +0 -0
- package/dist/web/assets/angular-ts-BwZT4LLn.js.gz +0 -0
- package/dist/web/assets/apache-Pmp26Uib.js.br +0 -0
- package/dist/web/assets/apache-Pmp26Uib.js.gz +0 -0
- package/dist/web/assets/apex-D8_7TLub.js.br +0 -0
- package/dist/web/assets/apex-D8_7TLub.js.gz +0 -0
- package/dist/web/assets/apl-B4CMkyY2.js.br +0 -0
- package/dist/web/assets/apl-B4CMkyY2.js.gz +0 -0
- package/dist/web/assets/apl-dKokRX4l.js.br +0 -0
- package/dist/web/assets/apl-dKokRX4l.js.gz +0 -0
- package/dist/web/assets/applescript-Co6uUVPk.js.br +0 -0
- package/dist/web/assets/applescript-Co6uUVPk.js.gz +0 -0
- package/dist/web/assets/ara-BRHolxvo.js.br +0 -0
- package/dist/web/assets/ara-BRHolxvo.js.gz +0 -0
- package/dist/web/assets/arc-DoGfTGgR.js +1 -0
- package/dist/web/assets/arc-DoGfTGgR.js.br +0 -0
- package/dist/web/assets/arc-DoGfTGgR.js.gz +0 -0
- package/dist/web/assets/asciiarmor-Df11BRmG.js.br +0 -0
- package/dist/web/assets/asciiarmor-Df11BRmG.js.gz +0 -0
- package/dist/web/assets/asciidoc-Ve4PFQV2.js.br +0 -0
- package/dist/web/assets/asciidoc-Ve4PFQV2.js.gz +0 -0
- package/dist/web/assets/askKiki-CgAsWGRZ.js +2 -0
- package/dist/web/assets/askKiki-CgAsWGRZ.js.br +0 -0
- package/dist/web/assets/askKiki-CgAsWGRZ.js.gz +0 -0
- package/dist/web/assets/asm-D_Q5rh1f.js.br +0 -0
- package/dist/web/assets/asm-D_Q5rh1f.js.gz +0 -0
- package/dist/web/assets/asn1-EdZsLKOL.js.br +0 -0
- package/dist/web/assets/asn1-EdZsLKOL.js.gz +0 -0
- package/dist/web/assets/asterisk-B-8jnY81.js.br +0 -0
- package/dist/web/assets/asterisk-B-8jnY81.js.gz +0 -0
- package/dist/web/assets/astro-CbQHKStN.js.br +0 -0
- package/dist/web/assets/astro-CbQHKStN.js.gz +0 -0
- package/dist/web/assets/aurora-x-D-2ljcwZ.js.br +0 -0
- package/dist/web/assets/aurora-x-D-2ljcwZ.js.gz +0 -0
- package/dist/web/assets/awk-DMzUqQB5.js.br +0 -0
- package/dist/web/assets/awk-DMzUqQB5.js.gz +0 -0
- package/dist/web/assets/ayu-dark-DYE7WIF3.js.br +0 -0
- package/dist/web/assets/ayu-dark-DYE7WIF3.js.gz +0 -0
- package/dist/web/assets/ayu-light-BA47KaF1.js.br +0 -0
- package/dist/web/assets/ayu-light-BA47KaF1.js.gz +0 -0
- package/dist/web/assets/ayu-mirage-32ctXXKs.js.br +0 -0
- package/dist/web/assets/ayu-mirage-32ctXXKs.js.gz +0 -0
- package/dist/web/assets/ballerina-BFfxhgS-.js.br +0 -0
- package/dist/web/assets/ballerina-BFfxhgS-.js.gz +0 -0
- package/dist/web/assets/band-dPffDWoQ.js +1 -0
- package/dist/web/assets/band-dPffDWoQ.js.br +0 -0
- package/dist/web/assets/band-dPffDWoQ.js.gz +0 -0
- package/dist/web/assets/bat-BkioyH1T.js.br +0 -0
- package/dist/web/assets/bat-BkioyH1T.js.gz +0 -0
- package/dist/web/assets/beancount-k_qm7-4y.js.br +0 -0
- package/dist/web/assets/beancount-k_qm7-4y.js.gz +0 -0
- package/dist/web/assets/berry-uYugtg8r.js.br +0 -0
- package/dist/web/assets/berry-uYugtg8r.js.gz +0 -0
- package/dist/web/assets/bibtex-CHM0blh-.js.br +0 -0
- package/dist/web/assets/bibtex-CHM0blh-.js.gz +0 -0
- package/dist/web/assets/bicep-Bmn6On1c.js.br +0 -0
- package/dist/web/assets/bicep-Bmn6On1c.js.gz +0 -0
- package/dist/web/assets/bird2-DPOp833l.js.br +0 -0
- package/dist/web/assets/bird2-DPOp833l.js.gz +0 -0
- package/dist/web/assets/blade-D4QpJJKB.js.br +0 -0
- package/dist/web/assets/blade-D4QpJJKB.js.gz +0 -0
- package/dist/web/assets/brainfuck-C4LP7Hcl.js.br +0 -0
- package/dist/web/assets/brainfuck-C4LP7Hcl.js.gz +0 -0
- package/dist/web/assets/bsl-BO_Y6i37.js.br +0 -0
- package/dist/web/assets/bsl-BO_Y6i37.js.gz +0 -0
- package/dist/web/assets/c-BIGW1oBm.js.br +0 -0
- package/dist/web/assets/c-BIGW1oBm.js.gz +0 -0
- package/dist/web/assets/c3-eo99z4R2.js.br +0 -0
- package/dist/web/assets/c3-eo99z4R2.js.gz +0 -0
- package/dist/web/assets/cadence-Bv_4Rxtq.js.br +0 -0
- package/dist/web/assets/cadence-Bv_4Rxtq.js.gz +0 -0
- package/dist/web/assets/cairo-KRGpt6FW.js.br +0 -0
- package/dist/web/assets/cairo-KRGpt6FW.js.gz +0 -0
- package/dist/web/assets/catppuccin-frappe-DFWUc33u.js.br +0 -0
- package/dist/web/assets/catppuccin-frappe-DFWUc33u.js.gz +0 -0
- package/dist/web/assets/catppuccin-latte-C9dUb6Cb.js.br +0 -0
- package/dist/web/assets/catppuccin-latte-C9dUb6Cb.js.gz +0 -0
- package/dist/web/assets/catppuccin-macchiato-DQyhUUbL.js.br +0 -0
- package/dist/web/assets/catppuccin-macchiato-DQyhUUbL.js.gz +0 -0
- package/dist/web/assets/catppuccin-mocha-D87Tk5Gz.js.br +0 -0
- package/dist/web/assets/catppuccin-mocha-D87Tk5Gz.js.gz +0 -0
- package/dist/web/assets/channel-BwCaPRlV.js +1 -0
- package/dist/web/assets/channel-BwCaPRlV.js.br +0 -0
- package/dist/web/assets/channel-BwCaPRlV.js.gz +0 -0
- package/dist/web/assets/clarity-D53aC0YG.js.br +0 -0
- package/dist/web/assets/clarity-D53aC0YG.js.gz +0 -0
- package/dist/web/assets/client-cAizUM-b.js +7 -0
- package/dist/web/assets/client-cAizUM-b.js.br +0 -0
- package/dist/web/assets/client-cAizUM-b.js.gz +0 -0
- package/dist/web/assets/clike-B9uivgTg.js.br +0 -0
- package/dist/web/assets/clike-B9uivgTg.js.gz +0 -0
- package/dist/web/assets/clojure-BMjYHr_A.js.br +0 -0
- package/dist/web/assets/clojure-BMjYHr_A.js.gz +0 -0
- package/dist/web/assets/clojure-P80f7IUj.js.br +0 -0
- package/dist/web/assets/clojure-P80f7IUj.js.gz +0 -0
- package/dist/web/assets/clone-JiRK1kR-.js +1 -0
- package/dist/web/assets/clone-JiRK1kR-.js.br +0 -0
- package/dist/web/assets/clone-JiRK1kR-.js.gz +0 -0
- package/dist/web/assets/cmake-BQqOBYOt.js.br +0 -0
- package/dist/web/assets/cmake-BQqOBYOt.js.gz +0 -0
- package/dist/web/assets/cmake-D1j8_8rp.js.br +0 -0
- package/dist/web/assets/cmake-D1j8_8rp.js.gz +0 -0
- package/dist/web/assets/cobol-CWcv1MsR.js.br +0 -0
- package/dist/web/assets/cobol-CWcv1MsR.js.gz +0 -0
- package/dist/web/assets/cobol-nwyudZeR.js.br +0 -0
- package/dist/web/assets/cobol-nwyudZeR.js.gz +0 -0
- package/dist/web/assets/codeowners-Bp6g37R7.js.br +0 -0
- package/dist/web/assets/codeowners-Bp6g37R7.js.gz +0 -0
- package/dist/web/assets/codeql-DsOJ9woJ.js.br +0 -0
- package/dist/web/assets/codeql-DsOJ9woJ.js.gz +0 -0
- package/dist/web/assets/coffee-Ch7k5sss.js.br +0 -0
- package/dist/web/assets/coffee-Ch7k5sss.js.gz +0 -0
- package/dist/web/assets/coffeescript-S37ZYGWr.js.br +0 -0
- package/dist/web/assets/coffeescript-S37ZYGWr.js.gz +0 -0
- package/dist/web/assets/common-lisp-Cg-RD9OK.js.br +0 -0
- package/dist/web/assets/common-lisp-Cg-RD9OK.js.gz +0 -0
- package/dist/web/assets/commonlisp-DBKNyK5s.js.br +0 -0
- package/dist/web/assets/commonlisp-DBKNyK5s.js.gz +0 -0
- package/dist/web/assets/connection-5XKg4sL2.js +404 -0
- package/dist/web/assets/connection-5XKg4sL2.js.br +0 -0
- package/dist/web/assets/connection-5XKg4sL2.js.gz +0 -0
- package/dist/web/assets/controls-C3UrNiBn.js +1 -0
- package/dist/web/assets/controls-C3UrNiBn.js.br +0 -0
- package/dist/web/assets/controls-C3UrNiBn.js.gz +0 -0
- package/dist/web/assets/coq-DkFqJrB1.js.br +0 -0
- package/dist/web/assets/coq-DkFqJrB1.js.gz +0 -0
- package/dist/web/assets/cpp-CofmeUqb.js.br +0 -0
- package/dist/web/assets/cpp-CofmeUqb.js.gz +0 -0
- package/dist/web/assets/crystal-SjHAIU92.js.br +0 -0
- package/dist/web/assets/crystal-SjHAIU92.js.gz +0 -0
- package/dist/web/assets/crystal-tKQVLTB8.js.br +0 -0
- package/dist/web/assets/crystal-tKQVLTB8.js.gz +0 -0
- package/dist/web/assets/csharp-COcwbKMJ.js.br +0 -0
- package/dist/web/assets/csharp-COcwbKMJ.js.gz +0 -0
- package/dist/web/assets/css-BnMrqG3P.js.br +0 -0
- package/dist/web/assets/css-BnMrqG3P.js.gz +0 -0
- package/dist/web/assets/css-DPfMkruS.js.br +0 -0
- package/dist/web/assets/css-DPfMkruS.js.gz +0 -0
- package/dist/web/assets/csv-fuZLfV_i.js.br +0 -0
- package/dist/web/assets/csv-fuZLfV_i.js.gz +0 -0
- package/dist/web/assets/cue-D82EKSYY.js.br +0 -0
- package/dist/web/assets/cue-D82EKSYY.js.gz +0 -0
- package/dist/web/assets/cypher-COkxafJQ.js.br +0 -0
- package/dist/web/assets/cypher-COkxafJQ.js.gz +0 -0
- package/dist/web/assets/cypher-C_CwsFkJ.js.br +0 -0
- package/dist/web/assets/cypher-C_CwsFkJ.js.gz +0 -0
- package/dist/web/assets/cytoscape-cose-bilkent-CGdh9URw.js +1 -0
- package/dist/web/assets/cytoscape-cose-bilkent-CGdh9URw.js.br +0 -0
- package/dist/web/assets/cytoscape-cose-bilkent-CGdh9URw.js.gz +0 -0
- package/dist/web/assets/cytoscape-fcose-ZavmgdCc.js +1 -0
- package/dist/web/assets/cytoscape-fcose-ZavmgdCc.js.br +0 -0
- package/dist/web/assets/cytoscape-fcose-ZavmgdCc.js.gz +0 -0
- package/dist/web/assets/cytoscape.esm-nFXppDBa.js.br +0 -0
- package/dist/web/assets/cytoscape.esm-nFXppDBa.js.gz +0 -0
- package/dist/web/assets/d-85-TOEBH.js.br +0 -0
- package/dist/web/assets/d-85-TOEBH.js.gz +0 -0
- package/dist/web/assets/d-pRatUO7H.js.br +0 -0
- package/dist/web/assets/d-pRatUO7H.js.gz +0 -0
- package/dist/web/assets/dark-plus-C3mMm8J8.js.br +0 -0
- package/dist/web/assets/dark-plus-C3mMm8J8.js.gz +0 -0
- package/dist/web/assets/dart-CF10PKvl.js.br +0 -0
- package/dist/web/assets/dart-CF10PKvl.js.gz +0 -0
- package/dist/web/assets/dax-CEL-wOlO.js.br +0 -0
- package/dist/web/assets/dax-CEL-wOlO.js.gz +0 -0
- package/dist/web/assets/{defaultLocale-DX6XiGOO.js → defaultLocale-5voVPcsN.js} +1 -1
- package/dist/web/assets/defaultLocale-5voVPcsN.js.br +0 -0
- package/dist/web/assets/defaultLocale-5voVPcsN.js.gz +0 -0
- package/dist/web/assets/desktop-BmXAJ9_W.js.br +0 -0
- package/dist/web/assets/desktop-BmXAJ9_W.js.gz +0 -0
- package/dist/web/assets/diff-D97Zzqfu.js.br +0 -0
- package/dist/web/assets/diff-D97Zzqfu.js.gz +0 -0
- package/dist/web/assets/diff-DbItnlRl.js.br +0 -0
- package/dist/web/assets/diff-DbItnlRl.js.gz +0 -0
- package/dist/web/assets/docker-BcOcwvcX.js.br +0 -0
- package/dist/web/assets/docker-BcOcwvcX.js.gz +0 -0
- package/dist/web/assets/dockerfile-BKs6k2Af.js.br +0 -0
- package/dist/web/assets/dockerfile-BKs6k2Af.js.gz +0 -0
- package/dist/web/assets/dotenv-Da5cRb03.js.br +0 -0
- package/dist/web/assets/dotenv-Da5cRb03.js.gz +0 -0
- package/dist/web/assets/dracula-BzJJZx-M.js.br +0 -0
- package/dist/web/assets/dracula-BzJJZx-M.js.gz +0 -0
- package/dist/web/assets/dracula-soft-BXkSAIEj.js.br +0 -0
- package/dist/web/assets/dracula-soft-BXkSAIEj.js.gz +0 -0
- package/dist/web/assets/dream-maker-BtqSS_iP.js.br +0 -0
- package/dist/web/assets/dream-maker-BtqSS_iP.js.gz +0 -0
- package/dist/web/assets/dtd-DF_7sFjM.js.br +0 -0
- package/dist/web/assets/dtd-DF_7sFjM.js.gz +0 -0
- package/dist/web/assets/duration-BNAPaH6N.js +1 -0
- package/dist/web/assets/duration-BNAPaH6N.js.br +0 -0
- package/dist/web/assets/duration-BNAPaH6N.js.gz +0 -0
- package/dist/web/assets/dylan-DwRh75JA.js.br +0 -0
- package/dist/web/assets/dylan-DwRh75JA.js.gz +0 -0
- package/dist/web/assets/ebnf-CDyGwa7X.js.br +0 -0
- package/dist/web/assets/ebnf-CDyGwa7X.js.gz +0 -0
- package/dist/web/assets/ecl-Cabwm37j.js.br +0 -0
- package/dist/web/assets/ecl-Cabwm37j.js.gz +0 -0
- package/dist/web/assets/edge-BkV0erSs.js.br +0 -0
- package/dist/web/assets/edge-BkV0erSs.js.gz +0 -0
- package/dist/web/assets/eiffel-CnydiIhH.js.br +0 -0
- package/dist/web/assets/eiffel-CnydiIhH.js.gz +0 -0
- package/dist/web/assets/elixir-CDX3lj18.js.br +0 -0
- package/dist/web/assets/elixir-CDX3lj18.js.gz +0 -0
- package/dist/web/assets/elm-DbKCFpqz.js.br +0 -0
- package/dist/web/assets/elm-DbKCFpqz.js.gz +0 -0
- package/dist/web/assets/elm-vLlmbW-K.js.br +0 -0
- package/dist/web/assets/elm-vLlmbW-K.js.gz +0 -0
- package/dist/web/assets/emacs-lisp-C9XAeP06.js.br +0 -0
- package/dist/web/assets/emacs-lisp-C9XAeP06.js.gz +0 -0
- package/dist/web/assets/erb-B12qg9BL.js.br +0 -0
- package/dist/web/assets/erb-B12qg9BL.js.gz +0 -0
- package/dist/web/assets/erlang-BNw1qcRV.js.br +0 -0
- package/dist/web/assets/erlang-BNw1qcRV.js.gz +0 -0
- package/dist/web/assets/erlang-DsQrWhSR.js.br +0 -0
- package/dist/web/assets/erlang-DsQrWhSR.js.gz +0 -0
- package/dist/web/assets/everforest-dark-BgDCqdQA.js.br +0 -0
- package/dist/web/assets/everforest-dark-BgDCqdQA.js.gz +0 -0
- package/dist/web/assets/everforest-light-C8M2exoo.js.br +0 -0
- package/dist/web/assets/everforest-light-C8M2exoo.js.gz +0 -0
- package/dist/web/assets/export-BlURphmw.js +2 -0
- package/dist/web/assets/export-BlURphmw.js.br +0 -0
- package/dist/web/assets/export-BlURphmw.js.gz +0 -0
- package/dist/web/assets/factor-kuTfRLto.js.br +0 -0
- package/dist/web/assets/factor-kuTfRLto.js.gz +0 -0
- package/dist/web/assets/fcl-Kvtd6kyn.js.br +0 -0
- package/dist/web/assets/fcl-Kvtd6kyn.js.gz +0 -0
- package/dist/web/assets/fennel-BYunw83y.js.br +0 -0
- package/dist/web/assets/fennel-BYunw83y.js.gz +0 -0
- package/dist/web/assets/fish-BvzEVeQv.js.br +0 -0
- package/dist/web/assets/fish-BvzEVeQv.js.gz +0 -0
- package/dist/web/assets/fluent-C4IJs8-o.js.br +0 -0
- package/dist/web/assets/fluent-C4IJs8-o.js.gz +0 -0
- package/dist/web/assets/forth-Ffai-XNe.js.br +0 -0
- package/dist/web/assets/forth-Ffai-XNe.js.gz +0 -0
- package/dist/web/assets/fortran-DYz_wnZ1.js.br +0 -0
- package/dist/web/assets/fortran-DYz_wnZ1.js.gz +0 -0
- package/dist/web/assets/fortran-fixed-form-CkoXwp7k.js.br +0 -0
- package/dist/web/assets/fortran-fixed-form-CkoXwp7k.js.gz +0 -0
- package/dist/web/assets/fortran-free-form-BxgE0vQu.js.br +0 -0
- package/dist/web/assets/fortran-free-form-BxgE0vQu.js.gz +0 -0
- package/dist/web/assets/fsharp-CXgrBDvD.js.br +0 -0
- package/dist/web/assets/fsharp-CXgrBDvD.js.gz +0 -0
- package/dist/web/assets/gas-Bneqetm1.js.br +0 -0
- package/dist/web/assets/gas-Bneqetm1.js.gz +0 -0
- package/dist/web/assets/gdresource-BOOCDP_w.js.br +0 -0
- package/dist/web/assets/gdresource-BOOCDP_w.js.gz +0 -0
- package/dist/web/assets/gdscript-C5YyOfLZ.js.br +0 -0
- package/dist/web/assets/gdscript-C5YyOfLZ.js.gz +0 -0
- package/dist/web/assets/gdshader-DkwncUOv.js.br +0 -0
- package/dist/web/assets/gdshader-DkwncUOv.js.gz +0 -0
- package/dist/web/assets/genie-D0YGMca9.js.br +0 -0
- package/dist/web/assets/genie-D0YGMca9.js.gz +0 -0
- package/dist/web/assets/gherkin-DyxjwDmM.js.br +0 -0
- package/dist/web/assets/gherkin-DyxjwDmM.js.gz +0 -0
- package/dist/web/assets/gherkin-heZmZLOM.js.br +0 -0
- package/dist/web/assets/gherkin-heZmZLOM.js.gz +0 -0
- package/dist/web/assets/git-commit-F4YmCXRG.js.br +0 -0
- package/dist/web/assets/git-commit-F4YmCXRG.js.gz +0 -0
- package/dist/web/assets/git-rebase-r7XF79zn.js.br +0 -0
- package/dist/web/assets/git-rebase-r7XF79zn.js.gz +0 -0
- package/dist/web/assets/github-dark-DHJKELXO.js.br +0 -0
- package/dist/web/assets/github-dark-DHJKELXO.js.gz +0 -0
- package/dist/web/assets/github-dark-default-Cuk6v7N8.js.br +0 -0
- package/dist/web/assets/github-dark-default-Cuk6v7N8.js.gz +0 -0
- package/dist/web/assets/github-dark-dimmed-DH5Ifo-i.js.br +0 -0
- package/dist/web/assets/github-dark-dimmed-DH5Ifo-i.js.gz +0 -0
- package/dist/web/assets/github-dark-high-contrast-E3gJ1_iC.js.br +0 -0
- package/dist/web/assets/github-dark-high-contrast-E3gJ1_iC.js.gz +0 -0
- package/dist/web/assets/github-light-DAi9KRSo.js.br +0 -0
- package/dist/web/assets/github-light-DAi9KRSo.js.gz +0 -0
- package/dist/web/assets/github-light-default-D7oLnXFd.js.br +0 -0
- package/dist/web/assets/github-light-default-D7oLnXFd.js.gz +0 -0
- package/dist/web/assets/github-light-high-contrast-BfjtVDDH.js.br +0 -0
- package/dist/web/assets/github-light-high-contrast-BfjtVDDH.js.gz +0 -0
- package/dist/web/assets/gleam-BspZqrRM.js.br +0 -0
- package/dist/web/assets/gleam-BspZqrRM.js.gz +0 -0
- package/dist/web/assets/glimmer-js-Rg0-pVw9.js.br +0 -0
- package/dist/web/assets/glimmer-js-Rg0-pVw9.js.gz +0 -0
- package/dist/web/assets/glimmer-ts-U6CK756n.js.br +0 -0
- package/dist/web/assets/glimmer-ts-U6CK756n.js.gz +0 -0
- package/dist/web/assets/glsl-DplSGwfg.js.br +0 -0
- package/dist/web/assets/glsl-DplSGwfg.js.gz +0 -0
- package/dist/web/assets/gn-n2N0HUVH.js.br +0 -0
- package/dist/web/assets/gn-n2N0HUVH.js.gz +0 -0
- package/dist/web/assets/gnuplot-DdkO51Og.js.br +0 -0
- package/dist/web/assets/gnuplot-DdkO51Og.js.gz +0 -0
- package/dist/web/assets/go-CxLEBnE3.js.br +0 -0
- package/dist/web/assets/go-CxLEBnE3.js.gz +0 -0
- package/dist/web/assets/graph--OzhPTMs.js.br +0 -0
- package/dist/web/assets/graph--OzhPTMs.js.gz +0 -0
- package/dist/web/assets/graphql-ChdNCCLP.js.br +0 -0
- package/dist/web/assets/graphql-ChdNCCLP.js.gz +0 -0
- package/dist/web/assets/groovy-D9Dt4D0W.js.br +0 -0
- package/dist/web/assets/groovy-D9Dt4D0W.js.gz +0 -0
- package/dist/web/assets/groovy-gcz8RCvz.js.br +0 -0
- package/dist/web/assets/groovy-gcz8RCvz.js.gz +0 -0
- package/dist/web/assets/gruvbox-dark-hard-CFHQjOhq.js.br +0 -0
- package/dist/web/assets/gruvbox-dark-hard-CFHQjOhq.js.gz +0 -0
- package/dist/web/assets/gruvbox-dark-medium-GsRaNv29.js.br +0 -0
- package/dist/web/assets/gruvbox-dark-medium-GsRaNv29.js.gz +0 -0
- package/dist/web/assets/gruvbox-dark-soft-CVdnzihN.js.br +0 -0
- package/dist/web/assets/gruvbox-dark-soft-CVdnzihN.js.gz +0 -0
- package/dist/web/assets/gruvbox-light-hard-CH1njM8p.js.br +0 -0
- package/dist/web/assets/gruvbox-light-hard-CH1njM8p.js.gz +0 -0
- package/dist/web/assets/gruvbox-light-medium-DRw_LuNl.js.br +0 -0
- package/dist/web/assets/gruvbox-light-medium-DRw_LuNl.js.gz +0 -0
- package/dist/web/assets/gruvbox-light-soft-hJgmCMqR.js.br +0 -0
- package/dist/web/assets/gruvbox-light-soft-hJgmCMqR.js.gz +0 -0
- package/dist/web/assets/hack-CaT9iCJl.js.br +0 -0
- package/dist/web/assets/hack-CaT9iCJl.js.gz +0 -0
- package/dist/web/assets/haml-B8DHNrY2.js.br +0 -0
- package/dist/web/assets/haml-B8DHNrY2.js.gz +0 -0
- package/dist/web/assets/handlebars-BL8al0AC.js.br +0 -0
- package/dist/web/assets/handlebars-BL8al0AC.js.gz +0 -0
- package/dist/web/assets/haskell-Cw1EW3IL.js.br +0 -0
- package/dist/web/assets/haskell-Cw1EW3IL.js.gz +0 -0
- package/dist/web/assets/haskell-Df6bDoY_.js.br +0 -0
- package/dist/web/assets/haskell-Df6bDoY_.js.gz +0 -0
- package/dist/web/assets/haxe-CzTSHFRz.js.br +0 -0
- package/dist/web/assets/haxe-CzTSHFRz.js.gz +0 -0
- package/dist/web/assets/haxe-H-WmDvRZ.js.br +0 -0
- package/dist/web/assets/haxe-H-WmDvRZ.js.gz +0 -0
- package/dist/web/assets/hcl-BWvSN4gD.js.br +0 -0
- package/dist/web/assets/hcl-BWvSN4gD.js.gz +0 -0
- package/dist/web/assets/highlighted-body-OFNGDK62-CF-6XyfM.js +1 -0
- package/dist/web/assets/highlighted-body-OFNGDK62-CF-6XyfM.js.br +0 -0
- package/dist/web/assets/highlighted-body-OFNGDK62-CF-6XyfM.js.gz +0 -0
- package/dist/web/assets/hjson-D5-asLiD.js.br +0 -0
- package/dist/web/assets/hjson-D5-asLiD.js.gz +0 -0
- package/dist/web/assets/hlsl-D3lLCCz7.js.br +0 -0
- package/dist/web/assets/hlsl-D3lLCCz7.js.gz +0 -0
- package/dist/web/assets/horizon-BUw7H-hv.js.br +0 -0
- package/dist/web/assets/horizon-BUw7H-hv.js.gz +0 -0
- package/dist/web/assets/horizon-bright-Cn-bp-IR.js.br +0 -0
- package/dist/web/assets/horizon-bright-Cn-bp-IR.js.gz +0 -0
- package/dist/web/assets/houston-DnULxvSX.js.br +0 -0
- package/dist/web/assets/houston-DnULxvSX.js.gz +0 -0
- package/dist/web/assets/html-GMplVEZG.js.br +0 -0
- package/dist/web/assets/html-GMplVEZG.js.gz +0 -0
- package/dist/web/assets/html-derivative-BFtXZ54Q.js.br +0 -0
- package/dist/web/assets/html-derivative-BFtXZ54Q.js.gz +0 -0
- package/dist/web/assets/http-DBlCnlav.js.br +0 -0
- package/dist/web/assets/http-DBlCnlav.js.gz +0 -0
- package/dist/web/assets/http-jrhK8wxY.js.br +0 -0
- package/dist/web/assets/http-jrhK8wxY.js.gz +0 -0
- package/dist/web/assets/hurl-irOxFIW8.js.br +0 -0
- package/dist/web/assets/hurl-irOxFIW8.js.gz +0 -0
- package/dist/web/assets/hxml-Bvhsp5Yf.js.br +0 -0
- package/dist/web/assets/hxml-Bvhsp5Yf.js.gz +0 -0
- package/dist/web/assets/hy-DFXneXwc.js.br +0 -0
- package/dist/web/assets/hy-DFXneXwc.js.gz +0 -0
- package/dist/web/assets/idl-BEugSyMb.js.br +0 -0
- package/dist/web/assets/idl-BEugSyMb.js.gz +0 -0
- package/dist/web/assets/imba-DGztddWO.js.br +0 -0
- package/dist/web/assets/imba-DGztddWO.js.gz +0 -0
- package/dist/web/assets/{index-DmwFFSkV.js → index-AtrTtxWl.js} +1 -1
- package/dist/web/assets/index-AtrTtxWl.js.br +0 -0
- package/dist/web/assets/index-AtrTtxWl.js.gz +0 -0
- package/dist/web/assets/index-BBEGEj83.js +1 -0
- package/dist/web/assets/index-BBEGEj83.js.br +0 -0
- package/dist/web/assets/index-BBEGEj83.js.gz +0 -0
- package/dist/web/assets/index-BDdIDEp4.js +1 -0
- package/dist/web/assets/index-BDdIDEp4.js.br +0 -0
- package/dist/web/assets/index-BDdIDEp4.js.gz +0 -0
- package/dist/web/assets/index-BIfumokk.js +1 -0
- package/dist/web/assets/index-BIfumokk.js.br +0 -0
- package/dist/web/assets/index-BIfumokk.js.gz +0 -0
- package/dist/web/assets/index-BLi2nTxe.js +206 -0
- package/dist/web/assets/index-BLi2nTxe.js.br +0 -0
- package/dist/web/assets/index-BLi2nTxe.js.gz +0 -0
- package/dist/web/assets/index-BNFiIuBC.js +1 -0
- package/dist/web/assets/index-BNFiIuBC.js.br +0 -0
- package/dist/web/assets/index-BNFiIuBC.js.gz +0 -0
- package/dist/web/assets/index-BOXDlCpS.js +1 -0
- package/dist/web/assets/index-BOXDlCpS.js.br +0 -0
- package/dist/web/assets/index-BOXDlCpS.js.gz +0 -0
- package/dist/web/assets/{index-CBvwNH_H.js → index-BPG2nU9y.js} +1 -1
- package/dist/web/assets/index-BPG2nU9y.js.br +0 -0
- package/dist/web/assets/index-BPG2nU9y.js.gz +0 -0
- package/dist/web/assets/index-BSVOVe3D.js +1 -0
- package/dist/web/assets/index-BSVOVe3D.js.br +0 -0
- package/dist/web/assets/index-BSVOVe3D.js.gz +0 -0
- package/dist/web/assets/{index-CPSWYh_R.js → index-BT8zjpNF.js} +5 -5
- package/dist/web/assets/index-BT8zjpNF.js.br +0 -0
- package/dist/web/assets/index-BT8zjpNF.js.gz +0 -0
- package/dist/web/assets/index-BTHoDcN1.js +7 -0
- package/dist/web/assets/index-BTHoDcN1.js.br +0 -0
- package/dist/web/assets/index-BTHoDcN1.js.gz +0 -0
- package/dist/web/assets/{index-DRo5Y_9p.js → index-BWFj-16K.js} +1 -1
- package/dist/web/assets/index-BWFj-16K.js.br +0 -0
- package/dist/web/assets/index-BWFj-16K.js.gz +0 -0
- package/dist/web/assets/index-BYkQjRc-.js +1 -0
- package/dist/web/assets/index-BYkQjRc-.js.br +0 -0
- package/dist/web/assets/index-BYkQjRc-.js.gz +0 -0
- package/dist/web/assets/{index-BxYCSNg_.js → index-BbmM2LEW.js} +2 -2
- package/dist/web/assets/index-BbmM2LEW.js.br +0 -0
- package/dist/web/assets/index-BbmM2LEW.js.gz +0 -0
- package/dist/web/assets/index-C6n6XERd.js +1 -0
- package/dist/web/assets/index-C6n6XERd.js.br +0 -0
- package/dist/web/assets/index-C6n6XERd.js.gz +0 -0
- package/dist/web/assets/index-C83WoUbd.js +1 -0
- package/dist/web/assets/index-C83WoUbd.js.br +0 -0
- package/dist/web/assets/index-C83WoUbd.js.gz +0 -0
- package/dist/web/assets/index-C8DDOUJx.css +1 -0
- package/dist/web/assets/index-C8DDOUJx.css.br +0 -0
- package/dist/web/assets/index-C8DDOUJx.css.gz +0 -0
- package/dist/web/assets/index-C9DdZFNJ.js +1 -0
- package/dist/web/assets/index-C9DdZFNJ.js.br +0 -0
- package/dist/web/assets/index-C9DdZFNJ.js.gz +0 -0
- package/dist/web/assets/index-CP99-KdF.js +1 -0
- package/dist/web/assets/index-CP99-KdF.js.br +0 -0
- package/dist/web/assets/index-CP99-KdF.js.gz +0 -0
- package/dist/web/assets/index-CVrtusX9.js +1 -0
- package/dist/web/assets/index-CVrtusX9.js.br +0 -0
- package/dist/web/assets/index-CVrtusX9.js.gz +0 -0
- package/dist/web/assets/{index-DfUpwUTM.js → index-ChTpz7dO.js} +2 -2
- package/dist/web/assets/index-ChTpz7dO.js.br +0 -0
- package/dist/web/assets/index-ChTpz7dO.js.gz +0 -0
- package/dist/web/assets/index-CjceQ8Nh.js +1 -0
- package/dist/web/assets/index-CjceQ8Nh.js.br +0 -0
- package/dist/web/assets/index-CjceQ8Nh.js.gz +0 -0
- package/dist/web/assets/{index-CjvqtF2I.js → index-CsKZwkF5.js} +1 -1
- package/dist/web/assets/index-CsKZwkF5.js.br +0 -0
- package/dist/web/assets/index-CsKZwkF5.js.gz +0 -0
- package/dist/web/assets/index-CvYzv8kf.js +1 -0
- package/dist/web/assets/index-CvYzv8kf.js.br +0 -0
- package/dist/web/assets/index-CvYzv8kf.js.gz +0 -0
- package/dist/web/assets/index-D2CHDVPg.js +1 -0
- package/dist/web/assets/index-D2CHDVPg.js.br +0 -0
- package/dist/web/assets/index-D2CHDVPg.js.gz +0 -0
- package/dist/web/assets/index-D4M-EXnj.js +1 -0
- package/dist/web/assets/index-D4M-EXnj.js.br +0 -0
- package/dist/web/assets/index-D4M-EXnj.js.gz +0 -0
- package/dist/web/assets/{index-BvRBCpc6.js → index-DHqpUC48.js} +2 -2
- package/dist/web/assets/index-DHqpUC48.js.br +0 -0
- package/dist/web/assets/index-DHqpUC48.js.gz +0 -0
- package/dist/web/assets/index-Da0Nrt28.js +1 -0
- package/dist/web/assets/index-Da0Nrt28.js.br +0 -0
- package/dist/web/assets/index-Da0Nrt28.js.gz +0 -0
- package/dist/web/assets/index-DyWRj5df.js +1 -0
- package/dist/web/assets/index-DyWRj5df.js.br +0 -0
- package/dist/web/assets/index-DyWRj5df.js.gz +0 -0
- package/dist/web/assets/{index-Dkbz748K.js → index-DyZAPivK.js} +4 -4
- package/dist/web/assets/index-DyZAPivK.js.br +0 -0
- package/dist/web/assets/index-DyZAPivK.js.gz +0 -0
- package/dist/web/assets/index-FqFCN7CT.js +13 -0
- package/dist/web/assets/index-FqFCN7CT.js.br +0 -0
- package/dist/web/assets/index-FqFCN7CT.js.gz +0 -0
- package/dist/web/assets/{index-Br3AlBrQ.js → index-L9ABPsXe.js} +1 -1
- package/dist/web/assets/index-L9ABPsXe.js.br +0 -0
- package/dist/web/assets/index-L9ABPsXe.js.gz +0 -0
- package/dist/web/assets/ini-BEwlwnbL.js.br +0 -0
- package/dist/web/assets/ini-BEwlwnbL.js.gz +0 -0
- package/dist/web/assets/init-Gi6I4Gst.js.br +0 -0
- package/dist/web/assets/init-Gi6I4Gst.js.gz +0 -0
- package/dist/web/assets/java-CylS5w8V.js.br +0 -0
- package/dist/web/assets/java-CylS5w8V.js.gz +0 -0
- package/dist/web/assets/javascript-iXu5QeM3.js.br +0 -0
- package/dist/web/assets/javascript-iXu5QeM3.js.gz +0 -0
- package/dist/web/assets/javascript-wDzz0qaB.js.br +0 -0
- package/dist/web/assets/javascript-wDzz0qaB.js.gz +0 -0
- package/dist/web/assets/jinja-4LBKfQ-Z.js.br +0 -0
- package/dist/web/assets/jinja-4LBKfQ-Z.js.gz +0 -0
- package/dist/web/assets/jison-wvAkD_A8.js.br +0 -0
- package/dist/web/assets/jison-wvAkD_A8.js.gz +0 -0
- package/dist/web/assets/json-Cp-IABpG.js.br +0 -0
- package/dist/web/assets/json-Cp-IABpG.js.gz +0 -0
- package/dist/web/assets/json-DQCdPPbD.js +1 -0
- package/dist/web/assets/json-DQCdPPbD.js.br +0 -0
- package/dist/web/assets/json-DQCdPPbD.js.gz +0 -0
- package/dist/web/assets/json5-C9tS-k6U.js.br +0 -0
- package/dist/web/assets/json5-C9tS-k6U.js.gz +0 -0
- package/dist/web/assets/jsonc-Des-eS-w.js.br +0 -0
- package/dist/web/assets/jsonc-Des-eS-w.js.gz +0 -0
- package/dist/web/assets/jsonl-DcaNXYhu.js.br +0 -0
- package/dist/web/assets/jsonl-DcaNXYhu.js.gz +0 -0
- package/dist/web/assets/jsonnet-DFQXde-d.js.br +0 -0
- package/dist/web/assets/jsonnet-DFQXde-d.js.gz +0 -0
- package/dist/web/assets/jssm-C2t-YnRu.js.br +0 -0
- package/dist/web/assets/jssm-C2t-YnRu.js.gz +0 -0
- package/dist/web/assets/jsx-g9-lgVsj.js.br +0 -0
- package/dist/web/assets/jsx-g9-lgVsj.js.gz +0 -0
- package/dist/web/assets/julia-CxzCAyBv.js.br +0 -0
- package/dist/web/assets/julia-CxzCAyBv.js.gz +0 -0
- package/dist/web/assets/julia-DuME0IfC.js.br +0 -0
- package/dist/web/assets/julia-DuME0IfC.js.gz +0 -0
- package/dist/web/assets/just-Cw27pwNe.js.br +0 -0
- package/dist/web/assets/just-Cw27pwNe.js.gz +0 -0
- package/dist/web/assets/kanagawa-dragon-CkXjmgJE.js.br +0 -0
- package/dist/web/assets/kanagawa-dragon-CkXjmgJE.js.gz +0 -0
- package/dist/web/assets/kanagawa-lotus-CfQXZHmo.js.br +0 -0
- package/dist/web/assets/kanagawa-lotus-CfQXZHmo.js.gz +0 -0
- package/dist/web/assets/kanagawa-wave-DWedfzmr.js.br +0 -0
- package/dist/web/assets/kanagawa-wave-DWedfzmr.js.gz +0 -0
- package/dist/web/assets/katex-HP8lGamR.js.br +0 -0
- package/dist/web/assets/katex-HP8lGamR.js.gz +0 -0
- package/dist/web/assets/kdl-DV7GczEv.js.br +0 -0
- package/dist/web/assets/kdl-DV7GczEv.js.gz +0 -0
- package/dist/web/assets/kotlin-BdnUsdx6.js.br +0 -0
- package/dist/web/assets/kotlin-BdnUsdx6.js.gz +0 -0
- package/dist/web/assets/kusto-DZf3V79B.js.br +0 -0
- package/dist/web/assets/kusto-DZf3V79B.js.gz +0 -0
- package/dist/web/assets/laserwave-DUszq2jm.js.br +0 -0
- package/dist/web/assets/laserwave-DUszq2jm.js.gz +0 -0
- package/dist/web/assets/latex-CWtU0Tv5.js.br +0 -0
- package/dist/web/assets/latex-CWtU0Tv5.js.gz +0 -0
- package/dist/web/assets/layout-SsrduOYp.js.br +0 -0
- package/dist/web/assets/layout-SsrduOYp.js.gz +0 -0
- package/dist/web/assets/layoutHooks-BzE4xDdh.js +1 -0
- package/dist/web/assets/layoutHooks-BzE4xDdh.js.br +0 -0
- package/dist/web/assets/layoutHooks-BzE4xDdh.js.gz +0 -0
- package/dist/web/assets/lean-BZvkOJ9d.js.br +0 -0
- package/dist/web/assets/lean-BZvkOJ9d.js.gz +0 -0
- package/dist/web/assets/less-B1dDrJ26.js.br +0 -0
- package/dist/web/assets/less-B1dDrJ26.js.gz +0 -0
- package/dist/web/assets/light-plus-B7mTdjB0.js.br +0 -0
- package/dist/web/assets/light-plus-B7mTdjB0.js.gz +0 -0
- package/dist/web/assets/linear-8XOvhBtb.js +1 -0
- package/dist/web/assets/linear-8XOvhBtb.js.br +0 -0
- package/dist/web/assets/linear-8XOvhBtb.js.gz +0 -0
- package/dist/web/assets/liquid-DYVedYrR.js.br +0 -0
- package/dist/web/assets/liquid-DYVedYrR.js.gz +0 -0
- package/dist/web/assets/livescript-BwQOo05w.js.br +0 -0
- package/dist/web/assets/livescript-BwQOo05w.js.gz +0 -0
- package/dist/web/assets/llvm-DjAJT7YJ.js.br +0 -0
- package/dist/web/assets/llvm-DjAJT7YJ.js.gz +0 -0
- package/dist/web/assets/log-2UxHyX5q.js.br +0 -0
- package/dist/web/assets/log-2UxHyX5q.js.gz +0 -0
- package/dist/web/assets/logo-BtOb2qkB.js.br +0 -0
- package/dist/web/assets/logo-BtOb2qkB.js.gz +0 -0
- package/dist/web/assets/lua-BaeVxFsk.js.br +0 -0
- package/dist/web/assets/lua-BaeVxFsk.js.gz +0 -0
- package/dist/web/assets/lua-VAEuO923.js.br +0 -0
- package/dist/web/assets/lua-VAEuO923.js.gz +0 -0
- package/dist/web/assets/luau-C-HG3fhB.js.br +0 -0
- package/dist/web/assets/luau-C-HG3fhB.js.gz +0 -0
- package/dist/web/assets/make-CHLpvVh8.js.br +0 -0
- package/dist/web/assets/make-CHLpvVh8.js.gz +0 -0
- package/dist/web/assets/markdown-Cvjx9yec.js.br +0 -0
- package/dist/web/assets/markdown-Cvjx9yec.js.gz +0 -0
- package/dist/web/assets/marko-CnJfTvn9.js.br +0 -0
- package/dist/web/assets/marko-CnJfTvn9.js.gz +0 -0
- package/dist/web/assets/material-theme-D5KoaKCx.js.br +0 -0
- package/dist/web/assets/material-theme-D5KoaKCx.js.gz +0 -0
- package/dist/web/assets/material-theme-darker-BfHTSMKl.js.br +0 -0
- package/dist/web/assets/material-theme-darker-BfHTSMKl.js.gz +0 -0
- package/dist/web/assets/material-theme-lighter-B0m2ddpp.js.br +0 -0
- package/dist/web/assets/material-theme-lighter-B0m2ddpp.js.gz +0 -0
- package/dist/web/assets/material-theme-ocean-CyktbL80.js.br +0 -0
- package/dist/web/assets/material-theme-ocean-CyktbL80.js.gz +0 -0
- package/dist/web/assets/material-theme-palenight-Csfq5Kiy.js.br +0 -0
- package/dist/web/assets/material-theme-palenight-Csfq5Kiy.js.gz +0 -0
- package/dist/web/assets/mathematica-DTrFuWx2.js.br +0 -0
- package/dist/web/assets/mathematica-DTrFuWx2.js.gz +0 -0
- package/dist/web/assets/matlab-D7o27uSR.js.br +0 -0
- package/dist/web/assets/matlab-D7o27uSR.js.gz +0 -0
- package/dist/web/assets/mbox-CNhZ1qSd.js.br +0 -0
- package/dist/web/assets/mbox-CNhZ1qSd.js.gz +0 -0
- package/dist/web/assets/mdc-BMNejdWA.js.br +0 -0
- package/dist/web/assets/mdc-BMNejdWA.js.gz +0 -0
- package/dist/web/assets/mdx-Cmh6b_Ma.js.br +0 -0
- package/dist/web/assets/mdx-Cmh6b_Ma.js.gz +0 -0
- package/dist/web/assets/memoryAuthority-B8YSN2MI.js +1 -0
- package/dist/web/assets/memoryAuthority-B8YSN2MI.js.br +0 -0
- package/dist/web/assets/memoryAuthority-B8YSN2MI.js.gz +0 -0
- package/dist/web/assets/mermaid-GHXKKRXX-D3Z62_uv.css +1 -0
- package/dist/web/assets/mermaid-GHXKKRXX-D3Z62_uv.css.br +0 -0
- package/dist/web/assets/mermaid-GHXKKRXX-D3Z62_uv.css.gz +0 -0
- package/dist/web/assets/mermaid-GHXKKRXX-DmcDxWiS.js +190 -0
- package/dist/web/assets/mermaid-GHXKKRXX-DmcDxWiS.js.br +0 -0
- package/dist/web/assets/mermaid-GHXKKRXX-DmcDxWiS.js.gz +0 -0
- package/dist/web/assets/mermaid-engine-AE7SfXFQ.js +2547 -0
- package/dist/web/assets/mermaid-engine-AE7SfXFQ.js.br +0 -0
- package/dist/web/assets/mermaid-engine-AE7SfXFQ.js.gz +0 -0
- package/dist/web/assets/mermaid-mWjccvbQ.js.br +0 -0
- package/dist/web/assets/mermaid-mWjccvbQ.js.gz +0 -0
- package/dist/web/assets/min-dark-CafNBF8u.js.br +0 -0
- package/dist/web/assets/min-dark-CafNBF8u.js.gz +0 -0
- package/dist/web/assets/min-light-CTRr51gU.js.br +0 -0
- package/dist/web/assets/min-light-CTRr51gU.js.gz +0 -0
- package/dist/web/assets/mipsasm-CKIfxQSi.js.br +0 -0
- package/dist/web/assets/mipsasm-CKIfxQSi.js.gz +0 -0
- package/dist/web/assets/mirc-CjQqDB4T.js.br +0 -0
- package/dist/web/assets/mirc-CjQqDB4T.js.gz +0 -0
- package/dist/web/assets/mllike-CXdrOF99.js.br +0 -0
- package/dist/web/assets/mllike-CXdrOF99.js.gz +0 -0
- package/dist/web/assets/modelica-Dc1JOy9r.js.br +0 -0
- package/dist/web/assets/modelica-Dc1JOy9r.js.gz +0 -0
- package/dist/web/assets/mojo-rZm6bMo-.js.br +0 -0
- package/dist/web/assets/mojo-rZm6bMo-.js.gz +0 -0
- package/dist/web/assets/monokai-D4h5O-jR.js.br +0 -0
- package/dist/web/assets/monokai-D4h5O-jR.js.gz +0 -0
- package/dist/web/assets/moonbit-_H4v1dQx.js.br +0 -0
- package/dist/web/assets/moonbit-_H4v1dQx.js.gz +0 -0
- package/dist/web/assets/move-IF9eRakj.js.br +0 -0
- package/dist/web/assets/move-IF9eRakj.js.gz +0 -0
- package/dist/web/assets/mscgen-BA5vi2Kp.js.br +0 -0
- package/dist/web/assets/mscgen-BA5vi2Kp.js.gz +0 -0
- package/dist/web/assets/mumps-BT43cFF4.js.br +0 -0
- package/dist/web/assets/mumps-BT43cFF4.js.gz +0 -0
- package/dist/web/assets/narrat-DRg8JJMk.js.br +0 -0
- package/dist/web/assets/narrat-DRg8JJMk.js.gz +0 -0
- package/dist/web/assets/nextflow-Zz6hmt5N.js.br +0 -0
- package/dist/web/assets/nextflow-Zz6hmt5N.js.gz +0 -0
- package/dist/web/assets/nextflow-groovy-BeH2EWoN.js.br +0 -0
- package/dist/web/assets/nextflow-groovy-BeH2EWoN.js.gz +0 -0
- package/dist/web/assets/nginx-BpAMiNFr.js.br +0 -0
- package/dist/web/assets/nginx-BpAMiNFr.js.gz +0 -0
- package/dist/web/assets/nginx-DdIZxoE0.js.br +0 -0
- package/dist/web/assets/nginx-DdIZxoE0.js.gz +0 -0
- package/dist/web/assets/night-owl-C39BiMTA.js.br +0 -0
- package/dist/web/assets/night-owl-C39BiMTA.js.gz +0 -0
- package/dist/web/assets/night-owl-light-CMTm3GFP.js.br +0 -0
- package/dist/web/assets/night-owl-light-CMTm3GFP.js.gz +0 -0
- package/dist/web/assets/nim-CVrawwO9.js.br +0 -0
- package/dist/web/assets/nim-CVrawwO9.js.gz +0 -0
- package/dist/web/assets/nix-CwoSXNpI.js.br +0 -0
- package/dist/web/assets/nix-CwoSXNpI.js.gz +0 -0
- package/dist/web/assets/nord-Ddv68eIx.js.br +0 -0
- package/dist/web/assets/nord-Ddv68eIx.js.gz +0 -0
- package/dist/web/assets/nsis-LdVXkNf5.js.br +0 -0
- package/dist/web/assets/nsis-LdVXkNf5.js.gz +0 -0
- package/dist/web/assets/ntriples-BfvgReVJ.js.br +0 -0
- package/dist/web/assets/ntriples-BfvgReVJ.js.gz +0 -0
- package/dist/web/assets/nushell-Cz2AlsmD.js.br +0 -0
- package/dist/web/assets/nushell-Cz2AlsmD.js.gz +0 -0
- package/dist/web/assets/objective-c-DXmwc3jG.js.br +0 -0
- package/dist/web/assets/objective-c-DXmwc3jG.js.gz +0 -0
- package/dist/web/assets/objective-cpp-CLxacb5B.js.br +0 -0
- package/dist/web/assets/objective-cpp-CLxacb5B.js.gz +0 -0
- package/dist/web/assets/ocaml-C0hk2d4L.js.br +0 -0
- package/dist/web/assets/ocaml-C0hk2d4L.js.gz +0 -0
- package/dist/web/assets/octave-Ck1zUtKM.js.br +0 -0
- package/dist/web/assets/octave-Ck1zUtKM.js.gz +0 -0
- package/dist/web/assets/odin-BBf5iR-q.js.br +0 -0
- package/dist/web/assets/odin-BBf5iR-q.js.gz +0 -0
- package/dist/web/assets/one-dark-pro-DVMEJ2y_.js.br +0 -0
- package/dist/web/assets/one-dark-pro-DVMEJ2y_.js.gz +0 -0
- package/dist/web/assets/one-light-C3Wv6jpd.js.br +0 -0
- package/dist/web/assets/one-light-C3Wv6jpd.js.gz +0 -0
- package/dist/web/assets/openscad-C4EeE6gA.js.br +0 -0
- package/dist/web/assets/openscad-C4EeE6gA.js.gz +0 -0
- package/dist/web/assets/ordinal-Cboi1Yqb.js.br +0 -0
- package/dist/web/assets/ordinal-Cboi1Yqb.js.gz +0 -0
- package/dist/web/assets/oz-BzwKVEFT.js.br +0 -0
- package/dist/web/assets/oz-BzwKVEFT.js.gz +0 -0
- package/dist/web/assets/packs-Bee69jWU.js +1 -0
- package/dist/web/assets/packs-Bee69jWU.js.br +0 -0
- package/dist/web/assets/packs-Bee69jWU.js.gz +0 -0
- package/dist/web/assets/pascal--L3eBynH.js.br +0 -0
- package/dist/web/assets/pascal--L3eBynH.js.gz +0 -0
- package/dist/web/assets/pascal-D93ZcfNL.js.br +0 -0
- package/dist/web/assets/pascal-D93ZcfNL.js.gz +0 -0
- package/dist/web/assets/pdf-CIFzrehN.js +13 -0
- package/dist/web/assets/pdf-CIFzrehN.js.br +0 -0
- package/dist/web/assets/pdf-CIFzrehN.js.gz +0 -0
- package/dist/web/assets/perl-C0TMdlhV.js.br +0 -0
- package/dist/web/assets/perl-C0TMdlhV.js.gz +0 -0
- package/dist/web/assets/perl-CdXCOZ3F.js.br +0 -0
- package/dist/web/assets/perl-CdXCOZ3F.js.gz +0 -0
- package/dist/web/assets/php-Dhbhpdrm.js.br +0 -0
- package/dist/web/assets/php-Dhbhpdrm.js.gz +0 -0
- package/dist/web/assets/pie-DJOJsNN1.js +1 -0
- package/dist/web/assets/pie-DJOJsNN1.js.br +0 -0
- package/dist/web/assets/pie-DJOJsNN1.js.gz +0 -0
- package/dist/web/assets/pig-CevX1Tat.js.br +0 -0
- package/dist/web/assets/pig-CevX1Tat.js.gz +0 -0
- package/dist/web/assets/pkl-u5AG7uiY.js.br +0 -0
- package/dist/web/assets/pkl-u5AG7uiY.js.gz +0 -0
- package/dist/web/assets/plastic-3e1v2bzS.js.br +0 -0
- package/dist/web/assets/plastic-3e1v2bzS.js.gz +0 -0
- package/dist/web/assets/plsql-ChMvpjG-.js.br +0 -0
- package/dist/web/assets/plsql-ChMvpjG-.js.gz +0 -0
- package/dist/web/assets/po-BTJTHyun.js.br +0 -0
- package/dist/web/assets/po-BTJTHyun.js.gz +0 -0
- package/dist/web/assets/poimandres-CS3Unz2-.js.br +0 -0
- package/dist/web/assets/poimandres-CS3Unz2-.js.gz +0 -0
- package/dist/web/assets/polar-C0HS_06l.js.br +0 -0
- package/dist/web/assets/polar-C0HS_06l.js.gz +0 -0
- package/dist/web/assets/postcss-CXtECtnM.js.br +0 -0
- package/dist/web/assets/postcss-CXtECtnM.js.gz +0 -0
- package/dist/web/assets/powerquery-CEu0bR-o.js.br +0 -0
- package/dist/web/assets/powerquery-CEu0bR-o.js.gz +0 -0
- package/dist/web/assets/powershell-CFHJl5sT.js.br +0 -0
- package/dist/web/assets/powershell-CFHJl5sT.js.gz +0 -0
- package/dist/web/assets/powershell-Dpen1YoG.js.br +0 -0
- package/dist/web/assets/powershell-Dpen1YoG.js.gz +0 -0
- package/dist/web/assets/prisma-Dd19v3D-.js.br +0 -0
- package/dist/web/assets/prisma-Dd19v3D-.js.gz +0 -0
- package/dist/web/assets/prolog-CbFg5uaA.js.br +0 -0
- package/dist/web/assets/prolog-CbFg5uaA.js.gz +0 -0
- package/dist/web/assets/properties-C78fOPTZ.js.br +0 -0
- package/dist/web/assets/properties-C78fOPTZ.js.gz +0 -0
- package/dist/web/assets/proto-C7zT0LnQ.js.br +0 -0
- package/dist/web/assets/proto-C7zT0LnQ.js.gz +0 -0
- package/dist/web/assets/protobuf-ChK-085T.js.br +0 -0
- package/dist/web/assets/protobuf-ChK-085T.js.gz +0 -0
- package/dist/web/assets/pug-CGlum2m_.js.br +0 -0
- package/dist/web/assets/pug-CGlum2m_.js.gz +0 -0
- package/dist/web/assets/pug-DeIclll2.js.br +0 -0
- package/dist/web/assets/pug-DeIclll2.js.gz +0 -0
- package/dist/web/assets/puppet-BMWR74SV.js.br +0 -0
- package/dist/web/assets/puppet-BMWR74SV.js.gz +0 -0
- package/dist/web/assets/puppet-DMA9R1ak.js.br +0 -0
- package/dist/web/assets/puppet-DMA9R1ak.js.gz +0 -0
- package/dist/web/assets/purescript-CklMAg4u.js.br +0 -0
- package/dist/web/assets/purescript-CklMAg4u.js.gz +0 -0
- package/dist/web/assets/python-B6aJPvgy.js.br +0 -0
- package/dist/web/assets/python-B6aJPvgy.js.gz +0 -0
- package/dist/web/assets/python-BuPzkPfP.js.br +0 -0
- package/dist/web/assets/python-BuPzkPfP.js.gz +0 -0
- package/dist/web/assets/q-pXgVlZs6.js.br +0 -0
- package/dist/web/assets/q-pXgVlZs6.js.gz +0 -0
- package/dist/web/assets/qml-3beO22l8.js.br +0 -0
- package/dist/web/assets/qml-3beO22l8.js.gz +0 -0
- package/dist/web/assets/qmldir-C8lEn-DE.js.br +0 -0
- package/dist/web/assets/qmldir-C8lEn-DE.js.gz +0 -0
- package/dist/web/assets/qss-IeuSbFQv.js.br +0 -0
- package/dist/web/assets/qss-IeuSbFQv.js.gz +0 -0
- package/dist/web/assets/r-B6wPVr8A.js.br +0 -0
- package/dist/web/assets/r-B6wPVr8A.js.gz +0 -0
- package/dist/web/assets/r-Dspwwk_N.js.br +0 -0
- package/dist/web/assets/r-Dspwwk_N.js.gz +0 -0
- package/dist/web/assets/racket-BqYA7rlc.js.br +0 -0
- package/dist/web/assets/racket-BqYA7rlc.js.gz +0 -0
- package/dist/web/assets/raku-DXvB9xmW.js.br +0 -0
- package/dist/web/assets/raku-DXvB9xmW.js.gz +0 -0
- package/dist/web/assets/razor-Uh8Bk_45.js.br +0 -0
- package/dist/web/assets/razor-Uh8Bk_45.js.gz +0 -0
- package/dist/web/assets/red-bN70gL4F.js.br +0 -0
- package/dist/web/assets/red-bN70gL4F.js.gz +0 -0
- package/dist/web/assets/reg-C-SQnVFl.js.br +0 -0
- package/dist/web/assets/reg-C-SQnVFl.js.gz +0 -0
- package/dist/web/assets/regexp-CDVJQ6XC.js.br +0 -0
- package/dist/web/assets/regexp-CDVJQ6XC.js.gz +0 -0
- package/dist/web/assets/rel-C3B-1QV4.js.br +0 -0
- package/dist/web/assets/rel-C3B-1QV4.js.gz +0 -0
- package/dist/web/assets/riscv-BM1_JUlF.js.br +0 -0
- package/dist/web/assets/riscv-BM1_JUlF.js.gz +0 -0
- package/dist/web/assets/ron-D8l8udqQ.js.br +0 -0
- package/dist/web/assets/ron-D8l8udqQ.js.gz +0 -0
- package/dist/web/assets/rose-pine-dawn-DHQR4-dF.js.br +0 -0
- package/dist/web/assets/rose-pine-dawn-DHQR4-dF.js.gz +0 -0
- package/dist/web/assets/rose-pine-moon-D4_iv3hh.js.br +0 -0
- package/dist/web/assets/rose-pine-moon-D4_iv3hh.js.gz +0 -0
- package/dist/web/assets/rose-pine-qdsjHGoJ.js.br +0 -0
- package/dist/web/assets/rose-pine-qdsjHGoJ.js.gz +0 -0
- package/dist/web/assets/rosmsg-BJDFO7_C.js.br +0 -0
- package/dist/web/assets/rosmsg-BJDFO7_C.js.gz +0 -0
- package/dist/web/assets/rpm-CTu-6PCP.js.br +0 -0
- package/dist/web/assets/rpm-CTu-6PCP.js.gz +0 -0
- package/dist/web/assets/rst-BrH8l1NY.js.br +0 -0
- package/dist/web/assets/rst-BrH8l1NY.js.gz +0 -0
- package/dist/web/assets/ruby-B2Rjki9n.js.br +0 -0
- package/dist/web/assets/ruby-B2Rjki9n.js.gz +0 -0
- package/dist/web/assets/ruby-Dw2BHqvy.js.br +0 -0
- package/dist/web/assets/ruby-Dw2BHqvy.js.gz +0 -0
- package/dist/web/assets/rust-B1yitclQ.js.br +0 -0
- package/dist/web/assets/rust-B1yitclQ.js.gz +0 -0
- package/dist/web/assets/sankeyLinkHorizontal-FH_jDQz2.js +1 -0
- package/dist/web/assets/sankeyLinkHorizontal-FH_jDQz2.js.br +0 -0
- package/dist/web/assets/sankeyLinkHorizontal-FH_jDQz2.js.gz +0 -0
- package/dist/web/assets/sas-B4kiWyti.js.br +0 -0
- package/dist/web/assets/sas-B4kiWyti.js.gz +0 -0
- package/dist/web/assets/sas-cz2c8ADy.js.br +0 -0
- package/dist/web/assets/sas-cz2c8ADy.js.gz +0 -0
- package/dist/web/assets/sass-Cj5Yp3dK.js.br +0 -0
- package/dist/web/assets/sass-Cj5Yp3dK.js.gz +0 -0
- package/dist/web/assets/scala-C151Ov-r.js.br +0 -0
- package/dist/web/assets/scala-C151Ov-r.js.gz +0 -0
- package/dist/web/assets/scheme-C41bIUwD.js.br +0 -0
- package/dist/web/assets/scheme-C41bIUwD.js.gz +0 -0
- package/dist/web/assets/scheme-C98Dy4si.js.br +0 -0
- package/dist/web/assets/scheme-C98Dy4si.js.gz +0 -0
- package/dist/web/assets/scss-OYdSNvt2.js.br +0 -0
- package/dist/web/assets/scss-OYdSNvt2.js.gz +0 -0
- package/dist/web/assets/sdbl-DVxCFoDh.js.br +0 -0
- package/dist/web/assets/sdbl-DVxCFoDh.js.gz +0 -0
- package/dist/web/assets/shaderlab-Dg9Lc6iA.js.br +0 -0
- package/dist/web/assets/shaderlab-Dg9Lc6iA.js.gz +0 -0
- package/dist/web/assets/shell-CjFT_Tl9.js.br +0 -0
- package/dist/web/assets/shell-CjFT_Tl9.js.gz +0 -0
- package/dist/web/assets/shellscript-Yzrsuije.js.br +0 -0
- package/dist/web/assets/shellscript-Yzrsuije.js.gz +0 -0
- package/dist/web/assets/shellsession-BADoaaVG.js.br +0 -0
- package/dist/web/assets/shellsession-BADoaaVG.js.gz +0 -0
- package/dist/web/assets/sieve-C3Gn_uJK.js.br +0 -0
- package/dist/web/assets/sieve-C3Gn_uJK.js.gz +0 -0
- package/dist/web/assets/simple-mode-GW_nhZxv.js.br +0 -0
- package/dist/web/assets/simple-mode-GW_nhZxv.js.gz +0 -0
- package/dist/web/assets/slack-dark-BthQWCQV.js.br +0 -0
- package/dist/web/assets/slack-dark-BthQWCQV.js.gz +0 -0
- package/dist/web/assets/slack-ochin-DqwNpetd.js.br +0 -0
- package/dist/web/assets/slack-ochin-DqwNpetd.js.gz +0 -0
- package/dist/web/assets/smalltalk-BERRCDM3.js.br +0 -0
- package/dist/web/assets/smalltalk-BERRCDM3.js.gz +0 -0
- package/dist/web/assets/smalltalk-CnHTOXQT.js.br +0 -0
- package/dist/web/assets/smalltalk-CnHTOXQT.js.gz +0 -0
- package/dist/web/assets/snazzy-light-Bw305WKR.js.br +0 -0
- package/dist/web/assets/snazzy-light-Bw305WKR.js.gz +0 -0
- package/dist/web/assets/solarized-dark-DXbdFlpD.js.br +0 -0
- package/dist/web/assets/solarized-dark-DXbdFlpD.js.gz +0 -0
- package/dist/web/assets/solarized-light-L9t79GZl.js.br +0 -0
- package/dist/web/assets/solarized-light-L9t79GZl.js.gz +0 -0
- package/dist/web/assets/solidity-rGO070M0.js.br +0 -0
- package/dist/web/assets/solidity-rGO070M0.js.gz +0 -0
- package/dist/web/assets/solr-DehyRSwq.js.br +0 -0
- package/dist/web/assets/solr-DehyRSwq.js.gz +0 -0
- package/dist/web/assets/soy-Brmx7dQM.js.br +0 -0
- package/dist/web/assets/soy-Brmx7dQM.js.gz +0 -0
- package/dist/web/assets/spaces-wH3o95f_.js +1 -0
- package/dist/web/assets/spaces-wH3o95f_.js.br +0 -0
- package/dist/web/assets/spaces-wH3o95f_.js.gz +0 -0
- package/dist/web/assets/sparql-DkYu6x3z.js.br +0 -0
- package/dist/web/assets/sparql-DkYu6x3z.js.gz +0 -0
- package/dist/web/assets/sparql-rVzFXLq3.js.br +0 -0
- package/dist/web/assets/sparql-rVzFXLq3.js.gz +0 -0
- package/dist/web/assets/splunk-BtCnVYZw.js.br +0 -0
- package/dist/web/assets/splunk-BtCnVYZw.js.gz +0 -0
- package/dist/web/assets/spreadsheet-BCZA_wO0.js.br +0 -0
- package/dist/web/assets/spreadsheet-BCZA_wO0.js.gz +0 -0
- package/dist/web/assets/sql-BLtJtn59.js.br +0 -0
- package/dist/web/assets/sql-BLtJtn59.js.gz +0 -0
- package/dist/web/assets/sql-D0XecflT.js.br +0 -0
- package/dist/web/assets/sql-D0XecflT.js.gz +0 -0
- package/dist/web/assets/ssh-config-_ykCGR6B.js.br +0 -0
- package/dist/web/assets/ssh-config-_ykCGR6B.js.gz +0 -0
- package/dist/web/assets/stata-BH5u7GGu.js.br +0 -0
- package/dist/web/assets/stata-BH5u7GGu.js.gz +0 -0
- package/dist/web/assets/stex-C3f8Ysf7.js.br +0 -0
- package/dist/web/assets/stex-C3f8Ysf7.js.gz +0 -0
- package/dist/web/assets/stylus-B533Al4x.js.br +0 -0
- package/dist/web/assets/stylus-B533Al4x.js.gz +0 -0
- package/dist/web/assets/stylus-BEDo0Tqx.js.br +0 -0
- package/dist/web/assets/stylus-BEDo0Tqx.js.gz +0 -0
- package/dist/web/assets/surrealql-Bq5Q-fJD.js.br +0 -0
- package/dist/web/assets/surrealql-Bq5Q-fJD.js.gz +0 -0
- package/dist/web/assets/svelte-C_ipcX3V.js.br +0 -0
- package/dist/web/assets/svelte-C_ipcX3V.js.gz +0 -0
- package/dist/web/assets/swift-BzpIVaGY.js.br +0 -0
- package/dist/web/assets/swift-BzpIVaGY.js.gz +0 -0
- package/dist/web/assets/swift-D82vCrfD.js.br +0 -0
- package/dist/web/assets/swift-D82vCrfD.js.gz +0 -0
- package/dist/web/assets/synthwave-84-CbfX1IO0.js.br +0 -0
- package/dist/web/assets/synthwave-84-CbfX1IO0.js.gz +0 -0
- package/dist/web/assets/system-verilog-CnnmHF94.js.br +0 -0
- package/dist/web/assets/system-verilog-CnnmHF94.js.gz +0 -0
- package/dist/web/assets/systemd-4A_iFExJ.js.br +0 -0
- package/dist/web/assets/systemd-4A_iFExJ.js.gz +0 -0
- package/dist/web/assets/talonscript-CkByrt1z.js.br +0 -0
- package/dist/web/assets/talonscript-CkByrt1z.js.gz +0 -0
- package/dist/web/assets/tasl-QIJgUcNo.js.br +0 -0
- package/dist/web/assets/tasl-QIJgUcNo.js.gz +0 -0
- package/dist/web/assets/tcl-DVfN8rqt.js.br +0 -0
- package/dist/web/assets/tcl-DVfN8rqt.js.gz +0 -0
- package/dist/web/assets/tcl-dwOrl1Do.js.br +0 -0
- package/dist/web/assets/tcl-dwOrl1Do.js.gz +0 -0
- package/dist/web/assets/templ-P3uqSqPl.js.br +0 -0
- package/dist/web/assets/templ-P3uqSqPl.js.gz +0 -0
- package/dist/web/assets/terraform-BETggiCN.js.br +0 -0
- package/dist/web/assets/terraform-BETggiCN.js.gz +0 -0
- package/dist/web/assets/tex-idrVyKtj.js.br +0 -0
- package/dist/web/assets/tex-idrVyKtj.js.gz +0 -0
- package/dist/web/assets/textile-CnDTJFAw.js.br +0 -0
- package/dist/web/assets/textile-CnDTJFAw.js.gz +0 -0
- package/dist/web/assets/theme-DVIt3W-5.js +1 -0
- package/dist/web/assets/theme-DVIt3W-5.js.br +0 -0
- package/dist/web/assets/theme-DVIt3W-5.js.gz +0 -0
- package/dist/web/assets/tiddlywiki-DO-Gjzrf.js.br +0 -0
- package/dist/web/assets/tiddlywiki-DO-Gjzrf.js.gz +0 -0
- package/dist/web/assets/tiki-DGYXhP31.js.br +0 -0
- package/dist/web/assets/tiki-DGYXhP31.js.gz +0 -0
- package/dist/web/assets/tokyo-night-hegEt444.js.br +0 -0
- package/dist/web/assets/tokyo-night-hegEt444.js.gz +0 -0
- package/dist/web/assets/toml-Bm5Em-hy.js.br +0 -0
- package/dist/web/assets/toml-Bm5Em-hy.js.gz +0 -0
- package/dist/web/assets/toml-vGWfd6FD.js.br +0 -0
- package/dist/web/assets/toml-vGWfd6FD.js.gz +0 -0
- package/dist/web/assets/troff-wAsdV37c.js.br +0 -0
- package/dist/web/assets/troff-wAsdV37c.js.gz +0 -0
- package/dist/web/assets/ts-tags-zn1MmPIZ.js.br +0 -0
- package/dist/web/assets/ts-tags-zn1MmPIZ.js.gz +0 -0
- package/dist/web/assets/tsv-B_m7g4N7.js.br +0 -0
- package/dist/web/assets/tsv-B_m7g4N7.js.gz +0 -0
- package/dist/web/assets/tsx-COt5Ahok.js.br +0 -0
- package/dist/web/assets/tsx-COt5Ahok.js.gz +0 -0
- package/dist/web/assets/ttcn-CfJYG6tj.js.br +0 -0
- package/dist/web/assets/ttcn-CfJYG6tj.js.gz +0 -0
- package/dist/web/assets/ttcn-cfg-B9xdYoR4.js.br +0 -0
- package/dist/web/assets/ttcn-cfg-B9xdYoR4.js.gz +0 -0
- package/dist/web/assets/turtle-B1tBg_DP.js.br +0 -0
- package/dist/web/assets/turtle-B1tBg_DP.js.gz +0 -0
- package/dist/web/assets/turtle-BsS91CYL.js.br +0 -0
- package/dist/web/assets/turtle-BsS91CYL.js.gz +0 -0
- package/dist/web/assets/twig-DNn4PbVi.js.br +0 -0
- package/dist/web/assets/twig-DNn4PbVi.js.gz +0 -0
- package/dist/web/assets/typescript-BPQ3VLAy.js.br +0 -0
- package/dist/web/assets/typescript-BPQ3VLAy.js.gz +0 -0
- package/dist/web/assets/typespec-BGHnOYBU.js.br +0 -0
- package/dist/web/assets/typespec-BGHnOYBU.js.gz +0 -0
- package/dist/web/assets/typst-DHCkPAjA.js.br +0 -0
- package/dist/web/assets/typst-DHCkPAjA.js.gz +0 -0
- package/dist/web/assets/uiZoom-CfR9h3Dy.js +1 -0
- package/dist/web/assets/uiZoom-CfR9h3Dy.js.br +0 -0
- package/dist/web/assets/uiZoom-CfR9h3Dy.js.gz +0 -0
- package/dist/web/assets/v-BcVCzyr7.js.br +0 -0
- package/dist/web/assets/v-BcVCzyr7.js.gz +0 -0
- package/dist/web/assets/v4-Dnyct6Ft.js +1 -0
- package/dist/web/assets/v4-Dnyct6Ft.js.br +0 -0
- package/dist/web/assets/v4-Dnyct6Ft.js.gz +0 -0
- package/dist/web/assets/vala-CsfeWuGM.js.br +0 -0
- package/dist/web/assets/vala-CsfeWuGM.js.gz +0 -0
- package/dist/web/assets/vb-CmGdzxic.js.br +0 -0
- package/dist/web/assets/vb-CmGdzxic.js.gz +0 -0
- package/dist/web/assets/vb-D17OF-Vu.js.br +0 -0
- package/dist/web/assets/vb-D17OF-Vu.js.gz +0 -0
- package/dist/web/assets/vbscript-BuJXcnF6.js.br +0 -0
- package/dist/web/assets/vbscript-BuJXcnF6.js.gz +0 -0
- package/dist/web/assets/velocity-D8B20fx6.js.br +0 -0
- package/dist/web/assets/velocity-D8B20fx6.js.gz +0 -0
- package/dist/web/assets/vendor-react-BqVzR-It.js +61 -0
- package/dist/web/assets/vendor-react-BqVzR-It.js.br +0 -0
- package/dist/web/assets/vendor-react-BqVzR-It.js.gz +0 -0
- package/dist/web/assets/venn.esm-D6tdiC58.js +7 -0
- package/dist/web/assets/venn.esm-D6tdiC58.js.br +0 -0
- package/dist/web/assets/venn.esm-D6tdiC58.js.gz +0 -0
- package/dist/web/assets/verilog-BQ8w6xss.js.br +0 -0
- package/dist/web/assets/verilog-BQ8w6xss.js.gz +0 -0
- package/dist/web/assets/verilog-C6RDOZhf.js.br +0 -0
- package/dist/web/assets/verilog-C6RDOZhf.js.gz +0 -0
- package/dist/web/assets/vesper-DU1UobuO.js.br +0 -0
- package/dist/web/assets/vesper-DU1UobuO.js.gz +0 -0
- package/dist/web/assets/vhdl-CeAyd5Ju.js.br +0 -0
- package/dist/web/assets/vhdl-CeAyd5Ju.js.gz +0 -0
- package/dist/web/assets/vhdl-lSbBsy5d.js.br +0 -0
- package/dist/web/assets/vhdl-lSbBsy5d.js.gz +0 -0
- package/dist/web/assets/viml-CJc9bBzg.js.br +0 -0
- package/dist/web/assets/viml-CJc9bBzg.js.gz +0 -0
- package/dist/web/assets/vitesse-black-Bkuqu6BP.js.br +0 -0
- package/dist/web/assets/vitesse-black-Bkuqu6BP.js.gz +0 -0
- package/dist/web/assets/vitesse-dark-D0r3Knsf.js.br +0 -0
- package/dist/web/assets/vitesse-dark-D0r3Knsf.js.gz +0 -0
- package/dist/web/assets/vitesse-light-CVO1_9PV.js.br +0 -0
- package/dist/web/assets/vitesse-light-CVO1_9PV.js.gz +0 -0
- package/dist/web/assets/vue-DN_0RTcg.js.br +0 -0
- package/dist/web/assets/vue-DN_0RTcg.js.gz +0 -0
- package/dist/web/assets/vue-html-AaS7Mt5G.js.br +0 -0
- package/dist/web/assets/vue-html-AaS7Mt5G.js.gz +0 -0
- package/dist/web/assets/vue-vine-CQOfvN7w.js.br +0 -0
- package/dist/web/assets/vue-vine-CQOfvN7w.js.gz +0 -0
- package/dist/web/assets/vyper-CDx5xZoG.js.br +0 -0
- package/dist/web/assets/vyper-CDx5xZoG.js.gz +0 -0
- package/dist/web/assets/{wardley-L42UT6IY-Bp3q2izt.js → wardley-L42UT6IY-CptWIPkK.js} +1 -1
- package/dist/web/assets/wardley-L42UT6IY-CptWIPkK.js.br +0 -0
- package/dist/web/assets/wardley-L42UT6IY-CptWIPkK.js.gz +0 -0
- package/dist/web/assets/wasm-CG6Dc4jp.js.br +0 -0
- package/dist/web/assets/wasm-CG6Dc4jp.js.gz +0 -0
- package/dist/web/assets/wasm-MzD3tlZU.js.br +0 -0
- package/dist/web/assets/wasm-MzD3tlZU.js.gz +0 -0
- package/dist/web/assets/webidl-ZXfAyPTL.js.br +0 -0
- package/dist/web/assets/webidl-ZXfAyPTL.js.gz +0 -0
- package/dist/web/assets/wenyan-BV7otONQ.js.br +0 -0
- package/dist/web/assets/wenyan-BV7otONQ.js.gz +0 -0
- package/dist/web/assets/wgsl-Dx-B1_4e.js.br +0 -0
- package/dist/web/assets/wgsl-Dx-B1_4e.js.gz +0 -0
- package/dist/web/assets/wikitext-BhOHFoWU.js.br +0 -0
- package/dist/web/assets/wikitext-BhOHFoWU.js.gz +0 -0
- package/dist/web/assets/wit-5i3qLPDT.js.br +0 -0
- package/dist/web/assets/wit-5i3qLPDT.js.gz +0 -0
- package/dist/web/assets/wolfram-lXgVvXCa.js.br +0 -0
- package/dist/web/assets/wolfram-lXgVvXCa.js.gz +0 -0
- package/dist/web/assets/xml-sdJ4AIDG.js.br +0 -0
- package/dist/web/assets/xml-sdJ4AIDG.js.gz +0 -0
- package/dist/web/assets/xquery-DzFWVndE.js.br +0 -0
- package/dist/web/assets/xquery-DzFWVndE.js.gz +0 -0
- package/dist/web/assets/xsl-CtQFsRM5.js.br +0 -0
- package/dist/web/assets/xsl-CtQFsRM5.js.gz +0 -0
- package/dist/web/assets/yacas-BJ4BC0dw.js.br +0 -0
- package/dist/web/assets/yacas-BJ4BC0dw.js.gz +0 -0
- package/dist/web/assets/yaml-Buea-lGh.js.br +0 -0
- package/dist/web/assets/yaml-Buea-lGh.js.gz +0 -0
- package/dist/web/assets/z80-Hz9HOZM7.js.br +0 -0
- package/dist/web/assets/z80-Hz9HOZM7.js.gz +0 -0
- package/dist/web/assets/zenscript-DVFEvuxE.js.br +0 -0
- package/dist/web/assets/zenscript-DVFEvuxE.js.gz +0 -0
- package/dist/web/assets/zig-VOosw3JB.js.br +0 -0
- package/dist/web/assets/zig-VOosw3JB.js.gz +0 -0
- package/dist/web/index.html +12 -17
- package/dist/web/index.html.br +0 -0
- package/dist/web/index.html.gz +0 -0
- package/dist/web/pdfjs/pdf.worker.min.mjs +1 -1
- package/dist/web/pdfjs/pdf.worker.min.mjs.br +0 -0
- package/dist/web/pdfjs/pdf.worker.min.mjs.gz +0 -0
- package/dist/web/theme-boot.js +20 -0
- package/dist/web/theme-boot.js.br +0 -0
- package/dist/web/theme-boot.js.gz +0 -0
- package/native/auth-native/index.cjs +6 -0
- package/native/auth-native/index.d.ts +14 -0
- package/native/auth-native/package.json +1 -2
- package/native/auth-native/prebuilds/darwin-arm64/auth-native.node +0 -0
- package/native/auth-native/prebuilds/darwin-x64/auth-native.node +0 -0
- package/native/auth-native/prebuilds/linux-arm64/auth-native.node +0 -0
- package/native/auth-native/prebuilds/linux-x64/auth-native.node +0 -0
- package/native/auth-native/prebuilds/win32-arm64/auth-native.node +0 -0
- package/native/auth-native/prebuilds/win32-x64/auth-native.node +0 -0
- package/package.json +1 -1
- package/dist/web/assets/AppErrorBoundary-B5Fc4f6-.js +0 -1
- package/dist/web/assets/NavScopeBoundary-C7MnGQio.js +0 -1
- package/dist/web/assets/arc-DGB9OVgQ.js +0 -1
- package/dist/web/assets/architectureDiagram-3BPJPVTR-glnQCMub.js +0 -36
- package/dist/web/assets/blockDiagram-GPEHLZMM-bM0tnGby.js +0 -132
- package/dist/web/assets/c4Diagram-AAUBKEIU-DMf_rTtt.js +0 -10
- package/dist/web/assets/channel-Cj8SKJ38.js +0 -1
- package/dist/web/assets/chunk-2J33WTMH-mTccJ3tW.js +0 -1
- package/dist/web/assets/chunk-4BX2VUAB-DhqPYMjY.js +0 -1
- package/dist/web/assets/chunk-55IACEB6-BujrYRoO.js +0 -1
- package/dist/web/assets/chunk-727SXJPM-ciMmSI4G.js +0 -206
- package/dist/web/assets/chunk-AQP2D5EJ-CZW9pKTc.js +0 -231
- package/dist/web/assets/chunk-FMBD7UC4-hdALNnnU.js +0 -15
- package/dist/web/assets/chunk-ND2GUHAM-CgKyqUdb.js +0 -1
- package/dist/web/assets/chunk-QZHKN3VN-B2mmUz_E.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-f8V9p-dD.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-f8V9p-dD.js +0 -1
- package/dist/web/assets/client-ClWQBErG.js +0 -3
- package/dist/web/assets/connection-C0J3BPgk.js +0 -1
- package/dist/web/assets/cose-bilkent-S5V4N54A-UV3uPjkK.js +0 -1
- package/dist/web/assets/dagre-BM42HDAG-Zjy-gQ6C.js +0 -4
- package/dist/web/assets/diagram-2AECGRRQ-DL-kilIf.js +0 -43
- package/dist/web/assets/diagram-5GNKFQAL-CjB_xR5B.js +0 -10
- package/dist/web/assets/diagram-KO2AKTUF-CjN4i3b9.js +0 -3
- package/dist/web/assets/diagram-LMA3HP47-CPCAMndo.js +0 -24
- package/dist/web/assets/diagram-OG6HWLK6-DVeBWBKd.js +0 -24
- package/dist/web/assets/erDiagram-TEJ5UH35-CHKzBHrr.js +0 -85
- package/dist/web/assets/export-CXoWon32.js +0 -2
- package/dist/web/assets/flowDiagram-I6XJVG4X-C5rQa2pq.js +0 -162
- package/dist/web/assets/ganttDiagram-6RSMTGT7-BrLjEsNJ.js +0 -292
- package/dist/web/assets/gitGraphDiagram-PVQCEYII-3DRR5VZj.js +0 -106
- package/dist/web/assets/highlighted-body-OFNGDK62-Bdj5SJfv.js +0 -1
- package/dist/web/assets/index-2Vx5mHRn.js +0 -1
- package/dist/web/assets/index-B1UXw2C9.js +0 -1
- package/dist/web/assets/index-BJxtlf4P.js +0 -309
- package/dist/web/assets/index-BY7jPurv.js +0 -1
- package/dist/web/assets/index-Bq79v-Sa.js +0 -1
- package/dist/web/assets/index-BqD3iTIl.js +0 -1
- package/dist/web/assets/index-C62wjCF_.js +0 -1
- package/dist/web/assets/index-CG9e6lgq.js +0 -1
- package/dist/web/assets/index-CS4xJLZV.js +0 -1
- package/dist/web/assets/index-CprdjRRk.js +0 -13
- package/dist/web/assets/index-CypTtrCB.js +0 -1
- package/dist/web/assets/index-DDJQGcUL.js +0 -1
- package/dist/web/assets/index-DLWzxUOO.js +0 -1
- package/dist/web/assets/index-DQxkxZmn.js +0 -7
- package/dist/web/assets/index-De_LkTZx.js +0 -1
- package/dist/web/assets/index-DpcWEDhW.js +0 -1
- package/dist/web/assets/index-Dqq1RDP4.js +0 -1
- package/dist/web/assets/index-H1uMvIoa.css +0 -1
- package/dist/web/assets/index-ICHWJ2SM.js +0 -1
- package/dist/web/assets/index-O5fSd569.js +0 -229
- package/dist/web/assets/index-odjtqLLS.js +0 -1
- package/dist/web/assets/index-v_yAQ0Am.js +0 -1
- package/dist/web/assets/infoDiagram-5YYISTIA-CCwV4Z0v.js +0 -2
- package/dist/web/assets/ishikawaDiagram-YF4QCWOH-BwwZcGyZ.js +0 -70
- package/dist/web/assets/journeyDiagram-JHISSGLW-Dc6WqniQ.js +0 -139
- package/dist/web/assets/kanban-definition-UN3LZRKU-DVUqULOS.js +0 -89
- package/dist/web/assets/linear-d6rWsNOU.js +0 -1
- package/dist/web/assets/memoryAdvisor-DBQXJB1o.js +0 -1
- package/dist/web/assets/mermaid-GHXKKRXX-Ik6SkVDT.js +0 -642
- package/dist/web/assets/mindmap-definition-RKZ34NQL-_JHAkhHL.js +0 -96
- package/dist/web/assets/navViewState-DaCMIYWA.js +0 -1
- package/dist/web/assets/pdf-C-olXVQ4.js +0 -12
- package/dist/web/assets/pieDiagram-4H26LBE5-BlhlygGy.js +0 -30
- package/dist/web/assets/quadrantDiagram-W4KKPZXB-jn6R_C0S.js +0 -7
- package/dist/web/assets/requirementDiagram-4Y6WPE33-B9fXCHBr.js +0 -84
- package/dist/web/assets/sankeyDiagram-5OEKKPKP-fPJwIxkl.js +0 -40
- package/dist/web/assets/sequenceDiagram-3UESZ5HK-1v1DTNGt.js +0 -162
- package/dist/web/assets/spaces-CvL2DRZM.js +0 -1
- package/dist/web/assets/stateDiagram-AJRCARHV-CEc_PLov.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-iAMctzaT.js +0 -1
- package/dist/web/assets/theme-LRSmy8mD.js +0 -1
- package/dist/web/assets/timeline-definition-PNZ67QCA-CEjhuitj.js +0 -120
- package/dist/web/assets/vennDiagram-CIIHVFJN-CActt9h9.js +0 -34
- package/dist/web/assets/wardleyDiagram-YWT4CUSO-C_zutiQ2.js +0 -78
- package/dist/web/assets/xychartDiagram-2RQKCTM6-CRafvv33.js +0 -7
|
@@ -1,889 +1,3891 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
/* oxlint-disable */
|
|
2
|
+
// Denial accounting, step usage and subagent projection are adapted from Paseo (Apache-2.0).
|
|
3
|
+
// Copyright (c) 2025-present Mohamed Boudra. Modified for Kiki's ACP bridge; see packages/acp-client/THIRD_PARTY_NOTICES.md.
|
|
4
|
+
import { isAbsolute, resolve } from "node:path";
|
|
5
|
+
import { Readable, Writable } from "node:stream";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
import { AGY_COMMAND_GUIDANCE_HOOK_KEY, AGY_STEERING_HOOK_KEY, recoverProjectHook, registerProjectHook } from "./agy-hook-registration.mjs";
|
|
8
|
+
import { recoverDeadProjectMcpPlugins, recoverProjectMcpPlugin, registerProjectMcpPlugin } from "./agy-mcp-plugin.mjs";
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
11
|
+
import { appendFile, mkdir, open, readFile, readdir, rename, stat, truncate, unlink, writeFile } from "node:fs/promises";
|
|
12
|
+
import { homedir } from "node:os";
|
|
13
|
+
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
14
|
+
import { openPermissionChannel, permissionChannelIdentity, requestHookPermission } from "./agy-permission-hook.mjs";
|
|
15
|
+
import { createReadStream } from "node:fs";
|
|
12
16
|
|
|
17
|
+
//#region src/auditLog.ts
|
|
18
|
+
const AUDIT_DEFAULT_MAX_BYTES = 2 * 1024 * 1024;
|
|
19
|
+
const AUDIT_TAIL_FRAME_RECORDS = 200;
|
|
20
|
+
const AUDIT_RETENTION_MS = 720 * 60 * 60 * 1e3;
|
|
21
|
+
const HIGH_FREQ_FRAME_TYPES = new Set(["native_frame_received", "native_frame_delivered"]);
|
|
22
|
+
async function readAuditFile(auditPath, options = {}) {
|
|
23
|
+
const maxBytes = options.maxBytes ?? 2097152;
|
|
24
|
+
const tailFrameLimit = options.tailFrameLimit ?? 200;
|
|
25
|
+
const warn = options.warn ?? ((message) => {
|
|
26
|
+
process.stderr.write(`[agy-cli-acp] ${message}\n`);
|
|
27
|
+
});
|
|
28
|
+
const info = await stat(auditPath);
|
|
29
|
+
const compactMode = info.size > maxBytes;
|
|
30
|
+
const keptState = [];
|
|
31
|
+
const keptFrames = [];
|
|
32
|
+
let order = 0;
|
|
33
|
+
let pendingMalformed;
|
|
34
|
+
let validByteOffset = 0;
|
|
35
|
+
let currentByteOffset = 0;
|
|
36
|
+
let carry = "";
|
|
37
|
+
let hadTruncatedTail = false;
|
|
38
|
+
let truncateToOffset = info.size;
|
|
39
|
+
const pushRecord = (record) => {
|
|
40
|
+
const entry = {
|
|
41
|
+
order: order++,
|
|
42
|
+
record
|
|
43
|
+
};
|
|
44
|
+
if (compactMode && HIGH_FREQ_FRAME_TYPES.has(record.type)) {
|
|
45
|
+
keptFrames.push(entry);
|
|
46
|
+
if (keptFrames.length > tailFrameLimit) keptFrames.shift();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
keptState.push(entry);
|
|
50
|
+
};
|
|
51
|
+
const processLine = (rawLine, lineBytes, terminatedByNewline) => {
|
|
52
|
+
const trimmed = rawLine.trim();
|
|
53
|
+
if (trimmed.length === 0) {
|
|
54
|
+
if (pendingMalformed === void 0 && terminatedByNewline) validByteOffset = currentByteOffset + lineBytes;
|
|
55
|
+
currentByteOffset += lineBytes;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (pendingMalformed !== void 0) throw pendingMalformed.error;
|
|
59
|
+
let parsed;
|
|
60
|
+
try {
|
|
61
|
+
parsed = JSON.parse(trimmed);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
pendingMalformed = {
|
|
64
|
+
error,
|
|
65
|
+
validByteOffset
|
|
66
|
+
};
|
|
67
|
+
currentByteOffset += lineBytes;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
pushRecord(parsed);
|
|
71
|
+
currentByteOffset += lineBytes;
|
|
72
|
+
validByteOffset = currentByteOffset;
|
|
73
|
+
};
|
|
74
|
+
await new Promise((resolveStream, rejectStream) => {
|
|
75
|
+
const stream = createReadStream(auditPath, {
|
|
76
|
+
encoding: "utf8",
|
|
77
|
+
highWaterMark: 64 * 1024
|
|
78
|
+
});
|
|
79
|
+
stream.on("data", (chunk) => {
|
|
80
|
+
try {
|
|
81
|
+
const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
82
|
+
const lines = (carry + text).split("\n");
|
|
83
|
+
carry = lines.pop() ?? "";
|
|
84
|
+
for (const line of lines) processLine(line, Buffer.byteLength(line, "utf8") + 1, true);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
stream.destroy();
|
|
87
|
+
rejectStream(error);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
stream.on("error", (error) => {
|
|
91
|
+
rejectStream(error);
|
|
92
|
+
});
|
|
93
|
+
stream.on("end", () => {
|
|
94
|
+
try {
|
|
95
|
+
const trimmedCarry = carry.trim();
|
|
96
|
+
if (trimmedCarry.length > 0) {
|
|
97
|
+
if (pendingMalformed !== void 0) throw pendingMalformed.error;
|
|
98
|
+
try {
|
|
99
|
+
pushRecord(JSON.parse(trimmedCarry));
|
|
100
|
+
hadTruncatedTail = true;
|
|
101
|
+
truncateToOffset = info.size;
|
|
102
|
+
} catch {
|
|
103
|
+
hadTruncatedTail = true;
|
|
104
|
+
truncateToOffset = validByteOffset;
|
|
105
|
+
warn(`Ignoring incomplete trailing audit record in ${auditPath}`);
|
|
106
|
+
}
|
|
107
|
+
} else if (pendingMalformed !== void 0) {
|
|
108
|
+
hadTruncatedTail = true;
|
|
109
|
+
truncateToOffset = pendingMalformed.validByteOffset;
|
|
110
|
+
warn(`Ignoring malformed trailing audit record in ${auditPath}`);
|
|
111
|
+
}
|
|
112
|
+
resolveStream();
|
|
113
|
+
} catch (error) {
|
|
114
|
+
rejectStream(error);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
if (hadTruncatedTail && options.repairTruncatedTail === true) {
|
|
119
|
+
if (truncateToOffset < info.size) await truncate(auditPath, truncateToOffset).catch(() => {});
|
|
120
|
+
else if (carry.length > 0) await writeFile(auditPath, "\n", { flag: "a" }).catch(() => {});
|
|
121
|
+
}
|
|
122
|
+
if (!compactMode) return keptState.map((item) => item.record);
|
|
123
|
+
return [...keptState, ...keptFrames].sort((a, b) => a.order - b.order).map((item) => item.record);
|
|
124
|
+
}
|
|
125
|
+
async function compactAuditFile(auditPath, options = {}) {
|
|
126
|
+
const records = await readAuditFile(auditPath, {
|
|
127
|
+
maxBytes: 0,
|
|
128
|
+
tailFrameLimit: options.tailFrameLimit ?? 200,
|
|
129
|
+
repairTruncatedTail: false
|
|
130
|
+
});
|
|
131
|
+
const payload = records.length === 0 ? "" : `${records.map((record) => JSON.stringify(record)).join("\n")}\n`;
|
|
132
|
+
const tempPath = `${auditPath}.${process.pid}.${randomUUID()}.tmp`;
|
|
133
|
+
await writeFile(tempPath, payload, "utf8");
|
|
134
|
+
try {
|
|
135
|
+
await rename(tempPath, auditPath);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
await unlink(tempPath).catch(() => {});
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
return Buffer.byteLength(payload, "utf8");
|
|
141
|
+
}
|
|
142
|
+
async function pruneExpiredAuditFiles(auditDir, maxAgeMs = AUDIT_RETENTION_MS) {
|
|
143
|
+
let entries;
|
|
144
|
+
try {
|
|
145
|
+
entries = await readdir(auditDir, { withFileTypes: true });
|
|
146
|
+
} catch {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const cutoff = Date.now() - maxAgeMs;
|
|
150
|
+
for (const entry of entries) {
|
|
151
|
+
if (!entry.isFile() || !entry.name.endsWith(".ndjson")) continue;
|
|
152
|
+
const filePath = resolve(auditDir, entry.name);
|
|
153
|
+
const info = await stat(filePath).catch(() => void 0);
|
|
154
|
+
if (info && info.mtimeMs < cutoff) await unlink(filePath).catch(() => {});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/types.ts
|
|
13
160
|
const MAX_FRAME_BYTES = 1024 * 1024;
|
|
14
|
-
const DEFAULT =
|
|
15
|
-
const EFFORTS = [
|
|
161
|
+
const DEFAULT = "engine-default";
|
|
162
|
+
const EFFORTS = [
|
|
163
|
+
"low",
|
|
164
|
+
"medium",
|
|
165
|
+
"high",
|
|
166
|
+
"xhigh",
|
|
167
|
+
"max"
|
|
168
|
+
];
|
|
169
|
+
const NATIVE_ID = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
|
|
170
|
+
const NATIVE_TOOL_NAME = /^[a-z][a-z0-9_]{0,63}$/i;
|
|
171
|
+
const LEGACY_NATIVE_STEP = {
|
|
172
|
+
user: 14,
|
|
173
|
+
planner: 15,
|
|
174
|
+
error: 17,
|
|
175
|
+
ephemeral: 90,
|
|
176
|
+
system: 101,
|
|
177
|
+
tool: 132
|
|
178
|
+
};
|
|
179
|
+
const LEGACY_NETWORK_FAILURE = "There was a network issue connecting to the server, please try again.";
|
|
180
|
+
const NETWORK_RECOVERY_INSTRUCTION = "The connection to the model provider was interrupted after your last completed step. Continue the same task from where it stopped. Do not repeat tool calls that already finished.";
|
|
181
|
+
const NETWORK_RECOVERY_BACKOFF_MS = [
|
|
182
|
+
1e3,
|
|
183
|
+
3e3,
|
|
184
|
+
7e3,
|
|
185
|
+
15e3,
|
|
186
|
+
25e3
|
|
187
|
+
];
|
|
188
|
+
const NETWORK_RECOVERY_EXIT_GRACE_MS = 5e3;
|
|
189
|
+
const ERROR_RESULT_WATCHDOG_MS = 15e3;
|
|
16
190
|
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/catalog.ts
|
|
193
|
+
const CATALOG_TIMEOUT_MS = 2e4;
|
|
194
|
+
const CATALOG_MAX_BYTES = 65536;
|
|
17
195
|
function processAlive(pid) {
|
|
18
|
-
|
|
19
|
-
|
|
196
|
+
if (!Number.isSafeInteger(pid) || pid <= 0) return true;
|
|
197
|
+
try {
|
|
198
|
+
process.kill(pid, 0);
|
|
199
|
+
return true;
|
|
200
|
+
} catch (error) {
|
|
201
|
+
return error.code !== "ESRCH";
|
|
202
|
+
}
|
|
20
203
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
: mode === 'auto' ? { toolPermission: 'request-review', agentMode: 'auto' }
|
|
32
|
-
: mode === 'yolo' ? { toolPermission: 'always-proceed', agentMode: 'accept-edits', allowNonWorkspaceAccess: true, enableTerminalSandbox: false }
|
|
33
|
-
: undefined;
|
|
34
|
-
if (settings !== undefined) args.push('--settings', JSON.stringify(settings));
|
|
35
|
-
for (const dir of session.additionalDirectories) args.push('--add-dir', dir);
|
|
36
|
-
return args;
|
|
204
|
+
function takeNewDenials(actions, reported) {
|
|
205
|
+
const counts = /* @__PURE__ */ new Map();
|
|
206
|
+
const fresh = (actions ?? []).filter((action) => {
|
|
207
|
+
const key = JSON.stringify([action?.action, action?.display_name]);
|
|
208
|
+
const count = (counts.get(key) ?? 0) + 1;
|
|
209
|
+
counts.set(key, count);
|
|
210
|
+
return count > (reported.get(key) ?? 0);
|
|
211
|
+
});
|
|
212
|
+
for (const [key, count] of counts) reported.set(key, Math.max(count, reported.get(key) ?? 0));
|
|
213
|
+
return fresh;
|
|
37
214
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
215
|
+
function accumulateStepUsage(usageSteps, totals, step) {
|
|
216
|
+
if (step?.state !== "DONE" || !step.usage || !Number.isSafeInteger(step.step_index) || usageSteps.has(step.step_index)) return false;
|
|
217
|
+
usageSteps.add(step.step_index);
|
|
218
|
+
totals.inputTokens += Number(step.usage.input_tokens) || 0;
|
|
219
|
+
totals.outputTokens += Number(step.usage.output_tokens) || 0;
|
|
220
|
+
totals.cachedReadTokens += Number(step.usage.cache_read_tokens) || 0;
|
|
221
|
+
totals.thoughtTokens += Number(step.usage.thinking_tokens) || 0;
|
|
222
|
+
totals.totalTokens += Number(step.usage.total_tokens) || 0;
|
|
223
|
+
return true;
|
|
46
224
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
225
|
+
function emptyUsage() {
|
|
226
|
+
return {
|
|
227
|
+
inputTokens: 0,
|
|
228
|
+
outputTokens: 0,
|
|
229
|
+
cachedReadTokens: 0,
|
|
230
|
+
thoughtTokens: 0,
|
|
231
|
+
totalTokens: 0
|
|
232
|
+
};
|
|
50
233
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
234
|
+
function subagentPayload(step) {
|
|
235
|
+
if (!step?.subagent_info) return void 0;
|
|
236
|
+
return { subagents: (step.subagent_info.subagents ?? []).map((child) => ({
|
|
237
|
+
type_name: child?.type_name,
|
|
238
|
+
initial_prompt: child?.initial_prompt,
|
|
239
|
+
conversation_id: child?.conversation_id,
|
|
240
|
+
log_uri: child?.log_uri
|
|
241
|
+
})) };
|
|
242
|
+
}
|
|
243
|
+
function encodedEffort(model) {
|
|
244
|
+
return EFFORTS.find((effort) => model.endsWith(`-${effort}`));
|
|
245
|
+
}
|
|
246
|
+
function validateEffort(model, effort) {
|
|
247
|
+
if (!["engine-default", ...EFFORTS].includes(effort)) throw new Error("Unsupported AGY effort selection");
|
|
248
|
+
const encoded = encodedEffort(model);
|
|
249
|
+
if (effort === "engine-default") return;
|
|
250
|
+
if (encoded === void 0) throw new Error(`AGY model ID ${model} does not embed an effort; effort ${effort} is not an advertised config for this id`);
|
|
251
|
+
if (effort !== encoded) throw new Error(`AGY model ID ${model} encodes effort ${encoded} and conflicts with effort ${effort}; select the corresponding raw AGY model ID instead`);
|
|
252
|
+
}
|
|
253
|
+
function launchArgs(session) {
|
|
254
|
+
validateEffort(session.model, session.effort);
|
|
255
|
+
const args = [
|
|
256
|
+
"--input-format",
|
|
257
|
+
"stream-json",
|
|
258
|
+
"--output-format",
|
|
259
|
+
"stream-json"
|
|
260
|
+
];
|
|
261
|
+
if (session.conversationId) args.push("--conversation", session.conversationId);
|
|
262
|
+
if (session.model !== "engine-default") args.push("--model", session.model);
|
|
263
|
+
if (session.effort !== "engine-default" && !session.model.startsWith("claude-")) args.push("--effort", session.effort);
|
|
264
|
+
const mode = session.permissionMode ?? "engine-default";
|
|
265
|
+
if (mode === "yolo") args.push("--dangerously-skip-permissions");
|
|
266
|
+
const settings = mode === "manual" ? {
|
|
267
|
+
toolPermission: "request-review",
|
|
268
|
+
agentMode: "default"
|
|
269
|
+
} : mode === "auto" ? {
|
|
270
|
+
toolPermission: "request-review",
|
|
271
|
+
agentMode: "auto"
|
|
272
|
+
} : mode === "yolo" ? {
|
|
273
|
+
toolPermission: "always-proceed",
|
|
274
|
+
agentMode: "accept-edits",
|
|
275
|
+
allowNonWorkspaceAccess: true,
|
|
276
|
+
enableTerminalSandbox: false
|
|
277
|
+
} : void 0;
|
|
278
|
+
const accountSettings = session.accountBound ? {
|
|
279
|
+
modelProvider: "gemini",
|
|
280
|
+
customModelsConfig: { customModels: { [session.model]: {
|
|
281
|
+
modelName: `gemini-api://models/${session.model}`,
|
|
282
|
+
toolFormatterType: "TOOL_FORMATTER_TYPE_NONE"
|
|
283
|
+
} } }
|
|
284
|
+
} : void 0;
|
|
285
|
+
if (settings !== void 0 || accountSettings !== void 0) args.push("--settings", JSON.stringify({
|
|
286
|
+
...settings,
|
|
287
|
+
...accountSettings
|
|
288
|
+
}));
|
|
289
|
+
for (const dir of session.additionalDirectories) args.push("--add-dir", dir);
|
|
290
|
+
return args;
|
|
291
|
+
}
|
|
292
|
+
function promptText(blocks) {
|
|
293
|
+
if (!Array.isArray(blocks) || blocks.some((b) => b?.type !== "text" || typeof b.text !== "string")) throw new Error("This AGY ACP adapter accepts text prompts only; CLI rich-input support has not been verified");
|
|
294
|
+
const text = blocks.map((b) => b.text).join("\n");
|
|
295
|
+
if (Buffer.byteLength(text) > 1048576 / 2) throw new Error("AGY prompt exceeds the adapter frame limit");
|
|
296
|
+
return text;
|
|
62
297
|
}
|
|
63
|
-
|
|
64
|
-
const CATALOG_TIMEOUT_MS = 20_000;
|
|
65
|
-
const CATALOG_MAX_BYTES = 65_536;
|
|
66
|
-
|
|
67
298
|
/** First whitespace token of each `agy models` row. Header and comment rows are not ids. */
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
299
|
+
function vendorModelIds(output) {
|
|
300
|
+
const values = [];
|
|
301
|
+
const seen = /* @__PURE__ */ new Set();
|
|
302
|
+
for (const line of String(output).split(/\r?\n/u)) {
|
|
303
|
+
const first = (line.trim().split(/\s+/u)[0] ?? "").trim();
|
|
304
|
+
if (first === "" || first.startsWith("#") || /^(?:id|model|models|name)$/iu.test(first)) continue;
|
|
305
|
+
if (first.length > 256 || /\s/u.test(first) || seen.has(first)) continue;
|
|
306
|
+
seen.add(first);
|
|
307
|
+
values.push(first);
|
|
308
|
+
}
|
|
309
|
+
return values;
|
|
79
310
|
}
|
|
80
|
-
|
|
81
311
|
function safeDiagnosticLine(text) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
312
|
+
const line = text.trim();
|
|
313
|
+
if (line.length === 0 || /(?:token|bearer|api[_-]?key|secret|authorization|password)/iu.test(line) || /[A-Za-z0-9+/_-]{32,}={0,2}/u.test(line) || /[\u0000-\u0008\u000b-\u001f\u007f]/u.test(line)) return;
|
|
314
|
+
return line.slice(0, 180);
|
|
85
315
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const line = String(text).split(/\r?\n/u).map(part => part.trim()).find(Boolean) ?? '';
|
|
89
|
-
return safeDiagnosticLine(line) ?? 'AGY model catalog probe failed';
|
|
316
|
+
function catalogDiagnostic(text) {
|
|
317
|
+
return safeDiagnosticLine(String(text).split(/\r?\n/u).map((part) => part.trim()).find(Boolean) ?? "") ?? "AGY model catalog probe failed";
|
|
90
318
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
319
|
+
function readVendorModelCatalog({ cliPath, cliPrefix = [], spawnProcess = spawn, stopProcess, timeoutMs = CATALOG_TIMEOUT_MS, maxOutputBytes = CATALOG_MAX_BYTES } = {}) {
|
|
320
|
+
return new Promise((resolveCatalog) => {
|
|
321
|
+
let child;
|
|
322
|
+
let settled = false;
|
|
323
|
+
let overflow = false;
|
|
324
|
+
const finish = (result) => {
|
|
325
|
+
if (settled) return;
|
|
326
|
+
settled = true;
|
|
327
|
+
clearTimeout(timer);
|
|
328
|
+
resolveCatalog(result);
|
|
329
|
+
};
|
|
330
|
+
const timer = setTimeout(() => {
|
|
331
|
+
const stopping = child === void 0 ? void 0 : Promise.resolve(stopProcess ? stopProcess(child) : child.kill?.()).catch(() => {});
|
|
332
|
+
Promise.resolve(stopping).finally(() => finish({
|
|
333
|
+
ok: false,
|
|
334
|
+
diagnostic: "AGY model catalog probe timed out"
|
|
335
|
+
}));
|
|
336
|
+
}, timeoutMs);
|
|
337
|
+
let stdout = Buffer.alloc(0);
|
|
338
|
+
let stderr = Buffer.alloc(0);
|
|
339
|
+
try {
|
|
340
|
+
child = spawnProcess(cliPath ?? "", [...cliPrefix, "models"], {
|
|
341
|
+
stdio: [
|
|
342
|
+
"ignore",
|
|
343
|
+
"pipe",
|
|
344
|
+
"pipe"
|
|
345
|
+
],
|
|
346
|
+
windowsHide: true
|
|
347
|
+
});
|
|
348
|
+
} catch (error) {
|
|
349
|
+
finish({
|
|
350
|
+
ok: false,
|
|
351
|
+
diagnostic: catalogDiagnostic(error instanceof Error ? error.message : String(error))
|
|
352
|
+
});
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
const take = (current, chunk) => {
|
|
356
|
+
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
357
|
+
const next = Buffer.concat([current, bytes]);
|
|
358
|
+
if (next.length > maxOutputBytes) {
|
|
359
|
+
overflow = true;
|
|
360
|
+
child?.kill?.();
|
|
361
|
+
return next.subarray(0, maxOutputBytes);
|
|
362
|
+
}
|
|
363
|
+
return next;
|
|
364
|
+
};
|
|
365
|
+
child.stdout?.on("data", (chunk) => {
|
|
366
|
+
stdout = take(stdout, chunk);
|
|
367
|
+
});
|
|
368
|
+
child.stderr?.on("data", (chunk) => {
|
|
369
|
+
stderr = take(stderr, chunk);
|
|
370
|
+
});
|
|
371
|
+
child.once?.("error", (error) => finish({
|
|
372
|
+
ok: false,
|
|
373
|
+
diagnostic: catalogDiagnostic(error instanceof Error ? error.message : String(error))
|
|
374
|
+
}));
|
|
375
|
+
child.once?.("close", (code) => {
|
|
376
|
+
if (overflow) finish({
|
|
377
|
+
ok: false,
|
|
378
|
+
diagnostic: "AGY model catalog probe exceeded the output limit"
|
|
379
|
+
});
|
|
380
|
+
else if (code !== 0) finish({
|
|
381
|
+
ok: false,
|
|
382
|
+
diagnostic: catalogDiagnostic(stderr.toString("utf8") || `AGY model catalog probe exited ${code}`)
|
|
383
|
+
});
|
|
384
|
+
else finish({
|
|
385
|
+
ok: true,
|
|
386
|
+
ids: vendorModelIds(stdout.toString("utf8"))
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
});
|
|
134
390
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
391
|
+
function configOptions(session) {
|
|
392
|
+
const effort = encodedEffort(session.model);
|
|
393
|
+
const options = [{
|
|
394
|
+
id: "effort",
|
|
395
|
+
name: "AGY effort",
|
|
396
|
+
category: "thought_level",
|
|
397
|
+
type: "select",
|
|
398
|
+
currentValue: session.effort,
|
|
399
|
+
options: [{
|
|
400
|
+
value: DEFAULT,
|
|
401
|
+
name: "Follow AGY settings"
|
|
402
|
+
}, ...effort ? [{
|
|
403
|
+
value: effort,
|
|
404
|
+
name: effort
|
|
405
|
+
}] : []]
|
|
406
|
+
}];
|
|
407
|
+
if (Array.isArray(session.modelChoices)) options.push({
|
|
408
|
+
id: "model",
|
|
409
|
+
name: "AGY model",
|
|
410
|
+
category: "model",
|
|
411
|
+
type: "select",
|
|
412
|
+
currentValue: session.model,
|
|
413
|
+
options: session.modelChoices.length === 0 ? [] : [...session.accountBound ? [] : [{
|
|
414
|
+
value: DEFAULT,
|
|
415
|
+
name: "Follow AGY settings"
|
|
416
|
+
}], ...session.modelChoices.map((id) => ({
|
|
417
|
+
value: id,
|
|
418
|
+
name: id
|
|
419
|
+
}))]
|
|
420
|
+
});
|
|
421
|
+
options.push({
|
|
422
|
+
id: "native-agent",
|
|
423
|
+
name: "AGY native agent",
|
|
424
|
+
category: "native_agent",
|
|
425
|
+
type: "select",
|
|
426
|
+
currentValue: DEFAULT,
|
|
427
|
+
options: [{
|
|
428
|
+
value: DEFAULT,
|
|
429
|
+
name: "Follow AGY default agent"
|
|
430
|
+
}]
|
|
431
|
+
});
|
|
432
|
+
options.push({
|
|
433
|
+
id: "permission-mode",
|
|
434
|
+
name: "AGY permissions",
|
|
435
|
+
category: "permission_mode",
|
|
436
|
+
type: "select",
|
|
437
|
+
currentValue: session.permissionMode ?? "engine-default",
|
|
438
|
+
options: [
|
|
439
|
+
{
|
|
440
|
+
value: DEFAULT,
|
|
441
|
+
name: "Follow AGY settings"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
value: "manual",
|
|
445
|
+
name: "Request review"
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
value: "auto",
|
|
449
|
+
name: "AGY auto mode"
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
value: "yolo",
|
|
453
|
+
name: "Full access"
|
|
454
|
+
}
|
|
455
|
+
]
|
|
456
|
+
});
|
|
457
|
+
return options;
|
|
153
458
|
}
|
|
154
|
-
|
|
155
459
|
async function terminate(child) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
460
|
+
const running = () => child?.pid !== void 0 && child.exitCode === null && child.signalCode === null;
|
|
461
|
+
if (!running() || !child) return;
|
|
462
|
+
let onClose;
|
|
463
|
+
const closed = new Promise((done) => {
|
|
464
|
+
onClose = done;
|
|
465
|
+
child.once("close", onClose);
|
|
466
|
+
});
|
|
467
|
+
try {
|
|
468
|
+
if (process.platform === "win32") {
|
|
469
|
+
const killer = spawn(resolve(process.env["SystemRoot"] ?? "C:/Windows", "System32/taskkill.exe"), [
|
|
470
|
+
"/PID",
|
|
471
|
+
String(child.pid),
|
|
472
|
+
"/T",
|
|
473
|
+
"/F"
|
|
474
|
+
], {
|
|
475
|
+
windowsHide: true,
|
|
476
|
+
stdio: "ignore"
|
|
477
|
+
});
|
|
478
|
+
await new Promise((done, reject) => {
|
|
479
|
+
killer.once("error", reject);
|
|
480
|
+
killer.once("close", (code, signal) => code === 0 ? done() : reject(/* @__PURE__ */ new Error(`taskkill exited with ${code ?? signal}`)));
|
|
481
|
+
});
|
|
482
|
+
} else if (!child.kill("SIGTERM")) throw new Error("SIGTERM was not delivered");
|
|
483
|
+
} catch (error) {
|
|
484
|
+
if (running()) {
|
|
485
|
+
child.off("close", onClose);
|
|
486
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
487
|
+
throw new Error(`Could not stop the owned AGY process: ${message}`, { cause: error });
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
await closed;
|
|
491
|
+
}
|
|
492
|
+
function consumeAccountEnvironment(env = process.env) {
|
|
493
|
+
const apiKey = env["GEMINI_API_KEY"];
|
|
494
|
+
const baseUrl = env["GOOGLE_GEMINI_BASE_URL"];
|
|
495
|
+
const rawModels = env["KIKI_AGY_ACCOUNT_MODELS"];
|
|
496
|
+
delete env["GEMINI_API_KEY"];
|
|
497
|
+
delete env["GOOGLE_GEMINI_BASE_URL"];
|
|
498
|
+
delete env["KIKI_AGY_ACCOUNT_MODELS"];
|
|
499
|
+
const modelIds = JSON.parse(rawModels ?? "null");
|
|
500
|
+
if (typeof apiKey !== "string" || !apiKey || typeof baseUrl !== "string" || !/^https?:\/\//.test(baseUrl) || !Array.isArray(modelIds) || modelIds.length === 0 || modelIds.some((id) => typeof id !== "string" || !id || /\s/.test(id) || id === "engine-default")) throw new Error("The selected account connection is unavailable; no global AGY fallback is allowed");
|
|
501
|
+
return {
|
|
502
|
+
apiKey,
|
|
503
|
+
baseUrl,
|
|
504
|
+
modelIds
|
|
505
|
+
};
|
|
164
506
|
}
|
|
165
507
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
await this.audit(session, 'permission_mode_configured', { value, mechanism: 'native-session-settings' });
|
|
355
|
-
return { configOptions: configOptions(session) };
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
async syncPermissionHook(session) {
|
|
359
|
-
session.permissionChannel ??= await openPermissionChannel(input => ['mcp_bootstrap', 'mcp_ready'].includes(input?.type)
|
|
360
|
-
? this.bindMcpBootstrap(session, input) : input?.type === 'steer_poll' ? this.pollSteering(session, input)
|
|
361
|
-
: this.requestPermission(), session.permissionIdentity);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
async registerMcpPlugin(session) {
|
|
365
|
-
if (!session.mcpServers.length || session.mcpPlugin) return;
|
|
366
|
-
session.mcpPlugin = await registerProjectMcpPlugin({ cwd: session.cwd, sessionId: session.id, namespace: session.mcpNamespace,
|
|
367
|
-
nodePath: process.execPath, handlerPath: fileURLToPath(import.meta.url), servers: session.mcpServers });
|
|
368
|
-
await this.audit(session, 'mcp_plugin_registered', { name: session.mcpPlugin.name, path: session.mcpPlugin.path,
|
|
369
|
-
servers: session.mcpServers.map(server => server.name), nativeAgent: 'engine-default' });
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
async bindMcpBootstrap(session, input) {
|
|
373
|
-
if (!session.mcpPlugin || !Object.hasOwn(session.mcpPlugin.env, input.key) || session.broken) {
|
|
374
|
-
return { decision: 'deny', reason: 'The MCP bootstrap does not belong to this active session' };
|
|
375
|
-
}
|
|
376
|
-
if (input.type === 'mcp_ready') {
|
|
377
|
-
if (!session.mcpBound.has(input.key)) return { decision: 'deny', reason: 'The MCP bootstrap has not been admitted' };
|
|
378
|
-
session.mcpReady.add(input.key);
|
|
379
|
-
} else session.mcpBound.add(input.key);
|
|
380
|
-
await this.audit(session, input.type === 'mcp_ready' ? 'mcp_stdio_ready' : 'mcp_stdio_bound',
|
|
381
|
-
{ server: session.mcpServers[Object.keys(session.mcpPlugin.env).indexOf(input.key)].name });
|
|
382
|
-
return { decision: 'allow' };
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* A previous adapter killed before its close ran can leave its owned hook keys and MCP
|
|
387
|
-
* plugin in this workspace. Before this session registers its own, recover only those
|
|
388
|
-
* whose every recorded owner process has exited; live leases, edited files and foreign
|
|
389
|
-
* entries are preserved and reported in the audit instead of failing the session.
|
|
390
|
-
*/
|
|
391
|
-
async recoverDeadOwnedResources(session) {
|
|
392
|
-
if (session.ownedRecoveryDone) return;
|
|
393
|
-
session.ownedRecoveryDone = true;
|
|
394
|
-
const results = {};
|
|
395
|
-
try {
|
|
396
|
-
results.hooks = (await recoverProjectHook({ cwd: session.cwd, nodePath: process.execPath,
|
|
397
|
-
handlerPath: fileURLToPath(new URL('./agy-permission-hook.mjs', import.meta.url)) })).status;
|
|
398
|
-
} catch (error) { results.hooks = { status: 'preserved', reason: error instanceof Error ? error.message : String(error) }; }
|
|
399
|
-
try { results.plugins = await recoverDeadProjectMcpPlugins({ cwd: session.cwd }); }
|
|
400
|
-
catch (error) { results.plugins = { status: 'preserved', reason: error instanceof Error ? error.message : String(error) }; }
|
|
401
|
-
if (results.hooks !== 'no-owned-registration' || results.plugins.length) this.auditQuietly(session, 'owned_recovery', results);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
async registerSteeringHook(session) {
|
|
405
|
-
session.steeringRegistration ??= await registerProjectHook({ cwd: session.cwd, nodePath: process.execPath,
|
|
406
|
-
handlerPath: fileURLToPath(new URL('./agy-permission-hook.mjs', import.meta.url)), sessionId: session.id,
|
|
407
|
-
key: AGY_STEERING_HOOK_KEY, args: ['--steering'] });
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Removes this turn's owned PostInvocation key. A failed removal keeps the registration
|
|
412
|
-
* on the session so the next turn end, cancel or close retries it; the turn result is
|
|
413
|
-
* never replaced by the cleanup error.
|
|
414
|
-
*/
|
|
415
|
-
async closeSteeringHook(session) {
|
|
416
|
-
const registration = session.steeringRegistration;
|
|
417
|
-
if (!registration) return;
|
|
418
|
-
try {
|
|
419
|
-
await registration.close();
|
|
420
|
-
if (session.steeringRegistration === registration) session.steeringRegistration = undefined;
|
|
421
|
-
} catch (error) {
|
|
422
|
-
this.auditQuietly(session, 'steering_hook_close_failed', { error: error instanceof Error ? error.message : String(error) });
|
|
423
|
-
throw error;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
auditQuietly(session, type, data) {
|
|
428
|
-
this.audit(session, type, data).catch(() => {});
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* Accepts one steering message for the running native turn. The text waits in this
|
|
433
|
-
* session until AGY's next PostInvocation hook drains it into the same invocation loop.
|
|
434
|
-
* An idle session returns `promptRequired` so the host submits a normal prompt instead.
|
|
435
|
-
*/
|
|
436
|
-
async steer(params) {
|
|
437
|
-
const session = this.session(params.sessionId);
|
|
438
|
-
const active = session.active;
|
|
439
|
-
if (!active || session.broken || !session.steeringRegistration) return { outcome: 'promptRequired', reason: 'noRunningTurn' };
|
|
440
|
-
const text = promptText(params.prompt);
|
|
441
|
-
const id = randomUUID();
|
|
442
|
-
await this.audit(session, 'steer_queued', { steerId: id, sha256: createHash('sha256').update(text).digest('hex') });
|
|
443
|
-
if (session.active !== active || session.broken || !session.steeringRegistration) {
|
|
444
|
-
this.auditQuietly(session, 'steer_not_delivered', { steerIds: [id] });
|
|
445
|
-
return { outcome: 'promptRequired', reason: 'turnEnded' };
|
|
446
|
-
}
|
|
447
|
-
return new Promise(resolveSteer => active.steering.push({ id, text, resolve: resolveSteer }));
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
releaseSteering(session, active) {
|
|
451
|
-
const pending = active.steering.splice(0);
|
|
452
|
-
if (pending.length) this.auditQuietly(session, 'steer_not_delivered', { steerIds: pending.map(item => item.id) });
|
|
453
|
-
for (const item of pending) item.resolve({ outcome: 'promptRequired', reason: 'turnEnded' });
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
async pollSteering(session, input) {
|
|
457
|
-
const active = session.active;
|
|
458
|
-
if (!active || session.broken || !session.init || input.conversationId !== session.init.conversation_id) {
|
|
459
|
-
return { decision: 'deny', reason: 'AGY steering poll does not belong to the running turn' };
|
|
460
|
-
}
|
|
461
|
-
if (active.steering.length === 0) return { decision: 'allow', steering: { injectSteps: [] } };
|
|
462
|
-
const batch = active.steering.splice(0);
|
|
463
|
-
this.auditQuietly(session, 'steer_delivering', { steerIds: batch.map(item => item.id), invocationNum: input.invocationNum });
|
|
464
|
-
let settled = false;
|
|
465
|
-
const settle = (outcome, type) => {
|
|
466
|
-
if (settled) return;
|
|
467
|
-
settled = true;
|
|
468
|
-
this.auditQuietly(session, type, { steerIds: batch.map(item => item.id) });
|
|
469
|
-
for (const item of batch) item.resolve({ outcome });
|
|
470
|
-
};
|
|
471
|
-
return { decision: 'allow', steering: { injectSteps: batch.map(item => ({ userMessage: item.text })) },
|
|
472
|
-
afterWrite: () => settle('injected', 'steer_delivered'),
|
|
473
|
-
afterFailure: () => settle('deliveryUnknown', 'steer_delivery_unknown') };
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
async start(session) {
|
|
477
|
-
await this.registerMcpPlugin(session);
|
|
478
|
-
const args = [...this.cliPrefix, ...launchArgs(session)];
|
|
479
|
-
const env = { ...process.env, ...session.permissionIdentity };
|
|
480
|
-
for (const key of Object.keys(env)) if (key.startsWith('KIKI_AGY_MCP_')) delete env[key];
|
|
481
|
-
Object.assign(env, session.mcpPlugin?.env);
|
|
482
|
-
let child;
|
|
483
|
-
try {
|
|
484
|
-
await session.mcpPlugin?.beforeLaunch();
|
|
485
|
-
child = this.spawnProcess(this.cliPath, args, { cwd: session.cwd, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true, env });
|
|
486
|
-
} catch (error) {
|
|
487
|
-
await session.permissionChannel?.close();
|
|
488
|
-
await this.closeSteeringHook(session).catch(() => {});
|
|
489
|
-
await session.mcpPlugin?.close();
|
|
490
|
-
throw error;
|
|
491
|
-
}
|
|
492
|
-
session.child = child;
|
|
493
|
-
session.exited = new Promise(done => child.once('close', done));
|
|
494
|
-
const decoder = new StringDecoder('utf8');
|
|
495
|
-
let buffer = '';
|
|
496
|
-
let stderr = Buffer.alloc(0);
|
|
497
|
-
let stderrTruncated = false;
|
|
498
|
-
let delivery = Promise.resolve();
|
|
499
|
-
const fail = error => {
|
|
500
|
-
session.broken = true;
|
|
501
|
-
if (session.active) { session.active.reject(error); session.active = undefined; }
|
|
502
|
-
void this.stopProcess(child).catch(() => {});
|
|
503
|
-
};
|
|
504
|
-
child.stdout.on('data', chunk => {
|
|
505
|
-
buffer += decoder.write(chunk);
|
|
506
|
-
if (Buffer.byteLength(buffer) > MAX_FRAME_BYTES) { fail(new Error('AGY stdout frame exceeds 1 MiB')); return; }
|
|
507
|
-
let newline;
|
|
508
|
-
while ((newline = buffer.indexOf('\n')) >= 0) {
|
|
509
|
-
const line = buffer.slice(0, newline).trim(); buffer = buffer.slice(newline + 1);
|
|
510
|
-
if (!line) continue;
|
|
511
|
-
delivery = delivery.then(async () => {
|
|
512
|
-
let event;
|
|
513
|
-
try { event = JSON.parse(line); } catch { throw new Error('AGY emitted invalid NDJSON'); }
|
|
514
|
-
await this.event(session, event);
|
|
515
|
-
}).catch(fail);
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
child.stderr.on('data', chunk => {
|
|
519
|
-
const text = chunk.toString();
|
|
520
|
-
if (/auto-denied|soft.denied|permission.*denied/i.test(text)) session.denied = true;
|
|
521
|
-
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
522
|
-
stderrTruncated ||= stderr.length + bytes.length > 8192;
|
|
523
|
-
const tail = Buffer.concat([stderr, bytes.subarray(Math.max(0, bytes.length - 8192))]);
|
|
524
|
-
stderr = tail.subarray(Math.max(0, tail.length - 8192));
|
|
525
|
-
process.stderr.write(chunk);
|
|
526
|
-
});
|
|
527
|
-
child.stdin.on('error', fail);
|
|
528
|
-
child.on('error', fail);
|
|
529
|
-
child.once('close', (code, signal) => {
|
|
530
|
-
const lines = stderr.toString('utf8').split(/\r?\n/u);
|
|
531
|
-
if (stderrTruncated) lines.shift();
|
|
532
|
-
const diagnostic = lines.map(safeDiagnosticLine).findLast(line => line !== undefined);
|
|
533
|
-
stderr = Buffer.alloc(0);
|
|
534
|
-
session.cleanup = (async () => {
|
|
535
|
-
try {
|
|
536
|
-
await delivery;
|
|
537
|
-
} finally {
|
|
538
|
-
session.broken = true;
|
|
539
|
-
if (session.active) {
|
|
540
|
-
const message = `AGY exited before terminal result (code: ${code ?? 'none'}, signal: ${signal ?? 'none'})${diagnostic === undefined ? '' : `: ${diagnostic}`}`;
|
|
541
|
-
const error = new Error(message);
|
|
542
|
-
error.code = 'AGY_EARLY_EXIT';
|
|
543
|
-
error.details = { exitCode: code ?? null, signal: signal ?? null, diagnostic };
|
|
544
|
-
session.failure = message;
|
|
545
|
-
session.active.reject(error);
|
|
546
|
-
session.active = undefined;
|
|
547
|
-
}
|
|
548
|
-
await session.permissionChannel?.close();
|
|
549
|
-
await this.closeSteeringHook(session).catch(() => {});
|
|
550
|
-
await session.mcpPlugin?.close();
|
|
551
|
-
if (!session.restarting) await session.releaseResume?.();
|
|
552
|
-
}
|
|
553
|
-
})();
|
|
554
|
-
session.cleanup.catch(error => { process.stderr.write(`AGY owned permission cleanup failed: ${error.message}\n`); });
|
|
555
|
-
});
|
|
556
|
-
try { await session.mcpPlugin?.launched(child.pid); }
|
|
557
|
-
catch (error) { await this.stopProcess(child); await session.cleanup; throw error; }
|
|
558
|
-
return this.audit(session, 'launch', { cliPath: this.cliPath, args, effort: session.effort, pid: child.pid, cwd: session.cwd });
|
|
559
|
-
}
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region ../../node_modules/.pnpm/@bufbuild+protobuf@2.17.0/node_modules/@bufbuild/protobuf/dist/esm/wire/varint.js
|
|
510
|
+
/**
|
|
511
|
+
* Read a 64 bit varint as two JS numbers.
|
|
512
|
+
*
|
|
513
|
+
* Stores the low and high words on the reader.
|
|
514
|
+
*
|
|
515
|
+
* Copyright 2008 Google Inc. All rights reserved.
|
|
516
|
+
*
|
|
517
|
+
* See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L175
|
|
518
|
+
*/
|
|
519
|
+
function varint64read() {
|
|
520
|
+
const buf = this.buf;
|
|
521
|
+
let pos = this.pos;
|
|
522
|
+
let lo = 0;
|
|
523
|
+
let hi = 0;
|
|
524
|
+
for (let shift = 0; shift < 28; shift += 7) {
|
|
525
|
+
const b = buf[pos++];
|
|
526
|
+
lo |= (b & 127) << shift;
|
|
527
|
+
if ((b & 128) == 0) {
|
|
528
|
+
this.pos = pos;
|
|
529
|
+
this.assertBounds();
|
|
530
|
+
this.varint64Lo = lo;
|
|
531
|
+
this.varint64Hi = hi;
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
const middleByte = buf[pos++];
|
|
536
|
+
lo |= (middleByte & 15) << 28;
|
|
537
|
+
hi = (middleByte & 112) >> 4;
|
|
538
|
+
if ((middleByte & 128) == 0) {
|
|
539
|
+
this.pos = pos;
|
|
540
|
+
this.assertBounds();
|
|
541
|
+
this.varint64Lo = lo;
|
|
542
|
+
this.varint64Hi = hi;
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
for (let shift = 3; shift <= 31; shift += 7) {
|
|
546
|
+
const b = buf[pos++];
|
|
547
|
+
hi |= (b & 127) << shift;
|
|
548
|
+
if ((b & 128) == 0) {
|
|
549
|
+
this.pos = pos;
|
|
550
|
+
this.assertBounds();
|
|
551
|
+
this.varint64Lo = lo;
|
|
552
|
+
this.varint64Hi = hi;
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
throw new Error("invalid varint");
|
|
557
|
+
}
|
|
558
|
+
const TWO_PWR_32_DBL = 4294967296;
|
|
559
|
+
/**
|
|
560
|
+
* Parse decimal string of 64 bit integer value as two JS numbers.
|
|
561
|
+
*
|
|
562
|
+
* Copyright 2008 Google Inc. All rights reserved.
|
|
563
|
+
*
|
|
564
|
+
* See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10
|
|
565
|
+
*/
|
|
566
|
+
function int64FromString(dec) {
|
|
567
|
+
const minus = dec[0] === "-";
|
|
568
|
+
if (minus) dec = dec.slice(1);
|
|
569
|
+
const base = 1e6;
|
|
570
|
+
let lowBits = 0;
|
|
571
|
+
let highBits = 0;
|
|
572
|
+
function add1e6digit(begin, end) {
|
|
573
|
+
const digit1e6 = Number(dec.slice(begin, end));
|
|
574
|
+
highBits *= base;
|
|
575
|
+
lowBits = lowBits * base + digit1e6;
|
|
576
|
+
if (lowBits >= TWO_PWR_32_DBL) {
|
|
577
|
+
highBits = highBits + (lowBits / TWO_PWR_32_DBL | 0);
|
|
578
|
+
lowBits = lowBits % TWO_PWR_32_DBL;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
add1e6digit(-24, -18);
|
|
582
|
+
add1e6digit(-18, -12);
|
|
583
|
+
add1e6digit(-12, -6);
|
|
584
|
+
add1e6digit(-6);
|
|
585
|
+
return minus ? negate(lowBits, highBits) : newBits(lowBits, highBits);
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Losslessly converts a 64-bit signed integer in 32:32 split representation
|
|
589
|
+
* into a decimal string.
|
|
590
|
+
*
|
|
591
|
+
* Copyright 2008 Google Inc. All rights reserved.
|
|
592
|
+
*
|
|
593
|
+
* See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10
|
|
594
|
+
*/
|
|
595
|
+
function int64ToString(lo, hi) {
|
|
596
|
+
let bits = newBits(lo, hi);
|
|
597
|
+
const negative = bits.hi & 2147483648;
|
|
598
|
+
if (negative) bits = negate(bits.lo, bits.hi);
|
|
599
|
+
const result = uInt64ToString(bits.lo, bits.hi);
|
|
600
|
+
return negative ? "-" + result : result;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Losslessly converts a 64-bit unsigned integer in 32:32 split representation
|
|
604
|
+
* into a decimal string.
|
|
605
|
+
*
|
|
606
|
+
* Copyright 2008 Google Inc. All rights reserved.
|
|
607
|
+
*
|
|
608
|
+
* See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10
|
|
609
|
+
*/
|
|
610
|
+
function uInt64ToString(lo, hi) {
|
|
611
|
+
({lo, hi} = toUnsigned(lo, hi));
|
|
612
|
+
if (hi <= 2097151) return String(TWO_PWR_32_DBL * hi + lo);
|
|
613
|
+
const low = lo & 16777215;
|
|
614
|
+
const mid = (lo >>> 24 | hi << 8) & 16777215;
|
|
615
|
+
const high = hi >> 16 & 65535;
|
|
616
|
+
let digitA = low + mid * 6777216 + high * 6710656;
|
|
617
|
+
let digitB = mid + high * 8147497;
|
|
618
|
+
let digitC = high * 2;
|
|
619
|
+
const base = 1e7;
|
|
620
|
+
if (digitA >= base) {
|
|
621
|
+
digitB += Math.floor(digitA / base);
|
|
622
|
+
digitA %= base;
|
|
623
|
+
}
|
|
624
|
+
if (digitB >= base) {
|
|
625
|
+
digitC += Math.floor(digitB / base);
|
|
626
|
+
digitB %= base;
|
|
627
|
+
}
|
|
628
|
+
return digitC.toString() + decimalFrom1e7WithLeadingZeros(digitB) + decimalFrom1e7WithLeadingZeros(digitA);
|
|
629
|
+
}
|
|
630
|
+
function toUnsigned(lo, hi) {
|
|
631
|
+
return {
|
|
632
|
+
lo: lo >>> 0,
|
|
633
|
+
hi: hi >>> 0
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
function newBits(lo, hi) {
|
|
637
|
+
return {
|
|
638
|
+
lo: lo | 0,
|
|
639
|
+
hi: hi | 0
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Returns two's compliment negation of input.
|
|
644
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Signed_32-bit_integers
|
|
645
|
+
*/
|
|
646
|
+
function negate(lowBits, highBits) {
|
|
647
|
+
highBits = ~highBits;
|
|
648
|
+
if (lowBits) lowBits = ~lowBits + 1;
|
|
649
|
+
else highBits += 1;
|
|
650
|
+
return newBits(lowBits, highBits);
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Returns decimal representation of digit1e7 with leading zeros.
|
|
654
|
+
*/
|
|
655
|
+
const decimalFrom1e7WithLeadingZeros = (digit1e7) => {
|
|
656
|
+
const partial = String(digit1e7);
|
|
657
|
+
return "0000000".slice(partial.length) + partial;
|
|
658
|
+
};
|
|
659
|
+
/**
|
|
660
|
+
* Read an unsigned 32 bit varint.
|
|
661
|
+
*
|
|
662
|
+
* See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L220
|
|
663
|
+
*/
|
|
664
|
+
function varint32read() {
|
|
665
|
+
let b = this.buf[this.pos++];
|
|
666
|
+
if ((b & 128) === 0) {
|
|
667
|
+
this.assertBounds();
|
|
668
|
+
return b;
|
|
669
|
+
}
|
|
670
|
+
let result = b & 127;
|
|
671
|
+
b = this.buf[this.pos++];
|
|
672
|
+
result |= (b & 127) << 7;
|
|
673
|
+
if ((b & 128) === 0) {
|
|
674
|
+
this.assertBounds();
|
|
675
|
+
return result;
|
|
676
|
+
}
|
|
677
|
+
b = this.buf[this.pos++];
|
|
678
|
+
result |= (b & 127) << 14;
|
|
679
|
+
if ((b & 128) === 0) {
|
|
680
|
+
this.assertBounds();
|
|
681
|
+
return result;
|
|
682
|
+
}
|
|
683
|
+
b = this.buf[this.pos++];
|
|
684
|
+
result |= (b & 127) << 21;
|
|
685
|
+
if ((b & 128) === 0) {
|
|
686
|
+
this.assertBounds();
|
|
687
|
+
return result;
|
|
688
|
+
}
|
|
689
|
+
b = this.buf[this.pos++];
|
|
690
|
+
result |= (b & 15) << 28;
|
|
691
|
+
for (let readBytes = 5; (b & 128) !== 0 && readBytes < 10; readBytes++) b = this.buf[this.pos++];
|
|
692
|
+
if ((b & 128) !== 0) throw new Error("invalid varint");
|
|
693
|
+
this.assertBounds();
|
|
694
|
+
return result >>> 0;
|
|
695
|
+
}
|
|
560
696
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
697
|
+
//#endregion
|
|
698
|
+
//#region ../../node_modules/.pnpm/@bufbuild+protobuf@2.17.0/node_modules/@bufbuild/protobuf/dist/esm/proto-int64.js
|
|
699
|
+
/**
|
|
700
|
+
* Int64Support for the current environment.
|
|
701
|
+
*/
|
|
702
|
+
const protoInt64 = /* @__PURE__ */ makeInt64Support();
|
|
703
|
+
function makeInt64Support() {
|
|
704
|
+
const dv = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
705
|
+
if (typeof BigInt === "function" && typeof dv.getBigInt64 === "function" && typeof dv.getBigUint64 === "function" && typeof dv.setBigInt64 === "function" && typeof dv.setBigUint64 === "function" && (!!globalThis.Deno || !!globalThis.Bun || typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1")) {
|
|
706
|
+
const MIN = BigInt("-9223372036854775808");
|
|
707
|
+
const MAX = BigInt("9223372036854775807");
|
|
708
|
+
const UMIN = BigInt("0");
|
|
709
|
+
const UMAX = BigInt("18446744073709551615");
|
|
710
|
+
return {
|
|
711
|
+
zero: BigInt(0),
|
|
712
|
+
supported: true,
|
|
713
|
+
parse(value) {
|
|
714
|
+
const bi = typeof value == "bigint" ? value : BigInt(value);
|
|
715
|
+
if (bi > MAX || bi < MIN) throw new Error(`invalid int64: ${value}`);
|
|
716
|
+
return bi;
|
|
717
|
+
},
|
|
718
|
+
uParse(value) {
|
|
719
|
+
const bi = typeof value == "bigint" ? value : BigInt(value);
|
|
720
|
+
if (bi > UMAX || bi < UMIN) throw new Error(`invalid uint64: ${value}`);
|
|
721
|
+
return bi;
|
|
722
|
+
},
|
|
723
|
+
enc(value) {
|
|
724
|
+
dv.setBigInt64(0, this.parse(value), true);
|
|
725
|
+
return {
|
|
726
|
+
lo: dv.getInt32(0, true),
|
|
727
|
+
hi: dv.getInt32(4, true)
|
|
728
|
+
};
|
|
729
|
+
},
|
|
730
|
+
uEnc(value) {
|
|
731
|
+
dv.setBigInt64(0, this.uParse(value), true);
|
|
732
|
+
return {
|
|
733
|
+
lo: dv.getInt32(0, true),
|
|
734
|
+
hi: dv.getInt32(4, true)
|
|
735
|
+
};
|
|
736
|
+
},
|
|
737
|
+
dec(lo, hi) {
|
|
738
|
+
dv.setInt32(0, lo, true);
|
|
739
|
+
dv.setInt32(4, hi, true);
|
|
740
|
+
return dv.getBigInt64(0, true);
|
|
741
|
+
},
|
|
742
|
+
uDec(lo, hi) {
|
|
743
|
+
dv.setInt32(0, lo, true);
|
|
744
|
+
dv.setInt32(4, hi, true);
|
|
745
|
+
return dv.getBigUint64(0, true);
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
return {
|
|
750
|
+
zero: "0",
|
|
751
|
+
supported: false,
|
|
752
|
+
parse(value) {
|
|
753
|
+
if (typeof value != "string") value = value.toString();
|
|
754
|
+
assertInt64String(value);
|
|
755
|
+
return value;
|
|
756
|
+
},
|
|
757
|
+
uParse(value) {
|
|
758
|
+
if (typeof value != "string") value = value.toString();
|
|
759
|
+
assertUInt64String(value);
|
|
760
|
+
return value;
|
|
761
|
+
},
|
|
762
|
+
enc(value) {
|
|
763
|
+
if (typeof value != "string") value = value.toString();
|
|
764
|
+
assertInt64String(value);
|
|
765
|
+
return int64FromString(value);
|
|
766
|
+
},
|
|
767
|
+
uEnc(value) {
|
|
768
|
+
if (typeof value != "string") value = value.toString();
|
|
769
|
+
assertUInt64String(value);
|
|
770
|
+
return int64FromString(value);
|
|
771
|
+
},
|
|
772
|
+
dec(lo, hi) {
|
|
773
|
+
return int64ToString(lo, hi);
|
|
774
|
+
},
|
|
775
|
+
uDec(lo, hi) {
|
|
776
|
+
return uInt64ToString(lo, hi);
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
function assertInt64String(value) {
|
|
781
|
+
if (!/^-?[0-9]+$/.test(value)) throw new Error("invalid int64: " + value);
|
|
782
|
+
}
|
|
783
|
+
function assertUInt64String(value) {
|
|
784
|
+
if (!/^[0-9]+$/.test(value)) throw new Error("invalid uint64: " + value);
|
|
785
|
+
}
|
|
567
786
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
787
|
+
//#endregion
|
|
788
|
+
//#region ../../node_modules/.pnpm/@bufbuild+protobuf@2.17.0/node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.js
|
|
789
|
+
let te;
|
|
790
|
+
/**
|
|
791
|
+
* Protobuf-ES requires the Text Encoding API to convert UTF-8 from and to
|
|
792
|
+
* binary. This WHATWG API is widely available, but it is not part of the
|
|
793
|
+
* ECMAScript standard. This function used to be the way to supply an
|
|
794
|
+
* implementation on runtimes that do not provide one.
|
|
795
|
+
*
|
|
796
|
+
* It only configures the copy of the library it is imported from. To provide
|
|
797
|
+
* the encoding API for every copy of Protobuf-ES in an isolate, install
|
|
798
|
+
* `TextEncoder` (with the methods `encode` and optionally `encodeInto`) and
|
|
799
|
+
* `TextDecoder` (with the `fatal: true` and `ignoreBOM: true` constructor
|
|
800
|
+
* arguments and the `decode` method) on `globalThis`.
|
|
801
|
+
*
|
|
802
|
+
* Providing `encodeUtf8Into` is optional for backwards compatibility. If it
|
|
803
|
+
* is omitted, we emulate it with a wrapper that calls `encodeUtf8`.
|
|
804
|
+
*
|
|
805
|
+
* Note that the Text Encoding API does not provide a way to validate UTF-8.
|
|
806
|
+
* Our implementation uses String.prototype.isWellFormed, and falls back
|
|
807
|
+
* to use encodeURIComponent().
|
|
808
|
+
*
|
|
809
|
+
* @deprecated Install `TextEncoder` and `TextDecoder` on `globalThis` instead.
|
|
810
|
+
*/
|
|
811
|
+
function configureTextEncoding(textEncoding) {
|
|
812
|
+
var _a;
|
|
813
|
+
te = Object.assign(Object.assign({}, textEncoding), { encodeUtf8Into: (_a = textEncoding.encodeUtf8Into) !== null && _a !== void 0 ? _a : emulateEncodeInto(textEncoding.encodeUtf8.bind(textEncoding)) });
|
|
814
|
+
}
|
|
815
|
+
function getTextEncoding() {
|
|
816
|
+
if (!te) {
|
|
817
|
+
const globals = globalThis;
|
|
818
|
+
if (!globals.TextEncoder || !globals.TextDecoder) throw new Error("encoding API missing: install TextEncoder and TextDecoder on globalThis");
|
|
819
|
+
const textEncoder = new globals.TextEncoder();
|
|
820
|
+
const textDecoder = new globals.TextDecoder("utf-8", { ignoreBOM: true });
|
|
821
|
+
let textDecoderStrict;
|
|
822
|
+
const config = {
|
|
823
|
+
encodeUtf8(text) {
|
|
824
|
+
return textEncoder.encode(text);
|
|
825
|
+
},
|
|
826
|
+
decodeUtf8(bytes, strict) {
|
|
827
|
+
if (strict) {
|
|
828
|
+
if (!textDecoderStrict) textDecoderStrict = new globals.TextDecoder("utf-8", {
|
|
829
|
+
fatal: true,
|
|
830
|
+
ignoreBOM: true
|
|
831
|
+
});
|
|
832
|
+
return textDecoderStrict.decode(bytes);
|
|
833
|
+
}
|
|
834
|
+
return textDecoder.decode(bytes);
|
|
835
|
+
},
|
|
836
|
+
checkUtf8(text) {
|
|
837
|
+
try {
|
|
838
|
+
return true;
|
|
839
|
+
} catch (_) {
|
|
840
|
+
return false;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
if (textEncoder.encodeInto) config.encodeUtf8Into = textEncoder.encodeInto.bind(textEncoder);
|
|
845
|
+
const nativeStringIsWellFormed = String.prototype.isWellFormed;
|
|
846
|
+
if (nativeStringIsWellFormed) config.checkUtf8 = (text) => {
|
|
847
|
+
return nativeStringIsWellFormed.call(text);
|
|
848
|
+
};
|
|
849
|
+
configureTextEncoding(config);
|
|
850
|
+
}
|
|
851
|
+
return te;
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Simplistic polyfill for encodeUtf8Into.
|
|
855
|
+
*
|
|
856
|
+
* @private
|
|
857
|
+
*/
|
|
858
|
+
function emulateEncodeInto(encodeUtf8) {
|
|
859
|
+
return (text, dest) => {
|
|
860
|
+
const bytes = encodeUtf8(text);
|
|
861
|
+
dest.set(bytes);
|
|
862
|
+
return { written: bytes.byteLength };
|
|
863
|
+
};
|
|
864
|
+
}
|
|
571
865
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
866
|
+
//#endregion
|
|
867
|
+
//#region ../../node_modules/.pnpm/@bufbuild+protobuf@2.17.0/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js
|
|
868
|
+
/**
|
|
869
|
+
* Protobuf binary format wire types.
|
|
870
|
+
*
|
|
871
|
+
* A wire type provides just enough information to find the length of the
|
|
872
|
+
* following value.
|
|
873
|
+
*
|
|
874
|
+
* See https://developers.google.com/protocol-buffers/docs/encoding#structure
|
|
875
|
+
*/
|
|
876
|
+
var WireType;
|
|
877
|
+
(function(WireType) {
|
|
878
|
+
/**
|
|
879
|
+
* Used for int32, int64, uint32, uint64, sint32, sint64, bool, enum
|
|
880
|
+
*/
|
|
881
|
+
WireType[WireType["Varint"] = 0] = "Varint";
|
|
882
|
+
/**
|
|
883
|
+
* Used for fixed64, sfixed64, double.
|
|
884
|
+
* Always 8 bytes with little-endian byte order.
|
|
885
|
+
*/
|
|
886
|
+
WireType[WireType["Bit64"] = 1] = "Bit64";
|
|
887
|
+
/**
|
|
888
|
+
* Used for string, bytes, embedded messages, packed repeated fields
|
|
889
|
+
*
|
|
890
|
+
* Only repeated numeric types (types which use the varint, 32-bit,
|
|
891
|
+
* or 64-bit wire types) can be packed. In proto3, such fields are
|
|
892
|
+
* packed by default.
|
|
893
|
+
*/
|
|
894
|
+
WireType[WireType["LengthDelimited"] = 2] = "LengthDelimited";
|
|
895
|
+
/**
|
|
896
|
+
* Start of a tag-delimited aggregate, such as a proto2 group, or a message
|
|
897
|
+
* in editions with message_encoding = DELIMITED.
|
|
898
|
+
*/
|
|
899
|
+
WireType[WireType["StartGroup"] = 3] = "StartGroup";
|
|
900
|
+
/**
|
|
901
|
+
* End of a tag-delimited aggregate.
|
|
902
|
+
*/
|
|
903
|
+
WireType[WireType["EndGroup"] = 4] = "EndGroup";
|
|
904
|
+
/**
|
|
905
|
+
* Used for fixed32, sfixed32, float.
|
|
906
|
+
* Always 4 bytes with little-endian byte order.
|
|
907
|
+
*/
|
|
908
|
+
WireType[WireType["Bit32"] = 5] = "Bit32";
|
|
909
|
+
})(WireType || (WireType = {}));
|
|
910
|
+
/**
|
|
911
|
+
* Maximum value for an unsigned 32-bit integer (Protobuf UINT32, FIXED32).
|
|
912
|
+
*/
|
|
913
|
+
const UINT32_MAX = 4294967295;
|
|
914
|
+
/**
|
|
915
|
+
* Maximum value for a signed 32-bit integer (Protobuf INT32, SFIXED32, SINT32).
|
|
916
|
+
*/
|
|
917
|
+
const INT32_MAX = 2147483647;
|
|
918
|
+
/**
|
|
919
|
+
* Minimum value for a signed 32-bit integer (Protobuf INT32, SFIXED32, SINT32).
|
|
920
|
+
*/
|
|
921
|
+
const INT32_MIN = -2147483648;
|
|
922
|
+
var BinaryWriter = class {
|
|
923
|
+
constructor(encodeUtf8) {
|
|
924
|
+
/**
|
|
925
|
+
* Previous fork positions (the write position at the time
|
|
926
|
+
* `fork()` was called).
|
|
927
|
+
*/
|
|
928
|
+
this.stackPos = [];
|
|
929
|
+
this.encodeUtf8Into = encodeUtf8 ? emulateEncodeInto(encodeUtf8) : getTextEncoding().encodeUtf8Into;
|
|
930
|
+
this.buffer = EMPTY_BUFFER;
|
|
931
|
+
this.viewCache = EMPTY_VIEW;
|
|
932
|
+
this.pos = 0;
|
|
933
|
+
}
|
|
934
|
+
ensureCapacity(size) {
|
|
935
|
+
const required = this.pos + size;
|
|
936
|
+
if (required > this.buffer.length) {
|
|
937
|
+
let newLen = this.buffer.length || INITIAL_SIZE;
|
|
938
|
+
while (newLen < required) newLen *= 2;
|
|
939
|
+
const newBuf = new Uint8Array(newLen);
|
|
940
|
+
if (this.pos > 0) newBuf.set(this.buffer);
|
|
941
|
+
this.buffer = newBuf;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* The DataView over `buffer`, rebuilt only if the buffer has grown since it
|
|
946
|
+
* was last used.
|
|
947
|
+
*/
|
|
948
|
+
view() {
|
|
949
|
+
const bytes = this.buffer;
|
|
950
|
+
const view = this.viewCache;
|
|
951
|
+
if (view.byteLength === bytes.byteLength) return view;
|
|
952
|
+
const newView = new DataView(bytes.buffer);
|
|
953
|
+
this.viewCache = newView;
|
|
954
|
+
return newView;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Return all bytes written and reset this writer.
|
|
958
|
+
*/
|
|
959
|
+
finish() {
|
|
960
|
+
const result = this.buffer.slice(0, this.pos);
|
|
961
|
+
this.pos = 0;
|
|
962
|
+
this.stackPos = [];
|
|
963
|
+
return result;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Start a new fork for length-delimited data like a message
|
|
967
|
+
* or a packed repeated field.
|
|
968
|
+
*
|
|
969
|
+
* Must be joined later with `join()`.
|
|
970
|
+
*/
|
|
971
|
+
fork() {
|
|
972
|
+
this.stackPos.push(this.pos);
|
|
973
|
+
this.ensureCapacity(DEFAULT_LEN_PREFIX_SIZE);
|
|
974
|
+
this.buffer[this.pos++] = 0;
|
|
975
|
+
return this;
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Join the last fork. Write its length and bytes, then
|
|
979
|
+
* return to the previous state.
|
|
980
|
+
*/
|
|
981
|
+
join() {
|
|
982
|
+
const forkPos = this.stackPos.pop();
|
|
983
|
+
if (forkPos === void 0) throw new Error("invalid state, fork stack empty");
|
|
984
|
+
const len = this.pos - forkPos - DEFAULT_LEN_PREFIX_SIZE;
|
|
985
|
+
const lenPrefixSize = varint32Size(len);
|
|
986
|
+
if (lenPrefixSize > DEFAULT_LEN_PREFIX_SIZE) {
|
|
987
|
+
this.ensureCapacity(lenPrefixSize - DEFAULT_LEN_PREFIX_SIZE);
|
|
988
|
+
this.buffer.copyWithin(forkPos + lenPrefixSize, forkPos + DEFAULT_LEN_PREFIX_SIZE, this.pos);
|
|
989
|
+
}
|
|
990
|
+
this.pos = forkPos;
|
|
991
|
+
this.uint32(len);
|
|
992
|
+
this.pos += len;
|
|
993
|
+
return this;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* Writes a tag (field number and wire type).
|
|
997
|
+
*
|
|
998
|
+
* Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`.
|
|
999
|
+
*
|
|
1000
|
+
* Generated code should compute the tag ahead of time and call `uint32()`.
|
|
1001
|
+
*/
|
|
1002
|
+
tag(fieldNo, type) {
|
|
1003
|
+
return this.uint32((fieldNo << 3 | type) >>> 0);
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Write a chunk of raw bytes.
|
|
1007
|
+
*/
|
|
1008
|
+
raw(chunk) {
|
|
1009
|
+
this.ensureCapacity(chunk.length);
|
|
1010
|
+
this.buffer.set(chunk, this.pos);
|
|
1011
|
+
this.pos += chunk.length;
|
|
1012
|
+
return this;
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Write a `uint32` value, an unsigned 32 bit varint.
|
|
1016
|
+
*/
|
|
1017
|
+
uint32(value) {
|
|
1018
|
+
assertUInt32(value);
|
|
1019
|
+
this.ensureCapacity(5);
|
|
1020
|
+
if (value < 128) {
|
|
1021
|
+
this.buffer[this.pos++] = value;
|
|
1022
|
+
return this;
|
|
1023
|
+
}
|
|
1024
|
+
while (value > 127) {
|
|
1025
|
+
this.buffer[this.pos++] = value & 127 | 128;
|
|
1026
|
+
value >>>= 7;
|
|
1027
|
+
}
|
|
1028
|
+
this.buffer[this.pos++] = value;
|
|
1029
|
+
return this;
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Write a `int32` value, a signed 32 bit varint.
|
|
1033
|
+
*/
|
|
1034
|
+
int32(value) {
|
|
1035
|
+
assertInt32(value);
|
|
1036
|
+
if (value >= 0) return this.uint32(value);
|
|
1037
|
+
this.ensureCapacity(10);
|
|
1038
|
+
for (let i = 0; i < 9; i++) {
|
|
1039
|
+
this.buffer[this.pos++] = value & 127 | 128;
|
|
1040
|
+
value >>= 7;
|
|
1041
|
+
}
|
|
1042
|
+
this.buffer[this.pos++] = 1;
|
|
1043
|
+
return this;
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Write a `bool` value, a varint.
|
|
1047
|
+
*/
|
|
1048
|
+
bool(value) {
|
|
1049
|
+
this.ensureCapacity(1);
|
|
1050
|
+
this.buffer[this.pos++] = value ? 1 : 0;
|
|
1051
|
+
return this;
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Write a `bytes` value, length-delimited arbitrary data.
|
|
1055
|
+
*/
|
|
1056
|
+
bytes(value) {
|
|
1057
|
+
this.uint32(value.byteLength);
|
|
1058
|
+
return this.raw(value);
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Write a `string` value, length-delimited data converted to UTF-8 text.
|
|
1062
|
+
*/
|
|
1063
|
+
string(value) {
|
|
1064
|
+
if (typeof value !== "string") value = String(value);
|
|
1065
|
+
const len = value.length;
|
|
1066
|
+
if (len <= ASCII_MAX_LENGTH) {
|
|
1067
|
+
this.ensureCapacity(len + 1);
|
|
1068
|
+
const ascii = this.buffer;
|
|
1069
|
+
let pos = this.pos;
|
|
1070
|
+
ascii[pos++] = len;
|
|
1071
|
+
let i = 0;
|
|
1072
|
+
for (; i < len; i++) {
|
|
1073
|
+
const code = value.charCodeAt(i);
|
|
1074
|
+
if (code > 127) break;
|
|
1075
|
+
ascii[pos++] = code;
|
|
1076
|
+
}
|
|
1077
|
+
if (i == len) {
|
|
1078
|
+
this.pos = pos;
|
|
1079
|
+
return this;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
this.ensureCapacity(len * 3 + 5);
|
|
1083
|
+
const lenPrefixSizeGuess = varint32Size(len);
|
|
1084
|
+
const buf = this.buffer;
|
|
1085
|
+
const start = this.pos;
|
|
1086
|
+
const { written } = this.encodeUtf8Into(value, buf.subarray(start + lenPrefixSizeGuess));
|
|
1087
|
+
const lenPrefixSize = varint32Size(written);
|
|
1088
|
+
if (lenPrefixSize != lenPrefixSizeGuess) buf.copyWithin(start + lenPrefixSize, start + lenPrefixSizeGuess, start + lenPrefixSizeGuess + written);
|
|
1089
|
+
this.uint32(written);
|
|
1090
|
+
this.pos += written;
|
|
1091
|
+
return this;
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Write a `float` value, 32-bit floating point number.
|
|
1095
|
+
*/
|
|
1096
|
+
float(value) {
|
|
1097
|
+
assertFloat32(value);
|
|
1098
|
+
this.ensureCapacity(4);
|
|
1099
|
+
this.view().setFloat32(this.pos, value, true);
|
|
1100
|
+
this.pos += 4;
|
|
1101
|
+
return this;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Write a `double` value, a 64-bit floating point number.
|
|
1105
|
+
*/
|
|
1106
|
+
double(value) {
|
|
1107
|
+
this.ensureCapacity(8);
|
|
1108
|
+
this.view().setFloat64(this.pos, value, true);
|
|
1109
|
+
this.pos += 8;
|
|
1110
|
+
return this;
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.
|
|
1114
|
+
*/
|
|
1115
|
+
fixed32(value) {
|
|
1116
|
+
assertUInt32(value);
|
|
1117
|
+
this.ensureCapacity(4);
|
|
1118
|
+
this.view().setUint32(this.pos, value, true);
|
|
1119
|
+
this.pos += 4;
|
|
1120
|
+
return this;
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
|
|
1124
|
+
*/
|
|
1125
|
+
sfixed32(value) {
|
|
1126
|
+
assertInt32(value);
|
|
1127
|
+
this.ensureCapacity(4);
|
|
1128
|
+
this.view().setInt32(this.pos, value, true);
|
|
1129
|
+
this.pos += 4;
|
|
1130
|
+
return this;
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
|
|
1134
|
+
*/
|
|
1135
|
+
sint32(value) {
|
|
1136
|
+
assertInt32(value);
|
|
1137
|
+
return this.uint32((value << 1 ^ value >> 31) >>> 0);
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Write a `sfixed64` value, a signed, fixed-length 64-bit integer.
|
|
1141
|
+
*/
|
|
1142
|
+
sfixed64(value) {
|
|
1143
|
+
const tc = protoInt64.enc(value);
|
|
1144
|
+
this.ensureCapacity(8);
|
|
1145
|
+
const view = this.view();
|
|
1146
|
+
view.setInt32(this.pos, tc.lo, true);
|
|
1147
|
+
view.setInt32(this.pos + 4, tc.hi, true);
|
|
1148
|
+
this.pos += 8;
|
|
1149
|
+
return this;
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
|
|
1153
|
+
*/
|
|
1154
|
+
fixed64(value) {
|
|
1155
|
+
const tc = protoInt64.uEnc(value);
|
|
1156
|
+
this.ensureCapacity(8);
|
|
1157
|
+
const view = this.view();
|
|
1158
|
+
view.setInt32(this.pos, tc.lo, true);
|
|
1159
|
+
view.setInt32(this.pos + 4, tc.hi, true);
|
|
1160
|
+
this.pos += 8;
|
|
1161
|
+
return this;
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Write a `int64` value, a signed 64-bit varint.
|
|
1165
|
+
*/
|
|
1166
|
+
int64(value) {
|
|
1167
|
+
const tc = protoInt64.enc(value);
|
|
1168
|
+
return this.writeVarint64(tc.lo, tc.hi);
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
|
|
1172
|
+
*/
|
|
1173
|
+
sint64(value) {
|
|
1174
|
+
const tc = protoInt64.enc(value), sign = tc.hi >> 31, lo = tc.lo << 1 ^ sign, hi = (tc.hi << 1 | tc.lo >>> 31) ^ sign;
|
|
1175
|
+
return this.writeVarint64(lo, hi);
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Write a `uint64` value, an unsigned 64-bit varint.
|
|
1179
|
+
*/
|
|
1180
|
+
uint64(value) {
|
|
1181
|
+
const tc = protoInt64.uEnc(value);
|
|
1182
|
+
return this.writeVarint64(tc.lo, tc.hi);
|
|
1183
|
+
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Write a 64-bit varint directly into the buffer. Accepts the value as
|
|
1186
|
+
* split low/high 32-bit words.
|
|
1187
|
+
*
|
|
1188
|
+
* Ported from varint64write() to avoid the intermediate number[] buffer.
|
|
1189
|
+
* See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/writer.js#L344
|
|
1190
|
+
*/
|
|
1191
|
+
writeVarint64(lo, hi) {
|
|
1192
|
+
this.ensureCapacity(10);
|
|
1193
|
+
const buf = this.buffer;
|
|
1194
|
+
let pos = this.pos;
|
|
1195
|
+
for (let i = 0; i < 28; i = i + 7) {
|
|
1196
|
+
const shift = lo >>> i;
|
|
1197
|
+
const hasNext = !(shift >>> 7 == 0 && hi == 0);
|
|
1198
|
+
buf[pos++] = (hasNext ? shift | 128 : shift) & 255;
|
|
1199
|
+
if (!hasNext) {
|
|
1200
|
+
this.pos = pos;
|
|
1201
|
+
return this;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
const splitBits = lo >>> 28 & 15 | (hi & 7) << 4;
|
|
1205
|
+
const hasMoreBits = !(hi >> 3 == 0);
|
|
1206
|
+
buf[pos++] = (hasMoreBits ? splitBits | 128 : splitBits) & 255;
|
|
1207
|
+
if (!hasMoreBits) {
|
|
1208
|
+
this.pos = pos;
|
|
1209
|
+
return this;
|
|
1210
|
+
}
|
|
1211
|
+
for (let i = 3; i < 31; i = i + 7) {
|
|
1212
|
+
const shift = hi >>> i;
|
|
1213
|
+
const hasNext = !(shift >>> 7 == 0);
|
|
1214
|
+
buf[pos++] = (hasNext ? shift | 128 : shift) & 255;
|
|
1215
|
+
if (!hasNext) {
|
|
1216
|
+
this.pos = pos;
|
|
1217
|
+
return this;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
buf[pos++] = hi >>> 31 & 1;
|
|
1221
|
+
this.pos = pos;
|
|
1222
|
+
return this;
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
/**
|
|
1226
|
+
* Capacity of the buffer allocated by the first write..
|
|
1227
|
+
*/
|
|
1228
|
+
const INITIAL_SIZE = 128;
|
|
1229
|
+
/**
|
|
1230
|
+
* Bytes `fork()` reserves for the length prefix, betting that the payload will
|
|
1231
|
+
* be under 128 bytes. `join()` fills them in, and widens them if the bet was
|
|
1232
|
+
* wrong.
|
|
1233
|
+
*/
|
|
1234
|
+
const DEFAULT_LEN_PREFIX_SIZE = 1;
|
|
1235
|
+
/**
|
|
1236
|
+
* Shared empty buffer used as the initial value before the first write.
|
|
1237
|
+
* Avoids allocating and zeroing `INITIAL_SIZE` bytes per BinaryWriter when a
|
|
1238
|
+
* writer is only used for a tiny message (or not used at all).
|
|
1239
|
+
*/
|
|
1240
|
+
const EMPTY_BUFFER = new Uint8Array(0);
|
|
1241
|
+
/**
|
|
1242
|
+
* Shared empty view, paired with `EMPTY_BUFFER`. Never written to: any
|
|
1243
|
+
* fixed-width write first grows the buffer, which replaces this view.
|
|
1244
|
+
*/
|
|
1245
|
+
const EMPTY_VIEW = new DataView(EMPTY_BUFFER.buffer);
|
|
1246
|
+
/**
|
|
1247
|
+
* Longest string on the ASCII fast paths. Must stay below 0x80, so
|
|
1248
|
+
* that the writer's length prefix always fits a single varint byte.
|
|
1249
|
+
*/
|
|
1250
|
+
const ASCII_MAX_LENGTH = 32;
|
|
1251
|
+
/**
|
|
1252
|
+
* Number of bytes needed to encode `value` as an unsigned 32-bit varint.
|
|
1253
|
+
*/
|
|
1254
|
+
function varint32Size(value) {
|
|
1255
|
+
if (value < 128) return 1;
|
|
1256
|
+
if (value < 16384) return 2;
|
|
1257
|
+
if (value < 2097152) return 3;
|
|
1258
|
+
if (value < 268435456) return 4;
|
|
1259
|
+
return 5;
|
|
1260
|
+
}
|
|
1261
|
+
var BinaryReader = class {
|
|
1262
|
+
constructor(buf, decodeUtf8 = getTextEncoding().decodeUtf8) {
|
|
1263
|
+
this.decodeUtf8 = decodeUtf8;
|
|
1264
|
+
this.varint64Lo = 0;
|
|
1265
|
+
this.varint64Hi = 0;
|
|
1266
|
+
this.varint64 = varint64read;
|
|
1267
|
+
/**
|
|
1268
|
+
* Read a `uint32` field, an unsigned 32 bit varint.
|
|
1269
|
+
*/
|
|
1270
|
+
this.uint32 = varint32read;
|
|
1271
|
+
this.buf = buf;
|
|
1272
|
+
this.len = buf.length;
|
|
1273
|
+
this.pos = 0;
|
|
1274
|
+
this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* Reads a tag - field number and wire type. Tags are uint32 varints; values
|
|
1278
|
+
* that do not fit in uint32 are rejected.
|
|
1279
|
+
*/
|
|
1280
|
+
tag() {
|
|
1281
|
+
const start = this.pos;
|
|
1282
|
+
const tag = this.uint32();
|
|
1283
|
+
const bytesRead = this.pos - start;
|
|
1284
|
+
if (bytesRead > 5 || bytesRead == 5 && this.buf[this.pos - 1] > 15) throw new Error("illegal tag: varint overflows uint32");
|
|
1285
|
+
const fieldNo = tag >>> 3;
|
|
1286
|
+
const wireType = tag & 7;
|
|
1287
|
+
if (fieldNo <= 0 || wireType > 5) throw new Error("illegal tag: field no " + fieldNo + " wire type " + wireType);
|
|
1288
|
+
return [fieldNo, wireType];
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Skip one element and return the skipped data.
|
|
1292
|
+
*
|
|
1293
|
+
* When skipping StartGroup, provide the tags field number to check for
|
|
1294
|
+
* matching field number in the EndGroup tag. Recursion into nested groups
|
|
1295
|
+
* is guarded by the `recursionLimit` argument: When the limit is reached,
|
|
1296
|
+
* this method throws.
|
|
1297
|
+
*/
|
|
1298
|
+
skip(wireType, fieldNo, recursionLimit = 100) {
|
|
1299
|
+
let start = this.pos;
|
|
1300
|
+
switch (wireType) {
|
|
1301
|
+
case WireType.Varint:
|
|
1302
|
+
while (this.buf[this.pos++] & 128);
|
|
1303
|
+
break;
|
|
1304
|
+
case WireType.Bit64: this.pos += 4;
|
|
1305
|
+
case WireType.Bit32:
|
|
1306
|
+
this.pos += 4;
|
|
1307
|
+
break;
|
|
1308
|
+
case WireType.LengthDelimited:
|
|
1309
|
+
let len = this.uint32();
|
|
1310
|
+
this.pos += len;
|
|
1311
|
+
break;
|
|
1312
|
+
case WireType.StartGroup:
|
|
1313
|
+
if (recursionLimit <= 0) throw new Error("maximum recursion depth reached");
|
|
1314
|
+
for (;;) {
|
|
1315
|
+
const [fn, wt] = this.tag();
|
|
1316
|
+
if (wt === WireType.EndGroup) {
|
|
1317
|
+
if (fieldNo !== void 0 && fn !== fieldNo) throw new Error("invalid end group tag");
|
|
1318
|
+
break;
|
|
1319
|
+
}
|
|
1320
|
+
this.skip(wt, fn, recursionLimit - 1);
|
|
1321
|
+
}
|
|
1322
|
+
break;
|
|
1323
|
+
default: throw new Error("cant skip wire type " + wireType);
|
|
1324
|
+
}
|
|
1325
|
+
this.assertBounds();
|
|
1326
|
+
return this.buf.subarray(start, this.pos);
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Throws error if position in byte array is out of range.
|
|
1330
|
+
*/
|
|
1331
|
+
assertBounds() {
|
|
1332
|
+
if (this.pos > this.len) throw new RangeError("premature EOF");
|
|
1333
|
+
}
|
|
1334
|
+
/**
|
|
1335
|
+
* Read a `int32` field, a signed 32 bit varint.
|
|
1336
|
+
*/
|
|
1337
|
+
int32() {
|
|
1338
|
+
return this.uint32() | 0;
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.
|
|
1342
|
+
*/
|
|
1343
|
+
sint32() {
|
|
1344
|
+
let zze = this.uint32();
|
|
1345
|
+
return zze >>> 1 ^ -(zze & 1);
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Read a `int64` field, a signed 64-bit varint.
|
|
1349
|
+
*/
|
|
1350
|
+
int64() {
|
|
1351
|
+
this.varint64();
|
|
1352
|
+
return protoInt64.dec(this.varint64Lo, this.varint64Hi);
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Read a `uint64` field, an unsigned 64-bit varint.
|
|
1356
|
+
*/
|
|
1357
|
+
uint64() {
|
|
1358
|
+
this.varint64();
|
|
1359
|
+
return protoInt64.uDec(this.varint64Lo, this.varint64Hi);
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
|
|
1363
|
+
*/
|
|
1364
|
+
sint64() {
|
|
1365
|
+
this.varint64();
|
|
1366
|
+
let lo = this.varint64Lo;
|
|
1367
|
+
let hi = this.varint64Hi;
|
|
1368
|
+
let s = -(lo & 1);
|
|
1369
|
+
lo = (lo >>> 1 | (hi & 1) << 31) ^ s;
|
|
1370
|
+
hi = hi >>> 1 ^ s;
|
|
1371
|
+
return protoInt64.dec(lo, hi);
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Read a `bool` field, a variant.
|
|
1375
|
+
*/
|
|
1376
|
+
bool() {
|
|
1377
|
+
const b = this.buf[this.pos];
|
|
1378
|
+
if (b < 128) {
|
|
1379
|
+
this.pos++;
|
|
1380
|
+
return b !== 0;
|
|
1381
|
+
}
|
|
1382
|
+
this.varint64();
|
|
1383
|
+
return this.varint64Lo !== 0 || this.varint64Hi !== 0;
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.
|
|
1387
|
+
*/
|
|
1388
|
+
fixed32() {
|
|
1389
|
+
return this.view.getUint32((this.pos += 4) - 4, true);
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Read a `sfixed32` field, a signed, fixed-length 32-bit integer.
|
|
1393
|
+
*/
|
|
1394
|
+
sfixed32() {
|
|
1395
|
+
return this.view.getInt32((this.pos += 4) - 4, true);
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
|
|
1399
|
+
*/
|
|
1400
|
+
fixed64() {
|
|
1401
|
+
return protoInt64.uDec(this.sfixed32(), this.sfixed32());
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* Read a `fixed64` field, a signed, fixed-length 64-bit integer.
|
|
1405
|
+
*/
|
|
1406
|
+
sfixed64() {
|
|
1407
|
+
return protoInt64.dec(this.sfixed32(), this.sfixed32());
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Read a `float` field, 32-bit floating point number.
|
|
1411
|
+
*/
|
|
1412
|
+
float() {
|
|
1413
|
+
return this.view.getFloat32((this.pos += 4) - 4, true);
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Read a `double` field, a 64-bit floating point number.
|
|
1417
|
+
*/
|
|
1418
|
+
double() {
|
|
1419
|
+
return this.view.getFloat64((this.pos += 8) - 8, true);
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Read a `bytes` field, length-delimited arbitrary data.
|
|
1423
|
+
*/
|
|
1424
|
+
bytes() {
|
|
1425
|
+
let len = this.uint32(), start = this.pos;
|
|
1426
|
+
this.pos += len;
|
|
1427
|
+
this.assertBounds();
|
|
1428
|
+
return this.buf.subarray(start, start + len);
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1431
|
+
* Read a `string` field, length-delimited data converted to UTF-8 text. If
|
|
1432
|
+
* `strict` is true, throw on invalid UTF-8 instead of substituting U+FFFD.
|
|
1433
|
+
*/
|
|
1434
|
+
string(strict) {
|
|
1435
|
+
const len = this.uint32();
|
|
1436
|
+
const start = this.pos;
|
|
1437
|
+
this.pos += len;
|
|
1438
|
+
this.assertBounds();
|
|
1439
|
+
const buf = this.buf;
|
|
1440
|
+
if (len <= ASCII_MAX_LENGTH) {
|
|
1441
|
+
const codes = new Array(len);
|
|
1442
|
+
for (let i = 0; i < len; i++) {
|
|
1443
|
+
const byte = buf[start + i];
|
|
1444
|
+
if (byte > 127) return this.decodeUtf8(buf.subarray(start, this.pos), strict);
|
|
1445
|
+
codes[i] = byte;
|
|
1446
|
+
}
|
|
1447
|
+
return String.fromCharCode.apply(String, codes);
|
|
1448
|
+
}
|
|
1449
|
+
return this.decodeUtf8(buf.subarray(start, this.pos), strict);
|
|
1450
|
+
}
|
|
1451
|
+
};
|
|
1452
|
+
/**
|
|
1453
|
+
* Assert a valid signed protobuf 32-bit integer as a number or string.
|
|
1454
|
+
*/
|
|
1455
|
+
function assertInt32(arg) {
|
|
1456
|
+
if (typeof arg == "string") arg = Number(arg);
|
|
1457
|
+
else if (typeof arg != "number") throw new Error("invalid int32: " + typeof arg);
|
|
1458
|
+
if (!Number.isInteger(arg) || arg > 2147483647 || arg < -2147483648) throw new Error("invalid int32: " + arg);
|
|
1459
|
+
}
|
|
1460
|
+
/**
|
|
1461
|
+
* Assert a valid unsigned protobuf 32-bit integer as a number or string.
|
|
1462
|
+
*/
|
|
1463
|
+
function assertUInt32(arg) {
|
|
1464
|
+
if (typeof arg == "string") arg = Number(arg);
|
|
1465
|
+
else if (typeof arg != "number") throw new Error("invalid uint32: " + typeof arg);
|
|
1466
|
+
if (!Number.isInteger(arg) || arg > 4294967295 || arg < 0) throw new Error("invalid uint32: " + arg);
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Assert a valid protobuf float32 value as a number or string.
|
|
1470
|
+
*/
|
|
1471
|
+
function assertFloat32(arg) {
|
|
1472
|
+
if (typeof arg == "string") {
|
|
1473
|
+
const o = arg;
|
|
1474
|
+
arg = Number(arg);
|
|
1475
|
+
if (Number.isNaN(arg) && o !== "NaN") throw new Error("invalid float32: " + o);
|
|
1476
|
+
} else if (typeof arg != "number") throw new Error("invalid float32: " + typeof arg);
|
|
1477
|
+
if (!Number.isFinite(Math.fround(arg)) && Number.isFinite(arg)) throw new Error("invalid float32: " + arg);
|
|
1478
|
+
}
|
|
679
1479
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
1480
|
+
//#endregion
|
|
1481
|
+
//#region src/protobuf.ts
|
|
1482
|
+
const utf8Decoder = new TextDecoder("utf-8");
|
|
1483
|
+
function toUint8Array(value) {
|
|
1484
|
+
if (value instanceof Uint8Array) return value;
|
|
1485
|
+
return Uint8Array.from(value);
|
|
1486
|
+
}
|
|
1487
|
+
function classifyWireError(error) {
|
|
1488
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1489
|
+
if (/invalid field|illegal tag.*field no 0/i.test(message)) return new Error("Unsupported AGY native metadata field", { cause: error });
|
|
1490
|
+
if (/invalid varint/i.test(message)) return new Error("Unsupported AGY native metadata encoding", { cause: error });
|
|
1491
|
+
if (error instanceof RangeError || /premature eof|beyond end|out of range|eof/i.test(message)) return new Error("Truncated AGY native metadata", { cause: error });
|
|
1492
|
+
return new Error("Unsupported AGY native metadata encoding", { cause: error });
|
|
1493
|
+
}
|
|
1494
|
+
function nativeBytesAt(value, path, optionalLast = false, repeatedLast = false) {
|
|
1495
|
+
let bytes = toUint8Array(value);
|
|
1496
|
+
for (const [index, field] of path.entries()) {
|
|
1497
|
+
const reader = new BinaryReader(bytes);
|
|
1498
|
+
let selected;
|
|
1499
|
+
const repeated = [];
|
|
1500
|
+
const last = index === path.length - 1;
|
|
1501
|
+
while (reader.pos < reader.len) {
|
|
1502
|
+
let fieldNo;
|
|
1503
|
+
let wireType;
|
|
1504
|
+
try {
|
|
1505
|
+
[fieldNo, wireType] = reader.tag();
|
|
1506
|
+
} catch (error) {
|
|
1507
|
+
throw classifyWireError(error);
|
|
1508
|
+
}
|
|
1509
|
+
if (!fieldNo) throw new Error("Unsupported AGY native metadata field");
|
|
1510
|
+
if (wireType === WireType.Varint || wireType === WireType.Bit64 || wireType === WireType.Bit32) try {
|
|
1511
|
+
reader.skip(wireType);
|
|
1512
|
+
} catch (error) {
|
|
1513
|
+
throw classifyWireError(error);
|
|
1514
|
+
}
|
|
1515
|
+
else if (wireType === WireType.LengthDelimited) {
|
|
1516
|
+
let slice;
|
|
1517
|
+
try {
|
|
1518
|
+
slice = reader.bytes();
|
|
1519
|
+
} catch (error) {
|
|
1520
|
+
throw classifyWireError(error);
|
|
1521
|
+
}
|
|
1522
|
+
if (fieldNo === field) if (repeatedLast && last) repeated.push(utf8Decoder.decode(slice));
|
|
1523
|
+
else if (selected !== void 0) throw new Error("Ambiguous AGY native metadata binding");
|
|
1524
|
+
else selected = slice;
|
|
1525
|
+
} else throw new Error("Unsupported AGY native metadata wire type");
|
|
1526
|
+
}
|
|
1527
|
+
if (repeatedLast && last) {
|
|
1528
|
+
if (repeated.length === 0 && !optionalLast) throw new Error("Unconfirmed AGY native metadata binding");
|
|
1529
|
+
return repeated;
|
|
1530
|
+
}
|
|
1531
|
+
if (selected === void 0) {
|
|
1532
|
+
if (optionalLast) return repeatedLast ? [] : void 0;
|
|
1533
|
+
throw new Error("Unconfirmed AGY native metadata binding");
|
|
1534
|
+
}
|
|
1535
|
+
bytes = selected;
|
|
1536
|
+
}
|
|
1537
|
+
return utf8Decoder.decode(bytes);
|
|
1538
|
+
}
|
|
1539
|
+
function nativeStringsAt(value, path, optionalLast = false) {
|
|
1540
|
+
return nativeBytesAt(value, path, optionalLast, true);
|
|
1541
|
+
}
|
|
1542
|
+
function encodeNativeMessage(fields) {
|
|
1543
|
+
const writer = new BinaryWriter();
|
|
1544
|
+
for (const field of fields) switch (field.kind) {
|
|
1545
|
+
case "string":
|
|
1546
|
+
writer.tag(field.fieldNo, WireType.LengthDelimited).string(field.value);
|
|
1547
|
+
break;
|
|
1548
|
+
case "bytes":
|
|
1549
|
+
writer.tag(field.fieldNo, WireType.LengthDelimited).bytes(field.value);
|
|
1550
|
+
break;
|
|
1551
|
+
case "varint":
|
|
1552
|
+
writer.tag(field.fieldNo, WireType.Varint).uint32(field.value);
|
|
1553
|
+
break;
|
|
1554
|
+
case "fixed32":
|
|
1555
|
+
writer.tag(field.fieldNo, WireType.Bit32).fixed32(field.value);
|
|
1556
|
+
break;
|
|
1557
|
+
case "fixed64":
|
|
1558
|
+
writer.tag(field.fieldNo, WireType.Bit64).fixed64(field.value);
|
|
1559
|
+
break;
|
|
1560
|
+
case "message":
|
|
1561
|
+
writer.tag(field.fieldNo, WireType.LengthDelimited).bytes(encodeNativeMessage(field.fields));
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1564
|
+
return writer.finish();
|
|
1565
|
+
}
|
|
718
1566
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
1567
|
+
//#endregion
|
|
1568
|
+
//#region src/legacyRecovery.ts
|
|
1569
|
+
async function readLegacyTranscript(path) {
|
|
1570
|
+
const file = await open(path, "r");
|
|
1571
|
+
try {
|
|
1572
|
+
const before = await file.stat();
|
|
1573
|
+
if (!before.isFile() || before.size > 2 * 1048576) throw new Error("AGY legacy transcript exceeds the recovery limit");
|
|
1574
|
+
const data = Buffer.alloc(before.size + 1);
|
|
1575
|
+
const { bytesRead } = await file.read(data, 0, data.length, 0);
|
|
1576
|
+
const after = await file.stat();
|
|
1577
|
+
if (bytesRead !== before.size || before.size !== after.size || before.mtimeMs !== after.mtimeMs) throw new Error("AGY legacy transcript changed during recovery");
|
|
1578
|
+
return data.subarray(0, bytesRead).toString("utf8").trim().split("\n").map((line) => JSON.parse(line));
|
|
1579
|
+
} finally {
|
|
1580
|
+
await file.close();
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
async function readLegacyNativeRecovery({ nativeHome, cwd, additionalDirectories = [], sessionId, proof, model }) {
|
|
1584
|
+
const extraDirs = proof?.additionalDirectories ?? [];
|
|
1585
|
+
const disclosedCwd = proof?.disclosedCwd;
|
|
1586
|
+
const terminalError = proof?.terminalError ?? "There was a network issue connecting to the server, please try again.";
|
|
1587
|
+
if (proof?.version !== 1 || proof.sessionId !== sessionId || !NATIVE_ID.test(sessionId) || !NATIVE_ID.test(proof.conversationId) || !isAbsolute(cwd) || !Array.isArray(additionalDirectories) || additionalDirectories.some((dir) => typeof dir !== "string" || !isAbsolute(dir)) || !Array.isArray(extraDirs) || extraDirs.some((dir) => typeof dir !== "string" || !isAbsolute(dir)) || disclosedCwd !== void 0 && (typeof disclosedCwd !== "string" || !isAbsolute(disclosedCwd)) || proof.model !== model || typeof proof.effort !== "string" || typeof terminalError !== "string" || !terminalError.trim() || /^(?:interrupted|canceled|cancelled)$/i.test(terminalError.trim()) || !Array.isArray(proof.tools) || !proof.tools.length || proof.tools.length > 1e3 || proof.tools.some((tool) => !Number.isSafeInteger(tool?.stepIndex) || tool.stepIndex < 0 || !NATIVE_TOOL_NAME.test(tool.name ?? "") || tool.failed !== void 0 && tool.failed !== true || tool.error !== void 0 && (typeof tool.error !== "string" || !tool.error.trim())) || new Set(proof.tools.map((tool) => tool.stepIndex)).size !== proof.tools.length) throw new Error("AGY legacy load requires an exact original session and completed native tool mapping");
|
|
1588
|
+
const canonical = (value) => process.platform === "win32" ? resolve(value).toLowerCase() : resolve(value);
|
|
1589
|
+
if (disclosedCwd !== void 0 && canonical(disclosedCwd) !== canonical(cwd) || additionalDirectories.length > 0 && (disclosedCwd === void 0 || extraDirs.length !== additionalDirectories.length || extraDirs.some((dir, index) => canonical(dir) !== canonical(additionalDirectories[index]))) || extraDirs.length > 0 && (extraDirs.length !== additionalDirectories.length || extraDirs.some((dir, index) => canonical(dir) !== canonical(additionalDirectories[index])))) throw new Error("AGY legacy native conversation or workspace differs from its original binding");
|
|
1590
|
+
const expectedRoots = new Set([cwd, ...additionalDirectories].map(canonical));
|
|
1591
|
+
if (expectedRoots.size !== 1 + additionalDirectories.length) throw new Error("AGY legacy native conversation or workspace differs from its original binding");
|
|
1592
|
+
const conversationId = proof.conversationId;
|
|
1593
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
1594
|
+
const db = new DatabaseSync(resolve(nativeHome, "conversations", `${conversationId}.db`), { readOnly: true });
|
|
1595
|
+
try {
|
|
1596
|
+
db.exec("BEGIN");
|
|
1597
|
+
const data = db.prepare("SELECT data FROM trajectory_metadata_blob WHERE id = ? AND length(data) <= 65536").get("main")?.data ?? new Uint8Array(0);
|
|
1598
|
+
const nativeRootUris = nativeStringsAt(data, [7]);
|
|
1599
|
+
const nativeRoots = new Set(nativeRootUris.map((uri) => canonical(fileURLToPath(uri))));
|
|
1600
|
+
if (nativeBytesAt(data, [6]) !== conversationId || nativeRootUris.length !== expectedRoots.size || nativeRoots.size !== expectedRoots.size || [...expectedRoots].some((root) => !nativeRoots.has(root))) throw new Error("AGY legacy native conversation or workspace differs from its original binding");
|
|
1601
|
+
const baseModel = proof.effort !== "engine-default" && model.endsWith(`-${proof.effort}`) ? model.slice(0, -(proof.effort.length + 1)) : model;
|
|
1602
|
+
const exactModel = (value) => value === model || value === `gemini-api://models/${model}`;
|
|
1603
|
+
const totalModels = Number(db.prepare("SELECT COUNT(*) AS count FROM (SELECT 1 FROM gen_metadata LIMIT 1001)").get()?.count ?? 0);
|
|
1604
|
+
if (totalModels === 0 || totalModels > 1e3) throw new Error("AGY legacy native model differs from its original binding");
|
|
1605
|
+
const models = db.prepare("SELECT CASE WHEN length(data) <= ? THEN data END AS data FROM gen_metadata ORDER BY idx LIMIT 1001");
|
|
1606
|
+
let rowIndex = 0;
|
|
1607
|
+
let sawModel = false;
|
|
1608
|
+
let sawExactModel = false;
|
|
1609
|
+
for (const row of models.iterate(MAX_FRAME_BYTES)) {
|
|
1610
|
+
const isLast = rowIndex === totalModels - 1;
|
|
1611
|
+
rowIndex += 1;
|
|
1612
|
+
const bytes = row.data ?? new Uint8Array(0);
|
|
1613
|
+
const name = nativeBytesAt(bytes, [1, 19], true);
|
|
1614
|
+
const uri = nativeBytesAt(bytes, [3, 28], true);
|
|
1615
|
+
if (name === void 0 && uri === void 0 && !isLast) throw new Error("AGY legacy native model differs from its original binding");
|
|
1616
|
+
if (name !== void 0 && name !== model && name !== baseModel) throw new Error("AGY legacy native model differs from its original binding");
|
|
1617
|
+
if (uri !== void 0 && !exactModel(uri)) throw new Error("AGY legacy native model differs from its original binding");
|
|
1618
|
+
if (name !== void 0 || uri !== void 0) sawModel = true;
|
|
1619
|
+
if (name === model || uri !== void 0 && exactModel(uri)) sawExactModel = true;
|
|
1620
|
+
}
|
|
1621
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type = ? AND name = ?").get("table", "executor_metadata")) {
|
|
1622
|
+
const execMeta = db.prepare("SELECT CASE WHEN length(data) <= ? THEN data END AS data FROM executor_metadata ORDER BY idx LIMIT 10");
|
|
1623
|
+
for (const row of execMeta.iterate(MAX_FRAME_BYTES)) {
|
|
1624
|
+
const uri = nativeBytesAt(row.data ?? new Uint8Array(0), [
|
|
1625
|
+
10,
|
|
1626
|
+
1,
|
|
1627
|
+
28
|
|
1628
|
+
], true);
|
|
1629
|
+
if (uri !== void 0 && !exactModel(uri)) throw new Error("AGY legacy native model differs from its original binding");
|
|
1630
|
+
if (uri !== void 0 && exactModel(uri)) sawExactModel = true;
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
if (rowIndex !== totalModels || !sawModel || !sawExactModel) throw new Error("AGY legacy native model differs from its original binding");
|
|
1634
|
+
const steps = db.prepare("SELECT idx, step_type, status FROM steps ORDER BY idx LIMIT 10001").all();
|
|
1635
|
+
const allowedStepTypes = Object.values(LEGACY_NATIVE_STEP);
|
|
1636
|
+
if (!steps.length || steps.length > 1e4 || steps.some((step, index) => step.idx !== index || !allowedStepTypes.includes(step.step_type) || (step.step_type === LEGACY_NATIVE_STEP.tool ? step.status !== 3 && step.status !== 7 : step.status !== 3)) || steps.filter((step) => step.step_type === LEGACY_NATIVE_STEP.user).length !== 1) throw new Error("AGY legacy native turn has unresolved steps or unknown steering; do not replay it");
|
|
1637
|
+
const step0Bytes = db.prepare("SELECT step_payload FROM steps WHERE idx = 0 AND length(step_payload) <= 65536").get()?.step_payload ?? new Uint8Array(0);
|
|
1638
|
+
if (proof.promptSha256 !== void 0) {
|
|
1639
|
+
const step0Text = nativeBytesAt(step0Bytes, [19, 2], true);
|
|
1640
|
+
if (typeof step0Text !== "string" || createHash("sha256").update(step0Text).digest("hex") !== proof.promptSha256) throw new Error("AGY legacy native initial prompt differs from its audited prompt digest");
|
|
1641
|
+
}
|
|
1642
|
+
const step0Uris = nativeStringsAt(step0Bytes, [
|
|
1643
|
+
19,
|
|
1644
|
+
12,
|
|
1645
|
+
12
|
|
1646
|
+
], true);
|
|
1647
|
+
if (step0Uris.length > 0) {
|
|
1648
|
+
const step0Roots = new Set(step0Uris.map((uri) => canonical(fileURLToPath(uri))));
|
|
1649
|
+
if (step0Uris.length !== expectedRoots.size || step0Roots.size !== expectedRoots.size || [...expectedRoots].some((root) => !step0Roots.has(root))) throw new Error("AGY legacy native conversation or workspace differs from its original binding");
|
|
1650
|
+
}
|
|
1651
|
+
const terminal = steps.at(-1);
|
|
1652
|
+
const terminalBytes = db.prepare("SELECT step_payload FROM steps WHERE idx = ? AND length(step_payload) <= 65536").get(terminal.idx)?.step_payload ?? new Uint8Array(0);
|
|
1653
|
+
const terminalErr1 = nativeBytesAt(terminalBytes, [
|
|
1654
|
+
24,
|
|
1655
|
+
3,
|
|
1656
|
+
1
|
|
1657
|
+
], true);
|
|
1658
|
+
const terminalErr2 = nativeBytesAt(terminalBytes, [
|
|
1659
|
+
24,
|
|
1660
|
+
3,
|
|
1661
|
+
2
|
|
1662
|
+
], true);
|
|
1663
|
+
if (terminal.step_type !== LEGACY_NATIVE_STEP.error || terminalErr1 !== terminalError && terminalErr2 !== terminalError) throw new Error("AGY legacy native turn has no confirmed terminal network failure");
|
|
1664
|
+
const toolSteps = steps.filter((step) => step.step_type === LEGACY_NATIVE_STEP.tool);
|
|
1665
|
+
const toolByIndex = new Map(toolSteps.map((step) => [step.idx, step]));
|
|
1666
|
+
if (toolByIndex.size !== proof.tools.length || proof.tools.some((tool) => !toolByIndex.has(tool.stepIndex))) throw new Error("AGY legacy native tools differ from the completed Kiki tool mapping");
|
|
1667
|
+
const selectStepPayload = db.prepare("SELECT step_payload FROM steps WHERE idx = ? AND length(step_payload) <= 65536");
|
|
1668
|
+
for (const tool of proof.tools) {
|
|
1669
|
+
const step = toolByIndex.get(tool.stepIndex);
|
|
1670
|
+
if (tool.failed === true !== (step.status === 7)) throw new Error("AGY legacy native tools differ from the completed Kiki tool mapping");
|
|
1671
|
+
const toolPayload = selectStepPayload.get(tool.stepIndex)?.step_payload ?? new Uint8Array(0);
|
|
1672
|
+
const nativeName = nativeBytesAt(toolPayload, [
|
|
1673
|
+
5,
|
|
1674
|
+
4,
|
|
1675
|
+
2
|
|
1676
|
+
], true);
|
|
1677
|
+
if (nativeName !== void 0 && nativeName !== tool.name) throw new Error("AGY legacy native tools differ from the completed Kiki tool mapping");
|
|
1678
|
+
if (tool.failed === true) {
|
|
1679
|
+
const nativeErr = nativeBytesAt(toolPayload, [31, 2], true) ?? nativeBytesAt(toolPayload, [31, 3], true);
|
|
1680
|
+
if (!nativeErr || /^tool call denied by pre-tool hook:/i.test(nativeErr.trimStart()) || tool.error !== void 0 && nativeErr !== tool.error) throw new Error("AGY legacy native tools differ from the completed Kiki tool mapping");
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
const transcript = await readLegacyTranscript(resolve(nativeHome, "brain", conversationId, ".system_generated", "logs", "transcript_full.jsonl"));
|
|
1684
|
+
const declared = transcript.flatMap((step) => step.tool_calls ?? []);
|
|
1685
|
+
const transcriptErrorStep = transcript.at(-1);
|
|
1686
|
+
const alignedErrorStep = steps[transcript.length - 1];
|
|
1687
|
+
const alignedErrorRow = alignedErrorStep?.step_type === LEGACY_NATIVE_STEP.error ? selectStepPayload.get(alignedErrorStep.idx) : void 0;
|
|
1688
|
+
const alignedErrorBytes = alignedErrorRow ? alignedErrorRow.step_payload ?? new Uint8Array(0) : void 0;
|
|
1689
|
+
const alignedErr1 = alignedErrorBytes ? nativeBytesAt(alignedErrorBytes, [
|
|
1690
|
+
24,
|
|
1691
|
+
3,
|
|
1692
|
+
1
|
|
1693
|
+
], true) : void 0;
|
|
1694
|
+
const alignedErr2 = alignedErrorBytes ? nativeBytesAt(alignedErrorBytes, [
|
|
1695
|
+
24,
|
|
1696
|
+
3,
|
|
1697
|
+
2
|
|
1698
|
+
], true) : void 0;
|
|
1699
|
+
const transcriptErrorText = typeof transcriptErrorStep?.error === "string" && transcriptErrorStep.error.trim() ? transcriptErrorStep.error : void 0;
|
|
1700
|
+
if (transcript.some((step, index) => step.step_index !== index || (step.type === "GENERIC" ? step.status !== "DONE" && step.status !== "ERROR" : step.status !== "DONE")) || transcript.length < steps.length - 1 || transcript.length > steps.length || transcriptErrorStep?.type !== "ERROR_MESSAGE" || alignedErrorStep?.step_type !== LEGACY_NATIVE_STEP.error || transcriptErrorText !== void 0 && transcriptErrorText !== alignedErr1 && transcriptErrorText !== alignedErr2 && transcriptErrorText !== terminalError || transcript.filter((step) => step.type === "USER_INPUT").length !== 1 || transcript.filter((step) => step.type === "GENERIC").length !== toolByIndex.size || declared.length !== proof.tools.length || declared.some((tool, index) => tool.name !== proof.tools[index].name) || proof.tools.some((tool) => {
|
|
1701
|
+
const entry = transcript[tool.stepIndex];
|
|
1702
|
+
return entry?.type !== "GENERIC" || (tool.failed === true ? entry.status !== "ERROR" || tool.error !== void 0 && entry.error !== tool.error : entry.status !== "DONE");
|
|
1703
|
+
})) throw new Error("AGY legacy native transcript is not fully reconciled or differs from the completed Kiki tool mapping");
|
|
1704
|
+
return {
|
|
1705
|
+
conversationId,
|
|
1706
|
+
model,
|
|
1707
|
+
effort: proof.effort
|
|
1708
|
+
};
|
|
1709
|
+
} finally {
|
|
1710
|
+
db.close();
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
async function inspectNativeErrorWatchdogState({ nativeHome, conversationId }) {
|
|
1714
|
+
if (typeof nativeHome !== "string" || !nativeHome || !NATIVE_ID.test(conversationId ?? "")) return { status: "missing_db" };
|
|
1715
|
+
const dbPath = resolve(nativeHome, "conversations", `${conversationId}.db`);
|
|
1716
|
+
let db;
|
|
1717
|
+
try {
|
|
1718
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
1719
|
+
const conn = new DatabaseSync(dbPath, { readOnly: true });
|
|
1720
|
+
db = conn;
|
|
1721
|
+
const latest = conn.prepare("SELECT idx, step_type, status, CASE WHEN length(step_payload) <= 65536 THEN step_payload END AS step_payload FROM steps ORDER BY idx DESC LIMIT 1").get();
|
|
1722
|
+
if (!latest) return { status: "no_terminal_error" };
|
|
1723
|
+
if (conn.prepare("SELECT idx, step_type, status FROM steps WHERE (step_type = ? AND status NOT IN (?, ?)) OR (step_type != ? AND status != ?) LIMIT 1").get(LEGACY_NATIVE_STEP.tool, 3, 7, LEGACY_NATIVE_STEP.tool, 3)) return { status: "incomplete_steps" };
|
|
1724
|
+
if (latest.step_type !== LEGACY_NATIVE_STEP.error) return { status: "no_terminal_error" };
|
|
1725
|
+
const bytes = latest.step_payload ?? new Uint8Array(0);
|
|
1726
|
+
const err1 = nativeBytesAt(bytes, [
|
|
1727
|
+
24,
|
|
1728
|
+
3,
|
|
1729
|
+
1
|
|
1730
|
+
], true);
|
|
1731
|
+
const err2 = nativeBytesAt(bytes, [
|
|
1732
|
+
24,
|
|
1733
|
+
3,
|
|
1734
|
+
2
|
|
1735
|
+
], true);
|
|
1736
|
+
if (typeof err1 === "string" && err1.trim()) return {
|
|
1737
|
+
status: "terminal_error",
|
|
1738
|
+
stepIndex: latest.idx,
|
|
1739
|
+
summary: err1,
|
|
1740
|
+
detail: err2,
|
|
1741
|
+
error: err2 || err1
|
|
1742
|
+
};
|
|
1743
|
+
return {
|
|
1744
|
+
status: "retrying",
|
|
1745
|
+
stepIndex: latest.idx,
|
|
1746
|
+
detail: err2
|
|
1747
|
+
};
|
|
1748
|
+
} catch (error) {
|
|
1749
|
+
const err = error;
|
|
1750
|
+
if (err?.code === "ERR_SQLITE_ERROR" || /unable to open database file/i.test(String(err?.message ?? ""))) return { status: "missing_db" };
|
|
1751
|
+
return { status: "db_error" };
|
|
1752
|
+
} finally {
|
|
1753
|
+
try {
|
|
1754
|
+
db?.close();
|
|
1755
|
+
} catch {}
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
function unconsumedNetworkContinuationProof(records, { sessionId, conversationId, model, effort, cwd, additionalDirectories = [] }) {
|
|
1759
|
+
if (!Array.isArray(records) || !NATIVE_ID.test(sessionId ?? "") || !NATIVE_ID.test(conversationId ?? "")) return;
|
|
1760
|
+
let lastTurnIndex = -1;
|
|
1761
|
+
for (let index = 0; index < records.length; index += 1) {
|
|
1762
|
+
const type = records[index]?.type;
|
|
1763
|
+
if (type === "native_turn_pending" || type === "native_turn_reconciled") lastTurnIndex = index;
|
|
1764
|
+
}
|
|
1765
|
+
if (lastTurnIndex < 0 || records[lastTurnIndex]?.type !== "native_turn_pending") return void 0;
|
|
1766
|
+
let launchIndex = -1;
|
|
1767
|
+
for (let index = lastTurnIndex; index >= 0; index -= 1) if (records[index]?.type === "launch") {
|
|
1768
|
+
launchIndex = index;
|
|
1769
|
+
break;
|
|
1770
|
+
}
|
|
1771
|
+
if (launchIndex < 0 || records.some((record, index) => index > launchIndex && record?.type === "launch")) return;
|
|
1772
|
+
if (records.some((record) => ["session_loaded", "legacy_native_recovered"].includes(record?.type))) return;
|
|
1773
|
+
if (records.filter((record) => record?.type === "prompt_sent").length !== 1) return void 0;
|
|
1774
|
+
const launch = records[launchIndex];
|
|
1775
|
+
if (!Number.isSafeInteger(launch["pid"]) || launch["pid"] <= 0) return void 0;
|
|
1776
|
+
const turnRecords = records.slice(lastTurnIndex + 1);
|
|
1777
|
+
const promptSent = turnRecords.filter((record) => record?.type === "prompt_sent");
|
|
1778
|
+
if (promptSent.length !== 1 || !/^[0-9a-f]{64}$/i.test(String(promptSent[0]["promptSha256"] ?? ""))) return;
|
|
1779
|
+
const consumed = turnRecords.filter((record) => record?.type === "prompt_consumed");
|
|
1780
|
+
if (consumed.length !== 1 || consumed[0]["stepIndex"] !== 0) return void 0;
|
|
1781
|
+
if (turnRecords.some((record) => typeof record?.type === "string" && (record.type.startsWith("steer_") || record.type === "pre_tool_hook_denied"))) return;
|
|
1782
|
+
const results = turnRecords.filter((record) => record?.type === "agy_result");
|
|
1783
|
+
const requested = turnRecords.filter((record) => record?.type === "network_recovery_requested");
|
|
1784
|
+
const sent = turnRecords.filter((record) => record?.type === "network_recovery_sent");
|
|
1785
|
+
if (results.length !== 1 || requested.length !== 1 || sent.length !== 1) return void 0;
|
|
1786
|
+
if (results[0]["conversationId"] !== conversationId || results[0]["status"] !== "ERROR" || requested[0]["conversationId"] !== conversationId || requested[0]["nativeStatus"] !== "ERROR" || requested[0]["attempt"] !== 1 || requested[0]["totalAttempts"] !== 1 || sent[0]["conversationId"] !== conversationId || sent[0]["attempt"] !== 1 || sent[0]["relaunched"] !== false) return;
|
|
1787
|
+
const sentIndex = turnRecords.indexOf(sent[0]);
|
|
1788
|
+
if (sentIndex < turnRecords.indexOf(requested[0]) || sentIndex < turnRecords.indexOf(results[0]) || sentIndex <= turnRecords.indexOf(consumed[0])) return;
|
|
1789
|
+
const afterSent = turnRecords.slice(sentIndex + 1);
|
|
1790
|
+
if (afterSent.some((record) => record?.type !== "native_frame_delivered" && record?.type !== "close")) return;
|
|
1791
|
+
const closes = afterSent.filter((record) => record?.type === "close");
|
|
1792
|
+
if (closes.length !== 1 || closes[0]["pid"] !== launch["pid"] || closes[0]["processEnded"] !== true || closes[0]["signal"] !== void 0 && closes[0]["signal"] !== null || closes[0]["exitCode"] !== void 0 && (!Number.isSafeInteger(closes[0]["exitCode"]) || closes[0]["exitCode"] < 0)) return;
|
|
1793
|
+
const toolsByStep = /* @__PURE__ */ new Map();
|
|
1794
|
+
for (const record of turnRecords) {
|
|
1795
|
+
if (record?.type !== "tool_state") continue;
|
|
1796
|
+
const match = /^agy-([0-9a-f-]+)-(\d+)$/i.exec(String(record["toolCallId"] ?? ""));
|
|
1797
|
+
if (!match || match[1] !== conversationId) return void 0;
|
|
1798
|
+
const stepIndex = Number(match[2]);
|
|
1799
|
+
if (!Number.isSafeInteger(stepIndex) || stepIndex <= 0) return void 0;
|
|
1800
|
+
toolsByStep.set(stepIndex, {
|
|
1801
|
+
stepIndex,
|
|
1802
|
+
name: record["name"],
|
|
1803
|
+
state: record["state"],
|
|
1804
|
+
...typeof record["error"] === "string" && record["error"].trim() ? { error: record["error"] } : {}
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
if (!toolsByStep.size) return void 0;
|
|
1808
|
+
const tools = [];
|
|
1809
|
+
for (const tool of [...toolsByStep.values()].sort((a, b) => a.stepIndex - b.stepIndex)) {
|
|
1810
|
+
if (tool.state !== "DONE" && tool.state !== "ERROR") return void 0;
|
|
1811
|
+
tools.push({
|
|
1812
|
+
stepIndex: tool.stepIndex,
|
|
1813
|
+
name: tool.name,
|
|
1814
|
+
...tool.state === "ERROR" ? { failed: true } : {},
|
|
1815
|
+
...tool.state === "ERROR" && tool.error ? { error: tool.error } : {}
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
return {
|
|
1819
|
+
version: 1,
|
|
1820
|
+
sessionId,
|
|
1821
|
+
conversationId,
|
|
1822
|
+
model,
|
|
1823
|
+
effort,
|
|
1824
|
+
promptSha256: String(promptSent[0]["promptSha256"]).toLowerCase(),
|
|
1825
|
+
terminalError: requested[0]["error"],
|
|
1826
|
+
disclosedCwd: cwd,
|
|
1827
|
+
additionalDirectories: additionalDirectories.length ? [...additionalDirectories] : void 0,
|
|
1828
|
+
tools
|
|
1829
|
+
};
|
|
1830
|
+
}
|
|
734
1831
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
1832
|
+
//#endregion
|
|
1833
|
+
//#region src/ndjson.ts
|
|
1834
|
+
function createNdjsonLineTransform(options = {}) {
|
|
1835
|
+
const maxFrameBytes = options.maxFrameBytes;
|
|
1836
|
+
const decoder = new TextDecoder("utf-8");
|
|
1837
|
+
let buffer = "";
|
|
1838
|
+
const checkLimit = (text) => {
|
|
1839
|
+
if (maxFrameBytes !== void 0 && Buffer.byteLength(text) > maxFrameBytes) throw new Error(`NDJSON frame exceeds ${maxFrameBytes} bytes`);
|
|
1840
|
+
};
|
|
1841
|
+
return new TransformStream({
|
|
1842
|
+
transform(chunk, controller) {
|
|
1843
|
+
buffer += typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true });
|
|
1844
|
+
let newline;
|
|
1845
|
+
while ((newline = buffer.indexOf("\n")) >= 0) {
|
|
1846
|
+
const raw = buffer.slice(0, newline);
|
|
1847
|
+
buffer = buffer.slice(newline + 1);
|
|
1848
|
+
const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
|
|
1849
|
+
checkLimit(line);
|
|
1850
|
+
controller.enqueue(line);
|
|
1851
|
+
}
|
|
1852
|
+
checkLimit(buffer);
|
|
1853
|
+
},
|
|
1854
|
+
flush(controller) {
|
|
1855
|
+
buffer += decoder.decode();
|
|
1856
|
+
if (buffer.length > 0) {
|
|
1857
|
+
const line = buffer.endsWith("\r") ? buffer.slice(0, -1) : buffer;
|
|
1858
|
+
checkLimit(line);
|
|
1859
|
+
controller.enqueue(line);
|
|
1860
|
+
buffer = "";
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
async function* readNdjsonLines(stream, options = {}) {
|
|
1866
|
+
const { maxFrameBytes, signal } = options;
|
|
1867
|
+
if (signal?.aborted) return;
|
|
1868
|
+
const decoder = new TextDecoder("utf-8");
|
|
1869
|
+
const queue = [];
|
|
1870
|
+
let buffer = "";
|
|
1871
|
+
let ended = false;
|
|
1872
|
+
let streamError;
|
|
1873
|
+
let hasError = false;
|
|
1874
|
+
let notify;
|
|
1875
|
+
const wake = () => {
|
|
1876
|
+
const fn = notify;
|
|
1877
|
+
notify = void 0;
|
|
1878
|
+
fn?.();
|
|
1879
|
+
};
|
|
1880
|
+
const checkLimit = (text) => {
|
|
1881
|
+
if (maxFrameBytes !== void 0 && Buffer.byteLength(text) > maxFrameBytes) {
|
|
1882
|
+
streamError = /* @__PURE__ */ new Error(`NDJSON frame exceeds ${maxFrameBytes} bytes`);
|
|
1883
|
+
hasError = true;
|
|
1884
|
+
ended = true;
|
|
1885
|
+
stream.pause();
|
|
1886
|
+
wake();
|
|
1887
|
+
return false;
|
|
1888
|
+
}
|
|
1889
|
+
return true;
|
|
1890
|
+
};
|
|
1891
|
+
const onData = (chunk) => {
|
|
1892
|
+
if (ended) return;
|
|
1893
|
+
buffer += typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true });
|
|
1894
|
+
let newline;
|
|
1895
|
+
while ((newline = buffer.indexOf("\n")) >= 0) {
|
|
1896
|
+
const raw = buffer.slice(0, newline);
|
|
1897
|
+
buffer = buffer.slice(newline + 1);
|
|
1898
|
+
const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
|
|
1899
|
+
if (!checkLimit(line)) return;
|
|
1900
|
+
queue.push(line);
|
|
1901
|
+
}
|
|
1902
|
+
if (!checkLimit(buffer)) return;
|
|
1903
|
+
if (queue.length > 0) {
|
|
1904
|
+
stream.pause();
|
|
1905
|
+
wake();
|
|
1906
|
+
}
|
|
1907
|
+
};
|
|
1908
|
+
const onEnd = () => {
|
|
1909
|
+
if (ended) return;
|
|
1910
|
+
buffer += decoder.decode();
|
|
1911
|
+
if (buffer.length > 0) {
|
|
1912
|
+
const line = buffer.endsWith("\r") ? buffer.slice(0, -1) : buffer;
|
|
1913
|
+
buffer = "";
|
|
1914
|
+
if (!checkLimit(line)) return;
|
|
1915
|
+
queue.push(line);
|
|
1916
|
+
}
|
|
1917
|
+
ended = true;
|
|
1918
|
+
wake();
|
|
1919
|
+
};
|
|
1920
|
+
const onError = (error) => {
|
|
1921
|
+
if (ended) return;
|
|
1922
|
+
streamError = error;
|
|
1923
|
+
hasError = true;
|
|
1924
|
+
ended = true;
|
|
1925
|
+
wake();
|
|
1926
|
+
};
|
|
1927
|
+
const onClose = () => {
|
|
1928
|
+
if (ended) return;
|
|
1929
|
+
ended = true;
|
|
1930
|
+
wake();
|
|
1931
|
+
};
|
|
1932
|
+
const onAbort = () => {
|
|
1933
|
+
ended = true;
|
|
1934
|
+
stream.pause();
|
|
1935
|
+
wake();
|
|
1936
|
+
};
|
|
1937
|
+
stream.on("data", onData);
|
|
1938
|
+
stream.once("end", onEnd);
|
|
1939
|
+
stream.once("error", onError);
|
|
1940
|
+
stream.once("close", onClose);
|
|
1941
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
1942
|
+
try {
|
|
1943
|
+
while (true) {
|
|
1944
|
+
while (queue.length > 0) {
|
|
1945
|
+
if (signal?.aborted) return;
|
|
1946
|
+
yield queue.shift();
|
|
1947
|
+
}
|
|
1948
|
+
if (hasError) throw streamError instanceof Error ? streamError : new Error(String(streamError));
|
|
1949
|
+
if (ended || signal?.aborted) return;
|
|
1950
|
+
await new Promise((resolve) => {
|
|
1951
|
+
notify = resolve;
|
|
1952
|
+
stream.resume();
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
} finally {
|
|
1956
|
+
stream.off("data", onData);
|
|
1957
|
+
stream.off("end", onEnd);
|
|
1958
|
+
stream.off("error", onError);
|
|
1959
|
+
stream.off("close", onClose);
|
|
1960
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1961
|
+
stream.pause();
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
var NdjsonFrameDecoder = class {
|
|
1965
|
+
decoder = new TextDecoder("utf-8");
|
|
1966
|
+
maxFrameBytes;
|
|
1967
|
+
reviver;
|
|
1968
|
+
onFrame;
|
|
1969
|
+
onError;
|
|
1970
|
+
buffer = "";
|
|
1971
|
+
failed = false;
|
|
1972
|
+
constructor(options) {
|
|
1973
|
+
this.maxFrameBytes = options.maxFrameBytes ?? 1048576;
|
|
1974
|
+
this.reviver = options.reviver;
|
|
1975
|
+
this.onFrame = options.onFrame;
|
|
1976
|
+
this.onError = options.onError;
|
|
1977
|
+
}
|
|
1978
|
+
stop() {
|
|
1979
|
+
this.failed = true;
|
|
1980
|
+
}
|
|
1981
|
+
push(chunk) {
|
|
1982
|
+
if (this.failed) return;
|
|
1983
|
+
this.buffer += typeof chunk === "string" ? chunk : this.decoder.decode(chunk, { stream: true });
|
|
1984
|
+
let newline;
|
|
1985
|
+
while ((newline = this.buffer.indexOf("\n")) >= 0) {
|
|
1986
|
+
const line = this.buffer.slice(0, newline).trim();
|
|
1987
|
+
this.buffer = this.buffer.slice(newline + 1);
|
|
1988
|
+
if (!line) continue;
|
|
1989
|
+
if (Buffer.byteLength(line) > this.maxFrameBytes) {
|
|
1990
|
+
this.failed = true;
|
|
1991
|
+
this.onError(/* @__PURE__ */ new Error("AGY stdout frame exceeds 1 MiB"));
|
|
1992
|
+
return;
|
|
1993
|
+
}
|
|
1994
|
+
let parsed;
|
|
1995
|
+
try {
|
|
1996
|
+
parsed = JSON.parse(line, this.reviver);
|
|
1997
|
+
} catch {
|
|
1998
|
+
this.failed = true;
|
|
1999
|
+
this.onError(/* @__PURE__ */ new Error("AGY emitted invalid NDJSON"));
|
|
2000
|
+
return;
|
|
2001
|
+
}
|
|
2002
|
+
this.onFrame(parsed);
|
|
2003
|
+
if (this.failed) return;
|
|
2004
|
+
}
|
|
2005
|
+
if (Buffer.byteLength(this.buffer) > this.maxFrameBytes) {
|
|
2006
|
+
this.failed = true;
|
|
2007
|
+
this.onError(/* @__PURE__ */ new Error("AGY stdout frame exceeds 1 MiB"));
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
};
|
|
2011
|
+
function writeNdjsonFrame(stream, frame) {
|
|
2012
|
+
return new Promise((done, reject) => {
|
|
2013
|
+
stream.write(frame, (error) => error ? reject(error) : done());
|
|
2014
|
+
});
|
|
758
2015
|
}
|
|
759
2016
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
if (!Object.hasOwn(request, 'id')) continue;
|
|
766
|
-
let result;
|
|
767
|
-
if (request.method === 'initialize') result = { protocolVersion: request.params?.protocolVersion,
|
|
768
|
-
capabilities: { tools: {}, resources: {}, prompts: {} }, serverInfo: { name: 'kiki-unbound-session', version: '1' } };
|
|
769
|
-
else if (request.method === 'tools/list') result = { tools: [] };
|
|
770
|
-
else if (request.method === 'resources/list') result = { resources: [] };
|
|
771
|
-
else if (request.method === 'resources/templates/list') result = { resourceTemplates: [] };
|
|
772
|
-
else if (request.method === 'prompts/list') result = { prompts: [] };
|
|
773
|
-
else if (request.method === 'ping') result = {};
|
|
774
|
-
process.stdout.write(JSON.stringify(result === undefined
|
|
775
|
-
? { jsonrpc: '2.0', id: request.id, error: { code: -32601, message: 'No Kiki session lease is bound to this process' } }
|
|
776
|
-
: { jsonrpc: '2.0', id: request.id, result }) + '\n');
|
|
777
|
-
}
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
|
-
const server = JSON.parse(process.env[key]);
|
|
781
|
-
if (!server || typeof server.command !== 'string' || !Array.isArray(server.args) || !Array.isArray(server.env)) {
|
|
782
|
-
throw new Error('Session MCP launch context is invalid');
|
|
783
|
-
}
|
|
784
|
-
const admission = await requestHookPermission({ type: 'mcp_bootstrap', key }, process.env, 10_000);
|
|
785
|
-
if (admission.decision !== 'allow') throw new Error('The session MCP bootstrap was not admitted by its owning adapter');
|
|
786
|
-
const env = { ...process.env, ...Object.fromEntries(server.env.map(entry => [entry.name, entry.value])) };
|
|
787
|
-
for (const name of Object.keys(env)) if (name.startsWith('KIKI_AGY_')) delete env[name];
|
|
788
|
-
const child = spawn(server.command, server.args, { env, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
|
|
789
|
-
const closed = new Promise(done => child.once('close', done));
|
|
790
|
-
const output = createInterface({ input: child.stdout });
|
|
791
|
-
let failure;
|
|
792
|
-
const fail = error => { failure ??= error; output.close(); };
|
|
793
|
-
child.once('error', fail);
|
|
794
|
-
child.stdin.on('error', fail);
|
|
795
|
-
const lists = new Set();
|
|
796
|
-
const input = createInterface({ input: process.stdin });
|
|
797
|
-
input.on('line', line => {
|
|
798
|
-
try { const frame = JSON.parse(line); if (frame.method === 'tools/list' && frame.id !== undefined) lists.add(frame.id); } catch {}
|
|
799
|
-
child.stdin.write(line + '\n');
|
|
800
|
-
});
|
|
801
|
-
input.once('close', () => child.stdin.end());
|
|
802
|
-
child.stderr.pipe(process.stderr);
|
|
803
|
-
const stop = () => { void terminate(child); };
|
|
804
|
-
process.once('SIGTERM', stop);
|
|
805
|
-
process.once('SIGINT', stop);
|
|
806
|
-
try {
|
|
807
|
-
let ready = false;
|
|
808
|
-
for await (const line of output) {
|
|
809
|
-
let frame;
|
|
810
|
-
try { frame = JSON.parse(line); } catch {}
|
|
811
|
-
if (!ready && lists.has(frame?.id) && Array.isArray(frame?.result?.tools)) {
|
|
812
|
-
const acknowledged = await requestHookPermission({ type: 'mcp_ready', key }, process.env, 10_000);
|
|
813
|
-
if (acknowledged.decision !== 'allow') throw Error('The session MCP readiness was not admitted by its owning adapter');
|
|
814
|
-
ready = true;
|
|
815
|
-
}
|
|
816
|
-
process.stdout.write(line + '\n');
|
|
817
|
-
}
|
|
818
|
-
if (failure instanceof Error) throw new Error(failure.message, { cause: failure });
|
|
819
|
-
if (failure) throw new Error('AGY session MCP child failed', { cause: failure });
|
|
820
|
-
process.exitCode = await closed ?? 1;
|
|
821
|
-
} finally {
|
|
822
|
-
input.close();
|
|
823
|
-
process.stdin.pause();
|
|
824
|
-
output.close();
|
|
825
|
-
process.removeListener('SIGTERM', stop);
|
|
826
|
-
process.removeListener('SIGINT', stop);
|
|
827
|
-
if (child.pid !== undefined) await terminate(child);
|
|
828
|
-
await closed;
|
|
829
|
-
}
|
|
2017
|
+
//#endregion
|
|
2018
|
+
//#region src/bridge.ts
|
|
2019
|
+
function asAgyError(error) {
|
|
2020
|
+
if (error instanceof Error) return error;
|
|
2021
|
+
return new Error(String(error));
|
|
830
2022
|
}
|
|
2023
|
+
var AgyBridge = class {
|
|
2024
|
+
stopProcess;
|
|
2025
|
+
continuationExitGraceMs;
|
|
2026
|
+
networkRecoveryBackoffMs;
|
|
2027
|
+
maxConsecutiveNetworkRecoveries;
|
|
2028
|
+
errorResultWatchdogMs;
|
|
2029
|
+
account;
|
|
2030
|
+
requestedModel;
|
|
2031
|
+
onAccountExit;
|
|
2032
|
+
model;
|
|
2033
|
+
cliPath;
|
|
2034
|
+
cliPrefix;
|
|
2035
|
+
auditDir;
|
|
2036
|
+
auditMaxBytes = AUDIT_DEFAULT_MAX_BYTES;
|
|
2037
|
+
nativeHome;
|
|
2038
|
+
spawnProcess;
|
|
2039
|
+
sessions;
|
|
2040
|
+
auditBytes = /* @__PURE__ */ new Map();
|
|
2041
|
+
auditNextCompactAt = /* @__PURE__ */ new Map();
|
|
2042
|
+
auditChains = /* @__PURE__ */ new Map();
|
|
2043
|
+
prunedAuditDir = false;
|
|
2044
|
+
modelChoices;
|
|
2045
|
+
modelDiagnostic;
|
|
2046
|
+
closePromise;
|
|
2047
|
+
constructor({ cliPath, cliPrefix = [], auditDir, nativeHome = resolve(homedir(), ".gemini", "antigravity-cli"), model = DEFAULT, spawnProcess = spawn, stopProcess = terminate, account, onAccountExit, continuationExitGraceMs = NETWORK_RECOVERY_EXIT_GRACE_MS, networkRecoveryBackoffMs = NETWORK_RECOVERY_BACKOFF_MS, maxConsecutiveNetworkRecoveries = 5, errorResultWatchdogMs = ERROR_RESULT_WATCHDOG_MS } = {}) {
|
|
2048
|
+
this.stopProcess = stopProcess;
|
|
2049
|
+
this.continuationExitGraceMs = continuationExitGraceMs;
|
|
2050
|
+
this.networkRecoveryBackoffMs = networkRecoveryBackoffMs;
|
|
2051
|
+
this.maxConsecutiveNetworkRecoveries = maxConsecutiveNetworkRecoveries;
|
|
2052
|
+
this.errorResultWatchdogMs = errorResultWatchdogMs;
|
|
2053
|
+
if (!isAbsolute(cliPath ?? "")) throw new Error("Pass the exact absolute AGY executable path");
|
|
2054
|
+
if (typeof model !== "string" || !model || /\s/.test(model)) throw new Error("AGY model must be a nonempty engine ID");
|
|
2055
|
+
if (account && model !== "engine-default" && !account.modelIds.includes(model)) throw new Error("The selected account does not provide the bound AGY model");
|
|
2056
|
+
this.account = account;
|
|
2057
|
+
this.requestedModel = model;
|
|
2058
|
+
this.onAccountExit = onAccountExit;
|
|
2059
|
+
this.model = account && model === "engine-default" ? account.modelIds[0] : model;
|
|
2060
|
+
this.cliPath = cliPath;
|
|
2061
|
+
this.cliPrefix = cliPrefix;
|
|
2062
|
+
this.auditDir = auditDir;
|
|
2063
|
+
this.nativeHome = nativeHome;
|
|
2064
|
+
this.spawnProcess = spawnProcess;
|
|
2065
|
+
this.sessions = /* @__PURE__ */ new Map();
|
|
2066
|
+
}
|
|
2067
|
+
nextAuditCompactThreshold(bytes) {
|
|
2068
|
+
const growthStep = Math.max(1024, Math.floor(this.auditMaxBytes / 2));
|
|
2069
|
+
return Math.max(this.auditMaxBytes, bytes + growthStep);
|
|
2070
|
+
}
|
|
2071
|
+
async audit(session, type, data) {
|
|
2072
|
+
if (!this.auditDir) return;
|
|
2073
|
+
const auditDir = this.auditDir;
|
|
2074
|
+
const auditPath = resolve(auditDir, `${session.id}.ndjson`);
|
|
2075
|
+
const line = JSON.stringify({
|
|
2076
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2077
|
+
type,
|
|
2078
|
+
...data
|
|
2079
|
+
}) + "\n";
|
|
2080
|
+
const next = (this.auditChains.get(session.id) ?? Promise.resolve()).catch(() => {}).then(async () => {
|
|
2081
|
+
await mkdir(auditDir, { recursive: true });
|
|
2082
|
+
if (!this.prunedAuditDir) {
|
|
2083
|
+
this.prunedAuditDir = true;
|
|
2084
|
+
pruneExpiredAuditFiles(auditDir).catch(() => {});
|
|
2085
|
+
}
|
|
2086
|
+
let knownBytes = this.auditBytes.get(session.id);
|
|
2087
|
+
if (knownBytes === void 0) {
|
|
2088
|
+
const existingSize = (await stat(auditPath).catch(() => void 0))?.size ?? 0;
|
|
2089
|
+
knownBytes = existingSize;
|
|
2090
|
+
if (!this.auditNextCompactAt.has(session.id)) {
|
|
2091
|
+
const initialThreshold = this.auditMaxBytes > 0 && existingSize >= this.auditMaxBytes ? this.nextAuditCompactThreshold(existingSize) : this.auditMaxBytes;
|
|
2092
|
+
this.auditNextCompactAt.set(session.id, initialThreshold);
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
await appendFile(auditPath, line);
|
|
2096
|
+
const written = knownBytes + Buffer.byteLength(line, "utf8");
|
|
2097
|
+
const compactAt = this.auditNextCompactAt.get(session.id) ?? this.auditMaxBytes;
|
|
2098
|
+
if (this.auditMaxBytes > 0 && written >= compactAt) {
|
|
2099
|
+
const compactedBytes = await compactAuditFile(auditPath, { maxBytes: this.auditMaxBytes });
|
|
2100
|
+
this.auditBytes.set(session.id, compactedBytes);
|
|
2101
|
+
this.auditNextCompactAt.set(session.id, this.nextAuditCompactThreshold(compactedBytes));
|
|
2102
|
+
} else this.auditBytes.set(session.id, written);
|
|
2103
|
+
});
|
|
2104
|
+
this.auditChains.set(session.id, next);
|
|
2105
|
+
await next;
|
|
2106
|
+
}
|
|
2107
|
+
initialize(version) {
|
|
2108
|
+
return {
|
|
2109
|
+
protocolVersion: version,
|
|
2110
|
+
agentInfo: {
|
|
2111
|
+
name: "agy-cli-acp",
|
|
2112
|
+
version: "0.2.0"
|
|
2113
|
+
},
|
|
2114
|
+
agentCapabilities: {
|
|
2115
|
+
loadSession: Boolean(this.auditDir),
|
|
2116
|
+
promptCapabilities: {
|
|
2117
|
+
image: false,
|
|
2118
|
+
audio: false,
|
|
2119
|
+
embeddedContext: false
|
|
2120
|
+
},
|
|
2121
|
+
mcpCapabilities: {
|
|
2122
|
+
http: false,
|
|
2123
|
+
sse: false
|
|
2124
|
+
},
|
|
2125
|
+
sessionCapabilities: { additionalDirectories: {} }
|
|
2126
|
+
},
|
|
2127
|
+
authMethods: [],
|
|
2128
|
+
_meta: { steering: { supported: true } }
|
|
2129
|
+
};
|
|
2130
|
+
}
|
|
2131
|
+
async requestPermission() {
|
|
2132
|
+
return { decision: "ask" };
|
|
2133
|
+
}
|
|
2134
|
+
async newSession(params, id = randomUUID(), event = "session_new", recovery) {
|
|
2135
|
+
const mcpServers = params.mcpServers ?? [];
|
|
2136
|
+
if (!Array.isArray(mcpServers) || mcpServers.some((server) => !server || typeof server.name !== "string" || !server.name || typeof server.command !== "string" || !server.command || !Array.isArray(server.args) || server.args.some((arg) => typeof arg !== "string") || !Array.isArray(server.env) || server.env.some((entry) => typeof entry.name !== "string" || typeof entry.value !== "string"))) throw new Error("AGY session MCP requires named stdio servers with command, args and env");
|
|
2137
|
+
if (params._meta?.["systemPromptOverride"] !== void 0) throw new Error("System replacement is unsupported; use explicit Kiki preamble delivery");
|
|
2138
|
+
if (!isAbsolute(params.cwd)) throw new Error("AGY workspace must be absolute");
|
|
2139
|
+
const dirs = params.additionalDirectories ?? [];
|
|
2140
|
+
if (!Array.isArray(dirs) || dirs.some((d) => typeof d !== "string" || !isAbsolute(d))) throw new Error("Additional directories must be absolute");
|
|
2141
|
+
const session = {
|
|
2142
|
+
id,
|
|
2143
|
+
cwd: params.cwd,
|
|
2144
|
+
additionalDirectories: dirs,
|
|
2145
|
+
model: this.model,
|
|
2146
|
+
effort: DEFAULT,
|
|
2147
|
+
modelChoices: this.modelChoices,
|
|
2148
|
+
accountBound: this.account !== void 0,
|
|
2149
|
+
mcpServers: structuredClone(mcpServers),
|
|
2150
|
+
mcpPlugin: void 0,
|
|
2151
|
+
mcpBound: /* @__PURE__ */ new Set(),
|
|
2152
|
+
mcpReady: /* @__PURE__ */ new Set(),
|
|
2153
|
+
permissionIdentity: permissionChannelIdentity(),
|
|
2154
|
+
permissionChannel: void 0,
|
|
2155
|
+
child: void 0,
|
|
2156
|
+
active: void 0,
|
|
2157
|
+
broken: false,
|
|
2158
|
+
init: void 0,
|
|
2159
|
+
exited: void 0,
|
|
2160
|
+
denialCounts: /* @__PURE__ */ new Map(),
|
|
2161
|
+
toolIds: /* @__PURE__ */ new Map(),
|
|
2162
|
+
toolDetails: /* @__PURE__ */ new Map(),
|
|
2163
|
+
toolInputs: /* @__PURE__ */ new Map()
|
|
2164
|
+
};
|
|
2165
|
+
this.sessions.set(session.id, session);
|
|
2166
|
+
try {
|
|
2167
|
+
await this.recoverDeadOwnedResources(session);
|
|
2168
|
+
await this.audit(session, event, {
|
|
2169
|
+
cwd: session.cwd,
|
|
2170
|
+
additionalDirectories: dirs,
|
|
2171
|
+
delivery: event === "session_new" ? "first_user_preamble" : "native_conversation",
|
|
2172
|
+
systemOverride: false,
|
|
2173
|
+
recovery
|
|
2174
|
+
});
|
|
2175
|
+
return {
|
|
2176
|
+
sessionId: session.id,
|
|
2177
|
+
configOptions: configOptions(session)
|
|
2178
|
+
};
|
|
2179
|
+
} catch (error) {
|
|
2180
|
+
await session.permissionChannel?.close();
|
|
2181
|
+
await this.closeSteeringHook(session).catch(() => {});
|
|
2182
|
+
this.sessions.delete(session.id);
|
|
2183
|
+
throw error;
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
async loadSession(params) {
|
|
2187
|
+
if (!this.auditDir) throw new Error("AGY native load requires the existing adapter audit directory");
|
|
2188
|
+
if (!/^[0-9a-f-]{36}$/i.test(params.sessionId)) throw new Error("Invalid AGY adapter session ID");
|
|
2189
|
+
if (this.sessions.has(params.sessionId)) throw new Error("AGY session is already owned by this connection");
|
|
2190
|
+
const auditPath = resolve(this.auditDir, `${params.sessionId}.ndjson`);
|
|
2191
|
+
const readAudit = async () => readAuditFile(auditPath, {
|
|
2192
|
+
maxBytes: this.auditMaxBytes,
|
|
2193
|
+
repairTruncatedTail: true
|
|
2194
|
+
});
|
|
2195
|
+
const records = await readAudit().catch((error) => {
|
|
2196
|
+
if (error.code !== "ENOENT" || params._meta?.["kiki.agyLegacyRecovery"] === void 0) throw error;
|
|
2197
|
+
});
|
|
2198
|
+
const workspace = records?.find((record) => ["session_new", "legacy_native_recovered"].includes(record.type));
|
|
2199
|
+
const launch = records?.findLast((record) => record.type === "launch");
|
|
2200
|
+
if (records === void 0 || !launch && workspace?.type === "legacy_native_recovered") return this.loadLegacySession(params, readAudit, workspace);
|
|
2201
|
+
const init = records.findLast((record) => record.type === "agy_init");
|
|
2202
|
+
if (!workspace || !launch || !init?.["conversationId"] || records.indexOf(init) < records.indexOf(launch)) throw new Error("AGY session has no confirmed native conversation to load; retain the failed attempt and create a new session");
|
|
2203
|
+
if (resolve(params.cwd) !== resolve(workspace["cwd"]) || JSON.stringify(params.additionalDirectories ?? []) !== JSON.stringify(workspace["additionalDirectories"] ?? [])) throw new Error("AGY native load workspace differs from its original binding");
|
|
2204
|
+
if (records.some((record) => record.type === "mcp_agent_registered")) throw new Error("This native conversation used the former custom MCP agent; retain its original adapter for recovery or create a new native main session");
|
|
2205
|
+
const mcpBinding = records.findLast((record) => record.type === "mcp_plugin_registered");
|
|
2206
|
+
if (mcpBinding && typeof mcpBinding["name"] !== "string") throw new Error("AGY native load has no audited MCP plugin namespace; preserve its original adapter for recovery");
|
|
2207
|
+
if (mcpBinding && JSON.stringify(params.mcpServers?.map((server) => server.name) ?? []) !== JSON.stringify(mcpBinding["servers"])) throw new Error("AGY native load requires fresh MCP connections matching its original server names");
|
|
2208
|
+
const launchArgsArr = launch["args"] ?? [];
|
|
2209
|
+
const argValue = (name) => {
|
|
2210
|
+
const index = launchArgsArr.lastIndexOf(name);
|
|
2211
|
+
return index < 0 ? DEFAULT : launchArgsArr[index + 1] ?? "engine-default";
|
|
2212
|
+
};
|
|
2213
|
+
const model = argValue("--model") === "engine-default" ? init["model"] : argValue("--model");
|
|
2214
|
+
if (typeof model !== "string" || !model || (this.account ? !this.account.modelIds.includes(model) || this.requestedModel !== "engine-default" && model !== this.requestedModel : this.model !== "engine-default" && model !== this.model)) throw new Error(this.account ? "AGY native load model differs from its original binding or is unavailable for the selected account" : "AGY native load model differs from its original binding or was not confirmed");
|
|
2215
|
+
const effort = launch["effort"] ?? argValue("--effort");
|
|
2216
|
+
validateEffort(model, effort);
|
|
2217
|
+
if (processAlive(launch["pid"])) throw new Error("AGY native conversation still has an owned process; close it before loading");
|
|
2218
|
+
const release = await this.claimResume(params.sessionId);
|
|
2219
|
+
try {
|
|
2220
|
+
const latest = await readAudit();
|
|
2221
|
+
const retired = latest.findLast((record) => record.type === "cancel_requested" || record.type === "cancel_failed" || record.type === "cancel" && record["resumeSupported"] === false || record.type === "tool_terminal_missing" && Array.isArray(record["tools"]) && record["tools"].length > 0);
|
|
2222
|
+
if (retired) {
|
|
2223
|
+
const error = /* @__PURE__ */ new Error(`AGY native session is retired or unreconciled (${retired.type}); inspect the native outcome before deciding what to run in a fresh session; do not replay interrupted prompts or commands`);
|
|
2224
|
+
error.code = "AGY_SESSION_RETIRED";
|
|
2225
|
+
error.details = {
|
|
2226
|
+
reason: retired.type,
|
|
2227
|
+
unresolvedTools: retired["unresolvedTools"] ?? retired["tools"] ?? []
|
|
2228
|
+
};
|
|
2229
|
+
throw error;
|
|
2230
|
+
}
|
|
2231
|
+
if (latest.findLast((record) => record.type === "native_turn_pending" || record.type === "native_turn_reconciled")?.type === "native_turn_pending") {
|
|
2232
|
+
const unconsumedProof = !mcpBinding ? unconsumedNetworkContinuationProof(latest, {
|
|
2233
|
+
sessionId: params.sessionId,
|
|
2234
|
+
conversationId: init["conversationId"],
|
|
2235
|
+
model,
|
|
2236
|
+
effort,
|
|
2237
|
+
cwd: workspace["cwd"],
|
|
2238
|
+
additionalDirectories: workspace["additionalDirectories"] ?? []
|
|
2239
|
+
}) : void 0;
|
|
2240
|
+
let reconciled = false;
|
|
2241
|
+
if (unconsumedProof !== void 0) try {
|
|
2242
|
+
await readLegacyNativeRecovery({
|
|
2243
|
+
nativeHome: this.nativeHome,
|
|
2244
|
+
cwd: workspace["cwd"],
|
|
2245
|
+
additionalDirectories: workspace["additionalDirectories"] ?? [],
|
|
2246
|
+
sessionId: params.sessionId,
|
|
2247
|
+
proof: unconsumedProof,
|
|
2248
|
+
model
|
|
2249
|
+
});
|
|
2250
|
+
reconciled = true;
|
|
2251
|
+
} catch {}
|
|
2252
|
+
if (!reconciled) {
|
|
2253
|
+
const error = /* @__PURE__ */ new Error("AGY native session has an unconfirmed turn; wait for its native outcome to be reconciled before loading; do not replay the interrupted prompt or commands");
|
|
2254
|
+
error.code = "AGY_SESSION_UNCONFIRMED";
|
|
2255
|
+
throw error;
|
|
2256
|
+
}
|
|
2257
|
+
await this.audit({ id: params.sessionId }, "native_turn_reconciled", {
|
|
2258
|
+
conversationId: init["conversationId"],
|
|
2259
|
+
status: "ERROR",
|
|
2260
|
+
reconciledFromNativeDb: true,
|
|
2261
|
+
unconsumedContinuationAttempt: 1
|
|
2262
|
+
});
|
|
2263
|
+
}
|
|
2264
|
+
await this.newSession(params, params.sessionId, "session_loaded");
|
|
2265
|
+
const session = this.session(params.sessionId);
|
|
2266
|
+
session.model = model;
|
|
2267
|
+
session.effort = effort;
|
|
2268
|
+
session.conversationId = init["conversationId"];
|
|
2269
|
+
session.mcpNamespace = mcpBinding?.["name"];
|
|
2270
|
+
session.releaseResume = release;
|
|
2271
|
+
return { configOptions: configOptions(session) };
|
|
2272
|
+
} catch (error) {
|
|
2273
|
+
await release();
|
|
2274
|
+
this.sessions.delete(params.sessionId);
|
|
2275
|
+
throw error;
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
async claimResume(sessionId) {
|
|
2279
|
+
await mkdir(this.auditDir, { recursive: true });
|
|
2280
|
+
const path = resolve(this.auditDir, `${sessionId}.resume-lock`);
|
|
2281
|
+
const claim = JSON.stringify({
|
|
2282
|
+
pid: process.pid,
|
|
2283
|
+
nonce: randomUUID()
|
|
2284
|
+
});
|
|
2285
|
+
let file;
|
|
2286
|
+
try {
|
|
2287
|
+
file = await open(path, "wx");
|
|
2288
|
+
} catch (error) {
|
|
2289
|
+
if (error.code !== "EEXIST") throw error;
|
|
2290
|
+
const previous = await readFile(path, "utf8");
|
|
2291
|
+
if (processAlive(JSON.parse(previous).pid)) throw new Error("AGY native conversation is already being loaded");
|
|
2292
|
+
throw new Error(`AGY native load lease is stale; recover only this exact owned lease after confirming no live adapter: ${path}`);
|
|
2293
|
+
}
|
|
2294
|
+
try {
|
|
2295
|
+
await file.writeFile(claim);
|
|
2296
|
+
} finally {
|
|
2297
|
+
await file.close();
|
|
2298
|
+
}
|
|
2299
|
+
return async () => {
|
|
2300
|
+
try {
|
|
2301
|
+
if (await readFile(path, "utf8") === claim) await unlink(path);
|
|
2302
|
+
} catch (error) {
|
|
2303
|
+
if (error.code !== "ENOENT") throw error;
|
|
2304
|
+
}
|
|
2305
|
+
};
|
|
2306
|
+
}
|
|
2307
|
+
async loadLegacySession(params, readAudit, previous) {
|
|
2308
|
+
const additionalDirectories = params.additionalDirectories ?? [];
|
|
2309
|
+
if ((params.mcpServers?.length ?? 0) !== 0 || !Array.isArray(additionalDirectories) || additionalDirectories.some((dir) => typeof dir !== "string" || !isAbsolute(dir))) throw new Error("AGY legacy native recovery requires the original default-home non-MCP binding");
|
|
2310
|
+
if (previous && (resolve(params.cwd) !== resolve(previous["cwd"]) || JSON.stringify(additionalDirectories) !== JSON.stringify(previous["additionalDirectories"] ?? []))) throw new Error("AGY legacy native conversation or workspace differs from its original binding");
|
|
2311
|
+
const proof = (previous?.["recovery"])?.proof ?? params._meta?.["kiki.agyLegacyRecovery"];
|
|
2312
|
+
const release = await this.claimResume(params.sessionId);
|
|
2313
|
+
try {
|
|
2314
|
+
const latest = await readAudit().catch((error) => {
|
|
2315
|
+
if (error.code !== "ENOENT") throw error;
|
|
2316
|
+
return [];
|
|
2317
|
+
});
|
|
2318
|
+
const latestRecovery = latest.find((record) => record.type === "legacy_native_recovered");
|
|
2319
|
+
if (JSON.stringify(latestRecovery) !== JSON.stringify(previous) || latest.some((record) => ![
|
|
2320
|
+
"legacy_native_recovered",
|
|
2321
|
+
"session_loaded",
|
|
2322
|
+
"owned_recovery",
|
|
2323
|
+
"permission_mode_configured",
|
|
2324
|
+
"close"
|
|
2325
|
+
].includes(record.type))) throw new Error("AGY legacy recovery state changed; preserve the original session without replay");
|
|
2326
|
+
const model = proof?.model;
|
|
2327
|
+
if (typeof model !== "string" || !model || this.requestedModel !== "engine-default" && model !== this.requestedModel || this.account && !this.account.modelIds.includes(model)) throw new Error("AGY legacy native model is not available for this binding");
|
|
2328
|
+
const recovered = await readLegacyNativeRecovery({
|
|
2329
|
+
nativeHome: this.nativeHome,
|
|
2330
|
+
cwd: params.cwd,
|
|
2331
|
+
additionalDirectories,
|
|
2332
|
+
sessionId: params.sessionId,
|
|
2333
|
+
proof,
|
|
2334
|
+
model
|
|
2335
|
+
});
|
|
2336
|
+
validateEffort(recovered.model, recovered.effort);
|
|
2337
|
+
await this.newSession(params, params.sessionId, previous ? "session_loaded" : "legacy_native_recovered", previous ? void 0 : {
|
|
2338
|
+
...recovered,
|
|
2339
|
+
proof
|
|
2340
|
+
});
|
|
2341
|
+
const session = this.session(params.sessionId);
|
|
2342
|
+
session.model = recovered.model;
|
|
2343
|
+
session.effort = recovered.effort;
|
|
2344
|
+
session.conversationId = recovered.conversationId;
|
|
2345
|
+
session.releaseResume = release;
|
|
2346
|
+
return { configOptions: configOptions(session) };
|
|
2347
|
+
} catch (error) {
|
|
2348
|
+
await release();
|
|
2349
|
+
this.sessions.delete(params.sessionId);
|
|
2350
|
+
throw error;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
session(id) {
|
|
2354
|
+
const session = this.sessions.get(id);
|
|
2355
|
+
if (!session) throw new Error("Unknown AGY session; use session/load for exact audited native recovery. Fork is unsupported");
|
|
2356
|
+
return session;
|
|
2357
|
+
}
|
|
2358
|
+
async loadVendorModels() {
|
|
2359
|
+
if (this.account) {
|
|
2360
|
+
this.modelChoices = this.account.modelIds;
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
2363
|
+
try {
|
|
2364
|
+
const result = await readVendorModelCatalog({
|
|
2365
|
+
cliPath: this.cliPath,
|
|
2366
|
+
cliPrefix: this.cliPrefix,
|
|
2367
|
+
spawnProcess: this.spawnProcess,
|
|
2368
|
+
stopProcess: this.stopProcess
|
|
2369
|
+
});
|
|
2370
|
+
this.modelChoices = result.ok ? result.ids : void 0;
|
|
2371
|
+
this.modelDiagnostic = result.ok ? void 0 : result.diagnostic;
|
|
2372
|
+
} catch (error) {
|
|
2373
|
+
this.modelChoices = void 0;
|
|
2374
|
+
this.modelDiagnostic = catalogDiagnostic(error instanceof Error ? error.message : String(error));
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
setModel(session, value) {
|
|
2378
|
+
if (session.accountBound && value === "engine-default") value = this.account.modelIds[0];
|
|
2379
|
+
if (typeof value !== "string" || value.length === 0 || /\s/u.test(value)) throw new Error("AGY model must be a nonempty engine ID");
|
|
2380
|
+
if (session.child && session.model !== value) throw new Error("AGY model/effort is frozen after process launch; select a fresh session");
|
|
2381
|
+
if (!Array.isArray(session.modelChoices)) throw new Error("AGY model catalog is unavailable; model is selected by argv in its own namespace");
|
|
2382
|
+
if (value !== "engine-default" && value !== session.model && !session.modelChoices.includes(value)) throw new Error(`AGY model ID ${value} is not in the vendor catalog`);
|
|
2383
|
+
validateEffort(value, session.effort);
|
|
2384
|
+
session.model = value;
|
|
2385
|
+
return { configOptions: configOptions(session) };
|
|
2386
|
+
}
|
|
2387
|
+
setConfig(params) {
|
|
2388
|
+
const session = this.session(params.sessionId);
|
|
2389
|
+
if (params.configId === "model") return this.setModel(session, params.value);
|
|
2390
|
+
if (params.configId === "permission-mode") return this.setPermissionMode(session, params.value);
|
|
2391
|
+
if (params.configId === "native-agent") {
|
|
2392
|
+
if (params.value !== "engine-default") throw new Error("AGY adapter supports only the native default agent; other native agents have not been discovered");
|
|
2393
|
+
return { configOptions: configOptions(session) };
|
|
2394
|
+
}
|
|
2395
|
+
const key = params.configId === "effort" ? "effort" : void 0;
|
|
2396
|
+
if (!key) throw new Error("Unsupported AGY config option; model is selected by argv in its own namespace");
|
|
2397
|
+
if (session.child && session[key] !== params.value) throw new Error("AGY model/effort is frozen after process launch; select a fresh session");
|
|
2398
|
+
validateEffort(session.model, params.value);
|
|
2399
|
+
session[key] = params.value;
|
|
2400
|
+
return { configOptions: configOptions(session) };
|
|
2401
|
+
}
|
|
2402
|
+
async setPermissionMode(session, value) {
|
|
2403
|
+
if (![
|
|
2404
|
+
"engine-default",
|
|
2405
|
+
"manual",
|
|
2406
|
+
"auto",
|
|
2407
|
+
"yolo"
|
|
2408
|
+
].includes(value)) throw new Error(`AGY native permission mode ${value} is unsupported; review requires the Kiki native executor`);
|
|
2409
|
+
if (session.permissionMode === value) return { configOptions: configOptions(session) };
|
|
2410
|
+
if (session.active) throw new Error("AGY permission mode cannot change during an active turn");
|
|
2411
|
+
if (session.child) {
|
|
2412
|
+
const conversationId = session.init?.conversation_id;
|
|
2413
|
+
if (!conversationId || session.broken) throw new Error("AGY permission changes require a confirmed healthy native conversation");
|
|
2414
|
+
session.restarting = true;
|
|
2415
|
+
try {
|
|
2416
|
+
await this.stopProcess(session.child);
|
|
2417
|
+
await session.cleanup;
|
|
2418
|
+
session.conversationId = conversationId;
|
|
2419
|
+
session.child = void 0;
|
|
2420
|
+
session.init = void 0;
|
|
2421
|
+
session.exited = void 0;
|
|
2422
|
+
session.cleanup = void 0;
|
|
2423
|
+
session.permissionChannel = void 0;
|
|
2424
|
+
session.mcpPlugin = void 0;
|
|
2425
|
+
session.mcpBound.clear();
|
|
2426
|
+
session.mcpReady.clear();
|
|
2427
|
+
session.broken = false;
|
|
2428
|
+
} finally {
|
|
2429
|
+
session.restarting = false;
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
session.permissionMode = value;
|
|
2433
|
+
await this.audit(session, "permission_mode_configured", {
|
|
2434
|
+
value,
|
|
2435
|
+
mechanism: "native-session-settings"
|
|
2436
|
+
});
|
|
2437
|
+
return { configOptions: configOptions(session) };
|
|
2438
|
+
}
|
|
2439
|
+
async syncPermissionHook(session) {
|
|
2440
|
+
session.permissionChannel ??= await openPermissionChannel((input) => ["mcp_bootstrap", "mcp_ready"].includes(String(input?.["type"])) ? this.bindMcpBootstrap(session, input) : input?.["type"] === "steer_poll" ? this.pollSteering(session, input) : this.requestPermission(), session.permissionIdentity);
|
|
2441
|
+
}
|
|
2442
|
+
async registerMcpPlugin(session) {
|
|
2443
|
+
if (!session.mcpServers.length || session.mcpPlugin) return;
|
|
2444
|
+
session.mcpPlugin = await registerProjectMcpPlugin({
|
|
2445
|
+
cwd: session.cwd,
|
|
2446
|
+
sessionId: session.id,
|
|
2447
|
+
namespace: session.mcpNamespace,
|
|
2448
|
+
nodePath: process.execPath,
|
|
2449
|
+
handlerPath: fileURLToPath(import.meta.url),
|
|
2450
|
+
servers: session.mcpServers
|
|
2451
|
+
});
|
|
2452
|
+
await this.audit(session, "mcp_plugin_registered", {
|
|
2453
|
+
name: session.mcpPlugin.name,
|
|
2454
|
+
path: session.mcpPlugin.path,
|
|
2455
|
+
servers: session.mcpServers.map((server) => server.name),
|
|
2456
|
+
nativeAgent: "engine-default"
|
|
2457
|
+
});
|
|
2458
|
+
}
|
|
2459
|
+
async bindMcpBootstrap(session, input) {
|
|
2460
|
+
const key = typeof input["key"] === "string" ? input["key"] : "";
|
|
2461
|
+
if (!session.mcpPlugin || !Object.hasOwn(session.mcpPlugin.env, key) || session.broken) return {
|
|
2462
|
+
decision: "deny",
|
|
2463
|
+
reason: "The MCP bootstrap does not belong to this active session"
|
|
2464
|
+
};
|
|
2465
|
+
if (input["type"] === "mcp_ready") {
|
|
2466
|
+
if (!session.mcpBound.has(key)) return {
|
|
2467
|
+
decision: "deny",
|
|
2468
|
+
reason: "The MCP bootstrap has not been admitted"
|
|
2469
|
+
};
|
|
2470
|
+
session.mcpReady.add(key);
|
|
2471
|
+
} else session.mcpBound.add(key);
|
|
2472
|
+
const serverIndex = Object.keys(session.mcpPlugin.env).indexOf(key);
|
|
2473
|
+
await this.audit(session, input["type"] === "mcp_ready" ? "mcp_stdio_ready" : "mcp_stdio_bound", { server: session.mcpServers[serverIndex]?.name });
|
|
2474
|
+
return { decision: "allow" };
|
|
2475
|
+
}
|
|
2476
|
+
/**
|
|
2477
|
+
* A previous adapter killed before its close ran can leave its owned hook keys and MCP
|
|
2478
|
+
* plugin in this workspace. Before this session registers its own, recover only those
|
|
2479
|
+
* whose every recorded owner process has exited; live leases, edited files and foreign
|
|
2480
|
+
* entries are preserved and reported in the audit instead of failing the session.
|
|
2481
|
+
*/
|
|
2482
|
+
async recoverDeadOwnedResources(session) {
|
|
2483
|
+
if (session.ownedRecoveryDone) return;
|
|
2484
|
+
session.ownedRecoveryDone = true;
|
|
2485
|
+
const results = {};
|
|
2486
|
+
try {
|
|
2487
|
+
results["hooks"] = (await recoverProjectHook({
|
|
2488
|
+
cwd: session.cwd,
|
|
2489
|
+
nodePath: process.execPath,
|
|
2490
|
+
handlerPath: fileURLToPath(new URL("./agy-permission-hook.mjs", import.meta.url))
|
|
2491
|
+
})).status;
|
|
2492
|
+
} catch (error) {
|
|
2493
|
+
results["hooks"] = {
|
|
2494
|
+
status: "preserved",
|
|
2495
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
2496
|
+
};
|
|
2497
|
+
}
|
|
2498
|
+
try {
|
|
2499
|
+
results["plugins"] = await recoverDeadProjectMcpPlugins({ cwd: session.cwd });
|
|
2500
|
+
} catch (error) {
|
|
2501
|
+
results["plugins"] = {
|
|
2502
|
+
status: "preserved",
|
|
2503
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
2504
|
+
};
|
|
2505
|
+
}
|
|
2506
|
+
const plugins = results["plugins"];
|
|
2507
|
+
if (results["hooks"] !== "no-owned-registration" || Array.isArray(plugins) && plugins.length > 0) this.auditQuietly(session, "owned_recovery", results);
|
|
2508
|
+
}
|
|
2509
|
+
async registerSteeringHook(session) {
|
|
2510
|
+
session.steeringRegistration ??= await registerProjectHook({
|
|
2511
|
+
cwd: session.cwd,
|
|
2512
|
+
nodePath: process.execPath,
|
|
2513
|
+
handlerPath: fileURLToPath(new URL("./agy-permission-hook.mjs", import.meta.url)),
|
|
2514
|
+
sessionId: session.id,
|
|
2515
|
+
key: AGY_STEERING_HOOK_KEY,
|
|
2516
|
+
args: ["--steering"]
|
|
2517
|
+
});
|
|
2518
|
+
if (!session.child && !session.conversationId) session.commandGuidanceRegistration ??= await registerProjectHook({
|
|
2519
|
+
cwd: session.cwd,
|
|
2520
|
+
nodePath: process.execPath,
|
|
2521
|
+
handlerPath: fileURLToPath(new URL("./agy-permission-hook.mjs", import.meta.url)),
|
|
2522
|
+
sessionId: session.id,
|
|
2523
|
+
key: AGY_COMMAND_GUIDANCE_HOOK_KEY,
|
|
2524
|
+
args: ["--command-guidance"]
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
/**
|
|
2528
|
+
* Removes the turn's owned steering and startup guidance keys. A failed removal keeps
|
|
2529
|
+
* its registration for the next turn end, cancel or close; cleanup never replaces the result.
|
|
2530
|
+
*/
|
|
2531
|
+
async closeSteeringHook(session) {
|
|
2532
|
+
const errors = [];
|
|
2533
|
+
for (const key of ["steeringRegistration", "commandGuidanceRegistration"]) {
|
|
2534
|
+
const registration = session[key];
|
|
2535
|
+
if (!registration) continue;
|
|
2536
|
+
try {
|
|
2537
|
+
await registration.close();
|
|
2538
|
+
if (session[key] === registration) session[key] = void 0;
|
|
2539
|
+
} catch (error) {
|
|
2540
|
+
this.auditQuietly(session, "steering_hook_close_failed", {
|
|
2541
|
+
registration: key,
|
|
2542
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2543
|
+
});
|
|
2544
|
+
errors.push(error);
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
if (errors.length) throw errors[0];
|
|
2548
|
+
}
|
|
2549
|
+
auditQuietly(session, type, data) {
|
|
2550
|
+
this.audit(session, type, data).catch(() => {});
|
|
2551
|
+
}
|
|
2552
|
+
/**
|
|
2553
|
+
* Accepts one steering message for the running native turn. The text waits in this
|
|
2554
|
+
* session until AGY's next PostInvocation hook drains it into the same invocation loop.
|
|
2555
|
+
* An idle session returns `promptRequired` so the host submits a normal prompt instead.
|
|
2556
|
+
*/
|
|
2557
|
+
async steer(params) {
|
|
2558
|
+
const session = this.session(params.sessionId);
|
|
2559
|
+
const active = session.active;
|
|
2560
|
+
if (!active || session.broken || !session.steeringRegistration) return {
|
|
2561
|
+
outcome: "promptRequired",
|
|
2562
|
+
reason: "noRunningTurn"
|
|
2563
|
+
};
|
|
2564
|
+
const text = promptText(params.prompt);
|
|
2565
|
+
const id = randomUUID();
|
|
2566
|
+
await this.audit(session, "steer_queued", {
|
|
2567
|
+
steerId: id,
|
|
2568
|
+
sha256: createHash("sha256").update(text).digest("hex")
|
|
2569
|
+
});
|
|
2570
|
+
if (session.active !== active || session.broken || !session.steeringRegistration) {
|
|
2571
|
+
this.auditQuietly(session, "steer_not_delivered", { steerIds: [id] });
|
|
2572
|
+
return {
|
|
2573
|
+
outcome: "promptRequired",
|
|
2574
|
+
reason: "turnEnded"
|
|
2575
|
+
};
|
|
2576
|
+
}
|
|
2577
|
+
return new Promise((resolveSteer) => active.steering.push({
|
|
2578
|
+
id,
|
|
2579
|
+
text,
|
|
2580
|
+
resolve: resolveSteer
|
|
2581
|
+
}));
|
|
2582
|
+
}
|
|
2583
|
+
releaseSteering(session, active) {
|
|
2584
|
+
const pending = active.steering.splice(0);
|
|
2585
|
+
if (pending.length) this.auditQuietly(session, "steer_not_delivered", { steerIds: pending.map((item) => item.id) });
|
|
2586
|
+
for (const item of pending) item.resolve({
|
|
2587
|
+
outcome: "promptRequired",
|
|
2588
|
+
reason: "turnEnded"
|
|
2589
|
+
});
|
|
2590
|
+
}
|
|
2591
|
+
async pollSteering(session, input) {
|
|
2592
|
+
const active = session.active;
|
|
2593
|
+
if (!active || session.broken || !session.init || input["conversationId"] !== session.init.conversation_id) return {
|
|
2594
|
+
decision: "deny",
|
|
2595
|
+
reason: "AGY steering poll does not belong to the running turn"
|
|
2596
|
+
};
|
|
2597
|
+
if (active.steering.length === 0) return {
|
|
2598
|
+
decision: "allow",
|
|
2599
|
+
steering: { injectSteps: [] }
|
|
2600
|
+
};
|
|
2601
|
+
const batch = active.steering.splice(0);
|
|
2602
|
+
this.auditQuietly(session, "steer_delivering", {
|
|
2603
|
+
steerIds: batch.map((item) => item.id),
|
|
2604
|
+
invocationNum: input["invocationNum"]
|
|
2605
|
+
});
|
|
2606
|
+
let settled = false;
|
|
2607
|
+
const settle = (outcome, type) => {
|
|
2608
|
+
if (settled) return;
|
|
2609
|
+
settled = true;
|
|
2610
|
+
if (outcome !== "injected") active.steerDeliveryUnknown = true;
|
|
2611
|
+
this.auditQuietly(session, type, { steerIds: batch.map((item) => item.id) });
|
|
2612
|
+
for (const item of batch) item.resolve({ outcome });
|
|
2613
|
+
};
|
|
2614
|
+
return {
|
|
2615
|
+
decision: "allow",
|
|
2616
|
+
steering: { injectSteps: batch.map((item) => ({ userMessage: item.text })) },
|
|
2617
|
+
afterWrite: () => settle("injected", "steer_delivered"),
|
|
2618
|
+
afterFailure: () => settle("deliveryUnknown", "steer_delivery_unknown")
|
|
2619
|
+
};
|
|
2620
|
+
}
|
|
2621
|
+
async start(session) {
|
|
2622
|
+
session.denialCounts = /* @__PURE__ */ new Map();
|
|
2623
|
+
await this.registerMcpPlugin(session);
|
|
2624
|
+
const args = [...this.cliPrefix, ...launchArgs(session)];
|
|
2625
|
+
const env = {
|
|
2626
|
+
...process.env,
|
|
2627
|
+
...session.permissionIdentity
|
|
2628
|
+
};
|
|
2629
|
+
for (const key of Object.keys(env)) if (key.startsWith("KIKI_AGY_MCP_")) delete env[key];
|
|
2630
|
+
Object.assign(env, session.mcpPlugin?.env);
|
|
2631
|
+
const account = this.account;
|
|
2632
|
+
if (account) Object.assign(env, {
|
|
2633
|
+
GEMINI_API_KEY: account.apiKey,
|
|
2634
|
+
GOOGLE_GEMINI_BASE_URL: account.baseUrl
|
|
2635
|
+
});
|
|
2636
|
+
const redact = (text) => account ? text.replaceAll(account.apiKey, "[redacted]").replaceAll(account.baseUrl, "[redacted]") : text;
|
|
2637
|
+
let child;
|
|
2638
|
+
try {
|
|
2639
|
+
await session.mcpPlugin?.beforeLaunch();
|
|
2640
|
+
child = this.spawnProcess(this.cliPath, args, {
|
|
2641
|
+
cwd: session.cwd,
|
|
2642
|
+
stdio: [
|
|
2643
|
+
"pipe",
|
|
2644
|
+
"pipe",
|
|
2645
|
+
"pipe"
|
|
2646
|
+
],
|
|
2647
|
+
windowsHide: true,
|
|
2648
|
+
env
|
|
2649
|
+
});
|
|
2650
|
+
} catch (error) {
|
|
2651
|
+
await session.permissionChannel?.close();
|
|
2652
|
+
await this.closeSteeringHook(session).catch(() => {});
|
|
2653
|
+
await session.mcpPlugin?.close();
|
|
2654
|
+
throw error;
|
|
2655
|
+
}
|
|
2656
|
+
session.child = child;
|
|
2657
|
+
session.exited = new Promise((done) => child.once("close", () => done()));
|
|
2658
|
+
let stderr = Buffer.alloc(0);
|
|
2659
|
+
let stderrTruncated = false;
|
|
2660
|
+
let delivery = Promise.resolve();
|
|
2661
|
+
let ingress = Promise.resolve();
|
|
2662
|
+
let sequence = 0;
|
|
2663
|
+
const fail = (error) => {
|
|
2664
|
+
session.broken = true;
|
|
2665
|
+
if (!session.cancelling) Promise.resolve(this.stopProcess(child)).catch(() => {});
|
|
2666
|
+
return this.loseTurn(session, asAgyError(error));
|
|
2667
|
+
};
|
|
2668
|
+
const failFrame = (error) => {
|
|
2669
|
+
decoder.stop();
|
|
2670
|
+
session.broken = true;
|
|
2671
|
+
if (!session.cancelling) Promise.resolve(this.stopProcess(child)).catch(() => {});
|
|
2672
|
+
delivery = delivery.then(() => this.loseTurn(session, error));
|
|
2673
|
+
};
|
|
2674
|
+
const decoder = new NdjsonFrameDecoder({
|
|
2675
|
+
reviver: account ? (_key, value) => typeof value === "string" ? redact(value) : value : void 0,
|
|
2676
|
+
onFrame: (event) => {
|
|
2677
|
+
const frame = {
|
|
2678
|
+
sequence: ++sequence,
|
|
2679
|
+
receivedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2680
|
+
event: event?.event,
|
|
2681
|
+
stepIndex: event?.step_update?.step_index,
|
|
2682
|
+
stepType: event?.step_update?.step_type,
|
|
2683
|
+
state: event?.step_update?.state,
|
|
2684
|
+
status: event?.result?.status
|
|
2685
|
+
};
|
|
2686
|
+
this.clearErrorResultWatchdog(session.active);
|
|
2687
|
+
ingress = ingress.then(() => this.audit(session, "native_frame_received", frame)).catch(fail);
|
|
2688
|
+
delivery = delivery.then(async () => {
|
|
2689
|
+
await this.event(session, event);
|
|
2690
|
+
await this.audit(session, "native_frame_delivered", { sequence: frame.sequence });
|
|
2691
|
+
}).catch(fail);
|
|
2692
|
+
},
|
|
2693
|
+
onError: failFrame
|
|
2694
|
+
});
|
|
2695
|
+
session.drainReceived = () => {
|
|
2696
|
+
decoder.stop();
|
|
2697
|
+
return Promise.all([ingress, delivery]);
|
|
2698
|
+
};
|
|
2699
|
+
session.queueInternalAction = (action) => {
|
|
2700
|
+
delivery = delivery.then(action).catch(fail);
|
|
2701
|
+
return delivery;
|
|
2702
|
+
};
|
|
2703
|
+
child.stdout?.on("data", (chunk) => {
|
|
2704
|
+
decoder.push(chunk);
|
|
2705
|
+
});
|
|
2706
|
+
child.stderr?.on("data", (chunk) => {
|
|
2707
|
+
const text = chunk.toString();
|
|
2708
|
+
if (/auto-denied|soft.denied|permission.*denied/i.test(text) && session.active) session.active.denied = true;
|
|
2709
|
+
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
2710
|
+
stderrTruncated ||= stderr.length + bytes.length > 8192;
|
|
2711
|
+
const tail = Buffer.concat([stderr, bytes.subarray(Math.max(0, bytes.length - 8192))]);
|
|
2712
|
+
stderr = tail.subarray(Math.max(0, tail.length - 8192));
|
|
2713
|
+
if (!account) process.stderr.write(chunk);
|
|
2714
|
+
});
|
|
2715
|
+
child.stdin?.on("error", (error) => {
|
|
2716
|
+
if (session.child === child && session.active?.continuationWriter !== child) fail(error);
|
|
2717
|
+
});
|
|
2718
|
+
child.on("error", (error) => {
|
|
2719
|
+
fail(error);
|
|
2720
|
+
});
|
|
2721
|
+
child.once("close", (code, signal) => {
|
|
2722
|
+
const lines = stderr.toString("utf8").split(/\r?\n/u);
|
|
2723
|
+
if (stderrTruncated) lines.shift();
|
|
2724
|
+
const diagnostic = lines.map((line) => safeDiagnosticLine(redact(line))).findLast((line) => line !== void 0);
|
|
2725
|
+
stderr = Buffer.alloc(0);
|
|
2726
|
+
const owned = child;
|
|
2727
|
+
const channel = session.permissionChannel;
|
|
2728
|
+
if (session.child === owned) session.broken = true;
|
|
2729
|
+
session.cleanup = (async () => {
|
|
2730
|
+
try {
|
|
2731
|
+
await Promise.all([ingress, delivery]);
|
|
2732
|
+
} finally {
|
|
2733
|
+
if (session.child === owned) {
|
|
2734
|
+
if (session.active && !session.cancelling) {
|
|
2735
|
+
const message = `AGY exited before terminal result (code: ${code ?? "none"}, signal: ${signal ?? "none"})${diagnostic === void 0 ? "" : `: ${diagnostic}`}`;
|
|
2736
|
+
const error = new Error(message);
|
|
2737
|
+
error.code = "AGY_EARLY_EXIT";
|
|
2738
|
+
error.details = {
|
|
2739
|
+
exitCode: code ?? null,
|
|
2740
|
+
signal: signal ?? null,
|
|
2741
|
+
diagnostic
|
|
2742
|
+
};
|
|
2743
|
+
await this.loseTurn(session, error);
|
|
2744
|
+
}
|
|
2745
|
+
await channel?.close();
|
|
2746
|
+
await this.closeSteeringHook(session).catch(() => {});
|
|
2747
|
+
await session.mcpPlugin?.close();
|
|
2748
|
+
if (!session.restarting) await session.releaseResume?.();
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
})();
|
|
2752
|
+
const ended = () => {
|
|
2753
|
+
if (account && session.child === owned && !session.restarting) this.onAccountExit?.();
|
|
2754
|
+
};
|
|
2755
|
+
session.cleanup.then(ended, (error) => {
|
|
2756
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
2757
|
+
process.stderr.write(`AGY owned permission cleanup failed: ${redact(msg)}\n`);
|
|
2758
|
+
ended();
|
|
2759
|
+
});
|
|
2760
|
+
});
|
|
2761
|
+
try {
|
|
2762
|
+
await session.mcpPlugin?.launched(child.pid);
|
|
2763
|
+
} catch (error) {
|
|
2764
|
+
await this.stopProcess(child);
|
|
2765
|
+
await session.cleanup;
|
|
2766
|
+
throw error;
|
|
2767
|
+
}
|
|
2768
|
+
return this.audit(session, "launch", {
|
|
2769
|
+
cliPath: this.cliPath,
|
|
2770
|
+
args,
|
|
2771
|
+
effort: session.effort,
|
|
2772
|
+
pid: child.pid,
|
|
2773
|
+
cwd: session.cwd
|
|
2774
|
+
});
|
|
2775
|
+
}
|
|
2776
|
+
unresolvedTools(session) {
|
|
2777
|
+
return [...session.toolIds].filter(([, status]) => status === "pending").map(([toolCallId]) => ({
|
|
2778
|
+
toolCallId,
|
|
2779
|
+
...session.toolDetails.get(toolCallId)
|
|
2780
|
+
}));
|
|
2781
|
+
}
|
|
2782
|
+
unknownToolMessage(reason, tools) {
|
|
2783
|
+
return `${reason}: ${tools.map((tool) => `${tool.toolCallId} (${tool.name ?? "unknown tool"}, ${tool.state ?? "unknown state"})`).join(", ")}; execution state is unknown; do not replay these calls or reuse this session until their native state is reconciled`;
|
|
2784
|
+
}
|
|
2785
|
+
async settlePendingTools(session, active, message) {
|
|
2786
|
+
for (const [toolCallId, status] of session.toolIds) {
|
|
2787
|
+
if (status !== "pending") continue;
|
|
2788
|
+
session.toolIds.set(toolCallId, "settled");
|
|
2789
|
+
await active.client.notify("session/update", {
|
|
2790
|
+
sessionId: session.id,
|
|
2791
|
+
update: {
|
|
2792
|
+
sessionUpdate: "tool_call_update",
|
|
2793
|
+
toolCallId,
|
|
2794
|
+
status: "failed",
|
|
2795
|
+
content: [{
|
|
2796
|
+
type: "content",
|
|
2797
|
+
content: {
|
|
2798
|
+
type: "text",
|
|
2799
|
+
text: message
|
|
2800
|
+
}
|
|
2801
|
+
}]
|
|
2802
|
+
}
|
|
2803
|
+
});
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
async rejectUnconfirmedTurn(session, active, error, unresolved, preserveMessage = false) {
|
|
2807
|
+
const message = unresolved.length ? this.unknownToolMessage(error.message, unresolved) : error.message;
|
|
2808
|
+
if (unresolved.length) {
|
|
2809
|
+
error.details = {
|
|
2810
|
+
...error.details,
|
|
2811
|
+
unresolvedTools: unresolved
|
|
2812
|
+
};
|
|
2813
|
+
if (!preserveMessage) error.message = message;
|
|
2814
|
+
await this.settlePendingTools(session, active, message).catch(() => {});
|
|
2815
|
+
}
|
|
2816
|
+
session.failure = `${message}; create a fresh session`;
|
|
2817
|
+
active.reject(error);
|
|
2818
|
+
}
|
|
2819
|
+
async loseTurn(session, error) {
|
|
2820
|
+
const active = session.active;
|
|
2821
|
+
if (!active || session.cancelling) return;
|
|
2822
|
+
this.clearErrorResultWatchdog(active);
|
|
2823
|
+
session.active = void 0;
|
|
2824
|
+
const unresolved = this.unresolvedTools(session);
|
|
2825
|
+
if (unresolved.length) await this.audit(session, "tool_terminal_missing", {
|
|
2826
|
+
reason: "stream_lost",
|
|
2827
|
+
tools: unresolved
|
|
2828
|
+
}).catch((auditError) => {
|
|
2829
|
+
const msg = auditError instanceof Error ? auditError.message : String(auditError);
|
|
2830
|
+
error.details = {
|
|
2831
|
+
...error.details,
|
|
2832
|
+
retirementAuditError: msg
|
|
2833
|
+
};
|
|
2834
|
+
});
|
|
2835
|
+
await this.rejectUnconfirmedTurn(session, active, error, unresolved);
|
|
2836
|
+
}
|
|
2837
|
+
clearErrorResultWatchdog(active) {
|
|
2838
|
+
if (!active?.errorWatchdog) return;
|
|
2839
|
+
clearTimeout(active.errorWatchdog);
|
|
2840
|
+
active.errorWatchdog = void 0;
|
|
2841
|
+
}
|
|
2842
|
+
armErrorResultWatchdog(session, active) {
|
|
2843
|
+
this.clearErrorResultWatchdog(active);
|
|
2844
|
+
if (typeof this.errorResultWatchdogMs !== "number" || this.errorResultWatchdogMs <= 0 || !Number.isFinite(this.errorResultWatchdogMs)) return;
|
|
2845
|
+
if (session.active !== active || session.cancelling || session.restarting) return;
|
|
2846
|
+
const child = session.child;
|
|
2847
|
+
if (!child || child.exitCode !== null || child.signalCode !== null) return;
|
|
2848
|
+
const token = Symbol("errorWatchdog");
|
|
2849
|
+
active.errorWatchdogToken = token;
|
|
2850
|
+
const timer = setTimeout(() => {
|
|
2851
|
+
if (active.errorWatchdog === timer) active.errorWatchdog = void 0;
|
|
2852
|
+
if (session.active !== active || active.errorWatchdogToken !== token || session.cancelling || session.restarting || session.child !== child) return;
|
|
2853
|
+
session.queueInternalAction?.(() => this.onErrorResultWatchdog(session, active, child, token));
|
|
2854
|
+
}, this.errorResultWatchdogMs);
|
|
2855
|
+
timer.unref?.();
|
|
2856
|
+
active.errorWatchdog = timer;
|
|
2857
|
+
}
|
|
2858
|
+
async onErrorResultWatchdog(session, active, child, token) {
|
|
2859
|
+
if (session.active !== active || active.errorWatchdogToken !== token || session.cancelling || session.restarting || session.child !== child) return;
|
|
2860
|
+
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
2861
|
+
if (active.lastStepType !== "error_message" || active.lastStepState !== "DONE") return;
|
|
2862
|
+
const conversationId = session.init?.conversation_id ?? session.conversationId;
|
|
2863
|
+
const dbState = await inspectNativeErrorWatchdogState({
|
|
2864
|
+
nativeHome: this.nativeHome,
|
|
2865
|
+
conversationId
|
|
2866
|
+
});
|
|
2867
|
+
if (session.active !== active || active.errorWatchdogToken !== token || session.cancelling || session.restarting || session.child !== child) return;
|
|
2868
|
+
if (dbState.status === "retrying" && (active.consecutiveErrorSteps ?? 0) < 2) {
|
|
2869
|
+
this.armErrorResultWatchdog(session, active);
|
|
2870
|
+
return;
|
|
2871
|
+
}
|
|
2872
|
+
if (dbState.status === "no_terminal_error") return;
|
|
2873
|
+
const unresolved = this.unresolvedTools(session);
|
|
2874
|
+
const errorText = dbState.status === "terminal_error" ? dbState.error ?? "There was a network issue connecting to the server, please try again." : active.lastErrorStepText || "There was a network issue connecting to the server, please try again.";
|
|
2875
|
+
await this.audit(session, "error_result_watchdog_triggered", {
|
|
2876
|
+
conversationId,
|
|
2877
|
+
stepIndex: active.lastStepIndex,
|
|
2878
|
+
consecutiveErrorSteps: active.consecutiveErrorSteps ?? 1,
|
|
2879
|
+
dbStatus: dbState.status,
|
|
2880
|
+
unresolvedCount: unresolved.length
|
|
2881
|
+
});
|
|
2882
|
+
if (session.active !== active || session.cancelling) return;
|
|
2883
|
+
if (dbState.status === "incomplete_steps" || dbState.status === "db_error" || !active.promptConsumed || unresolved.length > 0) {
|
|
2884
|
+
session.broken = true;
|
|
2885
|
+
await session.permissionChannel?.close();
|
|
2886
|
+
await Promise.resolve(this.stopProcess(child)).catch(() => {});
|
|
2887
|
+
await session.exited;
|
|
2888
|
+
if (session.active !== active || session.cancelling) return;
|
|
2889
|
+
const error = /* @__PURE__ */ new Error(`AGY stalled after error_message step ${active.lastStepIndex ?? "unknown"} without emitting a terminal result (${dbState.status})`);
|
|
2890
|
+
error.code = "AGY_ERROR_RESULT_TIMEOUT";
|
|
2891
|
+
error.details = {
|
|
2892
|
+
conversationId,
|
|
2893
|
+
stepIndex: active.lastStepIndex,
|
|
2894
|
+
dbStatus: dbState.status
|
|
2895
|
+
};
|
|
2896
|
+
await this.loseTurn(session, error);
|
|
2897
|
+
return;
|
|
2898
|
+
}
|
|
2899
|
+
await this.event(session, {
|
|
2900
|
+
event: "result",
|
|
2901
|
+
result: {
|
|
2902
|
+
conversation_id: conversationId,
|
|
2903
|
+
status: "ERROR",
|
|
2904
|
+
error: errorText
|
|
2905
|
+
},
|
|
2906
|
+
_watchdogSynthesized: true,
|
|
2907
|
+
_watchdogConfirmedFlush: dbState.status === "terminal_error" || dbState.status === "missing_db" && NATIVE_ID.test(conversationId ?? "")
|
|
2908
|
+
});
|
|
2909
|
+
}
|
|
2910
|
+
async event(session, event) {
|
|
2911
|
+
if (!event || typeof event !== "object") throw new Error("Invalid AGY event");
|
|
2912
|
+
if (event.event === "init") {
|
|
2913
|
+
if (session.init) throw new Error("AGY sent duplicate init");
|
|
2914
|
+
const init = event.init;
|
|
2915
|
+
if (!(typeof init?.cwd === "string" && (process.platform === "win32" ? resolve(init.cwd).toLowerCase() === resolve(session.cwd).toLowerCase() : resolve(init.cwd) === resolve(session.cwd)))) throw new Error("AGY init cwd does not match the frozen workspace binding; do not run tools in another project");
|
|
2916
|
+
if (session.model !== "engine-default" && init?.model !== session.model) throw new Error("AGY init model does not match the explicit binding");
|
|
2917
|
+
if (session.conversationId && event.conversation_id !== session.conversationId) throw new Error("AGY init conversation does not match the exact native resume binding");
|
|
2918
|
+
session.init = event;
|
|
2919
|
+
await this.audit(session, "agy_init", {
|
|
2920
|
+
conversationId: event.conversation_id,
|
|
2921
|
+
model: init?.model,
|
|
2922
|
+
agent: init?.agent,
|
|
2923
|
+
cwd: init?.cwd,
|
|
2924
|
+
projectId: init?.project_id ?? event.project_id,
|
|
2925
|
+
permissionMode: init?.permission_mode,
|
|
2926
|
+
tools: init?.tools
|
|
2927
|
+
});
|
|
2928
|
+
return;
|
|
2929
|
+
}
|
|
2930
|
+
const active = session.active;
|
|
2931
|
+
if (!active && session.broken) return;
|
|
2932
|
+
if (!active) throw new Error("AGY event arrived outside an active turn");
|
|
2933
|
+
if (event.event === "step_update") {
|
|
2934
|
+
const step = event.step_update;
|
|
2935
|
+
if (!step || typeof step.step_type !== "string") throw new Error("Malformed AGY step");
|
|
2936
|
+
if (step.step_type === "user_input" && step.state === "DONE") {
|
|
2937
|
+
active.promptConsumed = true;
|
|
2938
|
+
active.continuationWriter = void 0;
|
|
2939
|
+
active.lastStepType = "user_input";
|
|
2940
|
+
active.lastStepState = step.state;
|
|
2941
|
+
active.lastStepIndex = step.step_index;
|
|
2942
|
+
active.consecutiveErrorSteps = 0;
|
|
2943
|
+
active.lastErrorStepText = void 0;
|
|
2944
|
+
active.finalResponseDone = false;
|
|
2945
|
+
active.finalResponseStepIndex = void 0;
|
|
2946
|
+
active.finalResponseText = "";
|
|
2947
|
+
if (Number.isSafeInteger(step.step_index)) active.progressFloor = Math.max(active.progressFloor, step.step_index);
|
|
2948
|
+
await this.audit(session, "prompt_consumed", { stepIndex: step.step_index });
|
|
2949
|
+
} else {
|
|
2950
|
+
active.lastStepType = step.step_type;
|
|
2951
|
+
active.lastStepState = step.state;
|
|
2952
|
+
active.lastStepIndex = step.step_index;
|
|
2953
|
+
if (step.step_type === "error_message") {
|
|
2954
|
+
active.consecutiveErrorSteps = (active.consecutiveErrorSteps ?? 0) + 1;
|
|
2955
|
+
const stepError = typeof step.error === "string" && step.error ? step.error : typeof step.error === "object" && step.error !== null && typeof step.error.message === "string" && step.error.message ? step.error.message : typeof step.text_delta === "string" && step.text_delta ? step.text_delta : void 0;
|
|
2956
|
+
if (stepError !== void 0) active.lastErrorStepText = stepError;
|
|
2957
|
+
} else {
|
|
2958
|
+
active.consecutiveErrorSteps = 0;
|
|
2959
|
+
active.lastErrorStepText = void 0;
|
|
2960
|
+
}
|
|
2961
|
+
if (step.step_type !== "agent_response") {
|
|
2962
|
+
active.finalResponseDone = false;
|
|
2963
|
+
active.finalResponseStepIndex = void 0;
|
|
2964
|
+
active.finalResponseText = "";
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
active.usageSteps ??= /* @__PURE__ */ new Set();
|
|
2968
|
+
active.usage ??= emptyUsage();
|
|
2969
|
+
if (accumulateStepUsage(active.usageSteps, active.usage, step)) await this.audit(session, "native_usage", {
|
|
2970
|
+
stepIndex: step.step_index,
|
|
2971
|
+
usage: { ...active.usage }
|
|
2972
|
+
});
|
|
2973
|
+
const freshStep = Boolean(active.promptConsumed) && Number.isSafeInteger(step.step_index) && step.step_index > active.progressFloor;
|
|
2974
|
+
if (step.step_type === "agent_response") {
|
|
2975
|
+
if (active.finalResponseStepIndex !== step.step_index) {
|
|
2976
|
+
active.finalResponseStepIndex = step.step_index;
|
|
2977
|
+
active.finalResponseText = "";
|
|
2978
|
+
active.finalResponseDone = false;
|
|
2979
|
+
}
|
|
2980
|
+
if (typeof step.text_delta === "string" && step.text_delta) {
|
|
2981
|
+
active.text += step.text_delta;
|
|
2982
|
+
active.finalResponseText += step.text_delta;
|
|
2983
|
+
await active.client.notify("session/update", {
|
|
2984
|
+
sessionId: session.id,
|
|
2985
|
+
update: {
|
|
2986
|
+
sessionUpdate: "agent_message_chunk",
|
|
2987
|
+
content: {
|
|
2988
|
+
type: "text",
|
|
2989
|
+
text: step.text_delta
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
});
|
|
2993
|
+
}
|
|
2994
|
+
active.finalResponseDone = step.state === "DONE" && active.finalResponseText.length > 0;
|
|
2995
|
+
if (freshStep && active.finalResponseDone && active.finalResponseText.trim()) active.progressSinceRecovery = true;
|
|
2996
|
+
}
|
|
2997
|
+
if (step.step_type === "tool" || step.step_type === "subagent") {
|
|
2998
|
+
const id = `agy-${event.conversation_id ?? session.init?.conversation_id}-${step.step_index}`;
|
|
2999
|
+
const previousName = session.toolDetails.get(id)?.name;
|
|
3000
|
+
const detail = {
|
|
3001
|
+
name: step.tool_name ?? step.tool_info?.name ?? previousName ?? (step.step_type === "subagent" ? "invoke_subagent" : void 0),
|
|
3002
|
+
state: step.state
|
|
3003
|
+
};
|
|
3004
|
+
const parameters = step.tool_info?.parameters ?? step.parameters;
|
|
3005
|
+
const structured = subagentPayload(step);
|
|
3006
|
+
const rawInput = structured === void 0 ? parameters : {
|
|
3007
|
+
...parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) ? parameters : {},
|
|
3008
|
+
...structured
|
|
3009
|
+
};
|
|
3010
|
+
const previousInput = session.toolInputs.get(id);
|
|
3011
|
+
if (rawInput !== void 0) session.toolInputs.set(id, rawInput);
|
|
3012
|
+
session.toolDetails.set(id, detail);
|
|
3013
|
+
if (!session.toolIds.has(id)) {
|
|
3014
|
+
session.toolIds.set(id, "pending");
|
|
3015
|
+
await active.client.notify("session/update", {
|
|
3016
|
+
sessionId: session.id,
|
|
3017
|
+
update: {
|
|
3018
|
+
sessionUpdate: "tool_call",
|
|
3019
|
+
toolCallId: id,
|
|
3020
|
+
title: detail.name ?? "AGY tool",
|
|
3021
|
+
name: detail.name,
|
|
3022
|
+
kind: "other",
|
|
3023
|
+
status: "in_progress",
|
|
3024
|
+
rawInput,
|
|
3025
|
+
...structured === void 0 ? {} : { _meta: structured }
|
|
3026
|
+
}
|
|
3027
|
+
});
|
|
3028
|
+
} else if (session.active === active && step.state !== "DONE" && step.state !== "ERROR" && session.toolIds.get(id) === "pending" && (detail.name !== previousName || rawInput !== void 0 && JSON.stringify(rawInput) !== JSON.stringify(previousInput))) await active.client.notify("session/update", {
|
|
3029
|
+
sessionId: session.id,
|
|
3030
|
+
update: {
|
|
3031
|
+
sessionUpdate: "tool_call_update",
|
|
3032
|
+
toolCallId: id,
|
|
3033
|
+
title: detail.name,
|
|
3034
|
+
name: detail.name,
|
|
3035
|
+
status: "in_progress",
|
|
3036
|
+
rawInput: rawInput ?? previousInput,
|
|
3037
|
+
...structured === void 0 ? {} : { _meta: structured }
|
|
3038
|
+
}
|
|
3039
|
+
});
|
|
3040
|
+
await this.audit(session, "tool_state", {
|
|
3041
|
+
toolCallId: id,
|
|
3042
|
+
...detail
|
|
3043
|
+
});
|
|
3044
|
+
if (session.active === active && (step.state === "DONE" || step.state === "ERROR") && session.toolIds.get(id) === "pending") {
|
|
3045
|
+
const failed = step.state === "ERROR" || Boolean(step.tool_info?.error);
|
|
3046
|
+
if (freshStep && !failed) active.progressSinceRecovery = true;
|
|
3047
|
+
const error = step.tool_info?.error ?? step.error;
|
|
3048
|
+
session.toolIds.set(id, "settled");
|
|
3049
|
+
const errorText = typeof error === "string" ? error : error?.message;
|
|
3050
|
+
const output = step.tool_info?.output ?? step.tool_info?.result ?? errorText ?? (failed ? "AGY tool reported an error" : void 0);
|
|
3051
|
+
const deniedCandidate = typeof errorText === "string" ? errorText : typeof output === "string" ? output : "";
|
|
3052
|
+
if (failed && /^tool call denied by pre-tool hook:/i.test(deniedCandidate.trimStart())) {
|
|
3053
|
+
(active.preToolDenied ??= /* @__PURE__ */ new Set()).add(id);
|
|
3054
|
+
await this.audit(session, "pre_tool_hook_denied", {
|
|
3055
|
+
toolCallId: id,
|
|
3056
|
+
error: errorText ?? output
|
|
3057
|
+
});
|
|
3058
|
+
}
|
|
3059
|
+
const finalInput = rawInput ?? previousInput;
|
|
3060
|
+
await active.client.notify("session/update", {
|
|
3061
|
+
sessionId: session.id,
|
|
3062
|
+
update: {
|
|
3063
|
+
sessionUpdate: "tool_call_update",
|
|
3064
|
+
toolCallId: id,
|
|
3065
|
+
title: detail.name,
|
|
3066
|
+
name: detail.name,
|
|
3067
|
+
status: failed ? "failed" : "completed",
|
|
3068
|
+
rawInput: finalInput,
|
|
3069
|
+
...structured === void 0 ? {} : { _meta: structured },
|
|
3070
|
+
rawOutput: output,
|
|
3071
|
+
content: typeof output === "string" ? [{
|
|
3072
|
+
type: "content",
|
|
3073
|
+
content: {
|
|
3074
|
+
type: "text",
|
|
3075
|
+
text: output
|
|
3076
|
+
}
|
|
3077
|
+
}] : void 0
|
|
3078
|
+
}
|
|
3079
|
+
});
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
if (step.step_type === "error_message" && step.state === "DONE") this.armErrorResultWatchdog(session, active);
|
|
3083
|
+
return;
|
|
3084
|
+
}
|
|
3085
|
+
this.clearErrorResultWatchdog(active);
|
|
3086
|
+
if (event.event !== "result" || !event.result) throw new Error(`Unsupported AGY event: ${event.event}`);
|
|
3087
|
+
const result = event.result;
|
|
3088
|
+
await this.audit(session, "agy_result", {
|
|
3089
|
+
conversationId: result.conversation_id,
|
|
3090
|
+
status: result.status,
|
|
3091
|
+
numTurns: result.num_turns,
|
|
3092
|
+
usage: result.usage,
|
|
3093
|
+
deniedActions: result.denied_actions,
|
|
3094
|
+
synthesizedByWatchdog: event._watchdogSynthesized === true ? true : void 0,
|
|
3095
|
+
responseSha256: createHash("sha256").update(result.response ?? "").digest("hex")
|
|
3096
|
+
});
|
|
3097
|
+
const newDenials = takeNewDenials(result.denied_actions, session.denialCounts);
|
|
3098
|
+
if (session.active !== active || session.cancelling) return;
|
|
3099
|
+
if (result.status === "SUCCESS" && session.mcpServers.length !== session.mcpReady.size) throw new Error("AGY did not activate and initialize the requested session MCP plugin; preserve native plugin/MCP off settings and review the connection instead of switching agents");
|
|
3100
|
+
const unresolved = this.unresolvedTools(session);
|
|
3101
|
+
const unresolvedMessage = unresolved.length ? this.unknownToolMessage("AGY terminal result arrived before a tool terminal update", unresolved) : void 0;
|
|
3102
|
+
if (unresolved.length) {
|
|
3103
|
+
session.broken = true;
|
|
3104
|
+
session.failure = unresolvedMessage;
|
|
3105
|
+
await this.audit(session, "tool_terminal_missing", {
|
|
3106
|
+
conversationId: result.conversation_id,
|
|
3107
|
+
nativeStatus: result.status,
|
|
3108
|
+
tools: unresolved
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
let error;
|
|
3112
|
+
let stopReason = "end_turn";
|
|
3113
|
+
let stopAfterResult = false;
|
|
3114
|
+
let postResponseTerminalError;
|
|
3115
|
+
const nonRecoverableError = /\b(?:401|403|429|RESOURCE_EXHAUSTED|UNAUTHENTICATED|PERMISSION_DENIED)\b|quota[\s_-]*(?:reached|exceeded|exhausted)|rate[\s_-]*limit|insufficient[\s_-]*quota|unauthorized|authentication\s+failed/i;
|
|
3116
|
+
const lateTransportDisconnect = result.status === "ERROR" && typeof result.error === "string" && /\b(?:wsarecv|wsasend|connectex|ECONNRESET|ETIMEDOUT|ECONNREFUSED|ENOTFOUND|EAI_AGAIN|EHOSTUNREACH|ENETUNREACH|EPIPE|EOF|UNAVAILABLE|DEADLINE_EXCEEDED|502|503|504)\b|socket\s+hang\s+up|dial\s+tcp|read\s+tcp|write\s+tcp|actively\s+refused|connection\s+refused|connection\s+attempt\s+failed|connection\s+was\s+forcibly\s+closed|broken\s+pipe|tls\s+handshake\s+timeout|context\s+deadline\s+exceeded|http2:\s+(?:client\s+connection\s+(?:lost|force\s+closed)|server\s+sent\s+GOAWAY)|stream\s+error:\s+stream\s+ID|bad\s+gateway|service\s+unavailable|gateway\s+timeout/i.test(result.error) && !nonRecoverableError.test(result.error);
|
|
3117
|
+
const replayedSummaryError = result.status === "ERROR" && typeof result.error === "string" && (result.error === "There was a network issue connecting to the server, please try again." || /^The stream was interrupted\. Please continue the task you were working on\.$/i.test(result.error)) && !nonRecoverableError.test(result.error);
|
|
3118
|
+
const confirmedFinalResponse = Boolean((lateTransportDisconnect || replayedSummaryError) && active.promptConsumed && !unresolved.length && active.steering.length === 0 && !active.steerDeliveryUnknown && active.lastStepType === "agent_response" && active.lastStepState === "DONE" && active.finalResponseDone && active.text.length > active.segmentStart && (lateTransportDisconnect ? typeof result.response !== "string" || result.response.length === 0 || result.response === active.text.slice(active.segmentStart) : typeof result.response === "string" && result.response.length > 0 && result.response === active.text.slice(active.segmentStart)));
|
|
3119
|
+
const recoverableNetworkError = (lateTransportDisconnect || replayedSummaryError) && !confirmedFinalResponse && Boolean(active.promptConsumed) && unresolved.length === 0 && active.steering.length === 0 && !active.steerDeliveryUnknown && !active.denied && newDenials.length === 0 && !active.preToolDenied?.size;
|
|
3120
|
+
if (recoverableNetworkError && active.progressSinceRecovery) {
|
|
3121
|
+
active.networkRecoveries = 0;
|
|
3122
|
+
active.progressSinceRecovery = false;
|
|
3123
|
+
}
|
|
3124
|
+
const continuationAllowed = recoverableNetworkError && active.networkRecoveries < this.maxConsecutiveNetworkRecoveries;
|
|
3125
|
+
if (continuationAllowed) {
|
|
3126
|
+
const attempt = active.networkRecoveries + 1;
|
|
3127
|
+
const preservedTools = session.toolIds.size;
|
|
3128
|
+
await this.audit(session, "network_recovery_requested", {
|
|
3129
|
+
conversationId: result.conversation_id,
|
|
3130
|
+
nativeStatus: result.status,
|
|
3131
|
+
error: result.error,
|
|
3132
|
+
attempt,
|
|
3133
|
+
totalAttempts: active.networkRecoveriesTotal + 1,
|
|
3134
|
+
preservedTools,
|
|
3135
|
+
preservedTextLength: active.text.length,
|
|
3136
|
+
liveChild: Boolean(session.child && session.child.exitCode === null && session.child.signalCode === null)
|
|
3137
|
+
});
|
|
3138
|
+
if (session.active !== active || session.cancelling) return;
|
|
3139
|
+
active.networkRecoveries = attempt;
|
|
3140
|
+
active.networkRecoveriesTotal += 1;
|
|
3141
|
+
try {
|
|
3142
|
+
const sent = await this.continueNetworkFailure(session, active, attempt, result, { allowForcedExit: event._watchdogConfirmedFlush === true });
|
|
3143
|
+
if (sent?.outcome === "sent") {
|
|
3144
|
+
await this.audit(session, "network_recovery_sent", {
|
|
3145
|
+
conversationId: sent.conversationId,
|
|
3146
|
+
attempt,
|
|
3147
|
+
relaunched: sent.relaunched,
|
|
3148
|
+
bytes: sent.bytes,
|
|
3149
|
+
frameSha256: sent.frameSha256
|
|
3150
|
+
});
|
|
3151
|
+
return;
|
|
3152
|
+
}
|
|
3153
|
+
active.networkRecoveries -= 1;
|
|
3154
|
+
active.networkRecoveriesTotal -= 1;
|
|
3155
|
+
if (sent?.outcome === "unknown") {
|
|
3156
|
+
const message = `AGY terminal status ${result.status}: ${result.error ?? "no success result"}; delivery of automatic continuation ${attempt} is unconfirmed; it is not re-sent and no new conversation is opened; inspect the native outcome before continuing`;
|
|
3157
|
+
await this.audit(session, "network_recovery_failed", {
|
|
3158
|
+
conversationId: result.conversation_id,
|
|
3159
|
+
attempt,
|
|
3160
|
+
delivery: "unknown"
|
|
3161
|
+
});
|
|
3162
|
+
error = new Error(message);
|
|
3163
|
+
error.details = {
|
|
3164
|
+
nativeError: result.error,
|
|
3165
|
+
attempt,
|
|
3166
|
+
recoveries: active.networkRecoveriesTotal,
|
|
3167
|
+
preservedTools,
|
|
3168
|
+
conversationId: result.conversation_id,
|
|
3169
|
+
delivery: "unknown"
|
|
3170
|
+
};
|
|
3171
|
+
session.broken = true;
|
|
3172
|
+
session.failure = message;
|
|
3173
|
+
stopAfterResult = true;
|
|
3174
|
+
} else if (sent?.outcome === "exit_unconfirmed") {
|
|
3175
|
+
const message = `AGY terminal status ${result.status}: ${result.error ?? "no success result"}; headless CLI did not exit cleanly after the terminal error (${sent.reason}; exitCode: ${sent.exitCode ?? "none"}, signal: ${sent.signal ?? "none"}); native state flush is unconfirmed, so automatic continuation was not sent; inspect the native outcome before continuing`;
|
|
3176
|
+
await this.audit(session, "network_recovery_failed", {
|
|
3177
|
+
conversationId: result.conversation_id,
|
|
3178
|
+
attempt,
|
|
3179
|
+
delivery: "not_sent",
|
|
3180
|
+
reason: sent.reason,
|
|
3181
|
+
exitCode: sent.exitCode ?? null,
|
|
3182
|
+
signal: sent.signal ?? null
|
|
3183
|
+
});
|
|
3184
|
+
error = new Error(message);
|
|
3185
|
+
error.details = {
|
|
3186
|
+
nativeError: result.error,
|
|
3187
|
+
attempt,
|
|
3188
|
+
recoveries: active.networkRecoveriesTotal,
|
|
3189
|
+
preservedTools,
|
|
3190
|
+
conversationId: result.conversation_id,
|
|
3191
|
+
delivery: "not_sent",
|
|
3192
|
+
reason: sent.reason,
|
|
3193
|
+
exitCode: sent.exitCode ?? null,
|
|
3194
|
+
signal: sent.signal ?? null
|
|
3195
|
+
};
|
|
3196
|
+
session.broken = true;
|
|
3197
|
+
session.failure = message;
|
|
3198
|
+
stopAfterResult = true;
|
|
3199
|
+
} else await this.audit(session, "network_recovery_skipped", {
|
|
3200
|
+
conversationId: result.conversation_id,
|
|
3201
|
+
attempt,
|
|
3202
|
+
reason: "conversation_evidence_incomplete"
|
|
3203
|
+
});
|
|
3204
|
+
} catch (continueError) {
|
|
3205
|
+
active.networkRecoveries -= 1;
|
|
3206
|
+
active.networkRecoveriesTotal -= 1;
|
|
3207
|
+
const continueMsg = continueError instanceof Error ? continueError.message : String(continueError);
|
|
3208
|
+
const message = `AGY terminal status ${result.status}: ${result.error ?? "no success result"}; automatic continuation ${attempt} could not be delivered: ${continueMsg}; delivery of the continuation is unknown and it is not retried; inspect the native outcome before continuing`;
|
|
3209
|
+
await this.audit(session, "network_recovery_failed", {
|
|
3210
|
+
conversationId: result.conversation_id,
|
|
3211
|
+
attempt,
|
|
3212
|
+
delivery: "unknown",
|
|
3213
|
+
error: continueMsg
|
|
3214
|
+
});
|
|
3215
|
+
error = new Error(message);
|
|
3216
|
+
error.details = {
|
|
3217
|
+
nativeError: result.error,
|
|
3218
|
+
attempt,
|
|
3219
|
+
recoveries: active.networkRecoveriesTotal,
|
|
3220
|
+
preservedTools,
|
|
3221
|
+
conversationId: result.conversation_id,
|
|
3222
|
+
delivery: "unknown"
|
|
3223
|
+
};
|
|
3224
|
+
session.broken = true;
|
|
3225
|
+
session.failure = message;
|
|
3226
|
+
stopAfterResult = true;
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
if (recoverableNetworkError && !continuationAllowed) {
|
|
3230
|
+
const preservedTools = session.toolIds.size;
|
|
3231
|
+
const consecutiveRecoveries = active.networkRecoveries;
|
|
3232
|
+
const message = `AGY terminal status ${result.status}: ${result.error ?? "no success result"}; automatic continuation stopped after ${consecutiveRecoveries} consecutive attempts without progress; every completed tool result (${preservedTools}) and native conversation ${result.conversation_id ?? "(unknown)"} are retained; load that exact native conversation to continue it, instead of replaying the prompt or the finished tool calls`;
|
|
3233
|
+
await this.audit(session, "network_recovery_exhausted", {
|
|
3234
|
+
conversationId: result.conversation_id,
|
|
3235
|
+
error: result.error,
|
|
3236
|
+
recoveries: active.networkRecoveriesTotal,
|
|
3237
|
+
consecutiveRecoveries,
|
|
3238
|
+
preservedTools
|
|
3239
|
+
});
|
|
3240
|
+
error = new Error(message);
|
|
3241
|
+
error.details = {
|
|
3242
|
+
nativeError: result.error,
|
|
3243
|
+
recoveries: active.networkRecoveriesTotal,
|
|
3244
|
+
consecutiveRecoveries,
|
|
3245
|
+
preservedTools,
|
|
3246
|
+
conversationId: result.conversation_id
|
|
3247
|
+
};
|
|
3248
|
+
session.broken = true;
|
|
3249
|
+
session.failure = message;
|
|
3250
|
+
stopAfterResult = true;
|
|
3251
|
+
}
|
|
3252
|
+
if (active.denied || newDenials.length > 0 || active.preToolDenied?.size) {
|
|
3253
|
+
active.denied = false;
|
|
3254
|
+
const actions = [...new Set(newDenials.map((action) => typeof action?.action === "string" ? action.action : "unknown"))];
|
|
3255
|
+
const message = `AGY permission denied${actions.length ? ` for ${actions.join(", ")}` : ""}; ${active.preToolDenied?.size ? "a PreToolUse hook rejected a tool before execution; retain the denial; terminal SUCCESS is not evidence that the requested work ran" : "the native AGY permission policy did not approve the action"}${unresolvedMessage ? `; ${unresolvedMessage}` : ""}`;
|
|
3256
|
+
await this.settlePendingTools(session, active, message);
|
|
3257
|
+
process.stderr.write(`${message}\n`);
|
|
3258
|
+
error = new Error(message);
|
|
3259
|
+
error.code = "AGY_PERMISSION_DENIED";
|
|
3260
|
+
error.details = {
|
|
3261
|
+
deniedToolCallIds: [...active.preToolDenied ?? []],
|
|
3262
|
+
unresolvedTools: unresolved
|
|
3263
|
+
};
|
|
3264
|
+
} else if (result.status === "CANCELED" || result.status === "INTERRUPTED" || result.status === "ERROR" && result.error === "interrupted") {
|
|
3265
|
+
const message = unresolvedMessage ?? `AGY turn ${result.status.toLowerCase()}; do not replay interrupted prompts or commands`;
|
|
3266
|
+
session.broken = true;
|
|
3267
|
+
session.failure = message;
|
|
3268
|
+
await this.settlePendingTools(session, active, message);
|
|
3269
|
+
stopReason = "cancelled";
|
|
3270
|
+
stopAfterResult = true;
|
|
3271
|
+
} else if (result.status !== "SUCCESS" && confirmedFinalResponse) {
|
|
3272
|
+
postResponseTerminalError = `AGY terminal status ${result.status}: ${result.error ?? "no success result"}`;
|
|
3273
|
+
session.broken = true;
|
|
3274
|
+
session.failure = postResponseTerminalError;
|
|
3275
|
+
stopAfterResult = true;
|
|
3276
|
+
} else if (result.status !== "SUCCESS" && error === void 0) {
|
|
3277
|
+
const message = `AGY terminal status ${result.status}: ${result.error ?? "no success result"}`;
|
|
3278
|
+
await this.settlePendingTools(session, active, unresolvedMessage ?? message);
|
|
3279
|
+
error = new Error(unresolvedMessage ? `${message}; ${unresolvedMessage}` : message);
|
|
3280
|
+
session.broken = true;
|
|
3281
|
+
session.failure = error.message;
|
|
3282
|
+
stopAfterResult = true;
|
|
3283
|
+
} else if (unresolvedMessage) {
|
|
3284
|
+
await this.settlePendingTools(session, active, unresolvedMessage);
|
|
3285
|
+
error = new Error(unresolvedMessage);
|
|
3286
|
+
error.code = "AGY_TOOL_TERMINAL_MISSING";
|
|
3287
|
+
error.details = {
|
|
3288
|
+
conversationId: result.conversation_id,
|
|
3289
|
+
unresolvedTools: unresolved
|
|
3290
|
+
};
|
|
3291
|
+
} else if (error === void 0 && active.text.length === active.segmentStart && result.response) await active.client.notify("session/update", {
|
|
3292
|
+
sessionId: session.id,
|
|
3293
|
+
update: {
|
|
3294
|
+
sessionUpdate: "agent_message_chunk",
|
|
3295
|
+
content: {
|
|
3296
|
+
type: "text",
|
|
3297
|
+
text: result.response
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
});
|
|
3301
|
+
if (session.active !== active || session.cancelling) return;
|
|
3302
|
+
if (postResponseTerminalError !== void 0) await this.audit(session, "post_response_terminal_error", {
|
|
3303
|
+
conversationId: result.conversation_id,
|
|
3304
|
+
status: result.status,
|
|
3305
|
+
error: result.error,
|
|
3306
|
+
stepIndex: active.finalResponseStepIndex,
|
|
3307
|
+
responseSha256: createHash("sha256").update(active.text).digest("hex")
|
|
3308
|
+
});
|
|
3309
|
+
if (stopReason === "cancelled") await this.audit(session, "cancel", {
|
|
3310
|
+
pid: session.child?.pid,
|
|
3311
|
+
processEnded: false,
|
|
3312
|
+
resumeSupported: false,
|
|
3313
|
+
unresolvedTools: unresolved
|
|
3314
|
+
});
|
|
3315
|
+
else if (!unresolved.length && error?.details?.["delivery"] !== "unknown" && error?.details?.["delivery"] !== "not_sent") await this.audit(session, "native_turn_reconciled", {
|
|
3316
|
+
status: result.status,
|
|
3317
|
+
preservedCompletedResponse: postResponseTerminalError !== void 0 ? true : void 0
|
|
3318
|
+
});
|
|
3319
|
+
if (session.active !== active || session.cancelling) return;
|
|
3320
|
+
session.active = void 0;
|
|
3321
|
+
if (stopAfterResult) {
|
|
3322
|
+
await session.permissionChannel?.close();
|
|
3323
|
+
await Promise.resolve(this.stopProcess(session.child)).catch(() => {});
|
|
3324
|
+
await session.exited;
|
|
3325
|
+
await this.closeSteeringHook(session).catch(() => {});
|
|
3326
|
+
await session.mcpPlugin?.close();
|
|
3327
|
+
if (!session.restarting) await session.releaseResume?.();
|
|
3328
|
+
}
|
|
3329
|
+
if (error) active.reject(error);
|
|
3330
|
+
else active.resolve({
|
|
3331
|
+
stopReason,
|
|
3332
|
+
...active.usageSteps?.size ? { usage: { ...active.usage } } : {}
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
async prompt(params, client) {
|
|
3336
|
+
const session = this.session(params.sessionId);
|
|
3337
|
+
if (session.broken) throw new Error(session.failure ?? "AGY process ended; create a fresh session (no implicit resume/history handoff)");
|
|
3338
|
+
if (session.active) throw new Error("AGY session already has an active turn");
|
|
3339
|
+
const content = promptText(params.prompt);
|
|
3340
|
+
const promise = new Promise((resolveTurn, rejectTurn) => {
|
|
3341
|
+
const active = {
|
|
3342
|
+
client,
|
|
3343
|
+
text: "",
|
|
3344
|
+
steering: [],
|
|
3345
|
+
networkRecoveries: 0,
|
|
3346
|
+
networkRecoveriesTotal: 0,
|
|
3347
|
+
segmentStart: 0,
|
|
3348
|
+
progressSinceRecovery: false,
|
|
3349
|
+
progressFloor: -1,
|
|
3350
|
+
recoveryAbort: new AbortController(),
|
|
3351
|
+
usageSteps: /* @__PURE__ */ new Set(),
|
|
3352
|
+
usage: emptyUsage(),
|
|
3353
|
+
denied: false,
|
|
3354
|
+
finalResponseText: "",
|
|
3355
|
+
resolve: (value) => {
|
|
3356
|
+
this.clearErrorResultWatchdog(active);
|
|
3357
|
+
this.releaseSteering(session, active);
|
|
3358
|
+
this.closeSteeringHook(session).catch(() => {}).then(() => resolveTurn(value));
|
|
3359
|
+
},
|
|
3360
|
+
reject: (error) => {
|
|
3361
|
+
this.clearErrorResultWatchdog(active);
|
|
3362
|
+
this.releaseSteering(session, active);
|
|
3363
|
+
this.closeSteeringHook(session).catch(() => {}).then(() => rejectTurn(error));
|
|
3364
|
+
}
|
|
3365
|
+
};
|
|
3366
|
+
session.active = active;
|
|
3367
|
+
});
|
|
3368
|
+
promise.catch(() => {});
|
|
3369
|
+
try {
|
|
3370
|
+
session.preparing = (async () => {
|
|
3371
|
+
await this.recoverDeadOwnedResources(session);
|
|
3372
|
+
await this.syncPermissionHook(session);
|
|
3373
|
+
await this.registerSteeringHook(session);
|
|
3374
|
+
if (!session.broken && !session.child) await this.start(session);
|
|
3375
|
+
})();
|
|
3376
|
+
try {
|
|
3377
|
+
await session.preparing;
|
|
3378
|
+
} finally {
|
|
3379
|
+
session.preparing = void 0;
|
|
3380
|
+
}
|
|
3381
|
+
if (session.broken) return await promise;
|
|
3382
|
+
await this.audit(session, "native_turn_pending");
|
|
3383
|
+
if (session.broken) return await promise;
|
|
3384
|
+
const frame = JSON.stringify({
|
|
3385
|
+
event: "user",
|
|
3386
|
+
message: { content }
|
|
3387
|
+
}) + "\n";
|
|
3388
|
+
try {
|
|
3389
|
+
await writeNdjsonFrame(session.child.stdin, frame);
|
|
3390
|
+
} catch (error) {
|
|
3391
|
+
if (session.broken) return await promise;
|
|
3392
|
+
throw error;
|
|
3393
|
+
}
|
|
3394
|
+
await this.audit(session, "prompt_sent", {
|
|
3395
|
+
bytes: Buffer.byteLength(frame),
|
|
3396
|
+
promptSha256: createHash("sha256").update(content).digest("hex"),
|
|
3397
|
+
frameSha256: createHash("sha256").update(frame).digest("hex"),
|
|
3398
|
+
delivery: "unchanged_user_text"
|
|
3399
|
+
});
|
|
3400
|
+
return await promise;
|
|
3401
|
+
} catch (error) {
|
|
3402
|
+
if (session.active) {
|
|
3403
|
+
this.clearErrorResultWatchdog(session.active);
|
|
3404
|
+
this.releaseSteering(session, session.active);
|
|
3405
|
+
session.active = void 0;
|
|
3406
|
+
}
|
|
3407
|
+
await this.closeSteeringHook(session).catch(() => {});
|
|
3408
|
+
throw error;
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
async cancel(params) {
|
|
3412
|
+
const session = this.session(params.sessionId);
|
|
3413
|
+
if (session.cancelling) return session.cancelling;
|
|
3414
|
+
session.cancelling = this.cancelOwnedSession(session);
|
|
3415
|
+
try {
|
|
3416
|
+
await session.cancelling;
|
|
3417
|
+
} finally {
|
|
3418
|
+
session.cancelling = void 0;
|
|
3419
|
+
}
|
|
3420
|
+
}
|
|
3421
|
+
/**
|
|
3422
|
+
* Continues the same native conversation after a recoverable network terminal error, using
|
|
3423
|
+
* only evidence the adapter already confirmed: the finished terminal result, the native UUID
|
|
3424
|
+
* conversation ID it named, settled tool states, and a natural process exit.
|
|
3425
|
+
*
|
|
3426
|
+
* After emitting a terminal `result: ERROR` frame, headless AGY ends its invocation loop and
|
|
3427
|
+
* exits once its native SQLite and transcript flush completes. Close its stdin, wait for that
|
|
3428
|
+
* natural exit, relaunch the CLI with the recorded `--conversation`, and send only the
|
|
3429
|
+
* continuation frame. If the process must be force-stopped on timeout or exits via a signal,
|
|
3430
|
+
* native persistence is unconfirmed and the continuation is not sent.
|
|
3431
|
+
*/
|
|
3432
|
+
async continueNetworkFailure(session, active, attempt, result, { allowForcedExit = false } = {}) {
|
|
3433
|
+
if (session.active !== active || session.cancelling || active.denied) return void 0;
|
|
3434
|
+
const conversationId = typeof result?.conversation_id === "string" && result.conversation_id ? result.conversation_id : void 0;
|
|
3435
|
+
if (!conversationId || !NATIVE_ID.test(conversationId)) return void 0;
|
|
3436
|
+
if (session.init?.conversation_id !== void 0 && session.init.conversation_id !== conversationId) return;
|
|
3437
|
+
if (session.conversationId !== void 0 && session.conversationId !== conversationId) return;
|
|
3438
|
+
const owned = session.child;
|
|
3439
|
+
if (!owned) return void 0;
|
|
3440
|
+
const frame = JSON.stringify({
|
|
3441
|
+
event: "user",
|
|
3442
|
+
message: { content: `${NETWORK_RECOVERY_INSTRUCTION} (automatic continuation ${attempt}).` }
|
|
3443
|
+
}) + "\n";
|
|
3444
|
+
session.restarting = true;
|
|
3445
|
+
let exitUnconfirmed;
|
|
3446
|
+
try {
|
|
3447
|
+
const prepare = async () => {
|
|
3448
|
+
let forceStopped = false;
|
|
3449
|
+
if (owned.exitCode === null && owned.signalCode === null) {
|
|
3450
|
+
owned.stdin?.end();
|
|
3451
|
+
let timer;
|
|
3452
|
+
const stopFallback = new Promise((_, reject) => {
|
|
3453
|
+
timer = setTimeout(() => {
|
|
3454
|
+
forceStopped = true;
|
|
3455
|
+
Promise.resolve(this.stopProcess(owned)).catch(reject);
|
|
3456
|
+
}, this.continuationExitGraceMs);
|
|
3457
|
+
});
|
|
3458
|
+
try {
|
|
3459
|
+
await Promise.race([session.exited, stopFallback]);
|
|
3460
|
+
} finally {
|
|
3461
|
+
clearTimeout(timer);
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
await session.exited;
|
|
3465
|
+
if (session.active !== active || session.cancelling) return;
|
|
3466
|
+
const exitCode = owned.exitCode ?? null;
|
|
3467
|
+
const signal = owned.signalCode ?? null;
|
|
3468
|
+
await session.permissionChannel?.close();
|
|
3469
|
+
await this.closeSteeringHook(session);
|
|
3470
|
+
await session.mcpPlugin?.close();
|
|
3471
|
+
session.child = void 0;
|
|
3472
|
+
session.init = void 0;
|
|
3473
|
+
session.exited = void 0;
|
|
3474
|
+
session.cleanup = void 0;
|
|
3475
|
+
session.permissionChannel = void 0;
|
|
3476
|
+
session.mcpPlugin = void 0;
|
|
3477
|
+
session.mcpBound.clear();
|
|
3478
|
+
session.mcpReady.clear();
|
|
3479
|
+
if (!allowForcedExit && (forceStopped || signal !== null || !Number.isSafeInteger(exitCode) || exitCode < 0)) {
|
|
3480
|
+
exitUnconfirmed = {
|
|
3481
|
+
outcome: "exit_unconfirmed",
|
|
3482
|
+
conversationId,
|
|
3483
|
+
reason: forceStopped ? "exit_timeout_stopped" : signal !== null ? "signal_exit" : "missing_exit_code",
|
|
3484
|
+
exitCode,
|
|
3485
|
+
signal
|
|
3486
|
+
};
|
|
3487
|
+
return;
|
|
3488
|
+
}
|
|
3489
|
+
await this.audit(session, "close", {
|
|
3490
|
+
pid: owned.pid,
|
|
3491
|
+
processEnded: true,
|
|
3492
|
+
exitCode,
|
|
3493
|
+
signal,
|
|
3494
|
+
forcedAfterWatchdog: allowForcedExit && forceStopped ? true : void 0
|
|
3495
|
+
});
|
|
3496
|
+
const backoff = this.networkRecoveryBackoffMs[Math.min(attempt - 1, this.networkRecoveryBackoffMs.length - 1)] ?? 0;
|
|
3497
|
+
const { signal: recoverySignal } = active.recoveryAbort;
|
|
3498
|
+
if (backoff > 0) try {
|
|
3499
|
+
await setTimeout$1(backoff, void 0, { signal: recoverySignal });
|
|
3500
|
+
} catch (error) {
|
|
3501
|
+
if (error.code !== "ABORT_ERR") throw error;
|
|
3502
|
+
}
|
|
3503
|
+
if (session.active !== active || session.cancelling || recoverySignal.aborted) return;
|
|
3504
|
+
session.conversationId = conversationId;
|
|
3505
|
+
session.broken = false;
|
|
3506
|
+
await this.syncPermissionHook(session);
|
|
3507
|
+
await this.registerSteeringHook(session);
|
|
3508
|
+
if (session.active !== active || session.cancelling) return;
|
|
3509
|
+
await this.start(session);
|
|
3510
|
+
};
|
|
3511
|
+
session.preparing = prepare();
|
|
3512
|
+
try {
|
|
3513
|
+
await session.preparing;
|
|
3514
|
+
} finally {
|
|
3515
|
+
session.preparing = void 0;
|
|
3516
|
+
}
|
|
3517
|
+
} finally {
|
|
3518
|
+
session.restarting = false;
|
|
3519
|
+
}
|
|
3520
|
+
if (exitUnconfirmed) return exitUnconfirmed;
|
|
3521
|
+
if (session.active !== active || session.broken || session.cancelling) return void 0;
|
|
3522
|
+
const relaunched = await this.#writeContinuation(session, active, frame);
|
|
3523
|
+
if (relaunched === "not-written") return void 0;
|
|
3524
|
+
if (relaunched === "unknown") return {
|
|
3525
|
+
outcome: "unknown",
|
|
3526
|
+
conversationId
|
|
3527
|
+
};
|
|
3528
|
+
return {
|
|
3529
|
+
outcome: "sent",
|
|
3530
|
+
conversationId,
|
|
3531
|
+
relaunched: true,
|
|
3532
|
+
bytes: Buffer.byteLength(frame),
|
|
3533
|
+
frameSha256: createHash("sha256").update(frame).digest("hex")
|
|
3534
|
+
};
|
|
3535
|
+
}
|
|
3536
|
+
async #writeContinuation(session, active, frame) {
|
|
3537
|
+
const child = session.child;
|
|
3538
|
+
if (!child || child.exitCode !== null || child.signalCode !== null) return "not-written";
|
|
3539
|
+
active.continuationWriter = child;
|
|
3540
|
+
active.promptConsumed = false;
|
|
3541
|
+
active.consecutiveErrorSteps = 0;
|
|
3542
|
+
active.lastErrorStepText = void 0;
|
|
3543
|
+
active.segmentStart = active.text.length;
|
|
3544
|
+
active.finalResponseDone = false;
|
|
3545
|
+
active.finalResponseStepIndex = void 0;
|
|
3546
|
+
active.finalResponseText = "";
|
|
3547
|
+
active.progressSinceRecovery = false;
|
|
3548
|
+
try {
|
|
3549
|
+
await writeNdjsonFrame(child.stdin, frame);
|
|
3550
|
+
return "written";
|
|
3551
|
+
} catch {
|
|
3552
|
+
return "unknown";
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
async cancelOwnedSession(session) {
|
|
3556
|
+
const active = session.active;
|
|
3557
|
+
this.clearErrorResultWatchdog(active);
|
|
3558
|
+
active?.recoveryAbort.abort();
|
|
3559
|
+
session.broken = true;
|
|
3560
|
+
let requestAuditError;
|
|
3561
|
+
try {
|
|
3562
|
+
try {
|
|
3563
|
+
await this.audit(session, "cancel_requested", {
|
|
3564
|
+
pid: session.child?.pid,
|
|
3565
|
+
resumeSupported: false
|
|
3566
|
+
});
|
|
3567
|
+
} catch (error) {
|
|
3568
|
+
requestAuditError = error;
|
|
3569
|
+
}
|
|
3570
|
+
await session.preparing?.catch(() => {});
|
|
3571
|
+
await session.permissionChannel?.close();
|
|
3572
|
+
await this.stopProcess(session.child);
|
|
3573
|
+
await session.exited;
|
|
3574
|
+
await session.cleanup;
|
|
3575
|
+
await this.closeSteeringHook(session).catch(() => {});
|
|
3576
|
+
await session.mcpPlugin?.close();
|
|
3577
|
+
if (requestAuditError !== void 0) throw asAgyError(requestAuditError);
|
|
3578
|
+
const unresolved = this.unresolvedTools(session);
|
|
3579
|
+
if (active && unresolved.length) await this.settlePendingTools(session, active, this.unknownToolMessage("AGY turn cancelled before a tool terminal update", unresolved));
|
|
3580
|
+
await this.audit(session, "cancel", {
|
|
3581
|
+
pid: session.child?.pid,
|
|
3582
|
+
processEnded: true,
|
|
3583
|
+
resumeSupported: false,
|
|
3584
|
+
unresolvedTools: unresolved
|
|
3585
|
+
});
|
|
3586
|
+
active?.resolve({ stopReason: "cancelled" });
|
|
3587
|
+
} catch (error) {
|
|
3588
|
+
await session.drainReceived?.();
|
|
3589
|
+
session.active = void 0;
|
|
3590
|
+
const unresolved = this.unresolvedTools(session);
|
|
3591
|
+
const exitCode = session.child?.exitCode ?? null;
|
|
3592
|
+
const signal = session.child?.signalCode ?? null;
|
|
3593
|
+
const outcome = {
|
|
3594
|
+
processEnded: exitCode !== null || signal !== null,
|
|
3595
|
+
exitCode,
|
|
3596
|
+
signal
|
|
3597
|
+
};
|
|
3598
|
+
const failure = asAgyError(requestAuditError ?? error);
|
|
3599
|
+
const errObj = asAgyError(error);
|
|
3600
|
+
const cancelError = failure === error ? void 0 : {
|
|
3601
|
+
code: errObj.code,
|
|
3602
|
+
message: errObj.message
|
|
3603
|
+
};
|
|
3604
|
+
failure.details = {
|
|
3605
|
+
...failure.details,
|
|
3606
|
+
...outcome,
|
|
3607
|
+
cancelError
|
|
3608
|
+
};
|
|
3609
|
+
await this.audit(session, "cancel_failed", {
|
|
3610
|
+
pid: session.child?.pid,
|
|
3611
|
+
...outcome,
|
|
3612
|
+
unresolvedTools: unresolved,
|
|
3613
|
+
cancelError
|
|
3614
|
+
}).catch((auditError) => {
|
|
3615
|
+
const msg = auditError instanceof Error ? auditError.message : String(auditError);
|
|
3616
|
+
failure.details = {
|
|
3617
|
+
...failure.details,
|
|
3618
|
+
retirementAuditError: msg
|
|
3619
|
+
};
|
|
3620
|
+
});
|
|
3621
|
+
if (active) await this.rejectUnconfirmedTurn(session, active, failure, unresolved, failure === requestAuditError);
|
|
3622
|
+
throw failure;
|
|
3623
|
+
} finally {
|
|
3624
|
+
session.active = void 0;
|
|
3625
|
+
}
|
|
3626
|
+
}
|
|
3627
|
+
close() {
|
|
3628
|
+
this.closePromise ??= Promise.all([...this.sessions.values()].map(async (session) => {
|
|
3629
|
+
if (session.cancelling) await session.cancelling.catch(() => {});
|
|
3630
|
+
const active = session.active;
|
|
3631
|
+
this.clearErrorResultWatchdog(active);
|
|
3632
|
+
session.active = void 0;
|
|
3633
|
+
session.broken = true;
|
|
3634
|
+
try {
|
|
3635
|
+
const unresolved = this.unresolvedTools(session);
|
|
3636
|
+
if (active && unresolved.length) {
|
|
3637
|
+
await this.audit(session, "tool_terminal_missing", {
|
|
3638
|
+
reason: "connection_closed",
|
|
3639
|
+
tools: unresolved
|
|
3640
|
+
});
|
|
3641
|
+
await this.settlePendingTools(session, active, this.unknownToolMessage("ACP connection closed before a tool terminal update", unresolved));
|
|
3642
|
+
}
|
|
3643
|
+
} finally {
|
|
3644
|
+
active?.reject(/* @__PURE__ */ new Error("ACP connection closed"));
|
|
3645
|
+
await session.preparing?.catch(() => {});
|
|
3646
|
+
await session.permissionChannel?.close();
|
|
3647
|
+
if (session.child && session.child.exitCode === null && session.child.signalCode === null) {
|
|
3648
|
+
session.child.stdin?.end();
|
|
3649
|
+
let timer;
|
|
3650
|
+
const stopFailure = new Promise((_, reject) => {
|
|
3651
|
+
timer = setTimeout(() => {
|
|
3652
|
+
Promise.resolve(this.stopProcess(session.child)).catch(reject);
|
|
3653
|
+
}, 3e3);
|
|
3654
|
+
});
|
|
3655
|
+
try {
|
|
3656
|
+
await Promise.race([session.exited, stopFailure]);
|
|
3657
|
+
} finally {
|
|
3658
|
+
clearTimeout(timer);
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
await session.cleanup;
|
|
3662
|
+
await this.closeSteeringHook(session).catch(() => {});
|
|
3663
|
+
await session.mcpPlugin?.close();
|
|
3664
|
+
await session.releaseResume?.();
|
|
3665
|
+
await this.audit(session, "close", {
|
|
3666
|
+
pid: session.child?.pid,
|
|
3667
|
+
processEnded: true
|
|
3668
|
+
});
|
|
3669
|
+
}
|
|
3670
|
+
}));
|
|
3671
|
+
return this.closePromise;
|
|
3672
|
+
}
|
|
3673
|
+
};
|
|
831
3674
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
3675
|
+
//#endregion
|
|
3676
|
+
//#region src/sessionMcp.ts
|
|
3677
|
+
async function runSessionMcp(key) {
|
|
3678
|
+
if (!/^KIKI_AGY_MCP_[a-f0-9_]+_[0-9]+$/.test(key)) throw new Error("Invalid session MCP environment key");
|
|
3679
|
+
const rawServer = process.env[key];
|
|
3680
|
+
if (rawServer === void 0) {
|
|
3681
|
+
for await (const line of readNdjsonLines(process.stdin)) {
|
|
3682
|
+
if (!line.trim()) continue;
|
|
3683
|
+
const request = JSON.parse(line);
|
|
3684
|
+
if (!Object.hasOwn(request, "id")) continue;
|
|
3685
|
+
let result;
|
|
3686
|
+
if (request.method === "initialize") result = {
|
|
3687
|
+
protocolVersion: request.params?.protocolVersion,
|
|
3688
|
+
capabilities: {
|
|
3689
|
+
tools: {},
|
|
3690
|
+
resources: {},
|
|
3691
|
+
prompts: {}
|
|
3692
|
+
},
|
|
3693
|
+
serverInfo: {
|
|
3694
|
+
name: "kiki-unbound-session",
|
|
3695
|
+
version: "1"
|
|
3696
|
+
}
|
|
3697
|
+
};
|
|
3698
|
+
else if (request.method === "tools/list") result = { tools: [] };
|
|
3699
|
+
else if (request.method === "resources/list") result = { resources: [] };
|
|
3700
|
+
else if (request.method === "resources/templates/list") result = { resourceTemplates: [] };
|
|
3701
|
+
else if (request.method === "prompts/list") result = { prompts: [] };
|
|
3702
|
+
else if (request.method === "ping") result = {};
|
|
3703
|
+
process.stdout.write(JSON.stringify(result === void 0 ? {
|
|
3704
|
+
jsonrpc: "2.0",
|
|
3705
|
+
id: request.id,
|
|
3706
|
+
error: {
|
|
3707
|
+
code: -32601,
|
|
3708
|
+
message: "No Kiki session lease is bound to this process"
|
|
3709
|
+
}
|
|
3710
|
+
} : {
|
|
3711
|
+
jsonrpc: "2.0",
|
|
3712
|
+
id: request.id,
|
|
3713
|
+
result
|
|
3714
|
+
}) + "\n");
|
|
3715
|
+
}
|
|
3716
|
+
return;
|
|
3717
|
+
}
|
|
3718
|
+
const server = JSON.parse(rawServer);
|
|
3719
|
+
if (!server || typeof server.command !== "string" || !Array.isArray(server.args) || !Array.isArray(server.env)) throw new Error("Session MCP launch context is invalid");
|
|
3720
|
+
if ((await requestHookPermission({
|
|
3721
|
+
type: "mcp_bootstrap",
|
|
3722
|
+
key
|
|
3723
|
+
}, process.env, 1e4)).decision !== "allow") throw new Error("The session MCP bootstrap was not admitted by its owning adapter");
|
|
3724
|
+
const env = {
|
|
3725
|
+
...process.env,
|
|
3726
|
+
...Object.fromEntries(server.env.map((entry) => [entry.name, entry.value]))
|
|
3727
|
+
};
|
|
3728
|
+
for (const name of Object.keys(env)) if (name.startsWith("KIKI_AGY_")) delete env[name];
|
|
3729
|
+
const child = spawn(server.command, server.args, {
|
|
3730
|
+
env,
|
|
3731
|
+
stdio: [
|
|
3732
|
+
"pipe",
|
|
3733
|
+
"pipe",
|
|
3734
|
+
"pipe"
|
|
3735
|
+
],
|
|
3736
|
+
windowsHide: true
|
|
3737
|
+
});
|
|
3738
|
+
const closed = new Promise((done) => child.once("close", done));
|
|
3739
|
+
const outputAbort = new AbortController();
|
|
3740
|
+
const inputAbort = new AbortController();
|
|
3741
|
+
let failure;
|
|
3742
|
+
const fail = (error) => {
|
|
3743
|
+
failure ??= error;
|
|
3744
|
+
outputAbort.abort();
|
|
3745
|
+
};
|
|
3746
|
+
child.once("error", fail);
|
|
3747
|
+
child.stdin.on("error", fail);
|
|
3748
|
+
const lists = /* @__PURE__ */ new Set();
|
|
3749
|
+
const pumpInput = (async () => {
|
|
3750
|
+
try {
|
|
3751
|
+
for await (const line of readNdjsonLines(process.stdin, { signal: inputAbort.signal })) {
|
|
3752
|
+
try {
|
|
3753
|
+
const frame = JSON.parse(line);
|
|
3754
|
+
if (frame.method === "tools/list" && frame.id !== void 0) lists.add(frame.id);
|
|
3755
|
+
} catch {}
|
|
3756
|
+
if (!child.stdin.destroyed && !child.stdin.writableEnded) child.stdin.write(line + "\n");
|
|
3757
|
+
}
|
|
3758
|
+
if (!child.stdin.destroyed && !child.stdin.writableEnded) child.stdin.end();
|
|
3759
|
+
} catch {}
|
|
3760
|
+
})();
|
|
3761
|
+
child.stderr.pipe(process.stderr);
|
|
3762
|
+
const stop = () => {
|
|
3763
|
+
terminate(child).catch(fail);
|
|
3764
|
+
};
|
|
3765
|
+
process.once("SIGTERM", stop);
|
|
3766
|
+
process.once("SIGINT", stop);
|
|
3767
|
+
try {
|
|
3768
|
+
let ready = false;
|
|
3769
|
+
for await (const line of readNdjsonLines(child.stdout, { signal: outputAbort.signal })) {
|
|
3770
|
+
let frame;
|
|
3771
|
+
try {
|
|
3772
|
+
frame = JSON.parse(line);
|
|
3773
|
+
} catch {}
|
|
3774
|
+
if (!ready && lists.has(frame?.id) && Array.isArray(frame?.result?.tools)) {
|
|
3775
|
+
if ((await requestHookPermission({
|
|
3776
|
+
type: "mcp_ready",
|
|
3777
|
+
key
|
|
3778
|
+
}, process.env, 1e4)).decision !== "allow") throw new Error("The session MCP readiness was not admitted by its owning adapter");
|
|
3779
|
+
ready = true;
|
|
3780
|
+
}
|
|
3781
|
+
process.stdout.write(line + "\n");
|
|
3782
|
+
}
|
|
3783
|
+
if (failure instanceof Error) throw new Error(failure.message, { cause: failure });
|
|
3784
|
+
if (failure) throw new Error("AGY session MCP child failed", { cause: failure });
|
|
3785
|
+
process.exitCode = await closed ?? 1;
|
|
3786
|
+
} finally {
|
|
3787
|
+
inputAbort.abort();
|
|
3788
|
+
process.stdin.pause();
|
|
3789
|
+
outputAbort.abort();
|
|
3790
|
+
process.removeListener("SIGTERM", stop);
|
|
3791
|
+
process.removeListener("SIGINT", stop);
|
|
3792
|
+
if (child.pid !== void 0) await terminate(child);
|
|
3793
|
+
await closed;
|
|
3794
|
+
await pumpInput;
|
|
3795
|
+
}
|
|
863
3796
|
}
|
|
864
3797
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
3798
|
+
//#endregion
|
|
3799
|
+
//#region src/index.ts
|
|
3800
|
+
async function runBridge({ sdkPath, cliPath, cliPrefix = [], auditDir, model = DEFAULT, account } = {}) {
|
|
3801
|
+
if (!isAbsolute(sdkPath ?? "")) throw new Error("Pass an installed ACP SDK absolute path");
|
|
3802
|
+
const acp = await import(pathToFileURL(sdkPath).href);
|
|
3803
|
+
const bridge = new AgyBridge({
|
|
3804
|
+
cliPath,
|
|
3805
|
+
cliPrefix,
|
|
3806
|
+
auditDir,
|
|
3807
|
+
model,
|
|
3808
|
+
account,
|
|
3809
|
+
onAccountExit: () => setImmediate(shutdown)
|
|
3810
|
+
});
|
|
3811
|
+
await bridge.loadVendorModels();
|
|
3812
|
+
const sessionRequest = (handler) => async (ctx) => {
|
|
3813
|
+
try {
|
|
3814
|
+
return await handler(ctx);
|
|
3815
|
+
} catch (error) {
|
|
3816
|
+
if (account) setImmediate(shutdown);
|
|
3817
|
+
const agyErr = error;
|
|
3818
|
+
throw new acp.RequestError(-32603, error instanceof Error ? error.message : String(error), {
|
|
3819
|
+
adapterCode: agyErr?.code,
|
|
3820
|
+
details: agyErr?.details
|
|
3821
|
+
});
|
|
3822
|
+
}
|
|
3823
|
+
};
|
|
3824
|
+
const connection = acp.agent({
|
|
3825
|
+
name: "agy-cli-acp",
|
|
3826
|
+
version: "0.2.0"
|
|
3827
|
+
}).onRequest("initialize", () => bridge.initialize(acp.PROTOCOL_VERSION)).onRequest("session/new", sessionRequest((ctx) => bridge.newSession(ctx.params))).onRequest("session/load", sessionRequest((ctx) => bridge.loadSession(ctx.params))).onRequest("session/set_config_option", (ctx) => bridge.setConfig(ctx.params)).onRequest("session/prompt", sessionRequest((ctx) => bridge.prompt(ctx.params, ctx.client))).onRequest("_session/steering", (params) => params, sessionRequest((ctx) => bridge.steer(ctx.params))).onNotification("session/cancel", (ctx) => bridge.cancel(ctx.params)).connect(acp.ndJsonStream(Writable.toWeb(process.stdout), Readable.toWeb(process.stdin)));
|
|
3828
|
+
let shuttingDown = false;
|
|
3829
|
+
const shutdown = () => {
|
|
3830
|
+
if (shuttingDown) return;
|
|
3831
|
+
shuttingDown = true;
|
|
3832
|
+
bridge.close().then(() => process.exit(0), (error) => {
|
|
3833
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
3834
|
+
process.exit(1);
|
|
3835
|
+
});
|
|
3836
|
+
};
|
|
3837
|
+
process.once("SIGTERM", shutdown);
|
|
3838
|
+
process.once("SIGINT", shutdown);
|
|
3839
|
+
process.stdin.once("end", shutdown);
|
|
3840
|
+
try {
|
|
3841
|
+
await connection.closed;
|
|
3842
|
+
} finally {
|
|
3843
|
+
await bridge.close();
|
|
3844
|
+
}
|
|
889
3845
|
}
|
|
3846
|
+
if (process.argv[1] && pathToFileURL(resolve(process.argv[1])).href === import.meta.url) if (process.argv.includes("--version") || process.argv.length === 3 && process.argv[2] === "--kiki-harness-account-version") console.log("agy-cli-acp 0.2.0");
|
|
3847
|
+
else {
|
|
3848
|
+
const args = process.argv.slice(2);
|
|
3849
|
+
if (args.length === 2 && args[0] === "--mcp-stdio") runSessionMcp(args[1]).catch((error) => {
|
|
3850
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
3851
|
+
process.exitCode = 1;
|
|
3852
|
+
});
|
|
3853
|
+
else if (args.length === 3 && args[0] === "--recover-project-mcp") {
|
|
3854
|
+
if (!isAbsolute(args[1])) throw new Error("AGY MCP recovery workspace must be absolute");
|
|
3855
|
+
recoverProjectMcpPlugin({
|
|
3856
|
+
cwd: args[1],
|
|
3857
|
+
sessionId: args[2]
|
|
3858
|
+
}).then((result) => console.log(JSON.stringify(result))).catch((error) => {
|
|
3859
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
3860
|
+
process.exitCode = 1;
|
|
3861
|
+
});
|
|
3862
|
+
} else if (args.length === 2 && args[0] === "--recover-project-hook") {
|
|
3863
|
+
if (!isAbsolute(args[1])) throw new Error("AGY hook recovery workspace must be absolute");
|
|
3864
|
+
recoverProjectHook({
|
|
3865
|
+
cwd: args[1],
|
|
3866
|
+
nodePath: process.execPath,
|
|
3867
|
+
handlerPath: fileURLToPath(new URL("./agy-permission-hook.mjs", import.meta.url))
|
|
3868
|
+
}).then((result) => console.log(JSON.stringify(result))).catch((error) => {
|
|
3869
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
3870
|
+
process.exitCode = 1;
|
|
3871
|
+
});
|
|
3872
|
+
} else {
|
|
3873
|
+
const accountBound = args.at(-1) === "--kiki-harness-account";
|
|
3874
|
+
if (accountBound) args.pop();
|
|
3875
|
+
if (args.length && (args.length !== 2 || args[0] !== "--model")) throw new Error("Only --model <AGY model ID> or --recover-project-hook <workspace> is supported");
|
|
3876
|
+
const account = accountBound ? consumeAccountEnvironment() : void 0;
|
|
3877
|
+
runBridge({
|
|
3878
|
+
sdkPath: process.env["AGY_ACP_SDK_PATH"],
|
|
3879
|
+
cliPath: process.env["AGY_CLI_PATH"],
|
|
3880
|
+
auditDir: process.env["AGY_BRIDGE_AUDIT_DIR"],
|
|
3881
|
+
model: args[1] ?? "engine-default",
|
|
3882
|
+
account
|
|
3883
|
+
}).catch((error) => {
|
|
3884
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
3885
|
+
process.exitCode = 1;
|
|
3886
|
+
});
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
|
|
3890
|
+
//#endregion
|
|
3891
|
+
export { AgyBridge, NdjsonFrameDecoder, accumulateStepUsage, catalogDiagnostic, configOptions, consumeAccountEnvironment, createNdjsonLineTransform, encodeNativeMessage, encodedEffort, launchArgs, nativeBytesAt, nativeStringsAt, promptText, readLegacyNativeRecovery, readNdjsonLines, readVendorModelCatalog, runBridge, runSessionMcp, takeNewDenials, validateEffort, vendorModelIds, writeNdjsonFrame };
|