@useorgx/openclaw-plugin 0.4.5 → 0.4.8

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 (60) hide show
  1. package/README.md +333 -26
  2. package/dashboard/dist/assets/B3ziCA02.js +8 -0
  3. package/dashboard/dist/assets/BNeJ0kpF.js +1 -0
  4. package/dashboard/dist/assets/BzkiMPmM.js +215 -0
  5. package/dashboard/dist/assets/CUV9IHHi.js +1 -0
  6. package/dashboard/dist/assets/CpJsfbXo.js +9 -0
  7. package/dashboard/dist/assets/Ie7d9Iq2.css +1 -0
  8. package/dashboard/dist/assets/sAhvFnpk.js +4 -0
  9. package/dashboard/dist/index.html +5 -5
  10. package/dist/activity-actor-fields.d.ts +3 -0
  11. package/dist/activity-actor-fields.js +128 -0
  12. package/dist/activity-store.d.ts +28 -0
  13. package/dist/activity-store.js +257 -0
  14. package/dist/agent-context-store.d.ts +19 -0
  15. package/dist/agent-context-store.js +60 -3
  16. package/dist/agent-suite.d.ts +83 -0
  17. package/dist/agent-suite.js +615 -0
  18. package/dist/artifacts/register-artifact.d.ts +47 -0
  19. package/dist/artifacts/register-artifact.js +271 -0
  20. package/dist/auth-store.js +8 -13
  21. package/dist/contracts/client.d.ts +23 -1
  22. package/dist/contracts/client.js +127 -8
  23. package/dist/contracts/types.d.ts +194 -1
  24. package/dist/entity-comment-store.d.ts +29 -0
  25. package/dist/entity-comment-store.js +190 -0
  26. package/dist/hooks/post-reporting-event.mjs +326 -0
  27. package/dist/http-handler.d.ts +7 -1
  28. package/dist/http-handler.js +4500 -534
  29. package/dist/index.js +1078 -68
  30. package/dist/local-openclaw.js +8 -0
  31. package/dist/mcp-client-setup.js +145 -28
  32. package/dist/mcp-http-handler.d.ts +17 -0
  33. package/dist/mcp-http-handler.js +144 -3
  34. package/dist/next-up-queue-store.d.ts +31 -0
  35. package/dist/next-up-queue-store.js +169 -0
  36. package/dist/openclaw.plugin.json +1 -1
  37. package/dist/outbox.d.ts +1 -1
  38. package/dist/runtime-instance-store.d.ts +1 -1
  39. package/dist/runtime-instance-store.js +19 -2
  40. package/dist/skill-pack-state.d.ts +69 -0
  41. package/dist/skill-pack-state.js +232 -0
  42. package/dist/worker-supervisor.d.ts +25 -0
  43. package/dist/worker-supervisor.js +77 -0
  44. package/openclaw.plugin.json +1 -1
  45. package/package.json +15 -1
  46. package/skills/orgx-design-agent/SKILL.md +38 -0
  47. package/skills/orgx-engineering-agent/SKILL.md +55 -0
  48. package/skills/orgx-marketing-agent/SKILL.md +40 -0
  49. package/skills/orgx-operations-agent/SKILL.md +40 -0
  50. package/skills/orgx-orchestrator-agent/SKILL.md +45 -0
  51. package/skills/orgx-product-agent/SKILL.md +39 -0
  52. package/skills/orgx-sales-agent/SKILL.md +40 -0
  53. package/skills/ship/SKILL.md +63 -0
  54. package/dashboard/dist/assets/B68j2crt.js +0 -1
  55. package/dashboard/dist/assets/BZZ-fiJx.js +0 -32
  56. package/dashboard/dist/assets/BoXlCHKa.js +0 -9
  57. package/dashboard/dist/assets/Bq9x_Xyh.css +0 -1
  58. package/dashboard/dist/assets/DBhrRVdp.js +0 -1
  59. package/dashboard/dist/assets/DD1jv1Hd.js +0 -8
  60. package/dashboard/dist/assets/DNjbmawF.js +0 -214
package/README.md CHANGED
@@ -10,10 +10,97 @@ OrgX plugin for [OpenClaw](https://openclaw.ai) — connect your AI agents to Or
10
10
  4. Sign in at [useorgx.com](https://useorgx.com) and approve the connection.
11
11
  5. Return to OpenClaw. The plugin stores a dedicated credential and runs first sync automatically (no key copy/paste).
12
12
 
13
- If Claude/Cursor/Codex MCP configs are detected on this machine, the pairing flow also installs a local MCP bridge entry (no OAuth) pointing at `http://127.0.0.1:18789/orgx/mcp`. To opt out, set `ORGX_DISABLE_MCP_CLIENT_AUTOCONFIG=1`.
13
+ If Claude/Cursor/Codex MCP configs are detected on this machine, the pairing flow also installs a local MCP bridge entry (no OAuth) pointing at `http://127.0.0.1:18789/orgx/mcp`. To avoid overwriting your hosted `orgx` server entry, the local bridge is installed under the name `orgx-openclaw`. To opt out entirely, set `ORGX_DISABLE_MCP_CLIENT_AUTOCONFIG=1`.
14
14
 
15
15
  Manual API key entry is still available as a permanent fallback from the onboarding panel.
16
16
 
17
+ ## Architecture Overview
18
+
19
+ ```
20
+ ┌──────────────────────────────┐
21
+ │ OrgX Cloud API │
22
+ │ (useorgx.com) │
23
+ │ │
24
+ │ Snapshots, Decisions, │
25
+ │ Activity, Entity CRUD, │
26
+ │ Quality Gates, Model Routing │
27
+ └──────────────┬───────────────┘
28
+
29
+ Bearer token (oxk_...)
30
+
31
+ ┌───────────────────────────────────────┼───────────────────────────────────────┐
32
+ │ OpenClaw Gateway (localhost:18789) │ │
33
+ │ ┌────────────────────────────────────┴──────────────────────────────────┐ │
34
+ │ │ OrgX Plugin (this repo) │ │
35
+ │ │ │ │
36
+ │ │ ┌──────────────┐ ┌──────────────┐ ┌─────────────────────────┐ │ │
37
+ │ │ │ OrgXClient │ │ Outbox │ │ State Stores │ │ │
38
+ │ │ │ │ │ │ │ │ │ │
39
+ │ │ │ API calls │ │ Offline │ │ auth-store (creds) │ │ │
40
+ │ │ │ to cloud │◄──│ event queue │ │ snapshot-store (cache) │ │ │
41
+ │ │ │ │ │ + replay │ │ activity-store (feed) │ │ │
42
+ │ │ └──────┬───────┘ └──────────────┘ │ agent-run-store │ │ │
43
+ │ │ │ │ next-up-queue-store │ │ │
44
+ │ │ │ └─────────────────────────┘ │ │
45
+ │ │ │ │ │
46
+ │ │ ┌──────┴──────────────────────────────────────────────────────────┐ │ │
47
+ │ │ │ HTTP Handler │ │ │
48
+ │ │ │ │ │ │
49
+ │ │ │ /orgx/live → Dashboard SPA (Vite-built React app) │ │ │
50
+ │ │ │ /orgx/api/* → 33+ REST endpoints │ │ │
51
+ │ │ │ /orgx/mcp → MCP bridge (tools/list, tools/call) │ │ │
52
+ │ │ │ /orgx/api/live/* → Polling + SSE for real-time data │ │ │
53
+ │ │ └────────────────────────────────┬────────────────────────────────┘ │ │
54
+ │ │ │ │ │
55
+ │ │ ┌────────────────────────────────┼─────────────────────────────┐ │ │
56
+ │ │ │ Background Services │ │ │ │
57
+ │ │ │ │ │ │ │
58
+ │ │ │ Sync service (every 5min) │ Gateway watchdog │ │ │
59
+ │ │ │ Agent suite provisioning │ MCP client auto-config │ │ │
60
+ │ │ │ Auto-continue pipeline │ Worker supervisor │ │ │
61
+ │ │ └────────────────────────────────┘─────────────────────────────┘ │ │
62
+ │ └──────────────────────────────────────────────────────────────────────┘ │
63
+ │ │ │
64
+ │ ┌───────────────────────────────────┴──────────────────────────────────┐ │
65
+ │ │ MCP Tools (exposed to agents) │ │
66
+ │ │ │ │
67
+ │ │ orgx_status orgx_spawn_check orgx_create_entity │ │
68
+ │ │ orgx_sync orgx_quality_score orgx_update_entity │ │
69
+ │ │ orgx_emit_activity orgx_request_decision orgx_list_entities │ │
70
+ │ └──────────────────────────────────────────────────────────────────────┘ │
71
+ └──────────────────────────────────────────────────────────────────────────────┘
72
+
73
+ Polling (every 8s)
74
+
75
+ ┌──────────────┴───────────────┐
76
+ │ React Dashboard │
77
+ │ /orgx/live │
78
+ │ │
79
+ │ Mission Control (hierarchy) │
80
+ │ Activity Timeline │
81
+ │ Decision Queue (approve/ │
82
+ │ reject with notes) │
83
+ │ Session Inspector │
84
+ │ Agent Provisioning │
85
+ └──────────────────────────────┘
86
+ ```
87
+
88
+ ### Data Flow
89
+
90
+ ```
91
+ Agent calls MCP tool (e.g. orgx_emit_activity)
92
+ → Plugin validates + forwards to OrgX Cloud
93
+ → Cloud persists, returns updated state
94
+ → Plugin caches snapshot locally
95
+ → Dashboard polls /orgx/api/live/sessions every 8s
96
+ → useLiveData hook merges + renders
97
+
98
+ If cloud is unreachable:
99
+ → Plugin queues event in Outbox (~/.orgx/plugin/outbox/)
100
+ → Dashboard reads from cached snapshot + outbox replay
101
+ → On reconnect, outbox auto-replays with backoff
102
+ ```
103
+
17
104
  ## Installation
18
105
 
19
106
  ```bash
@@ -29,8 +116,8 @@ This plugin exposes the same `orgx_*` tools over a local MCP HTTP endpoint serve
29
116
 
30
117
  On successful browser pairing, the plugin will attempt to patch:
31
118
 
32
- - `~/.claude/mcp.json` (rewire `mcpServers.orgx.url` to the local bridge)
33
- - `~/.codex/config.toml` (rewire `[mcp_servers.orgx].url` to the local bridge)
119
+ - `~/.claude/mcp.json` (adds `mcpServers["orgx-openclaw"]` pointing to the local bridge)
120
+ - `~/.codex/config.toml` (add/update `[mcp_servers."orgx-openclaw"].url` to the local bridge)
34
121
  - `~/.cursor/mcp.json` (adds `mcpServers["orgx-openclaw"]` pointing to the local bridge)
35
122
 
36
123
  Each file is backed up first (only when a change is needed) with a `*.bak.<timestamp>-<rand>` suffix.
@@ -74,11 +161,13 @@ Environment overrides:
74
161
 
75
162
  ## Features
76
163
 
77
- ### 🛠️ MCP Tools
164
+ ### MCP Tools
78
165
 
79
166
  The plugin registers these tools for your agents:
80
167
 
81
168
  - **`orgx_status`** — Get current org status (initiatives, agents, tasks, decisions)
169
+ - **`orgx_status_json`** — Get current org status as JSON (for MCP Apps / automation)
170
+ - **`orgx_live_app`** — Open the OrgX Live MCP App (interactive widget)
82
171
  - **`orgx_sync`** — Bidirectional memory sync with OrgX
83
172
  - **`orgx_spawn_check`** — Pre-spawn quality gate + model routing
84
173
  - **`orgx_quality_score`** — Record quality scores for completed work
@@ -86,7 +175,7 @@ The plugin registers these tools for your agents:
86
175
  - **`orgx_update_entity`** — Update entity status and fields
87
176
  - **`orgx_list_entities`** — Query entities by type and status
88
177
 
89
- ### 📊 Live Dashboard
178
+ ### Live Dashboard
90
179
 
91
180
  Access the OrgX command center at `http://127.0.0.1:18789/orgx/live` (or your gateway URL).
92
181
  The Vite dev server (`http://localhost:5173`) is only for local preview; the installed plugin runs on the OpenClaw port (18789).
@@ -98,7 +187,15 @@ Shows:
98
187
  - Activity stream
99
188
  - Outbox replay visibility for buffered offline events
100
189
 
101
- ### 🎯 Model Routing
190
+ ### Auto-Continue (Scaffold to Agent Execution)
191
+
192
+ If you scaffold an initiative from chat (for example, "plan X" and then create/scaffold), OrgX can automatically start executing the first workstream via the stream auto-continue pipeline.
193
+
194
+ Troubleshooting:
195
+ - If agents do not start automatically, say: `start agents` to re-trigger dispatch.
196
+ - Open the live link (Mission Control) to see stream status (`ready`, `active`, `blocked`) and any upgrade/approval decisions.
197
+
198
+ ### Model Routing
102
199
 
103
200
  OrgX automatically routes tasks to the appropriate model tier:
104
201
 
@@ -108,30 +205,27 @@ OrgX automatically routes tasks to the appropriate model tier:
108
205
  | Implementation, code, docs | **sonnet** | claude-sonnet-4 |
109
206
  | Status checks, formatting | **local** | qwen2.5-coder |
110
207
 
111
- ### 🚦 Quality Gates
208
+ ### Quality Gates
112
209
 
113
210
  Before spawning sub-agents, check the quality gate:
114
211
 
115
212
  ```
116
213
  Agent calls orgx_spawn_check(domain: "engineering", taskId: "...")
117
-
118
- OrgX checks: rate limit, quality score threshold, task assignment
119
-
120
- Returns: { allowed: true, modelTier: "sonnet" }
121
-
122
- Agent spawns with recommended model
214
+ -> OrgX checks: rate limit, quality score threshold, task assignment
215
+ -> Returns: { allowed: true, modelTier: "sonnet" }
216
+ -> Agent spawns with recommended model
123
217
  ```
124
218
 
125
- ### 🔑 BYOK (Bring Your Own Keys)
219
+ ### BYOK (Bring Your Own Keys)
126
220
 
127
221
  If you use BYOK models (OpenAI, Anthropic, OpenRouter), store your provider keys in OpenClaw. The OrgX plugin reads OpenClaw settings and injects keys when it invokes OpenClaw CLI commands, so you do not need to put provider keys in the OrgX plugin config.
128
222
 
129
- ### 🩺 Diagnostics
223
+ ### Diagnostics
130
224
 
131
225
  - `openclaw orgx doctor` runs local checks and can optionally probe the OrgX API.
132
226
  - `openclaw gateway status --json` shows the OpenClaw gateway port and runtime state.
133
227
 
134
- ### 🔁 Gateway Watchdog
228
+ ### Gateway Watchdog
135
229
 
136
230
  The plugin starts a lightweight watchdog daemon that periodically probes the local OpenClaw gateway and restarts it if needed.
137
231
 
@@ -142,15 +236,15 @@ The plugin starts a lightweight watchdog daemon that periodically probes the loc
142
236
 
143
237
  | Capability | Status | Notes |
144
238
  |-----------|--------|-------|
145
- | Browser pairing onboarding | | `POST /orgx/api/onboarding/start` + polling flow |
146
- | Manual API key fallback | | In onboarding gate and `manual-key` endpoint |
147
- | Live sessions + activity + handoffs | | SSE with local fallback paths |
148
- | Mission Control hierarchy view | | Initiative workstream milestone task |
149
- | Run control shortcuts | | Pause/resume/cancel/checkpoint/rollback in Session Detail |
150
- | Outbox buffering + replay | | Local queue + auto replay on sync |
151
- | Outbox observability in dashboard | | Pending/replay indicators in header/notifications |
152
- | Plugin diagnostics (`doctor`) | | CLI + `GET /orgx/api/health` |
153
- | Full-auto codex dispatch | | `npm run job:dispatch` with retries + rollups |
239
+ | Browser pairing onboarding | Done | `POST /orgx/api/onboarding/start` + polling flow |
240
+ | Manual API key fallback | Done | In onboarding gate and `manual-key` endpoint |
241
+ | Live sessions + activity + handoffs | Done | SSE with local fallback paths |
242
+ | Mission Control hierarchy view | Done | Initiative -> workstream -> milestone -> task |
243
+ | Run control shortcuts | Done | Pause/resume/cancel/checkpoint/rollback in Session Detail |
244
+ | Outbox buffering + replay | Done | Local queue + auto replay on sync |
245
+ | Outbox observability in dashboard | Done | Pending/replay indicators in header/notifications |
246
+ | Plugin diagnostics (`doctor`) | Done | CLI + `GET /orgx/api/health` |
247
+ | Full-auto codex dispatch | Done | `npm run job:dispatch` with retries + rollups |
154
248
 
155
249
  ## CLI Commands
156
250
 
@@ -177,7 +271,7 @@ export ORGX_API_KEY=oxk_...
177
271
 
178
272
  npm run job:dispatch -- \
179
273
  --initiative_id=aa6d16dc-d450-417f-8a17-fd89bd597195 \
180
- --plan_file=/Users/hopeatina/Code/orgx-openclaw-plugin/docs/orgx-openclaw-launch-workstreams-plan-2026-02-14.md \
274
+ --plan_file=docs/orgx-openclaw-launch-workstreams-plan-2026-02-14.md \
181
275
  --codex_args="--full-auto" \
182
276
  --concurrency=6
183
277
  ```
@@ -205,6 +299,17 @@ Notes:
205
299
  Manual dispatch:
206
300
  - Use `docs/marketing/manual-agent-dispatch-golden-prompt.md` when manually launching a marketing agent for a specific task (non-batched dispatch).
207
301
 
302
+ ## SEO Automation (Keywords Everywhere + DataForSEO)
303
+
304
+ This repo also includes a repo-local SEO pipeline runner (scripts only; not shipped in the plugin package) under `scripts/seo/`.
305
+
306
+ - Apply an OrgX initiative plan for SEO automation: `npm run seo:plan`
307
+ - Run the pipeline:
308
+ - Dry run (no API calls): `npm run seo:run -- --config=docs/seo/seo.config.example.json --mode=all --dry-run=true`
309
+ - Live run: `npm run seo:run -- --config=docs/seo/seo.config.example.json --mode=all`
310
+
311
+ Details: `scripts/seo/README.md`
312
+
208
313
  ## API Endpoints
209
314
 
210
315
  When the plugin is loaded, these HTTP endpoints are available:
@@ -228,6 +333,208 @@ When the plugin is loaded, these HTTP endpoints are available:
228
333
  | `GET /orgx/api/handoffs` | Handoff summaries |
229
334
  | `POST /orgx/mcp` | Local MCP bridge (tools/list, tools/call) |
230
335
 
336
+ ## Contributing
337
+
338
+ ### Prerequisites
339
+
340
+ - Node.js 18+
341
+ - npm 9+
342
+ - An OrgX account (free tier works for development)
343
+
344
+ ### Dev Setup
345
+
346
+ ```bash
347
+ git clone https://github.com/useorgx/openclaw-plugin.git
348
+ cd openclaw-plugin
349
+
350
+ # Install root dependencies (plugin core)
351
+ npm install
352
+
353
+ # Install dashboard dependencies
354
+ cd dashboard && npm install && cd ..
355
+
356
+ # Build everything
357
+ npm run build
358
+
359
+ # Run tests
360
+ npm run test:hooks
361
+ ```
362
+
363
+ ### Development Workflow
364
+
365
+ ```bash
366
+ # Type-check (must pass before any commit)
367
+ npm run typecheck
368
+
369
+ # Run tests (must pass before any commit)
370
+ npm run test:hooks
371
+
372
+ # Build core only (TypeScript -> dist/)
373
+ npm run build:core
374
+
375
+ # Build dashboard only (Vite)
376
+ npm run build:dashboard
377
+
378
+ # Dashboard dev server (hot reload at localhost:5173)
379
+ cd dashboard && npm run dev
380
+
381
+ # Full build (core + dashboard)
382
+ npm run build
383
+ ```
384
+
385
+ ### Repository Structure
386
+
387
+ ```
388
+ src/ # Plugin core (TypeScript, ES modules)
389
+ index.ts # Entry point: config resolution, tool registration,
390
+ # background sync, CLI commands (4.4k lines)
391
+ http-handler.ts # HTTP API: 33+ routes, dashboard serving,
392
+ # MCP bridge, SSE streaming (12.3k lines)
393
+ contracts/
394
+ client.ts # OrgXClient — all cloud API calls
395
+ types.ts # Shared type contracts
396
+ auth-store.ts # Credential persistence (~/.orgx/plugin/auth.json)
397
+ snapshot-store.ts # Cached org snapshot for offline fallback
398
+ outbox.ts # Offline event queue + auto-replay
399
+ activity-store.ts # Paginated activity timeline persistence
400
+ agent-suite.ts # Agent provisioning (profiles, skills, managed files)
401
+ agent-run-store.ts # Spawned agent run records
402
+ agent-context-store.ts # Launch context for agent runs
403
+ mcp-http-handler.ts # Local MCP bridge at /orgx/mcp
404
+ mcp-client-setup.ts # Auto-config for Claude/Codex/Cursor
405
+ gateway-watchdog.ts # Local gateway health monitor
406
+ local-openclaw.ts # Fallback: read OpenClaw local state when cloud down
407
+ byok-store.ts # Provider key management (OpenAI, Anthropic, etc.)
408
+ runtime-instance-store.ts # Runtime process tracking
409
+ next-up-queue-store.ts # Task ordering for auto-dispatch
410
+ worker-supervisor.ts # Detect failed agent handshakes
411
+ skill-pack-state.ts # Skill pack download/install tracking
412
+ fs-utils.ts # Atomic file writes, corruption recovery
413
+ paths.ts # Config directory paths (~/.orgx/plugin/)
414
+
415
+ dashboard/ # React SPA (served at /orgx/live)
416
+ src/
417
+ App.tsx # Root component, view routing (2.3k lines)
418
+ components/
419
+ activity/ # ActivityTimeline (live feed, 4.3k lines)
420
+ mission-control/ # Hierarchy view: initiative -> workstream -> task
421
+ sessions/ # Session inspector, agent chats
422
+ decisions/ # Decision queue (approve/reject with notes)
423
+ initiatives/ # Initiative detail + list
424
+ artifacts/ # Artifact viewer modal
425
+ agents/ # Agent panel, status indicators
426
+ handoffs/ # Handoff list
427
+ onboarding/ # Browser pairing gate
428
+ settings/ # Connection, BYOK, agent suite panels
429
+ shared/ # Modal, Badge, EntityIcon, MarkdownText
430
+ hooks/ # 17 custom hooks
431
+ useLiveData.ts # Core data hook (polling, state merge)
432
+ useConnection.ts # Connection status
433
+ useOnboarding.ts # Pairing flow
434
+ useMissionControlGraph.ts # Hierarchy visualization
435
+ useEntityMutations.ts # Entity CRUD operations
436
+ lib/
437
+ tokens.ts # Design tokens (lime, teal, background, etc.)
438
+
439
+ scripts/ # Orchestration and QA (not shipped in package)
440
+ run-codex-dispatch-job.mjs # Full-auto agent dispatch
441
+ capture-qa-evidence.mjs # Playwright QA screenshots
442
+ ship.mjs # Commit, PR, auto-merge
443
+
444
+ skills/ # Agent skill packs (9 domains)
445
+ tests/ # 26 test suites (Node test runner)
446
+ docs/ # ADRs, ops guides, launch plans
447
+ ```
448
+
449
+ ### Known Architecture Debt
450
+
451
+ This is an honest accounting of where the codebase is messy. If you're looking for high-impact contributions, these are the places that need the most love.
452
+
453
+ **1. God files**
454
+
455
+ Three files account for most of the complexity:
456
+
457
+ | File | Lines | Problem |
458
+ |------|------:|---------|
459
+ | `src/http-handler.ts` | 12,253 | 33 routes in one `if/else` chain inside a single 8,700-line closure. No router, no middleware, no controller separation. Business logic (auto-continue orchestration, LLM headline summarization, spawn guard enforcement) lives inline with route dispatch. |
460
+ | `src/index.ts` | 4,355 | Plugin bootstrap, tool registration, config resolution, sync logic, and CLI commands all in one file. |
461
+ | `dashboard/src/components/activity/ActivityTimeline.tsx` | 4,326 | Rendering, data transformation, outcome classification, and interaction logic in one component. |
462
+
463
+ The HTTP handler is the worst offender. Every new endpoint means modifying a 12k-line file. A 25-line negated boolean guard (listing every known route) must be manually updated each time a route is added.
464
+
465
+ **Ideal decomposition for `http-handler.ts`:**
466
+ - `routes/onboarding.ts` — pairing, manual key, disconnect
467
+ - `routes/live.ts` — sessions, activity, SSE streaming
468
+ - `routes/entities.ts` — CRUD, comments, artifacts
469
+ - `routes/mission-control.ts` — graph, next-up, auto-continue
470
+ - `routes/decisions.ts` — approval queue, mutations
471
+ - `routes/agents.ts` — launch, stop, suite provisioning
472
+ - `routes/dashboard.ts` — SPA serving, asset caching
473
+ - A thin router with route registration instead of the `if/else` cascade.
474
+
475
+ **2. State store sprawl**
476
+
477
+ Eight separate file-based stores under `~/.orgx/plugin/`:
478
+
479
+ ```
480
+ auth-store.ts → auth.json
481
+ snapshot-store.ts → snapshot.json
482
+ activity-store.ts → activity pages
483
+ outbox.ts → outbox/<session>.json
484
+ agent-run-store.ts → agent run records
485
+ agent-context-store.ts → launch context
486
+ next-up-queue-store.ts → task ordering
487
+ skill-pack-state.ts → skill checksums
488
+ ```
489
+
490
+ Each has its own read/write/corruption-recovery logic. Some overlap (outbox events become activity items; agent-run and agent-context track the same runs from different angles). A unified local store with a single persistence layer would reduce duplication.
491
+
492
+ **3. Type duplication**
493
+
494
+ Two separate `types.ts` files that can desync:
495
+ - `src/contracts/types.ts` — cloud API contract types
496
+ - `dashboard/src/types.ts` — dashboard-specific types
497
+
498
+ The `LiveDecision` interface exists in the dashboard types but has no shared definition with the server. The HTTP handler manually shapes responses to match what the dashboard expects, with no compile-time guarantee they agree.
499
+
500
+ **4. No routing abstraction**
501
+
502
+ The HTTP handler uses raw `if (method === "POST" && route === "...")` checks. Adding a new route requires:
503
+ 1. Adding a boolean variable to the route-matching block
504
+ 2. Adding it to the 25-line negated guard for unknown routes
505
+ 3. Adding the handler body somewhere in the 8,700-line function
506
+ 4. Hoping you don't accidentally shadow another route
507
+
508
+ **5. Dashboard polls by default**
509
+
510
+ SSE streaming exists (`/orgx/api/live/stream`) but the dashboard defaults to polling every 8 seconds. This works but means decisions and activity can feel delayed. The SSE path exists but isn't the primary code path.
511
+
512
+ ### Design Decisions (Why Things Are This Way)
513
+
514
+ Not all of the above is accidental. Some context for why the architecture looks the way it does:
515
+
516
+ - **Zero production dependencies**: The plugin ships with no npm runtime deps. This means no Express, no Fastify, no routing library. The HTTP handler is hand-rolled because adding a router would be the first external dependency. The tradeoff is clear: easy distribution vs. maintainability.
517
+
518
+ - **File-based state over SQLite**: The plugin runs inside OpenClaw's process. Using SQLite would add a native dependency (build complexity, platform issues). JSON files are portable and inspectable with `cat`. The tradeoff: no queries, no transactions, more code for corruption recovery.
519
+
520
+ - **Monolithic bootstrap**: `index.ts` does everything at startup because OpenClaw plugins have a single entry point. There's no lifecycle hook for "register tools in phase 1, start services in phase 2." Everything happens in `register()`.
521
+
522
+ ### What Makes a Good Contribution
523
+
524
+ - **Splitting `http-handler.ts`** into route modules would be the single highest-impact refactor. Even extracting one domain (e.g., onboarding routes) into its own file would be a great start.
525
+ - **Dashboard component extraction** — breaking `ActivityTimeline.tsx` into smaller components (OutcomeCard, ActivityItem, FilterBar) would make it approachable.
526
+ - **Shared types** — creating a shared `types/` directory that both `src/` and `dashboard/src/` import from would catch desync bugs at compile time.
527
+ - **Bug fixes and UX improvements** to the dashboard are always welcome. The design language is in `dashboard/src/lib/tokens.ts`.
528
+
529
+ ### Code Conventions
530
+
531
+ - **TypeScript strict mode** — no `any`, no implicit returns, no unused variables
532
+ - **ES modules only** — all imports use `import`, no `require()`
533
+ - **Zero production dependencies** — if you need a library, implement the subset you need
534
+ - **Node test runner** — tests use `node --test`, not Jest. Test files end in `.test.mjs`
535
+ - **Dashboard design tokens** — use values from `dashboard/src/lib/tokens.ts`, not raw hex colors
536
+ - **Read AGENTS.md** — it has guardrails for AI agents working on this repo, but the conventions apply to humans too
537
+
231
538
  ## Requirements
232
539
 
233
540
  - OpenClaw 2026.1.0 or later