diff --git a/README.md b/README.md index d56301a..96c8291 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,20 @@ pnpm install --frozen-lockfile cp .env.example .env ``` -Set `OPENAI_API_KEY` and `BROWSERBASE_API_KEY` in `.env`. For ordinary browsing, set `BELL_DEMO_URL` to your target website. +Set `OPENAI_API_KEY` and `BROWSERBASE_API_KEY` in `.env`. For ordinary browsing, set `BELL_DEMO_URL` to your target website. Set `PARALLEL_API_KEY` to enable public-web research. Keep research inputs public; use the browser for authenticated pages and actions. ```sh pnpm dev ``` +## WebMCP + +In browsers that support WebMCP, Bell exposes ui-sdk's `snapshot`, `query`, and +`act` tools. A browser agent can discover controls and edit the message draft. +Sending messages, replying to Bell, starting a new conversation, opening the demo, +and stopping a request require confirmation. Browsers without WebMCP work normally. + ## Start here diff --git a/agent/agent.ts b/agent/agent.ts index 05bd7cc..13e7cdf 100644 --- a/agent/agent.ts +++ b/agent/agent.ts @@ -2,7 +2,7 @@ import { openai } from "@ai-sdk/openai"; import { defineAgent } from "eve"; export default defineAgent({ - model: openai.responses(process.env.BELL_MODEL ?? "gpt-5.6-sol"), + model: openai.responses(process.env.BELL_MODEL ?? "gpt-6.1-sol"), build: { externalDependencies: [ "@1password/sdk", diff --git a/app/chat.tsx b/app/chat.tsx deleted file mode 100644 index d2f9cb1..0000000 --- a/app/chat.tsx +++ /dev/null @@ -1,227 +0,0 @@ -"use client"; -import Image from "next/image"; -import { useRouter } from "next/navigation"; -import { useEveAgent } from "eve/react"; -import { Client } from "eve/client"; -import { useState } from "react"; -import { browserPreview } from "./projection"; - -export default function Chat({ sessionId, demoUrl }: { sessionId?: string; demoUrl: string }) { - const router = useRouter(); - const [input, setInput] = useState(""); - const [error, setError] = useState(""); - const [retiring, setRetiring] = useState(false); - const agent = useEveAgent({ - initialSession: sessionId ? { sessionId, streamIndex: 0 } : undefined, - resume: Boolean(sessionId), - onSessionChange(session) { - if (session && !sessionId) - window.history.replaceState(null, "", `/s/${encodeURIComponent(session.sessionId)}`); - }, - }); - const busy = agent.status === "submitted" || agent.status === "streaming"; - 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] : []; - }); - async function send(text: string) { - if (!text.trim() || waiting) return; - setError(""); - setInput(""); - try { - await agent.send(text.trim()); - } catch { - setError("The request failed. If the development server restarted, start a fresh conversation."); - } - } - async function newConversation() { - if (waiting) return; - setRetiring(true); - setError(""); - try { - const activeSessionId = agent.session?.sessionId ?? sessionId; - if (activeSessionId) - await new Client({ host: "" }).sessions.attach(activeSessionId).reset(); - agent.reset(); - setInput(""); - router.push("/"); - } catch { - setError("Could not close this conversation. Try again."); - } finally { - setRetiring(false); - } - } - return ( -
-
-
-

PERSONAL ASSISTANT STACK

-

- Bell. -

-
- -
-
-
-

Ask. Browse. Verify.

-

One conversation, one persistent browser.

- -
- {agent.data.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, - )} -
- ))} -
-

- {waiting ? "Working…" : "Ready"} -

- {(error || agent.error) && ( -

- {error || "The agent request failed. If the development server restarted, start a fresh conversation."} - {" "} -

- )} - {pending.map((request) => ( -
- {request.prompt} - {request.options?.map((option) => ( - - ))} - {request.allowFreeform && ( -
{ - event.preventDefault(); - const text = String( - new FormData(event.currentTarget).get("reply") ?? "", - ).trim(); - if (text) - void agent - .respond([{ requestId: request.requestId, text }]) - .catch(() => setError("Reply failed. Please retry.")); - }} - > - - - -
- )} -
- ))} -
{ - event.preventDefault(); - void send(input); - }} - > - -