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

refactor(mods): one source for the secret screen — sync-mod-screen.mjs regenerates the shared region of 37 screen.ts copies, --check in all-plugins-smoke (ADR-445)

ruv71bf281bf0af
diff --git a/.github/workflows/all-plugins-smoke.yml b/.github/workflows/all-plugins-smoke.yml
index 19b515ea32..0dfe5bc2cb 100644
--- a/.github/workflows/all-plugins-smoke.yml
+++ b/.github/workflows/all-plugins-smoke.yml
@@ -18,12 +18,14 @@ on:
- 'plugins/**'
- 'scripts/smoke-all-plugins.mjs'
- 'scripts/audit-plugin-mcp-prefix.mjs'
+ - 'scripts/sync-mod-screen.mjs'
- '.github/workflows/all-plugins-smoke.yml'
pull_request:
paths:
- 'plugins/**'
- 'scripts/smoke-all-plugins.mjs'
- 'scripts/audit-plugin-mcp-prefix.mjs'
+ - 'scripts/sync-mod-screen.mjs'
- '.github/workflows/all-plugins-smoke.yml'
workflow_dispatch:
@@ -47,6 +49,11 @@ jobs:
# smoke while letting the metaharness fleet finish.
run: node scripts/smoke-all-plugins.mjs --timeout 300
+ - name: Mod secret screen — every copy matches the origin (ADR-445)
+ run: node scripts/sync-mod-screen.mjs --check
+ # Fails when any plugins/*/hooks/screen.ts drifted from plugins/ruflo-agentdb/hooks/screen.ts between the
+ # SHARED SCREEN markers, or when it finds no copies. Fix: node scripts/sync-mod-screen.mjs
+
- name: Fleet-wide exit-bypass antipattern lint (iter-75 bug class)
run: node scripts/audit-exit-bypass-antipattern.mjs
# Static analyzer: scans every plugins/*/scripts/*.mjs for the
diff --git a/plugins/ruflo-adr/hooks/screen.ts b/plugins/ruflo-adr/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-adr/hooks/screen.ts
+++ b/plugins/ruflo-adr/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-agent/hooks/screen.ts b/plugins/ruflo-agent/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-agent/hooks/screen.ts
+++ b/plugins/ruflo-agent/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-agentdb/hooks/screen.ts b/plugins/ruflo-agentdb/hooks/screen.ts
index b3b107dbef..f75f792820 100644
--- a/plugins/ruflo-agentdb/hooks/screen.ts
+++ b/plugins/ruflo-agentdb/hooks/screen.ts
@@ -1,9 +1,17 @@
/**
* 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.
+ *
+ * This file is the ORIGIN of the secret screen. Every plugin's hooks/screen.ts carries a copy of the region between the BEGIN and END markers,
+ * regenerated by `node scripts/sync-mod-screen.mjs` (and checked by `--check` in CI). Edit the shared region HERE only; anything outside the
+ * markers belongs to this plugin.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +20,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +32,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-agentdb/tests/screen.test.ts b/plugins/ruflo-agentdb/tests/screen.test.ts
index c7c862b802..c8caf88b55 100644
--- a/plugins/ruflo-agentdb/tests/screen.test.ts
+++ b/plugins/ruflo-agentdb/tests/screen.test.ts
@@ -36,6 +36,7 @@ describe('screen', () => {
test('tidy strips control and bidi characters and caps length', () => {
expect(tidy('a\u202eb\u0000c\n\n d', 50)).toBe('abc d')
expect(tidy('x'.repeat(100), 10)).toHaveLength(10)
+ expect(tidy('a\u200bb\u2028c', 50)).toBe('abc')
})
})
diff --git a/plugins/ruflo-agntcy/hooks/screen.ts b/plugins/ruflo-agntcy/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-agntcy/hooks/screen.ts
+++ b/plugins/ruflo-agntcy/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-ai-team/hooks/screen.ts b/plugins/ruflo-ai-team/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-ai-team/hooks/screen.ts
+++ b/plugins/ruflo-ai-team/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-aidefence/hooks/screen.ts b/plugins/ruflo-aidefence/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-aidefence/hooks/screen.ts
+++ b/plugins/ruflo-aidefence/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-arena/hooks/screen.ts b/plugins/ruflo-arena/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-arena/hooks/screen.ts
+++ b/plugins/ruflo-arena/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-autopilot/hooks/screen.ts b/plugins/ruflo-autopilot/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-autopilot/hooks/screen.ts
+++ b/plugins/ruflo-autopilot/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-bbs-federation/hooks/screen.ts b/plugins/ruflo-bbs-federation/hooks/screen.ts
index f0f4639ce9..2eb643ec3a 100644
--- a/plugins/ruflo-bbs-federation/hooks/screen.ts
+++ b/plugins/ruflo-bbs-federation/hooks/screen.ts
@@ -3,7 +3,11 @@
* Findings are NAMES only: the matched text is never returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,19 +16,54 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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,}/],
- ['nostr secret key', /\bnsec1[02-9ac-hj-np-z]{50,}/],
- ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
+
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
+ const bounded = bare(text)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
+}
+
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['nostr secret key', /\bnsec1[02-9ac-hj-np-z]{50,}/],
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => SECRETS.filter(([, re]) => re.test(bare(text))).map(([name]) => name)
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what the guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-browser/hooks/screen.ts b/plugins/ruflo-browser/hooks/screen.ts
index ade364356c..d56a5160a1 100644
--- a/plugins/ruflo-browser/hooks/screen.ts
+++ b/plugins/ruflo-browser/hooks/screen.ts
@@ -3,7 +3,11 @@
* Findings are NAMES only: the matched text is never returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,19 +16,54 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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,}/],
- ['nostr secret key', /\bnsec1[02-9ac-hj-np-z]{50,}/],
- ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
+
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
+ const bounded = bare(text)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
+}
+
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['nostr secret key', /\bnsec1[02-9ac-hj-np-z]{50,}/],
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => SECRETS.filter(([, re]) => re.test(bare(text))).map(([name]) => name)
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what the guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-business-pods/hooks/screen.ts b/plugins/ruflo-business-pods/hooks/screen.ts
index 069dbb8428..7a00619578 100644
--- a/plugins/ruflo-business-pods/hooks/screen.ts
+++ b/plugins/ruflo-business-pods/hooks/screen.ts
@@ -3,7 +3,11 @@
* Findings are NAMES only: the matched text is never returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,19 +16,54 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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,}/],
- ['nostr secret key', /\bnsec1[02-9ac-hj-np-z]{50,}/],
- ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
+
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
+ const bounded = bare(text)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
+}
+
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['nostr secret key', /\bnsec1[02-9ac-hj-np-z]{50,}/],
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => SECRETS.filter(([, re]) => re.test(bare(text))).map(([name]) => name)
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what the guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-chatgpt-federation/hooks/screen.ts b/plugins/ruflo-chatgpt-federation/hooks/screen.ts
index b91cbaa8a7..97d3b30dae 100644
--- a/plugins/ruflo-chatgpt-federation/hooks/screen.ts
+++ b/plugins/ruflo-chatgpt-federation/hooks/screen.ts
@@ -3,7 +3,11 @@
* Findings are NAMES only: the matched text is never returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,19 +16,54 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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,}/],
- ['nostr secret key', /\bnsec1[02-9ac-hj-np-z]{50,}/],
- ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
+
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
+ const bounded = bare(text)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
+}
+
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['nostr secret key', /\bnsec1[02-9ac-hj-np-z]{50,}/],
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => SECRETS.filter(([, re]) => re.test(bare(text))).map(([name]) => name)
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what the guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-daa/hooks/screen.ts b/plugins/ruflo-daa/hooks/screen.ts
index 14e017efed..c7122184d6 100644
--- a/plugins/ruflo-daa/hooks/screen.ts
+++ b/plugins/ruflo-daa/hooks/screen.ts
@@ -3,7 +3,11 @@
* matched text is never returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,21 +16,53 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
+]
+
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretNames = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretNames(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretNames = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what a guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-ddd/hooks/screen.ts b/plugins/ruflo-ddd/hooks/screen.ts
index 14e017efed..c7122184d6 100644
--- a/plugins/ruflo-ddd/hooks/screen.ts
+++ b/plugins/ruflo-ddd/hooks/screen.ts
@@ -3,7 +3,11 @@
* matched text is never returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,21 +16,53 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
+]
+
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretNames = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretNames(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretNames = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what a guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-deepseek-harness/hooks/screen.ts b/plugins/ruflo-deepseek-harness/hooks/screen.ts
index 14e017efed..c7122184d6 100644
--- a/plugins/ruflo-deepseek-harness/hooks/screen.ts
+++ b/plugins/ruflo-deepseek-harness/hooks/screen.ts
@@ -3,7 +3,11 @@
* matched text is never returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,21 +16,53 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
+]
+
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretNames = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretNames(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretNames = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what a guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-docs/hooks/screen.ts b/plugins/ruflo-docs/hooks/screen.ts
index 14e017efed..c7122184d6 100644
--- a/plugins/ruflo-docs/hooks/screen.ts
+++ b/plugins/ruflo-docs/hooks/screen.ts
@@ -3,7 +3,11 @@
* matched text is never returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,21 +16,53 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
+]
+
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretNames = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretNames(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretNames = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what a guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-federation/hooks/screen.ts b/plugins/ruflo-federation/hooks/screen.ts
index 14e017efed..c7122184d6 100644
--- a/plugins/ruflo-federation/hooks/screen.ts
+++ b/plugins/ruflo-federation/hooks/screen.ts
@@ -3,7 +3,11 @@
* matched text is never returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,21 +16,53 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
+]
+
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretNames = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretNames(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretNames = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what a guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-goals/hooks/screen.ts b/plugins/ruflo-goals/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-goals/hooks/screen.ts
+++ b/plugins/ruflo-goals/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-graph-intelligence/hooks/screen.ts b/plugins/ruflo-graph-intelligence/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-graph-intelligence/hooks/screen.ts
+++ b/plugins/ruflo-graph-intelligence/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-intelligence/hooks/screen.ts b/plugins/ruflo-intelligence/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-intelligence/hooks/screen.ts
+++ b/plugins/ruflo-intelligence/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-iot-cognitum/hooks/screen.ts b/plugins/ruflo-iot-cognitum/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-iot-cognitum/hooks/screen.ts
+++ b/plugins/ruflo-iot-cognitum/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-jujutsu/hooks/screen.ts b/plugins/ruflo-jujutsu/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-jujutsu/hooks/screen.ts
+++ b/plugins/ruflo-jujutsu/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-knowledge-graph/hooks/screen.ts b/plugins/ruflo-knowledge-graph/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-knowledge-graph/hooks/screen.ts
+++ b/plugins/ruflo-knowledge-graph/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-loop-workers/hooks/screen.ts b/plugins/ruflo-loop-workers/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-loop-workers/hooks/screen.ts
+++ b/plugins/ruflo-loop-workers/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-market-data/hooks/screen.ts b/plugins/ruflo-market-data/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-market-data/hooks/screen.ts
+++ b/plugins/ruflo-market-data/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-metaharness/hooks/screen.ts b/plugins/ruflo-metaharness/hooks/screen.ts
index b3b107dbef..44d44964a2 100644
--- a/plugins/ruflo-metaharness/hooks/screen.ts
+++ b/plugins/ruflo-metaharness/hooks/screen.ts
@@ -3,7 +3,11 @@
* 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])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,10 +16,9 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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])[] = [
+export const INJECTION: Rules = [
['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],
@@ -25,26 +28,37 @@ const INJECTION: readonly (readonly [string, RegExp])[] = [
['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.
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export 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[] }
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
-const names = (rules: readonly (readonly [string, RegExp])[], text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
-/** Names of every secret shape and injection phrase found in `text`. Cost is linear in the capped input. */
-export function scan(text: string): Findings {
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return { secrets: names(SECRETS, bounded), injection: names(INJECTION, bounded) }
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => names(SECRETS, bare(text)).length > 0
-
+export const hasSecretIn = (secrets: Rules, 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
}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+export const scan = (text: string): Findings => screenWith(SECRETS, text)
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-migrations/hooks/screen.ts b/plugins/ruflo-migrations/hooks/screen.ts
index df741eca9c..ac5c8585fa 100644
--- a/plugins/ruflo-migrations/hooks/screen.ts
+++ b/plugins/ruflo-migrations/hooks/screen.ts
@@ -3,7 +3,11 @@
* counted by value, so a deny reason cannot leak what it caught.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,22 +16,54 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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[A-Za-z0-9_-]*(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
- ['database url with password', /\b[a-z][a-z0-9+.-]{1,20}:\/\/[^\s:@/]+:[^\s@/]{3,}@[^\s/]+/i],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b[A-Za-z0-9_-]*(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+ ['database url with password', /\b[a-z][a-z0-9+.-]{1,20}:\/\/[^\s:@/]+:[^\s@/]{3,}@[^\s/]+/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what the guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-music/hooks/screen.ts b/plugins/ruflo-music/hooks/screen.ts
index 1fcad54e84..708ff4af27 100644
--- a/plugins/ruflo-music/hooks/screen.ts
+++ b/plugins/ruflo-music/hooks/screen.ts
@@ -3,7 +3,11 @@
* counted by value, so a deny reason cannot leak what it caught.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,21 +16,53 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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[A-Za-z0-9_-]*(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b[A-Za-z0-9_-]*(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what the guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-neural-trader/hooks/screen.ts b/plugins/ruflo-neural-trader/hooks/screen.ts
index 8a6552c2f1..26363d951e 100644
--- a/plugins/ruflo-neural-trader/hooks/screen.ts
+++ b/plugins/ruflo-neural-trader/hooks/screen.ts
@@ -3,7 +3,11 @@
* counted by value, so a deny reason cannot leak what it caught.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,21 +16,53 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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[A-Za-z0-9_-]*(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b[A-Za-z0-9_-]*(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what the guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-observability/hooks/screen.ts b/plugins/ruflo-observability/hooks/screen.ts
index 17d77d8d58..7e29007f11 100644
--- a/plugins/ruflo-observability/hooks/screen.ts
+++ b/plugins/ruflo-observability/hooks/screen.ts
@@ -3,7 +3,11 @@
* counted by value, so a deny reason cannot leak what it caught.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,23 +16,55 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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[A-Za-z0-9_-]*(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
- ['us ssn', /\b\d{3}-\d{2}-\d{4}\b/],
- ['payment card number', /\b\d{4}[ -]\d{4}[ -]\d{4}[ -]\d{4}\b/],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b[A-Za-z0-9_-]*(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+ ['us ssn', /\b\d{3}-\d{2}-\d{4}\b/],
+ ['payment card number', /\b\d{4}[ -]\d{4}[ -]\d{4}[ -]\d{4}\b/],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
/** Every string in a tool's input, to a bounded depth and size: what the guard reads. */
export function textsOf(input: unknown, budget = { left: 20_000 }, depth = 0): string[] {
diff --git a/plugins/ruflo-rag-memory/hooks/screen.ts b/plugins/ruflo-rag-memory/hooks/screen.ts
index 620c591de5..23355464bc 100644
--- a/plugins/ruflo-rag-memory/hooks/screen.ts
+++ b/plugins/ruflo-rag-memory/hooks/screen.ts
@@ -3,7 +3,11 @@
* returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,18 +16,50 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-ruvector/hooks/screen.ts b/plugins/ruflo-ruvector/hooks/screen.ts
index e75f5e115f..aba3641659 100644
--- a/plugins/ruflo-ruvector/hooks/screen.ts
+++ b/plugins/ruflo-ruvector/hooks/screen.ts
@@ -3,7 +3,11 @@
* returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,18 +16,50 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-ruvllm/hooks/screen.ts b/plugins/ruflo-ruvllm/hooks/screen.ts
index b547b9e5fd..270241a1ca 100644
--- a/plugins/ruflo-ruvllm/hooks/screen.ts
+++ b/plugins/ruflo-ruvllm/hooks/screen.ts
@@ -3,7 +3,11 @@
* returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,18 +16,50 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-rvf/hooks/screen.ts b/plugins/ruflo-rvf/hooks/screen.ts
index 7ca8cd8b5f..b34f61d860 100644
--- a/plugins/ruflo-rvf/hooks/screen.ts
+++ b/plugins/ruflo-rvf/hooks/screen.ts
@@ -3,7 +3,11 @@
* returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,18 +16,50 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-security-audit/hooks/screen.ts b/plugins/ruflo-security-audit/hooks/screen.ts
index 939fd1c424..fac26a9fbc 100644
--- a/plugins/ruflo-security-audit/hooks/screen.ts
+++ b/plugins/ruflo-security-audit/hooks/screen.ts
@@ -3,7 +3,11 @@
* returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,18 +16,50 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-sparc/hooks/screen.ts b/plugins/ruflo-sparc/hooks/screen.ts
index 0bc8f69b8d..d36ced2b33 100644
--- a/plugins/ruflo-sparc/hooks/screen.ts
+++ b/plugins/ruflo-sparc/hooks/screen.ts
@@ -3,7 +3,11 @@
* returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,18 +16,50 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-workflows/hooks/screen.ts b/plugins/ruflo-workflows/hooks/screen.ts
index 324cd0dd7b..9cccc515c7 100644
--- a/plugins/ruflo-workflows/hooks/screen.ts
+++ b/plugins/ruflo-workflows/hooks/screen.ts
@@ -3,7 +3,11 @@
* returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,18 +16,50 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-x-gateway/hooks/screen.ts b/plugins/ruflo-x-gateway/hooks/screen.ts
index 297038b9ed..734858376d 100644
--- a/plugins/ruflo-x-gateway/hooks/screen.ts
+++ b/plugins/ruflo-x-gateway/hooks/screen.ts
@@ -3,7 +3,11 @@
* returned, logged or counted by value.
*/
-const SECRETS: readonly (readonly [string, RegExp])[] = [
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
['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/],
@@ -12,18 +16,50 @@ const SECRETS: readonly (readonly [string, RegExp])[] = [
['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],
]
-// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters.
+export const INJECTION: Rules = [
+ ['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; built with escapes, never raw.
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, '')
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
-/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
-export const secretsIn = (text: string): string[] => {
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
const bounded = bare(text)
- return SECRETS.filter(([, re]) => re.test(bounded)).map(([name]) => name)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
}
-export const hasSecret = (text: string) => secretsIn(text).length > 0
+export const hasSecretIn = (secrets: Rules, 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
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** Names of every secret shape found in `text`. Cost is linear in the capped input. */
+export const secretsIn = (text: string): string[] => names(SECRETS, bare(text))
+
+export const hasSecret = (text: string) => hasSecretIn(SECRETS, text)
diff --git a/scripts/__tests__/sync-mod-screen.test.mjs b/scripts/__tests__/sync-mod-screen.test.mjs
new file mode 100644
index 0000000000..e557a666db
--- /dev/null
+++ b/scripts/__tests__/sync-mod-screen.test.mjs
@@ -0,0 +1,67 @@
+import { describe, expect, it, beforeEach, afterEach } from 'vitest';
+import { spawnSync } from 'node:child_process';
+import { cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+
+const script = join(__dirname, '..', 'sync-mod-screen.mjs');
+const repo = join(__dirname, '..', '..');
+
+let root;
+const run = (...args) => spawnSync('node', [script, '--root', root, ...args], { encoding: 'utf8' });
+const copy = name => join(root, 'plugins', name, 'hooks', 'screen.ts');
+
+beforeEach(() => {
+ root = mkdtempSync(join(tmpdir(), 'sync-screen-'));
+ for (const name of ['ruflo-agentdb', 'ruflo-daa', 'ruflo-music']) {
+ mkdirSync(join(root, 'plugins', name, 'hooks'), { recursive: true });
+ cpSync(join(repo, 'plugins', name, 'hooks', 'screen.ts'), copy(name));
+ }
+});
+afterEach(() => rmSync(root, { recursive: true, force: true }));
+
+describe('sync-mod-screen', () => {
+ it('passes on a tree whose copies match the origin', () => {
+ const r = run('--check');
+ expect(r.status).toBe(0);
+ expect(r.stdout).toContain('2 copies match');
+ });
+
+ it('fails --check when the shared region of a copy drifted, and write mode repairs it', () => {
+ writeFileSync(copy('ruflo-daa'), readFileSync(copy('ruflo-daa'), 'utf8').replace("['jwt',", "['jwt2',"));
+ const bad = run('--check');
+ expect(bad.status).toBe(1);
+ expect(bad.stderr).toContain('ruflo-daa');
+ expect(run().status).toBe(0);
+ expect(run('--check').status).toBe(0);
+ });
+
+ it('keeps per-plugin additions outside the markers when it rewrites', () => {
+ const src = readFileSync(copy('ruflo-music'), 'utf8');
+ writeFileSync(copy('ruflo-music'), src.replace("['jwt',", "['jwt2',"));
+ run();
+ const after = readFileSync(copy('ruflo-music'), 'utf8');
+ expect(after).toContain("['key assignment', /\\b[A-Za-z0-9_-]*(?:api");
+ expect(after).toBe(src);
+ });
+
+ it('fails a copy that lost its markers', () => {
+ writeFileSync(copy('ruflo-daa'), '// no markers here\n');
+ const r = run('--check');
+ expect(r.status).toBe(1);
+ expect(r.stderr).toContain('no single');
+ });
+
+ it('is loud when it finds no copies', () => {
+ rmSync(join(root, 'plugins', 'ruflo-daa'), { recursive: true });
+ rmSync(join(root, 'plugins', 'ruflo-music'), { recursive: true });
+ const r = run('--check');
+ expect(r.status).toBe(1);
+ expect(r.stderr).toContain('found 0 copies');
+ });
+
+ it('passes on the real repo', () => {
+ const r = spawnSync('node', [script, '--check'], { encoding: 'utf8' });
+ expect(r.status).toBe(0);
+ });
+});
diff --git a/scripts/sync-mod-screen.mjs b/scripts/sync-mod-screen.mjs
new file mode 100755
index 0000000000..72d3b90790
--- /dev/null
+++ b/scripts/sync-mod-screen.mjs
@@ -0,0 +1,64 @@
+#!/usr/bin/env node
+// One source for the mod secret screen (ADR-445). plugins/ruflo-agentdb/hooks/screen.ts is the origin; every other plugins/*/hooks/screen.ts
+// carries a copy of the region between the BEGIN and END markers. Anything outside the markers (extra patterns, helpers) stays per plugin.
+// node scripts/sync-mod-screen.mjs rewrite the shared region of every copy
+// node scripts/sync-mod-screen.mjs --check exit 1 when a copy drifted, lacks the markers, or when no copies are found
+// --root <dir> use <dir>/plugins instead of this repo (tests)
+import { readdirSync, readFileSync, writeFileSync, existsSync } from 'node:fs'
+import { dirname, join } from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const argRoot = process.argv.indexOf('--root')
+const ROOT = argRoot > 0 ? process.argv[argRoot + 1] : join(dirname(fileURLToPath(import.meta.url)), '..')
+const PLUGINS = join(ROOT, 'plugins')
+const ORIGIN = 'ruflo-agentdb'
+const BEGIN = '// BEGIN SHARED SCREEN'
+const END = '// END SHARED SCREEN'
+// Raw zero-width, bidi and line-separator characters must never sit in a regex literal (they are built from escapes).
+const RAW_INVISIBLE = new RegExp('[\\u2028\\u2029\\u200b-\\u200f\\u202a-\\u202e\\u2060-\\u2064\\ufeff]')
+
+/** Split into the text before the begin line, the region (begin line to end line inclusive), and the text after. */
+export function split(src) {
+ const lines = src.split('\n')
+ const b = lines.findIndex(l => l.startsWith(BEGIN))
+ const e = lines.findIndex((l, i) => i > b && l.trim() === END)
+ if (b < 0 || e < 0 || lines.slice(b + 1).some(l => l.startsWith(BEGIN))) return undefined
+ return { head: lines.slice(0, b).join('\n'), region: lines.slice(b, e + 1).join('\n'), tail: lines.slice(e + 1).join('\n') }
+}
+
+const mode = process.argv.includes('--check') ? 'check' : 'write'
+const fail = msg => {
+ console.error(`sync-mod-screen: ${msg}`)
+ process.exit(1)
+}
+
+const originPath = join(PLUGINS, ORIGIN, 'hooks', 'screen.ts')
+const origin = existsSync(originPath) ? split(readFileSync(originPath, 'utf8')) : undefined
+if (!origin) fail(`${originPath} is missing or has no single ${BEGIN} ... ${END} region`)
+if (RAW_INVISIBLE.test(origin.region)) fail('the shared region holds a raw zero-width, bidi or line-separator character; build it from escapes')
+
+const copies = readdirSync(PLUGINS)
+ .map(name => ({ name, path: join(PLUGINS, name, 'hooks', 'screen.ts') }))
+ .filter(c => c.name !== ORIGIN && existsSync(c.path))
+if (copies.length === 0) fail('found 0 copies of hooks/screen.ts besides the origin; the glob is wrong or the tree moved, so a clean result would mean nothing')
+
+const bad = []
+let changed = 0
+for (const c of copies) {
+ const src = readFileSync(c.path, 'utf8')
+ const parts = split(src)
+ if (!parts) {
+ bad.push(`${c.name}: no single ${BEGIN} ... ${END} region`)
+ continue
+ }
+ if (parts.region === origin.region) continue
+ if (mode === 'check') {
+ bad.push(`${c.name}: shared region drifted from ${ORIGIN} (run node scripts/sync-mod-screen.mjs)`)
+ continue
+ }
+ writeFileSync(c.path, [parts.head, origin.region, parts.tail].join('\n'))
+ changed++
+}
+
+if (bad.length) fail(`${bad.length} of ${copies.length} copies\n ${bad.join('\n ')}`)
+console.log(mode === 'check' ? `sync-mod-screen: ${copies.length} copies match ${ORIGIN}` : `sync-mod-screen: ${copies.length} copies checked, ${changed} rewritten`)