claude-flow 3.7.0-alpha.26 → 3.7.0-alpha.27

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.
@@ -1,4 +1,5 @@
1
1
  {
2
+ "_note": "#1921 — hook commands invoke scripts/ruflo-hook.sh (resilient shim): prefers a locally-installed `ruflo`/`claude-flow` binary, falls back to `npx --prefer-offline`, and always exits 0 so a CLI/install failure (e.g. arborist `Invalid Version` on npm 10.8.x) never surfaces an error in Claude Code or blocks a turn. The trailing `|| true` guards the case where $CLAUDE_PLUGIN_ROOT is unset (older Claude Code) — the hook then no-ops silently. DO NOT revert to a bare `npx <pkg>@alpha hooks …` per fire.",
2
3
  "hooks": {
3
4
  "PreToolUse": [
4
5
  {
@@ -6,7 +7,7 @@
6
7
  "hooks": [
7
8
  {
8
9
  "type": "command",
9
- "command": "cat | npx claude-flow@alpha hooks modify-bash"
10
+ "command": "\"${CLAUDE_PLUGIN_ROOT}/scripts/ruflo-hook.sh\" modify-bash || true"
10
11
  }
11
12
  ]
12
13
  },
@@ -15,7 +16,7 @@
15
16
  "hooks": [
16
17
  {
17
18
  "type": "command",
18
- "command": "cat | npx claude-flow@alpha hooks modify-file"
19
+ "command": "\"${CLAUDE_PLUGIN_ROOT}/scripts/ruflo-hook.sh\" modify-file || true"
19
20
  }
20
21
  ]
21
22
  }
@@ -26,7 +27,7 @@
26
27
  "hooks": [
27
28
  {
28
29
  "type": "command",
29
- "command": "cat | jq -r '.tool_input.command // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks post-command --command '{}' --track-metrics true --store-results true"
30
+ "command": "cat | jq -r '.tool_input.command // empty' | tr '\\n' '\\0' | xargs -0 -I {} \"${CLAUDE_PLUGIN_ROOT}/scripts/ruflo-hook.sh\" post-command --command '{}' --track-metrics true --store-results true || true"
30
31
  }
31
32
  ]
32
33
  },
@@ -35,7 +36,7 @@
35
36
  "hooks": [
36
37
  {
37
38
  "type": "command",
38
- "command": "cat | jq -r '.tool_input.file_path // .tool_input.path // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks post-edit --file '{}' --format true --update-memory true"
39
+ "command": "cat | jq -r '.tool_input.file_path // .tool_input.path // empty' | tr '\\n' '\\0' | xargs -0 -I {} \"${CLAUDE_PLUGIN_ROOT}/scripts/ruflo-hook.sh\" post-edit --file '{}' --format true --update-memory true || true"
39
40
  }
40
41
  ]
41
42
  }
@@ -65,7 +66,7 @@
65
66
  "hooks": [
66
67
  {
67
68
  "type": "command",
68
- "command": "npx claude-flow@alpha hooks session-end --generate-summary true --persist-state true --export-metrics true"
69
+ "command": "\"${CLAUDE_PLUGIN_ROOT}/scripts/ruflo-hook.sh\" session-end --generate-summary true --persist-state true --export-metrics true || true"
69
70
  }
70
71
  ]
71
72
  }
@@ -72,9 +72,9 @@
72
72
  "description": "Advanced git workflows with diff analysis, risk scoring, and reviewer recommendations"
73
73
  },
74
74
  {
75
- "name": "ruflo-wasm",
76
- "source": "./plugins/ruflo-wasm",
77
- "description": "Sandboxed WASM agent creation, execution, and gallery sharing"
75
+ "name": "ruflo-agent",
76
+ "source": "./plugins/ruflo-agent",
77
+ "description": "Agent runtimes — local WASM-sandboxed agents (rvagent) + Anthropic Claude Managed Agents (cloud); one interface, local-vs-cloud backends"
78
78
  },
79
79
  {
80
80
  "name": "ruflo-workflows",
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env bash
2
+ # ruflo-hook.sh — resilient invoker for ruflo CLI hook subcommands (#1921).
3
+ #
4
+ # Hooks fire on EVERY PreToolUse / PostToolUse / Stop. A bare
5
+ # `npx <pkg>@alpha hooks …` re-resolves the @alpha dist-tag and re-installs
6
+ # from cold cache on every fire, and when the install crashes (e.g. an
7
+ # arborist `Invalid Version` on npm 10.8.x) the user sees a hook error in
8
+ # Claude Code after every turn. This shim:
9
+ # 1. prefers an already-installed `ruflo` / `claude-flow` binary (no npx,
10
+ # no install) — the common case for plugin users;
11
+ # 2. falls back to `npx --prefer-offline` so a populated npx cache is
12
+ # reused instead of a fresh registry resolve;
13
+ # 3. ALWAYS exits 0 — hook subcommands are best-effort telemetry/learning;
14
+ # a failure must never surface an error or block a turn.
15
+ #
16
+ # stdin (the hook event JSON) is passed through to the CLI unchanged.
17
+ # Usage: ruflo-hook.sh <hook-subcommand> [args…] (the literal `hooks`
18
+ # word is prepended here, so callers pass e.g. `post-edit -f "$FILE" -s true`).
19
+
20
+ # Swallow all diagnostics — nothing this script prints should reach Claude Code.
21
+ exec 2>/dev/null
22
+
23
+ run() { "$@" || true; }
24
+
25
+ if command -v ruflo >/dev/null 2>&1; then
26
+ run ruflo hooks "$@"
27
+ elif command -v claude-flow >/dev/null 2>&1; then
28
+ run claude-flow hooks "$@"
29
+ else
30
+ run npx --prefer-offline --yes ruflo@alpha hooks "$@"
31
+ fi
32
+
33
+ exit 0
package/README.md CHANGED
@@ -77,78 +77,78 @@ This adds slash commands and agent definitions only. The Ruflo MCP server is NOT
77
77
 
78
78
  | Plugin | What it does |
79
79
  |--------|-------------|
80
- | **ruflo-core** | Foundation — server, health checks, plugin discovery |
81
- | **ruflo-swarm** | Coordinate multiple agents as a team |
82
- | **ruflo-autopilot** | Let agents run autonomously in a loop |
83
- | **ruflo-loop-workers** | Schedule background tasks on a timer |
84
- | **ruflo-workflows** | Reusable multi-step task templates |
85
- | **ruflo-federation** | Agents on different machines collaborate securely |
80
+ | [**ruflo-core**](plugins/ruflo-core/README.md) | Foundation — server, health checks, plugin discovery |
81
+ | [**ruflo-swarm**](plugins/ruflo-swarm/README.md) | Coordinate multiple agents as a team |
82
+ | [**ruflo-autopilot**](plugins/ruflo-autopilot/README.md) | Let agents run autonomously in a loop |
83
+ | [**ruflo-loop-workers**](plugins/ruflo-loop-workers/README.md) | Schedule background tasks on a timer |
84
+ | [**ruflo-workflows**](plugins/ruflo-workflows/README.md) | Reusable multi-step task templates |
85
+ | [**ruflo-federation**](plugins/ruflo-federation/README.md) | Agents on different machines collaborate securely |
86
86
 
87
87
  #### Memory & Knowledge
88
88
 
89
89
  | Plugin | What it does |
90
90
  |--------|-------------|
91
- | **ruflo-agentdb** | Fast vector database for agent memory |
92
- | **ruflo-rag-memory** | Smart retrieval — hybrid search, graph hops, diversity ranking |
93
- | **ruflo-rvf** | Save and restore agent memory across sessions |
94
- | **ruflo-ruvector** | [`ruvector`](https://npmjs.com/package/ruvector) — GPU-accelerated search, Graph RAG, 103 tools |
95
- | **ruflo-knowledge-graph** | Build and traverse entity relationship maps |
91
+ | [**ruflo-agentdb**](plugins/ruflo-agentdb/README.md) | Fast vector database for agent memory |
92
+ | [**ruflo-rag-memory**](plugins/ruflo-rag-memory/README.md) | Smart retrieval — hybrid search, graph hops, diversity ranking |
93
+ | [**ruflo-rvf**](plugins/ruflo-rvf/README.md) | Save and restore agent memory across sessions |
94
+ | [**ruflo-ruvector**](plugins/ruflo-ruvector/README.md) | [`ruvector`](https://npmjs.com/package/ruvector) — GPU-accelerated search, Graph RAG, 103 tools |
95
+ | [**ruflo-knowledge-graph**](plugins/ruflo-knowledge-graph/README.md) | Build and traverse entity relationship maps |
96
96
 
97
97
  #### Intelligence & Learning
98
98
 
99
99
  | Plugin | What it does |
100
100
  |--------|-------------|
101
- | **ruflo-intelligence** | Agents learn from past successes and get smarter |
102
- | **ruflo-daa** | Dynamic agent behavior and cognitive patterns |
103
- | **ruflo-ruvllm** | Run local LLMs (Ollama, etc.) with smart routing |
104
- | **ruflo-goals** | Break big goals into plans and track progress |
101
+ | [**ruflo-intelligence**](plugins/ruflo-intelligence/README.md) | Agents learn from past successes and get smarter |
102
+ | [**ruflo-daa**](plugins/ruflo-daa/README.md) | Dynamic agent behavior and cognitive patterns |
103
+ | [**ruflo-ruvllm**](plugins/ruflo-ruvllm/README.md) | Run local LLMs (Ollama, etc.) with smart routing |
104
+ | [**ruflo-goals**](plugins/ruflo-goals/README.md) | Break big goals into plans and track progress |
105
105
 
106
106
  #### Code Quality & Testing
107
107
 
108
108
  | Plugin | What it does |
109
109
  |--------|-------------|
110
- | **ruflo-testgen** | Find missing tests and generate them automatically |
111
- | **ruflo-browser** | Automate browser testing with Playwright |
112
- | **ruflo-jujutsu** | Analyze git diffs, score risk, suggest reviewers |
113
- | **ruflo-docs** | Generate and maintain documentation automatically |
110
+ | [**ruflo-testgen**](plugins/ruflo-testgen/README.md) | Find missing tests and generate them automatically |
111
+ | [**ruflo-browser**](plugins/ruflo-browser/README.md) | Automate browser testing with Playwright |
112
+ | [**ruflo-jujutsu**](plugins/ruflo-jujutsu/README.md) | Analyze git diffs, score risk, suggest reviewers |
113
+ | [**ruflo-docs**](plugins/ruflo-docs/README.md) | Generate and maintain documentation automatically |
114
114
 
115
115
  #### Security & Compliance
116
116
 
117
117
  | Plugin | What it does |
118
118
  |--------|-------------|
119
- | **ruflo-security-audit** | Scan for vulnerabilities and CVEs |
120
- | **ruflo-aidefence** | Block prompt injection, detect PII, safety scanning |
119
+ | [**ruflo-security-audit**](plugins/ruflo-security-audit/README.md) | Scan for vulnerabilities and CVEs |
120
+ | [**ruflo-aidefence**](plugins/ruflo-aidefence/README.md) | Block prompt injection, detect PII, safety scanning |
121
121
 
122
122
  #### Architecture & Methodology
123
123
 
124
124
  | Plugin | What it does |
125
125
  |--------|-------------|
126
- | **ruflo-adr** | Track architecture decisions with a living record |
127
- | **ruflo-ddd** | Scaffold domain-driven design — contexts, aggregates, events |
128
- | **ruflo-sparc** | Guided 5-phase development methodology with quality gates |
126
+ | [**ruflo-adr**](plugins/ruflo-adr/README.md) | Track architecture decisions with a living record |
127
+ | [**ruflo-ddd**](plugins/ruflo-ddd/README.md) | Scaffold domain-driven design — contexts, aggregates, events |
128
+ | [**ruflo-sparc**](plugins/ruflo-sparc/README.md) | Guided 5-phase development methodology with quality gates |
129
129
 
130
130
  #### DevOps & Observability
131
131
 
132
132
  | Plugin | What it does |
133
133
  |--------|-------------|
134
- | **ruflo-migrations** | Manage database schema changes safely |
135
- | **ruflo-observability** | Structured logs, traces, and metrics in one place |
136
- | **ruflo-cost-tracker** | Track token usage, set budgets, get cost alerts |
134
+ | [**ruflo-migrations**](plugins/ruflo-migrations/README.md) | Manage database schema changes safely |
135
+ | [**ruflo-observability**](plugins/ruflo-observability/README.md) | Structured logs, traces, and metrics in one place |
136
+ | [**ruflo-cost-tracker**](plugins/ruflo-cost-tracker/README.md) | Track token usage, set budgets, get cost alerts |
137
137
 
138
138
  #### Extensibility
139
139
 
140
140
  | Plugin | What it does |
141
141
  |--------|-------------|
142
- | **ruflo-wasm** | Run sandboxed WebAssembly agents |
143
- | **ruflo-plugin-creator** | Scaffold, validate, and publish your own plugins |
142
+ | [**ruflo-agent**](plugins/ruflo-agent/README.md) | Run agents local WASM sandbox (rvagent) + Anthropic Claude Managed Agents (cloud) |
143
+ | [**ruflo-plugin-creator**](plugins/ruflo-plugin-creator/README.md) | Scaffold, validate, and publish your own plugins |
144
144
 
145
145
  #### Domain-Specific
146
146
 
147
147
  | Plugin | What it does |
148
148
  |--------|-------------|
149
- | **ruflo-iot-cognitum** | IoT device management — trust scoring, anomaly detection, fleets |
150
- | **ruflo-neural-trader** | [`neural-trader`](https://npmjs.com/package/neural-trader) — AI trading with 4 agents, backtesting, 112+ tools |
151
- | **ruflo-market-data** | Ingest market data, vectorize OHLCV, detect patterns |
149
+ | [**ruflo-iot-cognitum**](plugins/ruflo-iot-cognitum/README.md) | IoT device management — trust scoring, anomaly detection, fleets |
150
+ | [**ruflo-neural-trader**](plugins/ruflo-neural-trader/README.md) | [`neural-trader`](https://npmjs.com/package/neural-trader) — AI trading with 4 agents, backtesting, 112+ tools |
151
+ | [**ruflo-market-data**](plugins/ruflo-market-data/README.md) | Ingest market data, vectorize OHLCV, detect patterns |
152
152
 
153
153
  </details>
154
154
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.7.0-alpha.26",
3
+ "version": "3.7.0-alpha.27",
4
4
  "description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -77,78 +77,78 @@ This adds slash commands and agent definitions only. The Ruflo MCP server is NOT
77
77
 
78
78
  | Plugin | What it does |
79
79
  |--------|-------------|
80
- | **ruflo-core** | Foundation — server, health checks, plugin discovery |
81
- | **ruflo-swarm** | Coordinate multiple agents as a team |
82
- | **ruflo-autopilot** | Let agents run autonomously in a loop |
83
- | **ruflo-loop-workers** | Schedule background tasks on a timer |
84
- | **ruflo-workflows** | Reusable multi-step task templates |
85
- | **ruflo-federation** | Agents on different machines collaborate securely |
80
+ | [**ruflo-core**](plugins/ruflo-core/README.md) | Foundation — server, health checks, plugin discovery |
81
+ | [**ruflo-swarm**](plugins/ruflo-swarm/README.md) | Coordinate multiple agents as a team |
82
+ | [**ruflo-autopilot**](plugins/ruflo-autopilot/README.md) | Let agents run autonomously in a loop |
83
+ | [**ruflo-loop-workers**](plugins/ruflo-loop-workers/README.md) | Schedule background tasks on a timer |
84
+ | [**ruflo-workflows**](plugins/ruflo-workflows/README.md) | Reusable multi-step task templates |
85
+ | [**ruflo-federation**](plugins/ruflo-federation/README.md) | Agents on different machines collaborate securely |
86
86
 
87
87
  #### Memory & Knowledge
88
88
 
89
89
  | Plugin | What it does |
90
90
  |--------|-------------|
91
- | **ruflo-agentdb** | Fast vector database for agent memory |
92
- | **ruflo-rag-memory** | Smart retrieval — hybrid search, graph hops, diversity ranking |
93
- | **ruflo-rvf** | Save and restore agent memory across sessions |
94
- | **ruflo-ruvector** | [`ruvector`](https://npmjs.com/package/ruvector) — GPU-accelerated search, Graph RAG, 103 tools |
95
- | **ruflo-knowledge-graph** | Build and traverse entity relationship maps |
91
+ | [**ruflo-agentdb**](plugins/ruflo-agentdb/README.md) | Fast vector database for agent memory |
92
+ | [**ruflo-rag-memory**](plugins/ruflo-rag-memory/README.md) | Smart retrieval — hybrid search, graph hops, diversity ranking |
93
+ | [**ruflo-rvf**](plugins/ruflo-rvf/README.md) | Save and restore agent memory across sessions |
94
+ | [**ruflo-ruvector**](plugins/ruflo-ruvector/README.md) | [`ruvector`](https://npmjs.com/package/ruvector) — GPU-accelerated search, Graph RAG, 103 tools |
95
+ | [**ruflo-knowledge-graph**](plugins/ruflo-knowledge-graph/README.md) | Build and traverse entity relationship maps |
96
96
 
97
97
  #### Intelligence & Learning
98
98
 
99
99
  | Plugin | What it does |
100
100
  |--------|-------------|
101
- | **ruflo-intelligence** | Agents learn from past successes and get smarter |
102
- | **ruflo-daa** | Dynamic agent behavior and cognitive patterns |
103
- | **ruflo-ruvllm** | Run local LLMs (Ollama, etc.) with smart routing |
104
- | **ruflo-goals** | Break big goals into plans and track progress |
101
+ | [**ruflo-intelligence**](plugins/ruflo-intelligence/README.md) | Agents learn from past successes and get smarter |
102
+ | [**ruflo-daa**](plugins/ruflo-daa/README.md) | Dynamic agent behavior and cognitive patterns |
103
+ | [**ruflo-ruvllm**](plugins/ruflo-ruvllm/README.md) | Run local LLMs (Ollama, etc.) with smart routing |
104
+ | [**ruflo-goals**](plugins/ruflo-goals/README.md) | Break big goals into plans and track progress |
105
105
 
106
106
  #### Code Quality & Testing
107
107
 
108
108
  | Plugin | What it does |
109
109
  |--------|-------------|
110
- | **ruflo-testgen** | Find missing tests and generate them automatically |
111
- | **ruflo-browser** | Automate browser testing with Playwright |
112
- | **ruflo-jujutsu** | Analyze git diffs, score risk, suggest reviewers |
113
- | **ruflo-docs** | Generate and maintain documentation automatically |
110
+ | [**ruflo-testgen**](plugins/ruflo-testgen/README.md) | Find missing tests and generate them automatically |
111
+ | [**ruflo-browser**](plugins/ruflo-browser/README.md) | Automate browser testing with Playwright |
112
+ | [**ruflo-jujutsu**](plugins/ruflo-jujutsu/README.md) | Analyze git diffs, score risk, suggest reviewers |
113
+ | [**ruflo-docs**](plugins/ruflo-docs/README.md) | Generate and maintain documentation automatically |
114
114
 
115
115
  #### Security & Compliance
116
116
 
117
117
  | Plugin | What it does |
118
118
  |--------|-------------|
119
- | **ruflo-security-audit** | Scan for vulnerabilities and CVEs |
120
- | **ruflo-aidefence** | Block prompt injection, detect PII, safety scanning |
119
+ | [**ruflo-security-audit**](plugins/ruflo-security-audit/README.md) | Scan for vulnerabilities and CVEs |
120
+ | [**ruflo-aidefence**](plugins/ruflo-aidefence/README.md) | Block prompt injection, detect PII, safety scanning |
121
121
 
122
122
  #### Architecture & Methodology
123
123
 
124
124
  | Plugin | What it does |
125
125
  |--------|-------------|
126
- | **ruflo-adr** | Track architecture decisions with a living record |
127
- | **ruflo-ddd** | Scaffold domain-driven design — contexts, aggregates, events |
128
- | **ruflo-sparc** | Guided 5-phase development methodology with quality gates |
126
+ | [**ruflo-adr**](plugins/ruflo-adr/README.md) | Track architecture decisions with a living record |
127
+ | [**ruflo-ddd**](plugins/ruflo-ddd/README.md) | Scaffold domain-driven design — contexts, aggregates, events |
128
+ | [**ruflo-sparc**](plugins/ruflo-sparc/README.md) | Guided 5-phase development methodology with quality gates |
129
129
 
130
130
  #### DevOps & Observability
131
131
 
132
132
  | Plugin | What it does |
133
133
  |--------|-------------|
134
- | **ruflo-migrations** | Manage database schema changes safely |
135
- | **ruflo-observability** | Structured logs, traces, and metrics in one place |
136
- | **ruflo-cost-tracker** | Track token usage, set budgets, get cost alerts |
134
+ | [**ruflo-migrations**](plugins/ruflo-migrations/README.md) | Manage database schema changes safely |
135
+ | [**ruflo-observability**](plugins/ruflo-observability/README.md) | Structured logs, traces, and metrics in one place |
136
+ | [**ruflo-cost-tracker**](plugins/ruflo-cost-tracker/README.md) | Track token usage, set budgets, get cost alerts |
137
137
 
138
138
  #### Extensibility
139
139
 
140
140
  | Plugin | What it does |
141
141
  |--------|-------------|
142
- | **ruflo-wasm** | Run sandboxed WebAssembly agents |
143
- | **ruflo-plugin-creator** | Scaffold, validate, and publish your own plugins |
142
+ | [**ruflo-agent**](plugins/ruflo-agent/README.md) | Run agents local WASM sandbox (rvagent) + Anthropic Claude Managed Agents (cloud) |
143
+ | [**ruflo-plugin-creator**](plugins/ruflo-plugin-creator/README.md) | Scaffold, validate, and publish your own plugins |
144
144
 
145
145
  #### Domain-Specific
146
146
 
147
147
  | Plugin | What it does |
148
148
  |--------|-------------|
149
- | **ruflo-iot-cognitum** | IoT device management — trust scoring, anomaly detection, fleets |
150
- | **ruflo-neural-trader** | [`neural-trader`](https://npmjs.com/package/neural-trader) — AI trading with 4 agents, backtesting, 112+ tools |
151
- | **ruflo-market-data** | Ingest market data, vectorize OHLCV, detect patterns |
149
+ | [**ruflo-iot-cognitum**](plugins/ruflo-iot-cognitum/README.md) | IoT device management — trust scoring, anomaly detection, fleets |
150
+ | [**ruflo-neural-trader**](plugins/ruflo-neural-trader/README.md) | [`neural-trader`](https://npmjs.com/package/neural-trader) — AI trading with 4 agents, backtesting, 112+ tools |
151
+ | [**ruflo-market-data**](plugins/ruflo-market-data/README.md) | Ingest market data, vectorize OHLCV, detect patterns |
152
152
 
153
153
  </details>
154
154
 
@@ -3,6 +3,26 @@
3
3
  * Manages background worker daemon (Node.js-based, similar to shell helpers)
4
4
  */
5
5
  import type { Command } from '../types.js';
6
+ /**
7
+ * #1914: Resolve the `--workspace` flag to an absolute path, or return null
8
+ * if it is absent / not a usable string. Rejects values with null bytes or
9
+ * shell metacharacters (defence-in-depth — the value is later embedded in a
10
+ * forked child's argv and compared against `ps`/`tasklist` output).
11
+ */
12
+ export declare function resolveWorkspaceFlag(raw: unknown): string | null;
13
+ /**
14
+ * #1914: True when a process command line (from `ps -eo command` on POSIX or
15
+ * the tasklist Window Title column on Windows) belongs to a daemon started
16
+ * for `workspaceRoot`. The launcher (`startBackgroundDaemon`) always appends
17
+ * `--workspace <root>` as the FINAL argv entry, so an exact trailing match
18
+ * after stripping trailing whitespace/quotes is unambiguous — even for
19
+ * workspace paths containing spaces — and never a bare path-prefix match,
20
+ * so workspace `/a/proj` does not reap `/a/proj-other`'s daemon. A daemon
21
+ * whose argv puts `--workspace` mid-list (only possible via a hand-rolled
22
+ * invocation) simply won't be auto-reaped — `daemon stop` still handles it
23
+ * via the PID file.
24
+ */
25
+ export declare function daemonCommandLineBelongsToWorkspace(commandLine: string, workspaceRoot: string): boolean;
6
26
  export declare const daemonCommand: Command;
7
27
  export default daemonCommand;
8
28
  //# sourceMappingURL=daemon.d.ts.map
@@ -21,6 +21,11 @@ const startCommand = {
21
21
  { name: 'sandbox', type: 'string', description: 'Default sandbox mode for headless workers', choices: ['strict', 'permissive', 'disabled'] },
22
22
  { name: 'max-cpu-load', type: 'string', description: 'Override maxCpuLoad resource threshold (e.g. 4.0)' },
23
23
  { name: 'min-free-memory', type: 'string', description: 'Override minFreeMemoryPercent resource threshold (e.g. 15)' },
24
+ // #1914: workspace root for this daemon. Set automatically when the
25
+ // background launcher forks the foreground child so the daemon process
26
+ // carries its workspace path in argv — `killStaleDaemons` then only
27
+ // reaps daemons belonging to the current workspace (ADR-014 scope).
28
+ { name: 'workspace', type: 'string', description: 'Workspace root for this daemon (internal — set automatically when forking)' },
24
29
  ],
25
30
  examples: [
26
31
  { command: 'claude-flow daemon start', description: 'Start daemon in background (default)' },
@@ -31,7 +36,9 @@ const startCommand = {
31
36
  action: async (ctx) => {
32
37
  const quiet = ctx.flags.quiet;
33
38
  const foreground = ctx.flags.foreground;
34
- const projectRoot = process.cwd();
39
+ // #1914: a forked daemon child receives --workspace <root>; the launcher
40
+ // and interactive invocations have no flag and fall back to cwd.
41
+ const projectRoot = resolveWorkspaceFlag(ctx.flags.workspace) ?? process.cwd();
35
42
  const isDaemonProcess = process.env.CLAUDE_FLOW_DAEMON === '1';
36
43
  // Parse resource threshold overrides from CLI flags
37
44
  const config = {};
@@ -195,6 +202,37 @@ function validatePath(path, label) {
195
202
  }
196
203
  }
197
204
  }
205
+ /**
206
+ * #1914: Resolve the `--workspace` flag to an absolute path, or return null
207
+ * if it is absent / not a usable string. Rejects values with null bytes or
208
+ * shell metacharacters (defence-in-depth — the value is later embedded in a
209
+ * forked child's argv and compared against `ps`/`tasklist` output).
210
+ */
211
+ export function resolveWorkspaceFlag(raw) {
212
+ if (typeof raw !== 'string')
213
+ return null;
214
+ const trimmed = raw.trim();
215
+ if (!trimmed)
216
+ return null;
217
+ if (trimmed.includes('\0') || /[;&|`$<>]/.test(trimmed))
218
+ return null;
219
+ return resolve(trimmed);
220
+ }
221
+ /**
222
+ * #1914: True when a process command line (from `ps -eo command` on POSIX or
223
+ * the tasklist Window Title column on Windows) belongs to a daemon started
224
+ * for `workspaceRoot`. The launcher (`startBackgroundDaemon`) always appends
225
+ * `--workspace <root>` as the FINAL argv entry, so an exact trailing match
226
+ * after stripping trailing whitespace/quotes is unambiguous — even for
227
+ * workspace paths containing spaces — and never a bare path-prefix match,
228
+ * so workspace `/a/proj` does not reap `/a/proj-other`'s daemon. A daemon
229
+ * whose argv puts `--workspace` mid-list (only possible via a hand-rolled
230
+ * invocation) simply won't be auto-reaped — `daemon stop` still handles it
231
+ * via the PID file.
232
+ */
233
+ export function daemonCommandLineBelongsToWorkspace(commandLine, workspaceRoot) {
234
+ return commandLine.replace(/[\s"']+$/u, '').endsWith(`--workspace ${workspaceRoot}`);
235
+ }
198
236
  /**
199
237
  * Start daemon as a detached background process
200
238
  */
@@ -266,6 +304,10 @@ async function startBackgroundDaemon(projectRoot, quiet, maxCpuLoad, minFreeMemo
266
304
  if (minFreeMemory && SPAWN_NUMERIC_RE.test(minFreeMemory)) {
267
305
  forkArgs.push('--min-free-memory', minFreeMemory);
268
306
  }
307
+ // #1914: stamp the workspace into argv (kept LAST) so the foreground daemon
308
+ // process is self-identifying and `killStaleDaemons` only reaps daemons
309
+ // belonging to this workspace. resolvedRoot was validatePath()'d above.
310
+ forkArgs.push('--workspace', resolvedRoot);
269
311
  const child = fork(cliPath, forkArgs, forkOpts);
270
312
  // Get PID from spawned process directly (no shell echo needed)
271
313
  const pid = child.pid;
@@ -408,12 +450,18 @@ async function killStaleDaemonsPosix(projectRoot, quiet) {
408
450
  const lines = psOutput.split('\n');
409
451
  const currentPid = process.pid;
410
452
  const trackedPid = getBackgroundDaemonPid(projectRoot);
453
+ // #1914: only ever reap daemons belonging to THIS workspace (ADR-014).
454
+ const resolvedRoot = resolve(projectRoot);
411
455
  let killed = 0;
412
456
  for (const line of lines) {
413
457
  if (!line.includes('daemon start --foreground'))
414
458
  continue;
415
459
  if (!line.includes('claude-flow') && !line.includes('@claude-flow/cli'))
416
460
  continue;
461
+ // #1914: skip daemons from other workspaces (or pre-#1914 versions that
462
+ // didn't stamp --workspace — let `daemon stop` handle those via PID file).
463
+ if (!daemonCommandLineBelongsToWorkspace(line, resolvedRoot))
464
+ continue;
417
465
  const pidStr = line.trim().split(/\s+/)[0];
418
466
  const pid = parseInt(pidStr, 10);
419
467
  if (isNaN(pid) || pid === currentPid || pid === trackedPid)
@@ -453,6 +501,8 @@ async function killStaleDaemonsWindows(projectRoot, quiet) {
453
501
  const lines = out.split(/\r?\n/);
454
502
  const currentPid = process.pid;
455
503
  const trackedPid = getBackgroundDaemonPid(projectRoot);
504
+ // #1914: only ever reap daemons belonging to THIS workspace (ADR-014).
505
+ const resolvedRoot = resolve(projectRoot);
456
506
  let killed = 0;
457
507
  for (const line of lines) {
458
508
  if (!line.trim())
@@ -463,6 +513,9 @@ async function killStaleDaemonsWindows(projectRoot, quiet) {
463
513
  continue;
464
514
  if (!line.includes('claude-flow') && !line.includes('@claude-flow/cli'))
465
515
  continue;
516
+ // #1914: skip daemons from other workspaces (or pre-#1914 versions).
517
+ if (!daemonCommandLineBelongsToWorkspace(line, resolvedRoot))
518
+ continue;
466
519
  // Parse CSV: tasklist quotes each field, so split on `","`
467
520
  const fields = line.split(/","/).map(f => f.replace(/^"|"$/g, ''));
468
521
  // fields[0] = Image Name, fields[1] = PID, …
@@ -39,6 +39,10 @@ import { agentdbTools } from './mcp-tools/agentdb-tools.js';
39
39
  // RuVector WASM tools
40
40
  import { ruvllmWasmTools } from './mcp-tools/ruvllm-tools.js';
41
41
  import { wasmAgentTools } from './mcp-tools/wasm-agent-tools.js';
42
+ // ADR-115: Anthropic Claude Managed Agents — a cloud agent runtime alongside
43
+ // the local WASM-sandboxed `wasm_agent_*` (rvagent) tools. Lives in the
44
+ // `ruflo-agent` plugin.
45
+ import { managedAgentTools } from './mcp-tools/managed-agent-tools.js';
42
46
  import { guidanceTools } from './mcp-tools/guidance-tools.js';
43
47
  import { autopilotTools } from './mcp-tools/autopilot-tools.js';
44
48
  // #1916: coverage-aware routing tools — defined in ruvector/coverage-tools.ts
@@ -111,6 +115,8 @@ registerTools([
111
115
  // RuVector WASM tools
112
116
  ...ruvllmWasmTools,
113
117
  ...wasmAgentTools,
118
+ // ADR-115: Anthropic Claude Managed Agents (cloud agent runtime)
119
+ ...managedAgentTools,
114
120
  // Guidance & discovery tools
115
121
  ...guidanceTools,
116
122
  // Autopilot persistent completion tools
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Managed Agent MCP tools — Anthropic Claude Managed Agents as a *cloud*
3
+ * agent runtime alongside ruflo's local WASM-sandboxed agents (`rvagent` /
4
+ * `wasm_agent_*`). See ADR-115.
5
+ *
6
+ * Wraps the Managed Agents REST API (beta, `anthropic-beta:
7
+ * managed-agents-2026-04-01`) with plain `fetch` — no new SDK dependency.
8
+ * Needs `ANTHROPIC_API_KEY` (or `CLAUDE_API_KEY`); every tool degrades
9
+ * gracefully with a structured error when the key is absent so the CLI/MCP
10
+ * server stays up.
11
+ *
12
+ * Lifecycle (mirrors `wasm_agent_*`):
13
+ * managed_agent_create → agents.create + environments.create + sessions.create ↔ wasm_agent_create
14
+ * managed_agent_prompt → events.send(user.message) + poll events until idle ↔ wasm_agent_prompt
15
+ * managed_agent_status → GET /v1/sessions/{id}
16
+ * managed_agent_events → GET /v1/sessions/{id}/events (full transcript) ↔ wasm_agent_files (artifacts/log)
17
+ * managed_agent_list → GET /v1/sessions
18
+ * managed_agent_terminate→ DELETE /v1/sessions/{id} (+ optionally the env) ↔ wasm_agent_terminate
19
+ */
20
+ import type { MCPTool } from './types.js';
21
+ export declare const managedAgentTools: MCPTool[];
22
+ //# sourceMappingURL=managed-agent-tools.d.ts.map
@@ -0,0 +1,357 @@
1
+ /**
2
+ * Managed Agent MCP tools — Anthropic Claude Managed Agents as a *cloud*
3
+ * agent runtime alongside ruflo's local WASM-sandboxed agents (`rvagent` /
4
+ * `wasm_agent_*`). See ADR-115.
5
+ *
6
+ * Wraps the Managed Agents REST API (beta, `anthropic-beta:
7
+ * managed-agents-2026-04-01`) with plain `fetch` — no new SDK dependency.
8
+ * Needs `ANTHROPIC_API_KEY` (or `CLAUDE_API_KEY`); every tool degrades
9
+ * gracefully with a structured error when the key is absent so the CLI/MCP
10
+ * server stays up.
11
+ *
12
+ * Lifecycle (mirrors `wasm_agent_*`):
13
+ * managed_agent_create → agents.create + environments.create + sessions.create ↔ wasm_agent_create
14
+ * managed_agent_prompt → events.send(user.message) + poll events until idle ↔ wasm_agent_prompt
15
+ * managed_agent_status → GET /v1/sessions/{id}
16
+ * managed_agent_events → GET /v1/sessions/{id}/events (full transcript) ↔ wasm_agent_files (artifacts/log)
17
+ * managed_agent_list → GET /v1/sessions
18
+ * managed_agent_terminate→ DELETE /v1/sessions/{id} (+ optionally the env) ↔ wasm_agent_terminate
19
+ */
20
+ const API_BASE = process.env.ANTHROPIC_BASE_URL?.replace(/\/$/, '') || 'https://api.anthropic.com';
21
+ const BETA_HEADER = 'managed-agents-2026-04-01';
22
+ const ANTHROPIC_VERSION = '2023-06-01';
23
+ const DEFAULT_MODEL = 'claude-sonnet-4-6';
24
+ const POLL_INTERVAL_MS = 1500;
25
+ const DEFAULT_MAX_WAIT_MS = 180_000; // 3 min — long enough for a real task, bounded so a tool call never hangs forever
26
+ function apiKey() {
27
+ return process.env.ANTHROPIC_API_KEY || process.env.CLAUDE_API_KEY || null;
28
+ }
29
+ function headers(key) {
30
+ return {
31
+ 'x-api-key': key,
32
+ 'anthropic-version': ANTHROPIC_VERSION,
33
+ 'anthropic-beta': BETA_HEADER,
34
+ 'content-type': 'application/json',
35
+ };
36
+ }
37
+ const NEEDS_KEY = {
38
+ error: 'managed-agent runtime needs ANTHROPIC_API_KEY (or CLAUDE_API_KEY) and Claude Managed Agents beta access. ' +
39
+ 'For a local, no-key agent runtime use wasm_agent_create instead (rvagent / WASM sandbox).',
40
+ };
41
+ async function maRequest(method, path, body) {
42
+ const key = apiKey();
43
+ if (!key)
44
+ return { ok: false, status: 0, error: NEEDS_KEY.error };
45
+ let res;
46
+ try {
47
+ res = await fetch(`${API_BASE}/v1${path}`, {
48
+ method,
49
+ headers: headers(key),
50
+ body: body !== undefined ? JSON.stringify(body) : undefined,
51
+ signal: AbortSignal.timeout(30_000),
52
+ });
53
+ }
54
+ catch (e) {
55
+ return { ok: false, status: 0, error: `network error calling ${method} /v1${path}: ${e.message}` };
56
+ }
57
+ const text = await res.text();
58
+ let parsed = undefined;
59
+ try {
60
+ parsed = text ? JSON.parse(text) : undefined;
61
+ }
62
+ catch { /* leave undefined */ }
63
+ if (!res.ok) {
64
+ const apiErr = parsed?.error?.message
65
+ ?? parsed?.message
66
+ ?? text.slice(0, 300);
67
+ return { ok: false, status: res.status, error: `Managed Agents API ${res.status}: ${apiErr}`, body: parsed };
68
+ }
69
+ return { ok: true, status: res.status, data: parsed };
70
+ }
71
+ // ---- helpers --------------------------------------------------------------
72
+ function summarizeEvents(events) {
73
+ let assistantText = '';
74
+ const toolUses = [];
75
+ let status = 'unknown';
76
+ let stopReason = null;
77
+ for (const e of events) {
78
+ if (e.type === 'agent.message' && Array.isArray(e.content)) {
79
+ assistantText += e.content.filter(b => b.type === 'text').map(b => b.text ?? '').join('');
80
+ }
81
+ else if (e.type === 'agent.tool_use') {
82
+ toolUses.push({ name: e.name ?? '?', input: e.input });
83
+ }
84
+ else if (e.type === 'session.status_running') {
85
+ status = 'running';
86
+ }
87
+ else if (e.type === 'session.status_idle') {
88
+ status = 'idle';
89
+ stopReason = e.stop_reason?.type ?? null;
90
+ }
91
+ else if (e.type === 'session.status_error' || e.type === 'session.status_failed') {
92
+ status = 'error';
93
+ }
94
+ }
95
+ return { assistantText, toolUses, status, stopReason, eventCount: events.length };
96
+ }
97
+ async function fetchSessionEvents(sessionId) {
98
+ const r = await maRequest('GET', `/sessions/${encodeURIComponent(sessionId)}/events`);
99
+ if (!r.ok)
100
+ return [];
101
+ const d = r.data;
102
+ return (d.data ?? d.events ?? []);
103
+ }
104
+ // Wait until the session is no longer "running": poll the event log for a
105
+ // terminal session.status_* event. Bounded by maxWaitMs.
106
+ async function waitForIdle(sessionId, maxWaitMs) {
107
+ const deadline = Date.now() + Math.max(1_000, Math.min(maxWaitMs, 600_000));
108
+ let events = [];
109
+ while (Date.now() < deadline) {
110
+ events = await fetchSessionEvents(sessionId);
111
+ const terminal = events.some(e => e.type === 'session.status_idle' || e.type === 'session.status_error' || e.type === 'session.status_failed');
112
+ // Also stop early if the session record itself reports a non-running status
113
+ if (terminal)
114
+ return { done: true, events };
115
+ await new Promise(r => setTimeout(r, POLL_INTERVAL_MS));
116
+ }
117
+ return { done: false, events };
118
+ }
119
+ function maName(prefix, given) {
120
+ if (typeof given === 'string' && given.trim())
121
+ return given.trim().slice(0, 80);
122
+ return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
123
+ }
124
+ // ---------------------------------------------------------------------------
125
+ export const managedAgentTools = [
126
+ {
127
+ name: 'managed_agent_create',
128
+ description: 'Spin up an Anthropic-managed cloud agent (Agent + Environment + Session) — the CLOUD counterpart of wasm_agent_create. Use when wasm_agent_create (local WASM sandbox) is wrong because the task is long-running/async (minutes-hours), needs a real cloud container with pre-installed packages + network, or persistent filesystem + transcript across turns. For a fast, free, ephemeral, offline agent use wasm_agent_create (rvagent). Needs ANTHROPIC_API_KEY + Managed Agents beta access. Returns {sessionId, agentId, environmentId}; pair with managed_agent_prompt.',
129
+ category: 'agent',
130
+ inputSchema: {
131
+ type: 'object',
132
+ properties: {
133
+ name: { type: 'string', description: 'Agent name (default: auto)' },
134
+ model: { type: 'string', description: 'Model id (default: claude-sonnet-4-6)' },
135
+ system: { type: 'string', description: 'System prompt' },
136
+ title: { type: 'string', description: 'Session title' },
137
+ mcpServers: {
138
+ type: 'array',
139
+ description: 'MCP servers to expose to the agent — each {type:"url", url, name, authorization_token?}. NOTE: the cloud agent must be able to *reach* the URL (a local `ruflo mcp start` is not reachable from Anthropic\'s cloud — deploy/tunnel it).',
140
+ items: { type: 'object' },
141
+ },
142
+ skills: { type: 'array', description: 'Skills to attach to the agent', items: { type: 'object' } },
143
+ packages: { type: 'object', description: 'Environment packages: {pip?:[], npm?:[], apt?:[], cargo?:[], gem?:[], go?:[]}' },
144
+ networking: { type: 'string', enum: ['unrestricted', 'restricted', 'none'], description: 'Environment networking (default: unrestricted)' },
145
+ initScript: { type: 'string', description: 'Environment init script (bash, run at container start)' },
146
+ },
147
+ },
148
+ handler: async (input) => {
149
+ if (!apiKey())
150
+ return { success: false, ...NEEDS_KEY };
151
+ // 1. Agent
152
+ const agentBody = {
153
+ name: maName('ruflo-managed', input.name),
154
+ model: typeof input.model === 'string' && input.model ? input.model : DEFAULT_MODEL,
155
+ tools: [{ type: 'agent_toolset_20260401' }],
156
+ };
157
+ if (typeof input.system === 'string')
158
+ agentBody.system = input.system;
159
+ if (Array.isArray(input.mcpServers) && input.mcpServers.length)
160
+ agentBody.mcp_servers = input.mcpServers;
161
+ if (Array.isArray(input.skills) && input.skills.length)
162
+ agentBody.skills = input.skills;
163
+ const a = await maRequest('POST', '/agents', agentBody);
164
+ if (!a.ok)
165
+ return { success: false, stage: 'agent', error: a.error };
166
+ // 2. Environment
167
+ const net = input.networking || 'unrestricted';
168
+ const envBody = {
169
+ name: maName('ruflo-managed-env', input.name),
170
+ config: { type: 'cloud', networking: { type: net } },
171
+ };
172
+ if (input.packages && typeof input.packages === 'object')
173
+ envBody.config.packages = { type: 'packages', ...input.packages };
174
+ if (typeof input.initScript === 'string' && input.initScript)
175
+ envBody.config.init_script = input.initScript;
176
+ const e = await maRequest('POST', '/environments', envBody);
177
+ if (!e.ok)
178
+ return { success: false, stage: 'environment', agentId: a.data.id, error: e.error };
179
+ // 3. Session
180
+ const s = await maRequest('POST', '/sessions', {
181
+ agent: a.data.id,
182
+ environment_id: e.data.id,
183
+ title: maName('ruflo-managed session', input.title),
184
+ });
185
+ if (!s.ok)
186
+ return { success: false, stage: 'session', agentId: a.data.id, environmentId: e.data.id, error: s.error };
187
+ return {
188
+ success: true,
189
+ runtime: 'managed',
190
+ sessionId: s.data.id,
191
+ agentId: a.data.id,
192
+ agentVersion: a.data.version,
193
+ environmentId: e.data.id,
194
+ status: s.data.status ?? 'idle',
195
+ model: agentBody.model,
196
+ note: 'Cloud agent provisioned. Send work with managed_agent_prompt({sessionId, message}); inspect with managed_agent_events; clean up with managed_agent_terminate (it bills container time + tokens until you do).',
197
+ };
198
+ },
199
+ },
200
+ {
201
+ name: 'managed_agent_prompt',
202
+ description: 'Send a user turn to a managed cloud-agent session and wait for it to go idle, returning the assistant text + a tool-use trace — the CLOUD counterpart of wasm_agent_prompt. Use when wasm_agent_prompt (local WASM) is wrong because the work is long-running, needs the cloud container, or must persist across turns. Polls the session event log up to maxWaitMs (default 180s); for very long tasks raise maxWaitMs or follow up with managed_agent_events. Pair with managed_agent_create (for sessionId).',
203
+ category: 'agent',
204
+ inputSchema: {
205
+ type: 'object',
206
+ properties: {
207
+ sessionId: { type: 'string', description: 'Session id from managed_agent_create' },
208
+ message: { type: 'string', description: 'The user turn / task for the agent' },
209
+ maxWaitMs: { type: 'number', description: 'Max ms to wait for the session to go idle (default 180000, capped at 600000)' },
210
+ },
211
+ required: ['sessionId', 'message'],
212
+ },
213
+ handler: async (input) => {
214
+ if (!apiKey())
215
+ return { success: false, ...NEEDS_KEY };
216
+ const sessionId = String(input.sessionId ?? '');
217
+ const message = String(input.message ?? '');
218
+ if (!sessionId)
219
+ return { success: false, error: 'sessionId is required' };
220
+ if (!message)
221
+ return { success: false, error: 'message is required' };
222
+ const send = await maRequest('POST', `/sessions/${encodeURIComponent(sessionId)}/events`, {
223
+ events: [{ type: 'user.message', content: [{ type: 'text', text: message }] }],
224
+ });
225
+ if (!send.ok)
226
+ return { success: false, stage: 'send', sessionId, error: send.error };
227
+ const maxWait = typeof input.maxWaitMs === 'number' && input.maxWaitMs > 0 ? input.maxWaitMs : DEFAULT_MAX_WAIT_MS;
228
+ const { done, events } = await waitForIdle(sessionId, maxWait);
229
+ const sum = summarizeEvents(events);
230
+ return {
231
+ success: true,
232
+ runtime: 'managed',
233
+ sessionId,
234
+ finished: done,
235
+ status: sum.status,
236
+ stopReason: sum.stopReason,
237
+ assistantText: sum.assistantText,
238
+ toolUses: sum.toolUses,
239
+ eventCount: sum.eventCount,
240
+ note: done
241
+ ? undefined
242
+ : `Session still running after ${maxWait}ms — call managed_agent_events({sessionId}) to keep watching, or managed_agent_prompt again to steer.`,
243
+ };
244
+ },
245
+ },
246
+ {
247
+ name: 'managed_agent_status',
248
+ description: 'Get the lifecycle state of a managed cloud-agent session: idle/running/error, title, last error. Use when native conversation memory is wrong because you need the cloud session\'s server-side status across turns rather than guessing. For a local WASM agent use wasm_agent_list. Pair with managed_agent_events for the full transcript.',
249
+ category: 'agent',
250
+ inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Session id' } }, required: ['sessionId'] },
251
+ handler: async (input) => {
252
+ if (!apiKey())
253
+ return { ...NEEDS_KEY };
254
+ const sessionId = String(input.sessionId ?? '');
255
+ if (!sessionId)
256
+ return { error: 'sessionId is required' };
257
+ const r = await maRequest('GET', `/sessions/${encodeURIComponent(sessionId)}`);
258
+ if (!r.ok)
259
+ return { sessionId, error: r.error };
260
+ return { runtime: 'managed', sessionId: r.data.id, status: r.data.status, title: r.data.title, error: r.data.error ?? null, environmentId: r.data.environment_id };
261
+ },
262
+ },
263
+ {
264
+ name: 'managed_agent_events',
265
+ description: 'Fetch the full server-persisted event log of a managed cloud-agent session (user turns, agent thinking, tool_use, tool_result, status) — the transcript/artifact view, the CLOUD counterpart of wasm_agent_files. Use when native Read is wrong because the work happened in Anthropic\'s cloud container, not on disk. For a local WASM agent\'s filesystem use wasm_agent_files. Returns the events plus a summary (assistantText, toolUses).',
266
+ category: 'agent',
267
+ inputSchema: {
268
+ type: 'object',
269
+ properties: {
270
+ sessionId: { type: 'string', description: 'Session id' },
271
+ raw: { type: 'boolean', description: 'Include the full raw event objects (default: summary + compact list)' },
272
+ },
273
+ required: ['sessionId'],
274
+ },
275
+ handler: async (input) => {
276
+ if (!apiKey())
277
+ return { ...NEEDS_KEY };
278
+ const sessionId = String(input.sessionId ?? '');
279
+ if (!sessionId)
280
+ return { error: 'sessionId is required' };
281
+ const events = await fetchSessionEvents(sessionId);
282
+ const sum = summarizeEvents(events);
283
+ const compact = events.map(e => {
284
+ if (e.type === 'agent.message')
285
+ return { type: e.type, text: (e.content ?? []).filter(b => b.type === 'text').map(b => b.text ?? '').join('').slice(0, 500) };
286
+ if (e.type === 'agent.tool_use')
287
+ return { type: e.type, name: e.name, input: e.input };
288
+ if (e.type === 'agent.tool_result')
289
+ return { type: e.type, content: JSON.stringify(e.content ?? {}).slice(0, 500) };
290
+ return { type: e.type, ...(e.stop_reason ? { stop_reason: e.stop_reason } : {}) };
291
+ });
292
+ return {
293
+ runtime: 'managed',
294
+ sessionId,
295
+ status: sum.status,
296
+ stopReason: sum.stopReason,
297
+ assistantText: sum.assistantText,
298
+ toolUses: sum.toolUses,
299
+ eventCount: sum.eventCount,
300
+ events: input.raw ? events : compact,
301
+ };
302
+ },
303
+ },
304
+ {
305
+ name: 'managed_agent_list',
306
+ description: 'List managed cloud-agent sessions on this Anthropic org (id, status, title) — the CLOUD counterpart of wasm_agent_list. Use when native conversation memory is wrong because you need to see which cloud sessions exist (and which are still running / billing) across turns. For local WASM agents use wasm_agent_list. Pair with managed_agent_terminate to clean up idle sessions.',
307
+ category: 'agent',
308
+ inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Max sessions to return (default 50)' } } },
309
+ handler: async (input) => {
310
+ if (!apiKey())
311
+ return { ...NEEDS_KEY, sessions: [], total: 0 };
312
+ const limit = typeof input.limit === 'number' && input.limit > 0 ? Math.min(Math.floor(input.limit), 200) : 50;
313
+ const r = await maRequest('GET', `/sessions?limit=${limit}`);
314
+ if (!r.ok)
315
+ return { sessions: [], total: 0, error: r.error };
316
+ const list = (r.data.data ?? r.data.sessions ?? []);
317
+ return {
318
+ runtime: 'managed',
319
+ sessions: list.map(s => ({ sessionId: s.id, status: s.status, title: s.title, environmentId: s.environment_id })),
320
+ total: list.length,
321
+ };
322
+ },
323
+ },
324
+ {
325
+ name: 'managed_agent_terminate',
326
+ description: 'Delete a managed cloud-agent session (stops billing for it) — the CLOUD counterpart of wasm_agent_terminate. Use when native nothing applies because a cloud session keeps billing container time + tokens until deleted. For a local WASM agent use wasm_agent_terminate. Optionally also deletes the session\'s environment. Always call this when done with a managed agent.',
327
+ category: 'agent',
328
+ inputSchema: {
329
+ type: 'object',
330
+ properties: {
331
+ sessionId: { type: 'string', description: 'Session id to delete' },
332
+ environmentId: { type: 'string', description: 'Optional: also delete this environment (the one returned by managed_agent_create)' },
333
+ },
334
+ required: ['sessionId'],
335
+ },
336
+ handler: async (input) => {
337
+ if (!apiKey())
338
+ return { success: false, ...NEEDS_KEY };
339
+ const sessionId = String(input.sessionId ?? '');
340
+ if (!sessionId)
341
+ return { success: false, error: 'sessionId is required' };
342
+ const s = await maRequest('DELETE', `/sessions/${encodeURIComponent(sessionId)}`);
343
+ const result = { runtime: 'managed', sessionId, sessionDeleted: s.ok };
344
+ if (!s.ok)
345
+ result.error = s.error;
346
+ if (typeof input.environmentId === 'string' && input.environmentId) {
347
+ const e = await maRequest('DELETE', `/environments/${encodeURIComponent(String(input.environmentId))}`);
348
+ result.environmentDeleted = e.ok;
349
+ if (!e.ok)
350
+ result.environmentError = e.error;
351
+ }
352
+ result.success = s.ok;
353
+ return result;
354
+ },
355
+ },
356
+ ];
357
+ //# sourceMappingURL=managed-agent-tools.js.map
@@ -8,10 +8,13 @@ import type { PluginRegistry, KnownPluginRegistry, PluginStoreConfig } from './t
8
8
  * Default plugin store configuration
9
9
  */
10
10
  /**
11
- * Live IPFS Registry CID - Updated 2026-01-24
12
- * This is the current pinned registry on Pinata
11
+ * Live IPFS Registry CID - Updated 2026-05-11
12
+ * This is the current pinned registry on Pinata.
13
+ * 2026-05-11: bumped agentic-qe→3.0.0-alpha.5, gastown-bridge→0.1.4,
14
+ * legal-contracts/healthcare-clinical/perf-optimizer→3.0.0-alpha.2
15
+ * (republished to fix #1902/#1903/#1904 install breakage).
13
16
  */
14
- export declare const LIVE_REGISTRY_CID = "QmXbfEAaR7D2Ujm4GAkbwcGZQMHqAMpwDoje4583uNP834";
17
+ export declare const LIVE_REGISTRY_CID = "QmeXmAdbWVvT84GfDXPD2Vg1HWhiTW2VdZfRLhkS96KkX2";
15
18
  /**
16
19
  * Pre-trained Model Registry CID - Updated 2026-01-24
17
20
  * Contains 8 pre-trained learning pattern models with 40 patterns
@@ -37,10 +37,13 @@ async function fetchNpmStats(packageName) {
37
37
  * Default plugin store configuration
38
38
  */
39
39
  /**
40
- * Live IPFS Registry CID - Updated 2026-01-24
41
- * This is the current pinned registry on Pinata
40
+ * Live IPFS Registry CID - Updated 2026-05-11
41
+ * This is the current pinned registry on Pinata.
42
+ * 2026-05-11: bumped agentic-qe→3.0.0-alpha.5, gastown-bridge→0.1.4,
43
+ * legal-contracts/healthcare-clinical/perf-optimizer→3.0.0-alpha.2
44
+ * (republished to fix #1902/#1903/#1904 install breakage).
42
45
  */
43
- export const LIVE_REGISTRY_CID = 'QmXbfEAaR7D2Ujm4GAkbwcGZQMHqAMpwDoje4583uNP834';
46
+ export const LIVE_REGISTRY_CID = 'QmeXmAdbWVvT84GfDXPD2Vg1HWhiTW2VdZfRLhkS96KkX2';
44
47
  /**
45
48
  * Pre-trained Model Registry CID - Updated 2026-01-24
46
49
  * Contains 8 pre-trained learning pattern models with 40 patterns
@@ -538,7 +541,7 @@ export class PluginDiscoveryService {
538
541
  name: '@claude-flow/plugin-agentic-qe',
539
542
  displayName: 'Agentic Quality Engineering',
540
543
  description: 'AI-powered quality engineering with 58 agents that write tests, find bugs, predict defects, scan security, and perform chaos engineering safely.',
541
- version: '3.0.0-alpha.3',
544
+ version: '3.0.0-alpha.5',
542
545
  cid: 'bafybeiagenticqeplugin2024',
543
546
  size: 285000,
544
547
  checksum: 'sha256:agenticqe2024xyz',
@@ -656,7 +659,7 @@ export class PluginDiscoveryService {
656
659
  name: '@claude-flow/plugin-healthcare-clinical',
657
660
  displayName: 'Healthcare Clinical',
658
661
  description: 'HIPAA-compliant clinical workflow automation with patient data protection, medical terminology NLP, and healthcare interoperability standards.',
659
- version: '0.1.0',
662
+ version: '3.0.0-alpha.2',
660
663
  cid: 'bafybeihealthcareplugin2024',
661
664
  size: 210000,
662
665
  checksum: 'sha256:healthcare2024xyz',
@@ -714,7 +717,7 @@ export class PluginDiscoveryService {
714
717
  name: '@claude-flow/plugin-legal-contracts',
715
718
  displayName: 'Legal Contracts',
716
719
  description: 'Attorney-client privilege aware contract analysis with clause extraction, risk identification, and compliance checking.',
717
- version: '0.1.0',
720
+ version: '3.0.0-alpha.2',
718
721
  cid: 'bafybeilegalcontractsplugin2024',
719
722
  size: 175000,
720
723
  checksum: 'sha256:legalcontracts2024xyz',
@@ -802,7 +805,7 @@ export class PluginDiscoveryService {
802
805
  name: '@claude-flow/plugin-perf-optimizer',
803
806
  displayName: 'Performance Optimizer',
804
807
  description: 'AI-powered performance optimization with bottleneck detection, memory profiling, and automated performance tuning.',
805
- version: '0.1.0',
808
+ version: '3.0.0-alpha.2',
806
809
  cid: 'bafybeiperfoptimizerplugin2024',
807
810
  size: 225000,
808
811
  checksum: 'sha256:perfoptimizer2024xyz',
@@ -920,7 +923,7 @@ export class PluginDiscoveryService {
920
923
  name: '@claude-flow/plugin-gastown-bridge',
921
924
  displayName: 'Gas Town Bridge',
922
925
  description: 'Gas Town orchestrator integration with WASM-accelerated formula parsing, Beads sync, convoy management, and graph analysis (352x faster).',
923
- version: '0.1.0',
926
+ version: '0.1.4',
924
927
  cid: 'bafybeigastownbridgeplugin2024',
925
928
  size: 485000,
926
929
  checksum: 'sha256:gastownbridge2024xyz',
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.7.0-alpha.26",
3
+ "version": "3.7.0-alpha.27",
4
4
  "type": "module",
5
5
  "description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",