Skip to content

Commit f6d21d9

Browse files
authored
feat(workbot): roll out browser use separately from computer use (#6564)
* feat(workbot): roll out browser use separately from computer use Workbot's cloud computer has two views, the browser and the native desktop apps, and both were gated by `computerUse`. Add a `browserUse` flag for the Browser view and keep `computerUse` for the Computer view, so an organization can get one without the other. Den reports `browser` next to `computer`. Workbot sends the runner the views a chat may use (`desktopViews`), and the runner narrows the desktop tool, prompt, viewer and demonstration routes to them and refuses calls on a view the chat may not use. A runner from before this change ignores the setting and offers both views. Teaching browser tasks and the browser live view now need `browserUse`. Signed-off-by: Jalil <reachjalil@gmail.com> * fix(workbot): never widen a chat's desktop views Two paths could give a chat a desktop view its organization had turned off. The Computer routes checked the view against a fresh Den session but then told the runner the views from the member's cached session, which can still include the browser for a short while after an admin turns it off. They now pass on only the views from the fresh answer. When a runner from before per-view limits rejects `desktopViews`, the client dropped the setting and the runner offered both views. A chat allowed only one view now gets no desktop on such a runner; a chat allowed both keeps both. Signed-off-by: Jalil <reachjalil@gmail.com> * fix(workbot): fail a one-view desktop update the runner can't enforce A runner too old for both `desktopViews` and `desktop` rejected the update that turns a one-view chat's desktop off, and the client then saved the chat without any desktop setting, which could keep desktop access it had before. Such an update now fails instead. A chat allowed both views still falls back as before. Signed-off-by: Jalil <reachjalil@gmail.com> --------- Signed-off-by: Jalil <reachjalil@gmail.com>
1 parent eb9df27 commit f6d21d9

26 files changed

Lines changed: 369 additions & 62 deletions

File tree

‎docs/computer-use/workbot.md‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
# Workbot's Computer tab
22

3-
Workbot's **Computer** tab appears after **Documents** when `workbot`,
4-
`computerUse`, and `remoteComputers` are enabled for the organization in
5-
`/admin`. It opens directly, without a consent screen. The combined testing
6-
branch also includes Documents; its `workbotDocuments` rollout remains independent.
3+
Workbot's **Computer** tab appears after **Documents** when `workbot` and
4+
`remoteComputers` are enabled for the organization in `/admin`, together with at
5+
least one of its two views. It opens directly, without a consent screen. The
6+
combined testing branch also includes Documents; its `workbotDocuments` rollout
7+
remains independent.
8+
9+
Each view is its own rollout (both on `cloud` and `self_hosted`, owned by
10+
`reachjalil`):
11+
12+
| Flag | What Workbot gets | Off |
13+
|---|---|---|
14+
| `browserUse` (default off) | The **Browser** view and the `desktop` tool's browser operations. Teaching browser tasks (`browserDemonstrations`) and the page stream (`browserLiveView`) need it too. | No Browser view; the model is offered only the native desktop, and the runner refuses browser calls. |
15+
| `computerUse` | The **Computer** view and the `desktop` tool's native-app operations (`computer_*`). | No Computer view; the model is offered only the browser, and the runner refuses native-app calls. |
16+
17+
Workspaces that had Workbot's computer before the split keep the Computer view
18+
and get the Browser view once `browserUse` is turned on for them. Workbot tells
19+
the runner each chat's views (`desktopViews` on the session), taken from Den's
20+
answer at that moment rather than a cached session. A runner from before the
21+
split can't limit the views, so a chat allowed only one gets no desktop there
22+
until the runner is updated; a chat allowed both keeps both.
23+
Turning a flag off applies to the next viewer connection and the chat's next
24+
turn; a viewer already open can outlive it as described under Transport and
25+
rollout. `bash` and `look` are not views: every Workbot chat keeps them while
26+
the runner has a computer.
727

828
The two views use one conversation computer:
929

‎ee/apps/den-api/src/workbot/routes.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ const sessionSchema = z.object({
5858
enabled: z.boolean(),
5959
/** Workbot may set up recurring work: the organization runs Automations on the headless runner. */
6060
canSchedule: z.boolean(),
61+
/** Workbot may use the native apps on its cloud computer. */
6162
computer: z.boolean().optional(),
63+
/** Workbot may use the browser on its cloud computer; off on older Dens, which gave the browser with `computer`. */
64+
browser: z.boolean().optional(),
6265
browserDemonstrations: z.boolean().optional(),
6366
/** The Browser view streams the page with Chromium's screencast; off on older Dens. */
6467
browserLiveView: z.boolean().optional(),
@@ -388,9 +391,11 @@ export function registerWorkbotRoutes<T extends { Variables: object }>(app: Hono
388391
organization: { id: organization.id, name: organization.name, brandAppName: readBrandAppName(organization.metadata) },
389392
memberId,
390393
enabled: true,
394+
// Workbot's browser and its other desktop apps share one cloud computer but are rolled out separately.
391395
computer: features.computerUse && features.remoteComputers,
392-
browserDemonstrations: features.browserDemonstrations && features.computerUse && features.remoteComputers,
393-
browserLiveView: features.browserLiveView && features.computerUse && features.remoteComputers,
396+
browser: features.browserUse && features.remoteComputers,
397+
browserDemonstrations: features.browserDemonstrations && features.browserUse && features.remoteComputers,
398+
browserLiveView: features.browserLiveView && features.browserUse && features.remoteComputers,
394399
canSchedule,
395400
calendar: true,
396401
documents: features.workbotDocuments,

‎ee/apps/headless-runner/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"start": "node dist/server.js",
1313
"typecheck": "tsc -p tsconfig.json --noEmit",
1414
"smoke": "tsx scripts/smoke.ts",
15-
"test:computer-config": "tsx --test scripts/computer-config.test.ts scripts/worker-http.test.ts",
15+
"test:computer-config": "tsx --test scripts/computer-config.test.ts scripts/worker-http.test.ts scripts/desktop-views.test.ts",
1616
"test:service-health": "tsx --conditions=development --test scripts/service-health.test.ts",
1717
"test:sql-store": "tsx --test scripts/sql-store.test.ts",
1818
"test:error-reporting": "tsx --test scripts/error-reporting.test.ts",
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import assert from "node:assert/strict"
2+
import { mkdtempSync, rmSync } from "node:fs"
3+
import { tmpdir } from "node:os"
4+
import { join } from "node:path"
5+
import { test } from "node:test"
6+
import { DESKTOP_TOOL } from "../../../packages/headless-computer/src/desktop-tool.js"
7+
import { desktopPrompt, desktopToolsFor, desktopViewRefused } from "../src/desktop-views.js"
8+
import { nodeSqlite } from "../src/node-sqlite.js"
9+
import { Store } from "../src/store.js"
10+
11+
type Schema = { properties: { view: { enum: string[] }; operation: { enum: string[] } } }
12+
13+
test("a conversation keeps the desktop views it may use, and every view is the default", () => {
14+
const directory = mkdtempSync(join(tmpdir(), "headless-views-"))
15+
const store = new Store(nodeSqlite(join(directory, "runner.sqlite")), () => 1_000)
16+
try {
17+
const session = store.createSession({ owner: "owner", computer: true, desktop: true })
18+
assert.equal(store.getSession(session.id)?.desktopViews, null)
19+
store.putSession(session.id, { desktopViews: ["computer"] })
20+
assert.deepEqual(store.getSession(session.id)?.desktopViews, ["computer"])
21+
// An update that doesn't mention views keeps them.
22+
store.putSession(session.id, { title: "Renamed" })
23+
assert.deepEqual(store.getSession(session.id)?.desktopViews, ["computer"])
24+
store.putSession(session.id, { desktopViews: ["computer", "browser"] })
25+
assert.equal(store.getSession(session.id)?.desktopViews, null)
26+
} finally {
27+
rmSync(directory, { recursive: true, force: true })
28+
}
29+
})
30+
31+
test("the desktop tool offers only the views a conversation may use", () => {
32+
assert.deepEqual(desktopToolsFor([DESKTOP_TOOL], null), [DESKTOP_TOOL])
33+
assert.deepEqual(desktopToolsFor([DESKTOP_TOOL], ["browser", "computer"]), [DESKTOP_TOOL])
34+
35+
const browser = desktopToolsFor([DESKTOP_TOOL], ["browser"])[0]!.inputSchema as Schema
36+
assert.deepEqual(browser.properties.view.enum, ["browser"])
37+
assert.deepEqual(browser.properties.operation.enum, ["tabs", "open", "navigate", "observe", "act", "extract", "computer_run"])
38+
39+
const computer = desktopToolsFor([DESKTOP_TOOL], ["computer"])[0]!.inputSchema as Schema
40+
assert.deepEqual(computer.properties.view.enum, ["computer"])
41+
assert.ok(computer.properties.operation.enum.every((name) => name.startsWith("computer_")))
42+
assert.ok(computer.properties.operation.enum.includes("computer_run"))
43+
44+
assert.match(desktopPrompt(["browser"]), /the browser \(view browser only/)
45+
assert.match(desktopPrompt(null), /visible browser and native applications/)
46+
})
47+
48+
test("a desktop call on a view the conversation may not use is refused", () => {
49+
assert.equal(desktopViewRefused(null, { view: "computer" }), null)
50+
assert.equal(desktopViewRefused(["browser"], { view: "browser", operation: "computer_run" }), null)
51+
assert.equal(desktopViewRefused(["browser"], { view: "computer", operation: "computer_launch" })?.isError, true)
52+
assert.equal(desktopViewRefused(["computer"], { view: "browser", operation: "open" })?.isError, true)
53+
})

‎ee/apps/headless-runner/src/app.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { modelProbeResponse, type ModelProbe } from "./model-probe.js"
1919
import { CONVERSATION_TABLES, sqlRow, type SessionInput, type StoredMessage, type Store, type Turn } from "./store.js"
2020
import { LargeBodyUnavailableError, SegmentError, SessionStorage } from "./storage/index.js"
2121
import { CellsStore } from "./cells-store.js"
22-
import { ACTIVE, executionSchema, repeatLimitsSchema, turnCredentialsSchema, turnStatusSchema, type SessionComputer } from "./types.js"
22+
import { ACTIVE, DESKTOP_VIEWS, desktopViewSchema, executionSchema, repeatLimitsSchema, turnCredentialsSchema, turnStatusSchema, type DesktopView, type SessionComputer } from "./types.js"
2323

2424
const createSessionBody = z
2525
.object({
@@ -31,6 +31,8 @@ const createSessionBody = z
3131
/** Give this conversation a Linux computer (needs HEADLESS_COMPUTER). Off unless asked for. */
3232
computer: z.boolean().optional(),
3333
desktop: z.boolean().optional(),
34+
/** The desktop views this conversation may use, at least one; omitted keeps the current ones (all, by default). */
35+
desktopViews: z.array(desktopViewSchema).min(1).max(DESKTOP_VIEWS.length).optional(),
3436
/** Let the model react to the person's message with one emoji (the `react` tool). Off unless asked for. */
3537
reactions: z.boolean().optional(),
3638
/** Let the conversation hand longer work to background tasks (start_task) and keep talking. Off unless asked for. */
@@ -221,15 +223,18 @@ export function createApp(input: {
221223
if (!session?.computer || !session.desktop) return c.json({ error: "desktop_disabled" }, 403)
222224
const raw: unknown = await c.req.json().catch(() => null)
223225
c.header("Cache-Control", "no-store")
226+
const allows = (view: DesktopView) => !session.desktopViews || session.desktopViews.includes(view)
224227
try {
225228
if (c.req.param("operation") === "demonstration" && input.computer?.browserDemonstration) {
229+
if (!allows("browser")) return c.json({ error: "desktop_view_disabled" }, 403)
226230
const body = demonstrationCommandSchema.safeParse(raw)
227231
if (!body.success) return c.json({ error: "invalid_request" }, 400)
228232
return c.json(await input.computer.browserDemonstration(session.id, body.data))
229233
}
230234
if (c.req.param("operation") === "viewer" && input.computer?.desktopViewer) {
231235
const body = z.object({ view: z.enum(["browser", "computer"]), control: z.boolean(), origin: z.string().url().max(2048) }).strict().safeParse(raw)
232236
if (!body.success) return c.json({ error: "invalid_request" }, 400)
237+
if (!allows(body.data.view)) return c.json({ error: "desktop_view_disabled" }, 403)
233238
return c.json(await input.computer.desktopViewer(session.id, body.data))
234239
}
235240
if (c.req.param("operation") === "action" && input.computer?.desktopAction) {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { DESKTOP_VIEWS, type DesktopView, type ToolResult, type ToolSpec } from "./types.js"
2+
3+
const NAMES: Record<DesktopView, string> = { browser: "the browser", computer: "the desktop's native applications" }
4+
5+
/** The views a conversation may use, or null when it may use all of them. */
6+
const narrowed = (views: DesktopView[] | null) => (views && !DESKTOP_VIEWS.every((view) => views.includes(view)) ? views : null)
7+
8+
/** What the model is told about the visible desktop, naming only the views this conversation may use. */
9+
export function desktopPrompt(views: DesktopView[] | null) {
10+
const only = narrowed(views)
11+
const where = only ? `${only.map((view) => NAMES[view]).join(" and ")} (view ${only.join(" or ")} only; the organization has not enabled the rest of the desktop)` : "the visible browser and native applications"
12+
return `Use desktop to work in ${where}. The organization enabled this computer: use it directly when needed. If the person takes control, wait for them to return it before continuing desktop operations.`
13+
}
14+
15+
/**
16+
* The desktop tool, narrowed to the views this conversation may use: its `view` and `operation` choices list only
17+
* those, and its description says so first. Unchanged when every view is allowed.
18+
*/
19+
export function desktopToolsFor(tools: ToolSpec[], views: DesktopView[] | null): ToolSpec[] {
20+
const only = narrowed(views)
21+
if (!only) return tools
22+
const browserOnly = !only.includes("computer")
23+
return tools.map((tool) => {
24+
const properties = tool.inputSchema.properties as Record<string, { enum?: string[] }> | undefined
25+
const operations = properties?.operation?.enum
26+
if (!properties || !operations) return tool
27+
return {
28+
...tool,
29+
description: `Only view ${only.join(" or ")} is available in this conversation; ignore the other view's operations.\n${tool.description}`,
30+
inputSchema: {
31+
...tool.inputSchema,
32+
properties: {
33+
...properties,
34+
view: { ...properties.view, enum: [...only] },
35+
// computer_run works on either view; the other computer_* operations are the native desktop's.
36+
operation: { ...properties.operation, enum: operations.filter((name) => name === "computer_run" || name.startsWith("computer_") !== browserOnly) },
37+
},
38+
},
39+
}
40+
})
41+
}
42+
43+
/** A refusal for a desktop call on a view this conversation may not use; null when the call may go ahead. */
44+
export function desktopViewRefused(views: DesktopView[] | null, input: Record<string, unknown>): ToolResult | null {
45+
const only = narrowed(views)
46+
if (!only || only.includes(input.view as DesktopView)) return null
47+
return { output: `Only view ${only.join(" or ")} is available in this conversation. The organization has not enabled the other desktop view.`, isError: true }
48+
}

‎ee/apps/headless-runner/src/runner.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { isWorkbotTurn, type WorkbotTurnFact } from "./workbot-telemetry.js"
44
import type { SessionEvents } from "./events.js"
55
import { FILE_TOOLS, FILE_TOOL_NAMES, isMemoryPath, normalizePath, runFileTool } from "./files.js"
66
import { CellsStore } from "./cells-store.js"
7+
import { desktopPrompt, desktopToolsFor, desktopViewRefused } from "./desktop-views.js"
78
import { localMemory, MemoryUnavailableError, type MemoryAccess, type MemoryResolver } from "./memory.js"
89
import type { McpConnector, ToolSession } from "./mcp.js"
910
import { createModelAdapter, ModelError, normalizeTranscript, type ModelClient } from "./model.js"
@@ -871,7 +872,7 @@ export class Runner {
871872
this.options.systemPrompt ?? DEFAULT_SYSTEM_PROMPT,
872873
files ? FILES_PROMPT : "",
873874
computer?.prompt ?? "",
874-
session?.desktop && computer?.desktopTools?.length ? "Use desktop to work in the visible browser and native applications. The organization enabled this computer: use it directly when needed. If the person takes control, wait for them to return it before continuing desktop operations." : "",
875+
session?.desktop && computer?.desktopTools?.length ? desktopPrompt(session.desktopViews) : "",
875876
tools || kind === "report" ? "" : "No OpenWork connection is available in this conversation, so connected apps cannot be reached.",
876877
session?.instructions ?? "",
877878
memorySection(memoryFiles),
@@ -881,7 +882,7 @@ export class Runner {
881882
]
882883
.filter(Boolean)
883884
.join("\n\n")
884-
const toolSpecs = kind === "report" ? FILE_TOOLS.filter((tool) => READ_ONLY_LOCAL_TOOLS.has(tool.name)) : [...FILE_TOOLS.filter((tool) => !readOnly || READ_ONLY_LOCAL_TOOLS.has(tool.name)), ...(files ? SAVED_FILE_TOOLS.filter((tool) => !readOnly || READ_ONLY_LOCAL_TOOLS.has(tool.name)) : []), ...(computer?.tools ?? []), ...(session?.desktop ? computer?.desktopTools ?? [] : []), ...(reactions ? REACTION_TOOLS : []), ...(taskTools ? TASK_TOOLS : []), ...(session?.documentNavigation && kind === "message" ? [DOCUMENT_NAVIGATION_TOOL] : []), ...(tools?.tools ?? [])]
885+
const toolSpecs = kind === "report" ? FILE_TOOLS.filter((tool) => READ_ONLY_LOCAL_TOOLS.has(tool.name)) : [...FILE_TOOLS.filter((tool) => !readOnly || READ_ONLY_LOCAL_TOOLS.has(tool.name)), ...(files ? SAVED_FILE_TOOLS.filter((tool) => !readOnly || READ_ONLY_LOCAL_TOOLS.has(tool.name)) : []), ...(computer?.tools ?? []), ...(session?.desktop ? desktopToolsFor(computer?.desktopTools ?? [], session.desktopViews) : []), ...(reactions ? REACTION_TOOLS : []), ...(taskTools ? TASK_TOOLS : []), ...(session?.documentNavigation && kind === "message" ? [DOCUMENT_NAVIGATION_TOOL] : []), ...(tools?.tools ?? [])]
885886
return { turn, session, repeatLimits, files, readOnly, computer, reactions, taskTools, memory, baseSystem, toolSpecs }
886887
}
887888

@@ -980,7 +981,8 @@ export class Runner {
980981
: taskTools && turn && TASK_TOOL_NAMES.has(call.name)
981982
? this.runTaskTool(turn, call.name, call.input, context.held)
982983
: call.name === "desktop" && store.getSession(sessionId)?.desktop && computer?.desktopRun
983-
? await computer.desktopRun(sessionId, call.input, signal).catch((error: unknown) => ({ output: error instanceof Error ? error.message : "Desktop unavailable", isError: true }))
984+
? desktopViewRefused(store.getSession(sessionId)?.desktopViews ?? null, call.input)
985+
?? await computer.desktopRun(sessionId, call.input, signal).catch((error: unknown) => ({ output: error instanceof Error ? error.message : "Desktop unavailable", isError: true }))
984986
: computer?.toolNames.has(call.name)
985987
? await computer.run(sessionId, call.name, call.input).catch((error: unknown) => ({
986988
output: `The computer didn't respond: ${error instanceof Error ? error.message : "unknown error"}. Its outcome is unknown; check before repeating it.`,

‎ee/apps/headless-runner/src/store.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ import { stepStateSchema, type StepState } from "./steps.js"
2222
import { withoutAttachments } from "./tool-files.js"
2323
import {
2424
ACTIVE,
25+
DESKTOP_VIEWS,
2526
attachmentSchema,
27+
desktopViewSchema,
2628
messageSchema,
2729
repeatLimitsSchema,
2830
turnStatusSchema,
2931
type Attachment,
32+
type DesktopView,
3033
type Execution,
3134
type Message,
3235
type RepeatLimits,
@@ -49,6 +52,7 @@ const sessionOptions = z.object({
4952
files: z.boolean().optional(),
5053
computer: z.boolean().optional(),
5154
desktop: z.boolean().optional(),
55+
desktopViews: z.array(desktopViewSchema).optional(),
5256
reactions: z.boolean().optional(),
5357
tasks: z.boolean().optional(),
5458
documentNavigation: z.boolean().optional(),
@@ -96,6 +100,8 @@ export type Session = {
96100
files: boolean
97101
computer: boolean
98102
desktop: boolean
103+
/** The desktop views this conversation may use (see DesktopView); null means all of them. */
104+
desktopViews: DesktopView[] | null
99105
/** Whether the model may react to the person's message with an emoji (the caller shows it). */
100106
reactions: boolean
101107
/** Whether the conversation may hand work to background tasks (start_task) and keep talking meanwhile. */
@@ -127,6 +133,7 @@ export type SessionInput = {
127133
files?: boolean
128134
computer?: boolean
129135
desktop?: boolean
136+
desktopViews?: DesktopView[] | null
130137
reactions?: boolean
131138
tasks?: boolean
132139
documentNavigation?: boolean
@@ -144,6 +151,7 @@ function optionsOf(input: {
144151
files?: boolean
145152
computer?: boolean
146153
desktop?: boolean
154+
desktopViews?: DesktopView[] | null
147155
reactions?: boolean
148156
tasks?: boolean
149157
documentNavigation?: boolean
@@ -157,6 +165,7 @@ function optionsOf(input: {
157165
...(input.files !== undefined ? { files: input.files } : {}),
158166
...(input.computer !== undefined ? { computer: input.computer } : {}),
159167
...(input.desktop !== undefined ? { desktop: input.desktop } : {}),
168+
...(input.desktopViews !== undefined ? { desktopViews: input.desktopViews ?? [...DESKTOP_VIEWS] } : {}),
160169
...(input.reactions !== undefined ? { reactions: input.reactions } : {}),
161170
...(input.tasks !== undefined ? { tasks: input.tasks } : {}),
162171
...(input.documentNavigation !== undefined ? { documentNavigation: input.documentNavigation } : {}),
@@ -177,6 +186,8 @@ function serializeOptions(options: SessionOptions) {
177186
...(options.files ? { files: true } : {}),
178187
...(options.computer ? { computer: true } : {}),
179188
...(options.desktop ? { desktop: true } : {}),
189+
// Every view is the default, so only a narrower set is kept, in one order.
190+
...(options.desktopViews && !DESKTOP_VIEWS.every(view => options.desktopViews!.includes(view)) ? { desktopViews: DESKTOP_VIEWS.filter(view => options.desktopViews!.includes(view)) } : {}),
180191
...(options.reactions ? { reactions: true } : {}),
181192
...(options.tasks ? { tasks: true } : {}),
182193
...(options.documentNavigation ? { documentNavigation: true } : {}),
@@ -548,6 +559,7 @@ export class Store {
548559
files: options.files ?? false,
549560
computer: options.computer ?? false,
550561
desktop: options.desktop ?? false,
562+
desktopViews: options.desktopViews ?? null,
551563
reactions: options.reactions ?? false,
552564
tasks: options.tasks ?? false,
553565
documentNavigation: options.documentNavigation ?? false,

0 commit comments

Comments
 (0)