feat: add native Node.js RTK output filtering (FAR-66)
Replace the init-container RTK binary approach with a self-contained Node.js implementation. When `enableRtk: true` is set in adapter config, the job's main container startup: 1. Writes a Node.js filter script to /tmp/.rtk-filter.js (base64-encoded inline — no curl, no wget, no external binary download required). 2. Merges a PostToolUse hook into ~/.claude/settings.json so Claude Code runs the filter after every tool call. 3. The filter truncates tool_response/tool_result content that exceeds `rtkMaxOutputBytes` (default: 50 000 B), handling both string and array (text-block) content formats. New config fields: enableRtk toggle — off by default rtkMaxOutputBytes number — truncation threshold (default 50 000) 9 new tests cover: command shape, ordering, no-external-binary guarantee, threshold injection, PostToolUse hook presence, and filter-script logic. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -133,6 +133,21 @@ export function getConfigSchema(): AdapterConfigSchema {
|
||||
label: "Labels",
|
||||
hint: "Extra labels added to Job metadata. One key=value per line.",
|
||||
},
|
||||
// Output filtering (RTK-compatible)
|
||||
{
|
||||
type: "toggle",
|
||||
key: "enableRtk",
|
||||
label: "Enable Output Filtering",
|
||||
hint: "Truncate oversized tool outputs before they reach the model, reducing token consumption. Implemented natively in Node.js — no external binary required. Installs a PostToolUse hook in ~/.claude/settings.json for each run.",
|
||||
default: false,
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
key: "rtkMaxOutputBytes",
|
||||
label: "Max Tool Output Bytes",
|
||||
hint: "Maximum bytes of tool output to pass to the model when output filtering is enabled. Outputs exceeding this threshold are truncated with a summary. Default: 50000.",
|
||||
default: 50000,
|
||||
},
|
||||
];
|
||||
|
||||
return { fields };
|
||||
|
||||
Reference in New Issue
Block a user