infinicode 2.8.27 → 2.8.29

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 CHANGED
@@ -1,624 +1,624 @@
1
- # OpenKernel
2
-
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)
51
-
52
- ```bash
53
- npm install -g infinicode
54
-
55
- # Connect to your Ollama master
56
- infinicode connect 192.168.1.100
57
-
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
62
- infinicode
63
- ```
64
-
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.
66
-
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`.
68
-
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
84
-
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.
96
-
97
- ```bash
98
- # install on each device
99
- npm install -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 — ask any running node for its peers (self + connected)
113
- curl http://localhost:47913/fed/nodes
114
- ```
115
-
116
- Set your cloud provider keys + policy **once on the hub**; every satellite auto-sources them (over `--seed`/`--lan`/`--tailscale`) and registers the providers + models live, no restart.
117
-
118
- Drive the fleet from an MCP host — register the control server (spawn / dispatch / follow / role / voice / mesh-map tools):
119
-
120
- ```jsonc
121
- // ~/.claude.json
122
- { "mcpServers": { "infinicode": { "command": "infinicode", "args": ["mcp", "--lan"] } } }
123
- ```
124
-
125
- Link a node onto an **InfiniBot** neural-mesh map (no InfiniBot changes needed):
126
-
127
- ```bash
128
- infinicode serve --hub --gateway ws://<infinibot-host>:18789 --gateway-token <token>
129
- ```
130
-
131
- 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`.
132
-
133
- > 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.
134
-
135
- ### As a library
136
-
137
- ```ts
138
- import { createKernel, OllamaProvider, OpenAICompatibleProvider } from 'infinicode/kernel';
139
-
140
- const kernel = createKernel();
141
-
142
- // Register providers (plugins — the application never knows which)
143
- kernel.registerProvider('ollama', new OllamaProvider({
144
- baseURL: 'http://192.168.1.100:11434',
145
- defaultModel: 'qwen2.5-coder:14b',
146
- }));
147
-
148
- kernel.registerProvider('openrouter', new OpenAICompatibleProvider({
149
- id: 'openrouter',
150
- name: 'OpenRouter',
151
- baseURL: 'https://openrouter.ai/api',
152
- apiKey: process.env.OPENROUTER_API_KEY!,
153
- }));
154
-
155
- // Subscribe to events (plugins, notifications, logging)
156
- kernel.subscribeAll(event => console.log(event.type));
157
-
158
- // Execute a mission — the kernel decides where/when/with which model
159
- const mission = await kernel.execute({
160
- name: 'reverse-string',
161
- description: 'Write a TypeScript string reverser',
162
- goal: 'Produce a reverseString function',
163
- policy: 'local-first',
164
- tasks: [
165
- {
166
- description: 'Write the function',
167
- capabilities: ['coding', 'reasoning'],
168
- input: { prompt: 'Write `reverseString(s: string): string`. Include only the function.' },
169
- },
170
- ],
171
- });
172
-
173
- console.log(mission.status, mission.tasks[0].output?.content);
174
- ```
175
-
176
- ---
177
-
178
- ## Core Principles
179
-
180
- 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.
181
- 2. **Framework Agnostic** — works equally well with Harness, custom workflows, CLI, n8n, Discord bots, VSCode extensions. Everything interacts through the same execution API.
182
- 3. **Model Agnostic** — workers never request "Gemini". They request `Need: Coding, Reasoning>90, Vision, Context>128K`. The router decides.
183
- 4. **Provider Agnostic** — providers are plugins. The application never knows.
184
-
185
- ---
186
-
187
- ## Architecture
188
-
189
- ```
190
- Applications
191
-
192
- Harness CLI n8n VSCode
193
-
194
-
195
- ──────────────────── API ───────────────────
196
-
197
- AI Execution Kernel
198
- ────────────────────────────────────────────
199
-
200
- Mission Engine
201
- Native Orchestrator
202
- Scheduler
203
- Worker Runtime
204
- Capability Router
205
- Provider Manager
206
- Policy Engine
207
- Verification
208
- Recovery
209
- Checkpoint Engine
210
- Event Bus
211
- Plugin Manager
212
- ────────────────────────────────────────────
213
-
214
- Providers Tools Workers Notifications
215
- ```
216
-
217
- ### Components
218
-
219
- | Component | Responsibility |
220
- |---|---|
221
- | **Mission Engine** | Lifecycle (NEW → PLANNING → READY → RUNNING → VERIFYING → WAITING → FAILED → COMPLETED), pause/resume, completion |
222
- | **Native Orchestrator** | Always running. Coordinates everything, executes nothing directly |
223
- | **Scheduler** | Mission → Objectives → Tasks → Execution Queue → Workers. Sequential, parallel, dependency graphs |
224
- | **Worker Runtime** | Disposable capability containers: Spawn → Initialize → Execute → Verify → Publish → Destroy |
225
- | **Capability Registry** | Workers advertise capabilities (coding, browser, vision, terminal, planning, reasoning, …) |
226
- | **Policy Engine** | 7 built-in policies: free-first, fastest, highest-quality, local-first, privacy-first, balanced, offline |
227
- | **Intelligent Router** | Scores: capability + reliability + speed + quota + context + policy − cost → best model + provider |
228
- | **Provider Manager** | Tracks models, quota, 429s, latency, success rate, health. Background refresh only, never blocks |
229
- | **Verification Engine** | Pipeline: objective → compile → tests → lint → browser tests → expected output → LLM judge (always last) |
230
- | **Recovery Manager** | Classifies failures (429, timeout, provider-down, hallucination, …) → retry / rotate / spawn-different-worker / replan / checkpoint |
231
- | **Checkpoint Engine** | Persists mission, objectives, tasks, worker state, memory, logs, artifacts. Pause/resume/crash-recovery |
232
- | **Event Bus** | Everything emits events. Plugins subscribe |
233
- | **Plugin System** | Core stays tiny. Telegram, Discord, Slack, Browser, Search, Dashboard, Metrics, … all optional |
234
-
235
- ---
236
-
237
- ## Worker Types (built-in)
238
-
239
- 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.
240
-
241
- ```
242
- research browser coding architecture
243
- vision review documentation translation
244
- terminal verification
245
- ```
246
-
247
- Register custom workers via `kernel.registerWorker({ type, capabilities, preferences })`.
248
-
249
- ---
250
-
251
- ## Providers (built-in)
252
-
253
- | Provider | Type | File |
254
- |---|---|---|
255
- | **Ollama** | local | `ollama-provider.ts` (LAN + Tailscale fallback, migrated from v1) |
256
- | **OpenAI-compatible** | local/cloud | `openai-compatible-provider.ts` (powers OpenRouter, Groq, GitHub Models, NVIDIA, HF, vLLM, LM Studio, SGLang) |
257
- | **Gemini** | cloud | `gemini-provider.ts` (Google Generative Language API — generateContent / streamGenerateContent) |
258
-
259
- All three implement the same `ProviderInterface`. The application never knows which is in use.
260
-
261
- ### Adding a cloud provider
262
-
263
- ```ts
264
- import { OpenAICompatibleProvider } from 'infinicode/kernel';
265
-
266
- kernel.registerProvider('groq', new OpenAICompatibleProvider({
267
- id: 'groq',
268
- name: 'Groq',
269
- baseURL: 'https://api.groq.com/openai',
270
- apiKey: process.env.GROQ_API_KEY!,
271
- knownModels: [
272
- { id: 'llama-3.3-70b-versatile', contextLength: 128_000, supportsVision: false },
273
- ],
274
- }));
275
- ```
276
-
277
- ### Adding Gemini
278
-
279
- ```ts
280
- import { GeminiProvider } from 'infinicode/kernel';
281
-
282
- kernel.registerProvider('gemini', new GeminiProvider({
283
- apiKey: process.env.GEMINI_API_KEY!,
284
- knownModels: [
285
- { id: 'gemini-2.0-flash', contextLength: 1_048_576, supportsVision: true, supportsFunctionCalling: true },
286
- ],
287
- }));
288
- ```
289
-
290
- ---
291
-
292
- ## Browser Layer (Phase 4)
293
-
294
- Default: **Playwright** (optional peer dependency). When Playwright is not installed, the browser controller degrades to a fetch-based read-only mode automatically.
295
-
296
- ```ts
297
- import { createBrowserPlugin } from 'infinicode/kernel';
298
- await kernel.registerPlugin(createBrowserPlugin({ headless: true }));
299
-
300
- // Drive the browser via a mission task:
301
- const mission = await kernel.execute({
302
- goal: 'Extract the latest news headlines',
303
- tasks: [{
304
- description: 'Open site and extract headlines',
305
- capabilities: ['browser'],
306
- input: {
307
- prompt: 'Navigate and extract the top 5 headlines',
308
- context: {
309
- actions: [
310
- { type: 'navigate', url: 'https://news.ycombinator.com' },
311
- { type: 'extract' },
312
- ],
313
- },
314
- },
315
- }],
316
- });
317
- ```
318
-
319
- ## Search Layer (Phase 4)
320
-
321
- Default stack: **SearXNG → Crawler → Markdown → LLM**. Falls back to a DuckDuckGo HTML scrape when SearXNG is not configured.
322
-
323
- ```ts
324
- import { createSearchPlugin } from 'infinicode/kernel';
325
- await kernel.registerPlugin(createSearchPlugin({ searxngUrl: 'http://localhost:8080' }));
326
-
327
- // Research worker uses the search controller automatically:
328
- const mission = await kernel.execute({
329
- goal: 'Research latest TS patterns',
330
- tasks: [{
331
- description: 'Research and summarize',
332
- capabilities: ['search', 'citations'],
333
- input: { prompt: 'TypeScript branded types', context: { query: 'TypeScript branded types' } },
334
- }],
335
- });
336
- ```
337
-
338
- ## Plugin SDK & Harness SDK (Phase 4)
339
-
340
- ```ts
341
- import { definePlugin, mission, taskInput, browserTaskInput, researchTaskInput } from 'infinicode/kernel';
342
-
343
- // Author a plugin fluently
344
- const myPlugin = definePlugin('my-plugin')
345
- .version('1.0.0')
346
- .description('Custom notifier')
347
- .subscribe(['MISSION_COMPLETED'], (e) => console.log('done', e.missionId))
348
- .command('ping', 'Ping', async (args) => console.log('pong', args.join(' ')))
349
- .build();
350
- await kernel.registerPlugin(myPlugin);
351
-
352
- // Build a mission input fluently
353
- const input = mission('reverse-string', 'Produce a reverseString function')
354
- .description('Write a TypeScript string reverser')
355
- .policy('local-first')
356
- .task('Write the function', ['coding', 'reasoning'], taskInput('Write `reverseString(s)`'))
357
- .build();
358
- await kernel.execute(input);
359
- ```
360
-
361
- ## Dashboard & Metrics (Phase 4)
362
-
363
- ```ts
364
- import { createDashboardPlugin, createMetricsPlugin } from 'infinicode/kernel';
365
-
366
- const metrics = createMetricsPlugin();
367
- await kernel.registerPlugin(metrics);
368
- await kernel.registerPlugin(createDashboardPlugin({ port: 7331 }));
369
-
370
- // Read counters anytime
371
- console.log(metrics.snapshot());
372
- // → { missionsStarted: 3, tasksCompleted: 11, recoveries: 1, totalTokensOut: 4521, ... }
373
- ```
374
-
375
- The dashboard serves `http://127.0.0.1:7331/` (HTML), `/status`, `/missions`, `/events`.
376
-
377
- ---
378
-
379
- ## Policies
380
-
381
- ```yaml
382
- policy:
383
- execution:
384
- parallelism: 4
385
- routing:
386
- mode: free-first
387
- verification:
388
- strict
389
- checkpoint:
390
- every-task: true
391
- retry:
392
- maxAttempts: 5
393
- notifications:
394
- channels: [telegram]
395
- ```
396
-
397
- Built-in: `free-first`, `fastest`, `highest-quality`, `local-first`, `privacy-first`, `balanced`, `offline`.
398
-
399
- ```ts
400
- kernel.registerPolicy({
401
- name: 'my-policy',
402
- execution: { parallelism: 8 },
403
- routing: { mode: 'balanced', preferredProviders: ['ollama', 'groq'] },
404
- retry: { maxAttempts: 5 },
405
- });
406
- ```
407
-
408
- ---
409
-
410
- ## Public API
411
-
412
- ```ts
413
- kernel.execute(mission) // → Promise<Mission>
414
- kernel.pause(missionId) // → Promise<void>
415
- kernel.resume(missionId) // → Promise<Mission>
416
- kernel.cancel(missionId) // → Promise<void>
417
- kernel.status(missionId) // → Promise<MissionStatus>
418
- kernel.subscribe(types, fn) // → unsubscribe
419
- kernel.subscribeAll(fn) // → unsubscribe
420
- kernel.registerWorker(def)
421
- kernel.registerProvider(id, provider)
422
- kernel.registerPlugin(plugin)
423
- kernel.registerPolicy(policy)
424
- kernel.getMission(id)
425
- kernel.listMissions()
426
- ```
427
-
428
- ---
429
-
430
- ## CLI Commands
431
-
432
- | Command | Alias | Description |
433
- |---|---|---|
434
- | `infinicode connect <ip>` | `ic c` | Quick connect to Ollama master |
435
- | `infinicode setup` | `ic s` | Interactive setup wizard (Ollama only) |
436
- | `infinicode run` | `ic` | Start the infinicode TUI (full provider pool: Ollama + cloud) |
437
- | `infinicode status` | | Show config & all provider health |
438
- | `infinicode models` | `ic m` | List available models across all healthy providers |
439
- | `infinicode config` | | View or modify configuration |
440
- | `infinicode kernel-setup` | `ic ks` | **Friendly setup wizard — providers + worker models + policy** |
441
- | `infinicode workers` | `ic w` | **View per-worker model preferences** |
442
- | `infinicode workers edit` | `ic w e` | **Interactively pick a model per worker type** |
443
- | `infinicode workers reset` | | Clear all worker pins |
444
- | `infinicode providers` | `ic p` | **View configured providers** |
445
- | `infinicode providers add` | | **Add a cloud provider (Groq/OpenRouter/GitHub/NVIDIA/HF/Gemini)** |
446
- | `infinicode providers remove <id>` | | Remove a cloud provider |
447
- | `infinicode providers test [id]` | | Test connection to one or all providers |
448
- | `infinicode mission run` | `ic k run` | **Execute a mission through the kernel** |
449
- | `infinicode mission samples` | | List built-in sample missions |
450
- | `infinicode mission status <id>` | | Show mission status |
451
- | `infinicode mission list` | | List missions in this session |
452
- | `infinicode mission resume <id>` | | Resume a paused mission |
453
- | `infinicode mission cancel <id>` | | Cancel a running mission |
454
-
455
- ### Mission run options
456
-
457
- ```
458
- infinicode mission run \
459
- --goal "Mission goal" \
460
- --name "mission-name" \
461
- --task "Task 1 description" --task "Task 2 description" \
462
- --cap coding,reasoning \
463
- --policy local-first \
464
- --sample hello-code
465
- ```
466
-
467
- ---
468
-
469
- ## Worker Model Preferences
470
-
471
- 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.
472
-
473
- ```bash
474
- # View current pins
475
- infinicode workers
476
-
477
- # Interactively pick a model per worker type (arrow-key lists)
478
- infinicode workers edit
479
-
480
- # Clear all pins (router decides for every worker type)
481
- infinicode workers reset
482
- ```
483
-
484
- Each worker type has a recommended default based on capability match across your configured providers. The wizard preselects the recommendation.
485
-
486
- ### Worker types
487
-
488
- | Type | Capabilities | Description |
489
- |---|---|---|
490
- | `coding` | coding, reasoning, filesystem, terminal | Writes code |
491
- | `research` | search, crawl, summarize, citations | Researches with citations (SearXNG → Crawl → LLM) |
492
- | `architecture` | architecture, planning, reasoning | Designs structure |
493
- | `review` | review, coding, reasoning | Critiques code/design |
494
- | `documentation` | documentation, summarize, reasoning | Produces docs |
495
- | `translation` | translation, reasoning | Translates content |
496
- | `terminal` | terminal, coding, filesystem | Produces shell commands |
497
- | `verification` | verification, reasoning, review | Verifies acceptance criteria |
498
- | `vision` | vision, ocr, reasoning | Analyzes images |
499
- | `browser` | browser, crawl, search, reasoning | Drives a browser (Playwright or fetch fallback) |
500
-
501
- ### Programmatic API
502
-
503
- ```ts
504
- kernel.workerRuntime.setWorkerPin('coding', 'groq', 'llama-3.3-70b-versatile');
505
- kernel.workerRuntime.setWorkerPins(new Map([
506
- ['coding', { providerId: 'ollama', modelId: 'qwen2.5-coder:14b' }],
507
- ['research', { providerId: 'groq', modelId: 'llama-3.3-70b-versatile' }],
508
- ]));
509
- kernel.setDefaultPolicy('local-first');
510
- ```
511
-
512
- ---
513
-
514
- **Harness owns:** Prompts, workflows, templates, agent design, memory strategy.
515
- **Kernel owns:** Execution, scheduling, workers, routing, recovery, verification, checkpoints.
516
-
517
- Perfect separation. A harness produces mission inputs; the kernel executes them.
518
-
519
- ---
520
-
521
- ## Harness Integration
522
-
523
- **Harness owns:** Prompts, workflows, templates, agent design, memory strategy.
524
- **Kernel owns:** Execution, scheduling, workers, routing, recovery, verification, checkpoints.
525
-
526
- Perfect separation. A harness produces mission inputs; the kernel executes them.
527
-
528
- ---
529
-
530
- ## Development Roadmap
531
-
532
- ### Phase 1 — Core Runtime ✅
533
-
534
- - [x] Mission Engine
535
- - [x] Scheduler
536
- - [x] Worker Runtime
537
- - [x] Provider Interface (Ollama + OpenAI-compatible)
538
- - [x] Event Bus
539
- - [x] Checkpoints
540
- - [x] Capability Router (policy-weighted scoring)
541
- - [x] Policy Engine (7 built-in policies)
542
- - [x] Plugin Manager + Telegram/Discord/Slack/Browser/Search stubs
543
- - [x] Setup wizard + worker model pinning + free cloud provider presets
544
-
545
- **Target:** Stable execution kernel. ✅
546
-
547
- ### Phase 2 — Intelligent Routing
548
-
549
- - [x] Model scoring benchmarks
550
- - [x] Capability-based routing with health awareness
551
- - [x] Free-first routing
552
- - [x] Automatic failover (via Recovery Manager → rotate-provider)
553
- - [x] Provider telemetry: 429 / quota / success-rate tracking
554
-
555
- **Target:** Provider-independent inference. ✅
556
-
557
- ### Phase 3 — Reliability
558
-
559
- - [x] Verification engine (objective → compile → tests → lint → browser → expected output → LLM judge)
560
- - [x] Recovery manager (retry → rotate provider → spawn different worker → replan → checkpoint)
561
- - [x] Long-running missions (checkpoint + resume)
562
- - [x] Persistent checkpoints (fs-backed, capped at 20/mission)
563
- - [ ] Automatic replanning (planning-failure → replan action wired; full objective re-plan pending)
564
-
565
- **Target:** Autonomous execution. ✅ (core)
566
-
567
- ### Phase 4 — Ecosystem
568
-
569
- - [x] Telegram notifications + slash commands (/status /workers /logs /pause /resume /retry /models /providers /checkpoints /goal)
570
- - [x] Browser worker (Playwright-backed; fetch fallback when Playwright not installed)
571
- - [x] Research worker (SearXNG → Crawl4AI-style crawler → Markdown → LLM; DuckDuckGo fallback)
572
- - [x] Plugin SDK (`definePlugin()` fluent builder)
573
- - [x] Harness SDK (`mission()` builder + `taskInput`/`browserTaskInput`/`researchTaskInput` helpers)
574
- - [x] Dashboard plugin (HTTP `/status` `/missions` `/events` + HTML view)
575
- - [x] Metrics plugin (runtime counters: missions/tasks/workers/tokens/latency)
576
- - [x] Gemini provider (Google Generative Language API — dedicated class, not OpenAI-compatible)
577
- - [ ] Natural chat with orchestrator via Telegram
578
- - [ ] Vision / Email / Database / Storage / Monitoring plugins
579
-
580
- **Target:** Extensible platform. ✅ (core)
581
-
582
- ---
583
-
584
- ## Configuration
585
-
586
- Config is stored automatically (via `conf`). Override with:
587
-
588
- ```bash
589
- infinicode config --set defaultModel=qwen2.5-coder:14b
590
- infinicode config --set masterUrl=http://192.168.1.100:11434
591
- infinicode config --list
592
- ```
593
-
594
- Checkpoints persist to `.openkernel/checkpoints/` (capped at 20 per mission).
595
-
596
- ---
597
-
598
- ## Recommended Models
599
-
600
- | Model | Size | Best For |
601
- |---|---|---|
602
- | `qwen2.5-coder:14b` | 9GB | Great balance |
603
- | `qwen2.5-coder:32b` | 20GB | Best quality |
604
- | `deepseek-coder-v2:16b` | 10GB | Strong reasoning |
605
- | `codestral:22b` | 13GB | Fast completion |
606
-
607
- ---
608
-
609
- ## Requirements
610
-
611
- - Node.js 20+
612
- - infinicode installed globally (`npm install -g infinicode`) — provides the TUI binary
613
- - An Ollama master running somewhere on your network — for the kernel's default local provider
614
- - Optional: cloud provider API keys (Groq, OpenRouter, GitHub, NVIDIA, HF, Gemini) for provider rotation
615
-
616
- ---
617
-
618
- ## License
619
-
620
- MIT
621
-
622
- ---
623
-
1
+ # OpenKernel
2
+
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)
51
+
52
+ ```bash
53
+ npm install -g infinicode
54
+
55
+ # Connect to your Ollama master
56
+ infinicode connect 192.168.1.100
57
+
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
62
+ infinicode
63
+ ```
64
+
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.
66
+
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`.
68
+
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
84
+
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.
96
+
97
+ ```bash
98
+ # install on each device
99
+ npm install -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 — ask any running node for its peers (self + connected)
113
+ curl http://localhost:47913/fed/nodes
114
+ ```
115
+
116
+ Set your cloud provider keys + policy **once on the hub**; every satellite auto-sources them (over `--seed`/`--lan`/`--tailscale`) and registers the providers + models live, no restart.
117
+
118
+ Drive the fleet from an MCP host — register the control server (spawn / dispatch / follow / role / voice / mesh-map tools):
119
+
120
+ ```jsonc
121
+ // ~/.claude.json
122
+ { "mcpServers": { "infinicode": { "command": "infinicode", "args": ["mcp", "--lan"] } } }
123
+ ```
124
+
125
+ Link a node onto an **InfiniBot** neural-mesh map (no InfiniBot changes needed):
126
+
127
+ ```bash
128
+ infinicode serve --hub --gateway ws://<infinibot-host>:18789 --gateway-token <token>
129
+ ```
130
+
131
+ 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`.
132
+
133
+ > 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.
134
+
135
+ ### As a library
136
+
137
+ ```ts
138
+ import { createKernel, OllamaProvider, OpenAICompatibleProvider } from 'infinicode/kernel';
139
+
140
+ const kernel = createKernel();
141
+
142
+ // Register providers (plugins — the application never knows which)
143
+ kernel.registerProvider('ollama', new OllamaProvider({
144
+ baseURL: 'http://192.168.1.100:11434',
145
+ defaultModel: 'qwen2.5-coder:14b',
146
+ }));
147
+
148
+ kernel.registerProvider('openrouter', new OpenAICompatibleProvider({
149
+ id: 'openrouter',
150
+ name: 'OpenRouter',
151
+ baseURL: 'https://openrouter.ai/api',
152
+ apiKey: process.env.OPENROUTER_API_KEY!,
153
+ }));
154
+
155
+ // Subscribe to events (plugins, notifications, logging)
156
+ kernel.subscribeAll(event => console.log(event.type));
157
+
158
+ // Execute a mission — the kernel decides where/when/with which model
159
+ const mission = await kernel.execute({
160
+ name: 'reverse-string',
161
+ description: 'Write a TypeScript string reverser',
162
+ goal: 'Produce a reverseString function',
163
+ policy: 'local-first',
164
+ tasks: [
165
+ {
166
+ description: 'Write the function',
167
+ capabilities: ['coding', 'reasoning'],
168
+ input: { prompt: 'Write `reverseString(s: string): string`. Include only the function.' },
169
+ },
170
+ ],
171
+ });
172
+
173
+ console.log(mission.status, mission.tasks[0].output?.content);
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Core Principles
179
+
180
+ 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.
181
+ 2. **Framework Agnostic** — works equally well with Harness, custom workflows, CLI, n8n, Discord bots, VSCode extensions. Everything interacts through the same execution API.
182
+ 3. **Model Agnostic** — workers never request "Gemini". They request `Need: Coding, Reasoning>90, Vision, Context>128K`. The router decides.
183
+ 4. **Provider Agnostic** — providers are plugins. The application never knows.
184
+
185
+ ---
186
+
187
+ ## Architecture
188
+
189
+ ```
190
+ Applications
191
+
192
+ Harness CLI n8n VSCode
193
+
194
+
195
+ ──────────────────── API ───────────────────
196
+
197
+ AI Execution Kernel
198
+ ────────────────────────────────────────────
199
+
200
+ Mission Engine
201
+ Native Orchestrator
202
+ Scheduler
203
+ Worker Runtime
204
+ Capability Router
205
+ Provider Manager
206
+ Policy Engine
207
+ Verification
208
+ Recovery
209
+ Checkpoint Engine
210
+ Event Bus
211
+ Plugin Manager
212
+ ────────────────────────────────────────────
213
+
214
+ Providers Tools Workers Notifications
215
+ ```
216
+
217
+ ### Components
218
+
219
+ | Component | Responsibility |
220
+ |---|---|
221
+ | **Mission Engine** | Lifecycle (NEW → PLANNING → READY → RUNNING → VERIFYING → WAITING → FAILED → COMPLETED), pause/resume, completion |
222
+ | **Native Orchestrator** | Always running. Coordinates everything, executes nothing directly |
223
+ | **Scheduler** | Mission → Objectives → Tasks → Execution Queue → Workers. Sequential, parallel, dependency graphs |
224
+ | **Worker Runtime** | Disposable capability containers: Spawn → Initialize → Execute → Verify → Publish → Destroy |
225
+ | **Capability Registry** | Workers advertise capabilities (coding, browser, vision, terminal, planning, reasoning, …) |
226
+ | **Policy Engine** | 7 built-in policies: free-first, fastest, highest-quality, local-first, privacy-first, balanced, offline |
227
+ | **Intelligent Router** | Scores: capability + reliability + speed + quota + context + policy − cost → best model + provider |
228
+ | **Provider Manager** | Tracks models, quota, 429s, latency, success rate, health. Background refresh only, never blocks |
229
+ | **Verification Engine** | Pipeline: objective → compile → tests → lint → browser tests → expected output → LLM judge (always last) |
230
+ | **Recovery Manager** | Classifies failures (429, timeout, provider-down, hallucination, …) → retry / rotate / spawn-different-worker / replan / checkpoint |
231
+ | **Checkpoint Engine** | Persists mission, objectives, tasks, worker state, memory, logs, artifacts. Pause/resume/crash-recovery |
232
+ | **Event Bus** | Everything emits events. Plugins subscribe |
233
+ | **Plugin System** | Core stays tiny. Telegram, Discord, Slack, Browser, Search, Dashboard, Metrics, … all optional |
234
+
235
+ ---
236
+
237
+ ## Worker Types (built-in)
238
+
239
+ 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.
240
+
241
+ ```
242
+ research browser coding architecture
243
+ vision review documentation translation
244
+ terminal verification
245
+ ```
246
+
247
+ Register custom workers via `kernel.registerWorker({ type, capabilities, preferences })`.
248
+
249
+ ---
250
+
251
+ ## Providers (built-in)
252
+
253
+ | Provider | Type | File |
254
+ |---|---|---|
255
+ | **Ollama** | local | `ollama-provider.ts` (LAN + Tailscale fallback, migrated from v1) |
256
+ | **OpenAI-compatible** | local/cloud | `openai-compatible-provider.ts` (powers OpenRouter, Groq, GitHub Models, NVIDIA, HF, vLLM, LM Studio, SGLang) |
257
+ | **Gemini** | cloud | `gemini-provider.ts` (Google Generative Language API — generateContent / streamGenerateContent) |
258
+
259
+ All three implement the same `ProviderInterface`. The application never knows which is in use.
260
+
261
+ ### Adding a cloud provider
262
+
263
+ ```ts
264
+ import { OpenAICompatibleProvider } from 'infinicode/kernel';
265
+
266
+ kernel.registerProvider('groq', new OpenAICompatibleProvider({
267
+ id: 'groq',
268
+ name: 'Groq',
269
+ baseURL: 'https://api.groq.com/openai',
270
+ apiKey: process.env.GROQ_API_KEY!,
271
+ knownModels: [
272
+ { id: 'llama-3.3-70b-versatile', contextLength: 128_000, supportsVision: false },
273
+ ],
274
+ }));
275
+ ```
276
+
277
+ ### Adding Gemini
278
+
279
+ ```ts
280
+ import { GeminiProvider } from 'infinicode/kernel';
281
+
282
+ kernel.registerProvider('gemini', new GeminiProvider({
283
+ apiKey: process.env.GEMINI_API_KEY!,
284
+ knownModels: [
285
+ { id: 'gemini-2.0-flash', contextLength: 1_048_576, supportsVision: true, supportsFunctionCalling: true },
286
+ ],
287
+ }));
288
+ ```
289
+
290
+ ---
291
+
292
+ ## Browser Layer (Phase 4)
293
+
294
+ Default: **Playwright** (optional peer dependency). When Playwright is not installed, the browser controller degrades to a fetch-based read-only mode automatically.
295
+
296
+ ```ts
297
+ import { createBrowserPlugin } from 'infinicode/kernel';
298
+ await kernel.registerPlugin(createBrowserPlugin({ headless: true }));
299
+
300
+ // Drive the browser via a mission task:
301
+ const mission = await kernel.execute({
302
+ goal: 'Extract the latest news headlines',
303
+ tasks: [{
304
+ description: 'Open site and extract headlines',
305
+ capabilities: ['browser'],
306
+ input: {
307
+ prompt: 'Navigate and extract the top 5 headlines',
308
+ context: {
309
+ actions: [
310
+ { type: 'navigate', url: 'https://news.ycombinator.com' },
311
+ { type: 'extract' },
312
+ ],
313
+ },
314
+ },
315
+ }],
316
+ });
317
+ ```
318
+
319
+ ## Search Layer (Phase 4)
320
+
321
+ Default stack: **SearXNG → Crawler → Markdown → LLM**. Falls back to a DuckDuckGo HTML scrape when SearXNG is not configured.
322
+
323
+ ```ts
324
+ import { createSearchPlugin } from 'infinicode/kernel';
325
+ await kernel.registerPlugin(createSearchPlugin({ searxngUrl: 'http://localhost:8080' }));
326
+
327
+ // Research worker uses the search controller automatically:
328
+ const mission = await kernel.execute({
329
+ goal: 'Research latest TS patterns',
330
+ tasks: [{
331
+ description: 'Research and summarize',
332
+ capabilities: ['search', 'citations'],
333
+ input: { prompt: 'TypeScript branded types', context: { query: 'TypeScript branded types' } },
334
+ }],
335
+ });
336
+ ```
337
+
338
+ ## Plugin SDK & Harness SDK (Phase 4)
339
+
340
+ ```ts
341
+ import { definePlugin, mission, taskInput, browserTaskInput, researchTaskInput } from 'infinicode/kernel';
342
+
343
+ // Author a plugin fluently
344
+ const myPlugin = definePlugin('my-plugin')
345
+ .version('1.0.0')
346
+ .description('Custom notifier')
347
+ .subscribe(['MISSION_COMPLETED'], (e) => console.log('done', e.missionId))
348
+ .command('ping', 'Ping', async (args) => console.log('pong', args.join(' ')))
349
+ .build();
350
+ await kernel.registerPlugin(myPlugin);
351
+
352
+ // Build a mission input fluently
353
+ const input = mission('reverse-string', 'Produce a reverseString function')
354
+ .description('Write a TypeScript string reverser')
355
+ .policy('local-first')
356
+ .task('Write the function', ['coding', 'reasoning'], taskInput('Write `reverseString(s)`'))
357
+ .build();
358
+ await kernel.execute(input);
359
+ ```
360
+
361
+ ## Dashboard & Metrics (Phase 4)
362
+
363
+ ```ts
364
+ import { createDashboardPlugin, createMetricsPlugin } from 'infinicode/kernel';
365
+
366
+ const metrics = createMetricsPlugin();
367
+ await kernel.registerPlugin(metrics);
368
+ await kernel.registerPlugin(createDashboardPlugin({ port: 7331 }));
369
+
370
+ // Read counters anytime
371
+ console.log(metrics.snapshot());
372
+ // → { missionsStarted: 3, tasksCompleted: 11, recoveries: 1, totalTokensOut: 4521, ... }
373
+ ```
374
+
375
+ The dashboard serves `http://127.0.0.1:7331/` (HTML), `/status`, `/missions`, `/events`.
376
+
377
+ ---
378
+
379
+ ## Policies
380
+
381
+ ```yaml
382
+ policy:
383
+ execution:
384
+ parallelism: 4
385
+ routing:
386
+ mode: free-first
387
+ verification:
388
+ strict
389
+ checkpoint:
390
+ every-task: true
391
+ retry:
392
+ maxAttempts: 5
393
+ notifications:
394
+ channels: [telegram]
395
+ ```
396
+
397
+ Built-in: `free-first`, `fastest`, `highest-quality`, `local-first`, `privacy-first`, `balanced`, `offline`.
398
+
399
+ ```ts
400
+ kernel.registerPolicy({
401
+ name: 'my-policy',
402
+ execution: { parallelism: 8 },
403
+ routing: { mode: 'balanced', preferredProviders: ['ollama', 'groq'] },
404
+ retry: { maxAttempts: 5 },
405
+ });
406
+ ```
407
+
408
+ ---
409
+
410
+ ## Public API
411
+
412
+ ```ts
413
+ kernel.execute(mission) // → Promise<Mission>
414
+ kernel.pause(missionId) // → Promise<void>
415
+ kernel.resume(missionId) // → Promise<Mission>
416
+ kernel.cancel(missionId) // → Promise<void>
417
+ kernel.status(missionId) // → Promise<MissionStatus>
418
+ kernel.subscribe(types, fn) // → unsubscribe
419
+ kernel.subscribeAll(fn) // → unsubscribe
420
+ kernel.registerWorker(def)
421
+ kernel.registerProvider(id, provider)
422
+ kernel.registerPlugin(plugin)
423
+ kernel.registerPolicy(policy)
424
+ kernel.getMission(id)
425
+ kernel.listMissions()
426
+ ```
427
+
428
+ ---
429
+
430
+ ## CLI Commands
431
+
432
+ | Command | Alias | Description |
433
+ |---|---|---|
434
+ | `infinicode connect <ip>` | `ic c` | Quick connect to Ollama master |
435
+ | `infinicode setup` | `ic s` | Interactive setup wizard (Ollama only) |
436
+ | `infinicode run` | `ic` | Start the infinicode TUI (full provider pool: Ollama + cloud) |
437
+ | `infinicode status` | | Show config & all provider health |
438
+ | `infinicode models` | `ic m` | List available models across all healthy providers |
439
+ | `infinicode config` | | View or modify configuration |
440
+ | `infinicode kernel-setup` | `ic ks` | **Friendly setup wizard — providers + worker models + policy** |
441
+ | `infinicode workers` | `ic w` | **View per-worker model preferences** |
442
+ | `infinicode workers edit` | `ic w e` | **Interactively pick a model per worker type** |
443
+ | `infinicode workers reset` | | Clear all worker pins |
444
+ | `infinicode providers` | `ic p` | **View configured providers** |
445
+ | `infinicode providers add` | | **Add a cloud provider (Groq/OpenRouter/GitHub/NVIDIA/HF/Gemini)** |
446
+ | `infinicode providers remove <id>` | | Remove a cloud provider |
447
+ | `infinicode providers test [id]` | | Test connection to one or all providers |
448
+ | `infinicode mission run` | `ic k run` | **Execute a mission through the kernel** |
449
+ | `infinicode mission samples` | | List built-in sample missions |
450
+ | `infinicode mission status <id>` | | Show mission status |
451
+ | `infinicode mission list` | | List missions in this session |
452
+ | `infinicode mission resume <id>` | | Resume a paused mission |
453
+ | `infinicode mission cancel <id>` | | Cancel a running mission |
454
+
455
+ ### Mission run options
456
+
457
+ ```
458
+ infinicode mission run \
459
+ --goal "Mission goal" \
460
+ --name "mission-name" \
461
+ --task "Task 1 description" --task "Task 2 description" \
462
+ --cap coding,reasoning \
463
+ --policy local-first \
464
+ --sample hello-code
465
+ ```
466
+
467
+ ---
468
+
469
+ ## Worker Model Preferences
470
+
471
+ 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.
472
+
473
+ ```bash
474
+ # View current pins
475
+ infinicode workers
476
+
477
+ # Interactively pick a model per worker type (arrow-key lists)
478
+ infinicode workers edit
479
+
480
+ # Clear all pins (router decides for every worker type)
481
+ infinicode workers reset
482
+ ```
483
+
484
+ Each worker type has a recommended default based on capability match across your configured providers. The wizard preselects the recommendation.
485
+
486
+ ### Worker types
487
+
488
+ | Type | Capabilities | Description |
489
+ |---|---|---|
490
+ | `coding` | coding, reasoning, filesystem, terminal | Writes code |
491
+ | `research` | search, crawl, summarize, citations | Researches with citations (SearXNG → Crawl → LLM) |
492
+ | `architecture` | architecture, planning, reasoning | Designs structure |
493
+ | `review` | review, coding, reasoning | Critiques code/design |
494
+ | `documentation` | documentation, summarize, reasoning | Produces docs |
495
+ | `translation` | translation, reasoning | Translates content |
496
+ | `terminal` | terminal, coding, filesystem | Produces shell commands |
497
+ | `verification` | verification, reasoning, review | Verifies acceptance criteria |
498
+ | `vision` | vision, ocr, reasoning | Analyzes images |
499
+ | `browser` | browser, crawl, search, reasoning | Drives a browser (Playwright or fetch fallback) |
500
+
501
+ ### Programmatic API
502
+
503
+ ```ts
504
+ kernel.workerRuntime.setWorkerPin('coding', 'groq', 'llama-3.3-70b-versatile');
505
+ kernel.workerRuntime.setWorkerPins(new Map([
506
+ ['coding', { providerId: 'ollama', modelId: 'qwen2.5-coder:14b' }],
507
+ ['research', { providerId: 'groq', modelId: 'llama-3.3-70b-versatile' }],
508
+ ]));
509
+ kernel.setDefaultPolicy('local-first');
510
+ ```
511
+
512
+ ---
513
+
514
+ **Harness owns:** Prompts, workflows, templates, agent design, memory strategy.
515
+ **Kernel owns:** Execution, scheduling, workers, routing, recovery, verification, checkpoints.
516
+
517
+ Perfect separation. A harness produces mission inputs; the kernel executes them.
518
+
519
+ ---
520
+
521
+ ## Harness Integration
522
+
523
+ **Harness owns:** Prompts, workflows, templates, agent design, memory strategy.
524
+ **Kernel owns:** Execution, scheduling, workers, routing, recovery, verification, checkpoints.
525
+
526
+ Perfect separation. A harness produces mission inputs; the kernel executes them.
527
+
528
+ ---
529
+
530
+ ## Development Roadmap
531
+
532
+ ### Phase 1 — Core Runtime ✅
533
+
534
+ - [x] Mission Engine
535
+ - [x] Scheduler
536
+ - [x] Worker Runtime
537
+ - [x] Provider Interface (Ollama + OpenAI-compatible)
538
+ - [x] Event Bus
539
+ - [x] Checkpoints
540
+ - [x] Capability Router (policy-weighted scoring)
541
+ - [x] Policy Engine (7 built-in policies)
542
+ - [x] Plugin Manager + Telegram/Discord/Slack/Browser/Search stubs
543
+ - [x] Setup wizard + worker model pinning + free cloud provider presets
544
+
545
+ **Target:** Stable execution kernel. ✅
546
+
547
+ ### Phase 2 — Intelligent Routing
548
+
549
+ - [x] Model scoring benchmarks
550
+ - [x] Capability-based routing with health awareness
551
+ - [x] Free-first routing
552
+ - [x] Automatic failover (via Recovery Manager → rotate-provider)
553
+ - [x] Provider telemetry: 429 / quota / success-rate tracking
554
+
555
+ **Target:** Provider-independent inference. ✅
556
+
557
+ ### Phase 3 — Reliability
558
+
559
+ - [x] Verification engine (objective → compile → tests → lint → browser → expected output → LLM judge)
560
+ - [x] Recovery manager (retry → rotate provider → spawn different worker → replan → checkpoint)
561
+ - [x] Long-running missions (checkpoint + resume)
562
+ - [x] Persistent checkpoints (fs-backed, capped at 20/mission)
563
+ - [ ] Automatic replanning (planning-failure → replan action wired; full objective re-plan pending)
564
+
565
+ **Target:** Autonomous execution. ✅ (core)
566
+
567
+ ### Phase 4 — Ecosystem
568
+
569
+ - [x] Telegram notifications + slash commands (/status /workers /logs /pause /resume /retry /models /providers /checkpoints /goal)
570
+ - [x] Browser worker (Playwright-backed; fetch fallback when Playwright not installed)
571
+ - [x] Research worker (SearXNG → Crawl4AI-style crawler → Markdown → LLM; DuckDuckGo fallback)
572
+ - [x] Plugin SDK (`definePlugin()` fluent builder)
573
+ - [x] Harness SDK (`mission()` builder + `taskInput`/`browserTaskInput`/`researchTaskInput` helpers)
574
+ - [x] Dashboard plugin (HTTP `/status` `/missions` `/events` + HTML view)
575
+ - [x] Metrics plugin (runtime counters: missions/tasks/workers/tokens/latency)
576
+ - [x] Gemini provider (Google Generative Language API — dedicated class, not OpenAI-compatible)
577
+ - [ ] Natural chat with orchestrator via Telegram
578
+ - [ ] Vision / Email / Database / Storage / Monitoring plugins
579
+
580
+ **Target:** Extensible platform. ✅ (core)
581
+
582
+ ---
583
+
584
+ ## Configuration
585
+
586
+ Config is stored automatically (via `conf`). Override with:
587
+
588
+ ```bash
589
+ infinicode config --set defaultModel=qwen2.5-coder:14b
590
+ infinicode config --set masterUrl=http://192.168.1.100:11434
591
+ infinicode config --list
592
+ ```
593
+
594
+ Checkpoints persist to `.openkernel/checkpoints/` (capped at 20 per mission).
595
+
596
+ ---
597
+
598
+ ## Recommended Models
599
+
600
+ | Model | Size | Best For |
601
+ |---|---|---|
602
+ | `qwen2.5-coder:14b` | 9GB | Great balance |
603
+ | `qwen2.5-coder:32b` | 20GB | Best quality |
604
+ | `deepseek-coder-v2:16b` | 10GB | Strong reasoning |
605
+ | `codestral:22b` | 13GB | Fast completion |
606
+
607
+ ---
608
+
609
+ ## Requirements
610
+
611
+ - Node.js 20+
612
+ - infinicode installed globally (`npm install -g infinicode`) — provides the TUI binary
613
+ - An Ollama master running somewhere on your network — for the kernel's default local provider
614
+ - Optional: cloud provider API keys (Groq, OpenRouter, GitHub, NVIDIA, HF, Gemini) for provider rotation
615
+
616
+ ---
617
+
618
+ ## License
619
+
620
+ MIT
621
+
622
+ ---
623
+
624
624
  ⚡ Built for sovereign computing. Your code, your models, your hardware.