Add automation CLI commands (#2315)
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
+42
-1
@@ -3,6 +3,7 @@ import { RuntimeClientError } from './runtime-client'
|
||||
export type ParsedArgs = {
|
||||
commandPath: string[]
|
||||
flags: Map<string, string | boolean>
|
||||
positionalFlagConflicts?: string[]
|
||||
}
|
||||
|
||||
export type CommandSpec = {
|
||||
@@ -10,6 +11,7 @@ export type CommandSpec = {
|
||||
summary: string
|
||||
usage: string
|
||||
allowedFlags: string[]
|
||||
positionalArgs?: string[]
|
||||
examples?: string[]
|
||||
notes?: string[]
|
||||
}
|
||||
@@ -62,7 +64,9 @@ export function supportsBrowserPageFlag(commandPath: string[]): boolean {
|
||||
if (['open', 'status'].includes(commandPath[0])) {
|
||||
return false
|
||||
}
|
||||
if (['repo', 'worktree', 'terminal', 'computer', 'note'].includes(commandPath[0])) {
|
||||
if (
|
||||
['automations', 'repo', 'worktree', 'terminal', 'computer', 'note'].includes(commandPath[0])
|
||||
) {
|
||||
return false
|
||||
}
|
||||
return ![
|
||||
@@ -79,6 +83,7 @@ export function isCommandGroup(commandPath: string[]): boolean {
|
||||
return (
|
||||
(commandPath.length === 1 &&
|
||||
[
|
||||
'automations',
|
||||
'repo',
|
||||
'worktree',
|
||||
'terminal',
|
||||
@@ -101,6 +106,33 @@ export function isCommandGroup(commandPath: string[]): boolean {
|
||||
)
|
||||
}
|
||||
|
||||
export function normalizeCommandPositionals(specs: CommandSpec[], parsed: ParsedArgs): ParsedArgs {
|
||||
for (const spec of specs) {
|
||||
const positionalArgs = spec.positionalArgs ?? []
|
||||
if (positionalArgs.length === 0) {
|
||||
continue
|
||||
}
|
||||
if (parsed.commandPath.length !== spec.path.length + positionalArgs.length) {
|
||||
continue
|
||||
}
|
||||
if (!matches(parsed.commandPath.slice(0, spec.path.length), spec.path)) {
|
||||
continue
|
||||
}
|
||||
const flags = new Map(parsed.flags)
|
||||
const values = parsed.commandPath.slice(spec.path.length)
|
||||
// Why: validation runs inside main's error-reporting path, so normalization
|
||||
// records ambiguity instead of throwing before CLI errors can be formatted.
|
||||
const positionalFlagConflicts = positionalArgs.filter((name) => flags.has(name))
|
||||
positionalArgs.forEach((name, index) => {
|
||||
if (!flags.has(name)) {
|
||||
flags.set(name, values[index])
|
||||
}
|
||||
})
|
||||
return { commandPath: spec.path, flags, positionalFlagConflicts }
|
||||
}
|
||||
return parsed
|
||||
}
|
||||
|
||||
export function findCommandSpec(
|
||||
specs: CommandSpec[],
|
||||
commandPath: string[]
|
||||
@@ -117,6 +149,15 @@ export function validateCommandAndFlags(specs: CommandSpec[], parsed: ParsedArgs
|
||||
)
|
||||
}
|
||||
|
||||
if (parsed.positionalFlagConflicts && parsed.positionalFlagConflicts.length > 0) {
|
||||
throw new RuntimeClientError(
|
||||
'invalid_argument',
|
||||
`Pass ${parsed.positionalFlagConflicts
|
||||
.map((flag) => `--${flag}`)
|
||||
.join(', ')} either positionally or as a flag, not both.`
|
||||
)
|
||||
}
|
||||
|
||||
for (const flag of parsed.flags.keys()) {
|
||||
if (
|
||||
!spec.allowedFlags.includes(flag) &&
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { RuntimeClient } from './runtime-client'
|
||||
import { RuntimeClientError } from './runtime-client'
|
||||
import { CORE_HANDLERS } from './handlers/core'
|
||||
import { AUTOMATION_HANDLERS } from './handlers/automations'
|
||||
import { REPO_HANDLERS } from './handlers/repo'
|
||||
import { WORKTREE_HANDLERS } from './handlers/worktree'
|
||||
import { TERMINAL_HANDLERS } from './handlers/terminal'
|
||||
@@ -29,6 +30,7 @@ function buildHandlers(): Map<string, CommandHandler> {
|
||||
const table = new Map<string, CommandHandler>()
|
||||
const groups = [
|
||||
CORE_HANDLERS,
|
||||
AUTOMATION_HANDLERS,
|
||||
REPO_HANDLERS,
|
||||
WORKTREE_HANDLERS,
|
||||
TERMINAL_HANDLERS,
|
||||
|
||||
@@ -33,6 +33,8 @@ import type {
|
||||
RuntimeWorktreePsResult,
|
||||
RuntimeWorktreeRecord
|
||||
} from '../shared/runtime-types'
|
||||
import type { Automation, AutomationRun } from '../shared/automations-types'
|
||||
import { formatAutomationSchedule } from '../shared/automation-schedules'
|
||||
import type { PublicKnownRuntimeEnvironment } from '../shared/runtime-environments'
|
||||
import type { RuntimeRpcFailure, RuntimeRpcSuccess } from './runtime-client'
|
||||
import { RuntimeClientError, RuntimeRpcFailureError } from './runtime-client'
|
||||
@@ -282,6 +284,68 @@ export function formatWorktreeShow(result: { worktree: RuntimeWorktreeRecord }):
|
||||
.join('\n')
|
||||
}
|
||||
|
||||
export function formatAutomationList(result: { automations: Automation[] }): string {
|
||||
if (result.automations.length === 0) {
|
||||
return 'No automations found.'
|
||||
}
|
||||
return result.automations
|
||||
.map((automation) => {
|
||||
const status = automation.enabled ? 'enabled' : 'disabled'
|
||||
return `${automation.id} ${automation.name} ${automation.agentId} ${status}\n${formatAutomationSchedule(automation.rrule)} next: ${new Date(automation.nextRunAt).toISOString()}`
|
||||
})
|
||||
.join('\n\n')
|
||||
}
|
||||
|
||||
export function formatAutomationShow(result: { automation: Automation }): string {
|
||||
const automation = result.automation
|
||||
return [
|
||||
`id: ${automation.id}`,
|
||||
`name: ${automation.name}`,
|
||||
`provider: ${automation.agentId}`,
|
||||
`enabled: ${automation.enabled}`,
|
||||
`schedule: ${formatAutomationSchedule(automation.rrule)}`,
|
||||
`rrule: ${automation.rrule}`,
|
||||
`nextRunAt: ${new Date(automation.nextRunAt).toISOString()}`,
|
||||
`projectId: ${automation.projectId}`,
|
||||
`workspaceMode: ${automation.workspaceMode}`,
|
||||
`workspaceId: ${automation.workspaceId ?? 'null'}`,
|
||||
`baseBranch: ${automation.baseBranch ?? 'null'}`,
|
||||
`target: ${automation.executionTargetType}:${automation.executionTargetId}`,
|
||||
`prompt: ${automation.prompt}`
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
export function formatAutomationRemoved(result: { removed: boolean; id: string }): string {
|
||||
return result.removed
|
||||
? `Removed automation ${result.id}.`
|
||||
: `Automation ${result.id} not removed.`
|
||||
}
|
||||
|
||||
export function formatAutomationRun(result: { run: AutomationRun }): string {
|
||||
return [
|
||||
`id: ${result.run.id}`,
|
||||
`automationId: ${result.run.automationId}`,
|
||||
`title: ${result.run.title}`,
|
||||
`status: ${result.run.status}`,
|
||||
`trigger: ${result.run.trigger}`,
|
||||
`scheduledFor: ${new Date(result.run.scheduledFor).toISOString()}`,
|
||||
`workspaceId: ${result.run.workspaceId ?? 'null'}`,
|
||||
`error: ${result.run.error ?? 'null'}`
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
export function formatAutomationRuns(result: { runs: AutomationRun[] }): string {
|
||||
if (result.runs.length === 0) {
|
||||
return 'No automation runs found.'
|
||||
}
|
||||
return result.runs
|
||||
.map(
|
||||
(run) =>
|
||||
`${run.id} ${run.automationId} ${run.status} ${run.trigger} ${new Date(run.scheduledFor).toISOString()}\n${run.title}${run.error ? `\nerror: ${run.error}` : ''}`
|
||||
)
|
||||
.join('\n\n')
|
||||
}
|
||||
|
||||
export function formatSnapshot(result: BrowserSnapshotResult): string {
|
||||
const header = `page: ${result.browserPageId}\n${result.title} — ${result.url}\n`
|
||||
return header + result.snapshot
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
/* eslint-disable max-lines -- Why: automation handlers share schedule parsing, target resolution, and RPC payload shaping for one command family. */
|
||||
import type {
|
||||
Automation,
|
||||
AutomationCreateInput,
|
||||
AutomationRun,
|
||||
AutomationSchedulePreset,
|
||||
AutomationUpdateInput
|
||||
} from '../../shared/automations-types'
|
||||
import type { TuiAgent } from '../../shared/types'
|
||||
import { buildAutomationRrule, isValidAutomationSchedule } from '../../shared/automation-schedules'
|
||||
import { isTuiAgent } from '../../shared/tui-agent-config'
|
||||
import type { CommandHandler } from '../dispatch'
|
||||
import {
|
||||
formatAutomationList,
|
||||
formatAutomationRemoved,
|
||||
formatAutomationRun,
|
||||
formatAutomationRuns,
|
||||
formatAutomationShow,
|
||||
printResult
|
||||
} from '../format'
|
||||
import {
|
||||
getOptionalPositiveIntegerFlag,
|
||||
getOptionalStringFlag,
|
||||
getRequiredStringFlag
|
||||
} from '../flags'
|
||||
import { RuntimeClientError } from '../runtime-client'
|
||||
import { getOptionalWorktreeSelector, resolveCurrentWorktreeSelector } from '../selectors'
|
||||
|
||||
type AutomationCreateParams = Omit<AutomationCreateInput, 'projectId' | 'timezone'> & {
|
||||
repo?: string
|
||||
timezone?: string
|
||||
workspace?: string
|
||||
}
|
||||
|
||||
type AutomationUpdateParams = AutomationUpdateInput & {
|
||||
repo?: string
|
||||
workspace?: string
|
||||
}
|
||||
|
||||
const PRESET_TRIGGERS = new Set<AutomationSchedulePreset>(['hourly', 'daily', 'weekdays', 'weekly'])
|
||||
const SCHEDULE_MODIFIER_FLAGS = ['day', 'time'] as const
|
||||
|
||||
function getScheduleModifierFlag(flags: Map<string, string | boolean>): string | undefined {
|
||||
return SCHEDULE_MODIFIER_FLAGS.find((flag) => flags.has(flag))
|
||||
}
|
||||
|
||||
function validateScheduleModifierApplicability(
|
||||
flags: Map<string, string | boolean>,
|
||||
raw: string
|
||||
): void {
|
||||
const isPreset = PRESET_TRIGGERS.has(raw as AutomationSchedulePreset)
|
||||
if (!isPreset) {
|
||||
if (flags.has('time')) {
|
||||
throw new RuntimeClientError(
|
||||
'invalid_argument',
|
||||
'--time can only be used with preset automation triggers'
|
||||
)
|
||||
}
|
||||
if (flags.has('day')) {
|
||||
throw new RuntimeClientError(
|
||||
'invalid_argument',
|
||||
'--day can only be used with the weekly automation preset'
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
if (raw === 'hourly' && flags.has('time')) {
|
||||
throw new RuntimeClientError(
|
||||
'invalid_argument',
|
||||
'--time cannot be used with the hourly automation preset; use a cron trigger such as "30 * * * *" to choose the minute'
|
||||
)
|
||||
}
|
||||
if (raw !== 'weekly' && flags.has('day')) {
|
||||
throw new RuntimeClientError(
|
||||
'invalid_argument',
|
||||
'--day can only be used with the weekly automation preset'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function getOptionalDayFlag(flags: Map<string, string | boolean>): number | undefined {
|
||||
const raw = flags.get('day')
|
||||
if (raw === undefined) {
|
||||
return undefined
|
||||
}
|
||||
const day = typeof raw === 'string' && /^\d+$/.test(raw) ? Number(raw) : Number.NaN
|
||||
if (!Number.isInteger(day) || day < 0 || day > 6) {
|
||||
throw new RuntimeClientError('invalid_argument', '--day must be an integer from 0 to 6')
|
||||
}
|
||||
return day
|
||||
}
|
||||
|
||||
function getProviderFlag(flags: Map<string, string | boolean>): TuiAgent {
|
||||
const provider = getRequiredStringFlag(flags, 'provider')
|
||||
if (!isTuiAgent(provider)) {
|
||||
throw new RuntimeClientError('invalid_argument', `Unknown provider: ${provider}`)
|
||||
}
|
||||
return provider
|
||||
}
|
||||
|
||||
function getOptionalProviderFlag(flags: Map<string, string | boolean>): TuiAgent | undefined {
|
||||
const provider = getOptionalStringFlag(flags, 'provider')
|
||||
if (provider === undefined) {
|
||||
return undefined
|
||||
}
|
||||
if (!isTuiAgent(provider)) {
|
||||
throw new RuntimeClientError('invalid_argument', `Unknown provider: ${provider}`)
|
||||
}
|
||||
return provider
|
||||
}
|
||||
|
||||
function getTimeFlag(flags: Map<string, string | boolean>): { hour: number; minute: number } {
|
||||
const value = flags.get('time')
|
||||
if (value === undefined) {
|
||||
return { hour: 9, minute: 0 }
|
||||
}
|
||||
if (typeof value !== 'string' || value.length === 0) {
|
||||
throw new RuntimeClientError('invalid_argument', '--time must use HH:MM format')
|
||||
}
|
||||
return parseTimeFlag(value)
|
||||
}
|
||||
|
||||
function parseTimeFlag(value: string): { hour: number; minute: number } {
|
||||
const match = /^(\d{1,2}):(\d{2})$/.exec(value)
|
||||
if (!match) {
|
||||
throw new RuntimeClientError('invalid_argument', '--time must use HH:MM format')
|
||||
}
|
||||
const hour = Number(match[1])
|
||||
const minute = Number(match[2])
|
||||
if (!Number.isInteger(hour) || hour < 0 || hour > 23 || minute < 0 || minute > 59) {
|
||||
throw new RuntimeClientError('invalid_argument', '--time must be a valid 24-hour time')
|
||||
}
|
||||
return { hour, minute }
|
||||
}
|
||||
|
||||
function getScheduleFlag(
|
||||
flags: Map<string, string | boolean>,
|
||||
required: boolean
|
||||
): { rrule: string; dtstart: number } | undefined {
|
||||
const trigger = getOptionalStringFlag(flags, 'trigger')
|
||||
const schedule = getOptionalStringFlag(flags, 'schedule')
|
||||
if (trigger && schedule) {
|
||||
throw new RuntimeClientError(
|
||||
'invalid_argument',
|
||||
'Use either --trigger or --schedule, not both.'
|
||||
)
|
||||
}
|
||||
const raw = trigger ?? schedule
|
||||
if (!raw) {
|
||||
const modifier = getScheduleModifierFlag(flags)
|
||||
if (modifier) {
|
||||
throw new RuntimeClientError(
|
||||
'invalid_argument',
|
||||
`--${modifier} requires --trigger or --schedule`
|
||||
)
|
||||
}
|
||||
if (required) {
|
||||
throw new RuntimeClientError('invalid_argument', 'Missing required --trigger')
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
if (raw === 'manual') {
|
||||
throw new RuntimeClientError(
|
||||
'invalid_argument',
|
||||
'Manual-only automations are not supported yet. Create a scheduled automation with --disabled and run it with `orca automations run <id>` when needed.'
|
||||
)
|
||||
}
|
||||
validateScheduleModifierApplicability(flags, raw)
|
||||
const { hour, minute } = raw === 'hourly' ? { hour: 0, minute: 0 } : getTimeFlag(flags)
|
||||
const dayOfWeek = raw === 'weekly' ? (getOptionalDayFlag(flags) ?? 1) : 1
|
||||
const rrule = PRESET_TRIGGERS.has(raw as AutomationSchedulePreset)
|
||||
? buildAutomationRrule({
|
||||
preset: raw as Exclude<AutomationSchedulePreset, 'custom'>,
|
||||
hour,
|
||||
minute,
|
||||
dayOfWeek
|
||||
})
|
||||
: raw
|
||||
if (!isValidAutomationSchedule(rrule)) {
|
||||
throw new RuntimeClientError('invalid_argument', `Invalid automation trigger: ${raw}`)
|
||||
}
|
||||
return { rrule, dtstart: Date.now() }
|
||||
}
|
||||
|
||||
function getEnabledFlag(flags: Map<string, string | boolean>): boolean | undefined {
|
||||
const enabledFlag = flags.get('enabled')
|
||||
const disabledFlag = flags.get('disabled')
|
||||
if (typeof enabledFlag === 'string') {
|
||||
throw new RuntimeClientError('invalid_argument', '--enabled does not take a value')
|
||||
}
|
||||
if (typeof disabledFlag === 'string') {
|
||||
throw new RuntimeClientError('invalid_argument', '--disabled does not take a value')
|
||||
}
|
||||
const enabled = enabledFlag === true
|
||||
const disabled = disabledFlag === true
|
||||
if (enabled && disabled) {
|
||||
throw new RuntimeClientError(
|
||||
'invalid_argument',
|
||||
'Use either --enabled or --disabled, not both.'
|
||||
)
|
||||
}
|
||||
if (enabled) {
|
||||
return true
|
||||
}
|
||||
if (disabled) {
|
||||
return false
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
function getWorkspaceModeFlag(
|
||||
flags: Map<string, string | boolean>
|
||||
): 'existing' | 'new_per_run' | undefined {
|
||||
const value = getOptionalStringFlag(flags, 'workspace-mode')
|
||||
if (value === undefined) {
|
||||
return undefined
|
||||
}
|
||||
if (value === 'existing') {
|
||||
return 'existing'
|
||||
}
|
||||
if (value === 'new-per-run' || value === 'new_per_run') {
|
||||
return 'new_per_run'
|
||||
}
|
||||
throw new RuntimeClientError(
|
||||
'invalid_argument',
|
||||
'--workspace-mode must be existing or new-per-run'
|
||||
)
|
||||
}
|
||||
|
||||
async function resolveDefaultTarget(
|
||||
flags: Map<string, string | boolean>,
|
||||
cwd: string,
|
||||
client: Parameters<CommandHandler>[0]['client']
|
||||
): Promise<{ repo?: string; workspace?: string }> {
|
||||
const repo = getOptionalStringFlag(flags, 'repo')
|
||||
if (repo && getOptionalStringFlag(flags, 'workspace')) {
|
||||
throw new RuntimeClientError('invalid_argument', 'Use either --repo or --workspace, not both.')
|
||||
}
|
||||
const workspace = await getOptionalWorktreeSelector(flags, 'workspace', cwd, client)
|
||||
if (repo || workspace) {
|
||||
return { repo, workspace }
|
||||
}
|
||||
if (client.isRemote) {
|
||||
return {}
|
||||
}
|
||||
try {
|
||||
return { workspace: await resolveCurrentWorktreeSelector(cwd, client) }
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
async function getExplicitTarget(
|
||||
flags: Map<string, string | boolean>,
|
||||
cwd: string,
|
||||
client: Parameters<CommandHandler>[0]['client']
|
||||
): Promise<{ repo?: string; workspace?: string }> {
|
||||
const repo = getOptionalStringFlag(flags, 'repo')
|
||||
if (repo && getOptionalStringFlag(flags, 'workspace')) {
|
||||
throw new RuntimeClientError('invalid_argument', 'Use either --repo or --workspace, not both.')
|
||||
}
|
||||
const workspace = await getOptionalWorktreeSelector(flags, 'workspace', cwd, client)
|
||||
return { repo, workspace }
|
||||
}
|
||||
|
||||
export const AUTOMATION_HANDLERS: Record<string, CommandHandler> = {
|
||||
'automations list': async ({ client, json }) => {
|
||||
const result = await client.call<{ automations: Automation[] }>('automation.list')
|
||||
printResult(result, json, formatAutomationList)
|
||||
},
|
||||
'automations show': async ({ flags, client, json }) => {
|
||||
const result = await client.call<{ automation: Automation }>('automation.show', {
|
||||
id: getRequiredStringFlag(flags, 'id')
|
||||
})
|
||||
printResult(result, json, formatAutomationShow)
|
||||
},
|
||||
'automations create': async ({ flags, client, cwd, json }) => {
|
||||
const schedule = getScheduleFlag(flags, true)
|
||||
if (!schedule) {
|
||||
throw new RuntimeClientError('invalid_argument', 'Missing required --trigger')
|
||||
}
|
||||
const target = await resolveDefaultTarget(flags, cwd, client)
|
||||
const workspaceMode =
|
||||
getWorkspaceModeFlag(flags) ?? (target.workspace ? 'existing' : 'new_per_run')
|
||||
const result = await client.call<{ automation: Automation }>('automation.create', {
|
||||
name: getRequiredStringFlag(flags, 'name'),
|
||||
prompt: getRequiredStringFlag(flags, 'prompt'),
|
||||
agentId: getProviderFlag(flags),
|
||||
repo: target.repo,
|
||||
workspace: target.workspace,
|
||||
workspaceMode,
|
||||
baseBranch: getOptionalStringFlag(flags, 'base-branch'),
|
||||
timezone: getOptionalStringFlag(flags, 'timezone'),
|
||||
enabled: getEnabledFlag(flags),
|
||||
missedRunGraceMinutes: getOptionalPositiveIntegerFlag(flags, 'missed-run-grace-minutes'),
|
||||
...schedule
|
||||
} satisfies AutomationCreateParams)
|
||||
printResult(result, json, formatAutomationShow)
|
||||
},
|
||||
'automations edit': async ({ flags, client, cwd, json }) => {
|
||||
const target = await getExplicitTarget(flags, cwd, client)
|
||||
const schedule = getScheduleFlag(flags, false)
|
||||
const result = await client.call<{ automation: Automation }>('automation.update', {
|
||||
id: getRequiredStringFlag(flags, 'id'),
|
||||
updates: {
|
||||
name: getOptionalStringFlag(flags, 'name'),
|
||||
prompt: getOptionalStringFlag(flags, 'prompt'),
|
||||
agentId: getOptionalProviderFlag(flags),
|
||||
repo: target.repo,
|
||||
workspace: target.workspace,
|
||||
workspaceMode: getWorkspaceModeFlag(flags),
|
||||
baseBranch: getOptionalStringFlag(flags, 'base-branch'),
|
||||
timezone: getOptionalStringFlag(flags, 'timezone'),
|
||||
enabled: getEnabledFlag(flags),
|
||||
missedRunGraceMinutes: getOptionalPositiveIntegerFlag(flags, 'missed-run-grace-minutes'),
|
||||
...schedule
|
||||
} satisfies AutomationUpdateParams
|
||||
})
|
||||
printResult(result, json, formatAutomationShow)
|
||||
},
|
||||
'automations remove': async ({ flags, client, json }) => {
|
||||
const id = getRequiredStringFlag(flags, 'id')
|
||||
const result = await client.call<{ removed: boolean; id: string }>('automation.delete', { id })
|
||||
printResult(result, json, formatAutomationRemoved)
|
||||
},
|
||||
'automations run': async ({ flags, client, json }) => {
|
||||
const result = await client.call<{ run: AutomationRun }>('automation.runNow', {
|
||||
id: getRequiredStringFlag(flags, 'id')
|
||||
})
|
||||
printResult(result, json, formatAutomationRun)
|
||||
},
|
||||
'automations runs': async ({ flags, client, json }) => {
|
||||
const result = await client.call<{ runs: AutomationRun[] }>('automation.runs', {
|
||||
automationId: getOptionalStringFlag(flags, 'id')
|
||||
})
|
||||
printResult(result, json, formatAutomationRuns)
|
||||
}
|
||||
}
|
||||
+22
-1
@@ -17,6 +17,15 @@ Environments:
|
||||
environment show Show one saved remote Orca runtime
|
||||
environment rm Remove a saved remote Orca runtime
|
||||
|
||||
Automations:
|
||||
automations list List scheduled Orca automations
|
||||
automations show Show one Orca automation
|
||||
automations create Create a scheduled Orca automation
|
||||
automations edit Edit an Orca automation
|
||||
automations remove Remove an Orca automation and its run history
|
||||
automations run Run an Orca automation now
|
||||
automations runs List automation run history
|
||||
|
||||
Repos:
|
||||
repo list List repos registered in Orca
|
||||
repo add Add a project to Orca by filesystem path
|
||||
@@ -345,7 +354,7 @@ export function formatFlagHelp(flag: string): string {
|
||||
key: '--key <key> Key or combo to press, e.g. Escape or CmdOrCtrl+L',
|
||||
limit: '--limit <n> Maximum number of rows to return',
|
||||
'mouse-button': '--mouse-button <btn> Mouse button: left, right, or middle',
|
||||
name: '--name <name> Name for the new worktree',
|
||||
name: '--name <name> Name for the new worktree or automation',
|
||||
'no-parent': '--no-parent Force no parent lineage',
|
||||
'no-screenshot': '--no-screenshot Skip screenshot capture after the operation',
|
||||
pages: '--pages <n> Number of scroll pages',
|
||||
@@ -367,6 +376,18 @@ export function formatFlagHelp(flag: string): string {
|
||||
'to-y': '--to-y <y> Destination window-local y coordinate',
|
||||
worktree:
|
||||
'--worktree <selector> Worktree selector such as id:<id>, branch:<branch>, issue:<number>, path:<path>, or active/current',
|
||||
workspace: '--workspace <selector> Existing worktree selector for automation runs',
|
||||
prompt: '--prompt <text> Automation prompt to pass to the agent',
|
||||
provider: '--provider <agent> Agent id such as codex, claude, or gemini',
|
||||
trigger: '--trigger <schedule> Automation schedule preset, cron, or RRULE',
|
||||
schedule: '--schedule <schedule> Alias for --trigger',
|
||||
time: '--time <HH:MM> Time used with daily/weekdays/weekly presets',
|
||||
day: '--day <0-6> Day used with weekly preset, Sunday=0',
|
||||
timezone: '--timezone <tz> IANA timezone for the automation',
|
||||
enabled: '--enabled Enable the automation',
|
||||
disabled: '--disabled Disable the automation',
|
||||
'workspace-mode': '--workspace-mode <mode> existing or new-per-run',
|
||||
'missed-run-grace-minutes': '--missed-run-grace-minutes <n> Missed-run grace window',
|
||||
'value-stdin': '--value-stdin Read set-value payload from stdin',
|
||||
'window-id': '--window-id <id> Target a window id from list-windows',
|
||||
'window-index': '--window-index <n> Target a window index from list-windows',
|
||||
|
||||
@@ -1439,4 +1439,448 @@ describe('orca cli worktree awareness', () => {
|
||||
expect(callMock).toHaveBeenCalledTimes(1)
|
||||
expect(callMock).toHaveBeenCalledWith('browser.tabCurrent', { worktree: undefined })
|
||||
})
|
||||
|
||||
it('creates an automation for the enclosing worktree by default', async () => {
|
||||
queueFixtures(
|
||||
callMock,
|
||||
worktreeListFixture([buildWorktree('/tmp/repo/feature', 'feature/foo', 'abc', 'repo-1')]),
|
||||
okFixture('req_automation_create', {
|
||||
automation: {
|
||||
id: 'auto-1',
|
||||
name: 'Daily review',
|
||||
prompt: 'Review open changes',
|
||||
agentId: 'codex',
|
||||
projectId: 'repo-1',
|
||||
executionTargetType: 'local',
|
||||
executionTargetId: 'local',
|
||||
schedulerOwner: 'local_host_service',
|
||||
workspaceMode: 'existing',
|
||||
workspaceId: 'repo-1::/tmp/repo/feature',
|
||||
baseBranch: null,
|
||||
timezone: 'America/Toronto',
|
||||
rrule: 'FREQ=DAILY;BYHOUR=9;BYMINUTE=0',
|
||||
dtstart: 1,
|
||||
enabled: true,
|
||||
nextRunAt: 2,
|
||||
missedRunPolicy: 'run_once_within_grace',
|
||||
missedRunGraceMinutes: 720,
|
||||
createdAt: 1,
|
||||
updatedAt: 1
|
||||
}
|
||||
})
|
||||
)
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await main(
|
||||
[
|
||||
'automations',
|
||||
'create',
|
||||
'--name',
|
||||
'Daily review',
|
||||
'--trigger',
|
||||
'daily',
|
||||
'--prompt',
|
||||
'Review open changes',
|
||||
'--provider',
|
||||
'codex',
|
||||
'--json'
|
||||
],
|
||||
'/tmp/repo/feature/src'
|
||||
)
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(1, 'worktree.list', { limit: 10_000 })
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'automation.create', {
|
||||
name: 'Daily review',
|
||||
prompt: 'Review open changes',
|
||||
agentId: 'codex',
|
||||
repo: undefined,
|
||||
workspace: `path:${path.resolve('/tmp/repo/feature')}`,
|
||||
workspaceMode: 'existing',
|
||||
baseBranch: undefined,
|
||||
timezone: undefined,
|
||||
enabled: undefined,
|
||||
missedRunGraceMinutes: undefined,
|
||||
rrule: 'FREQ=DAILY;BYHOUR=9;BYMINUTE=0',
|
||||
dtstart: expect.any(Number)
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects invalid automation --day values before calling the runtime', async () => {
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const priorExitCode = process.exitCode
|
||||
|
||||
await main(
|
||||
[
|
||||
'automations',
|
||||
'create',
|
||||
'--name',
|
||||
'Weekly review',
|
||||
'--trigger',
|
||||
'weekly',
|
||||
'--day',
|
||||
'7',
|
||||
'--prompt',
|
||||
'Review open changes',
|
||||
'--provider',
|
||||
'codex',
|
||||
'--json'
|
||||
],
|
||||
'/tmp/repo'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect([...logSpy.mock.calls, ...errSpy.mock.calls].flat().join('\n')).toContain(
|
||||
'--day must be an integer from 0 to 6'
|
||||
)
|
||||
expect(process.exitCode).toBe(1)
|
||||
|
||||
process.exitCode = priorExitCode
|
||||
})
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: 'day on daily preset',
|
||||
args: ['--trigger', 'daily', '--day', '2'],
|
||||
message: '--day can only be used with the weekly automation preset'
|
||||
},
|
||||
{
|
||||
name: 'time on custom cron',
|
||||
args: ['--trigger', '0 9 * * *', '--time', '10:30'],
|
||||
message: '--time can only be used with preset automation triggers'
|
||||
},
|
||||
{
|
||||
name: 'time on hourly preset',
|
||||
args: ['--trigger', 'hourly', '--time', '10:30'],
|
||||
message: '--time cannot be used with the hourly automation preset'
|
||||
}
|
||||
])('rejects automation schedule modifier mismatch: $name', async ({ args, message }) => {
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const priorExitCode = process.exitCode
|
||||
|
||||
await main(
|
||||
[
|
||||
'automations',
|
||||
'create',
|
||||
'--name',
|
||||
'Daily review',
|
||||
...args,
|
||||
'--prompt',
|
||||
'Review open changes',
|
||||
'--provider',
|
||||
'codex',
|
||||
'--json'
|
||||
],
|
||||
'/tmp/repo'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect([...logSpy.mock.calls, ...errSpy.mock.calls].flat().join('\n')).toContain(message)
|
||||
expect(process.exitCode).toBe(1)
|
||||
|
||||
process.exitCode = priorExitCode
|
||||
})
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: 'create',
|
||||
args: [
|
||||
'automations',
|
||||
'create',
|
||||
'--name',
|
||||
'Daily review',
|
||||
'--trigger',
|
||||
'daily',
|
||||
'--time',
|
||||
'--prompt',
|
||||
'Review open changes',
|
||||
'--provider',
|
||||
'codex',
|
||||
'--json'
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'edit',
|
||||
args: ['automations', 'edit', 'auto-1', '--trigger', 'daily', '--time', '--json']
|
||||
}
|
||||
])('rejects bare automation --time on $name', async ({ args }) => {
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const priorExitCode = process.exitCode
|
||||
|
||||
await main(args, '/tmp/repo')
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect([...logSpy.mock.calls, ...errSpy.mock.calls].flat().join('\n')).toContain(
|
||||
'--time must use HH:MM format'
|
||||
)
|
||||
expect(process.exitCode).toBe(1)
|
||||
|
||||
process.exitCode = priorExitCode
|
||||
})
|
||||
|
||||
it('rejects automation edit schedule modifiers without a schedule flag', async () => {
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const priorExitCode = process.exitCode
|
||||
|
||||
await main(['automations', 'edit', 'auto-1', '--day', '7', '--json'], '/tmp/repo')
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect([...logSpy.mock.calls, ...errSpy.mock.calls].flat().join('\n')).toContain(
|
||||
'--day requires --trigger or --schedule'
|
||||
)
|
||||
expect(process.exitCode).toBe(1)
|
||||
|
||||
process.exitCode = priorExitCode
|
||||
})
|
||||
|
||||
it('rejects automation create with both repo and workspace targets', async () => {
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const priorExitCode = process.exitCode
|
||||
|
||||
await main(
|
||||
[
|
||||
'automations',
|
||||
'create',
|
||||
'--name',
|
||||
'Daily review',
|
||||
'--trigger',
|
||||
'daily',
|
||||
'--prompt',
|
||||
'Review open changes',
|
||||
'--provider',
|
||||
'codex',
|
||||
'--repo',
|
||||
'id:repo-1',
|
||||
'--workspace',
|
||||
'id:repo-1::/tmp/repo/feature',
|
||||
'--json'
|
||||
],
|
||||
'/tmp/repo'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect([...logSpy.mock.calls, ...errSpy.mock.calls].flat().join('\n')).toContain(
|
||||
'Use either --repo or --workspace, not both.'
|
||||
)
|
||||
expect(process.exitCode).toBe(1)
|
||||
|
||||
process.exitCode = priorExitCode
|
||||
})
|
||||
|
||||
it('rejects automation edit with both repo and workspace targets', async () => {
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const priorExitCode = process.exitCode
|
||||
|
||||
await main(
|
||||
[
|
||||
'automations',
|
||||
'edit',
|
||||
'auto-1',
|
||||
'--repo',
|
||||
'id:repo-1',
|
||||
'--workspace',
|
||||
'id:repo-1::/tmp/repo/feature',
|
||||
'--json'
|
||||
],
|
||||
'/tmp/repo'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect([...logSpy.mock.calls, ...errSpy.mock.calls].flat().join('\n')).toContain(
|
||||
'Use either --repo or --workspace, not both.'
|
||||
)
|
||||
expect(process.exitCode).toBe(1)
|
||||
|
||||
process.exitCode = priorExitCode
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ flag: 'enabled', value: 'false', message: '--enabled does not take a value' },
|
||||
{ flag: 'disabled', value: 'false', message: '--disabled does not take a value' }
|
||||
])('rejects automation create --$flag with a string value', async ({ flag, value, message }) => {
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const priorExitCode = process.exitCode
|
||||
|
||||
await main(
|
||||
[
|
||||
'automations',
|
||||
'create',
|
||||
'--name',
|
||||
'Daily review',
|
||||
'--trigger',
|
||||
'daily',
|
||||
'--prompt',
|
||||
'Review open changes',
|
||||
'--provider',
|
||||
'codex',
|
||||
'--repo',
|
||||
'id:repo-1',
|
||||
`--${flag}`,
|
||||
value,
|
||||
'--json'
|
||||
],
|
||||
'/tmp/repo'
|
||||
)
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect([...logSpy.mock.calls, ...errSpy.mock.calls].flat().join('\n')).toContain(message)
|
||||
expect(process.exitCode).toBe(1)
|
||||
|
||||
process.exitCode = priorExitCode
|
||||
})
|
||||
|
||||
it('resolves explicit automation create workspace active from cwd', async () => {
|
||||
queueFixtures(
|
||||
callMock,
|
||||
worktreeListFixture([buildWorktree('/tmp/repo/feature', 'feature/foo', 'abc', 'repo-1')]),
|
||||
okFixture('req_automation_create', { automation: { id: 'auto-1', name: 'Daily review' } })
|
||||
)
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await main(
|
||||
[
|
||||
'automations',
|
||||
'create',
|
||||
'--name',
|
||||
'Daily review',
|
||||
'--trigger',
|
||||
'daily',
|
||||
'--prompt',
|
||||
'Review open changes',
|
||||
'--provider',
|
||||
'codex',
|
||||
'--workspace',
|
||||
'active',
|
||||
'--json'
|
||||
],
|
||||
'/tmp/repo/feature/src'
|
||||
)
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(1, 'worktree.list', { limit: 10_000 })
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'automation.create', {
|
||||
name: 'Daily review',
|
||||
prompt: 'Review open changes',
|
||||
agentId: 'codex',
|
||||
repo: undefined,
|
||||
workspace: `path:${path.resolve('/tmp/repo/feature')}`,
|
||||
workspaceMode: 'existing',
|
||||
baseBranch: undefined,
|
||||
timezone: undefined,
|
||||
enabled: undefined,
|
||||
missedRunGraceMinutes: undefined,
|
||||
rrule: 'FREQ=DAILY;BYHOUR=9;BYMINUTE=0',
|
||||
dtstart: expect.any(Number)
|
||||
})
|
||||
})
|
||||
|
||||
it('resolves explicit automation edit workspace current from cwd', async () => {
|
||||
queueFixtures(
|
||||
callMock,
|
||||
worktreeListFixture([buildWorktree('/tmp/repo/feature', 'feature/foo', 'abc', 'repo-1')]),
|
||||
okFixture('req_edit', { automation: { id: 'auto-1', name: 'Daily review' } })
|
||||
)
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await main(
|
||||
['automations', 'edit', 'auto-1', '--workspace', 'current', '--enabled', '--json'],
|
||||
'/tmp/repo/feature/src'
|
||||
)
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(1, 'worktree.list', { limit: 10_000 })
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'automation.update', {
|
||||
id: 'auto-1',
|
||||
updates: {
|
||||
name: undefined,
|
||||
prompt: undefined,
|
||||
agentId: undefined,
|
||||
repo: undefined,
|
||||
workspace: `path:${path.resolve('/tmp/repo/feature')}`,
|
||||
workspaceMode: undefined,
|
||||
baseBranch: undefined,
|
||||
timezone: undefined,
|
||||
enabled: true,
|
||||
missedRunGraceMinutes: undefined
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('passes positional automation ids to edit, remove, run, and show', async () => {
|
||||
queueFixtures(
|
||||
callMock,
|
||||
okFixture('req_edit', { automation: { id: 'auto-1', name: 'Paused' } }),
|
||||
okFixture('req_remove', { removed: true, id: 'auto-1' }),
|
||||
okFixture('req_run', {
|
||||
run: {
|
||||
id: 'run-1',
|
||||
automationId: 'auto-1',
|
||||
title: 'Paused run 1',
|
||||
status: 'pending',
|
||||
trigger: 'manual',
|
||||
scheduledFor: 1,
|
||||
workspaceId: null,
|
||||
sessionKind: 'terminal',
|
||||
chatSessionId: null,
|
||||
terminalSessionId: null,
|
||||
outputSnapshot: null,
|
||||
usage: null,
|
||||
error: null,
|
||||
startedAt: null,
|
||||
dispatchedAt: null,
|
||||
createdAt: 1
|
||||
}
|
||||
}),
|
||||
okFixture('req_show', { automation: { id: 'auto-1', name: 'Paused' } })
|
||||
)
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await main(['automations', 'edit', 'auto-1', '--disabled', '--json'], '/tmp/repo')
|
||||
await main(['automations', 'remove', 'auto-1', '--json'], '/tmp/repo')
|
||||
await main(['automations', 'run', 'auto-1', '--json'], '/tmp/repo')
|
||||
await main(['automations', 'show', 'auto-1', '--json'], '/tmp/repo')
|
||||
|
||||
expect(callMock).toHaveBeenNthCalledWith(1, 'automation.update', {
|
||||
id: 'auto-1',
|
||||
updates: {
|
||||
name: undefined,
|
||||
prompt: undefined,
|
||||
agentId: undefined,
|
||||
repo: undefined,
|
||||
workspace: undefined,
|
||||
workspaceMode: undefined,
|
||||
baseBranch: undefined,
|
||||
timezone: undefined,
|
||||
enabled: false,
|
||||
missedRunGraceMinutes: undefined
|
||||
}
|
||||
})
|
||||
expect(callMock).toHaveBeenNthCalledWith(2, 'automation.delete', { id: 'auto-1' })
|
||||
expect(callMock).toHaveBeenNthCalledWith(3, 'automation.runNow', { id: 'auto-1' })
|
||||
expect(callMock).toHaveBeenNthCalledWith(4, 'automation.show', { id: 'auto-1' })
|
||||
})
|
||||
|
||||
it('rejects ambiguous positional and flag automation ids before dispatch', async () => {
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
const priorExitCode = process.exitCode
|
||||
|
||||
await main(['automations', 'show', 'auto-1', '--id', 'auto-2', '--json'], '/tmp/repo')
|
||||
|
||||
expect(callMock).not.toHaveBeenCalled()
|
||||
expect(logSpy).toHaveBeenCalledTimes(1)
|
||||
expect(JSON.parse(String(logSpy.mock.calls[0]?.[0]))).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
code: 'invalid_argument',
|
||||
message: 'Pass --id either positionally or as a flag, not both.'
|
||||
}
|
||||
})
|
||||
expect(process.exitCode).toBe(1)
|
||||
|
||||
process.exitCode = priorExitCode
|
||||
})
|
||||
})
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@
|
||||
import {
|
||||
findCommandSpec,
|
||||
isCommandGroup,
|
||||
normalizeCommandPositionals,
|
||||
parseArgs,
|
||||
resolveHelpPath,
|
||||
validateCommandAndFlags
|
||||
@@ -20,7 +21,7 @@ function shouldIgnoreRemoteSelection(commandPath: string[]): boolean {
|
||||
}
|
||||
|
||||
export async function main(argv = process.argv.slice(2), cwd = process.cwd()): Promise<void> {
|
||||
const parsed = parseArgs(argv)
|
||||
const parsed = normalizeCommandPositionals(COMMAND_SPECS, parseArgs(argv))
|
||||
const helpPath = resolveHelpPath(parsed)
|
||||
if (helpPath !== null) {
|
||||
printHelp(COMMAND_SPECS, helpPath)
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import type { CommandSpec } from '../args'
|
||||
import { GLOBAL_FLAGS } from '../args'
|
||||
|
||||
const AUTOMATION_TARGET_FLAGS = ['repo', 'workspace', 'workspace-mode', 'base-branch']
|
||||
const AUTOMATION_SCHEDULE_FLAGS = ['trigger', 'schedule', 'time', 'day', 'timezone']
|
||||
const AUTOMATION_STATE_FLAGS = ['enabled', 'disabled', 'missed-run-grace-minutes']
|
||||
|
||||
export const AUTOMATION_COMMAND_SPECS: CommandSpec[] = [
|
||||
{
|
||||
path: ['automations', 'list'],
|
||||
summary: 'List scheduled Orca automations',
|
||||
usage: 'orca automations list [--json]',
|
||||
allowedFlags: [...GLOBAL_FLAGS],
|
||||
examples: ['orca automations list', 'orca automations list --json']
|
||||
},
|
||||
{
|
||||
path: ['automations', 'show'],
|
||||
summary: 'Show one Orca automation',
|
||||
usage: 'orca automations show <id> [--json]',
|
||||
allowedFlags: [...GLOBAL_FLAGS, 'id'],
|
||||
positionalArgs: ['id'],
|
||||
examples: ['orca automations show 2f9e...', 'orca automations show --id 2f9e... --json']
|
||||
},
|
||||
{
|
||||
path: ['automations', 'create'],
|
||||
summary: 'Create a scheduled Orca automation',
|
||||
usage:
|
||||
'orca automations create --name <name> --trigger <preset|cron|rrule> --prompt <text> --provider <agent> [--repo <selector>|--workspace <selector>] [--json]',
|
||||
allowedFlags: [
|
||||
...GLOBAL_FLAGS,
|
||||
'name',
|
||||
'prompt',
|
||||
'provider',
|
||||
...AUTOMATION_TARGET_FLAGS,
|
||||
...AUTOMATION_SCHEDULE_FLAGS,
|
||||
...AUTOMATION_STATE_FLAGS
|
||||
],
|
||||
notes: [
|
||||
'Trigger accepts hourly, daily, weekdays, weekly, a 5-field cron expression, or an RRULE string.',
|
||||
'When --repo is omitted, the CLI uses the enclosing Orca worktree when one can be resolved from cwd.',
|
||||
'Use --workspace to run in an existing worktree; otherwise the automation creates a new worktree per run.'
|
||||
],
|
||||
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'
|
||||
]
|
||||
},
|
||||
{
|
||||
path: ['automations', 'edit'],
|
||||
summary: 'Edit an Orca automation',
|
||||
usage: 'orca automations edit <id> [--name <name>] [--trigger <preset|cron|rrule>] [--json]',
|
||||
allowedFlags: [
|
||||
...GLOBAL_FLAGS,
|
||||
'id',
|
||||
'name',
|
||||
'prompt',
|
||||
'provider',
|
||||
...AUTOMATION_TARGET_FLAGS,
|
||||
...AUTOMATION_SCHEDULE_FLAGS,
|
||||
...AUTOMATION_STATE_FLAGS
|
||||
],
|
||||
positionalArgs: ['id'],
|
||||
examples: [
|
||||
'orca automations edit 2f9e... --disabled',
|
||||
'orca automations edit --id 2f9e... --trigger "30 * * * *" --json'
|
||||
]
|
||||
},
|
||||
{
|
||||
path: ['automations', 'remove'],
|
||||
summary: 'Remove an Orca automation and its run history',
|
||||
usage: 'orca automations remove <id> [--json]',
|
||||
allowedFlags: [...GLOBAL_FLAGS, 'id'],
|
||||
positionalArgs: ['id'],
|
||||
examples: ['orca automations remove 2f9e...', 'orca automations remove --id 2f9e... --json']
|
||||
},
|
||||
{
|
||||
path: ['automations', 'run'],
|
||||
summary: 'Run an Orca automation now',
|
||||
usage: 'orca automations run <id> [--json]',
|
||||
allowedFlags: [...GLOBAL_FLAGS, 'id'],
|
||||
positionalArgs: ['id'],
|
||||
examples: ['orca automations run 2f9e...', 'orca automations run --id 2f9e... --json']
|
||||
},
|
||||
{
|
||||
path: ['automations', 'runs'],
|
||||
summary: 'List automation run history',
|
||||
usage: 'orca automations runs [--id <automation-id>] [--json]',
|
||||
allowedFlags: [...GLOBAL_FLAGS, 'id'],
|
||||
examples: ['orca automations runs', 'orca automations runs --id 2f9e... --json']
|
||||
}
|
||||
]
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { CommandSpec } from '../args'
|
||||
import { BROWSER_ADVANCED_COMMAND_SPECS } from './browser-advanced'
|
||||
import { BROWSER_BASIC_COMMAND_SPECS } from './browser-basic'
|
||||
import { AUTOMATION_COMMAND_SPECS } from './automations'
|
||||
import { CORE_COMMAND_SPECS } from './core'
|
||||
import { ORCHESTRATION_COMMAND_SPECS } from './orchestration'
|
||||
import { COMPUTER_COMMAND_SPECS } from './computer'
|
||||
@@ -8,6 +9,7 @@ import { ENVIRONMENT_COMMAND_SPECS } from './environment'
|
||||
|
||||
export const COMMAND_SPECS: CommandSpec[] = [
|
||||
...CORE_COMMAND_SPECS,
|
||||
...AUTOMATION_COMMAND_SPECS,
|
||||
...BROWSER_BASIC_COMMAND_SPECS,
|
||||
...BROWSER_ADVANCED_COMMAND_SPECS,
|
||||
...ORCHESTRATION_COMMAND_SPECS,
|
||||
|
||||
Reference in New Issue
Block a user