@mindistryx/pi-arabic-runtime 0.0.0-stage → 1.0.0-beta.1
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 +20 -0
- package/extension/mode.mjs +48 -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-2C4T37KE.js +2 -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-5AGIVGSV.js +6 -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-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-PKIAAV4P.js +1237 -0
- package/pi/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
- package/pi/dist/bundle/chunks/chunk-PW6LDSKD.js +131 -0
- package/pi/dist/bundle/chunks/chunk-Q257PLDE.js +55 -0
- package/pi/dist/bundle/chunks/chunk-QGY2QT6O.js +30 -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/chunk-ZLIZPVRW.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-GLZSE5PF.js +2 -0
- package/pi/dist/bundle/chunks/execute-B7SPJZ6B.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-QM3JD34I.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,662 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC Extension UI Example (TUI)
|
|
3
|
+
*
|
|
4
|
+
* A lightweight TUI chat client that spawns the agent in RPC mode.
|
|
5
|
+
* Demonstrates how to build a custom UI on top of the RPC protocol,
|
|
6
|
+
* including handling extension UI requests (select, confirm, input, editor).
|
|
7
|
+
*
|
|
8
|
+
* Usage: node examples/rpc-extension-ui.ts
|
|
9
|
+
*
|
|
10
|
+
* Slash commands:
|
|
11
|
+
* /select - demo select dialog
|
|
12
|
+
* /confirm - demo confirm dialog
|
|
13
|
+
* /input - demo input dialog
|
|
14
|
+
* /editor - demo editor dialog
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { spawn } from "node:child_process";
|
|
18
|
+
import { dirname, join } from "node:path";
|
|
19
|
+
import { StringDecoder } from "node:string_decoder";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
import {
|
|
22
|
+
type Component,
|
|
23
|
+
Container,
|
|
24
|
+
Input,
|
|
25
|
+
matchesKey,
|
|
26
|
+
ProcessTerminal,
|
|
27
|
+
SelectList,
|
|
28
|
+
type TUI,
|
|
29
|
+
TuiMainScreen,
|
|
30
|
+
} from "@earendil-works/pi-tui";
|
|
31
|
+
|
|
32
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
33
|
+
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// ANSI helpers
|
|
36
|
+
// ============================================================================
|
|
37
|
+
|
|
38
|
+
const GREEN = "\x1b[32m";
|
|
39
|
+
const YELLOW = "\x1b[33m";
|
|
40
|
+
const BLUE = "\x1b[34m";
|
|
41
|
+
const MAGENTA = "\x1b[35m";
|
|
42
|
+
const RED = "\x1b[31m";
|
|
43
|
+
const DIM = "\x1b[2m";
|
|
44
|
+
const BOLD = "\x1b[1m";
|
|
45
|
+
const RESET = "\x1b[0m";
|
|
46
|
+
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Extension UI request type (subset of rpc-types.ts)
|
|
49
|
+
// ============================================================================
|
|
50
|
+
|
|
51
|
+
interface ExtensionUIRequest {
|
|
52
|
+
type: "extension_ui_request";
|
|
53
|
+
id: string;
|
|
54
|
+
method: string;
|
|
55
|
+
title?: string;
|
|
56
|
+
options?: string[];
|
|
57
|
+
message?: string;
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
prefill?: string;
|
|
60
|
+
notifyType?: "info" | "warning" | "error";
|
|
61
|
+
statusKey?: string;
|
|
62
|
+
statusText?: string;
|
|
63
|
+
widgetKey?: string;
|
|
64
|
+
widgetLines?: string[];
|
|
65
|
+
text?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// Output log: accumulates styled lines, renders the tail that fits
|
|
70
|
+
// ============================================================================
|
|
71
|
+
|
|
72
|
+
class OutputLog implements Component {
|
|
73
|
+
private lines: string[] = [];
|
|
74
|
+
private maxLines = 1000;
|
|
75
|
+
private visibleLines = 0;
|
|
76
|
+
|
|
77
|
+
setVisibleLines(n: number): void {
|
|
78
|
+
this.visibleLines = n;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
append(line: string): void {
|
|
82
|
+
this.lines.push(line);
|
|
83
|
+
if (this.lines.length > this.maxLines) {
|
|
84
|
+
this.lines = this.lines.slice(-this.maxLines);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
appendRaw(text: string): void {
|
|
89
|
+
if (this.lines.length === 0) {
|
|
90
|
+
this.lines.push(text);
|
|
91
|
+
} else {
|
|
92
|
+
this.lines[this.lines.length - 1] += text;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
invalidate(): void {}
|
|
97
|
+
|
|
98
|
+
render(width: number): string[] {
|
|
99
|
+
if (this.lines.length === 0) return [""];
|
|
100
|
+
const n = this.visibleLines > 0 ? this.visibleLines : this.lines.length;
|
|
101
|
+
return this.lines.slice(-n).map((l) => l.slice(0, width));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ============================================================================
|
|
106
|
+
// Loading indicator: "Agent: Working." -> ".." -> "..." -> "."
|
|
107
|
+
// ============================================================================
|
|
108
|
+
|
|
109
|
+
class LoadingIndicator implements Component {
|
|
110
|
+
private dots = 1;
|
|
111
|
+
private intervalId: NodeJS.Timeout | null = null;
|
|
112
|
+
private tui: TUI | null = null;
|
|
113
|
+
|
|
114
|
+
start(tui: TUI): void {
|
|
115
|
+
this.tui = tui;
|
|
116
|
+
this.dots = 1;
|
|
117
|
+
this.intervalId = setInterval(() => {
|
|
118
|
+
this.dots = (this.dots % 3) + 1;
|
|
119
|
+
this.tui?.requestRender();
|
|
120
|
+
}, 400);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
stop(): void {
|
|
124
|
+
if (this.intervalId) {
|
|
125
|
+
clearInterval(this.intervalId);
|
|
126
|
+
this.intervalId = null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
invalidate(): void {}
|
|
131
|
+
|
|
132
|
+
render(_width: number): string[] {
|
|
133
|
+
return [`${BLUE}${BOLD}Agent:${RESET} ${DIM}Working${".".repeat(this.dots)}${RESET}`];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ============================================================================
|
|
138
|
+
// Prompt input: label + single-line input
|
|
139
|
+
// ============================================================================
|
|
140
|
+
|
|
141
|
+
class PromptInput implements Component {
|
|
142
|
+
readonly input: Input;
|
|
143
|
+
onCtrlD?: () => void;
|
|
144
|
+
|
|
145
|
+
constructor() {
|
|
146
|
+
this.input = new Input();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
handleInput(data: string): void {
|
|
150
|
+
if (matchesKey(data, "ctrl+d")) {
|
|
151
|
+
this.onCtrlD?.();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.input.handleInput(data);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
invalidate(): void {
|
|
158
|
+
this.input.invalidate();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
render(width: number): string[] {
|
|
162
|
+
return [`${GREEN}${BOLD}You:${RESET}`, ...this.input.render(width)];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ============================================================================
|
|
167
|
+
// Dialog components: replace the prompt input during interactive requests
|
|
168
|
+
// ============================================================================
|
|
169
|
+
|
|
170
|
+
class SelectDialog implements Component {
|
|
171
|
+
private list: SelectList;
|
|
172
|
+
private title: string;
|
|
173
|
+
onSelect?: (value: string) => void;
|
|
174
|
+
onCancel?: () => void;
|
|
175
|
+
|
|
176
|
+
constructor(title: string, options: string[]) {
|
|
177
|
+
this.title = title;
|
|
178
|
+
const items = options.map((o) => ({ value: o, label: o }));
|
|
179
|
+
this.list = new SelectList(items, Math.min(items.length, 8), {
|
|
180
|
+
selectedPrefix: (t) => `${MAGENTA}${t}${RESET}`,
|
|
181
|
+
selectedText: (t) => `${MAGENTA}${t}${RESET}`,
|
|
182
|
+
description: (t) => `${DIM}${t}${RESET}`,
|
|
183
|
+
scrollInfo: (t) => `${DIM}${t}${RESET}`,
|
|
184
|
+
noMatch: (t) => `${YELLOW}${t}${RESET}`,
|
|
185
|
+
});
|
|
186
|
+
this.list.onSelect = (item) => this.onSelect?.(item.value);
|
|
187
|
+
this.list.onCancel = () => this.onCancel?.();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
handleInput(data: string): void {
|
|
191
|
+
this.list.handleInput(data);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
invalidate(): void {
|
|
195
|
+
this.list.invalidate();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
render(width: number): string[] {
|
|
199
|
+
return [
|
|
200
|
+
`${MAGENTA}${BOLD}${this.title}${RESET}`,
|
|
201
|
+
...this.list.render(width),
|
|
202
|
+
`${DIM}Up/Down, Enter to select, Esc to cancel${RESET}`,
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
class InputDialog implements Component {
|
|
208
|
+
private dialogInput: Input;
|
|
209
|
+
private title: string;
|
|
210
|
+
onCtrlD?: () => void;
|
|
211
|
+
|
|
212
|
+
constructor(title: string, prefill?: string) {
|
|
213
|
+
this.title = title;
|
|
214
|
+
this.dialogInput = new Input();
|
|
215
|
+
if (prefill) this.dialogInput.setValue(prefill);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
set onSubmit(fn: ((value: string) => void) | undefined) {
|
|
219
|
+
this.dialogInput.onSubmit = fn;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
set onEscape(fn: (() => void) | undefined) {
|
|
223
|
+
this.dialogInput.onEscape = fn;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
get inputComponent(): Input {
|
|
227
|
+
return this.dialogInput;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
handleInput(data: string): void {
|
|
231
|
+
if (matchesKey(data, "ctrl+d")) {
|
|
232
|
+
this.onCtrlD?.();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this.dialogInput.handleInput(data);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
invalidate(): void {
|
|
239
|
+
this.dialogInput.invalidate();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
render(width: number): string[] {
|
|
243
|
+
return [
|
|
244
|
+
`${MAGENTA}${BOLD}${this.title}${RESET}`,
|
|
245
|
+
...this.dialogInput.render(width),
|
|
246
|
+
`${DIM}Enter to submit, Esc to cancel${RESET}`,
|
|
247
|
+
];
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// ============================================================================
|
|
252
|
+
// Main
|
|
253
|
+
// ============================================================================
|
|
254
|
+
|
|
255
|
+
async function main() {
|
|
256
|
+
const extensionPath = join(__dirname, "extensions/rpc-demo.ts");
|
|
257
|
+
const cliPath = join(__dirname, "../dist/cli.js");
|
|
258
|
+
|
|
259
|
+
const agent = spawn(
|
|
260
|
+
"node",
|
|
261
|
+
[cliPath, "--mode", "rpc", "--no-session", "--no-extensions", "--extension", extensionPath],
|
|
262
|
+
{ stdio: ["pipe", "pipe", "pipe"] },
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
let stderr = "";
|
|
266
|
+
agent.stderr?.on("data", (data: Buffer) => {
|
|
267
|
+
stderr += data.toString();
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
271
|
+
if (agent.exitCode !== null) {
|
|
272
|
+
console.error(`Agent exited immediately. Stderr:\n${stderr}`);
|
|
273
|
+
process.exit(1);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// -- TUI setup --
|
|
277
|
+
|
|
278
|
+
const terminal = new ProcessTerminal();
|
|
279
|
+
const tui: TUI = new TuiMainScreen(terminal);
|
|
280
|
+
|
|
281
|
+
const outputLog = new OutputLog();
|
|
282
|
+
const loadingIndicator = new LoadingIndicator();
|
|
283
|
+
const promptInput = new PromptInput();
|
|
284
|
+
|
|
285
|
+
const root = new Container();
|
|
286
|
+
root.addChild(outputLog);
|
|
287
|
+
root.addChild(promptInput);
|
|
288
|
+
|
|
289
|
+
tui.addChild(root);
|
|
290
|
+
tui.setFocus(promptInput.input);
|
|
291
|
+
|
|
292
|
+
// -- Agent communication --
|
|
293
|
+
|
|
294
|
+
function send(obj: Record<string, unknown>): void {
|
|
295
|
+
agent.stdin!.write(`${JSON.stringify(obj)}\n`);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
let isStreaming = false;
|
|
299
|
+
let hasTextOutput = false;
|
|
300
|
+
|
|
301
|
+
function exit(): void {
|
|
302
|
+
tui.stop();
|
|
303
|
+
agent.kill("SIGTERM");
|
|
304
|
+
process.exit(0);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// -- Bottom area management --
|
|
308
|
+
// The bottom of the screen is either the prompt input or a dialog.
|
|
309
|
+
// These helpers swap between them.
|
|
310
|
+
|
|
311
|
+
let activeDialog: Component | null = null;
|
|
312
|
+
|
|
313
|
+
function setBottomComponent(component: Component): void {
|
|
314
|
+
root.clear();
|
|
315
|
+
root.addChild(outputLog);
|
|
316
|
+
if (isStreaming) root.addChild(loadingIndicator);
|
|
317
|
+
root.addChild(component);
|
|
318
|
+
tui.setFocus(component);
|
|
319
|
+
tui.requestRender();
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function showPrompt(): void {
|
|
323
|
+
activeDialog = null;
|
|
324
|
+
setBottomComponent(promptInput);
|
|
325
|
+
tui.setFocus(promptInput.input);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function showDialog(dialog: Component): void {
|
|
329
|
+
activeDialog = dialog;
|
|
330
|
+
setBottomComponent(dialog);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function showLoading(): void {
|
|
334
|
+
if (!isStreaming) {
|
|
335
|
+
isStreaming = true;
|
|
336
|
+
hasTextOutput = false;
|
|
337
|
+
root.clear();
|
|
338
|
+
root.addChild(outputLog);
|
|
339
|
+
root.addChild(loadingIndicator);
|
|
340
|
+
root.addChild(activeDialog ?? promptInput);
|
|
341
|
+
if (!activeDialog) tui.setFocus(promptInput.input);
|
|
342
|
+
loadingIndicator.start(tui);
|
|
343
|
+
tui.requestRender();
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function hideLoading(): void {
|
|
348
|
+
loadingIndicator.stop();
|
|
349
|
+
root.clear();
|
|
350
|
+
root.addChild(outputLog);
|
|
351
|
+
root.addChild(activeDialog ?? promptInput);
|
|
352
|
+
if (!activeDialog) tui.setFocus(promptInput.input);
|
|
353
|
+
tui.requestRender();
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// -- Extension UI dialog handling --
|
|
357
|
+
|
|
358
|
+
function showSelectDialog(title: string, options: string[], onDone: (value: string | undefined) => void): void {
|
|
359
|
+
const dialog = new SelectDialog(title, options);
|
|
360
|
+
dialog.onSelect = (value) => {
|
|
361
|
+
showPrompt();
|
|
362
|
+
onDone(value);
|
|
363
|
+
};
|
|
364
|
+
dialog.onCancel = () => {
|
|
365
|
+
showPrompt();
|
|
366
|
+
onDone(undefined);
|
|
367
|
+
};
|
|
368
|
+
showDialog(dialog);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function showInputDialog(title: string, prefill?: string, onDone?: (value: string | undefined) => void): void {
|
|
372
|
+
const dialog = new InputDialog(title, prefill);
|
|
373
|
+
dialog.onSubmit = (value) => {
|
|
374
|
+
showPrompt();
|
|
375
|
+
onDone?.(value.trim() || undefined);
|
|
376
|
+
};
|
|
377
|
+
dialog.onEscape = () => {
|
|
378
|
+
showPrompt();
|
|
379
|
+
onDone?.(undefined);
|
|
380
|
+
};
|
|
381
|
+
dialog.onCtrlD = exit;
|
|
382
|
+
showDialog(dialog);
|
|
383
|
+
tui.setFocus(dialog.inputComponent);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function handleExtensionUI(req: ExtensionUIRequest): void {
|
|
387
|
+
const { id, method } = req;
|
|
388
|
+
|
|
389
|
+
switch (method) {
|
|
390
|
+
// Dialog methods: replace prompt with interactive component
|
|
391
|
+
case "select": {
|
|
392
|
+
showSelectDialog(req.title ?? "Select", req.options ?? [], (value) => {
|
|
393
|
+
if (value !== undefined) {
|
|
394
|
+
send({ type: "extension_ui_response", id, value });
|
|
395
|
+
} else {
|
|
396
|
+
send({ type: "extension_ui_response", id, cancelled: true });
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
case "confirm": {
|
|
403
|
+
const title = req.message ? `${req.title}: ${req.message}` : (req.title ?? "Confirm");
|
|
404
|
+
showSelectDialog(title, ["Yes", "No"], (value) => {
|
|
405
|
+
send({ type: "extension_ui_response", id, confirmed: value === "Yes" });
|
|
406
|
+
});
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
case "input": {
|
|
411
|
+
const title = req.placeholder ? `${req.title} (${req.placeholder})` : (req.title ?? "Input");
|
|
412
|
+
showInputDialog(title, undefined, (value) => {
|
|
413
|
+
if (value !== undefined) {
|
|
414
|
+
send({ type: "extension_ui_response", id, value });
|
|
415
|
+
} else {
|
|
416
|
+
send({ type: "extension_ui_response", id, cancelled: true });
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
case "editor": {
|
|
423
|
+
const prefill = req.prefill?.replace(/\n/g, " ");
|
|
424
|
+
showInputDialog(req.title ?? "Editor", prefill, (value) => {
|
|
425
|
+
if (value !== undefined) {
|
|
426
|
+
send({ type: "extension_ui_response", id, value });
|
|
427
|
+
} else {
|
|
428
|
+
send({ type: "extension_ui_response", id, cancelled: true });
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// Fire-and-forget methods: display as notification
|
|
435
|
+
case "notify": {
|
|
436
|
+
const notifyType = (req.notifyType as string) ?? "info";
|
|
437
|
+
const color = notifyType === "error" ? RED : notifyType === "warning" ? YELLOW : MAGENTA;
|
|
438
|
+
outputLog.append(`${color}${BOLD}Notification:${RESET} ${req.message}`);
|
|
439
|
+
tui.requestRender();
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
case "setStatus":
|
|
444
|
+
outputLog.append(
|
|
445
|
+
`${MAGENTA}${BOLD}Notification:${RESET} ${DIM}[status: ${req.statusKey}]${RESET} ${req.statusText ?? "(cleared)"}`,
|
|
446
|
+
);
|
|
447
|
+
tui.requestRender();
|
|
448
|
+
break;
|
|
449
|
+
|
|
450
|
+
case "setWidget": {
|
|
451
|
+
const lines = req.widgetLines;
|
|
452
|
+
if (lines && lines.length > 0) {
|
|
453
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} ${DIM}[widget: ${req.widgetKey}]${RESET}`);
|
|
454
|
+
for (const wl of lines) {
|
|
455
|
+
outputLog.append(` ${DIM}${wl}${RESET}`);
|
|
456
|
+
}
|
|
457
|
+
tui.requestRender();
|
|
458
|
+
}
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
case "set_editor_text":
|
|
463
|
+
promptInput.input.setValue((req.text as string) ?? "");
|
|
464
|
+
tui.requestRender();
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// -- Slash commands (local, not sent to agent) --
|
|
470
|
+
|
|
471
|
+
function handleSlashCommand(cmd: string): boolean {
|
|
472
|
+
switch (cmd) {
|
|
473
|
+
case "/select":
|
|
474
|
+
showSelectDialog("Pick a color", ["Red", "Green", "Blue", "Yellow"], (value) => {
|
|
475
|
+
if (value) {
|
|
476
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} You picked: ${value}`);
|
|
477
|
+
} else {
|
|
478
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} Selection cancelled`);
|
|
479
|
+
}
|
|
480
|
+
tui.requestRender();
|
|
481
|
+
});
|
|
482
|
+
return true;
|
|
483
|
+
|
|
484
|
+
case "/confirm":
|
|
485
|
+
showSelectDialog("Are you sure?", ["Yes", "No"], (value) => {
|
|
486
|
+
const confirmed = value === "Yes";
|
|
487
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} Confirmed: ${confirmed}`);
|
|
488
|
+
tui.requestRender();
|
|
489
|
+
});
|
|
490
|
+
return true;
|
|
491
|
+
|
|
492
|
+
case "/input":
|
|
493
|
+
showInputDialog("Enter your name", undefined, (value) => {
|
|
494
|
+
if (value) {
|
|
495
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} You entered: ${value}`);
|
|
496
|
+
} else {
|
|
497
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} Input cancelled`);
|
|
498
|
+
}
|
|
499
|
+
tui.requestRender();
|
|
500
|
+
});
|
|
501
|
+
return true;
|
|
502
|
+
|
|
503
|
+
case "/editor":
|
|
504
|
+
showInputDialog("Edit text", "Hello, world!", (value) => {
|
|
505
|
+
if (value) {
|
|
506
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} Submitted: ${value}`);
|
|
507
|
+
} else {
|
|
508
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} Editor cancelled`);
|
|
509
|
+
}
|
|
510
|
+
tui.requestRender();
|
|
511
|
+
});
|
|
512
|
+
return true;
|
|
513
|
+
|
|
514
|
+
default:
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// -- Process agent stdout --
|
|
520
|
+
|
|
521
|
+
function handleAgentLine(line: string): void {
|
|
522
|
+
let data: Record<string, unknown>;
|
|
523
|
+
try {
|
|
524
|
+
data = JSON.parse(line);
|
|
525
|
+
} catch {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (data.type === "response" && !data.success) {
|
|
530
|
+
outputLog.append(`${RED}[error]${RESET} ${data.command}: ${data.error}`);
|
|
531
|
+
tui.requestRender();
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
if (data.type === "agent_start") {
|
|
536
|
+
showLoading();
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (data.type === "extension_ui_request") {
|
|
541
|
+
handleExtensionUI(data as unknown as ExtensionUIRequest);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
if (data.type === "message_update") {
|
|
546
|
+
const evt = data.assistantMessageEvent as Record<string, unknown> | undefined;
|
|
547
|
+
if (evt?.type === "text_delta") {
|
|
548
|
+
if (!hasTextOutput) {
|
|
549
|
+
hasTextOutput = true;
|
|
550
|
+
outputLog.append("");
|
|
551
|
+
outputLog.append(`${BLUE}${BOLD}Agent:${RESET}`);
|
|
552
|
+
}
|
|
553
|
+
const delta = evt.delta as string;
|
|
554
|
+
const parts = delta.split("\n");
|
|
555
|
+
for (let i = 0; i < parts.length; i++) {
|
|
556
|
+
if (i > 0) outputLog.append("");
|
|
557
|
+
if (parts[i]) outputLog.appendRaw(parts[i]);
|
|
558
|
+
}
|
|
559
|
+
tui.requestRender();
|
|
560
|
+
}
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (data.type === "tool_execution_start") {
|
|
565
|
+
outputLog.append(`${DIM}[tool: ${data.toolName}]${RESET}`);
|
|
566
|
+
tui.requestRender();
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (data.type === "tool_execution_end") {
|
|
571
|
+
const result = JSON.stringify(data.result).slice(0, 120);
|
|
572
|
+
outputLog.append(`${DIM}[result: ${result}...]${RESET}`);
|
|
573
|
+
tui.requestRender();
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (data.type === "agent_settled") {
|
|
578
|
+
isStreaming = false;
|
|
579
|
+
hideLoading();
|
|
580
|
+
outputLog.append("");
|
|
581
|
+
tui.requestRender();
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const stdoutDecoder = new StringDecoder("utf8");
|
|
587
|
+
let stdoutBuffer = "";
|
|
588
|
+
|
|
589
|
+
agent.stdout!.on("data", (chunk: Buffer) => {
|
|
590
|
+
const text = stdoutDecoder.write(chunk);
|
|
591
|
+
// Only the new text is scanned, so a long line arriving in many chunks is not rescanned per chunk.
|
|
592
|
+
let start = 0;
|
|
593
|
+
for (let newlineIndex = text.indexOf("\n"); newlineIndex !== -1; newlineIndex = text.indexOf("\n", start)) {
|
|
594
|
+
const line = stdoutBuffer + text.slice(start, newlineIndex);
|
|
595
|
+
stdoutBuffer = "";
|
|
596
|
+
start = newlineIndex + 1;
|
|
597
|
+
handleAgentLine(line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
598
|
+
}
|
|
599
|
+
stdoutBuffer += text.slice(start);
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
agent.stdout!.on("end", () => {
|
|
603
|
+
stdoutBuffer += stdoutDecoder.end();
|
|
604
|
+
if (stdoutBuffer.length > 0) {
|
|
605
|
+
handleAgentLine(stdoutBuffer.endsWith("\r") ? stdoutBuffer.slice(0, -1) : stdoutBuffer);
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// -- User input --
|
|
610
|
+
|
|
611
|
+
promptInput.input.onSubmit = (value) => {
|
|
612
|
+
const trimmed = value.trim();
|
|
613
|
+
if (!trimmed) return;
|
|
614
|
+
|
|
615
|
+
promptInput.input.setValue("");
|
|
616
|
+
|
|
617
|
+
if (handleSlashCommand(trimmed)) {
|
|
618
|
+
outputLog.append(`${GREEN}${BOLD}You:${RESET} ${trimmed}`);
|
|
619
|
+
tui.requestRender();
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
outputLog.append(`${GREEN}${BOLD}You:${RESET} ${trimmed}`);
|
|
624
|
+
send({ type: "prompt", message: trimmed });
|
|
625
|
+
tui.requestRender();
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
promptInput.onCtrlD = exit;
|
|
629
|
+
|
|
630
|
+
promptInput.input.onEscape = () => {
|
|
631
|
+
if (isStreaming) {
|
|
632
|
+
send({ type: "abort" });
|
|
633
|
+
outputLog.append(`${YELLOW}[aborted]${RESET}`);
|
|
634
|
+
tui.requestRender();
|
|
635
|
+
} else {
|
|
636
|
+
exit();
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
// -- Agent exit --
|
|
641
|
+
|
|
642
|
+
agent.on("exit", (code) => {
|
|
643
|
+
tui.stop();
|
|
644
|
+
if (stderr) console.error(stderr);
|
|
645
|
+
console.log(`Agent exited with code ${code}`);
|
|
646
|
+
process.exit(code ?? 0);
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
// -- Start --
|
|
650
|
+
|
|
651
|
+
outputLog.append(`${BOLD}RPC Chat${RESET}`);
|
|
652
|
+
outputLog.append(`${DIM}Type a message and press Enter. Esc to abort or exit. Ctrl+D to quit.${RESET}`);
|
|
653
|
+
outputLog.append(`${DIM}Slash commands: /select /confirm /input /editor${RESET}`);
|
|
654
|
+
outputLog.append("");
|
|
655
|
+
|
|
656
|
+
tui.start();
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
main().catch((err) => {
|
|
660
|
+
console.error(err);
|
|
661
|
+
process.exit(1);
|
|
662
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal SDK Usage
|
|
3
|
+
*
|
|
4
|
+
* Uses all defaults: discovers skills, extensions, tools, context files
|
|
5
|
+
* from cwd and ~/.pi/agent. Model chosen from settings or first available.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { createAgentSession } from "@earendil-works/pi-coding-agent";
|
|
9
|
+
|
|
10
|
+
const { session } = await createAgentSession();
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
session.subscribe((event) => {
|
|
14
|
+
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
15
|
+
process.stdout.write(event.assistantMessageEvent.delta);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
await session.prompt("What files are in the current directory?");
|
|
20
|
+
session.state.messages.forEach((msg) => {
|
|
21
|
+
console.log(msg);
|
|
22
|
+
});
|
|
23
|
+
console.log();
|
|
24
|
+
} finally {
|
|
25
|
+
session.dispose();
|
|
26
|
+
}
|