feat(controlplane): serve each step type's settings schema; the workflow editor checks settings before save

This commit is contained in:
sam committed 2026-10-05 00:39:47 +11:00
1 parent b2150381c5
commit 3eafb818b8
15 files changed
+168 -80

No files matched your search

+1 -1
View File
@@ -59,7 +59,7 @@ func NewServer(resources ResourceStore, steps *workflow.Manager) (*Server, error
if err != nil {
return nil, err
}
definitions := builtinDefinitions(registry)
definitions := builtinDefinitions(registry, steps.Settings())
byKind := make(map[string]Definition, len(definitions))
for _, definition := range definitions {
byKind[definition.Kind] = definition
+2 -2
View File
@@ -7,8 +7,8 @@ import (
// Schemas are not declared here: each Definition names its document type, and
// Definition.Descriptor derives the JSON Schema from it (internal/app/controlplane/schema.go).
func builtinDefinitions(steps workflow.StepRegistry) []Definition {
definitions := []Definition{workflowDefinition(), workflowDefinitionsDefinition(steps), workflowEnablementDefinition(), personaDefinition(), scheduleDefinition(), agentProfileDefinition(), playbooksDefinition(), skillsDefinition(), credentialBindingsDefinition(), identityGrantsDefinition(), reviewSettingsDefinition()}
func builtinDefinitions(steps workflow.StepRegistry, settings map[string]any) []Definition {
definitions := []Definition{workflowDefinition(), workflowDefinitionsDefinition(steps, settings), workflowEnablementDefinition(), personaDefinition(), scheduleDefinition(), agentProfileDefinition(), playbooksDefinition(), skillsDefinition(), credentialBindingsDefinition(), identityGrantsDefinition(), reviewSettingsDefinition()}
definitions = append(definitions, modelDefinitions()...)
definitions = append(definitions, operationalDefinitions()...)
return definitions
+28 -13
View File
@@ -35,7 +35,7 @@ func schemaJSON(document any, extensions map[string]any) string {
if document == nil {
return bareObjectSchema
}
schema := schemaOf(reflect.TypeOf(document))
schema := schemaOf(reflect.TypeOf(document), "json")
maps.Copy(schema, extensions)
encoded, err := json.Marshal(schema)
if err != nil {
@@ -47,9 +47,19 @@ func schemaJSON(document any, extensions map[string]any) string {
return string(encoded)
}
// schemaOf is the JSON Schema for one type, following json tags for keys and the
// Go type for everything else.
func schemaOf(t reflect.Type) map[string]any {
// settingsSchema is the JSON Schema of a workflow step's settings type, keyed by
// its yaml tags because step settings are written in YAML. Nil means the step
// takes no settings.
func settingsSchema(settings any) map[string]any {
if settings == nil {
return nil
}
return schemaOf(reflect.TypeOf(settings), "yaml")
}
// schemaOf is the JSON Schema for one type, following the keyTag struct tags
// for keys and the Go type for everything else.
func schemaOf(t reflect.Type, keyTag string) map[string]any {
for t.Kind() == reflect.Pointer {
t = t.Elem()
}
@@ -65,11 +75,11 @@ func schemaOf(t reflect.Type) map[string]any {
}
switch t.Kind() {
case reflect.Struct:
return objectSchemaOf(t)
return objectSchemaOf(t, keyTag)
case reflect.Slice, reflect.Array:
return map[string]any{"type": "array", "items": schemaOf(t.Elem())}
return map[string]any{"type": "array", "items": schemaOf(t.Elem(), keyTag)}
case reflect.Map:
return map[string]any{"type": "object", "additionalProperties": schemaOf(t.Elem())}
return map[string]any{"type": "object", "additionalProperties": schemaOf(t.Elem(), keyTag)}
case reflect.Bool:
return map[string]any{"type": "boolean"}
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
@@ -77,19 +87,21 @@ func schemaOf(t reflect.Type) map[string]any {
return map[string]any{"type": "integer"}
case reflect.Float32, reflect.Float64:
return map[string]any{"type": "number"}
case reflect.Interface:
return map[string]any{} // any JSON value
default:
return map[string]any{"type": "string"}
}
}
func objectSchemaOf(t reflect.Type) map[string]any {
func objectSchemaOf(t reflect.Type, keyTag string) map[string]any {
properties := map[string]any{}
for field := range t.Fields() {
if field.Anonymous {
// encoding/json promotes an embedded struct's fields into the
// enclosing object, so the schema lists them there too. Dropping
// them would leave document keys nothing describes.
embedded, ok := schemaOf(field.Type)["properties"].(map[string]any)
embedded, ok := schemaOf(field.Type, keyTag)["properties"].(map[string]any)
if !ok {
continue
}
@@ -99,11 +111,11 @@ func objectSchemaOf(t reflect.Type) map[string]any {
if field.PkgPath != "" {
continue // unexported: not part of any document
}
name, ok := documentKey(field)
name, ok := documentKey(field, keyTag)
if !ok {
continue
}
properties[name] = documented(schemaOf(field.Type), field)
properties[name] = documented(schemaOf(field.Type, keyTag), field)
}
return map[string]any{"type": "object", "properties": properties}
}
@@ -112,8 +124,8 @@ func objectSchemaOf(t reflect.Type) map[string]any {
// or the Go field name when the tag declares none, because that fallback is what
// encoding/json uses and therefore what the document really holds. Reporting the
// tag instead of the fallback would describe a document nobody stores.
func documentKey(field reflect.StructField) (string, bool) {
name, _, _ := strings.Cut(field.Tag.Get("json"), ",")
func documentKey(field reflect.StructField, keyTag string) (string, bool) {
name, _, _ := strings.Cut(field.Tag.Get(keyTag), ",")
switch name {
case "-":
return "", false
@@ -136,5 +148,8 @@ func documented(schema map[string]any, field reflect.StructField) map[string]any
schema[annotation.key] = value
}
}
if values := field.Tag.Get("enum"); values != "" {
schema["enum"] = strings.Split(values, ",")
}
return schema
}
@@ -21,7 +21,7 @@ func stepRegistry(steps *workflow.Manager) (workflow.StepRegistry, error) {
return steps.Registry(), nil
}
func workflowDefinitionsDefinition(steps workflow.StepRegistry) Definition {
func workflowDefinitionsDefinition(steps workflow.StepRegistry, settings map[string]any) Definition {
return Definition{
Kind: WorkflowDefinitionsKind,
Title: "Workflow definitions",
@@ -37,16 +37,21 @@ func workflowDefinitionsDefinition(steps workflow.StepRegistry) Definition {
_, err := workflow.DecodeDefinitionCollection(input, steps)
return err
},
SchemaExtensions: map[string]any{"x-step-types": stepTypeVocabulary(steps)},
SchemaExtensions: map[string]any{"x-step-types": stepTypeVocabulary(steps, settings)},
}
}
// stepTypeVocabulary is the registered step types as the dashboard editor
// checks them: each name and whether it needs a repository.
func stepTypeVocabulary(steps workflow.StepRegistry) []map[string]any {
// reads them: each name, whether it needs a repository, and the schema of its
// settings (absent for a step that takes none).
func stepTypeVocabulary(steps workflow.StepRegistry, settings map[string]any) []map[string]any {
vocabulary := make([]map[string]any, 0, len(steps))
for _, name := range slices.Sorted(maps.Keys(steps)) {
vocabulary = append(vocabulary, map[string]any{"name": name, "needs_repository": workflow.NeedsRepository(name)})
entry := map[string]any{"name": name, "needs_repository": workflow.NeedsRepository(name)}
if schema := settingsSchema(settings[name]); schema != nil {
entry["settings"] = schema
}
vocabulary = append(vocabulary, entry)
}
return vocabulary
}
+8 -8
View File
@@ -26,27 +26,27 @@ const resultToolName = "result"
type agentRunSettings struct {
// Mission is what the agent is asked to do. The workflow's inputs are
// appended to it as structured data.
Mission string `yaml:"mission"`
Mission string `yaml:"mission" doc:"What the agent is asked to do. May reference {{ task.* }}, {{ inputs.* }} and {{ steps.<id>.* }}."`
// Role selects the model (cfg.Models[Role]); empty means builder.
Role string `yaml:"role"`
Role string `yaml:"role" doc:"Which configured model role runs the agent, e.g. builder or planner. Empty means builder."`
// ReadOnly restricts the agent to read-only tools.
ReadOnly bool `yaml:"read_only"`
ReadOnly bool `yaml:"read_only" title:"Read only" doc:"Restrict the agent to read-only tools."`
// Gate holds the agent to the repository's gate before it may finish:
// "repository", or "test-failure" where the test command must fail
// (writing a failing reproduction). Empty means ungated.
Gate string `yaml:"gate"`
Gate string `yaml:"gate" enum:"repository,test-failure" doc:"Hold the agent to the repository gate before it may finish; test-failure requires the tests to fail."`
// ProtectTests write-blocks the repository's test files.
ProtectTests bool `yaml:"protect_tests"`
ProtectTests bool `yaml:"protect_tests" title:"Protect tests" doc:"Write-block the repository test files."`
// ExtraRules is appended to the agent's system prompt.
ExtraRules string `yaml:"extra_rules"`
ExtraRules string `yaml:"extra_rules" title:"Extra rules" doc:"Appended to the agent system prompt."`
// Result is a JSON Schema object. When set, the agent must return a value
// matching it, which later steps read as steps.<id>.result.
Result map[string]any `yaml:"result"`
Result map[string]any `yaml:"result" doc:"A JSON Schema object the agent must return; later steps read it as steps.<id>.result."`
}
// AgentRunStepType contributes the agent.run step type.
func AgentRunStepType() StepType {
return StepType{Name: AgentRunStepName, Factory: newAgentRunStage}
return StepType{Name: AgentRunStepName, Factory: newAgentRunStage, Settings: agentRunSettings{}}
}
func newAgentRunStage(settings yaml.Node) (Stage, error) {
+5 -5
View File
@@ -24,18 +24,18 @@ type commandRunSettings struct {
// Level is "error" (the default) or "warn". At "warn" a non-zero exit is
// logged and the workflow continues, which is what makes the step usable
// for a check the operator wants to see without being stopped by it.
Level string `yaml:"level"`
Level string `yaml:"level" enum:"error,warn" doc:"error stops the run on a failing command; warn reports it and continues."`
// Run is the commands to execute, in order. The first failure ends the
// step, so a later command does not run after an earlier one failed.
Run []commandRunCommand `yaml:"run"`
Run []commandRunCommand `yaml:"run" doc:"The commands to run in order; the first failure ends the step."`
}
// commandRunCommand is one command in a command.run step's settings. It is
// the YAML shape of agentrun.Command.
type commandRunCommand struct {
Name string `yaml:"name"`
Argv []string `yaml:"argv"`
ExpectFailure bool `yaml:"expect_failure"`
Argv []string `yaml:"argv" doc:"The program and its arguments."`
ExpectFailure bool `yaml:"expect_failure" title:"Expect failure" doc:"The command must exit non-zero."`
}
// command converts the settings shape into the type the execution path takes,
@@ -46,7 +46,7 @@ func (c commandRunCommand) command() agentrun.Command {
// CommandRunStepType contributes the command.run step type.
func CommandRunStepType() StepType {
return StepType{Name: CommandRunStepName, Factory: newCommandRunStage}
return StepType{Name: CommandRunStepName, Factory: newCommandRunStage, Settings: commandRunSettings{}}
}
func newCommandRunStage(settings yaml.Node) (Stage, error) {
+9 -9
View File
@@ -19,16 +19,16 @@ const (
// ControlStepTypes contributes the control and forge step types.
func ControlStepTypes() []StepType {
return []StepType{
{Name: HandoffStepName, Factory: newHandoffStage},
{Name: ApproveStepName, Factory: newApproveStage},
{Name: HandoffStepName, Factory: newHandoffStage, Settings: handoffSettings{}},
{Name: ApproveStepName, Factory: newApproveStage, Settings: approveSettings{}},
{Name: CloseIssueStepName, Factory: newCloseIssueStage},
{Name: CommentStepName, Factory: newCommentStage},
{Name: CommentStepName, Factory: newCommentStage, Settings: commentSettings{}},
}
}
type handoffSettings struct {
Workflow string `yaml:"workflow"`
Detail string `yaml:"detail"`
Workflow string `yaml:"workflow" doc:"The workflow the task is requeued under."`
Detail string `yaml:"detail" doc:"Why the task was handed off."`
}
// newHandoffStage requeues the task under another workflow: the same task,
@@ -51,9 +51,9 @@ func newHandoffStage(settings yaml.Node) (Stage, error) {
type approveSettings struct {
// Plan is what the human decides on. It is kept on the task, and the
// workflow named by Then reads it as task.plan.
Plan string `yaml:"plan"`
Plan string `yaml:"plan" doc:"What the human decides on; the next workflow reads it as task.plan."`
// Then is the workflow the task is requeued under once approved.
Then string `yaml:"then"`
Then string `yaml:"then" doc:"The workflow the task runs once approved."`
}
// newApproveStage delivers the plan to the decision surfaces and waits: the
@@ -85,9 +85,9 @@ func newCloseIssueStage(yaml.Node) (Stage, error) {
}
type commentSettings struct {
Body string `yaml:"body"`
Body string `yaml:"body" doc:"The comment text."`
// On is "issue" (the default) or "pr".
On string `yaml:"on"`
On string `yaml:"on" enum:"issue,pr" doc:"Comment on the issue or the pull request. Empty means issue."`
}
func newCommentStage(settings yaml.Node) (Stage, error) {
+3 -3
View File
@@ -54,7 +54,7 @@ type DiffRule struct {
ID string `yaml:"id"`
// Level is DiffRuleLevelError or DiffRuleLevelWarn, and is required: a rule
// that does not say whether it blocks is refused rather than defaulted.
Level string `yaml:"level"`
Level string `yaml:"level" enum:"error,warn"`
// Pattern is the RE2 expression matched against each added line's text
// (without its leading "+"). Required.
Pattern string `yaml:"pattern"`
@@ -73,14 +73,14 @@ type DiffRule struct {
// so the decode is strict: a settings key the step does not read is refused
// where the definition is validated, not ignored at run time.
type diffRulesSettings struct {
Rules []DiffRule `yaml:"rules"`
Rules []DiffRule `yaml:"rules" doc:"Patterns the change must not match."`
}
// DiffRulesStepType returns the registered step type for DiffRulesStepName, the
// way the shipped stages are declared: the factory builds the stage the
// executing side runs from the settings the validating side accepted.
func DiffRulesStepType() StepType {
return StepType{Name: DiffRulesStepName, Factory: newDiffRulesStage}
return StepType{Name: DiffRulesStepName, Factory: newDiffRulesStage, Settings: diffRulesSettings{}}
}
// newDiffRulesStage decodes and compiles the step's settings, refusing every
+3 -3
View File
@@ -19,13 +19,13 @@ var finishStatuses = map[string]string{
}
type finishSettings struct {
Status string `yaml:"status"`
Detail string `yaml:"detail"`
Status string `yaml:"status" enum:"completed,parked,waiting_human,declined" doc:"How the run ends. Empty means completed."`
Detail string `yaml:"detail" doc:"What the operator reads about the outcome."`
}
// FinishStepType contributes the workflow.finish step type.
func FinishStepType() StepType {
return StepType{Name: FinishStepName, Factory: newFinishStage}
return StepType{Name: FinishStepName, Factory: newFinishStage, Settings: finishSettings{}}
}
func newFinishStage(settings yaml.Node) (Stage, error) {
+13 -13
View File
@@ -25,10 +25,10 @@ const (
// RepoStepTypes contributes the general repository step types.
func RepoStepTypes() []StepType {
return []StepType{
{Name: RepoPrepareStepName, Factory: newRepoPrepareStage},
{Name: RepoCommitStepName, Factory: newRepoCommitStage},
{Name: RepoOpenPRStepName, Factory: newRepoOpenPRStage},
{Name: GateRepositoryName, Factory: newGateRepositoryStage},
{Name: RepoPrepareStepName, Factory: newRepoPrepareStage, Settings: repoPrepareSettings{}},
{Name: RepoCommitStepName, Factory: newRepoCommitStage, Settings: repoCommitSettings{}},
{Name: RepoOpenPRStepName, Factory: newRepoOpenPRStage, Settings: repoOpenPRSettings{}},
{Name: GateRepositoryName, Factory: newGateRepositoryStage, Settings: gateRepositorySettings{}},
{Name: GateDiffSizeStepName, Factory: func(yaml.Node) (Stage, error) {
stage := StageDiffCap()
stage.Name = GateDiffSizeStepName
@@ -51,7 +51,7 @@ func decodeSettings(step string, settings yaml.Node, into any) error {
type repoPrepareSettings struct {
// Branch is "fresh" (the default, a new branch from the base) or "task",
// the branch an earlier run of this task pushed.
Branch string `yaml:"branch"`
Branch string `yaml:"branch" enum:"fresh,task" doc:"fresh starts a new branch from the base; task resumes the branch this task pushed."`
}
func newRepoPrepareStage(settings yaml.Node) (Stage, error) {
@@ -73,14 +73,14 @@ func newRepoPrepareStage(settings yaml.Node) (Stage, error) {
}
type repoCommitSettings struct {
Message string `yaml:"message"`
Message string `yaml:"message" doc:"The commit message."`
// Reference is the verb that links the commit to the task's issue
// ("Fixes", "Implements", "Refs"); empty links nothing.
Reference string `yaml:"reference"`
Push bool `yaml:"push"`
Reference string `yaml:"reference" enum:"Fixes,Implements,Refs" doc:"How the commit links to the task issue."`
Push bool `yaml:"push" doc:"Push the branch after committing."`
// IfEmpty is what an empty worktree does: "fail" (the default), "skip",
// or "complete", which closes the issue and completes the workflow.
IfEmpty string `yaml:"if_empty"`
IfEmpty string `yaml:"if_empty" title:"If nothing changed" enum:"fail,skip,complete" doc:"fail stops the run, skip moves on, complete closes the issue and ends the run."`
}
func newRepoCommitStage(settings yaml.Node) (Stage, error) {
@@ -128,10 +128,10 @@ func newRepoCommitStage(settings yaml.Node) (Stage, error) {
}
type repoOpenPRSettings struct {
Body string `yaml:"body"`
Body string `yaml:"body" doc:"The pull request description."`
// Review runs the PR review pipeline on the change first; a blocking
// finding parks the task instead of opening the PR.
Review bool `yaml:"review"`
Review bool `yaml:"review" doc:"Review the change first; a blocking finding parks the task instead of opening the PR."`
}
func newRepoOpenPRStage(settings yaml.Node) (Stage, error) {
@@ -154,9 +154,9 @@ func newRepoOpenPRStage(settings yaml.Node) (Stage, error) {
type gateRepositorySettings struct {
// Expect is "pass" (the default) or "test-failure": every gate command
// passes except the test command, which must fail.
Expect string `yaml:"expect"`
Expect string `yaml:"expect" enum:"pass,test-failure" doc:"pass requires every gate command to pass; test-failure requires the test command to fail."`
// Repair lets the builder fix a failing gate before the step fails.
Repair bool `yaml:"repair"`
Repair bool `yaml:"repair" doc:"Let the builder fix a failing gate before the step fails."`
}
// newGateRepositoryStage runs the repository's gate commands in the worktree.
+2 -2
View File
@@ -21,7 +21,7 @@ func ReviewStepTypes() []StepType {
return []StepType{
{Name: ReviewPRStepName, Factory: newReviewPRStage},
{Name: ReviewRoundStepName, Factory: newReviewRoundStage},
{Name: ReviewReplyStepName, Factory: newReviewReplyStage},
{Name: ReviewReplyStepName, Factory: newReviewReplyStage, Settings: reviewReplySettings{}},
}
}
@@ -62,7 +62,7 @@ func newReviewRoundStage(yaml.Node) (Stage, error) {
}
type reviewReplySettings struct {
Body string `yaml:"body"`
Body string `yaml:"body" doc:"The reply to the review."`
}
// newReviewReplyStage answers the review this round addressed, in its own
+17 -1
View File
@@ -16,6 +16,10 @@ import (
type StepType struct {
Name string
Factory StepFactory
// Settings is a zero value of the step's settings type, from which the
// control plane derives the settings schema editors build forms from.
// Nil means the step takes no settings.
Settings any
}
// StepTypeProvider is the typed extension point through which a plugin
@@ -38,6 +42,7 @@ type Manager struct {
registry StepRegistry
// owners maps each step type to the provider that registered it.
owners map[string]string
settings map[string]any
providers []string
}
@@ -46,7 +51,7 @@ type Manager struct {
// composition root, so the vocabulary every side resolves is the one that was
// actually registered.
func NewManager() *Manager {
return &Manager{registry: StepRegistry{}, owners: map[string]string{}}
return &Manager{registry: StepRegistry{}, owners: map[string]string{}, settings: map[string]any{}}
}
// Register validates a provider's whole contribution and applies all of it or
@@ -63,6 +68,7 @@ func (m *Manager) Register(provider StepTypeProvider) error {
contributed := provider.StepTypes()
pending := make(StepRegistry, len(contributed))
settings := make(map[string]any, len(contributed))
order := make([]string, 0, len(contributed))
for _, stepType := range contributed {
switch {
@@ -75,6 +81,7 @@ func (m *Manager) Register(provider StepTypeProvider) error {
return fmt.Errorf("workflow step type provider %q declares step type %q twice", name, stepType.Name)
}
pending[stepType.Name] = stepType.Factory
settings[stepType.Name] = stepType.Settings
order = append(order, stepType.Name)
}
@@ -87,6 +94,7 @@ func (m *Manager) Register(provider StepTypeProvider) error {
}
for _, stepType := range order {
m.registry[stepType] = pending[stepType]
m.settings[stepType] = settings[stepType]
m.owners[stepType] = name
}
m.providers = append(m.providers, name)
@@ -104,6 +112,14 @@ func (m *Manager) Registry() StepRegistry {
return registry
}
// Settings returns each registered step type's settings value (see
// StepType.Settings), keyed by type name.
func (m *Manager) Settings() map[string]any {
m.mu.Lock()
defer m.mu.Unlock()
return maps.Clone(m.settings)
}
// StepTypes returns every registered step type name, sorted.
func (m *Manager) StepTypes() []string {
registry := m.Registry()
+3 -3
View File
@@ -36,9 +36,9 @@ var callPollInterval = 2 * time.Second
// a literal or "inputs.<name>", a reference to the calling workflow's declared
// input.
type workflowCallSettings struct {
Workflow string `yaml:"workflow"`
Workflow string `yaml:"workflow" doc:"The workflow to start as a child run."`
Inputs map[string]any `yaml:"inputs,omitempty"`
Wait bool `yaml:"wait,omitempty"`
Wait bool `yaml:"wait,omitempty" doc:"Wait for the child run to finish before continuing."`
// Outputs publishes a callee output as one of the caller's own: the key
// names the callee's declared output, the value an outputs.<name>
// reference naming the caller's declared output
@@ -61,7 +61,7 @@ var refName = regexp.MustCompile(`^[A-Za-z_][A-Za-z0-9_]*$`)
// WorkflowCallStepType contributes the workflow.call step type.
func WorkflowCallStepType() StepType {
return StepType{Name: WorkflowCallStepName, Factory: newWorkflowCallStage}
return StepType{Name: WorkflowCallStepName, Factory: newWorkflowCallStage, Settings: workflowCallSettings{}}
}
func newWorkflowCallStage(settings yaml.Node) (Stage, error) {
+12 -12
View File
@@ -6,19 +6,19 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Vp;function Hp(e){Vp=e}var Up=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Wp(e){let t=e instanceof Up?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Gp(e,t){let n=await fetch(e,t);if(Vp?.(n.status===401),!n.ok)throw new Up(await Bp(n),n.status);return n}async function Kp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Rp,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Gp(e,s);return a?await c.json():void 0}var qp={health:()=>Kp(`/health/detailed`),services:()=>Kp(`/api/services`),policies:()=>Kp(`/api/access/policies`),putPolicy:e=>Kp(`/api/access/policies`,{method:`PUT`,body:e}),deletePolicy:e=>Kp(`/api/access/policies`,{method:`DELETE`,body:e,parse:!1}),summary:()=>Kp(`/api/summary`),tasks:()=>Kp(`/api/tasks`),taskMeta:()=>Kp(`/api/task-meta`),task:e=>Kp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Kp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Kp(`/api/tasks/${encodeURIComponent(e)}/changes`+zp(t)),taskDebug:(e,t)=>Kp(`/api/tasks/${encodeURIComponent(e)}/debug`+zp(t)),taskAction:(e,t,n)=>Kp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t,...n}}),setup:()=>Kp(`/api/setup`),capabilities:()=>Kp(`/api/capabilities`),workflows:()=>Kp(`/api/workflows`),workflowEnabled:(e,t)=>Kp(`/api/workflows/${encodeURIComponent(e)}/enabled`,{method:`PUT`,body:{enabled:t},parse:!1}),workRequest:e=>Kp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Kp(`/api/skills`),channels:()=>Kp(`/api/channels`),curators:()=>Kp(`/api/curators`),channelReload:e=>Kp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Kp(`/api/config`),logs:e=>Kp(`/api/logs`+zp(e)),taskLogs:(e,t)=>Kp(`/api/tasks/${encodeURIComponent(e)}/logs`+zp(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>Kp(`/api/version`),updateSnapshot:()=>Kp(`/api/chat/update`),updateInstall:e=>Kp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>Kp(`/api/captures`+zp({limit:e})),eventTypes:()=>Kp(`/api/event-types`),eventTypeCreate:e=>Kp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>Kp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>Kp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>Kp(`/api/mappings`),mappingCreate:e=>Kp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Kp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Kp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Kp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Kp(`/api/bindings`),bindingCreate:e=>Kp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Kp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Kp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Kp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),harnessBindings:()=>Kp(`/api/harness/bindings`),sources:()=>Kp(`/api/sources`),sourceCreate:e=>Kp(`/api/sources`,{method:`POST`,body:{path:e}}),sourceSigning:(e,t)=>Kp(`/api/sources/${encodeURIComponent(e)}/signing`,{method:`POST`,body:{signed:t}}),sourceApproveUnsigned:e=>Kp(`/api/sources/${encodeURIComponent(e)}/approve-unsigned`,{method:`POST`}),sourceSecret:e=>Kp(`/api/sources/${encodeURIComponent(e)}/secret`,{method:`POST`}),chatSessions:()=>Kp(`/api/chat/sessions`),chatMessages:e=>Kp(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>Kp(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>Kp(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>Kp(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Lp(),text:t,page:location.pathname+location.search||`/`}}),chatPersona:(e,t)=>Kp(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatDangerous:()=>Kp(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>Kp(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>Kp(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,t={})=>Gp(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t.signal})};function Jp(e,t,n=``,r=!1){let i=new EventSource(Ip(n,r));return i.onopen=()=>t(`lLine truncated
`);u=r.pop()||``;for(let e of r){let t=e.split(`
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(lm.value=n.session_id),n.type===`delta`&&(o+=n.text,mm.value=mm.value?{...mm.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],mm.value=mm.value?{...mm.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);um.value=[...um.value,{from:`assistant`,text:o,tool_calls:a}],mm.value=null,fm.value=`Ready`,await km()}catch(e){let t=e;t.name===`AbortError`&&!c?(mm.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},fm.value=`Stopped`):(mm.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?im(r):void 0,isRetry:i},fm.value=`Error — retry available`)}finally{clearTimeout(l),Dm=null,pm.value=!1}}function Hm(){fm.value=`Stopping…`,lm.value&&qp.chatCancel(lm.value).catch(()=>{}),Om()}function iee(){Qi(()=>{km().catch(e=>{fm.value=e.message||`Chat unavailable`})}),na(()=>{Om()})}var aee=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],oee=L({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return X(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(V(),H(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full border border-border-strong bg-secondary text-primary shadow-[var(--shadow-md)] transition-transform duration-[140ms] hover:-translate-y-px focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":P(om),onClick:i[0]||=e=>n(`toggle`)},[W(`span`,{"aria-hidden":`true`,class:j(r(!e.open))},[G(P(Md),{size:22})],2),W(`span`,{"aria-hidden":`true`,class:j(r(e.open))},[G(P(nf),{size:22})],2)],8,aee))}});function Um(e){return typeof e==`string`?`'${e}'`:new cee().serialize(e)}var see=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Wm=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[see.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Gm(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&Wm[n]?Wm[n]:n+128,s=a<128&&Wm[a]?Wm[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var cee=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Gm(e,t):n===`number`&&r===`number`?e-t:Gm(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort(Gm),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`FloatLine truncated
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(lm.value=n.session_id),n.type===`delta`&&(o+=n.text,mm.value=mm.value?{...mm.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],mm.value=mm.value?{...mm.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);um.value=[...um.value,{from:`assistant`,text:o,tool_calls:a}],mm.value=null,fm.value=`Ready`,await km()}catch(e){let t=e;t.name===`AbortError`&&!c?(mm.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},fm.value=`Stopped`):(mm.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?im(r):void 0,isRetry:i},fm.value=`Error — retry available`)}finally{clearTimeout(l),Dm=null,pm.value=!1}}function Hm(){fm.value=`Stopping…`,lm.value&&qp.chatCancel(lm.value).catch(()=>{}),Om()}function Um(){Qi(()=>{km().catch(e=>{fm.value=e.message||`Chat unavailable`})}),na(()=>{Om()})}var iee=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],aee=L({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return X(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(V(),H(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full border border-border-strong bg-secondary text-primary shadow-[var(--shadow-md)] transition-transform duration-[140ms] hover:-translate-y-px focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":P(om),onClick:i[0]||=e=>n(`toggle`)},[W(`span`,{"aria-hidden":`true`,class:j(r(!e.open))},[G(P(Md),{size:22})],2),W(`span`,{"aria-hidden":`true`,class:j(r(e.open))},[G(P(nf),{size:22})],2)],8,iee))}});function Wm(e){return typeof e==`string`?`'${e}'`:new see().serialize(e)}var oee=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Gm=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[oee.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Km(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&Gm[n]?Gm[n]:n+128,s=a<128&&Gm[a]?Gm[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var see=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Km(e,t):n===`number`&&r===`number`?e-t:Km(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort(Km),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float6Line truncated
`)].join(`
`))}return()=>i.value||r.value||o.value?Zs(t.default({present:o.value})[0],{ref:e=>{let t=Ch(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),Vg=L({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=zh(n.default()),r=e.findIndex(e=>e.type!==os);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?J(t,i.props):t,o=xs({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),Hg=[`area`,`img`,`input`],Ug=L({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&Hg.includes(r)?()=>Zs(r,t):r===`template`?()=>Zs(Vg,t,{default:n.default}):()=>Zs(e.as,t,{default:n.default})}});function Wg(){let e=N();return{primitiveElement:e,currentElement:Y(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:Ch(e))}}var[Gg,Kg]=Xm(`CollapsibleRoot`),qg=L({__name:`CollapsibleRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:open`],setup(e,{expose:t,emit:n}){let r=e,i=Rh(r,`open`,n,{defaultValue:r.defaultOpen,passive:r.open===void 0}),{disabled:a,unmountOnHide:o}=xn(r);return Kg({contentId:``,disabled:a,open:i,unmountOnHide:o,onOpenToggle:()=>{a.value||(i.value=!i.value)}}),t({open:i}),Z(),(e,t)=>(V(),U(P(Ug),{as:e.as,"as-child":r.asChild,"data-state":P(i)?`open`:`closed`,"data-disabled":P(a)?``:void 0},{default:F(()=>[z(e.$slots,`default`,{open:P(i)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),Jg=L({inheritAttrs:!1,__name:`CollapsibleContent`,props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`contentFound`],setup(e,{emit:t}){let n=e,r=t,i=Gg();i.contentId||=Ag(void 0,`reka-collapsible-content`);let a=N(),{forwardRef:o,currentElement:s}=Z(),c=N(0),l=N(0),u=Y(()=>i.open.value),d=N(u.value),f=N();I(()=>[u.value,a.value?.present],async()=>{await er();let e=s.value;if(!e)return;f.value=f.value||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();l.value=t.height,c.value=t.width,d.value||(e.style.transitionDuration=f.value.transitionDuration,e.style.animationName=f.value.animationName)},{immediate:!0});let p=Y(()=>d.value&&i.open.value);return Qi(()=>{requestAnimationFrame(()=>{d.value=!1})}),wh(s,`beforematch`,e=>{requestAnimationFrame(()=>{i.onOpenToggle(),r(`contentFound`)})}),(e,t)=>(V(),U(P(Bg),{ref_key:`presentRef`,ref:a,present:e.forceMount||P(i).open.value,"force-mount":!0},{default:F(({present:t})=>[G(P(Ug),J(e.$attrs,{id:P(i).contentId,ref:P(o),"as-child":n.asChild,as:e.as,hidden:t?void 0:P(i).unmountOnHide.value?``:`until-found`,"data-state":p.value?void 0:P(i).open.value?`open`:`closed`,"data-disabled":P(i).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${l.value}px`,"--reka-collapsible-content-width":`${c.value}px`}}),{default:F(()=>[!P(i).unmountOnHide.value||t?z(e.$slots,`default`,{key:0}):q(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),Yg=L({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;Z();let n=Gg();return(e,r)=>(V(),U(P(Ug),{type:e.as===`button`?`button`:void 0,as:e.as,"as-child":t.asChild,"aria-controls":P(n).contentId,"aria-expanded":P(n).open.value,"data-state":P(n).open.value?`open`:`closed`,"data-disabled":P(n).disabled?.value?``:void 0,disabled:P(n).disabled?.value,onClick:P(n).onOpenToggle},{default:F(()=>[z(e.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}});function Xg({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function Zg({type:e,defaultValue:t,modelValue:n}){return e||Xg({type:e,defaultValue:t,modelValue:n})}function Qg({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function $g(e,t){let n=Y(()=>Zg(e)),r=Rh(e,`modelValue`,t,{defaultValue:Qg(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=Km(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(eh(t,e)){let n=t.findIndex(t=>Km(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:Y(()=>n.value===`single`)}}var[e_,t_]=Xm(`AccordionRoot`),n_=L({__name:`AccordionRoot`,props:{collapsible:{type:Boolean,required:! Line truncated
`))}return()=>i.value||r.value||o.value?Zs(t.default({present:o.value})[0],{ref:e=>{let t=wh(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),Hg=L({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=Bh(n.default()),r=e.findIndex(e=>e.type!==os);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?J(t,i.props):t,o=xs({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),Ug=[`area`,`img`,`input`],Wg=L({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&Ug.includes(r)?()=>Zs(r,t):r===`template`?()=>Zs(Hg,t,{default:n.default}):()=>Zs(e.as,t,{default:n.default})}});function Gg(){let e=N();return{primitiveElement:e,currentElement:Y(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:wh(e))}}var[Kg,qg]=Zm(`CollapsibleRoot`),Jg=L({__name:`CollapsibleRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:open`],setup(e,{expose:t,emit:n}){let r=e,i=zh(r,`open`,n,{defaultValue:r.defaultOpen,passive:r.open===void 0}),{disabled:a,unmountOnHide:o}=xn(r);return qg({contentId:``,disabled:a,open:i,unmountOnHide:o,onOpenToggle:()=>{a.value||(i.value=!i.value)}}),t({open:i}),Z(),(e,t)=>(V(),U(P(Wg),{as:e.as,"as-child":r.asChild,"data-state":P(i)?`open`:`closed`,"data-disabled":P(a)?``:void 0},{default:F(()=>[z(e.$slots,`default`,{open:P(i)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),Yg=L({inheritAttrs:!1,__name:`CollapsibleContent`,props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`contentFound`],setup(e,{emit:t}){let n=e,r=t,i=Kg();i.contentId||=jg(void 0,`reka-collapsible-content`);let a=N(),{forwardRef:o,currentElement:s}=Z(),c=N(0),l=N(0),u=Y(()=>i.open.value),d=N(u.value),f=N();I(()=>[u.value,a.value?.present],async()=>{await er();let e=s.value;if(!e)return;f.value=f.value||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();l.value=t.height,c.value=t.width,d.value||(e.style.transitionDuration=f.value.transitionDuration,e.style.animationName=f.value.animationName)},{immediate:!0});let p=Y(()=>d.value&&i.open.value);return Qi(()=>{requestAnimationFrame(()=>{d.value=!1})}),Th(s,`beforematch`,e=>{requestAnimationFrame(()=>{i.onOpenToggle(),r(`contentFound`)})}),(e,t)=>(V(),U(P(Vg),{ref_key:`presentRef`,ref:a,present:e.forceMount||P(i).open.value,"force-mount":!0},{default:F(({present:t})=>[G(P(Wg),J(e.$attrs,{id:P(i).contentId,ref:P(o),"as-child":n.asChild,as:e.as,hidden:t?void 0:P(i).unmountOnHide.value?``:`until-found`,"data-state":p.value?void 0:P(i).open.value?`open`:`closed`,"data-disabled":P(i).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${l.value}px`,"--reka-collapsible-content-width":`${c.value}px`}}),{default:F(()=>[!P(i).unmountOnHide.value||t?z(e.$slots,`default`,{key:0}):q(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),Xg=L({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;Z();let n=Kg();return(e,r)=>(V(),U(P(Wg),{type:e.as===`button`?`button`:void 0,as:e.as,"as-child":t.asChild,"aria-controls":P(n).contentId,"aria-expanded":P(n).open.value,"data-state":P(n).open.value?`open`:`closed`,"data-disabled":P(n).disabled?.value?``:void 0,disabled:P(n).disabled?.value,onClick:P(n).onOpenToggle},{default:F(()=>[z(e.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}});function Zg({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function Qg({type:e,defaultValue:t,modelValue:n}){return e||Zg({type:e,defaultValue:t,modelValue:n})}function $g({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function e_(e,t){let n=Y(()=>Qg(e)),r=zh(e,`modelValue`,t,{defaultValue:$g(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=qm(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(th(t,e)){let n=t.findIndex(t=>qm(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:Y(()=>n.value===`single`)}}var[t_,n_]=Zm(`AccordionRoot`),r_=L({__name:`AccordionRoot`,props:{collapsible:{type:Boolean,required:! Line truncated
- a positive number
- less than the value passed to \`max\` (or ${wS} if no \`max\` prop is set)
- less than the value passed to \`max\` (or ${TS} if no \`max\` prop is set)
- \`null\` or \`undefined\` if the progress is indeterminate.
Defaulting to \`null\`.`),null)}function kS(e){return DS(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 \`${wS}\`.`),wS)}var AS=L({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:wS},getValueLabel:{type:Function,required:!1,default:(e,t)=>DS(e)?`${Math.round(e/t*wS)}%`: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;Z();let i=Rh(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=Rh(n,`max`,r,{passive:n.max===void 0});I(()=>i.value,async e=>{let t=OS(e,n.max);t!==e&&(await er(),i.value=t)},{immediate:!0}),I(()=>n.max,e=>{let t=kS(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=Y(()=>$m(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return ES({modelValue:i,max:a,progressState:o}),(e,t)=>(V(),U(P(Ug),{"as-child":e.asChild,as:e.as,"aria-valuemax":P(a),"aria-valuemin":0,"aria-valuenow":DS(P(i))?P(i):void 0,"aria-valuetext":e.getValueText?.(P(i),P(a)),"aria-label":e.getValueLabel(P(i),P(a)),role:`progressbar`,"data-state":o.value,"data-value":P(i)??void 0,"data-max":P(a)},{default:F(()=>[z(e.$slots,`default`,{modelValue:P(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),jS=L({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=TS();return Z(),(e,r)=>(V(),U(P(Ug),J(t,{"data-state":P(n).progressState.value,"data-value":P(n).modelValue?.value??void 0,"data-max":P(n).max.value}),{default:F(()=>[z(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),MS=`radio.select`;function NS(e,t,n){Qm(MS,n,{originalEvent:e,value:t})}var PS=L({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=Rh(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=xn(n),{forwardRef:o,currentElement:s}=Z(),c=cg(s),l=dg(),u=Y(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||NS(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(V(),H(B,null,[G(P(Ug),J({id:e.id,ref:P(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":P(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":P(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:P(a),required:e.required,name:e.name},{...P(l),...e.$attrs},{onClick:tu(d,[`stop`])}),{default:F(()=>[z(e.$slots,`default`,{checked:P(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),P(c)&&e.name?(V(),U(P(gv),J({key:0,type:`radio`,tabindex:`-1`,value:P(a),checked:!!P(i),name:e.name,disabled:e.disabled,required:e.required},P(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):q(`v-if`,!0)],64))}}),[FS,IS]=Xm(`RadioGroupRoot`),LS=L({__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}=Z(),o=Rh(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=xn(n),p=rg(f),m=cg(a);return IS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(V(),U(P(Qb),{"as-child":``,orientation:P(l),dir:P(p),loop:P(c)},{default:F(()=>[G(P(Ug),{ref:P(i),role:`radiogroup`,"data-disabled":P(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":P(l),"aria-required":P(d),dir:P(p)},{default:F(()=>[z(e.$slots,`default`,{modelValue:P(o)}),P(m)&&P(u)?(V(),U(P(gv),{key:0,required:P(d),disabled:P(s),value:P(o),name:P(u)},null,8,[`required`,`disabled`,`value`,`name`])):q(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[fee,RS]=Xm(`RadioGroupItem`),zS=L({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:nuLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:NE(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>NE(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=FE(c),u=e+1<n.length?FE(n[e+1]):null;if(l&&u&&IE(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=FE(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>NE(e)),rows:r.map(e=>e.map(e=>NE(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:NE(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:NE(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function FE(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 IE(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var LE={class:`[overflow-wrap:anywhere]`},RE={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},zE={class:`font-mono text-[0.85em]`},BE={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},VE={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},HE={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},UE={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},WE={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},GE={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},KE={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},qE={key:8,class:`mb-2.5 last:mb-0`},JE=L({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=Y(()=>PE(t.text));return(e,t)=>(V(),H(`div`,LE,[(V(!0),H(B,null,R(n.value,(e,t)=>(V(),H(B,{key:t},[e.kind===`pre`?(V(),H(`pre`,RE,[W(`code`,zE,M(e.code),1)])):e.kind===`table`?(V(),H(`table`,BE,[W(`thead`,null,[W(`tr`,null,[(V(!0),H(B,null,R(e.head,(e,t)=>(V(),H(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[G(jE,{inline:e},null,8,[`inline`])]))),128))])]),W(`tbody`,null,[(V(!0),H(B,null,R(e.rows,(e,t)=>(V(),H(`tr`,{key:t},[(V(!0),H(B,null,R(e,(e,t)=>(V(),H(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[G(jE,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(V(),H(`blockquote`,VE,[G(jE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(V(),H(`h1`,HE,[G(jE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(V(),H(`h2`,UE,[G(jE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(V(),H(`h3`,WE,[G(jE,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(V(),H(`ul`,GE,[(V(!0),H(B,null,R(e.items,(e,t)=>(V(),H(`li`,{key:t},[G(jE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(V(),H(`ol`,KE,[(V(!0),H(B,null,R(e.items,(e,t)=>(V(),H(`li`,{key:t},[G(jE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(V(),H(`p`,qE,[G(jE,{inline:e.inline},null,8,[`inline`])])):q(``,!0)],64))),128))]))}}),YE={class:`truncate`},XE=L({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ca(`RouterLink`);return V(),U(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:F(()=>[G(P(dd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),W(`span`,YE,M(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),ZE={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},QE={class:`font-semibold text-foreground`},$E={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},eD=L({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=Y(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=Y(()=>t.tool.parameters||t.tool.Parameters||``),i=Y(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=Y(()=>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?(V(),U(XE,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(V(),H(`div`,ZE,[G(P(tf),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),W(`span`,QE,M(n.value),1),r.value?(V(),H(`code`,$E,M(r.value),1)):q(``,!0),W(`span`,{class:j(P(X)(`text-fg-muted`,i.value&&`text-danger`))},M(a.value),3)]))}}),tD={key:0,class:`mb-2 grid gap-0.5 text-xs`},nD={key:1,class:`mb-2 flex flex-wrap gap-1.5`},rD={key:3,class:`whitespace-pre-wrap`},iD=L({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(V(),H(`div`,{class:j([`flex`,e.assistant?`justify-start`:`justify-end`])},[W(`div`,{class:j(P(X)(`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?(V(),H(`div`,tD,[(V(!0),H(B,null,R(e.tools,(t,n)=>(V(),U(eD,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):q(``,!0),e.media.length?(V(),H(`div`,nD,[(V(!0),H(B,null,R(e.media,(e,t)=>(V(),U(wE,{key:t,attachment:e},null,8,[`attachment`]))),128))])):q(``,!0),e.assistant?(V(),U(JE,{key:2,text:e.text},null,8,[`text`])):(V(),H(`div`,rD,M(e.text),1)),z(t.$slots,`default`)],2)],2))}}),aD={class:`w-full self-center justify-self-center py-6 text-center`},oD={class:`grid gap-2`},sD=[`onClick`],cD=L({__name:`ChatEmptyState`,emits:[`proLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>OM?`${n.slice(0,OM).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var AM=[`title`],jM=L({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>tM(n.event)),a=Y(()=>kM(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=Y(()=>n.event.at?lj(n.event.at):`—`);return(e,t)=>(V(),U(P(TM),{class:j(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:[ru(tu(o,[`prevent`]),[`enter`]),ru(tu(o,[`prevent`]),[`space`])]},{default:F(()=>[G(P($),{class:`font-medium`},{default:F(()=>[K(M(n.event.kind||n.event.type||`event`),1)]),_:1}),G(P($),{class:`font-mono`},{default:F(()=>[K(M(i.value>0?`#${i.value}`:`—`),1)]),_:1}),G(P($),{class:`w-[55%] max-w-0`},{default:F(()=>[W(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},M(a.value.text),9,AM)]),_:1}),G(P($),null,{default:F(()=>[K(M(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),MM=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function NM(e){return(Number(e?.task_id)||0)>0}function PM(e,t){return t===`tasks`?NM(e):t!==`system`||!NM(e)}function FM(e,t){return e.filter(e=>PM(e,t))}function IM(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function LM(e,t){return`${e}:${t??0}`}function RM(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=LM(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 zM={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},BM={class:`max-h-[28rem] overflow-y-auto`},VM=[`aria-expanded`,`aria-label`,`onClick`],HM=[`title`],UM=L({__name:`LiveActivityCard`,setup(e){let t=jD(),{activity:n,streamKind:r,streamState:i}=Xu(fA()),a=N(`all`),o=Y(()=>FM(n.value,a.value)),s=Y(()=>IM(o.value.length,a.value)),c=Zt(new Set),l=Y(()=>RM(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?lj(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(V(),U(P(nj),null,{default:F(()=>[G(P(sj),null,{default:F(()=>[G(P(cj),null,{default:F(()=>[...t[1]||=[K(`Live activity`,-1)]]),_:1}),G(P(rj),{class:`flex items-center gap-2`},{default:F(()=>[G(P(xM),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:P(MM)},null,8,[`modelValue`,`options`]),G(P($A),{variant:P(r)},{default:F(()=>[K(M(P(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),G(P(ij),null,{default:F(()=>[W(`div`,zM,[W(`div`,BM,[G(P(CM),null,{default:F(()=>[G(P(DM),{class:`sticky top-0 z-10 bg-card`},{default:F(()=>[G(P(TM),null,{default:F(()=>[G(P(EM),null,{default:F(()=>[...t[2]||=[K(`Event`,-1)]]),_:1}),G(P(EM),null,{default:F(()=>[...t[3]||=[K(`Task`,-1)]]),_:1}),G(P(EM),null,{default:F(()=>[...t[4]||=[K(`Detail`,-1)]]),_:1}),G(P(EM),null,{default:F(()=>[...t[5]||=[K(`When`,-1)]]),_:1})]),_:1})]),_:1}),G(P(wM),null,{default:F(()=>[o.value.length?q(``,!0):(V(),U(P(TM),{key:0},{default:F(()=>[G(P($),{colspan:`4`},{default:F(()=>[G(P(GA),null,{default:F(()=>[G(P(JA),null,{default:F(()=>[G(P(ZA),null,{default:F(()=>[K(M(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(V(!0),H(B,{key:1},R(l.value,e=>(V(),H(B,{key:e.key},[e.count===1?(V(),U(jM,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(V(),H(B,{key:1},[G(P(TM),{class:j(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:[ru(tu(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),ru(tu(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:F(()=>[G(P($),{class:`font-medium`},{default:F(()=>[W(`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:tu(t=>u(e.key),[`stop`])},[d(e)?(V(),U(P(hd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(V(),U(P(gd),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),K(` `+M(e.label)+` `,1),G(P($A),{variant:`idle`},{default:F(()=>[K(`×`+M(e.count),1)]),_:2},1024)],8,VM)]),_:2},1024),G(P($),{class:`font-mono`},{default:F(()=>[K(M(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),G(P($),{class:`w-[55%] max-w-0`},{default:F(()=>[W(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},M(f(e).text),9,HM)]),_:2},1024),G(P($),null,{default:F(()=>[K(M(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(V(!0),H(B,{key:0},R(e.events,(t,n)=>(V(),U(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 oP(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 sP(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 cP(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 lP(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 uP=N([]),dP=N([]),fP=N(!0),pP=N(null),mP=N(null),hP=N(!1),gP=N(null);async function _P(){try{let e=await qp.eventTypes();fP.value=e.enabled!==!1,uP.value=e.event_types||[],dP.value=e.proposals||[],pP.value=null}catch(e){pP.value=e.message||String(e)}}function vP(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function yP(e){gP.value=null,mP.value=e}function bP(e){let t=OP.value.find(t=>String(t.id)===e.sample_id);yP({mode:`proposal`,id:null,source:e.source,name:``,rule:vP(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function xP(e=``){yP({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function SP(e){yP({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:vP(e.rule),headersText:``,body:``,exampleHeaders:{}})}function CP(){mP.value=null}async function wP(){let e=mP.value;if(e){hP.value=!0;try{if(e.mode===`edit`&&e.id)await qp.eventTypeUpdate(e.id,{name:e.name,rule:lP(e.rule)});else{let t=e.mode===`paste`?aP(e.headersText):e.exampleHeaders;await qp.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:lP(e.rule),example:{headers:t,body:e.body}})}mP.value=null,await _P()}catch(e){gP.value=e.message||String(e)}finally{hP.value=!1}}}var TP=N(null);async function EP(){let e=TP.value;if(TP.value=null,e)try{await qp.eventTypeDelete(e.id),await _P()}catch(e){pP.value=e.message||String(e)}}var DP=100,OP=N([]),kP=N(!0),AP=N(null),jP=N(!0),MP=N(null);async function NP(){try{let e=await qp.captures(DP);kP.value=e.enabled!==!1,OP.value=e.captures||[],AP.value=null}catch(e){AP.value=e.message||String(e)}finally{jP.value=!1}}function PP(e){let t=OP.value.find(t=>t.id===e);return t&&(MP.value=t),!!t}function FP(){OP.value.length&&(MP.value=OP.value[0])}function IP(){pA(`captures`,()=>{NP(),_P()})}var LP=`archie.theme`,RP=`archie.density`,zP=`archie.motion`,BP=`archie.tooltips`;function VP(e,t,n){try{let r=localStorage.getItem(e);return t.includes(r)?r:n}catch{return n}}function HP(e,t){try{localStorage.setItem(e,t)}catch{}}function UP(e){if(e!==`system`)return e;try{return matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}catch{return`dark`}}var WP=Yu(`appearance`,()=>{let e=N(VP(LP,[`system`,`dark`,`light`],`dark`)),t=N(VP(RP,[`comfortable`,`compact`],`comfortable`)),n=N(VP(zP,[`system`,`reduced`],`system`)),r=N(VP(BP,[`on`,`off`],`on`)===`on`),i=!1;function a(){document.documentElement.dataset.theme=UP(e.value)}function o(t){e.value=t,a(),HP(LP,t)}function s(e){t.value=e,document.documentElement.dataset.density=e,HP(RP,e)}function c(e){n.value=e,document.documentElement.dataset.motion=e,HP(zP,e)}function l(e){r.value=e,HP(BP,e?`on`:`off`)}function u(){if(!i){i=!0,a(),document.documentElement.dataset.density=t.value,document.documentElement.dataset.motion=n.value;try{matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{e.value===`system`&&a()})}catch{}}}return{theme:e,density:t,motion:n,tooltipsEnabled:r,initialize:u,setTheme:o,setDensity:s,setMotion:c,setTooltips:l}}),GP=L({__name:`Tooltip`,props:{defaultOpen:{type:Boolean},open:{type:Boolean},delayDuration:{},disableHoverableContent:{type:Boolean},disableClosingTrigger:{type:Boolean},disabled:{type:Boolean},ignoreNonKeyboardFocus:{type:Boolean}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=ug(n,t),{tooltipsEnabled:i}=Xu(WP());return(e,t)=>(V(),U(P(tw),J({"data-slot":`tooltip`},P(r),{disabled:n.disabled||!P(i)}),{default:F(t=>[z(e.$slots,`default`,ve(bs(t)))]),_:3},16,[`disabled`]))}}),KP=L({inheritAttrs:!1,__name:`TooltipContent`,props:{forceMount:{type:Boolean},ariaLabel:{},asChild:{type:Boolean},as:{},side:{},sideOffset:{default:0},align:{},alignOffset:{},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,r=t,i=ug(xw(n,`class`),r);return(e,t)=>(V(),U(P(aw),null,{defau Line truncated
Defaulting to \`null\`.`),null)}function AS(e){return OS(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 \`${TS}\`.`),TS)}var jS=L({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:TS},getValueLabel:{type:Function,required:!1,default:(e,t)=>OS(e)?`${Math.round(e/t*TS)}%`: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;Z();let i=zh(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=zh(n,`max`,r,{passive:n.max===void 0});I(()=>i.value,async e=>{let t=kS(e,n.max);t!==e&&(await er(),i.value=t)},{immediate:!0}),I(()=>n.max,e=>{let t=AS(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=Y(()=>eh(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return DS({modelValue:i,max:a,progressState:o}),(e,t)=>(V(),U(P(Wg),{"as-child":e.asChild,as:e.as,"aria-valuemax":P(a),"aria-valuemin":0,"aria-valuenow":OS(P(i))?P(i):void 0,"aria-valuetext":e.getValueText?.(P(i),P(a)),"aria-label":e.getValueLabel(P(i),P(a)),role:`progressbar`,"data-state":o.value,"data-value":P(i)??void 0,"data-max":P(a)},{default:F(()=>[z(e.$slots,`default`,{modelValue:P(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),MS=L({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=ES();return Z(),(e,r)=>(V(),U(P(Wg),J(t,{"data-state":P(n).progressState.value,"data-value":P(n).modelValue?.value??void 0,"data-max":P(n).max.value}),{default:F(()=>[z(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),NS=`radio.select`;function PS(e,t,n){$m(NS,n,{originalEvent:e,value:t})}var FS=L({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=zh(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=xn(n),{forwardRef:o,currentElement:s}=Z(),c=lg(s),l=fg(),u=Y(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||PS(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(V(),H(B,null,[G(P(Wg),J({id:e.id,ref:P(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":P(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":P(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:P(a),required:e.required,name:e.name},{...P(l),...e.$attrs},{onClick:tu(d,[`stop`])}),{default:F(()=>[z(e.$slots,`default`,{checked:P(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),P(c)&&e.name?(V(),U(P(_v),J({key:0,type:`radio`,tabindex:`-1`,value:P(a),checked:!!P(i),name:e.name,disabled:e.disabled,required:e.required},P(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):q(`v-if`,!0)],64))}}),[IS,LS]=Zm(`RadioGroupRoot`),RS=L({__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}=Z(),o=zh(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=xn(n),p=ig(f),m=lg(a);return LS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(V(),U(P($b),{"as-child":``,orientation:P(l),dir:P(p),loop:P(c)},{default:F(()=>[G(P(Wg),{ref:P(i),role:`radiogroup`,"data-disabled":P(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":P(l),"aria-required":P(d),dir:P(p)},{default:F(()=>[z(e.$slots,`default`,{modelValue:P(o)}),P(m)&&P(u)?(V(),U(P(_v),{key:0,required:P(d),disabled:P(s),value:P(o),name:P(u)},null,8,[`required`,`disabled`,`value`,`name`])):q(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[dee,zS]=Zm(`RadioGroupItem`),BS=L({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:nuLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:PE(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>PE(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=IE(c),u=e+1<n.length?IE(n[e+1]):null;if(l&&u&&LE(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=IE(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>PE(e)),rows:r.map(e=>e.map(e=>PE(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:PE(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:PE(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function IE(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 LE(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var RE={class:`[overflow-wrap:anywhere]`},zE={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},BE={class:`font-mono text-[0.85em]`},VE={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},HE={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},UE={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},WE={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},GE={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},KE={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},qE={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},JE={key:8,class:`mb-2.5 last:mb-0`},YE=L({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=Y(()=>FE(t.text));return(e,t)=>(V(),H(`div`,RE,[(V(!0),H(B,null,R(n.value,(e,t)=>(V(),H(B,{key:t},[e.kind===`pre`?(V(),H(`pre`,zE,[W(`code`,BE,M(e.code),1)])):e.kind===`table`?(V(),H(`table`,VE,[W(`thead`,null,[W(`tr`,null,[(V(!0),H(B,null,R(e.head,(e,t)=>(V(),H(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[G(ME,{inline:e},null,8,[`inline`])]))),128))])]),W(`tbody`,null,[(V(!0),H(B,null,R(e.rows,(e,t)=>(V(),H(`tr`,{key:t},[(V(!0),H(B,null,R(e,(e,t)=>(V(),H(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[G(ME,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(V(),H(`blockquote`,HE,[G(ME,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(V(),H(`h1`,UE,[G(ME,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(V(),H(`h2`,WE,[G(ME,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(V(),H(`h3`,GE,[G(ME,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(V(),H(`ul`,KE,[(V(!0),H(B,null,R(e.items,(e,t)=>(V(),H(`li`,{key:t},[G(ME,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(V(),H(`ol`,qE,[(V(!0),H(B,null,R(e.items,(e,t)=>(V(),H(`li`,{key:t},[G(ME,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(V(),H(`p`,JE,[G(ME,{inline:e.inline},null,8,[`inline`])])):q(``,!0)],64))),128))]))}}),XE={class:`truncate`},ZE=L({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ca(`RouterLink`);return V(),U(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:F(()=>[G(P(dd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),W(`span`,XE,M(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),QE={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},$E={class:`font-semibold text-foreground`},eD={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},tD=L({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=Y(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=Y(()=>t.tool.parameters||t.tool.Parameters||``),i=Y(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=Y(()=>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?(V(),U(ZE,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(V(),H(`div`,QE,[G(P(tf),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),W(`span`,$E,M(n.value),1),r.value?(V(),H(`code`,eD,M(r.value),1)):q(``,!0),W(`span`,{class:j(P(X)(`text-fg-muted`,i.value&&`text-danger`))},M(a.value),3)]))}}),nD={key:0,class:`mb-2 grid gap-0.5 text-xs`},rD={key:1,class:`mb-2 flex flex-wrap gap-1.5`},iD={key:3,class:`whitespace-pre-wrap`},aD=L({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(V(),H(`div`,{class:j([`flex`,e.assistant?`justify-start`:`justify-end`])},[W(`div`,{class:j(P(X)(`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?(V(),H(`div`,nD,[(V(!0),H(B,null,R(e.tools,(t,n)=>(V(),U(tD,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):q(``,!0),e.media.length?(V(),H(`div`,rD,[(V(!0),H(B,null,R(e.media,(e,t)=>(V(),U(TE,{key:t,attachment:e},null,8,[`attachment`]))),128))])):q(``,!0),e.assistant?(V(),U(YE,{key:2,text:e.text},null,8,[`text`])):(V(),H(`div`,iD,M(e.text),1)),z(t.$slots,`default`)],2)],2))}}),oD={class:`w-full self-center justify-self-center py-6 text-center`},sD={class:`grid gap-2`},cD=[`onClick`],lD=L({__name:`ChatEmptyState`,emits:[`proLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>OM?`${n.slice(0,OM).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var AM=[`title`],jM=L({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>tM(n.event)),a=Y(()=>kM(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=Y(()=>n.event.at?lj(n.event.at):`—`);return(e,t)=>(V(),U(P(TM),{class:j(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:[ru(tu(o,[`prevent`]),[`enter`]),ru(tu(o,[`prevent`]),[`space`])]},{default:F(()=>[G(P($),{class:`font-medium`},{default:F(()=>[K(M(n.event.kind||n.event.type||`event`),1)]),_:1}),G(P($),{class:`font-mono`},{default:F(()=>[K(M(i.value>0?`#${i.value}`:`—`),1)]),_:1}),G(P($),{class:`w-[55%] max-w-0`},{default:F(()=>[W(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},M(a.value.text),9,AM)]),_:1}),G(P($),null,{default:F(()=>[K(M(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),MM=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function NM(e){return(Number(e?.task_id)||0)>0}function PM(e,t){return t===`tasks`?NM(e):t!==`system`||!NM(e)}function FM(e,t){return e.filter(e=>PM(e,t))}function IM(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function LM(e,t){return`${e}:${t??0}`}function RM(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=LM(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 zM={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},BM={class:`max-h-[28rem] overflow-y-auto`},VM=[`aria-expanded`,`aria-label`,`onClick`],HM=[`title`],UM=L({__name:`LiveActivityCard`,setup(e){let t=MD(),{activity:n,streamKind:r,streamState:i}=Xu(fA()),a=N(`all`),o=Y(()=>FM(n.value,a.value)),s=Y(()=>IM(o.value.length,a.value)),c=Zt(new Set),l=Y(()=>RM(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?lj(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(V(),U(P(nj),null,{default:F(()=>[G(P(sj),null,{default:F(()=>[G(P(cj),null,{default:F(()=>[...t[1]||=[K(`Live activity`,-1)]]),_:1}),G(P(rj),{class:`flex items-center gap-2`},{default:F(()=>[G(P(xM),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:P(MM)},null,8,[`modelValue`,`options`]),G(P($A),{variant:P(r)},{default:F(()=>[K(M(P(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),G(P(ij),null,{default:F(()=>[W(`div`,zM,[W(`div`,BM,[G(P(CM),null,{default:F(()=>[G(P(DM),{class:`sticky top-0 z-10 bg-card`},{default:F(()=>[G(P(TM),null,{default:F(()=>[G(P(EM),null,{default:F(()=>[...t[2]||=[K(`Event`,-1)]]),_:1}),G(P(EM),null,{default:F(()=>[...t[3]||=[K(`Task`,-1)]]),_:1}),G(P(EM),null,{default:F(()=>[...t[4]||=[K(`Detail`,-1)]]),_:1}),G(P(EM),null,{default:F(()=>[...t[5]||=[K(`When`,-1)]]),_:1})]),_:1})]),_:1}),G(P(wM),null,{default:F(()=>[o.value.length?q(``,!0):(V(),U(P(TM),{key:0},{default:F(()=>[G(P($),{colspan:`4`},{default:F(()=>[G(P(GA),null,{default:F(()=>[G(P(JA),null,{default:F(()=>[G(P(ZA),null,{default:F(()=>[K(M(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(V(!0),H(B,{key:1},R(l.value,e=>(V(),H(B,{key:e.key},[e.count===1?(V(),U(jM,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(V(),H(B,{key:1},[G(P(TM),{class:j(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:[ru(tu(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),ru(tu(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:F(()=>[G(P($),{class:`font-medium`},{default:F(()=>[W(`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:tu(t=>u(e.key),[`stop`])},[d(e)?(V(),U(P(hd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(V(),U(P(gd),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),K(` `+M(e.label)+` `,1),G(P($A),{variant:`idle`},{default:F(()=>[K(`×`+M(e.count),1)]),_:2},1024)],8,VM)]),_:2},1024),G(P($),{class:`font-mono`},{default:F(()=>[K(M(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),G(P($),{class:`w-[55%] max-w-0`},{default:F(()=>[W(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},M(f(e).text),9,HM)]),_:2},1024),G(P($),null,{default:F(()=>[K(M(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(V(!0),H(B,{key:0},R(e.events,(t,n)=>(V(),U(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 oP(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 sP(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 cP(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 lP(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 uP=N([]),dP=N([]),fP=N(!0),pP=N(null),mP=N(null),hP=N(!1),gP=N(null);async function _P(){try{let e=await qp.eventTypes();fP.value=e.enabled!==!1,uP.value=e.event_types||[],dP.value=e.proposals||[],pP.value=null}catch(e){pP.value=e.message||String(e)}}function vP(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function yP(e){gP.value=null,mP.value=e}function bP(e){let t=OP.value.find(t=>String(t.id)===e.sample_id);yP({mode:`proposal`,id:null,source:e.source,name:``,rule:vP(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function xP(e=``){yP({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function SP(e){yP({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:vP(e.rule),headersText:``,body:``,exampleHeaders:{}})}function CP(){mP.value=null}async function wP(){let e=mP.value;if(e){hP.value=!0;try{if(e.mode===`edit`&&e.id)await qp.eventTypeUpdate(e.id,{name:e.name,rule:lP(e.rule)});else{let t=e.mode===`paste`?aP(e.headersText):e.exampleHeaders;await qp.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:lP(e.rule),example:{headers:t,body:e.body}})}mP.value=null,await _P()}catch(e){gP.value=e.message||String(e)}finally{hP.value=!1}}}var TP=N(null);async function EP(){let e=TP.value;if(TP.value=null,e)try{await qp.eventTypeDelete(e.id),await _P()}catch(e){pP.value=e.message||String(e)}}var DP=100,OP=N([]),kP=N(!0),AP=N(null),jP=N(!0),MP=N(null);async function NP(){try{let e=await qp.captures(DP);kP.value=e.enabled!==!1,OP.value=e.captures||[],AP.value=null}catch(e){AP.value=e.message||String(e)}finally{jP.value=!1}}function PP(e){let t=OP.value.find(t=>t.id===e);return t&&(MP.value=t),!!t}function FP(){OP.value.length&&(MP.value=OP.value[0])}function IP(){pA(`captures`,()=>{NP(),_P()})}var LP=`archie.theme`,RP=`archie.density`,zP=`archie.motion`,BP=`archie.tooltips`;function VP(e,t,n){try{let r=localStorage.getItem(e);return t.includes(r)?r:n}catch{return n}}function HP(e,t){try{localStorage.setItem(e,t)}catch{}}function UP(e){if(e!==`system`)return e;try{return matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}catch{return`dark`}}var WP=Yu(`appearance`,()=>{let e=N(VP(LP,[`system`,`dark`,`light`],`dark`)),t=N(VP(RP,[`comfortable`,`compact`],`comfortable`)),n=N(VP(zP,[`system`,`reduced`],`system`)),r=N(VP(BP,[`on`,`off`],`on`)===`on`),i=!1;function a(){document.documentElement.dataset.theme=UP(e.value)}function o(t){e.value=t,a(),HP(LP,t)}function s(e){t.value=e,document.documentElement.dataset.density=e,HP(RP,e)}function c(e){n.value=e,document.documentElement.dataset.motion=e,HP(zP,e)}function l(e){r.value=e,HP(BP,e?`on`:`off`)}function u(){if(!i){i=!0,a(),document.documentElement.dataset.density=t.value,document.documentElement.dataset.motion=n.value;try{matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{e.value===`system`&&a()})}catch{}}}return{theme:e,density:t,motion:n,tooltipsEnabled:r,initialize:u,setTheme:o,setDensity:s,setMotion:c,setTooltips:l}}),GP=L({__name:`Tooltip`,props:{defaultOpen:{type:Boolean},open:{type:Boolean},delayDuration:{},disableHoverableContent:{type:Boolean},disableClosingTrigger:{type:Boolean},disabled:{type:Boolean},ignoreNonKeyboardFocus:{type:Boolean}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=dg(n,t),{tooltipsEnabled:i}=Xu(WP());return(e,t)=>(V(),U(P(nw),J({"data-slot":`tooltip`},P(r),{disabled:n.disabled||!P(i)}),{default:F(t=>[z(e.$slots,`default`,ve(bs(t)))]),_:3},16,[`disabled`]))}}),KP=L({inheritAttrs:!1,__name:`TooltipContent`,props:{forceMount:{type:Boolean},ariaLabel:{},asChild:{type:Boolean},as:{},side:{},sideOffset:{default:0},align:{},alignOffset:{},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,r=t,i=dg(Sw(n,`class`),r);return(e,t)=>(V(),U(P(ow),null,{defau Line truncated
`).replace(`
`,`
@@ -147,6 +147,6 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
`)+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)){d7(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(o7(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=u7(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(o7(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(c7(t.key)&&!o7(t.sep,`newline`)){let e=u7(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]}):o7(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&&!o7(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)){d7(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||o7(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=u7(l7(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=u7(l7(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 m7(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new a7||null,prettyErrors:t}}function h7(e,t={}){let{lineCounter:n,prettyErrors:r}=m7(t),i=new p7(n?.addNewLine),a=new G5(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 s5(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(l5(e,n)),o.warnings.forEach(l5(e,n))),o}function g7(e,t){let n=new Map;for(let e of t)n.set(e.name,[...n.get(e.name)??[],e]);return{edges:e.edges,nodes:e.nodes.map(e=>{let{stage:t,occurrence:r}=e.data,i=t===void 0?void 0:n.get(t)?.[r??0];return i?{...e,data:{...e.data,run:i}}:e})}}var _7=120,v7=280,y7={"agent.run":`Agent`,"command.run":`Run commands`,"repo.prepare":`Prepare worktree`,"repo.commit":`Commit`,"repo.open-pr":`Open pull request`,"gate.repository":`Repository gate`,"gate.diff-size":`Diff size gate`,"gate.diff-rules":`Diff rules gate`,"forge.comment":`Comment`,"forge.close-issue":`Close issue`,"human.approve":`Human approval`,"workflow.call":`Call workflow`,"workflow.handoff":`Hand off`,"workflow.finish":`Finish`,"review.pr":`Review pull request`,"review.start-round":`Start review round`,"review.reply":`Reply to review`};function b7(e){return y7[e]??e}var x7=/\{\{\s*steps\.([A-Za-z0-9_-]+)\.[^}]*\}\}/g;function S7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C7(e,t){let n=e=>typeof t[e]==`string`?t[e]:``;switch(e){case`agent.run`:return[n(`role`)||`builder`,t.read_only?`read-only`:n(`gate`)?`gated: ${n(`gate`)}`:``].filter(Boolean).join(` · `);case`repo.commit`:return[n(`message`),t.push?`push`:``].filter(Boolean).join(` · `);case`workflow.call`:case`workflow.handoff`:return n(`workflow`);case`workflow.finish`:return n(`status`)||`completed`;case`human.approve`:return n(`then`)?`then ${n(`then`)}`:``;case`gate.repository`:return n(`expect`)===`test-failure`?`tests must fail`:t.repair?`repair if red`:``}return``}function w7(e,t){let n=JSON.stringify(e??{})+` `+(typeof t==`string`?`{{ ${t.replace(/^!/,``)} }}`:``);return[...new Set([...n.matchAll(x7)].map(e=>e[1]))]}function T7(e){let t=h7(e).toJS(),n=S7(t)&&Array.isArray(t.steps)?t.steps:[],r=[],i=[],a=new Map,o=[],s=`start`;r.push({id:s,type:`step`,position:{x:0,y:0},data:{kind:`start`,key:`start`,title:`Start`,type:``,detail:`an event or a task starts the run`}});let c=[s],l=1,u=new Map,d=e=>{let t=u.get(e)??0;return u.set(e,t+1),t},f=(e,t,n,i,s,c)=>{let l=S7(e)?e:{},u=typeof l.type==`string`?l.type:``,f=S7(l.settings)?l.settings:{},p=typeof l.id==`string`?l.id:``,m=`step-${t}`;r.push({id:m,type:`step`,position:{x:n,y:i},data:{kind:`step`,key:p||t,title:p||b7(u),type:u,detail:C7(u,f),when:typeof l.when==`string`?l.when:void 0,retry:S7(l.retry)&&typeof l.retry.attempts==`number`?l.retry.attempts:void 0,continues:l.on_failure===`continue`,branch:s,...c??{stage:p||u,occurrence:d(p||u)}}}),p&&a.set(p,m);for(let e of w7(l.settings,l.when))o.push({from:e,to:m});return m},p=(e,t)=>{for(let n of e)i.push({id:`flow-${n}-${t}`,source:n,target:t,kind:`flow`})};for(let[e,t]of n.entries()){if(S7(t)&&S7(t.parallel)){let n=Object.entries(t.parallel),r=typeof t.id==`string`?t.id:`parallel`,i={stage:r,occurrence:d(r)},a=[],o=0;n.forEach(([t,r],s)=>{let u=(s-(n.length-1)/2)*v7,d=c;(Array.isArray(r)?r:[]).forEach((n,r)=>{let a=f(n,`${e+1}-${t}-${Line truncated
`).map((e,t)=>({number:t+1,text:e,tokens:R7(e)}))}var I7=/^(\s*)(-\s+)?/,L7=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function R7(e){let{code:t,comment:n}=z7(e),r=B7(t);return n&&r.push({text:n,kind:`comment`}),r}function z7(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 B7(e){if(!e)return[];let t=[],n=I7.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=L7.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,...V7(i[4]??``)]):[...t,...V7(r)]}function V7(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 H7(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function U7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function W7(e){return typeof e==`string`&&e.trim()!==``}var G7={class:`space-y-1.5`},K7={class:`flex items-center gap-2`},q7={class:`flex items-center gap-2 text-sm`},J7=[`value`],Y7=[`value`],X7={key:0,class:`text-xs text-fg-subtle`},Z7={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`},Q7={"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`},$7={"aria-hidden":`true`,class:`pointer-events-none absolute inset-0 overflow-hidden py-3 pr-3 pl-14 break-words whitespace-pre-wrap`},e9={key:0,class:`text-sm`},t9={class:`cursor-pointer text-fg-subtle`},n9={class:`mt-2 flex flex-wrap gap-1.5`,"aria-label":`Step types`},r9=[`title`],i9={key:0,class:`text-fg-subtle`},a9={key:1,class:`text-sm text-danger`,role:`alert`},o9={class:`flex flex-wrap items-center gap-2 border-t border-border pt-4`},s9={key:0,class:`mr-auto font-mono text-xs text-fg-subtle`},c9=L({__name:`WorkflowEditor`,props:{selected:{required:!0},selectedModifiers:{}},emits:[`update:selected`],setup(e){let t=NA(),n=Y(()=>t.stateFor(`workflow-definitions`)),r=Y(()=>n.value.resource?.value??{definitions:[]}),i=Y(()=>t.shippedWorkflows()),a=no(e,`selected`),o=N(``),s=N(``),c=N(``),{runs:l,watched:u,stages:d,pick:f}=A7(a),p=Y(()=>i.value.definitions.find(e=>e.id===o.value));function m(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=``}I(a,m,{immediate:!0}),I(r,()=>{s.value||m(a.value)});async function h(e){return c.value=``,t.replace(`workflow-definitions`,e)}async function g(){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=jA(n,t)),await h(AA(n,{id:e,yaml:s.value}))&&(a.value=e)}async function _(){a.value&&await h(jA(r.value,a.value))&&(a.value=``,o.value=``,s.value=``)}async function v(){p.value&&await h(AA(r.value,OA(p.value)))}let y=Y(()=>t.stepTypes()),b=Y(()=>M7(s.value,y.value)),x=N(`canvas`),S=Y(()=>F7(s.value)),C=N(0);function w(e){C.value=e.target.scrollTop}return(e,t)=>(V(),H(`form`,{class:`space-y-4`,onSubmit:tu(g,[`prevent`])},[W(`div`,G7,[G(P(rT),{for:`workflow-id`},{default:F(()=>[...t[4]||=[K(`ID`,-1)]]),_:1}),G(P(bk),{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`])]),G(P(sW),{modelValue:x.value,"onUpdate:modelValue":t[3]||=e=>x.value=e,class:`space-y-1.5`},{default:F(()=>[W(`div`,K7,[G(P(lW),null,{default:F(()=>[G(P(uW),{value:`canvas`},{default:F(()=>[...t[5]||=[K(`Canvas`,-1)]]),_:1}),G(P(uW),{value:`yaml`},{default:F(()=>[...t[6]||=[K(`YAML`,-1)]]),_:1})]),_:1}),W(`span`,{class:j([`ml-auto text-xs`,b.value.ok?`text-ok`:`text-danger`]),role:`status`},M(b.value.ok?`✓`:`✕`)+` `+M(P(j7)(b.value)),3)]),G(P(cW),{value:`canvas`,class:`space-y-2`},{default:F(()=>[W(`label`,q7,[t[8]||=W(`span`,{class:`text-muted-foreground`},`Watching`,-1),W(`select`,{value:P(u),class:`h-8 max-w-md min-w-60 rounded-md border border-input bg-background px-2 text-sm`,onChange:t[1]||=e=>P(f)(e.target.value)},[t[7]||=W(`option`,{value:``},`No run, definition only`,-1),(V(!0),H(B,null,R(P(l),e=>(V(),H(`option`,{key:e.id,value:String(e.id)},` #`+M(e.id)+` `+M(e.title||`untitled`)+M(e.status?` · ${e.status}`:``),9,Y7))),128))],40,J7),P(l).length?q(``,!0):(V(),H(`span`,X7,`This workflow has not run yet.`))]),G(O7,{yaml:s.value,stages:P(d)},null,8,[`yaml`,`stages`])]),_:1}),G(P(cW),{value:`yaml`},{default:F(()=>[W(`div`,Z7,[W(`div`,Q7,[W(`div`,{style:pe(`transform:translateY(${-C.value}px)`)},[(V(!0),H(B,null,R(S.value,e=>(V(),H(`div`,{key:e.number,class:`min-h-6 pr-2 text-fg-subtle`},M(e.number),1))),128))],4)]),W(`div`,$7,[W(`div`,{style:pe(`transform:translateY(${-C.value}px)`)},[(V(!0),H(B,null,R(S.value,e=>(V(),H(`div`,{key:e.number,class:`min-h-6`},[(V(!0),H(B,null,R(e.tokens,(e,t)=>(V(),H(`span`,{key:t,class:j(P(P7)(e.kind))},M(e.text),3))),128))]))),128))],4)]),G(P(mT),{id:`workflow-yaml`,"aria-label":`Workflow YAML`,modelValue:s.value,"onUpdate:modelValue":t[2]||=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:w},null,8,[`modelValue`])])]),_:1})]),_:1},8,[`modelValue`]),y.value.length?(V(),H(`details`,e9,[W(`summary`,t9,`Step types (`+M(y.value.length)+`)`,1),W(`ul`,n9,[(V(!0),H(B,null,R(y.value,e=>(V(),H(`li`,{key:e.name,class:`rounded border border-border bg-secondary px-2 py-0.5 font-mono text-xs`,title:e.needs_repository?`Needs a repository`:`Runs without a repositoLine 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=u7(l7(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=u7(l7(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 m7(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new a7||null,prettyErrors:t}}function h7(e,t={}){let{lineCounter:n,prettyErrors:r}=m7(t),i=new p7(n?.addNewLine),a=new G5(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 s5(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(l5(e,n)),o.warnings.forEach(l5(e,n))),o}function g7(e,t){let n=new Map;for(let e of t)n.set(e.name,[...n.get(e.name)??[],e]);return{edges:e.edges,nodes:e.nodes.map(e=>{let{stage:t,occurrence:r}=e.data,i=t===void 0?void 0:n.get(t)?.[r??0];return i?{...e,data:{...e.data,run:i}}:e})}}var _7=120,v7=280,y7={"agent.run":`Agent`,"command.run":`Run commands`,"repo.prepare":`Prepare worktree`,"repo.commit":`Commit`,"repo.open-pr":`Open pull request`,"gate.repository":`Repository gate`,"gate.diff-size":`Diff size gate`,"gate.diff-rules":`Diff rules gate`,"forge.comment":`Comment`,"forge.close-issue":`Close issue`,"human.approve":`Human approval`,"workflow.call":`Call workflow`,"workflow.handoff":`Hand off`,"workflow.finish":`Finish`,"review.pr":`Review pull request`,"review.start-round":`Start review round`,"review.reply":`Reply to review`};function b7(e){return y7[e]??e}var x7=/\{\{\s*steps\.([A-Za-z0-9_-]+)\.[^}]*\}\}/g;function S7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C7(e,t){let n=e=>typeof t[e]==`string`?t[e]:``;switch(e){case`agent.run`:return[n(`role`)||`builder`,t.read_only?`read-only`:n(`gate`)?`gated: ${n(`gate`)}`:``].filter(Boolean).join(` · `);case`repo.commit`:return[n(`message`),t.push?`push`:``].filter(Boolean).join(` · `);case`workflow.call`:case`workflow.handoff`:return n(`workflow`);case`workflow.finish`:return n(`status`)||`completed`;case`human.approve`:return n(`then`)?`then ${n(`then`)}`:``;case`gate.repository`:return n(`expect`)===`test-failure`?`tests must fail`:t.repair?`repair if red`:``}return``}function w7(e,t){let n=JSON.stringify(e??{})+` `+(typeof t==`string`?`{{ ${t.replace(/^!/,``)} }}`:``);return[...new Set([...n.matchAll(x7)].map(e=>e[1]))]}function T7(e){let t=h7(e).toJS(),n=S7(t)&&Array.isArray(t.steps)?t.steps:[],r=[],i=[],a=new Map,o=[],s=`start`;r.push({id:s,type:`step`,position:{x:0,y:0},data:{kind:`start`,key:`start`,title:`Start`,type:``,detail:`an event or a task starts the run`}});let c=[s],l=1,u=new Map,d=e=>{let t=u.get(e)??0;return u.set(e,t+1),t},f=(e,t,n,i,s,c)=>{let l=S7(e)?e:{},u=typeof l.type==`string`?l.type:``,f=S7(l.settings)?l.settings:{},p=typeof l.id==`string`?l.id:``,m=`step-${t}`;r.push({id:m,type:`step`,position:{x:n,y:i},data:{kind:`step`,key:p||t,title:p||b7(u),type:u,detail:C7(u,f),when:typeof l.when==`string`?l.when:void 0,retry:S7(l.retry)&&typeof l.retry.attempts==`number`?l.retry.attempts:void 0,continues:l.on_failure===`continue`,branch:s,...c??{stage:p||u,occurrence:d(p||u)}}}),p&&a.set(p,m);for(let e of w7(l.settings,l.when))o.push({from:e,to:m});return m},p=(e,t)=>{for(let n of e)i.push({id:`flow-${n}-${t}`,source:n,target:t,kind:`flow`})};for(let[e,t]of n.entries()){if(S7(t)&&S7(t.parallel)){let n=Object.entries(t.parallel),r=typeof t.id==`string`?t.id:`parallel`,i={stage:r,occurrence:d(r)},a=[],o=0;n.forEach(([t,r],s)=>{let u=(s-(n.length-1)/2)*v7,d=c;(Array.isArray(r)?r:[]).forEach((n,r)=>{let a=f(n,`${e+1}-${t}-${Line truncated
`).map((e,t)=>({number:t+1,text:e,tokens:z7(e)}))}var L7=/^(\s*)(-\s+)?/,R7=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function z7(e){let{code:t,comment:n}=B7(e),r=V7(t);return n&&r.push({text:n,kind:`comment`}),r}function B7(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 V7(e){if(!e)return[];let t=[],n=L7.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=R7.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,...H7(i[4]??``)]):[...t,...H7(r)]}function H7(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 U7(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function W7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function G7(e){return typeof e==`string`&&e.trim()!==``}var K7={class:`space-y-1.5`},q7={class:`flex items-center gap-2`},J7={class:`flex items-center gap-2 text-sm`},Y7=[`value`],X7=[`value`],Z7={key:0,class:`text-xs text-fg-subtle`},Q7={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`},$7={"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`},e9={"aria-hidden":`true`,class:`pointer-events-none absolute inset-0 overflow-hidden py-3 pr-3 pl-14 break-words whitespace-pre-wrap`},t9={key:0,class:`text-sm`},n9={class:`cursor-pointer text-fg-subtle`},r9={class:`mt-2 flex flex-wrap gap-1.5`,"aria-label":`Step types`},i9=[`title`],a9={key:0,class:`text-fg-subtle`},o9={key:1,class:`text-sm text-danger`,role:`alert`},s9={class:`flex flex-wrap items-center gap-2 border-t border-border pt-4`},c9={key:0,class:`mr-auto font-mono text-xs text-fg-subtle`},l9=L({__name:`WorkflowEditor`,props:{selected:{required:!0},selectedModifiers:{}},emits:[`update:selected`],setup(e){let t=NA(),n=Y(()=>t.stateFor(`workflow-definitions`)),r=Y(()=>n.value.resource?.value??{definitions:[]}),i=Y(()=>t.shippedWorkflows()),a=no(e,`selected`),o=N(``),s=N(``),c=N(``),{runs:l,watched:u,stages:d,pick:f}=A7(a),p=Y(()=>i.value.definitions.find(e=>e.id===o.value));function m(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=``}I(a,m,{immediate:!0}),I(r,()=>{s.value||m(a.value)});async function h(e){return c.value=``,t.replace(`workflow-definitions`,e)}async function g(){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=jA(n,t)),await h(AA(n,{id:e,yaml:s.value}))&&(a.value=e)}async function _(){a.value&&await h(jA(r.value,a.value))&&(a.value=``,o.value=``,s.value=``)}async function v(){p.value&&await h(AA(r.value,OA(p.value)))}let y=Y(()=>t.stepTypes()),b=Y(()=>M7(s.value,y.value)),x=N(`canvas`),S=Y(()=>I7(s.value)),C=N(0);function w(e){C.value=e.target.scrollTop}return(e,t)=>(V(),H(`form`,{class:`space-y-4`,onSubmit:tu(g,[`prevent`])},[W(`div`,K7,[G(P(iT),{for:`workflow-id`},{default:F(()=>[...t[4]||=[K(`ID`,-1)]]),_:1}),G(P(bk),{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`])]),G(P(sW),{modelValue:x.value,"onUpdate:modelValue":t[3]||=e=>x.value=e,class:`space-y-1.5`},{default:F(()=>[W(`div`,q7,[G(P(lW),null,{default:F(()=>[G(P(uW),{value:`canvas`},{default:F(()=>[...t[5]||=[K(`Canvas`,-1)]]),_:1}),G(P(uW),{value:`yaml`},{default:F(()=>[...t[6]||=[K(`YAML`,-1)]]),_:1})]),_:1}),W(`span`,{class:j([`ml-auto text-xs`,b.value.ok?`text-ok`:`text-danger`]),role:`status`},M(b.value.ok?`✓`:`✕`)+` `+M(P(j7)(b.value)),3)]),G(P(cW),{value:`canvas`,class:`space-y-2`},{default:F(()=>[W(`label`,J7,[t[8]||=W(`span`,{class:`text-muted-foreground`},`Watching`,-1),W(`select`,{value:P(u),class:`h-8 max-w-md min-w-60 rounded-md border border-input bg-background px-2 text-sm`,onChange:t[1]||=e=>P(f)(e.target.value)},[t[7]||=W(`option`,{value:``},`No run, definition only`,-1),(V(!0),H(B,null,R(P(l),e=>(V(),H(`option`,{key:e.id,value:String(e.id)},` #`+M(e.id)+` `+M(e.title||`untitled`)+M(e.status?` · ${e.status}`:``),9,X7))),128))],40,Y7),P(l).length?q(``,!0):(V(),H(`span`,Z7,`This workflow has not run yet.`))]),G(O7,{yaml:s.value,stages:P(d)},null,8,[`yaml`,`stages`])]),_:1}),G(P(cW),{value:`yaml`},{default:F(()=>[W(`div`,Q7,[W(`div`,$7,[W(`div`,{style:pe(`transform:translateY(${-C.value}px)`)},[(V(!0),H(B,null,R(S.value,e=>(V(),H(`div`,{key:e.number,class:`min-h-6 pr-2 text-fg-subtle`},M(e.number),1))),128))],4)]),W(`div`,e9,[W(`div`,{style:pe(`transform:translateY(${-C.value}px)`)},[(V(!0),H(B,null,R(S.value,e=>(V(),H(`div`,{key:e.number,class:`min-h-6`},[(V(!0),H(B,null,R(e.tokens,(e,t)=>(V(),H(`span`,{key:t,class:j(P(F7)(e.kind))},M(e.text),3))),128))]))),128))],4)]),G(P(hT),{id:`workflow-yaml`,"aria-label":`Workflow YAML`,modelValue:s.value,"onUpdate:modelValue":t[2]||=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:w},null,8,[`modelValue`])])]),_:1})]),_:1},8,[`modelValue`]),y.value.length?(V(),H(`details`,t9,[W(`summary`,n9,`Step types (`+M(y.value.length)+`)`,1),W(`ul`,r9,[(V(!0),H(B,null,R(y.value,e=>(V(),H(`li`,{key:e.name,class:`rounded border border-border bg-secondary px-2 py-0.5 font-mono text-xs`,title:e.needs_repository?`Needs a repository`:`Runs without a repositoLine truncated
+52
View File
@@ -11,10 +11,23 @@ import { parseDocument } from "yaml";
* server's own reason.
*/
/** A JSON Schema node, as the control plane derives it from Go types. */
export interface SettingsSchema {
type?: string;
title?: string;
description?: string;
enum?: string[];
properties?: Record<string, SettingsSchema>;
items?: SettingsSchema;
additionalProperties?: SettingsSchema;
}
/** One registered step type, as the control-plane catalog serves it. */
export interface StepTypeInfo {
name: string;
needs_repository: boolean;
/** Absent for a step that takes no settings. */
settings?: SettingsSchema;
}
/** One chip in the read-only Steps preview. */
@@ -104,6 +117,45 @@ function checkStepType(
if (known.size && !info) return `${where}: unknown step type "${type}"`;
if (info?.needs_repository && repository !== "required")
return `${where}: "${type}" needs a repository, but the workflow's repository is ${repository}`;
if (!info || step.settings === undefined || step.settings === null) return "";
if (!info.settings) return `${where}: "${type}" takes no settings`;
return settingsProblem(step.settings, info.settings, `${where} settings`);
}
/** The first way a settings value breaks its schema, or "". A string holding a
* {{ reference }} is resolved at run time, so it is not held to an enum. */
export function settingsProblem(value: unknown, schema: SettingsSchema, path: string): string {
const actual = Array.isArray(value) ? "array" : value === null ? "null" : typeof value;
switch (schema.type) {
case "object": {
if (!isMapping(value)) return `${path} must be a mapping`;
for (const [key, child] of Object.entries(value)) {
const childSchema = schema.properties?.[key] ?? schema.additionalProperties;
if (!childSchema) return `${path}: unknown setting "${key}"`;
const problem = settingsProblem(child, childSchema, `${path}.${key}`);
if (problem) return problem;
}
return "";
}
case "array": {
if (!Array.isArray(value)) return `${path} must be a list`;
for (const [i, item] of value.entries()) {
const problem = schema.items ? settingsProblem(item, schema.items, `${path}[${i}]`) : "";
if (problem) return problem;
}
return "";
}
case "string":
if (actual !== "string") return `${path} must be text`;
if (schema.enum && !schema.enum.includes(value as string) && !(value as string).includes("{{"))
return `${path} must be one of ${schema.enum.join(", ")}`;
return "";
case "boolean":
return actual === "boolean" ? "" : `${path} must be true or false`;
case "integer":
case "number":
return actual === "number" ? "" : `${path} must be a number`;
}
return "";
}