Add the harness, envs, per-bot models and chat attachments

- Harness: providers, model catalog synced hourly, automatic free picks,
  cooldowns, tool loop with context trimming, MCP computer tools
- Bots queue runs replies and tasks through the harness; jobs wait
  (attempt refunded) while every model is resting
- Envs: Settings > Environment, scoped general/workspace/computer,
  written to computers and redacted from tool output
- Models: Settings > Models, per-harness provider select defaulting to
  OpenRouter, and a models modal on each bot's chat (the coordinator's
  edits the defaults)
- Chat: thinking row while a reply runs, file attachments (upload,
  paste, drop) that replies read as images, audio and document text
- Fix media uploads failing after a user's first file, and private
  files being served from the public media path

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-19 03:38:38 +01:00
co-authored by Claude Opus 5.5
parent d49f524fe8
commit 6a2665dae9
223 changed files with 12342 additions and 162 deletions
@@ -1,22 +1,32 @@
import type {
BUN_SQLITE_COBBLE_BOT_MESSAGES,
BUN_SQLITE_COBBLE_MEDIA,
BunSQLiteTables,
} from "@/db/types/db";
import type { BotMessageWithAttachments } from "@/src/types";
import BunSQLite from "@moduletrace/bun-sqlite";
import mediaToAttachment from "./media-to-attachment";
type Params = {
bot_id: number;
text: string;
/**
* Files to attach, already checked to be the user's own
* (`grabAttachableMedia`).
*/
media?: BUN_SQLITE_COBBLE_MEDIA[];
};
/**
* Appends a user message to a bot's conversation and bumps its activity.
* Callers must check the bot belongs to the session user first.
* Appends a user message (and its files) to a bot's conversation and
* bumps its activity. Callers must check the bot belongs to the session
* user first.
*/
export default async function insertUserMessage({
bot_id,
text,
}: Params): Promise<BUN_SQLITE_COBBLE_BOT_MESSAGES> {
media = [],
}: Params): Promise<BotMessageWithAttachments> {
const now = Date.now();
const res = await BunSQLite.insert<
@@ -33,6 +43,13 @@ export default async function insertUserMessage({
throw new Error(`Failed to save message: ${res.msg}`);
}
for (const file of media) {
await BunSQLite.sql({
sql: `INSERT INTO bot_message_media (created_at, updated_at, message_id, media_id) VALUES (?, ?, ?, ?)`,
values: [now, now, id, file.id!],
});
}
await BunSQLite.sql({
sql: `UPDATE bots SET last_activity_at = ? WHERE id = ?`,
values: [now, bot_id],
@@ -46,5 +63,6 @@ export default async function insertUserMessage({
needs_you: 0,
created_at: now,
updated_at: now,
attachments: media.map((file) => mediaToAttachment({ media: file })),
};
}