File size: 7,622 Bytes
5f40163 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | export interface AutomationTrigger {
/**
* Trigger kind. Known values are the schedule aliases "cron" / "schedule"
* (time-based) and "event" (webhook/event-driven). Kept as `string` rather
* than a closed union on purpose: the backend emits more than one
* scheduled-trigger alias and may introduce new kinds, so UI code branches
* on `type === "event"` and treats every other value as a schedule.
*/
type: string;
/** Cron expression (schedule triggers only). */
schedule?: string;
/** Human-readable schedule description (schedule triggers only). */
schedule_human?: string;
/** IANA timezone name (schedule triggers only). */
timezone?: string;
/** Event source, e.g. "github" (event triggers only). */
source?: string;
/** Event key pattern(s) to match, e.g. "pull_request.opened" or ["push", "release.*"]. */
on?: string | string[];
/** JMESPath filter expression evaluated against the raw webhook payload. */
filter?: string;
}
export interface Automation {
id: string;
name: string;
trigger: AutomationTrigger;
enabled: boolean;
/**
* Human-readable reason the automation was last disabled (the latest
* disablement event overwrites this). Mirrors the automation service's
* `AutomationResponse.disabled_reason`. `null`/absent for enabled automations
* or an automation service older than the release that started recording it.
*/
disabled_reason?: string | null;
/**
* Structured disablement metadata from the automation service
* (`AutomationResponse.disabled_detail`): `{reason, source, run_id, ...}`
* plus rule-specific fields (threshold, consecutive counts, status_detail).
* Used to tell user-initiated ("manual") disables from automatic ones
* (consecutive failures, permanent config faults).
*/
disabled_detail?: {
reason?: string;
source?: string;
run_id?: string | null;
[key: string]: unknown;
} | null;
/** UTC timestamp the automation was last disabled. */
disabled_at?: string | null;
/**
* UUID of the user who created this automation. The backend returns it in
* `AutomationResponse.user_id`; the frontend uses it to implement the
* "creator escape hatch" — a member (view-only) may still edit their own
* automations even without `manage_automations`.
*/
user_id?: string;
repository?: string;
/** LLM/model profile name used for automation runs. */
model?: string | null;
/**
* Maximum run time in seconds. `null`/omitted uses the server default
* (600s, 10 min); the deployment reports the maximum it accepts.
*/
timeout?: number | null;
created_at: string;
updated_at: string;
prompt: string | null;
branch?: string;
plugins?: string[];
notification?: string;
timezone?: string;
last_triggered_at?: string | null;
/**
* Service-owned preset state, returned verbatim. The GUI reads only the
* `template` provenance block inside it ({id, version, config}, written at
* setup time), and only through the guarded helper in
* `#/utils/automation-catalog`.
*/
preset_metadata?: Record<string, unknown> | null;
}
export type AutomationSpec = Omit<
Automation,
| "id"
| "created_at"
| "updated_at"
| "last_triggered_at"
| "preset_metadata"
| "disabled_reason"
| "disabled_detail"
| "disabled_at"
>;
/** The envelope constants come from the interface manifest's import/export spec. */
export interface AutomationExportFile {
version: number;
kind: string;
spec: AutomationSpec;
}
export interface AutomationsResponse {
automations: Automation[];
total: number;
}
/** Mirrors `RunStatus` in the automation service's OpenAPI schema. */
export enum AutomationRunStatus {
PENDING = "PENDING",
RUNNING = "RUNNING",
COMPLETED = "COMPLETED",
FAILED = "FAILED",
CANCELLED = "CANCELLED",
SKIPPED = "SKIPPED",
}
export type AutomationTaskOutcomeStatus =
| "success"
| "partial_success"
| "blocked"
| "failed"
| "unknown";
export interface AutomationFinishToolResponse {
status?: AutomationTaskOutcomeStatus | string;
outcome_summary?: string;
[key: string]: unknown;
}
export interface AutomationRunMetadata {
finish_tool_response?: AutomationFinishToolResponse | string | null;
[key: string]: unknown;
}
export interface AutomationRunStatusDetail {
phase?: string;
kind?: string;
detail?: string;
formatted_detail?: string;
transient?: boolean;
source?: string;
operation?: string;
code?: string;
status_code?: number;
[key: string]: unknown;
}
export interface AutomationRun {
id: string;
status: AutomationRunStatus;
conversation_id: string | null;
/**
* ID of the bash command that ran the automation inside the agent-server
* sandbox. Used to fetch run logs from
* `/api/bash/bash_events/{bash_command_id}` and the matching
* `BashOutput` events. Null when the run failed before a command was
* dispatched (e.g. sandbox provisioning errors).
*/
bash_command_id: string | null;
error_detail: string | null;
status_detail?: AutomationRunStatusDetail | null;
run_metadata?: AutomationRunMetadata | null;
/**
* Accumulated LLM cost of the run in USD, reported by the SDK in the
* completion callback. `null` means unknown — the run predates cost
* tracking, or ended without a callback (cancelled, watchdog timeout).
* Absent entirely when the automation service is older than the release
* that added the field, hence optional.
*/
cost?: number | null;
/**
* Machine-readable code for the run's current or last-known phase (e.g.
* "sandbox_provisioning"). `null` means nothing has reported one; absent
* entirely against an automation service that predates phase reporting.
* Code and label are one value, always written together.
*/
phase_code?: string | null;
/**
* Author-supplied description of the phase (at most 200 characters, no
* control or separator characters, emoji and non-Latin text allowed).
* Data, not translatable interface copy.
*/
phase_label?: string | null;
/** UTC datetime the phase was last written. Same nullability as `phase_code`. */
phase_updated_at?: string | null;
started_at: string;
completed_at: string | null;
}
export interface AutomationRunsResponse {
runs: AutomationRun[];
total: number;
/**
* Lifetime run counts by status, unaffected by pagination. Sparse — a
* status with no runs has no key, so when the field is present a missing
* key means zero. Absent entirely when the automation service is older
* than the release that added it.
*/
status_counts?: Partial<Record<AutomationRunStatus, number>>;
}
export type ActivityLogExportFormat = "json" | "csv";
/** Client-built Activity Log export row (from list runs + automation detail). */
export interface AutomationRunExportRow {
run_id: string;
automation_id: string;
automation_name: string;
trigger: AutomationTrigger | Record<string, unknown>;
start_time: string | null;
end_time: string | null;
duration_seconds: number | null;
status: AutomationRunStatus;
conversation_id: string | null;
conversation_url: string | null;
error: string | null;
/**
* Accumulated LLM cost in USD, or null when unknown. Unlike
* `AutomationRun["cost"]` this is always present: the row normalizes a
* missing field to null so every exported record has the same shape.
*/
cost: number | null;
/**
* The raw `phase_code`, like `status`, falling back to `phase_label` for a
* phase reported without a code. Null only when the run has no phase.
*/
phase: string | null;
}
|