Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

refactor(eve): remove dead helpers, low-signal tests, and test noise (#3851)

Andrew Barba16e2913cf6c6
diff --git a/.changeset/quiet-gray-matter-eval-warning.md b/.changeset/quiet-gray-matter-eval-warning.md
new file mode 100644
index 000000000..b04366470
--- /dev/null
+++ b/.changeset/quiet-gray-matter-eval-warning.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+eve no longer prints bundler warnings that come only from dependency code when it bundles authored modules, development generations, and workflow code, matching the production server build. Warnings from your own code and unresolved imports still print, and an unresolved import inside a workflow dependency still fails the build.
diff --git a/.changeset/remove-dead-internal-helpers.md b/.changeset/remove-dead-internal-helpers.md
new file mode 100644
index 000000000..cb8911e34
--- /dev/null
+++ b/.changeset/remove-dead-internal-helpers.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Remove unused internal helpers from the `eve` package. This is internal cleanup with no user-visible behavior change.
diff --git a/.github/workflows/eve-code-benchmark.yml b/.github/workflows/eve-code-benchmark.yml
index 787f61495..f17b17761 100644
--- a/.github/workflows/eve-code-benchmark.yml
+++ b/.github/workflows/eve-code-benchmark.yml
@@ -87,7 +87,7 @@ jobs:
with:
harness: ${{ needs.request.outputs.harness }}
agent-repository: vercel/eve
- agent-path: packages/eve-code
+ agent-paths: '["packages/eve-code"]'
agent-ref: ${{ needs.request.outputs.sha }}
dataset: swe-lean
# The PR comment's ranking tables show these plus each dimension's winner.
diff --git a/apps/docs/lib/integrations/discovery.test.ts b/apps/docs/lib/integrations/discovery.test.ts
index 40b854d3c..e06a9b64e 100644
--- a/apps/docs/lib/integrations/discovery.test.ts
+++ b/apps/docs/lib/integrations/discovery.test.ts
@@ -1,7 +1,18 @@
+import { getIntegrationEntry } from "@eve/catalog";
import { describe, expect, it } from "vitest";
import { getIntegration, integrations } from "./data";
import { integrationMarkdown, integrationPaths, integrationSearchText } from "./discovery";
+const SECTIONS = ["## Install", "## Quick start", "## Configure"] as const;
+
+function sectionBody(markdown: string, heading: string): string {
+ const start = markdown.indexOf(`${heading}\n\n`);
+ if (start === -1) return "";
+ const bodyStart = start + heading.length + 2;
+ const next = markdown.indexOf("\n\n## ", bodyStart);
+ return markdown.slice(bodyStart, next === -1 ? undefined : next).trim();
+}
+
describe("integration discovery", () => {
it("includes the landing page and every detail page in crawler paths", () => {
const paths = integrationPaths();
@@ -32,6 +43,31 @@ describe("integration discovery", () => {
expect(markdown).toContain("eve add channel/slack");
});
+ it.each(integrations.map((integration) => [integration.slug, integration] as const))(
+ "renders %s as complete agent-readable setup",
+ (slug, integration) => {
+ const markdown = integrationMarkdown(integration);
+ const offsets = SECTIONS.map((heading) => markdown.indexOf(`${heading}\n\n`));
+
+ expect(offsets.every((offset) => offset !== -1)).toBe(true);
+ expect([...offsets].sort((a, b) => a - b)).toEqual(offsets);
+ for (const heading of SECTIONS) expect(sectionBody(markdown, heading)).not.toBe("");
+ expect(markdown).toContain(`](${integration.docsHref})`);
+ expect(integrationSearchText(integration)).toContain(integration.name);
+ if (getIntegrationEntry(slug)?.surfaces.registry) expect(markdown).toContain("eve add ");
+
+ const related = markdown.indexOf("## Related resources");
+ if (!integration.relatedResources?.length) {
+ expect(related).toBe(-1);
+ return;
+ }
+ expect(related).toBeGreaterThan(offsets[2]!);
+ for (const resource of integration.relatedResources) {
+ expect(markdown).toContain(`- [${resource.title}](${resource.href})`);
+ }
+ },
+ );
+
it("renders Buzz as an ACP channel with explicit authorization guidance", () => {
const buzz = getIntegration("buzz");
expect(buzz).toBeDefined();
@@ -50,227 +86,6 @@ describe("integration discovery", () => {
expect(integrationSearchText(buzz!)).toContain("acp");
});
- it("renders the Web Chat setup for every host framework it documents", () => {
- const web = getIntegration("eve");
- expect(web).toBeDefined();
-
- const markdown = integrationMarkdown(web!);
- expect(markdown).toContain("eve add channel/web");
- expect(markdown).toContain("/docs/guides/frontend/nextjs");
- expect(markdown).toContain("/docs/guides/frontend/nuxt");
- expect(markdown).toContain("/docs/guides/frontend/sveltekit");
- expect(integrationSearchText(web!)).toContain("svelte");
- });
-
- it("renders the Browserbase extension setup", () => {
- const browserbase = getIntegration("browserbase");
- expect(browserbase).toBeDefined();
-
- const markdown = integrationMarkdown(browserbase!);
- expect(markdown).toContain("eve add extension/browserbase");
- expect(markdown).toContain('import browserbase from "@browserbasehq/eve"');
- expect(markdown).toContain("BROWSERBASE_API_KEY");
- expect(integrationSearchText(browserbase!)).toContain("Stagehand");
- });
-
- it("renders related resources after Configure and omits the section when empty", () => {
- const kernel = getIntegration("kernel");
- expect(kernel).toBeDefined();
-
- const markdown = integrationMarkdown(kernel!);
- expect(markdown).toContain("## Related resources");
- expect(markdown.indexOf("## Related resources")).toBeGreaterThan(
- markdown.indexOf("## Configure"),
- );
- expect(markdown).toContain(
- "- [How to build a browser agent that works behind a login](https://vercel.com/kb/guide/build-a-browser-agent)",
- );
- expect(markdown).toContain(
- "- [Give your software factory a browser](https://vercel.com/kb/guide/software-factory-browser)",
- );
-
- const agentBrowser = getIntegration("agent-browser");
- expect(agentBrowser).toBeDefined();
- expect(integrationMarkdown(agentBrowser!)).toContain(
- "- [Give your eve agent a browser](https://vercel.com/changelog/give-your-eve-agent-a-browser)",
- );
-
- for (const slug of ["github", "linear-agent", "github-tools", "linear", "vercel"]) {
- const integration = getIntegration(slug);
- expect(integration).toBeDefined();
- expect(integrationMarkdown(integration!)).toContain(
- "- [Build a software factory with eve](https://vercel.com/kb/guide/eve-software-factory)",
- );
- }
-
- const vercel = getIntegration("vercel");
- expect(integrationMarkdown(vercel!)).toContain(
- "- [Manage Vercel projects with a software factory](https://vercel.com/kb/guide/software-factory-vercel-mcp)",
- );
-
- for (const slug of [
- "slack",
- "github",
- "github-tools",
- "datadog",
- "datadog-instrumentation",
- "vercel",
- ]) {
- const integration = getIntegration(slug);
- expect(integration).toBeDefined();
- expect(integrationMarkdown(integration!)).toContain(
- "- [Build an incident response SRE agent with eve](https://vercel.com/kb/guide/eve-incident-sre-agent)",
- );
- }
-
- const vercelMarkdown = integrationMarkdown(vercel!);
- expect(vercelMarkdown.indexOf("eve-incident-sre-agent")).toBeLessThan(
- vercelMarkdown.indexOf("eve-software-factory"),
- );
-
- for (const slug of ["slack", "notion"]) {
- const integration = getIntegration(slug);
- expect(integration).toBeDefined();
- expect(integrationMarkdown(integration!)).toContain(
- "- [Run a marketing team from Slack with eve](https://vercel.com/kb/guide/marketing-team-eve)",
- );
- }
-
- const resend = getIntegration("chat-sdk-resend");
- expect(resend).toBeDefined();
- expect(integrationMarkdown(resend!)).toContain(
- "- [Give your eve agent an email inbox with Resend](https://vercel.com/kb/guide/eve-agent-with-resend)",
- );
-
- const browserbase = getIntegration("browserbase");
- expect(browserbase).toBeDefined();
- expect(integrationMarkdown(browserbase!)).not.toContain("## Related resources");
- });
-
- it("renders the BlitzReels extension setup", () => {
- const blitzreels = getIntegration("blitzreels");
- expect(blitzreels).toBeDefined();
-
- const markdown = integrationMarkdown(blitzreels!);
- expect(markdown).toContain("eve add extension/blitzreels");
- expect(markdown).toContain('import blitzreels from "@blitzreels/eve"');
- expect(markdown).toContain("BLITZREELS_API_KEY");
- expect(markdown).toContain("blitzreels__create_clip_batch");
- expect(markdown).toContain("require eve approval");
- expect(integrationSearchText(blitzreels!)).toContain("video editing");
- });
-
- it("renders the Mux Video extension setup", () => {
- const muxVideo = getIntegration("mux-video");
- expect(muxVideo).toBeDefined();
-
- const markdown = integrationMarkdown(muxVideo!);
- expect(markdown).toContain("github.com/muxinc/mux-video-agent.git");
- expect(markdown).toContain('import muxVideo from "@mux/eve-video"');
- expect(markdown).toContain("MUX_TOKEN_ID");
- expect(markdown).toContain("mux_video__run_workflow");
- expect(markdown).toContain("require explicit human approval");
- expect(integrationSearchText(muxVideo!)).toContain("Mux Robots");
- });
-
- it("renders the Jetty extension and eval reporter setup", () => {
- const jetty = getIntegration("jetty");
- expect(jetty).toBeDefined();
-
- const markdown = integrationMarkdown(jetty!);
- expect(markdown).toContain("eve add extension/jetty");
- expect(markdown).toContain('import jetty from "@jetty/eve"');
- expect(markdown).toContain('import { Jetty } from "@jetty/eve/reporter"');
- expect(markdown).toContain("JETTY_API_TOKEN");
- expect(integrationSearchText(jetty!)).toContain("grading");
- });
-
- it("renders the Upstash AgentKit memory provider setup", () => {
- const agentkitMemory = getIntegration("upstash-agentkit");
- expect(agentkitMemory).toBeDefined();
-
- const markdown = integrationMarkdown(agentkitMemory!);
- expect(markdown).toContain("eve add memory/upstash-agentkit");
- expect(markdown).toContain('import { redisMemory } from "@upstash/agentkit-eve/memory"');
- expect(markdown).toContain("UPSTASH_REDIS_REST_URL");
- expect(markdown).toContain("redisDocuments()");
- expect(markdown).toContain("upstash-agentkit__search_memory");
- expect(integrationSearchText(agentkitMemory!)).toContain("Memory provider");
- });
-
- it("renders the Kybernesis Arcana memory provider setup", () => {
- const arcana = getIntegration("arcana");
- expect(arcana).toBeDefined();
-
- const markdown = integrationMarkdown(arcana!);
- expect(markdown).toContain("eve add memory/arcana");
- expect(markdown).toContain('import { arcanaMemory } from "@kybernesis/arcana/memory"');
- expect(markdown).toContain("ARCANA_API_KEY");
- expect(markdown).toContain("ARCANA_WORKSPACE");
- expect(markdown).toContain("capture: { enabled: true }");
- expect(integrationSearchText(arcana!)).toContain("Memory provider");
- });
-
- it("renders the Supermemory provider setup", () => {
- const supermemory = getIntegration("supermemory");
- expect(supermemory).toBeDefined();
-
- const markdown = integrationMarkdown(supermemory!);
- expect(markdown).toContain("eve add memory/supermemory");
- expect(markdown).toContain('import supermemory from "@supermemory/eve"');
- expect(markdown).toContain("SUPERMEMORY_API_KEY");
- expect(markdown).toContain("supermemory__search");
- expect(integrationSearchText(supermemory!)).toContain("Memory provider");
- });
-
- it("renders built-in file-memory provisioning guidance", () => {
- const file = getIntegration("file");
- expect(file).toBeDefined();
-
- const markdown = integrationMarkdown(file!);
- expect(markdown).toContain("eve add memory/file");
- expect(markdown).toContain("eve integration setup file-memory");
- expect(markdown).toContain("EVE_MEMORY_BLOB_STORE_ID");
- expect(integrationSearchText(file!)).toContain("Memory provider");
- });
-
- it("renders the Hindsight memory extension setup", () => {
- const hindsight = getIntegration("hindsight");
- expect(hindsight).toBeDefined();
-
- const markdown = integrationMarkdown(hindsight!);
- expect(markdown).toContain("eve add extension/hindsight");
- expect(markdown).toContain('import { hindsightMemory } from "@vectorize-io/hindsight-eve"');
- expect(markdown).toContain("hindsightRetainHook");
- expect(markdown).toContain("HINDSIGHT_API_KEY");
- expect(markdown).toContain("HINDSIGHT_BANK_ID");
- expect(integrationSearchText(hindsight!)).toContain("long-term memory");
- });
-
- it("renders the GitHub Tools extension setup", () => {
- const githubTools = getIntegration("github-tools");
- expect(githubTools).toBeDefined();
-
- const markdown = integrationMarkdown(githubTools!);
- expect(markdown).toContain("eve add extension/github-tools");
- expect(markdown).toContain('connector: "github/my-connector"');
- expect(markdown).toContain('preset: "maintainer"');
- expect(markdown).toContain("github__addPullRequestComment");
- expect(integrationSearchText(githubTools!)).toContain("code review");
- });
-
- it("renders the Blooio channel setup", () => {
- const blooio = getIntegration("blooio");
- expect(blooio).toBeDefined();
-
- const markdown = integrationMarkdown(blooio!);
- expect(markdown).toContain("eve add channel/blooio");
- expect(markdown).toContain('import { blooioChannel } from "eve-channel-blooio"');
- expect(markdown).toContain("BLOOIO_API_KEY");
- expect(markdown).toContain("BLOOIO_WEBHOOK_SECRET");
- expect(integrationSearchText(blooio!)).toContain("iMessage");
- });
-
it("renders every connection setup variant", () => {
const notion = getIntegration("notion");
expect(notion).toBeDefined();
@@ -290,24 +105,4 @@ describe("integration discovery", () => {
expect(markdown).toContain("SHOPIFY_STORE_DOMAIN");
expect(markdown).not.toContain("### MCP ·");
});
-
- it("renders instrumentation integrations with registry installation", () => {
- const braintrust = getIntegration("braintrust");
- expect(braintrust).toBeDefined();
-
- const markdown = integrationMarkdown(braintrust!);
- expect(markdown).toContain("eve add instrumentation/braintrust");
- expect(markdown).toContain("agent/instrumentation/braintrust.ts");
- expect(markdown).toContain("braintrustEveInstrumentation");
- expect(markdown).not.toContain("// agent/hooks/braintrust.ts");
- expect(markdown).toContain("BRAINTRUST_API_KEY");
-
- const posthog = getIntegration("posthog-instrumentation");
- expect(posthog).toBeDefined();
-
- const posthogMarkdown = integrationMarkdown(posthog!);
- expect(posthogMarkdown).toContain("eve add instrumentation/posthog");
- expect(posthogMarkdown).toContain("PostHogTraceExporter");
- expect(posthogMarkdown).toContain("POSTHOG_PROJECT_TOKEN");
- });
});
diff --git a/packages/eve-catalog/src/index.test.ts b/packages/eve-catalog/src/index.test.ts
index 07235e09b..55ce46434 100644
--- a/packages/eve-catalog/src/index.test.ts
+++ b/packages/eve-catalog/src/index.test.ts
@@ -60,6 +60,7 @@ describe("integration catalog", () => {
});
it("keeps extensions free of connection identity", () => {
+ expect(extensionEntries().length).toBeGreaterThan(0);
for (const entry of extensionEntries()) {
expect(entry.connection).toBeUndefined();
}
@@ -107,46 +108,6 @@ describe("integration catalog", () => {
expect(getIntegrationEntry("linear")!.connection!.mcp!.url).toBe("https://mcp.linear.app/mcp");
});
- it("exposes Kernel as an extension", () => {
- expect(getIntegrationEntry("kernel")?.kind).toBe("extension");
- expect(getIntegrationEntry("kernel")?.connection).toBeUndefined();
- });
-
- it("exposes Browserbase as an extension", () => {
- expect(getIntegrationEntry("browserbase")?.kind).toBe("extension");
- expect(getIntegrationEntry("browserbase")?.connection).toBeUndefined();
- });
-
- it("exposes Jetty as an extension", () => {
- expect(getIntegrationEntry("jetty")?.kind).toBe("extension");
- expect(getIntegrationEntry("jetty")?.connection).toBeUndefined();
- });
-
- it("exposes Upstash AgentKit as a memory provider", () => {
- expect(getIntegrationEntry("upstash-agentkit")?.kind).toBe("memory");
- expect(getIntegrationEntry("upstash-agentkit")?.connection).toBeUndefined();
- });
-
- it("exposes Kybernesis Arcana as a memory provider", () => {
- expect(getIntegrationEntry("arcana")?.kind).toBe("memory");
- expect(getIntegrationEntry("arcana")?.connection).toBeUndefined();
- });
-
- it("exposes Hindsight as an extension", () => {
- expect(getIntegrationEntry("hindsight")?.kind).toBe("extension");
- expect(getIntegrationEntry("hindsight")?.connection).toBeUndefined();
- });
-
- it("exposes Supermemory as a memory provider", () => {
- expect(getIntegrationEntry("supermemory")?.kind).toBe("memory");
- expect(getIntegrationEntry("supermemory")?.connection).toBeUndefined();
- });
-
- it("exposes file memory as a memory provider", () => {
- expect(getIntegrationEntry("file")?.kind).toBe("memory");
- expect(getIntegrationEntry("file")?.connection).toBeUndefined();
- });
-
it("exposes Buzz as a gallery-only channel", () => {
expect(getIntegrationEntry("buzz")).toMatchObject({
kind: "channel",
@@ -161,12 +122,6 @@ describe("integration catalog", () => {
});
});
- it("exposes GitHub Tools as an extension distinct from the GitHub channel", () => {
- expect(getIntegrationEntry("github")?.kind).toBe("channel");
- expect(getIntegrationEntry("github-tools")?.kind).toBe("extension");
- expect(getIntegrationEntry("github-tools")?.connection).toBeUndefined();
- });
-
it("uses Browser Use's streamable HTTP MCP endpoint", () => {
expect(getIntegrationEntry("browser-use")!.connection!.mcp!.url).toBe(
"https://api.browser-use.com/v3/mcp",
diff --git a/packages/eve-code/test/scenario/instructions-policy.test.ts b/packages/eve-code/test/scenario/instructions-policy.test.ts
index 6c2fb1c3a..9c9522984 100644
--- a/packages/eve-code/test/scenario/instructions-policy.test.ts
+++ b/packages/eve-code/test/scenario/instructions-policy.test.ts
@@ -3,155 +3,9 @@ import { readFileSync } from "node:fs";
import test from "node:test";
const content = readFileSync(new URL("../../extension/instructions.md", import.meta.url), "utf8");
-const worker = readFileSync(
- new URL("../../extension/subagents/worker/instructions.md", import.meta.url),
- "utf8",
-);
-const workerAgent = readFileSync(
- new URL("../../extension/subagents/worker/agent.ts", import.meta.url),
- "utf8",
-);
test("routes authenticated GitHub operations through the scoped gh tool", () => {
assert.match(content, /GitHub credentials are not available to ordinary `bash`/u);
assert.match(content, /Use the `gh` tool for every authenticated GitHub operation/u);
- assert.match(
- content,
- /Authenticated commands run without an approval prompt[\s\S]*`description`/u,
- );
- assert.match(content, /The full `gh` CLI surface is available/u);
- assert.match(content, /Connect mints the real token for only the declared repository/u);
assert.match(content, /sandbox process receives only a placeholder `GH_TOKEN`/u);
- assert.match(content, /GitHub rejects access outside the token's server-side repository scope/u);
- assert.match(content, /Do not use environment assignments, pipes, redirects, substitutions/u);
- assert.match(content, /Commands without an explicit repository may use normal `gh` context/u);
- assert.match(content, /Clone with `gh repo clone owner\/name`/u);
- assert.match(content, /`git push`[\s\S]*through the `gh` tool/u);
- assert.match(content, /Local `git status`[\s\S]*`rebase` remain ordinary `bash` commands/u);
-});
-
-test("keeps read-only requests from authorizing edits or publication", () => {
- assert.match(content, /Match action to the request/u);
- assert.match(content, /answer, explanation, review, status report, diagnosis, or plan/u);
- assert.match(content, /not workspace edits, publication, cross-posts, or other external writes/u);
- assert.match(content, /Diagnose and explain causes without implementing a fix unless asked/u);
- assert.match(content, /Build or change the workspace only when the requester asks/u);
- assert.match(content, /Persistence never expands authority/u);
-});
-
-test("rebases only for explicit intent or a requested delivery need", () => {
- assert.match(content, /Do not rebase before work by default/u);
- assert.match(content, /requester explicitly asks for it/u);
- assert.match(
- content,
- /explicitly requested publication or delivery outcome requires a current base/u,
- );
- assert.doesNotMatch(content, /Always rebase from current base ref/u);
-});
-
-test("names the other minds the agent must hold", () => {
- assert.match(content, /Hold the other people in the work/u);
- assert.match(content, /The requester named an outcome, not a procedure/u);
- assert.match(content, /A future maintainer pays for every new concept/u);
- assert.match(content, /A worker is another mind with one slice/u);
- assert.match(content, /Evidence does not care what you hoped/u);
-});
-
-test("prefers action over ceremony", () => {
- assert.match(content, /Prefer action over ceremony/u);
-});
-
-test("skips todo model turns for bounded tasks", () => {
- assert.match(content, /For bounded tasks, do not call `todo`/u);
- assert.match(content, /begin the work directly instead of spending a model turn/u);
- assert.match(content, /only for long-running or open-ended work/u);
-});
-
-test("parallelizes independent calls and serializes dependent work", () => {
- assert.match(content, /multiple read-only calls are independently useful/u);
- assert.match(content, /emit them in the same response/u);
- assert.match(content, /eve executes calls from one response concurrently/u);
- assert.match(content, /unless it determines whether the next call is valid/u);
- assert.match(content, /[Ii]dentify independent slices a worker can own/u);
- assert.match(content, /start independent calls together/u);
- assert.match(content, /[Ss]erialize work that depends on earlier results/u);
-});
-
-test("keeps shared workspace writes and coordination with the root agent", () => {
- assert.match(
- content,
- /Writes stay here so workers never compete to mutate the shared workspace/u,
- );
-});
-
-test("gives worker subagents bounded scope without wasteful fanout", () => {
- assert.match(content, /Work streams that can run apart should/u);
- assert.match(content, /repositories, paths or refs, constraints, and expected output/u);
- assert.match(content, /do not copy full source/u);
- assert.match(content, /do not make delegation lossy/u);
-});
-
-test("discovers and independently scopes every repository needed for the task", () => {
- assert.match(
- content,
- /Determine the repositories needed[\s\S]*source discovery and investigation/u,
- );
- assert.match(content, /even when the requester does not name them/u);
- assert.match(
- content,
- /Do not ask the requester to enumerate repositories that can be discovered/u,
- );
- assert.match(content, /may select additional repositories as the work reveals them/u);
- assert.match(content, /mints a credential lease for that repository at the moment it is needed/u);
- assert.match(content, /cross-repository work uses separate scoped commands and leases/u);
-});
-
-test("lets the caller choose durable slice ownership or an ephemeral one-shot", () => {
- assert.match(content, /Choose the lifetime/u);
- assert.match(content, /own the slice end to end/u);
- assert.match(content, /send follow-ups as deltas/u);
- assert.match(content, /spawn ephemerally/u);
-});
-
-test("worker owns a scoped slice end to end or completes it ephemerally", () => {
- assert.match(worker, /assigned mind for one scoped slice/u);
- assert.match(worker, /own that slice end to end/u);
- assert.match(worker, /answer once and stop/u);
- assert.match(worker, /Follow the\s+assignment/u);
- assert.match(worker, /not a survey for the caller to finish/u);
- assert.match(worker, /Evidence does not care what you hoped/u);
- assert.doesNotMatch(worker, /token-intensive read-only/u);
-});
-
-test("worker description tells the caller what this mind is for", () => {
- assert.match(workerAgent, /Another mind for one scoped slice/u);
- assert.match(workerAgent, /choose the lifetime/u);
- assert.match(workerAgent, /own the slice end to end/u);
- assert.match(workerAgent, /or ask once/u);
- assert.match(workerAgent, /can see the shared tree/u);
- assert.match(workerAgent, /You remain the arbiter and keep the writes/u);
- assert.doesNotMatch(workerAgent, /token-intensive read-only/u);
-});
-
-test("leads with the answer and asks only when the next cut is blocked", () => {
- assert.match(content, /The reader did not see your tool calls/u);
- assert.match(content, /Lead with the answer/u);
- assert.match(content, /The final message stands alone/u);
- assert.match(content, /If the next cut depends on an unstated constraint, ask one question/u);
- assert.match(content, /Otherwise decide and proceed/u);
-});
-
-test("prefers grep for sandbox search and apply_patch for authored edits", () => {
- assert.match(content, /Use apply_patch for authored edits/u);
- assert.match(content, /If a hunk misses, re-read that file and rewrite only the failed hunk/u);
- assert.match(content, /Use `grep` for sandbox content search/u);
- assert.match(content, /Start with `files_with_matches`/u);
-});
-
-test("reads repository-local instructions before planning or editing", () => {
- assert.match(content, /Immediately after entering a checkout and before planning or editing/u);
- assert.match(content, /read its root `AGENTS.md`/u);
- assert.match(content, /use root `CLAUDE.md` only when `AGENTS.md` is absent/u);
- assert.match(content, /Before touching any path, read the nearest nested `AGENTS.md`/u);
- assert.match(content, /falling back to `CLAUDE.md` only when that directory has no `AGENTS.md`/u);
});
diff --git a/packages/eve/src/channel/schedule-auth.test.ts b/packages/eve/src/channel/schedule-auth.test.ts
deleted file mode 100644
index 1458298ee..000000000
--- a/packages/eve/src/channel/schedule-auth.test.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { describe, expect, it } from "vitest";
-
-import { isScheduleAppAuth, SCHEDULE_APP_AUTH } from "#channel/schedule-auth.js";
-
-describe("isScheduleAppAuth", () => {
- it("recognizes eve's schedule principal", () => {
- expect(isScheduleAppAuth(SCHEDULE_APP_AUTH)).toBe(true);
- expect(
- isScheduleAppAuth({
- ...SCHEDULE_APP_AUTH,
- attributes: { deployment: "preview" },
- issuer: "eve",
- }),
- ).toBe(true);
- });
-
- it("rejects other principals and missing auth", () => {
- expect(isScheduleAppAuth(null)).toBe(false);
- expect(isScheduleAppAuth(undefined)).toBe(false);
- expect(isScheduleAppAuth({ ...SCHEDULE_APP_AUTH, authenticator: "oidc" })).toBe(false);
- expect(isScheduleAppAuth({ ...SCHEDULE_APP_AUTH, principalId: "another-app" })).toBe(false);
- expect(isScheduleAppAuth({ ...SCHEDULE_APP_AUTH, principalType: "user" })).toBe(false);
- });
-});
diff --git a/packages/eve/src/channel/schedule-auth.ts b/packages/eve/src/channel/schedule-auth.ts
index d963a5803..9eef65476 100644
--- a/packages/eve/src/channel/schedule-auth.ts
+++ b/packages/eve/src/channel/schedule-auth.ts
@@ -9,14 +9,3 @@ export const SCHEDULE_APP_AUTH: SessionAuthContext = {
principalId: "eve:app",
principalType: "runtime",
};
-
-/** Returns whether the current request is authenticated as eve's schedule principal. */
-export function isScheduleAppAuth(
- auth: SessionAuthContext | null | undefined,
-): auth is SessionAuthContext {
- return (
- auth?.authenticator === SCHEDULE_APP_AUTH.authenticator &&
- auth.principalId === SCHEDULE_APP_AUTH.principalId &&
- auth.principalType === SCHEDULE_APP_AUTH.principalType
- );
-}
diff --git a/packages/eve/src/cli/application-root.test.ts b/packages/eve/src/cli/application-root.test.ts
index 0eb0407db..54979a282 100644
--- a/packages/eve/src/cli/application-root.test.ts
+++ b/packages/eve/src/cli/application-root.test.ts
@@ -1,11 +1,8 @@
-import { resolve } from "node:path";
-
import { describe, expect, it, vi } from "vitest";
import {
findCliApplicationRoot,
resolveCliApplicationProject,
- resolveCliApplicationRoot,
type ResolveCliApplicationRootDependencies,
} from "#cli/application-root.js";
import {
@@ -30,7 +27,7 @@ function dependencies(
return { resolveDiscoveryProject: vi.fn(implementation) };
}
-describe("resolveCliApplicationRoot", () => {
+describe("CLI application root", () => {
it("returns the complete project resolved by discovery", async () => {
const project = {
agentRoot: "/repo/agent",
@@ -42,16 +39,6 @@ describe("resolveCliApplicationRoot", () => {
await expect(resolveCliApplicationProject("/repo/agent/tools", deps)).resolves.toEqual(project);
});
- it("uses the application root resolved by project discovery", async () => {
- const deps = dependencies(async () => ({
- agentRoot: "/repo/agent",
- appRoot: "/repo",
- layout: "nested",
- }));
-
- await expect(resolveCliApplicationRoot("/repo/agent/tools", deps)).resolves.toBe("/repo");
- });
-
it("finds a named agent workspace member", async () => {
const deps = dependencies(async () => ({
agentRoot: "/repo/agents/billing/agent",
@@ -84,21 +71,11 @@ describe("resolveCliApplicationRoot", () => {
await expect(findCliApplicationRoot("/workspace/packages", deps)).resolves.toBeUndefined();
});
- it("preserves cwd when resolving from outside an application", async () => {
- const deps = dependencies(async (path) => {
- throw projectNotFound(path ?? process.cwd());
- });
-
- await expect(resolveCliApplicationRoot("./workspace/packages", deps)).resolves.toBe(
- resolve("./workspace/packages"),
- );
- });
-
it("does not hide unexpected discovery failures", async () => {
const deps = dependencies(async () => {
throw new Error("read failed");
});
- await expect(resolveCliApplicationRoot("/workspace", deps)).rejects.toThrow("read failed");
+ await expect(findCliApplicationRoot("/workspace", deps)).rejects.toThrow("read failed");
});
});
diff --git a/packages/eve/src/cli/application-root.ts b/packages/eve/src/cli/application-root.ts
index a3dbc21e7..6fa6714a0 100644
--- a/packages/eve/src/cli/application-root.ts
+++ b/packages/eve/src/cli/application-root.ts
@@ -1,5 +1,3 @@
-import { resolve } from "node:path";
-
import {
DiscoveryProjectResolutionError,
resolveDiscoveryProject,
@@ -34,11 +32,3 @@ export async function findCliApplicationRoot(
throw error;
}
}
-
-/** Uses the nearest enclosing eve application, or preserves cwd when none exists. */
-export async function resolveCliApplicationRoot(
- cwd: string = process.cwd(),
- dependencies: ResolveCliApplicationRootDependencies = defaultDependencies,
-): Promise<string> {
- return (await findCliApplicationRoot(cwd, dependencies)) ?? resolve(cwd);
-}
diff --git a/packages/eve/src/cli/commands/agent-instructions.test.ts b/packages/eve/src/cli/commands/agent-instructions.test.ts
index 72a03101d..c5a2588c4 100644
--- a/packages/eve/src/cli/commands/agent-instructions.test.ts
+++ b/packages/eve/src/cli/commands/agent-instructions.test.ts
@@ -9,7 +9,6 @@ import {
initAgentDevHandoff,
initAgentInstructions,
initAgentReadySummary,
- initAgentReplPrompt,
initExtensionHandoff,
initExtensionInstructions,
SETUP_SECTIONS,
@@ -109,18 +108,6 @@ describe("initAgentDevHandoff", () => {
});
});
-describe("initAgentReplPrompt", () => {
- it("uses the shared guidance without interpolating the project path into the launch argument", () => {
- const prompt = initAgentReplPrompt({ devCommand: "pnpm exec eve dev" });
-
- expect(prompt).toContain("The project at `.` is already scaffolded.");
- expect(prompt).toContain("What should the agent do?");
- expect(prompt).toContain("`eve registry search <query>`");
- expect(prompt).toContain("pnpm exec eve dev --no-ui");
- expect(prompt).not.toContain("{{");
- });
-});
-
describe("initExtensionInstructions", () => {
it("points coding agents at extension init with a package name", () => {
const instructions = initExtensionInstructions();
diff --git a/packages/eve/src/cli/commands/agent-instructions.ts b/packages/eve/src/cli/commands/agent-instructions.ts
index f0db4a7bf..f8e1e9e2c 100644
--- a/packages/eve/src/cli/commands/agent-instructions.ts
+++ b/packages/eve/src/cli/commands/agent-instructions.ts
@@ -84,14 +84,6 @@ export function initAgentDevHandoff(options: { projectPath: string; devCommand:
});
}
-/** The initial prompt for a coding-agent REPL opened inside the scaffolded project. */
-export function initAgentReplPrompt(options: { devCommand: string }): string {
- return compose(HANDOFF_SECTIONS, {
- devCommand: options.devCommand,
- workingDirectory: ".",
- });
-}
-
/**
* Pre-scaffold guide for a coding agent that ran `eve extension init` with no
* target. Mirrors agent bare-init: collect a package name, then re-run with it.
diff --git a/packages/eve/src/cli/commands/init-confirm.test.ts b/packages/eve/src/cli/commands/init-confirm.test.ts
deleted file mode 100644
index ea4653ae3..000000000
--- a/packages/eve/src/cli/commands/init-confirm.test.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import { describe, expect, it, vi } from "vitest";
-
-import { createFakePrompter, type FakePrompterConfig } from "#internal/testing/fake-prompter.js";
-
-import { confirmInitInNonEmptyDirectory, type InitConfirmDependencies } from "./init-confirm.js";
-
-function dependencies(input: {
- interactive: boolean;
- onSelect?: FakePrompterConfig["single"];
- onText?: FakePrompterConfig["text"];
-}): InitConfirmDependencies {
- const fake = createFakePrompter({ single: input.onSelect, text: input.onText });
- return {
- createPrompter: vi.fn(() => fake.prompter),
- hasInteractiveTerminal: vi.fn(() => input.interactive),
- };
-}
-
-describe("confirmInitInNonEmptyDirectory", () => {
- it("selects the current directory with an overwrite warning", async () => {
- const deps = dependencies({
- interactive: true,
- onSelect: (options) => {
- expect(options).toMatchObject({
- message: "Where should eve initialize the project?",
- description:
- "The current directory isn't empty. Found: README.md, src, notes.txt, draft.md, data.json, and 1 more.",
- initialValue: "subdirectory",
- });
- expect(options.options).toEqual([
- {
- value: "subdirectory",
- label: "Create a new subdirectory",
- hint: "Keep the current directory unchanged",
- },
- {
- value: "current-directory",
- label: "Use the current directory",
- hint: "Overwrite files at generated paths",
- accent: "warning",
- },
- ]);
- return "current-directory";
- },
- });
-
- await expect(
- confirmInitInNonEmptyDirectory(
- ["README.md", "src", "notes.txt", "draft.md", "data.json", "archive"],
- deps,
- ),
- ).resolves.toEqual({ kind: "current-directory" });
- });
-
- it("asks for and normalizes a new subdirectory name", async () => {
- const deps = dependencies({
- interactive: true,
- onSelect: () => "subdirectory",
- onText: (options) => {
- expect(options).toMatchObject({
- message: "Subdirectory name",
- defaultValue: "my-agent",
- });
- expect(options.validate?.("../escape")).toBeDefined();
- return " research-agent ";
- },
- });
-
- await expect(confirmInitInNonEmptyDirectory(["README.md"], deps)).resolves.toEqual({
- kind: "subdirectory",
- name: "research-agent",
- });
- });
-
- it("refuses a non-interactive scaffold instead of opening a prompt", async () => {
- const deps = dependencies({ interactive: false });
-
- await expect(confirmInitInNonEmptyDirectory(["README.md"], deps)).rejects.toThrow(
- "Cannot choose where to initialize the non-empty current directory without an interactive terminal. Found: README.md. Pass a new directory name, for example: eve init my-agent.",
- );
- expect(deps.createPrompter).not.toHaveBeenCalled();
- });
-});
diff --git a/packages/eve/src/cli/commands/init-confirm.ts b/packages/eve/src/cli/commands/init-confirm.ts
deleted file mode 100644
index fd8ccecdf..000000000
--- a/packages/eve/src/cli/commands/init-confirm.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-import { createPrompter, type Prompter } from "#setup/prompter.js";
-import { parseProjectName, validateProjectName } from "#setup/project-name.js";
-
-import { hasInteractiveTerminal } from "./preconditions.js";
-
-export interface InitConfirmDependencies {
- createPrompter(): Prompter;
- hasInteractiveTerminal(): boolean;
-}
-
-const defaultDependencies: InitConfirmDependencies = {
- createPrompter,
- hasInteractiveTerminal,
-};
-
-export type InitNonEmptyDirectoryTarget =
- | { kind: "current-directory" }
- | { kind: "subdirectory"; name: string };
-
-function formatEntries(entries: readonly string[]): string {
- const visible = entries.slice(0, 5).join(", ");
- const suffix = entries.length > 5 ? `, and ${entries.length - 5} more` : "";
- return `${visible}${suffix}`;
-}
-
-export async function confirmInitInNonEmptyDirectory(
- entries: readonly string[],
- dependencies: InitConfirmDependencies = defaultDependencies,
-): Promise<InitNonEmptyDirectoryTarget> {
- const found = formatEntries(entries);
- if (!dependencies.hasInteractiveTerminal()) {
- throw new Error(
- `Cannot choose where to initialize the non-empty current directory without an interactive terminal. Found: ${found}. Pass a new directory name, for example: eve init my-agent.`,
- );
- }
-
- const prompter = dependencies.createPrompter();
- const choice = await prompter.select<"current-directory" | "subdirectory">({
- message: "Where should eve initialize the project?",
- description: `The current directory isn't empty. Found: ${found}.`,
- options: [
- {
- value: "subdirectory",
- label: "Create a new subdirectory",
- hint: "Keep the current directory unchanged",
- },
- {
- value: "current-directory",
- label: "Use the current directory",
- hint: "Overwrite files at generated paths",
- accent: "warning",
- },
- ],
- initialValue: "subdirectory",
- });
- if (choice === "current-directory") return { kind: "current-directory" };
-
- const name = await prompter.text({
- message: "Subdirectory name",
- defaultValue: "my-agent",
- validate: validateProjectName,
- });
- return { kind: "subdirectory", name: parseProjectName(name) };
-}
diff --git a/packages/eve/src/cli/commands/init-project.ts b/packages/eve/src/cli/commands/init-project.ts
index 4b94c7c73..2bbe384a4 100644
--- a/packages/eve/src/cli/commands/init-project.ts
+++ b/packages/eve/src/cli/commands/init-project.ts
@@ -37,7 +37,6 @@ export type InitResult = {
agentLaunched: boolean;
packageManager: PackageManagerKind;
projectPath: string;
- selfModificationEnabled: boolean;
} & (
| {
configurationFilesChanged: string[];
diff --git a/packages/eve/src/cli/commands/init.ts b/packages/eve/src/cli/commands/init.ts
index a8e27c0b1..b8ea8a73c 100644
--- a/packages/eve/src/cli/commands/init.ts
+++ b/packages/eve/src/cli/commands/init.ts
@@ -287,7 +287,6 @@ async function runInitSteps(input: {
const debug = isLogLevelEnabled("debug");
const initTarget = await resolveInitTarget({ parentDirectory, target });
const evePackage = resolveInitEvePackageOverride();
- const selfModificationEnabled = false;
const startedAt = dependencies.now();
const progressOptions = {
@@ -466,7 +465,6 @@ async function runInitSteps(input: {
elapsedMs: dependencies.now() - startedAt,
agentLaunched,
gitResult,
- selfModificationEnabled,
};
}
@@ -474,7 +472,6 @@ async function runInitSteps(input: {
...project,
elapsedMs: dependencies.now() - startedAt,
agentLaunched,
- selfModificationEnabled,
};
} catch (error) {
trackTerminal?.(
@@ -554,9 +551,6 @@ export async function runInitCommand(
`${pc.green("✓")} Added an ${EVE_WORDMARK} agent to ${pc.bold(result.projectPath)} ${pc.dim(`in ${formatElapsed(result.elapsedMs)}`)}`,
);
}
- if (result.selfModificationEnabled) {
- logger.log(`${pc.green("✓")} Enabled self-modification`);
- }
if (result.kind === "created" && result.gitResult.kind === "failed") {
logger.error(
diff --git a/packages/eve/src/cli/commands/integration-setup.test.ts b/packages/eve/src/cli/commands/integration-setup.test.ts
index e57b4c2da..d53c7b0de 100644
--- a/packages/eve/src/cli/commands/integration-setup.test.ts
+++ b/packages/eve/src/cli/commands/integration-setup.test.ts
@@ -43,6 +43,8 @@ function logger(): RegistryCommandLogger & { errors: string[] } {
return { errors, error: (message) => errors.push(message), log: () => {} };
}
+const fakePrompterDeps = { createPrompter: () => createFakePrompter().prompter };
+
afterEach(() => {
process.exitCode = undefined;
vi.unstubAllEnvs();
@@ -103,7 +105,13 @@ describe("runIntegrationSetupCommand", () => {
completion: { facts: [] },
});
- await runIntegrationSetupCommand(logger(), "/workspace/agents/support", "slack");
+ await runIntegrationSetupCommand(
+ logger(),
+ "/workspace/agents/support",
+ "slack",
+ {},
+ fakePrompterDeps,
+ );
expect(runIntegrationSetup).toHaveBeenCalledWith(
"slack",
@@ -121,7 +129,13 @@ describe("runIntegrationSetupCommand", () => {
completion: { facts: [] },
});
- await runIntegrationSetupCommand(logger(), "/project", "photon", { force: true });
+ await runIntegrationSetupCommand(
+ logger(),
+ "/project",
+ "photon",
+ { force: true },
+ fakePrompterDeps,
+ );
expect(runIntegrationSetup).toHaveBeenCalledWith(
"photon",
@@ -146,7 +160,7 @@ describe("runIntegrationSetupCommand", () => {
return { kind: "done", completion: { facts: [] } };
});
- await runIntegrationSetupCommand(logger(), "/project", "web", { yes: true });
+ await runIntegrationSetupCommand(logger(), "/project", "web", { yes: true }, fakePrompterDeps);
});
it("passes answer-backed headless setup to the runner", async () => {
diff --git a/packages/eve/src/cli/dev/tui/runner.test.ts b/packages/eve/src/cli/dev/tui/runner.test.ts
index 1423e3a27..978fe60cc 100644
--- a/packages/eve/src/cli/dev/tui/runner.test.ts
+++ b/packages/eve/src/cli/dev/tui/runner.test.ts
@@ -24,18 +24,16 @@ import type { VercelDeploymentResolution } from "#setup/vercel-deployment.js";
import {
EveTUIRunner,
- parsePromptCommand,
registryHandoffAddress,
type AgentTUIAgentHeader,
type AgentTUIRenderer,
type AgentTUISessionOptions,
type AgentTUIStreamEvent,
type CommandPresentation,
- type PromptCommand,
type PromptCommandOutcome,
} from "./runner.js";
import { createPromptCommandHandler } from "./prompt-command-handler.js";
-import { promptCommandsFor } from "./prompt-commands.js";
+import { promptCommandsFor, type PromptCommand } from "./prompt-commands.js";
import { interruptedError } from "./errors.js";
import type { RemoteAuthFlow } from "./remote-auth.js";
import type { RemoteAuthCompletedMutation } from "./remote-auth-result.js";
@@ -506,47 +504,6 @@ afterEach(() => {
vi.useRealTimers();
});
-describe("parsePromptCommand", () => {
- it("parses /model with a provider/model slug", () => {
- expect(parsePromptCommand("/model anthropic/claude-opus-4.6")).toEqual({
- type: "extension",
- name: "model",
- argument: "anthropic/claude-opus-4.6",
- });
- });
-
- it("trims whitespace around the command and slug", () => {
- expect(parsePromptCommand(" /model anthropic/claude-opus-4.6 ")).toEqual({
- type: "extension",
- name: "model",
- argument: "anthropic/claude-opus-4.6",
- });
- });
-
- it("parses bare /model as an empty slug", () => {
- expect(parsePromptCommand("/model")).toEqual({
- type: "extension",
- name: "model",
- argument: "",
- });
- });
-
- it("recognizes /reset, /cancel, /clear, /compact, /exit, and /quit", () => {
- expect(parsePromptCommand("/reset")).toEqual({ type: "reset" });
- expect(parsePromptCommand("/cancel")).toEqual({ type: "cancel" });
- expect(parsePromptCommand("/clear")).toEqual({ type: "clear" });
- expect(parsePromptCommand("/compact")).toEqual({ type: "compact" });
- expect(parsePromptCommand("/exit")).toEqual({ type: "exit" });
- expect(parsePromptCommand("/quit")).toEqual({ type: "exit" });
- });
-
- it("does not match near-misses or normal messages", () => {
- expect(parsePromptCommand("hello")).toBeNull();
- expect(parsePromptCommand("/models")).toBeNull();
- expect(parsePromptCommand("what does /model do?")).toBeNull();
- });
-});
-
function fakeRenderer(overrides: Partial<AgentTUIRenderer> = {}): AgentTUIRenderer {
return {
renderStream: vi.fn(async () => {}),
@@ -3153,23 +3110,6 @@ describe("EveTUIRunner replay guards", () => {
});
});
-describe("parsePromptCommand", () => {
- it.each([
- ["/reset", { type: "reset" }],
- ["/new", { type: "clear" }],
- ["/exit", { type: "exit" }],
- ["/quit", { type: "exit" }],
- ["/deploy", { type: "extension", name: "deploy", argument: "" }],
- [" /channels ", null],
- ["/vercel", null],
- ["/links", null],
- ["deploy", null],
- ["tell me about /channels", null],
- ] as const)("parses %j as %j", (prompt, expected) => {
- expect(parsePromptCommand(prompt)).toEqual(expected);
- });
-});
-
describe("EveTUIRunner setup commands", () => {
function recordingRenderer(prompts: Array<string | undefined>) {
const notices: string[] = [];
diff --git a/packages/eve/src/cli/dev/tui/runner.ts b/packages/eve/src/cli/dev/tui/runner.ts
index 44792bbdb..c72f3be6f 100644
--- a/packages/eve/src/cli/dev/tui/runner.ts
+++ b/packages/eve/src/cli/dev/tui/runner.ts
@@ -113,8 +113,6 @@ import { getVercelAuthStatus, type VercelAuthStatus } from "#setup/vercel-projec
import type { DevDiagnostics } from "../diagnostics.js";
import type { CommandLifecycle } from "../../shutdown.js";
-export { parsePromptCommand, type PromptCommand } from "./prompt-commands.js";
-
const defaultAssistantResponseStats: AssistantResponseStatsMode = "tokensPerSecond";
const idleRuntimeArtifactPollMs = 500;
const idleChatGptAuthPollMs = 5_000;
diff --git a/packages/eve/src/cli/run.test.ts b/packages/eve/src/cli/run.test.ts
index 772b9870b..5b8c0e286 100644
--- a/packages/eve/src/cli/run.test.ts
+++ b/packages/eve/src/cli/run.test.ts
@@ -34,14 +34,22 @@ vi.mock("#internal/project-context.js", () => ({
})),
}));
-async function withInteractiveTerminal<T>(fn: () => Promise<T>): Promise<T> {
+async function withInteractiveTerminal<T>(
+ fn: () => Promise<T>,
+ stdoutWrites: string[] = [],
+): Promise<T> {
const stdinDescriptor = Object.getOwnPropertyDescriptor(process.stdin, "isTTY");
const stdoutDescriptor = Object.getOwnPropertyDescriptor(process.stdout, "isTTY");
Object.defineProperty(process.stdin, "isTTY", { configurable: true, value: true });
Object.defineProperty(process.stdout, "isTTY", { configurable: true, value: true });
+ const stdoutWrite = vi.spyOn(process.stdout, "write").mockImplementation((chunk) => {
+ stdoutWrites.push(String(chunk));
+ return true;
+ });
try {
return await fn();
} finally {
+ stdoutWrite.mockRestore();
if (stdinDescriptor !== undefined) {
Object.defineProperty(process.stdin, "isTTY", stdinDescriptor);
} else {
@@ -1033,20 +1041,13 @@ describe("eve dev boot progress", () => {
tuiReporter = input.onBootProgress;
throw new Error("TUI startup failed");
});
- const stdoutWrite = vi.spyOn(process.stdout, "write").mockImplementation((chunk) => {
- writes.push(String(chunk));
- return true;
- });
- try {
- await expect(
- withInteractiveTerminal(() =>
- runCli(["dev"], { error: () => {}, log: () => {} }, { runDevelopmentTui, startHost }),
- ),
- ).rejects.toThrow("TUI startup failed");
- } finally {
- stdoutWrite.mockRestore();
- }
+ await expect(
+ withInteractiveTerminal(
+ () => runCli(["dev"], { error: () => {}, log: () => {} }, { runDevelopmentTui, startHost }),
+ writes,
+ ),
+ ).rejects.toThrow("TUI startup failed");
expect(hostReporter).toBeTypeOf("function");
expect(tuiReporter).toBe(hostReporter);
diff --git a/packages/eve/src/cli/ui/output.test.ts b/packages/eve/src/cli/ui/output.test.ts
index a69ba801e..8c5bc1def 100644
--- a/packages/eve/src/cli/ui/output.test.ts
+++ b/packages/eve/src/cli/ui/output.test.ts
@@ -2,9 +2,7 @@ import { describe, expect, it } from "vitest";
import {
createCliTheme,
- renderCliBanner,
renderCliSection,
- renderCliSpeakerLine,
renderCliTaggedLine,
sanitizeForTerminal,
} from "./output.js";
@@ -61,23 +59,9 @@ describe("CLI renderers", () => {
).toBe("[EVENT] beforeafter red");
});
- it("sanitize speaker-line messages and speakers before rendering", () => {
+ it("sanitize section fields before rendering", () => {
const theme = createCliTheme({ color: false });
- expect(
- renderCliSpeakerLine(theme, {
- message: `${osc8Start}linked${osc8End}`,
- speaker: `agent${c1Osc}`,
- }),
- ).toBe("agent> linked");
- });
-
- it("sanitize banner and section fields before rendering", () => {
- const theme = createCliTheme({ color: false });
-
- expect(renderCliBanner(theme, { subtitle: `sub${dcs}title`, title: `ev${oscTitle}e` })).toBe(
- "eve\n===\nsubtitle",
- );
expect(
renderCliSection(theme, {
rows: [{ label: `Na${oscTitle}me`, value: `Val${osc52}ue` }],
diff --git a/packages/eve/src/cli/ui/output.ts b/packages/eve/src/cli/ui/output.ts
index 938e309c1..9b9919bbe 100644
--- a/packages/eve/src/cli/ui/output.ts
+++ b/packages/eve/src/cli/ui/output.ts
@@ -258,26 +258,6 @@ export function createCliTheme(input: { color?: boolean } = {}): CliTheme {
};
}
-/**
- * Renders a CLI banner with an optional subtitle.
- */
-export function renderCliBanner(
- theme: CliTheme,
- input: {
- readonly subtitle?: string;
- readonly title: string;
- },
-): string {
- const title = sanitizeForTerminal(input.title);
- const lines = [theme.heading(title), theme.muted("=".repeat(title.length))];
-
- if (input.subtitle) {
- lines.push(theme.muted(sanitizeForTerminal(input.subtitle)));
- }
-
- return lines.join("\n");
-}
-
/**
* Renders one labeled section with aligned values.
*/
@@ -333,27 +313,3 @@ export function renderCliTaggedLine(
[theme.muted(prefix), firstLine].join(" ") + (rest.length > 0 ? `\n${rest.join("\n")}` : "")
);
}
-
-/**
- * Renders one speaker-prefixed line such as `agent>`.
- */
-export function renderCliSpeakerLine(
- theme: CliTheme,
- input: {
- readonly message: string;
- readonly speaker: string;
- readonly tone?: CliMessageTone;
- },
-): string {
- const message = sanitizeForTerminal(input.message);
- const prefix = `${sanitizeForTerminal(input.speaker)}>`;
- const valueLines = renderIndentedLines(
- applyTone(theme, input.tone ?? "default", message).split("\n"),
- `${" ".repeat(prefix.length)} `,
- );
- const [firstLine = "", ...rest] = valueLines;
-
- return (
- [theme.muted(prefix), firstLine].join(" ") + (rest.length > 0 ? `\n${rest.join("\n")}` : "")
- );
-}
diff --git a/packages/eve/src/client/eve-agent-store.test.ts b/packages/eve/src/client/eve-agent-store.test.ts
index 72a106480..8cf182e72 100644
--- a/packages/eve/src/client/eve-agent-store.test.ts
+++ b/packages/eve/src/client/eve-agent-store.test.ts
@@ -196,12 +196,163 @@ function createStore<TData>(
return store;
}
+/**
+ * Runs client reconnect backoff (250ms per attempt) on a fake clock. Call
+ * `fastForwardTimers` once no stream is held open: auto-advancing while a
+ * held stream is open would also fire its read-idle timeout.
+ */
+function useFakeBackoffClock(): void {
+ vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
+}
+
+function fastForwardTimers(): void {
+ vi.setTimerTickMode("nextTimerAsync");
+}
+
afterEach(() => {
for (const cleanup of cleanupStores.splice(0)) cleanup();
+ vi.useRealTimers();
vi.restoreAllMocks();
vi.unstubAllGlobals();
});
+describe("EveAgentStore lifecycle", () => {
+ it("starts in ready status with empty data", () => {
+ const store = createStore({ reducer: defaultMessageReducer() });
+
+ expect(store.snapshot.status).toBe("ready");
+ expect(store.snapshot.data.messages).toEqual([]);
+ expect(store.snapshot.error).toBeUndefined();
+ expect(store.snapshot.events).toEqual([]);
+ });
+
+ it("sends a message and projects streamed events", async () => {
+ const events = turnEvents();
+ const start = Promise.withResolvers<Response>();
+ vi.spyOn(globalThis, "fetch")
+ .mockReturnValueOnce(start.promise)
+ .mockResolvedValueOnce(streamResponse(events));
+ const store = createStore({ reducer: defaultMessageReducer() });
+ const seenEvents: MessageStreamEvent[] = [];
+ const seenStreamIndexes: Array<number | undefined> = [];
+ store.setCallbacks({
+ onEvent: (event) => seenEvents.push(event),
+ onSessionChange: (session) => seenStreamIndexes.push(session?.streamIndex),
+ });
+
+ const sending = store.send({ message: "Hello" });
+ await Promise.resolve();
+
+ expect(store.snapshot.status).toBe("submitted");
+ expect(store.snapshot.data).toEqual({
+ messages: [
+ {
+ id: expect.stringMatching(/^optimistic:/),
+ metadata: { optimistic: true, status: "submitted" },
+ parts: [{ text: "Hello", type: "text" }],
+ role: "user",
+ },
+ ],
+ });
+
+ start.resolve(startedResponse());
+ await sending;
+
+ expect(seenEvents).toEqual(events);
+ expect(store.snapshot.status).toBe("ready");
+ expect(store.snapshot.data).toEqual({
+ messages: [
+ {
+ id: expect.stringMatching(/^evt_.+:user$/),
+ metadata: { status: "complete", turnId: "turn_1" },
+ parts: [{ state: "done", text: "Hello", type: "text" }],
+ role: "user",
+ },
+ {
+ id: "turn_1:assistant",
+ metadata: { status: "complete", turnId: "turn_1" },
+ parts: [
+ { type: "step-start" },
+ { state: "done", stepIndex: 0, text: "Hi there.", type: "text" },
+ ],
+ role: "assistant",
+ },
+ ],
+ });
+ expect(seenStreamIndexes).toEqual([0, 1, 2, 3, 3]);
+ });
+
+ it("surfaces transport errors", async () => {
+ vi.spyOn(globalThis, "fetch").mockRejectedValueOnce(new Error("Network failed"));
+ const store = createStore({ reducer: defaultMessageReducer() });
+ const onError = vi.fn();
+ store.setCallbacks({ onError });
+
+ await store.send({ message: "Hello" });
+
+ expect(onError).toHaveBeenCalledExactlyOnceWith(new Error("Network failed"));
+ expect(store.snapshot.status).toBe("error");
+ expect(store.snapshot.error?.message).toBe("Network failed");
+ });
+
+ it("resets state and creates a new session", async () => {
+ vi.spyOn(globalThis, "fetch").mockRejectedValueOnce(new Error("fail"));
+ const store = createStore({ reducer: defaultMessageReducer() });
+
+ await store.send({ message: "Hello" });
+ expect(store.snapshot.status).toBe("error");
+
+ store.reset();
+ expect(store.snapshot.status).toBe("ready");
+ expect(store.snapshot.data.messages).toEqual([]);
+ expect(store.snapshot.error).toBeUndefined();
+ expect(store.snapshot.events).toEqual([]);
+ });
+
+ it("unsubscribe removes the listener", () => {
+ const store = createStore({ reducer: defaultMessageReducer() });
+ const listener = vi.fn();
+ const unsubscribe = store.subscribe(listener);
+
+ store.reset();
+ expect(listener).toHaveBeenCalledOnce();
+
+ unsubscribe();
+ store.reset();
+ expect(listener).toHaveBeenCalledOnce();
+ });
+
+ it("projects input responses before the resumed stream returns", async () => {
+ const start = Promise.withResolvers<Response>();
+ vi.spyOn(globalThis, "fetch").mockImplementation(async (_request, init) =>
+ init?.method === "POST"
+ ? await start.promise
+ : streamResponse(stampTestEvents([createSessionWaitingEvent()])),
+ );
+ const store = createStore<readonly string[]>({
+ initialSession: { sessionId: "session_1", streamIndex: 0 },
+ reducer: {
+ initial: () => [],
+ reduce: (data, event) => [...data, event.type],
+ },
+ });
+
+ const sending = store.send({
+ inputResponses: [{ optionId: "cancel", requestId: "approval_1" }],
+ });
+ await Promise.resolve();
+
+ expect(store.snapshot.status).toBe("submitted");
+ expect(store.snapshot.data).toEqual(["client.input.responded"]);
+
+ start.resolve(startedResponse());
+ await sending;
+
+ expect(store.snapshot.status).toBe("ready");
+ expect(store.snapshot.data).toEqual(["client.input.responded", "session.waiting"]);
+ });
+});
+
describe("EveAgentStore prewarming", () => {
it("settles a send aborted during preparation without creating a session", async () => {
const fetchMock = vi.spyOn(globalThis, "fetch");
@@ -660,6 +811,8 @@ describe("EveAgentStore prewarming", () => {
describe("EveAgentStore stream overlap", () => {
it("reconstructs a split message across an in-memory stream reconnect", async () => {
+ useFakeBackoffClock();
+ fastForwardTimers();
const events = streamingTurnEvents();
const fetchMock = vi
.spyOn(globalThis, "fetch")
@@ -695,6 +848,8 @@ describe("EveAgentStore stream overlap", () => {
it.each(["21", "24"] as const)(
"reconstructs a split message across a v%s-to-v25 reconnect",
async (legacyVersion) => {
+ useFakeBackoffClock();
+ fastForwardTimers();
const current = streamingTurnEvents();
const received = current[0]!;
const started = current[1]!;
@@ -1039,6 +1194,8 @@ describe("EveAgentStore session resume", () => {
});
it("continues a split message from a complete hydrated prefix", async () => {
+ useFakeBackoffClock();
+ fastForwardTimers();
const events = streamingTurnEvents();
const prefix = events.slice(0, 3);
const fetchMock = vi
@@ -1073,6 +1230,8 @@ describe("EveAgentStore session resume", () => {
});
it("replays a split message from index zero when only its cursor was retained", async () => {
+ useFakeBackoffClock();
+ fastForwardTimers();
const events = streamingTurnEvents();
const fetchMock = vi
.spyOn(globalThis, "fetch")
@@ -1156,6 +1315,7 @@ describe("EveAgentStore session resume", () => {
});
it("moves an unsettled hydrated snapshot to streaming before following it", async () => {
+ useFakeBackoffClock();
const [received, started, completed, waiting] = stampTestEvents([
createMessageReceivedEvent({ message: "Hello", sequence: 0, turnId: "turn_1" }),
createTurnStartedEvent({ sequence: 1, turnId: "turn_1" }),
@@ -1192,6 +1352,7 @@ describe("EveAgentStore session resume", () => {
live.emit(completed!);
live.emit(waiting!);
live.close();
+ fastForwardTimers();
await resuming;
expect(store.snapshot.status).toBe("ready");
@@ -1386,6 +1547,7 @@ describe("EveAgentStore session resume", () => {
});
it("replays history and follows an interrupted turn through its boundary", async () => {
+ useFakeBackoffClock();
const [received, started, completed, waiting] = stampTestEvents([
createMessageReceivedEvent({ message: "Hello", sequence: 0, turnId: "turn_1" }),
createTurnStartedEvent({ sequence: 1, turnId: "turn_1" }),
@@ -1422,6 +1584,7 @@ describe("EveAgentStore session resume", () => {
live.emit(completed!);
live.emit(waiting!);
live.close();
+ fastForwardTimers();
await resuming;
expect(store.snapshot.status).toBe("ready");
diff --git a/packages/eve/src/discover/diagnostics.ts b/packages/eve/src/discover/diagnostics.ts
index 3e249f7ed..866ebcaee 100644
--- a/packages/eve/src/discover/diagnostics.ts
+++ b/packages/eve/src/discover/diagnostics.ts
@@ -105,10 +105,3 @@ export function summarizeDiscoverDiagnostics(
},
);
}
-
-/**
- * Returns whether discovery diagnostics include at least one error.
- */
-export function hasDiscoverErrors(diagnostics: readonly DiscoverDiagnostic[]): boolean {
- return diagnostics.some((diagnostic) => diagnostic.severity === "error");
-}
diff --git a/packages/eve/src/evals/runner/reporters/braintrust.test.ts b/packages/eve/src/evals/runner/reporters/braintrust.test.ts
index b3e8867f3..2236c85f5 100644
--- a/packages/eve/src/evals/runner/reporters/braintrust.test.ts
+++ b/packages/eve/src/evals/runner/reporters/braintrust.test.ts
@@ -105,14 +105,6 @@ describe("Braintrust", () => {
});
});
- it("creates a reporter", () => {
- const reporter = Braintrust(makeConfig());
- expect(reporter).toBeDefined();
- expect(reporter.onRunStart).toBeTypeOf("function");
- expect(reporter.onEvalComplete).toBeTypeOf("function");
- expect(reporter.onRunComplete).toBeTypeOf("function");
- });
-
it("onEvalComplete is a no-op when experiment is not initialized", () => {
const reporter = Braintrust(makeConfig());
diff --git a/packages/eve/src/execution/sandbox/bindings/just-bash.scenario.test.ts b/packages/eve/src/execution/sandbox/bindings/just-bash.scenario.test.ts
index fba5b5a32..144a2c4a6 100644
--- a/packages/eve/src/execution/sandbox/bindings/just-bash.scenario.test.ts
+++ b/packages/eve/src/execution/sandbox/bindings/just-bash.scenario.test.ts
@@ -383,11 +383,6 @@ describe("just-bash custom commands", () => {
});
describe("just-bash provider", () => {
- it("exposes a distinct stable provider name", () => {
- const provider = createJustBashProvider();
- expect(provider).toBeDefined();
- });
-
it("creates a fresh session when no template key is requested", async () => {
const appRoot = await createTemporaryCacheDirectory("fresh-session");
const provider = createJustBashProvider();
diff --git a/packages/eve/src/execution/sandbox/bindings/vercel.test.ts b/packages/eve/src/execution/sandbox/bindings/vercel.test.ts
index 6b1fb61da..f8b2afd05 100644
--- a/packages/eve/src/execution/sandbox/bindings/vercel.test.ts
+++ b/packages/eve/src/execution/sandbox/bindings/vercel.test.ts
@@ -964,11 +964,6 @@ describe("createVercelSandbox", () => {
);
});
- it("exposes a stable provider name", () => {
- const provider = createTestVercelSandbox();
- expect(provider).toBeDefined();
- });
-
it("prepares the base runtime during sandbox init", async () => {
const templateSandbox = createMockSandbox({ name: "template" });
const sessionSandbox = createMockSandbox({ name: "session" });
diff --git a/packages/eve/src/execution/session-inbox/inbox.integration.test.ts b/packages/eve/src/execution/session-inbox/inbox.integration.test.ts
index d06c9018f..fc80352b6 100644
--- a/packages/eve/src/execution/session-inbox/inbox.integration.test.ts
+++ b/packages/eve/src/execution/session-inbox/inbox.integration.test.ts
@@ -52,61 +52,4 @@ describe("session command inbox integration", () => {
if (status === "pending" || status === "running") await run.cancel();
}
});
-
- it("accepts commands alternately through the stable ID and channel aliases", async () => {
- const channelToken = "http:session-inbox:both-aliases";
- const run = await start(sessionCommandInboxWorkflow, [{ token: channelToken }]);
- const stableToken = sessionInboxHookToken(sessionCommandHookToken(run.runId));
-
- try {
- await Promise.all([
- waitForHook({ runId: run.runId }, { token: stableToken }),
- waitForHook({ runId: run.runId }, { token: sessionInboxHookToken(channelToken) }),
- ]);
-
- await resumeHook(stableToken, { kind: "send", payload: { message: "by id" } });
- await resumeHook(sessionInboxHookToken(channelToken), {
- kind: "deliver",
- payloads: [{ message: "by channel" }],
- });
-
- await expect(run.returnValue).resolves.toEqual(["by id", "by channel"]);
- } finally {
- const status = await run.status;
- if (status === "pending" || status === "running") await run.cancel();
- }
- });
-
- it("keeps every claimed continuation address active", async () => {
- const oldToken = "http:session-inbox:additive:old";
- const replacementToken = "http:session-inbox:additive:replacement";
- const run = await start(sessionCommandInboxWorkflow, [
- { messageCount: 3, nextToken: replacementToken, token: oldToken },
- ]);
-
- try {
- await Promise.all([
- waitForHook({ runId: run.runId }, { token: sessionInboxHookToken(oldToken) }),
- waitForHook({ runId: run.runId }, { token: sessionInboxHookToken(replacementToken) }),
- ]);
-
- await resumeHook(sessionInboxHookToken(replacementToken), {
- kind: "send",
- payload: { message: "replacement" },
- });
- await resumeHook(sessionInboxHookToken(oldToken), {
- kind: "send",
- payload: { message: "old" },
- });
- await resumeHook(sessionInboxHookToken(replacementToken), {
- kind: "send",
- payload: { message: "replacement again" },
- });
-
- await expect(run.returnValue).resolves.toEqual(["replacement", "old", "replacement again"]);
- } finally {
- const status = await run.status;
- if (status === "pending" || status === "running") await run.cancel();
- }
- });
});
diff --git a/packages/eve/src/execution/session-reset.integration.test.ts b/packages/eve/src/execution/session-reset.integration.test.ts
index 106a16cba..524d67992 100644
--- a/packages/eve/src/execution/session-reset.integration.test.ts
+++ b/packages/eve/src/execution/session-reset.integration.test.ts
@@ -41,7 +41,7 @@ describe("session reset integration", () => {
}),
).resolves.toEqual({ previousSessionId: first.runId, status: "reset" });
- await expect(first.returnValue).resolves.toEqual([]);
+ await expect(first.returnValue).resolves.toBeUndefined();
await expect(runtime.resolveContinuation(continuationToken)).resolves.toBeUndefined();
const second = await start(sessionCommandInboxWorkflow, [{ token: continuationToken }]);
diff --git a/packages/eve/src/harness/attachment-staging.integration.test.ts b/packages/eve/src/harness/attachment-staging.integration.test.ts
index f6272658c..49075cee0 100644
--- a/packages/eve/src/harness/attachment-staging.integration.test.ts
+++ b/packages/eve/src/harness/attachment-staging.integration.test.ts
@@ -27,44 +27,6 @@ import {
*/
describe("stageAttachmentsToSandbox (integration)", () => {
- it("writes FilePart bytes into the active sandbox and rewrites data to an eve-sandbox: ref", async () => {
- const sandbox = mockSandbox({ id: "sbx_integration" });
- const runtime = await createTestRuntime();
- const csvBytes = Buffer.from("id,name\n1,alpha\n", "utf8");
-
- const content: UserContent = [
- { type: "text", text: "summarize this csv" },
- { data: csvBytes, filename: "report.csv", mediaType: "text/csv", type: "file" },
- ];
-
- const staged = (await runtime.runAsSession({ sandbox }, async () =>
- stageAttachmentsToSandbox(content),
- )) as UserContent;
-
- expect(Array.isArray(staged)).toBe(true);
- expect(staged).toHaveLength(2);
- expect(staged[0]).toEqual({ type: "text", text: "summarize this csv" });
-
- const filePart = staged[1] as FilePart;
- expect(filePart.mediaType).toBe("text/csv");
- // Staged `data` is an eve-sandbox: ref (NOT raw bytes). The
- // refactor's key invariant: bytes never travel on the message,
- // only the ref does.
- expect(isSandboxRefUrl(filePart.data)).toBe(true);
- const ref = decodeSandboxRef(filePart.data as URL);
- expect(ref.mediaType).toBe("text/csv");
- expect(ref.size).toBe(csvBytes.byteLength);
- expect(ref.path).toMatch(/^\/workspace\/attachments\/[0-9a-f]{16}\/report\.csv$/);
- expect(filePart.filename).toBe(ref.path);
-
- expect(sandbox.writes).toHaveLength(1);
- const write = sandbox.writes[0];
- expect(write?.path).toMatch(new RegExp(`^${ATTACHMENTS_ROOT}/[0-9a-f]{16}/report\\.csv$`));
- const writtenBytes = write?.content as Buffer;
- expect(Buffer.isBuffer(writtenBytes)).toBe(true);
- expect(writtenBytes.equals(csvBytes)).toBe(true);
- });
-
it("exposes the staged path to authored tools via getSandbox().readFile", async () => {
const sandbox = mockSandbox({ id: "sbx_roundtrip" });
const readTool = mockTool({
@@ -96,18 +58,6 @@ describe("stageAttachmentsToSandbox (integration)", () => {
expect(result).toBe(payload);
});
- it("passes text-only messages through without touching the sandbox", async () => {
- const sandbox = mockSandbox({ id: "sbx_text" });
- const runtime = await createTestRuntime();
-
- const result = await runtime.runAsSession({ sandbox }, async () =>
- stageAttachmentsToSandbox("hello"),
- );
-
- expect(result).toBe("hello");
- expect(sandbox.writes).toHaveLength(0);
- });
-
it("passes UserContent arrays with no FileParts through untouched", async () => {
const sandbox = mockSandbox({ id: "sbx_no_files" });
const runtime = await createTestRuntime();
diff --git a/packages/eve/src/harness/authorization.ts b/packages/eve/src/harness/authorization.ts
index f5da7148b..2a6f29c1a 100644
--- a/packages/eve/src/harness/authorization.ts
+++ b/packages/eve/src/harness/authorization.ts
@@ -110,26 +110,6 @@ export function requestAuthorization(
return { [AUTHORIZATION_BRAND]: true, challenges };
}
-/**
- * Returns a model-safe copy of `signal` with runtime-only challenge state stripped.
- *
- * Used for the copy the AI SDK records as a tool output. The shape stays a
- * valid {@link AuthorizationSignal} so every `isAuthorizationSignal` consumer
- * still detects it; the park detector reads the full resume, principal, and
- * resolved-instance state from the harness's out-of-band stash.
- */
-export function redactSignalResume(signal: AuthorizationSignal): AuthorizationSignal {
- return requestAuthorization(
- signal.challenges.map((entry) => ({
- attemptId: entry.attemptId,
- candidateId: entry.candidateId,
- name: entry.name,
- challenge: entry.challenge,
- hookUrl: entry.hookUrl,
- })),
- );
-}
-
/**
* Reads the authorization callback on resume. Returns `undefined` if
* not resuming from an authorization request.
diff --git a/packages/eve/src/harness/prompt-cache-accounting.test.ts b/packages/eve/src/harness/prompt-cache-accounting.test.ts
deleted file mode 100644
index a2431aae7..000000000
--- a/packages/eve/src/harness/prompt-cache-accounting.test.ts
+++ /dev/null
@@ -1,466 +0,0 @@
-import type { ModelMessage } from "ai";
-import { describe, expect, it } from "vitest";
-
-import {
- type AnthropicCacheMarker,
- applyConversationCacheControl,
- getAnthropicCacheMarker,
-} from "#harness/prompt-cache.js";
-
-/**
- * Deterministic replay of two production benchmark traces that reported
- * ~45–48% prompt cache hit rates.
- *
- * A small simulator implements Anthropic's prefix-cache accounting rules:
- *
- * - `cache_read` = the previously cached prefix (when it still prefixes
- * the request and ends at or before the last breakpoint),
- * - `cache_write` = tokens between the read prefix and the last breakpoint,
- * - `input` = tokens after the last breakpoint (billed uncached,
- * never written).
- *
- * Driving the simulator with the legacy breakpoint placement (last
- * assistant + last user, tool messages skipped) reproduces the traces'
- * recorded `turn_usage` token-for-token on every turn after the first —
- * proving the observed percentages were caused by breakpoint placement,
- * not by cache invalidation. The fixed placement (last message + prior
- * assistant anchor) run on the identical workload eliminates all uncached
- * input: every token is written to the cache in the request that first
- * carries it, which is the accounting optimum.
- *
- * Convention: 1 character = 1 token, so message sizes are exact.
- */
-
-// ---------------------------------------------------------------------------
-// Token-sized message builders
-// ---------------------------------------------------------------------------
-
-function userMessage(tokens: number): ModelMessage {
- return { role: "user", content: "x".repeat(tokens) };
-}
-
-function assistantMessage(tokens: number): ModelMessage {
- return { role: "assistant", content: "x".repeat(tokens) };
-}
-
-function toolResultMessage(tokens: number): ModelMessage {
- return {
- role: "tool",
- content: [
- {
- type: "tool-result",
- toolCallId: "call",
- toolName: "fetch",
- output: { type: "text", value: "x".repeat(tokens) },
- },
- ],
- };
-}
-
-function tokensOf(message: ModelMessage): number {
- if (typeof message.content === "string") {
- return message.content.length;
- }
- let total = 0;
- for (const part of message.content) {
- if (part.type === "text") {
- total += part.text.length;
- } else if (part.type === "tool-result" && part.output.type === "text") {
- total += part.output.value.length;
- }
- }
- return total;
-}
-
-function isMarked(message: ModelMessage): boolean {
- const options = message.providerOptions as { anthropic?: { cacheControl?: unknown } } | undefined;
- return options?.anthropic?.cacheControl !== undefined;
-}
-
-// ---------------------------------------------------------------------------
-// Anthropic prefix-cache accounting simulator
-// ---------------------------------------------------------------------------
-
-interface TurnUsage {
- readonly input: number;
- readonly cacheRead: number;
- readonly cacheWrite: number;
-}
-
-class PrefixCacheAccounting {
- private cachedPrefixTokens: number;
-
- constructor(warmPrefixTokens: number) {
- this.cachedPrefixTokens = warmPrefixTokens;
- }
-
- /**
- * Accounts one request. `baseTokens` models the system prompt and tool
- * definitions, which the harness always covers with their own
- * breakpoints (`applySystemCacheBreakpoint`, `applyLastToolCacheBreakpoint`).
- */
- request(baseTokens: number, messages: readonly ModelMessage[]): TurnUsage {
- let total = baseTokens;
- let lastBreakpoint = baseTokens;
- for (const message of messages) {
- total += tokensOf(message);
- if (isMarked(message)) {
- lastBreakpoint = total;
- }
- }
- const cacheRead = Math.min(this.cachedPrefixTokens, lastBreakpoint);
- const cacheWrite = lastBreakpoint - cacheRead;
- const input = total - lastBreakpoint;
- this.cachedPrefixTokens = Math.max(this.cachedPrefixTokens, lastBreakpoint);
- return { input, cacheRead, cacheWrite };
- }
-}
-
-// ---------------------------------------------------------------------------
-// Legacy breakpoint placement (pre-fix), preserved to prove the regression
-// ---------------------------------------------------------------------------
-
-function legacyApplyConversationCacheControl(
- messages: readonly ModelMessage[],
- marker: AnthropicCacheMarker,
-): ModelMessage[] {
- const out = [...messages];
- let foundAssistant = false;
- let foundUser = false;
-
- for (let i = out.length - 1; i >= 0 && (!foundAssistant || !foundUser); i--) {
- const message = out[i];
- if (message === undefined) continue;
-
- if (!foundAssistant && message.role === "assistant") {
- out[i] = { ...message, providerOptions: { ...message.providerOptions, ...marker } };
- foundAssistant = true;
- } else if (!foundUser && message.role === "user") {
- out[i] = { ...message, providerOptions: { ...message.providerOptions, ...marker } };
- foundUser = true;
- }
- }
-
- return out;
-}
-
-// ---------------------------------------------------------------------------
-// Benchmark trace workloads
-// ---------------------------------------------------------------------------
-
-interface TraceScenario {
- readonly name: string;
- /** System prompt + tool definitions, always behind their own breakpoints. */
- readonly systemAndTools: number;
- /** The initial user task message. */
- readonly userTask: number;
- /** Cache warmth carried over from a sibling run sharing the system prefix. */
- readonly warmPrefix: number;
- /**
- * Serialized size of each assistant message when it re-enters the prompt.
- * Derived from the trace identity `cache_write(t+1) - input(t)`.
- */
- readonly assistantTurns: readonly number[];
- /** Tool results appended after each turn. Derived from `input(t+1)`. */
- readonly toolResults: readonly number[];
- /** `turn_usage` as recorded in the benchmark trace JSON. */
- readonly observed: readonly TurnUsage[];
- /** Exact served-from-cache rate under the legacy breakpoint placement. */
- readonly legacyServedFromCache: number;
- /** Exact served-from-cache rate under the fixed breakpoint placement. */
- readonly fixedServedFromCache: number;
-}
-
-const SCENARIOS: readonly TraceScenario[] = [
- {
- // Run 3c803a51-bb6a-4a05-88a5-42ca75f49fa5, claude-fable-5, 5 turns.
- name: "3c803a51 (claude-fable-5)",
- systemAndTools: 4565,
- userTask: 782,
- warmPrefix: 4565,
- assistantTurns: [168, 180, 127, 151],
- toolResults: [4466, 568, 7702, 19286],
- observed: [
- { input: 2, cacheRead: 4565, cacheWrite: 782 },
- { input: 4466, cacheRead: 5347, cacheWrite: 168 },
- { input: 568, cacheRead: 5515, cacheWrite: 4646 },
- { input: 7702, cacheRead: 10161, cacheWrite: 695 },
- { input: 19286, cacheRead: 10856, cacheWrite: 7853 },
- ],
- // 36444 read / (36444 read + 32022 input + 14144 write) = 44.12%
- legacyServedFromCache: 0.441157,
- // 49180 read / (49180 read + 0 input + 33430 write) = 59.53%
- fixedServedFromCache: 0.595327,
- },
- {
- // Run e7757164-b009-4bea-9a7f-f97d2e18ea9f, claude-haiku-4-5, 7 turns.
- name: "e7757164 (claude-haiku-4-5)",
- systemAndTools: 4179,
- userTask: 0,
- warmPrefix: 0,
- assistantTurns: [222, 205, 217, 165, 160, 167],
- toolResults: [8149, 3547, 8144, 16433, 9911, 23482],
- observed: [
- { input: 3, cacheRead: 0, cacheWrite: 4179 },
- { input: 8149, cacheRead: 4179, cacheWrite: 222 },
- { input: 3547, cacheRead: 4401, cacheWrite: 8354 },
- { input: 8144, cacheRead: 12755, cacheWrite: 3764 },
- { input: 16433, cacheRead: 16519, cacheWrite: 8309 },
- { input: 9911, cacheRead: 24828, cacheWrite: 16593 },
- { input: 23482, cacheRead: 41421, cacheWrite: 10078 },
- ],
- // 104103 read / (104103 read + 69666 input + 51499 write) = 46.21%
- legacyServedFromCache: 0.46213,
- // 150287 read / (150287 read + 0 input + 74981 write) = 66.71%
- fixedServedFromCache: 0.667148,
- },
-];
-
-type BreakpointStrategy = (
- messages: readonly ModelMessage[],
- marker: AnthropicCacheMarker,
-) => ModelMessage[];
-
-function replayToolLoop(scenario: TraceScenario, strategy: BreakpointStrategy): TurnUsage[] {
- const marker = getAnthropicCacheMarker();
- const accounting = new PrefixCacheAccounting(scenario.warmPrefix);
- const history: ModelMessage[] = [userMessage(scenario.userTask)];
- const usage: TurnUsage[] = [];
-
- for (let turn = 0; turn < scenario.observed.length; turn++) {
- usage.push(accounting.request(scenario.systemAndTools, strategy(history, marker)));
- if (turn < scenario.observed.length - 1) {
- history.push(
- assistantMessage(scenario.assistantTurns[turn]!),
- toolResultMessage(scenario.toolResults[turn]!),
- );
- }
- }
-
- return usage;
-}
-
-/** Fraction of all prompt tokens served from cache: read / (read + input + write). */
-function servedFromCache(usage: readonly TurnUsage[]): number {
- let read = 0;
- let uncached = 0;
- for (const turn of usage) {
- read += turn.cacheRead;
- uncached += turn.input + turn.cacheWrite;
- }
- return read / (read + uncached);
-}
-
-/** Fraction of previously seen prompt tokens served from cache: read / (read + input). */
-function inputCacheRate(usage: readonly TurnUsage[]): number {
- let read = 0;
- let input = 0;
- for (const turn of usage) {
- read += turn.cacheRead;
- input += turn.input;
- }
- return read / (read + input);
-}
-
-// ---------------------------------------------------------------------------
-// Grep-heavy coding session
-// ---------------------------------------------------------------------------
-
-/**
- * Deterministic grep-shaped output: `path:line: code` match lines, the way a
- * search tool floods a coding agent's context. These are the largest tool
- * results in practice, which makes them the costliest content to leave
- * outside the final cache breakpoint.
- */
-function grepOutput(query: string, matches: number): string {
- const lines: string[] = [];
- for (let i = 0; i < matches; i++) {
- lines.push(
- `src/module-${i % 23}/file-${i % 7}.ts:${100 + i}: ` +
- `const ${query}Result${i} = resolve${i % 5}(${query}, ctx.session);`,
- );
- }
- return lines.join("\n");
-}
-
-/** One tool message carrying one or more tool results (parallel calls). */
-function grepResultsMessage(outputs: readonly string[]): ModelMessage {
- return {
- role: "tool",
- content: outputs.map((text, index) => ({
- type: "tool-result",
- toolCallId: `call-${index}`,
- toolName: "grep",
- output: { type: "text", value: text },
- })),
- };
-}
-
-interface GrepStep {
- /** Assistant commentary + tool-call framing preceding the results. */
- readonly commentary: number;
- /** Grep outputs returned by this step's tool call(s). */
- readonly results: readonly string[];
-}
-
-const GREP_SESSION: readonly GrepStep[] = [
- { commentary: 140, results: [grepOutput("applyConversationCacheControl", 80)] },
- // A broad query floods the context, the classic coding-agent step.
- { commentary: 130, results: [grepOutput("cacheControl", 340)] },
- // Parallel fan-out: three greps land in one tool message.
- {
- commentary: 160,
- results: [
- grepOutput("providerOptions", 200),
- grepOutput("ephemeral", 190),
- grepOutput("breakpoint", 210),
- ],
- },
- { commentary: 120, results: [grepOutput("prepareStep", 130)] },
- { commentary: 150, results: [grepOutput("toolResult", 760)] },
-];
-
-const GREP_BASE_TOKENS = 3200;
-const GREP_TASK_TOKENS = 900;
-
-function replayGrepSession(strategy: BreakpointStrategy): TurnUsage[] {
- const marker = getAnthropicCacheMarker();
- const accounting = new PrefixCacheAccounting(0);
- const history: ModelMessage[] = [userMessage(GREP_TASK_TOKENS)];
- const usage: TurnUsage[] = [];
-
- for (const step of GREP_SESSION) {
- usage.push(accounting.request(GREP_BASE_TOKENS, strategy(history, marker)));
- history.push(assistantMessage(step.commentary), grepResultsMessage(step.results));
- }
-
- // Final step: the model reads the last grep results and answers.
- usage.push(accounting.request(GREP_BASE_TOKENS, strategy(history, marker)));
- return usage;
-}
-
-function totalGrepTokens(): number {
- let total = 0;
- for (const step of GREP_SESSION) {
- for (const text of step.results) {
- total += text.length;
- }
- }
- return total;
-}
-
-// ---------------------------------------------------------------------------
-// The proof
-// ---------------------------------------------------------------------------
-
-describe("prompt cache accounting replayed from benchmark traces", () => {
- for (const scenario of SCENARIOS) {
- describe(scenario.name, () => {
- it("legacy placement reproduces the recorded turn_usage token-for-token", () => {
- const usage = replayToolLoop(scenario, legacyApplyConversationCacheControl);
-
- // Turn 1 differs only by the trace's 2–3 structural overhead tokens
- // (request framing not attributable to any message).
- expect(usage[0]!.cacheRead).toBe(scenario.observed[0]!.cacheRead);
- expect(usage[0]!.cacheWrite).toBe(scenario.observed[0]!.cacheWrite);
-
- // Every subsequent turn matches the trace exactly on all three
- // columns: the reported hit rate is fully explained by placement.
- expect(usage.slice(1)).toEqual(scenario.observed.slice(1));
- });
-
- it("legacy placement yields the exact reported served-from-cache percentage", () => {
- const usage = replayToolLoop(scenario, legacyApplyConversationCacheControl);
- const simulated = servedFromCache(usage);
- const observed = servedFromCache(scenario.observed);
-
- // The simulated rate matches both the rate computed from the raw
- // trace and the hardcoded expected value — 44.12% (fable) and
- // 46.21% (haiku), the numbers behind the "45–48%" reports.
- expect(Math.abs(simulated - observed)).toBeLessThan(0.001);
- expect(simulated).toBeCloseTo(scenario.legacyServedFromCache, 5);
- });
-
- it("fixed placement yields the exact predicted served-from-cache percentage", () => {
- const usage = replayToolLoop(scenario, applyConversationCacheControl);
-
- // 59.53% (fable) and 66.71% (haiku) — the workload ceiling, since
- // every remaining non-read token is a mandatory first-time write.
- expect(servedFromCache(usage)).toBeCloseTo(scenario.fixedServedFromCache, 5);
- });
-
- it("fixed placement eliminates uncached input entirely on the same workload", () => {
- const usage = replayToolLoop(scenario, applyConversationCacheControl);
-
- for (const turn of usage) {
- expect(turn.input).toBe(0);
- }
- });
-
- it("fixed placement writes every token exactly once (accounting optimum)", () => {
- const usage = replayToolLoop(scenario, applyConversationCacheControl);
-
- const finalRequestTokens =
- scenario.systemAndTools +
- scenario.userTask +
- scenario.assistantTurns.reduce((a, b) => a + b, 0) +
- scenario.toolResults.reduce((a, b) => a + b, 0);
- const totalWrites =
- scenario.warmPrefix + usage.reduce((sum, turn) => sum + turn.cacheWrite, 0);
-
- expect(totalWrites).toBe(finalRequestTokens);
- });
-
- it("fixed placement beats legacy served-from-cache on the same workload", () => {
- const legacy = servedFromCache(
- replayToolLoop(scenario, legacyApplyConversationCacheControl),
- );
- const fixed = servedFromCache(replayToolLoop(scenario, applyConversationCacheControl));
-
- expect(fixed).toBeGreaterThan(legacy);
- });
- });
- }
-});
-
-describe("grep-heavy coding session", () => {
- it("legacy placement bills every grep result at the uncached rate exactly once", () => {
- const usage = replayGrepSession(legacyApplyConversationCacheControl);
-
- const uncached = usage.reduce((sum, turn) => sum + turn.input, 0);
- expect(uncached).toBe(totalGrepTokens());
- });
-
- it("legacy placement caps the input-cache rate near 50%", () => {
- const rate = inputCacheRate(replayGrepSession(legacyApplyConversationCacheControl));
-
- expect(rate).toBeGreaterThan(0.4);
- expect(rate).toBeLessThan(0.6);
- });
-
- it("fixed placement never bills a grep result uncached", () => {
- const usage = replayGrepSession(applyConversationCacheControl);
-
- for (const turn of usage) {
- expect(turn.input).toBe(0);
- }
- expect(inputCacheRate(usage)).toBeGreaterThan(0.99);
- });
-
- it("fixed placement covers parallel tool results with one trailing breakpoint", () => {
- // Reads always chain: read(t) equals everything cached through t-1, so
- // the multi-result fan-out step is fully re-read, never re-billed.
- const usage = replayGrepSession(applyConversationCacheControl);
- for (let i = 1; i < usage.length; i++) {
- expect(usage[i]!.cacheRead).toBe(usage[i - 1]!.cacheRead + usage[i - 1]!.cacheWrite);
- }
-
- const finalRequestTokens =
- GREP_BASE_TOKENS +
- GREP_TASK_TOKENS +
- GREP_SESSION.reduce((sum, step) => sum + step.commentary, 0) +
- totalGrepTokens();
- const totalWrites = usage.reduce((sum, turn) => sum + turn.cacheWrite, 0);
- expect(totalWrites).toBe(finalRequestTokens);
- });
-});
diff --git a/packages/eve/src/harness/tool-interrupts.test.ts b/packages/eve/src/harness/tool-interrupts.test.ts
index 418e879dd..f48081b48 100644
--- a/packages/eve/src/harness/tool-interrupts.test.ts
+++ b/packages/eve/src/harness/tool-interrupts.test.ts
@@ -7,9 +7,7 @@ import {
type AuthorizationSignal,
authorizationPendingAsJsonObject,
isAuthorizationPendingModelOutput,
- isAuthorizationSignal,
modelFacingAuthorizationOutput,
- redactSignalResume,
requestAuthorization,
} from "#harness/authorization.js";
import { createRuntimeToolResultFromValue } from "#harness/action-result-helpers.js";
@@ -64,22 +62,6 @@ describe("authorizationPendingAsJsonObject", () => {
});
});
-describe("redactSignalResume", () => {
- it("strips runtime-only state but keeps the model-safe challenge fields", () => {
- const redacted = redactSignalResume(signalWithVerifier());
- expect(isAuthorizationSignal(redacted)).toBe(true);
- expect(redacted.challenges[0]).toEqual({
- attemptId: "attempt-linear",
- name: "linear",
- challenge: { url: "https://idp.example/auth" },
- hookUrl: "https://app.example/cb",
- });
- expect(redacted.challenges[0]).not.toHaveProperty("instanceId");
- expect(redacted.challenges[0]).not.toHaveProperty("resume");
- expect(redacted.challenges[0]).not.toHaveProperty("principal");
- });
-});
-
describe("tool-interrupt stash", () => {
it("stores per toolCallId and is never serialized", () => {
const ctx = new ContextContainer();
diff --git a/packages/eve/src/harness/tool-loop.test.ts b/packages/eve/src/harness/tool-loop.test.ts
index ec85627e0..f5b97356d 100644
--- a/packages/eve/src/harness/tool-loop.test.ts
+++ b/packages/eve/src/harness/tool-loop.test.ts
@@ -88,7 +88,7 @@ import { PendingSkillAnnouncementKey } from "#context/dynamic-skill-lifecycle.js
import { deserializeContext, serializeContext } from "#context/serialize.js";
import { stashToolInterrupt } from "#harness/tool-interrupts.js";
import { appendMissingToolResultMessages, createToolLoopHarness } from "#harness/tool-loop.js";
-import { isSessionLimitDecline, TurnCancelledError } from "#harness/turn-cancellation.js";
+import { SessionLimitDeclinedError, TurnCancelledError } from "#harness/turn-cancellation.js";
import {
getSessionUsageLimitViolation,
getSessionTokenUsage,
@@ -2497,7 +2497,7 @@ describe("createToolLoopHarness", () => {
// execution layer settles as `turn.cancelled` → `session.waiting` (and,
// for delegated sessions, escalates to a root-turn cancel). No failure
// or completion events are emitted here.
- await expect(declined).rejects.toSatisfy((error) => isSessionLimitDecline(error));
+ await expect(declined).rejects.toBeInstanceOf(SessionLimitDeclinedError);
expect(vi.mocked(ToolLoopAgent)).not.toHaveBeenCalled();
expect(events.some((event) => event.type.endsWith(".failed"))).toBe(false);
expect(events.some((event) => event.type === "session.completed")).toBe(false);
@@ -9873,52 +9873,6 @@ describe("createToolLoopHarness", () => {
});
});
- it("gateway-auto path: respects author override of gateway.caching", async () => {
- setupStopResult();
- const session = createTestSession({
- agent: {
- modelReference: {
- id: "anthropic/claude-sonnet-4-5",
- providerOptions: { gateway: { caching: false } },
- },
- system: "",
- tools: [{ description: "Adds numbers", name: "add", inputSchema: { type: "object" } }],
- },
- });
- const config: ToolLoopHarnessConfig = {
- resolveModel: vi.fn().mockResolvedValue("anthropic/claude-sonnet-4-5"),
- tools: new Map([
- [
- "add",
- {
- description: "Adds numbers",
- execute: vi.fn(),
- inputSchema: jsonSchema({ type: "object" }),
- name: "add",
- },
- ],
- ]),
- };
- const runStep = createToolLoopHarness(config);
- await runStep(session, { message: "hi" });
-
- const agentCall = vi.mocked(ToolLoopAgent).mock.calls[0]?.[0];
- // providerOptions is now returned by prepareStep, not set on the constructor
- const prepareStep = getPrepareStep<unknown[], { providerOptions?: unknown }>(
- agentCall?.prepareStep,
- );
- const stepResult = await prepareStep({
- messages: [],
- stepNumber: 0,
- steps: [],
- model: agentCall?.model,
- context: undefined,
- });
- expect(stepResult.providerOptions).toEqual({
- gateway: { caching: false, sessionId: "test-session" },
- });
- });
-
it("anthropic-direct path: marks the last tool without dropping approval", async () => {
setupStopResult();
const config: ToolLoopHarnessConfig = {
diff --git a/packages/eve/src/harness/turn-cancellation.test.ts b/packages/eve/src/harness/turn-cancellation.test.ts
index df8a7c4e8..6d5009951 100644
--- a/packages/eve/src/harness/turn-cancellation.test.ts
+++ b/packages/eve/src/harness/turn-cancellation.test.ts
@@ -1,7 +1,6 @@
import { describe, expect, it } from "vitest";
import {
- isSessionLimitDecline,
isTurnCancellation,
SessionLimitDeclinedError,
throwIfTurnAborted,
@@ -53,29 +52,11 @@ describe("isTurnCancellation", () => {
});
describe("SessionLimitDeclinedError", () => {
- it("is a turn cancellation carrying the decline marker", () => {
+ it("is a turn cancellation with the canonical name", () => {
const error = new SessionLimitDeclinedError();
// Keeps the canonical name so every existing cancellation check matches.
expect(error.name).toBe("TurnCancelledError");
expect(isTurnCancellation(error)).toBe(true);
- expect(isSessionLimitDecline(error)).toBe(true);
- });
-});
-
-describe("isSessionLimitDecline", () => {
- it("walks the cause chain and ignores plain cancellations", () => {
- const wrapped = new Error("outer", { cause: new SessionLimitDeclinedError() });
- expect(isSessionLimitDecline(wrapped)).toBe(true);
-
- expect(isSessionLimitDecline(new TurnCancelledError())).toBe(false);
- expect(isSessionLimitDecline(undefined)).toBe(false);
- });
-
- it("survives a cause cycle", () => {
- const a = new Error("a");
- const b = new Error("b", { cause: a });
- (a as { cause?: unknown }).cause = b;
- expect(isSessionLimitDecline(a)).toBe(false);
});
});
diff --git a/packages/eve/src/harness/turn-cancellation.ts b/packages/eve/src/harness/turn-cancellation.ts
index 090085266..04a74d565 100644
--- a/packages/eve/src/harness/turn-cancellation.ts
+++ b/packages/eve/src/harness/turn-cancellation.ts
@@ -10,35 +10,15 @@ export class TurnCancelledError extends Error {
/**
* A turn cancellation raised when the user declines a session-limit
- * continuation prompt. Carries intent only — the execution layer detects it
- * at the step boundary and cancels the root turn, so a delegated child's
- * decline stops the whole delegation tree. Keeps the harness free of
- * cross-session cancellation authority.
+ * continuation prompt. It keeps the canonical cancellation name, so execution
+ * settles it through the standard turn-cancellation path.
*/
export class SessionLimitDeclinedError extends TurnCancelledError {
- readonly sessionLimitDeclined = true;
-
constructor() {
super("The user declined a fresh session token budget.");
}
}
-/** True when the error, or one of its causes, marks a session-limit decline. */
-export function isSessionLimitDecline(error: unknown): boolean {
- let current: unknown = error;
- const seen = new Set<unknown>();
-
- while (typeof current === "object" && current !== null && !seen.has(current)) {
- seen.add(current);
- if ((current as { sessionLimitDeclined?: unknown }).sessionLimitDeclined === true) {
- return true;
- }
- current = (current as { cause?: unknown }).cause;
- }
-
- return false;
-}
-
/** True when the error, or one of its causes, is a {@link TurnCancelledError}. */
export function isTurnCancellation(error: unknown): boolean {
let current: unknown = error;
diff --git a/packages/eve/src/harness/workflow-stream-error.test.ts b/packages/eve/src/harness/workflow-stream-error.test.ts
index ad7df2378..3720797be 100644
--- a/packages/eve/src/harness/workflow-stream-error.test.ts
+++ b/packages/eve/src/harness/workflow-stream-error.test.ts
@@ -1,9 +1,6 @@
import { describe, expect, it } from "vitest";
-import {
- extractWorkflowStreamWriteErrorDetails,
- isWorkflowStreamWriteError,
-} from "#harness/workflow-stream-error.js";
+import { extractWorkflowStreamWriteErrorDetails } from "#harness/workflow-stream-error.js";
describe("extractWorkflowStreamWriteErrorDetails", () => {
it("parses status, url, and vercel headers from the timeout signature", () => {
@@ -68,15 +65,3 @@ describe("extractWorkflowStreamWriteErrorDetails", () => {
expect(extractWorkflowStreamWriteErrorDetails(504)).toBeNull();
});
});
-
-describe("isWorkflowStreamWriteError", () => {
- it("is true for a workflow stream-write failure", () => {
- expect(
- isWorkflowStreamWriteError(new Error("Stream write failed: HTTP 504 (PUT https://x): t")),
- ).toBe(true);
- });
-
- it("is false for a model-call error", () => {
- expect(isWorkflowStreamWriteError(new Error("model overloaded"))).toBe(false);
- });
-});
diff --git a/packages/eve/src/harness/workflow-stream-error.ts b/packages/eve/src/harness/workflow-stream-error.ts
index 8bac1e422..c3ffec178 100644
--- a/packages/eve/src/harness/workflow-stream-error.ts
+++ b/packages/eve/src/harness/workflow-stream-error.ts
@@ -47,16 +47,6 @@ export function extractWorkflowStreamWriteErrorDetails(error: unknown): JsonObje
return null;
}
-/**
- * Returns `true` when `error` is a durable event-stream write failure
- * raised by the workflow runtime's stream transport, not by the model
- * provider. Thin predicate over
- * {@link extractWorkflowStreamWriteErrorDetails}.
- */
-export function isWorkflowStreamWriteError(error: unknown): boolean {
- return extractWorkflowStreamWriteErrorDetails(error) !== null;
-}
-
function parseStreamErrorMessage(message: string): JsonObject | null {
const match = WORKFLOW_STREAM_WRITE_ERROR_PATTERN.exec(message);
if (match === null) {
diff --git a/packages/eve/src/internal/bundler/nitro-rolldown.integration.test.ts b/packages/eve/src/internal/bundler/nitro-rolldown.integration.test.ts
index 77e4f54f2..09d8b2f37 100644
--- a/packages/eve/src/internal/bundler/nitro-rolldown.integration.test.ts
+++ b/packages/eve/src/internal/bundler/nitro-rolldown.integration.test.ts
@@ -3,7 +3,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { pathToFileURL } from "node:url";
-import { describe, expect, it } from "vitest";
+import { describe, expect, it, vi } from "vitest";
import {
buildSingleRolldownChunk,
@@ -91,6 +91,49 @@ describe("buildSingleRolldownChunk", () => {
}
});
+ it("keeps authored and unresolved-import warnings while silencing other dependency warnings", async () => {
+ const dir = mkdtempSync(join(tmpdir(), "eve-rolldown-dependency-warning-"));
+ const dependencyRoot = join(dir, "node_modules", "evaluator");
+ const entryPath = join(dir, "entry.mjs");
+ const warnings: string[] = [];
+ // Rolldown's default log handler prints warnings with console.warn.
+ const warn = vi.spyOn(console, "warn").mockImplementation((message: unknown) => {
+ warnings.push(String(message));
+ });
+
+ try {
+ mkdirSync(dependencyRoot, { recursive: true });
+ writeFileSync(
+ join(dependencyRoot, "package.json"),
+ `${JSON.stringify({ main: "./index.js", name: "evaluator", version: "1.0.0" })}\n`,
+ );
+ writeFileSync(
+ join(dependencyRoot, "index.js"),
+ 'import "eve-missing-package";\nexport const fromDependency = eval("1");\n',
+ );
+ writeFileSync(
+ entryPath,
+ 'import { fromDependency } from "evaluator";\nexport const values = [fromDependency, eval("2")];\n',
+ );
+
+ await buildSingleRolldownChunk("dependency warning fixture", {
+ cwd: dir,
+ input: entryPath,
+ platform: "node",
+ output: { format: "esm" },
+ });
+ } finally {
+ warn.mockRestore();
+ rmSync(dir, { force: true, recursive: true });
+ }
+
+ expect(warnings).toHaveLength(2);
+ expect(warnings.find((message) => message.includes("[EVAL]"))).toContain("entry.mjs");
+ expect(warnings.find((message) => message.includes("[UNRESOLVED_IMPORT]"))).toContain(
+ "eve-missing-package",
+ );
+ });
+
it("inlines dynamic imports into one chunk instead of splitting", async () => {
const entryPath = scratchModuleWithDynamicImport();
diff --git a/packages/eve/src/internal/bundler/nitro-rolldown.ts b/packages/eve/src/internal/bundler/nitro-rolldown.ts
index bf15d5d22..6b558349c 100644
--- a/packages/eve/src/internal/bundler/nitro-rolldown.ts
+++ b/packages/eve/src/internal/bundler/nitro-rolldown.ts
@@ -1,6 +1,11 @@
import { createRequire } from "node:module";
import { pathToFileURL } from "node:url";
+import {
+ type BundlerDefaultLogHandler,
+ onVendoredDependencyLog,
+} from "#internal/bundler/vendored-dependency-log.js";
+
type RolldownOutputChunk = {
readonly type: "chunk";
readonly code: string;
@@ -95,14 +100,31 @@ export async function parseWithNitroRolldownAst(
/**
* Runs a raw Rolldown build. Prefer {@link buildSingleRolldownChunk} for any
* bundle whose consumer expects one in-memory file; use this directly only
- * for multi-file, written-to-disk output.
+ * for multi-file, written-to-disk output. Warnings raised only by dependency
+ * code are dropped unless the caller supplies its own `onLog`, except
+ * unresolved imports.
*/
export async function buildWithNitroRolldown(
options: Record<string, unknown>,
): Promise<RolldownOutput> {
assertCustomRolldownConditionNames(options);
const { build } = await loadNitroRolldown();
- return await build(options);
+ return await build({ onLog: onRolldownBuildLog, ...options });
+}
+
+// Unlike the Nitro host build, whose dependency graph deliberately leaves
+// optional imports such as `just-bash` unresolved, these bundles inline their
+// dependencies, so an unresolved import there only fails once the bundle loads.
+function onRolldownBuildLog(
+ level: string,
+ log: unknown,
+ defaultHandler: BundlerDefaultLogHandler,
+): void {
+ if (level === "warn" && (log as { code?: unknown } | null)?.code === "UNRESOLVED_IMPORT") {
+ defaultHandler(level, log);
+ return;
+ }
+ onVendoredDependencyLog(level, log, defaultHandler);
}
export const ROLLDOWN_STANDARD_CONDITION_NAMES: ReadonlySet<string> = new Set([
diff --git a/packages/eve/src/internal/bundler/vendored-dependency-log.ts b/packages/eve/src/internal/bundler/vendored-dependency-log.ts
new file mode 100644
index 000000000..84828c2b1
--- /dev/null
+++ b/packages/eve/src/internal/bundler/vendored-dependency-log.ts
@@ -0,0 +1,69 @@
+interface BundlerLog {
+ readonly id?: string;
+ readonly ids?: readonly unknown[];
+ readonly loc?: {
+ readonly file?: string;
+ };
+}
+
+export type BundlerDefaultLogHandler = (level: string, log: unknown) => void;
+
+function normalizePath(value: string): string {
+ return value.replaceAll("\\", "/");
+}
+
+function isNodeModulesPath(filePath: string): boolean {
+ return normalizePath(filePath).split("/").includes("node_modules");
+}
+
+function hasPathSegments(filePath: string, segments: readonly string[]): boolean {
+ const pathSegments = normalizePath(filePath).split("/").filter(Boolean);
+ return pathSegments.some((_, index) =>
+ segments.every((segment, offset) => pathSegments[index + offset] === segment),
+ );
+}
+
+function isCompiledVendorPath(filePath: string): boolean {
+ return (
+ hasPathSegments(filePath, [".generated", "compiled"]) ||
+ hasPathSegments(filePath, ["dist", "src", "compiled"])
+ );
+}
+
+function getLogFilePaths(log: unknown): string[] {
+ if (log === null || typeof log !== "object") {
+ return [];
+ }
+
+ const candidate = log as BundlerLog;
+ const ids = Array.isArray(candidate.ids) ? candidate.ids : [];
+
+ return [candidate.id, ...ids, candidate.loc?.file].filter(
+ (value): value is string => typeof value === "string",
+ );
+}
+
+function isVendoredDependencyWarning(log: unknown): boolean {
+ const filePaths = getLogFilePaths(log);
+ return (
+ filePaths.length > 0 &&
+ filePaths.every((filePath) => isNodeModulesPath(filePath) || isCompiledVendorPath(filePath))
+ );
+}
+
+/**
+ * Rollup/Rolldown `onLog` handler that drops warnings raised only by
+ * dependency code (`node_modules` or eve's compiled vendor modules), which the
+ * user cannot act on, and forwards everything else.
+ */
+export function onVendoredDependencyLog(
+ level: string,
+ log: unknown,
+ defaultHandler: BundlerDefaultLogHandler,
+): void {
+ if (level === "warn" && isVendoredDependencyWarning(log)) {
+ return;
+ }
+
+ defaultHandler(level, log);
+}
diff --git a/packages/eve/src/internal/nitro/host/nitro-bundler-config.ts b/packages/eve/src/internal/nitro/host/nitro-bundler-config.ts
index 21ccbfcef..758fde8fd 100644
--- a/packages/eve/src/internal/nitro/host/nitro-bundler-config.ts
+++ b/packages/eve/src/internal/nitro/host/nitro-bundler-config.ts
@@ -1,77 +1,13 @@
+import { onVendoredDependencyLog } from "#internal/bundler/vendored-dependency-log.js";
import { createNodeEsmCompatBannerPlugin } from "#internal/node-esm-compat-banner.js";
-interface BundlerLog {
- readonly id?: string;
- readonly ids?: readonly unknown[];
- readonly loc?: {
- readonly file?: string;
- };
-}
-
-type BundlerDefaultLogHandler = (level: string, log: unknown) => void;
-
-function normalizePath(value: string): string {
- return value.replaceAll("\\", "/");
-}
-
-function isNodeModulesPath(filePath: string): boolean {
- return normalizePath(filePath).split("/").includes("node_modules");
-}
-
-function hasPathSegments(filePath: string, segments: readonly string[]): boolean {
- const pathSegments = normalizePath(filePath).split("/").filter(Boolean);
- return pathSegments.some((_, index) =>
- segments.every((segment, offset) => pathSegments[index + offset] === segment),
- );
-}
-
-function isCompiledVendorPath(filePath: string): boolean {
- return (
- hasPathSegments(filePath, [".generated", "compiled"]) ||
- hasPathSegments(filePath, ["dist", "src", "compiled"])
- );
-}
-
-function getLogFilePaths(log: unknown): string[] {
- if (log === null || typeof log !== "object") {
- return [];
- }
-
- const candidate = log as BundlerLog;
- const ids = Array.isArray(candidate.ids) ? candidate.ids : [];
-
- return [candidate.id, ...ids, candidate.loc?.file].filter(
- (value): value is string => typeof value === "string",
- );
-}
-
-function isVendoredDependencyWarning(log: unknown): boolean {
- const filePaths = getLogFilePaths(log);
- return (
- filePaths.length > 0 &&
- filePaths.every((filePath) => isNodeModulesPath(filePath) || isCompiledVendorPath(filePath))
- );
-}
-
-function onNitroBundlerLog(
- level: string,
- log: unknown,
- defaultHandler: BundlerDefaultLogHandler,
-): void {
- if (level === "warn" && isVendoredDependencyWarning(log)) {
- return;
- }
-
- defaultHandler(level, log);
-}
-
/**
* Creates eve-owned Nitro bundler overrides that must apply to both Rollup
* and Rolldown hosted builds.
*/
export function createNitroBundlerConfig(plugins: readonly object[]): Record<string, unknown> {
return {
- onLog: onNitroBundlerLog,
+ onLog: onVendoredDependencyLog,
plugins: [createNodeEsmCompatBannerPlugin(), ...plugins],
};
}
diff --git a/packages/eve/src/internal/nitro/host/schedule-task-routes.test.ts b/packages/eve/src/internal/nitro/host/schedule-task-routes.test.ts
index d9e6bde79..e6e35e71a 100644
--- a/packages/eve/src/internal/nitro/host/schedule-task-routes.test.ts
+++ b/packages/eve/src/internal/nitro/host/schedule-task-routes.test.ts
@@ -1,16 +1,8 @@
import type { Nitro } from "nitro/types";
import { describe, expect, it } from "vitest";
-import {
- EVE_SCHEDULE_TASK_NAME_PREFIX,
- createScheduleRegistrations,
- type ScheduleRegistration,
-} from "#runtime/schedules/register.js";
-import {
- registerScheduleTaskHandlers,
- removeScheduleTaskHandlers,
- syncScheduleTaskHandlers,
-} from "#internal/nitro/host/schedule-task-routes.js";
+import { createScheduleRegistrations } from "#runtime/schedules/register.js";
+import { registerScheduleTaskHandlers } from "#internal/nitro/host/schedule-task-routes.js";
const DISPATCH_MODULE_PATH = "/framework/schedule-task.ts";
@@ -98,116 +90,17 @@ describe("schedule task routes", () => {
expect(nitro.options.scheduledTasks).toEqual({});
expect(nitro.options.virtual).toEqual({});
});
-
- it("removes only eve-owned task entries, virtual modules, and cron mappings", () => {
- const nitro = createNitroStub({
- scheduledTasks: {
- "0 8 * * *": ["eve.schedule.example", "user-task"],
- "0 0 * * *": "eve.schedule.alone",
- },
- tasks: {
- "eve.schedule.example": { description: "eve", handler: "#eve-schedule-task/example" },
- "eve.schedule.alone": { description: "eve", handler: "#eve-schedule-task/alone" },
- "user-task": { description: "user", handler: "/user/task.ts" },
- },
- virtual: {
- "#eve-schedule-task/example": "...",
- "#eve-schedule-task/alone": "...",
- "#user/virtual": "...",
- },
- });
-
- removeScheduleTaskHandlers(nitro);
-
- expect(nitro.options.tasks).toEqual({
- "user-task": { description: "user", handler: "/user/task.ts" },
- });
- expect(nitro.options.virtual).toEqual({
- "#user/virtual": "...",
- });
- expect(nitro.options.scheduledTasks).toEqual({
- "0 8 * * *": "user-task",
- });
- });
-
- it("syncs registrations and reports whether the registration set changed", () => {
- const nitro = createNitroStub();
- const previous = makeRegistration({
- cron: "0 8 * * *",
- logicalPath: "schedules/daily.md",
- scheduleId: "daily",
- sourceId: "schedules/daily.md",
- });
- const next = makeRegistration({
- cron: "0 0 * * *",
- logicalPath: "schedules/nightly.md",
- scheduleId: "nightly",
- sourceId: "schedules/nightly.md",
- });
-
- registerScheduleTaskHandlers(nitro, {
- artifactsConfig: ARTIFACTS_CONFIG,
- dispatchModulePath: DISPATCH_MODULE_PATH,
- registrations: [previous],
- });
-
- const changed = syncScheduleTaskHandlers(nitro, {
- artifactsConfig: ARTIFACTS_CONFIG,
- dispatchModulePath: DISPATCH_MODULE_PATH,
- next: [next],
- previous: [previous],
- });
-
- expect(changed).toBe(true);
- expect(nitro.options.tasks[previous.taskName]).toBeUndefined();
- expect(nitro.options.tasks[next.taskName]).toBeDefined();
- expect(nitro.options.scheduledTasks).toEqual({
- [next.cron]: next.taskName,
- });
-
- const unchanged = syncScheduleTaskHandlers(nitro, {
- artifactsConfig: ARTIFACTS_CONFIG,
- dispatchModulePath: DISPATCH_MODULE_PATH,
- next: [next],
- previous: [next],
- });
-
- expect(unchanged).toBe(false);
- expect(nitro.options.tasks[next.taskName]).toBeDefined();
- });
});
-function createNitroStub(
- input: {
- scheduledTasks?: Record<string, string | string[]>;
- tasks?: Record<string, { description?: string; handler?: string }>;
- virtual?: Record<string, string>;
- } = {},
-): Nitro {
+function createNitroStub(): Nitro {
return {
options: {
experimental: {
tasks: false,
},
- scheduledTasks: input.scheduledTasks ?? {},
- tasks: input.tasks ?? {},
- virtual: input.virtual ?? {},
+ scheduledTasks: {},
+ tasks: {},
+ virtual: {},
},
} as unknown as Nitro;
}
-
-function makeRegistration(input: {
- cron: string;
- logicalPath: string;
- scheduleId: string;
- sourceId: string;
-}): ScheduleRegistration {
- return {
- cron: input.cron,
- description: `Run schedule "${input.scheduleId}".`,
- logicalPath: input.logicalPath,
- scheduleId: input.scheduleId,
- sourceId: input.sourceId,
- taskName: `${EVE_SCHEDULE_TASK_NAME_PREFIX}${input.scheduleId}`,
- };
-}
diff --git a/packages/eve/src/internal/nitro/host/schedule-task-routes.ts b/packages/eve/src/internal/nitro/host/schedule-task-routes.ts
index b12ca80bc..87f669626 100644
--- a/packages/eve/src/internal/nitro/host/schedule-task-routes.ts
+++ b/packages/eve/src/internal/nitro/host/schedule-task-routes.ts
@@ -1,9 +1,6 @@
import type { Nitro } from "nitro/types";
-import {
- EVE_SCHEDULE_TASK_NAME_PREFIX,
- type ScheduleRegistration,
-} from "#runtime/schedules/register.js";
+import type { ScheduleRegistration } from "#runtime/schedules/register.js";
import { stringifyEsmImportSpecifier } from "#internal/application/import-specifier.js";
import type { NitroArtifactsConfig } from "#internal/nitro/routes/runtime-artifacts.js";
@@ -33,17 +30,6 @@ export interface RegisterScheduleTaskHandlersInput {
readonly registrations: readonly ScheduleRegistration[];
}
-/**
- * Inputs needed to reconcile schedule task handlers when authored sources
- * change in dev mode.
- */
-export interface SyncScheduleTaskHandlersInput {
- readonly artifactsConfig: NitroArtifactsConfig;
- readonly dispatchModulePath: string;
- readonly next: readonly ScheduleRegistration[];
- readonly previous: readonly ScheduleRegistration[];
-}
-
/**
* Registers compiled authored schedules as virtual Nitro task handlers.
*
@@ -78,71 +64,6 @@ export function registerScheduleTaskHandlers(
}
}
-/**
- * Replaces the currently-registered eve schedule task handlers when the
- * compiled authored schedule set changes.
- *
- * Returns `true` when the registration set changed (and the caller should
- * trigger a Nitro rebuild reload), `false` when it was a structural no-op.
- */
-export function syncScheduleTaskHandlers(
- nitro: ScheduleTaskNitro,
- input: SyncScheduleTaskHandlersInput,
-): boolean {
- const hasChanged = !areScheduleRegistrationsEqual(input.previous, input.next);
-
- removeScheduleTaskHandlers(nitro);
- registerScheduleTaskHandlers(nitro, {
- artifactsConfig: input.artifactsConfig,
- dispatchModulePath: input.dispatchModulePath,
- registrations: input.next,
- });
-
- return hasChanged;
-}
-
-/**
- * Removes every eve-owned schedule task entry, virtual handler module, and
- * cron entry from the Nitro options. Used by the dev watcher before
- * re-registering the latest compiled set.
- */
-export function removeScheduleTaskHandlers(nitro: ScheduleTaskNitro): void {
- for (const taskName of Object.keys(nitro.options.tasks)) {
- if (taskName.startsWith(EVE_SCHEDULE_TASK_NAME_PREFIX)) {
- delete nitro.options.tasks[taskName];
- }
- }
-
- for (const virtualId of Object.keys(nitro.options.virtual)) {
- if (virtualId.startsWith(EVE_SCHEDULE_TASK_VIRTUAL_ID_PREFIX)) {
- delete nitro.options.virtual[virtualId];
- }
- }
-
- for (const [cron, scheduledTask] of Object.entries(nitro.options.scheduledTasks)) {
- const filtered = normalizeScheduledTasks(scheduledTask).filter(
- (taskName) => !taskName.startsWith(EVE_SCHEDULE_TASK_NAME_PREFIX),
- );
-
- if (filtered.length === 0) {
- delete nitro.options.scheduledTasks[cron];
- continue;
- }
-
- if (filtered.length === 1) {
- const [singleTask] = filtered;
-
- if (singleTask !== undefined) {
- nitro.options.scheduledTasks[cron] = singleTask;
- }
-
- continue;
- }
-
- nitro.options.scheduledTasks[cron] = filtered;
- }
-}
-
function addScheduleTaskVirtualHandler(
nitro: ScheduleTaskNitro,
input: {
@@ -195,38 +116,3 @@ function appendScheduledTask(nitro: ScheduleTaskNitro, cron: string, taskName: s
existingScheduleTasks.push(taskName);
}
}
-
-function normalizeScheduledTasks(value: string | string[]): string[] {
- return typeof value === "string" ? [value] : [...value];
-}
-
-function areScheduleRegistrationsEqual(
- left: readonly ScheduleRegistration[],
- right: readonly ScheduleRegistration[],
-): boolean {
- if (left.length !== right.length) {
- return false;
- }
-
- for (let index = 0; index < left.length; index += 1) {
- const leftRegistration = left[index];
- const rightRegistration = right[index];
-
- if (leftRegistration === undefined || rightRegistration === undefined) {
- return false;
- }
-
- if (
- leftRegistration.cron !== rightRegistration.cron ||
- leftRegistration.description !== rightRegistration.description ||
- leftRegistration.logicalPath !== rightRegistration.logicalPath ||
- leftRegistration.scheduleId !== rightRegistration.scheduleId ||
- leftRegistration.sourceId !== rightRegistration.sourceId ||
- leftRegistration.taskName !== rightRegistration.taskName
- ) {
- return false;
- }
- }
-
- return true;
-}
diff --git a/packages/eve/src/internal/nitro/host/start-production-server.test.ts b/packages/eve/src/internal/nitro/host/start-production-server.test.ts
index ccac624c9..88acbf991 100644
--- a/packages/eve/src/internal/nitro/host/start-production-server.test.ts
+++ b/packages/eve/src/internal/nitro/host/start-production-server.test.ts
@@ -53,14 +53,21 @@ function createChildProcess(): ChildProcess {
describe("startProductionServer", () => {
const originalFetch = globalThis.fetch;
const originalPort = process.env.PORT;
+ let stdoutWrites: string[] = [];
beforeEach(() => {
vi.clearAllMocks();
+ stdoutWrites = [];
+ vi.spyOn(process.stdout, "write").mockImplementation((chunk) => {
+ stdoutWrites.push(String(chunk));
+ return true;
+ });
delete process.env.PORT;
globalThis.fetch = vi.fn(async () => new Response('{"ok":true}', { status: 200 }));
});
afterEach(() => {
+ vi.restoreAllMocks();
globalThis.fetch = originalFetch;
if (originalPort === undefined) {
delete process.env.PORT;
@@ -92,6 +99,7 @@ describe("startProductionServer", () => {
});
expect(server.url).toBe("http://127.0.0.1:4321/");
+ expect(stdoutWrites).toContain("Listening on http://127.0.0.1:4321/\n");
expect(mocks.loadDevelopmentEnvironmentFiles).toHaveBeenCalledWith("/tmp/app");
expect(mocks.spawn).toHaveBeenCalledWith(
process.execPath,
diff --git a/packages/eve/src/internal/testing/session-inbox-workflow.ts b/packages/eve/src/internal/testing/session-inbox-workflow.ts
index 681282895..a488167c9 100644
--- a/packages/eve/src/internal/testing/session-inbox-workflow.ts
+++ b/packages/eve/src/internal/testing/session-inbox-workflow.ts
@@ -1,13 +1,11 @@
import { getWorkflowMetadata } from "#compiled/@workflow/core/index.js";
-import { createSessionInbox, type SessionInboxPayload } from "#execution/session-inbox/inbox.js";
+import { createSessionInbox } from "#execution/session-inbox/inbox.js";
import { sessionCommandHookToken } from "#execution/session-inbox/address.js";
export async function sessionCommandInboxWorkflow(input: {
- readonly messageCount?: number;
- readonly nextToken?: string;
readonly token: string;
-}): Promise<string[]> {
+}): Promise<void> {
"use workflow";
const { workflowRunId } = getWorkflowMetadata();
@@ -16,30 +14,11 @@ export async function sessionCommandInboxWorkflow(input: {
try {
await inbox.claimSessionHook(sessionCommandHookToken(workflowRunId));
await inbox.claimSessionHook(input.token);
- const pending = inbox.next();
- if (input.nextToken !== undefined) {
- await inbox.claimSessionHook(input.nextToken);
- }
-
- const messages: string[] = [];
- let payload = await pending;
while (true) {
- if (payload === undefined) return messages;
- if (payload.kind === "reset") return messages;
- collectMessage(payload, messages);
- if (messages.length >= (input.messageCount ?? 2)) return messages;
- payload = await inbox.next();
+ const payload = await inbox.next();
+ if (payload === undefined || payload.kind === "reset") return;
}
} finally {
await inbox.dispose();
}
}
-
-function collectMessage(command: SessionInboxPayload, messages: string[]): void {
- if (command.kind === "send" && typeof command.payload.message === "string") {
- messages.push(command.payload.message);
- }
- if (command.kind === "deliver" && typeof command.payloads[0]?.message === "string") {
- messages.push(command.payloads[0].message);
- }
-}
diff --git a/packages/eve/src/internal/workflow-bundle/builder.scenario.test.ts b/packages/eve/src/internal/workflow-bundle/builder.scenario.test.ts
index 2e6b93418..11bd1653a 100644
--- a/packages/eve/src/internal/workflow-bundle/builder.scenario.test.ts
+++ b/packages/eve/src/internal/workflow-bundle/builder.scenario.test.ts
@@ -880,28 +880,45 @@ describe("WorkflowBundleBuilder", () => {
await rm(tempRoot, { force: true, recursive: true });
}
});
- it("rejects unresolved workflow imports before emitting a VM bundle", async () => {
- const root = await mkdtemp(join(tmpdir(), "eve-workflow-missing-import-"));
- const flow = join(root, "flow.ts");
- try {
- await writeFile(
- flow,
- 'import { value } from "missing-workflow-package"; export async function flow() { "use workflow"; return value; }',
- );
- const builder = new FixtureWorkflowBundleBuilder(
- {
- agentName: "missing-import",
- appRoot: root,
- rootDir: root,
- outDir: join(root, "out"),
- compiledArtifactsBootstrapPath: join(root, "bootstrap.mjs"),
- watch: false,
- },
- [flow],
- );
- await expect(builder.build()).rejects.toThrow("missing-workflow-package");
- } finally {
- await rm(root, { recursive: true, force: true });
- }
- });
+ it.each([
+ { importer: "workflow code", specifier: "missing-workflow-package" },
+ // Dependency warnings are otherwise filtered as non-actionable.
+ { importer: "a dependency", specifier: "dep" },
+ ])(
+ "rejects unresolved imports from $importer before emitting a VM bundle",
+ async ({ specifier }) => {
+ const root = await mkdtemp(join(tmpdir(), "eve-workflow-missing-import-"));
+ const flow = join(root, "flow.ts");
+ const dependencyRoot = join(root, "node_modules", "dep");
+ try {
+ await mkdir(dependencyRoot, { recursive: true });
+ await writeFile(
+ join(dependencyRoot, "package.json"),
+ `${JSON.stringify({ main: "./index.js", name: "dep", version: "1.0.0" })}\n`,
+ );
+ await writeFile(
+ join(dependencyRoot, "index.js"),
+ 'export { value } from "missing-workflow-package";\n',
+ );
+ await writeFile(
+ flow,
+ `import { value } from "${specifier}"; export async function flow() { "use workflow"; return value; }`,
+ );
+ const builder = new FixtureWorkflowBundleBuilder(
+ {
+ agentName: "missing-import",
+ appRoot: root,
+ rootDir: root,
+ outDir: join(root, "out"),
+ compiledArtifactsBootstrapPath: join(root, "bootstrap.mjs"),
+ watch: false,
+ },
+ [flow],
+ );
+ await expect(builder.build()).rejects.toThrow("missing-workflow-package");
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+ },
+ );
});
diff --git a/packages/eve/src/internal/workflow-bundle/builder.ts b/packages/eve/src/internal/workflow-bundle/builder.ts
index ce931cded..2e35eb889 100644
--- a/packages/eve/src/internal/workflow-bundle/builder.ts
+++ b/packages/eve/src/internal/workflow-bundle/builder.ts
@@ -38,6 +38,10 @@ import {
type WorkflowBundleDiscoveredEntries,
} from "#internal/workflow-bundle/builder-support.js";
import { buildSingleRolldownChunk } from "#internal/bundler/nitro-rolldown.js";
+import {
+ type BundlerDefaultLogHandler,
+ onVendoredDependencyLog,
+} from "#internal/bundler/vendored-dependency-log.js";
import {
type NitroStepEntrypointDiscoveredEntries,
writeNitroStepEntrypoint,
@@ -304,11 +308,17 @@ export class WorkflowBundleBuilder {
].join("\n");
const interimBundle = await buildSingleRolldownChunk(`${options.label} workflow driver chunk`, {
cwd: this.config.workingDir,
- onwarn(warning: { code: string; message: string }, warn: (warning: unknown) => void) {
- if (warning.code === "UNRESOLVED_IMPORT") {
- throw new Error(`Cannot build workflow bundle: ${warning.message}`);
+ // Checked before the dependency-warning filter, which would otherwise
+ // drop an unresolved import raised inside node_modules.
+ onLog(
+ level: string,
+ log: { code?: string; message: string },
+ defaultHandler: BundlerDefaultLogHandler,
+ ) {
+ if (level === "warn" && log.code === "UNRESOLVED_IMPORT") {
+ throw new Error(`Cannot build workflow bundle: ${log.message}`);
}
- warn(warning);
+ onVendoredDependencyLog(level, log, defaultHandler);
},
input: WORKFLOW_VIRTUAL_ENTRY_ID,
platform: "neutral",
diff --git a/packages/eve/src/public/channels/auth.test.ts b/packages/eve/src/public/channels/auth.test.ts
index 53802d543..20f6e5e77 100644
--- a/packages/eve/src/public/channels/auth.test.ts
+++ b/packages/eve/src/public/channels/auth.test.ts
@@ -1460,34 +1460,6 @@ describe("vercelOidc strategy helper", () => {
await expect(Promise.resolve(authFn(request))).resolves.toBeNull();
});
- it("rejects malformed bearer payloads without throwing", async () => {
- const authFn = vercelOidc();
- const request = new Request(TEST_ROUTE_URL, {
- method: "POST",
- headers: { authorization: "Bearer not.a.real.jwt" },
- });
- await expect(Promise.resolve(authFn(request))).resolves.toBeNull();
- });
-
- it("rejects bearer tokens whose issuer is not on the Vercel OIDC prefix", async () => {
- const { privateKey } = await generateKeyPair("RS256");
- const token = await new SignJWT({})
- .setProtectedHeader({ alg: "RS256" })
- .setAudience("https://vercel.com/acme")
- .setExpirationTime("5m")
- .setIssuedAt()
- .setIssuer("https://attacker.example/oidc")
- .setSubject("acme")
- .sign(privateKey);
-
- const authFn = vercelOidc();
- const request = new Request(TEST_ROUTE_URL, {
- method: "POST",
- headers: { authorization: `Bearer ${token}` },
- });
- await expect(Promise.resolve(authFn(request))).resolves.toBeNull();
- });
-
it("uses the local host's linked project binding only for bearer requests", async () => {
vi.stubEnv("VERCEL_PROJECT_ID", "");
vi.stubEnv("VERCEL_TARGET_ENV", "");
@@ -1551,17 +1523,6 @@ describe("httpBasic strategy helper", () => {
principalId: "ops",
});
});
-
- it("rejects mismatched credentials", () => {
- const authFn = httpBasic({ password: "top-secret", username: "ops" });
- const request = new Request(TEST_ROUTE_URL, {
- method: "POST",
- headers: {
- authorization: `Basic ${Buffer.from("ops:wrong", "utf8").toString("base64")}`,
- },
- });
- expect(authFn(request)).toBeNull();
- });
});
describe("jwtHmac strategy helper", () => {
diff --git a/packages/eve/src/public/channels/eve.test.ts b/packages/eve/src/public/channels/eve.test.ts
index 4e48ab7f9..37f98b8df 100644
--- a/packages/eve/src/public/channels/eve.test.ts
+++ b/packages/eve/src/public/channels/eve.test.ts
@@ -567,15 +567,15 @@ describe("eveChannel — stream cursor", () => {
await vi.waitFor(() => expect(cancelled).toHaveBeenCalledOnce());
});
- it("forwards negative tail-relative start indices", async () => {
+ it.each([-1, 42])("forwards start index %i to the durable stream", async (startIndex) => {
const handler = createEveStreamHandler({ auth: none() });
const response = await handler.fetch(
- "https://eve.test/eve/v1/session/test-session-id/stream?startIndex=-1",
+ `https://eve.test/eve/v1/session/test-session-id/stream?startIndex=${startIndex}`,
);
expect(response.status).toBe(200);
- expect(handler.getEventStream).toHaveBeenCalledWith({ startIndex: -1 });
+ expect(handler.getEventStream).toHaveBeenCalledWith({ startIndex });
});
it.each(["1.5", "1junk", "0x10", "1e2", ""])(
diff --git a/packages/eve/src/public/channels/github/api.test.ts b/packages/eve/src/public/channels/github/api.test.ts
index 5bc22c539..4e52a3913 100644
--- a/packages/eve/src/public/channels/github/api.test.ts
+++ b/packages/eve/src/public/channels/github/api.test.ts
@@ -4,12 +4,10 @@ import {
GitHubApiError,
callGitHubApi,
createGitHubIssueComment,
- createGitHubPullRequestReviewComment,
createGitHubReaction,
createGitHubReviewCommentReply,
getGitHubPullRequest,
listGitHubPullRequestFiles,
- updateGitHubPullRequestReviewComment,
} from "#public/channels/github/api.js";
import {
clearGitHubInstallationTokenCache,
@@ -82,53 +80,6 @@ describe("GitHub API helpers", () => {
expect(requestBody(fetchMock.mock.calls[0]?.[1])).toEqual({ body: "inline reply" });
});
- it("creates inline pull request review comments through the pull comments API", async () => {
- const fetchMock = vi.fn().mockResolvedValue(jsonResponse({ id: 12 }));
-
- await createGitHubPullRequestReviewComment({
- api: { apiBaseUrl: "https://github.test", fetch: fetchMock },
- body: {
- body: "inline comment",
- commit_id: "abc123",
- line: 10,
- path: "src/file.ts",
- },
- credentials,
- installationId: 123,
- owner: "vercel",
- pullRequestNumber: 7,
- repo: "eve",
- });
-
- expect(fetchMock.mock.calls[0]?.[0]).toBe(
- "https://github.test/repos/vercel/eve/pulls/7/comments",
- );
- expect(requestBody(fetchMock.mock.calls[0]?.[1])).toMatchObject({
- body: "inline comment",
- path: "src/file.ts",
- });
- });
-
- it("updates review-thread comments through the pull request comments API", async () => {
- const fetchMock = vi.fn().mockResolvedValue(jsonResponse({ id: 11 }));
-
- await updateGitHubPullRequestReviewComment({
- api: { apiBaseUrl: "https://github.test", fetch: fetchMock },
- body: "updated inline reply",
- commentId: 99,
- credentials,
- installationId: 123,
- owner: "vercel",
- repo: "eve",
- });
-
- expect(fetchMock.mock.calls[0]?.[0]).toBe(
- "https://github.test/repos/vercel/eve/pulls/comments/99",
- );
- expect(fetchMock.mock.calls[0]?.[1]?.method).toBe("PATCH");
- expect(requestBody(fetchMock.mock.calls[0]?.[1])).toEqual({ body: "updated inline reply" });
- });
-
it("creates reactions on issue comments and throws owned API errors for non-2xx", async () => {
const fetchMock = vi
.fn()
diff --git a/packages/eve/src/public/channels/github/api.ts b/packages/eve/src/public/channels/github/api.ts
index fab9595cb..1cdc276bd 100644
--- a/packages/eve/src/public/channels/github/api.ts
+++ b/packages/eve/src/public/channels/github/api.ts
@@ -214,26 +214,6 @@ export async function createGitHubReviewCommentReply(
return toPostedComment(response.body);
}
-/** Updates an inline pull-request review comment or reply. */
-export async function updateGitHubPullRequestReviewComment(
- input: GitHubResourceInput & {
- readonly body: string | GitHubCommentBody;
- readonly commentId: number;
- },
-): Promise<GitHubPostedComment> {
- const response = await callGitHubApi({
- api: input.api,
- body: normalizeCommentBody(input.body),
- credentials: input.credentials,
- installationId: input.installationId,
- method: "PATCH",
- path: `/repos/${encodePath(input.owner)}/${encodePath(input.repo)}/pulls/comments/${
- input.commentId
- }`,
- });
- return toPostedComment(response.body);
-}
-
/** Creates a pull-request review. */
export function createGitHubPullRequestReview(
input: GitHubResourceInput & {
@@ -253,26 +233,6 @@ export function createGitHubPullRequestReview(
});
}
-/** Creates an inline pull-request review comment. */
-export async function createGitHubPullRequestReviewComment(
- input: GitHubResourceInput & {
- readonly body: GitHubJsonObject;
- readonly pullRequestNumber: number;
- },
-): Promise<GitHubPostedComment> {
- const response = await callGitHubApi({
- api: input.api,
- body: input.body,
- credentials: input.credentials,
- installationId: input.installationId,
- method: "POST",
- path: `/repos/${encodePath(input.owner)}/${encodePath(input.repo)}/pulls/${
- input.pullRequestNumber
- }/comments`,
- });
- return toPostedComment(response.body);
-}
-
/** Minimal pull-request metadata returned by {@link getGitHubPullRequest}. */
export interface GitHubPullRequestDetails {
readonly additions: number | undefined;
diff --git a/packages/eve/src/public/channels/slack/hitl.test.ts b/packages/eve/src/public/channels/slack/hitl.test.ts
index 0ed66d408..107a3b9eb 100644
--- a/packages/eve/src/public/channels/slack/hitl.test.ts
+++ b/packages/eve/src/public/channels/slack/hitl.test.ts
@@ -4,10 +4,10 @@ import type { InputRequest } from "#shared/input.js";
import {
buildAnsweredBlocks,
buildFreeformModalView,
+ decodeFreeformHitlActionId,
decodeHitlActionId,
deriveHitlResponse,
formatInputRequestFallbackText,
- freeformRequestIdFromActionId,
HITL_ACTION_PREFIX,
HITL_FREEFORM_ACTION_PREFIX,
HITL_FREEFORM_MODAL_ACTION_ID,
@@ -395,14 +395,6 @@ describe("renderInputRequestBlocks", () => {
expect(isFreeformAction(`${HITL_ACTION_PREFIX}call_abc`)).toBe(false);
});
- it("freeformRequestIdFromActionId extracts the trailing requestId slice", () => {
- expect(freeformRequestIdFromActionId(`${HITL_FREEFORM_ACTION_PREFIX}call_xyz`)).toBe(
- "call_xyz",
- );
- expect(freeformRequestIdFromActionId(`${HITL_ACTION_PREFIX}call_xyz`)).toBeUndefined();
- expect(freeformRequestIdFromActionId(HITL_FREEFORM_ACTION_PREFIX)).toBeUndefined();
- });
-
it("preserves the return route on a freeform question", () => {
const blocks = renderInputRequestBlocks(
makeRequest({ requestId: "question_freeform", options: undefined }),
@@ -412,7 +404,7 @@ describe("renderInputRequestBlocks", () => {
.action_id;
expect(actionId).toBe("eve_input_freeform:route:C777:7.7:question_freeform");
- expect(freeformRequestIdFromActionId(actionId)).toBe("question_freeform");
+ expect(decodeFreeformHitlActionId(actionId)?.requestId).toBe("question_freeform");
});
it("truncates section-block prompts past the Slack 3000-char cap", () => {
diff --git a/packages/eve/src/public/channels/slack/hitl.ts b/packages/eve/src/public/channels/slack/hitl.ts
index db31a35b0..33f526f0b 100644
--- a/packages/eve/src/public/channels/slack/hitl.ts
+++ b/packages/eve/src/public/channels/slack/hitl.ts
@@ -363,13 +363,6 @@ export function isFreeformAction(actionId: string): boolean {
return actionId.startsWith(HITL_FREEFORM_ACTION_PREFIX);
}
-/**
- * Extracts the requestId from a freeform-answer button's `action_id`.
- */
-export function freeformRequestIdFromActionId(actionId: string): string | undefined {
- return decodeFreeformHitlActionId(actionId)?.requestId;
-}
-
export function decodeFreeformHitlActionId(actionId: string): DecodedHitlActionId | null {
if (!isFreeformAction(actionId)) return null;
return decodeHitlActionId(
diff --git a/packages/eve/src/public/channels/slack/mrkdwn.test.ts b/packages/eve/src/public/channels/slack/mrkdwn.test.ts
index b74e2a305..581589883 100644
--- a/packages/eve/src/public/channels/slack/mrkdwn.test.ts
+++ b/packages/eve/src/public/channels/slack/mrkdwn.test.ts
@@ -1,39 +1,6 @@
import { describe, expect, it } from "vitest";
-import { gfmToSlackMrkdwn, slackMrkdwnToGfm } from "#public/channels/slack/mrkdwn.js";
-
-describe("gfmToSlackMrkdwn", () => {
- it("converts ** and __ bold to single-star bold", () => {
- expect(gfmToSlackMrkdwn("**a** and __b__")).toBe("*a* and *b*");
- });
-
- it("converts ~~strike~~ to ~strike~", () => {
- expect(gfmToSlackMrkdwn("~~gone~~")).toBe("~gone~");
- });
-
- it("converts [label](url) to <url|label>", () => {
- expect(gfmToSlackMrkdwn("see [docs](https://x.dev)")).toBe("see <https://x.dev|docs>");
- });
-
- it("escapes Slack control characters in link labels", () => {
- expect(gfmToSlackMrkdwn("see [a < b](https://x.dev?a=1&b=2)")).toBe(
- "see <https://x.dev?a=1&b=2|a &lt; b>",
- );
- });
-
- it("leaves links with Slack control characters in the URL unchanged", () => {
- expect(gfmToSlackMrkdwn("see [bad](https://x.dev/a|b)")).toBe("see [bad](https://x.dev/a|b)");
- });
-
- it("leaves fenced code blocks untouched", () => {
- const fenced = "before\n```\n**not bold**\n```\nafter";
- expect(gfmToSlackMrkdwn(fenced)).toBe(fenced);
- });
-
- it("leaves inline code spans untouched", () => {
- expect(gfmToSlackMrkdwn("call `**foo**` here")).toBe("call `**foo**` here");
- });
-});
+import { slackMrkdwnToGfm } from "#public/channels/slack/mrkdwn.js";
describe("slackMrkdwnToGfm", () => {
it("decodes user mentions with and without a display name", () => {
diff --git a/packages/eve/src/public/channels/slack/mrkdwn.ts b/packages/eve/src/public/channels/slack/mrkdwn.ts
index 8f27065f5..22c468be9 100644
--- a/packages/eve/src/public/channels/slack/mrkdwn.ts
+++ b/packages/eve/src/public/channels/slack/mrkdwn.ts
@@ -1,16 +1,4 @@
-import {
- formatSlackLink,
- markdownBoldToSlackMrkdwn,
- slackMrkdwnToMarkdown,
-} from "#compiled/@chat-adapter/slack/format.js";
-
-/** Converts markdown into Slack mrkdwn for legacy Slack text surfaces. */
-export function gfmToSlackMrkdwn(input: string): string {
- const segments = splitCodeFences(input);
- return segments
- .map((segment) => (segment.kind === "code" ? segment.text : markdownToSlack(segment.text)))
- .join("");
-}
+import { slackMrkdwnToMarkdown } from "#compiled/@chat-adapter/slack/format.js";
/** Converts inbound Slack mrkdwn into markdown while preserving code spans and fences. */
export function slackMrkdwnToGfm(input: string): string {
@@ -40,28 +28,6 @@ function splitCodeFences(input: string): Segment[] {
return segments;
}
-function markdownToSlack(input: string): string {
- let output = markdownBoldToSlackMrkdwn(input);
- output = output.replace(/__([^_\n]+)__/gu, "*$1*");
- output = output.replace(/~~([^~\n]+)~~/gu, "~$1~");
- output = output.replace(
- /\[([^\]\n]+)\]\(([^)\s]+)\)/gu,
- (match: string, label: string, url: string) => formatMarkdownLink(match, label, url),
- );
- return output;
-}
-
function slackToMarkdown(input: string): string {
return slackMrkdwnToMarkdown(input.replace(/<!(channel|here|everyone)>/gu, "@$1"));
}
-
-function formatMarkdownLink(match: string, label: string, url: string): string {
- try {
- return formatSlackLink(url, label);
- } catch (error) {
- if (error instanceof TypeError) {
- return match;
- }
- throw error;
- }
-}
diff --git a/packages/eve/src/public/channels/upload-policy.test.ts b/packages/eve/src/public/channels/upload-policy.test.ts
index 9c17aacc6..895cd94a5 100644
--- a/packages/eve/src/public/channels/upload-policy.test.ts
+++ b/packages/eve/src/public/channels/upload-policy.test.ts
@@ -9,7 +9,6 @@ import {
isMediaTypeAllowed,
isUploadsDisabled,
mergeUploadPolicy,
- stripDisallowedFileParts,
type UploadPolicy,
type UploadPolicyConfig,
type UploadPolicyViolation,
@@ -276,33 +275,6 @@ describe("collectUploadPolicyViolations", () => {
});
});
-describe("stripDisallowedFileParts", () => {
- it("removes violating file parts and keeps text/image parts", () => {
- const policy: UploadPolicy = {
- allowedMediaTypes: ["text/csv"],
- maxBytes: 4,
- };
- const content: UserContent = [
- { type: "text", text: "hi" },
- filePart({ data: makeBytes(1), filename: "keep.csv", mediaType: "text/csv" }),
- filePart({ data: makeBytes(64), filename: "drop-size.csv", mediaType: "text/csv" }),
- filePart({ filename: "drop-type.png", mediaType: "image/png" }),
- ];
-
- const stripped = stripDisallowedFileParts(content, policy);
-
- expect(Array.isArray(stripped)).toBe(true);
- expect(stripped).toHaveLength(2);
- const parts = stripped as ReadonlyArray<FilePart | { type: "text"; text: string }>;
- expect(parts[0]).toEqual({ type: "text", text: "hi" });
- expect((parts[1] as FilePart).filename).toBe("keep.csv");
- });
-
- it("returns the input unchanged for plain strings", () => {
- expect(stripDisallowedFileParts("untouched", DEFAULT_UPLOAD_POLICY)).toBe("untouched");
- });
-});
-
describe("formatUploadPolicyViolation", () => {
it("renders too-large violations with byte count and limit", () => {
const violation: UploadPolicyViolation = {
diff --git a/packages/eve/src/public/channels/upload-policy.ts b/packages/eve/src/public/channels/upload-policy.ts
index 8781a4c48..663272791 100644
--- a/packages/eve/src/public/channels/upload-policy.ts
+++ b/packages/eve/src/public/channels/upload-policy.ts
@@ -199,34 +199,6 @@ export function collectUploadPolicyViolations(
return violations;
}
-/**
- * Returns a copy of `content` with every {@link FilePart} that violates
- * `policy` removed.
- *
- * Callers that want a hard-fail contract (HTTP) should use
- * {@link collectUploadPolicyViolations} and return a 4xx response
- * instead. Callers that want best-effort delivery (Slack: drop the bad
- * upload, keep the turn going) use this helper and log the dropped
- * attachments.
- */
-export function stripDisallowedFileParts(
- content: string | UserContent,
- policy: UploadPolicy,
-): string | UserContent {
- if (typeof content === "string") {
- return content;
- }
-
- const filtered = content.filter((part) => {
- if (part.type !== "file") {
- return true;
- }
- return evaluateFilePart(part, policy) === null;
- });
-
- return filtered;
-}
-
/**
* Renders a {@link UploadPolicyViolation} as a short human-readable
* string. Used by channel error responses and warning logs.
diff --git a/packages/eve/src/public/next/server.integration.test.ts b/packages/eve/src/public/next/server.integration.test.ts
index 1cf686225..3a87c4203 100644
--- a/packages/eve/src/public/next/server.integration.test.ts
+++ b/packages/eve/src/public/next/server.integration.test.ts
@@ -113,6 +113,7 @@ describe("resolveEveDestinationPrefix", () => {
vi.stubEnv("NODE_ENV", "development");
const appRoot = await createTempAppRoot();
const child = createMockChildProcess();
+ vi.spyOn(process.stdout, "write").mockImplementation(() => true);
spawnMock.mockReturnValue(child);
const destination = resolveEveDestinationPrefix({
diff --git a/packages/eve/src/services/dev-client/vercel-auth-error.test.ts b/packages/eve/src/services/dev-client/vercel-auth-error.test.ts
index 645f69956..9d68040db 100644
--- a/packages/eve/src/services/dev-client/vercel-auth-error.test.ts
+++ b/packages/eve/src/services/dev-client/vercel-auth-error.test.ts
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
import { ClientError } from "#client/client-error.js";
import {
- formatVercelAuthChallengeMessage,
+ formatDevelopmentOidcTokenFailure,
isVercelAuthChallenge,
vercelTrustedSourcesErrorCode,
} from "#services/dev-client/vercel-auth-error.js";
@@ -166,14 +166,13 @@ describe("vercelTrustedSourcesErrorCode", () => {
it("returns undefined for an unrelated error", () => {
expect(vercelTrustedSourcesErrorCode("Unavailable")).toBeUndefined();
});
+});
+describe("formatDevelopmentOidcTokenFailure", () => {
it("includes invalid local OIDC claims in the repair context", () => {
- const message = formatVercelAuthChallengeMessage({
- serverUrl: "https://example.vercel.app",
- oidcTokenFailure: {
- kind: "invalid-claims",
- invalidClaims: ["owner_id", "project_id"],
- },
+ const message = formatDevelopmentOidcTokenFailure({
+ kind: "invalid-claims",
+ invalidClaims: ["owner_id", "project_id"],
});
expect(message).toContain("invalid claims");
@@ -182,12 +181,9 @@ describe("vercelTrustedSourcesErrorCode", () => {
});
it("identifies the claims that do not match the resolved target", () => {
- const message = formatVercelAuthChallengeMessage({
- serverUrl: "https://example.vercel.app",
- oidcTokenFailure: {
- kind: "target-mismatch",
- mismatchedClaims: ["owner_id", "project_id"],
- },
+ const message = formatDevelopmentOidcTokenFailure({
+ kind: "target-mismatch",
+ mismatchedClaims: ["owner_id", "project_id"],
});
expect(message).toContain("owner_id");
diff --git a/packages/eve/src/services/dev-client/vercel-auth-error.ts b/packages/eve/src/services/dev-client/vercel-auth-error.ts
index 308de6bca..3fee7d5a9 100644
--- a/packages/eve/src/services/dev-client/vercel-auth-error.ts
+++ b/packages/eve/src/services/dev-client/vercel-auth-error.ts
@@ -133,32 +133,6 @@ export function isVercelAuthChallenge(error: unknown): boolean {
);
}
-/**
- * Builds the human-readable repair message for the existing dev-client
- * challenge surface, including a structured local OIDC failure when known.
- */
-export function formatVercelAuthChallengeMessage(input: {
- readonly serverUrl: string;
- readonly oidcTokenFailure?: DevelopmentOidcTokenFailure;
-}): string {
- const lines = [`Vercel Deployment Protection blocked the request to ${input.serverUrl}.`];
- if (input.oidcTokenFailure !== undefined) {
- lines.push("", formatDevelopmentOidcTokenFailure(input.oidcTokenFailure));
- }
- lines.push(
- "",
- "To access the deployment from `eve dev`, do one of:",
- " • Run `vercel link` in this project so the CLI can mint an OIDC",
- " token for the deployment automatically.",
- " • Set VERCEL_AUTOMATION_BYPASS_SECRET to a Protection Bypass for",
- " Automation token (Project Settings → Deployment Protection).",
- " • Disable Deployment Protection on the target deployment.",
- "",
- "Docs: https://vercel.com/docs/deployment-protection",
- );
- return lines.join("\n");
-}
-
export function formatDevelopmentOidcTokenFailure(failure: DevelopmentOidcTokenFailure): string {
switch (failure.kind) {
case "resolution-failed":
diff --git a/packages/eve/src/setup/boxes/select-model.test.ts b/packages/eve/src/setup/boxes/select-model.test.ts
index 8ca5fe875..9167c1e70 100644
--- a/packages/eve/src/setup/boxes/select-model.test.ts
+++ b/packages/eve/src/setup/boxes/select-model.test.ts
@@ -1,24 +1,14 @@
import { afterEach, describe, expect, it, vi } from "vitest";
-import { createFakePrompter } from "#internal/testing/fake-prompter.js";
import { DEFAULT_AGENT_MODEL_ID } from "#shared/default-agent-model.js";
-import { headlessAsker, InteractionRequired, interactiveAsker, type Asker } from "../ask.js";
-import type { Prompter, PrompterValue, SingleSelectOptions } from "../prompter.js";
-import { createDefaultSetupState } from "../state.js";
-import type { OutputSink } from "../step.js";
-import { runHeadless, runInteractive } from "../runner.js";
import {
fetchGatewayCatalog,
modelOptionsFromCatalog,
parseGatewayCatalog,
- selectModel,
type GatewayCatalogModel,
- type SelectModelDeps,
} from "./select-model.js";
-const silentSink: OutputSink = { write: () => {} };
-
afterEach(() => {
vi.unstubAllGlobals();
});
@@ -68,43 +58,6 @@ const CATALOG: GatewayCatalogModel[] = [
{ id: "google/gemma-2", name: "Gemma 2", type: "language", owned_by: "google", tags: [] },
];
-function catalogDeps(models: GatewayCatalogModel[] = CATALOG): SelectModelDeps {
- return { fetchModels: vi.fn(async () => models) };
-}
-
-function unexpectedFetch(): SelectModelDeps {
- return {
- fetchModels: vi.fn(async (): Promise<GatewayCatalogModel[]> => {
- throw new Error("Unexpected catalog fetch in a select-model test.");
- }),
- };
-}
-
-/** Proves a path never reaches the channel at all. */
-function untouchableAsker(): Asker {
- return {
- ask(question): Promise<never> {
- throw new Error(`untouchableAsker was asked "${question.key}"`);
- },
- askEditable(question): Promise<never> {
- throw new Error(`untouchableAsker was asked "${question.key}"`);
- },
- askMany(question): Promise<never> {
- throw new Error(`untouchableAsker was asked "${question.key}"`);
- },
- };
-}
-
-type SingleHandler = (opts: SingleSelectOptions<PrompterValue>) => PrompterValue;
-
-function createSelectPrompter(handler: SingleHandler): {
- prompter: Prompter;
- single: SingleHandler;
-} {
- const single = vi.fn(handler);
- return { prompter: createFakePrompter({ single }).prompter, single };
-}
-
describe("modelOptionsFromCatalog", () => {
it("filters, sorts newest-first behind the featured lead, and marks the shortlist", () => {
const options = modelOptionsFromCatalog(CATALOG);
@@ -127,56 +80,10 @@ describe("modelOptionsFromCatalog", () => {
expect(values).toContain("google/gemini-3.5");
}
});
-});
-
-describe("selectModel box", () => {
- it("short-circuits both runners on a preset model", async () => {
- const deps = unexpectedFetch();
- const box = selectModel({ asker: untouchableAsker(), presetModel: "openai/gpt-5-mini", deps });
-
- const interactive = await runInteractive([box], createDefaultSetupState(), silentSink);
- expect(interactive.kind).toBe("done");
- if (interactive.kind !== "done") return;
- expect(interactive.state.modelId).toBe("openai/gpt-5-mini");
-
- const headless = await runHeadless([box], createDefaultSetupState(), silentSink);
- expect(headless.modelId).toBe("openai/gpt-5-mini");
-
- expect(deps.fetchModels).not.toHaveBeenCalled();
- });
-
- it("offers a searchable picker over the filtered, release-sorted catalog", async () => {
- let captured: SingleSelectOptions<PrompterValue> | undefined;
- const { prompter } = createSelectPrompter((opts) => {
- captured = opts;
- return "spacexai/grok-4.7";
- });
- const box = selectModel({ asker: interactiveAsker(prompter), deps: catalogDeps() });
-
- const result = await runInteractive([box], createDefaultSetupState(), silentSink);
-
- expect(result.kind).toBe("done");
- if (result.kind !== "done") return;
- expect(result.state.modelId).toBe("spacexai/grok-4.7");
- expect(captured?.search).toBe(true);
- // The featured default remains first; the rest are newest release first.
- expect(captured?.options.map((option) => option.value)).toEqual([
- "spacexai/grok-4.7",
- "zai/glm-4.6",
- "openai/gpt-5-mini",
- ]);
- // Cursor defaults to the top catalog entry when no default is configured.
- expect(captured?.initialValue).toBe("spacexai/grok-4.7");
- });
- it("orders the curated shortlist first, marks it featured, and pre-selects the default", async () => {
- let captured: SingleSelectOptions<PrompterValue> | undefined;
- const { prompter } = createSelectPrompter((opts) => {
- captured = opts;
- return DEFAULT_AGENT_MODEL_ID;
- });
+ it("orders the curated shortlist first and marks only it featured", () => {
// The curated order keeps the default ahead of the newer Opus entry.
- const catalog: GatewayCatalogModel[] = [
+ const options = modelOptionsFromCatalog([
{
id: "anthropic/claude-opus-4.8",
name: "Claude Opus 4.8",
@@ -186,99 +93,50 @@ describe("selectModel box", () => {
tags: ["web-search"],
},
...CATALOG,
- ];
- const box = selectModel({ asker: interactiveAsker(prompter), deps: catalogDeps(catalog) });
-
- const result = await runInteractive([box], createDefaultSetupState(), silentSink);
+ ]);
- expect(result.kind).toBe("done");
- if (result.kind !== "done") return;
- expect(captured?.options.map((option) => option.value)).toEqual([
+ expect(options.map((option) => option.value)).toEqual([
"spacexai/grok-4.7",
"anthropic/claude-opus-4.8",
"zai/glm-4.6",
"openai/gpt-5-mini",
]);
- // Only the curated entries are featured: the picker's default view shows
- // them alone, and scrolling or search surfaces the rest of the catalog.
- expect(captured?.options.filter((option) => option.featured).map((o) => o.value)).toEqual([
+ expect(options.filter((option) => option.featured).map((o) => o.value)).toEqual([
"spacexai/grok-4.7",
"anthropic/claude-opus-4.8",
]);
- expect(captured?.initialValue).toBe(DEFAULT_AGENT_MODEL_ID);
});
- it("sorts undated models after dated models with deterministic ties", async () => {
- let captured: SingleSelectOptions<PrompterValue> | undefined;
- const { prompter } = createSelectPrompter((opts) => {
- captured = opts;
- return "acme/newer";
- });
- const models: GatewayCatalogModel[] = [
- {
- id: "acme/undated",
- name: "Undated",
- type: "language",
- owned_by: "acme",
- tags: ["web-search"],
- },
- {
- id: "acme/zeta",
- name: "Same release Zeta",
- type: "language",
- owned_by: "acme",
- released: 100,
- tags: ["web-search"],
- },
- {
- id: "acme/alpha",
- name: "Same release Alpha",
+ it("sorts undated models after dated models with deterministic ties", () => {
+ const model = (id: string, name: string, released?: number): GatewayCatalogModel => {
+ const entry: GatewayCatalogModel = {
+ id,
+ name,
type: "language",
owned_by: "acme",
- released: 100,
tags: ["web-search"],
- },
- {
- id: "acme/newer",
- name: "Newer",
- type: "language",
- owned_by: "acme",
- released: 200,
- tags: ["web-search"],
- },
- ];
+ };
+ if (released !== undefined) entry.released = released;
+ return entry;
+ };
- await runInteractive(
- [selectModel({ asker: interactiveAsker(prompter), deps: catalogDeps(models) })],
- createDefaultSetupState(),
- silentSink,
- );
+ const options = modelOptionsFromCatalog([
+ model("acme/undated", "Undated"),
+ model("acme/zeta", "Same release Zeta", 100),
+ model("acme/alpha", "Same release Alpha", 100),
+ model("acme/newer", "Newer", 200),
+ ]);
- expect(captured?.options.map((option) => option.value)).toEqual([
+ expect(options.map((option) => option.value)).toEqual([
"acme/newer",
"acme/alpha",
"acme/zeta",
"acme/undated",
]);
});
+});
- it("pre-selects the configured default model when present in the catalog", async () => {
- let captured: SingleSelectOptions<PrompterValue> | undefined;
- const { prompter } = createSelectPrompter((opts) => {
- captured = opts;
- return "openai/gpt-5-mini";
- });
- const box = selectModel({
- asker: interactiveAsker(prompter),
- defaultModel: "openai/gpt-5-mini",
- deps: catalogDeps(),
- });
-
- await runInteractive([box], createDefaultSetupState(), silentSink);
-
- expect(captured?.initialValue).toBe("openai/gpt-5-mini");
- });
-
+describe("parseGatewayCatalog", () => {
it("skips malformed catalog entries instead of rejecting the whole catalog", () => {
const models = parseGatewayCatalog({
data: [
@@ -319,59 +177,4 @@ describe("selectModel box", () => {
it("rejects a catalog payload without a data array", () => {
expect(() => parseGatewayCatalog({ models: [] })).toThrow("invalid model catalog");
});
-
- it("falls back to the static shortlist when the catalog fetch fails", async () => {
- let captured: SingleSelectOptions<PrompterValue> | undefined;
- const { prompter } = createSelectPrompter((opts) => {
- captured = opts;
- return DEFAULT_AGENT_MODEL_ID;
- });
- const deps: SelectModelDeps = {
- fetchModels: vi.fn(async (): Promise<GatewayCatalogModel[]> => {
- throw new Error("network down");
- }),
- };
- const box = selectModel({ asker: interactiveAsker(prompter), deps });
-
- const result = await runInteractive([box], createDefaultSetupState(), silentSink);
-
- expect(result.kind).toBe("done");
- if (result.kind !== "done") return;
- expect(result.state.modelId).toBe(DEFAULT_AGENT_MODEL_ID);
- expect(captured?.options.map((option) => option.value)).toContain(DEFAULT_AGENT_MODEL_ID);
- expect(captured?.options.map((option) => option.value)).toContain("google/gemini-3.5");
- });
-
- it("falls back to the static shortlist when the filtered catalog is empty", async () => {
- let captured: SingleSelectOptions<PrompterValue> | undefined;
- const { prompter } = createSelectPrompter((opts) => {
- captured = opts;
- return DEFAULT_AGENT_MODEL_ID;
- });
- const box = selectModel({
- asker: interactiveAsker(prompter),
- deps: catalogDeps([
- { id: "openai/dall-e-3", name: "DALL-E 3", type: "image", owned_by: "openai" },
- ]),
- });
-
- await runInteractive([box], createDefaultSetupState(), silentSink);
-
- expect(captured?.options.map((option) => option.value)).toContain(DEFAULT_AGENT_MODEL_ID);
- });
-
- it("headless without a preset refuses with InteractionRequired naming the question", async () => {
- // The unified gather builds the option list before asking, so the catalog
- // fetch now precedes the structural refusal (the dual-face box failed
- // before fetching).
- const deps = catalogDeps();
- const box = selectModel({ asker: headlessAsker(), deps });
-
- const run = runHeadless([box], createDefaultSetupState(), silentSink);
- await expect(run).rejects.toThrow(InteractionRequired);
- await expect(runHeadless([box], createDefaultSetupState(), silentSink)).rejects.toMatchObject({
- message: expect.stringMatching(/Which model should your agent use\?/),
- question: expect.objectContaining({ key: "model", required: true }),
- });
- });
});
diff --git a/packages/eve/src/setup/boxes/select-model.ts b/packages/eve/src/setup/boxes/select-model.ts
index a17f79d0d..b1c3c9a50 100644
--- a/packages/eve/src/setup/boxes/select-model.ts
+++ b/packages/eve/src/setup/boxes/select-model.ts
@@ -5,12 +5,10 @@ import {
type GatewayCatalogModel,
} from "#shared/gateway-model-catalog.js";
-import { select, type Asker, type SelectOption } from "../ask.js";
-import type { SetupState } from "../state.js";
-import type { SetupBox } from "../step.js";
+import type { SelectOption } from "../ask.js";
+
const FETCH_TIMEOUT_MS = 5000;
const WEB_SEARCH_TAG = "web-search";
-const MODEL_PROMPT_MESSAGE = "Which model should your agent use?";
export type { GatewayCatalogModel } from "#shared/gateway-model-catalog.js";
@@ -56,7 +54,7 @@ function providerLabel(provider: string): string {
return PROVIDER_BRANDS[provider] ?? provider.charAt(0).toUpperCase() + provider.slice(1);
}
-/** Fetches the raw AI Gateway catalog. The default for {@link SelectModelDeps}. */
+/** Fetches the raw AI Gateway catalog. */
export async function fetchGatewayCatalog(signal?: AbortSignal): Promise<GatewayCatalogModel[]> {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
@@ -129,89 +127,3 @@ export function modelOptionsFromCatalog(
featured: FEATURED_MODEL_IDS.includes(value) || undefined,
}));
}
-
-async function buildModelOptions(
- fetchModels: (signal?: AbortSignal) => Promise<GatewayCatalogModel[]>,
- signal?: AbortSignal,
-): Promise<SelectOption<string>[]> {
- try {
- return modelOptionsFromCatalog(await fetchModels(signal));
- } catch {
- signal?.throwIfAborted();
- return FALLBACK_MODELS;
- }
-}
-
-/** Injected for tests; defaults to the real AI Gateway catalog fetch. */
-export interface SelectModelDeps {
- fetchModels: (signal?: AbortSignal) => Promise<GatewayCatalogModel[]>;
-}
-
-export interface SelectModelOptions {
- /** Resolves the model question; the composed stack decides how. */
- asker: Asker;
- /**
- * Resolve to this value without fetching the catalog or asking. Stays a
- * factory option (not a `withAnswers` rung) because a preset must keep
- * short-circuiting the catalog fetch and must keep accepting ids the
- * filtered catalog does not list, exactly as the dual-face box did.
- */
- presetModel?: string;
- /**
- * Pre-select this model in the picker so enter confirms it. Falls back to the
- * top catalog entry when omitted or not present in the catalog.
- */
- defaultModel?: string;
- deps?: SelectModelDeps;
-}
-
-/**
- * THE MODEL BOX: pick the default model baked into `agent/agent.ts`. The
- * gather fetches the AI Gateway catalog and asks one required "model" select
- * through the box's asker, so an interactive stack offers a searchable picker
- * while a headless stack refuses structurally when no preset answered it.
- * The model is the first thing the interview decides about the agent itself;
- * how the credential is wired (gateway vs your own provider key) is the
- * provisioning box's later decision, and the byok scaffold derives its
- * provider block from whatever model was picked here.
- */
-export function selectModel(options: SelectModelOptions): SetupBox<SetupState, string, string> {
- const deps = options.deps ?? { fetchModels: fetchGatewayCatalog };
-
- return {
- id: "select-model",
-
- async gather({ signal }): Promise<string> {
- const preset = options.presetModel;
- if (preset !== undefined && preset.length > 0) return preset;
- const models = await buildModelOptions(deps.fetchModels, signal);
- const recommended =
- options.defaultModel !== undefined && models.some((m) => m.value === options.defaultModel)
- ? options.defaultModel
- : models.some((m) => m.value === DEFAULT_AGENT_MODEL_ID)
- ? DEFAULT_AGENT_MODEL_ID
- : models[0]?.value;
- return options.asker.ask(
- select({
- key: "model",
- message: MODEL_PROMPT_MESSAGE,
- options: models,
- recommended,
- // A headless run without a preset must fail rather than guess a
- // model, as the dual-face box did.
- required: true,
- search: true,
- placeholder: "type to search",
- }),
- );
- },
-
- async perform({ input }): Promise<string> {
- return input;
- },
-
- apply(state, payload) {
- return { ...state, modelId: payload };
- },
- };
-}
diff --git a/packages/eve/src/setup/flows/provider.test.ts b/packages/eve/src/setup/flows/provider.test.ts
deleted file mode 100644
index d38a01a45..000000000
--- a/packages/eve/src/setup/flows/provider.test.ts
+++ /dev/null
@@ -1,473 +0,0 @@
-import { describe, expect, it, vi } from "vitest";
-
-import { createFakePrompter } from "#internal/testing/fake-prompter.js";
-import type { VercelAuthStatus } from "#setup/vercel-project.js";
-import { HumanActionRequiredError } from "#setup/human-action.js";
-
-import {
- EXTERNAL_PROVIDER_INSTRUCTIONS,
- EXTERNAL_PROVIDER_INSTRUCTIONS_TITLE,
- PROVIDER_QUESTION,
- runProviderFlow,
- type ProviderFlowDeps,
- type ProviderPicker,
-} from "./provider.js";
-
-const APP_ROOT = "/app/my-agent";
-
-function createDeps() {
- return {
- getVercelAuthStatus: vi.fn(async (): Promise<VercelAuthStatus> => "authenticated"),
- runLinkFlow: vi.fn<ProviderFlowDeps["runLinkFlow"]>(async () => ({
- kind: "done",
- })),
- appendEnv: vi.fn<ProviderFlowDeps["appendEnv"]>(async () => ({
- written: ["AI_GATEWAY_API_KEY"],
- skipped: [],
- })),
- validateGatewayApiKey: vi.fn<ProviderFlowDeps["validateGatewayApiKey"]>(async () => ({
- kind: "valid",
- })),
- };
-}
-
-type ProviderFlowInput = Parameters<typeof runProviderFlow>[0];
-
-function runTestProviderFlow(
- input: Omit<ProviderFlowInput, "availableProviders" | "selectedProvider"> &
- Partial<Pick<ProviderFlowInput, "availableProviders" | "selectedProvider">>,
-) {
- return runProviderFlow({
- availableProviders: ["chatgpt", "ai-gateway-project"],
- selectedProvider: "ai-gateway-project",
- ...input,
- });
-}
-
-describe("runProviderFlow", () => {
- it("hands the Dev TUI one menu and lets the active project be replaced", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
- const picker: ProviderPicker = async (request) => {
- expect(request.message).toBe(PROVIDER_QUESTION);
- expect(request.options.map((option) => option.value)).toEqual([
- "ai-gateway-project",
- "ai-gateway-key",
- "chatgpt",
- "external",
- ]);
- expect(request.options[2]).toMatchObject({
- value: "chatgpt",
- label: "ChatGPT subscription",
- });
- expect(request.options[3]).toMatchObject({
- value: "external",
- label: "Other providers",
- });
- expect(request.initialValue).toBe("ai-gateway-project");
- return { kind: "ai-gateway-project" };
- };
-
- const result = await runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker,
- deps,
- });
-
- expect(result).toEqual({ kind: "ai-gateway-project" });
- expect(deps.runLinkFlow).toHaveBeenCalledExactlyOnceWith({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- projectSelection: "create-or-link",
- });
- });
-
- it("returns ChatGPT without touching Gateway setup", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
-
- const result = await runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker: async (request) => {
- expect(request.options.map((option) => option.value)).toEqual([
- "ai-gateway-project",
- "ai-gateway-key",
- "chatgpt",
- "external",
- ]);
- return { kind: "chatgpt" };
- },
- deps,
- });
-
- expect(result).toEqual({ kind: "chatgpt" });
- expect(deps.getVercelAuthStatus).not.toHaveBeenCalled();
- expect(deps.runLinkFlow).not.toHaveBeenCalled();
- expect(deps.appendEnv).not.toHaveBeenCalled();
- });
-
- it("selects an available linked project without opening the link flow", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
-
- const result = await runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker: async () => ({ kind: "ai-gateway-project" }),
- selectedProvider: "chatgpt",
- deps,
- });
-
- expect(result).toEqual({ kind: "ai-gateway-project" });
- expect(deps.getVercelAuthStatus).not.toHaveBeenCalled();
- expect(deps.runLinkFlow).not.toHaveBeenCalled();
- });
-
- it("checks and describes the active provider, opening the cursor on it", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
- const linked: ProviderPicker = async (request) => {
- expect(request.initialValue).toBe("ai-gateway-project");
- expect(request.options[0]).toMatchObject({
- value: "ai-gateway-project",
- checked: true,
- hint: "Current",
- });
- expect(request.options[1]?.checked).toBeUndefined();
- return undefined;
- };
- await runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker: linked,
- selectedProvider: "ai-gateway-project",
- deps,
- });
-
- const keyed: ProviderPicker = async (request) => {
- expect(request.initialValue).toBe("ai-gateway-key");
- expect(request.options[1]).toMatchObject({
- value: "ai-gateway-key",
- checked: true,
- hint: "Current",
- });
- return undefined;
- };
- await runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker: keyed,
- selectedProvider: "ai-gateway-key",
- deps,
- });
- });
-
- it("does not mark an inferred provider as current during onboarding", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
- const picker: ProviderPicker = async (request) => {
- expect(request.initialValue).toBe("ai-gateway-project");
- expect(request.options.every((option) => option.checked !== true)).toBe(true);
- expect(request.options.every((option) => option.hint !== "Current")).toBe(true);
- return undefined;
- };
-
- await runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker,
- selectedProvider: "ai-gateway-project",
- selectionExplicit: false,
- deps,
- });
- });
-
- it("uses the stored selection when multiple providers are available", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
- const picker: ProviderPicker = async (request) => {
- expect(request.initialValue).toBe("ai-gateway-project");
- expect(request.options.find((option) => option.value === "ai-gateway-project")?.checked).toBe(
- true,
- );
- expect(
- request.options.find((option) => option.value === "ai-gateway-key")?.checked,
- ).toBeUndefined();
- return undefined;
- };
-
- await runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker,
- selectedProvider: "ai-gateway-project",
- deps,
- });
- });
-
- it("keeps a transiently unavailable project selectable for retry", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
- deps.getVercelAuthStatus
- .mockResolvedValueOnce("unavailable")
- .mockResolvedValueOnce("authenticated");
- let pick = 0;
-
- await expect(
- runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker: async (request) => {
- if (pick++ === 1) {
- expect(request.initialValue).toBe("ai-gateway-project");
- expect(request.options[0]).toMatchObject({
- value: "ai-gateway-project",
- hint: "Couldn't reach Vercel — select to retry",
- });
- expect(request.options[0]?.disabled).not.toBe(true);
- }
- return { kind: "ai-gateway-project" };
- },
- deps,
- }),
- ).resolves.toEqual({ kind: "ai-gateway-project" });
-
- expect(deps.getVercelAuthStatus).toHaveBeenCalledTimes(2);
- expect(deps.runLinkFlow).toHaveBeenCalledOnce();
- });
-
- it("keeps a declined login recoverable from the project row", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
- deps.getVercelAuthStatus.mockResolvedValue("logged-out");
- const recoverHumanAction = vi.fn(async () => "cancel" as const);
- let pick = 0;
-
- await expect(
- runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker: async (request) => {
- if (pick++ === 1) {
- expect(request.initialValue).toBe("ai-gateway-project");
- expect(request.options[0]).toMatchObject({
- value: "ai-gateway-project",
- hint: "Log in to Vercel — select to retry",
- });
- expect(request.options[0]?.disabled).not.toBe(true);
- return undefined;
- }
- return { kind: "ai-gateway-project" };
- },
- recoverHumanAction,
- deps,
- }),
- ).resolves.toEqual({ kind: "cancelled" });
-
- expect(recoverHumanAction).toHaveBeenCalledOnce();
- });
-
- it("repairs a missing CLI and login in place before linking", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
- deps.getVercelAuthStatus
- .mockResolvedValueOnce("cli-missing")
- .mockResolvedValueOnce("logged-out")
- .mockResolvedValueOnce("authenticated");
- const actions: string[] = [];
-
- await expect(
- runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker: async () => ({ kind: "ai-gateway-project" }),
- recoverHumanAction: async (error) => {
- actions.push(error.action.kind);
- return "retry";
- },
- deps,
- }),
- ).resolves.toEqual({ kind: "ai-gateway-project" });
-
- expect(actions).toEqual(["vercel-cli-missing", "vercel-login"]);
- expect(deps.runLinkFlow).toHaveBeenCalledOnce();
- });
-
- it("repairs a link-time Vercel capability and resumes the same link", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
- deps.runLinkFlow
- .mockRejectedValueOnce(
- new HumanActionRequiredError({
- kind: "vercel-cli-upgrade",
- command: "vercel upgrade",
- reason: "The CLI cannot list teams.",
- }),
- )
- .mockResolvedValueOnce({ kind: "done" });
- const recoverHumanAction = vi.fn(async () => "retry" as const);
-
- await expect(
- runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker: async () => ({ kind: "ai-gateway-project" }),
- recoverHumanAction,
- deps,
- }),
- ).resolves.toEqual({ kind: "ai-gateway-project" });
-
- expect(recoverHumanAction).toHaveBeenCalledOnce();
- expect(deps.runLinkFlow).toHaveBeenCalledTimes(2);
- });
-
- it("preserves cancellation from the project link flow", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
- deps.runLinkFlow.mockResolvedValueOnce({ kind: "cancelled" });
-
- await expect(
- runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker: async () => ({ kind: "ai-gateway-project" }),
- deps,
- }),
- ).resolves.toEqual({ kind: "cancelled" });
- });
-
- it("opens on ChatGPT when it is the selected provider", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
- const picker: ProviderPicker = async (request) => {
- expect(request.initialValue).toBe("chatgpt");
- expect(request.options.find((option) => option.value === "chatgpt")).toMatchObject({
- checked: true,
- hint: "Current",
- });
- return undefined;
- };
-
- await runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker,
- selectedProvider: "chatgpt",
- deps,
- });
- });
-
- it("reports a committed key as one set line", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
-
- await runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker: async () => ({
- kind: "ai-gateway-key",
- key: "sk-inline",
- validation: { kind: "valid" },
- }),
- deps,
- });
-
- expect(fake.prompter.log.success).toHaveBeenCalledExactlyOnceWith("AI_GATEWAY_API_KEY set.");
- });
-
- it("persists the accepted inline key and does not revalidate it after submission", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
- const picker: ProviderPicker = async (request) => {
- const signal = new AbortController().signal;
- const validation = await request.validateInlineKey("sk-inline", signal);
- if (validation.kind === "invalid") throw new Error(validation.message);
- return { kind: "ai-gateway-key", key: "sk-inline", validation };
- };
-
- const result = await runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker,
- deps,
- });
-
- expect(result).toEqual({ kind: "ai-gateway-key" });
- expect(deps.validateGatewayApiKey).toHaveBeenCalledExactlyOnceWith(
- "sk-inline",
- expect.any(AbortSignal),
- );
- expect(deps.appendEnv).toHaveBeenCalledExactlyOnceWith(
- `${APP_ROOT}/.env.local`,
- { AI_GATEWAY_API_KEY: "sk-inline" },
- { force: true },
- );
- });
-
- it("returns the committed key when interruption races the env write", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
- const picker: ProviderPicker = async () => ({
- kind: "ai-gateway-key",
- key: "sk-committed",
- validation: { kind: "valid" },
- });
- const writeStarted = Promise.withResolvers<void>();
- const releaseWrite = Promise.withResolvers<void>();
- deps.appendEnv.mockImplementationOnce(async () => {
- writeStarted.resolve();
- await releaseWrite.promise;
- return { written: ["AI_GATEWAY_API_KEY"], skipped: [] };
- });
- const controller = new AbortController();
-
- const execution = runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker,
- signal: controller.signal,
- deps,
- });
- await writeStarted.promise;
- controller.abort();
- releaseWrite.resolve();
-
- await expect(execution).resolves.toEqual({ kind: "ai-gateway-key" });
- });
-
- it("shows direct-provider instructions without changing credentials", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
-
- const result = await runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker: async () => ({ kind: "external" }),
- deps,
- });
-
- expect(result).toEqual({ kind: "external-provider" });
- expect(fake.prompter.acknowledge).toHaveBeenCalledExactlyOnceWith({
- message: EXTERNAL_PROVIDER_INSTRUCTIONS_TITLE,
- lines: EXTERNAL_PROVIDER_INSTRUCTIONS,
- });
- expect(deps.appendEnv).not.toHaveBeenCalled();
- });
-
- it("folds a cancelled provider picker into the flow's cancelled result", async () => {
- const fake = createFakePrompter();
- const deps = createDeps();
-
- await expect(
- runTestProviderFlow({
- appRoot: APP_ROOT,
- prompter: fake.prompter,
- picker: async () => undefined,
- deps,
- }),
- ).resolves.toEqual({ kind: "cancelled" });
- expect(deps.runLinkFlow).not.toHaveBeenCalled();
- });
-});
diff --git a/packages/eve/src/setup/flows/provider.ts b/packages/eve/src/setup/flows/provider.ts
index 09c31b333..e10ef09c2 100644
--- a/packages/eve/src/setup/flows/provider.ts
+++ b/packages/eve/src/setup/flows/provider.ts
@@ -1,48 +1,10 @@
-import { appendEnv } from "../append-env.js";
-import {
- AI_GATEWAY_API_KEY_ENV_FILE,
- AI_GATEWAY_API_KEY_ENV_VAR,
- writeAiGatewayApiKey,
-} from "../ai-gateway-api-key.js";
-import type { Prompter, SelectOption } from "../prompter.js";
-import { WizardCancelledError } from "../step.js";
-import { validateGatewayApiKey, type GatewayKeyValidation } from "../validate-gateway-key.js";
-import {
- getVercelAuthStatus,
- vercelAuthBlockerReason,
- type VercelAuthStatus,
-} from "../vercel-project.js";
-import { withSpinner } from "../with-spinner.js";
+import type { SelectOption } from "../prompter.js";
+import type { GatewayKeyValidation } from "../validate-gateway-key.js";
import type { ProviderSelection } from "#setup/provider-settings.js";
-import { HumanActionRequiredError } from "#setup/human-action.js";
-
-import { runLinkFlow } from "./link.js";
export type ProviderConnection = ProviderSelection | "external";
-export const PROVIDER_QUESTION = "Which model provider do you want to use?";
-
-export const EXTERNAL_PROVIDER_INSTRUCTIONS_TITLE = "Using another model provider";
-export const EXTERNAL_PROVIDER_INSTRUCTIONS: readonly string[] = [
- `Set your provider's API key in ${AI_GATEWAY_API_KEY_ENV_FILE} — e.g. ANTHROPIC_API_KEY or OPENAI_API_KEY.`,
- 'In agent/agent.ts, set `model` to a provider-authored model — e.g. `anthropic("claude-opus-4.8")` from `@ai-sdk/anthropic`.',
- "See https://eve.dev/docs/agent-config for details.",
- "A running `eve dev` reloads env files automatically — no restart needed.",
-];
-
-/** Injected for tests; defaults to the real link flow, env write, and key check. */
-export interface ProviderFlowDeps {
- getVercelAuthStatus: typeof getVercelAuthStatus;
- runLinkFlow: typeof runLinkFlow;
- appendEnv: typeof appendEnv;
- validateGatewayApiKey: typeof validateGatewayApiKey;
-}
-
-export type ProviderFlowResult = {
- kind: ProviderSelection | "cancelled" | "external-provider";
-};
-
type AcceptedGatewayKeyValidation = Exclude<GatewayKeyValidation, { kind: "invalid" }>;
/** A provider choice, including the accepted evidence for an inline key. */
@@ -63,268 +25,3 @@ export interface ProviderPickerRequest {
initialValue: ProviderConnection;
validateInlineKey(key: string, signal: AbortSignal): Promise<GatewayKeyValidation>;
}
-
-/** Renderer-owned provider chooser; only the Dev TUI invokes this flow. */
-export type ProviderPicker = (
- request: ProviderPickerRequest,
-) => Promise<ProviderPickerChoice | undefined>;
-
-function projectConnectionOption(
- authStatus: VercelAuthStatus | undefined,
- recoverable: boolean,
-): SelectOption<ProviderConnection> {
- const option: SelectOption<ProviderConnection> = {
- value: "ai-gateway-project",
- label: "AI Gateway via Project",
- hint: "Authenticates with AI Gateway automatically\nin a new or existing project. No keys to manage.",
- };
- if (authStatus === "unavailable") {
- return { ...option, hint: "Couldn't reach Vercel — select to retry" };
- }
- if (recoverable && authStatus === "logged-out") {
- return { ...option, hint: "Log in to Vercel — select to retry" };
- }
- if (recoverable && authStatus === "cli-missing") {
- return { ...option, hint: "Install the Vercel CLI — select to retry" };
- }
- const disabledReason = authStatus === undefined ? undefined : vercelAuthBlockerReason(authStatus);
- return disabledReason === undefined
- ? option
- : { ...option, disabled: true, disabledReason, disabledReasonTone: "warning" };
-}
-
-function providerOptions(
- authStatus: VercelAuthStatus | undefined,
- selectedProvider: ProviderSelection,
- selectionExplicit: boolean,
- recoverable: boolean,
-): SelectOption<ProviderConnection>[] {
- let project = projectConnectionOption(authStatus, recoverable);
- if (
- selectionExplicit &&
- selectedProvider === "ai-gateway-project" &&
- authStatus !== "unavailable" &&
- !(recoverable && (authStatus === "logged-out" || authStatus === "cli-missing"))
- ) {
- project = { ...project, checked: true, hint: "Current" };
- }
-
- let gatewayKey: SelectOption<ProviderConnection> = {
- value: "ai-gateway-key",
- label: `AI Gateway via ${AI_GATEWAY_API_KEY_ENV_VAR}`,
- hint: "⎿ type your key",
- };
- if (selectionExplicit && selectedProvider === "ai-gateway-key") {
- gatewayKey = { ...gatewayKey, checked: true, hint: "Current" };
- }
-
- return [
- project,
- gatewayKey,
- {
- value: "chatgpt",
- label: "ChatGPT subscription",
- hint:
- selectionExplicit && selectedProvider === "chatgpt"
- ? "Current"
- : "Sign in with your ChatGPT account",
- checked: (selectionExplicit && selectedProvider === "chatgpt") || undefined,
- },
- {
- value: "external",
- label: "Other providers",
- hint: "Connect directly to a model provider\nvia OPENAI_API_KEY or ANTHROPIC_API_KEY.",
- },
- ];
-}
-
-async function selectProvider(input: {
- picker?: ProviderPicker;
- options: SelectOption<ProviderConnection>[];
- initialValue: ProviderConnection;
- validateInlineKey: (key: string, signal: AbortSignal) => Promise<GatewayKeyValidation>;
-}): Promise<ProviderPickerChoice> {
- const request: ProviderPickerRequest = {
- message: PROVIDER_QUESTION,
- options: input.options,
- initialValue: input.initialValue,
- validateInlineKey: input.validateInlineKey,
- };
- if (input.picker === undefined) {
- throw new Error("The provider flow requires the Dev TUI provider picker.");
- }
- const choice = await input.picker(request);
- if (choice === undefined) throw new WizardCancelledError();
- return choice;
-}
-
-/**
- * THE PROVIDER FLOW behind the dev TUI `/model` menu's provider row
- * (`eve link` keeps {@link runLinkFlow}'s shape). One question chooses a
- * project-backed AI Gateway connection, an `AI_GATEWAY_API_KEY`, ChatGPT, or a
- * direct provider. Selecting an available but inactive project only changes
- * the selection; selecting the active project opens the link flow so it can
- * be replaced. A project-less agent can create its first project there rather
- * than dead-end on an empty list.
- */
-export async function runProviderFlow(input: {
- appRoot: string;
- prompter: Prompter;
- signal?: AbortSignal;
- picker?: ProviderPicker;
- /** Provider availability resolved before the picker opened. */
- availableProviders: readonly ProviderSelection[];
- /** The current provider selection. */
- selectedProvider: ProviderSelection;
- /** Whether that selection was explicitly persisted rather than inferred from available access. */
- selectionExplicit?: boolean;
- /** Interactive caller recovery that resumes project linking after Vercel repair. */
- recoverHumanAction?: (error: HumanActionRequiredError) => Promise<"retry" | "cancel">;
- deps?: Partial<ProviderFlowDeps>;
-}): Promise<ProviderFlowResult> {
- const { appRoot, prompter, signal } = input;
- const deps: ProviderFlowDeps = {
- getVercelAuthStatus,
- runLinkFlow,
- appendEnv,
- validateGatewayApiKey,
- ...input.deps,
- };
-
- let authStatus: VercelAuthStatus | undefined;
- const { availableProviders, selectedProvider } = input;
- // The cursor opens on the active provider; a Vercel auth blocker still
- // re-homes it onto the key row below.
- let initialValue: ProviderConnection = selectedProvider;
- let keyChoice: Extract<ProviderPickerChoice, { kind: "ai-gateway-key" }>;
-
- try {
- while (true) {
- const choice = await selectProvider({
- picker: input.picker,
- options: providerOptions(
- authStatus,
- selectedProvider,
- input.selectionExplicit !== false,
- input.recoverHumanAction !== undefined,
- ),
- initialValue,
- validateInlineKey: (key, validationSignal) =>
- deps.validateGatewayApiKey(
- key,
- signal === undefined ? validationSignal : AbortSignal.any([signal, validationSignal]),
- ),
- });
-
- if (choice.kind === "external") {
- if (prompter.acknowledge) {
- await prompter.acknowledge({
- message: EXTERNAL_PROVIDER_INSTRUCTIONS_TITLE,
- lines: EXTERNAL_PROVIDER_INSTRUCTIONS,
- });
- } else {
- prompter.note(
- EXTERNAL_PROVIDER_INSTRUCTIONS.join("\n"),
- EXTERNAL_PROVIDER_INSTRUCTIONS_TITLE,
- );
- }
- return { kind: "external-provider" };
- }
-
- if (choice.kind === "chatgpt") return choice;
-
- if (choice.kind === "ai-gateway-key") {
- keyChoice = choice;
- break;
- }
-
- if (
- selectedProvider !== "ai-gateway-project" &&
- availableProviders.includes("ai-gateway-project")
- ) {
- return choice;
- }
-
- while (true) {
- const auth = await withSpinner(prompter, "Checking your Vercel login…", () =>
- deps.getVercelAuthStatus(appRoot, { signal }),
- );
- signal?.throwIfAborted();
- authStatus = auth;
- if (auth === "authenticated") break;
- const actionKind =
- auth === "cli-missing"
- ? "vercel-cli-missing"
- : auth === "logged-out"
- ? "vercel-login"
- : undefined;
- if (actionKind === undefined || input.recoverHumanAction === undefined) {
- initialValue = auth === "unavailable" ? "ai-gateway-project" : "ai-gateway-key";
- break;
- }
- const recovery = await input.recoverHumanAction(
- new HumanActionRequiredError({
- kind: actionKind,
- command: auth === "cli-missing" ? "npm i -g vercel@latest" : "vercel login",
- reason:
- auth === "cli-missing"
- ? "AI Gateway via Project requires the Vercel CLI."
- : "AI Gateway via Project requires a Vercel login.",
- }),
- );
- if (recovery === "cancel") {
- initialValue = "ai-gateway-project";
- break;
- }
- }
- if (authStatus !== "authenticated") continue;
- while (true) {
- try {
- const result = await deps.runLinkFlow({
- appRoot,
- prompter,
- signal,
- projectSelection: "create-or-link",
- });
- if (result.kind === "cancelled") return result;
- return { kind: "ai-gateway-project" };
- } catch (error) {
- if (
- !(error instanceof HumanActionRequiredError) ||
- input.recoverHumanAction === undefined
- ) {
- throw error;
- }
- if ((await input.recoverHumanAction(error)) === "cancel") {
- initialValue = "ai-gateway-key";
- break;
- }
- }
- }
- }
- } catch (error) {
- if (error instanceof WizardCancelledError) return { kind: "cancelled" };
- throw error;
- }
-
- const key = keyChoice.key.trim();
- const validation = keyChoice.validation;
- signal?.throwIfAborted();
-
- if (validation.kind === "inconclusive") {
- prompter.log.warning(
- `Couldn't reach the gateway to validate (${validation.message}). Saving the key anyway.`,
- );
- }
-
- const location = await writeAiGatewayApiKey({
- projectRoot: appRoot,
- apiKey: key,
- appendEnv: deps.appendEnv,
- });
- // The env write is the commit point. A concurrent interrupt may mute the
- // remaining UI, but the caller must still refresh model access for the key
- // that is now on disk.
- prompter.log.success(`${location.envKey} set.`);
- return { kind: "ai-gateway-key" };
-}
diff --git a/packages/eve/src/setup/gateway-models.test.ts b/packages/eve/src/setup/gateway-models.test.ts
deleted file mode 100644
index 291204150..000000000
--- a/packages/eve/src/setup/gateway-models.test.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { describe, expect, it, vi } from "vitest";
-
-const mocks = vi.hoisted(() => ({ captureVercel: vi.fn() }));
-
-vi.mock("#setup/primitives/index.js", () => ({
- captureVercel: mocks.captureVercel,
-}));
-
-import { fetchGatewayModelIds } from "#setup/gateway-models.js";
-
-describe("fetchGatewayModelIds", () => {
- it("identifies eve on the Vercel-authenticated catalog request", async () => {
- mocks.captureVercel.mockResolvedValueOnce({ ok: true, stdout: '{"data":[]}' });
-
- await fetchGatewayModelIds("/tmp/app");
-
- expect(mocks.captureVercel).toHaveBeenCalledWith(
- expect.arrayContaining(["--header", expect.stringMatching(/^User-Agent: eve\/.+/)]),
- { cwd: "/tmp/app" },
- );
- });
-});
diff --git a/packages/eve/src/setup/gateway-models.ts b/packages/eve/src/setup/gateway-models.ts
deleted file mode 100644
index e5c578c64..000000000
--- a/packages/eve/src/setup/gateway-models.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { AI_GATEWAY_MODELS_URL } from "#internal/gateway.js";
-import { buildPackageUserAgent } from "#internal/user-agent.js";
-import { captureVercel } from "#setup/primitives/index.js";
-
-/**
- * Fetches the set of AI Gateway model ids, for validating a `--model` before
- * scaffolding. Routed through the (required) Vercel CLI — equivalent to:
- *
- * vercel curl https://ai-gateway.vercel.sh/v1/models -- --silent | jq -r '.data[].id'
- *
- * Returns `null` when the catalog is unreachable (no `vercel`, not logged in, or
- * a malformed response) — callers must not block creation on it.
- */
-export async function fetchGatewayModelIds(cwd: string): Promise<Set<string> | null> {
- const result = await captureVercel(
- [
- "curl",
- AI_GATEWAY_MODELS_URL,
- "--",
- "--silent",
- "--header",
- `User-Agent: ${buildPackageUserAgent()}`,
- ],
- { cwd },
- );
- if (!result.ok) return null;
- try {
- const json = JSON.parse(result.stdout) as { data?: { id?: unknown }[] };
- if (!Array.isArray(json.data)) return null;
- const ids = json.data
- .map((model) => model.id)
- .filter((id): id is string => typeof id === "string");
- return new Set(ids);
- } catch {
- return null;
- }
-}
diff --git a/packages/eve/src/setup/project-resolution.test.ts b/packages/eve/src/setup/project-resolution.test.ts
index 2ca88f196..549138e43 100644
--- a/packages/eve/src/setup/project-resolution.test.ts
+++ b/packages/eve/src/setup/project-resolution.test.ts
@@ -2,30 +2,10 @@ import { describe, expect, it } from "vitest";
import {
mergeProjectResolution,
- projectReferenceFromEnvironment,
projectResolutionFromDeployResult,
type ProjectResolution,
} from "./project-resolution.js";
-describe("projectReferenceFromEnvironment", () => {
- it("parses a complete owner and project pair", () => {
- expect(
- projectReferenceFromEnvironment({
- VERCEL_ORG_ID: "team_example",
- VERCEL_PROJECT_ID: "prj_example",
- }),
- ).toEqual({ orgId: "team_example", projectId: "prj_example" });
- });
-
- it("rejects incomplete and empty pairs", () => {
- expect(projectReferenceFromEnvironment({ VERCEL_ORG_ID: "team_example" })).toBeUndefined();
- expect(projectReferenceFromEnvironment({ VERCEL_PROJECT_ID: "prj_example" })).toBeUndefined();
- expect(
- projectReferenceFromEnvironment({ VERCEL_ORG_ID: "", VERCEL_PROJECT_ID: "prj_example" }),
- ).toBeUndefined();
- });
-});
-
describe("ProjectResolution", () => {
it("does not carry deployment metadata across project ids", () => {
const oldProject = {
diff --git a/packages/eve/src/setup/project-resolution.ts b/packages/eve/src/setup/project-resolution.ts
index f693e0bbd..f99aa56e6 100644
--- a/packages/eve/src/setup/project-resolution.ts
+++ b/packages/eve/src/setup/project-resolution.ts
@@ -1,12 +1,7 @@
import { stat } from "node:fs/promises";
import { join } from "node:path";
-import { z } from "#compiled/zod/index.js";
-import {
- readVercelProjectLink,
- type VercelProjectLink,
- VercelProjectLinkSchema,
-} from "#internal/vercel/project-link.js";
+import { readVercelProjectLink, type VercelProjectLink } from "#internal/vercel/project-link.js";
import { readVercelResourceName } from "#internal/vercel/api-resource.js";
import { captureVercel } from "./primitives/run-vercel.js";
@@ -21,26 +16,9 @@ export interface DeploymentInfo {
productionUrl?: string;
}
-const VercelProjectEnvironmentSchema = z.object({
- VERCEL_ORG_ID: VercelProjectLinkSchema.shape.orgId,
- VERCEL_PROJECT_ID: VercelProjectLinkSchema.shape.projectId,
-});
-
/** Validated Vercel owner and project identifiers. */
export type VercelProjectReference = VercelProjectLink;
-/** Parses the complete Vercel owner and project environment pair. */
-export function projectReferenceFromEnvironment(
- environment: Readonly<Record<string, string | undefined>>,
-): VercelProjectReference | undefined {
- const parsed = VercelProjectEnvironmentSchema.safeParse(environment);
- if (!parsed.success) return undefined;
- return {
- orgId: parsed.data.VERCEL_ORG_ID,
- projectId: parsed.data.VERCEL_PROJECT_ID,
- };
-}
-
/** Rejects Vercel's unsupported legacy link directory before link mutation. */
export async function assertNoLegacyProjectLinkDirectory(projectRoot: string): Promise<void> {
try {
diff --git a/packages/eve/src/setup/scaffold/channels-catalog.test.ts b/packages/eve/src/setup/scaffold/channels-catalog.test.ts
index 004db47c3..24f2f2e3b 100644
--- a/packages/eve/src/setup/scaffold/channels-catalog.test.ts
+++ b/packages/eve/src/setup/scaffold/channels-catalog.test.ts
@@ -10,35 +10,16 @@ describe("SCAFFOLDABLE_CHANNELS", () => {
.sort();
const overlaySlugs = SCAFFOLDABLE_CHANNELS.map((channel) => channel.slug).sort();
+ expect(channelEntries().some((entry) => !entry.surfaces.scaffoldable)).toBe(true);
expect(overlaySlugs).toEqual(catalogScaffoldable);
});
- test("excludes channels the catalog marks gallery-only", () => {
- const galleryOnly = channelEntries().filter((entry) => !entry.surfaces.scaffoldable);
- const overlaySlugs = new Set(SCAFFOLDABLE_CHANNELS.map((channel) => channel.slug));
-
- expect(galleryOnly.length).toBeGreaterThan(0);
- for (const entry of galleryOnly) {
- expect(overlaySlugs.has(entry.slug)).toBe(false);
- }
- });
-
- test("surfaces the catalog's `eve` web-chat channel as scaffolder kind `web`", () => {
- const eve = SCAFFOLDABLE_CHANNELS.find((channel) => channel.slug === "eve");
- expect(eve?.kind).toBe("web");
- });
-
- test("maps slack identity straight through", () => {
- const slack = SCAFFOLDABLE_CHANNELS.find((channel) => channel.slug === "slack");
- expect(slack?.kind).toBe("slack");
- });
-
test("associates scaffoldable channels with canonical registry items", () => {
- expect(SCAFFOLDABLE_CHANNELS.map(({ kind, registryItem }) => ({ kind, registryItem }))).toEqual(
- [
- { kind: "web", registryItem: "channel/web" },
- { kind: "slack", registryItem: "channel/slack" },
- ],
- );
+ expect(
+ SCAFFOLDABLE_CHANNELS.map(({ kind, registryItem, slug }) => ({ kind, registryItem, slug })),
+ ).toEqual([
+ { kind: "web", registryItem: "channel/web", slug: "eve" },
+ { kind: "slack", registryItem: "channel/slack", slug: "slack" },
+ ]);
});
});
diff --git a/packages/eve/src/setup/scaffold/connections/catalog.test.ts b/packages/eve/src/setup/scaffold/connections/catalog.test.ts
index cf18aa6b5..aa25499d9 100644
--- a/packages/eve/src/setup/scaffold/connections/catalog.test.ts
+++ b/packages/eve/src/setup/scaffold/connections/catalog.test.ts
@@ -1,15 +1,12 @@
import { describe, expect, test } from "vitest";
import {
- canonicalConnectorNameForEntry,
catalogSlugs,
CONNECTION_CATALOG,
- connectorServiceForEntry,
effectiveProtocols,
endpointForProtocol,
getCatalogEntry,
isValidConnectionSlug,
- mcpServiceHost,
SUPPORTED_PROTOCOLS,
} from "./catalog.js";
import { connectionEntries } from "@eve/catalog";
@@ -51,71 +48,14 @@ describe("catalog integrity", () => {
expect(connectionEntries().length).toBeGreaterThan(scaffoldable.length);
});
- test("every Connect entry resolves a `vercel connect create` service", () => {
- for (const entry of CONNECTION_CATALOG.filter((entry) => entry.auth.kind === "connect")) {
- expect(connectorServiceForEntry(entry)).toBeTruthy();
- expect(canonicalConnectorNameForEntry(entry)).toBeTruthy();
+ test("every Connect entry names the connector its scaffold references", () => {
+ for (const entry of CONNECTION_CATALOG) {
+ if (entry.auth.kind !== "connect") continue;
+ expect(entry.auth.connector.trim()).not.toBe("");
}
});
});
-describe("connectorServiceForEntry", () => {
- test("prefers the explicit service over the MCP endpoint", () => {
- expect(
- connectorServiceForEntry({
- mcp: { url: "https://mcp.example.com/sse" },
- auth: { kind: "connect", connector: "x", service: "explicit.example" },
- }),
- ).toBe("explicit.example");
- });
-
- test("falls back to the MCP host when no service is set", () => {
- expect(
- connectorServiceForEntry({
- mcp: { url: "https://mcp.example.com/sse" },
- auth: { kind: "connect", connector: "x" },
- }),
- ).toBe("mcp.example.com");
- });
-
- test("returns undefined for non-connect auth", () => {
- expect(
- connectorServiceForEntry({ auth: { kind: "bearer-env", envVar: "TOKEN" } }),
- ).toBeUndefined();
- });
-});
-
-describe("canonicalConnectorNameForEntry", () => {
- test("uses the configured connector name without inferring a UID namespace", () => {
- expect(canonicalConnectorNameForEntry(getCatalogEntry("notion")!)).toBe("notion");
- expect(
- canonicalConnectorNameForEntry({
- auth: { kind: "connect", connector: "custom", service: "mcp.example.com/mcp" },
- }),
- ).toBe("custom");
- });
-});
-
-describe("curated Connect services", () => {
- test("uses the provider's managed service identifier", () => {
- expect(connectorServiceForEntry(getCatalogEntry("linear")!)).toBe("mcp.linear.app");
- expect(connectorServiceForEntry(getCatalogEntry("notion")!)).toBe("mcp.notion.com");
- expect(connectorServiceForEntry(getCatalogEntry("datadog")!)).toBe("mcp.datadoghq.com");
- expect(connectorServiceForEntry(getCatalogEntry("honeycomb")!)).toBe("mcp.honeycomb.io");
- });
-});
-
-describe("mcpServiceHost", () => {
- test("extracts the host from a URL", () => {
- expect(mcpServiceHost("https://mcp.linear.app/mcp")).toBe("mcp.linear.app");
- });
-
- test("returns undefined for missing or unparseable input", () => {
- expect(mcpServiceHost(undefined)).toBeUndefined();
- expect(mcpServiceHost("not a url")).toBeUndefined();
- });
-});
-
describe("getCatalogEntry", () => {
test("resolves a known slug", () => {
expect(getCatalogEntry("linear")?.label).toBe("Linear");
diff --git a/packages/eve/src/setup/scaffold/connections/catalog.ts b/packages/eve/src/setup/scaffold/connections/catalog.ts
index 43d3b46ea..26d46cc82 100644
--- a/packages/eve/src/setup/scaffold/connections/catalog.ts
+++ b/packages/eve/src/setup/scaffold/connections/catalog.ts
@@ -191,39 +191,6 @@ export function isValidConnectionSlug(slug: string): boolean {
return CONNECTION_SLUG_PATTERN.test(slug);
}
-/**
- * The `vercel connect create <service>` identifier for a Connect-backed
- * connection: the explicit `auth.service` when set, otherwise the MCP host.
- * Returns `undefined` when neither is available, in which case the connector
- * must be provisioned out of band.
- */
-export function connectorServiceForEntry(
- entry: Pick<ConnectionCatalogEntry, "mcp" | "auth">,
-): string | undefined {
- if (entry.auth.kind !== "connect") return undefined;
- if (entry.auth.service) return entry.auth.service;
- return mcpServiceHost(entry.mcp?.url);
-}
-
-/** Canonical connector name attempted before offering discovery or creation. */
-export function canonicalConnectorNameForEntry(entry: {
- auth?: ConnectionAuthSpec;
-}): string | undefined {
- if (entry.auth?.kind !== "connect") return undefined;
- const name = entry.auth.connector.trim();
- return name.length > 0 ? name : undefined;
-}
-
-/** Extracts the bare host from an MCP URL, or `undefined` when unparseable. */
-export function mcpServiceHost(url: string | undefined): string | undefined {
- if (!url) return undefined;
- try {
- return new URL(url).host || undefined;
- } catch {
- return undefined;
- }
-}
-
/** Returns the endpoint block required for a protocol, or `null` when missing. */
export function endpointForProtocol(
entry: Pick<ConnectionCatalogEntry, "mcp" | "openapi">,
diff --git a/packages/eve/src/setup/scaffold/version-tokens.test.ts b/packages/eve/src/setup/scaffold/version-tokens.test.ts
index 2f2b981a7..f373eb458 100644
--- a/packages/eve/src/setup/scaffold/version-tokens.test.ts
+++ b/packages/eve/src/setup/scaffold/version-tokens.test.ts
@@ -3,11 +3,7 @@ import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
-import {
- DEFAULT_CONNECT_PACKAGE_VERSION,
- DEFAULT_MICROSANDBOX_PACKAGE_VERSION,
- resolveVersionToken,
-} from "./version-tokens.js";
+import { resolveVersionToken } from "./version-tokens.js";
// These tests always execute from the dev tree (vitest runs over src), so the
// fallback's sources — eve's package.json and the workspace catalog — are the
@@ -20,13 +16,6 @@ describe("resolveVersionToken", () => {
expect(resolveVersionToken("evePackage.version", "1.0.0-beta.3")).toBe("1.0.0-beta.3");
});
- it("uses concrete production integration dependency versions", () => {
- expect(DEFAULT_CONNECT_PACKAGE_VERSION).toBe("2.2.0");
- expect(DEFAULT_CONNECT_PACKAGE_VERSION).not.toMatch(/^__/);
- expect(DEFAULT_MICROSANDBOX_PACKAGE_VERSION).toBe("0.5.5");
- expect(DEFAULT_MICROSANDBOX_PACKAGE_VERSION).not.toMatch(/^__/);
- });
-
it("resolves eve runtime and dependency version tokens from eve's own package.json", () => {
const runtimeVersion = resolveVersionToken(
"evePackage.runtimeVersion",
diff --git a/packages/eve/src/setup/vercel-api-failure.test.ts b/packages/eve/src/setup/vercel-api-failure.test.ts
index cb4a9ceb9..9d97a9fe0 100644
--- a/packages/eve/src/setup/vercel-api-failure.test.ts
+++ b/packages/eve/src/setup/vercel-api-failure.test.ts
@@ -3,7 +3,6 @@ import { describe, expect, it } from "vitest";
import type { VercelCaptureFailure } from "#setup/primitives/index.js";
import {
- isConflictApiFailure,
isForbiddenApiFailure,
isNotFoundApiFailure,
normalizeVercelApiResult,
@@ -24,9 +23,6 @@ describe("Vercel API failure classification", () => {
expect(
isNotFoundApiFailure(failure({ stdout: JSON.stringify({ error: { code: "not_found" } }) })),
).toBe(true);
- expect(
- isConflictApiFailure(failure({ stdout: JSON.stringify({ error: { code: "conflict" } }) })),
- ).toBe(true);
expect(
isForbiddenApiFailure(failure({ stdout: JSON.stringify({ error: { code: "forbidden" } }) })),
).toBe(true);
@@ -51,11 +47,8 @@ describe("Vercel API failure classification", () => {
expect(isForbiddenApiFailure(result.failure)).toBe(true);
});
- it("classifies the Vercel CLI's stderr-only resource errors", () => {
+ it("classifies the Vercel CLI's stderr-only not-found errors", () => {
expect(isNotFoundApiFailure(failure({ stderr: "Error: Project not found. (404)" }))).toBe(true);
- expect(isConflictApiFailure(failure({ stderr: "Error: Project already exists. (409)" }))).toBe(
- true,
- );
});
it("does not infer an HTTP status from the process exit code or command text", () => {
@@ -65,7 +58,6 @@ describe("Vercel API failure classification", () => {
});
expect(isNotFoundApiFailure(operational)).toBe(false);
- expect(isConflictApiFailure(operational)).toBe(false);
expect(isForbiddenApiFailure(operational)).toBe(false);
expect(isForbiddenApiFailure(failure({ stderr: "Project association failed." }))).toBe(false);
});
diff --git a/packages/eve/src/setup/vercel-api-failure.ts b/packages/eve/src/setup/vercel-api-failure.ts
index 5a4f76bb7..150e95df1 100644
--- a/packages/eve/src/setup/vercel-api-failure.ts
+++ b/packages/eve/src/setup/vercel-api-failure.ts
@@ -46,11 +46,6 @@ export function isNotFoundApiFailure(failure: VercelCaptureFailure): boolean {
return /(^|\W)(404|not_found)(\W|$)|not found/.test(apiFailureText(failure));
}
-/** Whether a Vercel API failure proves that the requested resource already exists. */
-export function isConflictApiFailure(failure: VercelCaptureFailure): boolean {
- return /(^|\W)(409|conflict)(\W|$)|already exists/.test(apiFailureText(failure));
-}
-
/** Whether a scoped Vercel API request was denied. */
export function isForbiddenApiFailure(failure: VercelCaptureFailure): boolean {
return /(^|\W)(403|forbidden|not_authorized|team_unauthorized|sso|saml)(\W|$)|not authorized/.test(
diff --git a/packages/eve/src/setup/vercel-project.test.ts b/packages/eve/src/setup/vercel-project.test.ts
index 9be5f1b0d..9c5d56144 100644
--- a/packages/eve/src/setup/vercel-project.test.ts
+++ b/packages/eve/src/setup/vercel-project.test.ts
@@ -10,7 +10,6 @@ import { readProjectLink } from "./project-resolution.js";
import { configureTraceSampling } from "./vercel-trace-sampling.js";
import {
assertNewProjectNameAvailable,
- ensureLinkedVercelProject,
getVercelAuthStatus,
linkProject,
pickNewProjectName,
@@ -19,7 +18,6 @@ import {
requireAuth,
resolveProjectByNameOrId,
validateTeam,
- vercelAuthBlockerReason,
} from "./vercel-project.js";
vi.mock("#setup/primitives/index.js", async (importOriginal) => {
@@ -79,22 +77,6 @@ beforeEach(() => {
mockedReadProjectLink.mockReset();
});
-describe("vercelAuthBlockerReason", () => {
- it("maps non-authenticated states to their setup blockers", () => {
- expect([
- vercelAuthBlockerReason("authenticated"),
- vercelAuthBlockerReason("cli-missing"),
- vercelAuthBlockerReason("logged-out"),
- vercelAuthBlockerReason("unavailable"),
- ]).toEqual([
- undefined,
- "Vercel CLI not found, see /deploy",
- "Log in to Vercel first, see /deploy",
- "Couldn't reach Vercel, check your connection",
- ]);
- });
-});
-
describe("getVercelAuthStatus", () => {
it("reports authenticated when whoami succeeds", async () => {
mockedReadProjectLink.mockResolvedValueOnce(undefined);
@@ -596,47 +578,6 @@ describe("resolveProjectByNameOrId", () => {
});
});
-describe("ensureLinkedVercelProject", () => {
- it("returns the existing project link without invoking the CLI", async () => {
- mockedReadProjectLink.mockResolvedValue({ orgId: "team_a", projectId: "prj_a" });
- const { prompter } = createFakePrompter();
-
- await expect(
- ensureLinkedVercelProject({ projectRoot: "/tmp/eve-agent", prompter }),
- ).resolves.toEqual({ orgId: "team_a", projectId: "prj_a" });
-
- expect(mockedRunVercel).not.toHaveBeenCalled();
- });
-
- it("links interactively and reads the resulting project link", async () => {
- mockedReadProjectLink
- .mockResolvedValueOnce(undefined)
- .mockResolvedValueOnce({ orgId: "team_a", projectId: "prj_a" });
- const { prompter } = createFakePrompter();
- prompter.withInheritedStdio = vi.fn((task) => task());
-
- await expect(
- ensureLinkedVercelProject({ projectRoot: "/tmp/eve-agent", prompter }),
- ).resolves.toEqual({ orgId: "team_a", projectId: "prj_a" });
-
- expect(prompter.withInheritedStdio).toHaveBeenCalledOnce();
- expect(mockedRunVercel).toHaveBeenCalledWith(["link"], {
- cwd: "/tmp/eve-agent",
- signal: undefined,
- });
- });
-
- it("fails when the interactive link does not complete", async () => {
- mockedReadProjectLink.mockResolvedValue(undefined);
- mockedRunVercel.mockResolvedValue(false);
- const { prompter } = createFakePrompter();
-
- await expect(
- ensureLinkedVercelProject({ projectRoot: "/tmp/eve-agent", prompter }),
- ).rejects.toThrow("Vercel project linking failed.");
- });
-});
-
describe("linkProject", () => {
it("links a resolved existing project through `vercel link`", async () => {
const { prompter } = createFakePrompter();
diff --git a/packages/eve/src/setup/vercel-project.ts b/packages/eve/src/setup/vercel-project.ts
index bdd4f427e..ef413545b 100644
--- a/packages/eve/src/setup/vercel-project.ts
+++ b/packages/eve/src/setup/vercel-project.ts
@@ -60,46 +60,10 @@ export interface LinkProjectOperationOptions extends CreatedProjectFrameworkOpti
traceSampling?: boolean;
}
-/** Effects used to ensure an interactive Vercel project link. */
-export interface EnsureLinkedVercelProjectDeps {
- readProjectLink: typeof readProjectLink;
- runVercel: typeof runVercel;
-}
-
-/**
- * Returns the existing Vercel project link or creates one through the Vercel
- * CLI's interactive flow. The CLI owns team and project selection.
- */
-export async function ensureLinkedVercelProject(input: {
- projectRoot: string;
- prompter: Prompter;
- signal?: AbortSignal;
- deps?: EnsureLinkedVercelProjectDeps;
-}): Promise<NonNullable<Awaited<ReturnType<typeof readProjectLink>>>> {
- const deps = input.deps ?? { readProjectLink, runVercel };
- const existing = await deps.readProjectLink(input.projectRoot);
- if (existing !== undefined) return existing;
-
- const link = () => deps.runVercel(["link"], { cwd: input.projectRoot, signal: input.signal });
- const linked = await (input.prompter.withInheritedStdio?.(link) ?? link());
- if (!linked) {
- input.signal?.throwIfAborted();
- throw new Error("Vercel project linking failed.");
- }
- const project = await deps.readProjectLink(input.projectRoot);
- if (project === undefined) throw new Error("Vercel project linking failed.");
- return project;
-}
-
export function unresolvedProject(): ProjectResolution {
return { kind: "unresolved" };
}
-/** Resolves the linked project id from a resolution, if any. */
-export function projectIdFromResolution(project: ProjectResolution): string | undefined {
- return project.kind === "unresolved" ? undefined : project.projectId;
-}
-
function parseProjectReference(stdout: string, description: string): VercelProjectIdentity {
const parsed = VercelProjectReferenceSchema.safeParse(parseVercelJson(stdout, description));
if (!parsed.success) {
@@ -241,24 +205,6 @@ export function requireVercelAuth(failure: VercelCaptureFailure): never {
*/
export type VercelAuthStatus = "authenticated" | "logged-out" | "cli-missing" | "unavailable";
-/** Returns the user-facing reason Vercel-backed setup is unavailable. */
-export function vercelAuthBlockerReason(authStatus: VercelAuthStatus): string | undefined {
- switch (authStatus) {
- case "authenticated":
- return undefined;
- case "cli-missing":
- return "Vercel CLI not found, see /deploy";
- case "logged-out":
- return "Log in to Vercel first, see /deploy";
- case "unavailable":
- return "Couldn't reach Vercel, check your connection";
- default: {
- const exhaustive: never = authStatus;
- return exhaustive;
- }
- }
-}
-
export async function getVercelAuthStatus(
projectRoot: string,
options: VercelProjectOperationOptions = {},
diff --git a/packages/eve/src/shared/skill-paths.test.ts b/packages/eve/src/shared/skill-paths.test.ts
index 3ba456cf7..956c437db 100644
--- a/packages/eve/src/shared/skill-paths.test.ts
+++ b/packages/eve/src/shared/skill-paths.test.ts
@@ -4,25 +4,13 @@ import { mockSandbox } from "#internal/testing/mocks/mock-sandbox.js";
import {
FALLBACK_SKILL_ROOT,
MODEL_SKILL_ROOT,
- formatFallbackSkillPath,
- formatSkillModelPath,
resolveSandboxModelPath,
- resolveSandboxSkillReadPaths,
resolveSandboxSkillRoot,
} from "#shared/skill-paths.js";
const HOME_PROBE_COMMAND = `printf '%s\\n' "$HOME"`;
describe("skill path helpers", () => {
- it("formats model-facing and fallback skill paths", () => {
- expect(formatSkillModelPath({ name: "research", relativePath: "SKILL.md" })).toBe(
- `${MODEL_SKILL_ROOT}/research/SKILL.md`,
- );
- expect(formatFallbackSkillPath({ name: "research", relativePath: "SKILL.md" })).toBe(
- `${FALLBACK_SKILL_ROOT}/research/SKILL.md`,
- );
- });
-
it("resolves the sandbox skill root from HOME", async () => {
const sandbox = mockSandbox({
commands: {
@@ -85,38 +73,6 @@ describe("skill path helpers", () => {
).resolves.toBe("/workspace/skills/research/references/catalog.md");
});
- it("reads only from the resolved HOME skill root when HOME is usable", async () => {
- const sandbox = mockSandbox({
- commands: {
- [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "/home/agent\n" },
- },
- });
-
- await expect(
- resolveSandboxSkillReadPaths({
- name: "research",
- relativePath: "SKILL.md",
- sandbox: sandbox.session,
- }),
- ).resolves.toEqual(["/home/agent/.agents/skills/research/SKILL.md"]);
- });
-
- it("reads from /workspace/skills only when that root is selected", async () => {
- const sandbox = mockSandbox({
- commands: {
- [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "\n" },
- },
- });
-
- await expect(
- resolveSandboxSkillReadPaths({
- name: "research",
- relativePath: "SKILL.md",
- sandbox: sandbox.session,
- }),
- ).resolves.toEqual(["/workspace/skills/research/SKILL.md"]);
- });
-
it("resolves model-facing seed paths before writing to the sandbox", async () => {
const sandbox = mockSandbox({
commands: {
diff --git a/packages/eve/src/shared/skill-paths.ts b/packages/eve/src/shared/skill-paths.ts
index f4486e5b9..46dc386dd 100644
--- a/packages/eve/src/shared/skill-paths.ts
+++ b/packages/eve/src/shared/skill-paths.ts
@@ -8,28 +8,6 @@ export const FALLBACK_SKILL_ROOT = "/workspace/skills";
const HOME_PROBE_COMMAND = `printf '%s\\n' "$HOME"`;
const sandboxHomeCache = new WeakMap<SandboxSession, Promise<string | null>>();
-export function formatSkillModelPath(input: {
- readonly name: string;
- readonly relativePath: string;
-}): string {
- return formatSkillPath({
- name: input.name,
- relativePath: input.relativePath,
- root: MODEL_SKILL_ROOT,
- });
-}
-
-export function formatFallbackSkillPath(input: {
- readonly name: string;
- readonly relativePath: string;
-}): string {
- return formatSkillPath({
- name: input.name,
- relativePath: input.relativePath,
- root: FALLBACK_SKILL_ROOT,
- });
-}
-
/**
* Resolves where skills live in the sandbox: under the probed home when it has
* one, and under {@link FALLBACK_SKILL_ROOT} when it does not.
@@ -67,20 +45,6 @@ export async function resolveSandboxModelPath(input: {
return input.path;
}
-export async function resolveSandboxSkillReadPaths(input: {
- readonly name: string;
- readonly relativePath: string;
- readonly sandbox: SandboxSession;
-}): Promise<readonly string[]> {
- return [
- formatSkillPath({
- name: input.name,
- relativePath: input.relativePath,
- root: await resolveSandboxSkillRoot({ sandbox: input.sandbox }),
- }),
- ];
-}
-
export async function resolveSandboxSkillWritePath(input: {
readonly name: string;
readonly relativePath: string;
diff --git a/packages/eve/src/tracing/agent-trace-context-store.test.ts b/packages/eve/src/tracing/agent-trace-context-store.test.ts
index 3afc685a0..e52d40915 100644
--- a/packages/eve/src/tracing/agent-trace-context-store.test.ts
+++ b/packages/eve/src/tracing/agent-trace-context-store.test.ts
@@ -9,7 +9,6 @@ import {
ContextAgentTraceStateStore,
preserveSerializedAgentTraceState,
readActionTraceContext,
- readCurrentSessionTraceDecision,
readTurnTraceContext,
} from "#tracing/agent-trace-context-store.js";
@@ -247,21 +246,6 @@ describe("readTurnTraceContext", () => {
});
});
-describe("readCurrentSessionTraceDecision", () => {
- it("reads the decision bound in the current worker context", async () => {
- const context = new ContextContainer();
- const decision = { action: "record", recordInputs: false, recordOutputs: true } as const;
- await contextStorage.run(context, () => {
- new ContextAgentTraceStateStore().setSession("session-1", {
- context: spanContext("1", "2"),
- decision,
- rootSessionId: "session-1",
- });
- expect(readCurrentSessionTraceDecision("session-1")).toEqual(decision);
- });
- });
-});
-
describe("readActionTraceContext", () => {
it("reads the invoking action span out of a serialized context", async () => {
const context = new ContextContainer();
diff --git a/packages/eve/src/tracing/agent-trace-context-store.ts b/packages/eve/src/tracing/agent-trace-context-store.ts
index d974fe435..1a274496b 100644
--- a/packages/eve/src/tracing/agent-trace-context-store.ts
+++ b/packages/eve/src/tracing/agent-trace-context-store.ts
@@ -98,14 +98,6 @@ function pruneTraceOwnership(
context.set(AgentTraceContextKey, { ...state, actionAnchors, invocations });
}
-/** Reads the decision already bound to a session in the current worker context. */
-export function readCurrentSessionTraceDecision(
- sessionId: string,
-): InstrumentationDecision | undefined {
- const context = contextStorage.getStore();
- return context === undefined ? undefined : readSessionTraceDecision(context, sessionId);
-}
-
export function readSessionTraceDecision(
context: ContextAccessor,
sessionId: string,
diff --git a/packages/eve/src/vue/use-eve-agent.test.ts b/packages/eve/src/vue/use-eve-agent.test.ts
index 13538a9f3..11e44e958 100644
--- a/packages/eve/src/vue/use-eve-agent.test.ts
+++ b/packages/eve/src/vue/use-eve-agent.test.ts
@@ -1,11 +1,6 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { effectScope } from "vue";
-import {
- detachEveAgentStore,
- EveAgentStore,
- type EveAgentStoreSnapshot,
-} from "#client/eve-agent-store.js";
import { useEveAgent } from "#vue/use-eve-agent.js";
import type { EveMessageData } from "#client/message-reducer.js";
import {
@@ -16,13 +11,10 @@ import {
import {
createMessageCompletedEvent,
createMessageReceivedEvent,
- createSessionFailedEvent,
createSessionWaitingEvent,
type UnstampedMessageStreamEvent,
} from "#protocol/message.js";
import { stampTestEvents } from "#internal/testing/events.js";
-import { defaultMessageReducer } from "#client/message-reducer.js";
-import type { ClientSessionState } from "#client/types.js";
function createStartedMessageResponse(sessionId: string, continuationToken: string): Response {
return new Response(JSON.stringify({ continuationToken, ok: true, sessionId }), {
@@ -111,251 +103,11 @@ function completedTurnData(input: {
};
}
-const cleanupStores: Array<() => void> = [];
-function createStore<TData>(
- init: ConstructorParameters<typeof EveAgentStore<TData>>[0],
-): EveAgentStore<TData> {
- const store = new EveAgentStore<TData>(init);
- cleanupStores.push(() => detachEveAgentStore(store));
- return store;
-}
-
afterEach(() => {
- for (const cleanup of cleanupStores.splice(0)) cleanup();
vi.restoreAllMocks();
vi.unstubAllGlobals();
});
-describe("EveAgentStore (Vue composable backing store)", () => {
- it("starts in ready status with empty data", () => {
- const store = createStore({
- reducer: defaultMessageReducer(),
- });
-
- expect(store.snapshot.status).toBe("ready");
- expect(store.snapshot.data.messages).toEqual([]);
- expect(store.snapshot.error).toBeUndefined();
- expect(store.snapshot.events).toEqual([]);
- });
-
- it("notifies subscribers on state changes", async () => {
- const store = createStore({
- reducer: defaultMessageReducer(),
- });
-
- const snapshots: EveAgentStoreSnapshot<EveMessageData>[] = [];
- store.subscribe(() => {
- snapshots.push(store.snapshot);
- });
-
- vi.spyOn(globalThis, "fetch").mockRejectedValueOnce(new Error("Network failed"));
-
- await store.send({ message: "Hello" });
-
- expect(snapshots.length).toBeGreaterThan(0);
- expect(snapshots.at(-1)?.status).toBe("error");
- });
-
- it("sends a message and projects streamed events", async () => {
- const events = [
- createMessageReceivedEvent({
- message: "Hello",
- sequence: 0,
- turnId: "turn_1",
- }),
- createMessageCompletedEvent({
- message: "Hi there.",
- sequence: 1,
- stepIndex: 0,
- turnId: "turn_1",
- }),
- createSessionWaitingEvent(),
- ];
-
- const startResponse = createDeferred<Response>();
- vi.spyOn(globalThis, "fetch")
- .mockReturnValueOnce(startResponse.promise)
- .mockResolvedValueOnce(createEagerStreamResponse(events));
-
- const store = createStore({
- reducer: defaultMessageReducer(),
- });
-
- const seenEvents: UnstampedMessageStreamEvent[] = [];
- const seenSessions: Array<ClientSessionState | undefined> = [];
- store.setCallbacks({
- onEvent(event) {
- seenEvents.push(event);
- },
- onSessionChange(session) {
- seenSessions.push(session);
- },
- });
-
- const sendPromise = store.send({ message: "Hello" });
- await Promise.resolve();
-
- expect(store.snapshot.status).toBe("submitted");
- expect(store.snapshot.data).toEqual({
- messages: [
- {
- id: expect.stringMatching(/^optimistic:/),
- metadata: { optimistic: true, status: "submitted" },
- parts: [{ text: "Hello", type: "text" }],
- role: "user",
- },
- ],
- });
-
- startResponse.resolve(createStartedMessageResponse("session_1", "http:session_1"));
- await sendPromise;
-
- expect(seenEvents).toEqual(stampTestEvents(events));
- expect(store.snapshot.status).toBe("ready");
- expect(store.snapshot.data).toEqual(
- completedTurnData({
- assistantMessage: "Hi there.",
- turnId: "turn_1",
- userMessage: "Hello",
- }),
- );
- expect(seenSessions.map((session) => session?.streamIndex)).toEqual([0, 1, 2, 3, 3]);
- });
-
- it("surfaces transport errors", async () => {
- vi.spyOn(globalThis, "fetch").mockRejectedValueOnce(new Error("Network failed"));
-
- const store = createStore({
- reducer: defaultMessageReducer(),
- });
-
- const seenErrors: Error[] = [];
- store.setCallbacks({
- onError(error) {
- seenErrors.push(error);
- },
- });
-
- await store.send({ message: "Hello" });
-
- expect(seenErrors.map((e) => e.message)).toEqual(["Network failed"]);
- expect(store.snapshot.status).toBe("error");
- expect(store.snapshot.error?.message).toBe("Network failed");
- });
-
- it("surfaces terminal stream failures as store errors", async () => {
- const events = [
- createMessageReceivedEvent({
- message: "Hello",
- sequence: 0,
- turnId: "turn_1",
- }),
- createSessionFailedEvent({
- code: "MODEL_CALL_FAILED",
- message: "Bad Request",
- sessionId: "session_1",
- }),
- ];
-
- const startResponse = createDeferred<Response>();
- vi.spyOn(globalThis, "fetch")
- .mockReturnValueOnce(startResponse.promise)
- .mockResolvedValueOnce(createEagerStreamResponse(events));
-
- const store = createStore({
- reducer: defaultMessageReducer(),
- });
-
- const seenErrors: Error[] = [];
- store.setCallbacks({
- onError(error) {
- seenErrors.push(error);
- },
- });
-
- const sendPromise = store.send({ message: "Hello" });
- startResponse.resolve(createStartedMessageResponse("session_1", "http:session_1"));
- await sendPromise;
-
- expect(seenErrors.map((e) => e.message)).toEqual(["Bad Request"]);
- expect(store.snapshot.status).toBe("error");
- expect(store.snapshot.error?.message).toBe("Bad Request");
- });
-
- it("resets state and creates a new session", async () => {
- vi.spyOn(globalThis, "fetch").mockRejectedValueOnce(new Error("fail"));
-
- const store = createStore({
- reducer: defaultMessageReducer(),
- });
-
- await store.send({ message: "Hello" });
- expect(store.snapshot.status).toBe("error");
-
- store.reset();
- expect(store.snapshot.status).toBe("ready");
- expect(store.snapshot.data.messages).toEqual([]);
- expect(store.snapshot.error).toBeUndefined();
- expect(store.snapshot.events).toEqual([]);
- });
-
- it("unsubscribe removes the listener", () => {
- const store = createStore({
- reducer: defaultMessageReducer(),
- });
-
- let callCount = 0;
- const unsub = store.subscribe(() => {
- callCount += 1;
- });
-
- store.reset();
- expect(callCount).toBe(1);
-
- unsub();
- store.reset();
- expect(callCount).toBe(1);
- });
-
- it("projects input responses before the resumed stream returns", async () => {
- const startResponse = createDeferred<Response>();
- vi.spyOn(globalThis, "fetch").mockImplementation(async (_request, init) =>
- init?.method === "POST"
- ? await startResponse.promise
- : createEagerStreamResponse([createSessionWaitingEvent()]),
- );
-
- const store = createStore<readonly string[]>({
- initialSession: {
- sessionId: "session_1",
- streamIndex: 0,
- },
- reducer: {
- initial() {
- return [];
- },
- reduce(data, event) {
- return [...data, event.type];
- },
- },
- });
-
- const sendPromise = store.send({
- inputResponses: [{ optionId: "cancel", requestId: "approval_1" }],
- });
- await Promise.resolve();
-
- expect(store.snapshot.status).toBe("submitted");
- expect(store.snapshot.data).toEqual(["client.input.responded"]);
-
- startResponse.resolve(createStartedMessageResponse("session_1", "http:session_1"));
- await sendPromise;
-
- expect(store.snapshot.status).toBe("ready");
- expect(store.snapshot.data).toEqual(["client.input.responded", "session.waiting"]);
- });
-});
-
describe("useEveAgent (Vue composable wiring)", () => {
it("automatically replays an initial session when resume is enabled", async () => {
vi.stubGlobal("window", {});
diff --git a/packages/eve/test/client.test.ts b/packages/eve/test/client.test.ts
index a796e8e46..e8e4b00fd 100644
--- a/packages/eve/test/client.test.ts
+++ b/packages/eve/test/client.test.ts
@@ -194,49 +194,6 @@ describe("Client.health", () => {
expect(headers.get("authorization")).toBe("Bearer my-token");
});
- it("resolves bearer auth via callback on each request", async () => {
- let callCount = 0;
- const fetchMock = vi
- .spyOn(globalThis, "fetch")
- .mockImplementation(() =>
- Promise.resolve(Response.json({ ok: true, status: "ready", workflowId: "wf_001" })),
- );
-
- const client = new Client({
- auth: {
- bearer: () => {
- callCount += 1;
- return `token_${callCount}`;
- },
- },
- host: "http://localhost:3000",
- });
-
- await client.health();
- await client.health();
-
- const firstHeaders = new Headers(fetchMock.mock.calls[0]?.[1]?.headers);
- const secondHeaders = new Headers(fetchMock.mock.calls[1]?.[1]?.headers);
- expect(firstHeaders.get("authorization")).toBe("Bearer token_1");
- expect(secondHeaders.get("authorization")).toBe("Bearer token_2");
- expect(callCount).toBe(2);
- });
-
- it("sends basic auth header", async () => {
- const fetchMock = vi
- .spyOn(globalThis, "fetch")
- .mockResolvedValueOnce(Response.json({ ok: true, status: "ready", workflowId: "wf_001" }));
-
- const client = new Client({
- auth: { basic: { password: "secret", username: "admin" } },
- host: "http://localhost:3000",
- });
- await client.health();
-
- const headers = new Headers(fetchMock.mock.calls[0]?.[1]?.headers);
- expect(headers.get("authorization")).toBe(`Basic ${btoa("admin:secret")}`);
- });
-
it("sends custom headers", async () => {
const fetchMock = vi
.spyOn(globalThis, "fetch")
diff --git a/packages/eve/test/discover-diagnostics.test.ts b/packages/eve/test/discover-diagnostics.test.ts
index d60da6508..5f122cffe 100644
--- a/packages/eve/test/discover-diagnostics.test.ts
+++ b/packages/eve/test/discover-diagnostics.test.ts
@@ -3,7 +3,6 @@ import { describe, expect, it } from "vitest";
import {
createDiscoverErrorDiagnostic,
createDiscoverWarningDiagnostic,
- hasDiscoverErrors,
summarizeDiscoverDiagnostics,
} from "../src/discover/diagnostics.js";
@@ -47,6 +46,5 @@ describe("discovery diagnostics", () => {
errors: 1,
warnings: 2,
});
- expect(hasDiscoverErrors(diagnostics)).toBe(true);
});
});
diff --git a/packages/eve/test/eve-run-stream-channel.test.ts b/packages/eve/test/eve-run-stream-channel.test.ts
deleted file mode 100644
index 69178219e..000000000
--- a/packages/eve/test/eve-run-stream-channel.test.ts
+++ /dev/null
@@ -1,213 +0,0 @@
-import { describe, expect, it, vi } from "vitest";
-
-import type { MessageStreamEvent } from "../src/protocol/message.js";
-import { stampTestEvents } from "../src/internal/testing/events.js";
-import { mockChannelContext } from "../src/internal/testing/mocks/mock-channel-operations.js";
-import type { AttachSessionFn, RouteHandlerArgs } from "../src/channel/routes.js";
-import type { Session } from "../src/channel/session.js";
-import { EVE_SESSION_STREAM_ROUTE_PATTERN } from "../src/protocol/routes.js";
-import { none } from "../src/public/channels/auth.js";
-import { eveChannel } from "../src/public/channels/eve.js";
-
-/**
- * Regression coverage for the bug introduced when the stream route
- * stopped forwarding the `startIndex` query parameter to
- * `agent.getEventStream`.
- *
- * Without the fix, every reconnect or follow-up turn replays the run
- * from index 0 — the dev REPL would render the first turn's events on
- * every subsequent message because `Session.#createEventStream` cuts off
- * at the first `session.waiting` boundary it sees.
- */
-
-function createGetHandler() {
- const channel = eveChannel({ auth: none() });
- const getRoute = channel.routes.find(
- (r) => r.method === "GET" && r.path === EVE_SESSION_STREAM_ROUTE_PATTERN,
- );
- if (!getRoute) throw new Error("No stream GET route found");
- return getRoute;
-}
-
-describe("eveChannel GET stream", () => {
- it("forwards the startIndex query parameter into attachSession/getEventStream", async () => {
- const getRoute = createGetHandler();
- const events = createEvents(
- stampTestEvents([
- {
- type: "message.completed",
- data: {
- finishReason: "stop",
- message: "second turn reply",
- sequence: 0,
- stepIndex: 0,
- turnId: "turn-1",
- },
- },
- ]),
- );
- const attachSession = createMockAttachSession(events);
-
- const response = await (getRoute as any).handler(
- new Request("https://example.com/eve/v1/session/session_xyz/stream?startIndex=42", {
- method: "GET",
- }),
- createArgs({ attachSession, params: { sessionId: "session_xyz" } }),
- );
-
- expect(response.status).toBe(200);
- expect(attachSession).toHaveBeenCalledTimes(1);
- expect(attachSession.mock.calls[0]?.[0]).toBe("session_xyz");
- });
-
- it("passes startIndex undefined when the query parameter is absent", async () => {
- const getRoute = createGetHandler();
- const attachSession = createMockAttachSession(createEvents([]));
-
- const response = await (getRoute as any).handler(
- new Request("https://example.com/eve/v1/session/session_xyz/stream", {
- method: "GET",
- }),
- createArgs({ attachSession, params: { sessionId: "session_xyz" } }),
- );
-
- expect(response.status).toBe(200);
- expect(attachSession).toHaveBeenCalledTimes(1);
- });
-
- it("accepts negative tail-relative startIndex values", async () => {
- const getRoute = createGetHandler();
- const attachSession = createMockAttachSession(createEvents([]));
-
- const response = await (getRoute as any).handler(
- new Request("https://example.com/eve/v1/session/session_xyz/stream?startIndex=-3", {
- method: "GET",
- }),
- createArgs({ attachSession, params: { sessionId: "session_xyz" } }),
- );
-
- expect(response.status).toBe(200);
- expect(attachSession).toHaveBeenCalledTimes(1);
- });
-
- it("rejects non-integer startIndex values with 400", async () => {
- const getRoute = createGetHandler();
- const attachSession = createMockAttachSession(createEvents([]));
-
- const response = await (getRoute as any).handler(
- new Request("https://example.com/eve/v1/session/session_xyz/stream?startIndex=banana", {
- method: "GET",
- }),
- createArgs({ attachSession, params: { sessionId: "session_xyz" } }),
- );
-
- expect(response.status).toBe(400);
- expect(attachSession).toHaveBeenCalledWith("session_xyz");
- });
-
- it("returns 400 when the sessionId path parameter is missing", async () => {
- const getRoute = createGetHandler();
- const attachSession = createMockAttachSession(createEvents([]));
-
- const response = await (getRoute as any).handler(
- new Request("https://example.com/eve/v1/session//stream", { method: "GET" }),
- createArgs({ attachSession, params: {} }),
- );
-
- expect(response.status).toBe(400);
- expect(attachSession).not.toHaveBeenCalled();
- });
-
- it("re-serializes the parsed event stream as NDJSON bytes", async () => {
- const getRoute = createGetHandler();
- const events = stampTestEvents([
- {
- type: "message.completed",
- data: {
- finishReason: "stop",
- message: "hello",
- sequence: 0,
- stepIndex: 0,
- turnId: "turn-1",
- },
- },
- {
- type: "session.waiting",
- data: { continuationToken: "session-id", wait: "next-user-message" },
- },
- ]);
- const attachSession = createMockAttachSession(createEvents(events));
-
- const response = await (getRoute as any).handler(
- new Request("https://example.com/eve/v1/session/session_xyz/stream", {
- method: "GET",
- }),
- createArgs({ attachSession, params: { sessionId: "session_xyz" } }),
- );
-
- expect(response.status).toBe(200);
- const text = await response.text();
- const lines = text.trim().split("\n");
- expect(lines).toHaveLength(2);
- const [firstLine, secondLine] = lines;
- expect(firstLine).toBeDefined();
- expect(secondLine).toBeDefined();
- expect(JSON.parse(firstLine ?? "")).toMatchObject({ type: "message.completed" });
- expect(JSON.parse(secondLine ?? "")).toMatchObject({ type: "session.waiting" });
- });
-});
-
-function createEvents(events: readonly MessageStreamEvent[]): ReadableStream<MessageStreamEvent> {
- return new ReadableStream<MessageStreamEvent>({
- start(controller) {
- for (const event of events) {
- controller.enqueue(event);
- }
- controller.close();
- },
- });
-}
-
-function createMockAttachSession(events: ReadableStream<MessageStreamEvent>) {
- return vi.fn<AttachSessionFn>().mockReturnValue({
- id: "session_xyz",
- async send() {
- return { sessionId: "session_xyz", status: "accepted" };
- },
- async respond() {
- return { sessionId: "session_xyz", status: "accepted" };
- },
- async cancel() {
- return { status: "no_active_turn" };
- },
- async compact() {
- return { sessionId: "session_xyz", status: "accepted" };
- },
- async clear() {
- return { sessionId: "session_xyz", status: "accepted" };
- },
- async reset() {
- return { previousSessionId: "session_xyz", status: "reset" };
- },
- async getEventStream() {
- return events;
- },
- async getStreamTailIndex() {
- return -1;
- },
- } satisfies Session);
-}
-
-function createArgs(input: {
- readonly attachSession: AttachSessionFn;
- readonly params: Readonly<Record<string, string>>;
-}): RouteHandlerArgs {
- return {
- ...mockChannelContext(vi.fn()),
- attachSession: input.attachSession,
- to: vi.fn() as any,
- params: input.params,
- waitUntil: () => undefined,
- requestIp: "127.0.0.1",
- };
-}