Self-learning is excluded from the community edition (ADR-0004); the project owner reworks it separately. Cost tracking stays. - agent: delete behaviour evolution (evolve-schema, iterative GEPA, compose-evolution, evolution gates, orchestrator and deploy), improvement and correction detection, AgentLearning, the eval-dataset builder, optimization-capture and the agent_insights tool. Secret detection moves from eval-dataset to secret-patterns. The LLM wiring keeps only the Haiku adapter and judge call used by skill audit and hygiene, so @ax-llm/ax is now declared by agent instead of server. - server: delete /api/evolution/*, the evolution and optimizer services, GEPA expansion of the first chat message, the prompt_optimization and monthly_assessment jobs, the idle-session reviewer and its session-reviewer persona, prompt injection of past corrections and thumbs-down recorded as correction signals. Existing job rows of the removed types are ignored, not deleted. - core: delete OptimizationLogStore; stop re-exporting the improvement signal and evolution run stores. - web: delete the Evolution screen and the two job types in the automation editor. - delete packages/optimizer. Also logs UF-027 (self-learning loops read data nothing collects) and UF-028 (the Settings prompt-shape choice is ignored by chat).
63 lines
2.2 KiB
TypeScript
63 lines
2.2 KiB
TypeScript
/**
|
|
* Pre-write redaction for authored skill content.
|
|
*
|
|
* The closed-learning-loop (create_skill / auto_extract_skills) and the UI both
|
|
* persist skill markdown to disk (~/.waggle/skills). That content can carry
|
|
* secrets (API keys / tokens) or machine-specific filesystem paths pulled from
|
|
* the model's context or the user's input. The loop's "strip secrets/paths"
|
|
* instruction was model-advisory only — this enforces it deterministically
|
|
* before every authored write.
|
|
*
|
|
* Secrets reuse the curated SECRET_PATTERNS via redactSecrets (single source of
|
|
* truth — see secret-patterns.ts). Paths cover the user's home directory (the exact
|
|
* running-user path plus generic per-OS forms), which both leaks the username
|
|
* and makes a skill non-portable.
|
|
*/
|
|
import os from 'node:os';
|
|
import { redactSecrets } from './secret-patterns.js';
|
|
|
|
// Generic user-home prefixes. Each matches up to (not including) the next path
|
|
// separator, so the tail is preserved: C:\Users\me\.waggle\x -> ~\.waggle\x
|
|
const HOME_PATH_PATTERNS: readonly RegExp[] = [
|
|
/[A-Za-z]:\\Users\\[^\\/:*?"<>|\r\n]+/g, // Windows
|
|
/\/(?:Users|home)\/[^\s/\\:*?"<>|]+/g, // macOS / Linux
|
|
];
|
|
|
|
export interface SkillRedactionResult {
|
|
content: string;
|
|
/** De-duplicated labels of what was stripped (secret pattern names + 'home-path'). */
|
|
redactions: string[];
|
|
}
|
|
|
|
/**
|
|
* Strip secrets and user-home paths from skill content before it is written to
|
|
* disk. Pure — returns a new string; never mutates input.
|
|
*/
|
|
export function redactSkillContent(content: string): SkillRedactionResult {
|
|
const sec = redactSecrets(content);
|
|
let out = sec.text;
|
|
const redactions = new Set(sec.found);
|
|
|
|
// Exact running-user home first (most precise; literal string match).
|
|
try {
|
|
const home = os.homedir();
|
|
if (home && out.includes(home)) {
|
|
out = out.split(home).join('~');
|
|
redactions.add('home-path');
|
|
}
|
|
} catch {
|
|
/* homedir unavailable — generic patterns below still apply */
|
|
}
|
|
|
|
// Generic home paths (content authored about other machines/users).
|
|
for (const re of HOME_PATH_PATTERNS) {
|
|
const replaced = out.replace(re, '~');
|
|
if (replaced !== out) {
|
|
out = replaced;
|
|
redactions.add('home-path');
|
|
}
|
|
}
|
|
|
|
return { content: out, redactions: [...redactions] };
|
|
}
|