import type { Api, Model } from "@bastani/pi-ai/compat"; import type { ThinkingLevel } from "@earendil-works/pi-agent-core"; import type { ModelRegistry } from "../model-registry.ts"; import type { ScopedModel } from "../model-resolver.ts"; import type { SessionManager } from "../session-manager.ts"; import type { SkillCatalog } from "../skill-catalog.ts"; import type { BuildSystemPromptOptions } from "../system-prompt.ts"; import type { ForkHandler, NavigateTreeHandler, NewSessionHandler, ReloadHandler, SwitchSessionHandler } from "./runner-handlers.ts"; import type { CompactOptions, ContextUsage, ExtensionCommandContext, ExtensionContext, ExtensionMode, ExtensionUIContext, OrchestrationContext, SubagentChildPolicy } from "./types.ts"; export interface ExtensionContextSource { observeWorkflowActivity: ExtensionContext["observeWorkflowActivity"]; getChildSessionOptions?: ExtensionContext["getChildSessionOptions"]; getExtensionPaths?(): string[]; assertActive(): void; assertAction?(): void; getUIContext(): ExtensionUIContext; getMode(): ExtensionMode; hasUI(): boolean; hasHumanInput?(): boolean; isPresentationOnly?(): boolean; getCwd(): string; getSessionManager(): SessionManager; getModelRegistry(): ModelRegistry; getModel(): Model | undefined; getScopedModels(): readonly ScopedModel[]; getThinkingLevel(): ThinkingLevel | undefined; getOrchestrationContext(): OrchestrationContext | undefined; getSubagentPolicy(): SubagentChildPolicy | undefined; isIdle(): boolean; isProjectTrusted(): boolean; getSignal(): AbortSignal | undefined; getSessionSignal(): AbortSignal; abort(): void; hasPendingMessages(): boolean; isSessionSummaryEnabled?(): boolean; generateWorkflowSummary?(text: string, signal: AbortSignal, options?: { terminal?: boolean; }): Promise; shutdown(): void; getContextUsage(): ContextUsage | undefined; compact(options?: CompactOptions): void; getSystemPrompt(): string; getRouterModel?(): string; getModelRouting?(): import("../settings-types.ts").ModelRoutingSettings; getHttpIdleTimeoutMs?(): number; getSkillCatalog?(): SkillCatalog; getAgentTaskHost?(): import("../tasks/agent-adapter.js").AgentTaskHost; } export interface ExtensionCommandContextSource extends ExtensionContextSource { getSystemPromptOptions(): BuildSystemPromptOptions; waitForIdle(): Promise; newSession: NewSessionHandler; fork: ForkHandler; navigateTree: NavigateTreeHandler; switchSession: SwitchSessionHandler; reload: ReloadHandler; } /** * A defensive copy of the model scope, entries included. * * `readonly ScopedModel[]` is a compile-time claim only, so the array is * copied: a JavaScript extension, or one asserting the `readonly` away, could * otherwise push onto the session's own array and have `cycleModel()` treat the * entry as in scope. * * Copying the array alone is not enough. The entries are the session's objects, * so mutating `entry.model` or `entry.thinkingLevel` in place reaches the very * array `cycleModel()` reads, and swaps the model it selects without ever * touching the array. * * Nor is copying the entry and its model one level deep. `Object.freeze` and a * spread both stop at the first level, so `model.headers`, `model.input`, * `model.cost.tiers`, `model.thinkingLevelMap` and `model.compat` stayed the * session's own objects: writing through any of them changed the model used for * selection and request composition, and the freeze reported nothing. The copy * goes all the way down, and freezes all the way down with it, so an attempt * fails loudly under strict mode instead of silently succeeding. * * The accessor reports the scope; it must not be a way to change it. */ export declare function copyScopedModels(scoped: readonly ScopedModel[]): readonly ScopedModel[]; /** Internal lifecycle identity; contexts themselves are recreated for every dispatch. */ export declare function getExtensionContextOwner(context: object): object; type ContextEffect = () => void | Promise; export type ExtensionContextEffectPhase = "start" | "commit"; type ContextPublication = (effect: ContextEffect, phase: ExtensionContextEffectPhase) => void; export declare function bindExtensionContextPublication(context: object, stage: ContextPublication | undefined): void; export declare function runSynchronousExtensionContextEffect(effect: () => void): void; export declare function publishExtensionContextEffect(context: object, effect: () => void, phase: "commit"): Promise; export declare function publishExtensionContextEffect(context: object, effect: ContextEffect, phase?: "start"): Promise; export declare function registerExtensionContextRetirementEffect(context: object, effect: () => void): () => void; export declare function retireExtensionContextEffects(owner: object): void; /** * Create an ExtensionContext for use in event handlers and tool execution. * Context values are resolved at call time, so host changes are reflected. */ export declare function createExtensionContext(source: ExtensionContextSource, owner?: object): ExtensionContext; export declare function createExtensionCommandContext(source: ExtensionCommandContextSource, owner?: object): ExtensionCommandContext; export {}; //# sourceMappingURL=runner-context.d.ts.map