🌊 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
fix(ruflo-mods): keep main's Google-key and JWT matches when glued to a dash; no ^ at mid-line window starts (#3798)
Dragan Spiridonovc79f66e89f82
diff --git a/plugins/ruflo-mods/hooks/delivery/screen.ts b/plugins/ruflo-mods/hooks/delivery/screen.tsindex 0d8c8d1db8..107eb3990f 100644--- a/plugins/ruflo-mods/hooks/delivery/screen.ts+++ b/plugins/ruflo-mods/hooks/delivery/screen.ts@@ -1,4 +1,4 @@-import { anyWindow, scan, windows } from '../guidance/screen'+import { anyWindow, scanWindows, windows } from '../guidance/screen'/** Delivery origins that are the person's own or the lead's harness: never screened, so a screen cannot eat the user's prompt. */const TRUSTED_ORIGINS: ReadonlySet<string> = new Set(['bridge', 'coordinator', 'scheduled-trigger'])@@ -27,16 +27,17 @@ export const isScreenedOrigin = (kind: string) => !TRUSTED_ORIGINS.has(kind)* Names only: the matched text is never returned. In-process, no network, no model.*/export function screenInbound(text: string): string | undefined {- const shared = scan(text).injection[0]- if (shared) return shared- // The shared screen's windows: invisible characters cannot split a phrase past the peer rules, and padding cannot hide one.+ // The shared screen's windows, built once: invisible characters cannot split a phrase past the peer rules, and padding cannot hide one.const parts = windows(text)+ const shared = scanWindows(parts).injection[0]+ if (shared) return sharedreturn PEER_RULES.find(([, re]) => anyWindow(parts, re))?.[0]}/** Rule id of the first secret shape (or US social security number) in an outbound message, or undefined. */export function screenOutbound(text: string): string | undefined {- const found = scan(text)+ const parts = windows(text)+ const found = scanWindows(parts)if (found.secrets.length) return found.secrets[0]- return anyWindow(windows(text), SSN) ? 'us social security number' : undefined+ return anyWindow(parts, SSN) ? 'us social security number' : undefined}diff --git a/plugins/ruflo-mods/hooks/guidance/screen.ts b/plugins/ruflo-mods/hooks/guidance/screen.tsindex 148f5552f6..71dfbe9c03 100644--- a/plugins/ruflo-mods/hooks/guidance/screen.ts+++ b/plugins/ruflo-mods/hooks/guidance/screen.ts@@ -8,9 +8,10 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [['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', /\b(?:xox[abeprs]-|xapp-\d-)[A-Za-z0-9-]{10,}/],- ['google api key', /\bAIza[0-9A-Za-z_-]{35}(?![0-9A-Za-z_-])/],+ ['google api key', /\bAIza[0-9A-Za-z_-]{35}(?:\b|(?![0-9A-Za-z_-]))/],['anthropic or openai key', /\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{24,}/],- ['jwt', /(?<![A-Za-z0-9_-])eyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/],+ // One start per token run (linear on '-eyJ' repeats), at the first eyJ after a '-' or the run start.+ ['jwt', /(?<![A-Za-z0-9_-])(?=((?:[A-Za-z0-9_]*-)*?eyJ))\1[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,}/],// The keyword ends an _ or - separated name (GITHUB_TOKEN=, "client_secret":), optionally then _key / _access_key// (aws_secret_access_key =). Names that only start with it (TOKEN_URL=, MAX_TOKENS=) and all-digit values do not@@ -61,7 +62,9 @@ function cut(clean: string): string[] {// \b and ^ do not see a word cut in half; a long run without whitespace is covered by the overlap.const ws = start === 0 ? -1 : clean.slice(start, start + 256).search(/\s/)const from = ws >= 0 ? start + ws + 1 : start- out.push(clean.slice(from, start + WINDOW))+ // Mid-line, a window's first character is not a line start: a lead character keeps ^ from matching there.+ const lead = ws >= 0 && clean[from - 1] !== '\n' ? '\u0001' : ''+ out.push(lead + clean.slice(from, start + WINDOW))if (start + WINDOW >= clean.length) break}return out@@ -82,8 +85,10 @@ export type Findings = { readonly secrets: readonly string[]; readonly injectionconst names = (rules: readonly (readonly [string, RegExp])[], parts: readonly string[]) => rules.filter(([, re]) => anyWindow(parts, re)).map(([name]) => name)-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the input. */-export function scan(text: string): Findings {- const parts = windows(text)+/** Names of every secret shape and injection phrase in already-screened windows. */+export function scanWindows(parts: readonly string[]): Findings {return { secrets: names(SECRETS, parts), injection: names(INJECTION, parts) }}++/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the input. */+export const scan = (text: string): Findings => scanWindows(windows(text))diff --git a/plugins/ruflo-mods/tests/delivery.test.ts b/plugins/ruflo-mods/tests/delivery.test.tsindex e899bfd395..440918d5e1 100644--- a/plugins/ruflo-mods/tests/delivery.test.ts+++ b/plugins/ruflo-mods/tests/delivery.test.ts@@ -160,6 +160,18 @@ describe('screen coverage: prefixed keys, padding, invisible characters, more sefor (const t of ['x\u00adAKIAIOSFODNN7EXAMPLE', 'AKIAIOSFODNN7EXAMPLE\u2460', 'ssn a\u200b123-45-6789', 'my--token=abcdefghijklmnopqrstu']) expect(screenOutbound(t), JSON.stringify(t)).toBeTruthy()})+ test('secrets main caught stay caught when glued to a dash', () => {+ const key = 'AIza' + 'b'.repeat(35)+ for (const t of [`key=${key}-v2`, `${key}-prod`, `${key}--`]) expect(screenOutbound(t), t).toBe('google api key')+ const jwt = 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTYifQ.c2lnbmF0dXJlc2ln'+ for (const t of [`session-${jwt}`, `cookie=a-${jwt}`, `--${jwt}`]) expect(screenOutbound(t), t).toBe('jwt')+ })++ test('a mid-line "system:" at a window start is not a fake role tag', () => {+ const line = 'the system: ok and the assistant: fine '+ for (let pre = 0; pre < 60; pre += 7) expect(screenInbound('w'.repeat(pre) + line.repeat(1_600)), `${pre}`).toBeUndefined()+ })+test('CLI flag credentials are caught', () => {expect(screenOutbound('deploy --password=Sup3rS3cretPassw0rdxx')).toBe('key assignment')expect(screenOutbound('cli --token=abcdefghijklmnop0123456789')).toBe('key assignment')