Skip to content

An open-source, faster Devin alternative

TypeScript

Remove unsupported managed connections and channels (#624)

Mohamed Habib50ac411af03f
diff --git a/agent/README.md b/agent/README.md
index 96b63221..2ceab1af 100644
--- a/agent/README.md
+++ b/agent/README.md
@@ -23,12 +23,11 @@ describe that call; they do not perform I/O or run the durable agent loop.
`provider/model` spelling.
- `useTool()` and `useSubagent()` select declared capabilities.
- `useSessionData()` reads the current durable session-data snapshot.
-- `useConnection()` declares a named managed connection requirement.
- `useMcpServer()` conditionally selects a declared MCP server.
-Use `connection()` and `defineMcpServer()` for stable code declarations. Never
-put credentials in these declarations: OpenComputer resolves secrets through
-its managed gateway.
+Use `defineMcpServer()` for stable MCP declarations. Never put credentials
+directly in these declarations: OpenComputer resolves referenced secrets
+through its managed gateway.
## Secret-backed HTTP connections
@@ -41,7 +40,6 @@ import {
bearer,
defineConnection,
defineTool,
- useConnection,
useSecret,
useTool,
} from "@opencomputer/agent";
@@ -66,7 +64,6 @@ const repository = defineTool({
});
export default function Agent() {
- useConnection(github);
useTool(repository);
return "Use GitHub when the user asks about a repository.";
}
diff --git a/agent/package-lock.json b/agent/package-lock.json
index 0bcf7ad1..0eaefc86 100644
--- a/agent/package-lock.json
+++ b/agent/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@opencomputer/agent",
- "version": "0.3.1",
+ "version": "0.4.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@opencomputer/agent",
- "version": "0.3.1",
+ "version": "0.4.0",
"devDependencies": {
"typescript": "^5.9.0"
},
diff --git a/agent/package.json b/agent/package.json
index 47222d9a..1593bea4 100644
--- a/agent/package.json
+++ b/agent/package.json
@@ -1,6 +1,6 @@
{
"name": "@opencomputer/agent",
- "version": "0.3.1",
+ "version": "0.4.0",
"description": "Reactive agent authoring API for OpenComputer.",
"type": "module",
"main": "./dist/index.js",
diff --git a/agent/src/index.ts b/agent/src/index.ts
index d60c7aa4..d99c1068 100644
--- a/agent/src/index.ts
+++ b/agent/src/index.ts
@@ -79,7 +79,6 @@ interface AgentHooks {
useTool(tool: string | ResourceReference): void;
useSubagent(agent: string | ResourceReference): void;
useSessionData<T extends DataValue>(key: string): T | undefined;
- useConnection(connection: string | ResourceReference): void;
useMcpServer(server: string | ResourceReference): void;
}
@@ -101,10 +100,6 @@ function identifier(value: string, kind: string): string {
return id;
}
-export function connection(id: string): ConnectionReference {
- return Object.freeze({ kind: "connection", id: identifier(id, "connection") });
-}
-
export function useSecret(name: string): SecretReference {
const id = identifier(name, "useSecret");
if (!/^[A-Z][A-Z0-9_]{0,127}$/.test(id)) {
@@ -258,7 +253,6 @@ export const useCurrentInput = useInput;
export const useModel = (model: ModelSelection): void => hooks().useModel(model);
export const useTool = (tool: string | ResourceReference): void => hooks().useTool(tool);
export const useSubagent = (agent: string | ResourceReference): void => hooks().useSubagent(agent);
-export const useConnection = (value: string | ResourceReference): void => hooks().useConnection(value);
export const useMcpServer = (server: string | ResourceReference): void => hooks().useMcpServer(server);
export function useSessionData<T extends DataValue>(key: string): T | undefined {
return hooks().useSessionData<T>(key);
diff --git a/cli/README.md b/cli/README.md
index 6c259e9a..e026bd93 100644
--- a/cli/README.md
+++ b/cli/README.md
@@ -63,8 +63,8 @@ opencomputer secrets list --environment development
opencomputer secrets remove GITHUB_TOKEN --environment development
```
-Agent code declares secret-backed destinations with `defineConnection()`,
-`useSecret()`, and `useConnection()`. Requests use the managed gateway, which
+Agent code declares secret-backed destinations with `defineConnection()` and
+`useSecret()`. Requests use the managed gateway, which
injects a secret only for the declared origin, path, method, agent, and
environment. The plaintext secret is not added to the deployment or runtime.
diff --git a/cli/package-lock.json b/cli/package-lock.json
index 2ecff59f..90757cb9 100644
--- a/cli/package-lock.json
+++ b/cli/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@opencomputer/cli",
- "version": "0.4.11",
+ "version": "0.5.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@opencomputer/cli",
- "version": "0.4.11",
+ "version": "0.5.0",
"dependencies": {
"@opencode-ai/sdk": "1.18.4",
"ai": "^7.0.45",
diff --git a/cli/package.json b/cli/package.json
index 2a18d742..258faa4a 100644
--- a/cli/package.json
+++ b/cli/package.json
@@ -1,7 +1,7 @@
{
"name": "@opencomputer/cli",
- "version": "0.4.11",
- "description": "Build, test, connect, deploy, and share OpenComputer agents as code.",
+ "version": "0.5.0",
+ "description": "Build, test, deploy, and share OpenComputer agents as code.",
"type": "module",
"bin": {
"opencomputer": "dist/index.js",
diff --git a/cli/src/api.test.ts b/cli/src/api.test.ts
deleted file mode 100644
index 6efae045..00000000
--- a/cli/src/api.test.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import assert from "node:assert/strict";
-import test from "node:test";
-import { OpenComputerClient } from "./api.js";
-
-test("reads channels from the public managed-agents response", async () => {
- const originalFetch = globalThis.fetch;
- globalThis.fetch = async () =>
- Response.json({
- channels: [
- {
- id: "channel-1",
- channel: "slack",
- agentId: "agent-1",
- alias: "production",
- teamName: "OpenComputer",
- status: "connected",
- createdAt: "2026-08-01T00:00:00.000Z",
- updatedAt: "2026-08-01T00:00:00.000Z",
- },
- ],
- });
-
- try {
- const client = new OpenComputerClient({
- apiUrl: "https://app.opencomputer.dev",
- apiKey: "osb_test",
- });
- assert.deepEqual(await client.channelConnections(), [
- {
- id: "channel-1",
- channel: "slack",
- agentId: "agent-1",
- alias: "production",
- teamName: "OpenComputer",
- status: "connected",
- createdAt: "2026-08-01T00:00:00.000Z",
- updatedAt: "2026-08-01T00:00:00.000Z",
- },
- ]);
- } finally {
- globalThis.fetch = originalFetch;
- }
-});
diff --git a/cli/src/api.ts b/cli/src/api.ts
index f424ad5d..bbfd64c5 100644
--- a/cli/src/api.ts
+++ b/cli/src/api.ts
@@ -37,34 +37,6 @@ export interface ManagedAgentDeployment {
createdAt: string;
}
-export interface ManagedConnection {
- id: string;
- kind?: "channel" | "tool";
- provider: string;
- label: string;
- agentId?: string;
- alias?: string;
- externalAccountId?: string;
- displayName?: string;
- scopes?: string[];
- status: string;
- createdAt?: string;
- updatedAt?: string;
-}
-
-export interface ManagedSlackConnection {
- id: string;
- agentId: string;
- alias: string;
- appId?: string;
- teamId?: string;
- teamName?: string;
- botUserId?: string;
- status: string;
- createdAt: string;
- updatedAt: string;
-}
-
export interface ManagedAgentEvent {
id: string;
seq: number;
@@ -339,102 +311,6 @@ export class OpenComputerClient {
);
}
- async connections(): Promise<ManagedConnection[]> {
- const result = await this.request<{ connections: ManagedConnection[] }>(
- "/api/managed-agents/connections",
- );
- return result.connections;
- }
-
- disconnectConnection(connectionId: string) {
- return this.request<ManagedConnection>(
- `/api/managed-agents/connections/${encodeURIComponent(connectionId)}`,
- { method: "DELETE" },
- );
- }
-
- linkManagedConnection(service: string, label: string) {
- return this.request<{
- connectionId: string;
- label: string;
- service: string;
- toolkit: string;
- status: "connected" | "pending";
- connectedAccountId?: string;
- authorizationUrl?: string;
- expiresAt?: string;
- }>("/api/managed-agents/connections/link", {
- method: "POST",
- body: JSON.stringify({ service, label }),
- });
- }
-
- managedConnection(connectionId: string, service: string) {
- const provider = service === "github" ? "github" : "google";
- return this.request<{
- connectionId: string;
- label: string;
- service: string;
- toolkit: string;
- status: "connected" | "pending";
- connectedAccountId?: string;
- authorizationUrl?: string;
- expiresAt?: string;
- }>(
- `/api/managed-agents/connections/${provider}/status?service=${encodeURIComponent(service)}&connectionId=${encodeURIComponent(connectionId)}`,
- );
- }
-
- disconnectManagedConnection(connectionId: string, service: string) {
- const provider = service === "github" ? "github" : "google";
- return this.request<{
- connectionId: string;
- label: string;
- service: string;
- toolkit: string;
- status: "disconnected";
- connectedAccountId?: string;
- }>(
- `/api/managed-agents/connections/${provider}?service=${encodeURIComponent(service)}&connectionId=${encodeURIComponent(connectionId)}`,
- { method: "DELETE" },
- );
- }
-
- createSlackConnection(agentId: string) {
- return this.request<{
- connection: ManagedSlackConnection;
- webhookUrl: string;
- }>("/api/managed-agents/channels/slack/connections", {
- method: "POST",
- body: JSON.stringify({ agentId }),
- });
- }
-
- async channelConnections(): Promise<ManagedSlackConnection[]> {
- const result = await this.request<{
- channels?: ManagedSlackConnection[];
- connections?: ManagedSlackConnection[];
- }>("/api/managed-agents/channels");
- return result.channels ?? result.connections ?? [];
- }
-
- completeSlackConnection(connectionId: string, botToken: string) {
- return this.request<ManagedSlackConnection>(
- `/api/managed-agents/channels/slack/connections/${encodeURIComponent(connectionId)}`,
- {
- method: "PUT",
- body: JSON.stringify({ botToken }),
- },
- );
- }
-
- disconnectSlack(connectionId: string) {
- return this.request<ManagedSlackConnection>(
- `/api/managed-agents/channels/slack/connections/${encodeURIComponent(connectionId)}`,
- { method: "DELETE" },
- );
- }
-
createSession(agentId: string) {
return this.request<CreateSessionResult>("/api/managed-agents/sessions", {
method: "POST",
diff --git a/cli/src/commands.ts b/cli/src/commands.ts
index 388ffae0..8de7676b 100644
--- a/cli/src/commands.ts
+++ b/cli/src/commands.ts
@@ -1,12 +1,10 @@
-import { rm } from "node:fs/promises";
-
import {
OpenComputerClient,
type ManagedAgentEvent,
type ManagedAgentLog,
type ManagedSessionSnapshot,
} from "./api.js";
-import { login, logout, openBrowser } from "./auth.js";
+import { login, logout } from "./auth.js";
import { resolveConfig } from "./config.js";
import { runCloudDevelopment } from "./dev.js";
import {
@@ -15,24 +13,12 @@ import {
} from "./binding.js";
import { runLocalAgent } from "./local.js";
import {
- addSlackChannel,
assertStarterTarget,
buildAgentArtifact,
findAgentRoot,
initializeAgentProject,
readManifest,
} from "./project.js";
-import {
- captureLocalSlackState,
- clearSlackState,
- readLocalSlackState,
- readRemoteSlackState,
- remoteSlackStatePath,
- requireSlackAgentRoot,
- runSlackCli,
- slackManifest,
- writeRemoteSlackState,
-} from "./slack.js";
export interface GlobalOptions {
apiUrl?: string;
@@ -166,47 +152,6 @@ async function requireAgentRoot(): Promise<string> {
return root;
}
-async function connectManagedService(
- client: OpenComputerClient,
- service: "gmail" | "calendar" | "github",
- label = "default",
-): Promise<void> {
- const displayName =
- service === "calendar"
- ? "Google Calendar"
- : service === "github"
- ? "GitHub"
- : "Gmail";
- const started = await client.linkManagedConnection(service, label);
- if (started.status === "connected") {
- process.stdout.write(
- `${displayName} connection "${label}" is already connected.\n`,
- );
- return;
- }
- if (!started.authorizationUrl) {
- throw new Error(`${displayName} did not return an authorization link.`);
- }
- process.stdout.write(
- `Authorize ${displayName}:\n${started.authorizationUrl}\n`,
- );
- openBrowser(started.authorizationUrl);
- const deadline = started.expiresAt
- ? Date.parse(started.expiresAt)
- : Date.now() + 5 * 60_000;
- while (Date.now() < deadline) {
- await new Promise((resolve) => setTimeout(resolve, 1_500));
- if (
- (await client.managedConnection(started.connectionId, service)).status ===
- "connected"
- ) {
- process.stdout.write(`${displayName} connection "${label}" connected.\n`);
- return;
- }
- }
- throw new Error(`${displayName} authorization timed out.`);
-}
-
async function inferAgentReference(alias: string): Promise<string | undefined> {
const root = await findAgentRoot();
if (!root) return undefined;
@@ -912,308 +857,5 @@ export async function runCommand(
return;
}
- if (command === "connect") {
- const provider = args.shift();
- if ((provider !== "google" && provider !== "gmail") || args.length) {
- throw new Error("Usage: opencomputer connect google");
- }
- await connectManagedService(client, "gmail", "default");
- return;
- }
-
- if (command === "connection" || command === "connections") {
- const action = args.shift();
- if (action === "add" || action === "connect") {
- const provider = args.shift();
- const alias = option(args, "--alias") ?? "default";
- const service = provider === "google" ? "gmail" : provider;
- if (
- (service !== "gmail" &&
- service !== "calendar" &&
- service !== "github") ||
- args.length
- ) {
- throw new Error(
- "Usage: opencomputer connection add <gmail|calendar|github> [--alias <name>]",
- );
- }
- await connectManagedService(client, service, alias);
- return;
- }
- if (action === "remove" || action === "disconnect") {
- const connectionReference = args.shift();
- if (!connectionReference || args.length) {
- throw new Error(
- "Usage: opencomputer connection remove <alias|connection-id>",
- );
- }
- const connections = await client.connections();
- const matches = connections.filter(
- (connection) =>
- connection.id === connectionReference ||
- connection.label === connectionReference,
- );
- if (!matches.length) {
- throw new Error(`Connection "${connectionReference}" was not found.`);
- }
- if (matches.length > 1) {
- throw new Error(
- `More than one connection is named "${connectionReference}". Remove it by connection ID.`,
- );
- }
- const connection = matches[0]!;
- const googleService = connection.scopes?.some((scope) =>
- scope.includes("/auth/calendar"),
- )
- ? "calendar"
- : "gmail";
- const managedService =
- connection.provider === "github" ? "github" : googleService;
- const disconnected =
- connection.provider === "google" || connection.provider === "github"
- ? await client.disconnectManagedConnection(
- connection.id,
- managedService,
- )
- : await client.disconnectConnection(connection.id);
- if (globals.json) printJSON(disconnected);
- else process.stdout.write(`Removed connection "${connection.label}".\n`);
- return;
- }
- if (action !== "list" || args.length) {
- throw new Error(
- "Use `opencomputer connection add`, `list`, or `remove`.",
- );
- }
- const connections = await client.connections();
- if (globals.json) printJSON(connections);
- else if (!connections.length) process.stdout.write("No connections.\n");
- else {
- for (const connection of connections) {
- process.stdout.write(
- `${connection.id} ${connection.provider.padEnd(10)} ` +
- `${connection.status.padEnd(11)} ` +
- `${connection.label.padEnd(16)} ` +
- `${connection.displayName ?? ""}\n`,
- );
- }
- }
- return;
- }
-
- if (command === "channels") {
- const action = args.shift();
- if (action === "add" || action === "connect") {
- throw new Error(
- "Connect Slack from the deployed agent's Channels tab in the OpenComputer dashboard.",
- );
- }
- if (action === "list") {
- const localOnly = flag(args, "--local");
- const remoteOnly = flag(args, "--remote");
- if (localOnly && remoteOnly) {
- throw new Error("Choose either --local or --remote.");
- }
- if (args.length) throw new Error(`Unexpected argument: ${args[0]}`);
- const root = await findAgentRoot();
- const localState =
- !remoteOnly && root ? await readLocalSlackState(root) : undefined;
- const remoteConnections = localOnly
- ? []
- : await client.channelConnections();
- if (globals.json) {
- printJSON({
- local: localState,
- remote: remoteConnections,
- });
- } else if (!localState && !remoteConnections.length) {
- process.stdout.write("No channel connections.\n");
- } else {
- if (localState) {
- process.stdout.write(
- `local slack connected ${localState.teamName ?? localState.teamId}\n`,
- );
- }
- for (const connection of remoteConnections) {
- process.stdout.write(
- `${connection.id} slack ${connection.status.padEnd(12)} ` +
- `${connection.agentId}@${connection.alias} ` +
- `${connection.teamName ?? connection.teamId ?? "pending"}\n`,
- );
- }
- }
- return;
- }
- const channel = args.shift();
- if (channel !== "slack") {
- throw new Error(
- "Use `opencomputer channels add|connect|list|disconnect slack`.",
- );
- }
- if (action === "add") {
- if (args.length) throw new Error(`Unexpected argument: ${args[0]}`);
- const root = await requireAgentRoot();
- const files = await addSlackChannel(root);
- await import("./slack.js").then(({ ensureSlackHooks }) =>
- ensureSlackHooks(root),
- );
- process.stdout.write(
- `${files.map((file) => `Created ${file}`).join("\n")}\n`,
- );
- return;
- }
- if (action === "connect") {
- const local = flag(args, "--local");
- const remote = flag(args, "--remote");
- const agentOption = option(args, "--agent");
- const alias = option(args, "--alias") ?? "production";
- if (local === remote) {
- throw new Error("Choose exactly one of --local or --remote for Slack.");
- }
- if (args.length) throw new Error(`Unexpected argument: ${args[0]}`);
- const root = await requireSlackAgentRoot();
- if (local) {
- await runSlackCli(
- root,
- ["app", "install", "--environment", "local"],
- "local",
- );
- const state = await captureLocalSlackState(root);
- process.stdout.write(
- `Connected local Slack app ${state.appId} to ` +
- `${state.teamName ?? state.teamId}.\n`,
- );
- return;
- }
- const agent = agentOption ?? (await inferAgentReference(alias));
- if (!agent) {
- throw new Error(
- "No agent repository found. Pass --agent <agent>@<alias>.",
- );
- }
- const previous = await readRemoteSlackState(root);
- const started = await client.createSlackConnection(agent);
- await writeRemoteSlackState(root, {
- version: 1,
- connectionId: started.connection.id,
- agentId: `${started.connection.agentId}@${started.connection.alias}`,
- webhookUrl: started.webhookUrl,
- apiUrl: config.apiUrl,
- });
- try {
- await runSlackCli(root, ["deploy", "--app", "deployed"], "remote");
- const connected = (await client.channelConnections()).find(
- (connection) => connection.id === started.connection.id,
- );
- if (!connected || connected.status !== "connected") {
- throw new Error(
- "Slack CLI finished without completing the connection.",
- );
- }
- if (previous && previous.connectionId !== connected.id) {
- await client
- .disconnectSlack(previous.connectionId)
- .catch(() => undefined);
- }
- if (globals.json) printJSON(connected);
- else {
- process.stdout.write(
- `Connected ${connected.agentId}@${connected.alias} to ` +
- `${connected.teamName ?? connected.teamId ?? "Slack"}.\n`,
- );
- }
- } catch (error) {
- await client
- .disconnectSlack(started.connection.id)
- .catch(() => undefined);
- if (previous) await writeRemoteSlackState(root, previous);
- else await rm(remoteSlackStatePath(root), { force: true });
- throw error;
- }
- return;
- }
- if (action === "disconnect") {
- const local = flag(args, "--local");
- const remote = flag(args, "--remote");
- const connectionId = args.shift();
- if (local && remote) {
- throw new Error("Choose either --local or --remote.");
- }
- if (args.length) throw new Error(`Unexpected argument: ${args[0]}`);
- const root = await requireSlackAgentRoot();
- if (local) {
- await runSlackCli(
- root,
- ["app", "uninstall", "--app", "local"],
- "local",
- );
- await clearSlackState(root, "local");
- process.stdout.write("Disconnected the local Slack app.\n");
- return;
- }
- const stored = await readRemoteSlackState(root);
- const id = connectionId ?? stored?.connectionId;
- if (!id) {
- throw new Error(
- "Pass a connection ID or connect Slack from this agent first.",
- );
- }
- const disconnected = await client.disconnectSlack(id);
- if (stored?.connectionId === id) {
- await clearSlackState(root, "remote");
- }
- if (globals.json) printJSON(disconnected);
- else process.stdout.write(`Disconnected Slack connection ${id}.\n`);
- return;
- }
- throw new Error(
- "Use `opencomputer channels add|connect|list|disconnect slack`.",
- );
- }
-
- if (command === "slack-hook") {
- const action = args.shift();
- // Slack CLI app hooks append metadata such as --source=<directory>.
- // The hook already resolves its repository from the working directory,
- // so these Slack-owned arguments are intentionally ignored.
- const root = await requireSlackAgentRoot();
- const mode =
- process.env.OPENCOMPUTER_SLACK_MODE === "remote" ? "remote" : "local";
- if (action === "manifest") {
- printJSON(await slackManifest(root, mode));
- return;
- }
- if (action === "deploy") {
- const state = await readRemoteSlackState(root);
- if (!state) {
- throw new Error(
- "Run `opencomputer channels connect slack --remote` first.",
- );
- }
- const botToken =
- process.env.SLACK_BOT_TOKEN ?? process.env.SLACK_CLI_XOXB;
- if (!botToken) {
- throw new Error("Slack CLI did not provide SLACK_BOT_TOKEN.");
- }
- const hookConfig = await resolveConfig({
- ...globals,
- apiUrl: state.apiUrl,
- });
- const connection = await new OpenComputerClient(
- hookConfig,
- ).completeSlackConnection(state.connectionId, botToken);
- process.stdout.write(
- `OpenComputer connected ${connection.agentId}@${connection.alias} ` +
- `to ${connection.teamName ?? connection.teamId ?? "Slack"}.\n`,
- );
- return;
- }
- if (action === "start") {
- await runLocalAgent(["dev"], config);
- return;
- }
- throw new Error("Unsupported Slack CLI hook.");
- }
-
throw new Error(`Unknown command: ${command}`);
}
diff --git a/cli/src/index.ts b/cli/src/index.ts
index b2460ce5..533604d4 100644
--- a/cli/src/index.ts
+++ b/cli/src/index.ts
@@ -40,7 +40,7 @@ function takeFlag(args: string[], name: string): boolean {
function help(): void {
process.stdout.write(`${BANNER}
-OpenComputer — build, test, connect, and deploy agents as code
+OpenComputer — build, test, and deploy agents as code
Usage:
opencomputer login [--no-browser] [--force]
@@ -58,15 +58,10 @@ Usage:
opencomputer session attach <session-id>
opencomputer session send <session-id> <prompt> [--keep]
opencomputer session end <session-id>
- opencomputer connection add <gmail|calendar|github> [--alias <name>]
- opencomputer connection list
- opencomputer connection remove <alias|connection-id>
opencomputer secrets set <name> [--environment development|production] [--agent <agent>|current]
opencomputer secrets list [--environment development|production] [--agent <agent>|current]
opencomputer secrets remove <name> [--environment development|production] [--agent <agent>|current]
opencomputer logs [--agent <agent>] [--session <session-id>] [--environment development|production] [--follow]
- opencomputer channels list [--local|--remote]
- opencomputer channels disconnect slack [connection-id] [--local|--remote]
opencomputer deploy [--alias <alias>]
opencomputer run <agent> <prompt> [--keep]
diff --git a/cli/src/local.test.ts b/cli/src/local.test.ts
index 8ce35ecf..a3bfd528 100644
--- a/cli/src/local.test.ts
+++ b/cli/src/local.test.ts
@@ -3,71 +3,6 @@ import test from "node:test";
import { startGateway } from "./local.js";
-test("the local gateway proxies connection list and calendar requests", async () => {
- const originalFetch = globalThis.fetch;
- const upstream: Array<{ url: string; init?: RequestInit }> = [];
- globalThis.fetch = (async (
- input: string | URL | Request,
- init?: RequestInit,
- ) => {
- const url = String(input);
- upstream.push({ url, init });
- if (url.endsWith("/connections")) {
- return Response.json({ connections: [] });
- }
- return Response.json({
- service: "calendar",
- status: "pending",
- authorizationUrl: "https://connect.composio.dev/link/test",
- });
- }) as typeof fetch;
-
- const gateway = await startGateway({
- apiUrl: "https://mo-oc-dev.com",
- apiKey: "oc_test",
- });
- try {
- const headers = {
- authorization: `Bearer ${gateway.token}`,
- "content-type": "application/json",
- };
- const listed = await originalFetch(`${gateway.url}/opencomputer/fetch`, {
- method: "POST",
- headers,
- body: JSON.stringify({ action: "list" }),
- });
- assert.equal(listed.status, 200);
- assert.equal(
- upstream[0]?.url,
- "https://mo-oc-dev.com/api/managed-agents/connections",
- );
- assert.equal(upstream[0]?.init?.method, "GET");
-
- const requested = await originalFetch(`${gateway.url}/opencomputer/fetch`, {
- method: "POST",
- headers,
- body: JSON.stringify({
- action: "request",
- service: "calendar",
- label: "work-calendar",
- }),
- });
- assert.equal(requested.status, 200);
- assert.equal(
- upstream[1]?.url,
- "https://mo-oc-dev.com/api/managed-agents/connections/link",
- );
- assert.equal(upstream[1]?.init?.method, "POST");
- assert.deepEqual(JSON.parse(String(upstream[1]?.init?.body)), {
- service: "calendar",
- label: "work-calendar",
- });
- } finally {
- await gateway.close();
- globalThis.fetch = originalFetch;
- }
-});
-
test("the local gateway authenticates React requests to the cloud agent API", async () => {
const originalFetch = globalThis.fetch;
const upstream: Array<{ url: string; init?: RequestInit }> = [];
diff --git a/cli/src/local.ts b/cli/src/local.ts
index ed14f7b2..d76c2abf 100644
--- a/cli/src/local.ts
+++ b/cli/src/local.ts
@@ -4,7 +4,7 @@ import {
type ToolPart,
} from "@opencode-ai/sdk/v2";
import { spawn, type ChildProcess } from "node:child_process";
-import { randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
+import { randomBytes, timingSafeEqual } from "node:crypto";
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
import {
createServer,
@@ -113,73 +113,7 @@ export async function startGateway(config: ResolvedConfig): Promise<{
let target: string;
let upstreamMethod = request.method;
let upstreamBody: Buffer | string | undefined;
- if (
- request.method === "POST" &&
- (url.pathname === "/google/fetch" || url.pathname === "/github/fetch")
- ) {
- const provider = url.pathname.startsWith("/github/")
- ? "github"
- : "google";
- target = `${config.apiUrl}/api/managed-agents/connections/${provider}/fetch`;
- upstreamBody = await readBody(request);
- } else if (
- request.method === "POST" &&
- url.pathname === "/opencomputer/fetch"
- ) {
- const raw = await readBody(request);
- let input: Record<string, unknown>;
- try {
- const parsed: unknown = JSON.parse(raw.toString("utf8"));
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
- throw new Error("invalid payload");
- }
- input = parsed as Record<string, unknown>;
- } catch {
- sendJSON(response, 400, {
- error: { message: "Connection control payload must be valid JSON" },
- });
- return;
- }
- if (input.action === "list") {
- target = `${config.apiUrl}/api/managed-agents/connections`;
- upstreamMethod = "GET";
- } else if (input.action === "request") {
- const service = input.service;
- if (
- typeof service !== "string" ||
- !["gmail", "calendar", "drive", "sheets", "github"].includes(
- service,
- )
- ) {
- sendJSON(response, 400, {
- error: {
- message:
- "Expected one of gmail, calendar, drive, sheets, or github",
- },
- });
- return;
- }
- const requestedLabel =
- typeof input.label === "string" && input.label.trim()
- ? input.label.trim()
- : undefined;
- const label =
- requestedLabel ??
- (input.newAccount === true
- ? `${service}-${randomUUID().slice(0, 8)}`
- : "default");
- target = `${config.apiUrl}/api/managed-agents/connections/link`;
- upstreamMethod = "POST";
- upstreamBody = JSON.stringify({ service, label });
- } else {
- sendJSON(response, 400, {
- error: {
- message: "Expected a list or request connection action",
- },
- });
- return;
- }
- } else if (url.pathname.startsWith("/openrouter/")) {
+ if (url.pathname.startsWith("/openrouter/")) {
target =
`${config.apiUrl}/api/managed-agents/openrouter` +
`${url.pathname.slice("/openrouter".length)}${url.search}`;
diff --git a/cli/src/project.test.ts b/cli/src/project.test.ts
index a03908d9..a7e2204e 100644
--- a/cli/src/project.test.ts
+++ b/cli/src/project.test.ts
@@ -55,9 +55,9 @@ test("init creates a multi-agent-ready project and React hello world app", async
};
assert.equal(packageJSON.scripts.dev, "opencomputer dev");
assert.equal(packageJSON.scripts["dev:web"], undefined);
- assert.equal(packageJSON.dependencies["@opencomputer/agent"], "^0.3.1");
+ assert.equal(packageJSON.dependencies["@opencomputer/agent"], "^0.4.0");
assert.equal(packageJSON.dependencies["@opencomputer/react"], "^0.1.0");
- assert.equal(packageJSON.devDependencies["@opencomputer/cli"], "^0.4.11");
+ assert.equal(packageJSON.devDependencies["@opencomputer/cli"], "^0.5.0");
assert.ok(packageJSON.devDependencies["@types/node"]);
const viteConfig = await readFile(resolve(root, "vite.config.ts"), "utf8");
assert.match(viteConfig, /command === "serve"/);
@@ -89,7 +89,6 @@ test("init creates a multi-agent-ready project and React hello world app", async
"tools",
"connections",
"skills",
- "channels",
"workspace",
"evals",
]) {
@@ -160,9 +159,7 @@ test("the code-first compiler records hook resources without config files", asyn
await writeFile(
resolve(initialized.agentRoot, "agent.ts"),
`import {
- connection,
defineMcpServer,
- useConnection,
useInput,
useMcpServer,
useModel,
@@ -170,11 +167,9 @@ test("the code-first compiler records hook resources without config files", asyn
useTool,
} from "@opencomputer/agent";
-const github = connection("github");
const docs = defineMcpServer({
id: "docs",
url: "https://mcp.example.com",
- connection: github,
});
export default function Agent() {
@@ -182,7 +177,6 @@ export default function Agent() {
useModel("anthropic/claude-sonnet-4.6");
useTool("search-docs");
useSubagent("researcher");
- useConnection(github);
if (input.text?.includes("docs")) useMcpServer(docs);
return "Help with the request.";
}
@@ -207,14 +201,10 @@ export default function Agent() {
assert.deepEqual(manifest, {
version: 2,
entry: "../agent.js",
- tools: [
- "opencomputer_connections_list",
- "opencomputer_connections_request",
- "search-docs",
- ],
- toolModules: ["../tools/opencomputer-connections.js"],
+ tools: ["search-docs"],
+ toolModules: [],
subagents: ["researcher"],
- connections: ["github"],
+ connections: [],
httpConnections: [],
mcpServers: ["docs"],
});
@@ -256,11 +246,10 @@ export const repository = defineTool({
);
await writeFile(
resolve(initialized.agentRoot, "agent.ts"),
- `import { useConnection, useTool } from "@opencomputer/agent";
-import { github, repository } from "./tools/github.js";
+ `import { useTool } from "@opencomputer/agent";
+import { repository } from "./tools/github.js";
export default function Agent() {
- useConnection(github);
useTool(repository);
return "Use GitHub when needed.";
}
@@ -327,7 +316,7 @@ export default function Agent() {
}
});
-test("the compiler packages OpenComputer tools for native OpenCode 2 registration", async () => {
+test("the compiler packages code-defined tools for native OpenCode 2 registration", async () => {
const parent = await mkdtemp(resolve(tmpdir(), "opencomputer-v2-tools-"));
const root = resolve(parent, "app");
try {
diff --git a/cli/src/project.ts b/cli/src/project.ts
index c831c6f4..752cdda1 100644
--- a/cli/src/project.ts
+++ b/cli/src/project.ts
@@ -90,104 +90,6 @@ export function agentIdFromName(value: string): string {
return id;
}
-function connectionControlToolSource(): string {
- return `import { defineTool } from "@opencomputer/agent";
-
-async function connectionControl(
- method: "GET" | "POST",
- body?: unknown,
-): Promise<unknown> {
- const base = process.env.OPENCOMPUTER_CONNECTIONS_URL;
- const token = process.env.OPENCOMPUTER_CONNECTION_TOKEN;
- if (!base || !token) {
- throw new Error("OpenComputer connections are unavailable");
- }
- const response = await fetch(
- \`\${base.replace(/\\\/$/, "")}/opencomputer/fetch\`,
- {
- method: "POST",
- headers: {
- authorization: \`Bearer \${token}\`,
- "content-type": "application/json",
- },
- body: JSON.stringify({
- action: method === "GET" ? "list" : "request",
- ...(body && typeof body === "object" ? body : {}),
- }),
- },
- );
- const responseText = await response.text();
- let result: {
- error?: { message?: string };
- message?: string;
- [key: string]: unknown;
- } | undefined;
- if (responseText) {
- try {
- const parsed: unknown = JSON.parse(responseText);
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
- result = parsed as {
- error?: { message?: string };
- message?: string;
- [key: string]: unknown;
- };
- }
- } catch {
- // Preserve the response text below so the user sees the upstream error.
- }
- }
- if (!response.ok) {
- throw new Error(
- result?.error?.message ??
- result?.message ??
- responseText ??
- "Connection request failed",
- );
- }
- if (!result) {
- throw new Error("Connection service returned an empty response");
- }
- return result;
-}
-
-export const list = defineTool({
- name: "opencomputer_connections_list",
- description:
- "List the connected accounts available to the current session identity. Use this to discover connection providers and aliases without exposing credentials.",
- input: {
- type: "object",
- properties: {},
- additionalProperties: false,
- },
- async run() {
- return await connectionControl("GET");
- },
-});
-
-export const request = defineTool({
- name: "opencomputer_connections_request",
- description:
- "Ask the current user to connect an account. Use gmail for an email account. Set newAccount=true when the user asks for another account of the same service. In a messaging channel OpenComputer privately sends the authorization link to that user; otherwise the result includes the link.",
- input: {
- type: "object",
- properties: {
- service: {
- type: "string",
- enum: ["gmail", "calendar", "drive", "sheets", "github"],
- },
- label: { type: "string" },
- newAccount: { type: "boolean" },
- },
- required: ["service"],
- additionalProperties: false,
- },
- async run({ input }) {
- return await connectionControl("POST", input);
- },
-});
-`;
-}
-
export async function writeManifest(
root: string,
manifest: AgentManifest,
@@ -349,56 +251,6 @@ export async function readProjectAgents(
);
}
-export async function addSlackChannel(root: string): Promise<string[]> {
- await mkdir(resolve(root, "channels"), { recursive: true });
- await mkdir(resolve(root, "slack"), { recursive: true });
- await writeFile(
- resolve(root, "channels", "slack.ts"),
- `export default {
- type: "slack",
- events: ["app_mention", "message.im"],
-};
-`,
- );
- const manifest = await readManifest(root);
- await writeFile(
- resolve(root, "slack", "manifest.json"),
- `${JSON.stringify(
- {
- _metadata: { major_version: 1, minor_version: 1 },
- display_information: {
- name: manifest.name,
- description: `Run the ${manifest.name} OpenComputer agent from Slack.`,
- background_color: "#0B1220",
- },
- features: {
- bot_user: { display_name: manifest.name, always_online: true },
- },
- oauth_config: {
- scopes: {
- bot: [
- "app_mentions:read",
- "assistant:write",
- "chat:write",
- "im:history",
- ],
- },
- },
- settings: {
- event_subscriptions: {
- bot_events: ["app_mention", "message.im"],
- },
- socket_mode_enabled: true,
- token_rotation_enabled: false,
- },
- },
- null,
- 2,
- )}\n`,
- );
- return ["channels/slack.ts", "slack/manifest.json"];
-}
-
export async function assertStarterTarget(directory: string): Promise<void> {
const root = resolve(directory);
if (!(await exists(root))) {
@@ -502,7 +354,7 @@ export default function Agent() {
deploy: "opencomputer deploy",
},
dependencies: {
- "@opencomputer/agent": "^0.3.1",
+ "@opencomputer/agent": "^0.4.0",
...(spa
? {
"@opencomputer/react": "^0.1.0",
@@ -512,7 +364,7 @@ export default function Agent() {
: {}),
},
devDependencies: {
- "@opencomputer/cli": "^0.4.11",
+ "@opencomputer/cli": "^0.5.0",
...(spa
? {
"@types/node": "^24.0.0",
@@ -1006,7 +858,6 @@ function id(value, kind) {
if (!normalized) throw new Error(kind + " requires a non-empty id");
return normalized;
}
-export const connection = (value) => Object.freeze({ kind: "connection", id: id(value, "connection") });
export const useSecret = (value) => {
const name = id(value, "useSecret");
if (!/^[A-Z][A-Z0-9_]{0,127}$/.test(name)) throw new Error("Invalid secret name " + JSON.stringify(name));
@@ -1063,7 +914,6 @@ export const useCurrentInput = useInput;
export const useModel = (model) => hooks().useModel(model);
export const useTool = (tool) => hooks().useTool(tool);
export const useSubagent = (agent) => hooks().useSubagent(agent);
-export const useConnection = (value) => hooks().useConnection(value);
export const useMcpServer = (server) => hooks().useMcpServer(server);
export const useSessionData = (key) => hooks().useSessionData(key);
`;
@@ -1094,14 +944,6 @@ the product or support surface presented to users.
issue trackers, or support channels.
- Use the question tool when structured clarification is useful. OpenComputer
delivers it through the current chat and resumes when the user replies.
-- Before saying an external account is unavailable, use the built-in
- OpenComputer connection tools to list or request the required connection.
-- When the user asks for another account of the same service, request a new
- account instead of returning the existing default connection.
-- If a connection request reports private-message delivery, tell the user to
- check their private messages. If it returns an authorization URL, show it.
-- If a connection tool fails, report its exact error. Do not invent alternate
- controls or third-party support instructions.
`,
);
@@ -1195,12 +1037,7 @@ the product or support surface presented to users.
resolve(runtime, "opencomputer-agent.js"),
agentApiRuntimeSource(),
);
- const toolSources: Array<{ filename: string; source: string }> = [
- {
- filename: "opencomputer-connections.ts",
- source: connectionControlToolSource(),
- },
- ];
+ const toolSources: Array<{ filename: string; source: string }> = [];
const sourceTools = resolve(root, "tools");
if (await exists(sourceTools)) {
const entries = await readdir(sourceTools, { withFileTypes: true });
@@ -1294,13 +1131,7 @@ the product or support surface presented to users.
].sort(),
toolModules: toolModules.sort(),
subagents: literalHookIds(agentSource, "useSubagent"),
- connections: [
- ...new Set([
- ...literalHookIds(agentSource, "connection"),
- ...literalHookIds(agentSource, "useConnection"),
- ...httpConnections.map((connection) => connection.id),
- ]),
- ].sort(),
+ connections: httpConnections.map((connection) => connection.id).sort(),
httpConnections,
mcpServers: [
...new Set([
@@ -1316,21 +1147,6 @@ the product or support surface presented to users.
return runtime;
}
-async function collectNames(root: string, type: "channels" | "connections") {
- try {
- return (
- await readdir(resolve(root, type), {
- withFileTypes: true,
- })
- )
- .filter((entry) => entry.isFile())
- .map((entry) => entry.name.replace(/\.[^.]+$/, "").toLowerCase())
- .sort();
- } catch {
- return [];
- }
-}
-
async function collectFiles(
root: string,
directory = root,
@@ -1358,28 +1174,22 @@ export async function buildAgentArtifact(
const startedAt = performance.now();
const manifest = await readManifest(root);
const runtime = await prepareAgent(root);
- const channels = await collectNames(root, "channels");
const reactive = JSON.parse(
await readFile(resolve(runtime, ".opencomputer", "reactive.json"), "utf8"),
) as { connections?: string[]; httpConnections?: HttpConnectionManifest[] };
- const connections = [
- ...new Set([
- ...(await collectNames(root, "connections")),
- ...(reactive.connections ?? []),
- ]),
- ].sort();
+ const connections = [...new Set(reactive.connections ?? [])].sort();
const httpConnections = reactive.httpConnections ?? [];
const body = Buffer.from(
JSON.stringify({
version: 1,
- channels,
+ channels: [],
files: await collectFiles(runtime),
}),
);
return {
agentId: agentId ?? manifest.id,
name: manifest.name,
- channels,
+ channels: [],
connections,
httpConnections,
body,
diff --git a/cli/src/slack.test.ts b/cli/src/slack.test.ts
deleted file mode 100644
index 6a69a48b..00000000
--- a/cli/src/slack.test.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import assert from "node:assert/strict";
-import { mkdtemp, readFile, rm, stat } from "node:fs/promises";
-import { tmpdir } from "node:os";
-import { resolve } from "node:path";
-import test from "node:test";
-
-import { runCommand } from "./commands.js";
-import {
- addSlackChannel,
- initializeAgentProject,
-} from "./project.js";
-import {
- ensureSlackHooks,
- slackManifest,
- writeRemoteSlackState,
-} from "./slack.js";
-
-test("Slack channel state renders local and remote manifests", async () => {
- const parent = await mkdtemp(resolve(tmpdir(), "opencomputer-slack-"));
- const root = resolve(parent, "research-agent");
- try {
- const { agentRoot } = await initializeAgentProject(root);
- await addSlackChannel(agentRoot);
- await ensureSlackHooks(agentRoot);
-
- const local = await slackManifest(agentRoot, "local");
- assert.equal(
- (local.settings as Record<string, unknown>).socket_mode_enabled,
- true,
- );
- assert.equal(
- (await stat(resolve(agentRoot, ".opencomputer", "slack-hook.mjs"))).isFile(),
- true,
- );
- assert.match(
- await readFile(resolve(agentRoot, ".slack", "hooks.json"), "utf8"),
- /@opencomputer|opencomputer/,
- );
-
- await writeRemoteSlackState(agentRoot, {
- version: 1,
- connectionId: "channel-1",
- agentId: "research-agent@production",
- webhookUrl: "https://example.com/slack/events",
- apiUrl: "https://example.com",
- });
- const remote = await slackManifest(agentRoot, "remote");
- const settings = remote.settings as Record<string, unknown>;
- const subscriptions = settings.event_subscriptions as Record<
- string,
- unknown
- >;
- assert.equal(settings.socket_mode_enabled, false);
- assert.equal(subscriptions.request_url, "https://example.com/slack/events");
- } finally {
- await rm(parent, { recursive: true, force: true });
- }
-});
-
-test("Slack hooks accept source metadata from the Slack CLI", async () => {
- const parent = await mkdtemp(resolve(tmpdir(), "opencomputer-slack-hook-"));
- const root = resolve(parent, "research-agent");
- const previousDirectory = process.cwd();
- try {
- const { agentRoot } = await initializeAgentProject(root);
- await addSlackChannel(agentRoot);
- process.chdir(agentRoot);
- await assert.doesNotReject(
- runCommand("slack-hook", ["manifest", `--source=${agentRoot}`], {
- json: false,
- }),
- );
- } finally {
- process.chdir(previousDirectory);
- await rm(parent, { recursive: true, force: true });
- }
-});
diff --git a/cli/src/slack.ts b/cli/src/slack.ts
deleted file mode 100644
index 3e8f0489..00000000
--- a/cli/src/slack.ts
+++ /dev/null
@@ -1,340 +0,0 @@
-import { spawn } from "node:child_process";
-import { access, mkdir, readFile, rm, writeFile } from "node:fs/promises";
-import { basename, dirname, resolve } from "node:path";
-
-import { findAgentRoot, readManifest } from "./project.js";
-
-export interface LocalSlackState {
- version: 1;
- appId: string;
- teamId: string;
- teamName?: string;
-}
-
-export interface RemoteSlackState {
- version: 1;
- connectionId: string;
- agentId: string;
- webhookUrl: string;
- apiUrl: string;
-}
-
-interface SlackAppEntry {
- app_id?: string;
- team_domain?: string;
- team_id?: string;
-}
-
-interface SlackAppsFile {
- apps?: Record<string, SlackAppEntry>;
- default?: string;
- [key: string]: unknown;
-}
-
-const OPENCOMPUTER_SLACK_HOOKS = {
- "get-manifest": "node .opencomputer/slack-hook.mjs manifest",
- start: "node .opencomputer/slack-hook.mjs start",
- deploy: "node .opencomputer/slack-hook.mjs deploy",
-} as const;
-
-const OPENCOMPUTER_SLACK_HOOK_BRIDGE = `#!/usr/bin/env node
-import { spawn } from "node:child_process";
-
-const [action, ...extraArgs] = process.argv.slice(2);
-if (!["manifest", "start", "deploy"].includes(action)) {
- process.stderr.write("Unsupported OpenComputer Slack hook\\n");
- process.exit(1);
-}
-
-const cliEntry = process.env.OPENCOMPUTER_SLACK_CLI_ENTRY;
-const command = cliEntry
- ? process.env.OPENCOMPUTER_SLACK_NODE_EXECUTABLE || process.execPath
- : process.platform === "win32"
- ? "npx.cmd"
- : "npx";
-const args = cliEntry
- ? [cliEntry, "slack-hook", action, ...extraArgs]
- : [
- "-y",
- "@opencomputer/cli@latest",
- "slack-hook",
- action,
- ...extraArgs,
- ];
-const child = spawn(command, args, { stdio: "inherit", env: process.env });
-for (const signal of ["SIGINT", "SIGTERM"]) {
- process.once(signal, () => child.kill(signal));
-}
-child.once("error", (error) => {
- process.stderr.write(\`opencomputer: \${error.message}\\n\`);
- process.exit(1);
-});
-child.once("exit", (code) => process.exit(code ?? 1));
-`;
-
-async function exists(path: string): Promise<boolean> {
- try {
- await access(path);
- return true;
- } catch {
- return false;
- }
-}
-
-export function localSlackStatePath(root: string): string {
- return resolve(root, ".opencomputer", "channels", "slack.local.json");
-}
-
-export function remoteSlackStatePath(root: string): string {
- return resolve(root, ".opencomputer", "channels", "slack.remote.json");
-}
-
-export async function readLocalSlackState(
- root: string,
-): Promise<LocalSlackState | undefined> {
- try {
- return JSON.parse(
- await readFile(localSlackStatePath(root), "utf8"),
- ) as LocalSlackState;
- } catch {
- return undefined;
- }
-}
-
-export async function readRemoteSlackState(
- root: string,
-): Promise<RemoteSlackState | undefined> {
- try {
- return JSON.parse(
- await readFile(remoteSlackStatePath(root), "utf8"),
- ) as RemoteSlackState;
- } catch {
- return undefined;
- }
-}
-
-export async function writeRemoteSlackState(
- root: string,
- state: RemoteSlackState,
-): Promise<void> {
- const path = remoteSlackStatePath(root);
- await mkdir(dirname(path), { recursive: true });
- await writeFile(path, `${JSON.stringify(state, null, 2)}\n`, {
- mode: 0o600,
- });
-}
-
-export async function clearSlackState(
- root: string,
- mode: "local" | "remote",
-): Promise<void> {
- await rm(
- mode === "local" ? localSlackStatePath(root) : remoteSlackStatePath(root),
- { force: true },
- );
-}
-
-export async function ensureSlackHooks(root: string): Promise<void> {
- const path = resolve(root, ".slack", "hooks.json");
- await mkdir(dirname(path), { recursive: true });
- let existing: Record<string, unknown> = {};
- try {
- const parsed: unknown = JSON.parse(await readFile(path, "utf8"));
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
- existing = parsed as Record<string, unknown>;
- }
- } catch {
- // A new Slack project does not have hooks yet.
- }
- const hooks =
- existing.hooks &&
- typeof existing.hooks === "object" &&
- !Array.isArray(existing.hooks)
- ? (existing.hooks as Record<string, unknown>)
- : {};
- const startHook = hooks.start;
- const managed =
- startHook === undefined ||
- (typeof startHook === "string" &&
- (startHook.includes("@opencomputer/cli") ||
- startHook.includes(".opencomputer/slack-hook.mjs")));
- if (!managed) return;
- const config =
- existing.config &&
- typeof existing.config === "object" &&
- !Array.isArray(existing.config)
- ? (existing.config as Record<string, unknown>)
- : {};
- await writeFile(
- path,
- `${JSON.stringify(
- {
- ...existing,
- hooks: { ...hooks, ...OPENCOMPUTER_SLACK_HOOKS },
- config: { ...config, "sdk-managed-connection-enabled": true },
- },
- null,
- 2,
- )}\n`,
- );
- const bridge = resolve(root, ".opencomputer", "slack-hook.mjs");
- await mkdir(dirname(bridge), { recursive: true });
- await writeFile(bridge, OPENCOMPUTER_SLACK_HOOK_BRIDGE, { mode: 0o755 });
-}
-
-export async function requireSlackAgentRoot(): Promise<string> {
- const root = await findAgentRoot();
- if (!root || !(await exists(resolve(root, "channels", "slack.ts")))) {
- throw new Error(
- "Run `opencomputer channels add slack` inside an agent repository first.",
- );
- }
- await ensureSlackHooks(root);
- return root;
-}
-
-export async function slackManifest(
- root: string,
- mode: "local" | "remote",
-): Promise<Record<string, unknown>> {
- const manifest = await readManifest(root);
- const remote =
- mode === "remote" ? await readRemoteSlackState(root) : undefined;
- if (mode === "remote" && !remote?.webhookUrl) {
- throw new Error(
- "Run `opencomputer channels connect slack --remote` first.",
- );
- }
- const subscriptions: Record<string, unknown> = {
- bot_events: [
- "app_mention",
- "app_context_changed",
- "app_home_opened",
- "message.im",
- ],
- };
- if (remote) subscriptions.request_url = remote.webhookUrl;
- return {
- _metadata: { major_version: 1, minor_version: 1 },
- display_information: {
- name: manifest.name || basename(root),
- description: `Run the ${manifest.name} OpenComputer agent from Slack.`,
- background_color: "#0B1220",
- },
- features: {
- agent_view: {
- agent_description: `Work with the ${manifest.name} agent.`,
- suggested_prompts: [
- {
- title: "Get started",
- message: "Tell me what you can help with.",
- },
- ],
- },
- bot_user: {
- display_name: manifest.name,
- always_online: true,
- },
- },
- oauth_config: {
- scopes: {
- bot: [
- "app_mentions:read",
- "assistant:write",
- "chat:write",
- "im:history",
- ],
- },
- },
- settings: {
- event_subscriptions: subscriptions,
- org_deploy_enabled: false,
- socket_mode_enabled: mode === "local",
- token_rotation_enabled: false,
- },
- };
-}
-
-export async function runSlackCli(
- root: string,
- args: string[],
- mode: "local" | "remote",
-): Promise<void> {
- const cliEntry = process.argv[1];
- await new Promise<void>((resolvePromise, reject) => {
- const child = spawn("slack", args, {
- cwd: root,
- stdio: "inherit",
- env: {
- ...process.env,
- ...(cliEntry
- ? {
- OPENCOMPUTER_SLACK_CLI_ENTRY: cliEntry,
- OPENCOMPUTER_SLACK_NODE_EXECUTABLE: process.execPath,
- }
- : {}),
- OPENCOMPUTER_SLACK_MODE: mode,
- },
- });
- child.once("error", (error) => {
- reject(
- error instanceof Error && "code" in error && error.code === "ENOENT"
- ? new Error(
- "Slack CLI is required. Install it from https://docs.slack.dev/tools/slack-cli/.",
- )
- : error,
- );
- });
- child.once("exit", (code, signal) => {
- if (code === 0) resolvePromise();
- else {
- reject(
- new Error(
- `Slack CLI exited ${signal ? `with ${signal}` : `with code ${String(code)}`}`,
- ),
- );
- }
- });
- });
-}
-
-export async function captureLocalSlackState(
- root: string,
-): Promise<LocalSlackState> {
- const candidates = [
- resolve(root, ".slack", "apps.dev.json"),
- resolve(root, ".slack", "apps.json"),
- ];
- for (const path of candidates) {
- if (!(await exists(path))) continue;
- const parsed = JSON.parse(await readFile(path, "utf8")) as SlackAppsFile;
- const entries = parsed.apps
- ? Object.values(parsed.apps)
- : Object.values(parsed).filter((entry): entry is SlackAppEntry =>
- Boolean(
- entry &&
- typeof entry === "object" &&
- "app_id" in entry &&
- "team_id" in entry,
- ),
- );
- const selected =
- entries.find((entry) => entry.team_domain === parsed.default) ??
- entries[0];
- if (selected?.app_id && selected.team_id) {
- const state: LocalSlackState = {
- version: 1,
- appId: selected.app_id,
- teamId: selected.team_id,
- teamName: selected.team_domain,
- };
- const output = localSlackStatePath(root);
- await mkdir(dirname(output), { recursive: true });
- await writeFile(output, `${JSON.stringify(state, null, 2)}\n`, {
- mode: 0o600,
- });
- return state;
- }
- }
- throw new Error("Slack CLI did not persist the local app installation.");
-}
diff --git a/create-start/package.json b/create-start/package.json
index 30b185b8..172213b7 100644
--- a/create-start/package.json
+++ b/create-start/package.json
@@ -1,6 +1,6 @@
{
"name": "@opencomputer/create-start",
- "version": "0.4.11",
+ "version": "0.5.0",
"description": "Create a hello-world OpenComputer agent application.",
"type": "module",
"bin": {
@@ -18,7 +18,7 @@
"node": ">=22.0.0"
},
"dependencies": {
- "@opencomputer/cli": "0.4.11"
+ "@opencomputer/cli": "0.5.0"
},
"publishConfig": {
"access": "public"
diff --git a/docs/agents/channels.mdx b/docs/agents/channels.mdx
deleted file mode 100644
index cefcf29c..00000000
--- a/docs/agents/channels.mdx
+++ /dev/null
@@ -1,55 +0,0 @@
----
-title: "Channels"
-description: "Connect a deployed agent alias to Slack"
----
-
-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
-
-<Steps>
- <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">
- Open the project in the OpenComputer dashboard, choose the agent and
- environment, then select **Channels**.
- </Step>
- <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">
- Enter the requested Slack application values and install the app. Secrets
- are stored by OpenComputer rather than committed to the project.
- </Step>
-</Steps>
-
-Direct messages and supported Slack threads create or resume isolated agent
-sessions. Channel sessions appear in the project's **Sessions** view.
-
-## React to channel input
-
-Use the same agent function for every input source:
-
-```tsx
-import { useInput } from "@opencomputer/agent";
-
-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.";
-}
-```
-
-## User identity and 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.
-
-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.mdx
deleted file mode 100644
index 64404e6e..00000000
--- a/docs/agents/connections.mdx
+++ /dev/null
@@ -1,76 +0,0 @@
----
-title: "Connections and MCP"
-description: "Attach user-scoped services and managed MCP servers from agent code"
----
-
-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.
-
-## Request a connection from code
-
-```tsx
-import { connection, useConnection } from "@opencomputer/agent";
-
-const github = connection("github");
-
-export default function Agent() {
- useConnection(github);
- return "Help the user inspect and work with their GitHub account.";
-}
-```
-
-Connection declarations are safe to commit. They contain identifiers, not
-OAuth access tokens.
-
-## Authorize an account
-
-```bash
-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
-```
-
-Remove an authorization by alias or connection ID:
-
-```bash
-npx opencomputer connection remove work
-```
-
-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.";
-}
-```
-
-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.
-
-## Missing authorizations
-
-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/hooks.mdx b/docs/agents/hooks.mdx
index caa733ed..483c3511 100644
--- a/docs/agents/hooks.mdx
+++ b/docs/agents/hooks.mdx
@@ -45,7 +45,6 @@ agent function.
| `useTool(tool)` | Exposes a named or code-defined tool | [Tools](/agents/tools) |
| `useMcpServer(server)` | Exposes tools from a managed HTTPS MCP server | [MCP servers](/agents/mcp) |
| `useSubagent(agent)` | Makes another project agent available for delegation | [Subagents](/agents/subagents) |
-| `useConnection(connection)` | Requires a managed user or HTTP connection | [Connections](/agents/connections) |
| `useSessionData<T>(key)` | Reads a durable value associated with the session | [Session data](/agents/session-data) |
[Skills](/agents/skills) are also agent capabilities, but they are discovered
@@ -57,16 +56,9 @@ Hooks are ordinary synchronous functions. Group related capabilities in a
custom hook when several agents use the same setup:
```tsx
-import {
- connection,
- useConnection,
- useTool,
-} from "@opencomputer/agent";
-
-const github = connection("github");
+import { useTool } from "@opencomputer/agent";
function useGitHubResearch() {
- useConnection(github);
useTool("github-search");
return "Check GitHub before making claims about repositories or issues.";
}
diff --git a/docs/agents/inputs.mdx b/docs/agents/inputs.mdx
index 8f6466d9..42dd6e13 100644
--- a/docs/agents/inputs.mdx
+++ b/docs/agents/inputs.mdx
@@ -26,7 +26,6 @@ export default function Agent() {
interface AgentInput {
readonly source:
| "user"
- | "channel"
| "schedule"
| "webhook"
| "subagent"
@@ -48,7 +47,7 @@ before use.
## Adapt to the source
-One agent can handle direct user messages, channels, schedules, webhooks, and
+One agent can handle direct user messages, schedules, webhooks, and
subagent calls without separate definitions:
```tsx
@@ -58,8 +57,6 @@ export default function Agent() {
const input = useInput();
switch (input.source) {
- case "channel":
- return "Reply naturally and keep the answer suitable for a shared chat.";
case "schedule":
return "Run the scheduled review and summarize anything that changed.";
case "webhook":
diff --git a/docs/agents/mcp.mdx b/docs/agents/mcp.mdx
index 41cc01d0..d4de7e2e 100644
--- a/docs/agents/mcp.mdx
+++ b/docs/agents/mcp.mdx
@@ -38,25 +38,34 @@ close the connection itself.
| --- | --- | --- |
| `id` | yes | Stable ID for the server in the deployment |
| `url` | yes | HTTPS MCP endpoint |
-| `connection` | no | Managed connection used to authorize the server |
+| `connection` | no | Secret-backed HTTP connection used to authorize the server |
`useMcpServer()` accepts either a definition or an existing server ID.
## Attach authorization
-Reference a managed user connection when the server requires authorization:
+Reference a secret-backed HTTP connection when the server requires
+authorization:
```tsx
import {
- connection,
+ bearer,
+ defineConnection,
defineMcpServer,
+ useSecret,
useMcpServer,
} from "@opencomputer/agent";
-const github = connection("github");
+const github = defineConnection({
+ id: "github-mcp-auth",
+ origin: "https://api.githubcopilot.com",
+ headers: {
+ Authorization: bearer(useSecret("GITHUB_PAT")),
+ },
+});
const githubMcp = defineMcpServer({
id: "github",
- url: "https://mcp.example.com/github",
+ url: "https://api.githubcopilot.com/mcp/",
connection: github,
});
@@ -66,10 +75,9 @@ export default function Agent() {
}
```
-The connection declaration contains an identifier, not an OAuth token. Each
-user authorizes their own account through OpenComputer. See
-[Connections and MCP](/agents/connections) for authorization commands and
-missing-connection behavior.
+The declaration contains only a secret reference. Set the secret with
+`opencomputer secrets set GITHUB_PAT`; its value is injected only into requests
+to the declared origin. See [Secrets and managed egress](/agents/secrets).
## Attach MCP conditionally
diff --git a/docs/agents/overview.mdx b/docs/agents/overview.mdx
index 4e15f19a..f6e9eaf4 100644
--- a/docs/agents/overview.mdx
+++ b/docs/agents/overview.mdx
@@ -23,8 +23,8 @@ export default function Agent() {
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.
+the managed agent loop. Hooks attach the model, tools, MCP servers, and
+subagents needed for that render.
<CardGroup cols={2}>
<Card title="Projects" icon="folder" href="/agents/projects">
@@ -70,18 +70,16 @@ same command also starts it locally.
## What is available today
- TypeScript projects containing one or more agents
-- reactive instructions, model selection, tools, subagents, connections, MCP
+- reactive instructions, model selection, tools, subagents, MCP
servers, input metadata, and session data reads
- cloud development with file watching and automatic synchronization
- an optional React client using `@opencomputer/react` for 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
- project-level secrets with optional agent overrides and managed egress
- indexed runtime and egress logs available from the CLI
-- Slack channels connected to deployed agent aliases
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.
+belongs in the repository under `opencomputer/`; credentials remain managed by
+OpenComputer.
diff --git a/docs/agents/projects.mdx b/docs/agents/projects.mdx
index 3c9abbd6..73467a9e 100644
--- a/docs/agents/projects.mdx
+++ b/docs/agents/projects.mdx
@@ -95,7 +95,7 @@ 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
+- **Sessions** created through the dashboard, React client, or API
- **Channels** connected to a deployed agent alias
Project and agent behavior remains code-owned. The dashboard is for selection,
diff --git a/docs/agents/quickstart.mdx b/docs/agents/quickstart.mdx
index 577dbed1..15fdd17d 100644
--- a/docs/agents/quickstart.mdx
+++ b/docs/agents/quickstart.mdx
@@ -77,6 +77,6 @@ alias. Development remains available for subsequent edits.
Add more agents and understand project bindings.
</Card>
<Card title="Reactive agents" icon="code" href="/agents/reactive-agents">
- Add models, tools, connections, MCP servers, and subagents.
+ Add models, tools, MCP servers, and subagents.
</Card>
</CardGroup>
diff --git a/docs/agents/reactive-agents.mdx b/docs/agents/reactive-agents.mdx
index 41dd5d8a..4d39a03d 100644
--- a/docs/agents/reactive-agents.mdx
+++ b/docs/agents/reactive-agents.mdx
@@ -27,12 +27,11 @@ needs it.
| `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`,
+caused the current render. Its `source` can be `user`, `schedule`,
`webhook`, `subagent`, or `system`.
## Conditional configuration
diff --git a/docs/agents/secrets.mdx b/docs/agents/secrets.mdx
index 7a9e4886..91339be0 100644
--- a/docs/agents/secrets.mdx
+++ b/docs/agents/secrets.mdx
@@ -13,7 +13,6 @@ deployment manifests, runtime environment variables, logs, or API responses.
import {
bearer,
defineConnection,
- useConnection,
useSecret,
} from "@opencomputer/agent";
@@ -28,7 +27,6 @@ const github = defineConnection({
});
export default function Agent() {
- useConnection(github);
return "Use GitHub when it helps answer the request.";
}
```
diff --git a/docs/agents/session-data.mdx b/docs/agents/session-data.mdx
index aaf6d83b..9d3fadc9 100644
--- a/docs/agents/session-data.mdx
+++ b/docs/agents/session-data.mdx
@@ -31,7 +31,7 @@ The key is a string. Pass a TypeScript type argument for the expected value:
```tsx
const locale = useSessionData<string>("locale");
const approved = useSessionData<boolean>("brief_approved");
-const channels = useSessionData<readonly string[]>("channels");
+const tags = useSessionData<readonly string[]>("tags");
```
The hook returns `undefined` when the key is absent. Handle that case rather
diff --git a/docs/agents/sessions.mdx b/docs/agents/sessions.mdx
index 0408d726..ef442d44 100644
--- a/docs/agents/sessions.mdx
+++ b/docs/agents/sessions.mdx
@@ -1,6 +1,6 @@
---
title: "Sessions and playground"
-description: "Create durable conversations from React, the dashboard, channels, or the CLI"
+description: "Create durable conversations from React, the dashboard, or the CLI"
---
A session is a durable conversation with a deployed agent. Each turn appends
@@ -27,8 +27,8 @@ 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.
+API appear under **Sessions**, where their durable turn history can be
+inspected.
## CLI
@@ -55,15 +55,6 @@ 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.
+Inside an agent, `useInput().source` identifies how the current work arrived.
+This lets the same agent adapt to React, playground, API, schedule, webhook,
+subagent, and system inputs without separate agent definitions.
diff --git a/docs/docs.json b/docs/docs.json
index b982ab8b..a7a890e1 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -42,10 +42,8 @@
"agents/subagents",
"agents/session-data",
"agents/sessions",
- "agents/connections",
"agents/secrets",
- "agents/logs",
- "agents/channels"
+ "agents/logs"
]
},
{
diff --git a/docs/llms.txt b/docs/llms.txt
index 1d43f789..bdcfe029 100644
--- a/docs/llms.txt
+++ b/docs/llms.txt
@@ -1,13 +1,13 @@
# OpenComputer Serverless Agents
-> Build, test, connect, and deploy serverless agents as code with OpenComputer.
+> Build, test, and deploy serverless agents as code with OpenComputer.
## Serverless Agents
-- [Overview](https://docs.opencomputer.dev/agents/overview.md): Build, test, connect, and deploy agents as code.
+- [Overview](https://docs.opencomputer.dev/agents/overview.md): Build, test, and deploy agents as code.
- [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.
+- [Reactive agents](https://docs.opencomputer.dev/agents/reactive-agents.md): Render instructions, models, tools, subagents, and MCP servers from code.
- [Agent hooks](https://docs.opencomputer.dev/agents/hooks.md): Compose agent capabilities with reactive hooks.
- [Inputs](https://docs.opencomputer.dev/agents/inputs.md): Read text, structured payloads, and input sources with `useInput()`.
- [Models](https://docs.opencomputer.dev/agents/models.md): Select a managed model with `useModel()`.
@@ -17,10 +17,8 @@
- [Subagents](https://docs.opencomputer.dev/agents/subagents.md): Let an agent delegate focused work with `useSubagent()`.
- [Session data](https://docs.opencomputer.dev/agents/session-data.md): Read durable per-session values with `useSessionData()`.
- [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.
- [Secrets and managed egress](https://docs.opencomputer.dev/agents/secrets.md): Store scoped secrets and inject them only into declared outbound requests.
- [Logs](https://docs.opencomputer.dev/agents/logs.md): Inspect and follow runtime and managed-egress logs.
-- [Channels](https://docs.opencomputer.dev/agents/channels.md): Connect deployed agents to Slack.
## Examples