Compare commits

...
30 Commits
Author SHA1 Message Date
sam 4b62912343 chore(release): v1.51.0
deploy / gate (push) Canceled after 0s
deploy / archied-image (push) Canceled after 0s
deploy / agent-image (push) Canceled after 0s
deploy / dist-zip (push) Canceled after 0s
2026-10-08 01:37:28 +11:00
sam 8a8c8cf7e9 feat(chat): the dashboard chat records voice, downloads files a turn sends, and offers /model and /personality choices 2026-10-08 01:37:21 +11:00
sam 201529414b fix(gateway): providers resolve again when a secret engine starts after boot 2026-10-08 01:34:55 +11:00
sam 3da1f918a4 chore(release): v1.50.1
deploy / gate (push) Canceled after 0s
deploy / archied-image (push) Canceled after 0s
deploy / agent-image (push) Canceled after 0s
deploy / dist-zip (push) Canceled after 0s
2026-10-08 00:40:03 +11:00
sam f8d8e5b1e2 fix(update): the watchdog logs the health report it rolled back on 2026-10-08 00:39:57 +11:00
sam 826d4849df chore(release): v1.50.0
deploy / archied-image (push) Canceled after 0s
deploy / agent-image (push) Canceled after 0s
deploy / dist-zip (push) Canceled after 0s
deploy / gate (push) Canceled after 33s
2026-10-08 00:25:35 +11:00
sam 0a18bfe21b feat(chat): the dashboard chat answers tool approvals and questions, and /update offers Install 2026-10-08 00:25:23 +11:00
sam 5976b94fbc fix(gatewayrpc): carry tool approvals and ask_user questions between a channel and the gateway turn 2026-10-08 00:22:37 +11:00
sam 698548d6ef chore(release): v1.49.4
deploy / gate (push) Canceled after 0s
deploy / archied-image (push) Canceled after 0s
deploy / agent-image (push) Canceled after 0s
deploy / dist-zip (push) Canceled after 0s
2026-10-07 23:58:52 +11:00
sam d0584279e5 fix(ui): tabbed Status and Extensions, one Add MCP server, repos page renders without repos, save bar rests at the viewport edge 2026-10-07 23:46:34 +11:00
sam 62f248fd2c fix(ui): the Versions table's status column ends at the card's edge 2026-10-07 23:35:12 +11:00
sam 8f2750a266 chore(release): v1.49.3
deploy / gate (push) Canceled after 0s
deploy / archied-image (push) Canceled after 0s
deploy / agent-image (push) Canceled after 0s
deploy / dist-zip (push) Canceled after 0s
2026-10-07 23:34:21 +11:00
sam 2ea7f7cd38 fix(ui): the release channel control sits at the Updates card's edge, not mid-row 2026-10-07 23:34:13 +11:00
sam 75b3810856 fix(archieui): the Versions card compares against the running daemon, so an available update can be installed 2026-10-07 23:29:03 +11:00
sam 30419532ba chore(release): v1.49.2
deploy / archied-image (push) Canceled after 0s
deploy / agent-image (push) Canceled after 0s
deploy / dist-zip (push) Canceled after 0s
deploy / gate (push) Canceled after 1m51s
2026-10-07 23:18:11 +11:00
sam fff67838e0 fix(releaseupdate): read GitHub releases directly; drop go-selfupdate and its openpgp dependency 2026-10-07 23:18:03 +11:00
sam 15ebe24927 chore(release): v1.49.1
deploy / gate (push) Failing after 3m43s
deploy / archied-image (push) Skipped
deploy / agent-image (push) Skipped
deploy / dist-zip (push) Skipped
2026-10-07 23:10:38 +11:00
sam b2c1629925 fix(ui): an expired session reloads to the sign-in page instead of showing a banner 2026-10-07 23:05:52 +11:00
sam 0e8fcf70a0 chore(release): v1.49.0
deploy / gate (push) Failing after 5m18s
deploy / archied-image (push) Skipped
deploy / agent-image (push) Skipped
deploy / dist-zip (push) Skipped
2026-10-07 22:17:00 +11:00
sam 4673b435b7 fix(extension): confine egress only for packages that declare egress hosts 2026-10-07 22:15:06 +11:00
sam 1e062fd7f0 fix(releaseupdate): reuse a found release for ten minutes to stay under GitHub's unauthenticated rate limit 2026-10-07 01:17:21 +11:00
sam 74a3ec925c feat(releaseupdate): archied update check finds releases through go-selfupdate; archie-update-check is deleted 2026-10-07 01:12:11 +11:00
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
sam cbedb8a504 chore(release): v1.48.0
deploy / gate (push) Failing after 5m4s
deploy / archied-image (push) Skipped
deploy / agent-image (push) Skipped
deploy / dist-zip (push) Skipped
2026-10-07 00:57:07 +11:00
sam a8dbab0cff feat(controlplane): update commands are an update-settings kind edited on Status, defaulting to the installed scripts 2026-10-07 00:57:01 +11:00
sam 789ff73fe9 fix(scripts): archie-update-install loads the archie env file so a shell run can back up the bundled database 2026-10-07 00:53:23 +11:00
sam 5176938e95 ci(deploy): build the archied and agent images in parallel so the release zip waits only on the agent image 2026-10-07 00:35:13 +11:00
sam 69a1ee677d chore(release): v1.47.3
deploy / gate (push) Failing after 3m29s
deploy / build-and-push (push) Skipped
deploy / dist-zip (push) Skipped
2026-10-07 00:33:23 +11:00
sam b3cf2c59a8 fix(webui): extension Accept and Remove dialogs act on the selected extension 2026-10-07 00:32:44 +11:00
77 changed files with 2661 additions and 1083 deletions

No files matched your search

+42 -11
View File
@@ -170,9 +170,7 @@ jobs:
echo "This commit is not a release, so the images are published as :edge and sha-<sha>; :latest keeps naming the newest release."
fi
build-and-push:
outputs:
agent_digest: ${{ steps.agent.outputs.digest }}
archied-image:
needs: gate
runs-on: ubuntu-latest
steps:
@@ -264,6 +262,43 @@ jobs:
cache-from: type=gha,scope=archied
cache-to: type=gha,mode=max,scope=archied
agent-image:
outputs:
agent_digest: ${{ steps.agent.outputs.digest }}
needs: gate
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Annotated tags: dereference to the commit, as archied-image does.
- name: Resolve the commit this ref points at
id: commit
run: |
sha="$(git rev-parse "${GITHUB_REF}^{commit}")"
echo "sha=$sha" >> "$GITHUB_OUTPUT"
echo "short=${sha:0:12}" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Resolve runtime version
id: versions
run: |
RUNTIME_TAG="$(git tag --points-at HEAD --list 'archie/v*' | sort -V | tail -1)"
RELEASE_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -1)"
RUNTIME_VERSION="${RUNTIME_TAG#archie/}"
[ -n "$RUNTIME_VERSION" ] || RUNTIME_VERSION="${RELEASE_TAG#v}"
echo "runtime_tag=$RUNTIME_TAG" >> "$GITHUB_OUTPUT"
echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
echo "runtime=$RUNTIME_VERSION" >> "$GITHUB_OUTPUT"
- name: Build and push archie-agent
id: agent
if: steps.versions.outputs.runtime_tag != '' || steps.versions.outputs.release_tag != ''
@@ -283,14 +318,10 @@ jobs:
# Packages every host-run binary (archied, archie-gateway,
# archie-state-store, archie-ui, archie-messaging) as a
# linux/amd64 zip for a
# non-Docker install. Independent of build-and-push: it never touches the
# archied/archie-agent image jobs, and a gateway-only release (no
# archie/v* tag) still produces this zip -- it's keyed to the archied tag
# alone. archie-agent is deliberately excluded: it only ever runs inside
# the Docker image build-and-push already publishes, never as a host
# binary (archie-core-8cda.4.7.1).
# non-Docker install. It waits only for the agent image, whose digest
# release.json pins; archie-agent itself never ships as a host binary.
dist-zip:
needs: [gate, build-and-push]
needs: [gate, agent-image]
# Not gated on github.ref. A release is pushed as main plus both tags at
# one SHA, the concurrency group below collapses those into a single run,
# and the survivor is whichever ref happened to start last -- for
@@ -352,7 +383,7 @@ jobs:
done
cp deployments/INSTRUCTIONS.md CHANGELOG.md "$name/"
cp scripts/archie-update-* "$name/"
digest='${{ needs.build-and-push.outputs.agent_digest }}'
digest='${{ needs.agent-image.outputs.agent_digest }}'
test -n "$digest"
jq --arg image "ghcr.io/samcharles93/archie-agent@$digest" '. + {agent_image: $image}' release.json > "$name/release.json"
# README.md doesn't exist yet in this repo; include it once it does
+78
View File
@@ -5,6 +5,84 @@ release's per-component sections are labelled beneath its heading.
## [Unreleased]
## [1.51.0] - 2026-10-08
### archied
- A secret engine enabled after Archie started (Bitwarden, for example) now supplies its keys straight away; providers that depended on it no longer stay disabled until a restart.
- The dashboard chat has a microphone button: record a voice message and it is transcribed like a Telegram voice note. It shows only when a `transcription` model role is set under Settings → Models.
- A file Archie sends in the dashboard chat is a download link for an hour, instead of a note that it can't be delivered.
- Typing `/model` or `/personality` on its own in the dashboard chat offers the choices as buttons.
## [1.50.1] - 2026-10-08
### archied
- When an update is rolled back, the log names the health check that failed instead of only "unhealthy".
## [1.50.0] - 2026-10-08
### archied
- Tools that need your approval ask for it again, and Archie can ask you a question or offer choices mid-reply. Since the services were split these never reached Telegram or the dashboard: approval-gated tools failed and questions were never asked.
- The dashboard chat shows approvals as Approve / Always this session / Deny, choices as buttons, and questions with a reply field.
- `/update` in the dashboard chat lists what's available with Install and Not now.
- Settings → Status → Versions installs the update it shows; its Install button sent an empty request.
## [1.49.4] - 2026-10-07
### archied
- Settings → Status and Settings → Extensions are split into tabs instead of one long page; the Versions table's status column ends at the card's edge.
- Tools & MCP has one "Add MCP server" button; the transport is chosen in the form, and an unnamed new server is not an unsaved change.
- Settings → Repositories shows the add field when no repositories are configured, instead of a blank page.
- The unsaved-changes bar always rests at the bottom of the window.
## [1.49.3] - 2026-10-07
### archied
- Settings → Status → Versions shows the Gateway as "Update available" with an Install button when a newer release exists; it read "Unknown" with no way to install. The Runtime row stays "Unknown" until an agent task has run.
- The release channel buttons sit at the Updates card's right edge instead of mid-row.
## [1.49.2] - 2026-10-07
### archied
- Carries the 1.49.0 and 1.49.1 changes, whose builds were never published. The update check reads GitHub releases directly and still offers only releases with a verifiable linux-amd64 zip.
## [1.49.1] - 2026-10-07
### archied
- When the dashboard session expires, the page returns to the sign-in screen instead of showing errors on every page until a manual refresh.
## [1.49.0] - 2026-10-07
### archied
- Extensions that declare no egress hosts (vault, email, gitea) reach the network again; only packages that declare their hosts are confined to them. The Accept dialog shows "network: unrestricted" for the rest.
- The update check finds releases itself, and reuses a found release for ten minutes so repeated checks stay under GitHub's rate limit.
## [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
### archied
- **Settings → Status → Updates** edits the update check and install commands. They default to the `archie-update-*` scripts installed beside the binaries, so a zip install shows **Install** on the Versions card with nothing configured. The `update_check_command` and `update_install_command` keys under `[chat.telegram]` are no longer read; remove them from `config.toml`.
- `archie-update-install` run from a shell now reads `~/.config/archie/env`, so the pre-update backup of the bundled database no longer fails with `no password supplied`. Run it with `--auto` to install the newest release.
## [1.47.3] - 2026-10-07
### archied
- **Settings → Extensions**: **Accept** in the authority review now accepts the extension, and **Remove** removes it. Both previously closed the dialog without doing anything.
## [1.47.2] - 2026-10-06
### archied
+2 -2
View File
@@ -16,8 +16,8 @@ func main() {
if archied.IsSetupArgs(args) {
os.Exit(archied.RunSetup(args[1:], os.Stdin, os.Stdout, os.Stderr))
}
if len(args) > 0 && args[0] == "select-release" {
os.Exit(archied.RunReleaseChannel(args[1:], os.Stdin, os.Stdout, os.Stderr))
if len(args) > 0 && args[0] == "update" {
os.Exit(archied.RunUpdate(args[1:], os.Stdout, os.Stderr))
}
if len(args) > 0 && args[0] == "update-image" {
os.Exit(archied.RunUpdateImage(args[1:], os.Stderr))
-7
View File
@@ -146,16 +146,9 @@ class = "ollama"
# "openrouter/openai/gpt-5.6-sol",
# ]
# Optional self-hosted update adapter. Both values are argv arrays (never
# shell snippets). The check command must write a releaseupdate.Snapshot JSON
# document to stdout; configure the installer as well to show Approve/Defer.
# [chat.telegram]
# The bot token from @BotFather, resolved through a configured secret engine.
# token = { engine = "bws", key = "TELEGRAM_BOT_TOKEN" }
# Run by archie-messaging, which serves /update, so these commands execute on
# whichever host runs that process.
# update_check_command = ["/usr/local/bin/archie-update-check"]
# update_install_command = ["/usr/local/bin/archie-update-install"]
# Email and the generic inbound webhook are archipelago channel extensions
# (channels/email, channels/webhook): install, accept and enable them from the
+5 -4
View File
@@ -92,14 +92,15 @@ an install (or an upgrade across v1.30.0) needs its unit as well -- see
`archie-update-install` downloads the approved release's Linux/amd64 archive
and verifies its `SHA256SUMS` entry before executing or installing it. Releases
must include `release.json`, all host binaries, and the three updater scripts.
must include `release.json`, all host binaries, and the two updater scripts.
Older releases without this contract cannot be installed through the artifact
path. `--from-source` (or `ARCHIE_UPDATE_SOURCE_BUILD=1`) explicitly clones and
builds the selected release instead.
The update check command accepts `--channel stable` (default), `--channel next`
(includes prereleases), or `--channel exact-pin --pin 1.2.3`. Set these arguments
in the control plane's channel settings alongside the existing check command.
`archied update check` finds the newest GitHub release with a linux-amd64 zip on
the channel chosen under Settings → Status → Updates: stable, next (includes
prereleases) or a pinned version. From a shell it reads
`ARCHIE_UPDATE_RELEASE_CHANNEL` and `ARCHIE_UPDATE_PIN`, or `-channel` and `-pin`.
The notification destination remains separate from the release channel.
For scheduled, unattended runs, `archie-update-install --auto` discovers the
+22
View File
@@ -64,7 +64,18 @@
"/news/archie/1.47.0/": "/news/1.47.0/",
"/news/archie/1.47.1/": "/news/1.47.1/",
"/news/archie/1.47.2/": "/news/1.47.2/",
"/news/archie/1.47.3/": "/news/1.47.3/",
"/news/archie/1.48.0/": "/news/1.48.0/",
"/news/archie/1.48.1/": "/news/1.48.1/",
"/news/archie/1.49.0/": "/news/1.49.0/",
"/news/archie/1.49.1/": "/news/1.49.1/",
"/news/archie/1.49.2/": "/news/1.49.2/",
"/news/archie/1.49.3/": "/news/1.49.3/",
"/news/archie/1.49.4/": "/news/1.49.4/",
"/news/archie/1.5.0/": "/news/1.5.0/",
"/news/archie/1.50.0/": "/news/1.50.0/",
"/news/archie/1.50.1/": "/news/1.50.1/",
"/news/archie/1.51.0/": "/news/1.51.0/",
"/news/archie/1.6.0/": "/news/1.6.0/",
"/news/archie/1.7.0/": "/news/1.7.0/",
"/news/archie/1.8.0/": "/news/1.8.0/",
@@ -145,7 +156,18 @@
"/news/archied/1.47.0/": "/news/1.47.0/",
"/news/archied/1.47.1/": "/news/1.47.1/",
"/news/archied/1.47.2/": "/news/1.47.2/",
"/news/archied/1.47.3/": "/news/1.47.3/",
"/news/archied/1.48.0/": "/news/1.48.0/",
"/news/archied/1.48.1/": "/news/1.48.1/",
"/news/archied/1.49.0/": "/news/1.49.0/",
"/news/archied/1.49.1/": "/news/1.49.1/",
"/news/archied/1.49.2/": "/news/1.49.2/",
"/news/archied/1.49.3/": "/news/1.49.3/",
"/news/archied/1.49.4/": "/news/1.49.4/",
"/news/archied/1.5.0/": "/news/1.5.0/",
"/news/archied/1.50.0/": "/news/1.50.0/",
"/news/archied/1.50.1/": "/news/1.50.1/",
"/news/archied/1.51.0/": "/news/1.51.0/",
"/news/archied/1.6.0/": "/news/1.6.0/",
"/news/archied/1.7.0/": "/news/1.7.0/",
"/news/archied/1.8.0/": "/news/1.8.0/",
+55
View File
@@ -1,4 +1,59 @@
[
{
"version": "1.51.0",
"date": "2026-10-08",
"body": "### archied\n\n- A secret engine enabled after Archie started (Bitwarden, for example) now supplies its keys straight away; providers that depended on it no longer stay disabled until a restart.\n- The dashboard chat has a microphone button: record a voice message and it is transcribed like a Telegram voice note. It shows only when a `transcription` model role is set under Settings → Models.\n- A file Archie sends in the dashboard chat is a download link for an hour, instead of a note that it can't be delivered.\n- Typing `/model` or `/personality` on its own in the dashboard chat offers the choices as buttons."
},
{
"version": "1.50.1",
"date": "2026-10-08",
"body": "### archied\n\n- When an update is rolled back, the log names the health check that failed instead of only \"unhealthy\"."
},
{
"version": "1.50.0",
"date": "2026-10-08",
"body": "### archied\n\n- Tools that need your approval ask for it again, and Archie can ask you a question or offer choices mid-reply. Since the services were split these never reached Telegram or the dashboard: approval-gated tools failed and questions were never asked.\n- The dashboard chat shows approvals as Approve / Always this session / Deny, choices as buttons, and questions with a reply field.\n- `/update` in the dashboard chat lists what's available with Install and Not now.\n- Settings → Status → Versions installs the update it shows; its Install button sent an empty request."
},
{
"version": "1.49.4",
"date": "2026-10-07",
"body": "### archied\n\n- Settings → Status and Settings → Extensions are split into tabs instead of one long page; the Versions table's status column ends at the card's edge.\n- Tools & MCP has one \"Add MCP server\" button; the transport is chosen in the form, and an unnamed new server is not an unsaved change.\n- Settings → Repositories shows the add field when no repositories are configured, instead of a blank page.\n- The unsaved-changes bar always rests at the bottom of the window."
},
{
"version": "1.49.3",
"date": "2026-10-07",
"body": "### archied\n\n- Settings → Status → Versions shows the Gateway as \"Update available\" with an Install button when a newer release exists; it read \"Unknown\" with no way to install. The Runtime row stays \"Unknown\" until an agent task has run.\n- The release channel buttons sit at the Updates card's right edge instead of mid-row."
},
{
"version": "1.49.2",
"date": "2026-10-07",
"body": "### archied\n\n- Carries the 1.49.0 and 1.49.1 changes, whose builds were never published. The update check reads GitHub releases directly and still offers only releases with a verifiable linux-amd64 zip."
},
{
"version": "1.49.1",
"date": "2026-10-07",
"body": "### archied\n\n- When the dashboard session expires, the page returns to the sign-in screen instead of showing errors on every page until a manual refresh."
},
{
"version": "1.49.0",
"date": "2026-10-07",
"body": "### archied\n\n- Extensions that declare no egress hosts (vault, email, gitea) reach the network again; only packages that declare their hosts are confined to them. The Accept dialog shows \"network: unrestricted\" for the rest.\n- The update check finds releases itself, and reuses a found release for ten minutes so repeated checks stay under GitHub's rate limit."
},
{
"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",
"date": "2026-10-07",
"body": "### archied\n\n- **Settings → Status → Updates** edits the update check and install commands. They default to the `archie-update-*` scripts installed beside the binaries, so a zip install shows **Install** on the Versions card with nothing configured. The `update_check_command` and `update_install_command` keys under `[chat.telegram]` are no longer read; remove them from `config.toml`.\n- `archie-update-install` run from a shell now reads `~/.config/archie/env`, so the pre-update backup of the bundled database no longer fails with `no password supplied`. Run it with `--auto` to install the newest release."
},
{
"version": "1.47.3",
"date": "2026-10-07",
"body": "### archied\n\n- **Settings → Extensions**: **Accept** in the authority review now accepts the extension, and **Remove** removes it. Both previously closed the dialog without doing anything."
},
{
"version": "1.47.2",
"date": "2026-10-06",
-32
View File
@@ -1,32 +0,0 @@
package archied
import (
"flag"
"fmt"
"io"
"strings"
"github.com/samcharles93/archie-core/internal/releaseupdate"
)
func RunReleaseChannel(args []string, in io.Reader, out, stderr io.Writer) int {
flags := flag.NewFlagSet("select-release", flag.ContinueOnError)
flags.SetOutput(stderr)
channel := flags.String("channel", "stable", "stable, next, or exact-pin")
pin := flags.String("pin", "", "exact release version")
if err := flags.Parse(args); err != nil {
return 1
}
data, err := io.ReadAll(in)
if err != nil {
fmt.Fprintln(stderr, err)
return 1
}
version, err := releaseupdate.SelectRelease(strings.Fields(string(data)), *channel, *pin)
if err != nil {
fmt.Fprintln(stderr, err)
return 1
}
fmt.Fprintln(out, version)
return 0
}
+48
View File
@@ -0,0 +1,48 @@
package archied
import (
"context"
"encoding/json"
"flag"
"fmt"
"io"
"os"
"github.com/samcharles93/archie-core/internal/releaseupdate"
)
// RunUpdate serves `archied update check`, printing the release snapshot as
// JSON. The channel defaults to the environment the installer passes on.
func RunUpdate(args []string, out, stderr io.Writer) int {
if len(args) == 0 || args[0] != "check" {
fmt.Fprintln(stderr, "usage: archied update check [-channel stable|next|exact-pin] [-pin version]")
return 2
}
flags := flag.NewFlagSet("update check", flag.ContinueOnError)
flags.SetOutput(stderr)
channel := flags.String("channel", envOr("ARCHIE_UPDATE_RELEASE_CHANNEL", "stable"), "stable, next, or exact-pin")
pin := flags.String("pin", os.Getenv("ARCHIE_UPDATE_PIN"), "exact release version")
if err := flags.Parse(args[1:]); err != nil {
return 2
}
catalog := &releaseupdate.GitHubCatalog{Channel: func(context.Context) (string, string, error) { return *channel, *pin, nil }}
snapshot, err := catalog.Check(context.Background())
if err != nil {
fmt.Fprintln(stderr, err)
return 1
}
encoder := json.NewEncoder(out)
encoder.SetIndent("", " ")
if err := encoder.Encode(snapshot); err != nil {
fmt.Fprintln(stderr, err)
return 1
}
return 0
}
func envOr(key, fallback string) string {
if value := os.Getenv(key); value != "" {
return value
}
return fallback
}
+4 -17
View File
@@ -17,6 +17,7 @@ import (
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/events"
"github.com/samcharles93/archie-core/internal/gateway"
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
"github.com/samcharles93/archie-core/internal/installtype"
"github.com/samcharles93/archie-core/internal/releaseupdate"
"github.com/samcharles93/archie-core/internal/tools"
@@ -95,23 +96,9 @@ func componentInstallTypeEnricher(nats config.NATSConfig) func(string) (string,
}
}
func makeUpdateService(s chatSetup) *releaseupdate.Service {
cfg := s.Cfg.Get()
if len(cfg.Chat.Telegram.UpdateCheckCommand) == 0 {
return nil
}
updates := &releaseupdate.Service{
Catalog: releaseupdate.CommandCatalog{Command: cfg.Chat.Telegram.UpdateCheckCommand},
StatePath: filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"),
InstallType: installtype.Type(),
Enrich: componentInstallTypeEnricher(cfg.NATS),
}
if len(cfg.Chat.Telegram.UpdateInstallCommand) != 0 {
updates.Installer = releaseupdate.CommandInstaller{
Command: cfg.Chat.Telegram.UpdateInstallCommand,
HealthURL: cfg.Health.URL(),
}
}
func makeUpdateService(reader controlplanerpc.ResourceReader, cfg config.Config) *releaseupdate.Service {
updates := controlplanerpc.UpdateService(reader, filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"), cfg.Health.URL())
updates.Enrich = componentInstallTypeEnricher(cfg.NATS)
return updates
}
@@ -86,7 +86,7 @@ func (b *server) setupChatRuntime(ctx context.Context, cfg config.Config, actor
},
cancelExecution: b.stateStore.CancelExecution,
})
b.updateService = makeUpdateService(chatSetup{Cfg: config.NewHolder(cfg)})
b.updateService = makeUpdateService(b.controlPlane, cfg)
return nil
}
@@ -256,5 +256,6 @@ func (b *server) setupGatewayChat(ctx context.Context, actor gateway.ChatTaskAct
return &gateway.LocalChatAdapter{
Router: router, Sessions: b.chatSessionStore, Turns: gateway.NewTurns(b.log),
Models: b.chatModels, Personas: b.personas, TaskActor: actor, Tasks: b.stateStore,
VoiceAvailable: b.transcriber != nil,
}, nil
}
+11 -1
View File
@@ -64,6 +64,7 @@ type server struct {
taskLogs *logging.TaskRegistry
secrets *secret.Registry
engines *secretengine.Runner
stateStore *staterpc.Client
controlPlane *controlplane.Client
applyStatus *applystatus.Reporter
@@ -191,7 +192,8 @@ func (b *server) openState(ctx context.Context) error {
report := func(ctx context.Context, version int64, err error) {
b.applyStatus.Report(ctx, controlplanerpc.ExtensionSettingsKind, version, err)
}
b.addCleanup(secretengine.Supervise(ctx, b.secrets, source, applystatus.Gateway, report, b.log).Close)
b.engines = secretengine.Supervise(ctx, b.secrets, source, applystatus.Gateway, report, b.log)
b.addCleanup(b.engines.Close)
cfg, versions, err := b.runtimeConfig(ctx, b.cfg)
if err != nil {
return fmt.Errorf("load runtime settings: %w", err)
@@ -286,6 +288,14 @@ var gatewayRuntimeKinds = []string{
}
func (b *server) startRuntimeWatches(ctx context.Context) error {
// An engine that starts after boot answers references that failed then, so
// the providers resolve again.
b.engines.OnChange(func() {
base := b.cfgHolder.Get()
catalog, _ := b.catalogState()
modelcatalog.Apply(&base, catalog)
_ = b.relayer(ctx, base, controlplane.ProviderSettingsKind)
})
for _, kind := range gatewayRuntimeKinds {
updates, err := b.controlPlane.WatchResource(ctx, kind, b.runtimeVersions[kind])
if err != nil {
+4
View File
@@ -19,6 +19,7 @@ import (
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/infrastructure/messagingrpc"
"github.com/samcharles93/archie-core/internal/releaseupdate"
"github.com/samcharles93/archie-core/internal/sdnotify"
"github.com/samcharles93/archie-core/internal/secret"
)
@@ -43,6 +44,9 @@ type deps struct {
// SettingsSource enables live channel-settings reconciliation. Nil disables
// it.
SettingsSource chatSettingsSource
// Updates serves /update from the stored update settings. Nil without a
// State Store.
Updates *releaseupdate.Service
// ApplyReporter records what this process applied. Nil reports nothing.
ApplyReporter *applystatus.Reporter
// AppliedVersion is the channel-settings version already running when the
+5
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"log/slog"
"net"
"path/filepath"
"google.golang.org/grpc"
@@ -20,6 +21,7 @@ import (
"github.com/samcharles93/archie-core/internal/infrastructure/messagingrpc"
"github.com/samcharles93/archie-core/internal/infrastructure/secretengine"
"github.com/samcharles93/archie-core/internal/infrastructure/staterpc"
"github.com/samcharles93/archie-core/internal/releaseupdate"
"github.com/samcharles93/archie-core/internal/secret"
)
@@ -52,6 +54,7 @@ func Run(ctx context.Context, o Options) error {
var settingsSource chatSettingsSource
var applyReporter *applystatus.Reporter
var appliedVersion int64
var updates *releaseupdate.Service
var extensionChannels []*channelInstance
if cfg.Options.StateStore.Target != "" {
stateStore, closeClient, dialErr := staterpc.Dial(cfg.Options.StateStore.Target, presence.Messaging, cfg.Options.StateStore.Token, staterpc.WaitForPeer)
@@ -81,6 +84,7 @@ func Run(ctx context.Context, o Options) error {
settings = messaging.NewSettingsCommand(messagingControlPlane{client: stateStore.ControlPlane()}).WithIdentities(stateStore)
channelStatusStore, presenceStore = stateStore, stateStore
settingsSource, applyReporter, appliedVersion = controlPlaneClient, reporter, channelVersion
updates = controlplanerpc.UpdateService(controlPlaneClient, filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"), cfg.HealthURL)
}
if cfg.Options.StateStore.Target == "" {
@@ -101,6 +105,7 @@ func Run(ctx context.Context, o Options) error {
SettingsSource: settingsSource,
ApplyReporter: applyReporter,
AppliedVersion: appliedVersion,
Updates: updates,
})
if err != nil {
return err
@@ -9,14 +9,11 @@ import (
"time"
configtemplate "github.com/samcharles93/archie-core"
"github.com/samcharles93/archie-core/internal/app/servicekit"
"github.com/samcharles93/archie-core/internal/buildinfo"
"github.com/samcharles93/archie-core/internal/channels/telegram"
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/domain/presence"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/installtype"
"github.com/samcharles93/archie-core/internal/releaseannounce"
"github.com/samcharles93/archie-core/internal/releaseupdate"
"github.com/samcharles93/archie-core/internal/secret"
)
@@ -26,10 +23,10 @@ func configureTelegram(ctx context.Context, g *telegram.Gateway, cfg ResolvedCon
g.Version = gatewayVersionReporter(ctx, d.Chat, cfg.Options.DependencyTimeout)
g.SetShowToolCalls(cfg.ShowToolCalls)
g.Reload = telegramReloader(cfg.Options, d.Secrets, d.Log)
g.RunningVersions = runningVersions(ctx, d.Presence, cfg.Options.DependencyTimeout)
g.RunningVersions = servicekit.RunningVersions(ctx, d.Presence, cfg.Options.DependencyTimeout)
if updates := updateService(cfg); updates != nil {
g.Updates = updates
if d.Updates != nil {
g.Updates = d.Updates
}
if cfg.WorkDir != "" {
g.UpdateReportPath = identityStatePath(cfg.WorkDir, "update-report", cfg.BotUser)
@@ -42,34 +39,6 @@ func configureTelegram(ctx context.Context, g *telegram.Gateway, cfg ResolvedCon
}
}
// runningVersions reports the daemon version archied's own presence record
// carries, so an update report is checked against what archied compiled in
// rather than this process's build. A down or unreachable daemon, or a
// missing store, leaves the daemon unverified. The agent stays unverified:
// only archied observes it.
func runningVersions(ctx context.Context, store storecontract.PresenceStore, timeout time.Duration) func() map[string]string {
return func() map[string]string {
if store == nil {
return nil
}
if timeout <= 0 {
timeout = 5 * time.Second
}
callCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
records, err := store.ListPresence(callCtx)
if err != nil {
return nil
}
for _, service := range presence.Mesh(records, time.Now()) {
if service.Service == presence.Daemon && service.State != presence.StateDown {
return map[string]string{releaseupdate.ComponentDaemon: service.Version}
}
}
return nil
}
}
// gatewayVersionReporter renders /version from the Gateway's build info,
// fetched per call with a timeout.
func gatewayVersionReporter(ctx context.Context, chat messaging.ChatContract, timeout time.Duration) func() string {
@@ -91,26 +60,6 @@ func gatewayVersionReporter(ctx context.Context, chat messaging.ChatContract, ti
}
}
// updateService builds /update from [chat.telegram] commands, or nil when
// none are configured.
func updateService(cfg ResolvedConfig) *releaseupdate.Service {
if len(cfg.Telegram.UpdateCheckCommand) == 0 {
return nil
}
updates := &releaseupdate.Service{
Catalog: releaseupdate.CommandCatalog{Command: cfg.Telegram.UpdateCheckCommand},
StatePath: filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"),
InstallType: installtype.Type(),
}
if len(cfg.Telegram.UpdateInstallCommand) != 0 {
updates.Installer = releaseupdate.CommandInstaller{
Command: cfg.Telegram.UpdateInstallCommand,
HealthURL: cfg.HealthURL,
}
}
return updates
}
// telegramReloader re-resolves the token and allowlist from this service's own
// configuration on /restart. A reload that cannot produce a token is refused so
// the running bot keeps the credential it is already authenticated with.
+6 -2
View File
@@ -5,6 +5,7 @@ import (
"log/slog"
"time"
"github.com/samcharles93/archie-core/internal/app/servicekit"
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
"github.com/samcharles93/archie-core/internal/domain/access"
"github.com/samcharles93/archie-core/internal/domain/health"
@@ -17,6 +18,7 @@ import (
infraaccess "github.com/samcharles93/archie-core/internal/infrastructure/access"
"github.com/samcharles93/archie-core/internal/infrastructure/captureintake"
"github.com/samcharles93/archie-core/internal/infrastructure/gatewayrpc"
"github.com/samcharles93/archie-core/internal/releaseupdate"
"github.com/samcharles93/archie-core/internal/webhookguard"
"github.com/samcharles93/archie-core/internal/webui"
)
@@ -29,6 +31,7 @@ type deps struct {
Log *slog.Logger
Store storecontract.TaskStore
Chat messaging.ChatContract
Updates *releaseupdate.Service
Health *health.Registry
ControlPlane controlpb.ControlPlaneServiceClient
Identities identity.Repository
@@ -48,7 +51,7 @@ type deps struct {
// compose builds the dashboard server from contract-backed dependencies.
// Unset fields answer 501/503 or empty.
func compose(d deps) *webui.Server {
func compose(ctx context.Context, d deps) *webui.Server {
srv := &webui.Server{
Store: d.Store,
Log: d.Log,
@@ -88,6 +91,7 @@ func compose(d deps) *webui.Server {
wireOrgSurface(srv, d.Store)
if presence, ok := d.Store.(storecontract.PresenceStore); ok {
srv.Presence = presence
srv.RunningVersions = servicekit.RunningVersions(ctx, presence, 0)
}
if applyStatus, ok := d.Store.(storecontract.ApplyStatusStore); ok {
srv.ApplyStatus = applyStatus
@@ -107,7 +111,7 @@ func compose(d deps) *webui.Server {
srv.EventTypes = eventTypes
}
if d.Chat != nil {
srv.Chat = &webui.ChatService{Contract: d.Chat}
srv.Chat = &webui.ChatService{Contract: d.Chat, Updates: d.Updates}
}
wireCatalog(d, srv)
// The policy chain: wired together or not at all.
+5 -1
View File
@@ -8,6 +8,7 @@ import (
"net"
"net/http"
"os"
"path/filepath"
"slices"
"time"
@@ -18,6 +19,8 @@ import (
"github.com/samcharles93/archie-core/internal/domain/applystatus"
"github.com/samcharles93/archie-core/internal/domain/presence"
infraaccess "github.com/samcharles93/archie-core/internal/infrastructure/access"
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
"github.com/samcharles93/archie-core/internal/infrastructure/gatewayrpc"
"github.com/samcharles93/archie-core/internal/infrastructure/staterpc"
"github.com/samcharles93/archie-core/internal/webui"
@@ -82,11 +85,12 @@ func Run(ctx context.Context, options Options) error {
return err
}
srv := compose(deps{
srv := compose(ctx, deps{
Options: opts,
Log: log,
Store: tasks,
Chat: chat,
Updates: controlplanerpc.UpdateService(controlplanerpc.NewRPCClient(tasks.ControlPlane()), filepath.Join(configuration.DefaultWorkDir(), "ui-update-deferrals.json"), ""),
Health: newReadinessRegistry(opts, tasks, chat, chain, provider),
ControlPlane: tasks.ControlPlane(),
Identities: tasks,
@@ -9,6 +9,7 @@ import (
"github.com/samcharles93/archie-core/internal/domain/workintake"
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
"github.com/samcharles93/archie-core/internal/releaseupdate"
)
const (
@@ -18,6 +19,7 @@ const (
PluginSettingsKind = "plugin-settings"
ContainerRuntimePoliciesKind = "container-runtime-policies"
ExtensionSettingsKind = controlplanerpc.ExtensionSettingsKind
UpdateSettingsKind = controlplanerpc.UpdateSettingsKind
)
type schedulingPolicy struct {
@@ -34,7 +36,7 @@ type pluginSettings struct {
func operationalDefinitions() []Definition {
return []Definition{
{Kind: RepositoryPoliciesKind, Title: "Repository policies", ApplyMode: "live", Document: []config.Repo{}, Seed: func(cfg config.Config) any { return cfg.Repos }, Validate: validateRepositories},
{Kind: RepositoryPoliciesKind, Title: "Repository policies", ApplyMode: "live", Document: []config.Repo{}, Seed: func(cfg config.Config) any { return append([]config.Repo{}, cfg.Repos...) }, Validate: validateRepositories},
// Restart-required: the Messaging Service, which owns the channel
// transports, reconciles them live and archied re-layers each update, but
// the Gateway's chat surfaces (workspace tools, rate limit, model
@@ -59,6 +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},
// Live: the container pool reads these on every acquire and the dispatcher
// is resized on publish.
// Live: every check and install reads the channel afresh.
{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},
}
}
@@ -119,3 +123,10 @@ func validateScheduling(input []byte) error {
return nil
})
}
// validateUpdateSettings refuses a channel the update scripts cannot select.
func validateUpdateSettings(input []byte) error {
return validateAs(input, func(doc controlplanerpc.UpdateSettings) error {
return releaseupdate.ValidateChannel(doc.Channel, doc.Pin)
})
}
+38
View File
@@ -0,0 +1,38 @@
package servicekit
import (
"context"
"time"
"github.com/samcharles93/archie-core/internal/domain/presence"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/releaseupdate"
)
// RunningVersions reports the daemon version archied's own presence record
// carries, so an update report is checked against what archied compiled in
// rather than this process's build. A down or unreachable daemon, or a
// missing store, leaves the daemon unverified. The agent stays unverified:
// only archied observes it.
func RunningVersions(ctx context.Context, store storecontract.PresenceStore, timeout time.Duration) func() map[string]string {
return func() map[string]string {
if store == nil {
return nil
}
if timeout <= 0 {
timeout = 5 * time.Second
}
callCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
records, err := store.ListPresence(callCtx)
if err != nil {
return nil
}
for _, service := range presence.Mesh(records, time.Now()) {
if service.Service == presence.Daemon && service.State != presence.StateDown {
return map[string]string{releaseupdate.ComponentDaemon: service.Version}
}
}
return nil
}
}
-7
View File
@@ -534,8 +534,6 @@ func (c Config) Clone() Config {
c.Identities = cloneIdentities(c.Identities)
c.Chat.Models = append([]string(nil), c.Chat.Models...)
c.Chat.Telegram.AllowedUserIDs = append([]int64(nil), c.Chat.Telegram.AllowedUserIDs...)
c.Chat.Telegram.UpdateCheckCommand = append([]string(nil), c.Chat.Telegram.UpdateCheckCommand...)
c.Chat.Telegram.UpdateInstallCommand = append([]string(nil), c.Chat.Telegram.UpdateInstallCommand...)
c.Bindings.PreviousEncryptionKeys = append([]SecretRef(nil), c.Bindings.PreviousEncryptionKeys...)
c.Tools.MCPServers = cloneMCPServers(c.Tools.MCPServers)
// Services is a map of structs, so the header is shared by the value copy
@@ -918,11 +916,6 @@ type TelegramConfig struct {
// Token references the bot token from @BotFather through the configured
// secret engine. Empty disables the Telegram channel.
Token SecretRef `toml:"token" yaml:"token"`
// UpdateCheckCommand writes a releaseupdate.Snapshot JSON document to
// stdout. UpdateInstallCommand applies an already-approved update. Both
// are argv arrays, never shell snippets.
UpdateCheckCommand []string `toml:"update_check_command" yaml:"update_check_command"`
UpdateInstallCommand []string `toml:"update_install_command" yaml:"update_install_command"`
}
// Notify configures outbound notifications (n8n webhook → email etc.).
File diff suppressed because it is too large. Load diff
@@ -25,6 +25,7 @@ const (
ChatService_RecentTurns_FullMethodName = "/gateway.v1.ChatService/RecentTurns"
ChatService_Route_FullMethodName = "/gateway.v1.ChatService/Route"
ChatService_Stream_FullMethodName = "/gateway.v1.ChatService/Stream"
ChatService_Answer_FullMethodName = "/gateway.v1.ChatService/Answer"
ChatService_Cancel_FullMethodName = "/gateway.v1.ChatService/Cancel"
ChatService_StopTasks_FullMethodName = "/gateway.v1.ChatService/StopTasks"
ChatService_SetPersona_FullMethodName = "/gateway.v1.ChatService/SetPersona"
@@ -56,6 +57,7 @@ type ChatServiceClient interface {
RecentTurns(ctx context.Context, in *RecentTurnsRequest, opts ...grpc.CallOption) (*RecentTurnsResponse, error)
Route(ctx context.Context, in *RouteRequest, opts ...grpc.CallOption) (*RouteResponse, error)
Stream(ctx context.Context, in *StreamRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StreamResponse], error)
Answer(ctx context.Context, in *AnswerRequest, opts ...grpc.CallOption) (*AnswerResponse, error)
Cancel(ctx context.Context, in *CancelRequest, opts ...grpc.CallOption) (*CancelResponse, error)
StopTasks(ctx context.Context, in *StopTasksRequest, opts ...grpc.CallOption) (*StopTasksResponse, error)
SetPersona(ctx context.Context, in *SetPersonaRequest, opts ...grpc.CallOption) (*SetPersonaResponse, error)
@@ -154,6 +156,16 @@ func (c *chatServiceClient) Stream(ctx context.Context, in *StreamRequest, opts
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type ChatService_StreamClient = grpc.ServerStreamingClient[StreamResponse]
func (c *chatServiceClient) Answer(ctx context.Context, in *AnswerRequest, opts ...grpc.CallOption) (*AnswerResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AnswerResponse)
err := c.cc.Invoke(ctx, ChatService_Answer_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *chatServiceClient) Cancel(ctx context.Context, in *CancelRequest, opts ...grpc.CallOption) (*CancelResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CancelResponse)
@@ -354,6 +366,7 @@ type ChatServiceServer interface {
RecentTurns(context.Context, *RecentTurnsRequest) (*RecentTurnsResponse, error)
Route(context.Context, *RouteRequest) (*RouteResponse, error)
Stream(*StreamRequest, grpc.ServerStreamingServer[StreamResponse]) error
Answer(context.Context, *AnswerRequest) (*AnswerResponse, error)
Cancel(context.Context, *CancelRequest) (*CancelResponse, error)
StopTasks(context.Context, *StopTasksRequest) (*StopTasksResponse, error)
SetPersona(context.Context, *SetPersonaRequest) (*SetPersonaResponse, error)
@@ -401,6 +414,9 @@ func (UnimplementedChatServiceServer) Route(context.Context, *RouteRequest) (*Ro
func (UnimplementedChatServiceServer) Stream(*StreamRequest, grpc.ServerStreamingServer[StreamResponse]) error {
return status.Error(codes.Unimplemented, "method Stream not implemented")
}
func (UnimplementedChatServiceServer) Answer(context.Context, *AnswerRequest) (*AnswerResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Answer not implemented")
}
func (UnimplementedChatServiceServer) Cancel(context.Context, *CancelRequest) (*CancelResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Cancel not implemented")
}
@@ -580,6 +596,24 @@ func _ChatService_Stream_Handler(srv interface{}, stream grpc.ServerStream) erro
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type ChatService_StreamServer = grpc.ServerStreamingServer[StreamResponse]
func _ChatService_Answer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AnswerRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ChatServiceServer).Answer(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: ChatService_Answer_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ChatServiceServer).Answer(ctx, req.(*AnswerRequest))
}
return interceptor(ctx, in, info, handler)
}
func _ChatService_Cancel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CancelRequest)
if err := dec(in); err != nil {
@@ -949,6 +983,10 @@ var ChatService_ServiceDesc = grpc.ServiceDesc{
MethodName: "Route",
Handler: _ChatService_Route_Handler,
},
{
MethodName: "Answer",
Handler: _ChatService_Answer_Handler,
},
{
MethodName: "Cancel",
Handler: _ChatService_Cancel_Handler,
+3 -1
View File
@@ -17,7 +17,9 @@ type ChatSnapshot struct {
Version string
RestartAvailable bool
CancellationAvailable bool
PersonasAvailable bool
// VoiceAvailable reports that a voice clip is transcribed into the turn.
VoiceAvailable bool
PersonasAvailable bool
}
// ChatReply is the blocking reply from Route.
+3 -1
View File
@@ -25,6 +25,8 @@ type LocalChatAdapter struct {
TaskActor ChatTaskActor
// Tasks reads the tasks /stop acts on.
Tasks TaskReader
// VoiceAvailable reports that voice clips are transcribed.
VoiceAvailable bool
}
// TaskReader is the task reads /stop needs.
@@ -42,7 +44,7 @@ func (a *LocalChatAdapter) Snapshot(ctx context.Context) (ChatSnapshot, error) {
if err != nil {
return ChatSnapshot{}, err
}
s := ChatSnapshot{Sessions: sessions, Models: []string{}, Providers: []string{}, Personas: []string{}, ModelsByProvider: map[string][]string{}, ActivePersonas: map[string]string{}, RestartAvailable: a.Router.Restart != nil, CancellationAvailable: a.Turns != nil, PersonasAvailable: a.Personas != nil, Version: a.Router.Version}
s := ChatSnapshot{Sessions: sessions, Models: []string{}, Providers: []string{}, Personas: []string{}, ModelsByProvider: map[string][]string{}, ActivePersonas: map[string]string{}, RestartAvailable: a.Router.Restart != nil, CancellationAvailable: a.Turns != nil, PersonasAvailable: a.Personas != nil, VoiceAvailable: a.VoiceAvailable, Version: a.Router.Version}
if a.Models != nil {
s.Models = slices.Clone(a.Models.Models())
s.ActiveModel = a.Models.ActiveModel()
@@ -80,11 +80,10 @@ func RuntimeChatConfigFrom(ctx context.Context, reader ResourceReader, base conf
if err := json.Unmarshal(value, &settings); err != nil {
return err
}
check, install := base.Telegram.UpdateCheckCommand, base.Telegram.UpdateInstallCommand
out = config.ChatConfig{
Operator: settings.Operator, ShowToolCalls: settings.ShowToolCalls, MaxSteps: settings.MaxSteps,
Models: settings.Models,
Telegram: config.TelegramConfig{AllowedUserIDs: settings.Telegram.AllowedUserIDs, Token: settings.Telegram.Token, UpdateCheckCommand: check, UpdateInstallCommand: install},
Telegram: config.TelegramConfig{AllowedUserIDs: settings.Telegram.AllowedUserIDs, Token: settings.Telegram.Token},
RateLimit: config.RateLimitConfig{Window: time.Duration(settings.RateLimit.Window), MaxRequests: settings.RateLimit.MaxRequests},
UnrestrictedFilesystem: settings.UnrestrictedFilesystem, Workspace: settings.Workspace,
}
@@ -2,11 +2,14 @@ package controlplanerpc
import (
"bytes"
"context"
"encoding/json"
"fmt"
"time"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/installtype"
"github.com/samcharles93/archie-core/internal/releaseupdate"
)
// ChannelSettings is the channel-settings resource document, with
@@ -105,3 +108,36 @@ func (d *ChannelDuration) UnmarshalJSON(data []byte) error {
*d = ChannelDuration(nanos)
return nil
}
// UpdateSettingsKind holds which releases the update scripts select.
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 checks GitHub on the stored release channel and installs
// through the script beside this binary. statePath keeps each recipient's
// deferrals; healthURL reaches the installer.
func UpdateService(reader ResourceReader, statePath, healthURL string) *releaseupdate.Service {
return &releaseupdate.Service{
Catalog: &releaseupdate.GitHubCatalog{Channel: updateChannel(reader)},
Installer: releaseupdate.ScriptInstaller{HealthURL: healthURL},
StatePath: statePath,
InstallType: installtype.Type(),
}
}
// updateChannel reads the update-settings resource. An unstored kind is the
// stable channel.
func updateChannel(reader ResourceReader) func(context.Context) (string, string, error) {
return func(ctx context.Context) (string, string, error) {
settings := UpdateSettings{Channel: "stable"}
_, _, err := reader.Query(ctx, UpdateSettingsKind, func(value []byte) error {
return json.Unmarshal(value, &settings)
})
return settings.Channel, settings.Pin, err
}
}
@@ -53,6 +53,15 @@ func confinedCommand(ctx context.Context, binary *os.File, socket string) (*exec
return cmd, nil
}
// openCommand runs the verified binary by its open descriptor with the host's
// network, for a package that declares no egress hosts.
func openCommand(ctx context.Context, binary *os.File) *exec.Cmd {
path := fmt.Sprintf("/proc/%d/fd/%d", os.Getpid(), binary.Fd())
cmd := exec.CommandContext(ctx, path) //nolint:gosec // the host-verified binary, by descriptor
cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGKILL}
return cmd
}
// launch runs inside the namespace: loopback up, relay listening, then the
// extension from descriptor 3 with every capability gone.
func launch(socket string) int {
@@ -14,3 +14,7 @@ import (
func confinedCommand(context.Context, *os.File, string) (*exec.Cmd, error) {
return nil, errors.New("extensions need Linux network namespaces to confine their egress")
}
func openCommand(ctx context.Context, binary *os.File) *exec.Cmd {
return exec.CommandContext(ctx, binary.Name()) //nolint:gosec // the host-verified binary
}
+27 -10
View File
@@ -11,6 +11,7 @@ import (
"fmt"
"io"
"os"
"os/exec"
"sync"
"github.com/hashicorp/go-hclog"
@@ -36,9 +37,9 @@ type Spec struct {
// Env names the host environment variables the extension may see. PATH and
// HOME are always passed so a plugin can find the CLI it wraps.
Env []string
// Egress is the accepted egress host list. The extension runs in its own
// network namespace and reaches only these hosts, through a proxy; an
// empty list reaches nothing.
// Egress is the accepted egress host list. When it names hosts, the
// extension runs in its own network namespace and reaches only these,
// through a proxy; an empty list runs it on the host's network.
Egress []string
}
@@ -58,7 +59,28 @@ type proc struct {
func (p *proc) kill() {
p.client.Kill()
p.gate.close()
if p.gate != nil {
p.gate.close()
}
}
// command confines the extension to egress when the package declares hosts.
// A package that declares none opted out of confinement and gets the host's
// network, with no gate.
func command(ctx context.Context, binary *os.File, egress []string) (*exec.Cmd, *gate, error) {
if len(egress) == 0 {
return openCommand(ctx, binary), nil, nil
}
g, err := openGate(ctx, egress)
if err != nil {
return nil, nil, fmt.Errorf("egress: %w", err)
}
cmd, err := confinedCommand(ctx, binary, g.socket)
if err != nil {
g.close()
return nil, nil, err
}
return cmd, g, nil
}
// NewHost returns a Host that reports plugin lifecycle problems to log.
@@ -81,13 +103,8 @@ func (h *Host) Start(ctx context.Context, spec Spec, surface string, impl goplug
return nil, fmt.Errorf("extension %q: %w", spec.Name, err)
}
defer func() { _ = binary.Close() }()
g, err := openGate(ctx, spec.Egress)
cmd, g, err := command(ctx, binary, spec.Egress)
if err != nil {
return nil, fmt.Errorf("extension %q: egress: %w", spec.Name, err)
}
cmd, err := confinedCommand(ctx, binary, g.socket)
if err != nil {
g.close()
return nil, fmt.Errorf("extension %q: %w", spec.Name, err)
}
cmd.Env = passEnv(spec.Env)
+145
View File
@@ -0,0 +1,145 @@
package gatewayrpc
import (
"context"
"crypto/rand"
"encoding/hex"
"errors"
"strings"
"sync"
pb "github.com/samcharles93/archie-core/internal/contracts/gateway/v1"
"github.com/samcharles93/archie-core/internal/domain/messaging"
)
// Answers to the asks a turn is blocked on, keyed by ask id. A channel's
// requesters live in the caller's process, so a turn asks over its stream and
// the caller answers through the Answer RPC.
type pendingAsks struct {
mu sync.Mutex
waiting map[string]chan string
}
func (p *pendingAsks) open() (string, chan string) {
var b [12]byte
_, _ = rand.Read(b[:])
id := hex.EncodeToString(b[:])
ch := make(chan string, 1)
p.mu.Lock()
if p.waiting == nil {
p.waiting = make(map[string]chan string)
}
p.waiting[id] = ch
p.mu.Unlock()
return id, ch
}
func (p *pendingAsks) close(id string) {
p.mu.Lock()
delete(p.waiting, id)
p.mu.Unlock()
}
func (p *pendingAsks) answer(id, answer string) bool {
p.mu.Lock()
ch, ok := p.waiting[id]
p.mu.Unlock()
if !ok {
return false
}
select {
case ch <- answer:
default:
}
return true
}
// remoteAsker poses a turn's questions on its stream. send is serialized with
// the turn's own frames by the caller.
type remoteAsker struct {
pending *pendingAsks
send func(*pb.StreamResponse) error
}
func (a remoteAsker) ask(ctx context.Context, q *pb.Ask) (string, error) {
id, ch := a.pending.open()
defer a.pending.close(id)
q.Id = id
if err := a.send(&pb.StreamResponse{Kind: "ask", Ask: q}); err != nil {
return "", err
}
select {
case answer := <-ch:
return answer, nil
case <-ctx.Done():
return "", ctx.Err()
}
}
func (a remoteAsker) RequestApproval(ctx context.Context, action, description string) (messaging.ApprovalDecision, error) {
answer, err := a.ask(ctx, &pb.Ask{Kind: "approval", Prompt: action, Detail: description})
if err != nil {
return messaging.ApprovalDenied, err
}
switch answer {
case "approve":
return messaging.ApprovalApproved, nil
case "always":
return messaging.ApprovalPermanentlyApproved, nil
default:
return messaging.ApprovalDenied, nil
}
}
func (a remoteAsker) RequestClarification(ctx context.Context, req messaging.ClarifyRequest) (string, error) {
answer, err := a.ask(ctx, &pb.Ask{Kind: "clarify", Prompt: req.Question, Choices: choicesProto(req.Suggestions)})
if err != nil {
return "", err
}
if answer = strings.TrimSpace(answer); answer == "" {
return "", messaging.ErrEmptyReply
}
return answer, nil
}
func (a remoteAsker) RequestChoice(ctx context.Context, req messaging.PickerRequest) (messaging.InteractiveChoice, error) {
if len(req.Options) == 0 {
return messaging.InteractiveChoice{}, messaging.ErrNoPickerOptions
}
answer, err := a.ask(ctx, &pb.Ask{Kind: "picker", Prompt: req.Prompt, Choices: choicesProto(req.Options)})
if err != nil {
return messaging.InteractiveChoice{}, err
}
for _, option := range req.Options {
if option.ID == answer {
return option, nil
}
}
return messaging.InteractiveChoice{}, errors.New("picker answer matches no option")
}
func choicesProto(choices []messaging.InteractiveChoice) []*pb.Choice {
out := make([]*pb.Choice, 0, len(choices))
for _, c := range choices {
out = append(out, &pb.Choice{Id: c.ID, Label: c.Label})
}
return out
}
// withAsks puts on ctx the requesters the caller said it can answer.
func withAsks(ctx context.Context, r *pb.StreamRequest, asker remoteAsker) context.Context {
if r.CanApprove {
ctx = messaging.WithApprovalRequester(ctx, asker)
}
var interactive messaging.Interactive
if r.CanClarify {
interactive.Clarifier = asker
}
if r.CanPick {
interactive.Picker = asker
}
if interactive.Carries() {
ctx = messaging.WithInteractive(ctx, interactive)
}
return ctx
}
@@ -0,0 +1,93 @@
package gatewayrpc
import (
"context"
"net"
"testing"
"time"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/test/bufconn"
"github.com/samcharles93/archie-core/internal/domain/messaging"
)
// askingChat is a turn that asks for approval and reports what it got.
type askingChat struct{ messaging.ChatContract }
func (askingChat) Stream(ctx context.Context, _ messaging.Inbound) (<-chan messaging.ChatEvent, error) {
out := make(chan messaging.ChatEvent, 1)
go func() {
defer close(out)
approver := messaging.ApprovalFromContext(ctx)
if approver == nil {
out <- messaging.ChatEvent{Kind: "done", Text: "not configured"}
return
}
decision, err := approver.RequestApproval(ctx, "shell", "rm -rf /tmp/x")
switch {
case err != nil:
out <- messaging.ChatEvent{Kind: "done", Text: "error"}
case decision == messaging.ApprovalDenied:
out <- messaging.ChatEvent{Kind: "done", Text: "denied"}
default:
out <- messaging.ChatEvent{Kind: "done", Text: "approved"}
}
}()
return out, nil
}
type fixedApprover messaging.ApprovalDecision
func (f fixedApprover) RequestApproval(context.Context, string, string) (messaging.ApprovalDecision, error) {
return messaging.ApprovalDecision(f), nil
}
// TestStreamCarriesApproval: an approval-gated turn in the gateway reaches the
// caller's own approver, and a caller with none is never asked.
func TestStreamCarriesApproval(t *testing.T) {
listener := bufconn.Listen(1 << 16)
srv := grpc.NewServer()
RegisterServer(srv, askingChat{}, nil, Catalog{})
go func() { _ = srv.Serve(listener) }()
t.Cleanup(srv.Stop)
conn, err := grpc.NewClient("passthrough:///bufnet",
grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { return listener.Dial() }),
grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = conn.Close() })
client := NewClient(conn)
tests := []struct {
name string
approver messaging.ApprovalRequester
want string
}{
{name: "approved by the caller", approver: fixedApprover(messaging.ApprovalApproved), want: "approved"},
{name: "denied by the caller", approver: fixedApprover(messaging.ApprovalDenied), want: "denied"},
{name: "a caller with no approver is not asked", want: "not configured"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if tt.approver != nil {
ctx = messaging.WithApprovalRequester(ctx, tt.approver)
}
events, err := client.Stream(ctx, messaging.Inbound{})
if err != nil {
t.Fatal(err)
}
var got string
for event := range events {
got = event.Text
}
if got != tt.want {
t.Fatalf("turn saw %q, want %q", got, tt.want)
}
})
}
}
+53 -1
View File
@@ -123,7 +123,14 @@ func (c *Client) ApplyOperatorTaskAction(ctx context.Context, actor taskactions.
}
func (c *Client) Stream(ctx context.Context, in messaging.Inbound) (<-chan messaging.ChatEvent, error) {
stream, err := c.client.Stream(ctx, &pb.StreamRequest{Message: inboundProto(in)})
approver := messaging.ApprovalFromContext(ctx)
interactive := messaging.InteractiveFromContext(ctx)
stream, err := c.client.Stream(ctx, &pb.StreamRequest{
Message: inboundProto(in),
CanApprove: approver != nil,
CanClarify: interactive.Clarifier != nil,
CanPick: interactive.Picker != nil,
})
if err != nil {
return nil, err
}
@@ -135,6 +142,11 @@ func (c *Client) Stream(ctx context.Context, in messaging.Inbound) (<-chan messa
if errors.Is(err, io.EOF) {
return
}
if err == nil && v.GetAsk() != nil {
// The turn blocks on this; keep receiving while the human answers.
go c.answer(ctx, v.GetAsk(), approver, interactive)
continue
}
var event messaging.ChatEvent
if err != nil {
event = messaging.ChatEvent{Kind: "error", Text: err.Error()}
@@ -153,3 +165,43 @@ func (c *Client) Stream(ctx context.Context, in messaging.Inbound) (<-chan messa
}()
return out, nil
}
// answer puts ask to the channel's own requester and returns its reply. A
// failed or abandoned ask answers deny or empty, which the turn reads as no.
func (c *Client) answer(ctx context.Context, ask *pb.Ask, approver messaging.ApprovalRequester, interactive messaging.Interactive) {
var reply string
switch ask.GetKind() {
case "approval":
if approver != nil {
decision, err := approver.RequestApproval(ctx, ask.GetPrompt(), ask.GetDetail())
switch {
case err != nil || decision == messaging.ApprovalDenied:
reply = "deny"
case decision == messaging.ApprovalPermanentlyApproved:
reply = "always"
default:
reply = "approve"
}
}
case "clarify":
if interactive.Clarifier != nil {
reply, _ = interactive.Clarifier.RequestClarification(ctx, messaging.ClarifyRequest{Question: ask.GetPrompt(), Suggestions: choicesValue(ask.GetChoices())})
}
case "picker":
if interactive.Picker != nil {
choice, err := interactive.Picker.RequestChoice(ctx, messaging.PickerRequest{Prompt: ask.GetPrompt(), Options: choicesValue(ask.GetChoices())})
if err == nil {
reply = choice.ID
}
}
}
_, _ = c.client.Answer(ctx, &pb.AnswerRequest{AskId: ask.GetId(), Answer: reply})
}
func choicesValue(choices []*pb.Choice) []messaging.InteractiveChoice {
out := make([]messaging.InteractiveChoice, 0, len(choices))
for _, c := range choices {
out = append(out, messaging.InteractiveChoice{ID: c.GetId(), Label: c.GetLabel()})
}
return out
}
+16 -2
View File
@@ -2,6 +2,7 @@ package gatewayrpc
import (
"context"
"sync"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
@@ -19,6 +20,7 @@ type server struct {
chat messaging.ChatContract
sessions messaging.SessionStore
catalog Catalog
asks pendingAsks
}
// RegisterServer serves the Gateway chat contract. catalog supplies the
@@ -259,7 +261,15 @@ func (s *server) SearchMessages(ctx context.Context, r *pb.SearchMessagesRequest
}
func (s *server) Stream(r *pb.StreamRequest, out grpc.ServerStreamingServer[pb.StreamResponse]) error {
events, err := s.chat.Stream(out.Context(), inboundValue(r.Message))
// An ask is sent from the turn's goroutine while this one sends events.
var sendMu sync.Mutex
send := func(v *pb.StreamResponse) error {
sendMu.Lock()
defer sendMu.Unlock()
return out.Send(v)
}
ctx := withAsks(out.Context(), r, remoteAsker{pending: &s.asks, send: send})
events, err := s.chat.Stream(ctx, inboundValue(r.Message))
if err != nil {
return err
}
@@ -271,9 +281,13 @@ func (s *server) Stream(r *pb.StreamRequest, out grpc.ServerStreamingServer[pb.S
if !ok {
return nil
}
if err := out.Send(eventProto(event)); err != nil {
if err := send(eventProto(event)); err != nil {
return err
}
}
}
}
func (s *server) Answer(_ context.Context, r *pb.AnswerRequest) (*pb.AnswerResponse, error) {
return &pb.AnswerResponse{Found: s.asks.answer(r.AskId, r.Answer)}, nil
}
+2 -2
View File
@@ -257,7 +257,7 @@ func snapshotProto(v messaging.ChatSnapshot) *pb.SnapshotResponse {
for k, list := range v.ModelsByProvider {
groups[k] = &pb.StringList{Values: list}
}
return &pb.SnapshotResponse{Sessions: mapValues(v.Sessions, sessionProto), Models: v.Models, ModelsByProvider: groups, Providers: v.Providers, ActiveModel: v.ActiveModel, ActiveProvider: v.ActiveProvider, Personas: v.Personas, ActivePersonas: v.ActivePersonas, RestartAvailable: v.RestartAvailable, CancellationAvailable: v.CancellationAvailable, PersonasAvailable: v.PersonasAvailable, Version: v.Version}
return &pb.SnapshotResponse{Sessions: mapValues(v.Sessions, sessionProto), Models: v.Models, ModelsByProvider: groups, Providers: v.Providers, ActiveModel: v.ActiveModel, ActiveProvider: v.ActiveProvider, Personas: v.Personas, ActivePersonas: v.ActivePersonas, RestartAvailable: v.RestartAvailable, CancellationAvailable: v.CancellationAvailable, PersonasAvailable: v.PersonasAvailable, VoiceAvailable: v.VoiceAvailable, Version: v.Version}
}
func snapshotValue(v *pb.SnapshotResponse) messaging.ChatSnapshot {
@@ -265,5 +265,5 @@ func snapshotValue(v *pb.SnapshotResponse) messaging.ChatSnapshot {
for k, list := range v.ModelsByProvider {
groups[k] = list.GetValues()
}
return messaging.ChatSnapshot{Sessions: mapValues(v.Sessions, sessionValue), Models: v.Models, ModelsByProvider: groups, Providers: v.Providers, ActiveModel: v.ActiveModel, ActiveProvider: v.ActiveProvider, Personas: v.Personas, ActivePersonas: v.ActivePersonas, RestartAvailable: v.RestartAvailable, CancellationAvailable: v.CancellationAvailable, PersonasAvailable: v.PersonasAvailable, Version: v.Version}
return messaging.ChatSnapshot{Sessions: mapValues(v.Sessions, sessionValue), Models: v.Models, ModelsByProvider: groups, Providers: v.Providers, ActiveModel: v.ActiveModel, ActiveProvider: v.ActiveProvider, Personas: v.Personas, ActivePersonas: v.ActivePersonas, RestartAvailable: v.RestartAvailable, CancellationAvailable: v.CancellationAvailable, PersonasAvailable: v.PersonasAvailable, VoiceAvailable: v.VoiceAvailable, Version: v.Version}
}
@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"log/slog"
"maps"
"os"
"path/filepath"
"slices"
@@ -39,10 +40,21 @@ type Runner struct {
// outcome. Nil reports nothing.
report func(ctx context.Context, version int64, err error)
// changed runs after a sync starts or stops an engine, so a service can
// resolve again the references that engine answers. Nil does nothing.
changed func()
mu sync.Mutex
running map[string]runningEngine
}
// OnChange makes every sync that starts or stops an engine call changed.
func (r *Runner) OnChange(changed func()) {
r.mu.Lock()
r.changed = changed
r.mu.Unlock()
}
type runningEngine struct {
digest string
settings string
@@ -96,6 +108,12 @@ func (r *Runner) apply(ctx context.Context, settings map[string]controlplanerpc.
}
r.mu.Lock()
defer r.mu.Unlock()
before := r.runningDigests()
defer func() {
if r.changed != nil && !maps.Equal(before, r.runningDigests()) {
go r.changed()
}
}()
var problems []error
want := make(map[string]bool)
@@ -121,6 +139,14 @@ func (r *Runner) apply(ctx context.Context, settings map[string]controlplanerpc.
return errors.Join(problems...)
}
func (r *Runner) runningDigests() map[string]string {
out := make(map[string]string, len(r.running))
for name, engine := range r.running {
out[name] = engine.digest
}
return out
}
func secretEngines(d storepkg.Descriptor) []storepkg.Extension {
var out []storepkg.Extension
for _, extension := range d.Contributes.Extensions {
@@ -158,10 +158,13 @@ func TestHostLaunch(t *testing.T) {
key string
want string
wantErr string
// open runs the package with no declared egress hosts.
open bool
}{
{name: "an accepted egress host is reachable through the proxy", sha: good, key: "GET:http://" + accepted, want: "reached"},
{name: "a host that was not accepted is refused", sha: good, key: "GET:http://" + other, want: "403 Forbidden"},
{name: "a direct connection bypassing the proxy fails", sha: good, key: "DIAL:" + accepted, want: "dial failed"},
{name: "a package declaring no egress hosts dials directly", sha: good, key: "DIAL:" + accepted, want: "connected", open: true},
{name: "loopback is refused even when accepted", sha: good, key: "GET:http://" + loopback, want: "502 Bad Gateway"},
{name: "settings reach the engine", sha: good, key: "color", want: "blue"},
{name: "an unknown key is not found", sha: good, key: "missing", wantErr: "not found"},
@@ -174,6 +177,9 @@ func TestHostLaunch(t *testing.T) {
host := extension.NewHost(hclog.NewNullLogger())
t.Cleanup(host.Close)
spec := extension.Spec{Name: "echo", Path: os.Args[0], SHA256: tt.sha, Env: []string{"ARCHIE_TEST_PASSED"}, Egress: []string{accepted, loopback}}
if tt.open {
spec.Egress = nil
}
engine, err := Start(context.Background(), host, spec, map[string]string{"color": "blue"})
if tt.sha != good {
if err == nil || !strings.Contains(err.Error(), tt.wantErr) {
@@ -253,6 +259,16 @@ func TestRunnerRunsOnlyWhatIsAcceptedAndEnabled(t *testing.T) {
runner := NewRunner(host, registry, Source{Query: source, Packages: source}, t.TempDir(), slog.New(slog.DiscardHandler))
t.Cleanup(runner.Close)
ctx := context.Background()
changes := make(chan struct{}, 4)
runner.OnChange(func() { changes <- struct{}{} })
changed := func() bool {
select {
case <-changes:
return true
case <-time.After(time.Second):
return false
}
}
registered := func() bool { _, ok := registry.Get("echo"); return ok }
sync := func() {
@@ -267,6 +283,9 @@ func TestRunnerRunsOnlyWhatIsAcceptedAndEnabled(t *testing.T) {
if registered() {
t.Fatal("an extension whose authority was never accepted must not run")
}
if len(changes) > 0 {
t.Fatal("a sync that started nothing must not report a change")
}
source.pkg.AcceptedAuthority = &storepkg.Authority{}
sync()
@@ -274,10 +293,16 @@ func TestRunnerRunsOnlyWhatIsAcceptedAndEnabled(t *testing.T) {
if err != nil || got != "v" {
t.Fatalf("accepted and enabled: Resolve = %q, %v; want v", got, err)
}
if !changed() {
t.Fatal("starting an engine must report a change, so references resolve again")
}
source.settings.Extensions[0].Enabled = false
sync()
if registered() || host.Alive("echo") {
t.Fatal("a disabled extension must be unregistered and its process stopped")
}
if !changed() {
t.Fatal("stopping an engine must report a change")
}
}
+7 -41
View File
@@ -2,53 +2,19 @@ package releaseupdate
import (
"fmt"
"regexp"
"strings"
"golang.org/x/mod/semver"
)
// SelectRelease compares release versions, never git-describe strings. Exact
// pins still have to exist in the catalog; a pin cannot invent a release.
func SelectRelease(tags []string, channel, pin string) (string, error) {
if channel == "" {
channel = "stable"
}
// 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)
return fmt.Errorf("unknown release channel %q", channel)
}
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]+([+-].*)?$`)
newest := ""
for _, tag := range tags {
tag = strings.TrimPrefix(tag, "refs/tags/")
tag = strings.TrimPrefix(tag, "archied/")
if !fullVersion.MatchString(tag) || !semver.IsValid(tag) {
continue
}
if !releaseMatchesChannel(tag, channel, pin) {
continue
}
if semver.Compare(tag, newest) > 0 {
newest = tag
}
}
if newest == "" {
return "", fmt.Errorf("no release found for channel %s (pin %s)", channel, pin)
}
return strings.TrimPrefix(newest, "v"), nil
}
func releaseMatchesChannel(tag, channel, pin string) bool {
switch channel {
case "stable":
return semver.Prerelease(tag) == ""
case "exact-pin":
return tag == "v"+pin
default:
return true
if channel == "exact-pin" && !semver.IsValid("v"+strings.TrimPrefix(pin, "v")) {
return fmt.Errorf("exact-pin requires a semantic version")
}
return nil
}
-24
View File
@@ -1,24 +0,0 @@
package releaseupdate
import "testing"
func TestSelectRelease(t *testing.T) {
tags := []string{"archied/v1.9.0", "v1.10.0", "archied/v2.0.0-rc.2", "v2.0.0-rc.10", "archie/v9.0.0", "nonsense"}
for _, tc := range []struct{ channel, pin, want string }{
{"stable", "", "1.10.0"},
{"", "", "1.10.0"},
{"next", "", "2.0.0-rc.10"},
{"exact-pin", "1.9.0", "1.9.0"},
{"exact-pin", "2.0.0-rc.2", "2.0.0-rc.2"},
{"exact-pin", "9.0.0", ""},
{"exact-pin", "", ""},
{"invalid", "", ""},
} {
t.Run(tc.channel+tc.pin, func(t *testing.T) {
got, err := SelectRelease(tags, tc.channel, tc.pin)
if got != tc.want || (err != nil) != (tc.want == "") {
t.Fatalf("got %q, %v; want %q", got, err, tc.want)
}
})
}
}
+34 -28
View File
@@ -5,8 +5,11 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
)
@@ -16,34 +19,6 @@ import (
// as-is.
const updateResultSentinel = "ARCHIE_UPDATE_RESULT "
// CommandCatalog reads a Snapshot JSON document from an explicitly configured
// argv command. It never invokes a shell; deployment tooling remains an
// administrator-owned adapter.
type CommandCatalog struct {
Command []string
ReleaseChannel string
Pin string
}
func (c CommandCatalog) Check(ctx context.Context) (Snapshot, error) {
if len(c.Command) == 0 {
return Snapshot{}, fmt.Errorf("update check command is empty")
}
cmd := exec.CommandContext(ctx, c.Command[0], c.Command[1:]...)
if c.ReleaseChannel != "" {
cmd.Env = append(cmd.Environ(), "ARCHIE_UPDATE_RELEASE_CHANNEL="+c.ReleaseChannel, "ARCHIE_UPDATE_PIN="+c.Pin)
}
output, err := cmd.Output()
if err != nil {
return Snapshot{}, fmt.Errorf("run update check: %w", err)
}
var snapshot Snapshot
if err := json.Unmarshal(output, &snapshot); err != nil {
return Snapshot{}, fmt.Errorf("decode update check output: %w", err)
}
return snapshot, nil
}
// CommandInstaller runs the deployment's install command. HealthURL is
// passed as ARCHIE_HEALTH_URL when set.
type CommandInstaller struct {
@@ -133,3 +108,34 @@ func componentVersions(snapshot Snapshot) map[string]Component {
}
return versions
}
// ErrNotConfigured is returned when the step's command is unset.
var ErrNotConfigured = errors.New("updates are not configured")
// ScriptInstaller runs the install script a release places beside this binary.
type ScriptInstaller struct {
HealthURL string
}
func (s ScriptInstaller) path() string {
exe, err := os.Executable()
if err != nil {
return ""
}
path := filepath.Join(filepath.Dir(exe), "archie-update-install")
if info, err := os.Stat(path); err != nil || info.Mode()&0o111 == 0 {
return ""
}
return path
}
func (s ScriptInstaller) Install(ctx context.Context, snapshot Snapshot, meta InstallMeta, progress func(string)) (Result, error) {
path := s.path()
if path == "" {
return Result{}, ErrNotConfigured
}
return CommandInstaller{Command: []string{path}, HealthURL: s.HealthURL}.Install(ctx, snapshot, meta, progress)
}
// Installable reports whether the install script is present.
func (s ScriptInstaller) Installable(context.Context) bool { return s.path() != "" }
+214
View File
@@ -0,0 +1,214 @@
package releaseupdate
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"os"
"path/filepath"
"regexp"
"strings"
"sync"
"time"
"golang.org/x/mod/semver"
"github.com/samcharles93/archie-core/internal/buildinfo"
)
// ReleaseSlug is the repository releases are published to.
const ReleaseSlug = "samcharles93/archie-core"
const changelogURL = "https://github.com/" + ReleaseSlug + "/blob/main/CHANGELOG.md"
// buildSuffix is the git-describe tail of an untagged build (1.7.0-4-g0736708).
var buildSuffix = regexp.MustCompile(`-[0-9]+-g[0-9a-f]+$`)
// GitHubCatalog finds the newest release on the selected channel that ships a
// linux-amd64 zip, and reports it against this build. Only one version covers
// every component, so the daemon and agent are offered the same release.
type GitHubCatalog struct {
// Channel returns the release channel and pin in force.
Channel func(context.Context) (channel, pin string, err error)
// A found release is reused for checkTTL: unauthenticated GitHub API
// calls are limited to 60 an hour per address.
mu sync.Mutex
key string
at time.Time
release *release
}
const checkTTL = 10 * time.Minute
func (c *GitHubCatalog) Check(ctx context.Context) (Snapshot, error) {
channel, pin, err := c.Channel(ctx)
if err != nil {
return Snapshot{}, err
}
if channel == "" {
channel = "stable"
}
release, err := c.detect(ctx, channel, pin)
if err != nil {
return Snapshot{}, err
}
component := func(id, label, installed string) Component {
return Component{
ID: id, Label: label,
Installed: installed, Available: release.version,
Reference: release.asset, Changelog: changelogURL,
}
}
return Snapshot{Components: []Component{
component("daemon", "Gateway", installedVersion(buildinfo.Version)),
component("agent", "Runtime", installedAgent()),
}}, nil
}
func (c *GitHubCatalog) detect(ctx context.Context, channel, pin string) (*release, error) {
c.mu.Lock()
defer c.mu.Unlock()
key := channel + "\x00" + pin
if c.release != nil && c.key == key && time.Since(c.at) < checkTTL {
return c.release, nil
}
release, err := detectRelease(ctx, channel, pin)
if err != nil {
return nil, err
}
c.key, c.at, c.release = key, time.Now(), release
return release, nil
}
// release is one published version and the zip that installs it here.
type release struct {
version string
asset string
}
const releasesURL = "https://api.github.com/repos/" + ReleaseSlug + "/releases?per_page=100"
type githubRelease struct {
TagName string `json:"tag_name"`
Draft bool `json:"draft"`
Prerelease bool `json:"prerelease"`
Assets []struct {
Name string `json:"name"`
} `json:"assets"`
}
// detectRelease resolves channel to one published release. A release with no
// zip for this platform, or no SHA256SUMS to verify it against, is not
// installable, so it is never offered.
func detectRelease(ctx context.Context, channel, pin string) (*release, error) {
if err := ValidateChannel(channel, pin); err != nil {
return nil, err
}
releases, err := listReleases(ctx)
if err != nil {
return nil, fmt.Errorf("find releases: %w", err)
}
if found := pick(releases, channel, pin); found != nil {
return found, nil
}
return nil, errors.New("no published release with a linux-amd64 zip matches the channel")
}
func listReleases(ctx context.Context) ([]githubRelease, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, releasesURL, nil)
if err != nil {
return nil, err
}
req.Header.Set("Accept", "application/vnd.github+json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("GitHub answered %s", resp.Status)
}
var releases []githubRelease
if err := json.NewDecoder(resp.Body).Decode(&releases); err != nil {
return nil, fmt.Errorf("decode releases: %w", err)
}
return releases, nil
}
// pick returns the newest installable release on channel.
func pick(releases []githubRelease, channel, pin string) *release {
var best *release
for _, r := range releases {
if !onChannel(r, channel, pin) {
continue
}
asset := installable(r)
if asset == "" {
continue
}
if best == nil || semver.Compare(r.TagName, "v"+best.version) > 0 {
best = &release{version: strings.TrimPrefix(r.TagName, "v"), asset: asset}
}
}
return best
}
// onChannel: stable skips prereleases, next includes them, and exact-pin takes
// only the pinned tag.
func onChannel(r githubRelease, channel, pin string) bool {
if r.Draft || !semver.IsValid(r.TagName) {
return false
}
switch channel {
case "exact-pin":
return r.TagName == "v"+strings.TrimPrefix(pin, "v")
case "next":
return true
default:
return !r.Prerelease
}
}
// installable names the release's linux-amd64 zip, or "" when it has none or
// no SHA256SUMS to verify it against.
func installable(r githubRelease) string {
asset, sums := "", false
for _, a := range r.Assets {
switch {
case a.Name == "SHA256SUMS":
sums = true
case strings.HasSuffix(a.Name, "-linux-amd64.zip"):
asset = a.Name
}
}
if !sums {
return ""
}
return asset
}
func installedVersion(version string) string {
return buildSuffix.ReplaceAllString(version, "")
}
// installedAgent is the image the installer last switched to, recorded in a
// sidecar beside the binaries; without one it is the runtime this release was
// cut with. A malformed sidecar is unknown, not guessed.
func installedAgent() string {
exe, err := os.Executable()
if err != nil {
return installedVersion(buildinfo.Runtime)
}
data, err := os.ReadFile(filepath.Join(filepath.Dir(exe), "archie-agent.version"))
if errors.Is(err, os.ErrNotExist) {
return installedVersion(buildinfo.Runtime)
}
version := strings.TrimSpace(string(data))
if err != nil || strings.ContainsAny(version, " \n") || ValidateChannel("exact-pin", version) != nil {
return ""
}
return installedVersion(version)
}
+1 -1
View File
@@ -161,7 +161,7 @@ func makeUpdateArchive(t *testing.T, root, scripts, scenario string) []byte {
for _, name := range []string{"archied", "archie-state-store", "archie-gateway", "archie-ui", "archie-messaging"} {
files[name] = "#!/bin/bash\n# new\nif [ \"$1\" = -version ]; then echo '" + name + " 2.0.0'; fi\nexit 0\n"
}
for _, name := range []string{"archie-update-install", "archie-update-watchdog", "archie-update-check"} {
for _, name := range []string{"archie-update-install", "archie-update-watchdog"} {
data, err := os.ReadFile(filepath.Join(scripts, name))
if err != nil {
t.Fatal(err)
+11 -1
View File
@@ -204,7 +204,17 @@ func (s *Service) Install(ctx context.Context, snapshot Snapshot, meta InstallMe
return s.Installer.Install(installCtx, snapshot, meta, progress)
}
func (s *Service) CanInstall() bool { return s != nil && s.Installer != nil }
func (s *Service) CanInstall() bool {
if s == nil || s.Installer == nil {
return false
}
if installer, ok := s.Installer.(interface{ Installable(context.Context) bool }); ok {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
return installer.Installable(ctx)
}
return true
}
type deferrals map[string]map[string]string
+56 -12
View File
@@ -3,8 +3,10 @@ package webui
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"path/filepath"
"reflect"
"strings"
"sync"
@@ -43,8 +45,19 @@ type chatMessageRequest struct {
// set by the web chat so the agent's system prompt can state where the
// operator is looking and point them somewhere relevant.
Page string `json:"page,omitempty"`
// Voice is a recorded clip, transcribed by the Gateway like a Telegram
// voice note. Base64 in JSON.
Voice *chatVoice `json:"voice,omitempty"`
}
type chatVoice struct {
Data []byte `json:"data"`
MIMEType string `json:"mime_type"`
}
// maxVoiceBytes bounds a recorded clip: about ten minutes of Opus.
const maxVoiceBytes = 10 << 20
// chatMessageView is one entry of a session's history as the dashboard
// reads it. The persisted record is messaging.Message; this is the shape
// the browser has always been served, kept here so the HTTP response owns
@@ -174,6 +187,7 @@ func (s *Server) handleChatSessions(w http.ResponseWriter, r *http.Request) {
"active_model": snapshot.ActiveModel,
"active_provider": snapshot.ActiveProvider,
"personas": snapshot.Personas,
"voice_available": snapshot.VoiceAvailable,
"active_personas": active,
"commands": chatCommandSpecs(chat),
"restart_available": snapshot.RestartAvailable,
@@ -256,11 +270,23 @@ func (s *Server) handleChatTurns(w http.ResponseWriter, r *http.Request) {
func (s *Server) decodeChatMessage(w http.ResponseWriter, r *http.Request) (messaging.Inbound, bool) {
var req chatMessageRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
// Base64 makes a clip a third larger than its bytes.
if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, maxVoiceBytes*3/2)).Decode(&req); err != nil {
http.Error(w, "invalid chat message", http.StatusBadRequest)
return messaging.Inbound{}, false
}
req.Text = strings.TrimSpace(req.Text)
var media []messaging.MediaAttachment
if req.Voice != nil {
if len(req.Voice.Data) == 0 || len(req.Voice.Data) > maxVoiceBytes {
http.Error(w, "voice clip is empty or too long", http.StatusBadRequest)
return messaging.Inbound{}, false
}
media = append(media, messaging.MediaAttachment{Type: messaging.MediaTypeVoice, MIMEType: req.Voice.MIMEType, Data: req.Voice.Data})
if req.Text == "" {
req.Text = "[voice message]"
}
}
if req.Text == "" || req.ChannelID == "" {
http.Error(w, "text and channel_id are required", http.StatusBadRequest)
return messaging.Inbound{}, false
@@ -279,7 +305,8 @@ func (s *Server) decodeChatMessage(w http.ResponseWriter, r *http.Request) (mess
Role: messaging.RoleUser,
Text: req.Text,
},
Page: req.Page,
Media: media,
Page: req.Page,
// The dashboard names the channel it carries; see the platform field's
// note in internal/domain/messaging/inbound.go.
Platform: "web",
@@ -317,6 +344,8 @@ type chatStreamEvent struct {
// only on a navigate event.
Path string `json:"path,omitempty"`
Label string `json:"label,omitempty"`
// Ask is a question the turn waits on; answered by POST /api/chat/answer.
Ask *chatAsk `json:"ask,omitempty"`
}
// chatStreamSink writes turn text and tool activity to the browser stream.
@@ -324,6 +353,8 @@ type chatStreamEvent struct {
type chatStreamSink struct {
write func(chatStreamEvent)
showToolCalls bool
// files hands out downloads for the local files a turn sends.
files *chatFiles
}
func (s chatStreamSink) Delta(text string) {
@@ -368,15 +399,12 @@ func (s chatStreamSink) Media(event messaging.MediaEvent) {
switch {
case att.URL != "":
s.write(chatStreamEvent{Type: "delta", Text: "\n\n📎 " + att.Type + ": " + att.URL})
case att.Path != "":
case att.Path != "" && s.files != nil:
name := att.FileName
if name == "" {
name = att.Path
name = filepath.Base(att.Path)
}
s.write(chatStreamEvent{
Type: "delta",
Text: "\n\n📎 could not send " + name + ": this channel cannot deliver a local file. It is on the daemon host at " + att.Path + ".",
})
s.write(chatStreamEvent{Type: "delta", Text: "\n\n📎 [" + name + "](" + chatFileURL(s.files.offer(att.Path, att.FileName)) + ")"})
}
}
@@ -407,18 +435,24 @@ func (s *Server) handleChatStream(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/event-stream")
w.Header().Set("Cache-Control", "no-cache")
w.Header().Set("X-Accel-Buffering", "no")
// An ask is written from the gateway client's goroutine while this one
// writes the turn's events.
var writeMu sync.Mutex
writeChatEvent := func(event chatStreamEvent, sessionID string) {
writeMu.Lock()
defer writeMu.Unlock()
event.SessionID = sessionID
payload, _ := json.Marshal(event)
_, _ = fmt.Fprintf(w, "data: %s\n\n", payload)
flusher.Flush()
}
events, err := chat.Contract.Stream(r.Context(), msg)
asker := dashboardAsker{asks: &s.chatAsks, write: func(frame chatStreamEvent) { writeChatEvent(frame, "") }}
events, err := chat.Contract.Stream(withDashboardAsks(r.Context(), asker), msg)
if err != nil {
writeChatEvent(chatStreamEvent{Type: "error", Text: err.Error()}, "")
return
}
sink := chatStreamSink{showToolCalls: s.chatShowToolCalls(r.Context())}
sink := chatStreamSink{showToolCalls: s.chatShowToolCalls(r.Context()), files: &s.chatFiles}
for event := range events {
sink.write = func(frame chatStreamEvent) { writeChatEvent(frame, event.SessionID) }
switch event.Kind {
@@ -506,6 +540,16 @@ func (s *Server) handleChatPersona(w http.ResponseWriter, r *http.Request) {
writeJSON(w, map[string]any{"ok": true, "name": strings.ToLower(req.Name)})
}
// writeUpdateCheckError answers an unset check command as not configured, which
// the dashboard shows as such rather than as a failure.
func writeUpdateCheckError(w http.ResponseWriter, err error) {
if errors.Is(err, releaseupdate.ErrNotConfigured) {
http.Error(w, "updates are not configured", http.StatusNotImplemented)
return
}
http.Error(w, err.Error(), http.StatusBadGateway)
}
func (s *Server) handleChatUpdate(w http.ResponseWriter, r *http.Request) {
chat, ok := s.chatReady(w)
if !ok {
@@ -517,7 +561,7 @@ func (s *Server) handleChatUpdate(w http.ResponseWriter, r *http.Request) {
}
snapshot, err := chat.Updates.Check(r.Context(), 0)
if err != nil {
http.Error(w, err.Error(), http.StatusBadGateway)
writeUpdateCheckError(w, err)
return
}
writeJSON(w, map[string]any{
@@ -564,7 +608,7 @@ func (s *Server) handleChatUpdateInstall(w http.ResponseWriter, r *http.Request)
}
fresh, err := chat.Updates.Check(r.Context(), 0)
if err != nil {
http.Error(w, err.Error(), http.StatusBadGateway)
writeUpdateCheckError(w, err)
return
}
if !releaseupdate.SameAvailable(fresh, req.Snapshot) {
+160
View File
@@ -0,0 +1,160 @@
package webui
import (
"context"
"crypto/rand"
"encoding/hex"
"encoding/json"
"errors"
"net/http"
"strings"
"sync"
"github.com/samcharles93/archie-core/internal/domain/messaging"
)
// chatAsk is a question a turn is blocked on, rendered as a card in the chat.
type chatAsk struct {
ID string `json:"id"`
Kind string `json:"kind"` // approval, clarify or picker
Prompt string `json:"prompt"`
Detail string `json:"detail,omitempty"`
Choices []chatAskChoice `json:"choices,omitempty"`
}
type chatAskChoice struct {
ID string `json:"id"`
Label string `json:"label"`
}
// chatAsks holds the asks waiting for the browser's answer, keyed by id.
type chatAsks struct {
mu sync.Mutex
waiting map[string]chan string
}
func (a *chatAsks) open() (string, chan string) {
var b [12]byte
_, _ = rand.Read(b[:])
id := hex.EncodeToString(b[:])
ch := make(chan string, 1)
a.mu.Lock()
if a.waiting == nil {
a.waiting = make(map[string]chan string)
}
a.waiting[id] = ch
a.mu.Unlock()
return id, ch
}
func (a *chatAsks) close(id string) {
a.mu.Lock()
delete(a.waiting, id)
a.mu.Unlock()
}
func (a *chatAsks) answer(id, answer string) bool {
a.mu.Lock()
ch, ok := a.waiting[id]
a.mu.Unlock()
if ok {
select {
case ch <- answer:
default:
}
}
return ok
}
// dashboardAsker answers a turn's approvals and questions through cards in
// the chat stream, so the dashboard carries everything Telegram does.
type dashboardAsker struct {
asks *chatAsks
write func(chatStreamEvent)
}
func (d dashboardAsker) ask(ctx context.Context, q chatAsk) (string, error) {
id, ch := d.asks.open()
defer d.asks.close(id)
q.ID = id
d.write(chatStreamEvent{Type: "ask", Ask: &q})
select {
case answer := <-ch:
return answer, nil
case <-ctx.Done():
return "", ctx.Err()
}
}
func (d dashboardAsker) RequestApproval(ctx context.Context, action, description string) (messaging.ApprovalDecision, error) {
answer, err := d.ask(ctx, chatAsk{Kind: "approval", Prompt: action, Detail: description})
switch {
case err != nil:
return messaging.ApprovalDenied, err
case answer == "approve":
return messaging.ApprovalApproved, nil
case answer == "always":
return messaging.ApprovalPermanentlyApproved, nil
}
return messaging.ApprovalDenied, nil
}
func (d dashboardAsker) RequestClarification(ctx context.Context, req messaging.ClarifyRequest) (string, error) {
answer, err := d.ask(ctx, chatAsk{Kind: "clarify", Prompt: req.Question, Choices: askChoices(req.Suggestions)})
if err != nil {
return "", err
}
if answer = strings.TrimSpace(answer); answer == "" {
return "", messaging.ErrEmptyReply
}
return answer, nil
}
func (d dashboardAsker) RequestChoice(ctx context.Context, req messaging.PickerRequest) (messaging.InteractiveChoice, error) {
if len(req.Options) == 0 {
return messaging.InteractiveChoice{}, messaging.ErrNoPickerOptions
}
answer, err := d.ask(ctx, chatAsk{Kind: "picker", Prompt: req.Prompt, Choices: askChoices(req.Options)})
if err != nil {
return messaging.InteractiveChoice{}, err
}
for _, option := range req.Options {
if option.ID == answer {
return option, nil
}
}
return messaging.InteractiveChoice{}, errors.New("picker answer matches no option")
}
func askChoices(choices []messaging.InteractiveChoice) []chatAskChoice {
out := make([]chatAskChoice, 0, len(choices))
for _, c := range choices {
out = append(out, chatAskChoice{ID: c.ID, Label: c.Label})
}
return out
}
// withDashboardAsks puts the dashboard's askers on a turn's context.
func withDashboardAsks(ctx context.Context, asker dashboardAsker) context.Context {
ctx = messaging.WithApprovalRequester(ctx, asker)
return messaging.WithInteractive(ctx, messaging.Interactive{Clarifier: asker, Picker: asker})
}
type chatAnswerRequest struct {
ID string `json:"id"`
Answer string `json:"answer"`
}
// handleChatAnswer delivers the operator's answer to the ask a turn waits on.
func (s *Server) handleChatAnswer(w http.ResponseWriter, r *http.Request) {
var req chatAnswerRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.ID == "" {
http.Error(w, "id is required", http.StatusBadRequest)
return
}
if !s.chatAsks.answer(req.ID, req.Answer) {
http.Error(w, "that question is no longer waiting", http.StatusNotFound)
return
}
writeJSON(w, map[string]bool{"answered": true})
}
+83
View File
@@ -0,0 +1,83 @@
package webui
import (
"crypto/rand"
"encoding/hex"
"fmt"
"mime"
"net/http"
"path/filepath"
"sync"
"time"
)
// chatFileTTL is how long a file a turn sent stays downloadable.
const chatFileTTL = time.Hour
// chatFiles serves the files a chat turn sent from the Gateway's host. Only a
// path a turn named is reachable, through an unguessable token that expires;
// no request can name a path of its own.
type chatFiles struct {
mu sync.Mutex
files map[string]chatFile
now func() time.Time
}
type chatFile struct {
path string
name string
expires time.Time
}
func (c *chatFiles) clock() time.Time {
if c.now != nil {
return c.now()
}
return time.Now()
}
// offer registers path and returns the token that downloads it.
func (c *chatFiles) offer(path, name string) string {
var b [16]byte
_, _ = rand.Read(b[:])
token := hex.EncodeToString(b[:])
if name == "" {
name = filepath.Base(path)
}
c.mu.Lock()
defer c.mu.Unlock()
if c.files == nil {
c.files = make(map[string]chatFile)
}
now := c.clock()
for t, f := range c.files {
if now.After(f.expires) {
delete(c.files, t)
}
}
c.files[token] = chatFile{path: path, name: name, expires: now.Add(chatFileTTL)}
return token
}
func (c *chatFiles) lookup(token string) (chatFile, bool) {
c.mu.Lock()
defer c.mu.Unlock()
f, ok := c.files[token]
if !ok || c.clock().After(f.expires) {
return chatFile{}, false
}
return f, true
}
func (s *Server) handleChatFile(w http.ResponseWriter, r *http.Request) {
f, ok := s.chatFiles.lookup(r.PathValue("token"))
if !ok {
http.Error(w, "that file is no longer available", http.StatusNotFound)
return
}
w.Header().Set("Content-Disposition", mime.FormatMediaType("attachment", map[string]string{"filename": f.name}))
w.Header().Set("X-Content-Type-Options", "nosniff")
http.ServeFile(w, r, f.path)
}
func chatFileURL(token string) string { return fmt.Sprintf("/api/chat/file/%s", token) }
+50
View File
@@ -0,0 +1,50 @@
package webui
import (
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"testing"
"time"
)
// TestChatFileDownload: only a file a turn offered is served, and only until
// its token expires.
func TestChatFileDownload(t *testing.T) {
path := filepath.Join(t.TempDir(), "report.txt")
if err := os.WriteFile(path, []byte("contents"), 0o600); err != nil {
t.Fatal(err)
}
now := time.Now()
srv := &Server{}
srv.chatFiles.now = func() time.Time { return now }
token := srv.chatFiles.offer(path, "")
tests := []struct {
name string
token string
after time.Duration
want int
}{
{name: "an offered file is served", token: token, want: http.StatusOK},
{name: "a token nobody was given is refused", token: "0123456789abcdef0123456789abcdef", want: http.StatusNotFound},
{name: "a path is not a token", token: "..%2f..%2fetc%2fpasswd", want: http.StatusNotFound},
{name: "an expired token is refused", token: token, after: chatFileTTL + time.Second, want: http.StatusNotFound},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
srv.chatFiles.now = func() time.Time { return now.Add(tt.after) }
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/chat/file/x", nil)
req.SetPathValue("token", tt.token)
rec := httptest.NewRecorder()
srv.handleChatFile(rec, req)
if rec.Code != tt.want {
t.Fatalf("status = %d, want %d", rec.Code, tt.want)
}
if tt.want == http.StatusOK && rec.Body.String() != "contents" {
t.Fatalf("body = %q", rec.Body.String())
}
})
}
}
+1 -1
View File
@@ -71,7 +71,7 @@ func (s *Server) handleVersion(w http.ResponseWriter, r *http.Request) {
}
snapshot, err := s.Chat.Updates.Check(r.Context(), 0)
if err != nil {
http.Error(w, err.Error(), http.StatusBadGateway)
writeUpdateCheckError(w, err)
return
}
running := map[string]string{}
+7
View File
@@ -25,6 +25,11 @@ import (
)
type Server struct {
// chatAsks holds the chat questions waiting for the operator's answer.
chatAsks chatAsks
// chatFiles holds the downloads for files chat turns sent.
chatFiles chatFiles
Store storecontract.TaskStore
Log *slog.Logger
@@ -358,6 +363,8 @@ func (s *Server) registerChatRoutes(mux *http.ServeMux) {
mux.HandleFunc("POST /api/chat/message", s.handleChatMessage)
mux.HandleFunc("POST /api/chat/stream", s.handleChatStream)
mux.HandleFunc("POST /api/chat/cancel", s.handleChatCancel)
mux.HandleFunc("POST /api/chat/answer", s.handleChatAnswer)
mux.HandleFunc("GET /api/chat/file/{token}", s.handleChatFile)
mux.HandleFunc("POST /api/chat/persona", s.handleChatPersona)
mux.HandleFunc("GET /api/chat/update", s.handleChatUpdate)
mux.HandleFunc("POST /api/chat/update/defer", s.handleChatUpdateDefer)
+25 -1
View File
@@ -11,6 +11,7 @@ service ChatService {
rpc RecentTurns(RecentTurnsRequest) returns (RecentTurnsResponse);
rpc Route(RouteRequest) returns (RouteResponse);
rpc Stream(StreamRequest) returns (stream StreamResponse);
rpc Answer(AnswerRequest) returns (AnswerResponse);
rpc Cancel(CancelRequest) returns (CancelResponse);
rpc StopTasks(StopTasksRequest) returns (StopTasksResponse);
rpc SetPersona(SetPersonaRequest) returns (SetPersonaResponse);
@@ -129,6 +130,7 @@ message SnapshotResponse {
bool cancellation_available = 10;
bool personas_available = 11;
string version = 12;
bool voice_available = 13;
}
message GetSessionRequest { string session_id = 1; }
message GetSessionResponse { Session session = 1; bool found = 2; }
@@ -144,13 +146,35 @@ message RouteResponse {
// outcome.
bool rate_limited = 3;
}
message StreamRequest { Message message = 1; }
// The caller states which asks it can answer; the turn offers only those.
message StreamRequest {
Message message = 1;
bool can_approve = 2;
bool can_clarify = 3;
bool can_pick = 4;
}
// Ask is a question the turn blocks on until Answer names its id.
message Ask {
string id = 1;
// approval, clarify or picker.
string kind = 2;
string prompt = 3;
// Tool description, for an approval.
string detail = 4;
repeated Choice choices = 5;
}
message Choice { string id = 1; string label = 2; }
// For an approval, answer is approve, always or deny; for a picker, the
// choice id; for a clarify, the reply text.
message AnswerRequest { string ask_id = 1; string answer = 2; }
message AnswerResponse { bool found = 1; }
message StreamResponse {
string kind = 1;
string text = 2;
string session_id = 3;
ToolCall tool = 4;
Media media = 5;
Ask ask = 6;
}
message CancelRequest { string session_id = 1; }
message CancelResponse { bool cancelled = 1; int64 dropped = 2; }
-186
View File
@@ -1,186 +0,0 @@
#!/usr/bin/env bash
# archie-update-check -- update discovery adapter for archied's /update command.
#
# Writes a releaseupdate.Snapshot JSON document to stdout. archied runs this
# via CommandCatalog (internal/releaseupdate/command.go), which never invokes
# a shell, so this file must be directly executable.
#
# "Installed" for the daemon is the release the running binary was ACTUALLY
# built from, read via `archied -version`. The agent value in that output is
# only the runtime version the daemon release was cut with; it is not the
# managed image that an installer later rebuilt. The installer therefore owns
# a sidecar beside BIN_DIR, archie-agent.version, and that is authoritative.
# Older installations without the sidecar use the agent line as a compatibility
# fallback. An existing malformed sidecar is reported as unknown, not replaced
# by a fabricated version. Build-stamp git-describe suffixes are stripped for
# comparison (1.7.0-4-g0736708 -> 1.7.0).
#
# "Available" is the newest release TAG, resolved without any dependency on a
# local checkout. Two independent sources, in order:
#
# 1. the forge API (tags + releases), which also reports whether the tag has
# a PUBLISHED artifact -- the thing an artifact install path downloads;
# 2. `git ls-remote` against the source remote, which needs no API and no
# working tree.
#
# The tag is the authority for "an update exists"; the artifact is reported
# separately in Reference, so a tagged-but-unpublished release is still
# announced (it is installable via the source-build fallback) instead of being
# silently hidden.
#
# A tag source that fails to resolve is a FAILURE TO CHECK, not an absence.
# An empty Available means "this component is at the newest release we could
# resolve", so it must never be the result of a probe that failed. When no
# authoritative source answers at all, this script exits non-zero and the
# /update command says it could not check -- rather than rendering a failed
# lookup as "Archie is up to date".
set -uo pipefail
readonly REPO_SLUG="${ARCHIE_SOURCE_SLUG:-samcharles93/archie-core}"
readonly API_BASE="${ARCHIE_FORGE_API:-https://api.github.com}"
readonly SOURCE_URL="${ARCHIE_SOURCE_URL:-https://github.com/${REPO_SLUG}.git}"
readonly BIN="${ARCHIE_BIN:-$HOME/.local/bin/archied}"
readonly BIN_DIR="${ARCHIE_BIN_DIR:-$(dirname "$BIN")}"
readonly AGENT_VERSION_FILE="${ARCHIE_AGENT_VERSION_FILE:-$BIN_DIR/archie-agent.version}"
readonly CURL_TIMEOUT="${ARCHIE_FORGE_TIMEOUT:-20}"
readonly TOKEN="${ARCHIE_FORGE_TOKEN:-}"
# base 1.7.0-4-g0736708 -> 1.7.0
base() { printf '%s\n' "$1" | sed -E 's/-[0-9]+-g[0-9a-f]+$//'; }
# installed_for reads the version this binary reports for a named component.
# archied stamps both its own version and the runtime version the release was
# cut with, and -version prints one line per component -- so the installed
# runtime is what THIS RELEASE says it was built against, not a stray binary
# on the host. releaseupdate/service.go documents why a host-side archie-agent
# binary cannot answer this: every archie-agent process is task-scoped and
# ephemeral, observed only through a completed taskrun.Response.
installed_for() {
"$BIN" -version 2>/dev/null | awk -v n="$1" '$1 == n { print $2; exit }'
}
curl_api() {
if [ -n "$TOKEN" ]; then
curl -fsS --max-time "$CURL_TIMEOUT" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/vnd.github+json" \
"$1" 2>/dev/null
else
curl -fsS --max-time "$CURL_TIMEOUT" \
-H "Accept: application/vnd.github+json" \
"$1" 2>/dev/null
fi
}
RELEASE_CHANNEL="${ARCHIE_UPDATE_RELEASE_CHANNEL:-stable}"
PIN="${ARCHIE_UPDATE_PIN:-}"
while [ "$#" -gt 0 ]; do
case "$1" in
--channel) RELEASE_CHANNEL="$2"; shift 2 ;;
--pin) PIN="$2"; shift 2 ;;
*) echo "unknown option: $1" >&2; exit 1 ;;
esac
done
select_release() { "$BIN" select-release -channel "$RELEASE_CHANNEL" -pin "$PIN"; }
newest_tag_git() {
local tags
tags="$(git ls-remote --tags --refs "$SOURCE_URL" 'archied/v*' 'v*' 2>/dev/null)" || return 1
printf '%s\n' "$tags" | awk '{print $2}' | select_release
}
newest_tag_api() {
local page payload tags=""
for page in $(seq 1 100); do
payload="$(curl_api "${API_BASE}/repos/${REPO_SLUG}/tags?per_page=100&page=${page}")" || return 1
tags+="$(jq -er '.[].name' <<< "$payload")"$'\n'
if [ "$(jq 'length' <<< "$payload")" -lt 100 ]; then
printf '%s' "$tags" | select_release
return $?
fi
done
echo "tag catalog exceeded pagination limit" >&2
return 1
}
# artifact_state reports whether a tagged release is PUBLISHED with assets,
# which decides whether an artifact install can use it or the source-build
# fallback has to. Purely descriptive: a failure here never fabricates a
# state, it reports "unknown-artifact".
artifact_state() {
local tag="$1" payload count
command -v jq >/dev/null 2>&1 || { printf 'unknown-artifact'; return 0; }
payload="$(curl_api "${API_BASE}/repos/${REPO_SLUG}/releases/tags/${tag}")" || { printf 'no-release'; return 0; }
[ -n "$payload" ] || { printf 'no-release'; return 0; }
count="$(printf '%s\n' "$payload" | jq -r '[.assets[] | select(.name != "")] | length' 2>/dev/null)"
case "${count:-}" in
'' | *[!0-9]*) printf 'unknown-artifact' ;;
0) printf 'no-artifact' ;;
*) printf '%s-assets' "$count" ;;
esac
}
esc() { printf '%s' "${1:-}" | sed 's/\\/\\\\/g; s/"/\\"/g'; }
daemon_installed="$(base "$(installed_for archied || true)")"
agent_installed=""
if [ -f "$AGENT_VERSION_FILE" ]; then
# A sidecar is updater state: accept only one released semantic version and
# deliberately do not fall back if it is empty or malformed.
sidecar_version="$(awk 'NF { if (seen++) { bad=1; next } gsub(/^[[:space:]]+|[[:space:]]+$/, "", $0); print } END { if (bad) exit 1 }' "$AGENT_VERSION_FILE" 2>/dev/null || true)"
if [[ "$sidecar_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]]; then
agent_installed="$(base "$sidecar_version")"
fi
else
# Compatibility for hosts installed before the sidecar existed.
agent_installed="$(base "$(installed_for archie-agent || true)")"
fi
# One version covers every component (RELEASING.md): the runtime image a
# release publishes carries the release's own version, tagged archied/v*.
daemon_available="$(newest_tag_git archied || true)"
tag_source="git-tags"
if [ -z "$daemon_available" ]; then
daemon_available="$(newest_tag_api archied || true)"
tag_source="forge-api-tags"
fi
agent_available="$daemon_available"
if [ -z "$daemon_available" ]; then
# Neither source answered. Report the failure; do not exit 0 with two empty
# components, which the caller renders as "up to date".
echo "archie-update-check: could not resolve any release tag from ${SOURCE_URL} or ${API_BASE}/repos/${REPO_SLUG}/tags" >&2
exit 1
fi
daemon_artifacts=""
[ -n "$daemon_available" ] && daemon_artifacts="$(artifact_state "archied/v${daemon_available}")"
agent_artifacts=""
agent_artifacts="$daemon_artifacts"
reference_for() {
local component="$1" version="$2" artifacts="$3"
[ -z "$version" ] && { printf ''; return 0; }
printf '%s artifact=%s (%s)' "$tag_source" "$artifacts" "$component"
}
cat <<EOF
{
"Components": [
{
"ID": "daemon",
"Label": "Gateway",
"Installed": "$(esc "$daemon_installed")",
"Available": "$(esc "$daemon_available")",
"Reference": "$(esc "$(reference_for archie-core "$daemon_available" "$daemon_artifacts")")",
"Changelog": "https://github.com/${REPO_SLUG}/blob/main/CHANGELOG.md"
},
{
"ID": "agent",
"Label": "Runtime",
"Installed": "$(esc "$agent_installed")",
"Available": "$(esc "$agent_available")",
"Reference": "$(esc "$(reference_for archie-runtime "$agent_available" "$agent_artifacts")")",
"Changelog": "https://github.com/${REPO_SLUG}/blob/main/CHANGELOG.md"
}
],
"Deferred": false
}
EOF
+10 -2
View File
@@ -15,6 +15,14 @@ SOURCE_URL="${ARCHIE_SOURCE_URL:-https://github.com/samcharles93/archie-core.git
BIN_DIR="${ARCHIE_BIN_DIR:-$HOME/.local/bin}"
CONFIG_PATH="${ARCHIE_CONFIG_PATH:-${XDG_CONFIG_HOME:-$HOME/.config}/archie/config.toml}"
export PATH="/usr/local/go/bin:$PATH"
# The units load this file; a run from a shell needs it too, for PGPASSWORD.
ENV_FILE="$(dirname "$CONFIG_PATH")/env"
if [ -r "$ENV_FILE" ]; then
set -a
# shellcheck disable=SC1090
. "$ENV_FILE"
set +a
fi
# State for the managed image, independent of archied's daemon build stamp.
AGENT_VERSION_FILE="${ARCHIE_AGENT_VERSION_FILE:-$BIN_DIR/archie-agent.version}"
@@ -55,7 +63,7 @@ for arg in "$@"; do
done
if [ "$AUTO" = 1 ] && [ -z "${ARCHIE_UPDATE_DAEMON_VERSION:-}${ARCHIE_UPDATE_AGENT_VERSION:-}" ]; then
snapshot="$("$(dirname "$0")/archie-update-check")"
snapshot="$("$BIN_DIR/archied" update check)"
export ARCHIE_UPDATE_DAEMON_PREVIOUS="$(jq -r '.Components[] | select(.ID == "daemon") | .Installed' <<< "$snapshot")"
export ARCHIE_UPDATE_DAEMON_VERSION="$(jq -r '.Components[] | select(.ID == "daemon") | .Available' <<< "$snapshot")"
export ARCHIE_UPDATE_AGENT_PREVIOUS="$(jq -r '.Components[] | select(.ID == "agent") | .Installed' <<< "$snapshot")"
@@ -218,7 +226,7 @@ if [[ ",$components," == *,daemon,* ]]; then
done
mkdir -p "$(dirname "$DB_SNAPSHOT")"
"$BIN_DIR/archie-state-store" backup -config "$CONFIG_PATH" -out "$DB_SNAPSHOT"
built="$GATEWAY_BINARIES archie-update-install archie-update-watchdog archie-update-check"
built="$GATEWAY_BINARIES archie-update-install archie-update-watchdog"
fi
# Freeze recovery code and every prior file before publishing the intent.
+10 -2
View File
@@ -78,9 +78,16 @@ EOF
mv -f "$tmp" "$REPORT_PATH"
}
# LAST_HEALTH is the last report healthy saw, printed when the update is
# given up so the log says which component failed.
LAST_HEALTH=""
healthy() {
local report
report="$(curl -fsS --max-time 10 "$HEALTH_URL/health/detailed")" || return 1
if ! report="$(curl -fsS --max-time 10 "$HEALTH_URL/health/detailed")"; then
LAST_HEALTH="$(curl -sS --max-time 10 "$HEALTH_URL/health/detailed" 2>&1)"
return 1
fi
LAST_HEALTH="$report"
[ "$(jq -r '.version' <<< "$report")" = "$ARCHIE_UPDATE_INSTALLED_GATEWAY" ] &&
[ "$(jq -r '.status' <<< "$report")" = ok ]
}
@@ -92,12 +99,13 @@ wait_healthy() {
deadline=$((SECONDS + OBSERVE_SECONDS))
while [ "$SECONDS" -lt "$deadline" ]; do
sleep "$POLL_INTERVAL_SECONDS"
healthy || return 1
healthy || { echo "==> unhealthy while observing: $LAST_HEALTH"; return 1; }
done
return 0
fi
sleep "$POLL_INTERVAL_SECONDS"
done
echo "==> never became healthy; last report: $LAST_HEALTH"
return 1
}
+1 -1
View File
@@ -92,7 +92,7 @@ archied_dirs() {
component_dirs ./cmd/archie-ui
printf '%s\n' "cmd/archied" "Dockerfile.archied" "cmd/archie-ui" "internal/app/archieui" \
"Taskfile.yml" ".github/workflows/deploy.yml" "install.sh" \
"scripts/archie-update-install" "scripts/archie-update-check" \
"scripts/archie-update-install" \
"scripts/archie-update-watchdog" "deployments/INSTRUCTIONS.md"
}
+1 -1
View File
@@ -1 +1 @@
.vue-flow{z-index:0;direction:ltr;width:100%;height:100%;position:relative;overflow:hidden}.vue-flow__container{width:100%;height:100%;position:absolute;top:0;left:0}.vue-flow__pane{z-index:1}.vue-flow__pane.draggable{cursor:grab}.vue-flow__pane.selection{cursor:pointer}.vue-flow__pane.dragging{cursor:grabbing}.vue-flow__transformationpane{transform-origin:0 0;z-index:2;pointer-events:none}.vue-flow__viewport{z-index:4;overflow:clip}.vue-flow__selection{z-index:6}.vue-flow__edge-labels{pointer-events:none;-webkit-user-select:none;user-select:none;width:100%;height:100%;position:absolute}.vue-flow__nodesselection-rect:focus,.vue-flow__nodesselection-rect:focus-visible{outline:none}.vue-flow .vue-flow__edges{pointer-events:none;overflow:visible}.vue-flow__edge-path,.vue-flow__connection-path{stroke:#b1b1b7;stroke-width:1px;fill:none}.vue-flow__edge{pointer-events:visibleStroke;cursor:pointer}.vue-flow__edge.animated path{stroke-dasharray:5;animation:.5s linear infinite dashdraw}.vue-flow__edge.animated path.vue-flow__edge-interaction{stroke-dasharray:none;animation:none}.vue-flow__edge.inactive{pointer-events:none}.vue-flow__edge.selected,.vue-flow__edge:focus,.vue-flow__edge:focus-visible{outline:none}.vue-flow__edge.selected .vue-flow__edge-path,.vue-flow__edge:focus .vue-flow__edge-path,.vue-flow__edge:focus-visible .vue-flow__edge-path{stroke:#555}.vue-flow__edge-textwrapper{pointer-events:all}.vue-flow__edge-textbg{fill:#fff}.vue-flow__edge-text{pointer-events:none;-webkit-user-select:none;user-select:none}.vue-flow__connection{pointer-events:none}.vue-flow__connection .animated{stroke-dasharray:5;animation:.5s linear infinite dashdraw}.vue-flow__connectionline{z-index:1001}.vue-flow__nodes{pointer-events:none;transform-origin:0 0}.vue-flow__node{-webkit-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default;position:absolute}.vue-flow__node.draggable{cursor:grab;pointer-events:all}.vue-flow__node.draggable.dragging{cursor:grabbing}.vue-flow__nodesselection{z-index:3;transform-origin:0 0;pointer-events:none}.vue-flow__nodesselection-rect{pointer-events:all;cursor:grab;position:absolute}.vue-flow__nodesselection-rect.dragging{cursor:grabbing}.vue-flow__handle{pointer-events:none;min-width:5px;min-height:5px;position:absolute}.vue-flow__handle.connectable{pointer-events:all;cursor:crosshair}.vue-flow__handle-bottom{bottom:0;left:50%;transform:translate(-50%,50%)}.vue-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.vue-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.vue-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.vue-flow__edgeupdater{cursor:move;pointer-events:all}.vue-flow__panel{z-index:5;margin:15px;position:absolute}.vue-flow__panel.top{top:0}.vue-flow__panel.bottom{bottom:0}.vue-flow__panel.left{left:0}.vue-flow__panel.right{right:0}.vue-flow__panel.center{left:50%;transform:translate(-50%)}@keyframes dashdraw{0%{stroke-dashoffset:10px}}.vue-flow__controls{box-shadow:0 0 2px 1px #00000014}.vue-flow__controls-button{box-sizing:content-box;cursor:pointer;-webkit-user-select:none;user-select:none;background:#fefefe;border:none;border-bottom:1px solid #eee;justify-content:center;align-items:center;width:16px;height:16px;padding:5px;display:flex}.vue-flow__controls-button svg{width:100%;max-width:12px;max-height:12px}.vue-flow__controls-button:hover{background:#f4f4f4}.vue-flow__controls-button:disabled{pointer-events:none}.vue-flow__controls-button:disabled svg{fill-opacity:.4}.workflow-flow-edge path{stroke:var(--color-muted-foreground);stroke-width:1.5px}.workflow-data-edge path{stroke:var(--color-primary);stroke-dasharray:5 4;stroke-width:1.25px}@keyframes step-running{50%{box-shadow:0 0 0 4px color-mix(in oklab, var(--color-info) 30%, transparent)}}.step-running{animation:1.6s ease-in-out infinite step-running}.workflow-canvas .vue-flow__controls{box-shadow:none}.workflow-canvas .vue-flow__controls-button{background:var(--color-card);border-color:var(--color-border);fill:var(--color-foreground)}.workflow-canvas .vue-flow__controls-button:hover{background:var(--color-secondary)}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-divide-x-reverse:0;--tw-border-style:solid;--tw-divide-y-reverse:0;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--twLine truncated
.vue-flow{z-index:0;direction:ltr;width:100%;height:100%;position:relative;overflow:hidden}.vue-flow__container{width:100%;height:100%;position:absolute;top:0;left:0}.vue-flow__pane{z-index:1}.vue-flow__pane.draggable{cursor:grab}.vue-flow__pane.selection{cursor:pointer}.vue-flow__pane.dragging{cursor:grabbing}.vue-flow__transformationpane{transform-origin:0 0;z-index:2;pointer-events:none}.vue-flow__viewport{z-index:4;overflow:clip}.vue-flow__selection{z-index:6}.vue-flow__edge-labels{pointer-events:none;-webkit-user-select:none;user-select:none;width:100%;height:100%;position:absolute}.vue-flow__nodesselection-rect:focus,.vue-flow__nodesselection-rect:focus-visible{outline:none}.vue-flow .vue-flow__edges{pointer-events:none;overflow:visible}.vue-flow__edge-path,.vue-flow__connection-path{stroke:#b1b1b7;stroke-width:1px;fill:none}.vue-flow__edge{pointer-events:visibleStroke;cursor:pointer}.vue-flow__edge.animated path{stroke-dasharray:5;animation:.5s linear infinite dashdraw}.vue-flow__edge.animated path.vue-flow__edge-interaction{stroke-dasharray:none;animation:none}.vue-flow__edge.inactive{pointer-events:none}.vue-flow__edge.selected,.vue-flow__edge:focus,.vue-flow__edge:focus-visible{outline:none}.vue-flow__edge.selected .vue-flow__edge-path,.vue-flow__edge:focus .vue-flow__edge-path,.vue-flow__edge:focus-visible .vue-flow__edge-path{stroke:#555}.vue-flow__edge-textwrapper{pointer-events:all}.vue-flow__edge-textbg{fill:#fff}.vue-flow__edge-text{pointer-events:none;-webkit-user-select:none;user-select:none}.vue-flow__connection{pointer-events:none}.vue-flow__connection .animated{stroke-dasharray:5;animation:.5s linear infinite dashdraw}.vue-flow__connectionline{z-index:1001}.vue-flow__nodes{pointer-events:none;transform-origin:0 0}.vue-flow__node{-webkit-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default;position:absolute}.vue-flow__node.draggable{cursor:grab;pointer-events:all}.vue-flow__node.draggable.dragging{cursor:grabbing}.vue-flow__nodesselection{z-index:3;transform-origin:0 0;pointer-events:none}.vue-flow__nodesselection-rect{pointer-events:all;cursor:grab;position:absolute}.vue-flow__nodesselection-rect.dragging{cursor:grabbing}.vue-flow__handle{pointer-events:none;min-width:5px;min-height:5px;position:absolute}.vue-flow__handle.connectable{pointer-events:all;cursor:crosshair}.vue-flow__handle-bottom{bottom:0;left:50%;transform:translate(-50%,50%)}.vue-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.vue-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.vue-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.vue-flow__edgeupdater{cursor:move;pointer-events:all}.vue-flow__panel{z-index:5;margin:15px;position:absolute}.vue-flow__panel.top{top:0}.vue-flow__panel.bottom{bottom:0}.vue-flow__panel.left{left:0}.vue-flow__panel.right{right:0}.vue-flow__panel.center{left:50%;transform:translate(-50%)}@keyframes dashdraw{0%{stroke-dashoffset:10px}}.vue-flow__controls{box-shadow:0 0 2px 1px #00000014}.vue-flow__controls-button{box-sizing:content-box;cursor:pointer;-webkit-user-select:none;user-select:none;background:#fefefe;border:none;border-bottom:1px solid #eee;justify-content:center;align-items:center;width:16px;height:16px;padding:5px;display:flex}.vue-flow__controls-button svg{width:100%;max-width:12px;max-height:12px}.vue-flow__controls-button:hover{background:#f4f4f4}.vue-flow__controls-button:disabled{pointer-events:none}.vue-flow__controls-button:disabled svg{fill-opacity:.4}.workflow-flow-edge path{stroke:var(--color-muted-foreground);stroke-width:1.5px}.workflow-data-edge path{stroke:var(--color-primary);stroke-dasharray:5 4;stroke-width:1.25px}@keyframes step-running{50%{box-shadow:0 0 0 4px color-mix(in oklab, var(--color-info) 30%, transparent)}}.step-running{animation:1.6s ease-in-out infinite step-running}.workflow-canvas .vue-flow__controls{box-shadow:none}.workflow-canvas .vue-flow__controls-button{background:var(--color-card);border-color:var(--color-border);fill:var(--color-foreground)}.workflow-canvas .vue-flow__controls-button:hover{background:var(--color-secondary)}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-divide-x-reverse:0;--tw-border-style:solid;--tw-divide-y-reverse:0;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--twLine truncated
+74 -74
View File
@@ -1,74 +1,74 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HarnessPage.js","assets/HarnessPage.css"])))=>i.map(i=>d[i]);
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function n(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var r={},i=[],a=()=>{},o=()=>!1,s=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),c=e=>e.startsWith(`onUpdate:`),l=Object.assign,u=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},d=Object.prototype.hasOwnProperty,f=(e,t)=>d.call(e,t),p=Array.isArray,m=e=>w(e)===`[object Map]`,h=e=>w(e)===`[object Set]`,g=e=>w(e)===`[object Date]`,_=e=>w(e)===`[object RegExp]`,v=e=>typeof e==`function`,y=e=>typeof e==`string`,b=e=>typeof e==`symbol`,x=e=>typeof e==`object`&&!!e,S=e=>(x(e)||v(e))&&v(e.then)&&v(e.catch),C=Object.prototype.toString,w=e=>C.call(e),T=e=>w(e).slice(8,-1),E=e=>w(e)===`[object Object]`,D=e=>y(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,O=n(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),ee=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},te=/-\w/g,ne=ee(e=>e.replace(te,e=>e.slice(1).toUpperCase())),re=/\B([A-Z])/g,ie=ee(e=>e.replace(re,`-$1`).toLowerCase()),ae=ee(e=>e.charAt(0).toUpperCase()+e.slice(1)),oe=ee(e=>e?`on${ae(e)}`:``),k=(e,t)=>!Object.is(e,t),se=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},ce=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},le=e=>{let t=parseFloat(e);return isNaN(t)?e:t},ue=e=>{let t=y(e)?Number(e):NaN;return isNaN(t)?e:t},de,fe=()=>de||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{},pe=n(`Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol`);function me(e){if(p(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=y(r)?ve(r):me(r);if(i)for(let e in i)t[e]=i[e]}return t}if(y(e)||x(e))return e}var he=/;(?![^(]*\))/g,ge=/:([^]+)/,_e=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function ve(e){let t={};return e.replace(_e,e=>e.startsWith(`/*`)?``:e).split(he).forEach(e=>{if(e){let n=e.split(ge);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function A(e){let t=``;if(y(e))t=e;else if(p(e))for(let n=0;n<e.length;n++){let r=A(e[n]);r&&(t+=r+` `)}else if(x(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}function ye(e){if(!e)return null;let{class:t,style:n}=e;return t&&!y(t)&&(e.class=A(t)),n&&(e.style=me(n)),e}var be=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,xe=n(be);be+``;function Se(e){return!!e||e===``}function Ce(e,t,n){if(e.length!==t.length)return!1;let r=!0;for(let i=0;r&&i<e.length;i++)r=De(e[i],t[i],n);return r}function we(e,t,n){if(e.size!==t.size)return!1;let r=Array.from(t),i=new Uint8Array(r.length);for(let t of e){let e=-1;for(let a=0;a<r.length;a++)if(!i[a]&&De(t,r[a],n)){e=a;break}if(e<0)return!1;i[e]=1}return!0}function Te(e,t,n){let r=m(e),i=m(t);if(r||i||(r=h(e),i=h(t),r||i))return r&&i?we(e,t,n):!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e){let i=e.hasOwnProperty(r),a=t.hasOwnProperty(r);if(i&&!a||!i&&a||!De(e[r],t[r],n))return!1}return String(e)===String(t)}function Ee(e,t,n,r){n||=[new Map,new Map];let[i,a]=n;if(i.has(e)||a.has(t))return i.get(e)===t&&a.get(t)===e;i.set(e,t),a.set(t,e);let o=r(e,t,n);return i.delete(e),a.delete(t),o}function De(e,t,n){if(e===t)return!0;let r=g(e),i=g(t);return r||i?r&&i?e.getTime()===t.getTime():!1:(r=b(e),i=b(t),r||i?e===t:(r=p(e),i=p(t),r||i?r&&i?Ee(e,t,n,Ce):!1:(r=x(e),i=x(t),r||i?!r||!i?!1:Ee(e,t,n,Te):String(e)===String(t))))}function Oe(e,t){return e.findIndex(e=>De(e,t))}var ke=e=>!!(e&&e.__v_isRef===!0),j=e=>y(e)?e:e==null?``:p(e)||x(e)&&(e.toString===C||!v(e.toString))?ke(e)?j(e.value):JSON.stringify(e,Ae,2):String(e),Ae=(e,t)=>ke(t)?Ae(e,t.value):m(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[je(t,r)+` =>`]=n,e),{})}:h(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>je(e))}:b(t)?je(t):x(t)&&!p(t)&&!E(t)?String(t):t,je=(e,t=``)=>b(e)?`Symbol(${e.description??t})`:e;function Me(e){return e==null?`initial`:typeof Line truncated
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function n(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var r={},i=[],a=()=>{},o=()=>!1,s=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),c=e=>e.startsWith(`onUpdate:`),l=Object.assign,u=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},d=Object.prototype.hasOwnProperty,f=(e,t)=>d.call(e,t),p=Array.isArray,m=e=>w(e)===`[object Map]`,h=e=>w(e)===`[object Set]`,g=e=>w(e)===`[object Date]`,_=e=>w(e)===`[object RegExp]`,v=e=>typeof e==`function`,y=e=>typeof e==`string`,b=e=>typeof e==`symbol`,x=e=>typeof e==`object`&&!!e,S=e=>(x(e)||v(e))&&v(e.then)&&v(e.catch),C=Object.prototype.toString,w=e=>C.call(e),T=e=>w(e).slice(8,-1),E=e=>w(e)===`[object Object]`,D=e=>y(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,O=n(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),ee=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},te=/-\w/g,ne=ee(e=>e.replace(te,e=>e.slice(1).toUpperCase())),re=/\B([A-Z])/g,ie=ee(e=>e.replace(re,`-$1`).toLowerCase()),ae=ee(e=>e.charAt(0).toUpperCase()+e.slice(1)),oe=ee(e=>e?`on${ae(e)}`:``),k=(e,t)=>!Object.is(e,t),se=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},ce=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},le=e=>{let t=parseFloat(e);return isNaN(t)?e:t},ue=e=>{let t=y(e)?Number(e):NaN;return isNaN(t)?e:t},de,fe=()=>de||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{},pe=n(`Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol`);function me(e){if(p(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=y(r)?ve(r):me(r);if(i)for(let e in i)t[e]=i[e]}return t}if(y(e)||x(e))return e}var he=/;(?![^(]*\))/g,ge=/:([^]+)/,_e=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function ve(e){let t={};return e.replace(_e,e=>e.startsWith(`/*`)?``:e).split(he).forEach(e=>{if(e){let n=e.split(ge);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function A(e){let t=``;if(y(e))t=e;else if(p(e))for(let n=0;n<e.length;n++){let r=A(e[n]);r&&(t+=r+` `)}else if(x(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}function ye(e){if(!e)return null;let{class:t,style:n}=e;return t&&!y(t)&&(e.class=A(t)),n&&(e.style=me(n)),e}var be=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,xe=n(be);be+``;function Se(e){return!!e||e===``}function Ce(e,t,n){if(e.length!==t.length)return!1;let r=!0;for(let i=0;r&&i<e.length;i++)r=De(e[i],t[i],n);return r}function we(e,t,n){if(e.size!==t.size)return!1;let r=Array.from(t),i=new Uint8Array(r.length);for(let t of e){let e=-1;for(let a=0;a<r.length;a++)if(!i[a]&&De(t,r[a],n)){e=a;break}if(e<0)return!1;i[e]=1}return!0}function Te(e,t,n){let r=m(e),i=m(t);if(r||i||(r=h(e),i=h(t),r||i))return r&&i?we(e,t,n):!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e){let i=e.hasOwnProperty(r),a=t.hasOwnProperty(r);if(i&&!a||!i&&a||!De(e[r],t[r],n))return!1}return String(e)===String(t)}function Ee(e,t,n,r){n||=[new Map,new Map];let[i,a]=n;if(i.has(e)||a.has(t))return i.get(e)===t&&a.get(t)===e;i.set(e,t),a.set(t,e);let o=r(e,t,n);return i.delete(e),a.delete(t),o}function De(e,t,n){if(e===t)return!0;let r=g(e),i=g(t);return r||i?r&&i?e.getTime()===t.getTime():!1:(r=b(e),i=b(t),r||i?e===t:(r=p(e),i=p(t),r||i?r&&i?Ee(e,t,n,Ce):!1:(r=x(e),i=x(t),r||i?!r||!i?!1:Ee(e,t,n,Te):String(e)===String(t))))}function Oe(e,t){return e.findIndex(e=>De(e,t))}var ke=e=>!!(e&&e.__v_isRef===!0),j=e=>y(e)?e:e==null?``:p(e)||x(e)&&(e.toString===C||!v(e.toString))?ke(e)?j(e.value):JSON.stringify(e,Ae,2):String(e),Ae=(e,t)=>ke(t)?Ae(e,t.value):m(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[je(t,r)+` =>`]=n,e),{})}:h(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>je(e))}:b(t)?je(t):x(t)&&!p(t)&&!E(t)?String(t):t,je=(e,t=``)=>b(e)?`Symbol(${e.description??t})`:e;function Me(e){return e==null?`initial`:typeof Line truncated
`&&(e.tagName===`PRE`||e.tagName===`TEXTAREA`)&&(n=n.slice(1));let{textContent:r}=e;r!==n&&r!==n.replace(/\r\n|\r/g,`
`)&&(pi(e,0)||ri(),e.textContent=t.children)}if(d){if(_||b||!o||f&48){let t=e.tagName.includes(`-`),i=e.namespaceURI.includes(`svg`)?`svg`:e.namespaceURI.includes(`MathML`)?`mathml`:void 0;for(let a in d)if(_&&(a.endsWith(`value`)||a===`indeterminate`)||s(a)&&!O(a)||a[0]===`.`||t&&!O(a)||u&&u.includes(a)){if(ui(e,a,d[a]))continue;r(e,a,null,d[a],i,n)}}else if(d.onClick)r(e,`onClick`,null,d.onClick,void 0,n);else if(f&4&&$t(d.style))for(let e in d.style)d.style[e]}let x;(x=d&&d.onVnodeBeforeMount)&&us(x,n,t),h&&lr(t,null,n,`beforeMount`),((x=d&&d.onVnodeMounted)||h||l)&&Ho(()=>{x&&us(x,n,t),l&&g.enter(e),h&&lr(t,null,n,`mounted`)},i)}return e.nextSibling},m=(e,t,r,o,s,c,u)=>{u||=!!t.dynamicChildren;let d=t.children,p=d.length,m=!1;for(let t=0;t<p;t++){let h=u?d[t]:d[t]=ss(d[t]),g=h.type===Wo;e?(g&&!u&&t+1<p&&ss(d[t+1]).type===Wo&&(l(i(e.data.slice(h.children.length)),r,a(e)),e.data=h.children),e=f(e,h,o,s,c,u)):g&&!h.children?l(h.el=i(``),r):(m||(m=!0,pi(r,1)||ri()),n(null,h,r,null,o,s,oi(r),c))}return e},h=(e,t,n,r,i,s)=>{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&si(f)&&f.data===`]`?a(t.anchor=f):(ri(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,s,l)=>{if(hi(e,t)||ri(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)c(n);else break}}let u=a(e),d=o(e);return c(e),n(null,t,d,u,r,i,oi(d),s),r&&(r.vnode.el=t.el,eo(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&si(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var li=new Set([`src`,`srcset`,`href`,`poster`]);function ui(e,t,n){return li.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var di=`data-allow-mismatch`,fi={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function pi(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(di);)e=e.parentElement;return mi(e&&e.getAttribute(di),t)}function mi(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(fi[t])}}function hi(e,t){return pi(e.parentElement,1)||gi(e)||_i(t)}function gi(e){return e.nodeType===1&&mi(e.getAttribute(di),1)}function _i({props:e}){let t=e&&e[di];return typeof t==`string`&&mi(t,1)}var vi=fe().requestIdleCallback||(e=>setTimeout(e,1)),yi=fe().cancelIdleCallback||(e=>clearTimeout(e)),bi=(e=1e4)=>t=>{let n=vi(t,{timeout:e});return()=>yi(n)};function xi(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t<a||r>0&&r<a)&&(n>0&&n<o||i>0&&i<o)}var Si=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return n(e=>{if(e instanceof Element){if(xi(e))return t(),r.disconnect(),!1;r.observe(e)}}),()=>r.disconnect()},Ci=e=>t=>{if(e){let n=matchMedia(e);if(n.matches)t();else return n.addEventListener(`change`,t,{once:!0}),()=>n.removeEventListener(`change`,t)}},wi=(e=[])=>(t,n)=>{y(e)&&(e=[e]);let r=!1,i=e=>{r||(r=!0,a(),t(),e.target.dispatchEvent(new e.constructor(e.type,e)))},a=()=>{n(t=>{for(let n of e)t.removeEventListener(n,i)})};return n(t=>{for(let n of e)t.addEventListener(n,i,{once:!0})}),a};function Ti(e,t){if(si(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(si(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var Ei=e=>!!e.type.__asyncLoader;function Di(e){v(e)&&(e={loader:e});let{loader:t,loadingComponent:n,errorComponent:r,delay:i=200,hydrate:a,timeout:o,suspensible:s=!0,onError:c}=e,l=null,u,d=0,f=()=>(d++,l=null,p()),p=()=>{let e;return l||(e=l=t().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(f()),()=>n(e),d+1)});throw e}).then(t=>e!==l&&l?l:(t&&(t.__esModule||t[Symbol.toStringTag]===`Module`)&&(t=t.default),u=t,t)))};return I({name:`AsyncComponentWrapper`,__asyncLoader:p,__asyncHydrate(e,t,n){let r=e.isConnected,i=!1;(t.bu||=[]).push(()=>i=!0);let o=()=>{i||!e.parentNode||r&&!e.isConnected||n()},s=a?()=>{let n=a(o,t=>Ti(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=ms;if(Xr(e),u)return()=>Oi(u,e);let t=t=>{l=null,Rn(t,e,13,!r)};if(s&&e.suspense||xs)return p().then(t=>()=>Oi(t,e)).catch(e=>(t(e),()=>r?W(r,{error:e}):null));let a=M(!1),c=M(),d=M(!!i),f,m;return Gi(()=>{f!=null&&clearTimeout(f),m!=null&&clearTimeout(m)}),i&&(m=setTimeout(()=>{e.isUnmounted||(d.value=!1)},i)),o!=null&&(f=setTimeout(()=>{if(!e.isUnmounted&&!a.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);t(e),c.value=e}},o)),p().then(()=>{e.isUnmounted||(a.value=!0,e.parent&&ki(e.parent.vnode)&&e.parent.update())}).catch(n=>{if(e.isUnmounted){l=null;return}t(n),c.value=n}),()=>{if(a.value&&u)return Oi(u,e);if(c.value&&r)return W(r,{error:c.value});if(n&&!d Line truncated
`))),e[Sl]=yl(i);let a=r||i.props&&i.props.type===`number`;Bc(e,t?`change`:`input`,t=>{t.target.composing||e[Sl](wl(e.value,n,a))}),(n||a)&&Bc(e,`change`,()=>{e.value=wl(e.value,n,a)}),t||(Bc(e,`compositionstart`,bl),Bc(e,`compositionend`,xl),Bc(e,`change`,xl))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[Cl];delete e[Cl],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Sl](wl(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Sl]=yl(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?le(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},El={deep:!0,created(e,t,n){e[Sl]=yl(n),Bc(e,`change`,()=>{let t=e._modelValue,n=jl(e),r=e.checked,i=e[Sl];if(p(t)){let e=Oe(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(h(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(Ml(e,r))})},mounted:Dl,beforeUpdate(e,t,n){e[Sl]=yl(n),Dl(e,t,n)}};function Dl(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(p(t))i=Oe(t,r.props.value)>-1;else if(h(t))i=t.has(r.props.value);else{if(t===n)return;i=De(t,Ml(e,!0))}e.checked!==i&&(e.checked=i)}var Ol={created(e,{value:t},n){e.checked=De(t,n.props.value),e[Sl]=yl(n),Bc(e,`change`,()=>{e[Sl](jl(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Sl]=yl(r),t!==n&&(e.checked=De(t,r.props.value))}},kl={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,Bc(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?le(jl(e)):jl(e)),r=e.multiple,i=r?h(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?p(i)?t.slice():t:i];try{e[Sl](i)}finally{qn(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Sl]=yl(r)},mounted(e,{value:t}){Al(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Sl]=yl(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!yee(t,n[1],n[0]))&&Al(e,t)}};function yee(e,t,n){if(!n||p(e))return De(e,t);if(h(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function Al(e,t){let n=e.multiple,r=p(t);if(!n||r||h(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=jl(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Oe(t,o)>-1}else a.selected=t.has(o)}else if(De(jl(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function jl(e){return`_value`in e?e._value:e.value}function Ml(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var Nl={created(e,t,n){Fl(e,t,n,null,`created`)},mounted(e,t,n){Fl(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){Fl(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){Fl(e,t,n,r,`updated`)}};function Pl(e,t){switch(e){case`SELECT`:return kl;case`TEXTAREA`:return Tl;default:switch(t){case`checkbox`:return El;case`radio`:return Ol;default:return Tl}}}function Fl(e,t,n,r,i){let a=Pl(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function bee(){Tl.getSSRProps=({value:e})=>({value:e}),Ol.getSSRProps=({value:e},t)=>{if(t.props&&De(t.props.value,e))return{checked:!0}},El.getSSRProps=({value:e},t)=>{if(p(e)){if(t.props&&Oe(e,t.props.value)>-1)return{checked:!0}}else if(h(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},Nl.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=Pl(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var xee=[`ctrl`,`shift`,`alt`,`meta`],See={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>xee.some(n=>e[`${n}Key`]&&!t.includes(n))},Il=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=See[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},Cee={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},Ll=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=ie(n.key);if(t.some(e=>e===r||Cee[e]===r))return e(n)}))},Rl=l({patchProp:Qc},Qs),zl,Bl=!1;function Vl(){return zl||=xo(Rl)}function Hl(){return zl=Bl?zl:So(Rl),Bl=!0,zl}var Ul=((...e)=>{Vl().render(...e)}),Wl=((...e)=>{Hl().hydrate(...e)}),Gl=((...e)=>{let t=Vl().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Jl(e);if(!r)return;let i=t._component;!v(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,ql(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a}, Line truncated
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Mp;function Np(e){Mp=e}var Pp=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Fp(e){let t=e instanceof Pp?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 Ip(e,t){let n=await fetch(e,t);if(Mp?.(n.status===401),!n.ok)throw new Pp(await jp(n),n.status);return n}async function Lp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=kp,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 Ip(e,s);return a?await c.json():void 0}var X={health:()=>Lp(`/health/detailed`),services:()=>Lp(`/api/services`),policies:()=>Lp(`/api/access/policies`),putPolicy:e=>Lp(`/api/access/policies`,{method:`PUT`,body:e}),deletePolicy:e=>Lp(`/api/access/policies`,{method:`DELETE`,body:e,parse:!1}),orgs:()=>Lp(`/api/orgs`),orgCreate:e=>Lp(`/api/orgs`,{method:`POST`,body:e}),org:e=>Lp(`/api/orgs/${encodeURIComponent(e)}`),orgWorkspaces:e=>Lp(`/api/orgs/${encodeURIComponent(e)}/workspaces`),createOrgWorkspace:(e,t)=>Lp(`/api/orgs/${encodeURIComponent(e)}/workspaces`,{method:`POST`,body:t}),orgMembers:e=>Lp(`/api/orgs/${encodeURIComponent(e)}/members`),setOrgMember:(e,t,n)=>Lp(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`PUT`,body:n}),removeOrgMember:(e,t,n)=>Lp(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`+Ap({workspace:n}),{method:`DELETE`,parse:!1}),assignOrgAgent:(e,t)=>Lp(`/api/orgs/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}`,{method:`PUT`}),summary:()=>Lp(`/api/summary`),tasks:()=>Lp(`/api/tasks`),taskPage:async e=>{let t=await Ip(`/api/tasks`+Ap(e),{headers:{Accept:`application/json`},signal:AbortSignal.timeout(kp)});return{tasks:await t.json(),next:t.headers.get(`X-Next-Cursor`)}},taskMeta:()=>Lp(`/api/task-meta`),task:e=>Lp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Lp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Lp(`/api/tasks/${encodeURIComponent(e)}/changes`+Ap(t)),taskDebug:(e,t)=>Lp(`/api/tasks/${encodeURIComponent(e)}/debug`+Ap(t)),taskAction:(e,t,n)=>Lp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t,...n}}),setup:()=>Lp(`/api/setup`),capabilities:()=>Lp(`/api/capabilities`),workflows:()=>Lp(`/api/workflows`),workflowEnabled:(e,t)=>Lp(`/api/workflows/${encodeURIComponent(e)}/enabled`,{method:`PUT`,body:{enabled:t},parse:!1}),workRequest:e=>Lp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Lp(`/api/skills`),channels:()=>Lp(`/api/channels`),curators:()=>Lp(`/api/curators`),channelReload:e=>Lp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Lp(`/api/config`),logs:e=>Lp(`/api/logs`+Ap(e)),taskLogs:(e,t)=>Lp(`/api/tasks/${encodeURIComponent(e)}/logs`+Ap(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>Lp(`/api/version`),updateSnapshot:()=>Lp(`/api/chat/update`),updateInstall:e=>Lp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>Lp(`/api/captures`+Ap({limit:e})),eventTypes:()=>Lp(`/api/event-types`),eventTypeCreate:e=>Lp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>Lp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>Lp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>Lp(`/api/mappings`),mappingCreate:e=>Lp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Lp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Lp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Lp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Lp(`/api/bindings`),dispatches:(e,t)=>Lp(`/api/${e}/${encodeURIComponent(t)}/dispatches`),bindingCreate:e=>Lp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Lp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Lp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Lp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),bindingPause:e=>Lp(`/api/bindings/${encodeURIComponent(e)}/pause`,{method:`POST`}),bindingResume:e=>Lp(`/api/bindings/${encodeURIComponent(e)}/resume`,{method:`POST`}),harnessBindings:()=>Lp(`/api/harness/bindings`),sources:()=>Lp(`/api/sources`),sourceCreate:e=>Lp(`/api/sources`,{method:`POST`,body:{path:e}}),sourceSigning:(e,t)=>Lp(`/api/sources/${encodeURIComponent(e)}/signing`,{method:`POST`,body:{signed:t}}),sourceApproveUnsigned:e=>Lp(`/api/sources/${encodeURIComponent(e)}/aLine truncated
`)&&(xi(e,0)||fi(),e.textContent=t.children)}if(d){if(_||b||!o||f&48){let t=e.tagName.includes(`-`),i=e.namespaceURI.includes(`svg`)?`svg`:e.namespaceURI.includes(`MathML`)?`mathml`:void 0;for(let a in d)if(_&&(a.endsWith(`value`)||a===`indeterminate`)||s(a)&&!O(a)||a[0]===`.`||t&&!O(a)||u&&u.includes(a)){if(yi(e,a,d[a]))continue;r(e,a,null,d[a],i,n)}}else if(d.onClick)r(e,`onClick`,null,d.onClick,void 0,n);else if(f&4&&tn(d.style))for(let e in d.style)d.style[e]}let x;(x=d&&d.onVnodeBeforeMount)&&gs(x,n,t),h&&_r(t,null,n,`beforeMount`),((x=d&&d.onVnodeMounted)||h||l)&&qo(()=>{x&&gs(x,n,t),l&&g.enter(e),h&&_r(t,null,n,`mounted`)},i)}return e.nextSibling},m=(e,t,r,o,s,c,u)=>{u||=!!t.dynamicChildren;let d=t.children,p=d.length,m=!1;for(let t=0;t<p;t++){let h=u?d[t]:d[t]=ps(d[t]),g=h.type===Xo;e?(g&&!u&&t+1<p&&ps(d[t+1]).type===Xo&&(l(i(e.data.slice(h.children.length)),r,a(e)),e.data=h.children),e=f(e,h,o,s,c,u)):g&&!h.children?l(h.el=i(``),r):(m||(m=!0,xi(r,1)||fi()),n(null,h,r,null,o,s,hi(r),c))}return e},h=(e,t,n,r,i,s)=>{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&gi(f)&&f.data===`]`?a(t.anchor=f):(fi(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,s,l)=>{if(iee(e,t)||fi(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)c(n);else break}}let u=a(e),d=o(e);return c(e),n(null,t,d,u,r,i,hi(d),s),r&&(r.vnode.el=t.el,ao(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&gi(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var vi=new Set([`src`,`srcset`,`href`,`poster`]);function yi(e,t,n){return vi.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var bi=`data-allow-mismatch`,ree={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function xi(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(bi);)e=e.parentElement;return Si(e&&e.getAttribute(bi),t)}function Si(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(ree[t])}}function iee(e,t){return xi(e.parentElement,1)||aee(e)||oee(t)}function aee(e){return e.nodeType===1&&Si(e.getAttribute(bi),1)}function oee({props:e}){let t=e&&e[bi];return typeof t==`string`&&Si(t,1)}var see=fe().requestIdleCallback||(e=>setTimeout(e,1)),cee=fe().cancelIdleCallback||(e=>clearTimeout(e)),Ci=(e=1e4)=>t=>{let n=see(t,{timeout:e});return()=>cee(n)};function lee(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t<a||r>0&&r<a)&&(n>0&&n<o||i>0&&i<o)}var wi=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return n(e=>{if(e instanceof Element){if(lee(e))return t(),r.disconnect(),!1;r.observe(e)}}),()=>r.disconnect()},Ti=e=>t=>{if(e){let n=matchMedia(e);if(n.matches)t();else return n.addEventListener(`change`,t,{once:!0}),()=>n.removeEventListener(`change`,t)}},Ei=(e=[])=>(t,n)=>{y(e)&&(e=[e]);let r=!1,i=e=>{r||(r=!0,a(),t(),e.target.dispatchEvent(new e.constructor(e.type,e)))},a=()=>{n(t=>{for(let n of e)t.removeEventListener(n,i)})};return n(t=>{for(let n of e)t.addEventListener(n,i,{once:!0})}),a};function Di(e,t){if(gi(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(gi(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var Oi=e=>!!e.type.__asyncLoader;function ki(e){v(e)&&(e={loader:e});let{loader:t,loadingComponent:n,errorComponent:r,delay:i=200,hydrate:a,timeout:o,suspensible:s=!0,onError:c}=e,l=null,u,d=0,f=()=>(d++,l=null,p()),p=()=>{let e;return l||(e=l=t().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(f()),()=>n(e),d+1)});throw e}).then(t=>e!==l&&l?l:(t&&(t.__esModule||t[Symbol.toStringTag]===`Module`)&&(t=t.default),u=t,t)))};return I({name:`AsyncComponentWrapper`,__asyncLoader:p,__asyncHydrate(e,t,n){let r=e.isConnected,i=!1;(t.bu||=[]).push(()=>i=!0);let o=()=>{i||!e.parentNode||r&&!e.isConnected||n()},s=a?()=>{let n=a(o,t=>Di(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=bs;if(ai(e),u)return()=>Ai(u,e);let t=t=>{l=null,Wn(t,e,13,!r)};if(s&&e.suspense||Ds)return p().then(t=>()=>Ai(t,e)).catch(e=>(t(e),()=>r?W(r,{error:e}):null));let a=M(!1),c=M(),d=M(!!i),f,m;return qi(()=>{f!=null&&clearTimeout(f),m!=null&&clearTimeout(m)}),i&&(m=setTimeout(()=>{e.isUnmounted||(d.value=!1)},i)),o!=null&&(f=setTimeout(()=>{if(!e.isUnmounted&&!a.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);t(e),c.value=e}},o)),p().then(()=>{e.isUnmounted||(a.value=!0,e.parent&&ji(e.parent.vnode)&&e.parent.update())}).catch(n=>{if(e.isUnmounted){l=null;return}t(n),c.value=n}),()=>{if(a.value&&u)return Ai(u,e);if(c.value&&r)return W(r,{error:c.va Line truncated
`))),e[Ol]=Tl(i);let a=r||i.props&&i.props.type===`number`;Kc(e,t?`change`:`input`,t=>{t.target.composing||e[Ol](Al(e.value,n,a))}),(n||a)&&Kc(e,`change`,()=>{e.value=Al(e.value,n,a)}),t||(Kc(e,`compositionstart`,El),Kc(e,`compositionend`,Dl),Kc(e,`change`,Dl))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[kl];delete e[kl],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Ol](Al(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Ol]=Tl(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?le(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Ml={deep:!0,created(e,t,n){e[Ol]=Tl(n),Kc(e,`change`,()=>{let t=e._modelValue,n=Rl(e),r=e.checked,i=e[Ol];if(p(t)){let e=Oe(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(h(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(zl(e,r))})},mounted:Nl,beforeUpdate(e,t,n){e[Ol]=Tl(n),Nl(e,t,n)}};function Nl(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(p(t))i=Oe(t,r.props.value)>-1;else if(h(t))i=t.has(r.props.value);else{if(t===n)return;i=De(t,zl(e,!0))}e.checked!==i&&(e.checked=i)}var Pl={created(e,{value:t},n){e.checked=De(t,n.props.value),e[Ol]=Tl(n),Kc(e,`change`,()=>{e[Ol](Rl(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Ol]=Tl(r),t!==n&&(e.checked=De(t,r.props.value))}},Fl={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,Kc(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?le(Rl(e)):Rl(e)),r=e.multiple,i=r?h(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?p(i)?t.slice():t:i];try{e[Ol](i)}finally{$n(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Ol]=Tl(r)},mounted(e,{value:t}){Ll(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Ol]=Tl(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!Il(t,n[1],n[0]))&&Ll(e,t)}};function Il(e,t,n){if(!n||p(e))return De(e,t);if(h(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function Ll(e,t){let n=e.multiple,r=p(t);if(!n||r||h(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=Rl(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Oe(t,o)>-1}else a.selected=t.has(o)}else if(De(Rl(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function Rl(e){return`_value`in e?e._value:e.value}function zl(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var Bl={created(e,t,n){Hl(e,t,n,null,`created`)},mounted(e,t,n){Hl(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){Hl(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){Hl(e,t,n,r,`updated`)}};function Vl(e,t){switch(e){case`SELECT`:return Fl;case`TEXTAREA`:return jl;default:switch(t){case`checkbox`:return Ml;case`radio`:return Pl;default:return jl}}}function Hl(e,t,n,r,i){let a=Vl(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function Ul(){jl.getSSRProps=({value:e})=>({value:e}),Pl.getSSRProps=({value:e},t)=>{if(t.props&&De(t.props.value,e))return{checked:!0}},Ml.getSSRProps=({value:e},t)=>{if(p(e)){if(t.props&&Oe(e,t.props.value)>-1)return{checked:!0}}else if(h(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},Bl.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=Vl(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var Wl=[`ctrl`,`shift`,`alt`,`meta`],Gl={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>Wl.some(n=>e[`${n}Key`]&&!t.includes(n))},Kl=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=Gl[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},ql={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},Jl=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=ie(n.key);if(t.some(e=>e===r||ql[e]===r))return e(n)}))},Yl=l({patchProp:il},ic),Xl,Zl=!1;function Ql(){return Xl||=Eo(Yl)}function $l(){return Xl=Zl?Xl:Do(Yl),Zl=!0,Xl}var eu=((...e)=>{Ql().render(...e)}),tu=((...e)=>{$l().hydrate(...e)}),nu=((...e)=>{let t=Ql().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=au(e);if(!r)return;let i=t._component;!v(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,iu(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t}),ru=(( Line truncated
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var dp;function fp(e){dp=e}var pp=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function mp(e){let t=e instanceof pp?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 hp(e,t){let n=await fetch(e,t);if(dp?.(n.status===401),!n.ok)throw new pp(await up(n),n.status);return n}async function gp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=cp,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 hp(e,s);return a?await c.json():void 0}var X={health:()=>gp(`/health/detailed`),services:()=>gp(`/api/services`),policies:()=>gp(`/api/access/policies`),putPolicy:e=>gp(`/api/access/policies`,{method:`PUT`,body:e}),deletePolicy:e=>gp(`/api/access/policies`,{method:`DELETE`,body:e,parse:!1}),orgs:()=>gp(`/api/orgs`),orgCreate:e=>gp(`/api/orgs`,{method:`POST`,body:e}),org:e=>gp(`/api/orgs/${encodeURIComponent(e)}`),orgWorkspaces:e=>gp(`/api/orgs/${encodeURIComponent(e)}/workspaces`),createOrgWorkspace:(e,t)=>gp(`/api/orgs/${encodeURIComponent(e)}/workspaces`,{method:`POST`,body:t}),orgMembers:e=>gp(`/api/orgs/${encodeURIComponent(e)}/members`),setOrgMember:(e,t,n)=>gp(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`PUT`,body:n}),removeOrgMember:(e,t,n)=>gp(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`+lp({workspace:n}),{method:`DELETE`,parse:!1}),assignOrgAgent:(e,t)=>gp(`/api/orgs/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}`,{method:`PUT`}),summary:()=>gp(`/api/summary`),tasks:()=>gp(`/api/tasks`),taskPage:async e=>{let t=await hp(`/api/tasks`+lp(e),{headers:{Accept:`application/json`},signal:AbortSignal.timeout(cp)});return{tasks:await t.json(),next:t.headers.get(`X-Next-Cursor`)}},taskMeta:()=>gp(`/api/task-meta`),task:e=>gp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>gp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>gp(`/api/tasks/${encodeURIComponent(e)}/changes`+lp(t)),taskDebug:(e,t)=>gp(`/api/tasks/${encodeURIComponent(e)}/debug`+lp(t)),taskAction:(e,t,n)=>gp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t,...n}}),setup:()=>gp(`/api/setup`),capabilities:()=>gp(`/api/capabilities`),workflows:()=>gp(`/api/workflows`),workflowEnabled:(e,t)=>gp(`/api/workflows/${encodeURIComponent(e)}/enabled`,{method:`PUT`,body:{enabled:t},parse:!1}),workRequest:e=>gp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>gp(`/api/skills`),channels:()=>gp(`/api/channels`),curators:()=>gp(`/api/curators`),channelReload:e=>gp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>gp(`/api/config`),logs:e=>gp(`/api/logs`+lp(e)),taskLogs:(e,t)=>gp(`/api/tasks/${encodeURIComponent(e)}/logs`+lp(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>gp(`/api/version`),updateSnapshot:()=>gp(`/api/chat/update`),updateDefer:e=>gp(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),updateInstall:e=>gp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>gp(`/api/captures`+lp({limit:e})),eventTypes:()=>gp(`/api/event-types`),eventTypeCreate:e=>gp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>gp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>gp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>gp(`/api/mappings`),mappingCreate:e=>gp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>gp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>gp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>gp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>gp(`/api/bindings`),dispatches:(e,t)=>gp(`/api/${e}/${encodeURIComponent(t)}/dispatches`),bindingCreate:e=>gp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>gp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>gp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>gp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),bindingPause:e=>gp(`/api/bindings/${encodeURIComponent(e)}/pause`,{method:`POST`}),bindingResume:e=>gp(`/api/bindings/${encodeURIComponent(e)}/resume`,{method:`POST`}),harnessBindings:()=>gp(`/api/harness/bindings`),sources:()=>gp(`/api/sources`),sourceCreate:e=>gp(`/api/sources`,{method:`POST`,body:{path:e}}),sourceSigning:(e,t)=>gp(`/api/sources/${encodeURIComponent(e)}/signing`,{method:`POST`,body:{si Line 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&&($p.value=n.session_id),n.type===`delta`&&(o+=n.text,im.value=im.value?{...im.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],im.value=im.value?{...im.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`);em.value=[...em.value,{from:`assistant`,text:o,tool_calls:a}],im.value=null,nm.value=`Ready`,await ym()}catch(e){let t=e;t.name===`AbortError`&&!c?(im.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},nm.value=`Stopped`):(im.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?Jp(r):void 0,isRetry:i},nm.value=`Error — retry available`)}finally{clearTimeout(l),_m=null,rm.value=!1}}function Mee(){nm.value=`Stopping…`,$p.value&&X.chatCancel($p.value).catch(()=>{}),vm()}function Nee(){Vi(()=>{ym().catch(e=>{nm.value=e.message||`Chat unavailable`})}),Gi(()=>{vm()})}var Pee=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],Fee=I({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return Y(`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)=>(B(),V(`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":N(Xp),onClick:i[0]||=e=>n(`toggle`)},[U(`span`,{"aria-hidden":`true`,class:A(r(!e.open))},[W(N(_d),{size:22})],2),U(`span`,{"aria-hidden":`true`,class:A(r(e.open))},[W(N(qd),{size:22})],2)],8,Pee))}});function Tm(e){return typeof e==`string`?`'${e}'`:new Lee().serialize(e)}var Iee=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Em=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Iee.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Dm(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&&Em[n]?Em[n]:n+128,s=a<128&&Em[a]?Em[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 Lee=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Dm(e,t):n===`number`&&r===`number`?e-t:Dm(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(Dm),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
`);d=n.pop()||``;for(let e of n){let t=e.split(`
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(Np.value=n.session_id),n.type===`delta`&&(o+=n.text,Rp.value=Rp.value?{...Rp.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],Rp.value=Rp.value?{...Rp.value,tools:a}:null),n.type===`ask`&&n.ask&&(clearTimeout(l),Rp.value=Rp.value?{...Rp.value,ask:n.ask}: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`);Pp.value=[...Pp.value,{from:`assistant`,text:o,tool_calls:a}],Rp.value=null,Ip.value=`Ready`,await $p()}catch(e){let t=e;t.name===`AbortError`&&!c?(Rp.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},Ip.value=`Stopped`):(Rp.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?Dp(r):void 0,isRetry:i},Ip.value=`Error — retry available`)}finally{clearTimeout(l),Ap=null,Zp=null,Lp.value=!1}}function fm(){Ip.value=`Stopping…`,Np.value&&X.chatCancel(Np.value).catch(()=>{}),Qp()}function pm(){Ui(()=>{$p().catch(e=>{Ip.value=e.message||`Chat unavailable`})}),qi(()=>{Qp()})}async function mm(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));await dm({textOverride:`🎤 Voice message`,voice:{data:btoa(n),mime_type:e.type||`audio/webm`}})}var hm=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],gm=I({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return Y(`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)=>(B(),V(`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":N(kp),onClick:i[0]||=e=>n(`toggle`)},[U(`span`,{"aria-hidden":`true`,class:A(r(!e.open))},[W(N(Od),{size:22})],2),U(`span`,{"aria-hidden":`true`,class:A(r(e.open))},[W(N(of),{size:22})],2)],8,hm))}});function _m(e){return typeof e==`string`?`'${e}'`:new xm().serialize(e)}var vm=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,ym=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[vm.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function bm(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&&ym[n]?ym[n]:n+128,s=a<128&&ym[a]?ym[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 xm=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?bm(e,t):n===`number`&&r===`number`?e-t:bm(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(bm),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.$ArLine truncated
`)].join(`
`))}return()=>i.value||r.value||o.value?Fs(t.default({present:o.value})[0],{ref:e=>{let t=Qm(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),gg=I({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=mh(n.default()),r=e.findIndex(e=>e.type!==Go);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?q(t,i.props):t,o=as({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),_g=[`area`,`img`,`input`],vg=I({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`&&_g.includes(r)?()=>Fs(r,t):r===`template`?()=>Fs(gg,t,{default:n.default}):()=>Fs(e.as,t,{default:n.default})}});function yg(){let e=M();return{primitiveElement:e,currentElement:J(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:Qm(e))}}var[bg,xg]=Mm(`CollapsibleRoot`),Sg=I({__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=ph(r,`open`,n,{defaultValue:r.defaultOpen,passive:r.open===void 0}),{disabled:a,unmountOnHide:o}=vn(r);return xg({contentId:``,disabled:a,open:i,unmountOnHide:o,onOpenToggle:()=>{a.value||(i.value=!i.value)}}),t({open:i}),Z(),(e,t)=>(B(),H(N(vg),{as:e.as,"as-child":r.asChild,"data-state":N(i)?`open`:`closed`,"data-disabled":N(a)?``:void 0},{default:P(()=>[R(e.$slots,`default`,{open:N(i)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),Cg=I({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=bg();i.contentId||=ag(void 0,`reka-collapsible-content`);let a=M(),{forwardRef:o,currentElement:s}=Z(),c=M(0),l=M(0),u=J(()=>i.open.value),d=M(u.value),f=M();F(()=>[u.value,a.value?.present],async()=>{await qn();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=J(()=>d.value&&i.open.value);return Vi(()=>{requestAnimationFrame(()=>{d.value=!1})}),$m(s,`beforematch`,e=>{requestAnimationFrame(()=>{i.onOpenToggle(),r(`contentFound`)})}),(e,t)=>(B(),H(N(hg),{ref_key:`presentRef`,ref:a,present:e.forceMount||N(i).open.value,"force-mount":!0},{default:P(({present:t})=>[W(N(vg),q(e.$attrs,{id:N(i).contentId,ref:N(o),"as-child":n.asChild,as:e.as,hidden:t?void 0:N(i).unmountOnHide.value?``:`until-found`,"data-state":p.value?void 0:N(i).open.value?`open`:`closed`,"data-disabled":N(i).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${l.value}px`,"--reka-collapsible-content-width":`${c.value}px`}}),{default:P(()=>[!N(i).unmountOnHide.value||t?R(e.$slots,`default`,{key:0}):K(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),wg=I({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;Z();let n=bg();return(e,r)=>(B(),H(N(vg),{type:e.as===`button`?`button`:void 0,as:e.as,"as-child":t.asChild,"aria-controls":N(n).contentId,"aria-expanded":N(n).open.value,"data-state":N(n).open.value?`open`:`closed`,"data-disabled":N(n).disabled?.value?``:void 0,disabled:N(n).disabled?.value,onClick:N(n).onOpenToggle},{default:P(()=>[R(e.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}});function Tg({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 Eg({type:e,defaultValue:t,modelValue:n}){return e||Tg({type:e,defaultValue:t,modelValue:n})}function Dg({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function Og(e,t){let n=J(()=>Eg(e)),r=ph(e,`modelValue`,t,{defaultValue:Dg(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=Om(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(Im(t,e)){let n=t.findIndex(t=>Om(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:J(()=>n.value===`single`)}}var[kg,Ag]=Mm(`AccordionRoot`),jg=I({__name:`AccordionRoot`,props:{collapsible:{type:Boolean,required:! Line truncated
`))}return()=>i.value||r.value||o.value?Vs(t.default({present:o.value})[0],{ref:e=>{let t=qm(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),dg=I({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=lh(n.default()),r=e.findIndex(e=>e.type!==Zo);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?q(t,i.props):t,o=ds({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),fg=[`area`,`img`,`input`],pg=I({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`&&fg.includes(r)?()=>Vs(r,t):r===`template`?()=>Vs(dg,t,{default:n.default}):()=>Vs(e.as,t,{default:n.default})}});function mg(){let e=M();return{primitiveElement:e,currentElement:J(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:qm(e))}}var[hg,gg]=Em(`CollapsibleRoot`),_g=I({__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=ch(r,`open`,n,{defaultValue:r.defaultOpen,passive:r.open===void 0}),{disabled:a,unmountOnHide:o}=bn(r);return gg({contentId:``,disabled:a,open:i,unmountOnHide:o,onOpenToggle:()=>{a.value||(i.value=!i.value)}}),t({open:i}),Z(),(e,t)=>(B(),H(N(pg),{as:e.as,"as-child":r.asChild,"data-state":N(i)?`open`:`closed`,"data-disabled":N(a)?``:void 0},{default:P(()=>[R(e.$slots,`default`,{open:N(i)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),vg=I({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=hg();i.contentId||=eg(void 0,`reka-collapsible-content`);let a=M(),{forwardRef:o,currentElement:s}=Z(),c=M(0),l=M(0),u=J(()=>i.open.value),d=M(u.value),f=M();F(()=>[u.value,a.value?.present],async()=>{await $n();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=J(()=>d.value&&i.open.value);return Ui(()=>{requestAnimationFrame(()=>{d.value=!1})}),Jm(s,`beforematch`,e=>{requestAnimationFrame(()=>{i.onOpenToggle(),r(`contentFound`)})}),(e,t)=>(B(),H(N(ug),{ref_key:`presentRef`,ref:a,present:e.forceMount||N(i).open.value,"force-mount":!0},{default:P(({present:t})=>[W(N(pg),q(e.$attrs,{id:N(i).contentId,ref:N(o),"as-child":n.asChild,as:e.as,hidden:t?void 0:N(i).unmountOnHide.value?``:`until-found`,"data-state":p.value?void 0:N(i).open.value?`open`:`closed`,"data-disabled":N(i).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${l.value}px`,"--reka-collapsible-content-width":`${c.value}px`}}),{default:P(()=>[!N(i).unmountOnHide.value||t?R(e.$slots,`default`,{key:0}):K(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),yg=I({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;Z();let n=hg();return(e,r)=>(B(),H(N(pg),{type:e.as===`button`?`button`:void 0,as:e.as,"as-child":t.asChild,"aria-controls":N(n).contentId,"aria-expanded":N(n).open.value,"data-state":N(n).open.value?`open`:`closed`,"data-disabled":N(n).disabled?.value?``:void 0,disabled:N(n).disabled?.value,onClick:N(n).onOpenToggle},{default:P(()=>[R(e.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}});function bg({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 xg({type:e,defaultValue:t,modelValue:n}){return e||bg({type:e,defaultValue:t,modelValue:n})}function Sg({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function Cg(e,t){let n=J(()=>xg(e)),r=ch(e,`modelValue`,t,{defaultValue:Sg(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=Sm(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(Am(t,e)){let n=t.findIndex(t=>Sm(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:J(()=>n.value===`single`)}}var[wg,Tg]=Em(`AccordionRoot`),Eg=I({__name:`AccordionRoot`,props:{collapsible:{type:Boolean,required:! Line truncated
- a positive number
- less than the value passed to \`max\` (or ${lS} if no \`max\` prop is set)
- less than the value passed to \`max\` (or ${Wx} if no \`max\` prop is set)
- \`null\` or \`undefined\` if the progress is indeterminate.
Defaulting to \`null\`.`),null)}function mS(e){return fS(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 \`${lS}\`.`),lS)}var hS=I({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:lS},getValueLabel:{type:Function,required:!1,default:(e,t)=>fS(e)?`${Math.round(e/t*lS)}%`: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=ph(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=ph(n,`max`,r,{passive:n.max===void 0});F(()=>i.value,async e=>{let t=pS(e,n.max);t!==e&&(await qn(),i.value=t)},{immediate:!0}),F(()=>n.max,e=>{let t=mS(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=J(()=>Fm(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return dS({modelValue:i,max:a,progressState:o}),(e,t)=>(B(),H(N(vg),{"as-child":e.asChild,as:e.as,"aria-valuemax":N(a),"aria-valuemin":0,"aria-valuenow":fS(N(i))?N(i):void 0,"aria-valuetext":e.getValueText?.(N(i),N(a)),"aria-label":e.getValueLabel(N(i),N(a)),role:`progressbar`,"data-state":o.value,"data-value":N(i)??void 0,"data-max":N(a)},{default:P(()=>[R(e.$slots,`default`,{modelValue:N(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),gS=I({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=uS();return Z(),(e,r)=>(B(),H(N(vg),q(t,{"data-state":N(n).progressState.value,"data-value":N(n).modelValue?.value??void 0,"data-max":N(n).max.value}),{default:P(()=>[R(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),_S=`radio.select`;function vS(e,t,n){Pm(_S,n,{originalEvent:e,value:t})}var yS=I({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=ph(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=vn(n),{forwardRef:o,currentElement:s}=Z(),c=Lh(s),l=Bh(),u=J(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||vS(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(B(),V(z,null,[W(N(vg),q({id:e.id,ref:N(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":N(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":N(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:N(a),required:e.required,name:e.name},{...N(l),...e.$attrs},{onClick:Il(d,[`stop`])}),{default:P(()=>[R(e.$slots,`default`,{checked:N(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),N(c)&&e.name?(B(),H(N(q_),q({key:0,type:`radio`,tabindex:`-1`,value:N(a),checked:!!N(i),name:e.name,disabled:e.disabled,required:e.required},N(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):K(`v-if`,!0)],64))}}),[bS,xS]=Mm(`RadioGroupRoot`),SS=I({__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=ph(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=vn(n),p=Mh(f),m=Lh(a);return xS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(B(),H(N(kb),{"as-child":``,orientation:N(l),dir:N(p),loop:N(c)},{default:P(()=>[W(N(vg),{ref:N(i),role:`radiogroup`,"data-disabled":N(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":N(l),"aria-required":N(d),dir:N(p)},{default:P(()=>[R(e.$slots,`default`,{modelValue:N(o)}),N(m)&&N(u)?(B(),H(N(q_),{key:0,required:N(d),disabled:N(s),value:N(o),name:N(u)},null,8,[`required`,`disabled`,`value`,`name`])):K(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[Jee,Yee]=Mm(`RadioGroupItem`),CS=I({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:nLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:UT(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>UT(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=WT(c),u=e+1<n.length?WT(n[e+1]):null;if(l&&u&&Ete(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=WT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>UT(e)),rows:r.map(e=>e.map(e=>UT(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:UT(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:UT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function WT(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 Ete(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Dte={class:`[overflow-wrap:anywhere]`},Ote={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},kte={class:`font-mono text-[0.85em]`},Ate={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},jte={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},Mte={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},Nte={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},Pte={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Fte={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Ite={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},Lte={key:8,class:`mb-2.5 last:mb-0`},Rte=I({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=J(()=>Tte(t.text));return(e,t)=>(B(),V(`div`,Dte,[(B(!0),V(z,null,L(n.value,(e,t)=>(B(),V(z,{key:t},[e.kind===`pre`?(B(),V(`pre`,Ote,[U(`code`,kte,j(e.code),1)])):e.kind===`table`?(B(),V(`table`,Ate,[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(HT,{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(HT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(B(),V(`blockquote`,jte,[W(HT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(B(),V(`h1`,Mte,[W(HT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(B(),V(`h2`,Nte,[W(HT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(B(),V(`h3`,Pte,[W(HT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(B(),V(`ul`,Fte,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(HT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(B(),V(`ol`,Ite,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(HT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(B(),V(`p`,Lte,[W(HT,{inline:e.inline},null,8,[`inline`])])):K(``,!0)],64))),128))]))}}),zte={class:`truncate`},Bte=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`,zte,j(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),Vte={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},Hte={class:`font-semibold text-foreground`},Ute={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},Wte=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(Bte,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(B(),V(`div`,Vte,[W(N(Kd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),U(`span`,Hte,j(n.value),1),r.value?(B(),V(`code`,Ute,j(r.value),1)):K(``,!0),U(`span`,{class:A(N(Y)(`text-fg-muted`,i.value&&`text-danger`))},j(a.value),3)]))}}),Gte={key:0,class:`mb-2 grid gap-0.5 text-xs`},Kte={key:1,class:`mb-2 flex flex-wrap gap-1.5`},qte={key:3,class:`whitespace-pre-wrap`},GT=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`,Gte,[(B(!0),V(z,null,L(e.tools,(t,n)=>(B(),H(Wte,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):K(``,!0),e.media.length?(B(),V(`div`,Kte,[(B(!0),V(z,null,L(e.media,(e,t)=>(B(),H(_te,{key:t,attachment:e},null,8,[`attachment`]))),128))])):K(``,!0),e.assistant?(B(),H(Rte,{key:2,text:e.text},null,8,[`text`])):(B(),V(`div`,qte,j(e.text),1)),R(t.$slots,`default`)],2)],2))}}),Jte={class:`w-full self-center justify-self-center py-6 text-center`},Yte={class:`grid gap-2`},Xte=[`onCLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>NA?`${n.slice(0,NA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var FA=[`title`],IA=I({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=J(()=>oA(n.event)),a=J(()=>PA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=J(()=>n.event.at?mk(n.event.at):`—`);return(e,t)=>(B(),H(N(AA),{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,FA)]),_:1}),W(N($),null,{default:P(()=>[G(j(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),LA=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function RA(e){return(Number(e?.task_id)||0)>0}function zA(e,t){return t===`tasks`?RA(e):t!==`system`||!RA(e)}function BA(e,t){return e.filter(e=>zA(e,t))}function VA(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function HA(e,t){return`${e}:${t??0}`}function UA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=HA(PA(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 WA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},GA={class:`max-h-[28rem] overflow-y-auto`},KA=[`aria-expanded`,`aria-label`,`onClick`],qA=[`title`],JA=I({__name:`LiveActivityCard`,setup(e){let t=oE(),{activity:n,streamKind:r,streamState:i}=Au(gO()),a=M(`all`),o=J(()=>BA(n.value,a.value)),s=J(()=>VA(o.value.length,a.value)),c=Jt(new Set),l=J(()=>UA(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 PA(e.representative)}function p(e){return e.representative.at?mk(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(B(),H(N(sk),null,{default:P(()=>[W(N(fk),null,{default:P(()=>[W(N(pk),null,{default:P(()=>[...t[1]||=[G(`Live activity`,-1)]]),_:1}),W(N(ck),{class:`flex items-center gap-2`},{default:P(()=>[W(N(EA),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:N(LA)},null,8,[`modelValue`,`options`]),W(N(ik),{variant:N(r)},{default:P(()=>[G(j(N(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),W(N(lk),null,{default:P(()=>[U(`div`,WA,[U(`div`,GA,[W(N(OA),null,{default:P(()=>[W(N(MA),{class:`sticky top-0 z-10 bg-card`},{default:P(()=>[W(N(AA),null,{default:P(()=>[W(N(jA),null,{default:P(()=>[...t[2]||=[G(`Event`,-1)]]),_:1}),W(N(jA),null,{default:P(()=>[...t[3]||=[G(`Task`,-1)]]),_:1}),W(N(jA),null,{default:P(()=>[...t[4]||=[G(`Detail`,-1)]]),_:1}),W(N(jA),null,{default:P(()=>[...t[5]||=[G(`When`,-1)]]),_:1})]),_:1})]),_:1}),W(N(kA),null,{default:P(()=>[o.value.length?K(``,!0):(B(),H(N(AA),{key:0},{default:P(()=>[W(N($),{colspan:`4`},{default:P(()=>[W(N(XO),null,{default:P(()=>[W(N($O),null,{default:P(()=>[W(N(nk),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(IA,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(B(),V(z,{key:1},[W(N(AA),{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(ik),{variant:`idle`},{default:P(()=>[G(`×`+j(e.count),1)]),_:2},1024)],8,KA)]),_: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,qA)]),_: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(IA,{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 hM(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 gM(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 _M(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 vM(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 yM=M([]),bM=M([]),xM=M(!0),SM=M(null),CM=M(null),wM=M(!1),TM=M(null);async function EM(){try{let e=await X.eventTypes();xM.value=e.enabled!==!1,yM.value=e.event_types||[],bM.value=e.proposals||[],SM.value=null}catch(e){SM.value=e.message||String(e)}}function DM(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function OM(e){TM.value=null,CM.value=e}function kM(e){let t=LM.value.find(t=>String(t.id)===e.sample_id);OM({mode:`proposal`,id:null,source:e.source,name:``,rule:DM(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function AM(e=``){OM({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function jM(e){OM({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:DM(e.rule),headersText:``,body:``,exampleHeaders:{}})}function MM(){CM.value=null}async function NM(){let e=CM.value;if(e){wM.value=!0;try{if(e.mode===`edit`&&e.id)await X.eventTypeUpdate(e.id,{name:e.name,rule:vM(e.rule)});else{let t=e.mode===`paste`?mM(e.headersText):e.exampleHeaders;await X.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:vM(e.rule),example:{headers:t,body:e.body}})}CM.value=null,await EM()}catch(e){TM.value=e.message||String(e)}finally{wM.value=!1}}}var PM=M(null);async function FM(){let e=PM.value;if(PM.value=null,e)try{await X.eventTypeDelete(e.id),await EM()}catch(e){SM.value=e.message||String(e)}}var IM=100,LM=M([]),RM=M(!0),zM=M(null),BM=M(!0),VM=M(null);async function HM(){try{let e=await X.captures(IM);RM.value=e.enabled!==!1,LM.value=e.captures||[],zM.value=null}catch(e){zM.value=e.message||String(e)}finally{BM.value=!1}}function UM(e){let t=LM.value.find(t=>t.id===e);return t&&(VM.value=t),!!t}function WM(){LM.value.length&&(VM.value=LM.value[0])}function GM(){_O(`captures`,()=>{HM(),EM()})}var KM={key:0,class:`text-xs text-fg-muted`},qM={key:1,class:`flex flex-col gap-1 text-xs`},JM={key:1},YM={key:2,class:`text-xs text-fg-muted`},XM=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`,KM,`Dispatches unavailable.`)):n.value.length?(B(),V(`ul`,qM,[(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`,JM,j(e.reason||`claimed, no task recorded`),1))],64)),U(`span`,null,j(N(mk)(e.dispatched_at)),1)]))),128))])):t.kind===`tasks`?K(``,!0):(B(),V(`p`,YM,` No dispatches yet. `))}}}),ZM=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 QM(e,t){return t?e.filter(e=>e.event_type_id===t):[]}function $M(e){return(e?.repository??`required`)!==`none`}function eN(e,t){return e.filter(e=>t===`any`||e.type===`any`||e.type===t)}function tN(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 nN={pending_approval:`pending approval`,armed:`armed`,paused:`paused`},rN={pending_approval:`warn`,armed:`ok`,paused:`idle`};function iN(e) Line truncated
`)}};SJ.defaultYaml={explicit:!1,version:`1.2`},SJ.defaultTags={"!!":`tag:yaml.org,2002:`};function CJ(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 wJ(e){let t=new Set;return hJ(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function TJ(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function EJ(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=wJ(e);let a=TJ(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(sJ(t.node)||lJ(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 DJ(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=DJ(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=DJ(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=DJ(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=DJ(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function OJ(e,t,n){if(Array.isArray(e))return e.map((e,t)=>OJ(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!dJ(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 kJ=class{constructor(e){Object.defineProperty(this,nJ,{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(!iJ(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=OJ(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?DJ(i,{"":o},``,o):o}},AJ=class extends kJ{constructor(e){super(Xq),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=[],hJ(e,{Node:(e,t)=>{(rJ(t)||dJ(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||=(OJ(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=jJ(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(CJ(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 jJ(e,t,n){if(rJ(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(lJ(t)){let r=0;for(let i of t.items){let t=jJ(e,i,n);t>r&&(r=t)}return r}if(oJ(t)){let r=jJ(e,t.key,n),i=jJ(e,t.value,n);return Math.max(r,i)}return 1}var MJ=e=>!e||typeof e!=`function`&&typeof e!=`object`,NJ=class extends kJ{constructor(e){super(eJ),this.value=e}toJSON(e,t){return t?.keep?this.value:OJ(this.value,e,t)}toString(){return String(this.value)}};NJ.BLOCK_FOLDED=`BLOCK_FOLDED`,NJ.BLOCK_LITERAL=`BLOCK_LITERAL`,NJ.PLAIN=`PLAIN`,NJ.QUOTE_DOUBLE=`QUOTE_DOUBLE`,NJ.QUOTE_SINGLE=`QUOTE_SINGLE`;var PJ=`tag:yaml.org,2002:`;function FJ(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 IJ(e,t,n){if(iJ(e)&&(e=e.contents),uJ(e))return e;if(oJ(e)){let t=n.schema[Qq].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 AJ(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=PJ+t.slice(2));let l=FJ(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new NJ(e);return c&&(c.node=t),t Line truncated
`)?VJ(n,t):n.includes(`
Defaulting to \`null\`.`),null)}function Yx(e){return qx(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 \`${Wx}\`.`),Wx)}var Xx=I({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:Wx},getValueLabel:{type:Function,required:!1,default:(e,t)=>qx(e)?`${Math.round(e/t*Wx)}%`: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=ch(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=ch(n,`max`,r,{passive:n.max===void 0});F(()=>i.value,async e=>{let t=Jx(e,n.max);t!==e&&(await $n(),i.value=t)},{immediate:!0}),F(()=>n.max,e=>{let t=Yx(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=J(()=>km(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return Kx({modelValue:i,max:a,progressState:o}),(e,t)=>(B(),H(N(pg),{"as-child":e.asChild,as:e.as,"aria-valuemax":N(a),"aria-valuemin":0,"aria-valuenow":qx(N(i))?N(i):void 0,"aria-valuetext":e.getValueText?.(N(i),N(a)),"aria-label":e.getValueLabel(N(i),N(a)),role:`progressbar`,"data-state":o.value,"data-value":N(i)??void 0,"data-max":N(a)},{default:P(()=>[R(e.$slots,`default`,{modelValue:N(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),Zx=I({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=Gx();return Z(),(e,r)=>(B(),H(N(pg),q(t,{"data-state":N(n).progressState.value,"data-value":N(n).modelValue?.value??void 0,"data-max":N(n).max.value}),{default:P(()=>[R(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),Qx=`radio.select`;function $x(e,t,n){Om(Qx,n,{originalEvent:e,value:t})}var eS=I({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=ch(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=bn(n),{forwardRef:o,currentElement:s}=Z(),c=Mh(s),l=Fh(),u=J(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||$x(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(B(),V(z,null,[W(N(pg),q({id:e.id,ref:N(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":N(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":N(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:N(a),required:e.required,name:e.name},{...N(l),...e.$attrs},{onClick:Kl(d,[`stop`])}),{default:P(()=>[R(e.$slots,`default`,{checked:N(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),N(c)&&e.name?(B(),H(N(O_),q({key:0,type:`radio`,tabindex:`-1`,value:N(a),checked:!!N(i),name:e.name,disabled:e.disabled,required:e.required},N(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):K(`v-if`,!0)],64))}}),[tS,nS]=Em(`RadioGroupRoot`),rS=I({__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=ch(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=bn(n),p=Dh(f),m=Mh(a);return nS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(B(),H(N(ub),{"as-child":``,orientation:N(l),dir:N(p),loop:N(c)},{default:P(()=>[W(N(pg),{ref:N(i),role:`radiogroup`,"data-disabled":N(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":N(l),"aria-required":N(d),dir:N(p)},{default:P(()=>[R(e.$slots,`default`,{modelValue:N(o)}),N(m)&&N(u)?(B(),H(N(O_),{key:0,required:N(d),disabled:N(s),value:N(o),name:N(u)},null,8,[`required`,`disabled`,`value`,`name`])):K(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[_te,iS]=Em(`RadioGroupItem`),aS=I({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:YT(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>YT(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=XT(c),u=e+1<n.length?XT(n[e+1]):null;if(l&&u&&Pte(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=XT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>YT(e)),rows:r.map(e=>e.map(e=>YT(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:YT(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:YT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function XT(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 Pte(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Fte={class:`[overflow-wrap:anywhere]`},Ite={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},Lte={class:`font-mono text-[0.85em]`},Rte={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},zte={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},Bte={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},Vte={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},Hte={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Ute={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Wte={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},Gte={key:8,class:`mb-2.5 last:mb-0`},Kte=I({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=J(()=>Nte(t.text));return(e,t)=>(B(),V(`div`,Fte,[(B(!0),V(z,null,L(n.value,(e,t)=>(B(),V(z,{key:t},[e.kind===`pre`?(B(),V(`pre`,Ite,[U(`code`,Lte,j(e.code),1)])):e.kind===`table`?(B(),V(`table`,Rte,[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(JT,{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(JT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(B(),V(`blockquote`,zte,[W(JT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(B(),V(`h1`,Bte,[W(JT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(B(),V(`h2`,Vte,[W(JT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(B(),V(`h3`,Hte,[W(JT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(B(),V(`ul`,Ute,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(JT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(B(),V(`ol`,Wte,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(JT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(B(),V(`p`,Gte,[W(JT,{inline:e.inline},null,8,[`inline`])])):K(``,!0)],64))),128))]))}}),qte={class:`truncate`},Jte=I({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ea(`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(nd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),U(`span`,qte,j(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),Yte={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},Xte={class:`font-semibold text-foreground`},Zte={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},Qte=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(Jte,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(B(),V(`div`,Yte,[W(N(af),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),U(`span`,Xte,j(n.value),1),r.value?(B(),V(`code`,Zte,j(r.value),1)):K(``,!0),U(`span`,{class:A(N(Y)(`text-fg-muted`,i.value&&`text-danger`))},j(a.value),3)]))}}),$te={key:0,class:`mb-2 grid gap-0.5 text-xs`},ene={key:1,class:`mb-2 flex flex-wrap gap-1.5`},tne={key:3,class:`whitespace-pre-wrap`},ZT=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`,$te,[(B(!0),V(z,null,L(e.tools,(t,n)=>(B(),H(Qte,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):K(``,!0),e.media.length?(B(),V(`div`,ene,[(B(!0),V(z,null,L(e.media,(e,t)=>(B(),H(Tte,{key:t,attachment:e},null,8,[`attachment`]))),128))])):K(``,!0),e.assistant?(B(),H(Kte,{key:2,text:e.text},null,8,[`text`])):(B(),V(`div`,tne,j(e.text),1)),R(t.$slots,`default`)],2)],2))}}),nne={class:`text-sm`},rne={class:`font-medium`},ine={key:0,class:`mt-1 text-fg-muted`},ane={key:1,class: Line truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>tj?`${n.slice(0,tj).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var rj=[`title`],ij=I({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=J(()=>OA(n.event)),a=J(()=>nj(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=J(()=>n.event.at?Ik(n.event.at):`—`);return(e,t)=>(B(),H(N(QA),{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:[Jl(Kl(o,[`prevent`]),[`enter`]),Jl(Kl(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,rj)]),_:1}),W(N($),null,{default:P(()=>[G(j(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),aj=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function oj(e){return(Number(e?.task_id)||0)>0}function sj(e,t){return t===`tasks`?oj(e):t!==`system`||!oj(e)}function cj(e,t){return e.filter(e=>sj(e,t))}function lj(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function uj(e,t){return`${e}:${t??0}`}function dj(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=uj(nj(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 fj={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},pj={class:`max-h-[28rem] overflow-y-auto`},mj=[`aria-expanded`,`aria-label`,`onClick`],hj=[`title`],gj=I({__name:`LiveActivityCard`,setup(e){let t=fE(),{activity:n,streamKind:r,streamState:i}=Vu(RO()),a=M(`all`),o=J(()=>cj(n.value,a.value)),s=J(()=>lj(o.value.length,a.value)),c=Xt(new Set),l=J(()=>dj(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 nj(e.representative)}function p(e){return e.representative.at?Ik(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(B(),H(N(kk),null,{default:P(()=>[W(N(Pk),null,{default:P(()=>[W(N(Fk),null,{default:P(()=>[...t[1]||=[G(`Live activity`,-1)]]),_:1}),W(N(Ak),{class:`flex items-center gap-2`},{default:P(()=>[W(N(JA),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:N(aj)},null,8,[`modelValue`,`options`]),W(N(Ek),{variant:N(r)},{default:P(()=>[G(j(N(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),W(N(jk),null,{default:P(()=>[U(`div`,fj,[U(`div`,pj,[W(N(XA),null,{default:P(()=>[W(N(ej),{class:`sticky top-0 z-10 bg-card`},{default:P(()=>[W(N(QA),null,{default:P(()=>[W(N($A),null,{default:P(()=>[...t[2]||=[G(`Event`,-1)]]),_:1}),W(N($A),null,{default:P(()=>[...t[3]||=[G(`Task`,-1)]]),_:1}),W(N($A),null,{default:P(()=>[...t[4]||=[G(`Detail`,-1)]]),_:1}),W(N($A),null,{default:P(()=>[...t[5]||=[G(`When`,-1)]]),_:1})]),_:1})]),_:1}),W(N(ZA),null,{default:P(()=>[o.value.length?K(``,!0):(B(),H(N(QA),{key:0},{default:P(()=>[W(N($),{colspan:`4`},{default:P(()=>[W(N(vk),null,{default:P(()=>[W(N(xk),null,{default:P(()=>[W(N(wk),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(ij,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(B(),V(z,{key:1},[W(N(QA),{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:[Jl(Kl(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),Jl(Kl(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:Kl(t=>u(e.key),[`stop`])},[d(e)?(B(),H(N(ld),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(B(),H(N(ud),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),G(` `+j(e.label)+` `,1),W(N(Ek),{variant:`idle`},{default:P(()=>[G(`×`+j(e.count),1)]),_:2},1024)],8,mj)]),_: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,hj)]),_: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(ij,{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 IM(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 LM(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 RM(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 zM(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 BM=M([]),VM=M([]),HM=M(!0),UM=M(null),WM=M(null),GM=M(!1),KM=M(null);async function qM(){try{let e=await X.eventTypes();HM.value=e.enabled!==!1,BM.value=e.event_types||[],VM.value=e.proposals||[],UM.value=null}catch(e){UM.value=e.message||String(e)}}function JM(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function YM(e){KM.value=null,WM.value=e}function XM(e){let t=iN.value.find(t=>String(t.id)===e.sample_id);YM({mode:`proposal`,id:null,source:e.source,name:``,rule:JM(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function ZM(e=``){YM({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function QM(e){YM({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:JM(e.rule),headersText:``,body:``,exampleHeaders:{}})}function $M(){WM.value=null}async function eN(){let e=WM.value;if(e){GM.value=!0;try{if(e.mode===`edit`&&e.id)await X.eventTypeUpdate(e.id,{name:e.name,rule:zM(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:zM(e.rule),example:{headers:t,body:e.body}})}WM.value=null,await qM()}catch(e){KM.value=e.message||String(e)}finally{GM.value=!1}}}var tN=M(null);async function nN(){let e=tN.value;if(tN.value=null,e)try{await X.eventTypeDelete(e.id),await qM()}catch(e){UM.value=e.message||String(e)}}var rN=100,iN=M([]),aN=M(!0),oN=M(null),sN=M(!0),cN=M(null);async function lN(){try{let e=await X.captures(rN);aN.value=e.enabled!==!1,iN.value=e.captures||[],oN.value=null}catch(e){oN.value=e.message||String(e)}finally{sN.value=!1}}function uN(e){let t=iN.value.find(t=>t.id===e);return t&&(cN.value=t),!!t}function dN(){iN.value.length&&(cN.value=iN.value[0])}function fN(){zO(`captures`,()=>{lN(),qM()})}var pN={key:0,class:`text-xs text-fg-muted`},mN={key:1,class:`flex flex-col gap-1 text-xs`},hN={key:1},gN={key:2,class:`text-xs text-fg-muted`},_N=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=ea(`RouterLink`);return r.value?(B(),V(`p`,pN,`Dispatches unavailable.`)):n.value.length?(B(),V(`ul`,mN,[(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`,hN,j(e.reason||`claimed, no task recorded`),1))],64)),U(`span`,null,j(N(Ik)(e.dispatched_at)),1)]))),128))])):t.kind===`tasks`?K(``,!0):(B(),V(`p`,gN,` No dispatches yet. `))}}}),vN=I({__name:`Spinner`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e;return(e,n)=>(B(),H(N(wd),{role:`status`,"aria-label":`Loading`,class:A(N(Y)(`size-4 animate-spin`,t.class))},null,8,[`class`]))}});function yN(e,t){return t?e.filter(e=>e.event_type_id===t):[]}function bN(e){return(e?.repository??`required`)!==`none`}function xN(e,t){return e.filter(e=>t===`any`||e.type===`any`||e.type===t)}function SN(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 CN={pending_approval:`pending approval`,armed:`armed`,paused:`paused`},wN={pending_approval:`warn`,armed:`ok`,paused:`idle`};function TN(e) Line truncated
`)}};KJ.defaultYaml={explicit:!1,version:`1.2`},KJ.defaultTags={"!!":`tag:yaml.org,2002:`};function qJ(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 JJ(e){let t=new Set;return zJ(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function YJ(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function XJ(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=JJ(e);let a=YJ(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(jJ(t.node)||NJ(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 ZJ(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=ZJ(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=ZJ(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=ZJ(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=ZJ(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function QJ(e,t,n){if(Array.isArray(e))return e.map((e,t)=>QJ(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 $J=class{constructor(e){Object.defineProperty(this,EJ,{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(!OJ(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=QJ(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?ZJ(i,{"":o},``,o):o}},eY=class extends $J{constructor(e){super(bJ),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=[],zJ(e,{Node:(e,t)=>{(DJ(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||=(QJ(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=tY(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(qJ(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 tY(e,t,n){if(DJ(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(NJ(t)){let r=0;for(let i of t.items){let t=tY(e,i,n);t>r&&(r=t)}return r}if(AJ(t)){let r=tY(e,t.key,n),i=tY(e,t.value,n);return Math.max(r,i)}return 1}var nY=e=>!e||typeof e!=`function`&&typeof e!=`object`,rY=class extends $J{constructor(e){super(wJ),this.value=e}toJSON(e,t){return t?.keep?this.value:QJ(this.value,e,t)}toString(){return String(this.value)}};rY.BLOCK_FOLDED=`BLOCK_FOLDED`,rY.BLOCK_LITERAL=`BLOCK_LITERAL`,rY.PLAIN=`PLAIN`,rY.QUOTE_DOUBLE=`QUOTE_DOUBLE`,rY.QUOTE_SINGLE=`QUOTE_SINGLE`;var iY=`tag:yaml.org,2002:`;function aY(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 oY(e,t,n){if(OJ(e)&&(e=e.contents),PJ(e))return e;if(AJ(e)){let t=n.schema[SJ].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 eY(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=iY+t.slice(2));let l=aY(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new rY(e);return c&&(c.node=t),t Line truncated
`)?dY(n,t):n.includes(`
`)?`
`+VJ(n,t):(e.endsWith(` `)?``:` `)+n,UJ=`flow`,WJ=`block`,GJ=`quoted`;function KJ(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=qJ(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
`)n===`block`&&(h=qJ(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
`+dY(n,t):(e.endsWith(` `)?``:` `)+n,pY=`flow`,mY=`block`,hY=`quoted`;function gY(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=_Y(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
`)n===`block`&&(h=_Y(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
`&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function qJ(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
`);r=t,i=t+1,a=e[i]}return r}var JJ=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),YJ=e=>/^(%|---|\.\.\.)/m.test(e);function XJ(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function ZJ(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(YJ(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function _Y(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
`);r=t,i=t+1,a=e[i]}return r}var vY=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),yY=e=>/^(%|---|\.\.\.)/m.test(e);function bY(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function xY(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(yY(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
`;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:KJ(o,a,GJ,JJ(t,!1))}function QJ(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
`)||/[ \t]\n|\n[ \t]/.test(e))return ZJ(e,t);let n=t.indent||(YJ(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:KJ(r,n,UJ,JJ(t,!1))}function $J(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=ZJ;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?QJ:i&&!t?ZJ:n?QJ:ZJ}return r(e,t)}var eY;try{eY=RegExp(`(^|(?<!
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:gY(o,a,hY,vY(t,!1))}function SY(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
`)||/[ \t]\n|\n[ \t]/.test(e))return xY(e,t);let n=t.indent||(yY(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:gY(r,n,pY,vY(t,!1))}function CY(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=xY;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?SY:i&&!t?xY:n?SY:xY}return r(e,t)}var wY;try{wY=RegExp(`(^|(?<!
))
+(?!
|$)`,`g`)}catch{eY=/\n+(?!\n|$)/g}function tY({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return $J(n,r);let l=r.indent||(r.forceBlockIndent||YJ(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===NJ.BLOCK_FOLDED?!1:t===NJ.BLOCK_LITERAL||!XJ(n,c,l.length);if(!n)return u?`|
|$)`,`g`)}catch{wY=/\n+(?!\n|$)/g}function TY({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return CY(n,r);let l=r.indent||(r.forceBlockIndent||yY(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===rY.BLOCK_FOLDED?!1:t===rY.BLOCK_LITERAL||!bY(n,c,l.length);if(!n)return u?`|
`:`>
`;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
`&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
`);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
`&&(p=p.slice(0,-1)),p.replace(eY,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
`&&(p=p.slice(0,-1)),p.replace(wY,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
`)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=JJ(r,!0);o!==`folded`&&t!==NJ.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=KJ(`${v}${e}${p}`,l,WJ,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function nY(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
`)||u&&/[[\]{},]/.test(a))return $J(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
`)?$J(a,t):tY(e,t,n,r);if(!s&&!u&&i!==NJ.PLAIN&&a.includes(`
`))return tY(e,t,n,r);if(YJ(a)){if(c===``)return t.forceBlockIndent=!0,tY(e,t,n,r);if(s&&c===l)return $J(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return $J(a,t)}return s?d:KJ(d,c,UJ,JJ(t,!1))}function rY(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==NJ.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=NJ.QUOTE_DOUBLE);let c=e=>{switch(e){case NJ.BLOCK_FOLDED:case NJ.BLOCK_LITERAL:return i||a?$J(o.value,t):tY(o,t,n,r);case NJ.QUOTE_DOUBLE:return ZJ(o.value,t);case NJ.QUOTE_SINGLE:return QJ(o.value,t);case NJ.PLAIN:return nY(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function iY(e,t){let n=Object.assign({blockQuote:!0,commentString:BJ,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function aY(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(sJ(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function oY(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(sJ(e)||lJ(e))&&e.anchor;a&&CJ(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function sY(e,t,n,r){if(oJ(e))return e.toString(t,n,r);if(rJ(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=uJ(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=aY(t.doc.schema.tags,a);let o=oY(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):sJ(a)?rY(a,t,n,r):a.toString(t,n,r);return o?sJ(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function cY({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=uJ(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(lJ(e)||!uJ(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||lJ(e)||(sJ(e)?e.type===NJ.BLOCK_FOLDED||e.type===NJ.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=sY(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=HJ(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=HJ(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=HJ(g,n.indent,l(f))));let _,v,y;uJ(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&sJ(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&cJ(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=sY(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
`:``,v){let e=l(v);S+=`\n${VJ(e,n.indent)}`}x===``&&!n.inFlow?S===`
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=vY(r,!0);o!==`folded`&&t!==rY.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=gY(`${v}${e}${p}`,l,mY,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function EY(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
`)||u&&/[[\]{},]/.test(a))return CY(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
`)?CY(a,t):TY(e,t,n,r);if(!s&&!u&&i!==rY.PLAIN&&a.includes(`
`))return TY(e,t,n,r);if(yY(a)){if(c===``)return t.forceBlockIndent=!0,TY(e,t,n,r);if(s&&c===l)return CY(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return CY(a,t)}return s?d:gY(d,c,pY,vY(t,!1))}function DY(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==rY.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=rY.QUOTE_DOUBLE);let c=e=>{switch(e){case rY.BLOCK_FOLDED:case rY.BLOCK_LITERAL:return i||a?CY(o.value,t):TY(o,t,n,r);case rY.QUOTE_DOUBLE:return xY(o.value,t);case rY.QUOTE_SINGLE:return SY(o.value,t);case rY.PLAIN:return EY(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function OY(e,t){let n=Object.assign({blockQuote:!0,commentString:uY,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function kY(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(jJ(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function AY(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(jJ(e)||NJ(e))&&e.anchor;a&&qJ(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function jY(e,t,n,r){if(AJ(e))return e.toString(t,n,r);if(DJ(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=PJ(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=kY(t.doc.schema.tags,a);let o=AY(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):jJ(a)?DY(a,t,n,r):a.toString(t,n,r);return o?jJ(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function MY({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=PJ(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(NJ(e)||!PJ(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||NJ(e)||(jJ(e)?e.type===rY.BLOCK_FOLDED||e.type===rY.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=jY(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=fY(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=fY(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=fY(g,n.indent,l(f))));let _,v,y;PJ(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&jJ(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&MJ(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=jY(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
`:``,v){let e=l(v);S+=`\n${dY(e,n.indent)}`}x===``&&!n.inFlow?S===`
`&&y&&(S=`
`):S+=`\n${n.indent}`}else if(!p&&lJ(t)){let e=x[0],r=x.indexOf(`
`):S+=`\n${n.indent}`}else if(!p&&NJ(t)){let e=x[0],r=x.indexOf(`
`),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(S=`\n${n.indent}`)}}else(x===``||x[0]===`
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=HJ(g,n.indent,l(y)):h&&i&&i(),g}function lY(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var uY=`<<`,dY={identify:e=>e===uY||typeof e==`symbol`&&e.description===uY,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new NJ(Symbol(uY)),{addToJSMap:pY}),stringify:()=>uY},fY=(e,t)=>(dY.identify(t)||sJ(t)&&(!t.type||t.type===NJ.PLAIN)&&dY.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===dY.tag&&e.default);function pY(e,t,n){let r=hY(e,n);if(cJ(r))for(let n of r.items)mY(e,t,n);else if(Array.isArray(r))for(let n of r)mY(e,t,n);else mY(e,t,r)}function mY(e,t,n){let r=hY(e,n);if(!aJ(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function hY(e,t){return e&&rJ(t)?t.resolve(e.doc,e):t}function gY(e,t,{key:n,value:r}){if(uJ(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(fY(e,n))pY(e,t,r);else{let i=OJ(n,``,e);if(t instanceof Map)t.set(i,OJ(r,i,e));else if(t instanceof Set)t.add(i);else{let a=_Y(n,i,e),o=OJ(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function _Y(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(uJ(e)&&n?.doc){let t=iY(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),lY(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function vY(e,t,n){return new yY(IJ(e,void 0,n),IJ(t,void 0,n))}var yY=class e{constructor(e,t=null){Object.defineProperty(this,nJ,{value:$q}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return uJ(n)&&(n=n.clone(t)),uJ(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return gY(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?cY(this,e,t,n):JSON.stringify(this)}};function bY(e,t,n){return(t.inFlow??e.flow?SY:xY)(e,t,n)}function xY({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(uJ(i))!d&&i.spaceBefore&&f.push(``),CY(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(oJ(i)){let e=uJ(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),CY(n,f,e.commentBefore,d))}d=!1;let s=sY(i,u,()=>o=null,()=>d=!0);o&&(s+=HJ(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=fY(g,n.indent,l(y)):h&&i&&i(),g}function NY(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var PY=`<<`,FY={identify:e=>e===PY||typeof e==`symbol`&&e.description===PY,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new rY(Symbol(PY)),{addToJSMap:LY}),stringify:()=>PY},IY=(e,t)=>(FY.identify(t)||jJ(t)&&(!t.type||t.type===rY.PLAIN)&&FY.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===FY.tag&&e.default);function LY(e,t,n){let r=zY(e,n);if(MJ(r))for(let n of r.items)RY(e,t,n);else if(Array.isArray(r))for(let n of r)RY(e,t,n);else RY(e,t,r)}function RY(e,t,n){let r=zY(e,n);if(!kJ(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function zY(e,t){return e&&DJ(t)?t.resolve(e.doc,e):t}function BY(e,t,{key:n,value:r}){if(PJ(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(IY(e,n))LY(e,t,r);else{let i=QJ(n,``,e);if(t instanceof Map)t.set(i,QJ(r,i,e));else if(t instanceof Set)t.add(i);else{let a=VY(n,i,e),o=QJ(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function VY(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(PJ(e)&&n?.doc){let t=OY(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),NY(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function HY(e,t,n){return new UY(oY(e,void 0,n),oY(t,void 0,n))}var UY=class e{constructor(e,t=null){Object.defineProperty(this,EJ,{value:CJ}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return PJ(n)&&(n=n.clone(t)),PJ(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return BY(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?MY(this,e,t,n):JSON.stringify(this)}};function WY(e,t,n){return(t.inFlow??e.flow?KY:GY)(e,t,n)}function GY({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(PJ(i))!d&&i.spaceBefore&&f.push(``),qY(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(AJ(i)){let e=PJ(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),qY(n,f,e.commentBefore,d))}d=!1;let s=jY(i,u,()=>o=null,()=>d=!0);o&&(s+=fY(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
`}}return e?(p+=`
`+VJ(l(e),c),s&&s()):d&&o&&o(),p}function SY({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(uJ(i))i.spaceBefore&&d.push(``),CY(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(oJ(i)){let e=uJ(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),CY(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=uJ(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=sY(i,c,()=>a=null);l||=d.length>u||o.includes(`
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=HJ(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function CY({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=VJ(t(r),e);n.push(i.trimStart())}}function wY(e,t){let n=sJ(t)?t.value:t;for(let r of e)if(oJ(r)&&(r.key===t||r.key===n||sJ(r.key)&&r.key.value===n))return r}var TY=class extends zJ{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(Qq,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(vY(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=oJ(e)?e:!e||typeof e!=`object`||!(`key`in e)?new yY(e,e?.value):new yY(e.key,e.value);let r=wY(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);sJ(r.value)&&MJ(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=wY(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=wY(this.items,e)?.value;return(!t&&sJ(n)?n.value:n)??void 0}has(e){return!!wY(this.items,e)}set(e,t){this.add(new yY(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)gY(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!oJ(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),bY(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},EY={collection:`map`,default:!0,nodeClass:TY,tag:`tag:yaml.org,2002:map`,resolve(e,t){return aJ(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>TY.from(e,t,n)},DY=class extends zJ{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(tJ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=OY(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=OY(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&sJ(r)?r.value:r}has(e){let t=OY(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=OY(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];sJ(r)&&MJ(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(OJ(e,String(r++),t));return n}toString(e,t,n){return e?bY(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(IJ(a,void 0,n))}}return i}};function OY(e){let t=sJ(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var kY={collection:`seq`,default:!0,nodeClass:DY,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return cJ(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>DY.from(e,t,n)},AY={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),rY(e,t,n,r)}},jY={identify:e=>e==null,createNode:()=>new NJ(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new NJ(null),stringify:({source:e},t)=>typeof e==`string`&&jY.test.test(e)?e:t.options.nullStr},MY={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new NJ(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&MY.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function NY({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var PY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:NY},FY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),string Line truncated
`:` `)}return rY({comment:e,type:t,value:s},r,i,a)}};function YY(e,t){if(cJ(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!oJ(r)){if(aJ(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new yY(new NJ(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=oJ(r)?r:new yY(r)}}else t(`Expected a sequence for this tag`);return e}function XY(e,t,n){let{replacer:r}=n,i=new DY(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(vY(o,s,n))}return i}var ZY={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:YY,createNode:XY},QY=class e extends DY{constructor(){super(),this.add=TY.prototype.add.bind(this),this.delete=TY.prototype.delete.bind(this),this.get=TY.prototype.get.bind(this),this.has=TY.prototype.has.bind(this),this.set=TY.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(oJ(e)?(r=OJ(e.key,``,t),i=OJ(e.value,r,t)):r=OJ(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=XY(e,t,n),i=new this;return i.items=r.items,i}};QY.tag=`tag:yaml.org,2002:omap`;var $Y={collection:`seq`,identify:e=>e instanceof Map,nodeClass:QY,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=YY(e,t),r=[];for(let{key:e}of n.items)sJ(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new QY,n)},createNode:(e,t,n)=>QY.from(e,t,n)};function eX({value:e,source:t},n){return t&&(e?tX:nX).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var tX={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new NJ(!0),stringify:eX},nX={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new NJ(!1),stringify:eX},rX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:NY},iX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():NY(e)}},aX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new NJ(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:NY},oX=e=>typeof e==`bigint`||Number.isInteger(e);function sX(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function cX(e,t,n){let{value:r}=e;if(oX(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return NY(e)}var lX={identify:oX,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>sX(e,2,2,n),stringify:e=>cX(e,2,`0b`)},uX={identify:oX,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>sX(e,1,8,n),stringify:e=>cX(e,8,`0`)},dX={identify:oX,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>sX(e,0,10,n),stringify:NY},fX={identify:oX,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>sX(e,2,16,n),stringify:e=>cX(e,16,`0x`)},pX=class e extends TY{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=oJ(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new yY(e.key,null):new yY(e,null),wY(this.items,t.key)||this.items.push(t)}get(e,t){let n=wY(this.items,e);return!t&&oJ(n)?sJ(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=wY(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new yY(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return s Line truncated
`)?(n.push(`...`),n.push(VJ(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(VJ(a(t),``)))}return n.join(`
`+dY(l(e),c),s&&s()):d&&o&&o(),p}function KY({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(PJ(i))i.spaceBefore&&d.push(``),qY(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(AJ(i)){let e=PJ(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),qY(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=PJ(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=jY(i,c,()=>a=null);l||=d.length>u||o.includes(`
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=fY(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function qY({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=dY(t(r),e);n.push(i.trimStart())}}function JY(e,t){let n=jJ(t)?t.value:t;for(let r of e)if(AJ(r)&&(r.key===t||r.key===n||jJ(r.key)&&r.key.value===n))return r}var YY=class extends lY{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(SJ,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(HY(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=AJ(e)?e:!e||typeof e!=`object`||!(`key`in e)?new UY(e,e?.value):new UY(e.key,e.value);let r=JY(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);jJ(r.value)&&nY(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=JY(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=JY(this.items,e)?.value;return(!t&&jJ(n)?n.value:n)??void 0}has(e){return!!JY(this.items,e)}set(e,t){this.add(new UY(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)BY(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!AJ(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),WY(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},XY={collection:`map`,default:!0,nodeClass:YY,tag:`tag:yaml.org,2002:map`,resolve(e,t){return kJ(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>YY.from(e,t,n)},ZY=class extends lY{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(TJ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=QY(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=QY(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&jJ(r)?r.value:r}has(e){let t=QY(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=QY(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];jJ(r)&&nY(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(QJ(e,String(r++),t));return n}toString(e,t,n){return e?WY(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(oY(a,void 0,n))}}return i}};function QY(e){let t=jJ(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var $Y={collection:`seq`,default:!0,nodeClass:ZY,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return MJ(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>ZY.from(e,t,n)},eX={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),DY(e,t,n,r)}},tX={identify:e=>e==null,createNode:()=>new rY(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new rY(null),stringify:({source:e},t)=>typeof e==`string`&&tX.test.test(e)?e:t.options.nullStr},nX={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new rY(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&nX.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function rX({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var iX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:rX},aX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),string Line truncated
`:` `)}return DY({comment:e,type:t,value:s},r,i,a)}};function yX(e,t){if(MJ(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!AJ(r)){if(kJ(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new UY(new rY(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=AJ(r)?r:new UY(r)}}else t(`Expected a sequence for this tag`);return e}function bX(e,t,n){let{replacer:r}=n,i=new ZY(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(HY(o,s,n))}return i}var xX={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:yX,createNode:bX},SX=class e extends ZY{constructor(){super(),this.add=YY.prototype.add.bind(this),this.delete=YY.prototype.delete.bind(this),this.get=YY.prototype.get.bind(this),this.has=YY.prototype.has.bind(this),this.set=YY.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(AJ(e)?(r=QJ(e.key,``,t),i=QJ(e.value,r,t)):r=QJ(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=bX(e,t,n),i=new this;return i.items=r.items,i}};SX.tag=`tag:yaml.org,2002:omap`;var CX={collection:`seq`,identify:e=>e instanceof Map,nodeClass:SX,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=yX(e,t),r=[];for(let{key:e}of n.items)jJ(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new SX,n)},createNode:(e,t,n)=>SX.from(e,t,n)};function wX({value:e,source:t},n){return t&&(e?TX:EX).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var TX={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new rY(!0),stringify:wX},EX={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new rY(!1),stringify:wX},DX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:rX},OX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():rX(e)}},kX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new rY(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:rX},AX=e=>typeof e==`bigint`||Number.isInteger(e);function jX(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function MX(e,t,n){let{value:r}=e;if(AX(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return rX(e)}var NX={identify:AX,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>jX(e,2,2,n),stringify:e=>MX(e,2,`0b`)},PX={identify:AX,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>jX(e,1,8,n),stringify:e=>MX(e,8,`0`)},FX={identify:AX,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>jX(e,0,10,n),stringify:rX},IX={identify:AX,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>jX(e,2,16,n),stringify:e=>MX(e,16,`0x`)},LX=class e extends YY{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=AJ(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new UY(e.key,null):new UY(e,null),JY(this.items,t.key)||this.items.push(t)}get(e,t){let n=JY(this.items,e);return!t&&AJ(n)?jJ(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=JY(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new UY(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return s Line truncated
`)?(n.push(`...`),n.push(dY(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(dY(a(t),``)))}return n.join(`
`)+`
`}var OX=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,nJ,{value:Zq});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new SJ({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[nJ]:{value:Zq}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=uJ(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){kX(this.contents)&&this.contents.add(e)}addIn(e,t){kX(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=wJ(this);e.anchor=!t||n.has(t)?TJ(t||`a`,n):t}return new AJ(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=EJ(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=IJ(e,l,p);return o&&lJ(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new yY(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return kX(this.contents)?this.contents.delete(e):!1}deleteIn(e){return RJ(e)?this.contents!=null&&(this.contents=null,!0):kX(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return lJ(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return RJ(e)?!t&&sJ(this.contents)?this.contents.value:this.contents:lJ(this.contents)?this.contents.getIn(e,t):void 0}has(e){return lJ(this.contents)?this.contents.has(e):!1}hasIn(e){return RJ(e)?this.contents!==void 0:lJ(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=LJ(this.schema,[e],t):kX(this.contents)&&this.contents.set(e,t)}setIn(e,t){RJ(e)?this.contents=t:this.contents==null?this.contents=LJ(this.schema,Array.from(e),t):kX(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new SJ({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new SJ({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new EX(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=OJ(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?DJ(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return DX(this,e)}};function kX(e){if(lJ(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var AX=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},jX=class extends AX{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},MX=class extends AX{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},NX=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function PX(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function FX(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(FX(t.key)||FX(t.value))return!0}return!1;default:return!0}}function IX(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&FX(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function LX(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||sJ(e)&&sJ(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var RX=`All mapping items must start at the same column`;function zX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??TY)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=PX(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,RX)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||FX(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,RX);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&IX(r.indent,u,i),n.atKey=!1,LX(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=PX(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&IX(r.indent,f,i),s=c.range[2];let l=new yY(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let e=new yY(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function BX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??DY)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=PX(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l?.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&IX(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function VX(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var HX=`Block collections are not allowed within flow collections`,UX=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function WX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?TY:DY))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=PX(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&FX(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];oJ(t)&&(t=t.value??t.key),t.comment?t.comment+=`
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],UX(m)&&i(r.range,`BLOCK_IN_FLOW`,HX)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);UX(f)&&i(g.range,`BLOCK_IN_FLOW`,HX),n.atKey=!1;let _=PX(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source?.[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?UX(m)&&i(v.range,`BLOCK_IN_FLOW`,HX):_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let y=new yY(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;LX(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new TY(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f?.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=VX(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function GX(e,t,n,r,i,a){let o=n.type===`block-map`?zX(e,t,n,r,a):n.type===`block-seq`?BX(e,t,n,r,a):WX(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function KX(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===TY.tagName&&s===`map`||o===DY.tagName&&s===`seq`)return GX(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r?.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),GX(e,t,n,i,o)}let l=GX(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=uJ(u)?u:new NJ(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function qX(e,t,n){let r=t.offset,i=JX(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?NJ.BLOCK_FOLDED:NJ.BLOCK_LITERAL,o=t.source?YX(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
`}var ZX=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,EJ,{value:xJ});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new KJ({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[EJ]:{value:xJ}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=PJ(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){QX(this.contents)&&this.contents.add(e)}addIn(e,t){QX(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=JJ(this);e.anchor=!t||n.has(t)?YJ(t||`a`,n):t}return new eY(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=XJ(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=oY(e,l,p);return o&&NJ(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new UY(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return QX(this.contents)?this.contents.delete(e):!1}deleteIn(e){return cY(e)?this.contents!=null&&(this.contents=null,!0):QX(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return NJ(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return cY(e)?!t&&jJ(this.contents)?this.contents.value:this.contents:NJ(this.contents)?this.contents.getIn(e,t):void 0}has(e){return NJ(this.contents)?this.contents.has(e):!1}hasIn(e){return cY(e)?this.contents!==void 0:NJ(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=sY(this.schema,[e],t):QX(this.contents)&&this.contents.set(e,t)}setIn(e,t){cY(e)?this.contents=t:this.contents==null?this.contents=sY(this.schema,Array.from(e),t):QX(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new KJ({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new KJ({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new YX(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=QJ(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?ZJ(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return XX(this,e)}};function QX(e){if(NJ(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var $X=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},eZ=class extends $X{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},tZ=class extends $X{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},nZ=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function rZ(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function iZ(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(iZ(t.key)||iZ(t.value))return!0}return!1;default:return!0}}function aZ(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&iZ(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function oZ(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||jJ(e)&&jJ(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var sZ=`All mapping items must start at the same column`;function cZ({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??YY)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=rZ(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,sZ)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||iZ(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,sZ);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&aZ(r.indent,u,i),n.atKey=!1,oZ(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=rZ(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&aZ(r.indent,f,i),s=c.range[2];let l=new UY(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let e=new UY(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function lZ({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??ZY)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=rZ(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l?.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&aZ(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function uZ(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var dZ=`Block collections are not allowed within flow collections`,fZ=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function pZ({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?YY:ZY))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=rZ(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&iZ(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];AJ(t)&&(t=t.value??t.key),t.comment?t.comment+=`
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],fZ(m)&&i(r.range,`BLOCK_IN_FLOW`,dZ)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);fZ(f)&&i(g.range,`BLOCK_IN_FLOW`,dZ),n.atKey=!1;let _=rZ(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source?.[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?fZ(m)&&i(v.range,`BLOCK_IN_FLOW`,dZ):_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let y=new UY(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;oZ(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new YY(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f?.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=uZ(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function mZ(e,t,n,r,i,a){let o=n.type===`block-map`?cZ(e,t,n,r,a):n.type===`block-seq`?lZ(e,t,n,r,a):pZ(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function hZ(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===YY.tagName&&s===`map`||o===ZY.tagName&&s===`seq`)return mZ(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r?.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),mZ(e,t,n,i,o)}let l=mZ(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=PJ(u)?u:new rY(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function gZ(e,t,n){let r=t.offset,i=_Z(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?rY.BLOCK_FOLDED:rY.BLOCK_LITERAL,o=t.source?vZ(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
`.repeat(Math.max(1,o.length-1)):``,n=r+i.length;return t.source&&(n+=t.source.length),{value:e,type:a,comment:i.comment,range:[r,n,n]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let t=0;t<s;++t){let[r,a]=o[t];if(a===``||a===`\r`)i.indent===0&&r.length>c&&(c=r.length);else{r.length<c&&n(l+r.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),i.indent===0&&(c=r.length),u=t,c===0&&!e.atRoot&&n(l,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}l+=r.length+a.length+1}for(let e=o.length-1;e>=s;--e)o[e][0].length>c&&(s=e+1);let d=``,f=``,p=!1;for(let e=0;e<u;++e)d+=o[e][0].slice(c)+`
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===NJ.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===rY.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
`):t.length>c||r[0]===` `?(f===` `?f=`
`:!p&&f===`
`&&(f=`
@@ -81,59 +81,59 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
`+o[e][0].slice(c);d[d.length-1]!==`
`&&(d+=`
`);break;default:d+=`
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function JX({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function YX(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function XX(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=NJ.PLAIN,c=ZX(a,l);break;case`single-quoted-scalar`:s=NJ.QUOTE_SINGLE,c=QX(a,l);break;case`double-quoted-scalar`:s=NJ.QUOTE_DOUBLE,c=eZ(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=VX(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function ZX(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),$X(e)}function QX(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),$X(e.slice(1,-1)).replace(/''/g,`'`)}function $X(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function _Z({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function vZ(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function yZ(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=rY.PLAIN,c=bZ(a,l);break;case`single-quoted-scalar`:s=rY.QUOTE_SINGLE,c=xZ(a,l);break;case`double-quoted-scalar`:s=rY.QUOTE_DOUBLE,c=CZ(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=uZ(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function bZ(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),SZ(e)}function xZ(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),SZ(e.slice(1,-1)).replace(/''/g,`'`)}function SZ(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
`?a+=o:o=`
`:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function eZ(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
`:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function CZ(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
`){if(i===`
`){let{fold:t,offset:i}=tZ(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=nZ[i];if(a)n+=a;else if(i===`
`){let{fold:t,offset:i}=wZ(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=TZ[i];if(a)n+=a;else if(i===`
`)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=rZ(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=EZ(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
`&&(a!==`\r`||e[r+2]!==`
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function tZ(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function wZ(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
`||r===`\r`)&&(r!==`\r`||e[t+2]===`
`);)r===`
`&&(n+=`
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var nZ={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
`,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function rZ(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}function iZ(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?qX(e,t,r):XX(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[eJ]:c?aZ(e.schema,i,c,n,r):t.type===`scalar`?oZ(e,i,t,r):e.schema[eJ];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=sJ(a)?a:new NJ(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new NJ(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function aZ(e,t,n,r,i){if(n===`!`)return e[eJ];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[eJ])}function oZ({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[eJ];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[eJ];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function sZ(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var cZ={composeNode:lZ,composeEmptyNode:uZ};function lZ(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=dZ(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=iZ(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=KX(cZ,e,t,n,r),s&&(l.anchor=s.source.substring(1))}catch(e){r(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),u=!1}return l??=uZ(e,t.offset,void 0,null,n,r),s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!sJ(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function uZ(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=iZ(e,{type:`scalar`,offset:sZ(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function dZ({options:e},{offset:t,source:n,end:r},i){let a=new AJ(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=VX(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function fZ(e,t,{offset:n,start:r,value:i,end:a},o){let s=new OX(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=PX(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?lZ(c,i,l,o):uZ(c,l.end,r,null,l,o);let u=s.contents.range[2],d=VX(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function pZ(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function mZ(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var TZ={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
`,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function EZ(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}function DZ(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?gZ(e,t,r):yZ(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[wJ]:c?OZ(e.schema,i,c,n,r):t.type===`scalar`?kZ(e,i,t,r):e.schema[wJ];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=jJ(a)?a:new rY(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new rY(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function OZ(e,t,n,r,i){if(n===`!`)return e[wJ];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[wJ])}function kZ({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[wJ];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[wJ];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function AZ(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var jZ={composeNode:MZ,composeEmptyNode:NZ};function MZ(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=PZ(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=DZ(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=hZ(jZ,e,t,n,r),s&&(l.anchor=s.source.substring(1))}catch(e){r(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),u=!1}return l??=NZ(e,t.offset,void 0,null,n,r),s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!jJ(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function NZ(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=DZ(e,{type:`scalar`,offset:AZ(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function PZ({options:e},{offset:t,source:n,end:r},i){let a=new eY(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=uZ(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function FZ(e,t,{offset:n,start:r,value:i,end:a},o){let s=new ZX(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=rZ(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?MZ(c,i,l,o):NZ(c,l.end,r,null,l,o);let u=s.contents.range[2],d=uZ(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function IZ(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function LZ(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
`:`
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var hZ=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=pZ(e);r?this.warnings.push(new MX(i,t,n)):this.errors.push(new jX(i,t,n))},this.directives=new SJ({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=mZ(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(lJ(i)&&!i.flow&&i.items.length>0){let e=i.items[0];oJ(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:mZ(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=pZ(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=fZ(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new jX(pZ(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new jX(pZ(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=VX(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new jX(pZ(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new OX(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},gZ=Symbol(`break visit`),_Z=Symbol(`skip children`),vZ=Symbol(`remove item`);function yZ(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),bZ(Object.freeze([]),e,t)}yZ.BREAK=gZ,yZ.SKIP=_Z,yZ.REMOVE=vZ,yZ.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},yZ.parentCollection=(e,t)=>{let n=yZ.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function bZ(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=bZ(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===gZ)return gZ;else r===vZ&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function xZ(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var RZ=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=IZ(e);r?this.warnings.push(new tZ(i,t,n)):this.errors.push(new eZ(i,t,n))},this.directives=new KJ({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=LZ(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(NJ(i)&&!i.flow&&i.items.length>0){let e=i.items[0];AJ(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:LZ(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=IZ(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=FZ(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new eZ(IZ(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new eZ(IZ(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=uZ(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new eZ(IZ(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new ZX(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},zZ=Symbol(`break visit`),BZ=Symbol(`skip children`),VZ=Symbol(`remove item`);function HZ(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),UZ(Object.freeze([]),e,t)}HZ.BREAK=zZ,HZ.SKIP=BZ,HZ.REMOVE=VZ,HZ.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},HZ.parentCollection=(e,t)=>{let n=HZ.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function UZ(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=UZ(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===zZ)return zZ;else r===VZ&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function WZ(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
`:case`\r
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function SZ(e){switch(e){case void 0:case` `:case`
`:case`\r`:case` `:return!0;default:return!1}}var CZ=new Set(`0123456789ABCDEFabcdef`),wZ=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),TZ=new Set(`,[]{}`),EZ=new Set(` ,[]{}
\r `),DZ=e=>!e||EZ.has(e),OZ=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function GZ(e){switch(e){case void 0:case` `:case`
`:case`\r`:case` `:return!0;default:return!1}}var KZ=new Set(`0123456789ABCDEFabcdef`),qZ=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),JZ=new Set(`,[]{}`),YZ=new Set(` ,[]{}
\r `),XZ=e=>!e||YZ.has(e),ZZ=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
`||t===`\r`&&this.buffer[e+1]===`
`}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
`||!t&&!this.atEnd)return e+n+1}return t===`
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&SZ(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&SZ(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!SZ(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&SZ(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(DZ),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&SZ(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(DZ),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||SZ(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&GZ(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&GZ(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!GZ(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&GZ(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(XZ),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&GZ(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(XZ),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||GZ(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
`,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>SZ(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>GZ(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
`:e=r,t=0;break;case`\r`:{let e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
`)break}default:break loop}if(!n&&!this.atEnd)return this.setNext(`block-scalar`);if(t>=this.indentNext){this.indentNext=this.blockScalarIndent===-1?t:this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
`,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===` `;)n=this.buffer[++r];if(n===` `){for(;n===` `||n===` `||n===`\r`||n===`
`;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let n=e-1,r=this.buffer[n];r===`\r`&&(r=this.buffer[--n]);let i=n;for(;r===` `;)r=this.buffer[--n];if(r===`
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(1);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(SZ(r)||e&&TZ.has(r))break;t=n}else if(SZ(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(1);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(GZ(r)||e&&JZ.has(r))break;t=n}else if(GZ(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
`?(n+=1,r=`
`,i=this.buffer[n+1]):t=n),i===`#`||e&&TZ.has(i))break;if(r===`
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&TZ.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(DZ),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(SZ(n)||t&&TZ.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!SZ(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(wZ.has(t))t=this.buffer[++e];else if(t===`%`&&CZ.has(this.buffer[e+1])&&CZ.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
`,i=this.buffer[n+1]):t=n),i===`#`||e&&JZ.has(i))break;if(r===`
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&JZ.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(XZ),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(GZ(n)||t&&JZ.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!GZ(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(qZ.has(t))t=this.buffer[++e];else if(t===`%`&&KZ.has(this.buffer[e+1])&&KZ.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},kZ=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function AZ(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function jZ(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function MZ(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function NZ(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function PZ(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function FZ(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function IZ(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!AZ(t.start,`explicit-key-ind`)&&!AZ(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,MZ(t.value)?t.value.end?FZ(t.value.end,t.sep):t.value.end=t.sep:FZ(t.start,t.sep),delete t.sep)}var LZ=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new OZ,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=xZ(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&IZ(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&jZ(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.i Line truncated
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},QZ=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function $Z(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function eQ(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function tQ(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function nQ(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function rQ(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function iQ(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function aQ(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!$Z(t.start,`explicit-key-ind`)&&!$Z(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,tQ(t.value)?t.value.end?iQ(t.value.end,t.sep):t.value.end=t.sep:iQ(t.start,t.sep),delete t.sep)}var oQ=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new ZZ,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=WZ(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&aQ(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&eQ(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.i Line truncated
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){FZ(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(AZ(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=PZ(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(AZ(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(MZ(t.key)&&!AZ(t.sep,`newline`)){let e=PZ(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]}):AZ(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&&!AZ(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)){FZ(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||AZ(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.ite Line truncated
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){iQ(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($Z(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=rQ(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($Z(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(tQ(t.key)&&!$Z(t.sep,`newline`)){let e=rQ(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]}):$Z(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&&!$Z(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)){iQ(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||$Z(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=PZ(NZ(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=PZ(NZ(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 RZ(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new kZ||null,prettyErrors:t}}function zZ(e,t={}){let{lineCounter:n,prettyErrors:r}=RZ(t),i=new LZ(n?.addNewLine),a=new hZ(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 jX(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(NX(e,n)),o.warnings.forEach(NX(e,n))),o}function BZ(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=zZ(e,n);if(!i)return null;if(i.warnings.forEach(e=>lY(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function VZ(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return iJ(e)&&!r?e.toString(n):new OX(e,r,n).toString(n)}function HZ(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})}}function UZ(e,t){let n=e=>e.path&&e.path.length>=2?Number(e.path[1]):-1,r=e.nodes.find(e=>JSON.stringify(e.data.path)===JSON.stringify(t))?.data,i=r?.resume??r?.stage;if(!r||!i)return null;let a=Math.max(-1,...e.nodes.filter(e=>e.data.run).map(e=>n(e.data))),o=n(r);if(o<0||o>a)return null;let s=e.nodes.filter(e=>e.data.path?.length===2).sort((e,t)=>n(e.data)-n(t.data)).map(e=>e.data.resume??e.data.stage??``),c=e=>!!e&&s.filter(t=>t===e).length>1;return c(i)||o>0&&c(s[o-1])?{label:`Add an id to resume here`,from:i,blocked:!0}:{label:o===a?`Resume from here`:`Re-run from here`,from:i}}var WZ=140,GZ=280,KZ={"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 qZ(e){return KZ[e]??e}var JZ=/\{\{\s*steps\.([A-Za-z0-9_-]+)\.[^}]*\}\}/g;function YZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function XZ(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 ZZ(e){for(let t of[`mission`,`message`,`body`,`plan`,`detail`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.replace(/\{\{\s*([^}]+?)\s*\}\}/g,`‹$1›`).split(`
`).find(e=>e.trim())?.trim()}}function QZ(e,t){let n=JSON.stringify(e??{})+` `+(typeof t==`string`?`{{ ${t.replace(/^!/,``)} }}`:``);return[...new Set([...n.matchAll(JZ)].map(e=>e[1]))]}function $Z(e){let t=zZ(e).toJS(),n=YZ(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:`Starts when`,type:``,detail:``}});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,l)=>{let u=YZ(e)?e:{},f=typeof u.type==`string`?u.type:``,p=YZ(u.settings)?u.settings:{},m=typeof u.id==`string`?u.id:``,h=`step-${t}`,g=s?`${s}/${m||f}`:m||f;r.push({id:h,type:`step`,position:{x:n,y:i},data:{kind:`step`,key:m||t,title:m||qZ(f),type:f,detail:XZ(f,p),summary:ZZ(p),when:typeof u.when==`string`?u.when:void 0,retry:YZ(u.retry)&&typeof u.retry.attempts==`number`?u.retry.attempts:void 0,continues:u.on_failure===`continue`,branch:s,path:l,stage:g,occurrence:d(g),...c?{resume:c}:{}}}),m&&a.set(m,h);for(let e of QZ(u.settings,u.when))o.push({from:e,to:h});return h},p=(e,t,n)=>{e.forEach((r,a)=>i.push({id:`flow-${r}-${t}`,source:r,target:t,kind:`flow`,insertAfter:a===e.length-1?n:void 0}))};for(let[e,t]of n.entries()){if(YZ(t)&&YZ(t.parallel)){let n=Object.entries(t.parallel),r=typeof t.id==`string`?t.id:`parallel`,i=[],a=0;n.forEach(([t,o],s)=>{let u=(s-(n.length-1)/2)*GZ,d=c,m=c;(Array.isArray(o)?o:[]).forEach((i,o)=>{let c=f(i,`${e+1}-${t}-${o+1}`,u,(l+o)*WZ,t,r,[`steps`,e,`parallel`,t,o]);p(d,c,d===m&&s===n.length-1?e-1:void 0),d=[c],a=Math.max(a,o+1)}),i.push(...d)}),c=i,l+=Math.max(a,1);continue}let n=f(t,String(e+1),0,l*WZ,void 0,void 0,[`steps`,e]);p(c,n,e-1),c=[n],l++}r.push({id:`add-end`,type:`add`,position:{x:104,y:l*WZ-24},data:{kind:`step`,key:`add`,title:``,type:``,detail:``}}),p(c,`add-end`);for(let{from:e,to:t}of o){let n=a.get(e);n&&(i.some(e=>e.kind===`flow`&&e.source===n&&e.target===t)||i.push({id:`data-${n}-${t}`,source:n,target:t,kind:`data`,label:e,offset:24+14*i.filter(e=>e.kind===`data`).length,sourceHandle:`data-out`,targetHandle:`data-in`}))}return{nodes:r,edges:i}}var eQ={agent:Ju,command:Fd,repo:ud,gate:Md,forge:vd,human:Hd,review:cd,workflow:Gd},tQ={agent:`Agents`,command:`Commands`,repo:`Repository`,gate:`Checks`,forge:`Issues and PRs`,human:`People`,review:`Review`,workflow:`Flow`};function nQ(e){return eQ[e.split(`.`)[0]]??Gd}function rQ(e){return Object.keys(tQ).map(t=>({title:tQ[t],icon:eQ[t],types:e.filter(e=>e.split(`.`)[0]===t)})).filter(e=>e.types.length)}function iQ(e,t){let n=zZ(e).getIn(t,!0);if(aJ(n))return n.toJSON()}function aQ(e,t,n){let r=zZ(e);return r.setIn(t,r.createNode(dQ(n))),r.toString()}function oQ(e,t,n){let r=zZ(e),i=r.get(`steps`,!0);if(cJ(i)||(r.set(`steps`,r.createNode([])),i=r.get(`steps`,!0)),!cJ(i))return{source:e,path:[]};let a=Math.min(Math.max(t+1,0),i.items.length);return i.items.splice(a,0,r.createNode({type:n})),{source:r.toString(),path:[`steps`,a]}}function sQ(e,t){let n=zZ(e),r=n.getIn(t.slice(0,-1),!0),i=t.at(-1);if(!cJ(r)||typeof i!=`number`)return{source:e,path:t};let a=n.createNode(n.getIn(t));return aJ(a)&&a.delete(`id`),r.items.splice(i+1,0,a),{source:n.toString(),path:[...t.slice(0,-1),i+1]}}function cQ(e,t){let n=zZ(e);n.deleteIn(t);let r=t.slice(0,-1);if(r.length>2){let e=n.getIn(r,!0);cJ(e)&&e.items.length===0&&n.deleteIn(r)}return n.toString()}function lQ(e,t,n){let r=zZ(e),i=r.getIn(t.slice(0,-1),!0),a=t.at(-1);if(!cJ(i)||typeof a!=`number`)return{source:e,path:t};let o=a+n;if(o<0||o>=i.items.length)return{source:e,path:t};let[s]=i.items.splice(a,1);return i.items.splice(o,0,s),{source:r.toString(),path:[...t.slice(0,-1),o]}}function uQ(e,t){let n=zZ(e).toJS(),r=Array.isArray(n?.steps)?n.steps:[],i=typeof t[1]==`number`?t[1]:r.length,a=[],o=e=>{if(typeof e!=`object`||!e)return;let t=e;if(typeof t.id==`string`&&a.push(t.id),typeof t.parallel==`object`&&t.parallel!==null)for(let e of Object.values(t.parallel))Array.isArray(e)&&e.forEach(o)};if(r.slice(0,i).forEach(o),t.length===5){let e=r[i]?.parallel?.[t[3]];Array.isArray(e)&&e.slice(0,t[4]).forEach(o)}return a}function dQ(e){if(Array.isArray(e))return e.map(dQ);if(typeof e!=`object`||!e)return e;let t={};for(let[n,r]of Object.entries(e)){if(r===void 0||r===``||r===null)continue;let e=dQ(r);(typeof e!=`object`||!e||Array.isArray(e)||Object.keys(e).length!==0)&&(t[n]=e)}return t}function fQ(e,t){let n=zZ(e).get(t,!0);return n&&typeof n==`object`&&`toJSON`in n?n.toJSON():zZ(e).get(t)}function pQ(e,t,n){let r=zZ(e),i=dQ({[t]:n})[t];return i===void 0?r.delete(t):r.set(t,r.createNode(i)),r.toString()}function mQ(e){return e.ok?`Valid`:e.line?`Line ${e.line}: ${e.message}`:e.message}function hQ(e,t=[]){let n=zZ(e),r=n.errors[0];if(r)return{ok:!1,message:kQ(r.message),line:r.linePos?.[0]?.line};let i=n.toJS();if(!AQ(i))return{ok:!1,message:`A workflow is a mapping with an id and steps.`};let a=typeof i.id==`string`?i.id.trim():``;if(!a)return{ok:!1,message:`workflow id is required`};le Line truncated
`).map((e,t)=>({number:t+1,text:e,tokens:TQ(e)}))}var CQ=/^(\s*)(-\s+)?/,wQ=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function TQ(e){let{code:t,comment:n}=EQ(e),r=DQ(t);return n&&r.push({text:n,kind:`comment`}),r}function EQ(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 DQ(e){if(!e)return[];let t=[],n=CQ.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=wQ.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,...OQ(i[4]??``)]):[...t,...OQ(r)]}function OQ(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 kQ(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function AQ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function jQ(e){return typeof e==`string`&&e.trim()!==``}var MQ={class:`flex h-full w-[24rem] flex-col border-l border-border bg-card shadow-xl`},NQ={class:`flex items-center gap-2.5 border-b border-border px-4 py-3`},PQ={class:`flex size-8 shrink-0 items-center justify-center rounded-md bg-secondary text-primary`},FQ={class:`min-w-0 flex-1`},IQ=[`value`,`placeholder`],LQ={class:`truncate font-mono text-[11px] text-fg-subtle`},RQ={class:`flex-1 space-y-5 overflow-y-auto px-4 py-4`},zQ={key:0,class:`rounded-md bg-danger/10 px-2.5 py-1.5 text-xs text-danger`,role:`alert`},BQ={key:1,class:`space-y-1.5`},VQ=[`title`],HQ=[`value`],UQ=[`value`],WQ={key:3,class:`flex flex-wrap items-center gap-1 pt-0.5`},GQ=[`onClick`],KQ=[`onClick`],qQ={key:2,class:`divide-y divide-border rounded-md border border-border`},JQ=[`title`],YQ=[`value`,`onChange`],XQ=[`value`],ZQ=[`value`,`onInput`],QQ=[`value`,`onFocus`,`onInput`],$Q=[`title`],e$={key:0,class:`text-xs text-danger`},t$={class:`space-y-2`},n$={class:`divide-y divide-border rounded-md border border-border`},r$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},i$=[`value`],a$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},o$=[`value`],s$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},c$=[`value`],l$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},u$={class:`flex items-center border-t border-border px-4 py-2.5`},d$=I({__name:`StepEditor`,props:{yaml:{},path:{},vocabulary:{}},emits:[`update:yaml`,`close`,`remove`],setup(e,{emit:t}){let n=e,r=t,i=J(()=>iQ(n.yaml,n.path)??{}),a=J(()=>typeof i.value.type==`string`?i.value.type:``),o=J(()=>n.vocabulary.find(e=>e.name===a.value)),s=J(()=>typeof i.value.settings==`object`&&i.value.settings!==null?i.value.settings:{}),c=J(()=>uQ(n.yaml,n.path)),l=J(()=>o.value?.settings&&i.value.settings?bQ(i.value.settings,o.value.settings,`settings`):``),u=[`mission`,`workflow`,`message`,`body`,`plan`,`then`,`status`,`detail`,`run`,`rules`],d=/mission|body|detail|plan|rules/;function f(e,t){return t.type===`string`?t.enum?`select`:d.test(e)?`text`:`line`:t.type===`boolean`?`boolean`:t.type===`integer`||t.type===`number`?`number`:t.type===`array`&&t.items?.type===`string`?`lines`:`yaml`}let p=J(()=>{let e=Object.entries(o.value?.settings?.properties??{}).map(([e,t])=>({key:e,schema:t,kind:f(e,t)})),t=e.filter(e=>u.includes(e.key)&&e.kind!==`boolean`).sort((e,t)=>u.indexOf(e.key)-u.indexOf(t.key))[0],n=e.filter(e=>e!==t);return{lead:t,compact:n.filter(e=>[`select`,`line`,`number`,`boolean`].includes(e.kind)),long:n.filter(e=>[`text`,`lines`,`yaml`].includes(e.kind))}});function m(e){let{id:t,type:i,...a}=e;r(`update:yaml`,aQ(n.yaml,n.path,{id:t,type:i,...a}))}function h(e,t){m({...i.value,[e]:t})}function g(e){h(`retry`,{...i.value.retry,...e})}function _(e,t){m({...i.value,settings:{...s.value,[e]:t}})}let v=M(null);function y(e,t){let n=v.value??p.value.lead?.key;if(!n)return;let r=typeof s.value[n]==`string`?s.value[n]:``,i=`{{ steps.${e}.${t} }}`;_(n,r?`${r.trimEnd()} ${i}`:i)}let b=M({});function x(e,t){try{_(e,t.trim()?BZ(t):void 0),b.value={...b.value,[e]:``}}catch(t){b.value={...b.value,[e]:String(t.message).split(`
`)[0]}}}let S=e=>e===void 0?``:VZ(e).trimEnd(),C=(e,t)=>t.title??e.replaceAll(`_`,` `).replace(/^./,e=>e.toUpperCase()),w=e=>typeof s.value[e]==`string`?s.value[e]:``;return(e,t)=>(B(),V(`aside`,MQ,[U(`header`,NQ,[U(`span`,PQ,[(B(),H(ea(N(nQ)(a.value)),{class:`size-4`}))]),U(`div`,FQ,[U(`input`,{value:i.value.id??``,class:`w-full truncate bg-transparent text-sm font-medium outline-none placeholder:text-fg-subtle focus:underline`,placeholder:N(qZ)(a.value),"aria-label":`Step id`,onInput:t[0]||=e=>h(`id`,e.target.value)},null,40,IQ),U(`div`,LQ,j(a.value),1)]),W(N(Q),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,onClick:t[1]||=e=>r(`close`)},{default:P(()=>[W(N(qd))]),_:1})]),U(`div`,RQ,[l.value?(B(),V(`p`,zQ,j(l.value),1)):K(``,!0),p.value.lead?(B(),V(`section`,BQ,[U(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:p.value.lead.schema.description},[G(j(C(p.value.lead.key,p.value.lead.schema))+` `,1),p.value.lead.schema.description?(B(),H(N(id),{key:0,class:`size-3 text-fg-subtle`})):K(``,!0)],8,VQ),p.value.lead.kind===`select`?(B(),V(`select`,{key:0,class:`h-9 w-full rounded-md border border-input bg-background px-2`,value:w(p.value.lead.key),onChange:t[2]||=e=>_(p.value.lead.key,e.target.value||void 0)},[t[13]||=U(`option`,{value:``},`Default`,-1),(B(!0),V(z,null,L(p.value.lead.schema.enum,e=>(B(),V(`option`,{key:e,value:e},j(e),9,UQ))),128))],40,HQ)):p.value.lead.kind===`text`?(B(),H(N(Qw),{key:1,"model-value":w(p.value.lead.key),class:`min-h-40 text-[13px] leading-relaxed`,onFocus:t[3]||=e=>v.value=p.value.lead.key,"onUpdate:modelValue":t[4]||=e=>_(p.value.lead.key,String(e))},null,8,[`model-value`])):(B(),H(N(wD),{key:2,"model-value":w(p.value.lead.key),onFocus:t[5]||=e=>v.value=p.value.lead.key,"onUpdate:modelValue":t[6]||=e=>_(p.value.lead.key,String(e))},null,8,[`model-value`])),c.value.length&&p.value.lead.kind!==`select`?(B(),V(`div`,WQ,[t[14]||=U(`span`,{class:`text-[11px] text-fg-subtle`},`Insert`,-1),(B(!0),V(z,null,L(c.value,e=>(B(),V(z,{key:e},[U(`button`,{type:`button`,class:`rounded-full border border-border px-2 py-0.5 font-mono text-[11px] hover:border-primary hover:text-primary`,onClick:t=>y(e,`summary`)},j(e),9,GQ),U(`button`,{type:`button`,class:`rounded-full border border-border px-2 py-0.5 font-mono text-[11px] hover:border-primary hover:text-primary`,onClick:t=>y(e,`result`)},j(e)+`.result`,9,KQ)],64))),128))])):K(``,!0)])):K(``,!0),p.value.compact.length?(B(),V(`section`,qQ,[(B(!0),V(z,null,L(p.value.compact,e=>(B(),V(`div`,{key:e.key,class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},[U(`span`,{class:`flex flex-1 items-center gap-1 text-[13px]`,title:e.schema.description},[G(j(C(e.key,e.schema))+` `,1),e.schema.description?(B(),H(N(id),{key:0,class:`size-3 text-fg-subtle`})):K(``,!0)],8,JQ),e.kind===`boolean`?(B(),H(N(YD),{key:0,"model-value":s.value[e.key]===!0,"onUpdate:modelValue":t=>_(e.key,t||void 0)},null,8,[`model-value`,`onUpdate:modelValue`])):e.kind===`select`?(B(),V(`select`,{key:1,class:`h-7 max-w-40 rounded-md border border-input bg-background px-1.5 text-[13px]`,value:w(e.key),onChange:t=>_(e.key,t.target.value||void 0)},[t[15]||=U(`option`,{value:``},`Default`,-1),(B(!0),V(z,null,L(e.schema.enum,e=>(B(),V(`option`,{key:e,value:e},j(e),9,XQ))),128))],40,YQ)):e.kind===`number`?(B(),V(`input`,{key:2,type:`number`,class:`h-7 w-24 rounded-md border border-input bg-background px-2 text-right text-[13px]`,value:s.value[e.key]??``,onInput:t=>_(e.key,t.target.value===``?void 0:Number(t.target.value))},null,40,ZQ)):(B(),V(`input`,{key:3,class:`h-7 w-40 rounded-md border border-input bg-background px-2 text-[13px]`,value:w(e.key),onFocus:t=>v.value=e.key,onInput:t=>_(e.key,t.target.value)},null,40,QQ))]))),128))])):K(``,!0),(B(!0),V(z,null,L(p.value.long,e=>(B(),V(`section`,{key:e.key,class:`space-y-1.5`},[U(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:e.schema.description},[G(j(C(e.key,e.schema))+` `,1),e.schema.description?(B(),H(N(id),{key:0,class:`size-3 text-fg-subtle`})):K(``,!0)],8,$Q),e.kind===`text`?(B(),H(N(Qw),{key:0,"model-value":w(e.key),class:`min-h-20 text-[13px]`,onFocus:t=>v.value=e.key,"onUpdate:modelValue":t=>_(e.key,String(t))},null,8,[`model-value`,`onFocus`,`onUpdate:modelValue`])):e.kind===`lines`?(B(),H(N(Qw),{key:1,"model-value":Array.isArray(s.value[e.key])?s.value[e.key].join(`
`,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=rQ(nQ(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=rQ(nQ(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 sQ(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new QZ||null,prettyErrors:t}}function cQ(e,t={}){let{lineCounter:n,prettyErrors:r}=sQ(t),i=new oQ(n?.addNewLine),a=new RZ(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 eZ(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(nZ(e,n)),o.warnings.forEach(nZ(e,n))),o}function lQ(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=cQ(e,n);if(!i)return null;if(i.warnings.forEach(e=>NY(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function uQ(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return OJ(e)&&!r?e.toString(n):new ZX(e,r,n).toString(n)}function dQ(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})}}function fQ(e,t){let n=e=>e.path&&e.path.length>=2?Number(e.path[1]):-1,r=e.nodes.find(e=>JSON.stringify(e.data.path)===JSON.stringify(t))?.data,i=r?.resume??r?.stage;if(!r||!i)return null;let a=Math.max(-1,...e.nodes.filter(e=>e.data.run).map(e=>n(e.data))),o=n(r);if(o<0||o>a)return null;let s=e.nodes.filter(e=>e.data.path?.length===2).sort((e,t)=>n(e.data)-n(t.data)).map(e=>e.data.resume??e.data.stage??``),c=e=>!!e&&s.filter(t=>t===e).length>1;return c(i)||o>0&&c(s[o-1])?{label:`Add an id to resume here`,from:i,blocked:!0}:{label:o===a?`Resume from here`:`Re-run from here`,from:i}}var pQ=140,mQ=280,hQ={"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 gQ(e){return hQ[e]??e}var _Q=/\{\{\s*steps\.([A-Za-z0-9_-]+)\.[^}]*\}\}/g;function vQ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yQ(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 bQ(e){for(let t of[`mission`,`message`,`body`,`plan`,`detail`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.replace(/\{\{\s*([^}]+?)\s*\}\}/g,`‹$1›`).split(`
`).find(e=>e.trim())?.trim()}}function xQ(e,t){let n=JSON.stringify(e??{})+` `+(typeof t==`string`?`{{ ${t.replace(/^!/,``)} }}`:``);return[...new Set([...n.matchAll(_Q)].map(e=>e[1]))]}function SQ(e){let t=cQ(e).toJS(),n=vQ(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:`Starts when`,type:``,detail:``}});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,l)=>{let u=vQ(e)?e:{},f=typeof u.type==`string`?u.type:``,p=vQ(u.settings)?u.settings:{},m=typeof u.id==`string`?u.id:``,h=`step-${t}`,g=s?`${s}/${m||f}`:m||f;r.push({id:h,type:`step`,position:{x:n,y:i},data:{kind:`step`,key:m||t,title:m||gQ(f),type:f,detail:yQ(f,p),summary:bQ(p),when:typeof u.when==`string`?u.when:void 0,retry:vQ(u.retry)&&typeof u.retry.attempts==`number`?u.retry.attempts:void 0,continues:u.on_failure===`continue`,branch:s,path:l,stage:g,occurrence:d(g),...c?{resume:c}:{}}}),m&&a.set(m,h);for(let e of xQ(u.settings,u.when))o.push({from:e,to:h});return h},p=(e,t,n)=>{e.forEach((r,a)=>i.push({id:`flow-${r}-${t}`,source:r,target:t,kind:`flow`,insertAfter:a===e.length-1?n:void 0}))};for(let[e,t]of n.entries()){if(vQ(t)&&vQ(t.parallel)){let n=Object.entries(t.parallel),r=typeof t.id==`string`?t.id:`parallel`,i=[],a=0;n.forEach(([t,o],s)=>{let u=(s-(n.length-1)/2)*mQ,d=c,m=c;(Array.isArray(o)?o:[]).forEach((i,o)=>{let c=f(i,`${e+1}-${t}-${o+1}`,u,(l+o)*pQ,t,r,[`steps`,e,`parallel`,t,o]);p(d,c,d===m&&s===n.length-1?e-1:void 0),d=[c],a=Math.max(a,o+1)}),i.push(...d)}),c=i,l+=Math.max(a,1);continue}let n=f(t,String(e+1),0,l*pQ,void 0,void 0,[`steps`,e]);p(c,n,e-1),c=[n],l++}r.push({id:`add-end`,type:`add`,position:{x:104,y:l*pQ-24},data:{kind:`step`,key:`add`,title:``,type:``,detail:``}}),p(c,`add-end`);for(let{from:e,to:t}of o){let n=a.get(e);n&&(i.some(e=>e.kind===`flow`&&e.source===n&&e.target===t)||i.push({id:`data-${n}-${t}`,source:n,target:t,kind:`data`,label:e,offset:24+14*i.filter(e=>e.kind===`data`).length,sourceHandle:`data-out`,targetHandle:`data-in`}))}return{nodes:r,edges:i}}var CQ={agent:ad,command:qd,repo:xd,gate:Wd,forge:kd,human:ef,review:yd,workflow:rf},wQ={agent:`Agents`,command:`Commands`,repo:`Repository`,gate:`Checks`,forge:`Issues and PRs`,human:`People`,review:`Review`,workflow:`Flow`};function TQ(e){return CQ[e.split(`.`)[0]]??rf}function EQ(e){return Object.keys(wQ).map(t=>({title:wQ[t],icon:CQ[t],types:e.filter(e=>e.split(`.`)[0]===t)})).filter(e=>e.types.length)}function DQ(e,t){let n=cQ(e).getIn(t,!0);if(kJ(n))return n.toJSON()}function OQ(e,t,n){let r=cQ(e);return r.setIn(t,r.createNode(PQ(n))),r.toString()}function kQ(e,t,n){let r=cQ(e),i=r.get(`steps`,!0);if(MJ(i)||(r.set(`steps`,r.createNode([])),i=r.get(`steps`,!0)),!MJ(i))return{source:e,path:[]};let a=Math.min(Math.max(t+1,0),i.items.length);return i.items.splice(a,0,r.createNode({type:n})),{source:r.toString(),path:[`steps`,a]}}function AQ(e,t){let n=cQ(e),r=n.getIn(t.slice(0,-1),!0),i=t.at(-1);if(!MJ(r)||typeof i!=`number`)return{source:e,path:t};let a=n.createNode(n.getIn(t));return kJ(a)&&a.delete(`id`),r.items.splice(i+1,0,a),{source:n.toString(),path:[...t.slice(0,-1),i+1]}}function jQ(e,t){let n=cQ(e);n.deleteIn(t);let r=t.slice(0,-1);if(r.length>2){let e=n.getIn(r,!0);MJ(e)&&e.items.length===0&&n.deleteIn(r)}return n.toString()}function MQ(e,t,n){let r=cQ(e),i=r.getIn(t.slice(0,-1),!0),a=t.at(-1);if(!MJ(i)||typeof a!=`number`)return{source:e,path:t};let o=a+n;if(o<0||o>=i.items.length)return{source:e,path:t};let[s]=i.items.splice(a,1);return i.items.splice(o,0,s),{source:r.toString(),path:[...t.slice(0,-1),o]}}function NQ(e,t){let n=cQ(e).toJS(),r=Array.isArray(n?.steps)?n.steps:[],i=typeof t[1]==`number`?t[1]:r.length,a=[],o=e=>{if(typeof e!=`object`||!e)return;let t=e;if(typeof t.id==`string`&&a.push(t.id),typeof t.parallel==`object`&&t.parallel!==null)for(let e of Object.values(t.parallel))Array.isArray(e)&&e.forEach(o)};if(r.slice(0,i).forEach(o),t.length===5){let e=r[i]?.parallel?.[t[3]];Array.isArray(e)&&e.slice(0,t[4]).forEach(o)}return a}function PQ(e){if(Array.isArray(e))return e.map(PQ);if(typeof e!=`object`||!e)return e;let t={};for(let[n,r]of Object.entries(e)){if(r===void 0||r===``||r===null)continue;let e=PQ(r);(typeof e!=`object`||!e||Array.isArray(e)||Object.keys(e).length!==0)&&(t[n]=e)}return t}function FQ(e,t){let n=cQ(e).get(t,!0);return n&&typeof n==`object`&&`toJSON`in n?n.toJSON():cQ(e).get(t)}function IQ(e,t,n){let r=cQ(e),i=PQ({[t]:n})[t];return i===void 0?r.delete(t):r.set(t,r.createNode(i)),r.toString()}function LQ(e){return e.ok?`Valid`:e.line?`Line ${e.line}: ${e.message}`:e.message}function RQ(e,t=[]){let n=cQ(e),r=n.errors[0];if(r)return{ok:!1,message:QQ(r.message),line:r.linePos?.[0]?.line};let i=n.toJS();if(!$Q(i))return{ok:!1,message:`A workflow is a mapping with an id and steps.`};let a=typeof i.id==`string`?i.id.trim():``;if(!a)return{ok:!1,message:`workflow id is required`};le Line truncated
`).map((e,t)=>({number:t+1,text:e,tokens:JQ(e)}))}var KQ=/^(\s*)(-\s+)?/,qQ=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function JQ(e){let{code:t,comment:n}=YQ(e),r=XQ(t);return n&&r.push({text:n,kind:`comment`}),r}function YQ(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 XQ(e){if(!e)return[];let t=[],n=KQ.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=qQ.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,...ZQ(i[4]??``)]):[...t,...ZQ(r)]}function ZQ(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 QQ(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function $Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function e$(e){return typeof e==`string`&&e.trim()!==``}var t$={class:`flex h-full w-[24rem] flex-col border-l border-border bg-card shadow-xl`},n$={class:`flex items-center gap-2.5 border-b border-border px-4 py-3`},r$={class:`flex size-8 shrink-0 items-center justify-center rounded-md bg-secondary text-primary`},i$={class:`min-w-0 flex-1`},a$=[`value`,`placeholder`],o$={class:`truncate font-mono text-[11px] text-fg-subtle`},s$={class:`flex-1 space-y-5 overflow-y-auto px-4 py-4`},c$={key:0,class:`rounded-md bg-danger/10 px-2.5 py-1.5 text-xs text-danger`,role:`alert`},l$={key:1,class:`space-y-1.5`},u$=[`title`],d$=[`value`],f$=[`value`],p$={key:3,class:`flex flex-wrap items-center gap-1 pt-0.5`},m$=[`onClick`],h$=[`onClick`],g$={key:2,class:`divide-y divide-border rounded-md border border-border`},_$=[`title`],v$=[`value`,`onChange`],y$=[`value`],b$=[`value`,`onInput`],x$=[`value`,`onFocus`,`onInput`],S$=[`title`],C$={key:0,class:`text-xs text-danger`},w$={class:`space-y-2`},T$={class:`divide-y divide-border rounded-md border border-border`},E$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},D$=[`value`],O$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},k$=[`value`],A$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},j$=[`value`],M$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},N$={class:`flex items-center border-t border-border px-4 py-2.5`},P$=I({__name:`StepEditor`,props:{yaml:{},path:{},vocabulary:{}},emits:[`update:yaml`,`close`,`remove`],setup(e,{emit:t}){let n=e,r=t,i=J(()=>DQ(n.yaml,n.path)??{}),a=J(()=>typeof i.value.type==`string`?i.value.type:``),o=J(()=>n.vocabulary.find(e=>e.name===a.value)),s=J(()=>typeof i.value.settings==`object`&&i.value.settings!==null?i.value.settings:{}),c=J(()=>NQ(n.yaml,n.path)),l=J(()=>o.value?.settings&&i.value.settings?UQ(i.value.settings,o.value.settings,`settings`):``),u=[`mission`,`workflow`,`message`,`body`,`plan`,`then`,`status`,`detail`,`run`,`rules`],d=/mission|body|detail|plan|rules/;function f(e,t){return t.type===`string`?t.enum?`select`:d.test(e)?`text`:`line`:t.type===`boolean`?`boolean`:t.type===`integer`||t.type===`number`?`number`:t.type===`array`&&t.items?.type===`string`?`lines`:`yaml`}let p=J(()=>{let e=Object.entries(o.value?.settings?.properties??{}).map(([e,t])=>({key:e,schema:t,kind:f(e,t)})),t=e.filter(e=>u.includes(e.key)&&e.kind!==`boolean`).sort((e,t)=>u.indexOf(e.key)-u.indexOf(t.key))[0],n=e.filter(e=>e!==t);return{lead:t,compact:n.filter(e=>[`select`,`line`,`number`,`boolean`].includes(e.kind)),long:n.filter(e=>[`text`,`lines`,`yaml`].includes(e.kind))}});function m(e){let{id:t,type:i,...a}=e;r(`update:yaml`,OQ(n.yaml,n.path,{id:t,type:i,...a}))}function h(e,t){m({...i.value,[e]:t})}function g(e){h(`retry`,{...i.value.retry,...e})}function _(e,t){m({...i.value,settings:{...s.value,[e]:t}})}let v=M(null);function y(e,t){let n=v.value??p.value.lead?.key;if(!n)return;let r=typeof s.value[n]==`string`?s.value[n]:``,i=`{{ steps.${e}.${t} }}`;_(n,r?`${r.trimEnd()} ${i}`:i)}let b=M({});function x(e,t){try{_(e,t.trim()?lQ(t):void 0),b.value={...b.value,[e]:``}}catch(t){b.value={...b.value,[e]:String(t.message).split(`
`)[0]}}}let S=e=>e===void 0?``:uQ(e).trimEnd(),C=(e,t)=>t.title??e.replaceAll(`_`,` `).replace(/^./,e=>e.toUpperCase()),w=e=>typeof s.value[e]==`string`?s.value[e]:``;return(e,t)=>(B(),V(`aside`,t$,[U(`header`,n$,[U(`span`,r$,[(B(),H(na(N(TQ)(a.value)),{class:`size-4`}))]),U(`div`,i$,[U(`input`,{value:i.value.id??``,class:`w-full truncate bg-transparent text-sm font-medium outline-none placeholder:text-fg-subtle focus:underline`,placeholder:N(gQ)(a.value),"aria-label":`Step id`,onInput:t[0]||=e=>h(`id`,e.target.value)},null,40,a$),U(`div`,o$,j(a.value),1)]),W(N(Q),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,onClick:t[1]||=e=>r(`close`)},{default:P(()=>[W(N(of))]),_:1})]),U(`div`,s$,[l.value?(B(),V(`p`,c$,j(l.value),1)):K(``,!0),p.value.lead?(B(),V(`section`,l$,[U(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:p.value.lead.schema.description},[G(j(C(p.value.lead.key,p.value.lead.schema))+` `,1),p.value.lead.schema.description?(B(),H(N(hd),{key:0,class:`size-3 text-fg-subtle`})):K(``,!0)],8,u$),p.value.lead.kind===`select`?(B(),V(`select`,{key:0,class:`h-9 w-full rounded-md border border-input bg-background px-2`,value:w(p.value.lead.key),onChange:t[2]||=e=>_(p.value.lead.key,e.target.value||void 0)},[t[13]||=U(`option`,{value:``},`Default`,-1),(B(!0),V(z,null,L(p.value.lead.schema.enum,e=>(B(),V(`option`,{key:e,value:e},j(e),9,f$))),128))],40,d$)):p.value.lead.kind===`text`?(B(),H(N(Pw),{key:1,"model-value":w(p.value.lead.key),class:`min-h-40 text-[13px] leading-relaxed`,onFocus:t[3]||=e=>v.value=p.value.lead.key,"onUpdate:modelValue":t[4]||=e=>_(p.value.lead.key,String(e))},null,8,[`model-value`])):(B(),H(N(VT),{key:2,"model-value":w(p.value.lead.key),onFocus:t[5]||=e=>v.value=p.value.lead.key,"onUpdate:modelValue":t[6]||=e=>_(p.value.lead.key,String(e))},null,8,[`model-value`])),c.value.length&&p.value.lead.kind!==`select`?(B(),V(`div`,p$,[t[14]||=U(`span`,{class:`text-[11px] text-fg-subtle`},`Insert`,-1),(B(!0),V(z,null,L(c.value,e=>(B(),V(z,{key:e},[U(`button`,{type:`button`,class:`rounded-full border border-border px-2 py-0.5 font-mono text-[11px] hover:border-primary hover:text-primary`,onClick:t=>y(e,`summary`)},j(e),9,m$),U(`button`,{type:`button`,class:`rounded-full border border-border px-2 py-0.5 font-mono text-[11px] hover:border-primary hover:text-primary`,onClick:t=>y(e,`result`)},j(e)+`.result`,9,h$)],64))),128))])):K(``,!0)])):K(``,!0),p.value.compact.length?(B(),V(`section`,g$,[(B(!0),V(z,null,L(p.value.compact,e=>(B(),V(`div`,{key:e.key,class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},[U(`span`,{class:`flex flex-1 items-center gap-1 text-[13px]`,title:e.schema.description},[G(j(C(e.key,e.schema))+` `,1),e.schema.description?(B(),H(N(hd),{key:0,class:`size-3 text-fg-subtle`})):K(``,!0)],8,_$),e.kind===`boolean`?(B(),H(N(_O),{key:0,"model-value":s.value[e.key]===!0,"onUpdate:modelValue":t=>_(e.key,t||void 0)},null,8,[`model-value`,`onUpdate:modelValue`])):e.kind===`select`?(B(),V(`select`,{key:1,class:`h-7 max-w-40 rounded-md border border-input bg-background px-1.5 text-[13px]`,value:w(e.key),onChange:t=>_(e.key,t.target.value||void 0)},[t[15]||=U(`option`,{value:``},`Default`,-1),(B(!0),V(z,null,L(e.schema.enum,e=>(B(),V(`option`,{key:e,value:e},j(e),9,y$))),128))],40,v$)):e.kind===`number`?(B(),V(`input`,{key:2,type:`number`,class:`h-7 w-24 rounded-md border border-input bg-background px-2 text-right text-[13px]`,value:s.value[e.key]??``,onInput:t=>_(e.key,t.target.value===``?void 0:Number(t.target.value))},null,40,b$)):(B(),V(`input`,{key:3,class:`h-7 w-40 rounded-md border border-input bg-background px-2 text-[13px]`,value:w(e.key),onFocus:t=>v.value=e.key,onInput:t=>_(e.key,t.target.value)},null,40,x$))]))),128))])):K(``,!0),(B(!0),V(z,null,L(p.value.long,e=>(B(),V(`section`,{key:e.key,class:`space-y-1.5`},[U(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:e.schema.description},[G(j(C(e.key,e.schema))+` `,1),e.schema.description?(B(),H(N(hd),{key:0,class:`size-3 text-fg-subtle`})):K(``,!0)],8,S$),e.kind===`text`?(B(),H(N(Pw),{key:0,"model-value":w(e.key),class:`min-h-20 text-[13px]`,onFocus:t=>v.value=e.key,"onUpdate:modelValue":t=>_(e.key,String(t))},null,8,[`model-value`,`onFocus`,`onUpdate:modelValue`])):e.kind===`lines`?(B(),H(N(Pw),{key:1,"model-value":Array.isArray(s.value[e.key])?s.value[e.key].join(`
`):``,class:`min-h-16 font-mono text-xs`,placeholder:`One per line`,"onUpdate:modelValue":t=>_(e.key,String(t).split(`
`).filter(Boolean))},null,8,[`model-value`,`onUpdate:modelValue`])):(B(),V(z,{key:2},[W(N(Qw),{"model-value":S(s.value[e.key]),class:`min-h-24 font-mono text-xs`,placeholder:`YAML`,onChange:t=>x(e.key,t.target.value)},null,8,[`model-value`,`onChange`]),b.value[e.key]?(B(),V(`span`,e$,j(b.value[e.key]),1)):K(``,!0)],64))]))),128)),U(`section`,t$,[t[21]||=U(`div`,{class:`text-xs font-medium text-muted-foreground`},`Flow`,-1),U(`div`,n$,[U(`label`,r$,[t[16]||=U(`span`,{class:`flex-1 text-[13px]`},`Run only when`,-1),U(`input`,{class:`h-7 w-48 rounded-md border border-input bg-background px-2 font-mono text-xs`,placeholder:`always`,value:i.value.when??``,onInput:t[7]||=e=>h(`when`,e.target.value)},null,40,i$)]),U(`label`,a$,[t[18]||=U(`span`,{class:`flex-1 text-[13px]`},`If it fails`,-1),U(`select`,{class:`h-7 rounded-md border border-input bg-background px-1.5 text-[13px]`,value:i.value.on_failure??``,onChange:t[8]||=e=>h(`on_failure`,e.target.value||void 0)},[...t[17]||=[U(`option`,{value:``},`Park the task`,-1),U(`option`,{value:`continue`},`Continue`,-1)]],40,o$)]),U(`label`,s$,[t[19]||=U(`span`,{class:`flex-1 text-[13px]`},`Attempts`,-1),U(`input`,{type:`number`,min:`1`,max:`10`,placeholder:`1`,class:`h-7 w-20 rounded-md border border-input bg-background px-2 text-right text-[13px]`,value:i.value.retry?.attempts??``,onInput:t[9]||=e=>g({attempts:e.target.value===``?void 0:Number(e.target.value)})},null,40,c$)]),U(`label`,l$,[t[20]||=U(`span`,{class:`flex-1 text-[13px]`},`Retry backoff`,-1),W(N(LD),{"model-value":i.value.retry?.backoff??``,units:[`s`,`m`,`h`],"onUpdate:modelValue":t[10]||=e=>g({backoff:e||void 0})},null,8,[`model-value`])])])])]),U(`footer`,u$,[W(N(Q),{type:`button`,variant:`ghost`,size:`sm`,class:`text-danger`,onClick:t[11]||=e=>r(`remove`)},{default:P(()=>[W(N(Ld)),t[22]||=G(` Delete step`,-1)]),_:1}),W(N(Q),{type:`button`,size:`sm`,class:`ml-auto`,onClick:t[12]||=e=>r(`close`)},{default:P(()=>[...t[23]||=[G(`Done`,-1)]]),_:1})])]))}}),f$=`repository_path`;function p$(e,t,n){let r=[];for(let[n,i]of e){let e=t[n];e?.from===`path`&&e.path.trim()&&r.push({name:n,path:e.path.trim(),type:i.type??`string`,required:i.required===!0})}return n.trim()&&r.push({name:f$,path:n.trim(),type:`string`,required:!0}),r}function m$(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e==`boolean`?`bool`:typeof e==`object`?`object`:typeof e}function h$(e,t,n){let r=[];for(let[i,a]of e){let e=t[i],o=a.type??`string`;if(!(e&&(e.from===`path`?e.path.trim():e.value!==``))){a.required&&r.push(`${i} is required`);continue}if(e.from===`path`){let e=n?.failures?.find(e=>e.field_name===i);e&&r.push(`${i}: ${e.reason}`);continue}let s=m$(tN(e.value,o));o!==`any`&&s!==o&&r.push(`${i} is ${o}, but ${JSON.stringify(e.value)} is not`)}return n?.failures?.some(e=>e.field_name===`repository_path`)&&r.push(`the repository path does not resolve`),r}function g$(e,t){let n={};for(let[r,i]of e){let e=t[r];e?.from===`path`&&e.path.trim()?n[r]={param:r}:e?.from===`value`&&e.value!==``&&(n[r]={value:tN(e.value,i.type??`string`)})}return n}function _$(e,t){let n=e=>t.find(t=>t.name===e)?.path??``,r={};for(let[t,i]of Object.entries(e.inputs??{}))r[t]=i.param?{from:`path`,path:n(i.param),value:``}:{from:`value`,path:``,value:typeof i.value==`string`?i.value:JSON.stringify(i.value)};return{rows:r,repositoryPath:n(e.repo_param)}}function v$(e,t=``){return Array.isArray(e)?e.slice(0,3).flatMap((e,n)=>{let r=`${t}[${n}]`;return[r,...v$(e,r)]}):e&&typeof e==`object`?Object.entries(e).flatMap(([e,n])=>{let r=t?`${t}.${e}`:e;return[r,...v$(n,r)]}):[]}function y$(e){try{return e?.body?JSON.parse(e.body):null}catch{return null}}function b$(e){try{let t=JSON.parse(e.headers??`{}`);return Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Array.isArray(t)?t.join(`, `):String(t)]))}catch{return{}}}function x$(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>80?`${t.slice(0,80)}…`:t}var S$={class:`flex h-full flex-col`},C$={class:`flex items-center gap-2 border-b border-border px-4 py-3`},w$={class:`min-w-0 flex-1 truncate text-sm font-medium`},T$={key:0,class:`flex flex-1 items-center justify-center`},E$={class:`space-y-1.5`},D$=[`disabled`],O$=[`value`],k$={key:1,class:`space-y-1.5`},A$=[`value`],j$=[`title`],M$={class:`space-y-1.5`},N$={id:`bind-paths`},P$=[`value`],F$={class:`divide-y divide-border rounded-md border border-border`},I$={class:`flex items-center gap-1.5 text-xs`},L$={class:`font-mono`},R$={class:`text-fg-subtle`},z$={key:0,class:`text-danger`,title:`Required`},B$=[`title`,`aria-label`,`onClick`],V$=[`onUpdate:modelValue`,`aria-label`],H$=[`onUpdate:modelValue`,`aria-label`],U$={key:2,class:`text-xs text-danger`},W$=[`title`],G$={key:0,class:`space-y-1 px-3 py-2`},K$={key:0,class:`text-xs text-danger`},q$={key:1,class:`truncate font-mono text-xs text-success`},J$={key:1,class:`px-3 py-2 text-xs text-fg-subtle`},Y$={class:`space-y-2`},X$={key:0,role:`alert`,class:`text-xs text-danger`},Z$={key:1,class:`texLine truncated
`).filter(Boolean))},null,8,[`model-value`,`onUpdate:modelValue`])):(B(),V(z,{key:2},[W(N(Pw),{"model-value":S(s.value[e.key]),class:`min-h-24 font-mono text-xs`,placeholder:`YAML`,onChange:t=>x(e.key,t.target.value)},null,8,[`model-value`,`onChange`]),b.value[e.key]?(B(),V(`span`,C$,j(b.value[e.key]),1)):K(``,!0)],64))]))),128)),U(`section`,w$,[t[21]||=U(`div`,{class:`text-xs font-medium text-muted-foreground`},`Flow`,-1),U(`div`,T$,[U(`label`,E$,[t[16]||=U(`span`,{class:`flex-1 text-[13px]`},`Run only when`,-1),U(`input`,{class:`h-7 w-48 rounded-md border border-input bg-background px-2 font-mono text-xs`,placeholder:`always`,value:i.value.when??``,onInput:t[7]||=e=>h(`when`,e.target.value)},null,40,D$)]),U(`label`,O$,[t[18]||=U(`span`,{class:`flex-1 text-[13px]`},`If it fails`,-1),U(`select`,{class:`h-7 rounded-md border border-input bg-background px-1.5 text-[13px]`,value:i.value.on_failure??``,onChange:t[8]||=e=>h(`on_failure`,e.target.value||void 0)},[...t[17]||=[U(`option`,{value:``},`Park the task`,-1),U(`option`,{value:`continue`},`Continue`,-1)]],40,k$)]),U(`label`,A$,[t[19]||=U(`span`,{class:`flex-1 text-[13px]`},`Attempts`,-1),U(`input`,{type:`number`,min:`1`,max:`10`,placeholder:`1`,class:`h-7 w-20 rounded-md border border-input bg-background px-2 text-right text-[13px]`,value:i.value.retry?.attempts??``,onInput:t[9]||=e=>g({attempts:e.target.value===``?void 0:Number(e.target.value)})},null,40,j$)]),U(`label`,M$,[t[20]||=U(`span`,{class:`flex-1 text-[13px]`},`Retry backoff`,-1),W(N(aO),{"model-value":i.value.retry?.backoff??``,units:[`s`,`m`,`h`],"onUpdate:modelValue":t[10]||=e=>g({backoff:e||void 0})},null,8,[`model-value`])])])])]),U(`footer`,N$,[W(N(Q),{type:`button`,variant:`ghost`,size:`sm`,class:`text-danger`,onClick:t[11]||=e=>r(`remove`)},{default:P(()=>[W(N(Yd)),t[22]||=G(` Delete step`,-1)]),_:1}),W(N(Q),{type:`button`,size:`sm`,class:`ml-auto`,onClick:t[12]||=e=>r(`close`)},{default:P(()=>[...t[23]||=[G(`Done`,-1)]]),_:1})])]))}}),F$=`repository_path`;function I$(e,t,n){let r=[];for(let[n,i]of e){let e=t[n];e?.from===`path`&&e.path.trim()&&r.push({name:n,path:e.path.trim(),type:i.type??`string`,required:i.required===!0})}return n.trim()&&r.push({name:F$,path:n.trim(),type:`string`,required:!0}),r}function L$(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e==`boolean`?`bool`:typeof e==`object`?`object`:typeof e}function R$(e,t,n){let r=[];for(let[i,a]of e){let e=t[i],o=a.type??`string`;if(!(e&&(e.from===`path`?e.path.trim():e.value!==``))){a.required&&r.push(`${i} is required`);continue}if(e.from===`path`){let e=n?.failures?.find(e=>e.field_name===i);e&&r.push(`${i}: ${e.reason}`);continue}let s=L$(SN(e.value,o));o!==`any`&&s!==o&&r.push(`${i} is ${o}, but ${JSON.stringify(e.value)} is not`)}return n?.failures?.some(e=>e.field_name===`repository_path`)&&r.push(`the repository path does not resolve`),r}function z$(e,t){let n={};for(let[r,i]of e){let e=t[r];e?.from===`path`&&e.path.trim()?n[r]={param:r}:e?.from===`value`&&e.value!==``&&(n[r]={value:SN(e.value,i.type??`string`)})}return n}function B$(e,t){let n=e=>t.find(t=>t.name===e)?.path??``,r={};for(let[t,i]of Object.entries(e.inputs??{}))r[t]=i.param?{from:`path`,path:n(i.param),value:``}:{from:`value`,path:``,value:typeof i.value==`string`?i.value:JSON.stringify(i.value)};return{rows:r,repositoryPath:n(e.repo_param)}}function V$(e,t=``){return Array.isArray(e)?e.slice(0,3).flatMap((e,n)=>{let r=`${t}[${n}]`;return[r,...V$(e,r)]}):e&&typeof e==`object`?Object.entries(e).flatMap(([e,n])=>{let r=t?`${t}.${e}`:e;return[r,...V$(n,r)]}):[]}function H$(e){try{return e?.body?JSON.parse(e.body):null}catch{return null}}function U$(e){try{let t=JSON.parse(e.headers??`{}`);return Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Array.isArray(t)?t.join(`, `):String(t)]))}catch{return{}}}function W$(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>80?`${t.slice(0,80)}…`:t}var G$={class:`flex h-full flex-col`},K$={class:`flex items-center gap-2 border-b border-border px-4 py-3`},q$={class:`min-w-0 flex-1 truncate text-sm font-medium`},J$={key:0,class:`flex flex-1 items-center justify-center`},Y$={class:`space-y-1.5`},X$=[`disabled`],Z$=[`value`],Q$={key:1,class:`space-y-1.5`},$$=[`value`],e1=[`title`],t1={class:`space-y-1.5`},n1={id:`bind-paths`},r1=[`value`],i1={class:`divide-y divide-border rounded-md border border-border`},a1={class:`flex items-center gap-1.5 text-xs`},o1={class:`font-mono`},s1={class:`text-fg-subtle`},c1={key:0,class:`text-danger`,title:`Required`},l1=[`title`,`aria-label`,`onClick`],u1=[`onUpdate:modelValue`,`aria-label`],d1=[`onUpdate:modelValue`,`aria-label`],f1={key:2,class:`text-xs text-danger`},p1=[`title`],m1={key:0,class:`space-y-1 px-3 py-2`},h1={key:0,class:`text-xs text-danger`},g1={key:1,class:`truncate font-mono text-xs text-success`},_1={key:1,class:`px-3 py-2 text-xs text-fg-subtle`},v1={class:`space-y-2`},y1={key:0,role:`alert`,class:`text-xs text-danger`},b1={key:1,class:`texLine truncated
`).replace(`
`,`
+`).split(`
`).map(e=>e.trim().toLowerCase());if(i.length===1)return e.toLowerCase()===t.toLowerCase();r||n.add(e.toLowerCase());let a=i.every((e,t)=>n.has(e)&&Array.from(n.values())[t]===i[t]);return r&&n.delete(e.toLowerCase()),a}function Une(e,t){return n=>{if(!n.code&&!n.key)return!1;let r=Wne(n.code,e);return Array.isArray(e)?e.some(e=>F5(n[r],e,t,n.type===`keyup`)):F5(n[r],e,t,n.type===`keyup`)}}function Wne(e,t){return t.includes(e)?`code`:`key`}function I5(e,t){let n=J(()=>pn(t?.target)??Vne),r=ln(pn(e)===!0),i=!1,a=new Set,o=c(pn(e));F(()=>pn(e),(e,t)=>{typeof t==`boolean`&&typeof e!=`boolean`&&s(),o=c(e)},{immediate:!0}),R0([`blur`,`contextmenu`],s),B0((...e)=>o(...e),e=>{let n=pn(t?.actInsideInputWithModifier)??!0,a=pn(t?.preventDefault)??!1;if(i=Hne(e),(!i||i&&!n)&&P5(e))return;let o=e.composedPath?.call(e)?.[0]||e.target,s=o?.nodeName===`BUTTON`||o?.nodeName===`A`;!a&&(i||!s)&&e.preventDefault(),r.value=!0},{eventName:`keydown`,target:n}),B0((...e)=>o(...e),e=>{let n=pn(t?.actInsideInputWithModifier)??!0;if(r.value){if((!i||i&&!n)&&P5(e))return;i=!1,r.value=!1}},{eventName:`keyup`,target:n});function s(){i=!1,a.clear(),r.value=pn(e)===!0}function c(e){return e===null?(s(),()=>!1):typeof e==`boolean`?(s(),r.value=e,()=>!1):Array.isArray(e)||typeof e==`string`?Une(e,a):e}return r}var L5=`vue-flow__node-desc`,R5=`vue-flow__edge-desc`,Gne=`vue-flow__aria-live`,z5=[`Enter`,` `,`Escape`],B5={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};function V5(e){return{...e.computedPosition||{x:0,y:0},width:e.dimensions.width||0,height:e.dimensions.height||0}}function H5(e,t){let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)}function U5(e){return{width:e.offsetWidth,height:e.offsetHeight}}function W5(e,t=0,n=1){return Math.min(Math.max(e,t),n)}function G5(e,t){return{x:W5(e.x,t[0][0],t[1][0]),y:W5(e.y,t[0][1],t[1][1])}}function K5(e){let t=e.getRootNode();return`elementFromPoint`in t?t:window.document}function q5(e){return e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e}function J5(e){return e&&typeof e==`object`&&`id`in e&&`position`in e&&!q5(e)}function Y5(e){return J5(e)&&`computedPosition`in e}function X5(e){return!Number.isNaN(e)&&Number.isFinite(e)}function Kne(e){return X5(e.width)&&X5(e.height)&&X5(e.x)&&X5(e.y)}function qne(e,t,n){let r={id:e.id.toString(),type:e.type??`default`,dimensions:an({width:0,height:0}),computedPosition:an({z:0,...e.position}),handleBounds:{source:[],target:[]},draggable:void 0,selectable:void 0,connectable:void 0,focusable:void 0,selected:!1,dragging:!1,resizing:!1,initialized:!1,isParent:!1,position:{x:0,y:0},data:W7(e.data)?e.data:{},events:an(W7(e.events)?e.events:{})};return Object.assign(t??r,e,{id:e.id.toString(),parentNode:n})}function Z5(e,t,n){let r={id:e.id.toString(),type:e.type??t?.type??`default`,source:e.source.toString(),target:e.target.toString(),sourceHandle:e.sourceHandle?.toString(),targetHandle:e.targetHandle?.toString(),updatable:e.updatable??n?.updatable,selectable:e.selectable??n?.selectable,focusable:e.focusable??n?.focusable,data:W7(e.data)?e.data:{},events:an(W7(e.events)?e.events:{}),label:e.label??``,interactionWidth:e.interactionWidth??n?.interactionWidth,...n??{}};return Object.assign(t??r,e,{id:e.id.toString()})}function Q5(e,t,n,r){let i=typeof e==`string`?e:e.id,a=new Set,o=r===`source`?`target`:`source`;for(let e of n)e[o]===i&&a.add(e[r]);return t.filter(e=>a.has(e.id))}function Jne(...e){if(e.length===3){let[t,n,r]=e;return Q5(t,n,r,`target`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>q5(e)&&e.source===r).map(e=>n.find(t=>J5(t)&&t.id===e.target))}function Yne(...e){if(e.length===3){let[t,n,r]=e;return Q5(t,n,r,`source`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>q5(e)&&e.target===r).map(e=>n.find(t=>J5(t)&&t.id===e.source))}function $5({source:e,sourceHandle:t,target:n,targetHandle:r}){return`vueflow__edge-${e}${t??``}-${n}${r??``}`}function Xne(e,t){return t.some(t=>q5(t)&&t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle))}function e7({x:e,y:t},{x:n,y:r,zoom:i}){return{x:e*i+n,y:t*i+r}}function t7({x:e,y:t},{x:n,y:r,zoom:i},a=!1,o=[1,1]){let s={x:(e-n)/i,y:(t-r)/i};return a?P7(s,o):s}function Zne(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}}function n7({x:e,y:t,width:n,height:r}){return{x:e,y:t,x2:e+n,y2:t+r}}function Qne({x:e,y:t,x2:n,y2:r}){return{x:e,y:t,width:n-e,height:r-t}}function r7(e){let t={x:1/0,y:1/0,x2:-1/0,y2:-1/0};for(let n=0;n<e.length;n++){let r=e[n];t=Zne(t,n7({...r.computedPosition,...r.dimensions}))}return Qne(t)}function i7(e,t,n={x:0,y:0,zoom:1},r=!1,i=!1){let a={...t7(t,n),width:t.width/n.zoom,height:t.height/n.zoom},o=[];for(let t of e){let{dimensions:e,selectabl Line truncated
`).map(e=>e.trim().toLowerCase());if(i.length===1)return e.toLowerCase()===t.toLowerCase();r||n.add(e.toLowerCase());let a=i.every((e,t)=>n.has(e)&&Array.from(n.values())[t]===i[t]);return r&&n.delete(e.toLowerCase()),a}function xre(e,t){return n=>{if(!n.code&&!n.key)return!1;let r=Sre(n.code,e);return Array.isArray(e)?e.some(e=>F5(n[r],e,t,n.type===`keyup`)):F5(n[r],e,t,n.type===`keyup`)}}function Sre(e,t){return t.includes(e)?`code`:`key`}function I5(e,t){let n=J(()=>hn(t?.target)??yre),r=dn(hn(e)===!0),i=!1,a=new Set,o=c(hn(e));F(()=>hn(e),(e,t)=>{typeof t==`boolean`&&typeof e!=`boolean`&&s(),o=c(e)},{immediate:!0}),s2([`blur`,`contextmenu`],s),l2((...e)=>o(...e),e=>{let n=hn(t?.actInsideInputWithModifier)??!0,a=hn(t?.preventDefault)??!1;if(i=bre(e),(!i||i&&!n)&&P5(e))return;let o=e.composedPath?.call(e)?.[0]||e.target,s=o?.nodeName===`BUTTON`||o?.nodeName===`A`;!a&&(i||!s)&&e.preventDefault(),r.value=!0},{eventName:`keydown`,target:n}),l2((...e)=>o(...e),e=>{let n=hn(t?.actInsideInputWithModifier)??!0;if(r.value){if((!i||i&&!n)&&P5(e))return;i=!1,r.value=!1}},{eventName:`keyup`,target:n});function s(){i=!1,a.clear(),r.value=hn(e)===!0}function c(e){return e===null?(s(),()=>!1):typeof e==`boolean`?(s(),r.value=e,()=>!1):Array.isArray(e)||typeof e==`string`?xre(e,a):e}return r}var L5=`vue-flow__node-desc`,R5=`vue-flow__edge-desc`,Cre=`vue-flow__aria-live`,z5=[`Enter`,` `,`Escape`],B5={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};function V5(e){return{...e.computedPosition||{x:0,y:0},width:e.dimensions.width||0,height:e.dimensions.height||0}}function H5(e,t){let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)}function U5(e){return{width:e.offsetWidth,height:e.offsetHeight}}function W5(e,t=0,n=1){return Math.min(Math.max(e,t),n)}function G5(e,t){return{x:W5(e.x,t[0][0],t[1][0]),y:W5(e.y,t[0][1],t[1][1])}}function K5(e){let t=e.getRootNode();return`elementFromPoint`in t?t:window.document}function q5(e){return e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e}function J5(e){return e&&typeof e==`object`&&`id`in e&&`position`in e&&!q5(e)}function Y5(e){return J5(e)&&`computedPosition`in e}function X5(e){return!Number.isNaN(e)&&Number.isFinite(e)}function wre(e){return X5(e.width)&&X5(e.height)&&X5(e.x)&&X5(e.y)}function Tre(e,t,n){let r={id:e.id.toString(),type:e.type??`default`,dimensions:sn({width:0,height:0}),computedPosition:sn({z:0,...e.position}),handleBounds:{source:[],target:[]},draggable:void 0,selectable:void 0,connectable:void 0,focusable:void 0,selected:!1,dragging:!1,resizing:!1,initialized:!1,isParent:!1,position:{x:0,y:0},data:W7(e.data)?e.data:{},events:sn(W7(e.events)?e.events:{})};return Object.assign(t??r,e,{id:e.id.toString(),parentNode:n})}function Z5(e,t,n){let r={id:e.id.toString(),type:e.type??t?.type??`default`,source:e.source.toString(),target:e.target.toString(),sourceHandle:e.sourceHandle?.toString(),targetHandle:e.targetHandle?.toString(),updatable:e.updatable??n?.updatable,selectable:e.selectable??n?.selectable,focusable:e.focusable??n?.focusable,data:W7(e.data)?e.data:{},events:sn(W7(e.events)?e.events:{}),label:e.label??``,interactionWidth:e.interactionWidth??n?.interactionWidth,...n??{}};return Object.assign(t??r,e,{id:e.id.toString()})}function Q5(e,t,n,r){let i=typeof e==`string`?e:e.id,a=new Set,o=r===`source`?`target`:`source`;for(let e of n)e[o]===i&&a.add(e[r]);return t.filter(e=>a.has(e.id))}function Ere(...e){if(e.length===3){let[t,n,r]=e;return Q5(t,n,r,`target`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>q5(e)&&e.source===r).map(e=>n.find(t=>J5(t)&&t.id===e.target))}function Dre(...e){if(e.length===3){let[t,n,r]=e;return Q5(t,n,r,`source`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>q5(e)&&e.target===r).map(e=>n.find(t=>J5(t)&&t.id===e.source))}function $5({source:e,sourceHandle:t,target:n,targetHandle:r}){return`vueflow__edge-${e}${t??``}-${n}${r??``}`}function Ore(e,t){return t.some(t=>q5(t)&&t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle))}function e7({x:e,y:t},{x:n,y:r,zoom:i}){return{x:e*i+n,y:t*i+r}}function t7({x:e,y:t},{x:n,y:r,zoom:i},a=!1,o=[1,1]){let s={x:(e-n)/i,y:(t-r)/i};return a?P7(s,o):s}function kre(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}}function n7({x:e,y:t,width:n,height:r}){return{x:e,y:t,x2:e+n,y2:t+r}}function Are({x:e,y:t,x2:n,y2:r}){return{x:e,y:t,width:n-e,height:r-t}}function r7(e){let t={x:1/0,y:1/0,x2:-1/0,y2:-1/0};for(let n=0;n<e.length;n++){let r=e[n];t=kre(t,n7({...r.computedPosition,...r.dimensions}))}return Are(t)}function i7(e,t,n={x:0,y:0,zoom:1},r=!1,i=!1){let a={...t7(t,n),width:t.width/n.zoom,height:t.height/n.zoom},o=[];for(let t of e){let{dimensions:e,selectabl Line truncated
Node: ${e}`,NODE_NOT_FOUND:e=>`Node not found
Node: ${e}`,NODE_MISSING_PARENT:(e,t)=>`Node is missing a parent
Node: ${e}
@@ -153,4 +153,4 @@ Edge: ${e}
Source: ${t}
Target: ${n}`,EDGE_ORPHANED:e=>`Edge was orphaned (suddenly missing source or target) and has been removed
Edge: ${e}`,EDGE_NOT_FOUND:e=>`Edge not found
Edge: ${e}`,USEVUEFLOW_OPTIONS:()=>`The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead`},A7=class extends Error{constructor(e,...t){super(k7[e]?.call(k7,...t)),this.name=`VueFlowError`,this.code=e,this.args=t}};function j7(e){return`clientX`in e}function cre(e){return`sourceEvent`in e}function M7(e,t){let n=j7(e),r,i;return n?(r=e.clientX,i=e.clientY):`touches`in e&&e.touches.length>0?(r=e.touches[0].clientX,i=e.touches[0].clientY):`changedTouches`in e&&e.changedTouches.length>0?(r=e.changedTouches[0].clientX,i=e.changedTouches[0].clientY):(r=0,i=0),{x:r-(t?.left??0),y:i-(t?.top??0)}}var N7=()=>typeof navigator<`u`&&(navigator==null?void 0:navigator.userAgent)?.indexOf(`Mac`)>=0;function lre(e){return{width:e.dimensions?.width??e.width??0,height:e.dimensions?.height??e.height??0}}function P7(e,t=[1,1]){return{x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}}var ure=()=>!0;function F7(e){e?.classList.remove(`valid`,`connecting`,`vue-flow__handle-valid`,`vue-flow__handle-connecting`)}function dre(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())H5(i,V5(e))>0&&r.push(e);return r}var fre=250;function pre(e,t,n,r){let i=[],a=1/0,o=dre(e,n,t+fre);for(let n of o){let o=[...n.handleBounds?.source??[],...n.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=E7(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function I7(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=ure},u,d,f,p){let m=a===`target`,h=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:_}=M7(e),v=o.elementFromPoint(g,_),y=v?.classList.contains(`${s}-flow__handle`)?v:h,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){let e=L7(void 0,y),t=y.getAttribute(`data-nodeid`),a=y.getAttribute(`data-handleid`),o=y.classList.contains(`connectable`),s=y.classList.contains(`connectableend`);if(!t||!e)return b;let c={source:m?t:r,sourceHandle:m?a:i,target:m?r:t,targetHandle:m?i:a};b.connection=c,b.isValid=o&&s&&(n===A5.Strict?m&&e===`source`||!m&&e===`target`:t!==r||a!==i)&&l(c,{nodes:d,edges:u,sourceNode:f(c.source),targetNode:f(c.target)}),b.toHandle=R7(t,e,a,p,n,!0)}return b}function L7(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function mre(e,t){let n=null;return t?n=`valid`:e&&!t&&(n=`invalid`),n}function hre(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}function R7(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===A5.Strict?o.handleBounds?.[t]:[...o.handleBounds?.source??[],...o.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...E7(o,c,c.position,!0)}:c}var z7={[D5.Left]:D5.Right,[D5.Right]:D5.Left,[D5.Top]:D5.Bottom,[D5.Bottom]:D5.Top},gre=[`production`,`prod`];function B7(e,...t){V7()&&console.warn(`[Vue Flow]: ${e}`,...t)}function V7(){return!gre.includes(`production`)}function H7(e,t,n,r,i){let a=t.querySelectorAll(`.vue-flow__handle.${e}`);return a?.length?Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...U5(t)}}):null}function U7(e,t,n,r,i,a=!1,o){i.value=!1,e.selected?(a||e.selected&&t)&&(r([e]),qn(()=>{o.blur()})):n([e])}function W7(e){return N(e)!==void 0}function _re(e,t,n,r){if(!e||!e.source||!e.target)return n(new A7(O7.EDGE_INVALID,e?.id??`[ID UNKNOWN]`)),!1;let i;return i=q5(e)?e:{...e,id:$5(e)},i=Z5(i,void 0,r),!Xne(i,t)&&i}function vre(e,t,n,r,i){if(!t.source||!t.target)return i(new A7(O7.EDGE_INVALID,e.id)),!1;if(!n)return i(new A7(O7.EDGE_NOT_FOUND,e.id)),!1;let{id:a,...o}=e;return{...o,id:r?$5(t):a,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle}}function G7(e,t,n){let r={},i=[];for(let a=0;a<e.length;++a){let o=e[a];if(!J5(o)){n(new A7(O7.NODE_INVALID,o?.id));continue}let s=qne(o,t(o.id),o.parentNode);o.parentNode&&(r[o.parentNode]=!0),i[a]=s}for(let e of i){let a=t(e.parentNode)||i.find(t=>t.id===e.parentNode);e.parentNode&&!a&&n(new A7(O7.NODE_MISSING_PARENT,e.id,e.parentNode)),(e.parentNode||r[e.id])&&(r[e.id]&&(e.isParent=!0),a&&(a.isParent=!0))}return i}function K7(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function q7(e,t,n){e.clear();for(let t of n){let{source:n,target:r,sourceHandle:i=null,targetHandle:a=null}=t,o={edgeId:t.id,source:n,target:r,sourceHandle:i,targetHandle:a},s=`${n}-${i}--${r}-${a}`;K7(`sourcLine truncated
Edge: ${e}`,USEVUEFLOW_OPTIONS:()=>`The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead`},A7=class extends Error{constructor(e,...t){super(k7[e]?.call(k7,...t)),this.name=`VueFlowError`,this.code=e,this.args=t}};function j7(e){return`clientX`in e}function Bre(e){return`sourceEvent`in e}function M7(e,t){let n=j7(e),r,i;return n?(r=e.clientX,i=e.clientY):`touches`in e&&e.touches.length>0?(r=e.touches[0].clientX,i=e.touches[0].clientY):`changedTouches`in e&&e.changedTouches.length>0?(r=e.changedTouches[0].clientX,i=e.changedTouches[0].clientY):(r=0,i=0),{x:r-(t?.left??0),y:i-(t?.top??0)}}var N7=()=>typeof navigator<`u`&&(navigator==null?void 0:navigator.userAgent)?.indexOf(`Mac`)>=0;function Vre(e){return{width:e.dimensions?.width??e.width??0,height:e.dimensions?.height??e.height??0}}function P7(e,t=[1,1]){return{x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}}var Hre=()=>!0;function F7(e){e?.classList.remove(`valid`,`connecting`,`vue-flow__handle-valid`,`vue-flow__handle-connecting`)}function Ure(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())H5(i,V5(e))>0&&r.push(e);return r}var Wre=250;function Gre(e,t,n,r){let i=[],a=1/0,o=Ure(e,n,t+Wre);for(let n of o){let o=[...n.handleBounds?.source??[],...n.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=E7(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function I7(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=Hre},u,d,f,p){let m=a===`target`,h=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:_}=M7(e),v=o.elementFromPoint(g,_),y=v?.classList.contains(`${s}-flow__handle`)?v:h,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){let e=L7(void 0,y),t=y.getAttribute(`data-nodeid`),a=y.getAttribute(`data-handleid`),o=y.classList.contains(`connectable`),s=y.classList.contains(`connectableend`);if(!t||!e)return b;let c={source:m?t:r,sourceHandle:m?a:i,target:m?r:t,targetHandle:m?i:a};b.connection=c,b.isValid=o&&s&&(n===A5.Strict?m&&e===`source`||!m&&e===`target`:t!==r||a!==i)&&l(c,{nodes:d,edges:u,sourceNode:f(c.source),targetNode:f(c.target)}),b.toHandle=R7(t,e,a,p,n,!0)}return b}function L7(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function Kre(e,t){let n=null;return t?n=`valid`:e&&!t&&(n=`invalid`),n}function qre(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}function R7(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===A5.Strict?o.handleBounds?.[t]:[...o.handleBounds?.source??[],...o.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...E7(o,c,c.position,!0)}:c}var z7={[D5.Left]:D5.Right,[D5.Right]:D5.Left,[D5.Top]:D5.Bottom,[D5.Bottom]:D5.Top},Jre=[`production`,`prod`];function B7(e,...t){V7()&&console.warn(`[Vue Flow]: ${e}`,...t)}function V7(){return!Jre.includes(`production`)}function H7(e,t,n,r,i){let a=t.querySelectorAll(`.vue-flow__handle.${e}`);return a?.length?Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...U5(t)}}):null}function U7(e,t,n,r,i,a=!1,o){i.value=!1,e.selected?(a||e.selected&&t)&&(r([e]),$n(()=>{o.blur()})):n([e])}function W7(e){return N(e)!==void 0}function Yre(e,t,n,r){if(!e||!e.source||!e.target)return n(new A7(O7.EDGE_INVALID,e?.id??`[ID UNKNOWN]`)),!1;let i;return i=q5(e)?e:{...e,id:$5(e)},i=Z5(i,void 0,r),!Ore(i,t)&&i}function Xre(e,t,n,r,i){if(!t.source||!t.target)return i(new A7(O7.EDGE_INVALID,e.id)),!1;if(!n)return i(new A7(O7.EDGE_NOT_FOUND,e.id)),!1;let{id:a,...o}=e;return{...o,id:r?$5(t):a,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle}}function G7(e,t,n){let r={},i=[];for(let a=0;a<e.length;++a){let o=e[a];if(!J5(o)){n(new A7(O7.NODE_INVALID,o?.id));continue}let s=Tre(o,t(o.id),o.parentNode);o.parentNode&&(r[o.parentNode]=!0),i[a]=s}for(let e of i){let a=t(e.parentNode)||i.find(t=>t.id===e.parentNode);e.parentNode&&!a&&n(new A7(O7.NODE_MISSING_PARENT,e.id,e.parentNode)),(e.parentNode||r[e.id])&&(r[e.id]&&(e.isParent=!0),a&&(a.isParent=!0))}return i}function K7(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function q7(e,t,n){e.clear();for(let t of n){let{source:n,target:r,sourceHandle:i=null,targetHandle:a=null}=t,o={edgeId:t.id,source:n,target:r,sourceHandle:i,targetHandle:a},s=`${n}-${i}--${r}-${a}`;K7(`sourcLine truncated
+1 -45
View File
@@ -1,40 +1,13 @@
<script setup lang="ts">
import { storeToRefs } from "pinia";
import { onMounted, ref } from "vue";
import { onMounted } from "vue";
import ChatLauncher from "@/chat/ChatLauncher.vue";
import CommandPalette from "@/components/command-palette/CommandPalette.vue";
import Topbar from "@/components/topbar/Topbar.vue";
import SettingsShell from "@/settings/SettingsShell.vue";
import {
Alert,
AlertAction,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import { TooltipProvider } from "@/components/ui/tooltip";
import { hidden, loadCapabilities } from "@/lib/capabilities";
import { createSessionRetry } from "@/lib/session-retry";
import { loadTaskMeta } from "@/lib/task-meta";
import { useLiveUpdatesStore } from "@/stores/live-updates";
const { authenticationRequired } = storeToRefs(useLiveUpdatesStore());
// Re-runs the reads that report their own 401s to the live-updates store. A
// session that came back clears the banner without a document reload; one that
// did not leaves it up.
const retrying = ref(false);
const retrySession = createSessionRetry([loadCapabilities, loadTaskMeta]);
async function retryAuthentication(): Promise<void> {
retrying.value = true;
try {
await retrySession();
} finally {
retrying.value = false;
}
}
onMounted(() => {
// Asked for once, after the shell is up: the nav paints immediately and
@@ -69,23 +42,6 @@ onMounted(() => {
>
<Topbar :hidden="hidden" />
<main class="w-full flex-1 overflow-x-clip p-8 max-lg:p-4">
<Alert v-if="authenticationRequired" variant="destructive" class="mb-4">
<AlertTitle>Dashboard authentication required</AlertTitle>
<AlertDescription>
Open the dashboard URL Archie logged at startup to establish a new
authenticated session.
</AlertDescription>
<AlertAction>
<Button
variant="outline"
size="sm"
:disabled="retrying"
@click="retryAuthentication"
>
{{ retrying ? "Retrying…" : "Retry" }}
</Button>
</AlertAction>
</Alert>
<!--
Keyed on the path and its parameters but not the query: a query-only
change is an entry state, so the page keeps the operator's filters,
+1 -1
View File
@@ -167,7 +167,7 @@ const models = computed({
<section class="mt-8 rounded-lg border border-border bg-card px-5 pt-4 pb-2" aria-labelledby="ch-defaults">
<h2 id="ch-defaults" class="text-[11px] font-medium tracking-[0.06em] text-fg-subtle uppercase">
Chat session defaults · all channels
Chat session defaults
</h2>
<SettingRow label="Workspace" for="cs-workspace" hint="Empty disables file tools.">
<Input id="cs-workspace" v-model="chat.workspace" class="max-w-md font-mono" />
+53
View File
@@ -0,0 +1,53 @@
<script setup lang="ts">
import { ref } from "vue";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { answerAsk, type ChatAsk } from "./state";
defineProps<{ ask: ChatAsk }>();
const reply = ref("");
function sendReply() {
const text = reply.value.trim();
if (!text) return;
reply.value = "";
void answerAsk(text);
}
</script>
<template>
<div class="mt-2 rounded-lg border border-border bg-card p-3 text-sm" role="group" :aria-label="ask.prompt">
<template v-if="ask.kind === 'approval'">
<p class="font-medium">Allow {{ ask.prompt }}?</p>
<p v-if="ask.detail" class="mt-1 font-mono text-xs break-all text-fg-muted">{{ ask.detail }}</p>
<div class="mt-3 flex flex-wrap gap-2">
<Button size="sm" @click="answerAsk('approve')">Approve</Button>
<Button size="sm" variant="outline" @click="answerAsk('always')">Always this session</Button>
<Button size="sm" variant="ghost" class="text-danger" @click="answerAsk('deny')">Deny</Button>
</div>
</template>
<template v-else-if="ask.kind === 'picker'">
<p class="font-medium">{{ ask.prompt }}</p>
<div class="mt-3 flex flex-wrap gap-2">
<Button v-for="choice in ask.choices" :key="choice.id" size="sm" variant="outline" @click="answerAsk(choice.id)">
{{ choice.label }}
</Button>
</div>
</template>
<template v-else>
<p class="font-medium">{{ ask.prompt }}</p>
<div v-if="ask.choices?.length" class="mt-3 flex flex-wrap gap-2">
<Button v-for="choice in ask.choices" :key="choice.id" size="sm" variant="outline" @click="answerAsk(choice.label)">
{{ choice.label }}
</Button>
</div>
<form class="mt-3 flex gap-2" @submit.prevent="sendReply">
<Input v-model="reply" class="flex-1" placeholder="Your answer" aria-label="Your answer" />
<Button type="submit" size="sm" :disabled="!reply.trim()">Send</Button>
</form>
</template>
</div>
</template>
+38
View File
@@ -0,0 +1,38 @@
<script setup lang="ts">
import { computed } from "vue";
import { Button } from "@/components/ui/button";
import { selectorData, setModel, setPersona } from "./state";
const props = defineProps<{ choose: "model" | "personality" }>();
const options = computed(() =>
props.choose === "model" ? (selectorData.value.models ?? []) : (selectorData.value.personas ?? []),
);
const active = computed(() =>
props.choose === "model" ? selectorData.value.active_model : selectorData.value.active_persona,
);
function pick(value: string) {
if (props.choose === "model") void setModel(value);
else setPersona(value);
}
</script>
<template>
<div class="text-sm">
<p class="font-medium">{{ choose === "model" ? "Choose a model" : "Choose a personality" }}</p>
<p v-if="!options.length" class="mt-1 text-fg-muted">None configured.</p>
<div v-else class="mt-2 flex flex-wrap gap-2">
<Button
v-for="option in options"
:key="option"
size="sm"
:variant="option === active ? 'default' : 'outline'"
class="font-mono"
@click="pick(option)"
>{{ option }}</Button
>
</div>
</div>
</template>
+42 -1
View File
@@ -1,5 +1,7 @@
<script setup lang="ts">
import { nextTick, ref, watch } from "vue";
import { computed, nextTick, ref, watch } from "vue";
import { Mic } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";
@@ -15,6 +17,8 @@ import {
isSending,
moveCommandSelection,
sendMessage,
selectorData,
sendVoice,
stopTurn,
syncCommandMenu,
} from "./state";
@@ -34,6 +38,33 @@ import {
*/
const props = defineProps<{ open: boolean }>();
// Voice: recorded in the browser, transcribed by the server like a Telegram
// voice note. The mic shows only while the composer is empty.
const canRecord = computed(
() => !!selectorData.value.voice_available && typeof MediaRecorder !== "undefined" && !!navigator.mediaDevices?.getUserMedia,
);
const recording = ref(false);
let recorder: MediaRecorder | null = null;
async function toggleRecording() {
if (recorder) {
recorder.stop();
return;
}
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
const chunks: Blob[] = [];
recorder = new MediaRecorder(stream);
recorder.ondataavailable = (e) => chunks.push(e.data);
recorder.onstop = () => {
stream.getTracks().forEach((t) => t.stop());
const clip = new Blob(chunks, { type: recorder?.mimeType || "audio/webm" });
recorder = null;
recording.value = false;
if (clip.size) void sendVoice(clip);
};
recorder.start();
recording.value = true;
}
const field = ref<{ $el: HTMLTextAreaElement } | null>(null);
function focus(): void {
@@ -156,6 +187,16 @@ function onKeydown(event: KeyboardEvent): void {
>Stop</Button
>
<Button
v-if="canRecord && !composerText.trim()"
size="sm"
:variant="recording ? 'destructive' : 'outline'"
:disabled="isSending && !recording"
:aria-label="recording ? 'Stop recording and send' : 'Record a voice message'"
@click="toggleRecording"
><Mic data-icon="inline-start" />{{ recording ? "Send" : "" }}</Button
>
<Button
v-else
size="sm"
:disabled="isSending || !composerText.trim()"
@click="sendMessage()"
+10 -1
View File
@@ -10,7 +10,10 @@ import {
MessageScrollerProvider,
MessageScrollerViewport,
} from "@/components/ui/message-scroller";
import ChatAskCard from "./ChatAskCard.vue";
import ChatBubble from "./ChatBubble.vue";
import ChatChooseCard from "./ChatChooseCard.vue";
import ChatUpdateCard from "./ChatUpdateCard.vue";
import ChatEmptyState from "./ChatEmptyState.vue";
import {
messages,
@@ -41,6 +44,8 @@ function parts(message: ChatMessage) {
// metadata only -- so the bubble labels them.
media: message.media || [],
assistant: from !== "web",
update: message.update,
choose: message.choose,
};
}
@@ -68,7 +73,10 @@ const bubbles = computed(() => messages.value.map(parts));
:tools="bubble.tools"
:media="bubble.media"
:assistant="bubble.assistant"
/>
>
<ChatUpdateCard v-if="bubble.update" :update="bubble.update" />
<ChatChooseCard v-if="bubble.choose" :choose="bubble.choose" />
</ChatBubble>
</MessageScrollerItem>
<!-- The live turn is a bubble like any other, so what arrives is
@@ -94,6 +102,7 @@ const bubbles = computed(() => messages.value.map(parts));
>
Retry
</Button>
<ChatAskCard v-if="streamingTurn.ask" :ask="streamingTurn.ask" />
</ChatBubble>
</MessageScrollerItem>
</template>
+72
View File
@@ -0,0 +1,72 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { Button } from "@/components/ui/button";
import { api } from "@/lib/api";
import type { ChatUpdate } from "./state";
const props = defineProps<{ update: ChatUpdate }>();
interface Component {
Label?: string;
ID?: string;
Installed?: string;
Available?: string;
Changelog?: string;
}
const available = computed(() => (props.update.available ?? []) as Component[]);
const state = ref<"idle" | "installing" | "deferred" | "done" | "failed">("idle");
const result = ref("");
async function install() {
state.value = "installing";
try {
const out = await api.updateInstall<{ result?: { installed?: Record<string, string> } }>(props.update.snapshot);
const installed = out.result?.installed;
result.value = installed
? Object.entries(installed).map(([id, v]) => `${id} → ${v}`).join(", ") + ". Archie restarts to apply it."
: "Update finished.";
state.value = "done";
} catch (err) {
result.value = (err as Error).message;
state.value = "failed";
}
}
async function later() {
try {
await api.updateDefer(props.update.snapshot);
state.value = "deferred";
} catch (err) {
result.value = (err as Error).message;
state.value = "failed";
}
}
</script>
<template>
<div class="text-sm">
<p v-if="!available.length">Archie is up to date.</p>
<template v-else>
<p class="font-medium">An update is available</p>
<ul class="mt-1 space-y-0.5">
<li v-for="c in available" :key="c.ID">
{{ c.Label || c.ID }}: <span class="font-mono">{{ c.Installed || "?" }} → {{ c.Available }}</span>
<a v-if="c.Changelog" :href="c.Changelog" target="_blank" rel="noopener" class="ml-1 text-xs underline">changes</a>
</li>
</ul>
<div v-if="state === 'idle'" class="mt-3 flex gap-2">
<Button v-if="update.can_install" size="sm" @click="install">Install</Button>
<Button size="sm" variant="ghost" @click="later">Not now</Button>
</div>
<p v-else-if="state === 'installing'" class="mt-2 text-fg-muted">Installing… this can take a few minutes.</p>
<p v-else-if="state === 'deferred'" class="mt-2 text-fg-muted">Skipped until a newer release.</p>
<p v-else-if="state === 'done'" class="mt-2 text-ok">{{ result }}</p>
<p v-else class="mt-2 text-danger">{{ result }}</p>
<p v-if="state === 'idle' && !update.can_install" class="mt-2 text-xs text-fg-muted">
This host has no install script, so the update can't be installed from here.
</p>
</template>
</div>
</template>
+93 -4
View File
@@ -91,6 +91,17 @@ export interface ChatMessage {
ToolCalls?: ChatToolCall[];
message_id?: string;
MessageID?: string;
/** An update check answered in the panel, with its install actions. */
update?: ChatUpdate;
/** A bare /model or /personality, answered with its choices. */
choose?: "model" | "personality";
}
/** The update snapshot /update shows, and whether this host can install it. */
export interface ChatUpdate {
snapshot: unknown;
available: unknown[];
can_install: boolean;
}
/** A turn in flight: what it is showing, and what to resend if it fails. */
@@ -100,6 +111,17 @@ export interface StreamingTurn {
isError: boolean;
turn?: ChatTurn;
isRetry: boolean;
/** A question the turn waits on until the operator answers it. */
ask?: ChatAsk;
}
/** An approval, clarify or picker question from a running turn. */
export interface ChatAsk {
id: string;
kind: "approval" | "clarify" | "picker";
prompt: string;
detail?: string;
choices?: { id: string; label: string }[];
}
/** Everything the selectors on the panel read, from one sessions read. */
@@ -113,6 +135,7 @@ export interface ChatSelectorData {
active_provider?: string;
active_model?: string;
commands?: Array<ChatCommandSpec | string>;
voice_available?: boolean;
}
/**
@@ -130,10 +153,21 @@ interface ChatStreamFrame extends ChatToolCall {
type?: string;
text: string;
session_id?: string;
ask?: ChatAsk;
}
/** A turn that never settles must not hold the composer closed forever. */
const STREAM_TIMEOUT_MS = 120000;
let rearmTimeout: (() => void) | null = null;
/** answerAsk sends the operator's answer to the question the turn waits on. */
export async function answerAsk(answer: string): Promise<void> {
const ask = streamingTurn.value?.ask;
if (!ask) return;
streamingTurn.value = streamingTurn.value ? { ...streamingTurn.value, ask: undefined } : null;
rearmTimeout?.();
await api.chatAnswer(ask.id, answer);
}
export const sessions = ref<ChatSession[]>([]);
export const currentSession = ref("");
@@ -391,6 +425,34 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
composerText.value = "";
}
// Bare /model and /personality offer their choices as buttons, as Telegram
// does; with an argument they go to the gateway like any command.
if (!isRetry && (text.trim() === "/model" || text.trim() === "/personality")) {
const choose = text.trim() === "/model" ? "model" : "personality";
messages.value = [...messages.value, { from: "assistant", text: "", choose }];
isSending.value = false;
statusText.value = "Ready";
return;
}
// /update answers here, where the panel can offer Install like Telegram does.
if (!isRetry && text.trim() === "/update") {
try {
const update = await api.updateSnapshot<ChatUpdate>();
messages.value = [...messages.value, { from: "assistant", text: "", update }];
statusText.value = "Ready";
} catch (err) {
messages.value = [
...messages.value,
{ from: "assistant", text: `Could not check for updates: ${(err as Error).message}` },
];
statusText.value = "Ready";
} finally {
isSending.value = false;
}
return;
}
let activeTools: ChatToolCall[] = [];
streamingTurn.value = { text: "", tools: [], isError: false, turn, isRetry };
@@ -402,10 +464,16 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
try {
const controller = new AbortController();
activeController = controller;
timeoutId = setTimeout(() => {
timedOut = true;
controller.abort();
}, STREAM_TIMEOUT_MS);
const arm = () => {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
timedOut = true;
controller.abort();
}, STREAM_TIMEOUT_MS);
};
arm();
// The clock stops while a question waits on the operator.
rearmTimeout = arm;
const response = await api.chatStream(
{
@@ -413,6 +481,7 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
source_id: turn.sourceID,
text: turn.text,
page: currentPage(),
voice: turn.voice,
},
{ signal: controller.signal },
);
@@ -454,6 +523,12 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
? { ...streamingTurn.value, tools: activeTools }
: null;
}
if (event.type === "ask" && event.ask) {
clearTimeout(timeoutId);
streamingTurn.value = streamingTurn.value
? { ...streamingTurn.value, ask: event.ask }
: null;
}
if (event.type === "done") {
finished = true;
if (!streamedText) streamedText = event.text || "";
@@ -495,6 +570,7 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
}
} finally {
clearTimeout(timeoutId);
rearmTimeout = null;
activeController = null;
isSending.value = false;
}
@@ -524,3 +600,16 @@ export function useChat(): void {
abortActiveTurn();
});
}
/** sendVoice sends a recorded clip as a turn; the server transcribes it. */
export async function sendVoice(clip: Blob): Promise<void> {
const bytes = new Uint8Array(await clip.arrayBuffer());
let binary = "";
for (let i = 0; i < bytes.length; i += 0x8000) {
binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
}
await sendMessage({
textOverride: "🎤 Voice message",
voice: { data: btoa(binary), mime_type: clip.type || "audio/webm" },
});
}
+6 -3
View File
@@ -7,10 +7,12 @@ import { randomUUID } from "@/lib/uuid";
export interface ChatTurn {
text: string;
sourceID: string;
/** A recorded clip, base64, transcribed by the server. */
voice?: { data: string; mime_type: string };
}
export function newChatTurn(text: string): ChatTurn {
return { text, sourceID: randomUUID() };
export function newChatTurn(text: string, voice?: ChatTurn["voice"]): ChatTurn {
return { text, sourceID: randomUUID(), voice };
}
export function retryChatTurn(turn: ChatTurn): ChatTurn {
@@ -21,6 +23,7 @@ export function retryChatTurn(turn: ChatTurn): ChatTurn {
export interface RetryOptions {
textOverride?: string;
turn?: ChatTurn;
voice?: ChatTurn["voice"];
}
// resolveTurn decides what to send: a real retry descriptor's original turn,
@@ -42,6 +45,6 @@ export function resolveTurn(
typeof retry.turn.text === "string"
);
const text = isRetry ? retry.turn!.text : composerValue.trim();
const turn = isRetry ? retryChatTurn(retry.turn!) : newChatTurn(text);
const turn = isRetry ? retryChatTurn(retry.turn!) : newChatTurn(text, retry?.voice);
return { text, turn, isRetry };
}
+4
View File
@@ -262,6 +262,8 @@ export const api = {
// not the 15s default, and the watchdog owns everything after the restart.
version: <T = unknown>() => request<T>("/api/version"),
updateSnapshot: <T = unknown>() => request<T>("/api/chat/update"),
updateDefer: (snapshot: unknown) =>
request("/api/chat/update/defer", { method: "POST", body: { snapshot } }),
updateInstall: <T = unknown>(snapshot: unknown) =>
request<T>("/api/chat/update/install", {
method: "POST",
@@ -351,6 +353,8 @@ export const api = {
method: "POST",
}),
chatSessions: <T = unknown>() => request<T>("/api/chat/sessions"),
chatAnswer: (id: string, answer: string) =>
request("/api/chat/answer", { method: "POST", body: { id, answer } }),
chatMessages: <T = unknown>(id: string) =>
request<T>(`/api/chat/sessions/${encodeURIComponent(id)}/messages`),
chatTurns: <T = unknown>(id: string) =>
-23
View File
@@ -1,23 +0,0 @@
/**
* A retry that re-runs the reads which establish whether the dashboard's
* session is valid, without reloading the document.
*
* It knows nothing about authentication: the reads report their own 401s to
* `setAuthenticationStateHandler`, so a successful retry clears the banner and
* a still-expired session leaves it up. The in-flight guard means a double
* click runs the reads once.
*/
export function createSessionRetry(
loads: Array<() => Promise<unknown> | void>,
): () => Promise<void> {
let running = false;
return async () => {
if (running) return;
running = true;
try {
await Promise.all(loads.map((load) => load()));
} finally {
running = false;
}
};
}
+81 -73
View File
@@ -18,6 +18,7 @@ import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
import { Input } from "@/components/ui/input";
import { StatusPill } from "@/components/ui/status-pill";
import { Switch } from "@/components/ui/switch";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { grants, stage, useExtensionsStore, type Extension } from "@/stores/extensions";
import ApplyStatusRows from "./ApplyStatusRows.vue";
@@ -36,15 +37,17 @@ async function install(): Promise<void> {
}
}
// The dialog's action closes it before its click handler runs, so the
// target outlives the open flag rather than being cleared on close.
const accepting = ref<Extension | null>(null);
const acceptOpen = ref(false);
async function accept(): Promise<void> {
if (accepting.value) await store.accept(accepting.value.name);
accepting.value = null;
}
const removing = ref<Extension | null>(null);
const removeOpen = ref(false);
async function remove(): Promise<void> {
if (removing.value) await store.remove(removing.value.name);
removing.value = null;
}
const tones = {
@@ -61,77 +64,83 @@ const tones = {
<p v-if="store.error" role="alert" class="mb-4 text-sm text-danger">{{ store.error }}</p>
<section class="mb-6" aria-label="Marketplace">
<h2 class="mb-2 text-sm font-medium">Marketplace</h2>
<p v-if="store.catalogueError" class="text-sm text-fg-muted">{{ store.catalogueError }}</p>
<ul v-else class="divide-y divide-border rounded-lg border border-border bg-card">
<li v-for="entry in available" :key="entry.name" class="flex flex-wrap items-center gap-3 px-4 py-3">
<div class="min-w-0 flex-1">
<p class="truncate text-sm font-medium">
{{ entry.name }}
<span class="font-mono text-xs text-fg-subtle">{{ entry.surface }} {{ entry.version }}</span>
</p>
<p class="text-xs text-fg-subtle">{{ entry.description }}</p>
</div>
<Button size="sm" :disabled="!!store.busy" @click="store.installFromCatalogue(entry.name)">
<Plus data-icon="inline-start" /> Install
</Button>
</li>
<li v-if="!available.length" class="px-4 py-3 text-sm text-fg-muted">Everything listed is installed.</li>
</ul>
<details class="mt-3">
<summary class="cursor-pointer text-xs text-fg-muted">Install by reference</summary>
<form class="mt-2 flex flex-wrap gap-2" @submit.prevent="install">
<Input v-model="name" class="max-w-40" placeholder="Name" aria-label="Name" required />
<Input v-model="reference" class="max-w-80 font-mono" placeholder="registry/repo:tag" aria-label="Reference" required />
<Input v-model="digest" class="max-w-96 font-mono" placeholder="sha256:…" aria-label="Digest" required />
<Button type="submit" size="sm" :disabled="!!store.busy"><Plus data-icon="inline-start" /> Install</Button>
</form>
</details>
</section>
<Tabs default-value="installed" class="space-y-4">
<TabsList>
<TabsTrigger value="installed">Installed</TabsTrigger>
<TabsTrigger value="marketplace">Marketplace</TabsTrigger>
</TabsList>
<TabsContent value="installed">
<ul class="divide-y divide-border rounded-lg border border-border bg-card" aria-label="Extensions">
<li v-for="extension in store.extensions" :key="extension.name" class="flex flex-wrap items-center gap-3 px-4 py-3">
<div class="min-w-0 flex-1">
<p class="truncate text-sm font-medium">
{{ extension.display_name || extension.name }}
<span class="font-mono text-xs text-fg-subtle">{{ extension.name }} {{ extension.version }}</span>
</p>
<p class="text-xs text-fg-subtle">{{ extension.description }}</p>
<p class="truncate font-mono text-xs text-fg-subtle">{{ extension.digest }}</p>
</div>
<StatusPill :tone="tones[stage(extension)].tone" :dot="tones[stage(extension)].dot">
{{ tones[stage(extension)].label }}
</StatusPill>
<Button
v-if="stage(extension) === 'accept'"
variant="ghost"
size="sm"
:disabled="!!store.busy"
@click="(accepting = extension), (acceptOpen = true)"
>Review authority</Button
>
<Switch
v-else-if="stage(extension) !== 'inert'"
:model-value="extension.enabled"
:disabled="!!store.busy"
:aria-label="`Enable ${extension.name}`"
@update:model-value="(value: boolean) => store.setEnabled(extension.name, value)"
/>
<Button variant="ghost" size="sm" class="text-danger" :disabled="!!store.busy" @click="(removing = extension), (removeOpen = true)">Remove</Button>
</li>
<li v-if="!store.extensions.length">
<Empty class="py-6">
<EmptyHeader>
<EmptyTitle>Nothing installed</EmptyTitle>
</EmptyHeader>
</Empty>
</li>
</ul>
<ul class="divide-y divide-border rounded-lg border border-border bg-card" aria-label="Extensions">
<li v-for="extension in store.extensions" :key="extension.name" class="flex flex-wrap items-center gap-3 px-4 py-3">
<div class="min-w-0 flex-1">
<p class="truncate text-sm font-medium">
{{ extension.display_name || extension.name }}
<span class="font-mono text-xs text-fg-subtle">{{ extension.name }} {{ extension.version }}</span>
</p>
<p class="text-xs text-fg-subtle">{{ extension.description }}</p>
<p class="truncate font-mono text-xs text-fg-subtle">{{ extension.digest }}</p>
</div>
<StatusPill :tone="tones[stage(extension)].tone" :dot="tones[stage(extension)].dot">
{{ tones[stage(extension)].label }}
</StatusPill>
<Button
v-if="stage(extension) === 'accept'"
variant="ghost"
size="sm"
:disabled="!!store.busy"
@click="accepting = extension"
>Review authority</Button
>
<Switch
v-else-if="stage(extension) !== 'inert'"
:model-value="extension.enabled"
:disabled="!!store.busy"
:aria-label="`Enable ${extension.name}`"
@update:model-value="(value: boolean) => store.setEnabled(extension.name, value)"
/>
<Button variant="ghost" size="sm" class="text-danger" :disabled="!!store.busy" @click="removing = extension">Remove</Button>
</li>
<li v-if="!store.extensions.length">
<Empty class="py-6">
<EmptyHeader>
<EmptyTitle>Nothing installed</EmptyTitle>
</EmptyHeader>
</Empty>
</li>
</ul>
<ApplyStatusRows :kind="KIND" class="mt-6 border-t border-border py-4" />
</TabsContent>
<TabsContent value="marketplace">
<p v-if="store.catalogueError" class="text-sm text-fg-muted">{{ store.catalogueError }}</p>
<ul v-else class="divide-y divide-border rounded-lg border border-border bg-card">
<li v-for="entry in available" :key="entry.name" class="flex flex-wrap items-center gap-3 px-4 py-3">
<div class="min-w-0 flex-1">
<p class="truncate text-sm font-medium">
{{ entry.name }}
<span class="font-mono text-xs text-fg-subtle">{{ entry.surface }} {{ entry.version }}</span>
</p>
<p class="text-xs text-fg-subtle">{{ entry.description }}</p>
</div>
<Button size="sm" :disabled="!!store.busy" @click="store.installFromCatalogue(entry.name)">
<Plus data-icon="inline-start" /> Install
</Button>
</li>
<li v-if="!available.length" class="px-4 py-3 text-sm text-fg-muted">Everything listed is installed.</li>
</ul>
<details class="mt-3">
<summary class="cursor-pointer text-xs text-fg-muted">Install by reference</summary>
<form class="mt-2 flex flex-wrap gap-2" @submit.prevent="install">
<Input v-model="name" class="max-w-40" placeholder="Name" aria-label="Name" required />
<Input v-model="reference" class="max-w-80 font-mono" placeholder="registry/repo:tag" aria-label="Reference" required />
<Input v-model="digest" class="max-w-96 font-mono" placeholder="sha256:…" aria-label="Digest" required />
<Button type="submit" size="sm" :disabled="!!store.busy"><Plus data-icon="inline-start" /> Install</Button>
</form>
</details>
</TabsContent>
</Tabs>
<ApplyStatusRows :kind="KIND" class="mt-6 border-t border-border py-4" />
<AlertDialog :open="!!accepting" @update:open="(open) => !open && (accepting = null)">
<AlertDialog v-model:open="acceptOpen">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Accept what {{ accepting?.name }} may use?</AlertDialogTitle>
@@ -141,7 +150,6 @@ const tones = {
</AlertDialogHeader>
<ul class="font-mono text-xs">
<li v-for="line in accepting ? grants(accepting.declared) : []" :key="line">{{ line }}</li>
<li v-if="accepting && !grants(accepting.declared).length">Nothing beyond its own process.</li>
</ul>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
@@ -150,7 +158,7 @@ const tones = {
</AlertDialogContent>
</AlertDialog>
<AlertDialog :open="!!removing" @update:open="(open) => !open && (removing = null)">
<AlertDialog v-model:open="removeOpen">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Remove {{ removing?.name }}?</AlertDialogTitle>
+1 -1
View File
@@ -61,7 +61,7 @@ async function save() {
<template>
<div
v-if="count > 0"
class="sticky bottom-4 z-30 mt-6 rounded-lg border border-border bg-popover shadow-[var(--shadow-md)]"
class="sticky bottom-4 z-30 mt-auto rounded-lg border border-border bg-popover shadow-[var(--shadow-md)]"
role="region"
aria-label="Unsaved changes"
>
+3 -1
View File
@@ -120,7 +120,9 @@ onBeforeUnmount(() => {
aria-hidden="true"
/>
</div>
<div class="min-w-0 flex-1" :class="route.meta.wide ? '' : 'max-w-[960px]'">
<!-- At least a screen tall, so the sticky save bar always rests at the
viewport's bottom edge rather than under the last setting. -->
<div class="flex min-h-screen min-w-0 flex-1 flex-col" :class="route.meta.wide ? '' : 'max-w-[960px]'">
<RestartPendingBanner />
<!-- Room below the last setting, so it can be scrolled up to eye level. -->
<div class="pb-[40vh]">
+6 -4
View File
@@ -55,15 +55,17 @@ const { catalog, catalogError } = storeToRefs(store);
onMounted(store.load);
const resources = computed(() => resourcesForPage(catalog.value, "repositories"));
const repos = computed(() => store.drafts[KIND]?.value as Repo[] | undefined);
const draft = computed(() => store.drafts[KIND]);
const repos = computed(() => (draft.value?.value ?? []) as Repo[]);
const error = computed(() => store.stateFor(KIND).error);
const ecosystems = ["go", "python", "node", "rust", "custom"];
const newRepo = ref("");
function addRepo() {
const [owner, name] = newRepo.value.trim().split("/");
if (!repos.value || !owner || !name) return;
repos.value.push({
if (!draft.value || !owner || !name) return;
draft.value.value ??= [];
(draft.value.value as Repo[]).push({
owner, name, base: "main", ecosystem: "go", gate: [], preflight: null, protect: null,
test_glob: "", persistent_storage: false, max_retries: 0, allow_concurrent: false,
});
@@ -80,7 +82,7 @@ const protectOf = (repo: Repo) => repo.protect ?? [];
<p v-if="catalogError || error" class="mb-4 text-sm text-danger" role="alert">{{ catalogError || error }}</p>
<template v-if="repos">
<template v-if="draft">
<section
v-for="(repo, i) in repos"
:key="i"
+15 -3
View File
@@ -1,7 +1,9 @@
<script setup lang="ts">
import PageHeader from "@/base/PageHeader.vue";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import HealthStatusCard from "./HealthStatusCard.vue";
import ServicesCard from "./ServicesCard.vue";
import UpdateSettingsCard from "./UpdateSettingsCard.vue";
import VersionsCard from "./VersionsCard.vue";
</script>
@@ -9,8 +11,18 @@ import VersionsCard from "./VersionsCard.vue";
<div>
<PageHeader title="Status" />
<ServicesCard />
<HealthStatusCard />
<VersionsCard class="mt-4" />
<Tabs default-value="services" class="space-y-4">
<TabsList>
<TabsTrigger value="services">Services</TabsTrigger>
<TabsTrigger value="health">Health</TabsTrigger>
<TabsTrigger value="versions">Versions</TabsTrigger>
</TabsList>
<TabsContent value="services"><ServicesCard /></TabsContent>
<TabsContent value="health"><HealthStatusCard /></TabsContent>
<TabsContent value="versions" class="space-y-4">
<VersionsCard />
<UpdateSettingsCard />
</TabsContent>
</Tabs>
</div>
</template>
+43 -22
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import HistoryLink from "@/settings/HistoryLink.vue";
import { computed, onMounted } from "vue";
import { computed, onMounted, ref, toRaw, watch } from "vue";
import { storeToRefs } from "pinia";
import { Plus } from "@lucide/vue";
@@ -47,14 +47,41 @@ const webFetchOn = computed({
},
});
function addServer(transport: string) {
tools.value?.mcp_servers.push({
name: "",
transport,
parallel_tool_calls: false,
headers_configured: false,
});
// A new server is held here, outside the draft, until it is named: opening
// the form is not yet a change to save.
const pending = ref<McpServer | null>(null);
const shown = computed(() => {
const servers = tools.value?.mcp_servers ?? [];
return pending.value ? [...servers, pending.value] : servers;
});
// Keyed by identity, so the pending editor keeps its focus when it joins the draft.
const keys = new WeakMap<object, number>();
let nextKey = 0;
function keyOf(server: McpServer): number {
const raw = toRaw(server);
if (!keys.has(raw)) keys.set(raw, nextKey++);
return keys.get(raw)!;
}
function removeServer(server: McpServer) {
if (pending.value && toRaw(pending.value) === toRaw(server)) {
pending.value = null;
return;
}
const servers = tools.value?.mcp_servers;
const i = servers?.findIndex((s) => toRaw(s) === toRaw(server)) ?? -1;
if (i >= 0) servers!.splice(i, 1);
}
function addServer() {
pending.value = { name: "", transport: "stdio", parallel_tool_calls: false, headers_configured: false };
}
watch(
() => pending.value?.name,
(name) => {
if (!name?.trim() || !pending.value || !tools.value) return;
tools.value.mcp_servers.push(pending.value);
pending.value = null;
},
);
const eyebrow = "mb-1 text-[11px] font-medium tracking-[0.06em] text-fg-subtle uppercase";
</script>
@@ -73,23 +100,17 @@ const eyebrow = "mb-1 text-[11px] font-medium tracking-[0.06em] text-fg-subtle u
<h2 :class="eyebrow">MCP servers</h2>
<div class="grid gap-3 border-t border-border pt-4">
<McpServerEditor
v-for="(_, i) in tools.mcp_servers"
:key="i"
v-model="tools.mcp_servers[i]!"
@remove="tools.mcp_servers.splice(i, 1)"
v-for="server in shown"
:key="keyOf(server)"
:model-value="server"
@remove="removeServer(server)"
/>
<p v-if="!tools.mcp_servers.length" class="text-sm text-fg-muted">
<p v-if="!tools.mcp_servers.length && !pending" class="text-sm text-fg-muted">
No MCP servers.
</p>
<div class="flex flex-wrap gap-2">
<Button variant="outline" size="sm" @click="addServer('stdio')">
<Plus data-icon="inline-start" /> stdio command
</Button>
<Button variant="outline" size="sm" @click="addServer('http')">
<Plus data-icon="inline-start" /> HTTP endpoint
</Button>
<Button variant="outline" size="sm" @click="addServer('sse')">
<Plus data-icon="inline-start" /> SSE endpoint
<div v-if="!pending">
<Button variant="outline" size="sm" @click="addServer">
<Plus data-icon="inline-start" /> Add MCP server
</Button>
</div>
</div>
+51
View File
@@ -0,0 +1,51 @@
<script setup lang="ts">
import { computed, onMounted } from "vue";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { SettingRow } from "@/components/ui/setting-row";
import { useControlPlaneStore } from "@/stores/control-plane";
const KIND = "update-settings";
type UpdateSettings = { channel: string; pin: string };
const store = useControlPlaneStore();
onMounted(store.load);
const draft = computed(() => store.drafts[KIND]?.value as UpdateSettings | undefined);
const error = computed(() => store.stateFor(KIND).error);
const channels = [
{ value: "stable", label: "Stable" },
{ value: "next", label: "Prereleases" },
{ value: "exact-pin", label: "Pinned" },
];
const channel = computed({
get: () => draft.value?.channel || "stable",
set: (value: string) => {
if (draft.value) draft.value.channel = value;
},
});
</script>
<template>
<Card v-if="draft">
<CardHeader>
<CardTitle>Updates</CardTitle>
</CardHeader>
<CardContent>
<p v-if="error" class="mb-2 text-sm text-danger" role="alert">{{ error }}</p>
<SettingRow label="Release channel">
<div class="flex justify-end">
<SegmentedControl v-model="channel" label="Release channel" :options="channels" />
</div>
</SettingRow>
<SettingRow v-if="channel === 'exact-pin'" label="Version" for="update-pin">
<div class="flex justify-end">
<Input id="update-pin" v-model="draft.pin" class="max-w-40 font-mono" placeholder="1.48.0" />
</div>
</SettingRow>
</CardContent>
</Card>
</template>
+9 -27
View File
@@ -35,20 +35,9 @@ interface ComponentVersion {
status: "ok" | "update_available" | "drift" | "unknown";
}
interface ComponentSnapshot {
id?: string;
label?: string;
installed?: string;
available?: string;
}
interface UpdateSnapshot {
components?: ComponentSnapshot[];
deferred?: boolean;
}
const components = ref<ComponentVersion[]>([]);
const snapshot = ref<UpdateSnapshot | null>(null);
const snapshot = ref<unknown>(null);
const available = ref<unknown[]>([]);
const canInstall = ref(false);
const notConfigured = ref(false);
const loading = ref(true);
@@ -86,7 +75,7 @@ async function load(): Promise<void> {
const [report, update] = await Promise.all([
api.version<{ components: ComponentVersion[] }>(),
api
.updateSnapshot<{ snapshot: UpdateSnapshot; can_install: boolean }>()
.updateSnapshot<{ snapshot: unknown; available: unknown[] | null; can_install: boolean }>()
.catch((err) => {
if (err instanceof ApiError && err.status === 501) {
notConfigured.value = true;
@@ -98,6 +87,7 @@ async function load(): Promise<void> {
components.value = report.components;
if (update) {
snapshot.value = update.snapshot;
available.value = update.available ?? [];
canInstall.value = update.can_install;
}
} catch (err) {
@@ -107,18 +97,10 @@ async function load(): Promise<void> {
}
}
// The snapshot the install endpoint demands is the one the operator saw —
// The snapshot the install endpoint demands is the one the operator saw --
// the endpoint re-checks freshness and answers 409 when releases moved.
function installableSnapshot(): UpdateSnapshot | null {
if (!snapshot.value) return null;
if (
snapshot.value.components?.some(
(c) => c.available && c.available !== c.installed,
)
) {
return snapshot.value;
}
return null;
function installableSnapshot(): unknown {
return snapshot.value && available.value.length ? snapshot.value : null;
}
async function install(): Promise<void> {
@@ -169,7 +151,7 @@ onMounted(load);
<TableHead>Component</TableHead>
<TableHead>Running</TableHead>
<TableHead>Available</TableHead>
<TableHead>Status</TableHead>
<TableHead class="text-right">Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
@@ -183,7 +165,7 @@ onMounted(load);
<TableCell class="font-mono text-fg-muted">{{
component.latest_available || "—"
}}</TableCell>
<TableCell>
<TableCell class="text-right">
<Badge :variant="statusKind[component.status]">{{
statusLabel[component.status]
}}</Badge>
+3 -1
View File
@@ -58,7 +58,9 @@ export function grants(authority: Authority): string[] {
["tool", authority.tools],
["env", authority.env],
];
return labelled.flatMap(([label, values]) => values.map((value) => `${label}: ${value}`));
const lines = labelled.flatMap(([label, values]) => values.map((value) => `${label}: ${value}`));
// A package that declares no egress hosts runs on the host's network.
return authority.egress_hosts.length ? lines : ["network: unrestricted", ...lines];
}
/** What an extension needs from the operator next, in the order it happens. */
+3 -3
View File
@@ -20,7 +20,6 @@ import {
export const useLiveUpdatesStore = defineStore("live-updates", () => {
const streamState = ref<StreamState | "connecting">("connecting");
const connectionRevision = ref(0);
const authenticationRequired = ref(false);
const activity = ref<LiveEvent[]>([]);
const revisions = reactive<Record<LiveResource, number>>({
tasks: 0,
@@ -74,8 +73,10 @@ export const useLiveUpdatesStore = defineStore("live-updates", () => {
function initialize(): void {
if (unsubscribe) return;
// An expired session reloads the document: the server answers a page
// request without a session by sending the browser to sign in.
setAuthenticationStateHandler((required) => {
authenticationRequired.value = required;
if (required) window.location.reload();
});
connect();
}
@@ -96,7 +97,6 @@ export const useLiveUpdatesStore = defineStore("live-updates", () => {
return {
activity,
authenticationRequired,
connectionRevision,
revisions,
streamKind,
-78
View File
@@ -1,78 +0,0 @@
import assert from "node:assert/strict";
import test from "node:test";
const { createSessionRetry } = await import("../src/lib/session-retry.ts");
test("session retry awaits every load before settling", async () => {
const order: string[] = [];
let release: (() => void) | undefined;
const retry = createSessionRetry([
() => {
order.push("first");
},
() =>
new Promise<void>((resolve) => {
release = () => {
order.push("second");
resolve();
};
}),
]);
const done = retry();
await Promise.resolve();
assert.deepEqual(
order,
["first"],
"the retry settled before the second read finished",
);
release?.();
await done;
assert.deepEqual(order, ["first", "second"]);
});
test("session retry ignores a second call while one is running", async () => {
let calls = 0;
let release: (() => void) | undefined;
const retry = createSessionRetry([
() =>
new Promise<void>((resolve) => {
calls += 1;
release = resolve;
}),
]);
const first = retry();
const second = retry();
release?.();
await Promise.all([first, second]);
assert.equal(calls, 1, "a double click re-ran the reads");
});
test("session retry runs again after a failure", async () => {
let calls = 0;
const retry = createSessionRetry([
() => {
calls += 1;
if (calls === 1) throw new Error("daemon unavailable");
},
]);
await assert.rejects(retry(), /daemon unavailable/);
await retry();
assert.equal(calls, 2, "a failed retry left the guard latched");
});
test("session retry runs again after it settles", async () => {
let calls = 0;
const retry = createSessionRetry([
() => {
calls += 1;
},
]);
await retry();
await retry();
assert.equal(calls, 2);
});