import { Inngest } from 'inngest'; import type { EventPayload } from 'inngest/types'; import type { StoreContext } from '../chatkit/store'; import type { AgentRuntimeEvent } from './AgentRuntimeTypes'; import { ManagedRunWorker, type ManagedRunStore } from './ManagedRunWorker'; import type { RunContextRetriever, RunExecutionBackend, RunExecutionInput } from './RunExecutionBackend'; import type { AiConnectionsInvocationKeyIssuer } from '../ai-gateway/auth/AiConnectionsInvocationKeyIssuer'; export declare const XPOD_RUN_REQUESTED_EVENT = "xpod/run.requested"; export declare const XPOD_RUN_CONTINUE_REQUESTED_EVENT = "xpod/run.continue_requested"; export declare const XPOD_AGENT_RUN_FUNCTION_ID = "xpod-agent-run"; export interface XpodRunRequestedEventData { source: string; runId: string; threadId: string; executionKey?: string; authBindingId?: string; webId?: string; continuation?: RunExecutionInput['continuation']; } export type XpodRunRequestedEvent = EventPayload & { name: string; }; export interface InngestRunExecutionBackendOptions { client?: Inngest; source?: string; baseUrl?: string; eventKey?: string; signingKey?: string; isDev?: boolean; runtimeDriver?: RunExecutionBackend; store?: ManagedRunStore; managedRunWorker?: ManagedRunWorker; contextRetriever?: RunContextRetriever; contextResolver?: (data: XpodRunRequestedEventData) => StoreContext | Promise | undefined; contextRecorder?: (context: StoreContext | undefined) => void; aiConnectionInvocationKeyIssuer?: Pick; durableDelivery?: boolean; /** * When true, execute the registered Inngest handler in-process after sending * the event. This keeps Chat streaming low-latency while preserving the * Inngest event/function boundary for the managed-agents backend. */ executeInline?: boolean; } /** * Inngest-backed managed-agent execution backend. * * Xpod owns the Run facts; Inngest owns durable function delivery. In this * first API-facing implementation the function can execute inline so ChatKit * still receives a normal SSE stream without waiting for external polling. * * The in-memory pending map is only the streaming bridge for an active HTTP * request. When no pending stream exists, the registered Inngest function can * restore the Run from store through ManagedRunWorker. */ export declare class InngestRunExecutionBackend implements RunExecutionBackend { private readonly client; private readonly source; private readonly requestedEventName; private readonly continueRequestedEventName; private readonly runtimeDriver; private readonly managedRunWorker?; private readonly contextResolver?; private readonly contextRecorder?; private readonly aiConnectionInvocationKeyIssuer?; private readonly executeInline; private readonly durableDelivery; private readonly pendingRuns; readonly agentRunFunction: import("inngest").InngestFunction Promise>>>; waitForSignal: (idOrOptions: import("inngest").StepOptionsOrId, opts: { signal: string; timeout: number | string | Date | import("inngest").DurationLike | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike; onConflict: "replace" | "fail"; }) => Promise<{ signal: string; data: import("inngest/types").Jsonify; } | null>; realtime: { publish: (idOrOptions: import("inngest").StepOptionsOrId, topicRef: import("inngest").Realtime.TopicRef, data: TData) => Promise; }; sendSignal: (idOrOptions: import("inngest").StepOptionsOrId, opts: { signal: string; data?: unknown; }) => Promise; waitForEvent: ; timeout: number | string | Date | import("inngest").DurationLike | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike; } & import("inngest").ExclusiveKeys<{ match?: string; if?: string; }, "match", "if">>(idOrOptions: import("inngest").StepOptionsOrId, opts: TOpts) => Promise>>; } ? { name: TName; data: TData; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : TOpts extends { event: import("inngest").EventType; } ? { name: TName_1; data: Record; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : TOpts extends { event: infer TName_2 extends string; schema: import("inngest").StandardSchemaV1>; } ? { name: TName_2; data: TData_1; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : TOpts extends { event: infer TName_3 extends string; } ? { name: TName_3; data: Record; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : EventPayload | null>; run: unknown>(idOrOptions: import("inngest").StepOptionsOrId, fn: TFn, ...input: Parameters) => Promise) => Promise ? Awaited : ReturnType extends void ? null : ReturnType>>; ai: { infer: (idOrOptions: import("inngest").StepOptionsOrId, options: { model: TAdapter; body: import("inngest").AiAdapter.Input; }) => Promise>; wrap: unknown>(idOrOptions: import("inngest").StepOptionsOrId, fn: TFn, ...input: Parameters) => Promise) => Promise ? Awaited : ReturnType extends void ? null : ReturnType>>; models: { anthropic: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").Anthropic.AiModelOptions], import("inngest").Anthropic.AiModel>; gemini: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").Gemini.AiModelOptions], import("inngest").Gemini.AiModel>; openai: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").OpenAi.AiModelOptions], import("inngest").OpenAi.AiModel>; deepseek: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").DeepSeek.AiModelOptions], import("inngest").DeepSeek.AiModel>; grok: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").Grok.AiModelOptions], import("inngest").Grok.AiModel>; }; }; sleep: (idOrOptions: import("inngest").StepOptionsOrId, time: number | string | import("inngest").DurationLike) => Promise; sleepUntil: (idOrOptions: import("inngest").StepOptionsOrId, time: Date | string | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike) => Promise; invoke: (idOrOptions: import("inngest").StepOptionsOrId, opts: { function: TFunction; } & Omit, "id"> & { meta?: import("inngest").EventMeta; timeout?: number | string | Date | import("inngest").DurationLike | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike; }) => import("inngest/types").InvocationResult>>; fetch: import("inngest").StepFetch; }, [{ readonly event: string; }, { readonly event: string; }], Omit, never> & Record & { logger: import("inngest").Logger; }, "group" | "step" | "requestId" | "event" | "attempt" | "events" | "runId" | "defer" | "jobId" | "maxAttempts"> & import("inngest").FailureEventArgs> & { step: { sendEvent: (idOrOptions: import("inngest").StepOptionsOrId, payload: import("inngest").SendEventPayload) => Promise>>>; waitForSignal: (idOrOptions: import("inngest").StepOptionsOrId, opts: { signal: string; timeout: number | string | Date | import("inngest").DurationLike | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike; onConflict: "replace" | "fail"; }) => Promise<{ signal: string; data: import("inngest/types").Jsonify; } | null>; realtime: { publish: (idOrOptions: import("inngest").StepOptionsOrId, topicRef: import("inngest").Realtime.TopicRef, data: TData) => Promise; }; sendSignal: (idOrOptions: import("inngest").StepOptionsOrId, opts: { signal: string; data?: unknown; }) => Promise; waitForEvent: ; timeout: number | string | Date | import("inngest").DurationLike | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike; } & import("inngest").ExclusiveKeys<{ match?: string; if?: string; }, "match", "if">>(idOrOptions: import("inngest").StepOptionsOrId, opts: TOpts) => Promise>>; } ? { name: TName; data: TData; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : TOpts extends { event: import("inngest").EventType; } ? { name: TName_1; data: Record; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : TOpts extends { event: infer TName_2 extends string; schema: import("inngest").StandardSchemaV1>; } ? { name: TName_2; data: TData_1; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : TOpts extends { event: infer TName_3 extends string; } ? { name: TName_3; data: Record; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : EventPayload | null>; run: unknown>(idOrOptions: import("inngest").StepOptionsOrId, fn: TFn, ...input: Parameters) => Promise) => Promise ? Awaited : ReturnType extends void ? null : ReturnType>>; ai: { infer: (idOrOptions: import("inngest").StepOptionsOrId, options: { model: TAdapter; body: import("inngest").AiAdapter.Input; }) => Promise>; wrap: unknown>(idOrOptions: import("inngest").StepOptionsOrId, fn: TFn, ...input: Parameters) => Promise) => Promise ? Awaited : ReturnType extends void ? null : ReturnType>>; models: { anthropic: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").Anthropic.AiModelOptions], import("inngest").Anthropic.AiModel>; gemini: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").Gemini.AiModelOptions], import("inngest").Gemini.AiModel>; openai: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").OpenAi.AiModelOptions], import("inngest").OpenAi.AiModel>; deepseek: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").DeepSeek.AiModelOptions], import("inngest").DeepSeek.AiModel>; grok: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").Grok.AiModelOptions], import("inngest").Grok.AiModel>; }; }; sleep: (idOrOptions: import("inngest").StepOptionsOrId, time: number | string | import("inngest").DurationLike) => Promise; sleepUntil: (idOrOptions: import("inngest").StepOptionsOrId, time: Date | string | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike) => Promise; invoke: (idOrOptions: import("inngest").StepOptionsOrId, opts: { function: TFunction; } & Omit, "id"> & { meta?: import("inngest").EventMeta; timeout?: number | string | Date | import("inngest").DurationLike | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike; }) => import("inngest/types").InvocationResult>>; fetch: import("inngest").StepFetch; }; }>>, (ctx: any) => Promise<{ runId: string; status: string; }>, import("inngest").HandlerWithTriggers<{ sendEvent: (idOrOptions: import("inngest").StepOptionsOrId, payload: import("inngest").SendEventPayload) => Promise>>>; waitForSignal: (idOrOptions: import("inngest").StepOptionsOrId, opts: { signal: string; timeout: number | string | Date | import("inngest").DurationLike | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike; onConflict: "replace" | "fail"; }) => Promise<{ signal: string; data: import("inngest/types").Jsonify; } | null>; realtime: { publish: (idOrOptions: import("inngest").StepOptionsOrId, topicRef: import("inngest").Realtime.TopicRef, data: TData) => Promise; }; sendSignal: (idOrOptions: import("inngest").StepOptionsOrId, opts: { signal: string; data?: unknown; }) => Promise; waitForEvent: ; timeout: number | string | Date | import("inngest").DurationLike | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike; } & import("inngest").ExclusiveKeys<{ match?: string; if?: string; }, "match", "if">>(idOrOptions: import("inngest").StepOptionsOrId, opts: TOpts) => Promise>>; } ? { name: TName; data: TData; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : TOpts extends { event: import("inngest").EventType; } ? { name: TName_1; data: Record; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : TOpts extends { event: infer TName_2 extends string; schema: import("inngest").StandardSchemaV1>; } ? { name: TName_2; data: TData_1; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : TOpts extends { event: infer TName_3 extends string; } ? { name: TName_3; data: Record; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : EventPayload | null>; run: unknown>(idOrOptions: import("inngest").StepOptionsOrId, fn: TFn, ...input: Parameters) => Promise) => Promise ? Awaited : ReturnType extends void ? null : ReturnType>>; ai: { infer: (idOrOptions: import("inngest").StepOptionsOrId, options: { model: TAdapter; body: import("inngest").AiAdapter.Input; }) => Promise>; wrap: unknown>(idOrOptions: import("inngest").StepOptionsOrId, fn: TFn, ...input: Parameters) => Promise) => Promise ? Awaited : ReturnType extends void ? null : ReturnType>>; models: { anthropic: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").Anthropic.AiModelOptions], import("inngest").Anthropic.AiModel>; gemini: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").Gemini.AiModelOptions], import("inngest").Gemini.AiModel>; openai: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").OpenAi.AiModelOptions], import("inngest").OpenAi.AiModel>; deepseek: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").DeepSeek.AiModelOptions], import("inngest").DeepSeek.AiModel>; grok: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").Grok.AiModelOptions], import("inngest").Grok.AiModel>; }; }; sleep: (idOrOptions: import("inngest").StepOptionsOrId, time: number | string | import("inngest").DurationLike) => Promise; sleepUntil: (idOrOptions: import("inngest").StepOptionsOrId, time: Date | string | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike) => Promise; invoke: (idOrOptions: import("inngest").StepOptionsOrId, opts: { function: TFunction; } & Omit, "id"> & { meta?: import("inngest").EventMeta; timeout?: number | string | Date | import("inngest").DurationLike | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike; }) => import("inngest/types").InvocationResult>>; fetch: import("inngest").StepFetch; }, [{ readonly event: string; }, { readonly event: string; }], Omit, never> & Record & { logger: import("inngest").Logger; }, "group" | "step" | "requestId" | "event" | "attempt" | "events" | "runId" | "defer" | "jobId" | "maxAttempts"> & import("inngest").FailureEventArgs> & { step: { sendEvent: (idOrOptions: import("inngest").StepOptionsOrId, payload: import("inngest").SendEventPayload) => Promise>>>; waitForSignal: (idOrOptions: import("inngest").StepOptionsOrId, opts: { signal: string; timeout: number | string | Date | import("inngest").DurationLike | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike; onConflict: "replace" | "fail"; }) => Promise<{ signal: string; data: import("inngest/types").Jsonify; } | null>; realtime: { publish: (idOrOptions: import("inngest").StepOptionsOrId, topicRef: import("inngest").Realtime.TopicRef, data: TData) => Promise; }; sendSignal: (idOrOptions: import("inngest").StepOptionsOrId, opts: { signal: string; data?: unknown; }) => Promise; waitForEvent: ; timeout: number | string | Date | import("inngest").DurationLike | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike; } & import("inngest").ExclusiveKeys<{ match?: string; if?: string; }, "match", "if">>(idOrOptions: import("inngest").StepOptionsOrId, opts: TOpts) => Promise>>; } ? { name: TName; data: TData; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : TOpts extends { event: import("inngest").EventType; } ? { name: TName_1; data: Record; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : TOpts extends { event: infer TName_2 extends string; schema: import("inngest").StandardSchemaV1>; } ? { name: TName_2; data: TData_1; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : TOpts extends { event: infer TName_3 extends string; } ? { name: TName_3; data: Record; id: string; ts: number; v?: string; meta?: import("inngest").ReceivedEventMeta; } | null : EventPayload | null>; run: unknown>(idOrOptions: import("inngest").StepOptionsOrId, fn: TFn, ...input: Parameters) => Promise) => Promise ? Awaited : ReturnType extends void ? null : ReturnType>>; ai: { infer: (idOrOptions: import("inngest").StepOptionsOrId, options: { model: TAdapter; body: import("inngest").AiAdapter.Input; }) => Promise>; wrap: unknown>(idOrOptions: import("inngest").StepOptionsOrId, fn: TFn, ...input: Parameters) => Promise) => Promise ? Awaited : ReturnType extends void ? null : ReturnType>>; models: { anthropic: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").Anthropic.AiModelOptions], import("inngest").Anthropic.AiModel>; gemini: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").Gemini.AiModelOptions], import("inngest").Gemini.AiModel>; openai: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").OpenAi.AiModelOptions], import("inngest").OpenAi.AiModel>; deepseek: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").DeepSeek.AiModelOptions], import("inngest").DeepSeek.AiModel>; grok: import("inngest").AiAdapter.ModelCreator<[options: import("inngest").Grok.AiModelOptions], import("inngest").Grok.AiModel>; }; }; sleep: (idOrOptions: import("inngest").StepOptionsOrId, time: number | string | import("inngest").DurationLike) => Promise; sleepUntil: (idOrOptions: import("inngest").StepOptionsOrId, time: Date | string | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike) => Promise; invoke: (idOrOptions: import("inngest").StepOptionsOrId, opts: { function: TFunction; } & Omit, "id"> & { meta?: import("inngest").EventMeta; timeout?: number | string | Date | import("inngest").DurationLike | import("inngest").InstantLike | import("inngest").ZonedDateTimeLike; }) => import("inngest/types").InvocationResult>>; fetch: import("inngest").StepFetch; }; }>, Inngest, [{ readonly event: string; }, { readonly event: string; }]>; constructor(options?: InngestRunExecutionBackendOptions); getClient(): Inngest; getSource(): string; start(input: RunExecutionInput): AsyncIterable; private handleAgentRun; restoreExecutionInput(runId: string, context: StoreContext): Promise; close(): Promise; private createInlineContext; private formatError; private executionKeyForInput; private contextEventData; }