@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
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { createAgentModelDiscovery } from '../../model-discovery-native.js';
|
|
2
|
+
import { execAgentFile } from '../shared.js';
|
|
3
|
+
const AMR_MODELS_TIMEOUT_MS = 10_000;
|
|
4
|
+
const AMR_MODELS_RETRY_DELAYS_MS = [250, 750];
|
|
5
|
+
// AMR is the vela CLI's ACP stdio mode. `vela agent run --runtime opencode`
|
|
6
|
+
// starts a private OpenCode server and forwards stream-json over ACP JSON-RPC.
|
|
7
|
+
// Required env (supplied by the host process environment):
|
|
8
|
+
// VELA_RUNTIME_KEY — OpenRouter (or compatible) API key
|
|
9
|
+
// VELA_LINK_URL — OpenAI-compatible endpoint, e.g. https://openrouter.ai/api/v1
|
|
10
|
+
// VELA_OPENCODE_BIN — optional; absolute path to opencode when not on PATH
|
|
11
|
+
// See docs/new-agent-runtime-acp.md and the vela
|
|
12
|
+
// `specs/current/runtime/manual-agent-run-openrouter.md`.
|
|
13
|
+
//
|
|
14
|
+
// Model wiring notes:
|
|
15
|
+
//
|
|
16
|
+
// 1. vela rejects `session/prompt` until `session/set_model` has been
|
|
17
|
+
// called, so AMR cannot accept the synthetic `default` model id —
|
|
18
|
+
// attachAcpSession skips set_model whenever model === 'default'.
|
|
19
|
+
//
|
|
20
|
+
// 2. Vela 0.0.1 exposes the current link-supported catalog through
|
|
21
|
+
// `vela models`, but that command prints public ids such as
|
|
22
|
+
// `public_model_deepseek_v3_2`. The ACP `session/set_model` call accepts
|
|
23
|
+
// the link-facing slug (`deepseek-v3.2` / `glm-5.1`), so this adapter
|
|
24
|
+
// normalizes those public ids at the spawn boundary until Vela exposes
|
|
25
|
+
// canonical ACP ids directly.
|
|
26
|
+
export function normalizeVelaModelId({ rawId }, _optional = {}) {
|
|
27
|
+
const withoutPrefix = stripPrefix({ value: stripPrefix({ value: rawId.trim(), prefix: 'vela/' }), prefix: 'public_model_' });
|
|
28
|
+
if (!withoutPrefix)
|
|
29
|
+
return null;
|
|
30
|
+
const alias = VELA_MODEL_ID_ALIASES.find(([pattern]) => pattern.test(withoutPrefix));
|
|
31
|
+
if (alias)
|
|
32
|
+
return alias[1];
|
|
33
|
+
return normalizeKnownVelaVersionId(withoutPrefix) ?? withoutPrefix.replace(/_/g, '-');
|
|
34
|
+
}
|
|
35
|
+
/** Compact Vela public ids whose link-facing slug is not a plain underscore-to-dash rewrite. */
|
|
36
|
+
const VELA_MODEL_ID_ALIASES = [
|
|
37
|
+
[/^deepseek_v3_2$/i, 'deepseek-v3.2'],
|
|
38
|
+
[/^deepseek-v3-2$/i, 'deepseek-v3.2'],
|
|
39
|
+
[/^kimi_k2_6$/i, 'kimi-k2.6'],
|
|
40
|
+
[/^kimi_k2_7_code$/i, 'kimi-k2.7-code'],
|
|
41
|
+
[/^glm_5_1$/i, 'glm-5.1'],
|
|
42
|
+
[/^glm_5$/i, 'glm-5'],
|
|
43
|
+
];
|
|
44
|
+
function stripPrefix({ value, prefix }) {
|
|
45
|
+
return value.startsWith(prefix) ? value.slice(prefix.length) : value;
|
|
46
|
+
}
|
|
47
|
+
// Every capture group below is a mandatory (non-optional) part of its
|
|
48
|
+
// pattern — `(haiku|opus|sonnet)` is a required alternation and `(\d+)`
|
|
49
|
+
// requires 1+ digit characters — so none can be empty/undefined when the
|
|
50
|
+
// overall regex matches. `family` needs an explicit assertion because it's
|
|
51
|
+
// the only capture with a method called on it directly; the others type-check
|
|
52
|
+
// fine interpolated bare (`noUncheckedIndexedAccess` types them
|
|
53
|
+
// `string | undefined`, but TypeScript doesn't restrict template-literal
|
|
54
|
+
// interpolation the way it restricts a method call on a possibly-undefined
|
|
55
|
+
// value).
|
|
56
|
+
function normalizeKnownVelaVersionId(rawId) {
|
|
57
|
+
const claude = /^claude[_-](haiku|opus|sonnet)[_-](\d+)[_-](\d+)(?!\d)(.*)$/i.exec(rawId);
|
|
58
|
+
if (claude) {
|
|
59
|
+
const [, family, major, minor, suffix = ''] = claude;
|
|
60
|
+
return `claude-${family.toLowerCase()}-${major}.${minor}${suffix.replace(/_/g, '-')}`;
|
|
61
|
+
}
|
|
62
|
+
const gpt = /^gpt_(\d+)_(\d+)(?!\d)(.*)$/i.exec(rawId);
|
|
63
|
+
if (gpt) {
|
|
64
|
+
const [, major, minor, suffix = ''] = gpt;
|
|
65
|
+
return `gpt-${major}.${minor}${suffix.replace(/_/g, '-')}`;
|
|
66
|
+
}
|
|
67
|
+
const gemini = /^gemini_(\d+)_(\d+)(?!\d)(.*)$/i.exec(rawId);
|
|
68
|
+
if (gemini) {
|
|
69
|
+
const [, major, minor, suffix = ''] = gemini;
|
|
70
|
+
return `gemini-${major}.${minor}${suffix.replace(/_/g, '-')}`;
|
|
71
|
+
}
|
|
72
|
+
const minimax = /^minimax_m(\d+)_(\d+)(?!\d)(.*)$/i.exec(rawId);
|
|
73
|
+
if (minimax) {
|
|
74
|
+
const [, major, minor, suffix = ''] = minimax;
|
|
75
|
+
return `minimax-m${major}.${minor}${suffix.replace(/_/g, '-')}`;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
function isVelaChatModelId(modelId) {
|
|
80
|
+
// Temporary chat-surface guard: Vela already lists media-generation models,
|
|
81
|
+
// but this AMR runtime adapter currently drives only chat completions.
|
|
82
|
+
// Remove this filter when AMR grows first-class image/video execution.
|
|
83
|
+
const id = modelId.toLowerCase();
|
|
84
|
+
if (id.startsWith('gpt-image-'))
|
|
85
|
+
return false;
|
|
86
|
+
if (id.startsWith('seedance-'))
|
|
87
|
+
return false;
|
|
88
|
+
if (id.startsWith('doubao-seedance-'))
|
|
89
|
+
return false;
|
|
90
|
+
if (id.startsWith('veo-'))
|
|
91
|
+
return false;
|
|
92
|
+
if (id.startsWith('imagen-'))
|
|
93
|
+
return false;
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
export function parseVelaModels({ stdout }, _optional = {}) {
|
|
97
|
+
const ids = [];
|
|
98
|
+
for (const line of String(stdout || '').split('\n')) {
|
|
99
|
+
const trimmed = line.trim();
|
|
100
|
+
if (!trimmed || trimmed.startsWith('#'))
|
|
101
|
+
continue;
|
|
102
|
+
// `trimmed` is already non-empty and has no leading whitespace (checked
|
|
103
|
+
// above), so its first whitespace-split token is always non-empty too.
|
|
104
|
+
const rawId = trimmed.split(/\s+/)[0];
|
|
105
|
+
ids.push(normalizeVelaModelId({ rawId: rawId }));
|
|
106
|
+
}
|
|
107
|
+
return collectChatModels(ids);
|
|
108
|
+
}
|
|
109
|
+
export function parseVelaModelJson({ stdout, expectedSource }, _optional = {}) {
|
|
110
|
+
const data = parseVelaModelJsonData({ stdout, expectedSource });
|
|
111
|
+
return collectChatModels(data.map((item) => {
|
|
112
|
+
const rawId = item && typeof item === 'object'
|
|
113
|
+
? item.id
|
|
114
|
+
: null;
|
|
115
|
+
return typeof rawId === 'string' ? rawId.trim() : '';
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
/** Validates the `{ source, data: [...] }` envelope and returns its `data` array. */
|
|
119
|
+
function parseVelaModelJsonData({ stdout, expectedSource }) {
|
|
120
|
+
let parsed;
|
|
121
|
+
try {
|
|
122
|
+
parsed = JSON.parse(stdout);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
throw new Error(`Invalid vela model JSON: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
126
|
+
}
|
|
127
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
128
|
+
throw new Error('Invalid vela model JSON: expected object');
|
|
129
|
+
}
|
|
130
|
+
const source = parsed.source;
|
|
131
|
+
if (source !== expectedSource) {
|
|
132
|
+
throw new Error(`Invalid vela model JSON source: expected ${expectedSource}, got ${String(source)}`);
|
|
133
|
+
}
|
|
134
|
+
const data = parsed.data;
|
|
135
|
+
if (!Array.isArray(data)) {
|
|
136
|
+
throw new Error('Invalid vela model JSON: expected data array');
|
|
137
|
+
}
|
|
138
|
+
return data;
|
|
139
|
+
}
|
|
140
|
+
/** First occurrence of each non-empty chat model id, in discovered order. */
|
|
141
|
+
function collectChatModels(ids) {
|
|
142
|
+
const seen = new Set();
|
|
143
|
+
const models = [];
|
|
144
|
+
for (const id of ids) {
|
|
145
|
+
if (!id || seen.has(id) || !isVelaChatModelId(id))
|
|
146
|
+
continue;
|
|
147
|
+
seen.add(id);
|
|
148
|
+
models.push({ id, label: id });
|
|
149
|
+
}
|
|
150
|
+
return orderAmrChatModels(models);
|
|
151
|
+
}
|
|
152
|
+
// Discovered order is kept; the user's saved choice is preselected elsewhere. No hard-coded preference.
|
|
153
|
+
function orderAmrChatModels(models) {
|
|
154
|
+
return [...models];
|
|
155
|
+
}
|
|
156
|
+
function sleep(ms) {
|
|
157
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
158
|
+
}
|
|
159
|
+
function velaModelsErrorMessage(error) {
|
|
160
|
+
if (error instanceof Error)
|
|
161
|
+
return error.message;
|
|
162
|
+
return String(error ?? '');
|
|
163
|
+
}
|
|
164
|
+
function isRetriableVelaModelsError(error) {
|
|
165
|
+
const message = velaModelsErrorMessage(error).toLowerCase();
|
|
166
|
+
return [
|
|
167
|
+
'deadline exceeded',
|
|
168
|
+
'timed out',
|
|
169
|
+
'timeout',
|
|
170
|
+
'temporarily unavailable',
|
|
171
|
+
'temporary failure',
|
|
172
|
+
'econnreset',
|
|
173
|
+
'econnrefused',
|
|
174
|
+
'enotfound',
|
|
175
|
+
'502',
|
|
176
|
+
'503',
|
|
177
|
+
'504',
|
|
178
|
+
].some((pattern) => message.includes(pattern));
|
|
179
|
+
}
|
|
180
|
+
export async function fetchVelaPresetModels({ resolvedBin, env }, _optional = {}) {
|
|
181
|
+
const { stdout } = await execAgentFile({ command: resolvedBin, args: ['model', 'preset', '--format', 'json'] }, { options: {
|
|
182
|
+
env,
|
|
183
|
+
timeout: AMR_MODELS_TIMEOUT_MS,
|
|
184
|
+
maxBuffer: 1024 * 1024,
|
|
185
|
+
} });
|
|
186
|
+
return parseVelaModelJson({ stdout: String(stdout), expectedSource: 'preset' });
|
|
187
|
+
}
|
|
188
|
+
export async function fetchVelaRemoteModelsWithRetry({ resolvedBin, env }) {
|
|
189
|
+
// One attempt per retry delay, each followed by that delay when it fails with a retriable
|
|
190
|
+
// error; a non-retriable error (including a malformed catalog) is thrown at once. The final
|
|
191
|
+
// attempt after the last delay is not retried, so whatever it throws propagates as-is.
|
|
192
|
+
for (const delayMs of AMR_MODELS_RETRY_DELAYS_MS) {
|
|
193
|
+
try {
|
|
194
|
+
return await fetchVelaRemoteModelsOnce({ resolvedBin, env });
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
if (!isRetriableVelaModelsError(error))
|
|
198
|
+
throw error;
|
|
199
|
+
}
|
|
200
|
+
await sleep(delayMs);
|
|
201
|
+
}
|
|
202
|
+
return fetchVelaRemoteModelsOnce({ resolvedBin, env });
|
|
203
|
+
}
|
|
204
|
+
async function fetchVelaRemoteModelsOnce({ resolvedBin, env }) {
|
|
205
|
+
const { stdout } = await execAgentFile({ command: resolvedBin, args: ['model', 'list', '--format', 'json'] }, { options: {
|
|
206
|
+
env,
|
|
207
|
+
timeout: AMR_MODELS_TIMEOUT_MS,
|
|
208
|
+
maxBuffer: 1024 * 1024,
|
|
209
|
+
} });
|
|
210
|
+
return parseVelaModelJson({ stdout: String(stdout), expectedSource: 'remote' });
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Read the signed-in account's billing summary via the vela CLI — the same
|
|
214
|
+
* data source used for models, so balance/tier come through the versioned CLI
|
|
215
|
+
* contract rather than a separate HTTP call. Returns total available balance
|
|
216
|
+
* and the real membership tier.
|
|
217
|
+
*/
|
|
218
|
+
export async function fetchVelaBillingSummary({ resolvedBin, env }, _optional = {}) {
|
|
219
|
+
const { stdout } = await execAgentFile({ command: resolvedBin, args: ['billing', 'summary', '--format', 'json'] }, { options: { env, timeout: AMR_MODELS_TIMEOUT_MS, maxBuffer: 1024 * 1024 } });
|
|
220
|
+
const data = JSON.parse(String(stdout));
|
|
221
|
+
// Use `balanceUsd` — the same field the console wallet page renders as the
|
|
222
|
+
// headline "余额" — so the two surfaces always agree. Fall back to the total
|
|
223
|
+
// available only if `balanceUsd` is missing.
|
|
224
|
+
const balanceUsd = [data.balanceUsd, data.totalAvailableCreditsUsd].find((value) => typeof value === 'string') ?? null;
|
|
225
|
+
// `membershipTier` is omitted for free accounts. A SUCCESSFUL summary with no
|
|
226
|
+
// tier therefore means "free" — normalize to the explicit sentinel so the UI
|
|
227
|
+
// shows the plan and the Upgrade CTA for free users. "Unknown" (billing
|
|
228
|
+
// unavailable) is signalled separately by the fetch rejecting → null account,
|
|
229
|
+
// never by an absent tier on a successful read.
|
|
230
|
+
const tier = typeof data.membershipTier === 'string' && data.membershipTier.trim()
|
|
231
|
+
? data.membershipTier.trim()
|
|
232
|
+
: 'free';
|
|
233
|
+
return { plan: tier, balanceUsd };
|
|
234
|
+
}
|
|
235
|
+
export const amrAgentDef = {
|
|
236
|
+
// UNVERIFIED live integration locally; source/category and limits are documented in model-discovery-adapters.ts.
|
|
237
|
+
...createAgentModelDiscovery('amr', { fallbackModels: () => amrAgentDef.fallbackModels, parse: ({ stdout }) => parseVelaModelJson({ stdout, expectedSource: 'remote' }) }),
|
|
238
|
+
id: 'amr',
|
|
239
|
+
name: 'AMR',
|
|
240
|
+
bin: 'vela',
|
|
241
|
+
versionArgs: ['--version'],
|
|
242
|
+
fetchModels: fetchVelaRemoteModelsWithRetry,
|
|
243
|
+
// Fail closed when Vela's live catalog is unavailable. Stale static
|
|
244
|
+
// fallbacks let users select models that link/opencode no longer accepts.
|
|
245
|
+
fallbackModels: [],
|
|
246
|
+
buildArgs: () => ['agent', 'run', '--runtime', 'opencode'],
|
|
247
|
+
streamFormat: 'acp-json-rpc',
|
|
248
|
+
// AMR is a genuine ACP-native def (same `acp-json-rpc` transport as devin/hermes/kilo/kimi/
|
|
249
|
+
// kiro/reasonix/trae-cli/vibe), so it gets the caller's external MCP servers the same way those
|
|
250
|
+
// 8 do: merged into the `session/new` `mcpServers` array. `buildMcpBridgeDelivery` dispatches on
|
|
251
|
+
// this declared strategy alone, never on `def.id`, so this one field is the whole fix — no
|
|
252
|
+
// `agent-executor.ts` change needed. Previously undeclared here only because this def was ported
|
|
253
|
+
// after the other 8 and the field was missed, not because vela lacks the transport.
|
|
254
|
+
externalMcpInjection: 'acp-merge',
|
|
255
|
+
// vela resumes the upstream OpenCode session via ACP session/load across
|
|
256
|
+
// turns (the OpenCode session store persists per conversation), so the daemon
|
|
257
|
+
// captures the durable handle, skips the transcript resend on resume, and
|
|
258
|
+
// maps vela's resume_failed onto the reseed path. See resumesSessionViaAcpLoad.
|
|
259
|
+
resumesSessionViaAcpLoad: true,
|
|
260
|
+
// Vela routes model selection through ACP's `session/set_model` and only
|
|
261
|
+
// accepts ids that survived the `vela models` preflight check, so a
|
|
262
|
+
// free-text "Custom" id silently fails at spawn. The model picker
|
|
263
|
+
// surfaces the live Vela catalog instead.
|
|
264
|
+
supportsCustomModel: false,
|
|
265
|
+
// vela's ACP transport carries images as `resource_link` prompt blocks —
|
|
266
|
+
// see `agent-protocol/acp/session-params.ts#buildPromptBlocks`, shared by
|
|
267
|
+
// every `acp-json-rpc` def, confirmed live to receive `imagePaths` from
|
|
268
|
+
// `agent-executor.ts#wireAcpLifecycle` for all 9 of them, not just AMR.
|
|
269
|
+
imageDelivery: 'native',
|
|
270
|
+
// Daemon-process env override for emergency operator pinning. Normal UI
|
|
271
|
+
// selection comes from the live `vela models` catalog and is preflighted
|
|
272
|
+
// before spawn.
|
|
273
|
+
defaultModelEnvVar: 'VELA_DEFAULT_MODEL',
|
|
274
|
+
// Vela/OpenCode can spend extended stretches silent while the upstream
|
|
275
|
+
// provider is still working. Keep the outer chat watchdog aligned with the
|
|
276
|
+
// 30-minute ACP stage timeout so the daemon does not fail the run first.
|
|
277
|
+
inactivityTimeoutMs: 30 * 60 * 1000,
|
|
278
|
+
};
|
|
279
|
+
//# sourceMappingURL=index.js.map
|
package/dist/defs/amr.d.ts
CHANGED
|
@@ -1,69 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export type VelaModelJsonSource = 'preset' | 'remote';
|
|
3
|
-
export declare function normalizeVelaModelId({ rawId }: {
|
|
4
|
-
rawId: string;
|
|
5
|
-
}): string | null;
|
|
6
|
-
export declare function parseVelaModels({ stdout }: {
|
|
7
|
-
stdout: string;
|
|
8
|
-
}): RuntimeModelOption[];
|
|
9
|
-
export declare function parseVelaModelJson({ stdout, expectedSource }: {
|
|
10
|
-
stdout: string;
|
|
11
|
-
expectedSource: VelaModelJsonSource;
|
|
12
|
-
}): RuntimeModelOption[];
|
|
13
|
-
export declare function fetchVelaPresetModels({ resolvedBin, env }: {
|
|
14
|
-
resolvedBin: string;
|
|
15
|
-
env: NodeJS.ProcessEnv;
|
|
16
|
-
}): Promise<RuntimeModelOption[]>;
|
|
17
|
-
export declare function fetchVelaRemoteModelsWithRetry({ resolvedBin, env }: {
|
|
18
|
-
resolvedBin: string;
|
|
19
|
-
env: NodeJS.ProcessEnv;
|
|
20
|
-
}): Promise<RuntimeModelOption[]>;
|
|
21
|
-
/** Live account fields parsed from `vela billing summary --format json`. */
|
|
22
|
-
export interface VelaBillingSummary {
|
|
23
|
-
/** Real subscription tier (e.g. "max"); absent for free accounts. */
|
|
24
|
-
plan?: string;
|
|
25
|
-
/** Total available balance in USD (string), or null when unavailable. */
|
|
26
|
-
balanceUsd?: string | null;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Read the signed-in account's billing summary via the vela CLI — the same
|
|
30
|
-
* data source used for models, so balance/tier come through the versioned CLI
|
|
31
|
-
* contract rather than a separate HTTP call. Returns total available balance
|
|
32
|
-
* and the real membership tier.
|
|
33
|
-
*/
|
|
34
|
-
export declare function fetchVelaBillingSummary({ resolvedBin, env }: {
|
|
35
|
-
resolvedBin: string;
|
|
36
|
-
env: NodeJS.ProcessEnv;
|
|
37
|
-
}): Promise<VelaBillingSummary>;
|
|
38
|
-
export declare const amrAgentDef: {
|
|
39
|
-
id: string;
|
|
40
|
-
name: string;
|
|
41
|
-
bin: string;
|
|
42
|
-
versionArgs: string[];
|
|
43
|
-
fetchModels: typeof fetchVelaRemoteModelsWithRetry;
|
|
44
|
-
fallbackModels: RuntimeModelOption[];
|
|
45
|
-
buildArgs: () => string[];
|
|
46
|
-
streamFormat: string;
|
|
47
|
-
externalMcpInjection: "acp-merge";
|
|
48
|
-
resumesSessionViaAcpLoad: true;
|
|
49
|
-
supportsCustomModel: false;
|
|
50
|
-
imageDelivery: "native";
|
|
51
|
-
defaultModelEnvVar: string;
|
|
52
|
-
inactivityTimeoutMs: number;
|
|
53
|
-
discoverModels(requiredArgs: {
|
|
54
|
-
context: import("../model-discovery-types.js").ModelDiscoveryContext;
|
|
55
|
-
}, optionalArgs?: {
|
|
56
|
-
signal?: AbortSignal;
|
|
57
|
-
force?: boolean;
|
|
58
|
-
staleWhileRevalidate?: boolean;
|
|
59
|
-
deps?: import("../model-discovery-types.js").ModelDiscoveryDeps;
|
|
60
|
-
}): Promise<import("../model-discovery-types.js").ModelCatalogSnapshot>;
|
|
61
|
-
resolveDefaultModel(requiredArgs: {
|
|
62
|
-
context: import("../model-discovery-types.js").ModelDiscoveryContext;
|
|
63
|
-
catalog: import("../model-discovery-types.js").ModelCatalogSnapshot;
|
|
64
|
-
}, optionalArgs?: {
|
|
65
|
-
signal?: AbortSignal;
|
|
66
|
-
deps?: import("../model-discovery-types.js").ModelDiscoveryDeps;
|
|
67
|
-
}): Promise<import("../model-discovery-types.js").DefaultModelResolution>;
|
|
68
|
-
};
|
|
1
|
+
export * from './amr/index.js';
|
|
69
2
|
//# sourceMappingURL=amr.d.ts.map
|
package/dist/defs/amr.js
CHANGED
|
@@ -1,292 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { execAgentFile } from './shared.js';
|
|
3
|
-
const AMR_MODELS_TIMEOUT_MS = 10_000;
|
|
4
|
-
const AMR_MODELS_RETRY_DELAYS_MS = [250, 750];
|
|
5
|
-
const PREFERRED_AMR_CHAT_MODEL_ORDER = [
|
|
6
|
-
'deepseek-v4-flash',
|
|
7
|
-
'deepseek-v3.2',
|
|
8
|
-
'glm-5.1',
|
|
9
|
-
'gemini-2.5-flash',
|
|
10
|
-
];
|
|
11
|
-
const PREFERRED_AMR_CHAT_MODEL_RANK = new Map(PREFERRED_AMR_CHAT_MODEL_ORDER.map((id, index) => [id, index]));
|
|
12
|
-
// AMR is the vela CLI's ACP stdio mode. `vela agent run --runtime opencode`
|
|
13
|
-
// starts a private OpenCode server and forwards stream-json over ACP JSON-RPC.
|
|
14
|
-
// Required env (supplied by the host process environment):
|
|
15
|
-
// VELA_RUNTIME_KEY — OpenRouter (or compatible) API key
|
|
16
|
-
// VELA_LINK_URL — OpenAI-compatible endpoint, e.g. https://openrouter.ai/api/v1
|
|
17
|
-
// VELA_OPENCODE_BIN — optional; absolute path to opencode when not on PATH
|
|
18
|
-
// See docs/new-agent-runtime-acp.md and the vela
|
|
19
|
-
// `specs/current/runtime/manual-agent-run-openrouter.md`.
|
|
20
|
-
//
|
|
21
|
-
// Model wiring notes:
|
|
22
|
-
//
|
|
23
|
-
// 1. vela rejects `session/prompt` until `session/set_model` has been
|
|
24
|
-
// called, so AMR cannot accept the synthetic `default` model id —
|
|
25
|
-
// attachAcpSession skips set_model whenever model === 'default'.
|
|
26
|
-
//
|
|
27
|
-
// 2. Vela 0.0.1 exposes the current link-supported catalog through
|
|
28
|
-
// `vela models`, but that command prints public ids such as
|
|
29
|
-
// `public_model_deepseek_v3_2`. The ACP `session/set_model` call accepts
|
|
30
|
-
// the link-facing slug (`deepseek-v3.2` / `glm-5.1`), so this adapter
|
|
31
|
-
// normalizes those public ids at the spawn boundary until Vela exposes
|
|
32
|
-
// canonical ACP ids directly.
|
|
33
|
-
export function normalizeVelaModelId({ rawId }) {
|
|
34
|
-
const withoutPrefix = stripPrefix({ value: stripPrefix({ value: rawId.trim(), prefix: 'vela/' }), prefix: 'public_model_' });
|
|
35
|
-
if (!withoutPrefix)
|
|
36
|
-
return null;
|
|
37
|
-
const alias = VELA_MODEL_ID_ALIASES.find(([pattern]) => pattern.test(withoutPrefix));
|
|
38
|
-
if (alias)
|
|
39
|
-
return alias[1];
|
|
40
|
-
return normalizeKnownVelaVersionId(withoutPrefix) ?? withoutPrefix.replace(/_/g, '-');
|
|
41
|
-
}
|
|
42
|
-
/** Compact Vela public ids whose link-facing slug is not a plain underscore-to-dash rewrite. */
|
|
43
|
-
const VELA_MODEL_ID_ALIASES = [
|
|
44
|
-
[/^deepseek_v3_2$/i, 'deepseek-v3.2'],
|
|
45
|
-
[/^deepseek-v3-2$/i, 'deepseek-v3.2'],
|
|
46
|
-
[/^kimi_k2_6$/i, 'kimi-k2.6'],
|
|
47
|
-
[/^kimi_k2_7_code$/i, 'kimi-k2.7-code'],
|
|
48
|
-
[/^glm_5_1$/i, 'glm-5.1'],
|
|
49
|
-
[/^glm_5$/i, 'glm-5'],
|
|
50
|
-
];
|
|
51
|
-
function stripPrefix({ value, prefix }) {
|
|
52
|
-
return value.startsWith(prefix) ? value.slice(prefix.length) : value;
|
|
53
|
-
}
|
|
54
|
-
// Every capture group below is a mandatory (non-optional) part of its
|
|
55
|
-
// pattern — `(haiku|opus|sonnet)` is a required alternation and `(\d+)`
|
|
56
|
-
// requires 1+ digit characters — so none can be empty/undefined when the
|
|
57
|
-
// overall regex matches. `family` needs an explicit assertion because it's
|
|
58
|
-
// the only capture with a method called on it directly; the others type-check
|
|
59
|
-
// fine interpolated bare (`noUncheckedIndexedAccess` types them
|
|
60
|
-
// `string | undefined`, but TypeScript doesn't restrict template-literal
|
|
61
|
-
// interpolation the way it restricts a method call on a possibly-undefined
|
|
62
|
-
// value).
|
|
63
|
-
function normalizeKnownVelaVersionId(rawId) {
|
|
64
|
-
const claude = /^claude[_-](haiku|opus|sonnet)[_-](\d+)[_-](\d+)(?!\d)(.*)$/i.exec(rawId);
|
|
65
|
-
if (claude) {
|
|
66
|
-
const [, family, major, minor, suffix = ''] = claude;
|
|
67
|
-
return `claude-${family.toLowerCase()}-${major}.${minor}${suffix.replace(/_/g, '-')}`;
|
|
68
|
-
}
|
|
69
|
-
const gpt = /^gpt_(\d+)_(\d+)(?!\d)(.*)$/i.exec(rawId);
|
|
70
|
-
if (gpt) {
|
|
71
|
-
const [, major, minor, suffix = ''] = gpt;
|
|
72
|
-
return `gpt-${major}.${minor}${suffix.replace(/_/g, '-')}`;
|
|
73
|
-
}
|
|
74
|
-
const gemini = /^gemini_(\d+)_(\d+)(?!\d)(.*)$/i.exec(rawId);
|
|
75
|
-
if (gemini) {
|
|
76
|
-
const [, major, minor, suffix = ''] = gemini;
|
|
77
|
-
return `gemini-${major}.${minor}${suffix.replace(/_/g, '-')}`;
|
|
78
|
-
}
|
|
79
|
-
const minimax = /^minimax_m(\d+)_(\d+)(?!\d)(.*)$/i.exec(rawId);
|
|
80
|
-
if (minimax) {
|
|
81
|
-
const [, major, minor, suffix = ''] = minimax;
|
|
82
|
-
return `minimax-m${major}.${minor}${suffix.replace(/_/g, '-')}`;
|
|
83
|
-
}
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
function isVelaChatModelId(modelId) {
|
|
87
|
-
// Temporary chat-surface guard: Vela already lists media-generation models,
|
|
88
|
-
// but this AMR runtime adapter currently drives only chat completions.
|
|
89
|
-
// Remove this filter when AMR grows first-class image/video execution.
|
|
90
|
-
const id = modelId.toLowerCase();
|
|
91
|
-
if (id.startsWith('gpt-image-'))
|
|
92
|
-
return false;
|
|
93
|
-
if (id.startsWith('seedance-'))
|
|
94
|
-
return false;
|
|
95
|
-
if (id.startsWith('doubao-seedance-'))
|
|
96
|
-
return false;
|
|
97
|
-
if (id.startsWith('veo-'))
|
|
98
|
-
return false;
|
|
99
|
-
if (id.startsWith('imagen-'))
|
|
100
|
-
return false;
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
export function parseVelaModels({ stdout }) {
|
|
104
|
-
const ids = [];
|
|
105
|
-
for (const line of String(stdout || '').split('\n')) {
|
|
106
|
-
const trimmed = line.trim();
|
|
107
|
-
if (!trimmed || trimmed.startsWith('#'))
|
|
108
|
-
continue;
|
|
109
|
-
// `trimmed` is already non-empty and has no leading whitespace (checked
|
|
110
|
-
// above), so its first whitespace-split token is always non-empty too.
|
|
111
|
-
const rawId = trimmed.split(/\s+/)[0];
|
|
112
|
-
ids.push(normalizeVelaModelId({ rawId: rawId }));
|
|
113
|
-
}
|
|
114
|
-
return collectChatModels(ids);
|
|
115
|
-
}
|
|
116
|
-
export function parseVelaModelJson({ stdout, expectedSource }) {
|
|
117
|
-
const data = parseVelaModelJsonData({ stdout, expectedSource });
|
|
118
|
-
return collectChatModels(data.map((item) => {
|
|
119
|
-
const rawId = item && typeof item === 'object'
|
|
120
|
-
? item.id
|
|
121
|
-
: null;
|
|
122
|
-
return typeof rawId === 'string' ? rawId.trim() : '';
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
125
|
-
/** Validates the `{ source, data: [...] }` envelope and returns its `data` array. */
|
|
126
|
-
function parseVelaModelJsonData({ stdout, expectedSource }) {
|
|
127
|
-
let parsed;
|
|
128
|
-
try {
|
|
129
|
-
parsed = JSON.parse(stdout);
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
throw new Error(`Invalid vela model JSON: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
133
|
-
}
|
|
134
|
-
if (!parsed || typeof parsed !== 'object') {
|
|
135
|
-
throw new Error('Invalid vela model JSON: expected object');
|
|
136
|
-
}
|
|
137
|
-
const source = parsed.source;
|
|
138
|
-
if (source !== expectedSource) {
|
|
139
|
-
throw new Error(`Invalid vela model JSON source: expected ${expectedSource}, got ${String(source)}`);
|
|
140
|
-
}
|
|
141
|
-
const data = parsed.data;
|
|
142
|
-
if (!Array.isArray(data)) {
|
|
143
|
-
throw new Error('Invalid vela model JSON: expected data array');
|
|
144
|
-
}
|
|
145
|
-
return data;
|
|
146
|
-
}
|
|
147
|
-
/** First occurrence of each non-empty chat model id, in preferred AMR chat order. */
|
|
148
|
-
function collectChatModels(ids) {
|
|
149
|
-
const seen = new Set();
|
|
150
|
-
const models = [];
|
|
151
|
-
for (const id of ids) {
|
|
152
|
-
if (!id || seen.has(id) || !isVelaChatModelId(id))
|
|
153
|
-
continue;
|
|
154
|
-
seen.add(id);
|
|
155
|
-
models.push({ id, label: id });
|
|
156
|
-
}
|
|
157
|
-
return orderAmrChatModels(models);
|
|
158
|
-
}
|
|
159
|
-
function orderAmrChatModels(models) {
|
|
160
|
-
return models
|
|
161
|
-
.map((model, index) => ({ model, index }))
|
|
162
|
-
.sort((a, b) => {
|
|
163
|
-
const aRank = PREFERRED_AMR_CHAT_MODEL_RANK.get(a.model.id) ?? Number.MAX_SAFE_INTEGER;
|
|
164
|
-
const bRank = PREFERRED_AMR_CHAT_MODEL_RANK.get(b.model.id) ?? Number.MAX_SAFE_INTEGER;
|
|
165
|
-
return aRank - bRank || a.index - b.index;
|
|
166
|
-
})
|
|
167
|
-
.map(({ model }) => model);
|
|
168
|
-
}
|
|
169
|
-
function sleep(ms) {
|
|
170
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
171
|
-
}
|
|
172
|
-
function velaModelsErrorMessage(error) {
|
|
173
|
-
if (error instanceof Error)
|
|
174
|
-
return error.message;
|
|
175
|
-
return String(error ?? '');
|
|
176
|
-
}
|
|
177
|
-
function isRetriableVelaModelsError(error) {
|
|
178
|
-
const message = velaModelsErrorMessage(error).toLowerCase();
|
|
179
|
-
return [
|
|
180
|
-
'deadline exceeded',
|
|
181
|
-
'timed out',
|
|
182
|
-
'timeout',
|
|
183
|
-
'temporarily unavailable',
|
|
184
|
-
'temporary failure',
|
|
185
|
-
'econnreset',
|
|
186
|
-
'econnrefused',
|
|
187
|
-
'enotfound',
|
|
188
|
-
'502',
|
|
189
|
-
'503',
|
|
190
|
-
'504',
|
|
191
|
-
].some((pattern) => message.includes(pattern));
|
|
192
|
-
}
|
|
193
|
-
export async function fetchVelaPresetModels({ resolvedBin, env }) {
|
|
194
|
-
const { stdout } = await execAgentFile({ command: resolvedBin, args: ['model', 'preset', '--format', 'json'] }, { options: {
|
|
195
|
-
env,
|
|
196
|
-
timeout: AMR_MODELS_TIMEOUT_MS,
|
|
197
|
-
maxBuffer: 1024 * 1024,
|
|
198
|
-
} });
|
|
199
|
-
return parseVelaModelJson({ stdout: String(stdout), expectedSource: 'preset' });
|
|
200
|
-
}
|
|
201
|
-
export async function fetchVelaRemoteModelsWithRetry({ resolvedBin, env }) {
|
|
202
|
-
// One attempt per retry delay, each followed by that delay when it fails with a retriable
|
|
203
|
-
// error; a non-retriable error (including a malformed catalog) is thrown at once. The final
|
|
204
|
-
// attempt after the last delay is not retried, so whatever it throws propagates as-is.
|
|
205
|
-
for (const delayMs of AMR_MODELS_RETRY_DELAYS_MS) {
|
|
206
|
-
try {
|
|
207
|
-
return await fetchVelaRemoteModelsOnce({ resolvedBin, env });
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
if (!isRetriableVelaModelsError(error))
|
|
211
|
-
throw error;
|
|
212
|
-
}
|
|
213
|
-
await sleep(delayMs);
|
|
214
|
-
}
|
|
215
|
-
return fetchVelaRemoteModelsOnce({ resolvedBin, env });
|
|
216
|
-
}
|
|
217
|
-
async function fetchVelaRemoteModelsOnce({ resolvedBin, env }) {
|
|
218
|
-
const { stdout } = await execAgentFile({ command: resolvedBin, args: ['model', 'list', '--format', 'json'] }, { options: {
|
|
219
|
-
env,
|
|
220
|
-
timeout: AMR_MODELS_TIMEOUT_MS,
|
|
221
|
-
maxBuffer: 1024 * 1024,
|
|
222
|
-
} });
|
|
223
|
-
return parseVelaModelJson({ stdout: String(stdout), expectedSource: 'remote' });
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Read the signed-in account's billing summary via the vela CLI — the same
|
|
227
|
-
* data source used for models, so balance/tier come through the versioned CLI
|
|
228
|
-
* contract rather than a separate HTTP call. Returns total available balance
|
|
229
|
-
* and the real membership tier.
|
|
230
|
-
*/
|
|
231
|
-
export async function fetchVelaBillingSummary({ resolvedBin, env }) {
|
|
232
|
-
const { stdout } = await execAgentFile({ command: resolvedBin, args: ['billing', 'summary', '--format', 'json'] }, { options: { env, timeout: AMR_MODELS_TIMEOUT_MS, maxBuffer: 1024 * 1024 } });
|
|
233
|
-
const data = JSON.parse(String(stdout));
|
|
234
|
-
// Use `balanceUsd` — the same field the console wallet page renders as the
|
|
235
|
-
// headline "余额" — so the two surfaces always agree. Fall back to the total
|
|
236
|
-
// available only if `balanceUsd` is missing.
|
|
237
|
-
const balanceUsd = [data.balanceUsd, data.totalAvailableCreditsUsd].find((value) => typeof value === 'string') ?? null;
|
|
238
|
-
// `membershipTier` is omitted for free accounts. A SUCCESSFUL summary with no
|
|
239
|
-
// tier therefore means "free" — normalize to the explicit sentinel so the UI
|
|
240
|
-
// shows the plan and the Upgrade CTA for free users. "Unknown" (billing
|
|
241
|
-
// unavailable) is signalled separately by the fetch rejecting → null account,
|
|
242
|
-
// never by an absent tier on a successful read.
|
|
243
|
-
const tier = typeof data.membershipTier === 'string' && data.membershipTier.trim()
|
|
244
|
-
? data.membershipTier.trim()
|
|
245
|
-
: 'free';
|
|
246
|
-
return { plan: tier, balanceUsd };
|
|
247
|
-
}
|
|
248
|
-
export const amrAgentDef = {
|
|
249
|
-
// UNVERIFIED live integration locally; source/category and limits are documented in model-discovery-adapters.ts.
|
|
250
|
-
...createAgentModelDiscovery('amr', { fallbackModels: () => amrAgentDef.fallbackModels, parse: ({ stdout }) => parseVelaModelJson({ stdout, expectedSource: 'remote' }) }),
|
|
251
|
-
id: 'amr',
|
|
252
|
-
name: 'AMR',
|
|
253
|
-
bin: 'vela',
|
|
254
|
-
versionArgs: ['--version'],
|
|
255
|
-
fetchModels: fetchVelaRemoteModelsWithRetry,
|
|
256
|
-
// Fail closed when Vela's live catalog is unavailable. Stale static
|
|
257
|
-
// fallbacks let users select models that link/opencode no longer accepts.
|
|
258
|
-
fallbackModels: [],
|
|
259
|
-
buildArgs: () => ['agent', 'run', '--runtime', 'opencode'],
|
|
260
|
-
streamFormat: 'acp-json-rpc',
|
|
261
|
-
// AMR is a genuine ACP-native def (same `acp-json-rpc` transport as devin/hermes/kilo/kimi/
|
|
262
|
-
// kiro/reasonix/trae-cli/vibe), so it gets the caller's external MCP servers the same way those
|
|
263
|
-
// 8 do: merged into the `session/new` `mcpServers` array. `buildMcpBridgeDelivery` dispatches on
|
|
264
|
-
// this declared strategy alone, never on `def.id`, so this one field is the whole fix — no
|
|
265
|
-
// `agent-executor.ts` change needed. Previously undeclared here only because this def was ported
|
|
266
|
-
// after the other 8 and the field was missed, not because vela lacks the transport.
|
|
267
|
-
externalMcpInjection: 'acp-merge',
|
|
268
|
-
// vela resumes the upstream OpenCode session via ACP session/load across
|
|
269
|
-
// turns (the OpenCode session store persists per conversation), so the daemon
|
|
270
|
-
// captures the durable handle, skips the transcript resend on resume, and
|
|
271
|
-
// maps vela's resume_failed onto the reseed path. See resumesSessionViaAcpLoad.
|
|
272
|
-
resumesSessionViaAcpLoad: true,
|
|
273
|
-
// Vela routes model selection through ACP's `session/set_model` and only
|
|
274
|
-
// accepts ids that survived the `vela models` preflight check, so a
|
|
275
|
-
// free-text "Custom" id silently fails at spawn. The model picker
|
|
276
|
-
// surfaces the live Vela catalog instead.
|
|
277
|
-
supportsCustomModel: false,
|
|
278
|
-
// vela's ACP transport carries images as `resource_link` prompt blocks —
|
|
279
|
-
// see `agent-protocol/acp/session-params.ts#buildPromptBlocks`, shared by
|
|
280
|
-
// every `acp-json-rpc` def, confirmed live to receive `imagePaths` from
|
|
281
|
-
// `agent-executor.ts#wireAcpLifecycle` for all 9 of them, not just AMR.
|
|
282
|
-
imageDelivery: 'native',
|
|
283
|
-
// Daemon-process env override for emergency operator pinning. Normal UI
|
|
284
|
-
// selection comes from the live `vela models` catalog and is preflighted
|
|
285
|
-
// before spawn.
|
|
286
|
-
defaultModelEnvVar: 'VELA_DEFAULT_MODEL',
|
|
287
|
-
// Vela/OpenCode can spend extended stretches silent while the upstream
|
|
288
|
-
// provider is still working. Keep the outer chat watchdog aligned with the
|
|
289
|
-
// 30-minute ACP stage timeout so the daemon does not fail the run first.
|
|
290
|
-
inactivityTimeoutMs: 30 * 60 * 1000,
|
|
291
|
-
};
|
|
1
|
+
export * from './amr/index.js';
|
|
292
2
|
//# sourceMappingURL=amr.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function antigravityAuthGuidance({}: {}, { hostName }?: {
|
|
2
|
+
hostName?: string;
|
|
3
|
+
}): string;
|
|
4
|
+
export declare function antigravityQuotaGuidance(): string;
|
|
5
|
+
export declare function isAntigravityAuthFailureText({ text }: {
|
|
6
|
+
text: string;
|
|
7
|
+
}): boolean;
|
|
8
|
+
export declare const antigravityAuthProfile: {
|
|
9
|
+
isFailure: typeof isAntigravityAuthFailureText;
|
|
10
|
+
guidance: ({ hostName }: {
|
|
11
|
+
hostName: string;
|
|
12
|
+
}) => string;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=auth.d.ts.map
|