gsd-pi 2.34.0 → 2.35.0-dev.cd3b7ea
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/resources/extensions/gsd/changelog.js +162 -0
- package/dist/resources/extensions/gsd/commands-bootstrap.js +1 -0
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +5 -1
- package/dist/resources/extensions/gsd/commands.js +8 -1
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +10 -0
- package/dist/resources/extensions/gsd/doctor-checks.js +113 -5
- package/dist/resources/extensions/gsd/doctor-proactive.js +22 -0
- package/dist/resources/extensions/gsd/doctor.js +36 -0
- package/dist/resources/extensions/gsd/guided-flow.js +4 -2
- package/dist/resources/extensions/gsd/preferences-validation.js +38 -0
- package/dist/resources/extensions/gsd/preferences.js +2 -0
- package/dist/resources/extensions/mcp-client/index.js +2 -1
- package/dist/resources/skills/create-gsd-extension/references/events-reference.md +4 -4
- package/package.json +1 -1
- package/packages/native/dist/native.d.ts +0 -2
- package/packages/native/dist/native.js +0 -2
- package/packages/native/src/native.ts +0 -3
- package/packages/pi-agent-core/dist/agent-loop.d.ts +14 -0
- package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +24 -27
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/dist/agent.d.ts +1 -0
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +11 -22
- package/packages/pi-agent-core/dist/agent.js.map +1 -1
- package/packages/pi-agent-core/dist/proxy.d.ts +1 -25
- package/packages/pi-agent-core/dist/proxy.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/proxy.js +3 -9
- package/packages/pi-agent-core/dist/proxy.js.map +1 -1
- package/packages/pi-agent-core/src/agent-loop.ts +30 -27
- package/packages/pi-agent-core/src/agent.ts +12 -23
- package/packages/pi-agent-core/src/proxy.ts +3 -9
- package/packages/pi-ai/dist/api-registry.d.ts +0 -2
- package/packages/pi-ai/dist/api-registry.d.ts.map +1 -1
- package/packages/pi-ai/dist/api-registry.js +0 -10
- package/packages/pi-ai/dist/api-registry.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.d.ts +0 -8
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/azure-openai-responses.js +5 -41
- package/packages/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
- package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts +0 -1
- package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/github-copilot-headers.js +1 -1
- package/packages/pi-ai/dist/providers/github-copilot-headers.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts +1 -43
- package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.js +2 -2
- package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-shared.d.ts +0 -4
- package/packages/pi-ai/dist/providers/google-shared.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/google-shared.js +1 -1
- package/packages/pi-ai/dist/providers/google-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +10 -73
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-responses.js +8 -79
- package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-shared.d.ts +65 -0
- package/packages/pi-ai/dist/providers/openai-shared.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-shared.js +146 -0
- package/packages/pi-ai/dist/providers/openai-shared.js.map +1 -0
- package/packages/pi-ai/dist/providers/register-builtins.d.ts +0 -1
- package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/register-builtins.js +1 -1
- package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -1
- package/packages/pi-ai/dist/utils/event-stream.d.ts +0 -2
- package/packages/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/event-stream.js +0 -4
- package/packages/pi-ai/dist/utils/event-stream.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.js +7 -135
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js +7 -135
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.d.ts +46 -0
- package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.js +160 -0
- package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.js.map +1 -0
- package/packages/pi-ai/dist/utils/overflow.d.ts +0 -4
- package/packages/pi-ai/dist/utils/overflow.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/overflow.js +0 -6
- package/packages/pi-ai/dist/utils/overflow.js.map +1 -1
- package/packages/pi-ai/dist/utils/validation.d.ts +0 -8
- package/packages/pi-ai/dist/utils/validation.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/validation.js +0 -14
- package/packages/pi-ai/dist/utils/validation.js.map +1 -1
- package/packages/pi-ai/src/api-registry.ts +0 -12
- package/packages/pi-ai/src/providers/anthropic.ts +1 -1
- package/packages/pi-ai/src/providers/azure-openai-responses.ts +11 -45
- package/packages/pi-ai/src/providers/github-copilot-headers.ts +1 -1
- package/packages/pi-ai/src/providers/google-gemini-cli.ts +2 -2
- package/packages/pi-ai/src/providers/google-shared.ts +1 -1
- package/packages/pi-ai/src/providers/openai-completions.ts +16 -86
- package/packages/pi-ai/src/providers/openai-responses.ts +15 -95
- package/packages/pi-ai/src/providers/openai-shared.ts +193 -0
- package/packages/pi-ai/src/providers/register-builtins.ts +1 -1
- package/packages/pi-ai/src/utils/event-stream.ts +0 -5
- package/packages/pi-ai/src/utils/oauth/google-antigravity.ts +14 -162
- package/packages/pi-ai/src/utils/oauth/google-gemini-cli.ts +13 -161
- package/packages/pi-ai/src/utils/oauth/google-oauth-utils.ts +201 -0
- package/packages/pi-ai/src/utils/overflow.ts +1 -8
- package/packages/pi-ai/src/utils/validation.ts +0 -15
- package/packages/pi-coding-agent/dist/config.d.ts +0 -9
- package/packages/pi-coding-agent/dist/config.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/config.js +4 -8
- package/packages/pi-coding-agent/dist/config.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +16 -63
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +104 -641
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +0 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.js +4 -35
- package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js +5 -43
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js +11 -69
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts +40 -0
- package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/utils.js +78 -0
- package/packages/pi-coding-agent/dist/core/compaction/utils.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts +77 -0
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js +331 -0
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts +0 -4
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js +1 -1
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +2 -2
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.js +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +15 -5
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +129 -256
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +49 -42
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.js +2 -21
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/keybindings.d.ts +0 -8
- package/packages/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/keybindings.js +2 -2
- package/packages/pi-coding-agent/dist/core/keybindings.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lock-utils.d.ts +39 -0
- package/packages/pi-coding-agent/dist/core/lock-utils.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/lock-utils.js +89 -0
- package/packages/pi-coding-agent/dist/core/lock-utils.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/lsp/client.d.ts +0 -17
- package/packages/pi-coding-agent/dist/core/lsp/client.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/client.js +3 -62
- package/packages/pi-coding-agent/dist/core/lsp/client.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/config.d.ts +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/config.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/config.js +2 -6
- package/packages/pi-coding-agent/dist/core/lsp/config.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/edits.d.ts +0 -5
- package/packages/pi-coding-agent/dist/core/lsp/edits.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/edits.js +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/edits.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/index.js +52 -107
- package/packages/pi-coding-agent/dist/core/lsp/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/lspmux.d.ts +0 -1
- package/packages/pi-coding-agent/dist/core/lsp/lspmux.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/lspmux.js +3 -22
- package/packages/pi-coding-agent/dist/core/lsp/lspmux.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/types.d.ts +0 -1
- package/packages/pi-coding-agent/dist/core/lsp/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/types.js +0 -28
- package/packages/pi-coding-agent/dist/core/lsp/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/utils.d.ts +1 -6
- package/packages/pi-coding-agent/dist/core/lsp/utils.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/utils.js +1 -28
- package/packages/pi-coding-agent/dist/core/lsp/utils.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/messages.d.ts +0 -8
- package/packages/pi-coding-agent/dist/core/messages.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/messages.js +5 -5
- package/packages/pi-coding-agent/dist/core/messages.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts +0 -3
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +1 -3
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.d.ts +1 -26
- package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.js +3 -59
- package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/package-manager.js +2 -4
- package/packages/pi-coding-agent/dist/core/package-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts +0 -17
- package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/prompt-templates.js +2 -2
- package/packages/pi-coding-agent/dist/core/prompt-templates.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/resource-loader.d.ts +2 -4
- package/packages/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/resource-loader.js +33 -58
- package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/retry-handler.d.ts +87 -0
- package/packages/pi-coding-agent/dist/core/retry-handler.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/retry-handler.js +295 -0
- package/packages/pi-coding-agent/dist/core/retry-handler.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts +0 -5
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js +5 -32
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +8 -12
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js +78 -168
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/skills.js +1 -3
- package/packages/pi-coding-agent/dist/core/skills.js.map +1 -1
- package/packages/pi-coding-agent/dist/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/index.js +1 -1
- package/packages/pi-coding-agent/dist/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/migrations.d.ts +0 -16
- package/packages/pi-coding-agent/dist/migrations.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/migrations.js +2 -2
- package/packages/pi-coding-agent/dist/migrations.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts +0 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js +2 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js +9 -26
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +1 -13
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.d.ts +44 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.js +61 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js +6 -9
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +1 -24
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +50 -512
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts +71 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +514 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +65 -4
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +6 -23
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts +12 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +175 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.d.ts +6 -0
- package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.js +15 -0
- package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/print-mode.js +2 -30
- package/packages/pi-coding-agent/dist/modes/print-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +2 -28
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.d.ts +19 -0
- package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.js +45 -0
- package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/changelog.d.ts +0 -4
- package/packages/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/utils/changelog.js +1 -1
- package/packages/pi-coding-agent/dist/utils/changelog.js.map +1 -1
- package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts +0 -1
- package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/utils/clipboard-image.js +1 -1
- package/packages/pi-coding-agent/dist/utils/clipboard-image.js.map +1 -1
- package/packages/pi-coding-agent/dist/utils/error.d.ts +5 -0
- package/packages/pi-coding-agent/dist/utils/error.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/error.js +7 -0
- package/packages/pi-coding-agent/dist/utils/error.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/photon.d.ts +0 -19
- package/packages/pi-coding-agent/dist/utils/photon.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/utils/photon.js +1 -120
- package/packages/pi-coding-agent/dist/utils/photon.js.map +1 -1
- package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts +0 -1
- package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/utils/tools-manager.js +1 -1
- package/packages/pi-coding-agent/dist/utils/tools-manager.js.map +1 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/config.ts +5 -10
- package/packages/pi-coding-agent/src/core/agent-session.ts +117 -745
- package/packages/pi-coding-agent/src/core/auth-storage.ts +4 -38
- package/packages/pi-coding-agent/src/core/compaction/branch-summarization.ts +7 -53
- package/packages/pi-coding-agent/src/core/compaction/compaction.ts +14 -74
- package/packages/pi-coding-agent/src/core/compaction/utils.ts +100 -0
- package/packages/pi-coding-agent/src/core/compaction-orchestrator.ts +424 -0
- package/packages/pi-coding-agent/src/core/export-html/ansi-to-html.ts +1 -1
- package/packages/pi-coding-agent/src/core/extensions/index.ts +1 -21
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +119 -256
- package/packages/pi-coding-agent/src/core/extensions/types.ts +50 -69
- package/packages/pi-coding-agent/src/core/keybindings.ts +2 -2
- package/packages/pi-coding-agent/src/core/lock-utils.ts +113 -0
- package/packages/pi-coding-agent/src/core/lsp/client.ts +3 -73
- package/packages/pi-coding-agent/src/core/lsp/config.ts +2 -10
- package/packages/pi-coding-agent/src/core/lsp/edits.ts +1 -1
- package/packages/pi-coding-agent/src/core/lsp/index.ts +83 -152
- package/packages/pi-coding-agent/src/core/lsp/lspmux.ts +3 -23
- package/packages/pi-coding-agent/src/core/lsp/types.ts +0 -29
- package/packages/pi-coding-agent/src/core/lsp/utils.ts +1 -33
- package/packages/pi-coding-agent/src/core/messages.ts +5 -5
- package/packages/pi-coding-agent/src/core/model-registry.ts +0 -2
- package/packages/pi-coding-agent/src/core/model-resolver.ts +3 -77
- package/packages/pi-coding-agent/src/core/package-manager.ts +1 -4
- package/packages/pi-coding-agent/src/core/prompt-templates.ts +2 -2
- package/packages/pi-coding-agent/src/core/resource-loader.ts +43 -67
- package/packages/pi-coding-agent/src/core/retry-handler.ts +359 -0
- package/packages/pi-coding-agent/src/core/session-manager.ts +5 -34
- package/packages/pi-coding-agent/src/core/settings-manager.ts +87 -166
- package/packages/pi-coding-agent/src/core/skills.ts +1 -4
- package/packages/pi-coding-agent/src/index.ts +1 -7
- package/packages/pi-coding-agent/src/migrations.ts +2 -2
- package/packages/pi-coding-agent/src/modes/interactive/components/session-selector-search.ts +2 -2
- package/packages/pi-coding-agent/src/modes/interactive/components/session-selector.ts +17 -29
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +1 -13
- package/packages/pi-coding-agent/src/modes/interactive/components/tree-render-utils.ts +81 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tree-selector.ts +14 -19
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +50 -561
- package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +653 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +7 -26
- package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +196 -0
- package/packages/pi-coding-agent/src/modes/interactive/utils/shorten-path.ts +14 -0
- package/packages/pi-coding-agent/src/modes/print-mode.ts +2 -30
- package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +2 -28
- package/packages/pi-coding-agent/src/modes/shared/command-context-actions.ts +53 -0
- package/packages/pi-coding-agent/src/utils/changelog.ts +1 -1
- package/packages/pi-coding-agent/src/utils/clipboard-image.ts +1 -1
- package/packages/pi-coding-agent/src/utils/error.ts +6 -0
- package/packages/pi-coding-agent/src/utils/photon.ts +0 -137
- package/packages/pi-coding-agent/src/utils/tools-manager.ts +1 -1
- package/packages/pi-tui/dist/components/editor.d.ts +0 -10
- package/packages/pi-tui/dist/components/editor.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/editor.js +1 -1
- package/packages/pi-tui/dist/components/editor.js.map +1 -1
- package/packages/pi-tui/dist/components/markdown.d.ts +5 -0
- package/packages/pi-tui/dist/components/markdown.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/markdown.js +25 -31
- package/packages/pi-tui/dist/components/markdown.js.map +1 -1
- package/packages/pi-tui/dist/keys.d.ts +0 -4
- package/packages/pi-tui/dist/keys.d.ts.map +1 -1
- package/packages/pi-tui/dist/keys.js +94 -162
- package/packages/pi-tui/dist/keys.js.map +1 -1
- package/packages/pi-tui/dist/overlay-layout.d.ts +55 -0
- package/packages/pi-tui/dist/overlay-layout.d.ts.map +1 -0
- package/packages/pi-tui/dist/overlay-layout.js +288 -0
- package/packages/pi-tui/dist/overlay-layout.js.map +1 -0
- package/packages/pi-tui/dist/tui.d.ts +0 -22
- package/packages/pi-tui/dist/tui.d.ts.map +1 -1
- package/packages/pi-tui/dist/tui.js +6 -272
- package/packages/pi-tui/dist/tui.js.map +1 -1
- package/packages/pi-tui/dist/utils.d.ts +0 -7
- package/packages/pi-tui/dist/utils.d.ts.map +1 -1
- package/packages/pi-tui/dist/utils.js +0 -44
- package/packages/pi-tui/dist/utils.js.map +1 -1
- package/packages/pi-tui/src/components/editor.ts +1 -1
- package/packages/pi-tui/src/components/markdown.ts +25 -29
- package/packages/pi-tui/src/keys.ts +94 -173
- package/packages/pi-tui/src/overlay-layout.ts +372 -0
- package/packages/pi-tui/src/tui.ts +11 -312
- package/packages/pi-tui/src/utils.ts +0 -43
- package/pkg/dist/core/export-html/ansi-to-html.d.ts +0 -4
- package/pkg/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/pkg/dist/core/export-html/ansi-to-html.js +1 -1
- package/pkg/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.d.ts +65 -4
- package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.js +6 -23
- package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
- package/pkg/dist/modes/interactive/theme/themes.d.ts +12 -0
- package/pkg/dist/modes/interactive/theme/themes.d.ts.map +1 -0
- package/pkg/dist/modes/interactive/theme/themes.js +175 -0
- package/pkg/dist/modes/interactive/theme/themes.js.map +1 -0
- package/pkg/package.json +1 -1
- package/src/resources/extensions/gsd/changelog.ts +213 -0
- package/src/resources/extensions/gsd/commands-bootstrap.ts +1 -0
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +5 -1
- package/src/resources/extensions/gsd/commands.ts +9 -1
- package/src/resources/extensions/gsd/docs/preferences-reference.md +10 -0
- package/src/resources/extensions/gsd/doctor-checks.ts +107 -5
- package/src/resources/extensions/gsd/doctor-proactive.ts +24 -0
- package/src/resources/extensions/gsd/doctor-types.ts +9 -1
- package/src/resources/extensions/gsd/doctor.ts +35 -0
- package/src/resources/extensions/gsd/guided-flow.ts +4 -2
- package/src/resources/extensions/gsd/preferences-validation.ts +38 -0
- package/src/resources/extensions/gsd/preferences.ts +2 -0
- package/src/resources/extensions/gsd/tests/doctor-git.test.ts +98 -2
- package/src/resources/extensions/gsd/tests/doctor-runtime.test.ts +59 -3
- package/src/resources/extensions/gsd/tests/preferences.test.ts +28 -0
- package/src/resources/extensions/mcp-client/index.ts +2 -1
- package/src/resources/skills/create-gsd-extension/references/events-reference.md +4 -4
- package/packages/pi-coding-agent/dist/modes/interactive/theme/dark.json +0 -85
- package/packages/pi-coding-agent/dist/modes/interactive/theme/light.json +0 -84
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +0 -335
- package/packages/pi-coding-agent/src/modes/interactive/theme/dark.json +0 -85
- package/packages/pi-coding-agent/src/modes/interactive/theme/light.json +0 -84
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.json +0 -335
- package/pkg/dist/modes/interactive/theme/dark.json +0 -85
- package/pkg/dist/modes/interactive/theme/light.json +0 -84
- package/pkg/dist/modes/interactive/theme/theme-schema.json +0 -335
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import type { Tool, ToolCall } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Finds a tool by name and validates the tool call arguments against its TypeBox schema
|
|
4
|
-
* @param tools Array of tool definitions
|
|
5
|
-
* @param toolCall The tool call from the LLM
|
|
6
|
-
* @returns The validated arguments
|
|
7
|
-
* @throws Error if tool is not found or validation fails
|
|
8
|
-
*/
|
|
9
|
-
export declare function validateToolCall(tools: Tool[], toolCall: ToolCall): any;
|
|
10
2
|
/**
|
|
11
3
|
* Validates tool call arguments against the tool's TypeBox schema
|
|
12
4
|
* @param tool The tool definition with TypeBox schema
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAuBlD;;;;;;GAMG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAuBlD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAG,GAAG,CA+BzE"}
|
|
@@ -23,20 +23,6 @@ if (!isBrowserExtension) {
|
|
|
23
23
|
console.warn("AJV validation disabled due to CSP restrictions");
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Finds a tool by name and validates the tool call arguments against its TypeBox schema
|
|
28
|
-
* @param tools Array of tool definitions
|
|
29
|
-
* @param toolCall The tool call from the LLM
|
|
30
|
-
* @returns The validated arguments
|
|
31
|
-
* @throws Error if tool is not found or validation fails
|
|
32
|
-
*/
|
|
33
|
-
export function validateToolCall(tools, toolCall) {
|
|
34
|
-
const tool = tools.find((t) => t.name === toolCall.name);
|
|
35
|
-
if (!tool) {
|
|
36
|
-
throw new Error(`Tool "${toolCall.name}" not found`);
|
|
37
|
-
}
|
|
38
|
-
return validateToolArguments(tool, toolCall);
|
|
39
|
-
}
|
|
40
26
|
/**
|
|
41
27
|
* Validates tool call arguments against the tool's TypeBox schema
|
|
42
28
|
* @param tool The tool definition with TypeBox schema
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,KAAK,CAAC;AAC5B,OAAO,gBAAgB,MAAM,aAAa,CAAC;AAE3C,wCAAwC;AACxC,MAAM,GAAG,GAAI,SAAiB,CAAC,OAAO,IAAI,SAAS,CAAC;AACpD,MAAM,UAAU,GAAI,gBAAwB,CAAC,OAAO,IAAI,gBAAgB,CAAC;AAIzE,qEAAqE;AACrE,2EAA2E;AAC3E,MAAM,kBAAkB,GAAG,OAAO,UAAU,KAAK,WAAW,IAAK,UAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,SAAS,CAAC;AAEtH,kFAAkF;AAClF,qEAAqE;AACrE,IAAI,GAAG,GAAQ,IAAI,CAAC;AACpB,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACzB,IAAI,CAAC;QACJ,GAAG,GAAG,IAAI,GAAG,CAAC;YACb,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,UAAU,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACb,qDAAqD;QACrD,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IACjE,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,KAAK,CAAC;AAC5B,OAAO,gBAAgB,MAAM,aAAa,CAAC;AAE3C,wCAAwC;AACxC,MAAM,GAAG,GAAI,SAAiB,CAAC,OAAO,IAAI,SAAS,CAAC;AACpD,MAAM,UAAU,GAAI,gBAAwB,CAAC,OAAO,IAAI,gBAAgB,CAAC;AAIzE,qEAAqE;AACrE,2EAA2E;AAC3E,MAAM,kBAAkB,GAAG,OAAO,UAAU,KAAK,WAAW,IAAK,UAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,SAAS,CAAC;AAEtH,kFAAkF;AAClF,qEAAqE;AACrE,IAAI,GAAG,GAAQ,IAAI,CAAC;AACpB,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACzB,IAAI,CAAC;QACJ,GAAG,GAAG,IAAI,GAAG,CAAC;YACb,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,UAAU,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACb,qDAAqD;QACrD,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IACjE,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAU,EAAE,QAAkB;IACnE,+FAA+F;IAC/F,IAAI,CAAC,GAAG,IAAI,kBAAkB,EAAE,CAAC;QAChC,4CAA4C;QAC5C,uEAAuE;QACvE,OAAO,QAAQ,CAAC,SAAS,CAAC;IAC3B,CAAC;IAED,qBAAqB;IACrB,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAE9C,6DAA6D;IAC7D,MAAM,IAAI,GAAG,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEjD,uEAAuE;IACvE,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,kCAAkC;IAClC,MAAM,MAAM,GACX,QAAQ,CAAC,MAAM;QACd,EAAE,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE;QAClB,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC;QACrG,OAAO,OAAO,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,IAAI,0BAA0B,CAAC;IAE5C,MAAM,YAAY,GAAG,+BAA+B,QAAQ,CAAC,IAAI,OAAO,MAAM,4BAA4B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;IAExJ,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import AjvModule from \"ajv\";\nimport addFormatsModule from \"ajv-formats\";\n\n// Handle both default and named exports\nconst Ajv = (AjvModule as any).default || AjvModule;\nconst addFormats = (addFormatsModule as any).default || addFormatsModule;\n\nimport type { Tool, ToolCall } from \"../types.js\";\n\n// Detect if we're in a browser extension environment with strict CSP\n// Chrome extensions with Manifest V3 don't allow eval/Function constructor\nconst isBrowserExtension = typeof globalThis !== \"undefined\" && (globalThis as any).chrome?.runtime?.id !== undefined;\n\n// Create a singleton AJV instance with formats (only if not in browser extension)\n// AJV requires 'unsafe-eval' CSP which is not allowed in Manifest V3\nlet ajv: any = null;\nif (!isBrowserExtension) {\n\ttry {\n\t\tajv = new Ajv({\n\t\t\tallErrors: true,\n\t\t\tstrict: false,\n\t\t\tcoerceTypes: true,\n\t\t});\n\t\taddFormats(ajv);\n\t} catch (_e) {\n\t\t// AJV initialization failed (likely CSP restriction)\n\t\tconsole.warn(\"AJV validation disabled due to CSP restrictions\");\n\t}\n}\n\n/**\n * Validates tool call arguments against the tool's TypeBox schema\n * @param tool The tool definition with TypeBox schema\n * @param toolCall The tool call from the LLM\n * @returns The validated (and potentially coerced) arguments\n * @throws Error with formatted message if validation fails\n */\nexport function validateToolArguments(tool: Tool, toolCall: ToolCall): any {\n\t// Skip validation in browser extension environment (CSP restrictions prevent AJV from working)\n\tif (!ajv || isBrowserExtension) {\n\t\t// Trust the LLM's output without validation\n\t\t// Browser extensions can't use AJV due to Manifest V3 CSP restrictions\n\t\treturn toolCall.arguments;\n\t}\n\n\t// Compile the schema\n\tconst validate = ajv.compile(tool.parameters);\n\n\t// Clone arguments so AJV can safely mutate for type coercion\n\tconst args = structuredClone(toolCall.arguments);\n\n\t// Validate the arguments (AJV mutates args in-place for type coercion)\n\tif (validate(args)) {\n\t\treturn args;\n\t}\n\n\t// Format validation errors nicely\n\tconst errors =\n\t\tvalidate.errors\n\t\t\t?.map((err: any) => {\n\t\t\t\tconst path = err.instancePath ? err.instancePath.substring(1) : err.params.missingProperty || \"root\";\n\t\t\t\treturn ` - ${path}: ${err.message}`;\n\t\t\t})\n\t\t\t.join(\"\\n\") || \"Unknown validation error\";\n\n\tconst errorMessage = `Validation failed for tool \"${toolCall.name}\":\\n${errors}\\n\\nReceived arguments:\\n${JSON.stringify(toolCall.arguments, null, 2)}`;\n\n\tthrow new Error(errorMessage);\n}\n"]}
|
|
@@ -81,18 +81,6 @@ export function getApiProvider(api: Api): ApiProviderInternal | undefined {
|
|
|
81
81
|
return apiProviderRegistry.get(api)?.provider;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
export function getApiProviders(): ApiProviderInternal[] {
|
|
85
|
-
return Array.from(apiProviderRegistry.values(), (entry) => entry.provider);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function unregisterApiProviders(sourceId: string): void {
|
|
89
|
-
for (const [api, entry] of apiProviderRegistry.entries()) {
|
|
90
|
-
if (entry.sourceId === sourceId) {
|
|
91
|
-
apiProviderRegistry.delete(api);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
84
|
export function clearApiProviders(): void {
|
|
97
85
|
apiProviderRegistry.clear();
|
|
98
86
|
}
|
|
@@ -230,7 +230,7 @@ function isTransientNetworkError(error: unknown): boolean {
|
|
|
230
230
|
* Checks: retry-after (seconds or RFC date), x-ratelimit-reset-requests, x-ratelimit-reset-tokens.
|
|
231
231
|
* Returns undefined if no valid delay is found or if the delay is in the past.
|
|
232
232
|
*/
|
|
233
|
-
|
|
233
|
+
function extractRetryAfterMs(headers: Headers | { get(name: string): string | null }, errorText = ""): number | undefined {
|
|
234
234
|
const normalizeDelay = (ms: number): number | undefined => (ms > 0 ? Math.ceil(ms + 1000) : undefined);
|
|
235
235
|
|
|
236
236
|
const retryAfter = headers.get("retry-after");
|
|
@@ -5,8 +5,6 @@ import type { ResponseCreateParamsStreaming } from "openai/resources/responses/r
|
|
|
5
5
|
import { getEnvApiKey } from "../env-api-keys.js";
|
|
6
6
|
import { supportsXhigh } from "../models.js";
|
|
7
7
|
import type {
|
|
8
|
-
Api,
|
|
9
|
-
AssistantMessage,
|
|
10
8
|
Context,
|
|
11
9
|
Model,
|
|
12
10
|
SimpleStreamOptions,
|
|
@@ -15,6 +13,13 @@ import type {
|
|
|
15
13
|
} from "../types.js";
|
|
16
14
|
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
17
15
|
import { convertResponsesMessages, convertResponsesTools, processResponsesStream } from "./openai-responses-shared.js";
|
|
16
|
+
import {
|
|
17
|
+
assertStreamSuccess,
|
|
18
|
+
buildInitialOutput,
|
|
19
|
+
clampReasoningForModel,
|
|
20
|
+
finalizeStream,
|
|
21
|
+
handleStreamError,
|
|
22
|
+
} from "./openai-shared.js";
|
|
18
23
|
import { buildBaseOptions, clampReasoning } from "./simple-options.js";
|
|
19
24
|
|
|
20
25
|
let _AzureOpenAIClass: typeof AzureOpenAI | undefined;
|
|
@@ -26,16 +31,6 @@ async function getAzureOpenAIClass(): Promise<typeof AzureOpenAI> {
|
|
|
26
31
|
return _AzureOpenAIClass;
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
/**
|
|
30
|
-
* Clamp reasoning effort for models that don't support all levels.
|
|
31
|
-
* gpt-5.x models don't support "minimal" — map to "low".
|
|
32
|
-
*/
|
|
33
|
-
function clampReasoningForModel(modelName: string, effort: string): string {
|
|
34
|
-
const name = modelName.includes("/") ? modelName.split("/").pop()! : modelName;
|
|
35
|
-
if (name.startsWith("gpt-5") && effort === "minimal") return "low";
|
|
36
|
-
return effort;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
34
|
const DEFAULT_AZURE_API_VERSION = "v1";
|
|
40
35
|
const AZURE_TOOL_CALL_PROVIDERS = new Set(["openai", "openai-codex", "opencode", "azure-openai-responses"]);
|
|
41
36
|
|
|
@@ -83,24 +78,7 @@ export const streamAzureOpenAIResponses: StreamFunction<"azure-openai-responses"
|
|
|
83
78
|
// Start async processing
|
|
84
79
|
(async () => {
|
|
85
80
|
const deploymentName = resolveDeploymentName(model, options);
|
|
86
|
-
|
|
87
|
-
const output: AssistantMessage = {
|
|
88
|
-
role: "assistant",
|
|
89
|
-
content: [],
|
|
90
|
-
api: "azure-openai-responses" as Api,
|
|
91
|
-
provider: model.provider,
|
|
92
|
-
model: model.id,
|
|
93
|
-
usage: {
|
|
94
|
-
input: 0,
|
|
95
|
-
output: 0,
|
|
96
|
-
cacheRead: 0,
|
|
97
|
-
cacheWrite: 0,
|
|
98
|
-
totalTokens: 0,
|
|
99
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
100
|
-
},
|
|
101
|
-
stopReason: "stop",
|
|
102
|
-
timestamp: Date.now(),
|
|
103
|
-
};
|
|
81
|
+
const output = buildInitialOutput(model);
|
|
104
82
|
|
|
105
83
|
try {
|
|
106
84
|
// Create Azure OpenAI client
|
|
@@ -119,22 +97,10 @@ export const streamAzureOpenAIResponses: StreamFunction<"azure-openai-responses"
|
|
|
119
97
|
|
|
120
98
|
await processResponsesStream(openaiStream, output, stream, model);
|
|
121
99
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
|
127
|
-
throw new Error("An unknown error occurred");
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
stream.push({ type: "done", reason: output.stopReason, message: output });
|
|
131
|
-
stream.end();
|
|
100
|
+
assertStreamSuccess(output, options?.signal);
|
|
101
|
+
finalizeStream(stream, output);
|
|
132
102
|
} catch (error) {
|
|
133
|
-
|
|
134
|
-
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
135
|
-
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
136
|
-
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
137
|
-
stream.end();
|
|
103
|
+
handleStreamError(stream, output, error, options?.signal);
|
|
138
104
|
}
|
|
139
105
|
})();
|
|
140
106
|
|
|
@@ -2,7 +2,7 @@ import type { Message } from "../types.js";
|
|
|
2
2
|
|
|
3
3
|
// Copilot expects X-Initiator to indicate whether the request is user-initiated
|
|
4
4
|
// or agent-initiated (e.g. follow-up after assistant/tool messages).
|
|
5
|
-
|
|
5
|
+
function inferCopilotInitiator(messages: Message[]): "user" | "agent" {
|
|
6
6
|
const last = messages[messages.length - 1];
|
|
7
7
|
return last && last.role !== "user" ? "agent" : "user";
|
|
8
8
|
}
|
|
@@ -112,7 +112,7 @@ const CLAUDE_THINKING_BETA_HEADER = "interleaved-thinking-2025-05-14";
|
|
|
112
112
|
* - "Please retry in Xs" or "Please retry in Xms"
|
|
113
113
|
* - "retryDelay": "34.074824224s" (JSON field)
|
|
114
114
|
*/
|
|
115
|
-
|
|
115
|
+
function extractRetryDelay(errorText: string, response?: Response | Headers): number | undefined {
|
|
116
116
|
const normalizeDelay = (ms: number): number | undefined => (ms > 0 ? Math.ceil(ms + 1000) : undefined);
|
|
117
117
|
|
|
118
118
|
const headers = response instanceof Headers ? response : response?.headers;
|
|
@@ -865,7 +865,7 @@ export const streamSimpleGoogleGeminiCli: StreamFunction<"google-gemini-cli", Si
|
|
|
865
865
|
} satisfies GoogleGeminiCliOptions);
|
|
866
866
|
};
|
|
867
867
|
|
|
868
|
-
|
|
868
|
+
function buildRequest(
|
|
869
869
|
model: Model<"google-gemini-cli">,
|
|
870
870
|
context: Context,
|
|
871
871
|
projectId: string,
|
|
@@ -66,7 +66,7 @@ function resolveThoughtSignature(isSameProviderAndModel: boolean, signature: str
|
|
|
66
66
|
/**
|
|
67
67
|
* Models via Google APIs that require explicit tool call IDs in function calls/responses.
|
|
68
68
|
*/
|
|
69
|
-
|
|
69
|
+
function requiresToolCallId(modelId: string): boolean {
|
|
70
70
|
return modelId.startsWith("claude-") || modelId.startsWith("gpt-oss-");
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -31,19 +31,16 @@ import type {
|
|
|
31
31
|
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
32
32
|
import { parseStreamingJson } from "../utils/json-parse.js";
|
|
33
33
|
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
34
|
-
import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "./github-copilot-headers.js";
|
|
35
34
|
import { buildBaseOptions, clampReasoning } from "./simple-options.js";
|
|
35
|
+
import {
|
|
36
|
+
assertStreamSuccess,
|
|
37
|
+
buildInitialOutput,
|
|
38
|
+
createOpenAIClient,
|
|
39
|
+
finalizeStream,
|
|
40
|
+
handleStreamError,
|
|
41
|
+
} from "./openai-shared.js";
|
|
36
42
|
import { transformMessages } from "./transform-messages.js";
|
|
37
43
|
|
|
38
|
-
let _OpenAICompletionsClass: typeof OpenAI | undefined;
|
|
39
|
-
async function getOpenAICompletionsClass(): Promise<typeof OpenAI> {
|
|
40
|
-
if (!_OpenAICompletionsClass) {
|
|
41
|
-
const mod = await import("openai");
|
|
42
|
-
_OpenAICompletionsClass = mod.default;
|
|
43
|
-
}
|
|
44
|
-
return _OpenAICompletionsClass;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
44
|
/**
|
|
48
45
|
* Check if conversation messages contain tool calls or tool results.
|
|
49
46
|
* This is needed because Anthropic (via proxy) requires the tools param
|
|
@@ -76,27 +73,15 @@ export const streamOpenAICompletions: StreamFunction<"openai-completions", OpenA
|
|
|
76
73
|
const stream = new AssistantMessageEventStream();
|
|
77
74
|
|
|
78
75
|
(async () => {
|
|
79
|
-
const output
|
|
80
|
-
role: "assistant",
|
|
81
|
-
content: [],
|
|
82
|
-
api: model.api,
|
|
83
|
-
provider: model.provider,
|
|
84
|
-
model: model.id,
|
|
85
|
-
usage: {
|
|
86
|
-
input: 0,
|
|
87
|
-
output: 0,
|
|
88
|
-
cacheRead: 0,
|
|
89
|
-
cacheWrite: 0,
|
|
90
|
-
totalTokens: 0,
|
|
91
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
92
|
-
},
|
|
93
|
-
stopReason: "stop",
|
|
94
|
-
timestamp: Date.now(),
|
|
95
|
-
};
|
|
76
|
+
const output = buildInitialOutput(model);
|
|
96
77
|
|
|
97
78
|
try {
|
|
98
79
|
const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
|
|
99
|
-
const
|
|
80
|
+
const isZai = model.provider === "zai" || model.baseUrl.includes("api.z.ai");
|
|
81
|
+
const client = await createOpenAIClient(model, context, apiKey, {
|
|
82
|
+
optionsHeaders: options?.headers,
|
|
83
|
+
extraClientOptions: isZai ? { timeout: 100_000, maxRetries: 4 } : undefined,
|
|
84
|
+
});
|
|
100
85
|
let params = buildParams(model, context, options);
|
|
101
86
|
const nextParams = await options?.onPayload?.(params, model);
|
|
102
87
|
if (nextParams !== undefined) {
|
|
@@ -292,25 +277,12 @@ export const streamOpenAICompletions: StreamFunction<"openai-completions", OpenA
|
|
|
292
277
|
}
|
|
293
278
|
|
|
294
279
|
finishCurrentBlock(currentBlock);
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
|
300
|
-
throw new Error("An unknown error occurred");
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
stream.push({ type: "done", reason: output.stopReason, message: output });
|
|
304
|
-
stream.end();
|
|
280
|
+
assertStreamSuccess(output, options?.signal);
|
|
281
|
+
finalizeStream(stream, output);
|
|
305
282
|
} catch (error) {
|
|
306
|
-
for (const block of output.content) delete (block as any).index;
|
|
307
|
-
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
308
|
-
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
309
283
|
// Some providers via OpenRouter give additional information in this field.
|
|
310
284
|
const rawMetadata = (error as any)?.error?.metadata?.raw;
|
|
311
|
-
|
|
312
|
-
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
313
|
-
stream.end();
|
|
285
|
+
handleStreamError(stream, output, error, options?.signal, rawMetadata);
|
|
314
286
|
}
|
|
315
287
|
})();
|
|
316
288
|
|
|
@@ -338,48 +310,6 @@ export const streamSimpleOpenAICompletions: StreamFunction<"openai-completions",
|
|
|
338
310
|
} satisfies OpenAICompletionsOptions);
|
|
339
311
|
};
|
|
340
312
|
|
|
341
|
-
async function createClient(
|
|
342
|
-
model: Model<"openai-completions">,
|
|
343
|
-
context: Context,
|
|
344
|
-
apiKey?: string,
|
|
345
|
-
optionsHeaders?: Record<string, string>,
|
|
346
|
-
) {
|
|
347
|
-
if (!apiKey) {
|
|
348
|
-
if (!process.env.OPENAI_API_KEY) {
|
|
349
|
-
throw new Error(
|
|
350
|
-
"OpenAI API key is required. Set OPENAI_API_KEY environment variable or pass it as an argument.",
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
apiKey = process.env.OPENAI_API_KEY;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
const headers = { ...model.headers };
|
|
357
|
-
if (model.provider === "github-copilot") {
|
|
358
|
-
const hasImages = hasCopilotVisionInput(context.messages);
|
|
359
|
-
const copilotHeaders = buildCopilotDynamicHeaders({
|
|
360
|
-
messages: context.messages,
|
|
361
|
-
hasImages,
|
|
362
|
-
});
|
|
363
|
-
Object.assign(headers, copilotHeaders);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// Merge options headers last so they can override defaults
|
|
367
|
-
if (optionsHeaders) {
|
|
368
|
-
Object.assign(headers, optionsHeaders);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
const isZai = model.provider === "zai" || model.baseUrl.includes("api.z.ai");
|
|
372
|
-
const OpenAIClass = await getOpenAICompletionsClass();
|
|
373
|
-
|
|
374
|
-
return new OpenAIClass({
|
|
375
|
-
apiKey,
|
|
376
|
-
baseURL: model.baseUrl,
|
|
377
|
-
dangerouslyAllowBrowser: true,
|
|
378
|
-
defaultHeaders: headers,
|
|
379
|
-
...(isZai && { timeout: 100_000, maxRetries: 4 }),
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
|
|
383
313
|
function buildParams(model: Model<"openai-completions">, context: Context, options?: OpenAICompletionsOptions) {
|
|
384
314
|
const compat = getCompat(model);
|
|
385
315
|
const messages = convertMessages(model, context, compat);
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
// Lazy-loaded: OpenAI SDK is imported on first use, not at startup.
|
|
2
2
|
// This avoids penalizing users who don't use OpenAI models.
|
|
3
|
-
import type OpenAI from "openai";
|
|
4
3
|
import type { ResponseCreateParamsStreaming } from "openai/resources/responses/responses.js";
|
|
5
4
|
import { getEnvApiKey } from "../env-api-keys.js";
|
|
6
5
|
import { supportsXhigh } from "../models.js";
|
|
7
6
|
import type {
|
|
8
|
-
Api,
|
|
9
|
-
AssistantMessage,
|
|
10
7
|
CacheRetention,
|
|
11
8
|
Context,
|
|
12
9
|
Model,
|
|
@@ -16,29 +13,17 @@ import type {
|
|
|
16
13
|
Usage,
|
|
17
14
|
} from "../types.js";
|
|
18
15
|
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
19
|
-
import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "./github-copilot-headers.js";
|
|
20
16
|
import { convertResponsesMessages, convertResponsesTools, processResponsesStream } from "./openai-responses-shared.js";
|
|
17
|
+
import {
|
|
18
|
+
assertStreamSuccess,
|
|
19
|
+
buildInitialOutput,
|
|
20
|
+
clampReasoningForModel,
|
|
21
|
+
createOpenAIClient,
|
|
22
|
+
finalizeStream,
|
|
23
|
+
handleStreamError,
|
|
24
|
+
} from "./openai-shared.js";
|
|
21
25
|
import { buildBaseOptions, clampReasoning } from "./simple-options.js";
|
|
22
26
|
|
|
23
|
-
let _OpenAIResponsesClass: typeof OpenAI | undefined;
|
|
24
|
-
async function getOpenAIResponsesClass(): Promise<typeof OpenAI> {
|
|
25
|
-
if (!_OpenAIResponsesClass) {
|
|
26
|
-
const mod = await import("openai");
|
|
27
|
-
_OpenAIResponsesClass = mod.default;
|
|
28
|
-
}
|
|
29
|
-
return _OpenAIResponsesClass;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Clamp reasoning effort for models that don't support all levels.
|
|
34
|
-
* gpt-5.x models don't support "minimal" — map to "low".
|
|
35
|
-
*/
|
|
36
|
-
function clampReasoningForModel(modelName: string, effort: string): string {
|
|
37
|
-
const name = modelName.includes("/") ? modelName.split("/").pop()! : modelName;
|
|
38
|
-
if (name.startsWith("gpt-5") && effort === "minimal") return "low";
|
|
39
|
-
return effort;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
27
|
const OPENAI_TOOL_CALL_PROVIDERS = new Set(["openai", "openai-codex", "opencode"]);
|
|
43
28
|
|
|
44
29
|
/**
|
|
@@ -88,28 +73,14 @@ export const streamOpenAIResponses: StreamFunction<"openai-responses", OpenAIRes
|
|
|
88
73
|
|
|
89
74
|
// Start async processing
|
|
90
75
|
(async () => {
|
|
91
|
-
const output
|
|
92
|
-
role: "assistant",
|
|
93
|
-
content: [],
|
|
94
|
-
api: model.api as Api,
|
|
95
|
-
provider: model.provider,
|
|
96
|
-
model: model.id,
|
|
97
|
-
usage: {
|
|
98
|
-
input: 0,
|
|
99
|
-
output: 0,
|
|
100
|
-
cacheRead: 0,
|
|
101
|
-
cacheWrite: 0,
|
|
102
|
-
totalTokens: 0,
|
|
103
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
104
|
-
},
|
|
105
|
-
stopReason: "stop",
|
|
106
|
-
timestamp: Date.now(),
|
|
107
|
-
};
|
|
76
|
+
const output = buildInitialOutput(model);
|
|
108
77
|
|
|
109
78
|
try {
|
|
110
79
|
// Create OpenAI client
|
|
111
80
|
const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
|
|
112
|
-
const client = await
|
|
81
|
+
const client = await createOpenAIClient(model, context, apiKey, {
|
|
82
|
+
optionsHeaders: options?.headers,
|
|
83
|
+
});
|
|
113
84
|
let params = buildParams(model, context, options);
|
|
114
85
|
const nextParams = await options?.onPayload?.(params, model);
|
|
115
86
|
if (nextParams !== undefined) {
|
|
@@ -126,22 +97,10 @@ export const streamOpenAIResponses: StreamFunction<"openai-responses", OpenAIRes
|
|
|
126
97
|
applyServiceTierPricing,
|
|
127
98
|
});
|
|
128
99
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
|
134
|
-
throw new Error("An unknown error occurred");
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
stream.push({ type: "done", reason: output.stopReason, message: output });
|
|
138
|
-
stream.end();
|
|
100
|
+
assertStreamSuccess(output, options?.signal);
|
|
101
|
+
finalizeStream(stream, output);
|
|
139
102
|
} catch (error) {
|
|
140
|
-
|
|
141
|
-
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
142
|
-
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
143
|
-
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
144
|
-
stream.end();
|
|
103
|
+
handleStreamError(stream, output, error, options?.signal);
|
|
145
104
|
}
|
|
146
105
|
})();
|
|
147
106
|
|
|
@@ -167,45 +126,6 @@ export const streamSimpleOpenAIResponses: StreamFunction<"openai-responses", Sim
|
|
|
167
126
|
} satisfies OpenAIResponsesOptions);
|
|
168
127
|
};
|
|
169
128
|
|
|
170
|
-
async function createClient(
|
|
171
|
-
model: Model<"openai-responses">,
|
|
172
|
-
context: Context,
|
|
173
|
-
apiKey?: string,
|
|
174
|
-
optionsHeaders?: Record<string, string>,
|
|
175
|
-
) {
|
|
176
|
-
if (!apiKey) {
|
|
177
|
-
if (!process.env.OPENAI_API_KEY) {
|
|
178
|
-
throw new Error(
|
|
179
|
-
"OpenAI API key is required. Set OPENAI_API_KEY environment variable or pass it as an argument.",
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
apiKey = process.env.OPENAI_API_KEY;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const headers = { ...model.headers };
|
|
186
|
-
if (model.provider === "github-copilot") {
|
|
187
|
-
const hasImages = hasCopilotVisionInput(context.messages);
|
|
188
|
-
const copilotHeaders = buildCopilotDynamicHeaders({
|
|
189
|
-
messages: context.messages,
|
|
190
|
-
hasImages,
|
|
191
|
-
});
|
|
192
|
-
Object.assign(headers, copilotHeaders);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Merge options headers last so they can override defaults
|
|
196
|
-
if (optionsHeaders) {
|
|
197
|
-
Object.assign(headers, optionsHeaders);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const OpenAIClass = await getOpenAIResponsesClass();
|
|
201
|
-
return new OpenAIClass({
|
|
202
|
-
apiKey,
|
|
203
|
-
baseURL: model.baseUrl,
|
|
204
|
-
dangerouslyAllowBrowser: true,
|
|
205
|
-
defaultHeaders: headers,
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
129
|
function buildParams(model: Model<"openai-responses">, context: Context, options?: OpenAIResponsesOptions) {
|
|
210
130
|
const messages = convertResponsesMessages(model, context, OPENAI_TOOL_CALL_PROVIDERS);
|
|
211
131
|
|