From 26d72cfa5bbd7ea5d4a42dc7d5c4010ae5247711 Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Fri, 5 Dec 2025 16:43:08 -0500 Subject: [PATCH] feat(delegation): add passthrough args for claude cli flags Support passing through additional CLI flags like --agent, --system-prompt-file to the underlying Claude CLI when using delegation mode. --- src/delegation/delegation-handler.ts | 34 ++++++++++++++++++++++++++++ src/delegation/headless-executor.ts | 7 ++++++ 2 files changed, 41 insertions(+) diff --git a/src/delegation/delegation-handler.ts b/src/delegation/delegation-handler.ts index da245f6a..868b39cf 100644 --- a/src/delegation/delegation-handler.ts +++ b/src/delegation/delegation-handler.ts @@ -16,6 +16,7 @@ interface ParsedArgs { timeout?: number; resumeSession?: boolean; sessionId?: string; + extraArgs?: string[]; // Passthrough args for Claude CLI }; } @@ -185,6 +186,39 @@ export class DelegationHandler { options.timeout = parseInt(args[timeoutIndex + 1], 10); } + // Collect extra args to pass through to Claude CLI + // CCS-handled flags with values (skip these and their values): + const ccsFlagsWithValue = new Set(['-p', '--prompt', '--timeout', '--permission-mode']); + const extraArgs: string[] = []; + const profile = this._extractProfile(args); + + for (let i = 0; i < args.length; i++) { + const arg = args[i]; + + // Skip profile name (non-flag first arg) + if (arg === profile && !arg.startsWith('-')) continue; + + // Skip CCS-handled flags and their values + if (ccsFlagsWithValue.has(arg)) { + i++; // Skip next arg (the value) + continue; + } + + // Collect flags and their values as passthrough + if (arg.startsWith('-')) { + extraArgs.push(arg); + // If next arg exists and doesn't start with '-', it's likely a value + if (i + 1 < args.length && !args[i + 1].startsWith('-')) { + extraArgs.push(args[i + 1]); + i++; // Skip the value we just added + } + } + } + + if (extraArgs.length > 0) { + options.extraArgs = extraArgs; + } + return options; } diff --git a/src/delegation/headless-executor.ts b/src/delegation/headless-executor.ts index a9d723d2..0416f470 100644 --- a/src/delegation/headless-executor.ts +++ b/src/delegation/headless-executor.ts @@ -45,6 +45,7 @@ interface ExecutionOptions { resumeSession?: boolean; sessionId?: string; maxRetries?: number; + extraArgs?: string[]; // Passthrough args for Claude CLI } interface ExecutionResult { @@ -112,6 +113,7 @@ export class HeadlessExecutor { permissionMode = 'acceptEdits', resumeSession = false, sessionId = null, + extraArgs = [], } = options; // Validate permission mode @@ -210,6 +212,11 @@ export class HeadlessExecutor { // Note: No max-turns limit - using time-based limits instead (default 10min timeout) + // Passthrough extra args (from Claude CLI flags like --agent, --system-prompt-file, etc.) + if (extraArgs.length > 0) { + args.push(...extraArgs); + } + // Debug log args if (process.env.CCS_DEBUG) { console.error(`[i] Claude CLI args: ${args.join(' ')}`);