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
@@ -0,0 +1,61 @@
import { Harnesses } from "@/src/dict/harness-dict";
import type { BotHarnessOverviewPayload } from "@/src/types";
import grabHarnessModelEntries from "./grab-harness-model-entries";
import grabHarnessOverviewItem from "./grab-harness-overview-item";
import grabHarnessSetting from "./grab-harness-setting";
type Params = {
/**
* A worker bot the caller has checked belongs to the session user.
*/
bot_id: number;
};
/**
* A worker bot's model settings page: per harness, the bot's own setting
* (or the default it inherits), the models it can pick, what it runs on
* now, and what the default runs on.
*/
export default async function grabBotHarnessOverview({
bot_id,
}: Params): Promise<BotHarnessOverviewPayload> {
const [own, defaults] = await Promise.all([
Promise.all(
Harnesses.map((harness) => grabHarnessSetting({ harness: harness.value, bot_id })),
),
Promise.all(
Harnesses.map((harness) => grabHarnessSetting({ harness: harness.value })),
),
]);
const entries = await grabHarnessModelEntries({
pinned_ids: [...own, ...defaults].flatMap((setting) =>
setting.model_id ? [setting.model_id] : [],
),
});
return {
harnesses: await Promise.all(
own.map(async (setting, index) => {
const [item, default_item] = await Promise.all([
grabHarnessOverviewItem({ harness: setting.harness, setting, entries, bot_id }),
grabHarnessOverviewItem({
harness: setting.harness,
setting: defaults[index]!,
entries,
}),
]);
return {
...item,
inherit: setting.source == "default",
default: {
enabled: default_item.enabled,
current: default_item.current,
candidate_count: default_item.candidate_count,
},
};
}),
),
};
}