automations: feat: add shared automations protocol - #393
automations: feat: add shared automations protocol#393Ulugbek Abdullaev (ulugbekna) wants to merge 10 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 935e37c8-2b68-40b1-9273-f195cb3af9a0
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 935e37c8-2b68-40b1-9273-f195cb3af9a0
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 935e37c8-2b68-40b1-9273-f195cb3af9a0
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
isClientDispatchable did not accept automation or automation-run actions, so servers could not use it to reject server-only actions arriving on the new automation channels. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Collapse recurring schedules to the specified five-field AHP cron format, document the automation and run protocol surfaces, expand the guide, and regenerate every client and schema. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Require imported definitions to remain disabled through cutover and let clients supply the source scheduler's next unevaluated occurrence. Document durable occurrence claiming so catch-up runs cannot be duplicated after restart. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7 # Conflicts: # clients/go/ahptypes/state.generated.go # clients/kotlin/src/main/kotlin/com/microsoft/agenthostprotocol/generated/State.generated.kt # clients/rust/crates/ahp-types/src/actions.rs # clients/rust/crates/ahp-types/src/state.rs # clients/rust/crates/ahp/src/reducers.rs # clients/swift/AgentHostProtocol/Sources/AgentHostProtocol/Generated/State.generated.swift # scripts/generate-rust.ts
| * | ||
| * @category Automation State | ||
| */ | ||
| export const enum AutomationOperation { |
There was a problem hiding this comment.
Do we expect these to be the only kinds of actions for automations? If yes, are they actually going to vary by automation or should then just be capabilities at the e.g. host level?
We have ChangesetOperation already which is a richer/more flexible type. When read "AutomationOperation" I initially assume that should be following the same pattern.
There was a problem hiding this comment.
We're at early stage of automations, so a bit hard to say if we expect other actions in future.
are they actually going to vary by automation or should then just be capabilities at the e.g. host level?
If we in future support automations to come for plugins, I would expect those would need to miss the "update" operation? (or any time when we would like an automation to be un-updatable/un-deletable, eg admin policy-driven automations)
| * Values described by {@link AutomationTriggerDefinition.configSchema}. | ||
| * Clients MUST preserve unknown entries when editing other fields. | ||
| */ | ||
| config?: Record<string, unknown>; |
There was a problem hiding this comment.
Would we want additional information from the AutomationTriggerDefinition/AutomationTriggerEventDefinition to aid in display here? Since looking them up again required a ListAutomationTriggerDefinitionsParams method call and potentially some enumeration under the hood...
| workingDirectories?: URI[]; | ||
| /** Opaque host-defined runtime metadata. */ | ||
| _meta?: Record<string, unknown>; | ||
| } |
There was a problem hiding this comment.
I'm unclear on how this is used. Automations already have their own session.workingDirectories, how is this different?
| /** Monotonic definition revision used for optimistic concurrency. */ | ||
| revision: number; |
There was a problem hiding this comment.
this does not appear to actually be used
| export interface PreviewAutomationScheduleParams extends BaseParams { | ||
| /** Schedule preview is requested from the root channel. */ | ||
| channel: 'ahp-root://'; | ||
| /** Portable AHP cron schedule to evaluate. */ | ||
| schedule: AutomationSchedule; | ||
| /** Requested maximum number of future occurrences; the host MAY cap it. */ | ||
| count?: number; | ||
| } |
There was a problem hiding this comment.
I'm unconvinced we need a whole protocol method for this. I would not be opposed to including a test case for cron scheduling in client libraries in this repo (like action tests, we should have a JSON assertion file and then have each language test against that fixture for consistency)
| * | ||
| * @category Automation Run State | ||
| */ | ||
| export type AutomationRunCause = |
There was a problem hiding this comment.
We have the notion of origin's already for message and chat provenance, I suggest we use the same terminology here
| export type AutomationRunCause = | |
| export type AutomationRunOrigin = |
| * | ||
| * @category Automation Run State | ||
| */ | ||
| export const enum AutomationRunOperation { |
There was a problem hiding this comment.
Same Q on operations here -- is this a capability or open ended operation
| * @category Automation Run State | ||
| */ | ||
| export interface AutomationRunArtifact extends ContentRef { | ||
| /** Stable artifact id within this run, used by artifact actions. */ |
There was a problem hiding this comment.
- I don't see any notion of artifact actions in this PR
- These should be unique already by
ContentRef.uri, no need for another ID
| export type AutomationRunLifecycle = | ||
| | AutomationPendingRunLifecycle | ||
| | AutomationRunningRunLifecycle | ||
| | AutomationBlockedRunLifecycle | ||
| | AutomationCompletedRunLifecycle | ||
| | AutomationFailedRunLifecycle | ||
| | AutomationCancelledRunLifecycle; |
There was a problem hiding this comment.
It seems in these we kind of reinvent/mirror the SessionInputRequest / SessionStatus but use slightly different terminology/interfaces. Can we consilidate these?
Summary
Add shared, host-owned Automations to Agent Host Protocol.
The protocol represents:
preview, and retained history;
Multiple clients connected to one authority can share one catalogue, scheduler,
run claim, and history instead of independently scheduling duplicate sessions.
Resource model
ahp-automation:Owns the reusable definition:
ahp-automation-run:Owns one invocation:
Ordinary session/chat channels remain authoritative for transcripts, tools,
confirmations, and changes.
Triggers and execution
time zone.
Unix day-of-month/day-of-week matching.
configuration discovered through
listAutomationTriggerDefinitions.execution.lifetimedistinguishes interactivehostLifetimescheduling fromindependently managed authorities.
runAutomation.requestIdis a durable idempotency key.Cutover-safe imports
createAutomation.importcarries a stable source, batch, and item identity.It may also carry each schedule trigger's next unevaluated source occurrence.
host definition, overdue work follows the trigger's misfire policy.
execution, preventing restart from dispatching the same catch-up twice.
This supports a migration with no interval where both old and new schedulers can
run the same definition.
Commands and synchronization
Adds:
listAutomations;listAutomationTriggerDefinitions;createAutomation;updateAutomation;disposeAutomation;runAutomation;fetchAutomationRuns;previewAutomationSchedule;Presence capabilities use optional objects rather than booleans so they can gain
feature-specific details without changing capability detection.
Generated surfaces
The contract is propagated through JSON Schema, reference documentation,
TypeScript, Rust, Go, Swift, Kotlin, reducer fixtures, and round-trip fixtures.
The guide documents authority, cron semantics, imports, revisions, lifecycle,
cancellation, retention, reconciliation, and security.
Deliberate boundaries
provenance must not be cleared to change client presentation.
Main merge
Merged current AHP
mainthroughd6bf47d2, preserving its scopedcustomization-enablement model. Additive generated-client conflicts were
resolved by updating the Rust generator and regenerating every client/schema.
Validation
npm run generatenpm run testcargo test --workspaceunderclients/rustnpm run docs:buildCompanion implementation
Companion VS Code draft PR:
microsoft/vscode#330463