@mindistryx/pi-arabic-runtime 0.0.0-stage → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +26 -2
- package/THIRD-PARTY-NOTICES.md +17 -0
- package/arguments.mjs +20 -0
- package/extension/command.mjs +31 -0
- package/extension/extension.mjs +32 -0
- package/extension/mode.mjs +48 -0
- package/extension/reader.mjs +33 -0
- package/launcher.mjs +34 -0
- package/licenses/Apache-2.0.txt +201 -0
- package/licenses/Unicode-3.0.txt +39 -0
- package/licenses/_anthropic-ai_sdk-0.129.0-LICENSE +8 -0
- package/licenses/_aws-sdk_client-bedrock-runtime-3.1127.0-LICENSE +201 -0
- package/licenses/_aws-sdk_core-3.977.9-LICENSE +201 -0
- package/licenses/_aws-sdk_credential-provider-env-3.972.70-LICENSE +201 -0
- package/licenses/_aws-sdk_credential-provider-ini-3.973.15-LICENSE +201 -0
- package/licenses/_aws-sdk_credential-provider-node-3.972.82-LICENSE +201 -0
- package/licenses/_aws-sdk_credential-provider-process-3.972.70-LICENSE +201 -0
- package/licenses/_aws-sdk_credential-provider-sso-3.973.14-LICENSE +201 -0
- package/licenses/_aws-sdk_credential-provider-web-identity-3.972.76-LICENSE +201 -0
- package/licenses/_aws-sdk_eventstream-handler-node-3.972.34-LICENSE +201 -0
- package/licenses/_aws-sdk_middleware-eventstream-3.972.29-LICENSE +201 -0
- package/licenses/_aws-sdk_middleware-websocket-3.972.52-LICENSE +201 -0
- package/licenses/_aws-sdk_signature-v4-multi-region-3.996.46-LICENSE +201 -0
- package/licenses/_aws-sdk_token-providers-3.1116.0-LICENSE +201 -0
- package/licenses/_aws-sdk_token-providers-3.1127.0-LICENSE +201 -0
- package/licenses/_aws-sdk_types-3.974.5-LICENSE +201 -0
- package/licenses/_aws-sdk_xml-builder-3.972.40-LICENSE +201 -0
- package/licenses/_aws_lambda-invoke-store-0.3.0-LICENSE +175 -0
- package/licenses/_babel_runtime-7.29.10-LICENSE +22 -0
- package/licenses/_google_genai-3.6.1-LICENSE +202 -0
- package/licenses/_isaacs_nonrecursive-glob-match-1.1.0-LICENSE.md +55 -0
- package/licenses/_protobufjs_aspromise-1.1.2-LICENSE +26 -0
- package/licenses/_protobufjs_base64-1.1.2-LICENSE +26 -0
- package/licenses/_protobufjs_codegen-2.0.5-LICENSE +26 -0
- package/licenses/_protobufjs_eventemitter-1.1.1-LICENSE +26 -0
- package/licenses/_protobufjs_fetch-1.1.1-LICENSE +26 -0
- package/licenses/_protobufjs_float-1.0.2-LICENSE +26 -0
- package/licenses/_protobufjs_path-1.1.2-LICENSE +26 -0
- package/licenses/_protobufjs_pool-1.1.0-LICENSE +26 -0
- package/licenses/_protobufjs_utf8-1.1.1-LICENSE +26 -0
- package/licenses/_silvia-odwyer_photon-node-0.3.4-LICENSE.md +201 -0
- package/licenses/_smithy_core-3.33.3-LICENSE +201 -0
- package/licenses/_smithy_credential-provider-imds-4.5.2-LICENSE +201 -0
- package/licenses/_smithy_fetch-http-handler-5.8.0-LICENSE +201 -0
- package/licenses/_smithy_node-http-handler-4.12.1-LICENSE +201 -0
- package/licenses/_smithy_signature-v4-5.7.3-LICENSE +201 -0
- package/licenses/_smithy_types-4.18.0-LICENSE +201 -0
- package/licenses/_stablelib_base64-1.0.1-LICENSE +21 -0
- package/licenses/_types_node-22.19.19-LICENSE +21 -0
- package/licenses/_types_retry-0.12.0-LICENSE +21 -0
- package/licenses/agent-base-7.1.4-LICENSE +22 -0
- package/licenses/agent-base-9.0.0-LICENSE +22 -0
- package/licenses/balanced-match-4.0.4-LICENSE.md +23 -0
- package/licenses/base64-js-1.5.1-LICENSE +21 -0
- package/licenses/bidi-js-1.1.0-LICENSE.txt +22 -0
- package/licenses/bignumber.js-9.3.1-LICENCE.md +26 -0
- package/licenses/bowser-2.14.1-LICENSE +39 -0
- package/licenses/brace-expansion-5.0.12-LICENSE +23 -0
- package/licenses/buffer-equal-constant-time-1.0.1-LICENSE.txt +12 -0
- package/licenses/chalk-6.0.0-license +9 -0
- package/licenses/cross-spawn-7.1.2-LICENSE +21 -0
- package/licenses/data-uri-to-buffer-4.0.1-LICENSE.generated.txt +22 -0
- package/licenses/debug-4.4.3-LICENSE +20 -0
- package/licenses/dependency-index.json +994 -0
- package/licenses/diff-8.0.4-LICENSE +29 -0
- package/licenses/ecdsa-sig-formatter-1.0.11-LICENSE +201 -0
- package/licenses/extend-3.0.2-LICENSE +23 -0
- package/licenses/fast-sha256-1.3.0-LICENSE +24 -0
- package/licenses/fetch-blob-3.2.0-LICENSE +21 -0
- package/licenses/formdata-polyfill-4.0.10-LICENSE +21 -0
- package/licenses/gaxios-7.1.4-LICENSE +202 -0
- package/licenses/gcp-metadata-8.1.2-LICENSE +202 -0
- package/licenses/get-east-asian-width-1.6.0-license +9 -0
- package/licenses/google-auth-library-10.6.2-LICENSE +202 -0
- package/licenses/google-logging-utils-1.1.3-LICENSE +202 -0
- package/licenses/graceful-fs-4.2.11-LICENSE +15 -0
- package/licenses/highlight.js-10.7.3-LICENSE +29 -0
- package/licenses/hosted-git-info-9.0.3-LICENSE +13 -0
- package/licenses/http-proxy-agent-9.1.0-LICENSE +22 -0
- package/licenses/https-proxy-agent-7.0.6-LICENSE +22 -0
- package/licenses/https-proxy-agent-9.1.0-LICENSE +22 -0
- package/licenses/ignore-7.0.8-LICENSE-MIT +21 -0
- package/licenses/isexe-2.0.0-LICENSE +15 -0
- package/licenses/jiti-2.7.0-LICENSE +21 -0
- package/licenses/json-bigint-1.0.0-LICENSE +20 -0
- package/licenses/json-schema-to-ts-3.1.1-LICENSE +21 -0
- package/licenses/jwa-2.0.1-LICENSE +17 -0
- package/licenses/jws-4.0.1-LICENSE +17 -0
- package/licenses/long-5.3.2-LICENSE +202 -0
- package/licenses/lovely-mermaid-0.3.3-LICENSE +205 -0
- package/licenses/lru-cache-11.4.0-LICENSE.md +55 -0
- package/licenses/marked-18.0.11-LICENSE +44 -0
- package/licenses/marked-cjk-friendly-0.1.2-LICENSE +22 -0
- package/licenses/mcp/modelcontextprotocol-typescript-sdk.txt +21 -0
- package/licenses/minimatch-11.0.9-LICENSE.md +55 -0
- package/licenses/ms-2.1.3-license.md +21 -0
- package/licenses/node-domexception-1.0.0-LICENSE +21 -0
- package/licenses/node-fetch-3.3.2-LICENSE.md +22 -0
- package/licenses/openai-7.59.0-LICENSE +201 -0
- package/licenses/p-retry-4.6.2-license +9 -0
- package/licenses/partial-json-0.1.7-LICENSE +21 -0
- package/licenses/path-key-3.1.1-license +9 -0
- package/licenses/proper-lockfile-4.1.2-LICENSE +21 -0
- package/licenses/protobufjs-7.6.6-LICENSE +39 -0
- package/licenses/proxy-agent-negotiate-1.1.0-LICENSE.generated.txt +22 -0
- package/licenses/quickjs-wasi-3.6.2-LICENSE +21 -0
- package/licenses/require-from-string-2.0.2-license +21 -0
- package/licenses/retry-0.12.0-License +21 -0
- package/licenses/retry-0.13.1-License +21 -0
- package/licenses/safe-buffer-5.2.1-LICENSE +21 -0
- package/licenses/schema/typebox-LICENSE +23 -0
- package/licenses/semver-7.8.5-LICENSE +15 -0
- package/licenses/shebang-command-2.0.0-license +9 -0
- package/licenses/shebang-regex-3.0.0-license +9 -0
- package/licenses/signal-exit-3.0.7-LICENSE.txt +16 -0
- package/licenses/standardwebhooks-1.1.1-LICENSE.generated.txt +22 -0
- package/licenses/ts-algebra-2.0.0-LICENSE +21 -0
- package/licenses/tslib-2.8.1-LICENSE.txt +12 -0
- package/licenses/typebox-1.3.27-license +23 -0
- package/licenses/undici-8.12.4-LICENSE +21 -0
- package/licenses/undici-types-6.21.0-LICENSE +21 -0
- package/licenses/upstream-pi.MIT.txt +21 -0
- package/licenses/web-streams-polyfill-3.3.3-LICENSE +22 -0
- package/licenses/which-2.0.2-LICENSE +15 -0
- package/licenses/ws-8.23.1-LICENSE +20 -0
- package/licenses/yaml-2.9.0-LICENSE +13 -0
- package/package.json +46 -4
- package/pi/CHANGELOG.md +6869 -0
- package/pi/README.md +95 -0
- package/pi/dist/bundle/chunks/anthropic-messages-TZF4LOZ3.js +3 -0
- package/pi/dist/bundle/chunks/anthropic.js +75 -0
- package/pi/dist/bundle/chunks/azure-openai-responses-OPCDWPFL.js +2 -0
- package/pi/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
- package/pi/dist/bundle/chunks/chunk-2BKJ4UF2.js +6 -0
- package/pi/dist/bundle/chunks/chunk-3TDGKLEK.js +4 -0
- package/pi/dist/bundle/chunks/chunk-4L3MQGA6.js +2 -0
- package/pi/dist/bundle/chunks/chunk-4MIF4MCH.js +2 -0
- package/pi/dist/bundle/chunks/chunk-4OXX5KPU.js +1237 -0
- package/pi/dist/bundle/chunks/chunk-5AGIVGSV.js +6 -0
- package/pi/dist/bundle/chunks/chunk-6F2YCHJI.js +55 -0
- package/pi/dist/bundle/chunks/chunk-6MVVCNIJ.js +2 -0
- package/pi/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
- package/pi/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
- package/pi/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
- package/pi/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
- package/pi/dist/bundle/chunks/chunk-BSRKXBKS.js +2 -0
- package/pi/dist/bundle/chunks/chunk-BXIXP3HJ.js +16 -0
- package/pi/dist/bundle/chunks/chunk-E3JXGAHC.js +2 -0
- package/pi/dist/bundle/chunks/chunk-EANOEWGP.js +2 -0
- package/pi/dist/bundle/chunks/chunk-FFMDRXC4.js +10 -0
- package/pi/dist/bundle/chunks/chunk-H5S7TE7A.js +20 -0
- package/pi/dist/bundle/chunks/chunk-IEBK4HQA.js +2 -0
- package/pi/dist/bundle/chunks/chunk-IKKTFUAW.js +82 -0
- package/pi/dist/bundle/chunks/chunk-INODY4DR.js +2 -0
- package/pi/dist/bundle/chunks/chunk-JCDBIE47.js +131 -0
- package/pi/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
- package/pi/dist/bundle/chunks/chunk-KBNQNV33.js +8 -0
- package/pi/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
- package/pi/dist/bundle/chunks/chunk-L6EYYEJG.js +2 -0
- package/pi/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
- package/pi/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
- package/pi/dist/bundle/chunks/chunk-LWG2CUTI.js +31 -0
- package/pi/dist/bundle/chunks/chunk-OVXT2WQH.js +2 -0
- package/pi/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
- package/pi/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
- package/pi/dist/bundle/chunks/chunk-PHM5C7IG.js +9 -0
- package/pi/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
- package/pi/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
- package/pi/dist/bundle/chunks/chunk-QGY2QT6O.js +30 -0
- package/pi/dist/bundle/chunks/chunk-QLVTCW2U.js +2 -0
- package/pi/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
- package/pi/dist/bundle/chunks/chunk-SSLDNFEJ.js +2 -0
- package/pi/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
- package/pi/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
- package/pi/dist/bundle/chunks/chunk-WHLWHMLX.js +14 -0
- package/pi/dist/bundle/chunks/chunk-YMIUSQL3.js +44 -0
- package/pi/dist/bundle/chunks/chunk-ZFO73KYQ.js +2 -0
- package/pi/dist/bundle/chunks/chunk-ZG74NES2.js +2 -0
- package/pi/dist/bundle/chunks/cli-66VDVHXA.js +53 -0
- package/pi/dist/bundle/chunks/cloudflare-workers-ai-system-one-BCB6I5BD.js +2 -0
- package/pi/dist/bundle/chunks/codemode-worker.js +480 -0
- package/pi/dist/bundle/chunks/easter-egg-3d-2XVDERXF.js +2 -0
- package/pi/dist/bundle/chunks/execute-CLOD3DVG.js +507 -0
- package/pi/dist/bundle/chunks/github-copilot.js +2 -0
- package/pi/dist/bundle/chunks/google-generative-ai-YXFPI4IA.js +2 -0
- package/pi/dist/bundle/chunks/google-vertex-SI54R6EC.js +2 -0
- package/pi/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
- package/pi/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/pi/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +21 -0
- package/pi/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +2 -0
- package/pi/dist/bundle/chunks/kimi-coding.js +2 -0
- package/pi/dist/bundle/chunks/lib-4AVRLBHM.js +9 -0
- package/pi/dist/bundle/chunks/llama-cpp-classify-PRGRPOMM.js +22 -0
- package/pi/dist/bundle/chunks/meta.js +2 -0
- package/pi/dist/bundle/chunks/mistral-conversations-D5VW6GSS.js +4 -0
- package/pi/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
- package/pi/dist/bundle/chunks/node-AUOGOBCN.js +2 -0
- package/pi/dist/bundle/chunks/node-KCMANYC2.js +16 -0
- package/pi/dist/bundle/chunks/openai-chatgpt.js +75 -0
- package/pi/dist/bundle/chunks/openai-codex-responses-NM5HSETG.js +2 -0
- package/pi/dist/bundle/chunks/openai-codex.js +75 -0
- package/pi/dist/bundle/chunks/openai-completions-QZF567FN.js +7 -0
- package/pi/dist/bundle/chunks/openai-decisions-YJYDQHYN.js +5 -0
- package/pi/dist/bundle/chunks/openai-responses-AVMLOXIQ.js +4 -0
- package/pi/dist/bundle/chunks/openrouter-chat-images-3V4TR7TT.js +2 -0
- package/pi/dist/bundle/chunks/openrouter-images-UBTJFBR6.js +4 -0
- package/pi/dist/bundle/chunks/openrouter.js +75 -0
- package/pi/dist/bundle/chunks/pi-decision-XC3CEYXE.js +2 -0
- package/pi/dist/bundle/chunks/pi-image-GRYH565R.js +2 -0
- package/pi/dist/bundle/chunks/pi-messages-5Z2U3PEK.js +2 -0
- package/pi/dist/bundle/chunks/radius.js +75 -0
- package/pi/dist/bundle/chunks/runtime-PSL6AEOU.js +2 -0
- package/pi/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
- package/pi/dist/bundle/chunks/typesafe-system-one-3JC45JJT.js +2 -0
- package/pi/dist/bundle/chunks/virtual-modules-AG72WCIK.js +2 -0
- package/pi/dist/bundle/chunks/xai.js +2 -0
- package/pi/dist/bundle/cli-runtime.js +3 -0
- package/pi/dist/bundle/cli.js +5 -0
- package/pi/dist/bundle/index.js +2 -0
- package/pi/dist/bundle/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
- package/pi/dist/bundle/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
- package/pi/dist/bundle/native/linux/prebuilds/linux-arm64/linux-platform-x11.node +0 -0
- package/pi/dist/bundle/native/linux/prebuilds/linux-x64/linux-platform-x11.node +0 -0
- package/pi/dist/bundle/native/win32/prebuilds/win32-arm64/win32-platform.node +0 -0
- package/pi/dist/bundle/native/win32/prebuilds/win32-x64/win32-platform.node +0 -0
- package/pi/dist/bundle/rpc-entry.js +3 -0
- package/pi/dist/core/export-html/ansi-to-html.d.ts +27 -0
- package/pi/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/pi/dist/core/export-html/ansi-to-html.js +286 -0
- package/pi/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/pi/dist/core/export-html/index.d.ts +37 -0
- package/pi/dist/core/export-html/index.d.ts.map +1 -0
- package/pi/dist/core/export-html/index.js +230 -0
- package/pi/dist/core/export-html/index.js.map +1 -0
- package/pi/dist/core/export-html/template.css +1085 -0
- package/pi/dist/core/export-html/template.html +56 -0
- package/pi/dist/core/export-html/template.js +2044 -0
- package/pi/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/pi/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/pi/dist/core/export-html/tool-renderer.js +112 -0
- package/pi/dist/core/export-html/tool-renderer.js.map +1 -0
- package/pi/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/pi/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/pi/dist/core/export-html/vendor/marked.min.js +79 -0
- package/pi/dist/modes/interactive/assets/clankolas.png +0 -0
- package/pi/dist/modes/interactive/theme/dark.json +78 -0
- package/pi/dist/modes/interactive/theme/light.json +78 -0
- package/pi/dist/modes/interactive/theme/system-theme.d.ts +55 -0
- package/pi/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
- package/pi/dist/modes/interactive/theme/system-theme.js +546 -0
- package/pi/dist/modes/interactive/theme/system-theme.js.map +1 -0
- package/pi/dist/modes/interactive/theme/theme-controller.d.ts +81 -0
- package/pi/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
- package/pi/dist/modes/interactive/theme/theme-controller.js +210 -0
- package/pi/dist/modes/interactive/theme/theme-controller.js.map +1 -0
- package/pi/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
- package/pi/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
- package/pi/dist/modes/interactive/theme/theme-schema.js +105 -0
- package/pi/dist/modes/interactive/theme/theme-schema.js.map +1 -0
- package/pi/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
- package/pi/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
- package/pi/dist/modes/interactive/theme/theme-tokens.js +94 -0
- package/pi/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
- package/pi/dist/modes/interactive/theme/theme.d.ts +165 -0
- package/pi/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/pi/dist/modes/interactive/theme/theme.js +918 -0
- package/pi/dist/modes/interactive/theme/theme.js.map +1 -0
- package/pi/docs/cli-integration.md +106 -0
- package/pi/docs/cli.md +358 -0
- package/pi/docs/codemode.md +241 -0
- package/pi/docs/compaction.md +463 -0
- package/pi/docs/configuration.md +47 -0
- package/pi/docs/containerization.md +183 -0
- package/pi/docs/custom-provider.md +227 -0
- package/pi/docs/docs.json +224 -0
- package/pi/docs/environment-variables.md +104 -0
- package/pi/docs/extensions.md +3394 -0
- package/pi/docs/how-pi-works.md +49 -0
- package/pi/docs/images/doom-extension.png +0 -0
- package/pi/docs/images/exy.png +0 -0
- package/pi/docs/images/interactive-mode.png +0 -0
- package/pi/docs/images/tree-view.png +0 -0
- package/pi/docs/index.md +39 -0
- package/pi/docs/json.md +226 -0
- package/pi/docs/keybindings.md +195 -0
- package/pi/docs/llama-cpp.md +138 -0
- package/pi/docs/mcp.md +301 -0
- package/pi/docs/message-types.md +280 -0
- package/pi/docs/models-configuration.md +213 -0
- package/pi/docs/models.md +248 -0
- package/pi/docs/nvidia-rtx-llama-cpp.md +96 -0
- package/pi/docs/packages.md +153 -0
- package/pi/docs/prompt-templates.md +59 -0
- package/pi/docs/providers.md +251 -0
- package/pi/docs/quickstart.md +140 -0
- package/pi/docs/rpc-commands.md +860 -0
- package/pi/docs/rpc-extension-ui.md +200 -0
- package/pi/docs/rpc.md +195 -0
- package/pi/docs/sdk.md +147 -0
- package/pi/docs/security.md +99 -0
- package/pi/docs/session-format.md +293 -0
- package/pi/docs/sessions.md +82 -0
- package/pi/docs/settings.md +175 -0
- package/pi/docs/shell-aliases.md +93 -0
- package/pi/docs/skills.md +93 -0
- package/pi/docs/slash-commands.md +61 -0
- package/pi/docs/subscriptions.md +96 -0
- package/pi/docs/terminal-setup.md +298 -0
- package/pi/docs/termux.md +117 -0
- package/pi/docs/themes.md +138 -0
- package/pi/docs/tmux.md +61 -0
- package/pi/docs/tui.md +199 -0
- package/pi/docs/usage.md +94 -0
- package/pi/docs/virtual-models.md +114 -0
- package/pi/docs/windows.md +109 -0
- package/pi/examples/README.md +36 -0
- package/pi/examples/extensions/README.md +215 -0
- package/pi/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/pi/examples/extensions/bash-spawn-hook.ts +30 -0
- package/pi/examples/extensions/bookmark.ts +50 -0
- package/pi/examples/extensions/border-status-editor.ts +150 -0
- package/pi/examples/extensions/built-in-tool-renderer.ts +225 -0
- package/pi/examples/extensions/claude-rules.ts +86 -0
- package/pi/examples/extensions/commands.ts +72 -0
- package/pi/examples/extensions/confirm-destructive.ts +59 -0
- package/pi/examples/extensions/custom-compaction.ts +117 -0
- package/pi/examples/extensions/custom-footer.ts +64 -0
- package/pi/examples/extensions/custom-header.ts +73 -0
- package/pi/examples/extensions/custom-provider-anthropic/index.ts +613 -0
- package/pi/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/pi/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/pi/examples/extensions/custom-provider-gitlab-duo/index.ts +405 -0
- package/pi/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/pi/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/pi/examples/extensions/debug-provider.ts +90 -0
- package/pi/examples/extensions/dirty-repo-guard.ts +56 -0
- package/pi/examples/extensions/doom-overlay/README.md +46 -0
- package/pi/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/pi/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/pi/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/pi/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/pi/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/pi/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/pi/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/pi/examples/extensions/doom-overlay/index.ts +74 -0
- package/pi/examples/extensions/doom-overlay/wad-finder.ts +55 -0
- package/pi/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/pi/examples/extensions/dynamic-resources/dynamic.json +81 -0
- package/pi/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/pi/examples/extensions/dynamic-resources/index.ts +15 -0
- package/pi/examples/extensions/dynamic-tools.ts +74 -0
- package/pi/examples/extensions/entry-renderer.ts +41 -0
- package/pi/examples/extensions/event-bus.ts +43 -0
- package/pi/examples/extensions/file-trigger.ts +41 -0
- package/pi/examples/extensions/git-checkpoint.ts +53 -0
- package/pi/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/pi/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/pi/examples/extensions/gondolin/index.ts +528 -0
- package/pi/examples/extensions/gondolin/package-lock.json +175 -0
- package/pi/examples/extensions/gondolin/package.json +19 -0
- package/pi/examples/extensions/handoff.ts +190 -0
- package/pi/examples/extensions/hello.ts +26 -0
- package/pi/examples/extensions/hidden-thinking-label.ts +53 -0
- package/pi/examples/extensions/inline-bash.ts +94 -0
- package/pi/examples/extensions/input-transform-streaming.ts +39 -0
- package/pi/examples/extensions/input-transform.ts +43 -0
- package/pi/examples/extensions/interactive-shell.ts +196 -0
- package/pi/examples/extensions/jev-router.ts +113 -0
- package/pi/examples/extensions/mac-system-theme.ts +47 -0
- package/pi/examples/extensions/message-renderer.ts +59 -0
- package/pi/examples/extensions/minimal-mode.ts +353 -0
- package/pi/examples/extensions/modal-editor.ts +85 -0
- package/pi/examples/extensions/model-status.ts +31 -0
- package/pi/examples/extensions/notify.ts +57 -0
- package/pi/examples/extensions/overlay-qa-tests.ts +1456 -0
- package/pi/examples/extensions/overlay-test.ts +165 -0
- package/pi/examples/extensions/permission-gate.ts +34 -0
- package/pi/examples/extensions/pirate.ts +47 -0
- package/pi/examples/extensions/plan-mode/README.md +66 -0
- package/pi/examples/extensions/plan-mode/index.ts +404 -0
- package/pi/examples/extensions/plan-mode/utils.ts +194 -0
- package/pi/examples/extensions/preset.ts +438 -0
- package/pi/examples/extensions/project-trust.ts +64 -0
- package/pi/examples/extensions/prompt-customizer.ts +49 -0
- package/pi/examples/extensions/protected-paths.ts +30 -0
- package/pi/examples/extensions/provider-payload.ts +18 -0
- package/pi/examples/extensions/qna.ts +118 -0
- package/pi/examples/extensions/question.ts +286 -0
- package/pi/examples/extensions/questionnaire.ts +448 -0
- package/pi/examples/extensions/rainbow-editor.ts +88 -0
- package/pi/examples/extensions/reload-runtime.ts +49 -0
- package/pi/examples/extensions/rpc-demo.ts +118 -0
- package/pi/examples/extensions/send-user-message.ts +97 -0
- package/pi/examples/extensions/session-name.ts +27 -0
- package/pi/examples/extensions/shutdown-command.ts +63 -0
- package/pi/examples/extensions/snake.ts +343 -0
- package/pi/examples/extensions/space-invaders.ts +560 -0
- package/pi/examples/extensions/ssh.ts +220 -0
- package/pi/examples/extensions/status-line.ts +32 -0
- package/pi/examples/extensions/structured-output.ts +65 -0
- package/pi/examples/extensions/subagent/README.md +180 -0
- package/pi/examples/extensions/subagent/agents/planner.md +37 -0
- package/pi/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/pi/examples/extensions/subagent/agents/scout.md +50 -0
- package/pi/examples/extensions/subagent/agents/worker.md +24 -0
- package/pi/examples/extensions/subagent/agents.ts +157 -0
- package/pi/examples/extensions/subagent/index.ts +1258 -0
- package/pi/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/pi/examples/extensions/subagent/prompts/implement.md +10 -0
- package/pi/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/pi/examples/extensions/summarize.ts +199 -0
- package/pi/examples/extensions/system-prompt-header.ts +17 -0
- package/pi/examples/extensions/tic-tac-toe.ts +1008 -0
- package/pi/examples/extensions/timed-confirm.ts +70 -0
- package/pi/examples/extensions/titlebar-spinner.ts +58 -0
- package/pi/examples/extensions/todo.ts +304 -0
- package/pi/examples/extensions/tool-override.ts +144 -0
- package/pi/examples/extensions/tools.ts +148 -0
- package/pi/examples/extensions/trigger-compact.ts +50 -0
- package/pi/examples/extensions/truncated-tool.ts +195 -0
- package/pi/examples/extensions/widget-placement.ts +9 -0
- package/pi/examples/extensions/with-deps/index.ts +32 -0
- package/pi/examples/extensions/with-deps/package-lock.json +31 -0
- package/pi/examples/extensions/with-deps/package.json +22 -0
- package/pi/examples/extensions/working-indicator.ts +123 -0
- package/pi/examples/extensions/working-message-test.ts +25 -0
- package/pi/examples/rpc-client.ts +35 -0
- package/pi/examples/rpc-extension-ui.ts +662 -0
- package/pi/examples/sdk/01-minimal.ts +26 -0
- package/pi/examples/sdk/02-custom-model.ts +49 -0
- package/pi/examples/sdk/03-custom-prompt.ts +75 -0
- package/pi/examples/sdk/04-skills.ts +55 -0
- package/pi/examples/sdk/05-tools.ts +48 -0
- package/pi/examples/sdk/06-extensions.ts +99 -0
- package/pi/examples/sdk/07-context-files.ts +47 -0
- package/pi/examples/sdk/08-prompt-templates.ts +51 -0
- package/pi/examples/sdk/09-api-keys-and-oauth.ts +34 -0
- package/pi/examples/sdk/10-settings.ts +53 -0
- package/pi/examples/sdk/11-sessions.ts +52 -0
- package/pi/examples/sdk/12-full-control.ts +74 -0
- package/pi/examples/sdk/13-session-runtime.ts +67 -0
- package/pi/examples/sdk/14-codemode-mcp.ts +61 -0
- package/pi/examples/sdk/README.md +141 -0
- package/pi/examples/tsconfig.json +208 -0
- package/pi/package.json +5 -0
- package/pi/schemas/keybindings.schema.json +393 -0
- package/pi/schemas/mcp.schema.json +306 -0
- package/pi/schemas/models.schema.json +1253 -0
- package/pi/schemas/settings.schema.json +820 -0
- package/pi/schemas/theme.schema.json +365 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool HTML renderer for custom tools in HTML export.
|
|
3
|
+
*
|
|
4
|
+
* Renders custom tool calls and results to HTML by invoking their TUI renderers
|
|
5
|
+
* and converting the ANSI output to HTML.
|
|
6
|
+
*/
|
|
7
|
+
import type { Theme } from "../../modes/interactive/theme/theme.ts";
|
|
8
|
+
import type { ToolRenderers } from "../extensions/types.ts";
|
|
9
|
+
export interface ToolHtmlRendererDeps {
|
|
10
|
+
/** Renderers of calls to a tool, as resolved by extensions and the registered tool */
|
|
11
|
+
getToolRenderers: (name: string) => ToolRenderers | undefined;
|
|
12
|
+
/** Theme for styling */
|
|
13
|
+
theme: Theme;
|
|
14
|
+
/** Working directory for render context */
|
|
15
|
+
cwd: string;
|
|
16
|
+
/** Terminal width for rendering (default: 100) */
|
|
17
|
+
width?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ToolHtmlRenderer {
|
|
20
|
+
/** Render a tool call to HTML. Returns undefined if tool has no custom renderer. */
|
|
21
|
+
renderCall(toolCallId: string, toolName: string, args: unknown): string | undefined;
|
|
22
|
+
/** Render a tool result to collapsed/expanded HTML. Returns undefined if tool has no custom renderer. */
|
|
23
|
+
renderResult(toolCallId: string, toolName: string, result: Array<{
|
|
24
|
+
type: string;
|
|
25
|
+
text?: string;
|
|
26
|
+
data?: string;
|
|
27
|
+
mimeType?: string;
|
|
28
|
+
}>, details: unknown, isError: boolean): {
|
|
29
|
+
collapsed?: string;
|
|
30
|
+
expanded?: string;
|
|
31
|
+
} | undefined;
|
|
32
|
+
}
|
|
33
|
+
export declare function createToolHtmlRenderer(deps: ToolHtmlRendererDeps): ToolHtmlRenderer;
|
|
34
|
+
//# sourceMappingURL=tool-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-renderer.d.ts","sourceRoot":"","sources":["../../../src/core/export-html/tool-renderer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,KAAK,EAAqB,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG/E,MAAM,WAAW,oBAAoB;IACpC,sFAAsF;IACtF,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;IAC9D,wBAAwB;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAChC,oFAAoF;IACpF,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IACpF,yGAAyG;IACzG,YAAY,CACX,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAChF,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GACd;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CACzD;AAoBD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,GAAG,gBAAgB,CAsHnF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool HTML renderer for custom tools in HTML export.
|
|
3
|
+
*
|
|
4
|
+
* Renders custom tool calls and results to HTML by invoking their TUI renderers
|
|
5
|
+
* and converting the ANSI output to HTML.
|
|
6
|
+
*/
|
|
7
|
+
import { keyHint, keyText } from "../../modes/interactive/components/keybinding-hints.js";
|
|
8
|
+
import { ansiLinesToHtml, stripAnsiEscapes } from "./ansi-to-html.js";
|
|
9
|
+
/**
|
|
10
|
+
* Create a tool HTML renderer.
|
|
11
|
+
*
|
|
12
|
+
* The renderer looks up tool definitions and invokes their renderCall/renderResult
|
|
13
|
+
* methods, converting the resulting TUI Component output (ANSI) to HTML.
|
|
14
|
+
*/
|
|
15
|
+
function isBlankRenderedLine(line) {
|
|
16
|
+
return stripAnsiEscapes(line).trim().length === 0;
|
|
17
|
+
}
|
|
18
|
+
function trimRenderedResultLines(lines) {
|
|
19
|
+
let start = 0;
|
|
20
|
+
let end = lines.length;
|
|
21
|
+
while (start < end && isBlankRenderedLine(lines[start]))
|
|
22
|
+
start++;
|
|
23
|
+
while (end > start && isBlankRenderedLine(lines[end - 1]))
|
|
24
|
+
end--;
|
|
25
|
+
return lines.slice(start, end);
|
|
26
|
+
}
|
|
27
|
+
export function createToolHtmlRenderer(deps) {
|
|
28
|
+
const { getToolRenderers, theme, cwd, width = 100 } = deps;
|
|
29
|
+
const renderedCallComponents = new Map();
|
|
30
|
+
const renderedResultComponents = new Map();
|
|
31
|
+
const renderedStates = new Map();
|
|
32
|
+
const renderedArgs = new Map();
|
|
33
|
+
const getState = (toolCallId) => {
|
|
34
|
+
let state = renderedStates.get(toolCallId);
|
|
35
|
+
if (!state) {
|
|
36
|
+
state = {};
|
|
37
|
+
renderedStates.set(toolCallId, state);
|
|
38
|
+
}
|
|
39
|
+
return state;
|
|
40
|
+
};
|
|
41
|
+
const createRenderContext = (toolCallId, lastComponent, expanded, isPartial, isError) => {
|
|
42
|
+
return {
|
|
43
|
+
args: renderedArgs.get(toolCallId),
|
|
44
|
+
toolCallId,
|
|
45
|
+
invalidate: () => { },
|
|
46
|
+
lastComponent,
|
|
47
|
+
state: getState(toolCallId),
|
|
48
|
+
cwd,
|
|
49
|
+
executionStarted: true,
|
|
50
|
+
argsComplete: true,
|
|
51
|
+
isPartial,
|
|
52
|
+
expanded,
|
|
53
|
+
showImages: false,
|
|
54
|
+
isError,
|
|
55
|
+
durationMs: undefined,
|
|
56
|
+
outputPad: 1,
|
|
57
|
+
keyText,
|
|
58
|
+
keyHint,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
renderCall(toolCallId, toolName, args) {
|
|
63
|
+
try {
|
|
64
|
+
renderedArgs.set(toolCallId, args);
|
|
65
|
+
const toolDef = getToolRenderers(toolName);
|
|
66
|
+
if (!toolDef?.renderCall) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const component = toolDef.renderCall(args, theme, createRenderContext(toolCallId, renderedCallComponents.get(toolCallId), false, true, false));
|
|
70
|
+
renderedCallComponents.set(toolCallId, component);
|
|
71
|
+
const lines = component.render(width);
|
|
72
|
+
return ansiLinesToHtml(lines);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// On error, return undefined so HTML export can fall back to structured result rendering
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
renderResult(toolCallId, toolName, result, details, isError) {
|
|
80
|
+
try {
|
|
81
|
+
const toolDef = getToolRenderers(toolName);
|
|
82
|
+
if (!toolDef?.renderResult) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
// Build AgentToolResult from content array
|
|
86
|
+
// Cast content since session storage uses generic object types
|
|
87
|
+
const agentToolResult = {
|
|
88
|
+
content: result,
|
|
89
|
+
details,
|
|
90
|
+
isError,
|
|
91
|
+
};
|
|
92
|
+
// Render collapsed
|
|
93
|
+
const collapsedComponent = toolDef.renderResult(agentToolResult, { expanded: false, isPartial: false }, theme, createRenderContext(toolCallId, renderedResultComponents.get(toolCallId), false, false, isError));
|
|
94
|
+
renderedResultComponents.set(toolCallId, collapsedComponent);
|
|
95
|
+
const collapsed = ansiLinesToHtml(trimRenderedResultLines(collapsedComponent.render(width)));
|
|
96
|
+
// Render expanded
|
|
97
|
+
const expandedComponent = toolDef.renderResult(agentToolResult, { expanded: true, isPartial: false }, theme, createRenderContext(toolCallId, renderedResultComponents.get(toolCallId), true, false, isError));
|
|
98
|
+
renderedResultComponents.set(toolCallId, expandedComponent);
|
|
99
|
+
const expanded = ansiLinesToHtml(trimRenderedResultLines(expandedComponent.render(width)));
|
|
100
|
+
return {
|
|
101
|
+
...(collapsed && collapsed !== expanded ? { collapsed } : {}),
|
|
102
|
+
expanded,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// On error, return undefined so HTML export can fall back to structured result rendering
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=tool-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-renderer.js","sourceRoot":"","sources":["../../../src/core/export-html/tool-renderer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;A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AU,EAAE,iBAAiB,CAAC,CAAC;gBAC5D,MAAM,QAAQ,GAAG,eAAe,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAE3F,OAAO;oBACN,GAAG,CAAC,SAAS,IAAI,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC7D,QAAQ;iBACR,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACR,yFAAyF;gBACzF,OAAO,SAAS,CAAC;YAClB,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Tool HTML renderer for custom tools in HTML export.\n *\n * Renders custom tool calls and results to HTML by invoking their TUI renderers\n * and converting the ANSI output to HTML.\n */\n\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai\";\nimport type { Component } from \"@earendil-works/pi-tui\";\nimport { keyHint, keyText } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { ToolRenderContext, ToolRenderers } from \"../extensions/types.ts\";\nimport { ansiLinesToHtml, stripAnsiEscapes } from \"./ansi-to-html.ts\";\n\nexport interface ToolHtmlRendererDeps {\n\t/** Renderers of calls to a tool, as resolved by extensions and the registered tool */\n\tgetToolRenderers: (name: string) => ToolRenderers | undefined;\n\t/** Theme for styling */\n\ttheme: Theme;\n\t/** Working directory for render context */\n\tcwd: string;\n\t/** Terminal width for rendering (default: 100) */\n\twidth?: number;\n}\n\nexport interface ToolHtmlRenderer {\n\t/** Render a tool call to HTML. Returns undefined if tool has no custom renderer. */\n\trenderCall(toolCallId: string, toolName: string, args: unknown): string | undefined;\n\t/** Render a tool result to collapsed/expanded HTML. Returns undefined if tool has no custom renderer. */\n\trenderResult(\n\t\ttoolCallId: string,\n\t\ttoolName: string,\n\t\tresult: Array<{ type: string; text?: string; data?: string; mimeType?: string }>,\n\t\tdetails: unknown,\n\t\tisError: boolean,\n\t): { collapsed?: string; expanded?: string } | undefined;\n}\n\n/**\n * Create a tool HTML renderer.\n *\n * The renderer looks up tool definitions and invokes their renderCall/renderResult\n * methods, converting the resulting TUI Component output (ANSI) to HTML.\n */\nfunction isBlankRenderedLine(line: string): boolean {\n\treturn stripAnsiEscapes(line).trim().length === 0;\n}\n\nfunction trimRenderedResultLines(lines: readonly string[]): string[] {\n\tlet start = 0;\n\tlet end = lines.length;\n\twhile (start < end && isBlankRenderedLine(lines[start])) start++;\n\twhile (end > start && isBlankRenderedLine(lines[end - 1])) end--;\n\treturn lines.slice(start, end);\n}\n\nexport function createToolHtmlRenderer(deps: ToolHtmlRendererDeps): ToolHtmlRenderer {\n\tconst { getToolRenderers, theme, cwd, width = 100 } = deps;\n\n\tconst renderedCallComponents = new Map<string, Component>();\n\tconst renderedResultComponents = new Map<string, Component>();\n\tconst renderedStates = new Map<string, any>();\n\tconst renderedArgs = new Map<string, unknown>();\n\n\tconst getState = (toolCallId: string): any => {\n\t\tlet state = renderedStates.get(toolCallId);\n\t\tif (!state) {\n\t\t\tstate = {};\n\t\t\trenderedStates.set(toolCallId, state);\n\t\t}\n\t\treturn state;\n\t};\n\n\tconst createRenderContext = (\n\t\ttoolCallId: string,\n\t\tlastComponent: Component | undefined,\n\t\texpanded: boolean,\n\t\tisPartial: boolean,\n\t\tisError: boolean,\n\t): ToolRenderContext => {\n\t\treturn {\n\t\t\targs: renderedArgs.get(toolCallId),\n\t\t\ttoolCallId,\n\t\t\tinvalidate: () => {},\n\t\t\tlastComponent,\n\t\t\tstate: getState(toolCallId),\n\t\t\tcwd,\n\t\t\texecutionStarted: true,\n\t\t\targsComplete: true,\n\t\t\tisPartial,\n\t\t\texpanded,\n\t\t\tshowImages: false,\n\t\t\tisError,\n\t\t\tdurationMs: undefined,\n\t\t\toutputPad: 1,\n\t\t\tkeyText,\n\t\t\tkeyHint,\n\t\t};\n\t};\n\n\treturn {\n\t\trenderCall(toolCallId: string, toolName: string, args: unknown): string | undefined {\n\t\t\ttry {\n\t\t\t\trenderedArgs.set(toolCallId, args);\n\t\t\t\tconst toolDef = getToolRenderers(toolName);\n\t\t\t\tif (!toolDef?.renderCall) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst component = toolDef.renderCall(\n\t\t\t\t\targs,\n\t\t\t\t\ttheme,\n\t\t\t\t\tcreateRenderContext(toolCallId, renderedCallComponents.get(toolCallId), false, true, false),\n\t\t\t\t);\n\t\t\t\trenderedCallComponents.set(toolCallId, component);\n\t\t\t\tconst lines = component.render(width);\n\t\t\t\treturn ansiLinesToHtml(lines);\n\t\t\t} catch {\n\t\t\t\t// On error, return undefined so HTML export can fall back to structured result rendering\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t},\n\n\t\trenderResult(\n\t\t\ttoolCallId: string,\n\t\t\ttoolName: string,\n\t\t\tresult: Array<{ type: string; text?: string; data?: string; mimeType?: string }>,\n\t\t\tdetails: unknown,\n\t\t\tisError: boolean,\n\t\t): { collapsed?: string; expanded?: string } | undefined {\n\t\t\ttry {\n\t\t\t\tconst toolDef = getToolRenderers(toolName);\n\t\t\t\tif (!toolDef?.renderResult) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\t// Build AgentToolResult from content array\n\t\t\t\t// Cast content since session storage uses generic object types\n\t\t\t\tconst agentToolResult = {\n\t\t\t\t\tcontent: result as (TextContent | ImageContent)[],\n\t\t\t\t\tdetails,\n\t\t\t\t\tisError,\n\t\t\t\t};\n\n\t\t\t\t// Render collapsed\n\t\t\t\tconst collapsedComponent = toolDef.renderResult(\n\t\t\t\t\tagentToolResult,\n\t\t\t\t\t{ expanded: false, isPartial: false },\n\t\t\t\t\ttheme,\n\t\t\t\t\tcreateRenderContext(toolCallId, renderedResultComponents.get(toolCallId), false, false, isError),\n\t\t\t\t);\n\t\t\t\trenderedResultComponents.set(toolCallId, collapsedComponent);\n\t\t\t\tconst collapsed = ansiLinesToHtml(trimRenderedResultLines(collapsedComponent.render(width)));\n\n\t\t\t\t// Render expanded\n\t\t\t\tconst expandedComponent = toolDef.renderResult(\n\t\t\t\t\tagentToolResult,\n\t\t\t\t\t{ expanded: true, isPartial: false },\n\t\t\t\t\ttheme,\n\t\t\t\t\tcreateRenderContext(toolCallId, renderedResultComponents.get(toolCallId), true, false, isError),\n\t\t\t\t);\n\t\t\t\trenderedResultComponents.set(toolCallId, expandedComponent);\n\t\t\t\tconst expanded = ansiLinesToHtml(trimRenderedResultLines(expandedComponent.render(width)));\n\n\t\t\t\treturn {\n\t\t\t\t\t...(collapsed && collapsed !== expanded ? { collapsed } : {}),\n\t\t\t\t\texpanded,\n\t\t\t\t};\n\t\t\t} catch {\n\t\t\t\t// On error, return undefined so HTML export can fall back to structured result rendering\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
|