feat(webui): link parked tasks to the page that fixes their blocker

This commit is contained in:
sam committed 2026-10-17 17:08:24 +11:00
1 parent b96e432841
commit 4e56a9a05f
24 files changed
+214 -50

No files matched your search

+26 -6
View File
@@ -1871,8 +1871,11 @@ type Task struct {
// of the captured event that started a binding task.
BindingSignature string `protobuf:"bytes,46,opt,name=binding_signature,json=bindingSignature,proto3" json:"binding_signature,omitempty"`
BindingAddr string `protobuf:"bytes,47,opt,name=binding_addr,json=bindingAddr,proto3" json:"binding_addr,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
// park_blocker names what a parked task is missing (taskstate.Blocker),
// recorded at the park site; empty when the park has no known fix.
ParkBlocker string `protobuf:"bytes,48,opt,name=park_blocker,json=parkBlocker,proto3" json:"park_blocker,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Task) Reset() {
@@ -2235,6 +2238,13 @@ func (x *Task) GetBindingAddr() string {
return ""
}
func (x *Task) GetParkBlocker() string {
if x != nil {
return x.ParkBlocker
}
return ""
}
// Event mirrors internal/events.Event. Data is carried as a JSON object
// string (matching the store's own on-disk representation) rather than
// google.protobuf.Struct, to stay a direct mirror of the existing column.
@@ -5454,6 +5464,7 @@ type ParkTaskRequest struct {
From string `protobuf:"bytes,2,opt,name=from,proto3" json:"from,omitempty"`
Detail string `protobuf:"bytes,3,opt,name=detail,proto3" json:"detail,omitempty"`
Class string `protobuf:"bytes,4,opt,name=class,proto3" json:"class,omitempty"`
Blocker string `protobuf:"bytes,5,opt,name=blocker,proto3" json:"blocker,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -5516,6 +5527,13 @@ func (x *ParkTaskRequest) GetClass() string {
return ""
}
func (x *ParkTaskRequest) GetBlocker() string {
if x != nil {
return x.Blocker
}
return ""
}
type ParkTaskResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
@@ -19493,7 +19511,7 @@ const file_state_v1_state_proto_rawDesc = "" +
"\x06tokens\x18\x01 \x03(\v2\x17.state.v1.PersonalTokenR\x06tokens\",\n" +
"\x1aRevokePersonalTokenRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\"\x1d\n" +
"\x1bRevokePersonalTokenResponse\"\xb8\f\n" +
"\x1bRevokePersonalTokenResponse\"\xdb\f\n" +
"\x04Task\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x14\n" +
"\x05owner\x18\x02 \x01(\tR\x05owner\x12\x12\n" +
@@ -19556,7 +19574,8 @@ const file_state_v1_state_proto_rawDesc = "" +
"\x06origin\x18, \x01(\tR\x06origin\x12\x1c\n" +
"\tworkspace\x18- \x01(\tR\tworkspace\x12+\n" +
"\x11binding_signature\x18. \x01(\tR\x10bindingSignature\x12!\n" +
"\fbinding_addr\x18/ \x01(\tR\vbindingAddr\"\xf8\x02\n" +
"\fbinding_addr\x18/ \x01(\tR\vbindingAddr\x12!\n" +
"\fpark_blocker\x180 \x01(\tR\vparkBlocker\"\xf8\x02\n" +
"\x05Event\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\x12*\n" +
"\x02at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\x02at\x12\x12\n" +
@@ -19819,12 +19838,13 @@ const file_state_v1_state_proto_rawDesc = "" +
"\vfrom_status\x18\x02 \x01(\tR\n" +
"fromStatus\x12\x1a\n" +
"\bworkflow\x18\x03 \x01(\tR\bworkflow\"\x11\n" +
"\x0fRequeueResponse\"l\n" +
"\x0fRequeueResponse\"\x86\x01\n" +
"\x0fParkTaskRequest\x12\x17\n" +
"\atask_id\x18\x01 \x01(\x03R\x06taskId\x12\x12\n" +
"\x04from\x18\x02 \x01(\tR\x04from\x12\x16\n" +
"\x06detail\x18\x03 \x01(\tR\x06detail\x12\x14\n" +
"\x05class\x18\x04 \x01(\tR\x05class\"\x12\n" +
"\x05class\x18\x04 \x01(\tR\x05class\x12\x18\n" +
"\ablocker\x18\x05 \x01(\tR\ablocker\"\x12\n" +
"\x10ParkTaskResponse\"\x15\n" +
"\x13RecoverStaleRequest\",\n" +
"\x14RecoverStaleResponse\x12\x14\n" +
+27 -4
View File
@@ -1480,7 +1480,7 @@ func (d *Daemon) process(ctx context.Context, task *workflow.Task, hold *taskHol
trees, repo, err := d.taskWorkspace(ctx, task)
if err != nil {
d.parkRunningTask(ctx, task, err.Error(), pinParkClass(err))
d.parkBlockedTask(ctx, task, err.Error(), pinParkClass(err), parkBlocker(err))
return
}
@@ -1801,13 +1801,19 @@ func (d *Daemon) parkCapabilityUnavailable(ctx context.Context, task *workflow.T
// bounded context that ignores cancellation. ErrStaleTransition is ignored;
// other errors are logged.
func (d *Daemon) parkRunningTask(ctx context.Context, task *workflow.Task, reason string, class taskstate.ParkClass) {
d.parkBlockedTask(ctx, task, reason, class, "")
}
// parkBlockedTask is parkRunningTask recording the blocker the park site
// knows, so the dashboard can link to its fix.
func (d *Daemon) parkBlockedTask(ctx context.Context, task *workflow.Task, reason string, class taskstate.ParkClass, blocker taskstate.Blocker) {
if d.Store == nil {
return
}
writeCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 10*time.Second)
defer cancel()
if err := d.Store.ParkTask(writeCtx, task.ID, workflow.StatusRunning, reason, class); err != nil {
if err := d.Store.ParkTask(writeCtx, task.ID, workflow.StatusRunning, reason, class, blocker); err != nil {
if !errors.Is(err, storecontract.ErrStaleTransition) {
d.Log.Warn("terminal park transition failed", "task", task.ID, "reason", reason, "err", err)
}
@@ -1905,7 +1911,7 @@ func (d *Daemon) runViaAgent(ctx context.Context, task *workflow.Task, repo conf
func (d *Daemon) pinTaskProfile(ctx context.Context, task *workflow.Task) (config.AgentProfile, bool) {
if err := d.pinWorkflowDefinition(ctx, task); err != nil {
d.Log.Error("pin workflow definition failed", "task", task.ID, "err", err)
d.parkRunningTask(ctx, task, "pin workflow definition: "+err.Error(), pinParkClass(err))
d.parkBlockedTask(ctx, task, "pin workflow definition: "+err.Error(), pinParkClass(err), parkBlocker(err))
return config.AgentProfile{}, false
}
iface, err := workflowtask.ParseWorkflowInterface(task.WorkflowDefinitionYAML)
@@ -1958,7 +1964,7 @@ func (d *Daemon) pinWorkflowDefinition(ctx context.Context, task *workflow.Task)
return pinFailure{taskstate.ParkTransient, fmt.Errorf("workflow enablement: %w", err)}
}
if !enablement.Enabled(task.Org, task.Workflow) {
return pinFailure{taskstate.ParkNeedsHuman, fmt.Errorf("workflow %s is disabled", task.Workflow)}
return blockedPark{taskstate.BlockerWorkflowDisabled, pinFailure{taskstate.ParkNeedsHuman, fmt.Errorf("workflow %s is disabled", task.Workflow)}}
}
if err := d.checkPackageTrigger(ctx, task); err != nil {
return pinFailure{taskstate.ParkNeedsHuman, err}
@@ -2007,6 +2013,23 @@ func pinParkClass(err error) taskstate.ParkClass {
return taskstate.ParkNeedsHuman
}
// blockedPark names what a park is missing alongside the failure.
type blockedPark struct {
blocker taskstate.Blocker
err error
}
func (e blockedPark) Error() string { return e.err.Error() }
func (e blockedPark) Unwrap() error { return e.err }
// parkBlocker reports the blocker err names, or empty.
func parkBlocker(err error) taskstate.Blocker {
if b, ok := errors.AsType[blockedPark](err); ok {
return b.blocker
}
return ""
}
// pinnedDefinitionID returns the workflow id a task's pin declares, checking
// its digest. ok is false when there is no pin.
func pinnedDefinitionID(task *workflow.Task) (string, bool, error) {
+1 -1
View File
@@ -506,7 +506,7 @@ func (s *stubStore) ClaimNext(context.Context) (*workflow.Task, error) {
func (s *stubStore) Update(context.Context, *workflow.Task) error { return nil }
func (s *stubStore) ParkTask(context.Context, int64, string, string, string) error {
func (s *stubStore) ParkTask(context.Context, int64, string, string, string, string) error {
s.park()
return nil
}
+1 -1
View File
@@ -16,7 +16,7 @@ type parkStore struct {
err error
}
func (s parkStore) ParkTask(context.Context, int64, string, string, taskstate.ParkClass) error {
func (s parkStore) ParkTask(context.Context, int64, string, string, taskstate.ParkClass, taskstate.Blocker) error {
return s.err
}
+13 -12
View File
@@ -26,29 +26,29 @@ import (
func (d *Daemon) adoptWorkflowIdentity(ctx context.Context, task *workflow.Task) bool {
if err := d.pinWorkflowDefinition(ctx, task); err != nil {
d.Log.Error("pin workflow definition failed", "task", task.ID, "err", err)
d.parkRunningTask(ctx, task, "pin workflow definition: "+err.Error(), pinParkClass(err))
d.parkBlockedTask(ctx, task, "pin workflow definition: "+err.Error(), pinParkClass(err), parkBlocker(err))
return false
}
iface, err := workflowtask.ParseWorkflowInterface(task.WorkflowDefinitionYAML)
if err != nil {
d.parkRunningTask(ctx, task, "workflow "+task.Workflow+": "+err.Error(), taskstate.ParkNeedsHuman)
d.parkBlockedTask(ctx, task, "workflow "+task.Workflow+": "+err.Error(), taskstate.ParkNeedsHuman, taskstate.BlockerWorkflowIdentity)
return false
}
if iface.Identity == "" {
d.parkRunningTask(ctx, task, "workflow "+task.Workflow+" declares no identity to run as; set one in its settings", taskstate.ParkNeedsHuman)
d.parkBlockedTask(ctx, task, "workflow "+task.Workflow+" declares no identity to run as; set one in its settings", taskstate.ParkNeedsHuman, taskstate.BlockerWorkflowIdentity)
return false
}
runsAs, runnerName, err := d.declaredIdentity(ctx, task, iface.Identity)
if err != nil {
d.parkRunningTask(ctx, task, "workflow "+task.Workflow+": "+err.Error(), pinParkClass(err))
d.parkBlockedTask(ctx, task, "workflow "+task.Workflow+": "+err.Error(), pinParkClass(err), parkBlocker(err))
return false
}
if !d.mayRunWorkflow(ctx, task, d.publisherIdentity(task.Identity)) {
d.parkRunningTask(ctx, task, "the identity that started it may not run workflow "+task.Workflow, taskstate.ParkNeedsHuman)
d.parkBlockedTask(ctx, task, "the identity that started it may not run workflow "+task.Workflow, taskstate.ParkNeedsHuman, taskstate.BlockerPolicyDenied)
return false
}
if !d.mayRunWorkflow(ctx, task, runsAs) {
d.parkRunningTask(ctx, task, "identity "+iface.Identity+" may not run workflow "+task.Workflow, taskstate.ParkNeedsHuman)
d.parkBlockedTask(ctx, task, "identity "+iface.Identity+" may not run workflow "+task.Workflow, taskstate.ParkNeedsHuman, taskstate.BlockerPolicyDenied)
return false
}
// In memory only: the stored identity stays the starter's, so every
@@ -90,14 +90,15 @@ func (d *Daemon) declaredIdentity(ctx context.Context, task *workflow.Task, ref
func (d *Daemon) databaseExecutionIdentity(ctx context.Context, task *workflow.Task, id identity.IdentityID) (identity.Identity, error) {
value, err := d.IdentityRepository.Get(ctx, id)
if err != nil {
class := taskstate.ParkTransient
failure := pinFailure{taskstate.ParkTransient, fmt.Errorf("resolve execution identity %s: %w", id, err)}
if errors.Is(err, identity.ErrNotFound) {
class = taskstate.ParkNeedsHuman
failure.class = taskstate.ParkNeedsHuman
return identity.Identity{}, blockedPark{taskstate.BlockerAgentAssignment, failure}
}
return identity.Identity{}, pinFailure{class, fmt.Errorf("resolve execution identity %s: %w", id, err)}
return identity.Identity{}, failure
}
if !value.Kind.Agent() || value.Lifecycle != identity.LifecycleActive {
return identity.Identity{}, pinFailure{taskstate.ParkNeedsHuman, fmt.Errorf("execution identity %s must be an active bot or service account", id)}
return identity.Identity{}, blockedPark{taskstate.BlockerAgentAssignment, pinFailure{taskstate.ParkNeedsHuman, fmt.Errorf("execution identity %s must be an active bot or service account", id)}}
}
if d.AgentAssignments == nil {
return identity.Identity{}, pinFailure{taskstate.ParkTransient, fmt.Errorf("agent assignment authority unavailable")}
@@ -111,14 +112,14 @@ func (d *Daemon) databaseExecutionIdentity(ctx context.Context, task *workflow.T
return identity.Identity{}, pinFailure{taskstate.ParkTransient, fmt.Errorf("resolve execution principal: %w", err)}
}
if principal.Org != owner {
return identity.Identity{}, pinFailure{taskstate.ParkNeedsHuman, fmt.Errorf("execution identity belongs to another organisation")}
return identity.Identity{}, blockedPark{taskstate.BlockerAgentAssignment, pinFailure{taskstate.ParkNeedsHuman, fmt.Errorf("execution identity belongs to another organisation")}}
}
assignments, err := d.AgentAssignments.ListOrgAgents(access.WithPrincipal(ctx, principal), owner)
if err != nil {
return identity.Identity{}, pinFailure{taskstate.ParkTransient, fmt.Errorf("resolve execution identity assignment: %w", err)}
}
if !slices.ContainsFunc(assignments, func(a org.AgentAssignment) bool { return a.IdentityID == value.ID && a.OrgID == owner }) {
return identity.Identity{}, pinFailure{taskstate.ParkNeedsHuman, fmt.Errorf("execution identity %s is not assigned to this organisation", id)}
return identity.Identity{}, blockedPark{taskstate.BlockerAgentAssignment, pinFailure{taskstate.ParkNeedsHuman, fmt.Errorf("execution identity %s is not assigned to this organisation", id)}}
}
return value, nil
}
+1 -1
View File
@@ -24,7 +24,7 @@ type identityStore struct {
func (*identityStore) Update(context.Context, *workflow.Task) error { return nil }
func (s *identityStore) ParkTask(context.Context, int64, string, string, taskstate.ParkClass) error {
func (s *identityStore) ParkTask(context.Context, int64, string, string, taskstate.ParkClass, taskstate.Blocker) error {
s.parked = true
return nil
}
@@ -47,10 +47,10 @@ type TaskLifecycle interface {
RecoverStale(ctx context.Context) (int64, error)
}
// TaskParker parks a task with a park class. Unknown classes become
// needs_human.
// TaskParker parks a task with a park class and the blocker the park site
// knows, if any. Unknown classes become needs_human.
type TaskParker interface {
ParkTask(ctx context.Context, taskID int64, from, detail, class string) error
ParkTask(ctx context.Context, taskID int64, from, detail, class, blocker string) error
}
// StepRecorder records a running execution's steps.
+3
View File
@@ -125,6 +125,9 @@ type Task struct {
// park site, never inferred from reason text; needs_human is the
// default an unclassified park reads as.
ParkClass string `json:"park_class"`
// ParkBlocker is what a parked task is missing (taskstate.Blocker), set
// at the park site; empty when no dashboard page fixes it.
ParkBlocker string `json:"park_blocker,omitempty"`
// RemediationRounds counts review-triggered remediation rounds.
RemediationRounds int `json:"remediation_rounds"`
// ReviewGate is the encoded review gate document; empty if the task never
@@ -0,0 +1,7 @@
-- What a parked task is missing, so the dashboard can route to the fix.
-- +goose Up
ALTER TABLE tasks ADD COLUMN park_blocker text NOT NULL DEFAULT '';
-- +goose Down
ALTER TABLE tasks DROP COLUMN park_blocker;
@@ -24,7 +24,7 @@ func (q *Queries) CallStatusDetail(ctx context.Context, taskID int64) (string, e
const enqueueCallTask = `-- name: EnqueueCallTask :one
WITH caller AS (
SELECT t.id, t.owner, t.repo, t.issue_number, t.title, t.body, t.labels, t.status, t.workflow, t.branch, t.plan, t.notes, t.pr_number, t.tokens_used, t.iterations, t.attempt, t.park_reason, t.watch_comment_id, t.park_class, t.remediation_rounds, t.retry_count, t.source, t.identity, t.binding_id, t.binding_version, t.review_payload, t.workflow_definition_version, t.workflow_definition_digest, t.workflow_definition_yaml, t.created_at, t.updated_at, t.review_cursor, t.inputs, t.org_id, t.workspace_id, t.call_parent_task_id, t.call_depth, t.outputs, t.review_gate, t.rereview_rounds, t.retry_mode, t.resume_from, t.resume_results, t.pending_reviews, t.origin, t.call_key, t.outcome_posted, t.binding_signature, t.binding_addr FROM tasks t WHERE t.id = $1 FOR UPDATE
SELECT t.id, t.owner, t.repo, t.issue_number, t.title, t.body, t.labels, t.status, t.workflow, t.branch, t.plan, t.notes, t.pr_number, t.tokens_used, t.iterations, t.attempt, t.park_reason, t.watch_comment_id, t.park_class, t.remediation_rounds, t.retry_count, t.source, t.identity, t.binding_id, t.binding_version, t.review_payload, t.workflow_definition_version, t.workflow_definition_digest, t.workflow_definition_yaml, t.created_at, t.updated_at, t.review_cursor, t.inputs, t.org_id, t.workspace_id, t.call_parent_task_id, t.call_depth, t.outputs, t.review_gate, t.rereview_rounds, t.retry_mode, t.resume_from, t.resume_results, t.pending_reviews, t.origin, t.call_key, t.outcome_posted, t.binding_signature, t.binding_addr, t.park_blocker FROM tasks t WHERE t.id = $1 FOR UPDATE
), number AS (
INSERT INTO chat_issue_numbers (owner, repo, last_number)
SELECT caller.owner, caller.repo, $9::bigint + 1 FROM caller
@@ -43,7 +43,7 @@ SELECT
FROM caller, number
WHERE caller.status = 'running' AND caller.call_depth + 1 <= $8::int
ON CONFLICT (call_parent_task_id, call_key) WHERE call_key <> '' AND status NOT IN ('dead', 'closed_wont_do') DO UPDATE SET call_key = EXCLUDED.call_key
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr, park_blocker
`
type EnqueueCallTaskParams struct {
@@ -135,6 +135,7 @@ func (q *Queries) EnqueueCallTask(ctx context.Context, arg EnqueueCallTaskParams
&i.OutcomePosted,
&i.BindingSignature,
&i.BindingAddr,
&i.ParkBlocker,
)
return i, err
}
@@ -541,6 +541,7 @@ type Task struct {
OutcomePosted bool
BindingSignature string
BindingAddr string
ParkBlocker string
}
type ToolCall struct {
@@ -13,7 +13,7 @@ import (
)
const activeTasksByOrigin = `-- name: ActiveTasksByOrigin :many
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr FROM tasks
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr, park_blocker FROM tasks
WHERE origin = $1 AND origin <> '' AND status IN ('queued', 'running') AND ($2::text IS NULL OR org_id = $2)
ORDER BY id
`
@@ -83,6 +83,7 @@ func (q *Queries) ActiveTasksByOrigin(ctx context.Context, arg ActiveTasksByOrig
&i.OutcomePosted,
&i.BindingSignature,
&i.BindingAddr,
&i.ParkBlocker,
); err != nil {
return nil, err
}
@@ -162,7 +163,7 @@ func (q *Queries) BeginRemediationTask(ctx context.Context, arg BeginRemediation
const claimByIssue = `-- name: ClaimByIssue :one
UPDATE tasks SET status = 'running', attempt = attempt + 1, outputs = '', updated_at = now()
WHERE owner = $1 AND repo = $2 AND issue_number = $3 AND status = 'queued'
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr, park_blocker
`
type ClaimByIssueParams struct {
@@ -226,6 +227,7 @@ func (q *Queries) ClaimByIssue(ctx context.Context, arg ClaimByIssueParams) (Tas
&i.OutcomePosted,
&i.BindingSignature,
&i.BindingAddr,
&i.ParkBlocker,
)
return i, err
}
@@ -240,7 +242,7 @@ WHERE id = (
FOR UPDATE SKIP LOCKED
LIMIT 1
)
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr, park_blocker
`
// FOR UPDATE SKIP LOCKED replaces the SQLite single-writer assumption: two
@@ -302,6 +304,7 @@ func (q *Queries) ClaimNextTask(ctx context.Context) (Task, error) {
&i.OutcomePosted,
&i.BindingSignature,
&i.BindingAddr,
&i.ParkBlocker,
)
return i, err
}
@@ -419,7 +422,7 @@ FROM number, (SELECT COALESCE(
'org-sys'
) AS id) AS owner_org
WHERE $11::text IS NULL OR owner_org.id = $11
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr, park_blocker
`
type InsertChatTaskParams struct {
@@ -515,6 +518,7 @@ func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams)
&i.OutcomePosted,
&i.BindingSignature,
&i.BindingAddr,
&i.ParkBlocker,
)
return i, err
}
@@ -756,15 +760,16 @@ func (q *Queries) MarkOutcomePosted(ctx context.Context, id int64) error {
const parkTask = `-- name: ParkTask :execrows
UPDATE tasks
SET status = 'parked', park_reason = $2, park_class = $3, updated_at = now()
SET status = 'parked', park_reason = $2, park_class = $3, park_blocker = $5, updated_at = now()
WHERE id = $1 AND status = $4
`
type ParkTaskParams struct {
ID int64
ParkReason string
ParkClass string
Status string
ID int64
ParkReason string
ParkClass string
Status string
ParkBlocker string
}
func (q *Queries) ParkTask(ctx context.Context, arg ParkTaskParams) (int64, error) {
@@ -773,6 +778,7 @@ func (q *Queries) ParkTask(ctx context.Context, arg ParkTaskParams) (int64, erro
arg.ParkReason,
arg.ParkClass,
arg.Status,
arg.ParkBlocker,
)
if err != nil {
return 0, err
@@ -986,7 +992,7 @@ func (q *Queries) StampTaskBinding(ctx context.Context, arg StampTaskBindingPara
}
const taskByID = `-- name: TaskByID :one
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr FROM tasks WHERE id = $1 AND ($2::text IS NULL OR org_id = $2)
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr, park_blocker FROM tasks WHERE id = $1 AND ($2::text IS NULL OR org_id = $2)
`
type TaskByIDParams struct {
@@ -1047,12 +1053,13 @@ func (q *Queries) TaskByID(ctx context.Context, arg TaskByIDParams) (Task, error
&i.OutcomePosted,
&i.BindingSignature,
&i.BindingAddr,
&i.ParkBlocker,
)
return i, err
}
const taskByIssue = `-- name: TaskByIssue :one
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr, park_blocker FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3
AND ($4::text IS NULL OR org_id = $4)
`
@@ -1121,12 +1128,13 @@ func (q *Queries) TaskByIssue(ctx context.Context, arg TaskByIssueParams) (Task,
&i.OutcomePosted,
&i.BindingSignature,
&i.BindingAddr,
&i.ParkBlocker,
)
return i, err
}
const taskByPR = `-- name: TaskByPR :one
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3 AND status = $4
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr, park_blocker FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3 AND status = $4
AND ($5::text IS NULL OR org_id = $5)
`
@@ -1200,6 +1208,7 @@ func (q *Queries) TaskByPR(ctx context.Context, arg TaskByPRParams) (Task, error
&i.OutcomePosted,
&i.BindingSignature,
&i.BindingAddr,
&i.ParkBlocker,
)
return i, err
}
@@ -1209,6 +1218,7 @@ UPDATE tasks
SET status = $2,
park_reason = CASE WHEN $2 = 'parked' THEN $3 ELSE park_reason END,
park_class = CASE WHEN $2 = 'parked' THEN $4 ELSE park_class END,
park_blocker = CASE WHEN $2 = 'parked' THEN '' ELSE park_blocker END,
updated_at = now()
WHERE id = $1 AND status = $5
`
@@ -1238,7 +1248,7 @@ func (q *Queries) TransitionTask(ctx context.Context, arg TransitionTaskParams)
}
const unpostedOutcomes = `-- name: UnpostedOutcomes :many
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr FROM tasks
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted, binding_signature, binding_addr, park_blocker FROM tasks
WHERE origin <> '' AND NOT outcome_posted
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed')
AND ($1::text IS NULL OR org_id = $1)
@@ -1306,6 +1316,7 @@ func (q *Queries) UnpostedOutcomes(ctx context.Context, scopeOrg pgtype.Text) ([
&i.OutcomePosted,
&i.BindingSignature,
&i.BindingAddr,
&i.ParkBlocker,
); err != nil {
return nil, err
}
@@ -155,6 +155,7 @@ UPDATE tasks
SET status = $2,
park_reason = CASE WHEN $2 = 'parked' THEN $3 ELSE park_reason END,
park_class = CASE WHEN $2 = 'parked' THEN $4 ELSE park_class END,
park_blocker = CASE WHEN $2 = 'parked' THEN '' ELSE park_blocker END,
updated_at = now()
WHERE id = $1 AND status = $5;
@@ -165,7 +166,7 @@ FROM tasks t WHERE t.id = sqlc.arg(task_id);
-- name: ParkTask :execrows
UPDATE tasks
SET status = 'parked', park_reason = $2, park_class = $3, updated_at = now()
SET status = 'parked', park_reason = $2, park_class = $3, park_blocker = $5, updated_at = now()
WHERE id = $1 AND status = $4;
-- name: ClearTerminalTasks :execrows
+3 -2
View File
@@ -120,6 +120,7 @@ func taskFromRow(t postgresdb.Task) *workflow.Task {
ReviewGate: t.ReviewGate,
RereviewRounds: int(t.RereviewRounds),
ParkClass: t.ParkClass,
ParkBlocker: t.ParkBlocker,
RemediationRounds: int(t.RemediationRounds),
CallParentTaskID: t.CallParentTaskID,
CallDepth: int(t.CallDepth),
@@ -318,7 +319,7 @@ func (s *Store) Transition(ctx context.Context, taskID int64, from, to, detail s
// transition Transition performs, carrying the park class the site chose.
// The park is only legal from running (the transition table), so a stale or
// off-table from is refused before anything is written.
func (s *Store) ParkTask(ctx context.Context, taskID int64, from, detail, class string) error {
func (s *Store) ParkTask(ctx context.Context, taskID int64, from, detail, class, blocker string) error {
tx, err := s.pool.Begin(ctx)
if err != nil {
return err
@@ -331,7 +332,7 @@ func (s *Store) ParkTask(ctx context.Context, taskID int64, from, detail, class
}
n, err := q.ParkTask(ctx, postgresdb.ParkTaskParams{
ID: taskID, ParkReason: clip(detail, 4000),
ParkClass: taskstate.NormalizeParkClass(class), Status: from,
ParkClass: taskstate.NormalizeParkClass(class), Status: from, ParkBlocker: blocker,
})
if err != nil {
return err
+2 -2
View File
@@ -237,8 +237,8 @@ func (c *Client) Requeue(ctx context.Context, taskID int64, fromStatus, wf strin
return unmapError(err)
}
func (c *Client) ParkTask(ctx context.Context, taskID int64, from, detail, class string) error {
_, err := c.client.ParkTask(ctx, &pb.ParkTaskRequest{TaskId: taskID, From: from, Detail: detail, Class: class})
func (c *Client) ParkTask(ctx context.Context, taskID int64, from, detail, class, blocker string) error {
_, err := c.client.ParkTask(ctx, &pb.ParkTaskRequest{TaskId: taskID, From: from, Detail: detail, Class: class, Blocker: blocker})
return unmapError(err)
}
+1 -1
View File
@@ -433,7 +433,7 @@ func (s *server) Requeue(ctx context.Context, r *pb.RequeueRequest) (*pb.Requeue
}
func (s *server) ParkTask(ctx context.Context, r *pb.ParkTaskRequest) (*pb.ParkTaskResponse, error) {
if err := s.deps.Tasks.ParkTask(ctx, r.TaskId, r.From, r.Detail, r.Class); err != nil {
if err := s.deps.Tasks.ParkTask(ctx, r.TaskId, r.From, r.Detail, r.Class, r.Blocker); err != nil {
return nil, s.logErr("ParkTask", err)
}
return &pb.ParkTaskResponse{}, nil
@@ -77,6 +77,7 @@ func taskProto(t *task.Task) *pb.Task { // mirror-image field-by-field proto<->d
RereviewRounds: int64(t.RereviewRounds),
ReviewCursor: t.ReviewCursor,
ParkClass: t.ParkClass,
ParkBlocker: t.ParkBlocker,
RemediationRounds: int32(t.RemediationRounds),
WorkflowDefinitionVersion: t.WorkflowDefinitionVersion,
WorkflowDefinitionDigest: t.WorkflowDefinitionDigest,
@@ -113,6 +114,7 @@ func taskValue(t *pb.Task) *task.Task { // see taskProto above
RereviewRounds: int(t.RereviewRounds),
ReviewCursor: t.ReviewCursor,
ParkClass: t.ParkClass,
ParkBlocker: t.ParkBlocker,
RemediationRounds: int(t.RemediationRounds),
WorkflowDefinitionVersion: t.WorkflowDefinitionVersion,
WorkflowDefinitionDigest: t.WorkflowDefinitionDigest,
+18
View File
@@ -251,6 +251,24 @@ const (
ParkTerminal ParkClass = "terminal"
)
// Blockers: what a parked task is missing, recorded at the park site so the
// dashboard can route an operator to the page that supplies it. Part of the
// on-disk format.
const (
// BlockerWorkflowDisabled: the task's org has the workflow turned off.
BlockerWorkflowDisabled Blocker = "workflow_disabled"
// BlockerWorkflowIdentity: the workflow declares no usable identity.
BlockerWorkflowIdentity Blocker = "workflow_identity"
// BlockerAgentAssignment: the execution identity is inactive or not
// assigned to the task's org.
BlockerAgentAssignment Blocker = "agent_assignment"
// BlockerPolicyDenied: an access policy refuses the run.
BlockerPolicyDenied Blocker = "policy_denied"
)
// Blocker is the persisted park blocker string.
type Blocker = string
// ParkClass is the persisted park classification string.
type ParkClass = string
+4
View File
@@ -39,6 +39,9 @@ type taskAttemptsView struct {
Inputs map[string]any `json:"inputs,omitempty"`
Outputs map[string]any `json:"outputs,omitempty"`
CalledBy int64 `json:"called_by,omitempty"`
// Recovery links a parked task to the page that fixes its blocker,
// present only when the viewer may act there.
Recovery *taskRecoveryView `json:"recovery,omitempty"`
}
// taskAttemptView is one attempt, bounded by its first and last event.
@@ -114,6 +117,7 @@ func (s *Server) handleTaskAttempts(w http.ResponseWriter, r *http.Request) {
Inputs: t.Inputs,
Outputs: t.Outputs,
CalledBy: t.CallParentTaskID,
Recovery: s.taskRecovery(r, t),
})
}
+62
View File
@@ -0,0 +1,62 @@
package webui
import (
"net/http"
"net/url"
"github.com/samcharles93/archie-core/internal/domain/access"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
"github.com/samcharles93/archie-core/internal/taskstate"
)
// taskRecoveryView is the fix for a parked task's blocker: the dashboard page
// that supplies what the task is missing.
type taskRecoveryView struct {
Blocker taskstate.Blocker `json:"blocker"`
Label string `json:"label"`
Link string `json:"link"`
}
// recoveryRoute is where a blocker is fixed: the page, and the API write that
// page makes, which decides whether the viewer may act there.
type recoveryRoute struct {
label, page, method, api string
instance bool
}
func blockerRoute(t *task.Task) (recoveryRoute, bool) {
workflowPage := "/workflows?workflow=" + url.QueryEscape(t.Workflow)
switch t.ParkBlocker {
case taskstate.BlockerWorkflowDisabled:
return recoveryRoute{label: "Enable workflow", page: workflowPage, method: http.MethodPut, api: "/api/workflows/" + url.PathEscape(t.Workflow) + "/enabled"}, true
case taskstate.BlockerWorkflowIdentity:
return recoveryRoute{label: "Set execution identity", page: workflowPage, method: http.MethodPost, api: "/api/control-plane/resources/workflow-definitions/commands/apply"}, true
case taskstate.BlockerAgentAssignment:
return recoveryRoute{label: "Assign agent", page: "/org/agents", method: http.MethodPut, api: "/api/orgs/" + url.PathEscape(t.OrgOrDefault()) + "/agents/_", instance: true}, true
case taskstate.BlockerPolicyDenied:
return recoveryRoute{label: "Edit policies", page: "/org/policies", method: http.MethodPut, api: "/api/access/policies"}, true
}
return recoveryRoute{}, false
}
// taskRecovery returns the recovery link for a parked task, or nil when the
// park names no blocker or the viewer may not make the fixing write.
func (s *Server) taskRecovery(r *http.Request, t *task.Task) *taskRecoveryView {
if t.Status != task.StatusParked || s.Access == nil {
return nil
}
route, ok := blockerRoute(t)
if !ok || (route.instance && !instanceViewer(r)) {
return nil
}
principal, ok := access.PrincipalFromContext(r.Context())
if !ok {
return nil
}
action, kind, id := accessRequest(&http.Request{Method: route.method, URL: &url.URL{Path: route.api}})
resource, err := s.recordResource(r.Context(), kind, id)
if err != nil || !s.Access.Authorize(principal, action, resource, access.Context{}).Allowed {
return nil
}
return &taskRecoveryView{Blocker: t.ParkBlocker, Label: route.label, Link: route.page}
}
+4
View File
@@ -508,6 +508,9 @@ message Task {
// of the captured event that started a binding task.
string binding_signature = 46;
string binding_addr = 47;
// park_blocker names what a parked task is missing (taskstate.Blocker),
// recorded at the park site; empty when the park has no known fix.
string park_blocker = 48;
}
// Event mirrors internal/events.Event. Data is carried as a JSON object
@@ -877,6 +880,7 @@ message ParkTaskRequest {
string from = 2;
string detail = 3;
string class = 4;
string blocker = 5;
}
message ParkTaskResponse {}
+1 -1
View File
@@ -8,7 +8,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
`)}),t}function bd(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 xd(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Sd={class:`[overflow-wrap:anywhere]`},Cd={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},wd={class:`font-mono text-[0.85em]`},Td={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},Ed={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},Dd={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},Od={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},kd={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Ad={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},jd={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},Md={key:8,class:`mb-2.5 last:mb-0`},Nd=k({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=I(()=>yd(t.text));return(e,t)=>(R(),W(`div`,Sd,[(R(!0),W(V,null,G(n.value,(e,t)=>(R(),W(V,{key:t},[e.kind===`pre`?(R(),W(`pre`,Cd,[U(`code`,wd,B(e.code),1)])):e.kind===`table`?(R(),W(`table`,Td,[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(gd,{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(gd,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(R(),W(`blockquote`,Ed,[M(gd,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(R(),W(`h1`,Dd,[M(gd,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(R(),W(`h2`,Od,[M(gd,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(R(),W(`h3`,kd,[M(gd,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(R(),W(`ul`,Ad,[(R(!0),W(V,null,G(e.items,(e,t)=>(R(),W(`li`,{key:t},[M(gd,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(R(),W(`ol`,jd,[(R(!0),W(V,null,G(e.items,(e,t)=>(R(),W(`li`,{key:t},[M(gd,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(R(),W(`p`,Md,[M(gd,{inline:e.inline},null,8,[`inline`])])):L(``,!0)],64))),128))]))}}),Pd={class:`truncate`},Fd=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(xs),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),U(`span`,Pd,B(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),Id={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},Ld={class:`font-semibold text-foreground`},Rd={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},zd=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(Fd,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(R(),W(`div`,Id,[M(z(bc),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),U(`span`,Ld,B(n.value),1),r.value?(R(),W(`code`,Rd,B(r.value),1)):L(``,!0),U(`span`,{class:N(z(J)(`text-fg-muted`,i.value&&`text-danger`))},B(a.value),3)]))}}),Bd={key:0,class:`mb-2 grid gap-0.5 text-xs`},Vd={key:1,class:`mb-2 flex flex-wrap gap-1.5`},Hd={key:3,class:`whitespace-pre-wrap`},Ud=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`,Bd,[(R(!0),W(V,null,G(e.tools,(t,n)=>(R(),K(zd,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):L(``,!0),e.media.length?(R(),W(`div`,Vd,[(R(!0),W(V,null,G(e.media,(e,t)=>(R(),K(ld,{key:t,attachment:e},null,8,[`attachment`]))),128))])):L(``,!0),e.assistant?(R(),K(Nd,{key:2,text:e.text},null,8,[`text`])):(R(),W(`div`,Hd,B(e.text),1)),P(t.$slots,`default`)],2)],2))}}),Wd={class:`text-sm`},Gd={key:0,class:`mt-1 text-fg-muted`},Kd={key:1,class:`mt-2 flex flex-wrap gap-2`},qd=k({__name:`ChatChooseCard`,props:{choose:{}} Line truncated
`).map(e=>e.trim()).find(Boolean)||``,i=r.length>e_?`${r.slice(0,e_).trimEnd()}…`:r;return{text:i,full:n,truncated:i!==n}}function n_(e){return String(e||`event`).replaceAll(`_`,` `).replace(/\b\w/g,e=>e.toUpperCase())}function r_(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 i_(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:t.toLocaleString(`en-US`)}function a_(e){return typeof e==`string`?e:``}function o_(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=r_(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,a_(t.error),a_(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:[a_(t.previous_stage)&&`after ${a_(t.previous_stage)}`,a_(t.previous_reason)].filter(Boolean).join(`: `)||e.detail||``}}if(e.kind===`agent_finish`){let r=i_(t.iterations),i=i_(t.tokens),a=Number(t.cached_tokens)||0,o=i_((Number(t.prompt_tokens)||0)-a),s=i_(t.completion_tokens),c=i_(t.cached_tokens),l=[r&&`${r} iterations`,i&&`${i} tokens`,o&&`${o} fresh prompt`,s&&`${s} completion`,c&&`${c} cached`,a_(t.model)].filter(Boolean);return{title:`Agent ${a_(t.status)||`finished`}: ${n}`,detail:l.join(` · `)||e.detail||``}}if(e.kind===`remediation_round`){let e=Number(t.of),n=a_(t.author);return{title:`Remediation ${a_(t.round)}${e>0?` of ${e}`:``}`,detail:[n&&`answers ${n}'s review`,t.review_id?`#${a_(t.review_id)}`:``].filter(Boolean).join(` `)}}if(e.kind===`review_approved`){let e=a_(t.pr_number);return{title:`Pull request approved`,detail:[a_(t.author),e&&`#${e}`].filter(Boolean).join(` · `)}}if(e.kind===`step_retried`)return{title:`Attempt ${a_(t.attempt)} of ${a_(t.of)} failed: ${e.stage||`step`}`,detail:a_(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=a_(t.source),n=a_(t.capture_id),r=[{label:`binding ${a_(t.binding_name)||a_(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 ${a_(t.captured_after)}`:``].filter(Boolean).join(` · `)}}return{title:n_(e.kind||e.type),detail:e.detail||``}}var s_=[`title`],c_=k({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=$g();n.watchIdentities();let r=e,i=t,a=Hg(),o=I(()=>a.taskIDFor(r.event)),s=I(()=>t_(r.event,n.identityName));function c(){o.value>0&&i(`open`,o.value)}let l=I(()=>r.event.at?xg(r.event.at):`—`);return(e,t)=>(R(),K(z(Yg),{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(o_)({...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,s_)]),_:1}),M(z(Q),null,{default:j(()=>[A(B(l.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),l_=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function u_(e){return(Number(e?.task_id)||0)>0}function d_(e,t){return t===`tasks`?u_(e):t!==`system`||!u_(e)}function f_(e,t){return e.filter(e=>d_(e,t))}function p_(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function m_(e,t){return`${e}:${t??0}`}function h_(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=m_(t_(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 g_={key:0,class:`font-normal text-fg-subtle`},__={role:`region`,"aria-label":`Activity`,"ari Line truncated
`,1)[0]??``;return t.length>80?`${t.slice(0,79)}…`:t}function Pv(e){return(e?.merged||0)+(e?.completed||0)}function Fv(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 Iv(e,t){return e.filter(e=>e.required&&!(t[e.name]??``).trim()).map(e=>e.name)}function Lv(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 Rv(e,t){let n={};for(let r of e){let e=t[r.name];e!==void 0&&e!==``&&(n[r.name]=Lv(e,r.type))}return n}var zv=[`onKeydown`],Bv={key:0,class:`text-sm text-danger`,role:`alert`},Vv={key:1,class:`grid gap-1.5`},Hv=[`for`],Uv={key:0,class:`font-normal text-fg-subtle`},Wv=[`id`],Gv=[`value`],Kv={key:0,class:`text-xs text-fg-subtle`},qv={key:2,class:`grid gap-1.5`},Jv=[`id`],Yv={class:`block truncate font-mono text-[13px] font-medium`},Xv={class:`block text-xs text-fg-subtle`},cee={key:0,class:`text-xs text-fg-subtle`},Zv={key:3,class:`grid gap-3`},Qv=[`for`],$v={class:`font-mono`},ey={key:0,class:`text-fg-subtle`},ty={class:`text-xs text-fg-subtle`},ny={class:`grid gap-1.5`},ry=[`for`],iy={class:`grid gap-1.5`},ay=[`for`],oy={key:4,class:`text-sm text-danger`,role:`alert`},sy={class:`flex items-center gap-2 border-t border-border pt-4`},cy={class:`mr-auto text-xs text-fg-subtle`},ly=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(Nv(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(()=>Fv(m.value)),g=I(()=>Iv(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:Rv(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`,Bv,B(c.value),1)):L(``,!0),_.value===`none`?L(``,!0):(R(),W(`div`,Vv,[U(`label`,{for:`${z(i)}-repo`,class:`text-[13px] font-medium`},[t[5]||=A(`Repository`,-1),v.value?L(``,!0):(R(),W(`span`,Uv,` (optional)`))],8,Hv),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,Gv))),128))],8,Wv),s.value.length?(R(),W(`p`,Kv,[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`,qv,[U(`span`,{id:`${z(i)}-wf`,class:`text-[13px] font-medium`},`Workflow`,8,Jv),M(z(Ta),{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(Da),{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`,Yv,B(e.name||e.id),1),U(`span`,Xv,[A(B(y(e.id)?.runs||0)+` runs`,1),y(e.id)?.runs?(R(),W(V,{key:0},[A(` · `+B(Math.round(z(Pv)(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`,cee,`No enabled workflows.`)):L(``,!0)])),h.value.length?(R(),W(`div`,Zv,[(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`,$v,B(e.name),1),e.required?(R(),W(`span`,ey,` · required`)):L(``,!0)],8, 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 Dy(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 Oy(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 ky(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 Ay(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 jy=q([]),My=q([]),Ny=q(!0),Py=q(null),Fy=q(null),Iy=q(!1),Ly=q(null);async function Ry(){try{let e=await X.eventTypes(Ty().workspace);Ny.value=e.enabled!==!1,jy.value=e.event_types||[],My.value=e.proposals||[],Py.value=null}catch(e){Py.value=e.message||String(e)}}function zy(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function By(e){Ly.value=null,Fy.value=e}function Vy(e){let t=Yy.value.find(t=>String(t.id)===e.sample_id);By({mode:`proposal`,id:null,source:e.source,name:``,rule:zy(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function Hy(e=``){By({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function Uy(e){By({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:zy(e.rule),headersText:``,body:``,exampleHeaders:{}})}function Wy(){Fy.value=null}async function Gy(){let e=Fy.value;if(e){Iy.value=!0;try{if(e.mode===`edit`&&e.id)await X.eventTypeUpdate(e.id,{name:e.name,rule:Ay(e.rule)});else{let t=e.mode===`paste`?Ey(e.headersText):e.exampleHeaders;await X.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:Ay(e.rule),example:{headers:t,body:e.body}})}Fy.value=null,await Ry()}catch(e){Ly.value=e.message||String(e)}finally{Iy.value=!1}}}var Ky=q(null);async function qy(){let e=Ky.value;if(Ky.value=null,e)try{await X.eventTypeDelete(e.id),await Ry()}catch(e){Py.value=e.message||String(e)}}var Jy=100,Yy=q([]),Xy=q(!0),Zy=q(null),Qy=q(!0),$y=q(null);async function eb(){try{let e=await X.captures(Jy);Xy.value=e.enabled!==!1,Yy.value=e.captures||[],Zy.value=null}catch(e){Zy.value=e.message||String(e)}finally{Qy.value=!1}}function tb(e){let t=Yy.value.find(t=>t.id===e);return t&&($y.value=t),!!t}function nb(){Yy.value.length&&($y.value=Yy.value[0])}function rb(){Fe(`captures`,()=>{eb(),Ry()})}var ib=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(_o),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`]))}}),ab=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(bo),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`]))}}),ob=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(xo),H({"data-slot":`tabs-list`,"data-variant":e.variant},z(n),{class:z(J)(z(cb)({variant:e.variant}),t.class)}),{default:j(()=>[P(r.$slots,`default`)]),_:3},16,[`data-variant`,`class`]))}}),sb=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(So),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
`)){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 Dy(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 Oy(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 ky(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 Ay(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 jy=q([]),My=q([]),Ny=q(!0),Py=q(null),Fy=q(null),Iy=q(!1),Ly=q(null);async function Ry(){try{let e=await X.eventTypes(Ty().workspace);Ny.value=e.enabled!==!1,jy.value=e.event_types||[],My.value=e.proposals||[],Py.value=null}catch(e){Py.value=e.message||String(e)}}function zy(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function By(e){Ly.value=null,Fy.value=e}function Vy(e){let t=Yy.value.find(t=>String(t.id)===e.sample_id);By({mode:`proposal`,id:null,source:e.source,name:``,rule:zy(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function Hy(e=``){By({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function Uy(e){By({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:zy(e.rule),headersText:``,body:``,exampleHeaders:{}})}function Wy(){Fy.value=null}async function Gy(){let e=Fy.value;if(e){Iy.value=!0;try{if(e.mode===`edit`&&e.id)await X.eventTypeUpdate(e.id,{name:e.name,rule:Ay(e.rule)});else{let t=e.mode===`paste`?Ey(e.headersText):e.exampleHeaders;await X.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:Ay(e.rule),example:{headers:t,body:e.body}})}Fy.value=null,await Ry()}catch(e){Ly.value=e.message||String(e)}finally{Iy.value=!1}}}var Ky=q(null);async function qy(){let e=Ky.value;if(Ky.value=null,e)try{await X.eventTypeDelete(e.id),await Ry()}catch(e){Py.value=e.message||String(e)}}var Jy=100,Yy=q([]),Xy=q(!0),Zy=q(null),Qy=q(!0),$y=q(null);async function eb(){try{let e=await X.captures(Jy);Xy.value=e.enabled!==!1,Yy.value=e.captures||[],Zy.value=null}catch(e){Zy.value=e.message||String(e)}finally{Qy.value=!1}}function tb(e){let t=Yy.value.find(t=>t.id===e);return t&&($y.value=t),!!t}function nb(){Yy.value.length&&($y.value=Yy.value[0])}function rb(){Fe(`captures`,()=>{eb(),Ry()})}var ib=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(_o),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`]))}}),ab=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(bo),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`]))}}),ob=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(xo),H({"data-slot":`tabs-list`,"data-variant":e.variant},z(n),{class:z(J)(z(cb)({variant:e.variant}),t.class)}),{default:j(()=>[P(r.$slots,`default`)]),_:3},16,[`data-variant`,`class`]))}}),sb=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(So),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
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var $j=zj(`CharSizeService`),eM=zj(`CoreBrowserService`),tM=zj(`MouseService`),nM=zj(`RenderService`),rM=zj(`SelectionService`),iM=zj(`CharacterJoinerService`),aM=zj(`ThemeService`),oM=zj(`LinkProviderService`),sM=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?pM.isErrorNoTelemetry(e)?new pM(e.message+`
+3
View File
@@ -176,6 +176,9 @@ const headerActions = computed(() =>
<AlertDescription>
<p v-if="failure.detail" class="mt-0.5 font-mono text-xs break-words text-fg-muted">{{ failure.detail }}</p>
<p v-if="jumpError" class="mt-1 text-xs" role="alert">{{ jumpError }}</p>
<Button v-if="failure.parked && run.attempts?.recovery" as-child size="sm" class="mt-2">
<RouterLink :to="run.attempts.recovery.link">{{ run.attempts.recovery.label }}</RouterLink>
</Button>
</AlertDescription>
</Alert>
</div>
+2
View File
@@ -92,6 +92,8 @@ export interface AttemptsState {
outputs?: Record<string, unknown>;
/** The task whose workflow.call started this one. */
called_by?: number;
/** The page that fixes a parked task's blocker, when the viewer may act there. */
recovery?: { blocker: string; label: string; link: string };
}
/** One event off the task's stream, as much of it as this page reads. */