@psnext/slingcli 2.5.20260623-1 → 2.5.20260705-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/@aws/lambda-invoke-store/README.md +25 -1
- package/node_modules/@aws/lambda-invoke-store/dist-cjs/invoke-store.js +12 -0
- package/node_modules/@aws/lambda-invoke-store/dist-es/invoke-store.js +12 -0
- package/node_modules/@aws/lambda-invoke-store/dist-types/invoke-store.d.ts +6 -0
- package/node_modules/@aws/lambda-invoke-store/package.json +1 -1
- package/node_modules/@aws-sdk/core/account-id-endpoint.d.ts +1 -3
- package/node_modules/@aws-sdk/core/client.d.ts +1 -3
- package/node_modules/@aws-sdk/core/httpAuthSchemes.d.ts +1 -3
- package/node_modules/@aws-sdk/core/package.json +10 -17
- package/node_modules/@aws-sdk/core/protocols.d.ts +1 -3
- package/node_modules/@aws-sdk/core/util.d.ts +1 -3
- package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/index.js +172 -1
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-cjs/index.js +3 -51
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-es/index.js +3 -3
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-types/index.d.ts +3 -3
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-http/package.json +8 -10
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +13 -13
- package/node_modules/@aws-sdk/credential-provider-login/package.json +6 -6
- package/node_modules/@aws-sdk/credential-provider-node/package.json +11 -11
- package/node_modules/@aws-sdk/credential-provider-process/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +6 -6
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/index.js +58 -3
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +7 -8
- package/node_modules/@aws-sdk/eventstream-handler-node/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-eventstream/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-websocket/package.json +7 -7
- package/node_modules/@aws-sdk/nested-clients/cognito-identity.d.ts +1 -3
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +13 -25
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +13 -17
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +12 -15
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +12 -15
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +13 -25
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/commandBuilder.js +6 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/commands/GetCredentialsForIdentityCommand.js +2 -14
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/commands/GetIdCommand.js +2 -14
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/index.js +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/runtimeConfig.browser.js +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/runtimeConfig.js +1 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/runtimeConfig.native.js +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/runtimeConfig.shared.js +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/commandBuilder.js +8 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/commands/CreateOAuth2TokenCommand.js +2 -17
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/index.js +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/runtimeConfig.browser.js +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/runtimeConfig.js +1 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/runtimeConfig.native.js +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/runtimeConfig.shared.js +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/commandBuilder.js +6 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/commands/GetRoleCredentialsCommand.js +2 -14
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/index.js +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/runtimeConfig.browser.js +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/runtimeConfig.js +1 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/runtimeConfig.native.js +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/runtimeConfig.shared.js +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/commandBuilder.js +6 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/commands/CreateTokenCommand.js +2 -14
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/index.js +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/runtimeConfig.browser.js +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/runtimeConfig.js +1 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/runtimeConfig.native.js +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/runtimeConfig.shared.js +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/commandBuilder.js +6 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/commands/AssumeRoleCommand.js +2 -14
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/commands/AssumeRoleWithWebIdentityCommand.js +2 -14
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/index.js +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/runtimeConfig.browser.js +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/runtimeConfig.js +1 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/runtimeConfig.native.js +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/runtimeConfig.shared.js +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/commandBuilder.d.ts +18 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/commands/GetCredentialsForIdentityCommand.d.ts +3 -8
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/commands/GetIdCommand.d.ts +3 -8
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/index.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.browser.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.native.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.shared.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/commandBuilder.d.ts +18 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/commands/CreateOAuth2TokenCommand.d.ts +3 -8
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/index.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.browser.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.native.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.shared.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/commandBuilder.d.ts +18 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/commands/GetRoleCredentialsCommand.d.ts +3 -8
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/index.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.browser.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.native.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.shared.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/commandBuilder.d.ts +18 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/commands/CreateTokenCommand.d.ts +3 -8
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/index.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.browser.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.native.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.shared.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/commandBuilder.d.ts +18 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/commands/AssumeRoleCommand.d.ts +3 -8
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/commands/AssumeRoleWithWebIdentityCommand.d.ts +3 -8
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/index.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.browser.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.native.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.shared.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/commandBuilder.d.ts +46 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/commands/GetCredentialsForIdentityCommand.d.ts +7 -16
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/commands/GetIdCommand.d.ts +7 -16
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/index.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.browser.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.native.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.shared.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/commandBuilder.d.ts +42 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/commands/CreateOAuth2TokenCommand.d.ts +3 -8
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/index.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.browser.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.native.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.shared.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/commandBuilder.d.ts +42 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/commands/GetRoleCredentialsCommand.d.ts +3 -8
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/index.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.browser.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.native.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.shared.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/commandBuilder.d.ts +42 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/commands/CreateTokenCommand.d.ts +3 -8
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/index.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.browser.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.native.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.shared.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/commandBuilder.d.ts +46 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/commands/AssumeRoleCommand.d.ts +7 -16
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/commands/AssumeRoleWithWebIdentityCommand.d.ts +7 -16
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/index.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.browser.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.native.d.ts +8 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.shared.d.ts +1 -0
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-cjs/index.js +3 -51
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-es/index.js +3 -3
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-types/index.d.ts +3 -3
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/package.json +4 -4
- package/node_modules/@aws-sdk/nested-clients/package.json +8 -10
- package/node_modules/@aws-sdk/nested-clients/signin.d.ts +1 -3
- package/node_modules/@aws-sdk/nested-clients/sso-oidc.d.ts +1 -3
- package/node_modules/@aws-sdk/nested-clients/sso.d.ts +1 -3
- package/node_modules/@aws-sdk/nested-clients/sts.d.ts +1 -3
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +4 -4
- package/node_modules/@aws-sdk/types/package.json +2 -2
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/index.js +236 -3
- package/node_modules/@aws-sdk/xml-builder/package.json +3 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +10 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +9 -8
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +20 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +2 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +51 -47
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +11 -17
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +25 -11
- package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare.js +0 -18
- package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +8 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +8 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +68 -43
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +38 -29
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +189 -204
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +26 -35
- package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +4 -6
- package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +11 -2
- package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +19 -4
- package/node_modules/@earendil-works/pi-ai/dist/compat.js +81 -7
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +60 -45
- package/node_modules/@earendil-works/pi-ai/dist/images-models.js +7 -3
- package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/legacy-api-aliases.js +49 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.js +7 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js +149 -12
- package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js +18 -34
- package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js +20 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js +39 -9
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.js +85 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js +13 -13
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +1 -20
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js +20 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +57 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js +72 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js +4 -4
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js +4 -4
- package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js +4 -4
- package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js +23 -4
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +16 -16
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +90 -17
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +390 -102
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js +39 -20
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +389 -80
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js +7 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js +12 -12
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js +12 -12
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js +12 -12
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js +15 -15
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js +6 -6
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js +6 -6
- package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +109 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js +95 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/headers.js +10 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.js +15 -2
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js +3 -2
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +87 -0
- package/node_modules/@earendil-works/pi-ai/package.json +1 -33
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli/file-processor.js +13 -25
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +50 -34
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js +13 -5
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js +11 -11
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js +11 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.js +33 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/http-dispatcher.js +28 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-registry.js +2 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.js +15 -18
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/project-trust.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/provider-attribution.js +0 -10
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js +96 -73
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js +19 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/timings.js +24 -14
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js +20 -5
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit.js +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.js +12 -25
- package/node_modules/@earendil-works/pi-coding-agent/dist/index.js +2 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +20 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/assistant-message.js +23 -15
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-entry.js +52 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/extension-editor.js +12 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/session-selector.js +14 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +13 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/status-indicator.js +60 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/user-message.js +19 -6
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +180 -155
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-client.js +14 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-mode.js +16 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +7 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/rpc-entry.js +10 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-convert.js +21 -15
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-process.js +83 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/mime.js +41 -0
- package/node_modules/@earendil-works/pi-coding-agent/npm-shrinkwrap.json +12 -12
- package/node_modules/@earendil-works/pi-coding-agent/package.json +8 -5
- package/node_modules/@earendil-works/pi-orchestrator/dist/cli.js +136 -0
- package/node_modules/@earendil-works/pi-orchestrator/dist/config.js +55 -0
- package/node_modules/@earendil-works/pi-orchestrator/dist/handler.js +105 -0
- package/node_modules/@earendil-works/pi-orchestrator/dist/index.js +11 -0
- package/node_modules/@earendil-works/pi-orchestrator/dist/ipc/client.js +56 -0
- package/node_modules/@earendil-works/pi-orchestrator/dist/ipc/protocol.js +12 -0
- package/node_modules/@earendil-works/pi-orchestrator/dist/ipc/server.js +145 -0
- package/node_modules/@earendil-works/pi-orchestrator/dist/radius.js +365 -0
- package/node_modules/@earendil-works/pi-orchestrator/dist/rpc-process.js +168 -0
- package/node_modules/@earendil-works/pi-orchestrator/dist/serve.js +70 -0
- package/node_modules/@earendil-works/pi-orchestrator/dist/storage.js +58 -0
- package/node_modules/@earendil-works/pi-orchestrator/dist/supervisor.js +290 -0
- package/node_modules/@earendil-works/pi-orchestrator/dist/types.js +2 -0
- package/node_modules/@earendil-works/pi-orchestrator/package.json +45 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +3 -0
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.browser.js +358 -145
- package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.js +462 -142
- package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.native.js +358 -145
- package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +18 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/config/index.js +108 -63
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.browser.js +11 -8
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +11 -8
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +5 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.browser.js +30 -36
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +85 -137
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.native.js +30 -36
- package/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Js.js +30 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Node.js +24 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/index.browser.js +7 -1
- package/node_modules/@smithy/core/dist-es/submodules/checksum/index.js +7 -1
- package/node_modules/@smithy/core/dist-es/submodules/checksum/index.native.js +7 -1
- package/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Js.js +92 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Node.js +29 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Js.js +179 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Node.js +59 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256WebCrypto.js +71 -0
- package/node_modules/@smithy/core/dist-es/submodules/client/index.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/client-command-builder.js +17 -0
- package/node_modules/@smithy/core/dist-es/submodules/config/config-resolver/regionConfig/config.js +6 -1
- package/node_modules/@smithy/core/dist-es/submodules/config/config-resolver/regionConfig/getInstanceMetadataRegion.js +92 -0
- package/node_modules/@smithy/core/dist-es/submodules/config/defaults-mode/constants.js +3 -0
- package/node_modules/@smithy/core/dist-es/submodules/config/defaults-mode/resolveDefaultsModeConfig.js +3 -56
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/EventStreamCodec.js +5 -3
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/splitMessage.js +7 -6
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +4 -1
- package/node_modules/@smithy/core/dist-es/submodules/serde/concatBytes.js +15 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.browser.js +2 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.js +2 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.native.js +2 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/checksum/ChecksumStream.js +35 -27
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/headStream.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/stream-collector.browser.js +12 -38
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/stream-collector.js +18 -33
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-utf8/toUint8Array.browser.js +3 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-utf8/toUint8Array.js +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/crc32/Crc32Js.d.ts +18 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/crc32/Crc32Node.d.ts +18 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/index.browser.d.ts +7 -1
- package/node_modules/@smithy/core/dist-types/submodules/checksum/index.d.ts +7 -1
- package/node_modules/@smithy/core/dist-types/submodules/checksum/index.native.d.ts +7 -1
- package/node_modules/@smithy/core/dist-types/submodules/checksum/md5/Md5Js.d.ts +19 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/md5/Md5Node.d.ts +17 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256Js.d.ts +28 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256Node.d.ts +13 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256WebCrypto.d.ts +22 -0
- package/node_modules/@smithy/core/dist-types/submodules/client/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/submodules/client/smithy-client/client-command-builder.d.ts +22 -0
- package/node_modules/@smithy/core/dist-types/submodules/client/smithy-client/command.d.ts +5 -6
- package/node_modules/@smithy/core/dist-types/submodules/config/config-resolver/regionConfig/getInstanceMetadataRegion.d.ts +7 -0
- package/node_modules/@smithy/core/dist-types/submodules/config/defaults-mode/constants.d.ts +12 -0
- package/node_modules/@smithy/core/dist-types/submodules/endpoints/index.browser.d.ts +4 -5
- package/node_modules/@smithy/core/dist-types/submodules/endpoints/index.d.ts +4 -5
- package/node_modules/@smithy/core/dist-types/submodules/endpoints/middleware-endpoint/adaptors/getEndpointFromInstructions.d.ts +3 -4
- package/node_modules/@smithy/core/dist-types/submodules/endpoints/middleware-endpoint/endpointMiddleware.d.ts +1 -2
- package/node_modules/@smithy/core/dist-types/submodules/endpoints/middleware-endpoint/getEndpointPlugin.d.ts +1 -2
- package/node_modules/@smithy/core/dist-types/submodules/serde/concatBytes.d.ts +6 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/index.browser.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/index.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/index.native.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/checksum/ChecksumStream.d.ts +29 -12
- package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/stream-collector.browser.d.ts +8 -2
- package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/stream-collector.d.ts +4 -1
- package/node_modules/@smithy/core/package.json +5 -5
- package/node_modules/@smithy/credential-provider-imds/package.json +3 -3
- package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +2 -55
- package/node_modules/@smithy/fetch-http-handler/dist-es/index.js +2 -2
- package/node_modules/@smithy/fetch-http-handler/dist-types/index.d.ts +2 -2
- package/node_modules/@smithy/fetch-http-handler/package.json +4 -4
- package/node_modules/@smithy/signature-v4/package.json +3 -4
- package/node_modules/@smithy/types/dist-types/index.d.ts +1 -0
- package/node_modules/@smithy/types/package.json +1 -1
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/buffer.d.ts +64 -25
- package/node_modules/@types/node/crypto.d.ts +18 -5
- package/node_modules/@types/node/diagnostics_channel.d.ts +254 -23
- package/node_modules/@types/node/dns.d.ts +1 -1
- package/node_modules/@types/node/ffi.d.ts +486 -0
- package/node_modules/@types/node/fs/promises.d.ts +3 -0
- package/node_modules/@types/node/fs.d.ts +21 -6
- package/node_modules/@types/node/http.d.ts +25 -0
- package/node_modules/@types/node/index.d.ts +1 -0
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/process.d.ts +14 -1
- package/node_modules/@types/node/quic.d.ts +92 -11
- package/node_modules/@types/node/sqlite.d.ts +55 -0
- package/node_modules/@types/node/stream/iter.d.ts +150 -0
- package/node_modules/@types/node/stream.d.ts +32 -0
- package/node_modules/@types/node/test.d.ts +112 -2
- package/node_modules/@types/node/ts5.6/index.d.ts +1 -0
- package/node_modules/@types/node/ts5.7/index.d.ts +1 -0
- package/node_modules/@types/node/util.d.ts +19 -2
- package/node_modules/@types/node/v8.d.ts +84 -2
- package/node_modules/@types/node/worker_threads.d.ts +8 -7
- package/node_modules/brace-expansion/dist/commonjs/index.js +24 -14
- package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -1
- package/node_modules/brace-expansion/dist/esm/index.js +24 -14
- package/node_modules/brace-expansion/dist/esm/index.js.map +1 -1
- package/node_modules/brace-expansion/package.json +2 -2
- package/node_modules/google-auth-library/build/src/auth/googleauth.js +1 -1
- package/node_modules/google-auth-library/package.json +4 -4
- package/node_modules/protobufjs/dist/light/protobuf.js +2 -2
- package/node_modules/protobufjs/dist/light/protobuf.min.js +2 -2
- package/node_modules/protobufjs/dist/minimal/protobuf.js +2 -2
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +2 -2
- package/node_modules/protobufjs/dist/protobuf.js +5 -2
- package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/package.json +1 -1
- package/node_modules/protobufjs/src/parse.js +3 -0
- package/package.json +7 -6
- package/slingshot/index.js +293 -295
- package/node_modules/@aws-crypto/crc32/CHANGELOG.md +0 -100
- package/node_modules/@aws-crypto/crc32/LICENSE +0 -201
- package/node_modules/@aws-crypto/crc32/README.md +0 -16
- package/node_modules/@aws-crypto/crc32/build/main/aws_crc32.d.ts +0 -7
- package/node_modules/@aws-crypto/crc32/build/main/aws_crc32.js +0 -31
- package/node_modules/@aws-crypto/crc32/build/main/aws_crc32.js.map +0 -1
- package/node_modules/@aws-crypto/crc32/build/main/index.d.ts +0 -7
- package/node_modules/@aws-crypto/crc32/build/main/index.js +0 -108
- package/node_modules/@aws-crypto/crc32/build/main/index.js.map +0 -1
- package/node_modules/@aws-crypto/crc32/build/module/aws_crc32.d.ts +0 -7
- package/node_modules/@aws-crypto/crc32/build/module/aws_crc32.js +0 -28
- package/node_modules/@aws-crypto/crc32/build/module/aws_crc32.js.map +0 -1
- package/node_modules/@aws-crypto/crc32/build/module/index.d.ts +0 -7
- package/node_modules/@aws-crypto/crc32/build/module/index.js +0 -103
- package/node_modules/@aws-crypto/crc32/build/module/index.js.map +0 -1
- package/node_modules/@aws-crypto/crc32/package.json +0 -32
- package/node_modules/@aws-crypto/crc32/src/aws_crc32.ts +0 -24
- package/node_modules/@aws-crypto/crc32/src/index.ts +0 -92
- package/node_modules/@aws-crypto/crc32/tsconfig.json +0 -9
- package/node_modules/@aws-crypto/crc32/tsconfig.module.json +0 -7
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.browser.js +0 -869
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.native.js +0 -862
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/checkUrl.js +0 -42
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.browser.js +0 -27
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.js +0 -71
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/requestHelpers.js +0 -49
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/retry-wrapper.js +0 -13
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/index.browser.js +0 -2
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-es/stream-collector/collector.js +0 -8
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-es/stream-collector/index.js +0 -41
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-types/stream-collector/collector.d.ts +0 -5
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-types/stream-collector/index.d.ts +0 -7
- package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/fromTokenFile.js +0 -29
- package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/fromWebToken.js +0 -25
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-es/stream-collector/collector.js +0 -8
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-es/stream-collector/index.js +0 -41
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-types/stream-collector/collector.d.ts +0 -5
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-types/stream-collector/index.d.ts +0 -7
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.browser.js +0 -57
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.js +0 -234
- package/node_modules/@earendil-works/pi-ai/dist/api-registry.js +0 -44
- package/node_modules/@smithy/core/dist-es/submodules/checksum/md5-js/constants.js +0 -3
- package/node_modules/@smithy/core/dist-es/submodules/checksum/md5-js/md5.js +0 -168
- package/node_modules/@smithy/core/dist-types/submodules/checksum/md5-js/constants.d.ts +0 -12
- package/node_modules/@smithy/core/dist-types/submodules/checksum/md5-js/md5.d.ts +0 -16
- package/node_modules/@smithy/fetch-http-handler/dist-es/stream-collector.js +0 -53
- package/node_modules/@smithy/fetch-http-handler/dist-types/stream-collector.d.ts +0 -2
- /package/node_modules/@smithy/{core/dist-es/submodules/endpoints/middleware-endpoint/types.js → types/dist-es/endpoints/EndpointParameterInstructions.js} +0 -0
- /package/node_modules/@smithy/{core/dist-types/submodules/endpoints/middleware-endpoint/types.d.ts → types/dist-types/endpoints/EndpointParameterInstructions.d.ts} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import OpenAI from "openai";
|
|
2
2
|
import { calculateCost, clampThinkingLevel } from "../models.js";
|
|
3
|
+
import { formatProviderError, normalizeProviderError } from "../utils/error-body.js";
|
|
3
4
|
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
4
5
|
import { headersToRecord } from "../utils/headers.js";
|
|
5
6
|
import { parseStreamingJson } from "../utils/json-parse.js";
|
|
6
7
|
import { getProviderEnvValue } from "../utils/provider-env.js";
|
|
7
8
|
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
8
|
-
import { isCloudflareProvider, resolveCloudflareBaseUrl } from "./cloudflare.js";
|
|
9
9
|
import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "./github-copilot-headers.js";
|
|
10
10
|
import { clampOpenAIPromptCacheKey } from "./openai-prompt-cache.js";
|
|
11
11
|
import { buildBaseOptions } from "./simple-options.js";
|
|
@@ -15,6 +15,23 @@ import { transformMessages } from "./transform-messages.js";
|
|
|
15
15
|
* This is needed because Anthropic (via proxy) requires the tools param
|
|
16
16
|
* to be present when messages include tool_calls or tool role messages.
|
|
17
17
|
*/
|
|
18
|
+
function hasHeader(headers, name) {
|
|
19
|
+
if (!headers)
|
|
20
|
+
return false;
|
|
21
|
+
const expected = name.toLowerCase();
|
|
22
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
23
|
+
if (key.toLowerCase() === expected && value !== null && value.trim().length > 0)
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
function getClientApiKey(provider, apiKey, headers) {
|
|
29
|
+
if (apiKey)
|
|
30
|
+
return apiKey;
|
|
31
|
+
if (hasHeader(headers, "authorization") || hasHeader(headers, "cf-aig-authorization"))
|
|
32
|
+
return "unused";
|
|
33
|
+
throw new Error(`No API key for provider: ${provider}`);
|
|
34
|
+
}
|
|
18
35
|
function hasToolHistory(messages) {
|
|
19
36
|
for (const msg of messages) {
|
|
20
37
|
if (msg.role === "toolResult") {
|
|
@@ -81,14 +98,11 @@ export const stream = (model, context, options) => {
|
|
|
81
98
|
timestamp: Date.now(),
|
|
82
99
|
};
|
|
83
100
|
try {
|
|
84
|
-
const apiKey = options?.apiKey;
|
|
85
|
-
if (!apiKey) {
|
|
86
|
-
throw new Error(`No API key for provider: ${model.provider}`);
|
|
87
|
-
}
|
|
101
|
+
const apiKey = getClientApiKey(model.provider, options?.apiKey, options?.headers);
|
|
88
102
|
const compat = getCompat(model);
|
|
89
103
|
const cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env);
|
|
90
104
|
const cacheSessionId = cacheRetention === "none" ? undefined : options?.sessionId;
|
|
91
|
-
const client = createClient(model, context, apiKey, options?.headers, cacheSessionId, compat
|
|
105
|
+
const client = createClient(model, context, apiKey, options?.headers, cacheSessionId, compat);
|
|
92
106
|
let params = buildParams(model, context, options, compat, cacheRetention);
|
|
93
107
|
const nextParams = await options?.onPayload?.(params, model);
|
|
94
108
|
if (nextParams !== undefined) {
|
|
@@ -353,11 +367,15 @@ export const stream = (model, context, options) => {
|
|
|
353
367
|
delete block.streamIndex;
|
|
354
368
|
}
|
|
355
369
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
356
|
-
output.errorMessage =
|
|
370
|
+
output.errorMessage = formatProviderError(normalizeProviderError(error));
|
|
357
371
|
// Some providers via OpenRouter give additional information in this field.
|
|
372
|
+
// normalizeProviderError already stringifies the parsed body (error.error)
|
|
373
|
+
// into errorMessage, so only append the raw metadata when it is not already
|
|
374
|
+
// present to avoid double-printing it.
|
|
358
375
|
const rawMetadata = error?.error?.metadata?.raw;
|
|
359
|
-
if (rawMetadata)
|
|
376
|
+
if (rawMetadata && !output.errorMessage.includes(String(rawMetadata))) {
|
|
360
377
|
output.errorMessage += `\n${rawMetadata}`;
|
|
378
|
+
}
|
|
361
379
|
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
362
380
|
stream.end();
|
|
363
381
|
}
|
|
@@ -365,11 +383,8 @@ export const stream = (model, context, options) => {
|
|
|
365
383
|
return stream;
|
|
366
384
|
};
|
|
367
385
|
export const streamSimple = (model, context, options) => {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
throw new Error(`No API key for provider: ${model.provider}`);
|
|
371
|
-
}
|
|
372
|
-
const base = buildBaseOptions(model, options, apiKey);
|
|
386
|
+
getClientApiKey(model.provider, options?.apiKey, options?.headers);
|
|
387
|
+
const base = buildBaseOptions(model, context, options, options?.apiKey);
|
|
373
388
|
const clampedReasoning = options?.reasoning ? clampThinkingLevel(model, options.reasoning) : undefined;
|
|
374
389
|
const reasoningEffort = clampedReasoning === "off" ? undefined : clampedReasoning;
|
|
375
390
|
const toolChoice = options?.toolChoice;
|
|
@@ -379,7 +394,7 @@ export const streamSimple = (model, context, options) => {
|
|
|
379
394
|
toolChoice,
|
|
380
395
|
});
|
|
381
396
|
};
|
|
382
|
-
function createClient(model, context, apiKey, optionsHeaders, sessionId, compat = getCompat(model)
|
|
397
|
+
function createClient(model, context, apiKey, optionsHeaders, sessionId, compat = getCompat(model)) {
|
|
383
398
|
const headers = { ...model.headers };
|
|
384
399
|
if (model.provider === "github-copilot") {
|
|
385
400
|
const hasImages = hasCopilotVisionInput(context.messages);
|
|
@@ -398,18 +413,11 @@ function createClient(model, context, apiKey, optionsHeaders, sessionId, compat
|
|
|
398
413
|
if (optionsHeaders) {
|
|
399
414
|
Object.assign(headers, optionsHeaders);
|
|
400
415
|
}
|
|
401
|
-
const defaultHeaders = model.provider === "cloudflare-ai-gateway"
|
|
402
|
-
? {
|
|
403
|
-
...headers,
|
|
404
|
-
Authorization: headers.Authorization ?? null,
|
|
405
|
-
"cf-aig-authorization": `Bearer ${apiKey}`,
|
|
406
|
-
}
|
|
407
|
-
: headers;
|
|
408
416
|
return new OpenAI({
|
|
409
417
|
apiKey,
|
|
410
|
-
baseURL:
|
|
418
|
+
baseURL: model.baseUrl,
|
|
411
419
|
dangerouslyAllowBrowser: true,
|
|
412
|
-
defaultHeaders,
|
|
420
|
+
defaultHeaders: headers,
|
|
413
421
|
});
|
|
414
422
|
}
|
|
415
423
|
function buildParams(model, context, options, compat = getCompat(model), cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env)) {
|
|
@@ -460,7 +468,7 @@ function buildParams(model, context, options, compat = getCompat(model), cacheRe
|
|
|
460
468
|
}
|
|
461
469
|
if (compat.thinkingFormat === "zai" && model.reasoning) {
|
|
462
470
|
const zaiParams = params;
|
|
463
|
-
zaiParams.thinking =
|
|
471
|
+
zaiParams.thinking = options?.reasoningEffort ? { type: "enabled", clear_thinking: false } : { type: "disabled" };
|
|
464
472
|
if (options?.reasoningEffort && compat.supportsReasoningEffort) {
|
|
465
473
|
const mappedEffort = model.thinkingLevelMap?.[options.reasoningEffort];
|
|
466
474
|
const effort = mappedEffort === undefined ? options.reasoningEffort : mappedEffort;
|
|
@@ -545,7 +553,7 @@ function buildParams(model, context, options, compat = getCompat(model), cacheRe
|
|
|
545
553
|
params.provider = model.compat.openRouterRouting;
|
|
546
554
|
}
|
|
547
555
|
// Vercel AI Gateway provider routing preferences
|
|
548
|
-
if (model.
|
|
556
|
+
if (model.compat?.vercelGatewayRouting) {
|
|
549
557
|
const routing = model.compat.vercelGatewayRouting;
|
|
550
558
|
if (routing.only || routing.order) {
|
|
551
559
|
const gatewayOptions = {};
|
|
@@ -913,6 +921,7 @@ function parseChunkUsage(rawUsage, model) {
|
|
|
913
921
|
output: outputTokens,
|
|
914
922
|
cacheRead: cacheReadTokens,
|
|
915
923
|
cacheWrite: cacheWriteTokens,
|
|
924
|
+
reasoning: rawUsage.completion_tokens_details?.reasoning_tokens || 0,
|
|
916
925
|
totalTokens: input + outputTokens + cacheReadTokens + cacheWriteTokens,
|
|
917
926
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
918
927
|
};
|
|
@@ -943,9 +952,9 @@ function mapStopReason(reason) {
|
|
|
943
952
|
}
|
|
944
953
|
}
|
|
945
954
|
/**
|
|
946
|
-
*
|
|
947
|
-
*
|
|
948
|
-
*
|
|
955
|
+
* Auto-detect compatibility settings from provider name and baseUrl.
|
|
956
|
+
* Used as the base when model.compat is not set; explicit model.compat
|
|
957
|
+
* entries override these detected values.
|
|
949
958
|
*/
|
|
950
959
|
function detectCompat(model) {
|
|
951
960
|
const provider = model.provider;
|
|
@@ -1018,7 +1027,7 @@ function detectCompat(model) {
|
|
|
1018
1027
|
}
|
|
1019
1028
|
/**
|
|
1020
1029
|
* Get resolved compatibility settings for a model.
|
|
1021
|
-
*
|
|
1030
|
+
* Auto-detects from provider/URL then overrides with explicit model.compat.
|
|
1022
1031
|
*/
|
|
1023
1032
|
function getCompat(model) {
|
|
1024
1033
|
const detected = detectCompat(model);
|
|
@@ -214,254 +214,236 @@ export function convertResponsesTools(tools, options) {
|
|
|
214
214
|
strict,
|
|
215
215
|
}));
|
|
216
216
|
}
|
|
217
|
-
// =============================================================================
|
|
218
|
-
// Stream processing
|
|
219
|
-
// =============================================================================
|
|
220
217
|
export async function processResponsesStream(openaiStream, output, stream, model, options) {
|
|
221
|
-
let
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
|
|
218
|
+
let sawTerminalResponseEvent = false;
|
|
219
|
+
const outputSlots = new Map();
|
|
220
|
+
const getSlot = (outputIndex, type) => {
|
|
221
|
+
const slot = outputSlots.get(outputIndex);
|
|
222
|
+
return slot?.type === type ? slot : undefined;
|
|
223
|
+
};
|
|
224
|
+
const createSlot = (outputIndex, item) => {
|
|
225
|
+
if (item.type === "reasoning") {
|
|
226
|
+
const block = { type: "thinking", thinking: "" };
|
|
227
|
+
output.content.push(block);
|
|
228
|
+
const slot = {
|
|
229
|
+
type: "thinking",
|
|
230
|
+
block,
|
|
231
|
+
contentIndex: output.content.length - 1,
|
|
232
|
+
};
|
|
233
|
+
outputSlots.set(outputIndex, slot);
|
|
234
|
+
stream.push({ type: "thinking_start", contentIndex: slot.contentIndex, partial: output });
|
|
235
|
+
return slot;
|
|
236
|
+
}
|
|
237
|
+
if (item.type === "message") {
|
|
238
|
+
const block = { type: "text", text: "" };
|
|
239
|
+
output.content.push(block);
|
|
240
|
+
const slot = { type: "text", block, contentIndex: output.content.length - 1 };
|
|
241
|
+
outputSlots.set(outputIndex, slot);
|
|
242
|
+
stream.push({ type: "text_start", contentIndex: slot.contentIndex, partial: output });
|
|
243
|
+
return slot;
|
|
244
|
+
}
|
|
245
|
+
if (item.type === "function_call") {
|
|
246
|
+
const block = {
|
|
247
|
+
type: "toolCall",
|
|
248
|
+
id: `${item.call_id}|${item.id}`,
|
|
249
|
+
name: item.name,
|
|
250
|
+
arguments: {},
|
|
251
|
+
partialJson: item.arguments || "",
|
|
252
|
+
};
|
|
253
|
+
output.content.push(block);
|
|
254
|
+
const slot = {
|
|
255
|
+
type: "toolCall",
|
|
256
|
+
block,
|
|
257
|
+
contentIndex: output.content.length - 1,
|
|
258
|
+
};
|
|
259
|
+
outputSlots.set(outputIndex, slot);
|
|
260
|
+
stream.push({ type: "toolcall_start", contentIndex: slot.contentIndex, partial: output });
|
|
261
|
+
return slot;
|
|
262
|
+
}
|
|
263
|
+
return undefined;
|
|
264
|
+
};
|
|
265
|
+
const getOrCreateSlot = (outputIndex, item) => {
|
|
266
|
+
return outputSlots.get(outputIndex) ?? createSlot(outputIndex, item);
|
|
267
|
+
};
|
|
268
|
+
const finalizeResponse = (response) => {
|
|
269
|
+
sawTerminalResponseEvent = true;
|
|
270
|
+
if (response?.id) {
|
|
271
|
+
output.responseId = response.id;
|
|
272
|
+
}
|
|
273
|
+
if (response?.usage) {
|
|
274
|
+
const cachedTokens = response.usage.input_tokens_details?.cached_tokens || 0;
|
|
275
|
+
output.usage = {
|
|
276
|
+
// OpenAI includes cached tokens in input_tokens, so subtract to get non-cached input
|
|
277
|
+
input: (response.usage.input_tokens || 0) - cachedTokens,
|
|
278
|
+
output: response.usage.output_tokens || 0,
|
|
279
|
+
cacheRead: cachedTokens,
|
|
280
|
+
cacheWrite: 0,
|
|
281
|
+
reasoning: response.usage.output_tokens_details?.reasoning_tokens || 0,
|
|
282
|
+
totalTokens: response.usage.total_tokens || 0,
|
|
283
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
calculateCost(model, output.usage);
|
|
287
|
+
if (options?.applyServiceTierPricing) {
|
|
288
|
+
const serviceTier = options.resolveServiceTier
|
|
289
|
+
? options.resolveServiceTier(response?.service_tier, options.serviceTier)
|
|
290
|
+
: (response?.service_tier ?? options.serviceTier);
|
|
291
|
+
options.applyServiceTierPricing(output.usage, serviceTier);
|
|
292
|
+
}
|
|
293
|
+
// Map status to stop reason
|
|
294
|
+
output.stopReason = mapStopReason(response?.status);
|
|
295
|
+
if (output.content.some((b) => b.type === "toolCall") && output.stopReason === "stop") {
|
|
296
|
+
output.stopReason = "toolUse";
|
|
297
|
+
}
|
|
298
|
+
};
|
|
225
299
|
for await (const event of openaiStream) {
|
|
226
300
|
if (event.type === "response.created") {
|
|
227
301
|
output.responseId = event.response.id;
|
|
228
302
|
}
|
|
229
303
|
else if (event.type === "response.output_item.added") {
|
|
230
|
-
|
|
231
|
-
if (item.type === "reasoning") {
|
|
232
|
-
currentItem = item;
|
|
233
|
-
currentBlock = { type: "thinking", thinking: "" };
|
|
234
|
-
output.content.push(currentBlock);
|
|
235
|
-
stream.push({ type: "thinking_start", contentIndex: blockIndex(), partial: output });
|
|
236
|
-
}
|
|
237
|
-
else if (item.type === "message") {
|
|
238
|
-
currentItem = item;
|
|
239
|
-
currentBlock = { type: "text", text: "" };
|
|
240
|
-
output.content.push(currentBlock);
|
|
241
|
-
stream.push({ type: "text_start", contentIndex: blockIndex(), partial: output });
|
|
242
|
-
}
|
|
243
|
-
else if (item.type === "function_call") {
|
|
244
|
-
currentItem = item;
|
|
245
|
-
currentBlock = {
|
|
246
|
-
type: "toolCall",
|
|
247
|
-
id: `${item.call_id}|${item.id}`,
|
|
248
|
-
name: item.name,
|
|
249
|
-
arguments: {},
|
|
250
|
-
partialJson: item.arguments || "",
|
|
251
|
-
};
|
|
252
|
-
output.content.push(currentBlock);
|
|
253
|
-
stream.push({ type: "toolcall_start", contentIndex: blockIndex(), partial: output });
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
else if (event.type === "response.reasoning_summary_part.added") {
|
|
257
|
-
if (currentItem && currentItem.type === "reasoning") {
|
|
258
|
-
currentItem.summary = currentItem.summary || [];
|
|
259
|
-
currentItem.summary.push(event.part);
|
|
260
|
-
}
|
|
304
|
+
createSlot(event.output_index, event.item);
|
|
261
305
|
}
|
|
262
306
|
else if (event.type === "response.reasoning_summary_text.delta") {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
partial: output,
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
}
|
|
307
|
+
const slot = getSlot(event.output_index, "thinking");
|
|
308
|
+
if (!slot)
|
|
309
|
+
continue;
|
|
310
|
+
slot.block.thinking += event.delta;
|
|
311
|
+
stream.push({
|
|
312
|
+
type: "thinking_delta",
|
|
313
|
+
contentIndex: slot.contentIndex,
|
|
314
|
+
delta: event.delta,
|
|
315
|
+
partial: output,
|
|
316
|
+
});
|
|
277
317
|
}
|
|
278
318
|
else if (event.type === "response.reasoning_summary_part.done") {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
partial: output,
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
}
|
|
319
|
+
const slot = getSlot(event.output_index, "thinking");
|
|
320
|
+
if (!slot)
|
|
321
|
+
continue;
|
|
322
|
+
slot.block.thinking += "\n\n";
|
|
323
|
+
stream.push({
|
|
324
|
+
type: "thinking_delta",
|
|
325
|
+
contentIndex: slot.contentIndex,
|
|
326
|
+
delta: "\n\n",
|
|
327
|
+
partial: output,
|
|
328
|
+
});
|
|
293
329
|
}
|
|
294
330
|
else if (event.type === "response.reasoning_text.delta") {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
else if (event.type === "response.content_part.added") {
|
|
306
|
-
if (currentItem?.type === "message") {
|
|
307
|
-
currentItem.content = currentItem.content || [];
|
|
308
|
-
// Filter out ReasoningText, only accept output_text and refusal
|
|
309
|
-
if (event.part.type === "output_text" || event.part.type === "refusal") {
|
|
310
|
-
currentItem.content.push(event.part);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
331
|
+
const slot = getSlot(event.output_index, "thinking");
|
|
332
|
+
if (!slot)
|
|
333
|
+
continue;
|
|
334
|
+
slot.block.thinking += event.delta;
|
|
335
|
+
stream.push({
|
|
336
|
+
type: "thinking_delta",
|
|
337
|
+
contentIndex: slot.contentIndex,
|
|
338
|
+
delta: event.delta,
|
|
339
|
+
partial: output,
|
|
340
|
+
});
|
|
313
341
|
}
|
|
314
342
|
else if (event.type === "response.output_text.delta") {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
contentIndex: blockIndex(),
|
|
326
|
-
delta: event.delta,
|
|
327
|
-
partial: output,
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
}
|
|
343
|
+
const slot = getSlot(event.output_index, "text");
|
|
344
|
+
if (!slot)
|
|
345
|
+
continue;
|
|
346
|
+
slot.block.text += event.delta;
|
|
347
|
+
stream.push({
|
|
348
|
+
type: "text_delta",
|
|
349
|
+
contentIndex: slot.contentIndex,
|
|
350
|
+
delta: event.delta,
|
|
351
|
+
partial: output,
|
|
352
|
+
});
|
|
331
353
|
}
|
|
332
354
|
else if (event.type === "response.refusal.delta") {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
contentIndex: blockIndex(),
|
|
344
|
-
delta: event.delta,
|
|
345
|
-
partial: output,
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
}
|
|
355
|
+
const slot = getSlot(event.output_index, "text");
|
|
356
|
+
if (!slot)
|
|
357
|
+
continue;
|
|
358
|
+
slot.block.text += event.delta;
|
|
359
|
+
stream.push({
|
|
360
|
+
type: "text_delta",
|
|
361
|
+
contentIndex: slot.contentIndex,
|
|
362
|
+
delta: event.delta,
|
|
363
|
+
partial: output,
|
|
364
|
+
});
|
|
349
365
|
}
|
|
350
366
|
else if (event.type === "response.function_call_arguments.delta") {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
367
|
+
const slot = getSlot(event.output_index, "toolCall");
|
|
368
|
+
if (!slot)
|
|
369
|
+
continue;
|
|
370
|
+
slot.block.partialJson += event.delta;
|
|
371
|
+
slot.block.arguments = parseStreamingJson(slot.block.partialJson);
|
|
372
|
+
stream.push({
|
|
373
|
+
type: "toolcall_delta",
|
|
374
|
+
contentIndex: slot.contentIndex,
|
|
375
|
+
delta: event.delta,
|
|
376
|
+
partial: output,
|
|
377
|
+
});
|
|
361
378
|
}
|
|
362
379
|
else if (event.type === "response.function_call_arguments.done") {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
380
|
+
const slot = getSlot(event.output_index, "toolCall");
|
|
381
|
+
if (!slot)
|
|
382
|
+
continue;
|
|
383
|
+
const previousPartialJson = slot.block.partialJson;
|
|
384
|
+
slot.block.partialJson = event.arguments;
|
|
385
|
+
slot.block.arguments = parseStreamingJson(slot.block.partialJson);
|
|
386
|
+
if (event.arguments.startsWith(previousPartialJson)) {
|
|
387
|
+
const delta = event.arguments.slice(previousPartialJson.length);
|
|
388
|
+
if (delta.length > 0) {
|
|
389
|
+
stream.push({
|
|
390
|
+
type: "toolcall_delta",
|
|
391
|
+
contentIndex: slot.contentIndex,
|
|
392
|
+
delta,
|
|
393
|
+
partial: output,
|
|
394
|
+
});
|
|
377
395
|
}
|
|
378
396
|
}
|
|
379
397
|
}
|
|
380
398
|
else if (event.type === "response.output_item.done") {
|
|
381
399
|
const item = event.item;
|
|
382
|
-
|
|
400
|
+
const slot = getOrCreateSlot(event.output_index, item);
|
|
401
|
+
if (item.type === "reasoning" && slot?.type === "thinking") {
|
|
383
402
|
const summaryText = item.summary?.map((s) => s.text).join("\n\n") || "";
|
|
384
403
|
const contentText = item.content?.map((c) => c.text).join("\n\n") || "";
|
|
385
|
-
|
|
386
|
-
|
|
404
|
+
slot.block.thinking = summaryText || contentText || slot.block.thinking;
|
|
405
|
+
slot.block.thinkingSignature = JSON.stringify(item);
|
|
387
406
|
stream.push({
|
|
388
407
|
type: "thinking_end",
|
|
389
|
-
contentIndex:
|
|
390
|
-
content:
|
|
408
|
+
contentIndex: slot.contentIndex,
|
|
409
|
+
content: slot.block.thinking,
|
|
391
410
|
partial: output,
|
|
392
411
|
});
|
|
393
|
-
|
|
412
|
+
outputSlots.delete(event.output_index);
|
|
394
413
|
}
|
|
395
|
-
else if (item.type === "message" &&
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
currentBlock.textSignature = encodeTextSignatureV1(item.id, item.phase ?? undefined);
|
|
414
|
+
else if (item.type === "message" && slot?.type === "text") {
|
|
415
|
+
slot.block.text = item.content?.map((c) => (c.type === "output_text" ? c.text : c.refusal)).join("") || "";
|
|
416
|
+
slot.block.textSignature = encodeTextSignatureV1(item.id, item.phase ?? undefined);
|
|
399
417
|
stream.push({
|
|
400
418
|
type: "text_end",
|
|
401
|
-
contentIndex:
|
|
402
|
-
content:
|
|
419
|
+
contentIndex: slot.contentIndex,
|
|
420
|
+
content: slot.block.text,
|
|
403
421
|
partial: output,
|
|
404
422
|
});
|
|
405
|
-
|
|
423
|
+
outputSlots.delete(event.output_index);
|
|
406
424
|
}
|
|
407
|
-
else if (item.type === "function_call") {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
else {
|
|
420
|
-
toolCall = {
|
|
421
|
-
type: "toolCall",
|
|
422
|
-
id: `${item.call_id}|${item.id}`,
|
|
423
|
-
name: item.name,
|
|
424
|
-
arguments: args,
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
currentBlock = null;
|
|
428
|
-
stream.push({ type: "toolcall_end", contentIndex: blockIndex(), toolCall, partial: output });
|
|
425
|
+
else if (item.type === "function_call" && slot?.type === "toolCall") {
|
|
426
|
+
slot.block.arguments = parseStreamingJson(item.arguments || slot.block.partialJson || "{}");
|
|
427
|
+
// Finalize in-place and strip the scratch buffer so replay only
|
|
428
|
+
// carries parsed arguments.
|
|
429
|
+
delete slot.block.partialJson;
|
|
430
|
+
stream.push({
|
|
431
|
+
type: "toolcall_end",
|
|
432
|
+
contentIndex: slot.contentIndex,
|
|
433
|
+
toolCall: slot.block,
|
|
434
|
+
partial: output,
|
|
435
|
+
});
|
|
436
|
+
outputSlots.delete(event.output_index);
|
|
429
437
|
}
|
|
430
438
|
}
|
|
431
|
-
else if (event.type === "response.completed") {
|
|
432
|
-
|
|
433
|
-
if (response?.id) {
|
|
434
|
-
output.responseId = response.id;
|
|
435
|
-
}
|
|
436
|
-
if (response?.usage) {
|
|
437
|
-
const cachedTokens = response.usage.input_tokens_details?.cached_tokens || 0;
|
|
438
|
-
output.usage = {
|
|
439
|
-
// OpenAI includes cached tokens in input_tokens, so subtract to get non-cached input
|
|
440
|
-
input: (response.usage.input_tokens || 0) - cachedTokens,
|
|
441
|
-
output: response.usage.output_tokens || 0,
|
|
442
|
-
cacheRead: cachedTokens,
|
|
443
|
-
cacheWrite: 0,
|
|
444
|
-
totalTokens: response.usage.total_tokens || 0,
|
|
445
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
calculateCost(model, output.usage);
|
|
449
|
-
if (options?.applyServiceTierPricing) {
|
|
450
|
-
const serviceTier = options.resolveServiceTier
|
|
451
|
-
? options.resolveServiceTier(response?.service_tier, options.serviceTier)
|
|
452
|
-
: (response?.service_tier ?? options.serviceTier);
|
|
453
|
-
options.applyServiceTierPricing(output.usage, serviceTier);
|
|
454
|
-
}
|
|
455
|
-
// Map status to stop reason
|
|
456
|
-
output.stopReason = mapStopReason(response?.status);
|
|
457
|
-
if (output.content.some((b) => b.type === "toolCall") && output.stopReason === "stop") {
|
|
458
|
-
output.stopReason = "toolUse";
|
|
459
|
-
}
|
|
439
|
+
else if (event.type === "response.completed" || event.type === "response.incomplete") {
|
|
440
|
+
finalizeResponse(event.response);
|
|
460
441
|
}
|
|
461
442
|
else if (event.type === "error") {
|
|
462
443
|
throw new Error(`Error Code ${event.code}: ${event.message}` || "Unknown error");
|
|
463
444
|
}
|
|
464
445
|
else if (event.type === "response.failed") {
|
|
446
|
+
sawTerminalResponseEvent = true;
|
|
465
447
|
const error = event.response?.error;
|
|
466
448
|
const details = event.response?.incomplete_details;
|
|
467
449
|
const msg = error
|
|
@@ -472,6 +454,9 @@ export async function processResponsesStream(openaiStream, output, stream, model
|
|
|
472
454
|
throw new Error(msg);
|
|
473
455
|
}
|
|
474
456
|
}
|
|
457
|
+
if (!sawTerminalResponseEvent) {
|
|
458
|
+
throw new Error("OpenAI Responses stream ended before a terminal response event");
|
|
459
|
+
}
|
|
475
460
|
}
|
|
476
461
|
function mapStopReason(status) {
|
|
477
462
|
if (!status)
|