- 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]>
90 lines
3.0 KiB
TypeScript
90 lines
3.0 KiB
TypeScript
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 workspace the caller has checked belongs to the session user. Then
|
|
* the settings shown are the workspace's own, over what it inherits:
|
|
* the bot's (when given) or the defaults.
|
|
*/
|
|
workspace_id?: number;
|
|
};
|
|
|
|
/**
|
|
* A worker bot's (or a workspace's) model settings: per harness, its own
|
|
* setting (or what it inherits), the models it can pick, what it runs on
|
|
* now, and what it would run on without its own setting.
|
|
*/
|
|
export default async function grabBotHarnessOverview({
|
|
bot_id,
|
|
workspace_id,
|
|
}: Params): Promise<BotHarnessOverviewPayload> {
|
|
/**
|
|
* In a workspace, "the default" is what a run there gets without the
|
|
* workspace's own setting: the bot's, else the defaults.
|
|
*/
|
|
const inherited_bot_id = workspace_id ? bot_id : undefined;
|
|
|
|
const [own, defaults] = await Promise.all([
|
|
Promise.all(
|
|
Harnesses.map((harness) =>
|
|
grabHarnessSetting({
|
|
harness: harness.value,
|
|
bot_id: workspace_id ? undefined : bot_id,
|
|
workspace_id,
|
|
}),
|
|
),
|
|
),
|
|
Promise.all(
|
|
Harnesses.map((harness) =>
|
|
grabHarnessSetting({ harness: harness.value, bot_id: inherited_bot_id }),
|
|
),
|
|
),
|
|
]);
|
|
|
|
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,
|
|
workspace_id,
|
|
}),
|
|
grabHarnessOverviewItem({
|
|
harness: setting.harness,
|
|
setting: defaults[index]!,
|
|
entries,
|
|
bot_id: inherited_bot_id,
|
|
}),
|
|
]);
|
|
|
|
return {
|
|
...item,
|
|
inherit: setting.source == "default",
|
|
default: {
|
|
enabled: default_item.enabled,
|
|
current: default_item.current,
|
|
candidate_count: default_item.candidate_count,
|
|
},
|
|
};
|
|
}),
|
|
),
|
|
};
|
|
}
|