Files
sam c30624a59e
Quality / check (push) Successful in 4m12s
deploy / gate (push) Successful in 4m42s
deploy / archied-image (push) Successful in 3m13s
deploy / agent-image (push) Successful in 11s
deploy / dist-zip (push) Skipped
feat(workflow): a handoff starts a separate linked run of the next workflow (#1791)
2026-11-03 20:56:03 +11:00

249 lines
8.9 KiB
Protocol Buffer

syntax = "proto3";
package state.v1;
import "google/protobuf/timestamp.proto";
import "state/v1/types.proto";
service TaskService {
rpc EnqueueIssue(EnqueueIssueRequest) returns (EnqueueIssueResponse);
rpc EnqueueChatTask(EnqueueChatTaskRequest) returns (EnqueueChatTaskResponse);
rpc ActiveTasksByOrigin(ActiveTasksByOriginRequest) returns (ActiveTasksByOriginResponse);
// UnpostedOutcomes lists finished chat tasks whose outcome has not yet been
// posted to their conversation; MarkOutcomePosted records that it was.
rpc UnpostedOutcomes(UnpostedOutcomesRequest) returns (UnpostedOutcomesResponse);
rpc MarkOutcomePosted(MarkOutcomePostedRequest) returns (MarkOutcomePostedResponse);
rpc ClaimNext(ClaimNextRequest) returns (ClaimNextResponse);
rpc ClaimByIssue(ClaimByIssueRequest) returns (ClaimByIssueResponse);
rpc Transition(TransitionRequest) returns (TransitionResponse);
rpc Update(UpdateRequest) returns (UpdateResponse);
// TaskModels answers what a task's models resolve against: the aliases its
// org may use and the org's own providers. The org is the task's, never
// the caller's.
rpc TaskModels(TaskModelsRequest) returns (TaskModelsResponse);
// TaskInstructions answers the instance and organisation instructions a
// task's agent runs follow. Organisation is empty for a system-org task.
rpc TaskInstructions(TaskInstructionsRequest) returns (TaskInstructionsResponse);
rpc Requeue(RequeueRequest) returns (RequeueResponse);
rpc ParkTask(ParkTaskRequest) returns (ParkTaskResponse);
rpc RecoverStale(RecoverStaleRequest) returns (RecoverStaleResponse);
rpc ArchiveTask(ArchiveTaskRequest) returns (ArchiveTaskResponse);
rpc RetryTask(RetryTaskRequest) returns (RetryTaskResponse);
rpc TaskByIssue(TaskByIssueRequest) returns (TaskByIssueResponse);
rpc OpenTaskByPR(OpenTaskByPRRequest) returns (OpenTaskByPRResponse);
rpc TaskByID(TaskByIDRequest) returns (TaskByIDResponse);
rpc OpenPRs(OpenPRsRequest) returns (OpenPRsResponse);
rpc ClearTerminalTasks(ClearTerminalTasksRequest) returns (ClearTerminalTasksResponse);
rpc Tasks(TasksRequest) returns (TasksResponse);
// WorkflowCaller: a workflow.call step starts its callee and, with
// wait:true, reads it back while waiting. Both are the one sanctioned
// widening of a task-scoped grant -- the callee is the caller's child
// (docs/prds/workflow-calls.md). CallStatus re-checks the parent-child
// relation server-side, so the grant only names the caller.
rpc EnqueueCallTask(EnqueueCallTaskRequest) returns (EnqueueCallTaskResponse);
// HandoffTask completes a running run and starts its linked successor on
// the same work item under another workflow.
rpc HandoffTask(HandoffTaskRequest) returns (HandoffTaskResponse);
rpc WorkflowCallStatus(WorkflowCallStatusRequest) returns (WorkflowCallStatusResponse);
}
message EnqueueIssueRequest {
string owner = 1;
string repo = 2;
int64 number = 3;
string title = 4;
string body = 5;
string labels = 6;
string identity = 7;
}
message EnqueueIssueResponse { bool inserted = 1; }
message ActiveTasksByOriginRequest { string origin = 1; }
message ActiveTasksByOriginResponse { repeated Task tasks = 1; }
message UnpostedOutcomesRequest {}
message UnpostedOutcomesResponse { repeated Task tasks = 1; }
message MarkOutcomePostedRequest {
int64 task_id = 1;
// status is the task status whose state was posted.
string status = 2;
}
message MarkOutcomePostedResponse {}
message EnqueueChatTaskRequest {
string owner = 1;
string repo = 2;
string title = 3;
string body = 4;
string workflow = 5;
string identity = 6;
// inputs_json assigns workflow inputs, a JSON object of the same form
// EnqueueBindingTaskRequest carries. A chat task sets them at insert
// time: it has no binding provenance to stamp afterwards.
string inputs_json = 7;
// origin names the conversation that created the task; empty for none.
string origin = 8;
// draft_yaml, when set, makes the task a test run of that unsaved
// definition: it is pinned to it and writes nothing to a forge.
string draft_yaml = 9;
}
message EnqueueChatTaskResponse { Task task = 1; }
message ClaimNextRequest {}
message ClaimNextResponse {
Task task = 1;
bool found = 2;
}
message ClaimByIssueRequest {
string owner = 1;
string repo = 2;
int64 number = 3;
}
message ClaimByIssueResponse {
Task task = 1;
bool found = 2;
}
message TransitionRequest {
int64 task_id = 1;
string from = 2;
string to = 3;
string detail = 4;
}
message TransitionResponse {}
message UpdateRequest { Task task = 1; }
message UpdateResponse {}
message RequeueRequest {
int64 task_id = 1;
string from_status = 2;
string workflow = 3;
}
message RequeueResponse {}
message ParkTaskRequest {
int64 task_id = 1;
string from = 2;
string detail = 3;
string class = 4;
string blocker = 5;
}
message ParkTaskResponse {}
message RecoverStaleRequest {}
message RecoverStaleResponse { int64 count = 1; }
message ArchiveTaskRequest {
int64 task_id = 1;
string from_status = 2;
Event audit = 3;
}
message ArchiveTaskResponse { int64 event_id = 1; }
message RetryTaskRequest {
int64 task_id = 1;
string from_status = 2;
string workflow = 3;
// retry_mode is the operator's worktree choice (taskstate.RetryMode) the
// requeue persists. Empty reads as refresh_onto_base.
string retry_mode = 4;
// resume_from is the stage the attempt starts at, and resume_after the
// stage before it whose recorded results it starts with (task.Resume).
string resume_from = 5;
string resume_after = 6;
// current_definition clears the pinned definition so the next dispatch
// pins the workflow's current stored version.
bool current_definition = 7;
}
message RetryTaskResponse {}
message TaskByIssueRequest {
string owner = 1;
string repo = 2;
int64 number = 3;
}
message TaskByIssueResponse {
Task task = 1;
bool found = 2;
}
message OpenTaskByPRRequest {
string owner = 1;
string repo = 2;
int64 number = 3;
}
message OpenTaskByPRResponse {
Task task = 1;
bool found = 2;
}
message TaskByIDRequest { int64 task_id = 1; }
message TaskByIDResponse {
Task task = 1;
bool found = 2;
}
message OpenPRsRequest {}
message OpenPRsResponse { repeated Task tasks = 1; }
message ClearTerminalTasksRequest {}
message ClearTerminalTasksResponse { int64 count = 1; }
// TasksRequest selects one page of tasks, most recently updated first. Empty
// statuses matches every status; after_id 0 starts at the newest task.
message TasksRequest {
int64 limit = 1;
repeated string statuses = 2;
google.protobuf.Timestamp after_updated_at = 3;
int64 after_id = 4;
// workflow, when set, keeps only that workflow's tasks.
string workflow = 5;
}
message TasksResponse { repeated Task tasks = 1; }
// workflow.call: the caller's grant names the caller; the store derives the
// rest from the caller's row (docs/prds/workflow-calls.md).
message EnqueueCallTaskRequest {
int64 caller_task_id = 1;
string workflow = 2;
string inputs_json = 3;
// call_key is the call site's durable identity: the call step's declared
// path within the run, plus the workflow it starts (so one task running a
// second definition at a colliding path does not reuse the first callee's
// child). The store stamps it on the child and, when the caller already
// started a child under it, returns that child instead of starting a second
// one. Required: a retry of one call site carries the same key, so the retry
// cannot duplicate the child's work.
string call_key = 4;
}
message HandoffTaskRequest {
int64 task_id = 1;
string workflow = 2;
string detail = 3;
}
message HandoffTaskResponse { Task task = 1; }
message EnqueueCallTaskResponse {
Task task = 1;
bool accepted = 2;
}
message WorkflowCallStatusRequest {
int64 caller_task_id = 1;
int64 call_task_id = 2;
}
message WorkflowCallStatusResponse {
// status is the callee's task status and detail its latest transition
// detail (empty before the callee first moves). outputs_json is the
// callee's written outputs (task.EncodeOutputs), so a wait:true caller can
// publish one as its own (docs/prds/workflow-call-outputs.md, "Storage and
// wire").
string status = 1;
string detail = 2;
string outputs_json = 3;
}
message TaskModelsRequest { int64 task_id = 1; }
message TaskInstructionsRequest { int64 task_id = 1; }
message TaskInstructionsResponse {
string instance = 1;
string organisation = 2;
}
message TaskModelsResponse {
string org_id = 1;
map<string, string> aliases = 2;
map<string, ModelProvider> providers = 3;
}
// ModelProvider is an org's own provider. Its key is the org's credential
// binding named after it.
message ModelProvider {
string class = 1;
string base_url = 2;
string api_key_env = 3;
// The provider's credential reference: where its key lives, never the key
// itself. A daemon resolves a model egress credential from it; without it
// every provider arrives credential-less and no runtime can be built.
string api_key_engine = 4;
string api_key_key = 5;
}