feat(taskactions): retry a parked task on the current workflow definition
This commit is contained in:
18 files changed
+134
-58
No files matched your search
@@ -2074,9 +2074,12 @@ type ApplyOperatorTaskActionRequest struct {
|
||||
// and chat carries no mode syntax -- an empty value means refresh_onto_base.
|
||||
RetryMode string `protobuf:"bytes,8,opt,name=retry_mode,json=retryMode,proto3" json:"retry_mode,omitempty"`
|
||||
// resume_from is the stage a retry starts at; empty runs every stage.
|
||||
ResumeFrom string `protobuf:"bytes,9,opt,name=resume_from,json=resumeFrom,proto3" json:"resume_from,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
ResumeFrom string `protobuf:"bytes,9,opt,name=resume_from,json=resumeFrom,proto3" json:"resume_from,omitempty"`
|
||||
// current_definition moves a retry onto the workflow's current stored
|
||||
// definition instead of the one the run is pinned to.
|
||||
CurrentDefinition bool `protobuf:"varint,10,opt,name=current_definition,json=currentDefinition,proto3" json:"current_definition,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ApplyOperatorTaskActionRequest) Reset() {
|
||||
@@ -2172,6 +2175,13 @@ func (x *ApplyOperatorTaskActionRequest) GetResumeFrom() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ApplyOperatorTaskActionRequest) GetCurrentDefinition() bool {
|
||||
if x != nil {
|
||||
return x.CurrentDefinition
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type ApplyOperatorTaskActionResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"`
|
||||
@@ -3988,7 +3998,7 @@ const file_gateway_v1_chat_proto_rawDesc = "" +
|
||||
"\x17ApplyTaskActionResponse\x12\x17\n" +
|
||||
"\atask_id\x18\x01 \x01(\x03R\x06taskId\x12\x16\n" +
|
||||
"\x06action\x18\x02 \x01(\tR\x06action\x12\x18\n" +
|
||||
"\amessage\x18\x03 \x01(\tR\amessage\"\xae\x02\n" +
|
||||
"\amessage\x18\x03 \x01(\tR\amessage\"\xdd\x02\n" +
|
||||
"\x1eApplyOperatorTaskActionRequest\x12\x17\n" +
|
||||
"\atask_id\x18\x01 \x01(\x03R\x06taskId\x12\x16\n" +
|
||||
"\x06action\x18\x02 \x01(\tR\x06action\x12\x19\n" +
|
||||
@@ -4001,7 +4011,9 @@ const file_gateway_v1_chat_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"retry_mode\x18\b \x01(\tR\tretryMode\x12\x1f\n" +
|
||||
"\vresume_from\x18\t \x01(\tR\n" +
|
||||
"resumeFrom\"l\n" +
|
||||
"resumeFrom\x12-\n" +
|
||||
"\x12current_definition\x18\n" +
|
||||
" \x01(\bR\x11currentDefinition\"l\n" +
|
||||
"\x1fApplyOperatorTaskActionResponse\x12\x17\n" +
|
||||
"\atask_id\x18\x01 \x01(\x03R\x06taskId\x12\x16\n" +
|
||||
"\x06action\x18\x02 \x01(\tR\x06action\x12\x18\n" +
|
||||
|
||||
@@ -5746,10 +5746,13 @@ type RetryTaskRequest struct {
|
||||
RetryMode string `protobuf:"bytes,4,opt,name=retry_mode,json=retryMode,proto3" json:"retry_mode,omitempty"`
|
||||
// resume_from is the stage the attempt starts at, and resume_after the
|
||||
// stage before it whose recorded results it starts with (task.Resume).
|
||||
ResumeFrom string `protobuf:"bytes,5,opt,name=resume_from,json=resumeFrom,proto3" json:"resume_from,omitempty"`
|
||||
ResumeAfter string `protobuf:"bytes,6,opt,name=resume_after,json=resumeAfter,proto3" json:"resume_after,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
ResumeFrom string `protobuf:"bytes,5,opt,name=resume_from,json=resumeFrom,proto3" json:"resume_from,omitempty"`
|
||||
ResumeAfter string `protobuf:"bytes,6,opt,name=resume_after,json=resumeAfter,proto3" json:"resume_after,omitempty"`
|
||||
// current_definition clears the pinned definition so the next dispatch
|
||||
// pins the workflow's current stored version.
|
||||
CurrentDefinition bool `protobuf:"varint,7,opt,name=current_definition,json=currentDefinition,proto3" json:"current_definition,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RetryTaskRequest) Reset() {
|
||||
@@ -5824,6 +5827,13 @@ func (x *RetryTaskRequest) GetResumeAfter() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RetryTaskRequest) GetCurrentDefinition() bool {
|
||||
if x != nil {
|
||||
return x.CurrentDefinition
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type RetryTaskResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
@@ -19825,7 +19835,7 @@ const file_state_v1_state_proto_rawDesc = "" +
|
||||
"fromStatus\x12%\n" +
|
||||
"\x05audit\x18\x03 \x01(\v2\x0f.state.v1.EventR\x05audit\"0\n" +
|
||||
"\x13ArchiveTaskResponse\x12\x19\n" +
|
||||
"\bevent_id\x18\x01 \x01(\x03R\aeventId\"\xcb\x01\n" +
|
||||
"\bevent_id\x18\x01 \x01(\x03R\aeventId\"\xfa\x01\n" +
|
||||
"\x10RetryTaskRequest\x12\x17\n" +
|
||||
"\atask_id\x18\x01 \x01(\x03R\x06taskId\x12\x1f\n" +
|
||||
"\vfrom_status\x18\x02 \x01(\tR\n" +
|
||||
@@ -19835,7 +19845,8 @@ const file_state_v1_state_proto_rawDesc = "" +
|
||||
"retry_mode\x18\x04 \x01(\tR\tretryMode\x12\x1f\n" +
|
||||
"\vresume_from\x18\x05 \x01(\tR\n" +
|
||||
"resumeFrom\x12!\n" +
|
||||
"\fresume_after\x18\x06 \x01(\tR\vresumeAfter\"\x13\n" +
|
||||
"\fresume_after\x18\x06 \x01(\tR\vresumeAfter\x12-\n" +
|
||||
"\x12current_definition\x18\a \x01(\bR\x11currentDefinition\"\x13\n" +
|
||||
"\x11RetryTaskResponse\"\x96\x01\n" +
|
||||
"\x18RespondReviewGateRequest\x12\x17\n" +
|
||||
"\atask_id\x18\x01 \x01(\x03R\x06taskId\x12\x1f\n" +
|
||||
|
||||
@@ -95,7 +95,7 @@ type TaskArchiver interface {
|
||||
// is where the attempt starts; a resume whose After stage did not complete in
|
||||
// its last run is refused with ErrResumeIncomplete.
|
||||
type TaskRetryer interface {
|
||||
RetryTask(ctx context.Context, taskID int64, fromStatus, workflow, retryMode string, resume task.Resume) error
|
||||
RetryTask(ctx context.Context, taskID int64, fromStatus, workflow, retryMode string, resume task.Resume, currentDefinition bool) error
|
||||
}
|
||||
|
||||
// ReviewGateResponder records the operator's review-gate answer. A re-review
|
||||
|
||||
@@ -79,6 +79,9 @@ type ActionPayload struct {
|
||||
// ResumeFrom is the stage a retry starts at, keeping the results of the
|
||||
// stages before it. Empty runs every stage.
|
||||
ResumeFrom string
|
||||
// CurrentDefinition moves a retry onto the workflow's current stored
|
||||
// definition rather than the version the run is pinned to.
|
||||
CurrentDefinition bool
|
||||
}
|
||||
|
||||
// Actor is who performed an action and the principal whose authority allowed
|
||||
@@ -182,7 +185,9 @@ type Store interface {
|
||||
Requeue(context.Context, int64, string, string) error
|
||||
// RetryTask requeues a parked task, records the operator's worktree mode
|
||||
// for the next dispatch and increments retry_count in one guarded write.
|
||||
RetryTask(context.Context, int64, string, string, string, workflowtask.Resume) error
|
||||
// currentDefinition drops the run's pinned definition so the next dispatch
|
||||
// pins the workflow's current stored version.
|
||||
RetryTask(context.Context, int64, string, string, string, workflowtask.Resume, bool) error
|
||||
// RespondReviewGate is the guarded review gate response write
|
||||
// (internal/domain/storecontract.ReviewGateResponder): it records the
|
||||
// answered document, and for a re-review increments rereview_rounds and
|
||||
@@ -440,7 +445,7 @@ func (s Service) applyRetry(ctx context.Context, task *Task, actor Actor, o outc
|
||||
if !ok {
|
||||
return o, fmt.Errorf("unknown retry mode %q: %w", requested, ErrConflict)
|
||||
}
|
||||
resume, err := resumePoint(task.Stages, payload.ResumeFrom)
|
||||
resume, err := retryStart(task.Stages, payload)
|
||||
if err != nil {
|
||||
return o, fmt.Errorf("%w: %w", err, ErrConflict)
|
||||
}
|
||||
@@ -468,18 +473,27 @@ func (s Service) applyRetry(ctx context.Context, task *Task, actor Actor, o outc
|
||||
}
|
||||
return o, fmt.Errorf("%w: %s", ErrConflict, reason)
|
||||
}
|
||||
err = s.Store.RetryTask(ctx, task.ID, "parked", "", string(mode), resume)
|
||||
err = s.Store.RetryTask(ctx, task.ID, "parked", "", string(mode), resume, payload.CurrentDefinition)
|
||||
if errors.Is(err, storecontract.ErrResumeIncomplete) {
|
||||
err = fmt.Errorf("%q did not complete in its last run, so there is nothing to resume from: %w", resume.After, ErrConflict)
|
||||
}
|
||||
o.event.Kind, o.event.Detail = events.KindTaskRetried, actor.describe("retried")
|
||||
o.event.Data = map[string]any{"retry_count": task.RetryCount + 1, "previous_reason": task.ParkReason, "retry_mode": string(mode)}
|
||||
o.event.Data = map[string]any{"retry_count": task.RetryCount + 1, "previous_reason": task.ParkReason, "retry_mode": string(mode), "current_definition": payload.CurrentDefinition}
|
||||
if resume.From != "" {
|
||||
o.event.Data["resume_from"] = resume.From
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
// retryStart resolves where a retry starts. Resume stages name steps of the
|
||||
// pinned definition, which a move to the current definition replaces.
|
||||
func retryStart(stages []string, payload ActionPayload) (workflowtask.Resume, error) {
|
||||
if payload.CurrentDefinition && payload.ResumeFrom != "" {
|
||||
return workflowtask.Resume{}, errors.New("a retry on the current definition runs every step")
|
||||
}
|
||||
return resumePoint(stages, payload.ResumeFrom)
|
||||
}
|
||||
|
||||
// resumePoint resolves a resume stage against the pinned definition's stages.
|
||||
// Stage names are how runs are recorded, so a name two stages share cannot
|
||||
// say which one to resume.
|
||||
|
||||
@@ -97,15 +97,16 @@ func (c *Client) ApplyTaskAction(ctx context.Context, identity string, taskID in
|
||||
|
||||
func (c *Client) ApplyOperatorTaskAction(ctx context.Context, actor taskactions.Actor, taskID int64, action taskstate.Action, res taskactions.ActionPayload) (messaging.TaskActionResult, error) {
|
||||
v, err := c.client.ApplyOperatorTaskAction(ctx, &pb.ApplyOperatorTaskActionRequest{
|
||||
TaskId: taskID,
|
||||
Action: string(action),
|
||||
ActorId: string(actor.Identity),
|
||||
ActorKind: string(actor.Kind),
|
||||
PrincipalId: string(actor.Principal),
|
||||
Instructions: res.Instructions,
|
||||
Findings: res.Findings,
|
||||
RetryMode: string(res.RetryMode),
|
||||
ResumeFrom: res.ResumeFrom,
|
||||
TaskId: taskID,
|
||||
Action: string(action),
|
||||
ActorId: string(actor.Identity),
|
||||
ActorKind: string(actor.Kind),
|
||||
PrincipalId: string(actor.Principal),
|
||||
Instructions: res.Instructions,
|
||||
Findings: res.Findings,
|
||||
RetryMode: string(res.RetryMode),
|
||||
ResumeFrom: res.ResumeFrom,
|
||||
CurrentDefinition: res.CurrentDefinition,
|
||||
})
|
||||
if err != nil {
|
||||
return messaging.TaskActionResult{}, taskActionError(err)
|
||||
|
||||
@@ -116,10 +116,11 @@ func (s *server) ApplyOperatorTaskAction(ctx context.Context, r *pb.ApplyOperato
|
||||
Principal: identity.IdentityID(r.PrincipalId),
|
||||
}
|
||||
v, err := s.chat.ApplyOperatorTaskAction(ctx, actor, r.TaskId, taskstate.Action(r.Action), taskactions.ActionPayload{
|
||||
Instructions: r.Instructions,
|
||||
Findings: r.Findings,
|
||||
RetryMode: taskstate.RetryMode(r.RetryMode),
|
||||
ResumeFrom: r.ResumeFrom,
|
||||
Instructions: r.Instructions,
|
||||
Findings: r.Findings,
|
||||
RetryMode: taskstate.RetryMode(r.RetryMode),
|
||||
ResumeFrom: r.ResumeFrom,
|
||||
CurrentDefinition: r.CurrentDefinition,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, taskActionStatus(err)
|
||||
|
||||
@@ -890,17 +890,21 @@ UPDATE tasks SET status = 'queued', retry_count = retry_count + 1,
|
||||
workflow = CASE WHEN $1::text = '' THEN workflow ELSE $1::text END,
|
||||
retry_mode = $2::text,
|
||||
resume_from = $3::text, resume_results = $4::jsonb,
|
||||
workflow_definition_yaml = CASE WHEN $5::bool THEN '' ELSE workflow_definition_yaml END,
|
||||
workflow_definition_digest = CASE WHEN $5::bool THEN '' ELSE workflow_definition_digest END,
|
||||
workflow_definition_version = CASE WHEN $5::bool THEN 0 ELSE workflow_definition_version END,
|
||||
park_reason = '', park_class = 'needs_human', updated_at = now()
|
||||
WHERE id = $5 AND status = $6
|
||||
WHERE id = $6 AND status = $7
|
||||
`
|
||||
|
||||
type RetryTaskParams struct {
|
||||
Workflow string
|
||||
RetryMode string
|
||||
ResumeFrom string
|
||||
ResumeResults []byte
|
||||
ID int64
|
||||
FromStatus string
|
||||
Workflow string
|
||||
RetryMode string
|
||||
ResumeFrom string
|
||||
ResumeResults []byte
|
||||
CurrentDefinition bool
|
||||
ID int64
|
||||
FromStatus string
|
||||
}
|
||||
|
||||
func (q *Queries) RetryTask(ctx context.Context, arg RetryTaskParams) (int64, error) {
|
||||
@@ -909,6 +913,7 @@ func (q *Queries) RetryTask(ctx context.Context, arg RetryTaskParams) (int64, er
|
||||
arg.RetryMode,
|
||||
arg.ResumeFrom,
|
||||
arg.ResumeResults,
|
||||
arg.CurrentDefinition,
|
||||
arg.ID,
|
||||
arg.FromStatus,
|
||||
)
|
||||
|
||||
@@ -258,6 +258,9 @@ UPDATE tasks SET status = 'queued', retry_count = retry_count + 1,
|
||||
workflow = CASE WHEN @workflow::text = '' THEN workflow ELSE @workflow::text END,
|
||||
retry_mode = @retry_mode::text,
|
||||
resume_from = @resume_from::text, resume_results = @resume_results::jsonb,
|
||||
workflow_definition_yaml = CASE WHEN @current_definition::bool THEN '' ELSE workflow_definition_yaml END,
|
||||
workflow_definition_digest = CASE WHEN @current_definition::bool THEN '' ELSE workflow_definition_digest END,
|
||||
workflow_definition_version = CASE WHEN @current_definition::bool THEN 0 ELSE workflow_definition_version END,
|
||||
park_reason = '', park_class = 'needs_human', updated_at = now()
|
||||
WHERE id = @id AND status = @from_status;
|
||||
|
||||
|
||||
@@ -535,9 +535,11 @@ func (s *Store) Requeue(ctx context.Context, taskID int64, fromStatus, wf string
|
||||
// transaction, under the same table check Requeue applies. retryMode is the
|
||||
// operator's worktree choice for the next dispatch; the store persists it
|
||||
// unread so the daemon's prepareWorkspace reads the mode the operator set.
|
||||
// currentDefinition clears the pinned definition so the next dispatch pins
|
||||
// the workflow's current stored version.
|
||||
// A resume copies the results recorded after its After stage onto the row, in
|
||||
// the same transaction, so the attempt starts from what that stage left.
|
||||
func (s *Store) RetryTask(ctx context.Context, taskID int64, fromStatus, wf, retryMode string, resume task.Resume) error {
|
||||
func (s *Store) RetryTask(ctx context.Context, taskID int64, fromStatus, wf, retryMode string, resume task.Resume, currentDefinition bool) error {
|
||||
return s.requeue(ctx, taskID, fromStatus, wf, "retried "+wf, func(q *postgresdb.Queries) (int64, error) {
|
||||
results, err := resumeResults(ctx, q, taskID, resume)
|
||||
if err != nil {
|
||||
@@ -545,7 +547,7 @@ func (s *Store) RetryTask(ctx context.Context, taskID int64, fromStatus, wf, ret
|
||||
}
|
||||
return q.RetryTask(ctx, postgresdb.RetryTaskParams{
|
||||
ID: taskID, Workflow: wf, FromStatus: fromStatus, RetryMode: retryMode,
|
||||
ResumeFrom: resume.From, ResumeResults: results,
|
||||
ResumeFrom: resume.From, ResumeResults: results, CurrentDefinition: currentDefinition,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -260,10 +260,10 @@ func (c *Client) ArchiveTask(ctx context.Context, taskID int64, fromStatus strin
|
||||
return r.EventId, nil
|
||||
}
|
||||
|
||||
func (c *Client) RetryTask(ctx context.Context, taskID int64, fromStatus, wf, retryMode string, resume task.Resume) error {
|
||||
func (c *Client) RetryTask(ctx context.Context, taskID int64, fromStatus, wf, retryMode string, resume task.Resume, currentDefinition bool) error {
|
||||
_, err := c.client.RetryTask(ctx, &pb.RetryTaskRequest{
|
||||
TaskId: taskID, FromStatus: fromStatus, Workflow: wf, RetryMode: retryMode,
|
||||
ResumeFrom: resume.From, ResumeAfter: resume.After,
|
||||
ResumeFrom: resume.From, ResumeAfter: resume.After, CurrentDefinition: currentDefinition,
|
||||
})
|
||||
return unmapError(err)
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ func (s *server) ArchiveTask(ctx context.Context, r *pb.ArchiveTaskRequest) (*pb
|
||||
}
|
||||
|
||||
func (s *server) RetryTask(ctx context.Context, r *pb.RetryTaskRequest) (*pb.RetryTaskResponse, error) {
|
||||
if err := s.deps.Tasks.RetryTask(ctx, r.TaskId, r.FromStatus, r.Workflow, r.RetryMode, task.Resume{From: r.ResumeFrom, After: r.ResumeAfter}); err != nil {
|
||||
if err := s.deps.Tasks.RetryTask(ctx, r.TaskId, r.FromStatus, r.Workflow, r.RetryMode, task.Resume{From: r.ResumeFrom, After: r.ResumeAfter}, r.CurrentDefinition); err != nil {
|
||||
return nil, s.logErr("RetryTask", err)
|
||||
}
|
||||
return &pb.RetryTaskResponse{}, nil
|
||||
|
||||
@@ -36,6 +36,8 @@ type actionRequest struct {
|
||||
Findings []string `json:"findings,omitempty"`
|
||||
RetryMode taskstate.RetryMode `json:"retry_mode,omitempty"`
|
||||
ResumeFrom string `json:"resume_from,omitempty"`
|
||||
// CurrentDefinition moves a retry onto the current stored definition.
|
||||
CurrentDefinition bool `json:"current_definition,omitempty"`
|
||||
}
|
||||
|
||||
type actorPayload struct {
|
||||
@@ -118,10 +120,11 @@ func Register(nc *nats.Conn, service taskactions.Service, log *slog.Logger) (fun
|
||||
return
|
||||
}
|
||||
err := service.Apply(context.Background(), req.Identity, req.Actor.actor(), req.TaskID, req.Action, taskactions.ActionPayload{
|
||||
Instructions: req.Instructions,
|
||||
Findings: req.Findings,
|
||||
RetryMode: req.RetryMode,
|
||||
ResumeFrom: req.ResumeFrom,
|
||||
Instructions: req.Instructions,
|
||||
Findings: req.Findings,
|
||||
RetryMode: req.RetryMode,
|
||||
ResumeFrom: req.ResumeFrom,
|
||||
CurrentDefinition: req.CurrentDefinition,
|
||||
})
|
||||
natsrpc.Respond(msg, log, "taskactions", actionResponse{
|
||||
Envelope: natsrpc.NewEnvelope(err),
|
||||
@@ -149,13 +152,14 @@ func (c Client) ApplyChatTaskAction(ctx context.Context, scope *string, actor ta
|
||||
return gateway.TaskActionResult{}, fmt.Errorf("task action connection is unavailable")
|
||||
}
|
||||
request := actionRequest{
|
||||
Identity: scope,
|
||||
TaskID: id,
|
||||
Action: action,
|
||||
Instructions: res.Instructions,
|
||||
Findings: res.Findings,
|
||||
RetryMode: res.RetryMode,
|
||||
ResumeFrom: res.ResumeFrom,
|
||||
Identity: scope,
|
||||
TaskID: id,
|
||||
Action: action,
|
||||
Instructions: res.Instructions,
|
||||
Findings: res.Findings,
|
||||
RetryMode: res.RetryMode,
|
||||
ResumeFrom: res.ResumeFrom,
|
||||
CurrentDefinition: res.CurrentDefinition,
|
||||
Actor: &actorPayload{
|
||||
ID: string(actor.Identity),
|
||||
Kind: string(actor.Kind),
|
||||
|
||||
@@ -250,6 +250,9 @@ type taskActionRequest struct {
|
||||
RetryMode string `json:"retry_mode"`
|
||||
// ResumeFrom is the step a retry starts at; empty runs every step.
|
||||
ResumeFrom string `json:"resume_from"`
|
||||
// CurrentDefinition moves a retry onto the workflow's current stored
|
||||
// definition.
|
||||
CurrentDefinition bool `json:"current_definition"`
|
||||
}
|
||||
|
||||
func (s *Server) handleTaskAction(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -313,7 +316,7 @@ func decodeTaskAction(w http.ResponseWriter, r *http.Request) (taskstate.Action,
|
||||
http.Error(w, "a re-review needs instructions", http.StatusBadRequest)
|
||||
return "", taskactions.ActionPayload{}, false
|
||||
}
|
||||
return action, taskactions.ActionPayload{Instructions: req.Instructions, Findings: req.Findings, RetryMode: taskstate.RetryMode(req.RetryMode), ResumeFrom: req.ResumeFrom}, true
|
||||
return action, taskactions.ActionPayload{Instructions: req.Instructions, Findings: req.Findings, RetryMode: taskstate.RetryMode(req.RetryMode), ResumeFrom: req.ResumeFrom, CurrentDefinition: req.CurrentDefinition}, true
|
||||
}
|
||||
|
||||
func taskMutation(action taskstate.Action) bool {
|
||||
|
||||
@@ -224,6 +224,9 @@ message ApplyOperatorTaskActionRequest {
|
||||
string retry_mode = 8;
|
||||
// resume_from is the stage a retry starts at; empty runs every stage.
|
||||
string resume_from = 9;
|
||||
// current_definition moves a retry onto the workflow's current stored
|
||||
// definition instead of the one the run is pinned to.
|
||||
bool current_definition = 10;
|
||||
}
|
||||
message ApplyOperatorTaskActionResponse { int64 task_id = 1; string action = 2; string message = 3; }
|
||||
message SaveSessionResponse {}
|
||||
|
||||
@@ -901,6 +901,9 @@ message RetryTaskRequest {
|
||||
// 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 {}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -6,7 +6,7 @@ import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J a
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:bd(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>bd(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
|
||||
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=Sd(c),u=e+1<n.length?Sd(n[e+1]):null;if(l&&u&&Cd(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=Sd(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>bd(e)),rows:r.map(e=>e.map(e=>bd(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:bd(d[2])});continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1])}else c.startsWith(`>`)?(o(),s(),t.push({kind:`blockquote`,inline:bd(c.replace(/^>\s?/,``))})):r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
|
||||
`)}),t}function Sd(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function Cd(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var wd={class:`[overflow-wrap:anywhere]`},Td={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},Ed={class:`font-mono text-[0.85em]`},Dd={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},Od={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},kd={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},Ad={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},jd={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Md={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Nd={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},Pd={key:8,class:`mb-2.5 last:mb-0`},Fd=k({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=I(()=>xd(t.text));return(e,t)=>(R(),W(`div`,wd,[(R(!0),W(V,null,G(n.value,(e,t)=>(R(),W(V,{key:t},[e.kind===`pre`?(R(),W(`pre`,Td,[U(`code`,Ed,B(e.code),1)])):e.kind===`table`?(R(),W(`table`,Dd,[U(`thead`,null,[U(`tr`,null,[(R(!0),W(V,null,G(e.head,(e,t)=>(R(),W(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[M(vd,{inline:e},null,8,[`inline`])]))),128))])]),U(`tbody`,null,[(R(!0),W(V,null,G(e.rows,(e,t)=>(R(),W(`tr`,{key:t},[(R(!0),W(V,null,G(e,(e,t)=>(R(),W(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[M(vd,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(R(),W(`blockquote`,Od,[M(vd,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(R(),W(`h1`,kd,[M(vd,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(R(),W(`h2`,Ad,[M(vd,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(R(),W(`h3`,jd,[M(vd,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(R(),W(`ul`,Md,[(R(!0),W(V,null,G(e.items,(e,t)=>(R(),W(`li`,{key:t},[M(vd,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(R(),W(`ol`,Nd,[(R(!0),W(V,null,G(e.items,(e,t)=>(R(),W(`li`,{key:t},[M(vd,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(R(),W(`p`,Pd,[M(vd,{inline:e.inline},null,8,[`inline`])])):L(``,!0)],64))),128))]))}}),Id={class:`truncate`},Ld=k({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=Be(`RouterLink`);return R(),K(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-md border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:j(()=>[M(z(Ss),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),U(`span`,Id,B(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),Rd={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},zd={class:`font-semibold text-foreground`},Bd={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},Vd=k({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=I(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=I(()=>t.tool.parameters||t.tool.Parameters||``),i=I(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=I(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(R(),K(Ld,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(R(),W(`div`,Rd,[M(z(xc),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),U(`span`,zd,B(n.value),1),r.value?(R(),W(`code`,Bd,B(r.value),1)):L(``,!0),U(`span`,{class:N(z(J)(`text-fg-muted`,i.value&&`text-danger`))},B(a.value),3)]))}}),Hd={key:0,class:`mb-2 grid gap-0.5 text-xs`},Ud={key:1,class:`mb-2 flex flex-wrap gap-1.5`},Wd={key:3,class:`whitespace-pre-wrap`},Gd=k({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(R(),W(`div`,{class:N([`flex`,e.assistant?`justify-start`:`justify-end`])},[U(`div`,{class:N(z(J)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(R(),W(`div`,Hd,[(R(!0),W(V,null,G(e.tools,(t,n)=>(R(),K(Vd,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):L(``,!0),e.media.length?(R(),W(`div`,Ud,[(R(!0),W(V,null,G(e.media,(e,t)=>(R(),K(dd,{key:t,attachment:e},null,8,[`attachment`]))),128))])):L(``,!0),e.assistant?(R(),K(Fd,{key:2,text:e.text},null,8,[`text`])):(R(),W(`div`,Wd,B(e.text),1)),P(t.$slots,`default`)],2)],2))}}),Kd={class:`text-sm`},qd={key:0,class:`mt-1 text-fg-muted`},Jd={key:1,class:`mt-2 flex flex-wrap gap-2`},Yd=k({__name:`ChatChooseCard`,props:{choose:{}}
Line truncated
|
||||
`).map(e=>e.trim()).find(Boolean)||``,i=r.length>n_?`${r.slice(0,n_).trimEnd()}…`:r;return{text:i,full:n,truncated:i!==n}}function i_(e){return String(e||`event`).replaceAll(`_`,` `).replace(/\b\w/g,e=>e.toUpperCase())}function a_(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return``;if(t<1e3)return`under 1 s`;let n=t/1e3;if(n<60)return`${n.toFixed(+(n<10))} s`;let r=Math.round(n),i=Math.floor(r/60),a=r%60;if(i<60)return a===0?`${i} min`:`${i} min ${a} s`;let o=Math.floor(i/60),s=i-o*60;return s===0?`${o} h`:`${o} h ${s} min`}function o_(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:t.toLocaleString(`en-US`)}function s_(e){return typeof e==`string`?e:``}function c_(e={}){let t=e.data||{},n=e.stage||`unknown stage`,r=e.workflow?`${e.workflow} workflow`:``;if(e.kind===`stage_start`)return{title:`Started stage: ${n}`,detail:r};if(e.kind===`stage_finish`){let e=a_(t.duration_ms),i=[r,e&&`ran for ${e}`].filter(Boolean).join(` · `);return{title:t.interrupted?`Stage interrupted: ${n}`:t.skipped?`Skipped stage: ${n}`:t.error?`Stage failed: ${n}`:`Finished stage: ${n}`,detail:[i,s_(t.error),s_(t.when)].filter(Boolean).join(` · `)}}if(e.kind===`task_retried`){let n=Number(t.retry_count);return{title:Number.isFinite(n)&&n>0?`Retry ${n}`:`Retry requested`,detail:[s_(t.previous_stage)&&`after ${s_(t.previous_stage)}`,s_(t.previous_reason)].filter(Boolean).join(`: `)||e.detail||``}}if(e.kind===`agent_finish`){let r=o_(t.iterations),i=o_(t.tokens),a=Number(t.cached_tokens)||0,o=o_((Number(t.prompt_tokens)||0)-a),s=o_(t.completion_tokens),c=o_(t.cached_tokens),l=[r&&`${r} iterations`,i&&`${i} tokens`,o&&`${o} fresh prompt`,s&&`${s} completion`,c&&`${c} cached`,s_(t.model)].filter(Boolean);return{title:`Agent ${s_(t.status)||`finished`}: ${n}`,detail:l.join(` · `)||e.detail||``}}if(e.kind===`remediation_round`){let e=Number(t.of),n=s_(t.author);return{title:`Remediation ${s_(t.round)}${e>0?` of ${e}`:``}`,detail:[n&&`answers ${n}'s review`,t.review_id?`#${s_(t.review_id)}`:``].filter(Boolean).join(` `)}}if(e.kind===`review_approved`){let e=s_(t.pr_number);return{title:`Pull request approved`,detail:[s_(t.author),e&&`#${e}`].filter(Boolean).join(` · `)}}if(e.kind===`step_retried`)return{title:`Attempt ${s_(t.attempt)} of ${s_(t.of)} failed: ${e.stage||`step`}`,detail:s_(t.error),tone:`warn`};if(e.kind===`config_captured`)return{title:`Configuration captured`,detail:`The effective task-runtime configuration for this run.`};if(e.kind===`binding_started`){let e=s_(t.source),n=s_(t.capture_id),r=[{label:`binding ${s_(t.binding_name)||s_(t.binding_id)}`,to:`/events?tab=bindings`},...n?[{label:`captured event`,to:`/events?tab=inspector&capture=${encodeURIComponent(n)}`}]:[]];return t.unsigned===!0?{title:`Started by an unsigned event`,detail:e?`source ${e}`:``,tone:`warn`,links:r}:{title:`Started by an event`,detail:e?`source ${e}`:``,links:r}}if(e.kind===`changes_captured`){let e=t.totals??{},n=Number(e.files);return{title:`Change capture recorded`,detail:[Number.isFinite(n)&&n>0?`${n} file${n===1?``:`s`} changed`:``,t.captured_after?`captured after ${s_(t.captured_after)}`:``].filter(Boolean).join(` · `)}}return{title:i_(e.kind||e.type),detail:e.detail||``}}var l_=[`title`],u_=k({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=t_();n.watchIdentities();let r=e,i=t,a=Wg(),o=I(()=>a.taskIDFor(r.event)),s=I(()=>r_(r.event,n.identityName));function c(){o.value>0&&i(`open`,o.value)}let l=I(()=>r.event.at?Cg(r.event.at):`—`);return(e,t)=>(R(),K(z(Zg),{class:N(o.value>0?`cursor-pointer`:``),role:o.value>0?`link`:void 0,tabindex:o.value>0?0:void 0,title:o.value>0?`Open task details`:void 0,onClick:c,onKeydown:[kt(jt(c,[`prevent`]),[`enter`]),kt(jt(c,[`prevent`]),[`space`])]},{default:j(()=>[M(z(Q),{class:`font-medium`},{default:j(()=>[A(B(z(c_)({...r.event,at:void 0,detail:void 0}).title),1)]),_:1}),M(z(Q),{class:`font-mono`},{default:j(()=>[A(B(o.value>0?`#${o.value}`:`—`),1)]),_:1}),M(z(Q),{class:`w-[55%] max-w-0`},{default:j(()=>[U(`span`,{class:`block truncate`,title:s.value.truncated?s.value.full:void 0},B(s.value.text),9,l_)]),_:1}),M(z(Q),null,{default:j(()=>[A(B(l.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),d_=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function f_(e){return(Number(e?.task_id)||0)>0}function p_(e,t){return t===`tasks`?f_(e):t!==`system`||!f_(e)}function m_(e,t){return e.filter(e=>p_(e,t))}function h_(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function g_(e,t){return`${e}:${t??0}`}function __(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=g_(r_(n).text,r),a=t[t.length-1];a&&a.key===i?(a.count+=1,a.events.push(n)):t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var v_={key:0,class:`font-normal text-fg-subtle`},y_={role:`region`,"aria-label":`Activity`,"ari
Line truncated
|
||||
`).map(e=>e.trim()).find(Boolean)||``,i=r.length>n_?`${r.slice(0,n_).trimEnd()}…`:r;return{text:i,full:n,truncated:i!==n}}function i_(e){return String(e||`event`).replaceAll(`_`,` `).replace(/\b\w/g,e=>e.toUpperCase())}function a_(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return``;if(t<1e3)return`under 1 s`;let n=t/1e3;if(n<60)return`${n.toFixed(+(n<10))} s`;let r=Math.round(n),i=Math.floor(r/60),a=r%60;if(i<60)return a===0?`${i} min`:`${i} min ${a} s`;let o=Math.floor(i/60),s=i-o*60;return s===0?`${o} h`:`${o} h ${s} min`}function o_(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:t.toLocaleString(`en-US`)}function s_(e){return typeof e==`string`?e:``}function c_(e={}){let t=e.data||{},n=e.stage||`unknown stage`,r=e.workflow?`${e.workflow} workflow`:``;if(e.kind===`stage_start`)return{title:`Started stage: ${n}`,detail:r};if(e.kind===`stage_finish`){let e=a_(t.duration_ms),i=[r,e&&`ran for ${e}`].filter(Boolean).join(` · `);return{title:t.interrupted?`Stage interrupted: ${n}`:t.skipped?`Skipped stage: ${n}`:t.error?`Stage failed: ${n}`:`Finished stage: ${n}`,detail:[i,s_(t.error),s_(t.when)].filter(Boolean).join(` · `)}}if(e.kind===`task_retried`){let n=Number(t.retry_count);return{title:Number.isFinite(n)&&n>0?`Retry ${n}`:`Retry requested`,detail:[s_(t.previous_stage)&&`after ${s_(t.previous_stage)}`,s_(t.previous_reason)].filter(Boolean).join(`: `)||e.detail||``}}if(e.kind===`agent_finish`){let r=o_(t.iterations),i=o_(t.tokens),a=Number(t.cached_tokens)||0,o=o_((Number(t.prompt_tokens)||0)-a),s=o_(t.completion_tokens),c=o_(t.cached_tokens),l=[r&&`${r} iterations`,i&&`${i} tokens`,o&&`${o} fresh prompt`,s&&`${s} completion`,c&&`${c} cached`,s_(t.model)].filter(Boolean);return{title:`Agent ${s_(t.status)||`finished`}: ${n}`,detail:l.join(` · `)||e.detail||``}}if(e.kind===`remediation_round`){let e=Number(t.of),n=s_(t.author);return{title:`Remediation ${s_(t.round)}${e>0?` of ${e}`:``}`,detail:[n&&`answers ${n}'s review`,t.review_id?`#${s_(t.review_id)}`:``].filter(Boolean).join(` `)}}if(e.kind===`review_approved`){let e=s_(t.pr_number);return{title:`Pull request approved`,detail:[s_(t.author),e&&`#${e}`].filter(Boolean).join(` · `)}}if(e.kind===`step_retried`)return{title:`Attempt ${s_(t.attempt)} of ${s_(t.of)} failed: ${e.stage||`step`}`,detail:s_(t.error),tone:`warn`};if(e.kind===`config_captured`)return{title:`Configuration captured`,detail:`The effective task-runtime configuration for this run.`};if(e.kind===`binding_started`){let e=s_(t.source),n=s_(t.capture_id),r=[{label:`binding ${s_(t.binding_name)||s_(t.binding_id)}`,to:`/events?tab=bindings`},...n?[{label:`captured event`,to:`/events?tab=inspector&capture=${encodeURIComponent(n)}`}]:[]];return t.unsigned===!0?{title:`Started by an unsigned event`,detail:e?`source ${e}`:``,tone:`warn`,links:r}:{title:`Started by an event`,detail:e?`source ${e}`:``,links:r}}if(e.kind===`changes_captured`){let e=t.totals??{},n=Number(e.files);return{title:`Change capture recorded`,detail:[Number.isFinite(n)&&n>0?`${n} file${n===1?``:`s`} changed`:``,t.captured_after?`captured after ${s_(t.captured_after)}`:``].filter(Boolean).join(` · `)}}return{title:i_(e.kind||e.type),detail:e.detail||``}}var l_=[`title`],u_=k({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=t_();n.watchIdentities();let r=e,i=t,a=Wg(),o=I(()=>a.taskIDFor(r.event)),s=I(()=>r_(r.event,n.identityName));function c(){o.value>0&&i(`open`,o.value)}let l=I(()=>r.event.at?Cg(r.event.at):`—`);return(e,t)=>(R(),K(z(Zg),{class:N(o.value>0?`cursor-pointer`:``),role:o.value>0?`link`:void 0,tabindex:o.value>0?0:void 0,title:o.value>0?`Open task details`:void 0,onClick:c,onKeydown:[kt(jt(c,[`prevent`]),[`enter`]),kt(jt(c,[`prevent`]),[`space`])]},{default:j(()=>[M(z(Q),{class:`font-medium`},{default:j(()=>[A(B(z(c_)({...r.event,at:void 0,detail:void 0}).title),1)]),_:1}),M(z(Q),{class:`font-mono`},{default:j(()=>[A(B(o.value>0?`#${o.value}`:`—`),1)]),_:1}),M(z(Q),{class:`w-[55%] max-w-0`},{default:j(()=>[U(`span`,{class:`block truncate`,title:s.value.truncated?s.value.full:void 0},B(s.value.text),9,l_)]),_:1}),M(z(Q),null,{default:j(()=>[A(B(l.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),d_=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function f_(e){return(Number(e?.task_id)||0)>0}function p_(e,t){return t===`tasks`?f_(e):t!==`system`||!f_(e)}function m_(e,t){return e.filter(e=>p_(e,t))}function h_(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function g_(e,t){return`${e}:${t??0}`}function __(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=g_(r_(n).text,r),a=t[t.length-1];a&&a.key===i?(a.count+=1,a.events.push(n)):t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var v_={key:0,class:`font-normal text-fg-subtle`},y_={role:`region`,"aria-label":`Activity`,"ari
Line truncated
|
||||
`,1)[0]??``;return t.length>80?`${t.slice(0,79)}…`:t}function Iv(e){return(e?.merged||0)+(e?.completed||0)}function Lv(e){return Object.entries(e?.inputs??{}).map(([e,t])=>({name:e,type:t.type,required:t.required===!0})).sort((e,t)=>e.name.localeCompare(t.name))}function Rv(e,t){return e.filter(e=>e.required&&!(t[e.name]??``).trim()).map(e=>e.name)}function zv(e,t){switch(t){case`number`:{let t=e.trim();return t!==``&&!Number.isNaN(Number(t))?Number(t):e}case`bool`:return e===`true`||e!==`false`&&e;case`string`:return e;default:try{return JSON.parse(e)}catch{return e}}}function Bv(e,t){let n={};for(let r of e){let e=t[r.name];e!==void 0&&e!==``&&(n[r.name]=zv(e,r.type))}return n}var Vv=[`onKeydown`],Hv={key:0,class:`text-sm text-danger`,role:`alert`},Uv={key:1,class:`grid gap-1.5`},Wv=[`for`],Gv={key:0,class:`font-normal text-fg-subtle`},Kv=[`id`],qv=[`value`],Jv={key:0,class:`text-xs text-fg-subtle`},Yv={key:2,class:`grid gap-1.5`},Xv=[`id`],Zv={class:`block truncate font-mono text-[13px] font-medium`},Qv={class:`block text-xs text-fg-subtle`},$v={key:0,class:`text-xs text-fg-subtle`},ey={key:3,class:`grid gap-3`},oee=[`for`],ty={class:`font-mono`},ny={key:0,class:`text-fg-subtle`},ry={class:`text-xs text-fg-subtle`},iy={class:`grid gap-1.5`},ay=[`for`],oy={class:`grid gap-1.5`},sy=[`for`],cy={key:4,class:`text-sm text-danger`,role:`alert`},ly={class:`flex items-center gap-2 border-t border-border pt-4`},uy={class:`mr-auto text-xs text-fg-subtle`},dy=k({__name:`NewTaskForm`,props:{workflow:{},draft:{},initialWorkflow:{},initialInstructions:{}},emits:[`started`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=Ue(),a=q([]),o=q([]),s=q([]),c=q(``);ht(async()=>{try{let[e,t]=await Promise.all([X.workflows(),X.repositories()]);a.value=(e?.definitions??[]).filter(e=>e.enabled),o.value=e?.workflows??[],s.value=(t??[]).map(e=>`${e.owner}/${e.name}`)}catch(e){c.value=String(e.message||e)}});let l=q(``),u=q(n.workflow??n.initialWorkflow??``),d=q(n.initialInstructions??``),f=q(Fv(d.value)),p=q({});et(()=>{!u.value&&a.value[0]&&(u.value=a.value[0].id)});let m=I(()=>a.value.find(e=>e.id===u.value)),h=I(()=>Lv(m.value)),g=I(()=>Rv(h.value,p.value)),_=I(()=>m.value?.repository??`required`),v=I(()=>_.value!==`optional`&&_.value!==`none`),y=e=>o.value.find(t=>t.workflow===e),b=q(!1),x=q(``),S=I(()=>!!((l.value.trim()||!v.value)&&u.value&&f.value.trim()&&d.value.trim())&&g.value.length===0);async function C(){if(S.value&&!b.value){b.value=!0,x.value=``;try{let e=await X.workRequest({repository:_.value===`none`?``:l.value.trim(),workflow:u.value,title:f.value.trim(),instructions:d.value,inputs:Bv(h.value,p.value),...n.draft?{draft:n.draft}:{}});r(`started`,e.task_id)}catch(e){x.value=String(e.message||e)}finally{b.value=!1}}}return(e,t)=>(R(),W(`form`,{class:`grid gap-5`,onSubmit:jt(C,[`prevent`]),onKeydown:[kt(jt(C,[`meta`,`prevent`]),[`enter`]),kt(jt(C,[`ctrl`,`prevent`]),[`enter`])]},[c.value?(R(),W(`p`,Hv,B(c.value),1)):L(``,!0),_.value===`none`?L(``,!0):(R(),W(`div`,Uv,[U(`label`,{for:`${z(i)}-repo`,class:`text-[13px] font-medium`},[t[5]||=A(`Repository`,-1),v.value?L(``,!0):(R(),W(`span`,Gv,` (optional)`))],8,Wv),M(z(Z),{id:`${z(i)}-repo`,modelValue:l.value,"onUpdate:modelValue":t[0]||=e=>l.value=e,class:`font-mono`,placeholder:`owner/repository`,list:`${z(i)}-repos`,required:v.value},null,8,[`id`,`modelValue`,`list`,`required`]),U(`datalist`,{id:`${z(i)}-repos`},[(R(!0),W(V,null,G(s.value,e=>(R(),W(`option`,{key:e,value:e},null,8,qv))),128))],8,Kv),s.value.length?(R(),W(`p`,Jv,[t[6]||=A(`Configured: `,-1),(R(!0),W(V,null,G(s.value,e=>(R(),K(z(Y),{key:e,type:`button`,variant:`link`,size:`xs`,class:`h-auto px-1 font-mono text-fg-subtle`,onClick:t=>l.value=e},{default:j(()=>[A(B(e),1)]),_:2},1032,[`onClick`]))),128))])):L(``,!0)])),n.workflow?L(``,!0):(R(),W(`div`,Yv,[U(`span`,{id:`${z(i)}-wf`,class:`text-[13px] font-medium`},`Workflow`,8,Xv),M(z(Ea),{modelValue:u.value,"onUpdate:modelValue":t[1]||=e=>u.value=e,"aria-labelledby":`${z(i)}-wf`,class:`grid grid-cols-1 gap-2 sm:grid-cols-3`,loop:``},{default:j(()=>[(R(!0),W(V,null,G(a.value,e=>(R(),K(z(Oa),{key:e.id,value:e.id,class:`rounded-md border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-secondary focus-visible:outline-2 focus-visible:outline-ring data-[state=checked]:border-primary data-[state=checked]:bg-secondary`},{default:j(()=>[U(`span`,Zv,B(e.name||e.id),1),U(`span`,Qv,[A(B(y(e.id)?.runs||0)+` runs`,1),y(e.id)?.runs?(R(),W(V,{key:0},[A(` · `+B(Math.round(z(Iv)(y(e.id))/(y(e.id)?.runs||1)*100))+`% delivered`,1)],64)):L(``,!0)])]),_:2},1032,[`value`]))),128))]),_:1},8,[`modelValue`,`aria-labelledby`]),!a.value.length&&!c.value?(R(),W(`p`,$v,`No enabled workflows.`)):L(``,!0)])),h.value.length?(R(),W(`div`,ey,[(R(!0),W(V,null,G(h.value,e=>(R(),W(`div`,{key:e.name,class:`grid gap-1.5`},[U(`label`,{for:`${z(i)}-input-${e.name}`,class:`text-[13px] font-medium`},[U(`span`,ty,B(e.name),1),e.required?(R(),W(`span`,ny,` · required`)):L(``,!0)],8,o
Line truncated
|
||||
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function ky(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function Ay(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function jy(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function My(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var Ny=q([]),Py=q([]),Fy=q(!0),Iy=q(null),Ly=q(null),Ry=q(!1),zy=q(null);async function By(){try{let e=await X.eventTypes(Dy().workspace);Fy.value=e.enabled!==!1,Ny.value=e.event_types||[],Py.value=e.proposals||[],Iy.value=null}catch(e){Iy.value=e.message||String(e)}}function Vy(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function Hy(e){zy.value=null,Ly.value=e}function Uy(e){let t=Zy.value.find(t=>String(t.id)===e.sample_id);Hy({mode:`proposal`,id:null,source:e.source,name:``,rule:Vy(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function Wy(e=``){Hy({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function Gy(e){Hy({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:Vy(e.rule),headersText:``,body:``,exampleHeaders:{}})}function Ky(){Ly.value=null}async function qy(){let e=Ly.value;if(e){Ry.value=!0;try{if(e.mode===`edit`&&e.id)await X.eventTypeUpdate(e.id,{name:e.name,rule:My(e.rule)});else{let t=e.mode===`paste`?Oy(e.headersText):e.exampleHeaders;await X.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:My(e.rule),example:{headers:t,body:e.body}})}Ly.value=null,await By()}catch(e){zy.value=e.message||String(e)}finally{Ry.value=!1}}}var Jy=q(null);async function Yy(){let e=Jy.value;if(Jy.value=null,e)try{await X.eventTypeDelete(e.id),await By()}catch(e){Iy.value=e.message||String(e)}}var Xy=100,Zy=q([]),Qy=q(!0),$y=q(null),eb=q(!0),tb=q(null);async function nb(){try{let e=await X.captures(Xy);Qy.value=e.enabled!==!1,Zy.value=e.captures||[],$y.value=null}catch(e){$y.value=e.message||String(e)}finally{eb.value=!1}}function rb(e){let t=Zy.value.find(t=>t.id===e);return t&&(tb.value=t),!!t}function ib(){Zy.value.length&&(tb.value=Zy.value[0])}function ab(){Fe(`captures`,()=>{nb(),By()})}var ob=k({__name:`Tabs`,props:{defaultValue:{},orientation:{},dir:{},activationMode:{},modelValue:{},unmountOnHide:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=It(n,`class`),a=v(i,r);return(e,t)=>(R(),K(z(vo),H({"data-slot":`tabs`,"data-orientation":z(a).orientation||`horizontal`},z(a),{class:z(J)(`gap-2 group/tabs flex data-horizontal:flex-col`,n.class)}),{default:j(t=>[P(e.$slots,`default`,ft(Re(t)))]),_:3},16,[`data-orientation`,`class`]))}}),sb=k({__name:`TabsContent`,props:{value:{},forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=It(t,`class`);return(e,r)=>(R(),K(z(xo),H({"data-slot":`tabs-content`,class:z(J)(`text-sm flex-1 outline-none`,t.class)},z(n)),{default:j(()=>[P(e.$slots,`default`)]),_:3},16,[`class`]))}}),cb=k({__name:`TabsList`,props:{loop:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]},variant:{default:`default`}},setup(e){let t=e,n=It(t,`class`,`variant`);return(r,i)=>(R(),K(z(So),H({"data-slot":`tabs-list`,"data-variant":e.variant},z(n),{class:z(J)(z(ub)({variant:e.variant}),t.class)}),{default:j(()=>[P(r.$slots,`default`)]),_:3},16,[`data-variant`,`class`]))}}),lb=k({__name:`TabsTrigger`,props:{value:{},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=It(t,`class`),r=Ie(n);return(e,n)=>(R(),K(z(Co),H({"data-slot":`tabs-trigger`,class:z(J)(`gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg:not([class*=size-])]:size-4 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointerLine truncated
|
||||
|
||||
|
||||
@@ -255,6 +255,7 @@ export const api = {
|
||||
findings?: string[];
|
||||
retry_mode?: string;
|
||||
resume_from?: string;
|
||||
current_definition?: boolean;
|
||||
},
|
||||
) =>
|
||||
request<T>(`/api/tasks/${encodeURIComponent(id)}/action`, {
|
||||
|
||||
@@ -213,7 +213,12 @@ function request(id: string) {
|
||||
|
||||
async function run(
|
||||
id: string,
|
||||
payload?: { instructions?: string; retry_mode?: string; findings?: string[] },
|
||||
payload?: {
|
||||
instructions?: string;
|
||||
retry_mode?: string;
|
||||
findings?: string[];
|
||||
current_definition?: boolean;
|
||||
},
|
||||
) {
|
||||
if (id === "approve" && gate.value) {
|
||||
if (!props.findings?.length) return;
|
||||
@@ -251,11 +256,14 @@ function onRetryOpen(open: boolean) {
|
||||
retryOpen.value = open;
|
||||
}
|
||||
|
||||
function submitRetry() {
|
||||
// currentDefinition moves the run off its pinned definition onto the
|
||||
// workflow's current stored version, so a definition edit reaches it.
|
||||
function submitRetry(currentDefinition = false) {
|
||||
const id = retryId.value;
|
||||
if (!id || !retryMode.value) return;
|
||||
retryOpen.value = false;
|
||||
void run(id, retryPayload(retryMode.value));
|
||||
const payload = retryPayload(retryMode.value);
|
||||
void run(id, currentDefinition ? { ...payload, current_definition: true } : payload);
|
||||
}
|
||||
|
||||
function onConfirmationOpen(open: boolean) {
|
||||
@@ -420,7 +428,12 @@ function requestFromMenu(id: string) {
|
||||
</RadioGroupRoot>
|
||||
<DialogFooter>
|
||||
<Button variant="ghost" :disabled="inFlight" @click="onRetryOpen(false)">Keep it parked</Button>
|
||||
<Button :disabled="inFlight || !retryMode" @click="submitRetry">Retry</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
:disabled="inFlight || !retryMode"
|
||||
@click="submitRetry(true)"
|
||||
>Retry on current definition</Button>
|
||||
<Button :disabled="inFlight || !retryMode" @click="submitRetry()">Retry</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
Reference in new issue
Block a user