feat(webui): let the operator choose the retry worktree mode

A retry now carries the operator's worktree choice (refresh onto the base
branch or continue the work already pushed on the task branch) from the
dashboard through the task action to the daemon dispatch, and persists it
on the task row so it survives a reload. The daemon resolves the mode from
the task, never from the workflow; BeginRemediation records continue
explicitly so a remediation still resumes its pull request branch.
This commit is contained in:
sam committed 2026-10-02 10:53:21 +10:00
1 parent ef203ce30a
commit 19520a63e5
58 files changed
+977 -252

No files matched your search

+2 -2
View File
@@ -131,11 +131,11 @@ func (f *fakeGateway) Cancel(context.Context, string) (messaging.ChatCancellatio
func (f *fakeGateway) SetPersona(context.Context, string, string) (bool, error) { return false, nil }
func (f *fakeGateway) ApplyTaskAction(context.Context, string, int64, taskstate.Action, taskactions.ReviewResponse) (messaging.TaskActionResult, error) {
func (f *fakeGateway) ApplyTaskAction(context.Context, string, int64, taskstate.Action, taskactions.ActionPayload) (messaging.TaskActionResult, error) {
return messaging.TaskActionResult{}, nil
}
func (f *fakeGateway) ApplyOperatorTaskAction(_ context.Context, actor taskactions.Actor, id int64, action taskstate.Action, _ taskactions.ReviewResponse) (messaging.TaskActionResult, error) {
func (f *fakeGateway) ApplyOperatorTaskAction(_ context.Context, actor taskactions.Actor, id int64, action taskstate.Action, _ taskactions.ActionPayload) (messaging.TaskActionResult, error) {
f.mu.Lock()
defer f.mu.Unlock()
f.actions = append(f.actions, fmt.Sprintf("%d:%s", id, action))
+1 -1
View File
@@ -71,7 +71,7 @@ func (b *boot) setupChatRuntime(ctx context.Context, cfg config.Config) error {
// than its own requeue, so a chat approval and a dashboard approval
// cannot record different decisions for one operator intent
// (docs/prds/pr-review-operator-response.md, Decision 1).
approve: func(ctx context.Context, scope *string, actor taskactions.Actor, taskID int64, res taskactions.ReviewResponse) error {
approve: func(ctx context.Context, scope *string, actor taskactions.Actor, taskID int64, res taskactions.ActionPayload) error {
return b.taskActions().Apply(ctx, scope, actor, taskID, taskstate.ActionApprove, res)
},
cancelExecution: canceller.CancelExecution,
+2 -2
View File
@@ -94,11 +94,11 @@ func (stubGatewayContract) SetPersona(context.Context, string, string) (bool, er
return false, nil
}
func (stubGatewayContract) ApplyTaskAction(context.Context, string, int64, taskstate.Action, taskactions.ReviewResponse) (messaging.TaskActionResult, error) {
func (stubGatewayContract) ApplyTaskAction(context.Context, string, int64, taskstate.Action, taskactions.ActionPayload) (messaging.TaskActionResult, error) {
return messaging.TaskActionResult{}, nil
}
func (stubGatewayContract) ApplyOperatorTaskAction(context.Context, taskactions.Actor, int64, taskstate.Action, taskactions.ReviewResponse) (messaging.TaskActionResult, error) {
func (stubGatewayContract) ApplyOperatorTaskAction(context.Context, taskactions.Actor, int64, taskstate.Action, taskactions.ActionPayload) (messaging.TaskActionResult, error) {
return messaging.TaskActionResult{}, nil
}
+3 -3
View File
@@ -570,7 +570,7 @@ func (a chatTaskWriterAdapter) EnqueueChatTask(
type chatTaskControllerAdapter struct {
taskByID func(context.Context, int64) (*workflow.Task, error)
approve func(context.Context, *string, taskactions.Actor, int64, taskactions.ReviewResponse) error
approve func(context.Context, *string, taskactions.Actor, int64, taskactions.ActionPayload) error
cancelExecution func(context.Context, int64, string, string) ([]int64, error)
}
@@ -597,7 +597,7 @@ func (a chatTaskControllerAdapter) ApproveChatTask(ctx context.Context, taskID i
// authority, and /approve carries no selection syntax, so the review gate
// answer posts every offered finding.
scope := string(actor.Identity)
return a.approve(ctx, &scope, actor, taskID, taskactions.ReviewResponse{})
return a.approve(ctx, &scope, actor, taskID, taskactions.ActionPayload{})
}
func (a chatTaskControllerAdapter) CancelChatTask(ctx context.Context, taskID int64, reason string) error {
@@ -702,7 +702,7 @@ type chatTaskActorAdapter struct {
}
func (a chatTaskActorAdapter) ApplyChatTaskAction(
ctx context.Context, identity *string, actor taskactions.Actor, taskID int64, action taskstate.Action, res taskactions.ReviewResponse,
ctx context.Context, identity *string, actor taskactions.Actor, taskID int64, action taskstate.Action, res taskactions.ActionPayload,
) (gateway.TaskActionResult, error) {
if a.contract == nil {
return gateway.TaskActionResult{}, gateway.ErrChatCapabilityUnavailable
+3 -3
View File
@@ -734,13 +734,13 @@ func TestChatTaskControllerAdapterTransitions(t *testing.T) {
task := &workflow.Task{ID: 42, Source: workflow.SourceChat, Status: workflow.StatusWaitingHuman}
var approveScope string
var approveActor taskactions.Actor
var approveRes taskactions.ReviewResponse
var approveRes taskactions.ActionPayload
var cancelReason, cancelTo string
adapter := chatTaskControllerAdapter{
taskByID: func(context.Context, int64) (*workflow.Task, error) { return task, nil },
// Chat's approval reaches the daemon's one task-action service, not
// its own requeue: this records what the adapter hands it.
approve: func(_ context.Context, scope *string, actor taskactions.Actor, _ int64, res taskactions.ReviewResponse) error {
approve: func(_ context.Context, scope *string, actor taskactions.Actor, _ int64, res taskactions.ActionPayload) error {
if scope != nil {
approveScope = *scope
}
@@ -916,7 +916,7 @@ func TestChatTaskCommandsEndToEnd(t *testing.T) {
actions := taskactionstore.NewService(taskactionstore.Store{TaskStore: st}, nil, nil, nil, nil, nil, nil, nil)
controller := gateway.NewStoreTaskController(chatTaskControllerAdapter{
taskByID: st.TaskByID,
approve: func(ctx context.Context, scope *string, actor taskactions.Actor, taskID int64, res taskactions.ReviewResponse) error {
approve: func(ctx context.Context, scope *string, actor taskactions.Actor, taskID int64, res taskactions.ActionPayload) error {
return actions.Apply(ctx, scope, actor, taskID, taskstate.ActionApprove, res)
},
cancelExecution: st.CancelExecution,
@@ -24,7 +24,7 @@ import (
type testTaskActor struct{ b *boot }
func (a testTaskActor) ApplyChatTaskAction(
ctx context.Context, identity *string, actor taskactions.Actor, taskID int64, action taskstate.Action, res taskactions.ReviewResponse,
ctx context.Context, identity *string, actor taskactions.Actor, taskID int64, action taskstate.Action, res taskactions.ActionPayload,
) (gateway.TaskActionResult, error) {
if err := a.b.taskActions().Apply(ctx, identity, actor, taskID, action, res); err != nil {
return gateway.TaskActionResult{}, err
@@ -84,7 +84,7 @@ func TestChatTaskActorAdapterCrossIdentityRefused(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
_, err := adapter.ApplyChatTaskAction(ctx, &tc.actorIdentity, taskactions.Actor{}, task.ID, tc.action, taskactions.ReviewResponse{})
_, err := adapter.ApplyChatTaskAction(ctx, &tc.actorIdentity, taskactions.Actor{}, task.ID, tc.action, taskactions.ActionPayload{})
if err == nil {
t.Fatalf("ApplyChatTaskAction() allowed cross-identity action %s by %q on task owned by %q",
tc.action, tc.actorIdentity, task.Identity)
@@ -152,7 +152,7 @@ func TestChatTaskActorAdapterRefusesDisallowedStateAction(t *testing.T) {
}
taskstatetest.Seed(ctx, t, st, task.ID, workflow.StatusQueued, tc.initialStatus, "setup")
_, err = adapter.ApplyChatTaskAction(ctx, new("archie"), taskactions.Actor{}, task.ID, tc.attemptAction, taskactions.ReviewResponse{})
_, err = adapter.ApplyChatTaskAction(ctx, new("archie"), taskactions.Actor{}, task.ID, tc.attemptAction, taskactions.ActionPayload{})
if err == nil {
t.Fatalf("expected error attempting %s on %s task, got nil", tc.attemptAction, tc.initialStatus)
}
@@ -182,7 +182,7 @@ func TestChatTaskActorAdapterTaskNotFound(t *testing.T) {
adapter := newChatTaskActorForTest(t, st, config.Config{})
_, err := adapter.ApplyChatTaskAction(ctx, new("archie"), taskactions.Actor{}, 999999, taskstate.ActionAbandon, taskactions.ReviewResponse{})
_, err := adapter.ApplyChatTaskAction(ctx, new("archie"), taskactions.Actor{}, 999999, taskstate.ActionAbandon, taskactions.ActionPayload{})
if err == nil {
t.Fatal("expected error for non-existent task, got nil")
}
@@ -257,7 +257,7 @@ func TestChatTaskActorAdapterAppliesActionsToStore(t *testing.T) {
}
taskstatetest.Seed(ctx, t, st, task.ID, workflow.StatusQueued, tc.initialStatus, "setup")
result, err := adapter.ApplyChatTaskAction(ctx, new("archie"), taskactions.Actor{}, task.ID, tc.action, taskactions.ReviewResponse{})
result, err := adapter.ApplyChatTaskAction(ctx, new("archie"), taskactions.Actor{}, task.ID, tc.action, taskactions.ActionPayload{})
if err != nil {
t.Fatalf("ApplyChatTaskAction(%s) error = %v", tc.action, err)
}
@@ -292,7 +292,7 @@ func TestChatTaskActorAdapterNilContract(t *testing.T) {
ctx := context.Background()
adapter := chatTaskActorAdapter{contract: nil}
_, err := adapter.ApplyChatTaskAction(ctx, new("archie"), taskactions.Actor{}, 1, taskstate.ActionAbandon, taskactions.ReviewResponse{})
_, err := adapter.ApplyChatTaskAction(ctx, new("archie"), taskactions.Actor{}, 1, taskstate.ActionAbandon, taskactions.ActionPayload{})
if err == nil {
t.Fatal("expected error for nil contract, got nil")
}
+1 -1
View File
@@ -88,7 +88,7 @@ func runChatAction(t *testing.T, ctx context.Context, st storecontract.TaskStore
actions := taskactionstore.NewService(taskactionstore.Store{TaskStore: st}, nil, nil, nil, nil, nil, nil, nil)
controller := gateway.NewStoreTaskController(chatTaskControllerAdapter{
taskByID: st.TaskByID,
approve: func(ctx context.Context, scope *string, actor taskactions.Actor, taskID int64, res taskactions.ReviewResponse) error {
approve: func(ctx context.Context, scope *string, actor taskactions.Actor, taskID int64, res taskactions.ActionPayload) error {
return actions.Apply(ctx, scope, actor, taskID, taskstate.ActionApprove, res)
},
cancelExecution: canceller.CancelExecution,
+2 -2
View File
@@ -72,11 +72,11 @@ func (f *fakeChat) Cancel(context.Context, string) (gateway.ChatCancellation, er
func (f *fakeChat) SetPersona(context.Context, string, string) (bool, error) { return false, nil }
func (f *fakeChat) ApplyTaskAction(context.Context, string, int64, taskstate.Action, taskactions.ReviewResponse) (gateway.TaskActionResult, error) {
func (f *fakeChat) ApplyTaskAction(context.Context, string, int64, taskstate.Action, taskactions.ActionPayload) (gateway.TaskActionResult, error) {
return gateway.TaskActionResult{}, nil
}
func (f *fakeChat) ApplyOperatorTaskAction(context.Context, taskactions.Actor, int64, taskstate.Action, taskactions.ReviewResponse) (gateway.TaskActionResult, error) {
func (f *fakeChat) ApplyOperatorTaskAction(context.Context, taskactions.Actor, int64, taskstate.Action, taskactions.ActionPayload) (gateway.TaskActionResult, error) {
return gateway.TaskActionResult{}, nil
}
+2 -2
View File
@@ -82,10 +82,10 @@ func (f *fakeChatContract) SetPersona(ctx context.Context, id, name string) (boo
return true, nil
}
func (f *fakeChatContract) ApplyTaskAction(ctx context.Context, identity string, taskID int64, action taskstate.Action, _ taskactions.ReviewResponse) (messaging.TaskActionResult, error) {
func (f *fakeChatContract) ApplyTaskAction(ctx context.Context, identity string, taskID int64, action taskstate.Action, _ taskactions.ActionPayload) (messaging.TaskActionResult, error) {
return messaging.TaskActionResult{}, nil
}
func (f *fakeChatContract) ApplyOperatorTaskAction(ctx context.Context, actor taskactions.Actor, taskID int64, action taskstate.Action, _ taskactions.ReviewResponse) (messaging.TaskActionResult, error) {
func (f *fakeChatContract) ApplyOperatorTaskAction(ctx context.Context, actor taskactions.Actor, taskID int64, action taskstate.Action, _ taskactions.ActionPayload) (messaging.TaskActionResult, error) {
return messaging.TaskActionResult{}, nil
}
+19 -5
View File
@@ -1703,11 +1703,16 @@ type ApplyOperatorTaskActionRequest struct {
ActorKind string `protobuf:"bytes,4,opt,name=actor_kind,json=actorKind,proto3" json:"actor_kind,omitempty"`
PrincipalId string `protobuf:"bytes,5,opt,name=principal_id,json=principalId,proto3" json:"principal_id,omitempty"`
// instructions and findings are the review gate answer payload
// (taskactions.ReviewResponse): the instructions a rereview requires, and
// (taskactions.ActionPayload): the instructions a rereview requires, and
// the finding keys an approve posts (empty means every offered finding).
// They are empty for every other action.
Instructions string `protobuf:"bytes,6,opt,name=instructions,proto3" json:"instructions,omitempty"`
Findings []string `protobuf:"bytes,7,rep,name=findings,proto3" json:"findings,omitempty"`
Instructions string `protobuf:"bytes,6,opt,name=instructions,proto3" json:"instructions,omitempty"`
Findings []string `protobuf:"bytes,7,rep,name=findings,proto3" json:"findings,omitempty"`
// retry_mode is the operator's worktree choice for a retry
// (taskstate.RetryMode): refresh onto the base branch or continue the work
// already pushed on the task's branch. It is empty for every other action,
// 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"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -1791,6 +1796,13 @@ func (x *ApplyOperatorTaskActionRequest) GetFindings() []string {
return nil
}
func (x *ApplyOperatorTaskActionRequest) GetRetryMode() string {
if x != nil {
return x.RetryMode
}
return ""
}
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"`
@@ -3022,7 +3034,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\"\xee\x01\n" +
"\amessage\x18\x03 \x01(\tR\amessage\"\x8d\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" +
@@ -3031,7 +3043,9 @@ const file_gateway_v1_chat_proto_rawDesc = "" +
"actor_kind\x18\x04 \x01(\tR\tactorKind\x12!\n" +
"\fprincipal_id\x18\x05 \x01(\tR\vprincipalId\x12\"\n" +
"\finstructions\x18\x06 \x01(\tR\finstructions\x12\x1a\n" +
"\bfindings\x18\a \x03(\tR\bfindings\"l\n" +
"\bfindings\x18\a \x03(\tR\bfindings\x12\x1d\n" +
"\n" +
"retry_mode\x18\b \x01(\tR\tretryMode\"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" +
+37 -10
View File
@@ -1354,8 +1354,14 @@ type Task struct {
// from retry_count and remediation_rounds for the same reason those are
// separate from each other.
RereviewRounds int64 `protobuf:"varint,40,opt,name=rereview_rounds,json=rereviewRounds,proto3" json:"rereview_rounds,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
// retry_mode is the operator's worktree choice for the next dispatch
// (taskstate.RetryMode: refresh_onto_base, continue_pushed_work). The retry
// action writes it and the daemon's prepareWorkspace reads it, so it must
// cross the wire for a retry to land on the source the operator chose. The
// empty string reads as refresh_onto_base.
RetryMode string `protobuf:"bytes,41,opt,name=retry_mode,json=retryMode,proto3" json:"retry_mode,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Task) Reset() {
@@ -1669,6 +1675,13 @@ func (x *Task) GetRereviewRounds() int64 {
return 0
}
func (x *Task) GetRetryMode() string {
if x != nil {
return x.RetryMode
}
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.
@@ -4811,10 +4824,13 @@ func (x *ArchiveTaskResponse) GetEventId() int64 {
}
type RetryTaskRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"`
FromStatus string `protobuf:"bytes,2,opt,name=from_status,json=fromStatus,proto3" json:"from_status,omitempty"`
Workflow string `protobuf:"bytes,3,opt,name=workflow,proto3" json:"workflow,omitempty"`
state protoimpl.MessageState `protogen:"open.v1"`
TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"`
FromStatus string `protobuf:"bytes,2,opt,name=from_status,json=fromStatus,proto3" json:"from_status,omitempty"`
Workflow string `protobuf:"bytes,3,opt,name=workflow,proto3" json:"workflow,omitempty"`
// retry_mode is the operator's worktree choice (taskstate.RetryMode) the
// requeue persists. Empty reads as refresh_onto_base.
RetryMode string `protobuf:"bytes,4,opt,name=retry_mode,json=retryMode,proto3" json:"retry_mode,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -4870,6 +4886,13 @@ func (x *RetryTaskRequest) GetWorkflow() string {
return ""
}
func (x *RetryTaskRequest) GetRetryMode() string {
if x != nil {
return x.RetryMode
}
return ""
}
type RetryTaskResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
@@ -12108,7 +12131,7 @@ const file_state_v1_state_proto_rawDesc = "" +
"\asubject\x18\x03 \x01(\tR\asubject\x12-\n" +
"\x05audit\x18\x04 \x01(\v2\x17.state.v1.IdentityAuditR\x05audit\"M\n" +
"\x1bBindIdentitySubjectResponse\x12.\n" +
"\bidentity\x18\x01 \x01(\v2\x12.state.v1.IdentityR\bidentity\"\xcb\n" +
"\bidentity\x18\x01 \x01(\v2\x12.state.v1.IdentityR\bidentity\"\xea\n" +
"\n" +
"\x04Task\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x14\n" +
@@ -12163,7 +12186,9 @@ const file_state_v1_state_proto_rawDesc = "" +
"\foutputs_json\x18& \x01(\tR\voutputsJson\x12\x1f\n" +
"\vreview_gate\x18' \x01(\tR\n" +
"reviewGate\x12'\n" +
"\x0frereview_rounds\x18( \x01(\x03R\x0erereviewRounds\"\xf8\x02\n" +
"\x0frereview_rounds\x18( \x01(\x03R\x0erereviewRounds\x12\x1d\n" +
"\n" +
"retry_mode\x18) \x01(\tR\tretryMode\"\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" +
@@ -12418,12 +12443,14 @@ 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\"h\n" +
"\bevent_id\x18\x01 \x01(\x03R\aeventId\"\x87\x01\n" +
"\x10RetryTaskRequest\x12\x17\n" +
"\atask_id\x18\x01 \x01(\x03R\x06taskId\x12\x1f\n" +
"\vfrom_status\x18\x02 \x01(\tR\n" +
"fromStatus\x12\x1a\n" +
"\bworkflow\x18\x03 \x01(\tR\bworkflow\"\x13\n" +
"\bworkflow\x18\x03 \x01(\tR\bworkflow\x12\x1d\n" +
"\n" +
"retry_mode\x18\x04 \x01(\tR\tretryMode\"\x13\n" +
"\x11RetryTaskResponse\"\x96\x01\n" +
"\x18RespondReviewGateRequest\x12\x17\n" +
"\atask_id\x18\x01 \x01(\x03R\x06taskId\x12\x1f\n" +
+12 -24
View File
@@ -1485,25 +1485,24 @@ func (d *Daemon) prepareWorkspace(ctx context.Context, task *workflow.Task, tree
}
return dir, true
}
// The retry path selects the worktree mode from the task row. A task that
// continues an already-open PR branch -- the remediate workflow -- resumes
// that branch's remote tip instead of resetting onto base: preparing one
// the ordinary way discarded the commits the implement run had already
// pushed, so the agent remediated a PR from a tree that no longer contained
// it. Every other task starts fresh on base. This runs before Acquire,
// The retry action writes the worktree mode onto the task row
// (taskstate.RetryMode): continue_pushed_work resumes the branch the task
// already pushed, refresh_onto_base resets onto base. The mode is never
// inferred here from the workflow -- the reaction consumer writes
// continue_pushed_work when it queues a remediation, so every path that
// needs a resume records that choice explicitly. This runs before Acquire,
// because the daemon holds the forge credential that fetches the branch and
// the container must find the PR's work already in place. It also runs on a
// the container must find the work already in place. It also runs on a
// retry whose local worktree is gone: Prepare clones a missing worktree for
// either target, which is how a resume reaches a task whose clone the
// terminal cleanup removed.
target := worktree.Fresh
if continuesOpenPRBranch(task) {
if taskstate.NormalizeRetryMode(task.RetryMode) == taskstate.RetryContinuePushedWork {
if task.Branch == "" {
// A remediation task is queued against the branch its implement
// run pushed, so an empty branch is a dispatch bug upstream and no
// retry can fix it.
d.Log.Error("remediate task has no persisted branch", "task", task.ID)
d.parkRunningTask(ctx, task.ID, "worktree resume failed: remediate task has no branch to resume", taskstate.ParkNeedsHuman)
// The action refuses this combination, so an empty branch here is a
// dispatch bug upstream and no retry can fix it.
d.Log.Error("task has no persisted branch to continue", "task", task.ID)
d.parkRunningTask(ctx, task.ID, "worktree resume failed: task has no branch to continue", taskstate.ParkNeedsHuman)
return "", false
}
target = worktree.Target(task.Branch)
@@ -1530,17 +1529,6 @@ func (d *Daemon) prepareWorkspace(ctx context.Context, task *workflow.Task, tree
return dir, true
}
// continuesOpenPRBranch reports whether the task must continue a branch archie
// already pushed rather than start from base. Only the remediate workflow does:
// it addresses review feedback on an open archie-owned PR and reuses that PR's
// branch (docs/prds/pr-review-remediation.md decision 4), while every other
// workflow starts fresh work. The workflow is read from the task row, where the
// reaction consumer wrote it before queueing the run -- a decision about this
// task that no later routing may overturn.
func continuesOpenPRBranch(task *workflow.Task) bool {
return task.Workflow == "remediate"
}
// cleanupTerminalTaskWorktree removes a task's worktree once its forge side is
// settled, unless the worktree still holds work no commit captured.
//
+66 -11
View File
@@ -13,6 +13,7 @@ import (
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/domain/workflow"
"github.com/samcharles93/archie-core/internal/infrastructure/postgres/pgstore"
"github.com/samcharles93/archie-core/internal/taskstate"
"github.com/samcharles93/archie-core/internal/worktree"
)
@@ -41,10 +42,10 @@ func pushedImplementRun(t *testing.T, trees *worktree.Manager, title string) (di
}
// claimedTask returns the running row a dispatch leaves behind, carrying the
// workflow and branch prepareWorkspace must route on. The row is read back from
// the store, so the test drives prepareWorkspace from persisted state rather
// than from a struct the test assembled.
func claimedTask(t *testing.T, st *pgstore.TaskDB, title, workflowName, branch string) *workflow.Task {
// workflow, branch and retry mode prepareWorkspace must route on. The row is
// read back from the store, so the test drives prepareWorkspace from persisted
// state rather than from a struct the test assembled.
func claimedTask(t *testing.T, st *pgstore.TaskDB, title, workflowName, branch string, retryMode taskstate.RetryMode) *workflow.Task {
t.Helper()
ctx := context.Background()
if _, err := st.EnqueueIssue(ctx, "acme", "widget", 7, title, "body", "bug", ""); err != nil {
@@ -55,6 +56,7 @@ func claimedTask(t *testing.T, st *pgstore.TaskDB, title, workflowName, branch s
t.Fatalf("ClaimNext = (%+v, %v)", task, err)
}
task.Workflow, task.Branch = workflowName, branch
task.RetryMode = string(retryMode)
if err := st.Update(ctx, task); err != nil {
t.Fatalf("persist task fields: %v", err)
}
@@ -63,9 +65,9 @@ func claimedTask(t *testing.T, st *pgstore.TaskDB, title, workflowName, branch s
if err != nil {
t.Fatalf("TaskByID: %v", err)
}
if persisted.Workflow != workflowName || persisted.Branch != branch {
t.Fatalf("persisted row = (workflow %q, branch %q), want (%q, %q)",
persisted.Workflow, persisted.Branch, workflowName, branch)
if persisted.Workflow != workflowName || persisted.Branch != branch || persisted.RetryMode != string(retryMode) {
t.Fatalf("persisted row = (workflow %q, branch %q, retry mode %q), want (%q, %q, %q)",
persisted.Workflow, persisted.Branch, persisted.RetryMode, workflowName, branch, retryMode)
}
return persisted
}
@@ -99,7 +101,7 @@ func TestPrepareWorkspaceResumesThePersistedBranchForARemediation(t *testing.T)
d, st, _ := testDaemon(t, 3, 0)
// The issue was retitled since; the PR's branch is still the pushed one.
task := claimedTask(t, st, "fix: retitled issue", "remediate", branch)
task := claimedTask(t, st, "fix: retitled issue", "remediate", branch, taskstate.RetryContinuePushedWork)
gotDir, ok := d.prepareWorkspace(ctx, task, trees, config.Repo{Owner: "acme", Name: "widget", Base: "main"})
if !ok {
@@ -135,7 +137,7 @@ func TestPrepareWorkspaceResumesAPRBranchAfterTheWorktreeWasRemoved(t *testing.T
}
d, st, _ := testDaemon(t, 3, 0)
task := claimedTask(t, st, "fix: original issue", "remediate", branch)
task := claimedTask(t, st, "fix: original issue", "remediate", branch, taskstate.RetryContinuePushedWork)
gotDir, ok := d.prepareWorkspace(ctx, task, trees, config.Repo{Owner: "acme", Name: "widget", Base: "main"})
if !ok {
@@ -167,7 +169,7 @@ func TestPrepareWorkspaceFailsClosedWhenTheRemediationBranchIsGone(t *testing.T)
dir, _, tip := pushedImplementRun(t, trees, "fix: original issue")
d, st, _ := testDaemon(t, 3, 0)
task := claimedTask(t, st, "fix: original issue", "remediate", "fix/7-never-pushed")
task := claimedTask(t, st, "fix: original issue", "remediate", "fix/7-never-pushed", taskstate.RetryContinuePushedWork)
gotDir, ok := d.prepareWorkspace(ctx, task, trees, config.Repo{Owner: "acme", Name: "widget", Base: "main"})
if ok {
@@ -203,7 +205,7 @@ func TestPrepareWorkspaceStartsBaseForANonRemediationTask(t *testing.T) {
_, pushedBranch, tip := pushedImplementRun(t, trees, "fix: original issue")
d, st, _ := testDaemon(t, 3, 0)
task := claimedTask(t, st, "fix: retitled issue", "implement", pushedBranch)
task := claimedTask(t, st, "fix: retitled issue", "implement", pushedBranch, taskstate.RetryRefreshOntoBase)
gotDir, ok := d.prepareWorkspace(ctx, task, trees, config.Repo{Owner: "acme", Name: "widget", Base: "main"})
if !ok {
@@ -219,3 +221,56 @@ func TestPrepareWorkspaceStartsBaseForANonRemediationTask(t *testing.T) {
t.Errorf("task branch = %q, want the branch recomputed for fresh work rather than the persisted PR branch", task.Branch)
}
}
// TestPrepareWorkspaceContinuesPushedWorkWhenTheOperatorChoseIt is the
// operator-mode half of the retry routing: a task whose persisted retry_mode
// is continue_pushed_work resumes the branch it already pushed, even though
// its workflow -- implement -- is not one that resumes by default. The
// worktree must land on the pushed tip, not reset over it.
func TestPrepareWorkspaceContinuesPushedWorkWhenTheOperatorChoseIt(t *testing.T) {
ctx := context.Background()
trees := newTestTrees(t, newLocalRemote(t, "acme", "widget"))
dir, branch, tip := pushedImplementRun(t, trees, "fix: original issue")
d, st, _ := testDaemon(t, 3, 0)
task := claimedTask(t, st, "fix: retitled issue", "implement", branch, taskstate.RetryContinuePushedWork)
gotDir, ok := d.prepareWorkspace(ctx, task, trees, config.Repo{Owner: "acme", Name: "widget", Base: "main"})
if !ok {
t.Fatal("prepareWorkspace() = false, want the retry prepared on the branch the operator chose to continue")
}
if gotDir != dir {
t.Errorf("prepareWorkspace() dir = %q, want the task's worktree %q", gotDir, dir)
}
if _, err := os.Stat(filepath.Join(gotDir, "widget.go")); err != nil {
t.Fatalf("widget.go missing after prepare: %v (the pushed work was discarded despite continue_pushed_work)", err)
}
if got := headOf(t, gotDir); got != tip {
t.Errorf("worktree HEAD = %s, want the pushed branch tip %s", got, tip)
}
}
// TestPrepareWorkspaceRefreshesOntoBaseWhenTheOperatorChoseIt pins that the
// persisted mode decides, not the workflow: a task whose workflow would resume
// (remediate) but whose retry_mode is refresh_onto_base must land on base. The
// daemon must not re-derive the choice from the workflow, which is the silent
// default this bead exists to remove.
func TestPrepareWorkspaceRefreshesOntoBaseWhenTheOperatorChoseIt(t *testing.T) {
ctx := context.Background()
trees := newTestTrees(t, newLocalRemote(t, "acme", "widget"))
_, branch, tip := pushedImplementRun(t, trees, "fix: original issue")
d, st, _ := testDaemon(t, 3, 0)
task := claimedTask(t, st, "fix: original issue", "remediate", branch, taskstate.RetryRefreshOntoBase)
gotDir, ok := d.prepareWorkspace(ctx, task, trees, config.Repo{Owner: "acme", Name: "widget", Base: "main"})
if !ok {
t.Fatal("prepareWorkspace() = false, want a fresh base preparation for refresh_onto_base")
}
if got := headOf(t, gotDir); got == tip {
t.Errorf("worktree HEAD = %s, want base rather than the pushed branch tip: refresh_onto_base must win over the workflow", got)
}
if _, err := os.Stat(filepath.Join(gotDir, "widget.go")); !os.IsNotExist(err) {
t.Errorf("widget.go present after refresh_onto_base (stat err = %v), want a fresh base checkout", err)
}
}
+2 -2
View File
@@ -33,7 +33,7 @@ type ChatTaskActionContract interface {
// may only act on its own tasks. res carries the review gate answer
// payload; the chat surface has no instruction or selection syntax, so it
// is the zero value there.
ApplyTaskAction(context.Context, string, int64, taskstate.Action, taskactions.ReviewResponse) (TaskActionResult, error)
ApplyTaskAction(context.Context, string, int64, taskstate.Action, taskactions.ActionPayload) (TaskActionResult, error)
// ApplyOperatorTaskAction applies an action on behalf of an authenticated
// dashboard caller, who acts across identities. The actor is who the
// credential resolved to, or the zero Actor when the caller presented
@@ -43,7 +43,7 @@ type ChatTaskActionContract interface {
// chatTaskProfiles in the daemon). res carries the review gate answer
// payload: the operator's finding selection for approve, and the
// instructions a rereview requires.
ApplyOperatorTaskAction(context.Context, taskactions.Actor, int64, taskstate.Action, taskactions.ReviewResponse) (TaskActionResult, error)
ApplyOperatorTaskAction(context.Context, taskactions.Actor, int64, taskstate.Action, taskactions.ActionPayload) (TaskActionResult, error)
}
// TaskActionResult is what task_action returns.
@@ -122,9 +122,11 @@ type TaskArchiver interface {
}
// TaskRetryer atomically requeues recoverable work and accounts for the new
// attempt so a partial write cannot evade the retry cap.
// attempt so a partial write cannot evade the retry cap. retryMode is the
// operator's worktree choice for the next dispatch (taskstate.RetryMode),
// persisted on the row so the daemon reads it instead of inferring it.
type TaskRetryer interface {
RetryTask(ctx context.Context, taskID int64, fromStatus, workflow string) error
RetryTask(ctx context.Context, taskID int64, fromStatus, workflow, retryMode string) error
}
// ReviewGateResponder is the operator's answer to the review gate
@@ -50,7 +50,7 @@ func TestOperatorActionsRouteThroughCancelExecution(t *testing.T) {
Store: store,
CancelTask: func(id int64) bool { deliveries = append(deliveries, id); return true },
}
if err := service.Apply(context.Background(), nil, humanActor(), 7, tt.action, ReviewResponse{}); err != nil {
if err := service.Apply(context.Background(), nil, humanActor(), 7, tt.action, ActionPayload{}); err != nil {
t.Fatalf("Apply(%s): %v", tt.action, err)
}
if len(store.cancels) != 1 {
@@ -81,7 +81,7 @@ func TestStopRecordsEvenWhenNothingWasExecuting(t *testing.T) {
Store: store,
CancelTask: func(int64) bool { return false },
}
if err := service.Apply(context.Background(), nil, humanActor(), 7, taskstate.ActionStop, ReviewResponse{}); err != nil {
if err := service.Apply(context.Background(), nil, humanActor(), 7, taskstate.ActionStop, ActionPayload{}); err != nil {
t.Fatalf("Apply(stop): %v", err)
}
if len(store.cancels) != 1 || store.cancels[0].to != taskstate.Parked {
@@ -81,7 +81,7 @@ func TestApproveOfAGateRecordsTheSelectionOnTheOffer(t *testing.T) {
service := Service{Store: store}
if err := service.Apply(context.Background(), nil, humanActor(), 7, taskstate.ActionApprove,
ReviewResponse{Findings: []string{findings[0].Key()}}); err != nil {
ActionPayload{Findings: []string{findings[0].Key()}}); err != nil {
t.Fatalf("Apply(approve): %v", err)
}
if len(store.requeues) != 0 {
@@ -114,7 +114,7 @@ func TestApproveWithNoSelectionRecordsEveryOfferedFinding(t *testing.T) {
store := &gateStore{task: offeredGate(findings...)}
service := Service{Store: store}
if err := service.Apply(context.Background(), nil, humanActor(), 7, taskstate.ActionApprove, ReviewResponse{}); err != nil {
if err := service.Apply(context.Background(), nil, humanActor(), 7, taskstate.ActionApprove, ActionPayload{}); err != nil {
t.Fatalf("Apply(approve): %v", err)
}
gate, _ := workflowtask.DecodeReviewGate(store.gateWrites[0].gate)
@@ -128,7 +128,7 @@ func TestApproveRefusesANonOfferedFindingKey(t *testing.T) {
service := Service{Store: store}
err := service.Apply(context.Background(), nil, humanActor(), 7, taskstate.ActionApprove,
ReviewResponse{Findings: []string{"main.go:99:stale"}})
ActionPayload{Findings: []string{"main.go:99:stale"}})
if !errors.Is(err, ErrConflict) {
t.Fatalf("Apply(approve with a stale key) = %v, want ErrConflict", err)
}
@@ -146,7 +146,7 @@ func TestApproveWithoutAGateKeepsTheTasksWorkflow(t *testing.T) {
store := &gateStore{task: &Task{ID: 7, Owner: "acme", Repo: "widgets", Status: taskstate.WaitingHuman}}
service := Service{Store: store}
if err := service.Apply(context.Background(), nil, humanActor(), 7, taskstate.ActionApprove, ReviewResponse{}); err != nil {
if err := service.Apply(context.Background(), nil, humanActor(), 7, taskstate.ActionApprove, ActionPayload{}); err != nil {
t.Fatalf("Apply(approve): %v", err)
}
if len(store.gateWrites) != 0 {
@@ -163,7 +163,7 @@ func TestRereviewRecordsInstructionsAndClearsTheOffer(t *testing.T) {
service := Service{Store: store}
if err := service.Apply(context.Background(), nil, humanActor(), 7, taskstate.ActionRereview,
ReviewResponse{Instructions: "look at the migration ordering"}); err != nil {
ActionPayload{Instructions: "look at the migration ordering"}); err != nil {
t.Fatalf("Apply(rereview): %v", err)
}
write := store.gateWrites[0]
@@ -186,7 +186,7 @@ func TestRereviewRefusedWithoutInstructionsAndAtTheCap(t *testing.T) {
tests := []struct {
name string
task *Task
res ReviewResponse
res ActionPayload
want string
}{
{
@@ -197,7 +197,7 @@ func TestRereviewRefusedWithoutInstructionsAndAtTheCap(t *testing.T) {
{
name: "no gate offer",
task: &Task{ID: 7, Owner: "acme", Repo: "widgets", Status: taskstate.WaitingHuman},
res: ReviewResponse{Instructions: "look again"},
res: ActionPayload{Instructions: "look again"},
want: "no review gate",
},
{
@@ -207,7 +207,7 @@ func TestRereviewRefusedWithoutInstructionsAndAtTheCap(t *testing.T) {
task.RereviewRounds = workflowtask.MaxRereviewRounds
return task
}(),
res: ReviewResponse{Instructions: "look again"},
res: ActionPayload{Instructions: "look again"},
want: "re-reviews",
},
}
+51 -19
View File
@@ -25,6 +25,15 @@ type Task struct {
Owner, Repo, Identity, Status, ParkReason string
IssueNumber, RetryCount int
ForgeBacked bool
// Branch is the branch this task already pushed, if any. A retry that
// continues pushed work resumes it, so the service refuses that mode for a
// task with no branch rather than queueing a resume that cannot land.
Branch string
// RetryMode is the worktree mode already persisted for this task. A retry
// that carries no explicit mode (chat has no mode syntax) keeps this value
// rather than resetting it, so a chat retry of a remediation still
// continues the branch its queued run recorded.
RetryMode string
// ReviewGate is the operator-approval gate's document as the task carries
// it (workflowtask.EncodeReviewGate): the offer the gate wrote, and the answer
// the response path fills in. The response path reads the offer here and
@@ -41,17 +50,23 @@ type Task struct {
Attempt int
}
// ReviewResponse is the payload an operator's answer to the review gate
// carries (docs/prds/pr-review-operator-response.md, Decision 1). It is empty
// for every other action, and for chat's /approve, which has no instruction or
// selection syntax: an absent selection means every offered finding.
type ReviewResponse struct {
// ActionPayload is the per-action data an operator action carries: the
// review-gate answer for approve and rereview (docs/prds/pr-review-operator-
// response.md, Decision 1), and the worktree mode for retry. Every field is
// empty for the actions that do not use it, and for chat's /approve and
// /retry, which carry no instruction, selection or mode syntax.
type ActionPayload struct {
// Instructions are what a re-review must focus on. The response path
// requires them for ActionRereview and ignores them otherwise.
Instructions string
// Findings are the keys (prreview.ScoredFinding.Key) of the offered
// findings an approve posts. Empty means all of them.
Findings []string
// RetryMode is the worktree choice a retry carries (taskstate.RetryMode):
// refresh onto the base branch, or continue the work already pushed on the
// task's branch. It is empty -- the explicit default, refresh -- for every
// other action.
RetryMode taskstate.RetryMode
}
// Actor is the identity that performed an action, and the principal whose
@@ -159,7 +174,9 @@ type Store interface {
TaskByID(context.Context, int64) (*Task, error)
Transition(context.Context, int64, string, string, string) error
Requeue(context.Context, int64, string, string) error
RetryTask(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) 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
@@ -197,12 +214,12 @@ type Service struct {
// The actor is not derived from scope: scope is which tasks a caller may touch,
// actor is who touched one, and the two are only equal by coincidence.
//
// res is the review-gate answer payload: the operator's instruction and
// finding selection for approve and rereview, empty for every other action
// and for the chat surfaces that carry no selection syntax. Both the dashboard
// and chat reach the same apply, so one operator intent cannot be recorded as
// two different decisions.
func (s Service) Apply(ctx context.Context, scope *string, actor Actor, id int64, action taskstate.Action, res ReviewResponse) error {
// res is the per-action payload (ActionPayload): the operator's instruction
// and finding selection for approve and rereview, the worktree mode for
// retry, and empty for every other action and for the chat surfaces that
// carry no such syntax. Both the dashboard and chat reach the same apply, so
// one operator intent cannot be recorded as two different decisions.
func (s Service) Apply(ctx context.Context, scope *string, actor Actor, id int64, action taskstate.Action, res ActionPayload) error {
task, err := s.Store.TaskByID(ctx, id)
if err != nil {
return err
@@ -243,7 +260,7 @@ type outcome struct {
// record alongside it. Errors from the store are returned unwrapped: the
// caller maps them to a response, and the rules-level errors (ErrConflict)
// were already checked above.
func (s Service) apply(ctx context.Context, task *Task, actor Actor, action taskstate.Action, res ReviewResponse) (outcome, error) {
func (s Service) apply(ctx context.Context, task *Task, actor Actor, action taskstate.Action, res ActionPayload) (outcome, error) {
o := outcome{event: s.attributed(task, actor)}
switch action {
case taskstate.ActionApprove:
@@ -251,7 +268,7 @@ func (s Service) apply(ctx context.Context, task *Task, actor Actor, action task
case taskstate.ActionRereview:
return s.applyRereview(ctx, task, actor, o, res)
case taskstate.ActionRetry:
return s.applyRetry(ctx, task, actor, o)
return s.applyRetry(ctx, task, actor, o, res)
case taskstate.ActionStop:
return s.applyStop(ctx, task, actor, o)
case taskstate.ActionReject:
@@ -283,7 +300,7 @@ func (s Service) apply(ctx context.Context, task *Task, actor Actor, action task
// it requeues under the workflow the wait names -- which feasibility sets to
// implement before it waits (docs/prds/pr-review-operator-response.md,
// Decision 1) -- never a name this handler hardcodes.
func (s Service) applyApprove(ctx context.Context, task *Task, actor Actor, o outcome, res ReviewResponse) (outcome, error) {
func (s Service) applyApprove(ctx context.Context, task *Task, actor Actor, o outcome, res ActionPayload) (outcome, error) {
o.event.Kind, o.event.Detail = approvedKind(actor), actor.describe("approved")
gate, ok := workflowtask.DecodeReviewGate(task.ReviewGate)
if !ok || !gate.Offered() {
@@ -308,7 +325,7 @@ func (s Service) applyApprove(ctx context.Context, task *Task, actor Actor, o ou
// one at the cap: in both cases the task stays waiting and nothing is written.
// The offer's findings are cleared, because the resumed run recomputes them;
// the instructions are what reach the recomputation.
func (s Service) applyRereview(ctx context.Context, task *Task, actor Actor, o outcome, res ReviewResponse) (outcome, error) {
func (s Service) applyRereview(ctx context.Context, task *Task, actor Actor, o outcome, res ActionPayload) (outcome, error) {
gate, ok := workflowtask.DecodeReviewGate(task.ReviewGate)
if !ok || !gate.Offered() {
return o, fmt.Errorf("task %d has no review gate to re-review: %w", task.ID, ErrConflict)
@@ -380,7 +397,22 @@ func (s Service) attributed(task *Task, actor Actor) events.Event {
}
}
func (s Service) applyRetry(ctx context.Context, task *Task, actor Actor, o outcome) (outcome, error) {
func (s Service) applyRetry(ctx context.Context, task *Task, actor Actor, o outcome, payload ActionPayload) (outcome, error) {
// An explicit mode always wins. When the action carries none -- chat has no
// mode syntax -- the task's persisted mode is kept rather than reset, so a
// chat retry of a remediation still continues its branch. An empty stored
// value reads as the explicit refresh default.
requested := payload.RetryMode
if requested == "" {
requested = taskstate.RetryMode(task.RetryMode)
}
mode, ok := taskstate.ResolveRetryMode(string(requested))
if !ok {
return o, fmt.Errorf("unknown retry mode %q: %w", requested, ErrConflict)
}
if mode == taskstate.RetryContinuePushedWork && strings.TrimSpace(task.Branch) == "" {
return o, fmt.Errorf("task %d has no pushed branch to continue: %w", task.ID, ErrConflict)
}
limit := 0
if s.MaxRetries != nil {
limit = s.MaxRetries(task)
@@ -395,9 +427,9 @@ 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", "")
err := s.Store.RetryTask(ctx, task.ID, "parked", "", string(mode))
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}
o.event.Data = map[string]any{"retry_count": task.RetryCount + 1, "previous_reason": task.ParkReason, "retry_mode": string(mode)}
return o, err
}
+84 -10
View File
@@ -2,6 +2,7 @@ package taskactions
import (
"context"
"errors"
"testing"
"github.com/samcharles93/archie-core/internal/domain/identity"
@@ -10,8 +11,10 @@ import (
)
type fakeStore struct {
task *Task
events []events.Event
task *Task
events []events.Event
retryMode string
retried bool
}
func (f *fakeStore) TaskByID(context.Context, int64) (*Task, error) { return f.task, nil }
@@ -29,7 +32,9 @@ func (f *fakeStore) RespondReviewGate(context.Context, int64, string, string, bo
return nil
}
func (f *fakeStore) RetryTask(context.Context, int64, string, string) error {
func (f *fakeStore) RetryTask(_ context.Context, _ int64, _, _, retryMode string) error {
f.retryMode = retryMode
f.retried = true
return nil
}
@@ -87,7 +92,7 @@ func TestEventKindDescribesTheActor(t *testing.T) {
store := &fakeStore{task: &Task{ID: 7, Owner: "acme", Repo: "widgets", Status: "waiting_human"}}
service := Service{Store: store}
if err := service.Apply(context.Background(), nil, tc.actor, 7, tc.action, ReviewResponse{}); err != nil {
if err := service.Apply(context.Background(), nil, tc.actor, 7, tc.action, ActionPayload{}); err != nil {
t.Fatalf("Apply() error = %v", err)
}
got := store.last()
@@ -112,7 +117,7 @@ func TestActorAndPrincipalAreRecordedSeparately(t *testing.T) {
service := Service{Store: store}
actor := agentActor().AuthorisedBy(humanID)
if err := service.Apply(context.Background(), nil, actor, 7, taskstate.ActionApprove, ReviewResponse{}); err != nil {
if err := service.Apply(context.Background(), nil, actor, 7, taskstate.ActionApprove, ActionPayload{}); err != nil {
t.Fatalf("Apply() error = %v", err)
}
@@ -137,7 +142,7 @@ func TestUnattributedActionClaimsNoApprover(t *testing.T) {
store := &fakeStore{task: &Task{ID: 7, Owner: "acme", Repo: "widgets", Status: "waiting_human"}}
service := Service{Store: store}
if err := service.Apply(context.Background(), nil, Actor{}, 7, taskstate.ActionApprove, ReviewResponse{}); err != nil {
if err := service.Apply(context.Background(), nil, Actor{}, 7, taskstate.ActionApprove, ActionPayload{}); err != nil {
t.Fatalf("Apply() error = %v", err)
}
@@ -172,7 +177,7 @@ func TestEveryActionCarriesItsAttribution(t *testing.T) {
Store: store,
CancelTask: func(int64) bool { return true },
}
if err := service.Apply(context.Background(), nil, agentActor(), 7, tc.action, ReviewResponse{}); err != nil {
if err := service.Apply(context.Background(), nil, agentActor(), 7, tc.action, ActionPayload{}); err != nil {
t.Fatalf("Apply(%s) error = %v", tc.action, err)
}
got := store.last()
@@ -191,14 +196,14 @@ func TestScopeStillLimitsATaskButIsNotTheActor(t *testing.T) {
store := &fakeStore{task: &Task{ID: 7, Owner: "acme", Repo: "widgets", Status: "waiting_human", Identity: "archie"}}
service := Service{Store: store}
if err := service.Apply(context.Background(), &other, agentActor(), 7, taskstate.ActionApprove, ReviewResponse{}); err == nil {
if err := service.Apply(context.Background(), &other, agentActor(), 7, taskstate.ActionApprove, ActionPayload{}); err == nil {
t.Fatal("Apply() allowed an identity to act on another identity's task")
}
if len(store.events) != 0 {
t.Fatalf("a refused action recorded %d events", len(store.events))
}
if err := service.Apply(context.Background(), &other, agentActor(), 7, taskstate.ActionApprove, ReviewResponse{}); err == nil {
if err := service.Apply(context.Background(), &other, agentActor(), 7, taskstate.ActionApprove, ActionPayload{}); err == nil {
t.Fatal("Apply() allowed a scoped caller to act on a foreign task")
}
}
@@ -238,7 +243,7 @@ func TestOnlyRejectAndCancelCloseTheIssue(t *testing.T) {
closed = true
return nil
}}
if err := service.Apply(context.Background(), nil, agentActor(), 7, tc.action, ReviewResponse{}); err != nil {
if err := service.Apply(context.Background(), nil, agentActor(), 7, tc.action, ActionPayload{}); err != nil {
t.Fatalf("Apply(%s) error = %v", tc.action, err)
}
if closed != tc.closes {
@@ -247,3 +252,72 @@ func TestOnlyRejectAndCancelCloseTheIssue(t *testing.T) {
})
}
}
// TestRetryPersistsTheOperatorsWorktreeMode pins the retry half of the
// operator surface: the mode the dashboard sent reaches the store write, so
// the daemon reads the operator's choice instead of inferring one. The event
// records the mode too, so the timeline says how the retry was dispatched.
func TestRetryPersistsTheOperatorsWorktreeMode(t *testing.T) {
tests := []struct {
name string
mode taskstate.RetryMode
persisted string
branch string
wantMode string
}{
{"continue pushed work", taskstate.RetryContinuePushedWork, "", "fix/7-thing", "continue_pushed_work"},
{"refresh onto base", taskstate.RetryRefreshOntoBase, "", "", "refresh_onto_base"},
{"an empty mode is the explicit refresh default", "", "", "", "refresh_onto_base"},
{"an empty mode keeps the persisted choice", "", string(taskstate.RetryContinuePushedWork), "fix/7-thing", "continue_pushed_work"},
{"an explicit mode overrides the persisted choice", taskstate.RetryRefreshOntoBase, string(taskstate.RetryContinuePushedWork), "fix/7-thing", "refresh_onto_base"},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
store := &fakeStore{task: &Task{ID: 7, Owner: "acme", Repo: "widgets", Status: taskstate.Parked, Branch: tc.branch, RetryMode: tc.persisted}}
service := Service{Store: store}
if err := service.Apply(context.Background(), nil, humanActor(), 7, taskstate.ActionRetry, ActionPayload{RetryMode: tc.mode}); err != nil {
t.Fatalf("Apply(retry) error = %v", err)
}
if !store.retried || store.retryMode != tc.wantMode {
t.Fatalf("RetryTask mode = %q (called %v), want %q", store.retryMode, store.retried, tc.wantMode)
}
if got := store.last().Data["retry_mode"]; got != tc.wantMode {
t.Errorf("retry event retry_mode = %v, want %q", got, tc.wantMode)
}
})
}
}
// TestRetryRefusesModesThatCannotLand keeps a refuse-from-the-operator rule at
// the service, where every surface reaches it: continuing work with no pushed
// branch would queue a resume that cannot land, and an unknown mode is a
// caller bug rather than a task to reset. Both are conflicts and neither
// writes.
func TestRetryRefusesModesThatCannotLand(t *testing.T) {
tests := []struct {
name string
mode taskstate.RetryMode
branch string
}{
{"continue with no pushed branch", taskstate.RetryContinuePushedWork, ""},
{"an unknown mode", taskstate.RetryMode("reset_to_branch_head"), "fix/7-thing"},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
store := &fakeStore{task: &Task{ID: 7, Owner: "acme", Repo: "widgets", Status: taskstate.Parked, Branch: tc.branch}}
service := Service{Store: store}
err := service.Apply(context.Background(), nil, humanActor(), 7, taskstate.ActionRetry, ActionPayload{RetryMode: tc.mode})
if err == nil {
t.Fatal("Apply(retry) = nil error, want a conflict")
}
if !errors.Is(err, ErrConflict) {
t.Fatalf("Apply(retry) error = %v, want ErrConflict", err)
}
if store.retried {
t.Error("RetryTask was called, want the refusal to write nothing")
}
})
}
}
+8
View File
@@ -66,6 +66,14 @@ type Task struct {
// (parking-to-queued transitions). When it reaches the configured
// max_retries the daemon moves the task to StatusDead.
RetryCount int `json:"retry_count"`
// RetryMode is the operator's worktree choice for the next dispatch of this
// task (taskstate.RetryMode): refresh onto the base branch, or continue the
// work already pushed on Branch. The retry action writes it -- and the
// reaction consumer writes continue when it queues a remediation -- and the
// daemon's prepareWorkspace reads it to position the worktree. Empty reads
// as the explicit default, RefreshOntoBase; it is never inferred from the
// workflow at dispatch.
RetryMode string `json:"retry_mode"`
// WatchCommentID is the poll backstop's high-water mark over forge
// review-comment IDs for this task (pr-review-remediation.md decision
// 2's persisted per-task cursor; the comment-watch design it was
+2 -2
View File
@@ -118,14 +118,14 @@ func (a *LocalChatAdapter) SetPersona(ctx context.Context, id, name string) (boo
return a.Personas.SetActive(id, strings.ToLower(name)), nil
}
func (a *LocalChatAdapter) ApplyTaskAction(ctx context.Context, identity string, taskID int64, action taskstate.Action, res taskactions.ReviewResponse) (TaskActionResult, error) {
func (a *LocalChatAdapter) ApplyTaskAction(ctx context.Context, identity string, taskID int64, action taskstate.Action, res taskactions.ActionPayload) (TaskActionResult, error) {
if a.TaskActor == nil {
return TaskActionResult{}, ErrChatCapabilityUnavailable
}
return a.TaskActor.ApplyChatTaskAction(ctx, &identity, taskactions.ActorFromScope(identity), taskID, action, res)
}
func (a *LocalChatAdapter) ApplyOperatorTaskAction(ctx context.Context, actor taskactions.Actor, taskID int64, action taskstate.Action, res taskactions.ReviewResponse) (TaskActionResult, error) {
func (a *LocalChatAdapter) ApplyOperatorTaskAction(ctx context.Context, actor taskactions.Actor, taskID int64, action taskstate.Action, res taskactions.ActionPayload) (TaskActionResult, error) {
if a.TaskActor == nil {
return TaskActionResult{}, ErrChatCapabilityUnavailable
}
+1 -1
View File
@@ -22,7 +22,7 @@ type fakeActor struct {
gotAction taskstate.Action
}
func (f *fakeActor) ApplyChatTaskAction(_ context.Context, identity *string, actor taskactions.Actor, taskID int64, action taskstate.Action, _ taskactions.ReviewResponse) (TaskActionResult, error) {
func (f *fakeActor) ApplyChatTaskAction(_ context.Context, identity *string, actor taskactions.Actor, taskID int64, action taskstate.Action, _ taskactions.ActionPayload) (TaskActionResult, error) {
if identity != nil {
f.gotIdentity = *identity
}
+2 -2
View File
@@ -79,7 +79,7 @@ type ChatTaskActor interface {
// and not the same as an empty name, which is a real identity in a
// single-identity deployment. res is the review gate answer payload; this
// tool has no instruction or selection syntax, so it is the zero value.
ApplyChatTaskAction(ctx context.Context, identity *string, actor taskactions.Actor, taskID int64, action taskstate.Action, res taskactions.ReviewResponse) (TaskActionResult, error)
ApplyChatTaskAction(ctx context.Context, identity *string, actor taskactions.Actor, taskID int64, action taskstate.Action, res taskactions.ActionPayload) (TaskActionResult, error)
}
// ChatTaskLogEntry is one log line as task_logs returns it. It mirrors
@@ -331,7 +331,7 @@ func taskActionTool(actor ChatTaskActor, identity string) tools.ToolEntry {
// actor is that same bound identity, because a bot acting on
// its own channel's task is exactly what happened -- and it is
// recorded as an agent's action, not a person's.
result, err := actor.ApplyChatTaskAction(ctx, &identity, taskactions.ActorFromScope(identity), taskID, taskstate.Action(actionStr), taskactions.ReviewResponse{})
result, err := actor.ApplyChatTaskAction(ctx, &identity, taskactions.ActorFromScope(identity), taskID, taskstate.Action(actionStr), taskactions.ActionPayload{})
if err != nil {
return nil, fmt.Errorf("task_action: %w", err)
}
+3 -2
View File
@@ -82,7 +82,7 @@ func (c *Client) SetPersona(ctx context.Context, id, name string) (bool, error)
return v.Found, nil
}
func (c *Client) ApplyTaskAction(ctx context.Context, identity string, taskID int64, action taskstate.Action, res taskactions.ReviewResponse) (messaging.TaskActionResult, error) {
func (c *Client) ApplyTaskAction(ctx context.Context, identity string, taskID int64, action taskstate.Action, res taskactions.ActionPayload) (messaging.TaskActionResult, error) {
v, err := c.client.ApplyTaskAction(ctx, &pb.ApplyTaskActionRequest{
Identity: identity, TaskId: taskID, Action: string(action),
Instructions: res.Instructions, Findings: res.Findings,
@@ -93,7 +93,7 @@ func (c *Client) ApplyTaskAction(ctx context.Context, identity string, taskID in
return messaging.TaskActionResult{TaskID: v.TaskId, Action: v.Action, Message: v.Message}, nil
}
func (c *Client) ApplyOperatorTaskAction(ctx context.Context, actor taskactions.Actor, taskID int64, action taskstate.Action, res taskactions.ReviewResponse) (messaging.TaskActionResult, error) {
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),
@@ -102,6 +102,7 @@ func (c *Client) ApplyOperatorTaskAction(ctx context.Context, actor taskactions.
PrincipalId: string(actor.Principal),
Instructions: res.Instructions,
Findings: res.Findings,
RetryMode: string(res.RetryMode),
})
if err != nil {
return messaging.TaskActionResult{}, taskActionError(err)
@@ -142,12 +142,13 @@ type recordingTaskActor struct {
identity *string
taskID int64
action taskstate.Action
payload taskactions.ActionPayload
}
func (a *recordingTaskActor) ApplyChatTaskAction(
_ context.Context, identity *string, actor taskactions.Actor, taskID int64, action taskstate.Action, _ taskactions.ReviewResponse,
_ context.Context, identity *string, actor taskactions.Actor, taskID int64, action taskstate.Action, payload taskactions.ActionPayload,
) (gateway.TaskActionResult, error) {
a.identity, a.taskID, a.action = identity, taskID, action
a.identity, a.taskID, a.action, a.payload = identity, taskID, action, payload
return gateway.TaskActionResult{TaskID: taskID, Action: string(action), Message: "applied"}, nil
}
@@ -169,7 +170,7 @@ func TestTaskActionScopeSurvivesTheWire(t *testing.T) {
chat = remoteChat(t, local)
}
result, err := chat.ApplyOperatorTaskAction(ctx, taskactions.Actor{}, 42, taskstate.ActionApprove, taskactions.ReviewResponse{})
result, err := chat.ApplyOperatorTaskAction(ctx, taskactions.Actor{}, 42, taskstate.ActionApprove, taskactions.ActionPayload{RetryMode: taskstate.RetryContinuePushedWork})
if err != nil {
t.Fatalf("operator action: %v", err)
}
@@ -179,11 +180,14 @@ func TestTaskActionScopeSurvivesTheWire(t *testing.T) {
if actor.taskID != 42 || actor.action != taskstate.ActionApprove {
t.Fatalf("operator action = (%d, %q), want (42, %q)", actor.taskID, actor.action, taskstate.ActionApprove)
}
if actor.payload.RetryMode != taskstate.RetryContinuePushedWork {
t.Fatalf("operator action retry mode = %q, want %q: the choice must survive the hop", actor.payload.RetryMode, taskstate.RetryContinuePushedWork)
}
if result.TaskID != 42 || result.Action != string(taskstate.ActionApprove) || result.Message != "applied" {
t.Fatalf("operator result = %+v, want the daemon's result", result)
}
if _, err := chat.ApplyTaskAction(ctx, "scout", 7, taskstate.ActionRetry, taskactions.ReviewResponse{}); err != nil {
if _, err := chat.ApplyTaskAction(ctx, "scout", 7, taskstate.ActionRetry, taskactions.ActionPayload{}); err != nil {
t.Fatalf("chat action: %v", err)
}
if actor.identity == nil || *actor.identity != "scout" {
@@ -197,7 +201,7 @@ func TestTaskActionScopeSurvivesTheWire(t *testing.T) {
type failingTaskActor struct{ err error }
func (a failingTaskActor) ApplyChatTaskAction(
context.Context, *string, taskactions.Actor, int64, taskstate.Action, taskactions.ReviewResponse,
context.Context, *string, taskactions.Actor, int64, taskstate.Action, taskactions.ActionPayload,
) (gateway.TaskActionResult, error) {
return gateway.TaskActionResult{}, a.err
}
@@ -221,7 +225,7 @@ func TestTaskActionErrorsKeepTheirSentinelOverGRPC(t *testing.T) {
local := &gateway.LocalChatAdapter{TaskActor: failingTaskActor{err: tc.err}}
chat := remoteChat(t, local)
_, err := chat.ApplyOperatorTaskAction(ctx, taskactions.Actor{}, 7, taskstate.ActionApprove, taskactions.ReviewResponse{})
_, err := chat.ApplyOperatorTaskAction(ctx, taskactions.Actor{}, 7, taskstate.ActionApprove, taskactions.ActionPayload{})
if err == nil {
t.Fatalf("ApplyOperatorTaskAction error = nil, want %v", tc.err)
}
+3 -2
View File
@@ -92,7 +92,7 @@ func (s *server) SetPersona(ctx context.Context, r *pb.SetPersonaRequest) (*pb.S
}
func (s *server) ApplyTaskAction(ctx context.Context, r *pb.ApplyTaskActionRequest) (*pb.ApplyTaskActionResponse, error) {
v, err := s.chat.ApplyTaskAction(ctx, r.Identity, r.TaskId, taskstate.Action(r.Action), taskactions.ReviewResponse{
v, err := s.chat.ApplyTaskAction(ctx, r.Identity, r.TaskId, taskstate.Action(r.Action), taskactions.ActionPayload{
Instructions: r.Instructions,
Findings: r.Findings,
})
@@ -108,9 +108,10 @@ func (s *server) ApplyOperatorTaskAction(ctx context.Context, r *pb.ApplyOperato
Kind: identity.Kind(r.ActorKind),
Principal: identity.IdentityID(r.PrincipalId),
}
v, err := s.chat.ApplyOperatorTaskAction(ctx, actor, r.TaskId, taskstate.Action(r.Action), taskactions.ReviewResponse{
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),
})
if err != nil {
return nil, taskActionStatus(err)
@@ -0,0 +1,20 @@
-- Operator-selected retry worktree mode
-- (archie-core-vrl5: "retry should let the operator choose refresh-onto-base
-- or continue-pushed-work").
--
-- tasks.retry_mode records how the next dispatch positions the worktree:
-- 'refresh_onto_base' resets it onto the base branch, 'continue_pushed_work'
-- resumes the branch the task already pushed. The retry action writes the
-- operator's choice; BeginRemediationTask writes 'continue_pushed_work' when
-- it queues a remediation, because a remediation must continue its PR branch.
-- The default is the explicit refresh mode, so every existing row reads as a
-- retry that starts from base and no dispatch path infers the mode from the
-- workflow.
-- +goose Up
ALTER TABLE tasks ADD COLUMN retry_mode text NOT NULL DEFAULT 'refresh_onto_base';
-- +goose Down
ALTER TABLE tasks DROP COLUMN retry_mode;
@@ -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 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 FROM tasks t WHERE t.id = $1 FOR UPDATE
)
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, workspace_id, inputs, call_parent_task_id, call_depth)
SELECT
@@ -41,7 +41,7 @@ SELECT
caller.id, caller.call_depth + 1
FROM caller
WHERE caller.status = 'running' AND caller.call_depth + 1 <= $7::int
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
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
`
type EnqueueCallTaskParams struct {
@@ -115,6 +115,7 @@ func (q *Queries) EnqueueCallTask(ctx context.Context, arg EnqueueCallTaskParams
&i.Outputs,
&i.ReviewGate,
&i.RereviewRounds,
&i.RetryMode,
)
return i, err
}
@@ -395,6 +395,7 @@ type Task struct {
Outputs string
ReviewGate string
RereviewRounds int64
RetryMode string
}
type ToolCall struct {
@@ -28,7 +28,7 @@ func (q *Queries) ArchiveTaskDelete(ctx context.Context, arg ArchiveTaskDeletePa
}
const beginRemediationTask = `-- name: BeginRemediationTask :execrows
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '', park_class = 'needs_human', review_payload = $2, updated_at = now()
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '', park_class = 'needs_human', review_payload = $2, retry_mode = 'continue_pushed_work', updated_at = now()
WHERE id = $1 AND status = 'pr_open'
`
@@ -37,6 +37,9 @@ type BeginRemediationTaskParams struct {
ReviewPayload string
}
// A remediation must continue the branch its pull request lives on, so it
// records that dispatch mode explicitly (taskstate.RetryContinuePushedWork)
// rather than leaving prepareWorkspace to infer it from the workflow.
func (q *Queries) BeginRemediationTask(ctx context.Context, arg BeginRemediationTaskParams) (int64, error) {
result, err := q.db.Exec(ctx, beginRemediationTask, arg.ID, arg.ReviewPayload)
if err != nil {
@@ -48,7 +51,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
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
`
type ClaimByIssueParams struct {
@@ -103,6 +106,7 @@ func (q *Queries) ClaimByIssue(ctx context.Context, arg ClaimByIssueParams) (Tas
&i.Outputs,
&i.ReviewGate,
&i.RereviewRounds,
&i.RetryMode,
)
return i, err
}
@@ -117,7 +121,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
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
`
// FOR UPDATE SKIP LOCKED replaces the SQLite single-writer assumption: two
@@ -170,6 +174,7 @@ func (q *Queries) ClaimNextTask(ctx context.Context) (Task, error) {
&i.Outputs,
&i.ReviewGate,
&i.RereviewRounds,
&i.RetryMode,
)
return i, err
}
@@ -280,7 +285,7 @@ VALUES (
),
$8
)
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
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
`
type InsertChatTaskParams struct {
@@ -354,6 +359,7 @@ func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams)
&i.Outputs,
&i.ReviewGate,
&i.RereviewRounds,
&i.RetryMode,
)
return i, err
}
@@ -647,18 +653,25 @@ func (q *Queries) RespondReviewGateTask(ctx context.Context, arg RespondReviewGa
const retryTask = `-- name: RetryTask :execrows
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,
park_reason = '', park_class = 'needs_human', updated_at = now()
WHERE id = $2 AND status = $3
WHERE id = $3 AND status = $4
`
type RetryTaskParams struct {
Workflow string
RetryMode string
ID int64
FromStatus string
}
func (q *Queries) RetryTask(ctx context.Context, arg RetryTaskParams) (int64, error) {
result, err := q.db.Exec(ctx, retryTask, arg.Workflow, arg.ID, arg.FromStatus)
result, err := q.db.Exec(ctx, retryTask,
arg.Workflow,
arg.RetryMode,
arg.ID,
arg.FromStatus,
)
if err != nil {
return 0, err
}
@@ -700,7 +713,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 FROM tasks WHERE id = $1
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 FROM tasks WHERE id = $1
`
func (q *Queries) TaskByID(ctx context.Context, id int64) (Task, error) {
@@ -747,12 +760,13 @@ func (q *Queries) TaskByID(ctx context.Context, id int64) (Task, error) {
&i.Outputs,
&i.ReviewGate,
&i.RereviewRounds,
&i.RetryMode,
)
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 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 FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3
`
type TaskByIssueParams struct {
@@ -805,12 +819,13 @@ func (q *Queries) TaskByIssue(ctx context.Context, arg TaskByIssueParams) (Task,
&i.Outputs,
&i.ReviewGate,
&i.RereviewRounds,
&i.RetryMode,
)
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 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 FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3 AND status = $4
`
type TaskByPRParams struct {
@@ -872,6 +887,7 @@ func (q *Queries) TaskByPR(ctx context.Context, arg TaskByPRParams) (Task, error
&i.Outputs,
&i.ReviewGate,
&i.RereviewRounds,
&i.RetryMode,
)
return i, err
}
@@ -934,7 +950,7 @@ UPDATE tasks SET workflow = $2, branch = $3, plan = $4, notes = $5,
review_payload = $13, workflow_definition_version = $14,
workflow_definition_digest = $15, workflow_definition_yaml = $16,
outputs = $17, review_gate = $18, rereview_rounds = $19,
updated_at = now()
retry_mode = $20, updated_at = now()
WHERE id = $1
`
@@ -958,6 +974,7 @@ type UpdateTaskParams struct {
Outputs string
ReviewGate string
RereviewRounds int64
RetryMode string
}
func (q *Queries) UpdateTask(ctx context.Context, arg UpdateTaskParams) error {
@@ -981,6 +998,7 @@ func (q *Queries) UpdateTask(ctx context.Context, arg UpdateTaskParams) error {
arg.Outputs,
arg.ReviewGate,
arg.RereviewRounds,
arg.RetryMode,
)
return err
}
@@ -85,7 +85,7 @@ UPDATE tasks SET workflow = $2, branch = $3, plan = $4, notes = $5,
review_payload = $13, workflow_definition_version = $14,
workflow_definition_digest = $15, workflow_definition_yaml = $16,
outputs = $17, review_gate = $18, rereview_rounds = $19,
updated_at = now()
retry_mode = $20, updated_at = now()
WHERE id = $1;
-- name: RereviewRounds :one
@@ -152,7 +152,10 @@ WHERE owner = $1 AND repo = $2 AND issue_number = $3 AND status = 'queued'
RETURNING *;
-- name: BeginRemediationTask :execrows
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '', park_class = 'needs_human', review_payload = $2, updated_at = now()
-- A remediation must continue the branch its pull request lives on, so it
-- records that dispatch mode explicitly (taskstate.RetryContinuePushedWork)
-- rather than leaving prepareWorkspace to infer it from the workflow.
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '', park_class = 'needs_human', review_payload = $2, retry_mode = 'continue_pushed_work', updated_at = now()
WHERE id = $1 AND status = 'pr_open';
-- name: UpdateReviewPayloadTask :execrows
@@ -172,6 +175,7 @@ WHERE id = @id AND status = @from_status;
-- name: RetryTask :execrows
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,
park_reason = '', park_class = 'needs_human', updated_at = now()
WHERE id = @id AND status = @from_status;
+7 -3
View File
@@ -111,6 +111,7 @@ func taskFromRow(t postgresdb.Task) *workflow.Task {
Attempt: int(t.Attempt),
ParkReason: t.ParkReason,
RetryCount: int(t.RetryCount),
RetryMode: t.RetryMode,
WatchCommentID: t.WatchCommentID,
ReviewCursor: t.ReviewCursor,
Source: t.Source,
@@ -322,6 +323,7 @@ func (s *Store) Update(ctx context.Context, t *workflow.Task) error {
ReviewPayload: t.ReviewPayload,
ReviewGate: t.ReviewGate,
RereviewRounds: int64(t.RereviewRounds),
RetryMode: t.RetryMode,
WorkflowDefinitionVersion: t.WorkflowDefinitionVersion,
WorkflowDefinitionDigest: t.WorkflowDefinitionDigest,
WorkflowDefinitionYaml: t.WorkflowDefinitionYAML,
@@ -401,11 +403,13 @@ func (s *Store) Requeue(ctx context.Context, taskID int64, fromStatus, wf string
}
// RetryTask requeues a task and increments retry_count in the same guarded
// transaction, under the same table check Requeue applies.
func (s *Store) RetryTask(ctx context.Context, taskID int64, fromStatus, wf string) error {
// 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.
func (s *Store) RetryTask(ctx context.Context, taskID int64, fromStatus, wf, retryMode string) error {
return s.requeue(ctx, taskID, fromStatus, wf, "retried "+wf, func(q *postgresdb.Queries) (int64, error) {
return q.RetryTask(ctx, postgresdb.RetryTaskParams{
ID: taskID, Workflow: wf, FromStatus: fromStatus,
ID: taskID, Workflow: wf, FromStatus: fromStatus, RetryMode: retryMode,
})
})
}
@@ -105,7 +105,7 @@ func TestTaskOutputs(t *testing.T) {
if err := st.Transition(ctx, task.ID, workflow.StatusRunning, workflow.StatusParked, "needs a look"); err != nil {
t.Fatal(err)
}
if err := st.RetryTask(ctx, task.ID, workflow.StatusParked, ""); err != nil {
if err := st.RetryTask(ctx, task.ID, workflow.StatusParked, "", ""); err != nil {
t.Fatal(err)
}
second, err := st.ClaimNext(ctx)
@@ -51,10 +51,10 @@ func TestIllegalTransitionsAreRejected(t *testing.T) {
return s.Requeue(t.Context(), taskID, taskstate.Merged, "implement")
}},
{name: "retry from terminal merged", seed: taskstate.Merged, write: func(s *Store, taskID int64) error {
return s.RetryTask(t.Context(), taskID, taskstate.Merged, "implement")
return s.RetryTask(t.Context(), taskID, taskstate.Merged, "implement", "")
}},
{name: "retry from queued self-pair", seed: taskstate.Queued, write: func(s *Store, taskID int64) error {
return s.RetryTask(t.Context(), taskID, taskstate.Queued, "implement")
return s.RetryTask(t.Context(), taskID, taskstate.Queued, "implement", "")
}},
}
for _, tt := range tests {
+2 -2
View File
@@ -207,8 +207,8 @@ 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 string) error {
_, err := c.client.RetryTask(ctx, &pb.RetryTaskRequest{TaskId: taskID, FromStatus: fromStatus, Workflow: wf})
func (c *Client) RetryTask(ctx context.Context, taskID int64, fromStatus, wf, retryMode string) error {
_, err := c.client.RetryTask(ctx, &pb.RetryTaskRequest{TaskId: taskID, FromStatus: fromStatus, Workflow: wf, RetryMode: retryMode})
return unmapError(err)
}
@@ -408,10 +408,10 @@ func TestStateStoreConformance(t *testing.T) {
// edges, and each guard is the wire contract. The battery used to
// walk queued -> queued through RetryTask, a self-write the shared
// transition table refuses, so the retry runs from running instead.
if err := c.RetryTask(ctx, claimed.ID, "running", ""); err != nil {
if err := c.RetryTask(ctx, claimed.ID, "running", "", ""); err != nil {
t.Fatalf("RetryTask: %v", err)
}
if err := c.RetryTask(ctx, claimed.ID, "queued", ""); !errors.Is(err, storecontract.ErrIllegalTransition) {
if err := c.RetryTask(ctx, claimed.ID, "queued", "", ""); !errors.Is(err, storecontract.ErrIllegalTransition) {
t.Fatalf("RetryTask queued->queued = %v, want ErrIllegalTransition", err)
}
if err := c.Transition(ctx, claimed.ID, "queued", "running", "re-claimed"); err != nil {
+1 -1
View File
@@ -347,7 +347,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); err != nil {
if err := s.deps.Tasks.RetryTask(ctx, r.TaskId, r.FromStatus, r.Workflow, r.RetryMode); err != nil {
return nil, s.logErr("RetryTask", err)
}
return &pb.RetryTaskResponse{}, nil
@@ -71,6 +71,7 @@ func taskProto(t *task.Task) *pb.Task { //nolint:dupl // mirror-image field-by-f
Workflow: t.Workflow, Branch: t.Branch, Plan: t.Plan, Notes: t.Notes,
PrNumber: int64(t.PRNumber), TokensUsed: int64(t.TokensUsed), Iterations: int64(t.Iterations),
Attempt: int64(t.Attempt), ParkReason: t.ParkReason, RetryCount: int64(t.RetryCount),
RetryMode: t.RetryMode,
WatchCommentId: t.WatchCommentID, Source: t.Source, Identity: t.Identity,
BindingId: t.BindingID, BindingVersion: int64(t.BindingVersion),
InputsJson: inputsJSON(t.Inputs),
@@ -101,6 +102,7 @@ func taskValue(t *pb.Task) *task.Task { //nolint:dupl // see taskProto above
Workflow: t.Workflow, Branch: t.Branch, Plan: t.Plan, Notes: t.Notes,
PRNumber: int(t.PrNumber), TokensUsed: int(t.TokensUsed), Iterations: int(t.Iterations),
Attempt: int(t.Attempt), ParkReason: t.ParkReason, RetryCount: int(t.RetryCount),
RetryMode: t.RetryMode,
WatchCommentID: t.WatchCommentId, Source: t.Source, Identity: t.Identity,
BindingID: t.BindingId, BindingVersion: int(t.BindingVersion),
Inputs: inputsValue(t.InputsJson),
+10 -6
View File
@@ -37,11 +37,13 @@ type actionRequest struct {
Action taskstate.Action `json:"action"`
Actor *actorPayload `json:"actor,omitempty"`
// Instructions and Findings are the review gate answer payload
// (taskactions.ReviewResponse). They are empty for every action but
// (taskactions.ActionPayload). They are empty for every action but
// approve and rereview, and for chat surfaces, which carry no selection
// syntax.
Instructions string `json:"instructions,omitempty"`
Findings []string `json:"findings,omitempty"`
// syntax. RetryMode is the worktree choice a retry carries; empty means
// the explicit default, refresh_onto_base.
Instructions string `json:"instructions,omitempty"`
Findings []string `json:"findings,omitempty"`
RetryMode taskstate.RetryMode `json:"retry_mode,omitempty"`
}
type actorPayload struct {
@@ -127,9 +129,10 @@ func Register(nc *nats.Conn, service taskactions.Service, log *slog.Logger) (fun
natsrpc.Respond(msg, log, "taskactions", actionResponse{Envelope: natsrpc.NewEnvelope(err)})
return
}
err := service.Apply(context.Background(), req.Identity, req.Actor.actor(), req.TaskID, req.Action, taskactions.ReviewResponse{
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,
})
natsrpc.Respond(msg, log, "taskactions", actionResponse{
Envelope: natsrpc.NewEnvelope(err),
@@ -152,7 +155,7 @@ func (c Client) rpc() *natsrpc.Client {
// ApplyChatTaskAction sends an action to the daemon's responder, carrying the
// scope and the actor the caller resolved. A caller with no verified identity
// passes the zero actor, which the daemon records as unattributed.
func (c Client) ApplyChatTaskAction(ctx context.Context, scope *string, actor taskactions.Actor, id int64, action taskstate.Action, res taskactions.ReviewResponse) (gateway.TaskActionResult, error) {
func (c Client) ApplyChatTaskAction(ctx context.Context, scope *string, actor taskactions.Actor, id int64, action taskstate.Action, res taskactions.ActionPayload) (gateway.TaskActionResult, error) {
if c.Conn == nil {
return gateway.TaskActionResult{}, fmt.Errorf("task action connection is unavailable")
}
@@ -162,6 +165,7 @@ func (c Client) ApplyChatTaskAction(ctx context.Context, scope *string, actor ta
Action: action,
Instructions: res.Instructions,
Findings: res.Findings,
RetryMode: res.RetryMode,
Actor: &actorPayload{
ID: string(actor.Identity),
Kind: string(actor.Kind),
@@ -49,7 +49,7 @@ func (s stubStore) Requeue(context.Context, int64, string, string) error { retur
func (s stubStore) RespondReviewGate(context.Context, int64, string, string, bool, int) error {
return s.err
}
func (s stubStore) RetryTask(context.Context, int64, string, string) error { return s.err }
func (s stubStore) RetryTask(context.Context, int64, string, string, string) error { return s.err }
func (s stubStore) ArchiveTask(context.Context, int64, string, events.Event) (int64, error) {
return 0, s.err
@@ -111,7 +111,7 @@ func TestActionErrorKeepsItsSentinelAcrossNATS(t *testing.T) {
t.Fatalf("flush: %v", err)
}
_, err = Client{Conn: nc}.ApplyChatTaskAction(t.Context(), nil, domain.Actor{}, 7, tc.action, domain.ReviewResponse{})
_, err = Client{Conn: nc}.ApplyChatTaskAction(t.Context(), nil, domain.Actor{}, 7, tc.action, domain.ActionPayload{})
if err == nil {
t.Fatalf("ApplyChatTaskAction(%s) error = nil, want %v", tc.action, tc.want)
}
@@ -119,7 +119,7 @@ func TestActionErrorKeepsItsSentinelAcrossNATS(t *testing.T) {
t.Fatalf("error %v (%T) is not %v", err, err, tc.want)
}
// The wording the operator reads survives too, not just the class.
direct := service.Apply(t.Context(), nil, domain.Actor{}, 7, tc.action, domain.ReviewResponse{})
direct := service.Apply(t.Context(), nil, domain.Actor{}, 7, tc.action, domain.ActionPayload{})
if direct == nil || err.Error() != direct.Error() {
t.Fatalf("remote message = %q, want the daemon's own %v", err.Error(), direct)
}
@@ -158,7 +158,7 @@ func TestActionScopeCrossesNATS(t *testing.T) {
t.Fatalf("flush: %v", err)
}
result, err := Client{Conn: nc}.ApplyChatTaskAction(t.Context(), tc.identity, domain.Actor{}, 7, taskstate.ActionAbandon, domain.ReviewResponse{})
result, err := Client{Conn: nc}.ApplyChatTaskAction(t.Context(), tc.identity, domain.Actor{}, 7, taskstate.ActionAbandon, domain.ActionPayload{})
if err != nil {
t.Fatalf("apply: %v", err)
}
+1 -1
View File
@@ -17,7 +17,7 @@ func (s Store) TaskByID(ctx context.Context, id int64) (*taskactions.Task, error
if err != nil || t == nil {
return nil, err
}
return &taskactions.Task{ID: t.ID, Owner: t.Owner, Repo: t.Repo, Identity: t.Identity, Status: t.Status, ParkReason: t.ParkReason, IssueNumber: t.IssueNumber, RetryCount: t.RetryCount, Attempt: t.Attempt, ForgeBacked: t.IsForgeBacked(), ReviewGate: t.ReviewGate, RereviewRounds: t.RereviewRounds}, nil
return &taskactions.Task{ID: t.ID, Owner: t.Owner, Repo: t.Repo, Identity: t.Identity, Status: t.Status, ParkReason: t.ParkReason, IssueNumber: t.IssueNumber, RetryCount: t.RetryCount, Attempt: t.Attempt, Branch: t.Branch, RetryMode: t.RetryMode, ForgeBacked: t.IsForgeBacked(), ReviewGate: t.ReviewGate, RereviewRounds: t.RereviewRounds}, nil
}
// CancelExecution delegates to the store's one cancel path
+68
View File
@@ -148,6 +148,74 @@ func CheckRetry(status string) error {
return nil
}
// RetryMode is the operator's worktree choice for the next dispatch of a
// retried task. It is a dispatch directive: the daemon resolves it to the
// commit the worktree is prepared at, never infers it from the workflow.
//
// The values are persisted on the task row (tasks.retry_mode) and cross the
// wire, so they are part of the on-disk format: renaming one is a migration.
type RetryMode string
const (
// RetryRefreshOntoBase starts the retry from the current base branch,
// discarding anything an earlier attempt committed on the task branch.
// It is the default for work that is not an open pull request.
RetryRefreshOntoBase RetryMode = "refresh_onto_base"
// RetryContinuePushedWork resumes the branch the task already pushed, so
// the retry continues the work an earlier attempt committed instead of
// resetting over it. It requires a branch to resume.
RetryContinuePushedWork RetryMode = "continue_pushed_work"
)
// NormalizeRetryMode maps a stored retry mode to the mode it means. Empty and
// unknown values fall back to RefreshOntoBase: a retry that carries no explicit
// choice resets onto base, which is the safe default for work that is not an
// open pull request.
func NormalizeRetryMode(mode string) RetryMode {
if RetryMode(mode) == RetryContinuePushedWork {
return RetryContinuePushedWork
}
return RetryRefreshOntoBase
}
// ResolveRetryMode validates a retry mode arriving from a caller. Unlike
// stored data, a wire value that names no mode is rejected rather than
// defaulted: silently reading a typo as "refresh onto base" would reset a task
// the operator asked to continue. The empty string is accepted and means the
// explicit default, RetryRefreshOntoBase.
func ResolveRetryMode(mode string) (RetryMode, bool) {
switch RetryMode(mode) {
case "", RetryRefreshOntoBase:
return RetryRefreshOntoBase, true
case RetryContinuePushedWork:
return RetryContinuePushedWork, true
default:
return "", false
}
}
// RetryModeMeta describes how to present a retry mode. The dashboard renders
// the operator's choice from this catalog rather than keeping its own copy.
type RetryModeMeta struct {
ID string `json:"id"`
Label string `json:"label"`
Description string `json:"description"`
Default bool `json:"default"`
// RequiresBranch reports that the mode can only land when the task has a
// branch to resume. The dashboard disables it otherwise; the action refuses
// the same combination, so the UI check is a convenience, not the rule.
RequiresBranch bool `json:"requires_branch"`
}
// RetryModes returns the presentation catalog for the retry modes, in display
// order. Callers receive a fresh slice.
func RetryModes() []RetryModeMeta {
return []RetryModeMeta{
{ID: string(RetryRefreshOntoBase), Label: "Refresh onto base", Description: "Start the retry from the current base branch, discarding work already pushed on this task's branch.", Default: true},
{ID: string(RetryContinuePushedWork), Label: "Continue pushed work", Description: "Resume the branch this task already pushed, keeping its commits.", RequiresBranch: true},
}
}
// CheckDecline reports whether a task in this status can be declined.
//
// The legacy chat command expresses cancel, stop, reject and abandon as one
+10 -7
View File
@@ -21,23 +21,26 @@ type changeStatusMeta struct {
// struct rather than an inline map so the wire shape is declared in one place
// and pinned against the dashboard's freeze-dried snapshot by a fixture test.
type taskMetaView struct {
Statuses []taskstate.StatusMeta `json:"statuses"`
Actions []taskstate.ActionMeta `json:"actions"`
ChangeStatuses []changeStatusMeta `json:"change_statuses"`
ConfigSchema string `json:"config_schema"`
Statuses []taskstate.StatusMeta `json:"statuses"`
Actions []taskstate.ActionMeta `json:"actions"`
RetryModes []taskstate.RetryModeMeta `json:"retry_modes"`
ChangeStatuses []changeStatusMeta `json:"change_statuses"`
ConfigSchema string `json:"config_schema"`
}
// buildTaskMeta derives the lifecycle presentation catalog: the status
// vocabulary (with label, pill severity, "needs you" grouping), the operator
// action controls (with label, button variant, confirm prompt), the
// action controls (with label, button variant, confirm prompt), the retry
// worktree modes (with label, description and which is the default), the
// changes_captured status labels and the schema stamp a config_captured
// payload carries. Everything the dashboard can present that also exists on
// the server is derived here, so the frontend never has to keep a hand-synced
// copy of the vocabulary or the control set.
func buildTaskMeta() taskMetaView {
return taskMetaView{
Statuses: taskstate.Statuses(),
Actions: taskstate.ActionCatalog(),
Statuses: taskstate.Statuses(),
Actions: taskstate.ActionCatalog(),
RetryModes: taskstate.RetryModes(),
ChangeStatuses: []changeStatusMeta{
{ID: task.ChangeAdded, Label: "Added"},
{ID: task.ChangeModified, Label: "Modified"},
+22
View File
@@ -35,6 +35,13 @@ func TestTaskMetaCatalog(t *testing.T) {
Kind string `json:"kind"`
Confirm string `json:"confirm"`
} `json:"actions"`
RetryModes []struct {
ID string `json:"id"`
Label string `json:"label"`
Description string `json:"description"`
Default bool `json:"default"`
RequiresBranch bool `json:"requires_branch"`
} `json:"retry_modes"`
ChangeStatuses []struct {
ID string `json:"id"`
Label string `json:"label"`
@@ -51,6 +58,21 @@ func TestTaskMetaCatalog(t *testing.T) {
if len(got.Actions) == 0 {
t.Error("actions empty")
}
if len(got.RetryModes) == 0 {
t.Error("retry_modes empty; the retry dialog would offer no mode")
}
defaults := 0
for _, m := range got.RetryModes {
if m.ID == "" || m.Label == "" || m.Description == "" {
t.Errorf("retry mode missing id/label/description: %+v", m)
}
if m.Default {
defaults++
}
}
if defaults != 1 {
t.Errorf("retry_modes has %d defaults, want exactly 1", defaults)
}
if len(got.ChangeStatuses) == 0 {
t.Error("change_statuses empty; the dashboard renders raw status codes without it")
}
+14 -8
View File
@@ -199,6 +199,12 @@ type taskActionRequest struct {
// absent selection means all of them. It is ignored by every other
// action.
Findings []string `json:"findings"`
// RetryMode is the operator's worktree choice for a retry
// (taskstate.RetryMode): refresh onto the base branch, or continue the
// work already pushed on the task's branch. The retry control sends one;
// an empty value means the explicit default, refresh_onto_base. It is
// ignored by every other action.
RetryMode string `json:"retry_mode"`
}
func (s *Server) handleTaskAction(w http.ResponseWriter, r *http.Request) {
@@ -232,7 +238,7 @@ func (s *Server) handleTaskAction(w http.ResponseWriter, r *http.Request) {
writeJSON(w, map[string]any{"ok": true, "action": action, "task_id": id})
}
func decodeTaskAction(w http.ResponseWriter, r *http.Request) (taskstate.Action, taskactions.ReviewResponse, bool) {
func decodeTaskAction(w http.ResponseWriter, r *http.Request) (taskstate.Action, taskactions.ActionPayload, bool) {
r.Body = http.MaxBytesReader(w, r.Body, 4096)
var req taskActionRequest
decoder := json.NewDecoder(r.Body)
@@ -240,19 +246,19 @@ func decodeTaskAction(w http.ResponseWriter, r *http.Request) (taskstate.Action,
if err := decoder.Decode(&req); err != nil {
if _, ok := errors.AsType[*http.MaxBytesError](err); ok {
http.Error(w, "action body too large", http.StatusRequestEntityTooLarge)
return "", taskactions.ReviewResponse{}, false
return "", taskactions.ActionPayload{}, false
}
http.Error(w, "invalid action", http.StatusBadRequest)
return "", taskactions.ReviewResponse{}, false
return "", taskactions.ActionPayload{}, false
}
if err := decoder.Decode(&struct{}{}); !errors.Is(err, io.EOF) {
http.Error(w, "invalid action", http.StatusBadRequest)
return "", taskactions.ReviewResponse{}, false
return "", taskactions.ActionPayload{}, false
}
action := taskstate.Action(req.Action)
if !taskMutation(action) {
http.Error(w, "unknown action", http.StatusBadRequest)
return "", taskactions.ReviewResponse{}, false
return "", taskactions.ActionPayload{}, false
}
// A re-review without instructions is not a request the gate can honour,
// and refusing it here keeps the refusal the operator's to read rather
@@ -260,9 +266,9 @@ func decodeTaskAction(w http.ResponseWriter, r *http.Request) (taskstate.Action,
// that do not pass through this handler.
if action == taskstate.ActionRereview && strings.TrimSpace(req.Instructions) == "" {
http.Error(w, "a re-review needs instructions", http.StatusBadRequest)
return "", taskactions.ReviewResponse{}, false
return "", taskactions.ActionPayload{}, false
}
return action, taskactions.ReviewResponse{Instructions: req.Instructions, Findings: req.Findings}, true
return action, taskactions.ActionPayload{Instructions: req.Instructions, Findings: req.Findings, RetryMode: taskstate.RetryMode(req.RetryMode)}, true
}
func taskMutation(action taskstate.Action) bool {
@@ -359,7 +365,7 @@ func validOrigin(u *url.URL, wantScheme, wantHost string) bool {
// timeline needs its event bus, and stopping running work needs the
// goroutine or container that is executing it. Composing a local service
// over the task store alone would silently drop all four.
func (s *Server) applyOperatorTaskAction(ctx context.Context, id int64, action taskstate.Action, res taskactions.ReviewResponse) error {
func (s *Server) applyOperatorTaskAction(ctx context.Context, id int64, action taskstate.Action, res taskactions.ActionPayload) error {
if s.Chat == nil || s.Chat.Contract == nil {
return fmt.Errorf("%w: no gateway contract is wired", taskactions.ErrUnavailable)
}
+46 -2
View File
@@ -72,7 +72,7 @@ type daemonActions struct {
}
func (d *daemonActions) ApplyChatTaskAction(
ctx context.Context, identity *string, actor taskactions.Actor, id int64, action taskstate.Action, res taskactions.ReviewResponse,
ctx context.Context, identity *string, actor taskactions.Actor, id int64, action taskstate.Action, res taskactions.ActionPayload,
) (gateway.TaskActionResult, error) {
d.scopes = append(d.scopes, identity)
service := taskactionstore.NewService(
@@ -236,7 +236,7 @@ func TestRetryEnforcesMaxRetries(t *testing.T) {
// (RetryTask) rather than a raw counter bump, re-parking
// between retries so each call sees the fromStatus it needs.
for range tc.priorCount {
if err := srv.Store.RetryTask(ctx, task.ID, workflow.StatusParked, ""); err != nil {
if err := srv.Store.RetryTask(ctx, task.ID, workflow.StatusParked, "", ""); err != nil {
t.Fatal(err)
}
taskstatetest.Seed(ctx, t, srv.Store, task.ID, workflow.StatusQueued, workflow.StatusParked, "re-parked for test fixture")
@@ -898,3 +898,47 @@ func TestTaskActionRequiresCSRFHeader(t *testing.T) {
t.Fatalf("status = %d, want 403 without CSRF header (body %s)", w.Code, w.Body)
}
}
// TestRetryCarriesTheWorktreeModeToTheStore is the dashboard half of the
// operator retry choice: the mode in the action body reaches the store write,
// so the daemon reads the operator's choice rather than inferring one. The
// refusal case pins that continuing with nothing pushed is a conflict, not a
// queued resume.
func TestRetryCarriesTheWorktreeModeToTheStore(t *testing.T) {
t.Run("continue pushed work persists the choice", func(t *testing.T) {
srv, task, _, _, _ := actionServer(t, workflow.StatusParked, "it broke")
if err := srv.Store.Update(t.Context(), &workflow.Task{ID: task.ID, Branch: "fix/11-thing"}); err != nil {
t.Fatal(err)
}
w := postActionBody(t, srv, task.ID, `{"action":"retry","retry_mode":"continue_pushed_work"}`)
if w.Code != http.StatusOK {
t.Fatalf("status = %d, want 200 (body %s)", w.Code, w.Body)
}
got, err := srv.Store.TaskByID(t.Context(), task.ID)
if err != nil || got == nil {
t.Fatalf("TaskByID = (%+v, %v)", got, err)
}
if got.RetryMode != string(taskstate.RetryContinuePushedWork) {
t.Errorf("retry_mode = %q, want %q", got.RetryMode, taskstate.RetryContinuePushedWork)
}
})
t.Run("continue with no branch is refused", func(t *testing.T) {
srv, task, _, _, _ := actionServer(t, workflow.StatusParked, "it broke")
w := postActionBody(t, srv, task.ID, `{"action":"retry","retry_mode":"continue_pushed_work"}`)
if w.Code != http.StatusConflict {
t.Fatalf("status = %d, want 409 (body %s)", w.Code, w.Body)
}
got, err := srv.Store.TaskByID(t.Context(), task.ID)
if err != nil || got == nil {
t.Fatalf("TaskByID = (%+v, %v)", got, err)
}
if got.Status != workflow.StatusParked {
t.Errorf("status = %q, want the task left parked", got.Status)
}
})
}
+2 -2
View File
@@ -93,7 +93,7 @@ func twoAttemptTask(t *testing.T, srv *Server) *workflow.Task {
if err := srv.Store.Transition(ctx, first.ID, workflow.StatusRunning, workflow.StatusParked, "stage implement: builder exited 1"); err != nil {
t.Fatal(err)
}
if err := srv.Store.RetryTask(ctx, first.ID, workflow.StatusParked, ""); err != nil {
if err := srv.Store.RetryTask(ctx, first.ID, workflow.StatusParked, "", ""); err != nil {
t.Fatal(err)
}
second, err := srv.Store.ClaimNext(ctx)
@@ -328,7 +328,7 @@ func TestHandleTaskAttemptsRendersBothAttemptsOfARetry(t *testing.T) {
if err := srv.Store.Transition(ctx, claimed1.ID, workflow.StatusRunning, workflow.StatusParked, "stage implement: builder exited 1"); err != nil {
t.Fatal(err)
}
if err := srv.Store.RetryTask(ctx, claimed1.ID, workflow.StatusParked, ""); err != nil {
if err := srv.Store.RetryTask(ctx, claimed1.ID, workflow.StatusParked, "", ""); err != nil {
t.Fatal(err)
}
current, err := srv.Store.ClaimNext(ctx)
+6 -1
View File
@@ -168,11 +168,16 @@ message ApplyOperatorTaskActionRequest {
string actor_kind = 4;
string principal_id = 5;
// instructions and findings are the review gate answer payload
// (taskactions.ReviewResponse): the instructions a rereview requires, and
// (taskactions.ActionPayload): the instructions a rereview requires, and
// the finding keys an approve posts (empty means every offered finding).
// They are empty for every other action.
string instructions = 6;
repeated string findings = 7;
// retry_mode is the operator's worktree choice for a retry
// (taskstate.RetryMode): refresh onto the base branch or continue the work
// already pushed on the task's branch. It is empty for every other action,
// and chat carries no mode syntax -- an empty value means refresh_onto_base.
string retry_mode = 8;
}
message ApplyOperatorTaskActionResponse { int64 task_id = 1; string action = 2; string message = 3; }
message SaveSessionResponse {}
+9
View File
@@ -360,6 +360,12 @@ message Task {
// from retry_count and remediation_rounds for the same reason those are
// separate from each other.
int64 rereview_rounds = 40;
// retry_mode is the operator's worktree choice for the next dispatch
// (taskstate.RetryMode: refresh_onto_base, continue_pushed_work). The retry
// action writes it and the daemon's prepareWorkspace reads it, so it must
// cross the wire for a retry to land on the source the operator chose. The
// empty string reads as refresh_onto_base.
string retry_mode = 41;
}
// Event mirrors internal/events.Event. Data is carried as a JSON object
@@ -708,6 +714,9 @@ message RetryTaskRequest {
int64 task_id = 1;
string from_status = 2;
string workflow = 3;
// retry_mode is the operator's worktree choice (taskstate.RetryMode) the
// requeue persists. Empty reads as refresh_onto_base.
string retry_mode = 4;
}
message RetryTaskResponse {}
+1 -1
View File
@@ -1,2 +1,2 @@
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-divide-x-reverse:0;--tw-border-style:solid;--tw-divide-y-reverse:0;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-scrollbar-thumb:#0000;--tw-scrollbar-track:#0000;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0;--scroll-fade-b:0;--scroll-fade-s:0;--scroll-fade-e:0;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@font-face{font-family:IBM Plex Sans Variable;font-style:normal;font-display:swap;font-weight:100 700;src:url(/assets/ibm-plex-sans-cyrillic-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:IBM Plex Sans Variable;font-style:normal;font-display:swap;font-weight:100 700;src:url(/assets/ibm-plex-sans-cyrillic-wght-normal.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:IBM Plex Sans Variable;font-style:normal;font-display:swap;font-weight:100 700;src:url(/assets/ibm-plex-sans-greek-wght-normal.woff2)format("woff2-variations");unicode-range:U+370-377,U+37A-37F,U+384-38A,U+38C,U+38E-3A1,U+3A3-3FF}@font-face{font-family:IBM Plex Sans Variable;font-style:normal;font-display:swap;font-weight:100 700;src:url(/assets/ibm-plex-sans-vietnamese-wght-normal.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:IBM Plex Sans Variable;font-style:normal;font-display:swap;font-weight:100 700;src:url(/assets/ibm-plex-sans-latin-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans Variable;font-style:normal;font-display:swap;font-weight:100 700;src:url(/assets/ibm-plex-sans-latin-wght-normal.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/assets/ibm-plex-mono-cyrillic-ext-400-normal.woff2)format("woff2"),url(/assets/ibm-plex-mono-cyrillic-ext-400-normal.woff)format("woff");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:IBM Plex Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/assets/ibm-plex-mono-cyrillic-400-normal.woff2)format("woff2"),url(/assets/ibm-plex-mono-cyrillic-400-normal.woff)format("woff");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:IBM Plex Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/assets/ibm-plex-mono-vietnamese-400-normal.woff2)format("woff2"),url(/assets/ibm-plex-mono-vietnamese-400-normal.woff)fLine truncated
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-divide-x-reverse:0;--tw-border-style:solid;--tw-divide-y-reverse:0;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-scrollbar-thumb:#0000;--tw-scrollbar-track:#0000;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0;--scroll-fade-b:0;--scroll-fade-s:0;--scroll-fade-e:0;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@font-face{font-family:IBM Plex Sans Variable;font-style:normal;font-display:swap;font-weight:100 700;src:url(/assets/ibm-plex-sans-cyrillic-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:IBM Plex Sans Variable;font-style:normal;font-display:swap;font-weight:100 700;src:url(/assets/ibm-plex-sans-cyrillic-wght-normal.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:IBM Plex Sans Variable;font-style:normal;font-display:swap;font-weight:100 700;src:url(/assets/ibm-plex-sans-greek-wght-normal.woff2)format("woff2-variations");unicode-range:U+370-377,U+37A-37F,U+384-38A,U+38C,U+38E-3A1,U+3A3-3FF}@font-face{font-family:IBM Plex Sans Variable;font-style:normal;font-display:swap;font-weight:100 700;src:url(/assets/ibm-plex-sans-vietnamese-wght-normal.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:IBM Plex Sans Variable;font-style:normal;font-display:swap;font-weight:100 700;src:url(/assets/ibm-plex-sans-latin-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans Variable;font-style:normal;font-display:swap;font-weight:100 700;src:url(/assets/ibm-plex-sans-latin-wght-normal.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/assets/ibm-plex-mono-cyrillic-ext-400-normal.woff2)format("woff2"),url(/assets/ibm-plex-mono-cyrillic-ext-400-normal.woff)format("woff");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:IBM Plex Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/assets/ibm-plex-mono-cyrillic-400-normal.woff2)format("woff2"),url(/assets/ibm-plex-mono-cyrillic-400-normal.woff)format("woff");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:IBM Plex Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/assets/ibm-plex-mono-vietnamese-400-normal.woff2)format("woff2"),url(/assets/ibm-plex-mono-vietnamese-400-normal.woff)fLine truncated
+58 -58
View File
@@ -16,59 +16,59 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
Defaulting to \`null\`.`),null)}function BS(e){return RS(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${FS}\`.`),FS)}var VS=M({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:FS},getValueLabel:{type:Function,required:!1,default:(e,t)=>RS(e)?`${Math.round(e/t*FS)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;Y();let i=qh(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=qh(n,`max`,r,{passive:n.max===void 0});j(()=>i.value,async e=>{let t=zS(e,n.max);t!==e&&(await ar(),i.value=t)},{immediate:!0}),j(()=>n.max,e=>{let t=BS(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=W(()=>ch(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return LS({modelValue:i,max:a,progressState:o}),(e,t)=>(I(),R(k(X),{"as-child":e.asChild,as:e.as,"aria-valuemax":k(a),"aria-valuemin":0,"aria-valuenow":RS(k(i))?k(i):void 0,"aria-valuetext":e.getValueText?.(k(i),k(a)),"aria-label":e.getValueLabel(k(i),k(a)),role:`progressbar`,"data-state":o.value,"data-value":k(i)??void 0,"data-max":k(a)},{default:A(()=>[P(e.$slots,`default`,{modelValue:k(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),HS=M({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=IS();return Y(),(e,r)=>(I(),R(k(X),U(t,{"data-state":k(n).progressState.value,"data-value":k(n).modelValue?.value??void 0,"data-max":k(n).max.value}),{default:A(()=>[P(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),US=`radio.select`;function WS(e,t,n){sh(US,n,{originalEvent:e,value:t})}var GS=M({inheritAttrs:!1,__name:`Radio`,props:{id:{type:String,required:!1},value:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},checked:{type:Boolean,required:!1,default:void 0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:checked`,`select`],setup(e,{emit:t}){let n=e,r=t,i=qh(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=En(n),{forwardRef:o,currentElement:s}=Y(),c=vg(s),l=xg(),u=W(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||WS(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(I(),L(F,null,[B(k(X),U({id:e.id,ref:k(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":k(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":k(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:k(a),required:e.required,name:e.name},{...k(l),...e.$attrs},{onClick:lu(d,[`stop`])}),{default:A(()=>[P(e.$slots,`default`,{checked:k(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),k(c)&&e.name?(I(),R(k(Tv),U({key:0,type:`radio`,tabindex:`-1`,value:k(a),checked:!!k(i),name:e.name,disabled:e.disabled,required:e.required},k(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):H(`v-if`,!0)],64))}}),[KS,qS]=ah(`RadioGroupRoot`),JS=M({__name:`RadioGroupRoot`,props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=Y(),o=qh(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=En(n),p=pg(f),m=vg(a);return qS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(I(),R(k(sx),{"as-child":``,orientation:k(l),dir:k(p),loop:k(c)},{default:A(()=>[B(k(X),{ref:k(i),role:`radiogroup`,"data-disabled":k(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":k(l),"aria-required":k(d),dir:k(p)},{default:A(()=>[P(e.$slots,`default`,{modelValue:k(o)}),k(m)&&k(u)?(I(),R(k(Tv),{key:0,required:k(d),disabled:k(s),value:k(o),name:k(u)},null,8,[`required`,`disabled`,`value`,`name`])):H(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[YS,XS]=ah(`RadioGroupItem`),ZS=M({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:null,reLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:KE(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>KE(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=JE(c),u=e+1<n.length?JE(n[e+1]):null;if(l&&u&&YE(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=JE(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>KE(e)),rows:r.map(e=>e.map(e=>KE(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:KE(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]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:KE(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function JE(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 YE(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var XE={class:`[overflow-wrap:anywhere]`},ZE={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},QE={class:`font-mono text-[0.85em]`},$E={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`},tD={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},nD={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},rD={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},iD={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},aD={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},oD={key:8,class:`mb-2.5 last:mb-0`},sD=M({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=W(()=>qE(t.text));return(e,t)=>(I(),L(`div`,XE,[(I(!0),L(F,null,N(n.value,(e,t)=>(I(),L(F,{key:t},[e.kind===`pre`?(I(),L(`pre`,ZE,[z(`code`,QE,D(e.code),1)])):e.kind===`table`?(I(),L(`table`,$E,[z(`thead`,null,[z(`tr`,null,[(I(!0),L(F,null,N(e.head,(e,t)=>(I(),L(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[B(WE,{inline:e},null,8,[`inline`])]))),128))])]),z(`tbody`,null,[(I(!0),L(F,null,N(e.rows,(e,t)=>(I(),L(`tr`,{key:t},[(I(!0),L(F,null,N(e,(e,t)=>(I(),L(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[B(WE,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(I(),L(`blockquote`,eD,[B(WE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(I(),L(`h1`,tD,[B(WE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(I(),L(`h2`,nD,[B(WE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(I(),L(`h3`,rD,[B(WE,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(I(),L(`ul`,iD,[(I(!0),L(F,null,N(e.items,(e,t)=>(I(),L(`li`,{key:t},[B(WE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(I(),L(`ol`,aD,[(I(!0),L(F,null,N(e.items,(e,t)=>(I(),L(`li`,{key:t},[B(WE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(I(),L(`p`,oD,[B(WE,{inline:e.inline},null,8,[`inline`])])):H(``,!0)],64))),128))]))}}),cD={class:`truncate`},lD=M({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ma(`RouterLink`);return I(),R(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full 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:A(()=>[B(k(bd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),z(`span`,cD,D(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),uD={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},dD={class:`font-semibold text-foreground`},fD={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},pD=M({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=W(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=W(()=>t.tool.parameters||t.tool.Parameters||``),i=W(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=W(()=>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?(I(),R(lD,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(I(),L(`div`,uD,[B(k(lf),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),z(`span`,dD,D(n.value),1),r.value?(I(),L(`code`,fD,D(r.value),1)):H(``,!0),z(`span`,{class:E(k(q)(`text-fg-muted`,i.value&&`text-danger`))},D(a.value),3)]))}}),mD={key:0,class:`mb-2 grid gap-0.5 text-xs`},hD={key:1,class:`mb-2 flex flex-wrap gap-1.5`},gD={key:3,class:`whitespace-pre-wrap`},_D=M({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(I(),L(`div`,{class:E([`flex`,e.assistant?`justify-start`:`justify-end`])},[z(`div`,{class:E(k(q)(`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?(I(),L(`div`,mD,[(I(!0),L(F,null,N(e.tools,(t,n)=>(I(),R(pD,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):H(``,!0),e.media.length?(I(),L(`div`,hD,[(I(!0),L(F,null,N(e.media,(e,t)=>(I(),R(LE,{key:t,attachment:e},null,8,[`attachment`]))),128))])):H(``,!0),e.assistant?(I(),R(sD,{key:2,text:e.text},null,8,[`text`])):(I(),L(`div`,gD,D(e.text),1)),P(t.$slots,`default`)],2)],2))}}),vD={class:`w-full self-center justify-self-center py-6 text-center`},yD={class:`grid gap-2`},bD=[`onClick`],xD=M({__name:`ChatEmptyState`,emits:[`proLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>HM?`${n.slice(0,HM).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var WM=[`title`],GM=M({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=W(()=>gM(n.event)),a=W(()=>UM(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=W(()=>n.event.at?Dj(n.event.at):`—`);return(e,t)=>(I(),R(k(zM),{class:E(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[du(lu(o,[`prevent`]),[`enter`]),du(lu(o,[`prevent`]),[`space`])]},{default:A(()=>[B(k($),{class:`font-medium`},{default:A(()=>[V(D(n.event.kind||n.event.type||`event`),1)]),_:1}),B(k($),{class:`font-mono`},{default:A(()=>[V(D(i.value>0?`#${i.value}`:`—`),1)]),_:1}),B(k($),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},D(a.value.text),9,WM)]),_:1}),B(k($),null,{default:A(()=>[V(D(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),KM=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function qM(e){return(Number(e?.task_id)||0)>0}function JM(e,t){return t===`tasks`?qM(e):t!==`system`||!qM(e)}function YM(e,t){return e.filter(e=>JM(e,t))}function XM(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function ZM(e,t){return`${e}:${t??0}`}function QM(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=ZM(UM(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var $M={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},eN={class:`max-h-[28rem] overflow-y-auto`},tN=[`aria-expanded`,`aria-label`,`onClick`],nN=[`title`],rN=M({__name:`LiveActivityCard`,setup(e){let t=WD(),{activity:n,streamKind:r,streamState:i}=ad(kA()),a=O(`all`),o=W(()=>YM(n.value,a.value)),s=W(()=>XM(o.value.length,a.value)),c=nn(new Set),l=W(()=>QM(o.value));function u(e){c.has(e)?c.delete(e):c.add(e)}function d(e){return c.has(e.key)}function f(e){return UM(e.representative)}function p(e){return e.representative.at?Dj(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(I(),R(k(bj),null,{default:A(()=>[B(k(Tj),null,{default:A(()=>[B(k(Ej),null,{default:A(()=>[...t[1]||=[V(`Live activity`,-1)]]),_:1}),B(k(xj),{class:`flex items-center gap-2`},{default:A(()=>[B(k(tA),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:k(KM)},null,8,[`modelValue`,`options`]),B(k(_j),{variant:k(r)},{default:A(()=>[V(D(k(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),B(k(Sj),null,{default:A(()=>[z(`div`,$M,[z(`div`,eN,[B(k(LM),null,{default:A(()=>[B(k(VM),{class:`sticky top-0 z-10 bg-card`},{default:A(()=>[B(k(zM),null,{default:A(()=>[B(k(BM),null,{default:A(()=>[...t[2]||=[V(`Event`,-1)]]),_:1}),B(k(BM),null,{default:A(()=>[...t[3]||=[V(`Task`,-1)]]),_:1}),B(k(BM),null,{default:A(()=>[...t[4]||=[V(`Detail`,-1)]]),_:1}),B(k(BM),null,{default:A(()=>[...t[5]||=[V(`When`,-1)]]),_:1})]),_:1})]),_:1}),B(k(RM),null,{default:A(()=>[o.value.length?H(``,!0):(I(),R(k(zM),{key:0},{default:A(()=>[B(k($),{colspan:`4`},{default:A(()=>[B(k(lj),null,{default:A(()=>[B(k(fj),null,{default:A(()=>[B(k(hj),null,{default:A(()=>[V(D(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(I(!0),L(F,{key:1},N(l.value,e=>(I(),L(F,{key:e.key},[e.count===1?(I(),R(GM,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(I(),L(F,{key:1},[B(k(zM),{class:E(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&m(e.taskID),onKeydown:[du(lu(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),du(lu(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:A(()=>[B(k($),{class:`font-medium`},{default:A(()=>[z(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":d(e),"aria-label":`${d(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:lu(t=>u(e.key),[`stop`])},[d(e)?(I(),R(k(wd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(I(),R(k(Td),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),V(` `+D(e.label)+` `,1),B(k(_j),{variant:`idle`},{default:A(()=>[V(`×`+D(e.count),1)]),_:2},1024)],8,tN)]),_:2},1024),B(k($),{class:`font-mono`},{default:A(()=>[V(D(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),B(k($),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},D(f(e).text),9,nN)]),_:2},1024),B(k($),null,{default:A(()=>[V(D(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(I(!0),L(F,{key:0},N(e.events,(t,n)=>(I(),R(GM,{key:`${e.key}:${n}`,event:t,onO 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 mP(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 hP(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 gP(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 _P(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 vP=O([]),yP=O([]),bP=O(!0),xP=O(null),SP=O(null),CP=O(!1),wP=O(null);async function TP(){try{let e=await J.eventTypes();bP.value=e.enabled!==!1,vP.value=e.event_types||[],yP.value=e.proposals||[],xP.value=null}catch(e){xP.value=e.message||String(e)}}function EP(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function DP(e){wP.value=null,SP.value=e}function OP(e){let t=IP.value.find(t=>String(t.id)===e.sample_id);DP({mode:`proposal`,id:null,source:e.source,name:``,rule:EP(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function kP(e=``){DP({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function AP(e){DP({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:EP(e.rule),headersText:``,body:``,exampleHeaders:{}})}function jP(){SP.value=null}async function MP(){let e=SP.value;if(e){CP.value=!0;try{if(e.mode===`edit`&&e.id)await J.eventTypeUpdate(e.id,{name:e.name,rule:_P(e.rule)});else{let t=e.mode===`paste`?pP(e.headersText):e.exampleHeaders;await J.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:_P(e.rule),example:{headers:t,body:e.body}})}SP.value=null,await TP()}catch(e){wP.value=e.message||String(e)}finally{CP.value=!1}}}var NP=O(null);async function PP(){let e=NP.value;if(NP.value=null,e)try{await J.eventTypeDelete(e.id),await TP()}catch(e){xP.value=e.message||String(e)}}var FP=100,IP=O([]),LP=O(!0),RP=O(null),zP=O(!0),BP=O(null);async function VP(){try{let e=await J.captures(FP);LP.value=e.enabled!==!1,IP.value=e.captures||[],RP.value=null}catch(e){RP.value=e.message||String(e)}finally{zP.value=!1}}function HP(e){let t=IP.value.find(t=>t.id===e);return t&&(BP.value=t),!!t}function UP(){IP.value.length&&(BP.value=IP.value[0])}function WP(){AA(`captures`,()=>{VP(),TP()})}var GP=M({__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=bg(Pw(n,`class`),r);return(e,t)=>(I(),R(k(VC),U({"data-slot":`tabs`,"data-orientation":k(i).orientation||`horizontal`},k(i),{class:k(q)(`gap-2 group/tabs flex data-horizontal:flex-col`,n.class)}),{default:A(t=>[P(e.$slots,`default`,Ce(Ds(t)))]),_:3},16,[`data-orientation`,`class`]))}}),KP=M({__name:`TabsContent`,props:{value:{},forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=Pw(t,`class`);return(e,r)=>(I(),R(k(WC),U({"data-slot":`tabs-content`,class:k(q)(`text-sm flex-1 outline-none`,t.class)},k(n)),{default:A(()=>[P(e.$slots,`default`)]),_:3},16,[`class`]))}}),qP=M({__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=Pw(t,`class`,`variant`);return(r,i)=>(I(),R(k(GC),U({"data-slot":`tabs-list`,"data-variant":e.variant},k(n),{class:k(q)(k(YP)({variant:e.variant}),t.class)}),{default:A(()=>[P(r.$slots,`default`)]),_:3},16,[`data-variant`,`class`]))}}),JP=M({__name:`TabsTrigger`,props:{value:{},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=yg(Pw(t,`class`));return(e,r)=>(I(),R(k(KC),U({"data-slot":`tabs-trigger`,class:k(q)(`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:pointer-events-none disabledLine truncated
`)}};Eq.defaultYaml={explicit:!1,version:`1.2`},Eq.defaultTags={"!!":`tag:yaml.org,2002:`};function Dq(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function Oq(e){let t=new Set;return yq(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function kq(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function Aq(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=Oq(e);let a=kq(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(dq(t.node)||pq(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function jq(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=jq(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=jq(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=jq(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=jq(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function Mq(e,t,n){if(Array.isArray(e))return e.map((e,t)=>Mq(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!hq(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var Nq=class{constructor(e){Object.defineProperty(this,oq,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!cq(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=Mq(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?jq(i,{"":o},``,o):o}},Pq=class extends Nq{constructor(e){super(eq),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],yq(e,{Node:(e,t)=>{(sq(t)||hq(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(Mq(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Fq(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(Dq(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function Fq(e,t,n){if(sq(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(pq(t)){let r=0;for(let i of t.items){let t=Fq(e,i,n);t>r&&(r=t)}return r}if(uq(t)){let r=Fq(e,t.key,n),i=Fq(e,t.value,n);return Math.max(r,i)}return 1}var Iq=e=>!e||typeof e!=`function`&&typeof e!=`object`,Lq=class extends Nq{constructor(e){super(iq),this.value=e}toJSON(e,t){return t?.keep?this.value:Mq(this.value,e,t)}toString(){return String(this.value)}};Lq.BLOCK_FOLDED=`BLOCK_FOLDED`,Lq.BLOCK_LITERAL=`BLOCK_LITERAL`,Lq.PLAIN=`PLAIN`,Lq.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Lq.QUOTE_SINGLE=`QUOTE_SINGLE`;var Rq=`tag:yaml.org,2002:`;function zq(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function Bq(e,t,n){if(cq(e)&&(e=e.contents),mq(e))return e;if(uq(e)){let t=n.schema[nq].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new Pq(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=Rq+t.slice(2));let l=zq(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new Lq(e);return c&&(c.node=t),t Line truncated
`)?Gq(n,t):n.includes(`
`)}),t}function JE(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 YE(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var XE={class:`[overflow-wrap:anywhere]`},ZE={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},QE={class:`font-mono text-[0.85em]`},$E={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`},tD={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},nD={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},rD={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},iD={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},aD={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},oD={key:8,class:`mb-2.5 last:mb-0`},sD=M({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=W(()=>qE(t.text));return(e,t)=>(I(),L(`div`,XE,[(I(!0),L(F,null,N(n.value,(e,t)=>(I(),L(F,{key:t},[e.kind===`pre`?(I(),L(`pre`,ZE,[z(`code`,QE,D(e.code),1)])):e.kind===`table`?(I(),L(`table`,$E,[z(`thead`,null,[z(`tr`,null,[(I(!0),L(F,null,N(e.head,(e,t)=>(I(),L(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[B(WE,{inline:e},null,8,[`inline`])]))),128))])]),z(`tbody`,null,[(I(!0),L(F,null,N(e.rows,(e,t)=>(I(),L(`tr`,{key:t},[(I(!0),L(F,null,N(e,(e,t)=>(I(),L(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[B(WE,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(I(),L(`blockquote`,eD,[B(WE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(I(),L(`h1`,tD,[B(WE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(I(),L(`h2`,nD,[B(WE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(I(),L(`h3`,rD,[B(WE,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(I(),L(`ul`,iD,[(I(!0),L(F,null,N(e.items,(e,t)=>(I(),L(`li`,{key:t},[B(WE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(I(),L(`ol`,aD,[(I(!0),L(F,null,N(e.items,(e,t)=>(I(),L(`li`,{key:t},[B(WE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(I(),L(`p`,oD,[B(WE,{inline:e.inline},null,8,[`inline`])])):H(``,!0)],64))),128))]))}}),cD={class:`truncate`},lD=M({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ma(`RouterLink`);return I(),R(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full 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:A(()=>[B(k(bd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),z(`span`,cD,D(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),uD={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},dD={class:`font-semibold text-foreground`},fD={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},pD=M({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=W(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=W(()=>t.tool.parameters||t.tool.Parameters||``),i=W(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=W(()=>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?(I(),R(lD,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(I(),L(`div`,uD,[B(k(lf),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),z(`span`,dD,D(n.value),1),r.value?(I(),L(`code`,fD,D(r.value),1)):H(``,!0),z(`span`,{class:E(k(q)(`text-fg-muted`,i.value&&`text-danger`))},D(a.value),3)]))}}),mD={key:0,class:`mb-2 grid gap-0.5 text-xs`},hD={key:1,class:`mb-2 flex flex-wrap gap-1.5`},gD={key:3,class:`whitespace-pre-wrap`},_D=M({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(I(),L(`div`,{class:E([`flex`,e.assistant?`justify-start`:`justify-end`])},[z(`div`,{class:E(k(q)(`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?(I(),L(`div`,mD,[(I(!0),L(F,null,N(e.tools,(t,n)=>(I(),R(pD,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):H(``,!0),e.media.length?(I(),L(`div`,hD,[(I(!0),L(F,null,N(e.media,(e,t)=>(I(),R(LE,{key:t,attachment:e},null,8,[`attachment`]))),128))])):H(``,!0),e.assistant?(I(),R(sD,{key:2,text:e.text},null,8,[`text`])):(I(),L(`div`,gD,D(e.text),1)),P(t.$slots,`default`)],2)],2))}}),vD={class:`w-full self-center justify-self-center py-6 text-center`},yD={class:`grid gap-2`},bD=[`onClick`],xD=M({__name:`ChatEmptyState`,emits:[`proLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>GM?`${n.slice(0,GM).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var qM=[`title`],JM=M({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=W(()=>yM(n.event)),a=W(()=>KM(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=W(()=>n.event.at?Dj(n.event.at):`—`);return(e,t)=>(I(),R(k(HM),{class:E(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[du(lu(o,[`prevent`]),[`enter`]),du(lu(o,[`prevent`]),[`space`])]},{default:A(()=>[B(k($),{class:`font-medium`},{default:A(()=>[V(D(n.event.kind||n.event.type||`event`),1)]),_:1}),B(k($),{class:`font-mono`},{default:A(()=>[V(D(i.value>0?`#${i.value}`:`—`),1)]),_:1}),B(k($),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},D(a.value.text),9,qM)]),_:1}),B(k($),null,{default:A(()=>[V(D(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),YM=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function XM(e){return(Number(e?.task_id)||0)>0}function ZM(e,t){return t===`tasks`?XM(e):t!==`system`||!XM(e)}function QM(e,t){return e.filter(e=>ZM(e,t))}function $M(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function eN(e,t){return`${e}:${t??0}`}function tN(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=eN(KM(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var nN={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},rN={class:`max-h-[28rem] overflow-y-auto`},iN=[`aria-expanded`,`aria-label`,`onClick`],aN=[`title`],oN=M({__name:`LiveActivityCard`,setup(e){let t=WD(),{activity:n,streamKind:r,streamState:i}=ad(kA()),a=O(`all`),o=W(()=>QM(n.value,a.value)),s=W(()=>$M(o.value.length,a.value)),c=nn(new Set),l=W(()=>tN(o.value));function u(e){c.has(e)?c.delete(e):c.add(e)}function d(e){return c.has(e.key)}function f(e){return KM(e.representative)}function p(e){return e.representative.at?Dj(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(I(),R(k(bj),null,{default:A(()=>[B(k(Tj),null,{default:A(()=>[B(k(Ej),null,{default:A(()=>[...t[1]||=[V(`Live activity`,-1)]]),_:1}),B(k(xj),{class:`flex items-center gap-2`},{default:A(()=>[B(k(tA),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:k(YM)},null,8,[`modelValue`,`options`]),B(k(_j),{variant:k(r)},{default:A(()=>[V(D(k(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),B(k(Sj),null,{default:A(()=>[z(`div`,nN,[z(`div`,rN,[B(k(BM),null,{default:A(()=>[B(k(WM),{class:`sticky top-0 z-10 bg-card`},{default:A(()=>[B(k(HM),null,{default:A(()=>[B(k(UM),null,{default:A(()=>[...t[2]||=[V(`Event`,-1)]]),_:1}),B(k(UM),null,{default:A(()=>[...t[3]||=[V(`Task`,-1)]]),_:1}),B(k(UM),null,{default:A(()=>[...t[4]||=[V(`Detail`,-1)]]),_:1}),B(k(UM),null,{default:A(()=>[...t[5]||=[V(`When`,-1)]]),_:1})]),_:1})]),_:1}),B(k(VM),null,{default:A(()=>[o.value.length?H(``,!0):(I(),R(k(HM),{key:0},{default:A(()=>[B(k($),{colspan:`4`},{default:A(()=>[B(k(lj),null,{default:A(()=>[B(k(fj),null,{default:A(()=>[B(k(hj),null,{default:A(()=>[V(D(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(I(!0),L(F,{key:1},N(l.value,e=>(I(),L(F,{key:e.key},[e.count===1?(I(),R(JM,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(I(),L(F,{key:1},[B(k(HM),{class:E(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&m(e.taskID),onKeydown:[du(lu(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),du(lu(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:A(()=>[B(k($),{class:`font-medium`},{default:A(()=>[z(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":d(e),"aria-label":`${d(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:lu(t=>u(e.key),[`stop`])},[d(e)?(I(),R(k(wd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(I(),R(k(Td),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),V(` `+D(e.label)+` `,1),B(k(_j),{variant:`idle`},{default:A(()=>[V(`×`+D(e.count),1)]),_:2},1024)],8,iN)]),_:2},1024),B(k($),{class:`font-mono`},{default:A(()=>[V(D(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),B(k($),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},D(f(e).text),9,aN)]),_:2},1024),B(k($),null,{default:A(()=>[V(D(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(I(!0),L(F,{key:0},N(e.events,(t,n)=>(I(),R(JM,{key:`${e.key}:${n}`,event:t,onO 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 CP(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 wP(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 TP(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 EP(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 DP=O([]),OP=O([]),kP=O(!0),AP=O(null),jP=O(null),MP=O(!1),NP=O(null);async function PP(){try{let e=await J.eventTypes();kP.value=e.enabled!==!1,DP.value=e.event_types||[],OP.value=e.proposals||[],AP.value=null}catch(e){AP.value=e.message||String(e)}}function FP(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function IP(e){NP.value=null,jP.value=e}function LP(e){let t=GP.value.find(t=>String(t.id)===e.sample_id);IP({mode:`proposal`,id:null,source:e.source,name:``,rule:FP(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function RP(e=``){IP({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function zP(e){IP({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:FP(e.rule),headersText:``,body:``,exampleHeaders:{}})}function BP(){jP.value=null}async function VP(){let e=jP.value;if(e){MP.value=!0;try{if(e.mode===`edit`&&e.id)await J.eventTypeUpdate(e.id,{name:e.name,rule:EP(e.rule)});else{let t=e.mode===`paste`?SP(e.headersText):e.exampleHeaders;await J.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:EP(e.rule),example:{headers:t,body:e.body}})}jP.value=null,await PP()}catch(e){NP.value=e.message||String(e)}finally{MP.value=!1}}}var HP=O(null);async function UP(){let e=HP.value;if(HP.value=null,e)try{await J.eventTypeDelete(e.id),await PP()}catch(e){AP.value=e.message||String(e)}}var WP=100,GP=O([]),KP=O(!0),qP=O(null),JP=O(!0),YP=O(null);async function XP(){try{let e=await J.captures(WP);KP.value=e.enabled!==!1,GP.value=e.captures||[],qP.value=null}catch(e){qP.value=e.message||String(e)}finally{JP.value=!1}}function ZP(e){let t=GP.value.find(t=>t.id===e);return t&&(YP.value=t),!!t}function QP(){GP.value.length&&(YP.value=GP.value[0])}function $P(){AA(`captures`,()=>{XP(),PP()})}var eF=M({__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=bg(Pw(n,`class`),r);return(e,t)=>(I(),R(k(VC),U({"data-slot":`tabs`,"data-orientation":k(i).orientation||`horizontal`},k(i),{class:k(q)(`gap-2 group/tabs flex data-horizontal:flex-col`,n.class)}),{default:A(t=>[P(e.$slots,`default`,Ce(Ds(t)))]),_:3},16,[`data-orientation`,`class`]))}}),tF=M({__name:`TabsContent`,props:{value:{},forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=Pw(t,`class`);return(e,r)=>(I(),R(k(WC),U({"data-slot":`tabs-content`,class:k(q)(`text-sm flex-1 outline-none`,t.class)},k(n)),{default:A(()=>[P(e.$slots,`default`)]),_:3},16,[`class`]))}}),nF=M({__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=Pw(t,`class`,`variant`);return(r,i)=>(I(),R(k(GC),U({"data-slot":`tabs-list`,"data-variant":e.variant},k(n),{class:k(q)(k(iF)({variant:e.variant}),t.class)}),{default:A(()=>[P(r.$slots,`default`)]),_:3},16,[`data-variant`,`class`]))}}),rF=M({__name:`TabsTrigger`,props:{value:{},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=yg(Pw(t,`class`));return(e,r)=>(I(),R(k(KC),U({"data-slot":`tabs-trigger`,class:k(q)(`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:pointer-events-none disabledLine truncated
`)}};Fq.defaultYaml={explicit:!1,version:`1.2`},Fq.defaultTags={"!!":`tag:yaml.org,2002:`};function Iq(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function Lq(e){let t=new Set;return Oq(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function Rq(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function zq(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=Lq(e);let a=Rq(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(bq(t.node)||Sq(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function Bq(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=Bq(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=Bq(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=Bq(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=Bq(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function Vq(e,t,n){if(Array.isArray(e))return e.map((e,t)=>Vq(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!wq(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var Hq=class{constructor(e){Object.defineProperty(this,hq,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!_q(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=Vq(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?Bq(i,{"":o},``,o):o}},Uq=class extends Hq{constructor(e){super(lq),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],Oq(e,{Node:(e,t)=>{(gq(t)||wq(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(Vq(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Wq(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(Iq(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function Wq(e,t,n){if(gq(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(Sq(t)){let r=0;for(let i of t.items){let t=Wq(e,i,n);t>r&&(r=t)}return r}if(yq(t)){let r=Wq(e,t.key,n),i=Wq(e,t.value,n);return Math.max(r,i)}return 1}var Gq=e=>!e||typeof e!=`function`&&typeof e!=`object`,Kq=class extends Hq{constructor(e){super(pq),this.value=e}toJSON(e,t){return t?.keep?this.value:Vq(this.value,e,t)}toString(){return String(this.value)}};Kq.BLOCK_FOLDED=`BLOCK_FOLDED`,Kq.BLOCK_LITERAL=`BLOCK_LITERAL`,Kq.PLAIN=`PLAIN`,Kq.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Kq.QUOTE_SINGLE=`QUOTE_SINGLE`;var qq=`tag:yaml.org,2002:`;function Jq(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function Yq(e,t,n){if(_q(e)&&(e=e.contents),Cq(e))return e;if(yq(e)){let t=n.schema[dq].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new Uq(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=qq+t.slice(2));let l=Jq(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new Kq(e);return c&&(c.node=t),t Line truncated
`)?eJ(n,t):n.includes(`
`)?`
`+Gq(n,t):(e.endsWith(` `)?``:` `)+n,qq=`flow`,Jq=`block`,Yq=`quoted`;function Xq(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=Zq(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
`)n===`block`&&(h=Zq(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
`+eJ(n,t):(e.endsWith(` `)?``:` `)+n,nJ=`flow`,rJ=`block`,iJ=`quoted`;function aJ(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=oJ(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
`)n===`block`&&(h=oJ(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
`&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function Zq(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
`);r=t,i=t+1,a=e[i]}return r}var Qq=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),$q=e=>/^(%|---|\.\.\.)/m.test(e);function eJ(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function tJ(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||($q(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function oJ(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
`);r=t,i=t+1,a=e[i]}return r}var sJ=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),cJ=e=>/^(%|---|\.\.\.)/m.test(e);function lJ(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function uJ(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(cJ(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
`;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:Xq(o,a,Yq,Qq(t,!1))}function nJ(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
`)||/[ \t]\n|\n[ \t]/.test(e))return tJ(e,t);let n=t.indent||($q(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:Xq(r,n,qq,Qq(t,!1))}function rJ(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=tJ;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?nJ:i&&!t?tJ:n?nJ:tJ}return r(e,t)}var iJ;try{iJ=RegExp(`(^|(?<!
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:aJ(o,a,iJ,sJ(t,!1))}function dJ(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
`)||/[ \t]\n|\n[ \t]/.test(e))return uJ(e,t);let n=t.indent||(cJ(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:aJ(r,n,nJ,sJ(t,!1))}function fJ(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=uJ;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?dJ:i&&!t?uJ:n?dJ:uJ}return r(e,t)}var pJ;try{pJ=RegExp(`(^|(?<!
))
+(?!
|$)`,`g`)}catch{iJ=/\n+(?!\n|$)/g}function aJ({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return rJ(n,r);let l=r.indent||(r.forceBlockIndent||$q(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===Lq.BLOCK_FOLDED?!1:t===Lq.BLOCK_LITERAL||!eJ(n,c,l.length);if(!n)return u?`|
|$)`,`g`)}catch{pJ=/\n+(?!\n|$)/g}function mJ({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return fJ(n,r);let l=r.indent||(r.forceBlockIndent||cJ(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===Kq.BLOCK_FOLDED?!1:t===Kq.BLOCK_LITERAL||!lJ(n,c,l.length);if(!n)return u?`|
`:`>
`;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
`&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
`);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
`&&(p=p.slice(0,-1)),p.replace(iJ,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
`&&(p=p.slice(0,-1)),p.replace(pJ,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
`)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=Qq(r,!0);o!==`folded`&&t!==Lq.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=Xq(`${v}${e}${p}`,l,Jq,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function oJ(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
`)||u&&/[[\]{},]/.test(a))return rJ(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
`)?rJ(a,t):aJ(e,t,n,r);if(!s&&!u&&i!==Lq.PLAIN&&a.includes(`
`))return aJ(e,t,n,r);if($q(a)){if(c===``)return t.forceBlockIndent=!0,aJ(e,t,n,r);if(s&&c===l)return rJ(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return rJ(a,t)}return s?d:Xq(d,c,qq,Qq(t,!1))}function sJ(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==Lq.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Lq.QUOTE_DOUBLE);let c=e=>{switch(e){case Lq.BLOCK_FOLDED:case Lq.BLOCK_LITERAL:return i||a?rJ(o.value,t):aJ(o,t,n,r);case Lq.QUOTE_DOUBLE:return tJ(o.value,t);case Lq.QUOTE_SINGLE:return nJ(o.value,t);case Lq.PLAIN:return oJ(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function cJ(e,t){let n=Object.assign({blockQuote:!0,commentString:Wq,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function lJ(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(dq(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function uJ(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(dq(e)||pq(e))&&e.anchor;a&&Dq(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function dJ(e,t,n,r){if(uq(e))return e.toString(t,n,r);if(sq(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=mq(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=lJ(t.doc.schema.tags,a);let o=uJ(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):dq(a)?sJ(a,t,n,r):a.toString(t,n,r);return o?dq(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function fJ({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=mq(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(pq(e)||!mq(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||pq(e)||(dq(e)?e.type===Lq.BLOCK_FOLDED||e.type===Lq.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=dJ(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=Kq(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=Kq(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=Kq(g,n.indent,l(f))));let _,v,y;mq(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&dq(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&fq(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=dJ(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
`:``,v){let e=l(v);S+=`\n${Gq(e,n.indent)}`}x===``&&!n.inFlow?S===`
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=sJ(r,!0);o!==`folded`&&t!==Kq.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=aJ(`${v}${e}${p}`,l,rJ,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function hJ(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
`)||u&&/[[\]{},]/.test(a))return fJ(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
`)?fJ(a,t):mJ(e,t,n,r);if(!s&&!u&&i!==Kq.PLAIN&&a.includes(`
`))return mJ(e,t,n,r);if(cJ(a)){if(c===``)return t.forceBlockIndent=!0,mJ(e,t,n,r);if(s&&c===l)return fJ(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return fJ(a,t)}return s?d:aJ(d,c,nJ,sJ(t,!1))}function gJ(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==Kq.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Kq.QUOTE_DOUBLE);let c=e=>{switch(e){case Kq.BLOCK_FOLDED:case Kq.BLOCK_LITERAL:return i||a?fJ(o.value,t):mJ(o,t,n,r);case Kq.QUOTE_DOUBLE:return uJ(o.value,t);case Kq.QUOTE_SINGLE:return dJ(o.value,t);case Kq.PLAIN:return hJ(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function _J(e,t){let n=Object.assign({blockQuote:!0,commentString:$q,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function vJ(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(bq(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function yJ(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(bq(e)||Sq(e))&&e.anchor;a&&Iq(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function bJ(e,t,n,r){if(yq(e))return e.toString(t,n,r);if(gq(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=Cq(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=vJ(t.doc.schema.tags,a);let o=yJ(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):bq(a)?gJ(a,t,n,r):a.toString(t,n,r);return o?bq(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function xJ({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=Cq(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(Sq(e)||!Cq(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||Sq(e)||(bq(e)?e.type===Kq.BLOCK_FOLDED||e.type===Kq.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=bJ(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=tJ(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=tJ(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=tJ(g,n.indent,l(f))));let _,v,y;Cq(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&bq(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&xq(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=bJ(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
`:``,v){let e=l(v);S+=`\n${eJ(e,n.indent)}`}x===``&&!n.inFlow?S===`
`&&y&&(S=`
`):S+=`\n${n.indent}`}else if(!p&&pq(t)){let e=x[0],r=x.indexOf(`
`):S+=`\n${n.indent}`}else if(!p&&Sq(t)){let e=x[0],r=x.indexOf(`
`),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(S=`\n${n.indent}`)}}else(x===``||x[0]===`
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=Kq(g,n.indent,l(y)):h&&i&&i(),g}function pJ(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var mJ=`<<`,hJ={identify:e=>e===mJ||typeof e==`symbol`&&e.description===mJ,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new Lq(Symbol(mJ)),{addToJSMap:_J}),stringify:()=>mJ},gJ=(e,t)=>(hJ.identify(t)||dq(t)&&(!t.type||t.type===Lq.PLAIN)&&hJ.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===hJ.tag&&e.default);function _J(e,t,n){let r=yJ(e,n);if(fq(r))for(let n of r.items)vJ(e,t,n);else if(Array.isArray(r))for(let n of r)vJ(e,t,n);else vJ(e,t,r)}function vJ(e,t,n){let r=yJ(e,n);if(!lq(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function yJ(e,t){return e&&sq(t)?t.resolve(e.doc,e):t}function bJ(e,t,{key:n,value:r}){if(mq(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(gJ(e,n))_J(e,t,r);else{let i=Mq(n,``,e);if(t instanceof Map)t.set(i,Mq(r,i,e));else if(t instanceof Set)t.add(i);else{let a=xJ(n,i,e),o=Mq(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function xJ(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(mq(e)&&n?.doc){let t=cJ(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),pJ(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function SJ(e,t,n){return new CJ(Bq(e,void 0,n),Bq(t,void 0,n))}var CJ=class e{constructor(e,t=null){Object.defineProperty(this,oq,{value:rq}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return mq(n)&&(n=n.clone(t)),mq(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return bJ(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?fJ(this,e,t,n):JSON.stringify(this)}};function wJ(e,t,n){return(t.inFlow??e.flow?EJ:TJ)(e,t,n)}function TJ({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(mq(i))!d&&i.spaceBefore&&f.push(``),DJ(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(uq(i)){let e=mq(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),DJ(n,f,e.commentBefore,d))}d=!1;let s=dJ(i,u,()=>o=null,()=>d=!0);o&&(s+=Kq(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=tJ(g,n.indent,l(y)):h&&i&&i(),g}function SJ(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var CJ=`<<`,wJ={identify:e=>e===CJ||typeof e==`symbol`&&e.description===CJ,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new Kq(Symbol(CJ)),{addToJSMap:EJ}),stringify:()=>CJ},TJ=(e,t)=>(wJ.identify(t)||bq(t)&&(!t.type||t.type===Kq.PLAIN)&&wJ.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===wJ.tag&&e.default);function EJ(e,t,n){let r=OJ(e,n);if(xq(r))for(let n of r.items)DJ(e,t,n);else if(Array.isArray(r))for(let n of r)DJ(e,t,n);else DJ(e,t,r)}function DJ(e,t,n){let r=OJ(e,n);if(!vq(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function OJ(e,t){return e&&gq(t)?t.resolve(e.doc,e):t}function kJ(e,t,{key:n,value:r}){if(Cq(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(TJ(e,n))EJ(e,t,r);else{let i=Vq(n,``,e);if(t instanceof Map)t.set(i,Vq(r,i,e));else if(t instanceof Set)t.add(i);else{let a=AJ(n,i,e),o=Vq(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function AJ(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(Cq(e)&&n?.doc){let t=_J(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),SJ(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function jJ(e,t,n){return new MJ(Yq(e,void 0,n),Yq(t,void 0,n))}var MJ=class e{constructor(e,t=null){Object.defineProperty(this,hq,{value:fq}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return Cq(n)&&(n=n.clone(t)),Cq(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return kJ(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?xJ(this,e,t,n):JSON.stringify(this)}};function NJ(e,t,n){return(t.inFlow??e.flow?FJ:PJ)(e,t,n)}function PJ({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(Cq(i))!d&&i.spaceBefore&&f.push(``),IJ(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(yq(i)){let e=Cq(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),IJ(n,f,e.commentBefore,d))}d=!1;let s=bJ(i,u,()=>o=null,()=>d=!0);o&&(s+=tJ(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
`}}return e?(p+=`
`+Gq(l(e),c),s&&s()):d&&o&&o(),p}function EJ({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(mq(i))i.spaceBefore&&d.push(``),DJ(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(uq(i)){let e=mq(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),DJ(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=mq(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=dJ(i,c,()=>a=null);l||=d.length>u||o.includes(`
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=Kq(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function DJ({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=Gq(t(r),e);n.push(i.trimStart())}}function OJ(e,t){let n=dq(t)?t.value:t;for(let r of e)if(uq(r)&&(r.key===t||r.key===n||dq(r.key)&&r.key.value===n))return r}var kJ=class extends Uq{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(nq,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(SJ(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=uq(e)?e:!e||typeof e!=`object`||!(`key`in e)?new CJ(e,e?.value):new CJ(e.key,e.value);let r=OJ(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);dq(r.value)&&Iq(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=OJ(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=OJ(this.items,e)?.value;return(!t&&dq(n)?n.value:n)??void 0}has(e){return!!OJ(this.items,e)}set(e,t){this.add(new CJ(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)bJ(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!uq(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),wJ(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},AJ={collection:`map`,default:!0,nodeClass:kJ,tag:`tag:yaml.org,2002:map`,resolve(e,t){return lq(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>kJ.from(e,t,n)},jJ=class extends Uq{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(aq,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=MJ(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=MJ(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&dq(r)?r.value:r}has(e){let t=MJ(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=MJ(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];dq(r)&&Iq(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(Mq(e,String(r++),t));return n}toString(e,t,n){return e?wJ(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(Bq(a,void 0,n))}}return i}};function MJ(e){let t=dq(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var NJ={collection:`seq`,default:!0,nodeClass:jJ,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return fq(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>jJ.from(e,t,n)},PJ={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),sJ(e,t,n,r)}},FJ={identify:e=>e==null,createNode:()=>new Lq(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Lq(null),stringify:({source:e},t)=>typeof e==`string`&&FJ.test.test(e)?e:t.options.nullStr},IJ={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Lq(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&IJ.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function LJ({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var RJ={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:LJ},zJ={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),string Line truncated
`:` `)}return sJ({comment:e,type:t,value:s},r,i,a)}};function $J(e,t){if(fq(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!uq(r)){if(lq(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new CJ(new Lq(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=uq(r)?r:new CJ(r)}}else t(`Expected a sequence for this tag`);return e}function eY(e,t,n){let{replacer:r}=n,i=new jJ(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(SJ(o,s,n))}return i}var tY={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:$J,createNode:eY},nY=class e extends jJ{constructor(){super(),this.add=kJ.prototype.add.bind(this),this.delete=kJ.prototype.delete.bind(this),this.get=kJ.prototype.get.bind(this),this.has=kJ.prototype.has.bind(this),this.set=kJ.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(uq(e)?(r=Mq(e.key,``,t),i=Mq(e.value,r,t)):r=Mq(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=eY(e,t,n),i=new this;return i.items=r.items,i}};nY.tag=`tag:yaml.org,2002:omap`;var rY={collection:`seq`,identify:e=>e instanceof Map,nodeClass:nY,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=$J(e,t),r=[];for(let{key:e}of n.items)dq(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new nY,n)},createNode:(e,t,n)=>nY.from(e,t,n)};function iY({value:e,source:t},n){return t&&(e?aY:oY).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var aY={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Lq(!0),stringify:iY},oY={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Lq(!1),stringify:iY},sY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:LJ},cY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():LJ(e)}},lY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Lq(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:LJ},uY=e=>typeof e==`bigint`||Number.isInteger(e);function dY(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function fY(e,t,n){let{value:r}=e;if(uY(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return LJ(e)}var pY={identify:uY,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>dY(e,2,2,n),stringify:e=>fY(e,2,`0b`)},mY={identify:uY,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>dY(e,1,8,n),stringify:e=>fY(e,8,`0`)},hY={identify:uY,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>dY(e,0,10,n),stringify:LJ},gY={identify:uY,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>dY(e,2,16,n),stringify:e=>fY(e,16,`0x`)},_Y=class e extends kJ{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=uq(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new CJ(e.key,null):new CJ(e,null),OJ(this.items,t.key)||this.items.push(t)}get(e,t){let n=OJ(this.items,e);return!t&&uq(n)?dq(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=OJ(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new CJ(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return s Line truncated
`)?(n.push(`...`),n.push(Gq(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(Gq(a(t),``)))}return n.join(`
`+eJ(l(e),c),s&&s()):d&&o&&o(),p}function FJ({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(Cq(i))i.spaceBefore&&d.push(``),IJ(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(yq(i)){let e=Cq(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),IJ(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=Cq(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=bJ(i,c,()=>a=null);l||=d.length>u||o.includes(`
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=tJ(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function IJ({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=eJ(t(r),e);n.push(i.trimStart())}}function LJ(e,t){let n=bq(t)?t.value:t;for(let r of e)if(yq(r)&&(r.key===t||r.key===n||bq(r.key)&&r.key.value===n))return r}var RJ=class extends Qq{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(dq,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(jJ(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=yq(e)?e:!e||typeof e!=`object`||!(`key`in e)?new MJ(e,e?.value):new MJ(e.key,e.value);let r=LJ(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);bq(r.value)&&Gq(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=LJ(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=LJ(this.items,e)?.value;return(!t&&bq(n)?n.value:n)??void 0}has(e){return!!LJ(this.items,e)}set(e,t){this.add(new MJ(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)kJ(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!yq(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),NJ(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},zJ={collection:`map`,default:!0,nodeClass:RJ,tag:`tag:yaml.org,2002:map`,resolve(e,t){return vq(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>RJ.from(e,t,n)},BJ=class extends Qq{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(mq,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=VJ(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=VJ(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&bq(r)?r.value:r}has(e){let t=VJ(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=VJ(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];bq(r)&&Gq(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(Vq(e,String(r++),t));return n}toString(e,t,n){return e?NJ(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(Yq(a,void 0,n))}}return i}};function VJ(e){let t=bq(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var HJ={collection:`seq`,default:!0,nodeClass:BJ,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return xq(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>BJ.from(e,t,n)},UJ={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),gJ(e,t,n,r)}},WJ={identify:e=>e==null,createNode:()=>new Kq(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Kq(null),stringify:({source:e},t)=>typeof e==`string`&&WJ.test.test(e)?e:t.options.nullStr},GJ={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Kq(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&GJ.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function KJ({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var qJ={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:KJ},JJ={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),string Line truncated
`:` `)}return gJ({comment:e,type:t,value:s},r,i,a)}};function cY(e,t){if(xq(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!yq(r)){if(vq(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new MJ(new Kq(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=yq(r)?r:new MJ(r)}}else t(`Expected a sequence for this tag`);return e}function lY(e,t,n){let{replacer:r}=n,i=new BJ(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(jJ(o,s,n))}return i}var uY={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:cY,createNode:lY},dY=class e extends BJ{constructor(){super(),this.add=RJ.prototype.add.bind(this),this.delete=RJ.prototype.delete.bind(this),this.get=RJ.prototype.get.bind(this),this.has=RJ.prototype.has.bind(this),this.set=RJ.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(yq(e)?(r=Vq(e.key,``,t),i=Vq(e.value,r,t)):r=Vq(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=lY(e,t,n),i=new this;return i.items=r.items,i}};dY.tag=`tag:yaml.org,2002:omap`;var fY={collection:`seq`,identify:e=>e instanceof Map,nodeClass:dY,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=cY(e,t),r=[];for(let{key:e}of n.items)bq(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new dY,n)},createNode:(e,t,n)=>dY.from(e,t,n)};function pY({value:e,source:t},n){return t&&(e?mY:hY).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var mY={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Kq(!0),stringify:pY},hY={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Kq(!1),stringify:pY},gY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:KJ},_Y={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():KJ(e)}},vY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Kq(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:KJ},yY=e=>typeof e==`bigint`||Number.isInteger(e);function bY(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function xY(e,t,n){let{value:r}=e;if(yY(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return KJ(e)}var SY={identify:yY,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>bY(e,2,2,n),stringify:e=>xY(e,2,`0b`)},CY={identify:yY,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>bY(e,1,8,n),stringify:e=>xY(e,8,`0`)},wY={identify:yY,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>bY(e,0,10,n),stringify:KJ},TY={identify:yY,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>bY(e,2,16,n),stringify:e=>xY(e,16,`0x`)},EY=class e extends RJ{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=yq(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new MJ(e.key,null):new MJ(e,null),LJ(this.items,t.key)||this.items.push(t)}get(e,t){let n=LJ(this.items,e);return!t&&yq(n)?bq(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=LJ(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new MJ(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return s Line truncated
`)?(n.push(`...`),n.push(eJ(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(eJ(a(t),``)))}return n.join(`
`)+`
`}var MY=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,oq,{value:tq});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new Eq({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[oq]:{value:tq}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=mq(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){NY(this.contents)&&this.contents.add(e)}addIn(e,t){NY(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=Oq(this);e.anchor=!t||n.has(t)?kq(t||`a`,n):t}return new Pq(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=Aq(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=Bq(e,l,p);return o&&pq(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new CJ(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return NY(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Hq(e)?this.contents!=null&&(this.contents=null,!0):NY(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return pq(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Hq(e)?!t&&dq(this.contents)?this.contents.value:this.contents:pq(this.contents)?this.contents.getIn(e,t):void 0}has(e){return pq(this.contents)?this.contents.has(e):!1}hasIn(e){return Hq(e)?this.contents!==void 0:pq(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Vq(this.schema,[e],t):NY(this.contents)&&this.contents.set(e,t)}setIn(e,t){Hq(e)?this.contents=t:this.contents==null?this.contents=Vq(this.schema,Array.from(e),t):NY(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new Eq({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new Eq({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new AY(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=Mq(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?jq(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return jY(this,e)}};function NY(e){if(pq(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var PY=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},FY=class extends PY{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},IY=class extends PY{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},LY=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function RY(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function zY(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(zY(t.key)||zY(t.value))return!0}return!1;default:return!0}}function BY(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&zY(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function VY(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||dq(e)&&dq(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var HY=`All mapping items must start at the same column`;function UY({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??kJ)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=RY(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,HY)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||zY(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,HY);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&BY(r.indent,u,i),n.atKey=!1,VY(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=RY(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&BY(r.indent,f,i),s=c.range[2];let l=new CJ(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let e=new CJ(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function WY({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??jJ)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=RY(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l?.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&BY(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function GY(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var KY=`Block collections are not allowed within flow collections`,qY=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function JY({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?kJ:jJ))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=RY(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&zY(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];uq(t)&&(t=t.value??t.key),t.comment?t.comment+=`
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],qY(m)&&i(r.range,`BLOCK_IN_FLOW`,KY)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);qY(f)&&i(g.range,`BLOCK_IN_FLOW`,KY),n.atKey=!1;let _=RY(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source?.[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?qY(m)&&i(v.range,`BLOCK_IN_FLOW`,KY):_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let y=new CJ(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;VY(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new kJ(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f?.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=GY(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function YY(e,t,n,r,i,a){let o=n.type===`block-map`?UY(e,t,n,r,a):n.type===`block-seq`?WY(e,t,n,r,a):JY(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function XY(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===kJ.tagName&&s===`map`||o===jJ.tagName&&s===`seq`)return YY(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r?.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),YY(e,t,n,i,o)}let l=YY(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=mq(u)?u:new Lq(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function ZY(e,t,n){let r=t.offset,i=QY(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?Lq.BLOCK_FOLDED:Lq.BLOCK_LITERAL,o=t.source?$Y(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
`}var VY=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,hq,{value:uq});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new Fq({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[hq]:{value:uq}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=Cq(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){HY(this.contents)&&this.contents.add(e)}addIn(e,t){HY(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=Lq(this);e.anchor=!t||n.has(t)?Rq(t||`a`,n):t}return new Uq(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=zq(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=Yq(e,l,p);return o&&Sq(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new MJ(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return HY(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Zq(e)?this.contents!=null&&(this.contents=null,!0):HY(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Sq(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Zq(e)?!t&&bq(this.contents)?this.contents.value:this.contents:Sq(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Sq(this.contents)?this.contents.has(e):!1}hasIn(e){return Zq(e)?this.contents!==void 0:Sq(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Xq(this.schema,[e],t):HY(this.contents)&&this.contents.set(e,t)}setIn(e,t){Zq(e)?this.contents=t:this.contents==null?this.contents=Xq(this.schema,Array.from(e),t):HY(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new Fq({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new Fq({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new zY(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=Vq(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?Bq(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return BY(this,e)}};function HY(e){if(Sq(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var UY=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},WY=class extends UY{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},GY=class extends UY{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},KY=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function qY(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function JY(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(JY(t.key)||JY(t.value))return!0}return!1;default:return!0}}function YY(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&JY(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function XY(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||bq(e)&&bq(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var ZY=`All mapping items must start at the same column`;function QY({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??RJ)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=qY(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,ZY)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||JY(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,ZY);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&YY(r.indent,u,i),n.atKey=!1,XY(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=qY(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&YY(r.indent,f,i),s=c.range[2];let l=new MJ(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let e=new MJ(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function $Y({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??BJ)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=qY(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l?.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&YY(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function eX(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var tX=`Block collections are not allowed within flow collections`,nX=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function rX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?RJ:BJ))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=qY(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&JY(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];yq(t)&&(t=t.value??t.key),t.comment?t.comment+=`
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],nX(m)&&i(r.range,`BLOCK_IN_FLOW`,tX)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);nX(f)&&i(g.range,`BLOCK_IN_FLOW`,tX),n.atKey=!1;let _=qY(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source?.[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?nX(m)&&i(v.range,`BLOCK_IN_FLOW`,tX):_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let y=new MJ(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;XY(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new RJ(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f?.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=eX(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function iX(e,t,n,r,i,a){let o=n.type===`block-map`?QY(e,t,n,r,a):n.type===`block-seq`?$Y(e,t,n,r,a):rX(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function aX(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===RJ.tagName&&s===`map`||o===BJ.tagName&&s===`seq`)return iX(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r?.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),iX(e,t,n,i,o)}let l=iX(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=Cq(u)?u:new Kq(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function oX(e,t,n){let r=t.offset,i=sX(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?Kq.BLOCK_FOLDED:Kq.BLOCK_LITERAL,o=t.source?cX(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
`.repeat(Math.max(1,o.length-1)):``,n=r+i.length;return t.source&&(n+=t.source.length),{value:e,type:a,comment:i.comment,range:[r,n,n]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let t=0;t<s;++t){let[r,a]=o[t];if(a===``||a===`\r`)i.indent===0&&r.length>c&&(c=r.length);else{r.length<c&&n(l+r.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),i.indent===0&&(c=r.length),u=t,c===0&&!e.atRoot&&n(l,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}l+=r.length+a.length+1}for(let e=o.length-1;e>=s;--e)o[e][0].length>c&&(s=e+1);let d=``,f=``,p=!1;for(let e=0;e<u;++e)d+=o[e][0].slice(c)+`
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===Lq.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===Kq.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
`):t.length>c||r[0]===` `?(f===` `?f=`
`:!p&&f===`
`&&(f=`
@@ -81,47 +81,47 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
`+o[e][0].slice(c);d[d.length-1]!==`
`&&(d+=`
`);break;default:d+=`
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function QY({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function $Y(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function eX(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=Lq.PLAIN,c=tX(a,l);break;case`single-quoted-scalar`:s=Lq.QUOTE_SINGLE,c=nX(a,l);break;case`double-quoted-scalar`:s=Lq.QUOTE_DOUBLE,c=iX(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=GY(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function tX(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),rX(e)}function nX(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),rX(e.slice(1,-1)).replace(/''/g,`'`)}function rX(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function sX({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function cX(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function lX(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=Kq.PLAIN,c=uX(a,l);break;case`single-quoted-scalar`:s=Kq.QUOTE_SINGLE,c=dX(a,l);break;case`double-quoted-scalar`:s=Kq.QUOTE_DOUBLE,c=pX(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=eX(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function uX(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),fX(e)}function dX(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),fX(e.slice(1,-1)).replace(/''/g,`'`)}function fX(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
`?a+=o:o=`
`:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function iX(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
`:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function pX(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
`){if(i===`
`){let{fold:t,offset:i}=aX(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=oX[i];if(a)n+=a;else if(i===`
`){let{fold:t,offset:i}=mX(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=hX[i];if(a)n+=a;else if(i===`
`)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=sX(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=gX(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
`&&(a!==`\r`||e[r+2]!==`
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function aX(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function mX(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
`||r===`\r`)&&(r!==`\r`||e[t+2]===`
`);)r===`
`&&(n+=`
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var oX={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
`,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function sX(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}function cX(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?ZY(e,t,r):eX(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[iq]:c?lX(e.schema,i,c,n,r):t.type===`scalar`?uX(e,i,t,r):e.schema[iq];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=dq(a)?a:new Lq(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new Lq(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function lX(e,t,n,r,i){if(n===`!`)return e[iq];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[iq])}function uX({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[iq];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[iq];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function dX(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var fX={composeNode:pX,composeEmptyNode:mX};function pX(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=hX(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=cX(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=XY(fX,e,t,n,r),s&&(l.anchor=s.source.substring(1))}catch(e){r(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),u=!1}return l??=mX(e,t.offset,void 0,null,n,r),s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!dq(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function mX(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=cX(e,{type:`scalar`,offset:dX(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function hX({options:e},{offset:t,source:n,end:r},i){let a=new Pq(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=GY(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function gX(e,t,{offset:n,start:r,value:i,end:a},o){let s=new MY(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=RY(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?pX(c,i,l,o):mX(c,l.end,r,null,l,o);let u=s.contents.range[2],d=GY(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function _X(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function vX(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var hX={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
`,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function gX(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}function _X(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?oX(e,t,r):lX(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[pq]:c?vX(e.schema,i,c,n,r):t.type===`scalar`?yX(e,i,t,r):e.schema[pq];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=bq(a)?a:new Kq(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new Kq(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function vX(e,t,n,r,i){if(n===`!`)return e[pq];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[pq])}function yX({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[pq];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[pq];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function bX(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var xX={composeNode:SX,composeEmptyNode:CX};function SX(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=wX(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=_X(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=aX(xX,e,t,n,r),s&&(l.anchor=s.source.substring(1))}catch(e){r(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),u=!1}return l??=CX(e,t.offset,void 0,null,n,r),s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!bq(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function CX(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=_X(e,{type:`scalar`,offset:bX(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function wX({options:e},{offset:t,source:n,end:r},i){let a=new Uq(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=eX(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function TX(e,t,{offset:n,start:r,value:i,end:a},o){let s=new VY(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=qY(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?SX(c,i,l,o):CX(c,l.end,r,null,l,o);let u=s.contents.range[2],d=eX(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function EX(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function DX(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
`:`
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var yX=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=_X(e);r?this.warnings.push(new IY(i,t,n)):this.errors.push(new FY(i,t,n))},this.directives=new Eq({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=vX(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(pq(i)&&!i.flow&&i.items.length>0){let e=i.items[0];uq(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:vX(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=_X(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=gX(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new FY(_X(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new FY(_X(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=GY(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new FY(_X(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new MY(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},bX=Symbol(`break visit`),xX=Symbol(`skip children`),SX=Symbol(`remove item`);function CX(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),wX(Object.freeze([]),e,t)}CX.BREAK=bX,CX.SKIP=xX,CX.REMOVE=SX,CX.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},CX.parentCollection=(e,t)=>{let n=CX.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function wX(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=wX(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===bX)return bX;else r===SX&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function TX(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var OX=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=EX(e);r?this.warnings.push(new GY(i,t,n)):this.errors.push(new WY(i,t,n))},this.directives=new Fq({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=DX(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(Sq(i)&&!i.flow&&i.items.length>0){let e=i.items[0];yq(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:DX(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=EX(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=TX(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new WY(EX(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new WY(EX(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=eX(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new WY(EX(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new VY(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},kX=Symbol(`break visit`),AX=Symbol(`skip children`),jX=Symbol(`remove item`);function MX(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),NX(Object.freeze([]),e,t)}MX.BREAK=kX,MX.SKIP=AX,MX.REMOVE=jX,MX.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},MX.parentCollection=(e,t)=>{let n=MX.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function NX(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=NX(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===kX)return kX;else r===jX&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function PX(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
`:case`\r
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function EX(e){switch(e){case void 0:case` `:case`
`:case`\r`:case` `:return!0;default:return!1}}var DX=new Set(`0123456789ABCDEFabcdef`),OX=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),kX=new Set(`,[]{}`),AX=new Set(` ,[]{}
\r `),jX=e=>!e||AX.has(e),MX=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function FX(e){switch(e){case void 0:case` `:case`
`:case`\r`:case` `:return!0;default:return!1}}var IX=new Set(`0123456789ABCDEFabcdef`),LX=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),RX=new Set(`,[]{}`),zX=new Set(` ,[]{}
\r `),BX=e=>!e||zX.has(e),VX=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
`||t===`\r`&&this.buffer[e+1]===`
`}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
`||!t&&!this.atEnd)return e+n+1}return t===`
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&EX(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&EX(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!EX(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&EX(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(jX),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&EX(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(jX),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||EX(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&FX(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&FX(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!FX(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&FX(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(BX),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&FX(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(BX),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||FX(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
`,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>EX(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>FX(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
`:e=r,t=0;break;case`\r`:{let e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
`)break}default:break loop}if(!n&&!this.atEnd)return this.setNext(`block-scalar`);if(t>=this.indentNext){this.indentNext=this.blockScalarIndent===-1?t:this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
`,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===` `;)n=this.buffer[++r];if(n===` `){for(;n===` `||n===` `||n===`\r`||n===`
`;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let n=e-1,r=this.buffer[n];r===`\r`&&(r=this.buffer[--n]);let i=n;for(;r===` `;)r=this.buffer[--n];if(r===`
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(1);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(EX(r)||e&&kX.has(r))break;t=n}else if(EX(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(1);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(FX(r)||e&&RX.has(r))break;t=n}else if(FX(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
`?(n+=1,r=`
`,i=this.buffer[n+1]):t=n),i===`#`||e&&kX.has(i))break;if(r===`
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&kX.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(jX),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(EX(n)||t&&kX.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!EX(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(OX.has(t))t=this.buffer[++e];else if(t===`%`&&DX.has(this.buffer[e+1])&&DX.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
`,i=this.buffer[n+1]):t=n),i===`#`||e&&RX.has(i))break;if(r===`
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&RX.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(BX),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(FX(n)||t&&RX.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!FX(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(LX.has(t))t=this.buffer[++e];else if(t===`%`&&IX.has(this.buffer[e+1])&&IX.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},NX=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function PX(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function FX(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function IX(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function LX(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function RX(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function zX(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function BX(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!PX(t.start,`explicit-key-ind`)&&!PX(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,IX(t.value)?t.value.end?zX(t.value.end,t.sep):t.value.end=t.sep:zX(t.start,t.sep),delete t.sep)}var VX=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new MX,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=TX(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&BX(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&FX(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.i Line truncated
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},HX=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function UX(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function WX(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function GX(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function KX(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function qX(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function JX(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function YX(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!UX(t.start,`explicit-key-ind`)&&!UX(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,GX(t.value)?t.value.end?JX(t.value.end,t.sep):t.value.end=t.sep:JX(t.start,t.sep),delete t.sep)}var XX=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new VX,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=PX(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&YX(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&WX(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.i Line truncated
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){zX(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(PX(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=RX(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(PX(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(IX(t.key)&&!PX(t.sep,`newline`)){let e=RX(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):PX(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!PX(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){zX(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||PX(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.ite Line truncated
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){JX(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(UX(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=qX(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(UX(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(GX(t.key)&&!UX(t.sep,`newline`)){let e=qX(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):UX(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!UX(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){JX(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||UX(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.ite Line truncated
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=RX(LX(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=RX(LX(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function HX(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new NX||null,prettyErrors:t}}function UX(e,t={}){let{lineCounter:n,prettyErrors:r}=HX(t),i=new VX(n?.addNewLine),a=new yX(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new FY(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(LY(e,n)),o.warnings.forEach(LY(e,n))),o}function WX(e){return e.ok?`Valid`:e.line?`Line ${e.line}: ${e.message}`:e.message}function GX(e){let t=UX(e),n=t.errors[0];if(n)return{ok:!1,message:eZ(n.message),line:n.linePos?.[0]?.line};let r=t.toJS();if(!tZ(r))return{ok:!1,message:`A workflow is a mapping with an id and steps.`};let i=typeof r.id==`string`?r.id.trim():``;if(!i)return{ok:!1,message:`workflow id is required`};let a=r.steps;if(a==null||a===``)return{ok:!1,message:`workflow ${i} has no steps`};if(!Array.isArray(a))return{ok:!1,message:`workflow ${i}: steps must be a list`};if(!a.length)return{ok:!1,message:`workflow ${i} has no steps`};let o=[];for(let[e,t]of a.entries()){if(!tZ(t)||!nZ(t.type))return{ok:!1,message:`workflow ${i} step ${e+1} needs a type`};o.push({index:e+1,type:t.type.trim()})}return{ok:!0,id:i,steps:o}}function KX(e){switch(e){case`key`:return`text-fg-muted`;case`string`:return`text-ok`;case`comment`:case`punct`:return`text-fg-subtle`;default:return`text-foreground`}}function qX(e){return e.split(`
`).map((e,t)=>({number:t+1,text:e,tokens:XX(e)}))}var JX=/^(\s*)(-\s+)?/,YX=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function XX(e){let{code:t,comment:n}=ZX(e),r=QX(t);return n&&r.push({text:n,kind:`comment`}),r}function ZX(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(t){r===t&&(t=``);continue}if(r===`"`||r===`'`){t=r;continue}if(r===`#`&&(n===0||/\s/.test(e[n-1]??``)))return{code:e.slice(0,n),comment:e.slice(n)}}return{code:e,comment:``}}function QX(e){if(!e)return[];let t=[],n=JX.exec(e);n?.[1]&&t.push({text:n[1],kind:`plain`}),n?.[2]&&t.push({text:n[2],kind:`punct`});let r=e.slice(n?.[0].length??0);if(!r)return t;let i=YX.exec(r);return i?(t.push({text:i[1]??``,kind:`key`}),t.push({text:i[2]??`:`,kind:`punct`}),i[3]&&t.push({text:i[3],kind:`plain`}),[...t,...$X(i[4]??``)]):[...t,...$X(r)]}function $X(e){if(!e)return[];let t=/^("[^"]*"?|'[^']*'?)([\s\S]*)$/.exec(e);if(!t)return[{text:e,kind:`plain`}];let n=[{text:t[1]??``,kind:`string`}];return t[2]&&n.push({text:t[2],kind:`plain`}),n}function eZ(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function tZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function nZ(e){return typeof e==`string`&&e.trim()!==``}var rZ={class:`space-y-1.5`},iZ={class:`space-y-1.5`},aZ={class:`flex h-9 flex-nowrap items-center gap-1.5 overflow-hidden`,role:`list`,"aria-label":`Steps`},oZ=[`title`],sZ={key:1,class:`text-xs text-fg-subtle`},cZ={class:`space-y-1.5`},lZ={class:`flex items-baseline gap-2`},uZ={class:`relative overflow-hidden rounded-lg border border-input font-mono text-[13px] leading-6 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50`},dZ={"aria-hidden":`true`,class:`pointer-events-none absolute inset-y-0 left-0 w-11 select-none overflow-hidden border-r border-border bg-secondary/40 py-3 text-right`},fZ={"aria-hidden":`true`,class:`pointer-events-none absolute inset-0 overflow-hidden py-3 pr-3 pl-14 break-words whitespace-pre-wrap`},pZ={key:0,class:`text-sm text-danger`,role:`alert`},mZ={class:`flex flex-wrap items-center gap-2 border-t border-border pt-4`},hZ={key:0,class:`mr-auto font-mono text-xs text-fg-subtle`},gZ=M({__name:`WorkflowEditor`,props:{selected:{required:!0},selectedModifiers:{}},emits:[`update:selected`],setup(e){let t=ZA(),n=W(()=>t.stateFor(`workflow-definitions`)),r=W(()=>n.value.resource?.value??{definitions:[]}),i=W(()=>t.shippedWorkflows()),a=co(e,`selected`),o=O(``),s=O(``),c=O(``),l=W(()=>i.value.definitions.find(e=>e.id===o.value));function u(e){let t=r.value.definitions.find(t=>t.id===e);o.value=t?.id??e,s.value=t?.yaml??`id: ${e}\nsteps:\n - type: `,c.value=``}j(a,u,{immediate:!0}),j(r,()=>{s.value||u(a.value)});async function d(e){return c.value=``,t.replace(`workflow-definitions`,e)}async function f(){let e=o.value.trim();if(!e){c.value=`Workflow ID is required.`;return}let t=a.value,n=r.value;t&&t!==e&&(n=YA(n,t)),await d(JA(n,{id:e,yaml:s.value}))&&(a.value=e)}async function p(){a.value&&await d(YA(r.value,a.value))&&(a.value=``,o.value=``,s.value=``)}async function m(){l.value&&await d(JA(r.value,KA(l.value)))}let h=W(()=>GX(s.value)),g=W(()=>h.value.ok?h.value.steps:[]),_=W(()=>qX(s.value)),v=O(0);function y(e){v.value=e.target.scrollTop}return(e,t)=>(I(),L(`form`,{class:`space-y-4`,onSubmit:lu(f,[`prevent`])},[z(`div`,rZ,[B(k(gT),{for:`workflow-id`},{default:A(()=>[...t[2]||=[V(`ID`,-1)]]),_:1}),B(k(Q),{id:`workflow-id`,modelValue:o.value,"onUpdate:modelValue":t[0]||=e=>o.value=e,name:`workflow-id`,required:``,autocomplete:`off`,class:`max-w-sm font-mono`},null,8,[`modelValue`])]),z(`div`,iZ,[t[3]||=z(`span`,{class:`text-sm leading-none font-medium`},`Steps`,-1),z(`div`,aZ,[g.value.length?(I(!0),L(F,{key:0},N(g.value,(e,t)=>(I(),L(F,{key:e.index},[z(`span`,{role:`listitem`,class:`shrink-0 rounded border border-border bg-secondary px-2 py-0.5 font-mono text-xs`,title:e.type},D(e.type),9,oZ),t<g.value.length-1?(I(),R(k(yd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":`true`})):H(``,!0)],64))),128)):(I(),L(`span`,sZ,`No steps yet`))])]),z(`div`,cZ,[z(`div`,lZ,[B(k(gT),{for:`workflow-yaml`},{default:A(()=>[...t[4]||=[V(`YAML`,-1)]]),_:1}),z(`span`,{class:E([`ml-auto text-xs`,h.value.ok?`text-ok`:`text-danger`]),role:`status`},D(h.value.ok?`✓`:`✕`)+` `+D(k(WX)(h.value)),3)]),z(`div`,uZ,[z(`div`,dZ,[z(`div`,{style:ve(`transform:translateY(${-v.value}px)`)},[(I(!0),L(F,null,N(_.value,e=>(I(),L(`div`,{key:e.number,class:`min-h-6 pr-2 text-fg-subtle`},D(e.number),1))),128))],4)]),z(`div`,fZ,[z(`div`,{style:ve(`transform:translateY(${-v.value}px)`)},[(I(!0),L(F,null,N(_.value,e=>(I(),L(`div`,{key:e.number,class:`min-h-6`},[(I(!0),L(F,null,N(e.tokens,(e,t)=>(I(),L(`span`,{key:t,class:E(k(KX)(e.kind))},D(e.text),3))),128))]))),128))],4)]),B(k(DT),{id:`workflow-yaml`,modelValue:s.value,"onUpdate:modelValue":t[1]||=e=>s.value=e,name:`workflow-yaml`,required:``,class:`relative min-h-96 resize-y rounded-none border-0 bg-transparent py-3 pr-3 pl-14 text-[13px] leading-6 text-transparent caret-foreground shadow-none md:text-[13px] focus-visible:ring-0`,spellcheck:`false`,onScroll:y},null,8,[`modelValue`])])]),c.value||n.value.error?(I(),L(`p`,pZ,D(c.value||n.value.error),1)):H(``,!0),z(`div`,mZ,[n.value.resource?(I(),L(`span`,hZ,`Version `+D(n.value.resource.version),1)):H(``,!0),a.value?(I(),R(k(Z),{key:1,type:`button`,variant:`ghost`,class:`text-danger`,onClick:p},{default:A(()=>[B(k(rf)),t[5]||=V(` Remove`,-1)]),_:1})):H(``,!0),l.value?(I(),R(k(Z),{key:2,type:`button`,variant:`outline`,onClick:m},{default:A(()=>[B(k(Xd)),t[6]||=V(` Restore this workflow`,-1)]),_:1})):H(``,!0),B(k(Z),{type:`submit`,disabled:n.value.saving||!h.value.ok},{default:A(()=>[n.value.saving?(I(),R(k(yF),{key:0,"data-icon":`inline-start`})):H(``,!0),t[7]||=V(` Validate & save`,-1)]),_:1},8,[`disabled`])])],32))}});function _Z(e,t){let n=new Map((e||[]).map(e=>[e.workflow,e])),r=[],i=new Set;for(let e of t||[])i.add(e.id),r.push({...e,...n.get(e.id)||{workflow:e.id,runs:0,merged:0,completed:0}});for(let t of e||[])i.has(t.workflow)||r Line truncated
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=qX(KX(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=qX(KX(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function ZX(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new HX||null,prettyErrors:t}}function QX(e,t={}){let{lineCounter:n,prettyErrors:r}=ZX(t),i=new XX(n?.addNewLine),a=new OX(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new WY(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(KY(e,n)),o.warnings.forEach(KY(e,n))),o}function $X(e){return e.ok?`Valid`:e.line?`Line ${e.line}: ${e.message}`:e.message}function eZ(e){let t=QX(e),n=t.errors[0];if(n)return{ok:!1,message:lZ(n.message),line:n.linePos?.[0]?.line};let r=t.toJS();if(!uZ(r))return{ok:!1,message:`A workflow is a mapping with an id and steps.`};let i=typeof r.id==`string`?r.id.trim():``;if(!i)return{ok:!1,message:`workflow id is required`};let a=r.steps;if(a==null||a===``)return{ok:!1,message:`workflow ${i} has no steps`};if(!Array.isArray(a))return{ok:!1,message:`workflow ${i}: steps must be a list`};if(!a.length)return{ok:!1,message:`workflow ${i} has no steps`};let o=[];for(let[e,t]of a.entries()){if(!uZ(t)||!dZ(t.type))return{ok:!1,message:`workflow ${i} step ${e+1} needs a type`};o.push({index:e+1,type:t.type.trim()})}return{ok:!0,id:i,steps:o}}function tZ(e){switch(e){case`key`:return`text-fg-muted`;case`string`:return`text-ok`;case`comment`:case`punct`:return`text-fg-subtle`;default:return`text-foreground`}}function nZ(e){return e.split(`
`).map((e,t)=>({number:t+1,text:e,tokens:aZ(e)}))}var rZ=/^(\s*)(-\s+)?/,iZ=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function aZ(e){let{code:t,comment:n}=oZ(e),r=sZ(t);return n&&r.push({text:n,kind:`comment`}),r}function oZ(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(t){r===t&&(t=``);continue}if(r===`"`||r===`'`){t=r;continue}if(r===`#`&&(n===0||/\s/.test(e[n-1]??``)))return{code:e.slice(0,n),comment:e.slice(n)}}return{code:e,comment:``}}function sZ(e){if(!e)return[];let t=[],n=rZ.exec(e);n?.[1]&&t.push({text:n[1],kind:`plain`}),n?.[2]&&t.push({text:n[2],kind:`punct`});let r=e.slice(n?.[0].length??0);if(!r)return t;let i=iZ.exec(r);return i?(t.push({text:i[1]??``,kind:`key`}),t.push({text:i[2]??`:`,kind:`punct`}),i[3]&&t.push({text:i[3],kind:`plain`}),[...t,...cZ(i[4]??``)]):[...t,...cZ(r)]}function cZ(e){if(!e)return[];let t=/^("[^"]*"?|'[^']*'?)([\s\S]*)$/.exec(e);if(!t)return[{text:e,kind:`plain`}];let n=[{text:t[1]??``,kind:`string`}];return t[2]&&n.push({text:t[2],kind:`plain`}),n}function lZ(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function uZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function dZ(e){return typeof e==`string`&&e.trim()!==``}var fZ={class:`space-y-1.5`},pZ={class:`space-y-1.5`},mZ={class:`flex h-9 flex-nowrap items-center gap-1.5 overflow-hidden`,role:`list`,"aria-label":`Steps`},hZ=[`title`],gZ={key:1,class:`text-xs text-fg-subtle`},_Z={class:`space-y-1.5`},vZ={class:`flex items-baseline gap-2`},yZ={class:`relative overflow-hidden rounded-lg border border-input font-mono text-[13px] leading-6 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50`},bZ={"aria-hidden":`true`,class:`pointer-events-none absolute inset-y-0 left-0 w-11 select-none overflow-hidden border-r border-border bg-secondary/40 py-3 text-right`},xZ={"aria-hidden":`true`,class:`pointer-events-none absolute inset-0 overflow-hidden py-3 pr-3 pl-14 break-words whitespace-pre-wrap`},SZ={key:0,class:`text-sm text-danger`,role:`alert`},CZ={class:`flex flex-wrap items-center gap-2 border-t border-border pt-4`},wZ={key:0,class:`mr-auto font-mono text-xs text-fg-subtle`},TZ=M({__name:`WorkflowEditor`,props:{selected:{required:!0},selectedModifiers:{}},emits:[`update:selected`],setup(e){let t=ZA(),n=W(()=>t.stateFor(`workflow-definitions`)),r=W(()=>n.value.resource?.value??{definitions:[]}),i=W(()=>t.shippedWorkflows()),a=co(e,`selected`),o=O(``),s=O(``),c=O(``),l=W(()=>i.value.definitions.find(e=>e.id===o.value));function u(e){let t=r.value.definitions.find(t=>t.id===e);o.value=t?.id??e,s.value=t?.yaml??`id: ${e}\nsteps:\n - type: `,c.value=``}j(a,u,{immediate:!0}),j(r,()=>{s.value||u(a.value)});async function d(e){return c.value=``,t.replace(`workflow-definitions`,e)}async function f(){let e=o.value.trim();if(!e){c.value=`Workflow ID is required.`;return}let t=a.value,n=r.value;t&&t!==e&&(n=YA(n,t)),await d(JA(n,{id:e,yaml:s.value}))&&(a.value=e)}async function p(){a.value&&await d(YA(r.value,a.value))&&(a.value=``,o.value=``,s.value=``)}async function m(){l.value&&await d(JA(r.value,KA(l.value)))}let h=W(()=>eZ(s.value)),g=W(()=>h.value.ok?h.value.steps:[]),_=W(()=>nZ(s.value)),v=O(0);function y(e){v.value=e.target.scrollTop}return(e,t)=>(I(),L(`form`,{class:`space-y-4`,onSubmit:lu(f,[`prevent`])},[z(`div`,fZ,[B(k(gT),{for:`workflow-id`},{default:A(()=>[...t[2]||=[V(`ID`,-1)]]),_:1}),B(k(Q),{id:`workflow-id`,modelValue:o.value,"onUpdate:modelValue":t[0]||=e=>o.value=e,name:`workflow-id`,required:``,autocomplete:`off`,class:`max-w-sm font-mono`},null,8,[`modelValue`])]),z(`div`,pZ,[t[3]||=z(`span`,{class:`text-sm leading-none font-medium`},`Steps`,-1),z(`div`,mZ,[g.value.length?(I(!0),L(F,{key:0},N(g.value,(e,t)=>(I(),L(F,{key:e.index},[z(`span`,{role:`listitem`,class:`shrink-0 rounded border border-border bg-secondary px-2 py-0.5 font-mono text-xs`,title:e.type},D(e.type),9,hZ),t<g.value.length-1?(I(),R(k(yd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":`true`})):H(``,!0)],64))),128)):(I(),L(`span`,gZ,`No steps yet`))])]),z(`div`,_Z,[z(`div`,vZ,[B(k(gT),{for:`workflow-yaml`},{default:A(()=>[...t[4]||=[V(`YAML`,-1)]]),_:1}),z(`span`,{class:E([`ml-auto text-xs`,h.value.ok?`text-ok`:`text-danger`]),role:`status`},D(h.value.ok?`✓`:`✕`)+` `+D(k($X)(h.value)),3)]),z(`div`,yZ,[z(`div`,bZ,[z(`div`,{style:ve(`transform:translateY(${-v.value}px)`)},[(I(!0),L(F,null,N(_.value,e=>(I(),L(`div`,{key:e.number,class:`min-h-6 pr-2 text-fg-subtle`},D(e.number),1))),128))],4)]),z(`div`,xZ,[z(`div`,{style:ve(`transform:translateY(${-v.value}px)`)},[(I(!0),L(F,null,N(_.value,e=>(I(),L(`div`,{key:e.number,class:`min-h-6`},[(I(!0),L(F,null,N(e.tokens,(e,t)=>(I(),L(`span`,{key:t,class:E(k(tZ)(e.kind))},D(e.text),3))),128))]))),128))],4)]),B(k(DT),{id:`workflow-yaml`,modelValue:s.value,"onUpdate:modelValue":t[1]||=e=>s.value=e,name:`workflow-yaml`,required:``,class:`relative min-h-96 resize-y rounded-none border-0 bg-transparent py-3 pr-3 pl-14 text-[13px] leading-6 text-transparent caret-foreground shadow-none md:text-[13px] focus-visible:ring-0`,spellcheck:`false`,onScroll:y},null,8,[`modelValue`])])]),c.value||n.value.error?(I(),L(`p`,SZ,D(c.value||n.value.error),1)):H(``,!0),z(`div`,CZ,[n.value.resource?(I(),L(`span`,wZ,`Version `+D(n.value.resource.version),1)):H(``,!0),a.value?(I(),R(k(Z),{key:1,type:`button`,variant:`ghost`,class:`text-danger`,onClick:p},{default:A(()=>[B(k(rf)),t[5]||=V(` Remove`,-1)]),_:1})):H(``,!0),l.value?(I(),R(k(Z),{key:2,type:`button`,variant:`outline`,onClick:m},{default:A(()=>[B(k(Xd)),t[6]||=V(` Restore this workflow`,-1)]),_:1})):H(``,!0),B(k(Z),{type:`submit`,disabled:n.value.saving||!h.value.ok},{default:A(()=>[n.value.saving?(I(),R(k(OF),{key:0,"data-icon":`inline-start`})):H(``,!0),t[7]||=V(` Validate & save`,-1)]),_:1},8,[`disabled`])])],32))}});function EZ(e,t){let n=new Map((e||[]).map(e=>[e.workflow,e])),r=[],i=new Set;for(let e of t||[])i.add(e.id),r.push({...e,...n.get(e.id)||{workflow:e.id,runs:0,merged:0,completed:0}});for(let t of e||[])i.has(t.workflow)||r Line truncated
+8 -3
View File
@@ -152,12 +152,17 @@ export const api = {
request<T>(`/api/tasks/${encodeURIComponent(id)}/debug` + qs(params)),
// taskAction posts an operator action. A review-gate answer may carry a
// payload: the instructions a rereview requires, and the finding keys an
// approve posts (an absent selection means every offered finding). Every
// other action sends neither.
// approve posts (an absent selection means every offered finding). A retry
// carries the worktree mode the operator chose. Every other action sends
// none.
taskAction: <T = unknown>(
id: string,
action: string,
payload?: { instructions?: string; findings?: string[] },
payload?: {
instructions?: string;
findings?: string[];
retry_mode?: string;
},
) =>
request<T>(`/api/tasks/${encodeURIComponent(id)}/action`, {
method: "POST",
+26
View File
@@ -24,6 +24,15 @@ export interface ChangeStatusMeta {
label: string;
}
/** A retry worktree mode as the server describes it. */
export interface RetryModeMeta {
id: string;
label: string;
description: string;
default?: boolean;
requires_branch?: boolean;
}
export const DEFAULT_STATUSES: StatusMeta[] = [
{ id: "queued", label: "Queued", kind: "idle" },
{ id: "running", label: "Working", kind: "info" },
@@ -88,4 +97,21 @@ export const DEFAULT_CHANGE_STATUSES: ChangeStatusMeta[] = [
{ id: "typechange", label: "Type changed" },
];
export const DEFAULT_RETRY_MODES: RetryModeMeta[] = [
{
id: "refresh_onto_base",
label: "Refresh onto base",
description:
"Start the retry from the current base branch, discarding work already pushed on this task's branch.",
default: true,
},
{
id: "continue_pushed_work",
label: "Continue pushed work",
description:
"Resume the branch this task already pushed, keeping its commits.",
requires_branch: true,
},
];
export const DEFAULT_CONFIG_SCHEMA = "archie/task-config@1";
+29 -1
View File
@@ -28,14 +28,17 @@ import {
DEFAULT_ACTIONS,
DEFAULT_CHANGE_STATUSES,
DEFAULT_CONFIG_SCHEMA,
DEFAULT_RETRY_MODES,
DEFAULT_STATUSES,
type RetryModeMeta,
type StatusMeta,
} from "./task-meta-snapshot";
export type { ActionMeta, ChangeStatusMeta, StatusMeta };
export type { ActionMeta, ChangeStatusMeta, RetryModeMeta, StatusMeta };
const statuses = shallowRef<StatusMeta[]>([...DEFAULT_STATUSES]);
const actions = shallowRef<ActionMeta[]>([...DEFAULT_ACTIONS]);
const retryModesRef = shallowRef<RetryModeMeta[]>([...DEFAULT_RETRY_MODES]);
const changeStatuses = shallowRef<ChangeStatusMeta[]>([
...DEFAULT_CHANGE_STATUSES,
]);
@@ -48,6 +51,9 @@ const actionById = computed(() => new Map(actions.value.map((a) => [a.id, a])));
const changeStatusById = computed(
() => new Map(changeStatuses.value.map((c) => [c.id, c])),
);
const retryModeById = computed(
() => new Map(retryModesRef.value.map((m) => [m.id, m])),
);
// loadTaskMeta upgrades the dashboard from the server catalog. It never throws:
// a failed fetch keeps the defaults so the UI still renders.
@@ -56,11 +62,13 @@ export async function loadTaskMeta(): Promise<void> {
const data = await api.taskMeta<{
statuses?: StatusMeta[];
actions?: ActionMeta[];
retry_modes?: RetryModeMeta[];
change_statuses?: ChangeStatusMeta[];
config_schema?: string;
} | null>();
if (Array.isArray(data?.statuses)) statuses.value = data.statuses;
if (Array.isArray(data?.actions)) actions.value = data.actions;
if (Array.isArray(data?.retry_modes)) retryModesRef.value = data.retry_modes;
if (Array.isArray(data?.change_statuses))
changeStatuses.value = data.change_statuses;
if (data?.config_schema) configSchemaRef.value = data.config_schema;
@@ -105,6 +113,26 @@ export function actionFor(id: string): ActionMeta | null {
return actionById.value.get(id) || null;
}
/**
* retryModes returns the server's retry worktree modes in display order. The
* retry dialog renders these and falls back to the frozen snapshot before the
* catalog arrives.
*/
export function retryModes(): RetryModeMeta[] {
return retryModesRef.value;
}
/**
* retryModeFor returns one retry mode's metadata, or null if the server has
* never described it.
*/
export function retryModeFor(
id: string | null | undefined,
): RetryModeMeta | null {
if (!id) return null;
return retryModeById.value.get(id) || null;
}
/**
* changeStatusLabel names a changes_captured file status. An id the catalog
* does not know renders as itself rather than breaking the row.
+7
View File
@@ -20,6 +20,13 @@ export interface Task {
tokens_used?: number;
workflow?: string;
attempt?: number;
/** The branch this task pushed, if any. A retry that continues pushed work
* resumes it; the retry dialog disables that mode when it is empty. */
branch?: string;
/** The operator's persisted worktree choice for the next retry dispatch
* ("refresh_onto_base" or "continue_pushed_work"). The retry dialog opens
* on this value so the choice survives a reload. */
retry_mode?: string;
created_at?: string;
updated_at?: string;
actions?: string[];
+98 -3
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { Ellipsis } from "@lucide/vue";
import { computed, ref } from "vue";
import { RadioGroupItem, RadioGroupRoot } from "reka-ui";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import {
@@ -31,9 +32,14 @@ import {
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import { api, classifyActionError, type ActionErrorKind } from "@/lib/api";
import { actionFor, type ActionMeta } from "@/lib/task-meta";
import { actionFor, retryModes, type ActionMeta } from "@/lib/task-meta";
import type { Task } from "./TaskRow.vue";
import { shownActionIds } from "./task-actions";
import {
initialRetryChoice,
retryChoices,
retryPayload,
} from "./retry-mode";
/**
* The lifecycle controls for one task. A task offers whatever the server says
@@ -77,6 +83,17 @@ const rereviewOpen = ref(false);
const rereviewId = ref<string | null>(null);
const instructions = ref("");
// A retry carries the operator's worktree mode (taskstate.RetryMode). The
// dialog opens on the task's persisted choice -- so a remediation retry keeps
// continuing its branch -- and the operator may pick the other mode. The
// chosen value travels in the action body and is persisted on the task.
const retryOpen = ref(false);
const retryId = ref<string | null>(null);
const retryMode = ref("");
const retryOptions = computed(() =>
retryChoices(retryModes(), props.task.branch),
);
const controls = computed<Control[]>(() =>
shownActionIds(props.task.actions, props.only)
.map((id) => actionFor(id))
@@ -157,7 +174,8 @@ function variantFor(kind: string): ControlVariant {
// A control that names a consequence is confirmed first; the two that only open
// a forge page are not, because they change nothing. A re-review needs
// instructions, which its own dialog collects.
// instructions, which its own dialog collects; a retry needs a worktree mode,
// which its own dialog collects.
function request(id: string) {
error.value = null;
if (id === "rereview") {
@@ -165,6 +183,15 @@ function request(id: string) {
rereviewOpen.value = true;
return;
}
if (id === "retry") {
retryId.value = id;
retryMode.value = initialRetryChoice(
retryOptions.value,
props.task.retry_mode,
);
retryOpen.value = true;
return;
}
if (actionFor(id)?.confirm) {
confirmingId.value = id;
confirming.value = id;
@@ -173,7 +200,10 @@ function request(id: string) {
void run(id);
}
async function run(id: string, payload?: { instructions?: string }) {
async function run(
id: string,
payload?: { instructions?: string; retry_mode?: string },
) {
confirming.value = null;
inFlight.value = true;
error.value = null;
@@ -202,6 +232,17 @@ function submitRereview() {
void run(id, { instructions: text });
}
function onRetryOpen(open: boolean) {
retryOpen.value = open;
}
function submitRetry() {
const id = retryId.value;
if (!id || !retryMode.value) return;
retryOpen.value = false;
void run(id, retryPayload(retryMode.value));
}
function onConfirmationOpen(open: boolean) {
if (!open) confirming.value = null;
}
@@ -329,6 +370,60 @@ function requestFromMenu(id: string) {
</DialogContent>
</Dialog>
<!--
A retry opens this dialog rather than firing immediately: the operator
picks where the retry starts (taskstate.RetryMode), the choice rides the
action body and is persisted on the task, and the daemon's worktree
preparation reads it. Preselecting the task's persisted mode keeps a
remediation retry continuing its branch.
-->
<Dialog :open="retryOpen" @update:open="onRetryOpen">
<DialogContent class="sm:max-w-lg">
<DialogHeader>
<DialogTitle>Retry this task?</DialogTitle>
<DialogDescription>
Choose where the retry starts. The mode is saved on the task and
the daemon prepares the worktree from it.
</DialogDescription>
</DialogHeader>
<RadioGroupRoot
v-model="retryMode"
class="grid grid-cols-1 gap-2"
aria-label="Retry worktree mode"
loop
>
<label
v-for="option in retryOptions"
:key="option.id"
class="flex items-start gap-3 rounded-md border border-border bg-card px-3 py-2.5 text-left transition-colors"
:class="
option.disabled
? 'cursor-not-allowed opacity-60'
: 'cursor-pointer hover:bg-secondary'
"
>
<RadioGroupItem
:value="option.id"
:disabled="option.disabled || inFlight"
class="mt-0.5 shrink-0"
/>
<span class="grid gap-0.5">
<span class="text-[13px] font-medium">{{ option.label }}</span>
<span class="text-xs text-fg-subtle">{{ option.description }}</span>
</span>
</label>
</RadioGroupRoot>
<DialogFooter>
<Button variant="ghost" :disabled="inFlight" @click="onRetryOpen(false)">
Keep it parked
</Button>
<Button :disabled="inFlight || !retryMode" @click="submitRetry">
Retry
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<AlertDialog :open="confirming !== null" @update:open="onConfirmationOpen">
<AlertDialogContent>
<AlertDialogHeader>
+84
View File
@@ -0,0 +1,84 @@
/**
* The retry worktree choice, as the dashboard builds it.
*
* The module exists so the wire shape, the disable rule and the
* initial-selection rule are testable under the node module runner rather
* than buried in the SFC. The choice the operator makes here must travel to
* the daemon: the retry action carries it, the task row persists it, and the
* daemon's worktree preparation reads it (taskstate.RetryMode).
*/
/** The catalog shape /api/task-meta serves for one retry mode. */
export interface RetryModeOption {
id: string;
label: string;
description: string;
default?: boolean;
requires_branch?: boolean;
}
/** One option as the retry dialog renders it. */
export interface RetryChoice {
id: string;
label: string;
description: string;
disabled: boolean;
}
/**
* retryChoices is the operator's options for one task. A mode that needs a
* branch is disabled when the task has none: the server refuses that
* combination, so the dialog never sends a request it knows will conflict.
*/
export function retryChoices(
modes: readonly RetryModeOption[],
branch: string | null | undefined,
): RetryChoice[] {
const hasBranch = Boolean(branch && branch.trim());
return modes.map((mode) => ({
id: mode.id,
label: mode.label,
description: mode.description,
disabled: Boolean(mode.requires_branch) && !hasBranch,
}));
}
/**
* initialRetryMode is the mode the dialog opens on: the task's own persisted
* choice when the catalog still names it, otherwise the server's default.
* Reading the persisted value is what keeps a remediation retry continuing
* its branch rather than resetting over the pull request, while a first retry
* still opens on the explicit refresh default.
*/
export function initialRetryMode(
modes: readonly RetryModeOption[],
persisted: string | null | undefined,
): string {
if (persisted && modes.some((mode) => mode.id === persisted)) {
return persisted;
}
return modes.find((mode) => mode.default)?.id ?? modes[0]?.id ?? "";
}
/**
* initialRetryChoice is the option the dialog actually selects: the task's
* persisted mode when it is offered and enabled, otherwise the first enabled
* option. It exists so a persisted mode the task can no longer use -- say
* continue_pushed_work on a task whose branch is gone -- cannot be submitted
* as a preselected-but-disabled value.
*/
export function initialRetryChoice(
choices: readonly RetryChoice[],
persisted: string | null | undefined,
): string {
const match = persisted
? choices.find((choice) => choice.id === persisted)
: undefined;
if (match && !match.disabled) return match.id;
return choices.find((choice) => !choice.disabled)?.id ?? "";
}
/** retryPayload is the action body a retry posts for the chosen mode. */
export function retryPayload(mode: string): { retry_mode: string } {
return { retry_mode: mode };
}
+63
View File
@@ -0,0 +1,63 @@
import assert from "node:assert/strict";
import test from "node:test";
const { initialRetryChoice, initialRetryMode, retryChoices, retryPayload } =
await import("../src/tasks/retry-mode.ts");
const MODES = [
{
id: "refresh_onto_base",
label: "Refresh onto base",
description: "start from base",
default: true,
},
{
id: "continue_pushed_work",
label: "Continue pushed work",
description: "resume the branch",
requires_branch: true,
},
];
test("continue is disabled when the task has no pushed branch", () => {
const choices = retryChoices(MODES, "");
assert.equal(choices[0].disabled, false);
assert.equal(choices[1].disabled, true);
});
test("continue is offered when the task has a pushed branch", () => {
const choices = retryChoices(MODES, "fix/7-thing");
assert.equal(choices[1].disabled, false);
});
test("a whitespace branch is no branch", () => {
assert.equal(retryChoices(MODES, " ")[1].disabled, true);
});
test("the dialog opens on the task's persisted mode", () => {
assert.equal(initialRetryMode(MODES, "continue_pushed_work"), "continue_pushed_work");
});
test("an unknown persisted mode falls back to the explicit server default", () => {
assert.equal(initialRetryMode(MODES, "reset_to_head"), "refresh_onto_base");
assert.equal(initialRetryMode(MODES, ""), "refresh_onto_base");
});
test("the payload carries the chosen mode under the wire key", () => {
assert.deepEqual(retryPayload("continue_pushed_work"), {
retry_mode: "continue_pushed_work",
});
});
test("a persisted mode the task can no longer use is not preselected", () => {
const choices = retryChoices(MODES, "");
assert.equal(initialRetryChoice(choices, "continue_pushed_work"), "refresh_onto_base");
});
test("a persisted enabled mode is preselected", () => {
const choices = retryChoices(MODES, "fix/7-thing");
assert.equal(
initialRetryChoice(choices, "continue_pushed_work"),
"continue_pushed_work",
);
});