import type { Span } from '@opentelemetry/api'; import type { WorkingStateManager } from '../../compaction/manager.js'; import type { Sandbox } from '../../types/sandbox/index.js'; import type { SessionEvent } from '../../types/session/index.js'; import { type PromoteMemory } from '../../types/session/memory-promotion.js'; import type { AwaitedJobs } from '../jobs/awaited-jobs.js'; import type { BackgroundJobRegistry } from '../jobs/registry.js'; import type { TurnContext } from './context.js'; import type { EventTranslator } from './events.js'; import type { QuestionParkBinding } from './question-park.js'; /** * Everything a turn borrows, handed back when it ends. * * A turn attaches to process-wide things it does not own — a * shared background-job registry, a question channel a tool outlived, a task * store's listener, a sandbox — and every one of them has to be released on * the way out, including the exits a `try` never reaches. So this is the body * of `query()`'s `finally`: the keyword stays where it is, which is what makes * abandonment run this just as settlement does. * * The order is the contract, and the awaits are in it: unsubscribe from job exits, close the wait-intent recorder, kill * only this turn's jobs, unbind the question channel, promote what the turn * learned, tear the sandbox down, unsubscribe from the task store, record the * duration under the status the turn actually settled with, and end the root * span last. */ export interface TurnResources { readonly ctx: TurnContext; readonly eventTranslator: EventTranslator; readonly unsubscribeJobExits: (() => void) | undefined; readonly unsubscribeTaskStore: (() => void) | undefined; readonly awaitedJobs: AwaitedJobs | undefined; /** Jobs a host bound to its session are the host's to stop, not this turn's. */ readonly backgroundJobs: BackgroundJobRegistry | undefined; readonly backgroundJobOwner: string | undefined; readonly questionParks: QuestionParkBinding; readonly workingStateManager: WorkingStateManager | undefined; readonly promoteMemory: PromoteMemory | undefined; readonly sandbox: Sandbox | undefined; readonly sandboxTeardownTimeoutMs: number; readonly runStartedAt: number; readonly rootSpan: Span; } /** * Release them, in that order. * * A generator rather than a plain async function because the sandbox teardown * reports `sandbox_destroyed`, and that event has to reach the host at the * position it always did — `yield*` from the caller's `finally` keeps it * exactly there. */ export declare function releaseTurnResources(resources: TurnResources): AsyncGenerator; //# sourceMappingURL=release-turn.d.ts.map