An open-source, faster Devin alternative
TypeScript
fix: refresh serverless agent starter and docs (#612)
Mohamed Habib119d4b8b292f
diff --git a/cli/package-lock.json b/cli/package-lock.jsonindex 79f54aaf..1d67f8e3 100644--- a/cli/package-lock.json+++ b/cli/package-lock.json@@ -1,12 +1,12 @@{"name": "@opencomputer/cli",- "version": "0.4.4",+ "version": "0.4.6","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@opencomputer/cli",- "version": "0.4.4",+ "version": "0.4.6","dependencies": {"@opencode-ai/sdk": "1.18.4","ai": "^7.0.45",diff --git a/cli/package.json b/cli/package.jsonindex 1b9b1da6..bb790aff 100644--- a/cli/package.json+++ b/cli/package.json@@ -1,6 +1,6 @@{"name": "@opencomputer/cli",- "version": "0.4.4",+ "version": "0.4.6","description": "Build, test, connect, deploy, and share OpenComputer agents as code.","type": "module","bin": {diff --git a/cli/src/project.test.ts b/cli/src/project.test.tsindex 374bb28a..a5ee03aa 100644--- a/cli/src/project.test.ts+++ b/cli/src/project.test.ts@@ -53,11 +53,14 @@ test("init creates a multi-agent-ready project and React hello world app", asyncassert.equal(packageJSON.scripts.dev, "opencomputer dev");assert.equal(packageJSON.scripts["dev:web"], "vite");assert.equal(packageJSON.dependencies["@opencomputer/agent"], "^0.2.0");- assert.equal(packageJSON.devDependencies["@opencomputer/cli"], "^0.4.4");+ assert.equal(packageJSON.devDependencies["@opencomputer/cli"], "^0.4.6");assert.ok(packageJSON.devDependencies["@types/node"]);- assert.match(- await readFile(resolve(root, "vite.config.ts"), "utf8"),- /command === "serve"/,+ const viteConfig = await readFile(resolve(root, "vite.config.ts"), "utf8");+ assert.match(viteConfig, /command === "serve"/);+ assert.match(viteConfig, /resolve\("\.opencomputer\/dev\.json"\)/);+ assert.doesNotMatch(+ viteConfig,+ /opencomputer\/agents\/hello-world\/\.opencomputer\/dev\.json/,);assert.match(await readFile(resolve(root, "README.md"), "utf8"),diff --git a/cli/src/project.ts b/cli/src/project.tsindex 5d61056e..ca4104c1 100644--- a/cli/src/project.ts+++ b/cli/src/project.ts@@ -494,7 +494,7 @@ export default function Agent() {"react-dom": "^19.2.0",},devDependencies: {- "@opencomputer/cli": "^0.4.4",+ "@opencomputer/cli": "^0.4.6","@types/node": "^24.0.0","@types/react": "^19.2.0","@types/react-dom": "^19.2.0",@@ -517,10 +517,7 @@ import { defineConfig } from "vite";function openComputerDev() {try {return JSON.parse(- readFileSync(- resolve("opencomputer/agents/hello-world/.opencomputer/dev.json"),- "utf8",- ),+ readFileSync(resolve(".opencomputer/dev.json"), "utf8"),) as { url: string; token: string; agent: string };} catch {throw new Error(diff --git a/create-start/package-lock.json b/create-start/package-lock.jsonindex 0b939c2a..d90a1395 100644--- a/create-start/package-lock.json+++ b/create-start/package-lock.json@@ -1,14 +1,14 @@{"name": "@opencomputer/create-start",- "version": "0.1.0",+ "version": "0.1.2","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@opencomputer/create-start",- "version": "0.1.0",+ "version": "0.1.2","dependencies": {- "@opencomputer/cli": "^0.4.4"+ "@opencomputer/cli": "^0.4.6"},"bin": {"create-start": "index.js"@@ -75,9 +75,9 @@}},"node_modules/@opencomputer/cli": {- "version": "0.4.4",- "resolved": "https://registry.npmjs.org/@opencomputer/cli/-/cli-0.4.4.tgz",- "integrity": "sha512-SvV6l5PHzreF7QtR+c7axlDHvo4cT7zgIuzofxZiznGoScBQwSBSYoxWQwsVFTQbqbKJaAdZw0Pb0BadExcbMg==",+ "version": "0.4.6",+ "resolved": "https://registry.npmjs.org/@opencomputer/cli/-/cli-0.4.6.tgz",+ "integrity": "sha512-yNU9yT0kC/tD72LaCt2/M3B3o1VhavZZlmJdw9yevdOUYHuSvFg2JFekxAp95Rv+SXsoOGFWpagxedfTL5sLaw==","dependencies": {"@opencode-ai/sdk": "1.18.4","ai": "^7.0.45",diff --git a/create-start/package.json b/create-start/package.jsonindex ac535151..16a8ce61 100644--- a/create-start/package.json+++ b/create-start/package.json@@ -1,6 +1,6 @@{"name": "@opencomputer/create-start",- "version": "0.1.0",+ "version": "0.1.2","description": "Create a hello-world OpenComputer agent application.","type": "module","bin": {@@ -18,7 +18,7 @@"node": ">=22.0.0"},"dependencies": {- "@opencomputer/cli": "^0.4.4"+ "@opencomputer/cli": "^0.4.6"},"publishConfig": {"access": "public"diff --git a/docs/agents/architecture.mdx b/docs/agents/architecture.mdxdeleted file mode 100644index 544464ce..00000000--- a/docs/agents/architecture.mdx+++ /dev/null@@ -1,60 +0,0 @@-----title: "Architecture"-description: "How OpenComputer projects connect applications and agents"------OpenComputer separates application UI from agent definitions while keeping-both in one project repository.--```mermaid-flowchart LR- A["React app<br/>src/"] --> B["useAgent"]- B --> C["Authenticated local bridge<br/>npm run dev"]- C --> D["Agent definitions<br/>opencomputer/"]- D --> E["Development deployment"]- E --> F["Immutable production versions"]- F --> G["Durable sessions"]-```--## Project source--The `opencomputer/` tree contains project identity, agents, instructions,-tools, connections, channels, skills, routing, and runtime configuration. The-`src/` tree is a normal React application and can be changed independently.--Projects can contain multiple agents. The initial scaffold creates only-`hello-world`, so the developer can see the complete loop before adding more-behavior.--## Cloud development--`npm run dev` watches agent code and deploys it to Development (Cloud). It also-writes ephemeral connection details inside the selected agent's ignored-`.opencomputer/` directory. `npm run dev:web` starts Vite; its server-side-proxy reads those details and forwards browser requests. The credential is-never bundled into React code.--The generated `useAgent` hook:--- creates a session on the first prompt;-- streams newline-delimited agent events;-- appends assistant message deltas; and-- reuses the session ID for follow-up prompts.--## Environments and versions--Every project starts with a development environment. Local edits can be tested-against the live development agent, then deployed as an immutable version and-promoted through a stable alias such as `production`. Version history remains-available for inspection and rollback.--## Project and session resources--A project owns its agents, deployments, sessions, files shared by agents,-connections, inbound channels, schedules, agent schema, and access tokens.-A session owns its durable log, produced files, agent-written data, and secrets-shared specifically with that session. The model supports a main agent and-subagents with separate logs as that capability is introduced.--The dashboard and CLI call the public OpenComputer API. Runtime and-infrastructure services remain private implementation details.diff --git a/docs/agents/channels.mdx b/docs/agents/channels.mdxindex b441488f..cefcf29c 100644--- a/docs/agents/channels.mdx+++ b/docs/agents/channels.mdx@@ -1,111 +1,55 @@---title: "Channels"-description: "Connect deployed agents to Slack and other conversational interfaces"+description: "Connect a deployed agent alias to Slack"----Channels make a deployed agent available from an external interface such as-Slack. The agent's behavior remains defined by its source repository; the-channel supplies messages to managed sessions and returns the streamed result.+A channel delivers external messages to the same durable session runtime used+by React, the API, CLI, and playground. Agent behavior remains defined in code.## Connect Slack-Slack is connected after deployment and does not require channel source files,-a Slack manifest in Git, or the Slack CLI.-<Steps>- <Step title="Deploy the agent">- Deploy the source with `opencomputer deploy`. A channel targets an alias,- such as `production`, so later deployments can advance that alias without- reinstalling the Slack app.+ <Step title="Deploy an agent">+ Run `npm run deploy -- --alias production`. Slack connects to an alias so+ later versions can be promoted without reinstalling the app.</Step><Step title="Open Channels">- In the OpenComputer dashboard, open the deployed agent and select the- **Channels** tab. Choose **Connect Slack**.+ Open the project in the OpenComputer dashboard, choose the agent and+ environment, then select **Channels**.</Step>- <Step title="Name and create the Slack app">- Choose the app name people will see in Slack. Copy the generated manifest,- open Slack's app creation page, and create an app from that manifest.+ <Step title="Create the Slack app">+ Start **Connect Slack**, copy the generated manifest, and create the app in+ Slack using that manifest.</Step><Step title="Complete installation">- Follow the wizard to enter the App ID and Signing Secret, install the app,- and enter its Bot User OAuth Token. Secrets are stored encrypted and never- committed to the agent repository.+ Enter the requested Slack application values and install the app. Secrets+ are stored by OpenComputer rather than committed to the project.</Step></Steps>-Each deployment alias has its own Slack app connection. For example,-`support-agent@production` and `support-agent@staging` can be installed and-tested independently.--## Sessions from channels--Each supported Slack conversation creates or resumes a managed agent session.-Messages in the same user thread continue the same multi-turn session, while-other users and threads remain isolated. Invite the app to a channel and-@-mention it, or message it directly.--Channel sessions use the same deployed source and runtime behavior as sessions-started from the CLI or dashboard. They appear in the agent's session history.--## Linking a channel identity--A Slack identity is not automatically treated as the person who installed the-Slack application. Before an agent can access personal connections, each Slack-user links their own OpenComputer identity.--<Steps>- <Step title="Message the agent">- If the Slack user is not linked, the agent replies with a short-lived- OpenComputer dashboard link.- </Step>- <Step title="Sign in to OpenComputer">- Opening the link associates that Slack user with the authenticated- OpenComputer user.- </Step>- <Step title="Connect required services">- If the agent needs Gmail or another declared service, it can send that- Slack user a private connection link. Authorization never appears in the- shared channel.- </Step>- <Step title="Message the agent again">- The channel session can now use only the connections owned by the linked- user.- </Step>-</Steps>+Direct messages and supported Slack threads create or resume isolated agent+sessions. Channel sessions appear in the project's **Sessions** view.-This prevents a shared Slack channel from inheriting the installer's Gmail or-another teammate's connected accounts.+## React to channel input-OpenComputer identifies a Slack user within their Slack workspace and remembers-the linked OpenComputer identity. The same person can therefore use their own-connections across that workspace's OpenComputer agent apps without relinking-each app. This identity boundary also keeps two Slack workspaces with matching-user IDs separate.+Use the same agent function for every input source:-## Connections and channels are different+```tsx+import { useInput } from "@opencomputer/agent";-| Concept | Purpose | Ownership |-| --------------------- | --------------------------------------------------- | ---------------------------------------------- |-| Connection | Authorizes an external service such as Gmail | Individual OpenComputer user |-| Channel | Provides an interface for invoking a deployed agent | Agent deployment alias and installed workspace |-| Channel identity link | Maps an external user to an OpenComputer user | Individual external user |+export default function Agent() {+ const input = useInput();+ return input.source === "channel"+ ? "Reply briefly and avoid exposing private context in a shared channel."+ : "Give a complete and helpful response.";+}+```-A channel does not grant service access by itself. It identifies who sent the-message, and the managed session resolves only that user's connections.+## User identity and connections-Disconnect Slack from the same Channels tab. This stops new messages without-deleting the agent, its deployments, sessions, or personal service connections.+A Slack user links their own OpenComputer identity before the agent can use+that person's service connections. A shared channel does not inherit the Slack+installer's Gmail, GitHub, Calendar, or other authorizations.-<CardGroup cols={2}>- <Card title="Connections" icon="plug" href="/agents/connections">- Authorize multiple user-scoped accounts with recognizable aliases.- </Card>- <Card- title="Agents architecture"- icon="diagram-project"- href="/agents/architecture"- >- See how source, deployments, sessions, connections, and channels fit- together.- </Card>-</CardGroup>+Disconnecting Slack stops new channel messages without deleting the agent,+deployment history, or previous sessions.diff --git a/docs/agents/connections.mdx b/docs/agents/connections.mdxindex 1ea9373d..64404e6e 100644--- a/docs/agents/connections.mdx+++ b/docs/agents/connections.mdx@@ -1,120 +1,76 @@----title: "Connections"-description: "Give agents user-scoped access to services such as Gmail"+title: "Connections and MCP"+description: "Attach user-scoped services and managed MCP servers from agent code"----Connections let an agent use an external service without storing OAuth tokens-or provider credentials in the agent repository. A connection belongs to an-OpenComputer user and can be used during both local development and deployed-sessions.+Connections authorize external services without placing provider credentials+in source, prompts, or the agent runtime. Agent code declares what it needs;+each OpenComputer user authorizes their own account.-## Declarations and authorizations+## Request a connection from code-An agent repository declares the kinds of connections its tools can use. For-example, a Gmail agent contains a Google connection declaration alongside its-source:+```tsx+import { connection, useConnection } from "@opencomputer/agent";-```text-email-triage/-├── opencomputer.toml-├── connections/-│ └── google.json-└── tools/- └── gmail.ts+const github = connection("github");++export default function Agent() {+ useConnection(github);+ return "Help the user inspect and work with their GitHub account.";+}```-The declaration is safe to commit. It describes the provider, services, and-requested scopes, but contains no user credentials.+Connection declarations are safe to commit. They contain identifiers, not+OAuth access tokens.-Authorization is separate. Each user connects their own account through the-OpenComputer CLI:+## Authorize an account```bash-opencomputer connection add gmail --alias personal+npx opencomputer connection add github --alias work+npx opencomputer connection add gmail --alias personal+npx opencomputer connection add calendar --alias work-calendar+npx opencomputer connection list```-OpenComputer opens the provider authorization page and stores the resulting-connection outside the repository.--<Note>-Deploying an agent does not grant it access to the developer's account. At run-time, OpenComputer resolves connections using the identity of the user who-started the session.-</Note>--## Multiple accounts and aliases--Aliases distinguish multiple connections of the same type. For example, one-user can connect personal and work Gmail accounts:+Remove an authorization by alias or connection ID:```bash-opencomputer connection add gmail --alias personal-opencomputer connection add gmail --alias work-opencomputer connection list+npx opencomputer connection remove work```-Agent tools can select the appropriate alias for a request. If no alias is-specified, they use the `default` connection.--Use short, recognizable aliases made from letters, numbers, dots, dashes, or-underscores. An alias identifies a connection within your own OpenComputer-identity; it does not expose or share that account with another user.--## Using connections in sessions--The same managed connection works in both execution modes:--| Session | How access is provided |-| --- | --- |-| Local development | The CLI gives the local session a temporary connection capability. |-| Deployed agent | OpenComputer gives the managed session a user-scoped connection capability. |--Provider credentials remain outside the agent's source, workspace, prompts,-and model output.--Every agent runtime includes connection discovery and request tools. The agent-can list the providers and aliases available to the current session identity,-then ask that user to authorize a declared service when one is missing. These-tools return connection metadata only; they never return provider credentials.--In the CLI and playground, a connection request returns a secure dashboard-link. In Slack, OpenComputer privately messages that link to the person who-invoked the agent instead of posting it in the shared channel. After the user-authorizes the account, later sessions can find the connection by its alias.--An agent can request only connection providers declared by its deployed source.-The user still chooses whether to authorize the account and which provider-permissions to grant.+Connections are scoped to the authenticated user. Deploying an agent does not+grant every user access to the developer's connected accounts.++## Attach an MCP server++```tsx+import {+ connection,+ defineMcpServer,+ useInput,+ useMcpServer,+} from "@opencomputer/agent";++const github = connection("github");+const docs = defineMcpServer({+ id: "company-docs",+ url: "https://mcp.example.com/server",+ connection: github,+});++export default function Agent() {+ const input = useInput();+ if (input.text?.includes("documentation")) useMcpServer(docs);+ return "Use company documentation when it is relevant to the request.";+}+```-## List and remove connections+Managed MCP URLs must use HTTPS. Because `useMcpServer` can be conditional,+the server does not need to be exposed to every render of the agent.-```bash-opencomputer connection list-opencomputer connection remove work-```+## Missing authorizations-You can remove a connection by alias or by its connection ID. Use the ID when-more than one listed connection has the same alias.--Removing a connection prevents future sessions from using it. Agent source and-existing deployments are unchanged.--## Identity and security--- Connections belong to an authenticated OpenComputer user, not a device,- directory, agent, or organization-wide shared pool.-- Two users running the same deployed agent receive access to their own- connections only.-- A connection declaration limits which integrations an agent expects, while- the provider authorization limits the scopes that are actually available.-- Agent instructions should still require confirmation before consequential- actions such as sending messages or modifying external data.--<CardGroup cols={2}>- <Card title="Deploy a Gmail summarizer" icon="envelope" href="/agents/quickstart">- Create an agent, authorize Gmail, test it locally, and deploy it.- </Card>- <Card title="Channels" icon="comments" href="/agents/channels">- Let people invoke deployed agents from Slack and other interfaces.- </Card>-</CardGroup>+The managed runtime can list connection metadata available to the current+session and request an authorization when a declared service is missing. The+user completes that flow in OpenComputer; credentials are not returned to the+model or application.diff --git a/docs/agents/overview.mdx b/docs/agents/overview.mdxindex fc130c26..ab2c2953 100644--- a/docs/agents/overview.mdx+++ b/docs/agents/overview.mdx@@ -1,89 +1,77 @@---title: "Serverless Agents"-description: "Build projects with live agent backends and React apps"+description: "Define reactive agents in TypeScript and run them in the OpenComputer cloud"----An OpenComputer project groups one or more agents, their deployments, and the-application that interacts with them. Agent behavior and integrations are code;-OpenComputer manages execution, durable sessions, and version history.+OpenComputer is a managed runtime for agents defined as code. A project can+contain several agents and a React application that talks to them. You write+the behavior; OpenComputer manages development deployments, model execution,+tools, durable sessions, streaming, and production versions.++```tsx+import { useInput, useModel } from "@opencomputer/agent";++export default function Agent() {+ const input = useInput();+ useModel("anthropic/claude-sonnet-4.6");++ return input.text+ ? `Help the user with this request: ${input.text}`+ : "You are a helpful assistant.";+}+```++The exported function is a reactive description of the agent. OpenComputer+renders it for the current input and uses its return value as instructions for+the managed agent loop. Hooks attach the model, tools, connections, MCP+servers, and subagents needed for that render.<CardGroup cols={2}>- <Card title="Projects" icon="folder">- Keep related agents, sessions, files, connections, channels, and schedules- in one place.+ <Card title="Projects" icon="folder" href="/agents/projects">+ Group multiple agents and a client application in one repository.</Card>- <Card title="Agents as code" icon="code">- Instructions, tools, skills, connection declarations, and routing live in- source control.+ <Card title="Reactive agents" icon="code" href="/agents/reactive-agents">+ Build agent behavior with a function and conditional hooks.</Card>- <Card title="Live development" icon="terminal">- Run the agent server and React app separately while edits are deployed to- your development environment.+ <Card title="Cloud development" icon="cloud" href="/agents/development">+ Sync source directly to a managed development environment.</Card>- <Card title="Versioned deployment" icon="code-branch">- Promote an immutable deployment after testing it in development.+ <Card title="Sessions" icon="comments" href="/agents/sessions">+ Stream responses and inspect durable conversations.</Card></CardGroup>-## Initialize a project++## Start a project```bashnpm create @opencomputer/start@latest my-agentcd my-agentnpm installnpx opencomputer login+npm run dev```-The initial project contains one hello-world agent and is structured to accept-more agents later:--```text-my-agent/-├── opencomputer/-│ ├── project.ts-│ └── agents/-│ └── hello-world/-│ └── agent.ts-└── src/- ├── App.tsx- ├── main.tsx- └── use-agent.ts-```--`opencomputer/project.ts` lists the agents in the app. The first `npm run dev`-binds the local app to an OpenComputer cloud project.+The first `npm run dev` lets you create a cloud project or select an existing+one. OpenComputer stores the local project binding under `.opencomputer/` and+syncs every configured agent to the project's `development` environment.-## Development workflow+<Note>+There is no local agent server. The React app runs locally, while agent code+runs in OpenComputer's managed development cloud.+</Note>-<Steps>- <Step title="Start the agent backend">- Run `npm run dev`. It watches the agent definition and syncs it to the- project's Development (Cloud) environment.- </Step>- <Step title="Start the application">- In another terminal, run `npm run dev:web`. The generated `useAgent` hook- streams messages through the Vite proxy.- </Step>- <Step title="Customize and connect">- Edit instructions and add tools, connections, skills, channels, or routing- under `opencomputer/`.- </Step>- <Step title="Deploy a version">- Run `opencomputer deploy`. The project has a development environment by- default; promote a tested immutable version to production when ready.- </Step>-</Steps>+## What is available today-## Project resources+- TypeScript projects containing one or more agents+- reactive instructions, model selection, tools, subagents, connections, MCP+ servers, input metadata, and session data reads+- cloud development with file watching and automatic synchronization+- a generated React client with streaming and multi-turn session reuse+- dashboard and CLI playground sessions+- immutable deployments promoted through aliases such as `production`+- user-scoped Gmail, Calendar, and GitHub connections+- Slack channels connected to deployed agent aliases-The project view includes **Agent playground**, **Sessions**, **Files**,-**Connections**, **Channels**, **Schedules**, and **Agent schema**. A session-has a durable log and can own produced files, session data, and shared secrets.--<CardGroup cols={2}>- <Card title="Quickstart" icon="play" href="/agents/quickstart">- Create and run the hello-world project.- </Card>- <Card title="Architecture" icon="diagram-project" href="/agents/architecture">- Follow requests from React to the agent runtime.- </Card>-</CardGroup>+The dashboard is primarily an inspection and testing surface. Agent behavior+belongs in the repository under `opencomputer/`; credentials and user account+authorizations remain managed by OpenComputer.diff --git a/docs/agents/projects.mdx b/docs/agents/projects.mdxnew file mode 100644index 00000000..12a37bcb--- /dev/null+++ b/docs/agents/projects.mdx@@ -0,0 +1,95 @@+---+title: "Projects and agents"+description: "Organize multiple cloud agents and a React application"+---++A project is the cloud boundary for related agents, environments, deployments,+and sessions. A source repository contains the project's agent definitions and+the application that interacts with them.++## Project structure++The starter is intentionally small:++```text+my-agent/+├── opencomputer/+│ ├── project.ts+│ └── agents/+│ └── hello-world/+│ ├── agent.ts+│ ├── tools/ # optional+│ └── skills/ # optional+├── src/+│ ├── App.tsx+│ ├── main.tsx+│ └── use-agent.ts+├── package.json+└── vite.config.ts+```++- `opencomputer/project.ts` declares project metadata and agent IDs.+- `opencomputer/agents/<id>/agent.ts` defines one agent.+- `src/` is a normal React application.+- `.opencomputer/` is ignored local state created by the CLI.++Add source files only when the project uses them. The starter does not generate+placeholder capability directories.++## Create or select the cloud project++The source scaffold and cloud project are separate. `npm create` writes local+source; the first `npm run dev` asks where to sync it.++For non-interactive use:++```bash+npx opencomputer dev --project <project-id-or-slug>+npx opencomputer dev --create-project "Support agents"+```++Later runs reuse `.opencomputer/project.json`. Delete or change that binding+only when you intentionally want this source directory to target another+project.++## Add another agent++Create a new agent module:++```text+opencomputer/agents/researcher/agent.ts+```++```tsx+import { useModel } from "@opencomputer/agent";++export default function Agent() {+ useModel("anthropic/claude-sonnet-4.6");+ return "Research the request, verify claims, and cite useful sources.";+}+```++Then list it in `opencomputer/project.ts`:++```tsx+export default {+ name: "Customer workspace",+ agents: ["hello-world", "researcher"],+};+```++The running development process synchronizes both agents. In the dashboard,+the project-level environment selector switches between `development` and+`production`; the playground has a separate agent selector.++## Inspect the project++The current project dashboard provides:++- **Agent playground** for creating and resuming test sessions+- **Deployments** for immutable version history and active aliases+- **Sessions** created through channels or the API+- **Channels** connected to a deployed agent alias++Project and agent behavior remains code-owned. The dashboard is for selection,+inspection, testing, and credential-backed setup flows.diff --git a/docs/agents/quickstart.mdx b/docs/agents/quickstart.mdxindex a3481688..a6da0ccd 100644--- a/docs/agents/quickstart.mdx+++ b/docs/agents/quickstart.mdx@@ -1,15 +1,12 @@---title: "Quickstart"-description: "Create a hello-world agent project and React app"+description: "Create an agent project and sync it to Development (Cloud)"----This quickstart creates your first OpenComputer project, syncs its hello-world-agent to Development (Cloud), and opens a local React app that can steer it.-## Prerequisites- Node.js 22 or newer-- An OpenComputer account+- an OpenComputer account## 1. Create the app@@ -19,8 +16,7 @@ cd my-agentnpm install```-Use `npm create @opencomputer/start@latest .` to initialize the current-directory instead.+Use `.` instead of `my-agent` to initialize an empty current directory.## 2. Log in@@ -28,10 +24,10 @@ directory instead.npx opencomputer login```-The generated project includes the OpenComputer CLI. You do not need to install-it globally.+The CLI opens the OpenComputer device-login flow and stores the login locally.+The production API at `https://app.opencomputer.dev` is used by default.-## 3. Sync the agent to Development (Cloud)+## 3. Start cloud developmentIn the first terminal:@@ -39,11 +35,10 @@ In the first terminal:npm run dev```-The first run asks you to select an existing cloud project or create one. It-then watches `opencomputer/` and continuously deploys changes to that project's-development environment.+On the first run, choose an existing project or create a new one. The process+stays open, watches `opencomputer/`, and syncs changes to `development`.-## 4. Run the React app+## 4. Start ReactIn a second terminal:@@ -51,38 +46,48 @@ In a second terminal:npm run dev:web```-Open the Vite URL and send the suggested hello-world prompt. The generated-`useAgent` hook streams the response and reuses the session for follow-up+Open the Vite URL and send a message. The generated React hook creates a+durable session, streams response events, and reuses that session for follow-upmessages.-## 5. Customize the agent+<Warning>+Keep `npm run dev` running while using `npm run dev:web`. Vite reads temporary+bridge details from `.opencomputer/dev.json`; those details are intentionally+not bundled into browser code.+</Warning>++## 5. Change the agent++Edit `opencomputer/agents/hello-world/agent.ts`:-Edit `opencomputer/agents/hello-world/agent.ts`. Add reactive tools,-connections, skills, model selection, and routing as code beside it. React UI-code stays under `src/`.+```tsx+import { useInput, useModel } from "@opencomputer/agent";-```text-my-agent/-├── opencomputer/-│ ├── project.ts-│ └── agents/hello-world/-└── src/+export default function Agent() {+ const input = useInput();+ useModel("anthropic/claude-sonnet-4.6");++ return `Be concise and practical. Current request: ${input.text ?? "none"}`;+}```-## 6. Deploy+Saving the file publishes a new development deployment. Refreshing or+restarting the React app is not required for agent-only changes.++## 6. Deploy to production```bash-opencomputer deploy --alias production+npm run deploy -- --alias production```-Each source change produces an immutable deployment version. Open the project-in the dashboard and select **Agent playground** to test the deployed agent.+The command builds an immutable deployment and advances the `production`+alias. Development remains available for subsequent edits.<CardGroup cols={2}>- <Card title="Agents overview" icon="robot" href="/agents/overview">- Learn about projects, agents, sessions, and deployments.+ <Card title="Projects" icon="folder" href="/agents/projects">+ Add more agents and understand project bindings.</Card>- <Card title="Architecture" icon="diagram-project" href="/agents/architecture">- See how the React app connects to local and deployed agents.+ <Card title="Reactive agents" icon="code" href="/agents/reactive-agents">+ Add models, tools, connections, MCP servers, and subagents.</Card></CardGroup>diff --git a/docs/agents/reactive-agents.mdx b/docs/agents/reactive-agents.mdxnew file mode 100644index 00000000..314a621d--- /dev/null+++ b/docs/agents/reactive-agents.mdx@@ -0,0 +1,136 @@+---+title: "Reactive agents"+description: "Render instructions and capabilities from the current input"+---++An agent is a synchronous TypeScript function that returns instructions. The+OpenComputer runtime owns the durable conversation, streaming model calls,+tool loop, and continuation. Your function calculates the agent configuration+for the current render.++```tsx+export default function Agent() {+ return "You are a helpful assistant.";+}+```++This keeps ordinary TypeScript control flow available. Hooks may be called+conditionally, so a capability can be attached only when the current request+needs it.++## Hooks++| Hook | Current value or effect |+| --- | --- |+| `useInput()` | Reads the current source, text, and optional structured payload |+| `useCurrentInput()` | Alias for `useInput()` |+| `useModel(model)` | Selects a model using `provider/model` notation |+| `useTool(tool)` | Makes a named or code-defined tool available |+| `useSubagent(agent)` | Makes another project agent available as a subagent |+| `useConnection(connection)` | Declares a user-scoped service connection needed by this render |+| `useMcpServer(server)` | Attaches a managed HTTPS MCP server |+| `useSessionData(key)` | Reads a value previously stored in the current session |++`useInput()` is not a human-in-the-loop prompt. It describes the input that+caused the current render. Its `source` can be `user`, `channel`, `schedule`,+`webhook`, `subagent`, or `system`.++## Conditional configuration++```tsx+import {+ useInput,+ useModel,+ useSubagent,+ useTool,+} from "@opencomputer/agent";++export default function Agent() {+ const input = useInput();+ useModel("anthropic/claude-sonnet-4.6");++ if (input.text?.includes("research")) {+ useTool("web-search");+ useSubagent("researcher");+ }++ return "Answer directly. Research and verify when those capabilities exist.";+}+```++The hook calls describe capabilities for the next model step; they do not run+the model or tool themselves.++## Define a tool++Tools are TypeScript values with JSON Schema inputs and an asynchronous or+synchronous `run` function. Put the implementation beside the agent, for+example at `opencomputer/agents/hello-world/tools/hacker-news.ts`:++```tsx+import { defineTool } from "@opencomputer/agent";++export const latestStories = defineTool({+ name: "latest_hacker_news_stories",+ description: "Fetch the current top Hacker News stories",+ input: {+ type: "object",+ properties: { limit: { type: "number" } },+ },+ async run({ input, signal, reportProgress }) {+ await reportProgress({ status: "fetching" });+ const limit = Number(input.limit ?? 10);+ const ids = await fetch(+ "https://hacker-news.firebaseio.com/v0/topstories.json",+ { signal },+ ).then((response) => response.json() as Promise<number[]>);+ return ids.slice(0, limit);+ },+});+```++Import and attach it from `agent.ts`:++```tsx+import { useTool } from "@opencomputer/agent";+import { latestStories } from "./tools/hacker-news";++export default function Agent() {+ useTool(latestStories);+ return "Use the Hacker News tool when the user asks for current stories.";+}+```++Tool names may contain letters, numbers, underscores, and hyphens. Tool code+runs in the managed agent runtime, not in the browser.++## Skills++Skills are reusable instruction bundles for the coding-agent harness. Add a+skill only when an agent needs one:++```text+opencomputer/agents/hello-world/skills/code-review/SKILL.md+```++Skills in an agent's `skills/` directory are packaged with that agent and can+be loaded by the runtime when their description matches the task. Unlike+tools, skills provide instructions and supporting resources rather than a+callable JSON Schema function.++## Models++Use `provider/model` strings:++```tsx+useModel("anthropic/claude-sonnet-4.6");+```++An object form is also supported:++```tsx+useModel({ provider: "anthropic", model: "claude-sonnet-4.6" });+```++Provider credentials are resolved by the managed model gateway and are not+placed in the agent sandbox or React application.diff --git a/docs/agents/sessions.mdx b/docs/agents/sessions.mdxnew file mode 100644index 00000000..36842c2a--- /dev/null+++ b/docs/agents/sessions.mdx@@ -0,0 +1,68 @@+---+title: "Sessions and playground"+description: "Create durable conversations from React, the dashboard, channels, or the CLI"+---++A session is a durable conversation with a deployed agent. Each turn appends+input and streamed runtime events to the session, allowing clients to resume a+conversation without rebuilding its history locally.++## React++The starter includes `src/use-agent.ts`. Its `useAgent()` hook exposes:++- `messages` — accumulated user and assistant messages+- `send(text)` — create a session if necessary and stream the next turn+- `isRunning` — whether a turn is active+- `error` — the latest request error++The generated hook is ordinary application code. Extend it, replace its UI, or+build additional hooks around the same session endpoints.++## Agent playground++Open a project in the dashboard and choose **Agent playground**. Select the+agent and environment independently, then create a new session or resume a+previous playground session.++Playground sessions stay in the playground list. Sessions started through an+API or channel appear under **Sessions**, where their durable turn history can+be inspected.++## CLI++Start an interactive session against the development agent:++```bash+npm run session+```++Or manage remote sessions explicitly:++```bash+npx opencomputer session create "Draft a response" --remote \+ --agent hello-world@development+npx opencomputer session list+npx opencomputer session inspect <session-id>+npx opencomputer session attach <session-id>+npx opencomputer session send <session-id> "Continue"+npx opencomputer session end <session-id>+```++Use `--keep` on supported commands when the session should remain active after+the command exits.++## Input sources++Inside an agent, `useInput().source` identifies how the current work arrived:++```tsx+const input = useInput();++if (input.source === "channel") {+ return "Respond naturally for a shared chat channel.";+}+```++This lets the same agent adapt to React, playground, API, channel, schedule,+webhook, subagent, and system inputs without separate agent definitions.diff --git a/docs/docs.json b/docs/docs.jsonindex 61e2c111..d8ad0313 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -31,9 +31,11 @@"pages": ["agents/overview","agents/quickstart",+ "agents/projects",+ "agents/reactive-agents",+ "agents/sessions","agents/connections",- "agents/channels",- "agents/architecture"+ "agents/channels"]}]diff --git a/docs/llms.txt b/docs/llms.txtindex b3947023..13001c3d 100644--- a/docs/llms.txt+++ b/docs/llms.txt@@ -5,7 +5,9 @@## Serverless Agents- [Overview](https://docs.opencomputer.dev/agents/overview.md): Build, test, connect, and deploy agents as code.-- [Quickstart](https://docs.opencomputer.dev/agents/quickstart.md): Deploy a Gmail summarizer agent with the OpenComputer CLI.-- [Connections](https://docs.opencomputer.dev/agents/connections.md): Give agents user-scoped access to services such as Gmail.-- [Channels](https://docs.opencomputer.dev/agents/channels.md): Connect deployed agents to Slack and other conversational interfaces.-- [Architecture](https://docs.opencomputer.dev/agents/architecture.md): Learn how agent projects become managed, connected deployments.+- [Quickstart](https://docs.opencomputer.dev/agents/quickstart.md): Create a project and sync its first agent to Development (Cloud).+- [Projects and agents](https://docs.opencomputer.dev/agents/projects.md): Organize multiple agents and a React application.+- [Reactive agents](https://docs.opencomputer.dev/agents/reactive-agents.md): Render instructions, models, tools, subagents, connections, and MCP servers from code.+- [Sessions and playground](https://docs.opencomputer.dev/agents/sessions.md): Create and inspect durable conversations.+- [Connections and MCP](https://docs.opencomputer.dev/agents/connections.md): Attach user-scoped services and managed MCP servers from code.+- [Channels](https://docs.opencomputer.dev/agents/channels.md): Connect deployed agents to Slack.