import type { SessionResult } from "./session-runner.js"; export interface SimpleSubagentsConfig { confirmWrites: boolean; allowThinkingOverrides: boolean; } export type SessionState = "opening" | "open" | "closing" | "closed" | "failed"; export type WorkState = "queued" | "running" | "cancelling" | "completed" | "waiting_for_parent" | "cancelled" | "failed"; export type ResultState = "none" | "ready" | "collected" | "discarded"; export type AccessMode = "read-only" | "write"; export type ReportKind = "progress" | "help_request"; /** Maximum recent non-live closed or failed session records retained by the manager. */ export const SESSION_TOMBSTONE_MAX_ITEMS = 64; export const TASK_MAX_BYTES = 32 * 1024; export const REPORT_MAX_BYTES = 4 * 1024; export const REPORT_ID_MAX_BYTES = 256; export const REPORT_INBOX_MAX_BYTES = 50 * 1024; export const REPORT_INBOX_MAX_ITEMS = 128; export const REPORT_RECORD_FIXED_BYTES = 64; export const REPORT_DEDUPE_MAX_ITEMS = 512; export const REPORT_DEDUPE_MAX_BYTES = 16 * 1024; export const STATUS_ACTIVITY_LIMIT = 3; export const STATUS_ACTIVITY_MAX_BYTES = 256; export const RESULT_PREVIEW_MAX_BYTES = 1_024; export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const; export type ThinkingLevel = (typeof THINKING_LEVELS)[number]; export type LaunchThinkingSource = | "job" | "profile" | "parent" | "model_or_pi_default"; export interface AgentProfile { name: string; description: string; systemPrompt: string; tools?: string[]; model?: string; thinking?: ThinkingLevel; source: "builtin" | "user"; filePath?: string; } export interface JobRequest { task: string; agent: string; writeAccess: boolean; cwd?: string; model?: string; thinkingLevel?: ThinkingLevel; } export interface SubagentActivity { type: "model" | "tool" | "diagnostic"; text: string; timestamp: number; } export interface SubagentGeneration { number: number; state: WorkState; resultState: ResultState; /** Safe telemetry retained after the full result is collected or discarded. */ usage: UsageStats; /** Manager-owned, terminal-safe activity labels for only this generation. */ activity: SubagentActivity[]; /** Model identity reported by child telemetry, not the requested launch model. */ reportedModel?: string; /** Bounded terminal-safe output metadata retained only after collection. */ resultPreview?: string; result?: SessionResult; createdAt: number; startedAt?: number; finishedAt?: number; } export interface SubagentReport { sessionId: string; generation: number; reportId: string; kind: ReportKind; message: string; timestamp: number; } export interface SubagentSessionProfile { /** Safe agent identity retained after launch-private profile data is released. */ name: string; } export interface SubagentSession { id: string; request: JobRequest; profile: SubagentSessionProfile; state: SessionState; createdAt: number; openedAt?: number; failedAt?: number; errorMessage?: string; pendingHelpReportId?: string; pendingHelpQuestion?: string; reports: SubagentReport[]; /** UTF-8 record bytes retained across report messages, IDs, session IDs, and fixed metadata. */ reportBytes: number; omittedReports: number; generation: SubagentGeneration; launchModel?: string; launchThinkingLevel?: ThinkingLevel; launchThinkingSource?: LaunchThinkingSource; } export interface UsageStats { input: number; output: number; cacheRead: number; cacheWrite: number; cost: number; turns: number; } export interface TextTruncation { originalBytes: number; keptBytes: number; }