@jini-ai/agent-runtime 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +43 -0
- package/dist/acp-model-probe.d.ts +48 -0
- package/dist/acp-model-probe.d.ts.map +1 -0
- package/dist/acp-model-probe.js +15 -0
- package/dist/acp-model-probe.js.map +1 -0
- package/dist/agent-protocol/acp/account-failure.d.ts +54 -0
- package/dist/agent-protocol/acp/account-failure.d.ts.map +1 -0
- package/dist/agent-protocol/acp/account-failure.js +37 -0
- package/dist/agent-protocol/acp/account-failure.js.map +1 -0
- package/dist/agent-protocol/acp/constants.d.ts +26 -0
- package/dist/agent-protocol/acp/constants.d.ts.map +1 -0
- package/dist/agent-protocol/acp/constants.js +39 -0
- package/dist/agent-protocol/acp/constants.js.map +1 -0
- package/dist/agent-protocol/acp/index.d.ts +14 -0
- package/dist/agent-protocol/acp/index.d.ts.map +1 -0
- package/dist/agent-protocol/acp/index.js +14 -0
- package/dist/agent-protocol/acp/index.js.map +1 -0
- package/dist/agent-protocol/acp/json.d.ts +82 -0
- package/dist/agent-protocol/acp/json.d.ts.map +1 -0
- package/dist/agent-protocol/acp/json.js +144 -0
- package/dist/agent-protocol/acp/json.js.map +1 -0
- package/dist/agent-protocol/acp/models.d.ts +112 -0
- package/dist/agent-protocol/acp/models.d.ts.map +1 -0
- package/dist/agent-protocol/acp/models.js +293 -0
- package/dist/agent-protocol/acp/models.js.map +1 -0
- package/dist/agent-protocol/acp/rpc.d.ts +107 -0
- package/dist/agent-protocol/acp/rpc.d.ts.map +1 -0
- package/dist/agent-protocol/acp/rpc.js +162 -0
- package/dist/agent-protocol/acp/rpc.js.map +1 -0
- package/dist/agent-protocol/acp/session-params.d.ts +55 -0
- package/dist/agent-protocol/acp/session-params.d.ts.map +1 -0
- package/dist/agent-protocol/acp/session-params.js +81 -0
- package/dist/agent-protocol/acp/session-params.js.map +1 -0
- package/dist/agent-protocol/acp/session.d.ts +101 -0
- package/dist/agent-protocol/acp/session.d.ts.map +1 -0
- package/dist/agent-protocol/acp/session.js +832 -0
- package/dist/agent-protocol/acp/session.js.map +1 -0
- package/dist/agent-protocol/acp/text-suppression.d.ts +73 -0
- package/dist/agent-protocol/acp/text-suppression.d.ts.map +1 -0
- package/dist/agent-protocol/acp/text-suppression.js +229 -0
- package/dist/agent-protocol/acp/text-suppression.js.map +1 -0
- package/dist/agent-protocol/acp/types.d.ts +27 -0
- package/dist/agent-protocol/acp/types.d.ts.map +1 -0
- package/dist/agent-protocol/acp/types.js +2 -0
- package/dist/agent-protocol/acp/types.js.map +1 -0
- package/dist/agent-protocol/acp/updates.d.ts +166 -0
- package/dist/agent-protocol/acp/updates.d.ts.map +1 -0
- package/dist/agent-protocol/acp/updates.js +268 -0
- package/dist/agent-protocol/acp/updates.js.map +1 -0
- package/dist/agent-protocol/core/index.d.ts +6 -0
- package/dist/agent-protocol/core/index.d.ts.map +1 -0
- package/dist/agent-protocol/core/index.js +6 -0
- package/dist/agent-protocol/core/index.js.map +1 -0
- package/dist/agent-protocol/core/json-line-stream.d.ts +42 -0
- package/dist/agent-protocol/core/json-line-stream.d.ts.map +1 -0
- package/dist/agent-protocol/core/json-line-stream.js +333 -0
- package/dist/agent-protocol/core/json-line-stream.js.map +1 -0
- package/dist/agent-protocol/index.d.ts +8 -0
- package/dist/agent-protocol/index.d.ts.map +1 -0
- package/dist/agent-protocol/index.js +8 -0
- package/dist/agent-protocol/index.js.map +1 -0
- package/dist/agent-protocol/pi-rpc/events.d.ts +26 -0
- package/dist/agent-protocol/pi-rpc/events.d.ts.map +1 -0
- package/dist/agent-protocol/pi-rpc/events.js +167 -0
- package/dist/agent-protocol/pi-rpc/events.js.map +1 -0
- package/dist/agent-protocol/pi-rpc/index.d.ts +11 -0
- package/dist/agent-protocol/pi-rpc/index.d.ts.map +1 -0
- package/dist/agent-protocol/pi-rpc/index.js +11 -0
- package/dist/agent-protocol/pi-rpc/index.js.map +1 -0
- package/dist/agent-protocol/pi-rpc/internal.d.ts +45 -0
- package/dist/agent-protocol/pi-rpc/internal.d.ts.map +1 -0
- package/dist/agent-protocol/pi-rpc/internal.js +41 -0
- package/dist/agent-protocol/pi-rpc/internal.js.map +1 -0
- package/dist/agent-protocol/pi-rpc/models.d.ts +21 -0
- package/dist/agent-protocol/pi-rpc/models.d.ts.map +1 -0
- package/dist/agent-protocol/pi-rpc/models.js +48 -0
- package/dist/agent-protocol/pi-rpc/models.js.map +1 -0
- package/dist/agent-protocol/pi-rpc/session.d.ts +106 -0
- package/dist/agent-protocol/pi-rpc/session.d.ts.map +1 -0
- package/dist/agent-protocol/pi-rpc/session.js +371 -0
- package/dist/agent-protocol/pi-rpc/session.js.map +1 -0
- package/dist/amr-model-cache.d.ts +40 -0
- package/dist/amr-model-cache.d.ts.map +1 -0
- package/dist/amr-model-cache.js +79 -0
- package/dist/amr-model-cache.js.map +1 -0
- package/dist/amr-profile-resolver.d.ts +21 -0
- package/dist/amr-profile-resolver.d.ts.map +1 -0
- package/dist/amr-profile-resolver.js +4 -0
- package/dist/amr-profile-resolver.js.map +1 -0
- package/dist/artifact-taxonomy.d.ts +27 -0
- package/dist/artifact-taxonomy.d.ts.map +1 -0
- package/dist/artifact-taxonomy.js +5 -0
- package/dist/artifact-taxonomy.js.map +1 -0
- package/dist/auth.d.ts +25 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +332 -0
- package/dist/auth.js.map +1 -0
- package/dist/capabilities.d.ts +9 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +2 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/claude-stream.d.ts +37 -0
- package/dist/claude-stream.d.ts.map +1 -0
- package/dist/claude-stream.js +660 -0
- package/dist/claude-stream.js.map +1 -0
- package/dist/copilot-stream.d.ts +37 -0
- package/dist/copilot-stream.d.ts.map +1 -0
- package/dist/copilot-stream.js +136 -0
- package/dist/copilot-stream.js.map +1 -0
- package/dist/defs/aider.d.ts +13 -0
- package/dist/defs/aider.d.ts.map +1 -0
- package/dist/defs/aider.js +63 -0
- package/dist/defs/aider.js.map +1 -0
- package/dist/defs/amp.d.ts +12 -0
- package/dist/defs/amp.d.ts.map +1 -0
- package/dist/defs/amp.js +56 -0
- package/dist/defs/amp.js.map +1 -0
- package/dist/defs/amr.d.ts +37 -0
- package/dist/defs/amr.d.ts.map +1 -0
- package/dist/defs/amr.js +303 -0
- package/dist/defs/amr.js.map +1 -0
- package/dist/defs/antigravity.d.ts +25 -0
- package/dist/defs/antigravity.d.ts.map +1 -0
- package/dist/defs/antigravity.js +213 -0
- package/dist/defs/antigravity.js.map +1 -0
- package/dist/defs/claude.d.ts +30 -0
- package/dist/defs/claude.d.ts.map +1 -0
- package/dist/defs/claude.js +130 -0
- package/dist/defs/claude.js.map +1 -0
- package/dist/defs/codebuddy.d.ts +26 -0
- package/dist/defs/codebuddy.d.ts.map +1 -0
- package/dist/defs/codebuddy.js +124 -0
- package/dist/defs/codebuddy.js.map +1 -0
- package/dist/defs/codex.d.ts +30 -0
- package/dist/defs/codex.d.ts.map +1 -0
- package/dist/defs/codex.js +196 -0
- package/dist/defs/codex.js.map +1 -0
- package/dist/defs/copilot.d.ts +12 -0
- package/dist/defs/copilot.d.ts.map +1 -0
- package/dist/defs/copilot.js +88 -0
- package/dist/defs/copilot.js.map +1 -0
- package/dist/defs/cursor-agent.d.ts +27 -0
- package/dist/defs/cursor-agent.d.ts.map +1 -0
- package/dist/defs/cursor-agent.js +93 -0
- package/dist/defs/cursor-agent.js.map +1 -0
- package/dist/defs/deepseek.d.ts +12 -0
- package/dist/defs/deepseek.d.ts.map +1 -0
- package/dist/defs/deepseek.js +53 -0
- package/dist/defs/deepseek.js.map +1 -0
- package/dist/defs/devin.d.ts +12 -0
- package/dist/defs/devin.d.ts.map +1 -0
- package/dist/defs/devin.js +45 -0
- package/dist/defs/devin.js.map +1 -0
- package/dist/defs/grok-build.d.ts +26 -0
- package/dist/defs/grok-build.d.ts.map +1 -0
- package/dist/defs/grok-build.js +105 -0
- package/dist/defs/grok-build.js.map +1 -0
- package/dist/defs/hermes.d.ts +13 -0
- package/dist/defs/hermes.d.ts.map +1 -0
- package/dist/defs/hermes.js +51 -0
- package/dist/defs/hermes.js.map +1 -0
- package/dist/defs/index.d.ts +33 -0
- package/dist/defs/index.d.ts.map +1 -0
- package/dist/defs/index.js +33 -0
- package/dist/defs/index.js.map +1 -0
- package/dist/defs/kilo.d.ts +12 -0
- package/dist/defs/kilo.d.ts.map +1 -0
- package/dist/defs/kilo.js +20 -0
- package/dist/defs/kilo.js.map +1 -0
- package/dist/defs/kimi.d.ts +13 -0
- package/dist/defs/kimi.d.ts.map +1 -0
- package/dist/defs/kimi.js +26 -0
- package/dist/defs/kimi.js.map +1 -0
- package/dist/defs/kiro.d.ts +12 -0
- package/dist/defs/kiro.d.ts.map +1 -0
- package/dist/defs/kiro.js +20 -0
- package/dist/defs/kiro.js.map +1 -0
- package/dist/defs/mimo.d.ts +13 -0
- package/dist/defs/mimo.d.ts.map +1 -0
- package/dist/defs/mimo.js +26 -0
- package/dist/defs/mimo.js.map +1 -0
- package/dist/defs/opencode.d.ts +27 -0
- package/dist/defs/opencode.d.ts.map +1 -0
- package/dist/defs/opencode.js +89 -0
- package/dist/defs/opencode.js.map +1 -0
- package/dist/defs/pi.d.ts +18 -0
- package/dist/defs/pi.d.ts.map +1 -0
- package/dist/defs/pi.js +94 -0
- package/dist/defs/pi.js.map +1 -0
- package/dist/defs/qoder.d.ts +11 -0
- package/dist/defs/qoder.d.ts.map +1 -0
- package/dist/defs/qoder.js +50 -0
- package/dist/defs/qoder.js.map +1 -0
- package/dist/defs/qwen.d.ts +11 -0
- package/dist/defs/qwen.d.ts.map +1 -0
- package/dist/defs/qwen.js +28 -0
- package/dist/defs/qwen.js.map +1 -0
- package/dist/defs/reasonix.d.ts +20 -0
- package/dist/defs/reasonix.d.ts.map +1 -0
- package/dist/defs/reasonix.js +60 -0
- package/dist/defs/reasonix.js.map +1 -0
- package/dist/defs/shared.d.ts +23 -0
- package/dist/defs/shared.d.ts.map +1 -0
- package/dist/defs/shared.js +58 -0
- package/dist/defs/shared.js.map +1 -0
- package/dist/defs/trae-cli.d.ts +14 -0
- package/dist/defs/trae-cli.d.ts.map +1 -0
- package/dist/defs/trae-cli.js +22 -0
- package/dist/defs/trae-cli.js.map +1 -0
- package/dist/defs/vibe.d.ts +12 -0
- package/dist/defs/vibe.d.ts.map +1 -0
- package/dist/defs/vibe.js +20 -0
- package/dist/defs/vibe.js.map +1 -0
- package/dist/detection.d.ts +14 -0
- package/dist/detection.d.ts.map +1 -0
- package/dist/detection.js +266 -0
- package/dist/detection.js.map +1 -0
- package/dist/diagnostics.d.ts +8 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +95 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/env.d.ts +19 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +95 -0
- package/dist/env.js.map +1 -0
- package/dist/executables.d.ts +24 -0
- package/dist/executables.d.ts.map +1 -0
- package/dist/executables.js +349 -0
- package/dist/executables.js.map +1 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/dist/invocation.d.ts +6 -0
- package/dist/invocation.d.ts.map +1 -0
- package/dist/invocation.js +47 -0
- package/dist/invocation.js.map +1 -0
- package/dist/json-event-stream.d.ts +9 -0
- package/dist/json-event-stream.d.ts.map +1 -0
- package/dist/json-event-stream.js +856 -0
- package/dist/json-event-stream.js.map +1 -0
- package/dist/launch.d.ts +12 -0
- package/dist/launch.d.ts.map +1 -0
- package/dist/launch.js +221 -0
- package/dist/launch.js.map +1 -0
- package/dist/mcp.d.ts +44 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +12 -0
- package/dist/mcp.js.map +1 -0
- package/dist/metadata.d.ts +24 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/metadata.js +100 -0
- package/dist/metadata.js.map +1 -0
- package/dist/mmd-routes.d.ts +12 -0
- package/dist/mmd-routes.d.ts.map +1 -0
- package/dist/mmd-routes.js +146 -0
- package/dist/mmd-routes.js.map +1 -0
- package/dist/model-registry.d.ts +120 -0
- package/dist/model-registry.d.ts.map +1 -0
- package/dist/model-registry.js +77 -0
- package/dist/model-registry.js.map +1 -0
- package/dist/models.d.ts +16 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +93 -0
- package/dist/models.js.map +1 -0
- package/dist/opencode-log.d.ts +16 -0
- package/dist/opencode-log.d.ts.map +1 -0
- package/dist/opencode-log.js +163 -0
- package/dist/opencode-log.js.map +1 -0
- package/dist/paths.d.ts +3 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +29 -0
- package/dist/paths.js.map +1 -0
- package/dist/pi-models.d.ts +13 -0
- package/dist/pi-models.d.ts.map +1 -0
- package/dist/pi-models.js +36 -0
- package/dist/pi-models.js.map +1 -0
- package/dist/prompt-augmenter.d.ts +60 -0
- package/dist/prompt-augmenter.d.ts.map +1 -0
- package/dist/prompt-augmenter.js +26 -0
- package/dist/prompt-augmenter.js.map +1 -0
- package/dist/prompt-budget.d.ts +20 -0
- package/dist/prompt-budget.d.ts.map +1 -0
- package/dist/prompt-budget.js +226 -0
- package/dist/prompt-budget.js.map +1 -0
- package/dist/prompt-file.d.ts +7 -0
- package/dist/prompt-file.d.ts.map +1 -0
- package/dist/prompt-file.js +27 -0
- package/dist/prompt-file.js.map +1 -0
- package/dist/providers/aihubmix.d.ts +99 -0
- package/dist/providers/aihubmix.d.ts.map +1 -0
- package/dist/providers/aihubmix.js +239 -0
- package/dist/providers/aihubmix.js.map +1 -0
- package/dist/providers/anthropic-messages.d.ts +116 -0
- package/dist/providers/anthropic-messages.d.ts.map +1 -0
- package/dist/providers/anthropic-messages.js +313 -0
- package/dist/providers/anthropic-messages.js.map +1 -0
- package/dist/providers/azure-chat.d.ts +99 -0
- package/dist/providers/azure-chat.d.ts.map +1 -0
- package/dist/providers/azure-chat.js +164 -0
- package/dist/providers/azure-chat.js.map +1 -0
- package/dist/providers/connection-guard.d.ts +67 -0
- package/dist/providers/connection-guard.d.ts.map +1 -0
- package/dist/providers/connection-guard.js +211 -0
- package/dist/providers/connection-guard.js.map +1 -0
- package/dist/providers/elevenlabs.d.ts +28 -0
- package/dist/providers/elevenlabs.d.ts.map +1 -0
- package/dist/providers/elevenlabs.js +138 -0
- package/dist/providers/elevenlabs.js.map +1 -0
- package/dist/providers/google-messages.d.ts +108 -0
- package/dist/providers/google-messages.d.ts.map +1 -0
- package/dist/providers/google-messages.js +284 -0
- package/dist/providers/google-messages.js.map +1 -0
- package/dist/providers/google.d.ts +20 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/google.js +42 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/index.d.ts +39 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +39 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/model-catalog.d.ts +32 -0
- package/dist/providers/model-catalog.d.ts.map +1 -0
- package/dist/providers/model-catalog.js +394 -0
- package/dist/providers/model-catalog.js.map +1 -0
- package/dist/providers/oauth-callback-server.d.ts +35 -0
- package/dist/providers/oauth-callback-server.d.ts.map +1 -0
- package/dist/providers/oauth-callback-server.js +217 -0
- package/dist/providers/oauth-callback-server.js.map +1 -0
- package/dist/providers/oauth-credentials.d.ts +29 -0
- package/dist/providers/oauth-credentials.d.ts.map +1 -0
- package/dist/providers/oauth-credentials.js +70 -0
- package/dist/providers/oauth-credentials.js.map +1 -0
- package/dist/providers/oauth-provider.d.ts +95 -0
- package/dist/providers/oauth-provider.d.ts.map +1 -0
- package/dist/providers/oauth-provider.js +130 -0
- package/dist/providers/oauth-provider.js.map +1 -0
- package/dist/providers/oauth-tokens.d.ts +35 -0
- package/dist/providers/oauth-tokens.d.ts.map +1 -0
- package/dist/providers/oauth-tokens.js +136 -0
- package/dist/providers/oauth-tokens.js.map +1 -0
- package/dist/providers/ollama-chat.d.ts +106 -0
- package/dist/providers/ollama-chat.d.ts.map +1 -0
- package/dist/providers/ollama-chat.js +292 -0
- package/dist/providers/ollama-chat.js.map +1 -0
- package/dist/providers/openai-chat.d.ts +147 -0
- package/dist/providers/openai-chat.d.ts.map +1 -0
- package/dist/providers/openai-chat.js +302 -0
- package/dist/providers/openai-chat.js.map +1 -0
- package/dist/providers/pkce.d.ts +81 -0
- package/dist/providers/pkce.d.ts.map +1 -0
- package/dist/providers/pkce.js +176 -0
- package/dist/providers/pkce.js.map +1 -0
- package/dist/providers/sse-decode.d.ts +47 -0
- package/dist/providers/sse-decode.d.ts.map +1 -0
- package/dist/providers/sse-decode.js +109 -0
- package/dist/providers/sse-decode.js.map +1 -0
- package/dist/providers/token-params.d.ts +29 -0
- package/dist/providers/token-params.d.ts.map +1 -0
- package/dist/providers/token-params.js +41 -0
- package/dist/providers/token-params.js.map +1 -0
- package/dist/providers/turn-end-guard.d.ts +37 -0
- package/dist/providers/turn-end-guard.d.ts.map +1 -0
- package/dist/providers/turn-end-guard.js +42 -0
- package/dist/providers/turn-end-guard.js.map +1 -0
- package/dist/providers/types.d.ts +36 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +13 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/qoder-stream.d.ts +19 -0
- package/dist/qoder-stream.d.ts.map +1 -0
- package/dist/qoder-stream.js +167 -0
- package/dist/qoder-stream.js.map +1 -0
- package/dist/registry.d.ts +5 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +58 -0
- package/dist/registry.js.map +1 -0
- package/dist/resolution.d.ts +2 -0
- package/dist/resolution.d.ts.map +1 -0
- package/dist/resolution.js +19 -0
- package/dist/resolution.js.map +1 -0
- package/dist/role-marker-guard.d.ts +53 -0
- package/dist/role-marker-guard.d.ts.map +1 -0
- package/dist/role-marker-guard.js +280 -0
- package/dist/role-marker-guard.js.map +1 -0
- package/dist/telemetry-sink.d.ts +35 -0
- package/dist/telemetry-sink.d.ts.map +1 -0
- package/dist/telemetry-sink.js +5 -0
- package/dist/telemetry-sink.js.map +1 -0
- package/dist/terminal-launch.d.ts +11 -0
- package/dist/terminal-launch.d.ts.map +1 -0
- package/dist/terminal-launch.js +123 -0
- package/dist/terminal-launch.js.map +1 -0
- package/dist/types.d.ts +185 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module providers/anthropic-messages
|
|
3
|
+
*
|
|
4
|
+
* Anthropic Messages API wire adapter + tool-loop turn-runner. Built fresh
|
|
5
|
+
* against Anthropic's real, current public API docs (`platform.claude.com/
|
|
6
|
+
* docs/en/build-with-claude/streaming`, `.../api/messages-streaming`),
|
|
7
|
+
* following this repo's established "verify against real API docs, don't
|
|
8
|
+
* guess from memory" convention (see `packages/deploy/src/netlify.ts`'s
|
|
9
|
+
* doc comment for the precedent) — not a byte-for-byte OD port. Only the
|
|
10
|
+
* *shape* is modeled on OD's `apps/daemon/src/routes/chat.ts`'s
|
|
11
|
+
* `runAnthropicToolTurn` (per `ADS-memory/reports/proposals/
|
|
12
|
+
* PROP-http-route-packs-chat-model-proxy-2026-07-21.md`, which read that
|
|
13
|
+
* 2267-line file directly and extracted its mechanism, line numbers, and
|
|
14
|
+
* two confirmed bugs — this task did not have access to the OD source
|
|
15
|
+
* itself). Extends this package's existing `providers/` pattern
|
|
16
|
+
* (`model-catalog.ts`'s BYOK request/response handling,
|
|
17
|
+
* `connection-guard.ts`'s SSRF guard + secret redaction,
|
|
18
|
+
* `role-marker-guard.ts`'s contamination detector, and the
|
|
19
|
+
* "one file per vendor's stream-parsing shape" precedent
|
|
20
|
+
* `claude-stream.ts`/`copilot-stream.ts`/`qoder-stream.ts` already
|
|
21
|
+
* establish) rather than duplicating any of that inside `@jini-ai/http` — see
|
|
22
|
+
* the proposal's "real question: where does provider-specific wire-protocol
|
|
23
|
+
* logic belong?" section for the placement decision this file implements.
|
|
24
|
+
*
|
|
25
|
+
* **Scope for this pass:** the Anthropic Messages API only (native
|
|
26
|
+
* `x-api-key`/`anthropic-version` auth), text + tool-use content blocks,
|
|
27
|
+
* and the tool-execution loop. Extended thinking is deliberately out of
|
|
28
|
+
* scope — this adapter never sends a `thinking` request parameter, so
|
|
29
|
+
* Anthropic never emits `thinking`/`signature_delta` content blocks in the
|
|
30
|
+
* response (per the streaming docs: thinking blocks are opt-in), which
|
|
31
|
+
* means there is nothing to parse. A future pass can add it by following
|
|
32
|
+
* `claude-stream.ts#emitSafeText`'s precedent (thinking is passed through
|
|
33
|
+
* *unguarded* — the role-marker guard only polices the user-visible text
|
|
34
|
+
* channel, since thinking content is never re-serialized as a transcript
|
|
35
|
+
* turn boundary).
|
|
36
|
+
*
|
|
37
|
+
* **Two confirmed OD bugs fixed here, not carried forward** (both per the
|
|
38
|
+
* proposal doc above):
|
|
39
|
+
* 1. **Product-identity leak.** OD's OpenRouter branch hardcoded
|
|
40
|
+
* `'HTTP-Referer': 'https://opendesign.dev'` / `'X-Title': 'Open Design'`.
|
|
41
|
+
* OpenRouter itself is out of scope this pass, but the fix generalizes:
|
|
42
|
+
* `AnthropicTurnOptions.extraHeaders` is the *only* way any caller-
|
|
43
|
+
* identifying header reaches the outbound request, and it is always
|
|
44
|
+
* caller-supplied — nothing in this module ever hardcodes a product or
|
|
45
|
+
* gateway identity string.
|
|
46
|
+
* 2. **Duplicate `end`-event bug.** OD's `runAnthropicToolTurn` had two
|
|
47
|
+
* independent `sse.send('end', {})` call sites (role-marker-guard
|
|
48
|
+
* contamination, and normal turn completion) with no `ended`-flag guard,
|
|
49
|
+
* unlike its sibling non-tool-loop streamers in the same file. This
|
|
50
|
+
* module uses the shared `turn-end-guard.ts#createTurnEndGuard` — see
|
|
51
|
+
* that module's doc for why the guard is extracted into its own
|
|
52
|
+
* directly-tested unit rather than a local closure here — from every
|
|
53
|
+
* exit path (contamination, normal stop, max-tool-turns, upstream/
|
|
54
|
+
* network error), guaranteeing exactly one `end` event per call. See
|
|
55
|
+
* `__tests__/anthropic-messages.test.ts`'s "never emits end twice" case
|
|
56
|
+
* for the integration-level regression proof.
|
|
57
|
+
*/
|
|
58
|
+
import { createRoleMarkerGuard } from '../role-marker-guard.js';
|
|
59
|
+
import { redactSecrets, validateBaseUrl } from './connection-guard.js';
|
|
60
|
+
import { decodeSseStream } from './sse-decode.js';
|
|
61
|
+
import { createTurnEndGuard } from './turn-end-guard.js';
|
|
62
|
+
const DEFAULT_ANTHROPIC_BASE_URL = 'https://api.anthropic.com';
|
|
63
|
+
const DEFAULT_ANTHROPIC_VERSION = '2023-06-01';
|
|
64
|
+
const DEFAULT_MAX_TOOL_TURNS = 8;
|
|
65
|
+
function isRecord(value) {
|
|
66
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
67
|
+
}
|
|
68
|
+
function anthropicRequestUrl(baseUrl) {
|
|
69
|
+
const base = (baseUrl ?? DEFAULT_ANTHROPIC_BASE_URL).replace(/\/+$/, '');
|
|
70
|
+
return `${base}/v1/messages`;
|
|
71
|
+
}
|
|
72
|
+
function anthropicHeaders(options) {
|
|
73
|
+
return {
|
|
74
|
+
'content-type': 'application/json',
|
|
75
|
+
'x-api-key': options.apiKey,
|
|
76
|
+
'anthropic-version': options.apiVersion ?? DEFAULT_ANTHROPIC_VERSION,
|
|
77
|
+
...(options.extraHeaders ?? {}),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function anthropicRequestBody(options, messages) {
|
|
81
|
+
return {
|
|
82
|
+
model: options.model,
|
|
83
|
+
max_tokens: options.maxTokens,
|
|
84
|
+
stream: true,
|
|
85
|
+
messages,
|
|
86
|
+
...(options.system !== undefined ? { system: options.system } : {}),
|
|
87
|
+
...(options.temperature !== undefined ? { temperature: options.temperature } : {}),
|
|
88
|
+
...(options.tools && options.tools.length > 0 ? { tools: options.tools } : {}),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function extractAnthropicErrorDetail(rawText) {
|
|
92
|
+
try {
|
|
93
|
+
const parsed = JSON.parse(rawText);
|
|
94
|
+
if (isRecord(parsed) && isRecord(parsed.error) && typeof parsed.error.message === 'string') {
|
|
95
|
+
return parsed.error.message;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// Non-JSON error body — fall through to the raw text below.
|
|
100
|
+
}
|
|
101
|
+
return rawText.trim().slice(0, 500);
|
|
102
|
+
}
|
|
103
|
+
/** Runs exactly one Anthropic Messages API streaming request and reduces its SSE events into a single outcome. Calls `emitEnd` directly (and only) on contamination or a fatal request/stream error — the caller (`runAnthropicToolTurn`) is responsible for the normal-completion `emitEnd` call once the tool loop actually concludes, so the single `ended` flag stays the sole gate for every exit path. */
|
|
104
|
+
async function runSingleAnthropicRequest(options, messages, emitEnd) {
|
|
105
|
+
const { onEvent } = options;
|
|
106
|
+
const baseUrlCheck = validateBaseUrl(options.baseUrl ?? DEFAULT_ANTHROPIC_BASE_URL);
|
|
107
|
+
if (baseUrlCheck.error) {
|
|
108
|
+
onEvent({ type: 'error', message: baseUrlCheck.error });
|
|
109
|
+
emitEnd('error');
|
|
110
|
+
return { stopReason: null, toolCalls: [], text: '' };
|
|
111
|
+
}
|
|
112
|
+
let response;
|
|
113
|
+
try {
|
|
114
|
+
response = (await fetch(anthropicRequestUrl(options.baseUrl), {
|
|
115
|
+
method: 'POST',
|
|
116
|
+
headers: anthropicHeaders(options),
|
|
117
|
+
body: JSON.stringify(anthropicRequestBody(options, messages)),
|
|
118
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
123
|
+
onEvent({ type: 'error', message: redactSecrets(message, [options.apiKey]) });
|
|
124
|
+
emitEnd('error');
|
|
125
|
+
return { stopReason: null, toolCalls: [], text: '' };
|
|
126
|
+
}
|
|
127
|
+
if (!response.ok) {
|
|
128
|
+
const rawText = await response.text();
|
|
129
|
+
onEvent({
|
|
130
|
+
type: 'error',
|
|
131
|
+
message: redactSecrets(extractAnthropicErrorDetail(rawText), [options.apiKey]),
|
|
132
|
+
code: String(response.status),
|
|
133
|
+
});
|
|
134
|
+
emitEnd('error');
|
|
135
|
+
return { stopReason: null, toolCalls: [], text: '' };
|
|
136
|
+
}
|
|
137
|
+
if (!response.body) {
|
|
138
|
+
onEvent({ type: 'error', message: 'Anthropic response had no body' });
|
|
139
|
+
emitEnd('error');
|
|
140
|
+
return { stopReason: null, toolCalls: [], text: '' };
|
|
141
|
+
}
|
|
142
|
+
onEvent({ type: 'status', label: 'requesting' });
|
|
143
|
+
const guard = createRoleMarkerGuard('anthropic-turn');
|
|
144
|
+
const blocks = new Map();
|
|
145
|
+
const toolCalls = [];
|
|
146
|
+
let fullText = '';
|
|
147
|
+
let stopReason = null;
|
|
148
|
+
let usage = null;
|
|
149
|
+
for await (const frame of decodeSseStream(response.body)) {
|
|
150
|
+
// No `isEnded()` re-check at the top of this loop: every `emitEnd(...)` call site below is
|
|
151
|
+
// immediately followed by `break`, so `ended` can never be true when a new iteration starts
|
|
152
|
+
// — traced across all six call sites in this function (the four pre-loop early returns plus
|
|
153
|
+
// the two in-loop contamination/error branches below). Verified, not assumed; see
|
|
154
|
+
// `__tests__/anthropic-messages.test.ts`'s duplicate-end-event regression case.
|
|
155
|
+
let data;
|
|
156
|
+
try {
|
|
157
|
+
data = JSON.parse(frame.data);
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
continue; // tolerate a malformed/empty keep-alive frame
|
|
161
|
+
}
|
|
162
|
+
if (!isRecord(data))
|
|
163
|
+
continue;
|
|
164
|
+
const kind = typeof data.type === 'string' ? data.type : frame.event;
|
|
165
|
+
if (kind === 'content_block_start' && isRecord(data.content_block) && typeof data.index === 'number') {
|
|
166
|
+
const block = data.content_block;
|
|
167
|
+
if (block.type === 'text') {
|
|
168
|
+
blocks.set(data.index, { type: 'text', text: '', inputJson: '' });
|
|
169
|
+
}
|
|
170
|
+
else if (block.type === 'tool_use' && typeof block.id === 'string' && typeof block.name === 'string') {
|
|
171
|
+
blocks.set(data.index, { type: 'tool_use', text: '', toolId: block.id, toolName: block.name, inputJson: '' });
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
blocks.set(data.index, { type: 'other', text: '', inputJson: '' });
|
|
175
|
+
}
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (kind === 'content_block_delta' && isRecord(data.delta) && typeof data.index === 'number') {
|
|
179
|
+
const state = blocks.get(data.index);
|
|
180
|
+
const delta = data.delta;
|
|
181
|
+
if (delta.type === 'text_delta' && typeof delta.text === 'string') {
|
|
182
|
+
if (state)
|
|
183
|
+
state.text += delta.text;
|
|
184
|
+
// No `guard.contaminated` pre-check here: the only way it can become
|
|
185
|
+
// true is the `emitEnd('contaminated'); break;` a few lines below,
|
|
186
|
+
// which exits this loop immediately — a later text_delta in the same
|
|
187
|
+
// request can never reach this point already contaminated. (`feedText`
|
|
188
|
+
// itself is still safe to call unconditionally regardless — it
|
|
189
|
+
// early-returns `''` once contaminated, per its own doc.)
|
|
190
|
+
const safe = guard.feedText(delta.text);
|
|
191
|
+
if (safe.length > 0) {
|
|
192
|
+
fullText += safe;
|
|
193
|
+
onEvent({ type: 'text_delta', delta: safe });
|
|
194
|
+
}
|
|
195
|
+
if (guard.contaminated) {
|
|
196
|
+
const warn = guard.warningEvent();
|
|
197
|
+
if (warn)
|
|
198
|
+
onEvent(warn);
|
|
199
|
+
emitEnd('contaminated');
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
else if (delta.type === 'input_json_delta' && typeof delta.partial_json === 'string' && state) {
|
|
204
|
+
state.inputJson += delta.partial_json;
|
|
205
|
+
}
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (kind === 'content_block_stop' && typeof data.index === 'number') {
|
|
209
|
+
const state = blocks.get(data.index);
|
|
210
|
+
if (state?.type === 'tool_use' && state.toolId && state.toolName) {
|
|
211
|
+
let input = {};
|
|
212
|
+
if (state.inputJson.trim()) {
|
|
213
|
+
try {
|
|
214
|
+
input = JSON.parse(state.inputJson);
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
input = {};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const call = { id: state.toolId, name: state.toolName, input };
|
|
221
|
+
toolCalls.push(call);
|
|
222
|
+
onEvent({ type: 'tool_use', id: call.id, name: call.name, input: call.input });
|
|
223
|
+
}
|
|
224
|
+
blocks.delete(data.index);
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (kind === 'message_delta') {
|
|
228
|
+
if (isRecord(data.delta) && typeof data.delta.stop_reason === 'string') {
|
|
229
|
+
stopReason = data.delta.stop_reason;
|
|
230
|
+
}
|
|
231
|
+
if (isRecord(data.usage)) {
|
|
232
|
+
usage = data.usage;
|
|
233
|
+
onEvent({ type: 'usage', usage });
|
|
234
|
+
}
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (kind === 'error') {
|
|
238
|
+
const errorDetail = isRecord(data.error) && typeof data.error.message === 'string' ? data.error.message : 'upstream error';
|
|
239
|
+
const errorType = isRecord(data.error) && typeof data.error.type === 'string' ? data.error.type : undefined;
|
|
240
|
+
onEvent({ type: 'error', message: redactSecrets(errorDetail, [options.apiKey]), ...(errorType ? { code: errorType } : {}) });
|
|
241
|
+
emitEnd('error');
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
// `message_start`, `message_stop`, `ping`, and any future event type per
|
|
245
|
+
// Anthropic's own versioning policy ("your code should handle unknown
|
|
246
|
+
// event types gracefully") — nothing to do.
|
|
247
|
+
}
|
|
248
|
+
return { stopReason, toolCalls, text: fullText };
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Runs a full Anthropic Messages API turn, including the tool-execution
|
|
252
|
+
* loop when `options.executeTool` is supplied and the model requests tool
|
|
253
|
+
* use. Emits a generic event stream via `options.onEvent` — a caller (e.g.
|
|
254
|
+
* `@jini-ai/http`'s `model-proxy.ts`) adapts those events onto an outbound SSE
|
|
255
|
+
* channel; this module has no knowledge of HTTP/Express.
|
|
256
|
+
*
|
|
257
|
+
* Guarantees exactly one `{type: 'end'}` event per call, regardless of which
|
|
258
|
+
* of the four exit paths (contamination, normal stop, max-tool-turns,
|
|
259
|
+
* request/stream error) triggers it — the fix for OD's confirmed duplicate-
|
|
260
|
+
* `end`-event bug (see module doc).
|
|
261
|
+
*/
|
|
262
|
+
export async function runAnthropicToolTurn(options) {
|
|
263
|
+
const maxToolTurns = options.maxToolTurns ?? DEFAULT_MAX_TOOL_TURNS;
|
|
264
|
+
const endGuard = createTurnEndGuard(options.onEvent, (reason) => ({ type: 'end', reason }));
|
|
265
|
+
const emitEnd = endGuard.emitEnd;
|
|
266
|
+
let messages = options.messages.slice();
|
|
267
|
+
let toolTurns = 0;
|
|
268
|
+
let lastStopReason = null;
|
|
269
|
+
while (true) {
|
|
270
|
+
const outcome = await runSingleAnthropicRequest(options, messages, emitEnd);
|
|
271
|
+
lastStopReason = outcome.stopReason;
|
|
272
|
+
if (endGuard.hasEnded())
|
|
273
|
+
break;
|
|
274
|
+
if (outcome.stopReason !== 'tool_use' || outcome.toolCalls.length === 0) {
|
|
275
|
+
emitEnd('stop');
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
if (!options.executeTool) {
|
|
279
|
+
// Pending tool calls were already emitted as `tool_use` events above;
|
|
280
|
+
// with no executor to run them, the turn ends here rather than
|
|
281
|
+
// silently retrying forever.
|
|
282
|
+
emitEnd('stop');
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
if (toolTurns >= maxToolTurns) {
|
|
286
|
+
emitEnd('max_tool_turns');
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
toolTurns += 1;
|
|
290
|
+
const assistantContent = [
|
|
291
|
+
...(outcome.text ? [{ type: 'text', text: outcome.text }] : []),
|
|
292
|
+
...outcome.toolCalls.map((call) => ({ type: 'tool_use', id: call.id, name: call.name, input: call.input })),
|
|
293
|
+
];
|
|
294
|
+
const toolResultBlocks = [];
|
|
295
|
+
for (const call of outcome.toolCalls) {
|
|
296
|
+
const result = await options.executeTool(call);
|
|
297
|
+
options.onEvent({ type: 'tool_result', toolUseId: call.id, content: result.content, isError: result.isError ?? false });
|
|
298
|
+
toolResultBlocks.push({
|
|
299
|
+
type: 'tool_result',
|
|
300
|
+
tool_use_id: call.id,
|
|
301
|
+
content: result.content,
|
|
302
|
+
...(result.isError !== undefined ? { is_error: result.isError } : {}),
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
messages = [
|
|
306
|
+
...messages,
|
|
307
|
+
{ role: 'assistant', content: assistantContent },
|
|
308
|
+
{ role: 'user', content: toolResultBlocks },
|
|
309
|
+
];
|
|
310
|
+
}
|
|
311
|
+
return { stopReason: lastStopReason, toolTurns };
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=anthropic-messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic-messages.js","sourceRoot":"","sources":["../../src/providers/anthropic-messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAsB,MAAM,qBAAqB,CAAC;AAiG7E,MAAM,0BAA0B,GAAG,2BAA2B,CAAC;AAC/D,MAAM,yBAAyB,GAAG,YAAY,CAAC;AAC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,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC;YACxH,gBAAgB,CAAC,IAAI,CAAC;gBACpB,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,IAAI,CAAC,EAAE;gBACpB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACtE,CAAC,CAAC;QACL,CAAC;QAED,QAAQ,GAAG;YACT,GAAG,QAAQ;YACX,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE;YAChD,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE;SAC5C,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type TurnEndReason } from './turn-end-guard.js';
|
|
2
|
+
export interface AzureFunctionToolDef {
|
|
3
|
+
readonly type: 'function';
|
|
4
|
+
readonly function: {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly description?: string;
|
|
7
|
+
readonly parameters: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface AzureToolCallParam {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly type: 'function';
|
|
13
|
+
readonly function: {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly arguments: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface AzureMessageParam {
|
|
19
|
+
readonly role: 'system' | 'user' | 'assistant' | 'tool';
|
|
20
|
+
readonly content: string | null;
|
|
21
|
+
readonly tool_calls?: readonly AzureToolCallParam[];
|
|
22
|
+
readonly tool_call_id?: string;
|
|
23
|
+
readonly name?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface AzureToolCall {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly input: unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface AzureToolResult {
|
|
31
|
+
readonly content: string;
|
|
32
|
+
}
|
|
33
|
+
/** Host-owned tool execution — same "the collaborator is always supplied" convention as `anthropic-messages.ts#AnthropicToolExecutor`. */
|
|
34
|
+
export type AzureToolExecutor = (call: AzureToolCall) => Promise<AzureToolResult>;
|
|
35
|
+
export type AzureTurnEndReason = TurnEndReason;
|
|
36
|
+
export type AzureTurnEvent = {
|
|
37
|
+
readonly type: 'status';
|
|
38
|
+
readonly label: string;
|
|
39
|
+
} | {
|
|
40
|
+
readonly type: 'text_delta';
|
|
41
|
+
readonly delta: string;
|
|
42
|
+
} | {
|
|
43
|
+
readonly type: 'tool_use';
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly input: unknown;
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: 'tool_result';
|
|
49
|
+
readonly toolUseId: string;
|
|
50
|
+
readonly content: string;
|
|
51
|
+
readonly isError: boolean;
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: 'usage';
|
|
54
|
+
readonly usage: Record<string, unknown> | null;
|
|
55
|
+
} | {
|
|
56
|
+
readonly type: 'fabricated_role_marker';
|
|
57
|
+
readonly marker: string;
|
|
58
|
+
readonly messageId: string;
|
|
59
|
+
} | {
|
|
60
|
+
readonly type: 'error';
|
|
61
|
+
readonly message: string;
|
|
62
|
+
readonly code?: string;
|
|
63
|
+
} | {
|
|
64
|
+
readonly type: 'end';
|
|
65
|
+
readonly reason: AzureTurnEndReason;
|
|
66
|
+
};
|
|
67
|
+
export interface AzureTurnOptions {
|
|
68
|
+
readonly apiKey: string;
|
|
69
|
+
/** Required — every Azure OpenAI resource has its own endpoint, so there is no sane global default (see module doc). */
|
|
70
|
+
readonly baseUrl: string;
|
|
71
|
+
/** The Azure OpenAI *deployment name* (not a raw model id). */
|
|
72
|
+
readonly model: string;
|
|
73
|
+
/** Defaults to `'2024-10-21'` — see module doc for provenance. */
|
|
74
|
+
readonly apiVersion?: string;
|
|
75
|
+
readonly messages: readonly AzureMessageParam[];
|
|
76
|
+
readonly tools?: readonly AzureFunctionToolDef[];
|
|
77
|
+
readonly temperature?: number;
|
|
78
|
+
/** Defaults to 8192 when omitted or not a positive number — a token limit is always sent, matching OD's real `azure` proxy handler (see module doc). */
|
|
79
|
+
readonly maxTokens?: number;
|
|
80
|
+
/** Same bound and rationale as `AnthropicTurnOptions.maxToolTurns`. Defaults to 8. */
|
|
81
|
+
readonly maxToolTurns?: number;
|
|
82
|
+
readonly executeTool?: AzureToolExecutor;
|
|
83
|
+
readonly onEvent: (event: AzureTurnEvent) => void;
|
|
84
|
+
readonly signal?: AbortSignal;
|
|
85
|
+
/** Caller-supplied extra headers — see `anthropic-messages.ts#AnthropicTurnOptions.extraHeaders`'s doc for why this exists and what it fixes. */
|
|
86
|
+
readonly extraHeaders?: Record<string, string>;
|
|
87
|
+
}
|
|
88
|
+
export interface AzureTurnResult {
|
|
89
|
+
readonly finishReason: string | null;
|
|
90
|
+
readonly toolTurns: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Runs a full Azure OpenAI Chat Completions turn, including the
|
|
94
|
+
* tool-execution loop when `options.executeTool` is supplied and the model
|
|
95
|
+
* requests a function call. See `anthropic-messages.ts#runAnthropicToolTurn`'s
|
|
96
|
+
* doc for the shared event-stream/`ended`-flag contract this mirrors exactly.
|
|
97
|
+
*/
|
|
98
|
+
export declare function runAzureToolTurn(options: AzureTurnOptions): Promise<AzureTurnResult>;
|
|
99
|
+
//# sourceMappingURL=azure-chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azure-chat.d.ts","sourceRoot":"","sources":["../../src/providers/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
+
* Sibling of `anthropic-messages.ts`/`openai-chat.ts` — see those modules'
|
|
6
|
+
* headers for the shared design rationale. Azure OpenAI's chat-completions
|
|
7
|
+
* JSON request/response body is byte-identical to plain OpenAI's (same
|
|
8
|
+
* `messages`/`tools`/streaming-delta shape) — only the URL and the auth
|
|
9
|
+
* header differ — so this module reuses `openai-chat.ts`'s extracted
|
|
10
|
+
* `runOpenAiCompatibleRequest` SSE-reduction loop rather than duplicating
|
|
11
|
+
* it; see that function's doc for why it was pulled out.
|
|
12
|
+
*
|
|
13
|
+
* **URL**: `{baseUrl}/openai/deployments/{model}/chat/completions
|
|
14
|
+
* ?api-version={apiVersion}` — `model` here is the Azure *deployment name*,
|
|
15
|
+
* not a model id (Azure OpenAI resources map a deployment name to a
|
|
16
|
+
* specific model version at resource-creation time). `apiVersion` defaults
|
|
17
|
+
* to `'2024-10-21'`, the default this repo's real OD predecessor used for
|
|
18
|
+
* its own azure chat-completions proxy route (`apps/daemon/src/routes/
|
|
19
|
+
* chat.ts`'s `[proxy:azure]` handler, confirmed by reading that file
|
|
20
|
+
* directly in a sibling checkout — see `source-map.md`'s dated entry).
|
|
21
|
+
* That source additionally branches on whether `baseUrl` already contains
|
|
22
|
+
* a versioned `/openai/v1` path (a newer Azure OpenAI API preview); that
|
|
23
|
+
* branch is deliberately not carried forward here — this adapter targets
|
|
24
|
+
* the one documented, stable URL/body shape per this task's approved scope
|
|
25
|
+
* ("byte-identical to OpenAI, only URL/auth differ"). Its 400-retry
|
|
26
|
+
* behavior IS carried forward (see "Token-limit fix" below) — round-4
|
|
27
|
+
* external audit (`AUD-R4-001`) found the first port had dropped it,
|
|
28
|
+
* which fails every request against a GPT-5/o-series Azure deployment.
|
|
29
|
+
*
|
|
30
|
+
* **Auth**: `api-key: {apiKey}` header — NOT `Authorization: Bearer`,
|
|
31
|
+
* Azure OpenAI's own convention (also confirmed against the same OD
|
|
32
|
+
* source above).
|
|
33
|
+
*
|
|
34
|
+
* **No default `baseUrl`**: every Azure OpenAI resource has its own
|
|
35
|
+
* endpoint (`https://{resource}.openai.azure.com`), so unlike Anthropic/
|
|
36
|
+
* OpenAI/Google/Ollama, `baseUrl` is a required field on
|
|
37
|
+
* {@link AzureTurnOptions}, and `apiVersion` is validated as
|
|
38
|
+
* non-empty-if-supplied by the caller (`@jini-ai/http`'s
|
|
39
|
+
* `parseAzureProxyRequest` — see that module).
|
|
40
|
+
*
|
|
41
|
+
* **Token-limit fix**: an earlier version of this module sent no token-limit
|
|
42
|
+
* field at all — a live comparison against a running Open Design daemon
|
|
43
|
+
* found OD's real `azure` proxy handler always sends `max_tokens` (defaulting
|
|
44
|
+
* to 8192), unconditionally the legacy field name — never the newer
|
|
45
|
+
* `max_completion_tokens` `openai-chat.ts` picks for GPT-5/o-series models,
|
|
46
|
+
* since Azure deployment names are caller-defined strings, not necessarily
|
|
47
|
+
* matching OpenAI's own model-naming scheme. Wired via
|
|
48
|
+
* `./token-params.js#buildLegacyMaxTokensParam`. Because deployment names
|
|
49
|
+
* are opaque, a legacy-field request can still be rejected by a
|
|
50
|
+
* GPT-5/o-series deployment with a 400 — OD's real handler retries exactly
|
|
51
|
+
* once with `max_completion_tokens` on that specific error
|
|
52
|
+
* (`isUnsupportedMaxTokensError`); this module does the same via
|
|
53
|
+
* `runOpenAiCompatibleRequest`'s `retryableBody` hook.
|
|
54
|
+
*/
|
|
55
|
+
import { defaultDnsLookup, validateBaseUrlResolved } from './connection-guard.js';
|
|
56
|
+
import { runOpenAiCompatibleRequest } from './openai-chat.js';
|
|
57
|
+
import { buildLegacyMaxTokensParam, buildMaxCompletionTokensParam, isUnsupportedMaxTokensError } from './token-params.js';
|
|
58
|
+
import { createTurnEndGuard } from './turn-end-guard.js';
|
|
59
|
+
const DEFAULT_AZURE_API_VERSION = '2024-10-21';
|
|
60
|
+
const DEFAULT_MAX_TOOL_TURNS = 8;
|
|
61
|
+
/** Matches OD's real azure handler's default when `maxTokens` isn't supplied — see module doc. */
|
|
62
|
+
const DEFAULT_AZURE_MAX_TOKENS = 8192;
|
|
63
|
+
function azureRequestUrl(baseUrl, model, apiVersion) {
|
|
64
|
+
const base = baseUrl.replace(/\/+$/, '');
|
|
65
|
+
const version = apiVersion && apiVersion.trim() ? apiVersion.trim() : DEFAULT_AZURE_API_VERSION;
|
|
66
|
+
return `${base}/openai/deployments/${encodeURIComponent(model)}/chat/completions?api-version=${encodeURIComponent(version)}`;
|
|
67
|
+
}
|
|
68
|
+
function azureHeaders(options) {
|
|
69
|
+
return {
|
|
70
|
+
'content-type': 'application/json',
|
|
71
|
+
'api-key': options.apiKey,
|
|
72
|
+
...(options.extraHeaders ?? {}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function effectiveAzureMaxTokens(options) {
|
|
76
|
+
return typeof options.maxTokens === 'number' && options.maxTokens > 0 ? options.maxTokens : DEFAULT_AZURE_MAX_TOKENS;
|
|
77
|
+
}
|
|
78
|
+
/** `tokenParam` is injected so the 400-retry path (see module doc) can rebuild an otherwise-identical body with `max_completion_tokens` instead of `max_tokens`. */
|
|
79
|
+
function azureRequestBody(options, messages, tokenParam) {
|
|
80
|
+
return {
|
|
81
|
+
stream: true,
|
|
82
|
+
stream_options: { include_usage: true },
|
|
83
|
+
messages,
|
|
84
|
+
...tokenParam,
|
|
85
|
+
...(options.temperature !== undefined ? { temperature: options.temperature } : {}),
|
|
86
|
+
...(options.tools && options.tools.length > 0 ? { tools: options.tools } : {}),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** Validates `options.baseUrl`, then delegates to `openai-chat.ts#runOpenAiCompatibleRequest` with Azure's own URL/header/body builders. */
|
|
90
|
+
async function runSingleAzureRequest(options, messages, emitEnd, hasEnded) {
|
|
91
|
+
const baseUrlCheck = await validateBaseUrlResolved(options.baseUrl, defaultDnsLookup);
|
|
92
|
+
if (baseUrlCheck.error) {
|
|
93
|
+
options.onEvent({ type: 'error', message: baseUrlCheck.error });
|
|
94
|
+
emitEnd('error');
|
|
95
|
+
return { finishReason: null, toolCalls: [], text: '' };
|
|
96
|
+
}
|
|
97
|
+
const maxTokens = effectiveAzureMaxTokens(options);
|
|
98
|
+
return runOpenAiCompatibleRequest({
|
|
99
|
+
url: azureRequestUrl(options.baseUrl, options.model, options.apiVersion),
|
|
100
|
+
headers: azureHeaders(options),
|
|
101
|
+
body: azureRequestBody(options, messages, buildLegacyMaxTokensParam(maxTokens)),
|
|
102
|
+
retryableBody: (status, rawErrorText) => status === 400 && isUnsupportedMaxTokensError(rawErrorText)
|
|
103
|
+
? azureRequestBody(options, messages, buildMaxCompletionTokensParam(maxTokens))
|
|
104
|
+
: null,
|
|
105
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
106
|
+
redactSecretsList: [options.apiKey],
|
|
107
|
+
guardMessageId: 'azure-turn',
|
|
108
|
+
providerLabel: 'Azure OpenAI',
|
|
109
|
+
onEvent: options.onEvent,
|
|
110
|
+
emitEnd,
|
|
111
|
+
hasEnded,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Runs a full Azure OpenAI Chat Completions turn, including the
|
|
116
|
+
* tool-execution loop when `options.executeTool` is supplied and the model
|
|
117
|
+
* requests a function call. See `anthropic-messages.ts#runAnthropicToolTurn`'s
|
|
118
|
+
* doc for the shared event-stream/`ended`-flag contract this mirrors exactly.
|
|
119
|
+
*/
|
|
120
|
+
export async function runAzureToolTurn(options) {
|
|
121
|
+
const maxToolTurns = options.maxToolTurns ?? DEFAULT_MAX_TOOL_TURNS;
|
|
122
|
+
const endGuard = createTurnEndGuard(options.onEvent, (reason) => ({ type: 'end', reason }));
|
|
123
|
+
const emitEnd = endGuard.emitEnd;
|
|
124
|
+
let messages = options.messages.slice();
|
|
125
|
+
let toolTurns = 0;
|
|
126
|
+
let lastFinishReason = null;
|
|
127
|
+
while (true) {
|
|
128
|
+
const outcome = await runSingleAzureRequest(options, messages, emitEnd, endGuard.hasEnded);
|
|
129
|
+
lastFinishReason = outcome.finishReason;
|
|
130
|
+
if (endGuard.hasEnded())
|
|
131
|
+
break;
|
|
132
|
+
if (outcome.finishReason !== 'tool_calls' || outcome.toolCalls.length === 0) {
|
|
133
|
+
emitEnd('stop');
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
if (!options.executeTool) {
|
|
137
|
+
emitEnd('stop');
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (toolTurns >= maxToolTurns) {
|
|
141
|
+
emitEnd('max_tool_turns');
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
toolTurns += 1;
|
|
145
|
+
const assistantToolCalls = outcome.toolCalls.map((call) => ({
|
|
146
|
+
id: call.id,
|
|
147
|
+
type: 'function',
|
|
148
|
+
function: { name: call.name, arguments: JSON.stringify(call.input) },
|
|
149
|
+
}));
|
|
150
|
+
const toolResultMessages = [];
|
|
151
|
+
for (const call of outcome.toolCalls) {
|
|
152
|
+
const result = await options.executeTool(call);
|
|
153
|
+
options.onEvent({ type: 'tool_result', toolUseId: call.id, content: result.content, isError: false });
|
|
154
|
+
toolResultMessages.push({ role: 'tool', content: result.content, tool_call_id: call.id });
|
|
155
|
+
}
|
|
156
|
+
messages = [
|
|
157
|
+
...messages,
|
|
158
|
+
{ role: 'assistant', content: outcome.text || null, tool_calls: assistantToolCalls },
|
|
159
|
+
...toolResultMessages,
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
return { finishReason: lastFinishReason, toolTurns };
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=azure-chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azure-chat.js","sourceRoot":"","sources":["../../src/providers/azure-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAu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