Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

fix(plugin-agent-federation): #1949 β€” agentic-flow β†’ optional peer dep (drops [email protected] blocker) (#2013)

rUv455f0b17be2c
diff --git a/scripts/audit-fix-invariants.mjs b/scripts/audit-fix-invariants.mjs
index 4dcb67dbd0..f5efa09a57 100755
--- a/scripts/audit-fix-invariants.mjs
+++ b/scripts/audit-fix-invariants.mjs
@@ -238,6 +238,36 @@ const INVARIANTS = [
why: 'plugin.ts dispatches through the midstream-aware loader. Reverting to the bare loadQuicTransport import bypasses the ADR-120 preference layer entirely.',
},
+ // Issue #1949 β€” agentic-flow is an OPTIONAL peer dependency, not a
+ // hard runtime dep. Hardened npm registries that block the deep
+ // koa-router β†’ [email protected] transitive chain (under agentic-flow ->
+ // fastmcp -> mcp-proxy -> pipenet -> koa) can otherwise reject the
+ // plugin install with a 403 even on a clean checkout.
+ {
+ issue: '#1949',
+ file: 'v3/@claude-flow/plugin-agent-federation/package.json',
+ regex: /"peerDependencies"[\s\S]*?"agentic-flow"/,
+ why: 'agentic-flow must be a peer dependency (not a hard runtime dep) so hardened npm registries that block [email protected] transitively can still install the federation plugin (issue #1949).',
+ },
+ {
+ issue: '#1949',
+ file: 'v3/@claude-flow/plugin-agent-federation/package.json',
+ regex: /"peerDependenciesMeta"[\s\S]*?"agentic-flow"[\s\S]*?"optional"\s*:\s*true/,
+ why: 'agentic-flow must be marked optional in peerDependenciesMeta so npm doesn\'t warn or fail when the peer is missing (#1949).',
+ },
+ {
+ issue: '#1949',
+ file: 'v3/@claude-flow/plugin-agent-federation/src/transport/midstream-aware-loader.ts',
+ substring: "import type {",
+ why: 'midstream-aware-loader.ts must use TYPE-ONLY imports from agentic-flow (which are erased at compile time). Reverting to a static value import would force users to install agentic-flow even when only midstreamer is needed (#1949).',
+ },
+ {
+ issue: '#1949',
+ file: 'v3/@claude-flow/plugin-agent-federation/src/transport/midstream-aware-loader.ts',
+ substring: "loadAgenticFlowQuicTransport",
+ why: 'midstream-aware-loader.ts must lazy-load agentic-flow via loadAgenticFlowQuicTransport so it can degrade gracefully when the peer dep is absent (#1949).',
+ },
+
// ADR-120 Step 3 β€” ruflo-federation-peer Rust crate composes the
// QUIC transport (midstreamer-quic) with the AIMDS 3-gate pipeline.
{
diff --git a/v3/@claude-flow/plugin-agent-federation/package.json b/v3/@claude-flow/plugin-agent-federation/package.json
index 94643a048b..f6a95a59ec 100644
--- a/v3/@claude-flow/plugin-agent-federation/package.json
+++ b/v3/@claude-flow/plugin-agent-federation/package.json
@@ -1,6 +1,6 @@
{
"name": "@claude-flow/plugin-agent-federation",
- "version": "1.0.0-alpha.15",
+ "version": "1.0.0-alpha.16",
"description": "Cross-installation agent federation with zero-trust security, PII-gated data flow, and compliance-grade audit trails.",
"homepage": "https://github.com/ruvnet/ruflo",
"type": "module",
@@ -21,12 +21,24 @@
"clean": "rm -rf dist"
},
"dependencies": {
- "@noble/ed25519": "^2.0.0",
- "agentic-flow": "2.0.12-fix.8"
+ "@noble/ed25519": "^2.0.0"
+ },
+ "peerDependencies": {
+ "agentic-flow": ">=2.0.12-fix.8",
+ "midstreamer": ">=0.3.1"
+ },
+ "peerDependenciesMeta": {
+ "agentic-flow": {
+ "optional": true
+ },
+ "midstreamer": {
+ "optional": true
+ }
},
"devDependencies": {
"@claude-flow/shared": "workspace:*",
"@claude-flow/security": "workspace:*",
+ "agentic-flow": "2.0.12-fix.8",
"typescript": "^5.4.0",
"vitest": "^4.0.16"
},
diff --git a/v3/@claude-flow/plugin-agent-federation/src/transport/midstream-aware-loader.ts b/v3/@claude-flow/plugin-agent-federation/src/transport/midstream-aware-loader.ts
index 3995bd173a..4c750fec17 100644
--- a/v3/@claude-flow/plugin-agent-federation/src/transport/midstream-aware-loader.ts
+++ b/v3/@claude-flow/plugin-agent-federation/src/transport/midstream-aware-loader.ts
@@ -28,15 +28,64 @@
* surface from agentic-flow so consumers only import from one place.
*/
-import {
- loadQuicTransport,
- type AgentTransport,
- type AgentMessage,
- type QuicTransportConfig,
+// Type-only imports are erased at compile time β€” they do not force the
+// installation of `agentic-flow`. The value import (`loadQuicTransport`)
+// is now lazy via `loadAgenticFlowQuicTransport()` below so the
+// federation plugin can install + boot in environments that block the
+// koa transitive chain that agentic-flow pulls in (e.g. hardened npm
+// registries that block `[email protected]` per issue #1949).
+import type {
+ AgentTransport,
+ AgentMessage,
+ QuicTransportConfig,
} from 'agentic-flow/transport/loader';
export type { AgentTransport, AgentMessage, QuicTransportConfig };
+/**
+ * Lazy loader for agentic-flow's `loadQuicTransport`. Returns `null`
+ * when `agentic-flow` is not installed β€” callers must then fall back
+ * to the midstream-first path or surface a clear error.
+ *
+ * Per ADR-120 + issue #1949, `agentic-flow` is now an **optional**
+ * peer dependency. Operators who only want the midstream-native
+ * transport (via `MIDSTREAMER_QUIC_NATIVE=1`) can omit it to avoid
+ * the deep `koa-router` β†’ `[email protected]` transitive chain that
+ * hardened npm registries reject.
+ */
+async function loadAgenticFlowQuicTransport(
+ config?: QuicTransportConfig,
+): Promise<AgentTransport | null> {
+ // Direct dynamic `import()` (not the `new Function` trick) so
+ // test frameworks like vitest can intercept via `vi.mock`. The
+ // try/catch makes the module-not-found case a clean `null` so the
+ // caller falls back gracefully β€” agentic-flow is now an optional
+ // peer dependency.
+ let mod: {
+ loadQuicTransport?: (c?: QuicTransportConfig) => Promise<AgentTransport>;
+ default?: {
+ loadQuicTransport?: (c?: QuicTransportConfig) => Promise<AgentTransport>;
+ };
+ };
+ try {
+ mod = (await import('agentic-flow/transport/loader')) as typeof mod;
+ } catch {
+ return null;
+ }
+ const fn =
+ typeof mod.loadQuicTransport === 'function'
+ ? mod.loadQuicTransport
+ : mod.default?.loadQuicTransport;
+ if (typeof fn !== 'function') {
+ return null;
+ }
+ try {
+ return await fn(config);
+ } catch {
+ return null;
+ }
+}
+
/** Result envelope describing which backend the loader picked. */
export interface LoadedFederationTransport {
/** The live transport. Send/receive against this. */
@@ -160,7 +209,15 @@ export async function loadFederationTransport(
return { transport: probe.transport, source: 'midstreamer-native' };
}
- const transport = await loadQuicTransport(config);
+ const transport = await loadAgenticFlowQuicTransport(config);
+ if (!transport) {
+ throw new Error(
+ 'No federation transport available. Install `agentic-flow` ' +
+ '(default) or `midstreamer` and set `MIDSTREAMER_QUIC_NATIVE=1` ' +
+ '(per ADR-120). Both are now optional peer dependencies β€” at ' +
+ 'least one must be present at runtime.',
+ );
+ }
return {
transport,
source: 'agentic-flow-loader',