58 lines
2.4 KiB
TypeScript
58 lines
2.4 KiB
TypeScript
/** Hands-off goals in the browser: the goal the user put the standing agent on, and every decision it took for them. Browser-safe. */
|
|
import { actionRef, docRef } from '../goal/compat.ts'
|
|
|
|
/** One decision the standing agent took instead of asking the user. */
|
|
export type Decision = {
|
|
at: number
|
|
/** What it would have asked the user. */
|
|
question: string
|
|
/** What it chose. */
|
|
picked: string
|
|
reason: string
|
|
/** The branch the decision was for. */
|
|
conversation?: number
|
|
/** The entry of the standing agent's conversation holding the screenshots it judged, such as a UI preview it approved. */
|
|
images?: number
|
|
}
|
|
|
|
/** How a goal ended: met, blocked (every remaining criterion stuck), or ended by the user. */
|
|
export type Ending = {
|
|
at: number
|
|
by: 'user' | 'standing'
|
|
outcome: 'met' | 'blocked' | 'ended'
|
|
summary?: string
|
|
}
|
|
|
|
/** What "done" means, as the standing agent wrote it down: each criterion open, met, or blocked after repeated failed tries. */
|
|
export type Criterion = { text: string; status: 'open' | 'met' | 'blocked'; tries?: number }
|
|
|
|
export type Goal = {
|
|
id: number
|
|
/** The user's words: what to reach, and when to stop if they said so. */
|
|
text: string
|
|
startedAt: number
|
|
criteria: Criterion[]
|
|
decisions: Decision[]
|
|
/** The "Goal reminder" automation that wakes the standing agent every 30 minutes while the goal is open. */
|
|
reminder?: string
|
|
/** Set while the standing agent is blocked on the user: the reminder is paused until it resumes. */
|
|
waiting?: { reason: string; at: number }
|
|
ended?: Ending
|
|
}
|
|
|
|
/** `{ next, goals }` on conversation 1, oldest first; at most one goal is open (no `ended`). */
|
|
export const GoalDoc = docRef<{ next: number; goals: Goal[] }>('goal')
|
|
|
|
/** `goal.started` and `goal.report` entries in the standing agent's conversation name their goal. */
|
|
export type GoalEntry = { goal: number }
|
|
|
|
/** `{ text }` → the new goal. User-only: puts the standing agent hands-off on it. */
|
|
export const StartAction = actionRef<{ text: string }, Goal>('goal', 'start')
|
|
/** No arguments → the ended goal. User-only: ends the open goal; the standing agent asks again as usual. */
|
|
export const EndAction = actionRef<null, Goal>('goal', 'end')
|
|
/** `{ goal, entry }` → the images of a decision's screenshot entry. */
|
|
export const ImagesAction = actionRef<
|
|
{ goal: number; entry: number },
|
|
{ data: string; mimeType: string }[]
|
|
>('goal', 'images')
|