/** * Leaf context keys — no codec, no runtime imports. Safe to import from any * tier. Codec-carrying keys (`ChannelKey`, `BundleKey`) live in * `#runtime/sessions/runtime-context-keys.ts`. */ import type { LanguageModel, ModelMessage, SystemModelMessage } from "ai"; import type { ChannelDeliveryMetadata, ChannelInstrumentationProjection, SessionAuthContext, SessionCallback, SessionCapabilities, SessionParent, SessionTraceContext, SessionTraceRoot, SessionTurn } from "#channel/types.js"; import { ContextKey } from "#context/key.js"; import { type StubScope } from "#tool-stubs/types.js"; import { type SessionInboxAddress } from "#execution/session-inbox/address.js"; import type { LegacyRemoteAgentCaller } from "#execution/legacy-remote-agent/protocol.js"; import type { InstrumentationChannelDeliveryRef } from "#instrumentation/lifecycle.js"; import type { UserModelMessage } from "#harness/messages.js"; import type { HandleEventFn } from "#harness/types.js"; import type { PersistedDynamicToolMetadata } from "#context/dynamic-tool-metadata.js"; import type { DynamicSubagentAgentConfig } from "#runtime/subagents/dynamic-agent-config.js"; import type { DynamicRemoteAgentConfig } from "#runtime/subagents/dynamic-remote-agent-config.js"; import type { SandboxAccess, SandboxSessionEndReason } from "#sandbox/state.js"; import type { HistoryViewProjector } from "#shared/history-view.js"; import type { RuntimeModelReference } from "#runtime/agent/bootstrap.js"; import type { PreparedRuntimeDelegationTool } from "#runtime/sessions/turn.js"; import type { MemoryScope, MemoryTurnContext } from "#public/memory/index.js"; import type { SessionPredecessor } from "#protocol/message.js"; export type { SessionAuthContext, SessionParent, SessionTraceRoot, SessionTurn, } from "#channel/types.js"; export type { SessionPredecessor } from "#protocol/message.js"; /** * Auth metadata on the active session. * * `current` is the caller of the most recent request. * `initiator` is the caller who originally created the session. */ export interface SessionAuth { readonly current: SessionAuthContext | null; readonly initiator: SessionAuthContext | null; } /** * Internal session metadata seeded into the context container under * {@link SessionKey}. * * This is not the shape authored code observes. Tools, hooks, and channel * events receive the `SessionContext.session` projection (via `ctx.session`), * whose session id is exposed as `id`, not `sessionId`. */ export interface Session { readonly auth: SessionAuth; readonly parent?: SessionParent; readonly predecessor?: SessionPredecessor; readonly sessionId: string; readonly turn: SessionTurn; } export declare const AuthKey: ContextKey; export declare const ToolStubsKey: ContextKey; export declare const InitiatorAuthKey: ContextKey; export declare const SessionIdKey: ContextKey; export declare const ConversationIdKey: ContextKey; export declare const SessionInboxKey: ContextKey; export declare const ContinuationTokenKey: ContextKey; /** Every channel continuation address requested for this session, in claim order. */ export declare const ContinuationHookTokensKey: ContextKey; export declare const ChannelRequestIdKey: ContextKey; /** * Dev-host-verified originating-client metadata, valid only for the current * host secret. It carries the inherited dev-TUI hint, not editing authority. */ export interface LocalDevRequestProvenance { readonly address: string; readonly interactiveClient: boolean; readonly signature: string; } export declare const LocalDevRequestKey: ContextKey; export declare const OccurrenceIdKey: ContextKey; /** Authored schedule whose dispatch created this session. */ export declare const ScheduleIdKey: ContextKey; export declare const ScheduleInstanceKey: ContextKey; /** Display title derived from the session's initial input. */ export declare const SessionTitleKey: ContextKey; export declare const ChannelDeliveryKey: ContextKey; /** Accepted messages whose response owns the current turn's durable stream events. */ export declare const TurnDeliveryIdsKey: ContextKey; /** Last framework announcements recorded in the retained session history. */ export interface HistoryState { /** Last announced value per keyed announcement (see `#harness/announcements.js`). */ readonly announcements?: Readonly>; } export declare const HistoryStateKey: ContextKey; export interface ActiveChannelDelivery { readonly traceSessionId: string; readonly agentName?: string; readonly channelType?: string; readonly delivery: InstrumentationChannelDeliveryRef; readonly policyAgentName?: string; readonly rootSessionId: string; readonly sequence: number; readonly sessionId: string; readonly turnId: string; } export declare const ActiveChannelDeliveriesKey: ContextKey; export declare const ChannelInstrumentationKey: ContextKey; export declare const ParentSessionKey: ContextKey; /** Set only on a session eve started in place of one that could no longer run. */ export declare const SessionPredecessorKey: ContextKey; /** Set only when the trace root differs from `ParentSessionKey`'s root; see {@link SessionTraceRoot}. */ export declare const TraceRootKey: ContextKey; /** Separate from {@link ParentSessionKey} so it stays out of what extensions read. */ export declare const ParentTraceContextKey: ContextKey; export type SessionTraceSeed = SessionTraceContext; export declare const SessionTraceSeedKey: ContextKey; export declare const OtelTraceEnabledKey: ContextKey; /** * Session-level capability flags (see {@link SessionCapabilities}). Set * on root runs by channel routes and inherited pointwise by subagent * dispatch so HITL readiness flows through a conversation chain. */ export declare const CapabilitiesKey: ContextKey; /** * Optional framework-owned caller callback captured when the session is created. */ export declare const SessionCallbackKey: ContextKey; /** Present when a remote agent protocol 1 caller created the session. */ export declare const LegacyRemoteAgentCallerKey: ContextKey; export declare const SessionKey: ContextKey; export declare const SandboxKey: ContextKey; export declare const SandboxTerminalCleanupKey: ContextKey<(reason: SandboxSessionEndReason) => Promise>; export declare const HandleEventKey: ContextKey; /** Static model configured for the effective turn agent, or `null` for a dynamic-only agent. */ export declare const StaticModelReferenceKey: ContextKey | null>; /** Session-scoped dynamic model selection (from `session.started`). */ export declare const SessionDynamicModelReferenceKey: ContextKey | null>; /** Turn-scoped dynamic model selection (from `turn.started`). */ export declare const TurnDynamicModelReferenceKey: ContextKey | null>; export interface CachedModelMetadata { readonly contextWindowTokens: number; readonly expiresAt: number; readonly maxOutputTokens?: number; readonly resolvedModelId: string; } /** Successful runtime catalog selections cached in durable workflow state. */ export declare const RuntimeModelMetadataCacheKey: ContextKey>>; export interface LiveDynamicModelSelection { /** Live provider instance; absent for string selections, which resolve through the reference. */ readonly model?: LanguageModel; readonly reference: RuntimeModelReference; } /** Virtual step-scoped dynamic model selection (from `step.started`); never serialized. */ export declare const LiveStepDynamicModelSelectionKey: ContextKey; /** * Session-scoped dynamic tool metadata (from `session.started`). * Persists for the session lifetime. */ export declare const SessionDynamicToolMetadataKey: ContextKey; /** * Runtime revision that last resolved session-scoped dynamic tools. * Used to refresh their durable metadata after a deploy or development rebuild. */ export declare const SessionDynamicToolRuntimeRevisionKey: ContextKey; /** * Turn-scoped dynamic tool metadata (from `turn.started`). * Replaced each turn. */ export declare const TurnDynamicToolMetadataKey: ContextKey; export interface LockedMemorySlot { readonly scope: MemoryScope; readonly slot: string; readonly turn: MemoryTurnContext; readonly visibility: "scope" | "session"; } export declare const TurnMemoryLocksKey: ContextKey>>; export interface PreparedMemoryPreamble { readonly projector?: HistoryViewProjector; readonly history: readonly ModelMessage[]; readonly input: readonly ModelMessage[]; readonly state?: Readonly>; } export interface PendingMemoryCommit { /** Records recalled by this operation, to append after the prepared history. */ readonly recalledMessages: readonly ModelMessage[]; readonly state: Readonly>; } export declare const PreparedMemoryPreambleKey: ContextKey; export declare const PendingMemoryCommitKey: ContextKey; export interface PreparedMemoryCompaction { readonly history: readonly ModelMessage[]; readonly state?: Readonly>; } export declare const PreparedMemoryCompactionKey: ContextKey; /** Step-scoped dynamic tool metadata, replaced before each model step. */ export declare const StepDynamicToolMetadataKey: ContextKey; export type DurableDynamicSubagentSelection = { readonly agentConfig: DynamicSubagentAgentConfig; readonly kind: "subagent"; readonly prepared: PreparedRuntimeDelegationTool; readonly remoteAgent?: never; } | { readonly agentConfig?: never; readonly kind: "remote"; readonly prepared: PreparedRuntimeDelegationTool; readonly remoteAgent: DynamicRemoteAgentConfig; } | null; export declare const SessionDynamicSubagentSelectionsKey: ContextKey>>; export declare const TurnDynamicSubagentSelectionsKey: ContextKey>>; export declare const SessionDynamicSubagentRuntimeRevisionKey: ContextKey; export declare const DynamicSubagentAgentConfigKey: ContextKey; /** * Durable state for one session-scoped dynamic skill. */ export interface DurableDynamicSkillMetadata { readonly name: string; /** Listed in the catalog instead of the dynamic skill announcement. */ readonly deferred?: true; readonly description: string; /** `SKILL.md` content as authored; loading strips any frontmatter. */ readonly markdown: string; /** * Content hash of the package files. Present only for packages with * supporting files, which are the only packages written to the sandbox. */ readonly revision?: string; } export type DynamicSkillManifest = Readonly>; /** * Durable map from resolver slug to the qualified skills it last produced. * Used to diff on re-resolution, load skills, and rebuild the model-visible * announcement across turns without a sandbox. */ export declare const DynamicSkillManifestKey: ContextKey>>; /** * Durable map from dynamic skill name to the serialized sandbox session state * that holds its current manifest revision. Refreshes skip writes when the * revision and sandbox are unchanged; deleting the sandbox clears it. */ export declare const DynamicSkillSandboxKey: ContextKey>>; /** * Durable session-scoped instruction messages (from `session.started` * resolvers). Keyed by resolver slug. Persists for the session lifetime. */ export declare const SessionDynamicInstructionsKey: ContextKey>; /** * Durable turn-scoped instruction messages (from `turn.started` * resolvers). Keyed by resolver slug. Replaced each turn. */ export declare const TurnDynamicInstructionsKey: ContextKey>; /** Existing history exposed only to instructions resolvers during a preamble. */ export declare const DynamicInstructionResolveMessagesKey: ContextKey; /** User-role results waiting to be committed immediately after a preamble. */ export declare const PendingDynamicInstructionUserMessagesKey: ContextKey;