@useorgx/openclaw-plugin 0.4.6 → 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.
package/README.md CHANGED
@@ -14,6 +14,93 @@ If Claude/Cursor/Codex MCP configs are detected on this machine, the pairing flo
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
@@ -74,7 +161,7 @@ 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
 
@@ -88,7 +175,7 @@ The plugin registers these tools for your agents:
88
175
  - **`orgx_update_entity`** — Update entity status and fields
89
176
  - **`orgx_list_entities`** — Query entities by type and status
90
177
 
91
- ### 📊 Live Dashboard
178
+ ### Live Dashboard
92
179
 
93
180
  Access the OrgX command center at `http://127.0.0.1:18789/orgx/live` (or your gateway URL).
94
181
  The Vite dev server (`http://localhost:5173`) is only for local preview; the installed plugin runs on the OpenClaw port (18789).
@@ -100,7 +187,7 @@ Shows:
100
187
  - Activity stream
101
188
  - Outbox replay visibility for buffered offline events
102
189
 
103
- ### 🔁 Auto-Continue (Scaffold Agent Execution)
190
+ ### Auto-Continue (Scaffold to Agent Execution)
104
191
 
105
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.
106
193
 
@@ -108,7 +195,7 @@ Troubleshooting:
108
195
  - If agents do not start automatically, say: `start agents` to re-trigger dispatch.
109
196
  - Open the live link (Mission Control) to see stream status (`ready`, `active`, `blocked`) and any upgrade/approval decisions.
110
197
 
111
- ### 🎯 Model Routing
198
+ ### Model Routing
112
199
 
113
200
  OrgX automatically routes tasks to the appropriate model tier:
114
201
 
@@ -118,30 +205,27 @@ OrgX automatically routes tasks to the appropriate model tier:
118
205
  | Implementation, code, docs | **sonnet** | claude-sonnet-4 |
119
206
  | Status checks, formatting | **local** | qwen2.5-coder |
120
207
 
121
- ### 🚦 Quality Gates
208
+ ### Quality Gates
122
209
 
123
210
  Before spawning sub-agents, check the quality gate:
124
211
 
125
212
  ```
126
213
  Agent calls orgx_spawn_check(domain: "engineering", taskId: "...")
127
-
128
- OrgX checks: rate limit, quality score threshold, task assignment
129
-
130
- Returns: { allowed: true, modelTier: "sonnet" }
131
-
132
- 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
133
217
  ```
134
218
 
135
- ### 🔑 BYOK (Bring Your Own Keys)
219
+ ### BYOK (Bring Your Own Keys)
136
220
 
137
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.
138
222
 
139
- ### 🩺 Diagnostics
223
+ ### Diagnostics
140
224
 
141
225
  - `openclaw orgx doctor` runs local checks and can optionally probe the OrgX API.
142
226
  - `openclaw gateway status --json` shows the OpenClaw gateway port and runtime state.
143
227
 
144
- ### 🔁 Gateway Watchdog
228
+ ### Gateway Watchdog
145
229
 
146
230
  The plugin starts a lightweight watchdog daemon that periodically probes the local OpenClaw gateway and restarts it if needed.
147
231
 
@@ -152,15 +236,15 @@ The plugin starts a lightweight watchdog daemon that periodically probes the loc
152
236
 
153
237
  | Capability | Status | Notes |
154
238
  |-----------|--------|-------|
155
- | Browser pairing onboarding | | `POST /orgx/api/onboarding/start` + polling flow |
156
- | Manual API key fallback | | In onboarding gate and `manual-key` endpoint |
157
- | Live sessions + activity + handoffs | | SSE with local fallback paths |
158
- | Mission Control hierarchy view | | Initiative workstream milestone task |
159
- | Run control shortcuts | | Pause/resume/cancel/checkpoint/rollback in Session Detail |
160
- | Outbox buffering + replay | | Local queue + auto replay on sync |
161
- | Outbox observability in dashboard | | Pending/replay indicators in header/notifications |
162
- | Plugin diagnostics (`doctor`) | | CLI + `GET /orgx/api/health` |
163
- | 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 |
164
248
 
165
249
  ## CLI Commands
166
250
 
@@ -187,7 +271,7 @@ export ORGX_API_KEY=oxk_...
187
271
 
188
272
  npm run job:dispatch -- \
189
273
  --initiative_id=aa6d16dc-d450-417f-8a17-fd89bd597195 \
190
- --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 \
191
275
  --codex_args="--full-auto" \
192
276
  --concurrency=6
193
277
  ```
@@ -249,6 +333,208 @@ When the plugin is loaded, these HTTP endpoints are available:
249
333
  | `GET /orgx/api/handoffs` | Handoff summaries |
250
334
  | `POST /orgx/mcp` | Local MCP bridge (tools/list, tools/call) |
251
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
+
252
538
  ## Requirements
253
539
 
254
540
  - OpenClaw 2026.1.0 or later