/** * 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, SystemModelMessage } from "ai"; import type { JsonObject } from "#shared/json.js"; import type { ChannelInstrumentationProjection, SessionAuthContext, SessionCallback, SessionCapabilities, SessionParent, SessionTraceContext, SessionTurn } from "#channel/types.js"; import { ContextKey } from "#context/key.js"; import type { HarnessToolDefinition } from "#harness/execute-tool.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 } from "#sandbox/state.js"; import type { RunMode } from "#shared/run-mode.js"; import type { RuntimeModelReference } from "#runtime/agent/bootstrap.js"; import type { PreparedRuntimeDelegationTool } from "#runtime/sessions/turn.js"; export type { SessionAuthContext, SessionParent, SessionTurn } from "#channel/types.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 sessionId: string; readonly turn: SessionTurn; } export declare const AuthKey: ContextKey; export declare const InitiatorAuthKey: ContextKey; export declare const SessionIdKey: ContextKey; export declare const ContinuationTokenKey: ContextKey; export declare const ChannelRequestIdKey: ContextKey; export declare const ChannelInstrumentationKey: ContextKey; export declare const ModeKey: ContextKey; export declare const ParentSessionKey: ContextKey; /** Separate from {@link ParentSessionKey} so it stays out of what extensions read. */ export declare const ParentTraceContextKey: ContextKey; export declare const SubagentDepthKey: 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; export declare const SessionKey: ContextKey; export declare const SandboxKey: ContextKey; /** 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 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; export interface DurableDynamicToolMetadata { readonly name: string; readonly description: string; readonly inputSchema: JsonObject; readonly outputSchema?: JsonObject; readonly resolverSlug: string; readonly entryKey: string; readonly executeStepFnName?: string; readonly approvalStepFnName?: string; readonly closureVars?: Record; } /** * 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; /** * Virtual (non-serialized) live step-scoped tool definitions from * `step.started` resolvers. Carries original execute closures so * framework tools (which lack bundler step-function metadata) work. * Re-resolved every step — no cross-step persistence needed. */ export declare const LiveStepToolsKey: 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 metadata for one session-scoped dynamic skill. */ export interface DurableDynamicSkillMetadata { readonly name: string; readonly description: string; } /** * Durable map from resolver slug to the qualified skills it last produced. * Used to diff on re-resolution, clean up removed skills from the sandbox, * and rebuild the model-visible announcement across turns. */ export declare const DynamicSkillManifestKey: 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>;