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:
@@ -2,6 +2,7 @@ import bunext from "@moduletrace/bunext";
|
||||
import cronHeartbeat from "./heartbeat";
|
||||
import pruneBotsQueue from "./prune-bots-queue";
|
||||
import cronSyncHarnessModels from "./sync-harness-models";
|
||||
import syncComputers from "./sync-computers";
|
||||
import registerCronJob from "./register-cron-job";
|
||||
|
||||
export default function cron() {
|
||||
@@ -30,4 +31,11 @@ export default function cron() {
|
||||
task: cronSyncHarnessModels,
|
||||
run_on_start: true,
|
||||
});
|
||||
|
||||
registerCronJob({
|
||||
title: "sync-computers",
|
||||
schedule: "*/5 * * * *",
|
||||
task: syncComputers,
|
||||
run_on_start: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import bunext from "@moduletrace/bunext";
|
||||
import BunSQLite from "@moduletrace/bun-sqlite";
|
||||
import type { BUN_SQLITE_COBBLE_COMPUTERS, BUN_SQLITE_COBBLE_CONTAINERS } from "@/db/types/db";
|
||||
import pushComputerUpdate from "@/src/functions/backend/db/computers/push-computer-update";
|
||||
import inspectDockerContainer from "@/src/functions/backend/docker/inspect-docker-container";
|
||||
|
||||
type Row = Pick<BUN_SQLITE_COBBLE_CONTAINERS, "id" | "docker_id" | "status"> &
|
||||
Pick<BUN_SQLITE_COBBLE_COMPUTERS, "user_id"> & { computer_id: number };
|
||||
|
||||
/**
|
||||
* Reads every computer container's state from docker and records it
|
||||
* (`containers.status`, `last_seen_at`), telling owners about changes. A
|
||||
* container docker no longer has shows as `dead`. Containers still being
|
||||
* set up, or that failed, are left alone.
|
||||
*/
|
||||
export default async function syncComputers() {
|
||||
const rows =
|
||||
(
|
||||
await BunSQLite.sql<Row>({
|
||||
sql: `SELECT co.id, co.docker_id, co.status, c.user_id, c.id AS computer_id
|
||||
FROM containers co JOIN computers c ON c.container_id = co.id
|
||||
WHERE co.docker_id IS NOT NULL AND co.status NOT IN ('creating', 'failed')`,
|
||||
})
|
||||
).payload || [];
|
||||
|
||||
let changed = 0;
|
||||
|
||||
for (const row of rows) {
|
||||
const state = await inspectDockerContainer({ container: row.docker_id! }).catch(() => undefined);
|
||||
|
||||
if (state === undefined) continue;
|
||||
|
||||
const status = state?.status || "dead";
|
||||
|
||||
await BunSQLite.sql({
|
||||
sql: `UPDATE containers SET status = ?, last_seen_at = ?, updated_at = ? WHERE id = ?`,
|
||||
values: [status, Date.now(), Date.now(), row.id!],
|
||||
});
|
||||
|
||||
if (status != row.status) {
|
||||
changed++;
|
||||
await pushComputerUpdate({ computer_id: row.computer_id }).catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
bunext.bunextLog.info(`Cron: ${rows.length} computer(s) checked, ${changed} changed`);
|
||||
}
|
||||
Reference in New Issue
Block a user