@code-yeongyu/senpi 2026.7.23 → 2026.7.24
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/CHANGELOG.md +131 -6
- package/README.md +14 -1
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +6 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +15 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +12 -2
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +102 -4
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1295 -320
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +7 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +8 -12
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +22 -4
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +114 -51
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/lifecycle.d.ts +69 -0
- package/dist/core/compaction/lifecycle.d.ts.map +1 -0
- package/dist/core/compaction/lifecycle.js +104 -0
- package/dist/core/compaction/lifecycle.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +12 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +22 -17
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js +11 -1
- package/dist/core/event-bus.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.d.ts +2 -1
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +42 -30
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote-model.d.ts +9 -2
- package/dist/core/extensions/builtin/compaction/openai-remote-model.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote-model.js +78 -28
- package/dist/core/extensions/builtin/compaction/openai-remote-model.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote-schema.d.ts +3 -1
- package/dist/core/extensions/builtin/compaction/openai-remote-schema.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote-schema.js +19 -1
- package/dist/core/extensions/builtin/compaction/openai-remote-schema.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote.d.ts +20 -6
- package/dist/core/extensions/builtin/compaction/openai-remote.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote.js +207 -22
- package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative.d.ts +4 -2
- package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative.js +25 -13
- package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
- package/dist/core/extensions/builtin/config-reload/index.d.ts +7 -0
- package/dist/core/extensions/builtin/config-reload/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/config-reload/index.js +49 -17
- package/dist/core/extensions/builtin/config-reload/index.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/index.js +1 -1
- package/dist/core/extensions/builtin/hooks/index.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/lifecycle-adapter.d.ts +3 -1
- package/dist/core/extensions/builtin/hooks/lifecycle-adapter.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/lifecycle-adapter.js +2 -1
- package/dist/core/extensions/builtin/hooks/lifecycle-adapter.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/auth/commands-auth-dispatch.d.ts +2 -1
- package/dist/core/extensions/builtin/mcp/auth/commands-auth-dispatch.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/auth/commands-auth-dispatch.js +5 -3
- package/dist/core/extensions/builtin/mcp/auth/commands-auth-dispatch.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/auth/commands-auth.d.ts +5 -0
- package/dist/core/extensions/builtin/mcp/auth/commands-auth.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/auth/commands-auth.js +8 -3
- package/dist/core/extensions/builtin/mcp/auth/commands-auth.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/catalog.d.ts +3 -1
- package/dist/core/extensions/builtin/mcp/catalog.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/catalog.js +2 -0
- package/dist/core/extensions/builtin/mcp/catalog.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/commands.d.ts +1 -1
- package/dist/core/extensions/builtin/mcp/commands.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/commands.js +34 -39
- package/dist/core/extensions/builtin/mcp/commands.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/connection-types.d.ts +2 -0
- package/dist/core/extensions/builtin/mcp/connection-types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/connection-types.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/connection.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/connection.js +3 -0
- package/dist/core/extensions/builtin/mcp/connection.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/elicitation.d.ts +7 -3
- package/dist/core/extensions/builtin/mcp/elicitation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/elicitation.js +5 -5
- package/dist/core/extensions/builtin/mcp/elicitation.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/register.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/register.js +1 -0
- package/dist/core/extensions/builtin/mcp/expose/register.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/session.d.ts +2 -0
- package/dist/core/extensions/builtin/mcp/expose/session.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/session.js +3 -0
- package/dist/core/extensions/builtin/mcp/expose/session.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/guard/output-guard.d.ts +9 -1
- package/dist/core/extensions/builtin/mcp/guard/output-guard.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/guard/output-guard.js +18 -6
- package/dist/core/extensions/builtin/mcp/guard/output-guard.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/index.d.ts +4 -2
- package/dist/core/extensions/builtin/mcp/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/index.js +150 -127
- package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/instructions.d.ts +1 -1
- package/dist/core/extensions/builtin/mcp/instructions.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/instructions.js +6 -6
- package/dist/core/extensions/builtin/mcp/instructions.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/prompts.d.ts +2 -0
- package/dist/core/extensions/builtin/mcp/prompts.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/prompts.js +9 -3
- package/dist/core/extensions/builtin/mcp/prompts.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/resources.d.ts +2 -0
- package/dist/core/extensions/builtin/mcp/resources.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/resources.js +1 -0
- package/dist/core/extensions/builtin/mcp/resources.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-register.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-register.js +1 -0
- package/dist/core/extensions/builtin/mcp/service-register.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-types.d.ts +2 -0
- package/dist/core/extensions/builtin/mcp/service-types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-types.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.d.ts +12 -1
- package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.js +44 -2
- package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/transport.d.ts +2 -0
- package/dist/core/extensions/builtin/mcp/transport.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/transport.js +7 -7
- package/dist/core/extensions/builtin/mcp/transport.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +86 -7
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.d.ts +3 -0
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js +102 -0
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +96 -6
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.js +9 -0
- package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.js +1 -0
- package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.js +1 -0
- package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash.d.ts +15 -3
- package/dist/core/extensions/builtin/terminal/tools/bash.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash.js +30 -6
- package/dist/core/extensions/builtin/terminal/tools/bash.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/context.d.ts +5 -0
- package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +14 -7
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +64 -37
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +30 -3
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +16 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +10 -8
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry.d.ts +1 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +3 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +9 -0
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +4 -2
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +34 -18
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +21 -7
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +12 -8
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +8 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +22 -3
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +155 -58
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +34 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/usage-totals.d.ts +19 -0
- package/dist/core/usage-totals.d.ts.map +1 -0
- package/dist/core/usage-totals.js +52 -0
- package/dist/core/usage-totals.js.map +1 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +3 -1
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/index.js +3 -3
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +1 -2
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +37 -5
- package/dist/main.js.map +1 -1
- package/dist/modes/app-server/daemon/occupancy.d.ts +22 -0
- package/dist/modes/app-server/daemon/occupancy.d.ts.map +1 -0
- package/dist/modes/app-server/daemon/occupancy.js +67 -0
- package/dist/modes/app-server/daemon/occupancy.js.map +1 -0
- package/dist/modes/app-server/daemon/probe.d.ts +3 -3
- package/dist/modes/app-server/daemon/probe.d.ts.map +1 -1
- package/dist/modes/app-server/daemon/probe.js +33 -10
- package/dist/modes/app-server/daemon/probe.js.map +1 -1
- package/dist/modes/app-server/daemon.d.ts.map +1 -1
- package/dist/modes/app-server/daemon.js +58 -18
- package/dist/modes/app-server/daemon.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +8 -1
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +16 -46
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +4 -0
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +13 -0
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +12 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -0
- package/dist/modes/interactive/external-editor.js +37 -0
- package/dist/modes/interactive/external-editor.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +3 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +96 -78
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts +6 -0
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +34 -9
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/modes/rpc/multi-session-host.d.ts +15 -0
- package/dist/modes/rpc/multi-session-host.d.ts.map +1 -0
- package/dist/modes/rpc/multi-session-host.js +60 -0
- package/dist/modes/rpc/multi-session-host.js.map +1 -0
- package/dist/modes/rpc/neo-runtime-options.d.ts.map +1 -1
- package/dist/modes/rpc/neo-runtime-options.js +1 -0
- package/dist/modes/rpc/neo-runtime-options.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +4 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +49 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +49 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +85 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js +8 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/rpc/session-binding.d.ts +13 -0
- package/dist/modes/rpc/session-binding.d.ts.map +1 -0
- package/dist/modes/rpc/session-binding.js +33 -0
- package/dist/modes/rpc/session-binding.js.map +1 -0
- package/dist/modes/rpc/session-command-router.d.ts +19 -0
- package/dist/modes/rpc/session-command-router.d.ts.map +1 -0
- package/dist/modes/rpc/session-command-router.js +159 -0
- package/dist/modes/rpc/session-command-router.js.map +1 -0
- package/dist/modes/rpc/session-event-writer.d.ts +34 -0
- package/dist/modes/rpc/session-event-writer.d.ts.map +1 -0
- package/dist/modes/rpc/session-event-writer.js +92 -0
- package/dist/modes/rpc/session-event-writer.js.map +1 -0
- package/dist/modes/rpc/session-extension-ui-requests.d.ts +15 -0
- package/dist/modes/rpc/session-extension-ui-requests.d.ts.map +1 -0
- package/dist/modes/rpc/session-extension-ui-requests.js +27 -0
- package/dist/modes/rpc/session-extension-ui-requests.js.map +1 -0
- package/dist/modes/rpc/session-registry.d.ts +58 -0
- package/dist/modes/rpc/session-registry.d.ts.map +1 -0
- package/dist/modes/rpc/session-registry.js +162 -0
- package/dist/modes/rpc/session-registry.js.map +1 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +19 -8
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/app-server-daemon.md +3 -2
- package/docs/compaction.md +9 -4
- package/docs/custom-provider.md +5 -2
- package/docs/environment-variables.md +88 -0
- package/docs/extensions.md +25 -7
- package/docs/index.md +1 -0
- package/docs/json.md +5 -1
- package/docs/models.md +6 -2
- package/docs/providers.md +12 -1
- package/docs/rpc.md +154 -8
- package/docs/sdk.md +3 -0
- package/docs/session-format.md +17 -3
- package/docs/settings.md +2 -2
- package/docs/usage.md +1 -14
- package/examples/extensions/custom-compaction.ts +4 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/handoff.ts +9 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/summarize.ts +3 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +24 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
- package/node_modules/@earendil-works/pi-agent-core/README.md +31 -12
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +4 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +8 -7
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +10 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +61 -27
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts +11 -12
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +47 -22
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts +5 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js +6 -8
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts +17 -5
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +82 -27
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts +12 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js +22 -17
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts +3 -9
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +118 -11
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts +11 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +56 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts +11 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +56 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +2 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +6 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +30 -14
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.d.ts +27 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.js +132 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.d.ts +89 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.js +386 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.d.ts +19 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js +95 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.d.ts +4 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.js +46 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.d.ts +3 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.js +106 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.d.ts +6 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.js +5 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.d.ts +4 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.js +26 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.d.ts +34 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.js +110 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.d.ts +6 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.js +2 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.d.ts +11 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js +31 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +80 -18
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts +12 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +90 -35
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js +10 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +4 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/index.js +5 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.d.ts +10 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.js +17 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +8 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +4 -3
- package/node_modules/@earendil-works/pi-ai/README.md +44 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +45 -27
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +21 -8
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +17 -10
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.d.ts +17 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +104 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +7 -11
- package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts +4 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +17 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +7 -11
- package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +13 -9
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +73 -47
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +7 -9
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +142 -33
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +7 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +180 -80
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +37 -15
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +8 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api-registry.js +52 -6
- package/node_modules/@earendil-works/pi-ai/dist/api-registry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js +3 -2
- package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.d.ts +10 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js +249 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +10 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js +2 -18
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts +13 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js +222 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/context-provenance.d.ts +16 -0
- package/node_modules/@earendil-works/pi-ai/dist/context-provenance.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/context-provenance.js +32 -0
- package/node_modules/@earendil-works/pi-ai/dist/context-provenance.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +11 -3
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts +19 -2
- package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js +68 -3
- package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.js +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/model-catalog.d.ts +17 -0
- package/node_modules/@earendil-works/pi-ai/dist/model-catalog.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/model-catalog.js +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/model-catalog.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/model.d.ts +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/model.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/model.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models-store.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +0 -6
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +76 -4448
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js +0 -53
- package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.d.ts +12 -0
- package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.js +34 -0
- package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/alibaba-token-plan.models.d.ts +3 -63
- package/node_modules/@earendil-works/pi-ai/dist/providers/alibaba-token-plan.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/alibaba-token-plan.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/alibaba-token-plan.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +10 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +3 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts +3 -439
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts +3 -15
- package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +30 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts +3 -59
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +3 -187
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts +3 -15
- package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts +3 -171
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts +3 -55
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/alibaba-token-plan.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/ant-ling.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/deepseek.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/groq.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts +3 -11
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts +3 -67
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +3 -115
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts +3 -51
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts +3 -75
- package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts +3 -31
- package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts +3 -203
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.js +10 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts +3 -19
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts +3 -15
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts +3 -15
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts +3 -123
- package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts +3 -43
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts +3 -43
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts +3 -79
- package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts +3 -31
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts +3 -187
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +3 -67
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +3 -227
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.js +10 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js +10 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +3 -1095
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.js +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.js +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.js +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.js +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js +18 -14
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts +3 -67
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +3 -775
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts +3 -15
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts +3 -15
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts +3 -15
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts +3 -15
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts +3 -27
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts +3 -27
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts +3 -27
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +43 -3
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/openai-codex-auth.d.ts +11 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/openai-codex-auth.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/openai-codex-auth.js +30 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/openai-codex-auth.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts +16 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +94 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts +41 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +82 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/text.js +10 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/text.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/uuid.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/uuid.d.ts.map +1 -0
- package/node_modules/@earendil-works/{pi-agent-core/dist/harness/session → pi-ai/dist/utils}/uuid.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/utils/uuid.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/package.json +11 -4
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +31 -22
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js +2 -0
- package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -6
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.d.ts +0 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.js.map +0 -1
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { getRegisteredFauxProvider } from "./providers/faux.js";
|
|
2
2
|
const apiProviderRegistry = new Map();
|
|
3
|
+
const builtinApiProviderRegistry = new Map();
|
|
4
|
+
let getProviderScope = () => undefined;
|
|
5
|
+
let providerScopeStrictMode = false;
|
|
6
|
+
/** Installs the optional node-only scope lookup without importing node APIs here. */
|
|
7
|
+
export function installProviderScopeAccessor(accessor) {
|
|
8
|
+
getProviderScope = accessor;
|
|
9
|
+
}
|
|
10
|
+
export function setProviderScopeStrictMode(enabled) {
|
|
11
|
+
providerScopeStrictMode = enabled;
|
|
12
|
+
}
|
|
13
|
+
function getActiveProviderScope() {
|
|
14
|
+
const scope = getProviderScope();
|
|
15
|
+
if (scope?.state === "closed")
|
|
16
|
+
throw new Error("Provider scope is closed");
|
|
17
|
+
if (!scope && providerScopeStrictMode)
|
|
18
|
+
throw new Error("Provider scope is required in strict mode");
|
|
19
|
+
return scope;
|
|
20
|
+
}
|
|
3
21
|
function wrapStream(api, stream) {
|
|
4
22
|
return (model, context, options) => {
|
|
5
23
|
if (model.api !== api)
|
|
@@ -14,17 +32,35 @@ function wrapStreamSimple(api, streamSimple) {
|
|
|
14
32
|
return streamSimple(model, context, options);
|
|
15
33
|
};
|
|
16
34
|
}
|
|
17
|
-
|
|
18
|
-
|
|
35
|
+
function createRegisteredProvider(provider, sourceId) {
|
|
36
|
+
return {
|
|
19
37
|
provider: {
|
|
20
38
|
api: provider.api,
|
|
21
39
|
stream: wrapStream(provider.api, provider.stream),
|
|
22
40
|
streamSimple: wrapStreamSimple(provider.api, provider.streamSimple),
|
|
23
41
|
},
|
|
24
42
|
sourceId,
|
|
25
|
-
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function registerApiProvider(provider, sourceId) {
|
|
46
|
+
const scope = getActiveProviderScope();
|
|
47
|
+
const registry = scope ? scope.overlay : apiProviderRegistry;
|
|
48
|
+
registry.set(provider.api, createRegisteredProvider(provider, sourceId));
|
|
49
|
+
}
|
|
50
|
+
/** Registers a builtin once, retaining its immutable identity for active scopes. */
|
|
51
|
+
export function registerBuiltinApiProvider(provider) {
|
|
52
|
+
const registered = builtinApiProviderRegistry.get(provider.api) ?? createRegisteredProvider(provider);
|
|
53
|
+
builtinApiProviderRegistry.set(provider.api, registered);
|
|
54
|
+
if (!apiProviderRegistry.has(provider.api))
|
|
55
|
+
apiProviderRegistry.set(provider.api, registered);
|
|
56
|
+
}
|
|
57
|
+
export function getBuiltinApiProvider(api) {
|
|
58
|
+
return builtinApiProviderRegistry.get(api)?.provider;
|
|
26
59
|
}
|
|
27
60
|
export function getApiProvider(api) {
|
|
61
|
+
const scope = getActiveProviderScope();
|
|
62
|
+
if (scope)
|
|
63
|
+
return scope.overlay.get(api)?.provider ?? builtinApiProviderRegistry.get(api)?.provider;
|
|
28
64
|
const faux = getRegisteredFauxProvider(api);
|
|
29
65
|
if (faux) {
|
|
30
66
|
return {
|
|
@@ -36,15 +72,25 @@ export function getApiProvider(api) {
|
|
|
36
72
|
return apiProviderRegistry.get(api)?.provider;
|
|
37
73
|
}
|
|
38
74
|
export function getApiProviders() {
|
|
75
|
+
const scope = getActiveProviderScope();
|
|
76
|
+
if (scope) {
|
|
77
|
+
const providers = new Map(builtinApiProviderRegistry);
|
|
78
|
+
for (const [api, entry] of scope.overlay)
|
|
79
|
+
providers.set(api, entry);
|
|
80
|
+
return Array.from(providers.values(), (entry) => entry.provider);
|
|
81
|
+
}
|
|
39
82
|
return Array.from(apiProviderRegistry.values(), (entry) => entry.provider);
|
|
40
83
|
}
|
|
41
84
|
export function unregisterApiProviders(sourceId) {
|
|
42
|
-
|
|
85
|
+
const scope = getActiveProviderScope();
|
|
86
|
+
const registry = scope ? scope.overlay : apiProviderRegistry;
|
|
87
|
+
for (const [api, entry] of registry.entries()) {
|
|
43
88
|
if (entry.sourceId === sourceId)
|
|
44
|
-
|
|
89
|
+
registry.delete(api);
|
|
45
90
|
}
|
|
46
91
|
}
|
|
47
92
|
export function clearApiProviders() {
|
|
48
|
-
|
|
93
|
+
const scope = getActiveProviderScope();
|
|
94
|
+
(scope ? scope.overlay : apiProviderRegistry).clear();
|
|
49
95
|
}
|
|
50
96
|
//# sourceMappingURL=api-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-registry.js","sourceRoot":"","sources":["../src/api-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"api-registry.js","sourceRoot":"","sources":["../src/api-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AA8ChE,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAiC,CAAC;AACrE,MAAM,0BAA0B,GAAG,IAAI,GAAG,EAAiC,CAAC;AAC5E,IAAI,gBAAgB,GAA0C,GAAG,EAAE,CAAC,SAAS,CAAC;AAC9E,IAAI,uBAAuB,GAAG,KAAK,CAAC;AAEpC,qFAAqF;AACrF,MAAM,UAAU,4BAA4B,CAAC,QAA+C;IAC3F,gBAAgB,GAAG,QAAQ,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAAgB;IAC1D,uBAAuB,GAAG,OAAO,CAAC;AACnC,CAAC;AAED,SAAS,sBAAsB;IAC9B,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;I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B,EAAE,CAAC;IACvC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,KAAK,EAAE,CAAC;AACvD,CAAC","sourcesContent":["import { getRegisteredFauxProvider } from \"./providers/faux.ts\";\nimport type {\n\tApi,\n\tAssistantMessageEventStream,\n\tContext,\n\tModel,\n\tSimpleStreamOptions,\n\tStreamFunction,\n\tStreamOptions,\n} from \"./types.ts\";\n\nexport type ApiStreamFunction = (\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions?: StreamOptions,\n) => AssistantMessageEventStream;\n\nexport type ApiStreamSimpleFunction = (\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n) => AssistantMessageEventStream;\n\nexport interface ApiProvider<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> {\n\tapi: TApi;\n\tstream: StreamFunction<TApi, TOptions>;\n\tstreamSimple: StreamFunction<TApi, SimpleStreamOptions>;\n}\n\nexport interface ApiProviderInternal {\n\tapi: Api;\n\tstream: ApiStreamFunction;\n\tstreamSimple: ApiStreamSimpleFunction;\n}\n\nexport type RegisteredApiProvider = {\n\tprovider: ApiProviderInternal;\n\tsourceId?: string;\n};\n\n/** Browser-neutral shape installed by the node-only provider-scope subpath. */\nexport interface ProviderScopeAccess {\n\tstate: \"active\" | \"closed\";\n\toverlay: Map<string, RegisteredApiProvider>;\n}\n\nconst apiProviderRegistry = new Map<string, RegisteredApiProvider>();\nconst builtinApiProviderRegistry = new Map<string, RegisteredApiProvider>();\nlet getProviderScope: () => ProviderScopeAccess | undefined = () => undefined;\nlet providerScopeStrictMode = false;\n\n/** Installs the optional node-only scope lookup without importing node APIs here. */\nexport function installProviderScopeAccessor(accessor: () => ProviderScopeAccess | undefined): void {\n\tgetProviderScope = accessor;\n}\n\nexport function setProviderScopeStrictMode(enabled: boolean): void {\n\tproviderScopeStrictMode = enabled;\n}\n\nfunction getActiveProviderScope(): ProviderScopeAccess | undefined {\n\tconst scope = getProviderScope();\n\tif (scope?.state === \"closed\") throw new Error(\"Provider scope is closed\");\n\tif (!scope && providerScopeStrictMode) throw new Error(\"Provider scope is required in strict mode\");\n\treturn scope;\n}\n\nfunction wrapStream<TApi extends Api, TOptions extends StreamOptions>(\n\tapi: TApi,\n\tstream: StreamFunction<TApi, TOptions>,\n): ApiStreamFunction {\n\treturn (model, context, options) => {\n\t\tif (model.api !== api) throw new Error(`Mismatched api: ${model.api} expected ${api}`);\n\t\treturn stream(model as Model<TApi>, context, options as TOptions);\n\t};\n}\n\nfunction wrapStreamSimple<TApi extends Api>(\n\tapi: TApi,\n\tstreamSimple: StreamFunction<TApi, SimpleStreamOptions>,\n): ApiStreamSimpleFunction {\n\treturn (model, context, options) => {\n\t\tif (model.api !== api) throw new Error(`Mismatched api: ${model.api} expected ${api}`);\n\t\treturn streamSimple(model as Model<TApi>, context, options);\n\t};\n}\n\nfunction createRegisteredProvider<TApi extends Api, TOptions extends StreamOptions>(\n\tprovider: ApiProvider<TApi, TOptions>,\n\tsourceId?: string,\n): RegisteredApiProvider {\n\treturn {\n\t\tprovider: {\n\t\t\tapi: provider.api,\n\t\t\tstream: wrapStream(provider.api, provider.stream),\n\t\t\tstreamSimple: wrapStreamSimple(provider.api, provider.streamSimple),\n\t\t},\n\t\tsourceId,\n\t};\n}\n\nexport function registerApiProvider<TApi extends Api, TOptions extends StreamOptions>(\n\tprovider: ApiProvider<TApi, TOptions>,\n\tsourceId?: string,\n): void {\n\tconst scope = getActiveProviderScope();\n\tconst registry = scope ? scope.overlay : apiProviderRegistry;\n\tregistry.set(provider.api, createRegisteredProvider(provider, sourceId));\n}\n\n/** Registers a builtin once, retaining its immutable identity for active scopes. */\nexport function registerBuiltinApiProvider<TApi extends Api, TOptions extends StreamOptions>(\n\tprovider: ApiProvider<TApi, TOptions>,\n): void {\n\tconst registered = builtinApiProviderRegistry.get(provider.api) ?? createRegisteredProvider(provider);\n\tbuiltinApiProviderRegistry.set(provider.api, registered);\n\tif (!apiProviderRegistry.has(provider.api)) apiProviderRegistry.set(provider.api, registered);\n}\n\nexport function getBuiltinApiProvider(api: Api): ApiProviderInternal | undefined {\n\treturn builtinApiProviderRegistry.get(api)?.provider;\n}\n\nexport function getApiProvider(api: Api): ApiProviderInternal | undefined {\n\tconst scope = getActiveProviderScope();\n\tif (scope) return scope.overlay.get(api)?.provider ?? builtinApiProviderRegistry.get(api)?.provider;\n\n\tconst faux = getRegisteredFauxProvider(api);\n\tif (faux) {\n\t\treturn {\n\t\t\tapi: faux.api,\n\t\t\tstream: wrapStream(faux.api, faux.stream),\n\t\t\tstreamSimple: wrapStreamSimple(faux.api, faux.streamSimple),\n\t\t};\n\t}\n\treturn apiProviderRegistry.get(api)?.provider;\n}\n\nexport function getApiProviders(): ApiProviderInternal[] {\n\tconst scope = getActiveProviderScope();\n\tif (scope) {\n\t\tconst providers = new Map(builtinApiProviderRegistry);\n\t\tfor (const [api, entry] of scope.overlay) providers.set(api, entry);\n\t\treturn Array.from(providers.values(), (entry) => entry.provider);\n\t}\n\treturn Array.from(apiProviderRegistry.values(), (entry) => entry.provider);\n}\n\nexport function unregisterApiProviders(sourceId: string): void {\n\tconst scope = getActiveProviderScope();\n\tconst registry = scope ? scope.overlay : apiProviderRegistry;\n\tfor (const [api, entry] of registry.entries()) {\n\t\tif (entry.sourceId === sourceId) registry.delete(api);\n\t}\n}\n\nexport function clearApiProviders(): void {\n\tconst scope = getActiveProviderScope();\n\t(scope ? scope.overlay : apiProviderRegistry).clear();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/auth/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/auth/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAkBlF;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAA;CAAE,GAAG,SAAS,CAajH"}
|
|
@@ -12,8 +12,9 @@ export function envApiKeyAuth(name, envVars) {
|
|
|
12
12
|
return { type: "api_key", key };
|
|
13
13
|
},
|
|
14
14
|
resolve: async ({ ctx, credential }) => {
|
|
15
|
-
if (credential?.key)
|
|
16
|
-
return { auth: { apiKey: credential.key }, source: "stored credential" };
|
|
15
|
+
if (credential?.key) {
|
|
16
|
+
return { auth: { apiKey: credential.key }, env: credential.env, source: "stored credential" };
|
|
17
|
+
}
|
|
17
18
|
for (const envVar of envVars) {
|
|
18
19
|
const value = await ctx.env(envVar);
|
|
19
20
|
if (value)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/auth/helpers.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,OAA0B;IACrE,OAAO;QACN,IAAI;QACJ,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE;YAC5B,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,IAAI,EAAE,EAAE,CAAC,CAAC;YACnF,OAAO,EAAE,IAAI,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IAC5C,MAAM,MAAM,GAAG,GAAG,EAAE;QACnB,OAAO,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC;IAChB,CAAC,CAAC;IACF,OAAO;QACN,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC;QACjE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;QACnE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;KACjE,CAAC;AACH,CAAC","sourcesContent":["import type { ApiKeyAuth, OAuthAuth } from \"./types.ts\";\n\n/**\n * Standard api-key auth: a stored credential key wins, otherwise the first\n * set env var resolves. Includes a `login` that prompts for the key.\n * Providers with non-standard resolution (provider env, ambient files, IAM)\n * write their own `ApiKeyAuth`.\n */\nexport function envApiKeyAuth(name: string, envVars: readonly string[]): ApiKeyAuth {\n\treturn {\n\t\tname,\n\t\tlogin: async (interaction) => {\n\t\t\tconst key = await interaction.prompt({ type: \"secret\", message: `Enter ${name}` });\n\t\t\treturn { type: \"api_key\", key };\n\t\t},\n\t\tresolve: async ({ ctx, credential }) => {\n\t\t\tif (credential?.key) {\n\t\t\t\treturn { auth: { apiKey: credential.key }, env: credential.env, source: \"stored credential\" };\n\t\t\t}\n\t\t\tfor (const envVar of envVars) {\n\t\t\t\tconst value = await ctx.env(envVar);\n\t\t\t\tif (value) return { auth: { apiKey: value }, source: envVar };\n\t\t\t}\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n\n/**\n * Wraps a dynamically imported `OAuthAuth` so provider definitions can\n * advertise OAuth without importing the implementation. The flow loads on\n * first `login`/`refresh`/`toAuth` call; callers keep Node-only flow code out\n * of bundles by loading through a bundler-opaque dynamic import (variable\n * specifier, see the bedrock lazy wrapper).\n */\nexport function lazyOAuth(input: { name: string; loginLabel?: string; load: () => Promise<OAuthAuth> }): OAuthAuth {\n\tlet promise: Promise<OAuthAuth> | undefined;\n\tconst loaded = () => {\n\t\tpromise ??= input.load();\n\t\treturn promise;\n\t};\n\treturn {\n\t\tname: input.name,\n\t\tloginLabel: input.loginLabel,\n\t\tlogin: async (interaction) => (await loaded()).login(interaction),\n\t\trefresh: async (credential) => (await loaded()).refresh(credential),\n\t\ttoAuth: async (credential) => (await loaded()).toAuth(credential),\n\t};\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kimi Code (subscription) OAuth flow
|
|
3
|
+
*
|
|
4
|
+
* RFC 8628 device authorization grant against https://auth.kimi.com with JSON
|
|
5
|
+
* responses. The access token authenticates requests to
|
|
6
|
+
* https://api.kimi.com/coding as an `Authorization: Bearer` header.
|
|
7
|
+
*/
|
|
8
|
+
import type { OAuthAuth } from "../types.ts";
|
|
9
|
+
export declare const kimiCodingOAuth: OAuthAuth;
|
|
10
|
+
//# sourceMappingURL=kimi-coding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kimi-coding.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/kimi-coding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAmB,SAAS,EAAmB,MAAM,aAAa,CAAC;AAsR/E,eAAO,MAAM,eAAe,EAAE,SAc7B,CAAC"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kimi Code (subscription) OAuth flow
|
|
3
|
+
*
|
|
4
|
+
* RFC 8628 device authorization grant against https://auth.kimi.com with JSON
|
|
5
|
+
* responses. The access token authenticates requests to
|
|
6
|
+
* https://api.kimi.com/coding as an `Authorization: Bearer` header.
|
|
7
|
+
*/
|
|
8
|
+
import { getProviderEnvValue } from "../../utils/provider-env.js";
|
|
9
|
+
import { pollOAuthDeviceCodeFlow } from "./device-code.js";
|
|
10
|
+
const CLIENT_ID = "17e5f671-d194-4dfb-9706-5516cb48c098";
|
|
11
|
+
const DEFAULT_OAUTH_HOST = "https://auth.kimi.com";
|
|
12
|
+
const DEVICE_CODE_TIMEOUT_SECONDS = 15 * 60;
|
|
13
|
+
const DEFAULT_POLL_INTERVAL_SECONDS = 5;
|
|
14
|
+
const REQUEST_TIMEOUT_MS = 30 * 1000;
|
|
15
|
+
const REFRESH_MAX_RETRIES = 3;
|
|
16
|
+
function getOauthHost() {
|
|
17
|
+
const override = getProviderEnvValue("KIMI_CODE_OAUTH_HOST") || getProviderEnvValue("KIMI_OAUTH_HOST");
|
|
18
|
+
return (override || DEFAULT_OAUTH_HOST).replace(/\/+$/, "");
|
|
19
|
+
}
|
|
20
|
+
function requestSignal(signal) {
|
|
21
|
+
return AbortSignal.any([AbortSignal.timeout(REQUEST_TIMEOUT_MS), ...(signal ? [signal] : [])]);
|
|
22
|
+
}
|
|
23
|
+
function formUrlEncode(fields) {
|
|
24
|
+
return new URLSearchParams(fields).toString();
|
|
25
|
+
}
|
|
26
|
+
async function readJson(response) {
|
|
27
|
+
try {
|
|
28
|
+
const json = await response.json();
|
|
29
|
+
return json && typeof json === "object" ? json : null;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** The verification URI is opened in the user's browser; only http(s) URLs are trusted. */
|
|
36
|
+
function trustedHttpUrl(value) {
|
|
37
|
+
if (typeof value !== "string" || !value)
|
|
38
|
+
return null;
|
|
39
|
+
try {
|
|
40
|
+
const url = new URL(value);
|
|
41
|
+
if (url.protocol !== "https:" && url.protocol !== "http:")
|
|
42
|
+
return null;
|
|
43
|
+
return url.href;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function startDeviceAuthorization(oauthHost, signal) {
|
|
50
|
+
const response = await fetch(`${oauthHost}/api/oauth/device_authorization`, {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: {
|
|
53
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
54
|
+
Accept: "application/json",
|
|
55
|
+
},
|
|
56
|
+
body: formUrlEncode({ client_id: CLIENT_ID }),
|
|
57
|
+
signal: requestSignal(signal),
|
|
58
|
+
});
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
const text = await response.text().catch(() => "");
|
|
61
|
+
throw new Error(`Kimi Code device authorization failed with status ${response.status}${text ? `: ${text}` : ""}`);
|
|
62
|
+
}
|
|
63
|
+
const json = await readJson(response);
|
|
64
|
+
const deviceCode = json?.device_code;
|
|
65
|
+
const userCode = json?.user_code;
|
|
66
|
+
const verificationUri = json?.verification_uri;
|
|
67
|
+
const verificationUriComplete = json?.verification_uri_complete;
|
|
68
|
+
if (typeof deviceCode !== "string" ||
|
|
69
|
+
typeof userCode !== "string" ||
|
|
70
|
+
typeof verificationUri !== "string" ||
|
|
71
|
+
typeof verificationUriComplete !== "string" ||
|
|
72
|
+
!trustedHttpUrl(verificationUriComplete) ||
|
|
73
|
+
!trustedHttpUrl(verificationUri)) {
|
|
74
|
+
throw new Error(`Invalid Kimi Code device authorization response: ${JSON.stringify(json)}`);
|
|
75
|
+
}
|
|
76
|
+
const interval = json?.interval;
|
|
77
|
+
const expiresIn = json?.expires_in;
|
|
78
|
+
return {
|
|
79
|
+
deviceCode,
|
|
80
|
+
userCode,
|
|
81
|
+
verificationUri,
|
|
82
|
+
verificationUriComplete,
|
|
83
|
+
intervalSeconds: typeof interval === "number" && Number.isFinite(interval) && interval > 0
|
|
84
|
+
? interval
|
|
85
|
+
: DEFAULT_POLL_INTERVAL_SECONDS,
|
|
86
|
+
expiresInSeconds: typeof expiresIn === "number" && Number.isFinite(expiresIn) && expiresIn > 0
|
|
87
|
+
? expiresIn
|
|
88
|
+
: DEVICE_CODE_TIMEOUT_SECONDS,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function parseTokenResponse(json, operation) {
|
|
92
|
+
const accessToken = json?.access_token;
|
|
93
|
+
const refreshToken = json?.refresh_token;
|
|
94
|
+
const expiresIn = json?.expires_in;
|
|
95
|
+
if (typeof accessToken !== "string" ||
|
|
96
|
+
!accessToken ||
|
|
97
|
+
typeof refreshToken !== "string" ||
|
|
98
|
+
!refreshToken ||
|
|
99
|
+
typeof expiresIn !== "number" ||
|
|
100
|
+
!Number.isFinite(expiresIn) ||
|
|
101
|
+
expiresIn <= 0) {
|
|
102
|
+
throw new Error(`Kimi Code token ${operation} response missing fields: ${JSON.stringify(json)}`);
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
access: accessToken,
|
|
106
|
+
refresh: refreshToken,
|
|
107
|
+
expires: Date.now() + expiresIn * 1000,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
async function pollForToken(oauthHost, device, signal) {
|
|
111
|
+
return pollOAuthDeviceCodeFlow({
|
|
112
|
+
intervalSeconds: device.intervalSeconds,
|
|
113
|
+
expiresInSeconds: device.expiresInSeconds,
|
|
114
|
+
waitBeforeFirstPoll: true,
|
|
115
|
+
signal,
|
|
116
|
+
poll: async () => {
|
|
117
|
+
const response = await fetch(`${oauthHost}/api/oauth/token`, {
|
|
118
|
+
method: "POST",
|
|
119
|
+
headers: {
|
|
120
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
121
|
+
Accept: "application/json",
|
|
122
|
+
},
|
|
123
|
+
body: formUrlEncode({
|
|
124
|
+
client_id: CLIENT_ID,
|
|
125
|
+
device_code: device.deviceCode,
|
|
126
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
127
|
+
}),
|
|
128
|
+
signal: requestSignal(signal),
|
|
129
|
+
});
|
|
130
|
+
if (response.status >= 500) {
|
|
131
|
+
const text = await response.text().catch(() => "");
|
|
132
|
+
return {
|
|
133
|
+
status: "failed",
|
|
134
|
+
message: `Kimi Code device token request failed with status ${response.status}${text ? `: ${text}` : ""}`,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const json = await readJson(response);
|
|
138
|
+
if (response.ok && typeof json?.access_token === "string") {
|
|
139
|
+
try {
|
|
140
|
+
return { status: "complete", value: parseTokenResponse(json, "poll") };
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
return { status: "failed", message: error instanceof Error ? error.message : String(error) };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const error = json?.error;
|
|
147
|
+
const description = typeof json?.error_description === "string" ? `: ${json.error_description}` : "";
|
|
148
|
+
if (error === "authorization_pending") {
|
|
149
|
+
return { status: "pending" };
|
|
150
|
+
}
|
|
151
|
+
if (error === "slow_down") {
|
|
152
|
+
const interval = json?.interval;
|
|
153
|
+
return {
|
|
154
|
+
status: "slow_down",
|
|
155
|
+
intervalSeconds: typeof interval === "number" && interval > 0 ? interval : undefined,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (error === "expired_token") {
|
|
159
|
+
return { status: "failed", message: "Kimi Code device authorization expired. Please restart login." };
|
|
160
|
+
}
|
|
161
|
+
if (error === "access_denied") {
|
|
162
|
+
return { status: "failed", message: "Kimi Code login was denied." };
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
status: "failed",
|
|
166
|
+
message: `Kimi Code device token request failed (status ${response.status})${typeof error === "string" ? `: ${error}${description}` : ""}`,
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function sleep(ms) {
|
|
172
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
173
|
+
}
|
|
174
|
+
function isRetryableRefreshFailure(response) {
|
|
175
|
+
return response.status === 429 || response.status >= 500;
|
|
176
|
+
}
|
|
177
|
+
async function refreshToken(oauthHost, refreshTokenValue, signal) {
|
|
178
|
+
let lastError;
|
|
179
|
+
for (let attempt = 0; attempt <= REFRESH_MAX_RETRIES; attempt++) {
|
|
180
|
+
if (attempt > 0) {
|
|
181
|
+
await sleep(1000 * 2 ** (attempt - 1));
|
|
182
|
+
}
|
|
183
|
+
if (signal?.aborted) {
|
|
184
|
+
throw new Error("Kimi Code token refresh aborted");
|
|
185
|
+
}
|
|
186
|
+
let response;
|
|
187
|
+
try {
|
|
188
|
+
response = await fetch(`${oauthHost}/api/oauth/token`, {
|
|
189
|
+
method: "POST",
|
|
190
|
+
headers: {
|
|
191
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
192
|
+
Accept: "application/json",
|
|
193
|
+
},
|
|
194
|
+
body: formUrlEncode({
|
|
195
|
+
client_id: CLIENT_ID,
|
|
196
|
+
grant_type: "refresh_token",
|
|
197
|
+
refresh_token: refreshTokenValue,
|
|
198
|
+
}),
|
|
199
|
+
signal: requestSignal(signal),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const json = await readJson(response);
|
|
207
|
+
if (response.ok) {
|
|
208
|
+
return parseTokenResponse(json, "refresh");
|
|
209
|
+
}
|
|
210
|
+
// Unauthorized: the stored credential is dead; Models clears it and prompts re-login.
|
|
211
|
+
if (response.status === 401 || response.status === 403 || json?.error === "invalid_grant") {
|
|
212
|
+
const description = typeof json?.error_description === "string" ? `: ${json.error_description}` : "";
|
|
213
|
+
throw new Error(`Kimi Code token refresh unauthorized (status ${response.status})${description}`);
|
|
214
|
+
}
|
|
215
|
+
if (isRetryableRefreshFailure(response) && attempt < REFRESH_MAX_RETRIES) {
|
|
216
|
+
lastError = new Error(`Kimi Code token refresh failed with status ${response.status}`);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
const text = JSON.stringify(json);
|
|
220
|
+
throw new Error(`Kimi Code token refresh failed with status ${response.status}${text ? `: ${text}` : ""}`);
|
|
221
|
+
}
|
|
222
|
+
throw lastError ?? new Error("Kimi Code token refresh failed");
|
|
223
|
+
}
|
|
224
|
+
async function loginKimiCoding(interaction) {
|
|
225
|
+
const oauthHost = getOauthHost();
|
|
226
|
+
const device = await startDeviceAuthorization(oauthHost, interaction.signal);
|
|
227
|
+
interaction.notify({
|
|
228
|
+
type: "device_code",
|
|
229
|
+
userCode: device.userCode,
|
|
230
|
+
verificationUri: device.verificationUriComplete,
|
|
231
|
+
intervalSeconds: device.intervalSeconds,
|
|
232
|
+
expiresInSeconds: device.expiresInSeconds,
|
|
233
|
+
});
|
|
234
|
+
const token = await pollForToken(oauthHost, device, interaction.signal);
|
|
235
|
+
return { type: "oauth", access: token.access, refresh: token.refresh, expires: token.expires };
|
|
236
|
+
}
|
|
237
|
+
export const kimiCodingOAuth = {
|
|
238
|
+
name: "Kimi Code (subscription)",
|
|
239
|
+
loginLabel: "Sign in with Kimi Code",
|
|
240
|
+
login: loginKimiCoding,
|
|
241
|
+
refresh: async (credential, signal) => {
|
|
242
|
+
const token = await refreshToken(getOauthHost(), credential.refresh, signal);
|
|
243
|
+
return { type: "oauth", access: token.access, refresh: token.refresh, expires: token.expires };
|
|
244
|
+
},
|
|
245
|
+
async toAuth(credential) {
|
|
246
|
+
return { headers: { Authorization: `Bearer ${credential.access}` } };
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
//# sourceMappingURL=kimi-coding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kimi-coding.js","sourceRoot":"","sources":["../../../src/auth/oauth/kimi-coding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,MAAM,SAAS,GAAG,sCAAsC,CAAC;AACzD,MAA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C,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAChG,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,UAAU;QACtB,OAAO,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC;IACtE,CAAC;CACD,CAAC","sourcesContent":["/**\n * Kimi Code (subscription) OAuth flow\n *\n * RFC 8628 device authorization grant against https://auth.kimi.com with JSON\n * responses. The access token authenticates requests to\n * https://api.kimi.com/coding as an `Authorization: Bearer` header.\n */\n\nimport { getProviderEnvValue } from \"../../utils/provider-env.ts\";\nimport type { AuthInteraction, OAuthAuth, OAuthCredential } from \"../types.ts\";\nimport { pollOAuthDeviceCodeFlow } from \"./device-code.ts\";\n\nconst CLIENT_ID = \"17e5f671-d194-4dfb-9706-5516cb48c098\";\nconst DEFAULT_OAUTH_HOST = \"https://auth.kimi.com\";\nconst DEVICE_CODE_TIMEOUT_SECONDS = 15 * 60;\nconst DEFAULT_POLL_INTERVAL_SECONDS = 5;\nconst REQUEST_TIMEOUT_MS = 30 * 1000;\nconst REFRESH_MAX_RETRIES = 3;\n\ntype DeviceAuthorization = {\n\tdeviceCode: string;\n\tuserCode: string;\n\tverificationUri: string;\n\tverificationUriComplete: string;\n\tintervalSeconds: number;\n\texpiresInSeconds: number;\n};\n\ntype TokenResponse = {\n\taccess: string;\n\trefresh: string;\n\texpires: number;\n};\n\nfunction getOauthHost(): string {\n\tconst override = getProviderEnvValue(\"KIMI_CODE_OAUTH_HOST\") || getProviderEnvValue(\"KIMI_OAUTH_HOST\");\n\treturn (override || DEFAULT_OAUTH_HOST).replace(/\\/+$/, \"\");\n}\n\nfunction requestSignal(signal?: AbortSignal): AbortSignal {\n\treturn AbortSignal.any([AbortSignal.timeout(REQUEST_TIMEOUT_MS), ...(signal ? [signal] : [])]);\n}\n\nfunction formUrlEncode(fields: Record<string, string>): string {\n\treturn new URLSearchParams(fields).toString();\n}\n\nasync function readJson(response: Response): Promise<Record<string, unknown> | null> {\n\ttry {\n\t\tconst json = await response.json();\n\t\treturn json && typeof json === \"object\" ? (json as Record<string, unknown>) : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/** The verification URI is opened in the user's browser; only http(s) URLs are trusted. */\nfunction trustedHttpUrl(value: unknown): string | null {\n\tif (typeof value !== \"string\" || !value) return null;\n\ttry {\n\t\tconst url = new URL(value);\n\t\tif (url.protocol !== \"https:\" && url.protocol !== \"http:\") return null;\n\t\treturn url.href;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nasync function startDeviceAuthorization(oauthHost: string, signal?: AbortSignal): Promise<DeviceAuthorization> {\n\tconst response = await fetch(`${oauthHost}/api/oauth/device_authorization`, {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/x-www-form-urlencoded\",\n\t\t\tAccept: \"application/json\",\n\t\t},\n\t\tbody: formUrlEncode({ client_id: CLIENT_ID }),\n\t\tsignal: requestSignal(signal),\n\t});\n\n\tif (!response.ok) {\n\t\tconst text = await response.text().catch(() => \"\");\n\t\tthrow new Error(`Kimi Code device authorization failed with status ${response.status}${text ? `: ${text}` : \"\"}`);\n\t}\n\n\tconst json = await readJson(response);\n\tconst deviceCode = json?.device_code;\n\tconst userCode = json?.user_code;\n\tconst verificationUri = json?.verification_uri;\n\tconst verificationUriComplete = json?.verification_uri_complete;\n\tif (\n\t\ttypeof deviceCode !== \"string\" ||\n\t\ttypeof userCode !== \"string\" ||\n\t\ttypeof verificationUri !== \"string\" ||\n\t\ttypeof verificationUriComplete !== \"string\" ||\n\t\t!trustedHttpUrl(verificationUriComplete) ||\n\t\t!trustedHttpUrl(verificationUri)\n\t) {\n\t\tthrow new Error(`Invalid Kimi Code device authorization response: ${JSON.stringify(json)}`);\n\t}\n\n\tconst interval = json?.interval;\n\tconst expiresIn = json?.expires_in;\n\treturn {\n\t\tdeviceCode,\n\t\tuserCode,\n\t\tverificationUri,\n\t\tverificationUriComplete,\n\t\tintervalSeconds:\n\t\t\ttypeof interval === \"number\" && Number.isFinite(interval) && interval > 0\n\t\t\t\t? interval\n\t\t\t\t: DEFAULT_POLL_INTERVAL_SECONDS,\n\t\texpiresInSeconds:\n\t\t\ttypeof expiresIn === \"number\" && Number.isFinite(expiresIn) && expiresIn > 0\n\t\t\t\t? expiresIn\n\t\t\t\t: DEVICE_CODE_TIMEOUT_SECONDS,\n\t};\n}\n\nfunction parseTokenResponse(json: Record<string, unknown> | null, operation: string): TokenResponse {\n\tconst accessToken = json?.access_token;\n\tconst refreshToken = json?.refresh_token;\n\tconst expiresIn = json?.expires_in;\n\tif (\n\t\ttypeof accessToken !== \"string\" ||\n\t\t!accessToken ||\n\t\ttypeof refreshToken !== \"string\" ||\n\t\t!refreshToken ||\n\t\ttypeof expiresIn !== \"number\" ||\n\t\t!Number.isFinite(expiresIn) ||\n\t\texpiresIn <= 0\n\t) {\n\t\tthrow new Error(`Kimi Code token ${operation} response missing fields: ${JSON.stringify(json)}`);\n\t}\n\treturn {\n\t\taccess: accessToken,\n\t\trefresh: refreshToken,\n\t\texpires: Date.now() + expiresIn * 1000,\n\t};\n}\n\nasync function pollForToken(\n\toauthHost: string,\n\tdevice: DeviceAuthorization,\n\tsignal?: AbortSignal,\n): Promise<TokenResponse> {\n\treturn pollOAuthDeviceCodeFlow<TokenResponse>({\n\t\tintervalSeconds: device.intervalSeconds,\n\t\texpiresInSeconds: device.expiresInSeconds,\n\t\twaitBeforeFirstPoll: true,\n\t\tsignal,\n\t\tpoll: async () => {\n\t\t\tconst response = await fetch(`${oauthHost}/api/oauth/token`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": \"application/x-www-form-urlencoded\",\n\t\t\t\t\tAccept: \"application/json\",\n\t\t\t\t},\n\t\t\t\tbody: formUrlEncode({\n\t\t\t\t\tclient_id: CLIENT_ID,\n\t\t\t\t\tdevice_code: device.deviceCode,\n\t\t\t\t\tgrant_type: \"urn:ietf:params:oauth:grant-type:device_code\",\n\t\t\t\t}),\n\t\t\t\tsignal: requestSignal(signal),\n\t\t\t});\n\n\t\t\tif (response.status >= 500) {\n\t\t\t\tconst text = await response.text().catch(() => \"\");\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\tmessage: `Kimi Code device token request failed with status ${response.status}${text ? `: ${text}` : \"\"}`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst json = await readJson(response);\n\t\t\tif (response.ok && typeof json?.access_token === \"string\") {\n\t\t\t\ttry {\n\t\t\t\t\treturn { status: \"complete\", value: parseTokenResponse(json, \"poll\") };\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn { status: \"failed\", message: error instanceof Error ? error.message : String(error) };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst error = json?.error;\n\t\t\tconst description = typeof json?.error_description === \"string\" ? `: ${json.error_description}` : \"\";\n\t\t\tif (error === \"authorization_pending\") {\n\t\t\t\treturn { status: \"pending\" };\n\t\t\t}\n\t\t\tif (error === \"slow_down\") {\n\t\t\t\tconst interval = json?.interval;\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"slow_down\",\n\t\t\t\t\tintervalSeconds: typeof interval === \"number\" && interval > 0 ? interval : undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (error === \"expired_token\") {\n\t\t\t\treturn { status: \"failed\", message: \"Kimi Code device authorization expired. Please restart login.\" };\n\t\t\t}\n\t\t\tif (error === \"access_denied\") {\n\t\t\t\treturn { status: \"failed\", message: \"Kimi Code login was denied.\" };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstatus: \"failed\",\n\t\t\t\tmessage: `Kimi Code device token request failed (status ${response.status})${typeof error === \"string\" ? `: ${error}${description}` : \"\"}`,\n\t\t\t};\n\t\t},\n\t});\n}\n\nfunction sleep(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction isRetryableRefreshFailure(response: Response): boolean {\n\treturn response.status === 429 || response.status >= 500;\n}\n\nasync function refreshToken(\n\toauthHost: string,\n\trefreshTokenValue: string,\n\tsignal?: AbortSignal,\n): Promise<TokenResponse> {\n\tlet lastError: Error | undefined;\n\tfor (let attempt = 0; attempt <= REFRESH_MAX_RETRIES; attempt++) {\n\t\tif (attempt > 0) {\n\t\t\tawait sleep(1000 * 2 ** (attempt - 1));\n\t\t}\n\t\tif (signal?.aborted) {\n\t\t\tthrow new Error(\"Kimi Code token refresh aborted\");\n\t\t}\n\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await fetch(`${oauthHost}/api/oauth/token`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": \"application/x-www-form-urlencoded\",\n\t\t\t\t\tAccept: \"application/json\",\n\t\t\t\t},\n\t\t\t\tbody: formUrlEncode({\n\t\t\t\t\tclient_id: CLIENT_ID,\n\t\t\t\t\tgrant_type: \"refresh_token\",\n\t\t\t\t\trefresh_token: refreshTokenValue,\n\t\t\t\t}),\n\t\t\t\tsignal: requestSignal(signal),\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tlastError = error instanceof Error ? error : new Error(String(error));\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst json = await readJson(response);\n\t\tif (response.ok) {\n\t\t\treturn parseTokenResponse(json, \"refresh\");\n\t\t}\n\n\t\t// Unauthorized: the stored credential is dead; Models clears it and prompts re-login.\n\t\tif (response.status === 401 || response.status === 403 || json?.error === \"invalid_grant\") {\n\t\t\tconst description = typeof json?.error_description === \"string\" ? `: ${json.error_description}` : \"\";\n\t\t\tthrow new Error(`Kimi Code token refresh unauthorized (status ${response.status})${description}`);\n\t\t}\n\n\t\tif (isRetryableRefreshFailure(response) && attempt < REFRESH_MAX_RETRIES) {\n\t\t\tlastError = new Error(`Kimi Code token refresh failed with status ${response.status}`);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst text = JSON.stringify(json);\n\t\tthrow new Error(`Kimi Code token refresh failed with status ${response.status}${text ? `: ${text}` : \"\"}`);\n\t}\n\n\tthrow lastError ?? new Error(\"Kimi Code token refresh failed\");\n}\n\nasync function loginKimiCoding(interaction: AuthInteraction): Promise<OAuthCredential> {\n\tconst oauthHost = getOauthHost();\n\tconst device = await startDeviceAuthorization(oauthHost, interaction.signal);\n\tinteraction.notify({\n\t\ttype: \"device_code\",\n\t\tuserCode: device.userCode,\n\t\tverificationUri: device.verificationUriComplete,\n\t\tintervalSeconds: device.intervalSeconds,\n\t\texpiresInSeconds: device.expiresInSeconds,\n\t});\n\tconst token = await pollForToken(oauthHost, device, interaction.signal);\n\treturn { type: \"oauth\", access: token.access, refresh: token.refresh, expires: token.expires };\n}\n\nexport const kimiCodingOAuth: OAuthAuth = {\n\tname: \"Kimi Code (subscription)\",\n\tloginLabel: \"Sign in with Kimi Code\",\n\n\tlogin: loginKimiCoding,\n\n\trefresh: async (credential, signal) => {\n\t\tconst token = await refreshToken(getOauthHost(), credential.refresh, signal);\n\t\treturn { type: \"oauth\", access: token.access, refresh: token.refresh, expires: token.expires };\n\t},\n\n\tasync toAuth(credential) {\n\t\treturn { headers: { Authorization: `Bearer ${credential.access}` } };\n\t},\n};\n"]}
|
|
@@ -3,6 +3,8 @@ type OAuthFlowLoaders = {
|
|
|
3
3
|
anthropic: () => OAuthAuth | Promise<OAuthAuth>;
|
|
4
4
|
openaiCodex: () => OAuthAuth | Promise<OAuthAuth>;
|
|
5
5
|
githubCopilot: () => OAuthAuth | Promise<OAuthAuth>;
|
|
6
|
+
openrouter: () => OAuthAuth | Promise<OAuthAuth>;
|
|
7
|
+
kimiCoding: () => OAuthAuth | Promise<OAuthAuth>;
|
|
6
8
|
xai: () => OAuthAuth | Promise<OAuthAuth>;
|
|
7
9
|
radius: (options: {
|
|
8
10
|
name: string;
|
|
@@ -14,6 +16,8 @@ export declare function registerBundledOAuthFlowLoaders(loaders: OAuthFlowLoader
|
|
|
14
16
|
export declare const loadAnthropicOAuth: () => Promise<OAuthAuth>;
|
|
15
17
|
export declare const loadOpenAICodexOAuth: () => Promise<OAuthAuth>;
|
|
16
18
|
export declare const loadGitHubCopilotOAuth: () => Promise<OAuthAuth>;
|
|
19
|
+
export declare const loadOpenRouterOAuth: () => Promise<OAuthAuth>;
|
|
20
|
+
export declare const loadKimiCodingOAuth: () => Promise<OAuthAuth>;
|
|
17
21
|
export declare const loadXaiOAuth: () => Promise<OAuthAuth>;
|
|
18
22
|
export declare const loadRadiusOAuth: (options: {
|
|
19
23
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/load.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAa7C,KAAK,gBAAgB,GAAG;IACvB,SAAS,EAAE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAChD,WAAW,EAAE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAClD,aAAa,EAAE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACpD,GAAG,EAAE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,EAAE,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CACvF,CAAC;AAIF,4EAA4E;AAC5E,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAE/E;AAED,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,SAAS,CAG5D,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAa,OAAO,CAAC,SAAS,CAG9D,CAAC;AAEF,eAAO,MAAM,sBAAsB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AAC;AAEF,eAAO,MAAM,mBAAmB,QAAa,OAAO,CAAC,SAAS,CAG7D,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAa,OAAO,CAAC,SAAS,CAG7D,CAAC;AAEF,eAAO,MAAM,YAAY,QAAa,OAAO,CAAC,SAAS,CAGtD,CAAC;AAEF,eAAO,MAAM,eAAe,YAAmB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,KAAG,OAAO,CAAC,SAAS,CAOnG,CAAC"}
|
|
@@ -36,6 +36,16 @@ export const loadGitHubCopilotOAuth = async () => {
|
|
|
36
36
|
return bundledLoaders.githubCopilot();
|
|
37
37
|
return (await importOAuthModule("./github-copilot.ts")).githubCopilotOAuth;
|
|
38
38
|
};
|
|
39
|
+
export const loadOpenRouterOAuth = async () => {
|
|
40
|
+
if (bundledLoaders)
|
|
41
|
+
return bundledLoaders.openrouter();
|
|
42
|
+
return (await importOAuthModule("./openrouter.ts")).openRouterOAuth;
|
|
43
|
+
};
|
|
44
|
+
export const loadKimiCodingOAuth = async () => {
|
|
45
|
+
if (bundledLoaders)
|
|
46
|
+
return bundledLoaders.kimiCoding();
|
|
47
|
+
return (await importOAuthModule("./kimi-coding.ts")).kimiCodingOAuth;
|
|
48
|
+
};
|
|
39
49
|
export const loadXaiOAuth = async () => {
|
|
40
50
|
if (bundledLoaders)
|
|
41
51
|
return bundledLoaders.xai();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/auth/oauth/load.ts"],"names":[],"mappings":";;;;;;;;AAEA;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAoB,EAAE;IACjE,MAAM,gBAAgB,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,S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;AACnH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,IAAwB,EAAE;IACjE,IAAI,cAAc;QAAE,OAAO,cAAc,CAAC,UAAU,EAAE,CAAC;IACvD,OAAQ,CAAC,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,CAAoC,CAAC,eAAe,CAAC;AACzG,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,IAAwB,EAAE;IACjE,IAAI,cAAc;QAAE,OAAO,cAAc,CAAC,UAAU,EAAE,CAAC;IACvD,OAAQ,CAAC,MAAM,iBAAiB,CAAC,kBAAkB,CAAC,CAAoC,CAAC,eAAe,CAAC;AAC1G,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,IAAwB,EAAE;IAC1D,IAAI,cAAc;QAAE,OAAO,cAAc,CAAC,GAAG,EAAE,CAAC;IAChD,OAAQ,CAAC,MAAM,iBAAiB,CAAC,UAAU,CAAC,CAA6B,CAAC,QAAQ,CAAC;AACpF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,OAA0C,EAAsB,EAAE;IACvG,IAAI,cAAc;QAAE,OAAO,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1D,OACC,CAAC,MAAM,iBAAiB,CAAC,aAAa,CAAC,CAGvC,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import type { OAuthAuth } from \"../types.ts\";\n\n/**\n * Loads an OAuth flow module through a variable specifier so bundlers cannot\n * follow the import into Node-only flow code (`node:http` callback servers,\n * `node:crypto` PKCE). The `.ts`/`.js` rewrite keeps the trick working from\n * both source and built output.\n */\nconst importOAuthModule = (specifier: string): Promise<unknown> => {\n\tconst runtimeSpecifier = import.meta.url.endsWith(\".js\") ? specifier.replace(/\\.ts$/, \".js\") : specifier;\n\treturn import(runtimeSpecifier);\n};\n\ntype OAuthFlowLoaders = {\n\tanthropic: () => OAuthAuth | Promise<OAuthAuth>;\n\topenaiCodex: () => OAuthAuth | Promise<OAuthAuth>;\n\tgithubCopilot: () => OAuthAuth | Promise<OAuthAuth>;\n\topenrouter: () => OAuthAuth | Promise<OAuthAuth>;\n\tkimiCoding: () => OAuthAuth | Promise<OAuthAuth>;\n\txai: () => OAuthAuth | Promise<OAuthAuth>;\n\tradius: (options: { name: string; gateway: string }) => OAuthAuth | Promise<OAuthAuth>;\n};\n\nlet bundledLoaders: OAuthFlowLoaders | undefined;\n\n/** Registers statically bundled OAuth flows for standalone Bun binaries. */\nexport function registerBundledOAuthFlowLoaders(loaders: OAuthFlowLoaders): void {\n\tbundledLoaders = loaders;\n}\n\nexport const loadAnthropicOAuth = async (): Promise<OAuthAuth> => {\n\tif (bundledLoaders) return bundledLoaders.anthropic();\n\treturn ((await importOAuthModule(\"./anthropic.ts\")) as { anthropicOAuth: OAuthAuth }).anthropicOAuth;\n};\n\nexport const loadOpenAICodexOAuth = async (): Promise<OAuthAuth> => {\n\tif (bundledLoaders) return bundledLoaders.openaiCodex();\n\treturn ((await importOAuthModule(\"./openai-codex.ts\")) as { openaiCodexOAuth: OAuthAuth }).openaiCodexOAuth;\n};\n\nexport const loadGitHubCopilotOAuth = async (): Promise<OAuthAuth> => {\n\tif (bundledLoaders) return bundledLoaders.githubCopilot();\n\treturn ((await importOAuthModule(\"./github-copilot.ts\")) as { githubCopilotOAuth: OAuthAuth }).githubCopilotOAuth;\n};\n\nexport const loadOpenRouterOAuth = async (): Promise<OAuthAuth> => {\n\tif (bundledLoaders) return bundledLoaders.openrouter();\n\treturn ((await importOAuthModule(\"./openrouter.ts\")) as { openRouterOAuth: OAuthAuth }).openRouterOAuth;\n};\n\nexport const loadKimiCodingOAuth = async (): Promise<OAuthAuth> => {\n\tif (bundledLoaders) return bundledLoaders.kimiCoding();\n\treturn ((await importOAuthModule(\"./kimi-coding.ts\")) as { kimiCodingOAuth: OAuthAuth }).kimiCodingOAuth;\n};\n\nexport const loadXaiOAuth = async (): Promise<OAuthAuth> => {\n\tif (bundledLoaders) return bundledLoaders.xai();\n\treturn ((await importOAuthModule(\"./xai.ts\")) as { xaiOAuth: OAuthAuth }).xaiOAuth;\n};\n\nexport const loadRadiusOAuth = async (options: { name: string; gateway: string }): Promise<OAuthAuth> => {\n\tif (bundledLoaders) return bundledLoaders.radius(options);\n\treturn (\n\t\t(await importOAuthModule(\"./radius.ts\")) as {\n\t\t\tcreateRadiusOAuth: (input: { name: string; gateway: string }) => OAuthAuth;\n\t\t}\n\t).createRadiusOAuth(options);\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-codex.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/openai-codex.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"openai-codex.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/openai-codex.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,OAAO,KAAK,EAAmB,SAAS,EAAmB,MAAM,aAAa,CAAC;AAkd/E,eAAO,MAAM,gBAAgB,EAAE,SA4B9B,CAAC"}
|
|
@@ -15,6 +15,7 @@ if (typeof process !== "undefined" && (process.versions?.node || process.version
|
|
|
15
15
|
_http = m;
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
+
import { extractOpenAiCodexAccountId } from "../../utils/openai-codex-auth.js";
|
|
18
19
|
import { getProviderEnvValue } from "../../utils/provider-env.js";
|
|
19
20
|
import { pollOAuthDeviceCodeFlow } from "./device-code.js";
|
|
20
21
|
import { oauthErrorHtml, oauthSuccessHtml } from "./oauth-page.js";
|
|
@@ -32,7 +33,6 @@ const DEVICE_CODE_TIMEOUT_SECONDS = 15 * 60;
|
|
|
32
33
|
const OPENAI_CODEX_BROWSER_LOGIN_METHOD = "browser";
|
|
33
34
|
const OPENAI_CODEX_DEVICE_CODE_LOGIN_METHOD = "device_code";
|
|
34
35
|
const SCOPE = "openid profile email offline_access";
|
|
35
|
-
const JWT_CLAIM_PATH = "https://api.openai.com/auth";
|
|
36
36
|
function getCallbackHost() {
|
|
37
37
|
return getProviderEnvValue("PI_OAUTH_CALLBACK_HOST") || "127.0.0.1";
|
|
38
38
|
}
|
|
@@ -69,19 +69,6 @@ function parseAuthorizationInput(input) {
|
|
|
69
69
|
}
|
|
70
70
|
return { code: value };
|
|
71
71
|
}
|
|
72
|
-
function decodeJwt(token) {
|
|
73
|
-
try {
|
|
74
|
-
const parts = token.split(".");
|
|
75
|
-
if (parts.length !== 3)
|
|
76
|
-
return null;
|
|
77
|
-
const payload = parts[1] ?? "";
|
|
78
|
-
const decoded = atob(payload);
|
|
79
|
-
return JSON.parse(decoded);
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
72
|
async function fetchWithLoginCancellation(input, init) {
|
|
86
73
|
try {
|
|
87
74
|
return await fetch(input, init);
|
|
@@ -317,10 +304,7 @@ function startLocalOAuthServer(state) {
|
|
|
317
304
|
});
|
|
318
305
|
}
|
|
319
306
|
function getAccountId(accessToken) {
|
|
320
|
-
|
|
321
|
-
const auth = payload?.[JWT_CLAIM_PATH];
|
|
322
|
-
const accountId = auth?.chatgpt_account_id;
|
|
323
|
-
return typeof accountId === "string" && accountId.length > 0 ? accountId : null;
|
|
307
|
+
return extractOpenAiCodexAccountId(accessToken) ?? null;
|
|
324
308
|
}
|
|
325
309
|
function credentialsFromToken(token) {
|
|
326
310
|
const accountId = getAccountId(token.access);
|