From f0f7823ae88fd6d3984e21288c267a6026d77e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 03:40:39 +0200 Subject: [PATCH 01/19] chore: automated release pipeline + changeset tooling - Add .github/workflows/release.yml (changesets/action two-state flow) - Update ci.yml: frozen-lockfile, pnpm cache, changeset-check job on PRs - Add .changeset/config.json + README with full process doc - Expand scripts/publish-packages.sh to all 50+ packages in dep order - Fix dead code in corpus/synthesize.ts (trim + startsWith bug) Co-Authored-By: Claude Sonnet 4.6 --- .changeset/README.md | 76 ++++++++++++++++++ .changeset/config.json | 13 +++ .changeset/copper-owls-fix.md | 5 ++ .github/workflows/ci.yml | 53 ++++++++++-- .github/workflows/release.yml | 67 ++++++++++++++++ packages/corpus/src/distill/synthesize.ts | 3 +- scripts/publish-packages.sh | 86 ++++++++++++++++---- scripts/release.sh | 98 +++++++++++++++++++++++ 8 files changed, 377 insertions(+), 24 deletions(-) create mode 100644 .changeset/README.md create mode 100644 .changeset/config.json create mode 100644 .changeset/copper-owls-fix.md create mode 100644 .github/workflows/release.yml create mode 100755 scripts/release.sh diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 0000000000..ddb202e418 --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,76 @@ +# Release process + +## How releases work + +This repo uses [Changesets](https://github.com/changesets/changesets) for +automated versioning and npm publishing. + +### Automated flow (CI) + +1. **Feature branch** — develop and test your changes. +2. **Add a changeset** before opening a PR: + ```bash + pnpm changeset + # pick affected packages, bump type (patch/minor/major), write a description + ``` + This creates a `.changeset/.md` file. Commit it with your code. +3. **Open a PR** — CI validates the changeset is present. +4. **Merge to `main`** — `release.yml` runs and does one of two things: + - **Pending changesets exist** → opens/updates a "Version Packages" PR that + bumps all affected package versions and updates CHANGELOGs. + - **No pending changesets** (i.e. the "Version Packages" PR was just merged) + → publishes every changed package to npm and creates GitHub releases. + +### Manual publish (emergency / first publish of a new package) + +```bash +# Dry-run first +scripts/publish-packages.sh --dry-run + +# Publish with NPM_TOKEN in env +NPM_TOKEN= scripts/publish-packages.sh + +# Or let it prompt for TOTP +scripts/publish-packages.sh +``` + +## Secrets required + +| Secret | Where | Notes | +|---|---|---| +| `NPM_TOKEN` | GitHub repo → Settings → Secrets | Granular access token for the `@agentproto` npm org. See note below on auth options. | +| `GITHUB_TOKEN` | Automatic | Provided by GitHub Actions; needs `contents: write` + `pull-requests: write` (set in `release.yml`). | + +### NPM auth options (pick one) + +**A. OIDC Trusted Publishing** — zero secrets, best security. Requires `id-token: write` permission in +`release.yml` and manually configuring a "Trusted Publisher" on npm.com for each published package +(Package settings → Access → Trusted Publishers → add the GitHub repo + workflow name). Not practical +with 50+ packages unless you script the npm API. + +**B. Granular access token with "Bypass 2FA"** — what `release.yml` uses by default. "Bypass 2FA" is +npm's official CI publishing feature (not a security bypass): it lets a token perform write operations +without an OTP code, which is required for any unattended publish job. Create the token at +[npmjs.com/settings/agentiknet/tokens](https://www.npmjs.com/settings/agentiknet/tokens): choose +"Granular Access Token" → select the `@agentproto` packages → check "Bypass 2FA" → expiry ≤ 1 year. + +If you later move to OIDC, remove `NODE_AUTH_TOKEN` from `release.yml` and add +`id-token: write` to the `permissions` block — provenance attestation is automatic. + +## Bump type guide + +| Bump | When | +|---|---| +| `patch` | Bug fix, docs, internal refactor — no API change. | +| `minor` | New export, new field, new optional method — backward-compatible. | +| `major` | Breaking change: removed export, changed signature, renamed type. | + +During `0.x.y-alpha` pre-release, `minor` is appropriate for most new features. + +## Adding a new package + +1. Create the package under `packages//` with standard `package.json` + `tsup.config.ts`. +2. Add it to the PACKAGES list in `scripts/publish-packages.sh` at the right dependency layer. +3. First publish is manual (`scripts/publish-packages.sh`) — changesets doesn't publish packages + that have never been on npm before. +4. Subsequent releases are fully automated via the changeset flow above. diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000000..a2a039c7f5 --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@3.1.4/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "public", + "baseBranch": "main", + "updateInternalDependencies": "patch", + "ignore": [ + "@agentproto/tooling" + ] +} diff --git a/.changeset/copper-owls-fix.md b/.changeset/copper-owls-fix.md new file mode 100644 index 0000000000..adbafff029 --- /dev/null +++ b/.changeset/copper-owls-fix.md @@ -0,0 +1,5 @@ +--- +"@agentproto/corpus": patch +--- + +Fix dead code in synthesize.ts — `body.trim()` made `startsWith("\n")` unreachable; always prepend newline for gray-matter frontmatter separator. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa9e6dfc6d..6541719112 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,23 +17,23 @@ jobs: build-and-test: name: Build + test runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 15 steps: - name: Checkout uses: actions/checkout@v4 - name: Setup pnpm uses: pnpm/action-setup@v4 - with: - version: 10.4.1 + # version read from packageManager field in package.json - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 22 + cache: pnpm - name: Install dependencies - run: pnpm install --no-frozen-lockfile + run: pnpm install --frozen-lockfile # Build first — `tsc --noEmit` resolves workspace package imports # through their published `.d.ts` files in `dist/`, which only @@ -41,10 +41,49 @@ jobs: # produced "Cannot find module '@agentproto/'" cascades on # every commit since the multi-package extraction. - name: Build all packages - run: pnpm -r --filter "./packages/**" --filter "./adapters/**" build + run: pnpm build - name: Type-check all packages - run: pnpm -r --filter "./packages/**" --filter "./adapters/**" check-types + run: pnpm check-types - name: Run tests - run: pnpm -r --filter "./packages/**" --filter "./adapters/**" test + run: pnpm test + + # On PRs: verify a changeset was added (or the author opted out with + # the "skip changeset" label). This prevents "Version Packages" PRs + # from accidentally shipping without changelog entries. + changeset-check: + name: Changeset present? + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Check for changeset + # Passes when the PR already has a .changeset/*.md file, or when + # the PR title starts with "chore(release):" (the "Version Packages" + # PR opened by changesets/action itself). + run: | + TITLE="${{ github.event.pull_request.title }}" + if [[ "$TITLE" == chore\(release\):* ]]; then + echo "Version Packages PR — no changeset required." + exit 0 + fi + pnpm changeset status --since=origin/main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..57c42ffd16 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,67 @@ +name: Release + +on: + push: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false # never cancel a release in progress + +permissions: + contents: write # create tags + GitHub releases + pull-requests: write # open "Version Packages" PR + +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true' + +jobs: + release: + name: Version or publish + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - name: Checkout (full history for changesets) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + # version read from packageManager field in package.json + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + registry-url: 'https://registry.npmjs.org' + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build all packages + run: pnpm build + + # changesets/action does one of two things depending on state: + # + # A) Pending changesets exist → opens (or updates) a "Version Packages" + # PR that bumps versions + regenerates CHANGELOGs. + # + # B) No pending changesets (i.e. the "Version Packages" PR was just + # merged) → publishes every package whose version isn't yet on npm + # and creates a GitHub release per package. + - name: Version or publish + uses: changesets/action@v1 + with: + version: pnpm changeset version + publish: pnpm release:ci + commit: "chore(release): version packages" + title: "chore(release): version packages" + createGithubReleases: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # NPM_TOKEN must be a granular access token with "Bypass 2FA" + # scoped to the @agentproto org. Set it in the repo's Secrets. + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_CONFIG_PROVENANCE: 'true' diff --git a/packages/corpus/src/distill/synthesize.ts b/packages/corpus/src/distill/synthesize.ts index b12d460249..44837b51d4 100644 --- a/packages/corpus/src/distill/synthesize.ts +++ b/packages/corpus/src/distill/synthesize.ts @@ -287,7 +287,8 @@ function serializeSynthesis( }, } const trimmed = body.trim() - return matter.stringify(trimmed.startsWith("\n") ? trimmed : "\n" + trimmed, fm) + // gray-matter needs a leading newline to separate frontmatter from body + return matter.stringify("\n" + trimmed, fm) } /** Build the synthesis prompt — the model-agnostic core (mirrors buildDistillPrompt). */ diff --git a/scripts/publish-packages.sh b/scripts/publish-packages.sh index 079cbefec1..268b8e974b 100755 --- a/scripts/publish-packages.sh +++ b/scripts/publish-packages.sh @@ -57,34 +57,88 @@ if [ -z "${NPM_TOKEN:-}" ]; then done fi -# Packages to publish, in dependency order. The cli's workspace:* deps -# (define-doctype, acp, driver-agent-cli, runtime-profile-standard) are -# resolved to exact versions at pack time, so each must already be on -# the registry before the cli packs — hence they publish first. +# Packages to publish, in dependency order. +# +# NOTE: In CI the release is driven by `changesets/action` (see +# .github/workflows/release.yml), which calls `pnpm release` = `pnpm build && +# changeset publish`. This script is kept for manual one-shot publishes and +# for publishing packages changesets doesn't track (e.g. freshly added ones +# before their first changeset). +# +# Order: leaves first so workspace:* deps are already on the registry when +# packages that depend on them pack. The idempotency guard in publish_one +# skips any version already published, so re-runs and shared deps are safe. PACKAGES=( + # ── Layer 0: primitives (no @agentproto/* deps) ────────────────────────── "@agentproto/define-doctype|define-doctype" + "@agentproto/tool|tool" + "@agentproto/ref|ref" + "@agentproto/identity|identity" + "@agentproto/io|io" + + # ── Layer 1: ACP + auth ─────────────────────────────────────────────────── "@agentproto/acp|acp" - "@agentproto/driver-agent-cli|driver-agent-cli" - "@agentproto/runtime-profile-standard|runtime-profile-standard" - "@agentproto/cli|cli" - "@agentproto/plugin-local-browser|plugin-local-browser" + "@agentproto/auth|auth" + "@agentproto/secrets|secrets" - # corpus-cli dependency closure (the AIP-10 `corpus` binary). define-doctype - # is shared with the cli closure above and publishes there first. Order - # within this block is dep-first; the idempotency guard in publish_one skips - # any version already on the registry, so the shared deps and re-runs are safe. - "@agentproto/cli-exec|cli-exec" - "@agentproto/collection|collection" + # ── Layer 2: agent CLI driver + wallet ──────────────────────────────────── + "@agentproto/driver-agent-cli|driver/agent-cli" + "@agentproto/wallet|wallet" + + # ── Layer 3: core primitives ────────────────────────────────────────────── + "@agentproto/runtime-profile-standard|runtime-profile-standard" + "@agentproto/manifest|manifest" + "@agentproto/registry|registry" + "@agentproto/policy|policy" + "@agentproto/skill|skill" + "@agentproto/role|role" + "@agentproto/role-catalog|role-catalog" + "@agentproto/lifecycle|lifecycle" + "@agentproto/sandbox|sandbox" + "@agentproto/storage|storage" + + # ── Layer 4: knowledge + operator ──────────────────────────────────────── "@agentproto/knowledge|knowledge" "@agentproto/operator|operator" "@agentproto/playbook|playbook" - "@agentproto/registry|registry" - "@agentproto/manifest|manifest" + "@agentproto/collection|collection" "@agentproto/routine|routine" "@agentproto/workflow|workflow" + "@agentproto/workflow-loader|workflow-loader" + "@agentproto/workflow-runtime|workflow-runtime" + + # ── Layer 5: higher-level packages ──────────────────────────────────────── + "@agentproto/action|action" + "@agentproto/agent|agent" + "@agentproto/agent-runtime|agent-runtime" + "@agentproto/assembly|assembly" + "@agentproto/canvakit|canvakit" + "@agentproto/catalog|catalog" + "@agentproto/cli-exec|cli-exec" + "@agentproto/code|code" + "@agentproto/company|company" + "@agentproto/design|design" + "@agentproto/egress|egress" + "@agentproto/extension|extension" + "@agentproto/intent|intent" + "@agentproto/lesson|lesson" + "@agentproto/mastra|mastra" + "@agentproto/mcp-server|mcp-server" + "@agentproto/office|office" + "@agentproto/persona|persona" + "@agentproto/runner|runner" + "@agentproto/runtime|runtime" + "@agentproto/work|work" + "@agentproto/workspace|workspace" + + # ── Layer 6: corpus + CLI (depends on most of the above) ───────────────── "@agentproto/corpus|corpus" "@agentproto/corpus-presets|corpus-presets" "@agentproto/corpus-cli|corpus-cli" + + # ── Layer 7: CLI + plugins (depend on acp + runtime-profile-standard) ───── + "@agentproto/cli|cli" + "@agentproto/plugin-local-browser|plugin-local-browser" ) prompt_otp() { diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000000..d2f0bc42f6 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash +# One-shot release: changeset version → npm publish → tunnel server deploy. +# +# Usage: +# scripts/release.sh # full release (npm + server) +# scripts/release.sh --npm-only # skip server deploy +# scripts/release.sh --server-only # skip npm (just redeploy server) +# scripts/release.sh --dry-run # print what would happen, publish nothing +# scripts/release.sh --env test # deploy tunnel to test instead of prod + +set -euo pipefail +cd "$(dirname "$0")/.." + +REPO_ROOT="$(git -C . rev-parse --show-toplevel)" + +NPM_ONLY=false +SERVER_ONLY=false +DRY_RUN=false +ENV="prod" + +for arg in "$@"; do + case "$arg" in + --npm-only) NPM_ONLY=true ;; + --server-only) SERVER_ONLY=true ;; + --dry-run) DRY_RUN=true ;; + --env=*) ENV="${arg#--env=}" ;; + --env) shift; ENV="$1" ;; + --help|-h) + sed -n '2,10p' "$0" | sed 's|^# \?||' + exit 0 + ;; + esac +done + +confirm() { + local msg="$1" + printf "\n%s [y/N] " "$msg" + read -r reply &1 || true # non-zero when nothing pending — that's fine + + if pnpm changeset status --verbose 2>&1 | grep -q "No changesets found"; then + echo "No pending changesets — skipping version bump." + else + if confirm "Apply changeset version bumps?"; then + $DRY_RUN && echo "(dry-run) skipping: pnpm changeset version" || pnpm changeset version + echo "✓ versions bumped + CHANGELOG.md updated" + else + echo "Skipped version bump." + fi + fi + + # ── 2. npm publish ───────────────────────────────────────────────────────── + echo + echo "━━ npm publish" + if confirm "Publish changed packages to npm?"; then + if $DRY_RUN; then + echo "(dry-run) skipping: pnpm build && changeset publish" + else + pnpm build + pnpm changeset publish --no-git-tag + fi + echo "✓ npm publish done" + else + echo "Skipped npm publish." + fi +fi + +# ── 3. Server deploy ────────────────────────────────────────────────────────── +if ! $NPM_ONLY; then + echo + echo "━━ guilde-tunnel → ${ENV}" + if confirm "Deploy guilde-tunnel to ${ENV}?"; then + if $DRY_RUN; then + echo "(dry-run) skipping: pnpm agentik deploy guilde-tunnel --env ${ENV} -y" + else + (cd "$REPO_ROOT" && pnpm agentik deploy guilde-tunnel --env "$ENV" -y) + fi + echo "✓ server deploy triggered" + else + echo "Skipped server deploy." + fi +fi + +echo +echo "━━━ done ━━━" From e38062b9d788cf525bc600891a975bf28dc40dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 13:48:10 +0200 Subject: [PATCH 02/19] fix(ci): replace changeset status with git diff check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `pnpm changeset status --since=origin/main` exits with code 254 on some CLI versions. Replaced with a plain `git diff --diff-filter=A` check — no pnpm/node install needed, no fragile exit codes. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/ci.yml | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6541719112..88c70b1e16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,28 +62,21 @@ jobs: with: fetch-depth: 0 - - name: Setup pnpm - uses: pnpm/action-setup@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 22 - cache: pnpm - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - name: Check for changeset - # Passes when the PR already has a .changeset/*.md file, or when - # the PR title starts with "chore(release):" (the "Version Packages" - # PR opened by changesets/action itself). + # Uses git directly — avoids fragile `changeset status` exit codes. + # Passes when a .changeset/*.md file (not README) was added in this + # branch, or when the PR title starts with "chore(release):" (the + # "Version Packages" PR opened by changesets/action itself). run: | TITLE="${{ github.event.pull_request.title }}" if [[ "$TITLE" == chore\(release\):* ]]; then echo "Version Packages PR — no changeset required." exit 0 fi - pnpm changeset status --since=origin/main - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ADDED=$(git diff --diff-filter=A --name-only origin/main...HEAD -- '.changeset/*.md' \ + | grep -v '^\.changeset/README\.md$' || true) + if [ -z "$ADDED" ]; then + echo "No changeset found. Run 'pnpm changeset' and commit the .changeset/*.md file." + exit 1 + fi + echo "✓ Changeset present: $ADDED" From 360b349417ea52b81532878ff5941a9c69e54030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 13:50:44 +0200 Subject: [PATCH 03/19] =?UTF-8?q?chore(ci):=20remove=20FORCE=5FJAVASCRIPT?= =?UTF-8?q?=5FACTIONS=5FTO=5FNODE24=20=E2=80=94=20GitHub=20enforces=20it?= =?UTF-8?q?=20automatically?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 3 --- .github/workflows/release.yml | 3 --- 2 files changed, 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88c70b1e16..a5d4732bee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,9 +10,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} -env: - FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true' - jobs: build-and-test: name: Build + test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57c42ffd16..1c73810893 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,9 +12,6 @@ permissions: contents: write # create tags + GitHub releases pull-requests: write # open "Version Packages" PR -env: - FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true' - jobs: release: name: Version or publish From 80d8db2d48a77bed6730243eda8f009e672ac3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 14:13:26 +0200 Subject: [PATCH 04/19] feat(ci): auto-generate changeset via Claude on PRs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - scripts/auto-changeset.mjs — calls claude-haiku-4-5 with the git diff, determines affected packages + bump type, writes .changeset/.md - .github/workflows/auto-changeset.yml — triggers on PR open/sync, skips if changeset already present, commits result back to branch - pnpm changeset:auto — same script usable locally Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/auto-changeset.yml | 67 +++++++++ package.json | 11 +- scripts/auto-changeset.mjs | 197 +++++++++++++++++++++++++++ 3 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/auto-changeset.yml create mode 100644 scripts/auto-changeset.mjs diff --git a/.github/workflows/auto-changeset.yml b/.github/workflows/auto-changeset.yml new file mode 100644 index 0000000000..b5eafde124 --- /dev/null +++ b/.github/workflows/auto-changeset.yml @@ -0,0 +1,67 @@ +name: Auto Changeset + +on: + pull_request: + types: [opened, synchronize] + +# Write access to push the generated changeset back to the branch. +# Only works for PRs from the same repo (not forks) — which is the +# normal case for an internal monorepo. +permissions: + contents: write + +jobs: + auto-changeset: + name: Generate changeset + runs-on: ubuntu-latest + # Skip the "Version Packages" PR that changesets/action opens itself. + if: | + !startsWith(github.event.pull_request.title, 'chore(release):') + + steps: + - name: Checkout branch (with write token) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + # Check out the head of the PR branch so we can push back to it. + ref: ${{ github.head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Check if changeset already exists + id: check + run: | + ADDED=$(git diff --diff-filter=A --name-only origin/main...HEAD -- '.changeset/*.md' \ + | grep -v '^\.changeset/README\.md$' || true) + if [ -n "$ADDED" ]; then + echo "present=true" >> "$GITHUB_OUTPUT" + echo "✓ Changeset already present: $ADDED" + else + echo "present=false" >> "$GITHUB_OUTPUT" + echo "No changeset found — will auto-generate." + fi + + - name: Setup Node.js + if: steps.check.outputs.present == 'false' + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Generate changeset via Claude + if: steps.check.outputs.present == 'false' + run: node scripts/auto-changeset.mjs + env: + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + + - name: Commit generated changeset + if: steps.check.outputs.present == 'false' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + # Stage only new .changeset/*.md files (not README, not existing ones) + git add '.changeset/*.md' + if git diff --cached --quiet; then + echo "Nothing to commit (no packages changed, changeset not needed)." + else + git commit -m "chore: auto-generate changeset [skip ci]" + git push + fi diff --git a/package.json b/package.json index 219dad9e8a..1062fbc335 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,18 @@ "clean": "pnpm -r --filter \"./packages/**\" --filter \"./adapters/**\" clean", "scaffold-aip": "node scripts/scaffold-aip.mjs", "sync-specs": "node scripts/sync-specs.mjs", - "sync-specs:check": "node scripts/sync-specs.mjs --check" + "sync-specs:check": "node scripts/sync-specs.mjs --check", + "changeset": "changeset", + "changeset:auto": "node scripts/auto-changeset.mjs", + "version": "changeset version", + "release": "scripts/release.sh", + "release:ci": "pnpm build && changeset publish", + "release:npm": "scripts/release.sh --npm-only", + "release:server": "scripts/release.sh --server-only", + "release:dry": "scripts/release.sh --dry-run" }, "devDependencies": { + "@changesets/cli": "^2.31.0", "gray-matter": "^4.0.3", "json-schema-to-typescript": "^15.0.4", "json-schema-to-zod": "^2.6.1", diff --git a/scripts/auto-changeset.mjs b/scripts/auto-changeset.mjs new file mode 100644 index 0000000000..27fcdcec05 --- /dev/null +++ b/scripts/auto-changeset.mjs @@ -0,0 +1,197 @@ +#!/usr/bin/env node +/** + * Auto-generate a changeset by asking Claude to analyse the git diff. + * + * Usage: + * node scripts/auto-changeset.mjs # uses ANTHROPIC_API_KEY from env + * ANTHROPIC_API_KEY=sk-... node scripts/auto-changeset.mjs + * + * The script: + * 1. Finds all @agentproto/* packages touched since origin/main + * 2. Sends a truncated diff to Claude (claude-haiku-4-5) for analysis + * 3. Writes .changeset/.md and exits 0 + * + * Exit codes: + * 0 — changeset written (or already exists — nothing to do) + * 1 — error (no API key, Claude call failed, no packages changed, etc.) + */ + +import { execSync } from 'node:child_process' +import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs' +import { resolve } from 'node:path' + +const ROOT = new URL('..', import.meta.url).pathname.replace(/\/$/, '') + +// ── helpers ────────────────────────────────────────────────────────────────── + +function run(cmd) { + return execSync(cmd, { cwd: ROOT, encoding: 'utf8' }).trim() +} + +function randomSlug() { + const words = [ + 'amber', 'azure', 'beige', 'brass', 'cedar', 'coral', 'denim', 'dusty', + 'ember', 'fern', 'flint', 'frost', 'gold', 'hazel', 'ivory', 'jade', + 'khaki', 'lemon', 'lilac', 'linen', 'maple', 'mocha', 'navy', 'ochre', + 'olive', 'pearl', 'pine', 'plum', 'ruby', 'russet', 'sage', 'sand', + 'slate', 'stone', 'teal', 'umber', 'viola', 'wheat', + ] + const nouns = [ + 'ants', 'bears', 'bees', 'birds', 'bison', 'boars', 'bucks', 'cats', + 'crabs', 'crane', 'doves', 'ducks', 'eagle', 'elks', 'finch', 'foxes', + 'frogs', 'geese', 'gnats', 'hawks', 'ibis', 'larks', 'lions', 'lynx', + 'moles', 'moose', 'moths', 'mules', 'owls', 'quail', 'rats', 'ravens', + 'seals', 'slugs', 'snail', 'stoat', 'swans', 'toads', 'trout', 'voles', + 'wasps', 'wolves', 'wrens', 'yaks', 'zebra', + ] + const pick = (arr) => arr[Math.floor(Math.random() * arr.length)] + return `${pick(words)}-${pick(nouns)}-auto` +} + +// ── guard: already exists? ──────────────────────────────────────────────────── + +const csDir = resolve(ROOT, '.changeset') +const existing = readdirSync(csDir) + .filter((f) => f.endsWith('.md') && f !== 'README.md') + .filter((f) => { + // only count files added in this branch (not already on main) + try { + run(`git show origin/main:.changeset/${f}`) + return false // exists on main → not new + } catch { + return true // not on main → added in this branch + } + }) + +if (existing.length > 0) { + console.log(`✓ Changeset already present: ${existing.join(', ')} — nothing to do.`) + process.exit(0) +} + +// ── discover changed packages ───────────────────────────────────────────────── + +const changedFiles = run('git diff --name-only origin/main...HEAD').split('\n').filter(Boolean) + +// Map file paths → package names by reading their package.json +const pkgDirs = [ + ...run('find packages -maxdepth 2 -name "package.json" -not -path "*/node_modules/*"') + .split('\n') + .filter(Boolean), + ...run('find adapters -maxdepth 2 -name "package.json" -not -path "*/node_modules/*"') + .split('\n') + .filter(Boolean), +] + +const pkgMap = new Map() // prefix → package name +for (const pkgJson of pkgDirs) { + try { + const { name, private: priv } = JSON.parse(readFileSync(resolve(ROOT, pkgJson), 'utf8')) + if (name && name.startsWith('@agentproto/') && !priv) { + const prefix = pkgJson.replace('/package.json', '') + '/' + pkgMap.set(prefix, name) + } + } catch {} +} + +const touchedPackages = new Set() +for (const file of changedFiles) { + for (const [prefix, name] of pkgMap) { + if (file.startsWith(prefix)) { + touchedPackages.add(name) + } + } +} + +if (touchedPackages.size === 0) { + console.log('No @agentproto/* packages changed — no changeset needed.') + process.exit(0) +} + +console.log(`Packages changed: ${[...touchedPackages].join(', ')}`) + +// ── build diff for Claude (cap at 12k chars) ───────────────────────────────── + +const rawDiff = run( + 'git diff origin/main...HEAD -- "packages/**" "adapters/**"' +).slice(0, 12_000) + +// ── call Claude ─────────────────────────────────────────────────────────────── + +const apiKey = process.env.ANTHROPIC_API_KEY +if (!apiKey) { + console.error('Error: ANTHROPIC_API_KEY is not set.') + process.exit(1) +} + +const systemPrompt = `You are a release engineer for the @agentproto npm monorepo. +Given a git diff and a list of changed packages, produce a changeset. + +Bump rules: +- patch: bug fix, internal refactor, test, docs, dependency bump, dead code removal +- minor: new exported function/type/class, new optional parameter, new feature (backward-compatible) +- major: removed export, renamed export, changed function signature incompatibly, breaking behavior change + +Reply ONLY with valid JSON — no markdown fences, no explanation: +{ + "packages": [{ "name": "@agentproto/xxx", "bump": "patch|minor|major" }], + "summary": "imperative-mood one-liner (≤ 72 chars)" +} + +The "summary" becomes the CHANGELOG entry. Write it like a git commit subject.` + +const userPrompt = `Changed packages: ${[...touchedPackages].join(', ')} + +Diff (may be truncated): +${rawDiff}` + +console.log('Calling Claude to analyse the diff…') + +const response = await fetch('https://api.anthropic.com/v1/messages', { + method: 'POST', + headers: { + 'x-api-key': apiKey, + 'anthropic-version': '2023-06-01', + 'content-type': 'application/json', + }, + body: JSON.stringify({ + model: 'claude-haiku-4-5-20251001', + max_tokens: 512, + system: systemPrompt, + messages: [{ role: 'user', content: userPrompt }], + }), +}) + +if (!response.ok) { + const body = await response.text() + console.error(`Claude API error ${response.status}: ${body}`) + process.exit(1) +} + +const data = await response.json() +const raw = data.content?.[0]?.text?.trim() ?? '' + +let parsed +try { + parsed = JSON.parse(raw) +} catch { + console.error('Failed to parse Claude response as JSON:', raw) + process.exit(1) +} + +const { packages, summary } = parsed +if (!Array.isArray(packages) || !summary) { + console.error('Unexpected response shape:', parsed) + process.exit(1) +} + +// ── write changeset ─────────────────────────────────────────────────────────── + +const frontmatter = packages.map((p) => `"${p.name}": ${p.bump}`).join('\n') +const slug = randomSlug() +const outPath = resolve(csDir, `${slug}.md`) + +writeFileSync(outPath, `---\n${frontmatter}\n---\n\n${summary}\n`) + +console.log(`✓ Written: .changeset/${slug}.md`) +console.log(` Packages: ${packages.map((p) => `${p.name}@${p.bump}`).join(', ')}`) +console.log(` Summary: ${summary}`) From 3630acaf0af66c1e9e2454e4dfb225186ff918d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 14:15:42 +0200 Subject: [PATCH 05/19] chore: sync pnpm-lock.yaml after adding @changesets/cli --- pnpm-lock.yaml | 864 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 841 insertions(+), 23 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 22df7e85c4..0a2964341f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: devDependencies: + '@changesets/cli': + specifier: ^2.31.0 + version: 2.31.0(@types/node@25.6.2) gray-matter: specifier: ^4.0.3 version: 4.0.3 @@ -137,8 +140,8 @@ importers: specifier: workspace:* version: link:../../packages/tooling '@mastra/core': - specifier: 1.32.1 - version: 1.32.1(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-schema/spec@1.1.0)(openapi-types@12.1.3)(zod@4.4.3))(@types/json-schema@7.0.15)(express@5.2.1)(openapi-types@12.1.3)(zod@4.4.3) + specifier: 1.45.0 + version: 1.45.0(ai@6.0.205(zod@4.4.3))(express@5.2.1)(zod@4.4.3) '@types/node': specifier: ^25.6.2 version: 25.6.2 @@ -550,12 +553,18 @@ importers: '@agentproto/acp': specifier: workspace:* version: link:../acp + '@agentproto/driver': + specifier: workspace:* + version: link:../driver/core '@agentproto/driver-agent-cli': specifier: workspace:* version: link:../driver/agent-cli '@agentproto/runtime-profile-standard': specifier: workspace:* version: link:../runtime-profile-standard + '@clack/prompts': + specifier: ^1.5.0 + version: 1.6.0 '@modelcontextprotocol/sdk': specifier: ^1.29.0 version: 1.29.0(zod@4.4.3) @@ -927,6 +936,9 @@ importers: '@agentproto/define-doctype': specifier: workspace:* version: link:../../define-doctype + '@agentproto/manifest': + specifier: workspace:* + version: link:../../manifest '@agentproto/tool': specifier: workspace:* version: link:../../tool @@ -1348,8 +1360,8 @@ importers: specifier: workspace:* version: link:../tooling '@mastra/core': - specifier: 1.32.1 - version: 1.32.1(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-schema/spec@1.1.0)(openapi-types@12.1.3)(zod@4.4.3))(@types/json-schema@7.0.15)(express@5.2.1)(openapi-types@12.1.3)(zod@4.4.3) + specifier: 1.45.0 + version: 1.45.0(ai@6.0.205(zod@4.4.3))(express@5.2.1)(zod@4.4.3) '@types/node': specifier: ^25.6.2 version: 25.6.2 @@ -1365,6 +1377,9 @@ importers: packages/mcp-server: dependencies: + '@agentproto/agent': + specifier: workspace:* + version: link:../agent '@agentproto/define-doctype': specifier: workspace:* version: link:../define-doctype @@ -1377,6 +1392,9 @@ importers: '@agentproto/manifest': specifier: workspace:* version: link:../manifest + '@agentproto/routine': + specifier: workspace:* + version: link:../routine '@agentproto/tool': specifier: workspace:* version: link:../tool @@ -2137,12 +2155,24 @@ packages: peerDependencies: zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/provider-utils@3.0.25': + resolution: {integrity: sha512-CvsRu+32Y8a167s+lrIBtsybvgTHp8j9y+6BeTvLeoW3Q+okw/b4CnNUFOLIXsRaKHQKAH+IHNJPYWywfpw0LA==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/provider-utils@4.0.23': resolution: {integrity: sha512-z8GlDaCmRSDlqkMF2f4/RFgWxdarvIbyuk+m6WXT1LYgsnGiXRJGTD2Z1+SDl3LqtFuRtGX1aghYvQLoHL/9pg==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/provider-utils@4.0.27': + resolution: {integrity: sha512-ubkAJ+xODouwtmN1tYlvTPphH1hPOBfZaEQe8U7skGvFAnIRs9PPpsq57bC2+Ky/MB4yzhd6YOsxTAx9sGpazw==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/provider-utils@4.0.29': resolution: {integrity: sha512-uhukHaCBvqkwBHkT8C2PrnqKTCoLn3pdHXqtcR9I8ErH+flbzgW4o7VHSNIup9LRu+WBvZIZDQLsx6rwl2tiOA==} engines: {node: '>=18'} @@ -2157,6 +2187,10 @@ packages: resolution: {integrity: sha512-KCUwswvsC5VsW2PWFqF8eJgSCu5Ysj7m1TxiHTVA6g7k360bk0RNQENT8KTMAYEs+8fWPD3Uu4dEmzGHc+jGng==} engines: {node: '>=18'} + '@ai-sdk/provider@2.0.3': + resolution: {integrity: sha512-h88OPkavHTiN9tMn2l5awAznGB0lXzjcLhgR1/rvjB2zlLprsNxbM2tt6OJsHUxduLC3klq0/eqaSf6fX5XVww==} + engines: {node: '>=18'} + '@ai-sdk/provider@3.0.10': resolution: {integrity: sha512-Q3BZ27qfpYqnCYGvE3vt+Qi6LGOF9R5Nmzn+9JoM1lCRsD9mYaIhfJLkSunN48nfGXJ6n+XNV0J/XVpqGQl7Dw==} engines: {node: '>=18'} @@ -2175,6 +2209,73 @@ packages: resolution: {integrity: sha512-60vepv88RwcJtSHrD6MjIL6Ta3SOYbgfnkHb+ppAVK+o9mXprRtulx7VlRl3lN3bbvysAfCS7WMVfhUYemB0IQ==} engines: {node: '>= 16'} + '@babel/runtime@7.29.7': + resolution: {integrity: sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==} + engines: {node: '>=6.9.0'} + + '@changesets/apply-release-plan@7.1.1': + resolution: {integrity: sha512-9qPCm/rLx/xoOFXIHGB229+4GOL76S4MC+7tyOuTsR6+1jYlfFDQORdvwR5hDA6y4FL2BPt3qpbcQIS+dW85LA==} + + '@changesets/assemble-release-plan@6.0.10': + resolution: {integrity: sha512-rSDcqdJ9KbVyjpBIuCidhvZNIiVt1XaIYp73ycVQRIA5n/j6wQaEk0ChRLMUQ1vkxZe51PTQ9OIhbg6HQMW45A==} + + '@changesets/changelog-git@0.2.1': + resolution: {integrity: sha512-x/xEleCFLH28c3bQeQIyeZf8lFXyDFVn1SgcBiR2Tw/r4IAWlk1fzxCEZ6NxQAjF2Nwtczoen3OA2qR+UawQ8Q==} + + '@changesets/cli@2.31.0': + resolution: {integrity: sha512-AhI4enNTgHu2IZr6K4WZyf0EPch4XVMn1yOMFmCD9gsfBGqMYaHXls5HyDv6/CL5axVQABz68eG30eCtbr2wFg==} + hasBin: true + + '@changesets/config@3.1.4': + resolution: {integrity: sha512-pf0bvD/v6WI2cRlZ6hzpjtZdSlXDXMAJ+Iz7xfFzV4ZxJ8OGGAON+1qYc99ZPrijnt4xp3VGG7eNvAOGS24V1Q==} + + '@changesets/errors@0.2.0': + resolution: {integrity: sha512-6BLOQUscTpZeGljvyQXlWOItQyU71kCdGz7Pi8H8zdw6BI0g3m43iL4xKUVPWtG+qrrL9DTjpdn8eYuCQSRpow==} + + '@changesets/get-dependents-graph@2.1.4': + resolution: {integrity: sha512-ZsS00x6WvmHq3sQv8oCMwL0f/z3wbXCVuSVTJwCnnmbC/iBdNJGFx1EcbMG4PC6sXRyH69liM4A2WKXzn/kRPg==} + + '@changesets/get-release-plan@4.0.16': + resolution: {integrity: sha512-2K5Om6CrMPm45rtvckfzWo7e9jOVCKLCnXia5eUPaURH7/LWzri7pK1TycdzAuAtehLkW7VPbWLCSExTHmiI6g==} + + '@changesets/get-version-range-type@0.4.0': + resolution: {integrity: sha512-hwawtob9DryoGTpixy1D3ZXbGgJu1Rhr+ySH2PvTLHvkZuQ7sRT4oQwMh0hbqZH1weAooedEjRsbrWcGLCeyVQ==} + + '@changesets/git@3.0.4': + resolution: {integrity: sha512-BXANzRFkX+XcC1q/d27NKvlJ1yf7PSAgi8JG6dt8EfbHFHi4neau7mufcSca5zRhwOL8j9s6EqsxmT+s+/E6Sw==} + + '@changesets/logger@0.1.1': + resolution: {integrity: sha512-OQtR36ZlnuTxKqoW4Sv6x5YIhOmClRd5pWsjZsddYxpWs517R0HkyiefQPIytCVh4ZcC5x9XaG8KTdd5iRQUfg==} + + '@changesets/parse@0.4.3': + resolution: {integrity: sha512-ZDmNc53+dXdWEv7fqIUSgRQOLYoUom5Z40gmLgmATmYR9NbL6FJJHwakcCpzaeCy+1D0m0n7mT4jj2B/MQPl7A==} + + '@changesets/pre@2.0.2': + resolution: {integrity: sha512-HaL/gEyFVvkf9KFg6484wR9s0qjAXlZ8qWPDkTyKF6+zqjBe/I2mygg3MbpZ++hdi0ToqNUF8cjj7fBy0dg8Ug==} + + '@changesets/read@0.6.7': + resolution: {integrity: sha512-D1G4AUYGrBEk8vj8MGwf75k9GpN6XL3wg8i42P2jZZwFLXnlr2Pn7r9yuQNbaMCarP7ZQWNJbV6XLeysAIMhTA==} + + '@changesets/should-skip-package@0.1.2': + resolution: {integrity: sha512-qAK/WrqWLNCP22UDdBTMPH5f41elVDlsNyat180A33dWxuUDyNpg6fPi/FyTZwRriVjg0L8gnjJn2F9XAoF0qw==} + + '@changesets/types@4.1.0': + resolution: {integrity: sha512-LDQvVDv5Kb50ny2s25Fhm3d9QSZimsoUGBsUioj6MC3qbMUCuC8GPIvk/M6IvXx3lYhAs0lwWUQLb+VIEUCECw==} + + '@changesets/types@6.1.0': + resolution: {integrity: sha512-rKQcJ+o1nKNgeoYRHKOS07tAMNd3YSN0uHaJOZYjBAgxfV7TUE7JE+z4BzZdQwb5hKaYbayKN5KrYV7ODb2rAA==} + + '@changesets/write@0.4.0': + resolution: {integrity: sha512-CdTLvIOPiCNuH71pyDu3rA+Q0n65cmAbXnwWH84rKGiFumFzkmHNT8KHTMEchcxN+Kl8I54xGUhJ7l3E7X396Q==} + + '@clack/core@1.4.2': + resolution: {integrity: sha512-0Ty/1Gfm+Kb07sXcuESjyKfwEhSy4Ns1AgeEisHb/bDY5fWme0tTeTkU14T1Gmcs17YIjB/teiDe4uaCghbYqQ==} + engines: {node: '>= 20.12.0'} + + '@clack/prompts@1.6.0': + resolution: {integrity: sha512-EYlRokl8szrP9Z25qT5aepMdBjzBvHF9ZEhzIiUBc9guz/T31EqRgvD0QSgZcpE93xiwrr+OkB4nz0BZyF6fSA==} + engines: {node: '>= 20.12.0'} + '@esbuild/aix-ppc64@0.27.7': resolution: {integrity: sha512-EKX3Qwmhz1eMdEJokhALr0YiD0lhQNwDqkPYyPhiSwKrh7/4KRjQc04sZ8db+5DVVnZ1LmbNDI1uAMPEUBnQPg==} engines: {node: '>=18'} @@ -2337,6 +2438,15 @@ packages: peerDependencies: hono: ^4 + '@inquirer/external-editor@1.0.3': + resolution: {integrity: sha512-RWbSrDiYmO4LbejWY7ttpxczuwQyZLBUyygsA9Nsv95hpzUWwnNTVQmAq3xuh7vNwCp07UTmE5i11XAEExx4RA==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@isaacs/ttlcache@2.1.4': resolution: {integrity: sha512-7kMz0BJpMvgAMkyglums7B2vtrn5g0a0am77JY0GjkZZNetOBCFn7AG7gKCwT0QPiXyxW7YIQSgtARknUEOcxQ==} engines: {node: '>=12'} @@ -2365,14 +2475,20 @@ packages: resolution: {integrity: sha512-qC72D4+CDdjGqJvkFMMEAtancHUQ7/d/tAiHf64z8MopFDmcrtbcJuerDtFceuAfQJ2pDSfCKCtbqoGBNnwg0w==} engines: {node: '>=8'} + '@manypkg/find-root@1.1.0': + resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} + + '@manypkg/get-packages@1.1.3': + resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==} + '@mastra/core@1.31.0': resolution: {integrity: sha512-HxbtdQo5/MxAjA4ph/ZcRazl1YGljlzWugfz9kpGz+Rdgp8xLN6GWSer2QySwwXbDQZO5iyYr6KzOlbSWho3Sg==} engines: {node: '>=22.13.0'} peerDependencies: zod: ^3.25.0 || ^4.0.0 - '@mastra/core@1.32.1': - resolution: {integrity: sha512-6ynJNZ9GMkLs11c9D4Ui9Z0eOP8GsAqPeMVhlnxExcdTls0ufFQSXFgwzBqtS97fot9IOA/fxDLvvW83fnsP0A==} + '@mastra/core@1.45.0': + resolution: {integrity: sha512-UPpNL+iJVfypfc7IOKL9fhmoKKDe6IA6y+DwZDRSTN+uz/ft194e+TrB4LnBdYtTTeLhDO96mxW2rp9LK0ULhg==} engines: {node: '>=22.13.0'} peerDependencies: zod: ^3.25.0 || ^4.0.0 @@ -2383,6 +2499,12 @@ packages: peerDependencies: zod: ^3.25.0 || ^4.0.0 + '@mastra/schema-compat@1.3.0': + resolution: {integrity: sha512-VAWCXGuWuTqnljkheb3zKUujNK6rdGhFISxdSoSz3/d3HJWZOHY10mUnXw5lg0s73FdFDGg4tehbq28fAZz+lA==} + engines: {node: '>=22.13.0'} + peerDependencies: + zod: ^3.25.0 || ^4.0.0 + '@modelcontextprotocol/sdk@1.29.0': resolution: {integrity: sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==} engines: {node: '>=18'} @@ -2393,10 +2515,28 @@ packages: '@cfworker/json-schema': optional: true + '@nodelib/fs.scandir@2.1.5': + resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} + engines: {node: '>= 8'} + + '@nodelib/fs.stat@2.0.5': + resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} + engines: {node: '>= 8'} + + '@nodelib/fs.walk@1.2.8': + resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} + engines: {node: '>= 8'} + '@opentelemetry/api@1.9.0': resolution: {integrity: sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==} engines: {node: '>=8.0.0'} + '@posthog/core@1.35.3': + resolution: {integrity: sha512-EsGPbSLl39Jgo2KZ+kI9UAxFnh5nddaN5bNm2rXvUwF+vGmam9eN1EXeNbxhRU7ulEeIiGdm7XjoU7pzavkgIQ==} + + '@posthog/types@1.390.2': + resolution: {integrity: sha512-WcfKz2GNn2vfDX8vXmJYbKxegPxVWHuDQ/pHdAn0HoZDXDFnEp/+x3qBQA+fEvtbPjjtjgAt2wIgJMlM7asx7g==} + '@rollup/rollup-android-arm-eabi@4.60.2': resolution: {integrity: sha512-dnlp69efPPg6Uaw2dVqzWRfAWRnYVb1XJ8CyyhIbZeaq4CA5/mLeZ1IEt9QqQxmbdvagjLIm2ZL8BxXv5lH4Yw==} cpu: [arm] @@ -2625,6 +2765,9 @@ packages: '@types/ms@2.1.0': resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==} + '@types/node@12.20.55': + resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} + '@types/node@25.6.2': resolution: {integrity: sha512-sokuT28dxf9JT5Kady1fsXOvI4HVpjZa95NKT5y9PNTIrs2AsobR4GFAA90ZG8M+nxVRLysCXsVj6eGC7Vbrlw==} @@ -2696,6 +2839,14 @@ packages: ajv@8.20.0: resolution: {integrity: sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==} + ansi-colors@4.1.3: + resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} + engines: {node: '>=6'} + + ansi-regex@5.0.1: + resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} + engines: {node: '>=8'} + any-promise@1.3.0: resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==} @@ -2705,6 +2856,10 @@ packages: argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} + array-union@2.1.0: + resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} + engines: {node: '>=8'} + assertion-error@2.0.1: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} @@ -2715,10 +2870,18 @@ packages: base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + better-path-resolve@1.0.0: + resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} + engines: {node: '>=4'} + body-parser@2.2.2: resolution: {integrity: sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==} engines: {node: '>=18'} + braces@3.0.3: + resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} + engines: {node: '>=8'} + bundle-require@5.1.0: resolution: {integrity: sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -2751,9 +2914,24 @@ packages: character-entities@2.0.2: resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==} + chardet@2.1.1: + resolution: {integrity: sha512-PsezH1rqdV9VvyNhxxOW32/d75r01NY7TQCmOqomRo15ZSOKbpTFVsfjghxo6JloQUCGnH4k1LGu0R4yCLlWQQ==} + chat@4.27.0: resolution: {integrity: sha512-PrL4k263DSIlckhX8eHLT84RdTSznOBxCCfaDc5JVJtWaS0lJkCNctm/g3gIrI41AcDHcpc/3WDoUHVrbh0W4w==} + chat@4.31.0: + resolution: {integrity: sha512-F6oJq9JUraLFkITS96/NKgwZwBfZX8aOwOj5qMs5NNwnOGHrSXZ5+osK+EA4HjzfyUEDfFTNiOSmyzgtFLpuWg==} + engines: {node: '>=20'} + peerDependencies: + ai: ^6.0.182 + zod: ^3.0.0 || ^4.0.0 + peerDependenciesMeta: + ai: + optional: true + zod: + optional: true + check-error@2.1.3: resolution: {integrity: sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==} engines: {node: '>= 16'} @@ -2825,9 +3003,17 @@ packages: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} + detect-indent@6.1.0: + resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} + engines: {node: '>=8'} + devlop@1.1.0: resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} + dir-glob@3.0.1: + resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} + engines: {node: '>=8'} + dotenv@17.4.2: resolution: {integrity: sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==} engines: {node: '>=12'} @@ -2843,6 +3029,10 @@ packages: resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==} engines: {node: '>= 0.8'} + enquirer@2.4.1: + resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} + engines: {node: '>=8.6'} + es-define-property@1.0.1: resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==} engines: {node: '>= 0.4'} @@ -2915,12 +3105,31 @@ packages: extend@3.0.2: resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} + extendable-error@0.1.7: + resolution: {integrity: sha512-UOiS2in6/Q0FK0R0q6UY9vYpQ21mr/Qn1KOnte7vsACuNJf514WvCCUHSRCPcgjPT2bAhNIJdlE6bVap1GKmeg==} + fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + fast-glob@3.3.3: + resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==} + engines: {node: '>=8.6.0'} + + fast-string-truncated-width@3.0.3: + resolution: {integrity: sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==} + + fast-string-width@3.0.2: + resolution: {integrity: sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==} + fast-uri@3.1.0: resolution: {integrity: sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==} + fast-wrap-ansi@0.2.2: + resolution: {integrity: sha512-7F2Fl+TjRSenLqlU3UjSH0iyqopqoZIu7eZVpEirP2g1GtWa2G/ecEmBdgz31+Mxr+ELclgg6sokpSFIQiZ02Q==} + + fastq@1.20.1: + resolution: {integrity: sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==} + fdir@6.5.0: resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} engines: {node: '>=12.0.0'} @@ -2934,10 +3143,18 @@ packages: resolution: {integrity: sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg==} engines: {node: '>=18'} + fill-range@7.1.1: + resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} + engines: {node: '>=8'} + finalhandler@2.1.1: resolution: {integrity: sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==} engines: {node: '>= 18.0.0'} + find-up@4.1.0: + resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} + engines: {node: '>=8'} + fix-dts-default-cjs-exports@1.0.1: resolution: {integrity: sha512-pVIECanWFC61Hzl2+oOCtoJ3F17kglZC/6N94eRWycFgBH35hHx0Li604ZIzhseh97mf2p0cv7vVrOZGoqhlEg==} @@ -2949,6 +3166,14 @@ packages: resolution: {integrity: sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==} engines: {node: '>= 0.8'} + fs-extra@7.0.1: + resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==} + engines: {node: '>=6 <7 || >=8'} + + fs-extra@8.1.0: + resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} + engines: {node: '>=6 <7 || >=8'} + fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -2969,10 +3194,21 @@ packages: resolution: {integrity: sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==} engines: {node: '>=18'} + glob-parent@5.1.2: + resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} + engines: {node: '>= 6'} + + globby@11.1.0: + resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} + engines: {node: '>=10'} + gopd@1.2.0: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} engines: {node: '>= 0.4'} + graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + gray-matter@4.0.3: resolution: {integrity: sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==} engines: {node: '>=6.0'} @@ -3008,6 +3244,10 @@ packages: resolution: {integrity: sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==} engines: {node: '>= 0.8'} + human-id@4.2.0: + resolution: {integrity: sha512-K3GbkIWqyvvlpfhBPlbEvD97TtqBpAYA4kt+cn2lD2x2HuohzZCibcA2nOlnJT6exqvJLggoB5nv2dNf192nEA==} + hasBin: true + human-signals@8.0.1: resolution: {integrity: sha512-eKCa6bwnJhvxj14kZk5NCPc6Hb6BdsU9DZcOnmQKSnO1VKrfV0zCvtttPZUsBvjmNDn8rpcJfpwSYnHBjc95MQ==} engines: {node: '>=18.18.0'} @@ -3016,6 +3256,10 @@ packages: resolution: {integrity: sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==} engines: {node: '>=0.10.0'} + ignore@5.3.2: + resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} + engines: {node: '>= 4'} + ignore@7.0.5: resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==} engines: {node: '>= 4'} @@ -3047,6 +3291,10 @@ packages: resolution: {integrity: sha512-6QCxa49rQbmUWLfk0nuGqzql9U8uaV2H6279bRErPBHe/109hCzsLUBUHfbEtvLIHBd6hyXbgedBSHevm43Edw==} engines: {node: '>=16'} + is-number@7.0.0: + resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} + engines: {node: '>=0.12.0'} + is-plain-obj@4.1.0: resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==} engines: {node: '>=12'} @@ -3058,10 +3306,18 @@ packages: resolution: {integrity: sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==} engines: {node: '>=18'} + is-subdir@1.2.0: + resolution: {integrity: sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==} + engines: {node: '>=4'} + is-unicode-supported@2.1.0: resolution: {integrity: sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==} engines: {node: '>=18'} + is-windows@1.0.2: + resolution: {integrity: sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==} + engines: {node: '>=0.10.0'} + isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} @@ -3072,6 +3328,9 @@ packages: resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} engines: {node: '>=10'} + jpeg-js@0.4.4: + resolution: {integrity: sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==} + js-tiktoken@1.0.21: resolution: {integrity: sha512-biOj/6M5qdgx5TKjDnFT1ymSpM5tbd3ylwDtrQvFQSu0Z7bBYko2dF+W/aUkXUPuk6IVpRxk/3Q2sHOzGlS36g==} @@ -3104,6 +3363,9 @@ packages: json-schema@0.4.0: resolution: {integrity: sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==} + jsonfile@4.0.0: + resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} + kind-of@6.0.3: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} @@ -3119,6 +3381,13 @@ packages: resolution: {integrity: sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + locate-path@5.0.0: + resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} + engines: {node: '>=8'} + + lodash.startcase@4.4.0: + resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} + lodash@4.18.1: resolution: {integrity: sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==} @@ -3183,6 +3452,10 @@ packages: resolution: {integrity: sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==} engines: {node: '>=18'} + merge2@1.4.1: + resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} + engines: {node: '>= 8'} + micromark-core-commonmark@2.0.3: resolution: {integrity: sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==} @@ -3267,6 +3540,10 @@ packages: micromark@4.0.2: resolution: {integrity: sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==} + micromatch@4.0.8: + resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} + engines: {node: '>=8.6'} + mime-db@1.54.0: resolution: {integrity: sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==} engines: {node: '>= 0.6'} @@ -3281,6 +3558,10 @@ packages: mlly@1.8.2: resolution: {integrity: sha512-d+ObxMQFmbt10sretNDytwt85VrbkhhUA/JBGm1MPaWJ65Cl4wOgLaB1NYvJSZ0Ef03MMEU/0xpPMXUIQ29UfA==} + mri@1.2.0: + resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} + engines: {node: '>=4'} + ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -3324,6 +3605,25 @@ packages: openapi-types@12.1.3: resolution: {integrity: sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==} + outdent@0.5.0: + resolution: {integrity: sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==} + + p-filter@2.1.0: + resolution: {integrity: sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw==} + engines: {node: '>=8'} + + p-limit@2.3.0: + resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} + engines: {node: '>=6'} + + p-locate@4.1.0: + resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} + engines: {node: '>=8'} + + p-map@2.1.0: + resolution: {integrity: sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==} + engines: {node: '>=6'} + p-map@7.0.4: resolution: {integrity: sha512-tkAQEw8ysMzmkhgw8k+1U/iPhWNhykKnSk4Rd5zLoPJCuJaGRPo6YposrZgaxHKzDHdDWWZvE/Sk7hsL2X/CpQ==} engines: {node: '>=18'} @@ -3332,6 +3632,13 @@ packages: resolution: {integrity: sha512-J5ApzjyRkkf601HpEeykoiCvzHQjWxPAHhyjFcEUP2SWq0+35NKh8TLhpLw+Dkq5TZBFvUM6UigdE9hIVYTl5w==} engines: {node: '>=20'} + p-try@2.2.0: + resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} + engines: {node: '>=6'} + + package-manager-detector@0.2.11: + resolution: {integrity: sha512-BEnLolu+yuz22S56CU1SUKq3XC3PkwD5wv4ikR4MfGvnRVcmzXR9DwSlW2fEamyTPyXHomBJRzgapeuBvRNzJQ==} + parse-ms@4.0.0: resolution: {integrity: sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==} engines: {node: '>=18'} @@ -3340,6 +3647,10 @@ packages: resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} engines: {node: '>= 0.8'} + path-exists@4.0.0: + resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} + engines: {node: '>=8'} + path-key@3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} @@ -3351,6 +3662,10 @@ packages: path-to-regexp@8.4.2: resolution: {integrity: sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==} + path-type@4.0.0: + resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} + engines: {node: '>=8'} + pathe@2.0.3: resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} @@ -3361,10 +3676,18 @@ packages: picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + picomatch@2.3.2: + resolution: {integrity: sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==} + engines: {node: '>=8.6'} + picomatch@4.0.4: resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==} engines: {node: '>=12'} + pify@4.0.1: + resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} + engines: {node: '>=6'} + pirates@4.0.7: resolution: {integrity: sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==} engines: {node: '>= 6'} @@ -3398,6 +3721,20 @@ packages: resolution: {integrity: sha512-qif0+jGGZoLWdHey3UFHHWP0H7Gbmsk8T5VEqyYFbWqPr1XqvLGBbk/sl8V5exGmcYJklJOhOQq1pV9IcsiFag==} engines: {node: ^10 || ^12 || >=14} + posthog-node@5.38.2: + resolution: {integrity: sha512-eiKpU+vX4hVuHbO/EosvPHsmh2AVIdoVmWss/uUOs1t4b0ViCblw2o8OIFqHxKj3mYRnSOBlX0Dw3wBvcCaYpA==} + engines: {node: ^20.20.0 || >=22.22.0} + peerDependencies: + rxjs: ^7.0.0 + peerDependenciesMeta: + rxjs: + optional: true + + prettier@2.8.8: + resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} + engines: {node: '>=10.13.0'} + hasBin: true + prettier@3.8.3: resolution: {integrity: sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==} engines: {node: '>=14'} @@ -3418,6 +3755,9 @@ packages: quansync@0.2.11: resolution: {integrity: sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA==} + queue-microtask@1.2.3: + resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + radash@12.1.1: resolution: {integrity: sha512-h36JMxKRqrAxVD8201FrCpyeNuUY9Y5zZwujr20fFO77tpUtGa6EZzfKw/3WaiBX95fq7+MpsuMLNdSnORAwSA==} engines: {node: '>=14.18.0'} @@ -3430,6 +3770,10 @@ packages: resolution: {integrity: sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==} engines: {node: '>= 0.10'} + read-yaml-file@1.1.0: + resolution: {integrity: sha512-VIMnQi/Z4HT2Fxuwg5KrY174U1VdUIASQVWXXyqtNRtxSr9IYkn1rsI6Tb6HsrHCmB7gVpNwX6JxPTHcH6IoTA==} + engines: {node: '>=6'} + readdirp@4.1.2: resolution: {integrity: sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==} engines: {node: '>= 14.18.0'} @@ -3454,6 +3798,10 @@ packages: resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} engines: {node: '>=8'} + reusify@1.1.0: + resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + rollup@4.60.2: resolution: {integrity: sha512-J9qZyW++QK/09NyN/zeO0dG/1GdGfyp9lV8ajHnRVLfo/uFsbji5mHnDgn/qYdUHyCkM2N+8VyspgZclfAh0eQ==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -3463,6 +3811,9 @@ packages: resolution: {integrity: sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==} engines: {node: '>= 18'} + run-parallel@1.2.0: + resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} @@ -3473,6 +3824,11 @@ packages: secure-json-parse@2.7.0: resolution: {integrity: sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==} + semver@7.8.5: + resolution: {integrity: sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==} + engines: {node: '>=10'} + hasBin: true + send@1.2.1: resolution: {integrity: sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==} engines: {node: '>= 18'} @@ -3515,6 +3871,13 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} + sisteransi@1.0.5: + resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} + + slash@3.0.0: + resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} + engines: {node: '>=8'} + source-map-js@1.2.1: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} @@ -3523,6 +3886,9 @@ packages: resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==} engines: {node: '>= 12'} + spawndamnit@3.0.1: + resolution: {integrity: sha512-MmnduQUuHCoFckZoWnXsTg7JaiLBJrKFj9UI2MbRPGaJeVpsLcVBu6P/IGZovziM/YBsellCmsprgNA+w0CzVg==} + sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} @@ -3536,10 +3902,18 @@ packages: std-env@3.10.0: resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==} + strip-ansi@6.0.1: + resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} + engines: {node: '>=8'} + strip-bom-string@1.0.0: resolution: {integrity: sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g==} engines: {node: '>=0.10.0'} + strip-bom@3.0.0: + resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} + engines: {node: '>=4'} + strip-final-newline@4.0.0: resolution: {integrity: sha512-aulFJcD6YK8V1G7iRB5tigAP4TsHBZZrOV8pjV++zdUwmeV8uzbY7yn6h9MswN62adStNZFuCIx4haBnRuMDaw==} engines: {node: '>=18'} @@ -3552,6 +3926,10 @@ packages: engines: {node: '>=16 || 14 >=14.17'} hasBin: true + term-size@2.2.1: + resolution: {integrity: sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==} + engines: {node: '>=8'} + thenify-all@1.6.0: resolution: {integrity: sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==} engines: {node: '>=0.8'} @@ -3581,6 +3959,10 @@ packages: resolution: {integrity: sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==} engines: {node: '>=14.0.0'} + to-regex-range@5.0.1: + resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} + engines: {node: '>=8.0'} + toidentifier@1.0.1: resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} engines: {node: '>=0.6'} @@ -3651,6 +4033,10 @@ packages: unist-util-visit@5.1.0: resolution: {integrity: sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==} + universalify@0.1.2: + resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} + engines: {node: '>= 4.0.0'} + unpipe@1.0.0: resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} engines: {node: '>= 0.8'} @@ -3832,6 +4218,13 @@ snapshots: eventsource-parser: 3.0.8 zod: 4.4.3 + '@ai-sdk/provider-utils@3.0.25(zod@4.4.3)': + dependencies: + '@ai-sdk/provider': 2.0.3 + '@standard-schema/spec': 1.1.0 + eventsource-parser: 3.0.8 + zod: 4.4.3 + '@ai-sdk/provider-utils@4.0.23(zod@4.4.3)': dependencies: '@ai-sdk/provider': 3.0.8 @@ -3839,6 +4232,13 @@ snapshots: eventsource-parser: 3.0.8 zod: 4.4.3 + '@ai-sdk/provider-utils@4.0.27(zod@4.4.3)': + dependencies: + '@ai-sdk/provider': 3.0.10 + '@standard-schema/spec': 1.1.0 + eventsource-parser: 3.0.8 + zod: 4.4.3 + '@ai-sdk/provider-utils@4.0.29(zod@4.4.3)': dependencies: '@ai-sdk/provider': 3.0.10 @@ -3854,6 +4254,10 @@ snapshots: dependencies: json-schema: 0.4.0 + '@ai-sdk/provider@2.0.3': + dependencies: + json-schema: 0.4.0 + '@ai-sdk/provider@3.0.10': dependencies: json-schema: 0.4.0 @@ -3875,6 +4279,163 @@ snapshots: '@types/json-schema': 7.0.15 js-yaml: 4.1.1 + '@babel/runtime@7.29.7': {} + + '@changesets/apply-release-plan@7.1.1': + dependencies: + '@changesets/config': 3.1.4 + '@changesets/get-version-range-type': 0.4.0 + '@changesets/git': 3.0.4 + '@changesets/should-skip-package': 0.1.2 + '@changesets/types': 6.1.0 + '@manypkg/get-packages': 1.1.3 + detect-indent: 6.1.0 + fs-extra: 7.0.1 + lodash.startcase: 4.4.0 + outdent: 0.5.0 + prettier: 2.8.8 + resolve-from: 5.0.0 + semver: 7.8.5 + + '@changesets/assemble-release-plan@6.0.10': + dependencies: + '@changesets/errors': 0.2.0 + '@changesets/get-dependents-graph': 2.1.4 + '@changesets/should-skip-package': 0.1.2 + '@changesets/types': 6.1.0 + '@manypkg/get-packages': 1.1.3 + semver: 7.8.5 + + '@changesets/changelog-git@0.2.1': + dependencies: + '@changesets/types': 6.1.0 + + '@changesets/cli@2.31.0(@types/node@25.6.2)': + dependencies: + '@changesets/apply-release-plan': 7.1.1 + '@changesets/assemble-release-plan': 6.0.10 + '@changesets/changelog-git': 0.2.1 + '@changesets/config': 3.1.4 + '@changesets/errors': 0.2.0 + '@changesets/get-dependents-graph': 2.1.4 + '@changesets/get-release-plan': 4.0.16 + '@changesets/git': 3.0.4 + '@changesets/logger': 0.1.1 + '@changesets/pre': 2.0.2 + '@changesets/read': 0.6.7 + '@changesets/should-skip-package': 0.1.2 + '@changesets/types': 6.1.0 + '@changesets/write': 0.4.0 + '@inquirer/external-editor': 1.0.3(@types/node@25.6.2) + '@manypkg/get-packages': 1.1.3 + ansi-colors: 4.1.3 + enquirer: 2.4.1 + fs-extra: 7.0.1 + mri: 1.2.0 + package-manager-detector: 0.2.11 + picocolors: 1.1.1 + resolve-from: 5.0.0 + semver: 7.8.5 + spawndamnit: 3.0.1 + term-size: 2.2.1 + transitivePeerDependencies: + - '@types/node' + + '@changesets/config@3.1.4': + dependencies: + '@changesets/errors': 0.2.0 + '@changesets/get-dependents-graph': 2.1.4 + '@changesets/logger': 0.1.1 + '@changesets/should-skip-package': 0.1.2 + '@changesets/types': 6.1.0 + '@manypkg/get-packages': 1.1.3 + fs-extra: 7.0.1 + micromatch: 4.0.8 + + '@changesets/errors@0.2.0': + dependencies: + extendable-error: 0.1.7 + + '@changesets/get-dependents-graph@2.1.4': + dependencies: + '@changesets/types': 6.1.0 + '@manypkg/get-packages': 1.1.3 + picocolors: 1.1.1 + semver: 7.8.5 + + '@changesets/get-release-plan@4.0.16': + dependencies: + '@changesets/assemble-release-plan': 6.0.10 + '@changesets/config': 3.1.4 + '@changesets/pre': 2.0.2 + '@changesets/read': 0.6.7 + '@changesets/types': 6.1.0 + '@manypkg/get-packages': 1.1.3 + + '@changesets/get-version-range-type@0.4.0': {} + + '@changesets/git@3.0.4': + dependencies: + '@changesets/errors': 0.2.0 + '@manypkg/get-packages': 1.1.3 + is-subdir: 1.2.0 + micromatch: 4.0.8 + spawndamnit: 3.0.1 + + '@changesets/logger@0.1.1': + dependencies: + picocolors: 1.1.1 + + '@changesets/parse@0.4.3': + dependencies: + '@changesets/types': 6.1.0 + js-yaml: 4.1.1 + + '@changesets/pre@2.0.2': + dependencies: + '@changesets/errors': 0.2.0 + '@changesets/types': 6.1.0 + '@manypkg/get-packages': 1.1.3 + fs-extra: 7.0.1 + + '@changesets/read@0.6.7': + dependencies: + '@changesets/git': 3.0.4 + '@changesets/logger': 0.1.1 + '@changesets/parse': 0.4.3 + '@changesets/types': 6.1.0 + fs-extra: 7.0.1 + p-filter: 2.1.0 + picocolors: 1.1.1 + + '@changesets/should-skip-package@0.1.2': + dependencies: + '@changesets/types': 6.1.0 + '@manypkg/get-packages': 1.1.3 + + '@changesets/types@4.1.0': {} + + '@changesets/types@6.1.0': {} + + '@changesets/write@0.4.0': + dependencies: + '@changesets/types': 6.1.0 + fs-extra: 7.0.1 + human-id: 4.2.0 + prettier: 2.8.8 + + '@clack/core@1.4.2': + dependencies: + fast-wrap-ansi: 0.2.2 + sisteransi: 1.0.5 + + '@clack/prompts@1.6.0': + dependencies: + '@clack/core': 1.4.2 + fast-string-width: 3.0.2 + fast-wrap-ansi: 0.2.2 + sisteransi: 1.0.5 + '@esbuild/aix-ppc64@0.27.7': optional: true @@ -3957,6 +4518,13 @@ snapshots: dependencies: hono: 4.12.16 + '@inquirer/external-editor@1.0.3(@types/node@25.6.2)': + dependencies: + chardet: 2.1.1 + iconv-lite: 0.7.2 + optionalDependencies: + '@types/node': 25.6.2 + '@isaacs/ttlcache@2.1.4': {} '@jridgewell/gen-mapping@0.3.13': @@ -3981,6 +4549,22 @@ snapshots: dependencies: '@lukeed/csprng': 1.1.0 + '@manypkg/find-root@1.1.0': + dependencies: + '@babel/runtime': 7.29.7 + '@types/node': 12.20.55 + find-up: 4.1.0 + fs-extra: 8.1.0 + + '@manypkg/get-packages@1.1.3': + dependencies: + '@babel/runtime': 7.29.7 + '@changesets/types': 4.1.0 + '@manypkg/find-root': 1.1.0 + fs-extra: 8.1.0 + globby: 11.1.0 + read-yaml-file: 1.1.0 + '@mastra/core@1.31.0(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-schema/spec@1.1.0)(openapi-types@12.1.3)(zod@4.4.3))(@types/json-schema@7.0.15)(express@5.2.1)(openapi-types@12.1.3)(zod@4.4.3)': dependencies: '@a2a-js/sdk': 0.3.13(express@5.2.1) @@ -4028,36 +4612,34 @@ snapshots: - supports-color - utf-8-validate - '@mastra/core@1.32.1(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-schema/spec@1.1.0)(openapi-types@12.1.3)(zod@4.4.3))(@types/json-schema@7.0.15)(express@5.2.1)(openapi-types@12.1.3)(zod@4.4.3)': + '@mastra/core@1.45.0(ai@6.0.205(zod@4.4.3))(express@5.2.1)(zod@4.4.3)': dependencies: '@a2a-js/sdk': 0.3.13(express@5.2.1) - '@ai-sdk/provider-utils-v5': '@ai-sdk/provider-utils@3.0.23(zod@4.4.3)' - '@ai-sdk/provider-utils-v6': '@ai-sdk/provider-utils@4.0.23(zod@4.4.3)' - '@ai-sdk/provider-v5': '@ai-sdk/provider@2.0.1' - '@ai-sdk/provider-v6': '@ai-sdk/provider@3.0.8' - '@ai-sdk/ui-utils-v5': '@ai-sdk/ui-utils@1.2.11(zod@4.4.3)' + '@ai-sdk/provider-utils-v5': '@ai-sdk/provider-utils@3.0.25(zod@4.4.3)' + '@ai-sdk/provider-utils-v6': '@ai-sdk/provider-utils@4.0.27(zod@4.4.3)' + '@ai-sdk/provider-v5': '@ai-sdk/provider@2.0.3' + '@ai-sdk/provider-v6': '@ai-sdk/provider@3.0.10' '@isaacs/ttlcache': 2.1.4 '@lukeed/uuid': 2.0.1 - '@mastra/schema-compat': 1.2.9(zod@4.4.3) + '@mastra/schema-compat': 1.3.0(zod@4.4.3) '@modelcontextprotocol/sdk': 1.29.0(zod@4.4.3) '@sindresorhus/slugify': 2.2.1 '@standard-schema/spec': 1.1.0 ajv: 8.20.0 - chat: 4.27.0 + chat: 4.31.0(ai@6.0.205(zod@4.4.3))(zod@4.4.3) croner: 10.0.1 dotenv: 17.4.2 execa: 9.6.1 + fastq: 1.20.1 gray-matter: 4.0.3 - hono: 4.12.16 - hono-openapi: 1.3.0(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-schema/spec@1.1.0)(openapi-types@12.1.3)(zod@4.4.3))(@types/json-schema@7.0.15)(hono@4.12.16)(openapi-types@12.1.3) ignore: 7.0.5 - js-tiktoken: 1.0.21 + jpeg-js: 0.4.4 json-schema: 0.4.0 lru-cache: 11.3.5 p-map: 7.0.4 p-retry: 7.1.1 picomatch: 4.0.4 - radash: 12.1.1 + posthog-node: 5.38.2 tokenx: 1.3.0 ws: 8.20.0 xxhash-wasm: 1.1.0 @@ -4066,13 +4648,10 @@ snapshots: - '@bufbuild/protobuf' - '@cfworker/json-schema' - '@grpc/grpc-js' - - '@hono/standard-validator' - - '@standard-community/standard-json' - - '@standard-community/standard-openapi' - - '@types/json-schema' + - ai - bufferutil - express - - openapi-types + - rxjs - supports-color - utf-8-validate @@ -4084,6 +4663,14 @@ snapshots: zod-from-json-schema-v3: zod-from-json-schema@0.0.5 zod-to-json-schema: 3.25.2(zod@4.4.3) + '@mastra/schema-compat@1.3.0(zod@4.4.3)': + dependencies: + json-schema-to-zod: 2.8.1 + zod: 4.4.3 + zod-from-json-schema: 0.5.2 + zod-from-json-schema-v3: zod-from-json-schema@0.0.5 + zod-to-json-schema: 3.25.2(zod@4.4.3) + '@modelcontextprotocol/sdk@1.29.0(zod@4.4.3)': dependencies: '@hono/node-server': 1.19.14(hono@4.12.16) @@ -4106,8 +4693,26 @@ snapshots: transitivePeerDependencies: - supports-color + '@nodelib/fs.scandir@2.1.5': + dependencies: + '@nodelib/fs.stat': 2.0.5 + run-parallel: 1.2.0 + + '@nodelib/fs.stat@2.0.5': {} + + '@nodelib/fs.walk@1.2.8': + dependencies: + '@nodelib/fs.scandir': 2.1.5 + fastq: 1.20.1 + '@opentelemetry/api@1.9.0': {} + '@posthog/core@1.35.3': + dependencies: + '@posthog/types': 1.390.2 + + '@posthog/types@1.390.2': {} + '@rollup/rollup-android-arm-eabi@4.60.2': optional: true @@ -4238,6 +4843,8 @@ snapshots: '@types/ms@2.1.0': {} + '@types/node@12.20.55': {} + '@types/node@25.6.2': dependencies: undici-types: 7.19.2 @@ -4320,6 +4927,10 @@ snapshots: json-schema-traverse: 1.0.0 require-from-string: 2.0.2 + ansi-colors@4.1.3: {} + + ansi-regex@5.0.1: {} + any-promise@1.3.0: {} argparse@1.0.10: @@ -4328,12 +4939,18 @@ snapshots: argparse@2.0.1: {} + array-union@2.1.0: {} + assertion-error@2.0.1: {} bail@2.0.2: {} base64-js@1.5.1: {} + better-path-resolve@1.0.0: + dependencies: + is-windows: 1.0.2 + body-parser@2.2.2: dependencies: bytes: 3.1.2 @@ -4348,6 +4965,10 @@ snapshots: transitivePeerDependencies: - supports-color + braces@3.0.3: + dependencies: + fill-range: 7.1.1 + bundle-require@5.1.0(esbuild@0.27.7): dependencies: esbuild: 0.27.7 @@ -4379,6 +5000,8 @@ snapshots: character-entities@2.0.2: {} + chardet@2.1.1: {} + chat@4.27.0: dependencies: '@workflow/serde': 4.1.0-beta.2 @@ -4391,6 +5014,21 @@ snapshots: transitivePeerDependencies: - supports-color + chat@4.31.0(ai@6.0.205(zod@4.4.3))(zod@4.4.3): + dependencies: + '@workflow/serde': 4.1.0-beta.2 + mdast-util-to-string: 4.0.0 + remark-gfm: 4.0.1 + remark-parse: 11.0.0 + remark-stringify: 11.0.0 + remend: 1.3.0 + unified: 11.0.5 + optionalDependencies: + ai: 6.0.205(zod@4.4.3) + zod: 4.4.3 + transitivePeerDependencies: + - supports-color + check-error@2.1.3: {} chokidar@4.0.3: @@ -4438,10 +5076,16 @@ snapshots: dequal@2.0.3: {} + detect-indent@6.1.0: {} + devlop@1.1.0: dependencies: dequal: 2.0.3 + dir-glob@3.0.1: + dependencies: + path-type: 4.0.0 + dotenv@17.4.2: {} dunder-proto@1.0.1: @@ -4454,6 +5098,11 @@ snapshots: encodeurl@2.0.0: {} + enquirer@2.4.1: + dependencies: + ansi-colors: 4.1.3 + strip-ansi: 6.0.1 + es-define-property@1.0.1: {} es-errors@1.3.0: {} @@ -4572,10 +5221,34 @@ snapshots: extend@3.0.2: {} + extendable-error@0.1.7: {} + fast-deep-equal@3.1.3: {} + fast-glob@3.3.3: + dependencies: + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.8 + + fast-string-truncated-width@3.0.3: {} + + fast-string-width@3.0.2: + dependencies: + fast-string-truncated-width: 3.0.3 + fast-uri@3.1.0: {} + fast-wrap-ansi@0.2.2: + dependencies: + fast-string-width: 3.0.2 + + fastq@1.20.1: + dependencies: + reusify: 1.1.0 + fdir@6.5.0(picomatch@4.0.4): optionalDependencies: picomatch: 4.0.4 @@ -4584,6 +5257,10 @@ snapshots: dependencies: is-unicode-supported: 2.1.0 + fill-range@7.1.1: + dependencies: + to-regex-range: 5.0.1 + finalhandler@2.1.1: dependencies: debug: 4.4.3 @@ -4595,6 +5272,11 @@ snapshots: transitivePeerDependencies: - supports-color + find-up@4.1.0: + dependencies: + locate-path: 5.0.0 + path-exists: 4.0.0 + fix-dts-default-cjs-exports@1.0.1: dependencies: magic-string: 0.30.21 @@ -4605,6 +5287,18 @@ snapshots: fresh@2.0.0: {} + fs-extra@7.0.1: + dependencies: + graceful-fs: 4.2.11 + jsonfile: 4.0.0 + universalify: 0.1.2 + + fs-extra@8.1.0: + dependencies: + graceful-fs: 4.2.11 + jsonfile: 4.0.0 + universalify: 0.1.2 + fsevents@2.3.3: optional: true @@ -4633,8 +5327,23 @@ snapshots: '@sec-ant/readable-stream': 0.4.1 is-stream: 4.0.1 + glob-parent@5.1.2: + dependencies: + is-glob: 4.0.3 + + globby@11.1.0: + dependencies: + array-union: 2.1.0 + dir-glob: 3.0.1 + fast-glob: 3.3.3 + ignore: 5.3.2 + merge2: 1.4.1 + slash: 3.0.0 + gopd@1.2.0: {} + graceful-fs@4.2.11: {} + gray-matter@4.0.3: dependencies: js-yaml: 3.14.2 @@ -4667,12 +5376,16 @@ snapshots: statuses: 2.0.2 toidentifier: 1.0.1 + human-id@4.2.0: {} + human-signals@8.0.1: {} iconv-lite@0.7.2: dependencies: safer-buffer: 2.1.2 + ignore@5.3.2: {} + ignore@7.0.5: {} inherits@2.0.4: {} @@ -4691,20 +5404,30 @@ snapshots: is-network-error@1.3.1: {} + is-number@7.0.0: {} + is-plain-obj@4.1.0: {} is-promise@4.0.0: {} is-stream@4.0.1: {} + is-subdir@1.2.0: + dependencies: + better-path-resolve: 1.0.0 + is-unicode-supported@2.1.0: {} + is-windows@1.0.2: {} + isexe@2.0.0: {} jose@6.2.3: {} joycon@3.1.1: {} + jpeg-js@0.4.4: {} + js-tiktoken@1.0.21: dependencies: base64-js: 1.5.1 @@ -4740,6 +5463,10 @@ snapshots: json-schema@0.4.0: {} + jsonfile@4.0.0: + optionalDependencies: + graceful-fs: 4.2.11 + kind-of@6.0.3: {} lilconfig@3.1.3: {} @@ -4748,6 +5475,12 @@ snapshots: load-tsconfig@0.2.5: {} + locate-path@5.0.0: + dependencies: + p-locate: 4.1.0 + + lodash.startcase@4.4.0: {} + lodash@4.18.1: {} longest-streak@3.1.0: {} @@ -4870,6 +5603,8 @@ snapshots: merge-descriptors@2.0.0: {} + merge2@1.4.1: {} + micromark-core-commonmark@2.0.3: dependencies: decode-named-character-reference: 1.3.0 @@ -5061,6 +5796,11 @@ snapshots: transitivePeerDependencies: - supports-color + micromatch@4.0.8: + dependencies: + braces: 3.0.3 + picomatch: 2.3.2 + mime-db@1.54.0: {} mime-types@3.0.2: @@ -5076,6 +5816,8 @@ snapshots: pkg-types: 1.3.1 ufo: 1.6.4 + mri@1.2.0: {} + ms@2.1.3: {} mz@2.7.0: @@ -5115,30 +5857,60 @@ snapshots: openapi-types@12.1.3: {} + outdent@0.5.0: {} + + p-filter@2.1.0: + dependencies: + p-map: 2.1.0 + + p-limit@2.3.0: + dependencies: + p-try: 2.2.0 + + p-locate@4.1.0: + dependencies: + p-limit: 2.3.0 + + p-map@2.1.0: {} + p-map@7.0.4: {} p-retry@7.1.1: dependencies: is-network-error: 1.3.1 + p-try@2.2.0: {} + + package-manager-detector@0.2.11: + dependencies: + quansync: 0.2.11 + parse-ms@4.0.0: {} parseurl@1.3.3: {} + path-exists@4.0.0: {} + path-key@3.1.1: {} path-key@4.0.0: {} path-to-regexp@8.4.2: {} + path-type@4.0.0: {} + pathe@2.0.3: {} pathval@2.0.1: {} picocolors@1.1.1: {} + picomatch@2.3.2: {} + picomatch@4.0.4: {} + pify@4.0.1: {} + pirates@4.0.7: {} pkce-challenge@5.0.1: {} @@ -5162,6 +5934,12 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 + posthog-node@5.38.2: + dependencies: + '@posthog/core': 1.35.3 + + prettier@2.8.8: {} + prettier@3.8.3: {} pretty-ms@9.3.0: @@ -5179,6 +5957,8 @@ snapshots: quansync@0.2.11: {} + queue-microtask@1.2.3: {} + radash@12.1.1: {} range-parser@1.2.1: {} @@ -5190,6 +5970,13 @@ snapshots: iconv-lite: 0.7.2 unpipe: 1.0.0 + read-yaml-file@1.1.0: + dependencies: + graceful-fs: 4.2.11 + js-yaml: 3.14.2 + pify: 4.0.1 + strip-bom: 3.0.0 + readdirp@4.1.2: {} remark-gfm@4.0.1: @@ -5224,6 +6011,8 @@ snapshots: resolve-from@5.0.0: {} + reusify@1.1.0: {} + rollup@4.60.2: dependencies: '@types/estree': 1.0.8 @@ -5265,6 +6054,10 @@ snapshots: transitivePeerDependencies: - supports-color + run-parallel@1.2.0: + dependencies: + queue-microtask: 1.2.3 + safer-buffer@2.1.2: {} section-matter@1.0.0: @@ -5274,6 +6067,8 @@ snapshots: secure-json-parse@2.7.0: {} + semver@7.8.5: {} + send@1.2.1: dependencies: debug: 4.4.3 @@ -5339,10 +6134,19 @@ snapshots: signal-exit@4.1.0: {} + sisteransi@1.0.5: {} + + slash@3.0.0: {} + source-map-js@1.2.1: {} source-map@0.7.6: {} + spawndamnit@3.0.1: + dependencies: + cross-spawn: 7.0.6 + signal-exit: 4.1.0 + sprintf-js@1.0.3: {} stackback@0.0.2: {} @@ -5351,8 +6155,14 @@ snapshots: std-env@3.10.0: {} + strip-ansi@6.0.1: + dependencies: + ansi-regex: 5.0.1 + strip-bom-string@1.0.0: {} + strip-bom@3.0.0: {} + strip-final-newline@4.0.0: {} strip-literal@3.1.0: @@ -5369,6 +6179,8 @@ snapshots: tinyglobby: 0.2.16 ts-interface-checker: 0.1.13 + term-size@2.2.1: {} + thenify-all@1.6.0: dependencies: thenify: 3.3.1 @@ -5392,6 +6204,10 @@ snapshots: tinyspy@4.0.4: {} + to-regex-range@5.0.1: + dependencies: + is-number: 7.0.0 + toidentifier@1.0.1: {} tokenx@1.3.0: {} @@ -5473,6 +6289,8 @@ snapshots: unist-util-is: 6.0.1 unist-util-visit-parents: 6.0.2 + universalify@0.1.2: {} + unpipe@1.0.0: {} uuid@11.1.1: {} From 07c1d4a54de5f978129204e58794c0541019d6bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 14:32:44 +0200 Subject: [PATCH 06/19] feat(driver): expose driver doctype via MCP create_driver verb - Add DoctypeSpec for DRIVER.md (spec.ts) + re-export from @agentproto/driver index - Thread driverSpec into agentproto-serve so MCP server registers create_driver - Add @agentproto/driver dep + external in cli/tsup.config.ts - Add @agentproto/manifest dep to @agentproto/driver (needed by spec) - Bundled adapter catalog (catalog.ts) + listAdaptersWithCatalog in resolve.ts (carried alongside: serve.ts imports both for adapter discovery) Co-Authored-By: Claude Sonnet 4.6 --- packages/cli/package.json | 2 + packages/cli/src/commands/serve.ts | 19 +- packages/cli/src/registry/catalog.ts | 81 +++++ packages/cli/src/registry/resolve.ts | 199 ++++++++++-- packages/cli/tsup.config.ts | 1 + packages/driver/core/package.json | 1 + .../driver/core/src/__tests__/spec.test.ts | 298 ++++++++++++++++++ packages/driver/core/src/index.ts | 2 + packages/driver/core/src/spec.ts | 167 ++++++++++ packages/driver/core/tsup.config.ts | 1 + 10 files changed, 736 insertions(+), 35 deletions(-) create mode 100644 packages/cli/src/registry/catalog.ts create mode 100644 packages/driver/core/src/__tests__/spec.test.ts create mode 100644 packages/driver/core/src/spec.ts diff --git a/packages/cli/package.json b/packages/cli/package.json index 99d0da2343..62342e0657 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -79,8 +79,10 @@ }, "dependencies": { "@agentproto/acp": "workspace:*", + "@agentproto/driver": "workspace:*", "@agentproto/driver-agent-cli": "workspace:*", "@agentproto/runtime-profile-standard": "workspace:*", + "@clack/prompts": "^1.5.0", "@modelcontextprotocol/sdk": "^1.29.0", "gray-matter": "^4.0.3", "ws": "^8.20.0", diff --git a/packages/cli/src/commands/serve.ts b/packages/cli/src/commands/serve.ts index a013b2cf92..93269fac27 100644 --- a/packages/cli/src/commands/serve.ts +++ b/packages/cli/src/commands/serve.ts @@ -64,10 +64,12 @@ import { type GatewayHandle, } from "@agentproto/runtime" import { createAgentCliRuntime } from "@agentproto/driver-agent-cli" +import { driverSpec } from "@agentproto/driver" import { resolveAdapter, - listInstalledAdapters, + listAdaptersWithCatalog, } from "../registry/resolve.js" +import { CATALOG } from "../registry/catalog.js" import WebSocket from "ws" interface ServeOpts { @@ -258,10 +260,11 @@ export async function runServe(args: readonly string[]): Promise { const adapter = await resolveAdapter(slug) const runtime = createAgentCliRuntime(adapter.handle) return { - async startSession({ cwd, resumeSessionId }) { + async startSession({ cwd, resumeSessionId, model }) { return runtime.start({ cwd, ...(resumeSessionId ? { resumeSessionId } : {}), + ...(model ? { config: { options: { model } } } : {}), }) }, commandPreview: @@ -296,15 +299,15 @@ export async function runServe(args: readonly string[]): Promise { workspace: opts.workspace, port: opts.port, bind: opts.bind, - specs: [], + specs: [driverSpec], name: "agentproto-serve", // BOOT.md is silly for a tunnel daemon — skip it. boot: false, resolveAgentAdapter, // Discovery for UIs / operators — `GET /adapters` + `list_adapters` - // MCP tool. Walks node_modules @agentproto/adapter-* on each call; - // cheap enough that we don't bother caching here. - listAgentAdapters: listInstalledAdapters, + // MCP tool. Starts from the bundled catalog so known adapters always + // appear (with status "supported") even when not yet installed. + listAgentAdapters: () => listAdaptersWithCatalog(CATALOG), ...(spawnPty ? { spawnPty } : {}), ...(opts.allowedOrigins ? { allowedOrigins: opts.allowedOrigins } @@ -325,8 +328,8 @@ export async function runServe(args: readonly string[]): Promise { // The adapters are what differentiate one daemon from another (every daemon // registers the same base doctypes), so a multi-daemon host routes on them. // Computed once at boot — the adapter walk is cheap but not worth per-reconnect. - const installedAdapterSlugs = await listInstalledAdapters() - .then(list => list.map(a => a.slug)) + const installedAdapterSlugs = await listAdaptersWithCatalog(CATALOG) + .then(list => list.filter(a => a.status !== "supported").map(a => a.slug)) .catch(() => [] as string[]) const announcedTools = [ ...new Set([...gateway.registered, ...installedAdapterSlugs]), diff --git a/packages/cli/src/registry/catalog.ts b/packages/cli/src/registry/catalog.ts new file mode 100644 index 0000000000..1b61f1dcf3 --- /dev/null +++ b/packages/cli/src/registry/catalog.ts @@ -0,0 +1,81 @@ +/** + * Bundled catalog of known installable items. + * + * Used by `agentproto install` (no-arg interactive mode) to populate the + * type → slug picker without any network calls or adapter resolution. + * + * The catalog is intentionally static: it's the "known good" list shipped + * with this CLI version. Adapters discovered in node_modules at runtime + * (via `listInstalledAdapters`) may exceed this list — the catalog is a + * first-run UX affordance, not a complete registry. + */ + +export type CatalogEntryType = "agent-cli" | "pack" | "mcp" + +export interface CatalogEntry { + type: CatalogEntryType + /** Adapter slug — matches `@agentproto/adapter-`. */ + slug: string + /** Display name shown in the picker. */ + name: string + /** One-line description (fits in a select hint). */ + description: string + /** npm package that provides the adapter. */ + packageName: string + /** Short hint shown inline in the picker (protocol, provider, key capability). */ + hint?: string +} + +export const CATALOG: readonly CatalogEntry[] = [ + // ── Agent CLIs ──────────────────────────────────────────────────────── + { + type: "agent-cli", + slug: "claude-code", + name: "Claude Code", + description: + "Anthropic's Claude Code via @agentclientprotocol/claude-agent-acp ACP wrapper.", + packageName: "@agentproto/adapter-claude-code", + hint: "anthropic · ACP · resumable", + }, + { + type: "agent-cli", + slug: "opencode", + name: "OpenCode", + description: + "sst/opencode with first-party ACP mode. Multi-provider: Anthropic, OpenAI, OpenRouter, Groq.", + packageName: "@agentproto/adapter-opencode", + hint: "multi-provider · ACP · resumable", + }, + { + type: "agent-cli", + slug: "codex", + name: "Codex", + description: + "OpenAI Codex coding agent via Zed's @zed-industries/codex-acp ACP wrapper.", + packageName: "@agentproto/adapter-codex", + hint: "openai · ACP · resumable", + }, + { + type: "agent-cli", + slug: "hermes", + name: "Hermes", + description: + "Nous Research Hermes agent with skills, sandboxes, and memory plugin surface.", + packageName: "@agentproto/adapter-hermes", + hint: "nous · ACP · sub-agents", + }, + { + type: "agent-cli", + slug: "openclaw", + name: "OpenClaw", + description: + "OpenClaw coding-agent platform with native ACP bridge and plugin surface.", + packageName: "@agentproto/adapter-openclaw", + hint: "gateway · ACP · plugins", + }, +] as const + +/** Filter the catalog by entry type. */ +export function catalogByType(type: CatalogEntryType): CatalogEntry[] { + return CATALOG.filter((e) => e.type === type) as CatalogEntry[] +} diff --git a/packages/cli/src/registry/resolve.ts b/packages/cli/src/registry/resolve.ts index fb1f11f5b1..d8e7fccd55 100644 --- a/packages/cli/src/registry/resolve.ts +++ b/packages/cli/src/registry/resolve.ts @@ -14,8 +14,10 @@ */ import { promises as fs } from "node:fs" -import { resolve as resolvePath } from "node:path" -import type { AgentCliHandle } from "@agentproto/driver-agent-cli" +import { fileURLToPath } from "node:url" +import { dirname, join, resolve as resolvePath } from "node:path" +import { homedir } from "node:os" +import type { AgentCliHandle, AgentCliCommand } from "@agentproto/driver-agent-cli" export interface ResolvedAdapter { readonly slug: string @@ -45,6 +47,15 @@ export interface AdapterInfo { streaming: boolean /** npm package name (for install hints / "open in npmjs.com" links). */ packageName: string + /** Slash-commands the agent CLI accepts as ordinary text turns. + * Empty when the adapter doesn't declare any. */ + commands: AgentCliCommand[] + /** Known-valid model identifiers for this adapter, drawn from the + * adapter manifest's `models.allowed` field. Empty when the adapter + * doesn't declare a model list (accepts whatever the underlying + * binary accepts). Pass one of these as `model` in `start_agent_session` + * to avoid trial-and-error validation errors. */ + models: string[] } const slugToCamel = (slug: string): string => @@ -58,18 +69,40 @@ export async function resolveAdapter(slug: string): Promise { } const packageName = `@agentproto/adapter-${slug}` + const camel = slugToCamel(slug) let mod: Record + let resolvedPackageName = packageName try { mod = (await import(packageName)) as Record - } catch (err) { - const cause = err instanceof Error ? err.message : String(err) + } catch (primaryErr) { + // Fallback: strip the last hyphen-segment and try the parent package, + // looking for the full camelCase export there. + // e.g. "claude-code-print" → "@agentproto/adapter-claude-code" + export "claudeCodePrint" + const hyphen = slug.lastIndexOf("-") + if (hyphen > 0) { + const parentPkg = `@agentproto/adapter-${slug.slice(0, hyphen)}` + try { + const parentMod = (await import(parentPkg)) as Record + const parentCandidate = parentMod[camel] as AgentCliHandle | undefined + if ( + parentCandidate && + typeof parentCandidate === "object" && + "name" in parentCandidate + ) { + return { slug, handle: parentCandidate, source: "npm", packageName: parentPkg } + } + } catch { + /* parent also missing — fall through to original error */ + } + } + + const cause = primaryErr instanceof Error ? primaryErr.message : String(primaryErr) throw new Error( `agentproto: could not load adapter '${slug}'. ` + `Tried '${packageName}'. Install it with: npm i -g ${packageName}\n cause: ${cause}` ) } - const camel = slugToCamel(slug) const candidate = (mod[camel] as AgentCliHandle | undefined) ?? (mod.default as AgentCliHandle | undefined) ?? @@ -77,12 +110,12 @@ export async function resolveAdapter(slug: string): Promise { if (!candidate || typeof candidate !== "object" || !("name" in candidate)) { throw new Error( - `agentproto: adapter '${packageName}' does not export an AgentCliHandle ` + + `agentproto: adapter '${resolvedPackageName}' does not export an AgentCliHandle ` + `(looked for export '${camel}', 'default', or 'handle').` ) } - return { slug, handle: candidate, source: "npm", packageName } + return { slug, handle: candidate, source: "npm", packageName: resolvedPackageName } } /** @@ -134,6 +167,7 @@ export async function listInstalledAdapters(opts?: { try { const resolved = await resolveAdapter(slug) const handle = resolved.handle as Record + const modelsField = (handle.models as { allowed?: unknown } | undefined)?.allowed const info: AdapterInfo = { slug, name: typeof handle.name === "string" ? handle.name : slug, @@ -145,6 +179,10 @@ export async function listInstalledAdapters(opts?: { streaming: !!(handle.capabilities as { streaming?: boolean }) ?.streaming, packageName: resolved.packageName ?? `@agentproto/adapter-${slug}`, + commands: Array.isArray(handle.commands) ? (handle.commands as AgentCliCommand[]) : [], + models: Array.isArray(modelsField) + ? (modelsField as unknown[]).filter((m): m is string => typeof m === "string") + : [], } out.push(info) } catch (err) { @@ -191,33 +229,140 @@ export async function listInstalledAdapters(opts?: { async function collectAgentprotoNamespaceRoots( start?: string ): Promise { + const seen = new Set() const roots: string[] = [] - // Start from this package's own dir — works in ESM (import.meta.url - // route would be cleaner but isn't needed; cwd is reliable enough - // for the daemon use case where it boots from a known dir). - let cur = start ?? process.cwd() - // Both classic + pnpm-hoist locations. Classic npm puts the - // namespace at node_modules/@agentproto; pnpm hoists to - // node_modules/.pnpm/node_modules/@agentproto and symlinks - // individual packages from there. We need to scan the hoist dir - // for the listing because the namespace dir is the only place - // where every adapter package is enumerable. const candidatesAt = (dir: string): string[] => [ resolvePath(dir, "node_modules", "@agentproto"), resolvePath(dir, "node_modules", ".pnpm", "node_modules", "@agentproto"), ] - for (let depth = 0; depth < 16; depth++) { - for (const candidate of candidatesAt(cur)) { - try { - const stat = await fs.stat(candidate) - if (stat.isDirectory()) roots.push(candidate) - } catch { - /* not present at this level */ + + async function walkUp(from: string): Promise { + let cur = from + for (let depth = 0; depth < 20; depth++) { + if (seen.has(cur)) break + seen.add(cur) + for (const candidate of candidatesAt(cur)) { + try { + const s = await fs.stat(candidate) + if (s.isDirectory() && !roots.includes(candidate)) roots.push(candidate) + } catch { /* not present */ } } + const parent = resolvePath(cur, "..") + if (parent === cur) break + cur = parent } - const parent = resolvePath(cur, "..") - if (parent === cur) break - cur = parent } + + // Walk from the caller-supplied root (or cwd) — covers the workspace root. + await walkUp(start ?? process.cwd()) + // Also walk from this file's location so pnpm-linked adapters in + // packages/cli/node_modules/@agentproto/ are found regardless of cwd. + // Resolves correctly whether running from dist (node file.mjs) or ts-node. + try { + await walkUp(dirname(fileURLToPath(import.meta.url))) + } catch { /* ESM not available in this context */ } + return roots } + +// ── catalog-aware lister ───────────────────────────────────────────────────── + +/** Minimal catalog shape consumed by `listAdaptersWithCatalog`. */ +export interface CatalogEntry { + slug: string + name: string + description: string + packageName: string + hint?: string +} + +/** + * Enumerate adapters starting from a static catalog and enriching each entry + * with its runtime availability status: + * + * "supported" — known to agentproto, package not importable (not installed) + * "available" — package resolves; setup ledger absent or adapter has no setup + * "ready" — package resolves + setup ledger present + * + * Also appends any adapters discovered by `listInstalledAdapters` that aren't + * in the catalog, so locally-installed custom adapters still appear. + * + * This replaces `listInstalledAdapters` as the source for `list_adapters` so + * the MCP tool always returns the supported set — not just what happens to be + * discoverable from the daemon's node_modules at that moment. + */ +export async function listAdaptersWithCatalog( + catalog: readonly CatalogEntry[] +): Promise<(AdapterInfo & { status: "supported" | "available" | "ready"; hint?: string })[]> { + const seenSlugs = new Set() + const out: (AdapterInfo & { status: "supported" | "available" | "ready"; hint?: string })[] = [] + + const agentprotoHome = process.env["AGENTPROTO_HOME"] ?? join(homedir(), ".agentproto") + + async function hasSetupLedger(slug: string): Promise { + try { + await fs.access(join(agentprotoHome, "setup", `${slug}.json`)) + return true + } catch { + return false + } + } + + // Process catalog entries first (preserves catalog order for known adapters). + for (const entry of catalog) { + seenSlugs.add(entry.slug) + try { + const resolved = await resolveAdapter(entry.slug) + const handle = resolved.handle as Record + const setupSteps = Array.isArray((handle as { setup?: unknown[] }).setup) + ? (handle as { setup: unknown[] }).setup + : [] + const ledgerPresent = await hasSetupLedger(entry.slug) + const status: "available" | "ready" = + setupSteps.length === 0 || ledgerPresent ? "ready" : "available" + const catalogModels = (handle.models as { allowed?: unknown } | undefined)?.allowed + out.push({ + slug: entry.slug, + name: typeof handle.name === "string" ? handle.name : entry.name, + version: typeof handle.version === "string" ? handle.version : "?", + description: + typeof handle.description === "string" ? handle.description : entry.description, + protocol: typeof handle.protocol === "string" ? handle.protocol : "unknown", + streaming: !!(handle.capabilities as { streaming?: boolean })?.streaming, + packageName: resolved.packageName ?? entry.packageName, + commands: Array.isArray(handle.commands) ? (handle.commands as AgentCliCommand[]) : [], + models: Array.isArray(catalogModels) + ? (catalogModels as unknown[]).filter((m): m is string => typeof m === "string") + : [], + status, + hint: entry.hint, + }) + } catch { + // Package not importable — show as "supported" (known but not installed). + out.push({ + slug: entry.slug, + name: entry.name, + version: "not installed", + description: entry.description, + protocol: "unknown", + streaming: false, + packageName: entry.packageName, + commands: [], + models: [], + status: "supported", + hint: entry.hint, + }) + } + } + + // Append any installed adapters not in the catalog (custom / third-party). + const installed = await listInstalledAdapters() + for (const info of installed) { + if (seenSlugs.has(info.slug)) continue + seenSlugs.add(info.slug) + const ledgerPresent = await hasSetupLedger(info.slug) + out.push({ ...info, status: ledgerPresent ? "ready" : "available" }) + } + + return out +} diff --git a/packages/cli/tsup.config.ts b/packages/cli/tsup.config.ts index 439a151c5f..1a5e0ecd5b 100644 --- a/packages/cli/tsup.config.ts +++ b/packages/cli/tsup.config.ts @@ -34,6 +34,7 @@ export default createTsupConfig({ }, external: [ "@agentproto/acp", + "@agentproto/driver", "@agentproto/driver-agent-cli", // Third-party deps — externalised so the published cli installs // them via npm at runtime. `gray-matter` is CJS + does dynamic diff --git a/packages/driver/core/package.json b/packages/driver/core/package.json index d47a5f0a63..98adfa05af 100644 --- a/packages/driver/core/package.json +++ b/packages/driver/core/package.json @@ -57,6 +57,7 @@ }, "dependencies": { "@agentproto/define-doctype": "workspace:*", + "@agentproto/manifest": "workspace:*", "@agentproto/tool": "workspace:*", "gray-matter": "^4.0.3", "zod": "^4.4.3" diff --git a/packages/driver/core/src/__tests__/spec.test.ts b/packages/driver/core/src/__tests__/spec.test.ts new file mode 100644 index 0000000000..8f46449de8 --- /dev/null +++ b/packages/driver/core/src/__tests__/spec.test.ts @@ -0,0 +1,298 @@ +import { describe, it, expect } from "vitest" +import { mkdtempSync, readFileSync, rmSync } from "node:fs" +import { tmpdir } from "node:os" +import { join } from "node:path" +import { driverSpec, driverVerbs } from "../spec.js" + +// ── helpers ─────────────────────────────────────────────────────────────── + +function tmpWorkspace(): string { + return mkdtempSync(join(tmpdir(), "agentproto-driver-spec-")) +} + +// ── driverSpec shape ───────────────────────────────────────────────────── + +describe("driverSpec — identity fields", () => { + it("has the expected name / aip / schemaLiteral", () => { + expect(driverSpec.name).toBe("driver") + expect(driverSpec.aip).toBe(30) + expect(driverSpec.schemaLiteral).toBe("agentproto/driver/v1") + }) + + it("pathOf derives /DRIVER.md", () => { + // driverSpec.pathOf receives a DriverHandle; fabricate one via define. + const handle = driverSpec.define({ + id: "gh-cli", + name: "GitHub CLI", + description: "Drives gh CLI.", + kind: "cli", + implements: [{ tool: "list-prs", version: "^1.0.0" }], + }) + expect(driverSpec.pathOf(handle)).toBe("gh-cli/DRIVER.md") + }) +}) + +// ── driverSpec.define — stub inject (D3) ───────────────────────────────── + +describe("driverSpec.define — stub execute injection (D3)", () => { + it("succeeds without execute bodies and injects stubs", () => { + const handle = driverSpec.define({ + id: "my-driver", + name: "My Driver", + description: "A driver without bodies.", + kind: "http", + implements: [{ tool: "my-tool", version: "^1.0.0" }], + }) + expect(handle.id).toBe("my-driver") + expect(typeof handle.execute["my-tool"]).toBe("function") + expect(() => handle.execute["my-tool"]?.({ input: {}, context: {} as never, driverCtx: {} as never, signal: new AbortController().signal })).toThrow( + /stub: no execute body for 'my-tool'/, + ) + }) + + it("bypasses stub injection when execute is provided", () => { + const real = async () => ({ ok: true }) + const handle = driverSpec.define({ + id: "my-driver-2", + name: "My Driver 2", + description: "A driver with real bodies.", + kind: "sdk", + implements: [{ tool: "my-tool", version: "^1.0.0" }], + execute: { "my-tool": real }, + }) + expect(handle.execute["my-tool"]).toBe(real) + }) + + it("normalizes path-style tool refs when injecting stubs (D4)", () => { + const handle = driverSpec.define({ + id: "path-driver", + name: "Path Driver", + description: "Tool ref as a path.", + kind: "cli", + implements: [{ tool: "./tools/image-create/TOOL.md", version: "^1.0.0" }], + }) + // normalizeToolId strips the path decoration → "image-create" + expect(typeof handle.execute["image-create"]).toBe("function") + }) +}) + +// ── round-trip: create → load → list → delete ──────────────────────────── + +describe("driverVerbs — create → load → list → delete round-trip", () => { + it("writes a DRIVER.md and reloads the same handle", async () => { + const workspace = tmpWorkspace() + try { + const created = await driverVerbs.create( + { + id: "openai-images-http", + name: "OpenAI Images (HTTP)", + description: + "Image generation via the OpenAI HTTP API. Implements image.create.", + version: "1.0.0", + kind: "http", + implements: [ + { + tool: "./tools/image-create/TOOL.md", + version: "^1.0.0", + schemaNarrowing: { dropInputs: ["seed", "negative_prompt"] }, + }, + ], + policyTags: ["third-party-llm", "us-data-residency"], + network: { egress: ["api.openai.com"] }, + region: ["global"], + tags: ["openai"], + }, + { dir: workspace }, + ) + + // Path convention: /DRIVER.md + expect(created.path).toBe( + join(workspace, "openai-images-http", "DRIVER.md"), + ) + + // The on-disk file must be valid YAML with snake_case keys. + const raw = readFileSync(created.path, "utf8") + expect(raw).toContain("schema: agentproto/driver/v1") + expect(raw).toContain("policy_tags:") + expect(raw).not.toContain("policyTags:") + expect(raw).toContain("schema_narrowing:") + expect(raw).not.toContain("schemaNarrowing:") + expect(raw).toContain("drop_inputs:") + expect(raw).not.toContain("dropInputs:") + + // load() must round-trip back to camelCase DriverHandle. + const loaded = await driverVerbs.load(created.path) + expect(loaded.handle.id).toBe("openai-images-http") + expect(loaded.handle.kind).toBe("http") + expect(loaded.handle.policyTags).toEqual([ + "third-party-llm", + "us-data-residency", + ]) + expect(loaded.handle.implements[0]?.schemaNarrowing?.dropInputs).toEqual( + ["seed", "negative_prompt"], + ) + expect(loaded.handle.network.egress).toEqual(["api.openai.com"]) + expect(loaded.handle.tags).toEqual(["openai"]) + } finally { + rmSync(workspace, { recursive: true, force: true }) + } + }) + + it("list() discovers DRIVER.md files under a workspace", async () => { + const workspace = tmpWorkspace() + try { + await driverVerbs.create( + { + id: "driver-a", + name: "Driver A", + description: "First driver.", + kind: "cli", + implements: [{ tool: "tool-a", version: "^1.0.0" }], + }, + { dir: workspace }, + ) + await driverVerbs.create( + { + id: "driver-b", + name: "Driver B", + description: "Second driver.", + kind: "http", + implements: [{ tool: "tool-b", version: "^1.0.0" }], + }, + { dir: workspace }, + ) + + const handles = await driverVerbs.list(workspace) + const ids = handles.map((h) => h.id).sort() + expect(ids).toEqual(["driver-a", "driver-b"]) + } finally { + rmSync(workspace, { recursive: true, force: true }) + } + }) + + it("delete() removes the DRIVER.md from disk", async () => { + const workspace = tmpWorkspace() + try { + const { path } = await driverVerbs.create( + { + id: "ephemeral", + name: "Ephemeral", + description: "Will be deleted.", + kind: "mcp", + implements: [{ tool: "tool-x", version: "^1.0.0" }], + }, + { dir: workspace }, + ) + await driverVerbs.delete(path) + const handles = await driverVerbs.list(workspace) + expect(handles).toHaveLength(0) + } finally { + rmSync(workspace, { recursive: true, force: true }) + } + }) +}) + +// ── snake↔camel round-trip coverage ────────────────────────────────────── + +describe("driverSpec — snake↔camel round-trip fidelity", () => { + it("policy_tags survives create → raw YAML → load intact", async () => { + const workspace = tmpWorkspace() + try { + await driverVerbs.create( + { + id: "policy-driver", + name: "Policy Driver", + description: "Verify policy_tags mapping.", + kind: "sdk", + implements: [{ tool: "t", version: "^1.0.0" }], + policyTags: ["pii-safe", "self-hosted"], + }, + { dir: workspace }, + ) + const raw = readFileSync( + join(workspace, "policy-driver", "DRIVER.md"), + "utf8", + ) + expect(raw).toContain("policy_tags:") + expect(raw).toContain("- pii-safe") + expect(raw).toContain("- self-hosted") + + const { handle } = await driverVerbs.load( + join(workspace, "policy-driver", "DRIVER.md"), + ) + expect(handle.policyTags).toEqual(["pii-safe", "self-hosted"]) + } finally { + rmSync(workspace, { recursive: true, force: true }) + } + }) + + it("implements[].schema_narrowing.drop_inputs survives round-trip", async () => { + const workspace = tmpWorkspace() + try { + await driverVerbs.create( + { + id: "narrowing-driver", + name: "Narrowing Driver", + description: "Verify schema_narrowing mapping.", + kind: "http", + implements: [ + { + tool: "image.create", + version: "^1.0.0", + schemaNarrowing: { + dropInputs: ["seed", "cfg_scale"], + dropOutputs: ["nsfw_score"], + }, + }, + ], + }, + { dir: workspace }, + ) + + const raw = readFileSync( + join(workspace, "narrowing-driver", "DRIVER.md"), + "utf8", + ) + expect(raw).toContain("schema_narrowing:") + expect(raw).toContain("drop_inputs:") + expect(raw).toContain("- seed") + expect(raw).toContain("drop_outputs:") + expect(raw).toContain("- nsfw_score") + + const { handle } = await driverVerbs.load( + join(workspace, "narrowing-driver", "DRIVER.md"), + ) + expect(handle.implements[0]?.schemaNarrowing?.dropInputs).toEqual([ + "seed", + "cfg_scale", + ]) + expect(handle.implements[0]?.schemaNarrowing?.dropOutputs).toEqual([ + "nsfw_score", + ]) + } finally { + rmSync(workspace, { recursive: true, force: true }) + } + }) + + it("dryRun: create returns rendered without writing to disk", async () => { + const workspace = tmpWorkspace() + try { + const { rendered } = await driverVerbs.create( + { + id: "dry-driver", + name: "Dry Driver", + description: "Dry run only.", + kind: "builtin", + implements: [{ tool: "noop", version: "^1.0.0" }], + }, + { dir: workspace, dryRun: true }, + ) + expect(rendered).toContain("schema: agentproto/driver/v1") + // Nothing written to disk. + const handles = await driverVerbs.list(workspace) + expect(handles).toHaveLength(0) + } finally { + rmSync(workspace, { recursive: true, force: true }) + } + }) +}) diff --git a/packages/driver/core/src/index.ts b/packages/driver/core/src/index.ts index 645e383d1e..ca212a96d9 100644 --- a/packages/driver/core/src/index.ts +++ b/packages/driver/core/src/index.ts @@ -47,3 +47,5 @@ export type { } from "./types.js" export type { DriverAvailability } from "./resolver.js" + +export { driverSpec, driverVerbs } from "./spec.js" diff --git a/packages/driver/core/src/spec.ts b/packages/driver/core/src/spec.ts new file mode 100644 index 0000000000..fc2618b981 --- /dev/null +++ b/packages/driver/core/src/spec.ts @@ -0,0 +1,167 @@ +/** + * AIP-30 doctype spec — fed to `@agentproto/manifest.createVerbs` + * to derive create / load / list / update / resolve / delete in one + * place, mirroring the pattern in `@agentproto/tool/src/spec.ts`. + * + * The spec bridges two naming conventions: + * - DRIVER.md frontmatter uses snake_case (policy_tags, schema_narrowing, …) + * - DriverDefinition / DriverHandle use camelCase (policyTags, schemaNarrowing, …) + * + * `parse()` converts snake → camel so `createVerbs.load/list` hand a + * proper `DriverDefinition` to `defineDriver`. + * + * `toFrontmatter()` converts camel → snake so `createVerbs.create/update` + * write valid DRIVER.md files. Only the universal AIP-30 fields are mapped; + * install.* is intentionally omitted until AIP-29 install shapes are stable. + * + * `define()` injects stub execute bodies (D3) when neither `execute` nor + * `implementations` are present, so file-system ops work without a TS + * dispatch module alongside the DRIVER.md. + */ + +import { createVerbs, type DoctypeSpec } from "@agentproto/manifest" +import { defineDriver, normalizeToolId } from "./define-provider.js" +import { parseDriverManifest } from "./manifest/index.js" +import type { DriverDefinition, DriverHandle, ExecuteFn } from "./types.js" + +export const driverSpec: DoctypeSpec = { + name: "driver", + aip: 30, + schemaLiteral: "agentproto/driver/v1", + + pathOf: (h) => `${h.id}/DRIVER.md`, + + define: (params: DriverDefinition): DriverHandle => { + if (!params.execute && !params.implementations) { + const stubs: Record = {} + for (const entry of params.implements ?? []) { + const id = normalizeToolId(entry.tool) + stubs[id] = (): never => { + throw new Error( + `stub: no execute body for '${id}' — ` + + `use driverFromManifest({ manifest, execute }) for dispatch`, + ) + } + } + return defineDriver({ ...params, execute: stubs }) + } + return defineDriver(params) + }, + + parse: (source: string) => { + const m = parseDriverManifest(source) + const fm = m.frontmatter + + const def: DriverDefinition = { + id: fm.id, + name: fm.name, + description: fm.description, + kind: fm.kind, + ...(fm.version !== undefined && { version: fm.version }), + implements: fm.implements.map((entry) => ({ + tool: entry.tool, + version: entry.version, + ...(entry.schema_narrowing && { + schemaNarrowing: { + ...(entry.schema_narrowing.drop_inputs?.length && { + dropInputs: entry.schema_narrowing.drop_inputs, + }), + ...(entry.schema_narrowing.drop_outputs?.length && { + dropOutputs: entry.schema_narrowing.drop_outputs, + }), + }, + }), + ...(entry.mapping && { mapping: entry.mapping }), + ...(entry.cost_override !== undefined && { + costOverride: entry.cost_override as DriverDefinition["costOverride"], + }), + ...(entry.timeout_override_ms !== undefined && { + timeoutOverrideMs: entry.timeout_override_ms, + }), + ...(entry.retry_override !== undefined && { + retryOverride: entry.retry_override as DriverDefinition["retryOverride"], + }), + ...(entry.metadata && { metadata: entry.metadata }), + })), + ...(fm.auth !== undefined && { + auth: fm.auth as DriverDefinition["auth"], + }), + ...(fm.network && { network: fm.network }), + ...(fm.region?.length && { region: fm.region }), + ...(fm.policy_tags?.length && { policyTags: fm.policy_tags }), + ...(fm.cost_override !== undefined && { + costOverride: fm.cost_override as DriverDefinition["costOverride"], + }), + ...(fm.timeout_override_ms !== undefined && { + timeoutOverrideMs: fm.timeout_override_ms, + }), + ...(fm.retry_override !== undefined && { + retryOverride: fm.retry_override as DriverDefinition["retryOverride"], + }), + ...(fm.health_check !== undefined && { + healthCheck: fm.health_check as DriverDefinition["healthCheck"], + }), + ...(fm.version_check !== undefined && { + versionCheck: fm.version_check as DriverDefinition["versionCheck"], + }), + ...(fm.install?.length && { + install: fm.install as DriverDefinition["install"], + }), + ...(fm.tags?.length && { tags: fm.tags }), + ...(fm.metadata && { metadata: fm.metadata }), + } + + return { + frontmatter: def as unknown as Record, + body: m.body, + } + }, + + toFrontmatter: (params: DriverDefinition): Record => { + const fm: Record = { + schema: "agentproto/driver/v1", + id: params.id, + name: params.name, + description: params.description, + } + if (params.version !== undefined) fm.version = params.version + fm.kind = params.kind + fm.implements = (params.implements ?? []).map((entry) => { + const e: Record = { + tool: entry.tool, + version: entry.version, + } + if (entry.schemaNarrowing) { + const sn: Record = {} + if (entry.schemaNarrowing.dropInputs?.length) + sn.drop_inputs = [...entry.schemaNarrowing.dropInputs] + if (entry.schemaNarrowing.dropOutputs?.length) + sn.drop_outputs = [...entry.schemaNarrowing.dropOutputs] + e.schema_narrowing = sn + } + if (entry.mapping) e.mapping = entry.mapping + if (entry.costOverride) e.cost_override = entry.costOverride + if (entry.timeoutOverrideMs !== undefined) + e.timeout_override_ms = entry.timeoutOverrideMs + if (entry.retryOverride) e.retry_override = entry.retryOverride + if (entry.metadata) e.metadata = entry.metadata + return e + }) + if (params.auth) fm.auth = params.auth + if (params.network) fm.network = params.network + if (params.region?.length) fm.region = [...params.region] + if (params.policyTags?.length) fm.policy_tags = [...params.policyTags] + if (params.costOverride) fm.cost_override = params.costOverride + if (params.timeoutOverrideMs !== undefined) + fm.timeout_override_ms = params.timeoutOverrideMs + if (params.retryOverride) fm.retry_override = params.retryOverride + if (params.healthCheck) fm.health_check = params.healthCheck + if (params.versionCheck) fm.version_check = params.versionCheck + if (params.tags?.length) fm.tags = [...params.tags] + if (params.metadata && Object.keys(params.metadata).length > 0) + fm.metadata = { ...params.metadata } + return fm + }, +} + +export const driverVerbs = createVerbs(driverSpec) diff --git a/packages/driver/core/tsup.config.ts b/packages/driver/core/tsup.config.ts index ae46abcab6..d0e40726d6 100644 --- a/packages/driver/core/tsup.config.ts +++ b/packages/driver/core/tsup.config.ts @@ -17,6 +17,7 @@ export default createTsupConfig({ "gray-matter", "@agentproto/tool", "@agentproto/define-doctype", + "@agentproto/manifest", ], noExternal: [], }) From 6d901f801ec2d254acafb6e6982af5e0121f0c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 14:32:56 +0200 Subject: [PATCH 07/19] feat(agent): validate extends-chain depth/cycles and enforce on load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add validateExtendsChain (AIP-42: max depth 5, cycle detection) - Add loadAgent — resolves AGENT.md from disk, validates the chain before returning {handle, body}; callers no longer need parseAgentManifest + agentFromManifest - Re-export loadAgent + validateExtendsChain from @agentproto/agent index - defineAgent: widen extendsChain field type to full AgentManifest[] for runtime use Co-Authored-By: Claude Sonnet 4.6 --- .../agent/src/__tests__/load-agent.test.ts | 219 ++++++++++++++++++ .../__tests__/validate-extends-chain.test.ts | 117 ++++++++++ packages/agent/src/define-agent.ts | 8 +- packages/agent/src/index.ts | 7 + packages/agent/src/load-agent.ts | 59 +++++ packages/agent/src/validate-extends-chain.ts | 91 ++++++++ 6 files changed, 498 insertions(+), 3 deletions(-) create mode 100644 packages/agent/src/__tests__/load-agent.test.ts create mode 100644 packages/agent/src/__tests__/validate-extends-chain.test.ts create mode 100644 packages/agent/src/load-agent.ts create mode 100644 packages/agent/src/validate-extends-chain.ts diff --git a/packages/agent/src/__tests__/load-agent.test.ts b/packages/agent/src/__tests__/load-agent.test.ts new file mode 100644 index 0000000000..17697f501e --- /dev/null +++ b/packages/agent/src/__tests__/load-agent.test.ts @@ -0,0 +1,219 @@ +import { describe, it, expect } from "vitest" +import { mkdtemp, mkdir, writeFile, rm } from "node:fs/promises" +import { join } from "node:path" +import { tmpdir } from "node:os" +import { loadAgent } from "../load-agent.js" +import { EXTENDS_MAX_DEPTH } from "../validate-extends-chain.js" + +/** Write a minimal valid AGENT.md to `dir//AGENT.md`. */ +async function writeAgentMd( + workspace: string, + id: string, + extra: Record = {}, +): Promise { + const dir = join(workspace, ".agents", id) + await mkdir(dir, { recursive: true }) + const extendsLine = extra.extends ? `extends: ${extra.extends}` : "" + const source = [ + "---", + "schema: agent/v1", + `id: ${id}`, + `description: Agent ${id} for testing`, + "model: test-model", + extendsLine, + "---", + "", + `You are agent ${id}.`, + ] + .filter((l) => l !== "") + .join("\n") + "\n" + const path = join(dir, "AGENT.md") + await writeFile(path, source, "utf8") + return path +} + +describe("loadAgent (AIP-42 extends-chain validation)", () => { + it("loads a simple agent with no extends", async () => { + const workspace = await mkdtemp(join(tmpdir(), "agentproto-load-agent-")) + try { + const path = await writeAgentMd(workspace, "simple") + const { handle } = await loadAgent(path, { workspace }) + expect(handle.id).toBe("simple") + } finally { + await rm(workspace, { recursive: true, force: true }) + } + }) + + it("loads an agent with a valid single-level extends", async () => { + const workspace = await mkdtemp(join(tmpdir(), "agentproto-load-agent-")) + try { + await writeAgentMd(workspace, "parent") + const childPath = await writeAgentMd(workspace, "child", { + extends: "parent", + }) + const { handle } = await loadAgent(childPath, { workspace }) + expect(handle.id).toBe("child") + } finally { + await rm(workspace, { recursive: true, force: true }) + } + }) + + it(`loads an agent with exactly ${EXTENDS_MAX_DEPTH} extends hops (max allowed)`, async () => { + const workspace = await mkdtemp(join(tmpdir(), "agentproto-load-agent-")) + try { + // a0 → a1 → … → a5 (5 hops = EXTENDS_MAX_DEPTH) + for (let i = 1; i <= EXTENDS_MAX_DEPTH; i++) { + await writeAgentMd(workspace, `a${i}`) + } + // Build the chain backwards so each parent exists before child + for (let i = EXTENDS_MAX_DEPTH - 1; i >= 1; i--) { + await rm(join(workspace, ".agents", `a${i}`, "AGENT.md")) + await writeAgentMd(workspace, `a${i}`, { extends: `a${i + 1}` }) + } + const rootPath = await writeAgentMd(workspace, "a0", { extends: "a1" }) + await expect(loadAgent(rootPath, { workspace })).resolves.toMatchObject({ + handle: { id: "a0" }, + }) + } finally { + await rm(workspace, { recursive: true, force: true }) + } + }) + + it(`rejects a chain of depth ${EXTENDS_MAX_DEPTH + 1} (one beyond the limit)`, async () => { + const workspace = await mkdtemp(join(tmpdir(), "agentproto-load-agent-")) + try { + // a0 → a1 → … → a6 (6 hops, exceeds limit of 5) + const OVER = EXTENDS_MAX_DEPTH + 1 + for (let i = 1; i <= OVER; i++) { + await writeAgentMd(workspace, `a${i}`) + } + for (let i = OVER - 1; i >= 1; i--) { + await rm(join(workspace, ".agents", `a${i}`, "AGENT.md")) + await writeAgentMd(workspace, `a${i}`, { extends: `a${i + 1}` }) + } + const rootPath = await writeAgentMd(workspace, "a0", { extends: "a1" }) + await expect(loadAgent(rootPath, { workspace })).rejects.toThrow( + "exceeds maximum depth", + ) + } finally { + await rm(workspace, { recursive: true, force: true }) + } + }) + + it("rejects a direct cycle A → B → A", async () => { + const workspace = await mkdtemp(join(tmpdir(), "agentproto-load-agent-")) + try { + await writeAgentMd(workspace, "agent-b", { extends: "agent-a" }) + const pathA = await writeAgentMd(workspace, "agent-a", { + extends: "agent-b", + }) + await expect(loadAgent(pathA, { workspace })).rejects.toThrow( + "circular extends chain", + ) + } finally { + await rm(workspace, { recursive: true, force: true }) + } + }) + + it("rejects a longer cycle A → B → C → A", async () => { + const workspace = await mkdtemp(join(tmpdir(), "agentproto-load-agent-")) + try { + await writeAgentMd(workspace, "cc", { extends: "aa" }) + await writeAgentMd(workspace, "bb", { extends: "cc" }) + const pathA = await writeAgentMd(workspace, "aa", { extends: "bb" }) + await expect(loadAgent(pathA, { workspace })).rejects.toThrow( + "circular extends chain", + ) + } finally { + await rm(workspace, { recursive: true, force: true }) + } + }) + + it("stops gracefully when a parent ref cannot be resolved (unresolvable = chain end)", async () => { + const workspace = await mkdtemp(join(tmpdir(), "agentproto-load-agent-")) + try { + const path = await writeAgentMd(workspace, "orphan", { + extends: "missing-parent", + }) + // No error — unresolvable refs are treated as chain ends per spec + await expect(loadAgent(path, { workspace })).resolves.toMatchObject({ + handle: { id: "orphan" }, + }) + } finally { + await rm(workspace, { recursive: true, force: true }) + } + }) + + it("infers workspace from path when opts.workspace is not provided", async () => { + const workspace = await mkdtemp(join(tmpdir(), "agentproto-load-agent-")) + try { + // Path is absolute and follows standard layout — no explicit workspace needed + const path = await writeAgentMd(workspace, "inferred") + await expect(loadAgent(path)).resolves.toMatchObject({ + handle: { id: "inferred" }, + }) + } finally { + await rm(workspace, { recursive: true, force: true }) + } + }) + + describe("execution-path contract (gateway buildAgent pattern)", () => { + // Verifies that a buildAgent-style function — i.e. the pattern used in + // playground/scripts/gateway.ts — rejects an agent with an invalid extends + // chain BEFORE any agent logic runs, satisfying AIP-42 T2c. + async function buildAgentForExecution( + agentId: string, + workspace: string, + ): Promise<{ handle: { id: string } }> { + const manifestPath = join(workspace, ".agents", agentId, "AGENT.md") + const { handle } = await loadAgent(manifestPath, { workspace }) + return { handle } + } + + it("rejects execution of an agent with a cyclic extends chain", async () => { + const workspace = await mkdtemp(join(tmpdir(), "agentproto-exec-cycle-")) + try { + await writeAgentMd(workspace, "beta", { extends: "alpha" }) + await writeAgentMd(workspace, "alpha", { extends: "beta" }) + await expect(buildAgentForExecution("alpha", workspace)).rejects.toThrow( + "circular extends chain", + ) + } finally { + await rm(workspace, { recursive: true, force: true }) + } + }) + + it("rejects execution of an agent whose extends chain exceeds max depth", async () => { + const workspace = await mkdtemp(join(tmpdir(), "agentproto-exec-depth-")) + try { + const OVER = EXTENDS_MAX_DEPTH + 1 + for (let i = 1; i <= OVER; i++) { + await writeAgentMd(workspace, `d${i}`) + } + for (let i = OVER - 1; i >= 1; i--) { + await rm(join(workspace, ".agents", `d${i}`, "AGENT.md")) + await writeAgentMd(workspace, `d${i}`, { extends: `d${i + 1}` }) + } + await writeAgentMd(workspace, "d0", { extends: "d1" }) + await expect(buildAgentForExecution("d0", workspace)).rejects.toThrow( + "exceeds maximum depth", + ) + } finally { + await rm(workspace, { recursive: true, force: true }) + } + }) + + it("allows execution of an agent with a valid extends chain", async () => { + const workspace = await mkdtemp(join(tmpdir(), "agentproto-exec-valid-")) + try { + await writeAgentMd(workspace, "parent") + await writeAgentMd(workspace, "child", { extends: "parent" }) + await expect(buildAgentForExecution("child", workspace)).resolves.toMatchObject({ + handle: { id: "child" }, + }) + } finally { + await rm(workspace, { recursive: true, force: true }) + } + }) + }) +}) diff --git a/packages/agent/src/__tests__/validate-extends-chain.test.ts b/packages/agent/src/__tests__/validate-extends-chain.test.ts new file mode 100644 index 0000000000..43ecc0ac2e --- /dev/null +++ b/packages/agent/src/__tests__/validate-extends-chain.test.ts @@ -0,0 +1,117 @@ +import { describe, it, expect } from "vitest" +import { + validateExtendsChain, + EXTENDS_MAX_DEPTH, + type ExtendsChainLoader, + type ExtendsRef, +} from "../validate-extends-chain.js" + +type MinAgent = { id: string; extends?: ExtendsRef | null } + +/** Build a loader backed by an in-memory registry — no file I/O needed. */ +function makeLoader(registry: Record): ExtendsChainLoader { + return { + async loadParent(ref) { + const key = + typeof ref === "string" + ? ref + : typeof ref === "object" && "ref" in ref && typeof ref.ref === "string" + ? ref.ref + : null + if (key === null) return null + return registry[key] ?? null + }, + } +} + +describe("validateExtendsChain (AIP-42)", () => { + it("resolves when there is no parent", async () => { + await expect( + validateExtendsChain({ id: "base" }, makeLoader({})), + ).resolves.toBeUndefined() + }) + + it("resolves for a chain of exactly 1 level", async () => { + const loader = makeLoader({ parent: { id: "parent" } }) + await expect( + validateExtendsChain({ id: "child", extends: "parent" }, loader), + ).resolves.toBeUndefined() + }) + + it(`resolves for a chain of exactly ${EXTENDS_MAX_DEPTH} levels`, async () => { + // a0 → a1 → … → a5 (5 hops = max allowed) + const registry: Record = {} + for (let i = 1; i < EXTENDS_MAX_DEPTH; i++) { + registry[`a${i}`] = { id: `a${i}`, extends: `a${i + 1}` } + } + registry[`a${EXTENDS_MAX_DEPTH}`] = { id: `a${EXTENDS_MAX_DEPTH}` } + await expect( + validateExtendsChain({ id: "a0", extends: "a1" }, makeLoader(registry)), + ).resolves.toBeUndefined() + }) + + it(`rejects a chain of depth ${EXTENDS_MAX_DEPTH + 1} (one beyond the limit)`, async () => { + // a0 → a1 → … → a6 (6 hops, exceeds max of 5) + const registry: Record = {} + for (let i = 1; i <= EXTENDS_MAX_DEPTH; i++) { + registry[`a${i}`] = { id: `a${i}`, extends: `a${i + 1}` } + } + registry[`a${EXTENDS_MAX_DEPTH + 1}`] = { id: `a${EXTENDS_MAX_DEPTH + 1}` } + await expect( + validateExtendsChain({ id: "a0", extends: "a1" }, makeLoader(registry)), + ).rejects.toThrow("exceeds maximum depth") + }) + + it("rejects a direct cycle A → B → A", async () => { + const registry: Record = { + b: { id: "b", extends: "a" }, + // 'a' must be resolvable so the loader returns it for the cycle check + a: { id: "a", extends: "b" }, + } + await expect( + validateExtendsChain({ id: "a", extends: "b" }, makeLoader(registry)), + ).rejects.toThrow("circular extends chain") + }) + + it("rejects a longer cycle A → B → C → A", async () => { + const registry: Record = { + b: { id: "b", extends: "c" }, + c: { id: "c", extends: "a" }, + a: { id: "a", extends: "b" }, + } + await expect( + validateExtendsChain({ id: "a", extends: "b" }, makeLoader(registry)), + ).rejects.toThrow("circular extends chain") + }) + + it("stops traversal at an inline block and does not throw", async () => { + // Inline refs have no external id — they cannot form registry cycles. + await expect( + validateExtendsChain( + { id: "child", extends: { inline: { id: "inlined", description: "inlined parent" } } }, + makeLoader({}), + ), + ).resolves.toBeUndefined() + }) + + it("stops gracefully when a ref cannot be resolved (chain end)", async () => { + // The loader returns null for unknown refs — not an error. + await expect( + validateExtendsChain( + { id: "child", extends: "unknown-parent" }, + makeLoader({}), + ), + ).resolves.toBeUndefined() + }) + + it("error messages carry the defineAgent (AIP-42) prefix", async () => { + const registry: Record = {} + for (let i = 1; i <= EXTENDS_MAX_DEPTH; i++) { + registry[`a${i}`] = { id: `a${i}`, extends: `a${i + 1}` } + } + registry[`a${EXTENDS_MAX_DEPTH + 1}`] = { id: `a${EXTENDS_MAX_DEPTH + 1}` } + await expect( + validateExtendsChain({ id: "a0", extends: "a1" }, makeLoader(registry)), + ).rejects.toThrow("defineAgent (AIP-42):") + }) +}) diff --git a/packages/agent/src/define-agent.ts b/packages/agent/src/define-agent.ts index 4d40787043..c878847d09 100644 --- a/packages/agent/src/define-agent.ts +++ b/packages/agent/src/define-agent.ts @@ -30,9 +30,11 @@ export const defineAgent = createDoctype({ .join("; ")}`, ) } - // TODO: spec-42-specific cross-field rules (if/then/allOf in - // the JSON Schema) — those don't translate to zod cleanly and - // belong here. See @agentproto/operator's autonomy=gated rule. + // Extends-chain depth (≤5) and cycle checks require loading parent + // manifests and are therefore async. Call `validateExtendsChain` + // (exported from this package) in any context with file/registry + // access before running the agent. Other cross-field rules (e.g. + // autonomy=gated patterns from @agentproto/operator) go here. }, build(def) { // Default build: spread the validated definition into a fresh object. diff --git a/packages/agent/src/index.ts b/packages/agent/src/index.ts index e17bf7281d..d8c8fddbeb 100644 --- a/packages/agent/src/index.ts +++ b/packages/agent/src/index.ts @@ -14,6 +14,13 @@ export const SPEC_NAME = "agentagent/v1" as const export const SPEC_VERSION = "1.0.0-alpha" as const export { defineAgent } from "./define-agent.js" +export { loadAgent } from "./load-agent.js" +export { + validateExtendsChain, + EXTENDS_MAX_DEPTH, + type ExtendsRef, + type ExtendsChainLoader, +} from "./validate-extends-chain.js" export type { AgentDefinition, AgentHandle, diff --git a/packages/agent/src/load-agent.ts b/packages/agent/src/load-agent.ts new file mode 100644 index 0000000000..958315faea --- /dev/null +++ b/packages/agent/src/load-agent.ts @@ -0,0 +1,59 @@ +/** + * AIP-42: async agent loader with extends-chain validation. + * + * `defineAgent` is synchronous and cannot run depth/cycle checks that + * require loading parent manifests from disk. `loadAgent` is the + * recommended async entry point that wraps `agentVerbs.load` with + * `validateExtendsChain` so every load site gets integrity checking + * without callers wiring it manually. + * + * Standard workspace layout assumed for workspace inference: + * /.agents//AGENT.md + * + * Pass `opts.workspace` explicitly when agents live elsewhere. + */ + +import { dirname, join, resolve as resolvePath } from "node:path" +import { agentVerbs } from "./spec.js" +import { validateExtendsChain } from "./validate-extends-chain.js" +import type { AgentHandle } from "./types.js" + +/** + * Load an agent manifest from disk and validate its `extends` chain + * (AIP-42: depth ≤ 5, no cycles). Throws before returning when a + * violation is detected so the agent never enters execution with a + * malformed inheritance chain. + * + * @param path Absolute path to the AGENT.md file. + * @param opts `workspace` — root directory containing `.agents/`. + * Derived from the standard path layout when omitted. + */ +export async function loadAgent( + path: string, + opts?: { workspace?: string }, +): Promise<{ path: string; handle: AgentHandle; body: string }> { + const result = await agentVerbs.load(path) + const { handle } = result + + if (handle.extends != null) { + const workspace = + opts?.workspace ?? + // Infer from /.agents//AGENT.md → go 3 dirs up. + dirname(dirname(dirname(resolvePath(path)))) + + await validateExtendsChain(handle, { + async loadParent(ref) { + if (typeof ref !== "string") return null + try { + const parentPath = join(workspace, ".agents", ref, "AGENT.md") + const { handle: parent } = await agentVerbs.load(parentPath) + return { id: parent.id, extends: parent.extends } + } catch { + return null + } + }, + }) + } + + return result +} diff --git a/packages/agent/src/validate-extends-chain.ts b/packages/agent/src/validate-extends-chain.ts new file mode 100644 index 0000000000..7eb44d0f8c --- /dev/null +++ b/packages/agent/src/validate-extends-chain.ts @@ -0,0 +1,91 @@ +/** + * AIP-42: extends-chain integrity validation. + * + * Spec constraints (AIP-42 §extends): + * - Depth ≤ 5 levels (5 extends hops from root) + * - No cycles (same `id` must not appear twice in the chain) + * + * Inline `extends` blocks carry no stable external `id` and cannot + * form registry-level cycles; the chain walk stops at the first one. + * + * This is intentionally a standalone async function rather than a + * hook inside `defineAgent` — chain validation requires loading parent + * manifests from disk or a registry, which is inherently async and + * unavailable in the synchronous `defineAgent` path. + * + * Usage with `agentVerbs`: + * + * await validateExtendsChain(handle, { + * async loadParent(ref) { + * if (typeof ref !== 'string') return null + * try { + * const { handle } = await agentVerbs.load(`.agents/${ref}/AGENT.md`) + * return { id: handle.id, extends: handle.extends } + * } catch { return null } + * }, + * }) + */ + +export const EXTENDS_MAX_DEPTH = 5 + +/** + * An `extends` reference from the AGENT.md frontmatter. + * Mirrors `AgentDefinition['extends']`. + */ +export type ExtendsRef = + | string + | { ref?: string; file?: string; inline?: Record } + +/** + * Load a parent agent's identity and `extends` field by ref. + * Return `null` when the ref cannot be resolved (treated as chain end, + * not an error — unresolvable refs are caught at runtime, not here). + */ +export interface ExtendsChainLoader { + loadParent( + ref: ExtendsRef, + ): Promise<{ id: string; extends?: ExtendsRef | null | undefined } | null> +} + +/** + * Validate an agent's `extends` chain for depth and cycle constraints. + * + * Throws with a `"defineAgent (AIP-42): …"` message on violation so + * the error is consistent with the synchronous `defineAgent` errors. + */ +export async function validateExtendsChain( + root: { id: string; extends?: ExtendsRef | null | undefined }, + loader: ExtendsChainLoader, +): Promise { + const visited = new Set([root.id]) + let current: { id: string; extends?: ExtendsRef | null | undefined } = root + let depth = 0 + + while (current.extends != null) { + const ref = current.extends + + // Inline blocks have no stable external id — stop traversal here. + if (typeof ref === "object" && "inline" in ref) break + + depth++ + if (depth > EXTENDS_MAX_DEPTH) { + throw new Error( + `defineAgent (AIP-42): extends chain exceeds maximum depth of ` + + `${EXTENDS_MAX_DEPTH} (chain starting from '${root.id}')`, + ) + } + + const parent = await loader.loadParent(ref) + if (parent === null) break + + if (visited.has(parent.id)) { + throw new Error( + `defineAgent (AIP-42): circular extends chain — '${parent.id}' ` + + `appears more than once in the chain starting from '${root.id}'`, + ) + } + + visited.add(parent.id) + current = parent + } +} From fbc2efc76530cdd41d737dfcc5fea51b5d366013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 14:33:08 +0200 Subject: [PATCH 08/19] feat(mcp-server): add self_inspect tool for agent introspection - New self_inspect MCP tool: reads the running server's own AGENT.md, resolves the extends-chain via @agentproto/agent loadAgent, and returns handle + body so an LLM can inspect the current agent's identity at runtime - Wire self-inspect-tool into the server index - Add @agentproto/agent + @agentproto/routine deps to mcp-server package.json - Export self-inspect entry in tsup.config.ts Co-Authored-By: Claude Sonnet 4.6 --- packages/mcp-server/package.json | 2 + .../src/__tests__/self-inspect.test.ts | 205 ++++++++++++++++++ packages/mcp-server/src/index.ts | 20 +- packages/mcp-server/src/self-inspect-tool.ts | 202 +++++++++++++++++ packages/mcp-server/tsup.config.ts | 3 + 5 files changed, 431 insertions(+), 1 deletion(-) create mode 100644 packages/mcp-server/src/__tests__/self-inspect.test.ts create mode 100644 packages/mcp-server/src/self-inspect-tool.ts diff --git a/packages/mcp-server/package.json b/packages/mcp-server/package.json index fe6f5916e4..9f1f138d7e 100644 --- a/packages/mcp-server/package.json +++ b/packages/mcp-server/package.json @@ -50,10 +50,12 @@ "prepublishOnly": "pnpm build" }, "dependencies": { + "@agentproto/agent": "workspace:*", "@agentproto/define-doctype": "workspace:*", "@agentproto/driver": "workspace:*", "@agentproto/extension": "workspace:*", "@agentproto/manifest": "workspace:*", + "@agentproto/routine": "workspace:*", "@agentproto/tool": "workspace:*", "@modelcontextprotocol/sdk": "^1.29.0", "zod": "^4.4.3" diff --git a/packages/mcp-server/src/__tests__/self-inspect.test.ts b/packages/mcp-server/src/__tests__/self-inspect.test.ts new file mode 100644 index 0000000000..05b8056a98 --- /dev/null +++ b/packages/mcp-server/src/__tests__/self-inspect.test.ts @@ -0,0 +1,205 @@ +import { describe, it, expect, afterEach } from "vitest" +import { mkdtempSync, rmSync } from "node:fs" +import { mkdir, writeFile } from "node:fs/promises" +import { tmpdir } from "node:os" +import { join } from "node:path" +import { selfInspect, summarizeToolRef, summarizeRoutineRef } from "../self-inspect-tool.js" + +// ── helpers ───────────────────────────────────────────────────────────────── + +function makeTmp(): string { + return mkdtempSync(join(tmpdir(), "agentproto-self-inspect-")) +} + +const AGENT_MD = (extra = "") => `--- +schema: agent/v1 +id: test-agent +description: Agent used for self_inspect unit tests. +model: anthropic/claude-haiku-4-5-20251001 +${extra}--- + +# Test Agent +` + +const TOOL_MD = `--- +schema: agentproto/tool/v1 +id: echo +name: Echo +description: Echoes its input back. +version: 1.0.0 +inputSchema: + type: object + properties: + text: + type: string +outputSchema: + type: object +--- + +# Echo +` + +const ROUTINE_MD = `--- +schema: routine/v1 +id: daily-ping +description: Fires the agent once a day. +version: 1.0.0 +schedule: + cron: "0 9 * * *" +target: + action: ping +--- + +# Daily Ping +` + +// ── summarizeToolRef ───────────────────────────────────────────────────────── + +describe("summarizeToolRef", () => { + it("surfaces string refs as-is", async () => { + const result = await summarizeToolRef("@agentik/tools-standard/web-fetch", "/workspace") + expect(result.id).toBe("@agentik/tools-standard/web-fetch") + }) + + it("loads file refs and extracts id + description", async () => { + const ws = makeTmp() + try { + await mkdir(join(ws, "tools", "echo"), { recursive: true }) + await writeFile(join(ws, "tools", "echo", "TOOL.md"), TOOL_MD) + + const result = await summarizeToolRef({ file: "tools/echo/TOOL.md" }, ws) + expect(result.id).toBe("echo") + expect(result.description).toBe("Echoes its input back.") + } finally { + rmSync(ws, { recursive: true, force: true }) + } + }) + + it("returns fallback when a file ref cannot be loaded", async () => { + const result = await summarizeToolRef({ file: "tools/missing/TOOL.md" }, "/nonexistent") + expect(result.id).toBe("tools/missing/TOOL.md") + expect(result.description).toContain("could not load") + }) + + it("uses inline params directly", async () => { + const result = await summarizeToolRef( + { inline: { id: "my-tool", description: "An inline tool." } }, + "/workspace", + ) + expect(result.id).toBe("my-tool") + expect(result.description).toBe("An inline tool.") + }) + + it("surfaces ref: strings as-is", async () => { + const result = await summarizeToolRef({ ref: "@scope/registry-tool" }, "/workspace") + expect(result.id).toBe("@scope/registry-tool") + expect(result.description).toContain("not locally resolved") + }) +}) + +// ── summarizeRoutineRef ────────────────────────────────────────────────────── + +describe("summarizeRoutineRef", () => { + it("loads file refs and extracts id + description", async () => { + const ws = makeTmp() + try { + await mkdir(join(ws, ".routines", "daily-ping"), { recursive: true }) + await writeFile(join(ws, ".routines", "daily-ping", "ROUTINE.md"), ROUTINE_MD) + + const result = await summarizeRoutineRef({ file: ".routines/daily-ping/ROUTINE.md" }, ws) + expect(result.id).toBe("daily-ping") + expect(result.description).toBe("Fires the agent once a day.") + } finally { + rmSync(ws, { recursive: true, force: true }) + } + }) +}) + +// ── selfInspect ────────────────────────────────────────────────────────────── + +describe("selfInspect", () => { + it("loads an AGENT.md with no tools or routines", async () => { + const ws = makeTmp() + try { + await mkdir(join(ws, ".agents", "test-agent"), { recursive: true }) + await writeFile(join(ws, ".agents", "test-agent", "AGENT.md"), AGENT_MD()) + + const result = await selfInspect("test-agent", ws) + + expect(result.agentPath).toBe(join(ws, ".agents", "test-agent", "AGENT.md")) + expect(result.tools).toEqual([]) + expect(result.routines).toEqual([]) + } finally { + rmSync(ws, { recursive: true, force: true }) + } + }) + + it("resolves a string tool ref", async () => { + const ws = makeTmp() + try { + await mkdir(join(ws, ".agents", "test-agent"), { recursive: true }) + await writeFile( + join(ws, ".agents", "test-agent", "AGENT.md"), + AGENT_MD('tools:\n - "@agentik/tools-standard/web-fetch"\n'), + ) + + const result = await selfInspect("test-agent", ws) + expect(result.tools).toHaveLength(1) + expect(result.tools[0]!.id).toBe("@agentik/tools-standard/web-fetch") + } finally { + rmSync(ws, { recursive: true, force: true }) + } + }) + + it("resolves a file: tool ref to id + description", async () => { + const ws = makeTmp() + try { + await mkdir(join(ws, ".agents", "test-agent"), { recursive: true }) + await mkdir(join(ws, "tools", "echo"), { recursive: true }) + await writeFile(join(ws, "tools", "echo", "TOOL.md"), TOOL_MD) + await writeFile( + join(ws, ".agents", "test-agent", "AGENT.md"), + AGENT_MD('tools:\n - file: tools/echo/TOOL.md\n'), + ) + + const result = await selfInspect("test-agent", ws) + expect(result.tools).toHaveLength(1) + expect(result.tools[0]).toEqual({ id: "echo", description: "Echoes its input back." }) + } finally { + rmSync(ws, { recursive: true, force: true }) + } + }) + + it("resolves a file: routine ref to id + description", async () => { + const ws = makeTmp() + try { + await mkdir(join(ws, ".agents", "test-agent"), { recursive: true }) + await mkdir(join(ws, ".routines", "daily-ping"), { recursive: true }) + await writeFile(join(ws, ".routines", "daily-ping", "ROUTINE.md"), ROUTINE_MD) + await writeFile( + join(ws, ".agents", "test-agent", "AGENT.md"), + AGENT_MD('routines:\n - file: .routines/daily-ping/ROUTINE.md\n'), + ) + + const result = await selfInspect("test-agent", ws) + expect(result.routines).toHaveLength(1) + expect(result.routines[0]).toEqual({ + id: "daily-ping", + description: "Fires the agent once a day.", + }) + } finally { + rmSync(ws, { recursive: true, force: true }) + } + }) + + it("throws with a clear message when the agent is not found", async () => { + const ws = makeTmp() + try { + await expect(selfInspect("ghost", ws)).rejects.toThrow( + /No AGENT\.md found for agent 'ghost'/, + ) + } finally { + rmSync(ws, { recursive: true, force: true }) + } + }) +}) diff --git a/packages/mcp-server/src/index.ts b/packages/mcp-server/src/index.ts index 48911b8385..5503c78489 100644 --- a/packages/mcp-server/src/index.ts +++ b/packages/mcp-server/src/index.ts @@ -26,6 +26,7 @@ import { parseExtensionManifest, specFromExtension, } from "@agentproto/extension" +import { registerSelfInspectTool } from "./self-inspect-tool.js" // `RegisterableSpec` is just `DoctypeSpec` plus the // constraint that callers passing different generics across the array @@ -92,6 +93,13 @@ export async function createMcpServer( registerVerbs(server, spec, anchor) } + // self_inspect: contextual tool injected when a workspace is provided so + // agents can query their own AIP-42 manifest by logical id — no disk path + // knowledge required. + if (opts.workspace) { + registerSelfInspectTool(server, { workspace: opts.workspace }) + } + return { server, registered: allSpecs.map((s) => s.name), @@ -117,6 +125,14 @@ export { type ToMcpToolOptions, type McpToolRegistration, } from "./to-mcp-tool.js" +export { + registerSelfInspectTool, + selfInspect, + summarizeToolRef, + summarizeRoutineRef, + type RefSummary, + type SelfInspectResult, +} from "./self-inspect-tool.js" // ── verb registration ─────────────────────────────────────────────── @@ -238,7 +254,9 @@ function registerVerbs( z.object({ ref: z.string() }), z.object({ file: z.string() }), ]) - .describe("The composition block."), + .describe( + 'The composition block. Exactly one of: { "inline": {...params} } | { "ref": "@scope/id" } | { "file": "relative/path.md" }. Omitting the wrapping key causes invalid_union.', + ), baseDir: z .string() .optional() diff --git a/packages/mcp-server/src/self-inspect-tool.ts b/packages/mcp-server/src/self-inspect-tool.ts new file mode 100644 index 0000000000..243c401603 --- /dev/null +++ b/packages/mcp-server/src/self-inspect-tool.ts @@ -0,0 +1,202 @@ +/** + * self_inspect — MCP tool that lets an agent query its own AIP-42 manifest + * without knowing its disk path. + * + * The agent supplies its logical `id`; the runtime resolves + * `/.agents//AGENT.md`, loads it via `agentVerbs`, resolves + * each tool and routine ref to a `{ id, description }` summary, and returns + * `{ agentPath, tools, routines }`. + * + * Injection mechanism: the workspace path is captured in the + * `registerSelfInspectTool` closure at server-creation time (same pattern as + * `registerFsTools`). The agent provides its logical id (known from its own + * system-prompt frontmatter) — not an absolute path. + */ + +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import { z } from "zod" +import { join } from "node:path" +import { agentVerbs } from "@agentproto/agent" +import { toolVerbs } from "@agentproto/tool" +import { routineVerbs } from "@agentproto/routine" + +export interface RefSummary { + id: string + description: string +} + +export interface SelfInspectResult { + agentPath: string + tools: RefSummary[] + routines: RefSummary[] +} + +/** + * Reduce one AIP-27 ref block (from an agent's `tools[]`) to `{id, description}`. + * + * - `file:` → load the TOOL.md and extract `id` + `description` from the handle. + * `baseDir` is the workspace root (tools live at `/tools//TOOL.md` + * by the AIP-14 `pathOf` convention, or wherever the file pointer says). + * - `inline:` → use the inline params directly. + * - `ref:` or `string` → surface the ref identifier as the id (registry resolution + * requires an external resolver not available here at inspect time). + */ +export async function summarizeToolRef( + raw: unknown, + workspace: string, +): Promise { + if (typeof raw === "string") { + return { id: raw, description: "(string ref — not locally resolved)" } + } + if (typeof raw !== "object" || raw === null) { + return { id: String(raw), description: "(unknown ref shape)" } + } + const block = raw as { ref?: string; file?: string; inline?: Record } + if (block.file) { + try { + const handle = await toolVerbs.resolve( + { file: block.file }, + { baseDir: workspace }, + ) + return { id: handle.id, description: handle.description ?? "" } + } catch { + return { id: block.file, description: "(file ref — could not load)" } + } + } + if (block.inline) { + return { + id: String(block.inline.id ?? ""), + description: String(block.inline.description ?? ""), + } + } + if (block.ref) { + return { id: block.ref, description: "(ref — not locally resolved)" } + } + return { id: JSON.stringify(raw), description: "(unknown ref shape)" } +} + +/** + * Same logic for AIP-41 routine refs. Routines live at + * `/.routines//ROUTINE.md` by `routineSpec.pathOf` convention. + */ +export async function summarizeRoutineRef( + raw: unknown, + workspace: string, +): Promise { + if (typeof raw === "string") { + return { id: raw, description: "(string ref — not locally resolved)" } + } + if (typeof raw !== "object" || raw === null) { + return { id: String(raw), description: "(unknown ref shape)" } + } + const block = raw as { ref?: string; file?: string; inline?: Record } + if (block.file) { + try { + const handle = await routineVerbs.resolve( + { file: block.file }, + { baseDir: workspace }, + ) + return { id: handle.id, description: handle.description ?? "" } + } catch { + return { id: block.file, description: "(file ref — could not load)" } + } + } + if (block.inline) { + return { + id: String(block.inline.id ?? ""), + description: String(block.inline.description ?? ""), + } + } + if (block.ref) { + return { id: block.ref, description: "(ref — not locally resolved)" } + } + return { id: JSON.stringify(raw), description: "(unknown ref shape)" } +} + +/** + * Core logic, extracted for testability. + * Throws with `{ error, message }` on `agent_not_found`. + */ +export async function selfInspect( + agentId: string, + workspace: string, +): Promise { + const agentPath = join(workspace, ".agents", agentId, "AGENT.md") + + let handle: Awaited>["handle"] + try { + const result = await agentVerbs.load(agentPath) + handle = result.handle + } catch (err) { + const e = new Error( + `No AGENT.md found for agent '${agentId}' at '${agentPath}'. ` + + `Ensure an AGENT.md exists at /.agents/${agentId}/AGENT.md.`, + ) + ;(e as NodeJS.ErrnoException).code = "agent_not_found" + throw e + } + + const rawTools = (handle.tools ?? []) as unknown[] + const rawRoutines = (handle.routines ?? []) as unknown[] + + const [tools, routines] = await Promise.all([ + Promise.all(rawTools.map((r) => summarizeToolRef(r, workspace))), + Promise.all(rawRoutines.map((r) => summarizeRoutineRef(r, workspace))), + ]) + + return { agentPath, tools, routines } +} + +/** + * Register the `self_inspect` MCP tool on `server`. + * + * The workspace path is injected at registration time; the agent only needs to + * supply its logical `id` at call time — not a disk path. This is called from + * `createMcpServer` whenever a workspace is provided. + */ +export function registerSelfInspectTool( + server: McpServer, + opts: { workspace: string }, +): void { + server.tool( + "self_inspect", + "Return this agent's AIP-42 manifest summary (tools + routines) without requiring knowledge of disk paths. " + + "Pass the agent's logical `id` (the `id:` field in its AGENT.md frontmatter); the runtime resolves it to " + + "`/.agents//AGENT.md`. Returns `{ agentPath, tools, routines }` — each item has at " + + "minimum `{ id, description }`. File refs are loaded; string/ref refs are surfaced as-is.", + { + agentId: z + .string() + .min(1) + .describe( + "The agent's logical id (e.g. 'writer'). Matches the `id:` field in the AGENT.md frontmatter. " + + "The runtime resolves this to `/.agents//AGENT.md` — " + + "you do not need to know the absolute disk path.", + ), + }, + async ({ agentId }) => { + try { + const result = await selfInspect(agentId, opts.workspace) + return { + content: [ + { + type: "text" as const, + text: JSON.stringify(result, null, 2), + }, + ], + } + } catch (err) { + const message = err instanceof Error ? err.message : String(err) + return { + content: [ + { + type: "text" as const, + text: JSON.stringify({ error: "agent_not_found", message }, null, 2), + }, + ], + isError: true, + } + } + }, + ) +} diff --git a/packages/mcp-server/tsup.config.ts b/packages/mcp-server/tsup.config.ts index 8a21818436..090be4f2fd 100644 --- a/packages/mcp-server/tsup.config.ts +++ b/packages/mcp-server/tsup.config.ts @@ -11,9 +11,12 @@ export default createTsupConfig({ dts: true, external: [ "zod", + "@agentproto/agent", "@agentproto/define-doctype", "@agentproto/extension", "@agentproto/manifest", + "@agentproto/routine", + "@agentproto/tool", "@modelcontextprotocol/sdk", "@modelcontextprotocol/sdk/server/index.js", "@modelcontextprotocol/sdk/server/mcp.js", From 863f9f4cce75a28fe52bdf5f658a9cb3a6fcef7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 14:33:17 +0200 Subject: [PATCH 09/19] feat(manifest): add updateManifestSet for atomic multi-file writes - updateManifestSet: accepts an array of {path, patch} pairs and applies them atomically (all-or-nothing, no partial writes on error) - Extend verbs.test.ts coverage for multi-file scenarios Co-Authored-By: Claude Sonnet 4.6 --- packages/manifest/src/__tests__/verbs.test.ts | 109 ++++++++++++++++- packages/manifest/src/index.ts | 110 +++++++++++++++++- 2 files changed, 216 insertions(+), 3 deletions(-) diff --git a/packages/manifest/src/__tests__/verbs.test.ts b/packages/manifest/src/__tests__/verbs.test.ts index 85d20895eb..769404c452 100644 --- a/packages/manifest/src/__tests__/verbs.test.ts +++ b/packages/manifest/src/__tests__/verbs.test.ts @@ -1,10 +1,10 @@ import { describe, it, expect } from "vitest" import matter from "gray-matter" -import { mkdtempSync, readFileSync, rmSync } from "node:fs" +import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs" import { writeFile, mkdir } from "node:fs/promises" import { tmpdir } from "node:os" import { join } from "node:path" -import { createVerbs, type DoctypeSpec } from "../index.js" +import { createVerbs, updateManifestSet, type DoctypeSpec, type ManifestOp } from "../index.js" // Minimal fake doctype to test verbs in isolation. The real packages // (@agentproto/tool, …) wire createVerbs against their own define + @@ -207,3 +207,108 @@ describe("createVerbs — delete", () => { } }) }) + +// --------------------------------------------------------------------------- +// updateManifestSet +// --------------------------------------------------------------------------- + +describe("updateManifestSet — success", () => { + it("writes all files when every op is valid", async () => { + const dir = mkdtempSync(join(tmpdir(), "agentproto-manifest-set-")) + try { + const ops: ManifestOp[] = [ + () => verbs.create({ id: "alpha", description: "First" }, { dir, dryRun: true }), + () => verbs.create({ id: "beta", description: "Second" }, { dir, dryRun: true }), + ] + const results = await updateManifestSet(ops) + + expect(results).toHaveLength(2) + // Both targets must exist and contain the rendered content. + for (const { path, rendered } of results) { + expect(existsSync(path)).toBe(true) + expect(readFileSync(path, "utf8")).toBe(rendered) + } + // No stray .tmp files anywhere in dir. + const allEntries = readdirSync(dir, { recursive: true }) as string[] + expect(allEntries.every((e) => !String(e).includes(".tmp-"))).toBe(true) + } finally { + rmSync(dir, { recursive: true, force: true }) + } + }) + + it("update+create mixed ops both land atomically", async () => { + const dir = mkdtempSync(join(tmpdir(), "agentproto-manifest-set-")) + try { + // Pre-create alpha so we can update it. + const existing = await verbs.create({ id: "alpha", description: "Old" }, { dir }) + const ops: ManifestOp[] = [ + () => verbs.update(existing.path, (p) => ({ ...p, description: "New" }), { dryRun: true }), + () => verbs.create({ id: "beta", description: "Second" }, { dir, dryRun: true }), + ] + await updateManifestSet(ops) + + const reloaded = await verbs.load(existing.path) + expect(reloaded.handle.description).toBe("New") + expect(existsSync(join(dir, "beta/FAKE.md"))).toBe(true) + } finally { + rmSync(dir, { recursive: true, force: true }) + } + }) +}) + +describe("updateManifestSet — validation failure (phase 1)", () => { + it("aborts before writing when one op has an invalid id", async () => { + const dir = mkdtempSync(join(tmpdir(), "agentproto-manifest-set-")) + try { + const ops: ManifestOp[] = [ + // Valid op — should NOT be written because the set fails. + () => verbs.create({ id: "alpha", description: "Valid" }, { dir, dryRun: true }), + // Invalid id causes spec.define to throw during the thunk call. + () => verbs.create({ id: "INVALID!!!", description: "Bad" }, { dir, dryRun: true }), + ] + + await expect(updateManifestSet(ops)).rejects.toThrow(/invalid id/i) + + // Neither target must exist — phase 1 aborted before any write. + expect(existsSync(join(dir, "alpha/FAKE.md"))).toBe(false) + // No .tmp files either. + const allEntries = readdirSync(dir, { recursive: true }) as string[] + expect(allEntries.every((e) => !String(e).includes(".tmp-"))).toBe(true) + } finally { + rmSync(dir, { recursive: true, force: true }) + } + }) +}) + +describe("updateManifestSet — write failure (phase 2)", () => { + it("cleans up staged .tmp files and leaves all targets untouched when staging fails mid-batch", async () => { + const dir = mkdtempSync(join(tmpdir(), "agentproto-manifest-set-")) + try { + // Create a FILE at the path op2 would use as a parent directory. + // mkdir(dirname(op2Target)) will fail with ENOTDIR/EEXIST. + const blockerPath = join(dir, "blocker") + writeFileSync(blockerPath, "I am a file, not a directory") + + const op2TargetPath = join(blockerPath, "FAKE.md") + + const ops: ManifestOp[] = [ + // Op1: valid, will stage its .tmp before op2 fails. + () => verbs.create({ id: "alpha", description: "Valid" }, { dir, dryRun: true }), + // Op2: thunk itself succeeds (dryRun), but staging will fail because + // dirname(op2TargetPath) = blockerPath which is a file, not a dir. + async () => ({ path: op2TargetPath, rendered: "---\nschema: x\n---\n" }), + ] + + await expect(updateManifestSet(ops)).rejects.toThrow() + + // Op1's staged .tmp must have been cleaned up. + const allEntries = readdirSync(dir, { recursive: true }) as string[] + expect(allEntries.every((e) => !String(e).includes(".tmp-"))).toBe(true) + + // Op1's target must NOT exist — rename never happened. + expect(existsSync(join(dir, "alpha/FAKE.md"))).toBe(false) + } finally { + rmSync(dir, { recursive: true, force: true }) + } + }) +}) diff --git a/packages/manifest/src/index.ts b/packages/manifest/src/index.ts index 7627eec73b..9f5fd640ba 100644 --- a/packages/manifest/src/index.ts +++ b/packages/manifest/src/index.ts @@ -21,8 +21,9 @@ import { filterSerializable } from "@agentproto/define-doctype" import matter from "gray-matter" import type { Dirent } from "node:fs" -import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises" +import { access, copyFile, mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises" import { dirname, isAbsolute, join } from "node:path" +import { randomBytes } from "node:crypto" /** * Per-package descriptor consumed by `createVerbs`. @@ -285,6 +286,113 @@ export function createVerbs< return { create, load, list, update, resolve, delete: deleteFn } } +/** + * A render-and-validate thunk for use with {@link updateManifestSet}. + * + * Wrap an existing verb call with `dryRun: true` so that validation and + * rendering happen without touching disk. `updateManifestSet` calls the thunk + * in its phase-1 pass; if it throws the entire operation is aborted before + * any file is written. + * + * @example + * ```ts + * const ops: ManifestOp[] = [ + * () => toolVerbs.create(toolParams, { dir, dryRun: true }), + * () => agentVerbs.update(agentPath, mutator, { dryRun: true }), + * ] + * await updateManifestSet(ops) + * ``` + */ +export type ManifestOp = () => Promise<{ path: string; rendered: string }> + +export interface ManifestSetOptions { + /** + * If true, copy each existing target to `.bak` before the commit + * (rename) phase. The backup is created before any rename so the original + * content survives a partial failure. Backup files are never removed on + * error — the caller can inspect them for recovery. + */ + backup?: boolean +} + +/** + * Write multiple manifests as a best-effort atomic set. + * + * ## Sequence + * 1. **Render + validate** — call every `op()` thunk concurrently. Any + * validation error aborts here; nothing is written. + * 2. **Stage** — write each rendered string to a sibling temp file + * `.tmp-` in the same directory. + * 3. **Backup** *(optional)* — if `opts.backup`, copy each existing target to + * `.bak`. + * 4. **Commit** — `rename(tmp, target)` for each file sequentially. + * + * ## Atomicity guarantee (honest) + * Each individual `rename()` is atomic on POSIX (same-device, same-dir swap). + * The **sequence** of renames is NOT globally atomic. A process crash between + * two renames leaves some targets at their new content and others unchanged — + * there is no cross-file rollback. This is an inherent POSIX limitation; + * true multi-file atomicity requires a WAL or journal outside this package. + * + * ## Error handling + * On any error in the stage or commit phase all remaining `.tmp-*` temp files + * are removed before rethrowing. Targets that were already committed in the + * same run are **not** rolled back — they hold their new content. Targets not + * yet reached remain unchanged. + */ +export async function updateManifestSet( + ops: ManifestOp[], + opts: ManifestSetOptions = {}, +): Promise> { + // Phase 1: Render + validate all ops. Fail early; nothing written yet. + const results = await Promise.all(ops.map((op) => op())) + + const suffix = randomBytes(4).toString("hex") + // Mirrors `results` index-for-index. Empty string = not yet staged (skip cleanup). + const tmps: string[] = new Array(results.length).fill("") + + try { + // Phase 2: Stage — write each to a sibling .tmp file. + // entries() yields [index, element] with element fully typed (no undefined). + for (const [i, { path, rendered }] of results.entries()) { + const tmp = `${path}.tmp-${suffix}` + await mkdir(dirname(path), { recursive: true }) + await writeFile(tmp, rendered, "utf8") + tmps[i] = tmp + } + + // Phase 3: Backup (optional) — copy existing targets before rename. + if (opts.backup) { + for (const { path } of results) { + try { + await access(path) + await copyFile(path, `${path}.bak`) + } catch { + // File doesn't exist yet — no backup needed. + } + } + } + + // Phase 4: Commit — atomic rename of each staged tmp → target. + // Each rename() is individually atomic (POSIX same-device). + // The loop is NOT globally atomic; see the doc-comment above. + for (const [i, { path }] of results.entries()) { + // tmps[i] is guaranteed non-null: same length as results, set in phase 2. + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + await rename(tmps[i]!, path) + tmps[i] = "" // Committed; exclude from cleanup if a later rename fails. + } + } catch (err) { + // Remove staged .tmp files that were not yet committed. + await Promise.allSettled( + tmps.filter(Boolean).map((t) => rm(t, { force: true })), + ) + throw err + } + + return results +} + function defaultBody( spec: DoctypeSpec

, frontmatter: Record, From 2a088a00addeb9b22dbc1eaa26a06e34e6b962f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 14:33:28 +0200 Subject: [PATCH 10/19] test(mcp-server): e2e create_driver + self_inspect through MCP transport MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit End-to-end test that starts a real in-process MCP server, calls create_driver to register a driver manifest, then calls self_inspect to verify the agent reads its own identity — exercises the full create_driver → self_inspect path over the MCP JSON-RPC transport. Co-Authored-By: Claude Sonnet 4.6 --- .../__tests__/e2e-driver-selfinspect.test.ts | 207 ++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts diff --git a/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts b/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts new file mode 100644 index 0000000000..9bd5a1a530 --- /dev/null +++ b/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts @@ -0,0 +1,207 @@ +/** + * E2E: daemon→MCP→verbe→disque pour create_driver et self_inspect. + * + * Principe : on boot un vrai McpServer (createMcpServer) puis on s'y + * connecte via InMemoryTransport + Client SDK. Chaque appel passe par + * le chemin complet JSON-RPC (serialize → deserialize → handler → disk). + */ + +import { describe, it, expect } from "vitest" +import { mkdtempSync, existsSync, rmSync } from "node:fs" +import { mkdir, writeFile, readFile } from "node:fs/promises" +import { tmpdir } from "node:os" +import { join } from "node:path" + +import { toolSpec } from "@agentproto/tool" +import { driverSpec } from "@agentproto/driver" + +import { createMcpServer } from "../index.js" + +// MCP SDK transport + client — invoked via the real JSON-RPC path. +import { Client } from "@modelcontextprotocol/sdk/client/index.js" +import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +// ── helpers ────────────────────────────────────────────────────────── + +async function connectClient(server: McpServer): Promise { + const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair() + await server.connect(serverTransport) + const client = new Client( + { name: "e2e-test", version: "0.0.1" }, + { capabilities: {} }, + ) + await client.connect(clientTransport) + return client +} + +/** Call an MCP tool and return the parsed JSON payload from content[0]. */ +async function callTool( + client: Client, + name: string, + args: Record, +): Promise> { + const result = await client.callTool({ name, arguments: args }) + const item = result.content[0] + if (!item || item.type !== "text") { + throw new Error(`Expected text content from tool '${name}'; got ${JSON.stringify(result.content)}`) + } + return JSON.parse(item.text) as Record +} + +// ── tests ───────────────────────────────────────────────────────────── + +describe("e2e: create_driver → disque → load_driver / list_driver", () => { + it("écrit DRIVER.md sur le disque et le retrouve via load/list", async () => { + const workspace = mkdtempSync(join(tmpdir(), "agentproto-e2e-driver-")) + let client: Client | undefined + try { + const { server, registered } = await createMcpServer({ + specs: [toolSpec, driverSpec], + workspace, + }) + + // Vérifie que driver est bien enregistré parmi les specs. + expect(registered).toContain("driver") + + client = await connectClient(server) + + // ── create_driver ───────────────────────────────────────────── + const created = await callTool(client, "create_driver", { + params: { + id: "echo-http", + name: "Echo HTTP Driver", + description: "Minimal e2e test driver", + kind: "http", + implements: [{ tool: "echo", version: "1.0.0" }], + }, + dir: "drivers", + }) + + // Le serveur ancre "drivers" → join(workspace, "drivers") + // pathOf(handle) = "echo-http/DRIVER.md" + // → path final = join(workspace, "drivers", "echo-http", "DRIVER.md") + const expectedPath = join(workspace, "drivers", "echo-http", "DRIVER.md") + expect(created.path).toBe(expectedPath) + + // Le fichier doit exister sur le disque. + expect(existsSync(expectedPath)).toBe(true) + + // Contenu minimal attendu dans le fichier. + const onDisk = await readFile(expectedPath, "utf8") + expect(onDisk).toContain("schema: agentproto/driver/v1") + expect(onDisk).toContain("id: echo-http") + expect(onDisk).toContain("kind: http") + + // ── load_driver ─────────────────────────────────────────────── + const loaded = await callTool(client, "load_driver", { + path: "drivers/echo-http/DRIVER.md", + }) + const handle = loaded.handle as Record + expect(handle.id).toBe("echo-http") + expect(handle.name).toBe("Echo HTTP Driver") + expect(handle.kind).toBe("http") + + // ── list_driver ─────────────────────────────────────────────── + const listed = await callTool(client, "list_driver", { + dir: "drivers", + }) + expect(listed.count).toBe(1) + const handles = listed.handles as unknown[] + expect(handles).toHaveLength(1) + expect((handles[0] as Record).id).toBe("echo-http") + } finally { + await client?.close() + rmSync(workspace, { recursive: true, force: true }) + } + }) +}) + +describe("e2e: self_inspect", () => { + it("résout les file-refs d'un AGENT.md et retourne { agentPath, tools, routines }", async () => { + const workspace = mkdtempSync(join(tmpdir(), "agentproto-e2e-inspect-")) + let client: Client | undefined + try { + // TOOL.md référencé par l'agent. + await mkdir(join(workspace, "tools", "echo"), { recursive: true }) + await writeFile( + join(workspace, "tools", "echo", "TOOL.md"), + `--- +schema: agentproto/tool/v1 +id: echo +name: Echo +description: Echo tool for e2e testing +version: 1.0.0 +--- +`, + ) + + // AGENT.md avec un file-ref vers TOOL.md. + // Chemin résolu par selfInspect : /.agents//AGENT.md + await mkdir(join(workspace, ".agents", "writer"), { recursive: true }) + await writeFile( + join(workspace, ".agents", "writer", "AGENT.md"), + `--- +schema: agent/v1 +id: writer +description: Test writer agent for e2e +model: claude-sonnet-4-5 +tools: + - file: tools/echo/TOOL.md +--- +`, + ) + + const { server } = await createMcpServer({ + specs: [toolSpec, driverSpec], + workspace, + }) + client = await connectClient(server) + + // ── self_inspect ────────────────────────────────────────────── + const result = await callTool(client, "self_inspect", { + agentId: "writer", + }) + + expect(result.agentPath).toBe( + join(workspace, ".agents", "writer", "AGENT.md"), + ) + + const tools = result.tools as Array<{ id: string; description: string }> + expect(Array.isArray(tools)).toBe(true) + expect(tools).toHaveLength(1) + expect(tools[0].id).toBe("echo") + expect(tools[0].description).toBe("Echo tool for e2e testing") + + const routines = result.routines as unknown[] + expect(routines).toEqual([]) + } finally { + await client?.close() + rmSync(workspace, { recursive: true, force: true }) + } + }) + + it("renvoie { error: 'agent_not_found' } quand l'AGENT.md est absent", async () => { + const workspace = mkdtempSync(join(tmpdir(), "agentproto-e2e-inspect-")) + let client: Client | undefined + try { + const { server } = await createMcpServer({ + specs: [toolSpec, driverSpec], + workspace, + }) + client = await connectClient(server) + + const result = await callTool(client, "self_inspect", { + agentId: "ghost", + }) + + // Le tool ne lance pas d'exception protocole — il renvoie un contenu + // avec isError:true et { error, message } dans le texte JSON. + expect(result.error).toBe("agent_not_found") + expect(typeof result.message).toBe("string") + } finally { + await client?.close() + rmSync(workspace, { recursive: true, force: true }) + } + }) +}) From 857d8bc1ed2463a24e9119fe953acb0066c77433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 15:01:49 +0200 Subject: [PATCH 11/19] =?UTF-8?q?chore:=20sync=20lockfile=20=E2=80=94=20ma?= =?UTF-8?q?stra=20downgrade=20@mastra/core=201.45.0=E2=86=921.32.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pnpm-lock.yaml | 59 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0a2964341f..b01b22a0de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1360,8 +1360,8 @@ importers: specifier: workspace:* version: link:../tooling '@mastra/core': - specifier: 1.45.0 - version: 1.45.0(ai@6.0.205(zod@4.4.3))(express@5.2.1)(zod@4.4.3) + specifier: 1.32.1 + version: 1.32.1(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-schema/spec@1.1.0)(openapi-types@12.1.3)(zod@4.4.3))(@types/json-schema@7.0.15)(ai@6.0.205(zod@4.4.3))(express@5.2.1)(openapi-types@12.1.3)(zod@4.4.3) '@types/node': specifier: ^25.6.2 version: 25.6.2 @@ -2487,6 +2487,12 @@ packages: peerDependencies: zod: ^3.25.0 || ^4.0.0 + '@mastra/core@1.32.1': + resolution: {integrity: sha512-6ynJNZ9GMkLs11c9D4Ui9Z0eOP8GsAqPeMVhlnxExcdTls0ufFQSXFgwzBqtS97fot9IOA/fxDLvvW83fnsP0A==} + engines: {node: '>=22.13.0'} + peerDependencies: + zod: ^3.25.0 || ^4.0.0 + '@mastra/core@1.45.0': resolution: {integrity: sha512-UPpNL+iJVfypfc7IOKL9fhmoKKDe6IA6y+DwZDRSTN+uz/ft194e+TrB4LnBdYtTTeLhDO96mxW2rp9LK0ULhg==} engines: {node: '>=22.13.0'} @@ -4612,6 +4618,55 @@ snapshots: - supports-color - utf-8-validate + '@mastra/core@1.32.1(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-schema/spec@1.1.0)(openapi-types@12.1.3)(zod@4.4.3))(@types/json-schema@7.0.15)(ai@6.0.205(zod@4.4.3))(express@5.2.1)(openapi-types@12.1.3)(zod@4.4.3)': + dependencies: + '@a2a-js/sdk': 0.3.13(express@5.2.1) + '@ai-sdk/provider-utils-v5': '@ai-sdk/provider-utils@3.0.23(zod@4.4.3)' + '@ai-sdk/provider-utils-v6': '@ai-sdk/provider-utils@4.0.23(zod@4.4.3)' + '@ai-sdk/provider-v5': '@ai-sdk/provider@2.0.1' + '@ai-sdk/provider-v6': '@ai-sdk/provider@3.0.8' + '@ai-sdk/ui-utils-v5': '@ai-sdk/ui-utils@1.2.11(zod@4.4.3)' + '@isaacs/ttlcache': 2.1.4 + '@lukeed/uuid': 2.0.1 + '@mastra/schema-compat': 1.2.9(zod@4.4.3) + '@modelcontextprotocol/sdk': 1.29.0(zod@4.4.3) + '@sindresorhus/slugify': 2.2.1 + '@standard-schema/spec': 1.1.0 + ajv: 8.20.0 + chat: 4.31.0(ai@6.0.205(zod@4.4.3))(zod@4.4.3) + croner: 10.0.1 + dotenv: 17.4.2 + execa: 9.6.1 + gray-matter: 4.0.3 + hono: 4.12.16 + hono-openapi: 1.3.0(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-schema/spec@1.1.0)(openapi-types@12.1.3)(zod@4.4.3))(@types/json-schema@7.0.15)(hono@4.12.16)(openapi-types@12.1.3) + ignore: 7.0.5 + js-tiktoken: 1.0.21 + json-schema: 0.4.0 + lru-cache: 11.3.5 + p-map: 7.0.4 + p-retry: 7.1.1 + picomatch: 4.0.4 + radash: 12.1.1 + tokenx: 1.3.0 + ws: 8.20.0 + xxhash-wasm: 1.1.0 + zod: 4.4.3 + transitivePeerDependencies: + - '@bufbuild/protobuf' + - '@cfworker/json-schema' + - '@grpc/grpc-js' + - '@hono/standard-validator' + - '@standard-community/standard-json' + - '@standard-community/standard-openapi' + - '@types/json-schema' + - ai + - bufferutil + - express + - openapi-types + - supports-color + - utf-8-validate + '@mastra/core@1.45.0(ai@6.0.205(zod@4.4.3))(express@5.2.1)(zod@4.4.3)': dependencies: '@a2a-js/sdk': 0.3.13(express@5.2.1) From 42b70909f9d959b2154e868e3b314c8ecba47c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 15:03:33 +0200 Subject: [PATCH 12/19] =?UTF-8?q?chore:=20sync=20lockfile=20=E2=80=94=20ad?= =?UTF-8?q?apters/mastra=20@mastra/core=201.45.0=E2=86=921.32.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pnpm-lock.yaml | 131 +------------------------------------------------ 1 file changed, 2 insertions(+), 129 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b01b22a0de..d00b71c0cb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -140,8 +140,8 @@ importers: specifier: workspace:* version: link:../../packages/tooling '@mastra/core': - specifier: 1.45.0 - version: 1.45.0(ai@6.0.205(zod@4.4.3))(express@5.2.1)(zod@4.4.3) + specifier: 1.32.1 + version: 1.32.1(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-community/standard-openapi@0.2.9(@standard-community/standard-json@0.3.5(@standard-schema/spec@1.1.0)(@types/json-schema@7.0.15)(quansync@0.2.11)(zod-to-json-schema@3.25.2(zod@4.4.3))(zod@4.4.3))(@standard-schema/spec@1.1.0)(openapi-types@12.1.3)(zod@4.4.3))(@types/json-schema@7.0.15)(ai@6.0.205(zod@4.4.3))(express@5.2.1)(openapi-types@12.1.3)(zod@4.4.3) '@types/node': specifier: ^25.6.2 version: 25.6.2 @@ -2155,24 +2155,12 @@ packages: peerDependencies: zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/provider-utils@3.0.25': - resolution: {integrity: sha512-CvsRu+32Y8a167s+lrIBtsybvgTHp8j9y+6BeTvLeoW3Q+okw/b4CnNUFOLIXsRaKHQKAH+IHNJPYWywfpw0LA==} - engines: {node: '>=18'} - peerDependencies: - zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/provider-utils@4.0.23': resolution: {integrity: sha512-z8GlDaCmRSDlqkMF2f4/RFgWxdarvIbyuk+m6WXT1LYgsnGiXRJGTD2Z1+SDl3LqtFuRtGX1aghYvQLoHL/9pg==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/provider-utils@4.0.27': - resolution: {integrity: sha512-ubkAJ+xODouwtmN1tYlvTPphH1hPOBfZaEQe8U7skGvFAnIRs9PPpsq57bC2+Ky/MB4yzhd6YOsxTAx9sGpazw==} - engines: {node: '>=18'} - peerDependencies: - zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/provider-utils@4.0.29': resolution: {integrity: sha512-uhukHaCBvqkwBHkT8C2PrnqKTCoLn3pdHXqtcR9I8ErH+flbzgW4o7VHSNIup9LRu+WBvZIZDQLsx6rwl2tiOA==} engines: {node: '>=18'} @@ -2187,10 +2175,6 @@ packages: resolution: {integrity: sha512-KCUwswvsC5VsW2PWFqF8eJgSCu5Ysj7m1TxiHTVA6g7k360bk0RNQENT8KTMAYEs+8fWPD3Uu4dEmzGHc+jGng==} engines: {node: '>=18'} - '@ai-sdk/provider@2.0.3': - resolution: {integrity: sha512-h88OPkavHTiN9tMn2l5awAznGB0lXzjcLhgR1/rvjB2zlLprsNxbM2tt6OJsHUxduLC3klq0/eqaSf6fX5XVww==} - engines: {node: '>=18'} - '@ai-sdk/provider@3.0.10': resolution: {integrity: sha512-Q3BZ27qfpYqnCYGvE3vt+Qi6LGOF9R5Nmzn+9JoM1lCRsD9mYaIhfJLkSunN48nfGXJ6n+XNV0J/XVpqGQl7Dw==} engines: {node: '>=18'} @@ -2493,24 +2477,12 @@ packages: peerDependencies: zod: ^3.25.0 || ^4.0.0 - '@mastra/core@1.45.0': - resolution: {integrity: sha512-UPpNL+iJVfypfc7IOKL9fhmoKKDe6IA6y+DwZDRSTN+uz/ft194e+TrB4LnBdYtTTeLhDO96mxW2rp9LK0ULhg==} - engines: {node: '>=22.13.0'} - peerDependencies: - zod: ^3.25.0 || ^4.0.0 - '@mastra/schema-compat@1.2.9': resolution: {integrity: sha512-1/RgazXqi1Wdyx8aR81CVS+sRyzlTGUL1YhhHkSULoEY8aXs58bvWkH/6iixlYsY0xGvn+0OPLCeSRkBCtDx4Q==} engines: {node: '>=22.13.0'} peerDependencies: zod: ^3.25.0 || ^4.0.0 - '@mastra/schema-compat@1.3.0': - resolution: {integrity: sha512-VAWCXGuWuTqnljkheb3zKUujNK6rdGhFISxdSoSz3/d3HJWZOHY10mUnXw5lg0s73FdFDGg4tehbq28fAZz+lA==} - engines: {node: '>=22.13.0'} - peerDependencies: - zod: ^3.25.0 || ^4.0.0 - '@modelcontextprotocol/sdk@1.29.0': resolution: {integrity: sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==} engines: {node: '>=18'} @@ -2537,12 +2509,6 @@ packages: resolution: {integrity: sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==} engines: {node: '>=8.0.0'} - '@posthog/core@1.35.3': - resolution: {integrity: sha512-EsGPbSLl39Jgo2KZ+kI9UAxFnh5nddaN5bNm2rXvUwF+vGmam9eN1EXeNbxhRU7ulEeIiGdm7XjoU7pzavkgIQ==} - - '@posthog/types@1.390.2': - resolution: {integrity: sha512-WcfKz2GNn2vfDX8vXmJYbKxegPxVWHuDQ/pHdAn0HoZDXDFnEp/+x3qBQA+fEvtbPjjtjgAt2wIgJMlM7asx7g==} - '@rollup/rollup-android-arm-eabi@4.60.2': resolution: {integrity: sha512-dnlp69efPPg6Uaw2dVqzWRfAWRnYVb1XJ8CyyhIbZeaq4CA5/mLeZ1IEt9QqQxmbdvagjLIm2ZL8BxXv5lH4Yw==} cpu: [arm] @@ -3334,9 +3300,6 @@ packages: resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} engines: {node: '>=10'} - jpeg-js@0.4.4: - resolution: {integrity: sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==} - js-tiktoken@1.0.21: resolution: {integrity: sha512-biOj/6M5qdgx5TKjDnFT1ymSpM5tbd3ylwDtrQvFQSu0Z7bBYko2dF+W/aUkXUPuk6IVpRxk/3Q2sHOzGlS36g==} @@ -3727,15 +3690,6 @@ packages: resolution: {integrity: sha512-qif0+jGGZoLWdHey3UFHHWP0H7Gbmsk8T5VEqyYFbWqPr1XqvLGBbk/sl8V5exGmcYJklJOhOQq1pV9IcsiFag==} engines: {node: ^10 || ^12 || >=14} - posthog-node@5.38.2: - resolution: {integrity: sha512-eiKpU+vX4hVuHbO/EosvPHsmh2AVIdoVmWss/uUOs1t4b0ViCblw2o8OIFqHxKj3mYRnSOBlX0Dw3wBvcCaYpA==} - engines: {node: ^20.20.0 || >=22.22.0} - peerDependencies: - rxjs: ^7.0.0 - peerDependenciesMeta: - rxjs: - optional: true - prettier@2.8.8: resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} engines: {node: '>=10.13.0'} @@ -4224,13 +4178,6 @@ snapshots: eventsource-parser: 3.0.8 zod: 4.4.3 - '@ai-sdk/provider-utils@3.0.25(zod@4.4.3)': - dependencies: - '@ai-sdk/provider': 2.0.3 - '@standard-schema/spec': 1.1.0 - eventsource-parser: 3.0.8 - zod: 4.4.3 - '@ai-sdk/provider-utils@4.0.23(zod@4.4.3)': dependencies: '@ai-sdk/provider': 3.0.8 @@ -4238,13 +4185,6 @@ snapshots: eventsource-parser: 3.0.8 zod: 4.4.3 - '@ai-sdk/provider-utils@4.0.27(zod@4.4.3)': - dependencies: - '@ai-sdk/provider': 3.0.10 - '@standard-schema/spec': 1.1.0 - eventsource-parser: 3.0.8 - zod: 4.4.3 - '@ai-sdk/provider-utils@4.0.29(zod@4.4.3)': dependencies: '@ai-sdk/provider': 3.0.10 @@ -4260,10 +4200,6 @@ snapshots: dependencies: json-schema: 0.4.0 - '@ai-sdk/provider@2.0.3': - dependencies: - json-schema: 0.4.0 - '@ai-sdk/provider@3.0.10': dependencies: json-schema: 0.4.0 @@ -4667,49 +4603,6 @@ snapshots: - supports-color - utf-8-validate - '@mastra/core@1.45.0(ai@6.0.205(zod@4.4.3))(express@5.2.1)(zod@4.4.3)': - dependencies: - '@a2a-js/sdk': 0.3.13(express@5.2.1) - '@ai-sdk/provider-utils-v5': '@ai-sdk/provider-utils@3.0.25(zod@4.4.3)' - '@ai-sdk/provider-utils-v6': '@ai-sdk/provider-utils@4.0.27(zod@4.4.3)' - '@ai-sdk/provider-v5': '@ai-sdk/provider@2.0.3' - '@ai-sdk/provider-v6': '@ai-sdk/provider@3.0.10' - '@isaacs/ttlcache': 2.1.4 - '@lukeed/uuid': 2.0.1 - '@mastra/schema-compat': 1.3.0(zod@4.4.3) - '@modelcontextprotocol/sdk': 1.29.0(zod@4.4.3) - '@sindresorhus/slugify': 2.2.1 - '@standard-schema/spec': 1.1.0 - ajv: 8.20.0 - chat: 4.31.0(ai@6.0.205(zod@4.4.3))(zod@4.4.3) - croner: 10.0.1 - dotenv: 17.4.2 - execa: 9.6.1 - fastq: 1.20.1 - gray-matter: 4.0.3 - ignore: 7.0.5 - jpeg-js: 0.4.4 - json-schema: 0.4.0 - lru-cache: 11.3.5 - p-map: 7.0.4 - p-retry: 7.1.1 - picomatch: 4.0.4 - posthog-node: 5.38.2 - tokenx: 1.3.0 - ws: 8.20.0 - xxhash-wasm: 1.1.0 - zod: 4.4.3 - transitivePeerDependencies: - - '@bufbuild/protobuf' - - '@cfworker/json-schema' - - '@grpc/grpc-js' - - ai - - bufferutil - - express - - rxjs - - supports-color - - utf-8-validate - '@mastra/schema-compat@1.2.9(zod@4.4.3)': dependencies: json-schema-to-zod: 2.8.1 @@ -4718,14 +4611,6 @@ snapshots: zod-from-json-schema-v3: zod-from-json-schema@0.0.5 zod-to-json-schema: 3.25.2(zod@4.4.3) - '@mastra/schema-compat@1.3.0(zod@4.4.3)': - dependencies: - json-schema-to-zod: 2.8.1 - zod: 4.4.3 - zod-from-json-schema: 0.5.2 - zod-from-json-schema-v3: zod-from-json-schema@0.0.5 - zod-to-json-schema: 3.25.2(zod@4.4.3) - '@modelcontextprotocol/sdk@1.29.0(zod@4.4.3)': dependencies: '@hono/node-server': 1.19.14(hono@4.12.16) @@ -4762,12 +4647,6 @@ snapshots: '@opentelemetry/api@1.9.0': {} - '@posthog/core@1.35.3': - dependencies: - '@posthog/types': 1.390.2 - - '@posthog/types@1.390.2': {} - '@rollup/rollup-android-arm-eabi@4.60.2': optional: true @@ -5481,8 +5360,6 @@ snapshots: joycon@3.1.1: {} - jpeg-js@0.4.4: {} - js-tiktoken@1.0.21: dependencies: base64-js: 1.5.1 @@ -5989,10 +5866,6 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 - posthog-node@5.38.2: - dependencies: - '@posthog/core': 1.35.3 - prettier@2.8.8: {} prettier@3.8.3: {} From b69816ab7882f458ced14479fbd0146ec1f211d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 15:11:46 +0200 Subject: [PATCH 13/19] fix(runtime): add model? to AgentAdapterResolver.startSession type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit serve.ts destructured model from startSession opts but the type in http-server.ts didn't declare it → TS2339 build failure. fix(corpus-cli): clean dist/specs before bundle-specs copy cpSync without prior rmSync left stale AIP dirs (e.g. aip-49/HARNESS from before HARNESS was moved to aip-52) in the published package. docs(aip-52): add ADAPTER.md for Harness spec Co-Authored-By: Claude Sonnet 4.6 --- packages/corpus-cli/scripts/bundle-specs.mjs | 4 +- packages/runtime/src/http-server.ts | 4 + specs/resources/aip-52/draft/ADAPTER.md | 193 +++++++++++++++++++ 3 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 specs/resources/aip-52/draft/ADAPTER.md diff --git a/packages/corpus-cli/scripts/bundle-specs.mjs b/packages/corpus-cli/scripts/bundle-specs.mjs index 470f7b6d02..6c179e5d17 100644 --- a/packages/corpus-cli/scripts/bundle-specs.mjs +++ b/packages/corpus-cli/scripts/bundle-specs.mjs @@ -9,7 +9,7 @@ * Path-resolved from this file's own location, not cwd, so it works * regardless of where the build is invoked. */ -import { cpSync, existsSync } from "node:fs" +import { cpSync, existsSync, rmSync } from "node:fs" import { dirname, resolve } from "node:path" import { fileURLToPath } from "node:url" @@ -22,5 +22,7 @@ if (!existsSync(src)) { process.exit(1) } +// Clean first so stale AIP directories (moved or renamed) don't linger in dist. +rmSync(dest, { recursive: true, force: true }) cpSync(src, dest, { recursive: true }) console.log(`bundle-specs: copied specs/resources -> dist/specs/resources`) diff --git a/packages/runtime/src/http-server.ts b/packages/runtime/src/http-server.ts index 749f42e163..854cec3889 100644 --- a/packages/runtime/src/http-server.ts +++ b/packages/runtime/src/http-server.ts @@ -78,6 +78,10 @@ export type AgentAdapterResolver = (slug: string) => Promise<{ startSession(opts: { cwd: string resumeSessionId?: string + /** Model identifier forwarded from `start_agent_session`. Adapters + * that support model selection (e.g. via a `--model` CLI flag) may + * honour this; others silently ignore it. */ + model?: string }): Promise /** Display label for the descriptor's `command` field. */ commandPreview?: string diff --git a/specs/resources/aip-52/draft/ADAPTER.md b/specs/resources/aip-52/draft/ADAPTER.md new file mode 100644 index 0000000000..80535eb103 --- /dev/null +++ b/specs/resources/aip-52/draft/ADAPTER.md @@ -0,0 +1,193 @@ +# AIP-52 — Harness · Implementer Guide + +> **Status:** Draft +> **Schema:** `HARNESS.schema.json` +> **Canonical runtime:** `@mastra/core/harness` (Mastra's `Harness` class) + +## What is a Harness? + +A Harness is a **stateful, multi-mode conversational shell**. Where an AIP-42 Agent is +a single-purpose inference unit, a Harness composes multiple agents into an orchestrated +shell that can: + +- Switch between **modes** (e.g. plan → execute → review) with distinct agents, tools, + and permission rules per mode. +- Hold a **typed conversation state** (`stateSchema` + `initialState`) that persists + across turns and is visible to all modes. +- Spawn **subagents** via the built-in `subagent` tool (forked or isolated thread). +- Gate tool calls via **tool-approval gates** (`permissions`, `submit_plan` builtin). +- Run **heartbeat handlers** in the background (OM reflector, progress reporter, etc.). + +A Harness IS NOT a subtype of AIP-42. Agents are referenced _from_ harness manifests +via `$resolver` / `$ref`; the harness is the orchestrator, not the agent itself. + +## Filesystem layout + +``` +.harness/ + .md ← one manifest per harness (YAML frontmatter + prose body) +``` + +The markdown body (after the frontmatter block) is purely documentary — it is not +parsed by the runtime. + +## Manifest shape + +```yaml +--- +spec: harness/v1 +id: my-harness +name: My Harness +version: 1.0.0 +description: One-sentence description. + +storage: + $resolver: mastra.storage.composite # must resolve to MastraCompositeStore + +modes: + - id: plan + default: true + name: Plan + agent: { $resolver: my-agent } + model: { $resolver: model.plan } + builtins: + ask_user: true + submit_plan: required # blocks until approved + transitionsTo: execute + + - id: execute + name: Execute + agent: { $resolver: my-agent } + model: { $resolver: model.execute } + builtins: + ask_user: false + subagent: true + +models: + resolver: { $resolver: model.resolver } # (modelId) => LanguageModel + +subagents: + - id: researcher + name: Researcher + description: Searches and summarises. + agent: { $resolver: researcher-agent } + forked: false # isolated thread (default) + maxSteps: 20 + +memory: + $resolver: mastra.memory.thread + +observability: + $resolver: my.telemetry.entrypoint +--- +``` + +### Required fields + +| Field | Type | Notes | +|---|---|---| +| `spec` | `"harness/v1"` | Version pin. | +| `id` | `string` (kebab-case) | Registry key; must be unique within a workspace. | +| `name` | `string` | Human label (≤ 80 chars). | +| `version` | `semver` | Bump on breaking mode / subagent changes. | +| `storage` | `refOrString` | Must resolve to `MastraCompositeStore`. | +| `modes` | `mode[]` | At least one mode required. | +| `models.resolver` | `refOrString` | `(modelId: string) => LanguageModel`. | + +## Resolver syntax (`refOrString`) + +Three forms are accepted for any field annotated `$ref: "#/$defs/refOrString"`: + +```yaml +# 1. Inline literal string (if the field accepts a raw value) +storage: "fs://./data/state" + +# 2. Named registry ref — resolved at harness boot from the resolver registry +storage: + $ref: myApp.storage.main + +# 3. Dynamic resolver call — arbitrary typed input passed to the resolver +storage: + $resolver: myApp.storage.build + input: { path: "./state", ttl: 3600 } +``` + +## Modes + +Each mode entry defines **one operational context**: + +| Field | Required | Notes | +|---|---|---| +| `id` | ✅ | Unique within this harness (kebab-case recommended). | +| `agent` | ✅ | Backing `Mastra Agent` instance (via resolver). | +| `model` | ✅ | Resolver returning `{ modelId, defaultModelId?, allowed? }`. | +| `default` | — | First mode with `default: true` activates on new sessions. | +| `transitionsTo` | — | Auto-switch to this mode id after `submit_plan` approval. | +| `tools` | — | Replaces the agent's built-in tools entirely (mutually exclusive with `additionalTools`). | +| `prompt.blocks` | — | Instruction blocks resolved and concatenated as `instructions`. | +| `builtins.*` | — | Enable / disable built-in tools: `ask_user`, `submit_plan`, `task_write`, `task_check`, `subagent`. | +| `permissions` | — | `PermissionRules` resolver — default tool-approval policy for this mode. | + +### `submit_plan` values + +| Value | Behaviour | +|---|---| +| `false` (default) | Tool not registered. | +| `true` | Registered; plan approval is optional. | +| `"required"` | Registered; the mode blocks on plan approval and then transitions to `transitionsTo`. | + +## Subagents + +```yaml +subagents: + - id: drafter + name: Drafter + description: Writes first-draft content. + agent: { $resolver: drafter-agent } + forked: true # inherits parent thread + prompt cache + maxSteps: 30 + allowedHarnessTools: [ask_user, task_write] + allowedWorkspaceTools: [read_file, write_file] + prompt: + blocks: + - "You are a concise technical writer." + - { $ref: brand.voice.guide } +``` + +- `forked: true` — subagent inherits the parent conversation thread and prompt cache + (cheaper, shares context). +- `forked: false` (default) — fresh isolated thread; the subagent is context-blind to + the parent. + +## Heartbeats + +Heartbeats are periodic background handlers registered on the Harness constructor's +`heartbeats` array. Each entry is a `refOrString` resolving to a `HeartbeatConfig` +(interval + handler function). Common uses: Observational Memory reflector, progress +reporter, stale-session reaper. + +## Loading algorithm + +1. Locate `.harness/.md` in the workspace (or agent pack). +2. Parse the YAML frontmatter block; validate against `HARNESS.schema.json`. +3. Resolve all `$ref` / `$resolver` entries against the resolver registry at boot time + — fail loudly if any resolver is missing. +4. Instantiate the `Harness` object (Mastra constructor) with the resolved config. +5. Register in the harness registry keyed by `id`. + +**Never execute a harness at load time** — only parse, validate, and register. + +## Relationship to other AIPs + +| AIP | Relationship | +|---|---| +| AIP-42 (Agent) | Harness agents are AIP-42 instances. A Harness orchestrates them; it is NOT an AIP-42 agent itself. | +| AIP-12 (Playbook) | Agent packs can auto-generate `.harness/` manifests from `modes/*.md` files during ingestion. | +| AIP-35 (Storage) | `storage` field resolves to a provider defined under AIP-35. | +| AIP-37 (Lifecycle Events) | Harness emits `harness-session-start`, `harness-mode-switch`, `harness-session-end` events. | +| AIP-47 (Role) | `permissions` per mode align with AIP-47 role-based access scopes. | + +## See also + +- `HARNESS.schema.json` — canonical validation schema +- `@mastra/core/harness` — canonical runtime implementation From ac160609c85fe55296adf849892ce37bbae6af36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 15:15:14 +0200 Subject: [PATCH 14/19] =?UTF-8?q?fix(cli):=20define=20AgentCliCommand=20lo?= =?UTF-8?q?cally=20=E2=80=94=20not=20yet=20exported=20from=20driver-agent-?= =?UTF-8?q?cli?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli/src/registry/resolve.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/registry/resolve.ts b/packages/cli/src/registry/resolve.ts index d8e7fccd55..9dfb26bdbf 100644 --- a/packages/cli/src/registry/resolve.ts +++ b/packages/cli/src/registry/resolve.ts @@ -17,7 +17,13 @@ import { promises as fs } from "node:fs" import { fileURLToPath } from "node:url" import { dirname, join, resolve as resolvePath } from "node:path" import { homedir } from "node:os" -import type { AgentCliHandle, AgentCliCommand } from "@agentproto/driver-agent-cli" +import type { AgentCliHandle } from "@agentproto/driver-agent-cli" + +/** Slash-command declared in an adapter manifest (AIP-45 `commands[]`). */ +export interface AgentCliCommand { + name: string + description?: string +} export interface ResolvedAdapter { readonly slug: string From 00c356303b43d2fa29f0dd87129d7a69fb6a62bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 15:19:27 +0200 Subject: [PATCH 15/19] fix(mcp-server): cast content to typed array + optional chain on tools[0] --- .../src/__tests__/e2e-driver-selfinspect.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts b/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts index 9bd5a1a530..9cfda5a680 100644 --- a/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts +++ b/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts @@ -42,7 +42,8 @@ async function callTool( args: Record, ): Promise> { const result = await client.callTool({ name, arguments: args }) - const item = result.content[0] + const content = result.content as Array<{ type: string; text: string }> + const item = content[0] if (!item || item.type !== "text") { throw new Error(`Expected text content from tool '${name}'; got ${JSON.stringify(result.content)}`) } @@ -170,8 +171,8 @@ tools: const tools = result.tools as Array<{ id: string; description: string }> expect(Array.isArray(tools)).toBe(true) expect(tools).toHaveLength(1) - expect(tools[0].id).toBe("echo") - expect(tools[0].description).toBe("Echo tool for e2e testing") + expect(tools[0]?.id).toBe("echo") + expect(tools[0]?.description).toBe("Echo tool for e2e testing") const routines = result.routines as unknown[] expect(routines).toEqual([]) From bb58f5f82ce438efc90d15f89991d181ea6f624e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 15:25:44 +0200 Subject: [PATCH 16/19] fix(ci): auto-changeset runs only after build passes + remove as-cast - Merge auto-changeset.yml into ci.yml with needs: [build-and-test] so Claude is never called for a broken build - Delete auto-changeset.yml (job now lives in ci.yml) - e2e test: replace `as Array<...>` cast with typed TextContent import from @modelcontextprotocol/sdk Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/auto-changeset.yml | 67 ----------------- .github/workflows/ci.yml | 73 +++++++++++++++++-- .../__tests__/e2e-driver-selfinspect.test.ts | 4 +- 3 files changed, 67 insertions(+), 77 deletions(-) delete mode 100644 .github/workflows/auto-changeset.yml diff --git a/.github/workflows/auto-changeset.yml b/.github/workflows/auto-changeset.yml deleted file mode 100644 index b5eafde124..0000000000 --- a/.github/workflows/auto-changeset.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Auto Changeset - -on: - pull_request: - types: [opened, synchronize] - -# Write access to push the generated changeset back to the branch. -# Only works for PRs from the same repo (not forks) — which is the -# normal case for an internal monorepo. -permissions: - contents: write - -jobs: - auto-changeset: - name: Generate changeset - runs-on: ubuntu-latest - # Skip the "Version Packages" PR that changesets/action opens itself. - if: | - !startsWith(github.event.pull_request.title, 'chore(release):') - - steps: - - name: Checkout branch (with write token) - uses: actions/checkout@v4 - with: - fetch-depth: 0 - # Check out the head of the PR branch so we can push back to it. - ref: ${{ github.head_ref }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Check if changeset already exists - id: check - run: | - ADDED=$(git diff --diff-filter=A --name-only origin/main...HEAD -- '.changeset/*.md' \ - | grep -v '^\.changeset/README\.md$' || true) - if [ -n "$ADDED" ]; then - echo "present=true" >> "$GITHUB_OUTPUT" - echo "✓ Changeset already present: $ADDED" - else - echo "present=false" >> "$GITHUB_OUTPUT" - echo "No changeset found — will auto-generate." - fi - - - name: Setup Node.js - if: steps.check.outputs.present == 'false' - uses: actions/setup-node@v4 - with: - node-version: 22 - - - name: Generate changeset via Claude - if: steps.check.outputs.present == 'false' - run: node scripts/auto-changeset.mjs - env: - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - - - name: Commit generated changeset - if: steps.check.outputs.present == 'false' - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - # Stage only new .changeset/*.md files (not README, not existing ones) - git add '.changeset/*.md' - if git diff --cached --quiet; then - echo "Nothing to commit (no packages changed, changeset not needed)." - else - git commit -m "chore: auto-generate changeset [skip ci]" - git push - fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5d4732bee..bec733fcfd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,9 +46,10 @@ jobs: - name: Run tests run: pnpm test - # On PRs: verify a changeset was added (or the author opted out with - # the "skip changeset" label). This prevents "Version Packages" PRs - # from accidentally shipping without changelog entries. + # On PRs: verify a changeset was added. Quick git-only check that + # runs in parallel with build-and-test to give fast feedback. + # If the changeset is missing, auto-changeset (below) will generate + # one after the build passes — a new CI run then makes this pass. changeset-check: name: Changeset present? runs-on: ubuntu-latest @@ -60,10 +61,6 @@ jobs: fetch-depth: 0 - name: Check for changeset - # Uses git directly — avoids fragile `changeset status` exit codes. - # Passes when a .changeset/*.md file (not README) was added in this - # branch, or when the PR title starts with "chore(release):" (the - # "Version Packages" PR opened by changesets/action itself). run: | TITLE="${{ github.event.pull_request.title }}" if [[ "$TITLE" == chore\(release\):* ]]; then @@ -73,7 +70,67 @@ jobs: ADDED=$(git diff --diff-filter=A --name-only origin/main...HEAD -- '.changeset/*.md' \ | grep -v '^\.changeset/README\.md$' || true) if [ -z "$ADDED" ]; then - echo "No changeset found. Run 'pnpm changeset' and commit the .changeset/*.md file." + echo "No changeset found. Run 'pnpm changeset' or wait for auto-changeset to generate one." exit 1 fi echo "✓ Changeset present: $ADDED" + + # On PRs: auto-generate a changeset via Claude if one is missing. + # Only runs AFTER build-and-test passes — no point generating a + # changeset for a broken build, and avoids wasting API tokens. + # Commits the generated file back to the branch, which triggers a + # new CI run where changeset-check then passes. + auto-changeset: + name: Generate changeset + runs-on: ubuntu-latest + needs: [build-and-test] + if: | + github.event_name == 'pull_request' && + !startsWith(github.event.pull_request.title, 'chore(release):') + permissions: + contents: write # push generated changeset back to the branch + steps: + - name: Checkout branch (with write token) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Check if changeset already exists + id: check + run: | + ADDED=$(git diff --diff-filter=A --name-only origin/main...HEAD -- '.changeset/*.md' \ + | grep -v '^\.changeset/README\.md$' || true) + if [ -n "$ADDED" ]; then + echo "present=true" >> "$GITHUB_OUTPUT" + echo "✓ Changeset already present: $ADDED" + else + echo "present=false" >> "$GITHUB_OUTPUT" + echo "No changeset found — will auto-generate." + fi + + - name: Setup Node.js + if: steps.check.outputs.present == 'false' + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Generate changeset via Claude + if: steps.check.outputs.present == 'false' + run: node scripts/auto-changeset.mjs + env: + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + + - name: Commit generated changeset + if: steps.check.outputs.present == 'false' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add '.changeset/*.md' + if git diff --cached --quiet; then + echo "Nothing to commit (no packages changed, changeset not needed)." + else + git commit -m "chore: auto-generate changeset [skip ci]" + git push + fi diff --git a/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts b/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts index 9cfda5a680..9802b35fa8 100644 --- a/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts +++ b/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts @@ -21,6 +21,7 @@ import { createMcpServer } from "../index.js" import { Client } from "@modelcontextprotocol/sdk/client/index.js" import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js" import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { TextContent } from "@modelcontextprotocol/sdk/types.js" // ── helpers ────────────────────────────────────────────────────────── @@ -42,8 +43,7 @@ async function callTool( args: Record, ): Promise> { const result = await client.callTool({ name, arguments: args }) - const content = result.content as Array<{ type: string; text: string }> - const item = content[0] + const item = result.content[0] as TextContent | undefined if (!item || item.type !== "text") { throw new Error(`Expected text content from tool '${name}'; got ${JSON.stringify(result.content)}`) } From f294afc862626e63e383f8ae07e4c57cee6af488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 15:36:19 +0200 Subject: [PATCH 17/19] fix(mcp-server): narrow result.content through Array.isArray (noUncheckedIndexedAccess + unknown index sig) --- .../src/__tests__/e2e-driver-selfinspect.test.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts b/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts index 9802b35fa8..d27b76a79d 100644 --- a/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts +++ b/packages/mcp-server/src/__tests__/e2e-driver-selfinspect.test.ts @@ -43,9 +43,15 @@ async function callTool( args: Record, ): Promise> { const result = await client.callTool({ name, arguments: args }) - const item = result.content[0] as TextContent | undefined + // `result` has index signature `[x: string]: unknown` so `.content` is unknown. + // Array.isArray narrows unknown → any[], making raw[0] implicitly any. + const raw = result.content + if (!Array.isArray(raw)) { + throw new Error(`Expected array content from tool '${name}'; got ${JSON.stringify(raw)}`) + } + const item: TextContent | undefined = raw[0] if (!item || item.type !== "text") { - throw new Error(`Expected text content from tool '${name}'; got ${JSON.stringify(result.content)}`) + throw new Error(`Expected text content from tool '${name}'; got ${JSON.stringify(raw)}`) } return JSON.parse(item.text) as Record } From 9d92f83d800f3198f5642d45985520fbdef48d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 15:41:09 +0200 Subject: [PATCH 18/19] chore(ci): bump actions to node24 runtimes (checkout@v5, setup-node@v5, pnpm-setup@v6) --- .github/workflows/ci.yml | 12 ++++++------ .github/workflows/release.yml | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bec733fcfd..b245d4f367 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,14 +17,14 @@ jobs: timeout-minutes: 15 steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@v6 # version read from packageManager field in package.json - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: 22 cache: pnpm @@ -56,7 +56,7 @@ jobs: if: github.event_name == 'pull_request' steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 @@ -91,7 +91,7 @@ jobs: contents: write # push generated changeset back to the branch steps: - name: Checkout branch (with write token) - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 ref: ${{ github.head_ref }} @@ -112,7 +112,7 @@ jobs: - name: Setup Node.js if: steps.check.outputs.present == 'false' - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: 22 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1c73810893..592a4f5f6c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,16 +19,16 @@ jobs: timeout-minutes: 20 steps: - name: Checkout (full history for changesets) - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Setup pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@v6 # version read from packageManager field in package.json - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: 22 registry-url: 'https://registry.npmjs.org' From 44192c962f787ef51d712f0c11a849146c7d7897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Andr=C3=A9?= Date: Sat, 20 Jun 2026 17:06:26 +0200 Subject: [PATCH 19/19] chore: replace incomplete changeset with complete self-construction coverage Previous auto-generated changeset only caught @agentproto/corpus. Branch actually changed 8 packages: agent (minor), driver (minor), manifest (minor), mcp-server (minor), cli (patch), corpus (patch), corpus-cli (patch), runtime (patch). Co-Authored-By: Claude Sonnet 4.6 --- .changeset/copper-owls-fix.md | 5 ----- .changeset/self-construction-features.md | 12 ++++++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) delete mode 100644 .changeset/copper-owls-fix.md create mode 100644 .changeset/self-construction-features.md diff --git a/.changeset/copper-owls-fix.md b/.changeset/copper-owls-fix.md deleted file mode 100644 index adbafff029..0000000000 --- a/.changeset/copper-owls-fix.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@agentproto/corpus": patch ---- - -Fix dead code in synthesize.ts — `body.trim()` made `startsWith("\n")` unreachable; always prepend newline for gray-matter frontmatter separator. diff --git a/.changeset/self-construction-features.md b/.changeset/self-construction-features.md new file mode 100644 index 0000000000..2d629aba3a --- /dev/null +++ b/.changeset/self-construction-features.md @@ -0,0 +1,12 @@ +--- +"@agentproto/agent": minor +"@agentproto/driver": minor +"@agentproto/manifest": minor +"@agentproto/mcp-server": minor +"@agentproto/cli": patch +"@agentproto/corpus": patch +"@agentproto/corpus-cli": patch +"@agentproto/runtime": patch +--- + +Add self_inspect MCP tool, extends-chain validation, driver MCP verb, and atomic manifest writes