🌊 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
feat(ruflo-agntcy): mod (guard/status/command) as function hooks, ADR-445 pattern
ruv6491aa206035
diff --git a/plugins/ruflo-agntcy/.claude-plugin/plugin.json b/plugins/ruflo-agntcy/.claude-plugin/plugin.jsonindex 9a7949df4f..b30ec6b6b7 100644--- a/plugins/ruflo-agntcy/.claude-plugin/plugin.json+++ b/plugins/ruflo-agntcy/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "ruflo-agntcy","description": "AGNTCY/Outshift Internet-of-Cognition runtime integration for Ruflo — SLIM secure transport for cross-host agent coordination, CASA intent-scoped tool authorization enforcement, optional IOC Layer 9 coordination events, and AGNTCY identity/observability spans (ADR-380). Optional, removable augmentation per ADR-150; degrades gracefully when AGNTCY/SLIM packages are not installed.",- "version": "0.1.0",+ "version": "0.2.0","author": {"name": "ruvnet","url": "https://github.com/ruvnet"@@ -22,6 +22,8 @@"mycelium","authorization","multi-agent",- "distributed"+ "distributed",+ "mod",+ "function-hooks"]}diff --git a/plugins/ruflo-agntcy/README.md b/plugins/ruflo-agntcy/README.mdindex 3c256ec31b..4fa00a078a 100644--- a/plugins/ruflo-agntcy/README.md+++ b/plugins/ruflo-agntcy/README.md@@ -51,3 +51,13 @@ This plugin's runtime half is paired with metaharness repo ADR-240 (build-time h- SLIM architecture — https://github.com/agntcy/slim- Cisco CASA overview — https://outshift.cisco.com/blog/ai-ml/continuous-agentic-semantic-authorization-for-mas- IOC protocol repository — https://github.com/outshift-open/ioc-protocols-models++## As a mod++AGNTCY also ships as a function-hook mod (ADR-445 pattern; hooks in `hooks/`, loaded with the plugin). No network, no process, no model call.++- **No guard**: this plugin owns no tool a guard could usefully screen, so the mod only reports status.+- **`/agntcy-mod`**: answered locally. `/agntcy-mod status`, `/agntcy-mod config`.+- **Status file**: `.claude-flow/agntcy-mod/status.json` (`version`, `updatedMs`, counters), written at session start; the console reads it.++Test: `claude plugin validate plugins/ruflo-agntcy`, `claude plugin test plugins/ruflo-agntcy` (this plugin also holds vitest files that `claude plugin test` cannot load; run it on a copy holding only `.claude-plugin`, `hooks` and `tests/mod.test.ts`), and `bash plugins/ruflo-agntcy/scripts/smoke.sh`.diff --git a/plugins/ruflo-agntcy/hooks/command.ts b/plugins/ruflo-agntcy/hooks/command.tsnew file mode 100644index 0000000000..25e23e1a11--- /dev/null+++ b/plugins/ruflo-agntcy/hooks/command.ts@@ -0,0 +1,21 @@+import type { ModOptions } from './options'+import type { Stats } from './status'++/** `/agntcy-mod` is answered locally and takes no model turn. */+export type CommandDeps = { readonly opts: ModOptions; readonly stats: Stats }++const HELP = ['/agntcy-mod status', '/agntcy-mod config'].join('\n')++export function answer(args: string, deps: CommandDeps): string {+ const [verb = ''] = args.trim().split(/\s+/)++ if (verb === '' || verb === 'help') return HELP++ if (verb === 'status') {+ return `AGNTCY mod active · no tool is guarded`+ }++ if (verb === 'config') return 'AGNTCY/SLIM/CASA integration is scaffolding (ADR-380): no upstream package is installed, transport is local, CASA enforcement is off. This mod makes no network call to AGNTCY infrastructure.'++ return `Unknown: ${verb}\n${HELP}`+}diff --git a/plugins/ruflo-agntcy/hooks/hooks.json b/plugins/ruflo-agntcy/hooks/hooks.jsonnew file mode 100644index 0000000000..0639da52c6--- /dev/null+++ b/plugins/ruflo-agntcy/hooks/hooks.json@@ -0,0 +1,6 @@+{+ "description": "AGNTCY as a mod (ADR-445 pattern): /agntcy-mod, and a status file the console reads.",+ "modules": [+ "./register.ts"+ ]+}diff --git a/plugins/ruflo-agntcy/hooks/options.ts b/plugins/ruflo-agntcy/hooks/options.tsnew file mode 100644index 0000000000..e841ce5c83--- /dev/null+++ b/plugins/ruflo-agntcy/hooks/options.ts@@ -0,0 +1,16 @@+import type { PluginOptions } from 'claude-code'++/** The plugin's `userConfig`, validated: a bad value is the default (guard absent). */+export type ModOptions = {+ readonly guard: boolean+}++const flag = (value: unknown, fallback: boolean) =>+ value === true || value === 'true' || value === 'on' ? true : value === false || value === 'false' || value === 'off' ? false : fallback++export function readOptions(options: PluginOptions | undefined): ModOptions {+ const o = options ?? {}+ return {+ guard: flag(o.guard, false),+ }+}diff --git a/plugins/ruflo-agntcy/hooks/register.ts b/plugins/ruflo-agntcy/hooks/register.tsnew file mode 100644index 0000000000..786e2bb2e8--- /dev/null+++ b/plugins/ruflo-agntcy/hooks/register.ts@@ -0,0 +1,44 @@+import type { Hook, Register } from 'claude-code'++import { answer } from './command'+import { readOptions } from './options'+import { newStats, STATUS_PATH, statusText, type Stats } from './status'+import type { ModOptions } from './options'++type Dollar = Parameters<Hook<'session.start'>>[0]++/** Everything one session of the mod keeps: its settings, counters and the project root. */+type Session = { readonly opts: ModOptions; readonly stats: Stats; root?: string }++async function flush($: Dollar, s: Session): Promise<void> {+ if (s.root === undefined) return+ try {+ await $.fs.write(`${s.root}/${STATUS_PATH}`, statusText(s.stats, s.opts, await $.clock.now()))+ } catch {+ /* the status file is a courtesy */+ }+}++/**+ * AGNTCY as a mod (ADR-445 pattern): `/agntcy-mod`, and a status file the console reads.+ * No network, no process: only the hooks API.+ */+export const register: Register = (on, options) => {+ const s: Session = { opts: readOptions(options), stats: newStats() }++ on('session.start', async ($, e, next) => {+ const result = await next(e)+ s.root = (await $.session.root()) as string | undefined+ s.stats.startedMs = await $.clock.now()+ try {+ await $.command.register({ name: 'agntcy-mod', description: 'AGNTCY mod: status, config' })+ } catch {+ /* a name taken by another plugin must not stop the mod */+ }+ await flush($, s)+ return result+ })++ /** `/agntcy-mod` (a markdown command of the plugin cannot be answered by a hook, so the mod owns this name). */+ on('command.run', { command: 'agntcy-mod' }, async (_$, e) => ({ text: answer(typeof e.args === 'string' ? e.args : '', { opts: s.opts, stats: s.stats }) }))+}diff --git a/plugins/ruflo-agntcy/hooks/screen.ts b/plugins/ruflo-agntcy/hooks/screen.tsnew file mode 100644index 0000000000..b3b107dbef--- /dev/null+++ b/plugins/ruflo-agntcy/hooks/screen.ts@@ -0,0 +1,50 @@+/**+ * Pure text screening for the AgentDB mod (ADR-445). Two jobs: find secrets (so none is stored) and find prompt-injection phrasing (so+ * retrieved memory cannot instruct the model). Findings are NAMES only: the matched text is never returned, logged or counted by value.+ */++const SECRETS: readonly (readonly [string, RegExp])[] = [+ ['private key', /-----BEGIN [A-Z ]*PRIVATE KEY-----/],+ ['aws access key', /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/],+ ['github token', /\b(?:gh[pousr]_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{40,})\b/],+ ['slack token', /\bxox[abprs]-[A-Za-z0-9-]{10,}/],+ ['google api key', /\bAIza[0-9A-Za-z_-]{35}\b/],+ ['anthropic or openai key', /\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{24,}/],+ ['jwt', /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/],+ ['bearer token', /\bBearer\s+[A-Za-z0-9._~+/=-]{24,}/],+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],+]++const INJECTION: readonly (readonly [string, RegExp])[] = [+ ['override instructions', /\b(?:ignore|disregard|forget|override)\b[^.\n]{0,40}\b(?:previous|prior|above|earlier|all|any|system)\b[^.\n]{0,30}\b(?:instructions?|rules?|prompts?|guidelines?)\b/i],+ ['role reassignment', /\byou are (?:now|no longer)\b|\bact as (?:an? )?(?:unrestricted|jailbroken)\b/i],+ ['new instructions', /\b(?:new|updated|real) (?:system )?instructions?\s*:/i],+ ['fake role tags', /<\/?\s*(?:system|assistant|developer|instructions?)\s*>|^\s*(?:system|assistant)\s*:/im],+ ['concealment', /\bdo not (?:tell|inform|mention|reveal)[^.\n]{0,30}\b(?:user|human|operator)\b/i],+ ['exfiltration', /\b(?:exfiltrate|send|post|upload)\b[^.\n]{0,50}\b(?:secrets?|credentials?|tokens?|api keys?|\.env)\b/i],+ ['shell pipe', /\b(?:curl|wget)\b[^|\n]{0,200}\|\s*(?:sudo\s+)?(?:ba|z)?sh\b/i],+]++// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.+const INVISIBLE = new RegExp('[\\u0000-\\u0008\\u000b-\\u001f\\u007f-\\u009f\\u200b-\\u200f\\u2028-\\u202e\\u2060-\\u2064\\ufeff]', 'g')++const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')++export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }++const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)++/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */+export function scan(text: string): Findings {+ const bounded = bare(text)+ return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }+}++export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0+++/** Makes stored text safe to show: no control or bidi characters, whitespace collapsed, at most `max` characters. */+export function tidy(text: string, max: number): string {+ const flat = text.replace(INVISIBLE, '').replace(/\s+/g, ' ').trim()+ return flat.length > max ? `${flat.slice(0, Math.max(0, max - 1))}…` : flat+}diff --git a/plugins/ruflo-agntcy/hooks/status.ts b/plugins/ruflo-agntcy/hooks/status.tsnew file mode 100644index 0000000000..b6ea432a83--- /dev/null+++ b/plugins/ruflo-agntcy/hooks/status.ts@@ -0,0 +1,11 @@+/** Counters the mod keeps for the session and writes to `.claude-flow/agntcy-mod/status.json` for the console. */+export type Stats = { calls: number; blocked: number; startedMs: number }++export const newStats = (): Stats => ({ calls: 0, blocked: 0, startedMs: 0 })++export const STATUS_PATH = '.claude-flow/agntcy-mod/status.json'++/** The file's text; `version` lets the console refuse a shape it does not know. */+export function statusText(stats: Stats, mode: { guard: boolean }, nowMs: number): string {+ return `${JSON.stringify({ version: 1, updatedMs: nowMs, mod: 'agntcy', guard: mode.guard, ...stats }, null, 2)}\n`+}diff --git a/plugins/ruflo-agntcy/scripts/smoke.sh b/plugins/ruflo-agntcy/scripts/smoke.shnew file mode 100755index 0000000000..1d2feb98db--- /dev/null+++ b/plugins/ruflo-agntcy/scripts/smoke.sh@@ -0,0 +1,38 @@+#!/usr/bin/env bash+# Structural smoke test for the ruflo-agntcy mod (ADR-445 pattern). Offline-safe.+set -u+ROOT="$(cd "$(dirname "$0")/.." && pwd)"+PASS=0+FAIL=0+step() { printf "→ %s ... " "$1"; }+ok() { printf "PASS\n"; PASS=$((PASS+1)); }+bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }++step "0. plugin.json declares 0.2.0"+v=$(grep -E '"version"' "$ROOT/.claude-plugin/plugin.json" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)+[[ "$v" == "0.2.0" ]] && ok || bad "expected 0.2.0, got '$v'"++# M1. The mod (ADR-445 pattern): hooks module registered, files within the 500-line rule+step "M1. mod: hooks.json names register.ts, every hook file is present and under 500 lines"+mod_ok=1+grep -q '"./register.ts"' "$ROOT/hooks/hooks.json" || mod_ok=0+for f in options screen command status register; do+ [[ -f "$ROOT/hooks/$f.ts" ]] || mod_ok=0+ [[ $(wc -l < "$ROOT/hooks/$f.ts" 2>/dev/null || echo 9999) -le 500 ]] || mod_ok=0+done+[[ $mod_ok -eq 1 ]] && ok || bad "mod hooks incomplete or too long"++step "M2. mod: userConfig defaults are safe"+node -e '+const c = require(process.argv[1]).userConfig || {}+process.exit(Object.values(c).every(o => o.default !== undefined) ? 0 : 1)+' "$ROOT/.claude-plugin/plugin.json" && ok || bad "userConfig defaults wrong"++step "M3. mod: hooks never touch the network or spawn a process"+if grep -nE '\$\.(http|process)\.|child_process|fetch\(' "$ROOT"/hooks/*.ts >/dev/null; then bad "network or process call in hooks"; else ok; fi++step "M4. mod: /agntcy-mod is registered and collides with no command or skill of the plugin"+if grep -q "name: 'agntcy-mod'" "$ROOT/hooks/register.ts" && [[ ! -e "$ROOT/commands/agntcy-mod.md" && ! -e "$ROOT/skills/agntcy-mod" ]]; then ok; else bad "command name missing or taken"; fi++printf "\n%s passed, %s failed\n" "$PASS" "$FAIL"+[[ $FAIL -eq 0 ]] || exit 1diff --git a/plugins/ruflo-agntcy/tests/mod.test.ts b/plugins/ruflo-agntcy/tests/mod.test.tsnew file mode 100644index 0000000000..39858bcd9e--- /dev/null+++ b/plugins/ruflo-agntcy/tests/mod.test.ts@@ -0,0 +1,59 @@+import type { On } from 'claude-code'+import { describe, expect, test, tier } from 'claude-code/testing'++import { readOptions } from '../hooks/options'++tier('user')++const ROOT = '/work'+const START = { surface: 'terminal', isInteractive: true, cwd: ROOT } as const+const slash = (args: string) => ({ command: 'agntcy-mod', args, origin: { kind: 'composer' }, presentation: { isFullscreen: false, columns: 100 } }) as const+const STATUS = `${ROOT}/.claude-flow/agntcy-mod/status.json`++// Built at run time so no secret-shaped literal sits in the source.+const ghp = `ghp_${'a1B2'.repeat(10)}`++/** The world beneath the mod: a project root, a file map, command registration and a clock. */+function world(on: On) {+ const files = new Map<string, string>()+ const commands: string[] = []+ on('session.start', ($, e) => ({ cwd: e.cwd }))+ on('session.root', () => ({ value: ROOT }))+ on('command.register', ($, e) => (commands.push(e.name), { value: { command: e.name } }))+ on('fs.write', ($, e) => (files.set(e.path, e.text), { value: undefined }))+ on('clock.now', () => ({ value: Date.now() }))+ return { files, commands }+}+const status = (files: Map<string, string>) => JSON.parse(files.get(STATUS) ?? '{}')++describe('defaults', () => {+ test('options: bad values fall back to the safe default', () => {+ expect(readOptions(undefined).guard).toBe(false)+ expect(readOptions({ guard: 'banana' }).guard).toBe(false)+ expect(readOptions({ guard: 'off' }).guard).toBe(false)+ })++ test('session start registers /agntcy-mod and writes the status file', async ($, on) => {+ const w = world(on)+ await $.session.start(START)+ expect(w.commands).toContain('agntcy-mod')+ expect(status(w.files)).toMatchObject({ version: 1, mod: 'agntcy', guard: false, blocked: 0 })+ expect(typeof status(w.files).updatedMs).toBe('number')+ })+})++describe('/agntcy-mod', () => {+ test('status answer locally', async ($, on) => {+ world(on)+ await $.session.start(START)+ expect((await $.command.run(slash('status'))).text).toContain('no tool is guarded')+ expect((await $.command.run(slash('config'))).text).toContain("scaffolding")+ })++ test('an unknown verb gets the help, not a model turn', async ($, on) => {+ world(on)+ await $.session.start(START)+ expect((await $.command.run(slash('what is this'))).text).toContain('/agntcy-mod status')+ expect((await $.command.run(slash(''))).text).toContain('/agntcy-mod status')+ })+})diff --git a/plugins/ruflo-agntcy/tsconfig.json b/plugins/ruflo-agntcy/tsconfig.jsonnew file mode 100644index 0000000000..e4ba54993e--- /dev/null+++ b/plugins/ruflo-agntcy/tsconfig.json@@ -0,0 +1,19 @@+{+ "//": "Self-contained on purpose: bundlers (vite/esbuild in the root CI vitest) load this file for every module they transform, so it must not extend a file that only exists after Claude Code (>= 2.1.287) has loaded the plugin. Claude Code writes its declarations to .claude-plugin/types/ (gitignored) on load or validate; tsc -p . then reads them through typeRoots.",+ "compilerOptions": {+ "target": "es2023",+ "lib": ["es2023"],+ "module": "esnext",+ "moduleResolution": "bundler",+ "strict": true,+ "noUncheckedIndexedAccess": true,+ "noEmit": true,+ "skipLibCheck": true,+ "jsx": "react",+ "jsxFactory": "h",+ "jsxFragmentFactory": "Fragment",+ "typeRoots": ["./.claude-plugin/types"],+ "types": ["claude-code", "claude-code-tools", "claude-code-mcp"]+ },+ "include": ["hooks", "tests"]+}