- get op now returns paused goals (was returning null when enabled=false) - complete op now works on paused goals; previously required enabled=true which always failed after an interrupt set enabled=false - create op now allowed after previous goal status is 'complete'; was incorrectly blocked by the same guard as 'dropped' check - goal tool is re-added to the active tool set on session reload when a paused/active goal is persisted to disk; sdk.ts:1599 excludes 'goal' from initial active tools unconditionally, so restoreModeFromSession now re-adds it and saves #goalModePreviousTools for later cleanup - goal_updated event for 'dropped' status now triggers #exitGoalMode before clearing goalModeEnabled, ensuring the previous tool set is restored when the agent drops a goal via the tool - added 'resume' and 'drop' ops to goal tool schema and execute path - updated goal.md prompt to document new ops and the paused-goal workflow Fixes #1249
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import type { UsageStatistics } from "../session/session-manager";
|
|
|
|
export type GoalStatus = "active" | "paused" | "budget-limited" | "complete" | "dropped";
|
|
|
|
export interface Goal {
|
|
id: string;
|
|
objective: string;
|
|
status: GoalStatus;
|
|
tokenBudget?: number;
|
|
tokensUsed: number;
|
|
timeUsedSeconds: number;
|
|
createdAt: number;
|
|
updatedAt: number;
|
|
}
|
|
|
|
export interface GoalModeState {
|
|
enabled: boolean;
|
|
mode: "active" | "exiting";
|
|
reason?: "completed";
|
|
goal: Goal;
|
|
}
|
|
|
|
export interface GoalToolDetails {
|
|
op: "create" | "get" | "complete" | "resume" | "drop";
|
|
goal?: Goal | null;
|
|
remainingTokens?: number | null;
|
|
completionBudgetReport?: string | null;
|
|
}
|
|
|
|
export type GoalRuntimeEvent =
|
|
| { type: "goal_updated"; goal: Goal | null; state?: GoalModeState }
|
|
| { type: "goal_continuation_requested"; prompt: string };
|
|
|
|
export type GoalTokenUsage = Pick<UsageStatistics, "input" | "output" | "cacheRead" | "cacheWrite">;
|
|
|
|
export type GoalBudgetSteering = "allowed" | "suppressed";
|
|
export type GoalTerminalMetricEmission = "emit" | "suppress";
|