Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Team Clouds: a bot is its maker's until they share it (#5463)

Milind Sonia53326c8c9ef
diff --git a/docs/team-cloud.md b/docs/team-cloud.md
index 73419962fd..b3ba93d9e7 100644
--- a/docs/team-cloud.md
+++ b/docs/team-cloud.md
@@ -10,7 +10,7 @@ keeps people apart on it. The bot box ([bot-box.md](bot-box.md)) is what makes t
- **Signing in.** Each person pairs from the app with a link the Admin signs for them; the machine shows the team's name
wherever a server names itself. Owners and Admins get everything an admin session can do (Super admin and Admin in the
app); a Member (User) uses each bot as far as it is shared with them (below, "Who can use a bot"), uses rooms and
- makes routines, and connects no app and makes no webhook. Owners and Admins also get **Invite someone** under People in
+ makes routines and bots of their own (below, "A User's own bot"), and connects no app and makes no webhook. Owners and Admins also get **Invite someone** under People in
the sidebar, in Simple too and when they are alone on the team: it opens the team's People page on the Cloud in their
browser, where they sign in if that browser hasn't yet.
With Azure OpenAI chosen for Live calls, only an Owner or
@@ -275,7 +275,7 @@ this server shares with every bot. It exists only on a Team Cloud.
toward the person's and the team's totals (`server/host/private-records.ts`). What a person changes on their own
MausBot is never recorded in admin activity.
- For a business sign-in (Claude or ChatGPT on this server), the Admin opens this server's own pages signed in as that
- admin (a browser sign-in with the member's claim) at `/?connect=ai` (or `apps`, `mcp`, `keys`).
+ admin (a browser sign-in with the member's claim) at `/?connect=ai` (or `apps`, `mcp`, `keys`, and `bots` for Settings → Bot access, which opens for an admin only).
## Connections: the team's or each person's
@@ -546,8 +546,11 @@ none, and the person can hide it.
- **Just me** lists the bots the person can chat with privately (their own MausBot among them), each with their own
conversations with it, and no group chat. A bot opens the person's own chat with it, made through `POST
/api/bots/<id>/tasks` the first time.
-- **Team** lists the bots that have a shared chat, each with its shared conversations only, and the group chats. A bot
- opens its shared chat. A bot with no shared chat (a person's own MausBot) is not listed there. No new conversation is
+- **Team** lists the bots shared with someone (everyone, or at least one person besides whoever looks after it), each
+ with its shared conversations only, and the group chats. A bot opens its shared chat. A person's own MausBot is not
+ listed there, and neither is a bot only its owner and the admins can use (`sharedWithOthers`): that one is under Just
+ me whole, its main chat with it, which still says who reads it by the message box (*"Shared · only people added and
+ admins can see"*) and is never called private. No new conversation is
offered beside a shared chat: a conversation a person opens is always private, so New conversation is under Just me.
- **Which side a conversation is on is the server's answer**, never the switch: `private: true` on the task (or a
conversation this page just made through that route, or the person's own MausBot) is Just me; everything else, a
@@ -613,7 +616,7 @@ conversation that came in from outside.
## A bot's owner
Every team bot has one **owner**, a member: `reportsTo` (an email) names them; without it the owner is `createdBy`, the
-member who created it or moved it in (a bot a Chief creates gets the Chief's owner). Bots made before owners were
+member who created it, imported it or moved it in (a bot a Chief creates gets the Chief's owner). Bots made before owners were
recorded have none until someone picks one, and their asks go to the Admins. The app says "Owner" wherever it names this
(Bot access, a new bot's form, a bot's menu: "Owner: Ada…"; the Share dialog still says "Looks after it") and shows no
face on a bot's sidebar row and no caption beside a department. An Admin, or the owner handing it over, changes it one bot
@@ -674,7 +677,7 @@ Every bot still reaches every bot there.
Someone with a My Cloud moves a bot into a team from two places: **Move to Acme** in the bot's menu on My Cloud, and on the
team's own page in the desktop app, **Bring your stuff**, which lists My Cloud's bots with one **Move** each. Both say the
-same before anything moves: who can use it there, what goes (instructions, skills, files, routines, their chats), what
+same before anything moves: that only they and the team's admins can use it there until they share it, what goes (instructions, skills, files, routines, their chats), what
stays on My Cloud (what the bot remembers, their connections, MausBot), and that there is no way back.
A team's server isn't the person's own, so its page gets less than My Cloud's does (`electron/team-move-main.mjs`). It reads
@@ -704,8 +707,37 @@ allow, folders), where it runs, its department, whom it answers to or directs, c
the whole value sets it (Undo puts the previous one back): someone who can edit it only, a new person must be a
current member of the team (an older list's address or `@domain` may stay), and the owner is never stored. The bot's
`visibility` follows in the same write (everyone when everyone may at least view it, else the owner and the people
- added), so every rule of the audience rule above that reads who sees a bot holds unchanged. A new team bot is
- Everyone · Can chat. A member's own MausBot stays theirs alone, as before.
+ added), so every rule of the audience rule above that reads who sees a bot holds unchanged. A member's own
+ MausBot stays theirs alone, as before.
+- **A new bot is its maker's until they share it** (`server/new-bot-sharing.ts`, the one place that decides, set on the
+ store before anything is made). A bot made on a team starts as Only people added with nobody added: whoever looks
+ after it and the admins reach it, and to every other member it does not exist. That holds for New bot, a preset, a
+ copy, a package or template (the organization library's too), a backup and a bot moved in from My Cloud; an import
+ records the member who ran it as the one who made its bots. Three things differ. A request that says who sees the
+ bot wins: `visibility` on `POST /api/bots` ("everyone" is Everyone · Can chat) and `?visibility=` on an import, an
+ admin's choice. A bot another bot makes (a Chief's reviewed setup) is shared exactly as its maker is, because bots
+ reach each other only with the same audience (above), so a private Chief makes private bots and a shared one bots
+ shared with the same people. And the team's first bot, which nobody made, is everyone's. New bot's form states
+ General access as Just me or Everyone in Acme, preset to Just me. Bots made before this are untouched.
+- **A User's own bot.** A User makes a bot with New bot (`POST /api/bots`, which the handler opens to a Team Cloud
+ member and to no other session without the admin scope). It is theirs: they look after it, it is private to them,
+ and they change it as anyone who can edit a bot does. The request takes only what Can edit lets a person change
+ (`memberBotCreateViolation`, the same fields as the edit rule): its name, picture, instructions, profile, model, and
+ which of the team's connected apps and MCP servers it uses. Anything an admin alone sets is refused by name, at
+ creation and on every later edit (403 *"approvalMode" is an admin's to set*): what it may do on its computer, where
+ it runs, its department, whom it answers to or directs, a crown, its tool selection, a preset, its sharing at
+ creation (it starts private; they share it after). The admin's saved New bot defaults are not applied to it, so
+ those settings are what the server gives any bot nobody set up. Templates, packages, backups and the Grok Bot
+ import stay an admin's: they carry skills, notes, routines and approval levels. The team's bot limit counts every
+ bot alike, and the team's rules apply to a User's bot as to any other. An admin sees and changes it as any team
+ bot, and still reads none of its owner's private chats with it. **Deleting:** a User deletes a bot they look after
+ while nobody else can use it (`DELETE /api/bots/<id>`, `server/host/member-bots.ts`). Once it is shared with anyone,
+ or for any bot they do not look after, deleting stays with the admins, as it always was: the app shows Delete with
+ the reason, *"Only an admin can delete a shared bot. Stop sharing it first."*, and the route answers 403 in the same
+ words. Duplicate is offered for a bot they can edit and copies who it is and how it looks.
+- **Being told.** Sharing a bot with a person (`PUT /api/bots/<id>/access` newly naming a User who could not use it)
+ puts one line in that person's inbox, "Ada shared Quotes with you.", linked to the bot (`server/host/share-notice.ts`).
+ Sharing with everyone tells nobody, and neither does adding an admin or someone who could already use it.
- **A person's own MausBot exists for nobody else.** To every other member and every Admin, the Owner included, it is
in no list, stream, search, export, routine picker or group chat, whatever its stored sharing says
(`VisibleSet.bot`), and every route naming it, by path (its memory layers too) or in a body, answers exactly as an id
@@ -727,8 +759,12 @@ allow, folders), where it runs, its department, whom it answers to or directs, c
that names nobody needs everyone to be able to. The live stream sends each person their own `yourAccess` with every
bot frame, withdraws a bot that stops being shown (`bot.deleted`, and their stream ends to start fresh) and sends one
that becomes shown whole.
-- **The app.** The bot's Share button (the bot panel in Simple, the settings header in Advanced) opens the Share
- dialog on a team; the conversation's copy and download sit under the ⋯ of its header. On a team the dialog offers two
+- **The app.** The bot's Share button (the top right of its chat header, the bot panel in Simple, the settings header
+ in Advanced) opens the Share dialog on a team. Left of the header's Share is who the bot is shared with
+ (`HeaderShare`): the faces of the people added, a few and then "+N", each saying its person's name; one "Everyone in
+ Acme" mark when everyone can use it; nothing for a bot only its owner uses. It is read from what each person is
+ sent: only someone who can edit the bot is sent its sharing, so anyone else sees "Everyone in Acme" or "Only people
+ added" and never who. A narrow header folds the faces into one count. Each mark opens the Share dialog; the conversation's copy and download sit under the ⋯ of its header. On a team the dialog offers two
choices: "Everyone in Acme can use it" (`everyone: "chat"`) or "Only people added" (`everyone: "none"`), and lists
who looks after the bot and each person added, with Remove and the handover; it shows no Can view / Can chat / Can
edit menu. A person added gets `chat`; a `view` or `edit` stored earlier (or set through the API) stays as it is
@@ -824,6 +860,7 @@ inbox is unread.
| a question or approval routed to Ben (`ask-routing.ts`), from a shared chat, a room, a routine or work handed on | a copy of the card, `"ask"` | the card where it was asked: the copy's buttons answer it there (`answeredIn`) and the copy follows it |
| a routine's report or a failure routed to Ben | the report, `"result"` / `"notice"` | nothing |
| a routine Ben wrote that tried to hand work to a bot it may not reach | what was refused, `"notice"` | nothing |
+| a bot someone shared with Ben by name | "Ada shared Quotes with you.", `"notice"`, linked to the bot | nothing |
An ask in the person's own private chat, where they are, stays only there. The Admins' asks (a bot nobody owns) are not
anyone's inbox. A member without any bot of their own gets the notification where it was written, as before.
diff --git a/docs/verification/team-bot-access.md b/docs/verification/team-bot-access.md
index 846f0c21e5..992abbc842 100644
--- a/docs/verification/team-bot-access.md
+++ b/docs/verification/team-bot-access.md
@@ -108,6 +108,30 @@ checkout of the code before levels.
| The card in the owner's inbox | ![](evidence/team-bot-access/ask-card-ada-inbox.png) |
| After Allow | ![](evidence/team-bot-access/ask-allowed-bob.png) |
+## A new bot is its maker's until they share it
+
+```sh
+pnpm exec vitest run server/cloud-team-private-default.e2e.test.ts server/new-bot-sharing.test.ts server/host/share-notice.test.ts
+OMB_UI_E2E=1 OMB_TEAM_PRIVATE_SHOTS=/tmp/private-shots pnpm exec vitest run scripts/testing/team-private-default-ui.e2e.test.ts
+```
+
+The first runs a real Team Cloud with an Owner, an Admin and two Users and makes a bot every way one comes to exist
+(New bot, a preset, a copy, a package, a backup, a bot a User moves in): each starts as Only people added with nobody
+added, another User gets 404 for it on every route that names it and never lists or finds it, a request that says who
+sees it wins, sharing it with one person puts one line in that person's inbox, and a new bot on this computer and on My
+Cloud carries no sharing at all. The store's test covers a bot a Chief makes (shared exactly as the Chief) and bots saved
+before this (unchanged). The second drives the real app in headless Chrome: a User's New bot is under Just me only, a
+User neither sees it nor reaches it, the header's Share adds her and shows her face beside it, she reads the line in her
+inbox and chats, a narrow header folds the faces into a count, the Templates form states General access preset to Just
+me, and `/?connect=bots` opens Bot access for an admin and nothing for a User.
+
+A User makes a bot of their own too. The first test makes one as a User against the real routes: it is private and
+theirs, each setting an admin alone makes is refused by name at creation and on edit, the admin's saved New bot
+defaults stay out of it, another User gets 404, they share it, they delete it only while nobody else can use it, the
+team's bot limit refuses theirs in an admin's words, and `server/cloud-team-rules.e2e.test.ts` refuses a blocked
+engine on it. In the app run the maker is a User. Moving a bot in from My Cloud is driven through its routes in the
+first test and through the real move in `server/team-move.e2e.test.ts`.
+
## Not proven here
- No real Admin, phone, Slack worker or model was involved: the Admin's pairing is signed by the fixture, a relayed
diff --git a/electron/team-move-bring.node-test.mjs b/electron/team-move-bring.node-test.mjs
index 71e7090abb..94171f0fab 100644
--- a/electron/team-move-bring.node-test.mjs
+++ b/electron/team-move-bring.node-test.mjs
@@ -124,7 +124,7 @@ test("its confirm says what the page's confirm says, word for word", () => {
const words = teamMoveConfirmWords({ bot: "Atlas", team: "Acme" });
assert.equal(words.message, fill("teamMove.title"));
assert.equal(words.buttons[0], fill("teamMove.confirm"));
- for (const key of ["teamMove.everyone", "teamMove.goes", "teamMove.private", "teamMove.staysOnMyCloud", "teamMove.noWayBack"]) assert.ok(words.detail.includes(fill(key)), key);
+ for (const key of ["teamMove.yours", "teamMove.goes", "teamMove.private", "teamMove.staysOnMyCloud", "teamMove.noWayBack"]) assert.ok(words.detail.includes(fill(key)), key);
});
test("the native confirm and IPC refusals follow the app's current language", async () => {
@@ -140,7 +140,7 @@ test("the native confirm and IPC refusals follow the app's current language", as
assert.deepEqual(asked[1], {
message: "Mover Atlas para Acme?",
detail: [
- "Todos em Acme podem usar Atlas. Só os administradores de Acme podem alterá-lo.",
+ "Só você e os administradores de Acme podem usar Atlas até você compartilhar.",
"Vão com Atlas: instruções, habilidades, arquivos, rotinas e suas conversas com Atlas",
"Suas conversas continuam privadas lá: só você pode vê-las.",
"Ficam no My Cloud: o que Atlas lembra, suas conexões e o MausBot",
diff --git a/electron/team-move-main.mjs b/electron/team-move-main.mjs
index 0f15792e73..94b2e11a79 100644
--- a/electron/team-move-main.mjs
+++ b/electron/team-move-main.mjs
@@ -44,7 +44,7 @@ export function teamMoveConfirmWords(names, t = nativeText.englishText.t) {
return {
message: t("teamMove.title", names),
detail: [
- t("teamMove.everyone", names),
+ t("teamMove.yours", names),
t("teamMove.goes", names),
t("teamMove.private"),
t("teamMove.staysOnMyCloud", names),
diff --git a/scripts/ci-scope.mjs b/scripts/ci-scope.mjs
index 029b7f256a..ecf5ef88eb 100644
--- a/scripts/ci-scope.mjs
+++ b/scripts/ci-scope.mjs
@@ -67,6 +67,7 @@ export const VITEST_SUBSETS = {
"scripts/testing/secret-card-descriptions.test.ts",
"scripts/testing/team-conversation-share-ui.e2e.test.ts",
"scripts/testing/team-own-chat.e2e.test.ts",
+ "scripts/testing/team-private-default-ui.e2e.test.ts",
"scripts/testing/team-side-switch-ui.e2e.test.ts",
"server/body-thread-guards.e2e.test.ts",
"server/client-notifications.e2e.test.ts",
@@ -104,6 +105,7 @@ export const VITEST_SUBSETS = {
"server/cloud-team-pictures.e2e.test.ts",
"server/cloud-team-presence.e2e.test.ts",
"server/cloud-team-privacy-holes.e2e.test.ts",
+ "server/cloud-team-private-default.e2e.test.ts",
"server/cloud-team-private.e2e.test.ts",
"server/cloud-team-profile.e2e.test.ts",
"server/cloud-team-published-apps.e2e.test.ts",
diff --git a/scripts/ci-scope.test.ts b/scripts/ci-scope.test.ts
index 8c84c40814..f35c5bfc5d 100644
--- a/scripts/ci-scope.test.ts
+++ b/scripts/ci-scope.test.ts
@@ -207,6 +207,7 @@ describe("CI outputs", () => {
"scripts/testing/secret-card-descriptions.test.ts",
"scripts/testing/team-conversation-share-ui.e2e.test.ts",
"scripts/testing/team-own-chat.e2e.test.ts",
+ "scripts/testing/team-private-default-ui.e2e.test.ts",
"scripts/testing/team-side-switch-ui.e2e.test.ts",
"server/body-thread-guards.e2e.test.ts",
"server/client-notifications.e2e.test.ts",
@@ -244,6 +245,7 @@ describe("CI outputs", () => {
"server/cloud-team-pictures.e2e.test.ts",
"server/cloud-team-presence.e2e.test.ts",
"server/cloud-team-privacy-holes.e2e.test.ts",
+ "server/cloud-team-private-default.e2e.test.ts",
"server/cloud-team-private.e2e.test.ts",
"server/cloud-team-profile.e2e.test.ts",
"server/cloud-team-published-apps.e2e.test.ts",
diff --git a/scripts/testing/team-conversation-share-ui.e2e.test.ts b/scripts/testing/team-conversation-share-ui.e2e.test.ts
index 64b89a7f7e..0ed88fe094 100644
--- a/scripts/testing/team-conversation-share-ui.e2e.test.ts
+++ b/scripts/testing/team-conversation-share-ui.e2e.test.ts
@@ -128,7 +128,7 @@ async function openAs(who: Who, size: readonly [string, string]) {
const own = ((await as(who, "GET", "/api/bots?messages=0")).body.bots as Array<{ id: string; defaultBot?: { person?: string } }>).find((bot) => bot.defaultBot?.person === emails[who])!;
expect((await as(who, "PATCH", `/api/bots/${own.id}`, { welcomed: true, sidebarHidden: false, pinned: true })).status).toBe(200);
}
- const created = await as("olive", "POST", "/api/bots", { name: "Scout" });
+ const created = await as("olive", "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
scout = created.body.bot.id;
}, hostTimeout(300_000));
diff --git a/scripts/testing/team-own-chat.e2e.test.ts b/scripts/testing/team-own-chat.e2e.test.ts
index 430d02622a..e5ef0bd7a4 100644
--- a/scripts/testing/team-own-chat.e2e.test.ts
+++ b/scripts/testing/team-own-chat.e2e.test.ts
@@ -42,7 +42,7 @@ if (!teamFixture) console.info("skipping the team own-chat e2e: the cloud fixtur
ada: { email: "[email protected]", role: "member" }, cleo: { email: "[email protected]", role: "member" } } as Record<string, Member>)) {
tokens[who] = (await team.pair(member)).token!;
}
- const created = await team.as(tokens.olive!, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(tokens.olive!, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
scout = created.body.bot.id; main = created.body.bot.mainThreadId;
}, hostTimeout(180_000));
diff --git a/scripts/testing/team-private-default-ui.e2e.test.ts b/scripts/testing/team-private-default-ui.e2e.test.ts
new file mode 100644
index 0000000000..441060f25a
--- /dev/null
+++ b/scripts/testing/team-private-default-ui.e2e.test.ts
@@ -0,0 +1,394 @@
+// A team bot is its maker's until they share it, in the real app on a real Team Cloud (OMB_CLOUD_ROLE=team, each person
+// paired with the Admin's signed claim) in headless Chrome. Rui, a User, makes a bot with New bot: it is private, under
+// Just me only, and Marta, another User, neither sees it nor reaches it by id. Rui shares it with Marta from the Share
+// button at the top right of the chat: her face shows beside it, she gets one line in her inbox and can chat, and a
+// third User still sees nothing. Rui's menu deletes a bot of his own, and says why it can't while the bot is shared. An
+// admin's Templates form states who can use a new bot, preset to Just me. `/?connect=bots` opens Bot access for an admin
+// and nothing for a User. Run with OMB_UI_E2E=1; OMB_TEAM_PRIVATE_SHOTS=DIR keeps the screenshots.
+import { randomBytes } from "node:crypto";
+import { mkdirSync } from "node:fs";
+import { join } from "node:path";
+import { afterAll, beforeAll, describe, expect, it } from "vitest";
+
+import { WELCOME_VERSION } from "../../electron/onboarding-record.mjs";
+import { hostTimeout } from "../../server/testing/host-timeout.ts";
+import { SPOTLIGHTS } from "../../src/lib/first-conversation.ts";
+import { TOUR_STEPS } from "../../src/lib/guided-tour.ts";
+import { NOTICES } from "../../src/lib/notices.ts";
+import { launchCloudSendFixture, type CloudSendFixture, type CloudTeamFixture } from "./cloud-send-fixture.ts";
+import { agentBrowser, ensureUiBrowser, sessionEnv } from "./control-omb-ui.ts";
+import { mountPreview, REPO_ROOT } from "./preview-fixture.ts";
+
+const enabled = process.env.OMB_UI_E2E === "1";
+if (!enabled) console.info("skipping the private-until-shared UI e2e: set OMB_UI_E2E=1");
+
+const SHOTS = process.env.OMB_TEAM_PRIVATE_SHOTS || join(REPO_ROOT, ".omb-scratch", "team-private-default");
+const DESKTOP = ["1280", "800"] as const, PHONE = ["390", "844"] as const;
+const PEOPLE = { olive: "owner", ada: "admin", rui: "member", marta: "member", ben: "member" } as const;
+type Who = keyof typeof PEOPLE;
+const address = (who: Who) => `${who}@acme.test`;
+
+/** A new member is offered their own MausBot in a dialog over the app; this run leaves it for later. */
+const DISMISS = `(() => { [...document.querySelectorAll('[role="dialog"] button, dialog button')].find((button) => button.textContent.trim() === "Not now")?.click(); return true; })()`;
+
+type Access = { everyone: string; people: Record<string, string> };
+type Bot = { id: string; name: string; threadId: string; mainThreadId?: string; access?: Access; yourAccess?: string; defaultBot?: { person?: string } };
+type App = Awaited<ReturnType<typeof openAs>>;
+
+let fx: CloudSendFixture, team: CloudTeamFixture;
+let tools: { binary: string; chrome: string | null };
+const tokens = {} as Record<Who, string>;
+const apps: App[] = [];
+
+const botsOf = async (who: Who) => (await team.as(tokens[who], "GET", "/api/bots?messages=0")).body.bots as Bot[];
+const notices = async (who: Who) => (((await team.as(tokens[who], "GET", "/api/inbox")).body.rows ?? []) as Array<{ kind: string; text: string }>).filter((row) => row.kind === "notice").map((row) => row.text);
+
+/** The real renderer on the team's Cloud, signed in as one person, and what they do with it. */
+async function openAs(who: Who, size: readonly [string, string], query = "") {
+ const preview = await mountPreview({ info: { url: team.base } }, { entry: "/scripts/testing/threads-preview.tsx", route: "/__threads.html", title: "Private until shared",
+ logLevel: "warn", proxyHeaders: { ...fx.edge, authorization: `Bearer ${tokens[who]}` } });
+ // agent-browser 0.37 refuses a socket path over 103 bytes, and it lives under this home.
+ const home = join(fx.root, `b${apps.length}`);
+ mkdirSync(join(home, "tmp"), { recursive: true });
+ const env = sessionEnv({ home, session: `t${apps.length}`, chrome: tools.chrome });
+ const browser = (...args: string[]) => agentBrowser(tools.binary, env, args, 120_000);
+ await browser("set", "viewport", ...size);
+ const evaluate = async <T>(js: string) => (await browser("eval", js)).result as T;
+ await browser("open", new URL("/package.json", preview.previewUrl).href);
+ await evaluate(`(() => { for (const notice of ${JSON.stringify(NOTICES)}) localStorage.setItem(notice, "1"); return true; })()`);
+ await browser("open", `${preview.previewUrl}${query}`);
+ await evaluate(`(() => { window.__pageErrors = []; window.addEventListener("error", (event) => window.__pageErrors.push(String(event.error?.stack ?? event.message).slice(0, 1500))); return true; })()`);
+ const until = (js: string, timeout = 60_000) => expect.poll(() => evaluate<boolean>(`Boolean(${js})`), { timeout, interval: 400 }).toBe(true).catch(async (cause: unknown) => {
+ await browser("screenshot", join(SHOTS, `failed-${who}.png`)).catch(() => {});
+ const errors = await evaluate<string>("JSON.stringify(window.__pageErrors ?? null) + ' at ' + location.href").catch(() => "the page did not answer");
+ throw new Error(`${js} never held for ${who}; page errors: ${errors}`, { cause });
+ });
+ const click = async (selector: string) => {
+ await until(`document.querySelector(${JSON.stringify(selector)})`);
+ await evaluate(`document.querySelector(${JSON.stringify(selector)}).click(); true`);
+ };
+ const app = {
+ who, evaluate, until, click, browser,
+ side: () => evaluate<string | null>("document.querySelector('[data-team-side]')?.dataset.teamSide ?? null"),
+ audience: () => evaluate<string | null>("(() => { const label = document.querySelector('[data-team-audience]'); return label ? label.dataset.teamAudience + ':' + label.textContent : null; })()"),
+ listed: () => evaluate<string[]>("[...document.querySelectorAll('[data-sidebar-bot-row]')].map((row) => row.dataset.sidebarBotRow)"),
+ words: () => evaluate<string>("document.body.innerText"),
+ /** Who the header says the bot is shared with: "private", "people", "everyone" or "added". */
+ sharedWith: () => evaluate<string | null>("document.querySelector('[data-header-share]')?.dataset.headerShare ?? null"),
+ faces: () => evaluate<string[]>("[...document.querySelectorAll('[data-header-share] [data-access-stack]')].filter((stack) => stack.getClientRects().length).flatMap((stack) => [...stack.querySelectorAll('button')].map((face) => (face.dataset.accessFace ? 'face:' : 'more:') + face.title))"),
+ marker: () => evaluate<string | null>("document.querySelector('[data-header-share] [data-shared-with-marker]')?.title ?? null"),
+ fits: (selector: string) => evaluate<boolean>(`(() => { const box = document.querySelector(${JSON.stringify(selector)})?.getBoundingClientRect(); return Boolean(box && box.width > 0 && box.left >= 0 && box.right <= window.innerWidth && box.top >= 0 && box.bottom <= window.innerHeight); })()`),
+ async shot(name: string) {
+ await new Promise((resolve) => setTimeout(resolve, 500));
+ await browser("screenshot", join(SHOTS, `${name}.png`));
+ },
+ async ready() {
+ await evaluate(DISMISS);
+ await until("document.querySelector('[data-sidebar-bot-row]') || document.querySelector('textarea')");
+ await evaluate(DISMISS);
+ // An admin is shown the team's setup first, then its checklist over the foot of the sidebar, where this run clicks bots.
+ for (const label of ["Skip setup", "Hide setup"]) {
+ await evaluate(`[...document.querySelectorAll('button')].find((button) => button.textContent.trim() === ${JSON.stringify(label)})?.click(); true`);
+ await new Promise((resolve) => setTimeout(resolve, 400));
+ }
+ },
+ async choose(next: "me" | "team") {
+ await click(`[data-team-side-option="${next}"]`);
+ await expect.poll(app.side, { timeout: 30_000 }).toBe(next);
+ },
+ async openBot(id: string) {
+ await evaluate(DISMISS);
+ await click(`[data-sidebar-bot-row="${id}"]`);
+ await until(`document.querySelector('textarea[placeholder^="Message"]')`);
+ },
+ async openList() {
+ await evaluate(DISMISS);
+ await click('button[aria-label="Open bot list"]');
+ await until(`document.querySelector('button[aria-label="Open bot list"][aria-expanded="true"]')`, 30_000);
+ },
+ async say(text: string) {
+ await evaluate(`(() => { const field = document.querySelector('textarea[placeholder^="Message"]'); field.focus();
+ Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value").set.call(field, ${JSON.stringify(text)});
+ field.dispatchEvent(new Event("input", { bubbles: true })); return true; })()`);
+ await browser("press", "Enter");
+ await expect.poll(() => evaluate<string>("document.querySelector('main')?.innerText ?? ''"), { timeout: 30_000 }).toContain(text);
+ },
+ async type(selector: string, text: string) {
+ await until(`document.querySelector(${JSON.stringify(selector)})`);
+ await evaluate(`(() => { const field = document.querySelector(${JSON.stringify(selector)}); field.focus();
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value").set.call(field, ${JSON.stringify(text)});
+ field.dispatchEvent(new Event("input", { bubbles: true })); return true; })()`);
+ },
+ /** The header's Share dialog: opened from the Share button itself. */
+ async openShare() {
+ await click("[data-header-share] [data-share-bot-button]");
+ await until("document.querySelector('[data-share-bot]')");
+ },
+ async closeShare() {
+ await evaluate(`[...document.querySelectorAll('[data-share-bot] footer button')].at(-1).click(); true`);
+ await until("!document.querySelector('[data-share-bot]')");
+ },
+ async close() {
+ await browser("close").catch(() => {});
+ await preview.close();
+ },
+ };
+ apps.push(app);
+ return app;
+}
+
+(enabled ? describe : describe.skip)("a team bot is its maker's until they share it, in the real app", () => {
+ let scout = "", quotes: Bot;
+
+ beforeAll(async () => {
+ mkdirSync(SHOTS, { recursive: true });
+ tools = await ensureUiBrowser(process.env);
+ fx = await launchCloudSendFixture({ onePasswordToken: `ops_fake-private-default-${randomBytes(8).toString("hex")}`, team: { id: "team-acme-private-ui", name: "Acme" } });
+ team = fx.team!;
+ for (const who of Object.keys(PEOPLE) as Who[]) tokens[who] = (await team.pair({ email: address(who), role: PEOPLE[who] })).token!;
+ const onboarding = { completedAt: new Date().toISOString(), version: WELCOME_VERSION, hintsSeen: [...TOUR_STEPS.map((step) => step.id), ...SPOTLIGHTS, "cloud-welcome-done", "cloud-setup-hidden"] };
+ expect((await team.as(tokens.olive, "PATCH", "/api/config", { onboarding, language: "en" })).status).toBe(200);
+ for (const who of Object.keys(PEOPLE) as Who[]) {
+ await team.as(tokens[who], "PUT", "/api/me/welcome", { welcomed: true });
+ const own = (await botsOf(who)).find((bot) => bot.defaultBot?.person === address(who))!;
+ const added = await team.as(tokens[who], "PATCH", `/api/bots/${own.id}`, { welcomed: true, sidebarHidden: false, pinned: true });
+ expect(added.status, JSON.stringify(added.body)).toBe(200);
+ }
+ // One bot the whole team already uses, so everyone has a Team side to compare with.
+ const created = await team.as(tokens.olive, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
+ expect(created.status, JSON.stringify(created.body)).toBe(201);
+ scout = created.body.bot.id;
+ }, hostTimeout(300_000));
+ afterAll(async () => {
+ for (const app of apps) await app.close().catch(() => {});
+ await fx?.close();
+ }, hostTimeout(120_000));
+
+ it("a User's New bot makes a bot only he and the admins can use: under Just me only, and another User neither sees it nor reaches it", async () => {
+ const rui = await openAs("rui", DESKTOP);
+ await rui.ready();
+ const before = new Set((await botsOf("rui")).map((bot) => bot.id));
+ await rui.click('button[aria-label="New or share"]');
+ await rui.until(`[...document.querySelectorAll('[role="menu"] [role="menuitem"]')].some((item) => /^new bot$/i.test(item.textContent.trim()))`);
+ const offered = await rui.evaluate<string[]>(`[...document.querySelectorAll('[role="menu"] [role="menuitem"]')].map((item) => item.textContent.trim())`);
+ expect(offered, "a User is offered New bot").toEqual(expect.arrayContaining(["New bot", "New group chat"]));
+ expect(offered, "and no Templates, which stay an admin's").not.toContain("Templates");
+ await rui.shot("00-rui-user-plus-menu-desktop");
+ await rui.evaluate(`[...document.querySelectorAll('[role="menu"] [role="menuitem"]')].find((item) => /^new bot$/i.test(item.textContent.trim())).click(); true`);
+ await rui.type("[data-new-bot-name] input", "Quotes");
+ await rui.click('[data-new-bot-name] button[type="submit"]');
+ await expect.poll(async () => (await botsOf("rui")).filter((bot) => !before.has(bot.id)).length, { timeout: 60_000, interval: 500 }).toBe(1);
+ quotes = (await botsOf("rui")).find((bot) => !before.has(bot.id))!;
+ expect(quotes.name).toBe("Quotes");
+ expect(quotes.access, "Only people added, nobody added").toEqual({ everyone: "none", people: {} });
+ expect([(quotes as Bot & { createdBy?: string }).createdBy, quotes.yourAccess], "he looks after it").toEqual([address("rui"), "edit"]);
+ for (const admin of ["olive", "ada"] as const) expect((await botsOf(admin)).find((bot) => bot.id === quotes.id)?.yourAccess, admin).toBe("edit");
+
+ await rui.until(`document.querySelector('[data-sidebar-bot-row="${quotes.id}"]') && document.querySelector('textarea[placeholder^="Message"]')`);
+ await expect.poll(rui.audience, { timeout: 30_000 }).toBe("me:Private · only you");
+ await expect.poll(rui.sharedWith, { timeout: 30_000 }).toBe("private");
+ expect(await rui.faces(), "no face and no mark beside Share").toEqual([]);
+ expect(await rui.marker()).toBeNull();
+ expect(await rui.fits("[data-header-share] [data-share-bot-button]"), "Share is at the top of the chat").toBe(true);
+ await rui.shot("01-rui-new-bot-private-desktop");
+ await rui.choose("team");
+ expect(await rui.listed(), "a bot nobody else can use is not on the Team side").not.toContain(quotes.id);
+ expect(await rui.listed()).toContain(scout);
+ await rui.shot("02-rui-team-side-without-it-desktop");
+ await rui.choose("me");
+ expect(await rui.listed()).toContain(quotes.id);
+
+ for (const who of ["marta", "ben"] as const) {
+ expect((await botsOf(who)).some((bot) => bot.id === quotes.id), `${who}'s list`).toBe(false);
+ expect((await team.as(tokens[who], "GET", `/api/threads/${quotes.mainThreadId ?? quotes.threadId}/messages?limit=5`)).status, `${who} by id`).toBe(404);
+ expect((await team.as(tokens[who], "POST", `/api/bots/${quotes.id}/messages`, { text: "hello" })).status, `${who} writing to it`).toBe(404);
+ }
+ const marta = await openAs("marta", DESKTOP);
+ await marta.ready();
+ expect(await marta.listed()).not.toContain(quotes.id);
+ expect(await marta.words()).not.toContain(quotes.name);
+ await marta.choose("team");
+ expect(await marta.listed()).not.toContain(quotes.id);
+ expect(await marta.words()).not.toContain(quotes.name);
+ await marta.shot("03-marta-cannot-see-it-desktop");
+ await marta.close();
+ await rui.close();
+ }, hostTimeout(420_000));
+
+ it("Rui shares it with Marta from the header's Share: her face shows there, she is told once in her inbox and can chat", async () => {
+ const rui = await openAs("rui", DESKTOP);
+ await rui.ready();
+ await rui.openBot(quotes.id);
+ await rui.openShare();
+ expect(await rui.evaluate<string>("document.querySelector('[data-share-bot] [data-share-general]').dataset.shareGeneral")).toBe("none");
+ await rui.shot("04-rui-share-dialog-desktop");
+ await rui.type('[data-share-bot] input[role="combobox"]', "Marta");
+ await rui.until(`document.querySelector('[data-share-suggestion="${address("marta")}"]')`);
+ await rui.evaluate(`document.querySelector('[data-share-suggestion="${address("marta")}"]').dispatchEvent(new MouseEvent("mousedown", { bubbles: true })); true`);
+ await expect.poll(async () => (await botsOf("rui")).find((bot) => bot.id === quotes.id)?.access, { timeout: 30_000 }).toEqual({ everyone: "none", people: { [address("marta")]: "chat" } });
+ await rui.closeShare();
+ await expect.poll(rui.sharedWith, { timeout: 30_000 }).toBe("people");
+ expect(await rui.faces(), "her face, named, beside Share").toEqual(["face:Marta"]);
+ expect(await rui.fits(`[data-header-share] [data-access-face="${address("marta")}"]`)).toBe(true);
+ await rui.shot("05-rui-shared-with-marta-desktop");
+ await rui.choose("team");
+ expect(await rui.listed(), "shared with someone, it is on the Team side now").toContain(quotes.id);
+ await rui.choose("me");
+
+ expect(await notices("marta")).toEqual([`Rui shared ${quotes.name} with you.`]);
+ expect(await notices("ben"), "nobody else is told").toEqual([]);
+ expect((await botsOf("ben")).some((bot) => bot.id === quotes.id), "and nobody else sees it").toBe(false);
+
+ const marta = await openAs("marta", DESKTOP);
+ await marta.ready();
+ await marta.until(`document.querySelector('[data-sidebar-bot-row="${quotes.id}"]')`);
+ const line = `document.body.innerText.includes(${JSON.stringify(`Rui shared ${quotes.name} with you.`)})`;
+ if (!(await marta.evaluate<boolean>(line))) await marta.evaluate(`[...document.querySelectorAll('button')].find((button) => /inbox/i.test(button.getAttribute('aria-label') ?? button.textContent ?? ''))?.click(); true`);
+ await marta.until(line);
+ await marta.shot("06-marta-inbox-line-desktop");
+ await marta.openBot(quotes.id);
+ await expect.poll(marta.audience, { timeout: 30_000 }).toBe("me:Private · only you");
+ await marta.say("What does a quote for ten seats cost?");
+ await expect.poll(marta.sharedWith, { timeout: 30_000 }).toBe("added");
+ expect(await marta.marker(), "she is told it is shared, never with whom").toBe("Only people added");
+ expect(await marta.faces()).toEqual([]);
+ await marta.shot("07-marta-chats-desktop");
+ const mine = (await botsOf("marta")).find((bot) => bot.id === quotes.id)!;
+ expect(mine.yourAccess).toBe("chat");
+ expect(mine.access, "the server sends her no list").toBeUndefined();
+ await marta.close();
+
+ await rui.openBot(quotes.id);
+ await rui.openShare();
+ await rui.click('[data-share-bot] button[aria-label="General access"]');
+ await rui.click('[role="menu"] [data-menu-key="everyone"]');
+ await expect.poll(async () => (await botsOf("rui")).find((bot) => bot.id === quotes.id)?.access?.everyone, { timeout: 30_000 }).toBe("chat");
+ await rui.closeShare();
+ await expect.poll(rui.sharedWith, { timeout: 30_000 }).toBe("everyone");
+ expect(await rui.marker()).toBe("Everyone in Acme");
+ expect(await rui.faces(), "one mark, no faces").toEqual([]);
+ await rui.shot("08-rui-shared-with-everyone-desktop");
+ expect(await notices("ben"), "sharing with everyone tells nobody").toEqual([]);
+ expect((await botsOf("ben")).find((bot) => bot.id === quotes.id)?.yourAccess).toBe("chat");
+ await rui.close();
+ }, hostTimeout(480_000));
+
+ it("a User's menu deletes a bot of his own, and says why it can't while the bot is shared", async () => {
+ const made = await team.as(tokens.rui, "POST", "/api/bots", { name: "Scratchpad" });
+ expect(made.status, JSON.stringify(made.body)).toBe(201);
+ const scratch = made.body.bot.id as string;
+ const rui = await openAs("rui", DESKTOP);
+ await rui.ready();
+ const menu = async (id: string) => {
+ await rui.until(`document.querySelector('[data-sidebar-bot-row="${id}"]')`);
+ await rui.evaluate(`(() => { const row = document.querySelector('[data-sidebar-bot-row="${id}"]'); const box = row.getBoundingClientRect();
+ row.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: box.left + 20, clientY: box.top + 10 })); return true; })()`);
+ await rui.until("document.querySelector('[data-bot-menu]')");
+ return rui.evaluate<Array<[string, boolean, string]>>(`[...document.querySelectorAll('[data-bot-menu] [role="menuitem"], [data-bot-menu] button')].map((item) => [item.textContent.trim(), item.disabled, item.title])`);
+ };
+ const closeMenu = async () => { await rui.browser("press", "Escape"); await rui.until("!document.querySelector('[data-bot-menu]')"); };
+
+ expect((await menu(quotes.id)).find(([label]) => label === "Delete"), "shared with everyone: shown, with why").toEqual(["Delete", true, "Only an admin can delete a shared bot. Stop sharing it first."]);
+ await rui.shot("17-rui-menu-shared-bot-delete-is-admins-desktop");
+ await closeMenu();
+ expect((await menu(scout)).some(([label]) => label === "Delete"), "no Delete on a bot he does not look after").toBe(false);
+ await closeMenu();
+
+ expect((await menu(scratch)).find(([label]) => label === "Delete")?.slice(0, 2)).toEqual(["Delete", false]);
+ await rui.shot("18-rui-menu-own-bot-delete-desktop");
+ await rui.evaluate(`[...document.querySelectorAll('[data-bot-menu] button')].find((item) => item.textContent.trim() === "Delete").click(); true`);
+ await rui.until(`document.querySelector('[role="alertdialog"]')`);
+ await rui.shot("19-rui-delete-confirm-desktop");
+ await rui.evaluate(`[...document.querySelectorAll('[role="alertdialog"] button')].find((button) => /delete/i.test(button.textContent)).click(); true`);
+ await expect.poll(async () => (await botsOf("ada")).some((bot) => bot.id === scratch), { timeout: 60_000, interval: 500 }).toBe(false);
+ await rui.until(`!document.querySelector('[data-sidebar-bot-row="${scratch}"]')`);
+ expect((await botsOf("rui")).some((bot) => bot.id === quotes.id), "the shared one is still there").toBe(true);
+ await rui.close();
+ }, hostTimeout(420_000));
+
+ it("at phone width the header keeps the bot's name: faces fold into a count, and each mark still opens Share", async () => {
+ const shared = await team.as(tokens.rui, "PUT", `/api/bots/${quotes.id}/access`, { everyone: "none", people: { [address("marta")]: "chat", [address("ben")]: "chat" } });
+ expect(shared.status, JSON.stringify(shared.body)).toBe(200);
+ const rui = await openAs("rui", PHONE);
+ await rui.ready();
+ await rui.openList();
+ await rui.click(`[data-sidebar-bot-row="${quotes.id}"]`);
+ await rui.until("document.querySelector('textarea[placeholder^=\"Message\"]') && document.querySelector('[data-header-share]')");
+ await expect.poll(rui.sharedWith, { timeout: 30_000 }).toBe("people");
+ expect(await rui.faces(), "one count for the two people").toEqual(["more:Marta, Ben"]);
+ expect(await rui.fits("[data-header-share]"), "who it is shared with and Share are on screen").toBe(true);
+ expect(await rui.evaluate<boolean>(`[...document.querySelectorAll('main *')].some((node) => { const box = node.getBoundingClientRect();
+ return node.children.length === 0 && node.textContent.trim() === ${JSON.stringify(quotes.name)} && node.scrollWidth <= node.clientWidth && box.width > 20 && box.right <= window.innerWidth; })`), "the bot's whole name is still shown").toBe(true);
+ expect(await rui.evaluate<number>("document.scrollingElement.scrollWidth - window.innerWidth"), "no sideways scroll").toBeLessThanOrEqual(1);
+ await rui.shot("09-rui-shared-with-two-phone");
+ await rui.evaluate(`[...document.querySelectorAll('[data-header-share] [data-access-more]')].find((chip) => chip.getClientRects().length).click(); true`);
+ await rui.until("document.querySelector('[data-share-bot]')");
+ await rui.shot("10-rui-share-dialog-phone");
+ await rui.closeShare();
+ await rui.close();
+
+ const marta = await openAs("marta", PHONE);
+ await marta.ready();
+ await marta.openList();
+ await marta.click(`[data-sidebar-bot-row="${quotes.id}"]`);
+ await marta.until("document.querySelector('[data-header-share] [data-shared-with-marker]')");
+ expect(await marta.marker()).toBe("Only people added");
+ expect(await marta.fits("[data-header-share]")).toBe(true);
+ expect(await marta.evaluate<number>("document.scrollingElement.scrollWidth - window.innerWidth")).toBeLessThanOrEqual(1);
+ await marta.shot("11-marta-shared-mark-phone");
+ await marta.close();
+ }, hostTimeout(420_000));
+
+ it("an admin's Templates form says who can use the new bot, preset to Just me; choosing Everyone in Acme shares it from the start", async () => {
+ const rui = await openAs("ada", DESKTOP);
+ await rui.ready();
+ const addFromTemplates = async (everyone: boolean) => {
+ const before = new Set((await botsOf("ada")).map((bot) => bot.id));
+ await rui.click('button[aria-label="New or share"]');
+ await rui.until(`[...document.querySelectorAll('[role="menu"] [role="menuitem"]')].some((item) => /templates/i.test(item.textContent))`);
+ await rui.evaluate(`[...document.querySelectorAll('[role="menu"] [role="menuitem"]')].find((item) => /templates/i.test(item.textContent)).click(); true`);
+ await rui.click("[data-ready-bot] button");
+ await rui.until("document.querySelector('[data-new-bot-shared]')");
+ expect(await rui.evaluate<string>("document.querySelector('[data-new-bot-shared]').dataset.newBotShared"), "preset to Just me").toBe("me");
+ expect(await rui.evaluate<string[]>("[...document.querySelectorAll('[data-new-bot-shared] option')].map((option) => option.textContent)")).toEqual(["Just me", "Everyone in Acme"]);
+ expect(await rui.evaluate<boolean>("Boolean(document.querySelector('[data-new-bot-visibility]'))"), "one choice, not two").toBe(false);
+ if (everyone) {
+ await rui.evaluate(`(() => { const select = document.querySelector('[data-new-bot-shared] select');
+ Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value").set.call(select, "everyone");
+ select.dispatchEvent(new Event("change", { bubbles: true })); return true; })()`);
+ await rui.until(`document.querySelector('[data-new-bot-shared]').dataset.newBotShared === "everyone"`);
+ }
+ await rui.shot(everyone ? "13-admin-form-everyone-desktop" : "12-admin-form-just-me-desktop");
+ await rui.evaluate(`[...document.querySelectorAll('[role="dialog"][aria-label] button')].find((button) => button.textContent.trim() === "Create bot").click(); true`);
+ await expect.poll(async () => (await botsOf("ada")).filter((bot) => !before.has(bot.id)).length, { timeout: 90_000, interval: 500 }).toBe(1);
+ await rui.until("!document.querySelector('[data-new-bot-shared]')");
+ return (await botsOf("ada")).find((bot) => !before.has(bot.id))!;
+ };
+ const mine = await addFromTemplates(false);
+ expect(mine.access).toEqual({ everyone: "none", people: {} });
+ expect((await botsOf("marta")).some((bot) => bot.id === mine.id)).toBe(false);
+ const open = await addFromTemplates(true);
+ expect(open.access).toEqual({ everyone: "chat", people: {} });
+ expect((await botsOf("marta")).find((bot) => bot.id === open.id)?.yourAccess).toBe("chat");
+ await rui.close();
+ }, hostTimeout(480_000));
+
+ it("/?connect=bots opens Settings → Bot access for an admin, and nothing for a User", async () => {
+ for (const [size, name] of [[DESKTOP, "14-admin-bot-access-link-desktop"], [PHONE, "15-admin-bot-access-link-phone"]] as const) {
+ const olive = await openAs("olive", size, "?connect=bots");
+ await olive.until("document.querySelector('[data-access-overview]')");
+ expect(await olive.evaluate<string>("location.search"), "the address is left clean").toBe("");
+ expect(await olive.evaluate<string[]>("[...document.querySelectorAll('[data-access-row]')].map((row) => row.dataset.accessRow)")).toEqual(expect.arrayContaining([quotes.id, scout]));
+ await olive.shot(name);
+ await olive.close();
+ }
+ const marta = await openAs("marta", DESKTOP, "?connect=bots");
+ await marta.ready();
+ await new Promise((resolve) => setTimeout(resolve, 3_000));
+ expect(await marta.evaluate<string>("location.search")).toBe("");
+ expect(await marta.evaluate<boolean>("Boolean(document.querySelector('[data-access-overview]'))"), "a User is shown no Bot access").toBe(false);
+ expect(await marta.words()).not.toContain("Bot access");
+ await marta.shot("16-user-bot-access-link-does-nothing-desktop");
+ await marta.close();
+ }, hostTimeout(420_000));
+});
diff --git a/scripts/testing/team-side-switch-ui.e2e.test.ts b/scripts/testing/team-side-switch-ui.e2e.test.ts
index 6fc82dabf1..458a5154f3 100644
--- a/scripts/testing/team-side-switch-ui.e2e.test.ts
+++ b/scripts/testing/team-side-switch-ui.e2e.test.ts
@@ -131,7 +131,7 @@ async function openAs(who: keyof typeof tokens, size: readonly [string, string])
const added = await team.as(tokens[who], "PATCH", `/api/bots/${own.id}`, { welcomed: true, sidebarHidden: false, pinned: true });
expect(added.status, JSON.stringify(added.body)).toBe(200);
}
- const created = await team.as(tokens.olive, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(tokens.olive, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
scout = created.body.bot.id; main = created.body.bot.mainThreadId;
}, hostTimeout(300_000));
diff --git a/scripts/verify-team-bot-access.ts b/scripts/verify-team-bot-access.ts
index ed27ddeacb..9de29f324e 100644
--- a/scripts/verify-team-bot-access.ts
+++ b/scripts/verify-team-bot-access.ts
@@ -115,7 +115,7 @@ try {
return answer.body;
};
const payroll = (await as("ada", "POST", "/api/bots", { name: "Payroll", title: "Answers pay questions", color: "teal" })).bot as { id: string; threadId: string };
- const helpdesk = (await as("ada", "POST", "/api/bots", { name: "Helpdesk", title: "IT questions", color: "blue" })).bot as { id: string };
+ const helpdesk = (await as("ada", "POST", "/api/bots", { name: "Helpdesk", title: "IT questions", color: "blue", visibility: "everyone" })).bot as { id: string };
if (before) await as("ada", "PATCH", `/api/bots/${payroll.id}`, { visibility: { people: [PEOPLE.bob.email, PEOPLE.cara.email, PEOPLE.dan.email] } });
else await as("ada", "PUT", `/api/bots/${payroll.id}/access`, { everyone: "none", people: { [PEOPLE.bob.email]: "view", [PEOPLE.cara.email]: "chat", [PEOPLE.dan.email]: "edit" } });
const sales = (await as("ada", "POST", "/api/bots", { name: "Sales notes", title: "Keeps the deal notes", color: "orange" })).bot as { id: string };
@@ -331,7 +331,7 @@ try {
const added = Object.fromEntries(CROWD.map((person) => [person.email, "chat" as const]));
for (const person of CROWD) await team.pair(person);
await as("ada", "PUT", `/api/bots/${payroll.id}/access`, { everyone: "none", people: { [PEOPLE.bob.email]: "view", [PEOPLE.cara.email]: "chat", [PEOPLE.dan.email]: "edit", [PEOPLE.eve.email]: "view", ...added } });
- for (let i = 1; i <= 46; i++) await as("ada", "POST", "/api/bots", { name: `Bot ${String(i).padStart(2, "0")} with quite a long name for the list`, title: "Filler", color: "teal" });
+ for (let i = 1; i <= 46; i++) await as("ada", "POST", "/api/bots", { name: `Bot ${String(i).padStart(2, "0")} with quite a long name for the list`, title: "Filler", color: "teal", visibility: "everyone" });
}
let serving: Who | null = null;
for (const shot of SHOTS.filter((entry) => !only || only.has(entry.name))) {
diff --git a/server/client-notifications.e2e.test.ts b/server/client-notifications.e2e.test.ts
index 9453ce193e..e92c6f4c16 100644
--- a/server/client-notifications.e2e.test.ts
+++ b/server/client-notifications.e2e.test.ts
@@ -17,7 +17,7 @@ it("lets a Team Cloud member list and read only their own notification feed", as
const team = fixture.team!;
const owner = await team.pair({ email: "[email protected]", role: "owner" });
const member = await team.pair({ email: "[email protected]", role: "member" });
- const created = await team.as(owner.token!, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(owner.token!, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status).toBe(201);
const bot = created.body.bot;
const opened = await team.as(owner.token!, "POST", `/api/bots/${bot.id}/tasks`, { title: "Ada's private chat" });
@@ -60,7 +60,7 @@ it("reads only the opener's notifications in shared conversations and keeps spen
const team = fixture.team!;
const owner = await team.pair({ email: "[email protected]", role: "owner" });
const member = await team.pair({ email: "[email protected]", role: "member" });
- const created = await team.as(owner.token!, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(owner.token!, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status).toBe(201);
const bot = created.body.bot;
const channel = await team.as(owner.token!, "POST", "/api/groups", { name: "Updates", memberIds: [bot.id],
diff --git a/server/cloud-team-asker-owns.e2e.test.ts b/server/cloud-team-asker-owns.e2e.test.ts
index 74ce106d2c..1b22ae65ba 100644
--- a/server/cloud-team-asker-owns.e2e.test.ts
+++ b/server/cloud-team-asker-owns.e2e.test.ts
@@ -77,7 +77,7 @@ beforeAll(async () => {
for (const [token, name] of [[ada, "Ada"], [priya, "Priya"], [tom, "Tom"], [sam, "Sam"]]) {
expect((await team.as(token, "PUT", "/api/me", { name })).status).toBe(200);
}
- const created = await team.as(ada, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(ada, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
botId = created.body.bot.id;
shared = created.body.bot.threadId;
diff --git a/server/cloud-team-away.e2e.test.ts b/server/cloud-team-away.e2e.test.ts
index 13b4a219da..9ae1bc1d7d 100644
--- a/server/cloud-team-away.e2e.test.ts
+++ b/server/cloud-team-away.e2e.test.ts
@@ -74,7 +74,7 @@ beforeAll(async () => {
cleo = (await team.pair(CLEO)).token!;
ben = (await team.pair(BEN)).token!;
await bots(ben);
- const created = await team.as(cleo, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(cleo, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
scout = created.body.bot as Bot;
}, hostTimeout(180_000));
diff --git a/server/cloud-team-browser.e2e.test.ts b/server/cloud-team-browser.e2e.test.ts
index 52afd8717c..d7411e9d8e 100644
--- a/server/cloud-team-browser.e2e.test.ts
+++ b/server/cloud-team-browser.e2e.test.ts
@@ -50,7 +50,7 @@ beforeAll(async () => {
admin = (await team.pair(ADMIN)).token!;
ada = (await team.pair(MEMBER_A)).token!;
cleo = (await team.pair(MEMBER_C)).token!;
- const created = await team.as(owner, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(owner, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
bot = created.body.bot;
const opened = async (token: string, title: string) => {
@@ -145,7 +145,7 @@ it("pairs a member's phone with a code she made: her address and role, her chats
expect(listed).toContain(adaThread);
expect(listed).not.toContain(cleoThread);
// A member makes nothing wider: the admins' pairing route stays theirs.
- expect((await team.as(phone, "POST", "/api/bots", { name: "Nope" })).status).toBe(403);
+ expect((await team.as(phone, "POST", "/api/bots", { name: "Nope", computer: "cloud" })).status).toBe(403);
expect((await team.as(ada, "POST", "/api/auth/pairing", {})).status).toBe(403);
// An admin's code, from either route, carries the admin too.
const bens = await team.as(admin, "POST", "/api/auth/pairing", { scopes: ["admin", "client"] });
diff --git a/server/cloud-team-connections.e2e.test.ts b/server/cloud-team-connections.e2e.test.ts
index 11d36c49d2..bcbef222dc 100644
--- a/server/cloud-team-connections.e2e.test.ts
+++ b/server/cloud-team-connections.e2e.test.ts
@@ -44,7 +44,7 @@ beforeAll(async () => {
admin = (await team.pair(ADMIN)).token!;
ada = (await team.pair(ADA)).token!;
cleo = (await team.pair(CLEO)).token!;
- const created = await team.as(owner, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(owner, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
bot = created.body.bot;
// The Team Cloud registered its own installation as it started: the team's Gmail is connected there.
@@ -223,7 +223,7 @@ it("never uses her own Gmail or mail where others read, even for her own line in
}, hostTimeout(180_000));
it("gives work her own message hands to another bot her own Gmail, and never work Cleo's message hands on", async () => {
- const created = await team.as(owner, "POST", "/api/bots", { name: "Helper" });
+ const created = await team.as(owner, "POST", "/api/bots", { name: "Helper", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
const helper = created.body.bot as { id: string; mainThreadId: string };
const handOn = (who: string) => ({ name: "coordinate_bots", server: "agents", input: { bot_ids: [helper.id], message: `Fetch ${who}'s latest email.` } });
@@ -283,7 +283,7 @@ it("runs work her group-chat line hands on in the receiving bot's chat with her,
const SECRET = "Q3 salary review 7731";
writeFileSync(join(team.home, "marker-replies.json"), JSON.stringify({ "Brief from @Scout:": `Ada's latest email: ${SECRET}.` }));
try {
- const created = await team.as(owner, "POST", "/api/bots", { name: "Clerk" });
+ const created = await team.as(owner, "POST", "/api/bots", { name: "Clerk", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
const clerk = created.body.bot as { id: string; mainThreadId: string };
const clerkWork = () => (JSON.parse(readFileSync(join(team.home, ".openmausbot", "bots.json"), "utf8")) as Array<{ id: string; tasks: Array<{ threadId: string }> }>)
diff --git a/server/cloud-team-conversation-share.e2e.test.ts b/server/cloud-team-conversation-share.e2e.test.ts
index e7146cdb05..a9f48b2c90 100644
--- a/server/cloud-team-conversation-share.e2e.test.ts
+++ b/server/cloud-team-conversation-share.e2e.test.ts
@@ -69,7 +69,7 @@ beforeAll(async () => {
fx = await launchCloudSendFixture({ onePasswordToken: `ops_fake-share-${randomBytes(8).toString("hex")}`, team: { id: "team-acme-share", name: "Acme", engine: ENGINE } });
team = fx.team!;
for (const [who, person] of [["olive", OLIVE], ["rui", RUI], ["marta", MARTA], ["ana", ANA], ["ben", BEN]] as const) tokens[who] = (await team.pair(person)).token!;
- const created = await as("olive", "POST", "/api/bots", { name: "Scout" });
+ const created = await as("olive", "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
scout = created.body.bot.id;
const locked = await as("olive", "POST", "/api/bots", { name: "Vault" });
diff --git a/server/cloud-team-engine-homes.e2e.test.ts b/server/cloud-team-engine-homes.e2e.test.ts
index aae6ded9e9..7edf0394c8 100644
--- a/server/cloud-team-engine-homes.e2e.test.ts
+++ b/server/cloud-team-engine-homes.e2e.test.ts
@@ -78,7 +78,7 @@ beforeAll(async () => {
owner = (await team.pair(OWNER)).token!;
admin = (await team.pair(ADMIN)).token!;
bob = (await team.pair(BOB)).token!;
- const created = await team.as(owner, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(owner, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
bot = created.body.bot;
}, hostTimeout(120_000));
diff --git a/server/cloud-team-gateway-mcp.e2e.test.ts b/server/cloud-team-gateway-mcp.e2e.test.ts
index dca687b116..cc47281d5f 100644
--- a/server/cloud-team-gateway-mcp.e2e.test.ts
+++ b/server/cloud-team-gateway-mcp.e2e.test.ts
@@ -44,7 +44,7 @@ beforeAll(async () => {
team = fx.team!;
admin = (await team.pair(ADMIN)).token!;
ada = (await team.pair(ADA)).token!;
- const created = await as(admin, "POST", "/api/bots", { name: "Scout" });
+ const created = await as(admin, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
bot = created.body.bot;
}, hostTimeout(120_000));
diff --git a/server/cloud-team-inbox.e2e.test.ts b/server/cloud-team-inbox.e2e.test.ts
index f21c6b43a5..b6195e3220 100644
--- a/server/cloud-team-inbox.e2e.test.ts
+++ b/server/cloud-team-inbox.e2e.test.ts
@@ -156,7 +156,7 @@ beforeAll(async () => {
ben = (await team.pair(BEN)).token!;
await bots(ben);
const create = async (body: Record<string, unknown>) => {
- const created = await team.as(cleo, "POST", "/api/bots", body);
+ const created = await team.as(cleo, "POST", "/api/bots", { visibility: "everyone", ...body });
expect(created.status, JSON.stringify(created.body)).toBe(201);
return created.body.bot as Bot;
};
diff --git a/server/cloud-team-included-hosting.e2e.test.ts b/server/cloud-team-included-hosting.e2e.test.ts
index ea08ff4696..e78c1deb9f 100644
--- a/server/cloud-team-included-hosting.e2e.test.ts
+++ b/server/cloud-team-included-hosting.e2e.test.ts
@@ -77,7 +77,7 @@ beforeAll(async () => {
admin = (await team.pair(ADMIN)).token!;
ada = (await team.pair(ADA)).token!;
ben = (await team.pair(BEN)).token!;
- mira = (await team.as(owner, "POST", "/api/bots", { name: "Mira" })).body.bot;
+ mira = (await team.as(owner, "POST", "/api/bots", { name: "Mira", visibility: "everyone" })).body.bot;
mainThread = mira.mainThreadId ?? mira.threadId;
adaThread = (await team.as(ada, "POST", `/api/bots/${mira.id}/tasks`, { title: "Ada's portfolio" })).body.task.threadId;
benThread = (await team.as(ben, "POST", `/api/bots/${mira.id}/tasks`, { title: "Ben's plan" })).body.task.threadId;
diff --git a/server/cloud-team-mausbot-reach.e2e.test.ts b/server/cloud-team-mausbot-reach.e2e.test.ts
index 32a026ef8f..c1378f3689 100644
--- a/server/cloud-team-mausbot-reach.e2e.test.ts
+++ b/server/cloud-team-mausbot-reach.e2e.test.ts
@@ -82,7 +82,7 @@ beforeAll(async () => {
ben = (await team.pair(BEN)).token!;
for (const [token, name] of [[ada, "Ada"], [mira, "Mira"], [ben, "Ben"]] as const) expect((await team.as(token, "PUT", "/api/me", { name })).status).toBe(200);
const create = async (name: string) => {
- const created = await team.as(ada, "POST", "/api/bots", { name, title: name });
+ const created = await team.as(ada, "POST", "/api/bots", { name, title: name, visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
return created.body.bot as Bot;
};
diff --git a/server/cloud-team-member-secrets.e2e.test.ts b/server/cloud-team-member-secrets.e2e.test.ts
index d0eced9ca3..fcd1f8c090 100644
--- a/server/cloud-team-member-secrets.e2e.test.ts
+++ b/server/cloud-team-member-secrets.e2e.test.ts
@@ -69,7 +69,7 @@ beforeAll(async () => {
admin = (await team.pair(ADMIN)).token!;
ada = (await team.pair(ADA)).token!;
ben = (await team.pair(BEN)).token!;
- ledger = (await as(owner, "POST", "/api/bots", { name: "Ledger" })).body.bot;
+ ledger = (await as(owner, "POST", "/api/bots", { name: "Ledger", visibility: "everyone" })).body.bot;
adaThread = (await as(ada, "POST", `/api/bots/${ledger.id}/tasks`, { title: "Billing" })).body.task.threadId;
benThread = (await as(ben, "POST", `/api/bots/${ledger.id}/tasks`, { title: "Billing" })).body.task.threadId;
const room = await as(owner, "POST", "/api/groups", { name: "Finance", memberIds: [ledger.id] });
diff --git a/server/cloud-team-new-chat-private.e2e.test.ts b/server/cloud-team-new-chat-private.e2e.test.ts
index 1fb51ce46b..233b94583f 100644
--- a/server/cloud-team-new-chat-private.e2e.test.ts
+++ b/server/cloud-team-new-chat-private.e2e.test.ts
@@ -43,7 +43,7 @@ beforeAll(async () => {
ada = (await team.pair(ADA)).token!;
mira = (await team.pair(MIRA)).token!;
ben = (await team.pair(BEN)).token!;
- const created = await team.as(ada, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(ada, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
scout = created.body.bot as Bot;
}, hostTimeout(120_000));
diff --git a/server/cloud-team-one-answer.e2e.test.ts b/server/cloud-team-one-answer.e2e.test.ts
index bb9e2b07d6..e0b2ead4f8 100644
--- a/server/cloud-team-one-answer.e2e.test.ts
+++ b/server/cloud-team-one-answer.e2e.test.ts
@@ -33,7 +33,7 @@ const boltGo = () => join(team.home, "bolt-go");
const turns = (): Turn[] => existsSync(`${planPath()}.evidence.jsonl`)
? readFileSync(`${planPath()}.evidence.jsonl`, "utf8").trim().split("\n").filter(Boolean).map((line) => JSON.parse(line) as Turn) : [];
const create = async (body: Record<string, unknown>) => {
- const created = await team.as(olive, "POST", "/api/bots", body);
+ const created = await team.as(olive, "POST", "/api/bots", { visibility: "everyone", ...body });
expect(created.status, JSON.stringify(created.body)).toBe(201);
return created.body.bot as Bot;
};
diff --git a/server/cloud-team-open-reach.e2e.test.ts b/server/cloud-team-open-reach.e2e.test.ts
index f8fab6bc2c..37f2a5efe7 100644
--- a/server/cloud-team-open-reach.e2e.test.ts
+++ b/server/cloud-team-open-reach.e2e.test.ts
@@ -37,7 +37,7 @@ const messages = async (token: string, threadId: string) => {
return { status: read.status, messages: (read.body.messages ?? []) as Message[] };
};
const create = async (body: Record<string, unknown>) => {
- const created = await team.as(olive, "POST", "/api/bots", body);
+ const created = await team.as(olive, "POST", "/api/bots", { visibility: "everyone", ...body });
expect(created.status, JSON.stringify(created.body)).toBe(201);
return created.body.bot as Bot;
};
diff --git a/server/cloud-team-own-key-apps.e2e.test.ts b/server/cloud-team-own-key-apps.e2e.test.ts
index b90db64577..965c1fe395 100644
--- a/server/cloud-team-own-key-apps.e2e.test.ts
+++ b/server/cloud-team-own-key-apps.e2e.test.ts
@@ -42,7 +42,7 @@ beforeAll(async () => {
owner = (await team.pair(OWNER)).token!;
ada = (await team.pair(ADA)).token!;
cleo = (await team.pair(CLEO)).token!;
- const created = await team.as(owner, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(owner, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
bot = created.body.bot;
expect((await team.as(owner, "PUT", "/api/team/connection-scopes", { kind: "app", id: "gmail", scope: "person" })).body).toEqual({ scopes: { apps: ["gmail"], mcp: [] } });
diff --git a/server/cloud-team-owners.e2e.test.ts b/server/cloud-team-owners.e2e.test.ts
index fdf84f647f..e695da8301 100644
--- a/server/cloud-team-owners.e2e.test.ts
+++ b/server/cloud-team-owners.e2e.test.ts
@@ -53,7 +53,7 @@ afterAll(async () => {
});
const create = async (token: string, body: Record<string, unknown>) => {
- const created = await team.as(token, "POST", "/api/bots", body);
+ const created = await team.as(token, "POST", "/api/bots", { visibility: "everyone", ...body });
expect(created.status, JSON.stringify(created.body)).toBe(201);
return created.body.bot as Bot;
};
diff --git a/server/cloud-team-people.e2e.test.ts b/server/cloud-team-people.e2e.test.ts
index 93fcabe54c..c40ad12d99 100644
--- a/server/cloud-team-people.e2e.test.ts
+++ b/server/cloud-team-people.e2e.test.ts
@@ -67,7 +67,7 @@ beforeAll(async () => {
ada = (await team.pair(ADA)).token!;
await team.pair(BOB);
await team.pair(CARL);
- const created = await team.as(olive, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(olive, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
scout = created.body.bot;
mainThread = scout.mainThreadId ?? scout.threadId;
diff --git a/server/cloud-team-per-person.e2e.test.ts b/server/cloud-team-per-person.e2e.test.ts
index 699c2ffca7..6e4331f9ba 100644
--- a/server/cloud-team-per-person.e2e.test.ts
+++ b/server/cloud-team-per-person.e2e.test.ts
@@ -72,7 +72,7 @@ beforeAll(async () => {
ada = (await team.pair(ADA)).token!;
cleo = (await team.pair(CLEO)).token!;
for (const name of ["Scout", "Pilot"]) {
- const created = await team.as(owner, "POST", "/api/bots", { name });
+ const created = await team.as(owner, "POST", "/api/bots", { name, visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
if (name === "Scout") scout = created.body.bot; else pilot = created.body.bot;
}
@@ -180,7 +180,7 @@ it("each person orders their own bots; an Owner's or Admin's order is the team's
for (const token of [owner, admin, cleo]) expect(await order(token), "an Admin's order is the default too").toEqual(teams);
expect(await order(ada), "Ada keeps the order she chose").toEqual(flipped);
// A bot made after she ordered hers takes its place in the team's order in her list too.
- const created = await team.as(owner, "POST", "/api/bots", { name: "Atlas" });
+ const created = await team.as(owner, "POST", "/api/bots", { name: "Atlas", visibility: "everyone" });
expect(created.status).toBe(201);
const atlas = created.body.bot.id as string;
const three = async (token: string) => (await bots(token)).map((bot) => bot.id).filter((id) => [scout.id, pilot.id, atlas].includes(id));
diff --git a/server/cloud-team-presence.e2e.test.ts b/server/cloud-team-presence.e2e.test.ts
index 29b7a2dc77..bd818b1acc 100644
--- a/server/cloud-team-presence.e2e.test.ts
+++ b/server/cloud-team-presence.e2e.test.ts
@@ -53,10 +53,10 @@ beforeAll(async () => {
owner = (await team.pair(OWNER)).token!;
admin = (await team.pair(ADMIN)).token!;
bob = (await team.pair(BOB)).token!;
- const made = await team.as(owner, "POST", "/api/bots", { name: "Scout" });
+ const made = await team.as(owner, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(made.status, JSON.stringify(made.body)).toBe(201);
scout = made.body.bot;
- const other = await team.as(owner, "POST", "/api/bots", { name: "Payroll" });
+ const other = await team.as(owner, "POST", "/api/bots", { name: "Payroll", visibility: "everyone" });
expect(other.status, JSON.stringify(other.body)).toBe(201);
payroll = other.body.bot;
expect((await team.as(owner, "PUT", `/api/bots/${payroll.id}/access`, { everyone: "none", people: {} })).status).toBe(200);
diff --git a/server/cloud-team-privacy-holes.e2e.test.ts b/server/cloud-team-privacy-holes.e2e.test.ts
index 903f356d67..de7126e1b8 100644
--- a/server/cloud-team-privacy-holes.e2e.test.ts
+++ b/server/cloud-team-privacy-holes.e2e.test.ts
@@ -84,7 +84,7 @@ beforeAll(async () => {
admin = (await team.pair(ADMIN)).token!;
rui = (await team.pair(RUI)).token!;
marta = (await team.pair(MARTA)).token!;
- quotes = (await team.as(owner, "POST", "/api/bots", { name: "Quotes" })).body.bot;
+ quotes = (await team.as(owner, "POST", "/api/bots", { name: "Quotes", visibility: "everyone" })).body.bot;
ruiMaus = (await botsOf(rui)).find((bot) => bot.defaultBot?.person === RUI.email)!;
expect(ruiMaus, "Rui has a MausBot of his own").toBeTruthy();
diff --git a/server/cloud-team-private-default.e2e.test.ts b/server/cloud-team-private-default.e2e.test.ts
new file mode 100644
index 0000000000..0868e73b72
--- /dev/null
+++ b/server/cloud-team-private-default.e2e.test.ts
@@ -0,0 +1,343 @@
+// A team bot is its maker's until they share it, on a real Team Cloud: Acme's Owner (Olive), an Admin (Ada) and two
+// Users (Rui, Marta), each paired with the Admin's signed claim. Every way a bot comes to exist there is tried: New bot,
+// a preset, a copy, a package, a backup and a bot a User moves in. Each starts as Only people added with nobody added,
+// another User gets 404 for it by id and never sees it in a list, a request that says who can use it still wins, and
+// sharing it with one person puts one line in that person's inbox. Off a team nothing changes.
+import { randomBytes } from "node:crypto";
+import { afterAll, beforeAll, describe, expect, it } from "vitest";
+import { launchCloudSendFixture, type CloudSendFixture, type CloudTeamFixture } from "../scripts/testing/cloud-send-fixture.ts";
+import { hostTimeout } from "./testing/host-timeout.ts";
+
+const OLIVE = { email: "[email protected]", role: "owner" as const };
+const ADA = { email: "[email protected]", role: "admin" as const };
+const RUI = { email: "[email protected]", role: "member" as const };
+const MARTA = { email: "[email protected]", role: "member" as const };
+const PRIVATE = { everyone: "none", people: {} };
+
+type Access = { everyone: string; people: Record<string, string> };
+type Bot = { id: string; name: string; threadId: string; mainThreadId?: string; yourAccess?: string; access?: Access; visibility?: unknown; createdBy?: string; onlyPeopleAdded?: true };
+type Row = { kind: string; text: string; from: { name: string; email?: string }; origin?: { botId: string; threadId: string } };
+
+let fx: CloudSendFixture, team: CloudTeamFixture;
+const token: Record<string, string> = {};
+
+const as = (who: string, method: string, path: string, body?: unknown) => team.as(token[who]!, method, path, body);
+const bots = async (who: string) => (await as(who, "GET", "/api/bots?messages=0")).body.bots as Bot[];
+const botOf = async (who: string, id: string) => (await bots(who)).find((bot) => bot.id === id);
+const inbox = async (who: string) => ((await as(who, "GET", "/api/inbox")).body.rows ?? []) as Row[];
+const made = async (who: string, body: Record<string, unknown>) => {
+ const created = await as(who, "POST", "/api/bots", body);
+ expect(created.status, JSON.stringify(created.body)).toBe(201);
+ return created.body.bot as Bot;
+};
+
+/** Nobody but whoever looks after it and the admins: not in a User's list, and 404 on every route that names it. */
+async function hiddenFrom(who: string, bot: Bot): Promise<void> {
+ expect((await bots(who)).some((listed) => listed.id === bot.id), `${who} lists ${bot.name}`).toBe(false);
+ const main = bot.mainThreadId ?? bot.threadId;
+ for (const [method, path, body] of [
+ ["GET", `/api/threads/${main}/messages?limit=5`, undefined],
+ ["GET", `/api/bots/${bot.id}/memory/mine`, undefined],
+ ["POST", `/api/bots/${bot.id}/tasks`, {}],
+ ["POST", `/api/bots/${bot.id}/messages`, { text: "hello" }],
+ ["PATCH", `/api/bots/${bot.id}`, { name: "Mine now" }],
+ ["PUT", `/api/bots/${bot.id}/access`, { everyone: "chat", people: {} }],
+ ["POST", `/api/bots/${bot.id}/access-request`, {}],
+ ] as const) {
+ const answer = await as(who, method, path, body);
+ expect(answer.status, `${who} ${method} ${path}: ${JSON.stringify(answer.body)}`).toBe(404);
+ }
+ const search = await as(who, "GET", `/api/search?q=${encodeURIComponent(bot.name)}`);
+ expect(JSON.stringify(search.body), `${who} finds ${bot.name} by searching`).not.toContain(bot.id);
+}
+
+/** As private as a team bot starts: its maker and the admins edit it, and no User reaches it. */
+async function startsPrivate(bot: Bot, owner: string, others: string[]): Promise<void> {
+ const mine = (await botOf(owner, bot.id))!;
+ expect(mine.access, `${bot.name} as ${owner} has it`).toEqual(PRIVATE);
+ expect(mine.yourAccess).toBe("edit");
+ expect(mine.onlyPeopleAdded).toBe(true);
+ for (const admin of ["olive", "ada"]) expect((await botOf(admin, bot.id))?.yourAccess, `${admin} reaches ${bot.name}`).toBe("edit");
+ for (const who of others) await hiddenFrom(who, bot);
+}
+
+beforeAll(async () => {
+ fx = await launchCloudSendFixture({ onePasswordToken: `ops_fake-private-default-${randomBytes(8).toString("hex")}`, team: { id: "team-acme-private", name: "Acme" } });
+ team = fx.team!;
+ for (const [who, member] of Object.entries({ olive: OLIVE, ada: ADA, rui: RUI, marta: MARTA })) {
+ const paired = await team.pair(member);
+ expect(paired.status, JSON.stringify(paired.body)).toBe(200);
+ token[who] = paired.token!;
+ }
+ for (const who of ["rui", "marta"]) await as(who, "GET", "/api/inbox");
+}, hostTimeout(240_000));
+
+afterAll(async () => { await fx?.close(); }, hostTimeout(60_000));
+
+describe("a team bot is its maker's until they share it", () => {
+ it("the team's first bot, which nobody made, stays everyone's", async () => {
+ const seed = (await bots("ada")).find((bot) => bot.name === "Seedling")!;
+ expect(seed.access).toEqual({ everyone: "chat", people: {} });
+ expect((await botOf("marta", seed.id))?.yourAccess).toBe("chat");
+ });
+
+ it("New bot: only its maker and the admins reach it", async () => {
+ const quotes = await made("ada", { name: "Quotes" });
+ expect(quotes.access).toEqual(PRIVATE);
+ expect(quotes.createdBy).toBe(ADA.email);
+ await startsPrivate(quotes, "ada", ["rui", "marta"]);
+ });
+
+ it("New bot looked after by someone else is that person's", async () => {
+ const desk = await made("ada", { name: "Rui's desk", reportsTo: RUI.email });
+ expect((await botOf("rui", desk.id))?.yourAccess).toBe("edit");
+ expect((await botOf("rui", desk.id))?.access).toEqual(PRIVATE);
+ await hiddenFrom("marta", desk);
+ });
+
+ it("a request that says who can use it still wins", async () => {
+ const open = await made("ada", { name: "Open", visibility: "everyone" });
+ expect(open.access).toEqual({ everyone: "chat", people: {} });
+ for (const who of ["rui", "marta"]) expect((await botOf(who, open.id))?.yourAccess, who).toBe("chat");
+
+ const listed = await made("ada", { name: "Listed", visibility: { people: [MARTA.email] } });
+ expect((await botOf("marta", listed.id))?.yourAccess).toBe("chat");
+ await hiddenFrom("rui", listed);
+
+ const closed = await made("ada", { name: "Closed", visibility: "admins" });
+ for (const who of ["rui", "marta"]) await hiddenFrom(who, closed);
+ });
+
+ it("a copy of a shared bot is its maker's, as the app's Duplicate asks for it", async () => {
+ const copy = await made("olive", { name: "Open copy" });
+ await startsPrivate(copy, "olive", ["rui", "marta"]);
+ });
+
+ it("a preset's bot starts private too", async () => {
+ const defaults = await as("ada", "PATCH", "/api/config", { newBotDefaults: { profile: { name: "Sky", soul: "Be kind.\n" }, memory: {}, skills: [], routines: [] } });
+ expect(defaults.status, JSON.stringify(defaults.body)).toBe(200);
+ const saved = await as("ada", "POST", "/api/teams/export", { format: "package", version: 2, kind: "library", presetName: "Support agent" });
+ expect(saved.status, JSON.stringify(saved.body)).toBe(200);
+ const library = await as("ada", "POST", "/api/teams/import", saved.body.document);
+ expect(library.status, JSON.stringify(library.body)).toBe(201);
+ const preset = library.body.presets[0].id as string;
+ const agent = await made("ada", { name: "Agent", preset, useDefaults: false });
+ await startsPrivate(agent, "ada", ["rui", "marta"]);
+ });
+
+ it("a package and a backup: the bots are the importer's, unless the admin says who sees them", async () => {
+ const manifest = { format: "openmaus.team", version: 2, team: { name: "Desk", members: [{ key: "helper", name: "Desk helper", appearance: { color: "blue" } }] } };
+ const imported = await as("ada", "POST", "/api/teams/import?mode=add", manifest);
+ expect(imported.status, JSON.stringify(imported.body)).toBe(201);
+ const helper = imported.body.bots[0] as Bot;
+ expect(helper.createdBy).toBe(ADA.email);
+ await startsPrivate(helper, "ada", ["rui", "marta"]);
+
+ const shared = await as("ada", "POST", "/api/teams/import?mode=add&visibility=everyone", { ...manifest, team: { ...manifest.team, name: "Open desk" } });
+ expect(shared.status, JSON.stringify(shared.body)).toBe(201);
+ for (const who of ["rui", "marta"]) expect((await botOf(who, shared.body.bots[0].id))?.yourAccess, who).toBe("chat");
+
+ const backup = await as("olive", "POST", "/api/teams/export", { format: "backup", name: "Acme copy" });
+ expect(backup.status, JSON.stringify(backup.body)).toBe(200);
+ const before = new Set((await bots("olive")).map((bot) => bot.id));
+ const restored = await as("olive", "POST", "/api/teams/import?mode=add", backup.body);
+ expect(restored.status, JSON.stringify(restored.body)).toBe(201);
+ const fresh = (restored.body.bots as Bot[]).filter((bot) => !before.has(bot.id));
+ expect(fresh.length).toBeGreaterThan(0);
+ const seenByMarta = new Set((await bots("marta")).map((bot) => bot.id));
+ for (const bot of fresh) {
+ expect((await botOf("olive", bot.id))?.access, bot.name).toEqual(PRIVATE);
+ expect(seenByMarta.has(bot.id), `Marta sees ${bot.name}`).toBe(false);
+ }
+ await hiddenFrom("marta", fresh[0]!);
+ });
+
+ it("a bot a User moves in from My Cloud is theirs: no other User reaches it", async () => {
+ const id = `moved-${randomBytes(6).toString("hex")}`;
+ const begun = await as("rui", "POST", "/api/team-move-in", { v: 1, bot: { id, name: "Atlas" }, label: "Rui" });
+ expect(begun.status, JSON.stringify(begun.body)).toBe(200);
+ const moving = await team.as(begun.body.token, "POST", "/api/bots", { id, name: "Atlas", useDefaults: false });
+ expect(moving.status, JSON.stringify(moving.body)).toBe(201);
+ const done = await team.as(begun.body.token, "POST", `/api/team-move-in/${id}/done`, { v: 1, on: [] });
+ expect(done.status, JSON.stringify(done.body)).toBe(200);
+ const atlas = (await botOf("rui", id))!;
+ expect(atlas.createdBy).toBe(RUI.email);
+ await startsPrivate(atlas, "rui", ["marta"]);
+ });
+
+ it("sharing it with one person tells that person once; sharing with everyone tells nobody", async () => {
+ const ledger = await made("ada", { name: "Ledger" });
+ await hiddenFrom("marta", ledger);
+ const notices = async (who: string) => (await inbox(who)).filter((row) => row.kind === "notice" && row.text.includes("Ledger"));
+
+ expect((await as("ada", "PUT", `/api/bots/${ledger.id}/access`, { everyone: "none", people: { [MARTA.email]: "chat" } })).status).toBe(200);
+ const told = await notices("marta");
+ expect(told.map((row) => row.text)).toEqual(["Ada shared Ledger with you."]);
+ expect(told[0]!.origin).toMatchObject({ botId: ledger.id, threadId: ledger.mainThreadId ?? ledger.threadId });
+ expect(await notices("rui")).toEqual([]);
+ expect((await botOf("marta", ledger.id))?.yourAccess).toBe("chat");
+ expect((await botOf("marta", ledger.id))?.access, "someone who can only chat is never sent who else was added").toBeUndefined();
+ await hiddenFrom("rui", ledger);
+ const sent = await as("marta", "POST", `/api/bots/${ledger.id}/messages`, { text: "What's the total?" });
+ expect(sent.status, JSON.stringify(sent.body)).toBe(202);
+
+ expect((await as("ada", "PUT", `/api/bots/${ledger.id}/access`, { everyone: "chat", people: { [MARTA.email]: "chat" } })).status).toBe(200);
+ expect((await botOf("rui", ledger.id))?.yourAccess).toBe("chat");
+ expect(await notices("rui"), "sharing with everyone sends nothing").toEqual([]);
+ expect((await notices("marta")).length, "and nothing more to someone already added").toBe(1);
+
+ expect((await as("ada", "PUT", `/api/bots/${ledger.id}/access`, { everyone: "chat", people: { [MARTA.email]: "chat", [RUI.email]: "edit" } })).status).toBe(200);
+ expect(await notices("rui"), "adding someone who could already use it sends nothing").toEqual([]);
+ });
+
+ it("a User makes a bot of their own: private to them, with nothing an admin alone sets, and the admin's saved defaults stay out of it", async () => {
+ const defaults = await as("ada", "PATCH", "/api/config", { newBotDefaults: { profile: { soul: "The admin's instructions.\n", approvalMode: "auto", alwaysAllow: ["Bash(*)"], section: "Sales" }, memory: {}, skills: [], routines: [] } });
+ expect(defaults.status, JSON.stringify(defaults.body)).toBe(200);
+ const adas = await made("ada", {});
+ expect(adas, "an admin's New bot takes the saved defaults").toMatchObject({ soul: "The admin's instructions.\n", section: "Sales", approvalMode: "auto" });
+
+ const own = await made("rui", { name: "Rui's own", description: "Drafts quotes." });
+ expect(own).toMatchObject({ createdBy: RUI.email, access: PRIVATE, yourAccess: "edit" });
+ await startsPrivate(own, "rui", ["marta"]);
+ // What an admin alone sets is as the server gives any bot nobody set up: a bot an admin makes without the saved defaults.
+ const bare = (await made("ada", { useDefaults: false })) as Bot & Record<string, unknown>;
+ const seen = (await botOf("ada", own.id)) as Bot & Record<string, unknown>;
+ const adminSet = (bot: Record<string, unknown>) => ["approvalMode", "autoApprove", "alwaysAllow", "cwd", "computer", "browser", "section", "reportsTo", "chiefOfStaff", "managedSections", "toolScope", "composio", "mcpServers"].map((field) => [field, bot[field]]);
+ expect(adminSet(seen)).toEqual(adminSet(bare));
+ expect([seen.soul || "", seen.section, seen.autoApprove ?? false, seen.alwaysAllow ?? [], seen.reportsTo]).toEqual(["", undefined, false, [], undefined]);
+ const unnamed = await made("rui", {});
+ expect(unnamed.name).toBeTruthy();
+ expect((await botOf("ada", unnamed.id) as Bot & { soul?: string }).soul || "").toBe("");
+
+ const before = (await bots("ada")).length;
+ for (const [field, value] of Object.entries({
+ approvalMode: "full", autoApprove: true, alwaysAllow: ["Bash(*)"], cwd: "/tmp", computer: "cloud", browser: true, section: "Sales", reportsTo: MARTA.email,
+ chiefOfStaff: true, managedSections: ["Sales"], toolScope: { allow: ["native:*"] }, visibility: "everyone", preset: "anything", id: "rui-picked-this-id",
+ })) {
+ for (const body of [{ name: "Nope", [field]: value }, { name: "Nope", settings: { [field]: value } }]) {
+ const refused = await as("rui", "POST", "/api/bots", body);
+ expect(refused.status, `${field}: ${JSON.stringify(refused.body)}`).toBe(403);
+ expect(refused.body.error).toBe(`forbidden: "${field}" is an admin's to set`);
+ }
+ }
+ expect((await bots("ada")).length, "none of those made a bot").toBe(before);
+ });
+
+ it("a User changes their own bot as someone who can edit it, and never what an admin alone sets", async () => {
+ const own = await made("rui", { name: "Editable" });
+ const changed = await as("rui", "PATCH", `/api/bots/${own.id}`, { name: "Quotes desk", title: "Quotes", soul: "Quote list prices only.\n", composio: false });
+ expect(changed.status, JSON.stringify(changed.body)).toBe(200);
+ expect(changed.body.bot).toMatchObject({ name: "Quotes desk", soul: "Quote list prices only.\n" });
+ for (const [field, value] of Object.entries({
+ approvalMode: "full", autoApprove: true, alwaysAllow: ["Bash(*)"], cwd: "/tmp", computer: "cloud", browser: true, section: "Sales", reportsTo: MARTA.email,
+ chiefOfStaff: true, managedSections: ["Sales"], toolScope: { allow: ["native:*"] }, visibility: "everyone",
+ })) {
+ const refused = await as("rui", "PATCH", `/api/bots/${own.id}`, { [field]: value });
+ expect(refused.status, `${field}: ${JSON.stringify(refused.body)}`).toBe(403);
+ expect(refused.body.error).toBe(`forbidden: "${field}" is an admin's to change`);
+ }
+ for (const [method, path, body] of [
+ ["POST", "/api/webhooks", { botId: own.id, name: "Hook" }],
+ ["PUT", `/api/bots/${own.id}/memory/file`, { path: "MEMORY.md", text: "x" }],
+ ["GET", "/api/bot-defaults", undefined],
+ ["POST", "/api/teams/import?mode=add", { format: "openmaus.team", version: 2, team: { name: "Mine", members: [{ key: "a", name: "A" }] } }],
+ ] as const) {
+ expect((await as("rui", method, path, body)).status, `${method} ${path}`).toBe(403);
+ }
+ // An admin manages it as any team bot, and still reads none of its owner's private chats with it.
+ const raised = await as("ada", "PATCH", `/api/bots/${own.id}`, { section: "Sales" });
+ expect(raised.status, JSON.stringify(raised.body)).toBe(200);
+ const chat = await as("rui", "POST", `/api/bots/${own.id}/tasks`, {});
+ expect(chat.status, JSON.stringify(chat.body)).toBe(201);
+ for (const admin of ["ada", "olive"]) expect((await as(admin, "GET", `/api/threads/${chat.body.task.threadId}/messages?limit=5`)).status, admin).toBe(404);
+ });
+
+ it("a User shares their own bot and deletes it only while nobody else can use it", async () => {
+ const own = await made("rui", { name: "Short-lived" });
+ expect((await as("marta", "DELETE", `/api/bots/${own.id}`)).status, "to anyone else it does not exist").toBe(404);
+ const shared = await as("rui", "PUT", `/api/bots/${own.id}/access`, { everyone: "none", people: { [MARTA.email]: "edit" } });
+ expect(shared.status, JSON.stringify(shared.body)).toBe(200);
+ expect((await inbox("marta")).some((row) => row.text === "Rui shared Short-lived with you.")).toBe(true);
+ expect((await botOf("marta", own.id))?.yourAccess).toBe("edit");
+ const whileShared = await as("rui", "DELETE", `/api/bots/${own.id}`);
+ expect([whileShared.status, whileShared.body.error]).toEqual([403, "Only an admin can delete a bot that is shared. Stop sharing it first, or ask an admin."]);
+ expect((await as("marta", "DELETE", `/api/bots/${own.id}`)).status, "someone it is shared with, even to edit").toBe(403);
+ expect((await botOf("rui", own.id))?.name).toBe("Short-lived");
+
+ const adas = await made("ada", { name: "Ada's, shared with Rui" });
+ expect((await as("ada", "PUT", `/api/bots/${adas.id}/access`, { everyone: "none", people: { [RUI.email]: "edit" } })).status).toBe(200);
+ expect((await as("rui", "DELETE", `/api/bots/${adas.id}`)).status, "a bot he can edit but does not look after").toBe(403);
+ const mausbot = (await bots("rui")).find((bot) => (bot as Bot & { defaultBot?: { person?: string } }).defaultBot?.person === RUI.email);
+ if (mausbot) expect((await as("rui", "DELETE", `/api/bots/${mausbot.id}`)).status, "his own MausBot stays").toBe(409);
+
+ expect((await as("rui", "PUT", `/api/bots/${own.id}/access`, PRIVATE)).status).toBe(200);
+ const gone = await as("rui", "DELETE", `/api/bots/${own.id}`);
+ expect(gone.status, JSON.stringify(gone.body)).toBe(200);
+ for (const who of ["rui", "ada", "olive"]) expect((await bots(who)).some((bot) => bot.id === own.id), who).toBe(false);
+ expect((await as("ada", "DELETE", `/api/bots/${adas.id}`)).status, "an admin deletes any team bot, shared or not").toBe(200);
+ });
+
+ it("sharing a conversation of a private bot never widens who reaches the bot", async () => {
+ const own = await made("rui", { name: "Rui's notebook" });
+ const opened = await as("rui", "POST", `/api/bots/${own.id}/tasks`, { title: "Pricing ideas" });
+ expect(opened.status, JSON.stringify(opened.body)).toBe(201);
+ const threadId = opened.body.task.threadId as string;
+ const share = `/api/bots/${own.id}/tasks/${threadId}/share`;
+ const offered = await as("rui", "GET", share);
+ expect(offered.status, JSON.stringify(offered.body)).toBe(200);
+ expect((offered.body.people as Array<{ email: string }>).map((person) => person.email).sort(), "only people who can use the bot: its admins").toEqual([ADA.email, OLIVE.email]);
+ const refused = await as("rui", "POST", share, { with: { email: MARTA.email } });
+ expect(refused.status, JSON.stringify(refused.body)).toBe(409);
+ const unseen = async () => {
+ await hiddenFrom("marta", own);
+ expect((await as("marta", "GET", `/api/threads/${threadId}/messages?limit=5`)).status).toBe(404);
+ };
+ await unseen();
+
+ expect((await as("rui", "POST", share, { with: { email: ADA.email } })).status).toBe(200);
+ expect((await as("ada", "GET", `/api/threads/${threadId}/messages?limit=5`)).status, "the admin it was shared with reads it").toBe(200);
+ expect((await as("olive", "GET", `/api/threads/${threadId}/messages?limit=5`)).status, "another admin does not").toBe(404);
+ await unseen();
+ expect((await botOf("rui", own.id))?.access, "the bot is still shared with nobody").toEqual(PRIVATE);
+
+ expect((await as("rui", "POST", share, { with: "team" })).status).toBe(200);
+ expect((await as("olive", "GET", `/api/threads/${threadId}/messages?limit=5`)).status, "the team's, for a private bot, is whoever looks after it and the admins").toBe(200);
+ await unseen();
+ });
+
+ it("what was shared before stays shared across a restart, and what was private stays private", async () => {
+ const before = Object.fromEntries((await bots("olive")).map((bot) => [bot.id, bot.access]));
+ const martas = (await bots("marta")).map((bot) => bot.id).sort();
+ await team.relaunch();
+ for (const [who, member] of Object.entries({ olive: OLIVE, marta: MARTA })) token[who] = (await team.pair(member)).token!;
+ expect(Object.fromEntries((await bots("olive")).map((bot) => [bot.id, bot.access]))).toEqual(before);
+ expect((await bots("marta")).map((bot) => bot.id).sort()).toEqual(martas);
+ }, hostTimeout(120_000));
+});
+
+describe("the team's bot limit", () => {
+ it("counts a User's bots with everyone's: at the limit theirs is refused in the same words as an admin's", async () => {
+ for (let count = (await bots("olive")).length; count < 100; count++) {
+ const filler = await as("ada", "POST", "/api/bots", { name: `Filler ${count}`, useDefaults: false });
+ if (filler.status !== 201) break;
+ }
+ const all = (await bots("olive")).length;
+ const adminToo = await as("ada", "POST", "/api/bots", { name: "One more", useDefaults: false });
+ expect(adminToo.status, `${all} bots: ${JSON.stringify(adminToo.body)}`).toBe(409);
+ const refused = await as("rui", "POST", "/api/bots", { name: "One more" });
+ expect([refused.status, refused.body.error]).toEqual([409, adminToo.body.error]);
+ expect(refused.body.error).toMatch(/limited to 100 bots/);
+ }, hostTimeout(240_000));
+});
+
+describe("anywhere but a team", () => {
+ it("a new bot on this computer and on My Cloud is as it always was: no sharing, everyone who signs in", async () => {
+ for (const place of [fx.local, fx.onCloud]) {
+ const created = await place("POST", "/api/bots", { name: "Plain" });
+ expect(created.status, JSON.stringify(created.body)).toBe(201);
+ expect(created.body.bot.access).toBeUndefined();
+ expect(created.body.bot.visibility).toBeUndefined();
+ expect(created.body.bot.createdBy).toBeUndefined();
+ }
+ });
+});
diff --git a/server/cloud-team-private.e2e.test.ts b/server/cloud-team-private.e2e.test.ts
index cf45d660d6..0a0aa8ece6 100644
--- a/server/cloud-team-private.e2e.test.ts
+++ b/server/cloud-team-private.e2e.test.ts
@@ -72,7 +72,7 @@ beforeAll(async () => {
owner = (await team.pair(OWNER)).token!;
admin = (await team.pair(ADMIN)).token!;
bob = (await team.pair(BOB)).token!;
- const created = await team.as(owner, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(owner, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
bot = created.body.bot;
// Bob's private chat: his words, his note, his picture and his About you.
diff --git a/server/cloud-team-published-apps.e2e.test.ts b/server/cloud-team-published-apps.e2e.test.ts
index 995eec4c08..fedfd89ea0 100644
--- a/server/cloud-team-published-apps.e2e.test.ts
+++ b/server/cloud-team-published-apps.e2e.test.ts
@@ -78,7 +78,7 @@ beforeAll(async () => {
admin = (await team.pair(ADMIN)).token!;
ada = (await team.pair(ADA)).token!;
ben = (await team.pair(BEN)).token!;
- mira = (await team.as(owner, "POST", "/api/bots", { name: "Mira" })).body.bot;
+ mira = (await team.as(owner, "POST", "/api/bots", { name: "Mira", visibility: "everyone" })).body.bot;
adaMaus = (await botsOf(ada)).find((bot) => bot.defaultBot?.person === ADA.email)!;
expect(adaMaus, "Ada has a MausBot of her own").toBeTruthy();
mainThread = mira.mainThreadId ?? mira.threadId;
diff --git a/server/cloud-team-routines.e2e.test.ts b/server/cloud-team-routines.e2e.test.ts
index cefb5ec57e..589a38f213 100644
--- a/server/cloud-team-routines.e2e.test.ts
+++ b/server/cloud-team-routines.e2e.test.ts
@@ -82,7 +82,7 @@ beforeAll(async () => {
admin = (await team.pair(ADMIN)).token!;
bob = (await team.pair(BOB)).token!;
ben = (await team.pair(BEN)).token!;
- scout = (await team.as(owner, "POST", "/api/bots", { name: "Scout" })).body.bot;
+ scout = (await team.as(owner, "POST", "/api/bots", { name: "Scout", visibility: "everyone" })).body.bot;
bobThread = (await team.as(bob, "POST", `/api/bots/${scout.id}/tasks`, { title: "Bob's plans" })).body.task.threadId;
benThread = (await team.as(ben, "POST", `/api/bots/${scout.id}/tasks`, { title: "Ben's notes" })).body.task.threadId;
const upload = await fetch(`${team.base}/api/attachments`, { method: "POST", headers: { ...fx.edge, authorization: `Bearer ${bob}`, "content-type": "image/png" }, body: PNG });
@@ -103,7 +103,7 @@ beforeAll(async () => {
expect(shared.status, JSON.stringify(shared.body)).toBe(201);
standup = shared.body.routine.id;
// Ledger: only Bob and Ben added, and Bob looks after it.
- ledger = (await team.as(owner, "POST", "/api/bots", { name: "Ledger" })).body.bot;
+ ledger = (await team.as(owner, "POST", "/api/bots", { name: "Ledger", visibility: "everyone" })).body.bot;
expect((await team.as(owner, "PUT", `/api/bots/${ledger.id}/access`, { everyone: "none", people: { [BOB.email]: "chat", [BEN.email]: "chat" } })).status).toBe(200);
expect((await team.as(owner, "PUT", `/api/bots/${ledger.id}/reports-to`, { email: BOB.email })).status).toBe(200);
const tallied = await team.as(bob, "POST", "/api/routines", { name: "Ledger tally", prompt: "Add up the week", botId: ledger.id, schedule: LATER, resultsThreadId: null });
diff --git a/server/cloud-team-rules.e2e.test.ts b/server/cloud-team-rules.e2e.test.ts
index e8496d79f2..30d2bb60be 100644
--- a/server/cloud-team-rules.e2e.test.ts
+++ b/server/cloud-team-rules.e2e.test.ts
@@ -107,10 +107,10 @@ beforeAll(async () => {
team = fx.team!;
owner = (await team.pair(OWNER)).token!;
ada = (await team.pair(ADA)).token!;
- const created = await team.as(owner, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(owner, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
botId = created.body.bot.id;
- peerId = (await team.as(owner, "POST", "/api/bots", { name: "Helper" })).body.bot.id;
+ peerId = (await team.as(owner, "POST", "/api/bots", { name: "Helper", visibility: "everyone" })).body.bot.id;
expect((await team.as(owner, "POST", "/api/mcp/servers", { name: "orders", type: "http", url: gateway.url })).status).toBe(201);
expect((await team.as(owner, "PATCH", "/api/mcp/servers/orders", { enabled: true })).status).toBe(200);
}, hostTimeout(120_000));
@@ -144,6 +144,12 @@ it("a blocked engine is refused for a chat turn and a routine, for an Admin and
expect(sent.body.error).toMatch(/^Acme does not allow the Claude engine\. .*ask a team admin\.$/);
expect(engineRan()).toBe(false);
}
+ // A bot a User made is the team's too: the rule applies to it as to any other.
+ const own = await team.as(ada, "POST", "/api/bots", { name: "Ada's own", modelSelection: { instanceId: "claude", model: "claude-sonnet-5" } });
+ expect(own.status, JSON.stringify(own.body)).toBe(201);
+ const ownTurn = await team.as(ada, "POST", `/api/bots/${own.body.bot.id}/messages`, { text: "blocked on my own bot" });
+ expect([ownTurn.status, ownTurn.body.error], JSON.stringify(ownTurn.body)).toEqual([409, expect.stringMatching(/^Acme does not allow the Claude engine\./)]);
+ expect(engineRan()).toBe(false);
const routine = await routineRun("Blocked engine");
expect(routine.words).toMatch(/Acme does not allow the Claude engine/);
expect(engineRan()).toBe(false);
diff --git a/server/cloud-team-setup-request.e2e.test.ts b/server/cloud-team-setup-request.e2e.test.ts
index 3423bccac9..77d52c54d9 100644
--- a/server/cloud-team-setup-request.e2e.test.ts
+++ b/server/cloud-team-setup-request.e2e.test.ts
@@ -49,7 +49,7 @@ async function turn(token: string, botId: string, threadId: string, text: string
}
it("in the team's shared main chat, only the person who pressed Set me up sets the bot up, and only they can stop it", async () => {
- const created = await team.as(owner, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(owner, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
const bot = created.body.bot as { id: string; mainThreadId: string; messages: any[] };
const main = bot.mainThreadId;
@@ -83,7 +83,7 @@ it("in the team's shared main chat, only the person who pressed Set me up sets t
}, hostTimeout(180_000));
it("refuses another person's press while a member's request waits, and the owner can clear it", async () => {
- const bot = (await team.as(owner, "POST", "/api/bots", { name: "Scribe" })).body.bot as { id: string; mainThreadId: string };
+ const bot = (await team.as(owner, "POST", "/api/bots", { name: "Scribe", visibility: "everyone" })).body.bot as { id: string; mainThreadId: string };
const main = bot.mainThreadId;
expect((await team.as(ada, "POST", `/api/bots/${bot.id}/setup-request`, { threadId: main })).status).toBe(200);
expect(await team.as(owner, "POST", `/api/bots/${bot.id}/setup-request`, { threadId: main })).toEqual({
@@ -95,7 +95,7 @@ it("refuses another person's press while a member's request waits, and the owner
// Last: Ada's sessions end with her leaving.
it("drops a member's request when she leaves the team", async () => {
- const bot = (await team.as(owner, "POST", "/api/bots", { name: "Herald" })).body.bot as { id: string; mainThreadId: string };
+ const bot = (await team.as(owner, "POST", "/api/bots", { name: "Herald", visibility: "everyone" })).body.bot as { id: string; mainThreadId: string };
const main = bot.mainThreadId;
expect((await team.as(ada, "POST", `/api/bots/${bot.id}/setup-request`, { threadId: main })).status).toBe(200);
expect(await waiting(owner, bot.id, main)).toMatchObject({ by: expect.any(String) });
diff --git a/server/cloud-team.e2e.test.ts b/server/cloud-team.e2e.test.ts
index 2fd7fb8f3d..2bdcb2246a 100644
--- a/server/cloud-team.e2e.test.ts
+++ b/server/cloud-team.e2e.test.ts
@@ -33,7 +33,7 @@ beforeAll(async () => {
admin = (await team.pair(ADMIN)).token!;
ada = (await team.pair(MEMBER_A)).token!;
cleo = (await team.pair(MEMBER_C)).token!;
- const created = await team.as(owner, "POST", "/api/bots", { name: "Scout" });
+ const created = await team.as(owner, "POST", "/api/bots", { name: "Scout", visibility: "everyone" });
expect(created.status, JSON.stringify(created.body)).toBe(201);
bot = created.body.bot;
}, hostTimeout(120_000));
@@ -105,8 +105,9 @@ it("keeps every member's session across a restart, waits to sleep only while it
expect(sleep.body.busy).not.toContain("team");
expect((await team.signed("GET", "/api/cloud/power")).status).toBe(200);
expect((await team.signed("GET", "/api/cloud/health")).status).toBe(200);
- // A member reaches nothing an admin does: the team's setup is the admins'.
- expect((await team.as(ada, "POST", "/api/bots", { name: "Nope" })).status).toBe(403);
+ // A member reaches nothing an admin does: the team's setup is the admins', and so is what a bot may do.
+ expect((await team.as(ada, "POST", "/api/webhooks", { name: "Nope" })).status).toBe(403);
+ expect((await team.as(ada, "POST", "/api/bots", { name: "Nope", approvalMode: "full" })).status).toBe(403);
}, hostTimeout(90_000));
let adaThread = "", roomId = "", roomThread = "";
diff --git a/server/host/member-bots.ts b/server/host/member-bots.ts
new file mode 100644
index 0000000000..887fc8636d
--- /dev/null
+++ b/server/host/member-bots.ts
@@ -0,0 +1,22 @@
+// A Team Cloud member's own bots: they delete one only while it is theirs alone. Once a bot is shared with anyone, or
+// for any bot they do not look after, deleting stays with the admins, as it always was.
+import { botOwner } from "../../shared/bot-owner.ts";
+import { accessOf, type AccessBot } from "../bot-visibility.ts";
+import type { RequestAuth } from "../request-auth.ts";
+
+export const SHARED_BOT_DELETE_REFUSAL = "Only an admin can delete a bot that is shared. Stop sharing it first, or ask an admin.";
+
+/** Whether anyone but whoever looks after the bot is given it by its sharing. */
+export function sharedBeyondOwner(bot: AccessBot): boolean {
+ const access = accessOf(bot), owner = botOwner(bot);
+ return access.everyone !== "none" || Object.keys(access.people).some((entry) => entry !== owner);
+}
+
+/** Why a session without the admin scope may not delete this bot; null for an admin, and for a team member's own bot
+ * that nobody else can use. */
+export function memberDeleteRefusal(auth: RequestAuth, bot: (AccessBot & { name: string }) | null | undefined, team: boolean): string | null {
+ if (auth.kind !== "session" || auth.scopes.includes("admin")) return null;
+ const email = team && auth.session.membershipAuthority === "team" ? auth.session.email?.trim().toLowerCase() : undefined;
+ if (!email || !bot || botOwner(bot) !== email) return "forbidden: this session lacks the admin scope";
+ return sharedBeyondOwner(bot) ? SHARED_BOT_DELETE_REFUSAL : null;
+}
diff --git a/server/host/share-notice.test.ts b/server/host/share-notice.test.ts
new file mode 100644
index 0000000000..76415df914
--- /dev/null
+++ b/server/host/share-notice.test.ts
@@ -0,0 +1,47 @@
+import { describe, expect, it } from "vitest";
+
+import type { BotAccess } from "../../shared/bot-access.ts";
+import { personKey } from "../person-key.ts";
+import type { RequestAuth } from "../request-auth.ts";
+import type { BotRecord } from "../store.ts";
+import type { Delivery } from "./person-inbox.ts";
+import { createShareNotice, newlyShared } from "./share-notice.ts";
+
+const ADA = "[email protected]", RUI = "[email protected]", MARTA = "[email protected]", OLIVE = "[email protected]";
+const PEOPLE = [{ email: OLIVE, role: "owner" as const }, { email: ADA, role: "admin" as const }, { email: RUI, role: "member" as const }, { email: MARTA, role: "member" as const }];
+const only = (people: BotAccess["people"] = {}): BotAccess => ({ everyone: "none", people });
+const all = (people: BotAccess["people"] = {}): BotAccess => ({ everyone: "chat", people });
+
+describe("who is told a bot was shared with them", () => {
+ it("the Users named one by one who could not use it before", () => {
+ expect(newlyShared(only(), only({ [MARTA]: "chat" }), PEOPLE)).toEqual([MARTA]);
+ expect(newlyShared(only({ [MARTA]: "chat" }), only({ [MARTA]: "chat", [RUI]: "view" }), PEOPLE)).toEqual([RUI]);
+ expect(newlyShared(only({ [MARTA]: "view" }), only({ [MARTA]: "edit" }), PEOPLE), "a level raised is no news").toEqual([]);
+ });
+
+ it("nobody when it is shared with everyone, already was, or the person is an admin or not on the team", () => {
+ expect(newlyShared(only(), all(), PEOPLE)).toEqual([]);
+ expect(newlyShared(all(), all({ [MARTA]: "edit" }), PEOPLE)).toEqual([]);
+ expect(newlyShared(only(), only({ [ADA]: "chat", [OLIVE]: "edit" }), PEOPLE)).toEqual([]);
+ expect(newlyShared(only(), only({ "[email protected]": "chat", "@acme.test": "chat" }), PEOPLE)).toEqual([]);
+ expect(newlyShared(only({ "@acme.test": "chat" }), only({ "@acme.test": "chat", [MARTA]: "chat" }), PEOPLE), "an older list's domain already covered them").toEqual([]);
+ });
+
+ it("puts one line in each new person's inbox, from the sharer, linked to the bot's main chat", () => {
+ const delivered: Array<[string, Delivery]> = [];
+ const notice = createShareNotice({
+ people: () => PEOPLE, profileName: (email) => (email === ADA ? "Ada" : undefined),
+ store: () => ({ tasks: () => [{ threadId: "run", routineRunId: "r1", createdAt: 1 }, { threadId: "later", createdAt: 9 }, { threadId: "main", createdAt: 2 }] }) as never,
+ inbox: () => ({ deliver: (person, delivery) => { delivered.push([person, delivery]); return null; } }),
+ });
+ const bot = { id: "quotes", name: "Quotes" } as BotRecord;
+ notice({ kind: "session", session: { email: "[email protected]" } } as unknown as RequestAuth, bot, only(), only({ [MARTA]: "chat", [RUI]: "chat" }));
+ expect(delivered.map(([person]) => person).sort()).toEqual([personKey({ id: "", email: MARTA }), personKey({ id: "", email: RUI })].sort());
+ expect(delivered[0]![1]).toEqual({ kind: "notice", from: { name: "Ada", email: ADA }, origin: { botId: "quotes", threadId: "main" },
+ text: "Ada shared Quotes with you.", title: "Quotes is shared with you", notify: "done" });
+
+ delivered.length = 0;
+ notice({ kind: "loopback" } as unknown as RequestAuth, bot, only(), only({ [MARTA]: "chat" }));
+ expect(delivered[0]![1]).toMatchObject({ from: { name: "An admin" }, text: "An admin shared Quotes with you." });
+ });
+});
diff --git a/server/host/share-notice.ts b/server/host/share-notice.ts
new file mode 100644
index 0000000000..87777f148c
--- /dev/null
+++ b/server/host/share-notice.ts
@@ -0,0 +1,40 @@
+// Sharing a team bot with a person tells that person, once, in their inbox: "Ada shared Quotes with you." Sharing with
+// everyone tells nobody, and neither does adding someone who could already use the bot.
+import { sharedLevel, type BotAccess } from "../../shared/bot-access.ts";
+import { nameFromEmail } from "../../shared/bot-owner.ts";
+import type { TeamRole } from "../cloud-team.ts";
+import { personKey } from "../person-key.ts";
+import type { RequestAuth } from "../request-auth.ts";
+import type { BotRecord, Store } from "../store.ts";
+import type { Delivery } from "./person-inbox.ts";
+
+export interface ShareNoticeDeps {
+ /** The team's current members. */
+ people(): ReadonlyArray<{ email: string; role: TeamRole }>;
+ /** The name a member chose, when they chose one. */
+ profileName(email: string): string | undefined;
+ store(): Pick<Store, "tasks">;
+ inbox(): { deliver(person: string, delivery: Delivery): unknown };
+}
+
+/** The members `after` lets use the bot who could not before: named one by one, never through "everyone", and never an
+ * admin, who reaches every bot already. */
+export function newlyShared(before: BotAccess, after: BotAccess, people: ReadonlyArray<{ email: string; role: TeamRole }>): string[] {
+ return people.filter((person) => person.role === "member" && Object.hasOwn(after.people, person.email)
+ && sharedLevel(before, person.email) === "none").map((person) => person.email);
+}
+
+export function createShareNotice(deps: ShareNoticeDeps) {
+ return (auth: RequestAuth, bot: BotRecord, before: BotAccess, after: BotAccess): void => {
+ const by = auth.kind === "session" ? auth.session.email?.trim().toLowerCase() : undefined;
+ const name = by ? deps.profileName(by)?.trim() || nameFromEmail(by) : "An admin";
+ const main = deps.store().tasks(bot.id).filter((task) => !task.routineRunId).sort((a, b) => a.createdAt - b.createdAt)[0];
+ for (const email of newlyShared(before, after, deps.people())) {
+ if (email === by) continue;
+ deps.inbox().deliver(personKey({ id: "", email }), {
+ kind: "notice", from: { name, ...(by ? { email: by } : {}) }, ...(main ? { origin: { botId: bot.id, threadId: main.threadId } } : {}),
+ text: `${name} shared ${bot.name} with you.`, title: `${bot.name} is shared with you`, notify: "done",
+ });
+ }
+ };
+}
diff --git a/server/index.ts b/server/index.ts
index af018f59bd..f8906fd387 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -583,7 +583,7 @@ import { createNoAiNotice } from "./host/no-ai-notice.ts"; import { PASS, ROUTES
import { createHostedSlackRoutes } from "./routes/hosted-slack.ts";
import { createBotPresetRoutes } from "./routes/bot-presets.ts"; import { createWorkspaceBannerRoutes, workspaceBannerStore, workspaceBannerSummary } from "./routes/workspace-banner.ts";
import { createBotMemoryRoutes } from "./routes/bot-memory.ts";
-import { createBotCreateRoutes } from "./routes/bots-create.ts";
+import { createBotCreateRoutes } from "./routes/bots-create.ts"; import { privateUntilShared } from "./new-bot-sharing.ts"; import { createShareNotice } from "./host/share-notice.ts"; import { memberDeleteRefusal } from "./host/member-bots.ts";
import { createTeamOwnerRoutes } from "./routes/team-owners.ts";
import { createBotSettingsRoutes } from "./routes/bot-settings.ts";
import { createBotPatchRoutes } from "./routes/bot-patch.ts";
@@ -2861,7 +2861,7 @@ for (const pending of startupCatalogs) {
broadcast({ kind: "config", ...configStatus() });
}, () => {});
}
-const firstHourFresh = Boolean(CLOUD_PERSONAL) && store.needsSeed(); testedAi.seed({ defaultBot: !CLOUD_TEAM, ...(firstHourFresh ? { intro: (bot) => greetingMessage(bot, { name: cfg.profile?.name }, cfg.language) } : {}) }); moveFreeze.hold(() => { if (!CLOUD_TEAM) ensureDefaultBot(store, { dataDir: DATA_DIR }); }, () => {}); if (CLOUD_TEAM) readTeamRolesWith((email) => sessions.list().filter((session) => session.email?.toLowerCase() === email && session.teamRole).sort((a, b) => b.createdAt - a.createdAt)[0]?.teamRole ?? null); if (CLOUD_TEAM) void mausbotOwnChat.claimAll();
+const firstHourFresh = Boolean(CLOUD_PERSONAL) && store.needsSeed(); if (CLOUD_TEAM) store.newBotSharing = privateUntilShared; testedAi.seed({ defaultBot: !CLOUD_TEAM, ...(firstHourFresh ? { intro: (bot) => greetingMessage(bot, { name: cfg.profile?.name }, cfg.language) } : {}) }); moveFreeze.hold(() => { if (!CLOUD_TEAM) ensureDefaultBot(store, { dataDir: DATA_DIR }); }, () => {}); if (CLOUD_TEAM) readTeamRolesWith((email) => sessions.list().filter((session) => session.email?.toLowerCase() === email && session.teamRole).sort((a, b) => b.createdAt - a.createdAt)[0]?.teamRole ?? null); if (CLOUD_TEAM) void mausbotOwnChat.claimAll();
hostedModels?.reconcile(store);
if (skillsLibraryEnabled(cfg)) {
try {
@@ -12149,7 +12149,7 @@ ROUTES.push(createBotSettingsRoutes({
requestedTaskBot, threadBusy, activeGroupTurnForBot, checkedModelSelection, engineSwitchNeedsAsk, readCursor,
canManageCommandAllowlist, commandAllowlistResponse, cardAnswerRefusal, threadRead: teamMessages.seen, levelOf, personMarkThread: personRooms.personMarkThread,
}));
-ROUTES.push(createBotOrderRoutes({ store, visibleFor: (auth) => visibleTo(viewerFor(auth)), ...(botOrders ? { own: { person: botOrders.personOf, order: botOrders, told: (person, botIds) => broadcast({ kind: "bots.order", botIds }, { person }) } } : {}) }), createBotAccessRoutes({ team: CLOUD_TEAM, people: teamOwners.people, store, levelOf, wireBot, publicGroupState, broadcast, audienceChanged, record: (auth, row) => appendAdminAction(DATA_DIR, { ...row, actor: decisionActorFor(auth) }) }), accessRequests.routes);
+ROUTES.push(createBotOrderRoutes({ store, visibleFor: (auth) => visibleTo(viewerFor(auth)), ...(botOrders ? { own: { person: botOrders.personOf, order: botOrders, told: (person, botIds) => broadcast({ kind: "bots.order", botIds }, { person }) } } : {}) }), createBotAccessRoutes({ team: CLOUD_TEAM, people: teamOwners.people, store, levelOf, wireBot, publicGroupState, broadcast, audienceChanged, record: (auth, row) => appendAdminAction(DATA_DIR, { ...row, actor: decisionActorFor(auth) }), shared: createShareNotice({ people: () => teamOwners.people?.list() ?? [], profileName: (email) => teamHost.people.profile(personKey({ id: "", email })).name, store: () => store, inbox: () => teamMessages.inbox }) }), accessRequests.routes);
ROUTES.push(createBotPatchRoutes({
store, cfg, registry, sessions, browserRuntime, browserLive, memoryUpkeep, cacheKeepWarm, hostedModels, supportsApprovalMode,
routines: () => routines, activeVpsThreads,
@@ -12160,7 +12160,7 @@ ROUTES.push(createBotPatchRoutes({
}));
ROUTES.push(createBotLifecycleRoutes({
store, routines: () => routines, interruptAllDirectThreads, cancelDirectTurnDispatch, revokeInternalCapabilitiesForThread,
- activeGroupTurnForBot, cancelGroupTurnOperations, runningTurnInstance, closeOpenApprovals, deleteBotWithLifecycle,
+ activeGroupTurnForBot, cancelGroupTurnOperations, runningTurnInstance, closeOpenApprovals, deleteBotWithLifecycle, deleteRefusal: (auth, botId) => memberDeleteRefusal(auth, store.bot(botId), Boolean(CLOUD_TEAM)),
}));
ROUTES.push(createBotSkillsRoutes({ store, cfg, listBotSkills, readBotSkillFile, stagedSkillListing }));
ROUTES.push(createEmailRoutes({ service: emailService }));
diff --git a/server/new-bot-sharing.test.ts b/server/new-bot-sharing.test.ts
new file mode 100644
index 0000000000..c5c866cd60
--- /dev/null
+++ b/server/new-bot-sharing.test.ts
@@ -0,0 +1,158 @@
+import { rmSync } from "node:fs";
+import { beforeEach, describe, expect, it } from "vitest";
+
+import type { TeamSetupRequest } from "../shared/team-setup.ts";
+import { accessOf, memberLevel } from "./bot-visibility.ts";
+import { DATA_DIR } from "./config.ts";
+import type { ModelSelection } from "./contracts.ts";
+import { createDefaultBot } from "./default-bot.ts";
+import { memberDeleteRefusal, SHARED_BOT_DELETE_REFUSAL } from "./host/member-bots.ts";
+import { privateUntilShared, sharedAsMaker, sharedUnlessRestricted, teamCreator } from "./new-bot-sharing.ts";
+import { memberBotCreateViolation, memberBotPatchViolation, requiredScope, type RequestAuth } from "./request-auth.ts";
+import { Store, type BotRecord } from "./store.ts";
+
+const selection = (): ModelSelection => ({ instanceId: "claude", model: "claude-sonnet-5" });
+const ADA = "[email protected]", RUI = "[email protected]", MARTA = "[email protected]";
+const PRIVATE = { everyone: "none", people: {} };
+
+const teamStore = () => Object.assign(new Store(selection), { newBotSharing: privateUntilShared });
+const setup = (chief: BotRecord, botId: string): TeamSetupRequest => ({ version: 1, requestId: `setup-${botId}`, botId: chief.id, threadId: chief.threadId,
+ reason: "Requested", createdAt: 1, requesterRevision: "fixture", newTeams: [], operations: [
+ { action: "create", botId, threadId: `${botId}-thread`, fields: { name: botId, section: chief.section, modelSelection: selection() } },
+ ] });
+
+describe("how a new bot is shared", () => {
+ beforeEach(() => { rmSync(DATA_DIR, { recursive: true, force: true }); });
+
+ it("the two rules: everyone unless restricted anywhere, the owner's until shared on a team", () => {
+ expect(sharedUnlessRestricted(undefined, ADA)).toEqual({});
+ expect(sharedUnlessRestricted("everyone", ADA)).toEqual({});
+ expect(sharedUnlessRestricted("admins", null)).toEqual({ visibility: "admins" });
+ expect(privateUntilShared(undefined, ADA)).toEqual({ access: PRIVATE, visibility: { people: [ADA] } });
+ expect(privateUntilShared(undefined, null)).toEqual({ access: PRIVATE, visibility: "admins" });
+ expect(privateUntilShared("everyone", ADA), "as a shared bot always was: no sharing of its own, read as everyone").toEqual({});
+ expect(privateUntilShared({ people: [MARTA] }, ADA)).toEqual({ visibility: { people: [MARTA] } });
+ expect(privateUntilShared("admins", ADA)).toEqual({ visibility: "admins" });
+ });
+
+ it("only a Team Cloud member's request records who made a bot", () => {
+ const session = (membershipAuthority?: "team") => ({ kind: "session", scopes: ["admin"], session: { email: ADA, membershipAuthority } }) as unknown as RequestAuth;
+ expect(teamCreator(session("team"))).toEqual({ createdBy: ADA });
+ expect(teamCreator(session())).toEqual({});
+ expect(teamCreator({ kind: "loopback" } as unknown as RequestAuth)).toEqual({});
+ });
+
+ it("off a team a new bot carries no sharing and everyone sees it", () => {
+ const bot = new Store(selection).createBot({ name: "Plain" });
+ expect(bot.access).toBeUndefined();
+ expect(bot.visibility).toBeUndefined();
+ expect(memberLevel(bot, MARTA)).toBe("chat");
+ });
+
+ it("on a team a new bot is Only people added with nobody added, from the record that is first saved", () => {
+ const store = teamStore();
+ const seen: Array<BotRecord["access"]> = [];
+ const bot = store.createBot({ name: "Quotes", createdBy: ADA }, { beforeShown: (made) => seen.push(made.access) });
+ expect(seen).toEqual([PRIVATE]);
+ expect(new Store(selection).bot(bot.id)).toMatchObject({ access: PRIVATE, visibility: { people: [ADA] } });
+ expect(memberLevel(bot, MARTA)).toBe("none");
+ expect(memberLevel(bot, RUI)).toBe("none");
+
+ const handed = store.createBot({ name: "Rui's", createdBy: ADA, reportsTo: RUI });
+ expect(handed.visibility).toEqual({ people: [RUI] });
+ expect(memberLevel(handed, MARTA)).toBe("none");
+
+ const nobodys = store.createBot({ name: "Imported by the machine" });
+ expect(nobodys).toMatchObject({ access: PRIVATE, visibility: "admins" });
+ });
+
+ it("on a team what the request chose wins, and a member's own MausBot stays theirs alone", () => {
+ const store = teamStore();
+ expect(accessOf(store.createBot({ name: "Open", createdBy: ADA, visibility: "everyone" }))).toEqual({ everyone: "chat", people: {} });
+ expect(memberLevel(store.createBot({ name: "Listed", createdBy: ADA, visibility: { people: [MARTA] } }), MARTA)).toBe("chat");
+ const own = createDefaultBot(store, { person: MARTA, team: "Acme" });
+ expect(own.visibility).toEqual({ people: [MARTA] });
+ expect(own.access).toBeUndefined();
+ });
+
+ it("a team's first bot, which nobody made, is everyone's", () => {
+ const store = teamStore();
+ store.seedIfEmpty({ defaultBot: false });
+ expect(accessOf(store.bots[0]!)).toEqual({ everyone: "chat", people: {} });
+ expect(memberLevel(store.bots[0]!, MARTA)).toBe("chat");
+ });
+
+ it("a bot a Chief makes is shared exactly as the Chief is, so the two can reach each other", () => {
+ const store = teamStore();
+ const mine = store.createBot({ name: "Ada's Chief", section: "Sales", createdBy: ADA });
+ store.patchBot(mine.id, { chiefOfStaff: true });
+ store.applyTeamSetup(setup(store.bot(mine.id)!, "private-helper"));
+ expect(store.bot("private-helper")).toMatchObject({ access: PRIVATE, visibility: { people: [ADA] }, createdBy: ADA });
+ expect(memberLevel(store.bot("private-helper")!, MARTA)).toBe("none");
+
+ const shared = store.createBot({ name: "Team Chief", section: "Ops", createdBy: RUI, visibility: "everyone" });
+ store.patchBot(shared.id, { chiefOfStaff: true, access: { everyone: "none", people: { [MARTA]: "chat" } }, visibility: { people: [RUI, MARTA] } });
+ store.applyTeamSetup(setup(store.bot(shared.id)!, "shared-helper"));
+ expect(store.bot("shared-helper")).toMatchObject({ access: { everyone: "none", people: { [MARTA]: "chat" } }, visibility: { people: [RUI, MARTA] } });
+ expect(sharedAsMaker({})).toEqual({});
+ });
+
+ it("bots saved before this keep reading from their visibility: nothing shared becomes private", () => {
+ const before = new Store(selection);
+ const open = before.createBot({ name: "Old open" });
+ const listed = before.createBot({ name: "Old listed", visibility: { people: [MARTA] } });
+ const admins = before.createBot({ name: "Old admins", visibility: "admins" });
+ const now = Object.assign(new Store(selection), { newBotSharing: privateUntilShared });
+ expect(now.bot(open.id)?.access).toBeUndefined();
+ expect(accessOf(now.bot(open.id)!)).toEqual({ everyone: "chat", people: {} });
+ expect(memberLevel(now.bot(open.id)!, RUI)).toBe("chat");
+ expect(memberLevel(now.bot(listed.id)!, MARTA)).toBe("chat");
+ expect(memberLevel(now.bot(listed.id)!, RUI)).toBe("none");
+ expect(memberLevel(now.bot(admins.id)!, MARTA)).toBe("none");
+ });
+});
+
+describe("a Team Cloud member's own bot", () => {
+ const ADMIN_ONLY = ["approvalMode", "autoApprove", "alwaysAllow", "cwd", "computer", "cloudBackend", "vpsAlias", "browser", "browserProfile", "section",
+ "reportsTo", "createdBy", "chiefOfStaff", "managedSections", "toolScope", "helperModel", "visibility", "access", "preset", "id", "threadId", "defaultBot"];
+
+ it("takes at creation only what someone who can edit a bot may change", () => {
+ expect(memberBotCreateViolation({})).toBeNull();
+ expect(memberBotCreateViolation({ name: "Quotes", title: "Prices", description: "Quotes prices", color: "blue", modelSelection: { instanceId: "claude", model: "m" },
+ useDefaults: true, settings: { soul: "Be brief.", composio: true, mcpServers: ["orders"], connectorTools: {} } })).toBeNull();
+ for (const field of ADMIN_ONLY) {
+ expect(memberBotCreateViolation({ name: "Quotes", [field]: "x" }), field).toBe(field);
+ if (field !== "threadId") expect(memberBotPatchViolation({ [field]: "x" }, "edit", false, true), `${field} on edit`).toBe(field);
+ expect(memberBotCreateViolation({ name: "Quotes", settings: { [field]: "x" } }), `settings.${field}`).toBe(field);
+ }
+ expect(memberBotCreateViolation({ settings: "full access" })).toBe("settings");
+ });
+
+ it("is made and deleted through routes a member reaches, each of which decides for itself", () => {
+ expect(requiredScope("POST", "/api/bots")).toBe("client");
+ expect(requiredScope("DELETE", "/api/bots/b1")).toBe("client");
+ for (const [method, path] of [["GET", "/api/bot-defaults"], ["GET", "/api/bot-presets"], ["POST", "/api/teams/import"], ["POST", "/api/webhooks"], ["PUT", "/api/bots/b1/memory/file"]] as const) {
+ expect(requiredScope(method, path), path).toBe("admin");
+ }
+ });
+
+ it("is theirs to delete only while nobody else can use it", () => {
+ const session = (email: string, scopes: string[], membershipAuthority?: "team") => ({ kind: "session", scopes, session: { email, membershipAuthority } }) as unknown as RequestAuth;
+ const rui = session(RUI, ["client"], "team");
+ const own = { name: "Quotes", createdBy: RUI, access: { everyone: "none" as const, people: {} }, visibility: { people: [RUI] } };
+ expect(memberDeleteRefusal(rui, own, true)).toBeNull();
+ expect(memberDeleteRefusal(rui, { ...own, access: { everyone: "none", people: { [RUI]: "edit" } } }, true), "their own entry is nobody else").toBeNull();
+ expect(memberDeleteRefusal(rui, { ...own, access: { everyone: "none", people: { [MARTA]: "view" } } }, true)).toBe(SHARED_BOT_DELETE_REFUSAL);
+ expect(memberDeleteRefusal(rui, { ...own, access: { everyone: "chat", people: {} } }, true)).toBe(SHARED_BOT_DELETE_REFUSAL);
+ expect(memberDeleteRefusal(rui, { name: "Old", createdBy: RUI }, true), "set up before levels, everyone").toBe(SHARED_BOT_DELETE_REFUSAL);
+ const refused = "forbidden: this session lacks the admin scope";
+ expect(memberDeleteRefusal(rui, { ...own, createdBy: ADA, access: { everyone: "none", people: { [RUI]: "edit" } } }, true), "someone else's, even one they can edit").toBe(refused);
+ expect(memberDeleteRefusal(rui, { ...own, reportsTo: ADA }, true), "handed on").toBe(refused);
+ expect(memberDeleteRefusal(rui, null, true)).toBe(refused);
+ expect(memberDeleteRefusal(rui, own, false), "off a team").toBe(refused);
+ expect(memberDeleteRefusal(session(RUI, ["client"]), own, true), "a session the team did not pair").toBe(refused);
+ expect(memberDeleteRefusal(session(ADA, ["admin", "client"], "team"), { ...own, access: { everyone: "chat", people: {} } }, true)).toBeNull();
+ expect(memberDeleteRefusal({ kind: "loopback" } as unknown as RequestAuth, own, false)).toBeNull();
+ });
+});
+
diff --git a/server/new-bot-sharing.ts b/server/new-bot-sharing.ts
new file mode 100644
index 0000000000..5ea71ae133
--- /dev/null
+++ b/server/new-bot-sharing.ts
@@ -0,0 +1,41 @@
+// Who a bot is shared with as it is made. Security invariant: this is on the record before anyone is told the bot
+// exists, so a bot that starts restricted is never shown to someone who may not see it.
+import { visibilityFromAccess, type BotAccess } from "../shared/bot-access.ts";
+import { ownerEmail } from "../shared/bot-owner.ts";
+import type { BotVisibility } from "../shared/wire.ts";
+import type { RequestAuth } from "./request-auth.ts";
+
+export type NewBotSharing = { access?: BotAccess; visibility?: BotVisibility };
+
+/** `asked` is what the request making the bot chose, if it chose; `owner` is who will look after the bot. */
+export type NewBotSharingRule = (asked: BotVisibility | undefined, owner: string | null) => NewBotSharing;
+
+const restricted = (asked: BotVisibility | undefined): NewBotSharing => (asked && asked !== "everyone" ? { visibility: structuredClone(asked) } : {});
+
+/** Anywhere but a Team Cloud: everyone who can sign in, unless the request restricted it. */
+export const sharedUnlessRestricted: NewBotSharingRule = (asked) => restricted(asked);
+
+/** A Team Cloud: a bot is its owner's until they share it, as a document is. A request that says who sees it wins, and
+ * is kept as it always was. */
+export const privateUntilShared: NewBotSharingRule = (asked, owner) => {
+ if (asked) return restricted(asked);
+ const access: BotAccess = { everyone: "none", people: {} };
+ return { access, visibility: visibilityFromAccess(access, owner) };
+};
+
+/** A bot another bot makes is shared exactly as its maker is: bots reach each other only with the same audience. */
+export function sharedAsMaker(maker: NewBotSharing): NewBotSharing {
+ return { ...restricted(maker.visibility), ...(maker.access === undefined ? {} : { access: structuredClone(maker.access) }) };
+}
+
+/** Who looks after a bot a profile is about to become. */
+export const newBotOwner = (profile: { createdBy?: string; reportsTo?: string }): string | null => {
+ const email = profile.reportsTo?.trim() || profile.createdBy?.trim();
+ return email ? ownerEmail(email) : null;
+};
+
+/** The Team Cloud member behind a request, recorded as the one who made what it makes; nothing anywhere else. */
+export function teamCreator(auth: RequestAuth): { createdBy?: string } {
+ const email = auth.kind === "session" && auth.session.membershipAuthority === "team" ? auth.session.email : undefined;
+ return email ? { createdBy: email } : {};
+}
diff --git a/server/outside-lineage.e2e.test.ts b/server/outside-lineage.e2e.test.ts
index 28c4e4123f..f5a8ce4d35 100644
--- a/server/outside-lineage.e2e.test.ts
+++ b/server/outside-lineage.e2e.test.ts
@@ -49,7 +49,7 @@ afterAll(async () => {
});
const newBot = async (name: string, level = "full") => {
- const bot = (await team.as(ada, "POST", "/api/bots", { name })).body.bot as { id: string; threadId: string };
+ const bot = (await team.as(ada, "POST", "/api/bots", { name, visibility: "everyone" })).body.bot as { id: string; threadId: string };
expect((await team.as(ada, "PATCH", `/api/bots/${bot.id}`, { approvalMode: level, applyToAllThreads: true })).status).toBe(200);
return bot;
};
diff --git a/server/package-import.ts b/server/package-import.ts
index 2599d3607e..99680a2886 100644
--- a/server/package-import.ts
+++ b/server/package-import.ts
@@ -66,6 +66,8 @@ export interface PackageImportDeps {
/** The most bots this workspace holds, every plan alike. */
maxBots?: number;
presets?: PresetRegistry;
+ /** A Team Cloud: the member adding the package, who looks after its bots. */
+ createdBy?: string;
}
export interface OrgImportContext {
@@ -298,6 +300,7 @@ function runImport(source: ImportSource, options: PackageImportOptions, deps: Pa
modelSelection: selection,
section,
...(options.visibility ? { visibility: options.visibility } : {}),
+ ...(deps.createdBy ? { createdBy: deps.createdBy } : {}),
},
{ seedMessages: false },
);
diff --git a/server/request-auth.test.ts b/server/request-auth.test.ts
index 114c601e1b..bb58faa585 100644
--- a/server/request-auth.test.ts
+++ b/server/request-auth.test.ts
@@ -355,7 +355,7 @@ describe("resolveRequestAuth", () => {
const csrf = resolve({ host: "bots.example.com", cookie: `${cookieName}=${token}`, origin: "https://evil.example" }, "/api/bots", "POST");
expect(csrf.error).toBe("forbidden: cross-origin request");
expect(sessions.list()[0]?.expiresAt).toBe(session.expiresAt);
- const overScope = resolve({ authorization: `Bearer ${token}` }, "/api/bots", "POST");
+ const overScope = resolve({ authorization: `Bearer ${token}` }, "/api/webhooks", "POST");
expect(overScope.status).toBe(403);
expect(sessions.list()[0]?.expiresAt).toBe(session.expiresAt);
const { ticket } = sessions.issueStreamTicket(session.id);
diff --git a/server/request-auth.ts b/server/request-auth.ts
index 38648ff112..87472173f6 100644
--- a/server/request-auth.ts
+++ b/server/request-auth.ts
@@ -363,6 +363,10 @@ export const CLIENT_ALLOW: ReadonlyArray<{ methods: readonly string[]; path: Reg
{ methods: ["POST"], path: /^\/api\/bots\/[\w-]+\/tasks\/[\w-]+\/title$/ },
{ methods: ["PATCH"], path: /^\/api\/bots\/[\w-]+\/profile$/ },
{ methods: ["PATCH"], path: /^\/api\/bots\/[\w-]+$/ }, // display fields only: see clientBotPatchViolation
+ // A Team Cloud member makes a bot of their own and deletes it while nobody else can use it: the handlers refuse every
+ // other session without the admin scope, and a member's bot takes only what memberBotCreateViolation allows.
+ { methods: ["POST"], path: /^\/api\/bots$/ },
+ { methods: ["DELETE"], path: /^\/api\/bots\/[\w-]+$/ },
{ methods: ["PUT"], path: /^\/api\/bots\/order$/ }, // the fleet's display order; the handler accepts only bots the caller sees
{ methods: ["POST"], path: /^\/api\/bots\/[\w-]+\/respond$/ },
{ methods: ["POST"], path: /^\/api\/threads\/[\w-]+\/respond$/ },
@@ -540,6 +544,15 @@ export function memberBotPatchViolation(body: unknown, level: "view" | "chat" |
return Object.keys(body).find((key) => !allowed.has(key)) ?? null;
}
+/** What a Team Cloud member may say of a bot they make: what someone who can edit a bot may change, and nothing else.
+ * Its sharing, its department, whom it answers to, what it may do and where it runs are not theirs to set at creation:
+ * the bot starts private to them with the server's own defaults. The first field beyond that; null when there is none. */
+export function memberBotCreateViolation(body: Record<string, unknown>): string | null {
+ const { settings, useDefaults: _useDefaults, ...asked } = body;
+ const nested = settings && typeof settings === "object" && !Array.isArray(settings) ? Object.keys(settings) : settings === undefined ? [] : ["settings"];
+ return [...Object.keys(asked), ...nested].find((key) => key === "threadId" || !EDITOR_BOT_PATCH_FIELDS.has(key)) ?? null;
+}
+
/** Same for a room: name and reading state, never its folder or who answers. */
const CLIENT_GROUP_PATCH_FIELDS = new Set(["name", "bulletin", "unread", "pinnedMessageId", "section", "turnTimeoutMinutes"]);
export function clientGroupPatchViolation(body: unknown): string | null {
diff --git a/server/routes/bot-access.ts b/server/routes/bot-access.ts
index 85fdf9b352..bd9a23aa0d 100644
--- a/server/routes/bot-access.ts
+++ b/server/routes/bot-access.ts
@@ -29,6 +29,8 @@ export interface BotAccessRouteDeps {
audienceChanged(): void;
/** Settings → Activity: the request is client-scoped, so the admin audit never sees it. */
record?(auth: RequestAuth, row: Omit<AdminActionRow, "at" | "actor">): void;
+ /** The sharing was written: whoever it newly names is told. */
+ shared?(auth: RequestAuth, bot: BotRecord, before: BotAccess, after: BotAccess): void;
}
/** The bot's sharing with `next` applied: the owner is never listed (they always edit), and nobody new comes in from
@@ -79,6 +81,7 @@ export function createBotAccessRoutes(deps: BotAccessRouteDeps): RouteHandler {
const updated = writeAccess(deps, current, settled.access);
if (updated && !sameAccess(before, settled.access)) {
deps.record?.(auth, { category: "visibility", action: "access.update", target: { kind: "bot", id: updated.id, name: updated.name }, before: { access: before }, after: { access: settled.access } });
+ deps.shared?.(auth, updated, before, settled.access);
}
return updated ? json(res, 200, { bot: deps.wireBot(updated) }) : json(res, 404, userError("serverError.bot.missing"));
};
diff --git a/server/routes/bot-lifecycle.ts b/server/routes/bot-lifecycle.ts
index a5f1421497..6d6ba00773 100644
--- a/server/routes/bot-lifecycle.ts
+++ b/server/routes/bot-lifecycle.ts
@@ -1,4 +1,5 @@
import type { ProviderRegistry } from "../harness/registry.ts";
+import type { RequestAuth } from "../request-auth.ts";
import type { RoutineManager } from "../routines.ts";
import type { BotRecord, GroupRecord, Store } from "../store.ts";
import { PASS, type RouteHandler } from "./table.ts";
@@ -14,6 +15,9 @@ export interface BotLifecycleRouteDeps {
runningTurnInstance(bot: BotRecord | null | undefined, threadId: string): ReturnType<ProviderRegistry["get"]>;
closeOpenApprovals(threadId: string): void;
deleteBotWithLifecycle(botId: string): Promise<{ status: number; body: unknown }>;
+ /** Security: the route is client-scoped, so this is the gate. Why this session may not delete the bot; null when it
+ * may. */
+ deleteRefusal(auth: RequestAuth, botId: string): string | null;
}
export function createBotLifecycleRoutes(deps: BotLifecycleRouteDeps): RouteHandler {
@@ -21,7 +25,7 @@ export function createBotLifecycleRoutes(deps: BotLifecycleRouteDeps): RouteHand
store, interruptAllDirectThreads, cancelDirectTurnDispatch, revokeInternalCapabilitiesForThread, activeGroupTurnForBot,
cancelGroupTurnOperations, runningTurnInstance, closeOpenApprovals, deleteBotWithLifecycle,
} = deps;
- return async ({ req, res, path, method, json }) => {
+ return async ({ req, res, path, method, auth, json }) => {
let m: RegExpMatchArray | null = null;
const routines = deps.routines();
if (method === "POST" && path === "/api/local-computer/interrupt") {
@@ -54,6 +58,8 @@ export function createBotLifecycleRoutes(deps: BotLifecycleRouteDeps): RouteHand
}
m = path.match(/^\/api\/bots\/([\w-]+)$/);
if (m && method === "DELETE") {
+ const refused = deps.deleteRefusal(auth, m[1]!);
+ if (refused) return json(res, 403, { error: refused });
const result = await deleteBotWithLifecycle(m[1]);
return json(res, result.status, result.body);
}
diff --git a/server/routes/bot-presets.test.ts b/server/routes/bot-presets.test.ts
index cfe040d962..5614d28847 100644
--- a/server/routes/bot-presets.test.ts
+++ b/server/routes/bot-presets.test.ts
@@ -7,7 +7,7 @@ import { afterEach, describe, expect, it } from "vitest";
import { json, readBody } from "../harness/http.ts";
import { createPresetStore, type OrgInstallStatus } from "../presets.ts";
-import { requiredScope } from "../request-auth.ts";
+import { memberBotCreateViolation, requiredScope } from "../request-auth.ts";
import { parsePackageDocument } from "../../shared/package-format.ts";
import { createBotPresetRoutes } from "./bot-presets.ts";
import { dispatchRoutes } from "./table.ts";
@@ -68,7 +68,7 @@ describe("/api/bot-presets through the route table", () => {
it("is for admins only, like the New bot defaults, and so is creating a bot from a preset", () => {
expect(requiredScope("GET", "/api/bot-presets")).toBe("admin");
expect(requiredScope("DELETE", "/api/bot-presets/p1")).toBe("admin");
- expect(requiredScope("POST", "/api/bots")).toBe("admin");
+ expect(memberBotCreateViolation({ name: "Sky", preset: "p1" }), "a Team Cloud member's own new bot takes no preset").toBe("preset");
expect(requiredScope("POST", "/api/teams/export")).toBe("admin");
});
});
diff --git a/server/routes/bots-create.ts b/server/routes/bots-create.ts
index 8598f3a027..d074ef13f7 100644
--- a/server/routes/bots-create.ts
+++ b/server/routes/bots-create.ts
@@ -11,7 +11,7 @@ import { MAX_MCP_SERVERS, mcpServerNameError } from "../mcp-registry.ts";
import { journalMemoryWrite } from "../memory-journal.ts";
import { resolveBotCreationDefaults } from "../new-bot-defaults.ts";
import { PRESET_UNAVAILABLE_MESSAGE, applyPresetToBot, presetOffered, type OrgInstallStatus, type PresetStore } from "../presets.ts";
-import { adminOnlyBotSetting, clientBotPatchViolation, type RequestAuth } from "../request-auth.ts";
+import { adminOnlyBotSetting, memberBotCreateViolation, type RequestAuth } from "../request-auth.ts";
import type { RoutineManager } from "../routines.ts";
import { installOrgSkill, installSkill, parseSkillMd, setSkillEnabled } from "../skills.ts";
import type { BotRecord, Store } from "../store.ts";
@@ -96,18 +96,19 @@ export function createBotCreateRoutes(deps: BotCreateRouteDeps): RouteHandler {
return json(res, 403, { error: `forbidden: a paired device may say who a new bot is and how it looks, not "${field}"; set that on the host computer` });
}
}
+ if (auth.kind === "session" && !auth.scopes.includes("admin")) {
+ if (!deps.team || auth.session.membershipAuthority !== "team" || !auth.session.email) return json(res, 403, { error: "forbidden: this session lacks the admin scope" });
+ const field = memberBotCreateViolation(body);
+ if (field) return json(res, 403, { error: `forbidden: "${field}" is an admin's to set` });
+ // The saved New bot defaults are an admin's choices, some of them an admin's alone to make.
+ body = { ...body, useDefaults: false };
+ }
const kept = keptBotIds(body, store);
if ("error" in kept) return json(res, kept.error.includes("already") ? 409 : 400, { error: kept.error });
const { id: _id, threadId: _threadId, ...rest } = body;
body = rest;
const template = resolveBotCreationDefaults(cfg.newBotDefaults, body);
const settings = template.profile;
- if (auth.kind === "session" && !auth.scopes.includes("admin")) {
- const field = clientBotPatchViolation(settings);
- if (field || body.preset !== undefined || template.skills.length || template.routines.length || Object.keys(template.memory).length) {
- return json(res, 403, { error: "Creating a bot with these defaults needs the admin scope" });
- }
- }
if (body.preset !== undefined && (typeof body.preset !== "string" || !/^[\w-]{1,64}$/.test(body.preset))) {
return json(res, 400, { error: "preset must be a preset id from New bot" });
}
diff --git a/server/routes/teams.ts b/server/routes/teams.ts
index 36fe983cde..54b135c381 100644
--- a/server/routes/teams.ts
+++ b/server/routes/teams.ts
@@ -5,6 +5,7 @@ import { validateBotCwd } from "../bot-cwd.ts";
import { fetchBotDirectory, matchDirectoryBots, type MatchedDirectoryBot } from "../bot-directory.ts";
import { isBotPackage, packageSummary, parsePackageDocument, renderBotPackageMarkdown, type PackageDocument } from "../bot-package.ts";
import { parseVisibility } from "../bot-visibility.ts";
+import { teamCreator } from "../new-bot-sharing.ts";
import type { AppConfig } from "../config.ts";
import type { ModelSelection } from "../contracts.ts";
import type { OrgLibrary } from "../org-library.ts";
@@ -267,7 +268,7 @@ export function createTeamRoutes(deps: TeamRouteDeps): RouteHandler {
const packageId = typeof body?.packageId === "string" && /^[a-f0-9-]{36}$/.test(body.packageId) ? body.packageId : null;
if (!packageId) return json(res, 400, { error: "Choose a package from your organization's library." });
if (!orgLibrary) return json(res, 404, { error: "This package is not in your organization's library.", code: "not_listed" });
- const outcome = orgLibrary.add(packageId, packageImportDeps(await defaultSelection()));
+ const outcome = orgLibrary.add(packageId, { ...packageImportDeps(await defaultSelection()), ...teamCreator(auth) });
if (!outcome.ok) return json(res, outcome.status, { error: outcome.error, code: outcome.code });
if (outcome.value.alreadyAdded) return json(res, 200, outcome.value);
const imported = outcome.value.result;
@@ -338,7 +339,7 @@ export function createTeamRoutes(deps: TeamRouteDeps): RouteHandler {
if (body?.format === "openmaus.backup") {
if (importMode !== "add") return json(res, 400, { error: "Import backups alongside your existing bots; project mode is only for templates" });
try {
- const imported = importTeamBackup(store, routines!, body, await defaultSelection(), { visibility: importVisibility });
+ const imported = importTeamBackup(store, routines!, body, await defaultSelection(), { visibility: importVisibility, ...teamCreator(auth) });
// A restore writes transcripts without store events: these frames carry the restored pages to other clients.
const bots = imported.bots.map((bot) => publicBot(bot));
const groups = imported.groups.map((group) => groupWithThread(group));
@@ -358,7 +359,7 @@ export function createTeamRoutes(deps: TeamRouteDeps): RouteHandler {
} catch (error) {
return json(res, 400, { error: error instanceof Error ? error.message : "Invalid bot package" });
}
- const deps = packageImportDeps(await defaultSelection());
+ const deps = { ...packageImportDeps(await defaultSelection()), ...teamCreator(auth) };
const options = {
mode: importMode as "add" | "project",
cwd: projectCwd,
diff --git a/server/store.ts b/server/store.ts
index 9dbfa4a5f0..478ee93708 100644
--- a/server/store.ts
+++ b/server/store.ts
@@ -38,7 +38,7 @@ import { movesThreadToTop, nextOpenThread } from "../shared/wire.ts";
import { parseConnectorTools } from "./connector-tools.ts";
import { sameModelSelection } from "../shared/thread-model.ts";
import { initialGreetingMessage } from "./initial-greeting.ts"; import { createDefaultBot, defaultBotRefusal, type DefaultBotIntro } from "./default-bot.ts";
-import { appsFromCreator } from "./inherited-apps.ts";
+import { appsFromCreator } from "./inherited-apps.ts"; import { newBotOwner, sharedAsMaker, sharedUnlessRestricted, type NewBotSharingRule } from "./new-bot-sharing.ts";
import { ThreadCache, type ThreadState } from "./thread-cache.ts";
import { titleFromMessage, UNTITLED_TASK } from "./thread-title.ts";
export { titleFromMessage, UNTITLED_TASK } from "./thread-title.ts";
@@ -288,6 +288,8 @@ export class Store {
private driverKindOf: (instanceId: string) => string | undefined;
private initialLanguage: string | (() => string);
private personName: () => string | undefined;
+ /** How a new bot is shared; a Team Cloud sets its own rule. */
+ newBotSharing: NewBotSharingRule = sharedUnlessRestricted;
private listeners = new Set<(change: StoreChange) => void>();
private registeringInitialSections = true;
private readonly botsFile = new OwnedFile(BOTS_FILE, { mode: 0o600 }); private readonly groupsFile = new OwnedFile(GROUPS_FILE, { mode: 0o600 });
@@ -1317,8 +1319,7 @@ export class Store {
color: profile.color ?? rotationColor(this.bots.length), mascotFaceColor: profile.mascotFaceColor ?? undefined,
...(profile.mascotExpression ? { mascotExpression: profile.mascotExpression } : {}),
...(profile.mascotBody ? { mascotBody: profile.mascotBody } : {}),
- // Restricted from its first frame: no one else is ever told it exists.
- ...(profile.visibility && profile.visibility !== "everyone" ? { visibility: structuredClone(profile.visibility) } : {}),
+ ...this.newBotSharing(profile.visibility, newBotOwner(profile)),
...(toolScope.scope ? { toolScope: toolScope.scope } : {}),
unread: false,
modelSelection: this.newBotSelection(profile.modelSelection),
@@ -1375,8 +1376,7 @@ export class Store {
title: "", description: "", soul: "", notifications: true, color: rotationColor(nextBots.length), unread: false,
resumeCursors: {}, createdAt, ...operation.fields, modelSelection,
autoApprove: false,
- // A restricted Chief never creates a bot everyone sees.
- ...(chief.visibility && chief.visibility !== "everyone" ? { visibility: structuredClone(chief.visibility) } : {}),
+ ...sharedAsMaker(chief),
// A Chief's new specialist reports to the Chief's own person.
...(botOwner(chief) ? { createdBy: botOwner(chief)! } : {}),
tasks: [{ threadId: operation.threadId, title: UNTITLED_THREAD, createdAt, updatedAt: createdAt, resumeCursors: {},
@@ -2286,6 +2286,6 @@ export class Store {
/** A new place's first bot is its MausBot and its Chief; a Team Cloud's (`defaultBot: false`) is the team's Chief only. */
seedIfEmpty({ defaultBot = true, intro }: { defaultBot?: boolean; intro?: DefaultBotIntro } = {}) {
if (!this.needsSeed()) return;
- if (defaultBot) createDefaultBot(this, { chief: (id) => this.setChiefOfStaff(id), ...(intro ? { intro } : {}) }); else this.setChiefOfStaff(this.createBot().id);
+ if (defaultBot) createDefaultBot(this, { chief: (id) => this.setChiefOfStaff(id), ...(intro ? { intro } : {}) }); else this.setChiefOfStaff(this.createBot({ visibility: "everyone" }).id);
}
}
diff --git a/server/team-backup.ts b/server/team-backup.ts
index 6f08937159..46971682eb 100644
--- a/server/team-backup.ts
+++ b/server/team-backup.ts
@@ -141,7 +141,7 @@ export function createTeamBackup(store: Store, routines: Routine[], name: string
}
/** Always additive: rollback owns only the fresh records and cannot touch an existing bot or chat. */
-export function importTeamBackup(store: Store, routines: RoutineManager, input: unknown, selection: ModelSelection, options: { visibility?: BotVisibility } = {}) {
+export function importTeamBackup(store: Store, routines: RoutineManager, input: unknown, selection: ModelSelection, options: { visibility?: BotVisibility; createdBy?: string } = {}) {
const backup = parseTeamBackup(input);
const bots: BotRecord[] = [];
const groups: GroupRecord[] = [];
@@ -189,6 +189,7 @@ export function importTeamBackup(store: Store, routines: RoutineManager, input:
modelSelection: selection, section: sectionFor(source.section),
// who may see the imported team is the importing admin's choice
...(options.visibility ? { visibility: options.visibility } : {}),
+ ...(options.createdBy ? { createdBy: options.createdBy } : {}),
}, { seedMessages: false });
bots.push(bot);
botIds.set(source.key, bot.id);
diff --git a/server/team-move.e2e.test.ts b/server/team-move.e2e.test.ts
index 32946eabe0..2d39e1a21f 100644
--- a/server/team-move.e2e.test.ts
+++ b/server/team-move.e2e.test.ts
@@ -121,8 +121,11 @@ it("moves Scout with its two chats, its routine and its files; its notes about A
expect(phaseOf(scout.bot.id)?.phase, JSON.stringify(fx.teamMove.journal())).toBe("done");
expect(fx.teamMove.view()).toEqual({ bot: { id: scout.bot.id, name: "Scout" }, team: ACME, phase: "done" });
- // Everyone in Acme has Scout.
- for (const who of ["olive", "ben", "ada", "cleo"]) expect((await teamBots(who)).some((bot) => bot.id === scout.bot.id && bot.name === "Scout"), who).toBe(true);
+ // Scout is Ada's until she shares it: she and Acme's admins have it, and another User does not.
+ for (const who of ["olive", "ben", "ada"]) expect((await teamBots(who)).some((bot) => bot.id === scout.bot.id && bot.name === "Scout"), who).toBe(true);
+ expect(((await teamBots("ada")).find((bot) => bot.id === scout.bot.id) as { access?: unknown }).access).toEqual({ everyone: "none", people: {} });
+ expect((await teamBots("cleo")).some((bot) => bot.id === scout.bot.id), "cleo").toBe(false);
+ expect((await onTeam("cleo")("POST", `/api/bots/${scout.bot.id}/messages`, { text: "hello" })).status, "nor reaches it by id").toBe(404);
// Its two chats are Ada's own there: private, never the team's main chat, with her lines as hers.
const there = (await teamBots("ada")).find((bot) => bot.id === scout.bot.id)!;
expect(there.threadId === scout.main || (there as { mainThreadId?: string }).mainThreadId === scout.main, "its main chat in Acme is a new one of the team's").toBe(false);
@@ -135,7 +138,7 @@ it("moves Scout with its two chats, its routine and its files; its notes about A
expect((await onTeam("olive")("GET", `/api/threads/${threadId}/messages`)).status, "nor does the Owner").toBe(404);
expect((await onTeam("cleo")("GET", `/api/threads/${threadId}/messages`)).status, "another Member never does").toBe(404);
}
- expect((await teamBots("cleo")).find((bot) => bot.id === scout.bot.id)!.tasks?.some((task) => [scout.main, scout.budget].includes(task.threadId))).toBe(false);
+ expect((await teamBots("ben")).find((bot) => bot.id === scout.bot.id)!.tasks?.some((task) => [scout.main, scout.budget].includes(task.threadId))).toBe(false);
// The routine arrived off and was switched on after the check; it is gone from My Cloud, never on in both places.
const routines = (await onTeam("ada")("GET", "/api/routines")).body.routines as Array<{ id: string; enabled: boolean; resultsThreadId?: string; botId: string }>;
@@ -239,8 +242,8 @@ it("a bot whose name Acme already uses arrives as \"Scout (Ada)\"", async () =>
await say(bot, bot.threadId, "Hello, second Scout.");
await move(bot);
expect(phaseOf(bot.id)?.phase).toBe("done");
- expect((await teamBots("cleo")).find((entry) => entry.id === bot.id)?.name).toBe("Scout (Ada)");
- expect((await teamBots("cleo")).find((entry) => entry.id === scout.bot.id)?.name).toBe("Scout");
+ expect((await teamBots("ben")).find((entry) => entry.id === bot.id)?.name).toBe("Scout (Ada)");
+ expect((await teamBots("ben")).find((entry) => entry.id === scout.bot.id)?.name).toBe("Scout");
}, hostTimeout(180_000));
it("refuses a team the person isn't in, any page but My Cloud's, and Ada leaving Acme mid-move lets the bot go on on My Cloud", async () => {
diff --git a/server/team-protocol.e2e.test.ts b/server/team-protocol.e2e.test.ts
index 1b416d8b73..5f9bc62e04 100644
--- a/server/team-protocol.e2e.test.ts
+++ b/server/team-protocol.e2e.test.ts
@@ -70,7 +70,7 @@ beforeAll(async () => {
ben = (await team.pair(BEN)).token!;
for (const [token, name] of [[olive, "Olive"], [mira, "Mira"], [ben, "Ben"]] as const) expect((await team.as(token, "PUT", "/api/me", { name })).status).toBe(200);
const create = async (body: Record<string, unknown>) => {
- const created = await team.as(olive, "POST", "/api/bots", body);
+ const created = await team.as(olive, "POST", "/api/bots", { visibility: "everyone", ...body });
expect(created.status, JSON.stringify(created.body)).toBe(201);
return created.body.bot as Bot;
};
diff --git a/server/team-small-fixes.e2e.test.ts b/server/team-small-fixes.e2e.test.ts
index 08d0bb8c85..d88a357332 100644
--- a/server/team-small-fixes.e2e.test.ts
+++ b/server/team-small-fixes.e2e.test.ts
@@ -45,7 +45,7 @@ const turns = (): Turn[] => existsSync(`${planPath()}.evidence.jsonl`)
? readFileSync(`${planPath()}.evidence.jsonl`, "utf8").trim().split("\n").filter(Boolean).map((line) => JSON.parse(line) as Turn) : [];
const plan = (value: Record<string, unknown>) => writeFileSync(planPath(), JSON.stringify(value));
const create = async (body: Record<string, unknown>) => {
- const created = await team.as(ada, "POST", "/api/bots", body);
+ const created = await team.as(ada, "POST", "/api/bots", { visibility: "everyone", ...body });
expect(created.status, JSON.stringify(created.body)).toBe(201);
return created.body.bot as Bot;
};
diff --git a/server/team-welcome.e2e.test.ts b/server/team-welcome.e2e.test.ts
index 3749272242..8e57990c54 100644
--- a/server/team-welcome.e2e.test.ts
+++ b/server/team-welcome.e2e.test.ts
@@ -70,7 +70,7 @@ it("tells a signed-in member, never anyone before sign-in, where their team page
it("the welcome's one action, a chat with a bot, is the person's own private chat: the new conversation is marked private on the wire at once", async () => {
const ada = (await team.pair(ADA)).token!, cleo = (await team.pair(CLEO)).token!;
- const made = await team.as(ada, "POST", "/api/bots", { name: "Research", description: "Briefs before a call." });
+ const made = await team.as(ada, "POST", "/api/bots", { name: "Research", description: "Briefs before a call.", visibility: "everyone" });
expect(made.status, JSON.stringify(made.body)).toBe(201);
const botId = made.body.bot.id as string;
const opened = await team.as(cleo, "POST", `/api/bots/${botId}/tasks`, {});
@@ -83,7 +83,7 @@ it("the welcome's one action, a chat with a bot, is the person's own private cha
it("a User's copy of a team bot carries what the welcome's one line reads, and a removed person's page is told why", async () => {
const ada = (await team.pair(ADA)).token!;
- const made = await team.as(ada, "POST", "/api/bots", { name: "Seedling" });
+ const made = await team.as(ada, "POST", "/api/bots", { name: "Seedling", visibility: "everyone" });
await team.as(ada, "PATCH", `/api/bots/${made.body.bot.id}`, { soul: "You look after the team's plants." });
const dee = (await team.pair({ email: "[email protected]", role: "member" })).token!;
const copy = ((await team.as(dee, "GET", "/api/bots?messages=0")).body.bots as Array<{ id: string; soul?: string }>).find((bot) => bot.id === made.body.bot.id);
diff --git a/src/App.tsx b/src/App.tsx
index 1ff0b5c02e..64fd708794 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -67,7 +67,7 @@ import { t } from "@/lib/i18n";
import { botCycleStep, shouldOpenKeyboardShortcuts } from "@/lib/keyboard-shortcuts";
import { effectiveLanguage, useLanguageChoice, usePageLanguage } from "@/lib/language-preference";
import { botUnreadCount, showBrowserUnread } from "@/lib/bot-unread";
-import { phonePairingSettingsAction, takePhonePairingRequest } from "@/lib/phone-pairing"; import { takeConnectRequest } from "@/lib/connect-link";
+import { phonePairingSettingsAction, takePhonePairingRequest } from "@/lib/phone-pairing"; import { useConnectLink } from "@/lib/use-connect-link";
import { useDesktopNotificationOpens, useExternalChatLinks } from "@/hooks/use-external-chat-links";
import { useUsageSnapshot } from "@/hooks/use-usage-snapshot";
import { useReadShownChatOnFocus } from "@/hooks/use-read-shown-chat";
@@ -132,12 +132,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
window.history.replaceState(null, "", rest);
dispatch(phonePairingSettingsAction());
}, [dispatch]);
- useEffect(() => { // A bot's link to a connection that needs the person on My Cloud opens the page that connects it.
- const request = takeConnectRequest(window.location.href);
- if (!request) return;
- window.history.replaceState(null, "", request.rest);
- dispatch("section" in request ? { type: "toggleAppSettings", open: true, section: request.section } : { type: "togglePlugins", open: true, surface: request.surface });
- }, [dispatch]);
+ useConnectLink(dispatch, Boolean(state.config?.team));
useExternalChatLinks(state, dispatch); useDesktopNotificationOpens(state, dispatch);
usePresence(state, dispatch); useTeamPresence(state);
const [drawerOpen, setDrawerOpen] = useState(false);
diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsx
index 6faefa3c47..8d8712cc09 100644
--- a/src/components/ChatView.tsx
+++ b/src/components/ChatView.tsx
@@ -91,7 +91,7 @@ import { AttachmentGallery, collectMessageFiles, replyAttachmentGroup, splitMess
import { ScreenFrame } from "./ScreenFrame";
import { CompactionChip, DigestChip } from "./DigestChip";
import { RenameTitle } from "./RenameTitle"; import { ChatHeadRole, chiefOfStaffBadge } from "./BotRole";
-import { BotActivityPicker } from "./TaskPicker"; import { ChatHeadPill } from "./ChatHeadPill"; import { ThreadPresenceFaces } from "./TeamPresence"; import { useStoreRef } from "@/state/store-ref"; import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select"; import { sameDrawnBots } from "@/lib/drawn-bots";
+import { BotActivityPicker } from "./TaskPicker"; import { ChatHeadPill } from "./ChatHeadPill"; import { HeaderShare } from "./bot-access/HeaderShare"; import { ThreadPresenceFaces } from "./TeamPresence"; import { useStoreRef } from "@/state/store-ref"; import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select"; import { sameDrawnBots } from "@/lib/drawn-bots";
import { ELEVATED_FLOAT, ELEVATED_HOVER } from "./elevated";
import { ModelPicker } from "./ModelPicker";
import { ChatHeaderMenu, ChatMoreMenu } from "./ChatMoreMenu"; import { TeamOwnHelperHeader, TeamPrivateFirstLine, TeamPrivateHeader, TeamSharedHeader } from "./TeamPrivateChatsLine"; import { ownChatStarted } from "@/state/team-chats";
@@ -1116,7 +1116,7 @@ export const ChatView = memo(function ChatView({ bot: profile }: { bot: Bot }) {
>
<Monitor size={16} />{busy && place === "browser" && <span aria-hidden="true" className="absolute right-1 top-1 size-1.5 animate-pulse rounded-full bg-success" data-testid="computer-button-live" />}
</button>}
- {phoneMenu ? <ChatMoreMenu bot={bot} phoneHeader /> : (advanced || remoteClient) && <ChatHeaderMenu key={`menu:${bot.threadId}`} bot={bot} />}
+ <HeaderShare bot={bot} />{phoneMenu ? <ChatMoreMenu bot={bot} phoneHeader /> : (advanced || remoteClient) && <ChatHeaderMenu key={`menu:${bot.threadId}`} bot={bot} />}
</div>
</div>
</div>
diff --git a/src/components/MoveToTeam.test.ts b/src/components/MoveToTeam.test.ts
index d48e2d641d..e093fe3c84 100644
--- a/src/components/MoveToTeam.test.ts
+++ b/src/components/MoveToTeam.test.ts
@@ -107,7 +107,7 @@ it("the bot menu has one Move to item per team, none without a team or for a bot
hook.items(SCOUT, item);
items[0]!.onClick!();
const confirm = html(menu);
- for (const said of ["Move Scout to Acme?", "Everyone in Acme can use Scout. Only Acme's admins can change it.",
+ for (const said of ["Move Scout to Acme?", "Only you and Acme's admins can use Scout until you share it.",
"Goes with Scout: instructions, skills, files, routines, and your chats with Scout", "Your chats stay private there: only you can see them.",
"Stays on My Cloud: what Scout remembers, your connections, and MausBot", "There's no way back: you can't move it back to My Cloud.", "Move to Acme"]) expect(confirm).toContain(said);
expect(page.moveToTeam, "nothing moves until the confirm").not.toHaveBeenCalled();
diff --git a/src/components/MoveToTeam.tsx b/src/components/MoveToTeam.tsx
index 823fa6ebd4..8386211a08 100644
--- a/src/components/MoveToTeam.tsx
+++ b/src/components/MoveToTeam.tsx
@@ -64,7 +64,7 @@ export function useMoveToTeam({ blocked }: { blocked: (bot: Bot) => string | und
icon={<Users size={18} />}
title={t("teamMove.title", names)}
body={<span className="flex flex-col gap-2" data-team-move-confirm>
- <span>{t("teamMove.everyone", names)}</span>
+ <span>{t("teamMove.yours", names)}</span>
<span>{t("teamMove.goes", names)}</span>
<span>{t("teamMove.private", names)}</span>
<span>{t("teamMove.staysOnMyCloud", names)}</span>
diff --git a/src/components/NewBotDialog.test.ts b/src/components/NewBotDialog.test.ts
index 7793720ef0..4f89bfe4b2 100644
--- a/src/components/NewBotDialog.test.ts
+++ b/src/components/NewBotDialog.test.ts
@@ -3,7 +3,7 @@ import { renderToStaticMarkup } from "react-dom/server";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
const fixture = vi.hoisted(() => ({ effects: [] as EffectCallback[], dispatch: vi.fn(), api: vi.fn(), create: vi.fn(), setDraft: vi.fn(), ready: false, hook: 0, admin: false,
- profile: {} as Record<string, unknown>, track: vi.fn(), advanced: true, appSettingsOpen: false, openBot: vi.fn(), close: vi.fn() }));
+ profile: {} as Record<string, unknown>, track: vi.fn(), advanced: true, appSettingsOpen: false, openBot: vi.fn(), close: vi.fn(), teamName: null as string | null }));
vi.mock("@/state/thread-navigation", async importOriginal => ({
...await importOriginal<typeof import("@/state/thread-navigation")>(), openBot: fixture.openBot,
}));
@@ -29,10 +29,11 @@ vi.mock("@/lib/create-configured-bot", async importOriginal => ({
}));
vi.mock("@/state/store", async importOriginal => {
const store = await importOriginal<typeof import("@/state/store")>();
- return { ...store, api: fixture.api, BotEditorStore: () => null, useStore: () => ({ state: { ...store.initialState, appSettingsOpen: fixture.appSettingsOpen }, dispatch: fixture.dispatch }) };
+ return { ...store, api: fixture.api, BotEditorStore: () => null, useStore: () => ({ state: { ...store.initialState, appSettingsOpen: fixture.appSettingsOpen, ...(fixture.teamName ? { config: { team: { id: "acme", name: fixture.teamName } } } : {}) }, dispatch: fixture.dispatch }) };
});
import { NewBotDialog } from "./NewBotDialog";
import { setTeamChats } from "@/state/team-chats";
+import { setTeamPeople } from "@/state/team-people";
import { Select } from "./Select";
import type { BotCreationDraft } from "@/lib/bot-creation-draft";
@@ -74,9 +75,10 @@ beforeEach(() => {
fixture.appSettingsOpen = false;
fixture.openBot.mockReset();
fixture.close.mockReset();
+ fixture.teamName = null;
fixture.api.mockReturnValue(new Promise(() => {}));
});
-afterEach(() => { vi.unstubAllGlobals(); setTeamChats(null); });
+afterEach(() => { vi.unstubAllGlobals(); setTeamChats(null); setTeamPeople(null); });
describe("bot draft dialog", () => {
it("preserves upstream audience selection for browser admins before creation", () => {
@@ -197,6 +199,28 @@ describe("bot draft dialog", () => {
expect(fixture.openBot.mock.invocationCallOrder[0]).toBeGreaterThan(fixture.dispatch.mock.invocationCallOrder[added]);
});
+ it("on a team's Cloud, says who can use the new bot, preset to Just me, and asks the server for no sharing of its own", async () => {
+ const ada = { email: "[email protected]", name: "Ada", role: "admin" as const, you: true as const, here: true };
+ setTeamPeople({ people: [ada], me: ada, admin: true, needsYou: [] });
+ fixture.teamName = "Acme";
+ fixture.admin = true;
+ vi.stubGlobal("window", {});
+ fixture.ready = true;
+ fixture.create.mockResolvedValue({ bot: { id: "created", name: "Fixture" }, warnings: [] });
+ const dialog = render();
+ const choice = dialog.nodes.find(named("WhoCanUse"))!;
+ expect(choice.props).toMatchObject({ team: "Acme", everyone: false });
+ const select = output(choice).find(node => node.type === Select)!;
+ expect((select.props as unknown as { value: string }).value).toBe("me");
+ expect(renderToStaticMarkup(choice)).toContain("Just me");
+ expect(renderToStaticMarkup(choice)).toContain("Everyone in Acme");
+ expect(dialog.html, "the older Who can see it is not asked beside it").not.toContain("Who can see it");
+ dialog.nodes.filter(node => node.type === "button").at(-1)!.props.onClick!();
+ await vi.waitFor(() => expect(fixture.create).toHaveBeenCalledOnce());
+ expect(fixture.create.mock.calls[0]![4], "the server's own default decides: private").toBeUndefined();
+ expect(fixture.create.mock.calls[0]![5]).toBe("[email protected]");
+ });
+
it("anywhere but a team's Cloud, leaves the new bot selected as it always was", async () => {
fixture.ready = true;
fixture.create.mockResolvedValue({ bot: { id: "created", name: "Fixture" }, warnings: [] });
diff --git a/src/components/NewBotDialog.tsx b/src/components/NewBotDialog.tsx
index 2f7f801a14..cd9f8e75e0 100644
--- a/src/components/NewBotDialog.tsx
+++ b/src/components/NewBotDialog.tsx
@@ -13,7 +13,6 @@ import { useOwnerOrAdmin } from "@/lib/use-owner-or-admin";
import { useAdvancedMode } from "@/lib/interface-mode";
import { announceNewBot, reportsToFor, startingTemplate, type BotDefaultsAnswer } from "@/lib/new-bot";
import { useShowThreads } from "@/lib/thread-preferences";
-import { openServerMenu } from "./DesktopWorkspaceSwitcher";
import { useTeamPeople } from "@/state/team-people";
import { visibilityFromForm, type VisibilityMode } from "./bot-settings/VisibilitySection";
import type { Routine } from "@/lib/routines";
@@ -75,7 +74,8 @@ function NewBotEditor({ defaultsMode = false, onClose, onCreated, readyBotId }:
const ownerOrAdmin = useOwnerOrAdmin();
const showThreads = useShowThreads();
const sections = useAdvancedMode() ? SECTIONS : SECTIONS.filter((section) => section !== "Model");
- const choosesVisibility = !defaultsMode && typeof window !== "undefined" && !window.ogb && ownerOrAdmin === true;
+ const [everyone, setEveryone] = useState(false);
+ const choosesVisibility = !team && !defaultsMode && typeof window !== "undefined" && !window.ogb && ownerOrAdmin === true;
const dialog = useRef<HTMLDivElement>(null);
const closeRef = useRef(onClose);
closeRef.current = onClose;
@@ -121,7 +121,7 @@ function NewBotEditor({ defaultsMode = false, onClose, onCreated, readyBotId }:
const save = async () => {
if (!ready || savingRef.current || parent.state.botCreationPending) return;
if (!defaultsMode && draft.bot.approvalMode === "auto" && draft.bot.computer === "local" && !draft.consent.acknowledgeLocalAuto) { setWarning("local"); return; }
- const visibility = choosesVisibility ? visibilityFromForm(audience, people) : null;
+ const visibility = choosesVisibility ? visibilityFromForm(audience, people) : team && everyone ? { ok: true as const, visibility: "everyone" as const } : null;
if (visibility && !visibility.ok) { setError(t("botSettings.visibility.needPeople")); return; }
savingRef.current = true; setSaving(true); setError("");
parent.dispatch({ type: "botCreationPending", on: true });
@@ -166,7 +166,7 @@ function NewBotEditor({ defaultsMode = false, onClose, onCreated, readyBotId }:
<button type="button" onClick={() => closeRef.current()} aria-label={t("common.close")}
className="flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-40"><X size={18} className="pointer-events-none" /></button>
</div>
- {team && !defaultsMode && teamName && <SharedInTeam team={teamName} />}
+ {team && !defaultsMode && teamName && <WhoCanUse team={teamName} everyone={everyone} disabled={saving} onChange={setEveryone} />}
{choosesVisibility && (
<div className="flex flex-wrap items-center gap-2 px-5 pt-3 text-[13px] text-ink-secondary" data-new-bot-visibility>
<label className="flex items-center gap-2">
@@ -221,14 +221,15 @@ function NewBotEditor({ defaultsMode = false, onClose, onCreated, readyBotId }:
</div>;
}
-function SharedInTeam({ team }: { team: string }) {
- const bridge = typeof window === "undefined" ? undefined : window.ogb?.workspaces;
- return <div data-new-bot-shared className="flex flex-wrap items-center gap-x-2 gap-y-1 border-b border-hairline/40 bg-raised/30 px-5 py-2.5 text-[13px] text-ink-secondary">
- <span>{t("newBot.sharedWith", { team })}</span>
- {bridge
- ? <button type="button" onClick={() => void openServerMenu(bridge).catch(() => {})} className="font-medium text-accent hover:underline">{t("newBot.justForYou")}</button>
- : <span>{t("newBot.justForYou").replace(/\s*→$/, "")}</span>}
- </div>;
+/** A team bot is its maker's until they share it; this is the one place to share it with everyone from the start. */
+function WhoCanUse({ team, everyone, disabled, onChange }: { team: string; everyone: boolean; disabled: boolean; onChange(everyone: boolean): void }) {
+ return <label data-new-bot-shared={everyone ? "everyone" : "me"} className="flex flex-wrap items-center gap-2 border-b border-hairline/40 bg-raised/30 px-5 py-2.5 text-[13px] text-ink-secondary">
+ {t("botAccess.general")}
+ <Select size="sm" value={everyone ? "everyone" : "me"} disabled={disabled} onChange={(event) => onChange(event.target.value === "everyone")}>
+ <option value="me">{t("teamSide.me")}</option>
+ <option value="everyone">{t("teamSettings.everyone", { team })}</option>
+ </Select>
+ </label>;
}
function DraftSection({ active, draft, defaultsMode, owner }: { active: Section; draft: BotCreationDraft; defaultsMode: boolean;
diff --git a/src/components/Sidebar.plus-menu.test.ts b/src/components/Sidebar.plus-menu.test.ts
index a3fe4019de..df5ba31a7a 100644
--- a/src/components/Sidebar.plus-menu.test.ts
+++ b/src/components/Sidebar.plus-menu.test.ts
@@ -2,7 +2,7 @@
import { Children, isValidElement, type ReactElement, type ReactNode } from "react";
import { describe, expect, it, vi } from "vitest";
-const fixture = vi.hoisted(() => ({ values: [] as unknown[], index: 0, admin: true as boolean | null }));
+const fixture = vi.hoisted(() => ({ values: [] as unknown[], index: 0, admin: true as boolean | null, team: false }));
vi.mock("react", async (original) => ({
...await original<typeof import("react")>(),
useState: (initial: unknown) => {
@@ -37,7 +37,7 @@ vi.mock("@/lib/interface-mode", () => ({ useAdvancedMode: () => false, setAdvanc
vi.mock("@/state/store-select", async (importOriginal) => (await import("@/testing/plain-store-select")).plainStoreSelect(await importOriginal()));
vi.mock("@/state/store", async (importOriginal) => {
const original = await importOriginal<typeof import("@/state/store")>();
- return { ...original, useStore: () => ({ state: original.initialState, dispatch: vi.fn() }) };
+ return { ...original, useStore: () => ({ state: fixture.team ? { ...original.initialState, config: { team: { id: "acme", name: "Acme" } } } : original.initialState, dispatch: vi.fn() }) };
});
import { Sidebar } from "./Sidebar";
@@ -60,9 +60,10 @@ function render() {
fixture.index = 0;
return nodes(drawSidebar({ open: true, onClose: () => {} }));
}
-function plusMenu(admin: boolean | null) {
+function plusMenu(admin: boolean | null, team = false) {
fixture.values = [];
fixture.admin = admin;
+ fixture.team = team;
render().find((node) => node.type === "button" && String(node.props["aria-label"]).startsWith("New"))!.props.onClick!();
return render().filter((node) => node.props.role === "menuitem").map((node) => words(node.props.children));
}
@@ -72,7 +73,12 @@ describe("the sidebar's + menu", () => {
for (const admin of [true, null]) expect(plusMenu(admin)).toEqual(["New bot", "New group chat", "Templates"]);
});
- it("offers neither to a User, who keeps New group chat", () => {
+ it("offers a team's User a new bot of their own, and templates only to its admins", () => {
+ expect(plusMenu(false, true)).toEqual(["New bot", "New group chat"]);
+ expect(plusMenu(true, true)).toEqual(["New bot", "New group chat", "Templates"]);
+ });
+
+ it("offers neither to someone without the admin scope anywhere else, who keeps New group chat", () => {
expect(plusMenu(false)).toEqual(["New group chat"]);
});
});
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 41271971e2..8ee57a33a0 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -1177,7 +1177,7 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
{t("sidebar.newChat.title")}
</button>}
{!advanced && plusBot && <><button role="menuitem" className={plusItem} onClick={() => { setPlusOpen(false); dispatch({ type: "newTask", botId: plusBot.id }); }}><SquarePen size={16} className="text-ink-secondary" />{t("sidebar.newConversationWith", { name: plusBot.name })}</button><div role="separator" className={MENU_ITEM_SEPARATOR} /></>}
- {teamSettingsAllowed !== false && <button
+ {(teamSettingsAllowed !== false || state.config?.team) && <button
onClick={() => { setPlusOpen(false); dispatch({ type: "newBot" }); }}
role="menuitem"
className={plusItem}
@@ -1621,7 +1621,7 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
anchor={sidebarRef.current}
style={windowNoDragStyle}
onClose={() => setNewChatOpen(false)}
- onNewBot={teamSettingsAllowed === false ? undefined : () => { setNewChatOpen(false); dispatch({ type: "newBot" }); }}
+ onNewBot={teamSettingsAllowed === false && !state.config?.team ? undefined : () => { setNewChatOpen(false); dispatch({ type: "newBot" }); }}
onNewGroup={() => { setNewChatOpen(false); setNewRoom(true); }}
/>,
document.body,
diff --git a/src/components/SidebarBotMenu.tsx b/src/components/SidebarBotMenu.tsx
index bed6446bf5..6b21a7ad70 100644
--- a/src/components/SidebarBotMenu.tsx
+++ b/src/components/SidebarBotMenu.tsx
@@ -10,6 +10,7 @@ import { allThreadRows, BotDeleteMenuItem, useDeleteAllThreads } from "./BotMenu
import { HideDefaultBotItem } from "./DefaultBotControls";
import { navigateThreadMenu } from "./BotProjects";
import { useOwnerOrAdmin } from "@/lib/use-owner-or-admin";
+import { userBotMenu } from "@/lib/own-team-bot";
import { botUnreadThreadIds, markBotRead } from "@/lib/folder-read";
import { ownerMenuLabel, pickOwnerOf } from "./TeamOwner";
import { mayChangeOwner, mayRename, useTeamPeople } from "@/state/team-people";
@@ -162,6 +163,10 @@ export function BotContextMenu({
: visibleBotCount <= 1
? t("sidebar.bot.archiveBlockedLast")
: undefined;
+ const user = userBotMenu(bot, team?.me?.email), ownEdit = Boolean(team) && user.duplicate;
+ const ownDelete = () => !team || !user.delete ? []
+ : user.delete === "shared" ? [item(<Trash2 size={16} />, t("common.delete"), undefined, { danger: true, disabled: true, hint: t("sidebar.bot.deleteSharedAdminOnly") })]
+ : [<BotDeleteMenuItem key="delete" deleting={deleting} className={MENU_ITEM} onClick={() => { onClose(); onDelete(bot); }} />];
const chiefItem = () => item(
<Crown size={16} className={bot.chiefOfStaff ? "text-accent" : "text-ink-secondary"} />,
bot.chiefOfStaff ? t("sidebar.bot.removeChief") : t("sidebar.bot.makeChief"),
@@ -260,7 +265,7 @@ export function BotContextMenu({
const moreItems = remoteClient ? [editProfile, owner, ...deleteAll] : [
editProfile,
team ? null : chiefItem(),
- member ? null : item(<Copy size={16} className="text-ink-secondary" />, t("sidebar.bot.duplicate"), () => dispatch({ type: "duplicateBot", botId: bot.id })),
+ member && !ownEdit ? null : item(<Copy size={16} className="text-ink-secondary" />, t("sidebar.bot.duplicate"), () => dispatch({ type: "duplicateBot", botId: bot.id })),
owner,
...moveToTeam.items(bot, item),
...moveToCloud.items(bot, item),
@@ -280,7 +285,7 @@ export function BotContextMenu({
);
const threads = [divider("threads"), newThread, viewThreads, setMain];
const moreRow = flyoutButton("more", moreRef, <MoreHorizontal size={16} className="text-ink-secondary" />, t("sidebar.bot.more"));
- const leave = bot.defaultBot ? [<HideDefaultBotItem key="hide" bot={bot} onDone={onClose} className={MENU_ITEM} />] : member ? [] : [
+ const leave = bot.defaultBot ? [<HideDefaultBotItem key="hide" bot={bot} onDone={onClose} className={MENU_ITEM} />] : member ? ownDelete() : [
item(<Archive size={16} className="text-ink-secondary" />, t("sidebar.bot.archive"), () => onArchive(bot), { disabled: archiveBlocked, hint: archiveHint }),
<BotDeleteMenuItem key="delete" deleting={deleting} className={MENU_ITEM} onClick={() => { onClose(); onDelete(bot); }} />,
];
@@ -417,7 +422,7 @@ export function BotContextMenu({
openForSettings();
if (!state.settingsOpen) dispatch({ type: "toggleSettings", open: true });
}),
- !member && item(<Copy size={16} className="text-ink-secondary" />, t("sidebar.bot.duplicate"), () =>
+ (!member || ownEdit) && item(<Copy size={16} className="text-ink-secondary" />, t("sidebar.bot.duplicate"), () =>
dispatch({ type: "duplicateBot", botId: bot.id }),
),
divider("d2"),
@@ -425,7 +430,7 @@ export function BotContextMenu({
void copyText(bot.threadId);
}),
divider("d3"), ...moveToTeam.items(bot, item), ...moveToCloud.items(bot, item),
- ...(bot.defaultBot ? [<HideDefaultBotItem key="hide" bot={bot} onDone={onClose} className={MENU_ITEM} />] : member ? [] : [
+ ...(bot.defaultBot ? [<HideDefaultBotItem key="hide" bot={bot} onDone={onClose} className={MENU_ITEM} />] : member ? ownDelete() : [
item(<Archive size={16} className="text-ink-secondary" />, t("sidebar.bot.archive"), () => onArchive(bot), { disabled: archiveBlocked, hint: archiveHint }),
<BotDeleteMenuItem key="delete" deleting={deleting} className={MENU_ITEM} onClick={() => { onClose(); onDelete(bot); }} />,
]),
diff --git a/src/components/TeamSideSwitch.tsx b/src/components/TeamSideSwitch.tsx
index 2a2b111384..fe5635e2c4 100644
--- a/src/components/TeamSideSwitch.tsx
+++ b/src/components/TeamSideSwitch.tsx
@@ -5,7 +5,7 @@ import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
import { useShowThreads } from "@/lib/thread-preferences";
import { openBot, useStore, type AppState, type Bot, type Group } from "@/state/store";
-import { setTeamSide, showTeamSide, sideOfThread, teamSide, teamSideView, useTeamSide, type TeamSide } from "@/state/team-side";
+import { listedSide, setTeamSide, showTeamSide, sideOfThread, teamSide, teamSideView, useTeamSide, type TeamSide } from "@/state/team-side";
import { markTeamPrivateChatsLineSaid, sharedChatAudience } from "./TeamPrivateChatsLine";
const SIDES = [{ side: "me", label: "teamSide.me", Icon: Lock }, { side: "team", label: "teamSide.team", Icon: Users }] as const;
@@ -29,11 +29,11 @@ export function useTeamSideLists(state: Pick<AppState, "bots" | "groups" | "conf
return last.current.view;
}
-/** The side of the conversation a bot has on screen, on a team's Cloud; null anywhere else. */
+/** The side the conversation a bot has on screen is listed on, on a team's Cloud; null anywhere else. */
export function useConversationSide(bot: Bot): TeamSide | null {
const { state } = useStore();
const { team } = useTeamSide();
- return state.config?.team && team ? sideOfThread(bot, bot.threadId) : null;
+ return state.config?.team && team ? listedSide(bot, bot.threadId) : null;
}
function hintDue(teamId: string): boolean {
@@ -126,7 +126,8 @@ export function TeamAudienceLabel({ bot, group }: { bot?: Bot; group?: Group })
const { team } = useTeamSide();
noteStart(state, team);
const teamName = state.config?.team?.name;
- const side: TeamSide | null = !team || !teamName ? null : group ? "team" : bot ? sideOfThread(bot, bot.threadId) : null;
+ const readers: TeamSide | null = !team || !teamName ? null : group ? "team" : bot ? sideOfThread(bot, bot.threadId) : null;
+ const side: TeamSide | null = readers && bot && !group ? listedSide(bot, bot.threadId) : readers;
const shown = group?.threadId ?? bot?.threadId;
const person = team?.person;
useEffect(() => {
@@ -148,12 +149,12 @@ export function TeamAudienceLabel({ bot, group }: { bot?: Bot; group?: Group })
if (landing) openBot(dispatch, landing, showThreads);
else showTeamSide(side, team);
}, [team?.teamId, person, shown, side, bot?.switchingTo]);
- if (!side || !teamName) return null;
- const Icon = side === "me" ? Lock : Users;
+ if (!readers || !teamName) return null;
+ const Icon = readers === "me" ? Lock : Users;
const sharedWith = bot?.tasks?.find((task) => task.threadId === bot.threadId)?.sharedWith?.name;
- const label = side === "me" ? t("team.privateHeader") : group ? t("teamSide.groupAudience") : sharedChatAudience(teamName, bot?.onlyPeopleAdded, sharedWith);
+ const label = readers === "me" ? t("team.privateHeader") : group ? t("teamSide.groupAudience") : sharedChatAudience(teamName, bot?.onlyPeopleAdded, sharedWith);
return (
- <div role="note" data-team-audience={side} className="relative z-[1] flex items-center gap-1 px-2 pb-1 text-[12px] leading-4 text-ink-secondary">
+ <div role="note" data-team-audience={readers} className="relative z-[1] flex items-center gap-1 px-2 pb-1 text-[12px] leading-4 text-ink-secondary">
<Icon size={12} aria-hidden="true" className="shrink-0" /><span className="truncate">{label}</span>
</div>
);
diff --git a/src/components/bot-access/AccessOverview.tsx b/src/components/bot-access/AccessOverview.tsx
index 1e66387b0c..d277abd7e2 100644
--- a/src/components/bot-access/AccessOverview.tsx
+++ b/src/components/bot-access/AccessOverview.tsx
@@ -9,15 +9,14 @@ import { useStore, type Bot } from "@/state/store";
import { ownerOf, useTeamPeople, type TeamPeople, type TeamPerson } from "@/state/team-people";
import { BotAvatar } from "../Avatar";
import { PersonFace } from "../TeamOwner";
-import { accessOfBot, nameOf, personOf, saveAccess, withPerson } from "./access";
+import { accessOfBot, saveAccess, withPerson } from "./access";
import { UndoToast, useTeamName } from "./ShareBotButton";
import { ShareBotDialog } from "./ShareBotDialog";
-import { EntryFace } from "./ShareControls";
+import { PeopleStack } from "./PeopleStack";
type Change = { botId: string; before: BotAccess; after: BotAccess; text: string };
type Listing = "bot" | "person";
-const STACK_SHOWN = 4;
const ROW = "flex w-full min-w-0 items-center gap-3 px-3 py-2 text-start";
const LIST = "flex flex-col divide-y divide-hairline/30 overflow-hidden rounded-xl border border-hairline/40 bg-card";
@@ -137,20 +136,6 @@ function BotList({ bots, anyBots, team, onOpen }: { bots: Bot[]; anyBots: boolea
);
}
-function PeopleStack({ entries, team }: { entries: string[]; team: TeamPeople }) {
- if (!entries.length) return null;
- const names = entries.map((entry) => nameOf(entry, team)).join(", ");
- const beyond = entries.length - STACK_SHOWN;
- return (
- <span role="img" aria-label={names} title={names} data-access-stack={entries.length} className="flex shrink-0 -space-x-0.5 rtl:space-x-reverse">
- {entries.slice(0, STACK_SHOWN).map((entry) => (
- <span key={entry} className="flex rounded-full ring-2 ring-card"><EntryFace person={personOf(entry, team)} size={22} /></span>
- ))}
- {beyond > 0 && <span className="flex h-[22px] min-w-[22px] items-center justify-center rounded-full bg-card px-1 text-[11px] font-medium text-ink-secondary ring-2 ring-card">+{beyond}</span>}
- </span>
- );
-}
-
function PeopleList({ people, anyPeople, bots, onOpen }: { people: TeamPerson[]; anyPeople: boolean; bots: Bot[]; onOpen: (email: string) => void }) {
if (!anyPeople) return <p className="text-[13px] text-ink-secondary">{t("botAccess.overview.noPeople")}</p>;
if (!people.length) return <p className="text-[13px] text-ink-secondary">{t("botAccess.noMatch")}</p>;
diff --git a/src/components/bot-access/HeaderShare.dom.test.ts b/src/components/bot-access/HeaderShare.dom.test.ts
new file mode 100644
index 0000000000..eec44c4bc9
--- /dev/null
+++ b/src/components/bot-access/HeaderShare.dom.test.ts
@@ -0,0 +1,110 @@
+// @vitest-environment happy-dom
+// Who a team bot is shared with, at the top right of its chat header beside Share: the faces of the people added for
+// someone who can edit it, one "Everyone in Acme" mark when everyone can use it, nothing for a bot only its owner uses,
+// and for someone who can only chat never more than the server sent them. Each mark opens the Share dialog.
+import { createElement } from "react";
+import { flushSync } from "react-dom";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, expect, it, vi } from "vitest";
+import type { Bot } from "@/state/store";
+
+const server = vi.hoisted(() => ({ team: true }));
+vi.mock("@/state/store", async (importOriginal) => ({
+ ...await importOriginal<typeof import("@/state/store")>(),
+ api: vi.fn(async () => ({ bot: {} })),
+ useStore: () => ({ state: { config: server.team ? { team: { id: "team-acme", name: "Acme" } } : {} }, dispatch: vi.fn() }),
+}));
+
+const { setTeamPeople } = await import("@/state/team-people");
+const { HeaderShare, sharedWith } = await import("./HeaderShare");
+
+const RUI = { email: "[email protected]", name: "Rui", role: "admin" };
+const MEMBERS = ["Marta", "Bob", "Cara", "Dan", "Eve"].map((name) => ({ email: `${name.toLowerCase()}@acme.test`, name, role: "member" }));
+const [MARTA, BOB, CARA, DAN, EVE] = MEMBERS as [typeof RUI, typeof RUI, typeof RUI, typeof RUI, typeof RUI];
+const quotes = (fields: Partial<Bot>): Bot => ({
+ id: "quotes", threadId: "t-main", name: "Quotes", title: "", description: "", notifications: true, color: "teal", unread: false,
+ modelSelection: { instanceId: "claude", model: "claude-opus-5-5" }, messages: [], createdBy: RUI.email, ...fields,
+});
+const only = (...people: Array<{ email: string }>) => ({ everyone: "none" as const, people: Object.fromEntries(people.map((person) => [person.email, "chat" as const])) });
+
+let host: HTMLDivElement;
+let root: Root;
+const settle = async () => { for (let i = 0; i < 4; i++) await new Promise((resolve) => setTimeout(resolve, 0)); };
+const render = (bot: Bot) => flushSync(() => root.render(createElement(HeaderShare, { bot })));
+const wide = () => host.querySelector<HTMLElement>("[data-access-stack]");
+const faces = () => [...(wide()?.querySelectorAll<HTMLButtonElement>("[data-access-face]") ?? [])];
+const marker = () => host.querySelector<HTMLButtonElement>("[data-shared-with-marker]");
+const dialog = () => document.querySelector<HTMLElement>("[data-share-bot]");
+
+beforeEach(() => {
+ server.team = true;
+ setTeamPeople({ people: [{ ...RUI, you: true }, ...MEMBERS], me: { ...RUI, you: true }, admin: true, needsYou: [] });
+ host = document.createElement("div");
+ document.body.append(host);
+ root = createRoot(host);
+});
+afterEach(() => {
+ flushSync(() => root.unmount());
+ host.remove();
+ document.body.innerHTML = "";
+ setTeamPeople(null);
+});
+
+it("a bot only its owner uses shows Share and nobody", () => {
+ render(quotes({ yourAccess: "edit", access: only() }));
+ expect(host.querySelector("[data-header-share]")?.getAttribute("data-header-share")).toBe("private");
+ expect(wide()).toBeNull();
+ expect(marker()).toBeNull();
+ expect(host.querySelector("[data-share-bot-button]")).not.toBeNull();
+ render(quotes({ yourAccess: "edit", access: only(RUI) }));
+ expect(wide(), "its owner is not someone it is shared with").toBeNull();
+});
+
+it("shared with people: their faces, each named, a few and then +N; any of them opens Share", async () => {
+ render(quotes({ yourAccess: "edit", access: only(MARTA) }));
+ expect(faces().map((face) => [face.title, face.getAttribute("aria-label")])).toEqual([["Marta", "Marta"]]);
+ expect(wide()!.querySelector("[data-access-more]")).toBeNull();
+
+ render(quotes({ yourAccess: "edit", access: only(MARTA, BOB, CARA, DAN, EVE) }));
+ expect(faces().map((face) => face.title)).toEqual(["Marta", "Bob", "Cara"]);
+ const more = wide()!.querySelector<HTMLButtonElement>("[data-access-more]")!;
+ expect(more.textContent).toBe("+2");
+ expect(more.title, "the rest are named there").toBe("Dan, Eve");
+ expect(wide()!.getAttribute("aria-label")).toBe("Marta, Bob, Cara, Dan, Eve");
+ const narrow = host.querySelectorAll<HTMLElement>("[data-access-stack]")[1]!;
+ expect(narrow.textContent, "a narrow header folds them into one count").toBe("+5");
+ expect(narrow.querySelector("[data-access-face]")).toBeNull();
+
+ expect(dialog()).toBeNull();
+ faces()[1]!.click();
+ await settle();
+ expect(dialog()?.getAttribute("data-share-bot")).toBe("quotes");
+});
+
+it("shared with everyone: one mark that says so, never faces", async () => {
+ render(quotes({ yourAccess: "edit", access: { everyone: "chat", people: { [MARTA.email]: "edit" } } }));
+ expect(wide()).toBeNull();
+ expect([marker()!.title, marker()!.getAttribute("aria-label"), marker()!.dataset.sharedWithMarker]).toEqual(["Everyone in Acme", "Everyone in Acme", "everyone"]);
+ marker()!.click();
+ await settle();
+ expect(dialog()).not.toBeNull();
+});
+
+it("someone who can only chat or view sees that it is shared, never who with", () => {
+ const sent = { yourAccess: "chat" as const, createdBy: RUI.email };
+ render(quotes({ ...sent, onlyPeopleAdded: true }));
+ expect(wide()).toBeNull();
+ expect([marker()!.title, marker()!.dataset.sharedWithMarker]).toEqual(["Only people added", "added"]);
+ expect(host.textContent).not.toContain("Marta");
+ render(quotes({ ...sent }));
+ expect(marker()!.title).toBe("Everyone in Acme");
+ expect(sharedWith({ yourAccess: "view", onlyPeopleAdded: true, access: only(MARTA, BOB) } as never), "even a list that should never have been sent is not read").toEqual({ kind: "added" });
+});
+
+it("shows nothing off a team or on a person's own MausBot", () => {
+ render(quotes({ yourAccess: "edit", access: only(MARTA), defaultBot: { person: RUI.email } }));
+ expect(host.innerHTML).toBe("");
+ server.team = false;
+ render(quotes({ yourAccess: "edit", access: only(MARTA) }));
+ expect(host.innerHTML).toBe("");
+});
diff --git a/src/components/bot-access/HeaderShare.tsx b/src/components/bot-access/HeaderShare.tsx
new file mode 100644
index 0000000000..704bbec42c
--- /dev/null
+++ b/src/components/bot-access/HeaderShare.tsx
@@ -0,0 +1,59 @@
+import { Users } from "lucide-react";
+
+import { botOwner } from "../../../shared/bot-owner";
+import { cn } from "@/lib/cn";
+import { t } from "@/lib/i18n";
+import type { Bot } from "@/state/store";
+import { useTeamPeople } from "@/state/team-people";
+import { ELEVATED_FLOAT, ELEVATED_HOVER } from "../elevated";
+import { accessOfBot, canShare } from "./access";
+import { PeopleStack } from "./PeopleStack";
+import { ShareBotButton, useTeamName } from "./ShareBotButton";
+
+const FACE = 24;
+const FACES = 3;
+
+/** Who a team bot is shared with, as far as this person's copy of it says: the people added (only someone who can
+ * edit the bot is sent them), everyone in the team, only people added (to someone added, who is told no more), or
+ * nobody. */
+export type SharedWith = { kind: "people"; entries: string[] } | { kind: "everyone" } | { kind: "added" } | null;
+
+export function sharedWith(bot: Pick<Bot, "access" | "visibility" | "yourAccess" | "onlyPeopleAdded" | "createdBy" | "reportsTo" | "defaultBot">): SharedWith {
+ if (bot.defaultBot?.person) return null;
+ if (!canShare(bot)) return bot.yourAccess === "view" || bot.yourAccess === "chat" ? (bot.onlyPeopleAdded ? { kind: "added" } : { kind: "everyone" }) : null;
+ const access = accessOfBot(bot);
+ if (access.everyone !== "none") return { kind: "everyone" };
+ const owner = botOwner(bot);
+ const entries = Object.keys(access.people).filter((entry) => entry !== owner);
+ return entries.length ? { kind: "people", entries } : null;
+}
+
+const FOCUS = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus";
+const NARROW_ONLY = "hidden @max-[30rem]/chathead:flex";
+const WIDE_ONLY = "flex @max-[30rem]/chathead:hidden";
+
+/** At the top right of a team bot's chat header: who it is shared with, then Share. Each mark opens the Share dialog.
+ * On a narrow header the faces fold into one count and that mark stands in for Share, so the bot's name keeps its room. */
+export function HeaderShare({ bot }: { bot: Bot }) {
+ const teamName = useTeamName();
+ const team = useTeamPeople();
+ if (!teamName || bot.defaultBot?.person) return null;
+ const shared = sharedWith(bot);
+ const marker = (label: string, tone: string, open: () => void) => (
+ <button type="button" aria-haspopup="dialog" data-shared-with-marker={shared?.kind} title={label} aria-label={label} onClick={open}
+ className={cn("inline-flex shrink-0 items-center justify-center rounded-full", tone, FOCUS)} style={{ width: FACE, height: FACE }}>
+ <Users size={13} aria-hidden="true" />
+ </button>
+ );
+ return (
+ <span data-header-share={shared?.kind ?? "private"} className="flex shrink-0 items-center gap-1.5">
+ <ShareBotButton bot={bot} className={cn("size-8 items-center justify-center rounded-full text-ink-secondary hover:text-ink", ELEVATED_FLOAT, ELEVATED_HOVER, shared ? WIDE_ONLY : "flex")}
+ leading={(open) => shared?.kind === "everyone" ? marker(t("teamSettings.everyone", { team: teamName }), "bg-accent/15 text-accent", open)
+ : shared?.kind === "added" ? marker(t("botAccess.onlyAdded"), "bg-ink/[0.08] text-ink-secondary", open)
+ : shared?.kind === "people" ? <>
+ <span className={WIDE_ONLY}><PeopleStack entries={shared.entries} team={team} size={FACE} shown={FACES} ring="ring-app" overlap="-space-x-1.5" onOpen={open} /></span>
+ <span className={NARROW_ONLY}><PeopleStack entries={shared.entries} team={team} size={FACE} shown={shared.entries.length === 1 ? 1 : 0} ring="ring-app" onOpen={open} /></span>
+ </> : null} />
+ </span>
+ );
+}
diff --git a/src/components/bot-access/PeopleStack.tsx b/src/components/bot-access/PeopleStack.tsx
new file mode 100644
index 0000000000..fe3e43525e
--- /dev/null
+++ b/src/components/bot-access/PeopleStack.tsx
@@ -0,0 +1,39 @@
+import { cn } from "@/lib/cn";
+import type { TeamPeople } from "@/state/team-people";
+import { nameOf, personOf } from "./access";
+import { EntryFace } from "./ShareControls";
+
+const STACK_SHOWN = 4;
+
+/** The faces of the people a bot is shared with, a few and then "+N". With `onOpen` each face is a button that says
+ * that person's name and opens what the stack is about; without it the stack is one picture named for them all. */
+export function PeopleStack({ entries, team, size = 22, shown = STACK_SHOWN, ring = "ring-card", overlap = "-space-x-0.5", onOpen }: {
+ entries: string[]; team: Pick<TeamPeople, "people"> | null; size?: number; shown?: number; ring?: string; overlap?: string; onOpen?: () => void;
+}) {
+ if (!entries.length) return null;
+ const names = (of: string[]) => of.map((entry) => nameOf(entry, team)).join(", ");
+ const rest = entries.slice(shown);
+ const more = cn("flex items-center justify-center rounded-full bg-card px-1 text-[11px] font-medium tabular-nums text-ink-secondary ring-2", ring);
+ const box = { height: size, minWidth: size };
+ if (!onOpen) {
+ return (
+ <span role="img" aria-label={names(entries)} title={names(entries)} data-access-stack={entries.length} className={cn("flex shrink-0 rtl:space-x-reverse", overlap)}>
+ {entries.slice(0, shown).map((entry) => (
+ <span key={entry} className={cn("flex rounded-full ring-2", ring)}><EntryFace person={personOf(entry, team)} size={size} /></span>
+ ))}
+ {rest.length > 0 && <span style={box} className={more}>+{rest.length}</span>}
+ </span>
+ );
+ }
+ const face = "rounded-full focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus";
+ return (
+ <span role="group" aria-label={names(entries)} data-access-stack={entries.length} className={cn("flex shrink-0 rtl:space-x-reverse", overlap)}>
+ {entries.slice(0, shown).map((entry) => (
+ <button key={entry} type="button" aria-haspopup="dialog" data-access-face={entry} title={nameOf(entry, team)} aria-label={nameOf(entry, team)} onClick={onOpen}
+ className={cn("flex ring-2", ring, face)}><EntryFace person={personOf(entry, team)} size={size} /></button>
+ ))}
+ {rest.length > 0 && <button type="button" aria-haspopup="dialog" data-access-more={rest.length} title={names(rest)} aria-label={names(rest)} onClick={onOpen}
+ style={box} className={cn(more, face)}>+{rest.length}</button>}
+ </span>
+ );
+}
diff --git a/src/components/bot-access/ShareBotButton.tsx b/src/components/bot-access/ShareBotButton.tsx
index d2b6de561e..4528dd9e16 100644
--- a/src/components/bot-access/ShareBotButton.tsx
+++ b/src/components/bot-access/ShareBotButton.tsx
@@ -16,8 +16,11 @@ export function useTeamName(): string | null {
return typeof team?.name === "string" && team.name ? team.name : null;
}
-/** A bot's Share button on a team: opens who has access. `headerMenu` holds what else the button offers there. */
-export function ShareBotButton({ bot, className, headerMenu, iconSize = 16 }: { bot: Bot; className: string; headerMenu?: ReactNode; iconSize?: number }) {
+/** A bot's Share button on a team: opens who has access. `headerMenu` holds what else the button offers there, and
+ * `leading` what sits before the button and opens the same dialog. */
+export function ShareBotButton({ bot, className, headerMenu, iconSize = 16, leading }: {
+ bot: Bot; className: string; headerMenu?: ReactNode; iconSize?: number; leading?: (open: () => void) => ReactNode;
+}) {
const teamName = useTeamName();
const [open, setOpen] = useState(false);
const [change, setChange] = useState<AccessChange | null>(null);
@@ -25,6 +28,7 @@ export function ShareBotButton({ bot, className, headerMenu, iconSize = 16 }: {
if (!teamName) return null;
return (
<>
+ {leading?.(() => setOpen(true))}
<button type="button" data-panel-share data-share-bot-button aria-label={t("botAccess.share")} title={t("botAccess.share")}
aria-haspopup="dialog" onClick={() => setOpen(true)} className={className}>
<Share size={iconSize} aria-hidden="true" className="pointer-events-none" />
diff --git a/src/components/cloud-welcome/WelcomeBring.test.ts b/src/components/cloud-welcome/WelcomeBring.test.ts
index e729f62d3b..9039506150 100644
--- a/src/components/cloud-welcome/WelcomeBring.test.ts
+++ b/src/components/cloud-welcome/WelcomeBring.test.ts
@@ -25,7 +25,7 @@ describe("an empty Cloud opened in a browser", () => {
describe("the first setup step's promise", () => {
it("on a Team Cloud, never says the bots on this computer come here by themselves", () => {
const html = bring(true);
- expect(html).toContain("Acme is your team’s: its bots are shared with everyone in Acme, and your own bots stay where they are.");
+ expect(html).toContain("Acme is your team’s: a bot you make or bring here is yours until you share it, and your own bots stay where they are.");
expect(html).not.toContain("come here by themselves");
});
diff --git a/src/components/cloud-welcome/WelcomeBring.tsx b/src/components/cloud-welcome/WelcomeBring.tsx
index 2e2f0a62cc..4cf44b5bc8 100644
--- a/src/components/cloud-welcome/WelcomeBring.tsx
+++ b/src/components/cloud-welcome/WelcomeBring.tsx
@@ -67,7 +67,7 @@ export function WelcomeBring({ name, desktop, older = false, cloudHasWork, sent
</>
: <button type="button" className={PRIMARY} onClick={() => onFinish("skipped")}>{t("onboarding.continue")}</button>;
return <section aria-labelledby="cloud-welcome-step" data-welcome-step="bring" className="flex flex-col gap-5">
- <StepHeading headingRef={headingRef} title={t("cloudWelcome.bring.title", { name })} sub={t(team ? "cloudWelcome.bring.subTeamShared" : "cloudWelcome.bring.sub", { name })} />
+ <StepHeading headingRef={headingRef} title={t("cloudWelcome.bring.title", { name })} sub={t(team ? "cloudWelcome.bring.subTeamYours" : "cloudWelcome.bring.sub", { name })} />
{older && <p role="note" data-bring-update className="text-[13px] leading-relaxed text-ink">{t("cloudWelcome.bring.update")}</p>}
{team && desktop && <BringMyCloud />}
{cloudHasWork
diff --git a/src/lib/bot-duplicate.test.ts b/src/lib/bot-duplicate.test.ts
index 315a7f3496..2dcc6f465d 100644
--- a/src/lib/bot-duplicate.test.ts
+++ b/src/lib/bot-duplicate.test.ts
@@ -46,4 +46,13 @@ describe("what a duplicated bot is created with", () => {
const { vpsAlias: _alias, ...onDefault } = source;
expect(duplicateBotProfile(onDefault as Bot).vpsAlias).toBeUndefined();
});
+
+ it("a team's User gives a copy only who it is and how it looks: nothing an admin alone sets", () => {
+ const source = { name: "Quotes", title: "Prices", description: "d", soul: "s", notifications: true, modelSelection: { instanceId: "claude", model: "m" },
+ computer: "cloud", cloudBackend: "vps", autoStartVps: true, vpsAlias: "box", avatarUrl: "/a.png", visibility: { people: ["[email protected]"] }, toolScope: { allow: [] }, helperModel: false } as unknown as Bot;
+ expect(restrictedCopyRequest(source, true)).toEqual({});
+ expect(Object.keys(duplicateBotProfile(source, true)).sort()).toEqual(["avatarCrop", "avatarFocusX", "avatarFocusY", "avatarUrl", "avatarZoom", "description", "modelSelection", "name", "notifications", "soul", "title"]);
+ expect(duplicateBotProfile(source, true).name).toBe("Quotes copy");
+ expect(Object.keys(duplicateBotProfile(source, false))).toEqual(expect.arrayContaining(["computer", "cloudBackend", "autoStartVps", "vpsAlias"]));
+ });
});
diff --git a/src/lib/bot-duplicate.ts b/src/lib/bot-duplicate.ts
index 62d20745bc..dec5a9d5ec 100644
--- a/src/lib/bot-duplicate.ts
+++ b/src/lib/bot-duplicate.ts
@@ -1,6 +1,7 @@
// A copy's restrictions go in the request that creates it: a later patch that failed would leave it unrestricted.
import { helperModelAllowed } from "../../shared/wire";
import type { Bot } from "@/state/store";
+import { currentTeamPeople } from "@/state/team-people";
export type RestrictedSource = Pick<Bot, "visibility" | "toolScope" | "helperModel">;
@@ -9,7 +10,11 @@ export interface RestrictedCopyRequest {
settings?: { toolScope?: Bot["toolScope"]; helperModel?: false };
}
-export function restrictedCopyRequest(source: RestrictedSource): RestrictedCopyRequest {
+/** A team's User, who gives a copy only what someone who can edit a bot may set: the server refuses the rest. */
+const teamUser = () => currentTeamPeople()?.admin === false;
+
+export function restrictedCopyRequest(source: RestrictedSource, user = teamUser()): RestrictedCopyRequest {
+ if (user) return {};
const settings: NonNullable<RestrictedCopyRequest["settings"]> = {
...(Object.hasOwn(source, "toolScope") ? { toolScope: source.toolScope } : {}),
...(helperModelAllowed(source) ? {} : { helperModel: false as const }),
@@ -21,7 +26,7 @@ export function restrictedCopyRequest(source: RestrictedSource): RestrictedCopyR
}
/** What a copy takes from its source, PATCHed onto the new bot in one request. A copy of a VPS bot keeps its server. */
-export function duplicateBotProfile(source: Bot) {
+export function duplicateBotProfile(source: Bot, user = teamUser()) {
return {
name: `${source.name} copy`,
title: source.title,
@@ -29,10 +34,7 @@ export function duplicateBotProfile(source: Bot) {
soul: source.soul,
notifications: source.notifications,
modelSelection: source.modelSelection,
- computer: source.computer,
- cloudBackend: source.cloudBackend,
- autoStartVps: source.autoStartVps,
- vpsAlias: source.vpsAlias,
+ ...(user ? {} : { computer: source.computer, cloudBackend: source.cloudBackend, autoStartVps: source.autoStartVps, vpsAlias: source.vpsAlias }),
avatarUrl: source.avatarUrl,
avatarCrop: source.avatarCrop,
avatarZoom: source.avatarZoom,
diff --git a/src/lib/connect-link.test.ts b/src/lib/connect-link.test.ts
index e76d5030f0..2696a169f1 100644
--- a/src/lib/connect-link.test.ts
+++ b/src/lib/connect-link.test.ts
@@ -9,10 +9,11 @@ it("a bot's connect link opens the page that connects it and leaves the address
expect(takeConnectRequest("https://omb-u-1.fly.dev/?x=1")).toBeNull();
});
-it("a Team admin link from the Admin opens a Team Cloud's apps, MCP servers, keys or engines", () => {
+it("a Team admin link from the Admin opens a Team Cloud's apps, MCP servers, keys, engines or Bot access", () => {
expect(takeConnectRequest("https://omb-t-1.fly.dev/?connect=apps")).toEqual({ rest: "/", surface: "apps" });
expect(takeConnectRequest("https://omb-t-1.fly.dev/?connect=mcp")).toEqual({ rest: "/", surface: "mcp" });
expect(takeConnectRequest("https://omb-t-1.fly.dev/?connect=keys")).toEqual({ rest: "/", section: "connections" });
expect(takeConnectRequest("https://omb-t-1.fly.dev/?connect=ai")).toEqual({ rest: "/", section: "engines" });
+ expect(takeConnectRequest("https://omb-t-1.fly.dev/?connect=bots&x=1")).toEqual({ rest: "/?x=1", teamAdminSection: "botAccess" });
expect(takeConnectRequest("https://omb-t-1.fly.dev/?connect=mcp%3ABad%20Name")).toEqual({ rest: "/", surface: "apps" });
});
diff --git a/src/lib/connect-link.ts b/src/lib/connect-link.ts
index 224efe1b0d..a67286213e 100644
--- a/src/lib/connect-link.ts
+++ b/src/lib/connect-link.ts
@@ -1,13 +1,15 @@
/** A bot on My Cloud links to `/?connect=<id>` for a connection that needs the person there: an MCP server's sign-in
* opens the MCP servers, where its Sign in is; any other id opens the apps. The Admin's Team admin pages link a team's
- * admins to `/?connect=mcp`, `keys` (the keys in Settings) or `ai` (the engines in Settings). It only opens the page; it
- * never signs in by itself. Null for any other address. */
-export function takeConnectRequest(href: string): ({ rest: string } & ({ surface: "mcp" | "apps" } | { section: "connections" | "engines" })) | null {
+ * admins to `/?connect=mcp`, `keys` (the keys in Settings), `ai` (the engines in Settings) or `bots` (Bot access in
+ * Settings, which only a team's admin is shown). It only opens the page; it never signs in by itself. Null for any
+ * other address. */
+export function takeConnectRequest(href: string): ({ rest: string } & ({ surface: "mcp" | "apps" } | { section: "connections" | "engines" } | { teamAdminSection: "botAccess" })) | null {
const url = new URL(href);
const id = url.searchParams.get("connect");
if (id === null) return null;
url.searchParams.delete("connect");
const rest = `${url.pathname}${url.search}${url.hash}`;
+ if (id === "bots") return { rest, teamAdminSection: "botAccess" };
if (id === "keys" || id === "ai") return { rest, section: id === "keys" ? "connections" : "engines" };
return { rest, surface: /^mcp(?::[a-z][a-z0-9_-]{0,31})?$/u.test(id) ? "mcp" : "apps" };
}
diff --git a/src/lib/new-bot.test.ts b/src/lib/new-bot.test.ts
index 727f74328c..6ea221b1b5 100644
--- a/src/lib/new-bot.test.ts
+++ b/src/lib/new-bot.test.ts
@@ -72,11 +72,12 @@ describe("New bot", () => {
expect(botLimitReason()).toBeNull();
});
- it("makes nothing for a User on a team, however it was asked for", async () => {
+ it("makes a User's own bot on a team with one bare request: no defaults read, no department, nobody named to look after it", async () => {
setTeamPeople({ ...team, admin: false });
const { calls, request } = server();
- expect(await newBot(request)).toEqual([]);
- expect(calls).toEqual([]);
+ const sent = await newBot(request, { section: "Sales" });
+ expect(calls).toEqual([{ method: "POST", path: "/api/bots", body: {} }]);
+ expect(sent[0]).toMatchObject({ type: "botAdded", bot: { id: "created" } });
});
it("makes a bot at once from the New bot defaults and opens its chat", async () => {
diff --git a/src/lib/new-bot.ts b/src/lib/new-bot.ts
index b7dc7c1ece..723d98d150 100644
--- a/src/lib/new-bot.ts
+++ b/src/lib/new-bot.ts
@@ -51,10 +51,15 @@ let nameAsker: (() => Promise<string | null>) | null = null;
/** Where New bot asks for the bot's name on a team (the dialog mounted with the app); null takes it away. */
export function setNewBotNameAsker(ask: (() => Promise<string | null>) | null): void { nameAsker = ask; }
-/** A paired device may not read the host's New bot defaults: the host applies them to an empty request. Auto on this
- * computer needs the person's own OK, so a bot whose defaults ask for it starts on Ask. `name`: the person's own choice,
- * in place of a suggested one. */
+/** A team's User makes a bot of their own, which takes the server's own defaults: its department, whom it answers to
+ * and what it may do are an admin's. A paired device may not read the host's New bot defaults: the host applies them to
+ * an empty request. Auto on this computer needs the person's own OK, so a bot whose defaults ask for it starts on Ask.
+ * `name`: the person's own choice, in place of a suggested one. */
async function createNewBot(section: string | undefined, bots: readonly Bot[], team: TeamPeople | null, request: typeof api, name?: string) {
+ if (team?.admin === false) {
+ const { bot, paused } = await request<{ bot: Bot; paused?: true }>("/api/bots", { method: "POST", body: JSON.stringify(name ? { name } : {}) });
+ return { bot, warnings: [] as string[], startsOnAsk: false, ...(paused ? { paused } : {}) };
+ }
if (typeof window !== "undefined" && window.ogb?.remoteClient?.active) {
const { bot, paused } = await request<{ bot: Bot; paused?: true }>("/api/bots", { method: "POST", body: JSON.stringify({ ...(section === undefined ? {} : { section }), ...(name ? { name } : {}) }) });
return { bot, warnings: [] as string[], startsOnAsk: false, ...(paused ? { paused } : {}) };
@@ -78,7 +83,6 @@ async function createNewBot(section: string | undefined, bots: readonly Bot[], t
export async function makeNewBot(action: Extract<Action, { type: "newBot" }>, bots: readonly Bot[], dispatch: (action: Action) => void,
showThreads: boolean, request: typeof api = api): Promise<void> {
const team = currentTeamPeople();
- if (team?.admin === false) return;
let name: string | undefined;
if (team && nameAsker) {
dispatch({ type: "botCreationPending", on: false });
diff --git a/src/lib/own-team-bot.test.ts b/src/lib/own-team-bot.test.ts
new file mode 100644
index 0000000000..ccab71d668
--- /dev/null
+++ b/src/lib/own-team-bot.test.ts
@@ -0,0 +1,25 @@
+import { describe, expect, it } from "vitest";
+
+import { userBotMenu } from "./own-team-bot";
+
+const RUI = "[email protected]", MARTA = "[email protected]";
+const PRIVATE = { everyone: "none" as const, people: {} };
+
+describe("a team User's bot menu", () => {
+ it("offers Delete for a bot they look after while nobody else can use it", () => {
+ expect(userBotMenu({ createdBy: RUI, yourAccess: "edit", access: PRIVATE }, RUI)).toEqual({ duplicate: true, delete: "own" });
+ });
+
+ it("shows Delete with the reason once the bot is shared: that is an admin's", () => {
+ expect(userBotMenu({ createdBy: RUI, yourAccess: "edit", access: { everyone: "none", people: { [MARTA]: "chat" } } }, RUI).delete).toBe("shared");
+ expect(userBotMenu({ createdBy: RUI, yourAccess: "edit", access: { everyone: "chat", people: {} } }, RUI).delete).toBe("shared");
+ });
+
+ it("offers no Delete for anyone else's bot, and a copy only of one they can edit", () => {
+ expect(userBotMenu({ createdBy: MARTA, yourAccess: "edit", access: { everyone: "none", people: { [RUI]: "edit" } } }, RUI)).toEqual({ duplicate: true, delete: null });
+ expect(userBotMenu({ createdBy: MARTA, yourAccess: "chat" }, RUI)).toEqual({ duplicate: false, delete: null });
+ expect(userBotMenu({ createdBy: RUI, reportsTo: MARTA, yourAccess: "edit", access: { everyone: "none", people: { [RUI]: "edit" } } }, RUI).delete, "handed on").toBeNull();
+ expect(userBotMenu({ createdBy: RUI, yourAccess: "edit", access: PRIVATE }, undefined).delete).toBeNull();
+ expect(userBotMenu({ defaultBot: { person: RUI }, yourAccess: "edit" }, RUI), "their own MausBot is neither copied nor deleted").toEqual({ duplicate: false, delete: null });
+ });
+});
diff --git a/src/lib/own-team-bot.ts b/src/lib/own-team-bot.ts
new file mode 100644
index 0000000000..c388a48d26
--- /dev/null
+++ b/src/lib/own-team-bot.ts
@@ -0,0 +1,13 @@
+import { botOwner } from "../../shared/bot-owner";
+import type { Bot } from "@/state/store";
+import { sharedWithOthers } from "@/state/team-side";
+
+type MenuBot = Pick<Bot, "yourAccess" | "access" | "visibility" | "createdBy" | "reportsTo" | "defaultBot">;
+
+/** What a team's User is offered in a bot's menu beyond chatting: a copy of a bot they can edit, and Delete for a bot
+ * they look after, which is an admin's once the bot is shared ("shared": shown, with why it can't be done). The server
+ * holds the same rule. */
+export function userBotMenu(bot: MenuBot, me: string | undefined): { duplicate: boolean; delete: "own" | "shared" | null } {
+ const mine = Boolean(me) && !bot.defaultBot && botOwner(bot) === me;
+ return { duplicate: bot.yourAccess === "edit" && !bot.defaultBot, delete: !mine ? null : sharedWithOthers(bot) ? "shared" : "own" };
+}
diff --git a/src/lib/use-connect-link.ts b/src/lib/use-connect-link.ts
new file mode 100644
index 0000000000..22da4470eb
--- /dev/null
+++ b/src/lib/use-connect-link.ts
@@ -0,0 +1,24 @@
+import { useEffect, useState } from "react";
+
+import type { Action } from "@/state/store";
+import { takeConnectRequest } from "./connect-link";
+import { useOwnerOrAdmin } from "./use-owner-or-admin";
+
+/** Opens the page a `/?connect=` link asks for, once, and leaves the address clean. A page only a team's admin is
+ * shown opens when this person is known to be one, and never for anyone else. */
+export function useConnectLink(dispatch: (action: Action) => void, team: boolean): void {
+ const admin = useOwnerOrAdmin();
+ const [adminSection, setAdminSection] = useState<"botAccess" | null>(null);
+ useEffect(() => {
+ const request = takeConnectRequest(window.location.href);
+ if (!request) return;
+ window.history.replaceState(null, "", request.rest);
+ if ("teamAdminSection" in request) setAdminSection(request.teamAdminSection);
+ else dispatch("section" in request ? { type: "toggleAppSettings", open: true, section: request.section } : { type: "togglePlugins", open: true, surface: request.surface });
+ }, [dispatch]);
+ useEffect(() => {
+ if (!adminSection || !team || admin !== true) return;
+ setAdminSection(null);
+ dispatch({ type: "toggleAppSettings", open: true, section: adminSection });
+ }, [adminSection, team, admin, dispatch]);
+}
diff --git a/src/locales/de.json b/src/locales/de.json
index a9387869be..2ccdf09135 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -849,8 +849,6 @@
"inbox.reviewInChat": "Sieh dir das im Chat an, aus dem es kommt, um es zu beantworten.",
"inbox.youReplied": "Du hast geantwortet",
"sidebar.people.mention": "{name} schreiben",
- "newBot.sharedWith": "Mit allen in {team} geteilt.",
- "newBot.justForYou": "Nur für dich? Erstelle ihn in deinem eigenen Bereich →",
"sidebar.bot.markUnread": "Als ungelesen markieren",
"sidebar.bot.editProfile": "Profil bearbeiten",
"sidebar.bot.duplicate": "Duplizieren",
@@ -2420,7 +2418,6 @@
"homeLine.left": "Du bist nicht mehr in {name}.",
"teamMove.menu": "Nach {team} verschieben",
"teamMove.title": "{bot} nach {team} verschieben?",
- "teamMove.everyone": "Alle in {team} können {bot} nutzen. Nur die Admins von {team} können es ändern.",
"teamMove.goes": "Kommt mit {bot}: Anweisungen, Skills, Dateien, Routinen und deine Chats mit {bot}",
"teamMove.private": "Deine Chats bleiben dort privat: Nur du kannst sie sehen.",
"teamMove.staysOnMyCloud": "Bleibt auf My Cloud: was {bot} sich gemerkt hat, deine Verbindungen und MausBot",
diff --git a/src/locales/en.json b/src/locales/en.json
index aabefdfdf5..bf963b7654 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -1644,7 +1644,7 @@
"cloudWelcome.bring.title": "What should {name} start with?",
"cloudWelcome.bring.sub": "Bots on your computer come here by themselves from the {app} app.",
"cloudWelcome.bring.subTeam": "Your own bots stay on your computer. {name} starts with bots of its own that everyone in the team can use.",
- "cloudWelcome.bring.subTeamShared": "{name} is your team’s: its bots are shared with everyone in {name}, and your own bots stay where they are.",
+ "cloudWelcome.bring.subTeamYours": "{name} is your team’s: a bot you make or bring here is yours until you share it, and your own bots stay where they are.",
"cloudWelcome.bring.fresh": "Start fresh",
"cloudWelcome.bring.freshHint": "Pick a ready-made team from the library, or start with one bot and build your own.",
"cloudWelcome.bring.chooseTeam": "Choose a team",
@@ -2328,8 +2328,6 @@
"sidebar.people.retry": "Try again",
"presence.hasOpen": "{names} has this open",
"presence.haveOpen": "{names} have this open",
- "newBot.sharedWith": "Shared with everyone in {team}.",
- "newBot.justForYou": "Just for you? Create it in your own place →",
"sidebar.bot.markUnread": "Mark as Unread",
"sidebar.bot.rename": "Rename",
"sidebar.bot.markRead": "Mark as Read",
@@ -2351,6 +2349,7 @@
"sidebar.bot.archiveBlockedLast": "Keep at least one active bot",
"sidebar.bot.deleteCheckingTitle": "Deleting this bot and any desktop it owns",
"sidebar.bot.deleteChecking": "Deleting the bot and its desktop…",
+ "sidebar.bot.deleteSharedAdminOnly": "Only an admin can delete a shared bot. Stop sharing it first.",
"sidebar.bot.deletingRow": "Deleting the bot and any desktop it owns…",
"sidebar.bot.deletingAria": "{name}, deleting the bot and any desktop it owns",
"sidebar.bot.archived": "{name} archived",
@@ -7582,7 +7581,7 @@
"homeLine.local": "{name} starts fresh: a separate place on this computer, with its own bots, chats and files.",
"teamMove.menu": "Move to {team}",
"teamMove.title": "Move {bot} to {team}?",
- "teamMove.everyone": "Everyone in {team} can use {bot}. Only {team}'s admins can change it.",
+ "teamMove.yours": "Only you and {team}'s admins can use {bot} until you share it.",
"teamMove.goes": "Goes with {bot}: instructions, skills, files, routines, and your chats with {bot}",
"teamMove.private": "Your chats stay private there: only you can see them.",
"teamMove.staysOnMyCloud": "Stays on My Cloud: what {bot} remembers, your connections, and MausBot",
diff --git a/src/locales/es.json b/src/locales/es.json
index d9a329c1cf..5f0623cac9 100644
--- a/src/locales/es.json
+++ b/src/locales/es.json
@@ -1711,8 +1711,6 @@
"inbox.reviewInChat": "Revísalo en el chat de donde viene para responder.",
"inbox.youReplied": "Respondiste",
"sidebar.people.mention": "Escribir a {name}",
- "newBot.sharedWith": "Compartido con todos en {team}.",
- "newBot.justForYou": "¿Solo para ti? Créalo en tu propio espacio →",
"sidebar.bot.markUnread": "Marcar como no leído",
"sidebar.bot.markAllRead": "Marcar todas las conversaciones como leídas",
"sidebar.bot.markingAllRead": "Marcando las conversaciones como leídas…",
@@ -5455,7 +5453,6 @@
"homeLine.left": "Ya no formas parte de {name}.",
"teamMove.menu": "Mover a {team}",
"teamMove.title": "¿Mover {bot} a {team}?",
- "teamMove.everyone": "Todos en {team} pueden usar {bot}. Solo los administradores de {team} pueden cambiarlo.",
"teamMove.goes": "Se va con {bot}: instrucciones, habilidades, archivos, rutinas y tus chats con {bot}",
"teamMove.private": "Tus chats siguen siendo privados allí: solo tú puedes verlos.",
"teamMove.staysOnMyCloud": "Se queda en My Cloud: lo que {bot} recuerda, tus conexiones y MausBot",
diff --git a/src/locales/fr.json b/src/locales/fr.json
index a9b9e5781c..a2be4202bb 100644
--- a/src/locales/fr.json
+++ b/src/locales/fr.json
@@ -692,8 +692,6 @@
"inbox.reviewInChat": "Regardez-le dans le chat d'où il vient pour y répondre.",
"inbox.youReplied": "Vous avez répondu",
"sidebar.people.mention": "Écrire à {name}",
- "newBot.sharedWith": "Partagé avec tous les membres de {team}.",
- "newBot.justForYou": "Juste pour vous ? Créez-le dans votre propre espace →",
"sidebar.bot.markUnread": "Marquer comme non lu",
"sidebar.bot.editProfile": "Modifier le profil",
"sidebar.bot.duplicate": "Dupliquer",
@@ -2324,7 +2322,6 @@
"homeLine.left": "Vous ne faites plus partie de {name}.",
"teamMove.menu": "Déplacer vers {team}",
"teamMove.title": "Déplacer {bot} vers {team} ?",
- "teamMove.everyone": "Tout le monde dans {team} peut utiliser {bot}. Seuls les admins de {team} peuvent le modifier.",
"teamMove.goes": "Part avec {bot} : instructions, compétences, fichiers, routines et vos chats avec {bot}",
"teamMove.private": "Vos chats restent privés là-bas : vous seul pouvez les voir.",
"teamMove.staysOnMyCloud": "Reste sur My Cloud : ce que {bot} a retenu, vos connexions et MausBot",
diff --git a/src/locales/hi.json b/src/locales/hi.json
index dae6c6d6be..4bf4f1f854 100644
--- a/src/locales/hi.json
+++ b/src/locales/hi.json
@@ -692,8 +692,6 @@
"inbox.reviewInChat": "जवाब देने के लिए इसे उस चैट में देखें जहाँ से यह आया है।",
"inbox.youReplied": "आपने जवाब दिया",
"sidebar.people.mention": "{name} को लिखें",
- "newBot.sharedWith": "{team} में सभी के साथ साझा।",
- "newBot.justForYou": "सिर्फ़ आपके लिए? इसे अपनी जगह में बनाएँ →",
"sidebar.bot.markUnread": "अपठित के रूप में चिह्नित करें",
"sidebar.bot.editProfile": "प्रोफ़ाइल संपादित करें",
"sidebar.bot.duplicate": "प्रतिलिपि बनाएँ",
@@ -2324,7 +2322,6 @@
"homeLine.left": "अब आप {name} में नहीं हैं।",
"teamMove.menu": "{team} में ले जाएँ",
"teamMove.title": "{bot} को {team} में ले जाएँ?",
- "teamMove.everyone": "{team} में हर कोई {bot} का इस्तेमाल कर सकता है। सिर्फ़ {team} के एडमिन इसे बदल सकते हैं।",
"teamMove.goes": "{bot} के साथ जाता है: निर्देश, स्किल, फ़ाइलें, रूटीन और {bot} के साथ आपकी चैट",
"teamMove.private": "आपकी चैट वहाँ निजी रहती हैं: उन्हें सिर्फ़ आप देख सकते हैं।",
"teamMove.staysOnMyCloud": "My Cloud पर रहता है: {bot} को जो याद है, आपके कनेक्शन और MausBot",
diff --git a/src/locales/it.json b/src/locales/it.json
index 70a8640d6b..72a8fe8bf3 100644
--- a/src/locales/it.json
+++ b/src/locales/it.json
@@ -1821,8 +1821,6 @@
"needsYou.asking": "{bot} ti sta chiedendo",
"needsYou.fix": "{bot} ha bisogno di una correzione",
"needsYou.aBot": "Un bot",
- "newBot.sharedWith": "Condiviso con tutti in {team}.",
- "newBot.justForYou": "Solo per te? Crealo nel tuo spazio →",
"sidebar.bot.markUnread": "Segna come non letto",
"sidebar.bot.markAllRead": "Segna tutte le conversazioni come lette",
"sidebar.bot.markingAllRead": "Segnatura delle conversazioni come lette…",
@@ -6119,7 +6117,6 @@
"homeLine.left": "Non fai più parte di {name}.",
"teamMove.menu": "Sposta in {team}",
"teamMove.title": "Spostare {bot} in {team}?",
- "teamMove.everyone": "Tutti in {team} possono usare {bot}. Solo gli amministratori di {team} possono modificarlo.",
"teamMove.goes": "Va con {bot}: istruzioni, abilità, file, routine e le tue chat con {bot}",
"teamMove.private": "Le tue chat restano private lì: solo tu puoi vederle.",
"teamMove.staysOnMyCloud": "Resta su My Cloud: ciò che {bot} ricorda, le tue connessioni e MausBot",
diff --git a/src/locales/ja.json b/src/locales/ja.json
index a7131c688a..29bac91d8b 100644
--- a/src/locales/ja.json
+++ b/src/locales/ja.json
@@ -2063,8 +2063,6 @@
"inbox.reviewInChat": "返答するには、元のチャットで確認してください。",
"inbox.youReplied": "あなたの返信",
"sidebar.people.mention": "{name}さんに書く",
- "newBot.sharedWith": "{team} の全員と共有されます。",
- "newBot.justForYou": "自分専用にしますか?自分のスペースで作成 →",
"sidebar.bot.markUnread": "未読にする",
"sidebar.bot.rename": "名前を変更",
"sidebar.bot.markRead": "既読にする",
@@ -7045,7 +7043,6 @@
"homeLine.clean": "ボットは Cloud にあります。サインインして利用してください。",
"teamMove.menu": "{team} に移動",
"teamMove.title": "{bot} を {team} に移動しますか?",
- "teamMove.everyone": "{team} の全員が {bot} を使えます。変更できるのは {team} の管理者だけです。",
"teamMove.goes": "{bot} と一緒に移るもの:指示、スキル、ファイル、ルーティン、{bot} とのあなたのチャット",
"teamMove.private": "あなたのチャットは移動先でも非公開です。見られるのはあなただけです。",
"teamMove.staysOnMyCloud": "My Cloud に残るもの:{bot} が覚えていること、あなたの接続、MausBot",
diff --git a/src/locales/ko.json b/src/locales/ko.json
index 6d3a36554f..5e8d32afa1 100644
--- a/src/locales/ko.json
+++ b/src/locales/ko.json
@@ -1973,8 +1973,6 @@
"inbox.reviewInChat": "답하려면 이 내용이 온 채팅에서 확인하세요.",
"inbox.youReplied": "답장함",
"sidebar.people.mention": "{name}에게 쓰기",
- "newBot.sharedWith": "{team}의 모든 사람과 공유돼요.",
- "newBot.justForYou": "나만 쓸 건가요? 내 공간에서 만드세요 →",
"sidebar.bot.markUnread": "읽지 않음으로 표시",
"sidebar.bot.rename": "이름 바꾸기",
"sidebar.bot.markRead": "읽음으로 표시",
@@ -6795,7 +6793,6 @@
"homeLine.left": "더 이상 {name}에 속해 있지 않아요.",
"teamMove.menu": "{team}(으)로 옮기기",
"teamMove.title": "{bot}을(를) {team}(으)로 옮길까요?",
- "teamMove.everyone": "{team}의 모든 사람이 {bot}을(를) 쓸 수 있어요. {team}의 관리자만 바꿀 수 있어요.",
"teamMove.goes": "{bot}과(와) 함께 가는 것: 지침, 스킬, 파일, 루틴, {bot}과(와)의 내 채팅",
"teamMove.private": "내 채팅은 그곳에서도 비공개예요: 나만 볼 수 있어요.",
"teamMove.staysOnMyCloud": "My Cloud에 남는 것: {bot}이(가) 기억하는 내용, 내 연결, MausBot",
diff --git a/src/locales/pl.json b/src/locales/pl.json
index 10f990b41d..374882af57 100644
--- a/src/locales/pl.json
+++ b/src/locales/pl.json
@@ -6248,7 +6248,6 @@
"homeLine.left": "Nie jesteś już w {name}.",
"teamMove.menu": "Przenieś do {team}",
"teamMove.title": "Przenieść {bot} do {team}?",
- "teamMove.everyone": "Wszyscy w {team} mogą używać {bot}. Tylko administratorzy {team} mogą to zmienić.",
"teamMove.goes": "Przenosi się z {bot}: instrukcje, umiejętności, pliki, rutyny i twoje czaty z {bot}",
"teamMove.private": "Twoje czaty pozostają tam prywatne: tylko ty możesz je widzieć.",
"teamMove.staysOnMyCloud": "Zostaje na My Cloud: to, co {bot} pamięta, twoje połączenia i MausBot",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index 43ca1a95ae..c0b918a2a6 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -2162,8 +2162,6 @@
"sidebar.people.retry": "Tentar novamente",
"presence.hasOpen": "{names} está com esta conversa aberta",
"presence.haveOpen": "{names} estão com esta conversa aberta",
- "newBot.sharedWith": "Compartilhado com todos em {team}.",
- "newBot.justForYou": "Só para você? Criar no seu próprio local →",
"sidebar.bot.markUnread": "Marcar como não lido",
"sidebar.bot.rename": "Renomear",
"sidebar.bot.markRead": "Marcar como lido",
@@ -2185,6 +2183,7 @@
"sidebar.bot.archiveBlockedLast": "Mantenha pelo menos um bot ativo",
"sidebar.bot.deleteCheckingTitle": "Excluindo este bot e qualquer desktop que pertença a ele",
"sidebar.bot.deleteChecking": "Excluindo o bot e seu desktop…",
+ "sidebar.bot.deleteSharedAdminOnly": "Só um administrador pode excluir um bot compartilhado. Pare de compartilhá-lo primeiro.",
"sidebar.bot.deletingRow": "Excluindo o bot e qualquer desktop que pertença a ele…",
"sidebar.bot.deletingAria": "{name}, excluindo o bot e qualquer desktop que pertença a ele",
"sidebar.bot.archived": "Bot {name} arquivado",
@@ -7403,7 +7402,7 @@
"homeLine.cleanSaved": "Seus bots estão no Cloud da sua outra conta. Clique no ícone dele à esquerda do app para acessá-los.",
"teamMove.menu": "Mover para {team}",
"teamMove.title": "Mover {bot} para {team}?",
- "teamMove.everyone": "Todos em {team} podem usar {bot}. Só os administradores de {team} podem alterá-lo.",
+ "teamMove.yours": "Só você e os administradores de {team} podem usar {bot} até você compartilhar.",
"teamMove.goes": "Vão com {bot}: instruções, habilidades, arquivos, rotinas e suas conversas com {bot}",
"teamMove.private": "Suas conversas continuam privadas lá: só você pode vê-las.",
"teamMove.staysOnMyCloud": "Ficam no My Cloud: o que {bot} lembra, suas conexões e o MausBot",
@@ -10171,7 +10170,7 @@
"phone.signIn.emailCode": "Código de login do seu e-mail",
"settings.simple.account.noNameHint": "Ainda não definido",
"settings.simple.account.yourName": "Seu nome",
- "cloudWelcome.bring.subTeamShared": "{name} é da sua equipe: os bots são compartilhados com todos em {name}, e seus próprios bots ficam onde estão.",
+ "cloudWelcome.bring.subTeamYours": "{name} é da sua equipe: um bot que você cria ou traz para cá é seu até você compartilhar, e seus próprios bots ficam onde estão.",
"cloudWelcome.invite.title": "Convidar pessoas para {name}",
"cloudWelcome.invite.body": "{name} fica melhor com sua equipe. Convide as pessoas por e-mail no MausBot Cloud: elas podem abrir no navegador na hora.",
"cloudWelcome.invite.action": "Convidar pessoas",
diff --git a/src/locales/ru.json b/src/locales/ru.json
index d3e21229d8..d9b38f1d5a 100644
--- a/src/locales/ru.json
+++ b/src/locales/ru.json
@@ -1889,8 +1889,6 @@
"inbox.reviewInChat": "Чтобы ответить, посмотрите в чате, откуда это пришло.",
"inbox.youReplied": "Ваш ответ",
"sidebar.people.mention": "Написать: {name}",
- "newBot.sharedWith": "Доступен всем в {team}.",
- "newBot.justForYou": "Только для вас? Создайте в своём пространстве →",
"sidebar.bot.markUnread": "Отметить как непрочитанное",
"sidebar.bot.markAllRead": "Отметить все беседы прочитанными",
"sidebar.bot.markingAllRead": "Отметка бесед прочитанными…",
@@ -6337,7 +6335,6 @@
"homeLine.left": "Вас больше нет в {name}.",
"teamMove.menu": "Переместить в {team}",
"teamMove.title": "Переместить {bot} в {team}?",
- "teamMove.everyone": "Все в {team} смогут использовать {bot}. Изменить это могут только администраторы {team}.",
"teamMove.goes": "Переедет вместе с {bot}: инструкции, навыки, файлы, routine-задачи и ваши чаты с {bot}",
"teamMove.private": "Ваши чаты останутся приватными: их увидите только вы.",
"teamMove.staysOnMyCloud": "Останется в My Cloud: то, что помнит {bot}, ваши подключения и MausBot",
diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.json
index b43850736b..fcba029621 100644
--- a/src/locales/source-hashes.json
+++ b/src/locales/source-hashes.json
@@ -397,8 +397,6 @@
"needsYou.aBot": "7bcedea5b10ad528b823aeb4d71735ae99f491b4a098d404d8cb81fded167a67",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.editProfile": "fec2ac0f4cf167e35facd4d2038d15e8d60cbd604d7769635012a48a87363f44",
"sidebar.bot.duplicate": "02cdaabfca805d6ab75d81043998bdc733451b9ea48958ebf8098022d102ba2e",
@@ -1826,7 +1824,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -4764,8 +4761,6 @@
"needsYou.aBot": "7bcedea5b10ad528b823aeb4d71735ae99f491b4a098d404d8cb81fded167a67",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.markAllRead": "376c642893b92e6aa073a9f2bd5405f5fb1e91a8a319da476e8841f3d6c1e0b0",
"sidebar.bot.markingAllRead": "24d6245af13bf44e2213f0b097c4f55d6aba6f4781d3d998d1b6de169d509d18",
@@ -8309,7 +8304,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -9995,8 +9989,6 @@
"needsYou.aBot": "7bcedea5b10ad528b823aeb4d71735ae99f491b4a098d404d8cb81fded167a67",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.editProfile": "fec2ac0f4cf167e35facd4d2038d15e8d60cbd604d7769635012a48a87363f44",
"sidebar.bot.duplicate": "02cdaabfca805d6ab75d81043998bdc733451b9ea48958ebf8098022d102ba2e",
@@ -11487,7 +11479,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -13371,8 +13362,6 @@
"needsYou.aBot": "7bcedea5b10ad528b823aeb4d71735ae99f491b4a098d404d8cb81fded167a67",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.editProfile": "fec2ac0f4cf167e35facd4d2038d15e8d60cbd604d7769635012a48a87363f44",
"sidebar.bot.duplicate": "02cdaabfca805d6ab75d81043998bdc733451b9ea48958ebf8098022d102ba2e",
@@ -14863,7 +14852,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -17676,8 +17664,6 @@
"needsYou.aBot": "7bcedea5b10ad528b823aeb4d71735ae99f491b4a098d404d8cb81fded167a67",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.markAllRead": "376c642893b92e6aa073a9f2bd5405f5fb1e91a8a319da476e8841f3d6c1e0b0",
"sidebar.bot.markingAllRead": "24d6245af13bf44e2213f0b097c4f55d6aba6f4781d3d998d1b6de169d509d18",
@@ -21947,7 +21933,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -26111,8 +26096,6 @@
"sidebar.people.mention": "3367c9dc49343c4480f793b1b609c524c60b849a25739c016b7f3ed94f97892e",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.rename": "3064d79a295cefe4b384b8fe5cb29fd6b06d7eb1ad94b8895f4148039d06b330",
"sidebar.bot.markRead": "75c4ef2817e094a57f2b4bf97ec2a4f179d9aa46ed5dbcc7d3b91c33c7a01ade",
@@ -26134,6 +26117,7 @@
"sidebar.bot.archiveBlockedLast": "074f1d8851ce9493c25d8a4eb55702d30bb92412a7613f58bc5abe69c44560b7",
"sidebar.bot.deleteCheckingTitle": "beeab41b11879ca24232656883ed0840b198409d0e416561f209de66934e5293",
"sidebar.bot.deleteChecking": "edea81628b2af135ed25f0ee478278c5acc6809653119c0cb49482fed118b439",
+ "sidebar.bot.deleteSharedAdminOnly": "60879d552abf3e17948689282e51d870d653870d44b77c7a20d11dda34a0bcaf",
"sidebar.bot.deletingRow": "220b77d5e5ebdc2c3c927e5fc1e50f87d95732ed46f79d209078b0135ce860fe",
"sidebar.bot.deletingAria": "eb0433804155cfa6943afd92f568f355786046d88e445754c5817c32d29d99ea",
"sidebar.bot.archived": "648d59f2173b93ea76b5b80047d630250fd3043ae922c7fcd0743e05da1ddf50",
@@ -31093,7 +31077,7 @@
"homeLine.cleanSaved": "3901b2d808275732a5b8d38083d28308e994ab5c7039f12ecec5fa8a2ce7e141",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
+ "teamMove.yours": "a0011774c5a7ee2df2c1b77b51ec35b8813df3620fa09ab579dab4bda61e95f7",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.staysOnMyCloud": "871ea9b80e62bd88f55050db9b6d8f43b37d3d894bdee017e6d5d8071b7c7232",
@@ -33994,7 +33978,7 @@
"modelgoOffer.getKey": "a924525b9ba78ecd9db2884d80396d5dae485186aa549e3cbef08785723faa82",
"modelgoOffer.name": "e4289c5aa9fda7be5c34830842a68861d5d15f20e7b95ccbf77937a6b87cc058",
"modelgoOffer.link": "36d2f296e03d65fd53dedf77b0f1e994db6e4f58d6ceacd9a345eda4feca8665",
- "cloudWelcome.bring.subTeamShared": "4d7ed744d6f6c4aef400794ec62dc8153c2e7e5247618a8ef3a95b7fabce82b9",
+ "cloudWelcome.bring.subTeamYours": "1d3e87449e1bc422e6ebc014820e593ecc5e75b9eb299934c473d59864a12565",
"cloudWelcome.invite.title": "6978814074311b8054bccc8bcc255c22547da4a266c4539057df1891f34eace2",
"cloudWelcome.invite.body": "6c429e975ccbd3f782ac283010186a00a591f241d37286ca3c939eb70449ab73",
"cloudWelcome.invite.action": "27bf0f2d3f3f549002f193566e19b010a40b80c1a5564cf65a80d83f2f2c0462",
@@ -34944,8 +34928,6 @@
"needsYou.aBot": "7bcedea5b10ad528b823aeb4d71735ae99f491b4a098d404d8cb81fded167a67",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.editProfile": "fec2ac0f4cf167e35facd4d2038d15e8d60cbd604d7769635012a48a87363f44",
"sidebar.bot.duplicate": "02cdaabfca805d6ab75d81043998bdc733451b9ea48958ebf8098022d102ba2e",
@@ -37036,7 +37018,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -42928,8 +42909,6 @@
"needsYou.aBot": "7bcedea5b10ad528b823aeb4d71735ae99f491b4a098d404d8cb81fded167a67",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.editProfile": "fec2ac0f4cf167e35facd4d2038d15e8d60cbd604d7769635012a48a87363f44",
"sidebar.bot.duplicate": "02cdaabfca805d6ab75d81043998bdc733451b9ea48958ebf8098022d102ba2e",
@@ -45721,7 +45700,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -52488,8 +52466,6 @@
"needsYou.aBot": "7bcedea5b10ad528b823aeb4d71735ae99f491b4a098d404d8cb81fded167a67",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.editProfile": "fec2ac0f4cf167e35facd4d2038d15e8d60cbd604d7769635012a48a87363f44",
"sidebar.bot.duplicate": "02cdaabfca805d6ab75d81043998bdc733451b9ea48958ebf8098022d102ba2e",
@@ -54330,7 +54306,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -56752,8 +56727,6 @@
"needsYou.aBot": "7bcedea5b10ad528b823aeb4d71735ae99f491b4a098d404d8cb81fded167a67",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.markAllRead": "376c642893b92e6aa073a9f2bd5405f5fb1e91a8a319da476e8841f3d6c1e0b0",
"sidebar.bot.markingAllRead": "24d6245af13bf44e2213f0b097c4f55d6aba6f4781d3d998d1b6de169d509d18",
@@ -59989,7 +59962,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -62391,8 +62363,6 @@
"needsYou.aBot": "7bcedea5b10ad528b823aeb4d71735ae99f491b4a098d404d8cb81fded167a67",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.markAllRead": "376c642893b92e6aa073a9f2bd5405f5fb1e91a8a319da476e8841f3d6c1e0b0",
"sidebar.bot.markingAllRead": "24d6245af13bf44e2213f0b097c4f55d6aba6f4781d3d998d1b6de169d509d18",
@@ -65628,7 +65598,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -72586,7 +72555,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -75292,8 +75260,6 @@
"relay.toldHint": "de7d19e139c3fbb262cfa3af9bf44ae9174ede043fa250d52617671188b883ba",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.markAllRead": "376c642893b92e6aa073a9f2bd5405f5fb1e91a8a319da476e8841f3d6c1e0b0",
"sidebar.bot.markingAllRead": "24d6245af13bf44e2213f0b097c4f55d6aba6f4781d3d998d1b6de169d509d18",
@@ -79616,7 +79582,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -82215,8 +82180,6 @@
"needsYou.aBot": "7bcedea5b10ad528b823aeb4d71735ae99f491b4a098d404d8cb81fded167a67",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.markAllRead": "376c642893b92e6aa073a9f2bd5405f5fb1e91a8a319da476e8841f3d6c1e0b0",
"sidebar.bot.markingAllRead": "24d6245af13bf44e2213f0b097c4f55d6aba6f4781d3d998d1b6de169d509d18",
@@ -86390,7 +86353,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
@@ -89273,8 +89235,6 @@
"sidebar.people.mention": "3367c9dc49343c4480f793b1b609c524c60b849a25739c016b7f3ed94f97892e",
"orgChart.mode.departments": "5f9494c4d2179e6b024d5238e421c0771eff45f79587aa984739ca133dd5adae",
"orgChart.chief": "245b630a86a9f2753c86a86f1a9cdeaed80b74704dfa2fc3193d6e312c294a38",
- "newBot.sharedWith": "a27c2a648d76368cc2eb09fbbc3f81fddd9c7147c3e7e6a3f6cc4770bbef5fca",
- "newBot.justForYou": "802927c8d05700f406ab8591367659074d19f0f40860f161c45869d65b560f00",
"sidebar.bot.markUnread": "1a9220e4be1c8bc0a1bc9e8880ea6c1486d2b97a42aa0cc37c5bb37ab60e5d2d",
"sidebar.bot.rename": "3064d79a295cefe4b384b8fe5cb29fd6b06d7eb1ad94b8895f4148039d06b330",
"sidebar.bot.markRead": "75c4ef2817e094a57f2b4bf97ec2a4f179d9aa46ed5dbcc7d3b91c33c7a01ade",
@@ -94011,7 +93971,6 @@
"homeLine.left": "f0b1ba424cd65cd13d4432649c2044baffca6e28f0556c49403174ce33dbef02",
"teamMove.menu": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
"teamMove.title": "67842d53b0591251cdb93b499629f02002063dca84a48e04731c09f98bf6cb7d",
- "teamMove.everyone": "7e82b6a3deef645e04c18558b57ccd23fea86da185492e618ff333ecc0abdba0",
"teamMove.goes": "e24e226704f3116074ad47863f5e12274bc31b338b9b6afe6922cc992f3e682a",
"teamMove.private": "d6587c85a6f64a4801b4a5303db02756f6af2050b08bc0a87685242c7c2f93f0",
"teamMove.confirm": "428b3c909ea7010ae3b8c3f465007535be51411ff924048e585da63957a3b32e",
diff --git a/src/locales/tr.json b/src/locales/tr.json
index 3a5f70aa07..0fd92ab2e4 100644
--- a/src/locales/tr.json
+++ b/src/locales/tr.json
@@ -1415,8 +1415,6 @@
"inbox.reviewInChat": "Yanıtlamak için geldiği sohbette bak.",
"inbox.youReplied": "Yanıtın",
"sidebar.people.mention": "{name} kişisine yaz",
- "newBot.sharedWith": "{team} içindeki herkesle paylaşılır.",
- "newBot.justForYou": "Sadece sizin için mi? Kendi alanınızda oluşturun →",
"sidebar.bot.markUnread": "Okunmadı Olarak İşaretle",
"sidebar.bot.markAllRead": "Tüm sohbetleri okundu olarak işaretle",
"sidebar.bot.markingAllRead": "Sohbetler okundu olarak işaretleniyor…",
@@ -4794,7 +4792,6 @@
"homeLine.left": "Artık {name} içinde değilsiniz.",
"teamMove.menu": "{team} ekibine taşı",
"teamMove.title": "{bot} {team} ekibine taşınsın mı?",
- "teamMove.everyone": "{team} içindeki herkes {bot} botunu kullanabilir. Yalnızca {team} yöneticileri onu değiştirebilir.",
"teamMove.goes": "{bot} ile birlikte gider: talimatlar, beceriler, dosyalar, rutinler ve {bot} ile sohbetlerin",
"teamMove.private": "Sohbetlerin orada gizli kalır: onları yalnızca sen görebilirsin.",
"teamMove.staysOnMyCloud": "My Cloud'da kalır: {bot} botunun hatırladıkları, bağlantıların ve MausBot",
diff --git a/src/locales/uk.json b/src/locales/uk.json
index 2e7bdb2c3c..d4b28a96b9 100644
--- a/src/locales/uk.json
+++ b/src/locales/uk.json
@@ -810,8 +810,6 @@
"inbox.reviewInChat": "Щоб відповісти, перегляньте це в чаті, звідки воно прийшло.",
"inbox.youReplied": "Ваша відповідь",
"sidebar.people.mention": "Написати: {name}",
- "newBot.sharedWith": "Доступно всім у {team}.",
- "newBot.justForYou": "Лише для вас? Створіть його у своєму просторі →",
"sidebar.bot.markUnread": "Позначити непрочитаним",
"sidebar.bot.editProfile": "Редагувати профіль",
"sidebar.bot.duplicate": "Дублювати",
@@ -2793,7 +2791,6 @@
"homeLine.left": "Ви більше не в {name}.",
"teamMove.menu": "Перемістити до {team}",
"teamMove.title": "Перемістити {bot} до {team}?",
- "teamMove.everyone": "Усі в {team} можуть користуватися {bot}. Змінювати його можуть лише адміністратори {team}.",
"teamMove.goes": "Разом із {bot} переходять: інструкції, навички, файли, рутини та ваші чати з {bot}",
"teamMove.private": "Ваші чати лишаються там приватними: їх бачите лише ви.",
"teamMove.staysOnMyCloud": "Лишається в My Cloud: те, що пам'ятає {bot}, ваші підключення та MausBot",
diff --git a/src/locales/vi.json b/src/locales/vi.json
index ac8fde983f..c3b7ecc0ee 100644
--- a/src/locales/vi.json
+++ b/src/locales/vi.json
@@ -1415,8 +1415,6 @@
"inbox.reviewInChat": "Xem trong cuộc trò chuyện mà nó đến để trả lời.",
"inbox.youReplied": "Câu trả lời của bạn",
"sidebar.people.mention": "Viết cho {name}",
- "newBot.sharedWith": "Được chia sẻ với mọi người trong {team}.",
- "newBot.justForYou": "Chỉ dành cho bạn? Hãy tạo trong không gian riêng của bạn →",
"sidebar.bot.markUnread": "Đánh dấu là chưa đọc",
"sidebar.bot.markAllRead": "Đánh dấu tất cả cuộc trò chuyện là đã đọc",
"sidebar.bot.markingAllRead": "Đang đánh dấu các cuộc trò chuyện là đã đọc…",
@@ -4794,7 +4792,6 @@
"homeLine.left": "Bạn không còn trong {name} nữa.",
"teamMove.menu": "Chuyển sang {team}",
"teamMove.title": "Chuyển {bot} sang {team}?",
- "teamMove.everyone": "Mọi người trong {team} đều dùng được {bot}. Chỉ quản trị viên của {team} mới thay đổi được.",
"teamMove.goes": "Đi cùng {bot}: hướng dẫn, kỹ năng, tệp, thói quen và các cuộc trò chuyện của bạn với {bot}",
"teamMove.private": "Các cuộc trò chuyện của bạn vẫn riêng tư ở đó: chỉ bạn xem được.",
"teamMove.staysOnMyCloud": "Ở lại My Cloud: những gì {bot} ghi nhớ, các kết nối của bạn và MausBot",
diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.json
index a3f35afadb..0367326096 100644
--- a/src/locales/zh-tw.json
+++ b/src/locales/zh-tw.json
@@ -2223,8 +2223,6 @@
"inbox.headline.connect": "連線 {app}",
"inbox.youReplied": "你的回覆",
"sidebar.people.mention": "寫給 {name}",
- "newBot.sharedWith": "已與 {team} 的所有人分享。",
- "newBot.justForYou": "只給自己用?在你自己的空間中建立 →",
"sidebar.bot.markUnread": "標示為未讀",
"sidebar.bot.rename": "重新命名",
"sidebar.bot.markRead": "標示為已讀",
@@ -7251,7 +7249,6 @@
"homeLine.local": "{name} 從頭開始:這台電腦上的獨立空間,有自己的機器人、對話和檔案。",
"teamMove.menu": "移到 {team}",
"teamMove.title": "要把 {bot} 移到 {team} 嗎?",
- "teamMove.everyone": "{team} 的每個人都能使用 {bot}。只有 {team} 的管理員能變更它。",
"teamMove.goes": "隨 {bot} 一起移過去:指示、技能、檔案、例行任務,以及你和 {bot} 的對話",
"teamMove.private": "你的對話在那裡仍然保密:只有你看得到。",
"teamMove.staysOnMyCloud": "留在 My Cloud:{bot} 記得的內容、你的連線和 MausBot",
diff --git a/src/locales/zh.json b/src/locales/zh.json
index 9cc00fb8cd..9e80b78145 100644
--- a/src/locales/zh.json
+++ b/src/locales/zh.json
@@ -2098,8 +2098,6 @@
"inbox.reviewInChat": "请到它来自的聊天中查看并回复。",
"inbox.youReplied": "你的回复",
"sidebar.people.mention": "写给 {name}",
- "newBot.sharedWith": "已与 {team} 的所有人共享。",
- "newBot.justForYou": "只给自己用?在你自己的空间中创建 →",
"sidebar.bot.markUnread": "标记为未读",
"sidebar.bot.rename": "重命名",
"sidebar.bot.markRead": "标记为已读",
@@ -7007,7 +7005,6 @@
"homeLine.left": "你已不在 {name} 中。",
"teamMove.menu": "移到 {team}",
"teamMove.title": "要把 {bot} 移到 {team} 吗?",
- "teamMove.everyone": "{team} 里的每个人都能使用 {bot}。只有 {team} 的管理员能修改它。",
"teamMove.goes": "随 {bot} 一起移过去:指令、技能、文件、例行任务,以及你和 {bot} 的对话",
"teamMove.private": "你的对话在那里依然保密:只有你能看到。",
"teamMove.staysOnMyCloud": "留在 My Cloud:{bot} 记得的内容、你的连接和 MausBot",
diff --git a/src/state/team-side.test.ts b/src/state/team-side.test.ts
index ca45750f59..d916425adb 100644
--- a/src/state/team-side.test.ts
+++ b/src/state/team-side.test.ts
@@ -10,7 +10,7 @@ vi.mock("./api", () => ({
import { openBot } from "./thread-navigation";
import { rememberOwnChat, setTeamChats, type TeamChats } from "./team-chats";
-import { botOnSide, savedTeamSide, setTeamSide, showTeamSide, sideOfThread, tasksOfSide, teamSide, teamSideView, teamThreadOf } from "./team-side";
+import { botOnSide, listedSide, savedTeamSide, setTeamSide, sharedWithOthers, showTeamSide, sideOfThread, tasksOfSide, teamSide, teamSideView, teamThreadOf, teamThreadToOpen } from "./team-side";
const ADA: TeamChats = { teamId: "team-acme", member: true, opened: [], person: "[email protected]" };
const BEN: TeamChats = { ...ADA, person: "[email protected]" };
@@ -124,6 +124,60 @@ describe("what each side of the sidebar lists", () => {
expect(botOnSide(scout([{ threadId: "ada-old", private: true, createdAt: 2 }], { yourAccess: "view" }), ADA, "me")).toBe(true);
});
+ it("knows a bot is shared from what this copy of it says: its sharing for someone who can edit it, having it at all for anyone else", () => {
+ const owner = { createdBy: "[email protected]", yourAccess: "edit" };
+ expect(sharedWithOthers({ ...owner, access: { everyone: "none", people: {} } }), "only its owner and the admins").toBe(false);
+ expect(sharedWithOthers({ ...owner, access: { everyone: "none", people: { "[email protected]": "edit" } } }), "the owner's own entry is nobody else").toBe(false);
+ expect(sharedWithOthers({ ...owner, access: { everyone: "none", people: { "[email protected]": "view" } } })).toBe(true);
+ expect(sharedWithOthers({ ...owner, access: { everyone: "chat", people: {} } })).toBe(true);
+ expect(sharedWithOthers({ ...owner, visibility: "admins" }), "set up before levels, admins only").toBe(false);
+ expect(sharedWithOthers({ ...owner, visibility: { people: ["[email protected]"] } })).toBe(false);
+ expect(sharedWithOthers({ ...owner }), "set up before levels, everyone").toBe(true);
+ for (const yourAccess of ["view", "chat"]) expect(sharedWithOthers({ createdBy: "[email protected]", yourAccess }), "it was shared with this person").toBe(true);
+ expect(sharedWithOthers({ defaultBot: { person: "[email protected]" }, yourAccess: "edit" })).toBe(false);
+ });
+
+ it("lists a bot nobody else can use under Just me only, its main chat with it, and never under Team", () => {
+ const mine = scout([{ threadId: "ada-own", private: true, createdAt: 2 }], { createdBy: "[email protected]", yourAccess: "edit", access: { everyone: "none", people: {} } });
+ const shared = { ...scout([], { yourAccess: "chat" }), id: "payroll", threadId: "payroll-main", mainThreadId: "payroll-main", tasks: [{ ...MAIN, threadId: "payroll-main" }] };
+ expect(botOnSide(mine, ADA, "team")).toBe(false);
+ expect(botOnSide(mine, ADA, "me")).toBe(true);
+ const me = teamSideView([mine, shared, mausbot()], [], ADA, "me"), team = teamSideView([mine, shared, mausbot()], [], ADA, "team");
+ expect(ids(team.bots)).toEqual(["payroll"]);
+ expect(ids(me.bots)).toEqual(["scout", "payroll", "mine"]);
+ expect(me.bots[0]!.tasks.map((task) => task.threadId), "nothing of it is left where no list shows it").toEqual(["scout-main", "ada-own"]);
+ expect(me.bots[0]!.messages, "its main chat on screen is on this side").toEqual([{ id: "m1" }]);
+ expect(listedSide(mine, "scout-main")).toBe("me");
+ expect(sideOfThread(mine, "scout-main"), "who reads it is still the server's answer: its owner and the admins, so never called private").toBe("team");
+ setTeamChats(ADA);
+ setTeamSide("team");
+ expect(teamThreadToOpen(mine, ADA), "Team opens no shared chat of it").toBeNull();
+ expect(teamThreadToOpen(shared, ADA)).toBe("payroll-main");
+
+ const nowShared = { ...mine, access: { everyone: "none", people: { "[email protected]": "chat" } } };
+ expect(ids(teamSideView([nowShared, mausbot()], [], ADA, "team").bots), "shared with one person, it is the team's too").toEqual(["scout"]);
+ expect(teamSideView([nowShared, mausbot()], [], ADA, "me").bots[0]!.tasks.map((task) => task.threadId)).toEqual(["ada-own"]);
+ });
+
+ it("keeps a private bot under Just me whole, a conversation of it shared with someone included; what that conversation says of its readers is still the server's", () => {
+ const mine = scout([{ threadId: "with-ada", shared: true, createdAt: 2 }, { threadId: "ada-own", private: true, createdAt: 3 }],
+ { createdBy: "[email protected]", yourAccess: "edit", access: { everyone: "none", people: {} } });
+ expect(sideOfThread(mine, "with-ada"), "read by someone else: never called private").toBe("team");
+ expect(listedSide(mine, "with-ada")).toBe("me");
+ expect(botOnSide(mine, ADA, "team")).toBe(false);
+ expect(teamSideView([mine, mausbot()], [room()], ADA, "me").bots[0]!.tasks.map((task) => task.threadId)).toEqual(["scout-main", "with-ada", "ada-own"]);
+ expect(ids(teamSideView([mine, mausbot()], [room()], ADA, "team").bots)).toEqual([]);
+ const shared = { ...mine, access: { everyone: "chat" as const, people: {} } };
+ expect(listedSide(shared, "with-ada"), "on a shared bot it is on the Team side, as main lists it").toBe("team");
+ });
+
+ it("offers no switch when the only bots are ones nobody else can use", () => {
+ const mine = scout([], { createdBy: "[email protected]", yourAccess: "edit", access: { everyone: "none", people: {} } });
+ const view = teamSideView([mine, mausbot()], [], ADA, "me");
+ expect(view.switchable).toBe(false);
+ expect(ids(view.bots)).toEqual(["scout", "mine"]);
+ });
+
it("offers no switch, and hides nothing, when one side would be empty", () => {
const onlyMine = teamSideView([mausbot()], [], ADA, "team");
expect(onlyMine.switchable).toBe(false);
diff --git a/src/state/team-side.ts b/src/state/team-side.ts
index 916c6c7c96..a09a7cfb70 100644
--- a/src/state/team-side.ts
+++ b/src/state/team-side.ts
@@ -2,12 +2,16 @@
// "Team", the conversations everyone who sees a bot or a group chat reads. Which side a conversation belongs to is the
// server's answer (`private` on the task), never the position of the switch.
import { useSyncExternalStore } from "react";
+import { accessFromVisibility, type BotAccess } from "../../shared/bot-access";
+import { botOwner } from "../../shared/bot-owner";
+import type { BotVisibility } from "../../shared/wire";
import { onTeamChats, ownChatOf, ownChatStarted, teamChats, type TeamChats } from "./team-chats";
export type TeamSide = "me" | "team";
type SideTask = { threadId: string; private?: unknown; shared?: unknown; sharedChat?: unknown; unread?: boolean; routineRunId?: unknown; archivedAt?: unknown };
-type SideBot = { id: string; threadId: string; tasks?: SideTask[]; yourAccess?: string; defaultBot?: { person?: unknown }; hidden?: boolean; messages?: unknown[] };
+type SharedBot = { yourAccess?: string; access?: BotAccess; visibility?: BotVisibility; createdBy?: string; reportsTo?: string; defaultBot?: { person?: string } };
+type SideBot = SharedBot & { id: string; threadId: string; tasks?: SideTask[]; hidden?: boolean; messages?: unknown[] };
type SideGroup = { id: string; unread?: boolean };
/**
@@ -22,25 +26,41 @@ export function sideOfThread(bot: Pick<SideBot, "tasks" | "defaultBot">, threadI
return task?.sharedChat !== true && (task?.private === true || (ownChatStarted(threadId) && task?.shared !== true)) ? "me" : "team";
}
+/**
+ * Whether anyone but whoever looks after the bot and the admins can use it, as far as this copy of it says. Someone who
+ * can edit a bot is sent its sharing; anyone else who has the bot was given it, so it is shared with them.
+ */
+export function sharedWithOthers(bot: SharedBot): boolean {
+ if (bot.defaultBot?.person) return false;
+ if (bot.yourAccess === "view" || bot.yourAccess === "chat") return true;
+ const access = bot.access ?? accessFromVisibility(bot.visibility);
+ const owner = botOwner(bot);
+ return access.everyone !== "none" || Object.keys(access.people).some((entry) => entry !== owner);
+}
+
+/** The side a conversation is listed on. A bot nobody else can use is under "Just me" whole, its main chat included:
+ * "Team" lists only what is shared with someone. What the conversation says of its readers stays `sideOfThread`'s. */
+export const listedSide = (bot: SharedBot & Pick<SideBot, "tasks">, threadId: string): TeamSide => (sharedWithOthers(bot) ? sideOfThread(bot, threadId) : "me");
+
/** The bot's shared chat, as the server names it; null for a bot that has none (a person's own MausBot). */
export const teamThreadOf = (bot: Pick<SideBot, "tasks" | "defaultBot">): string | null =>
bot.defaultBot?.person ? null : bot.tasks?.find((task) => task.sharedChat === true && task.private !== true)?.threadId ?? null;
/** The bot's conversations of one side, for a list. */
-export const tasksOfSide = <T extends SideTask>(bot: Pick<SideBot, "defaultBot"> & { tasks?: T[] }, side: TeamSide): T[] =>
- (bot.tasks ?? []).filter((task) => sideOfThread(bot, task.threadId) === side);
+export const tasksOfSide = <T extends SideTask>(bot: SharedBot & { tasks?: T[] }, side: TeamSide): T[] =>
+ (bot.tasks ?? []).filter((task) => listedSide(bot, task.threadId) === side);
-/** Whether the bot is listed on a side: under "Team" with its shared chat; under "Just me" when the person can chat
- * with it privately, or already has a conversation of their own with it. */
+/** Whether the bot is listed on a side: under "Team" with its shared chat, when it is shared with someone; under
+ * "Just me" when the person can chat with it privately, or already has a conversation of their own with it. */
export function botOnSide(bot: SideBot, team: TeamChats, side: TeamSide): boolean {
- if (side === "team") return teamThreadOf(bot) !== null;
+ if (side === "team") return teamThreadOf(bot) !== null && sharedWithOthers(bot);
return Boolean(bot.defaultBot?.person) || bot.yourAccess !== "view" || ownChatOf(bot, team) !== null;
}
/** A bot as one side lists it: that side's conversations only, and nothing of the other side's on its row: no unread
* mark, no working line, no words in its preview. */
export function botForSide<T extends SideBot>(bot: T, side: TeamSide): T {
- const onScreenHere = sideOfThread(bot, bot.threadId) === side;
+ const onScreenHere = listedSide(bot, bot.threadId) === side;
const tasks = tasksOfSide(bot, side);
const elsewhere = onScreenHere ? {} : { busy: false, activity: undefined, waitingForTeammates: false, ...(bot.messages ? { messages: [] } : {}) };
return { ...bot, tasks: bot.tasks && tasks, unread: tasks.some(marksUnread), ...elsewhere } as T;
@@ -126,5 +146,5 @@ export function useTeamSide(): { team: TeamChats | null; side: TeamSide } {
/** The shared chat, when opening this bot should land on "Team": the side the sidebar shows. */
export function teamThreadToOpen(bot: SideBot, team: TeamChats | null): string | null {
- return team && teamSide(team) === "team" ? teamThreadOf(bot) : null;
+ return team && teamSide(team) === "team" && sharedWithOthers(bot) ? teamThreadOf(bot) : null;
}