wolverine-ai 6.4.1 → 6.4.3

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
@@ -1623,21 +1623,28 @@ Agentic AI agent mode powered by [OpenClaw](https://github.com/openclaw/openclaw
1623
1623
 
1624
1624
  Wolverine Claw wraps the OpenClaw gateway (WebSocket control plane + Pi agent runtime) in Wolverine's process manager. When the agent crashes or encounters errors, Wolverine's AI heal pipeline kicks in — diagnoses the error, generates a fix, verifies it, and restarts. The agent gets access to Wolverine's brain (semantic memory), backup system (workspace snapshots), and self-healing tools.
1625
1625
 
1626
- ### Setup (Existing OpenClaw Users)
1627
-
1628
- If you already have OpenClaw installed, the setup wizard detects your config and merges it:
1626
+ ### Setup (Existing OpenClaw Users) — One Command
1629
1627
 
1630
1628
  ```bash
1631
- npm install wolverine-ai
1632
- wolverine-claw --setup
1629
+ npx wolverine-ai@latest --setup-claw
1630
+ ```
1631
+
1632
+ That's it. One command. Zero code changes. Your existing `npm start` now runs with wolverine.
1633
+
1634
+ What it does automatically:
1635
+ 1. Detects your `.openclaw/config.yml` — merges gateway port, model, channels, security
1636
+ 2. Installs `wolverine-ai` as a dependency
1637
+ 3. Scaffolds `wolverine-claw/` with merged config, plugin, and workspace
1638
+ 4. **Patches your start scripts** — injects `--require ./wolverine-claw/bootstrap.js` so wolverine loads automatically when your gateway starts
1639
+ 5. Adds `claw`, `claw:info`, `claw:direct` npm scripts
1640
+ 6. Validates everything (Node, API keys, config, entry point)
1641
+
1642
+ ```
1643
+ Before: "start": "openclaw gateway"
1644
+ After: "start": "NODE_OPTIONS=\"--require ./wolverine-claw/bootstrap.js\" openclaw gateway"
1633
1645
  ```
1634
1646
 
1635
- The wizard will:
1636
- 1. Detect your OpenClaw installation and `~/.openclaw/config.yml`
1637
- 2. Merge your gateway port, model, channels, and security settings with wolverine defaults
1638
- 3. Scaffold `wolverine-claw/` with merged config
1639
- 4. Validate Node version, API keys, and dependencies
1640
- 5. Show next steps
1647
+ Your skills, plugins, and gateway code are never modified. The bootstrap preload handles everything at the process level.
1641
1648
 
1642
1649
  Preview without changes: `wolverine-claw --setup --dry`
1643
1650
 
@@ -1676,29 +1683,42 @@ wolverine --rollback-latest # Restore most recent
1676
1683
 
1677
1684
  ```
1678
1685
  wolverine-claw/
1686
+ ├── bootstrap.js # --require preload (auto-injected into start scripts)
1679
1687
  ├── config/
1680
1688
  │ └── settings.json # Gateway, agent, channels, healing, security
1681
1689
  ├── index.js # Entry point — bootstraps OpenClaw gateway
1682
1690
  ├── plugins/
1683
- │ └── wolverine-integration.js # 7 wolverine tools for the agent
1691
+ │ └── wolverine-integration.js # 8 tools + 8 Plugin SDK hooks
1684
1692
  ├── skills/ # Custom user skills
1685
1693
  └── workspace/ # Sandboxed agent working directory
1686
1694
 
1687
1695
  src/claw/
1688
1696
  ├── claw-runner.js # Process manager with healing pipeline
1689
- └── setup.js # Setup wizard (detect, merge, scaffold, validate)
1697
+ ├── setup.js # Setup wizard (detect, merge, scaffold, validate, patch)
1698
+ ├── standalone-agent.js # Built-in agent (32 tools) when openclaw not installed
1699
+ └── wolverine-api.js # Unified API — 85 access points across 13 subsystems
1690
1700
 
1691
1701
  bin/wolverine-claw.js # CLI entry point
1692
1702
  ```
1693
1703
 
1694
- ### How It Works
1704
+ ### How It Works (Zero-Code Integration)
1705
+
1706
+ ```
1707
+ npx wolverine-ai@latest --setup-claw
1708
+ → Detects .openclaw/config.yml, merges settings
1709
+ → Patches "start": "openclaw gateway"
1710
+ into "start": "NODE_OPTIONS=\"--require ./wolverine-claw/bootstrap.js\" openclaw gateway"
1711
+
1712
+ npm start (user's existing command)
1713
+ → Node loads bootstrap.js before anything else
1714
+ → global.wolverine = full API (85 access points, lazy-loaded)
1715
+ → Module._load patched → require("openclaw") auto-registers wolverine plugin
1716
+ → Process error handlers → report to wolverine heal pipeline via IPC
1717
+ → Gateway starts with wolverine plugin (8 tools + 8 hooks)
1718
+ → On crash: ClawRunner catches → AI heal → backup → fix → verify → restart
1719
+ ```
1695
1720
 
1696
- 1. `ClawRunner` spawns `wolverine-claw/index.js` as a child process with IPC
1697
- 2. `index.js` loads OpenClaw via `require("openclaw")` (SDK mode) or falls back to `npx openclaw gateway` (CLI mode)
1698
- 3. The wolverine integration plugin injects 7 tools into the OpenClaw agent
1699
- 4. On crash/error, `ClawRunner` catches via IPC or exit event
1700
- 5. Wolverine's AI heal pipeline runs: diagnose → backup → fix → verify → restart
1701
- 6. Gateway health monitored via TCP probe on WebSocket port every 30s
1721
+ No skills, plugins, or gateway code are ever modified. Everything is injected at the process entry point.
1702
1722
 
1703
1723
  ### Wolverine Tools for the Agent
1704
1724
 
@@ -1713,6 +1733,44 @@ The integration plugin gives the OpenClaw agent access to wolverine capabilities
1713
1733
  | `wolverine_health` | Get system health status (memory, uptime, backups) |
1714
1734
  | `wolverine_list_backups` | List all available snapshots |
1715
1735
  | `wolverine_self_heal` | Trigger the heal pipeline on a specific error |
1736
+ | `wolverine_error_stats` | Error counts from all OpenClaw subsystems |
1737
+
1738
+ ### Plugin Hooks (Automatic Error Pipeline)
1739
+
1740
+ The plugin registers 8 hooks into OpenClaw's Plugin SDK — errors from every subsystem flow to wolverine automatically:
1741
+
1742
+ | Hook | What It Catches |
1743
+ |------|----------------|
1744
+ | `after_tool_call` | Skill and tool execution failures |
1745
+ | `agent_end` | Agent crashes, timeouts, completion errors |
1746
+ | `before_tool_call` | Tool loop detection (before it burns tokens) |
1747
+ | `message_sent` | Channel send failures (Discord, Slack, etc.) |
1748
+ | `llm_output` | Provider errors, failovers, billing blocks (402) |
1749
+ | `subagent_ended` | Subagent failures and timeouts |
1750
+ | `gateway_start/stop` | Lifecycle tracking with error stats |
1751
+ | `session_end` | Session-level errors |
1752
+
1753
+ ### Wolverine API (for Custom Skills)
1754
+
1755
+ If you write custom OpenClaw skills that want wolverine features, they're available globally — no imports needed:
1756
+
1757
+ ```javascript
1758
+ // In any OpenClaw skill (after setup, global.wolverine is auto-available):
1759
+
1760
+ // Scan user input for prompt injection
1761
+ const scan = wolverine.scanText(userMessage);
1762
+ if (!scan.safe) return "Blocked: injection detected";
1763
+
1764
+ // Search past fixes
1765
+ const fixes = await wolverine.brain.search("ECONNREFUSED redis");
1766
+
1767
+ // Diagnose an error
1768
+ const diag = wolverine.diagnoseError(errorText);
1769
+ // → { type: "missing_module", tools: {...}, humanRequired: false }
1770
+
1771
+ // Create backup before risky operation
1772
+ wolverine.backup.create("before database migration");
1773
+ ```
1716
1774
 
1717
1775
  ### Configuration
1718
1776
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wolverine-ai",
3
- "version": "6.4.1",
3
+ "version": "6.4.3",
4
4
  "description": "Self-healing Node.js server framework powered by AI. Catches crashes, diagnoses errors, generates fixes, verifies, and restarts — automatically.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -12,9 +12,9 @@
12
12
  "dev": "node bin/wolverine.js server/index.js",
13
13
  "wolverine": "node bin/wolverine.js",
14
14
  "server": "node server/index.js",
15
- "claw": "node bin/wolverine-claw.js",
16
- "claw:direct": "node bin/wolverine-claw.js --direct",
17
- "claw:info": "node bin/wolverine-claw.js --info",
15
+ "claw": "wolverine-claw",
16
+ "claw:direct": "wolverine-claw --direct",
17
+ "claw:info": "wolverine-claw --info",
18
18
  "demo": "node examples/run-demo.js",
19
19
  "demo:list": "node examples/run-demo.js --list",
20
20
  "test:pentest": "node tests/pentest-secrets.js"
@@ -282,13 +282,21 @@ const SEED_DOCS = [
282
282
  metadata: { topic: "wolverine-claw" },
283
283
  },
284
284
  {
285
- text: "Wolverine Claw setup: guided onboarding for OpenClaw users (wolverine-claw --setup). 8-step flow: (1) Detect environment — Node version, OpenClaw installation (checks local node_modules, global install, package.json dep, ~/.openclaw/config.yml), API keys, wolverine core. (2) Abort if Node < 22. (3) Merge config — reads user's OpenClaw YAML config (gateway port, model, channels, security) and overlays onto wolverine-claw defaults. OpenClaw values win, wolverine fills gaps. (4) Scaffold — creates wolverine-claw/ with config/settings.json, plugins/wolverine-integration.js, workspace/, skills/. Never overwrites existing files. (5) Environment ensures .env.local has claw-specific key templates (DISCORD_BOT_TOKEN, SLACK_BOT_TOKEN, etc). (6) Install npm install openclaw --save-optional (falls back to npx). (7) Validate — 7 checks: Node, OpenClaw, API keys, config, entry point, plugin, wolverine core. (8) Next steps. Also available as wolverine --setup-claw from main CLI. Dry run: wolverine-claw --setup --dry.",
285
+ text: "Wolverine Claw setup one command: npx wolverine-ai@latest --setup-claw. Zero code changes needed. Flow: (1) Detect OpenClaw (node_modules, global, package.json, ~/.openclaw/config.yml). (2) Merge config — reads user's OpenClaw YAML config (gateway port, model, channels, security) and overlays onto wolverine defaults. (3) Scaffold wolverine-claw/ (config, plugins, workspace, skills). (4) Install wolverine-ai as dependency. (5) Auto-patch existing npm scripts: injects NODE_OPTIONS='--require ./wolverine-claw/bootstrap.js' into start/dev commands so wolverine loads automatically. (6) Add claw/claw:info/claw:direct npm scripts. (7) Setup .env.local with channel token templates. (8) Validate (Node, OpenClaw, API keys, config, entry point, plugin). After setup, user runs their existing 'npm start' command wolverine is already active. No imports needed anywhere.",
286
286
  metadata: { topic: "wolverine-claw-setup" },
287
287
  },
288
288
  {
289
- text: "Wolverine Claw integration plugin (wolverine-claw/plugins/wolverine-integration.js): registers 7 wolverine tools into the OpenClaw agent toolkit. Tools: wolverine_backup (create workspace snapshot), wolverine_rollback (restore to previous backup), wolverine_brain_search (semantic search of wolverine's memory for past fixes/patterns), wolverine_brain_learn (store new learnings in brain), wolverine_health (system health status), wolverine_list_backups (list all snapshots), wolverine_self_heal (trigger heal pipeline on a specific error). Plugin hooks into gateway events (error, agent:error, skill:error) to report errors to wolverine parent via IPC for automatic healing. Sends heartbeat every 30s. Registered via gateway.registerTools(), gateway.addTools(), or gateway.skills.register() depending on OpenClaw API version.",
289
+ text: "Wolverine Claw bootstrap preload (wolverine-claw/bootstrap.js): loaded via --require, auto-injected into OpenClaw's start command by setup. What it does: (1) Initializes full wolverine API as global.wolverine 85 access points across 13 subsystems, accessible from any skill/plugin without imports. (2) Patches Module._load to intercept require('openclaw') and auto-register the wolverine plugin when the gateway starts. (3) Installs process-level uncaughtException/unhandledRejection handlers that report errors to wolverine heal pipeline via IPC. (4) Provides wolverine.middleware.injectionGuard for route protection. The bootstrap makes wolverine completely transparent — the user's skills, plugins, and gateway code are never modified. Everything happens at the Node process entry point.",
290
+ metadata: { topic: "wolverine-claw-bootstrap" },
291
+ },
292
+ {
293
+ text: "Wolverine Claw integration plugin (wolverine-claw/plugins/wolverine-integration.js): two layers. Layer 1 — 8 tools injected into agent: wolverine_backup, wolverine_rollback, wolverine_brain_search, wolverine_brain_learn, wolverine_health, wolverine_list_backups, wolverine_self_heal, wolverine_error_stats. Layer 2 — 8 OpenClaw Plugin SDK hooks for deep error observability: after_tool_call (skill/tool failures), agent_end (agent crashes/timeouts), before_tool_call (tool loop detection), message_sent (channel send failures), llm_output (provider errors/failovers/billing), subagent_ended (subagent failures), gateway_start/stop (lifecycle). Error tracking state: per-category counts (tool/agent/channel/llm/subagent) + rolling 50-error buffer. Supports both Plugin SDK (api.registerPluginHook) and EventEmitter (gateway.on) registration.",
290
294
  metadata: { topic: "wolverine-claw-plugin" },
291
295
  },
296
+ {
297
+ text: "Wolverine API (src/claw/wolverine-api.js): unified entry point for any OpenClaw process. const api = require('wolverine-ai/src/claw/wolverine-api').init(projectRoot). 13 lazy-loaded subsystem categories, 85 verified access points: security (injection 50+ patterns, redaction, sandbox, rate limiter), brain (vector search, learn, embed, function map, tool router with 25+ error-to-tool mappings), ai (call, callWithHistory, dual-provider, model config, token tracking), errors (parse, classify, route tools, human-required detection, loop guard), backup (create, rollback, undo, list, promote, prune), skills (registry, SQL guard, deps analysis, migrations), monitor (ErrorMonitor, PerfMonitor, ProcessMonitor, AdaptiveLimiter), logger (EventLogger, TokenTracker, RepairHistory), config, agent (AgentEngine with 32 tools), context (server scanner), verify (syntax check, boot probe), mcp (McpRegistry). Convenience: api.scanText() for fast sync security scan, api.diagnoseError() for parse+classify+route+human-check. Everything lazy-loaded — requiring the module costs nothing until first use.",
298
+ metadata: { topic: "wolverine-api" },
299
+ },
292
300
  {
293
301
  text: "Wolverine Claw configuration (wolverine-claw/config/settings.json): gateway (port 18789, host 127.0.0.1), agent (model claude-sonnet-4-6, maxTurns 25, timeoutMs 120000), models (reasoning/coding/chat/embedding per-task), channels (terminal enabled by default, discord/slack/telegram/whatsapp configurable with tokens in .env.local), healing (enabled, healTimeoutMs 300000, maxHealsPerWindow 5, loopMaxAttempts 3), skills (codingAgent with sandbox+allowedPaths, browserControl, cron, canvas), workspace (path wolverine-claw/workspace, maxFileSizeMB 50), security (dmPairing true, sandbox true, blockedCommands, maxConcurrentSessions 5), logging, remoteAccess (disabled, tailscale method), backup (stabilityMs 1800000, retentionDays 7). Editable scope: only wolverine-claw/ files can be modified by the claw agent. src/, bin/, server/ are protected.",
294
302
  metadata: { topic: "wolverine-claw-config" },
package/src/claw/setup.js CHANGED
@@ -596,24 +596,25 @@ function addClawScripts(cwd) {
596
596
  if (typeof cmd !== "string") continue;
597
597
  // Skip scripts we just added
598
598
  if (name.startsWith("claw")) continue;
599
-
600
- // Find scripts that run openclaw (start, dev, gateway, etc.)
601
- const isOpenClawScript = cmd.includes("openclaw") || cmd.includes("open-claw");
602
- // Also patch plain node scripts that start a gateway/agent
603
- const isNodeScript = cmd.startsWith("node ") && !cmd.includes("wolverine");
604
-
605
- if ((isOpenClawScript || isNodeScript) && !cmd.includes("bootstrap.js")) {
606
- // Inject --require before the main script/command
607
- if (cmd.startsWith("node ")) {
608
- // node index.js → node --require ./wolverine-claw/bootstrap.js index.js
609
- pkg.scripts[name] = cmd.replace("node ", `node ${BOOTSTRAP} `);
610
- patched++;
611
- } else if (cmd.startsWith("openclaw ") || cmd.startsWith("npx openclaw")) {
612
- // For CLI commands, use NODE_OPTIONS to inject --require
613
- // npm scripts inherit env vars, so this works cross-platform
614
- pkg.scripts[name] = `NODE_OPTIONS="${BOOTSTRAP}" ${cmd}`;
615
- patched++;
616
- }
599
+ // Already patched
600
+ if (cmd.includes("bootstrap.js")) continue;
601
+
602
+ // Only patch scripts that actually run openclaw
603
+ const isOpenClawCLI = cmd.includes("openclaw") && !cmd.includes("wolverine");
604
+ // Or node scripts that start an openclaw entry point (not wolverine's own scripts)
605
+ const isOpenClawNode = cmd.startsWith("node ") &&
606
+ !cmd.includes("wolverine") &&
607
+ !cmd.includes("bin/") &&
608
+ !cmd.includes("examples/") &&
609
+ !cmd.includes("tests/") &&
610
+ (cmd.includes("gateway") || cmd.includes("openclaw") || cmd.includes("index.js"));
611
+
612
+ if (isOpenClawCLI) {
613
+ pkg.scripts[name] = `NODE_OPTIONS="${BOOTSTRAP}" ${cmd}`;
614
+ patched++;
615
+ } else if (isOpenClawNode) {
616
+ pkg.scripts[name] = cmd.replace("node ", `node ${BOOTSTRAP} `);
617
+ patched++;
617
618
  }
618
619
  }
619
620