Files
cobble/src/bots-queue/task-request-note.ts
T
tben 7edb5432c2 Make send_reply the only way a reply ends
A reply's prose alone was delivered as its answer, so a bot could say work had started when nothing was queued. Replies and task reports now close with send_reply({status, work?}): bare text is a draft, working must queue work or follow a real run, and queued work is cancelled with an unsent message. The review reads the declared status, and a task report no longer counts its own job as open work.
2026-11-19 10:29:15 +01:00

35 lines
1.4 KiB
TypeScript

import type { BUN_SQLITE_COBBLE_BOT_MESSAGES } from "@/db/types/db";
/**
* The user's own words that asked for a task run, put in front of the
* bot's brief (`runBotTask`).
*
* A task run opens with the brief its bot wrote for itself
* (`composeJobBrief`), so the request was only in the run if the bot
* repeated it there: one that shortened it away left its run with the
* goal and no route, and the run reached the same result by a way the
* user didn't ask for (a PNG to "layered PSD", locally, when they said to
* use their ArtCraft MCP). The message that asked for the work is on the
* job (`bots_queue.message_id`, from `send_reply`'s work or `start_task`), so the run reads the
* request itself, and `TaskRunNote` says the words win over the brief.
*
* Empty for a message the user didn't write (a crew message that asked
* for the work, an app notice) and for one with no text.
*/
export default function taskRequestNote({
message,
}: {
message?: Pick<BUN_SQLITE_COBBLE_BOT_MESSAGES, "author" | "text"> | null;
}) {
if (message?.author !== "user") return "";
const text = (message.text || "").trim();
if (!text) return "";
return `# What the user asked for
This is the request itself, as they wrote it. The brief below it is your own summary: where they disagree these words win, and the way they named is the way it is done.
${text}`;
}