Compare commits

...
2 Commits
Author SHA1 Message Date
sam 4944ec8473 chore(release): v1.48.1
deploy / gate (push) Failing after 3m28s
deploy / archied-image (push) Skipped
deploy / agent-image (push) Skipped
deploy / dist-zip (push) Skipped
2026-10-07 01:00:30 +11:00
sam 204b65a0e3 fix(controlplane): update-settings selects a release channel; services run only the installed update scripts 2026-10-07 01:00:28 +11:00
10 changed files with 103 additions and 75 deletions

No files matched your search

+6
View File
@@ -5,6 +5,12 @@ release's per-component sections are labelled beneath its heading.
## [Unreleased] ## [Unreleased]
## [1.48.1] - 2026-10-07
### archied
- **Settings → Status → Updates** now chooses only the release channel (stable, prereleases, or a pinned version). Update checks and installs always run the `archie-update-*` scripts installed beside the binaries; the dashboard can no longer set the command that runs.
## [1.48.0] - 2026-10-07 ## [1.48.0] - 2026-10-07
### archied ### archied
+3 -3
View File
@@ -98,9 +98,9 @@ path. `--from-source` (or `ARCHIE_UPDATE_SOURCE_BUILD=1`) explicitly clones and
builds the selected release instead. builds the selected release instead.
The update check command accepts `--channel stable` (default), `--channel next` The update check command accepts `--channel stable` (default), `--channel next`
(includes prereleases), or `--channel exact-pin --pin 1.2.3`. Both commands are (includes prereleases), or `--channel exact-pin --pin 1.2.3`. The services run
edited under Settings → Status → Updates, and default to the scripts installed only the scripts installed beside their binaries; Settings → Status → Updates
beside the binaries. chooses the channel they select from.
The notification destination remains separate from the release channel. The notification destination remains separate from the release channel.
For scheduled, unattended runs, `archie-update-install --auto` discovers the For scheduled, unattended runs, `archie-update-install --auto` discovers the
+2
View File
@@ -66,6 +66,7 @@
"/news/archie/1.47.2/": "/news/1.47.2/", "/news/archie/1.47.2/": "/news/1.47.2/",
"/news/archie/1.47.3/": "/news/1.47.3/", "/news/archie/1.47.3/": "/news/1.47.3/",
"/news/archie/1.48.0/": "/news/1.48.0/", "/news/archie/1.48.0/": "/news/1.48.0/",
"/news/archie/1.48.1/": "/news/1.48.1/",
"/news/archie/1.5.0/": "/news/1.5.0/", "/news/archie/1.5.0/": "/news/1.5.0/",
"/news/archie/1.6.0/": "/news/1.6.0/", "/news/archie/1.6.0/": "/news/1.6.0/",
"/news/archie/1.7.0/": "/news/1.7.0/", "/news/archie/1.7.0/": "/news/1.7.0/",
@@ -149,6 +150,7 @@
"/news/archied/1.47.2/": "/news/1.47.2/", "/news/archied/1.47.2/": "/news/1.47.2/",
"/news/archied/1.47.3/": "/news/1.47.3/", "/news/archied/1.47.3/": "/news/1.47.3/",
"/news/archied/1.48.0/": "/news/1.48.0/", "/news/archied/1.48.0/": "/news/1.48.0/",
"/news/archied/1.48.1/": "/news/1.48.1/",
"/news/archied/1.5.0/": "/news/1.5.0/", "/news/archied/1.5.0/": "/news/1.5.0/",
"/news/archied/1.6.0/": "/news/1.6.0/", "/news/archied/1.6.0/": "/news/1.6.0/",
"/news/archied/1.7.0/": "/news/1.7.0/", "/news/archied/1.7.0/": "/news/1.7.0/",
+5
View File
@@ -1,4 +1,9 @@
[ [
{
"version": "1.48.1",
"date": "2026-10-07",
"body": "### archied\n\n- **Settings → Status → Updates** now chooses only the release channel (stable, prereleases, or a pinned version). Update checks and installs always run the `archie-update-*` scripts installed beside the binaries; the dashboard can no longer set the command that runs."
},
{ {
"version": "1.48.0", "version": "1.48.0",
"date": "2026-10-07", "date": "2026-10-07",
@@ -2,8 +2,6 @@ package controlplane
import ( import (
"fmt" "fmt"
"os"
"path/filepath"
"strings" "strings"
"time" "time"
@@ -63,8 +61,8 @@ func operationalDefinitions() []Definition {
{Kind: ExtensionSettingsKind, Title: "Extension settings", ApplyMode: "live", Document: controlplanerpc.ExtensionSettings{}, Seed: func(config.Config) any { return controlplanerpc.ExtensionSettings{} }, Validate: validateExtensions}, {Kind: ExtensionSettingsKind, Title: "Extension settings", ApplyMode: "live", Document: controlplanerpc.ExtensionSettings{}, Seed: func(config.Config) any { return controlplanerpc.ExtensionSettings{} }, Validate: validateExtensions},
// Live: the container pool reads these on every acquire and the dispatcher // Live: the container pool reads these on every acquire and the dispatcher
// is resized on publish. // is resized on publish.
// Live: every check and install reads the commands afresh. // Live: every check and install reads the channel afresh.
{Kind: UpdateSettingsKind, Title: "Update settings", ApplyMode: "live", Document: releaseupdate.Commands{}, Seed: seedUpdateCommands, Validate: validateUpdateCommands}, {Kind: UpdateSettingsKind, Title: "Update settings", ApplyMode: "live", Document: controlplanerpc.UpdateSettings{}, Seed: func(config.Config) any { return controlplanerpc.UpdateSettings{Channel: "stable"} }, Validate: validateUpdateSettings},
{Kind: ContainerRuntimePoliciesKind, Title: "Container runtime policies", ApplyMode: "live", Document: containerRuntimePolicies{}, Seed: seedContainerPolicies, Validate: validateContainers, Normalize: normalizeContainerPolicies}, {Kind: ContainerRuntimePoliciesKind, Title: "Container runtime policies", ApplyMode: "live", Document: containerRuntimePolicies{}, Seed: seedContainerPolicies, Validate: validateContainers, Normalize: normalizeContainerPolicies},
} }
} }
@@ -126,38 +124,9 @@ func validateScheduling(input []byte) error {
}) })
} }
// seedUpdateCommands points at the update scripts a release installs beside // validateUpdateSettings refuses a channel the update scripts cannot select.
// its binaries, so a zip install can update itself with nothing configured. func validateUpdateSettings(input []byte) error {
func seedUpdateCommands(config.Config) any { return validateAs(input, func(doc controlplanerpc.UpdateSettings) error {
var commands releaseupdate.Commands return releaseupdate.ValidateChannel(doc.Channel, doc.Pin)
exe, err := os.Executable()
if err != nil {
return commands
}
script := func(name string) []string {
path := filepath.Join(filepath.Dir(exe), name)
if info, err := os.Stat(path); err != nil || info.Mode()&0o111 == 0 {
return nil
}
return []string{path}
}
commands.Check = script("archie-update-check")
commands.Install = script("archie-update-install")
return commands
}
// validateUpdateCommands refuses a command with a blank program, and an
// install command without a check to approve its release.
func validateUpdateCommands(input []byte) error {
return validateAs(input, func(doc releaseupdate.Commands) error {
for name, command := range map[string][]string{"check_command": doc.Check, "install_command": doc.Install} {
if len(command) != 0 && strings.TrimSpace(command[0]) == "" {
return fmt.Errorf("%s needs a program", name)
}
}
if len(doc.Install) != 0 && len(doc.Check) == 0 {
return fmt.Errorf("install_command needs a check_command")
}
return nil
}) })
} }
@@ -109,9 +109,15 @@ func (d *ChannelDuration) UnmarshalJSON(data []byte) error {
return nil return nil
} }
// UpdateSettingsKind holds the commands that check for and install releases. // UpdateSettingsKind holds which releases the update scripts select.
const UpdateSettingsKind = "update-settings" const UpdateSettingsKind = "update-settings"
// UpdateSettings is the update-settings document.
type UpdateSettings struct {
Channel string `json:"channel" title:"Release channel" doc:"stable, next (includes prereleases) or exact-pin."`
Pin string `json:"pin" title:"Pinned version" doc:"The version exact-pin installs."`
}
// UpdateService runs the stored update commands, reading them on every call. // UpdateService runs the stored update commands, reading them on every call.
// statePath keeps each recipient's deferrals; healthURL reaches the installer. // statePath keeps each recipient's deferrals; healthURL reaches the installer.
func UpdateService(reader ResourceReader, statePath, healthURL string) *releaseupdate.Service { func UpdateService(reader ResourceReader, statePath, healthURL string) *releaseupdate.Service {
@@ -119,14 +125,16 @@ func UpdateService(reader ResourceReader, statePath, healthURL string) *releaseu
return &releaseupdate.Service{Catalog: commands, Installer: commands, StatePath: statePath, InstallType: installtype.Type()} return &releaseupdate.Service{Catalog: commands, Installer: commands, StatePath: statePath, InstallType: installtype.Type()}
} }
// updateCommands reads the update-settings resource. An unstored kind is no // updateCommands reads the update-settings resource. An unstored kind is the
// commands. // stable channel.
func updateCommands(reader ResourceReader) func(context.Context) (releaseupdate.Commands, error) { func updateCommands(reader ResourceReader) func(context.Context) (releaseupdate.Commands, error) {
return func(ctx context.Context) (releaseupdate.Commands, error) { return func(ctx context.Context) (releaseupdate.Commands, error) {
var commands releaseupdate.Commands settings := UpdateSettings{Channel: "stable"}
_, _, err := reader.Query(ctx, UpdateSettingsKind, func(value []byte) error { if _, _, err := reader.Query(ctx, UpdateSettingsKind, func(value []byte) error {
return json.Unmarshal(value, &commands) return json.Unmarshal(value, &settings)
}) }); err != nil {
return commands, err return releaseupdate.Commands{}, err
}
return releaseupdate.ScriptCommands(settings.Channel, settings.Pin), nil
} }
} }
+14 -5
View File
@@ -8,19 +8,28 @@ import (
"golang.org/x/mod/semver" "golang.org/x/mod/semver"
) )
// ValidateChannel refuses an unknown channel, and an exact pin that is not a
// semantic version.
func ValidateChannel(channel, pin string) error {
if channel != "stable" && channel != "next" && channel != "exact-pin" {
return fmt.Errorf("unknown release channel %q", channel)
}
if channel == "exact-pin" && !semver.IsValid("v"+strings.TrimPrefix(pin, "v")) {
return fmt.Errorf("exact-pin requires a semantic version")
}
return nil
}
// SelectRelease compares release versions, never git-describe strings. Exact // SelectRelease compares release versions, never git-describe strings. Exact
// pins still have to exist in the catalog; a pin cannot invent a release. // pins still have to exist in the catalog; a pin cannot invent a release.
func SelectRelease(tags []string, channel, pin string) (string, error) { func SelectRelease(tags []string, channel, pin string) (string, error) {
if channel == "" { if channel == "" {
channel = "stable" channel = "stable"
} }
if channel != "stable" && channel != "next" && channel != "exact-pin" { if err := ValidateChannel(channel, pin); err != nil {
return "", fmt.Errorf("unknown release channel %q", channel) return "", err
} }
pin = strings.TrimPrefix(pin, "v") pin = strings.TrimPrefix(pin, "v")
if channel == "exact-pin" && !semver.IsValid("v"+pin) {
return "", fmt.Errorf("exact-pin requires a semantic version")
}
fullVersion := regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+([+-].*)?$`) fullVersion := regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+([+-].*)?$`)
newest := "" newest := ""
for _, tag := range tags { for _, tag := range tags {
+32 -4
View File
@@ -7,7 +7,9 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"os"
"os/exec" "os/exec"
"path/filepath"
"strconv" "strconv"
"strings" "strings"
) )
@@ -22,6 +24,7 @@ const updateResultSentinel = "ARCHIE_UPDATE_RESULT "
// administrator-owned adapter. // administrator-owned adapter.
type CommandCatalog struct { type CommandCatalog struct {
Command []string Command []string
Env []string
} }
func (c CommandCatalog) Check(ctx context.Context) (Snapshot, error) { func (c CommandCatalog) Check(ctx context.Context) (Snapshot, error) {
@@ -29,6 +32,7 @@ func (c CommandCatalog) Check(ctx context.Context) (Snapshot, error) {
return Snapshot{}, fmt.Errorf("update check command is empty") return Snapshot{}, fmt.Errorf("update check command is empty")
} }
cmd := exec.CommandContext(ctx, c.Command[0], c.Command[1:]...) cmd := exec.CommandContext(ctx, c.Command[0], c.Command[1:]...)
cmd.Env = append(cmd.Environ(), c.Env...)
output, err := cmd.Output() output, err := cmd.Output()
if err != nil { if err != nil {
return Snapshot{}, fmt.Errorf("run update check: %w", err) return Snapshot{}, fmt.Errorf("run update check: %w", err)
@@ -133,10 +137,34 @@ func componentVersions(snapshot Snapshot) map[string]Component {
// ErrNotConfigured is returned when the step's command is unset. // ErrNotConfigured is returned when the step's command is unset.
var ErrNotConfigured = errors.New("updates are not configured") var ErrNotConfigured = errors.New("updates are not configured")
// Commands is the argv pair a deployment runs to check for and install updates. // Commands is what a deployment runs to check for and install updates. Env
// is added to the check's environment.
type Commands struct { type Commands struct {
Check []string `json:"check_command" title:"Check command" doc:"Prints the available releases as JSON."` Check []string
Install []string `json:"install_command" title:"Install command" doc:"Installs an approved release."` Install []string
Env []string
}
// ScriptCommands runs the update scripts a release installs beside this
// binary, selecting releases from channel. Only these scripts ever run, so a
// setting cannot name an arbitrary program. A missing script is unset.
func ScriptCommands(channel, pin string) Commands {
exe, err := os.Executable()
if err != nil {
return Commands{}
}
script := func(name string) []string {
path := filepath.Join(filepath.Dir(exe), name)
if info, err := os.Stat(path); err != nil || info.Mode()&0o111 == 0 {
return nil
}
return []string{path}
}
return Commands{
Check: script("archie-update-check"),
Install: script("archie-update-install"),
Env: []string{"ARCHIE_UPDATE_RELEASE_CHANNEL=" + channel, "ARCHIE_UPDATE_PIN=" + pin},
}
} }
// SettingsCommands is both Catalog and Installer. It loads Commands on every // SettingsCommands is both Catalog and Installer. It loads Commands on every
@@ -154,7 +182,7 @@ func (s SettingsCommands) Check(ctx context.Context) (Snapshot, error) {
if len(commands.Check) == 0 { if len(commands.Check) == 0 {
return Snapshot{}, ErrNotConfigured return Snapshot{}, ErrNotConfigured
} }
return CommandCatalog{Command: commands.Check}.Check(ctx) return CommandCatalog{Command: commands.Check, Env: commands.Env}.Check(ctx)
} }
func (s SettingsCommands) Install(ctx context.Context, snapshot Snapshot, meta InstallMeta, progress func(string)) (Result, error) { func (s SettingsCommands) Install(ctx context.Context, snapshot Snapshot, meta InstallMeta, progress func(string)) (Result, error) {
+1 -1
View File
@@ -18,7 +18,7 @@ Defaulting to \`null\`.`),null)}function fS(e){return uS(e)&&!Number.isNaN(e)&&e
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=HT(c),u=e+1<n.length?HT(n[e+1]):null;if(l&&u&&Ote(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=HT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>VT(e)),rows:r.map(e=>e.map(e=>VT(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:VT(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:VT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(` `)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=HT(c),u=e+1<n.length?HT(n[e+1]):null;if(l&&u&&Ote(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=HT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>VT(e)),rows:r.map(e=>e.map(e=>VT(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:VT(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:VT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function HT(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 Ote(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var kte={class:`[overflow-wrap:anywhere]`},Ate={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},jte={class:`font-mono text-[0.85em]`},Mte={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},Nte={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},Pte={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},Fte={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},Ite={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Lte={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Rte={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},zte={key:8,class:`mb-2.5 last:mb-0`},Bte=I({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=J(()=>Dte(t.text));return(e,t)=>(B(),V(`div`,kte,[(B(!0),V(z,null,L(n.value,(e,t)=>(B(),V(z,{key:t},[e.kind===`pre`?(B(),V(`pre`,Ate,[U(`code`,jte,j(e.code),1)])):e.kind===`table`?(B(),V(`table`,Mte,[U(`thead`,null,[U(`tr`,null,[(B(!0),V(z,null,L(e.head,(e,t)=>(B(),V(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[W(BT,{inline:e},null,8,[`inline`])]))),128))])]),U(`tbody`,null,[(B(!0),V(z,null,L(e.rows,(e,t)=>(B(),V(`tr`,{key:t},[(B(!0),V(z,null,L(e,(e,t)=>(B(),V(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[W(BT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(B(),V(`blockquote`,Nte,[W(BT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(B(),V(`h1`,Pte,[W(BT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(B(),V(`h2`,Fte,[W(BT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(B(),V(`h3`,Ite,[W(BT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(B(),V(`ul`,Lte,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(BT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(B(),V(`ol`,Rte,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(BT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(B(),V(`p`,zte,[W(BT,{inline:e.inline},null,8,[`inline`])])):K(``,!0)],64))),128))]))}}),Vte={class:`truncate`},Hte=I({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=Qi(`RouterLink`);return B(),H(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:P(()=>[W(N(Gu),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),U(`span`,Vte,j(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),Ute={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},Wte={class:`font-semibold text-foreground`},Gte={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},Kte=I({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=J(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=J(()=>t.tool.parameters||t.tool.Parameters||``),i=J(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=J(()=>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?(B(),H(Hte,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(B(),V(`div`,Ute,[W(N(Kd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),U(`span`,Wte,j(n.value),1),r.value?(B(),V(`code`,Gte,j(r.value),1)):K(``,!0),U(`span`,{class:A(N(Y)(`text-fg-muted`,i.value&&`text-danger`))},j(a.value),3)]))}}),qte={key:0,class:`mb-2 grid gap-0.5 text-xs`},Jte={key:1,class:`mb-2 flex flex-wrap gap-1.5`},Yte={key:3,class:`whitespace-pre-wrap`},UT=I({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(B(),V(`div`,{class:A([`flex`,e.assistant?`justify-start`:`justify-end`])},[U(`div`,{class:A(N(Y)(`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?(B(),V(`div`,qte,[(B(!0),V(z,null,L(e.tools,(t,n)=>(B(),H(Kte,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):K(``,!0),e.media.length?(B(),V(`div`,Jte,[(B(!0),V(z,null,L(e.media,(e,t)=>(B(),H(yte,{key:t,attachment:e},null,8,[`attachment`]))),128))])):K(``,!0),e.assistant?(B(),H(Bte,{key:2,text:e.text},null,8,[`text`])):(B(),V(`div`,Yte,j(e.text),1)),R(t.$slots,`default`)],2)],2))}}),Xte={class:`w-full self-center justify-self-center py-6 text-center`},Zte={class:`grid gap-2`},Qte=[`onCLine truncated `)}),t}function HT(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 Ote(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var kte={class:`[overflow-wrap:anywhere]`},Ate={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},jte={class:`font-mono text-[0.85em]`},Mte={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},Nte={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},Pte={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},Fte={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},Ite={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Lte={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Rte={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},zte={key:8,class:`mb-2.5 last:mb-0`},Bte=I({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=J(()=>Dte(t.text));return(e,t)=>(B(),V(`div`,kte,[(B(!0),V(z,null,L(n.value,(e,t)=>(B(),V(z,{key:t},[e.kind===`pre`?(B(),V(`pre`,Ate,[U(`code`,jte,j(e.code),1)])):e.kind===`table`?(B(),V(`table`,Mte,[U(`thead`,null,[U(`tr`,null,[(B(!0),V(z,null,L(e.head,(e,t)=>(B(),V(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[W(BT,{inline:e},null,8,[`inline`])]))),128))])]),U(`tbody`,null,[(B(!0),V(z,null,L(e.rows,(e,t)=>(B(),V(`tr`,{key:t},[(B(!0),V(z,null,L(e,(e,t)=>(B(),V(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[W(BT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(B(),V(`blockquote`,Nte,[W(BT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(B(),V(`h1`,Pte,[W(BT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(B(),V(`h2`,Fte,[W(BT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(B(),V(`h3`,Ite,[W(BT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(B(),V(`ul`,Lte,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(BT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(B(),V(`ol`,Rte,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(BT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(B(),V(`p`,zte,[W(BT,{inline:e.inline},null,8,[`inline`])])):K(``,!0)],64))),128))]))}}),Vte={class:`truncate`},Hte=I({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=Qi(`RouterLink`);return B(),H(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:P(()=>[W(N(Gu),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),U(`span`,Vte,j(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),Ute={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},Wte={class:`font-semibold text-foreground`},Gte={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},Kte=I({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=J(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=J(()=>t.tool.parameters||t.tool.Parameters||``),i=J(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=J(()=>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?(B(),H(Hte,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(B(),V(`div`,Ute,[W(N(Kd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),U(`span`,Wte,j(n.value),1),r.value?(B(),V(`code`,Gte,j(r.value),1)):K(``,!0),U(`span`,{class:A(N(Y)(`text-fg-muted`,i.value&&`text-danger`))},j(a.value),3)]))}}),qte={key:0,class:`mb-2 grid gap-0.5 text-xs`},Jte={key:1,class:`mb-2 flex flex-wrap gap-1.5`},Yte={key:3,class:`whitespace-pre-wrap`},UT=I({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(B(),V(`div`,{class:A([`flex`,e.assistant?`justify-start`:`justify-end`])},[U(`div`,{class:A(N(Y)(`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?(B(),V(`div`,qte,[(B(!0),V(z,null,L(e.tools,(t,n)=>(B(),H(Kte,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):K(``,!0),e.media.length?(B(),V(`div`,Jte,[(B(!0),V(z,null,L(e.media,(e,t)=>(B(),H(yte,{key:t,attachment:e},null,8,[`attachment`]))),128))])):K(``,!0),e.assistant?(B(),H(Bte,{key:2,text:e.text},null,8,[`text`])):(B(),V(`div`,Yte,j(e.text),1)),R(t.$slots,`default`)],2)],2))}}),Xte={class:`w-full self-center justify-self-center py-6 text-center`},Zte={class:`grid gap-2`},Qte=[`onCLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>jA?`${n.slice(0,jA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var NA=[`title`],PA=I({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=J(()=>iA(n.event)),a=J(()=>MA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=J(()=>n.event.at?fk(n.event.at):`—`);return(e,t)=>(B(),H(N(OA),{class:A(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:[Ll(Il(o,[`prevent`]),[`enter`]),Ll(Il(o,[`prevent`]),[`space`])]},{default:P(()=>[W(N($),{class:`font-medium`},{default:P(()=>[G(j(n.event.kind||n.event.type||`event`),1)]),_:1}),W(N($),{class:`font-mono`},{default:P(()=>[G(j(i.value>0?`#${i.value}`:`—`),1)]),_:1}),W(N($),{class:`w-[55%] max-w-0`},{default:P(()=>[U(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},j(a.value.text),9,NA)]),_:1}),W(N($),null,{default:P(()=>[G(j(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),FA=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function IA(e){return(Number(e?.task_id)||0)>0}function LA(e,t){return t===`tasks`?IA(e):t!==`system`||!IA(e)}function RA(e,t){return e.filter(e=>LA(e,t))}function zA(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function BA(e,t){return`${e}:${t??0}`}function VA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=BA(MA(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 HA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},UA={class:`max-h-[28rem] overflow-y-auto`},WA=[`aria-expanded`,`aria-label`,`onClick`],GA=[`title`],KA=I({__name:`LiveActivityCard`,setup(e){let t=iE(),{activity:n,streamKind:r,streamState:i}=Au(mO()),a=M(`all`),o=J(()=>RA(n.value,a.value)),s=J(()=>zA(o.value.length,a.value)),c=Jt(new Set),l=J(()=>VA(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 MA(e.representative)}function p(e){return e.representative.at?fk(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(B(),H(N(ak),null,{default:P(()=>[W(N(uk),null,{default:P(()=>[W(N(dk),null,{default:P(()=>[...t[1]||=[G(`Live activity`,-1)]]),_:1}),W(N(ok),{class:`flex items-center gap-2`},{default:P(()=>[W(N(wA),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:N(FA)},null,8,[`modelValue`,`options`]),W(N(nk),{variant:N(r)},{default:P(()=>[G(j(N(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),W(N(sk),null,{default:P(()=>[U(`div`,HA,[U(`div`,UA,[W(N(EA),null,{default:P(()=>[W(N(AA),{class:`sticky top-0 z-10 bg-card`},{default:P(()=>[W(N(OA),null,{default:P(()=>[W(N(kA),null,{default:P(()=>[...t[2]||=[G(`Event`,-1)]]),_:1}),W(N(kA),null,{default:P(()=>[...t[3]||=[G(`Task`,-1)]]),_:1}),W(N(kA),null,{default:P(()=>[...t[4]||=[G(`Detail`,-1)]]),_:1}),W(N(kA),null,{default:P(()=>[...t[5]||=[G(`When`,-1)]]),_:1})]),_:1})]),_:1}),W(N(DA),null,{default:P(()=>[o.value.length?K(``,!0):(B(),H(N(OA),{key:0},{default:P(()=>[W(N($),{colspan:`4`},{default:P(()=>[W(N(JO),null,{default:P(()=>[W(N(ZO),null,{default:P(()=>[W(N(ek),null,{default:P(()=>[G(j(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(B(!0),V(z,{key:1},L(l.value,e=>(B(),V(z,{key:e.key},[e.count===1?(B(),H(PA,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(B(),V(z,{key:1},[W(N(OA),{class:A(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:[Ll(Il(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),Ll(Il(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:P(()=>[W(N($),{class:`font-medium`},{default:P(()=>[U(`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:Il(t=>u(e.key),[`stop`])},[d(e)?(B(),H(N(Qu),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(B(),H(N($u),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),G(` `+j(e.label)+` `,1),W(N(nk),{variant:`idle`},{default:P(()=>[G(`×`+j(e.count),1)]),_:2},1024)],8,WA)]),_:2},1024),W(N($),{class:`font-mono`},{default:P(()=>[G(j(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),W(N($),{class:`w-[55%] max-w-0`},{default:P(()=>[U(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},j(f(e).text),9,GA)]),_:2},1024),W(N($),null,{default:P(()=>[G(j(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(B(!0),V(z,{key:0},L(e.events,(t,n)=>(B(),H(PA,{key:`${e.key}:${n}`,event:t,onO Line truncated `).map(e=>e.trim()).find(Boolean)||``,r=n.length>jA?`${n.slice(0,jA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var NA=[`title`],PA=I({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=J(()=>iA(n.event)),a=J(()=>MA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=J(()=>n.event.at?fk(n.event.at):`—`);return(e,t)=>(B(),H(N(OA),{class:A(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:[Ll(Il(o,[`prevent`]),[`enter`]),Ll(Il(o,[`prevent`]),[`space`])]},{default:P(()=>[W(N($),{class:`font-medium`},{default:P(()=>[G(j(n.event.kind||n.event.type||`event`),1)]),_:1}),W(N($),{class:`font-mono`},{default:P(()=>[G(j(i.value>0?`#${i.value}`:`—`),1)]),_:1}),W(N($),{class:`w-[55%] max-w-0`},{default:P(()=>[U(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},j(a.value.text),9,NA)]),_:1}),W(N($),null,{default:P(()=>[G(j(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),FA=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function IA(e){return(Number(e?.task_id)||0)>0}function LA(e,t){return t===`tasks`?IA(e):t!==`system`||!IA(e)}function RA(e,t){return e.filter(e=>LA(e,t))}function zA(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function BA(e,t){return`${e}:${t??0}`}function VA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=BA(MA(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 HA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},UA={class:`max-h-[28rem] overflow-y-auto`},WA=[`aria-expanded`,`aria-label`,`onClick`],GA=[`title`],KA=I({__name:`LiveActivityCard`,setup(e){let t=iE(),{activity:n,streamKind:r,streamState:i}=Au(mO()),a=M(`all`),o=J(()=>RA(n.value,a.value)),s=J(()=>zA(o.value.length,a.value)),c=Jt(new Set),l=J(()=>VA(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 MA(e.representative)}function p(e){return e.representative.at?fk(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(B(),H(N(ak),null,{default:P(()=>[W(N(uk),null,{default:P(()=>[W(N(dk),null,{default:P(()=>[...t[1]||=[G(`Live activity`,-1)]]),_:1}),W(N(ok),{class:`flex items-center gap-2`},{default:P(()=>[W(N(wA),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:N(FA)},null,8,[`modelValue`,`options`]),W(N(nk),{variant:N(r)},{default:P(()=>[G(j(N(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),W(N(sk),null,{default:P(()=>[U(`div`,HA,[U(`div`,UA,[W(N(EA),null,{default:P(()=>[W(N(AA),{class:`sticky top-0 z-10 bg-card`},{default:P(()=>[W(N(OA),null,{default:P(()=>[W(N(kA),null,{default:P(()=>[...t[2]||=[G(`Event`,-1)]]),_:1}),W(N(kA),null,{default:P(()=>[...t[3]||=[G(`Task`,-1)]]),_:1}),W(N(kA),null,{default:P(()=>[...t[4]||=[G(`Detail`,-1)]]),_:1}),W(N(kA),null,{default:P(()=>[...t[5]||=[G(`When`,-1)]]),_:1})]),_:1})]),_:1}),W(N(DA),null,{default:P(()=>[o.value.length?K(``,!0):(B(),H(N(OA),{key:0},{default:P(()=>[W(N($),{colspan:`4`},{default:P(()=>[W(N(JO),null,{default:P(()=>[W(N(ZO),null,{default:P(()=>[W(N(ek),null,{default:P(()=>[G(j(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(B(!0),V(z,{key:1},L(l.value,e=>(B(),V(z,{key:e.key},[e.count===1?(B(),H(PA,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(B(),V(z,{key:1},[W(N(OA),{class:A(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:[Ll(Il(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),Ll(Il(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:P(()=>[W(N($),{class:`font-medium`},{default:P(()=>[U(`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:Il(t=>u(e.key),[`stop`])},[d(e)?(B(),H(N(Qu),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(B(),H(N($u),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),G(` `+j(e.label)+` `,1),W(N(nk),{variant:`idle`},{default:P(()=>[G(`×`+j(e.count),1)]),_:2},1024)],8,WA)]),_:2},1024),W(N($),{class:`font-mono`},{default:P(()=>[G(j(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),W(N($),{class:`w-[55%] max-w-0`},{default:P(()=>[U(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},j(f(e).text),9,GA)]),_:2},1024),W(N($),null,{default:P(()=>[G(j(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(B(!0),V(z,{key:0},L(e.events,(t,n)=>(B(),H(PA,{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 pM(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 mM(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 hM(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 gM(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 _M=M([]),vM=M([]),yM=M(!0),bM=M(null),xM=M(null),SM=M(!1),CM=M(null);async function wM(){try{let e=await X.eventTypes();yM.value=e.enabled!==!1,_M.value=e.event_types||[],vM.value=e.proposals||[],bM.value=null}catch(e){bM.value=e.message||String(e)}}function TM(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function EM(e){CM.value=null,xM.value=e}function DM(e){let t=FM.value.find(t=>String(t.id)===e.sample_id);EM({mode:`proposal`,id:null,source:e.source,name:``,rule:TM(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function OM(e=``){EM({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function kM(e){EM({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:TM(e.rule),headersText:``,body:``,exampleHeaders:{}})}function AM(){xM.value=null}async function jM(){let e=xM.value;if(e){SM.value=!0;try{if(e.mode===`edit`&&e.id)await X.eventTypeUpdate(e.id,{name:e.name,rule:gM(e.rule)});else{let t=e.mode===`paste`?fM(e.headersText):e.exampleHeaders;await X.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:gM(e.rule),example:{headers:t,body:e.body}})}xM.value=null,await wM()}catch(e){CM.value=e.message||String(e)}finally{SM.value=!1}}}var MM=M(null);async function NM(){let e=MM.value;if(MM.value=null,e)try{await X.eventTypeDelete(e.id),await wM()}catch(e){bM.value=e.message||String(e)}}var PM=100,FM=M([]),IM=M(!0),LM=M(null),RM=M(!0),zM=M(null);async function BM(){try{let e=await X.captures(PM);IM.value=e.enabled!==!1,FM.value=e.captures||[],LM.value=null}catch(e){LM.value=e.message||String(e)}finally{RM.value=!1}}function VM(e){let t=FM.value.find(t=>t.id===e);return t&&(zM.value=t),!!t}function HM(){FM.value.length&&(zM.value=FM.value[0])}function UM(){hO(`captures`,()=>{BM(),wM()})}var WM={key:0,class:`text-xs text-fg-muted`},GM={key:1,class:`flex flex-col gap-1 text-xs`},KM={key:1},qM={key:2,class:`text-xs text-fg-muted`},JM=I({__name:`DispatchLinks`,props:{kind:{},id:{}},setup(e){let t=e,n=M([]),r=M(!1);F(()=>[t.kind,t.id],async()=>{r.value=!1;try{n.value=await X.dispatches(t.kind,t.id)}catch{n.value=[],r.value=!0}},{immediate:!0});let i=e=>({path:`/events`,query:{tab:`inspector`,capture:e}});return(e,a)=>{let o=Qi(`RouterLink`);return r.value?(B(),V(`p`,WM,`Dispatches unavailable.`)):n.value.length?(B(),V(`ul`,GM,[(B(!0),V(z,null,L(n.value,e=>(B(),V(`li`,{key:e.binding_id+e.capture_id,class:`flex flex-wrap items-center gap-x-2 font-mono text-fg-muted`},[t.kind===`bindings`?K(``,!0):(B(),H(o,{key:0,to:{path:`/events`,query:{tab:`bindings`}},class:`hover:text-foreground`},{default:P(()=>[G(`binding `+j(e.binding_id.slice(0,8))+` v`+j(e.binding_version),1)]),_:2},1024)),t.kind===`captures`?K(``,!0):(B(),H(o,{key:1,to:i(e.capture_id),class:`hover:text-foreground`},{default:P(()=>[G(`capture `+j(e.capture_id.slice(0,8)),1)]),_:2},1032,[`to`])),t.kind===`tasks`?K(``,!0):(B(),V(z,{key:2},[e.task_id?(B(),H(o,{key:0,to:`/tasks/${e.task_id}`,class:`text-foreground hover:underline`},{default:P(()=>[G(`task #`+j(e.task_id),1)]),_:2},1032,[`to`])):(B(),V(`span`,KM,j(e.reason||`claimed, no task recorded`),1))],64)),U(`span`,null,j(N(fk)(e.dispatched_at)),1)]))),128))])):t.kind===`tasks`?K(``,!0):(B(),V(`p`,qM,` No dispatches yet. `))}}}),YM=I({__name:`Spinner`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e;return(e,n)=>(B(),H(N(pd),{role:`status`,"aria-label":`Loading`,class:A(N(Y)(`size-4 animate-spin`,t.class))},null,8,[`class`]))}});function XM(e,t){return t?e.filter(e=>e.event_type_id===t):[]}function ZM(e){return(e?.repository??`required`)!==`none`}function QM(e,t){return e.filter(e=>t===`any`||e.type===`any`||e.type===t)}function $M(e,t){switch(t){case`string`:return e;case`number`:return e.trim()!==``&&!Number.isNaN(Number(e))?Number(e):e;case`bool`:return e===`true`||e!==`false`&&e;default:try{return JSON.parse(e)}catch{return e}}}var eN={pending_approval:`pending approval`,armed:`armed`,paused:`paused`},tN={pending_approval:`warn`,armed:`ok`,paused:`idle`};function nN(e) 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 pM(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 mM(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 hM(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 gM(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 _M=M([]),vM=M([]),yM=M(!0),bM=M(null),xM=M(null),SM=M(!1),CM=M(null);async function wM(){try{let e=await X.eventTypes();yM.value=e.enabled!==!1,_M.value=e.event_types||[],vM.value=e.proposals||[],bM.value=null}catch(e){bM.value=e.message||String(e)}}function TM(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function EM(e){CM.value=null,xM.value=e}function DM(e){let t=FM.value.find(t=>String(t.id)===e.sample_id);EM({mode:`proposal`,id:null,source:e.source,name:``,rule:TM(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function OM(e=``){EM({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function kM(e){EM({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:TM(e.rule),headersText:``,body:``,exampleHeaders:{}})}function AM(){xM.value=null}async function jM(){let e=xM.value;if(e){SM.value=!0;try{if(e.mode===`edit`&&e.id)await X.eventTypeUpdate(e.id,{name:e.name,rule:gM(e.rule)});else{let t=e.mode===`paste`?fM(e.headersText):e.exampleHeaders;await X.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:gM(e.rule),example:{headers:t,body:e.body}})}xM.value=null,await wM()}catch(e){CM.value=e.message||String(e)}finally{SM.value=!1}}}var MM=M(null);async function NM(){let e=MM.value;if(MM.value=null,e)try{await X.eventTypeDelete(e.id),await wM()}catch(e){bM.value=e.message||String(e)}}var PM=100,FM=M([]),IM=M(!0),LM=M(null),RM=M(!0),zM=M(null);async function BM(){try{let e=await X.captures(PM);IM.value=e.enabled!==!1,FM.value=e.captures||[],LM.value=null}catch(e){LM.value=e.message||String(e)}finally{RM.value=!1}}function VM(e){let t=FM.value.find(t=>t.id===e);return t&&(zM.value=t),!!t}function HM(){FM.value.length&&(zM.value=FM.value[0])}function UM(){hO(`captures`,()=>{BM(),wM()})}var WM={key:0,class:`text-xs text-fg-muted`},GM={key:1,class:`flex flex-col gap-1 text-xs`},KM={key:1},qM={key:2,class:`text-xs text-fg-muted`},JM=I({__name:`DispatchLinks`,props:{kind:{},id:{}},setup(e){let t=e,n=M([]),r=M(!1);F(()=>[t.kind,t.id],async()=>{r.value=!1;try{n.value=await X.dispatches(t.kind,t.id)}catch{n.value=[],r.value=!0}},{immediate:!0});let i=e=>({path:`/events`,query:{tab:`inspector`,capture:e}});return(e,a)=>{let o=Qi(`RouterLink`);return r.value?(B(),V(`p`,WM,`Dispatches unavailable.`)):n.value.length?(B(),V(`ul`,GM,[(B(!0),V(z,null,L(n.value,e=>(B(),V(`li`,{key:e.binding_id+e.capture_id,class:`flex flex-wrap items-center gap-x-2 font-mono text-fg-muted`},[t.kind===`bindings`?K(``,!0):(B(),H(o,{key:0,to:{path:`/events`,query:{tab:`bindings`}},class:`hover:text-foreground`},{default:P(()=>[G(`binding `+j(e.binding_id.slice(0,8))+` v`+j(e.binding_version),1)]),_:2},1024)),t.kind===`captures`?K(``,!0):(B(),H(o,{key:1,to:i(e.capture_id),class:`hover:text-foreground`},{default:P(()=>[G(`capture `+j(e.capture_id.slice(0,8)),1)]),_:2},1032,[`to`])),t.kind===`tasks`?K(``,!0):(B(),V(z,{key:2},[e.task_id?(B(),H(o,{key:0,to:`/tasks/${e.task_id}`,class:`text-foreground hover:underline`},{default:P(()=>[G(`task #`+j(e.task_id),1)]),_:2},1032,[`to`])):(B(),V(`span`,KM,j(e.reason||`claimed, no task recorded`),1))],64)),U(`span`,null,j(N(fk)(e.dispatched_at)),1)]))),128))])):t.kind===`tasks`?K(``,!0):(B(),V(`p`,qM,` No dispatches yet. `))}}}),YM=I({__name:`Spinner`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e;return(e,n)=>(B(),H(N(pd),{role:`status`,"aria-label":`Loading`,class:A(N(Y)(`size-4 animate-spin`,t.class))},null,8,[`class`]))}});function XM(e,t){return t?e.filter(e=>e.event_type_id===t):[]}function ZM(e){return(e?.repository??`required`)!==`none`}function QM(e,t){return e.filter(e=>t===`any`||e.type===`any`||e.type===t)}function $M(e,t){switch(t){case`string`:return e;case`number`:return e.trim()!==``&&!Number.isNaN(Number(e))?Number(e):e;case`bool`:return e===`true`||e!==`false`&&e;default:try{return JSON.parse(e)}catch{return e}}}var eN={pending_approval:`pending approval`,armed:`armed`,paused:`paused`},tN={pending_approval:`warn`,armed:`ok`,paused:`idle`};function nN(e) Line truncated
`)}};CJ.defaultYaml={explicit:!1,version:`1.2`},CJ.defaultTags={"!!":`tag:yaml.org,2002:`};function wJ(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function TJ(e){let t=new Set;return gJ(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function EJ(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function DJ(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=TJ(e);let a=EJ(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(cJ(t.node)||uJ(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function OJ(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=OJ(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=OJ(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=OJ(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=OJ(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function kJ(e,t,n){if(Array.isArray(e))return e.map((e,t)=>kJ(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!fJ(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var AJ=class{constructor(e){Object.defineProperty(this,rJ,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!aJ(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=kJ(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?OJ(i,{"":o},``,o):o}},jJ=class extends AJ{constructor(e){super(Zq),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],gJ(e,{Node:(e,t)=>{(iJ(t)||fJ(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(kJ(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=MJ(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(wJ(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function MJ(e,t,n){if(iJ(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(uJ(t)){let r=0;for(let i of t.items){let t=MJ(e,i,n);t>r&&(r=t)}return r}if(sJ(t)){let r=MJ(e,t.key,n),i=MJ(e,t.value,n);return Math.max(r,i)}return 1}var NJ=e=>!e||typeof e!=`function`&&typeof e!=`object`,PJ=class extends AJ{constructor(e){super(tJ),this.value=e}toJSON(e,t){return t?.keep?this.value:kJ(this.value,e,t)}toString(){return String(this.value)}};PJ.BLOCK_FOLDED=`BLOCK_FOLDED`,PJ.BLOCK_LITERAL=`BLOCK_LITERAL`,PJ.PLAIN=`PLAIN`,PJ.QUOTE_DOUBLE=`QUOTE_DOUBLE`,PJ.QUOTE_SINGLE=`QUOTE_SINGLE`;var FJ=`tag:yaml.org,2002:`;function IJ(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function LJ(e,t,n){if(aJ(e)&&(e=e.contents),dJ(e))return e;if(sJ(e)){let t=n.schema[$q].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new jJ(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=FJ+t.slice(2));let l=IJ(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new PJ(e);return c&&(c.node=t),t Line truncated `)}};CJ.defaultYaml={explicit:!1,version:`1.2`},CJ.defaultTags={"!!":`tag:yaml.org,2002:`};function wJ(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function TJ(e){let t=new Set;return gJ(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function EJ(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function DJ(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=TJ(e);let a=EJ(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(cJ(t.node)||uJ(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function OJ(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=OJ(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=OJ(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=OJ(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=OJ(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function kJ(e,t,n){if(Array.isArray(e))return e.map((e,t)=>kJ(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!fJ(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var AJ=class{constructor(e){Object.defineProperty(this,rJ,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!aJ(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=kJ(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?OJ(i,{"":o},``,o):o}},jJ=class extends AJ{constructor(e){super(Zq),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],gJ(e,{Node:(e,t)=>{(iJ(t)||fJ(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(kJ(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=MJ(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(wJ(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function MJ(e,t,n){if(iJ(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(uJ(t)){let r=0;for(let i of t.items){let t=MJ(e,i,n);t>r&&(r=t)}return r}if(sJ(t)){let r=MJ(e,t.key,n),i=MJ(e,t.value,n);return Math.max(r,i)}return 1}var NJ=e=>!e||typeof e!=`function`&&typeof e!=`object`,PJ=class extends AJ{constructor(e){super(tJ),this.value=e}toJSON(e,t){return t?.keep?this.value:kJ(this.value,e,t)}toString(){return String(this.value)}};PJ.BLOCK_FOLDED=`BLOCK_FOLDED`,PJ.BLOCK_LITERAL=`BLOCK_LITERAL`,PJ.PLAIN=`PLAIN`,PJ.QUOTE_DOUBLE=`QUOTE_DOUBLE`,PJ.QUOTE_SINGLE=`QUOTE_SINGLE`;var FJ=`tag:yaml.org,2002:`;function IJ(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function LJ(e,t,n){if(aJ(e)&&(e=e.contents),dJ(e))return e;if(sJ(e)){let t=n.schema[$q].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new jJ(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=FJ+t.slice(2));let l=IJ(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new PJ(e);return c&&(c.node=t),t Line truncated
`)?HJ(n,t):n.includes(` `)?HJ(n,t):n.includes(`
`)?` `)?`
+18 -17
View File
@@ -3,29 +3,30 @@ import { computed, onMounted } from "vue";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { SettingRow } from "@/components/ui/setting-row"; import { SettingRow } from "@/components/ui/setting-row";
import { useControlPlaneStore } from "@/stores/control-plane"; import { useControlPlaneStore } from "@/stores/control-plane";
const KIND = "update-settings"; const KIND = "update-settings";
type Commands = { check_command: string[] | null; install_command: string[] | null }; type UpdateSettings = { channel: string; pin: string };
const store = useControlPlaneStore(); const store = useControlPlaneStore();
onMounted(store.load); onMounted(store.load);
const draft = computed(() => store.drafts[KIND]?.value as Commands | undefined); const draft = computed(() => store.drafts[KIND]?.value as UpdateSettings | undefined);
const error = computed(() => store.stateFor(KIND).error); const error = computed(() => store.stateFor(KIND).error);
// Each command is an argv array, edited as one line split on whitespace. const channels = [
function argv(field: keyof Commands) { { value: "stable", label: "Stable" },
return computed({ { value: "next", label: "Prereleases" },
get: () => (draft.value?.[field] ?? []).join(" "), { value: "exact-pin", label: "Pinned" },
set: (line: string) => { ];
if (draft.value) draft.value[field] = line.split(/\s+/).filter(Boolean); const channel = computed({
}, get: () => draft.value?.channel || "stable",
}); set: (value: string) => {
} if (draft.value) draft.value.channel = value;
const check = argv("check_command"); },
const install = argv("install_command"); });
</script> </script>
<template> <template>
@@ -35,11 +36,11 @@ const install = argv("install_command");
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<p v-if="error" class="mb-2 text-sm text-danger" role="alert">{{ error }}</p> <p v-if="error" class="mb-2 text-sm text-danger" role="alert">{{ error }}</p>
<SettingRow label="Check command" for="update-check" hint="Prints the available releases as JSON."> <SettingRow label="Release channel">
<Input id="update-check" v-model="check" class="font-mono" placeholder="archie-update-check" /> <SegmentedControl v-model="channel" label="Release channel" :options="channels" />
</SettingRow> </SettingRow>
<SettingRow label="Install command" for="update-install" hint="Installs the release you approve. Empty hides Install."> <SettingRow v-if="channel === 'exact-pin'" label="Version" for="update-pin">
<Input id="update-install" v-model="install" class="font-mono" placeholder="archie-update-install" /> <Input id="update-pin" v-model="draft.pin" class="max-w-40 font-mono" placeholder="1.48.0" />
</SettingRow> </SettingRow>
</CardContent> </CardContent>
</Card> </Card>