From f14cb7d91ee832c6d28b272e37f08bfd91bc2323 Mon Sep 17 00:00:00 2001
From: Colton Padden
Date: Fri, 20 Nov 2026 14:14:53 -0500
Subject: [PATCH] chore(deps): sync eve and pnpm versions
Signed-off-by: Colton Padden
---
.github/workflows/check.yml | 2 -
README.md | 2 +-
agent/connections/notion.ts | 52 +-
agent/extensions/link/lib/spend-requests.ts | 4 +-
agent/hooks/browser-lifecycle.ts | 4 +-
agent/hooks/task-state.ts | 38 +-
agent/lib/browser-runtime.ts | 6 +-
agent/lib/linq.ts | 8 +-
agent/lib/task-state.ts | 43 +-
app/chat.tsx | 72 +-
app/projection.ts | 36 +-
docs/repository.md | 11 +-
package.json | 18 +-
pnpm-lock.yaml | 874 +++++++++++++-------
pnpm-workspace.yaml | 10 +
scripts/test-parallel-research.mjs | 20 +-
scripts/test-session-retirement.mjs | 41 +-
tests/browser/browser-close.test.ts | 18 +-
tests/browser/captcha-recovery.test.ts | 12 +-
tests/browser/captcha-state.test.ts | 4 +-
tests/browser/eve-origin.test.ts | 2 +-
tests/browser/task-state.test.ts | 55 +-
tests/link-checkout.test.ts | 2 +-
tests/link-oauth.test.ts | 6 +-
tests/linq.test.ts | 10 +-
tests/notion.test.ts | 12 +-
tests/projection.test.ts | 56 +-
tests/sign-in.ts | 30 +
tests/workspace-runtime.test.ts | 4 +-
29 files changed, 902 insertions(+), 550 deletions(-)
create mode 100644 pnpm-workspace.yaml
create mode 100644 tests/sign-in.ts
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
index 3a1169d..843f490 100644
--- a/.github/workflows/check.yml
+++ b/.github/workflows/check.yml
@@ -38,8 +38,6 @@ jobs:
with:
persist-credentials: false
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
- with:
- version: 10.33.4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 24
diff --git a/README.md b/README.md
index c0dd03f..af2600f 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@
## Run locally
-Requires Node.js 24, pnpm 10.33.4, and OpenAI and Browserbase API keys.
+Requires Node.js 24, pnpm 12.21.0, and OpenAI and Browserbase API keys.
```sh
git clone https://github.com/browserbase/bell-stack.git
diff --git a/agent/connections/notion.ts b/agent/connections/notion.ts
index 88bd707..6227b72 100644
--- a/agent/connections/notion.ts
+++ b/agent/connections/notion.ts
@@ -3,33 +3,29 @@ import { notionAuth } from "../lib/notion-auth";
import { notionEnabled, notionEndpoint, notionOwner, safeNotion } from "../../server/notion/config";
import { getNotionOAuth } from "../../server/notion/oauth";
-export default defineDynamic({
- events: {
- "turn.started": (_event, ctx) => {
- if (!notionEnabled()) return null;
- const auth = ctx.session.auth.current;
- if (auth?.principalType !== "user" || !["bell:operator", "linq"].includes(auth.issuer ?? "")) return null;
- const principal = { type: "user" as const, id: auth.principalId, issuer: auth.issuer };
- const owner = notionOwner(principal);
- return defineMcpClientConnection({
- url: notionEndpoint,
- instanceKey: owner,
- description: "Notion: the user's personal preferences, routines, plans, decisions, and notes across conversations. Search before relying on remembered information.",
- protocolVersionDiscovery: false,
- auth: notionAuth,
- tools: { allow: [
- "notion-search", "notion-fetch", "notion-memory-search", "notion-get-self",
- "notion-get-tool-access", "notion-query-data-sources",
- "notion-create-pages", "notion-update-page", "notion-create-database", "notion-update-data-source",
- "notion-get-async-task", "notion-delete-pages",
- ] },
- approval: async ({ toolName }) => {
- if (toolName.startsWith("notion__") && (await safeNotion(() => getNotionOAuth().status(principal))).status !== "connected")
- return "denied";
- return /__(?:notion-create-database|notion-update-data-source|notion-delete-pages)$/.test(toolName)
- ? "user-approval" : "not-applicable";
- },
- });
+export default defineDynamic((ctx) => {
+ if (!notionEnabled()) return null;
+ const auth = ctx.session.auth.current;
+ if (auth?.principalType !== "user" || !["bell:operator", "linq"].includes(auth.issuer ?? "")) return null;
+ const principal = { type: "user" as const, id: auth.principalId, issuer: auth.issuer };
+ const owner = notionOwner(principal);
+ return defineMcpClientConnection({
+ url: notionEndpoint,
+ instanceKey: owner,
+ description: "Notion: the user's personal preferences, routines, plans, decisions, and notes across conversations. Search before relying on remembered information.",
+ protocolVersionDiscovery: false,
+ auth: notionAuth,
+ tools: { allow: [
+ "notion-search", "notion-fetch", "notion-memory-search", "notion-get-self",
+ "notion-get-tool-access", "notion-query-data-sources",
+ "notion-create-pages", "notion-update-page", "notion-create-database", "notion-update-data-source",
+ "notion-get-async-task", "notion-delete-pages",
+ ] },
+ approval: async ({ toolName }) => {
+ if (toolName.startsWith("notion__") && (await safeNotion(() => getNotionOAuth().status(principal))).status !== "connected")
+ return "denied";
+ return /__(?:notion-create-database|notion-update-data-source|notion-delete-pages)$/.test(toolName)
+ ? "user-approval" : "not-applicable";
},
- },
+ });
});
diff --git a/agent/extensions/link/lib/spend-requests.ts b/agent/extensions/link/lib/spend-requests.ts
index 7286b10..a409907 100644
--- a/agent/extensions/link/lib/spend-requests.ts
+++ b/agent/extensions/link/lib/spend-requests.ts
@@ -56,7 +56,7 @@ const metadata = z.object({
totals: z.array(total).optional(),
approval_url: z.string().optional(),
activity_url: z.string().optional(),
- expires_at: z.number().optional(),
+ expires_at: z.iso.datetime().optional(),
recurring: z.object({
interval: z.string(),
interval_count: z.number().optional(),
@@ -83,7 +83,7 @@ const metadata = z.object({
display_message: z.string().optional(),
action_url: z.string().nullable().optional(),
resolution: z.string().optional(),
- expires_at: z.number().nullable().optional(),
+ expires_at: z.iso.datetime().nullable().optional(),
}).optional(),
}).optional(),
}).nullable().optional(),
diff --git a/agent/hooks/browser-lifecycle.ts b/agent/hooks/browser-lifecycle.ts
index a5bab4e..9dda121 100644
--- a/agent/hooks/browser-lifecycle.ts
+++ b/agent/hooks/browser-lifecycle.ts
@@ -4,8 +4,8 @@ import { saveBrowserRuntime } from "../lib/browser-runtime";
export default defineHook({
events: {
- async "turn.completed"(_event, ctx) {
- await saveBrowserRuntime(ctx.session.id);
+ async "turn.settled"(event, ctx) {
+ if (event.data.outcome === "completed") await saveBrowserRuntime(ctx.session.id);
},
},
});
diff --git a/agent/hooks/task-state.ts b/agent/hooks/task-state.ts
index b17dbfa..e5d598a 100644
--- a/agent/hooks/task-state.ts
+++ b/agent/hooks/task-state.ts
@@ -1,36 +1,36 @@
-import { defineHook, type HookEvent } from "eve/hooks";
+import { defineHook, type HookContext, type HookEvent } from "eve/hooks";
import { closeBrowserRuntime, resumeBrowserAfterHumanInput } from "../lib/browser-runtime";
import { applyTaskEvent, taskState } from "../lib/task-state";
-const update = (event: HookEvent, ctx: { session: { id: string } }) =>
- taskState.update((current) => applyTaskEvent(current, event, ctx.session.id));
+function reduce(event: HookEvent, ctx: HookContext, current: ReturnType) {
+ return applyTaskEvent(current, event, ctx.session.id, {
+ id: ctx.occurrence.idempotencyKey, at: ctx.now.toISOString(),
+ });
+}
-const cancel = async (event: HookEvent<"turn.cancelled">, ctx: { session: { id: string } }) => {
- await closeBrowserRuntime(ctx.session.id);
- update(event, ctx);
-};
+const update = (event: HookEvent, ctx: HookContext) =>
+ taskState.update((current) => reduce(event, ctx, current));
export default defineHook({
events: {
"session.started": update,
"turn.started": update,
- "message.received": (event, ctx) => {
+ "delivery.consumed": (event, ctx) => {
taskState.update((current) => {
- const next = applyTaskEvent(current, event, ctx.session.id);
- if (next !== current && current.status === "waiting_for_user")
+ const next = reduce(event, ctx, current);
+ if (current.status === "waiting_for_user" && next.status === "running")
resumeBrowserAfterHumanInput(ctx.session.id);
return next;
});
},
- "step.started": update,
- "input.requested": update,
- "input.resolved": update,
- "turn.completed": update,
- "turn.failed": update,
- "turn.cancelled": cancel,
- "session.waiting": update,
- "session.failed": update,
- "session.completed": update,
+ "model.started": update,
+ "interaction.opened": update,
+ "interaction.settled": update,
+ async "turn.settled"(event, ctx) {
+ if (event.data.outcome === "cancelled") await closeBrowserRuntime(ctx.session.id);
+ update(event, ctx);
+ },
+ "session.ended": update,
},
});
diff --git a/agent/lib/browser-runtime.ts b/agent/lib/browser-runtime.ts
index 6f9839e..b5d204e 100644
--- a/agent/lib/browser-runtime.ts
+++ b/agent/lib/browser-runtime.ts
@@ -358,12 +358,8 @@ function scheduleIdleClose(sessionId: string, runtime: BrowserRuntime): void {
}
// Channel callbacks also run when Eve ends a session outside a turn.
-// Global stream hooks do not run on that path in Eve 0.79.1.
export const browserChannelEvents = {
- async "session.completed"(_event: unknown, _channel: unknown, ctx: { session: { id: string } }) {
+ async "session.ended"(_event: unknown, ctx: { session: { id: string } }) {
await closeBrowserRuntime(ctx.session.id);
},
- async "session.failed"(event: { sessionId: string }) {
- await closeBrowserRuntime(event.sessionId);
- },
};
diff --git a/agent/lib/linq.ts b/agent/lib/linq.ts
index 9462924..5e1db1b 100644
--- a/agent/lib/linq.ts
+++ b/agent/lib/linq.ts
@@ -3,11 +3,13 @@ import { browserChannelEvents } from "./browser-runtime";
export const linqBrowserEvents: NonNullable = {
...browserChannelEvents,
- async "session.failed"(event, channel) {
+ async "session.ended"(event, ctx) {
try {
- await browserChannelEvents["session.failed"](event);
+ await browserChannelEvents["session.ended"](event, ctx);
} finally {
- await channel.thread?.post("This session could not recover from an error. Start a new conversation to continue.");
+ if (event.data.outcome === "failed") {
+ await ctx.channel.thread?.post("This session could not recover from an error. Start a new conversation to continue.");
+ }
}
},
};
diff --git a/agent/lib/task-state.ts b/agent/lib/task-state.ts
index f90ed56..f35651e 100644
--- a/agent/lib/task-state.ts
+++ b/agent/lib/task-state.ts
@@ -1,4 +1,5 @@
import { defineState } from "eve/context";
+import type { HookEvent } from "eve/hooks";
import type { BrowserProxyLocation, BrowserState } from "../../server/browser/types.js";
@@ -74,25 +75,20 @@ export function initializeTask(
}
export function applyTaskEvent(
record: DurableTaskRecord,
- event: {
- type: string;
- data?: Record;
- meta?: { id?: string; at?: string };
- },
+ event: HookEvent,
sessionId: string,
+ { id, at }: { id: string; at: string },
): DurableTaskRecord {
- const id = event.meta?.id,
- at = event.meta?.at ?? new Date().toISOString();
let next = initializeTask(record, sessionId, at);
- if (id && next.processedEventIds.includes(id)) return next;
+ if (next.processedEventIds.includes(id)) return next;
next = {
...next,
- processedEventIds: id ? [...next.processedEventIds, id].slice(-2_000) : next.processedEventIds,
+ processedEventIds: [...next.processedEventIds, id].slice(-2_000),
updatedAt: at,
};
- if (event.type === "message.received") {
+ if (event.type === "delivery.consumed") {
if (next.title === "New task") {
- const text = safeText(event.data?.message ?? event.data?.text);
+ const text = safeText(event.data.parts.flatMap((part) => part.kind === "text" ? [part.text] : []).join(" "));
if (text) next = { ...next, title: text.slice(0, 64) };
}
// A reply after handoff permits a fresh observation of the existing page.
@@ -111,25 +107,25 @@ export function applyTaskEvent(
activeStep: "agent turn",
waitReason: undefined,
};
- else if (event.type === "step.started")
+ else if (event.type === "model.started")
next = captchaBlocksGeneric(next)
? next
: { ...next, status: "running", activeStep: "model step" };
- else if (event.type === "input.requested")
+ else if (event.type === "interaction.opened")
next = {
...next,
status: "waiting_for_user",
activeStep: "waiting for user",
- waitReason: classifyWait(event.data),
+ waitReason: classifyWait(event.data.request),
};
- else if (event.type === "input.resolved")
+ else if (event.type === "interaction.settled" && next.status === "waiting_for_user" && !captchaNeedsReply(next))
next = {
...next,
status: "running",
activeStep: "resuming",
waitReason: undefined,
};
- else if (event.type === "turn.completed" || event.type === "session.waiting")
+ else if (event.type === "turn.settled" && event.data.outcome === "completed")
next = captchaBlocksGeneric(next)
? next
: {
@@ -138,16 +134,16 @@ export function applyTaskEvent(
activeStep: undefined,
waitReason: undefined,
};
- else if (event.type === "turn.failed" || event.type === "session.failed")
+ else if ((event.type === "turn.settled" || event.type === "session.ended") && event.data.outcome === "failed")
next = { ...next, status: "failed", activeStep: undefined };
- else if (event.type === "turn.cancelled")
+ else if (event.type === "turn.settled" && event.data.outcome === "cancelled")
next = closeTaskBrowser({
...next,
status: "canceled",
activeStep: undefined,
waitReason: undefined,
});
- else if (event.type === "session.completed")
+ else if (event.type === "session.ended" && event.data.outcome === "completed")
next = { ...next, status: "complete", activeStep: undefined };
return next;
}
@@ -337,11 +333,14 @@ export function closeTaskBrowser(record: DurableTaskRecord): DurableTaskRecord {
updatedAt: new Date().toISOString(),
};
}
-function classifyWait(data?: Record): DurableTaskRecord["waitReason"] {
- const value = JSON.stringify(data ?? {}).toLowerCase();
+function captchaNeedsReply(record: DurableTaskRecord): boolean {
+ return record.captcha?.status === "errored" || record.captcha?.status === "timed_out";
+}
+function classifyWait(request: { kind: string; prompt: string }): DurableTaskRecord["waitReason"] {
+ const value = request.prompt.toLowerCase();
if (value.includes("captcha")) return "captcha";
if (value.includes("otp") || value.includes("code")) return "otp";
- if (value.includes("approval")) return "approval";
+ if (request.kind === "approval" || value.includes("approval")) return "approval";
return "other";
}
export function safeText(value: unknown): string | undefined {
diff --git a/app/chat.tsx b/app/chat.tsx
index d2f9cb1..a77c43e 100644
--- a/app/chat.tsx
+++ b/app/chat.tsx
@@ -2,7 +2,7 @@
import Image from "next/image";
import { useRouter } from "next/navigation";
import { useEveAgent } from "eve/react";
-import { Client } from "eve/client";
+import { openInteractions, signInEnding } from "eve/events";
import { useState } from "react";
import { browserPreview } from "./projection";
@@ -19,16 +19,12 @@ export default function Chat({ sessionId, demoUrl }: { sessionId?: string; demoU
window.history.replaceState(null, "", `/s/${encodeURIComponent(session.sessionId)}`);
},
});
- const busy = agent.status === "submitted" || agent.status === "streaming";
+ const busy = agent.status === "busy";
const waiting = busy || agent.status === "resuming" || retiring;
const preview = browserPreview(agent.events);
- const pending = agent.data.messages
- .flatMap((message) => message.parts)
- .flatMap((part) => {
- if (part.type !== "dynamic-tool" || part.state !== "approval-requested") return [];
- const request = part.toolMetadata?.eve?.inputRequest;
- return request ? [request] : [];
- });
+ const pending = openInteractions(agent.view).filter(
+ ({ request, answer }) => request.kind !== "sign-in" && answer === undefined,
+ );
async function send(text: string) {
if (!text.trim() || waiting) return;
setError("");
@@ -44,10 +40,8 @@ export default function Chat({ sessionId, demoUrl }: { sessionId?: string; demoU
setRetiring(true);
setError("");
try {
- const activeSessionId = agent.session?.sessionId ?? sessionId;
- if (activeSessionId)
- await new Client({ host: "" }).sessions.attach(activeSessionId).reset();
- agent.reset();
+ if (agent.session) await agent.end();
+ agent.newSession();
setInput("");
router.push("/");
} catch {
@@ -89,28 +83,32 @@ export default function Chat({ sessionId, demoUrl }: { sessionId?: string; demoU
Open demo site ↗
- {agent.data.messages
+ {agent.messages
.filter((message) => message.role === "user" || message.role === "assistant")
.map((message) => (
{message.role === "user" ? "You" : "Bell"}
- {message.parts.map((part, index) =>
- part.type === "text" ? {part.text}
- : part.type === "authorization" ? (
-
- {part.state === "completed" ? (
- {part.outcome === "authorized" ? `${part.displayName} connected.` : `${part.displayName} authorization ${part.outcome}.`}
- ) : (
- <>
- {part.description}
- {part.authorization?.url && (
- Connect {part.displayName}
- )}
- >
- )}
-
- ) : null,
- )}
+ {message.parts.map((part, index) => {
+ if (part.type === "text") return {part.text}
;
+ if (part.type !== "interaction" || part.request.kind !== "sign-in") return null;
+ const signIn = part.request.signIn;
+ const name = signIn?.displayName ?? signIn?.name ?? "the service";
+ return (
+
+ {part.status === "settled" ? (
+ {part.outcome === "accepted" ? `${name} connected.` : `${name} authorization ${signInEnding(part.outcome ?? "withdrawn")}.`}
+ ) : (
+ <>
+ {part.request.prompt}
+ {signIn?.instructions && signIn.instructions !== part.request.prompt && {signIn.instructions}
}
+ {signIn?.url && (
+ Connect {name}
+ )}
+ >
+ )}
+
+ );
+ })}
))}
@@ -123,8 +121,8 @@ export default function Chat({ sessionId, demoUrl }: { sessionId?: string; demoU
{" "}
)}
- {pending.map((request) => (
-