refactor(coding-agent): replace AgentSessionRuntimeHost with closure-based AgentSessionRuntime

- Replace AgentSessionRuntimeHost and bootstrap abstractions with AgentSessionRuntime
- Runtime creation is now closure-based via CreateAgentSessionRuntimeFactory
- Factory closes over process-global fixed inputs, recreates cwd-bound services per effective cwd
- Session config (model, thinking, tools, scoped models) re-resolved per target cwd
- CLI resource paths resolved once at startup as absolute paths
- Swap lifecycle: teardown old, create next, apply next (hard fail on creation error)
- Unified diagnostics model (info/warning/error) for args, services, session resolution, resources
- No logging or process exits inside creation/parsing logic
- Removed session_directory support
- Removed session_switch and session_fork extension events (use session_start with reason)
- Moved package/config CLI to package-manager-cli.ts
- Fixed theme init for --resume session picker
- Fixed flaky reftable footer test (content-based polling)
- Fixed silent drop of unknown single-dash CLI flags
- Added error diagnostics for missing explicit CLI resource paths
- Updated SDK docs, examples, plans, exports, tests, changelog

fixes #2753
This commit is contained in:
Mario Zechner
2026-04-03 20:14:12 +02:00
parent 042066b982
commit 9f9277ccdd
38 changed files with 2180 additions and 1366 deletions

View File

@@ -1554,23 +1554,6 @@ export const MODELS = {
contextWindow: 200000,
maxTokens: 64000,
} satisfies Model<"anthropic-messages">,
"claude-3-7-sonnet-latest": {
id: "claude-3-7-sonnet-latest",
name: "Claude Sonnet 3.7 (latest)",
api: "anthropic-messages",
provider: "anthropic",
baseUrl: "https://api.anthropic.com",
reasoning: true,
input: ["text", "image"],
cost: {
input: 3,
output: 15,
cacheRead: 0.3,
cacheWrite: 3.75,
},
contextWindow: 200000,
maxTokens: 64000,
} satisfies Model<"anthropic-messages">,
"claude-3-haiku-20240307": {
id: "claude-3-haiku-20240307",
name: "Claude Haiku 3",
@@ -6480,40 +6463,6 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 65536,
} satisfies Model<"openai-completions">,
"mimo-v2-omni-free": {
id: "mimo-v2-omni-free",
name: "MiMo V2 Omni Free",
api: "openai-completions",
provider: "opencode",
baseUrl: "https://opencode.ai/zen/v1",
reasoning: true,
input: ["text", "image"],
cost: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
maxTokens: 64000,
} satisfies Model<"openai-completions">,
"mimo-v2-pro-free": {
id: "mimo-v2-pro-free",
name: "MiMo V2 Pro Free",
api: "openai-completions",
provider: "opencode",
baseUrl: "https://opencode.ai/zen/v1",
reasoning: true,
input: ["text"],
cost: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 1048576,
maxTokens: 64000,
} satisfies Model<"openai-completions">,
"minimax-m2.5": {
id: "minimax-m2.5",
name: "MiniMax M2.5",
@@ -6562,9 +6511,26 @@ export const MODELS = {
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 1000000,
contextWindow: 204800,
maxTokens: 128000,
} satisfies Model<"openai-completions">,
"qwen3.6-plus-free": {
id: "qwen3.6-plus-free",
name: "Qwen3.6 Plus Free",
api: "openai-completions",
provider: "opencode",
baseUrl: "https://opencode.ai/zen/v1",
reasoning: true,
input: ["text"],
cost: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 1048576,
maxTokens: 64000,
} satisfies Model<"openai-completions">,
},
"opencode-go": {
"glm-5": {
@@ -6601,12 +6567,46 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 65536,
} satisfies Model<"openai-completions">,
"mimo-v2-omni": {
id: "mimo-v2-omni",
name: "MiMo V2 Omni",
api: "openai-completions",
provider: "opencode-go",
baseUrl: "https://opencode.ai/zen/go/v1",
reasoning: true,
input: ["text", "image"],
cost: {
input: 0.4,
output: 2,
cacheRead: 0.08,
cacheWrite: 0,
},
contextWindow: 262144,
maxTokens: 64000,
} satisfies Model<"openai-completions">,
"mimo-v2-pro": {
id: "mimo-v2-pro",
name: "MiMo V2 Pro",
api: "openai-completions",
provider: "opencode-go",
baseUrl: "https://opencode.ai/zen/go/v1",
reasoning: true,
input: ["text"],
cost: {
input: 1,
output: 3,
cacheRead: 0.2,
cacheWrite: 0,
},
contextWindow: 1048576,
maxTokens: 64000,
} satisfies Model<"openai-completions">,
"minimax-m2.5": {
id: "minimax-m2.5",
name: "MiniMax M2.5",
api: "anthropic-messages",
api: "openai-completions",
provider: "opencode-go",
baseUrl: "https://opencode.ai/zen/go",
baseUrl: "https://opencode.ai/zen/go/v1",
reasoning: true,
input: ["text"],
cost: {
@@ -6617,7 +6617,7 @@ export const MODELS = {
},
contextWindow: 204800,
maxTokens: 131072,
} satisfies Model<"anthropic-messages">,
} satisfies Model<"openai-completions">,
"minimax-m2.7": {
id: "minimax-m2.7",
name: "MiniMax M2.7",
@@ -7011,6 +7011,23 @@ export const MODELS = {
contextWindow: 131000,
maxTokens: 4096,
} satisfies Model<"openai-completions">,
"arcee-ai/trinity-large-thinking": {
id: "arcee-ai/trinity-large-thinking",
name: "Arcee AI: Trinity Large Thinking",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
reasoning: true,
input: ["text"],
cost: {
input: 0.22,
output: 0.85,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
maxTokens: 262144,
} satisfies Model<"openai-completions">,
"arcee-ai/trinity-mini": {
id: "arcee-ai/trinity-mini",
name: "Arcee AI: Trinity Mini",
@@ -7451,7 +7468,7 @@ export const MODELS = {
cacheWrite: 0.08333333333333334,
},
contextWindow: 1048576,
maxTokens: 65536,
maxTokens: 65535,
} satisfies Model<"openai-completions">,
"google/gemini-2.5-pro": {
id: "google/gemini-2.5-pro",
@@ -7572,6 +7589,23 @@ export const MODELS = {
contextWindow: 1048576,
maxTokens: 65536,
} satisfies Model<"openai-completions">,
"google/gemma-4-31b-it": {
id: "google/gemma-4-31b-it",
name: "Google: Gemma 4 31B",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
reasoning: true,
input: ["text", "image"],
cost: {
input: 0.14,
output: 0.39999999999999997,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
"inception/mercury": {
id: "inception/mercury",
name: "Inception: Mercury",
@@ -7623,23 +7657,6 @@ export const MODELS = {
contextWindow: 128000,
maxTokens: 32000,
} satisfies Model<"openai-completions">,
"kwaipilot/kat-coder-pro": {
id: "kwaipilot/kat-coder-pro",
name: "Kwaipilot: KAT-Coder-Pro V1",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
reasoning: false,
input: ["text"],
cost: {
input: 0.207,
output: 0.828,
cacheRead: 0.0414,
cacheWrite: 0,
},
contextWindow: 256000,
maxTokens: 128000,
} satisfies Model<"openai-completions">,
"kwaipilot/kat-coder-pro-v2": {
id: "kwaipilot/kat-coder-pro-v2",
name: "Kwaipilot: KAT-Coder-Pro V2",
@@ -7853,9 +7870,9 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
input: 0.19,
output: 1.15,
cacheRead: 0.095,
input: 0.118,
output: 0.9900000000000001,
cacheRead: 0.059,
cacheWrite: 0,
},
contextWindow: 196608,
@@ -8150,23 +8167,6 @@ export const MODELS = {
contextWindow: 32768,
maxTokens: 4096,
} satisfies Model<"openai-completions">,
"mistralai/mistral-small-24b-instruct-2501": {
id: "mistralai/mistral-small-24b-instruct-2501",
name: "Mistral: Mistral Small 3",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
reasoning: false,
input: ["text"],
cost: {
input: 0.049999999999999996,
output: 0.08,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 32768,
maxTokens: 16384,
} satisfies Model<"openai-completions">,
"mistralai/mistral-small-2603": {
id: "mistralai/mistral-small-2603",
name: "Mistral: Mistral Small 4",
@@ -9221,6 +9221,40 @@ export const MODELS = {
contextWindow: 1050000,
maxTokens: 128000,
} satisfies Model<"openai-completions">,
"openai/gpt-audio": {
id: "openai/gpt-audio",
name: "OpenAI: GPT Audio",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
reasoning: false,
input: ["text"],
cost: {
input: 2.5,
output: 10,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 128000,
maxTokens: 16384,
} satisfies Model<"openai-completions">,
"openai/gpt-audio-mini": {
id: "openai/gpt-audio-mini",
name: "OpenAI: GPT Audio Mini",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
reasoning: false,
input: ["text"],
cost: {
input: 0.6,
output: 2.4,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 128000,
maxTokens: 16384,
} satisfies Model<"openai-completions">,
"openai/gpt-oss-120b": {
id: "openai/gpt-oss-120b",
name: "OpenAI: gpt-oss-120b",
@@ -10188,7 +10222,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 256000,
maxTokens: 65536,
maxTokens: 32768,
} satisfies Model<"openai-completions">,
"qwen/qwen3.5-flash-02-23": {
id: "qwen/qwen3.5-flash-02-23",
@@ -10224,6 +10258,23 @@ export const MODELS = {
contextWindow: 1000000,
maxTokens: 65536,
} satisfies Model<"openai-completions">,
"qwen/qwen3.6-plus:free": {
id: "qwen/qwen3.6-plus:free",
name: "Qwen: Qwen3.6 Plus (free)",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
reasoning: true,
input: ["text", "image"],
cost: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 1000000,
maxTokens: 65536,
} satisfies Model<"openai-completions">,
"qwen/qwq-32b": {
id: "qwen/qwq-32b",
name: "Qwen: QwQ 32B",
@@ -10241,8 +10292,8 @@ export const MODELS = {
contextWindow: 131072,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
"reka/reka-edge": {
id: "reka/reka-edge",
"rekaai/reka-edge": {
id: "rekaai/reka-edge",
name: "Reka Edge",
api: "openai-completions",
provider: "openrouter",
@@ -10320,11 +10371,11 @@ export const MODELS = {
cost: {
input: 0.09999999999999999,
output: 0.3,
cacheRead: 0.02,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
maxTokens: 4096,
maxTokens: 65536,
} satisfies Model<"openai-completions">,
"stepfun/step-3.5-flash:free": {
id: "stepfun/step-3.5-flash:free",
@@ -10530,9 +10581,9 @@ export const MODELS = {
contextWindow: 2000000,
maxTokens: 30000,
} satisfies Model<"openai-completions">,
"x-ai/grok-4.20-beta": {
id: "x-ai/grok-4.20-beta",
name: "xAI: Grok 4.20 Beta",
"x-ai/grok-4.20": {
id: "x-ai/grok-4.20",
name: "xAI: Grok 4.20",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
@@ -10802,6 +10853,23 @@ export const MODELS = {
contextWindow: 202752,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
"z-ai/glm-5v-turbo": {
id: "z-ai/glm-5v-turbo",
name: "Z.ai: GLM 5V Turbo",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
reasoning: true,
input: ["text", "image"],
cost: {
input: 1.2,
output: 4,
cacheRead: 0.24,
cacheWrite: 0,
},
contextWindow: 202752,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
},
"vercel-ai-gateway": {
"alibaba/qwen-3-14b": {
@@ -11059,6 +11127,23 @@ export const MODELS = {
contextWindow: 1000000,
maxTokens: 64000,
} satisfies Model<"anthropic-messages">,
"alibaba/qwen3.6-plus": {
id: "alibaba/qwen3.6-plus",
name: "Qwen 3.6 Plus",
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
input: ["text", "image"],
cost: {
input: 0.5,
output: 3,
cacheRead: 0.09999999999999999,
cacheWrite: 0.625,
},
contextWindow: 1000000,
maxTokens: 64000,
} satisfies Model<"anthropic-messages">,
"anthropic/claude-3-haiku": {
id: "anthropic/claude-3-haiku",
name: "Claude 3 Haiku",
@@ -11297,6 +11382,23 @@ export const MODELS = {
contextWindow: 131000,
maxTokens: 131000,
} satisfies Model<"anthropic-messages">,
"arcee-ai/trinity-large-thinking": {
id: "arcee-ai/trinity-large-thinking",
name: "Trinity Large Thinking",
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
input: ["text"],
cost: {
input: 0.25,
output: 0.8999999999999999,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262100,
maxTokens: 80000,
} satisfies Model<"anthropic-messages">,
"bytedance/seed-1.6": {
id: "bytedance/seed-1.6",
name: "Seed 1.6",
@@ -11586,6 +11688,40 @@ export const MODELS = {
contextWindow: 1000000,
maxTokens: 64000,
} satisfies Model<"anthropic-messages">,
"google/gemma-4-26b-a4b-it": {
id: "google/gemma-4-26b-a4b-it",
name: "Gemma 4 26B A4B IT",
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
input: ["text", "image"],
cost: {
input: 0.13,
output: 0.39999999999999997,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
maxTokens: 131072,
} satisfies Model<"anthropic-messages">,
"google/gemma-4-31b-it": {
id: "google/gemma-4-31b-it",
name: "Gemma 4 31B IT",
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
input: ["text", "image"],
cost: {
input: 0.14,
output: 0.39999999999999997,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
maxTokens: 131072,
} satisfies Model<"anthropic-messages">,
"inception/mercury-2": {
id: "inception/mercury-2",
name: "Mercury 2",
@@ -12090,7 +12226,7 @@ export const MODELS = {
cost: {
input: 0.6,
output: 2.5,
cacheRead: 0.15,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 131072,
@@ -12107,11 +12243,11 @@ export const MODELS = {
cost: {
input: 0.6,
output: 2.5,
cacheRead: 0.15,
cacheRead: 0.3,
cacheWrite: 0,
},
contextWindow: 256000,
maxTokens: 16384,
maxTokens: 128000,
} satisfies Model<"anthropic-messages">,
"moonshotai/kimi-k2-thinking": {
id: "moonshotai/kimi-k2-thinking",
@@ -12700,12 +12836,12 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
input: 0.07,
output: 0.3,
input: 0.049999999999999996,
output: 0.19999999999999998,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 128000,
contextWindow: 131072,
maxTokens: 8192,
} satisfies Model<"anthropic-messages">,
"openai/gpt-oss-safeguard-20b": {
@@ -13388,6 +13524,23 @@ export const MODELS = {
contextWindow: 202800,
maxTokens: 131100,
} satisfies Model<"anthropic-messages">,
"zai/glm-5v-turbo": {
id: "zai/glm-5v-turbo",
name: "GLM 5V Turbo",
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
input: ["text", "image"],
cost: {
input: 1.2,
output: 4,
cacheRead: 0.24,
cacheWrite: 0,
},
contextWindow: 200000,
maxTokens: 128000,
} satisfies Model<"anthropic-messages">,
},
"xai": {
"grok-2": {
@@ -13878,7 +14031,7 @@ export const MODELS = {
api: "openai-completions",
provider: "zai",
baseUrl: "https://api.z.ai/api/coding/paas/v4",
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai"},
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai","zaiToolStream":true},
reasoning: true,
input: ["text"],
cost: {
@@ -13896,7 +14049,7 @@ export const MODELS = {
api: "openai-completions",
provider: "zai",
baseUrl: "https://api.z.ai/api/coding/paas/v4",
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai"},
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai","zaiToolStream":true},
reasoning: true,
input: ["text", "image"],
cost: {
@@ -13914,7 +14067,7 @@ export const MODELS = {
api: "openai-completions",
provider: "zai",
baseUrl: "https://api.z.ai/api/coding/paas/v4",
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai"},
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai","zaiToolStream":true},
reasoning: true,
input: ["text"],
cost: {
@@ -13932,7 +14085,7 @@ export const MODELS = {
api: "openai-completions",
provider: "zai",
baseUrl: "https://api.z.ai/api/coding/paas/v4",
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai"},
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai","zaiToolStream":true},
reasoning: true,
input: ["text"],
cost: {
@@ -13950,7 +14103,7 @@ export const MODELS = {
api: "openai-completions",
provider: "zai",
baseUrl: "https://api.z.ai/api/coding/paas/v4",
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai"},
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai","zaiToolStream":true},
reasoning: true,
input: ["text"],
cost: {
@@ -13968,7 +14121,7 @@ export const MODELS = {
api: "openai-completions",
provider: "zai",
baseUrl: "https://api.z.ai/api/coding/paas/v4",
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai"},
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai","zaiToolStream":true},
reasoning: true,
input: ["text"],
cost: {
@@ -13986,7 +14139,7 @@ export const MODELS = {
api: "openai-completions",
provider: "zai",
baseUrl: "https://api.z.ai/api/coding/paas/v4",
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai"},
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai","zaiToolStream":true},
reasoning: true,
input: ["text"],
cost: {
@@ -13998,5 +14151,23 @@ export const MODELS = {
contextWindow: 200000,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
"glm-5v-turbo": {
id: "glm-5v-turbo",
name: "glm-5v-turbo",
api: "openai-completions",
provider: "zai",
baseUrl: "https://api.z.ai/api/coding/paas/v4",
compat: {"supportsDeveloperRole":false,"thinkingFormat":"zai","zaiToolStream":true},
reasoning: true,
input: ["text", "image"],
cost: {
input: 1.2,
output: 4,
cacheRead: 0.24,
cacheWrite: 0,
},
contextWindow: 200000,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
},
} as const;