infinicode 2.3.5 → 2.4.0

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.
Files changed (64) hide show
  1. package/.opencode/plugins/home-logo-animation.tsx +5 -1
  2. package/.opencode/plugins/mesh-commands.tsx +4 -3
  3. package/.opencode/plugins/routing-mode-display.tsx +6 -2
  4. package/.opencode/tui.json +2 -1
  5. package/bin/robopark.js +2 -0
  6. package/dist/cli.js +46 -1
  7. package/dist/commands/maintain.d.ts +29 -0
  8. package/dist/commands/maintain.js +186 -0
  9. package/dist/commands/mcp.js +1 -1
  10. package/dist/commands/mesh-install.d.ts +10 -0
  11. package/dist/commands/mesh-install.js +160 -0
  12. package/dist/commands/robopark.d.ts +6 -0
  13. package/dist/commands/robopark.js +450 -0
  14. package/dist/commands/run.js +82 -22
  15. package/dist/commands/serve.d.ts +1 -0
  16. package/dist/commands/serve.js +152 -11
  17. package/dist/kernel/agents/backends/cli-backend.d.ts +41 -0
  18. package/dist/kernel/agents/backends/cli-backend.js +140 -0
  19. package/dist/kernel/agents/backends/detect.d.ts +17 -0
  20. package/dist/kernel/agents/backends/detect.js +140 -0
  21. package/dist/kernel/agents/backends/index.d.ts +11 -0
  22. package/dist/kernel/agents/backends/index.js +3 -0
  23. package/dist/kernel/agents/backends/parse-utils.d.ts +20 -0
  24. package/dist/kernel/agents/backends/parse-utils.js +72 -0
  25. package/dist/kernel/agents/backends/profiles.d.ts +67 -0
  26. package/dist/kernel/agents/backends/profiles.js +48 -0
  27. package/dist/kernel/agents/backends/registry.d.ts +31 -0
  28. package/dist/kernel/agents/backends/registry.js +174 -0
  29. package/dist/kernel/agents/backends/rotation.d.ts +51 -0
  30. package/dist/kernel/agents/backends/rotation.js +107 -0
  31. package/dist/kernel/agents/backends/types.d.ts +67 -0
  32. package/dist/kernel/agents/backends/types.js +1 -0
  33. package/dist/kernel/agents/index.d.ts +8 -0
  34. package/dist/kernel/agents/index.js +8 -0
  35. package/dist/kernel/federation/dashboard-html.d.ts +13 -0
  36. package/dist/kernel/federation/dashboard-html.js +371 -0
  37. package/dist/kernel/federation/federation.d.ts +112 -2
  38. package/dist/kernel/federation/federation.js +270 -10
  39. package/dist/kernel/federation/moltfed-adapter.js +1 -0
  40. package/dist/kernel/federation/telemetry.d.ts +1 -1
  41. package/dist/kernel/federation/telemetry.js +2 -1
  42. package/dist/kernel/federation/transport-http.d.ts +17 -1
  43. package/dist/kernel/federation/transport-http.js +65 -2
  44. package/dist/kernel/federation/types.d.ts +46 -1
  45. package/dist/kernel/free-providers.js +83 -0
  46. package/dist/kernel/gateway/openai-gateway.d.ts +55 -3
  47. package/dist/kernel/gateway/openai-gateway.js +428 -49
  48. package/dist/kernel/index.d.ts +2 -1
  49. package/dist/kernel/index.js +3 -1
  50. package/dist/kernel/logger.d.ts +16 -3
  51. package/dist/kernel/logger.js +38 -0
  52. package/dist/kernel/mcp/mcp-server.js +65 -10
  53. package/dist/kernel/orchestrator.d.ts +4 -0
  54. package/dist/kernel/orchestrator.js +34 -0
  55. package/dist/kernel/provider-manager.d.ts +13 -0
  56. package/dist/kernel/provider-manager.js +58 -5
  57. package/dist/kernel/providers/openai-compatible-provider.d.ts +6 -0
  58. package/dist/kernel/providers/openai-compatible-provider.js +22 -3
  59. package/dist/kernel/recovery-manager.js +55 -15
  60. package/dist/kernel/router.js +15 -2
  61. package/dist/kernel/types.d.ts +12 -2
  62. package/dist/robopark-cli.d.ts +2 -0
  63. package/dist/robopark-cli.js +23 -0
  64. package/package.json +6 -3
@@ -101,6 +101,89 @@ export const FREE_PROVIDERS = [
101
101
  ],
102
102
  notes: 'NVIDIA build.nvidia.com offers free NIM endpoints. 1000 req/month free tier.',
103
103
  },
104
+ {
105
+ id: 'cerebras',
106
+ name: 'Cerebras',
107
+ baseURL: 'https://api.cerebras.ai/v1',
108
+ keyUrl: 'https://cloud.cerebras.ai',
109
+ free: true,
110
+ recommended: {
111
+ coding: ['qwen-3-235b-a22b-instruct-2507', 'gpt-oss-120b'],
112
+ architecture: ['qwen-3-235b-a22b-instruct-2507'],
113
+ research: ['gpt-oss-120b'],
114
+ review: ['qwen-3-235b-a22b-instruct-2507'],
115
+ reasoning: ['qwen-3-235b-a22b-instruct-2507'],
116
+ },
117
+ knownModels: [
118
+ { id: 'qwen-3-235b-a22b-instruct-2507', name: 'Qwen3 235B', contextLength: 128_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
119
+ { id: 'gpt-oss-120b', name: 'GPT-OSS 120B', contextLength: 128_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
120
+ { id: 'qwen-3-32b', name: 'Qwen3 32B', contextLength: 128_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
121
+ { id: 'llama-3.3-70b', name: 'Llama 3.3 70B', contextLength: 128_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
122
+ ],
123
+ notes: 'Fastest inference (wafer-scale). Free: ~1M tokens/day, 30 RPM. Frontier open models.',
124
+ },
125
+ {
126
+ id: 'chutes',
127
+ name: 'Chutes',
128
+ baseURL: 'https://llm.chutes.ai/v1',
129
+ keyUrl: 'https://chutes.ai',
130
+ free: true,
131
+ recommended: {
132
+ coding: ['zai-org/GLM-4.6', 'deepseek-ai/DeepSeek-V3.1', 'moonshotai/Kimi-K2-Instruct'],
133
+ architecture: ['deepseek-ai/DeepSeek-V3.1', 'zai-org/GLM-4.6'],
134
+ research: ['deepseek-ai/DeepSeek-V3.1'],
135
+ reasoning: ['deepseek-ai/DeepSeek-R1'],
136
+ review: ['zai-org/GLM-4.6'],
137
+ },
138
+ knownModels: [
139
+ { id: 'zai-org/GLM-4.6', name: 'GLM-4.6', contextLength: 200_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
140
+ { id: 'moonshotai/Kimi-K2-Instruct', name: 'Kimi K2', contextLength: 128_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
141
+ { id: 'deepseek-ai/DeepSeek-V3.1', name: 'DeepSeek V3.1', contextLength: 128_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
142
+ { id: 'Qwen/Qwen3-235B-A22B', name: 'Qwen3 235B', contextLength: 256_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
143
+ { id: 'deepseek-ai/DeepSeek-R1', name: 'DeepSeek R1', contextLength: 128_000, capabilities: ['reasoning'] },
144
+ ],
145
+ notes: 'Huge decentralized catalog — GLM, Kimi, DeepSeek, Qwen frontier models. Generous free tier.',
146
+ },
147
+ {
148
+ id: 'sambanova',
149
+ name: 'SambaNova',
150
+ baseURL: 'https://api.sambanova.ai/v1',
151
+ keyUrl: 'https://cloud.sambanova.ai',
152
+ free: true,
153
+ recommended: {
154
+ coding: ['DeepSeek-V3.1', 'Meta-Llama-3.3-70B-Instruct'],
155
+ architecture: ['DeepSeek-V3.1'],
156
+ research: ['Meta-Llama-3.3-70B-Instruct'],
157
+ reasoning: ['DeepSeek-R1'],
158
+ },
159
+ knownModels: [
160
+ { id: 'DeepSeek-V3.1', name: 'DeepSeek V3.1', contextLength: 128_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
161
+ { id: 'Meta-Llama-3.3-70B-Instruct', name: 'Llama 3.3 70B', contextLength: 128_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
162
+ { id: 'gpt-oss-120b', name: 'GPT-OSS 120B', contextLength: 128_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
163
+ { id: 'Qwen3-32B', name: 'Qwen3 32B', contextLength: 128_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
164
+ ],
165
+ notes: 'Very fast (RDU). Permanent free tier (20 RPM) + $5 trial credits. No card.',
166
+ },
167
+ {
168
+ id: 'mistral',
169
+ name: 'Mistral',
170
+ baseURL: 'https://api.mistral.ai/v1',
171
+ keyUrl: 'https://console.mistral.ai/api-keys',
172
+ free: true,
173
+ recommended: {
174
+ coding: ['codestral-latest', 'mistral-large-latest'],
175
+ architecture: ['mistral-large-latest'],
176
+ research: ['mistral-large-latest'],
177
+ reasoning: ['magistral-medium-latest'],
178
+ },
179
+ knownModels: [
180
+ { id: 'mistral-large-latest', name: 'Mistral Large', contextLength: 128_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
181
+ { id: 'codestral-latest', name: 'Codestral', contextLength: 256_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
182
+ { id: 'magistral-medium-latest', name: 'Magistral Medium', contextLength: 128_000, capabilities: ['reasoning'], supportsFunctionCalling: true },
183
+ { id: 'mistral-small-latest', name: 'Mistral Small', contextLength: 128_000, capabilities: ['coding', 'reasoning'], supportsFunctionCalling: true },
184
+ ],
185
+ notes: 'La Plateforme free (Experiment) tier ≈ 1B tokens/month. Codestral is a strong coder.',
186
+ },
104
187
  {
105
188
  id: 'hf',
106
189
  name: 'Hugging Face Inference',
@@ -45,6 +45,16 @@ export interface KernelGatewayOptions {
45
45
  executor?: ProviderExecutor;
46
46
  /** Capabilities to route interactive chat under. */
47
47
  capabilities?: Capability[];
48
+ /**
49
+ * Soft benchmark floor for `auto` routing. Biases interactive coding toward
50
+ * capable models (weak ones become fallbacks, not first picks) so demanding
51
+ * work doesn't open on a lazy model — without hard-pinning anything.
52
+ */
53
+ minBenchmark?: number;
54
+ /** Stall guards (ms). Override the defaults (mainly for tests). */
55
+ headersTimeoutMs?: number;
56
+ firstChunkTimeoutMs?: number;
57
+ idleTimeoutMs?: number;
48
58
  }
49
59
  export declare class KernelGateway {
50
60
  private opts;
@@ -56,15 +66,55 @@ export declare class KernelGateway {
56
66
  constructor(opts: KernelGatewayOptions);
57
67
  get port(): number;
58
68
  get url(): string;
59
- /** Start listening. Scans ports [port .. port+10] to avoid collisions. */
69
+ /**
70
+ * Start listening. Scans ports [port .. port+20] then falls back to an OS-chosen
71
+ * ephemeral port. Retries past BOTH EADDRINUSE (a lingering session holds it) and
72
+ * EACCES (a Windows excluded/reserved range) — never dies on a single bad port,
73
+ * since the whole point is that the gateway must come up so the TUI gets routing.
74
+ */
60
75
  start(): Promise<void>;
61
76
  private listen;
62
77
  stop(): Promise<void>;
63
78
  private handle;
64
79
  private listModels;
65
80
  private handleChat;
66
- /** Stream bytes through untouched, or relay the JSON body for non-streaming. */
67
- private relay;
81
+ /**
82
+ * Build a continuation request: the original messages plus the partial answer as
83
+ * an assistant prefix so a fresh model resumes it instead of restarting. `prefix:
84
+ * true` is the continue-this-message convention (DeepSeek/Mistral/Zhipu/Qwen);
85
+ * providers that ignore it at worst restart — still better than a dead task.
86
+ */
87
+ private buildContinuation;
88
+ /** Close an already-open SSE stream with a synthetic clean finish so the client
89
+ * gets a proper end-of-turn instead of hanging on a half-open connection. */
90
+ private endStream;
91
+ /**
92
+ * Run one model. Returns forwarded:true only after the response is validated
93
+ * and sent to the client; otherwise nothing is written to `res` and the caller
94
+ * swaps to the next model. Catches BOTH transport failures (non-2xx) AND bad
95
+ * tool calls the model streams back on a 200 (a weak model naming a tool that
96
+ * isn't in request.tools — e.g. `glob={...}` — which downstream would reject).
97
+ */
98
+ private attempt;
99
+ /**
100
+ * Relay an SSE stream, but with a small look-ahead: buffer frames until the
101
+ * first tool-call name or content delta. If that first tool call names a tool
102
+ * not in request.tools (or an error frame arrives), fail WITHOUT writing to the
103
+ * client so the caller can swap models. Once a valid start is seen, commit and
104
+ * stream the rest live (so large generations still stream token-by-token).
105
+ */
106
+ private streamValidated;
107
+ /**
108
+ * Classify one SSE frame: does it error, is it a safe commit point, is it a
109
+ * TERMINAL frame (finish_reason / `[DONE]` — held back so a truncation can be
110
+ * continued), and what visible content does it carry (accumulated so a fresh
111
+ * model can continue the answer from where a dead provider left off)?
112
+ */
113
+ private inspectFrame;
114
+ /** Validate a non-streamed response body for unknown tool calls / errors. */
115
+ private validateResponse;
116
+ /** The set of tool names the request declared (OpenAI tools[].function.name). */
117
+ private allowedTools;
68
118
  /** Resolve the initial target: honor an explicit provider/model, else route. */
69
119
  private resolveTarget;
70
120
  /** Ask the kernel router for the best untried, executable model. */
@@ -75,6 +125,8 @@ export declare class KernelGateway {
75
125
  * escalate to a stronger model via the kernel ladder, then fall back to rank.
76
126
  */
77
127
  private nextTarget;
128
+ /** First configured provider/model not in `tried` (optionally skipping a provider). */
129
+ private firstUntried;
78
130
  private toTarget;
79
131
  private rank;
80
132
  private routingRequest;