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