/** * Runner session metadata. * * Holds only what the runner needs to resume the agent driver across * process restarts — notably `driverSessionId` for SDK session resume. * * Flow execution state (per-node status, approvals, outputs) moved out * of the session file in Phase 2 of the flow-execution plan. It now * lives in the FlowAdapter's in-memory snapshot and, for hosts that * persist it, in whatever durable store they provide (the Skaile * platform uses the `FlowExecution` Prisma table). The runner does * not read or write flow state from disk. * @docLink packages/runner/session#session-state */ export interface SessionState { /** Unique identifier for this session run (UUID). */ runId: string; /** ID of the flow definition being executed. */ flowId: string; /** Absolute path to the project directory. */ projectDir: string; /** * Absolute path to the agent definition directory (`agent.yaml`, * `SOUL.md`, `RULES.md`, `knowledge/`). Resolved from `skaile.yaml` * via `resolveAgentDir` when absent at session creation time. */ agentDir?: string; /** Agent driver backend used for this session (e.g. `"omp"`, `"claude-sdk"`). */ driver: string; /** LLM provider (if set), e.g. `"anthropic"` or `"openrouter"`. */ provider?: string; /** Model name (if set), e.g. `"claude-opus-4-5"`. */ model?: string; /** Provider-native session/thread identifier for resume support. */ driverSessionId?: string; /** ISO 8601 timestamp when the session was created. */ startedAt: string; /** ISO 8601 timestamp of the last state change. */ updatedAt: string; /** Optional human-readable label for the session */ label?: string; /** Session lifecycle status. */ status?: "running" | "complete" | "failed" | "paused"; } /** * Load the current (most recently active) session for a project. * * Reads the `/.skaile/current` pointer file and loads the * corresponding session. Auto-migrates the legacy flat `session.json` * format to the per-run `sessions/.json` layout on first call. * * @param projectDir - Absolute path to the project directory. * @returns The current session or `null` if no session exists. * @docLink packages/runner/session#load-session */ export declare function loadSession(projectDir: string): Promise; /** * Load a specific session by its run ID. * * @param projectDir - Absolute path to the project directory. * @param runId - The UUID of the session to load. * @returns The session state or `null` if not found. * @docLink packages/runner/session#load-session-by-id */ export declare function loadSessionById(projectDir: string, runId: string): Promise; /** * List all sessions for a project. * * Auto-migrates the legacy flat `session.json` format on first call. * Corrupt or unreadable session files are silently skipped. * * @param projectDir - Absolute path to the project directory. * @returns All sessions sorted by `updatedAt` descending (newest first). * @docLink packages/runner/session#list-sessions */ export declare function listSessions(projectDir: string): Promise; /** * Persist a session to `/.skaile/sessions/.json`. * * @param projectDir - Absolute path to the project directory. * @param state - Session state to write. * @param setCurrent - When `true` (default), updates the `current` pointer * file so subsequent {@link loadSession} calls return this session. * @docLink packages/runner/session#save-session */ export declare function saveSession(projectDir: string, state: SessionState, setCurrent?: boolean): Promise; /** * Set the current session pointer to an existing session. * * @param projectDir - Absolute path to the project directory. * @param runId - The UUID of the session to make current. * @throws {Error} When no session with the given `runId` exists. * @docLink packages/runner/session#set-current-session */ export declare function setCurrentSession(projectDir: string, runId: string): Promise; /** * Delete a session file by run ID. * * If the deleted session was the current session, the `current` pointer * file is also removed. Missing session files are silently ignored. * * @param projectDir - Absolute path to the project directory. * @param runId - The UUID of the session to delete. * @docLink packages/runner/session#delete-session */ export declare function deleteSession(projectDir: string, runId: string): Promise; /** * Unset the current session pointer without deleting the session file. * * After calling this, {@link loadSession} returns `null` until a new * session is saved or {@link setCurrentSession} is called. * * @param projectDir - Absolute path to the project directory. * @docLink packages/runner/session#clear-session */ export declare function clearSession(projectDir: string): Promise; /** * Create a new {@link SessionState} with a fresh UUID and current timestamps. * * The returned session has `status: "running"` and both `startedAt` and * `updatedAt` set to the current ISO 8601 time. Caller is responsible for * persisting it via {@link saveSession}. * * @param opts - All session fields except `runId`, `startedAt`, `updatedAt`, * and `status` (which are generated automatically). * @returns A fully initialized session state ready to be saved. * @docLink packages/runner/session#new-session */ export declare function newSession(opts: Omit): SessionState; /** * Update a session's `updatedAt` timestamp without changing any other field. * Used by callers that persist a session mid-run to refresh the staleness clock. * * @param state - Current session state * @returns New session state with updated timestamp * @docLink packages/runner/session#touch-session */ export declare function touchSession(state: SessionState): SessionState; //# sourceMappingURL=session.d.ts.map