@jini-ai/agent-runtime 0.7.2 → 0.7.3-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -3
- package/README.md +1 -0
- package/dist/acp-model-probe.d.ts +2 -3
- package/dist/acp-model-probe.js +1 -1
- package/dist/agent-protocol/acp/account-failure.d.ts +3 -1
- package/dist/agent-protocol/acp/account-failure.js +1 -1
- package/dist/agent-protocol/acp/constants.d.ts +6 -1
- package/dist/agent-protocol/acp/constants.js +7 -0
- package/dist/agent-protocol/acp/index.d.ts +2 -1
- package/dist/agent-protocol/acp/index.js +2 -1
- package/dist/agent-protocol/acp/json.d.ts +26 -7
- package/dist/agent-protocol/acp/json.js +11 -11
- package/dist/agent-protocol/acp/models.d.ts +26 -6
- package/dist/agent-protocol/acp/models.js +161 -128
- package/dist/agent-protocol/acp/rpc.d.ts +37 -9
- package/dist/agent-protocol/acp/rpc.js +19 -16
- package/dist/agent-protocol/acp/session-params.d.ts +4 -1
- package/dist/agent-protocol/acp/session-params.js +1 -1
- package/dist/agent-protocol/acp/session-permission.d.ts +13 -0
- package/dist/agent-protocol/acp/session-permission.js +110 -0
- package/dist/agent-protocol/acp/session-results.d.ts +61 -0
- package/dist/agent-protocol/acp/session-results.js +231 -0
- package/dist/agent-protocol/acp/session-run.d.ts +92 -0
- package/dist/agent-protocol/acp/session-run.js +555 -0
- package/dist/agent-protocol/acp/session-state.d.ts +9 -0
- package/dist/agent-protocol/acp/session-state.js +29 -0
- package/dist/agent-protocol/acp/session-text-updates.d.ts +56 -0
- package/dist/agent-protocol/acp/session-text-updates.js +119 -0
- package/dist/agent-protocol/acp/session-tool-updates.d.ts +21 -0
- package/dist/agent-protocol/acp/session-tool-updates.js +90 -0
- package/dist/agent-protocol/acp/session-types.d.ts +166 -0
- package/dist/agent-protocol/acp/session-types.js +4 -0
- package/dist/agent-protocol/acp/session.d.ts +4 -280
- package/dist/agent-protocol/acp/session.js +65 -998
- package/dist/agent-protocol/acp/text-suppression.d.ts +5 -1
- package/dist/agent-protocol/acp/text-suppression.js +1 -1
- package/dist/agent-protocol/acp/updates.d.ts +43 -12
- package/dist/agent-protocol/acp/updates.js +34 -34
- package/dist/agent-protocol/core/json-line-stream.d.ts +133 -36
- package/dist/agent-protocol/core/json-line-stream.js +62 -62
- package/dist/agent-protocol/pi-rpc/events.d.ts +14 -4
- package/dist/agent-protocol/pi-rpc/events.js +14 -14
- package/dist/agent-protocol/pi-rpc/internal.d.ts +9 -3
- package/dist/agent-protocol/pi-rpc/internal.js +3 -3
- package/dist/agent-protocol/pi-rpc/models.d.ts +3 -17
- package/dist/agent-protocol/pi-rpc/models.js +1 -45
- package/dist/agent-protocol/pi-rpc/session.d.ts +36 -12
- package/dist/agent-protocol/pi-rpc/session.js +134 -122
- package/dist/amr-model-cache.d.ts +1 -1
- package/dist/anthropic-live-models.d.ts +8 -3
- package/dist/anthropic-live-models.js +0 -0
- package/dist/auth-common.d.ts +2 -0
- package/dist/auth-common.js +2 -0
- package/dist/auth.d.ts +7 -34
- package/dist/auth.js +25 -139
- package/dist/capabilities.d.ts +1 -1
- package/dist/claude-code-models.d.ts +13 -5
- package/dist/claude-code-models.js +12 -10
- package/dist/claude-filesystem-policy.d.ts +1 -1
- package/dist/claude-stream-frames.d.ts +125 -0
- package/dist/claude-stream-frames.js +327 -0
- package/dist/claude-stream-handler.d.ts +19 -0
- package/dist/claude-stream-handler.js +480 -0
- package/dist/claude-stream.d.ts +3 -72
- package/dist/claude-stream.js +2 -801
- package/dist/core/model-discovery-shared.d.ts +14 -8
- package/dist/core/model-discovery-shared.js +6 -9
- package/dist/core/omit-keys.d.ts +4 -1
- package/dist/core/omit-keys.js +1 -1
- package/dist/defs/aider/executable.d.ts +2 -0
- package/dist/defs/aider/executable.js +2 -0
- package/dist/defs/aider/model-discovery.d.ts +3 -0
- package/dist/defs/aider/model-discovery.js +6 -0
- package/dist/defs/aider.d.ts +10 -10
- package/dist/defs/amp/index.d.ts +35 -0
- package/dist/defs/amp/index.js +75 -0
- package/dist/defs/amp.d.ts +1 -34
- package/dist/defs/amp.js +1 -74
- package/dist/defs/amr/executable-resolution.d.ts +7 -0
- package/dist/defs/amr/executable-resolution.js +50 -0
- package/dist/defs/amr/executable.d.ts +2 -0
- package/dist/defs/amr/executable.js +2 -0
- package/dist/defs/amr/index.d.ts +69 -0
- package/dist/defs/amr/index.js +279 -0
- package/dist/defs/amr/model-discovery.d.ts +3 -0
- package/dist/defs/amr/model-discovery.js +4 -0
- package/dist/defs/amr.d.ts +1 -68
- package/dist/defs/amr.js +1 -291
- package/dist/defs/antigravity/auth.d.ts +14 -0
- package/dist/defs/antigravity/auth.js +47 -0
- package/dist/defs/antigravity/index.d.ts +9 -9
- package/dist/defs/antigravity/index.js +3 -3
- package/dist/defs/antigravity/model-discovery.d.ts +3 -0
- package/dist/defs/antigravity/model-discovery.js +5 -0
- package/dist/defs/auggie/executable.d.ts +2 -0
- package/dist/defs/auggie/executable.js +2 -0
- package/dist/defs/auggie.d.ts +13 -13
- package/dist/defs/auggie.js +2 -9
- package/dist/defs/claude/auth.d.ts +15 -0
- package/dist/defs/claude/auth.js +47 -0
- package/dist/defs/claude/executable.d.ts +2 -0
- package/dist/defs/claude/executable.js +2 -0
- package/dist/defs/claude/model-discovery.d.ts +3 -0
- package/dist/defs/claude/model-discovery.js +20 -0
- package/dist/defs/claude-compatible-args.d.ts +10 -6
- package/dist/defs/claude-compatible-args.js +5 -5
- package/dist/defs/claude.d.ts +11 -11
- package/dist/defs/claude.js +5 -4
- package/dist/defs/cline/executable.d.ts +2 -0
- package/dist/defs/cline/executable.js +2 -0
- package/dist/defs/cline.d.ts +13 -13
- package/dist/defs/cline.js +2 -9
- package/dist/defs/codebuddy/executable.d.ts +2 -0
- package/dist/defs/codebuddy/executable.js +2 -0
- package/dist/defs/codebuddy/index.d.ts +48 -0
- package/dist/defs/codebuddy/index.js +121 -0
- package/dist/defs/codebuddy/model-discovery.d.ts +3 -0
- package/dist/defs/codebuddy/model-discovery.js +5 -0
- package/dist/defs/codebuddy.d.ts +1 -47
- package/dist/defs/codebuddy.js +1 -120
- package/dist/defs/codex/auth.d.ts +4 -0
- package/dist/defs/codex/auth.js +2 -0
- package/dist/defs/codex/event-stream.d.ts +10 -0
- package/dist/defs/codex/event-stream.js +353 -0
- package/dist/defs/codex/executable-resolution.d.ts +7 -0
- package/dist/defs/codex/executable-resolution.js +37 -0
- package/dist/defs/codex/executable.d.ts +2 -0
- package/dist/defs/codex/executable.js +2 -0
- package/dist/defs/codex/launch.d.ts +3 -0
- package/dist/defs/codex/launch.js +155 -0
- package/dist/defs/codex/model-discovery.d.ts +3 -0
- package/dist/defs/codex/model-discovery.js +11 -0
- package/dist/defs/codex/options.d.ts +11 -0
- package/dist/defs/codex/options.js +5 -0
- package/dist/defs/codex.d.ts +18 -11
- package/dist/defs/codex.js +32 -29
- package/dist/defs/crush/executable.d.ts +2 -0
- package/dist/defs/crush/executable.js +2 -0
- package/dist/defs/crush/model-discovery.d.ts +3 -0
- package/dist/defs/crush/model-discovery.js +6 -0
- package/dist/defs/crush.d.ts +10 -10
- package/dist/defs/cursor-agent/auth.d.ts +13 -0
- package/dist/defs/cursor-agent/auth.js +22 -0
- package/dist/defs/cursor-agent/event-stream.d.ts +8 -0
- package/dist/defs/cursor-agent/event-stream.js +104 -0
- package/dist/defs/cursor-agent/executable.d.ts +2 -0
- package/dist/defs/cursor-agent/executable.js +2 -0
- package/dist/defs/cursor-agent/model-discovery.d.ts +3 -0
- package/dist/defs/cursor-agent/model-discovery.js +5 -0
- package/dist/defs/cursor-agent.d.ts +11 -13
- package/dist/defs/cursor-agent.js +1 -1
- package/dist/defs/deepseek/auth.d.ts +13 -0
- package/dist/defs/deepseek/auth.js +18 -0
- package/dist/defs/deepseek/executable.d.ts +2 -0
- package/dist/defs/deepseek/executable.js +2 -0
- package/dist/defs/deepseek/model-discovery.d.ts +3 -0
- package/dist/defs/deepseek/model-discovery.js +5 -0
- package/dist/defs/deepseek.d.ts +10 -10
- package/dist/defs/devin/executable.d.ts +2 -0
- package/dist/defs/devin/executable.js +2 -0
- package/dist/defs/devin.d.ts +15 -15
- package/dist/defs/devin.js +3 -10
- package/dist/defs/droid/executable.d.ts +2 -0
- package/dist/defs/droid/executable.js +2 -0
- package/dist/defs/droid/model-discovery.d.ts +3 -0
- package/dist/defs/droid/model-discovery.js +5 -0
- package/dist/defs/droid.d.ts +10 -10
- package/dist/defs/gemini/event-stream.d.ts +14 -0
- package/dist/defs/gemini/event-stream.js +193 -0
- package/dist/defs/goose/executable.d.ts +2 -0
- package/dist/defs/goose/executable.js +2 -0
- package/dist/defs/goose.d.ts +13 -13
- package/dist/defs/goose.js +2 -9
- package/dist/defs/grok-build/model-discovery.d.ts +3 -0
- package/dist/defs/grok-build/model-discovery.js +5 -0
- package/dist/defs/grok-build.d.ts +10 -10
- package/dist/defs/hermes/executable.d.ts +2 -0
- package/dist/defs/hermes/executable.js +2 -0
- package/dist/defs/hermes/index.d.ts +34 -0
- package/dist/defs/hermes/index.js +57 -0
- package/dist/defs/hermes.d.ts +1 -33
- package/dist/defs/hermes.js +1 -56
- package/dist/defs/index.d.ts +1 -0
- package/dist/defs/index.js +1 -0
- package/dist/defs/kilo/executable.d.ts +2 -0
- package/dist/defs/kilo/executable.js +2 -0
- package/dist/defs/kilo.d.ts +13 -13
- package/dist/defs/kilo.js +2 -9
- package/dist/defs/kimi/event-stream.d.ts +3 -0
- package/dist/defs/kimi/event-stream.js +46 -0
- package/dist/defs/kimi/executable.d.ts +2 -0
- package/dist/defs/kimi/executable.js +2 -0
- package/dist/defs/kimi.d.ts +13 -13
- package/dist/defs/kimi.js +2 -9
- package/dist/defs/kiro/executable.d.ts +2 -0
- package/dist/defs/kiro/executable.js +2 -0
- package/dist/defs/kiro.d.ts +13 -13
- package/dist/defs/kiro.js +2 -9
- package/dist/defs/mimo/executable.d.ts +2 -0
- package/dist/defs/mimo/executable.js +2 -0
- package/dist/defs/mimo/model-discovery.d.ts +3 -0
- package/dist/defs/mimo/model-discovery.js +7 -0
- package/dist/defs/mimo.d.ts +10 -10
- package/dist/defs/opencode/event-stream.d.ts +8 -0
- package/dist/defs/opencode/event-stream.js +108 -0
- package/dist/defs/opencode/executable.d.ts +2 -0
- package/dist/defs/opencode/executable.js +2 -0
- package/dist/defs/opencode/model-discovery.d.ts +4 -0
- package/dist/defs/opencode/model-discovery.js +14 -0
- package/dist/defs/opencode-acp.d.ts +42 -0
- package/dist/defs/opencode-acp.js +23 -0
- package/dist/defs/opencode.d.ts +9 -9
- package/dist/defs/pi/executable.d.ts +2 -0
- package/dist/defs/pi/executable.js +2 -0
- package/dist/defs/pi/model-discovery.d.ts +4 -0
- package/dist/defs/pi/model-discovery.js +16 -0
- package/dist/defs/pi/options.d.ts +11 -0
- package/dist/defs/pi/options.js +5 -0
- package/dist/defs/pi.d.ts +10 -10
- package/dist/defs/qoder/executable.d.ts +2 -0
- package/dist/defs/qoder/executable.js +2 -0
- package/dist/defs/qoder/model-discovery.d.ts +3 -0
- package/dist/defs/qoder/model-discovery.js +7 -0
- package/dist/defs/qoder.d.ts +9 -9
- package/dist/defs/qwen/executable.d.ts +2 -0
- package/dist/defs/qwen/executable.js +2 -0
- package/dist/defs/qwen/model-discovery.d.ts +3 -0
- package/dist/defs/qwen/model-discovery.js +7 -0
- package/dist/defs/qwen.d.ts +10 -10
- package/dist/defs/reasonix/auth.d.ts +13 -0
- package/dist/defs/reasonix/auth.js +18 -0
- package/dist/defs/reasonix/executable.d.ts +2 -0
- package/dist/defs/reasonix/executable.js +2 -0
- package/dist/defs/reasonix.d.ts +13 -13
- package/dist/defs/reasonix.js +2 -9
- package/dist/defs/shared.d.ts +10 -2
- package/dist/defs/shared.js +5 -1
- package/dist/defs/trae-cli/executable.d.ts +2 -0
- package/dist/defs/trae-cli/executable.js +2 -0
- package/dist/defs/trae-cli.d.ts +15 -15
- package/dist/defs/trae-cli.js +2 -9
- package/dist/defs/vibe/executable.d.ts +2 -0
- package/dist/defs/vibe/executable.js +2 -0
- package/dist/defs/vibe.d.ts +13 -13
- package/dist/defs/vibe.js +2 -9
- package/dist/detection.d.ts +4 -3
- package/dist/detection.js +22 -22
- package/dist/diagnostics.d.ts +4 -4
- package/dist/diagnostics.js +2 -2
- package/dist/env.js +2 -1
- package/dist/executable-helpers.d.ts +21 -0
- package/dist/executable-helpers.js +2 -0
- package/dist/executables.d.ts +2 -2
- package/dist/executables.js +68 -114
- package/dist/index.d.ts +6 -2
- package/dist/index.js +5 -1
- package/dist/invocation.d.ts +22 -6
- package/dist/invocation.js +19 -17
- package/dist/json-event-stream-shared.d.ts +81 -0
- package/dist/json-event-stream-shared.js +147 -0
- package/dist/json-event-stream.d.ts +2 -4
- package/dist/json-event-stream.js +15 -940
- package/dist/launch.d.ts +1 -9
- package/dist/launch.js +6 -155
- package/dist/log-file.d.ts +2 -8
- package/dist/log-file.js +1 -1
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +1 -1
- package/dist/mmd-routes.d.ts +7 -7
- package/dist/mmd-routes.js +19 -27
- package/dist/model-discovery-adapters.d.ts +47 -11
- package/dist/model-discovery-adapters.js +47 -41
- package/dist/model-discovery-config-types.d.ts +44 -0
- package/dist/model-discovery-config-types.js +20 -0
- package/dist/model-discovery-config.d.ts +19 -11
- package/dist/model-discovery-config.js +64 -87
- package/dist/model-discovery-native.d.ts +2 -1
- package/dist/model-discovery-native.js +3 -3
- package/dist/model-discovery-sdk.d.ts +6 -2
- package/dist/model-discovery-sdk.js +2 -2
- package/dist/model-discovery-types.d.ts +1 -138
- package/dist/model-discovery-yaml.d.ts +3 -1
- package/dist/model-discovery-yaml.js +1 -1
- package/dist/model-discovery.d.ts +15 -5
- package/dist/model-discovery.js +119 -105
- package/dist/model-loading-state.d.ts +1 -1
- package/dist/model-loading-state.js +1 -1
- package/dist/model-registry.d.ts +5 -5
- package/dist/model-registry.js +7 -6
- package/dist/models.d.ts +4 -3
- package/dist/models.js +2 -2
- package/dist/native-permissions.d.ts +47 -0
- package/dist/native-permissions.js +80 -0
- package/dist/native-runtime.d.ts +11 -8
- package/dist/native-runtime.js +8 -4
- package/dist/native-tool-policy.d.ts +1 -40
- package/dist/opencode-log.d.ts +3 -3
- package/dist/opencode-log.js +5 -3
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/pi-models.d.ts +12 -2
- package/dist/pi-models.js +11 -1
- package/dist/prompt-augmenter.d.ts +1 -37
- package/dist/prompt-augmenter.js +0 -6
- package/dist/prompt-budget.d.ts +3 -3
- package/dist/prompt-budget.js +2 -2
- package/dist/prompt-file.d.ts +2 -6
- package/dist/prompt-file.js +1 -1
- package/dist/providers/aihubmix.d.ts +8 -8
- package/dist/providers/aihubmix.js +8 -8
- package/dist/providers/anthropic-messages.d.ts +22 -23
- package/dist/providers/anthropic-messages.js +26 -53
- package/dist/providers/azure-chat.d.ts +7 -6
- package/dist/providers/azure-chat.js +9 -6
- package/dist/providers/connection-guard.d.ts +3 -9
- package/dist/providers/connection-guard.js +6 -14
- package/dist/providers/connection-test.d.ts +1 -2
- package/dist/providers/connection-test.js +51 -51
- package/dist/providers/credentials.d.ts +59 -0
- package/dist/providers/credentials.js +80 -0
- package/dist/providers/elevenlabs.d.ts +2 -6
- package/dist/providers/elevenlabs.js +2 -31
- package/dist/providers/google-messages.d.ts +11 -10
- package/dist/providers/google-messages.js +16 -35
- package/dist/providers/google-schema.d.ts +1 -1
- package/dist/providers/google-schema.js +1 -1
- package/dist/providers/google.d.ts +6 -6
- package/dist/providers/google.js +6 -6
- package/dist/providers/index.d.ts +5 -2
- package/dist/providers/index.js +5 -2
- package/dist/providers/model-catalog.d.ts +4 -9
- package/dist/providers/model-catalog.js +3 -11
- package/dist/providers/oauth-callback-server.js +93 -87
- package/dist/providers/oauth-provider.d.ts +1 -1
- package/dist/providers/oauth-provider.js +1 -1
- package/dist/providers/oauth-tokens.d.ts +5 -5
- package/dist/providers/oauth-tokens.js +8 -9
- package/dist/providers/ollama-chat.d.ts +13 -12
- package/dist/providers/ollama-chat.js +15 -24
- package/dist/providers/openai-chat-request.d.ts +34 -0
- package/dist/providers/openai-chat-request.js +152 -0
- package/dist/providers/openai-chat-stream.d.ts +48 -0
- package/dist/providers/openai-chat-stream.js +89 -0
- package/dist/providers/openai-chat-tool-results.d.ts +81 -0
- package/dist/providers/openai-chat-tool-results.js +124 -0
- package/dist/providers/openai-chat-types.d.ts +180 -0
- package/dist/providers/openai-chat-types.js +3 -0
- package/dist/providers/openai-chat.d.ts +5 -405
- package/dist/providers/openai-chat.js +9 -388
- package/dist/providers/pkce.d.ts +1 -1
- package/dist/providers/pkce.js +1 -1
- package/dist/providers/provider-url.d.ts +6 -0
- package/dist/providers/provider-url.js +9 -0
- package/dist/providers/response-text.d.ts +4 -0
- package/dist/providers/response-text.js +16 -0
- package/dist/providers/sse-decode.d.ts +4 -0
- package/dist/providers/sse-decode.js +11 -0
- package/dist/providers/token-params.d.ts +5 -5
- package/dist/providers/token-params.js +5 -5
- package/dist/providers/tool-loop-verdict.d.ts +1 -1
- package/dist/providers/tool-loop-verdict.js +1 -1
- package/dist/providers/tool-turn-types.d.ts +2 -1
- package/dist/providers/tool-turn.js +30 -50
- package/dist/providers/turn-end-guard.d.ts +4 -1
- package/dist/providers/turn-end-guard.js +1 -1
- package/dist/qoder-stream.d.ts +1 -1
- package/dist/qoder-stream.js +1 -1
- package/dist/registry.d.ts +5 -5
- package/dist/registry.js +4 -4
- package/dist/role-marker-guard.d.ts +13 -1
- package/dist/role-marker-guard.js +15 -1
- package/dist/runtime-def-binding.d.ts +15 -0
- package/dist/runtime-def-binding.js +19 -0
- package/dist/runtime-port-bindings.d.ts +181 -0
- package/dist/runtime-port-bindings.js +95 -0
- package/dist/runtime-state.d.ts +2 -11
- package/dist/runtime-state.js +0 -13
- package/dist/types.d.ts +1 -454
- package/package.json +28 -16
- package/dist/ai-trace/capture.d.ts +0 -17
- package/dist/ai-trace/capture.js +0 -43
- package/dist/ai-trace/classify.d.ts +0 -12
- package/dist/ai-trace/classify.js +0 -16
- package/dist/ai-trace/index.d.ts +0 -13
- package/dist/ai-trace/index.js +0 -6
- package/dist/ai-trace/recorder.d.ts +0 -64
- package/dist/ai-trace/recorder.js +0 -258
- package/dist/ai-trace/sinks.d.ts +0 -51
- package/dist/ai-trace/sinks.js +0 -153
- package/dist/ai-trace/types.d.ts +0 -123
- package/dist/ai-trace/types.js +0 -17
- package/dist/ai-trace/usage.d.ts +0 -13
- package/dist/ai-trace/usage.js +0 -45
- package/dist/copilot-stream.d.ts +0 -65
- package/dist/copilot-stream.js +0 -131
- package/dist/defs/antigravity.d.ts +0 -94
- package/dist/defs/antigravity.js +0 -320
- package/dist/defs/copilot.d.ts +0 -34
- package/dist/defs/copilot.js +0 -96
- package/dist/defs/gemini.d.ts +0 -24
- package/dist/defs/gemini.js +0 -81
- package/dist/model-contracts.d.ts +0 -29
- package/dist/model-contracts.js +0 -2
- package/dist/providers/types.d.ts +0 -36
- package/dist/providers/types.js +0 -13
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
* module's own header and `archived provenance ledger`'s dated sections for the full
|
|
19
19
|
* rationale.
|
|
20
20
|
*/
|
|
21
|
-
export * from './types.js';
|
|
22
21
|
export * from './token-params.js';
|
|
23
22
|
export * from './google.js';
|
|
24
23
|
export * from './aihubmix.js';
|
|
@@ -27,7 +26,11 @@ export * from './model-catalog.js';
|
|
|
27
26
|
export * from './connection-test.js';
|
|
28
27
|
export * from './sse-decode.js';
|
|
29
28
|
export * from './anthropic-messages.js';
|
|
30
|
-
export
|
|
29
|
+
export { type OpenAiFunctionToolDef, type OpenAiToolCallParam, type OpenAiTextPart, type OpenAiImageUrlPart, type OpenAiContentPart, type OpenAiMessageParam, type OpenAiToolCall, type OpenAiToolResult, type OpenAiToolExecutor, type OpenAiTurnEndReason, type OpenAiTurnEvent, type OpenAiTurnOptions, type OpenAiTurnResult, type PendingToolCall, type OpenAiCompatibleRequestOutcome, type OpenAiCompatibleRequestInit, type OpenAiStreamState, type StrictToolRetryState } from './openai-chat-types.js';
|
|
30
|
+
export { DEFAULT_OPENAI_MAX_TOKENS, openAiRequestUrl, openAiHeaders, openAiRequestBody, createStrictToolRetry, refreshOpenAiTools, openAiLoopExitReason, runOpenAiToolTurn } from './openai-chat.js';
|
|
31
|
+
export { extractOpenAiErrorDetail, type OpenAiFrameResult, processOpenAiStreamFrame, runOpenAiCompatibleRequest } from './openai-chat-request.js';
|
|
32
|
+
export { parseOpenAiSseData, applyOpenAiStreamUsage, firstOpenAiChoice, handleOpenAiTextContentDelta, newPendingOpenAiToolCall, accumulateOpenAiToolCallDelta, handleOpenAiChoiceDelta, resolveOpenAiToolCalls } from './openai-chat-stream.js';
|
|
33
|
+
export { invalidOpenAiContentPartReason, type SanitizedOpenAiToolResult, sanitizeOpenAiToolResult, type SplitOpenAiToolResultContent, splitOpenAiToolResultContent, type OpenAiToolExecutionOutcome, executeOpenAiToolCalls, buildOpenAiAssistantToolCallMessage, buildOpenAiToolExchangeMessages } from './openai-chat-tool-results.js';
|
|
31
34
|
export * from './google-messages.js';
|
|
32
35
|
export * from './azure-chat.js';
|
|
33
36
|
export * from './ollama-chat.js';
|
package/dist/providers/index.js
CHANGED
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
* module's own header and `archived provenance ledger`'s dated sections for the full
|
|
19
19
|
* rationale.
|
|
20
20
|
*/
|
|
21
|
-
export * from './types.js';
|
|
22
21
|
export * from './token-params.js';
|
|
23
22
|
export * from './google.js';
|
|
24
23
|
export * from './aihubmix.js';
|
|
@@ -27,7 +26,11 @@ export * from './model-catalog.js';
|
|
|
27
26
|
export * from './connection-test.js';
|
|
28
27
|
export * from './sse-decode.js';
|
|
29
28
|
export * from './anthropic-messages.js';
|
|
30
|
-
export
|
|
29
|
+
export {} from './openai-chat-types.js';
|
|
30
|
+
export { DEFAULT_OPENAI_MAX_TOKENS, openAiRequestUrl, openAiHeaders, openAiRequestBody, createStrictToolRetry, refreshOpenAiTools, openAiLoopExitReason, runOpenAiToolTurn } from './openai-chat.js';
|
|
31
|
+
export { extractOpenAiErrorDetail, processOpenAiStreamFrame, runOpenAiCompatibleRequest } from './openai-chat-request.js';
|
|
32
|
+
export { parseOpenAiSseData, applyOpenAiStreamUsage, firstOpenAiChoice, handleOpenAiTextContentDelta, newPendingOpenAiToolCall, accumulateOpenAiToolCallDelta, handleOpenAiChoiceDelta, resolveOpenAiToolCalls } from './openai-chat-stream.js';
|
|
33
|
+
export { invalidOpenAiContentPartReason, sanitizeOpenAiToolResult, splitOpenAiToolResultContent, executeOpenAiToolCalls, buildOpenAiAssistantToolCallMessage, buildOpenAiToolExchangeMessages } from './openai-chat-tool-results.js';
|
|
31
34
|
export * from './google-messages.js';
|
|
32
35
|
export * from './azure-chat.js';
|
|
33
36
|
export * from './ollama-chat.js';
|
|
@@ -13,16 +13,11 @@
|
|
|
13
13
|
* unchanged — product-neutral as found (a bare BYOK-protocol model lister,
|
|
14
14
|
* no OD-branded strings).
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
signal?: AbortSignal;
|
|
16
|
+
import type { ProviderModelsQuery, ProviderModelsResponse } from '@jini-ai/core/contracts/agents';
|
|
17
|
+
/** The core query plus this runtime's transport-only field (an undici dispatcher), which a universal contract cannot name. */
|
|
18
|
+
export interface ProviderModelsInput extends ProviderModelsQuery {
|
|
20
19
|
requestInit?: Pick<RequestInit, 'dispatcher'>;
|
|
21
|
-
|
|
22
|
-
dnsLookup?: DnsLookupFn;
|
|
23
|
-
/** Injectable HTTP transport for adapter conformance; defaults to fetch. */
|
|
24
|
-
fetchFn?: typeof fetch;
|
|
25
|
-
};
|
|
20
|
+
}
|
|
26
21
|
/**
|
|
27
22
|
* Fetches the live model catalog for a BYOK provider connection. Validates
|
|
28
23
|
* the base URL (sync + DNS-resolved SSRF guard) before issuing any request,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { redactSecrets } from '@jini-ai/core';
|
|
2
2
|
import { defaultDnsLookup, validateBaseUrl, validateBaseUrlResolved } from './connection-guard.js';
|
|
3
3
|
import { aihubmixCatalogUrl, aihubmixHeaders, parseAIHubMixCatalog } from './aihubmix.js';
|
|
4
|
+
import { appendVersionedApiPath } from './provider-url.js';
|
|
4
5
|
import { googleProviderModelsUrl, normalizeGoogleModelId } from './google.js';
|
|
5
|
-
import { trimCharsEnd } from '@jini-ai/core/text';
|
|
6
6
|
const PROVIDER_MODELS_TIMEOUT_MS = 12_000;
|
|
7
7
|
// Every protocol `providerModelsUrl` resolves an endpoint for EXCEPT
|
|
8
8
|
// `aihubmix` — its catalogue is public and `providerModelsHeaders` already
|
|
@@ -30,14 +30,6 @@ const BEDROCK_MODEL_OPTIONS = [
|
|
|
30
30
|
{ id: 'amazon.nova-lite-v1:0', label: 'Amazon Nova Lite' },
|
|
31
31
|
{ id: 'amazon.nova-micro-v1:0', label: 'Amazon Nova Micro' },
|
|
32
32
|
];
|
|
33
|
-
function appendVersionedApiPath(baseUrl, suffix) {
|
|
34
|
-
const url = new URL(baseUrl);
|
|
35
|
-
const pathname = trimCharsEnd({ text: url.pathname, chars: '/' });
|
|
36
|
-
url.pathname = /\/v\d+(\/|$)/.test(pathname)
|
|
37
|
-
? `${pathname}${suffix}`
|
|
38
|
-
: `${pathname}/v1${suffix}`;
|
|
39
|
-
return url.toString();
|
|
40
|
-
}
|
|
41
33
|
function statusToKind(status) {
|
|
42
34
|
if (status === 401)
|
|
43
35
|
return 'auth_failed';
|
|
@@ -176,10 +168,10 @@ function providerModelsUrl(protocol, baseUrl, apiKey) {
|
|
|
176
168
|
return aihubmixCatalogUrl({ baseUrl: baseUrl, type: 'llm' });
|
|
177
169
|
}
|
|
178
170
|
if (protocol === 'openai' || protocol === 'senseaudio') {
|
|
179
|
-
return appendVersionedApiPath(baseUrl, '/models');
|
|
171
|
+
return appendVersionedApiPath({ baseUrl, suffix: '/models' });
|
|
180
172
|
}
|
|
181
173
|
if (protocol === 'anthropic') {
|
|
182
|
-
const url = new URL(appendVersionedApiPath(baseUrl, '/models'));
|
|
174
|
+
const url = new URL(appendVersionedApiPath({ baseUrl, suffix: '/models' }));
|
|
183
175
|
url.searchParams.set('limit', '1000');
|
|
184
176
|
return url.toString();
|
|
185
177
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { redactSecrets } from '@jini-ai/core';
|
|
1
|
+
import { describeErrorForLog } from '@jini-ai/core';
|
|
3
2
|
/**
|
|
4
3
|
* @module providers/oauth-callback-server
|
|
5
4
|
*
|
|
@@ -31,22 +30,30 @@ const DEFAULT_TIMEOUT_MS = 30 * 60 * 1000; // 30 min
|
|
|
31
30
|
*/
|
|
32
31
|
export async function startOAuthCallbackListener(requiredArgs, optionalArgs = {}) {
|
|
33
32
|
const input = { ...optionalArgs, ...requiredArgs };
|
|
34
|
-
const {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
const st = { input, consumed: false, stopped: false, server: null, timer: null };
|
|
34
|
+
const server = http.createServer((req, res) => {
|
|
35
|
+
void handleRequest({ st, req, res });
|
|
36
|
+
});
|
|
37
|
+
await listenServer(server, { host: input.host, port: input.port });
|
|
38
|
+
st.server = server;
|
|
39
|
+
startTimeout({ st, timeoutMs: input.timeoutMs ?? DEFAULT_TIMEOUT_MS });
|
|
40
|
+
const addr = server.address();
|
|
41
|
+
return {
|
|
42
|
+
address: { host: addr.address, port: addr.port },
|
|
43
|
+
stop: () => stopListener(st),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function closeServer(st) {
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
// Non-null: `stopListener` (this function's only caller) guards on `stopped`
|
|
42
49
|
// before ever reaching here, so this runs at most once — after
|
|
43
|
-
// `
|
|
44
|
-
//
|
|
45
|
-
const s =
|
|
46
|
-
|
|
47
|
-
if (timer) {
|
|
48
|
-
clearTimeout(timer);
|
|
49
|
-
timer = null;
|
|
50
|
+
// `st.server` was unconditionally set at listener-startup, before this
|
|
51
|
+
// listener's `stop`/`address` are ever handed to a caller.
|
|
52
|
+
const s = st.server;
|
|
53
|
+
st.server = null;
|
|
54
|
+
if (st.timer) {
|
|
55
|
+
clearTimeout(st.timer);
|
|
56
|
+
st.timer = null;
|
|
50
57
|
}
|
|
51
58
|
s.close(() => resolve());
|
|
52
59
|
// Force close after a short grace period so lingering keep-alive
|
|
@@ -64,65 +71,68 @@ export async function startOAuthCallbackListener(requiredArgs, optionalArgs = {}
|
|
|
64
71
|
}, 100);
|
|
65
72
|
reaper.unref?.();
|
|
66
73
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
74
|
+
}
|
|
75
|
+
async function stopListener(st) {
|
|
76
|
+
if (st.stopped)
|
|
77
|
+
return;
|
|
78
|
+
st.stopped = true;
|
|
79
|
+
await closeServer(st);
|
|
80
|
+
}
|
|
81
|
+
function respondText({ res, status, body }) {
|
|
82
|
+
res.statusCode = status;
|
|
83
|
+
res.setHeader('content-type', 'text/plain; charset=utf-8');
|
|
84
|
+
res.end(body);
|
|
85
|
+
}
|
|
86
|
+
async function handleRequest({ st, req, res }) {
|
|
87
|
+
const { host, port, path: callbackPath } = st.input;
|
|
88
|
+
if (st.consumed || !req.url) {
|
|
89
|
+
respondText({ res, status: 410, body: 'Listener already consumed.' });
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
let parsed;
|
|
93
|
+
try {
|
|
94
|
+
parsed = new URL(req.url, `http://${host}:${port}`);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
respondText({ res, status: 400, body: 'Bad request.' });
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// Ignore favicon.ico and any other path so the browser's incidental
|
|
101
|
+
// requests don't consume the slot meant for the callback path.
|
|
102
|
+
if (parsed.pathname !== callbackPath) {
|
|
103
|
+
respondText({ res, status: 404, body: 'Not found.' });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
await dispatchCallback({ st, params: parsed.searchParams, res });
|
|
107
|
+
}
|
|
108
|
+
async function dispatchCallback({ st, params, res }) {
|
|
109
|
+
const { expectedState, onCallback } = st.input;
|
|
110
|
+
const outcome = callbackOutcome({ params, expectedState });
|
|
111
|
+
const consumesListener = callbackConsumesListener({ params, expectedState, outcome });
|
|
112
|
+
if (consumesListener) {
|
|
113
|
+
st.consumed = true;
|
|
114
|
+
}
|
|
115
|
+
res.statusCode = outcome.kind === 'ok' ? 200 : 400;
|
|
116
|
+
res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
117
|
+
res.end(renderResultPage(outcome));
|
|
118
|
+
if (!consumesListener) {
|
|
119
|
+
// Stale-tab replay or malformed request — don't surface to the
|
|
120
|
+
// caller and don't tear down the listener. The browser sees the
|
|
121
|
+
// 400 page; the real flow can still complete on a later hit.
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
await onCallback(outcome);
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
console.error('[oauth-callback-server] onCallback failed:', describeErrorForLog({ err }));
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
void stopListener(st);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function listenServer(server, { host, port }) {
|
|
135
|
+
return new Promise((resolve, reject) => {
|
|
126
136
|
const onError = (err) => {
|
|
127
137
|
if (err.code === 'EADDRINUSE') {
|
|
128
138
|
reject(new Error(`Port ${port} is already in use — close any other process listening on ${host}:${port} (e.g. an in-flight OAuth flow) and try again`));
|
|
@@ -137,23 +147,19 @@ export async function startOAuthCallbackListener(requiredArgs, optionalArgs = {}
|
|
|
137
147
|
resolve();
|
|
138
148
|
});
|
|
139
149
|
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
150
|
+
}
|
|
151
|
+
function startTimeout({ st, timeoutMs }) {
|
|
152
|
+
st.timer = setTimeout(() => {
|
|
153
|
+
Promise.resolve(st.input.onCallback({
|
|
143
154
|
kind: 'error',
|
|
144
155
|
error: 'OAuth timed out — sign in again',
|
|
145
156
|
})).catch(() => {
|
|
146
|
-
// already logging in
|
|
157
|
+
// already logging in dispatchCallback(); this branch is best-effort cleanup.
|
|
147
158
|
});
|
|
148
|
-
void
|
|
159
|
+
void stopListener(st);
|
|
149
160
|
}, timeoutMs);
|
|
150
161
|
// unref so the timer doesn't keep the event loop alive in tests.
|
|
151
|
-
timer.unref?.();
|
|
152
|
-
const addr = server.address();
|
|
153
|
-
return {
|
|
154
|
-
address: { host: addr.address, port: addr.port },
|
|
155
|
-
stop,
|
|
156
|
-
};
|
|
162
|
+
st.timer.unref?.();
|
|
157
163
|
}
|
|
158
164
|
function renderResultPage(outcome) {
|
|
159
165
|
if (outcome.kind === 'ok') {
|
|
@@ -47,7 +47,7 @@ export interface BeginOAuthPkceResult {
|
|
|
47
47
|
* `authorizeUrl` and receiving the callback at `redirectUri`. When the
|
|
48
48
|
* callback arrives, pass `state` and `code` to {@link completeOAuthPkce}.
|
|
49
49
|
*/
|
|
50
|
-
export declare function beginOAuthPkce(input: BeginOAuthPkceInput): BeginOAuthPkceResult;
|
|
50
|
+
export declare function beginOAuthPkce(input: BeginOAuthPkceInput, _optional?: Record<string, never>): BeginOAuthPkceResult;
|
|
51
51
|
export interface CompleteOAuthPkceInput {
|
|
52
52
|
config: OAuthPkceProviderConfig;
|
|
53
53
|
pending: PendingAuthCache;
|
|
@@ -36,7 +36,7 @@ function authServerMetadata(config) {
|
|
|
36
36
|
* `authorizeUrl` and receiving the callback at `redirectUri`. When the
|
|
37
37
|
* callback arrives, pass `state` and `code` to {@link completeOAuthPkce}.
|
|
38
38
|
*/
|
|
39
|
-
export function beginOAuthPkce(input) {
|
|
39
|
+
export function beginOAuthPkce(input, _optional = {}) {
|
|
40
40
|
const { config, pending, redirectUri } = input;
|
|
41
41
|
const codeVerifier = generateCodeVerifier();
|
|
42
42
|
const codeChallenge = deriveCodeChallenge({ verifier: codeVerifier });
|
|
@@ -24,27 +24,27 @@ export interface OAuthTokenFile {
|
|
|
24
24
|
/** Coerces a freeform JSON blob into the typed shape, dropping anything that doesn't deserialize cleanly. Used both at read time and as a defensive pass when third-party tooling has hand-edited the file. */
|
|
25
25
|
export declare function sanitizeOAuthTokenFile({ raw }: {
|
|
26
26
|
raw: unknown;
|
|
27
|
-
}): OAuthTokenFile;
|
|
27
|
+
}, _optional?: Record<string, never>): OAuthTokenFile;
|
|
28
28
|
export declare function readOAuthTokenFile({ dataDir, fileName }: {
|
|
29
29
|
dataDir: string;
|
|
30
30
|
fileName: string;
|
|
31
|
-
}): Promise<OAuthTokenFile>;
|
|
31
|
+
}, _optional?: Record<string, never>): Promise<OAuthTokenFile>;
|
|
32
32
|
/** Gets the current stored OAuth token for `fileName`, or null when none is stored (or the persisted entry is malformed). */
|
|
33
33
|
export declare function getStoredOAuthToken({ dataDir, fileName }: {
|
|
34
34
|
dataDir: string;
|
|
35
35
|
fileName: string;
|
|
36
|
-
}): Promise<StoredOAuthToken | null>;
|
|
36
|
+
}, _optional?: Record<string, never>): Promise<StoredOAuthToken | null>;
|
|
37
37
|
/** Atomically replaces the stored OAuth token for `fileName`. */
|
|
38
38
|
export declare function setStoredOAuthToken({ dataDir, fileName, token }: {
|
|
39
39
|
dataDir: string;
|
|
40
40
|
fileName: string;
|
|
41
41
|
token: StoredOAuthToken;
|
|
42
|
-
}): Promise<void>;
|
|
42
|
+
}, _optional?: Record<string, never>): Promise<void>;
|
|
43
43
|
/** Atomically deletes the stored OAuth token for `fileName`. No-op when absent. */
|
|
44
44
|
export declare function clearStoredOAuthToken({ dataDir, fileName }: {
|
|
45
45
|
dataDir: string;
|
|
46
46
|
fileName: string;
|
|
47
|
-
}): Promise<void>;
|
|
47
|
+
}, _optional?: Record<string, never>): Promise<void>;
|
|
48
48
|
/** True when the stored token is past its `expiresAt` (or within `skew` milliseconds of expiring). Returns false when no `expiresAt` is recorded — some providers issue non-expiring tokens. */
|
|
49
49
|
export declare function isOAuthTokenExpired({ token }: {
|
|
50
50
|
token: StoredOAuthToken;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { redactSecrets } from '@jini-ai/core';
|
|
1
|
+
import { describeErrorForLog } from '@jini-ai/core';
|
|
3
2
|
/**
|
|
4
3
|
* @module providers/oauth-tokens
|
|
5
4
|
*
|
|
@@ -20,7 +19,7 @@ function isPlainObject(v) {
|
|
|
20
19
|
return Boolean(v) && typeof v === 'object' && !Array.isArray(v);
|
|
21
20
|
}
|
|
22
21
|
/** Coerces a freeform JSON blob into the typed shape, dropping anything that doesn't deserialize cleanly. Used both at read time and as a defensive pass when third-party tooling has hand-edited the file. */
|
|
23
|
-
export function sanitizeOAuthTokenFile({ raw }) {
|
|
22
|
+
export function sanitizeOAuthTokenFile({ raw }, _optional = {}) {
|
|
24
23
|
if (!isPlainObject(raw))
|
|
25
24
|
return {};
|
|
26
25
|
const tok = sanitizeToken(raw.token);
|
|
@@ -52,7 +51,7 @@ function sanitizeToken(raw) {
|
|
|
52
51
|
out.expiresAt = expiresAt;
|
|
53
52
|
return out;
|
|
54
53
|
}
|
|
55
|
-
export async function readOAuthTokenFile({ dataDir, fileName }) {
|
|
54
|
+
export async function readOAuthTokenFile({ dataDir, fileName }, _optional = {}) {
|
|
56
55
|
try {
|
|
57
56
|
const raw = await readFile(path.join(dataDir, fileName), 'utf8');
|
|
58
57
|
return sanitizeOAuthTokenFile({ raw: JSON.parse(raw) });
|
|
@@ -62,7 +61,7 @@ export async function readOAuthTokenFile({ dataDir, fileName }) {
|
|
|
62
61
|
if (e.code === 'ENOENT')
|
|
63
62
|
return {};
|
|
64
63
|
if (e.name === 'SyntaxError') {
|
|
65
|
-
console.error('[oauth-tokens] Corrupted JSON, returning empty:',
|
|
64
|
+
console.error('[oauth-tokens] Corrupted JSON, returning empty:', describeErrorForLog({ err }));
|
|
66
65
|
return {};
|
|
67
66
|
}
|
|
68
67
|
throw err;
|
|
@@ -96,24 +95,24 @@ async function writeTokenFile(dataDir, fileName, next) {
|
|
|
96
95
|
catch (err) {
|
|
97
96
|
const e = err;
|
|
98
97
|
if (e.code !== 'ENOTSUP' && e.code !== 'EPERM') {
|
|
99
|
-
console.warn('[oauth-tokens] could not chmod 0600', file,
|
|
98
|
+
console.warn('[oauth-tokens] could not chmod 0600', file, describeErrorForLog({ err }));
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
return next;
|
|
103
102
|
}
|
|
104
103
|
/** Gets the current stored OAuth token for `fileName`, or null when none is stored (or the persisted entry is malformed). */
|
|
105
|
-
export async function getStoredOAuthToken({ dataDir, fileName }) {
|
|
104
|
+
export async function getStoredOAuthToken({ dataDir, fileName }, _optional = {}) {
|
|
106
105
|
const file = await readOAuthTokenFile({ dataDir: dataDir, fileName: fileName });
|
|
107
106
|
return file.token ?? null;
|
|
108
107
|
}
|
|
109
108
|
/** Atomically replaces the stored OAuth token for `fileName`. */
|
|
110
|
-
export async function setStoredOAuthToken({ dataDir, fileName, token }) {
|
|
109
|
+
export async function setStoredOAuthToken({ dataDir, fileName, token }, _optional = {}) {
|
|
111
110
|
await withLock(`${dataDir}\0${fileName}`, async () => {
|
|
112
111
|
await writeTokenFile(dataDir, fileName, { token });
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
114
|
/** Atomically deletes the stored OAuth token for `fileName`. No-op when absent. */
|
|
116
|
-
export async function clearStoredOAuthToken({ dataDir, fileName }) {
|
|
115
|
+
export async function clearStoredOAuthToken({ dataDir, fileName }, _optional = {}) {
|
|
117
116
|
await withLock(`${dataDir}\0${fileName}`, async () => {
|
|
118
117
|
const file = await readOAuthTokenFile({ dataDir: dataDir, fileName: fileName });
|
|
119
118
|
if (!file.token)
|
|
@@ -104,7 +104,8 @@
|
|
|
104
104
|
* See docs/decisions/DR-001-provider-native-tool-lifecycle.md.
|
|
105
105
|
*/
|
|
106
106
|
import { createRoleMarkerGuard } from '../role-marker-guard.js';
|
|
107
|
-
import { type
|
|
107
|
+
import { type PinnedFetch } from './connection-guard.js';
|
|
108
|
+
import { type DnsLookupFn } from '@jini-ai/core/contracts/agents';
|
|
108
109
|
import { type TurnEndReason } from './turn-end-guard.js';
|
|
109
110
|
export interface OllamaFunctionToolDef {
|
|
110
111
|
readonly type: 'function';
|
|
@@ -244,17 +245,17 @@ export interface OllamaStreamState {
|
|
|
244
245
|
/** Parses one `function.arguments` value: Ollama's native tool-call payload documents it as a native JSON object, but a strict/older server can still send a stringified blob — this tolerates either, falling back to the raw string on malformed JSON. */
|
|
245
246
|
export declare function parseOllamaToolCallArguments({ args }: {
|
|
246
247
|
args: unknown;
|
|
247
|
-
}): unknown;
|
|
248
|
+
}, _optional?: Record<string, never>): unknown;
|
|
248
249
|
/** Resolves one raw `message.tool_calls[]` entry into an `OllamaToolCall`, or `null` when the entry is missing its `function`/`name` (malformed, so skipped rather than surfaced). `index` seeds the synthetic id fallback — see `OllamaToolCallParam`'s doc for why a call id is generated locally rather than trusted off the wire. */
|
|
249
250
|
export declare function resolveOllamaToolCall({ rawCall, index }: {
|
|
250
251
|
rawCall: unknown;
|
|
251
252
|
index: number;
|
|
252
|
-
}): OllamaToolCall | null;
|
|
253
|
+
}, _optional?: Record<string, never>): OllamaToolCall | null;
|
|
253
254
|
/** Resolves every entry in `message.tool_calls` into `state.toolCalls`, then marks `finishReason: 'tool_calls'` once at least one resolved — mirrors the original inline loop's behavior of setting `finishReason` after the whole batch rather than per-call. */
|
|
254
255
|
export declare function handleOllamaToolCallsField({ state, message }: {
|
|
255
256
|
state: OllamaStreamState;
|
|
256
257
|
message: Record<string, unknown>;
|
|
257
|
-
}): void;
|
|
258
|
+
}, _optional?: Record<string, never>): void;
|
|
258
259
|
/**
|
|
259
260
|
* Feeds one `message.content` delta through the role-marker guard and emits the safe portion.
|
|
260
261
|
* Returns `'break'` once the guard flags contamination, otherwise `'continue'` — same contract as
|
|
@@ -264,28 +265,28 @@ export declare function handleOllamaTextContent({ state, content, onEvent }: {
|
|
|
264
265
|
state: OllamaStreamState;
|
|
265
266
|
content: string;
|
|
266
267
|
onEvent: (event: OllamaTurnEvent) => void;
|
|
267
|
-
}): 'continue' | 'break';
|
|
268
|
+
}, _optional?: Record<string, never>): 'continue' | 'break';
|
|
268
269
|
export declare function processOllamaLine({ state, line, onEvent, emitEnd }: {
|
|
269
270
|
state: OllamaStreamState;
|
|
270
271
|
line: Record<string, unknown>;
|
|
271
272
|
onEvent: (event: OllamaTurnEvent) => void;
|
|
272
273
|
emitEnd: (reason: OllamaTurnEndReason) => void;
|
|
273
|
-
}): 'continue' | 'break' | 'done';
|
|
274
|
+
}, _optional?: Record<string, never>): 'continue' | 'break' | 'done';
|
|
274
275
|
/** Parses one NDJSON line, returning `undefined` for a malformed/empty line — JSON has no `undefined` literal, so a successful parse is never confused with a failed one. Extracted so the generator below never nests a `try`/`catch` inside its loops (see that function's doc). */
|
|
275
276
|
export declare function parseNdjsonLine({ line }: {
|
|
276
277
|
line: string;
|
|
277
|
-
}): unknown;
|
|
278
|
+
}, _optional?: Record<string, never>): unknown;
|
|
278
279
|
/** Splits already-accumulated buffer content into complete newline-terminated lines (newline stripped) plus the remaining partial-line `remainder`. Pure — no I/O — so this buffering/splitting logic is exercised as plain value-in/value-out assertions instead of through the full streaming generator. */
|
|
279
280
|
export declare function splitNdjsonLines({ buffer }: {
|
|
280
281
|
buffer: string;
|
|
281
|
-
}): {
|
|
282
|
+
}, _optional?: Record<string, never>): {
|
|
282
283
|
readonly lines: readonly string[];
|
|
283
284
|
readonly remainder: string;
|
|
284
285
|
};
|
|
285
286
|
/** Trims and parses each complete line in `rawLines`, yielding only the ones that parsed to something other than `undefined` — a plain (non-async) generator so `decodeNdjsonStream` below can delegate to it with `yield*` instead of nesting a `for`/`if`/`if` inside its own `for await` loop. */
|
|
286
287
|
export declare function parseNdjsonLines({ rawLines }: {
|
|
287
288
|
rawLines: readonly string[];
|
|
288
|
-
}): Generator<unknown>;
|
|
289
|
+
}, _optional?: Record<string, never>): Generator<unknown>;
|
|
289
290
|
/**
|
|
290
291
|
* Decides why the tool loop should stop after one request, or returns `null` when it should
|
|
291
292
|
* instead proceed to execute the pending tool calls — mirrors
|
|
@@ -295,11 +296,11 @@ export declare function ollamaLoopExitReason({ outcome, toolTurns, maxToolTurns
|
|
|
295
296
|
outcome: SingleRequestOutcome;
|
|
296
297
|
toolTurns: number;
|
|
297
298
|
maxToolTurns: number;
|
|
298
|
-
}): OllamaTurnEndReason | null;
|
|
299
|
+
}, _optional?: Record<string, never>): OllamaTurnEndReason | null;
|
|
299
300
|
/** Builds the assistant continuation's `tool_calls` field — Ollama's native shape has no `id`/`type` on the wire (see `OllamaToolCallParam`'s doc). */
|
|
300
301
|
export declare function buildOllamaAssistantToolCalls({ toolCalls }: {
|
|
301
302
|
toolCalls: readonly OllamaToolCall[];
|
|
302
|
-
}): OllamaToolCallParam[];
|
|
303
|
+
}, _optional?: Record<string, never>): OllamaToolCallParam[];
|
|
303
304
|
/**
|
|
304
305
|
* Runs every pending tool call in order, applying `guardToolResult` and reducing the results into
|
|
305
306
|
* the `tool`-role continuation messages Ollama's native `tool_name`-association scheme expects —
|
|
@@ -310,7 +311,7 @@ export declare function executeOllamaToolCalls({ executeTool, calls, onEvent }:
|
|
|
310
311
|
executeTool: OllamaToolExecutor;
|
|
311
312
|
calls: readonly OllamaToolCall[];
|
|
312
313
|
onEvent: (event: OllamaTurnEvent) => void;
|
|
313
|
-
}): Promise<OllamaMessageParam[]>;
|
|
314
|
+
}, _optional?: Record<string, never>): Promise<OllamaMessageParam[]>;
|
|
314
315
|
/**
|
|
315
316
|
* Runs a full Ollama native `/api/chat` turn, including the tool-execution
|
|
316
317
|
* loop when `options.executeTool` is supplied and the model requests a
|