Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6abfe32540 | ||
|
|
1f9807a99c
|
||
|
|
b2edf1fa8b
|
||
|
|
bb897e76b8 | ||
|
|
07062352b4 | ||
|
|
856c15858b
|
||
|
|
69a46249cc
|
||
|
|
6f10ecc04f
|
||
|
|
d6ca6a72a5
|
||
|
|
243832fee6
|
||
|
|
e8c2c844a8
|
||
|
|
6220387ed6
|
||
|
|
efd3eb2854
|
||
|
|
c78063eba0 | ||
|
|
0e931485a0
|
||
|
|
1bf536d4ab
|
||
|
|
2181b5fd08
|
||
|
|
a4a7c96da6
|
||
|
|
a7f6e517ad
|
||
|
|
812d9004a7
|
||
|
|
ebc6dd67e6
|
No files matched your search
@@ -0,0 +1,53 @@
|
||||
# Every 15 minutes, checks how the newest release on the `next` channel is
|
||||
# running on the canary host. If a hard check fails, the canary goes back to
|
||||
# the stable release straight away. If the release stays healthy for 24 hours,
|
||||
# it's promoted to stable. A rollback fails the run, so it shows up red.
|
||||
name: canary
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "*/15 * * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: canary
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
judge:
|
||||
if: vars.CANARY_URL != ''
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
# Full history with tags: a rollback compares the migrations between
|
||||
# the stable and failed release tags.
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: main
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
# The self-hosted runner keeps the Go caches on disk between jobs, and
|
||||
# archiving them for the Actions cache takes minutes.
|
||||
cache: false
|
||||
|
||||
- name: Build archied
|
||||
# The check never serves the dashboard, so the build leaves it out.
|
||||
run: go build -tags no_ui -o "$RUNNER_TEMP/archied" ./cmd/archied
|
||||
|
||||
# Promotion retags stable and the images' latest in the registry.
|
||||
- name: Log in to the Gitea registry
|
||||
run: echo "${{ secrets.DEPLOY_TOKEN }}" | docker login git.catlow.cloud -u "${{ github.actor }}" --password-stdin
|
||||
|
||||
- name: Judge the canary
|
||||
env:
|
||||
ARCHIE_CANARY_TOKEN: ${{ secrets.CANARY_TOKEN }}
|
||||
run: |
|
||||
"$RUNNER_TEMP/archied" release canary check -dashboard "${{ vars.CANARY_URL }}" \
|
||||
-latest git.catlow.cloud/sam/archied,git.catlow.cloud/sam/archie-agent
|
||||
@@ -59,6 +59,9 @@ jobs:
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
# The self-hosted runner keeps the Go caches on disk between jobs, and
|
||||
# archiving them for the Actions cache takes minutes.
|
||||
cache: false
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
@@ -96,13 +99,8 @@ jobs:
|
||||
- name: Pull test container images
|
||||
run: docker pull alpine:3
|
||||
|
||||
# One definition of the gate, in the Taskfile. This step used to inline
|
||||
# its own list, which drifted weaker than `task check`: it ran no
|
||||
# db:check, news:check or ui:check, so a release could ship stale
|
||||
# generated SQL, a stale ui/dist, or release notes that disagree with
|
||||
# CHANGELOG.md. It also ran the dashboard suite here rather than in the
|
||||
# gate, where test:ui runs it with the type check. TEST_FLAGS is the one
|
||||
# difference -- the release runs the whole suite, uncached and including
|
||||
# One definition of the gate, in the Taskfile. TEST_FLAGS is the one
|
||||
# difference: the release runs the whole suite, uncached and including
|
||||
# the Docker-backed tests -short skips. The diff after it asserts
|
||||
# `task fmt` changed nothing.
|
||||
- name: Quality gate
|
||||
@@ -134,12 +132,11 @@ jobs:
|
||||
if [ $fail -ne 0 ]; then
|
||||
echo
|
||||
echo "A release tag points at this commit but its changelog does not"
|
||||
echo "describe that version. Run: task release:prepare VERSION=<ver>"
|
||||
echo "edit the generated notes, then: task release VERSION=<ver>"
|
||||
echo "describe that version. Cut releases with the release workflow."
|
||||
exit 1
|
||||
fi
|
||||
if ! git tag --points-at HEAD | grep -qE '^v[0-9]' ; then
|
||||
echo "This commit is not a release, so the images are published as :edge and sha-<sha>; :latest keeps naming the newest release."
|
||||
echo "This commit isn't a release, so the images are published as :edge and sha-<sha>; :latest keeps naming the newest promoted release."
|
||||
fi
|
||||
|
||||
archied-image:
|
||||
@@ -186,19 +183,18 @@ jobs:
|
||||
echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
|
||||
echo "gateway=$GATEWAY_VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "runtime=$RUNTIME_VERSION" >> "$GITHUB_OUTPUT"
|
||||
# :latest names the newest RELEASE, so only a commit that IS one
|
||||
# publishes it. A push to main publishes :edge (mutable, newest main)
|
||||
# and sha-<sha> (immutable) instead. That is what stops a release's
|
||||
# :latest stamping from being overwritten minutes later by the next
|
||||
# ordinary commit, which left a host reporting dev and made the update
|
||||
# path unable to tell current from stale (archie-core-i5nb).
|
||||
# :latest names the newest PROMOTED release, so a release publishes
|
||||
# :v<version> and canary promotion moves :latest to it. A push to
|
||||
# main publishes :edge (mutable, newest main) and sha-<sha>
|
||||
# (immutable), so an ordinary commit never overwrites a release's
|
||||
# stamping.
|
||||
#
|
||||
# `if` blocks rather than `[ -n "$X" ] && echo`: the latter returns
|
||||
# non-zero when the test fails, and these steps run under `set -e`.
|
||||
{
|
||||
echo "archied_tags<<EOF"
|
||||
if [ -n "$RELEASE_TAG" ]; then
|
||||
echo "git.catlow.cloud/sam/archied:latest"
|
||||
echo "git.catlow.cloud/sam/archied:$RELEASE_TAG"
|
||||
fi
|
||||
echo "git.catlow.cloud/sam/archied:edge"
|
||||
echo "git.catlow.cloud/sam/archied:sha-${{ steps.commit.outputs.sha }}"
|
||||
@@ -261,7 +257,7 @@ jobs:
|
||||
file: Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
git.catlow.cloud/sam/archie-agent:latest
|
||||
git.catlow.cloud/sam/archie-agent:${{ steps.versions.outputs.release_tag }}
|
||||
git.catlow.cloud/sam/archie-agent:sha-${{ steps.commit.outputs.sha }}
|
||||
build-args: |
|
||||
RUNTIME_VERSION=${{ steps.versions.outputs.runtime }}
|
||||
@@ -294,6 +290,25 @@ jobs:
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
# The self-hosted runner keeps the Go caches on disk between jobs, and
|
||||
# archiving them for the Actions cache takes minutes.
|
||||
cache: false
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
package_json_file: ui/package.json
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
# archied and archie-ui embed the dashboard.
|
||||
- name: Build the dashboard
|
||||
working-directory: ui
|
||||
run: |
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm run build
|
||||
|
||||
- name: Resolve archied version
|
||||
id: version
|
||||
@@ -354,8 +369,8 @@ jobs:
|
||||
|
||||
# Installs and updates take a release from the signed artifact in the
|
||||
# registry, so this is what publishes it: the statement signed with
|
||||
# RELEASE_SIGNING_KEY and the zip, tagged v<version>, next, and stable
|
||||
# unless it is a prerelease.
|
||||
# RELEASE_SIGNING_KEY and the zip, tagged v<version> and next. stable
|
||||
# moves only when canary.yml promotes it.
|
||||
- name: Log in to the Gitea registry
|
||||
run: echo "${{ secrets.DEPLOY_TOKEN }}" | docker login git.catlow.cloud -u "${{ github.actor }}" --password-stdin
|
||||
|
||||
@@ -403,6 +418,14 @@ jobs:
|
||||
"$api/repos/$repo/releases" >/dev/null
|
||||
echo "published release notes for $tag"
|
||||
|
||||
# The canary host follows the `next` channel. canary.yml then decides
|
||||
# whether this release is promoted to stable or the canary is rolled back.
|
||||
- name: Install the release on the canary
|
||||
if: vars.CANARY_URL != ''
|
||||
env:
|
||||
ARCHIE_CANARY_TOKEN: ${{ secrets.CANARY_TOKEN }}
|
||||
run: ./dist/archied release canary start -dashboard "${{ vars.CANARY_URL }}" -version "${{ steps.version.outputs.version }}"
|
||||
|
||||
# A Gitea package belongs to its owner, not a repository, so the ones this
|
||||
# workflow publishes are linked here. Linking is per package and a no-op
|
||||
# once done, so an already linked package is not an error.
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# Cuts a release from main: [Unreleased] in CHANGELOG.md becomes the version's
|
||||
# section, then the commit and its tag are pushed together. The tag push starts
|
||||
# deploy.yml, which publishes the release to `next` for the canary.
|
||||
name: release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release:
|
||||
description: "major, minor, patch, or an exact version such as 1.57.0"
|
||||
required: true
|
||||
default: minor
|
||||
|
||||
concurrency:
|
||||
group: release
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
cut:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
# DEPLOY_TOKEN rather than the job token: a push made with the job token
|
||||
# doesn't start workflows, and the tag push must start deploy.yml.
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: main
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.DEPLOY_TOKEN }}
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
# The self-hosted runner keeps the Go caches on disk between jobs, and
|
||||
# archiving them for the Actions cache takes minutes.
|
||||
cache: false
|
||||
|
||||
- name: Install Task
|
||||
run: go install github.com/go-task/task/v3/cmd/task@v3.48.0
|
||||
|
||||
- name: Cut the release
|
||||
env:
|
||||
RELEASE: ${{ inputs.release }}
|
||||
run: |
|
||||
git config user.name "Sam Catlow"
|
||||
git config user.email "sam@catlow.tech"
|
||||
task release RELEASE="$RELEASE"
|
||||
|
||||
# Atomic: a commit without its tag would build images stamped dev.
|
||||
- name: Push the release
|
||||
run: git push --atomic origin main "$(git describe --exact-match --match 'v*' HEAD)"
|
||||
+1
-1
@@ -25,7 +25,7 @@ config.production.toml
|
||||
/ui/node_modules/
|
||||
/ui/.vite/
|
||||
/ui/*.tsbuildinfo
|
||||
# ui/dist IS committed: the Go build must not need a Node toolchain.
|
||||
/ui/dist/
|
||||
|
||||
# air live-reload
|
||||
/.air/
|
||||
|
||||
@@ -5,6 +5,18 @@ release's per-component sections are labelled beneath its heading.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.58.0] - 2026-11-01
|
||||
|
||||
### archied
|
||||
|
||||
- Running `install.sh` over an install whose services are already running now restarts them, so they run the new binaries.
|
||||
|
||||
## [1.57.0] - 2026-10-31
|
||||
|
||||
### archied
|
||||
|
||||
- A release reaches `stable` only after it has run on a canary for a day and passed: `archied release publish` now publishes to `next` alone, `archied release canary start|check` installs a release on a canary and judges it from the canary's dashboard, promoting it or rolling the canary back, and `archied release promote` moves `stable` by hand. Promotion refuses a prerelease and a release older than the one `stable` names. The `archied` and `archie-agent` images are published as `:v<version>`, and `:latest` moves only when a release is promoted.
|
||||
|
||||
## [1.56.0] - 2026-10-31
|
||||
|
||||
### archied
|
||||
|
||||
@@ -105,7 +105,7 @@ When sources disagree, the higher one wins:
|
||||
- If a fix fails twice, throw the block away and rewrite it simply.
|
||||
- Comments say why, briefly. No migration history, phase names or issue
|
||||
narration in code.
|
||||
- Generated files (`ui/dist/`, protobuf, sqlc) are regenerated and committed
|
||||
- Generated files (protobuf, sqlc) are regenerated and committed
|
||||
with the change that caused them, never hand-edited.
|
||||
|
||||
## Tests
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
# archied — the archie daemon
|
||||
# Run via docker compose alongside NATS.
|
||||
|
||||
FROM node:24-trixie-slim AS dashboard
|
||||
WORKDIR /src/ui
|
||||
RUN corepack enable
|
||||
COPY ui/package.json ui/pnpm-lock.yaml ui/pnpm-workspace.yaml ./
|
||||
RUN pnpm install --frozen-lockfile
|
||||
COPY ui/ ./
|
||||
RUN pnpm run build
|
||||
|
||||
FROM golang:1.27-trixie AS builder
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
COPY --from=dashboard /src/ui/dist ./ui/dist
|
||||
ARG GATEWAY_VERSION=dev
|
||||
ARG RUNTIME_VERSION=dev
|
||||
RUN CGO_ENABLED=0 go build \
|
||||
|
||||
+113
-113
@@ -1,141 +1,141 @@
|
||||
# Releasing
|
||||
|
||||
One release stream. `CHANGELOG.md` carries every release section, one generated
|
||||
page per version describes it, and one tag names the release. A release is one
|
||||
version covering whatever changed; the components' entries are labelled sections
|
||||
inside it (`### archied`, `### archie-agent`), not separate numbers or separate
|
||||
pages.
|
||||
page per version describes it, and one `v*` tag names the release. One version
|
||||
covers every process in the host bundle (`archied`, `archie-gateway`,
|
||||
`archie-state-store`, `archie-ui`, `archie-messaging`) and the `archie-agent`
|
||||
image; per-component detail is a labelled section inside the version
|
||||
(`### archied`, `### archie-agent`).
|
||||
|
||||
The host bundle ships five processes (`archied`, `archie-gateway`,
|
||||
`archie-state-store`, `archie-ui`, `archie-messaging`), and
|
||||
one version covers all of them. `archie-agent`, the per-task sandboxed runtime,
|
||||
ships as a container image and its changes are the `## [version]` release's
|
||||
`### archie-agent` section.
|
||||
A release is cut by CI, published to `next`, run on the canary for a day, and
|
||||
promoted to `stable` only if the canary's signals pass. Nothing is run locally.
|
||||
|
||||
`tools/release.sh` decides which commits a release carries from the package
|
||||
closure of **every shipped binary**, not from commit-message guessing: a change
|
||||
to a package only the messaging service, state store, playbook runner or UI
|
||||
links still lands in the changelog. Read its header comment for how it
|
||||
partitions commits and enforces `main`-only, clean-tree releases.
|
||||
## Notes are written with the change
|
||||
|
||||
## What justifies a version
|
||||
|
||||
`task release:preview VERSION=X.Y.Z` shows exactly what would land, before
|
||||
anything is written. A commit set that justifies no version produces no version:
|
||||
`release.sh` exits **3** with "nothing to release" rather than inventing one, so
|
||||
a pipeline can finish green without tagging.
|
||||
|
||||
Most sessions touch the gateway side (daemon, gateway, web UI, chat, messaging)
|
||||
and leave the agent runtime alone. That is no longer a per-component `skip`
|
||||
decision — one version covers the release — but a runtime code change being
|
||||
merged to `main` is still not the same as it being in production: the
|
||||
`archie-agent` image is rebuilt by the release, and a host that runs the agent
|
||||
must pull the new image (`docker compose pull agent`) to get it.
|
||||
|
||||
## What the notes are for
|
||||
A commit that changes what a reader experiences adds its bullet under
|
||||
`## [Unreleased]` in `CHANGELOG.md`, in the same commit. The release takes that
|
||||
section as it stands, so write the bullet as the release note, not as a commit
|
||||
subject.
|
||||
|
||||
**Release notes describe the reader's experience of what shipped.** The test is
|
||||
the reader, not whether a sentence is negative:
|
||||
|
||||
- A capability that **never existed** leaves no expectation to correct, so a
|
||||
note about it reads as a feature to someone who never had the thing — out.
|
||||
- **The implementation's journey** — what was rebuilt, what a guard finally
|
||||
covers, what a browser API refuses to surface — is not the reader's experience
|
||||
either — out.
|
||||
- A capability that **shipped but is not yet wired** _is_ the reader's
|
||||
note about it reads as a feature to someone who never had the thing: out.
|
||||
- **The implementation's journey** (what was rebuilt, what a guard finally
|
||||
covers, what a browser API refuses to surface) isn't the reader's experience
|
||||
either: out.
|
||||
- A capability that **shipped but isn't yet wired** _is_ the reader's
|
||||
experience, so it belongs, worded as a caveat on the capability and paired
|
||||
with the behaviour that compensates for it.
|
||||
|
||||
Design constraints and withheld capabilities are not release news.
|
||||
Do not apply this mechanically: deleting a caveat a reader needs misleads them,
|
||||
which is the failure this rule exists to prevent.
|
||||
Design constraints and withheld capabilities are not release news. Deleting a
|
||||
caveat a reader needs misleads them, which is the failure this rule exists to
|
||||
prevent.
|
||||
|
||||
## Cutting a release
|
||||
|
||||
```bash
|
||||
task release:preview VERSION=1.3.0 # preview what would land
|
||||
task release:prepare VERSION=1.3.0 # write the section into CHANGELOG.md, uncommitted
|
||||
# edit CHANGELOG.md -- generated notes are a starting point, not the release
|
||||
task release VERSION=1.3.0 # commit + annotated tag
|
||||
git push --atomic origin main v1.3.0 # both refs or neither
|
||||
```
|
||||
Dispatch the **release** workflow (`.github/workflows/release.yml`) with
|
||||
`major`, `minor`, `patch` or an exact version. It runs `task release` on `main`:
|
||||
|
||||
Pushing the tag is the release. The deploy workflow builds the images and the
|
||||
zip, then `archied release publish` signs the release with the
|
||||
`RELEASE_SIGNING_KEY` Actions secret and pushes it to
|
||||
`git.catlow.cloud/sam/archie` as `v1.3.0`, `next`, and `stable` unless the
|
||||
version is a prerelease. `install.sh` and the updater install only what that
|
||||
key signed.
|
||||
1. refuses a dirty tree, an existing tag, or an `[Unreleased]` with no entries;
|
||||
2. turns `[Unreleased]` into `## [x.y.z] - date` under a new empty
|
||||
`[Unreleased]`, and runs `task news`;
|
||||
3. commits `chore(release): vx.y.z` and tags `vx.y.z`;
|
||||
|
||||
`release:prepare` emits bare commit subjects; they are a starting point. Rewrite
|
||||
them to say what a reader gets, per "What the notes are for" above.
|
||||
then pushes `main` and the tag atomically with `DEPLOY_TOKEN`. A push made with
|
||||
the job token wouldn't start other workflows, so the user token is what lets
|
||||
the tag start the deploy.
|
||||
|
||||
Pushing is a separate, explicit step — never push without confirming first (see
|
||||
the repo's general "check before doing anything hard to reverse" rule). The
|
||||
deploy workflow reads tags pointing at `HEAD`; pushing the commit without its
|
||||
tag gets images stamped `dev`, which is why the push names the tag and is
|
||||
`--atomic`.
|
||||
|
||||
### After a release, `main` and the working branch have diverged
|
||||
|
||||
The release commit lands on `main` — `tools/release.sh` refuses to run anywhere
|
||||
else — while the working branch keeps advancing. So after every release, `main`
|
||||
is ahead by exactly that commit and the branch is ahead by however far it has
|
||||
moved: **neither tip is an ancestor of the other**, and `--ff-only` fails in
|
||||
both directions. That refusal reads as "the tree is not ready" when in fact the
|
||||
tree is fine.
|
||||
|
||||
Merge the release commit into the branch first, so any conflict is resolved on
|
||||
the branch, where it is reversible and nobody is reading the tip:
|
||||
|
||||
```bash
|
||||
git merge main # on the branch
|
||||
git merge --ff-only <branch> # then, in whichever worktree holds main
|
||||
```
|
||||
|
||||
Confirm which worktree holds `main` with `git worktree list` before the
|
||||
`--ff-only`. A detached worktree sitting at the same commit will accept it and
|
||||
move nothing, which looks like success.
|
||||
After a release, pull `main` before committing on it again: CI has added the
|
||||
release commit.
|
||||
|
||||
## What a release publishes
|
||||
|
||||
Tagging one version produces, from a single `deploy` run:
|
||||
The tag push runs `deploy.yml`:
|
||||
|
||||
- **Container images** — `git.catlow.cloud/sam/archied:latest` and, on a
|
||||
release tag, `git.catlow.cloud/sam/archie-agent:latest`. The runtime image is
|
||||
rebuilt by the release, so runtime commits merged to `main` do not reach a
|
||||
running sandbox until the host pulls the new image. The hand-run
|
||||
`tools/publish.sh` publishes the same two images to
|
||||
`git.catlow.cloud/sam` instead, which is the registry the binary's default
|
||||
`[containers].image` names.
|
||||
- **`:latest` names the newest release, not the newest commit.** A push to
|
||||
`main` that is not a release publishes `archied:edge` (mutable, tracking
|
||||
`main`) and `archied:sha-<commit>` (immutable) instead, so a release's
|
||||
`:latest` stamping is not overwritten minutes later by the next ordinary
|
||||
commit. A host that runs releases follows `:latest`; a host that tracks `main`
|
||||
follows `:edge`.
|
||||
- **A GitHub Release with a distribution zip** — `dist-zip` builds every process
|
||||
the reference deployment runs (`archied`, `archie-gateway`,
|
||||
`archie-state-store`, `archie-ui`, `archie-messaging`) for
|
||||
linux/amd64, packs them with `deployments/INSTRUCTIONS.md` and `CHANGELOG.md`,
|
||||
and attaches the zip to the Release. The Release body is that version's
|
||||
`## [version]` section of `CHANGELOG.md`.
|
||||
- **Gate.** `task check TEST_FLAGS=-count=1` (uncached, including the
|
||||
Docker-backed tests `-short` skips) and `govulncheck`, then a check that the
|
||||
tag has a `[version]` section in `CHANGELOG.md`.
|
||||
- **Images.** `archied:v<version>` and `archie-agent:v<version>` on a release
|
||||
tag; `archied:edge` and `archied:sha-<commit>` on any other push to `main`.
|
||||
`:latest` moves only on promotion, so it names the newest promoted release.
|
||||
- **The signed release.** `archied release publish` signs a statement
|
||||
(version, issued_at, zip digest, agent image by digest) with
|
||||
`RELEASE_SIGNING_KEY` and pushes it with the distribution zip to
|
||||
`git.catlow.cloud/sam/archie` as `v<version>` and `next`. It never moves
|
||||
`stable`.
|
||||
- **The release-notes page** on Gitea, from that version's `CHANGELOG.md`
|
||||
section, which the statement links to.
|
||||
- **The canary install**: `archied release canary start` points the canary at
|
||||
`next` and installs the release through its dashboard.
|
||||
|
||||
The zip is also uploaded as an Actions artifact, but that is a backup copy:
|
||||
artifacts expire after 90 days and need an Actions login to download. The
|
||||
Release asset is the durable, operator-reachable one.
|
||||
GitHub-style Actions run the workflow from the tagged commit, so a fix to
|
||||
`deploy.yml` reaches a release only if it is an ancestor of the tag. Re-cut the
|
||||
release rather than committing the fix on top of a tagged one.
|
||||
|
||||
## Gate
|
||||
## The canary
|
||||
|
||||
CI (`deploy.yml`) runs `task check TEST_FLAGS=-count=1` before building images,
|
||||
then verifies any release tag at `HEAD` has a matching `[version]` section in
|
||||
`CHANGELOG.md`. The gate has one definition, in the Taskfile: the release runs
|
||||
it with the uncached suite, including the Docker-backed tests `-short` skips.
|
||||
A tag with no changelog entry is a hard failure. No tags at `HEAD` is a
|
||||
warning, not a failure -- images get stamped `dev`.
|
||||
The canary is the production host, following `next`. Every quarter hour
|
||||
`canary.yml` runs `archied release canary check`, which reads the canary
|
||||
through its dashboard API and judges the release on `next`:
|
||||
|
||||
One consequence worth knowing when a release commit needs amending: GitHub
|
||||
Actions runs the workflow **from the commit that triggered it**, so a fix to
|
||||
`deploy.yml` only takes effect for a release if it is an ancestor of the tagged
|
||||
commit. Delete and re-cut the tag (`git tag -d`, `task release`) rather than
|
||||
committing the fix on top of an already-tagged release.
|
||||
| Signal | Source | Fails when |
|
||||
| --- | --- | --- |
|
||||
| Install outcome | `GET /api/chat/update` | the canary doesn't run the release (the watchdog rolled it back) |
|
||||
| Readiness | `GET /health/detailed` | the rollup isn't `ok` |
|
||||
| Alerts | `GET /api/alerts` | an open `action` alert was first raised after the release was issued |
|
||||
| Error log | `GET /api/logs?level=error` | error lines per day exceed `2 × baseline + 10` |
|
||||
| Task outcomes | `GET /api/tasks` | the share of finished tasks that parked or died rose more than 10 points |
|
||||
|
||||
- **Control.** The canary's own 24 hours before the release was issued. With
|
||||
one production host there's no simultaneous control.
|
||||
- **Window.** 24 hours from issue, one cycle of schedules and traffic. The
|
||||
first 30 minutes are for the install and restart.
|
||||
- **Hard signals** (install, readiness, alerts) roll back at any check after
|
||||
that. **Relative signals** (errors, tasks) are judged at the end of the
|
||||
window.
|
||||
- **Too little data skips a signal** rather than failing it: fewer than 5
|
||||
finished tasks in the window, or an error log that reaches back less than an
|
||||
hour into the baseline. A log read that stops short of a window is scaled to
|
||||
a full day from what it covers.
|
||||
|
||||
### Promote
|
||||
|
||||
A release that passes the window is promoted: `stable` is retagged to the
|
||||
`v<version>` manifest. The signature covers the statement, not the tag, so the
|
||||
retag needs no signing key. The `archied` and `archie-agent` images' `:latest`
|
||||
move to their `:v<version>` first, and the agent image must be the digest the
|
||||
statement pins. Promotion refuses a prerelease and a release issued
|
||||
before the one `stable` names, the same replay rule hosts enforce. The decision
|
||||
and its reasons are in the `canary` run log.
|
||||
|
||||
### Roll back
|
||||
|
||||
`stable` stays put, and the run turns red. The canary is pinned to the `stable`
|
||||
version through its update settings and reinstalled through its dashboard.
|
||||
|
||||
A release whose migrations differ from `stable`'s can't go back without
|
||||
restoring the pre-update database snapshot, which loses every write since. The
|
||||
canary is held on the failed release instead (pinned to it) and the fix goes
|
||||
forward in the next release. The next release's deploy points the canary back at
|
||||
`next`.
|
||||
|
||||
A pinned canary isn't judged, so a rollback is decided once.
|
||||
|
||||
### Configuration
|
||||
|
||||
| Name | Kind | Holds |
|
||||
| --- | --- | --- |
|
||||
| `CANARY_URL` | Actions variable | the canary's dashboard URL; unset disables the canary steps |
|
||||
| `CANARY_TOKEN` | Actions secret | a personal API token on the canary with instance admin |
|
||||
| `DEPLOY_TOKEN` | Actions secret | registry and repository write, for publishing, promoting and the release push |
|
||||
| `RELEASE_SIGNING_KEY` | Actions secret | the release signing seed |
|
||||
|
||||
The runner must reach `CANARY_URL`. Without a canary a release stays on `next`
|
||||
until promoted by hand, under the same refusals:
|
||||
|
||||
```bash
|
||||
archied release promote -version 1.57.0 \
|
||||
-latest git.catlow.cloud/sam/archied,git.catlow.cloud/sam/archie-agent
|
||||
```
|
||||
+34
-30
@@ -100,18 +100,12 @@ tasks:
|
||||
- pnpm install --frozen-lockfile
|
||||
|
||||
ui:
|
||||
desc: Build the dashboard into ui/dist (committed; the Go build embeds it)
|
||||
desc: Build the dashboard into ui/dist, which the Go build embeds
|
||||
dir: ui
|
||||
deps: [ui:deps]
|
||||
cmds:
|
||||
- pnpm run build
|
||||
|
||||
ui:check:
|
||||
desc: Rebuild the dashboard into a temporary directory and reject a stale ui/dist
|
||||
deps: [ui:deps]
|
||||
cmds:
|
||||
- bash tools/uidist.sh check
|
||||
|
||||
test:ui:
|
||||
desc: Test and type-check the dashboard
|
||||
dir: ui
|
||||
@@ -229,6 +223,7 @@ tasks:
|
||||
|
||||
build:
|
||||
desc: Build archie services and agent binaries
|
||||
deps: [ui]
|
||||
vars:
|
||||
GATEWAY_VERSION: '{{.GATEWAY_VERSION | default .VERSION}}'
|
||||
RUNTIME_VERSION: '{{.RUNTIME_VERSION | default .VERSION}}'
|
||||
@@ -278,13 +273,14 @@ tasks:
|
||||
desc: Run the full quality gate
|
||||
# Finish mutations before starting parallel checks.
|
||||
cmds:
|
||||
# Node packages land under ui/, which `go test ./...` walks: installing
|
||||
# them while the parallel checks scan the tree makes a lockfile update
|
||||
# delete Go sources mid-walk. Install first, then fan out. Every Go step
|
||||
# embeds ui/dist, so the dashboard is built before any of them.
|
||||
- task: ui
|
||||
- task: fmt
|
||||
- task: proto:check
|
||||
- task: db:check
|
||||
# Node packages land under ui/, which `go test ./...` walks: installing
|
||||
# them while the parallel checks scan the tree makes a lockfile update
|
||||
# delete Go sources mid-walk. Install first, then fan out.
|
||||
- task: ui:deps
|
||||
- task: check:readonly
|
||||
|
||||
check:readonly:
|
||||
@@ -297,25 +293,33 @@ tasks:
|
||||
- task: build
|
||||
- task: test
|
||||
- task: test:ui
|
||||
- task: ui:check
|
||||
|
||||
release:preview:
|
||||
desc: "Show the release notes that would be generated (VERSION=1.2.0)"
|
||||
cmds:
|
||||
- tools/release.sh --version {{.VERSION}} --dry-run
|
||||
requires:
|
||||
vars: [VERSION]
|
||||
|
||||
release:prepare:
|
||||
desc: Prepare changelog notes for editing (VERSION=1.2.0)
|
||||
cmds:
|
||||
- tools/release.sh --version {{.VERSION}} --prepare
|
||||
requires:
|
||||
vars: [VERSION]
|
||||
|
||||
release:
|
||||
desc: Commit and tag the prepared release (VERSION=1.2.0)
|
||||
cmds:
|
||||
- tools/release.sh --version {{.VERSION}} --tag
|
||||
desc: "Turn [Unreleased] into a release, then commit and tag it (RELEASE=major|minor|patch|1.2.3)"
|
||||
requires:
|
||||
vars: [VERSION]
|
||||
vars: [RELEASE]
|
||||
cmds:
|
||||
- |
|
||||
set -euo pipefail
|
||||
die() { echo "release: $*" >&2; exit 1; }
|
||||
[ "$(git rev-parse --abbrev-ref HEAD)" = main ] || die "releases are cut from main"
|
||||
[ -z "$(git status --porcelain)" ] || die "the working tree is dirty"
|
||||
last="$(git tag --list 'v*' --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1 || true)"
|
||||
IFS=. read -r major minor patch <<<"${last#v}"
|
||||
case "{{.RELEASE}}" in
|
||||
major) version="$((major + 1)).0.0" ;;
|
||||
minor) version="$major.$((minor + 1)).0" ;;
|
||||
patch) version="$major.$minor.$((patch + 1))" ;;
|
||||
*) version="$(echo "{{.RELEASE}}" | sed 's/^v//')" ;;
|
||||
esac
|
||||
echo "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$' || die "$version is not a version"
|
||||
! git rev-parse -q --verify "refs/tags/v$version" >/dev/null || die "v$version already exists"
|
||||
awk '/^## \[Unreleased\]/ { u = 1; next } u && /^## \[/ { exit } u && /^- / { found = 1 } END { exit !found }' CHANGELOG.md ||
|
||||
die "[Unreleased] in CHANGELOG.md has no entries"
|
||||
awk -v hdr="## [$version] - $(date -u +%F)" '{ print } /^## \[Unreleased\]/ { print ""; print hdr }' CHANGELOG.md >CHANGELOG.md.tmp
|
||||
mv CHANGELOG.md.tmp CHANGELOG.md
|
||||
go -C tools run -mod=readonly ./newsgen --repo-root ..
|
||||
git add CHANGELOG.md docs/news
|
||||
git commit -q -m "chore(release): v$version"
|
||||
git tag -a "v$version" -m "v$version"
|
||||
echo "tagged v$version"
|
||||
@@ -85,6 +85,8 @@
|
||||
"/news/archie/1.54.3/": "/news/1.54.3/",
|
||||
"/news/archie/1.55.0/": "/news/1.55.0/",
|
||||
"/news/archie/1.56.0/": "/news/1.56.0/",
|
||||
"/news/archie/1.57.0/": "/news/1.57.0/",
|
||||
"/news/archie/1.58.0/": "/news/1.58.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/",
|
||||
@@ -186,6 +188,8 @@
|
||||
"/news/archied/1.54.3/": "/news/1.54.3/",
|
||||
"/news/archied/1.55.0/": "/news/1.55.0/",
|
||||
"/news/archied/1.56.0/": "/news/1.56.0/",
|
||||
"/news/archied/1.57.0/": "/news/1.57.0/",
|
||||
"/news/archied/1.58.0/": "/news/1.58.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/",
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"version": "1.58.0",
|
||||
"date": "2026-11-01",
|
||||
"body": "### archied\n\n- Running `install.sh` over an install whose services are already running now restarts them, so they run the new binaries."
|
||||
},
|
||||
{
|
||||
"version": "1.57.0",
|
||||
"date": "2026-10-31",
|
||||
"body": "### archied\n\n- A release reaches `stable` only after it has run on a canary for a day and passed: `archied release publish` now publishes to `next` alone, `archied release canary start|check` installs a release on a canary and judges it from the canary's dashboard, promoting it or rolling the canary back, and `archied release promote` moves `stable` by hand. Promotion refuses a prerelease and a release older than the one `stable` names. The `archied` and `archie-agent` images are published as `:v<version>`, and `:latest` moves only when a release is promoted."
|
||||
},
|
||||
{
|
||||
"version": "1.56.0",
|
||||
"date": "2026-10-31",
|
||||
|
||||
+4
-2
@@ -475,10 +475,12 @@ EOF
|
||||
fi
|
||||
|
||||
# Auto-enable and start the services, the store first so a fresh boot does
|
||||
# not race a dial it depends on.
|
||||
# not race a dial it depends on. Restart rather than start, because a
|
||||
# reinstall over running services would otherwise leave the old binaries
|
||||
# running.
|
||||
if [ "${AUTO_START}" = true ]; then
|
||||
echo "==> Enabling and starting Archie services..."
|
||||
systemctl --user enable --now $INSTANCE_UNITS ||
|
||||
{ systemctl --user enable $INSTANCE_UNITS && systemctl --user restart $INSTANCE_UNITS; } ||
|
||||
echo " Notice: Could not start every service automatically. Check: systemctl --user status ${INSTANCE_UNITS}"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -52,7 +52,7 @@ type HarnessStages struct {
|
||||
Spec agentrun.HarnessSpec
|
||||
}
|
||||
|
||||
func (r HarnessStages) Run(ctx context.Context, workspace string, req agentrun.Request, report agentrun.ToolCallReporter) (agentrun.Result, error) {
|
||||
func (r HarnessStages) Run(ctx context.Context, workspace string, req agentrun.Request, report agentrun.Reporter) (agentrun.Result, error) {
|
||||
spec := r.Spec
|
||||
req.Harness = &spec
|
||||
return r.Runner.Run(ctx, workspace, req, report)
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestHarnessRequiresMCPInitialization(t *testing.T) {
|
||||
if !central {
|
||||
req.CaptureTools = []agentrun.CaptureTool{{Name: "capture_result", Parameters: json.RawMessage(`{"type":"object"}`)}}
|
||||
}
|
||||
result, err := NewHarnessRunner(nil).Run(t.Context(), workspace, req, nil)
|
||||
result, err := NewHarnessRunner(nil).Run(t.Context(), workspace, req, agentrun.Reporter{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ func newClaudeCodeHarnessOutput() *claudeCodeHarnessOutput {
|
||||
}
|
||||
}
|
||||
|
||||
func (o *claudeCodeHarnessOutput) Line(line []byte, report agentrun.ToolCallReporter) {
|
||||
func (o *claudeCodeHarnessOutput) Line(line []byte, report agentrun.Reporter) {
|
||||
var event struct {
|
||||
Type string `json:"type"`
|
||||
SessionID string `json:"session_id"`
|
||||
@@ -55,7 +55,7 @@ func (o *claudeCodeHarnessOutput) Line(line []byte, report agentrun.ToolCallRepo
|
||||
}
|
||||
}
|
||||
|
||||
func (o *claudeCodeHarnessOutput) assistant(raw json.RawMessage, _ agentrun.ToolCallReporter) {
|
||||
func (o *claudeCodeHarnessOutput) assistant(raw json.RawMessage, _ agentrun.Reporter) {
|
||||
var message struct {
|
||||
ID string `json:"id"`
|
||||
Usage json.RawMessage `json:"usage"`
|
||||
@@ -79,7 +79,7 @@ func (o *claudeCodeHarnessOutput) assistant(raw json.RawMessage, _ agentrun.Tool
|
||||
}
|
||||
}
|
||||
|
||||
func (o *claudeCodeHarnessOutput) user(raw json.RawMessage, report agentrun.ToolCallReporter) {
|
||||
func (o *claudeCodeHarnessOutput) user(raw json.RawMessage, report agentrun.Reporter) {
|
||||
var message struct {
|
||||
Content []struct {
|
||||
Type string `json:"type"`
|
||||
@@ -100,12 +100,10 @@ func (o *claudeCodeHarnessOutput) user(raw json.RawMessage, report agentrun.Tool
|
||||
continue
|
||||
}
|
||||
delete(o.pending, block.ToolUseID)
|
||||
if report != nil {
|
||||
report(agentrun.ToolCallReport{
|
||||
Tool: tool, Detail: ClipToolCallDetail(claudeResultContent(block.Content)),
|
||||
Failed: block.IsError,
|
||||
})
|
||||
}
|
||||
report.ReportToolCall(agentrun.ToolCallReport{
|
||||
Tool: tool, Detail: ClipToolCallDetail(claudeResultContent(block.Content)),
|
||||
Failed: block.IsError,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ type codexHarnessOutput struct {
|
||||
usage agentrun.Usage
|
||||
}
|
||||
|
||||
func (o *codexHarnessOutput) Line(line []byte, report agentrun.ToolCallReporter) {
|
||||
func (o *codexHarnessOutput) Line(line []byte, report agentrun.Reporter) {
|
||||
var event struct {
|
||||
Type string `json:"type"`
|
||||
ThreadID string `json:"thread_id"`
|
||||
@@ -43,8 +43,8 @@ func (o *codexHarnessOutput) Line(line []byte, report agentrun.ToolCallReporter)
|
||||
})
|
||||
}
|
||||
case "item.completed":
|
||||
if call, ok := event.Item.report(); ok && report != nil {
|
||||
report(call)
|
||||
if call, ok := event.Item.report(); ok {
|
||||
report.ReportToolCall(call)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ func newCopilotHarnessOutput() *copilotHarnessOutput {
|
||||
return &copilotHarnessOutput{pending: make(map[string]string)}
|
||||
}
|
||||
|
||||
func (o *copilotHarnessOutput) Line(line []byte, report agentrun.ToolCallReporter) {
|
||||
func (o *copilotHarnessOutput) Line(line []byte, report agentrun.Reporter) {
|
||||
var event struct {
|
||||
Type string `json:"type"`
|
||||
SessionID string `json:"sessionId"`
|
||||
@@ -52,9 +52,7 @@ func (o *copilotHarnessOutput) Line(line []byte, report agentrun.ToolCallReporte
|
||||
return
|
||||
}
|
||||
delete(o.pending, event.Data.ToolCallID)
|
||||
if report != nil {
|
||||
report(agentrun.ToolCallReport{Tool: tool, Detail: ClipToolCallDetail(event.Data.Result.Content), Failed: !event.Data.Success})
|
||||
}
|
||||
report.ReportToolCall(agentrun.ToolCallReport{Tool: tool, Detail: ClipToolCallDetail(event.Data.Result.Content), Failed: !event.Data.Success})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ type piHarnessOutput struct {
|
||||
usage agentrun.Usage
|
||||
}
|
||||
|
||||
func (o *piHarnessOutput) Line(line []byte, report agentrun.ToolCallReporter) {
|
||||
func (o *piHarnessOutput) Line(line []byte, report agentrun.Reporter) {
|
||||
var event struct {
|
||||
Type string `json:"type"`
|
||||
ID string `json:"id"`
|
||||
@@ -49,7 +49,7 @@ func (o *piHarnessOutput) Line(line []byte, report agentrun.ToolCallReporter) {
|
||||
o.usage = addUsage(o.usage, usageFromFields(u.Input, u.Output, u.CacheRead, u.CacheWrite))
|
||||
}
|
||||
case "tool_execution_end":
|
||||
if event.ToolName == "" || report == nil {
|
||||
if event.ToolName == "" {
|
||||
return
|
||||
}
|
||||
texts := make([]string, 0, len(event.Result.Content))
|
||||
@@ -58,7 +58,7 @@ func (o *piHarnessOutput) Line(line []byte, report agentrun.ToolCallReporter) {
|
||||
texts = append(texts, block.Text)
|
||||
}
|
||||
}
|
||||
report(agentrun.ToolCallReport{Tool: event.ToolName, Detail: ClipToolCallDetail(strings.Join(texts, "\n")), Failed: event.IsError})
|
||||
report.ReportToolCall(agentrun.ToolCallReport{Tool: event.ToolName, Detail: ClipToolCallDetail(strings.Join(texts, "\n")), Failed: event.IsError})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ const (
|
||||
// knows its CLI's stream format; it reports tool calls as they complete and
|
||||
// the session to resume.
|
||||
type HarnessOutput interface {
|
||||
Line(line []byte, report agentrun.ToolCallReporter)
|
||||
Line(line []byte, report agentrun.Reporter)
|
||||
SessionID() string
|
||||
Usage() agentrun.Usage
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func NewHarnessRunner(newOutput func() HarnessOutput) *HarnessRunner {
|
||||
return &HarnessRunner{newOutput: newOutput}
|
||||
}
|
||||
|
||||
func (r *HarnessRunner) Run(ctx context.Context, workspace string, req agentrun.Request, report agentrun.ToolCallReporter) (agentrun.Result, error) {
|
||||
func (r *HarnessRunner) Run(ctx context.Context, workspace string, req agentrun.Request, report agentrun.Reporter) (agentrun.Result, error) {
|
||||
if err := validateHarness(req); err != nil {
|
||||
return agentrun.Result{}, err
|
||||
}
|
||||
@@ -95,7 +95,7 @@ func (r *HarnessRunner) Run(ctx context.Context, workspace string, req agentrun.
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (r *HarnessRunner) run(ctx context.Context, workspace string, req agentrun.Request, mcpConfig string, report agentrun.ToolCallReporter) (agentrun.Result, error) {
|
||||
func (r *HarnessRunner) run(ctx context.Context, workspace string, req agentrun.Request, mcpConfig string, report agentrun.Reporter) (agentrun.Result, error) {
|
||||
res := agentrun.Result{Version: agentrun.ProtocolVersion, TaskID: req.TaskID, Attempt: req.Attempt, Stage: req.Stage}
|
||||
before, err := snapshotRepo(workspace)
|
||||
if err != nil {
|
||||
@@ -244,7 +244,7 @@ func resumeVerb(h *agentrun.HarnessSpec, sessionID string) []string {
|
||||
// invoke runs one harness invocation in its own process group, feeding
|
||||
// stdout to out line by line. Cancelling ctx kills the whole group, so a
|
||||
// CLI's children cannot outlive the step.
|
||||
func invoke(ctx context.Context, workspace string, h *agentrun.HarnessSpec, argv []string, out HarnessOutput, report agentrun.ToolCallReporter) error {
|
||||
func invoke(ctx context.Context, workspace string, h *agentrun.HarnessSpec, argv []string, out HarnessOutput, report agentrun.Reporter) error {
|
||||
cmd := exec.CommandContext(ctx, argv[0], argv[1:]...)
|
||||
cmd.Dir = workspace
|
||||
cmd.WaitDelay = killGrace
|
||||
@@ -467,9 +467,9 @@ func policyViolation(before, after repoState, changes []string, req agentrun.Req
|
||||
|
||||
type silentOutput struct{}
|
||||
|
||||
func (silentOutput) Line([]byte, agentrun.ToolCallReporter) {}
|
||||
func (silentOutput) SessionID() string { return "" }
|
||||
func (silentOutput) Usage() agentrun.Usage { return agentrun.Usage{} }
|
||||
func (silentOutput) Line([]byte, agentrun.Reporter) {}
|
||||
func (silentOutput) SessionID() string { return "" }
|
||||
func (silentOutput) Usage() agentrun.Usage { return agentrun.Usage{} }
|
||||
|
||||
// tailBuffer keeps the last stderrTailBytes written to it.
|
||||
type tailBuffer struct{ buf bytes.Buffer }
|
||||
|
||||
@@ -18,7 +18,7 @@ func TestHarnessLiveOutput(t *testing.T) {
|
||||
if os.Geteuid() == 0 {
|
||||
user = "65534"
|
||||
}
|
||||
err := invoke(t.Context(), "/tmp", &agentrun.HarnessSpec{User: user}, []string{"sh", "-c", `printf '%s\n' '{"type":"thread.started","thread_id":"live-thread"}'; printf '%s\n' 'live diagnostic' >&2`}, adapter, nil)
|
||||
err := invoke(t.Context(), "/tmp", &agentrun.HarnessSpec{User: user}, []string{"sh", "-c", `printf '%s\n' '{"type":"thread.started","thread_id":"live-thread"}'; printf '%s\n' 'live diagnostic' >&2`}, adapter, agentrun.Reporter{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func NewLoopRunner(
|
||||
// work on the chat workspace and bypass ReadOnly and ProtectPaths.
|
||||
const workspaceToolset = "workspace"
|
||||
|
||||
func (r *LoopRunner) Run(ctx context.Context, workspace string, req agentrun.Request, report agentrun.ToolCallReporter) (agentrun.Result, error) {
|
||||
func (r *LoopRunner) Run(ctx context.Context, workspace string, req agentrun.Request, report agentrun.Reporter) (agentrun.Result, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return agentrun.Result{}, err
|
||||
}
|
||||
@@ -67,12 +67,18 @@ func (r *LoopRunner) Run(ctx context.Context, workspace string, req agentrun.Req
|
||||
notes := &memoryNotes{initial: req.Notes}
|
||||
captures := make(map[string][]json.RawMessage)
|
||||
toolOpts := r.Limits.Options(workspaceToolset)
|
||||
toolOpts.OnToolCall = report
|
||||
toolOpts.OnToolCall = report.ToolCall
|
||||
centralTools, err := BuildToolSet(r.tools, toolOpts)
|
||||
if err != nil {
|
||||
return agentrun.Result{}, fmt.Errorf("build central tool set: %w", err)
|
||||
}
|
||||
captureTools := captureToolSet(req.CaptureTools, captures)
|
||||
var modelHooks []core.ModelHook
|
||||
var toolHooks []core.ToolHook
|
||||
if report.Transcript != nil {
|
||||
recorder := newTranscript(report.Transcript)
|
||||
modelHooks, toolHooks = []core.ModelHook{recorder}, []core.ToolHook{recorder}
|
||||
}
|
||||
res, err := r.run(ctx, agentloop.Config{
|
||||
Runtime: r.runtime,
|
||||
ModelRef: req.Model,
|
||||
@@ -101,7 +107,9 @@ func (r *LoopRunner) Run(ctx context.Context, workspace string, req agentrun.Req
|
||||
allowedTools(centralTools, r.AllowTools),
|
||||
captureTools,
|
||||
),
|
||||
Logger: r.logger(req),
|
||||
ModelHooks: modelHooks,
|
||||
ToolHooks: toolHooks,
|
||||
Logger: r.logger(req),
|
||||
})
|
||||
result := resultFromRun(req, res, notes.appended, captures)
|
||||
if cause := context.Cause(ctx); cause != nil {
|
||||
|
||||
@@ -74,7 +74,7 @@ type ToolSetOptions struct {
|
||||
// OnToolCall, when non-nil, is notified once per completed tool call.
|
||||
// LoopRunner populates it so a workflow stage can surface tool activity on
|
||||
// the task timeline. Nil means no one is listening.
|
||||
OnToolCall agentrun.ToolCallReporter
|
||||
OnToolCall func(agentrun.ToolCallReport)
|
||||
}
|
||||
|
||||
// reportToolCallCompletion notifies opts.OnToolCall, if set, of one
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
package modelloop
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/samcharles93/ai-sdk/chat"
|
||||
"github.com/samcharles93/ai-sdk/core"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/agentrun"
|
||||
"github.com/samcharles93/archie-core/internal/webhookguard"
|
||||
)
|
||||
|
||||
// transcriptFieldLimit caps each recorded text field, in bytes.
|
||||
const transcriptFieldLimit = 32 << 10
|
||||
|
||||
// compactionPrefix starts the instruction agentloop sends to summarise the
|
||||
// history, which marks a model call as a compaction rather than a step.
|
||||
const compactionPrefix = "Compact the conversation history above"
|
||||
|
||||
// transcript records one agent run's conversation through agentloop's model
|
||||
// and tool hooks. Tool hooks run concurrently, so entries are numbered and
|
||||
// reported under one lock to keep their order.
|
||||
type transcript struct {
|
||||
report func(agentrun.TranscriptEntry)
|
||||
|
||||
mu sync.Mutex
|
||||
seq int
|
||||
prompted bool
|
||||
lastUser string
|
||||
started map[string]time.Time
|
||||
}
|
||||
|
||||
func newTranscript(report func(agentrun.TranscriptEntry)) *transcript {
|
||||
return &transcript{report: report, started: map[string]time.Time{}}
|
||||
}
|
||||
|
||||
func (t *transcript) add(entry agentrun.TranscriptEntry) {
|
||||
t.seq++
|
||||
entry.Seq = t.seq
|
||||
t.report(entry)
|
||||
}
|
||||
|
||||
func (t *transcript) ModelCallStarted(context.Context, chat.Request) {}
|
||||
|
||||
func (t *transcript) ModelCallFinished(_ context.Context, req chat.Request, resp *chat.Response, err error, latency time.Duration, usage *chat.Usage) {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
entry := agentrun.TranscriptEntry{Kind: agentrun.TranscriptModel, LatencyMS: latency.Milliseconds(), Usage: transcriptUsage(usage)}
|
||||
if isCompaction(req) {
|
||||
entry.Kind = agentrun.TranscriptCompaction
|
||||
} else {
|
||||
t.recordInput(req.Messages)
|
||||
}
|
||||
if err != nil {
|
||||
entry.Error = clip(err.Error(), nil)
|
||||
}
|
||||
if resp != nil {
|
||||
entry.Text = clip(resp.Content, &entry.TextBytes)
|
||||
entry.Reasoning = clip(reasoning(resp.Parts), &entry.ReasoningBytes)
|
||||
entry.FinishReason = resp.FinishReason
|
||||
for _, call := range resp.ToolCalls {
|
||||
recorded := agentrun.TranscriptToolCall{ID: call.ID, Name: call.Name}
|
||||
recorded.Args = clipArgs(call.Arguments, &recorded.ArgsBytes)
|
||||
entry.ToolCalls = append(entry.ToolCalls, recorded)
|
||||
}
|
||||
}
|
||||
t.add(entry)
|
||||
}
|
||||
|
||||
// recordInput records the prompt on the first call, and after that each user
|
||||
// message the loop appended since the model last answered: gate feedback,
|
||||
// recovery nudges. Assistant and tool messages are recorded from the response
|
||||
// and the tool hooks instead.
|
||||
func (t *transcript) recordInput(messages []chat.Message) {
|
||||
if !t.prompted {
|
||||
t.prompted = true
|
||||
for _, message := range messages {
|
||||
t.recordMessage(message)
|
||||
}
|
||||
return
|
||||
}
|
||||
start := len(messages)
|
||||
for start > 0 && messages[start-1].Role == chat.RoleUser {
|
||||
start--
|
||||
}
|
||||
for _, message := range messages[start:] {
|
||||
if message.Content != t.lastUser {
|
||||
t.recordMessage(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *transcript) recordMessage(message chat.Message) {
|
||||
kind := agentrun.TranscriptUser
|
||||
switch message.Role {
|
||||
case chat.RoleSystem:
|
||||
kind = agentrun.TranscriptSystem
|
||||
case chat.RoleUser:
|
||||
t.lastUser = message.Content
|
||||
default:
|
||||
return
|
||||
}
|
||||
entry := agentrun.TranscriptEntry{Kind: kind}
|
||||
entry.Text = clip(message.Content, &entry.TextBytes)
|
||||
t.add(entry)
|
||||
}
|
||||
|
||||
func (t *transcript) BeforeToolExecute(_ context.Context, call *core.ToolCall) (*core.Skip, error) {
|
||||
t.mu.Lock()
|
||||
t.started[call.ToolCallID] = time.Now()
|
||||
t.mu.Unlock()
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (t *transcript) AfterToolExecute(_ context.Context, call core.ToolCall, result *core.ToolResult) {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
entry := agentrun.TranscriptEntry{Kind: agentrun.TranscriptTool, CallID: call.ToolCallID, Tool: call.ToolName}
|
||||
if started, ok := t.started[call.ToolCallID]; ok {
|
||||
entry.LatencyMS = time.Since(started).Milliseconds()
|
||||
delete(t.started, call.ToolCallID)
|
||||
}
|
||||
entry.Args = clipArgs(call.Input, &entry.ArgsBytes)
|
||||
entry.Output = clip(result.Output, &entry.OutputBytes)
|
||||
entry.Error = clip(result.Error, nil)
|
||||
t.add(entry)
|
||||
}
|
||||
|
||||
func reasoning(parts chat.Parts) string {
|
||||
var texts []string
|
||||
for _, part := range parts {
|
||||
if thought, ok := part.(chat.ReasoningPart); ok && thought.Text != "" {
|
||||
texts = append(texts, thought.Text)
|
||||
}
|
||||
}
|
||||
return strings.Join(texts, "\n\n")
|
||||
}
|
||||
|
||||
func isCompaction(req chat.Request) bool {
|
||||
n := len(req.Messages)
|
||||
return n > 0 && req.Messages[n-1].Role == chat.RoleUser && strings.HasPrefix(req.Messages[n-1].Content, compactionPrefix)
|
||||
}
|
||||
|
||||
func transcriptUsage(usage *chat.Usage) *agentrun.Usage {
|
||||
if usage == nil {
|
||||
return nil
|
||||
}
|
||||
return &agentrun.Usage{
|
||||
PromptTokens: usage.PromptTokens,
|
||||
CompletionTokens: usage.CompletionTokens,
|
||||
TotalTokens: usage.TotalTokens,
|
||||
CachedTokens: usage.CachedTokens,
|
||||
CacheCreationTokens: usage.CacheCreationTokens,
|
||||
}
|
||||
}
|
||||
|
||||
// clipArgs redacts tool arguments by key when they are JSON, then clips them.
|
||||
func clipArgs(args string, full *int) string {
|
||||
if json.Valid([]byte(args)) {
|
||||
if redacted, err := webhookguard.RedactPayload([]byte(args)); err == nil {
|
||||
args = string(redacted)
|
||||
}
|
||||
}
|
||||
return clip(args, full)
|
||||
}
|
||||
|
||||
// clip redacts secret-shaped spans and cuts text to transcriptFieldLimit on a
|
||||
// rune boundary, storing the original size in full when it cuts.
|
||||
func clip(text string, full *int) string {
|
||||
text = webhookguard.RedactText(text)
|
||||
if len(text) <= transcriptFieldLimit {
|
||||
return text
|
||||
}
|
||||
if full != nil {
|
||||
*full = len(text)
|
||||
}
|
||||
cut := transcriptFieldLimit
|
||||
for cut > 0 && !utf8.RuneStart(text[cut]) {
|
||||
cut--
|
||||
}
|
||||
return text[:cut]
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package modelloop
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/ai-sdk/core"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/agentrun"
|
||||
)
|
||||
|
||||
func TestTranscriptToolEntryRedactsAndClips(t *testing.T) {
|
||||
const jwt = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcmNoaWUifQ.c2lnbmF0dXJlc2lnbmF0dXJl"
|
||||
const pem = "-----BEGIN RSA PRIVATE KEY-----\nMIIEow\n-----END RSA PRIVATE KEY-----"
|
||||
long := strings.Repeat("x", transcriptFieldLimit+10)
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
output string
|
||||
wantArgs string
|
||||
wantOutput string
|
||||
wantBytes int
|
||||
}{
|
||||
{
|
||||
name: "secret key in arguments, token inside output",
|
||||
input: `{"path":"a.txt","api_key":"plain-value"}`,
|
||||
output: "curl -H 'Authorization: Bearer " + jwt + "' done",
|
||||
wantArgs: `{"api_key":"[redacted]","path":"a.txt"}`,
|
||||
wantOutput: "curl -H 'Authorization: Bearer [redacted]' done",
|
||||
},
|
||||
{
|
||||
name: "private key block inside output",
|
||||
input: `{}`,
|
||||
output: "before\n" + pem + "\nafter",
|
||||
wantArgs: `{}`,
|
||||
wantOutput: "before\n[redacted]\nafter",
|
||||
},
|
||||
{
|
||||
name: "oversized output keeps its full size",
|
||||
input: `{}`,
|
||||
output: long,
|
||||
wantArgs: `{}`,
|
||||
wantOutput: long[:transcriptFieldLimit],
|
||||
wantBytes: len(long),
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
var got []agentrun.TranscriptEntry
|
||||
recorder := newTranscript(func(entry agentrun.TranscriptEntry) { got = append(got, entry) })
|
||||
call := core.ToolCall{ToolCallID: "c1", ToolName: "shell", Input: tt.input}
|
||||
if _, err := recorder.BeforeToolExecute(t.Context(), &call); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
recorder.AfterToolExecute(t.Context(), call, &core.ToolResult{Output: tt.output})
|
||||
if len(got) != 1 {
|
||||
t.Fatalf("entries = %d, want 1", len(got))
|
||||
}
|
||||
entry := got[0]
|
||||
if entry.Args != tt.wantArgs {
|
||||
t.Errorf("args = %q, want %q", entry.Args, tt.wantArgs)
|
||||
}
|
||||
if entry.Output != tt.wantOutput {
|
||||
t.Errorf("output = %q, want %q", entry.Output, tt.wantOutput)
|
||||
}
|
||||
if entry.OutputBytes != tt.wantBytes {
|
||||
t.Errorf("output bytes = %d, want %d", entry.OutputBytes, tt.wantBytes)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ func readProjectMemory(path string) (string, error) {
|
||||
return "Project memory from earlier sessions:\n" + strings.Join(entries, "\n"), nil
|
||||
}
|
||||
|
||||
func (r persistentRunner) Run(ctx context.Context, workspace string, request agentrun.Request, report agentrun.ToolCallReporter) (agentrun.Result, error) {
|
||||
func (r persistentRunner) Run(ctx context.Context, workspace string, request agentrun.Request, report agentrun.Reporter) (agentrun.Result, error) {
|
||||
if !r.enabled {
|
||||
return r.Runner.Run(ctx, workspace, request, report)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ import (
|
||||
const releaseUsage = `usage: archied release <command>
|
||||
|
||||
keygen -seed FILE write a new signing key's seed to FILE and print its public key
|
||||
publish sign a release and push it to a release source`
|
||||
publish sign a release and push it to a release source's next channel
|
||||
promote -version V point stable at a published release by hand
|
||||
canary start point the canary at next and install a release on it
|
||||
canary check judge the release on next and promote it or roll the canary back`
|
||||
|
||||
// RunRelease is the publisher's side of a release source: it makes the key
|
||||
// a source signs with and pushes signed releases to it.
|
||||
@@ -31,6 +34,10 @@ func RunRelease(args []string, out, stderr io.Writer) int {
|
||||
return runReleaseKeygen(args[1:], out, stderr)
|
||||
case "publish":
|
||||
return runReleasePublish(args[1:], out, stderr)
|
||||
case "promote":
|
||||
return runReleasePromote(args[1:], out, stderr)
|
||||
case "canary":
|
||||
return runReleaseCanary(args[1:], out, stderr)
|
||||
default:
|
||||
fmt.Fprintln(stderr, releaseUsage)
|
||||
return 2
|
||||
@@ -79,7 +86,7 @@ func runReleasePublish(args []string, out, stderr io.Writer) int {
|
||||
flags.StringVar(&req.Repository, "source", "", "OCI repository to publish to")
|
||||
seedEnv := flags.String("seed-env", "ARCHIE_RELEASE_SEED", "environment variable holding the base64 private key seed")
|
||||
flags.StringVar(&req.Version, "version", "", "release version")
|
||||
flags.BoolVar(&req.Prerelease, "prerelease", false, "publish to next only")
|
||||
flags.BoolVar(&req.Prerelease, "prerelease", false, "mark the release a prerelease, which never reaches stable")
|
||||
flags.StringVar(&req.ZipPath, "zip", "", "distribution zip")
|
||||
flags.StringVar(&req.AgentImage, "agent-image", "", "agent image pinned by digest")
|
||||
flags.StringVar(&req.Changelog, "changelog", "", "URL of the release notes")
|
||||
@@ -97,10 +104,8 @@ func runReleasePublish(args []string, out, stderr io.Writer) int {
|
||||
}
|
||||
req.Signer = ed25519.NewKeyFromSeed(seed)
|
||||
public := distribution.EncodeKey(ed25519.PublicKey(req.Signer[ed25519.SeedSize:]))
|
||||
// stable moves only when the canary promotes the release.
|
||||
req.Channels = []string{"next"}
|
||||
if !req.Prerelease {
|
||||
req.Channels = append(req.Channels, "stable")
|
||||
}
|
||||
statement, err := releaseupdate.Publish(context.Background(), req)
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, err)
|
||||
@@ -110,3 +115,39 @@ func runReleasePublish(args []string, out, stderr io.Writer) int {
|
||||
strings.Join(req.Channels, ", "), public)
|
||||
return 0
|
||||
}
|
||||
|
||||
// runReleasePromote moves stable without a canary verdict, under the same
|
||||
// rules the canary promotes by.
|
||||
func runReleasePromote(args []string, out, stderr io.Writer) int {
|
||||
flags := flag.NewFlagSet("release promote", flag.ContinueOnError)
|
||||
flags.SetOutput(stderr)
|
||||
reference := flags.String("source", "", "OCI repository releases are published to; blank is the official releases")
|
||||
key := flags.String("key", "", "base64 ed25519 public key the source signs with")
|
||||
version := flags.String("version", "", "release to promote")
|
||||
latest := flags.String("latest", "", "comma-separated image repositories whose v<version> tag becomes latest")
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 2
|
||||
}
|
||||
source, err := distribution.Parse(*reference, *key, distribution.DefaultReleases())
|
||||
if err != nil || *version == "" {
|
||||
fmt.Fprintln(stderr, "release promote: -version is required, and -source with -key name another source")
|
||||
return 2
|
||||
}
|
||||
statement, err := releaseupdate.Promote(context.Background(), source.Reference, source.Key, *version, splitList(*latest))
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, err)
|
||||
return 1
|
||||
}
|
||||
fmt.Fprintf(out, "stable is %s\n", statement.Version)
|
||||
return 0
|
||||
}
|
||||
|
||||
func splitList(value string) []string {
|
||||
var items []string
|
||||
for item := range strings.SplitSeq(value, ",") {
|
||||
if item = strings.TrimSpace(item); item != "" {
|
||||
items = append(items, item)
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
"oras.land/oras-go/v2/errdef"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/distribution"
|
||||
"github.com/samcharles93/archie-core/internal/releaseupdate"
|
||||
)
|
||||
|
||||
// canaryInstallWait bounds how long an install on the canary may take,
|
||||
// including the watchdog's health wait and a rollback.
|
||||
const canaryInstallWait = 20 * time.Minute
|
||||
|
||||
// migrationsDir holds the schema migrations; a release that changes it can't
|
||||
// be rolled back without restoring the database snapshot.
|
||||
const migrationsDir = "internal/infrastructure/postgres/migrations"
|
||||
|
||||
func runReleaseCanary(args []string, out, stderr io.Writer) int {
|
||||
if len(args) == 0 || (args[0] != "start" && args[0] != "check") {
|
||||
fmt.Fprintln(stderr, releaseUsage)
|
||||
return 2
|
||||
}
|
||||
flags := flag.NewFlagSet("release canary "+args[0], flag.ContinueOnError)
|
||||
flags.SetOutput(stderr)
|
||||
dashboardURL := flags.String("dashboard", "", "canary dashboard URL")
|
||||
tokenEnv := flags.String("token-env", "ARCHIE_CANARY_TOKEN", "environment variable holding a dashboard API token for the canary")
|
||||
version := flags.String("version", "", "release to install (start)")
|
||||
reference := flags.String("source", "", "OCI repository releases are published to; blank is the official releases (check)")
|
||||
key := flags.String("key", "", "base64 ed25519 public key the source signs with (check)")
|
||||
latest := flags.String("latest", "", "comma-separated image repositories whose v<version> tag becomes latest on promotion (check)")
|
||||
checkout := flags.String("checkout", ".", "repository checkout with release tags, to see whether a release migrated the database (check)")
|
||||
if err := flags.Parse(args[1:]); err != nil {
|
||||
return 2
|
||||
}
|
||||
dashboard := releaseupdate.CanaryDashboard{URL: *dashboardURL, Token: os.Getenv(*tokenEnv)}
|
||||
if *dashboardURL == "" {
|
||||
fmt.Fprintln(stderr, "release canary: -dashboard is required")
|
||||
return 2
|
||||
}
|
||||
ctx := context.Background()
|
||||
if args[0] == "start" {
|
||||
if *version == "" {
|
||||
fmt.Fprintln(stderr, "release canary start: -version is required")
|
||||
return 2
|
||||
}
|
||||
if err := startCanary(ctx, dashboard, *version); err != nil {
|
||||
fmt.Fprintln(stderr, err)
|
||||
return 1
|
||||
}
|
||||
fmt.Fprintf(out, "canary follows next and runs %s\n", *version)
|
||||
return 0
|
||||
}
|
||||
source, err := distribution.Parse(*reference, *key, distribution.DefaultReleases())
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, "release canary check:", err)
|
||||
return 2
|
||||
}
|
||||
rolledBack, err := checkCanary(ctx, dashboard, source, splitList(*latest), *checkout, out)
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, err)
|
||||
return 1
|
||||
}
|
||||
if rolledBack {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func startCanary(ctx context.Context, dashboard releaseupdate.CanaryDashboard, version string) error {
|
||||
if err := dashboard.Follow(ctx, "next", ""); err != nil {
|
||||
return fmt.Errorf("point the canary at next: %w", err)
|
||||
}
|
||||
return dashboard.Install(ctx, version, canaryInstallWait)
|
||||
}
|
||||
|
||||
// checkCanary judges the release on the next channel once and acts on the
|
||||
// result. It reports rolledBack so that the caller can fail the run.
|
||||
func checkCanary(ctx context.Context, dashboard releaseupdate.CanaryDashboard, source distribution.Source, latest []string, checkout string, out io.Writer) (rolledBack bool, err error) {
|
||||
next, err := releaseupdate.Fetch(ctx, source, "next")
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
stable, err := releaseupdate.Fetch(ctx, source, "stable")
|
||||
hasStable := err == nil
|
||||
if err != nil && !errors.Is(err, errdef.ErrNotFound) {
|
||||
return false, err
|
||||
}
|
||||
release := next.Statement
|
||||
if release.Prerelease || (hasStable && !release.IssuedAt.After(stable.Statement.IssuedAt)) {
|
||||
fmt.Fprintf(out, "nothing to judge: next is %s and isn't a newer release than stable\n", release.Version)
|
||||
return false, nil
|
||||
}
|
||||
channel, pin, err := dashboard.Channel(ctx)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if channel != "next" {
|
||||
fmt.Fprintf(out, "nothing to judge: the canary is held on %s %s\n", channel, pin)
|
||||
return false, nil
|
||||
}
|
||||
now := time.Now().UTC()
|
||||
signals, err := dashboard.Signals(ctx, release.IssuedAt, now)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("read canary signals: %w", err)
|
||||
}
|
||||
verdict := releaseupdate.JudgeCanary(release.Version, now.Sub(release.IssuedAt), signals)
|
||||
fmt.Fprintf(out, "%s: %s\n", release.Version, verdict.Decision)
|
||||
for _, reason := range verdict.Reasons {
|
||||
fmt.Fprintf(out, " %s\n", reason)
|
||||
}
|
||||
switch verdict.Decision {
|
||||
case releaseupdate.CanaryPromote:
|
||||
if _, err := releaseupdate.Promote(ctx, source.Reference, source.Key, release.Version, latest); err != nil {
|
||||
return false, fmt.Errorf("promote %s: %w", release.Version, err)
|
||||
}
|
||||
fmt.Fprintf(out, "stable is %s\n", release.Version)
|
||||
return false, nil
|
||||
case releaseupdate.CanaryRollBack:
|
||||
return true, rollBackCanary(ctx, dashboard, release.Version, stable.Statement.Version, hasStable, checkout, out)
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// rollBackCanary pins the canary to the stable release and reinstalls it.
|
||||
// Going back past a migration needs the pre-update database snapshot, which
|
||||
// loses every write since, so a release that migrated is held instead.
|
||||
func rollBackCanary(ctx context.Context, dashboard releaseupdate.CanaryDashboard, failed, stable string, hasStable bool, checkout string, out io.Writer) error {
|
||||
if !hasStable || migrated(ctx, checkout, stable, failed) {
|
||||
if err := dashboard.Follow(ctx, "exact-pin", failed); err != nil {
|
||||
return fmt.Errorf("hold the canary on %s: %w", failed, err)
|
||||
}
|
||||
fmt.Fprintf(out, "%s changed the database schema or there's no stable release to return to: the canary is held on %s and stable is unchanged; fix forward\n", failed, failed)
|
||||
return nil
|
||||
}
|
||||
if err := dashboard.Follow(ctx, "exact-pin", stable); err != nil {
|
||||
return fmt.Errorf("pin the canary to %s: %w", stable, err)
|
||||
}
|
||||
if err := dashboard.Install(ctx, stable, canaryInstallWait); err != nil {
|
||||
return fmt.Errorf("return the canary to %s: %w", stable, err)
|
||||
}
|
||||
fmt.Fprintf(out, "the canary is back on %s and stable is unchanged\n", stable)
|
||||
return nil
|
||||
}
|
||||
|
||||
// migrated reports whether the migrations differ between two release tags.
|
||||
// If it can't tell, it says they differ, so the canary is held rather than
|
||||
// rolled back.
|
||||
func migrated(ctx context.Context, checkout, from, to string) bool {
|
||||
err := exec.CommandContext(ctx, "git", "-C", checkout, "diff", "--quiet", "v"+from, "v"+to, "--", migrationsDir).Run()
|
||||
return err != nil
|
||||
}
|
||||
@@ -211,8 +211,12 @@ func (x *EventsSinceResponse) GetEvents() []*Event {
|
||||
}
|
||||
|
||||
type TaskEventsRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"`
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"`
|
||||
// transcript selects the agent_transcript entries of one attempt instead of
|
||||
// the timeline, which leaves them out.
|
||||
Transcript bool `protobuf:"varint,2,opt,name=transcript,proto3" json:"transcript,omitempty"`
|
||||
Attempt int64 `protobuf:"varint,3,opt,name=attempt,proto3" json:"attempt,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -254,6 +258,20 @@ func (x *TaskEventsRequest) GetTaskId() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *TaskEventsRequest) GetTranscript() bool {
|
||||
if x != nil {
|
||||
return x.Transcript
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *TaskEventsRequest) GetAttempt() int64 {
|
||||
if x != nil {
|
||||
return x.Attempt
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type TaskEventsResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Events []*Event `protobuf:"bytes,1,rep,name=events,proto3" json:"events,omitempty"`
|
||||
@@ -311,9 +329,13 @@ const file_state_v1_task_event_proto_rawDesc = "" +
|
||||
"\bsince_id\x18\x01 \x01(\tR\asinceId\x12\x14\n" +
|
||||
"\x05limit\x18\x02 \x01(\x03R\x05limit\">\n" +
|
||||
"\x13EventsSinceResponse\x12'\n" +
|
||||
"\x06events\x18\x01 \x03(\v2\x0f.state.v1.EventR\x06events\",\n" +
|
||||
"\x06events\x18\x01 \x03(\v2\x0f.state.v1.EventR\x06events\"f\n" +
|
||||
"\x11TaskEventsRequest\x12\x17\n" +
|
||||
"\atask_id\x18\x01 \x01(\x03R\x06taskId\"=\n" +
|
||||
"\atask_id\x18\x01 \x01(\x03R\x06taskId\x12\x1e\n" +
|
||||
"\n" +
|
||||
"transcript\x18\x02 \x01(\bR\n" +
|
||||
"transcript\x12\x18\n" +
|
||||
"\aattempt\x18\x03 \x01(\x03R\aattempt\"=\n" +
|
||||
"\x12TaskEventsResponse\x12'\n" +
|
||||
"\x06events\x18\x01 \x03(\v2\x0f.state.v1.EventR\x06events2\xf3\x01\n" +
|
||||
"\x10TaskEventService\x12J\n" +
|
||||
|
||||
@@ -4,12 +4,13 @@ import "context"
|
||||
|
||||
// Runner executes one autonomous stage against an already prepared workspace.
|
||||
type Runner interface {
|
||||
// report, when non-nil, is notified once per completed tool call.
|
||||
Run(ctx context.Context, workspace string, req Request, report ToolCallReporter) (Result, error)
|
||||
// report receives what the run does as it happens; its zero value
|
||||
// discards everything.
|
||||
Run(ctx context.Context, workspace string, req Request, report Reporter) (Result, error)
|
||||
}
|
||||
|
||||
// ToolCallReport is one completed tool invocation, reported through a
|
||||
// ToolCallReporter.
|
||||
// Reporter.
|
||||
type ToolCallReport struct {
|
||||
Tool string
|
||||
// Detail is a clipped one-line summary: the tool's result, or
|
||||
@@ -18,6 +19,67 @@ type ToolCallReport struct {
|
||||
Failed bool
|
||||
}
|
||||
|
||||
// ToolCallReporter receives one ToolCallReport per completed tool call. A nil
|
||||
// reporter is valid and reports nothing.
|
||||
type ToolCallReporter func(ToolCallReport)
|
||||
// Reporter receives a run's activity. Either func may be nil.
|
||||
type Reporter struct {
|
||||
// ToolCall is notified once per completed tool call.
|
||||
ToolCall func(ToolCallReport)
|
||||
// Transcript is notified of each transcript entry, in order.
|
||||
Transcript func(TranscriptEntry)
|
||||
}
|
||||
|
||||
// ReportToolCall forwards report to r.ToolCall, if set.
|
||||
func (r Reporter) ReportToolCall(report ToolCallReport) {
|
||||
if r.ToolCall != nil {
|
||||
r.ToolCall(report)
|
||||
}
|
||||
}
|
||||
|
||||
// ReportTranscript forwards entry to r.Transcript, if set.
|
||||
func (r Reporter) ReportTranscript(entry TranscriptEntry) {
|
||||
if r.Transcript != nil {
|
||||
r.Transcript(entry)
|
||||
}
|
||||
}
|
||||
|
||||
// Transcript entry kinds.
|
||||
const (
|
||||
TranscriptSystem = "system" // Text: the system prompt
|
||||
TranscriptUser = "user" // Text: the mission, or input the loop added later
|
||||
TranscriptModel = "model" // Reasoning, Text and ToolCalls: one model response
|
||||
TranscriptTool = "tool" // one tool call's arguments and result
|
||||
TranscriptCompaction = "compaction" // Text: the summary that replaced the history
|
||||
)
|
||||
|
||||
// TranscriptEntry is one ordered item of an agent run's conversation. Text
|
||||
// fields are redacted and clipped; a *Bytes field holds the full size when its
|
||||
// field was clipped.
|
||||
type TranscriptEntry struct {
|
||||
Seq int `json:"seq"`
|
||||
Kind string `json:"kind"`
|
||||
Text string `json:"text,omitempty"`
|
||||
TextBytes int `json:"text_bytes,omitempty"`
|
||||
ToolCalls []TranscriptToolCall `json:"tool_calls,omitempty"`
|
||||
|
||||
Reasoning string `json:"reasoning,omitempty"`
|
||||
ReasoningBytes int `json:"reasoning_bytes,omitempty"`
|
||||
|
||||
CallID string `json:"call_id,omitempty"`
|
||||
Tool string `json:"tool,omitempty"`
|
||||
Args string `json:"args,omitempty"`
|
||||
ArgsBytes int `json:"args_bytes,omitempty"`
|
||||
Output string `json:"output,omitempty"`
|
||||
OutputBytes int `json:"output_bytes,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
|
||||
FinishReason string `json:"finish_reason,omitempty"`
|
||||
Usage *Usage `json:"usage,omitempty"`
|
||||
LatencyMS int64 `json:"latency_ms,omitempty"`
|
||||
}
|
||||
|
||||
// TranscriptToolCall is one tool call a model response requested.
|
||||
type TranscriptToolCall struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Args string `json:"args,omitempty"`
|
||||
ArgsBytes int `json:"args_bytes,omitempty"`
|
||||
}
|
||||
@@ -153,7 +153,10 @@ type TaskQueries interface {
|
||||
type TaskEvents interface {
|
||||
InsertEvent(ctx context.Context, e events.Event) (int64, error)
|
||||
EventsSince(ctx context.Context, cursor string, limit int) ([]events.Event, error)
|
||||
// TaskEvents returns a task's timeline, without agent transcripts.
|
||||
TaskEvents(ctx context.Context, taskID int64) ([]events.Event, error)
|
||||
// TaskTranscript returns one attempt's agent transcript entries in order.
|
||||
TaskTranscript(ctx context.Context, taskID int64, attempt int) ([]events.Event, error)
|
||||
WorkflowStats(ctx context.Context) ([]WorkflowStat, error)
|
||||
StageStats(ctx context.Context) ([]StageStat, error)
|
||||
TokensByDay(ctx context.Context, days int) ([]DayTokens, error)
|
||||
|
||||
@@ -71,7 +71,7 @@ func (a AgentStage) Stage() Stage {
|
||||
// The agent call is a child of the stage's recorded step: the store
|
||||
// says what the stage's runtime did, not just what the stage did.
|
||||
res, runErr := tc.RunAgentChild(ctx, a.Name, a.Model, modelRef, func() (agentrun.Result, error) {
|
||||
return tc.Agent.Run(ctx, tc.Dir, req, tc.toolCallReporter(ctx, a.Name))
|
||||
return tc.Agent.Run(ctx, tc.Dir, req, tc.reporter(ctx, a.Name))
|
||||
})
|
||||
return a.handleResult(ctx, tc, req, res, runErr, modelRef)
|
||||
}}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
// fakeBudgetRunner is an agent runner whose stage exhausted its budget.
|
||||
type fakeBudgetRunner struct{ res agentrun.Result }
|
||||
|
||||
func (f fakeBudgetRunner) Run(context.Context, string, agentrun.Request, agentrun.ToolCallReporter) (agentrun.Result, error) {
|
||||
func (f fakeBudgetRunner) Run(context.Context, string, agentrun.Request, agentrun.Reporter) (agentrun.Result, error) {
|
||||
return f.res, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ func runBaselineFix(ctx context.Context, tc *TaskContext, argv []string, out []b
|
||||
}
|
||||
|
||||
res, agentErr := tc.RunAgentChild(ctx, "baseline-fix", "", modelRef, func() (agentrun.Result, error) {
|
||||
return tc.Agent.Run(ctx, tc.Dir, req, tc.toolCallReporter(ctx, "baseline-fix"))
|
||||
return tc.Agent.Run(ctx, tc.Dir, req, tc.reporter(ctx, "baseline-fix"))
|
||||
})
|
||||
if agentErr != nil && res.Version == 0 {
|
||||
return baselineFixFailedError(argv, string(out), fmt.Sprintf("the builder could not run: %v", agentErr))
|
||||
|
||||
@@ -579,7 +579,7 @@ func runReviewerAgent(
|
||||
if err != nil {
|
||||
return agentrun.Result{}, err
|
||||
}
|
||||
res, runErr := tc.Agent.Run(ctx, tc.prReview.snapshotDir, req, tc.toolCallReporter(ctx, name))
|
||||
res, runErr := tc.Agent.Run(ctx, tc.prReview.snapshotDir, req, tc.reporter(ctx, name))
|
||||
tc.prReview.tokensSpent.Add(int64(res.TokensUsed))
|
||||
to, detail := taskstate.StepSucceeded, res.Summary
|
||||
switch {
|
||||
@@ -805,7 +805,7 @@ func runPRReviewAgentRecorded(
|
||||
CaptureTools: captureTools,
|
||||
}
|
||||
res, err := tc.RunAgentChild(ctx, name, "", modelRef, func() (agentrun.Result, error) {
|
||||
return tc.Agent.Run(ctx, workspace, req, tc.toolCallReporter(ctx, name))
|
||||
return tc.Agent.Run(ctx, workspace, req, tc.reporter(ctx, name))
|
||||
})
|
||||
tc.prReview.tokensSpent.Add(int64(res.TokensUsed))
|
||||
return res, err
|
||||
|
||||
@@ -64,7 +64,7 @@ type fakePromptRunner struct {
|
||||
mission string
|
||||
}
|
||||
|
||||
func (f *fakePromptRunner) Run(_ context.Context, workspace string, req agentrun.Request, _ agentrun.ToolCallReporter) (agentrun.Result, error) {
|
||||
func (f *fakePromptRunner) Run(_ context.Context, workspace string, req agentrun.Request, _ agentrun.Reporter) (agentrun.Result, error) {
|
||||
f.workspace = workspace
|
||||
f.mission = req.Mission
|
||||
return f.res, nil
|
||||
|
||||
@@ -206,7 +206,7 @@ func (tc *TaskContext) Emit(ctx context.Context, kind, stage, detail string, dat
|
||||
|
||||
// Activity belongs to the recorded stage, even when an agent uses its own name.
|
||||
func (tc *TaskContext) activityData(kind string, data map[string]any) map[string]any {
|
||||
if tc.StepID == 0 || (kind != events.KindToolCall && kind != events.KindAgentFinish) {
|
||||
if tc.StepID == 0 || (kind != events.KindToolCall && kind != events.KindAgentFinish && kind != events.KindAgentTranscript) {
|
||||
return data
|
||||
}
|
||||
out := make(map[string]any, len(data)+2)
|
||||
@@ -239,18 +239,41 @@ func (tc *TaskContext) EmitDurable(ctx context.Context, kind, stage, detail stri
|
||||
return nil
|
||||
}
|
||||
|
||||
// toolCallReporter builds the agentrun.ToolCallReporter an agent stage passes
|
||||
// to tc.Agent.Run, so every completed tool call during that run surfaces as a
|
||||
// tool_call event on the task timeline. Safe to call on a nil Bus: Emit no-ops.
|
||||
func (tc *TaskContext) toolCallReporter(ctx context.Context, stage string) agentrun.ToolCallReporter {
|
||||
return func(report agentrun.ToolCallReport) {
|
||||
tc.Emit(ctx, events.KindToolCall, stage, report.Detail, map[string]any{
|
||||
"tool": report.Tool,
|
||||
"failed": report.Failed,
|
||||
})
|
||||
// reporter builds the agentrun.Reporter an agent stage passes to
|
||||
// tc.Agent.Run: every completed tool call surfaces as a tool_call event on the
|
||||
// task timeline, and every transcript entry is persisted as an
|
||||
// agent_transcript event so it outlives the container. A transcript entry
|
||||
// that cannot be persisted is logged and dropped; it never fails the run.
|
||||
func (tc *TaskContext) reporter(ctx context.Context, stage string) agentrun.Reporter {
|
||||
return agentrun.Reporter{
|
||||
ToolCall: func(report agentrun.ToolCallReport) {
|
||||
tc.Emit(ctx, events.KindToolCall, stage, report.Detail, map[string]any{
|
||||
"tool": report.Tool,
|
||||
"failed": report.Failed,
|
||||
})
|
||||
},
|
||||
Transcript: func(entry agentrun.TranscriptEntry) {
|
||||
data, err := transcriptData(entry)
|
||||
if err == nil {
|
||||
err = tc.EmitDurable(ctx, events.KindAgentTranscript, stage, entry.Kind, data)
|
||||
}
|
||||
if err != nil && tc.Log != nil {
|
||||
tc.Log.WarnContext(ctx, "agent transcript entry not recorded",
|
||||
"task", tc.Task.ID, "stage", stage, "seq", entry.Seq, "err", err)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func transcriptData(entry agentrun.TranscriptEntry) (map[string]any, error) {
|
||||
encoded, err := json.Marshal(entry)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var data map[string]any
|
||||
return data, json.Unmarshal(encoded, &data)
|
||||
}
|
||||
|
||||
// Outcome is a stage's terminal decision for the whole workflow. Stages
|
||||
// that don't end the workflow leave it zero.
|
||||
type Outcome struct {
|
||||
|
||||
@@ -22,8 +22,12 @@ const (
|
||||
KindAgentFinish = "agent_finish" // data: status, stop_reason, tokens, iterations, model, prompt_tokens, completion_tokens, cached_tokens, cache_creation_tokens
|
||||
// KindToolCall marks one completed tool invocation during an agent stage
|
||||
// run. Only emitted for runners that execute in the same process as their
|
||||
// tools; see agentexec.ToolCallReporter.
|
||||
// tools; see agentrun.Reporter.
|
||||
KindToolCall = "tool_call" // data: tool, failed
|
||||
// KindAgentTranscript is one entry of an agent run's conversation: a
|
||||
// prompt, a model response, a tool call or a compaction. detail: the
|
||||
// entry kind; data: agentrun.TranscriptEntry's fields.
|
||||
KindAgentTranscript = "agent_transcript"
|
||||
// KindDeliveryRecorded records one outward delivery a test run did not
|
||||
// perform: a forge write, a push, an HTTP request, a central tool call.
|
||||
// detail: what it would have done, phrased "would ...".
|
||||
|
||||
@@ -136,24 +136,56 @@ func RunParams(ctx context.Context, p Prompter, discovery ModelDiscovery, secret
|
||||
}
|
||||
|
||||
// stepDatabase returns the PostgreSQL URL. A blank answer on a fresh install
|
||||
// means the bundled database: no network, reached through its Unix socket, with
|
||||
// a generated password that goes only to the env file as PGPASSWORD, which pgx
|
||||
// and Compose both read, so config.toml holds no secret.
|
||||
// means the bundled database. On a re-run with an existing URL the bundled
|
||||
// database is an explicit choice rather than something reachable only by
|
||||
// typing its socket URL; keeping the existing URL is the first option, so
|
||||
// the default answer is unchanged.
|
||||
func stepDatabase(ctx context.Context, p Prompter, secrets SecretSink, existing, param string) (string, error) {
|
||||
if strings.TrimSpace(param) != "" {
|
||||
return param, nil
|
||||
}
|
||||
prompt := "PostgreSQL 18 URL (blank for the bundled database with a generated password): "
|
||||
if existing != "" {
|
||||
prompt = "PostgreSQL 18 URL: "
|
||||
if strings.TrimSpace(existing) != "" {
|
||||
choice, err := p.Select(ctx, "Database:", []string{
|
||||
"Keep the existing database URL",
|
||||
"Bundled database (Unix socket, generated password in the env file)",
|
||||
"Enter a different PostgreSQL 18 URL",
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("setup: database choice: %w", err)
|
||||
}
|
||||
switch choice {
|
||||
case 0:
|
||||
return existing, nil
|
||||
case 1:
|
||||
return bundledDatabase(secrets)
|
||||
default:
|
||||
url, err := p.ReadLine(ctx, "PostgreSQL 18 URL: ", "")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("setup: database url: %w", err)
|
||||
}
|
||||
if strings.TrimSpace(url) == "" {
|
||||
// A blank answer keeps the existing URL, as it always has.
|
||||
return existing, nil
|
||||
}
|
||||
return url, nil
|
||||
}
|
||||
}
|
||||
url, err := p.ReadLine(ctx, prompt, existing)
|
||||
prompt := "PostgreSQL 18 URL (blank for the bundled database with a generated password): "
|
||||
url, err := p.ReadLine(ctx, prompt, "")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("setup: database url: %w", err)
|
||||
}
|
||||
if strings.TrimSpace(url) != "" {
|
||||
return url, nil
|
||||
}
|
||||
return bundledDatabase(secrets)
|
||||
}
|
||||
|
||||
// bundledDatabase switches to the bundled database: no network, reached
|
||||
// through its Unix socket, with a generated password that goes only to the
|
||||
// env file as PGPASSWORD, which pgx and Compose both read, so config.toml
|
||||
// holds no secret.
|
||||
func bundledDatabase(secrets SecretSink) (string, error) {
|
||||
pw := make([]byte, 24)
|
||||
if _, err := rand.Read(pw); err != nil {
|
||||
return "", fmt.Errorf("setup: generate database password: %w", err)
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
package setup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration/tomlwrite"
|
||||
)
|
||||
|
||||
// fakePrompter answers prompts from maps keyed by the exact prompt text and
|
||||
// records what it was asked, so a test can pin both the answers and that the
|
||||
// bundled database was actually offered.
|
||||
type fakePrompter struct {
|
||||
selectAnswers map[string]int
|
||||
lineAnswers map[string]string
|
||||
confirmAnswer bool
|
||||
|
||||
selects []recordedSelect
|
||||
lines []recordedLine
|
||||
}
|
||||
|
||||
type recordedSelect struct {
|
||||
prompt string
|
||||
options []string
|
||||
}
|
||||
|
||||
type recordedLine struct {
|
||||
prompt string
|
||||
defaultValue string
|
||||
}
|
||||
|
||||
func (f *fakePrompter) Select(_ context.Context, prompt string, options []string) (int, error) {
|
||||
f.selects = append(f.selects, recordedSelect{prompt: prompt, options: options})
|
||||
if ans, ok := f.selectAnswers[prompt]; ok {
|
||||
return ans, nil
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (f *fakePrompter) ReadLine(_ context.Context, prompt, defaultValue string) (string, error) {
|
||||
f.lines = append(f.lines, recordedLine{prompt: prompt, defaultValue: defaultValue})
|
||||
if ans, ok := f.lineAnswers[prompt]; ok {
|
||||
return ans, nil
|
||||
}
|
||||
return defaultValue, nil
|
||||
}
|
||||
|
||||
func (f *fakePrompter) ReadSecret(context.Context, string) (string, error) { return "", nil }
|
||||
|
||||
func (f *fakePrompter) Confirm(context.Context, string, bool) (bool, error) {
|
||||
return f.confirmAnswer, nil
|
||||
}
|
||||
|
||||
// fakeSink records Put calls by engine/key.
|
||||
type fakeSink struct {
|
||||
puts map[string]string
|
||||
}
|
||||
|
||||
func (s *fakeSink) Put(engine, key, value string) error {
|
||||
if s.puts == nil {
|
||||
s.puts = map[string]string{}
|
||||
}
|
||||
s.puts[engine+"/"+key] = value
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *fakeSink) Commit() error { return nil }
|
||||
|
||||
// databasePrompt is the re-run database choice; bundledChoice is the index of
|
||||
// the bundled database option in that menu.
|
||||
const (
|
||||
databasePrompt = "Database:"
|
||||
bundledChoice = 1
|
||||
differentURL = 2
|
||||
)
|
||||
|
||||
func bundledURL() string {
|
||||
return "postgres://archie@/archie?host=" + configuration.DefaultPostgresSocketDir()
|
||||
}
|
||||
|
||||
// TestRunParamsDatabaseChoice pins the re-run database step at the setup API
|
||||
// level: with an existing database_url the flow must offer the bundled
|
||||
// database as an explicit choice, switching to it must generate PGPASSWORD
|
||||
// into the sink, and keeping must leave the existing URL untouched.
|
||||
func TestRunParamsDatabaseChoice(t *testing.T) {
|
||||
const existing = "postgres://operator:secret@db.internal:5432/archie"
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
// existing is the prefilled database_url; empty means fresh install.
|
||||
existing string
|
||||
// param is Params.DatabaseURL (the -database-url flag).
|
||||
param string
|
||||
selectAnswers map[string]int
|
||||
lineAnswers map[string]string
|
||||
wantURL string
|
||||
wantPassword bool
|
||||
wantChoice bool // a database Select menu must be presented
|
||||
}{
|
||||
{
|
||||
name: "re-run keep existing is the default choice",
|
||||
existing: existing,
|
||||
selectAnswers: map[string]int{databasePrompt: 0},
|
||||
wantURL: existing,
|
||||
wantChoice: true,
|
||||
},
|
||||
{
|
||||
name: "re-run switch to the bundled database",
|
||||
existing: existing,
|
||||
selectAnswers: map[string]int{databasePrompt: bundledChoice},
|
||||
wantURL: bundledURL(),
|
||||
wantPassword: true,
|
||||
wantChoice: true,
|
||||
},
|
||||
{
|
||||
name: "re-run enter a different URL",
|
||||
existing: existing,
|
||||
selectAnswers: map[string]int{databasePrompt: differentURL},
|
||||
lineAnswers: map[string]string{"PostgreSQL 18 URL: ": "postgres://other.internal/archie"},
|
||||
wantURL: "postgres://other.internal/archie",
|
||||
wantChoice: true,
|
||||
},
|
||||
{
|
||||
name: "re-run blank answer on the different-URL prompt keeps existing",
|
||||
existing: existing,
|
||||
selectAnswers: map[string]int{databasePrompt: differentURL},
|
||||
lineAnswers: map[string]string{"PostgreSQL 18 URL: ": ""},
|
||||
wantURL: existing,
|
||||
wantChoice: true,
|
||||
},
|
||||
{
|
||||
name: "fresh install blank answer means the bundled database",
|
||||
existing: "",
|
||||
lineAnswers: map[string]string{"PostgreSQL 18 URL (blank for the bundled database with a generated password): ": ""},
|
||||
wantURL: bundledURL(),
|
||||
wantPassword: true,
|
||||
wantChoice: false,
|
||||
},
|
||||
{
|
||||
name: "database-url flag wins without prompting",
|
||||
existing: existing,
|
||||
param: "postgres://flag.internal/archie",
|
||||
wantURL: "postgres://flag.internal/archie",
|
||||
wantChoice: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
p := &fakePrompter{
|
||||
selectAnswers: tt.selectAnswers,
|
||||
lineAnswers: tt.lineAnswers,
|
||||
confirmAnswer: false,
|
||||
}
|
||||
sink := &fakeSink{}
|
||||
params := Params{
|
||||
DatabaseURL: tt.param,
|
||||
BotUser: "archie-bot",
|
||||
ForgeType: "none",
|
||||
Provider: "ollama",
|
||||
Model: "llama3",
|
||||
}
|
||||
edits, err := RunParams(context.Background(), p, nil, sink, ExistingValues{DatabaseURL: tt.existing}, params)
|
||||
if err != nil {
|
||||
t.Fatalf("RunParams: %v", err)
|
||||
}
|
||||
|
||||
var gotURL string
|
||||
for _, e := range edits {
|
||||
if e.Table == "" && e.Key == "database_url" {
|
||||
gotURL = e.Value
|
||||
}
|
||||
}
|
||||
if gotURL != tomlwrite.String(tt.wantURL) {
|
||||
t.Errorf("database_url = %s, want %s", gotURL, tomlwrite.String(tt.wantURL))
|
||||
}
|
||||
|
||||
password, hasPassword := sink.puts["env/PGPASSWORD"]
|
||||
if hasPassword != tt.wantPassword {
|
||||
t.Fatalf("PGPASSWORD stored = %v, want %v", hasPassword, tt.wantPassword)
|
||||
}
|
||||
if tt.wantPassword && len(password) != 48 {
|
||||
t.Errorf("PGPASSWORD = %q, want a 48-character hex password", password)
|
||||
}
|
||||
|
||||
var offered []string
|
||||
for _, sel := range p.selects {
|
||||
if sel.prompt == databasePrompt {
|
||||
offered = sel.options
|
||||
}
|
||||
}
|
||||
if tt.wantChoice {
|
||||
if offered == nil {
|
||||
t.Fatalf("no database choice was presented on a re-run; prompts seen: %+v", p.selects)
|
||||
}
|
||||
bundled := false
|
||||
for _, opt := range offered {
|
||||
if strings.Contains(strings.ToLower(opt), "bundled") {
|
||||
bundled = true
|
||||
}
|
||||
}
|
||||
if !bundled {
|
||||
t.Errorf("database choice options %v do not offer the bundled database", offered)
|
||||
}
|
||||
} else if offered != nil {
|
||||
t.Errorf("database choice was presented (%v) where the flow should not ask", offered)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,17 @@ func eventsFromRows(rows []postgresdb.Event) []events.Event {
|
||||
return out
|
||||
}
|
||||
|
||||
// TaskEvents returns a task's full timeline, oldest first.
|
||||
// TaskTranscript returns one attempt's agent transcript entries, oldest first.
|
||||
func (s *Store) TaskTranscript(ctx context.Context, taskID int64, attempt int) ([]events.Event, error) {
|
||||
rows, err := s.queries().TaskTranscript(ctx, postgresdb.TaskTranscriptParams{TaskID: taskID, Attempt: int64(attempt), ScopeOrg: scopeOrg(ctx)})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return eventsFromRows(rows), nil
|
||||
}
|
||||
|
||||
// TaskEvents returns a task's timeline without agent transcripts, oldest
|
||||
// first.
|
||||
func (s *Store) TaskEvents(ctx context.Context, taskID int64) ([]events.Event, error) {
|
||||
rows, err := s.queries().TaskEventsByID(ctx, postgresdb.TaskEventsByIDParams{TaskID: taskID, ScopeOrg: scopeOrg(ctx)})
|
||||
if err != nil {
|
||||
|
||||
@@ -228,7 +228,7 @@ func (q *Queries) StageStats(ctx context.Context, scopeOrg pgtype.Text) ([]Stage
|
||||
const taskEventsByID = `-- name: TaskEventsByID :many
|
||||
SELECT id, at, kind, task_id, repo, issue, workflow, stage, attempt, actor_id, actor_kind, principal_id, detail, data, org_id, workspace_id
|
||||
FROM events
|
||||
WHERE task_id = $1 AND ($2::text IS NULL OR org_id = $2)
|
||||
WHERE task_id = $1 AND kind <> 'agent_transcript' AND ($2::text IS NULL OR org_id = $2)
|
||||
ORDER BY id
|
||||
`
|
||||
|
||||
@@ -274,6 +274,56 @@ func (q *Queries) TaskEventsByID(ctx context.Context, arg TaskEventsByIDParams)
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const taskTranscript = `-- name: TaskTranscript :many
|
||||
SELECT id, at, kind, task_id, repo, issue, workflow, stage, attempt, actor_id, actor_kind, principal_id, detail, data, org_id, workspace_id
|
||||
FROM events
|
||||
WHERE task_id = $1 AND attempt = $2 AND kind = 'agent_transcript' AND ($3::text IS NULL OR org_id = $3)
|
||||
ORDER BY id
|
||||
`
|
||||
|
||||
type TaskTranscriptParams struct {
|
||||
TaskID int64
|
||||
Attempt int64
|
||||
ScopeOrg pgtype.Text
|
||||
}
|
||||
|
||||
func (q *Queries) TaskTranscript(ctx context.Context, arg TaskTranscriptParams) ([]Event, error) {
|
||||
rows, err := q.db.Query(ctx, taskTranscript, arg.TaskID, arg.Attempt, arg.ScopeOrg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Event
|
||||
for rows.Next() {
|
||||
var i Event
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.At,
|
||||
&i.Kind,
|
||||
&i.TaskID,
|
||||
&i.Repo,
|
||||
&i.Issue,
|
||||
&i.Workflow,
|
||||
&i.Stage,
|
||||
&i.Attempt,
|
||||
&i.ActorID,
|
||||
&i.ActorKind,
|
||||
&i.PrincipalID,
|
||||
&i.Detail,
|
||||
&i.Data,
|
||||
&i.OrgID,
|
||||
&i.WorkspaceID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const tokensByDay = `-- name: TokensByDay :many
|
||||
WITH event_totals AS (
|
||||
SELECT task_id, to_char(at AT TIME ZONE 'UTC', 'YYYY-MM-DD') AS day,
|
||||
|
||||
@@ -35,7 +35,13 @@ LIMIT sqlc.arg(page_limit);
|
||||
-- name: TaskEventsByID :many
|
||||
SELECT id, at, kind, task_id, repo, issue, workflow, stage, attempt, actor_id, actor_kind, principal_id, detail, data, org_id, workspace_id
|
||||
FROM events
|
||||
WHERE task_id = sqlc.arg(task_id) AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
|
||||
WHERE task_id = sqlc.arg(task_id) AND kind <> 'agent_transcript' AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
|
||||
ORDER BY id;
|
||||
|
||||
-- name: TaskTranscript :many
|
||||
SELECT id, at, kind, task_id, repo, issue, workflow, stage, attempt, actor_id, actor_kind, principal_id, detail, data, org_id, workspace_id
|
||||
FROM events
|
||||
WHERE task_id = sqlc.arg(task_id) AND attempt = sqlc.arg(attempt) AND kind = 'agent_transcript' AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
|
||||
ORDER BY id;
|
||||
|
||||
-- name: WorkflowStats :many
|
||||
|
||||
@@ -29,7 +29,13 @@ func (s *taskEventServer) EventsSince(ctx context.Context, r *pb.EventsSinceRequ
|
||||
}
|
||||
|
||||
func (s *taskEventServer) TaskEvents(ctx context.Context, r *pb.TaskEventsRequest) (*pb.TaskEventsResponse, error) {
|
||||
evs, err := s.deps.Tasks.TaskEvents(ctx, r.TaskId)
|
||||
var evs []events.Event
|
||||
var err error
|
||||
if r.Transcript {
|
||||
evs, err = s.deps.Tasks.TaskTranscript(ctx, r.TaskId, int(r.Attempt))
|
||||
} else {
|
||||
evs, err = s.deps.Tasks.TaskEvents(ctx, r.TaskId)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, s.logErr("TaskEvents", err)
|
||||
}
|
||||
@@ -59,3 +65,11 @@ func (c *Client) TaskEvents(ctx context.Context, taskID int64) ([]events.Event,
|
||||
}
|
||||
return mapValues(r.Events, eventValue), nil
|
||||
}
|
||||
|
||||
func (c *Client) TaskTranscript(ctx context.Context, taskID int64, attempt int) ([]events.Event, error) {
|
||||
r, err := c.taskEvent.TaskEvents(ctx, &pb.TaskEventsRequest{TaskId: taskID, Transcript: true, Attempt: int64(attempt)})
|
||||
if err != nil {
|
||||
return nil, unmapError(err)
|
||||
}
|
||||
return mapValues(r.Events, eventValue), nil
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package releaseupdate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// The canary host installs each release from the next channel. Its behaviour
|
||||
// in the 24 hours after a release is compared with its own behaviour in the
|
||||
// 24 hours before, because there's only one production host to compare with.
|
||||
const (
|
||||
// CanaryWindow is how long a release runs on the canary before it can be
|
||||
// promoted. A day covers one full cycle of schedules and traffic.
|
||||
CanaryWindow = 24 * time.Hour
|
||||
// canarySettle is how long the install and restart get, counted from when
|
||||
// the release was issued, before any check can fail the release.
|
||||
canarySettle = 30 * time.Minute
|
||||
// minFinished is the fewest finished tasks needed to judge the park rate.
|
||||
minFinished = 5
|
||||
// minLogCoverage is how far back into the baseline window the error log
|
||||
// must reach before error counts are compared.
|
||||
minLogCoverage = time.Hour
|
||||
)
|
||||
|
||||
// CanaryDecision is what the evaluation says to do with a release.
|
||||
type CanaryDecision string
|
||||
|
||||
const (
|
||||
CanaryWait CanaryDecision = "wait"
|
||||
CanaryPromote CanaryDecision = "promote"
|
||||
CanaryRollBack CanaryDecision = "roll back"
|
||||
)
|
||||
|
||||
// CanaryWindowSignals is one window's task and error-log counts.
|
||||
type CanaryWindowSignals struct {
|
||||
// Finished counts tasks that reached a terminal or review status; Bad
|
||||
// is those that parked or died.
|
||||
Finished, Bad int
|
||||
// Errors counts error-level log lines within Covered, the part of the
|
||||
// window that the log still reaches.
|
||||
Errors int
|
||||
Covered time.Duration
|
||||
}
|
||||
|
||||
// CanarySignals is what the canary reported at one check.
|
||||
type CanarySignals struct {
|
||||
Installed string
|
||||
Ready bool
|
||||
// NewActionAlerts are open action-severity alerts first raised since
|
||||
// the release was issued.
|
||||
NewActionAlerts []string
|
||||
Baseline CanaryWindowSignals
|
||||
Canary CanaryWindowSignals
|
||||
}
|
||||
|
||||
// CanaryVerdict is a decision and the signals that decided it.
|
||||
type CanaryVerdict struct {
|
||||
Decision CanaryDecision
|
||||
Reasons []string
|
||||
}
|
||||
|
||||
// JudgeCanary decides what to do with a release, given how long ago it was
|
||||
// issued. Once the release has settled, a failed hard check rolls it back at
|
||||
// any time. Error and park rates are compared with the baseline only after the
|
||||
// full window has passed.
|
||||
func JudgeCanary(version string, elapsed time.Duration, s CanarySignals) CanaryVerdict {
|
||||
if elapsed < canarySettle {
|
||||
return CanaryVerdict{Decision: CanaryWait, Reasons: []string{"settling after install"}}
|
||||
}
|
||||
var failed []string
|
||||
if s.Installed != version {
|
||||
failed = append(failed, fmt.Sprintf("canary runs %q, not %s: the install failed or was rolled back", s.Installed, version))
|
||||
}
|
||||
if !s.Ready {
|
||||
failed = append(failed, "readiness is degraded")
|
||||
}
|
||||
for _, alert := range s.NewActionAlerts {
|
||||
failed = append(failed, "new action alert: "+alert)
|
||||
}
|
||||
if len(failed) > 0 {
|
||||
return CanaryVerdict{Decision: CanaryRollBack, Reasons: failed}
|
||||
}
|
||||
if elapsed < CanaryWindow {
|
||||
return CanaryVerdict{Decision: CanaryWait, Reasons: []string{fmt.Sprintf("%s of %s elapsed", elapsed.Round(time.Minute), CanaryWindow)}}
|
||||
}
|
||||
var notes []string
|
||||
if reason, ok := judgeErrors(s.Baseline, s.Canary); !ok {
|
||||
failed = append(failed, reason)
|
||||
} else {
|
||||
notes = append(notes, reason)
|
||||
}
|
||||
if reason, ok := judgeParks(s.Baseline, s.Canary); !ok {
|
||||
failed = append(failed, reason)
|
||||
} else {
|
||||
notes = append(notes, reason)
|
||||
}
|
||||
if len(failed) > 0 {
|
||||
return CanaryVerdict{Decision: CanaryRollBack, Reasons: failed}
|
||||
}
|
||||
return CanaryVerdict{Decision: CanaryPromote, Reasons: notes}
|
||||
}
|
||||
|
||||
// judgeErrors fails when the canary logged more than twice the baseline's
|
||||
// error lines plus ten. Each count is scaled up to a full day when the log
|
||||
// covers only part of its window.
|
||||
func judgeErrors(baseline, canary CanaryWindowSignals) (string, bool) {
|
||||
if baseline.Covered < minLogCoverage || canary.Covered <= 0 {
|
||||
return "error log doesn't reach back over the baseline; error signal skipped", true
|
||||
}
|
||||
scale := func(w CanaryWindowSignals) float64 {
|
||||
return float64(w.Errors) * float64(CanaryWindow) / float64(w.Covered)
|
||||
}
|
||||
before, after := scale(baseline), scale(canary)
|
||||
limit := 2*before + 10
|
||||
if after > limit {
|
||||
return fmt.Sprintf("%.0f error log lines per day against a limit of %.0f (baseline %.0f)", after, limit, before), false
|
||||
}
|
||||
return fmt.Sprintf("%.0f error log lines per day, limit %.0f", after, limit), true
|
||||
}
|
||||
|
||||
// judgeParks fails when the share of finished tasks that parked or died rose
|
||||
// more than ten points over the baseline.
|
||||
func judgeParks(baseline, canary CanaryWindowSignals) (string, bool) {
|
||||
if canary.Finished < minFinished {
|
||||
return fmt.Sprintf("%d finished tasks, fewer than %d; park signal skipped", canary.Finished, minFinished), true
|
||||
}
|
||||
rate := func(w CanaryWindowSignals) float64 {
|
||||
if w.Finished == 0 {
|
||||
return 0
|
||||
}
|
||||
return float64(w.Bad) / float64(w.Finished)
|
||||
}
|
||||
before, after := rate(baseline), rate(canary)
|
||||
if after > before+0.10 {
|
||||
return fmt.Sprintf("%.0f%% of tasks parked or died against %.0f%% before", 100*after, 100*before), false
|
||||
}
|
||||
return fmt.Sprintf("%.0f%% of tasks parked or died, %.0f%% before", 100*after, 100*before), true
|
||||
}
|
||||
@@ -0,0 +1,330 @@
|
||||
package releaseupdate
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// CanaryDashboard reaches the canary through its dashboard API, the same
|
||||
// contract an operator uses: it reads the signals, edits the update settings
|
||||
// through the control plane and installs through the dashboard updater.
|
||||
type CanaryDashboard struct {
|
||||
URL string
|
||||
Token string
|
||||
HTTP *http.Client
|
||||
}
|
||||
|
||||
// Statuses a finished task can be in, and the subset that counts against a
|
||||
// release.
|
||||
var (
|
||||
finishedStatuses = map[string]bool{"completed": true, "merged": true, "pr_open": true, "rejected": true, "closed_wont_do": true, "parked": true, "dead": true}
|
||||
badStatuses = map[string]bool{"parked": true, "dead": true}
|
||||
)
|
||||
|
||||
const updateSettingsPath = "/api/control-plane/resources/update-settings"
|
||||
|
||||
// Signals reads the canary's current state. Tasks and error lines are split
|
||||
// into the day before the release was issued and the time since.
|
||||
func (d CanaryDashboard) Signals(ctx context.Context, issued, now time.Time) (CanarySignals, error) {
|
||||
var s CanarySignals
|
||||
var err error
|
||||
if s.Installed, _, err = d.installed(ctx); err != nil {
|
||||
return s, err
|
||||
}
|
||||
if s.Ready, err = d.ready(ctx); err != nil {
|
||||
return s, err
|
||||
}
|
||||
if s.NewActionAlerts, err = d.actionAlerts(ctx, issued); err != nil {
|
||||
return s, err
|
||||
}
|
||||
if err := d.tasks(ctx, issued, &s); err != nil {
|
||||
return s, err
|
||||
}
|
||||
return s, d.errors(ctx, issued, now, &s)
|
||||
}
|
||||
|
||||
// installed returns the daemon version the canary runs, and the raw update
|
||||
// snapshot it offers, which an install request must send back unchanged.
|
||||
func (d CanaryDashboard) installed(ctx context.Context) (string, json.RawMessage, error) {
|
||||
var body struct {
|
||||
Snapshot json.RawMessage `json:"snapshot"`
|
||||
}
|
||||
if _, err := d.call(ctx, http.MethodGet, "/api/chat/update", nil, &body); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
var snapshot Snapshot
|
||||
if err := json.Unmarshal(body.Snapshot, &snapshot); err != nil {
|
||||
return "", nil, fmt.Errorf("decode update snapshot: %w", err)
|
||||
}
|
||||
for _, c := range snapshot.Components {
|
||||
if c.ID == "daemon" {
|
||||
return c.Installed, body.Snapshot, nil
|
||||
}
|
||||
}
|
||||
return "", body.Snapshot, errors.New("canary reports no daemon version")
|
||||
}
|
||||
|
||||
func (d CanaryDashboard) ready(ctx context.Context) (bool, error) {
|
||||
var report struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
if _, err := d.call(ctx, http.MethodGet, "/health/detailed", nil, &report); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return report.Status == "ok", nil
|
||||
}
|
||||
|
||||
func (d CanaryDashboard) actionAlerts(ctx context.Context, since time.Time) ([]string, error) {
|
||||
var body struct {
|
||||
Alerts []struct {
|
||||
Severity string `json:"severity"`
|
||||
Title string `json:"title"`
|
||||
FirstRaised time.Time `json:"first_raised"`
|
||||
} `json:"alerts"`
|
||||
}
|
||||
if _, err := d.call(ctx, http.MethodGet, "/api/alerts", nil, &body); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var titles []string
|
||||
for _, a := range body.Alerts {
|
||||
if a.Severity == "action" && !a.FirstRaised.Before(since) {
|
||||
titles = append(titles, a.Title)
|
||||
}
|
||||
}
|
||||
return titles, nil
|
||||
}
|
||||
|
||||
// tasks reads tasks, newest update first, until it reaches tasks older than
|
||||
// the baseline window.
|
||||
func (d CanaryDashboard) tasks(ctx context.Context, issued time.Time, s *CanarySignals) error {
|
||||
from := issued.Add(-CanaryWindow)
|
||||
cursor := ""
|
||||
for range 50 {
|
||||
var page []struct {
|
||||
Status string `json:"status"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
path := "/api/tasks?limit=500"
|
||||
if cursor != "" {
|
||||
path += "&cursor=" + url.QueryEscape(cursor)
|
||||
}
|
||||
header, err := d.call(ctx, http.MethodGet, path, nil, &page)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, t := range page {
|
||||
if t.UpdatedAt.Before(from) || !finishedStatuses[t.Status] {
|
||||
continue
|
||||
}
|
||||
w := &s.Canary
|
||||
if t.UpdatedAt.Before(issued) {
|
||||
w = &s.Baseline
|
||||
}
|
||||
w.Finished++
|
||||
if badStatuses[t.Status] {
|
||||
w.Bad++
|
||||
}
|
||||
}
|
||||
cursor = header.Get("X-Next-Cursor")
|
||||
if cursor == "" || len(page) == 0 || page[len(page)-1].UpdatedAt.Before(from) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// errors counts error-level lines in each window. A log read returns a
|
||||
// limited number of lines, so a truncated read only reaches back as far as
|
||||
// its oldest line.
|
||||
func (d CanaryDashboard) errors(ctx context.Context, issued, now time.Time, s *CanarySignals) error {
|
||||
var body struct {
|
||||
Entries []struct {
|
||||
Time time.Time `json:"time"`
|
||||
} `json:"entries"`
|
||||
Truncated bool `json:"truncated"`
|
||||
}
|
||||
if _, err := d.call(ctx, http.MethodGet, "/api/logs?level=error&limit=2000", nil, &body); err != nil {
|
||||
return err
|
||||
}
|
||||
from := issued.Add(-CanaryWindow)
|
||||
if body.Truncated {
|
||||
from = now
|
||||
if len(body.Entries) > 0 {
|
||||
from = later(body.Entries[0].Time, issued.Add(-CanaryWindow))
|
||||
}
|
||||
}
|
||||
for _, e := range body.Entries {
|
||||
switch {
|
||||
case e.Time.Before(from):
|
||||
case e.Time.Before(issued):
|
||||
s.Baseline.Errors++
|
||||
default:
|
||||
s.Canary.Errors++
|
||||
}
|
||||
}
|
||||
s.Baseline.Covered = max(issued.Sub(from), 0)
|
||||
s.Canary.Covered = now.Sub(later(from, issued))
|
||||
return nil
|
||||
}
|
||||
|
||||
func later(a, b time.Time) time.Time {
|
||||
if a.After(b) {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Follow sets the canary's update channel, keeping its release source and
|
||||
// key. A pin is used only by exact-pin.
|
||||
func (d CanaryDashboard) Follow(ctx context.Context, channel, pin string) error {
|
||||
var current struct {
|
||||
Resource struct {
|
||||
Version int64 `json:"version"`
|
||||
Value json.RawMessage `json:"value"`
|
||||
} `json:"resource"`
|
||||
}
|
||||
if _, err := d.call(ctx, http.MethodGet, updateSettingsPath, nil, ¤t); err != nil {
|
||||
return err
|
||||
}
|
||||
value := map[string]any{}
|
||||
if len(current.Resource.Value) > 0 && string(current.Resource.Value) != "null" {
|
||||
if err := json.Unmarshal(current.Resource.Value, &value); err != nil {
|
||||
return fmt.Errorf("decode update settings: %w", err)
|
||||
}
|
||||
}
|
||||
value["channel"], value["pin"] = channel, pin
|
||||
_, err := d.call(ctx, http.MethodPost, updateSettingsPath+"/commands/replace",
|
||||
map[string]any{"value": value, "expected_version": current.Resource.Version}, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
// Channel is the canary's update channel and pin.
|
||||
func (d CanaryDashboard) Channel(ctx context.Context) (channel, pin string, err error) {
|
||||
var current struct {
|
||||
Resource struct {
|
||||
Value struct {
|
||||
Channel string `json:"channel"`
|
||||
Pin string `json:"pin"`
|
||||
} `json:"value"`
|
||||
} `json:"resource"`
|
||||
}
|
||||
if _, err := d.call(ctx, http.MethodGet, updateSettingsPath, nil, ¤t); err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
if current.Resource.Value.Channel == "" {
|
||||
return "stable", "", nil
|
||||
}
|
||||
return current.Resource.Value.Channel, current.Resource.Value.Pin, nil
|
||||
}
|
||||
|
||||
// Install has the canary install version through its updater and waits until
|
||||
// it reports running it. The install restarts the dashboard, so a dropped
|
||||
// connection after the request is sent is expected.
|
||||
func (d CanaryDashboard) Install(ctx context.Context, version string, wait time.Duration) error {
|
||||
deadline := time.Now().Add(wait)
|
||||
requested := false
|
||||
for {
|
||||
installed, snapshot, err := d.installed(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
// The dashboard drops off while the install restarts it.
|
||||
if !requested {
|
||||
return err
|
||||
}
|
||||
case installed == version:
|
||||
return nil
|
||||
case !requested:
|
||||
// The canary caches its registry lookup, so a release just
|
||||
// published can take a few minutes to be offered.
|
||||
offered, err := offers(snapshot, version)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if offered {
|
||||
_, err := d.call(ctx, http.MethodPost, "/api/chat/update/install", map[string]json.RawMessage{"snapshot": snapshot}, nil)
|
||||
if _, ok := errors.AsType[statusError](err); ok {
|
||||
return err
|
||||
}
|
||||
requested = true
|
||||
}
|
||||
}
|
||||
if !time.Now().Before(deadline) {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case <-time.After(15 * time.Second):
|
||||
}
|
||||
}
|
||||
if !requested {
|
||||
return fmt.Errorf("canary didn't offer %s within %s", version, wait)
|
||||
}
|
||||
return fmt.Errorf("canary didn't report %s within %s", version, wait)
|
||||
}
|
||||
|
||||
// offers reports whether an update snapshot offers version.
|
||||
func offers(snapshot json.RawMessage, version string) (bool, error) {
|
||||
var offered Snapshot
|
||||
if err := json.Unmarshal(snapshot, &offered); err != nil {
|
||||
return false, fmt.Errorf("decode update snapshot: %w", err)
|
||||
}
|
||||
available := offered.Available()
|
||||
return len(available) > 0 && available[0].Available == version, nil
|
||||
}
|
||||
|
||||
type statusError struct {
|
||||
code int
|
||||
body string
|
||||
}
|
||||
|
||||
func (e statusError) Error() string { return fmt.Sprintf("dashboard answered %d: %s", e.code, e.body) }
|
||||
|
||||
func (d CanaryDashboard) call(ctx context.Context, method, path string, in, out any) (http.Header, error) {
|
||||
var body io.Reader
|
||||
if in != nil {
|
||||
data, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
body = bytes.NewReader(data)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)
|
||||
defer cancel()
|
||||
req, err := http.NewRequestWithContext(ctx, method, strings.TrimRight(d.URL, "/")+path, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+d.Token)
|
||||
if in != nil {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
}
|
||||
client := d.HTTP
|
||||
if client == nil {
|
||||
client = http.DefaultClient
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s %s: %w", method, path, err)
|
||||
}
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
if resp.StatusCode/100 != 2 {
|
||||
text, _ := io.ReadAll(io.LimitReader(resp.Body, 512))
|
||||
return nil, fmt.Errorf("%s %s: %w", method, path, statusError{resp.StatusCode, strings.TrimSpace(string(text))})
|
||||
}
|
||||
if out == nil {
|
||||
return resp.Header, nil
|
||||
}
|
||||
if err := json.NewDecoder(resp.Body).Decode(out); err != nil {
|
||||
return nil, fmt.Errorf("%s %s: decode: %w", method, path, err)
|
||||
}
|
||||
return resp.Header, nil
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package releaseupdate
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// A release promotes only after a full window with no hard failure and no
|
||||
// relative signal past its threshold; any hard failure after settling rolls
|
||||
// it back at once.
|
||||
func TestJudgeCanary(t *testing.T) {
|
||||
healthy := func() CanarySignals {
|
||||
return CanarySignals{
|
||||
Installed: "1.1.0", Ready: true,
|
||||
Baseline: CanaryWindowSignals{Finished: 20, Bad: 2, Errors: 10, Covered: CanaryWindow},
|
||||
Canary: CanaryWindowSignals{Finished: 20, Bad: 2, Errors: 12, Covered: CanaryWindow},
|
||||
}
|
||||
}
|
||||
with := func(change func(*CanarySignals)) CanarySignals {
|
||||
s := healthy()
|
||||
change(&s)
|
||||
return s
|
||||
}
|
||||
cases := []struct {
|
||||
name string
|
||||
elapsed time.Duration
|
||||
signals CanarySignals
|
||||
want CanaryDecision
|
||||
}{
|
||||
{"settling ignores a failed check", 10 * time.Minute, with(func(s *CanarySignals) { s.Ready = false }), CanaryWait},
|
||||
{"healthy mid-window waits", 2 * time.Hour, healthy(), CanaryWait},
|
||||
{"healthy at the window promotes", CanaryWindow, healthy(), CanaryPromote},
|
||||
{"the watchdog rolled the install back", 2 * time.Hour, with(func(s *CanarySignals) { s.Installed = "1.0.0" }), CanaryRollBack},
|
||||
{"readiness degraded", 2 * time.Hour, with(func(s *CanarySignals) { s.Ready = false }), CanaryRollBack},
|
||||
{"a new action alert", 2 * time.Hour, with(func(s *CanarySignals) { s.NewActionAlerts = []string{"queue stalled"} }), CanaryRollBack},
|
||||
{"errors past twice the baseline plus ten", CanaryWindow, with(func(s *CanarySignals) { s.Canary.Errors = 31 }), CanaryRollBack},
|
||||
{"errors at the limit", CanaryWindow, with(func(s *CanarySignals) { s.Canary.Errors = 30 }), CanaryPromote},
|
||||
{"errors scaled from a partly covered log", CanaryWindow, with(func(s *CanarySignals) {
|
||||
s.Canary.Errors, s.Canary.Covered = 8, 6*time.Hour
|
||||
}), CanaryRollBack},
|
||||
{"a baseline the log doesn't reach skips errors", CanaryWindow, with(func(s *CanarySignals) {
|
||||
s.Baseline.Covered, s.Canary.Errors = 30*time.Minute, 500
|
||||
}), CanaryPromote},
|
||||
{"park rate up more than ten points", CanaryWindow, with(func(s *CanarySignals) { s.Canary.Bad = 5 }), CanaryRollBack},
|
||||
{"park rate up ten points", CanaryWindow, with(func(s *CanarySignals) { s.Canary.Bad = 4 }), CanaryPromote},
|
||||
{"too few tasks skips the park rate", CanaryWindow, with(func(s *CanarySignals) { s.Canary = CanaryWindowSignals{Finished: 4, Bad: 4, Covered: CanaryWindow} }), CanaryPromote},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got := JudgeCanary("1.1.0", tc.elapsed, tc.signals)
|
||||
if got.Decision != tc.want {
|
||||
t.Fatalf("decision = %s, want %s (%v)", got.Decision, tc.want, got.Reasons)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package releaseupdate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/ed25519"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"oras.land/oras-go/v2/errdef"
|
||||
"oras.land/oras-go/v2/registry/remote"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/distribution"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/signedoci"
|
||||
)
|
||||
|
||||
// Promote points the stable tag at a published release. The signature covers
|
||||
// the release statement, not the tag, so the release doesn't need signing
|
||||
// again. It refuses a prerelease, and a release issued before the one stable
|
||||
// already points at, which hosts would reject as a replay.
|
||||
//
|
||||
// Each image repository in latest gets its v<version> tag copied to latest
|
||||
// before stable moves, so if that fails stable is unchanged and running
|
||||
// Promote again finishes the job.
|
||||
func Promote(ctx context.Context, repository string, key ed25519.PublicKey, version string, latest []string) (Statement, error) {
|
||||
source := distribution.Source{Reference: repository, Key: key}
|
||||
release, err := Fetch(ctx, source, Tag("exact-pin", version))
|
||||
if err != nil {
|
||||
return Statement{}, err
|
||||
}
|
||||
if release.Statement.Prerelease {
|
||||
return Statement{}, fmt.Errorf("%s is a prerelease and never reaches stable", version)
|
||||
}
|
||||
current, err := Fetch(ctx, source, "stable")
|
||||
switch {
|
||||
case errors.Is(err, errdef.ErrNotFound):
|
||||
case err != nil:
|
||||
return Statement{}, err
|
||||
case release.Statement.IssuedAt.Before(current.Statement.IssuedAt):
|
||||
return Statement{}, fmt.Errorf("%s was issued before %s, which stable names", version, current.Statement.Version)
|
||||
}
|
||||
repo, err := pushRepository(repository)
|
||||
if err != nil {
|
||||
return Statement{}, err
|
||||
}
|
||||
desc, err := verifiedManifest(ctx, repo, version, release.Artifact.Statement, key)
|
||||
if err != nil {
|
||||
return Statement{}, err
|
||||
}
|
||||
for _, image := range latest {
|
||||
if err := promoteImage(ctx, image, version, release.Statement.AgentImage); err != nil {
|
||||
return Statement{}, err
|
||||
}
|
||||
}
|
||||
if err := repo.Tag(ctx, desc, "stable"); err != nil {
|
||||
return Statement{}, fmt.Errorf("tag stable: %w", err)
|
||||
}
|
||||
return release.Statement, nil
|
||||
}
|
||||
|
||||
// promoteImage tags image:v<version> as latest. The agent image must be the
|
||||
// one the statement pins, or latest would name an image the release never
|
||||
// signed for.
|
||||
func promoteImage(ctx context.Context, image, version, agentImage string) error {
|
||||
repo, err := pushRepository(image)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
desc, err := repo.Resolve(ctx, Tag("exact-pin", version))
|
||||
if err != nil {
|
||||
return fmt.Errorf("resolve %s:v%s: %w", image, version, err)
|
||||
}
|
||||
if pinned, digest, ok := strings.Cut(agentImage, "@"); ok && pinned == image && desc.Digest.String() != digest {
|
||||
return fmt.Errorf("%s:v%s is %s, not the %s the release pins", image, version, desc.Digest, digest)
|
||||
}
|
||||
if err := repo.Tag(ctx, desc, "latest"); err != nil {
|
||||
return fmt.Errorf("tag %s:latest: %w", image, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// verifiedManifest returns the manifest the version tag points at now, after
|
||||
// checking it carries the statement that was already verified. This stops a
|
||||
// tag that moved in the meantime from putting an unverified manifest on
|
||||
// stable.
|
||||
func verifiedManifest(ctx context.Context, repo *remote.Repository, version string, statement []byte, key ed25519.PublicKey) (ocispec.Descriptor, error) {
|
||||
desc, err := repo.Resolve(ctx, Tag("exact-pin", version))
|
||||
if err != nil {
|
||||
return ocispec.Descriptor{}, fmt.Errorf("resolve %s: %w", version, err)
|
||||
}
|
||||
stream, err := repo.Fetch(ctx, desc)
|
||||
if err != nil {
|
||||
return ocispec.Descriptor{}, fmt.Errorf("fetch %s manifest: %w", version, err)
|
||||
}
|
||||
raw, err := io.ReadAll(io.LimitReader(stream, desc.Size))
|
||||
_ = stream.Close()
|
||||
if err != nil {
|
||||
return ocispec.Descriptor{}, fmt.Errorf("read %s manifest: %w", version, err)
|
||||
}
|
||||
if digest.FromBytes(raw) != desc.Digest {
|
||||
return ocispec.Descriptor{}, fmt.Errorf("%s manifest doesn't match its digest", version)
|
||||
}
|
||||
var manifest ocispec.Manifest
|
||||
if err := json.Unmarshal(raw, &manifest); err != nil {
|
||||
return ocispec.Descriptor{}, fmt.Errorf("%s manifest: %w", version, err)
|
||||
}
|
||||
if err := signedoci.Verify(manifest, statement, key, Annotation); err != nil {
|
||||
return ocispec.Descriptor{}, fmt.Errorf("%s changed while promoting: %w", version, err)
|
||||
}
|
||||
return desc, nil
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package releaseupdate
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/distribution"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/signedoci"
|
||||
)
|
||||
|
||||
// stable moves only to a signed, non-prerelease release issued no earlier
|
||||
// than the one it names, and it moves to the very manifest that was verified.
|
||||
func TestPromote(t *testing.T) {
|
||||
trusted, signer, _ := ed25519.GenerateKey(nil)
|
||||
_, stranger, _ := ed25519.GenerateKey(nil)
|
||||
jan1, jan2 := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC), time.Date(2026, 1, 2, 0, 0, 0, 0, time.UTC)
|
||||
type published struct {
|
||||
version string
|
||||
issued time.Time
|
||||
prerelease bool
|
||||
signer ed25519.PrivateKey
|
||||
tags []string
|
||||
}
|
||||
cases := []struct {
|
||||
name string
|
||||
release []published
|
||||
promote string
|
||||
want string // error substring, or "" when stable must name promote
|
||||
}{
|
||||
{name: "a newer release", release: []published{{"1.0.0", jan1, false, signer, []string{"stable"}}, {"1.1.0", jan2, false, signer, []string{"next"}}}, promote: "1.1.0"},
|
||||
{name: "the first release", release: []published{{"1.0.0", jan1, false, signer, []string{"next"}}}, promote: "1.0.0"},
|
||||
{name: "a release issued before stable", release: []published{{"1.1.0", jan2, false, signer, []string{"stable"}}, {"1.0.0", jan1, false, signer, nil}}, promote: "1.0.0", want: "issued before"},
|
||||
{name: "a prerelease", release: []published{{"1.1.0-rc.1", jan2, true, signer, []string{"next"}}}, promote: "1.1.0-rc.1", want: "prerelease"},
|
||||
{name: "a release another key signed", release: []published{{"1.1.0", jan2, false, stranger, []string{"next"}}}, promote: "1.1.0", want: "signature"},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Setenv("XDG_STATE_HOME", t.TempDir())
|
||||
t.Setenv("DOCKER_CONFIG", t.TempDir())
|
||||
registry := newMemoryRegistry()
|
||||
server := httptest.NewServer(registry)
|
||||
defer server.Close()
|
||||
for _, r := range tc.release {
|
||||
registry.publish(t, r.version, r.issued, r.prerelease, r.signer, r.tags...)
|
||||
}
|
||||
repository := strings.TrimPrefix(server.URL, "http://") + "/archie"
|
||||
_, err := Promote(t.Context(), repository, trusted, tc.promote, nil)
|
||||
switch {
|
||||
case tc.want == "" && err != nil:
|
||||
t.Fatalf("Promote: %v", err)
|
||||
case tc.want != "" && (err == nil || !strings.Contains(err.Error(), tc.want)):
|
||||
t.Fatalf("Promote error = %v, want %q", err, tc.want)
|
||||
}
|
||||
stable, ok := registry.statement("stable")
|
||||
promoted := ok && stable.Version == tc.promote
|
||||
if promoted != (tc.want == "") {
|
||||
t.Fatalf("stable names %q (found %v) after promoting %s", stable.Version, ok, tc.promote)
|
||||
}
|
||||
if tc.want == "" {
|
||||
if _, err := Fetch(t.Context(), distribution.Source{Reference: repository, Key: trusted}, "stable"); err != nil {
|
||||
t.Fatalf("hosts refuse the promoted stable: %v", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// memoryRegistry serves manifests by tag or digest and accepts manifest
|
||||
// pushes, which is all fetching and retagging a release needs.
|
||||
type memoryRegistry struct {
|
||||
mu sync.Mutex
|
||||
manifests map[string][]byte
|
||||
blobs map[string][]byte
|
||||
}
|
||||
|
||||
func newMemoryRegistry() *memoryRegistry {
|
||||
return &memoryRegistry{manifests: map[string][]byte{}, blobs: map[string][]byte{}}
|
||||
}
|
||||
|
||||
func (m *memoryRegistry) publish(t *testing.T, version string, issued time.Time, prerelease bool, signer ed25519.PrivateKey, tags ...string) {
|
||||
t.Helper()
|
||||
archive := []byte("zip " + version)
|
||||
statement, err := json.Marshal(Statement{
|
||||
Version: version, Prerelease: prerelease, IssuedAt: issued, Platform: Platform, AgentImage: newImage,
|
||||
Zip: Blob{Name: ZipName(version), Digest: signedoci.Digest(archive), Size: int64(len(archive))},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
manifest, err := json.Marshal(ocispec.Manifest{
|
||||
SchemaVersion: 2, MediaType: ocispec.MediaTypeImageManifest, ArtifactType: ArtifactType, Config: ocispec.DescriptorEmptyJSON,
|
||||
Layers: []ocispec.Descriptor{
|
||||
{MediaType: StatementMediaType, Digest: digest.FromBytes(statement), Size: int64(len(statement))},
|
||||
{MediaType: "application/zip", Digest: digest.FromBytes(archive), Size: int64(len(archive))},
|
||||
},
|
||||
Annotations: map[string]string{Annotation: base64.StdEncoding.EncodeToString(ed25519.Sign(signer, statement))},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.blobs[signedoci.Digest(statement)], m.blobs[signedoci.Digest(archive)] = statement, archive
|
||||
m.manifests[signedoci.Digest(manifest)] = manifest
|
||||
for _, tag := range append(tags, "v"+version) {
|
||||
m.manifests[tag] = manifest
|
||||
}
|
||||
}
|
||||
|
||||
func (m *memoryRegistry) statement(tag string) (Statement, bool) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
var manifest ocispec.Manifest
|
||||
if json.Unmarshal(m.manifests[tag], &manifest) != nil || len(manifest.Layers) == 0 {
|
||||
return Statement{}, false
|
||||
}
|
||||
var s Statement
|
||||
return s, json.Unmarshal(m.blobs[manifest.Layers[0].Digest.String()], &s) == nil
|
||||
}
|
||||
|
||||
func (m *memoryRegistry) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if ref, ok := strings.CutPrefix(r.URL.Path, "/v2/archie/blobs/"); ok {
|
||||
blob, found := m.blobs[ref]
|
||||
if !found {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
_, _ = w.Write(blob)
|
||||
return
|
||||
}
|
||||
ref, ok := strings.CutPrefix(r.URL.Path, "/v2/archie/manifests/")
|
||||
if !ok {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if r.Method == http.MethodPut {
|
||||
body, _ := io.ReadAll(r.Body)
|
||||
m.manifests[ref], m.manifests[signedoci.Digest(body)] = body, body
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
return
|
||||
}
|
||||
manifest, found := m.manifests[ref]
|
||||
if !found {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", ocispec.MediaTypeImageManifest)
|
||||
w.Header().Set("Docker-Content-Digest", signedoci.Digest(manifest))
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(manifest)))
|
||||
if r.Method != http.MethodHead {
|
||||
_, _ = w.Write(manifest)
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,20 @@ func RedactString(value string) string {
|
||||
return value
|
||||
}
|
||||
|
||||
// pemPrivateKeyRe matches a PEM private-key block, header to footer.
|
||||
var pemPrivateKeyRe = regexp.MustCompile(`-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----`)
|
||||
|
||||
// RedactText replaces each secret-shaped span inside free text, keeping the
|
||||
// rest, for long text such as tool output where blanking the whole value would
|
||||
// hide everything around the secret.
|
||||
func RedactText(value string) string {
|
||||
if len(value) < 20 {
|
||||
return value
|
||||
}
|
||||
value = jwtTokenRe.ReplaceAllString(value, redactedValue)
|
||||
return pemPrivateKeyRe.ReplaceAllString(value, redactedValue)
|
||||
}
|
||||
|
||||
func redactValue(value any) any {
|
||||
switch typed := value.(type) {
|
||||
case map[string]any:
|
||||
|
||||
+161
-4
@@ -2,8 +2,15 @@ package webui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/identity"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
)
|
||||
@@ -23,6 +30,44 @@ type ModelReader interface {
|
||||
CallerModels(ctx context.Context) (org string, aliases map[string]string, err error)
|
||||
}
|
||||
|
||||
// The control-plane resources the effective-model read layers: the org's own
|
||||
// providers and the credential bindings that carry their keys. Spelled here
|
||||
// rather than imported so the dashboard package stays a leaf, as
|
||||
// api_harness.go does for "credential-bindings".
|
||||
const (
|
||||
providerSettingsKind = "provider-settings"
|
||||
credentialBindingsKind = "credential-bindings"
|
||||
)
|
||||
|
||||
// providerDoc is the part of one provider-settings entry the read needs: where
|
||||
// the provider's key comes from.
|
||||
type providerDoc struct {
|
||||
Class string `json:"class"`
|
||||
APIKeyEnv string `json:"api_key_env,omitempty"`
|
||||
APIKeyRef config.SecretRef `json:"api_key_ref"`
|
||||
}
|
||||
|
||||
// credentialBindingDoc is the part of one credential-bindings entry the read
|
||||
// needs: the org secret the service's key resolves through.
|
||||
type credentialBindingDoc struct {
|
||||
Service string `json:"service"`
|
||||
Secret config.SecretRef `json:"secret"`
|
||||
}
|
||||
|
||||
// effectiveModel is one model alias the caller's org may use, with the state
|
||||
// of the provider credential it runs on. An alias whose provider's credential
|
||||
// is missing or does not resolve cannot run a task, so the Model setup step
|
||||
// stays open and names it.
|
||||
type effectiveModel struct {
|
||||
Alias string
|
||||
Model string
|
||||
Provider string
|
||||
// Credential reports that the provider's credential is present and
|
||||
// resolves; Detail names what is missing when it does not.
|
||||
Credential bool
|
||||
Detail string
|
||||
}
|
||||
|
||||
// handleSetup reports which setup steps are still missing in the caller's
|
||||
// organisation, from live state. Optional capabilities (a chat channel, a
|
||||
// repository) are set up where they are used, not listed here.
|
||||
@@ -43,15 +88,127 @@ func (s *Server) handleSetup(w http.ResponseWriter, r *http.Request) {
|
||||
steps = append(steps, SetupStep{Title: "First task", Done: total > 0, Path: "/tasks"})
|
||||
}
|
||||
if s.Models != nil {
|
||||
// Shown only while the org has no model to run, so a working setup
|
||||
// carries no extra step.
|
||||
if _, aliases, err := s.Models.CallerModels(r.Context()); err == nil && len(aliases) == 0 {
|
||||
steps = append(steps, SetupStep{Title: "Model", Path: "/org/models"})
|
||||
// Shown only while the org has no runnable model, so a working setup
|
||||
// carries no extra step: an alias whose provider credential does not
|
||||
// resolve is no more runnable than no alias at all.
|
||||
if models, err := s.callerEffectiveModels(r.Context()); err == nil {
|
||||
if step, open := modelSetupStep(models); open {
|
||||
steps = append(steps, step)
|
||||
}
|
||||
}
|
||||
}
|
||||
writeJSON(w, map[string]any{"steps": steps})
|
||||
}
|
||||
|
||||
// modelSetupStep is the Model checklist step for the caller's effective
|
||||
// models. The step stays open until every alias's provider credential
|
||||
// resolves; its detail names the credential that does not.
|
||||
func modelSetupStep(models []effectiveModel) (SetupStep, bool) {
|
||||
if len(models) == 0 {
|
||||
return SetupStep{Title: "Model", Path: "/org/models", Detail: "no model alias configured"}, true
|
||||
}
|
||||
for _, model := range models {
|
||||
if !model.Credential {
|
||||
return SetupStep{Title: "Model", Path: "/org/models", Detail: model.Detail}, true
|
||||
}
|
||||
}
|
||||
return SetupStep{}, false
|
||||
}
|
||||
|
||||
// callerEffectiveModels reads the caller's effective models: the aliases the
|
||||
// org may use, each with the validity of the provider credential it runs on.
|
||||
// The credential surfaces are optional; without them the read reports the
|
||||
// aliases alone with every credential taken as valid.
|
||||
func (s *Server) callerEffectiveModels(ctx context.Context) ([]effectiveModel, error) {
|
||||
_, aliases, err := s.Models.CallerModels(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
models := make([]effectiveModel, 0, len(aliases))
|
||||
for _, alias := range slices.Sorted(maps.Keys(aliases)) {
|
||||
provider, _, _ := strings.Cut(aliases[alias], "/")
|
||||
models = append(models, effectiveModel{Alias: alias, Model: aliases[alias], Provider: provider, Credential: true})
|
||||
}
|
||||
if s.ControlPlane == nil || s.CheckSecret == nil || len(models) == 0 {
|
||||
return models, nil
|
||||
}
|
||||
orgID := string(org.OrgFromContext(ctx))
|
||||
var providers map[string]providerDoc
|
||||
if err := s.queryResourceValue(ctx, providerSettingsKind, &providers); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if providers == nil {
|
||||
providers = map[string]providerDoc{}
|
||||
}
|
||||
var bindings []credentialBindingDoc
|
||||
if err := s.queryResourceValue(ctx, credentialBindingsKind, &bindings); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range models {
|
||||
models[i].Credential, models[i].Detail = s.providerCredential(ctx, orgID, models[i].Provider, providers, bindings)
|
||||
}
|
||||
return models, nil
|
||||
}
|
||||
|
||||
// queryResourceValue decodes one control-plane resource of the caller's org
|
||||
// into into; an absent resource leaves into untouched.
|
||||
func (s *Server) queryResourceValue(ctx context.Context, kind string, into any) error {
|
||||
response, err := s.ControlPlane.Query(ctx, &controlpb.QueryRequest{Kind: kind})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if response.Resource == nil || len(response.Resource.ValueJson) == 0 {
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(response.Resource.ValueJson, into)
|
||||
}
|
||||
|
||||
// providerCredential reports whether provider's credential is present and
|
||||
// resolves for orgID, and names what is missing when it does not. The key
|
||||
// comes from the provider's own api_key_ref, or from the org's credential
|
||||
// binding named after the provider, or from its api_key_env; a binding with no
|
||||
// secret is OAuth, whose credential is the captured token set. A provider
|
||||
// that is not the org's own and has no binding is an instance provider: its
|
||||
// credential is the instance admin's, not this org's to configure.
|
||||
func (s *Server) providerCredential(ctx context.Context, orgID, provider string, providers map[string]providerDoc, bindings []credentialBindingDoc) (bool, string) {
|
||||
doc, own := providers[provider]
|
||||
if own && doc.APIKeyRef != (config.SecretRef{}) {
|
||||
return s.secretCredential(ctx, provider, doc.APIKeyRef)
|
||||
}
|
||||
for _, binding := range bindings {
|
||||
if binding.Service != provider {
|
||||
continue
|
||||
}
|
||||
if binding.Secret != (config.SecretRef{}) {
|
||||
return s.secretCredential(ctx, provider, binding.Secret)
|
||||
}
|
||||
if s.HarnessSecrets != nil {
|
||||
if token, err := s.HarnessSecrets.GetHarnessSecret(ctx, orgID, provider); err == nil && token.Validate() == nil {
|
||||
return true, ""
|
||||
}
|
||||
return false, fmt.Sprintf("provider %q has no captured sign-in for credential binding %q", provider, provider)
|
||||
}
|
||||
return false, fmt.Sprintf("credential binding %q names no secret and no sign-in is captured", provider)
|
||||
}
|
||||
if own {
|
||||
if doc.APIKeyEnv != "" {
|
||||
return s.secretCredential(ctx, provider, config.SecretRef{Engine: "env", Key: doc.APIKeyEnv})
|
||||
}
|
||||
return false, fmt.Sprintf("provider %q declares no credential: set its api_key_ref or add a credential binding named %q", provider, provider)
|
||||
}
|
||||
return true, ""
|
||||
}
|
||||
|
||||
// secretCredential reports whether ref resolves through the gateway's secret
|
||||
// engines, naming the reference when it does not.
|
||||
func (s *Server) secretCredential(ctx context.Context, provider string, ref config.SecretRef) (bool, string) {
|
||||
resolved, err := s.CheckSecret(ctx, ref)
|
||||
if err == nil && resolved {
|
||||
return true, ""
|
||||
}
|
||||
return false, fmt.Sprintf("provider %q credential %s:%s does not resolve", provider, ref.Engine, ref.Key)
|
||||
}
|
||||
|
||||
// hasActiveAgent reports whether the caller's org has an active bot or
|
||||
// service account assigned; ok is false when that cannot be read.
|
||||
func (s *Server) hasActiveAgent(r *http.Request) (done, ok bool) {
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
package webui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/harnesssecret"
|
||||
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
||||
"github.com/samcharles93/archie-core/internal/secret"
|
||||
)
|
||||
|
||||
type setupStore struct {
|
||||
storecontract.TaskStore
|
||||
}
|
||||
|
||||
func (setupStore) StatusCounts(context.Context) (map[string]int, error) {
|
||||
return map[string]int{"done": 1}, nil
|
||||
}
|
||||
|
||||
type setupModels struct {
|
||||
aliases map[string]string
|
||||
err error
|
||||
}
|
||||
|
||||
func (m setupModels) CallerModels(context.Context) (string, map[string]string, error) {
|
||||
return "org", m.aliases, m.err
|
||||
}
|
||||
|
||||
// setupControl answers provider-settings and credential-bindings queries from
|
||||
// fixed documents, the way the State Store would for one org.
|
||||
type setupControl struct {
|
||||
controlpb.ControlPlaneServiceClient
|
||||
providers string
|
||||
bindings string
|
||||
}
|
||||
|
||||
func (c setupControl) Query(_ context.Context, r *controlpb.QueryRequest, _ ...grpc.CallOption) (*controlpb.QueryResponse, error) {
|
||||
var value string
|
||||
switch r.Kind {
|
||||
case providerSettingsKind:
|
||||
value = c.providers
|
||||
case credentialBindingsKind:
|
||||
value = c.bindings
|
||||
default:
|
||||
value = "null"
|
||||
}
|
||||
return &controlpb.QueryResponse{Resource: &controlpb.Resource{Kind: r.Kind, ValueJson: []byte(value)}}, nil
|
||||
}
|
||||
|
||||
type setupHarnessSecrets struct {
|
||||
storecontract.HarnessSecretStore
|
||||
tokens map[string]harnesssecret.Secret
|
||||
}
|
||||
|
||||
func (h setupHarnessSecrets) GetHarnessSecret(_ context.Context, _, service string) (harnesssecret.Secret, error) {
|
||||
if token, ok := h.tokens[service]; ok {
|
||||
return token, nil
|
||||
}
|
||||
return harnesssecret.Secret{}, storecontract.ErrHarnessSecretNotFound
|
||||
}
|
||||
|
||||
func setupRequest(t *testing.T, srv *Server) []SetupStep {
|
||||
t.Helper()
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/setup", nil)
|
||||
response := httptest.NewRecorder()
|
||||
srv.handleSetup(response, req)
|
||||
if response.Code != http.StatusOK {
|
||||
t.Fatalf("response = %d %s", response.Code, response.Body.String())
|
||||
}
|
||||
var body struct {
|
||||
Steps []SetupStep `json:"steps"`
|
||||
}
|
||||
if err := json.Unmarshal(response.Body.Bytes(), &body); err != nil {
|
||||
t.Fatalf("decode response %q: %v", response.Body.String(), err)
|
||||
}
|
||||
return body.Steps
|
||||
}
|
||||
|
||||
func modelStep(steps []SetupStep) *SetupStep {
|
||||
for i := range steps {
|
||||
if steps[i].Title == "Model" {
|
||||
return &steps[i]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestHandleSetupModelStep(t *testing.T) {
|
||||
resolving := func(_ context.Context, ref secret.SecretRef) (bool, error) {
|
||||
return ref == (secret.SecretRef{Engine: "env", Key: "GOOD_KEY"}), nil
|
||||
}
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
aliases map[string]string
|
||||
providers string
|
||||
bindings string
|
||||
tokens map[string]harnesssecret.Secret
|
||||
check func(context.Context, secret.SecretRef) (bool, error)
|
||||
open bool
|
||||
detail string
|
||||
}{
|
||||
{
|
||||
name: "no aliases leaves the step open",
|
||||
aliases: map[string]string{},
|
||||
open: true,
|
||||
detail: "no model alias configured",
|
||||
},
|
||||
{
|
||||
name: "resolving api_key_ref completes the step",
|
||||
aliases: map[string]string{"default": "openai/gpt-5"},
|
||||
providers: `{"openai":{"class":"openai","api_key_ref":{"engine":"env","key":"GOOD_KEY"}}}`,
|
||||
check: resolving,
|
||||
open: false,
|
||||
},
|
||||
{
|
||||
name: "unresolving api_key_ref keeps the step open and names it",
|
||||
aliases: map[string]string{"default": "openai/gpt-5"},
|
||||
providers: `{"openai":{"class":"openai","api_key_ref":{"engine":"env","key":"BAD_KEY"}}}`,
|
||||
check: resolving,
|
||||
open: true,
|
||||
detail: `provider "openai" credential env:BAD_KEY does not resolve`,
|
||||
},
|
||||
{
|
||||
name: "provider declaring no credential keeps the step open",
|
||||
aliases: map[string]string{"default": "openai/gpt-5"},
|
||||
providers: `{"openai":{"class":"openai"}}`,
|
||||
check: resolving,
|
||||
open: true,
|
||||
detail: `provider "openai" declares no credential`,
|
||||
},
|
||||
{
|
||||
name: "credential binding secret resolves for an org provider",
|
||||
aliases: map[string]string{"default": "acme/gpt-5"},
|
||||
providers: `{"acme":{"class":"openai"}}`,
|
||||
bindings: `[{"service":"acme","secret":{"engine":"env","key":"GOOD_KEY"}}]`,
|
||||
check: resolving,
|
||||
open: false,
|
||||
},
|
||||
{
|
||||
name: "credential binding secret that does not resolve keeps the step open",
|
||||
aliases: map[string]string{"default": "acme/gpt-5"},
|
||||
providers: `{"acme":{"class":"openai"}}`,
|
||||
bindings: `[{"service":"acme","secret":{"engine":"env","key":"BAD_KEY"}}]`,
|
||||
check: resolving,
|
||||
open: true,
|
||||
detail: `provider "acme" credential env:BAD_KEY does not resolve`,
|
||||
},
|
||||
{
|
||||
name: "org provider without a binding keeps the step open",
|
||||
aliases: map[string]string{"default": "acme/gpt-5"},
|
||||
providers: `{"acme":{"class":"openai"}}`,
|
||||
check: resolving,
|
||||
open: true,
|
||||
detail: `provider "acme" declares no credential`,
|
||||
},
|
||||
{
|
||||
name: "instance provider is not the org's credential to configure",
|
||||
aliases: map[string]string{"default": "shared/gpt-5"},
|
||||
providers: `{}`,
|
||||
check: resolving,
|
||||
open: false,
|
||||
},
|
||||
{
|
||||
name: "oauth binding with a captured token set completes the step",
|
||||
aliases: map[string]string{"default": "acme/gpt-5"},
|
||||
providers: `{"acme":{"class":"openai"}}`,
|
||||
bindings: `[{"service":"acme"}]`,
|
||||
tokens: map[string]harnesssecret.Secret{"acme": {Org: "org", Service: "acme", AccessToken: "token"}},
|
||||
check: resolving,
|
||||
open: false,
|
||||
},
|
||||
{
|
||||
name: "oauth binding without a captured token set keeps the step open",
|
||||
aliases: map[string]string{"default": "acme/gpt-5"},
|
||||
providers: `{"acme":{"class":"openai"}}`,
|
||||
bindings: `[{"service":"acme"}]`,
|
||||
tokens: map[string]harnesssecret.Secret{},
|
||||
check: resolving,
|
||||
open: true,
|
||||
detail: `provider "acme" has no captured sign-in for credential binding "acme"`,
|
||||
},
|
||||
{
|
||||
name: "api_key_env resolves through the env engine",
|
||||
aliases: map[string]string{"default": "openai/gpt-5"},
|
||||
providers: `{"openai":{"class":"openai","api_key_env":"GOOD_KEY"}}`,
|
||||
check: resolving,
|
||||
open: false,
|
||||
},
|
||||
{
|
||||
name: "without the control plane the aliases alone decide",
|
||||
aliases: map[string]string{"default": "openai/gpt-5"},
|
||||
check: resolving,
|
||||
open: false,
|
||||
},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
srv := &Server{Store: setupStore{}, Models: setupModels{aliases: tt.aliases}}
|
||||
if tt.providers != "" || tt.bindings != "" {
|
||||
srv.ControlPlane = setupControl{providers: tt.providers, bindings: tt.bindings}
|
||||
}
|
||||
srv.CheckSecret = tt.check
|
||||
if tt.tokens != nil {
|
||||
srv.HarnessSecrets = setupHarnessSecrets{tokens: tt.tokens}
|
||||
}
|
||||
step := modelStep(setupRequest(t, srv))
|
||||
if !tt.open {
|
||||
if step != nil {
|
||||
t.Fatalf("Model step = %+v, want it complete (absent)", *step)
|
||||
}
|
||||
return
|
||||
}
|
||||
if step == nil {
|
||||
t.Fatalf("Model step absent, want it open with detail %q", tt.detail)
|
||||
}
|
||||
if step.Done {
|
||||
t.Fatalf("Model step done, want it open")
|
||||
}
|
||||
if !strings.Contains(step.Detail, tt.detail) {
|
||||
t.Fatalf("Model step detail = %q, want it to contain %q", step.Detail, tt.detail)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package webui
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/events"
|
||||
)
|
||||
|
||||
// taskTranscriptView is GET /api/tasks/{id}/transcript: one attempt's agent
|
||||
// transcript entries, oldest first.
|
||||
type taskTranscriptView struct {
|
||||
TaskID int64 `json:"task_id"`
|
||||
Attempt int `json:"attempt"`
|
||||
Entries []events.Event `json:"entries"`
|
||||
}
|
||||
|
||||
func (s *Server) handleTaskTranscript(w http.ResponseWriter, r *http.Request) {
|
||||
t, attempt, ok := s.taskAttemptTarget(w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
entries, err := s.Store.TaskTranscript(r.Context(), t.ID, attempt)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if entries == nil {
|
||||
entries = []events.Event{}
|
||||
}
|
||||
writeJSON(w, taskTranscriptView{TaskID: t.ID, Attempt: attempt, Entries: entries})
|
||||
}
|
||||
@@ -86,6 +86,7 @@ func TestHTTPPolicyCannotBeBypassed(t *testing.T) {
|
||||
{"GET", "/api/tasks/7/logs"},
|
||||
{"GET", "/api/tasks/7/logs/download"},
|
||||
{"GET", "/api/tasks/7/sandbox"},
|
||||
{"GET", "/api/tasks/7/transcript"},
|
||||
{"GET", "/api/tokens"},
|
||||
{"GET", "/api/version"},
|
||||
{"GET", "/api/workflows"},
|
||||
|
||||
@@ -320,6 +320,7 @@ func (s *Server) registerTaskRoutes(mux *http.ServeMux) {
|
||||
mux.HandleFunc("GET /api/tasks/{id}/changes", s.handleTaskChanges)
|
||||
mux.HandleFunc("GET /api/tasks/{id}/debug", s.handleTaskDebug)
|
||||
mux.HandleFunc("GET /api/tasks/{id}/logs", s.handleTaskLogs)
|
||||
mux.HandleFunc("GET /api/tasks/{id}/transcript", s.handleTaskTranscript)
|
||||
mux.HandleFunc("GET /api/tasks/{id}/sandbox", s.handleTaskSandbox)
|
||||
mux.HandleFunc("GET /api/tasks/{id}/logs/download", s.handleTaskLogDownload)
|
||||
}
|
||||
|
||||
@@ -22,5 +22,11 @@ message EventsSinceRequest {
|
||||
int64 limit = 2;
|
||||
}
|
||||
message EventsSinceResponse { repeated Event events = 1; }
|
||||
message TaskEventsRequest { int64 task_id = 1; }
|
||||
message TaskEventsRequest {
|
||||
int64 task_id = 1;
|
||||
// transcript selects the agent_transcript entries of one attempt instead of
|
||||
// the timeline, which leaves them out.
|
||||
bool transcript = 2;
|
||||
int64 attempt = 3;
|
||||
}
|
||||
message TaskEventsResponse { repeated Event events = 1; }
|
||||
@@ -1,217 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Cuts a release in two steps, so the generated notes can be edited before
|
||||
# they are frozen into a tag -- the same review window release-please gives
|
||||
# you with its release PR.
|
||||
#
|
||||
# tools/release.sh --version 1.2.0 --dry-run # preview
|
||||
# tools/release.sh --version 1.2.0 --prepare # write, then edit
|
||||
# tools/release.sh --version 1.2.0 --tag # commit + tag
|
||||
#
|
||||
# There is one release stream: CHANGELOG.md carries every release section,
|
||||
# one generated page per version, and one tag names the release. A release is
|
||||
# one version covering whatever changed; per-component detail is a labelled
|
||||
# section inside it, not a separate number.
|
||||
#
|
||||
# Exit codes: 0 released (or previewed/prepared); 1 failure; 3 nothing to
|
||||
# release -- a commit set that justifies no version is a result, not an error,
|
||||
# so a pipeline can finish green without tagging.
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
NOTHING_TO_RELEASE=3
|
||||
MODE=""
|
||||
VERSION=""
|
||||
|
||||
die() {
|
||||
echo "release: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--version) VERSION="${2:-}"; shift 2 ;;
|
||||
--dry-run) MODE="dry-run"; shift ;;
|
||||
--prepare) MODE="prepare"; shift ;;
|
||||
--tag) MODE="tag"; shift ;;
|
||||
*) die "unknown argument: $1" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$VERSION" ] || die "--version <version> is required"
|
||||
[ -n "$MODE" ] || die "one of --dry-run, --prepare or --tag is required"
|
||||
|
||||
if [ "$MODE" != "dry-run" ]; then
|
||||
branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||
[ "$branch" = "main" ] || die "releases are cut from main, not $branch"
|
||||
fi
|
||||
if [ "$MODE" = "prepare" ]; then
|
||||
[ -z "$(git status --porcelain)" ] || die "working tree is dirty; commit or stash first"
|
||||
fi
|
||||
|
||||
# component_dirs <cmd-path> -- repo-relative dirs of every package the binary
|
||||
# links, plus the files that build only that binary. go.mod and go.sum pin the
|
||||
# dependencies every binary links, so a dependency bump changes them all.
|
||||
component_dirs() {
|
||||
go list -deps -f '{{.Dir}}' "$1" 2>/dev/null |
|
||||
grep -F "$PWD/" |
|
||||
sed "s|^$PWD/||"
|
||||
printf '%s\n' go.mod go.sum
|
||||
}
|
||||
|
||||
# matches <changed-files> <dirs> -- true when any changed file lives in one
|
||||
# of the component's directories.
|
||||
matches() {
|
||||
local files="$1" dirs="$2" f d
|
||||
while read -r f; do
|
||||
[ -n "$f" ] || continue
|
||||
while read -r d; do
|
||||
[ -n "$d" ] || continue
|
||||
case "$f" in
|
||||
"$d"/*) return 0 ;;
|
||||
"$d") return 0 ;;
|
||||
esac
|
||||
done <<<"$dirs"
|
||||
done <<<"$files"
|
||||
return 1
|
||||
}
|
||||
|
||||
# The host bundle IS the archied artifact: the distribution zip is named and
|
||||
# versioned by the release, and every process it ships carries that version.
|
||||
# The paths below are named rather than whole directories, so a packaging-only
|
||||
# change is attributed to archied deliberately and not every CI or script edit.
|
||||
archied_dirs() {
|
||||
component_dirs ./cmd/archied
|
||||
# Every process the host bundles ships in this release, so a change to a
|
||||
# package only one of them links still lands in the changelog. Without
|
||||
# these, messaging-only and state-store-only packages closed
|
||||
# over no component and the release silently omitted them (the telegram fence
|
||||
# fix was dropped this way). The gap is pre-existing -- the old two-file
|
||||
# closures named only cmd/archied and cmd/archie-agent -- but it grew teeth
|
||||
# when the Messaging Service was severed from archied in 1.35.0.
|
||||
component_dirs ./cmd/archie-messaging
|
||||
component_dirs ./cmd/archie-state-store
|
||||
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" \
|
||||
"deployments/INSTRUCTIONS.md"
|
||||
}
|
||||
|
||||
# The UI Service ships with the archied release on purpose (archie-ui shares
|
||||
# internal/webui with archied), hence archied_dirs' extra paths above.
|
||||
runtime_dirs() {
|
||||
component_dirs ./cmd/archie-agent
|
||||
printf '%s\n' "cmd/archie-agent" "Dockerfile"
|
||||
}
|
||||
|
||||
# changelog_body -- labelled per-component sections for every releasable commit
|
||||
# since the last release. Empty output means nothing to release: a commit set
|
||||
# that justifies no version produces no body, and the caller reports that
|
||||
# rather than inventing one.
|
||||
changelog_body() {
|
||||
local last range archied runtime
|
||||
last="$(git describe --tags --abbrev=0 2>/dev/null || true)"
|
||||
range="HEAD"
|
||||
if [ -n "$last" ]; then
|
||||
range="$last..HEAD"
|
||||
fi
|
||||
archied="$(archied_dirs)"
|
||||
runtime="$(runtime_dirs)"
|
||||
|
||||
local sha subject files in_archied="" in_runtime=""
|
||||
while read -r sha; do
|
||||
[ -n "$sha" ] || continue
|
||||
subject="$(git log -1 --pretty=%s "$sha")"
|
||||
# Conventional commits only; release commits are not news.
|
||||
case "$subject" in
|
||||
feat:* | feat\(*|fix:* | fix\(*|perf:* | perf\(*|refactor:* | refactor\(*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
files="$(git show --pretty=format: --name-only "$sha")"
|
||||
if matches "$files" "$archied"; then
|
||||
in_archied="$in_archied- $subject"$'\n'
|
||||
fi
|
||||
if matches "$files" "$runtime"; then
|
||||
in_runtime="$in_runtime- $subject"$'\n'
|
||||
fi
|
||||
done < <(git log --no-merges --pretty=%H --reverse "$range")
|
||||
|
||||
if [ -n "$in_archied" ]; then
|
||||
printf '### archied\n\n%s\n' "$in_archied"
|
||||
fi
|
||||
if [ -n "$in_runtime" ]; then
|
||||
printf '### archie-agent\n\n%s\n' "$in_runtime"
|
||||
fi
|
||||
}
|
||||
|
||||
# prepend <version> <body-file> -- insert the new section after the title and
|
||||
# any [Unreleased] block, which stays at the top, and above every release.
|
||||
prepend() {
|
||||
local version="$1" bodyfile="$2" tmp line
|
||||
line="$(grep -n '^## \[' CHANGELOG.md | grep -v '## \[Unreleased\]' | head -1 | cut -d: -f1)"
|
||||
if [ -z "$line" ]; then
|
||||
line="$(($(wc -l <CHANGELOG.md) + 1))"
|
||||
fi
|
||||
tmp="$(mktemp)"
|
||||
{
|
||||
head -n "$((line - 1))" CHANGELOG.md
|
||||
echo "## [$version] - $(date +%F)"
|
||||
echo
|
||||
cat "$bodyfile"
|
||||
echo
|
||||
tail -n "+$line" CHANGELOG.md
|
||||
} >"$tmp"
|
||||
mv "$tmp" CHANGELOG.md
|
||||
}
|
||||
|
||||
body="$(changelog_body)"
|
||||
|
||||
if [ -z "$body" ]; then
|
||||
last="$(git describe --tags --abbrev=0 2>/dev/null || echo 'the beginning')"
|
||||
echo "nothing to release: no releasable commits since $last" >&2
|
||||
exit "$NOTHING_TO_RELEASE"
|
||||
fi
|
||||
|
||||
echo "==> release $VERSION"
|
||||
echo "$body" | sed 's/^/ /'
|
||||
|
||||
if [ "$MODE" = "dry-run" ]; then
|
||||
echo
|
||||
echo "dry run: no files written, no commits, no tags"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
bodyfile="$(mktemp)"
|
||||
printf '%s\n' "$body" >"$bodyfile"
|
||||
|
||||
if [ "$MODE" = "prepare" ]; then
|
||||
prepend "$VERSION" "$bodyfile"
|
||||
rm -f "$bodyfile"
|
||||
echo
|
||||
echo "CHANGELOG.md updated and left uncommitted. Edit it -- generated notes"
|
||||
echo "are a starting point, not the release -- then freeze it with:"
|
||||
echo
|
||||
echo " tools/release.sh --version $VERSION --tag"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# --tag: the changelog must already describe this release.
|
||||
grep -q "^## \\[$VERSION\\]" CHANGELOG.md ||
|
||||
die "CHANGELOG.md has no [$VERSION] section; run --prepare first"
|
||||
|
||||
# The published release notes are derived from the changelog, so regenerate
|
||||
# them after the maintainer's edit and ship them in the same commit as the
|
||||
# section they describe. newsgen skips a file whose bytes already match, so a
|
||||
# re-run leaves the tree clean.
|
||||
go -C tools run -mod=readonly ./newsgen --repo-root ..
|
||||
|
||||
git add CHANGELOG.md docs/news
|
||||
git commit -m "chore(release): v$VERSION"
|
||||
git tag -a "v$VERSION" -m "v$VERSION"
|
||||
|
||||
echo
|
||||
echo "tagged. push with:"
|
||||
echo " git push --atomic origin main v$VERSION"
|
||||
echo
|
||||
echo "The deploy workflow reads the tags pointing at HEAD, so the commit and"
|
||||
echo "its tag must land together; --atomic pushes both or neither."
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Verify the committed dashboard bundle matches a fresh build of ui/src.
|
||||
#
|
||||
# ui/dist is committed because the Go build embeds it, so it is a generated
|
||||
# source file: a change to ui/src that lands without the rebuilt bundle ships a
|
||||
# dashboard no reviewer ever saw. Rebuilding it in place here would bless
|
||||
# exactly that, silently -- and with more than one agent working in its own
|
||||
# worktree, each could "pass" while producing a different bundle.
|
||||
#
|
||||
# So this builds somewhere temporary and compares. A mismatch means ui/src
|
||||
# changed without `task ui`, or the bundle was hand-edited; the fix is the same
|
||||
# either way.
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
case "${1:-check}" in
|
||||
check) ;;
|
||||
*)
|
||||
echo 'usage: bash tools/uidist.sh check' >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
out="$(mktemp -d)"
|
||||
trap 'rm -rf "$out"' EXIT
|
||||
|
||||
# The comparison only means something if the build is deterministic, so a
|
||||
# failure here is staleness rather than toolchain noise. It is: vite is
|
||||
# configured to emit fixed asset names (no content hashes), and rebuilding an
|
||||
# unchanged tree produces byte-identical output.
|
||||
if ! build_log="$(cd ui && pnpm --silent run build --outDir "$out" --emptyOutDir 2>&1)"; then
|
||||
echo "$build_log" >&2
|
||||
echo 'the dashboard does not build; fix that before checking freshness' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! differences="$(diff -rq ui/dist "$out" 2>&1)"; then
|
||||
cat >&2 <<EOF
|
||||
ui/dist does not match a fresh build of ui/src:
|
||||
|
||||
$differences
|
||||
|
||||
Run \`task ui\` and commit the rebuilt bundle in the same commit as the change
|
||||
that caused it. The Go build embeds ui/dist, so a stale bundle ships a
|
||||
dashboard nobody reviewed.
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 'ui/dist matches a fresh build of ui/src'
|
||||
+9
-4
@@ -54,9 +54,14 @@ state; the UI presents them and submits operator choices.
|
||||
(text-caption, text-label, text-title) instead of pixel sizes. Never
|
||||
hand-roll a card, heading, caption, status dot or date format; if a pattern
|
||||
is missing, add it to components/ui with a real consumer first.
|
||||
- Add and update components/ui components with the shadcn-vue CLI, never by
|
||||
writing or copying them by hand: `pnpm dlx shadcn-vue@latest add <name>` from
|
||||
`ui/`, or the component's registry URL when the maintainer names one. Search
|
||||
the registry before writing a missing pattern yourself, and write one only
|
||||
when no registry has it. The CLI runs through `pnpm dlx`, so it never joins
|
||||
the application's dependencies.
|
||||
- Reuse components/ui and surrounding composition patterns before writing new
|
||||
markup. Keep vendored components local; use pnpm dlx shadcn-vue@latest for CLI work
|
||||
instead of adding the generator and its dependency tree to the application.
|
||||
markup.
|
||||
- Use semantic theme tokens, existing variants and cn() for conditional classes.
|
||||
Support both themes, compact density and reduced motion.
|
||||
- Keep controls compact and contextual. Use on-demand panels and inline
|
||||
@@ -123,8 +128,8 @@ pnpm audit # after dependency changes
|
||||
|
||||
- Run task check from the repository root before committing; stage only the
|
||||
task's own paths. Follow the root's commit and push rules.
|
||||
- ui/dist is embedded and committed. Regenerate it for source changes; never
|
||||
edit it by hand. Test-only edits do not need new dashboard assets.
|
||||
- ui/dist is build output: `task build` and CI build it before embedding it.
|
||||
Never commit it.
|
||||
- Reuse a running dev server for browser checks. Verify changed interactions,
|
||||
not just a screenshot or successful HTTP response.
|
||||
- Track work and follow-ups as Gitea issues (`tea`). Keep rules here only when
|
||||
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{A as e,C as t,Ct as n,D as r,M as i,Qt as a,S as o,Tt as s,Xt as c,_t as l,b as u,dt as d,er as f,ir as p,jn as m,k as h,l as g,n as _,pn as v,rt as y,t as b,wt as x,x as S,xn as C,y as w}from"./PageHeader.js";import{N as T,d as E,nt as D,ot as O,r as k,u as A,w as j}from"./createLucideIcon.js";import{p as M,t as N}from"./input.js";import{A as P,Et as F,Tt as I,at as L,c as R,gt as z,ht as B,it as V,ot as H,q as U,rt as W,vt as G,wt as K,yt as q}from"./index.js";var J=[`data-size`],Y=[`data-size`],X=i({inheritAttrs:!1,__name:`NativeSelect`,props:{modelValue:{},class:{type:[Boolean,null,String,Object,Array]},size:{}},emits:[`update:modelValue`],setup(n,{emit:r}){let i=n,o=M(i,`modelValue`,r,{passive:!0,defaultValue:``}),s=j(i,`class`,`size`);return(n,r)=>(l(),t(`div`,{class:f(m(_)(`group/native-select relative w-fit has-[select:disabled]:opacity-50`,i.class)),"data-slot":`native-select-wrapper`,"data-size":i.size??`default`},[a(u(`select`,y({...n.$attrs,...m(s)},{"onUpdate:modelValue":r[0]||=e=>v(o)?o.value=e:null,"data-slot":`native-select`,class:`border-input placeholder:text-fg-muted selection:bg-primary selection:text-primary-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 h-9 w-full min-w-0 appearance-none rounded-lg border bg-card py-1 pr-8 pl-2.5 text-sm transition-colors select-none focus-visible:ring-3 aria-invalid:ring-3 data-[size=sm]:h-8 data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[size=sm]:py-0.5 outline-none disabled:pointer-events-none disabled:cursor-not-allowed`,"data-size":i.size??`default`}),[x(n.$slots,`default`)],16,Y),[[D,m(o)]]),e(m(q),{class:`text-fg-muted top-1/2 right-2.5 size-4 -translate-y-1/2 pointer-events-none absolute select-none`,"aria-hidden":`true`,"data-slot":`native-select-icon`})],10,J))}}),Z=i({__name:`NativeSelectOption`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){let n=e;return(e,r)=>(l(),t(`option`,{"data-slot":`native-select-option`,class:f(m(_)(`bg-[Canvas] text-[CanvasText]`,n.class))},[x(e.$slots,`default`)],2))}}),Q={key:0,class:`text-fg-subtle`},$={key:1,role:`alert`,class:`mb-3 text-danger`},ee={key:2,class:`mb-3 rounded-lg border border-border p-3`},te={class:`flex gap-2`},ne={key:3,class:`text-fg-subtle`},re={class:`flex-1 truncate text-sm`},ie={class:`text-xs text-fg-subtle`},ae={class:`text-xs text-fg-subtle`},oe={class:`text-xs text-fg-subtle`},se=i({__name:`PersonalTokensCard`,setup(i){let a=[{days:7,label:`7 days`},{days:30,label:`30 days`},{days:90,label:`90 days`},{days:0,label:`No expiry`}],s=C(!1),f=C([]),_=C(``),v=C(``),y=C(!1),b=C(``),x=C(30);async function w(e){y.value=!0;try{await e(),v.value=``}catch(e){v.value=String(e.message||e)}finally{y.value=!1}}let E=()=>w(async()=>{let e=await k.tokens();s.value=e?.available??!1,f.value=e?.tokens??[]}),D=()=>w(async()=>{_.value=(await k.createToken(b.value.trim(),Number(x.value)))?.token??``,b.value=``,await E()}),A=()=>navigator.clipboard.writeText(_.value),j=e=>w(async()=>{await k.revokeToken(e),await E()});return d(E),(i,d)=>(l(),S(m(P),{title:`API tokens`},r({default:c(()=>[!s.value&&!y.value&&!v.value?(l(),t(`p`,Q,`Personal tokens need a signed-in person.`)):o(``,!0),v.value?(l(),t(`p`,$,p(v.value),1)):o(``,!0),_.value?(l(),t(`div`,ee,[d[5]||=u(`p`,{class:`mb-2 text-xs`},`Copy this token now. It cannot be shown again.`,-1),u(`div`,te,[e(m(N),{"model-value":_.value,readonly:``,"aria-label":`New token`,onFocus:d[2]||=e=>e.target.select()},null,8,[`model-value`]),e(m(T),{variant:`outline`,size:`sm`,"aria-label":`Copy token`,onClick:A},{default:c(()=>[e(m(G))]),_:1}),e(m(T),{variant:`ghost`,size:`sm`,"aria-label":`Dismiss`,onClick:d[3]||=e=>_.value=``},{default:c(()=>[e(m(B))]),_:1})])])):o(``,!0),s.value&&!f.value.length&&!y.value&&!v.value?(l(),t(`p`,ne,`No tokens yet.`)):o(``,!0),f.value.length?(l(),S(m(W),{key:4,"aria-label":`API tokens`},{default:c(()=>[(l(!0),t(g,null,n(f.value,n=>(l(),S(m(H),{key:n.id,as:`li`,variant:`outline`,size:`xs`},{default:c(()=>[u(`span`,re,p(n.name||n.id.slice(0,12)),1),u(`span`,ie,[d[6]||=h(`Created `,-1),e(m(U),{at:n.created_at},null,8,[`at`])]),u(`span`,ae,[d[7]||=h(`Expires `,-1),n.expires_at?(l(),S(m(U),{key:0,at:n.expires_at},null,8,[`at`])):(l(),t(g,{key:1},[h(`Never`)],64))]),u(`span`,oe,[d[8]||=h(`Last used `,-1),n.last_used_at?(l(),S(m(U),{key:0,at:n.last_used_at},null,8,[`at`])):(l(),t(g,{key:1},[h(`Never`)],64))]),e(m(T),{variant:`ghost`,size:`sm`,class:`text-danger`,disabled:y.value,onClick:e=>j(n.id)},{default:c(()=>[...d[9]||=[h(`Revoke`,-1)]]),_:1},8,[`disabled`,`onClick`])]),_:2},1024))),128))]),_:1})):o(``,!0)]),_:2},[s.value?{name:`action`,fn:c(()=>[u(`form`,{class:`flex items-center gap-2`,onSubmit:O(D,[`prevent`])},[e(m(N),{modelValue:b.value,"onUpdate:modelValue":d[0]||=e=>b.value=e,class:`w-40`,maxlength:`40`,rLine truncated
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{A as e,C as t,M as n,S as r,Xt as i,_t as a,b as o,dt as s,ir as c,jn as l,k as u,t as d,x as f,xn as p,y as m}from"./PageHeader.js";import{N as h,d as g,ot as _,u as v}from"./createLucideIcon.js";import{t as y}from"./input.js";import{B as b,K as x,L as S,R as C,U as w,V as T,W as E,Y as D,Z as O,et as k,l as A,z as j}from"./index.js";var M={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},N={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},P={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},F={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},I=`agent-profiles`,L=n({__name:`AgentProfilesPage`,setup(n){let L=x();s(L.load);let R=m(()=>L.draftValue(I)),z=p(``),B=p(``),V=m(()=>L.changesFor(I).length>0),H=m(()=>Object.entries(R.value??{}));function U(){if(V.value||!L.formFor(I))return;let e=z.value.trim();e&&!R.value?.[e]&&(L.setDraftEntry(I,e,{image:``,kit:``,adapter:``,tools:[]}),B.value=String(H.value.findIndex(([t])=>t===e)),z.value=``)}function W(e){let t=H.value[e]?.[0];t&&L.setDraftEntry(I,t,void 0)}function G(e,t){L.setDraftEntry(I,e,{...R.value?.[e],...t})}function K(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}return(n,s)=>(a(),t(`div`,null,[e(d,{title:`Agent profiles`},{default:i(()=>[e(w,{kinds:[I]},null,8,[`kinds`])]),_:1}),e(E,{kind:I,class:`mb-4`}),l(L).catalogError||l(L).pageErrorFor(I)?(a(),f(l(g),{key:0,variant:`destructive`,class:`mb-4`},{default:i(()=>[e(l(v),null,{default:i(()=>[u(c(l(L).catalogError||l(L).pageErrorFor(I)),1)]),_:1})]),_:1})):r(``,!0),o(`form`,{class:`mb-4 flex flex-wrap gap-2`,onSubmit:_(U,[`prevent`])},[e(l(y),{modelValue:z.value,"onUpdate:modelValue":s[0]||=e=>z.value=e,"aria-label":`Profile name`,placeholder:`Profile name`,class:`max-w-xs`,disabled:V.value},null,8,[`modelValue`,`disabled`]),e(l(h),{type:`submit`,disabled:V.value||!z.value.trim()||!!R.value?.[z.value.trim()]},{default:i(()=>[...s[2]||=[u(`Add profile`,-1)]]),_:1},8,[`disabled`])],32),Object.keys(R.value??{}).length?r(``,!0):(a(),f(l(k),{key:1},{default:i(()=>[e(l(O),null,{default:i(()=>[e(l(D),null,{default:i(()=>[...s[3]||=[u(`No agent profiles`,-1)]]),_:1})]),_:1})]),_:1})),e(A,{open:B.value,"onUpdate:open":s[1]||=e=>B.value=e,items:H.value,title:([e])=>e,"remove-label":`Remove`,mono:``,onRemove:W},{default:i(({item:[t,n]})=>[e(l(C),{class:`@container/field-group`},{default:i(()=>[e(l(T),{orientation:`responsive`},{default:i(()=>[e(l(b),null,{default:i(()=>[e(l(S),{for:`${t}-image`},{default:i(()=>[...s[4]||=[u(`Image`,-1)]]),_:1},8,[`for`])]),_:2},1024),o(`div`,M,[e(l(y),{id:`${t}-image`,"model-value":n.image,placeholder:`Container image`,"onUpdate:modelValue":e=>G(t,{image:String(e)})},null,8,[`id`,`model-value`,`onUpdate:modelValue`])])]),_:2},1024),e(l(T),{orientation:`responsive`},{default:i(()=>[e(l(b),null,{default:i(()=>[e(l(S),{for:`${t}-kit`},{default:i(()=>[...s[5]||=[u(`Kit`,-1)]]),_:1},8,[`for`]),e(l(j),null,{default:i(()=>[...s[6]||=[u(`Pinned digest. Used only when Image is empty.`,-1)]]),_:1})]),_:2},1024),o(`div`,N,[e(l(y),{id:`${t}-kit`,"model-value":n.kit,placeholder:`registry/kit@sha256:…`,"onUpdate:modelValue":e=>G(t,{kit:String(e)})},null,8,[`id`,`model-value`,`onUpdate:modelValue`])])]),_:2},1024),e(l(T),{orientation:`responsive`},{default:i(()=>[e(l(b),null,{default:i(()=>[e(l(S),{for:`${t}-adapter`},{default:i(()=>[...s[7]||=[u(`Adapter`,-1)]]),_:1},8,[`for`])]),_:2},1024),o(`div`,P,[e(l(y),{id:`${t}-adapter`,"model-value":n.adapter,"onUpdate:modelValue":e=>G(t,{adapter:String(e)})},null,8,[`id`,`model-value`,`onUpdate:modelValue`])])]),_:2},1024),e(l(T),{orientation:`responsive`},{default:i(()=>[e(l(b),null,{default:i(()=>[e(l(S),{for:`${t}-tools`},{default:i(()=>[...s[8]||=[u(`Tools`,-1)]]),_:1},8,[`for`]),e(l(j),null,{default:i(()=>[...s[9]||=[u(`Comma-separated tool names.`,-1)]]),_:1})]),_:2},1024),o(`div`,F,[e(l(y),{id:`${t}-tools`,"model-value":(n.tools??[]).join(`, `),onChange:e=>G(t,{tools:K(e.target.value)})},null,8,[`id`,`model-value`,`onChange`])])]),_:2},1024)]),_:2},1024)]),_:1},8,[`open`,`items`,`title`])]))}});export{L as default};
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{A as e,C as t,M as n,S as r,Xt as i,_t as a,b as o,dt as s,ir as c,jn as l,k as u,t as d,x as f,xn as p,y as m}from"./PageHeader.js";import{N as h,d as g,ot as _,r as v,u as y}from"./createLucideIcon.js";import{t as b}from"./input.js";import{A as x,bt as S,c as C,nt as w}from"./index.js";var T={class:`flex items-center justify-end gap-2 border-t border-border pt-3`},E=n({__name:`AuthenticationPage`,setup(n){let E=p({public_url:``,oidc_issuer:``,oidc_audience:``,oidc_client_id:``}),D=p(!1),O=p(``),k=p(!1),A=p(!1);s(async()=>{try{E.value=await v.authentication(),D.value=!0}catch(e){O.value=String(e.message||e)}});let j=m(()=>`${E.value.public_url.replace(/\/$/,``)}/oauth2/callback`);async function M(){k.value=!0,O.value=``,A.value=!1;try{await v.saveAuthentication(E.value),A.value=!0}catch(e){O.value=String(e.message||e)}finally{k.value=!1}}return(n,s)=>(a(),t(`div`,null,[e(d,{title:`Authentication`}),O.value?(a(),f(l(g),{key:0,variant:`destructive`,class:`mb-4`},{default:i(()=>[e(l(y),null,{default:i(()=>[u(c(O.value)+` `,1),s[4]||=o(`a`,{class:`underline`,href:`/?reauth=1`},`Sign in again`,-1)]),_:1})]),_:1})):r(``,!0),D.value?(a(),t(`form`,{key:1,onSubmit:_(M,[`prevent`])},[e(l(x),{title:`Instance URL`},{default:i(()=>[e(l(C),{label:`Public address`,for:`instance-url`,hint:`Passkeys require HTTPS and a domain name, or localhost. Once passkeys are enrolled, their domain is fixed.`},{default:i(()=>[e(l(b),{id:`instance-url`,modelValue:E.value.public_url,"onUpdate:modelValue":s[0]||=e=>E.value.public_url=e,type:`url`,required:``},null,8,[`modelValue`])]),_:1})]),_:1}),e(l(x),{title:`OpenID Connect`},{default:i(()=>[e(l(C),{label:`Issuer URL`,for:`oidc-issuer`},{default:i(()=>[e(l(b),{id:`oidc-issuer`,modelValue:E.value.oidc_issuer,"onUpdate:modelValue":s[1]||=e=>E.value.oidc_issuer=e,type:`url`,placeholder:`https://identity.example.com`},null,8,[`modelValue`])]),_:1}),e(l(C),{label:`Client ID`,for:`oidc-client`},{default:i(()=>[e(l(b),{id:`oidc-client`,modelValue:E.value.oidc_client_id,"onUpdate:modelValue":s[2]||=e=>E.value.oidc_client_id=e},null,8,[`modelValue`])]),_:1}),e(l(C),{label:`Access token audience`,for:`oidc-audience`},{default:i(()=>[e(l(b),{id:`oidc-audience`,modelValue:E.value.oidc_audience,"onUpdate:modelValue":s[3]||=e=>E.value.oidc_audience=e},null,8,[`modelValue`])]),_:1}),e(l(C),{label:`Redirect URI`,hint:`Add permitted people in Organisation → Members.`},{default:i(()=>[e(w,{code:j.value},null,8,[`code`])]),_:1}),o(`div`,T,[A.value?(a(),f(l(S),{key:0,role:`status`,"aria-label":`Saved`,class:`size-4 text-fg-muted`})):r(``,!0),e(l(h),{type:`submit`,disabled:k.value},{default:i(()=>[...s[5]||=[u(`Save`,-1)]]),_:1},8,[`disabled`])])]),_:1})],32)):r(``,!0)]))}});export{E as default};
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{I as e,M as t,S as n}from"./badge.js";import{Gt as r,Kt as i,M as a,U as o,Z as s,hn as c,xn as l,y as u,yt as d}from"./PageHeader.js";import{F as f}from"./createLucideIcon.js";function p(n){let r=t(``,1e3);return{search:r,handleTypeaheadSearch:(t,i)=>{if(r.value+=t,n)n(t);else{let t=e(),n=i.map(e=>({...e,textValue:e.value?.textValue??e.ref.textContent?.trim()??``})),a=n.find(e=>e.ref===t),o=h(n.map(e=>e.textValue),r.value,a?.textValue),s=n.find(e=>e.textValue===o);return s&&s.ref.focus(),s?.ref}},resetTypeahead:()=>{r.value=``}}}function m(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function h(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=m(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function g(){let e=l();return{primitiveElement:e,currentElement:u(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:n(e))}}var _=`menu.itemSelect`,v=[`Enter`,` `],y=[`ArrowDown`,`PageUp`,`Home`],b=[`ArrowUp`,`PageDown`,`End`],x=[...y,...b],S={ltr:[...v,`ArrowRight`],rtl:[...v,`ArrowLeft`]},C={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]};function w(e){return e?`open`:`closed`}function T(e){return e===`indeterminate`}function E(e){return T(e)?`indeterminate`:e?`checked`:`unchecked`}function D(e){let{onEntryFocus:t,onEntryFocusOnce:n,...r}=e;return r}function O(t){let n=e();for(let r of t)if(r===n||(r.focus(),e()!==n))return}function k(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e].x,s=t[e].y,c=t[a].x,l=t[a].y;s>r!=l>r&&n<(c-o)*(r-s)/(l-s)+o&&(i=!i)}return i}function A(e,t){return t?k({x:e.clientX,y:e.clientY},t):!1}function j(e){return e.pointerType===`mouse`}var M=`data-reka-collection-item`;function N(e={}){let{key:t=``,isProvider:n=!1}=e,p=`${t}CollectionProvider`,m;if(n){let e=l(new Map);m={collectionRef:l(),itemMap:e},d(p,m)}else m=s(p);let h=(e,t=!1)=>{if(!m.collectionRef.value)return;let n=m.itemMap.value.get(e);return n&&(t||n.ref.dataset.disabled!==``)?n:void 0},_=(e=!1)=>{let t=m.collectionRef.value;if(!t)return[];let n=Array.from(t.querySelectorAll(`[${M}]`)),r=new Map(n.map((e,t)=>[e,t])),i=Array.from(m.itemMap.value.values()).sort((e,t)=>(r.get(e.ref)??-1)-(r.get(t.ref)??-1));return e?i:i.filter(e=>e.ref.dataset.disabled!==``)},v=a({name:`CollectionSlot`,inheritAttrs:!1,setup(e,{slots:t,attrs:n}){let{primitiveElement:i,currentElement:a}=g();return r(a,()=>{m.collectionRef.value=a.value}),()=>o(f,{ref:i,...n},t)}}),y=a({name:`CollectionItem`,inheritAttrs:!1,props:{value:{validator:()=>!0}},setup(e,{slots:t,attrs:n}){let{primitiveElement:r,currentElement:a}=g();return i(t=>{if(a.value){let n=c(a.value);m.itemMap.value.set(n,{ref:a.value,value:e.value}),t(()=>m.itemMap.value.delete(n))}}),()=>o(f,{...n,[M]:``,ref:r},t)}});return{getItems:_,getItem:h,reactiveItems:u(()=>Array.from(m.itemMap.value.values())),itemMapSize:u(()=>m.itemMap.value.size),CollectionSlot:v,CollectionItem:y}}export{m as _,v as a,O as c,T as d,j as f,p as g,g as h,b as i,E as l,D as m,x as n,C as o,A as p,_ as r,S as s,N as t,w as u};
|
||||
-1
@@ -1 +0,0 @@
|
||||
import{A as e,C as t,M as n,S as r,Xt as i,_t as a,b as o,dt as s,ir as c,jn as l,k as u,t as d,x as f,xn as p,y as m}from"./PageHeader.js";import{N as h,d as g,u as _}from"./createLucideIcon.js";import{t as v}from"./input.js";import{B as y,K as b,L as x,R as S,U as C,V as w,W as T,Y as E,Z as D,et as O,k,l as A,z as j}from"./index.js";var M={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},N={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},P={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},F=`credential-bindings`,I=n({__name:`CredentialBindingsPage`,setup(n){let I=b();s(I.load);let L=m(()=>I.draftValue(F)),R=p(``),z=m(()=>I.changesFor(F).length>0);function B(){if(z.value||!I.formFor(F))return;let e=L.value??[];I.setDraftValue(F,[...e,{service:``,org:``,secret:{engine:``,key:``}}]),R.value=String(e.length)}function V(e){I.setDraftValue(F,(L.value??[]).filter((t,n)=>n!==e))}function H(e,t){I.setDraftValue(F,(L.value??[]).map((n,r)=>r===e?{...n,...t}:n))}return(n,s)=>(a(),t(`div`,null,[e(d,{title:`Credential bindings`},{default:i(()=>[e(C,{kinds:[F]},null,8,[`kinds`]),e(l(h),{disabled:z.value,onClick:B},{default:i(()=>[...s[1]||=[u(`Add binding`,-1)]]),_:1},8,[`disabled`])]),_:1}),e(T,{kind:F,class:`mb-4`}),l(I).catalogError||l(I).pageErrorFor(F)?(a(),f(l(g),{key:0,variant:`destructive`,class:`mb-4`},{default:i(()=>[e(l(_),null,{default:i(()=>[u(c(l(I).catalogError||l(I).pageErrorFor(F)),1)]),_:1})]),_:1})):r(``,!0),L.value?.length?r(``,!0):(a(),f(l(O),{key:1},{default:i(()=>[e(l(D),null,{default:i(()=>[e(l(E),null,{default:i(()=>[...s[2]||=[u(`No credential bindings`,-1)]]),_:1})]),_:1})]),_:1})),e(A,{open:R.value,"onUpdate:open":s[0]||=e=>R.value=e,items:L.value??[],title:e=>e.service||`New binding`,"remove-label":`Remove`,mono:``,onRemove:V},{default:i(({item:t,index:n})=>[e(l(S),{class:`@container/field-group`},{default:i(()=>[e(l(w),{orientation:`responsive`},{default:i(()=>[e(l(y),null,{default:i(()=>[e(l(x),{for:`binding-${n}-service`},{default:i(()=>[...s[3]||=[u(`Service`,-1)]]),_:1},8,[`for`])]),_:2},1024),o(`div`,M,[e(l(v),{id:`binding-${n}-service`,"model-value":t.service,"onUpdate:modelValue":e=>H(n,{service:String(e)})},null,8,[`id`,`model-value`,`onUpdate:modelValue`])])]),_:2},1024),e(l(w),{orientation:`responsive`},{default:i(()=>[e(l(y),null,{default:i(()=>[e(l(x),{for:`binding-${n}-org`},{default:i(()=>[...s[4]||=[u(`Organisation`,-1)]]),_:1},8,[`for`]),e(l(j),null,{default:i(()=>[...s[5]||=[u(`Empty uses the default organisation.`,-1)]]),_:1})]),_:2},1024),o(`div`,N,[e(l(v),{id:`binding-${n}-org`,"model-value":t.org,"onUpdate:modelValue":e=>H(n,{org:String(e)})},null,8,[`id`,`model-value`,`onUpdate:modelValue`])])]),_:2},1024),e(l(w),{orientation:`responsive`},{default:i(()=>[e(l(y),null,{default:i(()=>[e(l(x),null,{default:i(()=>[...s[6]||=[u(`Secret`,-1)]]),_:1})]),_:1}),o(`div`,P,[e(k,{"model-value":t.secret,"id-prefix":`binding-${n}-secret`,"onUpdate:modelValue":e=>H(n,{secret:e})},null,8,[`model-value`,`id-prefix`,`onUpdate:modelValue`])])]),_:2},1024)]),_:2},1024)]),_:1},8,[`open`,`items`,`title`])]))}});export{I as default};
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{t as e}from"./badge.js";import{A as t,C as n,Ct as r,M as i,S as a,Xt as o,_t as s,b as c,dt as l,ir as u,jn as d,k as f,l as p,st as m,t as h,x as g,xn as _}from"./PageHeader.js";import{N as v,d as y,l as b,n as x,r as S,u as C}from"./createLucideIcon.js";import{A as w,C as T,D as E,Dt as D,E as O,O as k,T as A,Y as j,Z as M,a as N,dt as ee,et as P,ft as F,lt as I,mt as L,o as R,pt as z,q as B,tt as V,ut as H,w as U}from"./index.js";function W(e,t=Date.now()){if(!e.captured)return`unconfigured`;if(!e.expires_at)return`ready`;let n=Date.parse(e.expires_at);return Number.isNaN(n)?`ready`:n<=t?`expired`:n-t<=18e5?`expiring`:`ready`}function G(e,t,n=80,r=24){let i=t.protocol===`https:`?`wss:`:`ws:`,a=new URLSearchParams({profile:e,cols:String(n),rows:String(r)}).toString();return`${i}//${t.host}/api/harness/terminal?${a}`}var K={class:`flex h-full min-h-0 flex-col gap-2`},q={key:0,class:`text-sm text-fg-muted`,role:`status`},J=i({__name:`SetupTerminal`,props:{profile:{}},setup(e){let t=e,r=_(null),i=_(`connecting`),o=null,u=null,d=null,h=null;function g(){try{d?.fit()}catch{}}return l(()=>{let e=r.value;if(!e)return;o=new R({convertEol:!0,cursorBlink:!0,fontFamily:`'IBM Plex Mono', ui-monospace, monospace`,fontSize:13,theme:{background:`#0b0f14`,foreground:`#e6edf3`,cursor:`#e6edf3`,selectionBackground:`#264f78`}}),d=new N,o.loadAddon(d),o.open(e),g(),o.focus();let n=new WebSocket(G(t.profile,window.location,o?.cols??80,o?.rows??24));u=n,n.binaryType=`arraybuffer`,n.onopen=()=>{i.value=`open`},n.onmessage=e=>{o&&(typeof e.data==`string`?o.write(e.data):o.write(new Uint8Array(e.data)))},n.onerror=()=>{i.value=`failed`},n.onclose=()=>{i.value=`closed`},o.onData(e=>{n.readyState===WebSocket.OPEN&&n.send(e)}),h=new ResizeObserver(g),h.observe(e)}),m(()=>{h?.disconnect(),h=null,u?.close(),u=null,o?.dispose(),o=null,d=null}),(e,t)=>(s(),n(`div`,K,[i.value===`open`?a(``,!0):(s(),n(`p`,q,[i.value===`connecting`?(s(),n(p,{key:0},[f(`Connecting…`)],64)):i.value===`closed`?(s(),n(p,{key:1},[f(`The terminal session ended.`)],64)):(s(),n(p,{key:2},[f(`Could not open the setup terminal.`)],64))])),c(`div`,{ref_key:`host`,ref:r,class:`min-h-0 flex-1 overflow-hidden rounded-md border border-border bg-[#0b0f14] p-2`},null,512)]))}}),Y={key:1,class:`flex flex-col gap-2`},X={class:`flex flex-wrap items-end gap-3`},Z={class:`flex flex-col gap-1 text-sm`},Q={class:`h-96`},$=i({__name:`HarnessPage`,setup(i){let m=_(null),N=_(!0),R=_(null),G=_(!1),K=_(``),q=_(!1),$={ready:{label:`Ready`,variant:`ok`},expiring:{label:`Expiring soon`,variant:`warn`},expired:{label:`Expired`,variant:`danger`},unconfigured:{label:`Not set up`,variant:`idle`}};l(te);async function te(){N.value=!0,R.value=null,G.value=!1;try{let e=await S.harnessBindings();m.value={terminal:e.terminal,bindings:e.bindings??[],profiles:e.profiles??[]},K.value=m.value.profiles[0]??``}catch(e){let t=e instanceof x?e.status:void 0;t===501||t===503?G.value=!0:R.value=e instanceof Error?e.message:String(e),m.value=null}finally{N.value=!1}}function ne(){m.value?.terminal&&K.value&&(q.value=!0)}function re(e){return e.scopes?.length?e.scopes.join(`, `):`–`}return(i,l)=>(s(),n(`div`,null,[t(h,{title:`Harness`}),R.value?(s(),g(d(y),{key:0,variant:`destructive`,class:`mb-4`},{default:o(()=>[t(d(b),null,{default:o(()=>[...l[1]||=[f(`Could not load the harness`,-1)]]),_:1}),t(d(C),null,{default:o(()=>[f(u(R.value),1)]),_:1})]),_:1})):a(``,!0),N.value?(s(),n(`div`,Y,[t(d(V),{class:`h-24 w-full`}),t(d(V),{class:`h-40 w-full`})])):G.value?(s(),g(d(P),{key:2},{default:o(()=>[t(d(M),null,{default:o(()=>[t(d(j),null,{default:o(()=>[...l[2]||=[f(`Harness bindings are not configured`,-1)]]),_:1})]),_:1})]),_:1})):m.value?(s(),n(p,{key:3},[m.value.terminal?(s(),g(d(w),{key:1},{default:o(()=>[c(`div`,X,[c(`div`,Z,[t(d(D),{for:`harness-profile`,class:`text-fg-muted`},{default:o(()=>[...l[5]||=[f(`Profile`,-1)]]),_:1}),t(d(L),{modelValue:K.value,"onUpdate:modelValue":l[0]||=e=>K.value=e,disabled:!m.value.profiles.length},{default:o(()=>[t(d(H),{id:`harness-profile`,size:`sm`,class:`min-w-48`},{default:o(()=>[t(d(I),{placeholder:`No profiles configured`})]),_:1}),t(d(z),null,{default:o(()=>[t(d(F),null,{default:o(()=>[(s(!0),n(p,null,r(m.value.profiles,e=>(s(),g(d(ee),{key:e,value:e},{default:o(()=>[f(u(e),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1})]),_:1},8,[`modelValue`,`disabled`])]),t(d(v),{disabled:!K.value,onClick:ne},{default:o(()=>[...l[6]||=[f(`Open setup terminal`,-1)]]),_:1},8,[`disabled`])])]),_:1})):(s(),g(d(y),{key:0,class:`mb-4`},{default:o(()=>[t(d(b),null,{default:o(()=>[...l[3]||=[f(`Setup terminal unavailable`,-1)]]),_:1}),t(d(C),null,{default:o(()=>[...l[4]||=[f(`Start the daemon with a container runtime and a harness token to log in to a CLI from here.`,-1)]]),_:1})]),_:1})),q.value&&K.value?(s(),g(d(w),{key:2},{default:o(()=>[c(`div`,Q,[t(J,{profile:K.value},null,8,[`profile`])])]),_:1})):a(``,!0),t(d(w),null,{default:o(()=>[t(d(k),null,{default:o(()=>[t(d(T)Line truncated
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{A as e,C as t,M as n,Tt as r,Xt as i,_t as a,jn as o,k as s,t as c}from"./PageHeader.js";import{Q as l,Y as u,Z as d,et as f}from"./index.js";var p=n({__name:`NotFoundPage`,setup(n){return(n,p)=>{let m=r(`RouterLink`);return a(),t(`div`,null,[e(c,{title:`Page not found`}),e(o(f),null,{default:i(()=>[e(o(d),null,{default:i(()=>[e(o(u),null,{default:i(()=>[...p[0]||=[s(`No page at this address`,-1)]]),_:1}),e(o(l),null,{default:i(()=>[e(m,{to:`/`},{default:i(()=>[...p[1]||=[s(`Return to dashboard`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})])}}});export{p as default};
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{A as e,C as t,Ct as n,M as r,S as i,Xt as a,_t as o,b as s,dt as c,ir as l,jn as u,k as d,l as f,t as p,x as m,y as h}from"./PageHeader.js";import{N as g,d as _,u as v}from"./createLucideIcon.js";import{r as y}from"./pinia.js";import{t as b}from"./input.js";import{B as x,G as S,K as C,L as w,R as T,U as E,V as D,W as O,dt as k,k as A,lt as j,mt as M,pt as N,st as P,u as F,ut as I,z as L}from"./index.js";var R={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},z={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},B={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},V=`task-policy`,H=r({__name:`OrgAlertsPage`,setup(r){let H=C(),{catalog:U,catalogError:W}=y(H);c(H.load);let G=h(()=>P().sections?.settings!==!1),K=h(()=>S(U.value,`alerts`)),q=h(()=>H.formFor(V)),J=h(()=>H.draftValue(V));return(r,c)=>(o(),t(`div`,null,[e(p,{title:`Alert webhook`},{default:a(()=>[e(E,{kinds:K.value.map(e=>e.kind)},null,8,[`kinds`])]),_:1}),(o(!0),t(f,null,n(K.value,e=>(o(),m(O,{key:e.kind,kind:e.kind,class:`mb-4`},null,8,[`kind`]))),128)),u(W)||u(H).pageErrorFor(V)?(o(),m(u(_),{key:0,variant:`destructive`,class:`mb-4`},{default:a(()=>[e(u(v),null,{default:a(()=>[d(l(u(W)||u(H).pageErrorFor(V)),1)]),_:1})]),_:1})):i(``,!0),q.value&&J.value?(o(),m(u(T),{key:1,class:`@container/field-group`},{default:a(()=>[e(u(q).Field,{name:`notify_webhook`},{default:a(({field:t})=>[e(u(D),{orientation:`responsive`},{default:a(()=>[e(u(x),null,{default:a(()=>[e(u(w),{for:`task-notify`},{default:a(()=>[...c[0]||=[d(`Alert webhook`,-1)]]),_:1}),e(u(L),null,{default:a(()=>[...c[1]||=[d(`Receives each raised and resolved alert. Empty disables.`,-1)]]),_:1})]),_:1}),s(`div`,R,[e(u(b),{id:`task-notify`,"model-value":t.state.value,type:`url`,class:`max-w-md`,onBlur:t.handleBlur,"onUpdate:modelValue":t.handleChange},null,8,[`model-value`,`onBlur`,`onUpdate:modelValue`]),e(F,{kind:V,path:`notify_webhook`})])]),_:2},1024)]),_:1}),e(u(q).Field,{name:`notify_min_severity`},{default:a(({field:t})=>[e(u(D),{orientation:`responsive`},{default:a(()=>[e(u(x),null,{default:a(()=>[e(u(w),null,{default:a(()=>[...c[2]||=[d(`Webhook severity`,-1)]]),_:1}),e(u(L),null,{default:a(()=>[...c[3]||=[d(`Minimum severity.`,-1)]]),_:1})]),_:1}),s(`div`,z,[e(u(M),{"model-value":t.state.value||`warning`,"onUpdate:modelValue":e=>t.handleChange(String(e))},{default:a(()=>[e(u(I),{class:`w-40`,"aria-label":`Webhook severity`},{default:a(()=>[e(u(j))]),_:1}),e(u(N),null,{default:a(()=>[e(u(k),{value:`info`},{default:a(()=>[...c[4]||=[d(`Info`,-1)]]),_:1}),e(u(k),{value:`warning`},{default:a(()=>[...c[5]||=[d(`Warning`,-1)]]),_:1}),e(u(k),{value:`action`},{default:a(()=>[...c[6]||=[d(`Needs attention`,-1)]]),_:1})]),_:1})]),_:1},8,[`model-value`,`onUpdate:modelValue`]),e(F,{kind:V,path:`notify_min_severity`})])]),_:2},1024)]),_:1}),G.value?(o(),m(u(q).Field,{key:0,name:`notify_secret`},{default:a(({field:t})=>[e(u(D),{orientation:`responsive`},{default:a(()=>[e(u(x),null,{default:a(()=>[e(u(w),null,{default:a(()=>[...c[7]||=[d(`Webhook signing secret`,-1)]]),_:1}),e(u(L),null,{default:a(()=>[...c[8]||=[d(`Signs each payload in X-Archie-Signature. Not set sends unsigned.`,-1)]]),_:1})]),_:1}),s(`div`,B,[t.state.value?(o(),m(A,{key:0,"model-value":t.state.value,"id-prefix":`task-notify-secret`,"onUpdate:modelValue":t.handleChange},null,8,[`model-value`,`onUpdate:modelValue`])):(o(),m(u(g),{key:1,variant:`outline`,size:`sm`,onClick:e=>t.handleChange({engine:``,key:``})},{default:a(()=>[...c[9]||=[d(`Set reference`,-1)]]),_:1},8,[`onClick`])),e(F,{kind:V,path:`notify_secret`})])]),_:2},1024)]),_:1})):i(``,!0)]),_:1})):i(``,!0)]))}});export{H as default};
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
function e(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var t={},n=[],r=()=>{},i=()=>!1,a=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),o=e=>e.startsWith(`onUpdate:`),s=Object.assign,c=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},l=Object.prototype.hasOwnProperty,u=(e,t)=>l.call(e,t),d=Array.isArray,f=e=>S(e)===`[object Map]`,p=e=>S(e)===`[object Set]`,m=e=>S(e)===`[object Date]`,h=e=>S(e)===`[object RegExp]`,g=e=>typeof e==`function`,_=e=>typeof e==`string`,v=e=>typeof e==`symbol`,y=e=>typeof e==`object`&&!!e,b=e=>(y(e)||g(e))&&g(e.then)&&g(e.catch),x=Object.prototype.toString,S=e=>x.call(e),C=e=>S(e).slice(8,-1),w=e=>S(e)===`[object Object]`,T=e=>_(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,E=e(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),D=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},ee=/-\w/g,O=D(e=>e.replace(ee,e=>e.slice(1).toUpperCase())),te=/\B([A-Z])/g,k=D(e=>e.replace(te,`-$1`).toLowerCase()),A=D(e=>e.charAt(0).toUpperCase()+e.slice(1)),j=D(e=>e?`on${A(e)}`:``),M=(e,t)=>!Object.is(e,t),N=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},P=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},ne=e=>{let t=parseFloat(e);return isNaN(t)?e:t},re=e=>{let t=_(e)?Number(e):NaN;return isNaN(t)?e:t},ie,ae=()=>ie||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{},F=e(`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 I(e){if(d(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=_(r)?ce(r):I(r);if(i)for(let e in i)t[e]=i[e]}return t}if(_(e)||y(e))return e}var oe=/;(?![^(]*\))/g,se=/:([^]+)/,L=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function ce(e){let t={};return e.replace(L,e=>e.startsWith(`/*`)?``:e).split(oe).forEach(e=>{if(e){let n=e.split(se);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function le(e){let t=``;if(_(e))t=e;else if(d(e))for(let n=0;n<e.length;n++){let r=le(e[n]);r&&(t+=r+` `)}else if(y(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}function ue(e){if(!e)return null;let{class:t,style:n}=e;return t&&!_(t)&&(e.class=le(t)),n&&(e.style=I(n)),e}var de=e(`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,playsinline,readonly`);function fe(e){return!!e||e===``}function pe(e,t,n){if(e.length!==t.length)return!1;let r=!0;for(let i=0;r&&i<e.length;i++)r=_e(e[i],t[i],n);return r}function me(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]&&_e(t,r[a],n)){e=a;break}if(e<0)return!1;i[e]=1}return!0}function he(e,t,n){let r=f(e),i=f(t);if(r||i||(r=p(e),i=p(t),r||i))return r&&i?me(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||!_e(e[r],t[r],n))return!1}return String(e)===String(t)}function ge(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 _e(e,t,n){if(e===t)return!0;let r=m(e),i=m(t);return r||i?r&&i?e.getTime()===t.getTime():!1:(r=v(e),i=v(t),r||i?e===t:(r=d(e),i=d(t),r||i?r&&i?ge(e,t,n,pe):!1:(r=y(e),i=y(t),r||i?!r||!i?!1:ge(e,t,n,he):String(e)===String(t))))}function ve(e,t){return e.findIndex(e=>_e(e,t))}var ye=e=>!!(e&&e.__v_isRef===!0),be=e=>_(e)?e:e==null?``:d(e)||y(e)&&(e.toString===x||!g(e.toString))?ye(e)?be(e.value):JSON.stringify(e,xe,2):String(e),xe=(e,t)=>ye(t)?xe(e,t.value):f(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[Se(t,r)+` =>`]=n,e),{})}:p(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>Se(e))}:v(t)?Se(t):y(t)&&!d(t)&&!w(t)?String(t):t,Se=(e,t=``)=>v(e)?`Symbol(${e.description??t})`:e;function Ce(e){return e==null?`initial`:typeof e==`string`?e===``?` `:e:String(e)}var R,we=class{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!e&&R&&(R.active?(this.parent=R,this.index=(R.scopes||(R.scopes=[])).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,t;if(this.scopes){let n=this.scopes.slice();for(e=0,t=n.length;e<t;e++)n[e].pause()}for(e=0,t=this.effects.length;e<t;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,t;if(this.scopes){let n=this.scopes.slice();for(e=0,t=n.length;e<t;e++)n[e].resume()}let n=this.effects.slice();for(e=0,t=n.length;e<t;e++)n[e].resume()}}run(e){if(this._active){let t=R;try{return R=this,e()}finally{RLine truncated
|
||||
`&&(e.tagName===`PRE`||e.tagName===`TEXTAREA`)&&(n=n.slice(1));let{textContent:r}=e;r!==n&&r!==n.replace(/\r\n|\r/g,`
|
||||
`)&&(vi(e,0)||ci(),e.textContent=t.children)}if(d){if(_||b||!s||f&48){let t=e.tagName.includes(`-`),i=e.namespaceURI.includes(`svg`)?`svg`:e.namespaceURI.includes(`MathML`)?`mathml`:void 0;for(let o in d)if(_&&(o.endsWith(`value`)||o===`indeterminate`)||a(o)&&!E(o)||o[0]===`.`||t&&!E(o)||u&&u.includes(o)){if(hi(e,o,d[o]))continue;r(e,o,null,d[o],i,n)}}else if(d.onClick)r(e,`onClick`,null,d.onClick,void 0,n);else if(f&4&&Kt(d.style))for(let e in d.style)d.style[e]}let x;(x=d&&d.onVnodeBeforeMount)&&Os(x,n,t),h&&dr(t,null,n,`beforeMount`),((x=d&&d.onVnodeMounted)||h||l)&&$o(()=>{x&&Os(x,n,t),l&&g.enter(e),h&&dr(t,null,n,`mounted`)},i)}return e.nextSibling},m=(e,t,r,a,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]=ws(d[t]),g=h.type===ns;e?(g&&!u&&t+1<p&&ws(d[t+1]).type===ns&&(l(i(e.data.slice(h.children.length)),r,o(e)),e.data=h.children),e=f(e,h,a,s,c,u)):g&&!h.children?l(h.el=i(``),r):(m||(m=!0,vi(r,1)||ci()),n(null,h,r,null,a,s,di(r),c))}return e},h=(e,t,n,r,i,a)=>{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=s(e),f=m(o(e),t,d,n,r,i,a);return f&&fi(f)&&f.data===`]`?o(t.anchor=f):(ci(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,a,l)=>{if(bi(e,t)||ci(),t.el=null,l){let t=_(e);for(;;){let n=o(e);if(n&&n!==t)c(n);else break}}let u=o(e),d=s(e);return c(e),n(null,t,d,u,r,i,di(d),a),r&&(r.vnode.el=t.el,po(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=o(e),e&&fi(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return o(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 mi=new Set([`src`,`srcset`,`href`,`poster`]);function hi(e,t,n){return mi.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var gi=`data-allow-mismatch`,_i={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function vi(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(gi);)e=e.parentElement;return yi(e&&e.getAttribute(gi),t)}function yi(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(_i[t])}}function bi(e,t){return vi(e.parentElement,1)||xi(e)||Si(t)}function xi(e){return e.nodeType===1&&yi(e.getAttribute(gi),1)}function Si({props:e}){let t=e&&e[gi];return typeof t==`string`&&yi(t,1)}var Ci=ae().requestIdleCallback||(e=>setTimeout(e,1)),wi=ae().cancelIdleCallback||(e=>clearTimeout(e)),Ti=(e=1e4)=>t=>{let n=Ci(t,{timeout:e});return()=>wi(n)};function Ei(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 Di=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e),i=e=>{if(Ei(e))return t(),r.disconnect(),!1;if(getComputedStyle(e).display===`contents`){for(let t=0;t<e.children.length;t++)if(i(e.children[t])===!1)return!1}r.observe(e)};return n(e=>{if(e instanceof Element)return i(e)}),()=>r.disconnect()},Oi=e=>t=>{if(e){let n=matchMedia(e);if(n.matches)t();else return n.addEventListener(`change`,t,{once:!0}),()=>n.removeEventListener(`change`,t)}},ki=(e=[])=>(t,n)=>{_(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 Ai(e,t){if(fi(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(fi(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var ji=e=>!!e.type.__asyncLoader;function Mi(e){g(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 $r({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=>Ai(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=Y;if(ti(e),u)return()=>Ni(u,e);let t=t=>{l=null,Fn(t,e,13,!r)};if(s&&e.suspense||zs)return p().then(t=>()=>Ni(t,e)).catch(e=>(t(e),()=>r?J(r,{error:e}):null));let a=$t(!1),c=$t(),d=$t(!!i),f,m;return Xi(()=>{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&&Pi(e.parent.vnode)&&e.parent.update())}).catch(n=
Line truncated
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{A as e,C as t,M as n,S as r,Xt as i,_t as a,b as o,dt as s,ir as c,jn as l,k as u,t as d,x as f,xn as p,y as m}from"./PageHeader.js";import{N as h,d as g,ot as _,u as v}from"./createLucideIcon.js";import{t as y}from"./input.js";import{K as b,U as x,W as S,Y as C,Z as w,ct as T,et as E,l as D}from"./index.js";var O=`eda-playbooks`,k=n({__name:`PlaybooksPage`,setup(n){let k=b();s(k.load);let A=m(()=>k.formFor(O)),j=m(()=>k.draftValue(O)),M=p(``),N=p(``),P=m(()=>k.changesFor(O).length>0);function F(){if(P.value)return;let e=M.value.trim();if(!e||j.value?.playbooks.some(t=>t.id===e)||!A.value)return;let t=j.value?.playbooks??[];k.setDraftValue(O,{playbooks:[...t,{id:e,yaml:``}]}),M.value=``,N.value=String(t.length)}function I(e){let t=j.value?.playbooks??[];k.setDraftValue(O,{playbooks:t.filter((t,n)=>n!==e)})}return(n,s)=>(a(),t(`div`,null,[e(d,{title:`Playbooks`},{default:i(()=>[e(x,{kinds:[O]},null,8,[`kinds`])]),_:1}),e(S,{kind:O,class:`mb-4`}),l(k).catalogError||l(k).pageErrorFor(O)?(a(),f(l(g),{key:0,variant:`destructive`,class:`mb-4`},{default:i(()=>[e(l(v),null,{default:i(()=>[u(c(l(k).catalogError||l(k).pageErrorFor(O)),1)]),_:1})]),_:1})):r(``,!0),o(`form`,{class:`mb-4 flex flex-wrap gap-2`,onSubmit:_(F,[`prevent`])},[e(l(y),{modelValue:M.value,"onUpdate:modelValue":s[0]||=e=>M.value=e,"aria-label":`Playbook ID`,placeholder:`Playbook ID`,class:`max-w-xs`,disabled:P.value},null,8,[`modelValue`,`disabled`]),e(l(h),{type:`submit`,disabled:P.value||!M.value.trim()||j.value?.playbooks.some(e=>e.id===M.value.trim())},{default:i(()=>[...s[2]||=[u(`Add playbook`,-1)]]),_:1},8,[`disabled`])],32),j.value?.playbooks.length?r(``,!0):(a(),f(l(E),{key:1},{default:i(()=>[e(l(w),null,{default:i(()=>[e(l(C),null,{default:i(()=>[...s[3]||=[u(`No playbooks installed`,-1)]]),_:1})]),_:1})]),_:1})),e(D,{open:N.value,"onUpdate:open":s[1]||=e=>N.value=e,items:j.value?.playbooks??[],title:e=>e.id,"remove-label":`Remove`,mono:``,onRemove:I},{default:i(({item:t,index:n})=>[A.value?(a(),f(l(A).Field,{key:0,name:`playbooks[${n}].yaml`},{default:i(({field:r})=>[e(l(T),{id:`playbook-${n}`,"model-value":r.state.value,"aria-label":`${t.id} YAML`,class:`mb-3 min-h-64 font-mono`,spellcheck:`false`,onBlur:r.handleBlur,"onUpdate:modelValue":r.handleChange},null,8,[`id`,`model-value`,`aria-label`,`onBlur`,`onUpdate:modelValue`])]),_:2},1032,[`name`])):r(``,!0)]),_:1},8,[`open`,`items`,`title`])]))}});export{k as default};
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{t as e}from"./badge.js";import{A as t,C as n,Ct as r,Gt as i,M as a,S as o,Tt as s,Xt as c,_t as l,b as u,ht as d,ir as f,jn as p,k as m,l as h,t as g,x as _,xn as v,y}from"./PageHeader.js";import{N as b,d as x,r as S,u as C}from"./createLucideIcon.js";import{A as w,Ot as T,St as E,Y as D,Z as O,_t as k,d as A,et as j,n as M,q as N,r as P,tt as F}from"./index.js";var I={key:0,class:`space-y-2`},L={class:`tabular-nums text-fg-muted`},R={class:`block max-w-md break-words whitespace-normal text-danger`},z={class:`flex flex-wrap gap-2`},B=a({__name:`ScheduleRunsPage`,setup(a){let B=T(),V=y(()=>String(B.params.id??``)),H=v(null),U=v(null),W=v(``);async function G(){let e=V.value;try{let[t,n]=await Promise.all([S.schedules(),S.scheduleRuns(e)]);if(e!==V.value)return;H.value=t.schedules?.find(t=>t.id===e)??null,U.value=n.runs??[],W.value=``}catch(t){e===V.value&&(W.value=t instanceof Error?t.message:String(t))}}i(V,()=>{U.value=null,G()},{immediate:!0});let K=setInterval(()=>void G(),15e3);d(()=>clearInterval(K));async function q(){W.value=``;try{await S.scheduleRunNow(V.value),await G()}catch(e){W.value=e instanceof Error?e.message:String(e)}}let J=[{id:`scheduled`,label:`Scheduled`,fixed:!0,sort:e=>e.scheduled_for},{id:`started`,label:`Started`},{id:`duration`,label:`Duration`},{id:`result`,label:`Result`,sort:e=>e.result},{id:`error`,label:`Error`},{id:`tasks`,label:`Tasks`}];return(i,a)=>{let d=s(`RouterLink`);return l(),n(`div`,null,[t(g,{title:H.value?.name||`Schedule runs`},{default:c(()=>[t(p(b),{variant:`ghost`,size:`sm`,"as-child":``},{default:c(()=>[t(d,{to:`/org/schedules`},{default:c(()=>[t(p(E),{"data-icon":`inline-start`}),a[0]||=m(`Schedules`,-1)]),_:1})]),_:1}),t(p(b),{size:`sm`,disabled:!H.value,onClick:q},{default:c(()=>[t(p(k),{"data-icon":`inline-start`}),a[1]||=m(`Run now`,-1)]),_:1},8,[`disabled`])]),_:1},8,[`title`]),W.value?(l(),_(p(x),{key:0,variant:`destructive`,class:`mb-4`},{default:c(()=>[t(p(C),null,{default:c(()=>[m(f(W.value),1)]),_:1})]),_:1})):o(``,!0),t(p(w),null,{default:c(()=>[!U.value&&!W.value?(l(),n(`div`,I,[t(p(F),{class:`h-8 w-full`}),t(p(F),{class:`h-8 w-full`})])):U.value?(l(),_(p(A),{key:1,columns:J,rows:U.value,"row-key":e=>String(e.id),"storage-key":`schedule-runs`,"initial-sort":{id:`scheduled`,desc:!0}},{empty:c(()=>[t(p(j),null,{default:c(()=>[t(p(O),null,{default:c(()=>[t(p(D),null,{default:c(()=>[...a[2]||=[m(`No runs yet`,-1)]]),_:1})]),_:1})]),_:1})]),"cell-scheduled":c(({row:e})=>[t(p(N),{at:e.scheduled_for,absolute:``},null,8,[`at`])]),"cell-started":c(({row:e})=>[t(p(N),{at:e.started,absolute:``},null,8,[`at`])]),"cell-duration":c(({row:e})=>[u(`span`,L,f(p(P)(e)||`–`),1)]),"cell-result":c(({row:n})=>[t(p(e),{variant:p(M)[n.result]??`idle`},{default:c(()=>[m(f(n.result),1)]),_:2},1032,[`variant`])]),"cell-error":c(({row:e})=>[u(`span`,R,f(e.error),1)]),"cell-tasks":c(({row:e})=>[u(`span`,z,[(l(!0),n(h,null,r(e.task_ids??[],e=>(l(),_(d,{key:e,to:`/tasks/${e}`,class:`font-mono hover:underline`},{default:c(()=>[m(`#`+f(e),1)]),_:2},1032,[`to`]))),128))])]),_:1},8,[`rows`,`row-key`])):o(``,!0)]),_:1})])}}});export{B as default};
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{t as e}from"./badge.js";import{A as t,C as n,Ct as r,M as ee,S as i,Tt as te,Xt as a,_t as o,b as s,dt as c,ht as l,ir as u,jn as d,k as f,l as p,t as ne,x as m,xn as h,y as g}from"./PageHeader.js";import{N as _,d as v,r as y,u as b}from"./createLucideIcon.js";import{r as re}from"./pinia.js";import{$ as ie,A as x,B as S,Ct as ae,F as oe,G as se,H as ce,I as le,J as ue,K as de,L as C,M as fe,N as pe,P as w,R as me,S as he,U as ge,V as T,W as _e,X as ve,Y as ye,Z as be,_ as xe,b as Se,d as Ce,et as we,f as Te,g as Ee,gt as E,h as D,i as De,j as Oe,m as O,p as ke,q as k,r as Ae,s as je,t as Me,tt as A,u as j,v as Ne,x as Pe,xt as Fe,y as Ie}from"./index.js";var Le={key:1,class:`space-y-2`},Re={class:`flex items-center gap-2`},ze={class:`truncate`},Be={class:`text-fg-muted`},Ve=[`title`],He={key:1,class:`text-fg-subtle`},Ue={class:`tabular-nums text-fg-muted`},M={key:1,class:`text-fg-subtle`},We={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},Ge={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},Ke={class:`flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1`},N=`schedule-settings`,P=ee({__name:`SchedulesPage`,setup(ee){let P=h(null),F=h(``),I=h(``),L;async function R(){try{let e=await y.schedules();P.value=e.schedules??[],F.value=``}catch(e){F.value=e instanceof Error?e.message:String(e)}}c(()=>{R(),L=setInterval(()=>void R(),3e4)}),l(()=>clearInterval(L));let z=de(),{catalog:qe}=re(z);c(z.load);let B=g(()=>se(qe.value,`schedules`)),V=g(()=>z.formFor(N)),H=g(()=>z.draftValue(N)),U=g(()=>z.pageErrorFor(N)),Je=g(()=>H.value?.time_zone||`UTC`),Ye=ae(),Xe=e=>ue(new Date(e),Ye.timeZone),Ze=e=>De(e.timing,Je.value,Xe),W=e=>e.owner.name||e.owner.id||e.owner.kind,Qe=[{id:`enabled`,label:`Enabled`,fixed:!0,class:`w-0`},{id:`name`,label:`Name`,fixed:!0,sort:e=>e.name.toLowerCase()},{id:`owner`,label:`Owner`,sort:W},{id:`interval`,label:`Interval`},{id:`last`,label:`Last Run`,sort:e=>e.last_run?.scheduled_for??``},{id:`duration`,label:`Last Duration`},{id:`next`,label:`Next Run`,sort:e=>e.next_run??``}];function G(e){if(!P.value)return;let t=P.value.findIndex(t=>t.id===e.id);t<0?P.value.push(e):P.value[t]=e}async function K(e){I.value=``;try{await e()}catch(e){I.value=e instanceof Error?e.message:String(e)}}let $e=(e,t)=>K(async()=>G(await y.scheduleSave(e.id,{...e,enabled:t}))),et=e=>K(async()=>{await y.scheduleRunNow(e.id),await R()}),q=h(null),J=h(``),Y=h(!1);function X(e,t){q.value=e,J.value=t,Y.value=!0}function Z(){return{id:crypto.randomUUID(),name:``,owner:{kind:`instance`},enabled:!0,built_in:!1,timing:{kind:`interval`,interval:`24h0m0s`}}}let Q=()=>X(Z(),`New schedule`),tt=e=>X({...Z(),name:`${e.name} copy`,timing:{...e.timing},enabled:!1},`Duplicate schedule`),$=h(null),nt=()=>K(async()=>{let e=$.value;$.value=null,e&&(await y.scheduleDelete(e.id),P.value=P.value?.filter(t=>t.id!==e.id)??null)});return(ee,c)=>{let l=te(`RouterLink`);return o(),n(`div`,null,[t(ne,{title:`Schedules`},{default:a(()=>[t(ge,{kinds:B.value.map(e=>e.kind)},null,8,[`kinds`]),t(d(_),{size:`sm`,disabled:!P.value,onClick:Q},{default:a(()=>[t(d(E),{"data-icon":`inline-start`}),c[2]||=f(`Add schedule`,-1)]),_:1},8,[`disabled`])]),_:1}),(o(!0),n(p,null,r(B.value,e=>(o(),m(_e,{key:e.kind,kind:e.kind,class:`mb-4`},null,8,[`kind`]))),128)),I.value?(o(),m(d(v),{key:0,variant:`destructive`,class:`mb-4`},{default:a(()=>[t(d(b),null,{default:a(()=>[f(u(I.value),1)]),_:1})]),_:1})):i(``,!0),t(d(x),null,{default:a(()=>[F.value?(o(),m(d(v),{key:0,variant:`destructive`},{default:a(()=>[t(d(b),null,{default:a(()=>[f(u(F.value),1)]),_:1})]),_:1})):P.value?(o(),m(d(Ce),{key:2,columns:Qe,rows:P.value,"row-key":e=>e.id,"storage-key":`schedules`,"initial-sort":{id:`name`,desc:!1}},{empty:a(()=>[t(d(we),null,{default:a(()=>[t(d(ve),{variant:`icon`},{default:a(()=>[t(d(Fe))]),_:1}),t(d(be),null,{default:a(()=>[t(d(ye),null,{default:a(()=>[...c[3]||=[f(`No schedules yet`,-1)]]),_:1})]),_:1}),t(d(ie),null,{default:a(()=>[t(d(_),{size:`sm`,onClick:Q},{default:a(()=>[t(d(E),{"data-icon":`inline-start`}),c[4]||=f(`Add schedule`,-1)]),_:1})]),_:1})]),_:1})]),"cell-enabled":a(({row:e})=>[t(d(Oe),{"model-value":e.enabled,"aria-label":`${e.name} enabled`,"onUpdate:modelValue":t=>$e(e,t)},null,8,[`model-value`,`aria-label`,`onUpdate:modelValue`])]),"cell-name":a(({row:t})=>[s(`span`,Re,[s(`span`,ze,u(t.name),1),t.built_in?(o(),m(d(e),{key:0,variant:`outline`},{default:a(()=>[...c[5]||=[f(`Built-in`,-1)]]),_:1})):i(``,!0)])]),"cell-owner":a(({row:e})=>[s(`span`,Be,u(W(e)),1)]),"cell-interval":a(({row:e})=>[s(`span`,{title:e.timing.kind===`cron`?e.timing.cron:void 0},u(Ze(e)),9,Ve)]),"cell-last":a(({row:r})=>[r.last_run?(o(),m(l,{key:0,to:`/org/schedules/${encodeURIComponent(r.id)}/runs`,class:`inline-flex items-center gap-2 hover:underline`},{default:a(()=>[t(d(k),{at:r.last_run.started||r.last_run.scheduled_for},null,8,[`at`]),r.last_run.result===`failed`?(o(),m(d(e),{key:0,variant:`danger`,title:r.Line truncated
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{S as e}from"./badge.js";import{M as t,Xt as n,_t as r,jn as i,kn as a,wt as o,x as s,y as c}from"./PageHeader.js";import{P as l}from"./createLucideIcon.js";function u(e,t=-1/0,n=1/0){return Math.min(n,Math.max(t,e))}function d(e,t){let n=e,r=t.toString(),i=r.indexOf(`.`),a=i>=0?r.length-i:0;if(a>0){let e=10**a;n=Math.round(n*e)/e}return n}function f(e,t,n,r){t=Number(t),n=Number(n);let i=(e-(Number.isNaN(t)?0:t))%r,a=d(Math.abs(i)*2>=r?e+Math.sign(i)*(r-Math.abs(i)):e-i,r);return Number.isNaN(t)?!Number.isNaN(n)&&a>n&&(a=Math.floor(d(n/r,r))*r):a<t?a=t:!Number.isNaN(n)&&a>n&&(a=t+Math.floor(d((n-t)/r,r))*r),a=d(a,r),a}function p(t){return c(()=>!a(t)||!!e(t)?.closest(`form`))}var m=t({__name:`VisuallyHidden`,props:{feature:{type:String,required:!1,default:`focusable`},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`span`}},setup(e){return(t,a)=>(r(),s(i(l),{as:e.as,"as-child":e.asChild,"aria-hidden":e.feature===`fully-hidden`?`true`:void 0,"data-hidden":e.feature===`fully-hidden`?``:void 0,tabindex:e.feature===`fully-hidden`?`-1`:void 0,style:{position:`absolute`,border:0,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,clipPath:`inset(50%)`,whiteSpace:`nowrap`,wordWrap:`normal`,top:`-1px`,left:`-1px`}},{default:n(()=>[o(t.$slots,`default`)]),_:3},8,[`as`,`as-child`,`aria-hidden`,`data-hidden`,`tabindex`]))}});export{f as i,p as n,u as r,m as t};
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
import{$ as e,$t as t,A as n,An as r,At as i,B as a,Bt as o,C as s,Cn as c,Ct as l,D as u,Dn as d,Dt as f,E as p,En as m,Et as h,F as g,Fn as _,Ft as v,G as y,Gt as b,H as x,Ht as S,I as C,It as w,J as T,Jt as E,K as ee,Kt as D,L as O,Lt as te,M as k,Mt as ne,N as re,Nt as ie,O as ae,On as oe,Ot as se,P as ce,Pn as le,Pt as ue,Q as de,Qt as fe,R as pe,Rt as me,S as he,Sn as ge,St as _e,T as ve,Tn as ye,Tt as be,U as xe,Ut as Se,V as Ce,Vt as we,W as Te,Wt as Ee,X as De,Xt as Oe,Y as ke,Yt as Ae,Z as je,Zt as Me,_ as Ne,_n as Pe,_t as A,a as Fe,an as Ie,ar as Le,at as Re,b as ze,bn as Be,bt as Ve,c as He,cn as Ue,ct as We,d as Ge,dn as Ke,dt as qe,en as Je,er as Ye,et as Xe,f as Ze,fn as Qe,ft as $e,g as et,gn as tt,gt as nt,h as rt,hn as it,ht as at,i as ot,in as st,ir as ct,it as j,j as lt,jn as M,jt as ut,k as dt,kn as N,kt as ft,l as pt,ln as mt,lt as ht,m as gt,mn as _t,mt as vt,n as yt,nn as bt,nr as xt,nt as St,o as Ct,on as wt,ot as Tt,p as Et,pn as Dt,pt as Ot,q as kt,qt as At,r as jt,rn as Mt,rr as Nt,rt as Pt,s as Ft,sn as It,st as Lt,tn as Rt,tt as zt,u as Bt,un as Vt,ut as Ht,v as Ut,vn as Wt,vt as Gt,w as Kt,wn as qt,wt as P,x as F,xn as I,xt as Jt,y as L,yn as Yt,yt as Xt,z as Zt,zt as Qt}from"./PageHeader.js";import{$ as $t,B as en,G as tn,H as nn,I as rn,J as an,K as on,L as sn,P as cn,Q as ln,R as un,U as dn,V as fn,W as pn,X as mn,Y as hn,Z as gn,at as _n,et as vn,it as yn,nt as bn,ot as xn,q as Sn,rt as Cn,tt as wn,w as Tn,z as En}from"./createLucideIcon.js";var Dn=Object.defineProperty,On=(e,t)=>{let n={};for(var r in e)Dn(n,r,{get:e[r],enumerable:!0});return t||Dn(n,Symbol.toStringTag,{value:`Module`}),n},kn=On({BaseTransition:()=>ot,BaseTransitionPropsValidators:()=>Fe,Comment:()=>Ct,DeprecationTypes:()=>null,EffectScope:()=>Rt,ErrorCodes:()=>Ft,ErrorTypeStrings:()=>He,Fragment:()=>pt,KeepAlive:()=>Bt,ReactiveEffect:()=>bt,Static:()=>Ge,Suspense:()=>Ze,Teleport:()=>Et,Text:()=>gt,TrackOpTypes:()=>Mt,Transition:()=>sn,TransitionGroup:()=>un,TriggerOpTypes:()=>st,VueElement:()=>En,assertNumber:()=>rt,callWithAsyncErrorHandling:()=>et,callWithErrorHandling:()=>Ne,camelize:()=>le,capitalize:()=>_,cloneVNode:()=>Ut,compatUtils:()=>null,compile:()=>An,computed:()=>L,createApp:()=>en,createBlock:()=>F,createCommentVNode:()=>he,createElementBlock:()=>s,createElementVNode:()=>ze,createHydrationRenderer:()=>Kt,createPropsRestProxy:()=>ve,createRenderer:()=>p,createSSRApp:()=>fn,createSlots:()=>u,createStaticVNode:()=>ae,createTextVNode:()=>dt,createVNode:()=>n,customRef:()=>Ie,defineAsyncComponent:()=>lt,defineComponent:()=>k,defineCustomElement:()=>nn,defineEmits:()=>re,defineExpose:()=>ce,defineModel:()=>g,defineOptions:()=>C,defineProps:()=>O,defineSSRCustomElement:()=>dn,defineSlots:()=>pe,devtools:()=>Zt,effect:()=>wt,effectScope:()=>It,getCurrentInstance:()=>a,getCurrentScope:()=>Ue,getCurrentWatcher:()=>mt,getTransitionRawChildren:()=>Ce,guardReactiveProps:()=>x,h:()=>xe,handleError:()=>Te,hasInjectionContext:()=>y,hydrate:()=>pn,hydrateOnIdle:()=>ee,hydrateOnInteraction:()=>kt,hydrateOnMediaQuery:()=>T,hydrateOnVisible:()=>ke,initCustomFormatter:()=>De,initDirectivesForSSR:()=>tn,inject:()=>je,isMemoSame:()=>de,isProxy:()=>Vt,isReactive:()=>Ke,isReadonly:()=>Qe,isRef:()=>Dt,isRuntimeOnly:()=>e,isShallow:()=>_t,isVNode:()=>Xe,markRaw:()=>it,mergeDefaults:()=>zt,mergeModels:()=>St,mergeProps:()=>Pt,nextTick:()=>j,nodeOps:()=>on,normalizeClass:()=>Ye,normalizeProps:()=>xt,normalizeStyle:()=>Nt,onActivated:()=>Re,onBeforeMount:()=>Tt,onBeforeUnmount:()=>Lt,onBeforeUpdate:()=>We,onDeactivated:()=>ht,onErrorCaptured:()=>Ht,onMounted:()=>qe,onRenderTracked:()=>$e,onRenderTriggered:()=>Ot,onScopeDispose:()=>tt,onServerPrefetch:()=>vt,onUnmounted:()=>at,onUpdated:()=>nt,onWatcherCleanup:()=>Pe,openBlock:()=>A,patchProp:()=>Sn,popScopeId:()=>Gt,provide:()=>Xt,proxyRefs:()=>Wt,pushScopeId:()=>Ve,queuePostFlushCb:()=>Jt,reactive:()=>Yt,readonly:()=>Be,ref:()=>I,registerRuntimeCompiler:()=>_e,render:()=>an,renderList:()=>l,renderSlot:()=>P,resolveComponent:()=>be,resolveDirective:()=>h,resolveDynamicComponent:()=>f,resolveFilter:()=>null,resolveTransitionHooks:()=>se,setBlockTracking:()=>ft,setDevtoolsHook:()=>i,setTransitionHooks:()=>ut,shallowReactive:()=>ge,shallowReadonly:()=>c,shallowRef:()=>qt,ssrContextKey:()=>ne,ssrUtils:()=>ie,stop:()=>ye,toDisplayString:()=>ct,toHandlerKey:()=>Le,toHandlers:()=>ue,toRaw:()=>m,toRef:()=>d,toRefs:()=>oe,toValue:()=>N,transformVNodeArgs:()=>v,triggerRef:()=>r,unref:()=>M,useAttrs:()=>w,useCssModule:()=>hn,useCssVars:()=>mn,useHost:()=>gn,useId:()=>te,useModel:()=>me,useSSRContext:()=>Qt,useShadowRoot:()=>ln,useSlots:()=>o,useTemplateRef:()=>we,useTransitionState:()=>S,vModelCheckbox:()=>$t,vModelDynamic:()=>vn,vModelRadio:()=>wn,vModelSelect:()=>bn,vModelText:()=>Cn,vShow:()=>yn,version:()=>Se,warn:()=>Ee,watch:()=>b,watchEffect:()=>D,watchPostEffect:()=>At,watchSyncEffect:()=>E,withAsyncContext:()=>Ae,withCtx:()=>Oe,withDefaults:()=>Me,withDirectives:()=>fe,Line truncated
|
||||
`)].join(`
|
||||
`))}return()=>i.value||r.value||s.value?xe(t.default({present:s.value})[0],{ref:e=>{let t=V(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?o.value=t.firstElementChild:o.value=t),t}}):null}}),$r=`dismissableLayer.pointerDownOutside`,ei=`dismissableLayer.focusOutside`;function ti(e){if(typeof e!=`object`||!e)return!1;let t=e.ownerDocument?.defaultView;return typeof Element<`u`&&e instanceof Element||!!t&&e instanceof t.Element}function ni(e,t){if(!ti(t))return!1;if(e.contains(t))return!0;let n=t.closest(`[data-dismissable-layer]`),r=e.dataset.dismissableLayer===``?e:e.querySelector(`[data-dismissable-layer]`),i=Array.from(e.ownerDocument.querySelectorAll(`[data-dismissable-layer]`));return!!(n&&(r===n||i.indexOf(r)<i.indexOf(n)))}function ri(e,t,n=!0){let r=I(!1),i=I(()=>{});return D(a=>{if(!B||!N(n))return;let o=t?.value?.ownerDocument??globalThis.document,s=async n=>{let a=n.target;if(t?.value&&a){if(ni(t.value,a))o.removeEventListener(`click`,i.value),r.value=!1;else{if(n.target&&!r.value){let t={originalEvent:n};function r(){Mn($r,e,t)}n.pointerType===`touch`?(o.removeEventListener(`click`,i.value),i.value=r,o.addEventListener(`click`,i.value,{once:!0})):r()}else o.removeEventListener(`click`,i.value);r.value=!1}}},c=window.setTimeout(()=>{o.addEventListener(`pointerdown`,s)},0);a(()=>{window.clearTimeout(c),o.removeEventListener(`pointerdown`,s),o.removeEventListener(`click`,i.value)})}),{onPointerDownCapture:()=>{N(n)&&(r.value=!0)}}}function ii(e,t,n=!0){let r=I(!1);return D(i=>{if(!B||!N(n))return;let a=t?.value?.ownerDocument??globalThis.document,o=async n=>{if(!t?.value)return;await j(),await j();let i=n.target;t.value&&i&&!ni(t.value,i)&&n.target&&!r.value&&Mn(ei,e,{originalEvent:n})};a.addEventListener(`focusin`,o),i(()=>a.removeEventListener(`focusin`,o))}),{onFocusCapture:()=>{N(n)&&(r.value=!0)},onBlurCapture:()=>{N(n)&&(r.value=!1)}}}var H=Yt({layersRoot:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ai=k({__name:`DismissableLayer`,props:{disableOutsidePointerEvents:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},present:{type:Boolean,required:!1,default:!0}},emits:[`escapeKeyDown`,`pointerDownOutside`,`focusOutside`,`interactOutside`,`dismiss`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=Nr(),o=L(()=>a.value?.ownerDocument??globalThis.document),s=L(()=>H.layersRoot),c=L(()=>a.value?Array.from(s.value).indexOf(a.value):-1),l=L(()=>H.layersWithOutsidePointerEventsDisabled.size>0),u=L(()=>{let e=Array.from(s.value),[t]=[...H.layersWithOutsidePointerEventsDisabled].slice(-1),n=e.indexOf(t);return c.value>=n}),d=ri(async e=>{let t=[...H.branches].some(t=>t?.contains(e.target));n.present&&u.value&&!t&&(r(`pointerDownOutside`,e),r(`interactOutside`,e),await j(),e.defaultPrevented||r(`dismiss`))},a,()=>n.present),f=ii(e=>{let t=[...H.branches].some(t=>t?.contains(e.target));n.present&&!t&&(r(`focusOutside`,e),r(`interactOutside`,e),e.defaultPrevented||r(`dismiss`))},a);return ar(`Escape`,e=>{n.present&&c.value===s.value.size-1&&(r(`escapeKeyDown`,e),e.defaultPrevented||r(`dismiss`))},{target:()=>o.value?.defaultView??globalThis.window}),b([a,()=>n.disableOutsidePointerEvents,()=>n.present],([e,t,n],r,i)=>{if(e&&n&&t){let t=e.ownerDocument;_r(t,e),H.layersWithOutsidePointerEventsDisabled.add(e),i(()=>{H.layersWithOutsidePointerEventsDisabled.delete(e),vr(t,e)})}},{immediate:!0}),b([a,()=>n.present],([e,t],n,r)=>{e&&t&&(s.value.add(e),r(()=>{s.value.delete(e)}))},{immediate:!0}),D(e=>{e(()=>{a.value&&(s.value.delete(a.value),H.layersWithOutsidePointerEventsDisabled.delete(a.value))})}),(t,n)=>(A(),F(M(cn),{ref:M(i),"as-child":e.asChild,as:e.as,"data-dismissable-layer":``,style:Nt({pointerEvents:l.value?u.value?`auto`:`none`:void 0}),onFocusCapture:M(f).onFocusCapture,onBlurCapture:M(f).onBlurCapture,onPointerdownCapture:M(d).onPointerDownCapture},{default:Oe(()=>[P(t.$slots,`default`)]),_:3},8,[`as-child`,`as`,`style`,`onFocusCapture`,`onBlurCapture`,`onPointerdownCapture`]))}}),oi=Pn(()=>I([]));function si(){let e=oi();return{add(t){let n=e.value[0];t!==n&&n?.pause(),e.value=ci(e.value,t),e.value.unshift(t)},remove(t){e.value=ci(e.value,t),e.value[0]?.resume()}}}function ci(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}var li=`focusScope.autoFocusOnMount`,ui=`focusScope.autoFocusOnUnmount`,di={bubbles:!1,cancelable:!0};function fi(e,t){let n=t;for(;n;){if(e.contains(n))return!0;n=n.getRootNode().host??null}return!1}function pi(e,{select:t=!1}={}){let n=R();for(let r of e)if(U(r,{select:t}),R()!==n)return!0}function mi(e){let t=hi(e);return[gi(t,e),gi(t.reverse(),e)]}function hi(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n
Line truncated
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
import{$n as e,A as t,B as n,Bn as r,C as i,Cn as a,Dn as o,E as s,En as c,Fn as l,G as u,Gn as d,Gt as f,Hn as p,Ht as m,In as h,Jn as g,Kn as ee,Ln as _,M as v,Mn as y,Nn as te,On as ne,Ot as b,Pn as x,Qn as S,Rn as C,U as w,Un as re,V as ie,Vn as T,Wn as ae,Xn as oe,Xt as se,Yn as E,Z as ce,Zn as D,_t as O,a as le,an as ue,bn as de,cn as fe,ct as pe,d as me,dt as he,er as k,g as ge,gn as _e,gt as ve,ht as ye,i as be,it as xe,jn as A,jt as Se,kn as Ce,l as we,n as Te,o as Ee,or as De,pn as Oe,qn as j,r as ke,rt as Ae,tr as je,v as Me,w as Ne,wn as Pe,wt as Fe,x as Ie,xn as Le,xt as Re,y as ze,yn as Be,zn as Ve}from"./PageHeader.js";var He=void 0,Ue=typeof window<`u`&&window.trustedTypes;if(Ue)try{He=Ue.createPolicy(`vue`,{createHTML:e=>e})}catch{}var We=He?e=>He.createHTML(e):e=>e,Ge=`http://www.w3.org/2000/svg`,Ke=`http://www.w3.org/1998/Math/MathML`,M=typeof document<`u`?document:null,qe=M&&M.createElement(`template`),Je={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{let t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{let i=t===`svg`?M.createElementNS(Ge,e):t===`mathml`?M.createElementNS(Ke,e):n?M.createElement(e,{is:n}):M.createElement(e);return e===`select`&&r&&r.multiple!=null&&i.setAttribute(`multiple`,r.multiple),i},createText:e=>M.createTextNode(e),createComment:e=>M.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>M.querySelector(e),setScopeId(e,t){e.setAttribute(t,``)},insertStaticContent(e,t,n,r,i,a){let o=n?n.previousSibling:t.lastChild;if(i&&(i===a||i.nextSibling))for(;t.insertBefore(i.cloneNode(!0),n),i!==a&&(i=i.nextSibling););else{qe.innerHTML=We(r===`svg`?`<svg>${e}</svg>`:r===`mathml`?`<math>${e}</math>`:e);let i=qe.content;if(r===`svg`||r===`mathml`){let e=i.firstChild;for(;e.firstChild;)i.appendChild(e.firstChild);i.removeChild(e)}t.insertBefore(i,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},N=`transition`,P=`animation`,F=Symbol(`_vtc`),Ye={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},Xe=h({},le,Ye),Ze=(e=>(e.displayName=`Transition`,e.props=Xe,e))((e,{slots:t})=>w(be,$e(e),t)),I=(e,t=[])=>{T(e)?e.forEach(e=>e(...t)):e&&e(...t)},Qe=e=>e?T(e)?e.some(e=>e.length>1):e.length>1:!1;function $e(e){let t={};for(let n in e)n in Ye||(t[n]=e[n]);if(e.css===!1)return t;let{name:n=`v`,type:r,duration:i,enterFromClass:a=`${n}-enter-from`,enterActiveClass:o=`${n}-enter-active`,enterToClass:s=`${n}-enter-to`,appearFromClass:c=a,appearActiveClass:l=o,appearToClass:u=s,leaveFromClass:d=`${n}-leave-from`,leaveActiveClass:f=`${n}-leave-active`,leaveToClass:p=`${n}-leave-to`}=e,m=et(i),g=m&&m[0],ee=m&&m[1],{onBeforeEnter:_,onEnter:v,onEnterCancelled:y,onLeave:te,onLeaveCancelled:ne,onBeforeAppear:b=_,onAppear:x=v,onAppearCancelled:S=y}=t,C=(e,t,n,r)=>{e._enterCancelled=r,R(e,t?u:s),R(e,t?l:o),n&&n()},w=(e,t)=>{e._isLeaving=!1,R(e,d),R(e,p),R(e,f),t&&t()},re=e=>(t,n)=>{let i=e?x:v,o=()=>C(t,e,n);I(i,[t,o]),nt(()=>{R(t,e?c:a),L(t,e?u:s),Qe(i)||it(t,r,g,o)})};return h(t,{onBeforeEnter(e){I(_,[e]),L(e,a),L(e,o)},onBeforeAppear(e){I(b,[e]),L(e,c),L(e,l)},onEnter:re(!1),onAppear:re(!0),onLeave(e,t){e._isLeaving=!0;let n=()=>w(e,t);L(e,d),e._enterCancelled?(L(e,f),ct(e)):(ct(e),L(e,f)),nt(()=>{e._isLeaving&&(R(e,d),L(e,p),Qe(te)||it(e,r,ee,n))}),I(te,[e,n])},onEnterCancelled(e){C(e,!1,void 0,!0),I(y,[e])},onAppearCancelled(e){C(e,!0,void 0,!0),I(S,[e])},onLeaveCancelled(e){w(e),I(ne,[e])}})}function et(e){if(e==null)return null;if(ae(e))return[tt(e.enter),tt(e.leave)];{let t=tt(e);return[t,t]}}function tt(e){return De(e)}function L(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.add(t)),(e[F]||(e[F]=new Set)).add(t)}function R(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.remove(t));let n=e[F];n&&(n.delete(t),n.size||(e[F]=void 0))}function nt(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}var rt=0;function it(e,t,n,r){let i=e._endId=++rt,a=()=>{i===e._endId&&r()};if(n!=null)return setTimeout(a,n);let{type:o,timeout:s,propCount:c}=at(e,t);if(!o)return r();let l=o+`end`,u=0,d=()=>{e.removeEventListener(l,f),a()},f=t=>{t.target===e&&++u>=c&&d()};setTimeout(()=>{u<c&&d()},s+1),e.addEventListener(l,f)}function at(e,t){let n=window.getComputedStyle(e),r=e=>(n[e]||``).split(`, `),i=r(`${N}Delay`),a=r(`${N}Duration`),o=ot(i,a),s=r(`${P}Delay`),c=r(`${P}Duration`),l=ot(s,c),u=null,d=0,f=0;t===N?o>0&&(u=N,d=o,f=a.length):t===P?l>0&&(u=P,d=l,f=c.length):(d=Math.max(o,l),u=d>0?o>l?N:P:null,f=u?u===N?a.length:c.length:0);let p=u===N&&/\b(?:transform|all)(?:,|$)/.test(r(`${N}Property`).toString());return{type:u,timeout:d,propCount:f,hasTransform:p}}function ot(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.maLine truncated
|
||||
`))),e[J]=q(i);let a=r||i.props&&i.props.type===`number`;W(e,t?`change`:`input`,t=>{t.target.composing||e[J](un(e.value,n,a))}),(n||a)&&W(e,`change`,()=>{e.value=un(e.value,n,a)}),t||(W(e,`compositionstart`,sn),W(e,`compositionend`,cn),W(e,`change`,cn))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[ln];delete e[ln],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[J](un(e.value,n,r)):e.value=i},beforeUpdate(t,{value:n,oldValue:r,modifiers:{lazy:i,trim:a,number:o}},s){if(t[J]=q(s),t.composing)return;let c=(o||t.type===`number`)&&!/^0\d/.test(t.value)?e(t.value):t.value,l=n??``;if(c===l)return;let u=t.getRootNode();(u instanceof Document||u instanceof ShadowRoot)&&u.activeElement===t&&t.type!==`range`&&(i&&n===r||a&&t.value.trim()===l)||(t.value=l)}},fn={deep:!0,created(e,t,n){e[J]=q(n),W(e,`change`,()=>{let t=e._modelValue,n=Y(e),r=e.checked,i=e[J];if(T(t)){let e=S(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(j(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(vn(e,r))})},mounted:pn,beforeUpdate(e,t,n){e[J]=q(n),pn(e,t,n)}};function pn(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(T(t))i=S(t,r.props.value)>-1;else if(j(t))i=t.has(r.props.value);else{if(t===n)return;i=D(t,vn(e,!0))}e.checked!==i&&(e.checked=i)}var mn={created(e,{value:t},n){e.checked=D(t,n.props.value),e[J]=q(n),W(e,`change`,()=>{e[J](Y(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[J]=q(r),t!==n&&(e.checked=D(t,r.props.value))}},hn={deep:!0,created(t,{value:n,modifiers:{number:r}},i){t._modelValue=n,W(t,`change`,()=>{let n=Array.prototype.filter.call(t.options,e=>e.selected).map(t=>r?e(Y(t)):Y(t)),i=t.multiple,a=i?j(t._modelValue)?new Set(n):n:n[0],o=t._pendingValue=[i,i?T(a)?n.slice():n:a];try{t[J](a)}finally{xe(()=>{t._pendingValue===o&&(t._pendingValue=void 0)})}}),t[J]=q(i)},mounted(e,{value:t}){_n(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[J]=q(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,n&&n[0]===e.multiple&&gn(t,n[1],n[0])||_n(e,t)}};function gn(e,t,n){if(!n||T(e))return D(e,t);if(j(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function _n(e,t){let n=e.multiple,r=T(t);if(!n||r||j(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=Y(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):S(t,o)>-1}else a.selected=t.has(o)}else if(D(Y(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function Y(e){return`_value`in e?e._value:e.value}function vn(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var yn={created(e,t,n){xn(e,t,n,null,`created`)},mounted(e,t,n){xn(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){xn(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){xn(e,t,n,r,`updated`)}};function bn(e,t){switch(e){case`SELECT`:return hn;case`TEXTAREA`:return dn;default:switch(t){case`checkbox`:return fn;case`radio`:return mn;default:return dn}}}function xn(e,t,n,r,i){let a=bn(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function Sn(){dn.getSSRProps=({value:e})=>({value:e}),mn.getSSRProps=({value:e},t)=>{if(t.props&&D(t.props.value,e))return{checked:!0}},fn.getSSRProps=({value:e},t)=>{if(T(e)){if(t.props&&S(e,t.props.value)>-1)return{checked:!0}}else if(j(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},yn.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=bn(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var Cn=[`ctrl`,`shift`,`alt`,`meta`],wn={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)=>Cn.some(n=>e[`${n}Key`]&&!t.includes(n))},Tn=(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=wn[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},En={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},Dn=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=C(n.key);if(t.some(e=>e===r||En[e]===r))return e(n)}))},On=h({patchProp:It},Je),kn,An=!1;function jn(){return kn||=s(On)}function Mn(){return kn=An?kn:Ne(On),An=!0,kn}var Nn=((...e)=>{jn().render(...e)}),Pn=((...e)=>{Mn().hydrate(...e)}),Fn=((...e)=>{let t=jn().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Rn(e);if(!r)return;let i=t._component;p(i)||i.render||i.template||(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,Ln(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t}),In=((...e)=>{let t=Mn().createApp(...e),{mount:n}=t;return t.m
Line truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Fr;function Ir(e){Fr=e}var Lr=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Rr(e){let t=e instanceof Lr?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 zr(e,t){let n=await fetch(e,t);if(Fr?.(n.status===401),!n.ok)throw new Lr(await Pr(n),n.status);return n}async function Q(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Nr,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 zr(e,s);return a?await c.json():void 0}var Br={recoveryCode:()=>Q(`/api/account/recovery`,{method:`POST`,body:{}}),recoverAccount:(e,t,n)=>Q(`/api/auth/recover`,{method:`POST`,body:{email:e,code:t,password:n},parse:!1}),authStatus:()=>Q(`/api/auth/status`),setupAccount:e=>Q(`/api/auth/setup`,{method:`POST`,body:e}),signIn:(e,t)=>Q(`/api/auth/login`,{method:`POST`,body:{email:e,password:t}}),signOut:()=>Q(`/api/auth/logout`,{method:`POST`,body:{},parse:!1}),createAccount:e=>Q(`/api/accounts`,{method:`POST`,body:e}),changePassword:(e,t)=>Q(`/api/account/password`,{method:`POST`,body:{current_password:e,new_password:t},parse:!1}),authentication:()=>Q(`/api/authentication`),saveAuthentication:e=>Q(`/api/authentication`,{method:`PUT`,body:e,parse:!1}),tokens:()=>Q(`/api/tokens`),createToken:(e,t)=>Q(`/api/tokens`,{method:`POST`,body:{name:e,days:t}}),revokeToken:e=>Q(`/api/tokens/${encodeURIComponent(e)}`,{method:`DELETE`,body:{},parse:!1}),passkeys:()=>Q(`/api/account/passkeys`),deletePasskey:e=>Q(`/api/account/passkeys/${encodeURIComponent(e)}`,{method:`DELETE`,body:{},parse:!1}),beginPasskey:e=>Q(e?`/api/account/passkeys/begin`:`/api/auth/passkey/begin`,{method:`POST`,body:{}}),finishPasskey:(e,t,n)=>Q(e?`/api/account/passkeys/finish`:`/api/auth/passkey/finish`,{method:`POST`,body:{credential:t,name:n}}),secretEngines:()=>Q(`/api/secret-engines`),checkSecret:e=>Q(`/api/secret-references/check`,{method:`POST`,body:e}),health:()=>Q(`/health/detailed`),services:()=>Q(`/api/services`),policies:()=>Q(`/api/access/policies`),denials:e=>Q(`/api/access/denials${e?`?limit=${e}`:``}`),putPolicy:e=>Q(`/api/access/policies`,{method:`PUT`,body:e}),deletePolicy:e=>Q(`/api/access/policies`,{method:`DELETE`,body:e,parse:!1}),schedules:()=>Q(`/api/schedules`),scheduleSave:(e,t)=>Q(`/api/schedules/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),scheduleDelete:e=>Q(`/api/schedules/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),scheduleRunNow:e=>Q(`/api/schedules/${encodeURIComponent(e)}/runs`,{method:`POST`,body:{}}),scheduleRuns:e=>Q(`/api/schedules/${encodeURIComponent(e)}/runs`),orgs:()=>Q(`/api/orgs`),orgSelect:e=>Q(`/api/orgs/current`,{method:`PUT`,body:{id:e},parse:!1}),orgCreate:e=>Q(`/api/orgs`,{method:`POST`,body:e}),org:e=>Q(`/api/orgs/${encodeURIComponent(e)}`),orgWorkspaces:e=>Q(`/api/orgs/${encodeURIComponent(e)}/workspaces`),createOrgWorkspace:(e,t)=>Q(`/api/orgs/${encodeURIComponent(e)}/workspaces`,{method:`POST`,body:t}),orgAgents:e=>Q(`/api/orgs/${encodeURIComponent(e)}/agents`),orgMembers:e=>Q(`/api/orgs/${encodeURIComponent(e)}/members`),addOrgMember:(e,t)=>Q(`/api/orgs/${encodeURIComponent(e)}/members`,{method:`POST`,body:t}),setOrgMember:(e,t,n)=>Q(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`PUT`,body:n}),removeOrgMember:(e,t,n)=>Q(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`+Z({workspace:n}),{method:`DELETE`,parse:!1}),assignOrgAgent:(e,t)=>Q(`/api/orgs/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}`,{method:`PUT`}),alerts:()=>Q(`/api/alerts`),dismissAlert:e=>Q(`/api/alerts/${e}/dismiss`,{method:`POST`,parse:!1}),identities:()=>Q(`/api/identities`),identityCreate:e=>Q(`/api/identities`,{method:`POST`,body:e}),identityCommand:(e,t,n)=>Q(`/api/identities/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`POST`,body:n}),summary:()=>Q(`/api/summary`),tasks:()=>Q(`/api/tasks`),taskPage:async e=>{let t=await zr(`/api/tasks`+Z(e),{headers:{Accept:`application/json`},signal:AbortSignal.timeout(Nr)});return{tasks:await t.json(),next:t.headers.get(`X-Next-Cursor`)}},taskMeta:()=>Q(`/api/task-meta`),task:e=>Q(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Q(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Q(`/api/tasks/${encodeURIComponent(e)}/changes`+Z(t)),taskDebug:(e,t)=>Q(`/api/tasks/${encodeURIComponent(e)}/debug`+Z(t)),taskAction:(e,t,n)=>Q(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t,...n}}),setup:()=>Q(`/api/setup`),capabilities:()=>Q(`/api/capabilities`),workflows:()=>Q(`/api/workflows`),workflowEnabled:(e,t)=>Q(`/api/workflows/${encodeURIComponent(Line truncated
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
var e=[Object.freeze(JSON.parse(`{"displayName":"CSS","name":"css","patterns":[{"include":"#comment-block"},{"include":"#escapes"},{"include":"#combinator-invalid"},{"include":"#selector"},{"include":"#at-rules"},{"include":"#rule-list"}],"repository":{"arithmetic-operators":{"match":"[*/]|(?<=\\\\s|^)[-+](?=\\\\s|$)","name":"keyword.operator.arithmetic.css"},"at-rules":{"patterns":[{"begin":"\\\\A\\\\uFEFF?(?i:(?=\\\\s*@charset\\\\b))","end":";|(?=$)","endCaptures":{"0":{"name":"punctuation.terminator.rule.css"}},"name":"meta.at-rule.charset.css","patterns":[{"captures":{"1":{"name":"invalid.illegal.not-lowercase.charset.css"},"2":{"name":"invalid.illegal.leading-whitespace.charset.css"},"3":{"name":"invalid.illegal.no-whitespace.charset.css"},"4":{"name":"invalid.illegal.whitespace.charset.css"},"5":{"name":"invalid.illegal.not-double-quoted.charset.css"},"6":{"name":"invalid.illegal.unclosed-string.charset.css"},"7":{"name":"invalid.illegal.unexpected-characters.charset.css"}},"match":"\\\\G((?!@charset)@\\\\w+)|\\\\G(\\\\s+)|(@charset\\\\S[^;]*)|(?<=@charset)( {2,}|\\\\t+)|(?<=@charset )([^\\";]+)|(\\"[^\\"]+)$|(?<=\\")([^;]+)"},{"captures":{"1":{"name":"keyword.control.at-rule.charset.css"},"2":{"name":"punctuation.definition.keyword.css"}},"match":"((@)charset)(?=\\\\s)"},{"begin":"\\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.css"}},"end":"\\"|$","endCaptures":{"0":{"name":"punctuation.definition.string.end.css"}},"name":"string.quoted.double.css","patterns":[{"begin":"(?:\\\\G|^)(?=[^\\"]+$)","end":"$","name":"invalid.illegal.unclosed.string.css"}]}]},{"begin":"(?i)((@)import)(?:\\\\s+|$|(?=[\\"']|/\\\\*))","beginCaptures":{"1":{"name":"keyword.control.at-rule.import.css"},"2":{"name":"punctuation.definition.keyword.css"}},"end":";","endCaptures":{"0":{"name":"punctuation.terminator.rule.css"}},"name":"meta.at-rule.import.css","patterns":[{"begin":"\\\\G\\\\s*(?=/\\\\*)","end":"(?<=\\\\*/)\\\\s*","patterns":[{"include":"#comment-block"}]},{"include":"#string"},{"include":"#url"},{"match":"\\\\s+"},{"include":"#layer-import"},{"include":"#media-query-list"}]},{"begin":"(?i)((@)font-face)(?=\\\\s*|\\\\{|/\\\\*|$)","beginCaptures":{"1":{"name":"keyword.control.at-rule.font-face.css"},"2":{"name":"punctuation.definition.keyword.css"}},"end":"(?!\\\\G)","name":"meta.at-rule.font-face.css","patterns":[{"include":"#comment-block"},{"include":"#escapes"},{"include":"#rule-list"}]},{"begin":"(?i)(@)page(?=[:{\\\\s]|/\\\\*|$)","captures":{"0":{"name":"keyword.control.at-rule.page.css"},"1":{"name":"punctuation.definition.keyword.css"}},"end":"(?=\\\\s*($|[:;{]))","name":"meta.at-rule.page.css","patterns":[{"include":"#rule-list"}]},{"begin":"(?i)(?=@media([(\\\\s]|/\\\\*|$))","end":"(?<=})(?!\\\\G)","patterns":[{"begin":"(?i)\\\\G(@)media","beginCaptures":{"0":{"name":"keyword.control.at-rule.media.css"},"1":{"name":"punctuation.definition.keyword.css"}},"end":"(?=\\\\s*[;{])","name":"meta.at-rule.media.header.css","patterns":[{"include":"#media-query-list"}]},{"begin":"\\\\{","beginCaptures":{"0":{"name":"punctuation.section.media.begin.bracket.curly.css"}},"end":"}","endCaptures":{"0":{"name":"punctuation.section.media.end.bracket.curly.css"}},"name":"meta.at-rule.media.body.css","patterns":[{"include":"#rule-list-innards"},{"include":"$self"}]}]},{"begin":"(?i)(?=@counter-style([\\"';{\\\\s]|/\\\\*|$))","end":"(?<=})(?!\\\\G)","patterns":[{"begin":"(?i)\\\\G(@)counter-style","beginCaptures":{"0":{"name":"keyword.control.at-rule.counter-style.css"},"1":{"name":"punctuation.definition.keyword.css"}},"end":"(?=\\\\s*\\\\{)","name":"meta.at-rule.counter-style.header.css","patterns":[{"include":"#comment-block"},{"include":"#escapes"},{"captures":{"0":{"patterns":[{"include":"#escapes"}]}},"match":"[-A-Z_a-z[^\\\\x00-\\\\x7F]](?:[-0-9A-Z_a-z[^\\\\x00-\\\\x7F]]|\\\\\\\\(?:\\\\h{1,6}|.))*","name":"variable.parameter.style-name.css"}]},{"begin":"\\\\{","beginCaptures":{"0":{"name":"punctuation.section.property-list.begin.bracket.curly.css"}},"end":"}","endCaptures":{"0":{"name":"punctuation.section.property-list.end.bracket.curly.css"}},"name":"meta.at-rule.counter-style.body.css","patterns":[{"include":"#comment-block"},{"include":"#escapes"},{"include":"#rule-list-innards"}]}]},{"begin":"(?i)(?=@document([\\"';{\\\\s]|/\\\\*|$))","end":"(?<=})(?!\\\\G)","patterns":[{"begin":"(?i)\\\\G(@)document","beginCaptures":{"0":{"name":"keyword.control.at-rule.document.css"},"1":{"name":"punctuation.definition.keyword.css"}},"end":"(?=\\\\s*[;{])","name":"meta.at-rule.document.header.css","patterns":[{"begin":"(?i)(?<![-\\\\w])(url-prefix|domain|regexp)(\\\\()","beginCaptures":{"1":{"name":"support.function.document-rule.css"},"2":{"name":"punctuation.section.function.begin.bracket.round.css"}},"end":"\\\\)","endCaptures":{"0":{"name":"punctuation.section.function.end.bracket.round.css"}},"name":"meta.function.document-rule.css","patterns":[{"include":"#string"},{"include":"#comment-block"},{"incl
Line truncated
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
export{t as default}from"./css.js";
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
var e=[Object.freeze(JSON.parse(`{"displayName":"Diff","name":"diff","patterns":[{"captures":{"1":{"name":"punctuation.definition.separator.diff"}},"match":"^((\\\\*{15})|(={67})|(-{3}))$\\\\n?","name":"meta.separator.diff"},{"match":"^\\\\d+(,\\\\d+)*([acd])\\\\d+(,\\\\d+)*$\\\\n?","name":"meta.diff.range.normal"},{"captures":{"1":{"name":"punctuation.definition.range.diff"},"2":{"name":"meta.toc-list.line-number.diff"},"3":{"name":"punctuation.definition.range.diff"}},"match":"^(@@)\\\\s*(.+?)\\\\s*(@@)($\\\\n?)?","name":"meta.diff.range.unified"},{"captures":{"3":{"name":"punctuation.definition.range.diff"},"4":{"name":"punctuation.definition.range.diff"},"6":{"name":"punctuation.definition.range.diff"},"7":{"name":"punctuation.definition.range.diff"}},"match":"^(((-{3}) .+ (-{4}))|((\\\\*{3}) .+ (\\\\*{4})))$\\\\n?","name":"meta.diff.range.context"},{"match":"^diff --git a/.*$\\\\n?","name":"meta.diff.header.git"},{"match":"^diff (-|\\\\S+\\\\s+\\\\S+).*$\\\\n?","name":"meta.diff.header.command"},{"captures":{"4":{"name":"punctuation.definition.from-file.diff"},"6":{"name":"punctuation.definition.from-file.diff"},"7":{"name":"punctuation.definition.from-file.diff"}},"match":"^((((-{3}) .+)|((\\\\*{3}) .+))$\\\\n?|(={4}) .+(?= - ))","name":"meta.diff.header.from-file"},{"captures":{"2":{"name":"punctuation.definition.to-file.diff"},"3":{"name":"punctuation.definition.to-file.diff"},"4":{"name":"punctuation.definition.to-file.diff"}},"match":"(^(\\\\+{3}) .+$\\\\n?| (-) .* (={4})$\\\\n?)","name":"meta.diff.header.to-file"},{"captures":{"3":{"name":"punctuation.definition.inserted.diff"},"6":{"name":"punctuation.definition.inserted.diff"}},"match":"^(((>)( .*)?)|((\\\\+).*))$\\\\n?","name":"markup.inserted.diff"},{"captures":{"1":{"name":"punctuation.definition.changed.diff"}},"match":"^(!).*$\\\\n?","name":"markup.changed.diff"},{"captures":{"3":{"name":"punctuation.definition.deleted.diff"},"6":{"name":"punctuation.definition.deleted.diff"}},"match":"^(((<)( .*)?)|((-).*))$\\\\n?","name":"markup.deleted.diff"},{"begin":"^(#)","captures":{"1":{"name":"punctuation.definition.comment.diff"}},"end":"\\\\n","name":"comment.line.number-sign.diff"},{"match":"^index [0-9a-f]{7,40}\\\\.\\\\.[0-9a-f]{7,40}.*$\\\\n?","name":"meta.diff.index.git"},{"captures":{"1":{"name":"punctuation.separator.key-value.diff"},"2":{"name":"meta.toc-list.file-name.diff"}},"match":"^Index(:) (.+)$\\\\n?","name":"meta.diff.index"},{"match":"^Only in .*: .*$\\\\n?","name":"meta.diff.only-in"}],"scopeName":"source.diff"}`))];export{e as default};
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
var e=Object.freeze(JSON.parse(`{"colors":{"activityBar.activeBorder":"#f9826c","activityBar.background":"#24292e","activityBar.border":"#1b1f23","activityBar.foreground":"#e1e4e8","activityBar.inactiveForeground":"#6a737d","activityBarBadge.background":"#0366d6","activityBarBadge.foreground":"#fff","badge.background":"#044289","badge.foreground":"#c8e1ff","breadcrumb.activeSelectionForeground":"#d1d5da","breadcrumb.focusForeground":"#e1e4e8","breadcrumb.foreground":"#959da5","breadcrumbPicker.background":"#2b3036","button.background":"#176f2c","button.foreground":"#dcffe4","button.hoverBackground":"#22863a","button.secondaryBackground":"#444d56","button.secondaryForeground":"#fff","button.secondaryHoverBackground":"#586069","checkbox.background":"#444d56","checkbox.border":"#1b1f23","debugToolBar.background":"#2b3036","descriptionForeground":"#959da5","diffEditor.insertedTextBackground":"#28a74530","diffEditor.removedTextBackground":"#d73a4930","dropdown.background":"#2f363d","dropdown.border":"#1b1f23","dropdown.foreground":"#e1e4e8","dropdown.listBackground":"#24292e","editor.background":"#24292e","editor.findMatchBackground":"#ffd33d44","editor.findMatchHighlightBackground":"#ffd33d22","editor.focusedStackFrameHighlightBackground":"#2b6a3033","editor.foldBackground":"#58606915","editor.foreground":"#e1e4e8","editor.inactiveSelectionBackground":"#3392FF22","editor.lineHighlightBackground":"#2b3036","editor.linkedEditingBackground":"#3392FF22","editor.selectionBackground":"#3392FF44","editor.selectionHighlightBackground":"#17E5E633","editor.selectionHighlightBorder":"#17E5E600","editor.stackFrameHighlightBackground":"#C6902625","editor.wordHighlightBackground":"#17E5E600","editor.wordHighlightBorder":"#17E5E699","editor.wordHighlightStrongBackground":"#17E5E600","editor.wordHighlightStrongBorder":"#17E5E666","editorBracketHighlight.foreground1":"#79b8ff","editorBracketHighlight.foreground2":"#ffab70","editorBracketHighlight.foreground3":"#b392f0","editorBracketHighlight.foreground4":"#79b8ff","editorBracketHighlight.foreground5":"#ffab70","editorBracketHighlight.foreground6":"#b392f0","editorBracketMatch.background":"#17E5E650","editorBracketMatch.border":"#17E5E600","editorCursor.foreground":"#c8e1ff","editorError.foreground":"#f97583","editorGroup.border":"#1b1f23","editorGroupHeader.tabsBackground":"#1f2428","editorGroupHeader.tabsBorder":"#1b1f23","editorGutter.addedBackground":"#28a745","editorGutter.deletedBackground":"#ea4a5a","editorGutter.modifiedBackground":"#2188ff","editorIndentGuide.activeBackground":"#444d56","editorIndentGuide.background":"#2f363d","editorLineNumber.activeForeground":"#e1e4e8","editorLineNumber.foreground":"#444d56","editorOverviewRuler.border":"#1b1f23","editorWarning.foreground":"#ffea7f","editorWhitespace.foreground":"#444d56","editorWidget.background":"#1f2428","errorForeground":"#f97583","focusBorder":"#005cc5","foreground":"#d1d5da","gitDecoration.addedResourceForeground":"#34d058","gitDecoration.conflictingResourceForeground":"#ffab70","gitDecoration.deletedResourceForeground":"#ea4a5a","gitDecoration.ignoredResourceForeground":"#6a737d","gitDecoration.modifiedResourceForeground":"#79b8ff","gitDecoration.submoduleResourceForeground":"#6a737d","gitDecoration.untrackedResourceForeground":"#34d058","input.background":"#2f363d","input.border":"#1b1f23","input.foreground":"#e1e4e8","input.placeholderForeground":"#959da5","list.activeSelectionBackground":"#39414a","list.activeSelectionForeground":"#e1e4e8","list.focusBackground":"#044289","list.hoverBackground":"#282e34","list.hoverForeground":"#e1e4e8","list.inactiveFocusBackground":"#1d2d3e","list.inactiveSelectionBackground":"#282e34","list.inactiveSelectionForeground":"#e1e4e8","notificationCenterHeader.background":"#24292e","notificationCenterHeader.foreground":"#959da5","notifications.background":"#2f363d","notifications.border":"#1b1f23","notifications.foreground":"#e1e4e8","notificationsErrorIcon.foreground":"#ea4a5a","notificationsInfoIcon.foreground":"#79b8ff","notificationsWarningIcon.foreground":"#ffab70","panel.background":"#1f2428","panel.border":"#1b1f23","panelInput.border":"#2f363d","panelTitle.activeBorder":"#f9826c","panelTitle.activeForeground":"#e1e4e8","panelTitle.inactiveForeground":"#959da5","peekViewEditor.background":"#1f242888","peekViewEditor.matchHighlightBackground":"#ffd33d33","peekViewResult.background":"#1f2428","peekViewResult.matchHighlightBackground":"#ffd33d33","pickerGroup.border":"#444d56","pickerGroup.foreground":"#e1e4e8","progressBar.background":"#0366d6","quickInput.background":"#24292e","quickInput.foreground":"#e1e4e8","scrollbar.shadow":"#0008","scrollbarSlider.activeBackground":"#6a737d88","scrollbarSlider.background":"#6a737d33","scrollbarSlider.hoverBackground":"#6a737d44","settings.headerForeground":"#e1e4e8","settings.modifiedItemIndicator":"#0366d6","sideBar.background":"#1f2428","sideBar.border":"#1b1f23","sideBar.foreground":"#d1d5da","sideBarSectionHeader.background":
Line truncated
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
var e=Object.freeze(JSON.parse(`{"colors":{"activityBar.activeBorder":"#f9826c","activityBar.background":"#fff","activityBar.border":"#e1e4e8","activityBar.foreground":"#2f363d","activityBar.inactiveForeground":"#959da5","activityBarBadge.background":"#2188ff","activityBarBadge.foreground":"#fff","badge.background":"#dbedff","badge.foreground":"#005cc5","breadcrumb.activeSelectionForeground":"#586069","breadcrumb.focusForeground":"#2f363d","breadcrumb.foreground":"#6a737d","breadcrumbPicker.background":"#fafbfc","button.background":"#159739","button.foreground":"#fff","button.hoverBackground":"#138934","button.secondaryBackground":"#e1e4e8","button.secondaryForeground":"#1b1f23","button.secondaryHoverBackground":"#d1d5da","checkbox.background":"#fafbfc","checkbox.border":"#d1d5da","debugToolBar.background":"#fff","descriptionForeground":"#6a737d","diffEditor.insertedTextBackground":"#34d05822","diffEditor.removedTextBackground":"#d73a4922","dropdown.background":"#fafbfc","dropdown.border":"#e1e4e8","dropdown.foreground":"#2f363d","dropdown.listBackground":"#fff","editor.background":"#fff","editor.findMatchBackground":"#ffdf5d","editor.findMatchHighlightBackground":"#ffdf5d66","editor.focusedStackFrameHighlightBackground":"#28a74525","editor.foldBackground":"#d1d5da11","editor.foreground":"#24292e","editor.inactiveSelectionBackground":"#0366d611","editor.lineHighlightBackground":"#f6f8fa","editor.linkedEditingBackground":"#0366d611","editor.selectionBackground":"#0366d625","editor.selectionHighlightBackground":"#34d05840","editor.selectionHighlightBorder":"#34d05800","editor.stackFrameHighlightBackground":"#ffd33d33","editor.wordHighlightBackground":"#34d05800","editor.wordHighlightBorder":"#24943e99","editor.wordHighlightStrongBackground":"#34d05800","editor.wordHighlightStrongBorder":"#24943e50","editorBracketHighlight.foreground1":"#005cc5","editorBracketHighlight.foreground2":"#e36209","editorBracketHighlight.foreground3":"#5a32a3","editorBracketHighlight.foreground4":"#005cc5","editorBracketHighlight.foreground5":"#e36209","editorBracketHighlight.foreground6":"#5a32a3","editorBracketMatch.background":"#34d05840","editorBracketMatch.border":"#34d05800","editorCursor.foreground":"#044289","editorError.foreground":"#cb2431","editorGroup.border":"#e1e4e8","editorGroupHeader.tabsBackground":"#f6f8fa","editorGroupHeader.tabsBorder":"#e1e4e8","editorGutter.addedBackground":"#28a745","editorGutter.deletedBackground":"#d73a49","editorGutter.modifiedBackground":"#2188ff","editorIndentGuide.activeBackground":"#d7dbe0","editorIndentGuide.background":"#eff2f6","editorLineNumber.activeForeground":"#24292e","editorLineNumber.foreground":"#1b1f234d","editorOverviewRuler.border":"#fff","editorWarning.foreground":"#f9c513","editorWhitespace.foreground":"#d1d5da","editorWidget.background":"#f6f8fa","errorForeground":"#cb2431","focusBorder":"#2188ff","foreground":"#444d56","gitDecoration.addedResourceForeground":"#28a745","gitDecoration.conflictingResourceForeground":"#e36209","gitDecoration.deletedResourceForeground":"#d73a49","gitDecoration.ignoredResourceForeground":"#959da5","gitDecoration.modifiedResourceForeground":"#005cc5","gitDecoration.submoduleResourceForeground":"#959da5","gitDecoration.untrackedResourceForeground":"#28a745","input.background":"#fafbfc","input.border":"#e1e4e8","input.foreground":"#2f363d","input.placeholderForeground":"#959da5","list.activeSelectionBackground":"#e2e5e9","list.activeSelectionForeground":"#2f363d","list.focusBackground":"#cce5ff","list.hoverBackground":"#ebf0f4","list.hoverForeground":"#2f363d","list.inactiveFocusBackground":"#dbedff","list.inactiveSelectionBackground":"#e8eaed","list.inactiveSelectionForeground":"#2f363d","notificationCenterHeader.background":"#e1e4e8","notificationCenterHeader.foreground":"#6a737d","notifications.background":"#fafbfc","notifications.border":"#e1e4e8","notifications.foreground":"#2f363d","notificationsErrorIcon.foreground":"#d73a49","notificationsInfoIcon.foreground":"#005cc5","notificationsWarningIcon.foreground":"#e36209","panel.background":"#f6f8fa","panel.border":"#e1e4e8","panelInput.border":"#e1e4e8","panelTitle.activeBorder":"#f9826c","panelTitle.activeForeground":"#2f363d","panelTitle.inactiveForeground":"#6a737d","pickerGroup.border":"#e1e4e8","pickerGroup.foreground":"#2f363d","progressBar.background":"#2188ff","quickInput.background":"#fafbfc","quickInput.foreground":"#2f363d","scrollbar.shadow":"#6a737d33","scrollbarSlider.activeBackground":"#959da588","scrollbarSlider.background":"#959da533","scrollbarSlider.hoverBackground":"#959da544","settings.headerForeground":"#2f363d","settings.modifiedItemIndicator":"#2188ff","sideBar.background":"#f6f8fa","sideBar.border":"#e1e4e8","sideBar.foreground":"#586069","sideBarSectionHeader.background":"#f6f8fa","sideBarSectionHeader.border":"#e1e4e8","sideBarSectionHeader.foreground":"#2f363d","sideBarTitle.foreground":"#2f363d","statusBar.background":"#fff","statusBar.border":"#e1e4e8","statusB
Line truncated
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
var e=[Object.freeze(JSON.parse(`{"displayName":"Go","name":"go","patterns":[{"include":"#statements"}],"repository":{"after_control_variables":{"captures":{"1":{"patterns":[{"include":"#type-declarations-without-brackets"},{"match":"\\\\[","name":"punctuation.definition.begin.bracket.square.go"},{"match":"]","name":"punctuation.definition.end.bracket.square.go"},{"match":"\\\\w+","name":"variable.other.go"}]}},"match":"(?<=\\\\brange\\\\b|;|\\\\bif\\\\b|\\\\bfor\\\\b|[<>]|<=|>=|==|!=|\\\\w[-%*+/]|\\\\w[-%*+/]=|\\\\|\\\\||&&)\\\\s*((?![]\\\\[]+)[-\\\\]!%*+./:<=>\\\\[_[:alnum:]]+)\\\\s*(?=\\\\{)"},"brackets":{"patterns":[{"begin":"\\\\{","beginCaptures":{"0":{"name":"punctuation.definition.begin.bracket.curly.go"}},"end":"}","endCaptures":{"0":{"name":"punctuation.definition.end.bracket.curly.go"}},"patterns":[{"include":"$self"}]},{"begin":"\\\\(","beginCaptures":{"0":{"name":"punctuation.definition.begin.bracket.round.go"}},"end":"\\\\)","endCaptures":{"0":{"name":"punctuation.definition.end.bracket.round.go"}},"patterns":[{"include":"$self"}]},{"begin":"\\\\[","beginCaptures":{"0":{"name":"punctuation.definition.begin.bracket.square.go"}},"end":"]","endCaptures":{"0":{"name":"punctuation.definition.end.bracket.square.go"}},"patterns":[{"include":"$self"}]}]},"built_in_functions":{"patterns":[{"match":"\\\\b(append|cap|close|complex|copy|delete|imag|len|panic|print|println|real|recover|min|max|clear)\\\\b(?=\\\\()","name":"entity.name.function.support.builtin.go"},{"begin":"\\\\b(new)\\\\b(\\\\()","beginCaptures":{"1":{"name":"entity.name.function.support.builtin.go"},"2":{"name":"punctuation.definition.begin.bracket.round.go"}},"end":"\\\\)","endCaptures":{"0":{"name":"punctuation.definition.end.bracket.round.go"}},"patterns":[{"include":"#functions"},{"include":"#struct_variables_types"},{"include":"#support_functions"},{"include":"#type-declarations"},{"include":"#generic_types"},{"match":"\\\\w+","name":"entity.name.type.go"},{"include":"$self"}]},{"begin":"\\\\b(make)\\\\b(\\\\()((?:(?:[]*\\\\[]+{0,1}(?:<-\\\\s*)?\\\\bchan\\\\b(?:\\\\s*<-)?\\\\s*)+(?:\\\\([^)]+\\\\))?)?[]*\\\\[]+{0,1}(?:(?!\\\\bmap\\\\b)[.\\\\w]+)?(\\\\[(?:\\\\S+(?:,\\\\s*\\\\S+)*)?])?,?)?","beginCaptures":{"1":{"name":"entity.name.function.support.builtin.go"},"2":{"name":"punctuation.definition.begin.bracket.round.go"},"3":{"patterns":[{"include":"#type-declarations-without-brackets"},{"include":"#parameter-variable-types"},{"match":"\\\\w+","name":"entity.name.type.go"}]}},"end":"\\\\)","endCaptures":{"0":{"name":"punctuation.definition.end.bracket.round.go"}},"patterns":[{"include":"$self"}]}]},"comments":{"patterns":[{"begin":"(/\\\\*)","beginCaptures":{"1":{"name":"punctuation.definition.comment.go"}},"end":"(\\\\*/)","endCaptures":{"1":{"name":"punctuation.definition.comment.go"}},"name":"comment.block.go"},{"begin":"(//)","beginCaptures":{"1":{"name":"punctuation.definition.comment.go"}},"end":"\\\\n|$","name":"comment.line.double-slash.go"}]},"const_assignment":{"patterns":[{"captures":{"1":{"patterns":[{"include":"#delimiters"},{"match":"\\\\w+","name":"variable.other.constant.go"}]},"2":{"patterns":[{"include":"#type-declarations-without-brackets"},{"include":"#generic_types"},{"match":"\\\\(","name":"punctuation.definition.begin.bracket.round.go"},{"match":"\\\\)","name":"punctuation.definition.end.bracket.round.go"},{"match":"\\\\[","name":"punctuation.definition.begin.bracket.square.go"},{"match":"]","name":"punctuation.definition.end.bracket.square.go"},{"match":"\\\\w+","name":"entity.name.type.go"}]}},"match":"(?<=\\\\bconst\\\\b)\\\\s*\\\\b([.\\\\w]+(?:,\\\\s*[.\\\\w]+)*)\\\\s*((?:(?:[]*\\\\[]+{0,1}(?:<-\\\\s*)?\\\\bchan\\\\b(?:\\\\s*<-)?\\\\s*)+(?:\\\\([^)]+\\\\))?)?(?![]*\\\\[]+{0,1}\\\\b(?:struct|func|map)\\\\b)(?:[]*.\\\\[\\\\w]+(?:,\\\\s*[]*.\\\\[\\\\w]+)*)?\\\\s*=?)?"},{"begin":"(?<=\\\\bconst\\\\b)\\\\s*(\\\\()","beginCaptures":{"1":{"name":"punctuation.definition.begin.bracket.round.go"}},"end":"\\\\)","endCaptures":{"0":{"name":"punctuation.definition.end.bracket.round.go"}},"patterns":[{"captures":{"1":{"patterns":[{"include":"#delimiters"},{"match":"\\\\w+","name":"variable.other.constant.go"}]},"2":{"patterns":[{"include":"#type-declarations-without-brackets"},{"include":"#generic_types"},{"match":"\\\\(","name":"punctuation.definition.begin.bracket.round.go"},{"match":"\\\\)","name":"punctuation.definition.end.bracket.round.go"},{"match":"\\\\[","name":"punctuation.definition.begin.bracket.square.go"},{"match":"]","name":"punctuation.definition.end.bracket.square.go"},{"match":"\\\\w+","name":"entity.name.type.go"}]}},"match":"^\\\\s*\\\\b([.\\\\w]+(?:,\\\\s*[.\\\\w]+)*)\\\\s*((?:(?:[]*\\\\[]+{0,1}(?:<-\\\\s*)?\\\\bchan\\\\b(?:\\\\s*<-)?\\\\s*)+(?:\\\\([^)]+\\\\))?)?(?![]*\\\\[]+{0,1}\\\\b(?:struct|func|map)\\\\b)(?:[]*.\\\\[\\\\w]+(?:,\\\\s*[]*.\\\\[\\\\w]+)*)?\\\\s*=?)?"},{"include":"$self"}]}]},"delimiters":{"patterns":[{"match":",","name":"punctuation.other.comma.go"},{"match":"\\\\.(?!\\\\.\\\\.)",
Line truncated
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import{t as e}from"./css.js";import{t}from"./javascript.js";var n=Object.freeze(JSON.parse(`{"displayName":"HTML","injections":{"R:text.html - (comment.block, text.html meta.embedded, meta.tag.*.*.html, meta.tag.*.*.*.html, meta.tag.*.*.*.*.html)":{"patterns":[{"match":"<","name":"invalid.illegal.bad-angle-bracket.html"}]}},"name":"html","patterns":[{"include":"#xml-processing"},{"include":"#comment"},{"include":"#doctype"},{"include":"#cdata"},{"include":"#tags-valid"},{"include":"#tags-invalid"},{"include":"#entities"}],"repository":{"attribute":{"patterns":[{"begin":"(s(hape|cope|t(ep|art)|ize(s)?|p(ellcheck|an)|elected|lot|andbox|rc(set|doc|lang)?)|h(ttp-equiv|i(dden|gh)|e(ight|aders)|ref(lang)?)|n(o(nce|validate|module)|ame)|c(h(ecked|arset)|ite|o(nt(ent(editable)?|rols)|ords|l(s(pan)?|or))|lass|rossorigin)|t(ype(mustmatch)?|itle|a(rget|bindex)|ranslate)|i(s(map)?|n(tegrity|putmode)|tem(scope|type|id|prop|ref)|d)|op(timum|en)|d(i(sabled|r(name)?)|ownload|e(coding|f(er|ault))|at(etime|a)|raggable)|usemap|p(ing|oster|la(ysinline|ceholder)|attern|reload)|enctype|value|kind|for(m(novalidate|target|enctype|action|method)?)?|w(idth|rap)|l(ist|o(op|w)|a(ng|bel))|a(s(ync)?|c(ce(sskey|pt(-charset)?)|tion)|uto(c(omplete|apitalize)|play|focus)|l(t|low(usermedia|paymentrequest|fullscreen))|bbr)|r(ows(pan)?|e(versed|quired|ferrerpolicy|l|adonly))|m(in(length)?|u(ted|ltiple)|e(thod|dia)|a(nifest|x(length)?)))(?![-:\\\\w])","beginCaptures":{"0":{"name":"entity.other.attribute-name.html"}},"end":"(?=\\\\s*+[^=\\\\s])","name":"meta.attribute.$1.html","patterns":[{"include":"#attribute-interior"}]},{"begin":"style(?![-:\\\\w])","beginCaptures":{"0":{"name":"entity.other.attribute-name.html"}},"end":"(?=\\\\s*+[^=\\\\s])","name":"meta.attribute.style.html","patterns":[{"begin":"=","beginCaptures":{"0":{"name":"punctuation.separator.key-value.html"}},"end":"(?<=[^=\\\\s])(?!\\\\s*=)|(?=/?>)","patterns":[{"begin":"(?=[^/<=>\`\\\\s]|/(?!>))","end":"(?!\\\\G)","name":"meta.embedded.line.css","patterns":[{"captures":{"0":{"name":"source.css"}},"match":"([^\\"'/<=>\`\\\\s]|/(?!>))+","name":"string.unquoted.html"},{"begin":"\\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.html"}},"contentName":"source.css","end":"(\\")","endCaptures":{"0":{"name":"punctuation.definition.string.end.html"},"1":{"name":"source.css"}},"name":"string.quoted.double.html","patterns":[{"include":"#entities"}]},{"begin":"'","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.html"}},"contentName":"source.css","end":"(')","endCaptures":{"0":{"name":"punctuation.definition.string.end.html"},"1":{"name":"source.css"}},"name":"string.quoted.single.html","patterns":[{"include":"#entities"}]}]},{"match":"=","name":"invalid.illegal.unexpected-equals-sign.html"}]}]},{"begin":"on(s(croll|t(orage|alled)|u(spend|bmit)|e(curitypolicyviolation|ek(ing|ed)|lect))|hashchange|c(hange|o(ntextmenu|py)|u(t|echange)|l(ick|ose)|an(cel|play(through)?))|t(imeupdate|oggle)|in(put|valid)|o((?:n|ff)line)|d(urationchange|r(op|ag(start|over|e(n(ter|d)|xit)|leave)?)|blclick)|un(handledrejection|load)|p(opstate|lay(ing)?|a(ste|use|ge(show|hide))|rogress)|e(nded|rror|mptied)|volumechange|key(down|up|press)|focus|w(heel|aiting)|l(oad(start|e(nd|d((?:|meta)data)))?|anguagechange)|a(uxclick|fterprint|bort)|r(e(s(ize|et)|jectionhandled)|atechange)|m(ouse(o(ut|ver)|down|up|enter|leave|move)|essage(error)?)|b(efore(unload|print)|lur))(?![-:\\\\w])","beginCaptures":{"0":{"name":"entity.other.attribute-name.html"}},"end":"(?=\\\\s*+[^=\\\\s])","name":"meta.attribute.event-handler.$1.html","patterns":[{"begin":"=","beginCaptures":{"0":{"name":"punctuation.separator.key-value.html"}},"end":"(?<=[^=\\\\s])(?!\\\\s*=)|(?=/?>)","patterns":[{"begin":"(?=[^/<=>\`\\\\s]|/(?!>))","end":"(?!\\\\G)","name":"meta.embedded.line.js","patterns":[{"captures":{"0":{"name":"source.js"},"1":{"patterns":[{"include":"source.js"}]}},"match":"(([^\\"'/<=>\`\\\\s]|/(?!>))+)","name":"string.unquoted.html"},{"begin":"\\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.html"}},"contentName":"source.js","end":"(\\")","endCaptures":{"0":{"name":"punctuation.definition.string.end.html"},"1":{"name":"source.js"}},"name":"string.quoted.double.html","patterns":[{"captures":{"0":{"patterns":[{"include":"source.js"}]}},"match":"([^\\\\n\\"/]|/(?![*/]))+"},{"begin":"//","beginCaptures":{"0":{"name":"punctuation.definition.comment.js"}},"end":"(?=\\")|\\\\n","name":"comment.line.double-slash.js"},{"begin":"/\\\\*","beginCaptures":{"0":{"name":"punctuation.definition.comment.begin.js"}},"end":"(?=\\")|\\\\*/","endCaptures":{"0":{"name":"punctuation.definition.comment.end.js"}},"name":"comment.block.js"}]},{"begin":"'","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.html"}},"contentName":"source.js","end":"(')","endCaptures":{"0":{"name":"punctuation.definition.string.end.html"},"1":{"name":"source.js"}},"name":"string.quoted.single.html","patterns":[{"captu
Line truncated
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loaded 100 of 184 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user