Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/cli/args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ describe('parseArgs', () => {
expect(parsed.flags.get('text')).toBe('--help')
})

it('accepts a space-separated flag value starting with -- for --agent-args', () => {
const parsed = parseArgs([
'automations',
'create',
'--agent-args',
'--dangerously-skip-permissions'
])

expect(parsed.commandPath).toEqual(['automations', 'create'])
expect(parsed.flags.get('agent-args')).toBe('--dangerously-skip-permissions')
})

it('splits --flag=value on the first = so values may contain =', () => {
const parsed = parseArgs(['set', 'cookie', '--value=a=b=c'])

Expand Down
2 changes: 1 addition & 1 deletion src/cli/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function parseArgs(argv: string[], commandPaths?: readonly string[][]): P
}
const hasNext = i + 1 < argv.length
const next = argv[i + 1]
if (!hasNext || next.startsWith('--')) {
if (!hasNext || (next.startsWith('--') && flag !== 'agent-args')) {
flags.set(flag, true)
continue
}
Expand Down
8 changes: 8 additions & 0 deletions src/cli/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ describe('formatAutomationShow', () => {
prompt: 'Run checks',
precheck: null,
agentId: 'codex',
agentArgs: null,
projectId: 'repo-legacy',
executionTargetType: 'local',
executionTargetId: 'local',
Expand Down Expand Up @@ -227,6 +228,13 @@ describe('formatAutomationShow', () => {
expect(output).toContain('legacyRepoId: repo-legacy')
expect(output).not.toContain('projectId: repo-legacy')
})

it('shows agent args when set and none when unset', () => {
expect(formatAutomationShow({ automation: automation() })).toContain('agentArgs: none')
expect(
formatAutomationShow({ automation: automation({ agentArgs: '--yolo --verbose' }) })
).toContain('agentArgs: --yolo --verbose')
})
})

describe('formatTerminalList', () => {
Expand Down
13 changes: 13 additions & 0 deletions src/cli/handlers/automations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,17 @@ function getPrecheckFlag(
}
}

function getOptionalAgentArgsFlag(flags: Map<string, string | boolean>): string | null | undefined {
if (!flags.has('agent-args')) {
return undefined
}
const value = flags.get('agent-args')
if (typeof value !== 'string') {
throw new RuntimeClientError('invalid_argument', '--agent-args requires a value')
}
return value.trim() || null
}

function getSourceContextFlag(
flags: Map<string, string | boolean>
): TaskSourceContext | null | undefined {
Expand Down Expand Up @@ -457,6 +468,7 @@ export const AUTOMATION_HANDLERS: Record<string, CommandHandler> = {
timezone: getOptionalStringFlag(flags, 'timezone'),
enabled: getEnabledFlag(flags),
missedRunGraceMinutes: getOptionalPositiveIntegerFlag(flags, 'missed-run-grace-minutes'),
agentArgs: getOptionalAgentArgsFlag(flags),
...schedule
} satisfies AutomationCreateParams)
printResult(result, json, formatAutomationShow)
Expand All @@ -482,6 +494,7 @@ export const AUTOMATION_HANDLERS: Record<string, CommandHandler> = {
timezone: getOptionalStringFlag(flags, 'timezone'),
enabled: getEnabledFlag(flags),
missedRunGraceMinutes: getOptionalPositiveIntegerFlag(flags, 'missed-run-grace-minutes'),
agentArgs: getOptionalAgentArgsFlag(flags),
...schedule
} satisfies AutomationUpdateParams
})
Expand Down
9 changes: 6 additions & 3 deletions src/cli/specs/automations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const AUTOMATION_STATE_FLAGS = [
'disabled',
'missed-run-grace-minutes',
'reuse-session',
'fresh-session'
'fresh-session',
'agent-args'
]

export const AUTOMATION_COMMAND_SPECS: CommandSpec[] = [
Expand Down Expand Up @@ -60,12 +61,14 @@ export const AUTOMATION_COMMAND_SPECS: CommandSpec[] = [
'Use --source-context with a JSON TaskSourceContext when task/provider data should come from a specific host/account; pass null on edit to clear it.',
'Use --workspace to run in an existing worktree; otherwise the automation creates a new worktree per run.',
'Use --precheck to run a bounded command before scheduled runs; exit code 0 continues, anything else records a skipped run.',
'Use --reuse-session only with existing-workspace automations to submit later runs to the previous live automation session when it is still available. Use --fresh-session to disable reuse.'
'Use --reuse-session only with existing-workspace automations to submit later runs to the previous live automation session when it is still available. Use --fresh-session to disable reuse.',
'Use --agent-args to pass extra CLI flags to the agent launch command (e.g. "--yolo"). When omitted, the global agent default args apply.'
],
examples: [
'orca automations create --name "Daily review" --trigger daily --prompt "Review open changes" --provider codex',
'orca automations create --name "Weekday triage" --trigger "0 9 * * 1-5" --prompt "Triage issues" --provider claude --repo my-repo',
'orca automations create --name "PR review" --trigger hourly --precheck "gh pr list --json number -q .[0].number" --prompt "Review requested PRs" --provider codex'
'orca automations create --name "PR review" --trigger hourly --precheck "gh pr list --json number -q .[0].number" --prompt "Review requested PRs" --provider codex',
'orca automations create --name "Yolo check" --trigger daily --prompt "Check the repo" --provider claude --agent-args "--yolo"'
]
},
{
Expand Down
1 change: 1 addition & 0 deletions src/cli/workspace-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export function formatAutomationShow(result: { automation: Automation }): string
`id: ${automation.id}`,
`name: ${automation.name}`,
`provider: ${automation.agentId}`,
`agentArgs: ${automation.agentArgs?.trim() ? automation.agentArgs : 'none'}`,
`enabled: ${automation.enabled}`,
`schedule: ${formatAutomationSchedule(automation.rrule)}`,
`rrule: ${automation.rrule}`,
Expand Down
16 changes: 16 additions & 0 deletions src/main/automations/headless-workspace-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const automation: Automation = {
prompt: 'Review changes',
precheck: null,
agentId: 'codex',
agentArgs: null,
runContext: {
kind: 'workspace-run',
projectId: 'project-1',
Expand Down Expand Up @@ -73,6 +74,7 @@ describe('headless automation workspace create args', () => {
createdWithAgent: 'codex',
startupAgent: 'codex',
startupPrompt: 'Review changes',
agentArgs: undefined,
telemetrySource: 'unknown',
automationProvenance: {
kind: 'created-by-automation',
Expand All @@ -90,6 +92,20 @@ describe('headless automation workspace create args', () => {
})
})

it('threads agentArgs through if non-empty', () => {
const args = buildHeadlessAutomationWorktreeCreateArgs({
automation: { ...automation, agentArgs: '--dangerously-skip-permissions' },
run: {
id: 'run-1',
title: 'Nightly review run',
scheduledFor: Date.UTC(2026, 0, 2, 3, 4, 5)
},
repo
})

expect(args.agentArgs).toBe('--dangerously-skip-permissions')
})

it('falls back to skip for legacy automations without a saved setup decision', () => {
const args = buildHeadlessAutomationWorktreeCreateArgs({
automation: { ...automation, setupDecision: undefined },
Expand Down
1 change: 1 addition & 0 deletions src/main/automations/headless-workspace-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export function buildHeadlessAutomationWorktreeCreateArgs({
createdWithAgent: automation.agentId,
startupAgent: automation.agentId,
startupPrompt: automation.prompt,
agentArgs: automation.agentArgs ?? undefined,
telemetrySource: 'unknown',
automationProvenance: buildAutomationWorkspaceProvenance(automation, run, repo, createdAt)
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2783,7 +2783,8 @@ void app.whenReady().then(async () => {
{
agent: automation.agentId,
prompt: automation.prompt,
title: run.title
title: run.title,
agentArgs: automation.agentArgs
}
)
terminalHandle = terminal.handle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function createAutomation(
),
reuseSession: input.workspaceMode === 'existing' ? (input.reuseSession ?? false) : false,
timezone: input.timezone,
agentArgs: input.agentArgs ?? null,
rrule: input.rrule,
dtstart: input.dtstart,
enabled: input.enabled ?? true,
Expand Down
1 change: 1 addition & 0 deletions src/main/runtime/orca-runtime-automations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const existingAutomation = {
prompt: 'Review changes',
precheck: null,
agentId: 'codex',
agentArgs: null,
projectId: 'repo-1',
executionTargetType: 'local',
executionTargetId: 'local',
Expand Down
28 changes: 22 additions & 6 deletions src/main/runtime/orca-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4096,7 +4096,8 @@ export class OrcaRuntimeService {
rrule: input.rrule,
dtstart: input.dtstart,
enabled: input.enabled,
missedRunGraceMinutes: input.missedRunGraceMinutes
missedRunGraceMinutes: input.missedRunGraceMinutes,
agentArgs: input.agentArgs
})
}

Expand Down Expand Up @@ -4148,6 +4149,9 @@ export class OrcaRuntimeService {
if (hasRuntimeAutomationUpdateValue(updates, 'missedRunGraceMinutes')) {
patch.missedRunGraceMinutes = updates.missedRunGraceMinutes
}
if (hasRuntimeAutomationUpdateValue(updates, 'agentArgs')) {
patch.agentArgs = updates.agentArgs
}
const targetChanged =
hasRuntimeAutomationUpdateValue(updates, 'repo') ||
hasRuntimeAutomationUpdateValue(updates, 'workspace') ||
Expand Down Expand Up @@ -23792,7 +23796,8 @@ export class OrcaRuntimeService {
repo: Repo,
agent: TuiAgent,
prompt: string | undefined,
launchPreferences?: AgentLaunchPreferences
launchPreferences?: AgentLaunchPreferences,
agentArgs?: string | null
): { agent: TuiAgent; startup: WorktreeStartupLaunch; followup?: WorktreeStartupFollowup } {
if (!this.store) {
throw new Error('runtime_unavailable')
Expand All @@ -23815,7 +23820,10 @@ export class OrcaRuntimeService {
agent,
prompt: prompt ?? '',
cmdOverrides: settings.agentCmdOverrides ?? {},
agentArgs: resolveTuiAgentLaunchArgs(agent, settings.agentDefaultArgs),
agentArgs:
agentArgs !== undefined && agentArgs !== null && agentArgs.trim().length > 0
? agentArgs
: resolveTuiAgentLaunchArgs(agent, settings.agentDefaultArgs),
agentEnv: resolveTuiAgentLaunchEnv(agent, settings.agentDefaultEnv),
sessionOptions,
sessionOptionsOverrideAgentArgs: Boolean(sessionOptions),
Expand Down Expand Up @@ -24264,6 +24272,7 @@ export class OrcaRuntimeService {
createdWithAgent?: TuiAgent
startupAgent?: TuiAgent
startupLaunchPreferences?: AgentLaunchPreferences
agentArgs?: string | null
startupPrompt?: string
pendingFirstAgentMessageRename?: boolean
automationProvenance?: AutomationWorkspaceProvenance
Expand Down Expand Up @@ -24301,7 +24310,8 @@ export class OrcaRuntimeService {
repo,
args.startupAgent,
args.startupPrompt,
args.startupLaunchPreferences
args.startupLaunchPreferences,
args.agentArgs
)
: null
const draftStartup =
Expand Down Expand Up @@ -28601,14 +28611,20 @@ export class OrcaRuntimeService {

async launchAgentTerminal(
worktreeSelector: string,
opts: { agent: TuiAgent; prompt: string; title?: string }
opts: { agent: TuiAgent; prompt: string; title?: string; agentArgs?: string | null }
): Promise<RuntimeTerminalCreate> {
const worktree = await this.resolveWorktreeSelector(worktreeSelector)
const repo = this.store?.getRepo(worktree.repoId)
if (!repo) {
throw new Error('Repository for the selected workspace is no longer available.')
}
const startup = this.buildStartupForAgent(repo, opts.agent, opts.prompt)
const startup = this.buildStartupForAgent(
repo,
opts.agent,
opts.prompt,
undefined,
opts.agentArgs
)
if (repo.connectionId) {
await this.markRemoteWorkspaceTrustedForAgent(opts.agent, repo.connectionId, worktree.path)
} else {
Expand Down
6 changes: 4 additions & 2 deletions src/main/runtime/rpc/methods/automations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ const AutomationCreate = z.object({
rrule: AutomationSchedule,
dtstart: requiredNumber('Missing trigger start time'),
enabled: OptionalBoolean,
missedRunGraceMinutes: OptionalPositiveInt
missedRunGraceMinutes: OptionalPositiveInt,
agentArgs: OptionalNullablePlainString
})

const AutomationUpdateFields = z.object({
Expand All @@ -137,7 +138,8 @@ const AutomationUpdateFields = z.object({
rrule: AutomationSchedule.optional(),
dtstart: requiredNumber('Missing trigger start time').optional(),
enabled: OptionalBoolean,
missedRunGraceMinutes: OptionalPositiveInt
missedRunGraceMinutes: OptionalPositiveInt,
agentArgs: OptionalNullablePlainString
})

const AutomationUpdate = z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type AutomationDraft = {
name: string
prompt: string
agentId: TuiAgent
agentArgs: string
projectId: string
workspaceMode: AutomationWorkspaceMode
workspaceId: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,29 @@ export function AutomationEditorSettingsSidebar({
allowNarrowTrigger
/>
</Field>
<Field
labelClassName={AUTOMATION_EDITOR_SECTION_LABEL_CLASS}
label={translate(
'auto.components.automations.AutomationEditorDialog.9f1c2a4d88',
'Agent args'
)}
>
<input
value={draft.agentArgs}
onChange={(event) =>
onDraftChange((current) => ({ ...current, agentArgs: event.target.value }))
}
placeholder={translate(
'auto.components.automations.AutomationEditorDialog.7d5e8b3f01',
'e.g. --yolo'
)}
aria-label={translate(
'auto.components.automations.AutomationEditorDialog.2c4a9f6e01',
'Extra agent launch arguments'
)}
className="h-9 w-full min-w-0 rounded-md border border-input bg-input/30 px-3 text-sm shadow-xs outline-none focus-visible:border-ring dark:bg-input/30"
/>
</Field>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function makeAutomation(overrides: Partial<Automation> = {}): Automation {
baseBranch: null,
reuseSession: false,
timezone: 'America/Los_Angeles',
agentArgs: null,
rrule: 'FREQ=DAILY',
dtstart: 1,
enabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const BASE_DRAFT: AutomationDraft = {
name: '',
prompt: '',
agentId: 'codex',
agentArgs: '',
projectId: '',
workspaceMode: 'existing',
workspaceId: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const BASE_DRAFT: AutomationDraft = {
name: '',
prompt: '',
agentId: 'codex',
agentArgs: '',
projectId: '',
workspaceMode: 'existing',
workspaceId: '',
Expand Down
Loading