/** * [WHO]: Provides IdleThink state, budget checks, lifecycle cleanup, and exploration loop orchestration * [FROM]: Depends on core extension context types, ./thinker, ./insights, and ./curiosity for exploration side effects * [TO]: Consumed by ./index.ts and idle-think behavior tests * [HERE]: extensions/builtin/idle-think/idle-think-runtime.ts - testable runtime boundary for idle exploration */ import type { ExtensionAPI, ExtensionContext } from "../../../core/extensions-host/types.js"; import { runExploration } from "./thinker.js"; import { storeInsight, loadRecentInsights, projectKeyFromCwd } from "./insights.js"; import { loadCuriosityQueue, saveCuriosityQueue, pickNextTopics, addTopicsFromInsight, extractTopicsFromInsight, markExplored } from "./curiosity.js"; export type IdleThinkState = { lastActivityAt: number; isRunning: boolean; dailyCount: number; dailyResetAt: number; abortController?: AbortController; timer?: ReturnType; }; export type IdleThinkSettings = { enabled?: boolean; idleMinutes?: number; dailyBudget?: number; maxDurationMinutes?: number; }; export type IdleThinkDeps = { runExploration: typeof runExploration; storeInsight: typeof storeInsight; loadRecentInsights: typeof loadRecentInsights; projectKeyFromCwd: typeof projectKeyFromCwd; loadCuriosityQueue: typeof loadCuriosityQueue; saveCuriosityQueue: typeof saveCuriosityQueue; pickNextTopics: typeof pickNextTopics; addTopicsFromInsight: typeof addTopicsFromInsight; extractTopicsFromInsight: typeof extractTopicsFromInsight; markExplored: typeof markExplored; now: () => number; }; export declare const defaultIdleThinkDeps: IdleThinkDeps; export declare function createState(deps?: Pick): IdleThinkState; export declare function startOfToday(now?: Date): number; export declare function touch(state: IdleThinkState, deps?: Pick): void; export declare function getSettings(ctx: ExtensionContext): IdleThinkSettings; export declare function checkBudget(state: IdleThinkState, settings: IdleThinkSettings): boolean; export declare function cleanup(state: IdleThinkState): void; export declare function startIdleLoop(api: ExtensionAPI, ctx: ExtensionContext, state: IdleThinkState, deps?: IdleThinkDeps): void; export declare function maybeRunExploration(api: ExtensionAPI, ctx: ExtensionContext, state: IdleThinkState, deps?: IdleThinkDeps): Promise;