@jini-ai/agent-runtime 0.7.1 → 0.7.3-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +3 -1
- package/dist/agent-protocol/acp/constants.js +2 -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 +157 -129
- 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 +226 -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 +27 -15
- 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/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
|
@@ -19,7 +19,7 @@ import { buildAcpSessionNewParams } from './session-params.js';
|
|
|
19
19
|
* @param value - A raw field value from an ACP config option object.
|
|
20
20
|
* @returns A normalised token string, or `''` when `value` is not a string.
|
|
21
21
|
*/
|
|
22
|
-
export function normalizeConfigOptionToken(value) {
|
|
22
|
+
export function normalizeConfigOptionToken({ value }, _optional = {}) {
|
|
23
23
|
return typeof value === 'string'
|
|
24
24
|
? value.trim().toLowerCase().replace(/[\s_-]+/g, '')
|
|
25
25
|
: '';
|
|
@@ -32,16 +32,16 @@ export function normalizeConfigOptionToken(value) {
|
|
|
32
32
|
* @param option - A single item from the `configOptions` array.
|
|
33
33
|
* @param configId - The trimmed `id` field of that item.
|
|
34
34
|
*/
|
|
35
|
-
export function isModelConfigOption(option, configId) {
|
|
36
|
-
const category = normalizeConfigOptionToken(option.category);
|
|
35
|
+
export function isModelConfigOption({ option, configId }, _optional = {}) {
|
|
36
|
+
const category = normalizeConfigOptionToken({ value: option.category });
|
|
37
37
|
if (category === 'model')
|
|
38
38
|
return true;
|
|
39
|
-
const id = normalizeConfigOptionToken(configId);
|
|
39
|
+
const id = normalizeConfigOptionToken({ value: configId });
|
|
40
40
|
if (id === 'model')
|
|
41
41
|
return true;
|
|
42
42
|
if (category)
|
|
43
43
|
return false;
|
|
44
|
-
const name = normalizeConfigOptionToken(option.name);
|
|
44
|
+
const name = normalizeConfigOptionToken({ value: option.name });
|
|
45
45
|
return MODEL_CONFIG_OPTION_IDS.has(id) || name === 'model';
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -52,7 +52,7 @@ export function isModelConfigOption(option, configId) {
|
|
|
52
52
|
* @param configOptions - The raw `result.configOptions` value from a session response.
|
|
53
53
|
* @returns A parsed `AcpModelConfigOption` or `null` when absent.
|
|
54
54
|
*/
|
|
55
|
-
export function findModelConfigOption(configOptions) {
|
|
55
|
+
export function findModelConfigOption({ configOptions }, _optional = {}) {
|
|
56
56
|
const options = Array.isArray(configOptions) ? configOptions : [];
|
|
57
57
|
for (const rawOption of options) {
|
|
58
58
|
const parsed = parseModelConfigOption(rawOption);
|
|
@@ -61,6 +61,20 @@ export function findModelConfigOption(configOptions) {
|
|
|
61
61
|
}
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
64
|
+
export function findEffortConfigOption({ configOptions }, _optional = {}) {
|
|
65
|
+
const options = Array.isArray(configOptions) ? configOptions : [];
|
|
66
|
+
for (const rawOption of options) {
|
|
67
|
+
const option = asObject({ value: rawOption });
|
|
68
|
+
if (option?.category !== 'thought_level' || typeof option.id !== 'string')
|
|
69
|
+
continue;
|
|
70
|
+
const values = Array.isArray(option.options) ? option.options.flatMap((rawValue) => {
|
|
71
|
+
const value = asObject({ value: rawValue })?.value;
|
|
72
|
+
return typeof value === 'string' ? [value] : [];
|
|
73
|
+
}) : [];
|
|
74
|
+
return { configId: option.id, values };
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
64
78
|
/** Returns the trimmed string when `value` is a string, else `''`. */
|
|
65
79
|
function trimmedOrEmpty(value) {
|
|
66
80
|
return typeof value === 'string' ? value.trim() : '';
|
|
@@ -68,7 +82,7 @@ function trimmedOrEmpty(value) {
|
|
|
68
82
|
/** Parses one `configOptions` entry, returning it only when it is a
|
|
69
83
|
* select-type (or untyped) model-selection option with a non-blank id. */
|
|
70
84
|
function parseModelConfigOption(rawOption) {
|
|
71
|
-
const option = asObject(rawOption);
|
|
85
|
+
const option = asObject({ value: rawOption });
|
|
72
86
|
if (!option)
|
|
73
87
|
return null;
|
|
74
88
|
const configId = trimmedOrEmpty(option.id);
|
|
@@ -77,7 +91,7 @@ function parseModelConfigOption(rawOption) {
|
|
|
77
91
|
const type = trimmedOrEmpty(option.type);
|
|
78
92
|
if (type && type !== 'select')
|
|
79
93
|
return null;
|
|
80
|
-
if (!isModelConfigOption(option, configId))
|
|
94
|
+
if (!isModelConfigOption({ option, configId }))
|
|
81
95
|
return null;
|
|
82
96
|
return {
|
|
83
97
|
configId,
|
|
@@ -109,7 +123,7 @@ function configOptionEntry(value) {
|
|
|
109
123
|
}
|
|
110
124
|
/** Reads a legacy `models.availableModels` entry. */
|
|
111
125
|
function legacyModelEntry(model) {
|
|
112
|
-
const obj = asObject(model);
|
|
126
|
+
const obj = asObject({ value: model });
|
|
113
127
|
return { id: trimmedOrEmpty(obj?.modelId), name: trimmedOrEmpty(obj?.name) };
|
|
114
128
|
}
|
|
115
129
|
/**
|
|
@@ -122,13 +136,13 @@ function legacyModelEntry(model) {
|
|
|
122
136
|
* @param defaultModelOption - The fallback option to prepend to the list.
|
|
123
137
|
* @returns `{ currentModelId, models }` or `null` when no config option is found.
|
|
124
138
|
*/
|
|
125
|
-
export function normalizeModelConfigOptions(configOptions, defaultModelOption) {
|
|
126
|
-
const modelConfig = findModelConfigOption(configOptions);
|
|
139
|
+
export function normalizeModelConfigOptions({ configOptions, defaultModelOption }, _optional = {}) {
|
|
140
|
+
const modelConfig = findModelConfigOption({ configOptions });
|
|
127
141
|
if (!modelConfig)
|
|
128
142
|
return null;
|
|
129
143
|
const entries = [];
|
|
130
144
|
for (const rawValue of modelConfig.values) {
|
|
131
|
-
const value = asObject(rawValue);
|
|
145
|
+
const value = asObject({ value: rawValue });
|
|
132
146
|
if (value)
|
|
133
147
|
entries.push(configOptionEntry(value));
|
|
134
148
|
}
|
|
@@ -151,7 +165,7 @@ export function normalizeModelConfigOptions(configOptions, defaultModelOption) {
|
|
|
151
165
|
* @returns A deduplicated array of `ModelOption` items.
|
|
152
166
|
*/
|
|
153
167
|
export function normalizeModels({ models, defaultModelOption }, { configOptions } = {}) {
|
|
154
|
-
const configModels = normalizeModelConfigOptions(configOptions, defaultModelOption);
|
|
168
|
+
const configModels = normalizeModelConfigOptions({ configOptions, defaultModelOption });
|
|
155
169
|
if (configModels && configModels.models.length > 1) {
|
|
156
170
|
return configModels.models;
|
|
157
171
|
}
|
|
@@ -160,7 +174,7 @@ export function normalizeModels({ models, defaultModelOption }, { configOptions
|
|
|
160
174
|
}
|
|
161
175
|
/** The legacy `result.models.availableModels` path of `normalizeModels`. */
|
|
162
176
|
function legacyModelOptions({ models, defaultModelOption, }) {
|
|
163
|
-
const modelsObj = asObject(models);
|
|
177
|
+
const modelsObj = asObject({ value: models });
|
|
164
178
|
const available = Array.isArray(modelsObj?.availableModels) ? modelsObj.availableModels : [];
|
|
165
179
|
const currentId = typeof modelsObj?.currentModelId === 'string' ? modelsObj.currentModelId : null;
|
|
166
180
|
return buildModelOptions({ defaultModelOption, currentId, entries: available.map(legacyModelEntry) });
|
|
@@ -172,7 +186,7 @@ function legacyModelOptions({ models, defaultModelOption, }) {
|
|
|
172
186
|
*
|
|
173
187
|
* @param code - The `error.code` value from a JSON-RPC error response.
|
|
174
188
|
*/
|
|
175
|
-
export function modelSelectionErrorIsRecoverable(code) {
|
|
189
|
+
export function modelSelectionErrorIsRecoverable({ code }, _optional = {}) {
|
|
176
190
|
return code === -32603 || code === -32602 || code === -32601 || code === -32002;
|
|
177
191
|
}
|
|
178
192
|
/**
|
|
@@ -182,11 +196,11 @@ export function modelSelectionErrorIsRecoverable(code) {
|
|
|
182
196
|
*
|
|
183
197
|
* @param result - The parsed `result` object from a session handshake response.
|
|
184
198
|
*/
|
|
185
|
-
export function currentModelFromSessionResult(result) {
|
|
186
|
-
const configCurrent = findModelConfigOption(result.configOptions)?.currentValue;
|
|
199
|
+
export function currentModelFromSessionResult({ result }, _optional = {}) {
|
|
200
|
+
const configCurrent = findModelConfigOption({ configOptions: result.configOptions })?.currentValue;
|
|
187
201
|
if (configCurrent)
|
|
188
202
|
return configCurrent;
|
|
189
|
-
const models = asObject(result.models);
|
|
203
|
+
const models = asObject({ value: result.models });
|
|
190
204
|
return typeof models?.currentModelId === 'string' && models.currentModelId.trim()
|
|
191
205
|
? models.currentModelId.trim()
|
|
192
206
|
: null;
|
|
@@ -211,118 +225,132 @@ export function currentModelFromSessionResult(result) {
|
|
|
211
225
|
* @returns A promise resolving to the available `ModelOption[]`.
|
|
212
226
|
*/
|
|
213
227
|
export async function detectAcpModels(requiredArgs, optionalArgs = {}) {
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
228
|
+
const config = resolveProbeConfig({ ...optionalArgs, ...requiredArgs });
|
|
229
|
+
return await new Promise((resolve, reject) => startProbe({ config, resolve, reject }));
|
|
230
|
+
}
|
|
231
|
+
function resolveProbeConfig(options) {
|
|
232
|
+
const { cwd = process.cwd(), env = process.env, timeoutMs = DEFAULT_TIMEOUT_MS, clientName = 'agent-runtime-detect', clientVersion = 'runtime-adapter', defaultModelOption = { id: 'default', label: 'Default (CLI config)' }, spawnProcess = spawn, } = options;
|
|
233
|
+
return {
|
|
234
|
+
bin: options.bin, args: options.args, cwd, env, timeoutMs, clientName, clientVersion,
|
|
235
|
+
defaultModelOption, spawnProcess, signal: options.signal, onSessionResult: options.onSessionResult,
|
|
236
|
+
effectiveTimeoutMs: resolveAcpTimeoutMs({ env, fallbackMs: timeoutMs }),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function finishProbe({ run, fn, value }) {
|
|
240
|
+
if (run.settled)
|
|
241
|
+
return;
|
|
242
|
+
run.settled = true;
|
|
243
|
+
if (run.timer)
|
|
244
|
+
clearTimeout(run.timer);
|
|
245
|
+
run.config.signal?.removeEventListener('abort', run.abort);
|
|
246
|
+
if (run.closed)
|
|
247
|
+
fn(value);
|
|
248
|
+
else
|
|
249
|
+
finishAcpProbeProcess({ child: run.child, complete: () => fn(value) });
|
|
250
|
+
}
|
|
251
|
+
function failProbe({ run, message }) {
|
|
252
|
+
finishProbe({ run, fn: run.reject, value: new Error(message) });
|
|
253
|
+
}
|
|
254
|
+
function writeProbeRpc(run, rpc) {
|
|
255
|
+
try {
|
|
256
|
+
sendRpc({ writable: run.child.stdin, id: rpc.id, method: rpc.method, params: rpc.params });
|
|
257
|
+
}
|
|
258
|
+
catch (err) {
|
|
259
|
+
failProbe({ run, message: `stdin write failed: ${errorMessage({ err })}` });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function handleProbeRpcError({ run, obj, rpcErr }) {
|
|
263
|
+
// JSON-RPC -32603 "Internal error" during model detection:
|
|
264
|
+
// If this is for the current expected-id (initialize/session/new),
|
|
265
|
+
// it's a real probe failure — reject immediately.
|
|
266
|
+
// Otherwise it's cleanup noise — suppress it.
|
|
267
|
+
if (asObject({ value: obj?.error })?.code === -32603 && obj?.id !== run.expectedId)
|
|
268
|
+
return;
|
|
269
|
+
failProbe({ run, message: rpcErr });
|
|
270
|
+
}
|
|
271
|
+
function handleProbeResult(run, result) {
|
|
272
|
+
const { config } = run;
|
|
273
|
+
if (run.expectedId === 1) {
|
|
274
|
+
run.expectedId = 2;
|
|
275
|
+
writeProbeRpc(run, { id: 2, method: 'session/new', params: buildAcpSessionNewParams({ cwd: config.cwd }) });
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
config.onSessionResult?.(result);
|
|
279
|
+
const models = normalizeModels({ models: result.models, defaultModelOption: config.defaultModelOption }, { configOptions: result.configOptions });
|
|
280
|
+
finishProbe({ run, fn: run.resolve, value: models });
|
|
281
|
+
}
|
|
282
|
+
function handleProbeMessage({ run, raw }) {
|
|
283
|
+
const obj = asObject({ value: raw });
|
|
284
|
+
const rpcErr = rpcErrorMessage({ raw });
|
|
285
|
+
if (rpcErr) {
|
|
286
|
+
handleProbeRpcError({ run, obj, rpcErr });
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const result = asObject({ value: obj?.result });
|
|
290
|
+
if (obj?.id !== run.expectedId || !result)
|
|
291
|
+
return;
|
|
292
|
+
handleProbeResult(run, result);
|
|
293
|
+
}
|
|
294
|
+
function handleProbeStdout({ run, parser, chunk }) {
|
|
295
|
+
run.stdoutBytes += Buffer.byteLength(String(chunk), 'utf8');
|
|
296
|
+
if (run.stdoutBytes > 8 * 1024 * 1024) {
|
|
297
|
+
failProbe({ run, message: 'ACP metadata output exceeded its limit' });
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
parser.feed({ chunk: chunk });
|
|
301
|
+
}
|
|
302
|
+
function handleProbeClose({ run, parser, exit }) {
|
|
303
|
+
run.closed = true;
|
|
304
|
+
parser.flush();
|
|
305
|
+
if (run.settled)
|
|
306
|
+
return;
|
|
307
|
+
const errTail = run.stderrBuf.trim();
|
|
308
|
+
const suffix = errTail ? ` stderr=${errTail}` : '';
|
|
309
|
+
failProbe({
|
|
310
|
+
run,
|
|
311
|
+
message: `ACP model detection exited code=${exit.code} signal=${exit.signal ?? 'none'}${suffix}`,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
function wireProbeListeners(run) {
|
|
315
|
+
const { child } = run;
|
|
316
|
+
const parser = createJsonLineStream({
|
|
317
|
+
onMessage: ({ message: raw }) => handleProbeMessage({ run, raw }),
|
|
318
|
+
}, { onError: error => failProbe({ run, message: error.message }) });
|
|
319
|
+
child.stdout.on('data', (chunk) => handleProbeStdout({ run, parser, chunk }));
|
|
320
|
+
child.stdout.on('close', () => parser.flush());
|
|
321
|
+
child.stdin.on('error', (err) => failProbe({ run, message: `stdin error: ${err.message}` }));
|
|
322
|
+
child.stderr.on('data', (chunk) => {
|
|
323
|
+
run.stderrBuf = `${run.stderrBuf}${chunk}`.slice(-16_000);
|
|
324
|
+
});
|
|
325
|
+
child.on('error', (err) => failProbe({ run, message: `spawn failed: ${err.message}` }));
|
|
326
|
+
child.on('close', (code, signal) => handleProbeClose({ run, parser, exit: { code, signal } }));
|
|
327
|
+
}
|
|
328
|
+
function startProbe({ config, resolve, reject }) {
|
|
329
|
+
if (config.signal?.aborted)
|
|
330
|
+
throw new Error('ACP model detection aborted');
|
|
331
|
+
const child = config.spawnProcess(config.bin, config.args, {
|
|
332
|
+
cwd: config.cwd,
|
|
333
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
334
|
+
env: { ...config.env },
|
|
335
|
+
});
|
|
336
|
+
child.stdout.setEncoding('utf8');
|
|
337
|
+
child.stderr.setEncoding('utf8');
|
|
338
|
+
const run = {
|
|
339
|
+
config, child, resolve, reject, settled: false, closed: false, stderrBuf: '', stdoutBytes: 0,
|
|
340
|
+
expectedId: 1, timer: null, abort: () => failProbe({ run, message: 'ACP model detection aborted' }),
|
|
341
|
+
};
|
|
342
|
+
config.signal?.addEventListener('abort', run.abort, { once: true });
|
|
343
|
+
wireProbeListeners(run);
|
|
344
|
+
if (config.effectiveTimeoutMs > 0) {
|
|
345
|
+
run.timer = setTimeout(() => {
|
|
346
|
+
failProbe({ run, message: `ACP model detection timed out after ${config.effectiveTimeoutMs}ms` });
|
|
347
|
+
}, config.effectiveTimeoutMs);
|
|
348
|
+
}
|
|
349
|
+
writeProbeRpc(run, { id: 1, method: 'initialize', params: {
|
|
321
350
|
protocolVersion: ACP_PROTOCOL_VERSION,
|
|
322
351
|
clientCapabilities: { terminal: false },
|
|
323
|
-
clientInfo: { name: clientName, version: clientVersion },
|
|
324
|
-
});
|
|
325
|
-
});
|
|
352
|
+
clientInfo: { name: config.clientName, version: config.clientVersion },
|
|
353
|
+
} });
|
|
326
354
|
}
|
|
327
355
|
/**
|
|
328
356
|
* Ends a finished probe and completes after close, or after exit plus a pipe-drain grace.
|
|
@@ -378,7 +406,7 @@ function finishAcpProbeProcess({ child, complete }, _optionalArgs = {}) {
|
|
|
378
406
|
export async function detectAcpModelMetadata(requiredArgs, optionalArgs = {}) {
|
|
379
407
|
let currentModelId = null;
|
|
380
408
|
const models = await detectAcpModels(requiredArgs, { ...optionalArgs, onSessionResult: (result) => {
|
|
381
|
-
currentModelId = currentModelFromSessionResult(result);
|
|
409
|
+
currentModelId = currentModelFromSessionResult({ result });
|
|
382
410
|
optionalArgs.onSessionResult?.(result);
|
|
383
411
|
} });
|
|
384
412
|
return { models: models.filter((model) => model.id !== 'default').map((model) => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* acp/types and acp/json; consumed by acp/session.ts and acp/models.ts.
|
|
5
5
|
*/
|
|
6
6
|
import type { JsonRpcId, RpcWritable } from './types.js';
|
|
7
|
-
import type { RuntimeBuildOptions } from '
|
|
7
|
+
import type { RuntimeBuildOptions } from '@jini-ai/core/contracts/agents';
|
|
8
8
|
/**
|
|
9
9
|
* Writes a JSON-RPC 2.0 request frame to `writable` as a single newline-terminated
|
|
10
10
|
* line. Used to send ACP method calls (e.g. `initialize`, `session/new`,
|
|
@@ -15,7 +15,12 @@ import type { RuntimeBuildOptions } from '../../types.js';
|
|
|
15
15
|
* @param method - The RPC method name.
|
|
16
16
|
* @param params - The method parameter payload (any JSON-serialisable value).
|
|
17
17
|
*/
|
|
18
|
-
export declare function sendRpc(writable
|
|
18
|
+
export declare function sendRpc({ writable, id, method, params }: {
|
|
19
|
+
writable: RpcWritable;
|
|
20
|
+
id: JsonRpcId;
|
|
21
|
+
method: string;
|
|
22
|
+
params: unknown;
|
|
23
|
+
}, _optional?: Record<string, never>): void;
|
|
19
24
|
/**
|
|
20
25
|
* Writes a JSON-RPC 2.0 result response frame to `writable`. Used to reply to
|
|
21
26
|
* incoming `session/request_permission` calls from an ACP agent.
|
|
@@ -24,7 +29,17 @@ export declare function sendRpc(writable: RpcWritable, id: JsonRpcId, method: st
|
|
|
24
29
|
* @param id - The id from the incoming request being answered.
|
|
25
30
|
* @param result - The result payload to include in the response.
|
|
26
31
|
*/
|
|
27
|
-
export declare function sendRpcResult(writable
|
|
32
|
+
export declare function sendRpcResult({ writable, id, result }: {
|
|
33
|
+
writable: RpcWritable;
|
|
34
|
+
id: JsonRpcId;
|
|
35
|
+
result: unknown;
|
|
36
|
+
}, _optional?: Record<string, never>): void;
|
|
37
|
+
export declare function sendRpcError({ writable, id, code, message }: {
|
|
38
|
+
writable: RpcWritable;
|
|
39
|
+
id: JsonRpcId;
|
|
40
|
+
code: number;
|
|
41
|
+
message: string;
|
|
42
|
+
}, _optional?: Record<string, never>): void;
|
|
28
43
|
/**
|
|
29
44
|
* Type guard that returns `true` when `value` is a valid JSON-RPC id
|
|
30
45
|
* (a `number` or `string`). Used before replying to incoming requests.
|
|
@@ -38,7 +53,9 @@ export declare function isJsonRpcId(value: unknown): value is JsonRpcId;
|
|
|
38
53
|
* @param raw - A parsed JSON-RPC response object (unknown shape).
|
|
39
54
|
* @returns A non-empty error message string, or `''` when not an error response.
|
|
40
55
|
*/
|
|
41
|
-
export declare function rpcErrorMessage(raw
|
|
56
|
+
export declare function rpcErrorMessage({ raw }: {
|
|
57
|
+
raw: unknown;
|
|
58
|
+
}, _optional?: Record<string, never>): string;
|
|
42
59
|
/**
|
|
43
60
|
* Extracts the structured `data` field from a JSON-RPC error response's `error`
|
|
44
61
|
* object, if present. Used to retrieve typed failure details (e.g. `retryable`,
|
|
@@ -47,7 +64,9 @@ export declare function rpcErrorMessage(raw: unknown): string;
|
|
|
47
64
|
* @param raw - A parsed JSON-RPC response object (unknown shape).
|
|
48
65
|
* @returns The `error.data` value, or `undefined` when absent.
|
|
49
66
|
*/
|
|
50
|
-
export declare function rpcErrorData(raw
|
|
67
|
+
export declare function rpcErrorData({ raw }: {
|
|
68
|
+
raw: unknown;
|
|
69
|
+
}, _optional?: Record<string, never>): unknown;
|
|
51
70
|
/**
|
|
52
71
|
* Reads the `retryable` boolean from a structured RPC error `data` payload.
|
|
53
72
|
* Returns `undefined` when the field is absent so callers can distinguish
|
|
@@ -55,7 +74,9 @@ export declare function rpcErrorData(raw: unknown): unknown;
|
|
|
55
74
|
*
|
|
56
75
|
* @param data - The value of `error.data` extracted via `rpcErrorData`.
|
|
57
76
|
*/
|
|
58
|
-
export declare function rpcErrorRetryable(data
|
|
77
|
+
export declare function rpcErrorRetryable({ data }: {
|
|
78
|
+
data: unknown;
|
|
79
|
+
}, _optional?: Record<string, never>): boolean | undefined;
|
|
59
80
|
/**
|
|
60
81
|
* Promotes an opencode `ROLE_MARKER_HALLUCINATION` error embedded in an ACP
|
|
61
82
|
* JSON-RPC `error.data` payload into a canonical, structured error object.
|
|
@@ -67,7 +88,10 @@ export declare function rpcErrorRetryable(data: unknown): boolean | undefined;
|
|
|
67
88
|
* @param fallbackMessage - Used when the payload's `message` field is blank.
|
|
68
89
|
* @returns A structured error payload, or `null` when not applicable.
|
|
69
90
|
*/
|
|
70
|
-
export declare function promotedOpenCodeSessionErrorPayload(data
|
|
91
|
+
export declare function promotedOpenCodeSessionErrorPayload({ data, fallbackMessage }: {
|
|
92
|
+
data: unknown;
|
|
93
|
+
fallbackMessage: string;
|
|
94
|
+
}, _optional?: Record<string, never>): {
|
|
71
95
|
message: string;
|
|
72
96
|
error: {
|
|
73
97
|
code: string;
|
|
@@ -95,7 +119,9 @@ export interface FormattedUsage {
|
|
|
95
119
|
* @param usage - The raw `result.usage` value from a `session/prompt` response.
|
|
96
120
|
* @returns A `FormattedUsage` object with at least one field, or `null`.
|
|
97
121
|
*/
|
|
98
|
-
export declare function formatUsage(usage
|
|
122
|
+
export declare function formatUsage({ usage }: {
|
|
123
|
+
usage: unknown;
|
|
124
|
+
}, _optional?: Record<string, never>): FormattedUsage | null;
|
|
99
125
|
/**
|
|
100
126
|
* Selects the best permission-outcome `optionId` to reply with when an ACP
|
|
101
127
|
* agent sends a `session/request_permission` request. Bypass permits only
|
|
@@ -107,5 +133,7 @@ export declare function formatUsage(usage: unknown): FormattedUsage | null;
|
|
|
107
133
|
* @returns An offered `optionId`, or `null` when no safe choice exists.
|
|
108
134
|
* @complexity O(n) time and O(1) space for n offered options.
|
|
109
135
|
*/
|
|
110
|
-
export declare function choosePermissionOutcome(options
|
|
136
|
+
export declare function choosePermissionOutcome({ options }: {
|
|
137
|
+
options: unknown;
|
|
138
|
+
}, policy?: Pick<RuntimeBuildOptions, 'permissionMode' | 'cliParity'>): string | null;
|
|
111
139
|
//# sourceMappingURL=rpc.d.ts.map
|
|
@@ -9,7 +9,7 @@ import { asObject } from './json.js';
|
|
|
9
9
|
* @param method - The RPC method name.
|
|
10
10
|
* @param params - The method parameter payload (any JSON-serialisable value).
|
|
11
11
|
*/
|
|
12
|
-
export function sendRpc(writable, id, method, params) {
|
|
12
|
+
export function sendRpc({ writable, id, method, params }, _optional = {}) {
|
|
13
13
|
writable.write(`${JSON.stringify({ jsonrpc: '2.0', id, method, params })}\n`);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
@@ -20,9 +20,12 @@ export function sendRpc(writable, id, method, params) {
|
|
|
20
20
|
* @param id - The id from the incoming request being answered.
|
|
21
21
|
* @param result - The result payload to include in the response.
|
|
22
22
|
*/
|
|
23
|
-
export function sendRpcResult(writable, id, result) {
|
|
23
|
+
export function sendRpcResult({ writable, id, result }, _optional = {}) {
|
|
24
24
|
writable.write(`${JSON.stringify({ jsonrpc: '2.0', id, result })}\n`);
|
|
25
25
|
}
|
|
26
|
+
export function sendRpcError({ writable, id, code, message }, _optional = {}) {
|
|
27
|
+
writable.write(`${JSON.stringify({ jsonrpc: '2.0', id, error: { code, message } })}\n`);
|
|
28
|
+
}
|
|
26
29
|
/**
|
|
27
30
|
* Type guard that returns `true` when `value` is a valid JSON-RPC id
|
|
28
31
|
* (a `number` or `string`). Used before replying to incoming requests.
|
|
@@ -38,9 +41,9 @@ export function isJsonRpcId(value) {
|
|
|
38
41
|
* @param raw - A parsed JSON-RPC response object (unknown shape).
|
|
39
42
|
* @returns A non-empty error message string, or `''` when not an error response.
|
|
40
43
|
*/
|
|
41
|
-
export function rpcErrorMessage(raw) {
|
|
42
|
-
const obj = asObject(raw);
|
|
43
|
-
const error = asObject(obj?.error);
|
|
44
|
+
export function rpcErrorMessage({ raw }, _optional = {}) {
|
|
45
|
+
const obj = asObject({ value: raw });
|
|
46
|
+
const error = asObject({ value: obj?.error });
|
|
44
47
|
if (!obj || !error) {
|
|
45
48
|
return '';
|
|
46
49
|
}
|
|
@@ -58,9 +61,9 @@ export function rpcErrorMessage(raw) {
|
|
|
58
61
|
* @param raw - A parsed JSON-RPC response object (unknown shape).
|
|
59
62
|
* @returns The `error.data` value, or `undefined` when absent.
|
|
60
63
|
*/
|
|
61
|
-
export function rpcErrorData(raw) {
|
|
62
|
-
const obj = asObject(raw);
|
|
63
|
-
const error = asObject(obj?.error);
|
|
64
|
+
export function rpcErrorData({ raw }, _optional = {}) {
|
|
65
|
+
const obj = asObject({ value: raw });
|
|
66
|
+
const error = asObject({ value: obj?.error });
|
|
64
67
|
return error && 'data' in error ? error.data : undefined;
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
@@ -70,8 +73,8 @@ export function rpcErrorData(raw) {
|
|
|
70
73
|
*
|
|
71
74
|
* @param data - The value of `error.data` extracted via `rpcErrorData`.
|
|
72
75
|
*/
|
|
73
|
-
export function rpcErrorRetryable(data) {
|
|
74
|
-
const details = asObject(data);
|
|
76
|
+
export function rpcErrorRetryable({ data }, _optional = {}) {
|
|
77
|
+
const details = asObject({ value: data });
|
|
75
78
|
return typeof details?.retryable === 'boolean' ? details.retryable : undefined;
|
|
76
79
|
}
|
|
77
80
|
/**
|
|
@@ -85,8 +88,8 @@ export function rpcErrorRetryable(data) {
|
|
|
85
88
|
* @param fallbackMessage - Used when the payload's `message` field is blank.
|
|
86
89
|
* @returns A structured error payload, or `null` when not applicable.
|
|
87
90
|
*/
|
|
88
|
-
export function promotedOpenCodeSessionErrorPayload(data, fallbackMessage) {
|
|
89
|
-
const details = asObject(data);
|
|
91
|
+
export function promotedOpenCodeSessionErrorPayload({ data, fallbackMessage }, _optional = {}) {
|
|
92
|
+
const details = asObject({ value: data });
|
|
90
93
|
if (details?.kind !== 'opencode_session_error' ||
|
|
91
94
|
details.source !== 'opencode' ||
|
|
92
95
|
details.code !== 'ROLE_MARKER_HALLUCINATION') {
|
|
@@ -117,8 +120,8 @@ export function promotedOpenCodeSessionErrorPayload(data, fallbackMessage) {
|
|
|
117
120
|
* @param usage - The raw `result.usage` value from a `session/prompt` response.
|
|
118
121
|
* @returns A `FormattedUsage` object with at least one field, or `null`.
|
|
119
122
|
*/
|
|
120
|
-
export function formatUsage(usage) {
|
|
121
|
-
const src = asObject(usage);
|
|
123
|
+
export function formatUsage({ usage }, _optional = {}) {
|
|
124
|
+
const src = asObject({ value: usage });
|
|
122
125
|
if (!src)
|
|
123
126
|
return null;
|
|
124
127
|
const out = {};
|
|
@@ -146,13 +149,13 @@ export function formatUsage(usage) {
|
|
|
146
149
|
* @returns An offered `optionId`, or `null` when no safe choice exists.
|
|
147
150
|
* @complexity O(n) time and O(1) space for n offered options.
|
|
148
151
|
*/
|
|
149
|
-
export function choosePermissionOutcome(options, policy = {}) {
|
|
152
|
+
export function choosePermissionOutcome({ options }, policy = {}) {
|
|
150
153
|
const list = Array.isArray(options) ? options : [];
|
|
151
154
|
const bypassKinds = policy.cliParity ? ['allow_once', 'allow_always', 'reject_once', 'reject_always'] : ['allow_once', 'reject_once', 'reject_always'];
|
|
152
155
|
const kinds = policy.permissionMode === 'bypass' ? bypassKinds : ['reject_once', 'reject_always'];
|
|
153
156
|
for (const kind of kinds) {
|
|
154
157
|
const option = list.find((value) => {
|
|
155
|
-
const record = asObject(value);
|
|
158
|
+
const record = asObject({ value });
|
|
156
159
|
return record?.kind === kind && typeof record.optionId === 'string' && record.optionId.length > 0;
|
|
157
160
|
});
|
|
158
161
|
if (option)
|
|
@@ -53,5 +53,8 @@ export declare function buildAcpSessionNewParams({ cwd }: {
|
|
|
53
53
|
* @param imagePaths - Optional image attachment paths to append.
|
|
54
54
|
* @returns An array of prompt blocks ready for inclusion in `session/prompt` params.
|
|
55
55
|
*/
|
|
56
|
-
export declare function buildPromptBlocks(prompt
|
|
56
|
+
export declare function buildPromptBlocks({ prompt, imagePaths }: {
|
|
57
|
+
prompt: string;
|
|
58
|
+
imagePaths: string[];
|
|
59
|
+
}, _optional?: Record<string, never>): Array<Record<string, string>>;
|
|
57
60
|
//# sourceMappingURL=session-params.d.ts.map
|
|
@@ -73,7 +73,7 @@ function normalizeMcpEnv({ rawEnv, wantsMap }) {
|
|
|
73
73
|
* @param imagePaths - Optional image attachment paths to append.
|
|
74
74
|
* @returns An array of prompt blocks ready for inclusion in `session/prompt` params.
|
|
75
75
|
*/
|
|
76
|
-
export function buildPromptBlocks(prompt, imagePaths) {
|
|
76
|
+
export function buildPromptBlocks({ prompt, imagePaths }, _optional = {}) {
|
|
77
77
|
const blocks = [{ type: 'text', text: prompt }];
|
|
78
78
|
for (const imagePath of imagePaths) {
|
|
79
79
|
if (typeof imagePath !== 'string' || imagePath.trim().length === 0)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @module agent-protocol/acp/session-permission
|
|
2
|
+
* Answers an ACP agent's `session/request_permission` calls for one attached
|
|
3
|
+
* session: well-formed option filtering, the default policy, the injected
|
|
4
|
+
* `onPermissionRequest` handler, and fail-closed cancellation. Split out of
|
|
5
|
+
* `session-run.ts` to keep each module under the file-size limit.
|
|
6
|
+
*/
|
|
7
|
+
import type { UnknownRecord } from './types.js';
|
|
8
|
+
import { type AcpRun } from './session-run.js';
|
|
9
|
+
export declare function replyPermission({ run, raw }: {
|
|
10
|
+
run: AcpRun;
|
|
11
|
+
raw: UnknownRecord;
|
|
12
|
+
}, _optional?: Record<string, never>): void;
|
|
13
|
+
//# sourceMappingURL=session-permission.d.ts.map
|