@tuan_son.dinh/gsd 2.6.3 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cli.js +24 -10
- package/dist/loader.js +21 -3
- package/dist/logo.d.ts +3 -3
- package/dist/logo.js +2 -2
- package/dist/onboarding.d.ts +3 -3
- package/dist/onboarding.js +3 -4
- package/dist/pi-migration.d.ts +5 -1
- package/dist/pi-migration.js +19 -2
- package/dist/resource-loader.d.ts +2 -1
- package/dist/resource-loader.js +60 -4
- package/dist/wizard.d.ts +1 -1
- package/package.json +12 -6
- package/packages/pi-agent-core/dist/agent-loop.d.ts +21 -0
- package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/agent-loop.js +308 -0
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -0
- package/packages/pi-agent-core/dist/agent.d.ts +162 -0
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/agent.js +399 -0
- package/packages/pi-agent-core/dist/agent.js.map +1 -0
- package/packages/pi-agent-core/dist/index.d.ts +5 -0
- package/packages/pi-agent-core/dist/index.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/index.js +9 -0
- package/packages/pi-agent-core/dist/index.js.map +1 -0
- package/packages/pi-agent-core/dist/proxy.d.ts +85 -0
- package/packages/pi-agent-core/dist/proxy.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/proxy.js +268 -0
- package/packages/pi-agent-core/dist/proxy.js.map +1 -0
- package/packages/pi-agent-core/dist/types.d.ts +178 -0
- package/packages/pi-agent-core/dist/types.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/types.js +2 -0
- package/packages/pi-agent-core/dist/types.js.map +1 -0
- package/packages/pi-agent-core/package.json +14 -0
- package/packages/pi-agent-core/src/agent-loop.ts +417 -0
- package/packages/pi-agent-core/src/agent.ts +568 -0
- package/packages/pi-agent-core/src/index.ts +8 -0
- package/packages/pi-agent-core/src/proxy.ts +340 -0
- package/packages/pi-agent-core/src/types.ts +194 -0
- package/packages/pi-agent-core/tsconfig.json +27 -0
- package/packages/pi-ai/bedrock-provider.d.ts +1 -0
- package/packages/pi-ai/bedrock-provider.js +1 -0
- package/packages/pi-ai/dist/api-registry.d.ts +20 -0
- package/packages/pi-ai/dist/api-registry.d.ts.map +1 -0
- package/packages/pi-ai/dist/api-registry.js +44 -0
- package/packages/pi-ai/dist/api-registry.js.map +1 -0
- package/packages/pi-ai/dist/bedrock-provider.d.ts +5 -0
- package/packages/pi-ai/dist/bedrock-provider.d.ts.map +1 -0
- package/packages/pi-ai/dist/bedrock-provider.js +6 -0
- package/packages/pi-ai/dist/bedrock-provider.js.map +1 -0
- package/packages/pi-ai/dist/cli.d.ts +3 -0
- package/packages/pi-ai/dist/cli.d.ts.map +1 -0
- package/packages/pi-ai/dist/cli.js +116 -0
- package/packages/pi-ai/dist/cli.js.map +1 -0
- package/packages/pi-ai/dist/env-api-keys.d.ts +9 -0
- package/packages/pi-ai/dist/env-api-keys.d.ts.map +1 -0
- package/packages/pi-ai/dist/env-api-keys.js +104 -0
- package/packages/pi-ai/dist/env-api-keys.js.map +1 -0
- package/packages/pi-ai/dist/index.d.ts +23 -0
- package/packages/pi-ai/dist/index.d.ts.map +1 -0
- package/packages/pi-ai/dist/index.js +21 -0
- package/packages/pi-ai/dist/index.js.map +1 -0
- package/packages/pi-ai/dist/models.d.ts +24 -0
- package/packages/pi-ai/dist/models.d.ts.map +1 -0
- package/packages/pi-ai/dist/models.generated.d.ts +13572 -0
- package/packages/pi-ai/dist/models.generated.d.ts.map +1 -0
- package/packages/pi-ai/dist/models.generated.js +13368 -0
- package/packages/pi-ai/dist/models.generated.js.map +1 -0
- package/packages/pi-ai/dist/models.js +55 -0
- package/packages/pi-ai/dist/models.js.map +1 -0
- package/packages/pi-ai/dist/oauth.d.ts +2 -0
- package/packages/pi-ai/dist/oauth.d.ts.map +1 -0
- package/packages/pi-ai/dist/oauth.js +2 -0
- package/packages/pi-ai/dist/oauth.js.map +1 -0
- package/packages/pi-ai/dist/providers/amazon-bedrock.d.ts +15 -0
- package/packages/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/amazon-bedrock.js +600 -0
- package/packages/pi-ai/dist/providers/amazon-bedrock.js.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic.d.ts +33 -0
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic.js +732 -0
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -0
- package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts +15 -0
- package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/azure-openai-responses.js +187 -0
- package/packages/pi-ai/dist/providers/azure-openai-responses.js.map +1 -0
- package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts +8 -0
- package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/github-copilot-headers.js +29 -0
- package/packages/pi-ai/dist/providers/github-copilot-headers.js.map +1 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts +74 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.js +757 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -0
- package/packages/pi-ai/dist/providers/google-shared.d.ts +65 -0
- package/packages/pi-ai/dist/providers/google-shared.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/google-shared.js +300 -0
- package/packages/pi-ai/dist/providers/google-shared.js.map +1 -0
- package/packages/pi-ai/dist/providers/google-vertex.d.ts +15 -0
- package/packages/pi-ai/dist/providers/google-vertex.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/google-vertex.js +374 -0
- package/packages/pi-ai/dist/providers/google-vertex.js.map +1 -0
- package/packages/pi-ai/dist/providers/google.d.ts +13 -0
- package/packages/pi-ai/dist/providers/google.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/google.js +355 -0
- package/packages/pi-ai/dist/providers/google.js.map +1 -0
- package/packages/pi-ai/dist/providers/mistral.d.ts +22 -0
- package/packages/pi-ai/dist/providers/mistral.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/mistral.js +498 -0
- package/packages/pi-ai/dist/providers/mistral.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts +9 -0
- package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-codex-responses.js +704 -0
- package/packages/pi-ai/dist/providers/openai-codex-responses.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-completions.d.ts +15 -0
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-completions.js +705 -0
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-responses-shared.d.ts +17 -0
- package/packages/pi-ai/dist/providers/openai-responses-shared.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-responses-shared.js +442 -0
- package/packages/pi-ai/dist/providers/openai-responses-shared.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-responses.d.ts +13 -0
- package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-responses.js +201 -0
- package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -0
- package/packages/pi-ai/dist/providers/register-builtins.d.ts +11 -0
- package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/register-builtins.js +138 -0
- package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -0
- package/packages/pi-ai/dist/providers/simple-options.d.ts +8 -0
- package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/simple-options.js +35 -0
- package/packages/pi-ai/dist/providers/simple-options.js.map +1 -0
- package/packages/pi-ai/dist/providers/transform-messages.d.ts +8 -0
- package/packages/pi-ai/dist/providers/transform-messages.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/transform-messages.js +155 -0
- package/packages/pi-ai/dist/providers/transform-messages.js.map +1 -0
- package/packages/pi-ai/dist/stream.d.ts +8 -0
- package/packages/pi-ai/dist/stream.d.ts.map +1 -0
- package/packages/pi-ai/dist/stream.js +27 -0
- package/packages/pi-ai/dist/stream.js.map +1 -0
- package/packages/pi-ai/dist/types.d.ts +285 -0
- package/packages/pi-ai/dist/types.d.ts.map +1 -0
- package/packages/pi-ai/dist/types.js +2 -0
- package/packages/pi-ai/dist/types.js.map +1 -0
- package/packages/pi-ai/dist/utils/event-stream.d.ts +21 -0
- package/packages/pi-ai/dist/utils/event-stream.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/event-stream.js +77 -0
- package/packages/pi-ai/dist/utils/event-stream.js.map +1 -0
- package/packages/pi-ai/dist/utils/hash.d.ts +3 -0
- package/packages/pi-ai/dist/utils/hash.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/hash.js +14 -0
- package/packages/pi-ai/dist/utils/hash.js.map +1 -0
- package/packages/pi-ai/dist/utils/json-parse.d.ts +9 -0
- package/packages/pi-ai/dist/utils/json-parse.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/json-parse.js +29 -0
- package/packages/pi-ai/dist/utils/json-parse.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/anthropic.d.ts +17 -0
- package/packages/pi-ai/dist/utils/oauth/anthropic.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/anthropic.js +104 -0
- package/packages/pi-ai/dist/utils/oauth/anthropic.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts +30 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js +281 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts +26 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.js +373 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts +26 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js +478 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/index.d.ts +61 -0
- package/packages/pi-ai/dist/utils/oauth/index.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/index.js +131 -0
- package/packages/pi-ai/dist/utils/oauth/index.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/openai-codex.d.ts +34 -0
- package/packages/pi-ai/dist/utils/oauth/openai-codex.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/openai-codex.js +380 -0
- package/packages/pi-ai/dist/utils/oauth/openai-codex.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/pkce.d.ts +13 -0
- package/packages/pi-ai/dist/utils/oauth/pkce.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/pkce.js +31 -0
- package/packages/pi-ai/dist/utils/oauth/pkce.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/types.d.ts +47 -0
- package/packages/pi-ai/dist/utils/oauth/types.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/types.js +2 -0
- package/packages/pi-ai/dist/utils/oauth/types.js.map +1 -0
- package/packages/pi-ai/dist/utils/overflow.d.ts +52 -0
- package/packages/pi-ai/dist/utils/overflow.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/overflow.js +117 -0
- package/packages/pi-ai/dist/utils/overflow.js.map +1 -0
- package/packages/pi-ai/dist/utils/sanitize-unicode.d.ts +22 -0
- package/packages/pi-ai/dist/utils/sanitize-unicode.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/sanitize-unicode.js +26 -0
- package/packages/pi-ai/dist/utils/sanitize-unicode.js.map +1 -0
- package/packages/pi-ai/dist/utils/typebox-helpers.d.ts +17 -0
- package/packages/pi-ai/dist/utils/typebox-helpers.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/typebox-helpers.js +21 -0
- package/packages/pi-ai/dist/utils/typebox-helpers.js.map +1 -0
- package/packages/pi-ai/dist/utils/validation.d.ts +18 -0
- package/packages/pi-ai/dist/utils/validation.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/validation.js +72 -0
- package/packages/pi-ai/dist/utils/validation.js.map +1 -0
- package/packages/pi-ai/package.json +40 -0
- package/packages/pi-ai/src/api-registry.ts +98 -0
- package/packages/pi-ai/src/bedrock-provider.ts +6 -0
- package/packages/pi-ai/src/cli.ts +133 -0
- package/packages/pi-ai/src/env-api-keys.ts +129 -0
- package/packages/pi-ai/src/index.ts +32 -0
- package/packages/pi-ai/src/models.generated.ts +13370 -0
- package/packages/pi-ai/src/models.ts +77 -0
- package/packages/pi-ai/src/oauth.ts +1 -0
- package/packages/pi-ai/src/providers/amazon-bedrock.ts +751 -0
- package/packages/pi-ai/src/providers/anthropic.ts +883 -0
- package/packages/pi-ai/src/providers/azure-openai-responses.ts +259 -0
- package/packages/pi-ai/src/providers/github-copilot-headers.ts +37 -0
- package/packages/pi-ai/src/providers/google-gemini-cli.ts +967 -0
- package/packages/pi-ai/src/providers/google-shared.ts +313 -0
- package/packages/pi-ai/src/providers/google-vertex.ts +485 -0
- package/packages/pi-ai/src/providers/google.ts +455 -0
- package/packages/pi-ai/src/providers/mistral.ts +582 -0
- package/packages/pi-ai/src/providers/openai-codex-responses.ts +875 -0
- package/packages/pi-ai/src/providers/openai-completions.ts +820 -0
- package/packages/pi-ai/src/providers/openai-responses-shared.ts +496 -0
- package/packages/pi-ai/src/providers/openai-responses.ts +262 -0
- package/packages/pi-ai/src/providers/register-builtins.ts +186 -0
- package/packages/pi-ai/src/providers/simple-options.ts +46 -0
- package/packages/pi-ai/src/providers/transform-messages.ts +172 -0
- package/packages/pi-ai/src/stream.ts +59 -0
- package/packages/pi-ai/src/types.ts +321 -0
- package/packages/pi-ai/src/utils/event-stream.ts +87 -0
- package/packages/pi-ai/src/utils/hash.ts +13 -0
- package/packages/pi-ai/src/utils/json-parse.ts +28 -0
- package/packages/pi-ai/src/utils/oauth/anthropic.ts +138 -0
- package/packages/pi-ai/src/utils/oauth/github-copilot.ts +381 -0
- package/packages/pi-ai/src/utils/oauth/google-antigravity.ts +457 -0
- package/packages/pi-ai/src/utils/oauth/google-gemini-cli.ts +599 -0
- package/packages/pi-ai/src/utils/oauth/index.ts +162 -0
- package/packages/pi-ai/src/utils/oauth/openai-codex.ts +455 -0
- package/packages/pi-ai/src/utils/oauth/pkce.ts +34 -0
- package/packages/pi-ai/src/utils/oauth/types.ts +59 -0
- package/packages/pi-ai/src/utils/overflow.ts +123 -0
- package/packages/pi-ai/src/utils/sanitize-unicode.ts +25 -0
- package/packages/pi-ai/src/utils/typebox-helpers.ts +24 -0
- package/packages/pi-ai/src/utils/validation.ts +84 -0
- package/packages/pi-ai/tsconfig.json +27 -0
- package/packages/pi-coding-agent/dist/cli/args.d.ts +48 -0
- package/packages/pi-coding-agent/dist/cli/args.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/cli/args.js +299 -0
- package/packages/pi-coding-agent/dist/cli/args.js.map +1 -0
- package/packages/pi-coding-agent/dist/cli/config-selector.d.ts +14 -0
- package/packages/pi-coding-agent/dist/cli/config-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/cli/config-selector.js +31 -0
- package/packages/pi-coding-agent/dist/cli/config-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/cli/file-processor.d.ts +15 -0
- package/packages/pi-coding-agent/dist/cli/file-processor.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/cli/file-processor.js +79 -0
- package/packages/pi-coding-agent/dist/cli/file-processor.js.map +1 -0
- package/packages/pi-coding-agent/dist/cli/list-models.d.ts +9 -0
- package/packages/pi-coding-agent/dist/cli/list-models.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/cli/list-models.js +92 -0
- package/packages/pi-coding-agent/dist/cli/list-models.js.map +1 -0
- package/packages/pi-coding-agent/dist/cli/session-picker.d.ts +9 -0
- package/packages/pi-coding-agent/dist/cli/session-picker.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/cli/session-picker.js +34 -0
- package/packages/pi-coding-agent/dist/cli/session-picker.js.map +1 -0
- package/packages/pi-coding-agent/dist/cli.d.ts +3 -0
- package/packages/pi-coding-agent/dist/cli.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/cli.js +16 -0
- package/packages/pi-coding-agent/dist/cli.js.map +1 -0
- package/packages/pi-coding-agent/dist/config.d.ts +68 -0
- package/packages/pi-coding-agent/dist/config.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/config.js +203 -0
- package/packages/pi-coding-agent/dist/config.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +618 -0
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/agent-session.js +2481 -0
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +134 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.js +415 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/bash-executor.d.ts +47 -0
- package/packages/pi-coding-agent/dist/core/bash-executor.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/bash-executor.js +212 -0
- package/packages/pi-coding-agent/dist/core/bash-executor.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts +86 -0
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js +242 -0
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts +121 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js +610 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/index.d.ts +7 -0
- package/packages/pi-coding-agent/dist/core/compaction/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/index.js +7 -0
- package/packages/pi-coding-agent/dist/core/compaction/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts +38 -0
- package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/utils.js +153 -0
- package/packages/pi-coding-agent/dist/core/compaction/utils.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/defaults.d.ts +3 -0
- package/packages/pi-coding-agent/dist/core/defaults.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/defaults.js +2 -0
- package/packages/pi-coding-agent/dist/core/defaults.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/diagnostics.d.ts +15 -0
- package/packages/pi-coding-agent/dist/core/diagnostics.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/diagnostics.js +2 -0
- package/packages/pi-coding-agent/dist/core/diagnostics.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/event-bus.d.ts +9 -0
- package/packages/pi-coding-agent/dist/core/event-bus.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/event-bus.js +25 -0
- package/packages/pi-coding-agent/dist/core/event-bus.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/exec.d.ts +29 -0
- package/packages/pi-coding-agent/dist/core/exec.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/exec.js +71 -0
- package/packages/pi-coding-agent/dist/core/exec.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js +249 -0
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/index.d.ts +37 -0
- package/packages/pi-coding-agent/dist/core/export-html/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/index.js +223 -0
- package/packages/pi-coding-agent/dist/core/export-html/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/template.css +971 -0
- package/packages/pi-coding-agent/dist/core/export-html/template.html +54 -0
- package/packages/pi-coding-agent/dist/core/export-html/template.js +1583 -0
- package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.d.ts +38 -0
- package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.js +70 -0
- package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/vendor/.gitkeep +0 -0
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +11 -0
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/index.js +9 -0
- package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts +25 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +426 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +147 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +672 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +1040 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.js +35 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/wrapper.d.ts +27 -0
- package/packages/pi-coding-agent/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/wrapper.js +102 -0
- package/packages/pi-coding-agent/dist/core/extensions/wrapper.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/footer-data-provider.d.ts +32 -0
- package/packages/pi-coding-agent/dist/core/footer-data-provider.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/footer-data-provider.js +134 -0
- package/packages/pi-coding-agent/dist/core/footer-data-provider.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/index.d.ts +9 -0
- package/packages/pi-coding-agent/dist/core/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/index.js +9 -0
- package/packages/pi-coding-agent/dist/core/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/keybindings.d.ts +55 -0
- package/packages/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/keybindings.js +151 -0
- package/packages/pi-coding-agent/dist/core/keybindings.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/messages.d.ts +77 -0
- package/packages/pi-coding-agent/dist/core/messages.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/messages.js +123 -0
- package/packages/pi-coding-agent/dist/core/messages.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts +113 -0
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry.js +537 -0
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.d.ts +104 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.js +462 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/package-manager.d.ts +156 -0
- package/packages/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/package-manager.js +1442 -0
- package/packages/pi-coding-agent/dist/core/package-manager.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts +50 -0
- package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/prompt-templates.js +251 -0
- package/packages/pi-coding-agent/dist/core/prompt-templates.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/resolve-config-value.d.ts +17 -0
- package/packages/pi-coding-agent/dist/core/resolve-config-value.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/resolve-config-value.js +59 -0
- package/packages/pi-coding-agent/dist/core/resolve-config-value.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/resource-loader.d.ts +184 -0
- package/packages/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/resource-loader.js +633 -0
- package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk.d.ts +90 -0
- package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk.js +242 -0
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts +323 -0
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager.js +1094 -0
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +232 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js +682 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/skills.d.ts +58 -0
- package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/skills.js +364 -0
- package/packages/pi-coding-agent/dist/core/skills.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/slash-commands.d.ts +15 -0
- package/packages/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/slash-commands.js +22 -0
- package/packages/pi-coding-agent/dist/core/slash-commands.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts +28 -0
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/system-prompt.js +159 -0
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/timings.d.ts +7 -0
- package/packages/pi-coding-agent/dist/core/timings.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/timings.js +25 -0
- package/packages/pi-coding-agent/dist/core/timings.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.d.ts +55 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.js +269 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.d.ts +63 -0
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.js +243 -0
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/edit.d.ts +39 -0
- package/packages/pi-coding-agent/dist/core/tools/edit.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/edit.js +146 -0
- package/packages/pi-coding-agent/dist/core/tools/edit.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/find.d.ts +39 -0
- package/packages/pi-coding-agent/dist/core/tools/find.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/find.js +206 -0
- package/packages/pi-coding-agent/dist/core/tools/find.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/grep.d.ts +45 -0
- package/packages/pi-coding-agent/dist/core/tools/grep.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/grep.js +239 -0
- package/packages/pi-coding-agent/dist/core/tools/grep.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts +73 -0
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/index.js +61 -0
- package/packages/pi-coding-agent/dist/core/tools/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/ls.d.ts +40 -0
- package/packages/pi-coding-agent/dist/core/tools/ls.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/ls.js +118 -0
- package/packages/pi-coding-agent/dist/core/tools/ls.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/path-utils.d.ts +8 -0
- package/packages/pi-coding-agent/dist/core/tools/path-utils.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/path-utils.js +81 -0
- package/packages/pi-coding-agent/dist/core/tools/path-utils.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/read.d.ts +39 -0
- package/packages/pi-coding-agent/dist/core/tools/read.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/read.js +166 -0
- package/packages/pi-coding-agent/dist/core/tools/read.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/truncate.d.ts +70 -0
- package/packages/pi-coding-agent/dist/core/tools/truncate.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/truncate.js +205 -0
- package/packages/pi-coding-agent/dist/core/tools/truncate.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/write.d.ts +29 -0
- package/packages/pi-coding-agent/dist/core/tools/write.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/write.js +78 -0
- package/packages/pi-coding-agent/dist/core/tools/write.js.map +1 -0
- package/packages/pi-coding-agent/dist/index.d.ts +27 -0
- package/packages/pi-coding-agent/dist/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/index.js +42 -0
- package/packages/pi-coding-agent/dist/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/main.d.ts +8 -0
- package/packages/pi-coding-agent/dist/main.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/main.js +691 -0
- package/packages/pi-coding-agent/dist/main.js.map +1 -0
- package/packages/pi-coding-agent/dist/migrations.d.ts +33 -0
- package/packages/pi-coding-agent/dist/migrations.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/migrations.js +261 -0
- package/packages/pi-coding-agent/dist/migrations.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/index.d.ts +9 -0
- package/packages/pi-coding-agent/dist/modes/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/index.js +8 -0
- package/packages/pi-coding-agent/dist/modes/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/armin.d.ts +34 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/armin.js +329 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/armin.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts +16 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js +92 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts +35 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.js +156 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.js +48 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js +42 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js +43 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.js +470 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js +28 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.js +63 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.js +74 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.js +138 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts +12 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js +133 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js +20 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts +20 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.js +106 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js +55 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.d.ts +24 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.js +71 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts +26 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +196 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/index.d.ts +32 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/index.js +33 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.d.ts +41 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js +61 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts +42 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +139 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts +47 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js +259 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.js +92 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.js +271 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js +825 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts +58 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +295 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.js +34 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js +45 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.js +44 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js +46 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +77 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +773 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts +87 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js +1026 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.js +110 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts +9 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js +27 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +330 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +3755 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/dark.json +86 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/light.json +85 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +78 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +944 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/print-mode.d.ts +28 -0
- package/packages/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/print-mode.js +101 -0
- package/packages/pi-coding-agent/dist/modes/print-mode.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/jsonl.d.ts +17 -0
- package/packages/pi-coding-agent/dist/modes/rpc/jsonl.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/jsonl.js +49 -0
- package/packages/pi-coding-agent/dist/modes/rpc/jsonl.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.d.ts +217 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.js +400 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +509 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts +409 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.js +8 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/changelog.d.ts +21 -0
- package/packages/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/changelog.js +87 -0
- package/packages/pi-coding-agent/dist/utils/changelog.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts +11 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-image.js +162 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-image.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-native.d.ts +7 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-native.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-native.js +14 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-native.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/clipboard.d.ts +2 -0
- package/packages/pi-coding-agent/dist/utils/clipboard.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/clipboard.js +67 -0
- package/packages/pi-coding-agent/dist/utils/clipboard.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/frontmatter.d.ts +8 -0
- package/packages/pi-coding-agent/dist/utils/frontmatter.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/frontmatter.js +26 -0
- package/packages/pi-coding-agent/dist/utils/frontmatter.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/git.d.ts +26 -0
- package/packages/pi-coding-agent/dist/utils/git.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/git.js +163 -0
- package/packages/pi-coding-agent/dist/utils/git.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/image-convert.d.ts +9 -0
- package/packages/pi-coding-agent/dist/utils/image-convert.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/image-convert.js +35 -0
- package/packages/pi-coding-agent/dist/utils/image-convert.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/image-resize.d.ts +36 -0
- package/packages/pi-coding-agent/dist/utils/image-resize.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/image-resize.js +181 -0
- package/packages/pi-coding-agent/dist/utils/image-resize.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/mime.d.ts +2 -0
- package/packages/pi-coding-agent/dist/utils/mime.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/mime.js +26 -0
- package/packages/pi-coding-agent/dist/utils/mime.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/photon.d.ts +21 -0
- package/packages/pi-coding-agent/dist/utils/photon.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/photon.js +121 -0
- package/packages/pi-coding-agent/dist/utils/photon.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/shell.d.ts +26 -0
- package/packages/pi-coding-agent/dist/utils/shell.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/shell.js +186 -0
- package/packages/pi-coding-agent/dist/utils/shell.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/sleep.d.ts +5 -0
- package/packages/pi-coding-agent/dist/utils/sleep.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/sleep.js +17 -0
- package/packages/pi-coding-agent/dist/utils/sleep.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts +3 -0
- package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/tools-manager.js +251 -0
- package/packages/pi-coding-agent/dist/utils/tools-manager.js.map +1 -0
- package/packages/pi-coding-agent/package.json +55 -0
- package/packages/pi-coding-agent/src/cli/args.ts +316 -0
- package/packages/pi-coding-agent/src/cli/config-selector.ts +52 -0
- package/packages/pi-coding-agent/src/cli/file-processor.ts +96 -0
- package/packages/pi-coding-agent/src/cli/list-models.ts +104 -0
- package/packages/pi-coding-agent/src/cli/session-picker.ts +51 -0
- package/packages/pi-coding-agent/src/cli.ts +18 -0
- package/packages/pi-coding-agent/src/config.ts +241 -0
- package/packages/pi-coding-agent/src/core/agent-session.ts +3050 -0
- package/packages/pi-coding-agent/src/core/auth-storage.ts +489 -0
- package/packages/pi-coding-agent/src/core/bash-executor.ts +278 -0
- package/packages/pi-coding-agent/src/core/compaction/branch-summarization.ts +352 -0
- package/packages/pi-coding-agent/src/core/compaction/compaction.ts +813 -0
- package/packages/pi-coding-agent/src/core/compaction/index.ts +7 -0
- package/packages/pi-coding-agent/src/core/compaction/utils.ts +170 -0
- package/packages/pi-coding-agent/src/core/defaults.ts +3 -0
- package/packages/pi-coding-agent/src/core/diagnostics.ts +15 -0
- package/packages/pi-coding-agent/src/core/event-bus.ts +33 -0
- package/packages/pi-coding-agent/src/core/exec.ts +104 -0
- package/packages/pi-coding-agent/src/core/export-html/ansi-to-html.ts +258 -0
- package/packages/pi-coding-agent/src/core/export-html/index.ts +306 -0
- package/packages/pi-coding-agent/src/core/export-html/template.css +971 -0
- package/packages/pi-coding-agent/src/core/export-html/template.html +54 -0
- package/packages/pi-coding-agent/src/core/export-html/template.js +1583 -0
- package/packages/pi-coding-agent/src/core/export-html/tool-renderer.ts +114 -0
- package/packages/pi-coding-agent/src/core/export-html/vendor/.gitkeep +0 -0
- package/packages/pi-coding-agent/src/core/extensions/index.ts +171 -0
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +545 -0
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +884 -0
- package/packages/pi-coding-agent/src/core/extensions/types.ts +1411 -0
- package/packages/pi-coding-agent/src/core/extensions/wrapper.ts +118 -0
- package/packages/pi-coding-agent/src/core/footer-data-provider.ts +144 -0
- package/packages/pi-coding-agent/src/core/index.ts +61 -0
- package/packages/pi-coding-agent/src/core/keybindings.ts +211 -0
- package/packages/pi-coding-agent/src/core/messages.ts +195 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +694 -0
- package/packages/pi-coding-agent/src/core/model-resolver.ts +594 -0
- package/packages/pi-coding-agent/src/core/package-manager.ts +1794 -0
- package/packages/pi-coding-agent/src/core/prompt-templates.ts +299 -0
- package/packages/pi-coding-agent/src/core/resolve-config-value.ts +64 -0
- package/packages/pi-coding-agent/src/core/resource-loader.ts +868 -0
- package/packages/pi-coding-agent/src/core/sdk.ts +373 -0
- package/packages/pi-coding-agent/src/core/session-manager.ts +1410 -0
- package/packages/pi-coding-agent/src/core/settings-manager.ts +942 -0
- package/packages/pi-coding-agent/src/core/skills.ts +459 -0
- package/packages/pi-coding-agent/src/core/slash-commands.ts +38 -0
- package/packages/pi-coding-agent/src/core/system-prompt.ts +218 -0
- package/packages/pi-coding-agent/src/core/timings.ts +25 -0
- package/packages/pi-coding-agent/src/core/tools/bash.ts +347 -0
- package/packages/pi-coding-agent/src/core/tools/edit-diff.ts +308 -0
- package/packages/pi-coding-agent/src/core/tools/edit.ts +227 -0
- package/packages/pi-coding-agent/src/core/tools/find.ts +273 -0
- package/packages/pi-coding-agent/src/core/tools/grep.ts +346 -0
- package/packages/pi-coding-agent/src/core/tools/index.ts +139 -0
- package/packages/pi-coding-agent/src/core/tools/ls.ts +170 -0
- package/packages/pi-coding-agent/src/core/tools/path-utils.ts +94 -0
- package/packages/pi-coding-agent/src/core/tools/read.ts +222 -0
- package/packages/pi-coding-agent/src/core/tools/truncate.ts +265 -0
- package/packages/pi-coding-agent/src/core/tools/write.ts +118 -0
- package/packages/pi-coding-agent/src/index.ts +333 -0
- package/packages/pi-coding-agent/src/main.ts +821 -0
- package/packages/pi-coding-agent/src/migrations.ts +295 -0
- package/packages/pi-coding-agent/src/modes/index.ts +9 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/armin.ts +382 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +115 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/bash-execution.ts +210 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/bordered-loader.ts +66 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/branch-summary-message.ts +58 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/compaction-summary-message.ts +59 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/config-selector.ts +592 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/countdown-timer.ts +38 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/custom-editor.ts +80 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/custom-message.ts +99 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/daxnuts.ts +164 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/diff.ts +147 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/dynamic-border.ts +25 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/extension-editor.ts +147 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/extension-input.ts +85 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/extension-selector.ts +107 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +216 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/index.ts +32 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/keybinding-hints.ts +66 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +174 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/model-selector.ts +329 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/oauth-selector.ts +121 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/scoped-models-selector.ts +346 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/session-selector-search.ts +194 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/session-selector.ts +1019 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/settings-selector.ts +421 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/show-images-selector.ts +45 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/skill-invocation-message.ts +55 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/theme-selector.ts +62 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/thinking-selector.ts +64 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +916 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tree-selector.ts +1184 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/user-message-selector.ts +143 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/user-message.ts +32 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/visual-truncate.ts +50 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +4464 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/dark.json +86 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/light.json +85 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.json +335 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +1105 -0
- package/packages/pi-coding-agent/src/modes/print-mode.ts +124 -0
- package/packages/pi-coding-agent/src/modes/rpc/jsonl.ts +58 -0
- package/packages/pi-coding-agent/src/modes/rpc/rpc-client.ts +505 -0
- package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +638 -0
- package/packages/pi-coding-agent/src/modes/rpc/rpc-types.ts +263 -0
- package/packages/pi-coding-agent/src/utils/changelog.ts +99 -0
- package/packages/pi-coding-agent/src/utils/clipboard-image.ts +207 -0
- package/packages/pi-coding-agent/src/utils/clipboard-native.ts +21 -0
- package/packages/pi-coding-agent/src/utils/clipboard.ts +62 -0
- package/packages/pi-coding-agent/src/utils/frontmatter.ts +39 -0
- package/packages/pi-coding-agent/src/utils/git.ts +192 -0
- package/packages/pi-coding-agent/src/utils/image-convert.ts +38 -0
- package/packages/pi-coding-agent/src/utils/image-resize.ts +231 -0
- package/packages/pi-coding-agent/src/utils/mime.ts +30 -0
- package/packages/pi-coding-agent/src/utils/photon.ts +139 -0
- package/packages/pi-coding-agent/src/utils/shell.ts +202 -0
- package/packages/pi-coding-agent/src/utils/sleep.ts +18 -0
- package/packages/pi-coding-agent/src/utils/tools-manager.ts +286 -0
- package/packages/pi-coding-agent/tsconfig.json +27 -0
- package/packages/pi-tui/dist/autocomplete.d.ts +50 -0
- package/packages/pi-tui/dist/autocomplete.d.ts.map +1 -0
- package/packages/pi-tui/dist/autocomplete.js +593 -0
- package/packages/pi-tui/dist/autocomplete.js.map +1 -0
- package/packages/pi-tui/dist/components/box.d.ts +22 -0
- package/packages/pi-tui/dist/components/box.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/box.js +99 -0
- package/packages/pi-tui/dist/components/box.js.map +1 -0
- package/packages/pi-tui/dist/components/cancellable-loader.d.ts +22 -0
- package/packages/pi-tui/dist/components/cancellable-loader.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/cancellable-loader.js +36 -0
- package/packages/pi-tui/dist/components/cancellable-loader.js.map +1 -0
- package/packages/pi-tui/dist/components/editor.d.ts +219 -0
- package/packages/pi-tui/dist/components/editor.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/editor.js +1693 -0
- package/packages/pi-tui/dist/components/editor.js.map +1 -0
- package/packages/pi-tui/dist/components/image.d.ts +28 -0
- package/packages/pi-tui/dist/components/image.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/image.js +61 -0
- package/packages/pi-tui/dist/components/image.js.map +1 -0
- package/packages/pi-tui/dist/components/input.d.ts +37 -0
- package/packages/pi-tui/dist/components/input.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/input.js +443 -0
- package/packages/pi-tui/dist/components/input.js.map +1 -0
- package/packages/pi-tui/dist/components/loader.d.ts +21 -0
- package/packages/pi-tui/dist/components/loader.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/loader.js +46 -0
- package/packages/pi-tui/dist/components/loader.js.map +1 -0
- package/packages/pi-tui/dist/components/markdown.d.ts +95 -0
- package/packages/pi-tui/dist/components/markdown.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/markdown.js +641 -0
- package/packages/pi-tui/dist/components/markdown.js.map +1 -0
- package/packages/pi-tui/dist/components/select-list.d.ts +32 -0
- package/packages/pi-tui/dist/components/select-list.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/select-list.js +148 -0
- package/packages/pi-tui/dist/components/select-list.js.map +1 -0
- package/packages/pi-tui/dist/components/settings-list.d.ts +50 -0
- package/packages/pi-tui/dist/components/settings-list.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/settings-list.js +177 -0
- package/packages/pi-tui/dist/components/settings-list.js.map +1 -0
- package/packages/pi-tui/dist/components/spacer.d.ts +12 -0
- package/packages/pi-tui/dist/components/spacer.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/spacer.js +22 -0
- package/packages/pi-tui/dist/components/spacer.js.map +1 -0
- package/packages/pi-tui/dist/components/text.d.ts +19 -0
- package/packages/pi-tui/dist/components/text.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/text.js +81 -0
- package/packages/pi-tui/dist/components/text.js.map +1 -0
- package/packages/pi-tui/dist/components/truncated-text.d.ts +13 -0
- package/packages/pi-tui/dist/components/truncated-text.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/truncated-text.js +48 -0
- package/packages/pi-tui/dist/components/truncated-text.js.map +1 -0
- package/packages/pi-tui/dist/editor-component.d.ts +39 -0
- package/packages/pi-tui/dist/editor-component.d.ts.map +1 -0
- package/packages/pi-tui/dist/editor-component.js +2 -0
- package/packages/pi-tui/dist/editor-component.js.map +1 -0
- package/packages/pi-tui/dist/fuzzy.d.ts +16 -0
- package/packages/pi-tui/dist/fuzzy.d.ts.map +1 -0
- package/packages/pi-tui/dist/fuzzy.js +107 -0
- package/packages/pi-tui/dist/fuzzy.js.map +1 -0
- package/packages/pi-tui/dist/index.d.ts +23 -0
- package/packages/pi-tui/dist/index.d.ts.map +1 -0
- package/packages/pi-tui/dist/index.js +32 -0
- package/packages/pi-tui/dist/index.js.map +1 -0
- package/packages/pi-tui/dist/keybindings.d.ts +39 -0
- package/packages/pi-tui/dist/keybindings.d.ts.map +1 -0
- package/packages/pi-tui/dist/keybindings.js +116 -0
- package/packages/pi-tui/dist/keybindings.js.map +1 -0
- package/packages/pi-tui/dist/keys.d.ts +170 -0
- package/packages/pi-tui/dist/keys.d.ts.map +1 -0
- package/packages/pi-tui/dist/keys.js +1046 -0
- package/packages/pi-tui/dist/keys.js.map +1 -0
- package/packages/pi-tui/dist/kill-ring.d.ts +28 -0
- package/packages/pi-tui/dist/kill-ring.d.ts.map +1 -0
- package/packages/pi-tui/dist/kill-ring.js +46 -0
- package/packages/pi-tui/dist/kill-ring.js.map +1 -0
- package/packages/pi-tui/dist/stdin-buffer.d.ts +48 -0
- package/packages/pi-tui/dist/stdin-buffer.d.ts.map +1 -0
- package/packages/pi-tui/dist/stdin-buffer.js +316 -0
- package/packages/pi-tui/dist/stdin-buffer.js.map +1 -0
- package/packages/pi-tui/dist/terminal-image.d.ts +68 -0
- package/packages/pi-tui/dist/terminal-image.d.ts.map +1 -0
- package/packages/pi-tui/dist/terminal-image.js +288 -0
- package/packages/pi-tui/dist/terminal-image.js.map +1 -0
- package/packages/pi-tui/dist/terminal.d.ts +85 -0
- package/packages/pi-tui/dist/terminal.d.ts.map +1 -0
- package/packages/pi-tui/dist/terminal.js +271 -0
- package/packages/pi-tui/dist/terminal.js.map +1 -0
- package/packages/pi-tui/dist/tui.d.ts +220 -0
- package/packages/pi-tui/dist/tui.d.ts.map +1 -0
- package/packages/pi-tui/dist/tui.js +976 -0
- package/packages/pi-tui/dist/tui.js.map +1 -0
- package/packages/pi-tui/dist/undo-stack.d.ts +17 -0
- package/packages/pi-tui/dist/undo-stack.d.ts.map +1 -0
- package/packages/pi-tui/dist/undo-stack.js +27 -0
- package/packages/pi-tui/dist/undo-stack.js.map +1 -0
- package/packages/pi-tui/dist/utils.d.ts +78 -0
- package/packages/pi-tui/dist/utils.d.ts.map +1 -0
- package/packages/pi-tui/dist/utils.js +817 -0
- package/packages/pi-tui/dist/utils.js.map +1 -0
- package/packages/pi-tui/package.json +21 -0
- package/packages/pi-tui/src/autocomplete.ts +736 -0
- package/packages/pi-tui/src/components/box.ts +137 -0
- package/packages/pi-tui/src/components/cancellable-loader.ts +40 -0
- package/packages/pi-tui/src/components/editor.ts +2035 -0
- package/packages/pi-tui/src/components/image.ts +104 -0
- package/packages/pi-tui/src/components/input.ts +521 -0
- package/packages/pi-tui/src/components/loader.ts +55 -0
- package/packages/pi-tui/src/components/markdown.ts +806 -0
- package/packages/pi-tui/src/components/select-list.ts +188 -0
- package/packages/pi-tui/src/components/settings-list.ts +250 -0
- package/packages/pi-tui/src/components/spacer.ts +28 -0
- package/packages/pi-tui/src/components/text.ts +106 -0
- package/packages/pi-tui/src/components/truncated-text.ts +65 -0
- package/packages/pi-tui/src/editor-component.ts +74 -0
- package/packages/pi-tui/src/fuzzy.ts +133 -0
- package/packages/pi-tui/src/index.ts +93 -0
- package/packages/pi-tui/src/keybindings.ts +189 -0
- package/packages/pi-tui/src/keys.ts +1255 -0
- package/packages/pi-tui/src/kill-ring.ts +46 -0
- package/packages/pi-tui/src/stdin-buffer.ts +386 -0
- package/packages/pi-tui/src/terminal-image.ts +381 -0
- package/packages/pi-tui/src/terminal.ts +349 -0
- package/packages/pi-tui/src/tui.ts +1212 -0
- package/packages/pi-tui/src/undo-stack.ts +28 -0
- package/packages/pi-tui/src/utils.ts +905 -0
- package/packages/pi-tui/tsconfig.json +27 -0
- package/pkg/dist/modes/interactive/theme/dark.json +5 -5
- package/pkg/dist/modes/interactive/theme/light.json +3 -2
- package/pkg/dist/modes/interactive/theme/theme.d.ts +2 -2
- package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.js +1 -6
- package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
- package/scripts/postinstall.js +2 -17
- package/src/resources/extensions/ask-user-questions.ts +2 -2
- package/src/resources/extensions/bg-shell/index.ts +4 -4
- package/src/resources/extensions/browser-tools/index.ts +3 -3
- package/src/resources/extensions/context7/index.ts +3 -3
- package/src/resources/extensions/get-secrets-from-user.ts +331 -59
- package/src/resources/extensions/google-search/index.ts +20 -7
- package/src/resources/extensions/gsd/activity-log.ts +1 -1
- package/src/resources/extensions/gsd/auto.ts +106 -21
- package/src/resources/extensions/gsd/commands.ts +2 -2
- package/src/resources/extensions/gsd/dashboard-overlay.ts +2 -2
- package/src/resources/extensions/gsd/docs/preferences-reference.md +45 -1
- package/src/resources/extensions/gsd/doctor.ts +23 -4
- package/src/resources/extensions/gsd/files.ts +115 -1
- package/src/resources/extensions/gsd/git-service.ts +64 -111
- package/src/resources/extensions/gsd/guided-flow.ts +3 -2
- package/src/resources/extensions/gsd/index.ts +18 -7
- package/src/resources/extensions/gsd/metrics.ts +1 -1
- package/src/resources/extensions/gsd/migrate/command.ts +1 -1
- package/src/resources/extensions/gsd/preferences.ts +72 -10
- package/src/resources/extensions/gsd/prompts/guided-plan-milestone.md +4 -0
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +17 -0
- package/src/resources/extensions/gsd/session-forensics.ts +19 -6
- package/src/resources/extensions/gsd/skill-discovery.ts +1 -1
- package/src/resources/extensions/gsd/templates/secrets-manifest.md +22 -0
- package/src/resources/extensions/gsd/tests/auto-secrets-gate.test.ts +196 -0
- package/src/resources/extensions/gsd/tests/collect-from-manifest.test.ts +469 -0
- package/src/resources/extensions/gsd/tests/doctor-fixlevel.test.ts +170 -0
- package/src/resources/extensions/gsd/tests/git-service.test.ts +43 -0
- package/src/resources/extensions/gsd/tests/manifest-status.test.ts +283 -0
- package/src/resources/extensions/gsd/tests/parsers.test.ts +401 -65
- package/src/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +2 -1
- package/src/resources/extensions/gsd/tests/secure-env-collect.test.ts +185 -0
- package/src/resources/extensions/gsd/types.ts +27 -0
- package/src/resources/extensions/gsd/worktree-command.ts +1 -1
- package/src/resources/extensions/mac-tools/index.ts +2 -2
- package/src/resources/extensions/mcporter/index.ts +3 -3
- package/src/resources/extensions/remote-questions/remote-command.ts +3 -3
- package/src/resources/extensions/search-the-web/command-search-provider.ts +2 -2
- package/src/resources/extensions/search-the-web/index.ts +1 -1
- package/src/resources/extensions/search-the-web/provider.ts +1 -1
- package/src/resources/extensions/search-the-web/tool-fetch-page.ts +3 -3
- package/src/resources/extensions/search-the-web/tool-llm-context.ts +4 -4
- package/src/resources/extensions/search-the-web/tool-search.ts +4 -4
- package/src/resources/extensions/shared/confirm-ui.ts +3 -3
- package/src/resources/extensions/shared/interview-ui.ts +3 -3
- package/src/resources/extensions/shared/next-action-ui.ts +3 -3
- package/src/resources/extensions/shared/progress-widget.ts +2 -2
- package/src/resources/extensions/shared/thinking-widget.ts +3 -3
- package/src/resources/extensions/shared/ui.ts +4 -4
- package/src/resources/extensions/shared/wizard-ui.ts +4 -4
- package/src/resources/extensions/slash-commands/audit.ts +1 -1
- package/src/resources/extensions/slash-commands/clear.ts +1 -1
- package/src/resources/extensions/slash-commands/create-extension.ts +2 -2
- package/src/resources/extensions/slash-commands/create-slash-command.ts +2 -2
- package/src/resources/extensions/slash-commands/index.ts +1 -1
- package/src/resources/extensions/subagent/agents.ts +1 -1
- package/src/resources/extensions/subagent/index.ts +5 -5
- package/src/resources/extensions/voice/index.ts +3 -3
- package/patches/@mariozechner+pi-coding-agent+0.57.1.patch +0 -113
- package/patches/@mariozechner+pi-tui+0.57.1.patch +0 -47
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent class that uses the agent-loop directly.
|
|
3
|
+
* No transport abstraction - calls streamSimple via the loop.
|
|
4
|
+
*/
|
|
5
|
+
import { getModel, streamSimple, } from "@gsd/pi-ai";
|
|
6
|
+
import { agentLoop, agentLoopContinue } from "./agent-loop.js";
|
|
7
|
+
/**
|
|
8
|
+
* Default convertToLlm: Keep only LLM-compatible messages, convert attachments.
|
|
9
|
+
*/
|
|
10
|
+
function defaultConvertToLlm(messages) {
|
|
11
|
+
return messages.filter((m) => m.role === "user" || m.role === "assistant" || m.role === "toolResult");
|
|
12
|
+
}
|
|
13
|
+
export class Agent {
|
|
14
|
+
constructor(opts = {}) {
|
|
15
|
+
this._state = {
|
|
16
|
+
systemPrompt: "",
|
|
17
|
+
model: getModel("google", "gemini-2.5-flash-lite-preview-06-17"),
|
|
18
|
+
thinkingLevel: "off",
|
|
19
|
+
tools: [],
|
|
20
|
+
messages: [],
|
|
21
|
+
isStreaming: false,
|
|
22
|
+
streamMessage: null,
|
|
23
|
+
pendingToolCalls: new Set(),
|
|
24
|
+
error: undefined,
|
|
25
|
+
};
|
|
26
|
+
this.listeners = new Set();
|
|
27
|
+
this.steeringQueue = [];
|
|
28
|
+
this.followUpQueue = [];
|
|
29
|
+
this._state = { ...this._state, ...opts.initialState };
|
|
30
|
+
this.convertToLlm = opts.convertToLlm || defaultConvertToLlm;
|
|
31
|
+
this.transformContext = opts.transformContext;
|
|
32
|
+
this.steeringMode = opts.steeringMode || "one-at-a-time";
|
|
33
|
+
this.followUpMode = opts.followUpMode || "one-at-a-time";
|
|
34
|
+
this.streamFn = opts.streamFn || streamSimple;
|
|
35
|
+
this._sessionId = opts.sessionId;
|
|
36
|
+
this.getApiKey = opts.getApiKey;
|
|
37
|
+
this._onPayload = opts.onPayload;
|
|
38
|
+
this._thinkingBudgets = opts.thinkingBudgets;
|
|
39
|
+
this._transport = opts.transport ?? "sse";
|
|
40
|
+
this._maxRetryDelayMs = opts.maxRetryDelayMs;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the current session ID used for provider caching.
|
|
44
|
+
*/
|
|
45
|
+
get sessionId() {
|
|
46
|
+
return this._sessionId;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Set the session ID for provider caching.
|
|
50
|
+
* Call this when switching sessions (new session, branch, resume).
|
|
51
|
+
*/
|
|
52
|
+
set sessionId(value) {
|
|
53
|
+
this._sessionId = value;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the current thinking budgets.
|
|
57
|
+
*/
|
|
58
|
+
get thinkingBudgets() {
|
|
59
|
+
return this._thinkingBudgets;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Set custom thinking budgets for token-based providers.
|
|
63
|
+
*/
|
|
64
|
+
set thinkingBudgets(value) {
|
|
65
|
+
this._thinkingBudgets = value;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the current preferred transport.
|
|
69
|
+
*/
|
|
70
|
+
get transport() {
|
|
71
|
+
return this._transport;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Set the preferred transport.
|
|
75
|
+
*/
|
|
76
|
+
setTransport(value) {
|
|
77
|
+
this._transport = value;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the current max retry delay in milliseconds.
|
|
81
|
+
*/
|
|
82
|
+
get maxRetryDelayMs() {
|
|
83
|
+
return this._maxRetryDelayMs;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Set the maximum delay to wait for server-requested retries.
|
|
87
|
+
* Set to 0 to disable the cap.
|
|
88
|
+
*/
|
|
89
|
+
set maxRetryDelayMs(value) {
|
|
90
|
+
this._maxRetryDelayMs = value;
|
|
91
|
+
}
|
|
92
|
+
get state() {
|
|
93
|
+
return this._state;
|
|
94
|
+
}
|
|
95
|
+
subscribe(fn) {
|
|
96
|
+
this.listeners.add(fn);
|
|
97
|
+
return () => this.listeners.delete(fn);
|
|
98
|
+
}
|
|
99
|
+
// State mutators
|
|
100
|
+
setSystemPrompt(v) {
|
|
101
|
+
this._state.systemPrompt = v;
|
|
102
|
+
}
|
|
103
|
+
setModel(m) {
|
|
104
|
+
this._state.model = m;
|
|
105
|
+
}
|
|
106
|
+
setThinkingLevel(l) {
|
|
107
|
+
this._state.thinkingLevel = l;
|
|
108
|
+
}
|
|
109
|
+
setSteeringMode(mode) {
|
|
110
|
+
this.steeringMode = mode;
|
|
111
|
+
}
|
|
112
|
+
getSteeringMode() {
|
|
113
|
+
return this.steeringMode;
|
|
114
|
+
}
|
|
115
|
+
setFollowUpMode(mode) {
|
|
116
|
+
this.followUpMode = mode;
|
|
117
|
+
}
|
|
118
|
+
getFollowUpMode() {
|
|
119
|
+
return this.followUpMode;
|
|
120
|
+
}
|
|
121
|
+
setTools(t) {
|
|
122
|
+
this._state.tools = t;
|
|
123
|
+
}
|
|
124
|
+
replaceMessages(ms) {
|
|
125
|
+
this._state.messages = ms.slice();
|
|
126
|
+
}
|
|
127
|
+
appendMessage(m) {
|
|
128
|
+
this._state.messages = [...this._state.messages, m];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Queue a steering message to interrupt the agent mid-run.
|
|
132
|
+
* Delivered after current tool execution, skips remaining tools.
|
|
133
|
+
*/
|
|
134
|
+
steer(m) {
|
|
135
|
+
this.steeringQueue.push(m);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Queue a follow-up message to be processed after the agent finishes.
|
|
139
|
+
* Delivered only when agent has no more tool calls or steering messages.
|
|
140
|
+
*/
|
|
141
|
+
followUp(m) {
|
|
142
|
+
this.followUpQueue.push(m);
|
|
143
|
+
}
|
|
144
|
+
clearSteeringQueue() {
|
|
145
|
+
this.steeringQueue = [];
|
|
146
|
+
}
|
|
147
|
+
clearFollowUpQueue() {
|
|
148
|
+
this.followUpQueue = [];
|
|
149
|
+
}
|
|
150
|
+
clearAllQueues() {
|
|
151
|
+
this.steeringQueue = [];
|
|
152
|
+
this.followUpQueue = [];
|
|
153
|
+
}
|
|
154
|
+
hasQueuedMessages() {
|
|
155
|
+
return this.steeringQueue.length > 0 || this.followUpQueue.length > 0;
|
|
156
|
+
}
|
|
157
|
+
dequeueSteeringMessages() {
|
|
158
|
+
if (this.steeringMode === "one-at-a-time") {
|
|
159
|
+
if (this.steeringQueue.length > 0) {
|
|
160
|
+
const first = this.steeringQueue[0];
|
|
161
|
+
this.steeringQueue = this.steeringQueue.slice(1);
|
|
162
|
+
return [first];
|
|
163
|
+
}
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
const steering = this.steeringQueue.slice();
|
|
167
|
+
this.steeringQueue = [];
|
|
168
|
+
return steering;
|
|
169
|
+
}
|
|
170
|
+
dequeueFollowUpMessages() {
|
|
171
|
+
if (this.followUpMode === "one-at-a-time") {
|
|
172
|
+
if (this.followUpQueue.length > 0) {
|
|
173
|
+
const first = this.followUpQueue[0];
|
|
174
|
+
this.followUpQueue = this.followUpQueue.slice(1);
|
|
175
|
+
return [first];
|
|
176
|
+
}
|
|
177
|
+
return [];
|
|
178
|
+
}
|
|
179
|
+
const followUp = this.followUpQueue.slice();
|
|
180
|
+
this.followUpQueue = [];
|
|
181
|
+
return followUp;
|
|
182
|
+
}
|
|
183
|
+
clearMessages() {
|
|
184
|
+
this._state.messages = [];
|
|
185
|
+
}
|
|
186
|
+
abort() {
|
|
187
|
+
this.abortController?.abort();
|
|
188
|
+
}
|
|
189
|
+
waitForIdle() {
|
|
190
|
+
return this.runningPrompt ?? Promise.resolve();
|
|
191
|
+
}
|
|
192
|
+
reset() {
|
|
193
|
+
this._state.messages = [];
|
|
194
|
+
this._state.isStreaming = false;
|
|
195
|
+
this._state.streamMessage = null;
|
|
196
|
+
this._state.pendingToolCalls = new Set();
|
|
197
|
+
this._state.error = undefined;
|
|
198
|
+
this.steeringQueue = [];
|
|
199
|
+
this.followUpQueue = [];
|
|
200
|
+
}
|
|
201
|
+
async prompt(input, images) {
|
|
202
|
+
if (this._state.isStreaming) {
|
|
203
|
+
throw new Error("Agent is already processing a prompt. Use steer() or followUp() to queue messages, or wait for completion.");
|
|
204
|
+
}
|
|
205
|
+
const model = this._state.model;
|
|
206
|
+
if (!model)
|
|
207
|
+
throw new Error("No model configured");
|
|
208
|
+
let msgs;
|
|
209
|
+
if (Array.isArray(input)) {
|
|
210
|
+
msgs = input;
|
|
211
|
+
}
|
|
212
|
+
else if (typeof input === "string") {
|
|
213
|
+
const content = [{ type: "text", text: input }];
|
|
214
|
+
if (images && images.length > 0) {
|
|
215
|
+
content.push(...images);
|
|
216
|
+
}
|
|
217
|
+
msgs = [
|
|
218
|
+
{
|
|
219
|
+
role: "user",
|
|
220
|
+
content,
|
|
221
|
+
timestamp: Date.now(),
|
|
222
|
+
},
|
|
223
|
+
];
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
msgs = [input];
|
|
227
|
+
}
|
|
228
|
+
await this._runLoop(msgs);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Continue from current context (used for retries and resuming queued messages).
|
|
232
|
+
*/
|
|
233
|
+
async continue() {
|
|
234
|
+
if (this._state.isStreaming) {
|
|
235
|
+
throw new Error("Agent is already processing. Wait for completion before continuing.");
|
|
236
|
+
}
|
|
237
|
+
const messages = this._state.messages;
|
|
238
|
+
if (messages.length === 0) {
|
|
239
|
+
throw new Error("No messages to continue from");
|
|
240
|
+
}
|
|
241
|
+
if (messages[messages.length - 1].role === "assistant") {
|
|
242
|
+
const queuedSteering = this.dequeueSteeringMessages();
|
|
243
|
+
if (queuedSteering.length > 0) {
|
|
244
|
+
await this._runLoop(queuedSteering, { skipInitialSteeringPoll: true });
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const queuedFollowUp = this.dequeueFollowUpMessages();
|
|
248
|
+
if (queuedFollowUp.length > 0) {
|
|
249
|
+
await this._runLoop(queuedFollowUp);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
throw new Error("Cannot continue from message role: assistant");
|
|
253
|
+
}
|
|
254
|
+
await this._runLoop(undefined);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Run the agent loop.
|
|
258
|
+
* If messages are provided, starts a new conversation turn with those messages.
|
|
259
|
+
* Otherwise, continues from existing context.
|
|
260
|
+
*/
|
|
261
|
+
async _runLoop(messages, options) {
|
|
262
|
+
const model = this._state.model;
|
|
263
|
+
if (!model)
|
|
264
|
+
throw new Error("No model configured");
|
|
265
|
+
this.runningPrompt = new Promise((resolve) => {
|
|
266
|
+
this.resolveRunningPrompt = resolve;
|
|
267
|
+
});
|
|
268
|
+
this.abortController = new AbortController();
|
|
269
|
+
this._state.isStreaming = true;
|
|
270
|
+
this._state.streamMessage = null;
|
|
271
|
+
this._state.error = undefined;
|
|
272
|
+
const reasoning = this._state.thinkingLevel === "off" ? undefined : this._state.thinkingLevel;
|
|
273
|
+
const context = {
|
|
274
|
+
systemPrompt: this._state.systemPrompt,
|
|
275
|
+
messages: this._state.messages.slice(),
|
|
276
|
+
tools: this._state.tools,
|
|
277
|
+
};
|
|
278
|
+
let skipInitialSteeringPoll = options?.skipInitialSteeringPoll === true;
|
|
279
|
+
const config = {
|
|
280
|
+
model,
|
|
281
|
+
reasoning,
|
|
282
|
+
sessionId: this._sessionId,
|
|
283
|
+
onPayload: this._onPayload,
|
|
284
|
+
transport: this._transport,
|
|
285
|
+
thinkingBudgets: this._thinkingBudgets,
|
|
286
|
+
maxRetryDelayMs: this._maxRetryDelayMs,
|
|
287
|
+
convertToLlm: this.convertToLlm,
|
|
288
|
+
transformContext: this.transformContext,
|
|
289
|
+
getApiKey: this.getApiKey,
|
|
290
|
+
getSteeringMessages: async () => {
|
|
291
|
+
if (skipInitialSteeringPoll) {
|
|
292
|
+
skipInitialSteeringPoll = false;
|
|
293
|
+
return [];
|
|
294
|
+
}
|
|
295
|
+
return this.dequeueSteeringMessages();
|
|
296
|
+
},
|
|
297
|
+
getFollowUpMessages: async () => this.dequeueFollowUpMessages(),
|
|
298
|
+
};
|
|
299
|
+
let partial = null;
|
|
300
|
+
try {
|
|
301
|
+
const stream = messages
|
|
302
|
+
? agentLoop(messages, context, config, this.abortController.signal, this.streamFn)
|
|
303
|
+
: agentLoopContinue(context, config, this.abortController.signal, this.streamFn);
|
|
304
|
+
for await (const event of stream) {
|
|
305
|
+
// Update internal state based on events
|
|
306
|
+
switch (event.type) {
|
|
307
|
+
case "message_start":
|
|
308
|
+
partial = event.message;
|
|
309
|
+
this._state.streamMessage = event.message;
|
|
310
|
+
break;
|
|
311
|
+
case "message_update":
|
|
312
|
+
partial = event.message;
|
|
313
|
+
this._state.streamMessage = event.message;
|
|
314
|
+
break;
|
|
315
|
+
case "message_end":
|
|
316
|
+
partial = null;
|
|
317
|
+
this._state.streamMessage = null;
|
|
318
|
+
this.appendMessage(event.message);
|
|
319
|
+
break;
|
|
320
|
+
case "tool_execution_start": {
|
|
321
|
+
const s = new Set(this._state.pendingToolCalls);
|
|
322
|
+
s.add(event.toolCallId);
|
|
323
|
+
this._state.pendingToolCalls = s;
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
case "tool_execution_end": {
|
|
327
|
+
const s = new Set(this._state.pendingToolCalls);
|
|
328
|
+
s.delete(event.toolCallId);
|
|
329
|
+
this._state.pendingToolCalls = s;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
case "turn_end":
|
|
333
|
+
if (event.message.role === "assistant" && event.message.errorMessage) {
|
|
334
|
+
this._state.error = event.message.errorMessage;
|
|
335
|
+
}
|
|
336
|
+
break;
|
|
337
|
+
case "agent_end":
|
|
338
|
+
this._state.isStreaming = false;
|
|
339
|
+
this._state.streamMessage = null;
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
// Emit to listeners
|
|
343
|
+
this.emit(event);
|
|
344
|
+
}
|
|
345
|
+
// Handle any remaining partial message
|
|
346
|
+
if (partial && partial.role === "assistant" && partial.content.length > 0) {
|
|
347
|
+
const onlyEmpty = !partial.content.some((c) => (c.type === "thinking" && c.thinking.trim().length > 0) ||
|
|
348
|
+
(c.type === "text" && c.text.trim().length > 0) ||
|
|
349
|
+
(c.type === "toolCall" && c.name.trim().length > 0));
|
|
350
|
+
if (!onlyEmpty) {
|
|
351
|
+
this.appendMessage(partial);
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
if (this.abortController?.signal.aborted) {
|
|
355
|
+
throw new Error("Request was aborted");
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
catch (err) {
|
|
361
|
+
const errorMsg = {
|
|
362
|
+
role: "assistant",
|
|
363
|
+
content: [{ type: "text", text: "" }],
|
|
364
|
+
api: model.api,
|
|
365
|
+
provider: model.provider,
|
|
366
|
+
model: model.id,
|
|
367
|
+
usage: {
|
|
368
|
+
input: 0,
|
|
369
|
+
output: 0,
|
|
370
|
+
cacheRead: 0,
|
|
371
|
+
cacheWrite: 0,
|
|
372
|
+
totalTokens: 0,
|
|
373
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
374
|
+
},
|
|
375
|
+
stopReason: this.abortController?.signal.aborted ? "aborted" : "error",
|
|
376
|
+
errorMessage: err?.message || String(err),
|
|
377
|
+
timestamp: Date.now(),
|
|
378
|
+
};
|
|
379
|
+
this.appendMessage(errorMsg);
|
|
380
|
+
this._state.error = err?.message || String(err);
|
|
381
|
+
this.emit({ type: "agent_end", messages: [errorMsg] });
|
|
382
|
+
}
|
|
383
|
+
finally {
|
|
384
|
+
this._state.isStreaming = false;
|
|
385
|
+
this._state.streamMessage = null;
|
|
386
|
+
this._state.pendingToolCalls = new Set();
|
|
387
|
+
this.abortController = undefined;
|
|
388
|
+
this.resolveRunningPrompt?.();
|
|
389
|
+
this.runningPrompt = undefined;
|
|
390
|
+
this.resolveRunningPrompt = undefined;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
emit(e) {
|
|
394
|
+
for (const listener of this.listeners) {
|
|
395
|
+
listener(e);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,QAAQ,EAKR,YAAY,GAIZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAY/D;;GAEG;AACH,SAAS,mBAAmB,CAAC,QAAwB;IACpD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;AACvG,CAAC;AAoED,MAAM,OAAO,KAAK;IA+BjB,YAAY,OAAqB,EAAE;QA9B3B,WAAM,GAAe;YAC5B,YAAY,EAAE,EAAE;YAChB,KAAK,EAAE,QAAQ,CAAC,QAAQ,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,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC;gBACzC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACL,CAAC;YAElB,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;YAChD,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC;YAChC,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;YACjD,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;YACjC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;YAC9B,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;YAC/B,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACvC,CAAC;IACF,CAAC;IAEO,IAAI,CAAC,CAAa;QACzB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACvC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACb,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n * Agent class that uses the agent-loop directly.\n * No transport abstraction - calls streamSimple via the loop.\n */\n\nimport {\n\tgetModel,\n\ttype ImageContent,\n\ttype Message,\n\ttype Model,\n\ttype SimpleStreamOptions,\n\tstreamSimple,\n\ttype TextContent,\n\ttype ThinkingBudgets,\n\ttype Transport,\n} from \"@gsd/pi-ai\";\nimport { agentLoop, agentLoopContinue } from \"./agent-loop.js\";\nimport type {\n\tAgentContext,\n\tAgentEvent,\n\tAgentLoopConfig,\n\tAgentMessage,\n\tAgentState,\n\tAgentTool,\n\tStreamFn,\n\tThinkingLevel,\n} from \"./types.js\";\n\n/**\n * Default convertToLlm: Keep only LLM-compatible messages, convert attachments.\n */\nfunction defaultConvertToLlm(messages: AgentMessage[]): Message[] {\n\treturn messages.filter((m) => m.role === \"user\" || m.role === \"assistant\" || m.role === \"toolResult\");\n}\n\nexport interface AgentOptions {\n\tinitialState?: Partial<AgentState>;\n\n\t/**\n\t * Converts AgentMessage[] to LLM-compatible Message[] before each LLM call.\n\t * Default filters to user/assistant/toolResult and converts attachments.\n\t */\n\tconvertToLlm?: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\n\t/**\n\t * Optional transform applied to context before convertToLlm.\n\t * Use for context pruning, injecting external context, etc.\n\t */\n\ttransformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\n\t/**\n\t * Steering mode: \"all\" = send all steering messages at once, \"one-at-a-time\" = one per turn\n\t */\n\tsteeringMode?: \"all\" | \"one-at-a-time\";\n\n\t/**\n\t * Follow-up mode: \"all\" = send all follow-up messages at once, \"one-at-a-time\" = one per turn\n\t */\n\tfollowUpMode?: \"all\" | \"one-at-a-time\";\n\n\t/**\n\t * Custom stream function (for proxy backends, etc.). Default uses streamSimple.\n\t */\n\tstreamFn?: StreamFn;\n\n\t/**\n\t * Optional session identifier forwarded to LLM providers.\n\t * Used by providers that support session-based caching (e.g., OpenAI Codex).\n\t */\n\tsessionId?: string;\n\n\t/**\n\t * Resolves an API key dynamically for each LLM call.\n\t * Useful for expiring tokens (e.g., GitHub Copilot OAuth).\n\t */\n\tgetApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\n\t/**\n\t * Inspect or replace provider payloads before they are sent.\n\t */\n\tonPayload?: SimpleStreamOptions[\"onPayload\"];\n\n\t/**\n\t * Custom token budgets for thinking levels (token-based providers only).\n\t */\n\tthinkingBudgets?: ThinkingBudgets;\n\n\t/**\n\t * Preferred transport for providers that support multiple transports.\n\t */\n\ttransport?: Transport;\n\n\t/**\n\t * Maximum delay in milliseconds to wait for a retry when the server requests a long wait.\n\t * If the server's requested delay exceeds this value, the request fails immediately,\n\t * allowing higher-level retry logic to handle it with user visibility.\n\t * Default: 60000 (60 seconds). Set to 0 to disable the cap.\n\t */\n\tmaxRetryDelayMs?: number;\n}\n\nexport class Agent {\n\tprivate _state: AgentState = {\n\t\tsystemPrompt: \"\",\n\t\tmodel: getModel(\"google\", \"gemini-2.5-flash-lite-preview-06-17\"),\n\t\tthinkingLevel: \"off\",\n\t\ttools: [],\n\t\tmessages: [],\n\t\tisStreaming: false,\n\t\tstreamMessage: null,\n\t\tpendingToolCalls: new Set<string>(),\n\t\terror: undefined,\n\t};\n\n\tprivate listeners = new Set<(e: AgentEvent) => void>();\n\tprivate abortController?: AbortController;\n\tprivate convertToLlm: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\tprivate transformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\tprivate steeringQueue: AgentMessage[] = [];\n\tprivate followUpQueue: AgentMessage[] = [];\n\tprivate steeringMode: \"all\" | \"one-at-a-time\";\n\tprivate followUpMode: \"all\" | \"one-at-a-time\";\n\tpublic streamFn: StreamFn;\n\tprivate _sessionId?: string;\n\tpublic getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\tprivate _onPayload?: SimpleStreamOptions[\"onPayload\"];\n\tprivate runningPrompt?: Promise<void>;\n\tprivate resolveRunningPrompt?: () => void;\n\tprivate _thinkingBudgets?: ThinkingBudgets;\n\tprivate _transport: Transport;\n\tprivate _maxRetryDelayMs?: number;\n\n\tconstructor(opts: AgentOptions = {}) {\n\t\tthis._state = { ...this._state, ...opts.initialState };\n\t\tthis.convertToLlm = opts.convertToLlm || defaultConvertToLlm;\n\t\tthis.transformContext = opts.transformContext;\n\t\tthis.steeringMode = opts.steeringMode || \"one-at-a-time\";\n\t\tthis.followUpMode = opts.followUpMode || \"one-at-a-time\";\n\t\tthis.streamFn = opts.streamFn || streamSimple;\n\t\tthis._sessionId = opts.sessionId;\n\t\tthis.getApiKey = opts.getApiKey;\n\t\tthis._onPayload = opts.onPayload;\n\t\tthis._thinkingBudgets = opts.thinkingBudgets;\n\t\tthis._transport = opts.transport ?? \"sse\";\n\t\tthis._maxRetryDelayMs = opts.maxRetryDelayMs;\n\t}\n\n\t/**\n\t * Get the current session ID used for provider caching.\n\t */\n\tget sessionId(): string | undefined {\n\t\treturn this._sessionId;\n\t}\n\n\t/**\n\t * Set the session ID for provider caching.\n\t * Call this when switching sessions (new session, branch, resume).\n\t */\n\tset sessionId(value: string | undefined) {\n\t\tthis._sessionId = value;\n\t}\n\n\t/**\n\t * Get the current thinking budgets.\n\t */\n\tget thinkingBudgets(): ThinkingBudgets | undefined {\n\t\treturn this._thinkingBudgets;\n\t}\n\n\t/**\n\t * Set custom thinking budgets for token-based providers.\n\t */\n\tset thinkingBudgets(value: ThinkingBudgets | undefined) {\n\t\tthis._thinkingBudgets = value;\n\t}\n\n\t/**\n\t * Get the current preferred transport.\n\t */\n\tget transport(): Transport {\n\t\treturn this._transport;\n\t}\n\n\t/**\n\t * Set the preferred transport.\n\t */\n\tsetTransport(value: Transport) {\n\t\tthis._transport = value;\n\t}\n\n\t/**\n\t * Get the current max retry delay in milliseconds.\n\t */\n\tget maxRetryDelayMs(): number | undefined {\n\t\treturn this._maxRetryDelayMs;\n\t}\n\n\t/**\n\t * Set the maximum delay to wait for server-requested retries.\n\t * Set to 0 to disable the cap.\n\t */\n\tset maxRetryDelayMs(value: number | undefined) {\n\t\tthis._maxRetryDelayMs = value;\n\t}\n\n\tget state(): AgentState {\n\t\treturn this._state;\n\t}\n\n\tsubscribe(fn: (e: AgentEvent) => void): () => void {\n\t\tthis.listeners.add(fn);\n\t\treturn () => this.listeners.delete(fn);\n\t}\n\n\t// State mutators\n\tsetSystemPrompt(v: string) {\n\t\tthis._state.systemPrompt = v;\n\t}\n\n\tsetModel(m: Model<any>) {\n\t\tthis._state.model = m;\n\t}\n\n\tsetThinkingLevel(l: ThinkingLevel) {\n\t\tthis._state.thinkingLevel = l;\n\t}\n\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\") {\n\t\tthis.steeringMode = mode;\n\t}\n\n\tgetSteeringMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.steeringMode;\n\t}\n\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\") {\n\t\tthis.followUpMode = mode;\n\t}\n\n\tgetFollowUpMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.followUpMode;\n\t}\n\n\tsetTools(t: AgentTool<any>[]) {\n\t\tthis._state.tools = t;\n\t}\n\n\treplaceMessages(ms: AgentMessage[]) {\n\t\tthis._state.messages = ms.slice();\n\t}\n\n\tappendMessage(m: AgentMessage) {\n\t\tthis._state.messages = [...this._state.messages, m];\n\t}\n\n\t/**\n\t * Queue a steering message to interrupt the agent mid-run.\n\t * Delivered after current tool execution, skips remaining tools.\n\t */\n\tsteer(m: AgentMessage) {\n\t\tthis.steeringQueue.push(m);\n\t}\n\n\t/**\n\t * Queue a follow-up message to be processed after the agent finishes.\n\t * Delivered only when agent has no more tool calls or steering messages.\n\t */\n\tfollowUp(m: AgentMessage) {\n\t\tthis.followUpQueue.push(m);\n\t}\n\n\tclearSteeringQueue() {\n\t\tthis.steeringQueue = [];\n\t}\n\n\tclearFollowUpQueue() {\n\t\tthis.followUpQueue = [];\n\t}\n\n\tclearAllQueues() {\n\t\tthis.steeringQueue = [];\n\t\tthis.followUpQueue = [];\n\t}\n\n\thasQueuedMessages(): boolean {\n\t\treturn this.steeringQueue.length > 0 || this.followUpQueue.length > 0;\n\t}\n\n\tprivate dequeueSteeringMessages(): AgentMessage[] {\n\t\tif (this.steeringMode === \"one-at-a-time\") {\n\t\t\tif (this.steeringQueue.length > 0) {\n\t\t\t\tconst first = this.steeringQueue[0];\n\t\t\t\tthis.steeringQueue = this.steeringQueue.slice(1);\n\t\t\t\treturn [first];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\n\t\tconst steering = this.steeringQueue.slice();\n\t\tthis.steeringQueue = [];\n\t\treturn steering;\n\t}\n\n\tprivate dequeueFollowUpMessages(): AgentMessage[] {\n\t\tif (this.followUpMode === \"one-at-a-time\") {\n\t\t\tif (this.followUpQueue.length > 0) {\n\t\t\t\tconst first = this.followUpQueue[0];\n\t\t\t\tthis.followUpQueue = this.followUpQueue.slice(1);\n\t\t\t\treturn [first];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\n\t\tconst followUp = this.followUpQueue.slice();\n\t\tthis.followUpQueue = [];\n\t\treturn followUp;\n\t}\n\n\tclearMessages() {\n\t\tthis._state.messages = [];\n\t}\n\n\tabort() {\n\t\tthis.abortController?.abort();\n\t}\n\n\twaitForIdle(): Promise<void> {\n\t\treturn this.runningPrompt ?? Promise.resolve();\n\t}\n\n\treset() {\n\t\tthis._state.messages = [];\n\t\tthis._state.isStreaming = false;\n\t\tthis._state.streamMessage = null;\n\t\tthis._state.pendingToolCalls = new Set<string>();\n\t\tthis._state.error = undefined;\n\t\tthis.steeringQueue = [];\n\t\tthis.followUpQueue = [];\n\t}\n\n\t/** Send a prompt with an AgentMessage */\n\tasync prompt(message: AgentMessage | AgentMessage[]): Promise<void>;\n\tasync prompt(input: string, images?: ImageContent[]): Promise<void>;\n\tasync prompt(input: string | AgentMessage | AgentMessage[], images?: ImageContent[]) {\n\t\tif (this._state.isStreaming) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Agent is already processing a prompt. Use steer() or followUp() to queue messages, or wait for completion.\",\n\t\t\t);\n\t\t}\n\n\t\tconst model = this._state.model;\n\t\tif (!model) throw new Error(\"No model configured\");\n\n\t\tlet msgs: AgentMessage[];\n\n\t\tif (Array.isArray(input)) {\n\t\t\tmsgs = input;\n\t\t} else if (typeof input === \"string\") {\n\t\t\tconst content: Array<TextContent | ImageContent> = [{ type: \"text\", text: input }];\n\t\t\tif (images && images.length > 0) {\n\t\t\t\tcontent.push(...images);\n\t\t\t}\n\t\t\tmsgs = [\n\t\t\t\t{\n\t\t\t\t\trole: \"user\",\n\t\t\t\t\tcontent,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t},\n\t\t\t];\n\t\t} else {\n\t\t\tmsgs = [input];\n\t\t}\n\n\t\tawait this._runLoop(msgs);\n\t}\n\n\t/**\n\t * Continue from current context (used for retries and resuming queued messages).\n\t */\n\tasync continue() {\n\t\tif (this._state.isStreaming) {\n\t\t\tthrow new Error(\"Agent is already processing. Wait for completion before continuing.\");\n\t\t}\n\n\t\tconst messages = this._state.messages;\n\t\tif (messages.length === 0) {\n\t\t\tthrow new Error(\"No messages to continue from\");\n\t\t}\n\t\tif (messages[messages.length - 1].role === \"assistant\") {\n\t\t\tconst queuedSteering = this.dequeueSteeringMessages();\n\t\t\tif (queuedSteering.length > 0) {\n\t\t\t\tawait this._runLoop(queuedSteering, { skipInitialSteeringPoll: true });\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst queuedFollowUp = this.dequeueFollowUpMessages();\n\t\t\tif (queuedFollowUp.length > 0) {\n\t\t\t\tawait this._runLoop(queuedFollowUp);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrow new Error(\"Cannot continue from message role: assistant\");\n\t\t}\n\n\t\tawait this._runLoop(undefined);\n\t}\n\n\t/**\n\t * Run the agent loop.\n\t * If messages are provided, starts a new conversation turn with those messages.\n\t * Otherwise, continues from existing context.\n\t */\n\tprivate async _runLoop(messages?: AgentMessage[], options?: { skipInitialSteeringPoll?: boolean }) {\n\t\tconst model = this._state.model;\n\t\tif (!model) throw new Error(\"No model configured\");\n\n\t\tthis.runningPrompt = new Promise<void>((resolve) => {\n\t\t\tthis.resolveRunningPrompt = resolve;\n\t\t});\n\n\t\tthis.abortController = new AbortController();\n\t\tthis._state.isStreaming = true;\n\t\tthis._state.streamMessage = null;\n\t\tthis._state.error = undefined;\n\n\t\tconst reasoning = this._state.thinkingLevel === \"off\" ? undefined : this._state.thinkingLevel;\n\n\t\tconst context: AgentContext = {\n\t\t\tsystemPrompt: this._state.systemPrompt,\n\t\t\tmessages: this._state.messages.slice(),\n\t\t\ttools: this._state.tools,\n\t\t};\n\n\t\tlet skipInitialSteeringPoll = options?.skipInitialSteeringPoll === true;\n\n\t\tconst config: AgentLoopConfig = {\n\t\t\tmodel,\n\t\t\treasoning,\n\t\t\tsessionId: this._sessionId,\n\t\t\tonPayload: this._onPayload,\n\t\t\ttransport: this._transport,\n\t\t\tthinkingBudgets: this._thinkingBudgets,\n\t\t\tmaxRetryDelayMs: this._maxRetryDelayMs,\n\t\t\tconvertToLlm: this.convertToLlm,\n\t\t\ttransformContext: this.transformContext,\n\t\t\tgetApiKey: this.getApiKey,\n\t\t\tgetSteeringMessages: async () => {\n\t\t\t\tif (skipInitialSteeringPoll) {\n\t\t\t\t\tskipInitialSteeringPoll = false;\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn this.dequeueSteeringMessages();\n\t\t\t},\n\t\t\tgetFollowUpMessages: async () => this.dequeueFollowUpMessages(),\n\t\t};\n\n\t\tlet partial: AgentMessage | null = null;\n\n\t\ttry {\n\t\t\tconst stream = messages\n\t\t\t\t? agentLoop(messages, context, config, this.abortController.signal, this.streamFn)\n\t\t\t\t: agentLoopContinue(context, config, this.abortController.signal, this.streamFn);\n\n\t\t\tfor await (const event of stream) {\n\t\t\t\t// Update internal state based on events\n\t\t\t\tswitch (event.type) {\n\t\t\t\t\tcase \"message_start\":\n\t\t\t\t\t\tpartial = event.message;\n\t\t\t\t\t\tthis._state.streamMessage = event.message;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"message_update\":\n\t\t\t\t\t\tpartial = event.message;\n\t\t\t\t\t\tthis._state.streamMessage = event.message;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"message_end\":\n\t\t\t\t\t\tpartial = null;\n\t\t\t\t\t\tthis._state.streamMessage = null;\n\t\t\t\t\t\tthis.appendMessage(event.message);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"tool_execution_start\": {\n\t\t\t\t\t\tconst s = new Set(this._state.pendingToolCalls);\n\t\t\t\t\t\ts.add(event.toolCallId);\n\t\t\t\t\t\tthis._state.pendingToolCalls = s;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase \"tool_execution_end\": {\n\t\t\t\t\t\tconst s = new Set(this._state.pendingToolCalls);\n\t\t\t\t\t\ts.delete(event.toolCallId);\n\t\t\t\t\t\tthis._state.pendingToolCalls = s;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase \"turn_end\":\n\t\t\t\t\t\tif (event.message.role === \"assistant\" && (event.message as any).errorMessage) {\n\t\t\t\t\t\t\tthis._state.error = (event.message as any).errorMessage;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"agent_end\":\n\t\t\t\t\t\tthis._state.isStreaming = false;\n\t\t\t\t\t\tthis._state.streamMessage = null;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Emit to listeners\n\t\t\t\tthis.emit(event);\n\t\t\t}\n\n\t\t\t// Handle any remaining partial message\n\t\t\tif (partial && partial.role === \"assistant\" && partial.content.length > 0) {\n\t\t\t\tconst onlyEmpty = !partial.content.some(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\t(c.type === \"thinking\" && c.thinking.trim().length > 0) ||\n\t\t\t\t\t\t(c.type === \"text\" && c.text.trim().length > 0) ||\n\t\t\t\t\t\t(c.type === \"toolCall\" && c.name.trim().length > 0),\n\t\t\t\t);\n\t\t\t\tif (!onlyEmpty) {\n\t\t\t\t\tthis.appendMessage(partial);\n\t\t\t\t} else {\n\t\t\t\t\tif (this.abortController?.signal.aborted) {\n\t\t\t\t\t\tthrow new Error(\"Request was aborted\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\tconst errorMsg: AgentMessage = {\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: [{ type: \"text\", text: \"\" }],\n\t\t\t\tapi: model.api,\n\t\t\t\tprovider: model.provider,\n\t\t\t\tmodel: model.id,\n\t\t\t\tusage: {\n\t\t\t\t\tinput: 0,\n\t\t\t\t\toutput: 0,\n\t\t\t\t\tcacheRead: 0,\n\t\t\t\t\tcacheWrite: 0,\n\t\t\t\t\ttotalTokens: 0,\n\t\t\t\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t\t\t\t},\n\t\t\t\tstopReason: this.abortController?.signal.aborted ? \"aborted\" : \"error\",\n\t\t\t\terrorMessage: err?.message || String(err),\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t} as AgentMessage;\n\n\t\t\tthis.appendMessage(errorMsg);\n\t\t\tthis._state.error = err?.message || String(err);\n\t\t\tthis.emit({ type: \"agent_end\", messages: [errorMsg] });\n\t\t} finally {\n\t\t\tthis._state.isStreaming = false;\n\t\t\tthis._state.streamMessage = null;\n\t\t\tthis._state.pendingToolCalls = new Set<string>();\n\t\t\tthis.abortController = undefined;\n\t\t\tthis.resolveRunningPrompt?.();\n\t\t\tthis.runningPrompt = undefined;\n\t\t\tthis.resolveRunningPrompt = undefined;\n\t\t}\n\t}\n\n\tprivate emit(e: AgentEvent) {\n\t\tfor (const listener of this.listeners) {\n\t\t\tlistener(e);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAE3B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,YAAY,CAAC;AAE3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,YAAY,CAAC;AAC3B,iBAAiB;AACjB,cAAc,iBAAiB,CAAC;AAChC,kBAAkB;AAClB,cAAc,YAAY,CAAC;AAC3B,QAAQ;AACR,cAAc,YAAY,CAAC","sourcesContent":["// Core Agent\nexport * from \"./agent.js\";\n// Loop functions\nexport * from \"./agent-loop.js\";\n// Proxy utilities\nexport * from \"./proxy.js\";\n// Types\nexport * from \"./types.js\";\n"]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy stream function for apps that route LLM calls through a server.
|
|
3
|
+
* The server manages auth and proxies requests to LLM providers.
|
|
4
|
+
*/
|
|
5
|
+
import { type AssistantMessage, type AssistantMessageEvent, type Context, EventStream, type Model, type SimpleStreamOptions, type StopReason } from "@gsd/pi-ai";
|
|
6
|
+
declare class ProxyMessageEventStream extends EventStream<AssistantMessageEvent, AssistantMessage> {
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Proxy event types - server sends these with partial field stripped to reduce bandwidth.
|
|
11
|
+
*/
|
|
12
|
+
export type ProxyAssistantMessageEvent = {
|
|
13
|
+
type: "start";
|
|
14
|
+
} | {
|
|
15
|
+
type: "text_start";
|
|
16
|
+
contentIndex: number;
|
|
17
|
+
} | {
|
|
18
|
+
type: "text_delta";
|
|
19
|
+
contentIndex: number;
|
|
20
|
+
delta: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: "text_end";
|
|
23
|
+
contentIndex: number;
|
|
24
|
+
contentSignature?: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: "thinking_start";
|
|
27
|
+
contentIndex: number;
|
|
28
|
+
} | {
|
|
29
|
+
type: "thinking_delta";
|
|
30
|
+
contentIndex: number;
|
|
31
|
+
delta: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: "thinking_end";
|
|
34
|
+
contentIndex: number;
|
|
35
|
+
contentSignature?: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: "toolcall_start";
|
|
38
|
+
contentIndex: number;
|
|
39
|
+
id: string;
|
|
40
|
+
toolName: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: "toolcall_delta";
|
|
43
|
+
contentIndex: number;
|
|
44
|
+
delta: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: "toolcall_end";
|
|
47
|
+
contentIndex: number;
|
|
48
|
+
} | {
|
|
49
|
+
type: "done";
|
|
50
|
+
reason: Extract<StopReason, "stop" | "length" | "toolUse">;
|
|
51
|
+
usage: AssistantMessage["usage"];
|
|
52
|
+
} | {
|
|
53
|
+
type: "error";
|
|
54
|
+
reason: Extract<StopReason, "aborted" | "error">;
|
|
55
|
+
errorMessage?: string;
|
|
56
|
+
usage: AssistantMessage["usage"];
|
|
57
|
+
};
|
|
58
|
+
export interface ProxyStreamOptions extends SimpleStreamOptions {
|
|
59
|
+
/** Auth token for the proxy server */
|
|
60
|
+
authToken: string;
|
|
61
|
+
/** Proxy server URL (e.g., "https://genai.example.com") */
|
|
62
|
+
proxyUrl: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Stream function that proxies through a server instead of calling LLM providers directly.
|
|
66
|
+
* The server strips the partial field from delta events to reduce bandwidth.
|
|
67
|
+
* We reconstruct the partial message client-side.
|
|
68
|
+
*
|
|
69
|
+
* Use this as the `streamFn` option when creating an Agent that needs to go through a proxy.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const agent = new Agent({
|
|
74
|
+
* streamFn: (model, context, options) =>
|
|
75
|
+
* streamProxy(model, context, {
|
|
76
|
+
* ...options,
|
|
77
|
+
* authToken: await getAuthToken(),
|
|
78
|
+
* proxyUrl: "https://genai.example.com",
|
|
79
|
+
* }),
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function streamProxy(model: Model<any>, context: Context, options: ProxyStreamOptions): ProxyMessageEventStream;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=proxy.d.ts.map
|
|
@@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