infinicode 1.0.0 → 2.1.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 (159) hide show
  1. package/.opencode/plugins/home-logo-animation.tsx +120 -0
  2. package/.opencode/plugins/routing-mode-display.tsx +135 -0
  3. package/.opencode/themes/infinibot-gold.json +222 -0
  4. package/.opencode/tui.json +8 -0
  5. package/README.md +564 -72
  6. package/dist/ascii-video-animation.d.ts +2 -0
  7. package/dist/ascii-video-animation.js +243 -0
  8. package/dist/cli.js +199 -50
  9. package/dist/commands/console.d.ts +6 -0
  10. package/dist/commands/console.js +111 -0
  11. package/dist/commands/kernel-setup.d.ts +3 -0
  12. package/dist/commands/kernel-setup.js +303 -0
  13. package/dist/commands/mcp.d.ts +14 -0
  14. package/dist/commands/mcp.js +100 -0
  15. package/dist/commands/mission.d.ts +16 -0
  16. package/dist/commands/mission.js +301 -0
  17. package/dist/commands/models.d.ts +3 -1
  18. package/dist/commands/models.js +111 -55
  19. package/dist/commands/providers.d.ts +6 -0
  20. package/dist/commands/providers.js +95 -0
  21. package/dist/commands/run.d.ts +2 -1
  22. package/dist/commands/run.js +349 -59
  23. package/dist/commands/serve.d.ts +20 -0
  24. package/dist/commands/serve.js +132 -0
  25. package/dist/commands/setup.d.ts +1 -1
  26. package/dist/commands/setup.js +77 -44
  27. package/dist/commands/status.d.ts +2 -1
  28. package/dist/commands/status.js +46 -30
  29. package/dist/commands/workers.d.ts +5 -0
  30. package/dist/commands/workers.js +103 -0
  31. package/dist/kernel/autonomy/goal-loop.d.ts +49 -0
  32. package/dist/kernel/autonomy/goal-loop.js +113 -0
  33. package/dist/kernel/autonomy/index.d.ts +8 -0
  34. package/dist/kernel/autonomy/index.js +7 -0
  35. package/dist/kernel/browser/browser-controller.d.ts +57 -0
  36. package/dist/kernel/browser/browser-controller.js +175 -0
  37. package/dist/kernel/checkpoint-engine.d.ts +17 -0
  38. package/dist/kernel/checkpoint-engine.js +128 -0
  39. package/dist/kernel/command-system.d.ts +37 -0
  40. package/dist/kernel/command-system.js +239 -0
  41. package/dist/kernel/config-schema.d.ts +57 -0
  42. package/dist/kernel/config-schema.js +36 -0
  43. package/dist/kernel/event-bus.d.ts +19 -0
  44. package/dist/kernel/event-bus.js +65 -0
  45. package/dist/kernel/federation/auto-update.d.ts +36 -0
  46. package/dist/kernel/federation/auto-update.js +57 -0
  47. package/dist/kernel/federation/compute-router.d.ts +27 -0
  48. package/dist/kernel/federation/compute-router.js +44 -0
  49. package/dist/kernel/federation/config-sync.d.ts +33 -0
  50. package/dist/kernel/federation/config-sync.js +37 -0
  51. package/dist/kernel/federation/discovery.d.ts +11 -0
  52. package/dist/kernel/federation/discovery.js +44 -0
  53. package/dist/kernel/federation/event-bridge.d.ts +30 -0
  54. package/dist/kernel/federation/event-bridge.js +61 -0
  55. package/dist/kernel/federation/federation-plugin.d.ts +24 -0
  56. package/dist/kernel/federation/federation-plugin.js +35 -0
  57. package/dist/kernel/federation/federation.d.ts +135 -0
  58. package/dist/kernel/federation/federation.js +378 -0
  59. package/dist/kernel/federation/index.d.ts +33 -0
  60. package/dist/kernel/federation/index.js +24 -0
  61. package/dist/kernel/federation/lan-discovery.d.ts +43 -0
  62. package/dist/kernel/federation/lan-discovery.js +135 -0
  63. package/dist/kernel/federation/moltfed-adapter.d.ts +30 -0
  64. package/dist/kernel/federation/moltfed-adapter.js +52 -0
  65. package/dist/kernel/federation/moltfed-connector.d.ts +98 -0
  66. package/dist/kernel/federation/moltfed-connector.js +193 -0
  67. package/dist/kernel/federation/node-identity.d.ts +19 -0
  68. package/dist/kernel/federation/node-identity.js +86 -0
  69. package/dist/kernel/federation/peer-mesh.d.ts +46 -0
  70. package/dist/kernel/federation/peer-mesh.js +117 -0
  71. package/dist/kernel/federation/protocol.d.ts +20 -0
  72. package/dist/kernel/federation/protocol.js +61 -0
  73. package/dist/kernel/federation/role-context.d.ts +5 -0
  74. package/dist/kernel/federation/role-context.js +45 -0
  75. package/dist/kernel/federation/telemetry.d.ts +21 -0
  76. package/dist/kernel/federation/telemetry.js +138 -0
  77. package/dist/kernel/federation/transport-http.d.ts +44 -0
  78. package/dist/kernel/federation/transport-http.js +207 -0
  79. package/dist/kernel/federation/types.d.ts +212 -0
  80. package/dist/kernel/federation/types.js +3 -0
  81. package/dist/kernel/free-providers.d.ts +28 -0
  82. package/dist/kernel/free-providers.js +162 -0
  83. package/dist/kernel/frontend-scoring.d.ts +21 -0
  84. package/dist/kernel/frontend-scoring.js +125 -0
  85. package/dist/kernel/index.d.ts +63 -0
  86. package/dist/kernel/index.js +45 -0
  87. package/dist/kernel/kernel.d.ts +75 -0
  88. package/dist/kernel/kernel.js +223 -0
  89. package/dist/kernel/logger.d.ts +18 -0
  90. package/dist/kernel/logger.js +26 -0
  91. package/dist/kernel/mcp/index.d.ts +9 -0
  92. package/dist/kernel/mcp/index.js +8 -0
  93. package/dist/kernel/mcp/mcp-server.d.ts +27 -0
  94. package/dist/kernel/mcp/mcp-server.js +178 -0
  95. package/dist/kernel/mission-engine.d.ts +42 -0
  96. package/dist/kernel/mission-engine.js +160 -0
  97. package/dist/kernel/orchestrator.d.ts +51 -0
  98. package/dist/kernel/orchestrator.js +226 -0
  99. package/dist/kernel/plugin-manager.d.ts +28 -0
  100. package/dist/kernel/plugin-manager.js +76 -0
  101. package/dist/kernel/plugins/browser-plugin.d.ts +22 -0
  102. package/dist/kernel/plugins/browser-plugin.js +34 -0
  103. package/dist/kernel/plugins/dashboard-plugin.d.ts +17 -0
  104. package/dist/kernel/plugins/dashboard-plugin.js +72 -0
  105. package/dist/kernel/plugins/discord-plugin.d.ts +11 -0
  106. package/dist/kernel/plugins/discord-plugin.js +35 -0
  107. package/dist/kernel/plugins/metrics-plugin.d.ts +33 -0
  108. package/dist/kernel/plugins/metrics-plugin.js +86 -0
  109. package/dist/kernel/plugins/search-plugin.d.ts +17 -0
  110. package/dist/kernel/plugins/search-plugin.js +20 -0
  111. package/dist/kernel/plugins/slack-plugin.d.ts +11 -0
  112. package/dist/kernel/plugins/slack-plugin.js +35 -0
  113. package/dist/kernel/plugins/telegram-plugin.d.ts +20 -0
  114. package/dist/kernel/plugins/telegram-plugin.js +122 -0
  115. package/dist/kernel/policies.d.ts +33 -0
  116. package/dist/kernel/policies.js +105 -0
  117. package/dist/kernel/provider-discovery.d.ts +41 -0
  118. package/dist/kernel/provider-discovery.js +179 -0
  119. package/dist/kernel/provider-manager.d.ts +38 -0
  120. package/dist/kernel/provider-manager.js +206 -0
  121. package/dist/kernel/provider-url.d.ts +18 -0
  122. package/dist/kernel/provider-url.js +45 -0
  123. package/dist/kernel/providers/gemini-provider.d.ts +43 -0
  124. package/dist/kernel/providers/gemini-provider.js +203 -0
  125. package/dist/kernel/providers/ollama-provider.d.ts +44 -0
  126. package/dist/kernel/providers/ollama-provider.js +241 -0
  127. package/dist/kernel/providers/openai-compatible-provider.d.ts +43 -0
  128. package/dist/kernel/providers/openai-compatible-provider.js +233 -0
  129. package/dist/kernel/recovery-manager.d.ts +38 -0
  130. package/dist/kernel/recovery-manager.js +156 -0
  131. package/dist/kernel/router.d.ts +44 -0
  132. package/dist/kernel/router.js +222 -0
  133. package/dist/kernel/sample-missions.d.ts +11 -0
  134. package/dist/kernel/sample-missions.js +132 -0
  135. package/dist/kernel/scheduler.d.ts +30 -0
  136. package/dist/kernel/scheduler.js +147 -0
  137. package/dist/kernel/sdk/harness-sdk.d.ts +37 -0
  138. package/dist/kernel/sdk/harness-sdk.js +48 -0
  139. package/dist/kernel/sdk/plugin-sdk.d.ts +27 -0
  140. package/dist/kernel/sdk/plugin-sdk.js +40 -0
  141. package/dist/kernel/search/search-controller.d.ts +32 -0
  142. package/dist/kernel/search/search-controller.js +141 -0
  143. package/dist/kernel/setup.d.ts +13 -0
  144. package/dist/kernel/setup.js +59 -0
  145. package/dist/kernel/types.d.ts +479 -0
  146. package/dist/kernel/types.js +7 -0
  147. package/dist/kernel/verification-engine.d.ts +33 -0
  148. package/dist/kernel/verification-engine.js +287 -0
  149. package/dist/kernel/worker-runtime.d.ts +66 -0
  150. package/dist/kernel/worker-runtime.js +261 -0
  151. package/dist/kernel/workers/browser-worker.d.ts +6 -0
  152. package/dist/kernel/workers/browser-worker.js +92 -0
  153. package/dist/kernel/workers/builtin-workers.d.ts +20 -0
  154. package/dist/kernel/workers/builtin-workers.js +120 -0
  155. package/dist/kernel/workers/research-worker.d.ts +5 -0
  156. package/dist/kernel/workers/research-worker.js +90 -0
  157. package/dist/prompt-ascii-video-animation.d.ts +2 -0
  158. package/dist/prompt-ascii-video-animation.js +243 -0
  159. package/package.json +43 -9
package/README.md CHANGED
@@ -1,6 +1,53 @@
1
- # ⚡ Infinicode
1
+ # OpenKernel
2
2
 
3
- **AI coding agent powered by your local Ollama.** Fork of OpenCode optimized for self-hosted LLMs.
3
+ ### Provider-Agnostic AI Execution Kernel
4
+
5
+ > **Mission:** Execute AI workloads reliably for hours or days using the best available inference without depending on any single provider, model, or framework.
6
+
7
+ `infinicode` now ships a **kernel** — a provider-agnostic AI execution runtime — alongside the original Ollama-based coding CLI. The kernel is not an agent framework; it executes missions. Harnesses, CLIs, bots, and custom workflows all interact through the same execution API.
8
+
9
+ ---
10
+
11
+ ## Quick Start
12
+
13
+ ### Friendly setup wizard (recommended)
14
+
15
+ ```bash
16
+ infinicode kernel-setup
17
+ ```
18
+
19
+ The wizard walks through:
20
+
21
+ 1. **Ollama master** — LAN URL + optional Tailscale fallback (preserved from v1)
22
+ 2. **Free cloud providers** — recommends setting up as many as possible for optimal rotation:
23
+ - **Groq** — fastest cloud inference, free tier
24
+ - **OpenRouter** — aggregator with many free model variants
25
+ - **GitHub Models** — free preview, use a GitHub token
26
+ - **NVIDIA NIM** — free NIM endpoints
27
+ - **Hugging Face** — free Inference API
28
+ - For each: prompt for API key, test connection, enable on success
29
+ 3. **Worker model pinning** — arrow-key list per worker type (coding, research, architecture, review, documentation, translation, terminal, verification, vision, browser). Recommends a model for each based on capability match.
30
+ 4. **Default policy** — local-first, free-first, fastest, highest-quality, privacy-first, balanced, offline
31
+ 5. **Save** — prints a summary
32
+
33
+ All choices are saved to the infinicode config. Setting up more providers gives the router more options for failover and rate-limit rotation.
34
+
35
+ ### Quick manual setup
36
+
37
+ ```bash
38
+ # Ollama only (original v1 flow)
39
+ infinicode connect 192.168.1.100
40
+
41
+ # Add a cloud provider
42
+ infinicode providers add
43
+
44
+ # Pin a model per worker type
45
+ infinicode workers edit
46
+ ```
47
+
48
+ ---
49
+
50
+ ### As a CLI (infinicode TUI)
4
51
 
5
52
  ```bash
6
53
  npm install -g infinicode
@@ -8,123 +55,568 @@ npm install -g infinicode
8
55
  # Connect to your Ollama master
9
56
  infinicode connect 192.168.1.100
10
57
 
11
- # Start coding
58
+ # Set up cloud providers (Groq, OpenRouter, GitHub, NVIDIA, HF, Gemini)
59
+ infinicode kernel-setup
60
+
61
+ # Start the infinicode TUI — full provider pool injected
12
62
  infinicode
13
63
  ```
14
64
 
15
- ## Why Infinicode?
65
+ The `run` command (default) launches the **infinicode TUI** — the infinicode SolidJS terminal UI with the infinicode gold theme, animated logo, markdown rendering, diff view, and plugin slots. infinicode builds the provider config from your saved kernel config (Ollama + all enabled cloud providers) and injects it via `OPENCODE_CONFIG_CONTENT`, so the TUI can use **every provider** — not just a single Ollama master.
16
66
 
17
- - **100% Local** All inference on YOUR hardware
18
- - **Zero Cloud** — No API keys, no subscriptions, no data leaving your network
19
- - **One Command Setup** — `infinicode connect <ip>` and you're done
20
- - **Multi-Node** — Run on any machine, point to one Ollama master
67
+ The TUI is the **Harness** (prompts, workflows, personas, memory). For headless mission execution with full kernel routing (capability router, recovery, verification, checkpoints), use `infinicode mission run`.
21
68
 
22
- ## Quick Start
69
+ ### As a kernel (new in v2)
70
+
71
+ ```bash
72
+ # One-time friendly setup wizard (providers + worker models + policy)
73
+ infinicode kernel-setup
74
+
75
+ # Or set up individual pieces
76
+ infinicode providers add # add Groq/OpenRouter/GitHub/NVIDIA/HF
77
+ infinicode workers edit # pick a model per worker type
78
+
79
+ # List built-in sample missions
80
+ infinicode mission samples
81
+
82
+ # Run a mission through the kernel
83
+ infinicode mission run --goal "Reverse a string in TypeScript" --task "Write reverseString(s)" --cap coding
23
84
 
24
- ### 1. Install
85
+ # Run a sample
86
+ infinicode mission run --sample hello-code
87
+
88
+ # Mission status / list
89
+ infinicode mission status <id>
90
+ infinicode mission list
91
+ ```
92
+
93
+ ### As a device mesh (multi-device, new in v2)
94
+
95
+ Install infinicode on every machine — laptop, workstation, Raspberry&nbsp;Pi — and they become one fleet. Spawn AI agents on any device from any device (no SSH), stream activity/hardware back, and drive it all from an MCP host like Claude Code or InfiniBot.
25
96
 
26
97
  ```bash
98
+ # install on each device
27
99
  npm install -g infinicode
28
- # or
29
- pnpm add -g infinicode
100
+
101
+ # same LAN — zero config: each node broadcasts a UDP beacon and auto-connects
102
+ infinicode serve --hub --lan # your main machine
103
+ infinicode serve --role satellite --lan # a Pi / other box
104
+
105
+ # across LAN + remote — auto-discover over Tailscale
106
+ infinicode serve --hub --tailscale
107
+ infinicode serve --role satellite --tailscale --tag tag:robopark
108
+
109
+ # or point at exact peers
110
+ infinicode serve --role satellite --seed http://192.168.1.20:47913
111
+
112
+ # verify the mesh
113
+ infinicode x /nodes
30
114
  ```
31
115
 
32
- ### 2. Setup Ollama Master
116
+ Drive the fleet from an MCP host — register the control server (spawn / dispatch / follow / role / voice / mesh-map tools):
117
+
118
+ ```jsonc
119
+ // ~/.claude.json
120
+ { "mcpServers": { "infinicode": { "command": "infinicode", "args": ["mcp", "--lan"] } } }
121
+ ```
33
122
 
34
- On your GPU machine:
123
+ Link a node onto an **InfiniBot** neural-mesh map (no InfiniBot changes needed):
35
124
 
36
125
  ```bash
37
- # Allow network connections
38
- OLLAMA_HOST=0.0.0.0:11434 ollama serve
126
+ infinicode serve --hub --gateway ws://<infinibot-host>:18789 --gateway-token <token>
127
+ ```
39
128
 
40
- # Pull a coding model
41
- ollama pull qwen2.5-coder:14b
129
+ Discovery options: `--lan` (same subnet, zero-config UDP broadcast, port 47915), `--tailscale` (LAN+remote), `--seed <url>` (exact) — they combine. Full guide: `docs/user-manual.html`; design deep-dive: `docs/federation-architecture.html`.
130
+
131
+ > The Windows TUI binaries are not shipped in the npm package (they're large and platform-specific), so `infinicode run` needs a local TUI build; the mesh commands (`serve`, `mcp`, `mission`, `console`) run everywhere as pure Node.
132
+
133
+ ### As a library
134
+
135
+ ```ts
136
+ import { createKernel, OllamaProvider, OpenAICompatibleProvider } from 'infinicode/kernel';
137
+
138
+ const kernel = createKernel();
139
+
140
+ // Register providers (plugins — the application never knows which)
141
+ kernel.registerProvider('ollama', new OllamaProvider({
142
+ baseURL: 'http://192.168.1.100:11434',
143
+ defaultModel: 'qwen2.5-coder:14b',
144
+ }));
145
+
146
+ kernel.registerProvider('openrouter', new OpenAICompatibleProvider({
147
+ id: 'openrouter',
148
+ name: 'OpenRouter',
149
+ baseURL: 'https://openrouter.ai/api',
150
+ apiKey: process.env.OPENROUTER_API_KEY!,
151
+ }));
152
+
153
+ // Subscribe to events (plugins, notifications, logging)
154
+ kernel.subscribeAll(event => console.log(event.type));
155
+
156
+ // Execute a mission — the kernel decides where/when/with which model
157
+ const mission = await kernel.execute({
158
+ name: 'reverse-string',
159
+ description: 'Write a TypeScript string reverser',
160
+ goal: 'Produce a reverseString function',
161
+ policy: 'local-first',
162
+ tasks: [
163
+ {
164
+ description: 'Write the function',
165
+ capabilities: ['coding', 'reasoning'],
166
+ input: { prompt: 'Write `reverseString(s: string): string`. Include only the function.' },
167
+ },
168
+ ],
169
+ });
170
+
171
+ console.log(mission.status, mission.tasks[0].output?.content);
42
172
  ```
43
173
 
44
- ### 3. Connect & Code
174
+ ---
45
175
 
46
- ```bash
47
- # From any machine on your network
48
- infinicode connect 192.168.1.100 # Your Ollama IP
49
- infinicode # Start coding!
176
+ ## Core Principles
177
+
178
+ 1. **Execution First** — the kernel is not an agent framework. It executes missions. It doesn't define prompts, workflows, or personas. Those belong to Harnesses.
179
+ 2. **Framework Agnostic** — works equally well with Harness, custom workflows, CLI, n8n, Discord bots, VSCode extensions. Everything interacts through the same execution API.
180
+ 3. **Model Agnostic** — workers never request "Gemini". They request `Need: Coding, Reasoning>90, Vision, Context>128K`. The router decides.
181
+ 4. **Provider Agnostic** — providers are plugins. The application never knows.
182
+
183
+ ---
184
+
185
+ ## Architecture
186
+
187
+ ```
188
+ Applications
189
+
190
+ Harness CLI n8n VSCode
191
+
192
+
193
+ ──────────────────── API ───────────────────
194
+
195
+ AI Execution Kernel
196
+ ────────────────────────────────────────────
197
+
198
+ Mission Engine
199
+ Native Orchestrator
200
+ Scheduler
201
+ Worker Runtime
202
+ Capability Router
203
+ Provider Manager
204
+ Policy Engine
205
+ Verification
206
+ Recovery
207
+ Checkpoint Engine
208
+ Event Bus
209
+ Plugin Manager
210
+ ────────────────────────────────────────────
211
+
212
+ Providers Tools Workers Notifications
213
+ ```
214
+
215
+ ### Components
216
+
217
+ | Component | Responsibility |
218
+ |---|---|
219
+ | **Mission Engine** | Lifecycle (NEW → PLANNING → READY → RUNNING → VERIFYING → WAITING → FAILED → COMPLETED), pause/resume, completion |
220
+ | **Native Orchestrator** | Always running. Coordinates everything, executes nothing directly |
221
+ | **Scheduler** | Mission → Objectives → Tasks → Execution Queue → Workers. Sequential, parallel, dependency graphs |
222
+ | **Worker Runtime** | Disposable capability containers: Spawn → Initialize → Execute → Verify → Publish → Destroy |
223
+ | **Capability Registry** | Workers advertise capabilities (coding, browser, vision, terminal, planning, reasoning, …) |
224
+ | **Policy Engine** | 7 built-in policies: free-first, fastest, highest-quality, local-first, privacy-first, balanced, offline |
225
+ | **Intelligent Router** | Scores: capability + reliability + speed + quota + context + policy − cost → best model + provider |
226
+ | **Provider Manager** | Tracks models, quota, 429s, latency, success rate, health. Background refresh only, never blocks |
227
+ | **Verification Engine** | Pipeline: objective → compile → tests → lint → browser tests → expected output → LLM judge (always last) |
228
+ | **Recovery Manager** | Classifies failures (429, timeout, provider-down, hallucination, …) → retry / rotate / spawn-different-worker / replan / checkpoint |
229
+ | **Checkpoint Engine** | Persists mission, objectives, tasks, worker state, memory, logs, artifacts. Pause/resume/crash-recovery |
230
+ | **Event Bus** | Everything emits events. Plugins subscribe |
231
+ | **Plugin System** | Core stays tiny. Telegram, Discord, Slack, Browser, Search, Dashboard, Metrics, … all optional |
232
+
233
+ ---
234
+
235
+ ## Worker Types (built-in)
236
+
237
+ Workers are **capability containers, not personalities**. No prompts, no workflows, no personas — only capabilities. Any system prompt is supplied by the Harness via `TaskInput.context`, never by the worker itself.
238
+
239
+ ```
240
+ research browser coding architecture
241
+ vision review documentation translation
242
+ terminal verification
243
+ ```
244
+
245
+ Register custom workers via `kernel.registerWorker({ type, capabilities, preferences })`.
246
+
247
+ ---
248
+
249
+ ## Providers (built-in)
250
+
251
+ | Provider | Type | File |
252
+ |---|---|---|
253
+ | **Ollama** | local | `ollama-provider.ts` (LAN + Tailscale fallback, migrated from v1) |
254
+ | **OpenAI-compatible** | local/cloud | `openai-compatible-provider.ts` (powers OpenRouter, Groq, GitHub Models, NVIDIA, HF, vLLM, LM Studio, SGLang) |
255
+ | **Gemini** | cloud | `gemini-provider.ts` (Google Generative Language API — generateContent / streamGenerateContent) |
256
+
257
+ All three implement the same `ProviderInterface`. The application never knows which is in use.
258
+
259
+ ### Adding a cloud provider
260
+
261
+ ```ts
262
+ import { OpenAICompatibleProvider } from 'infinicode/kernel';
263
+
264
+ kernel.registerProvider('groq', new OpenAICompatibleProvider({
265
+ id: 'groq',
266
+ name: 'Groq',
267
+ baseURL: 'https://api.groq.com/openai',
268
+ apiKey: process.env.GROQ_API_KEY!,
269
+ knownModels: [
270
+ { id: 'llama-3.3-70b-versatile', contextLength: 128_000, supportsVision: false },
271
+ ],
272
+ }));
273
+ ```
274
+
275
+ ### Adding Gemini
276
+
277
+ ```ts
278
+ import { GeminiProvider } from 'infinicode/kernel';
279
+
280
+ kernel.registerProvider('gemini', new GeminiProvider({
281
+ apiKey: process.env.GEMINI_API_KEY!,
282
+ knownModels: [
283
+ { id: 'gemini-2.0-flash', contextLength: 1_048_576, supportsVision: true, supportsFunctionCalling: true },
284
+ ],
285
+ }));
286
+ ```
287
+
288
+ ---
289
+
290
+ ## Browser Layer (Phase 4)
291
+
292
+ Default: **Playwright** (optional peer dependency). When Playwright is not installed, the browser controller degrades to a fetch-based read-only mode automatically.
293
+
294
+ ```ts
295
+ import { createBrowserPlugin } from 'infinicode/kernel';
296
+ await kernel.registerPlugin(createBrowserPlugin({ headless: true }));
297
+
298
+ // Drive the browser via a mission task:
299
+ const mission = await kernel.execute({
300
+ goal: 'Extract the latest news headlines',
301
+ tasks: [{
302
+ description: 'Open site and extract headlines',
303
+ capabilities: ['browser'],
304
+ input: {
305
+ prompt: 'Navigate and extract the top 5 headlines',
306
+ context: {
307
+ actions: [
308
+ { type: 'navigate', url: 'https://news.ycombinator.com' },
309
+ { type: 'extract' },
310
+ ],
311
+ },
312
+ },
313
+ }],
314
+ });
315
+ ```
316
+
317
+ ## Search Layer (Phase 4)
318
+
319
+ Default stack: **SearXNG → Crawler → Markdown → LLM**. Falls back to a DuckDuckGo HTML scrape when SearXNG is not configured.
320
+
321
+ ```ts
322
+ import { createSearchPlugin } from 'infinicode/kernel';
323
+ await kernel.registerPlugin(createSearchPlugin({ searxngUrl: 'http://localhost:8080' }));
324
+
325
+ // Research worker uses the search controller automatically:
326
+ const mission = await kernel.execute({
327
+ goal: 'Research latest TS patterns',
328
+ tasks: [{
329
+ description: 'Research and summarize',
330
+ capabilities: ['search', 'citations'],
331
+ input: { prompt: 'TypeScript branded types', context: { query: 'TypeScript branded types' } },
332
+ }],
333
+ });
334
+ ```
335
+
336
+ ## Plugin SDK & Harness SDK (Phase 4)
337
+
338
+ ```ts
339
+ import { definePlugin, mission, taskInput, browserTaskInput, researchTaskInput } from 'infinicode/kernel';
340
+
341
+ // Author a plugin fluently
342
+ const myPlugin = definePlugin('my-plugin')
343
+ .version('1.0.0')
344
+ .description('Custom notifier')
345
+ .subscribe(['MISSION_COMPLETED'], (e) => console.log('done', e.missionId))
346
+ .command('ping', 'Ping', async (args) => console.log('pong', args.join(' ')))
347
+ .build();
348
+ await kernel.registerPlugin(myPlugin);
349
+
350
+ // Build a mission input fluently
351
+ const input = mission('reverse-string', 'Produce a reverseString function')
352
+ .description('Write a TypeScript string reverser')
353
+ .policy('local-first')
354
+ .task('Write the function', ['coding', 'reasoning'], taskInput('Write `reverseString(s)`'))
355
+ .build();
356
+ await kernel.execute(input);
357
+ ```
358
+
359
+ ## Dashboard & Metrics (Phase 4)
360
+
361
+ ```ts
362
+ import { createDashboardPlugin, createMetricsPlugin } from 'infinicode/kernel';
363
+
364
+ const metrics = createMetricsPlugin();
365
+ await kernel.registerPlugin(metrics);
366
+ await kernel.registerPlugin(createDashboardPlugin({ port: 7331 }));
367
+
368
+ // Read counters anytime
369
+ console.log(metrics.snapshot());
370
+ // → { missionsStarted: 3, tasksCompleted: 11, recoveries: 1, totalTokensOut: 4521, ... }
371
+ ```
372
+
373
+ The dashboard serves `http://127.0.0.1:7331/` (HTML), `/status`, `/missions`, `/events`.
374
+
375
+ ---
376
+
377
+ ## Policies
378
+
379
+ ```yaml
380
+ policy:
381
+ execution:
382
+ parallelism: 4
383
+ routing:
384
+ mode: free-first
385
+ verification:
386
+ strict
387
+ checkpoint:
388
+ every-task: true
389
+ retry:
390
+ maxAttempts: 5
391
+ notifications:
392
+ channels: [telegram]
393
+ ```
394
+
395
+ Built-in: `free-first`, `fastest`, `highest-quality`, `local-first`, `privacy-first`, `balanced`, `offline`.
396
+
397
+ ```ts
398
+ kernel.registerPolicy({
399
+ name: 'my-policy',
400
+ execution: { parallelism: 8 },
401
+ routing: { mode: 'balanced', preferredProviders: ['ollama', 'groq'] },
402
+ retry: { maxAttempts: 5 },
403
+ });
404
+ ```
405
+
406
+ ---
407
+
408
+ ## Public API
409
+
410
+ ```ts
411
+ kernel.execute(mission) // → Promise<Mission>
412
+ kernel.pause(missionId) // → Promise<void>
413
+ kernel.resume(missionId) // → Promise<Mission>
414
+ kernel.cancel(missionId) // → Promise<void>
415
+ kernel.status(missionId) // → Promise<MissionStatus>
416
+ kernel.subscribe(types, fn) // → unsubscribe
417
+ kernel.subscribeAll(fn) // → unsubscribe
418
+ kernel.registerWorker(def)
419
+ kernel.registerProvider(id, provider)
420
+ kernel.registerPlugin(plugin)
421
+ kernel.registerPolicy(policy)
422
+ kernel.getMission(id)
423
+ kernel.listMissions()
50
424
  ```
51
425
 
52
- ## Commands
426
+ ---
427
+
428
+ ## CLI Commands
53
429
 
54
430
  | Command | Alias | Description |
55
- |---------|-------|-------------|
431
+ |---|---|---|
56
432
  | `infinicode connect <ip>` | `ic c` | Quick connect to Ollama master |
57
- | `infinicode setup` | `ic s` | Interactive setup wizard |
58
- | `infinicode run` | `ic` | Start the coding agent (default) |
59
- | `infinicode models` | `ic m` | List available models |
60
- | `infinicode status` | | Show config & connection status |
61
- | `infinicode config --list` | | View all configuration |
62
- | `infinicode config --reset` | | Reset to defaults |
433
+ | `infinicode setup` | `ic s` | Interactive setup wizard (Ollama only) |
434
+ | `infinicode run` | `ic` | Start the infinicode TUI (full provider pool: Ollama + cloud) |
435
+ | `infinicode status` | | Show config & all provider health |
436
+ | `infinicode models` | `ic m` | List available models across all healthy providers |
437
+ | `infinicode config` | | View or modify configuration |
438
+ | `infinicode kernel-setup` | `ic ks` | **Friendly setup wizard — providers + worker models + policy** |
439
+ | `infinicode workers` | `ic w` | **View per-worker model preferences** |
440
+ | `infinicode workers edit` | `ic w e` | **Interactively pick a model per worker type** |
441
+ | `infinicode workers reset` | | Clear all worker pins |
442
+ | `infinicode providers` | `ic p` | **View configured providers** |
443
+ | `infinicode providers add` | | **Add a cloud provider (Groq/OpenRouter/GitHub/NVIDIA/HF/Gemini)** |
444
+ | `infinicode providers remove <id>` | | Remove a cloud provider |
445
+ | `infinicode providers test [id]` | | Test connection to one or all providers |
446
+ | `infinicode mission run` | `ic k run` | **Execute a mission through the kernel** |
447
+ | `infinicode mission samples` | | List built-in sample missions |
448
+ | `infinicode mission status <id>` | | Show mission status |
449
+ | `infinicode mission list` | | List missions in this session |
450
+ | `infinicode mission resume <id>` | | Resume a paused mission |
451
+ | `infinicode mission cancel <id>` | | Cancel a running mission |
452
+
453
+ ### Mission run options
63
454
 
64
- ## Configuration
455
+ ```
456
+ infinicode mission run \
457
+ --goal "Mission goal" \
458
+ --name "mission-name" \
459
+ --task "Task 1 description" --task "Task 2 description" \
460
+ --cap coding,reasoning \
461
+ --policy local-first \
462
+ --sample hello-code
463
+ ```
464
+
465
+ ---
65
466
 
66
- Config is stored automatically. Override with:
467
+ ## Worker Model Preferences
468
+
469
+ Workers request **capabilities** (coding, reasoning, vision, …). The router picks the best model. You can **pin** a specific model per worker type — the pinned pair is used when healthy, otherwise the router falls back.
67
470
 
68
471
  ```bash
69
- # Set default model
70
- infinicode config --set defaultModel=codestral:22b
472
+ # View current pins
473
+ infinicode workers
71
474
 
72
- # Set master URL
73
- infinicode config --set masterUrl=http://192.168.1.100:11434
475
+ # Interactively pick a model per worker type (arrow-key lists)
476
+ infinicode workers edit
477
+
478
+ # Clear all pins (router decides for every worker type)
479
+ infinicode workers reset
480
+ ```
481
+
482
+ Each worker type has a recommended default based on capability match across your configured providers. The wizard preselects the recommendation.
483
+
484
+ ### Worker types
485
+
486
+ | Type | Capabilities | Description |
487
+ |---|---|---|
488
+ | `coding` | coding, reasoning, filesystem, terminal | Writes code |
489
+ | `research` | search, crawl, summarize, citations | Researches with citations (SearXNG → Crawl → LLM) |
490
+ | `architecture` | architecture, planning, reasoning | Designs structure |
491
+ | `review` | review, coding, reasoning | Critiques code/design |
492
+ | `documentation` | documentation, summarize, reasoning | Produces docs |
493
+ | `translation` | translation, reasoning | Translates content |
494
+ | `terminal` | terminal, coding, filesystem | Produces shell commands |
495
+ | `verification` | verification, reasoning, review | Verifies acceptance criteria |
496
+ | `vision` | vision, ocr, reasoning | Analyzes images |
497
+ | `browser` | browser, crawl, search, reasoning | Drives a browser (Playwright or fetch fallback) |
498
+
499
+ ### Programmatic API
500
+
501
+ ```ts
502
+ kernel.workerRuntime.setWorkerPin('coding', 'groq', 'llama-3.3-70b-versatile');
503
+ kernel.workerRuntime.setWorkerPins(new Map([
504
+ ['coding', { providerId: 'ollama', modelId: 'qwen2.5-coder:14b' }],
505
+ ['research', { providerId: 'groq', modelId: 'llama-3.3-70b-versatile' }],
506
+ ]));
507
+ kernel.setDefaultPolicy('local-first');
508
+ ```
509
+
510
+ ---
511
+
512
+ **Harness owns:** Prompts, workflows, templates, agent design, memory strategy.
513
+ **Kernel owns:** Execution, scheduling, workers, routing, recovery, verification, checkpoints.
514
+
515
+ Perfect separation. A harness produces mission inputs; the kernel executes them.
516
+
517
+ ---
74
518
 
75
- # View all
519
+ ## Harness Integration
520
+
521
+ **Harness owns:** Prompts, workflows, templates, agent design, memory strategy.
522
+ **Kernel owns:** Execution, scheduling, workers, routing, recovery, verification, checkpoints.
523
+
524
+ Perfect separation. A harness produces mission inputs; the kernel executes them.
525
+
526
+ ---
527
+
528
+ ## Development Roadmap
529
+
530
+ ### Phase 1 — Core Runtime ✅
531
+
532
+ - [x] Mission Engine
533
+ - [x] Scheduler
534
+ - [x] Worker Runtime
535
+ - [x] Provider Interface (Ollama + OpenAI-compatible)
536
+ - [x] Event Bus
537
+ - [x] Checkpoints
538
+ - [x] Capability Router (policy-weighted scoring)
539
+ - [x] Policy Engine (7 built-in policies)
540
+ - [x] Plugin Manager + Telegram/Discord/Slack/Browser/Search stubs
541
+ - [x] Setup wizard + worker model pinning + free cloud provider presets
542
+
543
+ **Target:** Stable execution kernel. ✅
544
+
545
+ ### Phase 2 — Intelligent Routing
546
+
547
+ - [x] Model scoring benchmarks
548
+ - [x] Capability-based routing with health awareness
549
+ - [x] Free-first routing
550
+ - [x] Automatic failover (via Recovery Manager → rotate-provider)
551
+ - [x] Provider telemetry: 429 / quota / success-rate tracking
552
+
553
+ **Target:** Provider-independent inference. ✅
554
+
555
+ ### Phase 3 — Reliability
556
+
557
+ - [x] Verification engine (objective → compile → tests → lint → browser → expected output → LLM judge)
558
+ - [x] Recovery manager (retry → rotate provider → spawn different worker → replan → checkpoint)
559
+ - [x] Long-running missions (checkpoint + resume)
560
+ - [x] Persistent checkpoints (fs-backed, capped at 20/mission)
561
+ - [ ] Automatic replanning (planning-failure → replan action wired; full objective re-plan pending)
562
+
563
+ **Target:** Autonomous execution. ✅ (core)
564
+
565
+ ### Phase 4 — Ecosystem
566
+
567
+ - [x] Telegram notifications + slash commands (/status /workers /logs /pause /resume /retry /models /providers /checkpoints /goal)
568
+ - [x] Browser worker (Playwright-backed; fetch fallback when Playwright not installed)
569
+ - [x] Research worker (SearXNG → Crawl4AI-style crawler → Markdown → LLM; DuckDuckGo fallback)
570
+ - [x] Plugin SDK (`definePlugin()` fluent builder)
571
+ - [x] Harness SDK (`mission()` builder + `taskInput`/`browserTaskInput`/`researchTaskInput` helpers)
572
+ - [x] Dashboard plugin (HTTP `/status` `/missions` `/events` + HTML view)
573
+ - [x] Metrics plugin (runtime counters: missions/tasks/workers/tokens/latency)
574
+ - [x] Gemini provider (Google Generative Language API — dedicated class, not OpenAI-compatible)
575
+ - [ ] Natural chat with orchestrator via Telegram
576
+ - [ ] Vision / Email / Database / Storage / Monitoring plugins
577
+
578
+ **Target:** Extensible platform. ✅ (core)
579
+
580
+ ---
581
+
582
+ ## Configuration
583
+
584
+ Config is stored automatically (via `conf`). Override with:
585
+
586
+ ```bash
587
+ infinicode config --set defaultModel=qwen2.5-coder:14b
588
+ infinicode config --set masterUrl=http://192.168.1.100:11434
76
589
  infinicode config --list
77
590
  ```
78
591
 
79
- ## Recommended Models
592
+ Checkpoints persist to `.openkernel/checkpoints/` (capped at 20 per mission).
80
593
 
81
- For coding tasks on Ollama:
594
+ ---
595
+
596
+ ## Recommended Models
82
597
 
83
598
  | Model | Size | Best For |
84
- |-------|------|----------|
599
+ |---|---|---|
85
600
  | `qwen2.5-coder:14b` | 9GB | Great balance |
86
601
  | `qwen2.5-coder:32b` | 20GB | Best quality |
87
602
  | `deepseek-coder-v2:16b` | 10GB | Strong reasoning |
88
603
  | `codestral:22b` | 13GB | Fast completion |
89
604
 
90
- ## Architecture
91
-
92
- ```
93
- ┌─────────────────┐
94
- │ Laptop │
95
- │ (infinicode) │──┐
96
- └─────────────────┘ │
97
- │ ┌─────────────────┐
98
- ┌─────────────────┐ │ │ GPU Server │
99
- │ Desktop │──┼───▶│ (Ollama) │
100
- │ (infinicode) │ │ │ │
101
- └─────────────────┘ │ │ qwen2.5-coder │
102
- │ │ codestral │
103
- ┌─────────────────┐ │ └─────────────────┘
104
- │ Server │──┘
105
- │ (infinicode) │
106
- └─────────────────┘
107
- ```
108
-
109
- ## Security
110
-
111
- Exposing Ollama to your network means anyone on that network can use it.
112
-
113
- **Secure options:**
114
- 1. **VPN/Tailscale** — Only accessible on private network
115
- 2. **SSH Tunnel** — `ssh -L 11434:localhost:11434 gpu-server`
116
- 3. **Firewall** — Allow only specific IPs
605
+ ---
117
606
 
118
607
  ## Requirements
119
608
 
120
609
  - Node.js 20+
121
- - OpenCode installed (`npm install -g opencode`)
122
- - Ollama running somewhere on your network
610
+ - infinicode installed globally (`npm install -g infinicode`) — provides the TUI binary
611
+ - An Ollama master running somewhere on your network — for the kernel's default local provider
612
+ - Optional: cloud provider API keys (Groq, OpenRouter, GitHub, NVIDIA, HF, Gemini) for provider rotation
613
+
614
+ ---
123
615
 
124
616
  ## License
125
617
 
126
- MIT — Based on [OpenCode](https://github.com/sst/opencode)
618
+ MIT
127
619
 
128
620
  ---
129
621
 
130
- ⚡ Built for sovereign computing. Your code, your models, your hardware.
622
+ ⚡ Built for sovereign computing. Your code, your models, your hardware.