Files
cobble/src/bots-queue/types.ts
T
tbenandClaude Opus 5.5 d7f88d8dd3 Keep a record of each run's tool calls so bots can't claim work they never did
The wrap-up turn now gets the run's actual tool calls, each bot message
keeps them as bot_messages.tool_log, and history follows recorded bot
messages with an [App record] line. The coordinator also gets update_bot
in workspaces, so it can fill a bot's core prompt from there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 11:32:56 +01:00

57 lines
1.8 KiB
TypeScript

import type { BUN_SQLITE_COBBLE_BOTS_QUEUE } from "@/db/types/db";
import type { TextLoopStep } from "@/src/harness/text/run-text-loop";
import type { HarnessToolUse } from "@/src/harness/types";
export type BotJobContext = {
job: BUN_SQLITE_COBBLE_BOTS_QUEUE;
params: Record<string, unknown>;
/**
* Saved by an earlier attempt, if the job was picked up again.
*/
checkpoint: Record<string, unknown> | null;
/**
* Aborted when the job is cancelled or lost to another handler. Stop
* work and return; the result is discarded.
*/
signal: AbortSignal;
/**
* Save progress and a checkpoint. The lock is renewed on a timer
* already, so call this for meaningful steps. False once the job is
* cancelled or lost.
*/
update: (params: {
progress?: string;
checkpoint?: Record<string, unknown>;
}) => Promise<boolean>;
/**
* Records a model turn as a step (`bots_queue_updates`), saves it as
* the job's progress and pushes it live. Pass it as the text loop's
* `onStep`. Best effort: a failed write never stops the job.
*/
report: (step: TextLoopStep) => Promise<void>;
};
export type BotJobOutcome = {
/**
* The completion message for the user (markdown).
*/
result: string;
needs_you?: boolean;
/**
* Finish without posting `result` (a reply with nothing left to answer).
*/
silent?: boolean;
/**
* Files the bot wrote and asked to send with its message (`media`
* ids), attached to the result message.
*/
attachments?: number[];
/**
* Every tool call the run made (`runTextLoop`'s `tool_uses`), kept on
* the result message as `tool_log`.
*/
tool_log?: HarnessToolUse[];
};
export type BotJobRunner = (context: BotJobContext) => Promise<BotJobOutcome>;