Skip to content

Commit c5ec6e1

Browse files
committed
refactor(engines): remove profile parameter from engine interfaces and executions
The profile parameter was redundant as the agentId is sufficient for authentication purposes. This simplifies the API surface and reduces unnecessary configuration options across all engine providers (Claude, Cursor, Codex) and their execution flows. Fixing json codex starting bug "can't find 'git-commit' profile"
1 parent c10796e commit c5ec6e1

File tree

14 files changed

+12
-59
lines changed

14 files changed

+12
-59
lines changed

src/agents/execution/runner.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ export interface ExecuteAgentOptions {
1818
*/
1919
model?: string;
2020

21-
/**
22-
* Engine profile to use (defaults to agentId)
23-
*/
24-
profile?: string;
2521

2622
/**
2723
* Working directory for execution
@@ -97,7 +93,7 @@ export async function executeAgent(
9793
prompt: string,
9894
options: ExecuteAgentOptions,
9995
): Promise<string> {
100-
const { workingDir, projectRoot, engine: engineOverride, model: modelOverride, profile: profileOverride, logger, stderrLogger, abortSignal, timeout } = options;
96+
const { workingDir, projectRoot, engine: engineOverride, model: modelOverride, logger, stderrLogger, abortSignal, timeout } = options;
10197

10298
// Load agent config to determine engine and model
10399
const agentConfig = await loadAgentConfig(agentId, projectRoot ?? workingDir);
@@ -136,10 +132,8 @@ export async function executeAgent(
136132
console.log(`ℹ️ No engine specified for agent '${agentId}', using ${foundEngine.metadata.name} (${engineType})`);
137133
}
138134

139-
const profile = profileOverride ?? agentId;
140-
141135
// Ensure authentication
142-
await ensureEngineAuth(engineType, profile);
136+
await ensureEngineAuth(engineType, agentId);
143137

144138
// Get engine module for defaults
145139
const engineModule = registry.get(engineType);
@@ -164,7 +158,6 @@ export async function executeAgent(
164158

165159
let totalStdout = '';
166160
const result = await engine.run({
167-
profile,
168161
prompt: compositePrompt,
169162
workingDir,
170163
model,

src/cli/commands/agent.command.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { Command } from 'commander';
33
import { executeAgent } from '../../agents/execution/index.js';
44

55
type AgentCommandOptions = {
6-
profile?: string;
76
model?: string;
87
};
98

@@ -21,7 +20,6 @@ async function registerMainAgentCommand(program: Command): Promise<void> {
2120
.description(`Execute agent with engine from config (defaults to ${defaultEngineName})`)
2221
.argument('<id>', 'Agent id from config/sub.agents.js or config/main.agents.js')
2322
.argument('<prompt...>', 'User request to send to the agent')
24-
.option('--profile <profile>', 'Engine profile to use (defaults to the agent id)')
2523
.option('--model <model>', 'Model to use (overrides agent config)')
2624
.action(async (id: string, promptParts: string[], options: AgentCommandOptions) => {
2725
const prompt = promptParts.join(' ').trim();
@@ -31,7 +29,6 @@ async function registerMainAgentCommand(program: Command): Promise<void> {
3129

3230
await executeAgent(id, prompt, {
3331
workingDir: process.cwd(),
34-
profile: options.profile,
3532
model: options.model,
3633
});
3734
});
@@ -54,7 +51,6 @@ function registerEngineAgentCommands(program: Command): void {
5451
.description(`Execute ${engine.metadata.name} with an agent wrapper`)
5552
.argument('<id>', 'Agent id from config/sub.agents.js or config/main.agents.js')
5653
.argument('<prompt...>', 'User request to send to the agent')
57-
.option('--profile <profile>', `${engine.metadata.name} profile to use (defaults to the agent id)`)
5854
.option('--model <model>', 'Model to use (overrides agent config)')
5955
.action(async (id: string, promptParts: string[], options: AgentCommandOptions) => {
6056
const prompt = promptParts.join(' ').trim();
@@ -65,7 +61,6 @@ function registerEngineAgentCommands(program: Command): void {
6561
await executeAgent(id, prompt, {
6662
engine: engine.metadata.id,
6763
workingDir: process.cwd(),
68-
profile: options.profile,
6964
model: options.model,
7065
});
7166
});

src/infra/engines/core/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
export type EngineType = string;
1010

1111
export interface EngineRunOptions {
12-
profile: string;
1312
prompt: string;
1413
workingDir: string;
1514
model?: string;

src/infra/engines/providers/claude/execution/commands.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export interface ClaudeCommandOptions {
2-
profile: string;
32
workingDir: string;
43
prompt: string;
54
model?: string;

src/infra/engines/providers/claude/execution/executor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export async function runClaudePrompt(options: {
2828
}
2929

3030
await runClaude({
31-
profile: options.agentId,
3231
prompt: options.prompt,
3332
workingDir: options.cwd,
3433
model: options.model,
@@ -79,7 +78,6 @@ export async function runAgent(
7978

8079
let buffered = '';
8180
const result = await runClaude({
82-
profile: agentId,
8381
prompt,
8482
workingDir: cwd,
8583
model: options.model,

src/infra/engines/providers/claude/execution/runner.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { expandHomeDir } from '../../../../../shared/utils/index.js';
88
import { logger } from '../../../../../shared/logging/index.js';
99

1010
export interface RunClaudeOptions {
11-
profile: string;
1211
prompt: string;
1312
workingDir: string;
1413
model?: string;
@@ -68,11 +67,7 @@ function formatStreamJsonLine(line: string): string | null {
6867
}
6968

7069
export async function runClaude(options: RunClaudeOptions): Promise<RunClaudeResult> {
71-
const { profile, prompt, workingDir, model, env, onData, onErrorData, abortSignal, timeout = 600000 } = options;
72-
73-
if (!profile) {
74-
throw new Error('runClaude requires a profile.');
75-
}
70+
const { prompt, workingDir, model, env, onData, onErrorData, abortSignal, timeout = 600000 } = options;
7671

7772
if (!prompt) {
7873
throw new Error('runClaude requires a prompt.');
@@ -82,7 +77,7 @@ export async function runClaude(options: RunClaudeOptions): Promise<RunClaudeRes
8277
throw new Error('runClaude requires a working directory.');
8378
}
8479

85-
// Set up CLAUDE_CONFIG_DIR (shared for authentication, profile is for agent data only)
80+
// Set up CLAUDE_CONFIG_DIR for authentication
8681
const claudeConfigDir = process.env.CLAUDE_CONFIG_DIR
8782
? expandHomeDir(process.env.CLAUDE_CONFIG_DIR)
8883
: path.join(homedir(), '.codemachine', 'claude');
@@ -120,7 +115,7 @@ export async function runClaude(options: RunClaudeOptions): Promise<RunClaudeRes
120115
return result;
121116
};
122117

123-
const { command, args } = buildClaudeExecCommand({ profile, workingDir, prompt, model });
118+
const { command, args } = buildClaudeExecCommand({ workingDir, prompt, model });
124119

125120
logger.debug(`Claude runner - prompt length: ${prompt.length}, lines: ${prompt.split('\n').length}`);
126121
logger.debug(`Claude runner - args count: ${args.length}, model: ${model ?? 'default'}`);

src/infra/engines/providers/codex/execution/commands.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export interface CodexCommandOptions {
2-
profile: string;
32
workingDir: string;
43
prompt: string;
54
model?: string;
@@ -12,13 +11,11 @@ export interface CodexCommand {
1211
}
1312

1413
export function buildCodexExecCommand(options: CodexCommandOptions): CodexCommand {
15-
const { profile, workingDir, model, modelReasoningEffort } = options;
14+
const { workingDir, model, modelReasoningEffort } = options;
1615

1716
const args = [
1817
'exec',
1918
'--json',
20-
'--profile',
21-
profile,
2219
'--skip-git-repo-check',
2320
'--sandbox',
2421
'danger-full-access',

src/infra/engines/providers/codex/execution/executor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export async function runCodexPrompt(options: {
2626
}
2727

2828
await runCodex({
29-
profile: options.agentId,
3029
prompt: options.prompt,
3130
workingDir: options.cwd,
3231
onData: (chunk) => {
@@ -76,7 +75,6 @@ export async function runAgent(
7675

7776
let buffered = '';
7877
const result = await runCodex({
79-
profile: agentId,
8078
prompt,
8179
workingDir: cwd,
8280
abortSignal: options.abortSignal,

src/infra/engines/providers/codex/execution/runner.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { expandHomeDir } from '../../../../../shared/utils/index.js';
88
import { logger } from '../../../../../shared/logging/index.js';
99

1010
export interface RunCodexOptions {
11-
profile: string;
1211
prompt: string;
1312
workingDir: string;
1413
model?: string;
@@ -79,11 +78,7 @@ function formatCodexStreamJsonLine(line: string): string | null {
7978
}
8079

8180
export async function runCodex(options: RunCodexOptions): Promise<RunCodexResult> {
82-
const { profile, prompt, workingDir, model, modelReasoningEffort, env, onData, onErrorData, abortSignal, timeout = 600000 } = options;
83-
84-
if (!profile) {
85-
throw new Error('runCodex requires a profile.');
86-
}
81+
const { prompt, workingDir, model, modelReasoningEffort, env, onData, onErrorData, abortSignal, timeout = 600000 } = options;
8782

8883
if (!prompt) {
8984
throw new Error('runCodex requires a prompt.');
@@ -96,7 +91,7 @@ export async function runCodex(options: RunCodexOptions): Promise<RunCodexResult
9691
// Prefer calling the real Codex CLI directly, mirroring runner-prompts spec
9792
// Example (Linux/Mac):
9893
// CODEX_HOME="$HOME/.codemachine/codex" codex exec \
99-
// --profile <profile> --skip-git-repo-check \
94+
// --skip-git-repo-check \
10095
// --sandbox danger-full-access --dangerously-bypass-approvals-and-sandbox \
10196
// -C <workingDir> "<composite prompt>"
10297

@@ -133,7 +128,7 @@ export async function runCodex(options: RunCodexOptions): Promise<RunCodexResult
133128
return result;
134129
};
135130

136-
const { command, args } = buildCodexExecCommand({ profile, workingDir, prompt, model, modelReasoningEffort });
131+
const { command, args } = buildCodexExecCommand({ workingDir, prompt, model, modelReasoningEffort });
137132

138133
logger.debug(`Codex runner - prompt length: ${prompt.length}, lines: ${prompt.split('\n').length}`);
139134
logger.debug(`Codex runner - args count: ${args.length}`);

src/infra/engines/providers/cursor/execution/commands.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export interface CursorCommandOptions {
2-
profile: string;
32
workingDir: string;
43
prompt: string;
54
model?: string;

0 commit comments

Comments
 (0)