Skip to content

Automation Run Channel

JSON Schema: state.schema.json

State Types

AutomationRunStatus

Lifecycle status of one automation run.

completed, failed, and cancelled are terminal. A run remains running while any linked session awaits input or client-side work; linked session state is authoritative for those interactions.

MemberValueDescription
Pending'pending'The durable run record exists but execution has not started.
Running'running'One or more linked sessions are executing or awaiting interaction.
Completed'completed'Execution finished successfully.
Failed'failed'Execution ended with an error.
Cancelled'cancelled'Execution ended because cancellation was accepted.

AutomationRunOriginKind

Discriminant describing what created an automation run.

MemberValueDescription
Manual'manual'A client explicitly invoked {@link RunAutomationParams | runAutomation}.
Trigger'trigger'An automatic schedule or event trigger fired.

AutomationManualRunOrigin

Origin recorded for a client-requested manual run.

FieldTypeDescription
kindAutomationRunOriginKind.Manual

AutomationTriggeredRunOrigin

Origin recorded for a run created by one of the automation's triggers.

FieldTypeRequiredDescription
kindAutomationRunOriginKind.TriggerYes
triggerIdstringYesMatches the stable {@link AutomationScheduleTrigger.id} or {@link AutomationEventTrigger.id} in the definition.
scheduledForstringNoIntended schedule occurrence as an ISO 8601 timestamp. Present for schedule triggers and normally absent for event triggers.
catchUpbooleanNotrue when this is a catch-up run created by {@link AutomationMisfirePolicy.RunOnce}.
eventRecord<string, unknown>NoHost-defined, non-secret event provenance suitable for display or audit. This is descriptive context, not an input that clients replay.

AutomationRunOrigin

Immutable provenance describing why a run was created.

AutomationManualRunOrigin | AutomationTriggeredRunOrigin

AutomationPendingRunLifecycle

A durable run exists but has not begun external execution.

FieldTypeDescription
statusAutomationRunStatus.Pending
createdAtstringRun creation timestamp in ISO 8601 format.

AutomationRunningRunLifecycle

The run is executing linked sessions or awaiting interaction on them.

Linked {@link SessionState.status} and {@link SessionState.inputNeeded} remain authoritative for whether user attention or client-side work is required.

FieldTypeDescription
statusAutomationRunStatus.Running
createdAtstringRun creation timestamp in ISO 8601 format.
startedAtstringFirst execution start timestamp in ISO 8601 format.

AutomationCompletedRunLifecycle

Terminal lifecycle for a successfully completed run.

FieldTypeRequiredDescription
statusAutomationRunStatus.CompletedYes
createdAtstringYesRun creation timestamp in ISO 8601 format.
startedAtstringYesFirst execution start timestamp in ISO 8601 format.
completedAtstringYesCompletion timestamp in ISO 8601 format.
usageUsageInfoNoOptional aggregate model usage across all linked sessions.

AutomationFailedRunLifecycle

Terminal lifecycle for a run that ended with an error.

startedAt is absent when failure occurred before execution began, such as session-template validation or workspace preparation.

FieldTypeRequiredDescription
statusAutomationRunStatus.FailedYes
createdAtstringYesRun creation timestamp in ISO 8601 format.
startedAtstringNoFirst execution start timestamp in ISO 8601 format, when execution began.
completedAtstringYesFailure timestamp in ISO 8601 format.
errorErrorInfoYesStable machine-readable and human-readable failure information.

AutomationCancelledRunLifecycle

Terminal lifecycle for a cancelled run.

startedAt is absent when cancellation completed while the run was still pending.

FieldTypeRequiredDescription
statusAutomationRunStatus.CancelledYes
createdAtstringYesRun creation timestamp in ISO 8601 format.
startedAtstringNoFirst execution start timestamp in ISO 8601 format, when execution began.
completedAtstringYesCancellation completion timestamp in ISO 8601 format.

AutomationRunLifecycle

Discriminated lifecycle of an automation run.

AutomationPendingRunLifecycle | AutomationRunningRunLifecycle | AutomationCompletedRunLifecycle | AutomationFailedRunLifecycle | AutomationCancelledRunLifecycle

AutomationRunSummary

Lightweight projection of a run retained in its automation's history.

A summary contains enough information to render run history without subscribing to every ahp-automation-run: resource.

FieldTypeRequiredDescription
resourceURIYesSubscribable ahp-automation-run: URI matching {@link AutomationRunState.resource}.
automationURIYesOwning ahp-automation: URI matching {@link AutomationRunState.automation}.
originAutomationRunOriginYesImmutable provenance matching {@link AutomationRunState.origin}.
lifecycleAutomationRunLifecycleYesCurrent or terminal lifecycle snapshot matching {@link AutomationRunState.lifecycle}.
primarySessionURINoSession matching {@link AutomationRunState.primarySession}, when selected.
sessionCountnumberYesNumber of entries in {@link AutomationRunState.sessions}.
_metaRecord<string, unknown>NoOpaque host-defined summary metadata.

AutomationRunState

Authoritative state of one subscribed ahp-automation-run: resource.

The run channel owns task-level lifecycle, provenance, and linked-session membership. Linked session and chat channels remain authoritative for transcripts, tools, interaction requirements, changesets, and per-session lifecycle.

FieldTypeRequiredDescription
resourceURIYesURI of this automation-run channel.
automationURIYesOwning ahp-automation: URI matching {@link AutomationState.resource}.
originAutomationRunOriginYesImmutable provenance describing how this run was created.
lifecycleAutomationRunLifecycleYesCurrent or terminal lifecycle.
sessionsURI[]YesOrdered, unique session URIs belonging to this run, each matching {@link SessionState.resource}. Entries may represent retries, parallel workers, or delegated attempts.
primarySessionURINoMember of {@link AutomationRunState.sessions} that the host recommends opening first.
_metaRecord<string, unknown>NoOpaque host-defined run metadata.

Actions

JSON Schema: actions.schema.json

automationRun/lifecycleChanged

Replace the run lifecycle.

The host dispatches this action for every lifecycle transition.

FieldTypeDescription
typeActionType.AutomationRunLifecycleChanged
lifecycleAutomationRunLifecycleComplete replacement {@link AutomationRunState.lifecycle}.

automationRun/sessionSet

Add a session to {@link AutomationRunState.sessions}.

Session URIs are unique. Setting an existing URI is a no-op.

FieldTypeDescription
typeActionType.AutomationRunSessionSet
sessionURISession URI to append to {@link AutomationRunState.sessions} when not already linked.

automationRun/sessionRemoved

Remove a linked session from the run.

Removing the current primary session also clears {@link AutomationRunState.primarySession}. An unknown URI is a no-op.

FieldTypeDescription
typeActionType.AutomationRunSessionRemoved
sessionURIEntry in {@link AutomationRunState.sessions} to remove.

automationRun/primarySessionChanged

Select or clear the session clients should open first for this run.

FieldTypeRequiredDescription
typeActionType.AutomationRunPrimarySessionChangedYes
primarySessionURINoNew {@link AutomationRunState.primarySession}, or omitted to clear the selection.

automationRun/cancelRequested

Ask the host to cancel this run.

This is the only client-dispatchable automation-run action. It is a side-effect request and deliberately leaves optimistic state unchanged. The client may dispatch it only when the host advertises its runCancellation capability and the current lifecycle is pending or running. The host revalidates that the run is non-terminal. The authoritative outcome arrives later through {@link AutomationRunLifecycleChangedAction}: cancellation may transition to cancelled, or the run may complete or fail before cancellation takes effect.

FieldTypeDescription
typeActionType.AutomationRunCancelRequested

Released under the MIT License.