diff --git a/api/openapi.yaml b/api/openapi.yaml
index d845a8efd2..bcc26e43b7 100644
--- a/api/openapi.yaml
+++ b/api/openapi.yaml
@@ -30862,6 +30862,13 @@ components:
- browser
- windows
description: 'The computer it works on: browser, the Bot''s own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner''s. One at a time. Experimental.'
+ computerAccess:
+ type: string
+ x-extensible-enum:
+ - allowed
+ - refused
+ readOnly: true
+ description: 'Whether the caller may see and use this Bot''s browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn''t know reads as allowed. Never accepted when a Bot is created or changed.'
instructions:
type: string
description: What the starter Bot is told, kept apart from its role description. Only the starter Bot has instructions.
diff --git a/api/openapi/bots.yaml b/api/openapi/bots.yaml
index 4d114fbe4f..b71442aa25 100644
--- a/api/openapi/bots.yaml
+++ b/api/openapi/bots.yaml
@@ -1752,6 +1752,21 @@ components:
which every Bot has unless told otherwise; or windows, the Windows
computer of the person it works for: in a conversation, theirs; in a
routine, its owner's. One at a time. Experimental.
+ computerAccess:
+ type: string
+ x-extensible-enum: [allowed, refused]
+ readOnly: true
+ description: >-
+ Whether the caller may see and use this Bot's browser computer:
+ its screen, its terminal, who has control and its activity.
+ allowed for an admin, on a public Bot, and for its owner. refused
+ for anybody else, such as a teammate a private Bot is shared
+ with, who still chats with it; every computer call and the live
+ screen and terminal answer them 404 BOT_NOT_FOUND. A client that
+ reads refused opens none of them and says so. Absent from a
+ server older than this field, where a client learns it from that
+ 404. A value this client doesn't know reads as allowed. Never
+ accepted when a Bot is created or changed.
instructions:
type: string
description: >-
diff --git a/app/src/components/computer/computer-panel.tsx b/app/src/components/computer/computer-panel.tsx
index 70170e397b..986b5b5794 100644
--- a/app/src/components/computer/computer-panel.tsx
+++ b/app/src/components/computer/computer-panel.tsx
@@ -4,12 +4,18 @@ import { useEffect, useState, useSyncExternalStore } from "react";
import {
IconDeviceDesktop,
IconDeviceDesktopOff,
+ IconLock,
IconTerminal2,
} from "@/components/icons";
import { PageEmpty } from "@/components/layout/page-parts";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { WindowsComputerView } from "@/components/windows-computer/windows-computer-page";
import { agentQueryOptions } from "@/lib/agents/queries";
+import {
+ COMPUTER_REFUSED_SAID,
+ COMPUTER_REFUSED_TITLE,
+ computerRefusedFor,
+} from "@/lib/computers/access";
import {
followedView,
onComputerViewRequest,
@@ -71,9 +77,28 @@ export function ComputerViewPanel({
);
+ /*
+ * A BOT WHOSE COMPUTER THIS PERSON MAY NOT SEE SAYS SO, AND OPENS NOTHING. A teammate on a private Bot shared with
+ * them: the server answers every call about its computer 404 (lib/computers/access.ts). The panel used to read
+ * those as a computer still starting, a wheel still being checked and a terminal reconnecting, for ever. Nothing
+ * of the live panel is drawn here, so no screenshot, status, wheel or activity is read and no socket is opened.
+ */
+ if (computerRefusedFor(bot.data)) return ;
return ;
}
+/** The panel where this person may not see the Bot's computer. */
+function RefusedComputerPanel() {
+ return (
+ // The empty state brings its own 16px above it, which is the panel's top padding.
+
+
+ {COMPUTER_REFUSED_SAID}
+
+
+ );
+}
+
/**
* The panel for a Bot that works on a Windows computer: the person's own, whichever of their Bots it is (a person
* has one in each organization). Its live screen, who is using it, and its recording; nothing of the browser computer
@@ -147,10 +172,16 @@ function LiveComputerPanel({
"screen";
// One wheel for the whole computer: whoever holds it holds the screen and the terminal both.
- const { control, someoneElse } = useComputerControl(agentId);
+ const { control, someoneElse, refused } = useComputerControl(agentId);
const youHaveIt =
control?.holder === "human" && !control.transitioning && !someoneElse;
+ /*
+ * A server older than `Bot.computerAccess` says it only by refusing: the wheel's first read answers 404, and the
+ * panel then says what it says above, closing the screen and the terminal with their reads and sockets.
+ */
+ if (refused) return ;
+
return (
* it is handed back. The terminal inside is always a dark terminal, in either of the app's themes.
*/
export function ComputerTerminal({ computerId }: { computerId: string }) {
- const { control, someoneElse } = useComputerControl(computerId);
+ const {
+ control,
+ someoneElse,
+ refused: controlRefused,
+ } = useComputerControl(computerId);
/** The signed-in person holds the wheel. Someone else holding it on a shared Bot is not them typing. */
const driving =
control?.holder === "human" && !control.transitioning && !someoneElse;
@@ -31,72 +36,93 @@ export function ComputerTerminal({ computerId }: { computerId: string }) {
const [problem, setProblem] = useState(null);
const [reconnecting, setReconnecting] = useState(false);
const [retryKey, setRetryKey] = useState(0);
+ /** The terminal's socket was refused: the server answered it 404 (lib/computers/access.ts). */
+ const [socketRefused, setSocketRefused] = useState(false);
+
+ /*
+ * NOT THIS PERSON'S TO SEE. The socket, or the wheel, was refused, and asking again gets the same answer: one
+ * sentence where the shell would be, and no socket, no Retry and no "Checking who has control…" under it. It used to
+ * say "Reconnecting…" for as long as the tab was open.
+ */
+ const refused = socketRefused || controlRefused;
return (
-
- {problem}
-
+ {driving ? (
+
+ You have control of the
+ terminal and the screen. Click the terminal and type. The Bot
+ waits until you hand it back.
+
+ ) : (
+
+ {!control
+ ? "Checking who has control…"
+ : control.transitioning
+ ? "Finishing the current action…"
+ : someoneElse
+ ? "Someone else has control."
+ : "The Bot has control."}
+
+ )}
+ terminal.current?.focus()}
+ />
- ) : null}
-
-
- {driving ? (
-
- You have control of the
- terminal and the screen. Click the terminal and type. The Bot waits
- until you hand it back.
-
- ) : (
-
- {!control
- ? "Checking who has control…"
- : control.transitioning
- ? "Finishing the current action…"
- : someoneElse
- ? "Someone else has control."
- : "The Bot has control."}
-
- )}
- terminal.current?.focus()}
- />
-
+ >
+ )}
);
}
diff --git a/app/src/components/computer/computer-view.tsx b/app/src/components/computer/computer-view.tsx
index 7f1f228625..e6f3458a3f 100644
--- a/app/src/components/computer/computer-view.tsx
+++ b/app/src/components/computer/computer-view.tsx
@@ -29,6 +29,10 @@ import {
botBrowserStateQueryOptions,
} from "@/lib/bot-browser/queries";
import type { ClientError } from "@/lib/client";
+import {
+ COMPUTER_REFUSED_LINE,
+ isComputerRefusal,
+} from "@/lib/computers/access";
import {
botsReason,
passkeyNotice,
@@ -520,7 +524,10 @@ export function ComputerView({
refresh: refreshControl,
problem: controlProblem,
someoneElse,
+ refused: controlRefused,
} = useComputerControl(computerId, !settled);
+ /** The screenshot was refused: this person may not see the Bot's computer (lib/computers/access.ts). */
+ const [screenRefused, setScreenRefused] = useState(false);
/** Held only until it is sent. Never lifted into a URL, a log, or anything that outlives this form. */
const [secret, setSecret] = useState("");
// The refusal kept whole, not as its words, so a hold is drawn calmly (`failureSaid`).
@@ -561,7 +568,9 @@ export function ComputerView({
expanded &&
!settled &&
(driving || (shot !== null && !isBlankBrowser(shot)));
- const polling = visualVisible && !liveStreamOpen;
+ // Never for a computer this person may not see: asking again gets the same refusal.
+ const polling =
+ visualVisible && !liveStreamOpen && !screenRefused && !controlRefused;
/*
* The frame this turn's page was showing, fetched once and then kept.
@@ -623,9 +632,21 @@ export function ComputerView({
// Always fetch at least one frame; only repeated refreshes are conditional.
const tick = async () => {
try {
- const { frame, error, notReady } = await readScreenshot(computerId);
+ const { frame, error, notReady, refused } =
+ await readScreenshot(computerId);
if (generation.current !== mine) return;
+ if (refused) {
+ /*
+ * Not this person's to see. It used to be held as a failed screenshot, which a computer not known to be
+ * ready reads as one still coming up: "Starting the Bot's computer…" for ever. Asked again it says the
+ * same, so it is not asked again.
+ */
+ setScreenRefused(true);
+ setProblem(null);
+ setShot(null);
+ return;
+ }
if (notReady) {
/*
* Asleep or starting, said by the server without waking the computer. Not a problem:
@@ -682,10 +703,24 @@ export function ComputerView({
*/
const status = useQuery({
...computerStatusQueryOptions(computerId),
- enabled: !settled && visualVisible && shot === null && polledState === null,
- refetchInterval: STATUS_POLL_MS,
+ enabled:
+ !settled &&
+ visualVisible &&
+ shot === null &&
+ polledState === null &&
+ !screenRefused &&
+ !controlRefused,
+ refetchInterval: (query) =>
+ isComputerRefusal(query.state.error) ? false : STATUS_POLL_MS,
retry: false,
});
+ /**
+ * This person may not see the Bot's computer: any of the reads said so (lib/computers/access.ts). Nothing is read
+ * again, nothing is started, and the screen says so in place of a computer starting or a wheel being checked.
+ */
+ const refused =
+ !settled &&
+ (screenRefused || controlRefused || isComputerRefusal(status.error));
/**
* The fresher of the two answers: the poll that just ran, else the status read. A state a newer
* server sends that this app doesn't know is none of the ones below: the screen waits for a frame.
@@ -711,7 +746,7 @@ export function ComputerView({
// A picture is a computer that is up, whatever the state reads have or have not said yet.
const hasFrame = shot !== null;
useEffect(() => {
- if (toolCallId || settled || !visualVisible) return;
+ if (toolCallId || settled || !visualVisible || refused) return;
if (!computerState && !hasFrame) return;
if (openedOn.current === computerId) return;
openedOn.current = computerId;
@@ -724,7 +759,15 @@ export function ComputerView({
if (state === "starting" || state === "ready") setStartAsked(true);
if (refused) setStartBlocked(refused);
});
- }, [computerId, computerState, hasFrame, settled, toolCallId, visualVisible]);
+ }, [
+ computerId,
+ computerState,
+ hasFrame,
+ refused,
+ settled,
+ toolCallId,
+ visualVisible,
+ ]);
useEffect(() => {
// Up, or on its way: what the server says is the news again, and a later "off" is one.
if (computerState && computerState !== "absent") {
@@ -738,7 +781,8 @@ export function ComputerView({
*/
const asleep = computerState === "absent" && !toolCallId && !startAsked;
/** Waiting for a first frame, for a reason that can end. A computer that is off waits for the Bot. */
- const waitingForFrame = !settled && visualVisible && shot === null && !asleep;
+ const waitingForFrame =
+ !settled && visualVisible && shot === null && !asleep && !refused;
/** Each Try again starts the wait for a first frame over. */
const [attempt, setAttempt] = useState(0);
@@ -803,7 +847,7 @@ export function ComputerView({
const botBrowser = useQuery({
...botBrowserStateQueryOptions(computerId),
// Not for a computer refused a start, which has no browser to read.
- enabled: expanded && !settled && !startBlocked,
+ enabled: expanded && !settled && !startBlocked && !refused,
});
/*
* Read again the moment the wheel changes hands, rather than up to a second later: the bar and Record go live, or
@@ -1177,118 +1221,133 @@ export function ComputerView({
thing a person watching may want to do, on the thing they are watching. A sibling of the picture's button
rather than inside it, because a control cannot sit inside another control.
*/}
-
- {/* Inline preview remains in transcript; click opens a readable full-size view. */}
-
+ )}
{/* The request reason appears above the always-available ownership controls. */}
{!driving && !settled && control?.requested ? (
diff --git a/app/src/components/computer/live-terminal.tsx b/app/src/components/computer/live-terminal.tsx
index 85de80228a..e9ecadd216 100644
--- a/app/src/components/computer/live-terminal.tsx
+++ b/app/src/components/computer/live-terminal.tsx
@@ -8,6 +8,7 @@ import {
useRef,
useState,
} from "react";
+import { computerRefusedNow } from "@/lib/computers/access";
import {
connectScreen,
type ScreenSocket,
@@ -77,6 +78,8 @@ type Props = {
/** Why the terminal cannot be shown, when retrying will not change it, or the retries are spent. */
onProblem?: (problem: string | null) => void;
onReconnecting?: (reconnecting: boolean) => void;
+ /** The server refused this person the Bot's computer (lib/computers/access.ts). Never retried. */
+ onRefused?: () => void;
/** Bumped by the parent's Retry, which reconnects. */
retryKey?: number;
ref?: Ref;
@@ -87,6 +90,7 @@ export function LiveTerminal({
driving,
onProblem,
onReconnecting,
+ onRefused,
retryKey = 0,
ref,
}: Props) {
@@ -98,6 +102,8 @@ export function LiveTerminal({
problemRef.current = onProblem;
const reconnectingRef = useRef(onReconnecting);
reconnectingRef.current = onReconnecting;
+ const refusedRef = useRef(onRefused);
+ refusedRef.current = onRefused;
const [live, setLive] = useState(false);
useImperativeHandle(ref, () => ({
@@ -232,6 +238,9 @@ export function LiveTerminal({
}
},
disconnected: "The terminal is disconnected. Retry to reconnect.",
+ // A socket the server answered 404 closes as a dropped one does: asked over HTTP before it is retried.
+ refused: () => computerRefusedNow(computerId),
+ onRefused: () => refusedRef.current?.(),
});
return () => {
diff --git a/app/src/lib/api/generated/bots/bots.zod.ts b/app/src/lib/api/generated/bots/bots.zod.ts
index af246f0893..61b2cf5107 100644
--- a/app/src/lib/api/generated/bots/bots.zod.ts
+++ b/app/src/lib/api/generated/bots/bots.zod.ts
@@ -128,6 +128,12 @@ export const ListBotsResponse = zod.object({
.describe(
"The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental.",
),
+ computerAccess: zod
+ .string()
+ .optional()
+ .describe(
+ "Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed.",
+ ),
instructions: zod
.string()
.optional()
@@ -476,6 +482,12 @@ export const CreateBotResponse = zod.object({
.describe(
"The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental.",
),
+ computerAccess: zod
+ .string()
+ .optional()
+ .describe(
+ "Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed.",
+ ),
instructions: zod
.string()
.optional()
@@ -666,6 +678,12 @@ export const GetBotResponse = zod.object({
.describe(
"The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental.",
),
+ computerAccess: zod
+ .string()
+ .optional()
+ .describe(
+ "Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed.",
+ ),
instructions: zod
.string()
.optional()
@@ -991,6 +1009,12 @@ export const UpdateBotResponse = zod.object({
.describe(
"The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental.",
),
+ computerAccess: zod
+ .string()
+ .optional()
+ .describe(
+ "Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed.",
+ ),
instructions: zod
.string()
.optional()
@@ -1323,6 +1347,12 @@ export const DuplicateBotResponse = zod.object({
.describe(
"The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental.",
),
+ computerAccess: zod
+ .string()
+ .optional()
+ .describe(
+ "Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed.",
+ ),
instructions: zod
.string()
.optional()
@@ -1525,6 +1555,12 @@ export const HideBotResponse = zod.object({
.describe(
"The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental.",
),
+ computerAccess: zod
+ .string()
+ .optional()
+ .describe(
+ "Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed.",
+ ),
instructions: zod
.string()
.optional()
@@ -1727,6 +1763,12 @@ export const UnhideBotResponse = zod.object({
.describe(
"The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental.",
),
+ computerAccess: zod
+ .string()
+ .optional()
+ .describe(
+ "Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed.",
+ ),
instructions: zod
.string()
.optional()
@@ -1929,6 +1971,12 @@ export const PinBotResponse = zod.object({
.describe(
"The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental.",
),
+ computerAccess: zod
+ .string()
+ .optional()
+ .describe(
+ "Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed.",
+ ),
instructions: zod
.string()
.optional()
@@ -2131,6 +2179,12 @@ export const UnpinBotResponse = zod.object({
.describe(
"The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental.",
),
+ computerAccess: zod
+ .string()
+ .optional()
+ .describe(
+ "Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed.",
+ ),
instructions: zod
.string()
.optional()
@@ -2375,6 +2429,12 @@ export const RevokeBotCallbackTokenResponse = zod.object({
.describe(
"The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental.",
),
+ computerAccess: zod
+ .string()
+ .optional()
+ .describe(
+ "Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed.",
+ ),
instructions: zod
.string()
.optional()
@@ -2577,6 +2637,12 @@ export const RemoveBotKeyResponse = zod.object({
.describe(
"The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental.",
),
+ computerAccess: zod
+ .string()
+ .optional()
+ .describe(
+ "Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed.",
+ ),
instructions: zod
.string()
.optional()
diff --git a/app/src/lib/api/generated/model/bot.ts b/app/src/lib/api/generated/model/bot.ts
index 23049c584e..ee6ec1034a 100644
--- a/app/src/lib/api/generated/model/bot.ts
+++ b/app/src/lib/api/generated/model/bot.ts
@@ -47,6 +47,8 @@ export interface Bot {
isolated: boolean;
/** The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental. */
computer?: string;
+ /** Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed. */
+ readonly computerAccess?: string;
/** What the starter Bot is told, kept apart from its role description. Only the starter Bot has instructions. */
instructions?: string;
/** What runs it, by the name a person reads ("LangChain", "OpenBot"). Absent when OpenBot doesn't know. */
diff --git a/app/src/lib/computers/access.ts b/app/src/lib/computers/access.ts
new file mode 100644
index 0000000000..b17866a68b
--- /dev/null
+++ b/app/src/lib/computers/access.ts
@@ -0,0 +1,55 @@
+import { getComputerControl } from "@/lib/api/generated/computers/computers";
+import { organizationId } from "@/lib/api/request";
+import { ClientError } from "@/lib/client";
+
+/**
+ * WHO MAY SEE A BOT'S COMPUTER. An admin, anybody on a public Bot, and its owner; nobody else. A teammate a private
+ * Bot is shared with chats with it, and it still works for them, but its screen, terminal, wheel and activity are its
+ * owner's signed-in computer, and the server answers every one of those calls, and the live screen and terminal, 404
+ * BOT_NOT_FOUND. The rule is the server's; the app never works it out for itself.
+ *
+ * The Bot read says it up front (`Bot.computerAccess`), so the Computer panel opens nothing for such a person. A server
+ * older than that field says it only by the 404, and every view of the computer reads that 404 as this same refusal,
+ * never as a computer still starting or a connection to retry.
+ */
+
+/** The Bot read says this person may not see its computer. Absent (an older server) or anything else is allowed. */
+export function computerRefusedFor(
+ bot: { computerAccess?: string } | undefined,
+): boolean {
+ return bot?.computerAccess === "refused";
+}
+
+/** A computer call refused because this person may not reach the Bot's computer: the API's 404 BOT_NOT_FOUND. */
+export function isComputerRefusal(error: unknown): boolean {
+ return (
+ error instanceof ClientError &&
+ error.status === 404 &&
+ error.code === "BOT_NOT_FOUND"
+ );
+}
+
+/**
+ * Ask the server, over plain HTTP, whether it refuses this person the Bot's computer: for a live socket that closed
+ * before it opened, which a browser can't tell from a dropped one. Who has control is the cheapest read under the Bot,
+ * and refused the same as the socket. Fails open: a read that did not come back says nothing about the person.
+ */
+export async function computerRefusedNow(computerId: string): Promise {
+ try {
+ await getComputerControl(organizationId(), computerId);
+ return false;
+ } catch (error) {
+ return isComputerRefusal(error);
+ }
+}
+
+/** The heading where the Bot's computer is not this person's to see. */
+export const COMPUTER_REFUSED_TITLE = "This Bot's computer is private";
+
+/** The sentence under it. */
+export const COMPUTER_REFUSED_SAID =
+ "Only the Bot's owner and admins can see it. You can still give the Bot work in a conversation.";
+
+/** The same, in one sentence, where a view of the computer has room for only one. */
+export const COMPUTER_REFUSED_LINE =
+ "Only the Bot's owner and admins can see its computer.";
diff --git a/app/src/lib/computers/screen-connection.ts b/app/src/lib/computers/screen-connection.ts
index 9e8c242868..e92f83ce8b 100644
--- a/app/src/lib/computers/screen-connection.ts
+++ b/app/src/lib/computers/screen-connection.ts
@@ -33,6 +33,17 @@ type Options = {
schedule?: (run: () => void, delay: number) => () => void;
/** What is said once the retries are spent. The live screen's sentence unless told otherwise. */
disconnected?: string;
+ /**
+ * Asked when a socket closes without ever having opened: whether the server refused this person the computer.
+ *
+ * A browser is told nothing about a socket the server answered with a refusal: it closes with no status, exactly as
+ * a dropped one does. The server answers 404 to somebody who may not see the Bot's computer (a teammate on a private
+ * Bot), and that close was retried as a dropped connection, "Reconnecting…" over a terminal that would never come.
+ * Yes ends the retries for good with `onRefused`; no, or a check that failed, retries as before.
+ */
+ refused?: () => Promise;
+ /** The server refused this person the computer (`refused`). Nothing is retried after it. */
+ onRefused?: () => void;
};
const BACKOFF = [500, 1000, 2000, 4000, 8000];
export function connectScreen(options: Options) {
@@ -51,12 +62,33 @@ export function connectScreen(options: Options) {
const current = options.open();
socket = current;
let disconnected = false;
+ /** Whether this socket ever opened. One that closes without having opened may have been refused. */
+ let opened = false;
const owns = () => !stopped && socket === current && !disconnected;
const disconnect = () => {
if (!owns()) return;
disconnected = true;
options.onDisconnect();
options.onReady(false);
+ const check = options.refused;
+ if (!opened && check) {
+ void check()
+ .catch(() => false)
+ .then((refused) => {
+ if (stopped || socket !== current) return;
+ if (!refused) {
+ retry();
+ return;
+ }
+ stopped = true;
+ options.onReconnecting?.(false);
+ options.onRefused?.();
+ });
+ return;
+ }
+ retry();
+ };
+ const retry = () => {
const delay = BACKOFF[attempts++];
if (delay === undefined) {
options.onReconnecting?.(false);
@@ -70,6 +102,7 @@ export function connectScreen(options: Options) {
cancelTimer = schedule(connect, delay);
};
current.onopen = async () => {
+ opened = true;
// The initial mount receives freshly polled ownership from its parent. Reconnect must refresh it.
const permitted =
attempts === 0 || (await options.verifyOwnership().catch(() => false));
diff --git a/app/src/lib/computers/screen.ts b/app/src/lib/computers/screen.ts
index f291d4214f..3251056b11 100644
--- a/app/src/lib/computers/screen.ts
+++ b/app/src/lib/computers/screen.ts
@@ -5,6 +5,7 @@ import {
} from "@/lib/api/generated/computers/computers";
import { idempotencyKey, organizationId } from "@/lib/api/request";
import { ClientError } from "@/lib/client";
+import { isComputerRefusal } from "./access";
import type { ComputerState } from "./queries";
import { settledRefusal } from "./refusal";
@@ -35,6 +36,11 @@ export type ScreenshotRead = {
frame?: Screenshot;
error?: string;
notReady?: { state: ComputerState; reason?: string };
+ /**
+ * This person may not see the Bot's computer (lib/computers/access.ts). Not a computer on its way up, and not
+ * a failure that may pass: asking again gets the same answer, so the caller stops asking and says so.
+ */
+ refused?: true;
};
const COMPUTER_STATES: readonly ComputerState[] = [
@@ -66,6 +72,7 @@ export async function readScreenshot(
if (notReady) return { notReady };
return parseScreenshot(body);
} catch (error) {
+ if (isComputerRefusal(error)) return { refused: true };
// The server's own sentence when it said why; otherwise the screen is simply not there.
return {
error: error instanceof ClientError ? error.message : unavailable,
diff --git a/app/src/lib/computers/use-control.ts b/app/src/lib/computers/use-control.ts
index 7ff5c028d3..034c71f22f 100644
--- a/app/src/lib/computers/use-control.ts
+++ b/app/src/lib/computers/use-control.ts
@@ -25,8 +25,19 @@ type Snapshot = {
control: ControlState | null;
busy: boolean;
problem: string | null;
+ /**
+ * The last read was refused because this person may not reach the Bot's computer (`BOT_GONE`): a teammate on a
+ * private Bot shared with them, or a Bot taken from them. Nobody will ever have control to show them, so a view
+ * says that (lib/computers/access.ts) and stops saying "Checking who has control…".
+ */
+ refused: boolean;
+};
+const EMPTY: Snapshot = {
+ control: null,
+ busy: false,
+ problem: null,
+ refused: false,
};
-const EMPTY: Snapshot = { control: null, busy: false, problem: null };
type ControlStore = {
getSnapshot: () => Snapshot;
refresh: () => Promise;
@@ -120,13 +131,17 @@ function createControlStore(computerId: string): ControlStore {
* takes the tab to signing in again (`askWhoIsSignedIn`).
*/
gone = answer === BOT_GONE || answer === SIGNED_OUT;
+ const refused = answer === BOT_GONE;
if (gone) {
failures = 0;
if (answer === SIGNED_OUT) void askWhoIsSignedIn(queryClient);
- if (snapshot.control || snapshot.problem)
- publish({ ...snapshot, control: null, problem: null });
+ if (snapshot.control || snapshot.problem || snapshot.refused !== refused)
+ publish({ ...snapshot, control: null, problem: null, refused });
return;
}
+ // Reachable again (the tab came back to a Bot that is theirs once more): no longer refused, and that is news.
+ const wasRefused = snapshot.refused;
+ if (wasRefused) snapshot = { ...snapshot, refused: false };
const control =
answer === BOT_GONE || answer === SIGNED_OUT ? null : answer;
/*
@@ -148,6 +163,7 @@ function createControlStore(computerId: string): ControlStore {
// The same answer as last time changes nothing on screen, so nothing is told. Every view of the
// computer re-rendered once a second for a state that had not moved.
if (
+ !wasRefused &&
problem === snapshot.problem &&
JSON.stringify(control) === JSON.stringify(snapshot.control)
) {
@@ -191,6 +207,7 @@ function createControlStore(computerId: string): ControlStore {
: await cancelControl(computerId, requestId)
: null;
publish({
+ ...snapshot,
control: next ?? control,
busy: false,
problem: next
diff --git a/app/tests/computer-refused.test.tsx b/app/tests/computer-refused.test.tsx
new file mode 100644
index 0000000000..3e3f8d5e5f
--- /dev/null
+++ b/app/tests/computer-refused.test.tsx
@@ -0,0 +1,408 @@
+import {
+ afterAll,
+ afterEach,
+ beforeAll,
+ describe,
+ expect,
+ test,
+} from "bun:test";
+import { GlobalRegistrator } from "@happy-dom/global-registrator";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import {
+ createMemoryHistory,
+ createRootRoute,
+ createRouter,
+ RouterProvider,
+} from "@tanstack/react-router";
+import { act, cleanup, render } from "@testing-library/react";
+import type { ReactElement } from "react";
+import { ComputerViewPanel } from "@/components/computer/computer-panel";
+import { ComputerView } from "@/components/computer/computer-view";
+import { computerRefusedNow } from "@/lib/computers/access";
+import {
+ connectScreen,
+ type ScreenSocket,
+} from "@/lib/computers/screen-connection";
+import { ME_PATH, meResponse } from "./accounts-api";
+import { DEPLOYMENT_PATH, deploymentResponse } from "./admin-settings-api";
+import { settleReactWork } from "./settle-react-work";
+
+/**
+ * A teammate a private Bot is shared with opens its Computer, and is told it isn't theirs to see.
+ *
+ * OpenBot lets an admin, anybody on a public Bot, and the Bot's owner see its computer; nobody else. A teammate
+ * on a private Bot chats with it, but every call about its computer, and its live screen and terminal sockets, are
+ * answered 404 BOT_NOT_FOUND (api/openapi/computers.yaml). The panel read those as a computer starting ("Starting
+ * Fernhill Guide's computer… The first start takes about a minute") for ever, "Checking who has control…" for ever,
+ * and the terminal "Reconnecting…".
+ *
+ * The Bot read now says so up front (`Bot.computerAccess`), and the panel opens nothing. A server older than that
+ * field says it only by the 404, and every view ends on the same honest words instead of a spinner.
+ *
+ * Drawn for real: the panel, the screen and the terminal's connection with their own queries and the generated
+ * client, against a server stand-in at the API's addresses that answers each viewer as the server does and keeps
+ * every request and socket it was sent. A refused socket is what a browser sees of the server's 404 to the upgrade:
+ * an error and a close, and never an open.
+ */
+
+const ORGANIZATION = "/api/v2/organizations/default";
+const COMPUTERS_PATH = `${ORGANIZATION}/computers`;
+const BOT = "fernhill-guide";
+const BOT_PATH = `${ORGANIZATION}/bots/${BOT}`;
+const OWNER = "ada";
+
+type Viewer = "owner" | "admin" | "teammate";
+
+/** Whether the server serves `Bot.computerAccess`, or is older than it. */
+type Server = "current" | "older";
+
+/** The API's `ComputerBotNotFound`, as api/openapi/computers.yaml gives it. */
+function botNotFound() {
+ return Response.json(
+ {
+ type: "https://open.bot/errors/bot-not-found",
+ title: "Bot not found.",
+ status: 404,
+ detail: "Couldn't find that Bot.",
+ code: "BOT_NOT_FOUND",
+ category: "not_found",
+ retryable: false,
+ },
+ { status: 404, headers: { "content-type": "application/problem+json" } },
+ );
+}
+
+/** Every socket the screen opened, and whether the server let it through. */
+const sockets: string[] = [];
+let socketsRefused = false;
+
+class SocketDouble {
+ static readonly OPEN = 1;
+ static readonly CLOSED = 3;
+ readyState = 0;
+ binaryType = "blob";
+ onopen: (() => void) | null = null;
+ onmessage: ((event: { data: unknown }) => void) | null = null;
+ onerror: (() => void) | null = null;
+ onclose: (() => void) | null = null;
+ constructor(readonly url: string) {
+ sockets.push(url);
+ const refused = socketsRefused;
+ queueMicrotask(() => {
+ if (refused) {
+ // What a browser reports of an upgrade the server answered 404: no status, an error and a close.
+ this.readyState = SocketDouble.CLOSED;
+ this.onerror?.();
+ this.onclose?.();
+ return;
+ }
+ this.readyState = SocketDouble.OPEN;
+ this.onopen?.();
+ });
+ }
+ send() {}
+ close() {
+ this.readyState = SocketDouble.CLOSED;
+ }
+}
+
+let originalFetch: typeof fetch;
+let originalWebSocket: typeof WebSocket;
+let originalIntersectionObserver: typeof IntersectionObserver | undefined;
+let originalDecode: typeof HTMLImageElement.prototype.decode;
+
+beforeAll(() => {
+ GlobalRegistrator.register();
+ originalFetch = globalThis.fetch;
+ originalWebSocket = globalThis.WebSocket;
+ originalIntersectionObserver = globalThis.IntersectionObserver;
+ originalDecode = HTMLImageElement.prototype.decode;
+ globalThis.WebSocket = SocketDouble as unknown as typeof WebSocket;
+ // Without an observer the Bot's screen counts as on screen, so it reads what it would in the app.
+ Reflect.deleteProperty(globalThis, "IntersectionObserver");
+ HTMLImageElement.prototype.decode = () => Promise.resolve();
+});
+
+afterEach(() => {
+ cleanup();
+ globalThis.fetch = originalFetch;
+ sockets.length = 0;
+ socketsRefused = false;
+});
+
+afterAll(async () => {
+ await settleReactWork();
+ globalThis.fetch = originalFetch;
+ globalThis.WebSocket = originalWebSocket;
+ if (originalIntersectionObserver)
+ globalThis.IntersectionObserver = originalIntersectionObserver;
+ HTMLImageElement.prototype.decode = originalDecode;
+ GlobalRegistrator.unregister();
+});
+
+/**
+ * The server, as it answers one viewer of Ada's private Bot: Ada, its owner; an admin; or a teammate it is shared
+ * with, who may chat with it but not see its computer.
+ */
+function serve(viewer: Viewer, server: Server = "current") {
+ const asked: string[] = [];
+ const allowed = viewer !== "teammate";
+ socketsRefused = !allowed;
+ globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
+ const path = new URL(String(input), "http://openbot.test").pathname;
+ asked.push(`${init?.method ?? "GET"} ${path}`);
+ if (path === DEPLOYMENT_PATH)
+ return deploymentResponse({ botComputers: true });
+ if (path === ME_PATH)
+ return meResponse({
+ user: {
+ id: viewer === "owner" ? OWNER : viewer,
+ name: viewer,
+ role: viewer === "admin" ? "admin" : "member",
+ },
+ });
+ if (path === BOT_PATH)
+ return Response.json({
+ bot: {
+ id: BOT,
+ name: "Fernhill Guide",
+ title: "",
+ roleDescription: "Finds walks.",
+ avatarSeed: BOT,
+ visibility: "private",
+ hidden: false,
+ pinned: false,
+ systemOwned: false,
+ endpoint: null,
+ hasAuth: false,
+ hasCallbackToken: false,
+ isolated: false,
+ computer: "browser",
+ canManage: viewer !== "teammate",
+ mine: viewer === "owner",
+ assignedToMe: false,
+ builtIn: true,
+ runsOnOpenBotModel: true,
+ keyFromOpenBot: true,
+ isolationActive: false,
+ isolationOffReason: null,
+ ...(server === "current"
+ ? { computerAccess: allowed ? "allowed" : "refused" }
+ : {}),
+ },
+ });
+ if (path.startsWith(`${COMPUTERS_PATH}/${BOT}`)) {
+ if (!allowed) return botNotFound();
+ if (path === `${COMPUTERS_PATH}/${BOT}`)
+ return Response.json({ botId: BOT, state: "ready" });
+ if (path === `${COMPUTERS_PATH}/${BOT}/control`)
+ return Response.json({
+ holder: "bot",
+ since: new Date(0).toISOString(),
+ requested: false,
+ });
+ if (path === `${COMPUTERS_PATH}/${BOT}/screenshot`)
+ return Response.json({
+ base64: "AAAA",
+ width: 320,
+ height: 200,
+ capturedAt: new Date(0).toISOString(),
+ url: "https://example.com/",
+ });
+ if (path === `${COMPUTERS_PATH}/${BOT}/activity`)
+ return Response.json({ items: [], nextCursor: null });
+ }
+ return Response.json({ detail: "Not here." }, { status: 404 });
+ }) as typeof fetch;
+ return {
+ asked,
+ /** Every request about the Bot's computer: its status, control, screenshot, browser and activity. */
+ aboutComputer: () =>
+ asked.filter((request) => request.includes(`${COMPUTERS_PATH}/${BOT}`)),
+ };
+}
+
+function draw(ui: ReactElement) {
+ const client = new QueryClient({
+ defaultOptions: { queries: { retry: false } },
+ });
+ const router = createRouter({
+ history: createMemoryHistory({ initialEntries: ["/"] }),
+ routeTree: createRootRoute({ component: () => ui }),
+ });
+ return render(
+
+
+ ,
+ );
+}
+
+async function settle(ms = 250) {
+ await act(async () => {
+ await new Promise((resolve) => setTimeout(resolve, ms));
+ });
+}
+
+const TITLE = "This Bot's computer is private";
+const LINE = /Only the Bot's owner and admins can see/;
+
+/** What the panel used to say, for ever, to somebody the server refuses. */
+function expectNoSpinner(view: ReturnType) {
+ expect(view.queryByText(/^Starting/)).toBeNull();
+ expect(view.queryByText(/first start takes/)).toBeNull();
+ expect(view.queryByText("Checking who has control…")).toBeNull();
+ expect(view.queryByText(/Couldn't load the Bot's browser/)).toBeNull();
+ expect(view.queryByText("Reconnecting…")).toBeNull();
+ expect(view.queryByText(/Can't show the screen/)).toBeNull();
+}
+
+describe("a teammate on a shared private Bot opens its Computer", () => {
+ test("is told only its owner and admins can see it, and nothing of the computer is read or opened", async () => {
+ const server = serve("teammate");
+ const view = draw(
+ ,
+ );
+
+ expect(await view.findByText(TITLE)).toBeTruthy();
+ expect(view.getByText(LINE)).toBeTruthy();
+ // Past the next second's reads too: who has control and the screen are read every second where they may be.
+ await settle(1200);
+ expectNoSpinner(view);
+ expect(view.queryByRole("tab")).toBeNull();
+ expect(view.queryByRole("button")).toBeNull();
+ expect(view.queryByText("Activity")).toBeNull();
+ expect(server.aboutComputer()).toEqual([]);
+ expect(sockets).toEqual([]);
+ });
+
+ test("against a server older than the field, ends on the same words once the server refuses, and stops asking", async () => {
+ const server = serve("teammate", "older");
+ const view = draw(
+ ,
+ );
+
+ expect(await view.findByText(TITLE)).toBeTruthy();
+ expect(view.getByText(LINE)).toBeTruthy();
+ await settle(1200);
+ expectNoSpinner(view);
+ expect(view.queryByRole("tab")).toBeNull();
+ // Refused once, and that is the answer: nothing is asked again a few seconds later.
+ const askedBy = server.aboutComputer().length;
+ await settle(2500);
+ expect(server.aboutComputer().length).toBe(askedBy);
+ expectNoSpinner(view);
+ }, 10_000);
+
+ test("a card of the Bot's screen in the conversation says so too, against a server older than the field", async () => {
+ const server = serve("teammate", "older");
+ const view = draw(
+ ,
+ );
+
+ expect(await view.findByText(LINE)).toBeTruthy();
+ await settle(1200);
+ expectNoSpinner(view);
+ expect(view.queryByRole("button", { name: "Take control" })).toBeNull();
+ const askedBy = server.aboutComputer().length;
+ await settle(2500);
+ expect(server.aboutComputer().length).toBe(askedBy);
+ }, 10_000);
+
+ test("the terminal's socket, refused, is not retried as a dropped connection", async () => {
+ serve("teammate", "older");
+ const said = { reconnecting: false, problem: null as string | null };
+ let refused = false;
+ let opened = 0;
+
+ const connection = connectScreen({
+ open: () => {
+ opened += 1;
+ return new SocketDouble(
+ `${COMPUTERS_PATH}/${BOT}/terminal`,
+ ) as unknown as ScreenSocket;
+ },
+ verifyOwnership: async () => true,
+ onReady: () => undefined,
+ onProblem: (problem) => {
+ said.problem = problem;
+ },
+ onReconnecting: (reconnecting) => {
+ if (reconnecting) said.reconnecting = true;
+ },
+ onDisconnect: () => undefined,
+ onMessage: () => undefined,
+ refused: () => computerRefusedNow(BOT),
+ onRefused: () => {
+ refused = true;
+ },
+ } as Parameters[0]);
+ await settle(1800);
+ connection.stop();
+
+ expect(refused).toBe(true);
+ expect(said.reconnecting).toBe(false);
+ expect(said.problem).toBeNull();
+ expect(opened).toBe(1);
+ });
+});
+
+describe("the owner and an admin open the same Bot's Computer", () => {
+ for (const viewer of ["owner", "admin"] as const) {
+ test(`the ${viewer} sees its screen, terminal, wheel and activity, as before`, async () => {
+ const server = serve(viewer);
+ const view = draw(
+ ,
+ );
+
+ expect(await view.findByRole("tab", { name: "Screen" })).toBeTruthy();
+ expect(view.getByRole("tab", { name: "Terminal" })).toBeTruthy();
+ expect(
+ await view.findByAltText("What the Bot is looking at"),
+ ).toBeTruthy();
+ expect(
+ await view.findByRole("button", { name: "Take control" }),
+ ).toBeTruthy();
+ expect(view.getByText("Activity")).toBeTruthy();
+ expect(view.queryByText(TITLE)).toBeNull();
+ const about = new Set(server.aboutComputer());
+ expect(about.has(`GET ${COMPUTERS_PATH}/${BOT}/control`)).toBe(true);
+ expect(about.has(`GET ${COMPUTERS_PATH}/${BOT}/screenshot`)).toBe(true);
+ });
+ }
+
+ test("a socket that drops before it opens, for somebody who may see the computer, is retried as before", async () => {
+ serve("owner");
+ // The server lets the owner in, but this socket never opened: a network that dropped it.
+ socketsRefused = true;
+ let reconnecting = false;
+ let refused = false;
+ let opened = 0;
+
+ const connection = connectScreen({
+ open: () => {
+ opened += 1;
+ return new SocketDouble(
+ `${COMPUTERS_PATH}/${BOT}/terminal`,
+ ) as unknown as ScreenSocket;
+ },
+ verifyOwnership: async () => true,
+ onReady: () => undefined,
+ onProblem: () => undefined,
+ onReconnecting: (next) => {
+ if (next) reconnecting = true;
+ },
+ onDisconnect: () => undefined,
+ onMessage: () => undefined,
+ refused: () => computerRefusedNow(BOT),
+ onRefused: () => {
+ refused = true;
+ },
+ } as Parameters[0]);
+ await settle(1000);
+ connection.stop();
+
+ expect(refused).toBe(false);
+ expect(reconnecting).toBe(true);
+ expect(opened).toBeGreaterThanOrEqual(2);
+ });
+});
diff --git a/mobile/src/api/generated/model/bot.ts b/mobile/src/api/generated/model/bot.ts
index 23049c584e..ee6ec1034a 100644
--- a/mobile/src/api/generated/model/bot.ts
+++ b/mobile/src/api/generated/model/bot.ts
@@ -47,6 +47,8 @@ export interface Bot {
isolated: boolean;
/** The computer it works on: browser, the Bot's own browser computer, which every Bot has unless told otherwise; or windows, the Windows computer of the person it works for: in a conversation, theirs; in a routine, its owner's. One at a time. Experimental. */
computer?: string;
+ /** Whether the caller may see and use this Bot's browser computer: its screen, its terminal, who has control and its activity. allowed for an admin, on a public Bot, and for its owner. refused for anybody else, such as a teammate a private Bot is shared with, who still chats with it; every computer call and the live screen and terminal answer them 404 BOT_NOT_FOUND. A client that reads refused opens none of them and says so. Absent from a server older than this field, where a client learns it from that 404. A value this client doesn't know reads as allowed. Never accepted when a Bot is created or changed. */
+ readonly computerAccess?: string;
/** What the starter Bot is told, kept apart from its role description. Only the starter Bot has instructions. */
instructions?: string;
/** What runs it, by the name a person reads ("LangChain", "OpenBot"). Absent when OpenBot doesn't know. */