pi-oxidized 0.1.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/.agent-tasks/pi-rust-rewrite/Cargo.lock +5022 -0
- package/.agent-tasks/pi-rust-rewrite/Cargo.toml +22 -0
- package/.agent-tasks/pi-rust-rewrite/GOALS.md +1 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/branch_summary.json +8 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/changelog.md +16 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/debug_dump.txt +11 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/events.jsonl +6 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/legacy_auth_migration.json +16 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/selector_snapshot.txt +9 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/session_stats.json +16 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/share_result.json +7 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/sessions/export-roundtrip.jsonl +6 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/provider-drain/isolation-expectations.json +21 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/rpc/commands.json +238 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/rpc/host-state.json +128 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/rpc/ts-goldens.json +1 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/rpc/ts-replay.ts +317 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v1/linear-with-compaction.expected.json +576 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v1/linear-with-compaction.jsonl +12 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v2/branched.expected.json +387 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v2/branched.jsonl +8 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/basic.expected.json +256 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/basic.jsonl +5 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/branched-labels.expected.json +474 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/branched-labels.jsonl +13 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/branched-session.expected.json +352 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/branched-session.jsonl +9 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/compacted-twice.expected.json +590 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/compacted-twice.jsonl +13 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/custom-messages.expected.json +400 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/custom-messages.jsonl +8 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/forked-header.expected.json +257 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/forked-header.jsonl +5 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/unknown-entries.expected.json +297 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/unknown-entries.jsonl +6 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/bash.json +16 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/edit.json +34 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/find.json +20 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/grep.json +36 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/ls.json +13 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/read.json +20 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/write.json +17 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tools/edit-cases.json +93 -0
- package/.agent-tasks/pi-rust-rewrite/helpers/reopen_session.ts +168 -0
- package/.agent-tasks/pi-rust-rewrite/src/lib.rs +13 -0
- package/.agent-tasks/pi-rust-rewrite/tests/phase7_fixtures.rs +742 -0
- package/.agent-tasks/pi-rust-rewrite/tests/pi_ai_contract.rs +101 -0
- package/.agent-tasks/pi-rust-rewrite/tests/provider_drain_isolation.rs +760 -0
- package/.agent-tasks/pi-rust-rewrite/tests/rpc_parity.rs +679 -0
- package/.agent-tasks/pi-rust-rewrite/tests/session_compat.rs +839 -0
- package/.agent-tasks/pi-rust-rewrite/tests/tool_parity.rs +761 -0
- package/.github/workflows/release-verification.yml +204 -0
- package/.gitmodules +5 -0
- package/.outline/audit/coverage.json +3262 -0
- package/.outline/audit/queue.json +4841 -0
- package/.outline/review-fix-grill/iterations/1.json +767 -0
- package/.outline/review-fix-grill/iterations/2.json +69 -0
- package/.outline/review-fix-grill/iterations/3.json +81 -0
- package/.outline/review-fix-grill/iterations/4.json +35 -0
- package/.outline/review-fix-grill/iterations/5.json +21 -0
- package/.outline/review-fix-grill/queue.json +6454 -0
- package/.references/pi/.gitattributes +23 -0
- package/.references/pi/.github/APPROVED_CONTRIBUTORS +281 -0
- package/.references/pi/.github/ISSUE_TEMPLATE/bug.yml +45 -0
- package/.references/pi/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/.references/pi/.github/ISSUE_TEMPLATE/contribution.yml +36 -0
- package/.references/pi/.github/ISSUE_TEMPLATE/package-report.yml +49 -0
- package/.references/pi/.github/workflows/approve-contributor.yml +179 -0
- package/.references/pi/.github/workflows/build-binaries.yml +294 -0
- package/.references/pi/.github/workflows/ci.yml +42 -0
- package/.references/pi/.github/workflows/issue-analysis.yml +634 -0
- package/.references/pi/.github/workflows/issue-gate.yml +129 -0
- package/.references/pi/.github/workflows/issue-triage-labels.yml +142 -0
- package/.references/pi/.github/workflows/npm-audit.yml +31 -0
- package/.references/pi/.github/workflows/pr-gate.yml +128 -0
- package/.references/pi/.github/workflows/publish-model-catalog.yml +112 -0
- package/.references/pi/.github/workflows/remove-inprogress-on-close.yml +31 -0
- package/.references/pi/.husky/pre-commit +45 -0
- package/.references/pi/.pi/extensions/import-repro.ts +351 -0
- package/.references/pi/.pi/extensions/prompt-url-widget.ts +270 -0
- package/.references/pi/.pi/extensions/redraws.ts +24 -0
- package/.references/pi/.pi/extensions/tps.ts +47 -0
- package/.references/pi/.pi/git/.gitignore +2 -0
- package/.references/pi/.pi/npm/.gitignore +2 -0
- package/.references/pi/.pi/prompts/cl.md +54 -0
- package/.references/pi/.pi/prompts/is.md +28 -0
- package/.references/pi/.pi/prompts/pr.md +37 -0
- package/.references/pi/.pi/prompts/sa.md +163 -0
- package/.references/pi/.pi/prompts/wr.md +40 -0
- package/.references/pi/.pi/skills/add-llm-provider.md +57 -0
- package/.references/pi/AGENTS.md +162 -0
- package/.references/pi/CONTRIBUTING.md +102 -0
- package/.references/pi/LICENSE +21 -0
- package/.references/pi/README.md +99 -0
- package/.references/pi/SECURITY.md +87 -0
- package/.references/pi/biome.json +39 -0
- package/.references/pi/bun.lock +961 -0
- package/.references/pi/package-lock.json +6172 -0
- package/.references/pi/package.json +66 -0
- package/.references/pi/packages/agent/CHANGELOG.md +594 -0
- package/.references/pi/packages/agent/README.md +488 -0
- package/.references/pi/packages/agent/docs/agent-harness.md +488 -0
- package/.references/pi/packages/agent/docs/durable-harness.md +212 -0
- package/.references/pi/packages/agent/docs/hooks.md +445 -0
- package/.references/pi/packages/agent/docs/models.md +964 -0
- package/.references/pi/packages/agent/docs/observability.md +376 -0
- package/.references/pi/packages/agent/package.json +60 -0
- package/.references/pi/packages/agent/src/agent-loop.ts +792 -0
- package/.references/pi/packages/agent/src/agent.ts +575 -0
- package/.references/pi/packages/agent/src/harness/agent-harness.ts +1029 -0
- package/.references/pi/packages/agent/src/harness/compaction/branch-summarization.ts +261 -0
- package/.references/pi/packages/agent/src/harness/compaction/compaction.ts +753 -0
- package/.references/pi/packages/agent/src/harness/compaction/utils.ts +144 -0
- package/.references/pi/packages/agent/src/harness/env/nodejs.ts +569 -0
- package/.references/pi/packages/agent/src/harness/messages.ts +164 -0
- package/.references/pi/packages/agent/src/harness/prompt-templates.ts +267 -0
- package/.references/pi/packages/agent/src/harness/session/jsonl-repo.ts +179 -0
- package/.references/pi/packages/agent/src/harness/session/jsonl-storage.ts +314 -0
- package/.references/pi/packages/agent/src/harness/session/memory-repo.ts +50 -0
- package/.references/pi/packages/agent/src/harness/session/memory-storage.ts +133 -0
- package/.references/pi/packages/agent/src/harness/session/repo-utils.ts +51 -0
- package/.references/pi/packages/agent/src/harness/session/session.ts +338 -0
- package/.references/pi/packages/agent/src/harness/session/uuid.ts +54 -0
- package/.references/pi/packages/agent/src/harness/skills.ts +375 -0
- package/.references/pi/packages/agent/src/harness/system-prompt.ts +34 -0
- package/.references/pi/packages/agent/src/harness/types.ts +838 -0
- package/.references/pi/packages/agent/src/harness/utils/shell-output.ts +135 -0
- package/.references/pi/packages/agent/src/harness/utils/truncate.ts +344 -0
- package/.references/pi/packages/agent/src/index.ts +46 -0
- package/.references/pi/packages/agent/src/node.ts +2 -0
- package/.references/pi/packages/agent/src/proxy.ts +367 -0
- package/.references/pi/packages/agent/src/types.ts +430 -0
- package/.references/pi/packages/agent/test/agent-loop.test.ts +1424 -0
- package/.references/pi/packages/agent/test/agent.test.ts +699 -0
- package/.references/pi/packages/agent/test/e2e.test.ts +404 -0
- package/.references/pi/packages/agent/test/harness/agent-harness-stream.test.ts +213 -0
- package/.references/pi/packages/agent/test/harness/agent-harness.test.ts +608 -0
- package/.references/pi/packages/agent/test/harness/compaction.test.ts +655 -0
- package/.references/pi/packages/agent/test/harness/nodejs-env.test.ts +321 -0
- package/.references/pi/packages/agent/test/harness/prompt-templates.test.ts +90 -0
- package/.references/pi/packages/agent/test/harness/repo.test.ts +92 -0
- package/.references/pi/packages/agent/test/harness/resource-formatting.test.ts +24 -0
- package/.references/pi/packages/agent/test/harness/session-test-utils.ts +55 -0
- package/.references/pi/packages/agent/test/harness/session-uuid.test.ts +50 -0
- package/.references/pi/packages/agent/test/harness/session.test.ts +203 -0
- package/.references/pi/packages/agent/test/harness/skills.test.ts +116 -0
- package/.references/pi/packages/agent/test/harness/storage.test.ts +341 -0
- package/.references/pi/packages/agent/test/harness/system-prompt.test.ts +66 -0
- package/.references/pi/packages/agent/test/harness/truncate.test.ts +169 -0
- package/.references/pi/packages/agent/test/scratch/simple.ts +72 -0
- package/.references/pi/packages/agent/test/utils/calculate.ts +32 -0
- package/.references/pi/packages/agent/test/utils/get-current-time.ts +46 -0
- package/.references/pi/packages/agent/tsconfig.build.json +13 -0
- package/.references/pi/packages/agent/vitest.config.ts +21 -0
- package/.references/pi/packages/agent/vitest.harness.config.ts +28 -0
- package/.references/pi/packages/ai/CHANGELOG.md +1739 -0
- package/.references/pi/packages/ai/README.md +1621 -0
- package/.references/pi/packages/ai/bedrock-provider.d.ts +1 -0
- package/.references/pi/packages/ai/bedrock-provider.js +1 -0
- package/.references/pi/packages/ai/package.json +97 -0
- package/.references/pi/packages/ai/scripts/generate-image-models.ts +131 -0
- package/.references/pi/packages/ai/scripts/generate-models.ts +2401 -0
- package/.references/pi/packages/ai/scripts/generate-test-image.ts +33 -0
- package/.references/pi/packages/ai/src/api/anthropic-messages.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/anthropic-messages.ts +1313 -0
- package/.references/pi/packages/ai/src/api/azure-openai-responses.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/azure-openai-responses.ts +298 -0
- package/.references/pi/packages/ai/src/api/bedrock-converse-stream.lazy.ts +30 -0
- package/.references/pi/packages/ai/src/api/bedrock-converse-stream.ts +1091 -0
- package/.references/pi/packages/ai/src/api/cloudflare.ts +15 -0
- package/.references/pi/packages/ai/src/api/github-copilot-headers.ts +37 -0
- package/.references/pi/packages/ai/src/api/google-generative-ai.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/google-generative-ai.ts +509 -0
- package/.references/pi/packages/ai/src/api/google-shared.ts +350 -0
- package/.references/pi/packages/ai/src/api/google-vertex.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/google-vertex.ts +584 -0
- package/.references/pi/packages/ai/src/api/lazy.ts +75 -0
- package/.references/pi/packages/ai/src/api/mistral-conversations.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/mistral-conversations.ts +664 -0
- package/.references/pi/packages/ai/src/api/openai-codex-responses.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/openai-codex-responses.ts +1573 -0
- package/.references/pi/packages/ai/src/api/openai-completions.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/openai-completions.ts +1355 -0
- package/.references/pi/packages/ai/src/api/openai-prompt-cache.ts +8 -0
- package/.references/pi/packages/ai/src/api/openai-responses-shared.ts +613 -0
- package/.references/pi/packages/ai/src/api/openai-responses.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/openai-responses.ts +318 -0
- package/.references/pi/packages/ai/src/api/openrouter-images.lazy.ts +10 -0
- package/.references/pi/packages/ai/src/api/openrouter-images.ts +185 -0
- package/.references/pi/packages/ai/src/api/pi-messages.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/pi-messages.ts +436 -0
- package/.references/pi/packages/ai/src/api/simple-options.ts +77 -0
- package/.references/pi/packages/ai/src/api/transform-messages.ts +223 -0
- package/.references/pi/packages/ai/src/auth/context.ts +45 -0
- package/.references/pi/packages/ai/src/auth/credential-store.ts +51 -0
- package/.references/pi/packages/ai/src/auth/helpers.ts +47 -0
- package/.references/pi/packages/ai/src/auth/oauth/anthropic.ts +350 -0
- package/.references/pi/packages/ai/src/auth/oauth/device-code.ts +98 -0
- package/.references/pi/packages/ai/src/auth/oauth/github-copilot.ts +379 -0
- package/.references/pi/packages/ai/src/auth/oauth/load.ts +56 -0
- package/.references/pi/packages/ai/src/auth/oauth/oauth-page.ts +109 -0
- package/.references/pi/packages/ai/src/auth/oauth/openai-codex.ts +538 -0
- package/.references/pi/packages/ai/src/auth/oauth/pkce.ts +34 -0
- package/.references/pi/packages/ai/src/auth/oauth/radius.ts +410 -0
- package/.references/pi/packages/ai/src/auth/oauth/xai.ts +238 -0
- package/.references/pi/packages/ai/src/auth/resolve.ts +139 -0
- package/.references/pi/packages/ai/src/auth/types.ts +220 -0
- package/.references/pi/packages/ai/src/bedrock-provider.ts +6 -0
- package/.references/pi/packages/ai/src/bun-oauth.ts +17 -0
- package/.references/pi/packages/ai/src/cli.ts +118 -0
- package/.references/pi/packages/ai/src/compat/extension-oauth-types.ts +45 -0
- package/.references/pi/packages/ai/src/compat.ts +298 -0
- package/.references/pi/packages/ai/src/env-api-keys.ts +178 -0
- package/.references/pi/packages/ai/src/image-models.generated.ts +534 -0
- package/.references/pi/packages/ai/src/image-models.ts +42 -0
- package/.references/pi/packages/ai/src/images-api-registry.ts +53 -0
- package/.references/pi/packages/ai/src/images-models.ts +274 -0
- package/.references/pi/packages/ai/src/images.ts +21 -0
- package/.references/pi/packages/ai/src/index.ts +45 -0
- package/.references/pi/packages/ai/src/legacy-api-aliases.ts +108 -0
- package/.references/pi/packages/ai/src/models-store.ts +38 -0
- package/.references/pi/packages/ai/src/models.generated.ts +76 -0
- package/.references/pi/packages/ai/src/models.ts +705 -0
- package/.references/pi/packages/ai/src/oauth.ts +10 -0
- package/.references/pi/packages/ai/src/providers/all.ts +140 -0
- package/.references/pi/packages/ai/src/providers/amazon-bedrock.models.ts +1897 -0
- package/.references/pi/packages/ai/src/providers/amazon-bedrock.ts +80 -0
- package/.references/pi/packages/ai/src/providers/ant-ling.models.ts +62 -0
- package/.references/pi/packages/ai/src/providers/ant-ling.ts +15 -0
- package/.references/pi/packages/ai/src/providers/anthropic.models.ts +257 -0
- package/.references/pi/packages/ai/src/providers/anthropic.ts +20 -0
- package/.references/pi/packages/ai/src/providers/azure-openai-responses.models.ts +816 -0
- package/.references/pi/packages/ai/src/providers/azure-openai-responses.ts +14 -0
- package/.references/pi/packages/ai/src/providers/cerebras.models.ts +61 -0
- package/.references/pi/packages/ai/src/providers/cerebras.ts +15 -0
- package/.references/pi/packages/ai/src/providers/cloudflare-ai-gateway.models.ts +760 -0
- package/.references/pi/packages/ai/src/providers/cloudflare-ai-gateway.ts +23 -0
- package/.references/pi/packages/ai/src/providers/cloudflare-auth.ts +96 -0
- package/.references/pi/packages/ai/src/providers/cloudflare-stream.ts +28 -0
- package/.references/pi/packages/ai/src/providers/cloudflare-workers-ai.models.ts +241 -0
- package/.references/pi/packages/ai/src/providers/cloudflare-workers-ai.ts +15 -0
- package/.references/pi/packages/ai/src/providers/deepseek.models.ts +45 -0
- package/.references/pi/packages/ai/src/providers/deepseek.ts +15 -0
- package/.references/pi/packages/ai/src/providers/faux.ts +538 -0
- package/.references/pi/packages/ai/src/providers/fireworks.models.ts +297 -0
- package/.references/pi/packages/ai/src/providers/fireworks.ts +19 -0
- package/.references/pi/packages/ai/src/providers/github-copilot.models.ts +543 -0
- package/.references/pi/packages/ai/src/providers/github-copilot.ts +34 -0
- package/.references/pi/packages/ai/src/providers/google-vertex.models.ts +184 -0
- package/.references/pi/packages/ai/src/providers/google-vertex.ts +93 -0
- package/.references/pi/packages/ai/src/providers/google.models.ts +290 -0
- package/.references/pi/packages/ai/src/providers/google.ts +15 -0
- package/.references/pi/packages/ai/src/providers/groq.models.ts +127 -0
- package/.references/pi/packages/ai/src/providers/groq.ts +15 -0
- package/.references/pi/packages/ai/src/providers/huggingface.models.ts +889 -0
- package/.references/pi/packages/ai/src/providers/huggingface.ts +15 -0
- package/.references/pi/packages/ai/src/providers/images/register-builtins.ts +50 -0
- package/.references/pi/packages/ai/src/providers/kimi-coding.models.ts +103 -0
- package/.references/pi/packages/ai/src/providers/kimi-coding.ts +15 -0
- package/.references/pi/packages/ai/src/providers/minimax-cn.models.ts +58 -0
- package/.references/pi/packages/ai/src/providers/minimax-cn.ts +15 -0
- package/.references/pi/packages/ai/src/providers/minimax.models.ts +58 -0
- package/.references/pi/packages/ai/src/providers/minimax.ts +15 -0
- package/.references/pi/packages/ai/src/providers/mistral.models.ts +517 -0
- package/.references/pi/packages/ai/src/providers/mistral.ts +15 -0
- package/.references/pi/packages/ai/src/providers/moonshotai-cn.models.ts +190 -0
- package/.references/pi/packages/ai/src/providers/moonshotai-cn.ts +15 -0
- package/.references/pi/packages/ai/src/providers/moonshotai.models.ts +190 -0
- package/.references/pi/packages/ai/src/providers/moonshotai.ts +15 -0
- package/.references/pi/packages/ai/src/providers/nvidia.models.ts +387 -0
- package/.references/pi/packages/ai/src/providers/nvidia.ts +15 -0
- package/.references/pi/packages/ai/src/providers/openai-codex.models.ts +144 -0
- package/.references/pi/packages/ai/src/providers/openai-codex.ts +18 -0
- package/.references/pi/packages/ai/src/providers/openai.models.ts +830 -0
- package/.references/pi/packages/ai/src/providers/openai.ts +15 -0
- package/.references/pi/packages/ai/src/providers/opencode-go.models.ts +278 -0
- package/.references/pi/packages/ai/src/providers/opencode-go.ts +18 -0
- package/.references/pi/packages/ai/src/providers/opencode.models.ts +1001 -0
- package/.references/pi/packages/ai/src/providers/opencode.ts +24 -0
- package/.references/pi/packages/ai/src/providers/openrouter-images.ts +14 -0
- package/.references/pi/packages/ai/src/providers/openrouter.models.ts +4915 -0
- package/.references/pi/packages/ai/src/providers/openrouter.ts +15 -0
- package/.references/pi/packages/ai/src/providers/radius-config.ts +95 -0
- package/.references/pi/packages/ai/src/providers/radius.ts +67 -0
- package/.references/pi/packages/ai/src/providers/together.models.ts +382 -0
- package/.references/pi/packages/ai/src/providers/together.ts +15 -0
- package/.references/pi/packages/ai/src/providers/vercel-ai-gateway.models.ts +3268 -0
- package/.references/pi/packages/ai/src/providers/vercel-ai-gateway.ts +15 -0
- package/.references/pi/packages/ai/src/providers/xai.models.ts +62 -0
- package/.references/pi/packages/ai/src/providers/xai.ts +27 -0
- package/.references/pi/packages/ai/src/providers/xiaomi-token-plan-ams.models.ts +61 -0
- package/.references/pi/packages/ai/src/providers/xiaomi-token-plan-ams.ts +15 -0
- package/.references/pi/packages/ai/src/providers/xiaomi-token-plan-cn.models.ts +61 -0
- package/.references/pi/packages/ai/src/providers/xiaomi-token-plan-cn.ts +15 -0
- package/.references/pi/packages/ai/src/providers/xiaomi-token-plan-sgp.models.ts +61 -0
- package/.references/pi/packages/ai/src/providers/xiaomi-token-plan-sgp.ts +15 -0
- package/.references/pi/packages/ai/src/providers/xiaomi.models.ts +115 -0
- package/.references/pi/packages/ai/src/providers/xiaomi.ts +15 -0
- package/.references/pi/packages/ai/src/providers/zai-coding-cn.models.ts +116 -0
- package/.references/pi/packages/ai/src/providers/zai-coding-cn.ts +15 -0
- package/.references/pi/packages/ai/src/providers/zai.models.ts +116 -0
- package/.references/pi/packages/ai/src/providers/zai.ts +15 -0
- package/.references/pi/packages/ai/src/session-resources.ts +24 -0
- package/.references/pi/packages/ai/src/types.ts +738 -0
- package/.references/pi/packages/ai/src/utils/abort-signals.ts +41 -0
- package/.references/pi/packages/ai/src/utils/deferred-tools.ts +39 -0
- package/.references/pi/packages/ai/src/utils/diagnostics.ts +45 -0
- package/.references/pi/packages/ai/src/utils/error-body.ts +127 -0
- package/.references/pi/packages/ai/src/utils/estimate.ts +143 -0
- package/.references/pi/packages/ai/src/utils/event-stream.ts +88 -0
- package/.references/pi/packages/ai/src/utils/hash.ts +13 -0
- package/.references/pi/packages/ai/src/utils/headers.ts +18 -0
- package/.references/pi/packages/ai/src/utils/json-parse.ts +124 -0
- package/.references/pi/packages/ai/src/utils/node-http-proxy.ts +112 -0
- package/.references/pi/packages/ai/src/utils/overflow.ts +165 -0
- package/.references/pi/packages/ai/src/utils/provider-env.ts +52 -0
- package/.references/pi/packages/ai/src/utils/retry.ts +101 -0
- package/.references/pi/packages/ai/src/utils/sanitize-unicode.ts +25 -0
- package/.references/pi/packages/ai/src/utils/typebox-helpers.ts +24 -0
- package/.references/pi/packages/ai/src/utils/validation.ts +310 -0
- package/.references/pi/packages/ai/test/abort.test.ts +303 -0
- package/.references/pi/packages/ai/test/anthropic-adaptive-thinking-models.test.ts +39 -0
- package/.references/pi/packages/ai/test/anthropic-cache-write-1h-cost.test.ts +86 -0
- package/.references/pi/packages/ai/test/anthropic-eager-tool-input-compat.test.ts +122 -0
- package/.references/pi/packages/ai/test/anthropic-eager-tool-input-e2e.test.ts +155 -0
- package/.references/pi/packages/ai/test/anthropic-empty-thinking-signature-compat.test.ts +108 -0
- package/.references/pi/packages/ai/test/anthropic-force-adaptive-thinking.test.ts +125 -0
- package/.references/pi/packages/ai/test/anthropic-long-cache-retention-e2e.test.ts +127 -0
- package/.references/pi/packages/ai/test/anthropic-oauth.test.ts +137 -0
- package/.references/pi/packages/ai/test/anthropic-opus-4-8-smoke.test.ts +71 -0
- package/.references/pi/packages/ai/test/anthropic-sse-parsing.test.ts +275 -0
- package/.references/pi/packages/ai/test/anthropic-temperature-compat.test.ts +103 -0
- package/.references/pi/packages/ai/test/anthropic-thinking-disable.test.ts +172 -0
- package/.references/pi/packages/ai/test/anthropic-tool-name-normalization.test.ts +204 -0
- package/.references/pi/packages/ai/test/azure-openai-base-url.test.ts +175 -0
- package/.references/pi/packages/ai/test/azure-openai-responses-reasoning-replay.test.ts +136 -0
- package/.references/pi/packages/ai/test/azure-utils.ts +28 -0
- package/.references/pi/packages/ai/test/bedrock-convert-messages.test.ts +245 -0
- package/.references/pi/packages/ai/test/bedrock-custom-headers.test.ts +202 -0
- package/.references/pi/packages/ai/test/bedrock-endpoint-resolution.test.ts +208 -0
- package/.references/pi/packages/ai/test/bedrock-models.test.ts +65 -0
- package/.references/pi/packages/ai/test/bedrock-thinking-payload.test.ts +246 -0
- package/.references/pi/packages/ai/test/bedrock-utils.ts +18 -0
- package/.references/pi/packages/ai/test/cache-retention.test.ts +498 -0
- package/.references/pi/packages/ai/test/cloudflare-stream.test.ts +65 -0
- package/.references/pi/packages/ai/test/cloudflare-utils.ts +9 -0
- package/.references/pi/packages/ai/test/codex-websocket-cached-probe.ts +299 -0
- package/.references/pi/packages/ai/test/compat-env.test.ts +74 -0
- package/.references/pi/packages/ai/test/context-estimate.test.ts +81 -0
- package/.references/pi/packages/ai/test/context-overflow.test.ts +734 -0
- package/.references/pi/packages/ai/test/cross-provider-handoff.test.ts +502 -0
- package/.references/pi/packages/ai/test/data/red-circle.png +0 -0
- package/.references/pi/packages/ai/test/deferred-tools.test.ts +481 -0
- package/.references/pi/packages/ai/test/empty.test.ts +741 -0
- package/.references/pi/packages/ai/test/env-api-keys.test.ts +60 -0
- package/.references/pi/packages/ai/test/error-body.test.ts +154 -0
- package/.references/pi/packages/ai/test/faux-provider.test.ts +597 -0
- package/.references/pi/packages/ai/test/fireworks-models.test.ts +269 -0
- package/.references/pi/packages/ai/test/github-copilot-anthropic.test.ts +120 -0
- package/.references/pi/packages/ai/test/github-copilot-oauth.test.ts +444 -0
- package/.references/pi/packages/ai/test/google-shared-convert-tools.test.ts +187 -0
- package/.references/pi/packages/ai/test/google-shared-gemini3-unsigned-tool-call.test.ts +116 -0
- package/.references/pi/packages/ai/test/google-shared-image-tool-result-routing.test.ts +102 -0
- package/.references/pi/packages/ai/test/google-thinking-disable.test.ts +160 -0
- package/.references/pi/packages/ai/test/google-thinking-signature.test.ts +38 -0
- package/.references/pi/packages/ai/test/google-vertex-api-key-resolution.test.ts +223 -0
- package/.references/pi/packages/ai/test/image-tool-result.test.ts +501 -0
- package/.references/pi/packages/ai/test/images-models.test.ts +209 -0
- package/.references/pi/packages/ai/test/images.test.ts +90 -0
- package/.references/pi/packages/ai/test/interleaved-thinking.test.ts +144 -0
- package/.references/pi/packages/ai/test/lax-message-content.test.ts +67 -0
- package/.references/pi/packages/ai/test/lazy-module-load.test.ts +119 -0
- package/.references/pi/packages/ai/test/max-thinking.test.ts +89 -0
- package/.references/pi/packages/ai/test/mistral-reasoning-mode.test.ts +97 -0
- package/.references/pi/packages/ai/test/mistral-tool-schema.test.ts +60 -0
- package/.references/pi/packages/ai/test/models-runtime.test.ts +689 -0
- package/.references/pi/packages/ai/test/node-http-proxy.test.ts +76 -0
- package/.references/pi/packages/ai/test/oauth-auth.test.ts +141 -0
- package/.references/pi/packages/ai/test/oauth-device-code.test.ts +139 -0
- package/.references/pi/packages/ai/test/oauth.ts +83 -0
- package/.references/pi/packages/ai/test/openai-codex-cache-affinity-e2e.test.ts +35 -0
- package/.references/pi/packages/ai/test/openai-codex-oauth.test.ts +479 -0
- package/.references/pi/packages/ai/test/openai-codex-stream.test.ts +2028 -0
- package/.references/pi/packages/ai/test/openai-completions-cache-control-format.test.ts +189 -0
- package/.references/pi/packages/ai/test/openai-completions-empty-tools.test.ts +304 -0
- package/.references/pi/packages/ai/test/openai-completions-prompt-cache.test.ts +264 -0
- package/.references/pi/packages/ai/test/openai-completions-reasoning-details.test.ts +118 -0
- package/.references/pi/packages/ai/test/openai-completions-response-model.test.ts +140 -0
- package/.references/pi/packages/ai/test/openai-completions-retry.test.ts +86 -0
- package/.references/pi/packages/ai/test/openai-completions-thinking-as-text.test.ts +218 -0
- package/.references/pi/packages/ai/test/openai-completions-tool-choice.test.ts +1716 -0
- package/.references/pi/packages/ai/test/openai-completions-tool-result-images.test.ts +152 -0
- package/.references/pi/packages/ai/test/openai-responses-cache-affinity-e2e.test.ts +31 -0
- package/.references/pi/packages/ai/test/openai-responses-compat.test.ts +472 -0
- package/.references/pi/packages/ai/test/openai-responses-empty-tool-result.test.ts +58 -0
- package/.references/pi/packages/ai/test/openai-responses-foreign-toolcall-id.test.ts +66 -0
- package/.references/pi/packages/ai/test/openai-responses-message-id.test.ts +48 -0
- package/.references/pi/packages/ai/test/openai-responses-partial-json-cleanup.test.ts +106 -0
- package/.references/pi/packages/ai/test/openai-responses-reasoning-replay-e2e.test.ts +291 -0
- package/.references/pi/packages/ai/test/openai-responses-terminal-event.test.ts +233 -0
- package/.references/pi/packages/ai/test/openai-responses-tool-result-images.test.ts +194 -0
- package/.references/pi/packages/ai/test/openrouter-cache-write-repro.test.ts +77 -0
- package/.references/pi/packages/ai/test/openrouter-images.test.ts +140 -0
- package/.references/pi/packages/ai/test/overflow.test.ts +139 -0
- package/.references/pi/packages/ai/test/pi-messages.test.ts +243 -0
- package/.references/pi/packages/ai/test/provider-error-body-passthrough.test.ts +78 -0
- package/.references/pi/packages/ai/test/provider-error-body-regression.test.ts +189 -0
- package/.references/pi/packages/ai/test/providers.test.ts +404 -0
- package/.references/pi/packages/ai/test/responseid.test.ts +120 -0
- package/.references/pi/packages/ai/test/retry.test.ts +59 -0
- package/.references/pi/packages/ai/test/scratch.ts +57 -0
- package/.references/pi/packages/ai/test/stream.test.ts +1632 -0
- package/.references/pi/packages/ai/test/supports-xhigh.test.ts +145 -0
- package/.references/pi/packages/ai/test/together-models.test.ts +78 -0
- package/.references/pi/packages/ai/test/tokens.test.ts +333 -0
- package/.references/pi/packages/ai/test/tool-call-id-normalization.test.ts +290 -0
- package/.references/pi/packages/ai/test/tool-call-without-result.test.ts +327 -0
- package/.references/pi/packages/ai/test/total-tokens.test.ts +789 -0
- package/.references/pi/packages/ai/test/transform-messages-copilot-openai-to-anthropic.test.ts +191 -0
- package/.references/pi/packages/ai/test/unicode-surrogate.test.ts +774 -0
- package/.references/pi/packages/ai/test/validation.test.ts +116 -0
- package/.references/pi/packages/ai/test/xai-oauth.test.ts +330 -0
- package/.references/pi/packages/ai/test/xai-responses.test.ts +117 -0
- package/.references/pi/packages/ai/test/xhigh.test.ts +70 -0
- package/.references/pi/packages/ai/test/xiaomi-models.test.ts +17 -0
- package/.references/pi/packages/ai/test/xiaomi-token-plan-ams-anthropic-empty-signature-smoke.test.ts +114 -0
- package/.references/pi/packages/ai/test/zen.test.ts +25 -0
- package/.references/pi/packages/ai/tsconfig.build.json +9 -0
- package/.references/pi/packages/ai/vitest.config.ts +11 -0
- package/.references/pi/packages/coding-agent/CHANGELOG.md +5038 -0
- package/.references/pi/packages/coding-agent/README.md +691 -0
- package/.references/pi/packages/coding-agent/docs/compaction.md +396 -0
- package/.references/pi/packages/coding-agent/docs/containerization.md +111 -0
- package/.references/pi/packages/coding-agent/docs/custom-provider.md +735 -0
- package/.references/pi/packages/coding-agent/docs/development.md +71 -0
- package/.references/pi/packages/coding-agent/docs/docs.json +156 -0
- package/.references/pi/packages/coding-agent/docs/extensions.md +2911 -0
- package/.references/pi/packages/coding-agent/docs/images/doom-extension.png +0 -0
- package/.references/pi/packages/coding-agent/docs/images/exy.png +0 -0
- package/.references/pi/packages/coding-agent/docs/images/interactive-mode.png +0 -0
- package/.references/pi/packages/coding-agent/docs/images/tree-view.png +0 -0
- package/.references/pi/packages/coding-agent/docs/index.md +82 -0
- package/.references/pi/packages/coding-agent/docs/json.md +82 -0
- package/.references/pi/packages/coding-agent/docs/keybindings.md +198 -0
- package/.references/pi/packages/coding-agent/docs/models.md +540 -0
- package/.references/pi/packages/coding-agent/docs/packages.md +228 -0
- package/.references/pi/packages/coding-agent/docs/prompt-templates.md +95 -0
- package/.references/pi/packages/coding-agent/docs/providers.md +290 -0
- package/.references/pi/packages/coding-agent/docs/quickstart.md +165 -0
- package/.references/pi/packages/coding-agent/docs/rpc.md +1480 -0
- package/.references/pi/packages/coding-agent/docs/sdk.md +1183 -0
- package/.references/pi/packages/coding-agent/docs/security.md +59 -0
- package/.references/pi/packages/coding-agent/docs/session-format.md +422 -0
- package/.references/pi/packages/coding-agent/docs/sessions.md +145 -0
- package/.references/pi/packages/coding-agent/docs/settings.md +319 -0
- package/.references/pi/packages/coding-agent/docs/shell-aliases.md +13 -0
- package/.references/pi/packages/coding-agent/docs/skills.md +231 -0
- package/.references/pi/packages/coding-agent/docs/terminal-setup.md +142 -0
- package/.references/pi/packages/coding-agent/docs/termux.md +127 -0
- package/.references/pi/packages/coding-agent/docs/themes.md +297 -0
- package/.references/pi/packages/coding-agent/docs/tmux.md +63 -0
- package/.references/pi/packages/coding-agent/docs/tui.md +927 -0
- package/.references/pi/packages/coding-agent/docs/usage.md +310 -0
- package/.references/pi/packages/coding-agent/docs/windows.md +17 -0
- package/.references/pi/packages/coding-agent/examples/README.md +25 -0
- package/.references/pi/packages/coding-agent/examples/extensions/README.md +213 -0
- package/.references/pi/packages/coding-agent/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/.references/pi/packages/coding-agent/examples/extensions/bash-spawn-hook.ts +30 -0
- package/.references/pi/packages/coding-agent/examples/extensions/bookmark.ts +50 -0
- package/.references/pi/packages/coding-agent/examples/extensions/border-status-editor.ts +150 -0
- package/.references/pi/packages/coding-agent/examples/extensions/built-in-tool-renderer.ts +249 -0
- package/.references/pi/packages/coding-agent/examples/extensions/claude-rules.ts +86 -0
- package/.references/pi/packages/coding-agent/examples/extensions/commands.ts +72 -0
- package/.references/pi/packages/coding-agent/examples/extensions/confirm-destructive.ts +59 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-compaction.ts +128 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-footer.ts +64 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-header.ts +73 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-provider-gitlab-duo/index.ts +404 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/.references/pi/packages/coding-agent/examples/extensions/dirty-repo-guard.ts +56 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/README.md +46 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/index.ts +74 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/.references/pi/packages/coding-agent/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/.references/pi/packages/coding-agent/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/.references/pi/packages/coding-agent/examples/extensions/dynamic-resources/index.ts +15 -0
- package/.references/pi/packages/coding-agent/examples/extensions/dynamic-tools.ts +74 -0
- package/.references/pi/packages/coding-agent/examples/extensions/entry-renderer.ts +41 -0
- package/.references/pi/packages/coding-agent/examples/extensions/event-bus.ts +43 -0
- package/.references/pi/packages/coding-agent/examples/extensions/file-trigger.ts +41 -0
- package/.references/pi/packages/coding-agent/examples/extensions/git-checkpoint.ts +53 -0
- package/.references/pi/packages/coding-agent/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/.references/pi/packages/coding-agent/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/.references/pi/packages/coding-agent/examples/extensions/gondolin/index.ts +531 -0
- package/.references/pi/packages/coding-agent/examples/extensions/gondolin/package-lock.json +185 -0
- package/.references/pi/packages/coding-agent/examples/extensions/gondolin/package.json +19 -0
- package/.references/pi/packages/coding-agent/examples/extensions/handoff.ts +191 -0
- package/.references/pi/packages/coding-agent/examples/extensions/hello.ts +26 -0
- package/.references/pi/packages/coding-agent/examples/extensions/hidden-thinking-label.ts +53 -0
- package/.references/pi/packages/coding-agent/examples/extensions/inline-bash.ts +94 -0
- package/.references/pi/packages/coding-agent/examples/extensions/input-transform-streaming.ts +39 -0
- package/.references/pi/packages/coding-agent/examples/extensions/input-transform.ts +43 -0
- package/.references/pi/packages/coding-agent/examples/extensions/interactive-shell.ts +196 -0
- package/.references/pi/packages/coding-agent/examples/extensions/kimi-deferred-tools.ts +61 -0
- package/.references/pi/packages/coding-agent/examples/extensions/mac-system-theme.ts +47 -0
- package/.references/pi/packages/coding-agent/examples/extensions/message-renderer.ts +59 -0
- package/.references/pi/packages/coding-agent/examples/extensions/minimal-mode.ts +426 -0
- package/.references/pi/packages/coding-agent/examples/extensions/modal-editor.ts +85 -0
- package/.references/pi/packages/coding-agent/examples/extensions/model-status.ts +31 -0
- package/.references/pi/packages/coding-agent/examples/extensions/notify.ts +55 -0
- package/.references/pi/packages/coding-agent/examples/extensions/overlay-qa-tests.ts +1450 -0
- package/.references/pi/packages/coding-agent/examples/extensions/overlay-test.ts +153 -0
- package/.references/pi/packages/coding-agent/examples/extensions/permission-gate.ts +34 -0
- package/.references/pi/packages/coding-agent/examples/extensions/pirate.ts +47 -0
- package/.references/pi/packages/coding-agent/examples/extensions/plan-mode/README.md +66 -0
- package/.references/pi/packages/coding-agent/examples/extensions/plan-mode/index.ts +390 -0
- package/.references/pi/packages/coding-agent/examples/extensions/plan-mode/utils.ts +168 -0
- package/.references/pi/packages/coding-agent/examples/extensions/preset.ts +436 -0
- package/.references/pi/packages/coding-agent/examples/extensions/project-trust.ts +64 -0
- package/.references/pi/packages/coding-agent/examples/extensions/prompt-customizer.ts +97 -0
- package/.references/pi/packages/coding-agent/examples/extensions/protected-paths.ts +30 -0
- package/.references/pi/packages/coding-agent/examples/extensions/provider-payload.ts +18 -0
- package/.references/pi/packages/coding-agent/examples/extensions/qna.ts +122 -0
- package/.references/pi/packages/coding-agent/examples/extensions/question.ts +286 -0
- package/.references/pi/packages/coding-agent/examples/extensions/questionnaire.ts +448 -0
- package/.references/pi/packages/coding-agent/examples/extensions/rainbow-editor.ts +88 -0
- package/.references/pi/packages/coding-agent/examples/extensions/reload-runtime.ts +37 -0
- package/.references/pi/packages/coding-agent/examples/extensions/rpc-demo.ts +118 -0
- package/.references/pi/packages/coding-agent/examples/extensions/sandbox/index.ts +321 -0
- package/.references/pi/packages/coding-agent/examples/extensions/sandbox/package-lock.json +92 -0
- package/.references/pi/packages/coding-agent/examples/extensions/sandbox/package.json +19 -0
- package/.references/pi/packages/coding-agent/examples/extensions/send-user-message.ts +97 -0
- package/.references/pi/packages/coding-agent/examples/extensions/session-name.ts +27 -0
- package/.references/pi/packages/coding-agent/examples/extensions/shutdown-command.ts +63 -0
- package/.references/pi/packages/coding-agent/examples/extensions/snake.ts +343 -0
- package/.references/pi/packages/coding-agent/examples/extensions/space-invaders.ts +560 -0
- package/.references/pi/packages/coding-agent/examples/extensions/ssh.ts +220 -0
- package/.references/pi/packages/coding-agent/examples/extensions/status-line.ts +32 -0
- package/.references/pi/packages/coding-agent/examples/extensions/structured-output.ts +65 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/README.md +175 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/agents/planner.md +37 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/agents/scout.md +50 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/agents/worker.md +24 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/agents.ts +126 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/index.ts +1015 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/prompts/implement.md +10 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/.references/pi/packages/coding-agent/examples/extensions/summarize.ts +207 -0
- package/.references/pi/packages/coding-agent/examples/extensions/system-prompt-header.ts +17 -0
- package/.references/pi/packages/coding-agent/examples/extensions/tic-tac-toe.ts +1008 -0
- package/.references/pi/packages/coding-agent/examples/extensions/timed-confirm.ts +70 -0
- package/.references/pi/packages/coding-agent/examples/extensions/titlebar-spinner.ts +58 -0
- package/.references/pi/packages/coding-agent/examples/extensions/todo.ts +297 -0
- package/.references/pi/packages/coding-agent/examples/extensions/tool-override.ts +144 -0
- package/.references/pi/packages/coding-agent/examples/extensions/tools.ts +146 -0
- package/.references/pi/packages/coding-agent/examples/extensions/trigger-compact.ts +50 -0
- package/.references/pi/packages/coding-agent/examples/extensions/truncated-tool.ts +195 -0
- package/.references/pi/packages/coding-agent/examples/extensions/widget-placement.ts +9 -0
- package/.references/pi/packages/coding-agent/examples/extensions/with-deps/index.ts +32 -0
- package/.references/pi/packages/coding-agent/examples/extensions/with-deps/package-lock.json +31 -0
- package/.references/pi/packages/coding-agent/examples/extensions/with-deps/package.json +22 -0
- package/.references/pi/packages/coding-agent/examples/extensions/working-indicator.ts +123 -0
- package/.references/pi/packages/coding-agent/examples/extensions/working-message-test.ts +25 -0
- package/.references/pi/packages/coding-agent/examples/rpc-extension-ui.ts +632 -0
- package/.references/pi/packages/coding-agent/examples/sdk/01-minimal.ts +26 -0
- package/.references/pi/packages/coding-agent/examples/sdk/02-custom-model.ts +50 -0
- package/.references/pi/packages/coding-agent/examples/sdk/03-custom-prompt.ts +75 -0
- package/.references/pi/packages/coding-agent/examples/sdk/04-skills.ts +55 -0
- package/.references/pi/packages/coding-agent/examples/sdk/05-tools.ts +48 -0
- package/.references/pi/packages/coding-agent/examples/sdk/06-extensions.ts +99 -0
- package/.references/pi/packages/coding-agent/examples/sdk/07-context-files.ts +47 -0
- package/.references/pi/packages/coding-agent/examples/sdk/08-prompt-templates.ts +51 -0
- package/.references/pi/packages/coding-agent/examples/sdk/09-api-keys-and-oauth.ts +34 -0
- package/.references/pi/packages/coding-agent/examples/sdk/10-settings.ts +53 -0
- package/.references/pi/packages/coding-agent/examples/sdk/11-sessions.ts +52 -0
- package/.references/pi/packages/coding-agent/examples/sdk/12-full-control.ts +72 -0
- package/.references/pi/packages/coding-agent/examples/sdk/13-session-runtime.ts +67 -0
- package/.references/pi/packages/coding-agent/examples/sdk/README.md +140 -0
- package/.references/pi/packages/coding-agent/install-lock/package-lock.json +1849 -0
- package/.references/pi/packages/coding-agent/install-lock/package.json +18 -0
- package/.references/pi/packages/coding-agent/npm-shrinkwrap.json +1839 -0
- package/.references/pi/packages/coding-agent/package.json +100 -0
- package/.references/pi/packages/coding-agent/scripts/migrate-sessions.sh +93 -0
- package/.references/pi/packages/coding-agent/src/bun/cli.ts +15 -0
- package/.references/pi/packages/coding-agent/src/bun/register-bedrock.ts +4 -0
- package/.references/pi/packages/coding-agent/src/bun/restore-sandbox-env.ts +36 -0
- package/.references/pi/packages/coding-agent/src/cli/args.ts +390 -0
- package/.references/pi/packages/coding-agent/src/cli/config-selector.ts +56 -0
- package/.references/pi/packages/coding-agent/src/cli/file-processor.ts +87 -0
- package/.references/pi/packages/coding-agent/src/cli/initial-message.ts +43 -0
- package/.references/pi/packages/coding-agent/src/cli/list-models.ts +111 -0
- package/.references/pi/packages/coding-agent/src/cli/project-trust.ts +62 -0
- package/.references/pi/packages/coding-agent/src/cli/session-picker.ts +55 -0
- package/.references/pi/packages/coding-agent/src/cli/startup-ui.ts +239 -0
- package/.references/pi/packages/coding-agent/src/cli.ts +20 -0
- package/.references/pi/packages/coding-agent/src/config.ts +566 -0
- package/.references/pi/packages/coding-agent/src/core/agent-session-runtime.ts +438 -0
- package/.references/pi/packages/coding-agent/src/core/agent-session-services.ts +207 -0
- package/.references/pi/packages/coding-agent/src/core/agent-session.ts +3279 -0
- package/.references/pi/packages/coding-agent/src/core/auth-guidance.ts +25 -0
- package/.references/pi/packages/coding-agent/src/core/auth-storage.ts +271 -0
- package/.references/pi/packages/coding-agent/src/core/bash-executor.ts +156 -0
- package/.references/pi/packages/coding-agent/src/core/cache-stats.ts +164 -0
- package/.references/pi/packages/coding-agent/src/core/compaction/branch-summarization.ts +371 -0
- package/.references/pi/packages/coding-agent/src/core/compaction/compaction.ts +872 -0
- package/.references/pi/packages/coding-agent/src/core/compaction/index.ts +7 -0
- package/.references/pi/packages/coding-agent/src/core/compaction/utils.ts +170 -0
- package/.references/pi/packages/coding-agent/src/core/defaults.ts +3 -0
- package/.references/pi/packages/coding-agent/src/core/diagnostics.ts +15 -0
- package/.references/pi/packages/coding-agent/src/core/event-bus.ts +33 -0
- package/.references/pi/packages/coding-agent/src/core/exec.ts +107 -0
- package/.references/pi/packages/coding-agent/src/core/experimental.ts +3 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/ansi-to-html.ts +258 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/index.ts +316 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/template.css +1066 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/template.html +55 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/template.js +1864 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/tool-renderer.ts +172 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/vendor/highlight.min.js +1213 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/vendor/marked.min.js +78 -0
- package/.references/pi/packages/coding-agent/src/core/extensions/index.ts +184 -0
- package/.references/pi/packages/coding-agent/src/core/extensions/loader.ts +708 -0
- package/.references/pi/packages/coding-agent/src/core/extensions/runner.ts +1189 -0
- package/.references/pi/packages/coding-agent/src/core/extensions/types.ts +1674 -0
- package/.references/pi/packages/coding-agent/src/core/extensions/wrapper.ts +45 -0
- package/.references/pi/packages/coding-agent/src/core/footer-data-provider.ts +388 -0
- package/.references/pi/packages/coding-agent/src/core/http-dispatcher.ts +106 -0
- package/.references/pi/packages/coding-agent/src/core/index.ts +80 -0
- package/.references/pi/packages/coding-agent/src/core/keybindings.ts +370 -0
- package/.references/pi/packages/coding-agent/src/core/messages.ts +195 -0
- package/.references/pi/packages/coding-agent/src/core/model-config.ts +287 -0
- package/.references/pi/packages/coding-agent/src/core/model-registry.ts +126 -0
- package/.references/pi/packages/coding-agent/src/core/model-resolver.ts +705 -0
- package/.references/pi/packages/coding-agent/src/core/model-runtime.ts +566 -0
- package/.references/pi/packages/coding-agent/src/core/models-store.ts +57 -0
- package/.references/pi/packages/coding-agent/src/core/output-guard.ts +108 -0
- package/.references/pi/packages/coding-agent/src/core/package-manager.ts +2650 -0
- package/.references/pi/packages/coding-agent/src/core/project-trust.ts +96 -0
- package/.references/pi/packages/coding-agent/src/core/prompt-templates.ts +284 -0
- package/.references/pi/packages/coding-agent/src/core/provider-attribution.ts +97 -0
- package/.references/pi/packages/coding-agent/src/core/provider-composer.ts +548 -0
- package/.references/pi/packages/coding-agent/src/core/radius.ts +1 -0
- package/.references/pi/packages/coding-agent/src/core/remote-catalog-provider.ts +83 -0
- package/.references/pi/packages/coding-agent/src/core/resolve-config-value.ts +287 -0
- package/.references/pi/packages/coding-agent/src/core/resource-loader.ts +1039 -0
- package/.references/pi/packages/coding-agent/src/core/runtime-credentials.ts +48 -0
- package/.references/pi/packages/coding-agent/src/core/sdk.ts +393 -0
- package/.references/pi/packages/coding-agent/src/core/session-cwd.ts +59 -0
- package/.references/pi/packages/coding-agent/src/core/session-manager.ts +1623 -0
- package/.references/pi/packages/coding-agent/src/core/settings-manager.ts +1234 -0
- package/.references/pi/packages/coding-agent/src/core/skills.ts +487 -0
- package/.references/pi/packages/coding-agent/src/core/slash-commands.ts +42 -0
- package/.references/pi/packages/coding-agent/src/core/source-info.ts +40 -0
- package/.references/pi/packages/coding-agent/src/core/system-prompt.ts +162 -0
- package/.references/pi/packages/coding-agent/src/core/telemetry.ts +13 -0
- package/.references/pi/packages/coding-agent/src/core/timings.ts +50 -0
- package/.references/pi/packages/coding-agent/src/core/tools/bash.ts +470 -0
- package/.references/pi/packages/coding-agent/src/core/tools/edit-diff.ts +560 -0
- package/.references/pi/packages/coding-agent/src/core/tools/edit.ts +437 -0
- package/.references/pi/packages/coding-agent/src/core/tools/file-mutation-queue.ts +61 -0
- package/.references/pi/packages/coding-agent/src/core/tools/find.ts +374 -0
- package/.references/pi/packages/coding-agent/src/core/tools/grep.ts +385 -0
- package/.references/pi/packages/coding-agent/src/core/tools/index.ts +196 -0
- package/.references/pi/packages/coding-agent/src/core/tools/ls.ts +225 -0
- package/.references/pi/packages/coding-agent/src/core/tools/output-accumulator.ts +222 -0
- package/.references/pi/packages/coding-agent/src/core/tools/path-utils.ts +118 -0
- package/.references/pi/packages/coding-agent/src/core/tools/read.ts +351 -0
- package/.references/pi/packages/coding-agent/src/core/tools/render-utils.ts +85 -0
- package/.references/pi/packages/coding-agent/src/core/tools/tool-definition-wrapper.ts +45 -0
- package/.references/pi/packages/coding-agent/src/core/tools/truncate.ts +276 -0
- package/.references/pi/packages/coding-agent/src/core/tools/write.ts +267 -0
- package/.references/pi/packages/coding-agent/src/core/trust-manager.ts +244 -0
- package/.references/pi/packages/coding-agent/src/index.ts +394 -0
- package/.references/pi/packages/coding-agent/src/main.ts +857 -0
- package/.references/pi/packages/coding-agent/src/migrations.ts +315 -0
- package/.references/pi/packages/coding-agent/src/modes/index.ts +15 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/assets/clankolas.png +0 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/armin.ts +382 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/assistant-message.ts +180 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/bash-execution.ts +220 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/bordered-loader.ts +68 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/branch-summary-message.ts +58 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/compaction-summary-message.ts +59 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/config-selector.ts +942 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/countdown-timer.ts +39 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/custom-editor.ts +80 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/custom-entry.ts +62 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/custom-message.ts +99 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/daxnuts.ts +164 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/diff.ts +147 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/dynamic-border.ts +25 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/earendil-announcement.ts +53 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/extension-editor.ts +167 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/extension-input.ts +87 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/extension-selector.ts +112 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/first-time-setup.ts +145 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/footer.ts +245 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/index.ts +38 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/keybinding-hints.ts +48 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/login-dialog.ts +233 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/model-selector.ts +361 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/oauth-selector.ts +214 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/scoped-models-selector.ts +360 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/session-selector-search.ts +194 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/session-selector.ts +1031 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/settings-selector.ts +838 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/show-images-selector.ts +50 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/skill-invocation-message.ts +55 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/status-indicator.ts +114 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/theme-selector.ts +67 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/thinking-selector.ts +75 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/tool-execution.ts +377 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/tree-selector.ts +1427 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/trust-selector.ts +134 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/user-message-selector.ts +155 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/user-message.ts +57 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/visual-truncate.ts +50 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/interactive-mode.ts +6005 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/model-search.ts +21 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/theme/dark.json +87 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/theme/light.json +86 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/theme/theme-controller.ts +126 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/theme/theme-schema.json +340 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/theme/theme.ts +1294 -0
- package/.references/pi/packages/coding-agent/src/modes/print-mode.ts +159 -0
- package/.references/pi/packages/coding-agent/src/modes/rpc/jsonl.ts +58 -0
- package/.references/pi/packages/coding-agent/src/modes/rpc/rpc-client.ts +592 -0
- package/.references/pi/packages/coding-agent/src/modes/rpc/rpc-mode.ts +795 -0
- package/.references/pi/packages/coding-agent/src/modes/rpc/rpc-types.ts +281 -0
- package/.references/pi/packages/coding-agent/src/package-manager-cli.ts +887 -0
- package/.references/pi/packages/coding-agent/src/rpc-entry.ts +12 -0
- package/.references/pi/packages/coding-agent/src/utils/ansi.ts +60 -0
- package/.references/pi/packages/coding-agent/src/utils/changelog.ts +196 -0
- package/.references/pi/packages/coding-agent/src/utils/child-process.ts +137 -0
- package/.references/pi/packages/coding-agent/src/utils/clipboard-image.ts +300 -0
- package/.references/pi/packages/coding-agent/src/utils/clipboard-native.ts +33 -0
- package/.references/pi/packages/coding-agent/src/utils/clipboard.ts +141 -0
- package/.references/pi/packages/coding-agent/src/utils/deprecation.ts +14 -0
- package/.references/pi/packages/coding-agent/src/utils/exif-orientation.ts +183 -0
- package/.references/pi/packages/coding-agent/src/utils/frontmatter.ts +39 -0
- package/.references/pi/packages/coding-agent/src/utils/fs-watch.ts +30 -0
- package/.references/pi/packages/coding-agent/src/utils/git.ts +226 -0
- package/.references/pi/packages/coding-agent/src/utils/highlight-js-lib-index.d.ts +19 -0
- package/.references/pi/packages/coding-agent/src/utils/html.ts +51 -0
- package/.references/pi/packages/coding-agent/src/utils/image-convert.ts +49 -0
- package/.references/pi/packages/coding-agent/src/utils/image-process.ts +119 -0
- package/.references/pi/packages/coding-agent/src/utils/image-resize-core.ts +164 -0
- package/.references/pi/packages/coding-agent/src/utils/image-resize-worker.ts +42 -0
- package/.references/pi/packages/coding-agent/src/utils/image-resize.ts +123 -0
- package/.references/pi/packages/coding-agent/src/utils/json.ts +6 -0
- package/.references/pi/packages/coding-agent/src/utils/mime.ts +116 -0
- package/.references/pi/packages/coding-agent/src/utils/open-browser.ts +24 -0
- package/.references/pi/packages/coding-agent/src/utils/paths.ts +118 -0
- package/.references/pi/packages/coding-agent/src/utils/photon.ts +139 -0
- package/.references/pi/packages/coding-agent/src/utils/pi-user-agent.ts +4 -0
- package/.references/pi/packages/coding-agent/src/utils/shell.ts +225 -0
- package/.references/pi/packages/coding-agent/src/utils/sleep.ts +18 -0
- package/.references/pi/packages/coding-agent/src/utils/syntax-highlight.ts +146 -0
- package/.references/pi/packages/coding-agent/src/utils/tools-manager.ts +369 -0
- package/.references/pi/packages/coding-agent/src/utils/version-check.ts +80 -0
- package/.references/pi/packages/coding-agent/src/utils/windows-self-update.ts +84 -0
- package/.references/pi/packages/coding-agent/test/agent-session-auto-compaction-queue.test.ts +450 -0
- package/.references/pi/packages/coding-agent/test/agent-session-branching.test.ts +156 -0
- package/.references/pi/packages/coding-agent/test/agent-session-compaction.test.ts +208 -0
- package/.references/pi/packages/coding-agent/test/agent-session-concurrent.test.ts +629 -0
- package/.references/pi/packages/coding-agent/test/agent-session-dynamic-provider.test.ts +122 -0
- package/.references/pi/packages/coding-agent/test/agent-session-dynamic-tools.test.ts +185 -0
- package/.references/pi/packages/coding-agent/test/agent-session-retry.test.ts +322 -0
- package/.references/pi/packages/coding-agent/test/agent-session-runtime-events.test.ts +257 -0
- package/.references/pi/packages/coding-agent/test/agent-session-stats.test.ts +169 -0
- package/.references/pi/packages/coding-agent/test/agent-session-tree-navigation.test.ts +323 -0
- package/.references/pi/packages/coding-agent/test/ansi-utils.test.ts +110 -0
- package/.references/pi/packages/coding-agent/test/args.test.ts +441 -0
- package/.references/pi/packages/coding-agent/test/assistant-message.test.ts +130 -0
- package/.references/pi/packages/coding-agent/test/auth-storage.test.ts +217 -0
- package/.references/pi/packages/coding-agent/test/bash-close-hang-windows.test.ts +126 -0
- package/.references/pi/packages/coding-agent/test/bash-execution-width.test.ts +80 -0
- package/.references/pi/packages/coding-agent/test/block-images.test.ts +148 -0
- package/.references/pi/packages/coding-agent/test/cache-stats.test.ts +143 -0
- package/.references/pi/packages/coding-agent/test/changelog.test.ts +49 -0
- package/.references/pi/packages/coding-agent/test/clipboard-image-bmp-conversion.test.ts +88 -0
- package/.references/pi/packages/coding-agent/test/clipboard-image.test.ts +184 -0
- package/.references/pi/packages/coding-agent/test/clipboard-native.test.ts +32 -0
- package/.references/pi/packages/coding-agent/test/clipboard.test.ts +166 -0
- package/.references/pi/packages/coding-agent/test/compaction-extensions-example.test.ts +66 -0
- package/.references/pi/packages/coding-agent/test/compaction-extensions.test.ts +415 -0
- package/.references/pi/packages/coding-agent/test/compaction-serialization.test.ts +79 -0
- package/.references/pi/packages/coding-agent/test/compaction-summary-reasoning.test.ts +134 -0
- package/.references/pi/packages/coding-agent/test/compaction.test.ts +596 -0
- package/.references/pi/packages/coding-agent/test/config-value-migration.test.ts +178 -0
- package/.references/pi/packages/coding-agent/test/config.test.ts +437 -0
- package/.references/pi/packages/coding-agent/test/edit-tool-legacy-input.test.ts +116 -0
- package/.references/pi/packages/coding-agent/test/edit-tool-no-full-redraw.test.ts +235 -0
- package/.references/pi/packages/coding-agent/test/experimental.test.ts +44 -0
- package/.references/pi/packages/coding-agent/test/export-html-skill-block.test.ts +40 -0
- package/.references/pi/packages/coding-agent/test/export-html-whitespace.test.ts +42 -0
- package/.references/pi/packages/coding-agent/test/export-html-xss.test.ts +67 -0
- package/.references/pi/packages/coding-agent/test/extensions-discovery.test.ts +528 -0
- package/.references/pi/packages/coding-agent/test/extensions-input-event.test.ts +125 -0
- package/.references/pi/packages/coding-agent/test/extensions-runner.test.ts +986 -0
- package/.references/pi/packages/coding-agent/test/file-mutation-queue.test.ts +274 -0
- package/.references/pi/packages/coding-agent/test/first-time-setup-fork.test.ts +39 -0
- package/.references/pi/packages/coding-agent/test/first-time-setup.test.ts +95 -0
- package/.references/pi/packages/coding-agent/test/fixtures/assistant-message-with-thinking-code.json +33 -0
- package/.references/pi/packages/coding-agent/test/fixtures/before-compaction.jsonl +1003 -0
- package/.references/pi/packages/coding-agent/test/fixtures/empty-agent/.gitkeep +0 -0
- package/.references/pi/packages/coding-agent/test/fixtures/empty-cwd/.gitkeep +0 -0
- package/.references/pi/packages/coding-agent/test/fixtures/large-session.jsonl +1019 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/consecutive-hyphens/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/disable-model-invocation/SKILL.md +9 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/invalid-name-chars/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/invalid-yaml/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/long-name/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/missing-description/SKILL.md +7 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/multiline-description/SKILL.md +11 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/name-mismatch/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/nested/child-skill/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/no-frontmatter/SKILL.md +3 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/root-skill-preferred/SKILL.md +3 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/root-skill-preferred/nested-child/SKILL.md +3 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/unknown-field/SKILL.md +10 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/valid-skill/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills-collision/first/calendar/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills-collision/second/calendar/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/footer-data-provider.test.ts +265 -0
- package/.references/pi/packages/coding-agent/test/footer-width.test.ts +144 -0
- package/.references/pi/packages/coding-agent/test/format-resume-command.test.ts +135 -0
- package/.references/pi/packages/coding-agent/test/frontmatter.test.ts +60 -0
- package/.references/pi/packages/coding-agent/test/git-merge-and-resolve-extension.test.ts +206 -0
- package/.references/pi/packages/coding-agent/test/git-ssh-url.test.ts +91 -0
- package/.references/pi/packages/coding-agent/test/git-update.test.ts +484 -0
- package/.references/pi/packages/coding-agent/test/http-dispatcher.test.ts +53 -0
- package/.references/pi/packages/coding-agent/test/image-process.test.ts +53 -0
- package/.references/pi/packages/coding-agent/test/image-processing.test.ts +170 -0
- package/.references/pi/packages/coding-agent/test/image-resize-callers.test.ts +53 -0
- package/.references/pi/packages/coding-agent/test/initial-message.test.ts +48 -0
- package/.references/pi/packages/coding-agent/test/input-transform-streaming-example.test.ts +84 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-anthropic-warning.test.ts +89 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-clone-command.test.ts +72 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-compaction.test.ts +85 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-import-command.test.ts +143 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-startup-input.test.ts +72 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-status.test.ts +1123 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-suspend.test.ts +149 -0
- package/.references/pi/packages/coding-agent/test/keybindings-migration.test.ts +88 -0
- package/.references/pi/packages/coding-agent/test/max-thinking.test.ts +45 -0
- package/.references/pi/packages/coding-agent/test/model-registry.test.ts +1934 -0
- package/.references/pi/packages/coding-agent/test/model-resolver.test.ts +690 -0
- package/.references/pi/packages/coding-agent/test/model-runtime-auth-options.test.ts +256 -0
- package/.references/pi/packages/coding-agent/test/model-runtime-cloudflare-compat.test.ts +95 -0
- package/.references/pi/packages/coding-agent/test/model-runtime-modify-models-compat.test.ts +85 -0
- package/.references/pi/packages/coding-agent/test/model-runtime-test-utils.ts +25 -0
- package/.references/pi/packages/coding-agent/test/models-store.test.ts +51 -0
- package/.references/pi/packages/coding-agent/test/oauth-selector.test.ts +147 -0
- package/.references/pi/packages/coding-agent/test/package-command-paths.test.ts +746 -0
- package/.references/pi/packages/coding-agent/test/package-manager-ssh.test.ts +97 -0
- package/.references/pi/packages/coding-agent/test/package-manager.test.ts +2512 -0
- package/.references/pi/packages/coding-agent/test/path-utils.test.ts +174 -0
- package/.references/pi/packages/coding-agent/test/paths.test.ts +150 -0
- package/.references/pi/packages/coding-agent/test/pi-user-agent.test.ts +12 -0
- package/.references/pi/packages/coding-agent/test/plan-mode-extension.test.ts +167 -0
- package/.references/pi/packages/coding-agent/test/plan-mode-utils.test.ts +261 -0
- package/.references/pi/packages/coding-agent/test/print-mode.test.ts +142 -0
- package/.references/pi/packages/coding-agent/test/prompt-templates.test.ts +615 -0
- package/.references/pi/packages/coding-agent/test/radius.test.ts +151 -0
- package/.references/pi/packages/coding-agent/test/remote-catalog-provider.test.ts +118 -0
- package/.references/pi/packages/coding-agent/test/resolve-config-value.test.ts +121 -0
- package/.references/pi/packages/coding-agent/test/resource-loader.test.ts +739 -0
- package/.references/pi/packages/coding-agent/test/restore-sandbox-env.test.ts +77 -0
- package/.references/pi/packages/coding-agent/test/rpc-client-clone.test.ts +29 -0
- package/.references/pi/packages/coding-agent/test/rpc-client-process-exit.test.ts +38 -0
- package/.references/pi/packages/coding-agent/test/rpc-example.ts +86 -0
- package/.references/pi/packages/coding-agent/test/rpc-jsonl.test.ts +65 -0
- package/.references/pi/packages/coding-agent/test/rpc-prompt-response-semantics.test.ts +288 -0
- package/.references/pi/packages/coding-agent/test/rpc.test.ts +377 -0
- package/.references/pi/packages/coding-agent/test/runtime-credentials.test.ts +42 -0
- package/.references/pi/packages/coding-agent/test/sdk-codex-cache-probe-tool-loop.ts +497 -0
- package/.references/pi/packages/coding-agent/test/sdk-openrouter-attribution.test.ts +266 -0
- package/.references/pi/packages/coding-agent/test/sdk-session-manager.test.ts +95 -0
- package/.references/pi/packages/coding-agent/test/sdk-skills.test.ts +109 -0
- package/.references/pi/packages/coding-agent/test/sdk-stream-options.test.ts +188 -0
- package/.references/pi/packages/coding-agent/test/session-cwd.test.ts +91 -0
- package/.references/pi/packages/coding-agent/test/session-file-invalid.test.ts +65 -0
- package/.references/pi/packages/coding-agent/test/session-id-readonly.test.ts +190 -0
- package/.references/pi/packages/coding-agent/test/session-info-modified-timestamp.test.ts +83 -0
- package/.references/pi/packages/coding-agent/test/session-manager/build-context.test.ts +305 -0
- package/.references/pi/packages/coding-agent/test/session-manager/custom-session-id.test.ts +169 -0
- package/.references/pi/packages/coding-agent/test/session-manager/file-operations.test.ts +315 -0
- package/.references/pi/packages/coding-agent/test/session-manager/labels.test.ts +211 -0
- package/.references/pi/packages/coding-agent/test/session-manager/migration.test.ts +78 -0
- package/.references/pi/packages/coding-agent/test/session-manager/save-entry.test.ts +55 -0
- package/.references/pi/packages/coding-agent/test/session-manager/tree-traversal.test.ts +533 -0
- package/.references/pi/packages/coding-agent/test/session-selector-path-delete.test.ts +354 -0
- package/.references/pi/packages/coding-agent/test/session-selector-rename.test.ts +111 -0
- package/.references/pi/packages/coding-agent/test/session-selector-search.test.ts +195 -0
- package/.references/pi/packages/coding-agent/test/settings-manager-bug.test.ts +147 -0
- package/.references/pi/packages/coding-agent/test/settings-manager.test.ts +511 -0
- package/.references/pi/packages/coding-agent/test/skills.test.ts +432 -0
- package/.references/pi/packages/coding-agent/test/startup-session-name.test.ts +135 -0
- package/.references/pi/packages/coding-agent/test/status-indicator.test.ts +32 -0
- package/.references/pi/packages/coding-agent/test/stdout-cleanliness.test.ts +128 -0
- package/.references/pi/packages/coding-agent/test/streaming-render-debug.ts +97 -0
- package/.references/pi/packages/coding-agent/test/suite/README.md +16 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-bash-persistence.test.ts +242 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-compaction.test.ts +446 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-model-extension.test.ts +373 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-prompt.test.ts +398 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-queue.test.ts +445 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-retry-events.test.ts +364 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-runtime.test.ts +609 -0
- package/.references/pi/packages/coding-agent/test/suite/harness.ts +219 -0
- package/.references/pi/packages/coding-agent/test/suite/lax-message-content.test.ts +162 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/1717-2113-agent-session-event-settlement.test.ts +95 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/2023-queued-slash-command-followup.test.ts +80 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/2753-reload-stale-resource-settings.test.ts +105 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/2781-skill-collision-precedence.test.ts +120 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/2791-fswatch-error-crash.test.ts +106 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/2835-tools-allowlist-filters-extension-tools.test.ts +94 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/2860-replaced-session-context.test.ts +279 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3217-scoped-model-order.test.ts +104 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3302-find-path-glob.test.ts +72 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3303-find-nested-gitignore.test.ts +83 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3317-network-connection-lost-retry.test.ts +33 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3592-no-builtin-tools-keeps-extension-tools.test.ts +119 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3616-settings-inmemory-reload.test.ts +86 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3686-session-name-event.test.ts +61 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3688-tree-cancel-compacting.test.ts +36 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3982-message-end-cost-override.test.ts +56 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/4167-thinking-toggle-pending-tool-render.test.ts +182 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5080-signal-shutdown-extension-cleanup.test.ts +185 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5109-exclude-tools.test.ts +81 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5208-late-bash-output.test.ts +29 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5217-compaction-reason.test.ts +95 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5303-bash-output-truncation.test.ts +79 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5433-extension-oauth-prompt-input.test.ts +119 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5596-missing-theme-export.test.ts +89 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5661-uppercase-header-values.test.ts +91 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5724-sigterm-signal-exit.test.ts +94 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5868-rpc-unknown-command-id.test.ts +113 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5943-session-start-notify.test.ts +515 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5996-session-name-newlines.test.ts +40 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/6019-explicit-provider-retry-message.test.ts +31 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/6162-extension-active-tools-next-turn.test.ts +192 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/6260-inline-extension-naming.test.ts +99 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/6324-branch-summary-ambient-auth.test.ts +61 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/6363-agent-settled-event.test.ts +158 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/extension-factory-cache.test.ts +131 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/pre-prompt-compaction-no-continue.test.ts +75 -0
- package/.references/pi/packages/coding-agent/test/syntax-highlight.test.ts +76 -0
- package/.references/pi/packages/coding-agent/test/system-prompt.test.ts +114 -0
- package/.references/pi/packages/coding-agent/test/test-harness.test.ts +321 -0
- package/.references/pi/packages/coding-agent/test/test-harness.ts +463 -0
- package/.references/pi/packages/coding-agent/test/test-theme-colors.ts +246 -0
- package/.references/pi/packages/coding-agent/test/theme-detection.test.ts +133 -0
- package/.references/pi/packages/coding-agent/test/theme-export.test.ts +104 -0
- package/.references/pi/packages/coding-agent/test/theme-picker.test.ts +51 -0
- package/.references/pi/packages/coding-agent/test/tool-execution-component.test.ts +529 -0
- package/.references/pi/packages/coding-agent/test/tools.test.ts +1213 -0
- package/.references/pi/packages/coding-agent/test/tree-selector.test.ts +702 -0
- package/.references/pi/packages/coding-agent/test/trigger-compact-extension.test.ts +59 -0
- package/.references/pi/packages/coding-agent/test/truncate-to-width.test.ts +81 -0
- package/.references/pi/packages/coding-agent/test/trust-manager.test.ts +67 -0
- package/.references/pi/packages/coding-agent/test/trust-selector.test.ts +87 -0
- package/.references/pi/packages/coding-agent/test/user-message.test.ts +25 -0
- package/.references/pi/packages/coding-agent/test/utilities.ts +318 -0
- package/.references/pi/packages/coding-agent/test/version-check.test.ts +91 -0
- package/.references/pi/packages/coding-agent/tsconfig.build.json +17 -0
- package/.references/pi/packages/coding-agent/tsconfig.examples.json +16 -0
- package/.references/pi/packages/coding-agent/vitest.config.ts +38 -0
- package/.references/pi/packages/orchestrator/CHANGELOG.md +19 -0
- package/.references/pi/packages/orchestrator/README.md +11 -0
- package/.references/pi/packages/orchestrator/package.json +45 -0
- package/.references/pi/packages/orchestrator/src/cli.ts +161 -0
- package/.references/pi/packages/orchestrator/src/config.ts +69 -0
- package/.references/pi/packages/orchestrator/src/handler.ts +161 -0
- package/.references/pi/packages/orchestrator/src/index.ts +10 -0
- package/.references/pi/packages/orchestrator/src/ipc/client.ts +63 -0
- package/.references/pi/packages/orchestrator/src/ipc/protocol.ts +142 -0
- package/.references/pi/packages/orchestrator/src/ipc/server.ts +209 -0
- package/.references/pi/packages/orchestrator/src/radius.ts +440 -0
- package/.references/pi/packages/orchestrator/src/rpc-process.ts +201 -0
- package/.references/pi/packages/orchestrator/src/serve.ts +77 -0
- package/.references/pi/packages/orchestrator/src/storage.ts +70 -0
- package/.references/pi/packages/orchestrator/src/supervisor.ts +354 -0
- package/.references/pi/packages/orchestrator/src/types.ts +25 -0
- package/.references/pi/packages/orchestrator/tsconfig.build.json +9 -0
- package/.references/pi/packages/tui/CHANGELOG.md +1005 -0
- package/.references/pi/packages/tui/README.md +791 -0
- package/.references/pi/packages/tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
- package/.references/pi/packages/tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/.references/pi/packages/tui/native/darwin/src/darwin-modifiers.c +70 -0
- package/.references/pi/packages/tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/.references/pi/packages/tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/.references/pi/packages/tui/native/win32/src/win32-console-mode.c +53 -0
- package/.references/pi/packages/tui/package.json +47 -0
- package/.references/pi/packages/tui/src/autocomplete.ts +786 -0
- package/.references/pi/packages/tui/src/components/box.ts +137 -0
- package/.references/pi/packages/tui/src/components/cancellable-loader.ts +40 -0
- package/.references/pi/packages/tui/src/components/editor.ts +2333 -0
- package/.references/pi/packages/tui/src/components/image.ts +126 -0
- package/.references/pi/packages/tui/src/components/input.ts +447 -0
- package/.references/pi/packages/tui/src/components/loader.ts +92 -0
- package/.references/pi/packages/tui/src/components/markdown.ts +858 -0
- package/.references/pi/packages/tui/src/components/select-list.ts +229 -0
- package/.references/pi/packages/tui/src/components/settings-list.ts +250 -0
- package/.references/pi/packages/tui/src/components/spacer.ts +28 -0
- package/.references/pi/packages/tui/src/components/text.ts +106 -0
- package/.references/pi/packages/tui/src/components/truncated-text.ts +65 -0
- package/.references/pi/packages/tui/src/editor-component.ts +74 -0
- package/.references/pi/packages/tui/src/fuzzy.ts +137 -0
- package/.references/pi/packages/tui/src/index.ts +114 -0
- package/.references/pi/packages/tui/src/keybindings.ts +244 -0
- package/.references/pi/packages/tui/src/keys.ts +1401 -0
- package/.references/pi/packages/tui/src/kill-ring.ts +46 -0
- package/.references/pi/packages/tui/src/native-modifiers.ts +59 -0
- package/.references/pi/packages/tui/src/stdin-buffer.ts +434 -0
- package/.references/pi/packages/tui/src/terminal-colors.ts +73 -0
- package/.references/pi/packages/tui/src/terminal-image.ts +488 -0
- package/.references/pi/packages/tui/src/terminal.ts +531 -0
- package/.references/pi/packages/tui/src/tui.ts +1714 -0
- package/.references/pi/packages/tui/src/undo-stack.ts +28 -0
- package/.references/pi/packages/tui/src/utils.ts +1209 -0
- package/.references/pi/packages/tui/src/word-navigation.ts +117 -0
- package/.references/pi/packages/tui/test/autocomplete.test.ts +542 -0
- package/.references/pi/packages/tui/test/bug-regression-isimageline-startswith-bug.test.ts +237 -0
- package/.references/pi/packages/tui/test/chat-simple.ts +129 -0
- package/.references/pi/packages/tui/test/editor.test.ts +4051 -0
- package/.references/pi/packages/tui/test/fuzzy.test.ts +112 -0
- package/.references/pi/packages/tui/test/image-test.ts +56 -0
- package/.references/pi/packages/tui/test/input.test.ts +647 -0
- package/.references/pi/packages/tui/test/key-tester.ts +123 -0
- package/.references/pi/packages/tui/test/keybindings.test.ts +46 -0
- package/.references/pi/packages/tui/test/keys.test.ts +622 -0
- package/.references/pi/packages/tui/test/markdown.test.ts +1442 -0
- package/.references/pi/packages/tui/test/overlay-non-capturing.test.ts +1202 -0
- package/.references/pi/packages/tui/test/overlay-options.test.ts +541 -0
- package/.references/pi/packages/tui/test/overlay-short-content.test.ts +61 -0
- package/.references/pi/packages/tui/test/regression-overlay-cjk-boundary.test.ts +68 -0
- package/.references/pi/packages/tui/test/regression-regional-indicator-width.test.ts +52 -0
- package/.references/pi/packages/tui/test/select-list.test.ts +116 -0
- package/.references/pi/packages/tui/test/stdin-buffer.test.ts +458 -0
- package/.references/pi/packages/tui/test/tab-width.test.ts +87 -0
- package/.references/pi/packages/tui/test/terminal-colors.test.ts +249 -0
- package/.references/pi/packages/tui/test/terminal-image.test.ts +492 -0
- package/.references/pi/packages/tui/test/terminal.test.ts +233 -0
- package/.references/pi/packages/tui/test/test-themes.ts +38 -0
- package/.references/pi/packages/tui/test/truncate-to-width.test.ts +76 -0
- package/.references/pi/packages/tui/test/truncated-text.test.ts +129 -0
- package/.references/pi/packages/tui/test/tui-cell-size-input.test.ts +81 -0
- package/.references/pi/packages/tui/test/tui-overlay-style-leak.test.ts +80 -0
- package/.references/pi/packages/tui/test/tui-render.test.ts +767 -0
- package/.references/pi/packages/tui/test/tui-shrink.test.ts +44 -0
- package/.references/pi/packages/tui/test/viewport-overwrite-repro.ts +106 -0
- package/.references/pi/packages/tui/test/virtual-terminal.ts +218 -0
- package/.references/pi/packages/tui/test/word-navigation.test.ts +191 -0
- package/.references/pi/packages/tui/test/wrap-ansi.test.ts +266 -0
- package/.references/pi/packages/tui/tsconfig.build.json +9 -0
- package/.references/pi/packages/tui/vitest.config.ts +7 -0
- package/.references/pi/pi-test.bat +14 -0
- package/.references/pi/pi-test.ps1 +71 -0
- package/.references/pi/pi-test.sh +57 -0
- package/.references/pi/scripts/browser-smoke-entry.ts +61 -0
- package/.references/pi/scripts/build-binaries.sh +245 -0
- package/.references/pi/scripts/check-browser-smoke.mjs +36 -0
- package/.references/pi/scripts/check-lockfile-commit.mjs +120 -0
- package/.references/pi/scripts/check-pinned-deps.mjs +63 -0
- package/.references/pi/scripts/check-ts-relative-imports.mjs +74 -0
- package/.references/pi/scripts/cost.ts +183 -0
- package/.references/pi/scripts/edit-tool-stats.mjs +834 -0
- package/.references/pi/scripts/generate-coding-agent-install-lock.mjs +439 -0
- package/.references/pi/scripts/generate-coding-agent-shrinkwrap.mjs +365 -0
- package/.references/pi/scripts/local-release.mjs +284 -0
- package/.references/pi/scripts/profile-coding-agent-node.mjs +639 -0
- package/.references/pi/scripts/publish-model-catalog.mjs +295 -0
- package/.references/pi/scripts/publish.mjs +125 -0
- package/.references/pi/scripts/read-tool-stats.mjs +505 -0
- package/.references/pi/scripts/release-notes.mjs +364 -0
- package/.references/pi/scripts/release.mjs +207 -0
- package/.references/pi/scripts/repro-5893-wsl-bash.mjs +55 -0
- package/.references/pi/scripts/session-context-stats.mjs +405 -0
- package/.references/pi/scripts/session-transcripts.ts +406 -0
- package/.references/pi/scripts/stats.ts +233 -0
- package/.references/pi/scripts/sync-versions.js +96 -0
- package/.references/pi/scripts/tool-stats.ts +232 -0
- package/.references/pi/scripts/update-source-imports-to-ts.sh +10 -0
- package/.references/pi/test.sh +81 -0
- package/.references/pi/tsconfig.base.json +25 -0
- package/.references/pi/tsconfig.json +27 -0
- package/AGENTS.md +8 -0
- package/Cargo.lock +5169 -0
- package/Cargo.toml +39 -0
- package/LICENSE +21 -0
- package/README.md +43 -0
- package/aliases/pi-rusty/Cargo.toml +19 -0
- package/aliases/pi-rusty/LICENSE +21 -0
- package/aliases/pi-rusty/README.md +10 -0
- package/aliases/pi-rusty/src/main.rs +8 -0
- package/bun.lock +687 -0
- package/crates/pi/Cargo.toml +66 -0
- package/crates/pi/LICENSE +21 -0
- package/crates/pi/assets/export-html/template.css +1066 -0
- package/crates/pi/assets/export-html/template.html +55 -0
- package/crates/pi/assets/export-html/template.js +1864 -0
- package/crates/pi/assets/export-html/vendor/dark.json +29 -0
- package/crates/pi/assets/export-html/vendor/highlight.min.js +1213 -0
- package/crates/pi/assets/export-html/vendor/light.json +6 -0
- package/crates/pi/assets/export-html/vendor/marked.min.js +78 -0
- package/crates/pi/src/cli/args.rs +889 -0
- package/crates/pi/src/cli/bootstrap.rs +2134 -0
- package/crates/pi/src/cli/entry.rs +1332 -0
- package/crates/pi/src/cli/help.rs +326 -0
- package/crates/pi/src/cli/mod.rs +22 -0
- package/crates/pi/src/cli/package_manager_cli.rs +1515 -0
- package/crates/pi/src/core/agent_session/bash.rs +453 -0
- package/crates/pi/src/core/agent_session/compaction.rs +1804 -0
- package/crates/pi/src/core/agent_session/events.rs +621 -0
- package/crates/pi/src/core/agent_session/extension.rs +2146 -0
- package/crates/pi/src/core/agent_session/extension_runner.rs +471 -0
- package/crates/pi/src/core/agent_session/mod.rs +1768 -0
- package/crates/pi/src/core/agent_session/model.rs +775 -0
- package/crates/pi/src/core/agent_session/persistence.rs +265 -0
- package/crates/pi/src/core/agent_session/prompt.rs +2289 -0
- package/crates/pi/src/core/agent_session/retry.rs +448 -0
- package/crates/pi/src/core/agent_session/stats.rs +302 -0
- package/crates/pi/src/core/agent_session/subscribe.rs +450 -0
- package/crates/pi/src/core/agent_session/tools.rs +515 -0
- package/crates/pi/src/core/agent_session/tree.rs +1219 -0
- package/crates/pi/src/core/agent_session_runtime.rs +1612 -0
- package/crates/pi/src/core/agent_session_services.rs +1613 -0
- package/crates/pi/src/core/compaction/branch.rs +767 -0
- package/crates/pi/src/core/compaction/mod.rs +1955 -0
- package/crates/pi/src/core/compaction/utils.rs +357 -0
- package/crates/pi/src/core/config.rs +1102 -0
- package/crates/pi/src/core/config_value.rs +179 -0
- package/crates/pi/src/core/experimental.rs +29 -0
- package/crates/pi/src/core/export_html/ansi_to_html.rs +279 -0
- package/crates/pi/src/core/export_html/mod.rs +787 -0
- package/crates/pi/src/core/export_html/session_data.rs +149 -0
- package/crates/pi/src/core/extension_host/acquire/tests.rs +579 -0
- package/crates/pi/src/core/extension_host/acquire.rs +431 -0
- package/crates/pi/src/core/extension_host/tests.rs +2353 -0
- package/crates/pi/src/core/extension_host.rs +2541 -0
- package/crates/pi/src/core/lockfile.rs +913 -0
- package/crates/pi/src/core/messages.rs +706 -0
- package/crates/pi/src/core/migrations.rs +828 -0
- package/crates/pi/src/core/mod.rs +28 -0
- package/crates/pi/src/core/model_resolver.rs +1473 -0
- package/crates/pi/src/core/model_runtime.rs +2720 -0
- package/crates/pi/src/core/output_guard.rs +977 -0
- package/crates/pi/src/core/package_manager/tests.rs +1304 -0
- package/crates/pi/src/core/package_manager.rs +2015 -0
- package/crates/pi/src/core/platform/clipboard.rs +702 -0
- package/crates/pi/src/core/platform/command.rs +223 -0
- package/crates/pi/src/core/platform/debug_dump.rs +274 -0
- package/crates/pi/src/core/platform/external_editor.rs +294 -0
- package/crates/pi/src/core/platform/first_run.rs +120 -0
- package/crates/pi/src/core/platform/image.rs +237 -0
- package/crates/pi/src/core/platform/mod.rs +27 -0
- package/crates/pi/src/core/platform/open_browser.rs +187 -0
- package/crates/pi/src/core/platform/release_packaging.rs +785 -0
- package/crates/pi/src/core/resources/diagnostics.rs +148 -0
- package/crates/pi/src/core/resources/discovery.rs +2570 -0
- package/crates/pi/src/core/resources/frontmatter.rs +205 -0
- package/crates/pi/src/core/resources/mod.rs +1402 -0
- package/crates/pi/src/core/resources/prompts.rs +510 -0
- package/crates/pi/src/core/resources/skills.rs +981 -0
- package/crates/pi/src/core/resources/slash.rs +199 -0
- package/crates/pi/src/core/resources/source_info.rs +141 -0
- package/crates/pi/src/core/resources/themes.rs +297 -0
- package/crates/pi/src/core/session_transfer.rs +390 -0
- package/crates/pi/src/core/sessions/context.rs +657 -0
- package/crates/pi/src/core/sessions/cwd.rs +176 -0
- package/crates/pi/src/core/sessions/entries.rs +1364 -0
- package/crates/pi/src/core/sessions/list.rs +610 -0
- package/crates/pi/src/core/sessions/mod.rs +2117 -0
- package/crates/pi/src/core/settings.rs +3794 -0
- package/crates/pi/src/core/share.rs +577 -0
- package/crates/pi/src/core/system_prompt.rs +654 -0
- package/crates/pi/src/core/tools/bash.rs +1574 -0
- package/crates/pi/src/core/tools/edit.rs +919 -0
- package/crates/pi/src/core/tools/edit_diff.rs +1150 -0
- package/crates/pi/src/core/tools/find.rs +652 -0
- package/crates/pi/src/core/tools/grep.rs +965 -0
- package/crates/pi/src/core/tools/ls.rs +545 -0
- package/crates/pi/src/core/tools/mod.rs +312 -0
- package/crates/pi/src/core/tools/mutation_queue.rs +392 -0
- package/crates/pi/src/core/tools/output_accumulator.rs +689 -0
- package/crates/pi/src/core/tools/path_utils.rs +517 -0
- package/crates/pi/src/core/tools/read.rs +1413 -0
- package/crates/pi/src/core/tools/truncate.rs +644 -0
- package/crates/pi/src/core/tools/write.rs +524 -0
- package/crates/pi/src/core/trust.rs +1414 -0
- package/crates/pi/src/core/update/changelog.rs +583 -0
- package/crates/pi/src/core/update/deprecation.rs +148 -0
- package/crates/pi/src/core/update/mod.rs +8 -0
- package/crates/pi/src/core/update/self_update.rs +1327 -0
- package/crates/pi/src/core/update/user_agent.rs +59 -0
- package/crates/pi/src/core/update/version_check.rs +511 -0
- package/crates/pi/src/core/update/windows_quarantine.rs +262 -0
- package/crates/pi/src/lib.rs +23 -0
- package/crates/pi/src/main.rs +13 -0
- package/crates/pi/src/modes/interactive/footer.rs +260 -0
- package/crates/pi/src/modes/interactive/header.rs +83 -0
- package/crates/pi/src/modes/interactive/input.rs +923 -0
- package/crates/pi/src/modes/interactive/messages.rs +640 -0
- package/crates/pi/src/modes/interactive/mod.rs +51 -0
- package/crates/pi/src/modes/interactive/progress.rs +181 -0
- package/crates/pi/src/modes/interactive/runtime.rs +7227 -0
- package/crates/pi/src/modes/interactive/selectors.rs +146 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__bash_state_widths.snap +138 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__compact_state_widths.snap +137 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__custom_branch_skill_messages.snap +145 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__empty_state_widths.snap +136 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__error_state_widths.snap +139 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__loading_state_widths.snap +136 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__queue_state_widths.snap +139 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__retry_state_widths.snap +136 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__streaming_state_widths.snap +137 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__user_assistant_messages.snap +145 -0
- package/crates/pi/src/modes/interactive/startup.rs +194 -0
- package/crates/pi/src/modes/interactive/state.rs +759 -0
- package/crates/pi/src/modes/interactive/status.rs +70 -0
- package/crates/pi/src/modes/interactive/tests.rs +945 -0
- package/crates/pi/src/modes/interactive/theme.rs +1402 -0
- package/crates/pi/src/modes/interactive/tool_renderer.rs +152 -0
- package/crates/pi/src/modes/interactive/view.rs +511 -0
- package/crates/pi/src/modes/mod.rs +6 -0
- package/crates/pi/src/modes/print/input.rs +415 -0
- package/crates/pi/src/modes/print/json.rs +195 -0
- package/crates/pi/src/modes/print/mod.rs +403 -0
- package/crates/pi/src/modes/print/text.rs +412 -0
- package/crates/pi/src/modes/rpc/extension_ui.rs +361 -0
- package/crates/pi/src/modes/rpc/jsonl.rs +429 -0
- package/crates/pi/src/modes/rpc/mod.rs +19 -0
- package/crates/pi/src/modes/rpc/mode_host.rs +466 -0
- package/crates/pi/src/modes/rpc/server.rs +3037 -0
- package/crates/pi/src/modes/rpc/types.rs +2999 -0
- package/crates/pi/src/modes/run.rs +636 -0
- package/crates/pi/tests/fixtures/fake_extension_host.rs +104 -0
- package/crates/pi/tests/fixtures/tool-schemas/bash.json +16 -0
- package/crates/pi/tests/fixtures/tool-schemas/edit.json +34 -0
- package/crates/pi/tests/fixtures/tool-schemas/find.json +20 -0
- package/crates/pi/tests/fixtures/tool-schemas/grep.json +36 -0
- package/crates/pi/tests/fixtures/tool-schemas/ls.json +13 -0
- package/crates/pi/tests/fixtures/tool-schemas/read.json +20 -0
- package/crates/pi/tests/fixtures/tool-schemas/write.json +17 -0
- package/crates/pi-agent/Cargo.toml +30 -0
- package/crates/pi-agent/LICENSE +21 -0
- package/crates/pi-agent/src/agent.rs +1780 -0
- package/crates/pi-agent/src/bus.rs +770 -0
- package/crates/pi-agent/src/config.rs +445 -0
- package/crates/pi-agent/src/drain.rs +941 -0
- package/crates/pi-agent/src/error.rs +61 -0
- package/crates/pi-agent/src/event.rs +270 -0
- package/crates/pi-agent/src/lib.rs +49 -0
- package/crates/pi-agent/src/message.rs +296 -0
- package/crates/pi-agent/src/queue.rs +222 -0
- package/crates/pi-agent/src/run.rs +1870 -0
- package/crates/pi-agent/src/schedule.rs +2153 -0
- package/crates/pi-agent/src/state.rs +377 -0
- package/crates/pi-agent/src/tool.rs +496 -0
- package/crates/pi-ai/Cargo.toml +45 -0
- package/crates/pi-ai/LICENSE +21 -0
- package/crates/pi-ai/data/builtin-models.json +25193 -0
- package/crates/pi-ai/src/auth/config_value.rs +598 -0
- package/crates/pi-ai/src/auth/context.rs +215 -0
- package/crates/pi-ai/src/auth/credential_store.rs +318 -0
- package/crates/pi-ai/src/auth/env_keys.rs +647 -0
- package/crates/pi-ai/src/auth/error.rs +194 -0
- package/crates/pi-ai/src/auth/file_store.rs +1179 -0
- package/crates/pi-ai/src/auth/http.rs +526 -0
- package/crates/pi-ai/src/auth/mod.rs +29 -0
- package/crates/pi-ai/src/auth/oauth/anthropic.rs +1482 -0
- package/crates/pi-ai/src/auth/oauth/callback_server.rs +584 -0
- package/crates/pi-ai/src/auth/oauth/device_code.rs +573 -0
- package/crates/pi-ai/src/auth/oauth/github_copilot.rs +1527 -0
- package/crates/pi-ai/src/auth/oauth/mod.rs +26 -0
- package/crates/pi-ai/src/auth/oauth/openai_codex.rs +2005 -0
- package/crates/pi-ai/src/auth/oauth/page.rs +159 -0
- package/crates/pi-ai/src/auth/oauth/pkce.rs +145 -0
- package/crates/pi-ai/src/auth/oauth/radius.rs +1685 -0
- package/crates/pi-ai/src/auth/oauth/xai.rs +989 -0
- package/crates/pi-ai/src/auth/resolve.rs +701 -0
- package/crates/pi-ai/src/auth/runtime_credentials.rs +226 -0
- package/crates/pi-ai/src/auth/types.rs +534 -0
- package/crates/pi-ai/src/catalog/merge.rs +316 -0
- package/crates/pi-ai/src/catalog/mod.rs +485 -0
- package/crates/pi-ai/src/lib.rs +13 -0
- package/crates/pi-ai/src/models_store.rs +974 -0
- package/crates/pi-ai/src/provider.rs +285 -0
- package/crates/pi-ai/src/providers/anthropic_messages.rs +1473 -0
- package/crates/pi-ai/src/providers/azure_openai_responses.rs +559 -0
- package/crates/pi-ai/src/providers/bedrock_converse_stream.rs +2430 -0
- package/crates/pi-ai/src/providers/google_generative_ai.rs +622 -0
- package/crates/pi-ai/src/providers/google_vertex.rs +1565 -0
- package/crates/pi-ai/src/providers/mistral_conversations.rs +1245 -0
- package/crates/pi-ai/src/providers/mod.rs +35 -0
- package/crates/pi-ai/src/providers/openai_codex_responses.rs +2003 -0
- package/crates/pi-ai/src/providers/openai_completions.rs +1873 -0
- package/crates/pi-ai/src/providers/openai_responses.rs +757 -0
- package/crates/pi-ai/src/providers/pi_messages.rs +1235 -0
- package/crates/pi-ai/src/providers/registry.rs +923 -0
- package/crates/pi-ai/src/providers/shared/google.rs +1193 -0
- package/crates/pi-ai/src/providers/shared/responses.rs +1873 -0
- package/crates/pi-ai/src/providers/shared.rs +671 -0
- package/crates/pi-ai/src/providers/stream_state.rs +683 -0
- package/crates/pi-ai/src/providers/transport.rs +488 -0
- package/crates/pi-ai/src/text.rs +322 -0
- package/crates/pi-ai/src/types.rs +1050 -0
- package/crates/pi-ai/tests/conformance_anthropic_mistral.rs +664 -0
- package/crates/pi-ai/tests/conformance_bedrock_pi_messages.rs +908 -0
- package/crates/pi-ai/tests/conformance_codex.rs +815 -0
- package/crates/pi-ai/tests/conformance_google.rs +743 -0
- package/crates/pi-ai/tests/conformance_openai.rs +607 -0
- package/crates/pi-ai/tests/fixtures/provenance/anthropic-sse-parsing.test.ts +275 -0
- package/crates/pi-ai/tests/fixtures/provenance/mistral-reasoning-mode.test.ts +97 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/anthropic-messages.ts +1313 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/bedrock-converse-stream.ts +1091 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/google-generative-ai.ts +509 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/google-shared.ts +350 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/mistral-conversations.ts +664 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/openai-completions.ts +1355 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/openai-responses-shared.ts +613 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/openai-responses.ts +318 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/abort.test.ts +303 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/azure-openai-base-url.test.ts +175 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/bedrock-endpoint-resolution.test.ts +208 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/bedrock-thinking-payload.test.ts +246 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/google-vertex-api-key-resolution.test.ts +223 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-codex-stream.test.ts +2028 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-completions-prompt-cache.test.ts +264 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-completions-retry.test.ts +86 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-completions-thinking-as-text.test.ts +218 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-completions-tool-choice.test.ts +1716 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-responses-partial-json-cleanup.test.ts +106 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-responses-terminal-event.test.ts +233 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/pi-messages.test.ts +243 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/provider-error-body-passthrough.test.ts +78 -0
- package/crates/pi-ai/tests/fixtures/providers/anthropic-messages/cases.jsonl +4 -0
- package/crates/pi-ai/tests/fixtures/providers/azure-openai-responses/cases.jsonl +2 -0
- package/crates/pi-ai/tests/fixtures/providers/bedrock-converse-stream/cases.jsonl +8 -0
- package/crates/pi-ai/tests/fixtures/providers/google-generative-ai/cases.jsonl +6 -0
- package/crates/pi-ai/tests/fixtures/providers/google-vertex/cases.jsonl +6 -0
- package/crates/pi-ai/tests/fixtures/providers/mistral-conversations/cases.jsonl +4 -0
- package/crates/pi-ai/tests/fixtures/providers/openai-codex-responses/cases.jsonl +7 -0
- package/crates/pi-ai/tests/fixtures/providers/openai-completions/cases.jsonl +9 -0
- package/crates/pi-ai/tests/fixtures/providers/openai-responses/cases.jsonl +5 -0
- package/crates/pi-ai/tests/fixtures/providers/pi-messages/cases.jsonl +8 -0
- package/crates/pi-ai/tests/provider_registry_contract.rs +85 -0
- package/crates/pi-ai/tests/support/golden.rs +191 -0
- package/crates/pi-ai/tests/support/http.rs +525 -0
- package/crates/pi-ai/tests/support/mod.rs +4 -0
- package/crates/pi-ext/Cargo.toml +34 -0
- package/crates/pi-ext/LICENSE +21 -0
- package/crates/pi-ext/src/adapters.rs +1915 -0
- package/crates/pi-ext/src/client.rs +1883 -0
- package/crates/pi-ext/src/host.rs +318 -0
- package/crates/pi-ext/src/lib.rs +10 -0
- package/crates/pi-ext/src/protocol.rs +1880 -0
- package/crates/pi-ext/src/sanitize.rs +524 -0
- package/crates/pi-ext/src/test_support.rs +93 -0
- package/crates/pi-ext/tests/fixtures/fake_jsonl_host.rs +35 -0
- package/crates/pi-ext/tests/fixtures/protocol/frames.jsonl +30 -0
- package/crates/pi-ext/tests/scaling.rs +530 -0
- package/crates/pi-tui/Cargo.toml +56 -0
- package/crates/pi-tui/LICENSE +21 -0
- package/crates/pi-tui/src/bin/pi_tui_pty_fixture.rs +722 -0
- package/crates/pi-tui/src/component.rs +101 -0
- package/crates/pi-tui/src/components/editor/mod.rs +2626 -0
- package/crates/pi-tui/src/components/editor/paste.rs +406 -0
- package/crates/pi-tui/src/components/editor/state.rs +240 -0
- package/crates/pi-tui/src/components/image.rs +352 -0
- package/crates/pi-tui/src/components/input.rs +742 -0
- package/crates/pi-tui/src/components/loader.rs +364 -0
- package/crates/pi-tui/src/components/markdown.rs +1154 -0
- package/crates/pi-tui/src/components/mod.rs +30 -0
- package/crates/pi-tui/src/components/padded.rs +212 -0
- package/crates/pi-tui/src/components/select_list.rs +464 -0
- package/crates/pi-tui/src/components/settings_list.rs +597 -0
- package/crates/pi-tui/src/components/spacer.rs +67 -0
- package/crates/pi-tui/src/components/text.rs +225 -0
- package/crates/pi-tui/src/components/truncated_text.rs +137 -0
- package/crates/pi-tui/src/components/util.rs +324 -0
- package/crates/pi-tui/src/editor_support/autocomplete.rs +1039 -0
- package/crates/pi-tui/src/editor_support/history.rs +248 -0
- package/crates/pi-tui/src/editor_support/kill_ring.rs +139 -0
- package/crates/pi-tui/src/editor_support/mod.rs +29 -0
- package/crates/pi-tui/src/editor_support/undo.rs +73 -0
- package/crates/pi-tui/src/editor_support/word_nav.rs +412 -0
- package/crates/pi-tui/src/editor_support/wrap.rs +317 -0
- package/crates/pi-tui/src/focus.rs +564 -0
- package/crates/pi-tui/src/frame.rs +163 -0
- package/crates/pi-tui/src/fuzzy.rs +221 -0
- package/crates/pi-tui/src/image.rs +749 -0
- package/crates/pi-tui/src/keybindings.rs +602 -0
- package/crates/pi-tui/src/keys.rs +1242 -0
- package/crates/pi-tui/src/layout.rs +563 -0
- package/crates/pi-tui/src/lib.rs +16 -0
- package/crates/pi-tui/src/link.rs +408 -0
- package/crates/pi-tui/src/overlay.rs +895 -0
- package/crates/pi-tui/src/terminal/backend.rs +348 -0
- package/crates/pi-tui/src/terminal/caps.rs +237 -0
- package/crates/pi-tui/src/terminal/guard.rs +476 -0
- package/crates/pi-tui/src/terminal/input.rs +266 -0
- package/crates/pi-tui/src/terminal/mod.rs +31 -0
- package/crates/pi-tui/src/terminal/probe.rs +498 -0
- package/crates/pi-tui/src/terminal/sink.rs +128 -0
- package/crates/pi-tui/src/terminal/writer.rs +1541 -0
- package/crates/pi-tui/src/text/ansi.rs +415 -0
- package/crates/pi-tui/src/text/mod.rs +29 -0
- package/crates/pi-tui/src/text/slice.rs +645 -0
- package/crates/pi-tui/src/text/tests.rs +359 -0
- package/crates/pi-tui/src/text/width.rs +311 -0
- package/crates/pi-tui/src/text/wrap.rs +344 -0
- package/crates/pi-tui/tests/pty_no_flicker.rs +929 -0
- package/deny.toml +38 -0
- package/npm-package/bin/pi.js +31 -0
- package/npm-package/package.json +35 -0
- package/npm-package/tests/archive.test.ts +139 -0
- package/npm-package/tests/wrapper.test.ts +70 -0
- package/package.json +34 -0
- package/packages/extension-host/bun.lock +664 -0
- package/packages/extension-host/fixtures/extensions/all-events.ts +55 -0
- package/packages/extension-host/fixtures/extensions/control-compat-shadow.ts +14 -0
- package/packages/extension-host/fixtures/extensions/control-compat.ts +35 -0
- package/packages/extension-host/fixtures/extensions/crash.ts +36 -0
- package/packages/extension-host/fixtures/extensions/hooks.ts +45 -0
- package/packages/extension-host/fixtures/extensions/hostile.ts +39 -0
- package/packages/extension-host/fixtures/extensions/idle.ts +9 -0
- package/packages/extension-host/fixtures/extensions/provider-stream.ts +121 -0
- package/packages/extension-host/fixtures/extensions/terminal-input-fast.ts +20 -0
- package/packages/extension-host/fixtures/extensions/terminal-input-slow.ts +23 -0
- package/packages/extension-host/fixtures/extensions/tool-progress.ts +72 -0
- package/packages/extension-host/fixtures/extensions/tool.ts +71 -0
- package/packages/extension-host/fixtures/extensions/virtual-imports.ts +87 -0
- package/packages/extension-host/fixtures/extensions/widget-active.ts +16 -0
- package/packages/extension-host/fixtures/photon-probe.ts +45 -0
- package/packages/extension-host/fixtures/runtime-import.ts +54 -0
- package/packages/extension-host/package.json +54 -0
- package/packages/extension-host/src/host.ts +1651 -0
- package/packages/extension-host/src/index.ts +21 -0
- package/packages/extension-host/src/main.ts +51 -0
- package/packages/extension-host/src/protocol.ts +10 -0
- package/packages/extension-host/src/refs.d.ts +364 -0
- package/packages/extension-host/src/sanitize.ts +503 -0
- package/packages/extension-host/src/virtual-modules.ts +90 -0
- package/packages/extension-host/tests/acceptance.test.ts +1498 -0
- package/packages/extension-host/tests/host.test.ts +244 -0
- package/packages/extension-host/tests/sanitize.test.ts +359 -0
- package/packages/extension-host/tests/scaling.test.ts +661 -0
- package/packages/extension-host/tests/virtual-modules.test.ts +122 -0
- package/packages/extension-host/tsconfig.build.json +44 -0
- package/packages/extension-host/tsconfig.check.json +29 -0
- package/packages/extension-host/tsconfig.json +8 -0
- package/packages/pi-tui-protocol/package.json +41 -0
- package/packages/pi-tui-protocol/src/client.ts +341 -0
- package/packages/pi-tui-protocol/src/codec.ts +439 -0
- package/packages/pi-tui-protocol/src/index.ts +77 -0
- package/packages/pi-tui-protocol/src/types.ts +358 -0
- package/packages/pi-tui-protocol/tests/client.test.ts +175 -0
- package/packages/pi-tui-protocol/tests/codec.test.ts +196 -0
- package/packages/pi-tui-protocol/tests/fixtures/frames.jsonl +30 -0
- package/packages/pi-tui-protocol/tsconfig.build.json +23 -0
- package/packages/pi-tui-protocol/tsconfig.json +9 -0
- package/rust-toolchain.toml +3 -0
- package/rustfmt.toml +5 -0
- package/scripts/bench-extension-scaling.ts +466 -0
- package/scripts/build-extension-host.ts +51 -0
- package/scripts/generate-builtin-models.ts +344 -0
- package/scripts/generate-session-fixtures.ts +1758 -0
- package/scripts/generate-tool-schemas.ts +444 -0
- package/scripts/package-npm.ts +263 -0
- package/scripts/package-release.ts +422 -0
- package/scripts/release/archive.ts +594 -0
- package/scripts/release/args.ts +187 -0
- package/scripts/release/extract-host-asset.ts +224 -0
- package/scripts/release/host.ts +825 -0
- package/scripts/release/runner.ts +435 -0
- package/scripts/release/runtime.ts +130 -0
- package/scripts/release/stage.ts +437 -0
- package/scripts/release/targets.ts +150 -0
- package/scripts/tests/archive.test.ts +210 -0
- package/scripts/tests/args.test.ts +180 -0
- package/scripts/tests/cli-dry-run.test.ts +61 -0
- package/scripts/tests/compat-authority.test.ts +79 -0
- package/scripts/tests/compat-matrix.test.ts +389 -0
- package/scripts/tests/extract-host-asset.test.ts +176 -0
- package/scripts/tests/host.test.ts +443 -0
- package/scripts/tests/npm-installed-smoke.test.ts +104 -0
- package/scripts/tests/package-release.test.ts +516 -0
- package/scripts/tests/repro-guards.test.ts +241 -0
- package/scripts/tests/runner.test.ts +188 -0
- package/scripts/tests/stage.test.ts +232 -0
- package/scripts/tests/targets.test.ts +93 -0
- package/scripts/tsconfig.json +47 -0
- package/scripts/verification/compat-matrix.json +455 -0
- package/scripts/verification/compat-matrix.ts +632 -0
- package/scripts/verification/e2e-smoke.ts +1093 -0
- package/scripts/verification/extension.ts +339 -0
- package/scripts/verification/foundation.test.ts +339 -0
- package/scripts/verification/npm-installed-smoke.ts +117 -0
- package/scripts/verification/performance.ts +1425 -0
- package/scripts/verification/pty.ts +332 -0
|
@@ -0,0 +1,1480 @@
|
|
|
1
|
+
# RPC Mode
|
|
2
|
+
|
|
3
|
+
RPC mode enables headless operation of the coding agent via a JSON protocol over stdin/stdout. This is useful for embedding the agent in other applications, IDEs, or custom UIs.
|
|
4
|
+
|
|
5
|
+
**Note for Node.js/TypeScript users**: If you're building a Node.js application, consider using `AgentSession` directly from `@earendil-works/pi-coding-agent` instead of spawning a subprocess. See [`src/core/agent-session.ts`](../src/core/agent-session.ts) for the API. For a subprocess-based TypeScript client, see [`src/modes/rpc/rpc-client.ts`](../src/modes/rpc/rpc-client.ts).
|
|
6
|
+
|
|
7
|
+
## Starting RPC Mode
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pi --mode rpc [options]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Common options:
|
|
14
|
+
- `--provider <name>`: Set the LLM provider (anthropic, openai, google, etc.)
|
|
15
|
+
- `--model <pattern>`: Model pattern or ID (supports `provider/id` and optional `:<thinking>`)
|
|
16
|
+
- `--name <name>` / `-n <name>`: Set the session display name at startup
|
|
17
|
+
- `--no-session`: Disable session persistence
|
|
18
|
+
- `--session-dir <path>`: Custom session storage directory
|
|
19
|
+
|
|
20
|
+
## Protocol Overview
|
|
21
|
+
|
|
22
|
+
- **Commands**: JSON objects sent to stdin, one per line
|
|
23
|
+
- **Responses**: JSON objects with `type: "response"` indicating command success/failure
|
|
24
|
+
- **Events**: Agent events streamed to stdout as JSON lines
|
|
25
|
+
|
|
26
|
+
All commands support an optional `id` field for request/response correlation. If provided, the corresponding response will include the same `id`.
|
|
27
|
+
|
|
28
|
+
### Framing
|
|
29
|
+
|
|
30
|
+
RPC mode uses strict JSONL semantics with LF (`\n`) as the only record delimiter.
|
|
31
|
+
|
|
32
|
+
This matters for clients:
|
|
33
|
+
- Split records on `\n` only
|
|
34
|
+
- Accept optional `\r\n` input by stripping a trailing `\r`
|
|
35
|
+
- Do not use generic line readers that treat Unicode separators as newlines
|
|
36
|
+
|
|
37
|
+
In particular, Node `readline` is not protocol-compliant for RPC mode because it also splits on `U+2028` and `U+2029`, which are valid inside JSON strings.
|
|
38
|
+
|
|
39
|
+
## Commands
|
|
40
|
+
|
|
41
|
+
### Prompting
|
|
42
|
+
|
|
43
|
+
#### prompt
|
|
44
|
+
|
|
45
|
+
Send a user prompt to the agent. The command response is emitted after the prompt is accepted, queued, or handled. Events continue streaming asynchronously after acceptance.
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{"id": "req-1", "type": "prompt", "message": "Hello, world!"}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
With images:
|
|
52
|
+
```json
|
|
53
|
+
{"type": "prompt", "message": "What's in this image?", "images": [{"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}]}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**During streaming**: If the agent is already streaming, you must specify `streamingBehavior` to queue the message:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{"type": "prompt", "message": "New instruction", "streamingBehavior": "steer"}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- `"steer"`: Queue the message while the agent is running. It is delivered after the current assistant turn finishes executing its tool calls, before the next LLM call.
|
|
63
|
+
- `"followUp"`: Wait until the agent finishes. Message is delivered only when agent stops.
|
|
64
|
+
|
|
65
|
+
If the agent is streaming and no `streamingBehavior` is specified, the command returns an error.
|
|
66
|
+
|
|
67
|
+
**Extension commands**: If the message is an extension command (e.g., `/mycommand`), it executes immediately even during streaming. Extension commands manage their own LLM interaction via `pi.sendMessage()`.
|
|
68
|
+
|
|
69
|
+
**Input expansion**: Skill commands (`/skill:name`) and prompt templates (`/template`) are expanded before sending/queueing.
|
|
70
|
+
|
|
71
|
+
Response:
|
|
72
|
+
```json
|
|
73
|
+
{"id": "req-1", "type": "response", "command": "prompt", "success": true}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`success: true` means the prompt was accepted, queued, or handled immediately. `success: false` means the prompt was rejected before acceptance. Failures after acceptance are reported through the normal event and message stream, not as a second `response` for the same request id.
|
|
77
|
+
|
|
78
|
+
The `images` field is optional. Each image uses `ImageContent` format: `{"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}`.
|
|
79
|
+
|
|
80
|
+
#### steer
|
|
81
|
+
|
|
82
|
+
Queue a steering message while the agent is running. It is delivered after the current assistant turn finishes executing its tool calls, before the next LLM call. Skill commands and prompt templates are expanded. Extension commands are not allowed (use `prompt` instead).
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{"type": "steer", "message": "Stop and do this instead"}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
With images:
|
|
89
|
+
```json
|
|
90
|
+
{"type": "steer", "message": "Look at this instead", "images": [{"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}]}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The `images` field is optional. Each image uses `ImageContent` format (same as `prompt`).
|
|
94
|
+
|
|
95
|
+
Response:
|
|
96
|
+
```json
|
|
97
|
+
{"type": "response", "command": "steer", "success": true}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
See [set_steering_mode](#set_steering_mode) for controlling how steering messages are processed.
|
|
101
|
+
|
|
102
|
+
#### follow_up
|
|
103
|
+
|
|
104
|
+
Queue a follow-up message to be processed after the agent finishes. Delivered only when agent has no more tool calls or steering messages. Skill commands and prompt templates are expanded. Extension commands are not allowed (use `prompt` instead).
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{"type": "follow_up", "message": "After you're done, also do this"}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
With images:
|
|
111
|
+
```json
|
|
112
|
+
{"type": "follow_up", "message": "Also check this image", "images": [{"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}]}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The `images` field is optional. Each image uses `ImageContent` format (same as `prompt`).
|
|
116
|
+
|
|
117
|
+
Response:
|
|
118
|
+
```json
|
|
119
|
+
{"type": "response", "command": "follow_up", "success": true}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
See [set_follow_up_mode](#set_follow_up_mode) for controlling how follow-up messages are processed.
|
|
123
|
+
|
|
124
|
+
#### abort
|
|
125
|
+
|
|
126
|
+
Abort the current agent operation.
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{"type": "abort"}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Response:
|
|
133
|
+
```json
|
|
134
|
+
{"type": "response", "command": "abort", "success": true}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### new_session
|
|
138
|
+
|
|
139
|
+
Start a fresh session. Can be cancelled by a `session_before_switch` extension event handler.
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{"type": "new_session"}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
With optional parent session tracking:
|
|
146
|
+
```json
|
|
147
|
+
{"type": "new_session", "parentSession": "/path/to/parent-session.jsonl"}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Response:
|
|
151
|
+
```json
|
|
152
|
+
{"type": "response", "command": "new_session", "success": true, "data": {"cancelled": false}}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
If an extension cancelled:
|
|
156
|
+
```json
|
|
157
|
+
{"type": "response", "command": "new_session", "success": true, "data": {"cancelled": true}}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### State
|
|
161
|
+
|
|
162
|
+
#### get_state
|
|
163
|
+
|
|
164
|
+
Get current session state.
|
|
165
|
+
|
|
166
|
+
```json
|
|
167
|
+
{"type": "get_state"}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Response:
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"type": "response",
|
|
174
|
+
"command": "get_state",
|
|
175
|
+
"success": true,
|
|
176
|
+
"data": {
|
|
177
|
+
"model": {...},
|
|
178
|
+
"thinkingLevel": "medium",
|
|
179
|
+
"isStreaming": false,
|
|
180
|
+
"isCompacting": false,
|
|
181
|
+
"steeringMode": "all",
|
|
182
|
+
"followUpMode": "one-at-a-time",
|
|
183
|
+
"sessionFile": "/path/to/session.jsonl",
|
|
184
|
+
"sessionId": "abc123",
|
|
185
|
+
"sessionName": "my-feature-work",
|
|
186
|
+
"autoCompactionEnabled": true,
|
|
187
|
+
"messageCount": 5,
|
|
188
|
+
"pendingMessageCount": 0
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The `model` field is a full [Model](#model) object or `null`. The `sessionName` field is the display name set via `set_session_name`, or omitted if not set.
|
|
194
|
+
|
|
195
|
+
#### get_messages
|
|
196
|
+
|
|
197
|
+
Get all messages in the conversation.
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{"type": "get_messages"}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Response:
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"type": "response",
|
|
207
|
+
"command": "get_messages",
|
|
208
|
+
"success": true,
|
|
209
|
+
"data": {"messages": [...]}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Messages are `AgentMessage` objects (see [Message Types](#message-types)).
|
|
214
|
+
|
|
215
|
+
### Model
|
|
216
|
+
|
|
217
|
+
#### set_model
|
|
218
|
+
|
|
219
|
+
Switch to a specific model.
|
|
220
|
+
|
|
221
|
+
```json
|
|
222
|
+
{"type": "set_model", "provider": "anthropic", "modelId": "claude-sonnet-4-20250514"}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Response contains the full [Model](#model) object:
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"type": "response",
|
|
229
|
+
"command": "set_model",
|
|
230
|
+
"success": true,
|
|
231
|
+
"data": {...}
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### cycle_model
|
|
236
|
+
|
|
237
|
+
Cycle to the next available model. Returns `null` data if only one model available.
|
|
238
|
+
|
|
239
|
+
```json
|
|
240
|
+
{"type": "cycle_model"}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Response:
|
|
244
|
+
```json
|
|
245
|
+
{
|
|
246
|
+
"type": "response",
|
|
247
|
+
"command": "cycle_model",
|
|
248
|
+
"success": true,
|
|
249
|
+
"data": {
|
|
250
|
+
"model": {...},
|
|
251
|
+
"thinkingLevel": "medium",
|
|
252
|
+
"isScoped": false
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
The `model` field is a full [Model](#model) object.
|
|
258
|
+
|
|
259
|
+
#### get_available_models
|
|
260
|
+
|
|
261
|
+
List all configured models.
|
|
262
|
+
|
|
263
|
+
```json
|
|
264
|
+
{"type": "get_available_models"}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Response contains an array of full [Model](#model) objects:
|
|
268
|
+
```json
|
|
269
|
+
{
|
|
270
|
+
"type": "response",
|
|
271
|
+
"command": "get_available_models",
|
|
272
|
+
"success": true,
|
|
273
|
+
"data": {
|
|
274
|
+
"models": [...]
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Thinking
|
|
280
|
+
|
|
281
|
+
#### set_thinking_level
|
|
282
|
+
|
|
283
|
+
Set the reasoning/thinking level for models that support it.
|
|
284
|
+
|
|
285
|
+
```json
|
|
286
|
+
{"type": "set_thinking_level", "level": "high"}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Levels: `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`, `"max"`
|
|
290
|
+
|
|
291
|
+
`"xhigh"` and `"max"` are exposed only when supported by the selected model. Some models, including GPT-5.6, expose both.
|
|
292
|
+
|
|
293
|
+
Response:
|
|
294
|
+
```json
|
|
295
|
+
{"type": "response", "command": "set_thinking_level", "success": true}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
#### cycle_thinking_level
|
|
299
|
+
|
|
300
|
+
Cycle through available thinking levels. Returns `null` data if model doesn't support thinking.
|
|
301
|
+
|
|
302
|
+
```json
|
|
303
|
+
{"type": "cycle_thinking_level"}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Response:
|
|
307
|
+
```json
|
|
308
|
+
{
|
|
309
|
+
"type": "response",
|
|
310
|
+
"command": "cycle_thinking_level",
|
|
311
|
+
"success": true,
|
|
312
|
+
"data": {"level": "high"}
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Queue Modes
|
|
317
|
+
|
|
318
|
+
#### set_steering_mode
|
|
319
|
+
|
|
320
|
+
Control how steering messages (from `steer`) are delivered.
|
|
321
|
+
|
|
322
|
+
```json
|
|
323
|
+
{"type": "set_steering_mode", "mode": "one-at-a-time"}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Modes:
|
|
327
|
+
- `"all"`: Deliver all steering messages after the current assistant turn finishes executing its tool calls
|
|
328
|
+
- `"one-at-a-time"`: Deliver one steering message per completed assistant turn (default)
|
|
329
|
+
|
|
330
|
+
Response:
|
|
331
|
+
```json
|
|
332
|
+
{"type": "response", "command": "set_steering_mode", "success": true}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
#### set_follow_up_mode
|
|
336
|
+
|
|
337
|
+
Control how follow-up messages (from `follow_up`) are delivered.
|
|
338
|
+
|
|
339
|
+
```json
|
|
340
|
+
{"type": "set_follow_up_mode", "mode": "one-at-a-time"}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Modes:
|
|
344
|
+
- `"all"`: Deliver all follow-up messages when agent finishes
|
|
345
|
+
- `"one-at-a-time"`: Deliver one follow-up message per agent completion (default)
|
|
346
|
+
|
|
347
|
+
Response:
|
|
348
|
+
```json
|
|
349
|
+
{"type": "response", "command": "set_follow_up_mode", "success": true}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Compaction
|
|
353
|
+
|
|
354
|
+
#### compact
|
|
355
|
+
|
|
356
|
+
Manually compact conversation context to reduce token usage.
|
|
357
|
+
|
|
358
|
+
```json
|
|
359
|
+
{"type": "compact"}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
With custom instructions:
|
|
363
|
+
```json
|
|
364
|
+
{"type": "compact", "customInstructions": "Focus on code changes"}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
Response:
|
|
368
|
+
```json
|
|
369
|
+
{
|
|
370
|
+
"type": "response",
|
|
371
|
+
"command": "compact",
|
|
372
|
+
"success": true,
|
|
373
|
+
"data": {
|
|
374
|
+
"summary": "Summary of conversation...",
|
|
375
|
+
"firstKeptEntryId": "abc123",
|
|
376
|
+
"tokensBefore": 150000,
|
|
377
|
+
"estimatedTokensAfter": 32000,
|
|
378
|
+
"details": {}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
`estimatedTokensAfter` is a heuristic estimate over the rebuilt message context immediately after compaction, not a provider-exact token count.
|
|
384
|
+
|
|
385
|
+
#### set_auto_compaction
|
|
386
|
+
|
|
387
|
+
Enable or disable automatic compaction when context is nearly full.
|
|
388
|
+
|
|
389
|
+
```json
|
|
390
|
+
{"type": "set_auto_compaction", "enabled": true}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Response:
|
|
394
|
+
```json
|
|
395
|
+
{"type": "response", "command": "set_auto_compaction", "success": true}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Retry
|
|
399
|
+
|
|
400
|
+
#### set_auto_retry
|
|
401
|
+
|
|
402
|
+
Enable or disable automatic retry on transient errors (overloaded, rate limit, 5xx).
|
|
403
|
+
|
|
404
|
+
```json
|
|
405
|
+
{"type": "set_auto_retry", "enabled": true}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
Response:
|
|
409
|
+
```json
|
|
410
|
+
{"type": "response", "command": "set_auto_retry", "success": true}
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
#### abort_retry
|
|
414
|
+
|
|
415
|
+
Abort an in-progress retry (cancel the delay and stop retrying).
|
|
416
|
+
|
|
417
|
+
```json
|
|
418
|
+
{"type": "abort_retry"}
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
Response:
|
|
422
|
+
```json
|
|
423
|
+
{"type": "response", "command": "abort_retry", "success": true}
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Bash
|
|
427
|
+
|
|
428
|
+
#### bash
|
|
429
|
+
|
|
430
|
+
Execute a shell command and add output to conversation context.
|
|
431
|
+
|
|
432
|
+
```json
|
|
433
|
+
{"type": "bash", "command": "ls -la"}
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Response:
|
|
437
|
+
```json
|
|
438
|
+
{
|
|
439
|
+
"type": "response",
|
|
440
|
+
"command": "bash",
|
|
441
|
+
"success": true,
|
|
442
|
+
"data": {
|
|
443
|
+
"output": "total 48\ndrwxr-xr-x ...",
|
|
444
|
+
"exitCode": 0,
|
|
445
|
+
"cancelled": false,
|
|
446
|
+
"truncated": false
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
If output was truncated, includes `fullOutputPath`:
|
|
452
|
+
```json
|
|
453
|
+
{
|
|
454
|
+
"type": "response",
|
|
455
|
+
"command": "bash",
|
|
456
|
+
"success": true,
|
|
457
|
+
"data": {
|
|
458
|
+
"output": "truncated output...",
|
|
459
|
+
"exitCode": 0,
|
|
460
|
+
"cancelled": false,
|
|
461
|
+
"truncated": true,
|
|
462
|
+
"fullOutputPath": "/tmp/pi-bash-abc123.log"
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
**How bash results reach the LLM:**
|
|
468
|
+
|
|
469
|
+
The `bash` command executes immediately and returns a `BashResult`. Internally, a `BashExecutionMessage` is created and stored in the agent's message state. This message does NOT emit an event.
|
|
470
|
+
|
|
471
|
+
When the next `prompt` command is sent, all messages (including `BashExecutionMessage`) are transformed before being sent to the LLM. The `BashExecutionMessage` is converted to a `UserMessage` with this format:
|
|
472
|
+
|
|
473
|
+
````
|
|
474
|
+
Ran `ls -la`
|
|
475
|
+
```
|
|
476
|
+
total 48
|
|
477
|
+
drwxr-xr-x ...
|
|
478
|
+
```
|
|
479
|
+
````
|
|
480
|
+
|
|
481
|
+
This means:
|
|
482
|
+
1. Bash output is included in the LLM context on the **next prompt**, not immediately
|
|
483
|
+
2. Multiple bash commands can be executed before a prompt; all outputs will be included
|
|
484
|
+
3. No event is emitted for the `BashExecutionMessage` itself
|
|
485
|
+
|
|
486
|
+
#### abort_bash
|
|
487
|
+
|
|
488
|
+
Abort a running bash command.
|
|
489
|
+
|
|
490
|
+
```json
|
|
491
|
+
{"type": "abort_bash"}
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
Response:
|
|
495
|
+
```json
|
|
496
|
+
{"type": "response", "command": "abort_bash", "success": true}
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### Session
|
|
500
|
+
|
|
501
|
+
#### get_session_stats
|
|
502
|
+
|
|
503
|
+
Get token usage, cost statistics, and current context window usage.
|
|
504
|
+
|
|
505
|
+
```json
|
|
506
|
+
{"type": "get_session_stats"}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
Response:
|
|
510
|
+
```json
|
|
511
|
+
{
|
|
512
|
+
"type": "response",
|
|
513
|
+
"command": "get_session_stats",
|
|
514
|
+
"success": true,
|
|
515
|
+
"data": {
|
|
516
|
+
"sessionFile": "/path/to/session.jsonl",
|
|
517
|
+
"sessionId": "abc123",
|
|
518
|
+
"userMessages": 5,
|
|
519
|
+
"assistantMessages": 5,
|
|
520
|
+
"toolCalls": 12,
|
|
521
|
+
"toolResults": 12,
|
|
522
|
+
"totalMessages": 22,
|
|
523
|
+
"tokens": {
|
|
524
|
+
"input": 50000,
|
|
525
|
+
"output": 10000,
|
|
526
|
+
"cacheRead": 40000,
|
|
527
|
+
"cacheWrite": 5000,
|
|
528
|
+
"total": 105000
|
|
529
|
+
},
|
|
530
|
+
"cost": 0.45,
|
|
531
|
+
"contextUsage": {
|
|
532
|
+
"tokens": 60000,
|
|
533
|
+
"contextWindow": 200000,
|
|
534
|
+
"percent": 30
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
`tokens` contains assistant usage totals for the current session state. `contextUsage` contains the actual current context-window estimate used for compaction and footer display.
|
|
541
|
+
|
|
542
|
+
`contextUsage` is omitted when no model or context window is available. `contextUsage.tokens` and `contextUsage.percent` are `null` immediately after compaction until a fresh post-compaction assistant response provides valid usage data.
|
|
543
|
+
|
|
544
|
+
#### export_html
|
|
545
|
+
|
|
546
|
+
Export session to an HTML file.
|
|
547
|
+
|
|
548
|
+
```json
|
|
549
|
+
{"type": "export_html"}
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
With custom path:
|
|
553
|
+
```json
|
|
554
|
+
{"type": "export_html", "outputPath": "/tmp/session.html"}
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
Response:
|
|
558
|
+
```json
|
|
559
|
+
{
|
|
560
|
+
"type": "response",
|
|
561
|
+
"command": "export_html",
|
|
562
|
+
"success": true,
|
|
563
|
+
"data": {"path": "/tmp/session.html"}
|
|
564
|
+
}
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
#### switch_session
|
|
568
|
+
|
|
569
|
+
Load a different session file. Can be cancelled by a `session_before_switch` extension event handler.
|
|
570
|
+
|
|
571
|
+
```json
|
|
572
|
+
{"type": "switch_session", "sessionPath": "/path/to/session.jsonl"}
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
Response:
|
|
576
|
+
```json
|
|
577
|
+
{"type": "response", "command": "switch_session", "success": true, "data": {"cancelled": false}}
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
If an extension cancelled the switch:
|
|
581
|
+
```json
|
|
582
|
+
{"type": "response", "command": "switch_session", "success": true, "data": {"cancelled": true}}
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
#### fork
|
|
586
|
+
|
|
587
|
+
Create a new fork from a previous user message on the active branch. Can be cancelled by a `session_before_fork` extension event handler. Returns the text of the message being forked from.
|
|
588
|
+
|
|
589
|
+
```json
|
|
590
|
+
{"type": "fork", "entryId": "abc123"}
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
Response:
|
|
594
|
+
```json
|
|
595
|
+
{
|
|
596
|
+
"type": "response",
|
|
597
|
+
"command": "fork",
|
|
598
|
+
"success": true,
|
|
599
|
+
"data": {"text": "The original prompt text...", "cancelled": false}
|
|
600
|
+
}
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
If an extension cancelled the fork:
|
|
604
|
+
```json
|
|
605
|
+
{
|
|
606
|
+
"type": "response",
|
|
607
|
+
"command": "fork",
|
|
608
|
+
"success": true,
|
|
609
|
+
"data": {"text": "The original prompt text...", "cancelled": true}
|
|
610
|
+
}
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
#### clone
|
|
614
|
+
|
|
615
|
+
Duplicate the current active branch into a new session at the current position. Can be cancelled by a `session_before_fork` extension event handler.
|
|
616
|
+
|
|
617
|
+
```json
|
|
618
|
+
{"type": "clone"}
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
Response:
|
|
622
|
+
```json
|
|
623
|
+
{
|
|
624
|
+
"type": "response",
|
|
625
|
+
"command": "clone",
|
|
626
|
+
"success": true,
|
|
627
|
+
"data": {"cancelled": false}
|
|
628
|
+
}
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
If an extension cancelled the clone:
|
|
632
|
+
```json
|
|
633
|
+
{
|
|
634
|
+
"type": "response",
|
|
635
|
+
"command": "clone",
|
|
636
|
+
"success": true,
|
|
637
|
+
"data": {"cancelled": true}
|
|
638
|
+
}
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
#### get_fork_messages
|
|
642
|
+
|
|
643
|
+
Get user messages available for forking.
|
|
644
|
+
|
|
645
|
+
```json
|
|
646
|
+
{"type": "get_fork_messages"}
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
Response:
|
|
650
|
+
```json
|
|
651
|
+
{
|
|
652
|
+
"type": "response",
|
|
653
|
+
"command": "get_fork_messages",
|
|
654
|
+
"success": true,
|
|
655
|
+
"data": {
|
|
656
|
+
"messages": [
|
|
657
|
+
{"entryId": "abc123", "text": "First prompt..."},
|
|
658
|
+
{"entryId": "def456", "text": "Second prompt..."}
|
|
659
|
+
]
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
#### get_entries
|
|
665
|
+
|
|
666
|
+
Get all session entries in append order (excluding the session header). The session is an append-only tree of entries with stable ids, so an entry id works as a durable cursor: pass the last entry id you have seen as `since` to get only entries strictly after it, even across client restarts. Unlike `get_messages`, this includes pre-compaction history and abandoned branches.
|
|
667
|
+
|
|
668
|
+
```json
|
|
669
|
+
{"type": "get_entries"}
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
With a cursor:
|
|
673
|
+
```json
|
|
674
|
+
{"type": "get_entries", "since": "abc123"}
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
Response:
|
|
678
|
+
```json
|
|
679
|
+
{
|
|
680
|
+
"type": "response",
|
|
681
|
+
"command": "get_entries",
|
|
682
|
+
"success": true,
|
|
683
|
+
"data": {
|
|
684
|
+
"entries": [
|
|
685
|
+
{"type": "message", "id": "def456", "parentId": "abc123", "timestamp": "...", "message": {"role": "user", "...": "..."}}
|
|
686
|
+
],
|
|
687
|
+
"leafId": "def456"
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
`leafId` is the id of the current leaf entry (`null` for an empty session), so a client can tell in one round trip whether the active branch moved. If `since` does not match any entry id, the response is `success: false`.
|
|
693
|
+
|
|
694
|
+
#### get_tree
|
|
695
|
+
|
|
696
|
+
Get the session as a tree of entries. Each node is `{entry, children, label?, labelTimestamp?}`. A well-formed session has a single root; orphaned entries (broken parent chain) also appear as roots.
|
|
697
|
+
|
|
698
|
+
```json
|
|
699
|
+
{"type": "get_tree"}
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
Response:
|
|
703
|
+
```json
|
|
704
|
+
{
|
|
705
|
+
"type": "response",
|
|
706
|
+
"command": "get_tree",
|
|
707
|
+
"success": true,
|
|
708
|
+
"data": {
|
|
709
|
+
"tree": [
|
|
710
|
+
{
|
|
711
|
+
"entry": {"type": "message", "id": "abc123", "parentId": null, "...": "..."},
|
|
712
|
+
"children": [
|
|
713
|
+
{"entry": {"type": "message", "id": "def456", "parentId": "abc123", "...": "..."}, "children": []}
|
|
714
|
+
]
|
|
715
|
+
}
|
|
716
|
+
],
|
|
717
|
+
"leafId": "def456"
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
#### get_last_assistant_text
|
|
723
|
+
|
|
724
|
+
Get the text content of the last assistant message.
|
|
725
|
+
|
|
726
|
+
```json
|
|
727
|
+
{"type": "get_last_assistant_text"}
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
Response:
|
|
731
|
+
```json
|
|
732
|
+
{
|
|
733
|
+
"type": "response",
|
|
734
|
+
"command": "get_last_assistant_text",
|
|
735
|
+
"success": true,
|
|
736
|
+
"data": {"text": "The assistant's response..."}
|
|
737
|
+
}
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
Returns `{"text": null}` if no assistant messages exist.
|
|
741
|
+
|
|
742
|
+
#### set_session_name
|
|
743
|
+
|
|
744
|
+
Set a display name for the current session. The name appears in session listings and helps identify sessions.
|
|
745
|
+
|
|
746
|
+
```json
|
|
747
|
+
{"type": "set_session_name", "name": "my-feature-work"}
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
Response:
|
|
751
|
+
```json
|
|
752
|
+
{
|
|
753
|
+
"type": "response",
|
|
754
|
+
"command": "set_session_name",
|
|
755
|
+
"success": true
|
|
756
|
+
}
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
The current session name is available via `get_state` in the `sessionName` field. To set the initial name when starting RPC mode, pass `--name <name>` or `-n <name>` to the `pi --mode rpc` process.
|
|
760
|
+
|
|
761
|
+
### Commands
|
|
762
|
+
|
|
763
|
+
#### get_commands
|
|
764
|
+
|
|
765
|
+
Get available commands (extension commands, prompt templates, and skills). These can be invoked via the `prompt` command by prefixing with `/`.
|
|
766
|
+
|
|
767
|
+
```json
|
|
768
|
+
{"type": "get_commands"}
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
Response:
|
|
772
|
+
```json
|
|
773
|
+
{
|
|
774
|
+
"type": "response",
|
|
775
|
+
"command": "get_commands",
|
|
776
|
+
"success": true,
|
|
777
|
+
"data": {
|
|
778
|
+
"commands": [
|
|
779
|
+
{"name": "session-name", "description": "Set or clear session name", "source": "extension", "path": "/home/user/.pi/agent/extensions/session.ts"},
|
|
780
|
+
{"name": "fix-tests", "description": "Fix failing tests", "source": "prompt", "location": "project", "path": "/home/user/myproject/.pi/agent/prompts/fix-tests.md"},
|
|
781
|
+
{"name": "skill:brave-search", "description": "Web search via Brave API", "source": "skill", "location": "user", "path": "/home/user/.pi/agent/skills/brave-search/SKILL.md"}
|
|
782
|
+
]
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
Each command has:
|
|
788
|
+
- `name`: Command name (invoke with `/name`)
|
|
789
|
+
- `description`: Human-readable description (optional for extension commands)
|
|
790
|
+
- `source`: What kind of command:
|
|
791
|
+
- `"extension"`: Registered via `pi.registerCommand()` in an extension
|
|
792
|
+
- `"prompt"`: Loaded from a prompt template `.md` file
|
|
793
|
+
- `"skill"`: Loaded from a skill directory (name is prefixed with `skill:`)
|
|
794
|
+
- `location`: Where it was loaded from (optional, not present for extensions):
|
|
795
|
+
- `"user"`: User-level (`~/.pi/agent/`)
|
|
796
|
+
- `"project"`: Project-level (`./.pi/agent/`)
|
|
797
|
+
- `"path"`: Explicit path via CLI or settings
|
|
798
|
+
- `path`: Absolute file path to the command source (optional)
|
|
799
|
+
|
|
800
|
+
**Note**: Built-in TUI commands (`/settings`, `/hotkeys`, etc.) are not included. They are handled only in interactive mode and would not execute if sent via `prompt`.
|
|
801
|
+
|
|
802
|
+
## Events
|
|
803
|
+
|
|
804
|
+
Events are streamed to stdout as JSON lines during agent operation. Events do NOT include an `id` field (only responses do).
|
|
805
|
+
|
|
806
|
+
### Event Types
|
|
807
|
+
|
|
808
|
+
| Event | Description |
|
|
809
|
+
|-------|-------------|
|
|
810
|
+
| `agent_start` | Agent begins processing |
|
|
811
|
+
| `agent_end` | One low-level agent run completes (may still be followed by retry, compaction, or queued continuations) |
|
|
812
|
+
| `agent_settled` | Agent run is fully settled; no automatic retry, compaction retry, or queued continuation remains |
|
|
813
|
+
| `turn_start` | New turn begins |
|
|
814
|
+
| `turn_end` | Turn completes (includes assistant message and tool results) |
|
|
815
|
+
| `message_start` | Message begins |
|
|
816
|
+
| `message_update` | Streaming update (text/thinking/toolcall deltas) |
|
|
817
|
+
| `message_end` | Message completes |
|
|
818
|
+
| `tool_execution_start` | Tool begins execution |
|
|
819
|
+
| `tool_execution_update` | Tool execution progress (streaming output) |
|
|
820
|
+
| `tool_execution_end` | Tool completes |
|
|
821
|
+
| `queue_update` | Pending steering/follow-up queue changed |
|
|
822
|
+
| `compaction_start` | Compaction begins |
|
|
823
|
+
| `compaction_end` | Compaction completes |
|
|
824
|
+
| `auto_retry_start` | Auto-retry begins (after transient error) |
|
|
825
|
+
| `auto_retry_end` | Auto-retry completes (success or final failure) |
|
|
826
|
+
| `extension_error` | Extension threw an error |
|
|
827
|
+
|
|
828
|
+
### agent_start
|
|
829
|
+
|
|
830
|
+
Emitted when the agent begins processing a prompt.
|
|
831
|
+
|
|
832
|
+
```json
|
|
833
|
+
{"type": "agent_start"}
|
|
834
|
+
```
|
|
835
|
+
|
|
836
|
+
### agent_end
|
|
837
|
+
|
|
838
|
+
Emitted when one low-level agent run completes. Contains all messages generated during this run. If `willRetry` is true, an automatic retry will follow.
|
|
839
|
+
|
|
840
|
+
```json
|
|
841
|
+
{
|
|
842
|
+
"type": "agent_end",
|
|
843
|
+
"messages": [...],
|
|
844
|
+
"willRetry": false
|
|
845
|
+
}
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
### agent_settled
|
|
849
|
+
|
|
850
|
+
Emitted after the full session-level run settles. At this point Pi will not continue automatically through retry, compaction retry, or queued follow-up messages.
|
|
851
|
+
|
|
852
|
+
```json
|
|
853
|
+
{"type": "agent_settled"}
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
### turn_start / turn_end
|
|
857
|
+
|
|
858
|
+
A turn consists of one assistant response plus any resulting tool calls and results.
|
|
859
|
+
|
|
860
|
+
```json
|
|
861
|
+
{"type": "turn_start"}
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
```json
|
|
865
|
+
{
|
|
866
|
+
"type": "turn_end",
|
|
867
|
+
"message": {...},
|
|
868
|
+
"toolResults": [...]
|
|
869
|
+
}
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
### message_start / message_end
|
|
873
|
+
|
|
874
|
+
Emitted when a message begins and completes. The `message` field contains an `AgentMessage`.
|
|
875
|
+
|
|
876
|
+
```json
|
|
877
|
+
{"type": "message_start", "message": {...}}
|
|
878
|
+
{"type": "message_end", "message": {...}}
|
|
879
|
+
```
|
|
880
|
+
|
|
881
|
+
### message_update (Streaming)
|
|
882
|
+
|
|
883
|
+
Emitted during streaming of assistant messages. Contains both the partial message and a streaming delta event.
|
|
884
|
+
|
|
885
|
+
```json
|
|
886
|
+
{
|
|
887
|
+
"type": "message_update",
|
|
888
|
+
"message": {...},
|
|
889
|
+
"assistantMessageEvent": {
|
|
890
|
+
"type": "text_delta",
|
|
891
|
+
"contentIndex": 0,
|
|
892
|
+
"delta": "Hello ",
|
|
893
|
+
"partial": {...}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
```
|
|
897
|
+
|
|
898
|
+
The `assistantMessageEvent` field contains one of these delta types:
|
|
899
|
+
|
|
900
|
+
| Type | Description |
|
|
901
|
+
|------|-------------|
|
|
902
|
+
| `start` | Message generation started |
|
|
903
|
+
| `text_start` | Text content block started |
|
|
904
|
+
| `text_delta` | Text content chunk |
|
|
905
|
+
| `text_end` | Text content block ended |
|
|
906
|
+
| `thinking_start` | Thinking block started |
|
|
907
|
+
| `thinking_delta` | Thinking content chunk |
|
|
908
|
+
| `thinking_end` | Thinking block ended |
|
|
909
|
+
| `toolcall_start` | Tool call started |
|
|
910
|
+
| `toolcall_delta` | Tool call arguments chunk |
|
|
911
|
+
| `toolcall_end` | Tool call ended (includes full `toolCall` object) |
|
|
912
|
+
| `done` | Message complete (reason: `"stop"`, `"length"`, `"toolUse"`) |
|
|
913
|
+
| `error` | Error occurred (reason: `"aborted"`, `"error"`) |
|
|
914
|
+
|
|
915
|
+
Example streaming a text response:
|
|
916
|
+
```json
|
|
917
|
+
{"type":"message_update","message":{...},"assistantMessageEvent":{"type":"text_start","contentIndex":0,"partial":{...}}}
|
|
918
|
+
{"type":"message_update","message":{...},"assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":"Hello","partial":{...}}}
|
|
919
|
+
{"type":"message_update","message":{...},"assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":" world","partial":{...}}}
|
|
920
|
+
{"type":"message_update","message":{...},"assistantMessageEvent":{"type":"text_end","contentIndex":0,"content":"Hello world","partial":{...}}}
|
|
921
|
+
```
|
|
922
|
+
|
|
923
|
+
### tool_execution_start / tool_execution_update / tool_execution_end
|
|
924
|
+
|
|
925
|
+
Emitted when a tool begins, streams progress, and completes execution.
|
|
926
|
+
|
|
927
|
+
```json
|
|
928
|
+
{
|
|
929
|
+
"type": "tool_execution_start",
|
|
930
|
+
"toolCallId": "call_abc123",
|
|
931
|
+
"toolName": "bash",
|
|
932
|
+
"args": {"command": "ls -la"}
|
|
933
|
+
}
|
|
934
|
+
```
|
|
935
|
+
|
|
936
|
+
During execution, `tool_execution_update` events stream partial results (e.g., bash output as it arrives):
|
|
937
|
+
|
|
938
|
+
```json
|
|
939
|
+
{
|
|
940
|
+
"type": "tool_execution_update",
|
|
941
|
+
"toolCallId": "call_abc123",
|
|
942
|
+
"toolName": "bash",
|
|
943
|
+
"args": {"command": "ls -la"},
|
|
944
|
+
"partialResult": {
|
|
945
|
+
"content": [{"type": "text", "text": "partial output so far..."}],
|
|
946
|
+
"details": {"truncation": null, "fullOutputPath": null}
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
When complete:
|
|
952
|
+
|
|
953
|
+
```json
|
|
954
|
+
{
|
|
955
|
+
"type": "tool_execution_end",
|
|
956
|
+
"toolCallId": "call_abc123",
|
|
957
|
+
"toolName": "bash",
|
|
958
|
+
"result": {
|
|
959
|
+
"content": [{"type": "text", "text": "total 48\n..."}],
|
|
960
|
+
"details": {...}
|
|
961
|
+
},
|
|
962
|
+
"isError": false
|
|
963
|
+
}
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
Use `toolCallId` to correlate events. The `partialResult` in `tool_execution_update` contains the accumulated output so far (not just the delta), allowing clients to simply replace their display on each update.
|
|
967
|
+
|
|
968
|
+
### queue_update
|
|
969
|
+
|
|
970
|
+
Emitted whenever the pending steering or follow-up queue changes.
|
|
971
|
+
|
|
972
|
+
```json
|
|
973
|
+
{
|
|
974
|
+
"type": "queue_update",
|
|
975
|
+
"steering": ["Focus on error handling"],
|
|
976
|
+
"followUp": ["After that, summarize the result"]
|
|
977
|
+
}
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
### compaction_start / compaction_end
|
|
981
|
+
|
|
982
|
+
Emitted when compaction runs, whether manual or automatic.
|
|
983
|
+
|
|
984
|
+
```json
|
|
985
|
+
{"type": "compaction_start", "reason": "threshold"}
|
|
986
|
+
```
|
|
987
|
+
|
|
988
|
+
The `reason` field is `"manual"`, `"threshold"`, or `"overflow"`.
|
|
989
|
+
|
|
990
|
+
```json
|
|
991
|
+
{
|
|
992
|
+
"type": "compaction_end",
|
|
993
|
+
"reason": "threshold",
|
|
994
|
+
"result": {
|
|
995
|
+
"summary": "Summary of conversation...",
|
|
996
|
+
"firstKeptEntryId": "abc123",
|
|
997
|
+
"tokensBefore": 150000,
|
|
998
|
+
"estimatedTokensAfter": 32000,
|
|
999
|
+
"details": {}
|
|
1000
|
+
},
|
|
1001
|
+
"aborted": false,
|
|
1002
|
+
"willRetry": false
|
|
1003
|
+
}
|
|
1004
|
+
```
|
|
1005
|
+
|
|
1006
|
+
If `reason` was `"overflow"` and compaction succeeds, `willRetry` is `true` and the agent will automatically retry the prompt.
|
|
1007
|
+
|
|
1008
|
+
If compaction was aborted, `result` is `null` and `aborted` is `true`.
|
|
1009
|
+
|
|
1010
|
+
If compaction failed (e.g., API quota exceeded), `result` is `null`, `aborted` is `false`, and `errorMessage` contains the error description.
|
|
1011
|
+
|
|
1012
|
+
### auto_retry_start / auto_retry_end
|
|
1013
|
+
|
|
1014
|
+
Emitted when automatic retry is triggered after a transient error (overloaded, rate limit, 5xx).
|
|
1015
|
+
|
|
1016
|
+
```json
|
|
1017
|
+
{
|
|
1018
|
+
"type": "auto_retry_start",
|
|
1019
|
+
"attempt": 1,
|
|
1020
|
+
"maxAttempts": 3,
|
|
1021
|
+
"delayMs": 2000,
|
|
1022
|
+
"errorMessage": "529 {\"type\":\"error\",\"error\":{\"type\":\"overloaded_error\",\"message\":\"Overloaded\"}}"
|
|
1023
|
+
}
|
|
1024
|
+
```
|
|
1025
|
+
|
|
1026
|
+
```json
|
|
1027
|
+
{
|
|
1028
|
+
"type": "auto_retry_end",
|
|
1029
|
+
"success": true,
|
|
1030
|
+
"attempt": 2
|
|
1031
|
+
}
|
|
1032
|
+
```
|
|
1033
|
+
|
|
1034
|
+
On final failure (max retries exceeded):
|
|
1035
|
+
```json
|
|
1036
|
+
{
|
|
1037
|
+
"type": "auto_retry_end",
|
|
1038
|
+
"success": false,
|
|
1039
|
+
"attempt": 3,
|
|
1040
|
+
"finalError": "529 overloaded_error: Overloaded"
|
|
1041
|
+
}
|
|
1042
|
+
```
|
|
1043
|
+
|
|
1044
|
+
### extension_error
|
|
1045
|
+
|
|
1046
|
+
Emitted when an extension throws an error.
|
|
1047
|
+
|
|
1048
|
+
```json
|
|
1049
|
+
{
|
|
1050
|
+
"type": "extension_error",
|
|
1051
|
+
"extensionPath": "/path/to/extension.ts",
|
|
1052
|
+
"event": "tool_call",
|
|
1053
|
+
"error": "Error message..."
|
|
1054
|
+
}
|
|
1055
|
+
```
|
|
1056
|
+
|
|
1057
|
+
## Extension UI Protocol
|
|
1058
|
+
|
|
1059
|
+
Extensions can request user interaction via `ctx.ui.select()`, `ctx.ui.confirm()`, etc. In RPC mode, these are translated into a request/response sub-protocol on top of the base command/event flow.
|
|
1060
|
+
|
|
1061
|
+
There are two categories of extension UI methods:
|
|
1062
|
+
|
|
1063
|
+
- **Dialog methods** (`select`, `confirm`, `input`, `editor`): emit an `extension_ui_request` on stdout and block until the client sends back an `extension_ui_response` on stdin with the matching `id`.
|
|
1064
|
+
- **Fire-and-forget methods** (`notify`, `setStatus`, `setWidget`, `setTitle`, `set_editor_text`): emit an `extension_ui_request` on stdout but do not expect a response. The client can display the information or ignore it.
|
|
1065
|
+
|
|
1066
|
+
If a dialog method includes a `timeout` field, the agent-side will auto-resolve with a default value when the timeout expires. The client does not need to track timeouts.
|
|
1067
|
+
|
|
1068
|
+
Some `ExtensionUIContext` methods are not supported or degraded in RPC mode because they require direct TUI access:
|
|
1069
|
+
- `custom()` returns `undefined`
|
|
1070
|
+
- `setWorkingMessage()`, `setWorkingIndicator()`, `setFooter()`, `setHeader()`, `setEditorComponent()`, `setToolsExpanded()` are no-ops
|
|
1071
|
+
- `getEditorText()` returns `""`
|
|
1072
|
+
- `getToolsExpanded()` returns `false`
|
|
1073
|
+
- `pasteToEditor()` delegates to `setEditorText()` (no paste/collapse handling)
|
|
1074
|
+
- `getAllThemes()` returns `[]`
|
|
1075
|
+
- `getTheme()` returns `undefined`
|
|
1076
|
+
- `setTheme()` returns `{ success: false, error: "..." }`
|
|
1077
|
+
|
|
1078
|
+
Note: `ctx.mode` is `"rpc"` and `ctx.hasUI` is `true` in RPC mode because the dialog and fire-and-forget methods are functional via the extension UI sub-protocol. Use `ctx.mode === "tui"` to guard TUI-specific features like `custom()` that require a real terminal.
|
|
1079
|
+
|
|
1080
|
+
### Extension UI Requests (stdout)
|
|
1081
|
+
|
|
1082
|
+
All requests have `type: "extension_ui_request"`, a unique `id`, and a `method` field.
|
|
1083
|
+
|
|
1084
|
+
#### select
|
|
1085
|
+
|
|
1086
|
+
Prompt the user to choose from a list. Dialog methods with a `timeout` field include the timeout in milliseconds; the agent auto-resolves with `undefined` if the client doesn't respond in time.
|
|
1087
|
+
|
|
1088
|
+
```json
|
|
1089
|
+
{
|
|
1090
|
+
"type": "extension_ui_request",
|
|
1091
|
+
"id": "uuid-1",
|
|
1092
|
+
"method": "select",
|
|
1093
|
+
"title": "Allow dangerous command?",
|
|
1094
|
+
"options": ["Allow", "Block"],
|
|
1095
|
+
"timeout": 10000
|
|
1096
|
+
}
|
|
1097
|
+
```
|
|
1098
|
+
|
|
1099
|
+
Expected response: `extension_ui_response` with `value` (the selected option string) or `cancelled: true`.
|
|
1100
|
+
|
|
1101
|
+
#### confirm
|
|
1102
|
+
|
|
1103
|
+
Prompt the user for yes/no confirmation.
|
|
1104
|
+
|
|
1105
|
+
```json
|
|
1106
|
+
{
|
|
1107
|
+
"type": "extension_ui_request",
|
|
1108
|
+
"id": "uuid-2",
|
|
1109
|
+
"method": "confirm",
|
|
1110
|
+
"title": "Clear session?",
|
|
1111
|
+
"message": "All messages will be lost.",
|
|
1112
|
+
"timeout": 5000
|
|
1113
|
+
}
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1116
|
+
Expected response: `extension_ui_response` with `confirmed: true/false` or `cancelled: true`.
|
|
1117
|
+
|
|
1118
|
+
#### input
|
|
1119
|
+
|
|
1120
|
+
Prompt the user for free-form text.
|
|
1121
|
+
|
|
1122
|
+
```json
|
|
1123
|
+
{
|
|
1124
|
+
"type": "extension_ui_request",
|
|
1125
|
+
"id": "uuid-3",
|
|
1126
|
+
"method": "input",
|
|
1127
|
+
"title": "Enter a value",
|
|
1128
|
+
"placeholder": "type something..."
|
|
1129
|
+
}
|
|
1130
|
+
```
|
|
1131
|
+
|
|
1132
|
+
Expected response: `extension_ui_response` with `value` (the entered text) or `cancelled: true`.
|
|
1133
|
+
|
|
1134
|
+
#### editor
|
|
1135
|
+
|
|
1136
|
+
Open a multi-line text editor with optional prefilled content.
|
|
1137
|
+
|
|
1138
|
+
```json
|
|
1139
|
+
{
|
|
1140
|
+
"type": "extension_ui_request",
|
|
1141
|
+
"id": "uuid-4",
|
|
1142
|
+
"method": "editor",
|
|
1143
|
+
"title": "Edit some text",
|
|
1144
|
+
"prefill": "Line 1\nLine 2\nLine 3"
|
|
1145
|
+
}
|
|
1146
|
+
```
|
|
1147
|
+
|
|
1148
|
+
Expected response: `extension_ui_response` with `value` (the edited text) or `cancelled: true`.
|
|
1149
|
+
|
|
1150
|
+
#### notify
|
|
1151
|
+
|
|
1152
|
+
Display a notification. Fire-and-forget, no response expected.
|
|
1153
|
+
|
|
1154
|
+
```json
|
|
1155
|
+
{
|
|
1156
|
+
"type": "extension_ui_request",
|
|
1157
|
+
"id": "uuid-5",
|
|
1158
|
+
"method": "notify",
|
|
1159
|
+
"message": "Command blocked by user",
|
|
1160
|
+
"notifyType": "warning"
|
|
1161
|
+
}
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1164
|
+
The `notifyType` field is `"info"`, `"warning"`, or `"error"`. Defaults to `"info"` if omitted.
|
|
1165
|
+
|
|
1166
|
+
#### setStatus
|
|
1167
|
+
|
|
1168
|
+
Set or clear a status entry in the footer/status bar. Fire-and-forget.
|
|
1169
|
+
|
|
1170
|
+
```json
|
|
1171
|
+
{
|
|
1172
|
+
"type": "extension_ui_request",
|
|
1173
|
+
"id": "uuid-6",
|
|
1174
|
+
"method": "setStatus",
|
|
1175
|
+
"statusKey": "my-ext",
|
|
1176
|
+
"statusText": "Turn 3 running..."
|
|
1177
|
+
}
|
|
1178
|
+
```
|
|
1179
|
+
|
|
1180
|
+
Send `statusText: undefined` (or omit it) to clear the status entry for that key.
|
|
1181
|
+
|
|
1182
|
+
#### setWidget
|
|
1183
|
+
|
|
1184
|
+
Set or clear a widget (block of text lines) displayed above or below the editor. Fire-and-forget.
|
|
1185
|
+
|
|
1186
|
+
```json
|
|
1187
|
+
{
|
|
1188
|
+
"type": "extension_ui_request",
|
|
1189
|
+
"id": "uuid-7",
|
|
1190
|
+
"method": "setWidget",
|
|
1191
|
+
"widgetKey": "my-ext",
|
|
1192
|
+
"widgetLines": ["--- My Widget ---", "Line 1", "Line 2"],
|
|
1193
|
+
"widgetPlacement": "aboveEditor"
|
|
1194
|
+
}
|
|
1195
|
+
```
|
|
1196
|
+
|
|
1197
|
+
Send `widgetLines: undefined` (or omit it) to clear the widget. The `widgetPlacement` field is `"aboveEditor"` (default) or `"belowEditor"`. Only string arrays are supported in RPC mode; component factories are ignored.
|
|
1198
|
+
|
|
1199
|
+
#### setTitle
|
|
1200
|
+
|
|
1201
|
+
Set the terminal window/tab title. Fire-and-forget.
|
|
1202
|
+
|
|
1203
|
+
```json
|
|
1204
|
+
{
|
|
1205
|
+
"type": "extension_ui_request",
|
|
1206
|
+
"id": "uuid-8",
|
|
1207
|
+
"method": "setTitle",
|
|
1208
|
+
"title": "pi - my project"
|
|
1209
|
+
}
|
|
1210
|
+
```
|
|
1211
|
+
|
|
1212
|
+
#### set_editor_text
|
|
1213
|
+
|
|
1214
|
+
Set the text in the input editor. Fire-and-forget.
|
|
1215
|
+
|
|
1216
|
+
```json
|
|
1217
|
+
{
|
|
1218
|
+
"type": "extension_ui_request",
|
|
1219
|
+
"id": "uuid-9",
|
|
1220
|
+
"method": "set_editor_text",
|
|
1221
|
+
"text": "prefilled text for the user"
|
|
1222
|
+
}
|
|
1223
|
+
```
|
|
1224
|
+
|
|
1225
|
+
### Extension UI Responses (stdin)
|
|
1226
|
+
|
|
1227
|
+
Responses are sent for dialog methods only (`select`, `confirm`, `input`, `editor`). The `id` must match the request.
|
|
1228
|
+
|
|
1229
|
+
#### Value response (select, input, editor)
|
|
1230
|
+
|
|
1231
|
+
```json
|
|
1232
|
+
{"type": "extension_ui_response", "id": "uuid-1", "value": "Allow"}
|
|
1233
|
+
```
|
|
1234
|
+
|
|
1235
|
+
#### Confirmation response (confirm)
|
|
1236
|
+
|
|
1237
|
+
```json
|
|
1238
|
+
{"type": "extension_ui_response", "id": "uuid-2", "confirmed": true}
|
|
1239
|
+
```
|
|
1240
|
+
|
|
1241
|
+
#### Cancellation response (any dialog)
|
|
1242
|
+
|
|
1243
|
+
Dismiss any dialog method. The extension receives `undefined` (for select/input/editor) or `false` (for confirm).
|
|
1244
|
+
|
|
1245
|
+
```json
|
|
1246
|
+
{"type": "extension_ui_response", "id": "uuid-3", "cancelled": true}
|
|
1247
|
+
```
|
|
1248
|
+
|
|
1249
|
+
## Error Handling
|
|
1250
|
+
|
|
1251
|
+
Failed commands return a response with `success: false`:
|
|
1252
|
+
|
|
1253
|
+
```json
|
|
1254
|
+
{
|
|
1255
|
+
"type": "response",
|
|
1256
|
+
"command": "set_model",
|
|
1257
|
+
"success": false,
|
|
1258
|
+
"error": "Model not found: invalid/model"
|
|
1259
|
+
}
|
|
1260
|
+
```
|
|
1261
|
+
|
|
1262
|
+
Parse errors:
|
|
1263
|
+
|
|
1264
|
+
```json
|
|
1265
|
+
{
|
|
1266
|
+
"type": "response",
|
|
1267
|
+
"command": "parse",
|
|
1268
|
+
"success": false,
|
|
1269
|
+
"error": "Failed to parse command: Unexpected token..."
|
|
1270
|
+
}
|
|
1271
|
+
```
|
|
1272
|
+
|
|
1273
|
+
## Types
|
|
1274
|
+
|
|
1275
|
+
Source files:
|
|
1276
|
+
- [`packages/ai/src/types.ts`](../../ai/src/types.ts) - `Model`, `UserMessage`, `AssistantMessage`, `ToolResultMessage`
|
|
1277
|
+
- [`packages/agent/src/types.ts`](../../agent/src/types.ts) - `AgentMessage`, `AgentEvent`
|
|
1278
|
+
- [`src/core/messages.ts`](../src/core/messages.ts) - `BashExecutionMessage`
|
|
1279
|
+
- [`src/modes/rpc/rpc-types.ts`](../src/modes/rpc/rpc-types.ts) - RPC command/response types, extension UI request/response types
|
|
1280
|
+
|
|
1281
|
+
### Model
|
|
1282
|
+
|
|
1283
|
+
```json
|
|
1284
|
+
{
|
|
1285
|
+
"id": "claude-sonnet-4-20250514",
|
|
1286
|
+
"name": "Claude Sonnet 4",
|
|
1287
|
+
"api": "anthropic-messages",
|
|
1288
|
+
"provider": "anthropic",
|
|
1289
|
+
"baseUrl": "https://api.anthropic.com",
|
|
1290
|
+
"reasoning": true,
|
|
1291
|
+
"input": ["text", "image"],
|
|
1292
|
+
"contextWindow": 200000,
|
|
1293
|
+
"maxTokens": 16384,
|
|
1294
|
+
"cost": {
|
|
1295
|
+
"input": 3.0,
|
|
1296
|
+
"output": 15.0,
|
|
1297
|
+
"cacheRead": 0.3,
|
|
1298
|
+
"cacheWrite": 3.75
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
```
|
|
1302
|
+
|
|
1303
|
+
### UserMessage
|
|
1304
|
+
|
|
1305
|
+
```json
|
|
1306
|
+
{
|
|
1307
|
+
"role": "user",
|
|
1308
|
+
"content": "Hello!",
|
|
1309
|
+
"timestamp": 1733234567890,
|
|
1310
|
+
"attachments": []
|
|
1311
|
+
}
|
|
1312
|
+
```
|
|
1313
|
+
|
|
1314
|
+
The `content` field can be a string or an array of `TextContent`/`ImageContent` blocks.
|
|
1315
|
+
|
|
1316
|
+
### AssistantMessage
|
|
1317
|
+
|
|
1318
|
+
```json
|
|
1319
|
+
{
|
|
1320
|
+
"role": "assistant",
|
|
1321
|
+
"content": [
|
|
1322
|
+
{"type": "text", "text": "Hello! How can I help?"},
|
|
1323
|
+
{"type": "thinking", "thinking": "User is greeting me..."},
|
|
1324
|
+
{"type": "toolCall", "id": "call_123", "name": "bash", "arguments": {"command": "ls"}}
|
|
1325
|
+
],
|
|
1326
|
+
"api": "anthropic-messages",
|
|
1327
|
+
"provider": "anthropic",
|
|
1328
|
+
"model": "claude-sonnet-4-20250514",
|
|
1329
|
+
"usage": {
|
|
1330
|
+
"input": 100,
|
|
1331
|
+
"output": 50,
|
|
1332
|
+
"cacheRead": 0,
|
|
1333
|
+
"cacheWrite": 0,
|
|
1334
|
+
"cost": {"input": 0.0003, "output": 0.00075, "cacheRead": 0, "cacheWrite": 0, "total": 0.00105}
|
|
1335
|
+
},
|
|
1336
|
+
"stopReason": "stop",
|
|
1337
|
+
"timestamp": 1733234567890
|
|
1338
|
+
}
|
|
1339
|
+
```
|
|
1340
|
+
|
|
1341
|
+
Stop reasons: `"stop"`, `"length"`, `"toolUse"`, `"error"`, `"aborted"`
|
|
1342
|
+
|
|
1343
|
+
### ToolResultMessage
|
|
1344
|
+
|
|
1345
|
+
```json
|
|
1346
|
+
{
|
|
1347
|
+
"role": "toolResult",
|
|
1348
|
+
"toolCallId": "call_123",
|
|
1349
|
+
"toolName": "bash",
|
|
1350
|
+
"content": [{"type": "text", "text": "total 48\ndrwxr-xr-x ..."}],
|
|
1351
|
+
"isError": false,
|
|
1352
|
+
"timestamp": 1733234567890
|
|
1353
|
+
}
|
|
1354
|
+
```
|
|
1355
|
+
|
|
1356
|
+
### BashExecutionMessage
|
|
1357
|
+
|
|
1358
|
+
Created by the `bash` RPC command (not by LLM tool calls):
|
|
1359
|
+
|
|
1360
|
+
```json
|
|
1361
|
+
{
|
|
1362
|
+
"role": "bashExecution",
|
|
1363
|
+
"command": "ls -la",
|
|
1364
|
+
"output": "total 48\ndrwxr-xr-x ...",
|
|
1365
|
+
"exitCode": 0,
|
|
1366
|
+
"cancelled": false,
|
|
1367
|
+
"truncated": false,
|
|
1368
|
+
"fullOutputPath": null,
|
|
1369
|
+
"timestamp": 1733234567890
|
|
1370
|
+
}
|
|
1371
|
+
```
|
|
1372
|
+
|
|
1373
|
+
### Attachment
|
|
1374
|
+
|
|
1375
|
+
```json
|
|
1376
|
+
{
|
|
1377
|
+
"id": "img1",
|
|
1378
|
+
"type": "image",
|
|
1379
|
+
"fileName": "photo.jpg",
|
|
1380
|
+
"mimeType": "image/jpeg",
|
|
1381
|
+
"size": 102400,
|
|
1382
|
+
"content": "base64-encoded-data...",
|
|
1383
|
+
"extractedText": null,
|
|
1384
|
+
"preview": null
|
|
1385
|
+
}
|
|
1386
|
+
```
|
|
1387
|
+
|
|
1388
|
+
## Example: Basic Client (Python)
|
|
1389
|
+
|
|
1390
|
+
```python
|
|
1391
|
+
import subprocess
|
|
1392
|
+
import json
|
|
1393
|
+
|
|
1394
|
+
proc = subprocess.Popen(
|
|
1395
|
+
["pi", "--mode", "rpc", "--no-session"],
|
|
1396
|
+
stdin=subprocess.PIPE,
|
|
1397
|
+
stdout=subprocess.PIPE,
|
|
1398
|
+
text=True
|
|
1399
|
+
)
|
|
1400
|
+
|
|
1401
|
+
def send(cmd):
|
|
1402
|
+
proc.stdin.write(json.dumps(cmd) + "\n")
|
|
1403
|
+
proc.stdin.flush()
|
|
1404
|
+
|
|
1405
|
+
def read_events():
|
|
1406
|
+
for line in proc.stdout:
|
|
1407
|
+
yield json.loads(line)
|
|
1408
|
+
|
|
1409
|
+
# Send prompt
|
|
1410
|
+
send({"type": "prompt", "message": "Hello!"})
|
|
1411
|
+
|
|
1412
|
+
# Process events
|
|
1413
|
+
for event in read_events():
|
|
1414
|
+
if event.get("type") == "message_update":
|
|
1415
|
+
delta = event.get("assistantMessageEvent", {})
|
|
1416
|
+
if delta.get("type") == "text_delta":
|
|
1417
|
+
print(delta["delta"], end="", flush=True)
|
|
1418
|
+
|
|
1419
|
+
if event.get("type") == "agent_end":
|
|
1420
|
+
print()
|
|
1421
|
+
break
|
|
1422
|
+
```
|
|
1423
|
+
|
|
1424
|
+
## Example: Interactive Client (Node.js)
|
|
1425
|
+
|
|
1426
|
+
See [`test/rpc-example.ts`](../test/rpc-example.ts) for a complete interactive example, or [`src/modes/rpc/rpc-client.ts`](../src/modes/rpc/rpc-client.ts) for a typed client implementation.
|
|
1427
|
+
|
|
1428
|
+
For a complete example of handling the extension UI protocol, see [`examples/rpc-extension-ui.ts`](../examples/rpc-extension-ui.ts) which pairs with the [`examples/extensions/rpc-demo.ts`](../examples/extensions/rpc-demo.ts) extension.
|
|
1429
|
+
|
|
1430
|
+
```javascript
|
|
1431
|
+
const { spawn } = require("child_process");
|
|
1432
|
+
const { StringDecoder } = require("string_decoder");
|
|
1433
|
+
|
|
1434
|
+
const agent = spawn("pi", ["--mode", "rpc", "--no-session"]);
|
|
1435
|
+
|
|
1436
|
+
function attachJsonlReader(stream, onLine) {
|
|
1437
|
+
const decoder = new StringDecoder("utf8");
|
|
1438
|
+
let buffer = "";
|
|
1439
|
+
|
|
1440
|
+
stream.on("data", (chunk) => {
|
|
1441
|
+
buffer += typeof chunk === "string" ? chunk : decoder.write(chunk);
|
|
1442
|
+
|
|
1443
|
+
while (true) {
|
|
1444
|
+
const newlineIndex = buffer.indexOf("\n");
|
|
1445
|
+
if (newlineIndex === -1) break;
|
|
1446
|
+
|
|
1447
|
+
let line = buffer.slice(0, newlineIndex);
|
|
1448
|
+
buffer = buffer.slice(newlineIndex + 1);
|
|
1449
|
+
if (line.endsWith("\r")) line = line.slice(0, -1);
|
|
1450
|
+
onLine(line);
|
|
1451
|
+
}
|
|
1452
|
+
});
|
|
1453
|
+
|
|
1454
|
+
stream.on("end", () => {
|
|
1455
|
+
buffer += decoder.end();
|
|
1456
|
+
if (buffer.length > 0) {
|
|
1457
|
+
onLine(buffer.endsWith("\r") ? buffer.slice(0, -1) : buffer);
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
attachJsonlReader(agent.stdout, (line) => {
|
|
1463
|
+
const event = JSON.parse(line);
|
|
1464
|
+
|
|
1465
|
+
if (event.type === "message_update") {
|
|
1466
|
+
const { assistantMessageEvent } = event;
|
|
1467
|
+
if (assistantMessageEvent.type === "text_delta") {
|
|
1468
|
+
process.stdout.write(assistantMessageEvent.delta);
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
|
|
1473
|
+
// Send prompt
|
|
1474
|
+
agent.stdin.write(JSON.stringify({ type: "prompt", message: "Hello" }) + "\n");
|
|
1475
|
+
|
|
1476
|
+
// Abort on Ctrl+C
|
|
1477
|
+
process.on("SIGINT", () => {
|
|
1478
|
+
agent.stdin.write(JSON.stringify({ type: "abort" }) + "\n");
|
|
1479
|
+
});
|
|
1480
|
+
```
|