Add workspaces, conversation sessions, app-managed computers and pictures

- Rail: Add icon with stacked form modals (bot, workspace, computer),
  coordinator, recent bots with "See all bots", Workspaces section, and
  a workspace mode listing only its crew
- Workspaces: page for context, bots (per-workspace instructions and
  memory), computers (default, link, unlink), models and delete;
  conversations scoped per bot per workspace
- Sessions: conversations split into searchable, reopenable sessions
  with carry-over summaries; sessions and new-session header icons
- Computers: created and provisioned over the docker socket, home dir
  kept at DATA_DIR/computers/<id> after delete; super admins only
- Models: workspace settings win over a bot's own, then the defaults
- Pictures for bots and workspaces; bots editable from the header
- Coordinator tools: update_workspace, set_bot_workspace_instructions

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-19 08:39:33 +01:00
co-authored by Claude Opus 5.5
parent 56daf0c462
commit 0ce61cdb49
223 changed files with 8166 additions and 585 deletions
+22 -13
View File
@@ -2,37 +2,46 @@ import { describe, expect, test } from "bun:test";
import composeBotPrompt from "./compose-bot-prompt";
describe("composeBotPrompt", () => {
test("orders core instructions, workspaces, then memory", () => {
test("orders core instructions, the workspace, then memory", () => {
expect(
composeBotPrompt({
system_prompt: "# You are Scout\n\nFind things.",
memory: "- The user prefers short replies.",
workspaces: [
{ name: "Launch", system_prompt: "Ship by Friday." },
{ name: "Ops", system_prompt: "Servers are on Debian." },
],
workspace: {
name: "Launch",
description: "The spring launch.",
system_prompt: "Ship by Friday.",
},
workspace_bot: {
system_prompt: "Own the changelog.",
memory: "- Marketing signs off on copy.",
},
}),
).toBe(
[
"# You are Scout\n\nFind things.",
"# Workspace: Launch\n\nShip by Friday.",
"# Workspace: Ops\n\nServers are on Debian.",
`# Workspace: Launch\n\nYou're working in the workspace "Launch". Follow its context and your instructions for it below, over your general habits where they differ.\n\nThe spring launch.\n\nShip by Friday.`,
"# Your instructions in Launch\n\nOwn the changelog.",
"# Memory\n\n- The user prefers short replies.",
"# Memory in Launch\n\n- Marketing signs off on copy.",
].join("\n\n"),
);
});
test("leaves out empty parts", () => {
test("leaves out empty parts and has no workspace outside one", () => {
expect(
composeBotPrompt({
system_prompt: "Core.",
memory: " ",
workspaces: [
{ name: "Empty", system_prompt: "" },
{ name: null, system_prompt: "Shared." },
],
workspace_bot: { system_prompt: "Ignored." },
}),
).toBe("Core.\n\n# Workspace: Untitled\n\nShared.");
).toBe("Core.");
expect(composeBotPrompt({})).toBe("");
});
test("names an untitled workspace even when it has no context", () => {
expect(composeBotPrompt({ workspace: { name: null } })).toBe(
`# Workspace: Untitled\n\nYou're working in the workspace "Untitled". Follow its context and your instructions for it below, over your general habits where they differ.`,
);
});
});
+38 -8
View File
@@ -1,41 +1,71 @@
type WorkspacePrompt = {
name?: string | null;
description?: string | null;
system_prompt?: string | null;
};
type WorkspaceBotPrompt = {
system_prompt?: string | null;
memory?: string | null;
};
type Params = {
system_prompt?: string | null;
memory?: string | null;
workspaces?: WorkspacePrompt[];
/**
* The workspace the bot is working in, if any.
*/
workspace?: WorkspacePrompt | null;
/**
* The bot's own instructions and memory for that workspace.
*/
workspace_bot?: WorkspaceBotPrompt | null;
};
/**
* The full prompt a bot runs with (markdown): its own core instructions,
* then the shared context of each workspace it's in, then its memory.
* Empty parts are left out.
* then, in a workspace, the workspace's context and the bot's
* instructions there, then its core memory and its memory there. Empty
* parts are left out; the workspace heading always shows, so the bot
* knows where it is.
*/
export default function composeBotPrompt({
system_prompt,
memory,
workspaces = [],
workspace,
workspace_bot,
}: Params) {
const parts: string[] = [];
const name = workspace?.name?.trim() || "Untitled";
if (system_prompt?.trim()) {
parts.push(system_prompt.trim());
}
for (const workspace of workspaces) {
if (!workspace.system_prompt?.trim()) continue;
if (workspace) {
parts.push(
`# Workspace: ${workspace.name?.trim() || "Untitled"}\n\n${workspace.system_prompt.trim()}`,
[
`# Workspace: ${name}`,
`You're working in the workspace "${name}". Follow its context and your instructions for it below, over your general habits where they differ.`,
workspace.description?.trim() || "",
workspace.system_prompt?.trim() || "",
]
.filter(Boolean)
.join("\n\n"),
);
if (workspace_bot?.system_prompt?.trim()) {
parts.push(`# Your instructions in ${name}\n\n${workspace_bot.system_prompt.trim()}`);
}
}
if (memory?.trim()) {
parts.push(`# Memory\n\n${memory.trim()}`);
}
if (workspace && workspace_bot?.memory?.trim()) {
parts.push(`# Memory in ${name}\n\n${workspace_bot.memory.trim()}`);
}
return parts.join("\n\n");
}
+1
View File
@@ -5,6 +5,7 @@ describe("isAdminSectionPath", () => {
test("allows live sections and their sub pages", () => {
expect(isAdminSectionPath({ pathname: "/admin/bots" })).toBe(true);
expect(isAdminSectionPath({ pathname: "/admin/bots/3" })).toBe(true);
expect(isAdminSectionPath({ pathname: "/admin/workspaces/2/bots/1" })).toBe(true);
expect(isAdminSectionPath({ pathname: "/admin/settings/change-password" })).toBe(
true,
);
+16
View File
@@ -0,0 +1,16 @@
import { describe, expect, test } from "bun:test";
import profileImageUrls from "./profile-image-urls";
describe("profileImageUrls", () => {
test("serves a picture privately, with a thumbnail", () => {
expect(profileImageUrls({ media_id: 7 })).toEqual({
src: "/media/private/7",
thumbnail_src: "/media/private/7/thumbnail",
});
});
test("is empty without a picture", () => {
expect(profileImageUrls({ media_id: null })).toEqual({});
expect(profileImageUrls({})).toEqual({});
});
});
+18
View File
@@ -0,0 +1,18 @@
type Params = {
/**
* A bot's or workspace's `image_media_id`.
*/
media_id?: number | string | null;
};
/**
* Where a bot's or workspace's picture is served (a private image, so
* only its owner can load it). Empty when it has none.
*/
export default function profileImageUrls({ media_id }: Params) {
if (!media_id) return {};
const src = `/media/private/${media_id}`;
return { src, thumbnail_src: `${src}/thumbnail` };
}