import { r as KlawConfig, t as ConfigFileSnapshot } from "./types.klaw-xKUw_Rz7.js"; import { O as SessionMaintenanceMode } from "./types.base-Dkv2492C.js"; import { o as SsrFPolicy } from "./ssrf-q-9Uof1-.js"; import { t as ModelProviderRequestTransportOverrides } from "./provider-request-config-DbzBMOuZ.js"; import { n as requestHeartbeat, t as HeartbeatRunResult } from "./heartbeat-wake-B4FIqrrU.js"; import { t as ConfigWriteAfterWrite } from "./runtime-snapshot-BAxn4s6n.js"; import { S as ConfigReplaceResult, m as ConfigMutationBase } from "./config-DrrBI5K4.js"; import { v as resolveStateDir } from "./paths-C75S1-ZG.js"; import { i as ThinkingCatalogEntry, r as ThinkLevel } from "./thinking.shared-B0i5nFYk.js"; import { h as EmbeddedPiRunResult, r as RunEmbeddedPiAgentParams } from "./params-Dn0c2Mlz.js"; import { o as ChannelRouteRef } from "./channel-route-DFDmK4kO.js"; import { t as DeliveryContext } from "./delivery-context.types-DI5lShOQ.js"; import { r as GroupKeyResolution, s as SessionEntry } from "./types-XfK0DXQJ.js"; import { t as FallbackAttempt } from "./model-fallback.types-C_orP3Pu.js"; import { n as DEFAULT_MODEL, r as DEFAULT_PROVIDER } from "./defaults-DYgLA5cx.js"; import { M as resolveAgentDir, N as resolveAgentWorkspaceDir } from "./agent-scope-B_s-qZfz.js"; import { n as resolveAgentIdentity } from "./identity-Dhui1gaI.js"; import { t as ModelCatalogEntry } from "./model-catalog.types-DT_5duBc.js"; import { n as ensureAgentWorkspace } from "./workspace-Dn-MZB8C.js"; import { a as updateSessionStore, d as resolveSessionFilePath, l as loadSessionStore, m as resolveStorePath, o as updateSessionStoreEntry } from "./store-CGcilHJ_.js"; import { s as AuthProfileStore } from "./types-ox6Zbtju.js"; import { n as MsgContext } from "./templating-B8JLQEN3.js"; import { o as enqueueSystemEvent } from "./system-events-C2reew94.js"; import { a as runCommandWithTimeout } from "./exec-Chz9ewyX.js"; import { s as mediaKindFromMime } from "./constants-nVHq1DXW.js"; import { f as resizeToJpeg, s as getImageMetadata } from "./image-ops-HCYsihHN.js"; import { n as loadWebMedia } from "./web-media-C26-UbU1.js"; import { n as detectMime } from "./mime-i2672JzP.js"; import { r as isVoiceCompatibleAudio } from "./audio-COJVfOz4.js"; import { _ as ImageGenerationSourceImage, c as ImageGenerationOutputFormat, f as ImageGenerationProviderOptions, h as ImageGenerationResolution, i as ImageGenerationNormalization, l as ImageGenerationProvider, n as ImageGenerationBackground, p as ImageGenerationQuality, r as ImageGenerationIgnoredOverride, t as GeneratedImageAsset } from "./types-FQdSJe7R.js"; import { d as VideoGenerationResolution, n as VideoGenerationIgnoredOverride, o as VideoGenerationNormalization, p as VideoGenerationSourceAsset, s as VideoGenerationProvider, t as GeneratedVideoAsset } from "./types-COw2PPSK.js"; import { c as MusicGenerationProvider, f as MusicGenerationSourceImage, o as MusicGenerationNormalization, r as MusicGenerationIgnoredOverride, s as MusicGenerationOutputFormat, t as GeneratedMusicAsset } from "./types-D2x6bXzX.js"; import { n as RuntimeEnv } from "./runtime-BPmgxFyD.js"; import { n as RuntimeWebSearchMetadata, t as RuntimeWebFetchMetadata } from "./runtime-web-tools.types-DfmQLp3d.js"; import { i as WizardPrompter } from "./prompts-BamwNu0a.js"; import { t as SecretInputMode } from "./provider-auth-types-CMPBtz92.js"; import { a as onAgentEvent } from "./agent-events-DOqfzMqh.js"; import { a as shouldLogVerbose } from "./globals-CUxknoam.js"; import { a as TaskRegistrySummary, c as TaskScopeKind, d as TaskTerminalOutcome, i as TaskRecord, l as TaskStatus, n as TaskDeliveryStatus, o as TaskRuntime, r as TaskNotifyPolicy, s as TaskRuntimeCounts, t as TaskDeliveryState, u as TaskStatusCounts } from "./task-registry.types-CVF0LO-p.js"; import { n as TaskFlowRecord, r as TaskFlowStatus, t as JsonValue } from "./task-flow-registry.types-BJh7p80m.js"; import { r as AnyAgentTool } from "./common-BtCut1Uo.js"; import { t as HookEntry } from "./types-CZ5dWnd9.js"; import { n as LogLevel } from "./levels-Dt-FmjoI.js"; import { a as MediaUnderstandingRuntime } from "./runtime-types-82iUEaT7.js"; import { i as TextToSpeechTelephony, n as TextToSpeech, r as TextToSpeechStream, t as ListSpeechVoices } from "./tts-runtime.types-ME5-eV7L.js"; import { TSchema } from "typebox"; import * as _$_earendil_works_pi_ai0 from "@earendil-works/pi-ai"; //#region src/agents/timeout.d.ts declare function resolveAgentTimeoutMs(opts: { cfg?: KlawConfig; overrideMs?: number | null; overrideSeconds?: number | null; minMs?: number; }): number; //#endregion //#region src/config/sessions/runtime-types.d.ts type ReadSessionUpdatedAt = (params: { storePath: string; sessionKey: string; }) => number | undefined; type SessionMaintenanceWarningRuntime = { activeSessionKey: string; activeUpdatedAt?: number; totalEntries: number; pruneAfterMs: number; maxEntries: number; wouldPrune: boolean; wouldCap: boolean; }; type ResolvedSessionMaintenanceConfigRuntime = { mode: SessionMaintenanceMode; pruneAfterMs: number; maxEntries: number; resetArchiveRetentionMs: number | null; maxDiskBytes: number | null; highWaterBytes: number | null; }; type SessionMaintenanceApplyReportRuntime = { mode: SessionMaintenanceMode; beforeCount: number; afterCount: number; pruned: number; capped: number; diskBudget: Record | null; }; type SaveSessionStoreOptions = { skipMaintenance?: boolean; activeSessionKey?: string; allowDropAcpMetaSessionKeys?: string[]; onWarn?: (warning: SessionMaintenanceWarningRuntime) => void | Promise; onMaintenanceApplied?: (report: SessionMaintenanceApplyReportRuntime) => void | Promise; maintenanceOverride?: Partial; }; type SaveSessionStore = (storePath: string, store: Record, opts?: SaveSessionStoreOptions) => Promise; type RecordSessionMetaFromInbound = (params: { storePath: string; sessionKey: string; ctx: MsgContext; groupResolution?: GroupKeyResolution | null; createIfMissing?: boolean; }) => Promise; type UpdateLastRoute = (params: { storePath: string; sessionKey: string; channel?: SessionEntry["lastChannel"]; to?: string; accountId?: string; threadId?: string | number; route?: ChannelRouteRef; deliveryContext?: DeliveryContext; ctx?: MsgContext; groupResolution?: GroupKeyResolution | null; createIfMissing?: boolean; }) => Promise; //#endregion //#region src/plugins/runtime/native-deps.d.ts type NativeDependencyHintParams = { packageName: string; manager?: "pnpm" | "npm" | "yarn"; rebuildCommand?: string; approveBuildsCommand?: string; downloadCommand?: string; }; declare function formatNativeDependencyHint(params: NativeDependencyHintParams): string; //#endregion //#region src/image-generation/runtime-types.d.ts type GenerateImageParams = { cfg: KlawConfig; prompt: string; agentDir?: string; authStore?: AuthProfileStore; modelOverride?: string; count?: number; size?: string; aspectRatio?: string; resolution?: ImageGenerationResolution; quality?: ImageGenerationQuality; outputFormat?: ImageGenerationOutputFormat; background?: ImageGenerationBackground; inputImages?: ImageGenerationSourceImage[]; autoProviderFallback?: boolean; /** Optional per-request provider timeout in milliseconds. */ timeoutMs?: number; providerOptions?: ImageGenerationProviderOptions; /** SSRF policy to propagate into image-generation provider HTTP calls. */ ssrfPolicy?: SsrFPolicy; }; type GenerateImageRuntimeResult = { images: GeneratedImageAsset[]; provider: string; model: string; attempts: FallbackAttempt[]; normalization?: ImageGenerationNormalization; metadata?: Record; ignoredOverrides: ImageGenerationIgnoredOverride[]; }; type ListRuntimeImageGenerationProvidersParams = { config?: KlawConfig; }; type RuntimeImageGenerationProvider = ImageGenerationProvider; //#endregion //#region src/video-generation/runtime-types.d.ts type GenerateVideoParams = { cfg: KlawConfig; prompt: string; agentDir?: string; authStore?: AuthProfileStore; modelOverride?: string; size?: string; aspectRatio?: string; resolution?: VideoGenerationResolution; durationSeconds?: number; audio?: boolean; watermark?: boolean; inputImages?: VideoGenerationSourceAsset[]; inputVideos?: VideoGenerationSourceAsset[]; inputAudios?: VideoGenerationSourceAsset[]; autoProviderFallback?: boolean; /** Arbitrary provider-specific options forwarded as-is to provider.generateVideo. */ providerOptions?: Record; /** Optional per-request provider timeout in milliseconds. */ timeoutMs?: number; }; type GenerateVideoRuntimeResult = { videos: GeneratedVideoAsset[]; provider: string; model: string; attempts: FallbackAttempt[]; normalization?: VideoGenerationNormalization; metadata?: Record; ignoredOverrides: VideoGenerationIgnoredOverride[]; }; type ListRuntimeVideoGenerationProvidersParams = { config?: KlawConfig; }; type RuntimeVideoGenerationProvider = VideoGenerationProvider; //#endregion //#region src/music-generation/runtime-types.d.ts type GenerateMusicParams = { cfg: KlawConfig; prompt: string; agentDir?: string; authStore?: AuthProfileStore; modelOverride?: string; lyrics?: string; instrumental?: boolean; durationSeconds?: number; format?: MusicGenerationOutputFormat; inputImages?: MusicGenerationSourceImage[]; autoProviderFallback?: boolean; /** Optional per-request provider timeout in milliseconds. */ timeoutMs?: number; }; type GenerateMusicRuntimeResult = { tracks: GeneratedMusicAsset[]; provider: string; model: string; attempts: FallbackAttempt[]; lyrics?: string[]; normalization?: MusicGenerationNormalization; metadata?: Record; ignoredOverrides: MusicGenerationIgnoredOverride[]; }; type ListRuntimeMusicGenerationProvidersParams = { config?: KlawConfig; }; type RuntimeMusicGenerationProvider = MusicGenerationProvider; //#endregion //#region src/plugins/web-provider-types.d.ts type WebSearchProviderId = string; type WebFetchProviderId = string; type WebSearchProviderToolDefinition = { description: string; parameters: TSchema; execute: (args: Record, context?: WebSearchProviderToolExecutionContext) => Promise>; }; type WebFetchProviderToolDefinition = { description: string; parameters: TSchema; execute: (args: Record) => Promise>; }; type WebSearchProviderContext = { config?: KlawConfig; searchConfig?: Record; runtimeMetadata?: RuntimeWebSearchMetadata; }; type WebSearchProviderToolExecutionContext = { signal?: AbortSignal; }; type WebFetchProviderContext = { config?: KlawConfig; fetchConfig?: Record; runtimeMetadata?: RuntimeWebFetchMetadata; }; type WebSearchCredentialResolutionSource = "config" | "secretRef" | "env" | "missing"; type WebSearchProviderConfiguredCredentialFallback = { path: string; value: unknown; }; type WebFetchProviderConfiguredCredentialFallback = { path: string; value: unknown; }; type WebSearchRuntimeMetadataContext = { config?: KlawConfig; searchConfig?: Record; runtimeMetadata?: RuntimeWebSearchMetadata; resolvedCredential?: { value?: string; source: WebSearchCredentialResolutionSource; fallbackEnvVar?: string; }; }; type WebSearchProviderSetupContext = { config: KlawConfig; runtime: RuntimeEnv; prompter: WizardPrompter; quickstartDefaults?: boolean; secretInputMode?: SecretInputMode; }; type WebFetchCredentialResolutionSource = "config" | "secretRef" | "env" | "missing"; type WebFetchRuntimeMetadataContext = { config?: KlawConfig; fetchConfig?: Record; runtimeMetadata?: RuntimeWebFetchMetadata; resolvedCredential?: { value?: string; source: WebFetchCredentialResolutionSource; fallbackEnvVar?: string; }; }; type WebSearchProviderPlugin = { id: WebSearchProviderId; label: string; hint: string; onboardingScopes?: readonly "text-inference"[]; requiresCredential?: boolean; credentialLabel?: string; envVars: string[]; placeholder: string; signupUrl: string; docsUrl?: string; /** Optional note shown before credential collection for provider-specific prerequisites. */ credentialNote?: string; autoDetectOrder?: number; credentialPath: string; inactiveSecretPaths?: string[]; getCredentialValue: (searchConfig?: Record) => unknown; setCredentialValue: (searchConfigTarget: Record, value: unknown) => void; getConfiguredCredentialValue?: (config?: KlawConfig) => unknown; setConfiguredCredentialValue?: (configTarget: KlawConfig, value: unknown) => void; getConfiguredCredentialFallback?: (config?: KlawConfig) => WebSearchProviderConfiguredCredentialFallback | undefined; applySelectionConfig?: (config: KlawConfig) => KlawConfig; runSetup?: (ctx: WebSearchProviderSetupContext) => KlawConfig | Promise; resolveRuntimeMetadata?: (ctx: WebSearchRuntimeMetadataContext) => Partial | Promise>; createTool: (ctx: WebSearchProviderContext) => WebSearchProviderToolDefinition | null; }; type PluginWebSearchProviderEntry = WebSearchProviderPlugin & { pluginId: string; }; type WebFetchProviderPlugin = { id: WebFetchProviderId; label: string; hint: string; requiresCredential?: boolean; credentialLabel?: string; envVars: string[]; placeholder: string; signupUrl: string; docsUrl?: string; autoDetectOrder?: number; credentialPath: string; inactiveSecretPaths?: string[]; getCredentialValue: (fetchConfig?: Record) => unknown; setCredentialValue: (fetchConfigTarget: Record, value: unknown) => void; getConfiguredCredentialValue?: (config?: KlawConfig) => unknown; setConfiguredCredentialValue?: (configTarget: KlawConfig, value: unknown) => void; getConfiguredCredentialFallback?: (config?: KlawConfig) => WebFetchProviderConfiguredCredentialFallback | undefined; applySelectionConfig?: (config: KlawConfig) => KlawConfig; resolveRuntimeMetadata?: (ctx: WebFetchRuntimeMetadataContext) => Partial | Promise>; createTool: (ctx: WebFetchProviderContext) => WebFetchProviderToolDefinition | null; }; type PluginWebFetchProviderEntry = WebFetchProviderPlugin & { pluginId: string; }; //#endregion //#region src/web-search/runtime-types.d.ts type ResolveWebSearchDefinitionParams = { config?: KlawConfig; sandboxed?: boolean; runtimeWebSearch?: RuntimeWebSearchMetadata; providerId?: string; preferRuntimeProviders?: boolean; preferInputConfig?: boolean; }; type RunWebSearchParams = ResolveWebSearchDefinitionParams & { args: Record; signal?: AbortSignal; }; type RunWebSearchResult = { provider: string; result: Record; }; type ListWebSearchProvidersParams = { config?: KlawConfig; }; type RuntimeWebSearchProviderEntry = PluginWebSearchProviderEntry; //#endregion //#region src/sessions/transcript-events.d.ts type SessionTranscriptUpdate = { sessionFile: string; sessionKey?: string; message?: unknown; messageId?: string; messageSeq?: number; }; type SessionTranscriptListener = (update: SessionTranscriptUpdate) => void; declare function onSessionTranscriptUpdate(listener: SessionTranscriptListener): () => void; declare function emitSessionTranscriptUpdate(update: string | SessionTranscriptUpdate): void; //#endregion //#region src/plugin-state/plugin-state-store.types.d.ts type PluginStateEntry = { key: string; value: T; createdAt: number; expiresAt?: number; }; type PluginStateKeyedStore = { register(key: string, value: T, opts?: { ttlMs?: number; }): Promise; registerIfAbsent(key: string, value: T, opts?: { ttlMs?: number; }): Promise; lookup(key: string): Promise; consume(key: string): Promise; delete(key: string): Promise; entries(): Promise[]>; clear(): Promise; }; type OpenKeyedStoreOptions = { namespace: string; maxEntries: number; defaultTtlMs?: number; }; //#endregion //#region src/agents/tool-fs-policy.types.d.ts type ToolFsPolicy = { workspaceOnly: boolean; }; //#endregion //#region src/plugins/tool-types.d.ts type KlawPluginActiveModelContext = { provider?: string; modelId?: string; modelRef?: string; }; /** Trusted execution context passed to plugin-owned agent tool factories. */ type KlawPluginToolContext = { config?: KlawConfig; /** Active runtime-resolved config snapshot when one is available. */ runtimeConfig?: KlawConfig; /** Returns the latest runtime-resolved config snapshot for long-lived tool definitions. */ getRuntimeConfig?: () => KlawConfig | undefined; /** Effective filesystem policy for the active tool run. */ fsPolicy?: ToolFsPolicy; workspaceDir?: string; agentDir?: string; agentId?: string; sessionKey?: string; /** Ephemeral session UUID - regenerated on /new and /reset. Use for per-conversation isolation. */ sessionId?: string; /** * Runtime-supplied active model metadata for informational use, diagnostics, * and plugin-owned policy decisions. This is not a security boundary against * the local operator, installed plugin code, or a modified Klaw runtime. */ activeModel?: KlawPluginActiveModelContext; browser?: { sandboxBridgeUrl?: string; allowHostControl?: boolean; }; messageChannel?: string; agentAccountId?: string; /** Trusted provider auth availability from the active auth profile store. */ hasAuthForProvider?: (providerId: string) => boolean; /** Resolves an API key from the active auth profile store when available. */ resolveApiKeyForProvider?: (providerId: string) => Promise; /** Trusted ambient delivery route for the active agent/session. */ deliveryContext?: DeliveryContext; /** Trusted sender id from inbound context (runtime-provided, not tool args). */ requesterSenderId?: string; /** Whether the trusted sender is an owner. */ senderIsOwner?: boolean; sandboxed?: boolean; }; type KlawPluginToolFactory = (ctx: KlawPluginToolContext) => AnyAgentTool | AnyAgentTool[] | null | undefined; type KlawPluginToolOptions = { name?: string; names?: string[]; optional?: boolean; }; type KlawPluginHookOptions = { entry?: HookEntry; name?: string; description?: string; register?: boolean; }; //#endregion //#region src/plugins/runtime/runtime-taskflow.types.d.ts type ManagedTaskFlowRecord = TaskFlowRecord & { syncMode: "managed"; controllerId: string; }; type ManagedTaskFlowMutationErrorCode = "not_found" | "not_managed" | "revision_conflict"; type ManagedTaskFlowMutationResult = { applied: true; flow: ManagedTaskFlowRecord; } | { applied: false; code: ManagedTaskFlowMutationErrorCode; current?: TaskFlowRecord; }; type BoundTaskFlowTaskRunResult = { created: true; flow: ManagedTaskFlowRecord; task: TaskRecord; } | { created: false; reason: string; found: boolean; flow?: TaskFlowRecord; }; type BoundTaskFlowCancelResult = { found: boolean; cancelled: boolean; reason?: string; flow?: TaskFlowRecord; tasks?: TaskRecord[]; }; type BoundTaskFlowRuntime = { readonly sessionKey: string; readonly requesterOrigin?: TaskDeliveryState["requesterOrigin"]; createManaged: (params: { controllerId: string; goal: string; status?: ManagedTaskFlowRecord["status"]; notifyPolicy?: TaskNotifyPolicy; currentStep?: string | null; stateJson?: JsonValue | null; waitJson?: JsonValue | null; cancelRequestedAt?: number | null; createdAt?: number; updatedAt?: number; endedAt?: number | null; }) => ManagedTaskFlowRecord; get: (flowId: string) => TaskFlowRecord | undefined; list: () => TaskFlowRecord[]; findLatest: () => TaskFlowRecord | undefined; resolve: (token: string) => TaskFlowRecord | undefined; getTaskSummary: (flowId: string) => TaskRegistrySummary | undefined; setWaiting: (params: { flowId: string; expectedRevision: number; currentStep?: string | null; stateJson?: JsonValue | null; waitJson?: JsonValue | null; blockedTaskId?: string | null; blockedSummary?: string | null; updatedAt?: number; }) => ManagedTaskFlowMutationResult; resume: (params: { flowId: string; expectedRevision: number; status?: Extract; currentStep?: string | null; stateJson?: JsonValue | null; updatedAt?: number; }) => ManagedTaskFlowMutationResult; finish: (params: { flowId: string; expectedRevision: number; stateJson?: JsonValue | null; updatedAt?: number; endedAt?: number; }) => ManagedTaskFlowMutationResult; fail: (params: { flowId: string; expectedRevision: number; stateJson?: JsonValue | null; blockedTaskId?: string | null; blockedSummary?: string | null; updatedAt?: number; endedAt?: number; }) => ManagedTaskFlowMutationResult; requestCancel: (params: { flowId: string; expectedRevision: number; cancelRequestedAt?: number; }) => ManagedTaskFlowMutationResult; cancel: (params: { flowId: string; cfg: KlawConfig; }) => Promise; runTask: (params: { flowId: string; runtime: TaskRuntime; sourceId?: string; childSessionKey?: string; parentTaskId?: string; agentId?: string; runId?: string; label?: string; task: string; preferMetadata?: boolean; notifyPolicy?: TaskNotifyPolicy; deliveryStatus?: TaskDeliveryStatus; status?: "queued" | "running"; startedAt?: number; lastEventAt?: number; progressSummary?: string | null; }) => BoundTaskFlowTaskRunResult; }; type PluginRuntimeTaskFlow = { bindSession: (params: { sessionKey: string; requesterOrigin?: TaskDeliveryState["requesterOrigin"]; }) => BoundTaskFlowRuntime; fromToolContext: (ctx: Pick) => BoundTaskFlowRuntime; }; //#endregion //#region src/agents/model-auth-runtime-shared.d.ts type ResolvedProviderAuth = { apiKey?: string; profileId?: string; source: string; mode: "api-key" | "oauth" | "token" | "aws-sdk"; }; declare function resolveAwsSdkEnvVarName(env?: NodeJS.ProcessEnv): string | undefined; declare function formatMissingAuthError(auth: ResolvedProviderAuth, provider: string): string; declare function requireApiKey(auth: ResolvedProviderAuth, provider: string): string; //#endregion //#region src/plugins/runtime/model-auth-types.d.ts /** * Runtime-ready auth result exposed to native plugins and context engines. * * `source`, `mode`, and `profileId` describe how the original credential was * resolved. `apiKey` is the request-ready credential after any provider-owned * runtime exchange, so it may differ from the stored/raw credential. */ type ResolvedProviderRuntimeAuth = Omit & { apiKey?: string; baseUrl?: string; request?: ModelProviderRequestTransportOverrides; expiresAt?: number; }; //#endregion //#region src/plugins/runtime/task-domain-types.d.ts type TaskRunAggregateSummary = { total: number; active: number; terminal: number; failures: number; byStatus: TaskStatusCounts; byRuntime: TaskRuntimeCounts; }; type TaskRunView = { id: string; runtime: TaskRuntime; sourceId?: string; sessionKey: string; ownerKey: string; scope: TaskScopeKind; childSessionKey?: string; flowId?: string; parentTaskId?: string; agentId?: string; runId?: string; label?: string; title: string; status: TaskStatus; deliveryStatus: TaskDeliveryStatus; notifyPolicy: TaskNotifyPolicy; createdAt: number; startedAt?: number; endedAt?: number; lastEventAt?: number; cleanupAfter?: number; error?: string; progressSummary?: string; terminalSummary?: string; terminalOutcome?: TaskTerminalOutcome; }; type TaskRunDetail = TaskRunView; type TaskRunCancelResult = { found: boolean; cancelled: boolean; reason?: string; task?: TaskRunDetail; }; type TaskFlowView = { id: string; ownerKey: string; requesterOrigin?: DeliveryContext; status: TaskFlowStatus; notifyPolicy: TaskNotifyPolicy; goal: string; currentStep?: string; cancelRequestedAt?: number; createdAt: number; updatedAt: number; endedAt?: number; }; type TaskFlowDetail = TaskFlowView & { state?: JsonValue; wait?: JsonValue; blocked?: { taskId?: string; summary?: string; }; tasks: TaskRunView[]; taskSummary: TaskRunAggregateSummary; }; //#endregion //#region src/plugins/runtime/runtime-tasks.types.d.ts type BoundTaskRunsRuntime = { readonly sessionKey: string; readonly requesterOrigin?: TaskDeliveryState["requesterOrigin"]; get: (taskId: string) => TaskRunDetail | undefined; list: () => TaskRunView[]; findLatest: () => TaskRunDetail | undefined; resolve: (token: string) => TaskRunDetail | undefined; cancel: (params: { taskId: string; cfg: KlawConfig; }) => Promise; }; type PluginRuntimeTaskRuns = { bindSession: (params: { sessionKey: string; requesterOrigin?: TaskDeliveryState["requesterOrigin"]; }) => BoundTaskRunsRuntime; fromToolContext: (ctx: Pick) => BoundTaskRunsRuntime; }; type BoundTaskFlowsRuntime = { readonly sessionKey: string; readonly requesterOrigin?: TaskDeliveryState["requesterOrigin"]; get: (flowId: string) => TaskFlowDetail | undefined; list: () => TaskFlowView[]; findLatest: () => TaskFlowDetail | undefined; resolve: (token: string) => TaskFlowDetail | undefined; getTaskSummary: (flowId: string) => TaskRunAggregateSummary | undefined; }; type PluginRuntimeTaskFlows = { bindSession: (params: { sessionKey: string; requesterOrigin?: TaskDeliveryState["requesterOrigin"]; }) => BoundTaskFlowsRuntime; fromToolContext: (ctx: Pick) => BoundTaskFlowsRuntime; }; type PluginRuntimeTasks = { runs: PluginRuntimeTaskRuns; flows: PluginRuntimeTaskFlows; managedFlows: PluginRuntimeTaskFlow; /** @deprecated Use runtime.tasks.flows for DTO-based TaskFlow access. */ flow: PluginRuntimeTaskFlow; }; //#endregion //#region src/plugins/runtime/types-core.d.ts type RuntimeRequestHeartbeatOptions = Parameters[0]; type RuntimeRequestHeartbeatNowOptions = Omit & Partial>; type RuntimeWriteConfigOptions = { envSnapshotForRestore?: Record; expectedConfigPath?: string; unsetPaths?: string[][]; }; type DeepReadonly = T extends ((...args: never[]) => unknown) ? T : T extends readonly (infer U)[] ? ReadonlyArray> : T extends object ? { readonly [K in keyof T]: DeepReadonly } : T; type RuntimeConfigAfterWrite = ConfigWriteAfterWrite; type RuntimeConfigReplaceResult = ConfigReplaceResult; type RuntimeConfigMutationBase = ConfigMutationBase; type RuntimeConfigMutationContext = { snapshot: ConfigFileSnapshot; previousHash: string | null; }; type RuntimeMutateConfigFileParams = { base?: RuntimeConfigMutationBase; baseHash?: string; afterWrite: RuntimeConfigAfterWrite; writeOptions?: RuntimeWriteConfigOptions; mutate: (draft: KlawConfig, context: RuntimeConfigMutationContext) => Promise | T | void; }; type RuntimeReplaceConfigFileParams = { nextConfig: KlawConfig; baseHash?: string; afterWrite: RuntimeConfigAfterWrite; writeOptions?: RuntimeWriteConfigOptions; }; type PluginRuntimeThinkingPolicyRequest = { provider?: string | null; model?: string | null; catalog?: ThinkingCatalogEntry[]; }; type PluginRuntimeThinkingPolicyLevel = { id: ThinkLevel; label: string; }; type PluginRuntimeThinkingPolicy = { levels: PluginRuntimeThinkingPolicyLevel[]; defaultLevel?: ThinkLevel | null; }; /** Structured logger surface injected into runtime-backed plugin helpers. */ type RuntimeLogger = { debug?: (message: string, meta?: Record) => void; info: (message: string, meta?: Record) => void; warn: (message: string, meta?: Record) => void; error: (message: string, meta?: Record) => void; }; type RunHeartbeatOnceOptions = { reason?: string; agentId?: string; sessionKey?: string; /** Override heartbeat config (e.g. `{ target: "last" }` to deliver to the last active channel). */ heartbeat?: { target?: string; }; }; type LlmCompleteMessage = { role: "system" | "user" | "assistant"; content: string; }; type LlmCompleteCaller = { kind: "plugin" | "context-engine" | "host" | "unknown"; id?: string; name?: string; }; type LlmCompleteUsage = { inputTokens?: number; outputTokens?: number; cacheReadTokens?: number; cacheWriteTokens?: number; totalTokens?: number; costUsd?: number; }; type LlmCompleteParams = { messages: LlmCompleteMessage[]; /** Model ref (e.g. "anthropic/claude-sonnet-4-6"); defaults to the target agent's configured model. */ model?: string; maxTokens?: number; temperature?: number; systemPrompt?: string; signal?: AbortSignal; /** Human-readable reason for audit/debug output. */ purpose?: string; /** Agent whose model/credentials to use. Session-bound capabilities may disallow overrides. */ agentId?: string; }; type LlmCompleteResult = { text: string; provider: string; model: string; agentId: string; usage: LlmCompleteUsage; audit: { caller: LlmCompleteCaller; purpose?: string; sessionKey?: string; }; }; type RuntimeRunEmbeddedPiAgent = (params: RunEmbeddedPiAgentParams) => Promise; /** Core runtime helpers exposed to trusted native plugins. */ type PluginRuntimeCore = { version: string; config: { /** Current process runtime config snapshot. Prefer config passed into the active call path. */current: () => DeepReadonly; /** * Persist a focused config mutation. Callers must choose the post-write * behavior explicitly so the gateway can hot-reload, restart, or defer. */ mutateConfigFile: (params: RuntimeMutateConfigFileParams) => Promise; /** * Persist a full config replacement. Callers must choose the post-write * behavior explicitly so the gateway can hot-reload, restart, or defer. */ replaceConfigFile: (params: RuntimeReplaceConfigFileParams) => Promise; /** * @deprecated Use current(), or pass the already loaded config through the * call path. Runtime code must not reload config on demand. Bundled * plugins and repo code are blocked from using this by the * deprecated-internal-config-api architecture guard. */ loadConfig: () => KlawConfig; /** * @deprecated Use mutateConfigFile() or replaceConfigFile() with an * explicit afterWrite intent so restart behavior stays under host control. * Bundled plugins and repo code are blocked from using this by the * deprecated-internal-config-api architecture guard. */ writeConfigFile: (cfg: KlawConfig, options?: RuntimeWriteConfigOptions & { afterWrite?: RuntimeConfigAfterWrite; }) => Promise; }; agent: { defaults: { model: typeof DEFAULT_MODEL; provider: typeof DEFAULT_PROVIDER; }; resolveAgentDir: typeof resolveAgentDir; resolveAgentWorkspaceDir: typeof resolveAgentWorkspaceDir; resolveAgentIdentity: typeof resolveAgentIdentity; resolveThinkingDefault: (params: { cfg: KlawConfig; provider: string; model: string; catalog?: ModelCatalogEntry[]; }) => ThinkLevel; normalizeThinkingLevel: (raw?: string | null) => ThinkLevel | undefined; resolveThinkingPolicy: (params: PluginRuntimeThinkingPolicyRequest) => PluginRuntimeThinkingPolicy; runEmbeddedAgent: RuntimeRunEmbeddedPiAgent; runEmbeddedPiAgent: RuntimeRunEmbeddedPiAgent; resolveAgentTimeoutMs: typeof resolveAgentTimeoutMs; ensureAgentWorkspace: typeof ensureAgentWorkspace; session: { resolveStorePath: typeof resolveStorePath; loadSessionStore: typeof loadSessionStore; saveSessionStore: SaveSessionStore; updateSessionStore: typeof updateSessionStore; updateSessionStoreEntry: typeof updateSessionStoreEntry; resolveSessionFilePath: typeof resolveSessionFilePath; }; }; system: { enqueueSystemEvent: typeof enqueueSystemEvent; requestHeartbeat: typeof requestHeartbeat; /** * @deprecated Use `requestHeartbeat({ source, intent, reason })` so wake producers declare * scheduler intent explicitly. */ requestHeartbeatNow: (opts?: RuntimeRequestHeartbeatNowOptions) => void; /** * Run a single heartbeat cycle immediately (bypassing the coalesce timer). * Accepts an optional `heartbeat` config override so callers can force * delivery to the last active channel — the same pattern the cron service * uses to avoid the default `target: "none"` suppression. */ runHeartbeatOnce: (opts?: RunHeartbeatOnceOptions) => Promise; runCommandWithTimeout: typeof runCommandWithTimeout; formatNativeDependencyHint: typeof formatNativeDependencyHint; }; media: { loadWebMedia: typeof loadWebMedia; detectMime: typeof detectMime; mediaKindFromMime: typeof mediaKindFromMime; isVoiceCompatibleAudio: typeof isVoiceCompatibleAudio; getImageMetadata: typeof getImageMetadata; resizeToJpeg: typeof resizeToJpeg; }; tts: { textToSpeech: TextToSpeech; textToSpeechStream: TextToSpeechStream; textToSpeechTelephony: TextToSpeechTelephony; listVoices: ListSpeechVoices; }; mediaUnderstanding: { runFile: MediaUnderstandingRuntime["runMediaUnderstandingFile"]; describeImageFile: MediaUnderstandingRuntime["describeImageFile"]; describeImageFileWithModel: MediaUnderstandingRuntime["describeImageFileWithModel"]; extractStructuredWithModel: MediaUnderstandingRuntime["extractStructuredWithModel"]; describeVideoFile: MediaUnderstandingRuntime["describeVideoFile"]; transcribeAudioFile: MediaUnderstandingRuntime["transcribeAudioFile"]; }; imageGeneration: { generate: (params: GenerateImageParams) => Promise; listProviders: (params?: ListRuntimeImageGenerationProvidersParams) => RuntimeImageGenerationProvider[]; }; videoGeneration: { generate: (params: GenerateVideoParams) => Promise; listProviders: (params?: ListRuntimeVideoGenerationProvidersParams) => RuntimeVideoGenerationProvider[]; }; musicGeneration: { generate: (params: GenerateMusicParams) => Promise; listProviders: (params?: ListRuntimeMusicGenerationProvidersParams) => RuntimeMusicGenerationProvider[]; }; webSearch: { listProviders: (params?: ListWebSearchProvidersParams) => RuntimeWebSearchProviderEntry[]; search: (params: RunWebSearchParams) => Promise; }; stt: { transcribeAudioFile: MediaUnderstandingRuntime["transcribeAudioFile"]; }; events: { onAgentEvent: typeof onAgentEvent; onSessionTranscriptUpdate: typeof onSessionTranscriptUpdate; }; logging: { shouldLogVerbose: typeof shouldLogVerbose; getChildLogger: (bindings?: Record, opts?: { level?: LogLevel; }) => RuntimeLogger; }; state: { resolveStateDir: typeof resolveStateDir; openKeyedStore: (options: OpenKeyedStoreOptions) => PluginStateKeyedStore; }; tasks: { runs: PluginRuntimeTaskRuns; flows: PluginRuntimeTaskFlows; managedFlows: PluginRuntimeTaskFlow; /** @deprecated Use runtime.tasks.flows for DTO-based TaskFlow access. */ flow: PluginRuntimeTaskFlow; }; /** @deprecated Use runtime.tasks.flows for DTO-based TaskFlow access. */ taskFlow: PluginRuntimeTaskFlow; llm: { complete: (params: LlmCompleteParams) => Promise; }; modelAuth: { /** Resolve auth for a model. Only provider/model, optional cfg, and workspaceDir are used. */getApiKeyForModel: (params: { model: _$_earendil_works_pi_ai0.Model<_$_earendil_works_pi_ai0.Api>; cfg?: KlawConfig; workspaceDir?: string; }) => Promise; /** Resolve request-ready auth for a model, including provider runtime exchanges. */ getRuntimeAuthForModel: (params: { model: _$_earendil_works_pi_ai0.Model<_$_earendil_works_pi_ai0.Api>; cfg?: KlawConfig; workspaceDir?: string; }) => Promise; /** Resolve auth for a provider by name. Only provider, optional cfg, and workspaceDir are used. */ resolveApiKeyForProvider: (params: { provider: string; cfg?: KlawConfig; workspaceDir?: string; }) => Promise; }; }; //#endregion export { ReadSessionUpdatedAt as $, SessionTranscriptUpdate as A, WebFetchRuntimeMetadataContext as B, resolveAwsSdkEnvVarName as C, KlawPluginToolContext as D, KlawPluginHookOptions as E, WebFetchCredentialResolutionSource as F, WebSearchProviderSetupContext as G, WebSearchProviderContext as H, WebFetchProviderContext as I, WebSearchRuntimeMetadataContext as J, WebSearchProviderToolDefinition as K, WebFetchProviderId as L, onSessionTranscriptUpdate as M, PluginWebFetchProviderEntry as N, KlawPluginToolFactory as O, PluginWebSearchProviderEntry as P, GenerateImageRuntimeResult as Q, WebFetchProviderPlugin as R, requireApiKey as S, KlawPluginActiveModelContext as T, WebSearchProviderId as U, WebSearchCredentialResolutionSource as V, WebSearchProviderPlugin as W, GenerateVideoRuntimeResult as X, GenerateVideoParams as Y, GenerateImageParams as Z, TaskRunDetail as _, LlmCompleteUsage as a, ResolvedProviderAuth as b, BoundTaskFlowsRuntime as c, PluginRuntimeTaskRuns as d, RecordSessionMetaFromInbound as et, PluginRuntimeTasks as f, TaskRunCancelResult as g, TaskRunAggregateSummary as h, LlmCompleteResult as i, emitSessionTranscriptUpdate as j, KlawPluginToolOptions as k, BoundTaskRunsRuntime as l, TaskFlowView as m, LlmCompleteMessage as n, resolveAgentTimeoutMs as nt, PluginRuntimeCore as o, TaskFlowDetail as p, WebSearchProviderToolExecutionContext as q, LlmCompleteParams as r, RuntimeLogger as s, LlmCompleteCaller as t, UpdateLastRoute as tt, PluginRuntimeTaskFlows as u, TaskRunView as v, PluginRuntimeTaskFlow as w, formatMissingAuthError as x, ResolvedProviderRuntimeAuth as y, WebFetchProviderToolDefinition as z };