cerebrex 0.9.0 โ†’ 0.9.1

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 (4) hide show
  1. package/LICENSE +130 -0
  2. package/README.md +470 -0
  3. package/dist/index.js +301 -301
  4. package/package.json +55 -55
package/LICENSE ADDED
@@ -0,0 +1,130 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other transformations
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by You, including the original version of the Work and any
49
+ modifications or additions to that Work or Derivative Works of the Work.
50
+
51
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
52
+ whom a Contribution has been received by the Licensor.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ (except as stated in this section) patent license to make, have made,
65
+ use, offer to sell, sell, import, and otherwise transfer the Work,
66
+ where such license applies only to those patent claims licensable
67
+ by such Contributor that are necessarily infringed by their
68
+ Contribution(s) alone or by the combination of their Contribution(s)
69
+ with the Work to which such Contribution(s) was submitted. If You
70
+ institute patent litigation against any entity (including a cross-claim
71
+ or counterclaim in a lawsuit) alleging that the Work or any
72
+ Contribution embodied within the Work constitutes direct or contributory
73
+ patent infringement, then any patent licenses granted to You under
74
+ this License for that Work shall terminate as of the date such
75
+ litigation is filed.
76
+
77
+ 4. Redistribution. You may reproduce and distribute copies of the
78
+ Work or Derivative Works thereof in any medium, with or without
79
+ modifications, and in Source or Object form, provided that You
80
+ meet the following conditions:
81
+
82
+ (a) You must give any other recipients of the Work or Derivative
83
+ Works a copy of this License; and
84
+
85
+ (b) You must cause any modified files to carry prominent notices
86
+ stating that You changed the files; and
87
+
88
+ (c) You must retain, in the Source form of any Derivative Works
89
+ that You distribute, all copyright, patent, trademark, and
90
+ attribution notices from the Source form of the Work,
91
+ excluding those notices that do not pertain to any part of
92
+ the Derivative Works; and
93
+
94
+ (d) If the Work includes a "NOTICE" text file, You must include a
95
+ readable copy of the attribution notices contained within such
96
+ NOTICE file, in the Derivative Works that You distribute.
97
+
98
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
99
+ any Contribution intentionally submitted for inclusion in the Work
100
+ by You to the Licensor shall be under the terms and conditions of
101
+ this License, without any additional terms or conditions.
102
+
103
+ 6. Trademarks. This License does not grant permission to use the trade
104
+ names, trademarks, service marks, or product names of the Licensor,
105
+ including "CerebreX", "A Real Cool Co.", and associated logos,
106
+ except as required for reasonable and customary use in describing the
107
+ origin of the Work and reproducing the content of the NOTICE file.
108
+
109
+ 7. Disclaimer of Warranty. Unless required by applicable law or
110
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
111
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
112
+
113
+ 8. Limitation of Liability. In no event and under no legal theory,
114
+ whether in tort, contract, or otherwise, shall any Contributor be
115
+ liable for damages, including any direct, indirect, special,
116
+ incidental, or exemplary damages arising out of this License or
117
+ out of the use or inability to use the Work.
118
+
119
+ 9. Accepting Warranty or Additional Liability. While redistributing
120
+ the Work or Derivative Works thereof, You may offer and charge a fee
121
+ for acceptance of support, warranty, indemnity, or other liability
122
+ obligations and rights consistent with this License.
123
+
124
+ END OF TERMS AND CONDITIONS
125
+
126
+ Copyright 2026 A Real Cool Co. โ€” Josef Douglas Charles McClammey
127
+ Licensed under the Apache License, Version 2.0.
128
+ You may not use this file except in compliance with the License.
129
+ You may obtain a copy of the License at:
130
+ http://www.apache.org/licenses/LICENSE-2.0
package/README.md ADDED
@@ -0,0 +1,470 @@
1
+ <div align="center">
2
+
3
+ # CerebreX
4
+
5
+ ### The Open-Source Agent Infrastructure OS
6
+
7
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](./LICENSE)
8
+ [![CI](https://github.com/arealcoolco/CerebreX/actions/workflows/ci.yml/badge.svg)](https://github.com/arealcoolco/CerebreX/actions/workflows/ci.yml)
9
+ [![npm version](https://img.shields.io/npm/v/cerebrex.svg)](https://www.npmjs.com/package/cerebrex)
10
+ [![GitHub Stars](https://img.shields.io/github/stars/arealcoolco/CerebreX?style=social)](https://github.com/arealcoolco/CerebreX)
11
+ [![Issues](https://img.shields.io/github/issues/arealcoolco/CerebreX)](https://github.com/arealcoolco/CerebreX/issues)
12
+
13
+ **Build. Test. Remember. Coordinate. Publish.**
14
+ The complete infrastructure layer for AI agents โ€” in one CLI.
15
+
16
+ [๐Ÿš€ Quickstart](#-quickstart) ยท [๐Ÿ—‚ Structure](#-monorepo-structure) ยท [๐Ÿ›ฃ Roadmap](#-roadmap) ยท [๐Ÿ› Issues](https://github.com/arealcoolco/CerebreX/issues)
17
+
18
+ </div>
19
+
20
+ ---
21
+
22
+ > **Status: v0.9.1 โ€” Security hardening patch: risk gate integrated, JWT auth on token endpoint, KAIROS backoff + validation**
23
+ > `npm install -g cerebrex` โ€” or download a self-contained binary from [GitHub Releases](https://github.com/arealcoolco/CerebreX/releases) (no Node.js required)
24
+ >
25
+ > **Live:** Registry UI โ†’ `https://registry.therealcool.site`
26
+ > **Live:** Trace Explorer โ†’ `https://registry.therealcool.site/ui/trace`
27
+ > **Live:** Website + Whitepaper โ†’ `https://therealcool.site`
28
+
29
+ ---
30
+
31
+ ## What is CerebreX?
32
+
33
+ CerebreX is an open-source **Agent Infrastructure OS** โ€” the complete toolchain developers need to build reliable, observable, and secure AI agents.
34
+
35
+ Eight modules. One CLI. One registry. One coordination layer.
36
+
37
+ | Module | Command | Status | What It Does |
38
+ |--------|---------|--------|-------------|
39
+ | ๐Ÿ”จ **FORGE** | `cerebrex build` | โœ… Working | Generate production MCP servers from any OpenAPI spec |
40
+ | ๐Ÿ” **TRACE** | `cerebrex trace` | โœ… Working | Record agent execution + visual web dashboard |
41
+ | ๐Ÿง  **MEMEX** | `cerebrex memex` | โœ… Working | Local + three-layer cloud memory (KV + R2 + D1) with SHA-256 integrity |
42
+ | ๐Ÿ”‘ **AUTH** | `cerebrex auth` | โœ… Working | Secure token storage + risk classification gate on every agent action |
43
+ | ๐Ÿ“ฆ **REGISTRY** | `cerebrex publish` | โœ… Working | Publish and install MCP servers (live registry + web UI) |
44
+ | ๐Ÿ **HIVE** | `cerebrex hive` | โœ… Working | Multi-agent coordination โ€” JWT auth, swarm strategies, risk-gated workers |
45
+ | โฐ **KAIROS** | *(cloud worker)* | โœ… Working | Autonomous agent daemon โ€” Durable Objects, 5-min tick loop, append-only log |
46
+ | ๐Ÿ“‹ **ULTRAPLAN** | *(cloud API)* | โœ… Working | Opus deep-thinking plan โ†’ human approval โ†’ parallel task execution |
47
+
48
+ ---
49
+
50
+ ## โšก Quickstart
51
+
52
+ ```bash
53
+ npm install -g cerebrex
54
+ cerebrex --help
55
+ ```
56
+
57
+ Or build from source (requires [Bun](https://bun.sh)):
58
+
59
+ ```bash
60
+ git clone https://github.com/arealcoolco/CerebreX.git
61
+ cd CerebreX/cerebrex
62
+ bun install
63
+ cd packages/types && bun run build && cd ../..
64
+ cd packages/core && bun run build && cd ../..
65
+ cd packages/registry-client && bun run build && cd ../..
66
+ cd apps/cli && bun run build
67
+ node dist/index.js --help
68
+ ```
69
+
70
+ ---
71
+
72
+ ## ๐Ÿ”จ FORGE โ€” MCP Server Generation
73
+
74
+ Generate a production-ready MCP server from any OpenAPI spec:
75
+
76
+ ```bash
77
+ # From a URL
78
+ cerebrex build --spec https://petstore3.swagger.io/api/v3/openapi.json --output ./my-server
79
+
80
+ # From a local file
81
+ cerebrex build --spec ./openapi.yaml --output ./my-server
82
+ ```
83
+
84
+ Output is a Cloudflare Workers project with:
85
+ - Zod input validation on every tool
86
+ - MCP-compliant stdio/SSE/Streamable HTTP transports
87
+ - Ready for `wrangler deploy`
88
+
89
+ ---
90
+
91
+ ## ๐Ÿ” TRACE โ€” Agent Execution Recording
92
+
93
+ ```bash
94
+ # Start recording (runs in foreground, default port 7432)
95
+ cerebrex trace start --session my-agent --port 7432
96
+
97
+ # From your agent, push steps:
98
+ # POST http://localhost:7432/step
99
+ # Body: { "type": "tool_call", "toolName": "listPets", "inputs": {}, "latencyMs": 42 }
100
+
101
+ # Stop and save
102
+ cerebrex trace stop --session my-agent
103
+
104
+ # View in terminal
105
+ cerebrex trace view --session my-agent
106
+
107
+ # View in visual web dashboard (opens browser)
108
+ cerebrex trace view --session my-agent --web
109
+
110
+ # Or use the hosted Trace Explorer (no CLI required)
111
+ # https://registry.therealcool.site/ui/trace
112
+
113
+ # List all saved sessions
114
+ cerebrex trace list
115
+ ```
116
+
117
+ Traces are saved to `~/.cerebrex/traces/`.
118
+
119
+ ---
120
+
121
+ ## ๐Ÿง  MEMEX โ€” Persistent Agent Memory
122
+
123
+ ```bash
124
+ # Store a value
125
+ cerebrex memex set "user-pref" "dark mode" --namespace ui
126
+
127
+ # Retrieve it
128
+ cerebrex memex get "user-pref" --namespace ui
129
+
130
+ # List all memory
131
+ cerebrex memex list
132
+
133
+ # With TTL (auto-expires after 3600 seconds)
134
+ cerebrex memex set "session-ctx" "..." --ttl 3600
135
+
136
+ # Delete a key
137
+ cerebrex memex delete "user-pref" --namespace ui
138
+
139
+ # List all namespaces
140
+ cerebrex memex namespaces
141
+ ```
142
+
143
+ All writes are SHA-256 checksummed. Reads verify integrity before returning.
144
+ Storage: `~/.cerebrex/memex/<namespace>.json` โ€” local, no cloud required.
145
+
146
+ ---
147
+
148
+ ## ๐Ÿ”‘ AUTH โ€” Secure Credentials
149
+
150
+ ```bash
151
+ cerebrex auth login # store token at ~/.cerebrex/.credentials (mode 0600)
152
+ cerebrex auth status # check current auth state
153
+ cerebrex auth logout # remove stored token
154
+ ```
155
+
156
+ `CEREBREX_TOKEN` env var always takes precedence over stored credentials.
157
+
158
+ ---
159
+
160
+ ## ๐Ÿ“ฆ REGISTRY โ€” Publish & Install MCP Servers
161
+
162
+ Registry API: `https://registry.therealcool.site`
163
+ Registry UI: `https://registry.therealcool.site` (browser)
164
+
165
+ ```bash
166
+ cerebrex auth login # authenticate first
167
+ cerebrex validate ./my-server # validate before publishing
168
+ cerebrex validate ./my-server --strict # + OWASP checks
169
+ cerebrex publish --dir ./my-server # publish to registry
170
+ cerebrex install my-mcp-server # install from registry
171
+ ```
172
+
173
+ ---
174
+
175
+ ## ๐Ÿ HIVE โ€” Multi-Agent Coordination
176
+
177
+ ```bash
178
+ # 1 โ€” Initialize and start the coordinator
179
+ cerebrex hive init --name my-hive
180
+ cerebrex hive start # runs on port 7433
181
+
182
+ # 2 โ€” Register agents and get JWTs
183
+ cerebrex hive register --id researcher --name "Researcher" --capabilities search,fetch
184
+ cerebrex hive register --id writer --name "Writer" --capabilities write,summarize
185
+
186
+ # 3 โ€” Start workers (each in its own terminal โ€” they poll and execute automatically)
187
+ cerebrex hive worker --id researcher --token <JWT>
188
+ cerebrex hive worker --id writer --token <JWT> --handler ./writer-handler.mjs
189
+
190
+ # Risk-gated workers โ€” HIGH-risk tasks are blocked by default
191
+ cerebrex hive worker --id researcher --token <JWT> # blocks fetch, deploy, send
192
+ cerebrex hive worker --id researcher --token <JWT> --allow-high-risk # permits all task types
193
+ cerebrex hive worker --id researcher --token <JWT> --block-medium-risk # LOW only
194
+
195
+ # 4 โ€” Send tasks โ€” workers pick them up and execute
196
+ cerebrex hive send --agent researcher --type fetch --payload '{"url":"https://api.example.com/data"}' --token <JWT>
197
+ cerebrex hive send --agent writer --type memex-get --payload '{"key":"research-results"}' --token <JWT>
198
+
199
+ # 5 โ€” Watch it live
200
+ cerebrex hive status
201
+ ```
202
+
203
+ **Built-in task types** (no `--handler` file required):
204
+
205
+ | Type | Payload | Risk | What it does |
206
+ |------|---------|------|-------------|
207
+ | `noop` | anything | LOW | Completes immediately |
208
+ | `echo` | anything | LOW | Returns payload as result |
209
+ | `memex-get` | `{ key, namespace? }` | LOW | Reads from local MEMEX |
210
+ | `memex-set` | `{ key, value, namespace?, ttl? }` | MEDIUM | Writes to local MEMEX |
211
+ | `fetch` | `{ url, method?, headers?, body? }` | MEDIUM | Makes an HTTP request |
212
+
213
+ **Custom handlers** โ€” drop in a JS module when you need more:
214
+
215
+ ```js
216
+ // researcher-handler.mjs
217
+ export async function execute(task) {
218
+ if (task.type === 'search') {
219
+ const res = await fetch(`https://api.example.com/search?q=${task.payload.query}`);
220
+ return { results: await res.json() };
221
+ }
222
+ throw new Error(`Unknown task type: ${task.type}`);
223
+ }
224
+ ```
225
+
226
+ ```bash
227
+ cerebrex hive worker --id researcher --token <JWT> --handler ./researcher-handler.mjs
228
+ ```
229
+
230
+ **Swarm strategies** โ€” launch multi-agent presets in one command:
231
+
232
+ ```bash
233
+ # List all strategies and presets
234
+ cerebrex hive strategies
235
+
236
+ # Run a named preset
237
+ cerebrex hive swarm research-and-recommend "What is the best vector database in 2026?"
238
+ cerebrex hive swarm code-review-pipeline "Review the auth module for security issues"
239
+ cerebrex hive swarm best-solution "How should we implement rate limiting?"
240
+ cerebrex hive swarm product-spec "Design a real-time collaboration feature"
241
+ cerebrex hive swarm content-pipeline "Write a technical blog post about MCP"
242
+ cerebrex hive swarm contract-audit "Audit this API contract for breaking changes"
243
+ ```
244
+
245
+ | Strategy | How it works | Best for |
246
+ |----------|-------------|---------|
247
+ | `parallel` | All agents receive the same task via `Promise.all` | Independent subtasks |
248
+ | `pipeline` | Sequential refinement chain โ€” each agent builds on the last | Research โ†’ Draft โ†’ Edit |
249
+ | `competitive` | Agents race; Opus picks the winner | Finding the optimal answer |
250
+
251
+ **With TRACE observability** โ€” every task shows up in the visual dashboard:
252
+
253
+ ```bash
254
+ cerebrex trace start --session my-run
255
+ cerebrex hive worker --id researcher --token <JWT> --trace-port 7432 --trace-session my-run
256
+ cerebrex trace view --session my-run --web
257
+ ```
258
+
259
+ HIVE runs a local HTTP coordinator with JWT-signed agent authentication.
260
+ State is persisted to `~/.cerebrex/hive/state.json`.
261
+
262
+ ---
263
+
264
+ ## โฐ KAIROS โ€” Autonomous Agent Daemon
265
+
266
+ KAIROS is a cloud-native daemon built on Cloudflare Durable Objects. Each agent gets its own persistent process that wakes on a 5-minute tick, consults Claude to decide whether to act, and logs every decision to an append-only audit trail.
267
+
268
+ ```bash
269
+ # Start a daemon for an agent (via the KAIROS REST API)
270
+ POST /v1/agents/my-agent/daemon/start
271
+
272
+ # Stop it
273
+ POST /v1/agents/my-agent/daemon/stop
274
+
275
+ # View the immutable tick history
276
+ GET /v1/agents/my-agent/daemon/log
277
+
278
+ # Queue a task for the daemon to pick up
279
+ POST /v1/agents/my-agent/tasks
280
+ { "type": "fetch", "payload": { "url": "https://api.example.com/data" } }
281
+ ```
282
+
283
+ **How it works:**
284
+
285
+ 1. The `KairosDaemon` Durable Object wakes every 5 minutes (configurable via `TICK_INTERVAL_MS`)
286
+ 2. It calls Claude with context: agent ID, tick number, pending task count
287
+ 3. Claude decides whether to act (queue a proactive task) or stay quiet
288
+ 4. The decision, reasoning, and result are written to an append-only D1 log โ€” agents cannot delete their own history
289
+ 5. If the Claude API is slow or errors repeatedly, the daemon backs off exponentially (1 min โ†’ 30 min cap) before resetting on the next success
290
+
291
+ ---
292
+
293
+ ## ๐Ÿ“‹ ULTRAPLAN โ€” Deep-Thinking Planning
294
+
295
+ Submit a high-level goal; Claude Opus produces a comprehensive execution plan; you review and approve it; all tasks queue simultaneously.
296
+
297
+ ```bash
298
+ # Submit a goal
299
+ POST /v1/ultraplan
300
+ { "goal": "Build a competitive analysis of the top 5 vector databases for our use case" }
301
+ # โ†’ { planId: "abc123", status: "planning", message: "Opus is thinking..." }
302
+
303
+ # Poll until ready (usually 30-60 seconds)
304
+ GET /v1/ultraplan/abc123
305
+ # โ†’ { status: "pending", plan: { summary, rationale, tasks, risks, success_criteria } }
306
+
307
+ # Approve โ€” all tasks queue simultaneously
308
+ POST /v1/ultraplan/abc123/approve
309
+
310
+ # Or reject
311
+ POST /v1/ultraplan/abc123/reject
312
+ ```
313
+
314
+ The plan JSON contains:
315
+ - `summary` โ€” one-line description
316
+ - `rationale` โ€” why this approach
317
+ - `tasks[]` โ€” array of `{ type, description, payload, priority }` ready to queue
318
+ - `risks[]` โ€” things that could go wrong
319
+ - `success_criteria[]` โ€” how to know the goal was achieved
320
+
321
+ Goals are capped at 50,000 bytes to prevent runaway Opus calls.
322
+
323
+ ---
324
+
325
+ ## ๐ŸŒ Web UI
326
+
327
+ The CerebreX registry includes a browser-based UI served directly from the Worker โ€” no install required.
328
+
329
+ | URL | What It Does |
330
+ |-----|-------------|
331
+ | `/` | Registry browser โ€” search packages, view details, copy install commands |
332
+ | `/ui/trace` | Hosted Trace Explorer โ€” drag-and-drop JSON trace files, full visual timeline |
333
+
334
+ ---
335
+
336
+ ## ๐Ÿ—‚ Monorepo Structure
337
+
338
+ ```
339
+ CerebreX/
340
+ โ”œโ”€โ”€ apps/
341
+ โ”‚ โ”œโ”€โ”€ cli/ # cerebrex CLI โ€” the main published package
342
+ โ”‚ โ”‚ โ”œโ”€โ”€ src/
343
+ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ commands/ # build, trace, memex, auth, hive, other-commands
344
+ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ core/ # forge/, trace/, memex/ engines + dashboard
345
+ โ”‚ โ”‚ โ””โ”€โ”€ dist/ # built output (git-ignored, built by CI)
346
+ โ”‚ โ””โ”€โ”€ dashboard/ # Standalone trace explorer HTML
347
+ โ”‚ โ””โ”€โ”€ src/index.html
348
+ โ”œโ”€โ”€ workers/
349
+ โ”‚ โ”œโ”€โ”€ registry/ # Cloudflare Worker โ€” live registry backend + Web UI
350
+ โ”‚ โ”‚ โ”œโ”€โ”€ src/index.ts # REST API (D1 + KV) + embedded HTML pages
351
+ โ”‚ โ”‚ โ”œโ”€โ”€ schema.sql # D1 database schema
352
+ โ”‚ โ”‚ โ””โ”€โ”€ wrangler.toml
353
+ โ”‚ โ”œโ”€โ”€ memex/ # Cloudflare Worker โ€” MEMEX v2 three-layer cloud memory
354
+ โ”‚ โ”‚ โ”œโ”€โ”€ src/index.ts # KV index + R2 topics + D1 transcripts + autoDream cron
355
+ โ”‚ โ”‚ โ”œโ”€โ”€ migrations/ # D1 schema for agents + transcripts tables
356
+ โ”‚ โ”‚ โ””โ”€โ”€ wrangler.toml
357
+ โ”‚ โ””โ”€โ”€ kairos/ # Cloudflare Worker โ€” KAIROS daemon + ULTRAPLAN
358
+ โ”‚ โ”œโ”€โ”€ src/index.ts # KairosDaemon Durable Object + task queue + ULTRAPLAN
359
+ โ”‚ โ”œโ”€โ”€ migrations/ # D1 schema for daemon_log, tasks, ultraplans
360
+ โ”‚ โ””โ”€โ”€ wrangler.toml
361
+ โ”œโ”€โ”€ packages/
362
+ โ”‚ โ”œโ”€โ”€ core/ # @cerebrex/core โ€” shared utilities
363
+ โ”‚ โ”œโ”€โ”€ types/ # @cerebrex/types โ€” shared TypeScript types
364
+ โ”‚ โ”œโ”€โ”€ registry-client/ # @cerebrex/registry โ€” registry API client
365
+ โ”‚ โ””โ”€โ”€ system-prompt/ # @cerebrex/system-prompt โ€” master system prompt + MEMEX loader
366
+ โ”œโ”€โ”€ .github/
367
+ โ”‚ โ””โ”€โ”€ workflows/
368
+ โ”‚ โ”œโ”€โ”€ ci.yml # build + typecheck on push/PR
369
+ โ”‚ โ”œโ”€โ”€ publish.yml # npm publish on GitHub release
370
+ โ”‚ โ”œโ”€โ”€ deploy-registry.yml # auto-deploy registry Worker
371
+ โ”‚ โ”œโ”€โ”€ deploy-memex.yml # auto-deploy MEMEX Worker
372
+ โ”‚ โ”œโ”€โ”€ deploy-kairos.yml # auto-deploy KAIROS Worker
373
+ โ”‚ โ””โ”€โ”€ build-binaries.yml # build standalone binaries on release
374
+ โ””โ”€โ”€ turbo.json
375
+ ```
376
+
377
+ ---
378
+
379
+ ## ๐Ÿ”’ Security
380
+
381
+ Built security-first, aligned with the [OWASP Top 10 for Agentic Applications (2025)](https://genai.owasp.org).
382
+
383
+ | Control | Where | What it does |
384
+ |---------|-------|-------------|
385
+ | **SHA-256 Memory Integrity** | Local MEMEX | All writes checksummed; reads verify before returning |
386
+ | **Timing-Safe Auth** | MEMEX + KAIROS workers | Constant-time XOR comparison prevents timing oracle attacks on API keys |
387
+ | **Risk Classification Gate** | HIVE worker | Every task classified LOW/MEDIUM/HIGH before execution; HIGH blocked by default |
388
+ | **Authenticated Token Issuance** | HIVE coordinator | `POST /token` requires `registration_secret` matching hive config โ€” no unauthenticated token requests |
389
+ | **JWT Hardening** | HIVE coordinator | `sub` claim required + non-empty; exp/nbf/iat all validated |
390
+ | **Input Validation** | Zod (FORGE) + regex (KAIROS/MEMEX) | agentId and topic names restricted to `[a-zA-Z0-9_-]` 1โ€“128 chars โ€” prevents path traversal |
391
+ | **Size Limits** | MEMEX + KAIROS | Transcripts โ‰ค1MB, topics โ‰ค512KB, index โ‰ค25KB, ULTRAPLAN goals โ‰ค50KB |
392
+ | **Zero Hardcoded Secrets** | FORGE validator | Scans generated code and blocks deploy if secrets are hardcoded |
393
+ | **Secure Credentials** | Auth CLI | Tokens stored at `~/.cerebrex/.credentials` (mode 0600); `icacls` hardening on Windows |
394
+ | **Daemon Backoff** | KAIROS | Exponential backoff on consecutive API errors (1 min โ†’ 30 min) prevents runaway loops |
395
+ | **Append-Only Audit Log** | KAIROS | Every daemon tick written to D1; agents cannot delete their own history |
396
+ | **Rate Limiting** | MEMEX Worker | `/consolidate` rate-limited to 1 per hour per agent via KV TTL |
397
+
398
+ Found a vulnerability? Please read our [Security Policy](./SECURITY.md) and report it privately.
399
+
400
+ ---
401
+
402
+ ## ๐Ÿค Contributing
403
+
404
+ Contributions are welcome. CerebreX is a solo-built open-source project โ€” PRs, issues, and feedback all help.
405
+
406
+ ```bash
407
+ git clone https://github.com/arealcoolco/CerebreX.git
408
+ cd CerebreX/cerebrex
409
+ bun install
410
+ cd packages/types && bun run build && cd ../..
411
+ cd packages/core && bun run build && cd ../..
412
+ cd packages/registry-client && bun run build && cd ../..
413
+ cd apps/cli && bun run build
414
+ # Open a PR against main
415
+ ```
416
+
417
+ ---
418
+
419
+ ## ๐Ÿ›ฃ Roadmap
420
+
421
+ - [x] FORGE โ€” MCP server generation from OpenAPI *(v0.1)*
422
+ - [x] TRACE โ€” Real HTTP event server, step recording + replay *(v0.2)*
423
+ - [x] MEMEX โ€” Persistent agent memory, SHA-256 integrity, TTL *(v0.2)*
424
+ - [x] AUTH โ€” Secure token storage, `cerebrex auth login/logout/status` *(v0.2)*
425
+ - [x] VALIDATE โ€” Real MCP + OWASP compliance checks *(v0.2)*
426
+ - [x] CI/CD โ€” GitHub Actions build + npm publish pipeline *(v0.2)*
427
+ - [x] npm package live โ€” `npm install -g cerebrex` *(v0.2.1)*
428
+ - [x] Web dashboard โ€” Visual trace explorer (`cerebrex trace view --web`) *(v0.3)*
429
+ - [x] Registry backend โ€” Cloudflare Worker + D1 + KV *(v0.3)*
430
+ - [x] HIVE โ€” Multi-agent JWT coordination (init/start/register/status/send) *(v0.3)*
431
+ - [x] Web UI โ€” Registry browser + hosted trace explorer (Worker-embedded) *(v0.4)*
432
+ - [x] Website live โ€” `therealcool.site` โ€” whitepaper, manifesto, proof of work *(v0.7)*
433
+ - [x] HIVE cloud API โ€” create/manage hives from anywhere via registry backend *(v0.7)*
434
+ - [x] 8 official MCP packages โ€” memex, hive, fetch, datetime, kvstore, github, nasa, openweathermap *(v0.7)*
435
+ - [x] Token self-service โ€” `POST /v1/auth/tokens` โ€” users can create scoped tokens *(v0.7)*
436
+ - [x] Rate limiting โ€” per-IP + per-token write limits on MEMEX + HIVE *(v0.7)*
437
+ - [x] HIVE worker โ€” `cerebrex hive worker` โ€” agents that poll, execute, and report back *(v0.7.2)*
438
+ - [x] Built-in task handlers โ€” fetch, memex-set, memex-get, echo, noop *(v0.7.2)*
439
+ - [x] Custom handler modules โ€” `--handler ./my-handler.mjs` for domain-specific logic *(v0.7.2)*
440
+ - [x] TRACE + HIVE integration โ€” `--trace-port` + `--trace-session` on workers *(v0.7.2)*
441
+ - [x] Standalone binaries โ€” `cerebrex-linux-x64`, `cerebrex-linux-arm64`, `cerebrex-windows-x64.exe` attached to every release *(v0.8)*
442
+ - [x] Windows `tar` fix + credential `icacls` hardening *(v0.8)*
443
+ - [x] Update checker โ€” cached background check, 24h TTL *(v0.8)*
444
+ - [x] PWA โ€” `registry.therealcool.site` installable on Android, Chrome OS, iOS Safari *(v0.8)*
445
+ - [x] MEMEX v2 โ€” three-layer cloud memory (KV + R2 + D1) + autoDream nightly consolidation *(v0.9)*
446
+ - [x] KAIROS โ€” autonomous agent daemon (Durable Objects, 5-min tick loop, append-only log) *(v0.9)*
447
+ - [x] ULTRAPLAN โ€” Opus deep-thinking plan โ†’ human approval โ†’ parallel task execution *(v0.9)*
448
+ - [x] AUTH risk gate โ€” LOW/MEDIUM/HIGH classification on every agent action *(v0.9)*
449
+ - [x] HIVE swarm strategies โ€” parallel, pipeline, competitive + 6 built-in presets *(v0.9)*
450
+ - [x] `@cerebrex/system-prompt` โ€” master system prompt package + live MEMEX context loader *(v0.9)*
451
+ - [x] Security hardening โ€” risk gate wired into HIVE worker, JWT /token endpoint authenticated, KAIROS exponential backoff + JSON validation, agentId injection prevention *(v0.9.1)*
452
+ - [ ] Agent test runner โ€” `cerebrex test` with replay + assertions *(v1.0)*
453
+ - [ ] Custom domain *(next)*
454
+ - [ ] Enterprise tier + on-prem *(v1.0)*
455
+
456
+ ---
457
+
458
+ ## ๐Ÿ“„ License
459
+
460
+ CerebreX is open source under the [Apache 2.0 License](./LICENSE).
461
+
462
+ ---
463
+
464
+ <div align="center">
465
+
466
+ Built by [A Real Cool Co.](https://therealcool.site) ยท Gulf Coast, Mississippi
467
+
468
+ *"The developer who builds the standard wins the ecosystem."*
469
+
470
+ </div>