@zergai/ztc 0.4.0-beta.1 → 0.4.1-dev.36919234045
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/README.md +8 -1
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/dist/App.js +2 -2
- package/dist/agent/agent.js +41 -5
- package/dist/agent/backends/anthropic.js +5 -10
- package/dist/agent/backends/gemini.js +2 -0
- package/dist/agent/backends/index.d.ts +1 -0
- package/dist/agent/backends/index.js +10 -1
- package/dist/agent/backends/openai.d.ts +0 -6
- package/dist/agent/backends/openai.js +5 -2
- package/dist/agent/backends/openai_compatible.d.ts +2 -0
- package/dist/agent/backends/openai_compatible.js +18 -8
- package/dist/agent/backends/provider_ids.d.ts +1 -0
- package/dist/agent/backends/provider_ids.js +4 -0
- package/dist/agent/backends/types.d.ts +1 -0
- package/dist/agent/backends/zrouter_stream.d.ts +5 -1
- package/dist/agent/backends/zrouter_stream.js +141 -37
- package/dist/agent/commands/compact.js +6 -5
- package/dist/agent/commands/config.js +4 -1
- package/dist/agent/commands/context.js +6 -1
- package/dist/agent/commands/effort.js +14 -6
- package/dist/agent/commands/model.js +12 -2
- package/dist/agent/commands/profile.js +21 -2
- package/dist/agent/commands/provider_selection.js +14 -1
- package/dist/agent/commands/settings.js +45 -7
- package/dist/agent/commands/types.d.ts +19 -0
- package/dist/agent/factory.js +14 -68
- package/dist/agent/subagent.d.ts +0 -10
- package/dist/agent/subagent.js +22 -0
- package/dist/agent/tool_response_store.d.ts +1 -1
- package/dist/agent/tool_response_store.js +4 -2
- package/dist/agent/tools/pane.d.ts +0 -7
- package/dist/agent/tools/pane.js +5 -4
- package/dist/app/command_context.js +33 -10
- package/dist/app/model_catalog_cache.d.ts +5 -0
- package/dist/app/model_catalog_cache.js +138 -0
- package/dist/app/restart.d.ts +1 -1
- package/dist/app/restart.js +16 -5
- package/dist/app/selection_completion.d.ts +17 -2
- package/dist/app/selection_completion.js +74 -6
- package/dist/app/session_manager.js +13 -8
- package/dist/cli_args.js +2 -16
- package/dist/cli_main.js +25 -6
- package/dist/cli_ratatui.js +70 -33
- package/dist/config/defaults.d.ts +2 -1
- package/dist/config/defaults.js +9 -2
- package/dist/config/resolved.d.ts +2 -2
- package/dist/config.d.ts +35 -3
- package/dist/config.js +227 -29
- package/dist/headless.js +2 -0
- package/dist/onboarding/first_run.js +5 -1
- package/dist/panes/model_catalog.d.ts +3 -3
- package/dist/panes/model_catalog.js +28 -4
- package/dist/panes/pane_registry.js +6 -2
- package/dist/panes/types.d.ts +2 -0
- package/dist/panes/ztc_launch.js +12 -0
- package/dist/session.d.ts +6 -2
- package/dist/session.js +65 -10
- package/dist/ui/views/completion_menu.js +10 -5
- package/dist/ui/views/status_bar.js +9 -5
- package/dist/ui/widgets/resume_panel.d.ts +2 -0
- package/dist/ui/widgets/resume_panel.js +17 -15
- package/dist/utils/compaction.d.ts +1 -1
- package/dist/utils/compaction.js +2 -2
- package/dist/utils/context.d.ts +4 -4
- package/dist/utils/context.js +14 -12
- package/dist/utils/deepseek.d.ts +2 -2
- package/dist/utils/deepseek.js +13 -5
- package/dist/utils/model_cache.d.ts +15 -0
- package/dist/utils/model_cache.js +143 -0
- package/dist/utils/models.d.ts +4 -2
- package/dist/utils/models.js +12 -16
- package/dist/utils/reasoning.d.ts +8 -1
- package/dist/utils/reasoning.js +31 -11
- package/dist/utils/router_catalog.d.ts +47 -0
- package/dist/utils/router_catalog.js +222 -0
- package/dist/zlm-embed.mjs +1180 -514
- package/node_modules/@zerg/model-contracts/LICENSE.md +375 -0
- package/node_modules/@zerg/model-contracts/README.md +78 -0
- package/node_modules/@zerg/model-contracts/index.d.ts +18 -0
- package/node_modules/@zerg/model-contracts/index.js +220 -0
- package/node_modules/@zerg/model-contracts/package.json +8 -0
- package/node_modules/glob/node_modules/brace-expansion/index.js +78 -22
- package/node_modules/glob/node_modules/brace-expansion/package.json +1 -1
- package/node_modules/readdir-glob/node_modules/brace-expansion/index.js +78 -22
- package/node_modules/readdir-glob/node_modules/brace-expansion/package.json +1 -1
- package/package.json +9 -6
- package/packages/model-contracts/LICENSE.md +375 -0
- package/packages/model-contracts/README.md +78 -0
- package/packages/model-contracts/index.d.ts +18 -0
- package/packages/model-contracts/index.js +220 -0
- package/packages/model-contracts/package.json +8 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// Exact reviewed contracts. Add a model here after checking its provider wire
|
|
2
|
+
// and effective controls; names and catalog membership are not capability proof.
|
|
3
|
+
const MODEL_CONTRACTS = new Map([
|
|
4
|
+
["openai", new Map([
|
|
5
|
+
["gpt-4o", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":16384}, fallbackRouting: true }],
|
|
6
|
+
["gpt-4o-mini", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":16384}, fallbackRouting: true }],
|
|
7
|
+
["gpt-5", { reasoningEfforts: ["minimal","low","medium","high"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: true }],
|
|
8
|
+
["gpt-5-mini", { reasoningEfforts: ["minimal","low","medium","high"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: true }],
|
|
9
|
+
["gpt-5.2", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: true }],
|
|
10
|
+
["gpt-5.2-codex", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: false }],
|
|
11
|
+
["gpt-5.3-codex", { reasoningEfforts: ["low","medium","high","xhigh"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: false }],
|
|
12
|
+
["gpt-5.4", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], chatToolReasoningEfforts: ["none"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: true }],
|
|
13
|
+
["gpt-5.4-mini", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], chatToolReasoningEfforts: ["none"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: true }],
|
|
14
|
+
["gpt-5.5", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], chatToolReasoningEfforts: ["none"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: true }],
|
|
15
|
+
["gpt-5.6", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], chatToolReasoningEfforts: ["none"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: true }],
|
|
16
|
+
["gpt-5.6-current", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: true }],
|
|
17
|
+
["gpt-5.6-luna", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], chatToolReasoningEfforts: ["none"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: true }],
|
|
18
|
+
["gpt-5.6-sol", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], chatToolReasoningEfforts: ["none"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: true }],
|
|
19
|
+
["gpt-5.6-terra", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], chatToolReasoningEfforts: ["none"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: true }],
|
|
20
|
+
["gpt-6-sol", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], chatToolReasoningEfforts: ["none"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: true }],
|
|
21
|
+
["gpt-6-luna", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], chatToolReasoningEfforts: ["none"], maxOutputTokens: {"min":256,"max":128000}, fallbackRouting: true }],
|
|
22
|
+
])],
|
|
23
|
+
["anthropic", new Map([
|
|
24
|
+
["claude-3-5-haiku-20241022", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":8192}, fallbackRouting: true }],
|
|
25
|
+
["claude-3-5-sonnet-20241022", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":8192}, fallbackRouting: true }],
|
|
26
|
+
["claude-opus-4-6", { reasoningEfforts: ["low","medium","high","max"], maxOutputTokens: {"min":256,"max":8192}, fallbackRouting: true }],
|
|
27
|
+
["claude-opus-4.8", { reasoningEfforts: ["low","medium","high","xhigh","max"], maxOutputTokens: {"min":256,"max":8192}, fallbackRouting: true }],
|
|
28
|
+
["claude-sonnet-4", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":64000}, fallbackRouting: true }],
|
|
29
|
+
["claude-sonnet-4-5", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":64000}, fallbackRouting: true }],
|
|
30
|
+
["claude-sonnet-4-6", { reasoningEfforts: ["low","medium","high","max"], maxOutputTokens: {"min":256,"max":64000}, fallbackRouting: true }],
|
|
31
|
+
["claude-sonnet-4-20250514", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":64000}, fallbackRouting: true }],
|
|
32
|
+
["claude-opus-4-5", { reasoningEfforts: ["low","medium","high","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
33
|
+
["claude-opus-4-8", { reasoningEfforts: ["low","medium","high","xhigh","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
34
|
+
["claude-opus-4-7", { reasoningEfforts: ["low","medium","high","xhigh","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
35
|
+
["claude-opus-5", { reasoningEfforts: ["low","medium","high","xhigh","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
36
|
+
["claude-opus-5-5", { reasoningEfforts: ["low","medium","high","xhigh","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
37
|
+
["claude-sonnet-5", { reasoningEfforts: ["low","medium","high","xhigh","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
38
|
+
["claude-sonnet-5-5", { reasoningEfforts: ["low","medium","high","xhigh","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
39
|
+
["claude-fable-5", { reasoningEfforts: ["low","medium","high","xhigh","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
40
|
+
["claude-fable-5-1", { reasoningEfforts: ["low","medium","high","xhigh","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
41
|
+
["claude-mythos-5", { reasoningEfforts: ["low","medium","high","xhigh","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
42
|
+
["claude-mythos-5-1", { reasoningEfforts: ["low","medium","high","xhigh","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
43
|
+
])],
|
|
44
|
+
["gemini", new Map([
|
|
45
|
+
["gemini-2.0-flash", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":8192}, fallbackRouting: true }],
|
|
46
|
+
["gemini-2.5-flash", { reasoningEfforts: ["none","low","medium","high"], maxOutputTokens: {"min":256,"max":65536}, fallbackRouting: true }],
|
|
47
|
+
["gemini-2.5-pro", { reasoningEfforts: ["low","medium","high"], maxOutputTokens: {"min":256,"max":65536}, fallbackRouting: true }],
|
|
48
|
+
["gemini-3.6-flash", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":8192}, fallbackRouting: true }],
|
|
49
|
+
["gemini-2.5-flash-lite", { reasoningEfforts: ["none","low","medium","high"], maxOutputTokens: {"min":256,"max":65536}, fallbackRouting: true }],
|
|
50
|
+
["gemini-3-flash-preview", { reasoningEfforts: ["minimal","low","medium","high"], maxOutputTokens: {"min":256,"max":65536}, fallbackRouting: true }],
|
|
51
|
+
["gemini-3.5-flash", { reasoningEfforts: ["minimal","low","medium","high"], maxOutputTokens: {"min":256,"max":65536}, fallbackRouting: true }],
|
|
52
|
+
["gemini-3.8-flash", { reasoningEfforts: ["minimal","low","medium","high"], maxOutputTokens: {"min":256,"max":65536}, fallbackRouting: true }],
|
|
53
|
+
["gemini-3.1-pro-preview", { reasoningEfforts: ["low","high"], maxOutputTokens: {"min":256,"max":65536}, fallbackRouting: true }],
|
|
54
|
+
])],
|
|
55
|
+
["deepseek", new Map([
|
|
56
|
+
["deepseek-flash", { reasoningEfforts: ["none","low","high","max"], maxOutputTokens: {"min":256,"max":384000}, fallbackRouting: true }],
|
|
57
|
+
["deepseek-chat", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":8192}, fallbackRouting: true }],
|
|
58
|
+
["deepseek-reasoner", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":8192}, fallbackRouting: true }],
|
|
59
|
+
["deepseek-v4-flash", { reasoningEfforts: ["none","low","high","max"], maxOutputTokens: {"min":256,"max":384000}, fallbackRouting: true }],
|
|
60
|
+
["deepseek-v4-flash-vision-exp", { reasoningEfforts: ["none","low","high","max"], maxOutputTokens: {"min":256,"max":384000}, fallbackRouting: true }],
|
|
61
|
+
["deepseek-v4-pro", { reasoningEfforts: ["none","low","high","max"], maxOutputTokens: {"min":256,"max":384000}, fallbackRouting: true }],
|
|
62
|
+
])],
|
|
63
|
+
["kimi", new Map([
|
|
64
|
+
["kimi-for-coding", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":32000}, fallbackRouting: true }],
|
|
65
|
+
["kimi-for-coding-highspeed", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":32000}, fallbackRouting: true }],
|
|
66
|
+
["kimi-k2.6", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":32000}, fallbackRouting: true }],
|
|
67
|
+
["kimi-k2.7-code", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: true }],
|
|
68
|
+
["kimi-k2.7-code-highspeed", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: true }],
|
|
69
|
+
["kimi-k3", { reasoningEfforts: ["low","high","max"], maxOutputTokens: {"min":256,"max":64000}, fallbackRouting: true }],
|
|
70
|
+
])],
|
|
71
|
+
["cohere", new Map([
|
|
72
|
+
["command-a-03-2025", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":4096}, fallbackRouting: true }],
|
|
73
|
+
["command-r", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":4096}, fallbackRouting: true }],
|
|
74
|
+
["command-r-plus", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":4096}, fallbackRouting: true }],
|
|
75
|
+
["command-a-reasoning-08-2025", { reasoningEfforts: ["none","high"], maxOutputTokens: {"min":256,"max":32000}, fallbackRouting: true }],
|
|
76
|
+
])],
|
|
77
|
+
["zai", new Map([
|
|
78
|
+
["glm-4-air", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":4096}, fallbackRouting: true }],
|
|
79
|
+
["glm-4-flash", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":4096}, fallbackRouting: true }],
|
|
80
|
+
["glm-4-plus", { reasoningEfforts: [], maxOutputTokens: {"min":256,"max":4096}, fallbackRouting: true }],
|
|
81
|
+
["glm-4.5", { reasoningEfforts: ["none","high"], maxOutputTokens: {"min":256,"max":4096}, fallbackRouting: true }],
|
|
82
|
+
["glm-4.6", { reasoningEfforts: ["none","high"], maxOutputTokens: {"min":256,"max":4096}, fallbackRouting: true }],
|
|
83
|
+
["glm-4.5-air", { reasoningEfforts: ["none","high"], maxOutputTokens: null, fallbackRouting: true }],
|
|
84
|
+
["glm-4.7", { reasoningEfforts: ["none","high"], maxOutputTokens: null, fallbackRouting: true }],
|
|
85
|
+
["glm-5", { reasoningEfforts: ["none","high"], maxOutputTokens: null, fallbackRouting: true }],
|
|
86
|
+
["glm-5.1", { reasoningEfforts: ["none","high"], maxOutputTokens: null, fallbackRouting: true }],
|
|
87
|
+
["glm-5.2", { reasoningEfforts: ["none","high","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
88
|
+
["glm-5.3", { reasoningEfforts: ["low","high","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
89
|
+
["glm-5.3-flash", { reasoningEfforts: ["low","high","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
90
|
+
])],
|
|
91
|
+
["codex", new Map([
|
|
92
|
+
["gpt-5.2", { reasoningEfforts: ["low","medium","high","xhigh"], maxOutputTokens: null, fallbackRouting: false }],
|
|
93
|
+
["gpt-5.3-codex", { reasoningEfforts: ["low","medium","high","xhigh"], maxOutputTokens: null, fallbackRouting: false }],
|
|
94
|
+
["gpt-5.3-codex-spark", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: false }],
|
|
95
|
+
["gpt-5.4", { reasoningEfforts: ["low","medium","high","xhigh"], maxOutputTokens: null, fallbackRouting: false }],
|
|
96
|
+
["gpt-5.4-mini", { reasoningEfforts: ["low","medium","high","xhigh"], maxOutputTokens: null, fallbackRouting: false }],
|
|
97
|
+
["gpt-5.5", { reasoningEfforts: ["low","medium","high","xhigh"], maxOutputTokens: null, fallbackRouting: false }],
|
|
98
|
+
["gpt-5.5-codex", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: false }],
|
|
99
|
+
["gpt-5.6", { reasoningEfforts: ["low","medium","high","xhigh","max","ultra"], maxOutputTokens: null, fallbackRouting: false }],
|
|
100
|
+
["gpt-5.6-luna", { reasoningEfforts: ["low","medium","high","xhigh","max"], maxOutputTokens: null, fallbackRouting: false }],
|
|
101
|
+
["gpt-5.6-sol", { reasoningEfforts: ["low","medium","high","xhigh","max","ultra"], maxOutputTokens: null, fallbackRouting: false }],
|
|
102
|
+
["gpt-5.6-terra", { reasoningEfforts: ["low","medium","high","xhigh","max","ultra"], maxOutputTokens: null, fallbackRouting: false }],
|
|
103
|
+
])],
|
|
104
|
+
["openai_compatible", new Map([
|
|
105
|
+
["gpt-6-sol", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], chatToolReasoningEfforts: ["none"], maxOutputTokens: null, fallbackRouting: false }],
|
|
106
|
+
["gpt-6-luna", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], chatToolReasoningEfforts: ["none"], maxOutputTokens: null, fallbackRouting: false }],
|
|
107
|
+
])],
|
|
108
|
+
["modal", new Map([
|
|
109
|
+
["deepseek-v4.1-flash", { reasoningEfforts: ["none","low","high","xhigh","max"], maxOutputTokens: {"min":256,"max":1048576}, fallbackRouting: false }],
|
|
110
|
+
["epoch--ep-deepseek-v4-1-flash-server.us-west.modal.direct", { reasoningEfforts: ["none","low","high","xhigh","max"], maxOutputTokens: {"min":256,"max":1048576}, fallbackRouting: false }],
|
|
111
|
+
["kimi-k3", { reasoningEfforts: ["low","high","max"], maxOutputTokens: null, fallbackRouting: false }],
|
|
112
|
+
["moonshot--kimi-k3-fast.modal.run", { reasoningEfforts: ["low","high","max"], maxOutputTokens: null, fallbackRouting: false }],
|
|
113
|
+
])],
|
|
114
|
+
["fireworks", new Map([
|
|
115
|
+
["deepseek-v4p1-flash", { reasoningEfforts: ["none","low","high","max"], maxOutputTokens: {"min":256,"max":384000}, fallbackRouting: true }],
|
|
116
|
+
["deepseek-v4-pro-0813", { reasoningEfforts: ["none","low","high","max"], maxOutputTokens: {"min":256,"max":384000}, fallbackRouting: true }],
|
|
117
|
+
["deepseek-v4-flash-0731", { reasoningEfforts: ["none","low","high","max"], maxOutputTokens: {"min":256,"max":384000}, fallbackRouting: true }],
|
|
118
|
+
["deepseek-v4-flash-vision-exp", { reasoningEfforts: ["none","low","high","max"], maxOutputTokens: {"min":256,"max":384000}, fallbackRouting: true }],
|
|
119
|
+
["kimi-k3", { reasoningEfforts: ["none","low","high","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
120
|
+
["gpt-oss-120b", { reasoningEfforts: ["low","medium","high"], maxOutputTokens: null, fallbackRouting: true }],
|
|
121
|
+
["qwen3p8-max", { reasoningEfforts: ["none","low","medium","high","xhigh","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
122
|
+
["glm-5p2", { reasoningEfforts: ["none","high","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
123
|
+
["glm-5p3", { reasoningEfforts: ["low","high","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
124
|
+
["glm-5p3-flash", { reasoningEfforts: ["low","high","max"], maxOutputTokens: null, fallbackRouting: true }],
|
|
125
|
+
["ember-1", { reasoningEfforts: ["none","high"], maxOutputTokens: null, fallbackRouting: true }],
|
|
126
|
+
["minimax-m3", { reasoningEfforts: ["none","high"], maxOutputTokens: null, fallbackRouting: true }],
|
|
127
|
+
["nemotron-lightning-3p5-30b-a3b", { reasoningEfforts: ["none","high"], maxOutputTokens: null, fallbackRouting: true }],
|
|
128
|
+
["muse-glimmer-30b", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: false }],
|
|
129
|
+
["kimi-k2p7-code", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: false }],
|
|
130
|
+
["nemotron-3-ultra-nvfp4", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: false }],
|
|
131
|
+
["inkling", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: false }],
|
|
132
|
+
["kimi-k2p6", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: false }],
|
|
133
|
+
])],
|
|
134
|
+
]);
|
|
135
|
+
|
|
136
|
+
export const CONTRACT_PROVIDERS = Object.freeze(["anthropic","openai","gemini","deepseek","fireworks","kimi","voyage","cohere","elevenlabs","replicate","fal","zai","modal","codex","self_hosted","openai_compatible","typesafe"]);
|
|
137
|
+
|
|
138
|
+
export function normalizeContractProvider(provider) {
|
|
139
|
+
const normalized = provider.trim().toLowerCase();
|
|
140
|
+
return normalized === 'moonshot' ? 'kimi' : normalized === 'claude' ? 'anthropic' : normalized;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function normalizeContractModel(provider, model) {
|
|
144
|
+
const canonicalProvider = normalizeContractProvider(provider);
|
|
145
|
+
let id = model.trim().toLowerCase();
|
|
146
|
+
if (id.startsWith(`${canonicalProvider}/`)) id = id.slice(canonicalProvider.length + 1);
|
|
147
|
+
if (canonicalProvider === 'fireworks' && id.startsWith('accounts/fireworks/models/')) {
|
|
148
|
+
id = id.slice('accounts/fireworks/models/'.length);
|
|
149
|
+
}
|
|
150
|
+
return id;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function modelContract(provider, model, surface = 'native_api') {
|
|
154
|
+
const canonicalProvider = normalizeContractProvider(provider);
|
|
155
|
+
const id = normalizeContractModel(canonicalProvider, model);
|
|
156
|
+
const contracts = MODEL_CONTRACTS.get(canonicalProvider);
|
|
157
|
+
const contract = contracts?.get(id)
|
|
158
|
+
?? (canonicalProvider === 'anthropic' ? contracts?.get(id.replace(/-\d{8}$/, '')) : undefined);
|
|
159
|
+
if (contract === undefined) return undefined;
|
|
160
|
+
// Callers cannot modify the shared policy through a returned array/range.
|
|
161
|
+
return {
|
|
162
|
+
reasoningEfforts: [...(surface === 'chat_tools' ? contract.chatToolReasoningEfforts ?? contract.reasoningEfforts : contract.reasoningEfforts)],
|
|
163
|
+
...(contract.chatToolReasoningEfforts ? { chatToolReasoningEfforts: [...contract.chatToolReasoningEfforts] } : {}),
|
|
164
|
+
maxOutputTokens: contract.maxOutputTokens === null ? null : { ...contract.maxOutputTokens },
|
|
165
|
+
fallbackRouting: contract.fallbackRouting,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function reasoningRequestParams(provider, model, effort) {
|
|
170
|
+
const canonicalProvider = normalizeContractProvider(provider);
|
|
171
|
+
const id = normalizeContractModel(canonicalProvider, model);
|
|
172
|
+
const contract = modelContract(canonicalProvider, id);
|
|
173
|
+
const selected = typeof effort === 'string' && contract?.reasoningEfforts.includes(effort) ? effort : null;
|
|
174
|
+
// Direct DeepSeek Flash historically enables thinking by default. Fireworks
|
|
175
|
+
// forbids sending thinking alongside reasoning_effort, so never infer its
|
|
176
|
+
// request format from the DeepSeek family name.
|
|
177
|
+
if (canonicalProvider === 'deepseek' && contract?.reasoningEfforts.length) {
|
|
178
|
+
if (selected === 'none') return { thinking: { type: 'disabled' } };
|
|
179
|
+
return { thinking: { type: 'enabled' }, reasoning_effort: selected ?? 'high' };
|
|
180
|
+
}
|
|
181
|
+
if (selected === null) return {};
|
|
182
|
+
if (canonicalProvider === 'anthropic') return { output_config: { effort: selected } };
|
|
183
|
+
if (canonicalProvider === 'gemini') {
|
|
184
|
+
const thinkingConfig = id.startsWith('gemini-2.5-')
|
|
185
|
+
? { thinkingBudget: selected === 'none' ? 0 : selected === 'low' ? 1024 : selected === 'medium' ? 8192 : id === 'gemini-2.5-pro' ? 32768 : 24576 }
|
|
186
|
+
: { thinkingLevel: selected };
|
|
187
|
+
return { generationConfig: { thinkingConfig } };
|
|
188
|
+
}
|
|
189
|
+
if (canonicalProvider === 'zai') {
|
|
190
|
+
const thinking = { type: selected === 'none' ? 'disabled' : 'enabled' };
|
|
191
|
+
return id === 'glm-5.2' || id === 'glm-5.3' || id === 'glm-5.3-flash'
|
|
192
|
+
? { thinking, ...(selected === 'none' ? {} : { reasoning_effort: selected }) }
|
|
193
|
+
: { thinking };
|
|
194
|
+
}
|
|
195
|
+
if (canonicalProvider === 'cohere') return { thinking: { type: selected === 'none' ? 'disabled' : 'enabled' } };
|
|
196
|
+
return { reasoning_effort: selected };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function applyReasoningSettings(body, provider, model, effort) {
|
|
200
|
+
// A fallback can cross API dialects. Each attempt owns these fields; remove
|
|
201
|
+
// inherited controls, including provider-native settings supplied by a sandbox.
|
|
202
|
+
for (const field of ['reasoning_effort', 'reasoning', 'thinking', 'output_config',
|
|
203
|
+
'thinking_config', 'reasoning_history', 'chat_template_kwargs']) delete body[field];
|
|
204
|
+
if (body.generationConfig && typeof body.generationConfig === 'object') {
|
|
205
|
+
const { thinkingConfig, ...rest } = body.generationConfig;
|
|
206
|
+
if (Object.keys(rest).length) body.generationConfig = rest;
|
|
207
|
+
else delete body.generationConfig;
|
|
208
|
+
}
|
|
209
|
+
// Router's canonical OpenAI-shaped envelope stays neutral until dispatch.
|
|
210
|
+
const contract = modelContract(provider, model, 'chat_tools');
|
|
211
|
+
if (typeof effort === 'string' && contract?.reasoningEfforts.includes(effort)) body.reasoning_effort = effort;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function fireworksRequestModel(model) {
|
|
215
|
+
// Direct keys may target a customer's deployment. Router independently
|
|
216
|
+
// enforces its serverless allowlist; this helper never expands that admission.
|
|
217
|
+
const upstream = model.trim().replace(/^fireworks\//i, '');
|
|
218
|
+
if (upstream.startsWith('accounts/')) return upstream;
|
|
219
|
+
return `accounts/fireworks/models/${normalizeContractModel('fireworks', model)}`;
|
|
220
|
+
}
|