char-slop/berry

multipurpose self-modifiable agentic harness

git clone https://git.t4t.associates/char-slop/berry

Charlotte Somweb: keep tool elapsed time accurate across navigation86bd162

main
652 B13 linesraw
1import type { Context } from "@earendil-works/chord";
2import { LiveDoc, type ToolExecutionApi } from "@earendil-works/pi-durable";
3
4/** Record when execution starts independently of renderer-specific progress details. */
5export async function startTool(api: ToolExecutionApi, context: Context): Promise<void> {
6  const startedAt = Date.now();
7  await api.commit(async (tx) => {
8    const live = await tx.doc(LiveDoc, api.conversationId);
9    const slot = live.tools?.find((slot) => slot.callId === api.callId);
10    // pi-durable does not yet record a wall-clock start time on the slot
11    if (slot) Object.assign(slot, { startedAt });
12  }, context);
13}