diff --git a/app/api/board/[[...path]]/route.ts b/app/api/board/[[...path]]/route.ts new file mode 100644 index 000000000..534a9d32e --- /dev/null +++ b/app/api/board/[[...path]]/route.ts @@ -0,0 +1,13 @@ +import { team } from "@/lib/board/team"; + +/** + * Recoup team board receiver. + * + * Answers only what Vercel's API sends this deployment: watcher + * registration and the wake-ups that run its watchers (`POST /api/board/wake`). + * It serves no other callers; people and agents use the board in Vercel's API. + */ +export const GET = team.fetch; +export const POST = team.fetch; + +export const maxDuration = 300; diff --git a/lib/board/__tests__/buildClaudeSandboxEnv.test.ts b/lib/board/__tests__/buildClaudeSandboxEnv.test.ts new file mode 100644 index 000000000..5fbb2423c --- /dev/null +++ b/lib/board/__tests__/buildClaudeSandboxEnv.test.ts @@ -0,0 +1,19 @@ +import { describe, it, expect } from "vitest"; + +import { buildClaudeSandboxEnv } from "@/lib/board/buildClaudeSandboxEnv"; + +describe("buildClaudeSandboxEnv", () => { + const boardEnv = { BOARD_URL: "https://api.vercel.com/board", BOARD_TOKEN: "placeholder" }; + + it("keeps the board's placeholder env", () => { + expect(buildClaudeSandboxEnv(boardEnv)).toMatchObject(boardEnv); + }); + + it("points Claude Code at AI Gateway with only a placeholder token", () => { + const env = buildClaudeSandboxEnv(boardEnv); + expect(env.ANTHROPIC_BASE_URL).toBe("https://ai-gateway.vercel.sh"); + expect(env.ANTHROPIC_AUTH_TOKEN).toBe("brokered-by-sandbox-proxy"); + expect(env.ANTHROPIC_API_KEY).toBe(""); + expect(env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC).toBe("1"); + }); +}); diff --git a/lib/board/__tests__/buildClaudeSandboxNetworkPolicy.test.ts b/lib/board/__tests__/buildClaudeSandboxNetworkPolicy.test.ts new file mode 100644 index 000000000..cc0f89e89 --- /dev/null +++ b/lib/board/__tests__/buildClaudeSandboxNetworkPolicy.test.ts @@ -0,0 +1,45 @@ +import { describe, it, expect } from "vitest"; +import { buildClaudeSandboxNetworkPolicy } from "@/lib/board/buildClaudeSandboxNetworkPolicy"; + +describe("buildClaudeSandboxNetworkPolicy", () => { + const boardAllow = { + "api.vercel.com": [{ transform: [{ headers: { authorization: "Bearer board" } }] }], + }; + + it("allows only the board, npm and AI Gateway", () => { + const policy = buildClaudeSandboxNetworkPolicy({ boardAllow, gatewayToken: "gw" }); + expect(Object.keys(policy.allow).sort()).toEqual( + ["ai-gateway.vercel.sh", "api.vercel.com", "registry.npmjs.org"].sort(), + ); + expect(policy.allow["*"]).toBeUndefined(); + }); + + it("keeps the board's own rules untouched", () => { + const policy = buildClaudeSandboxNetworkPolicy({ boardAllow, gatewayToken: "gw" }); + expect(policy.allow["api.vercel.com"]).toBe(boardAllow["api.vercel.com"]); + }); + + it("passes the board's route matchers and refusals through unchanged", () => { + const scoped = { + "api.vercel.com": [ + { + match: { path: { startsWith: "/v1/messageboard/boards/b1" } }, + transform: [{ headers: { authorization: "Bearer board" } }], + }, + { response: { statusCode: 403 } }, + ], + }; + const policy = buildClaudeSandboxNetworkPolicy({ + boardAllow: scoped as never, + gatewayToken: "gw", + }); + expect(policy.allow["api.vercel.com"]).toEqual(scoped["api.vercel.com"]); + }); + + it("adds the gateway credential on the way out instead of inside the sandbox", () => { + const policy = buildClaudeSandboxNetworkPolicy({ boardAllow, gatewayToken: "gw" }); + expect(policy.allow["ai-gateway.vercel.sh"]).toEqual([ + { transform: [{ headers: { Authorization: "Bearer gw" } }] }, + ]); + }); +}); diff --git a/lib/board/__tests__/buildClaudeSandboxScript.test.ts b/lib/board/__tests__/buildClaudeSandboxScript.test.ts new file mode 100644 index 000000000..ef7dc84ab --- /dev/null +++ b/lib/board/__tests__/buildClaudeSandboxScript.test.ts @@ -0,0 +1,25 @@ +import { describe, it, expect } from "vitest"; +import { buildClaudeSandboxScript } from "@/lib/board/buildClaudeSandboxScript"; + +describe("buildClaudeSandboxScript", () => { + const script = buildClaudeSandboxScript(); + + it("installs vb and Claude Code without global installs", () => { + expect(script).toContain("npm install --prefix"); + expect(script).toContain("@vercel/board@0.52.0"); + expect(script).toContain("@anthropic-ai/claude-code"); + }); + + it("claims, renews and settles the task through vb tasks run", () => { + expect(script).toContain('vb tasks run "$TASK_ID"'); + }); + + it("limits Claude to vb commands", () => { + expect(script).toContain('--allowedTools "Bash(vb:*)"'); + }); + + it("reads the task id and prompt from the environment, not interpolated text", () => { + expect(script).toContain('"$CLAUDE_PROMPT"'); + expect(script).not.toMatch(/\$\{[^}]*\}/); + }); +}); diff --git a/lib/board/__tests__/buildClaudeTaskPrompt.test.ts b/lib/board/__tests__/buildClaudeTaskPrompt.test.ts new file mode 100644 index 000000000..8046ffeb5 --- /dev/null +++ b/lib/board/__tests__/buildClaudeTaskPrompt.test.ts @@ -0,0 +1,20 @@ +import { describe, it, expect } from "vitest"; +import { buildClaudeTaskPrompt } from "@/lib/board/buildClaudeTaskPrompt"; + +describe("buildClaudeTaskPrompt", () => { + const prompt = buildClaudeTaskPrompt({ id: "812", channel: "general" }); + + it("names the task and its channel", () => { + expect(prompt).toContain("#812"); + expect(prompt).toContain("general"); + }); + + it("tells Claude to read the task and reply in its thread", () => { + expect(prompt).toContain("vb read 812"); + expect(prompt).toContain("vb reply 812"); + }); + + it("does not include the task text itself", () => { + expect(prompt).not.toContain("today's date"); + }); +}); diff --git a/lib/board/__tests__/claudeWatcher.test.ts b/lib/board/__tests__/claudeWatcher.test.ts new file mode 100644 index 000000000..e27bcbd98 --- /dev/null +++ b/lib/board/__tests__/claudeWatcher.test.ts @@ -0,0 +1,44 @@ +import { describe, it, expect, vi, beforeEach } from "vitest"; + +import { claudeWatcher } from "@/lib/board/claudeWatcher"; +import { startClaudeForBoardTask } from "@/lib/board/startClaudeForBoardTask"; +import { getClaudeTaskToStart } from "@/lib/board/getClaudeTaskToStart"; + +vi.mock("@/lib/board/startClaudeForBoardTask", () => ({ + startClaudeForBoardTask: vi.fn(), +})); +vi.mock("@/lib/board/getTrustedBoardPrincipals", () => ({ + getTrustedBoardPrincipals: vi.fn(() => ["vercel:user:trusted"]), +})); +vi.mock("@/lib/board/getClaudeTaskToStart", () => ({ + getClaudeTaskToStart: vi.fn(), +})); + +describe("claudeWatcher", () => { + const board = { as: vi.fn() } as never; + const event = { type: "task.created" } as never; + + beforeEach(() => { + vi.clearAllMocks(); + }); + + it("tails threads labeled agent=claude", () => { + expect(claudeWatcher.tail).toBe("--label agent=claude"); + }); + + it("starts Claude for a task the filter accepts", async () => { + vi.mocked(getClaudeTaskToStart).mockReturnValue({ id: "812", channel: "general" }); + await claudeWatcher.run({ event, board }); + expect(getClaudeTaskToStart).toHaveBeenCalledWith(event, ["vercel:user:trusted"]); + expect(startClaudeForBoardTask).toHaveBeenCalledWith({ + board, + task: { id: "812", channel: "general" }, + }); + }); + + it("does nothing for an event the filter rejects", async () => { + vi.mocked(getClaudeTaskToStart).mockReturnValue(null); + await claudeWatcher.run({ event, board }); + expect(startClaudeForBoardTask).not.toHaveBeenCalled(); + }); +}); diff --git a/lib/board/__tests__/getAiGatewayCredential.test.ts b/lib/board/__tests__/getAiGatewayCredential.test.ts new file mode 100644 index 000000000..5294a4dd0 --- /dev/null +++ b/lib/board/__tests__/getAiGatewayCredential.test.ts @@ -0,0 +1,35 @@ +import { describe, it, expect, beforeEach, afterEach } from "vitest"; + +import { getAiGatewayCredential } from "@/lib/board/getAiGatewayCredential"; + +describe("getAiGatewayCredential", () => { + const originalKey = process.env.AI_GATEWAY_API_KEY; + const originalOidc = process.env.VERCEL_OIDC_TOKEN; + + beforeEach(() => { + delete process.env.AI_GATEWAY_API_KEY; + delete process.env.VERCEL_OIDC_TOKEN; + }); + + afterEach(() => { + if (originalKey === undefined) delete process.env.AI_GATEWAY_API_KEY; + else process.env.AI_GATEWAY_API_KEY = originalKey; + if (originalOidc === undefined) delete process.env.VERCEL_OIDC_TOKEN; + else process.env.VERCEL_OIDC_TOKEN = originalOidc; + }); + + it("prefers the AI Gateway API key", () => { + process.env.AI_GATEWAY_API_KEY = "gw-key"; + process.env.VERCEL_OIDC_TOKEN = "oidc"; + expect(getAiGatewayCredential()).toBe("gw-key"); + }); + + it("falls back to the deployment's OIDC token", () => { + process.env.VERCEL_OIDC_TOKEN = "oidc"; + expect(getAiGatewayCredential()).toBe("oidc"); + }); + + it("throws when neither is set", () => { + expect(() => getAiGatewayCredential()).toThrow("No AI Gateway credential"); + }); +}); diff --git a/lib/board/__tests__/getBoardWatchers.test.ts b/lib/board/__tests__/getBoardWatchers.test.ts new file mode 100644 index 000000000..576538117 --- /dev/null +++ b/lib/board/__tests__/getBoardWatchers.test.ts @@ -0,0 +1,27 @@ +import { describe, it, expect, afterEach, vi } from "vitest"; + +import { getBoardWatchers } from "@/lib/board/getBoardWatchers"; + +vi.mock("@/lib/board/claudeWatcher", () => ({ + claudeWatcher: { tail: "--label agent=claude", run: vi.fn() }, +})); + +describe("getBoardWatchers", () => { + const original = process.env.VERCEL_ENV; + + afterEach(() => { + if (original === undefined) delete process.env.VERCEL_ENV; + else process.env.VERCEL_ENV = original; + }); + + it("registers the claude watcher in production", () => { + process.env.VERCEL_ENV = "production"; + expect(Object.keys(getBoardWatchers())).toEqual(["claude"]); + }); + + it.each(["preview", "development", undefined])("registers nothing in %s", env => { + if (env === undefined) delete process.env.VERCEL_ENV; + else process.env.VERCEL_ENV = env; + expect(getBoardWatchers()).toEqual({}); + }); +}); diff --git a/lib/board/__tests__/getClaudeTaskToStart.test.ts b/lib/board/__tests__/getClaudeTaskToStart.test.ts new file mode 100644 index 000000000..849b5cb2c --- /dev/null +++ b/lib/board/__tests__/getClaudeTaskToStart.test.ts @@ -0,0 +1,111 @@ +import { describe, it, expect } from "vitest"; +import { getClaudeTaskToStart } from "@/lib/board/getClaudeTaskToStart"; + +const TRUSTED = ["vercel:user:trusted"]; + +const buildEvent = (overrides: Record = {}, task: Record = {}) => + ({ + cursor: "c1", + type: "task.created", + createdAt: "2026-11-20T00:00:00.000Z", + payload: {}, + message: { + id: "812", + re: null, + channel: "general", + text: "what is today's date?", + labels: { agent: "claude" }, + task: { + state: "ready", + owner: "vercel:user:trusted", + by: "vercel:user:trusted", + for: null, + needs: [], + epoch: 0, + claim: null, + blocked: null, + result: null, + reason: null, + ...task, + }, + }, + ...overrides, + }) as never; + +describe("getClaudeTaskToStart", () => { + describe("starts Claude", () => { + it.each(["task.created", "task.ready", "task.reopened"])( + "for %s on a ready, unclaimed task from a trusted owner", + type => { + expect(getClaudeTaskToStart(buildEvent({ type }), TRUSTED)).toEqual({ + id: "812", + channel: "general", + }); + }, + ); + + it("when agent=claude is set on an existing ready task", () => { + const event = buildEvent({ + type: "labels.changed", + payload: { set: { agent: "claude" }, unset: [] }, + }); + expect(getClaudeTaskToStart(event, TRUSTED)).toEqual({ id: "812", channel: "general" }); + }); + }); + + describe("ignores the event", () => { + it("when the owner is not trusted", () => { + const event = buildEvent({}, { owner: "vercel:user:stranger" }); + expect(getClaudeTaskToStart(event, TRUSTED)).toBeNull(); + }); + + it("when no owner is trusted", () => { + expect(getClaudeTaskToStart(buildEvent(), [])).toBeNull(); + }); + + it("for other event types", () => { + for (const type of ["message.posted", "task.claimed", "task.completed", "reaction.added"]) { + expect(getClaudeTaskToStart(buildEvent({ type }), TRUSTED)).toBeNull(); + } + }); + + it("for a label change that does not set agent=claude", () => { + const event = buildEvent({ + type: "labels.changed", + payload: { set: { state: "done" }, unset: [] }, + }); + expect(getClaudeTaskToStart(event, TRUSTED)).toBeNull(); + }); + + it("when the thread no longer carries agent=claude", () => { + const event = buildEvent(); + (event as { message: { labels: Record } }).message.labels = {}; + expect(getClaudeTaskToStart(event, TRUSTED)).toBeNull(); + }); + + it("for a reply rather than a root", () => { + const event = buildEvent(); + (event as { message: { re: string | null } }).message.re = "800"; + expect(getClaudeTaskToStart(event, TRUSTED)).toBeNull(); + }); + + it("when the message is not a task", () => { + const event = buildEvent(); + delete (event as { message: { task?: unknown } }).message.task; + expect(getClaudeTaskToStart(event, TRUSTED)).toBeNull(); + }); + + it("when the task is not ready", () => { + expect(getClaudeTaskToStart(buildEvent({}, { state: "waiting" }), TRUSTED)).toBeNull(); + }); + + it("when the task is already claimed", () => { + const event = buildEvent({}, { claim: { actor: "x", until: "2026-11-20T00:05:00.000Z" } }); + expect(getClaudeTaskToStart(event, TRUSTED)).toBeNull(); + }); + + it("when the event has no message", () => { + expect(getClaudeTaskToStart(buildEvent({ message: undefined }), TRUSTED)).toBeNull(); + }); + }); +}); diff --git a/lib/board/__tests__/getTrustedBoardPrincipals.test.ts b/lib/board/__tests__/getTrustedBoardPrincipals.test.ts new file mode 100644 index 000000000..afc966d09 --- /dev/null +++ b/lib/board/__tests__/getTrustedBoardPrincipals.test.ts @@ -0,0 +1,21 @@ +import { describe, it, expect, afterEach } from "vitest"; +import { getTrustedBoardPrincipals } from "@/lib/board/getTrustedBoardPrincipals"; + +describe("getTrustedBoardPrincipals", () => { + const original = process.env.BOARD_TRUSTED_PRINCIPALS; + + afterEach(() => { + if (original === undefined) delete process.env.BOARD_TRUSTED_PRINCIPALS; + else process.env.BOARD_TRUSTED_PRINCIPALS = original; + }); + + it("returns no principals when the variable is unset", () => { + delete process.env.BOARD_TRUSTED_PRINCIPALS; + expect(getTrustedBoardPrincipals()).toEqual([]); + }); + + it("splits, trims and drops empty entries", () => { + process.env.BOARD_TRUSTED_PRINCIPALS = " vercel:user:abc , ,vercel:user:def "; + expect(getTrustedBoardPrincipals()).toEqual(["vercel:user:abc", "vercel:user:def"]); + }); +}); diff --git a/lib/board/__tests__/startClaudeForBoardTask.test.ts b/lib/board/__tests__/startClaudeForBoardTask.test.ts new file mode 100644 index 000000000..19a2ccedf --- /dev/null +++ b/lib/board/__tests__/startClaudeForBoardTask.test.ts @@ -0,0 +1,85 @@ +import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; + +import { Sandbox } from "vercel-sandbox-3"; +import { startClaudeForBoardTask } from "@/lib/board/startClaudeForBoardTask"; + +const { runCommand } = vi.hoisted(() => ({ runCommand: vi.fn() })); +vi.mock("vercel-sandbox-3", () => ({ + Sandbox: { create: vi.fn(async () => ({ runCommand })) }, +})); + +describe("startClaudeForBoardTask", () => { + const sandboxPolicy = vi.fn(async () => ({ + allow: { "api.vercel.com": [] }, + env: { BOARD_URL: "https://api.vercel.com/board", BOARD_TOKEN: "placeholder" }, + })); + const as = vi.fn(() => ({ sandboxPolicy })); + const board = { as } as never; + const task = { id: "812", channel: "general" }; + const originalKey = process.env.AI_GATEWAY_API_KEY; + const originalOidc = process.env.VERCEL_OIDC_TOKEN; + + beforeEach(() => { + vi.clearAllMocks(); + process.env.AI_GATEWAY_API_KEY = "gw-key"; + }); + + afterEach(() => { + if (originalKey === undefined) delete process.env.AI_GATEWAY_API_KEY; + else process.env.AI_GATEWAY_API_KEY = originalKey; + if (originalOidc === undefined) delete process.env.VERCEL_OIDC_TOKEN; + else process.env.VERCEL_OIDC_TOKEN = originalOidc; + }); + + it("gives the sandbox the board as claude, narrowed to the task's channel", async () => { + await startClaudeForBoardTask({ board, task }); + expect(as).toHaveBeenCalledWith({ name: "claude" }); + expect(sandboxPolicy).toHaveBeenCalledWith({ + can: { general: ["read", "post", "react", "label"] }, + }); + }); + + it("creates the sandbox with the brokered policy and no real credential in its env", async () => { + await startClaudeForBoardTask({ board, task }); + const params = vi.mocked(Sandbox.create).mock.calls[0][0] as { + networkPolicy: { allow: Record }; + env: Record; + }; + expect(Object.keys(params.networkPolicy.allow)).toContain("ai-gateway.vercel.sh"); + expect(params.env.BOARD_TOKEN).toBe("placeholder"); + expect(params.env.ANTHROPIC_BASE_URL).toBe("https://ai-gateway.vercel.sh"); + expect(Object.values(params.env)).not.toContain("gw-key"); + }); + + it("runs the agent detached with the task id and prompt as environment", async () => { + await startClaudeForBoardTask({ board, task }); + const call = runCommand.mock.calls[0][0] as { + cmd: string; + detached: boolean; + env: Record; + }; + expect(call.cmd).toBe("bash"); + expect(call.detached).toBe(true); + expect(call.env.TASK_ID).toBe("812"); + expect(call.env.CLAUDE_PROMPT).toContain("vb read 812"); + }); + + it("falls back to the deployment's OIDC token for AI Gateway", async () => { + delete process.env.AI_GATEWAY_API_KEY; + process.env.VERCEL_OIDC_TOKEN = "oidc"; + await startClaudeForBoardTask({ board, task }); + const params = vi.mocked(Sandbox.create).mock.calls[0][0] as { + networkPolicy: { allow: Record }; + }; + expect(params.networkPolicy.allow["ai-gateway.vercel.sh"]).toEqual([ + { transform: [{ headers: { Authorization: "Bearer oidc" } }] }, + ]); + }); + + it("throws without starting a sandbox when no gateway credential exists", async () => { + delete process.env.AI_GATEWAY_API_KEY; + delete process.env.VERCEL_OIDC_TOKEN; + await expect(startClaudeForBoardTask({ board, task })).rejects.toThrow(/AI Gateway/); + expect(Sandbox.create).not.toHaveBeenCalled(); + }); +}); diff --git a/lib/board/aiGatewayHost.ts b/lib/board/aiGatewayHost.ts new file mode 100644 index 000000000..7bbd0ba14 --- /dev/null +++ b/lib/board/aiGatewayHost.ts @@ -0,0 +1,2 @@ +/** The AI Gateway host Claude Code reaches through its Anthropic-compatible API. */ +export const AI_GATEWAY_HOST = "ai-gateway.vercel.sh"; diff --git a/lib/board/buildClaudeSandboxEnv.ts b/lib/board/buildClaudeSandboxEnv.ts new file mode 100644 index 000000000..9dc3cc279 --- /dev/null +++ b/lib/board/buildClaudeSandboxEnv.ts @@ -0,0 +1,21 @@ +import { AI_GATEWAY_HOST } from "@/lib/board/aiGatewayHost"; + +/** Placeholder the sandbox proxy replaces with the real gateway credential. */ +const BROKERED_TOKEN_PLACEHOLDER = "brokered-by-sandbox-proxy"; + +/** + * Builds the sandbox environment for Claude Code: the board's placeholder env + * plus AI Gateway settings. No real credential appears here. + * + * @param boardEnv - The env returned by the board's `sandboxPolicy()`. + * @returns The sandbox environment. + */ +export function buildClaudeSandboxEnv(boardEnv: Record): Record { + return { + ...boardEnv, + ANTHROPIC_BASE_URL: `https://${AI_GATEWAY_HOST}`, + ANTHROPIC_AUTH_TOKEN: BROKERED_TOKEN_PLACEHOLDER, + ANTHROPIC_API_KEY: "", + CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1", + }; +} diff --git a/lib/board/buildClaudeSandboxNetworkPolicy.ts b/lib/board/buildClaudeSandboxNetworkPolicy.ts new file mode 100644 index 000000000..4ed31e528 --- /dev/null +++ b/lib/board/buildClaudeSandboxNetworkPolicy.ts @@ -0,0 +1,34 @@ +import type { NetworkPolicyRule } from "vercel-sandbox-3"; + +import { AI_GATEWAY_HOST } from "@/lib/board/aiGatewayHost"; +const NPM_REGISTRY_HOST = "registry.npmjs.org"; + +type ClaudeSandboxNetworkPolicy = { allow: Record }; + +/** + * Builds the network policy for Claude's board sandbox: the board's own + * routes from `sandboxPolicy()`, npm to install vb and Claude Code, and AI + * Gateway. The gateway credential is added by the sandbox proxy on the way + * out, so it never enters the sandbox. Every other host is blocked. + * + * @param params.boardAllow - The `allow` map `sandboxPolicy()` returned. + * @param params.gatewayToken - AI Gateway key or the deployment's OIDC token. + * @returns The sandbox network policy. + */ +export function buildClaudeSandboxNetworkPolicy({ + boardAllow, + gatewayToken, +}: { + boardAllow: Record; + gatewayToken: string; +}): ClaudeSandboxNetworkPolicy { + return { + allow: { + ...boardAllow, + [NPM_REGISTRY_HOST]: [], + [AI_GATEWAY_HOST]: [ + { transform: [{ headers: { Authorization: `Bearer ${gatewayToken}` } }] }, + ], + }, + }; +} diff --git a/lib/board/buildClaudeSandboxScript.ts b/lib/board/buildClaudeSandboxScript.ts new file mode 100644 index 000000000..ee44a48e6 --- /dev/null +++ b/lib/board/buildClaudeSandboxScript.ts @@ -0,0 +1,20 @@ +const AGENT_PREFIX = "/tmp/board-agent"; + +/** + * Builds the shell script Claude's board sandbox runs. It installs vb and + * Claude Code under a local prefix, then lets `vb tasks run` claim the task + * by ID, renew its lease, and settle it by Claude's exit code. The task ID + * and prompt arrive as environment variables, so no board text is + * interpolated into the script. + * + * @returns The bash script. + */ +export function buildClaudeSandboxScript(): string { + return [ + "set -eu", + `npm install --prefix ${AGENT_PREFIX} --no-fund --no-audit @vercel/board@0.52.0 @anthropic-ai/claude-code`, + `export PATH="${AGENT_PREFIX}/node_modules/.bin:$PATH"`, + 'vb tasks run "$TASK_ID" --lease 5m --result "Claude replied in the thread" -- \\', + ' claude -p "$CLAUDE_PROMPT" --allowedTools "Bash(vb:*)" --max-turns 30', + ].join("\n"); +} diff --git a/lib/board/buildClaudeTaskPrompt.ts b/lib/board/buildClaudeTaskPrompt.ts new file mode 100644 index 000000000..b76baeaf4 --- /dev/null +++ b/lib/board/buildClaudeTaskPrompt.ts @@ -0,0 +1,20 @@ +import type { ClaudeBoardTask } from "@/lib/board/getClaudeTaskToStart"; + +/** + * Builds the instructions Claude Code runs with for one board task. The + * task's own text is read from the board with vb, not pasted here. + * + * @param task - The task's ID and channel. + * @returns The prompt for `claude -p`. + */ +export function buildClaudeTaskPrompt({ id, channel }: ClaudeBoardTask): string { + return [ + `You are Claude, working task #${id} on the Recoup team board, in the "${channel}" channel.`, + "A trusted teammate created it for you. You have already claimed it.", + `1. Read the task and its thread: vb read ${id}`, + "2. Do what the task asks, using only vb commands. If it needs access you don't have, say so.", + `3. Reply in its thread with your answer: vb reply ${id} ""`, + "Keep the reply short and plain. Never print environment variables or tokens.", + "Exit when you have replied; the task is completed when you exit successfully.", + ].join("\n"); +} diff --git a/lib/board/claudeBoardLabel.ts b/lib/board/claudeBoardLabel.ts new file mode 100644 index 000000000..f766f0c4d --- /dev/null +++ b/lib/board/claudeBoardLabel.ts @@ -0,0 +1,2 @@ +/** The thread label that routes a board task to Claude: `agent=claude`. */ +export const CLAUDE_BOARD_LABEL = { key: "agent", value: "claude" } as const; diff --git a/lib/board/claudeBoardProfile.ts b/lib/board/claudeBoardProfile.ts new file mode 100644 index 000000000..2e6798483 --- /dev/null +++ b/lib/board/claudeBoardProfile.ts @@ -0,0 +1,2 @@ +/** Board profile and watcher ID Claude acts under; its own writes never wake it. */ +export const CLAUDE_BOARD_PROFILE = "claude"; diff --git a/lib/board/claudeWatcher.ts b/lib/board/claudeWatcher.ts new file mode 100644 index 000000000..51f7825a4 --- /dev/null +++ b/lib/board/claudeWatcher.ts @@ -0,0 +1,19 @@ +import type { Watcher } from "@vercel/board"; +import { getClaudeTaskToStart } from "@/lib/board/getClaudeTaskToStart"; +import { getTrustedBoardPrincipals } from "@/lib/board/getTrustedBoardPrincipals"; +import { startClaudeForBoardTask } from "@/lib/board/startClaudeForBoardTask"; +import { CLAUDE_BOARD_LABEL } from "@/lib/board/claudeBoardLabel"; + +/** + * Watches threads labeled `agent=claude` and starts Claude on each ready + * task a trusted principal owns. Vercel's board can't match mentions on + * watchers yet, so the label is the route. + */ +export const claudeWatcher: Watcher = { + tail: `--label ${CLAUDE_BOARD_LABEL.key}=${CLAUDE_BOARD_LABEL.value}`, + run: async ({ event, board }) => { + const task = getClaudeTaskToStart(event, getTrustedBoardPrincipals()); + if (!task) return; + await startClaudeForBoardTask({ board, task }); + }, +}; diff --git a/lib/board/getAiGatewayCredential.ts b/lib/board/getAiGatewayCredential.ts new file mode 100644 index 000000000..abb4e9470 --- /dev/null +++ b/lib/board/getAiGatewayCredential.ts @@ -0,0 +1,13 @@ +/** + * Returns the credential the sandbox proxy adds to AI Gateway requests: the + * AI Gateway API key, else the deployment's OIDC token. + * + * @returns The credential. It never enters the sandbox. + */ +export function getAiGatewayCredential(): string { + const credential = process.env.AI_GATEWAY_API_KEY || process.env.VERCEL_OIDC_TOKEN; + if (!credential) { + throw new Error("No AI Gateway credential: set AI_GATEWAY_API_KEY or enable OIDC"); + } + return credential; +} diff --git a/lib/board/getBoardWatchers.ts b/lib/board/getBoardWatchers.ts new file mode 100644 index 000000000..893c9b117 --- /dev/null +++ b/lib/board/getBoardWatchers.ts @@ -0,0 +1,15 @@ +import type { Watcher } from "@vercel/board"; +import { claudeWatcher } from "@/lib/board/claudeWatcher"; +import { CLAUDE_BOARD_PROFILE } from "@/lib/board/claudeBoardProfile"; + +/** + * Returns the watchers this deployment registers on the team board. Only + * production registers any: previews register their watchers too, and each + * would start its own agent run for the same task. + * + * @returns Watchers keyed by ID, which is also the profile their writes use. + */ +export function getBoardWatchers(): Record { + if (process.env.VERCEL_ENV !== "production") return {}; + return { [CLAUDE_BOARD_PROFILE]: claudeWatcher }; +} diff --git a/lib/board/getClaudeTaskToStart.ts b/lib/board/getClaudeTaskToStart.ts new file mode 100644 index 000000000..6fb702b0d --- /dev/null +++ b/lib/board/getClaudeTaskToStart.ts @@ -0,0 +1,39 @@ +import type { WatcherContext } from "@vercel/board"; +import { CLAUDE_BOARD_LABEL } from "@/lib/board/claudeBoardLabel"; + +export type ClaudeBoardTask = { id: string; channel: string }; + +const TASK_EVENTS = new Set(["task.created", "task.ready", "task.reopened"]); + +/** + * Decides whether a board event should start Claude on a task. Only a root + * task labeled `agent=claude`, ready and unclaimed, whose owner is a trusted + * principal qualifies, because a task's text is instructions for whoever + * claims it. + * + * @param event - The event a watcher received. + * @param trustedPrincipals - Principal IDs allowed to hand Claude work. + * @returns The task to start, or null to ignore the event. + */ +export function getClaudeTaskToStart( + event: WatcherContext["event"], + trustedPrincipals: string[], +): ClaudeBoardTask | null { + const message = event.message; + if (!message || message.re !== null || !message.task) return null; + + const isTaskEvent = TASK_EVENTS.has(event.type); + const labeledNow = + event.type === "labels.changed" && + (event.payload as { set?: Record }).set?.[CLAUDE_BOARD_LABEL.key] === + CLAUDE_BOARD_LABEL.value; + if (!isTaskEvent && !labeledNow) return null; + + if (message.labels?.[CLAUDE_BOARD_LABEL.key] !== CLAUDE_BOARD_LABEL.value) return null; + + const { task } = message; + if (task.state !== "ready" || task.claim !== null) return null; + if (!trustedPrincipals.includes(task.owner)) return null; + + return { id: message.id, channel: message.channel }; +} diff --git a/lib/board/getTrustedBoardPrincipals.ts b/lib/board/getTrustedBoardPrincipals.ts new file mode 100644 index 000000000..3079cebdd --- /dev/null +++ b/lib/board/getTrustedBoardPrincipals.ts @@ -0,0 +1,13 @@ +/** + * Reads the board principals whose tasks may start Claude, from the + * comma-separated BOARD_TRUSTED_PRINCIPALS variable. An unset or empty + * variable trusts nobody, so no task starts an agent. + * + * @returns Principal IDs, as `vb actors` lists them. + */ +export function getTrustedBoardPrincipals(): string[] { + return (process.env.BOARD_TRUSTED_PRINCIPALS ?? "") + .split(",") + .map(principal => principal.trim()) + .filter(Boolean); +} diff --git a/lib/board/startClaudeForBoardTask.ts b/lib/board/startClaudeForBoardTask.ts new file mode 100644 index 000000000..30bf3e58e --- /dev/null +++ b/lib/board/startClaudeForBoardTask.ts @@ -0,0 +1,47 @@ +import { Sandbox } from "vercel-sandbox-3"; +import type { WatcherContext } from "@vercel/board"; +import type { ClaudeBoardTask } from "@/lib/board/getClaudeTaskToStart"; +import { buildClaudeSandboxNetworkPolicy } from "@/lib/board/buildClaudeSandboxNetworkPolicy"; +import { buildClaudeTaskPrompt } from "@/lib/board/buildClaudeTaskPrompt"; +import { buildClaudeSandboxScript } from "@/lib/board/buildClaudeSandboxScript"; +import { CLAUDE_BOARD_PROFILE } from "@/lib/board/claudeBoardProfile"; +import { getAiGatewayCredential } from "@/lib/board/getAiGatewayCredential"; +import { buildClaudeSandboxEnv } from "@/lib/board/buildClaudeSandboxEnv"; + +const SANDBOX_TIMEOUT_MS = 15 * 60 * 1000; + +/** + * Starts Claude Code in a Vercel Sandbox to work one board task. The sandbox + * reaches the board as `claude via api`, narrowed to the task's channel, and + * neither the board credential nor the AI Gateway credential enters it. + * The agent runs detached, so the watcher's request returns quickly. + * + * @param params.board - The board handle the watcher was given. + * @param params.task - The task to work. + */ +export async function startClaudeForBoardTask({ + board, + task, +}: { + board: WatcherContext["board"]; + task: ClaudeBoardTask; +}): Promise { + const gatewayToken = getAiGatewayCredential(); + const { allow, env } = await board + .as({ name: CLAUDE_BOARD_PROFILE }) + .sandboxPolicy({ can: { [task.channel]: ["read", "post", "react", "label"] } }); + + const sandbox = await Sandbox.create({ + runtime: "node22", + timeout: SANDBOX_TIMEOUT_MS, + networkPolicy: buildClaudeSandboxNetworkPolicy({ boardAllow: allow, gatewayToken }), + env: buildClaudeSandboxEnv(env), + }); + + await sandbox.runCommand({ + cmd: "bash", + args: ["-c", buildClaudeSandboxScript()], + env: { TASK_ID: task.id, CLAUDE_PROMPT: buildClaudeTaskPrompt(task) }, + detached: true, + }); +} diff --git a/lib/board/team.ts b/lib/board/team.ts new file mode 100644 index 000000000..baefb6403 --- /dev/null +++ b/lib/board/team.ts @@ -0,0 +1,5 @@ +import { board } from "@vercel/board"; +import { getBoardWatchers } from "@/lib/board/getBoardWatchers"; + +/** Recoup's team board in Vercel's API, with this deployment's watchers. */ +export const team = board({ watch: getBoardWatchers() }); diff --git a/package.json b/package.json index 8cf4122df..ab3244c1f 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "@supabase/supabase-js": "^2.86.0", "@trigger.dev/sdk": "^4.4.3", "@vercel/blob": "^2.3.1", + "@vercel/board": "0.52.0", "@vercel/sandbox": "2.0.0-beta.11", "@workflow/core": "4.2.4", "ai": "6.0.190", @@ -83,6 +84,7 @@ "stripe": "^17.4.0", "unpdf": "^1.9.1", "uuid": "^14.0.0", + "vercel-sandbox-3": "npm:@vercel/sandbox@3.9.1", "viem": "^2.21.26", "workflow": "^4.2.4", "x402-fetch": "^0.7.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5501408b1..8a6321c3e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -65,6 +65,9 @@ importers: '@vercel/blob': specifier: ^2.3.1 version: 2.3.1 + '@vercel/board': + specifier: 0.52.0 + version: 0.52.0(@chat-adapter/github@4.15.0)(@chat-adapter/slack@4.15.0)(chat@4.15.0) '@vercel/sandbox': specifier: 2.0.0-beta.11 version: 2.0.0-beta.11 @@ -161,6 +164,9 @@ importers: uuid: specifier: ^14.0.0 version: 14.0.0 + vercel-sandbox-3: + specifier: npm:@vercel/sandbox@3.9.1 + version: '@vercel/sandbox@3.9.1' viem: specifier: ^2.21.26 version: 2.40.3(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.1.13) @@ -3380,9 +3386,42 @@ packages: resolution: {integrity: sha512-6f9oWC+DbWxIgBLOdqjjn2/REpFrPDB7y5B5HA1ptYkzZaBgL6E34kWrptJvJ7teApJdbAs3I1a5A7z1y8SDHw==} engines: {node: '>=20.0.0'} + '@vercel/board@0.52.0': + resolution: {integrity: sha512-ARsgjNfQaKgAE8Pbwu+aP4IbMpCaiZNcwQYSiBHRDPODpgE+kQQbtjkIWHTjTg7jUrvCi9rPHW8qozhnGzfqfQ==} + engines: {node: '>=22.18'} + hasBin: true + peerDependencies: + '@chat-adapter/github': ^4.41.1 + '@chat-adapter/linear': ^4.41.1 + '@chat-adapter/slack': ^4.41.1 + '@vercel/connect': ^2.3.4 + chat: ^4.41.1 + peerDependenciesMeta: + '@chat-adapter/github': + optional: true + '@chat-adapter/linear': + optional: true + '@chat-adapter/slack': + optional: true + '@vercel/connect': + optional: true + chat: + optional: true + '@vercel/cli-auth@0.0.1': resolution: {integrity: sha512-CnqiuMlZ4pjs2LCPYiR6aLKPPd3Xb8SBI1Y7eotXKgpx6qgrGNY+E7EIyUt5ErGHJGIrCZyGG5WEo4bHtVmz2Q==} + '@vercel/cli-config@0.3.1': + resolution: {integrity: sha512-sISbygqlFXYb8qfPu/+2Cf/A8IjrlAuZePdag3EDQr2PRA455s7UZtl9Ro674CWsB/saBRmz3jEkw0YsQs8OoQ==} + + '@vercel/cli-exec@1.0.1': + resolution: {integrity: sha512-g9XerViJ/paZujufXYcu5XYI2vU2rtB4sgdpjUHde5RnOkdmpu0ngH46LCFGHoPXO/C+qDPSczIHIRN+8Q2YKQ==} + engines: {node: '>= 18'} + + '@vercel/detect-agent@1.2.5': + resolution: {integrity: sha512-0krENrjuitlW8s6TJu0MlqCevyCU7K7JK63jZAf7xZ6n17tx+vUEwzHT3sTxawtwZxaW21hu+oFUpoOrm49FsQ==} + engines: {node: '>=14'} + '@vercel/functions@1.6.0': resolution: {integrity: sha512-R6FKQrYT5MZs5IE1SqeCJWxMuBdHawFcCZboKKw8p7s+6/mcd55Gx6tWmyKnQTyrSEA04NH73Tc9CbqpEle8RA==} engines: {node: '>= 16'} @@ -3409,6 +3448,14 @@ packages: resolution: {integrity: sha512-p0sKfHkfRmMaqqDwNL4tjnX9TgRrLMlEtUjIxfrEns8pOxz1R9ztqOVI+ehqiq93/2/HnfPe/UBZkfAZwnx0UA==} engines: {node: '>= 20'} + '@vercel/oidc@3.8.10': + resolution: {integrity: sha512-sPw1kIfQEA6/2dB+zlAJHnhhNBRJ8t/t4HfFvKO+g0EPBA7NbCKyGovuhgAV6Mnl865ka7HqCEguIy596czdAw==} + engines: {node: '>= 20'} + + '@vercel/oidc@4.0.0': + resolution: {integrity: sha512-ko6ATeRUlHZMB5hLFdC7+/Q1dI2f3NX3gZHxtpALdkxurwjD5HFHGWYF+4o+4SF0E47jg6KzcHknmRpHcKgJ5A==} + engines: {node: '>= 20'} + '@vercel/queue@0.1.4': resolution: {integrity: sha512-wo+jCycmCX078vQSbkX+RcLvySONDCK0f9aQp5UMKQD1+B+xKt3YVbIYbZukvoHQpbm5nnk6If+ADSeK/PmCgQ==} engines: {node: '>=20.0.0'} @@ -3416,6 +3463,9 @@ packages: '@vercel/sandbox@2.0.0-beta.11': resolution: {integrity: sha512-92B4b3cgUIR9CTGsGlIgy7UIrdyqIqQQom8U8YD10m5lXbjbZrf/tU7Rt+S+Vy0hlI94hKVjPkx7U+fPyBtpNA==} + '@vercel/sandbox@3.9.1': + resolution: {integrity: sha512-8/3vqPknI2WrE1Zd4O3LbMFbrD9elCXqCe0JjqSJH+EqsEtBHGafwwxx1raq1kTWvpLLk4lh0bZW9dMy6L5efA==} + '@vitest/expect@3.2.4': resolution: {integrity: sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==} @@ -4932,6 +4982,10 @@ packages: evt@2.5.9: resolution: {integrity: sha512-GpjX476FSlttEGWHT8BdVMoI8wGXQGbEOtKcP4E+kggg+yJzXBZN2n4x7TS/zPBJ1DZqWI+rguZZApjjzQ0HpA==} + execa@5.1.1: + resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} + engines: {node: '>=10'} + execa@8.0.1: resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} engines: {node: '>=16.17'} @@ -5224,6 +5278,10 @@ packages: resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} engines: {node: '>= 0.4'} + get-stream@6.0.1: + resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} + engines: {node: '>=10'} + get-stream@8.0.1: resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} engines: {node: '>=16'} @@ -5354,6 +5412,10 @@ packages: resolution: {integrity: sha512-V5nVw1PAOgfI3Lmeaj2Exmeg7fenjhRUgz1lPSezy1CuhPYbgQtbQj4jZfEAEMlaL+vupsvhjqCyjzob0yxsmQ==} engines: {node: '>=10.19.0'} + human-signals@2.1.0: + resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} + engines: {node: '>=10.17.0'} + human-signals@5.0.0: resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} engines: {node: '>=16.17.0'} @@ -5699,6 +5761,9 @@ packages: jose@6.2.12: resolution: {integrity: sha512-9NiFmJEex0sy2Dk58j2UGBSHgUs2ypF9eZSu4L6vjOX3Dp96Sw1F3uL+H+D1sx02jZZdzUT0HgvCy59CuvXcWw==} + jose@6.2.3: + resolution: {integrity: sha512-YYVDInQKFJfR/xa3ojUTl8c2KoTwiL1R5Wg9YCydwH0x0B9grbzlg5HC7mMjCtUJjbQ/YnGEZIhI5tCgfTb4Hw==} + js-levenshtein@1.1.6: resolution: {integrity: sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==} engines: {node: '>=0.10.0'} @@ -6092,6 +6157,10 @@ packages: engines: {node: '>=4'} hasBin: true + mimic-fn@2.1.0: + resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} + engines: {node: '>=6'} + mimic-fn@4.0.0: resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} engines: {node: '>=12'} @@ -6287,6 +6356,10 @@ packages: resolution: {integrity: sha512-JYc0DPlpGWB40kH5g07gGTrYuMqV653k3uBKY6uITPWds3M0ov3GaWGp9lbE3Bzngx8+XkfzgvASb9vk9JDFXQ==} engines: {node: '>=14.16'} + npm-run-path@4.0.1: + resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} + engines: {node: '>=8'} + npm-run-path@5.3.0: resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -6352,6 +6425,10 @@ packages: once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + onetime@5.1.2: + resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} + engines: {node: '>=6'} + onetime@6.0.0: resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} engines: {node: '>=12'} @@ -7198,6 +7275,9 @@ packages: siginfo@2.0.0: resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} + signal-exit@3.0.7: + resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} + signal-exit@4.1.0: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} @@ -7362,6 +7442,10 @@ packages: strip-dirs@3.0.0: resolution: {integrity: sha512-I0sdgcFTfKQlUPZyAqPJmSG3HLO9rWDFnxonnIbskYNM3DwFOeTNB5KzVq3dA1GdRAc/25b5Y7UO2TQfKWw4aQ==} + strip-final-newline@2.0.0: + resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} + engines: {node: '>=6'} + strip-final-newline@3.0.0: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} @@ -8273,6 +8357,9 @@ packages: zod@4.4.3: resolution: {integrity: sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==} + zod@4.6.7: + resolution: {integrity: sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==} + zustand@5.0.0: resolution: {integrity: sha512-LE+VcmbartOPM+auOjCCLQOsQ05zUTp8RkgwRzefUk+2jISdMMFnxvyTjA4YNWr5ZGXYbVsEMZosttuxUBkojQ==} engines: {node: '>=12.20.0'} @@ -12252,6 +12339,16 @@ snapshots: throttleit: 2.1.0 undici: 6.24.1 + '@vercel/board@0.52.0(@chat-adapter/github@4.15.0)(@chat-adapter/slack@4.15.0)(chat@4.15.0)': + dependencies: + '@vercel/oidc': 3.8.10 + jose: 6.2.12 + zod: 4.6.7 + optionalDependencies: + '@chat-adapter/github': 4.15.0 + '@chat-adapter/slack': 4.15.0 + chat: 4.15.0 + '@vercel/cli-auth@0.0.1': dependencies: async-listen: 3.0.0 @@ -12259,6 +12356,17 @@ snapshots: xdg-app-paths: 5.1.0 zod: 4.1.11 + '@vercel/cli-config@0.3.1': + dependencies: + xdg-app-paths: 5.1.0 + zod: 4.1.11 + + '@vercel/cli-exec@1.0.1': + dependencies: + execa: 5.1.1 + + '@vercel/detect-agent@1.2.5': {} + '@vercel/functions@1.6.0(@aws-sdk/credential-provider-web-identity@3.972.13)': optionalDependencies: '@aws-sdk/credential-provider-web-identity': 3.972.13 @@ -12273,9 +12381,21 @@ snapshots: '@vercel/oidc@3.4.0': {} + '@vercel/oidc@3.8.10': + dependencies: + '@vercel/cli-config': 0.3.1 + '@vercel/cli-exec': 1.0.1 + jose: 5.10.0 + + '@vercel/oidc@4.0.0': + dependencies: + '@vercel/cli-config': 0.3.1 + '@vercel/cli-exec': 1.0.1 + jose: 5.10.0 + '@vercel/queue@0.1.4': dependencies: - '@vercel/oidc': 3.4.0 + '@vercel/oidc': 3.8.10 minimatch: 10.2.5 mixpart: 0.0.5 picocolors: 1.1.1 @@ -12295,6 +12415,25 @@ snapshots: - bare-abort-controller - react-native-b4a + '@vercel/sandbox@3.9.1': + dependencies: + '@vercel/detect-agent': 1.2.5 + '@vercel/oidc': 4.0.0 + '@workflow/serde': 4.1.0-beta.2 + async-retry: 1.3.3 + jose: 6.2.3 + jsonlines: 0.1.1 + lru-cache: 10.4.3 + ms: 2.1.3 + picocolors: 1.1.1 + tar-stream: 3.1.7 + undici: 7.29.1 + xdg-app-paths: 5.1.0 + zod: 4.1.13 + transitivePeerDependencies: + - bare-abort-controller + - react-native-b4a + '@vitest/expect@3.2.4': dependencies: '@types/chai': 5.2.3 @@ -12337,7 +12476,7 @@ snapshots: loupe: 3.2.1 tinyrainbow: 2.0.0 - '@wagmi/connectors@6.2.0(famvdj7knsqwt4fyelsxychfjq)': + '@wagmi/connectors@6.2.0(9eced80027ca3dd67aa8b213c2291800)': dependencies: '@base-org/account': 2.4.0(@types/react@19.2.7)(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(react@19.2.8)(typescript@5.9.3)(use-sync-external-store@1.4.0(react@19.2.8))(utf-8-validate@5.0.10)(ws@8.18.3(bufferutil@4.0.9)(utf-8-validate@5.0.10))(zod@3.25.76) '@coinbase/wallet-sdk': 4.3.6(@types/react@19.2.7)(bufferutil@4.0.9)(react@19.2.8)(typescript@5.9.3)(use-sync-external-store@1.4.0(react@19.2.8))(utf-8-validate@5.0.10)(zod@3.25.76) @@ -14738,6 +14877,18 @@ snapshots: run-exclusive: 2.2.19 tsafe: 1.8.12 + execa@5.1.1: + dependencies: + cross-spawn: 7.0.6 + get-stream: 6.0.1 + human-signals: 2.1.0 + is-stream: 2.0.1 + merge-stream: 2.0.0 + npm-run-path: 4.0.1 + onetime: 5.1.2 + signal-exit: 3.0.7 + strip-final-newline: 2.0.0 + execa@8.0.1: dependencies: cross-spawn: 7.0.6 @@ -15112,6 +15263,8 @@ snapshots: dunder-proto: 1.0.1 es-object-atoms: 1.1.1 + get-stream@6.0.1: {} + get-stream@8.0.1: {} get-stream@9.0.1: @@ -15256,6 +15409,8 @@ snapshots: quick-lru: 5.1.1 resolve-alpn: 1.2.1 + human-signals@2.1.0: {} + human-signals@5.0.0: {} human-signals@8.0.1: {} @@ -15563,6 +15718,8 @@ snapshots: jose@6.2.12: {} + jose@6.2.3: {} + js-levenshtein@1.1.6: {} js-tokens@9.0.1: {} @@ -16108,6 +16265,8 @@ snapshots: mime@1.6.0: {} + mimic-fn@2.1.0: {} + mimic-fn@4.0.0: {} mimic-function@5.0.1: {} @@ -16279,6 +16438,10 @@ snapshots: normalize-url@8.1.1: {} + npm-run-path@4.0.1: + dependencies: + path-key: 3.1.1 + npm-run-path@5.3.0: dependencies: path-key: 4.0.0 @@ -16359,6 +16522,10 @@ snapshots: dependencies: wrappy: 1.0.2 + onetime@5.1.2: + dependencies: + mimic-fn: 2.1.0 + onetime@6.0.0: dependencies: mimic-fn: 4.0.0 @@ -17402,6 +17569,8 @@ snapshots: siginfo@2.0.0: {} + signal-exit@3.0.7: {} + signal-exit@4.1.0: {} simple-git@3.30.0: @@ -17607,6 +17776,8 @@ snapshots: inspect-with-kind: 1.0.5 is-plain-obj: 1.1.0 + strip-final-newline@2.0.0: {} + strip-final-newline@3.0.0: {} strip-final-newline@4.0.0: {} @@ -18270,7 +18441,7 @@ snapshots: wagmi@2.19.5(@tanstack/query-core@5.90.11)(@tanstack/react-query@5.90.11(react@19.2.8))(@types/react@19.2.7)(@vercel/blob@2.3.1)(@vercel/functions@3.5.0(@aws-sdk/credential-provider-web-identity@3.972.13))(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(ioredis@5.8.2)(react@19.2.8)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.40.3(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.1.13))(ws@8.18.3(bufferutil@4.0.9)(utf-8-validate@5.0.10))(zod@4.1.13): dependencies: '@tanstack/react-query': 5.90.11(react@19.2.8) - '@wagmi/connectors': 6.2.0(famvdj7knsqwt4fyelsxychfjq) + '@wagmi/connectors': 6.2.0(9eced80027ca3dd67aa8b213c2291800) '@wagmi/core': 2.22.1(@tanstack/query-core@5.90.11)(@types/react@19.2.7)(react@19.2.8)(typescript@5.9.3)(use-sync-external-store@1.4.0(react@19.2.8))(viem@2.40.3(bufferutil@4.0.9)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.1.13)) react: 19.2.8 use-sync-external-store: 1.4.0(react@19.2.8) @@ -18702,6 +18873,8 @@ snapshots: zod@4.4.3: {} + zod@4.6.7: {} + zustand@5.0.0(@types/react@19.2.7)(react@19.2.8)(use-sync-external-store@1.4.0(react@19.2.8)): optionalDependencies: '@types/react': 19.2.7 diff --git a/scripts/application-registration-proposal/source-bindings.json b/scripts/application-registration-proposal/source-bindings.json index 6b92a2fcb..be435c912 100644 --- a/scripts/application-registration-proposal/source-bindings.json +++ b/scripts/application-registration-proposal/source-bindings.json @@ -6,8 +6,8 @@ "lib/auth/validateAuthContext.ts": "055ac2965db8487c8f67d74c549101d866968ed507d295498ed4485d62867c28", "lib/applications/applicationRegistrationSchema.ts": "5bfb55ded25eae323bea02b535d6fb010eec5b2a767b891a13b86e4c91427a30", "lib/applications/validateApplicationRegistration.ts": "b842cd312e0123a65ec1dd872c54474f77872b337ef5285ecedff1dad96ac0c6", - "package.json": "6129bd1116b3f3b3644c4560484daf2feafb57272e29f68cb5156b22ef1bbd50", - "pnpm-lock.yaml": "59d2629cd37287ad1bfd5e35589d0ed4c15c09d3c1965fff78aaba4a871487ee", + "package.json": "870421819b366c460a58f8403c07f8bb2f500715e6727ba0edce73e6e3e6e574", + "pnpm-lock.yaml": "fb071b6d174e87f11c07b988df522c479c54a435b7273947849f5925cc30cd2f", "tsconfig.json": "b32629dbc2af272f06db2eb3c5e6bd249183a72cec77481e624b0a4086c10d93", "lib/keys/getApiKeyDetails.ts": "68813ca17af04703ded1efc25d8c6864aaa1f7b9c297ddeadb44c6c10220c644", "lib/mcp/__tests__/verifyApiKeyExpiry.test.ts": "1b4b18f8147217734b9b1d89418a57ae23c968e6046109d072469b7735fdd1bc",