Let bots set a picture from a file they can see
A coordinator asked to set an uploaded logo as a workspace picture could not: the picture tools take a media id, and nothing ever gave the bot one. Attachments reached the model as "[Attached image \"logo.png\"]", every file tool answers with a [file:ID] ref, and an SVG is deliberately stored as a document rather than an image. - copyMediaAsPicture copies an approved image into a new picture row (bot-image/workspace-image). The source keeps its row and bytes, so a message that attached it still loads and changing a picture can never take a file away from a conversation. - grabPictureSource resolves a picture by [file:ID] (the same scope gate every file tool uses) or by the user's own upload; parseFileRef reads the [file:12] form. - The new set_picture tool ships on every run: a bot sets its own face, the coordinator can also dress a worker. update_workspace gained picture_file_id, and setBotPicture/setProfileImage share the copy and the delete. - removeReplacedPicture deletes a replaced picture only when it really is one, never a chat upload. - uploadAndRecordMedia writes images in their own format: PNG stays PNG with its transparency, WebP stays WebP, GIF becomes PNG, everything else JPEG, and the row records the real mime type (it used to say jpeg for every image). - Pictures change live: BotUpdatedData carries image_media_id and a new server:workspace-updated pushes workspace pictures, relayed between processes. - Attachments are labelled with their media id, and BotFilesNote tells a bot that a [file:ID] can become a picture. - grabRunScopes is now the single source of a run's reachable folders, shared by the file tools, imports and the picture tools.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { BUN_SQLITE_COBBLE_BOTS, BUN_SQLITE_COBBLE_COMPUTERS } from "@/db/types/db";
|
||||
import grabBotComputers from "@/src/functions/backend/db/computers/grab-bot-computers";
|
||||
import grabCrewWorkers from "@/src/functions/backend/db/bots/grab-crew-workers";
|
||||
import type { StorageScope } from "@/src/utils/storage-access";
|
||||
import type { HarnessTool } from "../../types";
|
||||
import askToTakeOverTool from "../computer/ask-to-take-over-tool";
|
||||
import searchComputersTool from "../computer/search-computers-tool";
|
||||
@@ -41,6 +42,11 @@ type Params = {
|
||||
* The user message being answered.
|
||||
*/
|
||||
message_id?: number | string;
|
||||
/**
|
||||
* The files the run reaches (`grabRunScopes`), so a picture it sets is
|
||||
* copied from one it can already read.
|
||||
*/
|
||||
scopes?: StorageScope[];
|
||||
/**
|
||||
* Called when the bot asks the user to take over a computer.
|
||||
*/
|
||||
@@ -70,6 +76,7 @@ export default async function grabBotChatTools({
|
||||
session_id,
|
||||
workspace_id,
|
||||
message_id,
|
||||
scopes = [],
|
||||
onTakeOver,
|
||||
}: Params): Promise<HarnessTool[]> {
|
||||
const bot_id = bot.id || 0;
|
||||
@@ -81,6 +88,7 @@ export default async function grabBotChatTools({
|
||||
computers,
|
||||
session_id,
|
||||
is_coordinator: bot.kind == "coordinator",
|
||||
scopes,
|
||||
})),
|
||||
startTaskTool({
|
||||
user_id,
|
||||
@@ -104,7 +112,7 @@ export default async function grabBotChatTools({
|
||||
tools.push(createWorkspaceTool({ user_id, workspaces }));
|
||||
|
||||
if (workspaces.length) {
|
||||
tools.push(updateWorkspaceTool({ user_id, workspaces, workspace_id }));
|
||||
tools.push(updateWorkspaceTool({ user_id, workspaces, workspace_id, scopes }));
|
||||
}
|
||||
|
||||
tools.push(createBotTool({ user_id, workspaces, workspace_id }));
|
||||
|
||||
Reference in New Issue
Block a user