Files
ruflo/package.json
T
Mathew BeaneandRuFlo 953d8d0018 feat: Grok Build host surface + host-agnostic team bus (ADR-402) (#3512)
* feat: Grok Build host surface + host-agnostic team bus (ADR-402)

Adds `ruflo init --grok` and nine team_* MCP tools. Together they let a
lead agent on Grok Build (or Codex, or Claude) run a named agent team
without Claude's SendMessage. The team state lives in the project under
.claude-flow/teams/.

Team bus (team_create, team_spawn, team_send, team_broadcast,
team_inbox, team_plan, team_status, team_on_stop, team_shutdown)
- One implementation: templates/grok/scripts/grok-team-bus.mjs (ops,
  CLI) plus grok-team-store.mjs (storage). The MCP tools import these
  files, the SubagentStop hook imports them, and init --grok copies
  them into a project as a CLI with no dependencies. The repo root has
  no second copy.
- Mail is scoped per team: teams/<team>/mailbox/<agent>/. team_inbox
  requires the team, and team_status counts only that team's mail.
- team.json updates take a cross-process lock (team.lock, an O_EXCL
  file holding an owner token) and are written through a temp file and
  a rename. A stale lock is broken by renaming it aside and checking
  the token, never by a blind delete, and release removes only the
  holder's own token. 30 concurrent spawns
  from separate processes register all 30.
- team_shutdown closes the team. After it, spawn, send, plan and
  on-stop refuse. team_spawn enforces maxAgents.
- A broadcast with no members is refused. priority is an integer from
  0 to 999, stored as a zero-padded filename prefix. Symlinked mailbox
  directories are refused. Concurrent drains claim each message by
  rename, so no message is delivered twice and no drain throws ENOENT.
- The spawn description is <role>:<agent>@<team>. The SubagentStop
  hook parses it to advance that team's plan. When the hook cannot
  record a team subagent, or the team is ambiguous, it writes the
  reason to stderr and exits 1.

init --grok
- Writes .grok/ (config, rules, four agent profiles, a skill, the
  SubagentStop hook), scripts/ and docs/grok/README.md in the project,
  and lists every path it wrote. --dry-run writes nothing.
- Pins the project MCP server to the running release (ruflo@<version>,
  which ships team_*) instead of @latest. From a source checkout it
  points at that checkout's bin/cli.js. Inserted values are escaped as
  TOML strings, so Windows paths are valid.
- Writes nothing outside the project unless --grok-statusline is
  passed. With the flag, it installs ~/.grok/ruflo/host-statusline.mjs
  and merges [ui.status_line] into ~/.grok/config.toml using
  @iarna/toml. The merge leaves an existing status row alone in any
  TOML form. It writes only when the re-parsed result keeps every
  other value, and otherwise prints the snippet to paste. The command
  is `node "<absolute path>"`, which needs no shell and runs no
  script from the repo.
- The status row expects only the agent-teams-grok skill.

Also classifies team_* in the capability brain (swarm-coordination)
and adds ADR-402.

Tests: __tests__/team-tools.test.ts, __tests__/grok-init.test.ts.

Co-Authored-By: RuFlo <ruv@ruv.net>

* fix(grok-host): address round-2 review of ADR-402 team bus (#3512)

N1 (blocking): root package.json "files" listed cli/dist but not
cli/templates, so npm pack (and npx claude-flow) shipped a build that
team_create / init --grok couldn't find grok-team-bus.mjs /
grok-team-store.mjs from. Added v3/@claude-flow/cli/templates/** and
verified with a real npm pack + tar extract (files present with the fix,
absent without it).

N2: breakStaleLock renamed a stale lock without re-checking it was still
the lock it first observed. A waiter that read a stale token could have
that exact lock broken by someone else and re-acquired fresh in between,
and the rename would steal that live lock out from under its holder,
opening a window for a fourth party to grab the vacated slot — two
holders at once. Now re-verifies token + mtime immediately before
renaming and backs off (no rename at all) if either changed. Added a
direct regression test (monkeypatched fs to force the exact interleaving)
plus a concurrent-CLI-process test with a pre-seeded stale lock.

N3: LOCK_WAIT_MS (10s) was shorter than LOCK_STALE_MS (30s), so any
acquire attempted in the ~20s gap between "waiter gives up" and "lock
considered stale" failed even with nothing actually stuck — and the
SubagentStop hook's own 5s command timeout couldn't survive either value.
Lowered stale/wait to 4s/4.5s (wait >= stale, both comfortably under the
hook's 5s budget with real critical sections being sub-millisecond JSON
r-m-w). Also replaced the synchronous Atomics.wait lock-wait loop with an
async setTimeout-based poll (sleepMsAsync), so an MCP server keeps serving
other requests while a caller waits for the lock; threaded async/await
through withTeamLock/createTeam/spawnMember/runCli/main and the
SubagentStop hook and team-tools.ts's dispatcher. sleepMs (sync) stays
only for writeJsonAtomic's bounded Windows rename retry.

Minor 1: --grok-statusline replaced a symlinked ~/.grok/config.toml with
a plain file, destroying the symlink. writeFileAtomic now resolves an
existing symlink and writes through it instead.

Minor 2: a TOML integer above 2^53 in the user's config parses to a
BigInt (@iarna/toml) and crashed JSON.stringify inside the status-line
merge, which ran as the LAST step of init — leaving project files already
written. Now validated up front, before any file is touched, naming the
offending key; init fails clean with nothing written instead of half-done.

Minor 3: host-statusline.mjs matched `trusted = true` / `[mcp_servers.x]`
via substring/regex, so a commented-out trusted=true read as trusted and
an `enabled = false` server still counted as loaded. Can't add a runtime
dependency on @iarna/toml here (this script ships as a zero-dependency
copy outside any node_modules tree — project scripts/ and
~/.grok/ruflo/host-statusline.mjs). Added a small comment-aware
table/key parser instead and used it for grok, and for codex's
mcp_servers check too (same bug class).

Minor 4: team_create --force reopened a team but left the old
incarnation's mailboxes on disk. Now clears mailbox/ when recreating.

Minor 5: priority accepted "1e2" and "0x10" (Number() coerces both).
Now requires a plain base-10 integer literal string.

Minor (stray changes): reverted an incidental .helpers-version bump and
a router.js mode change (644->755) picked up from a concurrent session's
helper auto-refresh — not part of this PR.

Verified: cli build + tsc --noEmit clean; grok-init.test.ts and
team-tools.test.ts (41 tests, including 8 new ones) and
guidance-brain.test.ts pass; full `npm test` for @claude-flow/cli is
green except 20 pre-existing failures across 16 files, all from
@claude-flow/memory / @claude-flow/mcp / @claude-flow/codex not being
built in this environment (none touch grok/team/statusline code).

Co-Authored-By: RuFlo <ruv@ruv.net>

* fix(grok-host): address round-3 review nits on the team lock and status line (#3512)

A lock whose holder pid is still alive is no longer broken after 4s, so a stalled writer does not lose an update. An existing [ui.status_line] no longer fails init when another value is a BigInt. Quoted trusted-folder keys may contain ].

Co-Authored-By: RuFlo <ruv@ruv.net>

* fix(grok-host): keep the TOML parser out of the MCP tool import path (#3512)

grokTemplatesRoot moves to init/grok-templates.ts, which has no
dependencies. The team_* tools import it from there, so loading the MCP
tool table no longer pulls in grok-generator and @iarna/toml. On current
main, analyze-json-output.test.ts runs the analyze command from a copied
source tree with only cli-core and security beside it, and failed 20 of
20 with "Cannot find package '@iarna/toml'" before this change.
grok-generator re-exports grokTemplatesRoot, so its callers are unchanged.

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: RuFlo <ruv@ruv.net>
2026-10-20 05:42:06 -04:00

229 lines
6.5 KiB
JSON

{
"name": "claude-flow",
"version": "3.58.1",
"workspaces": [
"v3/@claude-flow/codex",
"v3/@claude-flow/mcp",
"v3/@claude-flow/plugin-agent-federation",
"v3/@claude-flow/security"
],
"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",
"main": "dist/index.js",
"type": "module",
"bin": {
"claude-flow": "bin/cli.js"
},
"homepage": "https://github.com/ruvnet/claude-flow#readme",
"bugs": {
"url": "https://github.com/ruvnet/claude-flow/issues",
"email": "support@ruv.io"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ruvnet"
},
"files": [
"bin/**",
"v3/@claude-flow/cli/bin/**",
"v3/@claude-flow/cli/dist/**/*.js",
"v3/@claude-flow/cli/dist/**/*.d.ts",
"!v3/@claude-flow/cli/dist/**/*.map",
"v3/@claude-flow/cli/package.json",
"v3/@claude-flow/cli/catalog-manifest.json",
"v3/@claude-flow/cli/templates/**",
"v3/@claude-flow/shared/dist/**/*.js",
"v3/@claude-flow/shared/dist/**/*.d.ts",
"!v3/@claude-flow/shared/dist/**/*.map",
"v3/@claude-flow/shared/package.json",
"v3/@claude-flow/guidance/dist/**/*.js",
"v3/@claude-flow/guidance/dist/**/*.d.ts",
"!v3/@claude-flow/guidance/dist/**/*.map",
"v3/@claude-flow/guidance/package.json",
".claude-plugin/**",
".claude/**",
"!.claude/**/*.db",
"!.claude/**/*.map",
"!.claude/worktrees/**",
"!.claude/projects/**",
"!.claude/scheduled_tasks.lock",
"!.claude/sessions/**",
"README.md",
"LICENSE"
],
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsc",
"build:ts": "cd v3/@claude-flow/cli && npm run build || true",
"prepublishOnly": "node scripts/prepare-root-publish.mjs",
"test": "vitest",
"e2e": "node scripts/e2e/host-matrix.mjs",
"e2e:live": "RUFLO_E2E_LIVE=1 node scripts/e2e/host-matrix.mjs --live",
"test:ui": "vitest --ui",
"test:security": "vitest run v3/__tests__/security/",
"lint": "cd v3/@claude-flow/cli && npm run lint || true",
"security:audit": "npm audit --audit-level high",
"security:fix": "npm audit fix",
"security:test": "npm run test:security",
"v3:domains": "npm run build:domains",
"v3:swarm": "npm run start:swarm",
"v3:security": "npm run security:audit && npm run security:test"
},
"dependencies": {
"@claude-flow/cli-core": "3.7.5",
"@claude-flow/codex": "3.0.5",
"@claude-flow/mcp": "3.1.1",
"@claude-flow/neural": "3.0.0",
"@claude-flow/plugin-agent-federation": "1.0.1",
"@claude-flow/security": "3.0.5",
"@claude-flow/shared": "3.0.5",
"@iarna/toml": "^2.2.5",
"@noble/ed25519": "2.3.0",
"@ruvector/rabitq-wasm": "0.1.0",
"ajv": "^8.20.0",
"bcryptjs": "^3.0.3",
"chalk": "^5.3.0",
"commander": "^12.0.0",
"cors": "^2.8.5",
"fs-extra": "^11.2.0",
"express": ">=4.22.2",
"express-rate-limit": ">=8.4.1",
"fast-uri": "^3.1.6",
"helmet": "^7.2.0",
"inquirer": "^9.2.0",
"semver": "7.7.3",
"toml": "^3.0.0",
"ws": ">=8.21.0",
"yaml": "^2.8.0",
"zod": "3.25.76"
},
"optionalDependencies": {
"@napi-rs/keyring": "1.3.0",
"@claude-flow/plugin-gastown-bridge": "^0.1.3",
"@ruvector/attention": "^0.1.3",
"@ruvector/core": "^0.1.30",
"@ruvector/router": "^0.1.31",
"@ruvector/router-linux-x64-gnu": "^0.1.31",
"@ruvector/sona": "^0.1.5",
"agentdb": "^3.0.0-alpha.20",
"agentic-flow": "^2.0.14",
"better-sqlite3": "12.9.0"
},
"overrides": {
"ruvector": "^0.2.27",
"better-sqlite3": "12.9.0",
"js-yaml": ">=4.3.0",
"hono": ">=4.13.2",
"@ruvector/rvf-wasm": "0.1.5",
"@ruvector/rvf": "0.3.4",
"@hono/node-server": ">=2.1.1",
"flatted": ">=3.4.0",
"tar": ">=7.5.11",
"picomatch": ">=4.0.3",
"path-to-regexp": ">=8.2.1",
"undici": ">=8.10.0",
"minimatch": ">=10.0.0",
"@isaacs/brace-expansion": ">=5.0.1",
"cacache": ">=20.0.0",
"make-fetch-happen": ">=15.0.0",
"express-rate-limit": ">=8.4.1",
"express": ">=4.22.2",
"tinypool": ">=2.1.2",
"qs": ">=6.15.2",
"protobufjs": ">=8.7.2",
"uuid": ">=14.0.0",
"@opentelemetry/core": ">=2.8.0",
"@opentelemetry/resources": ">=2.8.0",
"@opentelemetry/sdk-trace-base": ">=2.8.0",
"@opentelemetry/sdk-node": ">=0.220.0",
"@opentelemetry/auto-instrumentations-node": ">=0.75.0",
"@opentelemetry/exporter-prometheus": ">=0.220.0",
"@opentelemetry/exporter-trace-otlp-grpc": ">=0.220.0",
"@opentelemetry/exporter-trace-otlp-http": ">=0.220.0",
"@opentelemetry/exporter-trace-otlp-proto": ">=0.220.0",
"@opentelemetry/otlp-exporter-base": ">=0.220.0",
"@opentelemetry/otlp-grpc-exporter-base": ">=0.220.0",
"@opentelemetry/otlp-transformer": ">=0.220.0",
"axios": ">=1.19.0",
"fast-uri": "$fast-uri",
"vite": ">=8.0.16",
"ws": ">=8.21.0",
"@grpc/grpc-js": ">=1.14.4",
"form-data": ">=4.0.6",
"http-proxy-middleware": ">=3.0.7",
"@ruvector/ruvllm": ">=2.6.0"
},
"devDependencies": {
"@openai/codex": "^0.98.0",
"@types/bcrypt": "^5.0.2",
"@types/node": "^20.0.0",
"esbuild": "^0.27.2",
"eslint": "^8.0.0",
"tsx": "^4.21.0",
"typescript": "^5.0.0",
"vitest": "^3.2.6"
},
"pnpm": {
"overrides": {
"better-sqlite3": "12.9.0"
}
},
"engines": {
"node": ">=20.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ruvnet/claude-flow.git"
},
"keywords": [
"ruvflow",
"claude",
"claude-code",
"anthropic",
"ai",
"ai-agents",
"multi-agent",
"agent-orchestration",
"swarm-intelligence",
"swarm",
"mcp",
"model-context-protocol",
"llm",
"large-language-model",
"gpt",
"chatgpt",
"automation",
"workflow",
"orchestration",
"cli",
"developer-tools",
"devtools",
"coding-assistant",
"code-generation",
"enterprise",
"vector-database",
"embeddings",
"machine-learning",
"neural-network",
"hive-mind",
"distributed-systems",
"consensus",
"self-learning"
],
"author": "RuvNet <ruv@ruv.io> (https://ruv.io)",
"license": "MIT",
"publishConfig": {
"access": "public",
"tag": "latest"
},
"bundleDependencies": [
"@claude-flow/codex",
"@claude-flow/mcp",
"@claude-flow/plugin-agent-federation",
"@claude-flow/security"
],
"directories": {
"doc": "docs",
"test": "tests"
}
}