An open-source, faster Devin alternative
TypeScript
fix(agent-urls): close public surface gaps
Igor Zalutski2d82003e9ffb
diff --git a/cmd/oc/internal/commands/agent.go b/cmd/oc/internal/commands/agent.goindex 95e0834e..5a04952e 100644--- a/cmd/oc/internal/commands/agent.go+++ b/cmd/oc/internal/commands/agent.go@@ -2,8 +2,9 @@ package commands// The `oc agent` command family, rebuilt on the v3 Durable Agent Sessions API// (/v3/agents/*). The legacy v1 managed-agents verbs (channels/packages/chat)-// were removed wholesale — agents are prompt+model+skills behaviors deployed-// as immutable revisions, a different model entirely.+// were removed wholesale — agents are reusable behaviors deployed as numbered+// revisions, a different model entirely. Built-in runtimes use prompt + model+// + skills; framework runtimes such as Flue carry behavior in their app.//// Verbs (each in its own file):// agent.go — parent command, shared response types, helpers, registration@@ -165,8 +166,9 @@ var agentCmd = &cobra.Command{Use: "agent",Short: "Create, deploy, and manage agents",Long: "Manage Durable Agent Sessions agents on OpenComputer.\n\n" +- "An agent is a prompt + model + skills behavior. Deploying it produces an\n" +- "immutable, numbered revision; the active revision is what new sessions run.\n" ++ "An agent is reusable behavior for durable sessions. Built-in agents combine\n" ++ "a prompt, model, and skills; Flue agents deploy a compiled app. Deploying\n" ++ "produces a numbered revision; the active revision is what new sessions run.\n" +"Deploy from a local directory (`oc agent deploy`) or link a GitHub repo for\n" +"push-to-deploy (`oc agent link`).",}diff --git a/cmd/oc/internal/commands/agent_deploy.go b/cmd/oc/internal/commands/agent_deploy.goindex 576b35ee..12870b5f 100644--- a/cmd/oc/internal/commands/agent_deploy.go+++ b/cmd/oc/internal/commands/agent_deploy.go@@ -326,7 +326,7 @@ func printDeployProgress(state string) {var agentDeployCmd = &cobra.Command{Use: "deploy [dir]",- Short: "Deploy an agent from a directory (agent.toml + prompt.md + skills/)",+ Short: "Deploy an agent from a local directory",Example: " oc agent deploy # deploy the agent.toml in the current directory\n" +" oc agent deploy ./agents/triage # deploy a specific directory\n" +" oc agent deploy --no-activate # stage a revision without making it active\n" +@@ -746,7 +746,7 @@ func registerAgentDeploy() {agentDeployCmd.Flags().String("agent", "", "Target agent id or name (else the manifest's [agent].id / name)")agentDeployCmd.Flags().Bool("no-activate", false, "Create the revision without activating it (stage)")agentDeployCmd.Flags().String("idempotency-key", "", "CI-safe key: a retry with the same key returns the same deployment")- agentDeployCmd.Flags().Int("timeout", 180, "Seconds to wait for a flue deploy to boot-verify (poll to terminal state)")+ agentDeployCmd.Flags().Int("timeout", 180, "Seconds to wait for a Flue deploy to boot-verify (poll to terminal state)")agentDeployCmd.Flags().Bool("verbose", false, "Show full framework build output")for _, c := range []*cobra.Command{agentRevisionsCmd, agentRollbackCmd, agentStatusCmd, agentLinkCmd, agentUnlinkCmd, agentDeploymentsCmd, agentDeploymentCmd} {diff --git a/cmd/oc/internal/commands/session.go b/cmd/oc/internal/commands/session.goindex 678a7b11..ce972b6c 100644--- a/cmd/oc/internal/commands/session.go+++ b/cmd/oc/internal/commands/session.go@@ -5,6 +5,7 @@ package commands// (which manages the behavior); sessions are addressed by id.import (+ "encoding/json""fmt""strings"@@ -136,11 +137,17 @@ var sessionGetCmd = &cobra.Command{if err != nil {return err}+ var raw json.RawMessagevar s Session- if err := sc.Get(cmd.Context(), "/v3/sessions/"+args[0], &s); err != nil {+ if err := sc.Get(cmd.Context(), "/v3/sessions/"+args[0], &raw); err != nil {return err}- printer.Print(s, func() {+ if err := json.Unmarshal(raw, &s); err != nil {+ return fmt.Errorf("decode session: %w", err)+ }+ // Keep the human view compact, but preserve the complete server response+ // for automation: usage, cursors, limits, and future additive fields.+ printer.Print(raw, func() {fmt.Printf("ID: %s\n", s.ID)fmt.Printf("Status: %s\n", s.Status)fmt.Printf("Agent: %s\n", s.AgentID)diff --git a/cmd/oc/internal/commands/session_test.go b/cmd/oc/internal/commands/session_test.goindex 23a2af9a..9af88275 100644--- a/cmd/oc/internal/commands/session_test.go+++ b/cmd/oc/internal/commands/session_test.go@@ -1,6 +1,17 @@package commands-import "testing"+import (+ "bytes"+ "context"+ "encoding/json"+ "net/http"+ "net/http/httptest"+ "testing"++ "github.com/opensandbox/opensandbox/cmd/oc/internal/client"+ "github.com/opensandbox/opensandbox/cmd/oc/internal/output"+ "github.com/spf13/cobra"+)func TestSessionCreateDoesNotExposeRevisionFlag(t *testing.T) {if flag := sessionCreateCmd.Flags().Lookup("revision"); flag != nil {@@ -8,6 +19,56 @@ func TestSessionCreateDoesNotExposeRevisionFlag(t *testing.T) {}}+func TestSessionGetJSONPreservesCompleteServerResponse(t *testing.T) {+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if r.URL.Path != "/v3/sessions/ses_test" {+ http.NotFound(w, r)+ return+ }+ w.Header().Set("Content-Type", "application/json")+ _, _ = w.Write([]byte(`{+ "id":"ses_test","status":"idle","agent_id":"agt_test","created_at":"2026-07-22T00:00:00Z",+ "head":7,"input_cursor":7,"last_turn":{"id":"trn_test","state":"ok"},+ "usage":{"active_seconds":3,"reported_turns":1,"unreported_turns":0,"complete":true,"tokens":42},+ "future_field":{"kept":true}+ }`))+ }))+ defer server.Close()++ cmd := &cobra.Command{}+ cmd.SetContext(client.WithSessionsClient(+ context.Background(),+ client.NewSessionsAPI(server.URL, "test-key"),+ ))++ previousPrinter, previousJSON := printer, jsonOutput+ var out bytes.Buffer+ printer = output.New(true)+ printer.W = &out+ jsonOutput = true+ defer func() {+ printer = previousPrinter+ jsonOutput = previousJSON+ }()++ if err := sessionGetCmd.RunE(cmd, []string{"ses_test"}); err != nil {+ t.Fatalf("session get: %v", err)+ }+ var got map[string]any+ if err := json.Unmarshal(out.Bytes(), &got); err != nil {+ t.Fatalf("decode command output: %v\n%s", err, out.String())+ }+ if got["head"] != float64(7) || got["input_cursor"] != float64(7) {+ t.Fatalf("session cursors were dropped: %#v", got)+ }+ if got["usage"].(map[string]any)["tokens"] != float64(42) {+ t.Fatalf("session usage was dropped: %#v", got)+ }+ if got["future_field"].(map[string]any)["kept"] != true {+ t.Fatalf("unknown server fields were dropped: %#v", got)+ }+}+func TestParseSources(t *testing.T) {ok := []struct {in []stringdiff --git a/docs/agent-sessions/agent-urls.mdx b/docs/agent-sessions/agent-urls.mdxindex 55b1ca0c..22395b3e 100644--- a/docs/agent-sessions/agent-urls.mdx+++ b/docs/agent-sessions/agent-urls.mdx@@ -123,6 +123,10 @@ The Agent URL has two application routes:| `POST /` | OpenComputer org API key | `202` receipt with a session client token || `POST /hooks/<token>` | Hook URL itself | `200` receipt without session access |+Opening the root URL in a browser shows a static usage guide. The page is+derived from the hostname only: it does not look up the agent or prove that the+agent exists.+Queries, redirects, trailing path variants, and every other route are rejected.Root invocation is server-to-server and does not advertise browser CORS.diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdxindex e02d214b..3236139c 100644--- a/docs/agent-sessions/api-reference.mdx+++ b/docs/agent-sessions/api-reference.mdx@@ -27,7 +27,7 @@ oc agent build --dir . --check-only --json # validate a Flue app without creden`idempotency_key` → `idempotencyKey`); the wire shapes below are raw JSON.Opaque blobs — session `metadata`, event `refs`/`raw` — pass through**verbatim**; everything else (incl. event `body`) is camelCased. The CLI- prints a table, or raw JSON with `--json`.+ prints a table, or machine-readable JSON with `--json`.</Note>## Agent URLs and Hooks@@ -655,7 +655,7 @@ the current active revision remains unchanged.| Command | Purpose || ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |-| `oc agent deploy [dir] [--agent <id\|name>] [--no-activate]` | Bundle a local directory → inline deployment. |+| `oc agent deploy [dir] [--agent <id\|name>] [--no-activate] [--verbose]` | Bundle a local directory → inline deployment; stream framework build output with `--verbose`. || `oc agent build --dir <dir> [--check-only] [--target cloudflare] [--output <dir>]` | Validate or build a Flue artifact without fetching, installing, authenticating, or deploying. || `oc agent deployments [--agent <id>]` · `oc agent deployments get <id>` | History · one deployment. |diff --git a/docs/agent-sessions/flue.mdx b/docs/agent-sessions/flue.mdxindex 1cfece63..86e523fd 100644--- a/docs/agent-sessions/flue.mdx+++ b/docs/agent-sessions/flue.mdx@@ -150,9 +150,9 @@ npm install# The agent is created from agent.toml when it does not exist yet.oc agent deploy-oc session create \- --agent support-triage \- --input "Order 2203 arrived with a torn shoulder strap. What happens next?"+# The deploy result prints the permanent Agent URL and this next command.+oc agent invoke support-triage \+ --data '{"message":"Order 2203 arrived with a torn shoulder strap. What happens next?"}'```Continue the session with `oc session steer <session-id> "..."`, inspect it with@@ -379,6 +379,10 @@ the `queued`, `fetching`, `validating`, `installing`, `building`, `uploading`, `5. Keeps the deployment in `verifying` until the exact live Worker returns two consecutive healthyresponses. Only then does the CLI report the revision as ready.+Successful framework build output stays quiet so the deployment result remains+scannable. Pass `--verbose` to stream it; if the build fails, the CLI replays+the captured output automatically.+<Warning>Flue currently has one live Worker per agent. Uploading a deployment changes the code used by new andexisting sessions before revision verification finishes. There is no isolated staged Worker, canarydiff --git a/docs/agent-sessions/overview.mdx b/docs/agent-sessions/overview.mdxindex e5247203..9ed67b27 100644--- a/docs/agent-sessions/overview.mdx+++ b/docs/agent-sessions/overview.mdx@@ -73,6 +73,9 @@ Use sessions for long-running or interactive agents. For a one-shot command, use<Card title="Session lifecycle" icon="book" href="/agent-sessions/sessions">Statuses, events, results, and limits.</Card>+ <Card title="HTTP invocation" icon="link" href="/agent-sessions/agent-urls">+ Invoke an agent from your backend or create a scoped Hook URL for an external system.+ </Card><Card title="Repos & GitHub" icon="github" href="/agent-sessions/repos">Private repo checkout with GitHub access kept outside the agent sandbox.</Card>diff --git a/docs/reference/cli/agent.mdx b/docs/reference/cli/agent.mdxindex 1a0bed5b..a299864a 100644--- a/docs/reference/cli/agent.mdx+++ b/docs/reference/cli/agent.mdx@@ -23,6 +23,10 @@ follow/steer commands. It generates one idempotency key and keeps it stableacross automatic retries; supply your own key when separate command runs mustconverge.+With `--json`, the output is the complete acceptance receipt, including the+one-hour session client token and canonical event/message links. Treat that+output as a session-scoped credential.+Use `oc session create` instead when you need model, source, destination, orper-session limit overrides.diff --git a/sdks/typescript/README.md b/sdks/typescript/README.mdindex 5ffeda16..d2f57e5a 100644--- a/sdks/typescript/README.md+++ b/sdks/typescript/README.md@@ -1,6 +1,6 @@# @opencomputer/sdk-The official TypeScript SDK for [OpenComputer](https://github.com/diggerhq/opensandbox): **cloud sandboxes** and **Durable Agent Sessions** (managed background agents).+The official TypeScript SDK for [OpenComputer](https://github.com/diggerhq/opencomputer): **cloud sandboxes** and **Durable Agent Sessions** (managed background agents).> This one package covers both surfaces — install **`@opencomputer/sdk`**. (The older `@opencomputer/agents-sdk` is superseded; use this instead.)@@ -66,6 +66,40 @@ if (delivery.type === "turn.completed") {}```+### Invoke through an Agent URL++Every agent has a permanent HTTP address. Use it from a trusted backend with+your org API key; the accepted response includes a session-scoped token for+streaming or steering that session.++```typescript+const agent = await oc.agents.get("agt_...");+const response = await fetch(`${agent.invokeUrl}/`, {+ method: "POST",+ headers: {+ Authorization: `Bearer ${process.env.OPENCOMPUTER_API_KEY}`,+ "Content-Type": "application/json",+ "Idempotency-Key": "incoming-event-id",+ },+ body: JSON.stringify({ task: "Review PR #42" }),+});+const receipt = await response.json();+console.log(receipt.session.id);+```++For an external system that cannot hold an org key, create an independently+revocable Hook URL. The complete URL is returned only once.++```typescript+const created = await oc.agents.hooks.create(agent.id, {+ name: "grafana-prod",+});+console.log(created.hookUrl);+```++[Agent URL guide](https://docs.opencomputer.dev/agent-sessions/agent-urls) ·+[Hook URL guide](https://docs.opencomputer.dev/agent-sessions/hooks)+### Create an agent from a repositoryRepository creation is a two-phase review/import so a moving branch cannot change underneath thediff --git a/web/src/api/agent-invocation-client.test.ts b/web/src/api/agent-invocation-client.test.tsindex 6ec42f9b..922cd08d 100644--- a/web/src/api/agent-invocation-client.test.ts+++ b/web/src/api/agent-invocation-client.test.ts@@ -2,7 +2,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest'import {createAgentHook,getAgentHooks,- invokeAgent,revokeAgentHook,} from './client'@@ -10,42 +9,6 @@ const agentId = 'agt_0123456789abcdef01234567'afterEach(() => vi.unstubAllGlobals())-describe('Agent URL dashboard client', () => {- it('invokes through the signed dashboard proxy with a stable key', async () => {- const fetchMock = vi.fn(- (input: string | URL | Request, init?: RequestInit) => {- void input- void init- return Promise.resolve(- Response.json({- request_id: 'req_1',- session: { id: 'ses_1', status: 'queued', head: 1 },- client_token: 'client-secret',- links: {- events: 'https://example.test/events',- messages: 'https://example.test/messages',- },- replayed: false,- }),- )- },- )- vi.stubGlobal('fetch', fetchMock)-- await expect(- invokeAgent(agentId, { task: 'review' }, 'invoke-1'),- ).resolves.toMatchObject({ session: { id: 'ses_1' } })- const [input, init] = fetchMock.mock.calls[0]- expect(input).toBe(`/api/dashboard/v3/agents/${agentId}/sessions`)- expect(init).toMatchObject({- method: 'POST',- credentials: 'include',- body: JSON.stringify({ task: 'review' }),- })- expect(new Headers(init?.headers).get('Idempotency-Key')).toBe('invoke-1')- })-})-describe('Hook management dashboard client', () => {it('parses copy-once creation and secret-free list responses', async () => {const fetchMock = vi.fn((input: string | URL | Request) => {diff --git a/web/src/api/client.ts b/web/src/api/client.tsindex a332bd0b..36c7d366 100644--- a/web/src/api/client.ts+++ b/web/src/api/client.ts@@ -60,7 +60,6 @@ export type {AgentSecurityNotification,AgentHook,AgentHookCreate,- AgentInvokeReceipt,SessionUsage,TurnUsage,} from './schemas'@@ -535,21 +534,6 @@ export const updateAgent = (S.AgentSchema,)-export const invokeAgent = (- agentId: string,- payload: unknown,- idempotencyKey: string,-) =>- apiFetch(- `/v3/agents/${encodeURIComponent(agentId)}/sessions`,- {- method: 'POST',- headers: { 'Idempotency-Key': idempotencyKey },- body: JSON.stringify(payload),- },- S.AgentInvokeReceiptSchema,- )-export const getAgentHooks = (agentId: string, cursor?: string) => {const query = new URLSearchParams({ include_revoked: 'true', limit: '100' })if (cursor) query.set('cursor', cursor)diff --git a/web/src/api/schemas.ts b/web/src/api/schemas.tsindex af5090f1..8c6096b0 100644--- a/web/src/api/schemas.ts+++ b/web/src/api/schemas.ts@@ -1064,18 +1064,6 @@ export const AgentHookCreateSchema = z.object({hook_url: z.string(),})-export const AgentInvokeReceiptSchema = z.object({- request_id: z.string(),- session: z.object({- id: z.string(),- status: z.string(),- head: z.coerce.number(),- }),- client_token: z.string(),- links: z.object({ events: z.string(), messages: z.string() }),- replayed: z.boolean(),-})-export const AgentSecurityNotificationSchema = z.object({id: z.string(),agentId: z.string(),@@ -1160,7 +1148,6 @@ export type TurnUsage = z.infer<typeof TurnUsageSchema>export type SessionUsage = z.infer<typeof SessionUsageSchema>export type AgentHook = z.infer<typeof AgentHookSchema>export type AgentHookCreate = z.infer<typeof AgentHookCreateSchema>-export type AgentInvokeReceipt = z.infer<typeof AgentInvokeReceiptSchema>export type AgentSecurityNotification = z.infer<typeof AgentSecurityNotificationSchema>diff --git a/web/src/components/agent-security-alert.test.tsx b/web/src/components/agent-security-alert.test.tsxindex 8385846a..cbeb17d4 100644--- a/web/src/components/agent-security-alert.test.tsx+++ b/web/src/components/agent-security-alert.test.tsx@@ -35,7 +35,9 @@ describe('AgentSecurityAlert', () => {expect(markup).toContain('role="alert"')expect(markup).toContain('An Agent Hook URL was exposed and revoked.')- expect(markup).toContain(`href="/agents/${alert.agentId}#hooks"`)+ expect(markup).toContain(+ `href="/agents/${alert.agentId}/settings?section=hooks"`,+ )expect(markup).toContain('>Acknowledge</button>')expect(markup).toContain('sm:flex-row')expect(markup).not.toContain(alert.hookId)diff --git a/web/src/components/agent-security-alert.tsx b/web/src/components/agent-security-alert.tsxindex 75a8c08a..5e5f2763 100644--- a/web/src/components/agent-security-alert.tsx+++ b/web/src/components/agent-security-alert.tsx@@ -38,7 +38,7 @@ export function AgentSecurityAlert({<p className="text-destructive/80 mt-0.5">Review the affected Hook before reconnecting its sender.{' '}<Link- to={`/agents/${encodeURIComponent(alert.agentId)}#hooks`}+ to={`/agents/${encodeURIComponent(alert.agentId)}/settings?section=hooks`}className="font-medium underline underline-offset-2">Review agent